motely-wasm 19.0.2 → 19.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 CHANGED
@@ -15,10 +15,9 @@ npm install motely-wasm
15
15
  ```js
16
16
  import bootsharp, { Motely } from "motely-wasm";
17
17
 
18
- // Boot the .NET WASM runtime. In a browser, pass the URL path under which your
19
- // host serves the package's `bin/` directory (where dotnet.native.wasm lives).
20
- // In Node, pass the `.wasm` bytes directly — see the "Booting" section below.
21
- await bootsharp.boot("/motely-wasm/bin");
18
+ // Boot the .NET WASM runtime no arguments needed.
19
+ // The WASM binary is embedded in the package as base64 (single self-contained ESM).
20
+ await bootsharp.boot();
22
21
 
23
22
  // A JAML filter — see https://github.com/OptimusPi/MotelyJAML for the language.
24
23
  const jaml = `
@@ -46,53 +45,22 @@ console.log("done:", search.totalSeedsSearched, "searched,", search.matchingSeed
46
45
 
47
46
  ## Booting
48
47
 
49
- `bootsharp.boot(...)` initializes the .NET WASM runtime. Call it once before any
50
- `Motely.*` API. The argument shape depends on the host.
48
+ `bootsharp.boot()` initializes the .NET WASM runtime. Call it once before any `Motely.*` API.
51
49
 
52
- ### Browser
53
-
54
- Pass the URL path your host serves the package's `bin/` directory at (where
55
- `dotnet.native.wasm` lives). It's host-chosen — typical mountings:
56
-
57
- | Host | Mount `bin/` at | Boot call |
58
- | --- | --- | --- |
59
- | Vite / Storybook `staticDirs` | `/motely-wasm/bin` | `boot("/motely-wasm/bin")` |
60
- | Next.js route handler | `/motely-wasm/bin/[...path]` | `boot("/motely-wasm/bin")` |
61
- | Public CDN (pinned version) | `https://unpkg.com/motely-wasm@<version>/bin` | `boot("https://unpkg.com/motely-wasm@18.2.2/bin")` |
62
-
63
- Web Workers must boot from the **same** URL as the main thread — absolute paths
64
- in a worker resolve against the page origin, so whichever URL serves the WASM
65
- to the main thread is the same one the worker must pass.
50
+ The WASM binary is **embedded** in the package as base64 — no separate files to serve, no CDN config, no `bin/` directory. One import, one `boot()`, done. Works in browser, Node, Web Workers, v0 previews, MCP apps, GitHub Pages — anywhere.
66
51
 
67
52
  ```js
68
53
  import bootsharp from "motely-wasm";
69
54
 
70
55
  if (bootsharp.getStatus() === bootsharp.BootStatus.Standby) {
71
- await bootsharp.boot("/motely-wasm/bin");
56
+ await bootsharp.boot();
72
57
  }
73
58
 
74
59
  console.log(bootsharp.getStatus()); // BootStatus.Booted
75
60
  ```
76
61
 
77
- ### Node / Bun / Deno
78
-
79
- Same ESM import as the browser. Point `boot()` at the published `bin/` directory
80
- (Node `fetch` accepts `file://` URLs):
81
-
82
- ```js
83
- import bootsharp, { Motely } from "motely-wasm";
84
-
85
- const binRoot = new URL("bin/", import.meta.resolve("motely-wasm/package.json")).href;
86
- await bootsharp.boot(binRoot);
87
-
88
- const status = Motely.validateJaml(jaml);
89
- ```
90
-
91
- Requires Node ≥ 20.6 (`import.meta.resolve`). Node 22 LTS is the recommended floor.
92
-
93
62
  **Publish gate (repo):** after `dotnet publish Motely.Wasm -c Release`, run
94
- `node Motely.Wasm/motely.test.mjs` and `node Motely.Wasm/pack-consumer-smoke.mjs`
95
- (`npm pack` → fresh `npm install` → same boot path).
63
+ `node Motely.Wasm/motely.test.mjs` and `node Motely.Wasm/pack-consumer-smoke.mjs`.
96
64
 
97
65
  ## JAML API
98
66
 
@@ -193,74 +161,6 @@ console.log(search.isCompleted, search.totalSeedsSearched, search.matchingSeeds)
193
161
  search.cancel(); // stop early
