motely-wasm 18.2.2 → 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 +11 -19
  2. package/bin/{dotnet.native.wasm → 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 +71 -33
  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/{index.g.mjs → modules/index.g.mjs} +32 -27
  19. package/dist/generated/{motely → modules/motely}/analysis.g.d.mts +12 -24
  20. package/dist/generated/{six-labors/image-sharp/color-spaces.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/{motely/filters/native.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} +30 -51
  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/dist/generated/bootsharp/inject.g.mjs +0 -6
  60. package/dist/generated/bootsharp.g.mjs +0 -6
  61. package/dist/generated/index.g.d.mts +0 -60
  62. package/dist/generated/jet-brains/annotations.g.mjs +0 -6
  63. package/dist/generated/motely/analysis.g.mjs +0 -12
  64. package/dist/generated/motely/enums.g.d.mts +0 -448
  65. package/dist/generated/motely/enums.g.mjs +0 -18
  66. package/dist/generated/motely/filters/converters.g.mjs +0 -6
  67. package/dist/generated/motely/filters/jaml/converters.g.mjs +0 -6
  68. package/dist/generated/motely/filters/jaml.g.d.mts +0 -10
  69. package/dist/generated/motely/filters/jaml.g.mjs +0 -7
  70. package/dist/generated/motely/filters.g.d.mts +0 -8
  71. package/dist/generated/motely/filters.g.mjs +0 -6
  72. package/dist/generated/motely/wasm.g.d.mts +0 -8
  73. package/dist/generated/motely/wasm.g.mjs +0 -11
  74. package/dist/generated/motely.g.d.mts +0 -59
  75. package/dist/generated/motely.g.mjs +0 -45
  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
@@ -58,9 +58,7 @@ Pass the URL path your host serves the package's `bin/` directory at (where
58
58
  | --- | --- | --- |
59
59
  | Vite / Storybook `staticDirs` | `/motely-wasm/bin` | `boot("/motely-wasm/bin")` |
60
60
  | Next.js route handler | `/motely-wasm/bin/[...path]` | `boot("/motely-wasm/bin")` |
61
- | Static page in `node_modules/motely-wasm/` | `/bin` | `boot("/bin")` |
62
- | Raw node_modules served as static | `/node_modules/motely-wasm/bin` | `boot("/node_modules/motely-wasm/bin")` |
63
- | 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")` |
64
62
 
65
63
  Web Workers must boot from the **same** URL as the main thread — absolute paths
66
64
  in a worker resolve against the page origin, so whichever URL serves the WASM
@@ -78,29 +76,23 @@ console.log(bootsharp.getStatus()); // BootStatus.Booted
78
76
 
79
77
  ### Node / Bun / Deno
80
78
 
81
- There's no URL to fetch from read `dotnet.native.wasm` off disk and hand its
82
- bytes to `boot`:
79
+ Same ESM import as the browser. Point `boot()` at the published `bin/` directory
80
+ (Node `fetch` accepts `file://` URLs):
83
81
 
84
82
  ```js
85
- import { readFile } from "node:fs/promises";
86
- import { fileURLToPath } from "node:url";
87
- import bootsharp from "motely-wasm";
83
+ import bootsharp, { Motely } from "motely-wasm";
88
84
 
89
- const wasmUrl = new URL("../bin/dotnet.native.wasm", import.meta.resolve("motely-wasm"));
90
- 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);
91
87
 
92
- await bootsharp.boot({
93
- wasm: wasmBytes.buffer.slice(
94
- wasmBytes.byteOffset,
95
- wasmBytes.byteOffset + wasmBytes.byteLength
96
- ),
97
- });
88
+ const status = Motely.validateJaml(jaml);
98
89
  ```
99
90
 
100
- 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.
101
92
 
102
- `Motely.Wasm/motely.test.mjs` in the source repo is the executable reference for
103
- 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).
104
96
 
105
97
  ## JAML API
106
98
 
@@ -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
  }