@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,331 @@
|
|
|
1
|
+
// Ported from https://github.com/mafintosh/end-of-stream with
|
|
2
|
+
// permission from the author, Mathias Buus (@mafintosh).
|
|
3
|
+
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
Promise,
|
|
8
|
+
PromisePrototypeThen,
|
|
9
|
+
} = primordials;
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
AbortError,
|
|
13
|
+
codes: {
|
|
14
|
+
ERR_INVALID_ARG_TYPE,
|
|
15
|
+
ERR_STREAM_PREMATURE_CLOSE,
|
|
16
|
+
},
|
|
17
|
+
} = require('internal/errors');
|
|
18
|
+
const {
|
|
19
|
+
kEmptyObject,
|
|
20
|
+
once,
|
|
21
|
+
SymbolDispose,
|
|
22
|
+
} = require('internal/util');
|
|
23
|
+
const {
|
|
24
|
+
validateAbortSignal,
|
|
25
|
+
validateFunction,
|
|
26
|
+
validateObject,
|
|
27
|
+
validateBoolean,
|
|
28
|
+
} = require('internal/validators');
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
isClosed,
|
|
32
|
+
isReadable,
|
|
33
|
+
isReadableNodeStream,
|
|
34
|
+
isReadableStream,
|
|
35
|
+
isReadableFinished,
|
|
36
|
+
isReadableErrored,
|
|
37
|
+
isWritable,
|
|
38
|
+
isWritableNodeStream,
|
|
39
|
+
isWritableStream,
|
|
40
|
+
isWritableFinished,
|
|
41
|
+
isWritableErrored,
|
|
42
|
+
isNodeStream,
|
|
43
|
+
willEmitClose: _willEmitClose,
|
|
44
|
+
kIsClosedPromise,
|
|
45
|
+
} = require('internal/streams/utils');
|
|
46
|
+
|
|
47
|
+
// Lazy load
|
|
48
|
+
let AsyncLocalStorage;
|
|
49
|
+
let addAbortListener;
|
|
50
|
+
|
|
51
|
+
function isRequest(stream) {
|
|
52
|
+
return stream.setHeader && typeof stream.abort === 'function';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const nop = () => {};
|
|
56
|
+
|
|
57
|
+
function eos(stream, options, callback) {
|
|
58
|
+
if (arguments.length === 2) {
|
|
59
|
+
callback = options;
|
|
60
|
+
options = kEmptyObject;
|
|
61
|
+
} else if (options == null) {
|
|
62
|
+
options = kEmptyObject;
|
|
63
|
+
} else {
|
|
64
|
+
validateObject(options, 'options');
|
|
65
|
+
}
|
|
66
|
+
validateFunction(callback, 'callback');
|
|
67
|
+
validateAbortSignal(options.signal, 'options.signal');
|
|
68
|
+
|
|
69
|
+
AsyncLocalStorage ??= require('async_hooks').AsyncLocalStorage;
|
|
70
|
+
callback = once(AsyncLocalStorage.bind(callback));
|
|
71
|
+
|
|
72
|
+
if (isReadableStream(stream) || isWritableStream(stream)) {
|
|
73
|
+
return eosWeb(stream, options, callback);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!isNodeStream(stream)) {
|
|
77
|
+
throw new ERR_INVALID_ARG_TYPE('stream', ['ReadableStream', 'WritableStream', 'Stream'], stream);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const readable = options.readable ?? isReadableNodeStream(stream);
|
|
81
|
+
const writable = options.writable ?? isWritableNodeStream(stream);
|
|
82
|
+
|
|
83
|
+
const wState = stream._writableState;
|
|
84
|
+
const rState = stream._readableState;
|
|
85
|
+
|
|
86
|
+
const onlegacyfinish = () => {
|
|
87
|
+
if (!stream.writable) {
|
|
88
|
+
onfinish();
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// TODO (ronag): Improve soft detection to include core modules and
|
|
93
|
+
// common ecosystem modules that do properly emit 'close' but fail
|
|
94
|
+
// this generic check.
|
|
95
|
+
let willEmitClose = (
|
|
96
|
+
_willEmitClose(stream) &&
|
|
97
|
+
isReadableNodeStream(stream) === readable &&
|
|
98
|
+
isWritableNodeStream(stream) === writable
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
let writableFinished = isWritableFinished(stream, false);
|
|
102
|
+
const onfinish = () => {
|
|
103
|
+
writableFinished = true;
|
|
104
|
+
// Stream should not be destroyed here. If it is that
|
|
105
|
+
// means that user space is doing something differently and
|
|
106
|
+
// we cannot trust willEmitClose.
|
|
107
|
+
if (stream.destroyed) {
|
|
108
|
+
willEmitClose = false;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (willEmitClose && (!stream.readable || readable)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (!readable || readableFinished) {
|
|
116
|
+
callback.call(stream);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
let readableFinished = isReadableFinished(stream, false);
|
|
121
|
+
const onend = () => {
|
|
122
|
+
readableFinished = true;
|
|
123
|
+
// Stream should not be destroyed here. If it is that
|
|
124
|
+
// means that user space is doing something differently and
|
|
125
|
+
// we cannot trust willEmitClose.
|
|
126
|
+
if (stream.destroyed) {
|
|
127
|
+
willEmitClose = false;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (willEmitClose && (!stream.writable || writable)) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (!writable || writableFinished) {
|
|
135
|
+
callback.call(stream);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const onerror = (err) => {
|
|
140
|
+
callback.call(stream, err);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
let closed = isClosed(stream);
|
|
144
|
+
|
|
145
|
+
const onclose = () => {
|
|
146
|
+
closed = true;
|
|
147
|
+
|
|
148
|
+
const errored = isWritableErrored(stream) || isReadableErrored(stream);
|
|
149
|
+
|
|
150
|
+
if (errored && typeof errored !== 'boolean') {
|
|
151
|
+
return callback.call(stream, errored);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (readable && !readableFinished && isReadableNodeStream(stream, true)) {
|
|
155
|
+
if (!isReadableFinished(stream, false))
|
|
156
|
+
return callback.call(stream,
|
|
157
|
+
new ERR_STREAM_PREMATURE_CLOSE());
|
|
158
|
+
}
|
|
159
|
+
if (writable && !writableFinished) {
|
|
160
|
+
if (!isWritableFinished(stream, false))
|
|
161
|
+
return callback.call(stream,
|
|
162
|
+
new ERR_STREAM_PREMATURE_CLOSE());
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
callback.call(stream);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const onclosed = () => {
|
|
169
|
+
closed = true;
|
|
170
|
+
|
|
171
|
+
const errored = isWritableErrored(stream) || isReadableErrored(stream);
|
|
172
|
+
|
|
173
|
+
if (errored && typeof errored !== 'boolean') {
|
|
174
|
+
return callback.call(stream, errored);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
callback.call(stream);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const onrequest = () => {
|
|
181
|
+
stream.req.on('finish', onfinish);
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
if (isRequest(stream)) {
|
|
185
|
+
stream.on('complete', onfinish);
|
|
186
|
+
if (!willEmitClose) {
|
|
187
|
+
stream.on('abort', onclose);
|
|
188
|
+
}
|
|
189
|
+
if (stream.req) {
|
|
190
|
+
onrequest();
|
|
191
|
+
} else {
|
|
192
|
+
stream.on('request', onrequest);
|
|
193
|
+
}
|
|
194
|
+
} else if (writable && !wState) { // legacy streams
|
|
195
|
+
stream.on('end', onlegacyfinish);
|
|
196
|
+
stream.on('close', onlegacyfinish);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Not all streams will emit 'close' after 'aborted'.
|
|
200
|
+
if (!willEmitClose && typeof stream.aborted === 'boolean') {
|
|
201
|
+
stream.on('aborted', onclose);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
stream.on('end', onend);
|
|
205
|
+
stream.on('finish', onfinish);
|
|
206
|
+
if (options.error !== false) {
|
|
207
|
+
stream.on('error', onerror);
|
|
208
|
+
}
|
|
209
|
+
stream.on('close', onclose);
|
|
210
|
+
|
|
211
|
+
if (closed) {
|
|
212
|
+
process.nextTick(onclose);
|
|
213
|
+
} else if (wState?.errorEmitted || rState?.errorEmitted) {
|
|
214
|
+
if (!willEmitClose) {
|
|
215
|
+
process.nextTick(onclosed);
|
|
216
|
+
}
|
|
217
|
+
} else if (
|
|
218
|
+
!readable &&
|
|
219
|
+
(!willEmitClose || isReadable(stream)) &&
|
|
220
|
+
(writableFinished || isWritable(stream) === false) &&
|
|
221
|
+
(wState == null || wState.pendingcb === undefined || wState.pendingcb === 0)
|
|
222
|
+
) {
|
|
223
|
+
process.nextTick(onclosed);
|
|
224
|
+
} else if (
|
|
225
|
+
!writable &&
|
|
226
|
+
(!willEmitClose || isWritable(stream)) &&
|
|
227
|
+
(readableFinished || isReadable(stream) === false)
|
|
228
|
+
) {
|
|
229
|
+
process.nextTick(onclosed);
|
|
230
|
+
} else if ((rState && stream.req && stream.aborted)) {
|
|
231
|
+
process.nextTick(onclosed);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const cleanup = () => {
|
|
235
|
+
callback = nop;
|
|
236
|
+
stream.removeListener('aborted', onclose);
|
|
237
|
+
stream.removeListener('complete', onfinish);
|
|
238
|
+
stream.removeListener('abort', onclose);
|
|
239
|
+
stream.removeListener('request', onrequest);
|
|
240
|
+
if (stream.req) stream.req.removeListener('finish', onfinish);
|
|
241
|
+
stream.removeListener('end', onlegacyfinish);
|
|
242
|
+
stream.removeListener('close', onlegacyfinish);
|
|
243
|
+
stream.removeListener('finish', onfinish);
|
|
244
|
+
stream.removeListener('end', onend);
|
|
245
|
+
stream.removeListener('error', onerror);
|
|
246
|
+
stream.removeListener('close', onclose);
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
if (options.signal && !closed) {
|
|
250
|
+
const abort = () => {
|
|
251
|
+
// Keep it because cleanup removes it.
|
|
252
|
+
const endCallback = callback;
|
|
253
|
+
cleanup();
|
|
254
|
+
endCallback.call(
|
|
255
|
+
stream,
|
|
256
|
+
new AbortError(undefined, { cause: options.signal.reason }));
|
|
257
|
+
};
|
|
258
|
+
if (options.signal.aborted) {
|
|
259
|
+
process.nextTick(abort);
|
|
260
|
+
} else {
|
|
261
|
+
addAbortListener ??= require('internal/events/abort_listener').addAbortListener;
|
|
262
|
+
const disposable = addAbortListener(options.signal, abort);
|
|
263
|
+
const originalCallback = callback;
|
|
264
|
+
callback = once((...args) => {
|
|
265
|
+
disposable[SymbolDispose]();
|
|
266
|
+
originalCallback.apply(stream, args);
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return cleanup;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function eosWeb(stream, options, callback) {
|
|
275
|
+
let isAborted = false;
|
|
276
|
+
let abort = nop;
|
|
277
|
+
if (options.signal) {
|
|
278
|
+
abort = () => {
|
|
279
|
+
isAborted = true;
|
|
280
|
+
callback.call(stream, new AbortError(undefined, { cause: options.signal.reason }));
|
|
281
|
+
};
|
|
282
|
+
if (options.signal.aborted) {
|
|
283
|
+
process.nextTick(abort);
|
|
284
|
+
} else {
|
|
285
|
+
addAbortListener ??= require('internal/events/abort_listener').addAbortListener;
|
|
286
|
+
const disposable = addAbortListener(options.signal, abort);
|
|
287
|
+
const originalCallback = callback;
|
|
288
|
+
callback = once((...args) => {
|
|
289
|
+
disposable[SymbolDispose]();
|
|
290
|
+
originalCallback.apply(stream, args);
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const resolverFn = (...args) => {
|
|
295
|
+
if (!isAborted) {
|
|
296
|
+
process.nextTick(() => callback.apply(stream, args));
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
PromisePrototypeThen(
|
|
300
|
+
stream[kIsClosedPromise].promise,
|
|
301
|
+
resolverFn,
|
|
302
|
+
resolverFn,
|
|
303
|
+
);
|
|
304
|
+
return nop;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function finished(stream, opts) {
|
|
308
|
+
let autoCleanup = false;
|
|
309
|
+
if (opts === null) {
|
|
310
|
+
opts = kEmptyObject;
|
|
311
|
+
}
|
|
312
|
+
if (opts?.cleanup) {
|
|
313
|
+
validateBoolean(opts.cleanup, 'cleanup');
|
|
314
|
+
autoCleanup = opts.cleanup;
|
|
315
|
+
}
|
|
316
|
+
return new Promise((resolve, reject) => {
|
|
317
|
+
const cleanup = eos(stream, opts, (err) => {
|
|
318
|
+
if (autoCleanup) {
|
|
319
|
+
cleanup();
|
|
320
|
+
}
|
|
321
|
+
if (err) {
|
|
322
|
+
reject(err);
|
|
323
|
+
} else {
|
|
324
|
+
resolve();
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
module.exports = eos;
|
|
331
|
+
module.exports.finished = finished;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
PromisePrototypeThen,
|
|
5
|
+
SymbolAsyncIterator,
|
|
6
|
+
SymbolIterator,
|
|
7
|
+
} = primordials;
|
|
8
|
+
const { Buffer } = require('buffer');
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
ERR_INVALID_ARG_TYPE,
|
|
12
|
+
ERR_STREAM_NULL_VALUES,
|
|
13
|
+
} = require('internal/errors').codes;
|
|
14
|
+
|
|
15
|
+
function from(Readable, iterable, opts) {
|
|
16
|
+
let iterator;
|
|
17
|
+
if (typeof iterable === 'string' || iterable instanceof Buffer) {
|
|
18
|
+
return new Readable({
|
|
19
|
+
objectMode: true,
|
|
20
|
+
...opts,
|
|
21
|
+
read() {
|
|
22
|
+
this.push(iterable);
|
|
23
|
+
this.push(null);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let isAsync;
|
|
29
|
+
if (iterable?.[SymbolAsyncIterator]) {
|
|
30
|
+
isAsync = true;
|
|
31
|
+
iterator = iterable[SymbolAsyncIterator]();
|
|
32
|
+
} else if (iterable?.[SymbolIterator]) {
|
|
33
|
+
isAsync = false;
|
|
34
|
+
iterator = iterable[SymbolIterator]();
|
|
35
|
+
} else {
|
|
36
|
+
throw new ERR_INVALID_ARG_TYPE('iterable', ['Iterable'], iterable);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
const readable = new Readable({
|
|
41
|
+
objectMode: true,
|
|
42
|
+
highWaterMark: 1,
|
|
43
|
+
// TODO(ronag): What options should be allowed?
|
|
44
|
+
...opts,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Flag to protect against _read
|
|
48
|
+
// being called before last iteration completion.
|
|
49
|
+
let reading = false;
|
|
50
|
+
let isAsyncValues = false;
|
|
51
|
+
|
|
52
|
+
readable._read = function() {
|
|
53
|
+
if (!reading) {
|
|
54
|
+
reading = true;
|
|
55
|
+
|
|
56
|
+
if (isAsync) {
|
|
57
|
+
nextAsync();
|
|
58
|
+
} else if (isAsyncValues) {
|
|
59
|
+
nextSyncWithAsyncValues();
|
|
60
|
+
} else {
|
|
61
|
+
nextSyncWithSyncValues();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
readable._destroy = function(error, cb) {
|
|
67
|
+
PromisePrototypeThen(
|
|
68
|
+
close(error),
|
|
69
|
+
() => process.nextTick(cb, error), // nextTick is here in case cb throws
|
|
70
|
+
(e) => process.nextTick(cb, e || error),
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
async function close(error) {
|
|
75
|
+
const hadError = (error !== undefined) && (error !== null);
|
|
76
|
+
const hasThrow = typeof iterator.throw === 'function';
|
|
77
|
+
if (hadError && hasThrow) {
|
|
78
|
+
const { value, done } = await iterator.throw(error);
|
|
79
|
+
await value;
|
|
80
|
+
if (done) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (typeof iterator.return === 'function') {
|
|
85
|
+
const { value } = await iterator.return();
|
|
86
|
+
await value;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// There are a lot of duplication here, it's done on purpose for performance
|
|
91
|
+
// reasons - avoid await when not needed.
|
|
92
|
+
|
|
93
|
+
function nextSyncWithSyncValues() {
|
|
94
|
+
for (;;) {
|
|
95
|
+
try {
|
|
96
|
+
const { value, done } = iterator.next();
|
|
97
|
+
|
|
98
|
+
if (done) {
|
|
99
|
+
readable.push(null);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (value &&
|
|
104
|
+
typeof value.then === 'function') {
|
|
105
|
+
return changeToAsyncValues(value);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (value === null) {
|
|
109
|
+
reading = false;
|
|
110
|
+
throw new ERR_STREAM_NULL_VALUES();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (readable.push(value)) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
reading = false;
|
|
118
|
+
} catch (err) {
|
|
119
|
+
readable.destroy(err);
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function changeToAsyncValues(value) {
|
|
126
|
+
isAsyncValues = true;
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
const res = await value;
|
|
130
|
+
|
|
131
|
+
if (res === null) {
|
|
132
|
+
reading = false;
|
|
133
|
+
throw new ERR_STREAM_NULL_VALUES();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (readable.push(res)) {
|
|
137
|
+
nextSyncWithAsyncValues();
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
reading = false;
|
|
142
|
+
} catch (err) {
|
|
143
|
+
readable.destroy(err);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async function nextSyncWithAsyncValues() {
|
|
148
|
+
for (;;) {
|
|
149
|
+
try {
|
|
150
|
+
const { value, done } = iterator.next();
|
|
151
|
+
|
|
152
|
+
if (done) {
|
|
153
|
+
readable.push(null);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const res = (value &&
|
|
158
|
+
typeof value.then === 'function') ?
|
|
159
|
+
await value :
|
|
160
|
+
value;
|
|
161
|
+
|
|
162
|
+
if (res === null) {
|
|
163
|
+
reading = false;
|
|
164
|
+
throw new ERR_STREAM_NULL_VALUES();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (readable.push(res)) {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
reading = false;
|
|
172
|
+
} catch (err) {
|
|
173
|
+
readable.destroy(err);
|
|
174
|
+
}
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async function nextAsync() {
|
|
180
|
+
for (;;) {
|
|
181
|
+
try {
|
|
182
|
+
const { value, done } = await iterator.next();
|
|
183
|
+
|
|
184
|
+
if (done) {
|
|
185
|
+
readable.push(null);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (value === null) {
|
|
190
|
+
reading = false;
|
|
191
|
+
throw new ERR_STREAM_NULL_VALUES();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (readable.push(value)) {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
reading = false;
|
|
199
|
+
} catch (err) {
|
|
200
|
+
readable.destroy(err);
|
|
201
|
+
}
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return readable;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
module.exports = from;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// LazyTransform is a special type of Transform stream that is lazily loaded.
|
|
2
|
+
// This is used for performance with bi-API-ship: when two APIs are available
|
|
3
|
+
// for the stream, one conventional and one non-conventional.
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
ObjectDefineProperties,
|
|
8
|
+
ObjectDefineProperty,
|
|
9
|
+
ObjectSetPrototypeOf,
|
|
10
|
+
} = primordials;
|
|
11
|
+
|
|
12
|
+
const stream = require('stream');
|
|
13
|
+
|
|
14
|
+
module.exports = LazyTransform;
|
|
15
|
+
|
|
16
|
+
function LazyTransform(options) {
|
|
17
|
+
this._options = options;
|
|
18
|
+
}
|
|
19
|
+
ObjectSetPrototypeOf(LazyTransform.prototype, stream.Transform.prototype);
|
|
20
|
+
ObjectSetPrototypeOf(LazyTransform, stream.Transform);
|
|
21
|
+
|
|
22
|
+
function makeGetter(name) {
|
|
23
|
+
return function() {
|
|
24
|
+
stream.Transform.call(this, this._options);
|
|
25
|
+
this._writableState.decodeStrings = false;
|
|
26
|
+
return this[name];
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function makeSetter(name) {
|
|
31
|
+
return function(val) {
|
|
32
|
+
ObjectDefineProperty(this, name, {
|
|
33
|
+
__proto__: null,
|
|
34
|
+
value: val,
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
ObjectDefineProperties(LazyTransform.prototype, {
|
|
43
|
+
_readableState: {
|
|
44
|
+
__proto__: null,
|
|
45
|
+
get: makeGetter('_readableState'),
|
|
46
|
+
set: makeSetter('_readableState'),
|
|
47
|
+
configurable: true,
|
|
48
|
+
enumerable: true,
|
|
49
|
+
},
|
|
50
|
+
_writableState: {
|
|
51
|
+
__proto__: null,
|
|
52
|
+
get: makeGetter('_writableState'),
|
|
53
|
+
set: makeSetter('_writableState'),
|
|
54
|
+
configurable: true,
|
|
55
|
+
enumerable: true,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
ArrayIsArray,
|
|
5
|
+
ObjectSetPrototypeOf,
|
|
6
|
+
ReflectOwnKeys,
|
|
7
|
+
} = primordials;
|
|
8
|
+
|
|
9
|
+
const EE = require('events');
|
|
10
|
+
|
|
11
|
+
function Stream(opts) {
|
|
12
|
+
EE.call(this, opts);
|
|
13
|
+
}
|
|
14
|
+
ObjectSetPrototypeOf(Stream.prototype, EE.prototype);
|
|
15
|
+
ObjectSetPrototypeOf(Stream, EE);
|
|
16
|
+
|
|
17
|
+
Stream.prototype.pipe = function(dest, options) {
|
|
18
|
+
const source = this;
|
|
19
|
+
|
|
20
|
+
function ondata(chunk) {
|
|
21
|
+
if (dest.writable && dest.write(chunk) === false && source.pause) {
|
|
22
|
+
source.pause();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
source.on('data', ondata);
|
|
27
|
+
|
|
28
|
+
function ondrain() {
|
|
29
|
+
if (source.readable && source.resume) {
|
|
30
|
+
source.resume();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
dest.on('drain', ondrain);
|
|
35
|
+
|
|
36
|
+
// If the 'end' option is not supplied, dest.end() will be called when
|
|
37
|
+
// source gets the 'end' or 'close' events. Only dest.end() once.
|
|
38
|
+
if (!dest._isStdio && (!options || options.end !== false)) {
|
|
39
|
+
source.on('end', onend);
|
|
40
|
+
source.on('close', onclose);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let didOnEnd = false;
|
|
44
|
+
function onend() {
|
|
45
|
+
if (didOnEnd) return;
|
|
46
|
+
didOnEnd = true;
|
|
47
|
+
|
|
48
|
+
dest.end();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
function onclose() {
|
|
53
|
+
if (didOnEnd) return;
|
|
54
|
+
didOnEnd = true;
|
|
55
|
+
|
|
56
|
+
if (typeof dest.destroy === 'function') dest.destroy();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Don't leave dangling pipes when there are errors.
|
|
60
|
+
function onerror(er) {
|
|
61
|
+
cleanup();
|
|
62
|
+
if (EE.listenerCount(this, 'error') === 0) {
|
|
63
|
+
this.emit('error', er);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
prependListener(source, 'error', onerror);
|
|
68
|
+
prependListener(dest, 'error', onerror);
|
|
69
|
+
|
|
70
|
+
// Remove all the event listeners that were added.
|
|
71
|
+
function cleanup() {
|
|
72
|
+
source.removeListener('data', ondata);
|
|
73
|
+
dest.removeListener('drain', ondrain);
|
|
74
|
+
|
|
75
|
+
source.removeListener('end', onend);
|
|
76
|
+
source.removeListener('close', onclose);
|
|
77
|
+
|
|
78
|
+
source.removeListener('error', onerror);
|
|
79
|
+
dest.removeListener('error', onerror);
|
|
80
|
+
|
|
81
|
+
source.removeListener('end', cleanup);
|
|
82
|
+
source.removeListener('close', cleanup);
|
|
83
|
+
|
|
84
|
+
dest.removeListener('close', cleanup);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
source.on('end', cleanup);
|
|
88
|
+
source.on('close', cleanup);
|
|
89
|
+
|
|
90
|
+
dest.on('close', cleanup);
|
|
91
|
+
dest.emit('pipe', source);
|
|
92
|
+
|
|
93
|
+
// Allow for unix-like usage: A.pipe(B).pipe(C)
|
|
94
|
+
return dest;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
Stream.prototype.eventNames = function eventNames() {
|
|
98
|
+
const names = [];
|
|
99
|
+
for (const key of ReflectOwnKeys(this._events)) {
|
|
100
|
+
if (typeof this._events[key] === 'function' || (ArrayIsArray(this._events[key]) && this._events[key].length > 0)) {
|
|
101
|
+
names.push(key);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return names;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
function prependListener(emitter, event, fn) {
|
|
108
|
+
// Sadly this is not cacheable as some libraries bundle their own
|
|
109
|
+
// event emitter implementation with them.
|
|
110
|
+
if (typeof emitter.prependListener === 'function')
|
|
111
|
+
return emitter.prependListener(event, fn);
|
|
112
|
+
|
|
113
|
+
// This is a hack to make sure that our error handler is attached before any
|
|
114
|
+
// userland ones. NEVER DO THIS. This is here only because this code needs
|
|
115
|
+
// to continue to work with older versions of Node.js that do not include
|
|
116
|
+
// the prependListener() method. The goal is to eventually remove this hack.
|
|
117
|
+
if (!emitter._events || !emitter._events[event])
|
|
118
|
+
emitter.on(event, fn);
|
|
119
|
+
else if (ArrayIsArray(emitter._events[event]))
|
|
120
|
+
emitter._events[event].unshift(fn);
|
|
121
|
+
else
|
|
122
|
+
emitter._events[event] = [fn, emitter._events[event]];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
module.exports = { Stream, prependListener };
|