@andreiltd/componentize-qjs-binding-win32-arm64-msvc 0.2.2 → 0.4.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
@@ -104,8 +104,9 @@ wasmtime run --wasm component-model-async=y --invoke 'greet("World")' hello.wasm
104
104
  ```
105
105
 
106
106
  The built-in runtime published with componentize-qjs includes component-model
107
- async support. A custom runtime built without that Cargo feature can be passed
108
- with `--runtime` for sync-only components.
107
+ async support. Pass `--sync` to embed the built-in non-async runtime instead,
108
+ producing components that run on hosts without component-model async support. A
109
+ custom runtime can also be supplied with `--runtime`.
109
110
 
110
111
  ## CLI Reference
111
112
 
@@ -118,16 +119,19 @@ componentize-qjs [OPTIONS] --wit <WIT> --js <JS>
118
119
  | `--wit <PATH>` | `-w` | Path to the WIT file or directory |
119
120
  | `--js <PATH>` | `-j` | Path to the JavaScript source file |
120
121
  | `--output <PATH>` | `-o` | Output path (default: `output.wasm`) |
122
+ | `--module-root <PATH>` | | Root directory exposed read-only during Wizer for resolving JavaScript imports |
121
123
  | `--world <NAME>` | `-n` | World name when the WIT defines multiple worlds |
122
124
  | `--stub-wasi` | | Replace all WASI imports with trap stubs |
123
125
  | `--minify` | `-m` | Minify JS source before embedding |
124
126
  | `--opt-size` | | Use the built-in QuickJS runtime optimized for size |
127
+ | `--sync` | | Use the built-in non-async runtime (combine with `--opt-size` for the non-async opt-size runtime) |
125
128
  | `--runtime <PATH>` | | Custom QuickJS runtime Wasm module to embed |
126
129
 
127
130
  ### Cargo features
128
131
 
129
132
  | Feature | Effect |
130
133
  |---|---|
134
+ | `component-model-async` | (default) Embed the component-model async runtime as the default built-in. The non-async runtime is always embedded and selectable via `--sync`. Disable to build a smaller binary with only the non-async runtime |
131
135
  | `opt-size` | Selects the bundled opt-size runtime when no runtime option is provided by the CLI or npm API |
132
136
 
133
137
  Build with features:
@@ -166,6 +170,13 @@ export function doubleAdd(a, b) {
166
170
  }
167
171
  ```
168
172
 
173
+ JavaScript modules imported by the entry file are resolved during Wizer
174
+ initialization. Relative imports are resolved from the entry file path passed to
175
+ `--js`; bare package imports are resolved under the read-only module root. By
176
+ default the CLI uses the current directory when the entry file is under it, or
177
+ the entry file's parent directory otherwise. Use `--module-root <PATH>` to expose
178
+ a project root that contains shared files or `node_modules`.
179
+
169
180
  ## WIT Type Mappings
170
181
 
171
182
  ### Primitive Types
@@ -187,13 +198,33 @@ export function doubleAdd(a, b) {
187
198
  | `list<T>` | `Array` | `[1, 2, 3]` |
188
199
  | `list<u8>` | `Uint8Array` or `Array` | `new Uint8Array([1, 2, 3])` |
189
200
  | `tuple<T, U, ...>` | `Array` | `[42, "hello"]` |
190
- | `option<T>` | `T \| null \| undefined` | `null` for none |
191
- | `result<T, E>` | `{ tag: "ok"\|"err", val?: T\|E }` | `{ tag: "ok", val: 42 }` |
201
+ | `option<T>` | `T \| null` (nested: `{ tag: "some"\|"none", val }`) | `null` for none; `option<option<T>>` is wrapped |
202
+ | `result<T, E>` | top-level function result: return `T` or throw `E`; nested result: `{ tag: "ok"\|"err", val?: T\|E }` | `return 42` / `throw "error"` |
192
203
  | `record { ... }` | `object` (camelCase keys) | `{ myField: 1 }` |
193
- | `variant` | `{ tag: number, val?: T }` | `{ tag: 0, val: "hi" }` |
194
- | `enum` | `number` | Lookup tables provided on the interface |
195
- | `flags` | `number` (bitmask) | Bit constants provided on the interface |
196
- | `own<R>`, `borrow<R>` | `number` (handle) | Opaque resource handle |
204
+ | `variant` | `{ tag: string, val?: T }` | `{ tag: "circle", val: 2.5 }` |
205
+ | `enum` | `string` (case name) | `"red"` |
206
+ | `flags` | `object` (camelCase booleans) | `{ read: true, write: false }` |
207
+ | `own<R>`, `borrow<R>` | resource object (methods on its prototype) | `input.blockingRead(n)` |
208
+
209
+ ### Imported Resources
210
+
211
+ Imported resources are exposed as JavaScript classes. Resource methods are
212
+ called on the handle:
213
+
214
+ ```js
215
+ import stdin from "wasi:cli/stdin@0.2.10";
216
+ import stdout from "wasi:cli/stdout@0.2.10";
217
+
218
+ const input = stdin.getStdin(); // an InputStream
219
+ const output = stdout.getStdout(); // an OutputStream
220
+
221
+ // Methods whose WIT return type is result<...> return the ok payload or throw.
222
+ const chunk = input.blockingRead(4096); // method on the resource (len is a number)
223
+ output.blockingWriteAndFlush(chunk);
224
+ ```
225
+
226
+ `[static]` methods are exposed on the resource class and `[constructor]` makes
227
+ the class callable with `new`.
197
228
 
198
229
  ### Async Exports
199
230
 
@@ -383,7 +414,10 @@ const { component } = await componentize({
383
414
  // component is a Buffer containing the WebAssembly component bytes
384
415
  ```
385
416
 
386
- Runtime selection is available through `optSize`, `runtime`, or `runtimeBytes`; provide only one of those options. The `runtime` option is a path to a custom QuickJS runtime Wasm module.
417
+ Runtime selection is available through `optSize`, `sync`, `runtime`, or
418
+ `runtimeBytes`. `optSize` and `sync` may be combined to select the non-async
419
+ opt-size runtime, but neither can be combined with a custom `runtime`/`runtimeBytes`.
420
+ The `runtime` option is a path to a custom QuickJS runtime Wasm module.
387
421
 
388
422
  ## Acknowledgments
389
423
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andreiltd/componentize-qjs-binding-win32-arm64-msvc",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "cpu": [
5
5
  "arm64"
6
6
  ],