194
162
  ```
195
163
 
196
- ## Stream cursor
197
-
198
- `Motely.createStreamCursor(seed, deck, stake, ante, kind)` returns a stateful cursor over
199
- one of Balatro's per-ante PRNG streams — one packed int per item, no JAML filter needed.
200
- The `kind` argument selects which stream; one factory + one enum arg covers every stream
201
- type:
202
-
203
- ```js
204
- import { Motely } from "motely-wasm";
205
- import { MotelyStreamKind } from "motely-wasm/motely";
206
- import { MotelyDeck, MotelyStake } from "motely-wasm/motely/enums";
207
-
208
- const cursor = Motely.createStreamCursor("AAAAAAAA", MotelyDeck.Red, MotelyStake.White, 1, MotelyStreamKind.Shop);
209
- const items = cursor.getNextChunk(6); // 6 packed ints, one WASM crossing
210
- ```
211
-
212
- **Always prefer `getNextChunk(n)` over repeated `getNext()` calls** — each call is a WASM
213
- interop crossing, so batching is the right default.
214
-
215
- | `MotelyStreamKind` value | Stream | Returned int |
216
- |---|---|---|
217
- | `Shop` | Mixed shop (jokers, tarots, planets, spectrals on Ghost, standard cards with MagicTrick) | Packed item (`decodeItemType`, `decodeItemCategory`, …) |
218
- | `Joker` | Shop jokers — includes edition + sticker bits | Packed item |
219
- | `Tarot` | Shop tarots | Packed item |
220
- | `Planet` | Shop planets | Packed item |
221
- | `Spectral` | Shop spectrals (non-Ghost returns `SpectralExcludedByStream`) | Packed item |
222
- | `LegendaryJoker` | Legendary fixed-rarity joker stream | Packed item |
223
- | `RareTagJoker` | Rare Tag hand-out joker stream | Packed item |
224
- | `Tag` | Tags — raw `MotelyTag` enum cast to int. Decoders do not apply; use `MotelyTag[value]`. | `(int)MotelyTag` |
225
- | `Voucher` | Vouchers — raw `MotelyVoucher` enum cast to int. Uses an empty run state, so odd-indexed (prerequisite-required) vouchers are skipped by the engine. Use `MotelyVoucher[value]`. | `(int)MotelyVoucher` |
226
-
227
- ## Packed-int decoders
228
-
229
- Stream cursors return packed integers. Bit fields are extracted with the decode helpers
230
- on `Motely`:
231
-
232
- ```js
233
- import { Motely } from "motely-wasm";
234
- import { MotelyStreamKind } from "motely-wasm/motely";
235
- import {
236
- MotelyItemType, MotelyItemTypeCategory, MotelyJokerRarity,
237
- MotelyItemEdition, MotelyItemSeal, MotelyItemEnhancement,
238
- } from "motely-wasm/motely/enums";
239
-
240
- const cursor = Motely.createStreamCursor("AAAAAAAA", 0, 0, 1, MotelyStreamKind.Joker);
241
- const v = cursor.getNext();
242
-
243
- const type = Motely.decodeItemType(v); // → MotelyItemType value
244
- const category = Motely.decodeItemCategory(v); // → MotelyItemTypeCategory value
245
- const rarity = Motely.decodeJokerRarity(v); // → MotelyJokerRarity (Common/Uncommon/Rare/Legendary)
246
- const edition = Motely.decodeItemEdition(v); // → MotelyItemEdition (None/Foil/Holo/Poly/Negative)
247
- const seal = Motely.decodeItemSeal(v); // → MotelyItemSeal
248
- const enh = Motely.decodeItemEnhancement(v); // → MotelyItemEnhancement
249
-
250
- const perishable = Motely.isPerishable(v); // → boolean
251
- const eternal = Motely.isEternal(v); // → boolean
252
- const rental = Motely.isRental(v); // → boolean
253
-
254
- console.log(MotelyItemType[type]); // e.g. "WeeJoker"
255
- console.log(MotelyJokerRarity[rarity]); // e.g. "Common"
256
- ```
257
-
258
- All enum tables (`MotelyItemType`, `MotelyItemTypeCategory`, `MotelyJokerRarity`,
259
- `MotelyItemEdition`, `MotelyItemSeal`, `MotelyItemEnhancement`, `MotelyTag`,
260
- `MotelyVoucher`, `MotelyBoosterPack`, `MotelyDeck`, `MotelyStake`) live at
261
- `motely-wasm/motely/enums` and can be used for reverse-lookup by numeric value or
262
- forward-lookup by name. `MotelyStreamKind` lives at `motely-wasm/motely`.
263
-
264
164
  ## Events
265
165
 
266
166
  Callbacks are registered on `Motely` once per `bootsharp.boot()` — not on each settings
@@ -287,7 +187,7 @@ Motely.onScoredResult.unsubscribe(handler);
287
187
  | Import path | Contents |
288
188
  |---|---|
289
189
  | `motely-wasm` | Default export: `boot`, `getStatus`, `BootStatus`. Named export: `Motely` (main API) |
290
- | `motely-wasm/motely` | `IMotelySearch`, `SearchSettings`, `IMotelyStreamCursor`, `MotelyProgress`, `MotelyScoredSeedResult`, `MotelyStreamKind` |
190
+ | `motely-wasm/motely` | `IMotelySearch`, `SearchSettings`, `MotelyProgress`, `MotelyScoredSeedResult`, `MotelyStreamKind` |
291
191
  | `motely-wasm/motely/enums` | All Balatro enums — `MotelyItemType`, `MotelyItemTypeCategory`, `MotelyJokerRarity`, `MotelyItemEdition`, `MotelyItemSeal`, `MotelyItemEnhancement`, `MotelyTag`, `MotelyVoucher`, `MotelyBoosterPack`, `MotelyDeck`, `MotelyStake`, `MotelyBossBlind`, etc. |
292
192
  | `motely-wasm/motely/filters` | `JamlAesthetic`, `JamlSearchPlan` |
293
193
  | `motely-wasm/motely/analysis` | `MotelyJamlyzerResult`, `MotelySeedAnalysis` |
@@ -315,7 +215,7 @@ self.onmessage = async ({ data }) => {
315
215
 
316
216
  try {
317
217
  if (bootsharp.getStatus() === bootsharp.BootStatus.Standby) {
318
- await bootsharp.boot("/motely-wasm/bin");
218
+ await bootsharp.boot();
319
219
  }
320
220
 
321
221
  const onResult = r =>
@@ -3,7 +3,7 @@
3
3
  * user code and passed across the interop boundary; instances received from C# are wrapped into
4
4
  * generated proxies that expose the same shape. */
5
5
  export declare class Collection<T> {
6
- private readonly items;
6
+ protected readonly items: T[];
7
7
  constructor(items?: Iterable<T>);
8
8
  /** Number of items in the collection. */
9
9
  get count(): number;
@@ -1,3 +1,4 @@
1
1
  export * from "./event.mjs";
2
2
  export * from "./collection.mjs";
3
+ export * from "./list.mjs";
3
4
  export * from "./cancellation.mjs";
@@ -1,3 +1,4 @@
1
1
  export * from "./event.mjs";
2
2
  export * from "./collection.mjs";
3
+ export * from "./list.mjs";
3
4
  export * from "./cancellation.mjs";
@@ -0,0 +1,17 @@
1
+ import { Collection } from "./collection.mjs";
2
+ /** JavaScript counterpart of the C# <c>System.Collections.Generic.IList&lt;T&gt;</c> specialization.
3
+ * Extends <see cref="Collection"/> with index-based access; like the collection, hand-rolled
4
+ * instances are passed across the interop boundary, while instances received from C# are wrapped
5
+ * into generated proxies that expose the same shape. */
6
+ export declare class List<T> extends Collection<T> {
7
+ /** Returns the index of the first occurrence of the specified item, or -1 when not found. */
8
+ indexOf(item: T): number;
9
+ /** Inserts the specified item at the specified index. */
10
+ insert(index: number, item: T): void;
11
+ /** Removes the item at the specified index. */
12
+ removeAt(index: number): void;
13
+ /** Returns the item at the specified index. */
14
+ getAt(index: number): T;
15
+ /** Assigns the specified item at the specified index. */
16
+ setAt(index: number, item: T): void;
17
+ }
@@ -0,0 +1,27 @@
1
+ import { Collection } from "./collection.mjs";
2
+ /** JavaScript counterpart of the C# <c>System.Collections.Generic.IList&lt;T&gt;</c> specialization.
3
+ * Extends <see cref="Collection"/> with index-based access; like the collection, hand-rolled
4
+ * instances are passed across the interop boundary, while instances received from C# are wrapped
5
+ * into generated proxies that expose the same shape. */
6
+ export class List extends Collection {
7
+ /** Returns the index of the first occurrence of the specified item, or -1 when not found. */
8
+ indexOf(item) {
9
+ return this.items.indexOf(item);
10
+ }
11
+ /** Inserts the specified item at the specified index. */
12
+ insert(index, item) {
13
+ this.items.splice(index, 0, item);
14
+ }
15
+ /** Removes the item at the specified index. */
16
+ removeAt(index) {
17
+ this.items.splice(index, 1);
18
+ }
19
+ /** Returns the item at the specified index. */
20
+ getAt(index) {
21
+ return this.items[index];
22
+ }
23
+ /** Assigns the specified item at the specified index. */
24
+ setAt(index, item) {
25
+ this.items[index] = item;
26
+ }
27
+ }