visaljs 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -2
- package/THIRD_PARTY_LICENSES +1216 -0
- package/cli.js +4414 -325
- package/node/include/js_node.h +57 -1
- package/node/include/js_uv.h +8 -1
- package/node/prelude/_stream_duplex.js +4 -0
- package/node/prelude/_stream_passthrough.js +4 -0
- package/node/prelude/_stream_readable.js +4 -0
- package/node/prelude/_stream_transform.js +4 -0
- package/node/prelude/_stream_writable.js +4 -0
- package/node/prelude/assert.js +1334 -0
- package/node/prelude/assert_strict.js +12 -0
- package/node/prelude/async_hooks.js +1 -1
- package/node/prelude/buffer.js +43 -3
- package/node/prelude/child_process.js +1098 -0
- package/node/prelude/cluster.js +52 -0
- package/node/prelude/console.js +328 -0
- package/node/prelude/constants.js +10 -0
- package/node/prelude/crypto.js +1 -1
- package/node/prelude/diagnostics_channel.js +1 -1
- package/node/prelude/dns.js +1 -1
- package/node/prelude/domain.js +115 -0
- package/node/prelude/events.js +144 -16
- package/node/prelude/fs.js +1138 -151
- package/node/prelude/fs_promises.js +117 -11
- package/node/prelude/http.js +104 -27
- package/node/prelude/http2.js +1 -1
- package/node/prelude/https.js +148 -0
- package/node/prelude/inspector.js +27 -0
- package/node/prelude/inspector_promises.js +4 -0
- package/node/prelude/internal/async_context.js +1 -1
- package/node/prelude/internal/buffer_transcode.js +44 -0
- package/node/prelude/internal/comparisons.js +916 -0
- package/node/prelude/internal/compression_streams.js +153 -0
- package/node/prelude/internal/crypto/asym.js +27 -14
- package/node/prelude/internal/crypto/cipher.js +16 -5
- package/node/prelude/internal/crypto/diffiehellman.js +3 -2
- package/node/prelude/internal/crypto/hash.js +2 -1
- package/node/prelude/internal/crypto/kdf.js +14 -9
- package/node/prelude/internal/crypto/keys.js +63 -50
- package/node/prelude/internal/crypto/random.js +2 -1
- package/node/prelude/internal/crypto/util.js +4 -4
- package/node/prelude/internal/dotenv.js +98 -0
- package/node/prelude/internal/errors.js +21 -5
- package/node/prelude/internal/events_extras.js +116 -0
- package/node/prelude/internal/events_on.js +100 -0
- package/node/prelude/internal/features.js +55 -0
- package/node/prelude/internal/fetch.js +364 -0
- package/node/prelude/internal/form_data.js +376 -0
- package/node/prelude/internal/fs_bigint_stats.js +41 -0
- package/node/prelude/internal/fs_blob.js +19 -0
- package/node/prelude/internal/fs_cp.js +709 -0
- package/node/prelude/internal/fs_dir.js +166 -0
- package/node/prelude/internal/fs_filehandle.js +287 -0
- package/node/prelude/internal/fs_glob.js +296 -0
- package/node/prelude/internal/fs_statfs.js +42 -0
- package/node/prelude/internal/fs_stats.js +89 -0
- package/node/prelude/internal/fs_streams.js +541 -0
- package/node/prelude/internal/fs_utils.js +286 -0
- package/node/prelude/internal/fs_watch.js +580 -0
- package/node/prelude/internal/http_agent.js +26 -0
- package/node/prelude/internal/mime.js +249 -0
- package/node/prelude/internal/net.js +1 -0
- package/node/prelude/internal/parse_args.js +288 -0
- package/node/prelude/internal/perf_histogram.js +435 -0
- package/node/prelude/internal/perf_observe.js +119 -0
- package/node/prelude/internal/performance_global.js +19 -0
- package/node/prelude/internal/process_events.js +49 -1
- package/node/prelude/internal/process_memory.js +14 -0
- package/node/prelude/internal/process_more.js +414 -0
- package/node/prelude/internal/process_signals.js +2 -1
- package/node/prelude/internal/process_stdin.js +52 -0
- package/node/prelude/internal/process_stdio.js +36 -0
- package/node/prelude/internal/querystring.js +0 -0
- package/node/prelude/internal/readline.js +338 -0
- package/node/prelude/internal/socketaddress.js +8 -4
- package/node/prelude/internal/source_map.js +122 -0
- package/node/prelude/internal/stream_compose.js +74 -0
- package/node/prelude/internal/stream_from.js +6 -0
- package/node/prelude/internal/stream_operators.js +23 -0
- package/node/prelude/internal/stream_pipeline.js +7 -0
- package/node/prelude/internal/stream_transform.js +10 -0
- package/node/prelude/internal/stream_web_adapters.js +143 -0
- package/node/prelude/internal/streams/add_abort_signal.js +58 -0
- package/node/prelude/internal/streams/compose.js +244 -0
- package/node/prelude/internal/streams/destroy.js +358 -0
- package/node/prelude/internal/streams/duplex.js +199 -0
- package/node/prelude/internal/streams/duplexify.js +378 -0
- package/node/prelude/internal/streams/end_of_stream.js +387 -0
- package/node/prelude/internal/streams/errors.js +216 -0
- package/node/prelude/internal/streams/from.js +211 -0
- package/node/prelude/internal/streams/legacy.js +120 -0
- package/node/prelude/internal/streams/operators.js +375 -0
- package/node/prelude/internal/streams/passthrough.js +45 -0
- package/node/prelude/internal/streams/pipeline.js +468 -0
- package/node/prelude/internal/streams/readable.js +1835 -0
- package/node/prelude/internal/streams/state.js +48 -0
- package/node/prelude/internal/streams/transform.js +203 -0
- package/node/prelude/internal/streams/utils.js +355 -0
- package/node/prelude/internal/streams/validators.js +108 -0
- package/node/prelude/internal/streams/writable.js +1160 -0
- package/node/prelude/internal/structured_clone.js +238 -0
- package/node/prelude/internal/system_errors.js +37 -0
- package/node/prelude/internal/test_runner/mock.js +431 -0
- package/node/prelude/internal/test_runner/reporters.js +404 -0
- package/node/prelude/internal/test_runner/test.js +1571 -0
- package/node/prelude/internal/timers.js +38 -7
- package/node/prelude/internal/timers_global.js +1 -1
- package/node/prelude/internal/tls/common.js +8 -2
- package/node/prelude/internal/tls/wrap.js +3 -15
- package/node/prelude/internal/tls/x509.js +1 -1
- package/node/prelude/internal/tty_read_stream.js +39 -0
- package/node/prelude/internal/tty_streams.js +3 -0
- package/node/prelude/internal/util_debuglog.js +68 -0
- package/node/prelude/internal/util_diff.js +63 -0
- package/node/prelude/internal/util_more.js +111 -0
- package/node/prelude/internal/util_styles.js +76 -0
- package/node/prelude/internal/zlib_engines.js +1 -1
- package/node/prelude/module.js +194 -7
- package/node/prelude/net.js +2 -1
- package/node/prelude/os.js +88 -11
- package/node/prelude/path.js +11 -7
- package/node/prelude/path_posix.js +1 -1
- package/node/prelude/path_win32.js +1 -1
- package/node/prelude/perf_hooks.js +147 -0
- package/node/prelude/process.js +36 -1
- package/node/prelude/punycode.js +188 -0
- package/node/prelude/querystring.js +1 -1
- package/node/prelude/readline.js +8 -0
- package/node/prelude/readline_promises.js +88 -0
- package/node/prelude/repl.js +38 -0
- package/node/prelude/sea.js +23 -0
- package/node/prelude/stream.js +70 -1332
- package/node/prelude/stream_consumers.js +34 -0
- package/node/prelude/stream_promises.js +1 -1
- package/node/prelude/stream_web.js +15 -2
- package/node/prelude/string_decoder.js +1 -1
- package/node/prelude/sys.js +7 -0
- package/node/prelude/test.js +56 -0
- package/node/prelude/test_reporters.js +269 -0
- package/node/prelude/timers.js +7 -84
- package/node/prelude/timers_promises.js +1 -1
- package/node/prelude/tls.js +2 -1
- package/node/prelude/trace_events.js +52 -0
- package/node/prelude/tty.js +10 -4
- package/node/prelude/url.js +88 -27
- package/node/prelude/util.js +121 -5
- package/node/prelude/util_types.js +4 -3
- package/node/prelude/v8.js +814 -0
- package/node/prelude/vm.js +86 -0
- package/node/prelude/wasi.js +10 -0
- package/node/prelude/worker_threads.js +56 -0
- package/node/prelude/zlib.js +58 -25
- package/node/src/host_brotli.c +59 -11
- package/node/src/host_fs.c +342 -11
- package/node/src/host_fswatch.c +170 -0
- package/node/src/host_http.c +143 -20
- package/node/src/host_loop.c +25 -2
- package/node/src/host_net.c +55 -7
- package/node/src/host_os.c +55 -1
- package/node/src/host_proc.c +291 -0
- package/node/src/host_process.c +488 -0
- package/node/src/host_sys.c +64 -2
- package/node/src/host_zlib.c +27 -7
- package/node/src/host_zstd.c +41 -6
- package/node/third_party/hdrhistogram/LICENSE +42 -0
- package/node/third_party/hdrhistogram/README.md +5 -0
- package/node/third_party/libuv/LICENSE +0 -0
- package/node/third_party/libuv/LICENSE-extra +36 -0
- package/node/third_party/libuv/include/uv/aix.h +0 -0
- package/node/third_party/libuv/include/uv/bsd.h +0 -0
- package/node/third_party/libuv/include/uv/darwin.h +0 -0
- package/node/third_party/libuv/include/uv/errno.h +0 -0
- package/node/third_party/libuv/include/uv/linux.h +0 -0
- package/node/third_party/libuv/include/uv/os390.h +0 -0
- package/node/third_party/libuv/include/uv/posix.h +0 -0
- package/node/third_party/libuv/include/uv/sunos.h +0 -0
- package/node/third_party/libuv/include/uv/threadpool.h +0 -0
- package/node/third_party/libuv/include/uv/tree.h +0 -0
- package/node/third_party/libuv/include/uv/unix.h +0 -0
- package/node/third_party/libuv/include/uv/version.h +0 -0
- package/node/third_party/libuv/include/uv/win.h +0 -0
- package/node/third_party/libuv/include/uv.h +0 -0
- package/node/third_party/libuv/src/fs-poll.c +0 -0
- package/node/third_party/libuv/src/heap-inl.h +0 -0
- package/node/third_party/libuv/src/idna.c +0 -0
- package/node/third_party/libuv/src/idna.h +0 -0
- package/node/third_party/libuv/src/inet.c +0 -0
- package/node/third_party/libuv/src/queue.h +0 -0
- package/node/third_party/libuv/src/random.c +0 -0
- package/node/third_party/libuv/src/strscpy.c +0 -0
- package/node/third_party/libuv/src/strscpy.h +0 -0
- package/node/third_party/libuv/src/strtok.c +0 -0
- package/node/third_party/libuv/src/strtok.h +0 -0
- package/node/third_party/libuv/src/thread-common.c +0 -0
- package/node/third_party/libuv/src/threadpool.c +0 -0
- package/node/third_party/libuv/src/timer.c +0 -0
- package/node/third_party/libuv/src/unix/async.c +0 -0
- package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +0 -0
- package/node/third_party/libuv/src/unix/core.c +0 -0
- package/node/third_party/libuv/src/unix/darwin-proctitle.c +0 -0
- package/node/third_party/libuv/src/unix/darwin-stub.h +0 -0
- package/node/third_party/libuv/src/unix/darwin-syscalls.h +0 -0
- package/node/third_party/libuv/src/unix/darwin.c +0 -0
- package/node/third_party/libuv/src/unix/dl.c +0 -0
- package/node/third_party/libuv/src/unix/fs.c +0 -0
- package/node/third_party/libuv/src/unix/fsevents.c +0 -0
- package/node/third_party/libuv/src/unix/getaddrinfo.c +0 -0
- package/node/third_party/libuv/src/unix/getnameinfo.c +0 -0
- package/node/third_party/libuv/src/unix/internal.h +0 -0
- package/node/third_party/libuv/src/unix/kqueue.c +0 -0
- package/node/third_party/libuv/src/unix/linux.c +0 -0
- package/node/third_party/libuv/src/unix/loop-watcher.c +0 -0
- package/node/third_party/libuv/src/unix/loop.c +0 -0
- package/node/third_party/libuv/src/unix/pipe.c +0 -0
- package/node/third_party/libuv/src/unix/poll.c +0 -0
- package/node/third_party/libuv/src/unix/process.c +0 -0
- package/node/third_party/libuv/src/unix/procfs-exepath.c +0 -0
- package/node/third_party/libuv/src/unix/proctitle.c +0 -0
- package/node/third_party/libuv/src/unix/random-devurandom.c +0 -0
- package/node/third_party/libuv/src/unix/random-getentropy.c +0 -0
- package/node/third_party/libuv/src/unix/random-getrandom.c +0 -0
- package/node/third_party/libuv/src/unix/random-sysctl-linux.c +0 -0
- package/node/third_party/libuv/src/unix/signal.c +0 -0
- package/node/third_party/libuv/src/unix/stream.c +0 -0
- package/node/third_party/libuv/src/unix/tcp.c +0 -0
- package/node/third_party/libuv/src/unix/thread.c +0 -0
- package/node/third_party/libuv/src/unix/tty.c +0 -0
- package/node/third_party/libuv/src/unix/udp.c +0 -0
- package/node/third_party/libuv/src/uv-common.c +0 -0
- package/node/third_party/libuv/src/uv-common.h +0 -0
- package/node/third_party/libuv/src/uv-data-getter-setters.c +0 -0
- package/node/third_party/libuv/src/version.c +0 -0
- package/node/third_party/llhttp/LICENSE +0 -0
- package/node/third_party/llhttp/api.c +0 -0
- package/node/third_party/llhttp/http.c +0 -0
- package/node/third_party/llhttp/llhttp.c +0 -0
- package/node/third_party/llhttp/llhttp.h +0 -0
- package/node/third_party/nodejs/LICENSE +47 -0
- package/node/third_party/nodejs/README.md +5 -0
- package/node/third_party/parseargs/LICENSE +21 -0
- package/node/third_party/parseargs/README.md +5 -0
- package/node/third_party/punycode/LICENSE +20 -0
- package/node/third_party/punycode/README.md +5 -0
- package/node/third_party/zlib/LICENSE.chromium +27 -0
- package/package.json +1 -5
- package/prebuilt/darwin-arm64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/darwin-arm64/brotli-7995bbdacc52e51c.a +0 -0
- package/prebuilt/darwin-arm64/uv-72ab666eae197cd8.a +0 -0
- package/prebuilt/darwin-arm64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/darwin-arm64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/darwin-x64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/darwin-x64/brotli-7995bbdacc52e51c.a +0 -0
- package/prebuilt/darwin-x64/uv-72ab666eae197cd8.a +0 -0
- package/prebuilt/darwin-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/darwin-x64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-arm64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-arm64/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-arm64/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-arm64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-arm64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-arm64-musl/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-arm64-musl/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-arm64-musl/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-arm64-musl/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-arm64-musl/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-x64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-x64/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-x64/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-x64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-x64-musl/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-x64-musl/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-x64-musl/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-x64-musl/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-x64-musl/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/win32-x64/boringssl-ce573858472b7fc9.a +0 -0
- package/prebuilt/win32-x64/brotli-20d86a61f30baeb3.a +0 -0
- package/prebuilt/win32-x64/uv-b11bae65d7fced82.a +0 -0
- package/prebuilt/win32-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/win32-x64/zstd-015315ac7c784c73.a +0 -0
- package/runtime/include/js_atoms.gen.h +0 -0
- package/runtime/include/js_atoms.h +1 -1
- package/runtime/include/js_bigint.h +1 -1
- package/runtime/include/js_buffer.h +4 -4
- package/runtime/include/js_builtins.h +41 -3
- package/runtime/include/js_console.h +9 -4
- package/runtime/include/js_convert.h +1 -1
- package/runtime/include/js_core.def +5 -4
- package/runtime/include/js_crypto.h +1 -1
- package/runtime/include/js_error.h +1 -1
- package/runtime/include/js_exception.h +21 -1
- package/runtime/include/js_function.h +33 -9
- package/runtime/include/js_gc.h +172 -30
- package/runtime/include/js_generator.h +2 -2
- package/runtime/include/js_host.h +19 -1
- package/runtime/include/js_jobs.h +5 -5
- package/runtime/include/js_module.h +1 -1
- package/runtime/include/js_object.h +142 -15
- package/runtime/include/js_ops.h +107 -5
- package/runtime/include/js_promise.h +3 -3
- package/runtime/include/js_regexp.h +1 -1
- package/runtime/include/js_runtime.h +0 -0
- package/runtime/include/js_symbol.h +1 -1
- package/runtime/include/js_web.h +2 -1
- package/runtime/include/jscell.h +22 -15
- package/runtime/include/jscontext.h +74 -39
- package/runtime/include/jsnum.h +1 -1
- package/runtime/include/jsstring.h +19 -6
- package/runtime/include/jsvalue.h +7 -3
- package/runtime/src/arguments.c +2 -2
- package/runtime/src/array.c +4 -1
- package/runtime/src/arraybuffer.c +19 -7
- package/runtime/src/async_iter.c +4 -3
- package/runtime/src/atoms.c +1 -1
- package/runtime/src/base64.c +2 -2
- package/runtime/src/bigint.c +1 -1
- package/runtime/src/blob.c +22 -9
- package/runtime/src/boringssl_support.cc +1 -1
- package/runtime/src/buffer.c +299 -91
- package/runtime/src/builtin_table.c +1 -1
- package/runtime/src/builtins.c +30 -4
- package/runtime/src/builtins_util.h +0 -0
- package/runtime/src/collections.c +18 -3
- package/runtime/src/components.c +1 -1
- package/runtime/src/console.c +14 -7
- package/runtime/src/convert.c +0 -0
- package/runtime/src/core_all.c +1 -1
- package/runtime/src/crypto.c +1 -1
- package/runtime/src/crypto_asym.c +1 -1
- package/runtime/src/crypto_bn.c +1 -1
- package/runtime/src/crypto_cipher.c +10 -3
- package/runtime/src/crypto_hash.c +1 -1
- package/runtime/src/crypto_host.c +1 -1
- package/runtime/src/crypto_internal.h +1 -1
- package/runtime/src/crypto_kdf.c +1 -1
- package/runtime/src/crypto_key.c +14 -1
- package/runtime/src/crypto_pkey.c +1 -1
- package/runtime/src/crypto_subtle.c +142 -58
- package/runtime/src/crypto_tls.c +1 -1
- package/runtime/src/date.c +5 -2
- package/runtime/src/domexception.c +2 -2
- package/runtime/src/elements.c +56 -17
- package/runtime/src/elements.h +7 -2
- package/runtime/src/encoding.c +1 -1
- package/runtime/src/error.c +4 -4
- package/runtime/src/events.c +23 -14
- package/runtime/src/exception.c +1 -1
- package/runtime/src/fetch.c +241 -17
- package/runtime/src/function.c +31 -19
- package/runtime/src/gc.c +1716 -207
- package/runtime/src/gc_visit.h +87 -0
- package/runtime/src/generator.c +5 -3
- package/runtime/src/global.c +14 -6
- package/runtime/src/headers.c +10 -10
- package/runtime/src/inspect.c +76 -17
- package/runtime/src/internal.h +5 -2
- package/runtime/src/iterate.c +94 -2
- package/runtime/src/iterator.c +1 -1
- package/runtime/src/jobs.c +11 -5
- package/runtime/src/jsnum.c +2 -2
- package/runtime/src/json.c +1 -1
- package/runtime/src/math.c +9 -1
- package/runtime/src/module.c +3 -3
- package/runtime/src/number.c +0 -0
- package/runtime/src/object.c +107 -74
- package/runtime/src/ops.c +21 -3
- package/runtime/src/os.c +192 -1
- package/runtime/src/os.h +33 -2
- package/runtime/src/process.c +73 -8
- package/runtime/src/promise.c +4 -4
- package/runtime/src/proxy.c +1 -1
- package/runtime/src/reflect.c +1 -1
- package/runtime/src/regexp.c +134 -2
- package/runtime/src/regexp_anchor.h +1 -1
- package/runtime/src/regexp_message.h +1 -1
- package/runtime/src/shape.c +10 -19
- package/runtime/src/shape.h +0 -0
- package/runtime/src/streams.c +22 -8
- package/runtime/src/streams.h +0 -0
- package/runtime/src/string.c +64 -25
- package/runtime/src/string_builtins.c +7 -7
- package/runtime/src/symbol.c +2 -7
- package/runtime/src/test_host.c +3 -3
- package/runtime/src/tls_roots.gen.h +102 -620
- package/runtime/src/typedarray.c +8 -3
- package/runtime/src/tznames.gen.h +2 -1
- package/runtime/src/uri.c +1 -1
- package/runtime/src/url.c +42 -39
- package/runtime/src/weak.c +15 -12
- package/runtime/src/web.c +21 -3
- package/runtime/src/wrapper.c +0 -0
- package/runtime/src/writable.c +7 -6
- package/runtime/third_party/ada-idna/LICENSE-MIT +0 -0
- package/runtime/third_party/ada-idna/README.md +7 -7
- package/runtime/third_party/ada-idna/convert.mjs +89 -27
- package/runtime/third_party/ada-idna/idna.c +30 -31
- package/runtime/third_party/ada-idna/idna.h +0 -0
- package/runtime/third_party/ada-idna/idna_tables.h +2272 -1952
- package/runtime/third_party/boringssl/third_party/fiat/LICENSE +15 -0
- package/runtime/third_party/mozilla-ca/LICENSE +373 -0
- package/runtime/third_party/mozilla-ca/README.md +9 -0
- package/runtime/third_party/nodejs/LICENSE +47 -0
- package/runtime/third_party/nodejs/README.md +7 -0
- package/runtime/third_party/quickjs-dtoa/LICENSE +0 -0
- package/runtime/third_party/quickjs-dtoa/README.md +1 -1
- package/runtime/third_party/quickjs-dtoa/dtoa.c +0 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.h +0 -0
- package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +0 -0
- package/runtime/third_party/quickjs-regexp/LICENSE +0 -0
- package/runtime/third_party/quickjs-regexp/README.md +2 -2
- package/runtime/third_party/quickjs-regexp/cutils.c +0 -0
- package/runtime/third_party/quickjs-regexp/cutils.h +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp.c +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp.h +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode-table.h +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode.c +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode.h +0 -0
- package/runtime/third_party/unicode/LICENSE +39 -0
- package/runtime/third_party/unicode/README.md +9 -0
- package/runtime/third_party/v8-ieee754/LICENSE +0 -0
- package/runtime/third_party/v8-ieee754/LICENSE.fdlibm +10 -0
- package/runtime/third_party/v8-ieee754/README.md +3 -2
- package/runtime/third_party/v8-ieee754/convert.py +0 -0
- package/runtime/third_party/v8-ieee754/ieee754.c +0 -0
- package/runtime/third_party/v8-ieee754/ieee754.h +0 -0
- package/runtime/tools/regexp_compile.c +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// What node:crypto's parts share
|
|
1
|
+
// What node:crypto's parts share: argument checks with Node's errors, encodings
|
|
2
2
|
// through Buffer, and LazyTransform, the stream base of Hash, Hmac and the ciphers (a Transform
|
|
3
3
|
// set up only when a stream property is first used, as Node's is).
|
|
4
|
-
import
|
|
4
|
+
import Transform from "../streams/transform.js";
|
|
5
5
|
import { codeError, invalidArgType } from "../errors.js";
|
|
6
6
|
|
|
7
7
|
export const kHandle = Symbol("kHandle");
|
|
@@ -60,7 +60,6 @@ function makeGetter(name) {
|
|
|
60
60
|
return function () {
|
|
61
61
|
Transform.call(this, this._options);
|
|
62
62
|
this._writableState.decodeStrings = false;
|
|
63
|
-
if (!this._options || !this._options.defaultEncoding) this._writableState.defaultEncoding = "buffer";
|
|
64
63
|
return this[name];
|
|
65
64
|
};
|
|
66
65
|
}
|
|
@@ -71,6 +70,7 @@ function makeSetter(name) {
|
|
|
71
70
|
};
|
|
72
71
|
}
|
|
73
72
|
|
|
74
|
-
|
|
73
|
+
/* Node 24's lib/internal/streams/lazy_transform.js: the two states (Transform keeps no third) */
|
|
74
|
+
for (const name of ["_readableState", "_writableState"]) {
|
|
75
75
|
Object.defineProperty(LazyTransform.prototype, name, { get: makeGetter(name), set: makeSetter(name), configurable: true, enumerable: true });
|
|
76
76
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// A .env file's variables, as Node's Dotenv::ParseContent reads them (util.parseEnv, and
|
|
2
|
+
// process.loadEnvFile): KEY=value lines, `export ` before a key, # comments, values in double
|
|
3
|
+
// quotes (\n becomes a newline, and they may span lines), single quotes or backticks. Linked into
|
|
4
|
+
// programs that name parseEnv (internal/features.js).
|
|
5
|
+
// Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
|
|
6
|
+
import { validateString } from "./errors.js";
|
|
7
|
+
import { features } from "./features.js";
|
|
8
|
+
|
|
9
|
+
const isSpace = (c) => c === " " || c === "\t" || c === "\n" || c === "\r" || c === "\f" || c === "\v";
|
|
10
|
+
|
|
11
|
+
function trimSpaces(s) {
|
|
12
|
+
let start = 0;
|
|
13
|
+
let end = s.length;
|
|
14
|
+
while (start < end && isSpace(s[start])) start++;
|
|
15
|
+
while (end > start && isSpace(s[end - 1])) end--;
|
|
16
|
+
return s.slice(start, end);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The variables, in an object (a later definition replaces an earlier one). */
|
|
20
|
+
export function parseDotenv(input) {
|
|
21
|
+
const store = Object.create(null);
|
|
22
|
+
let content = trimSpaces(String(input).replaceAll("\r", ""));
|
|
23
|
+
/* what's left after the next newline, or nothing */
|
|
24
|
+
const afterLine = (from = 0) => {
|
|
25
|
+
const newline = content.indexOf("\n", from);
|
|
26
|
+
return newline === -1 ? null : content.slice(newline + 1);
|
|
27
|
+
};
|
|
28
|
+
while (content.length > 0) {
|
|
29
|
+
if (content[0] === "\n" || content[0] === "#") { /* an empty line, or a comment */
|
|
30
|
+
content = afterLine() ?? "";
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const equalOrNewline = content.search(/[=\n]/);
|
|
34
|
+
if (equalOrNewline === -1 || content[equalOrNewline] === "\n") { /* no `=` on the line */
|
|
35
|
+
const rest = afterLine();
|
|
36
|
+
if (rest === null) break;
|
|
37
|
+
content = trimSpaces(rest);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
let key = trimSpaces(content.slice(0, equalOrNewline));
|
|
41
|
+
content = content.slice(equalOrNewline + 1);
|
|
42
|
+
if (content.length === 0 || content[0] === "\n") {
|
|
43
|
+
store[key] = "";
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
content = trimSpaces(content);
|
|
47
|
+
if (key.length === 0) {
|
|
48
|
+
const rest = afterLine();
|
|
49
|
+
if (rest === null) break;
|
|
50
|
+
content = trimSpaces(rest);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (key.startsWith("export ")) key = trimSpaces(key.slice(7));
|
|
54
|
+
if (content.length === 0 || content[0] === "\n") {
|
|
55
|
+
store[key] = "";
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
content = trimSpaces(content);
|
|
59
|
+
const quote = content[0];
|
|
60
|
+
if (quote === '"') {
|
|
61
|
+
const closing = content.indexOf('"', 1);
|
|
62
|
+
if (closing !== -1) {
|
|
63
|
+
store[key] = content.slice(1, closing).replaceAll("\\n", "\n");
|
|
64
|
+
content = afterLine(closing + 1) ?? "";
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (quote === "'" || quote === '"' || quote === "`") {
|
|
69
|
+
const closing = content.indexOf(quote, 1);
|
|
70
|
+
if (closing === -1) { /* unclosed: the rest of the line, quote and all */
|
|
71
|
+
const newline = content.indexOf("\n");
|
|
72
|
+
if (newline === -1) {
|
|
73
|
+
store[key] = content;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
store[key] = content.slice(0, newline);
|
|
77
|
+
content = content.slice(newline);
|
|
78
|
+
} else {
|
|
79
|
+
store[key] = content.slice(1, closing);
|
|
80
|
+
content = afterLine(closing + 1) ?? "";
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
const newline = content.indexOf("\n");
|
|
84
|
+
let value = newline === -1 ? content : content.slice(0, newline);
|
|
85
|
+
const hash = value.indexOf("#");
|
|
86
|
+
if (hash !== -1) value = value.slice(0, hash);
|
|
87
|
+
store[key] = trimSpaces(value);
|
|
88
|
+
content = newline === -1 ? "" : content.slice(newline + 1);
|
|
89
|
+
}
|
|
90
|
+
content = trimSpaces(content);
|
|
91
|
+
}
|
|
92
|
+
return store;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
features.parseEnv = (content) => {
|
|
96
|
+
validateString(content, "content");
|
|
97
|
+
return { ...parseDotenv(content) };
|
|
98
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// Node's error shapes
|
|
1
|
+
// Node's error shapes: argument errors with a `code`, and system errors built
|
|
2
2
|
// from the -errno that host primitives return.
|
|
3
3
|
import { errnoMessage, errnoName, utilInspect } from "visaljs:host";
|
|
4
4
|
|
|
5
5
|
/** How Node describes a bad argument: "Received type number (1)", "Received undefined", … */
|
|
6
6
|
function received(value) {
|
|
7
7
|
if (value == null) return " Received " + value;
|
|
8
|
-
if (typeof value === "function") return " Received function " +
|
|
8
|
+
if (typeof value === "function") return " Received function " + value.name; /* determineSpecificType: empty when anonymous */
|
|
9
9
|
if (typeof value === "object") {
|
|
10
10
|
const ctor = value.constructor;
|
|
11
11
|
return ctor && ctor.name ? " Received an instance of " + ctor.name : " Received " + String(value);
|
|
@@ -17,9 +17,23 @@ function received(value) {
|
|
|
17
17
|
|
|
18
18
|
function withCode(error, code) {
|
|
19
19
|
Object.defineProperty(error, "code", { value: code, writable: true, enumerable: true, configurable: true });
|
|
20
|
+
/* Node's NodeError: String(error) shows the code, "TypeError [ERR_X]: …" */
|
|
21
|
+
Object.defineProperty(error, "toString", { value: nodeErrorToString(code), writable: true, enumerable: false, configurable: true });
|
|
20
22
|
return error;
|
|
21
23
|
}
|
|
22
24
|
|
|
25
|
+
const toStrings = new Map();
|
|
26
|
+
function nodeErrorToString(code) {
|
|
27
|
+
let fn = toStrings.get(code);
|
|
28
|
+
if (fn === undefined) {
|
|
29
|
+
fn = function toString() {
|
|
30
|
+
return `${this.name} [${code}]: ${this.message}`;
|
|
31
|
+
};
|
|
32
|
+
toStrings.set(code, fn);
|
|
33
|
+
}
|
|
34
|
+
return fn;
|
|
35
|
+
}
|
|
36
|
+
|
|
23
37
|
/** An error of class Ctor with Node's `code`: codeError(TypeError, "ERR_X", "message"). */
|
|
24
38
|
export function codeError(Ctor, code, message) {
|
|
25
39
|
return withCode(new Ctor(message), code);
|
|
@@ -45,14 +59,16 @@ export function notSupported(what) {
|
|
|
45
59
|
}
|
|
46
60
|
|
|
47
61
|
/** A failed system call: `ENOENT: no such file or directory, open 'x'`, with errno, code,
|
|
48
|
-
* syscall and path, as Node's uvException builds it. */
|
|
49
|
-
export function systemError(errno, syscall, path) {
|
|
62
|
+
* syscall and path (and dest: `rename 'a' -> 'b'`), as Node's uvException builds it. */
|
|
63
|
+
export function systemError(errno, syscall, path, dest) {
|
|
50
64
|
const code = errnoName(errno);
|
|
51
|
-
const error = new Error(code + ": " + errnoMessage(errno) + ", " + syscall + (path === undefined ? "" : " '" + path + "'")
|
|
65
|
+
const error = new Error(code + ": " + errnoMessage(errno) + ", " + syscall + (path === undefined ? "" : " '" + path + "'") +
|
|
66
|
+
(dest === undefined ? "" : " -> '" + dest + "'"));
|
|
52
67
|
error.errno = errno;
|
|
53
68
|
error.code = code;
|
|
54
69
|
error.syscall = syscall;
|
|
55
70
|
if (path !== undefined) error.path = path;
|
|
71
|
+
if (dest !== undefined) error.dest = dest;
|
|
56
72
|
return error;
|
|
57
73
|
}
|
|
58
74
|
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// node:events' functions on emitters and EventTargets (getEventListeners, the max-listener
|
|
2
|
+
// counts, addAbortListener) and EventEmitterAsyncResource. Linked into programs that name them
|
|
3
|
+
// (internal/features.js).
|
|
4
|
+
import { AsyncResource } from "../async_hooks.js";
|
|
5
|
+
import { EventEmitter, EventEmitterAsyncResource as EventEmitterAsyncResourceWrapper } from "../events.js";
|
|
6
|
+
import { invalidArgType } from "./errors.js";
|
|
7
|
+
import { features, provideClass } from "./features.js";
|
|
8
|
+
|
|
9
|
+
const kMaxEventTargetListeners = Symbol("events.maxEventTargetListeners");
|
|
10
|
+
const isEventTarget = (target) => typeof target?.addEventListener === "function" && typeof target?.on !== "function";
|
|
11
|
+
|
|
12
|
+
function validateSignal(signal, name) {
|
|
13
|
+
if (signal !== undefined && (signal === null || typeof signal !== "object" || !("aborted" in signal))) {
|
|
14
|
+
throw invalidArgType(name, "an instance of AbortSignal", signal);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** An emitter's listeners for the event, or an EventTarget's (as its listeners() would). */
|
|
19
|
+
function getEventListeners(emitterOrTarget, type) {
|
|
20
|
+
if (typeof emitterOrTarget?.listeners === "function") return emitterOrTarget.listeners(type);
|
|
21
|
+
if (isEventTarget(emitterOrTarget)) {
|
|
22
|
+
const e = new Error("getEventListeners of an EventTarget is not supported by visaljs yet");
|
|
23
|
+
e.code = "ERR_VISALJS_UNSUPPORTED";
|
|
24
|
+
throw e;
|
|
25
|
+
}
|
|
26
|
+
throw invalidArgType("emitter", "an instance of EventEmitter or EventTarget", emitterOrTarget);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getMaxListeners(emitterOrTarget) {
|
|
30
|
+
if (typeof emitterOrTarget?.getMaxListeners === "function") return emitterOrTarget.getMaxListeners();
|
|
31
|
+
if (isEventTarget(emitterOrTarget)) return emitterOrTarget[kMaxEventTargetListeners] ?? EventEmitter.defaultMaxListeners;
|
|
32
|
+
throw invalidArgType("emitter", "an instance of EventEmitter or EventTarget", emitterOrTarget);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** setMaxListeners(n, ...targets): theirs, or with none the default for new ones. */
|
|
36
|
+
function setMaxListeners(n = EventEmitter.defaultMaxListeners, ...eventTargets) {
|
|
37
|
+
if (typeof n !== "number") throw invalidArgType("setMaxListeners", "of type number", n);
|
|
38
|
+
if (n < 0 || Number.isNaN(n)) {
|
|
39
|
+
const e = new RangeError(`The value of "setMaxListeners" is out of range. It must be >= 0. Received ${n}`);
|
|
40
|
+
e.code = "ERR_OUT_OF_RANGE";
|
|
41
|
+
throw e;
|
|
42
|
+
}
|
|
43
|
+
if (eventTargets.length === 0) EventEmitter.defaultMaxListeners = n;
|
|
44
|
+
for (const target of eventTargets) {
|
|
45
|
+
if (typeof target?.setMaxListeners === "function") target.setMaxListeners(n);
|
|
46
|
+
else if (isEventTarget(target)) target[kMaxEventTargetListeners] = n;
|
|
47
|
+
else throw invalidArgType("eventTargets", "an instance of EventEmitter or EventTarget", target);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
/** Calls listener once the signal aborts (on a later microtask if it has), until disposed. */
|
|
53
|
+
function addAbortListener(signal, listener) {
|
|
54
|
+
if (signal === undefined) throw invalidArgType("signal", "an instance of AbortSignal", signal);
|
|
55
|
+
validateSignal(signal, "signal");
|
|
56
|
+
if (typeof listener !== "function") throw invalidArgType("listener", "of type function", listener);
|
|
57
|
+
let remove;
|
|
58
|
+
if (signal.aborted) queueMicrotask(() => listener());
|
|
59
|
+
else {
|
|
60
|
+
signal.addEventListener("abort", listener, { once: true });
|
|
61
|
+
remove = () => signal.removeEventListener("abort", listener);
|
|
62
|
+
}
|
|
63
|
+
return { __proto__: null, [Symbol.dispose ?? Symbol.for("nodejs.dispose")]() {
|
|
64
|
+
remove?.();
|
|
65
|
+
} };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
/* the AsyncResource of an EventEmitterAsyncResource, which knows its emitter */
|
|
70
|
+
class EventEmitterReferencingAsyncResource extends AsyncResource {
|
|
71
|
+
#emitter;
|
|
72
|
+
constructor(emitter, type, options) {
|
|
73
|
+
super(type, options);
|
|
74
|
+
this.#emitter = emitter;
|
|
75
|
+
}
|
|
76
|
+
get eventEmitter() {
|
|
77
|
+
return this.#emitter;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** An EventEmitter whose listeners run in the async context it was created in. */
|
|
82
|
+
class EventEmitterAsyncResource extends EventEmitter {
|
|
83
|
+
#resource;
|
|
84
|
+
constructor(options = undefined) {
|
|
85
|
+
let name;
|
|
86
|
+
if (typeof options === "string") {
|
|
87
|
+
name = options;
|
|
88
|
+
options = undefined;
|
|
89
|
+
} else {
|
|
90
|
+
if ((new.target === EventEmitterAsyncResource || new.target === EventEmitterAsyncResourceWrapper) && typeof options?.name !== "string") {
|
|
91
|
+
throw invalidArgType("options.name", "of type string", options?.name);
|
|
92
|
+
}
|
|
93
|
+
name = options?.name || new.target.name;
|
|
94
|
+
}
|
|
95
|
+
super(options);
|
|
96
|
+
this.#resource = new EventEmitterReferencingAsyncResource(this, name, options);
|
|
97
|
+
}
|
|
98
|
+
emit(event, ...args) {
|
|
99
|
+
return this.#resource.runInAsyncScope(EventEmitter.prototype.emit, this, event, ...args);
|
|
100
|
+
}
|
|
101
|
+
emitDestroy() {
|
|
102
|
+
this.#resource.emitDestroy();
|
|
103
|
+
}
|
|
104
|
+
get asyncId() {
|
|
105
|
+
return this.#resource.asyncId();
|
|
106
|
+
}
|
|
107
|
+
get triggerAsyncId() {
|
|
108
|
+
return this.#resource.triggerAsyncId();
|
|
109
|
+
}
|
|
110
|
+
get asyncResource() {
|
|
111
|
+
return this.#resource;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
Object.assign(features, { getEventListeners, getMaxListeners, setMaxListeners, addAbortListener });
|
|
116
|
+
provideClass(EventEmitterAsyncResourceWrapper, EventEmitterAsyncResource);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// events.on: an emitter's or EventTarget's events as an async iterator. Linked into programs that
|
|
2
|
+
// name it (internal/features.js).
|
|
3
|
+
import { invalidArgType } from "./errors.js";
|
|
4
|
+
import { features } from "./features.js";
|
|
5
|
+
|
|
6
|
+
const isEventTarget = (target) => typeof target?.addEventListener === "function" && typeof target?.on !== "function";
|
|
7
|
+
|
|
8
|
+
function validateSignal(signal, name) {
|
|
9
|
+
if (signal !== undefined && (signal === null || typeof signal !== "object" || !("aborted" in signal))) {
|
|
10
|
+
throw invalidArgType(name, "an instance of AbortSignal", signal);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Node's AbortError: name and code, the signal's reason as its cause */
|
|
15
|
+
function abortError(signal) {
|
|
16
|
+
const error = new Error("The operation was aborted", { cause: signal?.reason });
|
|
17
|
+
error.code = "ABORT_ERR";
|
|
18
|
+
error.name = "AbortError";
|
|
19
|
+
return error;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** events.on(emitter, name[, { signal, close }]): the events as an async iterator of their
|
|
23
|
+
* arguments, buffered until read; an 'error' ends it by throwing, a `close` event by finishing. */
|
|
24
|
+
function on(emitter, event, options = {}) {
|
|
25
|
+
const signal = options?.signal;
|
|
26
|
+
validateSignal(signal, "options.signal");
|
|
27
|
+
if (signal?.aborted) throw abortError(signal);
|
|
28
|
+
const close = options?.close ?? [];
|
|
29
|
+
const unconsumedEvents = [];
|
|
30
|
+
const unconsumedPromises = [];
|
|
31
|
+
let error = null;
|
|
32
|
+
let finished = false;
|
|
33
|
+
const listening = [];
|
|
34
|
+
const listen = (name, handler) => {
|
|
35
|
+
if (isEventTarget(emitter)) emitter.addEventListener(name, handler);
|
|
36
|
+
else emitter.on(name, handler);
|
|
37
|
+
listening.push([name, handler]);
|
|
38
|
+
};
|
|
39
|
+
const result = (value, done) => ({ value, done });
|
|
40
|
+
|
|
41
|
+
const iterator = {
|
|
42
|
+
next() {
|
|
43
|
+
const value = unconsumedEvents.shift();
|
|
44
|
+
if (value) return Promise.resolve(result(value, false));
|
|
45
|
+
if (error) {
|
|
46
|
+
const p = Promise.reject(error);
|
|
47
|
+
error = null;
|
|
48
|
+
return p;
|
|
49
|
+
}
|
|
50
|
+
if (finished) return closeHandler();
|
|
51
|
+
return new Promise((resolve, reject) => unconsumedPromises.push({ resolve, reject }));
|
|
52
|
+
},
|
|
53
|
+
return() {
|
|
54
|
+
return closeHandler();
|
|
55
|
+
},
|
|
56
|
+
throw(err) {
|
|
57
|
+
if (!(err instanceof Error)) throw invalidArgType("EventEmitter.AsyncIterator", "an instance of Error", err);
|
|
58
|
+
errorHandler(err);
|
|
59
|
+
},
|
|
60
|
+
[Symbol.asyncIterator]() {
|
|
61
|
+
return this;
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
function eventHandler(...args) {
|
|
66
|
+
const pending = unconsumedPromises.shift();
|
|
67
|
+
if (pending) pending.resolve(result(args, false));
|
|
68
|
+
else unconsumedEvents.push(args);
|
|
69
|
+
}
|
|
70
|
+
function errorHandler(err) {
|
|
71
|
+
finished = true;
|
|
72
|
+
const pending = unconsumedPromises.shift();
|
|
73
|
+
if (pending) pending.reject(err);
|
|
74
|
+
else error = err;
|
|
75
|
+
iterator.return();
|
|
76
|
+
}
|
|
77
|
+
function abortListener() {
|
|
78
|
+
errorHandler(abortError(signal));
|
|
79
|
+
}
|
|
80
|
+
function closeHandler() {
|
|
81
|
+
for (const [name, handler] of listening) {
|
|
82
|
+
if (isEventTarget(emitter)) emitter.removeEventListener(name, handler);
|
|
83
|
+
else emitter.removeListener(name, handler);
|
|
84
|
+
}
|
|
85
|
+
listening.length = 0;
|
|
86
|
+
signal?.removeEventListener("abort", abortListener);
|
|
87
|
+
finished = true;
|
|
88
|
+
const done = result(undefined, true);
|
|
89
|
+
while (unconsumedPromises.length) unconsumedPromises.shift().resolve(done);
|
|
90
|
+
return Promise.resolve(done);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
listen(event, eventHandler);
|
|
94
|
+
if (event !== "error" && !isEventTarget(emitter)) listen("error", errorHandler);
|
|
95
|
+
for (const name of close) listen(name, closeHandler);
|
|
96
|
+
signal?.addEventListener("abort", abortListener, { once: true });
|
|
97
|
+
return iterator;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
features.on = on;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Features linked only into programs whose code names them (implicitModules in node/index.ts):
|
|
2
|
+
// each one's module sets its implementation here when it runs, and the public function looks it
|
|
3
|
+
// up. A feature named only at run time (computed, never in the code's text) isn't there: its
|
|
4
|
+
// function throws ERR_VISALJS_UNSUPPORTED.
|
|
5
|
+
import { notSupported } from "./errors.js";
|
|
6
|
+
|
|
7
|
+
export const features = Object.create(null);
|
|
8
|
+
|
|
9
|
+
/** A feature's implementation, or ERR_VISALJS_UNSUPPORTED. */
|
|
10
|
+
export function feature(name) {
|
|
11
|
+
const f = features[name];
|
|
12
|
+
if (f === undefined) throw notSupported(`${name} (named only at run time: build with --all-features to link it)`);
|
|
13
|
+
return f;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** A function of a feature's, which calls the implementation the feature's module set. */
|
|
17
|
+
export function lazyFunction(name, length = 0) {
|
|
18
|
+
const f = function (...args) {
|
|
19
|
+
return feature(name).apply(this, args);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(f, "name", { value: name });
|
|
22
|
+
Object.defineProperty(f, "length", { value: length });
|
|
23
|
+
return f;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** A class the program may construct, as a function the feature's module gives its prototype:
|
|
27
|
+
* `new Wrapper(…)` builds the feature's class, and instanceof holds. */
|
|
28
|
+
export function lazyClass(name) {
|
|
29
|
+
const Wrapper = function (...args) {
|
|
30
|
+
if (!new.target) throw new TypeError(`Class constructor ${name} cannot be invoked without 'new'`);
|
|
31
|
+
return Reflect.construct(feature(name), args, new.target);
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(Wrapper, "name", { value: name });
|
|
34
|
+
return Wrapper;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** A constructor function (not a class) of a feature's, as Node's stream classes are: `new Ctor(…)`,
|
|
38
|
+
* a class extending it, and the pre-class `Ctor.call(this, …)` with util.inherits all reach the
|
|
39
|
+
* feature's function, with `this` as given. Its prototype is the feature's (provideClass). */
|
|
40
|
+
export function lazyConstructor(name, length = 1) {
|
|
41
|
+
const Wrapper = function (...args) {
|
|
42
|
+
return Reflect.apply(feature(name), this, args);
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(Wrapper, "name", { value: name });
|
|
45
|
+
Object.defineProperty(Wrapper, "length", { value: length });
|
|
46
|
+
return Wrapper;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Called by a feature's module for a lazyClass: the wrapper takes the class's prototype. */
|
|
50
|
+
export function provideClass(Wrapper, Class) {
|
|
51
|
+
features[Wrapper.name] = Class;
|
|
52
|
+
Wrapper.prototype = Class.prototype;
|
|
53
|
+
Object.defineProperty(Class.prototype, "constructor", { value: Wrapper, writable: true, configurable: true });
|
|
54
|
+
Object.setPrototypeOf(Wrapper, Object.getPrototypeOf(Class));
|
|
55
|
+
}
|