feat: parallel web solving
This commit is contained in:
Generated
+79
-2
@@ -8,6 +8,12 @@ version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.20.3"
|
||||
@@ -114,7 +120,7 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustc_version",
|
||||
"syn",
|
||||
"syn 2.0.119",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
@@ -199,6 +205,15 @@ version = "0.2.189"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.4"
|
||||
@@ -278,6 +293,25 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rmp"
|
||||
version = "0.8.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ba8be72d372b2c9b35542551678538b562e7cf86c3315773cae48dfbfe7790c"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rmp-serde"
|
||||
version = "1.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72f81bee8c8ef9b577d1681a70ebbc962c232461e397b22c208c43c04b67a155"
|
||||
dependencies = [
|
||||
"rmp",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.1"
|
||||
@@ -299,6 +333,36 @@ version = "1.0.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_core"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.12"
|
||||
@@ -325,6 +389,17 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "3.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tabular"
|
||||
version = "0.2.0"
|
||||
@@ -430,7 +505,7 @@ dependencies = [
|
||||
"bumpalo",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.119",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
@@ -479,6 +554,8 @@ dependencies = [
|
||||
"js-sys",
|
||||
"rand",
|
||||
"rayon",
|
||||
"rmp-serde",
|
||||
"serde",
|
||||
"tabular",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
+3
-1
@@ -27,9 +27,11 @@ indicatif = { version = "0.18.6", features = ["rayon"] }
|
||||
js-sys = { version = "0.3.104", optional = true }
|
||||
rand = "0.10.2"
|
||||
rayon = "1.12.0"
|
||||
rmp-serde = { version = "1.3.1", optional = true }
|
||||
serde = { version = "1.0.229", optional = true, features = ["derive"] }
|
||||
tabular = { version = "0.2.0", features = ["ansi-cell"] }
|
||||
wasm-bindgen = { version = "0.2.127", optional = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
wasm-bindgen = ["dep:wasm-bindgen", "getrandom/wasm_js", "dep:js-sys"]
|
||||
wasm-bindgen = ["dep:wasm-bindgen", "getrandom/wasm_js", "dep:js-sys", "dep:serde", "dep:rmp-serde"]
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
use colored::Colorize;
|
||||
use derive_more::Display;
|
||||
#[cfg(feature = "wasm-bindgen")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Display, Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Hash)]
|
||||
#[cfg_attr(feature = "wasm-bindgen", derive(Serialize, Deserialize))]
|
||||
pub enum CharStatus {
|
||||
GREY,
|
||||
YELLOW,
|
||||
@@ -9,6 +12,7 @@ pub enum CharStatus {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
|
||||
#[cfg_attr(feature = "wasm-bindgen", derive(Serialize, Deserialize))]
|
||||
pub struct Pattern {
|
||||
chars: Vec<char>,
|
||||
stats: Vec<CharStatus>,
|
||||
|
||||
@@ -7,18 +7,23 @@ use crate::pattern::Pattern;
|
||||
use indicatif::ParallelProgressIterator;
|
||||
use rayon::iter::{ParallelBridge, ParallelIterator};
|
||||
|
||||
#[cfg(feature = "wasm-bindgen")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::word_list::WordList;
|
||||
|
||||
use derive_more::Display;
|
||||
use tabular::{Row, Table};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[cfg_attr(feature = "wasm-bindgen", derive(Serialize, Deserialize))]
|
||||
pub struct Guess {
|
||||
pub pattern: Pattern,
|
||||
pub information_gained: f64,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[cfg_attr(feature = "wasm-bindgen", derive(Serialize, Deserialize))]
|
||||
pub struct Solver {
|
||||
valid_words: WordList,
|
||||
possible_solutions: WordList,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use std::io;
|
||||
|
||||
use rmp_serde::{from_slice, to_vec};
|
||||
use serde::Serialize;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
use crate::{
|
||||
@@ -63,6 +65,26 @@ impl Solver {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn serialize(&self) -> Result<js_sys::Uint8Array, String> {
|
||||
let r = to_vec(&self.0).map_err(|e| {
|
||||
let s = e.to_string();
|
||||
drop(e);
|
||||
s
|
||||
})?;
|
||||
|
||||
Ok(js_sys::Uint8Array::from(&r[..]))
|
||||
}
|
||||
|
||||
pub fn new_from_serialized(bytes: &js_sys::Uint8Array) -> Result<Solver, String> {
|
||||
from_slice(&bytes.to_vec()[..])
|
||||
.map_err(|e| {
|
||||
let s = e.to_string();
|
||||
drop(e);
|
||||
s
|
||||
})
|
||||
.map(Solver)
|
||||
}
|
||||
|
||||
pub fn guess(&mut self, word: &str, colors: Vec<Color>) -> Result<(), String> {
|
||||
let pat = Pattern::try_new(
|
||||
word,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
use rand::{rng, seq::IteratorRandom};
|
||||
#[cfg(feature = "wasm-bindgen")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::{hash_set, HashSet},
|
||||
fs::{self},
|
||||
@@ -11,6 +13,7 @@ use derive_more::Display;
|
||||
use crate::pattern::Pattern;
|
||||
|
||||
#[derive(Display, Clone)]
|
||||
#[cfg_attr(feature = "wasm-bindgen", derive(Serialize, Deserialize))]
|
||||
#[display("{:?}", words)]
|
||||
pub struct WordList {
|
||||
words: HashSet<String>,
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
# 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?
|
||||
@@ -1,16 +0,0 @@
|
||||
<!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>
|
||||
@@ -1,38 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@@ -1,316 +0,0 @@
|
||||
<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,
|
||||
} 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_reset(use_default_wordle_answers);
|
||||
for (const g of guesses.slice(0, -1)) {
|
||||
try {
|
||||
await solver_guess(g.letters, g.colors);
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
|
||||
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>
|
||||
@@ -1,12 +0,0 @@
|
||||
@import "tailwindcss";
|
||||
@plugin "@tailwindcss/typography";
|
||||
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
min-height: 100vh;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
# 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.\].
|
||||
@@ -1,117 +0,0 @@
|
||||
<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>
|
||||
@@ -1,158 +0,0 @@
|
||||
<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>
|
||||
@@ -1,9 +0,0 @@
|
||||
import "./app.css";
|
||||
import { mount } from "svelte";
|
||||
import App from "./App.svelte";
|
||||
|
||||
const app = mount(App, {
|
||||
target: document.getElementById("app")!,
|
||||
});
|
||||
|
||||
export default app;
|
||||
@@ -1,145 +0,0 @@
|
||||
import type { Color } from "wordle-solver";
|
||||
import SolverWorker from "./worker?worker";
|
||||
import type { GuessResult, SolutionSpaceResult, EvaluateWordsResult, SolverRequest, SolverResponse, EvaluateWordsProgress } from "./types";
|
||||
|
||||
let solver_worker = new SolverWorker();
|
||||
await init_solver();
|
||||
|
||||
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>();
|
||||
|
||||
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 function solver_evaluate_words(n: number, progress: ((p: EvaluateWordsProgress) => void) | null): Promise<EvaluateWordsResult> {
|
||||
const id = msg_id++;
|
||||
|
||||
if (progress) {
|
||||
progresses.set(id, progress);
|
||||
}
|
||||
|
||||
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)));
|
||||
});
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
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
|
||||
};
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
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
|
||||
};
|
||||
@@ -1,105 +0,0 @@
|
||||
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;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"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"]
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
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()],
|
||||
});
|
||||
@@ -1,14 +0,0 @@
|
||||
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