motely-wasm
v2.2.3
Published
Run the classic Analyzer on a Balatro seed, and more all in your browser!
Maintainers
Readme
motely-wasm
Browser-only WebAssembly package for Motely Seed Oracle. Use in the browser, not in Node.
Installation
npm install motely-wasmOne-time setup (no recurring chores)
Use the plugin for your bundler. It serves/copies _framework and sets the required COOP/COEP headers. After this, you never copy files or touch headers again.
Vite
// vite.config.js
import { defineConfig } from "vite";
import motelyWasm from "motely-wasm/vite-plugin";
export default defineConfig({
plugins: [motelyWasm()],
});Dev: _framework is served at /_framework, headers set. Build: _framework and _framework_nt are copied into dist/.
Next.js
// next.config.mjs (or .js)
import withMotelyWasm from "motely-wasm/next-plugin";
export default withMotelyWasm({
// your existing next config
});On first run the plugin copies _framework and _framework_nt into public/ and sets COOP/COEP. No manual copy, no recurring setup.
Turbopack: The way loadMotely() loads the WASM runtime does not work with Next.js when Turbopack is enabled. Use the default webpack bundler (do not enable --turbo / turbo: true) when using motely-wasm.
Other frameworks (SvelteKit, Astro, Remix, static host, etc.)
No plugin needed. Do the same one-time setup in your stack:
- Serve
_framework: copynode_modules/motely-wasm/_frameworkinto your static/public folder, or configure your dev/server to serve that folder at/_framework. - Set COOP/COEP headers on all responses. Without these, the browser silently disables SharedArrayBuffer and multi-threading — your search will run single-threaded without any error:
Cross-Origin-Opener-Policy: same-origin Cross-Origin-Embedder-Policy: require-corp
Server config examples
Netlify / Cloudflare Pages — copy node_modules/motely-wasm/_headers to your site root, or add to your own _headers:
/*
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corpNginx:
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header Cross-Origin-Embedder-Policy "require-corp" always;Apache (.htaccess):
Header set Cross-Origin-Opener-Policy "same-origin"
Header set Cross-Origin-Embedder-Policy "require-corp"IIS (web.config):
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Cross-Origin-Opener-Policy" value="same-origin" />
<add name="Cross-Origin-Embedder-Policy" value="require-corp" />
</customHeaders>
</httpProtocol>
</system.webServer>Node/Express:
app.use((req, res, next) => {
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
next();
});Verify: open DevTools Console and run self.crossOriginIsolated — must return true.
Then call loadMotely() (auto-detects threads) or loadMotely({ baseUrl: "/your/path" }) if you used a different path.
Usage
import { loadMotely } from "motely-wasm";
const api = await loadMotely();
const version = api.getVersion();
const result = api.analyzeSeed("TACO1111", "Red", "White");
// Analyze seed with ante-by-ante breakdown
result.antes.forEach(ante => {
console.log(`Ante ${ante.ante}: Boss=${ante.boss}, Draw order=${ante.drawOrder}`);
ante.shopQueue.forEach(item => console.log(` Shop: ${item.name}`));
});
// Search with JAML filter
const searchResult = await api.startJamlSearch(jamlContent, {
threadCount: 4, // auto-detected if omitted; defaults to processorCount
batchCharCount: 4, // default: 4 (1.5M seeds per batch, range 1-7)
onProgress: (searched, matches, elapsed, count) => {
console.log(`Searched: ${searched}, Matches: ${matches}`);
},
onResult: (seed, score) => {
console.log(`Found: ${seed}`);
}
});Batch size tuning:
batchCharCount=4(default): 1.5M seeds/batch, good balance between responsiveness and JS interop overheadbatchCharCount=3: 175K seeds/batch, more responsive UI updatesbatchCharCount=5: 52M seeds/batch, fewer JS calls, less responsive
Optional custom base URL (e.g. CDN): loadMotely({ baseUrl: "https://cdn.example/assets" }).
Optional threading mode: loadMotely({ threads: "auto" | "on" | "off" }) (default: auto).
JAML schema
The package includes the JAML JSON schema for validation and editor IntelliSense. Use the file at node_modules/motely-wasm/jaml.schema.json or resolve motely-wasm/jaml.schema.json (e.g. copy to your public dir or point your editor at it).
License
MIT. See the MotelyJAML repository for details.
