@bytecodealliance/jco 1.33.0 → 1.35.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 +4 -0
- package/dist/bundle.d.ts.map +1 -1
- package/dist/bundle.js +5 -0
- package/dist/bundle.js.map +1 -1
- package/dist/cmd/componentize.d.ts +12 -2
- package/dist/cmd/componentize.d.ts.map +1 -1
- package/dist/cmd/componentize.js +16 -5
- package/dist/cmd/componentize.js.map +1 -1
- package/dist/cmd/new.js +2 -1
- package/dist/cmd/new.js.map +1 -1
- package/dist/cmd/transpile.d.ts.map +1 -1
- package/dist/cmd/transpile.js +28 -1
- package/dist/cmd/transpile.js.map +1 -1
- package/dist/engine-compat.d.ts +11 -0
- package/dist/engine-compat.d.ts.map +1 -0
- package/dist/engine-compat.js +56 -0
- package/dist/engine-compat.js.map +1 -0
- package/dist/jco.js +7 -2
- package/dist/jco.js.map +1 -1
- package/dist/node-builtins/assert.d.ts +3 -0
- package/dist/node-builtins/assert.d.ts.map +1 -0
- package/dist/node-builtins/assert.js +65 -0
- package/dist/node-builtins/assert.js.map +1 -0
- package/dist/node-builtins/async-hooks.d.ts +3 -0
- package/dist/node-builtins/async-hooks.d.ts.map +1 -0
- package/dist/node-builtins/async-hooks.js +27 -0
- package/dist/node-builtins/async-hooks.js.map +1 -0
- package/dist/node-builtins/buffer.d.ts +4 -0
- package/dist/node-builtins/buffer.d.ts.map +1 -0
- package/dist/node-builtins/buffer.js +87 -0
- package/dist/node-builtins/buffer.js.map +1 -0
- package/dist/node-builtins/child-process.d.ts +3 -0
- package/dist/node-builtins/child-process.d.ts.map +1 -0
- package/dist/node-builtins/child-process.js +23 -0
- package/dist/node-builtins/child-process.js.map +1 -0
- package/dist/node-builtins/cluster.d.ts +3 -0
- package/dist/node-builtins/cluster.d.ts.map +1 -0
- package/dist/node-builtins/cluster.js +28 -0
- package/dist/node-builtins/cluster.js.map +1 -0
- package/dist/node-builtins/console.d.ts +3 -0
- package/dist/node-builtins/console.d.ts.map +1 -0
- package/dist/node-builtins/console.js +39 -0
- package/dist/node-builtins/console.js.map +1 -0
- package/dist/node-builtins/crypto.d.ts +3 -0
- package/dist/node-builtins/crypto.d.ts.map +1 -0
- package/dist/node-builtins/crypto.js +5 -0
- package/dist/node-builtins/crypto.js.map +1 -0
- package/dist/node-builtins/dgram.d.ts +4 -0
- package/dist/node-builtins/dgram.d.ts.map +1 -0
- package/dist/node-builtins/dgram.js +13 -0
- package/dist/node-builtins/dgram.js.map +1 -0
- package/dist/node-builtins/diagnostics-channel.d.ts +3 -0
- package/dist/node-builtins/diagnostics-channel.d.ts.map +1 -0
- package/dist/node-builtins/diagnostics-channel.js +26 -0
- package/dist/node-builtins/diagnostics-channel.js.map +1 -0
- package/dist/node-builtins/dns.d.ts +3 -0
- package/dist/node-builtins/dns.d.ts.map +1 -0
- package/dist/node-builtins/dns.js +12 -0
- package/dist/node-builtins/dns.js.map +1 -0
- package/dist/node-builtins/domain.d.ts +3 -0
- package/dist/node-builtins/domain.d.ts.map +1 -0
- package/dist/node-builtins/domain.js +19 -0
- package/dist/node-builtins/domain.js.map +1 -0
- package/dist/node-builtins/events.d.ts +3 -0
- package/dist/node-builtins/events.d.ts.map +1 -0
- package/dist/node-builtins/events.js +39 -0
- package/dist/node-builtins/events.js.map +1 -0
- package/dist/node-builtins/ffi.d.ts +3 -0
- package/dist/node-builtins/ffi.d.ts.map +1 -0
- package/dist/node-builtins/ffi.js +59 -0
- package/dist/node-builtins/ffi.js.map +1 -0
- package/dist/node-builtins/fs.d.ts +3 -0
- package/dist/node-builtins/fs.d.ts.map +1 -0
- package/dist/node-builtins/fs.js +16 -0
- package/dist/node-builtins/fs.js.map +1 -0
- package/dist/node-builtins/globals.d.ts +19 -0
- package/dist/node-builtins/globals.d.ts.map +1 -0
- package/dist/node-builtins/globals.js +56 -0
- package/dist/node-builtins/globals.js.map +1 -0
- package/dist/node-builtins/http-common.d.ts +6 -0
- package/dist/node-builtins/http-common.d.ts.map +1 -0
- package/dist/node-builtins/http-common.js +111 -0
- package/dist/node-builtins/http-common.js.map +1 -0
- package/dist/node-builtins/http.d.ts +4 -0
- package/dist/node-builtins/http.d.ts.map +1 -0
- package/dist/node-builtins/http.js +15 -0
- package/dist/node-builtins/http.js.map +1 -0
- package/dist/node-builtins/http2.d.ts +4 -0
- package/dist/node-builtins/http2.d.ts.map +1 -0
- package/dist/node-builtins/http2.js +79 -0
- package/dist/node-builtins/http2.js.map +1 -0
- package/dist/node-builtins/https.d.ts +3 -0
- package/dist/node-builtins/https.d.ts.map +1 -0
- package/dist/node-builtins/https.js +5 -0
- package/dist/node-builtins/https.js.map +1 -0
- package/dist/node-builtins/index.d.ts +10 -0
- package/dist/node-builtins/index.d.ts.map +1 -0
- package/dist/node-builtins/index.js +164 -0
- package/dist/node-builtins/index.js.map +1 -0
- package/dist/node-builtins/inspector.d.ts +12 -0
- package/dist/node-builtins/inspector.d.ts.map +1 -0
- package/dist/node-builtins/inspector.js +70 -0
- package/dist/node-builtins/inspector.js.map +1 -0
- package/dist/node-builtins/module.d.ts +3 -0
- package/dist/node-builtins/module.d.ts.map +1 -0
- package/dist/node-builtins/module.js +55 -0
- package/dist/node-builtins/module.js.map +1 -0
- package/dist/node-builtins/net.d.ts +3 -0
- package/dist/node-builtins/net.d.ts.map +1 -0
- package/dist/node-builtins/net.js +46 -0
- package/dist/node-builtins/net.js.map +1 -0
- package/dist/node-builtins/os.d.ts +3 -0
- package/dist/node-builtins/os.d.ts.map +1 -0
- package/dist/node-builtins/os.js +39 -0
- package/dist/node-builtins/os.js.map +1 -0
- package/dist/node-builtins/path.d.ts +3 -0
- package/dist/node-builtins/path.d.ts.map +1 -0
- package/dist/node-builtins/path.js +91 -0
- package/dist/node-builtins/path.js.map +1 -0
- package/dist/node-builtins/perf-hooks.d.ts +3 -0
- package/dist/node-builtins/perf-hooks.d.ts.map +1 -0
- package/dist/node-builtins/perf-hooks.js +12 -0
- package/dist/node-builtins/perf-hooks.js.map +1 -0
- package/dist/node-builtins/process.d.ts +3 -0
- package/dist/node-builtins/process.d.ts.map +1 -0
- package/dist/node-builtins/process.js +9 -0
- package/dist/node-builtins/process.js.map +1 -0
- package/dist/node-builtins/querystring.d.ts +3 -0
- package/dist/node-builtins/querystring.d.ts.map +1 -0
- package/dist/node-builtins/querystring.js +18 -0
- package/dist/node-builtins/querystring.js.map +1 -0
- package/dist/node-builtins/readline.d.ts +3 -0
- package/dist/node-builtins/readline.d.ts.map +1 -0
- package/dist/node-builtins/readline.js +11 -0
- package/dist/node-builtins/readline.js.map +1 -0
- package/dist/node-builtins/repl.d.ts +9 -0
- package/dist/node-builtins/repl.d.ts.map +1 -0
- package/dist/node-builtins/repl.js +12 -0
- package/dist/node-builtins/repl.js.map +1 -0
- package/dist/node-builtins/shared.d.ts +24 -0
- package/dist/node-builtins/shared.d.ts.map +1 -0
- package/dist/node-builtins/shared.js +68 -0
- package/dist/node-builtins/shared.js.map +1 -0
- package/dist/node-builtins/sqlite.d.ts +3 -0
- package/dist/node-builtins/sqlite.d.ts.map +1 -0
- package/dist/node-builtins/sqlite.js +9 -0
- package/dist/node-builtins/sqlite.js.map +1 -0
- package/dist/node-builtins/stream.d.ts +3 -0
- package/dist/node-builtins/stream.d.ts.map +1 -0
- package/dist/node-builtins/stream.js +64 -0
- package/dist/node-builtins/stream.js.map +1 -0
- package/dist/node-builtins/string-decoder.d.ts +3 -0
- package/dist/node-builtins/string-decoder.d.ts.map +1 -0
- package/dist/node-builtins/string-decoder.js +14 -0
- package/dist/node-builtins/string-decoder.js.map +1 -0
- package/dist/node-builtins/test.d.ts +4 -0
- package/dist/node-builtins/test.d.ts.map +1 -0
- package/dist/node-builtins/test.js +8 -0
- package/dist/node-builtins/test.js.map +1 -0
- package/dist/node-builtins/timers.d.ts +4 -0
- package/dist/node-builtins/timers.d.ts.map +1 -0
- package/dist/node-builtins/timers.js +9 -0
- package/dist/node-builtins/timers.js.map +1 -0
- package/dist/node-builtins/tls.d.ts +3 -0
- package/dist/node-builtins/tls.d.ts.map +1 -0
- package/dist/node-builtins/tls.js +10 -0
- package/dist/node-builtins/tls.js.map +1 -0
- package/dist/node-builtins/trace-events.d.ts +3 -0
- package/dist/node-builtins/trace-events.d.ts.map +1 -0
- package/dist/node-builtins/trace-events.js +9 -0
- package/dist/node-builtins/trace-events.js.map +1 -0
- package/dist/node-builtins/tty.d.ts +8 -0
- package/dist/node-builtins/tty.d.ts.map +1 -0
- package/dist/node-builtins/tty.js +12 -0
- package/dist/node-builtins/tty.js.map +1 -0
- package/dist/{node-builtins.d.ts → node-builtins/types.d.ts} +73 -41
- package/dist/node-builtins/types.d.ts.map +1 -0
- package/dist/node-builtins/types.js +2 -0
- package/dist/node-builtins/types.js.map +1 -0
- package/dist/node-builtins/unenv.d.ts +6 -0
- package/dist/node-builtins/unenv.d.ts.map +1 -0
- package/dist/node-builtins/unenv.js +27 -0
- package/dist/node-builtins/unenv.js.map +1 -0
- package/dist/node-builtins/url-pattern.d.ts +8 -0
- package/dist/node-builtins/url-pattern.d.ts.map +1 -0
- package/dist/node-builtins/url-pattern.js +19 -0
- package/dist/node-builtins/url-pattern.js.map +1 -0
- package/dist/node-builtins/url.d.ts +4 -0
- package/dist/node-builtins/url.d.ts.map +1 -0
- package/dist/node-builtins/url.js +100 -0
- package/dist/node-builtins/url.js.map +1 -0
- package/dist/node-builtins/util.d.ts +3 -0
- package/dist/node-builtins/util.d.ts.map +1 -0
- package/dist/node-builtins/util.js +7 -0
- package/dist/node-builtins/util.js.map +1 -0
- package/dist/node-builtins/v8.d.ts +3 -0
- package/dist/node-builtins/v8.d.ts.map +1 -0
- package/dist/node-builtins/v8.js +6 -0
- package/dist/node-builtins/v8.js.map +1 -0
- package/dist/node-builtins/vfs.d.ts +3 -0
- package/dist/node-builtins/vfs.d.ts.map +1 -0
- package/dist/node-builtins/vfs.js +42 -0
- package/dist/node-builtins/vfs.js.map +1 -0
- package/dist/node-builtins/vm.d.ts +4 -0
- package/dist/node-builtins/vm.d.ts.map +1 -0
- package/dist/node-builtins/vm.js +6 -0
- package/dist/node-builtins/vm.js.map +1 -0
- package/dist/node-builtins/wasi-sockets.d.ts +10 -0
- package/dist/node-builtins/wasi-sockets.d.ts.map +1 -0
- package/dist/node-builtins/wasi-sockets.js +25 -0
- package/dist/node-builtins/wasi-sockets.js.map +1 -0
- package/dist/node-builtins/wasi.d.ts +10 -0
- package/dist/node-builtins/wasi.d.ts.map +1 -0
- package/dist/node-builtins/wasi.js +14 -0
- package/dist/node-builtins/wasi.js.map +1 -0
- package/dist/node-builtins/worker-threads.d.ts +3 -0
- package/dist/node-builtins/worker-threads.d.ts.map +1 -0
- package/dist/node-builtins/worker-threads.js +16 -0
- package/dist/node-builtins/worker-threads.js.map +1 -0
- package/dist/node-builtins/zlib.d.ts +3 -0
- package/dist/node-builtins/zlib.d.ts.map +1 -0
- package/dist/node-builtins/zlib.js +6 -0
- package/dist/node-builtins/zlib.js.map +1 -0
- package/dist/node-wit.d.ts +35 -0
- package/dist/node-wit.d.ts.map +1 -1
- package/dist/node-wit.js +135 -4
- package/dist/node-wit.js.map +1 -1
- package/lib/wit/builtin/jco-node-0.1.0/cluster.wit +3 -2
- package/lib/wit/builtin/jco-node-0.1.0/dgram.wit +142 -0
- package/lib/wit/builtin/jco-node-0.1.0/http.wit +7 -0
- package/lib/wit/builtin/jco-node-0.1.0/http2.wit +4 -5
- package/lib/wit/builtin/jco-node-0.1.0/process.wit +245 -0
- package/lib/wit/builtin/jco-node-0.1.0/sqlite.wit +154 -0
- package/lib/wit/builtin/jco-node-0.1.0/tls.wit +108 -0
- package/lib/wit/builtin/jco-node-0.1.0/trace-events.wit +27 -0
- package/lib/wit/builtin/jco-node-0.1.0/tty.wit +59 -0
- package/lib/wit/builtin/jco-node-0.1.0/v8.wit +102 -0
- package/lib/wit/builtin/jco-node-0.1.0/wasi.wit +57 -0
- package/lib/wit/builtin/jco-node-0.1.0/worker-threads.wit +67 -0
- package/lib/wit/builtin/jco-node-0.1.0/zlib.wit +77 -0
- package/lib/wit/builtin/wasi-tls-0.2.0-draft/LICENSE.md +8 -0
- package/lib/wit/builtin/wasi-tls-0.2.0-draft/README.md +25 -0
- package/lib/wit/builtin/wasi-tls-0.2.0-draft/deps/io/package.wit +66 -0
- package/lib/wit/builtin/wasi-tls-0.2.0-draft/types.wit +27 -0
- package/lib/wit/builtin/wasi-tls-0.2.0-draft/world.wit +8 -0
- package/package.json +8 -6
- package/dist/node-builtins.d.ts.map +0 -1
- package/dist/node-builtins.js +0 -1085
- package/dist/node-builtins.js.map +0 -1
package/dist/node-builtins.js
DELETED
|
@@ -1,1085 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from "node:url";
|
|
2
|
-
import { defineEnv } from "unenv";
|
|
3
|
-
import { CHILD_PROCESS_WIT_REQUIREMENT, CLUSTER_WIT_REQUIREMENT, CONSOLE_WIT_REQUIREMENT, DNS_PROMISES_WIT_REQUIREMENT, DNS_WIT_REQUIREMENT, FS_WIT_REQUIREMENT, FFI_WIT_REQUIREMENT, HTTP_WASI_HTTP_WIT_REQUIREMENTS, HTTP_WASI_SOCKETS_0_2_10_WIT_REQUIREMENTS, HTTP_WASI_SOCKETS_WIT_REQUIREMENTS, HTTP_WIT_REQUIREMENT, HTTP2_WIT_REQUIREMENT, INSPECTOR_PROMISES_WIT_REQUIREMENT, INSPECTOR_WIT_REQUIREMENT, OS_WIT_REQUIREMENT, } from "./node-wit.js";
|
|
4
|
-
const PATH_SPECIFIERS = new Map([
|
|
5
|
-
["node:path", "default"],
|
|
6
|
-
["node:path/posix", "posix"],
|
|
7
|
-
["node:path/win32", "win32"],
|
|
8
|
-
]);
|
|
9
|
-
const ASSERT_SPECIFIERS = new Set(["node:assert", "node:assert/strict"]);
|
|
10
|
-
const CHILD_PROCESS_SPECIFIER = "node:child_process";
|
|
11
|
-
const CLUSTER_SPECIFIER = "node:cluster";
|
|
12
|
-
const CONSOLE_SPECIFIER = "node:console";
|
|
13
|
-
const FS_SPECIFIERS = new Set(["node:fs", "node:fs/promises"]);
|
|
14
|
-
const ASYNC_HOOKS_SPECIFIER = "node:async_hooks";
|
|
15
|
-
const DOMAIN_SPECIFIER = "node:domain";
|
|
16
|
-
const FFI_SPECIFIER = "node:ffi";
|
|
17
|
-
const INSPECTOR_SPECIFIER = "node:inspector";
|
|
18
|
-
const INSPECTOR_PROMISES_SPECIFIER = "node:inspector/promises";
|
|
19
|
-
const INSPECTOR_SPECIFIERS = new Set([INSPECTOR_SPECIFIER, INSPECTOR_PROMISES_SPECIFIER]);
|
|
20
|
-
/**
|
|
21
|
-
* Virtual specifier the two-pass bundler imports to reach the guest-exported callbacks interface.
|
|
22
|
-
*
|
|
23
|
-
* `node:inspector` is host-backed, but the host also has to call *back* into the component. A
|
|
24
|
-
* component cannot implement a resource on an imported interface, so the callbacks live in a
|
|
25
|
-
* guest-exported interface, and this virtual module re-exports its implementation from the shared
|
|
26
|
-
* jco-std inspector module so the wrapper can add it to the component's top-level exports.
|
|
27
|
-
*/
|
|
28
|
-
export const INSPECTOR_CALLBACKS_SPECIFIER = "jco:node-inspector-callbacks";
|
|
29
|
-
const MODULE_SPECIFIER = "node:module";
|
|
30
|
-
const DIAGNOSTICS_CHANNEL_SPECIFIER = "node:diagnostics_channel";
|
|
31
|
-
const EVENTS_SPECIFIER = "node:events";
|
|
32
|
-
const OS_SPECIFIER = "node:os";
|
|
33
|
-
const STRING_DECODER_SPECIFIER = "node:string_decoder";
|
|
34
|
-
const STREAM_CONSUMERS_SPECIFIER = "node:stream/consumers";
|
|
35
|
-
const STREAM_ITER_SPECIFIER = "node:stream/iter";
|
|
36
|
-
const DNS_SPECIFIERS = new Set(["node:dns", "node:dns/promises"]);
|
|
37
|
-
const HTTP_SPECIFIER = "node:http";
|
|
38
|
-
export const HTTP_CALLBACKS_SPECIFIER = "jco:node-http-callbacks";
|
|
39
|
-
const HTTP2_SPECIFIER = "node:http2";
|
|
40
|
-
export const HTTP2_CALLBACKS_SPECIFIER = "jco:node-http2-callbacks";
|
|
41
|
-
const AUDITED_UNENV_SPECIFIERS = new Set(["node:buffer", "node:querystring"]);
|
|
42
|
-
const VIRTUAL_PREFIX = "\0jco-node-builtin:";
|
|
43
|
-
const INSPECTOR_CALLBACKS_MODULE = `${VIRTUAL_PREFIX}inspector-callbacks`;
|
|
44
|
-
const HTTP_CALLBACKS_MODULE = `${VIRTUAL_PREFIX}http-callbacks`;
|
|
45
|
-
const HTTP2_CALLBACKS_MODULE = `${VIRTUAL_PREFIX}http2-callbacks`;
|
|
46
|
-
const UNENV_BUFFER_CORE = `${VIRTUAL_PREFIX}unenv-buffer-core`;
|
|
47
|
-
const ABORT_GLOBALS_SPECIFIER = "jco:node-abort-globals";
|
|
48
|
-
const ABORT_GLOBALS_MODULE = `${VIRTUAL_PREFIX}abort-globals`;
|
|
49
|
-
const ERROR_GLOBALS_SPECIFIER = "jco:node-error-globals";
|
|
50
|
-
const ERROR_GLOBALS_MODULE = `${VIRTUAL_PREFIX}error-globals`;
|
|
51
|
-
const NODE_ERROR_GLOBAL_NAMES = [
|
|
52
|
-
"AggregateError",
|
|
53
|
-
"DOMException",
|
|
54
|
-
"Error",
|
|
55
|
-
"EvalError",
|
|
56
|
-
"RangeError",
|
|
57
|
-
"ReferenceError",
|
|
58
|
-
"SuppressedError",
|
|
59
|
-
"SyntaxError",
|
|
60
|
-
"TypeError",
|
|
61
|
-
"URIError",
|
|
62
|
-
];
|
|
63
|
-
/**
|
|
64
|
-
* Rolldown injection map for Node's global error constructors.
|
|
65
|
-
*
|
|
66
|
-
* Injection is demand-driven: if source never references one of these globals,
|
|
67
|
-
* Rolldown does not include the errors module in the generated bundle.
|
|
68
|
-
*/
|
|
69
|
-
export function nodeErrorGlobals(options = {}) {
|
|
70
|
-
const errorsModule = options.errorsModule ?? ERROR_GLOBALS_SPECIFIER;
|
|
71
|
-
return Object.fromEntries(NODE_ERROR_GLOBAL_NAMES.map((name) => [name, [errorsModule, name]]));
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Rolldown injection map for Node globals backed by Jco implementations.
|
|
75
|
-
*
|
|
76
|
-
* Web globals are supplied by the engine; Abort globals have a compatibility adapter
|
|
77
|
-
* for engines with the legacy variadic AbortSignal.any implementation.
|
|
78
|
-
* Rolldown includes these adapters only when their free identifiers survive bundling.
|
|
79
|
-
*/
|
|
80
|
-
export function nodeGlobals(options = {}) {
|
|
81
|
-
return {
|
|
82
|
-
...nodeErrorGlobals(options),
|
|
83
|
-
AbortController: [options.abortGlobalsModule ?? ABORT_GLOBALS_SPECIFIER, "AbortController"],
|
|
84
|
-
AbortSignal: [options.abortGlobalsModule ?? ABORT_GLOBALS_SPECIFIER, "AbortSignal"],
|
|
85
|
-
Buffer: [options.bufferModule ?? "node:buffer", "Buffer"],
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
let defaultUnenvAliases;
|
|
89
|
-
function getUnenvAliases(options) {
|
|
90
|
-
if (options.unenvAliases) {
|
|
91
|
-
return options.unenvAliases;
|
|
92
|
-
}
|
|
93
|
-
// NOTE: read back through the assignment rather than the module-level binding, which is
|
|
94
|
-
// only non-nullable here by narrowing
|
|
95
|
-
return (defaultUnenvAliases ??= {
|
|
96
|
-
...defineEnv({ resolve: true }).env.alias,
|
|
97
|
-
"unenv:buffer-core": fileURLToPath(import.meta.resolve("unenv/node/internal/buffer/buffer")),
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
function unenvModule(specifier, options) {
|
|
101
|
-
const resolved = getUnenvAliases(options)[specifier];
|
|
102
|
-
if (!resolved || resolved.startsWith("node:")) {
|
|
103
|
-
throw new Error(`unenv did not provide a bundleable implementation for audited builtin ${specifier}`);
|
|
104
|
-
}
|
|
105
|
-
return resolved;
|
|
106
|
-
}
|
|
107
|
-
function unenvAdapter(specifier, options) {
|
|
108
|
-
if (specifier === "node:buffer") {
|
|
109
|
-
return `
|
|
110
|
-
export { default } from ${JSON.stringify(UNENV_BUFFER_CORE)};
|
|
111
|
-
export * from ${JSON.stringify(UNENV_BUFFER_CORE)};
|
|
112
|
-
`;
|
|
113
|
-
}
|
|
114
|
-
if (specifier === "node:querystring") {
|
|
115
|
-
const querystringModule = unenvModule(specifier, options);
|
|
116
|
-
return `
|
|
117
|
-
import ${JSON.stringify(UNENV_BUFFER_CORE)};
|
|
118
|
-
import querystring from ${JSON.stringify(querystringModule)};
|
|
119
|
-
export * from ${JSON.stringify(querystringModule)};
|
|
120
|
-
export default querystring;
|
|
121
|
-
`;
|
|
122
|
-
}
|
|
123
|
-
throw new Error(`missing Jco adapter for audited unenv builtin ${specifier}`);
|
|
124
|
-
}
|
|
125
|
-
function unenvBufferCore(options) {
|
|
126
|
-
// Implementation source: unenv@2.0.0-rc.24's
|
|
127
|
-
// runtime/node/internal/buffer/buffer module, which wraps the MIT-licensed
|
|
128
|
-
// Feross buffer implementation. Node-facing constants and the public export
|
|
129
|
-
// shape follow Node.js v24 lib/buffer.js.
|
|
130
|
-
const bufferModule = unenvModule("unenv:buffer-core", options);
|
|
131
|
-
return `
|
|
132
|
-
import {
|
|
133
|
-
Buffer as UnenvBuffer,
|
|
134
|
-
INSPECT_MAX_BYTES,
|
|
135
|
-
kMaxLength,
|
|
136
|
-
} from ${JSON.stringify(bufferModule)};
|
|
137
|
-
function deprecatedBufferConstructor() {
|
|
138
|
-
const error = new Error("The deprecated Buffer() constructor is not supported; use Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() instead");
|
|
139
|
-
error.code = "ERR_JCO_UNSUPPORTED_DEPRECATED_NODE_API";
|
|
140
|
-
throw error;
|
|
141
|
-
}
|
|
142
|
-
function unsupported(api) {
|
|
143
|
-
const error = new Error(api + " is not supported by the Jco component runtime");
|
|
144
|
-
error.code = "ERR_JCO_UNSUPPORTED_NODE_API";
|
|
145
|
-
throw error;
|
|
146
|
-
}
|
|
147
|
-
export const Buffer = new Proxy(UnenvBuffer, {
|
|
148
|
-
apply: deprecatedBufferConstructor,
|
|
149
|
-
construct: deprecatedBufferConstructor,
|
|
150
|
-
});
|
|
151
|
-
Buffer.prototype.constructor = Buffer;
|
|
152
|
-
// TypedArray-derived methods must allocate through the upstream implementation,
|
|
153
|
-
// not the deprecated-constructor guard exposed to users.
|
|
154
|
-
Object.defineProperty(Buffer, Symbol.species, { value: UnenvBuffer });
|
|
155
|
-
export const SlowBuffer = new Proxy(function SlowBuffer() {}, {
|
|
156
|
-
apply: deprecatedBufferConstructor,
|
|
157
|
-
construct: deprecatedBufferConstructor,
|
|
158
|
-
});
|
|
159
|
-
export const Blob = globalThis.Blob ?? class Blob {
|
|
160
|
-
constructor() { unsupported("buffer.Blob"); }
|
|
161
|
-
};
|
|
162
|
-
export const File = globalThis.File ?? class File {
|
|
163
|
-
constructor() { unsupported("buffer.File"); }
|
|
164
|
-
};
|
|
165
|
-
export { INSPECT_MAX_BYTES, kMaxLength };
|
|
166
|
-
export const kStringMaxLength = 536870888;
|
|
167
|
-
export const constants = {
|
|
168
|
-
MAX_LENGTH: Number.MAX_SAFE_INTEGER,
|
|
169
|
-
MAX_STRING_LENGTH: kStringMaxLength,
|
|
170
|
-
};
|
|
171
|
-
export const atob = globalThis.atob?.bind(globalThis) ?? ((value) => UnenvBuffer.from(value, "base64").toString("latin1"));
|
|
172
|
-
export const btoa = globalThis.btoa?.bind(globalThis) ?? ((value) => UnenvBuffer.from(value, "latin1").toString("base64"));
|
|
173
|
-
export const isAscii = () => unsupported("buffer.isAscii");
|
|
174
|
-
export const isUtf8 = () => unsupported("buffer.isUtf8");
|
|
175
|
-
export const resolveObjectURL = () => unsupported("buffer.resolveObjectURL");
|
|
176
|
-
export const transcode = () => unsupported("buffer.transcode");
|
|
177
|
-
globalThis.Buffer = Buffer;
|
|
178
|
-
export default {
|
|
179
|
-
atob,
|
|
180
|
-
Blob,
|
|
181
|
-
Buffer,
|
|
182
|
-
btoa,
|
|
183
|
-
constants,
|
|
184
|
-
File,
|
|
185
|
-
INSPECT_MAX_BYTES,
|
|
186
|
-
isAscii,
|
|
187
|
-
isUtf8,
|
|
188
|
-
kMaxLength,
|
|
189
|
-
kStringMaxLength,
|
|
190
|
-
resolveObjectURL,
|
|
191
|
-
SlowBuffer,
|
|
192
|
-
transcode,
|
|
193
|
-
};
|
|
194
|
-
`;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Source of the `node:module` adapter.
|
|
198
|
-
*
|
|
199
|
-
* Capability-free: what this module can do here is classification and source-map arithmetic, and
|
|
200
|
-
* what it cannot do -- loading -- no host could supply, because the missing piece is the guest
|
|
201
|
-
* engine's ability to instantiate code that was not bundled.
|
|
202
|
-
*/
|
|
203
|
-
function moduleAdapter(moduleModule) {
|
|
204
|
-
return `
|
|
205
|
-
import nodeModule from ${JSON.stringify(moduleModule)};
|
|
206
|
-
export default nodeModule;
|
|
207
|
-
export {
|
|
208
|
-
Module,
|
|
209
|
-
SourceMap,
|
|
210
|
-
_cache,
|
|
211
|
-
_debug,
|
|
212
|
-
_extensions,
|
|
213
|
-
_findPath,
|
|
214
|
-
_initPaths,
|
|
215
|
-
_load,
|
|
216
|
-
_nodeModulePaths,
|
|
217
|
-
_pathCache,
|
|
218
|
-
_preloadModules,
|
|
219
|
-
_readPackage,
|
|
220
|
-
_resolveFilename,
|
|
221
|
-
_resolveLookupPaths,
|
|
222
|
-
_stat,
|
|
223
|
-
builtinModules,
|
|
224
|
-
constants,
|
|
225
|
-
createRequire,
|
|
226
|
-
enableCompileCache,
|
|
227
|
-
findPackageJSON,
|
|
228
|
-
findSourceMap,
|
|
229
|
-
flushCompileCache,
|
|
230
|
-
getCompileCacheDir,
|
|
231
|
-
getSourceMapsSupport,
|
|
232
|
-
globalPaths,
|
|
233
|
-
isBuiltin,
|
|
234
|
-
register,
|
|
235
|
-
registerHooks,
|
|
236
|
-
runMain,
|
|
237
|
-
setSourceMapsSupport,
|
|
238
|
-
stripTypeScriptTypes,
|
|
239
|
-
syncBuiltinESMExports,
|
|
240
|
-
wrap,
|
|
241
|
-
wrapper,
|
|
242
|
-
} from ${JSON.stringify(moduleModule)};
|
|
243
|
-
`;
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Source of the `node:ffi` adapter.
|
|
247
|
-
*
|
|
248
|
-
* Host-backed, like `node:child_process`: WASI has no dynamic loader and a component has no host
|
|
249
|
-
* address space, so the jco-std module imports the WIT interface itself and this adapter only has
|
|
250
|
-
* to re-export Node's module shape.
|
|
251
|
-
*
|
|
252
|
-
* Note the module this resolves to lives under `node/26.x.x`: `node:ffi` does not exist in Node 24.
|
|
253
|
-
*/
|
|
254
|
-
function ffiAdapter(ffiModule) {
|
|
255
|
-
return `
|
|
256
|
-
import ffi from ${JSON.stringify(ffiModule)};
|
|
257
|
-
export default ffi;
|
|
258
|
-
export {
|
|
259
|
-
DynamicLibrary,
|
|
260
|
-
dlclose,
|
|
261
|
-
dlopen,
|
|
262
|
-
dlsym,
|
|
263
|
-
exportArrayBuffer,
|
|
264
|
-
exportArrayBufferView,
|
|
265
|
-
exportBuffer,
|
|
266
|
-
exportString,
|
|
267
|
-
getCurrentEventLoop,
|
|
268
|
-
getFloat32,
|
|
269
|
-
getFloat64,
|
|
270
|
-
getInt16,
|
|
271
|
-
getInt32,
|
|
272
|
-
getInt64,
|
|
273
|
-
getInt8,
|
|
274
|
-
getRawPointer,
|
|
275
|
-
getUint16,
|
|
276
|
-
getUint32,
|
|
277
|
-
getUint64,
|
|
278
|
-
getUint8,
|
|
279
|
-
setFloat32,
|
|
280
|
-
setFloat64,
|
|
281
|
-
setInt16,
|
|
282
|
-
setInt32,
|
|
283
|
-
setInt64,
|
|
284
|
-
setInt8,
|
|
285
|
-
setUint16,
|
|
286
|
-
setUint32,
|
|
287
|
-
setUint64,
|
|
288
|
-
setUint8,
|
|
289
|
-
suffix,
|
|
290
|
-
toArrayBuffer,
|
|
291
|
-
toBuffer,
|
|
292
|
-
toString,
|
|
293
|
-
types,
|
|
294
|
-
} from ${JSON.stringify(ffiModule)};
|
|
295
|
-
`;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Source of the `node:inspector` adapter.
|
|
299
|
-
*
|
|
300
|
-
* Host-backed like `node:ffi`, but with a second half: the host also calls *back* into the
|
|
301
|
-
* component when a protocol response or notification arrives. That channel is the guest-exported
|
|
302
|
-
* `inspectorCallbacks` interface, added to the component's exports by Jco's two-pass bundling; this
|
|
303
|
-
* adapter only re-exports the module surface.
|
|
304
|
-
*/
|
|
305
|
-
function inspectorAdapter(inspectorModule) {
|
|
306
|
-
return `
|
|
307
|
-
import inspector from ${JSON.stringify(inspectorModule)};
|
|
308
|
-
export default inspector;
|
|
309
|
-
export {
|
|
310
|
-
close,
|
|
311
|
-
console,
|
|
312
|
-
DOMStorage,
|
|
313
|
-
Network,
|
|
314
|
-
NetworkResources,
|
|
315
|
-
open,
|
|
316
|
-
Session,
|
|
317
|
-
url,
|
|
318
|
-
waitForDebugger,
|
|
319
|
-
} from ${JSON.stringify(inspectorModule)};
|
|
320
|
-
`;
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Source of the `node:inspector/promises` adapter, sharing one core with `node:inspector`.
|
|
324
|
-
*
|
|
325
|
-
* The promises entry point re-exports the same public surface as `node:inspector`, so the adapter
|
|
326
|
-
* source is identical apart from the module it points at.
|
|
327
|
-
*/
|
|
328
|
-
function inspectorPromisesAdapter(inspectorPromisesModule) {
|
|
329
|
-
return inspectorAdapter(inspectorPromisesModule);
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Source of the virtual module the two-pass bundler exports to satisfy the guest-exported
|
|
333
|
-
* `jco:node/inspector-callbacks@0.1.0` interface.
|
|
334
|
-
*
|
|
335
|
-
* Always pulls from the base `node:inspector` module (not `/promises`), which owns the one callback
|
|
336
|
-
* registry both entries register into.
|
|
337
|
-
*/
|
|
338
|
-
function inspectorCallbacksAdapter(inspectorModule) {
|
|
339
|
-
return `export { inspectorCallbacks } from ${JSON.stringify(inspectorModule)};`;
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Source of the `node:domain` adapter.
|
|
343
|
-
*
|
|
344
|
-
* Resolves so the failure can explain itself: `node:domain` is deprecated upstream and every use
|
|
345
|
-
* throws. Leaving it unresolved would fail the build with an unrelated-sounding message.
|
|
346
|
-
*/
|
|
347
|
-
function domainAdapter(domainModule) {
|
|
348
|
-
return `
|
|
349
|
-
import domain from ${JSON.stringify(domainModule)};
|
|
350
|
-
export default domain;
|
|
351
|
-
export { Domain, create, createDomain } from ${JSON.stringify(domainModule)};
|
|
352
|
-
`;
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* Source of the `node:diagnostics_channel` adapter.
|
|
356
|
-
*
|
|
357
|
-
* Capability-free: in-process publish/subscribe with no host involvement.
|
|
358
|
-
*/
|
|
359
|
-
function diagnosticsChannelAdapter(diagnosticsChannelModule) {
|
|
360
|
-
return `
|
|
361
|
-
import diagnosticsChannel from ${JSON.stringify(diagnosticsChannelModule)};
|
|
362
|
-
export default diagnosticsChannel;
|
|
363
|
-
export {
|
|
364
|
-
Channel,
|
|
365
|
-
TracingChannel,
|
|
366
|
-
channel,
|
|
367
|
-
hasSubscribers,
|
|
368
|
-
subscribe,
|
|
369
|
-
tracingChannel,
|
|
370
|
-
unsubscribe,
|
|
371
|
-
} from ${JSON.stringify(diagnosticsChannelModule)};
|
|
372
|
-
`;
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Source of the `node:async_hooks` adapter.
|
|
376
|
-
*
|
|
377
|
-
* Capability-free: synchronous context tracking with no host involvement, so it resolves for a
|
|
378
|
-
* world with no imports at all.
|
|
379
|
-
*/
|
|
380
|
-
function asyncHooksAdapter(asyncHooksModule) {
|
|
381
|
-
return `
|
|
382
|
-
import asyncHooks from ${JSON.stringify(asyncHooksModule)};
|
|
383
|
-
export default asyncHooks;
|
|
384
|
-
export {
|
|
385
|
-
AsyncLocalStorage,
|
|
386
|
-
AsyncResource,
|
|
387
|
-
asyncWrapProviders,
|
|
388
|
-
createHook,
|
|
389
|
-
executionAsyncId,
|
|
390
|
-
executionAsyncResource,
|
|
391
|
-
triggerAsyncId,
|
|
392
|
-
} from ${JSON.stringify(asyncHooksModule)};
|
|
393
|
-
`;
|
|
394
|
-
}
|
|
395
|
-
/** Source of the capability-free `node:string_decoder` ESM facade. */
|
|
396
|
-
function stringDecoderAdapter(stringDecoderModule) {
|
|
397
|
-
return `
|
|
398
|
-
import stringDecoder from ${JSON.stringify(stringDecoderModule)};
|
|
399
|
-
export default stringDecoder;
|
|
400
|
-
export { StringDecoder } from ${JSON.stringify(stringDecoderModule)};
|
|
401
|
-
`;
|
|
402
|
-
}
|
|
403
|
-
/**
|
|
404
|
-
* Source of the `node:events` adapter.
|
|
405
|
-
*
|
|
406
|
-
* unenv's `EventEmitter` is faithful to Node and is reused whole, including `once`, `on`,
|
|
407
|
-
* `getEventListeners`, `addAbortListener` and `EventEmitterAsyncResource`. Three module-level
|
|
408
|
-
* functions are not: `listenerCount` and `setMaxListeners` are `notImplemented` stubs that throw
|
|
409
|
-
* when called, and `getMaxListeners` throws when handed an `EventTarget`. jco-std implements those
|
|
410
|
-
* three against the core, so guests get a complete module rather than one that fails at runtime.
|
|
411
|
-
*
|
|
412
|
-
* @param eventsCoreModule - unenv's `node:events`, supplying `EventEmitter`
|
|
413
|
-
* @param eventsModule - jco-std's `completeEvents`
|
|
414
|
-
*/
|
|
415
|
-
function eventsAdapter(eventsCoreModule, eventsModule) {
|
|
416
|
-
return `
|
|
417
|
-
import { completeEvents } from ${JSON.stringify(eventsModule)};
|
|
418
|
-
import events from ${JSON.stringify(eventsCoreModule)};
|
|
419
|
-
export * from ${JSON.stringify(eventsCoreModule)};
|
|
420
|
-
const completed = completeEvents(events);
|
|
421
|
-
// Explicit exports shadow the star re-export above, replacing the stubs with the real thing.
|
|
422
|
-
export const getMaxListeners = completed.getMaxListeners;
|
|
423
|
-
export const listenerCount = completed.listenerCount;
|
|
424
|
-
export const setMaxListeners = completed.setMaxListeners;
|
|
425
|
-
// Node's module object *is* the EventEmitter class, so \`events === events.EventEmitter\` holds and
|
|
426
|
-
// every module export is also a static. Anything reaching these through the class -- or through a
|
|
427
|
-
// captured default export -- has to see the completed versions too. Defined rather than assigned:
|
|
428
|
-
// unenv exposes \`getMaxListeners\` as a getter-only accessor, so assigning to it throws.
|
|
429
|
-
for (const [name, value] of Object.entries(completed)) {
|
|
430
|
-
Object.defineProperty(events, name, { configurable: true, value, writable: true });
|
|
431
|
-
}
|
|
432
|
-
export default events;
|
|
433
|
-
`;
|
|
434
|
-
}
|
|
435
|
-
/**
|
|
436
|
-
* Source of the `node:cluster` adapter.
|
|
437
|
-
*
|
|
438
|
-
* Like `node:child_process`, the jco-std module imports the host interface itself, so the adapter
|
|
439
|
-
* only has to re-export Node's module shape.
|
|
440
|
-
*/
|
|
441
|
-
function clusterAdapter(clusterModule) {
|
|
442
|
-
return `
|
|
443
|
-
import cluster from ${JSON.stringify(clusterModule)};
|
|
444
|
-
export default cluster;
|
|
445
|
-
export {
|
|
446
|
-
SCHED_NONE,
|
|
447
|
-
SCHED_RR,
|
|
448
|
-
Worker,
|
|
449
|
-
disconnect,
|
|
450
|
-
fork,
|
|
451
|
-
setupMaster,
|
|
452
|
-
setupPrimary,
|
|
453
|
-
} from ${JSON.stringify(clusterModule)};
|
|
454
|
-
`;
|
|
455
|
-
}
|
|
456
|
-
function childProcessAdapter(childProcessModule) {
|
|
457
|
-
return `
|
|
458
|
-
import childProcess from ${JSON.stringify(childProcessModule)};
|
|
459
|
-
export default childProcess;
|
|
460
|
-
export {
|
|
461
|
-
ChildProcess,
|
|
462
|
-
exec,
|
|
463
|
-
execFile,
|
|
464
|
-
execFileSync,
|
|
465
|
-
execSync,
|
|
466
|
-
fork,
|
|
467
|
-
spawn,
|
|
468
|
-
spawnSync,
|
|
469
|
-
} from ${JSON.stringify(childProcessModule)};
|
|
470
|
-
`;
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* Source of an adapter that forwards a module's default export and re-exports its whole named
|
|
474
|
-
* surface. `localName` only names the default-import binding in the generated source.
|
|
475
|
-
*/
|
|
476
|
-
function starReexportAdapter(module, localName) {
|
|
477
|
-
return `
|
|
478
|
-
import ${localName} from ${JSON.stringify(module)};
|
|
479
|
-
export default ${localName};
|
|
480
|
-
export * from ${JSON.stringify(module)};
|
|
481
|
-
`;
|
|
482
|
-
}
|
|
483
|
-
/** Source of a capability-free Node stream submodule adapter. */
|
|
484
|
-
function streamAdapter(module) {
|
|
485
|
-
return starReexportAdapter(module, "streamModule");
|
|
486
|
-
}
|
|
487
|
-
function dnsAdapter(dnsModule) {
|
|
488
|
-
return starReexportAdapter(dnsModule, "dns");
|
|
489
|
-
}
|
|
490
|
-
/** Source of the host-backed `node:os` ESM facade. */
|
|
491
|
-
function osAdapter(osModule) {
|
|
492
|
-
return `
|
|
493
|
-
import os from ${JSON.stringify(osModule)};
|
|
494
|
-
export default os;
|
|
495
|
-
export {
|
|
496
|
-
EOL,
|
|
497
|
-
arch,
|
|
498
|
-
availableParallelism,
|
|
499
|
-
constants,
|
|
500
|
-
cpus,
|
|
501
|
-
devNull,
|
|
502
|
-
endianness,
|
|
503
|
-
freemem,
|
|
504
|
-
getPriority,
|
|
505
|
-
homedir,
|
|
506
|
-
hostname,
|
|
507
|
-
loadavg,
|
|
508
|
-
machine,
|
|
509
|
-
networkInterfaces,
|
|
510
|
-
platform,
|
|
511
|
-
release,
|
|
512
|
-
setPriority,
|
|
513
|
-
tmpdir,
|
|
514
|
-
totalmem,
|
|
515
|
-
type,
|
|
516
|
-
uptime,
|
|
517
|
-
userInfo,
|
|
518
|
-
version,
|
|
519
|
-
} from ${JSON.stringify(osModule)};
|
|
520
|
-
`;
|
|
521
|
-
}
|
|
522
|
-
/** Source of the `node:fs` and `node:fs/promises` ESM facades. */
|
|
523
|
-
function fsAdapter(specifier, fsModule, fsPromisesModule) {
|
|
524
|
-
const module = specifier === "node:fs" ? fsModule : fsPromisesModule;
|
|
525
|
-
return `
|
|
526
|
-
import fs from ${JSON.stringify(module)};
|
|
527
|
-
export * from ${JSON.stringify(module)};
|
|
528
|
-
export default fs;
|
|
529
|
-
`;
|
|
530
|
-
}
|
|
531
|
-
const HTTP_EXPORTS = [
|
|
532
|
-
"Agent",
|
|
533
|
-
"ClientRequest",
|
|
534
|
-
"CloseEvent",
|
|
535
|
-
"IncomingMessage",
|
|
536
|
-
"METHODS",
|
|
537
|
-
"MessageEvent",
|
|
538
|
-
"OutgoingMessage",
|
|
539
|
-
"STATUS_CODES",
|
|
540
|
-
"Server",
|
|
541
|
-
"ServerResponse",
|
|
542
|
-
"WebSocket",
|
|
543
|
-
"_connectionListener",
|
|
544
|
-
"createServer",
|
|
545
|
-
"get",
|
|
546
|
-
"globalAgent",
|
|
547
|
-
"maxHeaderSize",
|
|
548
|
-
"request",
|
|
549
|
-
"setGlobalProxyFromEnv",
|
|
550
|
-
"setMaxIdleHTTPParsers",
|
|
551
|
-
"validateHeaderName",
|
|
552
|
-
"validateHeaderValue",
|
|
553
|
-
];
|
|
554
|
-
function httpExports(moduleExpression) {
|
|
555
|
-
return `
|
|
556
|
-
const http = ${moduleExpression};
|
|
557
|
-
export default http;
|
|
558
|
-
export const { ${HTTP_EXPORTS.join(", ")} } = http;
|
|
559
|
-
`;
|
|
560
|
-
}
|
|
561
|
-
function httpDirectAdapter(httpModule) {
|
|
562
|
-
return `
|
|
563
|
-
import directHttp from ${JSON.stringify(httpModule)};
|
|
564
|
-
${httpExports("directHttp")}
|
|
565
|
-
`;
|
|
566
|
-
}
|
|
567
|
-
/** Source for the guest-exported HTTP callback interface used by the component entry wrapper. */
|
|
568
|
-
function httpCallbacksAdapter(httpModule) {
|
|
569
|
-
return `export { httpCallbacks } from ${JSON.stringify(httpModule)};`;
|
|
570
|
-
}
|
|
571
|
-
function httpWasiSocketsAdapter(coreModule, implementationModule, version) {
|
|
572
|
-
const schedule = version === "0.2.10" ? ", schedule: task => setTimeout(task, 0)" : "";
|
|
573
|
-
return `
|
|
574
|
-
import * as instanceNetwork from "wasi:sockets/instance-network@${version}";
|
|
575
|
-
import * as ipNameLookup from "wasi:sockets/ip-name-lookup@${version}";
|
|
576
|
-
import * as tcpCreateSocket from "wasi:sockets/tcp-create-socket@${version}";
|
|
577
|
-
import { createHttp } from ${JSON.stringify(coreModule)};
|
|
578
|
-
import { createWasiSocketsHttpImplementation } from ${JSON.stringify(implementationModule)};
|
|
579
|
-
${httpExports(`createHttp(createWasiSocketsHttpImplementation({ instanceNetwork, ipNameLookup, tcpCreateSocket, u64: value => ${version === "0.2.10" ? "BigInt(value)" : "value"}${schedule} }))`)}
|
|
580
|
-
`;
|
|
581
|
-
}
|
|
582
|
-
function httpWasiHttpAdapter(coreModule, implementationModule) {
|
|
583
|
-
return `
|
|
584
|
-
import * as outgoingHandler from "wasi:http/outgoing-handler@0.2.12";
|
|
585
|
-
import * as types from "wasi:http/types@0.2.12";
|
|
586
|
-
import { createHttp } from ${JSON.stringify(coreModule)};
|
|
587
|
-
import { createWasiHttpImplementation } from ${JSON.stringify(implementationModule)};
|
|
588
|
-
${httpExports("createHttp(createWasiHttpImplementation({ outgoingHandler, types }))")}
|
|
589
|
-
`;
|
|
590
|
-
}
|
|
591
|
-
const HTTP2_EXPORTS = [
|
|
592
|
-
"Http2ServerRequest",
|
|
593
|
-
"Http2ServerResponse",
|
|
594
|
-
"connect",
|
|
595
|
-
"constants",
|
|
596
|
-
"createSecureServer",
|
|
597
|
-
"createServer",
|
|
598
|
-
"getDefaultSettings",
|
|
599
|
-
"getPackedSettings",
|
|
600
|
-
"getUnpackedSettings",
|
|
601
|
-
"performServerHandshake",
|
|
602
|
-
"sensitiveHeaders",
|
|
603
|
-
];
|
|
604
|
-
function http2Exports(moduleExpression) {
|
|
605
|
-
return `
|
|
606
|
-
const http2 = ${moduleExpression};
|
|
607
|
-
export default http2;
|
|
608
|
-
export const { ${HTTP2_EXPORTS.join(", ")} } = http2;
|
|
609
|
-
`;
|
|
610
|
-
}
|
|
611
|
-
function http2DirectAdapter(http2Module) {
|
|
612
|
-
return `
|
|
613
|
-
import directHttp2 from ${JSON.stringify(http2Module)};
|
|
614
|
-
${http2Exports("directHttp2")}
|
|
615
|
-
`;
|
|
616
|
-
}
|
|
617
|
-
/** Source for the guest-exported HTTP/2 callback interface used by the component entry wrapper. */
|
|
618
|
-
function http2CallbacksAdapter(http2Module) {
|
|
619
|
-
return `export { http2Callbacks } from ${JSON.stringify(http2Module)};`;
|
|
620
|
-
}
|
|
621
|
-
function http2PortableAdapter(coreModule, implementationModule, via, version) {
|
|
622
|
-
const factory = via === "wasi-sockets" ? "createWasiSocketsHttp2Implementation" : "createWasiHttpHttp2Implementation";
|
|
623
|
-
const provider = via === "wasi-sockets"
|
|
624
|
-
? `
|
|
625
|
-
import * as instanceNetwork from "wasi:sockets/instance-network@${version}";
|
|
626
|
-
import * as ipNameLookup from "wasi:sockets/ip-name-lookup@${version}";
|
|
627
|
-
import * as tcpCreateSocket from "wasi:sockets/tcp-create-socket@${version}";
|
|
628
|
-
`
|
|
629
|
-
: "";
|
|
630
|
-
const factoryArguments = via === "wasi-sockets"
|
|
631
|
-
? `{ instanceNetwork, ipNameLookup, tcpCreateSocket, u64: value => ${version === "0.2.10" ? "BigInt(value)" : "value"}${version === "0.2.10" ? ", schedule: task => setTimeout(task, 0)" : ""} }`
|
|
632
|
-
: "";
|
|
633
|
-
return `
|
|
634
|
-
${provider}
|
|
635
|
-
import { createHttp2 } from ${JSON.stringify(coreModule)};
|
|
636
|
-
import { ${factory} } from ${JSON.stringify(implementationModule)};
|
|
637
|
-
${http2Exports(`createHttp2(${factory}(${factoryArguments}))`)}
|
|
638
|
-
`;
|
|
639
|
-
}
|
|
640
|
-
function requireWasiHttpVersion(worldMetadata, via, version = "0.2.12") {
|
|
641
|
-
const packageName = via === "wasi-http" ? "http" : "sockets";
|
|
642
|
-
const incompatible = (worldMetadata.imports ?? []).find((iface) => iface.namespace === "wasi" &&
|
|
643
|
-
iface.package === packageName &&
|
|
644
|
-
iface.version !== null &&
|
|
645
|
-
iface.version !== undefined &&
|
|
646
|
-
`${iface.version.major}.${iface.version.minor}.${iface.version.patch}` !== version);
|
|
647
|
-
if (incompatible) {
|
|
648
|
-
const { major, minor, patch } = incompatible.version;
|
|
649
|
-
throw new Error(`node:http via ${via} requires wasi:${packageName}@${version}, but the selected WIT world imports wasi:${packageName}@${major}.${minor}.${patch}`);
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
/**
|
|
653
|
-
* Determine the `wasi:cli/environment` version a WIT world imports.
|
|
654
|
-
*
|
|
655
|
-
* `node:path` is backed by WASI, so the world has to import the interface it needs, at exactly
|
|
656
|
-
* one version.
|
|
657
|
-
*/
|
|
658
|
-
function environmentVersion(worldMetadata) {
|
|
659
|
-
const matches = (worldMetadata?.imports ?? []).filter((iface) => iface.namespace === "wasi" &&
|
|
660
|
-
iface.package === "cli" &&
|
|
661
|
-
iface.interface === "environment" &&
|
|
662
|
-
iface.version?.major === 0n &&
|
|
663
|
-
iface.version?.minor === 2n);
|
|
664
|
-
if (matches.length === 0) {
|
|
665
|
-
throw new Error("node:path requires the selected WIT world to import wasi:cli/environment@0.2.x; add that interface to the world");
|
|
666
|
-
}
|
|
667
|
-
if (matches.length > 1) {
|
|
668
|
-
throw new Error("node:path cannot select a WASI environment adapter because the selected WIT world imports multiple wasi:cli/environment@0.2.x versions");
|
|
669
|
-
}
|
|
670
|
-
const { major, minor, patch, pre } = matches[0].version;
|
|
671
|
-
return `${major}.${minor}.${patch}${pre ? `-${pre}` : ""}`;
|
|
672
|
-
}
|
|
673
|
-
/** Source of the shared `node:path` core, which owns the single WASI-backed path instance */
|
|
674
|
-
function pathCore(version, factoryPath) {
|
|
675
|
-
return `
|
|
676
|
-
import { initialCwd, getEnvironment } from "wasi:cli/environment@${version}";
|
|
677
|
-
import { createPath } from ${JSON.stringify(factoryPath)};
|
|
678
|
-
export const portablePath = createPath({ initialCwd, getEnvironment });
|
|
679
|
-
`;
|
|
680
|
-
}
|
|
681
|
-
/** Source of a `node:path`, `node:path/posix`, or `node:path/win32` adapter */
|
|
682
|
-
function pathAdapter(specifier, version) {
|
|
683
|
-
const namespace = PATH_SPECIFIERS.get(specifier);
|
|
684
|
-
return `
|
|
685
|
-
import { portablePath } from ${JSON.stringify(`${VIRTUAL_PREFIX}path-core@${version}`)};
|
|
686
|
-
const path = ${namespace === "default" ? "portablePath" : `portablePath.${namespace}`};
|
|
687
|
-
export default path;
|
|
688
|
-
export const _makeLong = path._makeLong;
|
|
689
|
-
export const basename = path.basename;
|
|
690
|
-
export const delimiter = path.delimiter;
|
|
691
|
-
export const dirname = path.dirname;
|
|
692
|
-
export const extname = path.extname;
|
|
693
|
-
export const format = path.format;
|
|
694
|
-
export const matchesGlob = path.matchesGlob;
|
|
695
|
-
export const isAbsolute = path.isAbsolute;
|
|
696
|
-
export const join = path.join;
|
|
697
|
-
export const normalize = path.normalize;
|
|
698
|
-
export const parse = path.parse;
|
|
699
|
-
export const posix = path.posix;
|
|
700
|
-
export const relative = path.relative;
|
|
701
|
-
export const resolve = path.resolve;
|
|
702
|
-
export const sep = path.sep;
|
|
703
|
-
export const toNamespacedPath = path.toNamespacedPath;
|
|
704
|
-
export const win32 = path.win32;
|
|
705
|
-
`;
|
|
706
|
-
}
|
|
707
|
-
/** Source of the `node:console` ESM facade. */
|
|
708
|
-
function consoleAdapter(consoleModule) {
|
|
709
|
-
return `
|
|
710
|
-
import console from ${JSON.stringify(consoleModule)};
|
|
711
|
-
export default console;
|
|
712
|
-
export {
|
|
713
|
-
Console,
|
|
714
|
-
assert,
|
|
715
|
-
clear,
|
|
716
|
-
count,
|
|
717
|
-
countReset,
|
|
718
|
-
debug,
|
|
719
|
-
dir,
|
|
720
|
-
dirxml,
|
|
721
|
-
error,
|
|
722
|
-
group,
|
|
723
|
-
groupCollapsed,
|
|
724
|
-
groupEnd,
|
|
725
|
-
info,
|
|
726
|
-
log,
|
|
727
|
-
profile,
|
|
728
|
-
profileEnd,
|
|
729
|
-
table,
|
|
730
|
-
time,
|
|
731
|
-
timeEnd,
|
|
732
|
-
timeLog,
|
|
733
|
-
timeStamp,
|
|
734
|
-
trace,
|
|
735
|
-
warn,
|
|
736
|
-
} from ${JSON.stringify(consoleModule)};
|
|
737
|
-
`;
|
|
738
|
-
}
|
|
739
|
-
/** Source of a `node:assert` or `node:assert/strict` adapter */
|
|
740
|
-
function assertAdapter(specifier, assertModule) {
|
|
741
|
-
if (specifier === "node:assert") {
|
|
742
|
-
return `
|
|
743
|
-
import assert from ${JSON.stringify(assertModule)};
|
|
744
|
-
export default assert;
|
|
745
|
-
export {
|
|
746
|
-
Assert,
|
|
747
|
-
AssertionError,
|
|
748
|
-
CallTracker,
|
|
749
|
-
deepEqual,
|
|
750
|
-
deepStrictEqual,
|
|
751
|
-
doesNotMatch,
|
|
752
|
-
doesNotReject,
|
|
753
|
-
doesNotThrow,
|
|
754
|
-
equal,
|
|
755
|
-
fail,
|
|
756
|
-
ifError,
|
|
757
|
-
match,
|
|
758
|
-
notDeepEqual,
|
|
759
|
-
notDeepStrictEqual,
|
|
760
|
-
notEqual,
|
|
761
|
-
notStrictEqual,
|
|
762
|
-
ok,
|
|
763
|
-
partialDeepStrictEqual,
|
|
764
|
-
rejects,
|
|
765
|
-
strict,
|
|
766
|
-
strictEqual,
|
|
767
|
-
throws,
|
|
768
|
-
} from ${JSON.stringify(assertModule)};
|
|
769
|
-
`;
|
|
770
|
-
}
|
|
771
|
-
return `
|
|
772
|
-
import { strict } from ${JSON.stringify(assertModule)};
|
|
773
|
-
export default strict;
|
|
774
|
-
export const Assert = strict.Assert;
|
|
775
|
-
export const AssertionError = strict.AssertionError;
|
|
776
|
-
export const CallTracker = strict.CallTracker;
|
|
777
|
-
export const deepEqual = strict.deepEqual;
|
|
778
|
-
export const deepStrictEqual = strict.deepStrictEqual;
|
|
779
|
-
export const doesNotMatch = strict.doesNotMatch;
|
|
780
|
-
export const doesNotReject = strict.doesNotReject;
|
|
781
|
-
export const doesNotThrow = strict.doesNotThrow;
|
|
782
|
-
export const equal = strict.equal;
|
|
783
|
-
export const fail = strict.fail;
|
|
784
|
-
export const ifError = strict.ifError;
|
|
785
|
-
export const match = strict.match;
|
|
786
|
-
export const notDeepEqual = strict.notDeepEqual;
|
|
787
|
-
export const notDeepStrictEqual = strict.notDeepStrictEqual;
|
|
788
|
-
export const notEqual = strict.notEqual;
|
|
789
|
-
export const notStrictEqual = strict.notStrictEqual;
|
|
790
|
-
export const ok = strict.ok;
|
|
791
|
-
export const partialDeepStrictEqual = strict.partialDeepStrictEqual;
|
|
792
|
-
export const rejects = strict.rejects;
|
|
793
|
-
export { strict };
|
|
794
|
-
export const strictEqual = strict.strictEqual;
|
|
795
|
-
export const throws = strict.throws;
|
|
796
|
-
`;
|
|
797
|
-
}
|
|
798
|
-
/** Create Jco's virtual adapters for supported Node builtins. */
|
|
799
|
-
export function nodeBuiltinPlugin(worldMetadata, options = {}) {
|
|
800
|
-
// NOTE: jco-std namespaces these by the WASI version they adapt Node to and then by the
|
|
801
|
-
// Node major: `wasi/0.2.x/node/24.x.x/*`. Both axes move independently -- Node's builtin
|
|
802
|
-
// semantics change across majors, and the same module adapted to WASI p3 is a different
|
|
803
|
-
// implementation -- so both are pinned here rather than resolved through an unversioned
|
|
804
|
-
// alias. Selecting either at build time, or detecting them, is future work.
|
|
805
|
-
// Resolve a jco-std module under `wasi/0.2.x/node/<major>.x.x/<subpath>` unless a test override
|
|
806
|
-
// is supplied. Resolution stays lazy (a thunk) so nothing touches the package until a builtin
|
|
807
|
-
// is actually bundled.
|
|
808
|
-
const stdModule = (override, subpath, major = "24.x.x") => override ?? fileURLToPath(import.meta.resolve(`@bytecodealliance/jco-std/wasi/0.2.x/node/${major}/${subpath}`));
|
|
809
|
-
const pathFactory = () => stdModule(options.pathFactory, "path");
|
|
810
|
-
const assertModule = () => stdModule(options.assertModule, "assert");
|
|
811
|
-
const moduleModule = () => stdModule(options.moduleModule, "module");
|
|
812
|
-
// NOTE: `node:ffi` resolves under `node/26.x.x`, not 24: it does not exist in Node 24. This is
|
|
813
|
-
// the first place the Node major in the path differs per module rather than per build.
|
|
814
|
-
const ffiModule = () => stdModule(options.ffiModule, "ffi", "26.x.x");
|
|
815
|
-
const inspectorModule = () => stdModule(options.inspectorModule, "inspector");
|
|
816
|
-
const inspectorPromisesModule = () => stdModule(options.inspectorPromisesModule, "inspector/promises");
|
|
817
|
-
const domainModule = () => stdModule(options.domainModule, "domain");
|
|
818
|
-
const diagnosticsChannelModule = () => stdModule(options.diagnosticsChannelModule, "diagnostics-channel");
|
|
819
|
-
const asyncHooksModule = () => stdModule(options.asyncHooksModule, "async-hooks");
|
|
820
|
-
const eventsModule = () => stdModule(options.eventsModule, "events");
|
|
821
|
-
const osModule = () => stdModule(options.osModule, "os");
|
|
822
|
-
const stringDecoderModule = () => stdModule(options.stringDecoderModule, "string-decoder");
|
|
823
|
-
const streamConsumersModule = () => stdModule(options.streamConsumersModule, "stream/consumers");
|
|
824
|
-
const streamIterModule = () => stdModule(options.streamIterModule, "stream/iter");
|
|
825
|
-
const clusterModule = () => stdModule(options.clusterModule, "cluster");
|
|
826
|
-
const childProcessModule = () => stdModule(options.childProcessModule, "child-process");
|
|
827
|
-
const consoleModule = () => stdModule(options.consoleModule, "console");
|
|
828
|
-
const fsModule = () => stdModule(options.fsModule, "fs");
|
|
829
|
-
const fsPromisesModule = () => stdModule(options.fsPromisesModule, "fs/promises");
|
|
830
|
-
const errorsModule = () => stdModule(options.errorsModule, "errors");
|
|
831
|
-
const abortGlobalsModule = () => stdModule(options.abortGlobalsModule, "abort-globals");
|
|
832
|
-
const dnsModule = (specifier) => specifier === "node:dns/promises"
|
|
833
|
-
? stdModule(options.dnsPromisesModule, "dns/promises")
|
|
834
|
-
: stdModule(options.dnsModule, "dns");
|
|
835
|
-
const httpModule = () => stdModule(options.httpModule, "http");
|
|
836
|
-
const httpCoreModule = () => stdModule(options.httpCoreModule, "http/core");
|
|
837
|
-
const httpWasiSocketsImplementationModule = () => stdModule(options.httpWasiSocketsImplementationModule, "http/impl/wasi-sockets");
|
|
838
|
-
const httpWasiHttpImplementationModule = () => stdModule(options.httpWasiHttpImplementationModule, "http/impl/wasi-http");
|
|
839
|
-
const httpVia = options.nodejsHttpVia ?? "direct";
|
|
840
|
-
const wasiSocketsVersion = options.wasiSocketsVersion ?? "0.2.12";
|
|
841
|
-
const http2Module = () => options.http2Module ??
|
|
842
|
-
fileURLToPath(import.meta.resolve("@bytecodealliance/jco-std/wasi/0.2.x/node/24.x.x/http2"));
|
|
843
|
-
const http2CoreModule = () => options.http2CoreModule ??
|
|
844
|
-
fileURLToPath(import.meta.resolve("@bytecodealliance/jco-std/wasi/0.2.x/node/24.x.x/http2/core"));
|
|
845
|
-
const http2WasiSocketsImplementationModule = () => options.http2WasiSocketsImplementationModule ??
|
|
846
|
-
fileURLToPath(import.meta.resolve("@bytecodealliance/jco-std/wasi/0.2.x/node/24.x.x/http2/impl/wasi-sockets"));
|
|
847
|
-
const http2WasiHttpImplementationModule = () => options.http2WasiHttpImplementationModule ??
|
|
848
|
-
fileURLToPath(import.meta.resolve("@bytecodealliance/jco-std/wasi/0.2.x/node/24.x.x/http2/impl/wasi-http"));
|
|
849
|
-
const http2Via = options.nodejsHttp2Via ?? "direct";
|
|
850
|
-
return {
|
|
851
|
-
name: "jco-node-builtins",
|
|
852
|
-
resolveId(id) {
|
|
853
|
-
if (id.startsWith(VIRTUAL_PREFIX)) {
|
|
854
|
-
return id;
|
|
855
|
-
}
|
|
856
|
-
if (id === ABORT_GLOBALS_SPECIFIER) {
|
|
857
|
-
return ABORT_GLOBALS_MODULE;
|
|
858
|
-
}
|
|
859
|
-
if (id === ERROR_GLOBALS_SPECIFIER) {
|
|
860
|
-
return ERROR_GLOBALS_MODULE;
|
|
861
|
-
}
|
|
862
|
-
if (id === HTTP_CALLBACKS_SPECIFIER) {
|
|
863
|
-
return HTTP_CALLBACKS_MODULE;
|
|
864
|
-
}
|
|
865
|
-
if (id === HTTP2_CALLBACKS_SPECIFIER) {
|
|
866
|
-
return HTTP2_CALLBACKS_MODULE;
|
|
867
|
-
}
|
|
868
|
-
if (ASSERT_SPECIFIERS.has(id)) {
|
|
869
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
870
|
-
}
|
|
871
|
-
if (id === MODULE_SPECIFIER) {
|
|
872
|
-
// No onWitRequirement: classification and source-map arithmetic need no host, and
|
|
873
|
-
// the loading half is unimplementable rather than unprovisioned.
|
|
874
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
875
|
-
}
|
|
876
|
-
if (id === FFI_SPECIFIER) {
|
|
877
|
-
options.onWitRequirement?.(FFI_WIT_REQUIREMENT);
|
|
878
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
879
|
-
}
|
|
880
|
-
if (id === INSPECTOR_CALLBACKS_SPECIFIER) {
|
|
881
|
-
// The two-pass wrapper's import of the guest-exported callbacks interface.
|
|
882
|
-
return INSPECTOR_CALLBACKS_MODULE;
|
|
883
|
-
}
|
|
884
|
-
if (INSPECTOR_SPECIFIERS.has(id)) {
|
|
885
|
-
options.onWitRequirement?.(id === INSPECTOR_PROMISES_SPECIFIER
|
|
886
|
-
? INSPECTOR_PROMISES_WIT_REQUIREMENT
|
|
887
|
-
: INSPECTOR_WIT_REQUIREMENT);
|
|
888
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
889
|
-
}
|
|
890
|
-
if (id === DOMAIN_SPECIFIER) {
|
|
891
|
-
// No onWitRequirement: nothing here reaches the host.
|
|
892
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
893
|
-
}
|
|
894
|
-
if (id === DIAGNOSTICS_CHANNEL_SPECIFIER) {
|
|
895
|
-
// No onWitRequirement: this needs no host capability.
|
|
896
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
897
|
-
}
|
|
898
|
-
if (id === ASYNC_HOOKS_SPECIFIER) {
|
|
899
|
-
// No onWitRequirement: this needs no host capability.
|
|
900
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
901
|
-
}
|
|
902
|
-
if (id === EVENTS_SPECIFIER) {
|
|
903
|
-
// No onWitRequirement: in-process emitters need no host capability.
|
|
904
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
905
|
-
}
|
|
906
|
-
if (id === OS_SPECIFIER) {
|
|
907
|
-
options.onWitRequirement?.(OS_WIT_REQUIREMENT);
|
|
908
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
909
|
-
}
|
|
910
|
-
if (id === STRING_DECODER_SPECIFIER) {
|
|
911
|
-
// No onWitRequirement: decoding and incomplete-byte state stay in the guest.
|
|
912
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
913
|
-
}
|
|
914
|
-
if (id === STREAM_CONSUMERS_SPECIFIER || id === STREAM_ITER_SPECIFIER) {
|
|
915
|
-
// No onWitRequirement: iterable streams are entirely guest-side.
|
|
916
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
917
|
-
}
|
|
918
|
-
if (id === CLUSTER_SPECIFIER) {
|
|
919
|
-
options.onWitRequirement?.(CLUSTER_WIT_REQUIREMENT);
|
|
920
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
921
|
-
}
|
|
922
|
-
if (id === CHILD_PROCESS_SPECIFIER) {
|
|
923
|
-
options.onWitRequirement?.(CHILD_PROCESS_WIT_REQUIREMENT);
|
|
924
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
925
|
-
}
|
|
926
|
-
if (PATH_SPECIFIERS.has(id)) {
|
|
927
|
-
const version = environmentVersion(worldMetadata);
|
|
928
|
-
return `${VIRTUAL_PREFIX}${id}@${version}`;
|
|
929
|
-
}
|
|
930
|
-
if (id === CONSOLE_SPECIFIER) {
|
|
931
|
-
options.onWitRequirement?.(CONSOLE_WIT_REQUIREMENT);
|
|
932
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
933
|
-
}
|
|
934
|
-
if (DNS_SPECIFIERS.has(id)) {
|
|
935
|
-
options.onWitRequirement?.(id === "node:dns/promises" ? DNS_PROMISES_WIT_REQUIREMENT : DNS_WIT_REQUIREMENT);
|
|
936
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
937
|
-
}
|
|
938
|
-
if (FS_SPECIFIERS.has(id)) {
|
|
939
|
-
options.onWitRequirement?.(FS_WIT_REQUIREMENT);
|
|
940
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
941
|
-
}
|
|
942
|
-
if (id === HTTP_SPECIFIER) {
|
|
943
|
-
if (httpVia === "direct") {
|
|
944
|
-
options.onWitRequirement?.(HTTP_WIT_REQUIREMENT);
|
|
945
|
-
}
|
|
946
|
-
else {
|
|
947
|
-
requireWasiHttpVersion(worldMetadata, httpVia, httpVia === "wasi-sockets" ? wasiSocketsVersion : "0.2.12");
|
|
948
|
-
const requirements = httpVia === "wasi-sockets"
|
|
949
|
-
? wasiSocketsVersion === "0.2.12"
|
|
950
|
-
? HTTP_WASI_SOCKETS_WIT_REQUIREMENTS
|
|
951
|
-
: HTTP_WASI_SOCKETS_0_2_10_WIT_REQUIREMENTS
|
|
952
|
-
: HTTP_WASI_HTTP_WIT_REQUIREMENTS;
|
|
953
|
-
for (const requirement of requirements) {
|
|
954
|
-
options.onWitRequirement?.(requirement);
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
958
|
-
}
|
|
959
|
-
if (id === HTTP2_SPECIFIER) {
|
|
960
|
-
if (http2Via === "direct") {
|
|
961
|
-
options.onWitRequirement?.(HTTP2_WIT_REQUIREMENT);
|
|
962
|
-
}
|
|
963
|
-
else if (http2Via === "wasi-sockets") {
|
|
964
|
-
requireWasiHttpVersion(worldMetadata, http2Via, wasiSocketsVersion);
|
|
965
|
-
for (const requirement of wasiSocketsVersion === "0.2.12"
|
|
966
|
-
? HTTP_WASI_SOCKETS_WIT_REQUIREMENTS
|
|
967
|
-
: HTTP_WASI_SOCKETS_0_2_10_WIT_REQUIREMENTS) {
|
|
968
|
-
options.onWitRequirement?.(requirement);
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
972
|
-
}
|
|
973
|
-
if (AUDITED_UNENV_SPECIFIERS.has(id)) {
|
|
974
|
-
unenvAdapter(id, options);
|
|
975
|
-
return `${VIRTUAL_PREFIX}${id}`;
|
|
976
|
-
}
|
|
977
|
-
return null;
|
|
978
|
-
},
|
|
979
|
-
load(id) {
|
|
980
|
-
if (!id.startsWith(VIRTUAL_PREFIX)) {
|
|
981
|
-
return null;
|
|
982
|
-
}
|
|
983
|
-
const value = id.slice(VIRTUAL_PREFIX.length);
|
|
984
|
-
if (id === UNENV_BUFFER_CORE) {
|
|
985
|
-
return unenvBufferCore(options);
|
|
986
|
-
}
|
|
987
|
-
if (id === ABORT_GLOBALS_MODULE) {
|
|
988
|
-
return `export * from ${JSON.stringify(abortGlobalsModule())};`;
|
|
989
|
-
}
|
|
990
|
-
if (id === ERROR_GLOBALS_MODULE) {
|
|
991
|
-
return `export * from ${JSON.stringify(errorsModule())};`;
|
|
992
|
-
}
|
|
993
|
-
if (id === HTTP_CALLBACKS_MODULE) {
|
|
994
|
-
return httpCallbacksAdapter(httpModule());
|
|
995
|
-
}
|
|
996
|
-
if (id === HTTP2_CALLBACKS_MODULE) {
|
|
997
|
-
return http2CallbacksAdapter(http2Module());
|
|
998
|
-
}
|
|
999
|
-
if (ASSERT_SPECIFIERS.has(value)) {
|
|
1000
|
-
return assertAdapter(value, assertModule());
|
|
1001
|
-
}
|
|
1002
|
-
if (value === MODULE_SPECIFIER) {
|
|
1003
|
-
return moduleAdapter(moduleModule());
|
|
1004
|
-
}
|
|
1005
|
-
if (value === FFI_SPECIFIER) {
|
|
1006
|
-
return ffiAdapter(ffiModule());
|
|
1007
|
-
}
|
|
1008
|
-
if (id === INSPECTOR_CALLBACKS_MODULE) {
|
|
1009
|
-
return inspectorCallbacksAdapter(inspectorModule());
|
|
1010
|
-
}
|
|
1011
|
-
if (value === INSPECTOR_PROMISES_SPECIFIER) {
|
|
1012
|
-
return inspectorPromisesAdapter(inspectorPromisesModule());
|
|
1013
|
-
}
|
|
1014
|
-
if (value === INSPECTOR_SPECIFIER) {
|
|
1015
|
-
return inspectorAdapter(inspectorModule());
|
|
1016
|
-
}
|
|
1017
|
-
if (value === DOMAIN_SPECIFIER) {
|
|
1018
|
-
return domainAdapter(domainModule());
|
|
1019
|
-
}
|
|
1020
|
-
if (value === DIAGNOSTICS_CHANNEL_SPECIFIER) {
|
|
1021
|
-
return diagnosticsChannelAdapter(diagnosticsChannelModule());
|
|
1022
|
-
}
|
|
1023
|
-
if (value === ASYNC_HOOKS_SPECIFIER) {
|
|
1024
|
-
return asyncHooksAdapter(asyncHooksModule());
|
|
1025
|
-
}
|
|
1026
|
-
if (value === EVENTS_SPECIFIER) {
|
|
1027
|
-
return eventsAdapter(unenvModule(EVENTS_SPECIFIER, options), eventsModule());
|
|
1028
|
-
}
|
|
1029
|
-
if (value === OS_SPECIFIER) {
|
|
1030
|
-
return osAdapter(osModule());
|
|
1031
|
-
}
|
|
1032
|
-
if (value === STRING_DECODER_SPECIFIER) {
|
|
1033
|
-
return stringDecoderAdapter(stringDecoderModule());
|
|
1034
|
-
}
|
|
1035
|
-
if (value === STREAM_CONSUMERS_SPECIFIER) {
|
|
1036
|
-
return streamAdapter(streamConsumersModule());
|
|
1037
|
-
}
|
|
1038
|
-
if (value === STREAM_ITER_SPECIFIER) {
|
|
1039
|
-
return streamAdapter(streamIterModule());
|
|
1040
|
-
}
|
|
1041
|
-
if (value === CLUSTER_SPECIFIER) {
|
|
1042
|
-
return clusterAdapter(clusterModule());
|
|
1043
|
-
}
|
|
1044
|
-
if (value === CHILD_PROCESS_SPECIFIER) {
|
|
1045
|
-
return childProcessAdapter(childProcessModule());
|
|
1046
|
-
}
|
|
1047
|
-
if (value === CONSOLE_SPECIFIER) {
|
|
1048
|
-
return consoleAdapter(consoleModule());
|
|
1049
|
-
}
|
|
1050
|
-
if (DNS_SPECIFIERS.has(value)) {
|
|
1051
|
-
return dnsAdapter(dnsModule(value));
|
|
1052
|
-
}
|
|
1053
|
-
if (FS_SPECIFIERS.has(value)) {
|
|
1054
|
-
return fsAdapter(value, fsModule(), fsPromisesModule());
|
|
1055
|
-
}
|
|
1056
|
-
if (value === HTTP_SPECIFIER) {
|
|
1057
|
-
if (httpVia === "direct") {
|
|
1058
|
-
return httpDirectAdapter(httpModule());
|
|
1059
|
-
}
|
|
1060
|
-
return httpVia === "wasi-sockets"
|
|
1061
|
-
? httpWasiSocketsAdapter(httpCoreModule(), httpWasiSocketsImplementationModule(), wasiSocketsVersion)
|
|
1062
|
-
: httpWasiHttpAdapter(httpCoreModule(), httpWasiHttpImplementationModule());
|
|
1063
|
-
}
|
|
1064
|
-
if (value === HTTP2_SPECIFIER) {
|
|
1065
|
-
if (http2Via === "direct") {
|
|
1066
|
-
return http2DirectAdapter(http2Module());
|
|
1067
|
-
}
|
|
1068
|
-
return http2PortableAdapter(http2CoreModule(), http2Via === "wasi-sockets"
|
|
1069
|
-
? http2WasiSocketsImplementationModule()
|
|
1070
|
-
: http2WasiHttpImplementationModule(), http2Via, wasiSocketsVersion);
|
|
1071
|
-
}
|
|
1072
|
-
if (AUDITED_UNENV_SPECIFIERS.has(value)) {
|
|
1073
|
-
return unenvAdapter(value, options);
|
|
1074
|
-
}
|
|
1075
|
-
const separator = value.lastIndexOf("@");
|
|
1076
|
-
const specifier = value.slice(0, separator);
|
|
1077
|
-
const version = value.slice(separator + 1);
|
|
1078
|
-
if (specifier === "path-core") {
|
|
1079
|
-
return pathCore(version, pathFactory());
|
|
1080
|
-
}
|
|
1081
|
-
return pathAdapter(specifier, version);
|
|
1082
|
-
},
|
|
1083
|
-
};
|
|
1084
|
-
}
|
|
1085
|
-
//# sourceMappingURL=node-builtins.js.map
|