motely-wasm 18.2.1 → 18.2.3

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.
Files changed (146) hide show
  1. package/README.md +24 -38
  2. package/bin/motely-wasm.wasm +0 -0
  3. package/dist/bcl/cancellation.d.mts +14 -0
  4. package/dist/bcl/cancellation.mjs +21 -0
  5. package/dist/bcl/collection.d.mts +22 -0
  6. package/dist/bcl/collection.mjs +42 -0
  7. package/dist/bcl/index.d.mts +3 -0
  8. package/dist/bcl/index.mjs +3 -0
  9. package/dist/boot.d.mts +2 -2
  10. package/dist/boot.mjs +4 -4
  11. package/dist/config.mjs +8 -2
  12. package/dist/dotnet/dotnet.native.js +1 -1
  13. package/dist/generated/imports.g.mjs +20 -158
  14. package/dist/generated/instances.g.mjs +78 -26
  15. package/dist/generated/{bootsharp → modules/bootsharp}/file-system.g.d.mts +33 -43
  16. package/dist/generated/{bootsharp → modules/bootsharp}/file-system.g.mjs +30 -11
  17. package/dist/generated/modules/index.g.d.mts +65 -0
  18. package/dist/generated/modules/index.g.mjs +68 -0
  19. package/dist/generated/{motely → modules/motely}/analysis.g.d.mts +13 -18
  20. package/dist/generated/{motely/filters/converters.g.mjs → modules/motely/analysis.g.mjs} +2 -2
  21. package/dist/generated/modules/motely/enums.g.d.mts +437 -0
  22. package/dist/generated/modules/motely/enums.g.mjs +852 -0
  23. package/dist/generated/modules/motely/filters/jaml.g.d.mts +9 -0
  24. package/dist/generated/modules/motely/filters/jaml.g.mjs +18 -0
  25. package/dist/generated/modules/motely/filters.g.d.mts +14 -0
  26. package/dist/generated/{six-labors/image-sharp/color-spaces.g.mjs → modules/motely/filters.g.mjs} +2 -2
  27. package/dist/generated/modules/motely/seed-providers.g.d.mts +6 -0
  28. package/dist/generated/modules/motely/seed-providers.g.mjs +11 -0
  29. package/dist/generated/modules/motely.g.d.mts +90 -0
  30. package/dist/generated/modules/motely.g.mjs +101 -0
  31. package/dist/generated/modules/system/threading.g.d.mts +6 -0
  32. package/dist/generated/modules/system/threading.g.mjs +9 -0
  33. package/dist/generated/modules/system.g.d.mts +3 -0
  34. package/dist/generated/modules/system.g.mjs +15 -0
  35. package/dist/generated/resources.g.d.mts +3 -3
  36. package/dist/generated/resources.g.mjs +5 -3
  37. package/dist/generated/{serialization.g.mjs → serializer.g.mjs} +31 -41
  38. package/dist/imports.d.mts +1 -1
  39. package/dist/imports.mjs +1 -1
  40. package/dist/index.d.mts +2 -2
  41. package/dist/index.mjs +2 -2
  42. package/dist/instances.d.mts +2 -2
  43. package/dist/instances.mjs +8 -4
  44. package/dist/node-boot.mjs +36 -0
  45. package/dist/resources.d.mts +6 -6
  46. package/dist/resources.mjs +6 -3
  47. package/dist/serialization/index.d.mts +10 -0
  48. package/dist/serialization/index.mjs +4 -0
  49. package/dist/serialization/reader.d.mts +22 -0
  50. package/dist/serialization/reader.mjs +94 -0
  51. package/dist/serialization/serializer.d.mts +15 -0
  52. package/dist/serialization/serializer.mjs +20 -0
  53. package/dist/serialization/std.d.mts +24 -0
  54. package/dist/serialization/std.mjs +97 -0
  55. package/dist/serialization/writer.d.mts +25 -0
  56. package/dist/serialization/writer.mjs +122 -0
  57. package/jaml.schema.json +5298 -4553
  58. package/package.json +3 -2
  59. package/bin/dotnet.native.wasm +0 -0
  60. package/dist/generated/bootsharp/inject.g.mjs +0 -6
  61. package/dist/generated/bootsharp.g.mjs +0 -6
  62. package/dist/generated/index.g.d.mts +0 -35
  63. package/dist/generated/index.g.mjs +0 -40
  64. package/dist/generated/jet-brains/annotations.g.mjs +0 -6
  65. package/dist/generated/motely/analysis.g.mjs +0 -6
  66. package/dist/generated/motely/enums.g.d.mts +0 -448
  67. package/dist/generated/motely/enums.g.mjs +0 -18
  68. package/dist/generated/motely/filters/jaml/converters.g.mjs +0 -6
  69. package/dist/generated/motely/filters/jaml.g.d.mts +0 -10
  70. package/dist/generated/motely/filters/jaml.g.mjs +0 -7
  71. package/dist/generated/motely/filters/native.g.mjs +0 -6
  72. package/dist/generated/motely/filters.g.d.mts +0 -8
  73. package/dist/generated/motely/filters.g.mjs +0 -6
  74. package/dist/generated/motely.g.d.mts +0 -61
  75. package/dist/generated/motely.g.mjs +0 -59
  76. package/dist/generated/six-labors/image-sharp/advanced.g.mjs +0 -6
  77. package/dist/generated/six-labors/image-sharp/color-spaces/companding.g.mjs +0 -6
  78. package/dist/generated/six-labors/image-sharp/color-spaces/conversion.g.mjs +0 -6
  79. package/dist/generated/six-labors/image-sharp/compression/zlib.g.mjs +0 -6
  80. package/dist/generated/six-labors/image-sharp/diagnostics.g.mjs +0 -6
  81. package/dist/generated/six-labors/image-sharp/formats/bmp.g.mjs +0 -6
  82. package/dist/generated/six-labors/image-sharp/formats/gif.g.mjs +0 -6
  83. package/dist/generated/six-labors/image-sharp/formats/jpeg/components/encoder.g.mjs +0 -6
  84. package/dist/generated/six-labors/image-sharp/formats/jpeg.g.mjs +0 -6
  85. package/dist/generated/six-labors/image-sharp/formats/pbm.g.mjs +0 -6
  86. package/dist/generated/six-labors/image-sharp/formats/png/chunks.g.mjs +0 -6
  87. package/dist/generated/six-labors/image-sharp/formats/png.g.mjs +0 -6
  88. package/dist/generated/six-labors/image-sharp/formats/qoi.g.mjs +0 -6
  89. package/dist/generated/six-labors/image-sharp/formats/tga.g.mjs +0 -6
  90. package/dist/generated/six-labors/image-sharp/formats/tiff/compression/decompressors.g.mjs +0 -6
  91. package/dist/generated/six-labors/image-sharp/formats/tiff/compression.g.mjs +0 -6
  92. package/dist/generated/six-labors/image-sharp/formats/tiff/constants.g.mjs +0 -6
  93. package/dist/generated/six-labors/image-sharp/formats/tiff.g.mjs +0 -6
  94. package/dist/generated/six-labors/image-sharp/formats/webp.g.mjs +0 -6
  95. package/dist/generated/six-labors/image-sharp/formats.g.mjs +0 -6
  96. package/dist/generated/six-labors/image-sharp/memory.g.mjs +0 -6
  97. package/dist/generated/six-labors/image-sharp/metadata/profiles/cicp.g.mjs +0 -6
  98. package/dist/generated/six-labors/image-sharp/metadata/profiles/exif.g.mjs +0 -6
  99. package/dist/generated/six-labors/image-sharp/metadata/profiles/icc.g.mjs +0 -6
  100. package/dist/generated/six-labors/image-sharp/metadata/profiles/iptc.g.mjs +0 -6
  101. package/dist/generated/six-labors/image-sharp/metadata/profiles/xmp.g.mjs +0 -6
  102. package/dist/generated/six-labors/image-sharp/metadata.g.mjs +0 -6
  103. package/dist/generated/six-labors/image-sharp/pixel-formats.g.mjs +0 -6
  104. package/dist/generated/six-labors/image-sharp/processing/processors/binarization.g.mjs +0 -6
  105. package/dist/generated/six-labors/image-sharp/processing/processors/convolution.g.mjs +0 -6
  106. package/dist/generated/six-labors/image-sharp/processing/processors/dithering.g.mjs +0 -6
  107. package/dist/generated/six-labors/image-sharp/processing/processors/drawing.g.mjs +0 -6
  108. package/dist/generated/six-labors/image-sharp/processing/processors/effects.g.mjs +0 -6
  109. package/dist/generated/six-labors/image-sharp/processing/processors/filters.g.mjs +0 -6
  110. package/dist/generated/six-labors/image-sharp/processing/processors/normalization.g.mjs +0 -6
  111. package/dist/generated/six-labors/image-sharp/processing/processors/overlays.g.mjs +0 -6
  112. package/dist/generated/six-labors/image-sharp/processing/processors/quantization.g.mjs +0 -6
  113. package/dist/generated/six-labors/image-sharp/processing/processors/transforms.g.mjs +0 -6
  114. package/dist/generated/six-labors/image-sharp/processing/processors.g.mjs +0 -6
  115. package/dist/generated/six-labors/image-sharp/processing.g.mjs +0 -6
  116. package/dist/generated/six-labors/image-sharp.g.mjs +0 -6
  117. package/dist/generated/system/collections/generic.g.mjs +0 -6
  118. package/dist/generated/system/threading.g.d.mts +0 -4
  119. package/dist/generated/system/threading.g.mjs +0 -6
  120. package/dist/generated/system.g.mjs +0 -6
  121. package/dist/generated/yaml-dot-net/core/events.g.mjs +0 -6
  122. package/dist/generated/yaml-dot-net/core/tokens.g.mjs +0 -6
  123. package/dist/generated/yaml-dot-net/core.g.mjs +0 -6
  124. package/dist/generated/yaml-dot-net/helpers.g.mjs +0 -6
  125. package/dist/generated/yaml-dot-net/representation-model.g.mjs +0 -6
  126. package/dist/generated/yaml-dot-net/serialization/buffered-deserialization/type-discriminators.g.mjs +0 -6
  127. package/dist/generated/yaml-dot-net/serialization/buffered-deserialization.g.mjs +0 -6
  128. package/dist/generated/yaml-dot-net/serialization/callbacks.g.mjs +0 -6
  129. package/dist/generated/yaml-dot-net/serialization/converters.g.mjs +0 -6
  130. package/dist/generated/yaml-dot-net/serialization/event-emitters.g.mjs +0 -6
  131. package/dist/generated/yaml-dot-net/serialization/naming-conventions.g.mjs +0 -6
  132. package/dist/generated/yaml-dot-net/serialization/node-deserializers.g.mjs +0 -6
  133. package/dist/generated/yaml-dot-net/serialization/node-type-resolvers.g.mjs +0 -6
  134. package/dist/generated/yaml-dot-net/serialization/object-factories.g.mjs +0 -6
  135. package/dist/generated/yaml-dot-net/serialization/object-graph-traversal-strategies.g.mjs +0 -6
  136. package/dist/generated/yaml-dot-net/serialization/object-graph-visitors.g.mjs +0 -6
  137. package/dist/generated/yaml-dot-net/serialization/schemas.g.mjs +0 -6
  138. package/dist/generated/yaml-dot-net/serialization/type-inspectors.g.mjs +0 -6
  139. package/dist/generated/yaml-dot-net/serialization/type-resolvers.g.mjs +0 -6
  140. package/dist/generated/yaml-dot-net/serialization/utilities.g.mjs +0 -6
  141. package/dist/generated/yaml-dot-net/serialization/value-deserializers.g.mjs +0 -6
  142. package/dist/generated/yaml-dot-net/serialization.g.mjs +0 -6
  143. package/dist/serialization.d.mts +0 -90
  144. package/dist/serialization.mjs +0 -331
  145. /package/dist/{event.d.mts → bcl/event.d.mts} +0 -0
  146. /package/dist/{event.mjs → bcl/event.mjs} +0 -0
