feat: parallel web solving
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
*.local
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta
|
||||||
|
name="viewport"
|
||||||
|
content="width=device-width, initial-scale=1.0"
|
||||||
|
/>
|
||||||
|
<title>Wordle Solver</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"name": "web",
|
||||||
|
"private": true,
|
||||||
|
"version": "0.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"build-no-wasm": "run-s tsc vite:build",
|
||||||
|
"build": "run-s wasm-pack:release tsc vite:build",
|
||||||
|
"dev": "run-s wasm-pack:dev vite:dev",
|
||||||
|
"tsc": "tsc",
|
||||||
|
"vite:build": "vite build",
|
||||||
|
"vite:dev": "vite -c vite.config.dev.ts",
|
||||||
|
"vite:preview": "vite preview",
|
||||||
|
"wasm-pack:dev": "rm -rf pkg; wasm-pack build --dev --features wasm-bindgen --manifest-path ../Cargo.toml; mv ../pkg .",
|
||||||
|
"wasm-pack:release": "rm -rf pkg; wasm-pack build --features wasm-bindgen --manifest-path ../Cargo.toml; mv ../pkg ."
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@sveltejs/vite-plugin-svelte": "^7.3.0",
|
||||||
|
"@tailwindcss/typography": "^0.5.20",
|
||||||
|
"@tailwindcss/vite": "^4.3.3",
|
||||||
|
"npm-run-all": "^4.1.5",
|
||||||
|
"tailwindcss": "^4.3.3",
|
||||||
|
"typescript": "~6.0.2",
|
||||||
|
"vite": "^8.2.0",
|
||||||
|
"vite-plugin-top-level-await": "^1.6.0",
|
||||||
|
"vite-plugin-wasm": "^3.6.0",
|
||||||
|
"vite-plugin-wasm-pack-watcher": "^1.0.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@humanspeak/svelte-markdown": "^1.8.7",
|
||||||
|
"@lucide/svelte": "^1.33.0",
|
||||||
|
"esbuild": "^0.28.2",
|
||||||
|
"katex": "^0.18.4",
|
||||||
|
"rollup": "^4.62.4",
|
||||||
|
"svelte": "^5.56.9",
|
||||||
|
"wordle-solver": "link:./pkg"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,312 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { Color } from "wordle-solver";
|
||||||
|
import WordleLine from "./components/WordleLine.svelte";
|
||||||
|
import {
|
||||||
|
solver_evaluate_words,
|
||||||
|
solver_guess,
|
||||||
|
solver_reset,
|
||||||
|
solver_solution_space,
|
||||||
|
solver_stop,
|
||||||
|
} from "./solver/solver.ts";
|
||||||
|
import type {
|
||||||
|
GuessResult,
|
||||||
|
SolutionSpaceResult,
|
||||||
|
EvaluateWordsResult,
|
||||||
|
EvaluateWordsProgress,
|
||||||
|
} from "./solver/types.ts";
|
||||||
|
import info_md from "./assets/info.md?raw";
|
||||||
|
import SolverOutput from "./components/SolverOutput.svelte";
|
||||||
|
import { CircleX, FolderGit2, Info } from "@lucide/svelte";
|
||||||
|
import { tick, onMount } from "svelte";
|
||||||
|
import SvelteMarkdown from "@humanspeak/svelte-markdown";
|
||||||
|
|
||||||
|
let guesses = $state([
|
||||||
|
{
|
||||||
|
letters: ["", "", "", "", ""],
|
||||||
|
colors: [
|
||||||
|
Color.GREY,
|
||||||
|
Color.GREY,
|
||||||
|
Color.GREY,
|
||||||
|
Color.GREY,
|
||||||
|
Color.GREY,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
let show_info = $state(false);
|
||||||
|
|
||||||
|
let infos_gained: (Promise<GuessResult> | null)[] = $state([null]);
|
||||||
|
|
||||||
|
let use_default_wordle_answers: boolean = $state(true);
|
||||||
|
|
||||||
|
let solution_space: Promise<SolutionSpaceResult> = $state(
|
||||||
|
solver_solution_space(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let best_words: Promise<EvaluateWordsResult> | null = $state(null);
|
||||||
|
let best_words_progress: EvaluateWordsProgress | null = $state(null);
|
||||||
|
let solving: boolean = $state(false);
|
||||||
|
|
||||||
|
let w_lines: WordleLine[] = $state([]);
|
||||||
|
let cursor = $state(0);
|
||||||
|
|
||||||
|
let is_desktop = $state(false);
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
const update = () => {
|
||||||
|
is_desktop = window.innerWidth >= 768;
|
||||||
|
};
|
||||||
|
|
||||||
|
update();
|
||||||
|
window.addEventListener("resize", update);
|
||||||
|
|
||||||
|
return () => window.removeEventListener("resize", update);
|
||||||
|
});
|
||||||
|
|
||||||
|
async function toggleSolver() {
|
||||||
|
if (solving) {
|
||||||
|
await stopSolver();
|
||||||
|
} else {
|
||||||
|
best_words = solver_evaluate_words(5, (p) => {
|
||||||
|
best_words_progress = p;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function reset() {
|
||||||
|
await solver_reset(use_default_wordle_answers);
|
||||||
|
|
||||||
|
guesses = [
|
||||||
|
{
|
||||||
|
letters: ["", "", "", "", ""],
|
||||||
|
colors: [
|
||||||
|
Color.GREY,
|
||||||
|
Color.GREY,
|
||||||
|
Color.GREY,
|
||||||
|
Color.GREY,
|
||||||
|
Color.GREY,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
infos_gained = [null];
|
||||||
|
best_words = null;
|
||||||
|
solution_space = solver_solution_space();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function stopSolver() {
|
||||||
|
await solver_stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function doGuess() {
|
||||||
|
const guess = guesses[guesses.length - 1];
|
||||||
|
|
||||||
|
if (guess.letters.join("").length != 5) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
infos_gained[infos_gained.length - 1] = solver_guess(
|
||||||
|
guess.letters,
|
||||||
|
guess.colors,
|
||||||
|
);
|
||||||
|
infos_gained.push(null);
|
||||||
|
solution_space = solver_solution_space();
|
||||||
|
|
||||||
|
cursor = 0;
|
||||||
|
|
||||||
|
guesses.push({
|
||||||
|
letters: ["", "", "", "", ""],
|
||||||
|
colors: [
|
||||||
|
Color.GREY,
|
||||||
|
Color.GREY,
|
||||||
|
Color.GREY,
|
||||||
|
Color.GREY,
|
||||||
|
Color.GREY,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
await tick();
|
||||||
|
|
||||||
|
w_lines[w_lines.length - 1].focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleKey(event: KeyboardEvent) {
|
||||||
|
if (/^[a-zA-Z ]$/.test(event.key)) {
|
||||||
|
w_lines[guesses.length - 1].focus();
|
||||||
|
} else if (event.key === "Enter" && event.shiftKey) {
|
||||||
|
best_words = solver_evaluate_words(5, (p) => {
|
||||||
|
best_words_progress = p;
|
||||||
|
});
|
||||||
|
} else if (event.key === "Escape" && event.ctrlKey) {
|
||||||
|
await reset();
|
||||||
|
} else if (event.key === "Escape") {
|
||||||
|
await stopSolver();
|
||||||
|
} else if (event.key === "Enter") {
|
||||||
|
await doGuess();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:window onkeydown={handleKey} />
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="h-dvh w-full max-w-full
|
||||||
|
bg-zinc-950 text-zinc-100
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="h-full overflow-y-auto
|
||||||
|
flex flex-wrap md:flex-row
|
||||||
|
items-center justify-center p-2 md:p-10 gap-4
|
||||||
|
overflow-hidden select-none"
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
class="fixed top-4 right-4"
|
||||||
|
href="https://git.jroeger.de/jonas/wordle-solver-rs"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
<FolderGit2 />
|
||||||
|
</a>
|
||||||
|
<a
|
||||||
|
class="fixed top-4 left-4"
|
||||||
|
onclick={() => {
|
||||||
|
show_info = true;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Info />
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="mb-4 text-3xl font-bold">Wordle Solver</h1>
|
||||||
|
|
||||||
|
<p class="text-sm text-zinc-500">
|
||||||
|
Use Wordle-Answers:
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
bind:checked={use_default_wordle_answers}
|
||||||
|
onfocus={(e) => {
|
||||||
|
if (e.currentTarget) {
|
||||||
|
e.currentTarget.blur();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onchange={reset}
|
||||||
|
/>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p class="mt-0 text-sm text-zinc-500">
|
||||||
|
{#await solution_space}
|
||||||
|
loading
|
||||||
|
{:then s}
|
||||||
|
Solution-space: {s.size}, Uncertainty: {s.uncertainty.toFixed(
|
||||||
|
2,
|
||||||
|
)}bits
|
||||||
|
{:catch e}
|
||||||
|
{e}
|
||||||
|
{/await}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="mt-2 flex flex-col gap-2">
|
||||||
|
{#each guesses as g, i (g)}
|
||||||
|
<WordleLine
|
||||||
|
active={i === guesses.length - 1}
|
||||||
|
on_guess_pressed={i === guesses.length - 1
|
||||||
|
? doGuess
|
||||||
|
: null}
|
||||||
|
bind:this={w_lines[i]}
|
||||||
|
bind:cursor
|
||||||
|
bind:letters={guesses[i].letters}
|
||||||
|
bind:colors={guesses[i].colors}
|
||||||
|
info_gained={infos_gained[i]}
|
||||||
|
/>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if is_desktop}
|
||||||
|
<p class="mt-4 text-sm text-zinc-500 mx-auto w-3/4">
|
||||||
|
Type letters · ← → navigate · Space cycle color · Backspace
|
||||||
|
delete · Enter apply · Shift+Enter solve · Escape abort
|
||||||
|
solver · Ctrl+Esc reset
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
<button
|
||||||
|
tabindex="-1"
|
||||||
|
class="mt-4 bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full"
|
||||||
|
onclick={(e) => {
|
||||||
|
e.currentTarget.blur();
|
||||||
|
toggleSolver();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{#if solving}
|
||||||
|
Cancel
|
||||||
|
{:else}
|
||||||
|
Solve
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{#if best_words}
|
||||||
|
<SolverOutput
|
||||||
|
data={best_words}
|
||||||
|
progress={best_words_progress}
|
||||||
|
insert_guess={(g) => {
|
||||||
|
guesses[guesses.length - 1].letters = g;
|
||||||
|
}}
|
||||||
|
bind:solving
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if show_info}
|
||||||
|
<div
|
||||||
|
class="fixed inset-0 z-50 flex items-center justify-center bg-black/60"
|
||||||
|
tabindex="-1"
|
||||||
|
role="button"
|
||||||
|
onclick={() => (show_info = false)}
|
||||||
|
onkeydown={() => (show_info = false)}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="relative flex flex-col
|
||||||
|
rounded-lg
|
||||||
|
bg-zinc-900
|
||||||
|
p-6 shadow-xl
|
||||||
|
md:max-w-[75vw]
|
||||||
|
md:max-h-[75vh]
|
||||||
|
max-w-[calc(100vw-3rem)]
|
||||||
|
max-h-[calc(100vh-3rem)]
|
||||||
|
overflow-hidden"
|
||||||
|
tabindex="0"
|
||||||
|
role="dialog"
|
||||||
|
onclick={(e) => e.stopPropagation()}
|
||||||
|
onkeydown={(e) => e.stopPropagation()}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="absolute top-4 right-4"
|
||||||
|
tabindex="-1"
|
||||||
|
role="button"
|
||||||
|
onclick={() => (show_info = false)}
|
||||||
|
onkeydown={() => (show_info = false)}
|
||||||
|
>
|
||||||
|
<CircleX />
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="prose prose-invert max-w-none
|
||||||
|
h-full
|
||||||
|
overflow-y-auto
|
||||||
|
overflow-x-hidden"
|
||||||
|
>
|
||||||
|
<SvelteMarkdown source={info_md} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
:global(body) {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
overscroll-behavior: none;
|
||||||
|
background: #09090b;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
@import "tailwindcss";
|
||||||
|
@plugin "@tailwindcss/typography";
|
||||||
|
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
min-height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# Wordle Solver
|
||||||
|
|
||||||
|
This wordle solver uses an information theory based approach to
|
||||||
|
evaluate the next-best-guess. It's heavily inspired by [3b1b's approach](https://www.youtube.com/watch?v=v68zYyaEmEA)
|
||||||
|
on solving wordle.
|
||||||
|
|
||||||
|
## How to use?
|
||||||
|
|
||||||
|
You can run the solver at any time to tell you five best next guesses (ranked).
|
||||||
|
However when the solver has no information this can take quite some time. So it's
|
||||||
|
best to make your first guess (e.g. "CRANE", "SALES", ...):
|
||||||
|
|
||||||
|
1. Once your wordle game gave you an answer, type it into the interface:
|
||||||
|
|
||||||
|
- type letters to input them
|
||||||
|
- click a cell to change it's color (or cycle it with <Space>)
|
||||||
|
|
||||||
|
2. To give the solver the information of your guess press enter (or the little enter icon next to the line)
|
||||||
|
|
||||||
|
3. The solver will tell you the amount of information gained by this guess.
|
||||||
|
|
||||||
|
4. Run the solver to get a new next-best-guess and repeat until you found the answer
|
||||||
|
|
||||||
|
## Solution Space
|
||||||
|
|
||||||
|
The solution space is by default the list of possible wordle-answers (uncheck the box to use all valid words as possible answers).
|
||||||
|
Above your inputs you can see how many possible answers are still left given your guesses with a value of
|
||||||
|
remaining uncertainty in bits (how many yes-no questions are required to identify an item in the equally distributed set).
|
||||||
|
The goal is to reach 0bits of uncertainty, meaning one word left.
|
||||||
|
|
||||||
|
Sometimes when adding a guess there may appear an error symbol. This occurrs when the guess would empty
|
||||||
|
the solution space. This can only happen if the solution space did not contain the solution of your wordle game (or there some inconsistencies in the guesses).
|
||||||
|
In this case you might wanna allow all valid words as possible answers.
|
||||||
|
|
||||||
|
|
||||||
|
## The Solver's output
|
||||||
|
|
||||||
|
- p(x) is the probability, that the word is actually the solution.
|
||||||
|
Often it will be 0, because the word is not a possible solution anymore.
|
||||||
|
If so, the expected information of guessing this that high, that it is worth guessing it.
|
||||||
|
|
||||||
|
- E\[Inf.\] The expected information to gain when guessing this word. (I.e. by how much do we expect to shrink the solution space?)
|
||||||
|
|
||||||
|
- E\[Score.\] The expected number of guesses required to solve the wordle when you guess this word now. It's based on a heuristic combination
|
||||||
|
of the current score, p(x) and E\[Inf.\].
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import katex from "katex";
|
||||||
|
import "katex/dist/katex.min.css";
|
||||||
|
import type {
|
||||||
|
EvaluateWordsProgress,
|
||||||
|
EvaluateWordsResult,
|
||||||
|
} from "../solver/types";
|
||||||
|
|
||||||
|
let {
|
||||||
|
data,
|
||||||
|
progress = null,
|
||||||
|
insert_guess = null,
|
||||||
|
solving = $bindable(true),
|
||||||
|
}: {
|
||||||
|
data: Promise<EvaluateWordsResult>;
|
||||||
|
progress: EvaluateWordsProgress | null;
|
||||||
|
insert_guess: ((word: string[]) => void) | null;
|
||||||
|
solving: boolean;
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
solving = true;
|
||||||
|
data.finally(() => {
|
||||||
|
solving = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function renderMath(txt: string | null) {
|
||||||
|
return (element: HTMLElement) => {
|
||||||
|
if (txt) {
|
||||||
|
katex.render(txt, element);
|
||||||
|
} else {
|
||||||
|
katex.render(element.innerText, element);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#await data}
|
||||||
|
<div
|
||||||
|
class="flex items-center justify-center gap-2 text-gray-600 max-w-full"
|
||||||
|
>
|
||||||
|
Solving...
|
||||||
|
{#if progress}
|
||||||
|
<span class="text-sm">
|
||||||
|
{progress.i} / {progress.n}
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{:then d}
|
||||||
|
<div
|
||||||
|
class="select-none rounded-lg border border-gray-500 shadow-sm max-w-full"
|
||||||
|
>
|
||||||
|
<table class="w-full text-left text-sm text-gray-700">
|
||||||
|
<thead class="divide-y divide-x bg-gray-800 text-xs text-gray-600">
|
||||||
|
<tr>
|
||||||
|
<th class="px-4 py-3" title="Rank the solver assigned"></th>
|
||||||
|
<th class="px-4 py-3" title="The best words">Word</th>
|
||||||
|
<th
|
||||||
|
class="px-4 py-3 math-header"
|
||||||
|
title="The probability that this word is the solution."
|
||||||
|
{@attach renderMath("p(x)")}
|
||||||
|
></th>
|
||||||
|
<th
|
||||||
|
title="The expected information to gain when guessing this word."
|
||||||
|
class="px-4 py-3 math-header"
|
||||||
|
{@attach renderMath("E[\\text{Inf.}]")}
|
||||||
|
></th>
|
||||||
|
<th
|
||||||
|
title="The expected number of guesses for this wordle when guessing this word."
|
||||||
|
class="px-4 py-3 math-header"
|
||||||
|
{@attach renderMath("E[\\text{Score}]")}
|
||||||
|
></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody class="divide-y divide-x divide-gray-500">
|
||||||
|
{#each d.stats as s, i}
|
||||||
|
<tr
|
||||||
|
class="transition-colors hover:bg-gray-50"
|
||||||
|
onclick={() => {
|
||||||
|
if (insert_guess) {
|
||||||
|
insert_guess([...s.word]);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<td class="px-4 py-3 font-bold">#{i + 1}</td>
|
||||||
|
<td class="px-4 py-3 font-bold">{s.word}</td>
|
||||||
|
<td class="px-4 py-3">
|
||||||
|
{(s.solution_probability * 100).toFixed(2) + "%"}
|
||||||
|
</td>
|
||||||
|
<td class="px-4 py-3">
|
||||||
|
{s.expected_information_gained.toFixed(2)} bits
|
||||||
|
</td>
|
||||||
|
<td class="px-4 py-3">
|
||||||
|
{s.expected_score_after_guess.toFixed(3)}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{:catch e}
|
||||||
|
<div class="rounded-lg border border-red-400 bg-gray-800 p-4 text-red-400">
|
||||||
|
{e}
|
||||||
|
</div>
|
||||||
|
{/await}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.math-header :global(.katex) {
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.math-header :global(.katex .mord) {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { Color } from "wordle-solver";
|
||||||
|
import type { GuessResult } from "../solver/types";
|
||||||
|
|
||||||
|
let {
|
||||||
|
active = false,
|
||||||
|
cursor = $bindable(0),
|
||||||
|
letters = $bindable(["", "", "", "", ""]),
|
||||||
|
colors = $bindable([
|
||||||
|
Color.GREY,
|
||||||
|
Color.GREY,
|
||||||
|
Color.GREY,
|
||||||
|
Color.GREY,
|
||||||
|
Color.GREY,
|
||||||
|
]),
|
||||||
|
info_gained = null,
|
||||||
|
on_guess_pressed = null,
|
||||||
|
}: {
|
||||||
|
active: boolean;
|
||||||
|
cursor: number;
|
||||||
|
letters: string[];
|
||||||
|
colors: Color[];
|
||||||
|
info_gained: Promise<GuessResult> | null;
|
||||||
|
on_guess_pressed: (() => void) | null;
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
let invalid: boolean = $state(false);
|
||||||
|
let inputs: HTMLInputElement[] = $state([]);
|
||||||
|
let info_gained_wrapped: Promise<GuessResult> | null = $state(null);
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
if (info_gained) {
|
||||||
|
info_gained_wrapped = info_gained.catch((e) => {
|
||||||
|
invalid = true;
|
||||||
|
throw e;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
info_gained_wrapped = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export function focus() {
|
||||||
|
inputs[cursor].focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleKey(event: KeyboardEvent) {
|
||||||
|
if (!active) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.key === "Backspace") {
|
||||||
|
if (letters[cursor] === "" && cursor > 0) {
|
||||||
|
const nc = cursor - 1;
|
||||||
|
inputs[nc].focus(); // Focusing / bluring resets cursor temporarily
|
||||||
|
cursor = nc;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (active) {
|
||||||
|
letters[cursor] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.key === "ArrowLeft") {
|
||||||
|
const nc = Math.max(0, cursor - 1);
|
||||||
|
inputs[nc].focus();
|
||||||
|
cursor = nc;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.key === "ArrowRight") {
|
||||||
|
const nc = Math.min(4, cursor + 1);
|
||||||
|
inputs[nc].focus();
|
||||||
|
cursor = nc;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.key === " ") {
|
||||||
|
colors[cursor] = (colors[cursor] + 1) % 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:window onkeydown={handleKey} />
|
||||||
|
|
||||||
|
<div class="flex justify-center gap-2">
|
||||||
|
{#each letters as _, i}
|
||||||
|
<input
|
||||||
|
disabled={!active}
|
||||||
|
tabindex="-1"
|
||||||
|
class="
|
||||||
|
flex aspect-square max-w-16 w-1/6 items-center justify-center
|
||||||
|
rounded-lg border-2
|
||||||
|
text-3xl font-bold
|
||||||
|
transition-all text-center caret-transparent
|
||||||
|
focus:outline-none
|
||||||
|
"
|
||||||
|
bind:this={inputs[i]}
|
||||||
|
bind:value={letters[i]}
|
||||||
|
class:border-blue-500={i === cursor && active}
|
||||||
|
class:border-zinc-700={i !== cursor || !active}
|
||||||
|
class:bg-green-600={colors[i] === Color.GREEN}
|
||||||
|
class:bg-yellow-600={colors[i] === Color.YELLOW}
|
||||||
|
class:bg-grey-600={colors[i] === Color.GREY}
|
||||||
|
class:opacity-20={invalid}
|
||||||
|
onblur={() => {
|
||||||
|
cursor = -1;
|
||||||
|
}}
|
||||||
|
onbeforeinput={(event) => {
|
||||||
|
if (event.inputType === "insertText") {
|
||||||
|
event.preventDefault();
|
||||||
|
let key = event.data ?? "";
|
||||||
|
|
||||||
|
if (/^[a-zA-Z]$/.test(key)) {
|
||||||
|
letters[i] = key.toUpperCase();
|
||||||
|
let nc = cursor;
|
||||||
|
if (nc < 4) {
|
||||||
|
nc++;
|
||||||
|
} else {
|
||||||
|
nc = 0;
|
||||||
|
}
|
||||||
|
inputs[nc].focus();
|
||||||
|
cursor = nc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onclick={() => {
|
||||||
|
if (!active) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (cursor === i) {
|
||||||
|
colors[cursor] = (colors[cursor] + 1) % 3;
|
||||||
|
} else {
|
||||||
|
cursor = i;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{/each}
|
||||||
|
<span
|
||||||
|
class="max-w-14 w-1/6 text-sm text-zinc-500 self-center flex items-center justify-center"
|
||||||
|
onclick={info_gained === null ? on_guess_pressed : null}
|
||||||
|
>
|
||||||
|
{#if info_gained_wrapped === null}
|
||||||
|
↵
|
||||||
|
{:else}
|
||||||
|
{#await info_gained_wrapped}
|
||||||
|
<div
|
||||||
|
class="size-3 animate-spin rounded-full border-2 border-gray-300 border-t-gray-700"
|
||||||
|
></div>
|
||||||
|
{:then i}
|
||||||
|
{i.info_gained.toFixed(2)} bits
|
||||||
|
{:catch e}
|
||||||
|
<span
|
||||||
|
title={e}
|
||||||
|
class="lex size-4 items-center justify-center rounded-full border border-red-500 text-[10px] font-bold text-red-500"
|
||||||
|
>!</span
|
||||||
|
>
|
||||||
|
{/await}
|
||||||
|
{/if}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import "./app.css";
|
||||||
|
import { mount } from "svelte";
|
||||||
|
import App from "./App.svelte";
|
||||||
|
|
||||||
|
const app = mount(App, {
|
||||||
|
target: document.getElementById("app")!,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default app;
|
||||||
@@ -0,0 +1,196 @@
|
|||||||
|
import type { Color } from "wordle-solver";
|
||||||
|
import SolverWorker from "./worker?worker";
|
||||||
|
import type { GuessResult, SolutionSpaceResult, EvaluateWordsResult, SolverRequest, SolverResponse, EvaluateWordsProgress, SolverStateResult, RestoreSolverState } from "./types";
|
||||||
|
|
||||||
|
let msg_id = 0;
|
||||||
|
|
||||||
|
const pending = new Map<number, {
|
||||||
|
resolve: (value: any) => void;
|
||||||
|
reject: (error: any) => void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const progresses = new Map<number, (p: EvaluateWordsProgress) => void>();
|
||||||
|
|
||||||
|
let solver_worker = new SolverWorker();
|
||||||
|
await init_solver();
|
||||||
|
|
||||||
|
let last_solver_state = await solver_state();
|
||||||
|
|
||||||
|
|
||||||
|
function init_solver(): Promise<void> {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
solver_worker.onmessage = (event: any) => {
|
||||||
|
if (event.data.type === "ready") {
|
||||||
|
solver_worker.onmessage = workerHandleMsg;
|
||||||
|
resolve();
|
||||||
|
} else {
|
||||||
|
workerHandleMsg(event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_solver_worker(): Promise<void> {
|
||||||
|
solver_worker = new SolverWorker();
|
||||||
|
|
||||||
|
return init_solver();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function solver_guess(word: string[], colors: Color[]): Promise<GuessResult> {
|
||||||
|
const id = msg_id++;
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
pending.set(id, { resolve, reject });
|
||||||
|
|
||||||
|
const r: SolverRequest = {
|
||||||
|
type: "guess",
|
||||||
|
id: id,
|
||||||
|
input: { word: word, colors: colors },
|
||||||
|
};
|
||||||
|
|
||||||
|
solver_worker.postMessage(JSON.parse(JSON.stringify(r)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function solver_solution_space(): Promise<SolutionSpaceResult> {
|
||||||
|
const id = msg_id++;
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
pending.set(id, { resolve, reject });
|
||||||
|
|
||||||
|
const r: SolverRequest = {
|
||||||
|
type: "solution_space",
|
||||||
|
id: id,
|
||||||
|
input: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
solver_worker.postMessage(JSON.parse(JSON.stringify(r)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function solver_evaluate_words(n: number, progress: ((p: EvaluateWordsProgress) => void) | null): Promise<EvaluateWordsResult> {
|
||||||
|
const id = msg_id++;
|
||||||
|
|
||||||
|
if (progress) {
|
||||||
|
progresses.set(id, progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
last_solver_state = await solver_state();
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
pending.set(id, { resolve, reject });
|
||||||
|
|
||||||
|
const r: SolverRequest = {
|
||||||
|
type: "evaluate_words",
|
||||||
|
id: id,
|
||||||
|
input: { n },
|
||||||
|
};
|
||||||
|
|
||||||
|
solver_worker.postMessage(JSON.parse(JSON.stringify(r)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function solver_state(): Promise<SolverStateResult> {
|
||||||
|
const id = msg_id++;
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
pending.set(id, { resolve, reject });
|
||||||
|
|
||||||
|
const r: SolverRequest = {
|
||||||
|
type: "solver_state",
|
||||||
|
id: id,
|
||||||
|
input: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
solver_worker.postMessage(JSON.parse(JSON.stringify(r)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function restore_solver_state(s: RestoreSolverState): Promise<void> {
|
||||||
|
const id = msg_id++;
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
pending.set(id, { resolve, reject });
|
||||||
|
|
||||||
|
const r: SolverRequest = {
|
||||||
|
type: "restore_solver_state",
|
||||||
|
id: id,
|
||||||
|
input: s,
|
||||||
|
};
|
||||||
|
|
||||||
|
solver_worker.postMessage(r);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function solver_stop(): Promise<void> {
|
||||||
|
solver_worker.terminate();
|
||||||
|
|
||||||
|
pending.forEach((v, _) => {
|
||||||
|
v.reject("Solver was stopped");
|
||||||
|
});
|
||||||
|
pending.clear();
|
||||||
|
progresses.clear();
|
||||||
|
|
||||||
|
await create_solver_worker();
|
||||||
|
|
||||||
|
await restore_solver_state(last_solver_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function solver_reset(wordle_answers: boolean): Promise<void> {
|
||||||
|
solver_worker.terminate();
|
||||||
|
|
||||||
|
await create_solver_worker();
|
||||||
|
|
||||||
|
pending.forEach((v, _) => {
|
||||||
|
v.reject("Solver was reset");
|
||||||
|
});
|
||||||
|
pending.clear();
|
||||||
|
progresses.clear();
|
||||||
|
|
||||||
|
const id = msg_id++;
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
pending.set(id, { resolve, reject });
|
||||||
|
|
||||||
|
const r: SolverRequest = {
|
||||||
|
type: "reload_wordlist",
|
||||||
|
id: id,
|
||||||
|
input: { use_wordle_ansers: wordle_answers },
|
||||||
|
};
|
||||||
|
|
||||||
|
solver_worker.postMessage(JSON.parse(JSON.stringify(r)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function workerHandleMsg(event: MessageEvent<SolverResponse>) {
|
||||||
|
let res = event.data;
|
||||||
|
|
||||||
|
if (res.type == "evaluate_words_progress") {
|
||||||
|
let progress = progresses.get(res.id);
|
||||||
|
|
||||||
|
if (progress) {
|
||||||
|
progress(res.result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const pendingRequest = pending.get(res.id);
|
||||||
|
|
||||||
|
if (!pendingRequest) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pending.delete(res.id);
|
||||||
|
progresses.delete(res.id);
|
||||||
|
|
||||||
|
if (res.error) {
|
||||||
|
pendingRequest.reject(res.error);
|
||||||
|
} else if (res.result) {
|
||||||
|
pendingRequest.resolve(res.result);
|
||||||
|
} else {
|
||||||
|
pendingRequest.reject("No result");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
import { Color } from "wordle-solver";
|
||||||
|
|
||||||
|
export type SolverRequest =
|
||||||
|
| {
|
||||||
|
type: "guess",
|
||||||
|
id: number,
|
||||||
|
input: Guess
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "evaluate_words",
|
||||||
|
id: number,
|
||||||
|
input: EvaluateWords
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "solution_space",
|
||||||
|
id: number,
|
||||||
|
input: null,
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "reload_wordlist",
|
||||||
|
id: number,
|
||||||
|
input: ReloadWordlist
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "solver_state",
|
||||||
|
id: number,
|
||||||
|
input: null
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "restore_solver_state",
|
||||||
|
id: number,
|
||||||
|
input: RestoreSolverState
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export type SolverResponse =
|
||||||
|
| {
|
||||||
|
type: "guess",
|
||||||
|
id: number,
|
||||||
|
error: string | null,
|
||||||
|
result: GuessResult | null
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "evaluate_words",
|
||||||
|
id: number,
|
||||||
|
error: string | null,
|
||||||
|
result: EvaluateWordsResult | null
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "evaluate_words_progress",
|
||||||
|
id: number,
|
||||||
|
error: null,
|
||||||
|
result: EvaluateWordsProgress
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "solution_space",
|
||||||
|
id: number,
|
||||||
|
error: string | null,
|
||||||
|
result: SolutionSpaceResult | null
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "reload_wordlist",
|
||||||
|
id: number,
|
||||||
|
error: string | null
|
||||||
|
result: boolean | null,
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "solver_state",
|
||||||
|
id: number,
|
||||||
|
error: string | null
|
||||||
|
result: SolverStateResult | null,
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "restore_solver_state",
|
||||||
|
id: number,
|
||||||
|
error: string | null
|
||||||
|
result: boolean | null,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export type Guess = {
|
||||||
|
word: string[],
|
||||||
|
colors: Color[]
|
||||||
|
};
|
||||||
|
export type GuessResult = {
|
||||||
|
info_gained: number,
|
||||||
|
};
|
||||||
|
export type EvaluateWords = {
|
||||||
|
n: number,
|
||||||
|
};
|
||||||
|
export type EvaluateWordsProgress = {
|
||||||
|
i: number,
|
||||||
|
n: number
|
||||||
|
};
|
||||||
|
export type ReloadWordlist = {
|
||||||
|
use_wordle_ansers: boolean
|
||||||
|
};
|
||||||
|
export type WordStats = {
|
||||||
|
word: string,
|
||||||
|
solution_probability: number,
|
||||||
|
expected_information_gained: number,
|
||||||
|
expected_score_after_guess: number
|
||||||
|
};
|
||||||
|
export type EvaluateWordsResult = {
|
||||||
|
stats: WordStats[]
|
||||||
|
};
|
||||||
|
export type SolutionSpaceResult = {
|
||||||
|
size: number,
|
||||||
|
uncertainty: number
|
||||||
|
};
|
||||||
|
export type SolverStateResult = {
|
||||||
|
raw: Uint8Array
|
||||||
|
};
|
||||||
|
export type RestoreSolverState = {
|
||||||
|
raw: Uint8Array
|
||||||
|
};
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
import { Solver, } from "wordle-solver";
|
||||||
|
import type { SolverRequest, SolverResponse, WordStats } from "./types";
|
||||||
|
|
||||||
|
let solver = Solver.new(true);
|
||||||
|
|
||||||
|
self.postMessage({
|
||||||
|
type: "ready",
|
||||||
|
});
|
||||||
|
|
||||||
|
self.onmessage = (event: MessageEvent<SolverRequest>) => {
|
||||||
|
const request = event.data;
|
||||||
|
|
||||||
|
switch (request.type) {
|
||||||
|
case "guess": {
|
||||||
|
try {
|
||||||
|
solver.guess(request.input.word.join(""), request.input.colors);
|
||||||
|
const infos = solver.guess_infos();
|
||||||
|
|
||||||
|
const response: SolverResponse = {
|
||||||
|
type: "guess",
|
||||||
|
id: request.id,
|
||||||
|
error: null,
|
||||||
|
result: { info_gained: infos[infos.length - 1] }
|
||||||
|
};
|
||||||
|
|
||||||
|
self.postMessage(JSON.parse(JSON.stringify(response)));
|
||||||
|
} catch (e) {
|
||||||
|
const response: SolverResponse = {
|
||||||
|
type: "guess",
|
||||||
|
id: request.id,
|
||||||
|
error: e as string,
|
||||||
|
result: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
self.postMessage(JSON.parse(JSON.stringify(response)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
case "evaluate_words": {
|
||||||
|
try {
|
||||||
|
let stats = solver.evaluate_words(request.input.n, (i: number, n: number) => {
|
||||||
|
let p: SolverResponse = {
|
||||||
|
type: "evaluate_words_progress",
|
||||||
|
id: request.id,
|
||||||
|
error: null,
|
||||||
|
result: { i, n }
|
||||||
|
};
|
||||||
|
self.postMessage(JSON.parse(JSON.stringify(p)));
|
||||||
|
}).map((ws): WordStats => {
|
||||||
|
return {
|
||||||
|
word: ws.word,
|
||||||
|
solution_probability: ws.solution_probability,
|
||||||
|
expected_information_gained: ws.expected_information_gained,
|
||||||
|
expected_score_after_guess: ws.expected_score_after_guess
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const response: SolverResponse = {
|
||||||
|
type: "evaluate_words",
|
||||||
|
id: request.id,
|
||||||
|
error: null,
|
||||||
|
result: { stats },
|
||||||
|
};
|
||||||
|
|
||||||
|
self.postMessage(JSON.parse(JSON.stringify(response)));
|
||||||
|
} catch (e) {
|
||||||
|
const response: SolverResponse = {
|
||||||
|
type: "evaluate_words",
|
||||||
|
id: request.id,
|
||||||
|
error: e as string,
|
||||||
|
result: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
self.postMessage(JSON.parse(JSON.stringify(response)));
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
case "solution_space": {
|
||||||
|
const response: SolverResponse = {
|
||||||
|
type: "solution_space",
|
||||||
|
id: request.id,
|
||||||
|
error: null,
|
||||||
|
result: { size: solver.solution_space(), uncertainty: solver.solution_space_uncertainty() }
|
||||||
|
};
|
||||||
|
self.postMessage(JSON.parse(JSON.stringify(response)));
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
case "reload_wordlist": {
|
||||||
|
solver.free();
|
||||||
|
solver = Solver.new(request.input.use_wordle_ansers);
|
||||||
|
const response: SolverResponse = {
|
||||||
|
type: "reload_wordlist",
|
||||||
|
id: request.id,
|
||||||
|
error: null,
|
||||||
|
result: true
|
||||||
|
};
|
||||||
|
self.postMessage(JSON.parse(JSON.stringify(response)));
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
case "solver_state": {
|
||||||
|
let response: SolverResponse = {
|
||||||
|
type: "solver_state",
|
||||||
|
id: request.id,
|
||||||
|
error: null,
|
||||||
|
result: null
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
response.result = { raw: solver.serialize() };
|
||||||
|
} catch (e) {
|
||||||
|
response.error = e as string;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.postMessage(response);
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
case "restore_solver_state": {
|
||||||
|
let response: SolverResponse = {
|
||||||
|
type: "restore_solver_state",
|
||||||
|
id: request.id,
|
||||||
|
error: null,
|
||||||
|
result: null
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
solver.free();
|
||||||
|
solver = Solver.new_from_serialized(request.input.raw);
|
||||||
|
response.result = true;
|
||||||
|
} catch (e) {
|
||||||
|
response.error = e as string;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.postMessage(response);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es2023",
|
||||||
|
"module": "esnext",
|
||||||
|
"lib": ["ES2023", "DOM"],
|
||||||
|
"types": ["vite/client"],
|
||||||
|
"allowArbitraryExtensions": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
|
||||||
|
/* Bundler mode */
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"moduleDetection": "force",
|
||||||
|
"noEmit": true,
|
||||||
|
|
||||||
|
/* Linting */
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"erasableSyntaxOnly": true,
|
||||||
|
"noFallthroughCasesInSwitch": true
|
||||||
|
},
|
||||||
|
"include": ["src"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { defineConfig } from "vite";
|
||||||
|
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
||||||
|
import tailwindcss from "@tailwindcss/vite";
|
||||||
|
import wasm from "vite-plugin-wasm";
|
||||||
|
import wasmPackWatchPlugin from "vite-plugin-wasm-pack-watcher";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
build: {
|
||||||
|
watch: {
|
||||||
|
include: ["src/**/*.ts", "../src/**/*.rs"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [wasmPackWatchPlugin(), wasm(), svelte(), tailwindcss()],
|
||||||
|
});
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { defineConfig } from "vite";
|
||||||
|
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
||||||
|
import tailwindcss from "@tailwindcss/vite";
|
||||||
|
import wasm from "vite-plugin-wasm";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [wasm(), svelte(), tailwindcss()],
|
||||||
|
build: {
|
||||||
|
target: "esnext"
|
||||||
|
},
|
||||||
|
worker: {
|
||||||
|
format: "es",
|
||||||
|
},
|
||||||
|
});
|
||||||
+2371
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user