Migrate to svelte 5

This commit is contained in:
kwaroran
2024-10-23 02:31:37 +09:00
parent e434c7ab96
commit c7330719ad
120 changed files with 2398 additions and 2033 deletions

View File

@@ -6,12 +6,12 @@
import Button from "../UI/GUI/Button.svelte";
import { HypaProcesser } from "src/ts/process/memory/hypamemory";
let query = "";
let model = "MiniLM";
let customEmbeddingUrl = "";
let data:string[] = [];
let dataresult:[string, number][] = [];
let running = false;
let query = $state("");
let model = $state("MiniLM");
let customEmbeddingUrl = $state("");
let data:string[] = $state([]);
let dataresult:[string, number][] = $state([]);
let running = $state(false);
const run = async () => {
if(running) return;
@@ -42,10 +42,10 @@
<TextInput bind:value={query} size="lg" fullwidth />
<span class="text-textcolor text-lg mt-6">Data</span>
{#each data as item}
<TextInput bind:value={item} size="lg" fullwidth marginBottom />
{#each data as item, i}
<TextInput bind:value={data[i]} size="lg" fullwidth marginBottom />
{/each}
<Button styled="outlined" on:click={() => {
<Button styled="outlined" onclick={() => {
data.push("");
data = data
}}>+</Button>
@@ -61,11 +61,11 @@
</div>
{/each}
<Button className="mt-6 flex justify-center" size="lg" on:click={() => {
<Button className="mt-6 flex justify-center" size="lg" onclick={() => {
run()
}}>
{#if running}
<div class="loadmove" />
<div class="loadmove"></div>
{:else}
{language.run?.toLocaleUpperCase()}
{/if}

View File

@@ -5,10 +5,10 @@
import { generateAIImage } from "src/ts/process/stableDiff";
import { createBlankChar } from "src/ts/characters";
let prompt = "";
let negPrompt = "";
let img = "";
let generating = false
let prompt = $state("");
let negPrompt = $state("");
let img = $state("");
let generating = $state(false)
const run = async () => {
console.log('running')
@@ -40,9 +40,9 @@
<img src={img} class="max-w-full mt-4" alt="Generated"/>
{/if}
<Button className="mt-6" on:click={run}>
<Button className="mt-6" onclick={run}>
{#if generating}
<div class="loadmove" />
<div class="loadmove"></div>
{:else}
Generate
{/if}

View File

@@ -2,8 +2,8 @@
import { language } from "src/lang";
import { Template } from '@huggingface/jinja';
import TextAreaInput from "../UI/GUI/TextAreaInput.svelte";
let input = "";
let json = JSON.stringify({
let input = $state("");
let json = $state(JSON.stringify({
"messages": [{
"role": "user",
"content": "Hello, I'm a user!"
@@ -13,8 +13,8 @@
}],
"eos_token": "",
"bos_token": ""
}, null, 4)
let output = "";
}, null, 4))
let output = $state("");
const onInput = () => {
try {
const template = new Template(input);

View File

@@ -15,7 +15,7 @@
import ToolConvertion from "./ToolConvertion.svelte";
import { joinMultiuserRoom } from "src/ts/sync/multiuser";
let easterEggTouch = 0
let easterEggTouch = $state(0)
const playgroundChat = () => {
let db = get(DataBase)
@@ -50,52 +50,52 @@
{#if $PlaygroundStore === 1}
<h2 class="text-4xl text-textcolor my-6 font-black relative">{language.playground}</h2>
<div class="grid grid-cols-1 gap-4 md:grid-cols-2 w-full max-w-4xl p-2">
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1 md:col-span-2" on:click={() => {
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1 md:col-span-2" onclick={() => {
playgroundChat()
}}>
<h1 class="text-2xl font-bold text-start">{language.Chat}</h1>
</button>
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" on:click={() => {
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" onclick={() => {
PlaygroundStore.set(3)
}}>
<h1 class="text-2xl font-bold text-start">{language.embedding}</h1>
</button>
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" on:click={() => {
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" onclick={() => {
PlaygroundStore.set(4)
}}>
<h1 class="text-2xl font-bold text-start">{language.tokenizer}</h1>
</button>
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" on:click={() => {
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" onclick={() => {
PlaygroundStore.set(5)
}}>
<h1 class="text-2xl font-bold text-start">{language.syntax}</h1>
</button>
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" on:click={() => {
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" onclick={() => {
PlaygroundStore.set(6)
}}>
<h1 class="text-2xl font-bold text-start">Jinja</h1>
</button>
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" on:click={() => {
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" onclick={() => {
PlaygroundStore.set(7)
}}>
<h1 class="text-2xl font-bold text-start">{language.imageGeneration}</h1>
</button>
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" on:click={() => {
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" onclick={() => {
PlaygroundStore.set(8)
}}>
<h1 class="text-2xl font-bold text-start">Parser</h1>
</button>
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" on:click={() => {
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" onclick={() => {
PlaygroundStore.set(101)
}}>
<h1 class="text-2xl font-bold text-start">{language.promptConvertion}</h1>
</button>
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" on:click={() => {
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" onclick={() => {
joinMultiuserRoom()
}}>
<h1 class="text-2xl font-bold text-start">{language.joinMultiUserRoom}</h1>
</button>
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" on:click={() => {
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" onclick={() => {
easterEggTouch += 1
}}>
<h1 class="text-2xl font-bold text-start">
@@ -115,7 +115,7 @@
{/if}
<div class="w-full max-w-4xl flex flex-col p-2">
<div class="flex items-center mt-4">
<button class="mr-2 text-textcolor2 hover:text-green-500" on:click={() => ($PlaygroundStore = 1)}>
<button class="mr-2 text-textcolor2 hover:text-green-500" onclick={() => ($PlaygroundStore = 1)}>
<ArrowLeft/>
</button>
</div>

View File

@@ -1,8 +1,8 @@
<script lang="ts">
import { ParseMarkdown } from "src/ts/parser";
import TextAreaInput from "../UI/GUI/TextAreaInput.svelte";
let input = "";
let output = "";
let input = $state("");
let output = $state("");
const onInput = async () => {
try {
output = await ParseMarkdown(input)

View File

@@ -4,8 +4,8 @@
import { risuChatParser } from 'src/ts/parser';
import { language } from 'src/lang';
import { sleep } from 'src/ts/util';
let input = "";
let output = "";
let input = $state("");
let output = $state("");
const onInput = async () => {
try {
await sleep(1)

View File

@@ -3,9 +3,9 @@
import TextAreaInput from "../UI/GUI/TextAreaInput.svelte";
import { language } from 'src/lang';
let input = "";
let output = "";
let outputLength = 0;
let input = $state("");
let output = $state("");
let outputLength = $state(0);
const onInput = async () => {
try {
const tokenized = await encode(input);

View File

@@ -4,7 +4,7 @@
import { selectMultipleFile } from "src/ts/util";
import { detectPromptJSONType, promptConvertion } from "src/ts/process/prompt";
let files: { name: string, content: string, type:string }[] = []
let files: { name: string, content: string, type:string }[] = $state([])
const addFile = async () => {
const selFiles = await selectMultipleFile(['json'])
@@ -42,8 +42,8 @@
<Button>Delete</Button>
</div>
{/each}
<Button on:click={addFile}>Add</Button>
<Button onclick={addFile}>Add</Button>
</div>
<Button className="mt-6" on:click={() => {
<Button className="mt-6" onclick={() => {
promptConvertion(files)
}}>Run</Button>