package/README.md CHANGED
@@ -34,14 +34,11 @@ must:
34
34
  const status = Motely.validateJaml(jaml);
35
35
  if (status !== "valid") throw new Error(status);
36
36
 
37
- // Subscribe to results before starting.
37
+ // One callback set per WASM load — subscribe after boot, before .start().
38
38
  Motely.onScoredResult.subscribe(r => console.log("match:", r.seed, r.score));
39
39
  Motely.onProgress.subscribe(p => console.log(`${p.percentComplete.toFixed(1)}%`));
40
40
 
41
- // Build, start, and await a search.
42
- const search = Motely.createSearch(jaml)
43
- .withSequentialSearch()
44
- .start();
41
+ const search = Motely.fromJaml(jaml).withSequentialSearch().start();
45
42
 
46
43
  await search.waitForCompletionAsync();
47
44
  console.log("done:", search.totalSeedsSearched, "searched,", search.matchingSeeds, "matched");
@@ -61,9 +58,7 @@ Pass the URL path your host serves the package's `bin/` directory at (where
61
58
  | --- | --- | --- |
62
59
  | Vite / Storybook `staticDirs` | `/motely-wasm/bin` | `boot("/motely-wasm/bin")` |
63
60
  | Next.js route handler | `/motely-wasm/bin/[...path]` | `boot("/motely-wasm/bin")` |
