motely-wasm 20.0.0 → 20.0.2
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 +113 -0
- package/RELEASE.md +139 -0
- package/dist/generated/resources.g.mjs +15 -1
- package/package.json +13 -3
- package/dist/bin/motely-wasm.wasm +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
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 **embedded** in the JS module — no extra files to serve.
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import bootsharp from "motely-wasm";
|
|
17
|
+
|
|
18
|
+
await bootsharp.boot();
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Guard re-boots with `bootsharp.getStatus() === bootsharp.BootStatus.Standby`.
|
|
22
|
+
|
|
23
|
+
## Imports
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
// Main API — the C# Program class, renamed to Motely
|
|
27
|
+
import { Program as Motely } from "motely-wasm/dist/generated/modules/motely/wasm.g.mjs";
|
|
28
|
+
|
|
29
|
+
// Enums — MotelyDeck, MotelyStake, etc.
|
|
30
|
+
import * as enums from "motely-wasm/dist/generated/modules/motely/enums.g.mjs";
|
|
31
|
+
|
|
32
|
+
// Types — MotelyProgress, IMotelySearch, MotelyScoredSeedResult, etc.
|
|
33
|
+
import * as types from "motely-wasm/dist/generated/modules/motely.g.mjs";
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick start
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
// Optional [Import] hook — surface WASM-side errors. Bind BEFORE boot:
|
|
40
|
+
// Bootsharp snapshots [Import] bindings at boot().
|
|
41
|
+
Motely.reportWasmError = (msg) => console.error("[WASM]", msg);
|
|
42
|
+
|
|
43
|
+
// Subscribe to events
|
|
44
|
+
Motely.onSeedMatch.subscribe(seed => console.log("match:", seed));
|
|
45
|
+
Motely.onProgress.subscribe(p => console.log(`${p.percentComplete.toFixed(1)}%`));
|
|
46
|
+
|
|
47
|
+
// Parse a JAML filter. JAML is YAML, and YAML is a JSON superset — a JSON
|
|
48
|
+
// object string parses too, which is what makes it round-trip cleanly over MCP.
|
|
49
|
+
const config = Motely.parseJaml(`
|
|
50
|
+
name: WeeMonday
|
|
51
|
+
deck: Erratic
|
|
52
|
+
stake: Black
|
|
53
|
+
must:
|
|
54
|
+
- joker: WeeJoker
|
|
55
|
+
antes: [1]
|
|
56
|
+
`);
|
|
57
|
+
|
|
58
|
+
// Run a search (blocks until complete — run in a Worker for non-blocking UI).
|
|
59
|
+
const search = Motely.runSequentialSearch(config);
|
|
60
|
+
console.log(search.matchingSeeds, "matches out of", search.totalSeedsSearched);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## API
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
Motely.parseJaml(jaml) // string → JamlConfig (throws on invalid JAML)
|
|
67
|
+
Motely.explainJaml(config) // human-readable plan summary
|
|
68
|
+
Motely.createPlan(config) // JamlSearchPlan (tally columns, CSV header)
|
|
69
|
+
Motely.jamlToJson(jaml) // JAML string → JSON string
|
|
70
|
+
Motely.jsonToJaml(json) // JSON string → JAML string
|
|
71
|
+
Motely.jamlyzer(seed, lens) // analyze ONE seed through a JamlConfig lens → JamlyzerSnapshot
|
|
72
|
+
Motely.nativeFilterNames() // built-in native filter names
|
|
73
|
+
|
|
74
|
+
Motely.runSequentialSearch(config, ...) // sequential seed search
|
|
75
|
+
Motely.runRandomSearch(config, count) // random seed sample
|
|
76
|
+
Motely.runSeedListSearch(config) // search only config.seeds
|
|
77
|
+
Motely.runAestheticSearch(config, aesthetic) // aesthetic / scored search
|
|
78
|
+
Motely.runNativeListSearch(name, seeds) // named native filter over a seed list
|
|
79
|
+
Motely.runPassthroughListSearch(seeds) // no filter, just iterate seeds
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Events
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
Motely.onSeedMatch.subscribe(seed => {}) // string — each matching seed
|
|
86
|
+
Motely.onScoredResult.subscribe(result => {}) // MotelyScoredSeedResult { seed, score, tallies }
|
|
87
|
+
Motely.onProgress.subscribe(p => {}) // MotelyProgress
|
|
88
|
+
Motely.onFileChanges.subscribe(changes => {}) // file system changes (browser OPFS)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## File system (browser)
|
|
92
|
+
|
|
93
|
+
`Motely.pickRoot`, `mountRoot`, `unmountRoot`, `readTextFile`, `writeTextFile` use the browser File System Access API via `Bootsharp.FileSystem`. Initialize the JS extension before booting:
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
import * as fs from "@rewaffle/bootsharp-file-system";
|
|
97
|
+
import { Bootsharp } from "motely-wasm/dist/generated/modules/bootsharp/file-system.g.mjs";
|
|
98
|
+
|
|
99
|
+
fs.init(Bootsharp.FileSystem.FileMounter);
|
|
100
|
+
await bootsharp.boot();
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Jimmolate
|
|
104
|
+
|
|
105
|
+
Scalar predicate filtering after the base SIMD pass. Bind the predicate **before** boot (Bootsharp snapshots `[Import]` bindings at boot), then enable it:
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
Motely.jimmolatePredicate = (result) => {
|
|
109
|
+
// result is MotelyScoredSeedResult — { seed, score, tallies }
|
|
110
|
+
return result.score > 0; // return true to keep the seed
|
|
111
|
+
};
|
|
112
|
+
Motely.jimmolateEnabled = true;
|
|
113
|
+
```
|
package/RELEASE.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Releasing motely-wasm to npm — the real pipeline
|
|
2
|
+
|
|
3
|
+
This is the finished reasoning for "how do you update the README and the package
|
|
4
|
+
without hand-editing anything," grounded in the Bootsharp docs and the actual
|
|
5
|
+
state of this repo. It replaces the don't-touch comment in `Motely.Wasm.csproj`
|
|
6
|
+
with an *understanding* of why that comment exists and what the correct fix is.
|
|
7
|
+
|
|
8
|
+
## What ships, and from where
|
|
9
|
+
|
|
10
|
+
`npm publish` runs from **`motely-wasm/`** (this directory). npm packs three
|
|
11
|
+
things from here, regardless of any `files` field:
|
|
12
|
+
|
|
13
|
+
| File | Owner today | Owner it should have |
|
|
14
|
+
|------|-------------|----------------------|
|
|
15
|
+
| `package.json` | hand-maintained | **npm** owns the version; structure hand-authored |
|
|
16
|
+
| `README.md` | hand-created (was *missing* for 20 weeks) | authored here, single source |
|
|
17
|
+
| `dist/` | Bootsharp build output (`BootsharpPublishDirectory`) | Bootsharp, regenerated on build |
|
|
18
|
+
|
|
19
|
+
`dist/bin/motely-wasm.wasm` is the sideloaded runtime (`BootsharpBinariesDirectory`
|
|
20
|
+
is set → separate `.wasm`, not base64-embedded → `boot()` MUST be told where it is;
|
|
21
|
+
that is the whole reason for the boot section in `README.md`).
|
|
22
|
+
|
|
23
|
+
## The root bug: two version sources, already drifted
|
|
24
|
+
|
|
25
|
+
There are **two** places a version lives, and they are out of sync right now:
|
|
26
|
+
|
|
27
|
+
- `Directory.Packages.props` → `<MotelyVersion>20.0.0</MotelyVersion>` — the **.NET
|
|
28
|
+
assembly version**, consumed solution-wide (`Motely.csproj`, `Motely.Wasm.csproj`
|
|
29
|
+
both do `<Version>$(MotelyVersion)</Version>`).
|
|
30
|
+
- `motely-wasm/package.json` → `"version": "20.0.1"` — the **npm package version**,
|
|
31
|
+
the one users actually `npm install`.
|
|
32
|
+
|
|
33
|
+
The published `20.0.1` is the `20.0.0` engine + a fixed README. That patch bump is
|
|
34
|
+
*semantically correct* (docs-only fix), but it was done by **hand-typing `20.0.1`
|
|
35
|
+
into package.json**, which is exactly the foot-gun: a human typing a version is a
|
|
36
|
+
human introducing drift.
|
|
37
|
+
|
|
38
|
+
These two versions are genuinely different concerns and **may** legitimately
|
|
39
|
+
diverge (a README-only npm patch should not force an engine version bump). The fix
|
|
40
|
+
is not "force them equal" — it's "make each one bumped by a tool, never by hand."
|
|
41
|
+
|
|
42
|
+
## Why Bootsharp can't own package.json
|
|
43
|
+
|
|
44
|
+
Bootsharp regenerates `package.json` on every build with a **bare** template — look
|
|
45
|
+
at `Motely.Wasm/obj/package.json` (where it's currently parked):
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{ "name": "motely-wasm", "type": "module", "exports": {...}, "browser": {...} }
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
No `version`, no `main`, no `types`, no `author`, no `license`, no `description`.
|
|
52
|
+
Publishing that fails (`npm publish` with no version → the `reading 'prerelease'`
|
|
53
|
+
crash the csproj comment warns about). Per the Bootsharp docs, `BootsharpPackageDirectory`
|
|
54
|
+
defaults to the project dir and Bootsharp **overwrites** the file there on every
|
|
55
|
+
build. So pointing it at the real npm root clobbers the rich manifest every build.
|
|
56
|
+
|
|
57
|
+
The current mitigation — redirect `BootsharpPackageDirectory` to `obj/` and
|
|
58
|
+
hand-author `motely-wasm/package.json` — is **correct**. Don't undo it. The bare
|
|
59
|
+
template genuinely lacks what npm needs, and Bootsharp offers no hook to enrich it.
|
|
60
|
+
|
|
61
|
+
## The correct ownership split
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
Directory.Packages.props : MotelyVersion — engine/assembly version, bump for ENGINE releases
|
|
65
|
+
motely-wasm/package.json : "version" — npm package version, bump with `npm version patch`
|
|
66
|
+
motely-wasm/package.json : everything else — stable, hand-authored, rarely changes
|
|
67
|
+
motely-wasm/README.md — authored HERE (package root), single source
|
|
68
|
+
motely-wasm/dist/ — Bootsharp output, never hand-touched
|
|
69
|
+
Motely.Wasm/obj/package.json — Bootsharp's throwaway bare template, ignored
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The "no hand-editing" rule applies to the **version field specifically**. You never
|
|
73
|
+
type a version again — `npm version patch` does. The rest of package.json (exports
|
|
74
|
+
map with types, browser shims, author) is a small stable file; authoring it once by
|
|
75
|
+
hand is fine and *better* than a generator that drops the fields npm requires.
|
|
76
|
+
|
|
77
|
+
## The release command (zero hand-edits)
|
|
78
|
+
|
|
79
|
+
From `motely-wasm/`:
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
npm version patch # 20.0.1 -> 20.0.2 in package.json AND creates the git tag v20.0.2
|
|
83
|
+
npm publish # packs package.json + README.md + dist/, pushes to npm
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`npm version patch` is the tool that "knows" — it edits the version *and* tags git
|
|
87
|
+
atomically. Never open package.json to change the version.
|
|
88
|
+
|
|
89
|
+
### Make it bulletproof with npm lifecycle scripts (the real automation)
|
|
90
|
+
|
|
91
|
+
Add to `motely-wasm/package.json` so a stale `dist/` can never ship:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
"scripts": {
|
|
95
|
+
"build": "dotnet publish ../Motely.Wasm/Motely.Wasm.csproj -c Release",
|
|
96
|
+
"prepublishOnly": "npm run build"
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`prepublishOnly` runs **after** `npm version patch` bumps the version and **before**
|
|
101
|
+
the tarball is packed — so `npm publish` always ships a freshly built `dist/` that
|
|
102
|
+
matches. (`dotnet publish` in Release is the Bootsharp path that emits `dist/` +
|
|
103
|
+
the sideloaded wasm; see Bootsharp `getting-started.md` / `build-config.md`.)
|
|
104
|
+
|
|
105
|
+
> Not yet wired — this is the one concrete edit the next session should make and
|
|
106
|
+
> test with `npm publish --dry-run`. Left undone tonight on purpose (handoff, not
|
|
107
|
+
> a 2am publish).
|
|
108
|
+
|
|
109
|
+
## The README: one source, here
|
|
110
|
+
|
|
111
|
+
`Motely.Wasm/README.md` (the C# project dir) is **stale v19** — it documents the
|
|
112
|
+
removed `jimmolateProbe` / `MotelySingleSearchContext`. It is NOT what ships and
|
|
113
|
+
should be deleted or treated as dead. The shipping README is **`motely-wasm/README.md`**
|
|
114
|
+
(this dir), authored against the live v20 surface. Keep exactly one. Don't add a
|
|
115
|
+
build "copy README" step that creates a second source to drift — author it where it
|
|
116
|
+
ships.
|
|
117
|
+
|
|
118
|
+
## What's drifted right now (reconcile when clear-headed)
|
|
119
|
+
|
|
120
|
+
- `MotelyVersion` is `20.0.0`; npm is `20.0.1`. The published wasm reports `20.0.0`
|
|
121
|
+
internally. Cosmetic, not breaking. If you want them re-aligned, bump
|
|
122
|
+
`MotelyVersion` to match at the next engine touch and rebuild — don't republish
|
|
123
|
+
just for this.
|
|
124
|
+
- The `Motely.Wasm.csproj` comment block says "DO NOT re-add a FinalizeNpmPackage
|
|
125
|
+
target." That advice is still right (Bootsharp's bare template can't be the
|
|
126
|
+
source), but the *reason* is now written down here instead of as a scar.
|
|
127
|
+
|
|
128
|
+
## Docs citations
|
|
129
|
+
|
|
130
|
+
- Bootsharp `build-config.md`: `BootsharpPackageDirectory` (default = project dir,
|
|
131
|
+
"Directory to publish package.json"), `BootsharpPublishDirectory`,
|
|
132
|
+
`BootsharpBinariesDirectory`.
|
|
133
|
+
- Bootsharp `sideloading.md`: binaries dir **set** → separate `.wasm`, `boot()` takes
|
|
134
|
+
a root URL or `{ wasm }` bytes (the v20 boot contract — see `README.md`).
|
|
135
|
+
- Bootsharp `getting-started.md`: `dotnet publish` (Release) produces the module +
|
|
136
|
+
`package.json`; Release auto-enables NativeAOT-LLVM + trimming.
|
|
137
|
+
- npm: `package.json` / `README.md` / `LICENSE` always ship regardless of `files`;
|
|
138
|
+
`npm version <patch|minor|major>` bumps version + tags git; `npm publish --dry-run`
|
|
139
|
+
to verify the tarball before pushing.
|