motely-wasm 11.3.1 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/demo.html ADDED
@@ -0,0 +1,88 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>motely-wasm · JAML seed search demo</title>
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <style>
8
+ :root { color-scheme: dark; }
9
+ body { font: 14px/1.45 system-ui, sans-serif; margin: 0; padding: 24px; background: #111; color: #eee; max-width: 900px; }
10
+ h1 { font-size: 20px; margin: 0 0 4px; }
11
+ p.sub { margin: 0 0 20px; color: #aaa; }
12
+ textarea, pre { width: 100%; background: #1a1a1a; color: #eee; border: 1px solid #333; border-radius: 6px; padding: 12px; font: 12px/1.4 ui-monospace, Consolas, monospace; box-sizing: border-box; }
13
+ textarea { height: 160px; resize: vertical; }
14
+ pre { max-height: 260px; overflow: auto; white-space: pre-wrap; }
15
+ .row { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
16
+ input[type=number] { background: #1a1a1a; color: #eee; border: 1px solid #333; border-radius: 6px; padding: 8px 10px; width: 140px; }
17
+ button { background: #d4af37; color: #111; border: 0; border-radius: 6px; padding: 10px 16px; font-weight: 600; cursor: pointer; }
18
+ button:disabled { opacity: 0.5; cursor: not-allowed; }
19
+ .stat { color: #aaa; }
20
+ .stat b { color: #eee; }
21
+ a { color: #d4af37; }
22
+ </style>
23
+ </head>
24
+ <body>
25
+ <h1>motely-wasm</h1>
26
+ <p class="sub">Balatro seed search. Plain-language JAML filters. One HTML file, CDN import, no bundler.</p>
27
+
28
+ <label>JAML filter</label>
29
+ <textarea id="jaml">deck: Red
30
+ stake: Gold
31
+
32
+ must:
33
+ - voucher: Telescope
34
+ antes: [1]
35
+ </textarea>
36
+
37
+ <div class="row">
38
+ <label>seeds: <input id="count" type="number" value="100000" min="1" /></label>
39
+ <button id="run">Run search</button>
40
+ <span class="stat" id="status">idle</span>
41
+ </div>
42
+
43
+ <pre id="out">ready.</pre>
44
+
45
+ <script type="module">
46
+ import bootsharp, { MotelyWasm, MotelyWasmEvents, Motely } from "https://cdn.seedfinder.app/motely-wasm/latest/index.mjs";
47
+
48
+ const out = document.getElementById("out");
49
+ const status = document.getElementById("status");
50
+ const runBtn = document.getElementById("run");
51
+ const log = (msg) => { out.textContent = msg + "\n" + out.textContent; };
52
+
53
+ status.textContent = "booting wasm…";
54
+ await bootsharp.boot();
55
+ status.textContent = `ready · motely-wasm ${MotelyWasm.getVersion()}`;
56
+ runBtn.disabled = false;
57
+
58
+ const hits = [];
59
+ MotelyWasmEvents.onResult.subscribe((seed, score) => {
60
+ hits.push({ seed, score });
61
+ if (hits.length <= 20) log(` hit: ${seed} score=${score}`);
62
+ });
63
+ MotelyWasmEvents.onProgress.subscribe((snap) => {
64
+ status.textContent = `searching · ${snap.totalSeedsSearched.toLocaleString()} / matches ${snap.matchingSeeds}`;
65
+ });
66
+
67
+ runBtn.addEventListener("click", async () => {
68
+ const jaml = document.getElementById("jaml").value;
69
+ const count = Number(document.getElementById("count").value) || 1;
70
+ hits.length = 0;
71
+ out.textContent = "";
72
+ log(`starting random search · ${count.toLocaleString()} seeds`);
73
+ runBtn.disabled = true;
74
+ try {
75
+ const search = MotelyWasm.startRandom(jaml, count);
76
+ const done = await search.waitForCompletion();
77
+ log(`done · state=${Motely.MotelyWasmSearchState[done.state]} searched=${done.totalSeedsSearched} matched=${done.matchingSeeds}`);
78
+ search.dispose();
79
+ } catch (err) {
80
+ log(`error: ${err?.message ?? err}`);
81
+ } finally {
82
+ runBtn.disabled = false;
83
+ status.textContent = `ready · motely-wasm ${MotelyWasm.getVersion()}`;
84
+ }
85
+ });
86
+ </script>
87
+ </body>
88
+ </html>