64
- | Static page in `node_modules/motely-wasm/` | `/bin` | `boot("/bin")` |
65
- | Raw node_modules served as static | `/node_modules/motely-wasm/bin` | `boot("/node_modules/motely-wasm/bin")` |
66
- | Public CDN | `https://unpkg.com/motely-wasm/bin` | `boot("https://unpkg.com/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")` |
67
62
 
68
63
  Web Workers must boot from the **same** URL as the main thread — absolute paths
69
64
  in a worker resolve against the page origin, so whichever URL serves the WASM
@@ -81,29 +76,23 @@ console.log(bootsharp.getStatus()); // BootStatus.Booted
81
76
 
82
77
  ### Node / Bun / Deno
83
78
 
84
- There's no URL to fetch from read `dotnet.native.wasm` off disk and hand its
85
- bytes to `boot`:
79
+ Same ESM import as the browser. Point `boot()` at the published `bin/` directory
80
+ (Node `fetch` accepts `file://` URLs):
86
81
 
87
82
  ```js
88
- import { readFile } from "node:fs/promises";
89
- import { fileURLToPath } from "node:url";
90
- import bootsharp from "motely-wasm";
83
+ import bootsharp, { Motely } from "motely-wasm";
91
84
 
92
- const wasmUrl = new URL("../bin/dotnet.native.wasm", import.meta.resolve("motely-wasm"));
93
- const wasmBytes = await readFile(fileURLToPath(wasmUrl));
85
+ const binRoot = new URL("bin/", import.meta.resolve("motely-wasm/package.json")).href;
86
+ await bootsharp.boot(binRoot);
94
87
 
95
- await bootsharp.boot({
96
- wasm: wasmBytes.buffer.slice(
97
- wasmBytes.byteOffset,
98
- wasmBytes.byteOffset + wasmBytes.byteLength
99
- ),
100
- });
88
+ const status = Motely.validateJaml(jaml);
101
89
  ```
