@andreiltd/componentize-qjs-binding-win32-arm64-msvc 0.4.4 → 0.5.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
@@ -24,11 +24,13 @@ Under the hood it:
24
24
  3. Snapshots the initialized JS state with
25
25
  [Wizer](https://github.com/bytecodealliance/wizer) so startup cost is paid at
26
26
  build time, not at runtime.
27
+ 4. Prunes explicitly marked one-time setup code with Walrus and strips
28
+ debug/build metadata from the snapshotted component.
27
29
 
28
30
  ## Prerequisites
29
31
 
30
- Rust **1.94** or later is required (the `wasm32-wasip2` target needs a recent
31
- toolchain for PIC support in wasi-libc).
32
+ Rust **1.97** or later is required by Wasmtime (the `wasm32-wasip2` target also
33
+ needs a recent toolchain for PIC support in wasi-libc).
32
34
 
33
35
  ## Installation
34
36
 
@@ -186,7 +188,7 @@ a project root that contains shared files or `node_modules`.
186
188
  | `bool` | `boolean` | |
187
189
  | `u8`, `u16`, `u32` | `number` | |
188
190
  | `s8`, `s16`, `s32` | `number` | |
189
- | `u64`, `s64` | `number` | Precision limited to 2⁵³ (Number.MAX_SAFE_INTEGER) |
191
+ | `u64`, `s64` | `BigInt` | |
190
192
  | `f32`, `f64` | `number` | |
191
193
  | `char` | `string` | Must be exactly one Unicode scalar value |
192
194
  | `string` | `string` | |
@@ -227,6 +229,43 @@ output.blockingWriteAndFlush(chunk);
227
229
  `[static]` methods are exposed on the resource class and `[constructor]` makes
228
230
  the class callable with `new`.
229
231
 
232
+ Owned imported resources support `[Symbol.dispose]()` for deterministic
233
+ cleanup. Passing one to a WIT `own<T>` parameter transfers ownership and
234
+ invalidates the original wrapper. Borrowed wrappers expire when their component
235
+ call completes and cannot be transferred or disposed as owners. Resources lent
236
+ to an in-flight import remain alive and cannot be disposed or transferred until
237
+ that import completes. Ownership is restored for unconsumed stream/future writes
238
+ and for imported calls cancelled before they start. Await imports using an
239
+ incoming borrowed resource before returning from its export.
240
+
241
+ ### Cancelling Async Imports
242
+
243
+ A pending async import exposes a `cancel()` method on its Promise. Calling it
244
+ requests cancellation of that import. If cancellation succeeds, the original
245
+ Promise rejects with `async import cancelled`; a call that finishes first may
246
+ still resolve normally. The enclosing export remains active, so its catch/finally
247
+ blocks can await further host operations.
248
+ Await the original Promise before releasing resources it borrowed.
249
+ Call `cancel()` from the same async export invocation that started the import;
250
+ it has no effect from another export invocation.
251
+
252
+ Calls that complete immediately may have no `cancel` method; use optional
253
+ chaining when completion timing is unknown. Repeated cancellation is harmless,
254
+ and a saved cancellation function cannot affect a later call that reuses the
255
+ same runtime handle.
256
+
257
+ ```js
258
+ const pending = service.compute(input);
259
+ const abort = () => pending.cancel?.();
260
+ signal.addEventListener("abort", abort);
261
+ try {
262
+ return await pending;
263
+ } finally {
264
+ signal.removeEventListener("abort", abort);
265
+ await service.release();
266
+ }
267
+ ```
268
+
230
269
  ### Async Exports
231
270
 
232
271
  Async exports are declared with the `async` keyword in WIT and implemented
@@ -405,7 +444,7 @@ world async-value {
405
444
  ```
406
445
 
407
446
  ```js
408
- async function compute() {
447
+ export async function compute() {
409
448
  const { readable, writable } = wit.Future();
410
449
 
411
450
  // Write the value (fire-and-forget; completes when reader reads)
@@ -418,6 +457,16 @@ async function compute() {
418
457
  **Future type constants** follow the same pattern: `wit.Future.U32`,
419
458
  `wit.Future.STRING`, etc.
420
459
 
460
+ Future handles are deliberately not thenable: use `await readable.read()` to
461
+ obtain the payload. This keeps `return readable` in an async export from
462
+ implicitly consuming the future, and preserves nested future handles.
463
+ Repeated `read()` calls share the same Promise; a cancelled read rejects that
464
+ Promise and allows a subsequent read to retry.
465
+
466
+ `wit.Future.from(value, type)` adapts a value or Promise and returns
467
+ `{ readable, completion }`. Return its `readable` from an async export rather
468
+ than returning the payload Promise directly, which JavaScript would await.
469
+
421
470
  **FutureReadable methods:**
422
471
 
423
472
  | Method | Returns | Description |
@@ -436,19 +485,33 @@ async function compute() {
436
485
 
437
486
  ### Resource Cleanup
438
487
 
439
- Stream and future handles support
488
+ Owned imported resources, stream endpoints, and future endpoints support
440
489
  [Explicit Resource Management](https://github.com/tc39/proposal-explicit-resource-management)
441
490
  via `Symbol.dispose`. In environments that support `using`:
442
491
 
443
492
  ```js
444
493
  {
445
- using stream = wit.Stream();
446
- // stream.writable and stream.readable are auto-dropped when leaving scope
494
+ const stream = wit.Stream();
495
+ using writable = stream.writable;
496
+ using readable = stream.readable;
497
+ // Each endpoint is disposed when leaving scope.
447
498
  }
448
499
  ```
449
500
 
501
+ The factory's `{ readable, writable }` pair is not itself disposable.
502
+ Complete an endpoint's pending operation (or cancel it and await its
503
+ settlement) before leaving its `using` scope or calling `.drop()`.
504
+ Host-requested task cancellation retains pending ABI buffers until the host
505
+ acknowledges each operation's completion or cancellation.
506
+
450
507
  Otherwise, call `.drop()` explicitly to release handles.
451
508
 
509
+ ## Snapshot Initialization
510
+
511
+ Snapshot creation uses a 1 GiB host-call copy budget to accommodate large module
512
+ graphs. This allowance belongs to the build-time initializer; execution hosts
513
+ continue to choose their own budgets for instantiated components.
514
+
452
515
  ## Node.js API
453
516
 
454
517
  The npm package exposes both a CLI and a programmatic API.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andreiltd/componentize-qjs-binding-win32-arm64-msvc",
3
- "version": "0.4.4",
3
+ "version": "0.5.0",
4
4
  "cpu": [
5
5
  "arm64"
6
6
  ],
@@ -28,4 +28,4 @@
28
28
  "os": [
29
29
  "win32"
30
30
  ]
31
- }
31
+ }