@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,408 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VirtualFS Adapter for just-bash
|
|
3
|
+
* Implements IFileSystem interface to bridge VirtualFS with just-bash
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
IFileSystem,
|
|
8
|
+
FsStat,
|
|
9
|
+
MkdirOptions,
|
|
10
|
+
RmOptions,
|
|
11
|
+
CpOptions,
|
|
12
|
+
BufferEncoding,
|
|
13
|
+
FileContent,
|
|
14
|
+
} from 'just-bash';
|
|
15
|
+
import type { VirtualFS } from '../virtual-fs';
|
|
16
|
+
import { createNodeError } from '../virtual-fs';
|
|
17
|
+
import { uint8ToBinaryString } from '../utils/binary-encoding';
|
|
18
|
+
|
|
19
|
+
const _decoder = new TextDecoder();
|
|
20
|
+
|
|
21
|
+
// Local types for just-bash interface compatibility
|
|
22
|
+
// These are not exported from just-bash main entry point
|
|
23
|
+
interface DirentEntry {
|
|
24
|
+
name: string;
|
|
25
|
+
isFile: boolean;
|
|
26
|
+
isDirectory: boolean;
|
|
27
|
+
isSymbolicLink: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface ReadFileOptions {
|
|
31
|
+
encoding?: BufferEncoding | null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface WriteFileOptions {
|
|
35
|
+
encoding?: BufferEncoding;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class VirtualFSAdapter implements IFileSystem {
|
|
39
|
+
constructor(private vfs: VirtualFS) {}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Read the contents of a file as a string
|
|
43
|
+
*/
|
|
44
|
+
async readFile(
|
|
45
|
+
path: string,
|
|
46
|
+
options?: ReadFileOptions | BufferEncoding
|
|
47
|
+
): Promise<string> {
|
|
48
|
+
const encoding = typeof options === 'string' ? options : options?.encoding;
|
|
49
|
+
|
|
50
|
+
// VirtualFS only natively supports utf8/utf-8
|
|
51
|
+
// For other encodings, we need to handle the conversion ourselves
|
|
52
|
+
if (!encoding || encoding === 'utf8' || encoding === 'utf-8') {
|
|
53
|
+
return this.vfs.readFileSync(path, 'utf8');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// For binary/latin1 encoding, convert each byte to a character
|
|
57
|
+
if (encoding === 'binary' || encoding === 'latin1') {
|
|
58
|
+
const buffer = this.vfs.readFileSync(path);
|
|
59
|
+
return uint8ToBinaryString(buffer);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// For other encodings, fall back to utf8
|
|
63
|
+
return this.vfs.readFileSync(path, 'utf8');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Read the contents of a file as a Uint8Array (binary)
|
|
68
|
+
*/
|
|
69
|
+
async readFileBuffer(path: string): Promise<Uint8Array> {
|
|
70
|
+
return this.vfs.readFileSync(path);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Write content to a file, creating it if it doesn't exist
|
|
75
|
+
*/
|
|
76
|
+
async writeFile(
|
|
77
|
+
path: string,
|
|
78
|
+
content: FileContent,
|
|
79
|
+
_options?: WriteFileOptions | BufferEncoding
|
|
80
|
+
): Promise<void> {
|
|
81
|
+
this.vfs.writeFileSync(path, content);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Append content to a file, creating it if it doesn't exist
|
|
86
|
+
*/
|
|
87
|
+
async appendFile(
|
|
88
|
+
path: string,
|
|
89
|
+
content: FileContent,
|
|
90
|
+
_options?: WriteFileOptions | BufferEncoding
|
|
91
|
+
): Promise<void> {
|
|
92
|
+
let existing = '';
|
|
93
|
+
try {
|
|
94
|
+
existing = this.vfs.readFileSync(path, 'utf8');
|
|
95
|
+
} catch {
|
|
96
|
+
// File doesn't exist, start with empty content
|
|
97
|
+
}
|
|
98
|
+
const newContent =
|
|
99
|
+
typeof content === 'string' ? content : _decoder.decode(content);
|
|
100
|
+
this.vfs.writeFileSync(path, existing + newContent);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Check if a path exists
|
|
105
|
+
*/
|
|
106
|
+
async exists(path: string): Promise<boolean> {
|
|
107
|
+
return this.vfs.existsSync(path);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Get file/directory information
|
|
112
|
+
*/
|
|
113
|
+
async stat(path: string): Promise<FsStat> {
|
|
114
|
+
const stats = this.vfs.statSync(path);
|
|
115
|
+
const isFile = stats.isFile();
|
|
116
|
+
const isDirectory = stats.isDirectory();
|
|
117
|
+
|
|
118
|
+
let size = 0;
|
|
119
|
+
if (isFile) {
|
|
120
|
+
try {
|
|
121
|
+
const content = this.vfs.readFileSync(path);
|
|
122
|
+
size = content.length;
|
|
123
|
+
} catch {
|
|
124
|
+
// Shouldn't happen, but default to 0
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Files in .bin/ directories need execute permission for just-bash PATH resolution
|
|
129
|
+
const isExecutable = isFile && path.includes('/node_modules/.bin/');
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
isFile,
|
|
133
|
+
isDirectory,
|
|
134
|
+
isSymbolicLink: false,
|
|
135
|
+
mode: isDirectory ? 0o755 : (isExecutable ? 0o755 : 0o644),
|
|
136
|
+
size,
|
|
137
|
+
mtime: new Date(),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Create a directory
|
|
143
|
+
*/
|
|
144
|
+
async mkdir(path: string, options?: MkdirOptions): Promise<void> {
|
|
145
|
+
this.vfs.mkdirSync(path, options);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Read directory contents
|
|
150
|
+
*/
|
|
151
|
+
async readdir(path: string): Promise<string[]> {
|
|
152
|
+
return this.vfs.readdirSync(path);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Read directory contents with file type information
|
|
157
|
+
*/
|
|
158
|
+
async readdirWithFileTypes(path: string): Promise<DirentEntry[]> {
|
|
159
|
+
const entries = this.vfs.readdirSync(path);
|
|
160
|
+
const result: DirentEntry[] = [];
|
|
161
|
+
|
|
162
|
+
for (const name of entries) {
|
|
163
|
+
const fullPath = path === '/' ? `/${name}` : `${path}/${name}`;
|
|
164
|
+
try {
|
|
165
|
+
const stats = this.vfs.statSync(fullPath);
|
|
166
|
+
result.push({
|
|
167
|
+
name,
|
|
168
|
+
isFile: stats.isFile(),
|
|
169
|
+
isDirectory: stats.isDirectory(),
|
|
170
|
+
isSymbolicLink: false,
|
|
171
|
+
});
|
|
172
|
+
} catch {
|
|
173
|
+
// Entry disappeared between readdir and stat, skip it
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Remove a file or directory
|
|
182
|
+
*/
|
|
183
|
+
async rm(path: string, options?: RmOptions): Promise<void> {
|
|
184
|
+
const exists = this.vfs.existsSync(path);
|
|
185
|
+
|
|
186
|
+
if (!exists) {
|
|
187
|
+
if (options?.force) {
|
|
188
|
+
return; // Force mode ignores missing files
|
|
189
|
+
}
|
|
190
|
+
throw createNodeError('ENOENT', 'rm', path);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const stats = this.vfs.statSync(path);
|
|
194
|
+
|
|
195
|
+
if (stats.isFile()) {
|
|
196
|
+
this.vfs.unlinkSync(path);
|
|
197
|
+
} else if (stats.isDirectory()) {
|
|
198
|
+
if (options?.recursive) {
|
|
199
|
+
await this.rmRecursive(path);
|
|
200
|
+
} else {
|
|
201
|
+
this.vfs.rmdirSync(path);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Recursively remove a directory and its contents
|
|
208
|
+
*/
|
|
209
|
+
private async rmRecursive(path: string): Promise<void> {
|
|
210
|
+
const entries = this.vfs.readdirSync(path);
|
|
211
|
+
|
|
212
|
+
for (const entry of entries) {
|
|
213
|
+
const fullPath = path === '/' ? `/${entry}` : `${path}/${entry}`;
|
|
214
|
+
const stats = this.vfs.statSync(fullPath);
|
|
215
|
+
|
|
216
|
+
if (stats.isDirectory()) {
|
|
217
|
+
await this.rmRecursive(fullPath);
|
|
218
|
+
} else {
|
|
219
|
+
this.vfs.unlinkSync(fullPath);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
this.vfs.rmdirSync(path);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Copy a file or directory
|
|
228
|
+
*/
|
|
229
|
+
async cp(src: string, dest: string, options?: CpOptions): Promise<void> {
|
|
230
|
+
const stats = this.vfs.statSync(src);
|
|
231
|
+
|
|
232
|
+
if (stats.isFile()) {
|
|
233
|
+
const content = this.vfs.readFileSync(src);
|
|
234
|
+
this.vfs.writeFileSync(dest, content);
|
|
235
|
+
} else if (stats.isDirectory()) {
|
|
236
|
+
if (!options?.recursive) {
|
|
237
|
+
throw new Error(
|
|
238
|
+
`EISDIR: illegal operation on a directory, cannot copy '${src}'`
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
await this.cpRecursive(src, dest);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Recursively copy a directory
|
|
247
|
+
*/
|
|
248
|
+
private async cpRecursive(src: string, dest: string): Promise<void> {
|
|
249
|
+
// Create destination directory
|
|
250
|
+
this.vfs.mkdirSync(dest, { recursive: true });
|
|
251
|
+
|
|
252
|
+
const entries = this.vfs.readdirSync(src);
|
|
253
|
+
|
|
254
|
+
for (const entry of entries) {
|
|
255
|
+
const srcPath = src === '/' ? `/${entry}` : `${src}/${entry}`;
|
|
256
|
+
const destPath = dest === '/' ? `/${entry}` : `${dest}/${entry}`;
|
|
257
|
+
const stats = this.vfs.statSync(srcPath);
|
|
258
|
+
|
|
259
|
+
if (stats.isDirectory()) {
|
|
260
|
+
await this.cpRecursive(srcPath, destPath);
|
|
261
|
+
} else {
|
|
262
|
+
const content = this.vfs.readFileSync(srcPath);
|
|
263
|
+
this.vfs.writeFileSync(destPath, content);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Move/rename a file or directory
|
|
270
|
+
*/
|
|
271
|
+
async mv(src: string, dest: string): Promise<void> {
|
|
272
|
+
this.vfs.renameSync(src, dest);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Resolve a relative path against a base path
|
|
277
|
+
*/
|
|
278
|
+
resolvePath(base: string, path: string): string {
|
|
279
|
+
// If path is absolute, return it as-is (normalized)
|
|
280
|
+
if (path.startsWith('/')) {
|
|
281
|
+
return this.normalizePath(path);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Combine base and relative path
|
|
285
|
+
const combined = base.endsWith('/')
|
|
286
|
+
? `${base}${path}`
|
|
287
|
+
: `${base}/${path}`;
|
|
288
|
+
|
|
289
|
+
return this.normalizePath(combined);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Normalize a path (resolve . and .. segments)
|
|
294
|
+
*/
|
|
295
|
+
private normalizePath(path: string): string {
|
|
296
|
+
if (!path.startsWith('/')) {
|
|
297
|
+
path = '/' + path;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const parts = path.split('/').filter(Boolean);
|
|
301
|
+
const resolved: string[] = [];
|
|
302
|
+
|
|
303
|
+
for (const part of parts) {
|
|
304
|
+
if (part === '..') {
|
|
305
|
+
resolved.pop();
|
|
306
|
+
} else if (part !== '.') {
|
|
307
|
+
resolved.push(part);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return '/' + resolved.join('/');
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Get all paths in the filesystem
|
|
316
|
+
*/
|
|
317
|
+
getAllPaths(): string[] {
|
|
318
|
+
const paths: string[] = [];
|
|
319
|
+
this.collectPaths('/', paths);
|
|
320
|
+
return paths;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Recursively collect all paths
|
|
325
|
+
*/
|
|
326
|
+
private collectPaths(dir: string, paths: string[]): void {
|
|
327
|
+
try {
|
|
328
|
+
const entries = this.vfs.readdirSync(dir);
|
|
329
|
+
for (const entry of entries) {
|
|
330
|
+
const fullPath = dir === '/' ? `/${entry}` : `${dir}/${entry}`;
|
|
331
|
+
paths.push(fullPath);
|
|
332
|
+
try {
|
|
333
|
+
const stats = this.vfs.statSync(fullPath);
|
|
334
|
+
if (stats.isDirectory()) {
|
|
335
|
+
this.collectPaths(fullPath, paths);
|
|
336
|
+
}
|
|
337
|
+
} catch {
|
|
338
|
+
// Skip if stat fails
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
} catch {
|
|
342
|
+
// Directory doesn't exist or can't be read
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Change file/directory permissions (no-op - VFS doesn't track permissions)
|
|
348
|
+
*/
|
|
349
|
+
async chmod(_path: string, _mode: number): Promise<void> {
|
|
350
|
+
// VFS doesn't track permissions, but we verify the path exists
|
|
351
|
+
if (!this.vfs.existsSync(_path)) {
|
|
352
|
+
throw createNodeError('ENOENT', 'chmod', _path);
|
|
353
|
+
}
|
|
354
|
+
// No-op
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Create a symbolic link (not supported)
|
|
359
|
+
*/
|
|
360
|
+
async symlink(_target: string, _linkPath: string): Promise<void> {
|
|
361
|
+
throw new Error('Symbolic links are not supported in VirtualFS');
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Create a hard link (not supported)
|
|
366
|
+
*/
|
|
367
|
+
async link(_existingPath: string, _newPath: string): Promise<void> {
|
|
368
|
+
throw new Error('Hard links are not supported in VirtualFS');
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Read the target of a symbolic link (not supported)
|
|
373
|
+
*/
|
|
374
|
+
async readlink(_path: string): Promise<string> {
|
|
375
|
+
throw new Error('Symbolic links are not supported in VirtualFS');
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Get file/directory information without following symlinks
|
|
380
|
+
* Since VFS doesn't support symlinks, this is the same as stat
|
|
381
|
+
*/
|
|
382
|
+
async lstat(path: string): Promise<FsStat> {
|
|
383
|
+
return this.stat(path);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Resolve all symlinks in a path
|
|
388
|
+
* Since VFS doesn't support symlinks, just normalize and return
|
|
389
|
+
*/
|
|
390
|
+
async realpath(path: string): Promise<string> {
|
|
391
|
+
// Verify path exists
|
|
392
|
+
if (!this.vfs.existsSync(path)) {
|
|
393
|
+
throw createNodeError('ENOENT', 'realpath', path);
|
|
394
|
+
}
|
|
395
|
+
return this.normalizePath(path);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Set access and modification times (no-op - VFS doesn't track times)
|
|
400
|
+
*/
|
|
401
|
+
async utimes(path: string, _atime: Date, _mtime: Date): Promise<void> {
|
|
402
|
+
// VFS doesn't track times, but we verify the path exists
|
|
403
|
+
if (!this.vfs.existsSync(path)) {
|
|
404
|
+
throw createNodeError('ENOENT', 'utimes', path);
|
|
405
|
+
}
|
|
406
|
+
// No-op
|
|
407
|
+
}
|
|
408
|
+
}
|
package/src/shims/vm.ts
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vm shim - Basic VM functionality using eval
|
|
3
|
+
*
|
|
4
|
+
* `vm.runInNewContext(code, sandbox)` runs the code with the sandbox as its
|
|
5
|
+
* global: what the code writes on `globalThis` lands on the sandbox, and a name
|
|
6
|
+
* the sandbox lacks reads from the host's global. This passed the sandbox's
|
|
7
|
+
* keys as parameters, so `globalThis.x = ...` wrote to the real global and the
|
|
8
|
+
* caller read nothing back. Next's server evaluates each client-reference
|
|
9
|
+
* manifest exactly that way and read an empty object.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { parse } from 'acorn';
|
|
13
|
+
|
|
14
|
+
export class Script {
|
|
15
|
+
private code: string;
|
|
16
|
+
|
|
17
|
+
constructor(code: string, _options?: object) {
|
|
18
|
+
this.code = code;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
runInThisContext(_options?: object): unknown {
|
|
22
|
+
return eval(this.code);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
runInNewContext(contextObject?: object, _options?: object): unknown {
|
|
26
|
+
const sandbox: Record<string | symbol, unknown> = contextObject && typeof contextObject === 'object' ? contextObject as Record<string | symbol, unknown> : {};
|
|
27
|
+
// A script's top-level `var` and function declarations are properties of
|
|
28
|
+
// its context's global, as they are of Node's; they are read off the
|
|
29
|
+
// script and copied onto the sandbox once it has run.
|
|
30
|
+
const declared: string[] = [];
|
|
31
|
+
try {
|
|
32
|
+
const ast = parse(this.code, { ecmaVersion: 'latest', sourceType: 'script', allowReturnOutsideFunction: true, allowAwaitOutsideFunction: true });
|
|
33
|
+
for (const node of ast.body) {
|
|
34
|
+
if (node.type === 'FunctionDeclaration' && node.id) declared.push(node.id.name);
|
|
35
|
+
if (node.type === 'VariableDeclaration' && node.kind === 'var') for (const d of node.declarations) if (d.id.type === 'Identifier') declared.push(d.id.name);
|
|
36
|
+
}
|
|
37
|
+
} catch {
|
|
38
|
+
// A script the parser refuses still runs; its declarations stay its own.
|
|
39
|
+
}
|
|
40
|
+
// The scope answers every name but the evaluator's own and the script's declarations.
|
|
41
|
+
const own = new Set(['__substrateScope', '__substrateCode', '__substrateDeclared', ...declared]);
|
|
42
|
+
// The context's global as the script sees it through `globalThis`: the
|
|
43
|
+
// sandbox's own properties answer `in`, a read of a name it lacks
|
|
44
|
+
// falls back to the host's, a write lands on the sandbox.
|
|
45
|
+
const globalView: Record<string | symbol, unknown> = new Proxy(sandbox, {
|
|
46
|
+
has: (target, name) => name in target,
|
|
47
|
+
get: (target, name) => {
|
|
48
|
+
if (name === 'globalThis' || name === 'global' || name === 'self') return name in target ? target[name] : globalView;
|
|
49
|
+
return name in target ? target[name] : (globalThis as unknown as Record<string | symbol, unknown>)[name];
|
|
50
|
+
},
|
|
51
|
+
set: (target, name, value) => { target[name] = value; return true; },
|
|
52
|
+
deleteProperty: (target, name) => { delete target[name]; return true; },
|
|
53
|
+
});
|
|
54
|
+
// The scope every bare name resolves through: the sandbox first, the
|
|
55
|
+
// host's global after, and the evaluator's own names and the script's
|
|
56
|
+
// declarations left to the function that holds them.
|
|
57
|
+
const scope = new Proxy(sandbox, {
|
|
58
|
+
has: (_target, name) => !own.has(name as string),
|
|
59
|
+
get: (target, name) => {
|
|
60
|
+
if (name === Symbol.unscopables) return void 0;
|
|
61
|
+
if (name === 'globalThis' || name === 'global' || name === 'self') return name in target ? target[name] : globalView;
|
|
62
|
+
if (name in target) return target[name];
|
|
63
|
+
return (globalThis as unknown as Record<string | symbol, unknown>)[name];
|
|
64
|
+
},
|
|
65
|
+
set: (target, name, value) => { target[name] = value; return true; },
|
|
66
|
+
deleteProperty: (target, name) => { delete target[name]; return true; },
|
|
67
|
+
});
|
|
68
|
+
const fn = new Function('__substrateScope', '__substrateCode', '__substrateDeclared', 'with (__substrateScope) { const __substrateResult = eval(__substrateCode); for (const name of __substrateDeclared) { try { __substrateScope[name] = eval(name); } catch {} } return __substrateResult; }');
|
|
69
|
+
return fn(scope, this.code, declared);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
runInContext(_context: object, _options?: object): unknown {
|
|
73
|
+
return this.runInNewContext(_context, _options);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
createCachedData(): Buffer {
|
|
77
|
+
return Buffer.from('');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function createContext(contextObject?: object, _options?: object): object {
|
|
82
|
+
return contextObject || {};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function isContext(_sandbox: object): boolean {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function runInThisContext(code: string, _options?: object): unknown {
|
|
90
|
+
return eval(code);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function runInNewContext(code: string, contextObject?: object, _options?: object): unknown {
|
|
94
|
+
const script = new Script(code);
|
|
95
|
+
return script.runInNewContext(contextObject);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function runInContext(code: string, context: object, _options?: object): unknown {
|
|
99
|
+
return runInNewContext(code, context);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function compileFunction(code: string, params?: string[], _options?: object): Function {
|
|
103
|
+
return new Function(...(params || []), code);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export class Module {
|
|
107
|
+
constructor(_code: string, _options?: object) {}
|
|
108
|
+
link(_linker: unknown): Promise<void> { return Promise.resolve(); }
|
|
109
|
+
evaluate(_options?: object): Promise<unknown> { return Promise.resolve(); }
|
|
110
|
+
get status(): string { return 'unlinked'; }
|
|
111
|
+
get identifier(): string { return ''; }
|
|
112
|
+
get context(): object { return {}; }
|
|
113
|
+
get namespace(): object { return {}; }
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export class SourceTextModule extends Module {}
|
|
117
|
+
export class SyntheticModule extends Module {
|
|
118
|
+
setExport(_name: string, _value: unknown): void {}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export default {
|
|
122
|
+
Script,
|
|
123
|
+
createContext,
|
|
124
|
+
isContext,
|
|
125
|
+
runInThisContext,
|
|
126
|
+
runInNewContext,
|
|
127
|
+
runInContext,
|
|
128
|
+
compileFunction,
|
|
129
|
+
Module,
|
|
130
|
+
SourceTextModule,
|
|
131
|
+
SyntheticModule,
|
|
132
|
+
};
|