102
90
 
103
- Requires Node ≥ 20.6 (sync `import.meta.resolve`). Node 22 LTS is the recommended floor.
91
+ Requires Node ≥ 20.6 (`import.meta.resolve`). Node 22 LTS is the recommended floor.
104
92
 
105
- `Motely.Wasm/motely.test.mjs` in the source repo is the executable reference for
106
- this path if Node boot breaks, that suite catches it first.
93
+ **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).
107
96
 
108
97
  ## JAML API
109
98
 
@@ -182,24 +171,17 @@ returns a human-readable plan; `Motely.createPlan(jaml)` returns the scoring str
182
171
 
183
172
  ## Running a search
184
173
 
185
- `Motely.createSearch(jaml)` returns a settings builder. Chain a search-mode method,
186
- then call `.start()` to get a running `IMotelySearch`.
174
+ Use `Motely.createSearchSettings()`, `Motely.createNativeSearchSettings(name)`, or
175
+ `Motely.fromJaml(jaml)` then chain modes. Callbacks are registered once per WASM load on `Motely`.
187
176
 
188
177
  ```js
189
178
  import { Motely } from "motely-wasm";
190
179
 
191
- Motely.onSeedMatch.subscribe(seed => { /* matching seed string */ });
192
- Motely.onScoredResult.subscribe(r => { /* r.seed, r.score, r.tallies */ });
193
- Motely.onProgress.subscribe(p => { /* p.percentComplete, p.seedsSearched, p.seedsPerMillisecond, … */ });
180
+ Motely.onSeedMatch.subscribe(seed => { /* */ });
181
+ Motely.onScoredResult.subscribe(r => { /* */ });
182
+ Motely.onProgress.subscribe(p => { /* … */ });
194
183
 
195
- const settings = Motely.createSearch(jaml)
196
- .withSequentialSearch() // enumerate all seeds in order
197
- // .withRandomSearch(10_000) // or pick N random seeds
198
- // .withListSearch(seeds, seeds.length) // or supply a seed list
199
- // .withAestheticSearch(0) // or a JamlAesthetic mode
200
- .withProgressReportIntervalMs(500n);
201
-
202
- const search = settings.start();
184
+ const search = Motely.fromJaml(jaml).withSequentialSearch().start();
203
185
 
204
186
  // Async (yields between batches — good on the main thread or in a Worker)
205
187
  await search.waitForCompletionAsync();
@@ -281,6 +263,10 @@ forward-lookup by name. `MotelyStreamKind` lives at `motely-wasm/motely`.
281
263
 
282
264
  ## Events
283
265
 
266
+ Callbacks are registered on `Motely` once per `bootsharp.boot()` — not on each settings
267
+ chain. Every search started from that WASM load shares the same handlers; run one search at
268
+ a time or use separate worker boots if you need isolated callbacks.
269
+
284
270
  | Event | Payload |
285
271
  |---|---|
286
272
  | `Motely.onSeedMatch` | `string` — matching seed |
@@ -301,7 +287,7 @@ Motely.onScoredResult.unsubscribe(handler);
301
287
  | Import path | Contents |
302
288
  |---|---|
303
289
  | `motely-wasm` | Default export: `boot`, `getStatus`, `BootStatus`. Named export: `Motely` (main API) |
304
- | `motely-wasm/motely` | `IMotelySearch`, `IMotelySearchSettingsInterop`, `IMotelyStreamCursor`, `MotelyProgress`, `MotelyScoredSeedResult`, `MotelyStreamKind` |
290
+ | `motely-wasm/motely` | `IMotelySearch`, `SearchSettings`, `IMotelyStreamCursor`, `MotelyProgress`, `MotelyScoredSeedResult`, `MotelyStreamKind` |
305
291
  | `motely-wasm/motely/enums` | All Balatro enums — `MotelyItemType`, `MotelyItemTypeCategory`, `MotelyJokerRarity`, `MotelyItemEdition`, `MotelyItemSeal`, `MotelyItemEnhancement`, `MotelyTag`, `MotelyVoucher`, `MotelyBoosterPack`, `MotelyDeck`, `MotelyStake`, `MotelyBossBlind`, etc. |
306
292
  | `motely-wasm/motely/filters` | `JamlAesthetic`, `JamlSearchPlan` |
307
293
  | `motely-wasm/motely/analysis` | `MotelyJamlyzerResult`, `MotelySeedAnalysis` |
Binary file
@@ -0,0 +1,14 @@
1
+ import { Event } from "./event.mjs";
2
+ /** JavaScript counterpart of the C# <c>System.Threading.CancellationToken</c> specialization.
3
+ * Hand-rolled instances are constructed in user code and passed across the interop boundary;
4
+ * instances received from C# are wrapped into generated proxies that expose the same shape. */
5
+ export declare class CancellationToken {
6
+ private cancelled;
7
+ /** Fires when the token is cancelled. */
8
+ readonly onCancellationRequested: Event<[]>;
9
+ /** Whether cancellation has been requested. */
10
+ get isCancellationRequested(): boolean;
11
+ /** Signal cancellation: flips <see cref="isCancellationRequested"/> and broadcasts
12
+ * <see cref="onCancellationRequested"/>. Idempotent. */
13
+ cancel(): void;
14
+ }
@@ -0,0 +1,21 @@
1
+ import { Event } from "./event.mjs";
2
+ /** JavaScript counterpart of the C# <c>System.Threading.CancellationToken</c> specialization.
3
+ * Hand-rolled instances are constructed in user code and passed across the interop boundary;
4
+ * instances received from C# are wrapped into generated proxies that expose the same shape. */
5
+ export class CancellationToken {
6
+ cancelled = false;
7
+ /** Fires when the token is cancelled. */
8
+ onCancellationRequested = new Event();
9
+ /** Whether cancellation has been requested. */
10
+ get isCancellationRequested() {
11
+ return this.cancelled;
12
+ }
13
+ /** Signal cancellation: flips <see cref="isCancellationRequested"/> and broadcasts
14
+ * <see cref="onCancellationRequested"/>. Idempotent. */
15
+ cancel() {
16
+ if (this.cancelled)
17
+ return;
18
+ this.cancelled = true;
19
+ this.onCancellationRequested.broadcast();
20
+ }
21
+ }
@@ -0,0 +1,22 @@
1
+ /** JavaScript counterpart of the C# <c>Bootsharp.Collection&lt;T&gt;</c> specialization of
2
+ * <c>System.Collections.Generic.ICollection&lt;T&gt;</c>. Hand-rolled instances are constructed in
3
+ * user code and passed across the interop boundary; instances received from C# are wrapped into
4
+ * generated proxies that expose the same shape. */
5
+ export declare class Collection<T> {
6
+ private readonly items;
7
+ constructor(items?: Iterable<T>);
8
+ /** Number of items in the collection. */
9
+ get count(): number;
10
+ /** Adds the specified item to the collection. */
11
+ add(item: T): void;
12
+ /** Removes the first occurrence of the specified item from the collection.
13
+ * @returns true when the item was removed; false when it wasn't found. */
14
+ remove(item: T): boolean;
15
+ /** Removes all items from the collection. */
16
+ clear(): void;
17
+ /** Whether the collection contains the specified item. */
18
+ contains(item: T): boolean;
19
+ /** Returns a fresh array with a snapshot of the current items. */
20
+ copy(): T[];
21
+ [Symbol.iterator](): IterableIterator<T>;
22
+ }
@@ -0,0 +1,42 @@
1
+ /** JavaScript counterpart of the C# <c>Bootsharp.Collection&lt;T&gt;</c> specialization of
2
+ * <c>System.Collections.Generic.ICollection&lt;T&gt;</c>. Hand-rolled instances are constructed in
3
+ * user code and passed across the interop boundary; instances received from C# are wrapped into
4
+ * generated proxies that expose the same shape. */
5
+ export class Collection {
6
+ items;
7
+ constructor(items) {
8
+ this.items = items != null ? Array.from(items) : [];
9
+ }
10
+ /** Number of items in the collection. */
11
+ get count() {
12
+ return this.items.length;
13
+ }
14
+ /** Adds the specified item to the collection. */
15
+ add(item) {
16
+ this.items.push(item);
17
+ }
18
+ /** Removes the first occurrence of the specified item from the collection.
19
+ * @returns true when the item was removed; false when it wasn't found. */
20
+ remove(item) {
21
+ const idx = this.items.indexOf(item);
22
+ if (idx < 0)
23
+ return false;
24
+ this.items.splice(idx, 1);
25
+ return true;
26
+ }
27
+ /** Removes all items from the collection. */
28
+ clear() {
29
+ this.items.length = 0;
30
+ }
31
+ /** Whether the collection contains the specified item. */
32
+ contains(item) {
33
+ return this.items.indexOf(item) >= 0;
34
+ }
35
+ /** Returns a fresh array with a snapshot of the current items. */
36
+ copy() {
37
+ return this.items.slice();
38
+ }
39
+ [Symbol.iterator]() {
40
+ return this.copy()[Symbol.iterator]();
41
+ }
42
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./event.mjs";
2
+ export * from "./collection.mjs";
3
+ export * from "./cancellation.mjs";
@@ -0,0 +1,3 @@
1
+ export * from "./event.mjs";
2
+ export * from "./collection.mjs";
3
+ export * from "./cancellation.mjs";
package/dist/boot.d.mts CHANGED
@@ -24,11 +24,11 @@ export type BootOptions = {
24
24
  };
25
25
  /** Returns current runtime module lifecycle state. */
26
26
  export declare function getStatus(): BootStatus;
27
- /** Initializes the runtime and binds C# APIs.
27
+ /** Initializes the runtime. When not in embedded mode, resources parameter has to be specified.
28
28
  * @param resources Either URL to the boot resources root (eg, <code>/bin</code>) or the preloaded content.
29
29
  * @param options Allows customizing the boot process and the runtime behaviour.
30
30
  * @return Promise that resolves into the runtime instance when the initialization is finished. */
31
- export declare function boot(resources: string | BootResources, options?: BootOptions): Promise<RuntimeAPI>;
31
+ export declare function boot(resources?: string | BootResources, options?: BootOptions): Promise<RuntimeAPI>;
32
32
  /** Terminates the runtime and removes WASM module from memory.
33
33
  * @param code Exit code; will use 0 (normal exit) by default.
34
34
  * @param reason Exit reason description (optional). */
package/dist/boot.mjs CHANGED
@@ -19,7 +19,7 @@ let status = BootStatus.Standby;
19
19
  export function getStatus() {
20
20
  return status;
21
21
  }
22
- /** Initializes the runtime and binds C# APIs.
22
+ /** Initializes the runtime. When not in embedded mode, resources parameter has to be specified.
23
23
  * @param resources Either URL to the boot resources root (eg, <code>/bin</code>) or the preloaded content.
24
24
  * @param options Allows customizing the boot process and the runtime behaviour.
25
25
  * @return Promise that resolves into the runtime instance when the initialization is finished. */
@@ -37,7 +37,7 @@ export async function boot(resources, options) {
37
37
  * @param code Exit code; will use 0 (normal exit) by default.
38
38
  * @param reason Exit reason description (optional). */
39
39
  export async function exit(code, reason) {
40
- /* v8 ignore start -- @preserve */ // Uncoverable, as exit terminates the host test process.
40
+ /* v8 ignore start -- uncoverable, as exit terminates the host test process */
41
41
  if (status !== BootStatus.Booted)
42
42
  throw Error("Failed to exit the C# runtime: not booted.");
43
43
  try {
@@ -47,10 +47,10 @@ export async function exit(code, reason) {
47
47
  finally {
48
48
  status = BootStatus.Standby;
49
49
  }
50
- /* v8 ignore stop -- @preserve */
50
+ /* v8 ignore stop */
51
51
  }
52
52
  async function createRuntime(res, opt) {
53
- const cfg = opt.config ?? buildConfig(typeof res === "string" ? await fetchResources(res) : res);
53
+ const cfg = opt.config ?? buildConfig(typeof res === "object" ? res : await fetchResources(res));
54
54
  const runtime = await opt.create?.(cfg) || await app.dotnet.withConfig(cfg).create();
55
55
  setRuntime(runtime);
56
56
  if (opt.import)
package/dist/config.mjs CHANGED
@@ -21,11 +21,12 @@ export function buildConfig(resources) {
21
21
  return { name, moduleExports: exports };
22
22
  }
23
23
  function resolveAsset(res) {
24
- return { name: res.name, virtualPath: res.name, buffer: res.content };
24
+ const buffer = resolveBinary(res.content);
25
+ return { name: res.name, virtualPath: res.name, buffer };
25
26
  }
26
27
  function resolveSymbols(res) {
27
28
  // Use 'resolveAsset<SymbolsAsset>()' once https://github.com/dotnet/runtime/pull/127087 is merged.
28
- const txt = new TextDecoder("utf-8").decode(res.content);
29
+ const txt = new TextDecoder("utf-8").decode(resolveBinary(res.content));
29
30
  return {
30
31
  name: res.name,
31
32
  pendingDownload: {
@@ -42,4 +43,9 @@ export function buildConfig(resources) {
42
43
  return "all";
43
44
  return "sharded";
44
45
  }
46
+ function resolveBinary(content) {
47
+ if (typeof content !== "string")
48
+ return content;
49
+ return Uint8Array.fromBase64(content).buffer;
50
+ }
45
51
  }