@bytecodealliance/preview2-shim 0.20.0 → 0.20.1

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
@@ -6,6 +6,10 @@ Node.js support is fully tested and conformant against the Wasmtime test suite.
6
6
 
7
7
  Browser support is considered experimental, and not currently suitable for production applications.
8
8
 
9
+ The Node.js implementation owns its worker artifact. Direct package use and supported downstream
10
+ bundlers should resolve it through the public shim imports; applications do not need to import or
11
+ copy files from `dist/io`.
12
+
9
13
  # Features
10
14
 
11
15
  ## WASI Shim object for easy instantiation
@@ -1,4 +1,4 @@
1
- import { fileURLToPath } from "node:url";
1
+ import { Worker } from "node:worker_threads";
2
2
  import { createSyncFn } from "../synckit/index.js";
3
3
  import { CALL_MASK, CALL_TYPE_MASK, FILE, HTTP_SERVER_INCOMING_HANDLER, HTTP, INPUT_STREAM_BLOCKING_READ, INPUT_STREAM_BLOCKING_SKIP, INPUT_STREAM_DISPOSE, INPUT_STREAM_READ, INPUT_STREAM_SKIP, INPUT_STREAM_SUBSCRIBE, OUTPUT_STREAM_BLOCKING_FLUSH, OUTPUT_STREAM_BLOCKING_SPLICE, OUTPUT_STREAM_BLOCKING_WRITE_AND_FLUSH, OUTPUT_STREAM_BLOCKING_WRITE_ZEROES_AND_FLUSH, OUTPUT_STREAM_CHECK_WRITE, OUTPUT_STREAM_DISPOSE, OUTPUT_STREAM_FLUSH, OUTPUT_STREAM_SPLICE, OUTPUT_STREAM_SUBSCRIBE, OUTPUT_STREAM_WRITE_ZEROES, OUTPUT_STREAM_WRITE, POLL_POLL_LIST, POLL_POLLABLE_BLOCK, POLL_POLLABLE_DISPOSE, POLL_POLLABLE_READY, SOCKET_TCP, STDERR, STDIN, STDOUT, reverseMap, } from "./calls.js";
4
4
  import nodeProcess, { exit, stderr, stdout, env } from "node:process";
@@ -6,7 +6,6 @@ const symbolDispose = Symbol.dispose || Symbol.for("dispose");
6
6
  const _rawDebug = "_rawDebug" in nodeProcess
7
7
  ? nodeProcess._rawDebug
8
8
  : console.error.bind(console);
9
- const workerPath = fileURLToPath(new URL("./worker-thread.js", import.meta.url));
10
9
  const httpIncomingHandlers = new Map();
11
10
  export function registerIncomingHttpHandler(id, handler) {
12
11
  httpIncomingHandlers.set(id, handler);
@@ -21,7 +20,7 @@ const DEBUG = env.PREVIEW2_SHIM_DEBUG === "0"
21
20
  /**
22
21
  * @type {(call: number, id: number | null, payload: any) -> any}
23
22
  */
24
- export let ioCall = createSyncFn(workerPath, DEBUG, (type, id, payload) => {
23
+ export let ioCall = createSyncFn((options) => new Worker(new URL("./worker-thread.bundle.js", import.meta.url), options), DEBUG, (type, id, payload) => {
25
24
  // 'callbacks' from the worker
26
25
  // ONLY happens for an http server incoming handler, and NOTHING else (not even sockets, since accept is sync!)
27
26
  if (type !== HTTP_SERVER_INCOMING_HANDLER) {