motely-wasm 14.0.2 → 14.1.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/README.md +100 -0
- package/demo.html +88 -0
- package/index.mjs +49 -2
- package/package.json +32 -5
- package/sync-version.mjs +32 -0
- package/types/bindings.g.d.ts +20 -0
package/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# motely-wasm
|
|
2
|
+
|
|
3
|
+
Find Balatro seeds with plain-language JAML filters — Jimbo's Ante Markup Language. SIMD-vectorized seed search (Motely engine, C# → NativeAOT-LLVM WASM). Browser + Node.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install motely-wasm
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Boot & Search
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import motely, { MotelyWasm, MotelyWasmEvents } from "motely-wasm";
|
|
15
|
+
|
|
16
|
+
await motely.boot();
|
|
17
|
+
|
|
18
|
+
const jaml = `
|
|
19
|
+
name: Blueprint Copy Engine
|
|
20
|
+
deck: Red
|
|
21
|
+
stake: White
|
|
22
|
+
must:
|
|
23
|
+
- rareJoker: Blueprint
|
|
24
|
+
antes: [1, 2, 3]
|
|
25
|
+
should:
|
|
26
|
+
- rareJoker: Brainstorm
|
|
27
|
+
score: 80
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
MotelyWasmEvents.onResult.subscribe((seed, score) => console.log(seed, score));
|
|
31
|
+
MotelyWasmEvents.onProgress.subscribe((searched, matching) => { /* … */ });
|
|
32
|
+
MotelyWasmEvents.onComplete.subscribe((status, searched, matched) => { /* … */ });
|
|
33
|
+
|
|
34
|
+
const search = MotelyWasm.startRandomSearch(jaml, 10000);
|
|
35
|
+
// later: search.cancel();
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## CDN Delivery (recommended for MCP Apps / single-file bundles)
|
|
39
|
+
|
|
40
|
+
Every published version of `motely-wasm` is mirrored to a public CDN:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
https://cdn.seedfinder.app/motely-wasm/<version>/index.mjs
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Use this when your build can't (or shouldn't) bundle the WASM payload inline — for example:
|
|
47
|
+
|
|
48
|
+
- **MCP Apps** bundled as a single HTML resource: dynamic `import(cdn)` keeps the HTML small and the browser caches the engine across tool invocations.
|
|
49
|
+
- **Vercel Functions / Cloudflare Workers**: dynamic import avoids bundling ~11MB of WASM into every deployment artifact.
|
|
50
|
+
- **CDN-hosted static sites**: one cached copy of the engine per version, shared across all pages.
|
|
51
|
+
|
|
52
|
+
Example — load the engine from CDN inside a Web Worker:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
// searchWorker.ts
|
|
56
|
+
const mod = await import(/* @vite-ignore */
|
|
57
|
+
`https://cdn.seedfinder.app/motely-wasm/12.4.1/index.mjs`);
|
|
58
|
+
await mod.default.boot();
|
|
59
|
+
const { MotelyWasm, MotelyWasmEvents } = mod;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Version must be pinned explicitly — the CDN serves immutable, versioned paths for long-term caching (`Cache-Control: max-age=31536000`).
|
|
63
|
+
|
|
64
|
+
### Content Security Policy
|
|
65
|
+
|
|
66
|
+
When embedding in a sandboxed iframe (MCP Apps), allow both script loading and fetch/import:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
script-src https://cdn.seedfinder.app
|
|
70
|
+
connect-src https://cdn.seedfinder.app
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
For MCP App servers using `@modelcontextprotocol/ext-apps`:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
{
|
|
77
|
+
ui: {
|
|
78
|
+
csp: {
|
|
79
|
+
resourceDomains: ["https://cdn.seedfinder.app"],
|
|
80
|
+
connectDomains: ["https://cdn.seedfinder.app"],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Build
|
|
87
|
+
|
|
88
|
+
NativeAOT-LLVM + SIMD. Verify "LLVM compilation to IR finished" in build output.
|
|
89
|
+
|
|
90
|
+
```xml
|
|
91
|
+
<BootsharpLlvm>true</BootsharpLlvm>
|
|
92
|
+
<WasmEnableSIMD>true</WasmEnableSIMD>
|
|
93
|
+
<EmccFlags>-msimd128</EmccFlags>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The `MONO_WASM:` prefix in console logs is Bootsharp's glue log string — this is **not** a Mono runtime build. Motely is NativeAOT-LLVM.
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
MIT
|
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>
|