motely-wasm 20.0.0 → 20.0.1
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 +126 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# motely-wasm
|
|
2
|
+
|
|
3
|
+
WebAssembly build of [MotelyJAML](https://github.com/OptimusPi/MotelyJAML) — the SIMD Balatro seed search engine with JAML filter support. Powers [seedfinder.app](https://seedfinder.app).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install motely-wasm
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Boot
|
|
12
|
+
|
|
13
|
+
The WASM binary is **sideloaded** — a separate `dist/bin/motely-wasm.wasm`, **not** base64-embedded — so `boot()` **must** be told where to find it. A no-arg `boot()` will not load the runtime and every search silently does nothing.
|
|
14
|
+
|
|
15
|
+
In Node, read the bytes and pass them directly (`fetch` can't read `file://` URLs):
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { readFile } from "node:fs/promises";
|
|
19
|
+
import { dirname, resolve } from "node:path";
|
|
20
|
+
import { fileURLToPath } from "node:url";
|
|
21
|
+
import bootsharp from "motely-wasm";
|
|
22
|
+
|
|
23
|
+
const dist = resolve(dirname(fileURLToPath(import.meta.url)), "node_modules/motely-wasm/dist");
|
|
24
|
+
const wasm = await readFile(resolve(dist, "bin", bootsharp.manifest.wasm));
|
|
25
|
+
await bootsharp.boot({ wasm });
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
In the browser, pass the root URL your host serves `dist/` at:
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
await bootsharp.boot("/motely-wasm/dist");
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Guard re-boots with `bootsharp.getStatus() === bootsharp.BootStatus.Standby`.
|
|
35
|
+
|
|
36
|
+
## Imports
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
// Main API — the C# Program class, renamed to Motely
|
|
40
|
+
import { Program as Motely } from "motely-wasm/dist/generated/modules/motely/wasm.g.mjs";
|
|
41
|
+
|
|
42
|
+
// Enums — MotelyDeck, MotelyStake, etc.
|
|
43
|
+
import * as enums from "motely-wasm/dist/generated/modules/motely/enums.g.mjs";
|
|
44
|
+
|
|
45
|
+
// Types — MotelyProgress, IMotelySearch, MotelyScoredSeedResult, etc.
|
|
46
|
+
import * as types from "motely-wasm/dist/generated/modules/motely.g.mjs";
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Quick start
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
// Optional [Import] hook — surface WASM-side errors. Bind BEFORE boot:
|
|
53
|
+
// Bootsharp snapshots [Import] bindings at boot().
|
|
54
|
+
Motely.reportWasmError = (msg) => console.error("[WASM]", msg);
|
|
55
|
+
|
|
56
|
+
// Subscribe to events
|
|
57
|
+
Motely.onSeedMatch.subscribe(seed => console.log("match:", seed));
|
|
58
|
+
Motely.onProgress.subscribe(p => console.log(`${p.percentComplete.toFixed(1)}%`));
|
|
59
|
+
|
|
60
|
+
// Parse a JAML filter. JAML is YAML, and YAML is a JSON superset — a JSON
|
|
61
|
+
// object string parses too, which is what makes it round-trip cleanly over MCP.
|
|
62
|
+
const config = Motely.parseJaml(`
|
|
63
|
+
name: WeeMonday
|
|
64
|
+
deck: Erratic
|
|
65
|
+
stake: Black
|
|
66
|
+
must:
|
|
67
|
+
- joker: WeeJoker
|
|
68
|
+
antes: [1]
|
|
69
|
+
`);
|
|
70
|
+
|
|
71
|
+
// Run a search (blocks until complete — run in a Worker for non-blocking UI).
|
|
72
|
+
const search = Motely.runSequentialSearch(config);
|
|
73
|
+
console.log(search.matchingSeeds, "matches out of", search.totalSeedsSearched);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## API
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
Motely.parseJaml(jaml) // string → JamlConfig (throws on invalid JAML)
|
|
80
|
+
Motely.explainJaml(config) // human-readable plan summary
|
|
81
|
+
Motely.createPlan(config) // JamlSearchPlan (tally columns, CSV header)
|
|
82
|
+
Motely.jamlToJson(jaml) // JAML string → JSON string
|
|
83
|
+
Motely.jsonToJaml(json) // JSON string → JAML string
|
|
84
|
+
Motely.jamlyzer(seed, lens) // analyze ONE seed through a JamlConfig lens → JamlyzerSnapshot
|
|
85
|
+
Motely.nativeFilterNames() // built-in native filter names
|
|
86
|
+
|
|
87
|
+
Motely.runSequentialSearch(config, ...) // sequential seed search
|
|
88
|
+
Motely.runRandomSearch(config, count) // random seed sample
|
|
89
|
+
Motely.runSeedListSearch(config) // search only config.seeds
|
|
90
|
+
Motely.runAestheticSearch(config, aesthetic) // aesthetic / scored search
|
|
91
|
+
Motely.runNativeListSearch(name, seeds) // named native filter over a seed list
|
|
92
|
+
Motely.runPassthroughListSearch(seeds) // no filter, just iterate seeds
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Events
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
Motely.onSeedMatch.subscribe(seed => {}) // string — each matching seed
|
|
99
|
+
Motely.onScoredResult.subscribe(result => {}) // MotelyScoredSeedResult { seed, score, tallies }
|
|
100
|
+
Motely.onProgress.subscribe(p => {}) // MotelyProgress
|
|
101
|
+
Motely.onFileChanges.subscribe(changes => {}) // file system changes (browser OPFS)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## File system (browser)
|
|
105
|
+
|
|
106
|
+
`Motely.pickRoot`, `mountRoot`, `unmountRoot`, `readTextFile`, `writeTextFile` use the browser File System Access API via `Bootsharp.FileSystem`. Initialize the JS extension before booting:
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
import * as fs from "@rewaffle/bootsharp-file-system";
|
|
110
|
+
import { Bootsharp } from "motely-wasm/dist/generated/modules/bootsharp/file-system.g.mjs";
|
|
111
|
+
|
|
112
|
+
fs.init(Bootsharp.FileSystem.FileMounter);
|
|
113
|
+
await bootsharp.boot("/motely-wasm/dist");
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Jimmolate
|
|
117
|
+
|
|
118
|
+
Scalar predicate filtering after the base SIMD pass. Bind the predicate **before** boot (Bootsharp snapshots `[Import]` bindings at boot), then enable it:
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
Motely.jimmolatePredicate = (result) => {
|
|
122
|
+
// result is MotelyScoredSeedResult — { seed, score, tallies }
|
|
123
|
+
return result.score > 0; // return true to keep the seed
|
|
124
|
+
};
|
|
125
|
+
Motely.jimmolateEnabled = true;
|
|
126
|
+
```
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motely-wasm",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "20.0.
|
|
4
|
+
"version": "20.0.1",
|
|
5
5
|
"description": "Balatro seed search + per-seed analysis, powered by JAML (Jimbo's Ante Markup Language). Vectorized SIMD engine, compiled to WebAssembly.",
|
|
6
6
|
"author": "Nathanial P. Howard",
|
|
7
7
|
"license": "MIT",
|