@volter/tabnode 0.2.14-volter.88
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/LICENSE +22 -0
- package/README.md +78 -0
- package/THIRD-PARTY-NOTICES.md +12 -0
- package/dist/__sw__.js +526 -0
- package/dist/assets/runtime-worker-4MKaHFVb.js +75221 -0
- package/dist/assets/runtime-worker-4MKaHFVb.js.map +1 -0
- package/dist/code-transforms.d.ts +21 -0
- package/dist/code-transforms.d.ts.map +1 -0
- package/dist/config/cdn.d.ts +12 -0
- package/dist/config/cdn.d.ts.map +1 -0
- package/dist/create-runtime.d.ts +22 -0
- package/dist/create-runtime.d.ts.map +1 -0
- package/dist/host-globals.d.ts +62 -0
- package/dist/host-globals.d.ts.map +1 -0
- package/dist/index.cjs +36021 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +127 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +36020 -0
- package/dist/index.mjs.map +1 -0
- package/dist/node-internals.d.ts +68 -0
- package/dist/node-internals.d.ts.map +1 -0
- package/dist/node-lib/binding/blob.d.ts +12 -0
- package/dist/node-lib/binding/blob.d.ts.map +1 -0
- package/dist/node-lib/binding/buffer.d.ts +144 -0
- package/dist/node-lib/binding/buffer.d.ts.map +1 -0
- package/dist/node-lib/binding/cares_wrap.d.ts +14 -0
- package/dist/node-lib/binding/cares_wrap.d.ts.map +1 -0
- package/dist/node-lib/binding/fds.d.ts +30 -0
- package/dist/node-lib/binding/fds.d.ts.map +1 -0
- package/dist/node-lib/binding/fs.d.ts +157 -0
- package/dist/node-lib/binding/fs.d.ts.map +1 -0
- package/dist/node-lib/binding/handles.d.ts +81 -0
- package/dist/node-lib/binding/handles.d.ts.map +1 -0
- package/dist/node-lib/binding/http_parser.d.ts +122 -0
- package/dist/node-lib/binding/http_parser.d.ts.map +1 -0
- package/dist/node-lib/binding/index.d.ts +3 -0
- package/dist/node-lib/binding/index.d.ts.map +1 -0
- package/dist/node-lib/binding/llhttp-wasm.d.ts +22 -0
- package/dist/node-lib/binding/llhttp-wasm.d.ts.map +1 -0
- package/dist/node-lib/binding/misc.d.ts +123 -0
- package/dist/node-lib/binding/misc.d.ts.map +1 -0
- package/dist/node-lib/binding/pipe_wrap.d.ts +84 -0
- package/dist/node-lib/binding/pipe_wrap.d.ts.map +1 -0
- package/dist/node-lib/binding/process_wrap.d.ts +173 -0
- package/dist/node-lib/binding/process_wrap.d.ts.map +1 -0
- package/dist/node-lib/binding/spawn_sync.d.ts +30 -0
- package/dist/node-lib/binding/spawn_sync.d.ts.map +1 -0
- package/dist/node-lib/binding/stream_wrap.d.ts +191 -0
- package/dist/node-lib/binding/stream_wrap.d.ts.map +1 -0
- package/dist/node-lib/binding/stubs.d.ts +23 -0
- package/dist/node-lib/binding/stubs.d.ts.map +1 -0
- package/dist/node-lib/binding/tcp_wrap.d.ts +98 -0
- package/dist/node-lib/binding/tcp_wrap.d.ts.map +1 -0
- package/dist/node-lib/binding/tty_wrap.d.ts +36 -0
- package/dist/node-lib/binding/tty_wrap.d.ts.map +1 -0
- package/dist/node-lib/binding/util.d.ts +126 -0
- package/dist/node-lib/binding/util.d.ts.map +1 -0
- package/dist/node-lib/binding/uv.d.ts +32 -0
- package/dist/node-lib/binding/uv.d.ts.map +1 -0
- package/dist/node-lib/binding/zlib-pako.d.ts +22 -0
- package/dist/node-lib/binding/zlib-pako.d.ts.map +1 -0
- package/dist/node-lib/binding/zlib.d.ts +38 -0
- package/dist/node-lib/binding/zlib.d.ts.map +1 -0
- package/dist/node-lib/buffer-module.d.ts +51 -0
- package/dist/node-lib/buffer-module.d.ts.map +1 -0
- package/dist/node-lib/child-process-module.d.ts +26 -0
- package/dist/node-lib/child-process-module.d.ts.map +1 -0
- package/dist/node-lib/events-module.d.ts +58 -0
- package/dist/node-lib/events-module.d.ts.map +1 -0
- package/dist/node-lib/fs-module.d.ts +5 -0
- package/dist/node-lib/fs-module.d.ts.map +1 -0
- package/dist/node-lib/http-bridge.d.ts +43 -0
- package/dist/node-lib/http-bridge.d.ts.map +1 -0
- package/dist/node-lib/http-module.d.ts +35 -0
- package/dist/node-lib/http-module.d.ts.map +1 -0
- package/dist/node-lib/internals/addresses.d.ts +40 -0
- package/dist/node-lib/internals/addresses.d.ts.map +1 -0
- package/dist/node-lib/internals/buffer-and-streams.d.ts +96 -0
- package/dist/node-lib/internals/buffer-and-streams.d.ts.map +1 -0
- package/dist/node-lib/internals/child-process.d.ts +27 -0
- package/dist/node-lib/internals/child-process.d.ts.map +1 -0
- package/dist/node-lib/internals/events-util.d.ts +83 -0
- package/dist/node-lib/internals/events-util.d.ts.map +1 -0
- package/dist/node-lib/internals/index.d.ts +2 -0
- package/dist/node-lib/internals/index.d.ts.map +1 -0
- package/dist/node-lib/internals/modules.d.ts +67 -0
- package/dist/node-lib/internals/modules.d.ts.map +1 -0
- package/dist/node-lib/internals/readline-access.d.ts +2 -0
- package/dist/node-lib/internals/readline-access.d.ts.map +1 -0
- package/dist/node-lib/internals/runtime.d.ts +150 -0
- package/dist/node-lib/internals/runtime.d.ts.map +1 -0
- package/dist/node-lib/internals/util.d.ts +33 -0
- package/dist/node-lib/internals/util.d.ts.map +1 -0
- package/dist/node-lib/lazy.d.ts +31 -0
- package/dist/node-lib/lazy.d.ts.map +1 -0
- package/dist/node-lib/load.d.ts +27 -0
- package/dist/node-lib/load.d.ts.map +1 -0
- package/dist/node-lib/module-hooks.d.ts +89 -0
- package/dist/node-lib/module-hooks.d.ts.map +1 -0
- package/dist/node-lib/net-module.d.ts +181 -0
- package/dist/node-lib/net-module.d.ts.map +1 -0
- package/dist/node-lib/node-versions.d.ts +27 -0
- package/dist/node-lib/node-versions.d.ts.map +1 -0
- package/dist/node-lib/public-modules.d.ts +2 -0
- package/dist/node-lib/public-modules.d.ts.map +1 -0
- package/dist/node-lib/require-hook.d.ts +15 -0
- package/dist/node-lib/require-hook.d.ts.map +1 -0
- package/dist/node-lib/small-modules.d.ts +16 -0
- package/dist/node-lib/small-modules.d.ts.map +1 -0
- package/dist/node-lib/sources.d.ts +4 -0
- package/dist/node-lib/sources.d.ts.map +1 -0
- package/dist/node-lib/stream-module.d.ts +77 -0
- package/dist/node-lib/stream-module.d.ts.map +1 -0
- package/dist/node-lib/timers.d.ts +19 -0
- package/dist/node-lib/timers.d.ts.map +1 -0
- package/dist/node-lib/util-module.d.ts +76 -0
- package/dist/node-lib/util-module.d.ts.map +1 -0
- package/dist/node-resolution.d.ts +50 -0
- package/dist/node-resolution.d.ts.map +1 -0
- package/dist/node-resolver.d.ts +7 -0
- package/dist/node-resolver.d.ts.map +1 -0
- package/dist/npm/index.d.ts +73 -0
- package/dist/npm/index.d.ts.map +1 -0
- package/dist/npm/registry.d.ts +111 -0
- package/dist/npm/registry.d.ts.map +1 -0
- package/dist/npm/resolver.d.ts +79 -0
- package/dist/npm/resolver.d.ts.map +1 -0
- package/dist/npm/tarball.d.ts +28 -0
- package/dist/npm/tarball.d.ts.map +1 -0
- package/dist/process-tokens.d.ts +77 -0
- package/dist/process-tokens.d.ts.map +1 -0
- package/dist/punycode-source.d.ts +3 -0
- package/dist/punycode-source.d.ts.map +1 -0
- package/dist/runtime-interface.d.ts +74 -0
- package/dist/runtime-interface.d.ts.map +1 -0
- package/dist/runtime.d.ts +144 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/server-bridge.d.ts +147 -0
- package/dist/server-bridge.d.ts.map +1 -0
- package/dist/shims/async_hooks.d.ts +50 -0
- package/dist/shims/async_hooks.d.ts.map +1 -0
- package/dist/shims/child_process.d.ts +104 -0
- package/dist/shims/child_process.d.ts.map +1 -0
- package/dist/shims/cluster.d.ts +52 -0
- package/dist/shims/cluster.d.ts.map +1 -0
- package/dist/shims/command-line.d.ts +43 -0
- package/dist/shims/command-line.d.ts.map +1 -0
- package/dist/shims/constants.d.ts +222 -0
- package/dist/shims/constants.d.ts.map +1 -0
- package/dist/shims/crypto-constants.d.ts +12 -0
- package/dist/shims/crypto-constants.d.ts.map +1 -0
- package/dist/shims/crypto.d.ts +144 -0
- package/dist/shims/crypto.d.ts.map +1 -0
- package/dist/shims/dgram.d.ts +34 -0
- package/dist/shims/dgram.d.ts.map +1 -0
- package/dist/shims/dns.d.ts +91 -0
- package/dist/shims/dns.d.ts.map +1 -0
- package/dist/shims/domain.d.ts +25 -0
- package/dist/shims/domain.d.ts.map +1 -0
- package/dist/shims/esbuild.d.ts +205 -0
- package/dist/shims/esbuild.d.ts.map +1 -0
- package/dist/shims/fs.d.ts +25 -0
- package/dist/shims/fs.d.ts.map +1 -0
- package/dist/shims/http2.d.ts +81 -0
- package/dist/shims/http2.d.ts.map +1 -0
- package/dist/shims/inspector.d.ts +25 -0
- package/dist/shims/inspector.d.ts.map +1 -0
- package/dist/shims/module.d.ts +22 -0
- package/dist/shims/module.d.ts.map +1 -0
- package/dist/shims/os.d.ts +159 -0
- package/dist/shims/os.d.ts.map +1 -0
- package/dist/shims/path.d.ts +52 -0
- package/dist/shims/path.d.ts.map +1 -0
- package/dist/shims/perf_hooks.d.ts +50 -0
- package/dist/shims/perf_hooks.d.ts.map +1 -0
- package/dist/shims/process.d.ts +226 -0
- package/dist/shims/process.d.ts.map +1 -0
- package/dist/shims/rollup.d.ts +71 -0
- package/dist/shims/rollup.d.ts.map +1 -0
- package/dist/shims/string_decoder.d.ts +41 -0
- package/dist/shims/string_decoder.d.ts.map +1 -0
- package/dist/shims/sync-child.d.ts +64 -0
- package/dist/shims/sync-child.d.ts.map +1 -0
- package/dist/shims/tls.d.ts +53 -0
- package/dist/shims/tls.d.ts.map +1 -0
- package/dist/shims/url.d.ts +84 -0
- package/dist/shims/url.d.ts.map +1 -0
- package/dist/shims/v8.d.ts +73 -0
- package/dist/shims/v8.d.ts.map +1 -0
- package/dist/shims/vfs-adapter.d.ts +126 -0
- package/dist/shims/vfs-adapter.d.ts.map +1 -0
- package/dist/shims/vm.d.ts +52 -0
- package/dist/shims/vm.d.ts.map +1 -0
- package/dist/shims/wasi.d.ts +78 -0
- package/dist/shims/wasi.d.ts.map +1 -0
- package/dist/shims/worker_threads.d.ts +66 -0
- package/dist/shims/worker_threads.d.ts.map +1 -0
- package/dist/shims/zlib-constants.d.ts +66 -0
- package/dist/shims/zlib-constants.d.ts.map +1 -0
- package/dist/shims/zlib.d.ts +102 -0
- package/dist/shims/zlib.d.ts.map +1 -0
- package/dist/transform.d.ts +24 -0
- package/dist/transform.d.ts.map +1 -0
- package/dist/types/package-json.d.ts +18 -0
- package/dist/types/package-json.d.ts.map +1 -0
- package/dist/utils/binary-encoding.d.ts +13 -0
- package/dist/utils/binary-encoding.d.ts.map +1 -0
- package/dist/utils/glob.d.ts +19 -0
- package/dist/utils/glob.d.ts.map +1 -0
- package/dist/utils/hash.d.ts +6 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/virtual-fs.d.ts +259 -0
- package/dist/virtual-fs.d.ts.map +1 -0
- package/dist/vite-plugin.cjs +50 -0
- package/dist/vite-plugin.cjs.map +1 -0
- package/dist/vite-plugin.d.ts +36 -0
- package/dist/vite-plugin.d.ts.map +1 -0
- package/dist/vite-plugin.mjs +31 -0
- package/dist/vite-plugin.mjs.map +1 -0
- package/dist/worker/runtime-worker.d.ts +8 -0
- package/dist/worker/runtime-worker.d.ts.map +1 -0
- package/dist/worker-runtime.d.ts +50 -0
- package/dist/worker-runtime.d.ts.map +1 -0
- package/package.json +88 -0
- package/src/code-transforms.ts +560 -0
- package/src/config/cdn.ts +13 -0
- package/src/create-runtime.ts +89 -0
- package/src/host-globals.ts +121 -0
- package/src/index.ts +235 -0
- package/src/node-internals.ts +283 -0
- package/src/node-lib/LICENSE +47 -0
- package/src/node-lib/_http_agent.js +547 -0
- package/src/node-lib/_http_client.js +996 -0
- package/src/node-lib/_http_common.js +269 -0
- package/src/node-lib/_http_incoming.js +453 -0
- package/src/node-lib/_http_outgoing.js +1262 -0
- package/src/node-lib/_http_server.js +1230 -0
- package/src/node-lib/assert/strict.js +3 -0
- package/src/node-lib/assert.js +844 -0
- package/src/node-lib/binding/blob.ts +35 -0
- package/src/node-lib/binding/buffer.ts +465 -0
- package/src/node-lib/binding/cares_wrap.ts +57 -0
- package/src/node-lib/binding/fds.ts +80 -0
- package/src/node-lib/binding/fs.ts +857 -0
- package/src/node-lib/binding/handles.ts +187 -0
- package/src/node-lib/binding/http_parser.ts +536 -0
- package/src/node-lib/binding/index.ts +77 -0
- package/src/node-lib/binding/llhttp-wasm.ts +670 -0
- package/src/node-lib/binding/misc.ts +252 -0
- package/src/node-lib/binding/pipe_wrap.ts +166 -0
- package/src/node-lib/binding/process_wrap.ts +371 -0
- package/src/node-lib/binding/spawn_sync.ts +141 -0
- package/src/node-lib/binding/stream_wrap.ts +413 -0
- package/src/node-lib/binding/stubs.ts +19 -0
- package/src/node-lib/binding/tcp_wrap.ts +254 -0
- package/src/node-lib/binding/tty_wrap.ts +56 -0
- package/src/node-lib/binding/util.ts +274 -0
- package/src/node-lib/binding/uv.ts +102 -0
- package/src/node-lib/binding/zlib-pako.ts +50 -0
- package/src/node-lib/binding/zlib.ts +259 -0
- package/src/node-lib/buffer-module.ts +70 -0
- package/src/node-lib/buffer.js +1373 -0
- package/src/node-lib/child-process-module.ts +58 -0
- package/src/node-lib/child_process.js +1046 -0
- package/src/node-lib/constants.js +41 -0
- package/src/node-lib/diagnostics_channel.js +438 -0
- package/src/node-lib/events-module.ts +80 -0
- package/src/node-lib/events.js +1223 -0
- package/src/node-lib/fs-module.ts +43 -0
- package/src/node-lib/fs.js +3377 -0
- package/src/node-lib/http-bridge.ts +299 -0
- package/src/node-lib/http-module.ts +53 -0
- package/src/node-lib/http.js +198 -0
- package/src/node-lib/https.js +429 -0
- package/src/node-lib/internal/assert/assertion_error.js +417 -0
- package/src/node-lib/internal/assert/calltracker.js +153 -0
- package/src/node-lib/internal/assert/myers_diff.js +177 -0
- package/src/node-lib/internal/assert/utils.js +278 -0
- package/src/node-lib/internal/buffer.js +1120 -0
- package/src/node-lib/internal/child_process/serialization.js +169 -0
- package/src/node-lib/internal/child_process.js +1135 -0
- package/src/node-lib/internal/constants.js +56 -0
- package/src/node-lib/internal/deps/minimatch/index.js +1628 -0
- package/src/node-lib/internal/errors.js +1912 -0
- package/src/node-lib/internal/events/abort_listener.js +54 -0
- package/src/node-lib/internal/events/symbols.js +11 -0
- package/src/node-lib/internal/fixed_queue.js +119 -0
- package/src/node-lib/internal/freelist.js +30 -0
- package/src/node-lib/internal/fs/cp/cp-sync.js +242 -0
- package/src/node-lib/internal/fs/cp/cp.js +382 -0
- package/src/node-lib/internal/fs/dir.js +369 -0
- package/src/node-lib/internal/fs/glob.js +763 -0
- package/src/node-lib/internal/fs/promises.js +1312 -0
- package/src/node-lib/internal/fs/read/context.js +129 -0
- package/src/node-lib/internal/fs/recursive_watch.js +275 -0
- package/src/node-lib/internal/fs/rimraf.js +311 -0
- package/src/node-lib/internal/fs/streams.js +571 -0
- package/src/node-lib/internal/fs/sync_write_stream.js +49 -0
- package/src/node-lib/internal/fs/utils.js +987 -0
- package/src/node-lib/internal/fs/watchers.js +418 -0
- package/src/node-lib/internal/http.js +62 -0
- package/src/node-lib/internal/mime.js +389 -0
- package/src/node-lib/internal/modules/customization_hooks.js +406 -0
- package/src/node-lib/internal/net.js +95 -0
- package/src/node-lib/internal/querystring.js +119 -0
- package/src/node-lib/internal/readline/callbacks.js +132 -0
- package/src/node-lib/internal/readline/emitKeypressEvents.js +99 -0
- package/src/node-lib/internal/readline/interface.js +1418 -0
- package/src/node-lib/internal/readline/promises.js +144 -0
- package/src/node-lib/internal/readline/utils.js +405 -0
- package/src/node-lib/internal/socket_list.js +108 -0
- package/src/node-lib/internal/stream_base_commons.js +280 -0
- package/src/node-lib/internal/streams/add-abort-signal.js +60 -0
- package/src/node-lib/internal/streams/compose.js +257 -0
- package/src/node-lib/internal/streams/destroy.js +361 -0
- package/src/node-lib/internal/streams/duplex.js +203 -0
- package/src/node-lib/internal/streams/duplexify.js +379 -0
- package/src/node-lib/internal/streams/duplexpair.js +62 -0
- package/src/node-lib/internal/streams/end-of-stream.js +331 -0
- package/src/node-lib/internal/streams/from.js +208 -0
- package/src/node-lib/internal/streams/lazy_transform.js +57 -0
- package/src/node-lib/internal/streams/legacy.js +125 -0
- package/src/node-lib/internal/streams/operators.js +436 -0
- package/src/node-lib/internal/streams/passthrough.js +47 -0
- package/src/node-lib/internal/streams/pipeline.js +465 -0
- package/src/node-lib/internal/streams/readable.js +1762 -0
- package/src/node-lib/internal/streams/state.js +51 -0
- package/src/node-lib/internal/streams/transform.js +204 -0
- package/src/node-lib/internal/streams/utils.js +363 -0
- package/src/node-lib/internal/streams/writable.js +1163 -0
- package/src/node-lib/internal/tty.js +260 -0
- package/src/node-lib/internal/util/colors.js +40 -0
- package/src/node-lib/internal/util/comparisons.js +1028 -0
- package/src/node-lib/internal/util/debuglog.js +524 -0
- package/src/node-lib/internal/util/inspect.js +2535 -0
- package/src/node-lib/internal/util/parse_args/parse_args.js +412 -0
- package/src/node-lib/internal/util/parse_args/utils.js +197 -0
- package/src/node-lib/internal/util.js +1003 -0
- package/src/node-lib/internal/validators.js +654 -0
- package/src/node-lib/internals/addresses.ts +159 -0
- package/src/node-lib/internals/buffer-and-streams.ts +224 -0
- package/src/node-lib/internals/child-process.ts +64 -0
- package/src/node-lib/internals/events-util.ts +105 -0
- package/src/node-lib/internals/index.ts +66 -0
- package/src/node-lib/internals/modules.ts +117 -0
- package/src/node-lib/internals/readline-access.ts +16 -0
- package/src/node-lib/internals/runtime.ts +277 -0
- package/src/node-lib/internals/util.ts +98 -0
- package/src/node-lib/lazy.ts +158 -0
- package/src/node-lib/load.ts +390 -0
- package/src/node-lib/module-hooks.ts +281 -0
- package/src/node-lib/net-module.ts +248 -0
- package/src/node-lib/net.js +2540 -0
- package/src/node-lib/node-versions.ts +34 -0
- package/src/node-lib/os.js +356 -0
- package/src/node-lib/path.js +1694 -0
- package/src/node-lib/primordials.js +743 -0
- package/src/node-lib/public-modules.ts +109 -0
- package/src/node-lib/punycode.js +455 -0
- package/src/node-lib/querystring.js +484 -0
- package/src/node-lib/readline/promises.js +73 -0
- package/src/node-lib/readline.js +523 -0
- package/src/node-lib/require-hook.ts +27 -0
- package/src/node-lib/small-modules.ts +35 -0
- package/src/node-lib/sources.ts +200 -0
- package/src/node-lib/stream/promises.js +44 -0
- package/src/node-lib/stream-module.ts +101 -0
- package/src/node-lib/stream.js +152 -0
- package/src/node-lib/timers.ts +33 -0
- package/src/node-lib/tty.js +168 -0
- package/src/node-lib/util-module.ts +104 -0
- package/src/node-lib/util.js +689 -0
- package/src/node-lib/wasi.js +179 -0
- package/src/node-lib/zlib.js +1036 -0
- package/src/node-resolution.ts +241 -0
- package/src/node-resolver.ts +33 -0
- package/src/npm/index.ts +425 -0
- package/src/npm/registry.ts +235 -0
- package/src/npm/resolver.ts +589 -0
- package/src/npm/tarball.ts +246 -0
- package/src/process-tokens.ts +156 -0
- package/src/punycode-source.ts +6 -0
- package/src/runtime-interface.ts +85 -0
- package/src/runtime.ts +3073 -0
- package/src/server-bridge.ts +971 -0
- package/src/shims/async_hooks.ts +181 -0
- package/src/shims/child_process.ts +1591 -0
- package/src/shims/cluster.ts +79 -0
- package/src/shims/command-line.ts +79 -0
- package/src/shims/constants.ts +68 -0
- package/src/shims/crypto-constants.ts +11 -0
- package/src/shims/crypto.ts +1061 -0
- package/src/shims/dgram.ts +47 -0
- package/src/shims/dns.ts +185 -0
- package/src/shims/domain.ts +58 -0
- package/src/shims/esbuild.ts +1638 -0
- package/src/shims/fs.ts +82 -0
- package/src/shims/http2.ts +96 -0
- package/src/shims/inspector.ts +30 -0
- package/src/shims/module.ts +86 -0
- package/src/shims/os.ts +195 -0
- package/src/shims/path.ts +246 -0
- package/src/shims/perf_hooks.ts +92 -0
- package/src/shims/process.ts +804 -0
- package/src/shims/rollup.ts +149 -0
- package/src/shims/string_decoder.ts +396 -0
- package/src/shims/sync-child.ts +469 -0
- package/src/shims/tls.ts +94 -0
- package/src/shims/url.ts +217 -0
- package/src/shims/v8.ts +113 -0
- package/src/shims/vfs-adapter.ts +408 -0
- package/src/shims/vm.ts +132 -0
- package/src/shims/wasi.ts +1440 -0
- package/src/shims/worker_threads.ts +114 -0
- package/src/shims/zlib-constants.ts +65 -0
- package/src/shims/zlib.ts +228 -0
- package/src/transform.ts +324 -0
- package/src/types/external.d.ts +55 -0
- package/src/types/package-json.ts +17 -0
- package/src/types/pako-zlib.d.ts +30 -0
- package/src/types/sha.js.d.ts +14 -0
- package/src/utils/binary-encoding.ts +43 -0
- package/src/utils/glob.ts +54 -0
- package/src/utils/hash.ts +12 -0
- package/src/virtual-fs.ts +1048 -0
- package/src/vite-plugin.ts +76 -0
- package/src/worker/runtime-worker.ts +128 -0
- package/src/worker-runtime.ts +145 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A run the embedding host has named, and the registry the container answers
|
|
3
|
+
* about it from.
|
|
4
|
+
*
|
|
5
|
+
* `container.run(command, { processToken })` names one run. The `node` command
|
|
6
|
+
* records the guest process it creates under that name, for as long as the run
|
|
7
|
+
* lasts, and forgets it when the run ends. Nothing here starts or ends a
|
|
8
|
+
* program: it is the registry three doors read, and the name a server
|
|
9
|
+
* registers itself under while its run is the one launching.
|
|
10
|
+
*
|
|
11
|
+
* The name reaches the `node` command through the shell's environment, under
|
|
12
|
+
* the reserved variable below, because two runs can be in flight at once on
|
|
13
|
+
* one shell and a module-level "the current run" would answer the later one
|
|
14
|
+
* for both. The guest never sees the variable: the environment the `node`
|
|
15
|
+
* command gives its process has it removed.
|
|
16
|
+
*/
|
|
17
|
+
/** Whatever the embedding runtime uses to name one guest process. */
|
|
18
|
+
export type ProcessToken = string;
|
|
19
|
+
/** The environment variable a run's name travels in, from `exec` to `node`. */
|
|
20
|
+
export declare const PROCESS_TOKEN_ENV = "__TABNODE_PROCESS_TOKEN";
|
|
21
|
+
/** What the engine can answer about one named run. */
|
|
22
|
+
export interface OwnedRun {
|
|
23
|
+
/** The timers the run's guest still holds, as Node's loop counts them. */
|
|
24
|
+
pendingTimers(): number;
|
|
25
|
+
/** Clear those timers, as ending the process clears them. */
|
|
26
|
+
stopTimers(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Report an exception nobody caught as this run's own, the way Node's
|
|
29
|
+
* process reports one: the run's `uncaughtException` listeners, else its
|
|
30
|
+
* stderr and exit 1. False when the run no longer answers.
|
|
31
|
+
*/
|
|
32
|
+
reportUncaught(error: unknown): boolean;
|
|
33
|
+
}
|
|
34
|
+
/** Run `fn` as this token's guest code, so the doors below name that run. */
|
|
35
|
+
export declare function enterRun<T>(token: ProcessToken, fn: () => T): T;
|
|
36
|
+
/**
|
|
37
|
+
* Record a named run's guest for the run's lifetime. The answer releases it;
|
|
38
|
+
* releasing twice is harmless, as a run ends once.
|
|
39
|
+
*/
|
|
40
|
+
export declare function __recordRun(token: ProcessToken, run: OwnedRun): () => void;
|
|
41
|
+
/** The run recorded under this name, while it lasts. */
|
|
42
|
+
export declare function __runFor(token: ProcessToken): OwnedRun | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* The run now launching a guest, for a handle or a server the guest opens
|
|
45
|
+
* after its entry has returned, when no run is the current one any more.
|
|
46
|
+
* `enterRun`'s async-local value covers the guest's own turn and everything
|
|
47
|
+
* scheduled from inside it; a listen that lands after a native `await`
|
|
48
|
+
* continuation is attributed here.
|
|
49
|
+
*/
|
|
50
|
+
export declare let __lastLaunchedToken: ProcessToken | null;
|
|
51
|
+
export declare function __setLastLaunchedToken(token: ProcessToken | null): void;
|
|
52
|
+
/** The run a guest is being launched under, where the host named one. */
|
|
53
|
+
export declare function __currentProcessToken(): ProcessToken | null;
|
|
54
|
+
/**
|
|
55
|
+
* End a named run's timers. The servers it owns are released by `http`'s own
|
|
56
|
+
* half, `__releaseOwnedServers`, which calls this for the timers.
|
|
57
|
+
*/
|
|
58
|
+
export declare function __stopOwnedProcess(token: ProcessToken): void;
|
|
59
|
+
/** The next process number this engine hands out. */
|
|
60
|
+
export declare function mintPid(): number;
|
|
61
|
+
/** Record the numbers a named run was started with, for the run to read back. */
|
|
62
|
+
export declare function setRunPid(token: ProcessToken, pid: number, ppid: number): void;
|
|
63
|
+
/** The numbers a named run was started with, where one was recorded. */
|
|
64
|
+
export declare function runPid(token: ProcessToken | null | undefined): {
|
|
65
|
+
pid: number;
|
|
66
|
+
ppid: number;
|
|
67
|
+
} | undefined;
|
|
68
|
+
/** A run that has ended is no longer a process; its number is nobody's. */
|
|
69
|
+
export declare function forgetRunPid(token: ProcessToken): void;
|
|
70
|
+
/** Whether a live run carries this number, which is what `kill(pid, 0)` asks. */
|
|
71
|
+
export declare function pidIsLive(pid: number): boolean;
|
|
72
|
+
/** The numbers a live process carries, looked up by its own pid. */
|
|
73
|
+
export declare function processByPid(pid: number): {
|
|
74
|
+
pid: number;
|
|
75
|
+
ppid: number;
|
|
76
|
+
} | undefined;
|
|
77
|
+
//# sourceMappingURL=process-tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-tokens.d.ts","sourceRoot":"","sources":["../src/process-tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,qEAAqE;AACrE,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC,+EAA+E;AAC/E,eAAO,MAAM,iBAAiB,4BAA4B,CAAC;AAE3D,sDAAsD;AACtD,MAAM,WAAW,QAAQ;IACvB,0EAA0E;IAC1E,aAAa,IAAI,MAAM,CAAC;IACxB,6DAA6D;IAC7D,UAAU,IAAI,IAAI,CAAC;IACnB;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;CACzC;AAcD,6EAA6E;AAC7E,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAE/D;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,QAAQ,GAAG,MAAM,IAAI,CAQ1E;AAED,wDAAwD;AACxD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,QAAQ,GAAG,SAAS,CAElE;AAED;;;;;;GAMG;AACH,eAAO,IAAI,mBAAmB,EAAE,YAAY,GAAG,IAAW,CAAC;AAC3D,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,GAAG,IAAI,CAEvE;AAED,yEAAyE;AACzE,wBAAgB,qBAAqB,IAAI,YAAY,GAAG,IAAI,CAE3D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAE5D;AA2BD,qDAAqD;AACrD,wBAAgB,OAAO,IAAI,MAAM,CAEhC;AAED,iFAAiF;AACjF,wBAAgB,SAAS,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAE9E;AAED,wEAAwE;AACxE,wBAAgB,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAExG;AAED,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAEtD;AAED,iFAAiF;AACjF,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAG9C;AAED,oEAAoE;AACpE,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAGnF"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const PUNYCODE_VERSION = "2.3.1";
|
|
2
|
+
export declare const PUNYCODE_SOURCE = "'use strict';\n\n/** Highest positive signed 32-bit float value */\nconst maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1\n\n/** Bootstring parameters */\nconst base = 36;\nconst tMin = 1;\nconst tMax = 26;\nconst skew = 38;\nconst damp = 700;\nconst initialBias = 72;\nconst initialN = 128; // 0x80\nconst delimiter = '-'; // '\\x2D'\n\n/** Regular expressions */\nconst regexPunycode = /^xn--/;\nconst regexNonASCII = /[^\\0-\\x7F]/; // Note: U+007F DEL is excluded too.\nconst regexSeparators = /[\\x2E\\u3002\\uFF0E\\uFF61]/g; // RFC 3490 separators\n\n/** Error messages */\nconst errors = {\n\t'overflow': 'Overflow: input needs wider integers to process',\n\t'not-basic': 'Illegal input >= 0x80 (not a basic code point)',\n\t'invalid-input': 'Invalid input'\n};\n\n/** Convenience shortcuts */\nconst baseMinusTMin = base - tMin;\nconst floor = Math.floor;\nconst stringFromCharCode = String.fromCharCode;\n\n/*--------------------------------------------------------------------------*/\n\n/**\n * A generic error utility function.\n * @private\n * @param {String} type The error type.\n * @returns {Error} Throws a `RangeError` with the applicable error message.\n */\nfunction error(type) {\n\tthrow new RangeError(errors[type]);\n}\n\n/**\n * A generic `Array#map` utility function.\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} callback The function that gets called for every array\n * item.\n * @returns {Array} A new array of values returned by the callback function.\n */\nfunction map(array, callback) {\n\tconst result = [];\n\tlet length = array.length;\n\twhile (length--) {\n\t\tresult[length] = callback(array[length]);\n\t}\n\treturn result;\n}\n\n/**\n * A simple `Array#map`-like wrapper to work with domain name strings or email\n * addresses.\n * @private\n * @param {String} domain The domain name or email address.\n * @param {Function} callback The function that gets called for every\n * character.\n * @returns {String} A new string of characters returned by the callback\n * function.\n */\nfunction mapDomain(domain, callback) {\n\tconst parts = domain.split('@');\n\tlet result = '';\n\tif (parts.length > 1) {\n\t\t// In email addresses, only the domain name should be punycoded. Leave\n\t\t// the local part (i.e. everything up to `@`) intact.\n\t\tresult = parts[0] + '@';\n\t\tdomain = parts[1];\n\t}\n\t// Avoid `split(regex)` for IE8 compatibility. See #17.\n\tdomain = domain.replace(regexSeparators, '\\x2E');\n\tconst labels = domain.split('.');\n\tconst encoded = map(labels, callback).join('.');\n\treturn result + encoded;\n}\n\n/**\n * Creates an array containing the numeric code points of each Unicode\n * character in the string. While JavaScript uses UCS-2 internally,\n * this function will convert a pair of surrogate halves (each of which\n * UCS-2 exposes as separate characters) into a single code point,\n * matching UTF-16.\n * @see `punycode.ucs2.encode`\n * @see <https://mathiasbynens.be/notes/javascript-encoding>\n * @memberOf punycode.ucs2\n * @name decode\n * @param {String} string The Unicode input string (UCS-2).\n * @returns {Array} The new array of code points.\n */\nfunction ucs2decode(string) {\n\tconst output = [];\n\tlet counter = 0;\n\tconst length = string.length;\n\twhile (counter < length) {\n\t\tconst value = string.charCodeAt(counter++);\n\t\tif (value >= 0xD800 && value <= 0xDBFF && counter < length) {\n\t\t\t// It's a high surrogate, and there is a next character.\n\t\t\tconst extra = string.charCodeAt(counter++);\n\t\t\tif ((extra & 0xFC00) == 0xDC00) { // Low surrogate.\n\t\t\t\toutput.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);\n\t\t\t} else {\n\t\t\t\t// It's an unmatched surrogate; only append this code unit, in case the\n\t\t\t\t// next code unit is the high surrogate of a surrogate pair.\n\t\t\t\toutput.push(value);\n\t\t\t\tcounter--;\n\t\t\t}\n\t\t} else {\n\t\t\toutput.push(value);\n\t\t}\n\t}\n\treturn output;\n}\n\n/**\n * Creates a string based on an array of numeric code points.\n * @see `punycode.ucs2.decode`\n * @memberOf punycode.ucs2\n * @name encode\n * @param {Array} codePoints The array of numeric code points.\n * @returns {String} The new Unicode string (UCS-2).\n */\nconst ucs2encode = codePoints => String.fromCodePoint(...codePoints);\n\n/**\n * Converts a basic code point into a digit/integer.\n * @see `digitToBasic()`\n * @private\n * @param {Number} codePoint The basic numeric code point value.\n * @returns {Number} The numeric value of a basic code point (for use in\n * representing integers) in the range `0` to `base - 1`, or `base` if\n * the code point does not represent a value.\n */\nconst basicToDigit = function(codePoint) {\n\tif (codePoint >= 0x30 && codePoint < 0x3A) {\n\t\treturn 26 + (codePoint - 0x30);\n\t}\n\tif (codePoint >= 0x41 && codePoint < 0x5B) {\n\t\treturn codePoint - 0x41;\n\t}\n\tif (codePoint >= 0x61 && codePoint < 0x7B) {\n\t\treturn codePoint - 0x61;\n\t}\n\treturn base;\n};\n\n/**\n * Converts a digit/integer into a basic code point.\n * @see `basicToDigit()`\n * @private\n * @param {Number} digit The numeric value of a basic code point.\n * @returns {Number} The basic code point whose value (when used for\n * representing integers) is `digit`, which needs to be in the range\n * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is\n * used; else, the lowercase form is used. The behavior is undefined\n * if `flag` is non-zero and `digit` has no uppercase form.\n */\nconst digitToBasic = function(digit, flag) {\n\t// 0..25 map to ASCII a..z or A..Z\n\t// 26..35 map to ASCII 0..9\n\treturn digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);\n};\n\n/**\n * Bias adaptation function as per section 3.4 of RFC 3492.\n * https://tools.ietf.org/html/rfc3492#section-3.4\n * @private\n */\nconst adapt = function(delta, numPoints, firstTime) {\n\tlet k = 0;\n\tdelta = firstTime ? floor(delta / damp) : delta >> 1;\n\tdelta += floor(delta / numPoints);\n\tfor (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {\n\t\tdelta = floor(delta / baseMinusTMin);\n\t}\n\treturn floor(k + (baseMinusTMin + 1) * delta / (delta + skew));\n};\n\n/**\n * Converts a Punycode string of ASCII-only symbols to a string of Unicode\n * symbols.\n * @memberOf punycode\n * @param {String} input The Punycode string of ASCII-only symbols.\n * @returns {String} The resulting string of Unicode symbols.\n */\nconst decode = function(input) {\n\t// Don't use UCS-2.\n\tconst output = [];\n\tconst inputLength = input.length;\n\tlet i = 0;\n\tlet n = initialN;\n\tlet bias = initialBias;\n\n\t// Handle the basic code points: let `basic` be the number of input code\n\t// points before the last delimiter, or `0` if there is none, then copy\n\t// the first basic code points to the output.\n\n\tlet basic = input.lastIndexOf(delimiter);\n\tif (basic < 0) {\n\t\tbasic = 0;\n\t}\n\n\tfor (let j = 0; j < basic; ++j) {\n\t\t// if it's not a basic code point\n\t\tif (input.charCodeAt(j) >= 0x80) {\n\t\t\terror('not-basic');\n\t\t}\n\t\toutput.push(input.charCodeAt(j));\n\t}\n\n\t// Main decoding loop: start just after the last delimiter if any basic code\n\t// points were copied; start at the beginning otherwise.\n\n\tfor (let index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {\n\n\t\t// `index` is the index of the next character to be consumed.\n\t\t// Decode a generalized variable-length integer into `delta`,\n\t\t// which gets added to `i`. The overflow checking is easier\n\t\t// if we increase `i` as we go, then subtract off its starting\n\t\t// value at the end to obtain `delta`.\n\t\tconst oldi = i;\n\t\tfor (let w = 1, k = base; /* no condition */; k += base) {\n\n\t\t\tif (index >= inputLength) {\n\t\t\t\terror('invalid-input');\n\t\t\t}\n\n\t\t\tconst digit = basicToDigit(input.charCodeAt(index++));\n\n\t\t\tif (digit >= base) {\n\t\t\t\terror('invalid-input');\n\t\t\t}\n\t\t\tif (digit > floor((maxInt - i) / w)) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\n\t\t\ti += digit * w;\n\t\t\tconst t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n\n\t\t\tif (digit < t) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tconst baseMinusT = base - t;\n\t\t\tif (w > floor(maxInt / baseMinusT)) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\n\t\t\tw *= baseMinusT;\n\n\t\t}\n\n\t\tconst out = output.length + 1;\n\t\tbias = adapt(i - oldi, out, oldi == 0);\n\n\t\t// `i` was supposed to wrap around from `out` to `0`,\n\t\t// incrementing `n` each time, so we'll fix that now:\n\t\tif (floor(i / out) > maxInt - n) {\n\t\t\terror('overflow');\n\t\t}\n\n\t\tn += floor(i / out);\n\t\ti %= out;\n\n\t\t// Insert `n` at position `i` of the output.\n\t\toutput.splice(i++, 0, n);\n\n\t}\n\n\treturn String.fromCodePoint(...output);\n};\n\n/**\n * Converts a string of Unicode symbols (e.g. a domain name label) to a\n * Punycode string of ASCII-only symbols.\n * @memberOf punycode\n * @param {String} input The string of Unicode symbols.\n * @returns {String} The resulting Punycode string of ASCII-only symbols.\n */\nconst encode = function(input) {\n\tconst output = [];\n\n\t// Convert the input in UCS-2 to an array of Unicode code points.\n\tinput = ucs2decode(input);\n\n\t// Cache the length.\n\tconst inputLength = input.length;\n\n\t// Initialize the state.\n\tlet n = initialN;\n\tlet delta = 0;\n\tlet bias = initialBias;\n\n\t// Handle the basic code points.\n\tfor (const currentValue of input) {\n\t\tif (currentValue < 0x80) {\n\t\t\toutput.push(stringFromCharCode(currentValue));\n\t\t}\n\t}\n\n\tconst basicLength = output.length;\n\tlet handledCPCount = basicLength;\n\n\t// `handledCPCount` is the number of code points that have been handled;\n\t// `basicLength` is the number of basic code points.\n\n\t// Finish the basic string with a delimiter unless it's empty.\n\tif (basicLength) {\n\t\toutput.push(delimiter);\n\t}\n\n\t// Main encoding loop:\n\twhile (handledCPCount < inputLength) {\n\n\t\t// All non-basic code points < n have been handled already. Find the next\n\t\t// larger one:\n\t\tlet m = maxInt;\n\t\tfor (const currentValue of input) {\n\t\t\tif (currentValue >= n && currentValue < m) {\n\t\t\t\tm = currentValue;\n\t\t\t}\n\t\t}\n\n\t\t// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,\n\t\t// but guard against overflow.\n\t\tconst handledCPCountPlusOne = handledCPCount + 1;\n\t\tif (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {\n\t\t\terror('overflow');\n\t\t}\n\n\t\tdelta += (m - n) * handledCPCountPlusOne;\n\t\tn = m;\n\n\t\tfor (const currentValue of input) {\n\t\t\tif (currentValue < n && ++delta > maxInt) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\t\t\tif (currentValue === n) {\n\t\t\t\t// Represent delta as a generalized variable-length integer.\n\t\t\t\tlet q = delta;\n\t\t\t\tfor (let k = base; /* no condition */; k += base) {\n\t\t\t\t\tconst t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n\t\t\t\t\tif (q < t) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tconst qMinusT = q - t;\n\t\t\t\t\tconst baseMinusT = base - t;\n\t\t\t\t\toutput.push(\n\t\t\t\t\t\tstringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))\n\t\t\t\t\t);\n\t\t\t\t\tq = floor(qMinusT / baseMinusT);\n\t\t\t\t}\n\n\t\t\t\toutput.push(stringFromCharCode(digitToBasic(q, 0)));\n\t\t\t\tbias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength);\n\t\t\t\tdelta = 0;\n\t\t\t\t++handledCPCount;\n\t\t\t}\n\t\t}\n\n\t\t++delta;\n\t\t++n;\n\n\t}\n\treturn output.join('');\n};\n\n/**\n * Converts a Punycode string representing a domain name or an email address\n * to Unicode. Only the Punycoded parts of the input will be converted, i.e.\n * it doesn't matter if you call it on a string that has already been\n * converted to Unicode.\n * @memberOf punycode\n * @param {String} input The Punycoded domain name or email address to\n * convert to Unicode.\n * @returns {String} The Unicode representation of the given Punycode\n * string.\n */\nconst toUnicode = function(input) {\n\treturn mapDomain(input, function(string) {\n\t\treturn regexPunycode.test(string)\n\t\t\t? decode(string.slice(4).toLowerCase())\n\t\t\t: string;\n\t});\n};\n\n/**\n * Converts a Unicode string representing a domain name or an email address to\n * Punycode. Only the non-ASCII parts of the domain name will be converted,\n * i.e. it doesn't matter if you call it with a domain that's already in\n * ASCII.\n * @memberOf punycode\n * @param {String} input The domain name or email address to convert, as a\n * Unicode string.\n * @returns {String} The Punycode representation of the given domain name or\n * email address.\n */\nconst toASCII = function(input) {\n\treturn mapDomain(input, function(string) {\n\t\treturn regexNonASCII.test(string)\n\t\t\t? 'xn--' + encode(string)\n\t\t\t: string;\n\t});\n};\n\n/*--------------------------------------------------------------------------*/\n\n/** Define the public API */\nconst punycode = {\n\t/**\n\t * A string representing the current Punycode.js version number.\n\t * @memberOf punycode\n\t * @type String\n\t */\n\t'version': '2.3.1',\n\t/**\n\t * An object of methods to convert from JavaScript's internal character\n\t * representation (UCS-2) to Unicode code points, and back.\n\t * @see <https://mathiasbynens.be/notes/javascript-encoding>\n\t * @memberOf punycode\n\t * @type Object\n\t */\n\t'ucs2': {\n\t\t'decode': ucs2decode,\n\t\t'encode': ucs2encode\n\t},\n\t'decode': decode,\n\t'encode': encode,\n\t'toASCII': toASCII,\n\t'toUnicode': toUnicode\n};\n\nmodule.exports = punycode;\n";
|
|
3
|
+
//# sourceMappingURL=punycode-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"punycode-source.d.ts","sourceRoot":"","sources":["../src/punycode-source.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gBAAgB,UAAU,CAAC;AACxC,eAAO,MAAM,eAAe,2zaAA2za,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime Interface - Common interface for main-thread and worker runtimes
|
|
3
|
+
*/
|
|
4
|
+
import type { VirtualFS } from './virtual-fs';
|
|
5
|
+
export interface IRuntimeOptions {
|
|
6
|
+
cwd?: string;
|
|
7
|
+
env?: Record<string, string>;
|
|
8
|
+
onConsole?: (method: string, args: unknown[]) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface IModule {
|
|
11
|
+
id: string;
|
|
12
|
+
filename: string;
|
|
13
|
+
exports: unknown;
|
|
14
|
+
loaded: boolean;
|
|
15
|
+
children: IModule[];
|
|
16
|
+
paths: string[];
|
|
17
|
+
}
|
|
18
|
+
export interface IExecuteResult {
|
|
19
|
+
exports: unknown;
|
|
20
|
+
module: IModule;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Common runtime interface implemented by both MainThreadRuntime and WorkerRuntime
|
|
24
|
+
*/
|
|
25
|
+
export interface IRuntime {
|
|
26
|
+
/**
|
|
27
|
+
* Execute code as a module
|
|
28
|
+
*/
|
|
29
|
+
execute(code: string, filename?: string): Promise<IExecuteResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Run a file from the virtual file system
|
|
32
|
+
*/
|
|
33
|
+
runFile(filename: string): Promise<IExecuteResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Clear the module cache
|
|
36
|
+
*/
|
|
37
|
+
clearCache(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Get the virtual file system (only available on main thread runtime)
|
|
40
|
+
*/
|
|
41
|
+
getVFS?(): VirtualFS;
|
|
42
|
+
/**
|
|
43
|
+
* Terminate the runtime (only applicable to worker runtime)
|
|
44
|
+
*/
|
|
45
|
+
terminate?(): void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Options for creating a runtime
|
|
49
|
+
*/
|
|
50
|
+
export interface CreateRuntimeOptions extends IRuntimeOptions {
|
|
51
|
+
/**
|
|
52
|
+
* Which thread the guest runs on.
|
|
53
|
+
* - false (default): the caller's thread
|
|
54
|
+
* - true: a worker of the engine's own
|
|
55
|
+
* - 'auto': a worker where the realm has them, the caller's thread otherwise
|
|
56
|
+
*
|
|
57
|
+
* A worker is a thread, not an origin: it reaches the page's storage and
|
|
58
|
+
* its network. An embedder that needs origin isolation serves the run from
|
|
59
|
+
* an origin of its own, which is the substrate's isolation worker.
|
|
60
|
+
*/
|
|
61
|
+
useWorker?: boolean | 'auto';
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* VFS snapshot for transferring to worker
|
|
65
|
+
*/
|
|
66
|
+
export interface VFSSnapshot {
|
|
67
|
+
files: VFSFileEntry[];
|
|
68
|
+
}
|
|
69
|
+
export interface VFSFileEntry {
|
|
70
|
+
path: string;
|
|
71
|
+
type: 'file' | 'directory';
|
|
72
|
+
content?: string;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=runtime-interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-inter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AY,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime - Execute user code with shimmed Node.js globals
|
|
3
|
+
*
|
|
4
|
+
* ESM to CJS transformation is now handled during npm install by transform.ts
|
|
5
|
+
* using esbuild-wasm. This runtime just executes the pre-transformed CJS code.
|
|
6
|
+
*/
|
|
7
|
+
import { VirtualFS } from './virtual-fs';
|
|
8
|
+
import type { IExecuteResult } from './runtime-interface';
|
|
9
|
+
import { Process } from './shims/process';
|
|
10
|
+
export declare function pendingGuestTimers(process: Process): number;
|
|
11
|
+
/**
|
|
12
|
+
* Clear every timer a guest still holds, as ending a Node process clears the
|
|
13
|
+
* ones its loop was waiting on. The ids were made by the host's own
|
|
14
|
+
* `setTimeout`/`setInterval` through the guest's global view, so the host's
|
|
15
|
+
* own clears end them; a `Timeout` is cleared by either in Node, and either
|
|
16
|
+
* refusing an id of the other kind is not an error here.
|
|
17
|
+
*/
|
|
18
|
+
export declare function stopGuestTimers(process: Process): void;
|
|
19
|
+
export declare function __substratePendingOf(value: unknown): Promise<void> | undefined;
|
|
20
|
+
export interface Module {
|
|
21
|
+
id: string;
|
|
22
|
+
filename: string;
|
|
23
|
+
exports: unknown;
|
|
24
|
+
loaded: boolean;
|
|
25
|
+
children: Module[];
|
|
26
|
+
paths: string[];
|
|
27
|
+
/** The module that first required this one; null for the entry, as Node's is. */
|
|
28
|
+
parent?: Module | null;
|
|
29
|
+
}
|
|
30
|
+
export interface RuntimeOptions {
|
|
31
|
+
cwd?: string;
|
|
32
|
+
env?: Record<string, string>;
|
|
33
|
+
onConsole?: (method: string, args: unknown[]) => void;
|
|
34
|
+
onStdout?: (data: string) => void;
|
|
35
|
+
onStderr?: (data: string) => void;
|
|
36
|
+
/** What is on the guest's fd 0, the way a shell puts the left of a pipe there. */
|
|
37
|
+
stdin?: string;
|
|
38
|
+
/** The runner can still write to fd 0, so standard input has not ended. */
|
|
39
|
+
stdinHeld?: boolean;
|
|
40
|
+
/** The run was given a TTY; a pipe child is not one. */
|
|
41
|
+
tty?: boolean;
|
|
42
|
+
/** This run's process number and its parent's; minted where neither is given. */
|
|
43
|
+
pid?: number;
|
|
44
|
+
ppid?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface RequireFunction {
|
|
47
|
+
(id: string): unknown;
|
|
48
|
+
resolve: (id: string) => string;
|
|
49
|
+
cache: Record<string, Module>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Runtime class for executing code in virtual environment
|
|
53
|
+
* Note: This class has sync methods for backward compatibility.
|
|
54
|
+
* Use createRuntime() factory for IRuntime interface compliance.
|
|
55
|
+
*/
|
|
56
|
+
export declare class Runtime {
|
|
57
|
+
private vfs;
|
|
58
|
+
private fsShim;
|
|
59
|
+
private process;
|
|
60
|
+
private moduleCache;
|
|
61
|
+
private options;
|
|
62
|
+
/** Cache for pre-processed code (after ESM transform) before eval */
|
|
63
|
+
private processedCodeCache;
|
|
64
|
+
constructor(vfs: VirtualFS, options?: RuntimeOptions);
|
|
65
|
+
/**
|
|
66
|
+
* Execute code as a module (synchronous - backward compatible)
|
|
67
|
+
*/
|
|
68
|
+
execute(code: string, filename?: string): {
|
|
69
|
+
exports: unknown;
|
|
70
|
+
module: Module;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Execute code as a module (async version for IRuntime interface)
|
|
74
|
+
* Alias: executeSync() is the same as execute() for backward compatibility
|
|
75
|
+
*/
|
|
76
|
+
executeSync: (code: string, filename?: string) => {
|
|
77
|
+
exports: unknown;
|
|
78
|
+
module: Module;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Execute code as a module (async - for IRuntime interface)
|
|
82
|
+
*/
|
|
83
|
+
executeAsync(code: string, filename?: string): Promise<IExecuteResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Run a file from the virtual file system (synchronous - backward compatible)
|
|
86
|
+
*/
|
|
87
|
+
runFile(filename: string): {
|
|
88
|
+
exports: unknown;
|
|
89
|
+
module: Module;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Alias for runFile (backward compatibility)
|
|
93
|
+
*/
|
|
94
|
+
runFileSync: (filename: string) => {
|
|
95
|
+
exports: unknown;
|
|
96
|
+
module: Module;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Run a file from the virtual file system (async - for IRuntime interface)
|
|
100
|
+
*/
|
|
101
|
+
runFileAsync(filename: string): Promise<IExecuteResult>;
|
|
102
|
+
/**
|
|
103
|
+
* Clear the module cache
|
|
104
|
+
*/
|
|
105
|
+
clearCache(): void;
|
|
106
|
+
/**
|
|
107
|
+
* Get the virtual file system
|
|
108
|
+
*/
|
|
109
|
+
getVFS(): VirtualFS;
|
|
110
|
+
/**
|
|
111
|
+
* Get the process object
|
|
112
|
+
*/
|
|
113
|
+
getProcess(): Process;
|
|
114
|
+
/**
|
|
115
|
+
* Create a REPL context that evaluates expressions and persists state.
|
|
116
|
+
*
|
|
117
|
+
* Returns an object with an `eval` method that:
|
|
118
|
+
* - Returns the value of the last expression (unlike `execute` which returns module.exports)
|
|
119
|
+
* - Persists variables between calls (`var x = 1` then `x` works)
|
|
120
|
+
* - Has access to `require`, `console`, `process`, `Buffer` (same as execute)
|
|
121
|
+
*
|
|
122
|
+
* Security: The eval runs inside a Generator's local scope via direct eval,
|
|
123
|
+
* NOT in the global scope. Only the runtime's own require/console/process are
|
|
124
|
+
* exposed — the same sandbox boundary as execute(). Variables created in the
|
|
125
|
+
* REPL are confined to the generator's closure and cannot leak to the page.
|
|
126
|
+
*
|
|
127
|
+
* Note: `const`/`let` are transformed to `var` so they persist across calls
|
|
128
|
+
* (var hoists to the generator's function scope, const/let are block-scoped
|
|
129
|
+
* to each eval call and would be lost).
|
|
130
|
+
*/
|
|
131
|
+
createREPL(): {
|
|
132
|
+
eval: (code: string) => unknown;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Create and execute code in a new runtime (synchronous - backward compatible)
|
|
137
|
+
*/
|
|
138
|
+
export declare function execute(code: string, vfs: VirtualFS, options?: RuntimeOptions): {
|
|
139
|
+
exports: unknown;
|
|
140
|
+
module: Module;
|
|
141
|
+
};
|
|
142
|
+
export type { IRuntime, IExecuteResult, IRuntimeOptions } from './runtime-interface';
|
|
143
|
+
export default Runtime;
|
|
144
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,EAAY,cAAc,EAAmB,MAAM,qBAAqB,CAAC;AAMrF,OAAO,EAAiB,OAAO,EAA6B,MAAM,iBAAiB,CAAC;AA4FpF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAE3D;AACD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAWtD;AAoaD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAI9E;AAuJD,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,iFAAiF;IACjF,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,cAA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
import { EventEmitter } from './node-lib/events-module';
|
|
7
|
+
/**
|
|
8
|
+
* Interface for virtual servers that can be registered with the bridge
|
|
9
|
+
*/
|
|
10
|
+
export interface IVirtualServer {
|
|
11
|
+
listening: boolean;
|
|
12
|
+
/** What `net.Server.address()` answers: an address and a port, or the PATH of a unix-domain socket. */
|
|
13
|
+
address(): {
|
|
14
|
+
port: number;
|
|
15
|
+
address: string;
|
|
16
|
+
family: string;
|
|
17
|
+
} | string | null;
|
|
18
|
+
handleRequest(method: string, url: string, headers: Record<string, string>, body?: Buffer | string): Promise<ResponseData>;
|
|
19
|
+
}
|
|
20
|
+
export interface VirtualServer {
|
|
21
|
+
/**
|
|
22
|
+
* A server the host registered and answers itself, or null for a guest's
|
|
23
|
+
* own: a guest's server is a port this engine is listening on, and it is
|
|
24
|
+
* reached by connecting to it like any other client.
|
|
25
|
+
*/
|
|
26
|
+
server: IVirtualServer | null;
|
|
27
|
+
port: number;
|
|
28
|
+
hostname: string;
|
|
29
|
+
}
|
|
30
|
+
export interface BridgeOptions {
|
|
31
|
+
baseUrl?: string;
|
|
32
|
+
onServerReady?: (port: number, url: string) => void;
|
|
33
|
+
}
|
|
34
|
+
export interface InitServiceWorkerOptions {
|
|
35
|
+
/**
|
|
36
|
+
* The URL path to the service worker file
|
|
37
|
+
* @default '/__sw__.js'
|
|
38
|
+
*/
|
|
39
|
+
swUrl?: string;
|
|
40
|
+
/**
|
|
41
|
+
* The page's own documents that are frames of it (a sandbox, a worker
|
|
42
|
+
* host), by path, so the worker does not take one for the preview's.
|
|
43
|
+
*/
|
|
44
|
+
ownDocuments?: string[];
|
|
45
|
+
}
|
|
46
|
+
export declare class ServerBridge extends EventEmitter {
|
|
47
|
+
static DEBUG: boolean;
|
|
48
|
+
servers: Map<number, VirtualServer>;
|
|
49
|
+
private baseUrl;
|
|
50
|
+
private options;
|
|
51
|
+
private messageChannel;
|
|
52
|
+
/** The upgrade channel this bridge opened, held so it can be given back. */
|
|
53
|
+
private upgradeChannel;
|
|
54
|
+
private serviceWorkerReady;
|
|
55
|
+
private keepaliveInterval;
|
|
56
|
+
constructor(options?: BridgeOptions);
|
|
57
|
+
/**
|
|
58
|
+
* Give back everything this bridge opened: the upgrade channel and the
|
|
59
|
+
* service worker keepalive. A host that is done with a container calls it
|
|
60
|
+
* and has its process back; calling it twice is nothing.
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* Every port a guest starts listening on becomes a server this bridge can
|
|
64
|
+
* answer for, and every port it stops listening on stops being one. The
|
|
65
|
+
* news comes from the net binding, because that is where a port is taken;
|
|
66
|
+
* the engine's `http` is Node's own file and knows nothing of a page.
|
|
67
|
+
*/
|
|
68
|
+
private watchGuestPorts;
|
|
69
|
+
close(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Register a server on a port
|
|
72
|
+
*/
|
|
73
|
+
registerServer(server: IVirtualServer | null, port: number, hostname?: string): void;
|
|
74
|
+
/**
|
|
75
|
+
* Unregister a server
|
|
76
|
+
*/
|
|
77
|
+
unregisterServer(port: number): void;
|
|
78
|
+
/** The server the service worker answers at the origin's root, the preview's; null for none. */
|
|
79
|
+
private primaryPort;
|
|
80
|
+
/**
|
|
81
|
+
* Names the server the service worker serves at the origin's root, as an
|
|
82
|
+
* app is served at its own origin's root: its documents read their routes
|
|
83
|
+
* from `location.pathname`, which under /__virtual__/<port>/ is not the
|
|
84
|
+
* path they expect. Told to the worker now and again whenever the worker
|
|
85
|
+
* is (re)initialized, since a worker that restarted remembers nothing.
|
|
86
|
+
*/
|
|
87
|
+
setPrimaryPort(port: number | null): void;
|
|
88
|
+
/** Every registration the worker should hold, sent again to a worker that was (re)initialized. */
|
|
89
|
+
private announceServers;
|
|
90
|
+
private ownDocuments;
|
|
91
|
+
/**
|
|
92
|
+
* Get server URL for a port
|
|
93
|
+
*/
|
|
94
|
+
getServerUrl(port: number): string;
|
|
95
|
+
/**
|
|
96
|
+
* Get all registered server ports
|
|
97
|
+
*/
|
|
98
|
+
getServerPorts(): number[];
|
|
99
|
+
/**
|
|
100
|
+
* Handle an incoming request from Service Worker
|
|
101
|
+
*/
|
|
102
|
+
handleRequest(port: number, method: string, url: string, headers: Record<string, string>, body?: ArrayBuffer): Promise<ResponseData>;
|
|
103
|
+
/**
|
|
104
|
+
* Initialize Service Worker communication
|
|
105
|
+
* @param options - Configuration options for the service worker
|
|
106
|
+
* @param options.swUrl - Custom URL path to the service worker file (default: '/__sw__.js')
|
|
107
|
+
*/
|
|
108
|
+
initServiceWorker(options?: InitServiceWorkerOptions): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Handle messages from Service Worker
|
|
111
|
+
*/
|
|
112
|
+
private handleServiceWorkerMessage;
|
|
113
|
+
/**
|
|
114
|
+
* Handle a streaming request - sends chunks as they arrive
|
|
115
|
+
*/
|
|
116
|
+
/**
|
|
117
|
+
* A page-side request streamed to the caller as it arrives, the door a host
|
|
118
|
+
* reads a guest's server through when it wants chunks rather than a body:
|
|
119
|
+
* a guest's own server is reached over the loopback as any client reaches
|
|
120
|
+
* it; a server the host registered answers through its own streaming
|
|
121
|
+
* method where it has one, else its buffered answer is delivered whole.
|
|
122
|
+
*/
|
|
123
|
+
handleStreamingRequest(port: number, method: string, url: string, headers: Record<string, string>, body: ArrayBuffer | undefined, callbacks: {
|
|
124
|
+
start(statusCode: number, statusMessage: string, headers: Record<string, string>): void;
|
|
125
|
+
chunk(chunk: Uint8Array): void;
|
|
126
|
+
end(): void;
|
|
127
|
+
}): Promise<boolean>;
|
|
128
|
+
private streamToServiceWorker;
|
|
129
|
+
/**
|
|
130
|
+
* Send message to Service Worker
|
|
131
|
+
*/
|
|
132
|
+
private notifyServiceWorker;
|
|
133
|
+
/**
|
|
134
|
+
* Create a mock request handler for testing without Service Worker
|
|
135
|
+
*/
|
|
136
|
+
createFetchHandler(): (request: Request) => Promise<Response>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Get or create the global server bridge
|
|
140
|
+
*/
|
|
141
|
+
export declare function getServerBridge(options?: BridgeOptions): ServerBridge;
|
|
142
|
+
/**
|
|
143
|
+
* Reset the global bridge (for testing)
|
|
144
|
+
*/
|
|
145
|
+
export declare function resetServerBridge(): void;
|
|
146
|
+
export default ServerBridge;
|
|
147
|
+
//# sourceMappingURL=server-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-bridge.d.ts","sourceRoot":"","sources":["../src/server-bridge.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAexD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,uGAAuG;IACvG,OAAO,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,GAAG,IAAI,CAAC;IAC7E,aAAa,CACX,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GACrB,OAAO,CAAC,YAAY,CAAC,CAAC;CAC1B;AAwBD,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACrD;AAED,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;O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AAO,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAwF1E;;OAEG;YACW,0BAA0B;IAoDxC;;OAEG;IACH;;;;;;OAMG;IACG,sBAAsB,CAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,SAAS,EAAE;QACT,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;QACxF,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;QAC/B,GAAG,IAAI,IAAI,CAAC;KACb,GACA,OAAO,CAAC,OAAO,CAAC;YA0CL,qBAAqB;IA8GnC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAM3B;;OAEG;IACH,kBAAkB,IAAI,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC;CAgD9D;AAKD;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,YAAY,CAKrE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* async_hooks shim - Async tracking is not available in browser
|
|
3
|
+
*/
|
|
4
|
+
export declare class AsyncResource {
|
|
5
|
+
constructor(_type: string, _options?: object);
|
|
6
|
+
runInAsyncScope<T>(fn: (...args: any[]) => T, thisArg?: unknown, ...args: any[]): T;
|
|
7
|
+
emitDestroy(): this;
|
|
8
|
+
asyncId(): number;
|
|
9
|
+
triggerAsyncId(): number;
|
|
10
|
+
static bind<T extends (...args: any[]) => any>(fn: T, _type?: string): T;
|
|
11
|
+
}
|
|
12
|
+
export declare class AsyncLocalStorage<T> {
|
|
13
|
+
private store;
|
|
14
|
+
constructor();
|
|
15
|
+
static snapshot(): (callback: (...args: unknown[]) => unknown, ...args: unknown[]) => unknown;
|
|
16
|
+
static bind(callback: (...args: unknown[]) => unknown): (...args: unknown[]) => unknown;
|
|
17
|
+
disable(): void;
|
|
18
|
+
getStore(): T | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* A store entered for an async callback used to be left the moment the
|
|
21
|
+
* callback returned its promise, so the first `await` inside a Server Action
|
|
22
|
+
* lost Next's request store and `cookies()` was "outside a request scope". A
|
|
23
|
+
* tab has no async_hooks and no AsyncContext, and an `await` of a native
|
|
24
|
+
* promise bypasses any `then` a patch could install, so the continuations
|
|
25
|
+
* cannot be followed. What can be done honestly is keep the store current
|
|
26
|
+
* until the callback's promise settles: exact for one run at a time, and
|
|
27
|
+
* last-entered-wins where two async runs overlap.
|
|
28
|
+
*/
|
|
29
|
+
run<R>(store: T, callback: (...args: unknown[]) => R, ...args: unknown[]): R;
|
|
30
|
+
exit<R>(callback: () => R): R;
|
|
31
|
+
enterWith(store: T): void;
|
|
32
|
+
}
|
|
33
|
+
export interface AsyncHook {
|
|
34
|
+
enable(): this;
|
|
35
|
+
disable(): this;
|
|
36
|
+
}
|
|
37
|
+
export declare function createHook(_callbacks: object): AsyncHook;
|
|
38
|
+
export declare function executionAsyncId(): number;
|
|
39
|
+
export declare function executionAsyncResource(): object;
|
|
40
|
+
export declare function triggerAsyncId(): number;
|
|
41
|
+
declare const _default: {
|
|
42
|
+
AsyncResource: typeof AsyncResource;
|
|
43
|
+
AsyncLocalStorage: typeof AsyncLocalStorage;
|
|
44
|
+
createHook: typeof createHook;
|
|
45
|
+
executionAsyncId: typeof executionAsyncId;
|
|
46
|
+
executionAsyncResource: typeof executionAsyncResource;
|
|
47
|
+
triggerAsyncId: typeof triggerAsyncId;
|
|
48
|
+
};
|
|
49
|
+
export default _default;
|
|
50
|
+
//# sourceMappingURL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