visaljs 0.0.7 → 0.0.9
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 +68 -4
- package/THIRD_PARTY_LICENSES +1216 -0
- package/cli.js +4461 -321
- package/node/include/js_node.h +57 -1
- package/node/include/js_uv.h +8 -1
- package/node/prelude/_http_agent.js +5 -0
- package/node/prelude/_http_server.js +7 -0
- 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 +8 -2
- package/node/prelude/domain.js +115 -0
- package/node/prelude/events.js +148 -16
- package/node/prelude/fs.js +1138 -151
- package/node/prelude/fs_promises.js +117 -11
- package/node/prelude/http.js +784 -301
- package/node/prelude/http2.js +1 -1
- package/node/prelude/https.js +159 -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 +113 -0
- package/node/prelude/internal/events_on.js +100 -0
- package/node/prelude/internal/features.js +72 -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 +114 -2
- package/node/prelude/internal/http_symbols.js +3 -0
- package/node/prelude/internal/mime.js +249 -0
- package/node/prelude/internal/net.js +1 -0
- package/node/prelude/internal/net_bound.js +123 -0
- package/node/prelude/internal/net_onread.js +73 -0
- package/node/prelude/internal/net_tos.js +54 -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 +125 -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 +5 -16
- 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 +219 -8
- package/node/prelude/net.js +197 -49
- 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 +151 -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 +292 -39
- package/node/src/host_loop.c +25 -2
- package/node/src/host_net.c +130 -16
- 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 -1
- 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 +5 -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 +5 -1
- package/runtime/include/jscell.h +22 -15
- package/runtime/include/jscontext.h +82 -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 +38 -4
- 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 +42 -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 +1720 -211
- 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 +9 -6
- 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 +700 -11
- package/runtime/src/regexp_anchor.h +1 -1
- package/runtime/src/regexp_message.h +1 -1
- package/runtime/src/shape.c +78 -20
- 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 +110 -36
- 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
|
@@ -2,15 +2,85 @@
|
|
|
2
2
|
// at most maxSockets each, the rest of the requests queued; with keepAlive, a socket whose
|
|
3
3
|
// response is done goes to freeSockets (unref'd, so it doesn't keep the program running) for
|
|
4
4
|
// the next request to the same origin, until the agent's timeout or the server's Keep-Alive hint.
|
|
5
|
+
// Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
|
|
6
|
+
import { httpGuard } from "visaljs:host";
|
|
5
7
|
import { EventEmitter } from "../events.js";
|
|
6
8
|
import { createConnection } from "../net.js";
|
|
7
9
|
import { invalidArgType, invalidArgValue, outOfRange } from "./errors.js";
|
|
10
|
+
import { isIP } from "./net.js";
|
|
8
11
|
|
|
9
12
|
function freeSocketErrorListener() {
|
|
10
13
|
this.destroy();
|
|
11
14
|
this.emit("agentRemove");
|
|
12
15
|
}
|
|
13
16
|
|
|
17
|
+
/* Node's free socket data guard: bytes a socket reads while it waits in the pool (no request on it)
|
|
18
|
+
* would be taken for the next request's response; the socket is destroyed instead. The bytes are
|
|
19
|
+
* caught in C (httpGuard), before they reach the socket's stream; attaching the next request's
|
|
20
|
+
* parser takes the guard off. */
|
|
21
|
+
const guardedSockets = new Map(); /* the guarded sockets, by their handle's id */
|
|
22
|
+
|
|
23
|
+
function onGuardedData(id) {
|
|
24
|
+
const socket = guardedSockets.get(id);
|
|
25
|
+
guardedSockets.delete(id);
|
|
26
|
+
socket?.destroy();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Node's maybeEnableKeylog: the sockets' keylog events become the agent's */
|
|
30
|
+
function maybeEnableKeylog(eventName) {
|
|
31
|
+
if (eventName !== "keylog") return;
|
|
32
|
+
this.removeListener("newListener", maybeEnableKeylog);
|
|
33
|
+
const emit = this.emit.bind(this);
|
|
34
|
+
this._onKeylog = function onkeylog(keylog) {
|
|
35
|
+
emit("keylog", keylog, this); /* this: the socket */
|
|
36
|
+
};
|
|
37
|
+
for (const set of [this.freeSockets, this.sockets]) {
|
|
38
|
+
for (const sockets of Object.values(set)) for (const socket of sockets) socket.on("keylog", this._onKeylog);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function installFreeSocketDataGuard(socket) {
|
|
43
|
+
/* a TLS socket's reads are records (session tickets, alerts) before they're data: its own */
|
|
44
|
+
if (socket.encrypted) return;
|
|
45
|
+
if (socket.readableLength > 0) {
|
|
46
|
+
socket.destroy();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (socket.connecting) {
|
|
50
|
+
if (!socket._freeGuardConnect) { /* once: a socket may come back to the pool before it connects */
|
|
51
|
+
socket._freeGuardConnect = () => {
|
|
52
|
+
socket._freeGuardConnect = undefined;
|
|
53
|
+
installFreeSocketDataGuard(socket);
|
|
54
|
+
};
|
|
55
|
+
socket.once("connect", socket._freeGuardConnect);
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const id = socket._handle;
|
|
60
|
+
if (typeof id === "number" && httpGuard(id, onGuardedData)) {
|
|
61
|
+
guardedSockets.set(id, socket);
|
|
62
|
+
socket._freeGuardId = id;
|
|
63
|
+
/* one listener while it's guarded, taken off when it's reused (a kept-alive socket comes back
|
|
64
|
+
* to the pool after each request) */
|
|
65
|
+
socket._freeGuardClose = () => removeFreeSocketDataGuard(socket);
|
|
66
|
+
socket.once("close", socket._freeGuardClose);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function removeFreeSocketDataGuard(socket) {
|
|
71
|
+
if (socket._freeGuardConnect) {
|
|
72
|
+
socket.removeListener("connect", socket._freeGuardConnect);
|
|
73
|
+
socket._freeGuardConnect = undefined;
|
|
74
|
+
}
|
|
75
|
+
if (socket._freeGuardClose) {
|
|
76
|
+
socket.removeListener("close", socket._freeGuardClose);
|
|
77
|
+
socket._freeGuardClose = undefined;
|
|
78
|
+
}
|
|
79
|
+
const id = socket._freeGuardId;
|
|
80
|
+
if (id !== undefined && guardedSockets.get(id) === socket) guardedSockets.delete(id);
|
|
81
|
+
socket._freeGuardId = undefined;
|
|
82
|
+
}
|
|
83
|
+
|
|
14
84
|
export function Agent(options) {
|
|
15
85
|
if (!(this instanceof Agent)) return new Agent(options);
|
|
16
86
|
EventEmitter.call(this);
|
|
@@ -27,6 +97,9 @@ export function Agent(options) {
|
|
|
27
97
|
this.maxSockets = this.options.maxSockets || Agent.defaultMaxSockets;
|
|
28
98
|
this.maxFreeSockets = this.options.maxFreeSockets || 256;
|
|
29
99
|
this.scheduling = this.options.scheduling || "lifo";
|
|
100
|
+
/* what the server's Keep-Alive timeout is cut by, so the socket isn't reused as the server closes it */
|
|
101
|
+
const buffer = this.options.agentKeepAliveTimeoutBuffer;
|
|
102
|
+
this.agentKeepAliveTimeoutBuffer = typeof buffer === "number" && buffer >= 0 && Number.isFinite(buffer) ? buffer : 1000;
|
|
30
103
|
this.maxTotalSockets = this.options.maxTotalSockets;
|
|
31
104
|
this.totalSocketCount = 0;
|
|
32
105
|
if (this.scheduling !== "fifo" && this.scheduling !== "lifo") throw invalidArgValue("scheduling", "must be one of: 'fifo', 'lifo'", this.scheduling);
|
|
@@ -37,6 +110,9 @@ export function Agent(options) {
|
|
|
37
110
|
this.maxTotalSockets = Infinity;
|
|
38
111
|
}
|
|
39
112
|
|
|
113
|
+
/* keylog events only once someone listens: then every socket's, the existing ones' too */
|
|
114
|
+
this.on("newListener", maybeEnableKeylog);
|
|
115
|
+
|
|
40
116
|
/* a socket whose request is done: the next queued request's, kept alive, or destroyed */
|
|
41
117
|
this.on("free", (socket, options) => {
|
|
42
118
|
const name = this.getName(options);
|
|
@@ -68,6 +144,7 @@ export function Agent(options) {
|
|
|
68
144
|
socket._httpMessage = null;
|
|
69
145
|
this.removeSocket(socket, options);
|
|
70
146
|
socket.once("error", freeSocketErrorListener);
|
|
147
|
+
installFreeSocketDataGuard(socket);
|
|
71
148
|
freeSockets.push(socket);
|
|
72
149
|
});
|
|
73
150
|
}
|
|
@@ -90,11 +167,34 @@ Agent.prototype.getName = function getName(options = {}) {
|
|
|
90
167
|
return name;
|
|
91
168
|
};
|
|
92
169
|
|
|
170
|
+
/* the TLS server name (SNI): the Host header's host, else the host; never an IP address. Plain
|
|
171
|
+
* HTTP ignores it; https's agent reads it, and its sessions are keyed by it (Node's) */
|
|
172
|
+
function calculateServerName(options, req) {
|
|
173
|
+
let servername = options.host;
|
|
174
|
+
const hostHeader = req.getHeader("host");
|
|
175
|
+
if (hostHeader) {
|
|
176
|
+
if (typeof hostHeader !== "string") throw invalidArgType("options.headers.host", "of type string", hostHeader);
|
|
177
|
+
if (hostHeader.startsWith("[")) {
|
|
178
|
+
const index = hostHeader.indexOf("]");
|
|
179
|
+
servername = index === -1 ? hostHeader : hostHeader.slice(1, index);
|
|
180
|
+
} else {
|
|
181
|
+
servername = hostHeader.split(":", 1)[0];
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (isIP(servername)) servername = "";
|
|
185
|
+
return servername;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function normalizeServerName(options, req) {
|
|
189
|
+
if (!options.servername && options.servername !== "") options.servername = calculateServerName(options, req);
|
|
190
|
+
}
|
|
191
|
+
|
|
93
192
|
/* a request: a free socket, a new one (under maxSockets), or the queue */
|
|
94
193
|
Agent.prototype.addRequest = function addRequest(req, options, port, localAddress) {
|
|
95
194
|
if (typeof options === "string") options = { __proto__: null, host: options, port, localAddress };
|
|
96
195
|
options = { __proto__: null, ...options, ...this.options };
|
|
97
196
|
if (options.socketPath) options.path = options.socketPath;
|
|
197
|
+
normalizeServerName(options, req);
|
|
98
198
|
const name = this.getName(options);
|
|
99
199
|
this.sockets[name] ||= [];
|
|
100
200
|
const freeSockets = this.freeSockets[name];
|
|
@@ -106,7 +206,12 @@ Agent.prototype.addRequest = function addRequest(req, options, port, localAddres
|
|
|
106
206
|
}
|
|
107
207
|
const freeLen = freeSockets ? freeSockets.length : 0;
|
|
108
208
|
const sockLen = freeLen + this.sockets[name].length;
|
|
209
|
+
/* a reused socket takes the request's highWaterMark, as Node's */
|
|
210
|
+
if (socket && options.highWaterMark != null && socket.writableHighWaterMark !== options.highWaterMark) {
|
|
211
|
+
socket._writableState.highWaterMark = options.highWaterMark;
|
|
212
|
+
}
|
|
109
213
|
if (socket) {
|
|
214
|
+
removeFreeSocketDataGuard(socket);
|
|
110
215
|
this.reuseSocket(socket, req);
|
|
111
216
|
setRequestSocket(this, req, socket);
|
|
112
217
|
this.sockets[name].push(socket);
|
|
@@ -125,6 +230,7 @@ Agent.prototype.addRequest = function addRequest(req, options, port, localAddres
|
|
|
125
230
|
Agent.prototype.createSocket = function createSocket(req, options, cb) {
|
|
126
231
|
options = { __proto__: null, ...options, ...this.options };
|
|
127
232
|
if (options.socketPath) options.path = options.socketPath;
|
|
233
|
+
normalizeServerName(options, req);
|
|
128
234
|
const name = this.getName(options);
|
|
129
235
|
options._agentKey = name;
|
|
130
236
|
options.encoding = null;
|
|
@@ -137,6 +243,7 @@ Agent.prototype.createSocket = function createSocket(req, options, cb) {
|
|
|
137
243
|
this.sockets[name].push(s);
|
|
138
244
|
this.totalSocketCount++;
|
|
139
245
|
installListeners(this, s, options);
|
|
246
|
+
if (this._onKeylog) s.on("keylog", this._onKeylog);
|
|
140
247
|
cb(null, s);
|
|
141
248
|
};
|
|
142
249
|
if (this.keepAlive) {
|
|
@@ -218,7 +325,7 @@ Agent.prototype.keepSocketAlive = function keepSocketAlive(socket) {
|
|
|
218
325
|
const hint = socket._httpMessage?.res?.headers["keep-alive"];
|
|
219
326
|
const seconds = hint ? /^timeout=(\d+)/.exec(hint)?.[1] : undefined;
|
|
220
327
|
if (seconds) {
|
|
221
|
-
let serverHintTimeout = parseInt(seconds, 10) * 1000 -
|
|
328
|
+
let serverHintTimeout = parseInt(seconds, 10) * 1000 - this.agentKeepAliveTimeoutBuffer;
|
|
222
329
|
serverHintTimeout = serverHintTimeout > 0 ? serverHintTimeout : 0;
|
|
223
330
|
if (serverHintTimeout === 0) canKeepSocketAlive = false;
|
|
224
331
|
else if (serverHintTimeout < agentTimeout) agentTimeout = serverHintTimeout;
|
|
@@ -246,4 +353,9 @@ function setRequestSocket(agent, req, socket) {
|
|
|
246
353
|
socket.setTimeout(req.timeout);
|
|
247
354
|
}
|
|
248
355
|
|
|
249
|
-
export
|
|
356
|
+
export let globalAgent = new Agent({ keepAlive: true, scheduling: "lifo", timeout: 5000 });
|
|
357
|
+
|
|
358
|
+
/* http.globalAgent's setter: the agent requests use by default from then on, as Node's */
|
|
359
|
+
export function setGlobalAgent(agent) {
|
|
360
|
+
globalAgent = agent;
|
|
361
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
// util.MIMEType and util.MIMEParams: Node's internal/mime.js (WHATWG MIME Sniffing's parsing):
|
|
2
|
+
// type and subtype lowercased, parameters parsed when first used, first of each name kept,
|
|
3
|
+
// values quoted when serialized if they need it. Linked into programs that name them
|
|
4
|
+
// (internal/features.js): util's MIMEType and MIMEParams build these classes.
|
|
5
|
+
// Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
|
|
6
|
+
import { MIMEParams as MIMEParamsWrapper, MIMEType as MIMETypeWrapper } from "../util.js";
|
|
7
|
+
import { codeError } from "./errors.js";
|
|
8
|
+
import { provideClass } from "./features.js";
|
|
9
|
+
|
|
10
|
+
const NOT_HTTP_TOKEN_CODE_POINT = /[^!#$%&'*+\-.^_`|~A-Za-z0-9]/g;
|
|
11
|
+
const NOT_HTTP_QUOTED_STRING_CODE_POINT = /[^\t -~\u0080-ÿ]/g;
|
|
12
|
+
const END_BEGINNING_WHITESPACE = /[^\r\n\t ]|$/;
|
|
13
|
+
const START_ENDING_WHITESPACE = /[\r\n\t ]*$/;
|
|
14
|
+
const EQUALS_SEMICOLON_OR_END = /[;=]|$/;
|
|
15
|
+
const QUOTED_VALUE_PATTERN = /^(?:([\\]$)|[\\][\s\S]|[^"])*(?:(")|$)/u;
|
|
16
|
+
|
|
17
|
+
function invalidMimeSyntax(production, str, invalidIndex) {
|
|
18
|
+
const at = invalidIndex !== -1 ? ` at ${invalidIndex}` : "";
|
|
19
|
+
return codeError(TypeError, "ERR_INVALID_MIME_SYNTAX", `The MIME syntax for a ${production} in "${str}" is invalid` + at);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function toASCIILower(str) {
|
|
23
|
+
let result = "";
|
|
24
|
+
for (let i = 0; i < str.length; i++) {
|
|
25
|
+
const char = str[i];
|
|
26
|
+
result += char >= "A" && char <= "Z" ? char.toLowerCase() : char;
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function parseTypeAndSubtype(str) {
|
|
32
|
+
let position = str.search(END_BEGINNING_WHITESPACE);
|
|
33
|
+
const typeEnd = str.indexOf("/", position);
|
|
34
|
+
const trimmedType = typeEnd === -1 ? str.slice(position) : str.slice(position, typeEnd);
|
|
35
|
+
const invalidTypeIndex = trimmedType.search(NOT_HTTP_TOKEN_CODE_POINT);
|
|
36
|
+
if (trimmedType === "" || invalidTypeIndex !== -1 || typeEnd === -1) throw invalidMimeSyntax("type", str, invalidTypeIndex);
|
|
37
|
+
position = typeEnd + 1;
|
|
38
|
+
const type = toASCIILower(trimmedType);
|
|
39
|
+
const subtypeEnd = str.indexOf(";", position);
|
|
40
|
+
const rawSubtype = subtypeEnd === -1 ? str.slice(position) : str.slice(position, subtypeEnd);
|
|
41
|
+
position += rawSubtype.length;
|
|
42
|
+
if (subtypeEnd !== -1) position += 1;
|
|
43
|
+
const trimmedSubtype = rawSubtype.slice(0, rawSubtype.search(START_ENDING_WHITESPACE));
|
|
44
|
+
const invalidSubtypeIndex = trimmedSubtype.search(NOT_HTTP_TOKEN_CODE_POINT);
|
|
45
|
+
if (trimmedSubtype === "" || invalidSubtypeIndex !== -1) throw invalidMimeSyntax("subtype", str, invalidSubtypeIndex);
|
|
46
|
+
return { type, subtype: toASCIILower(trimmedSubtype), parametersStringIndex: position };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function removeBackslashes(str) {
|
|
50
|
+
let ret = "";
|
|
51
|
+
let i;
|
|
52
|
+
for (i = 0; i < str.length - 1; i++) {
|
|
53
|
+
const c = str[i];
|
|
54
|
+
if (c === "\\") {
|
|
55
|
+
i++;
|
|
56
|
+
ret += str[i];
|
|
57
|
+
} else ret += c;
|
|
58
|
+
}
|
|
59
|
+
if (i === str.length - 1) ret += str[i];
|
|
60
|
+
return ret;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function escapeQuoteOrSolidus(str) {
|
|
64
|
+
let result = "";
|
|
65
|
+
for (let i = 0; i < str.length; i++) {
|
|
66
|
+
const char = str[i];
|
|
67
|
+
result += char === '"' || char === "\\" ? `\\${char}` : char;
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function encode(value) {
|
|
73
|
+
if (value.length === 0) return '""';
|
|
74
|
+
if (value.search(NOT_HTTP_TOKEN_CODE_POINT) === -1) return value;
|
|
75
|
+
return `"${escapeQuoteOrSolidus(value)}"`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let instantiateMimeParams;
|
|
79
|
+
|
|
80
|
+
class MIMEParams {
|
|
81
|
+
#data = new Map();
|
|
82
|
+
#processed = true; /* a MIMEType's are parsed when first used */
|
|
83
|
+
#string = null;
|
|
84
|
+
|
|
85
|
+
static {
|
|
86
|
+
instantiateMimeParams = (str) => {
|
|
87
|
+
const instance = new MIMEParams();
|
|
88
|
+
instance.#string = str;
|
|
89
|
+
instance.#processed = false;
|
|
90
|
+
return instance;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
delete(name) {
|
|
95
|
+
this.#parse();
|
|
96
|
+
this.#data.delete(name);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
get(name) {
|
|
100
|
+
this.#parse();
|
|
101
|
+
return this.#data.has(name) ? this.#data.get(name) : null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
has(name) {
|
|
105
|
+
this.#parse();
|
|
106
|
+
return this.#data.has(name);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
set(name, value) {
|
|
110
|
+
this.#parse();
|
|
111
|
+
name = `${name}`;
|
|
112
|
+
value = `${value}`;
|
|
113
|
+
const invalidNameIndex = name.search(NOT_HTTP_TOKEN_CODE_POINT);
|
|
114
|
+
if (name.length === 0 || invalidNameIndex !== -1) throw invalidMimeSyntax("parameter name", name, invalidNameIndex);
|
|
115
|
+
const invalidValueIndex = value.search(NOT_HTTP_QUOTED_STRING_CODE_POINT);
|
|
116
|
+
if (invalidValueIndex !== -1) throw invalidMimeSyntax("parameter value", value, invalidValueIndex);
|
|
117
|
+
this.#data.set(name, value);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
entries() {
|
|
121
|
+
this.#parse();
|
|
122
|
+
return this.#data.entries();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
keys() {
|
|
126
|
+
this.#parse();
|
|
127
|
+
return this.#data.keys();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
values() {
|
|
131
|
+
this.#parse();
|
|
132
|
+
return this.#data.values();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
toString() {
|
|
136
|
+
this.#parse();
|
|
137
|
+
let ret = "";
|
|
138
|
+
for (const [key, value] of this.#data) {
|
|
139
|
+
if (ret.length) ret += ";";
|
|
140
|
+
ret += `${key}=${encode(value)}`;
|
|
141
|
+
}
|
|
142
|
+
return ret;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
#parse() {
|
|
146
|
+
if (this.#processed) return;
|
|
147
|
+
const paramsMap = this.#data;
|
|
148
|
+
let position = 0;
|
|
149
|
+
const str = this.#string;
|
|
150
|
+
const endOfSource = str.slice(position).search(START_ENDING_WHITESPACE) + position;
|
|
151
|
+
while (position < endOfSource) {
|
|
152
|
+
position += str.slice(position).search(END_BEGINNING_WHITESPACE);
|
|
153
|
+
const afterParameterName = str.slice(position).search(EQUALS_SEMICOLON_OR_END) + position;
|
|
154
|
+
const parameterString = toASCIILower(str.slice(position, afterParameterName));
|
|
155
|
+
position = afterParameterName;
|
|
156
|
+
if (position < endOfSource) {
|
|
157
|
+
const char = str.charAt(position);
|
|
158
|
+
position += 1;
|
|
159
|
+
if (char === ";") continue; /* a parameter without a value */
|
|
160
|
+
}
|
|
161
|
+
if (position >= endOfSource) break;
|
|
162
|
+
const char = str.charAt(position);
|
|
163
|
+
let parameterValue;
|
|
164
|
+
if (char === '"') {
|
|
165
|
+
position += 1;
|
|
166
|
+
/* to the closing quote, or the end ($1: an unmatched backslash, $2: the closing quote) */
|
|
167
|
+
const insideMatch = QUOTED_VALUE_PATTERN.exec(str.slice(position));
|
|
168
|
+
position += insideMatch[0].length;
|
|
169
|
+
const inside = insideMatch[1] || insideMatch[2] ? insideMatch[0].slice(0, -1) : insideMatch[0];
|
|
170
|
+
parameterValue = removeBackslashes(inside);
|
|
171
|
+
if (insideMatch[1]) parameterValue += "\\";
|
|
172
|
+
} else {
|
|
173
|
+
const valueEnd = str.indexOf(";", position);
|
|
174
|
+
const rawValue = valueEnd === -1 ? str.slice(position) : str.slice(position, valueEnd);
|
|
175
|
+
position += rawValue.length;
|
|
176
|
+
const trimmedValue = rawValue.slice(0, rawValue.search(START_ENDING_WHITESPACE));
|
|
177
|
+
if (trimmedValue === "") continue;
|
|
178
|
+
parameterValue = trimmedValue;
|
|
179
|
+
}
|
|
180
|
+
if (parameterString !== "" && parameterString.search(NOT_HTTP_TOKEN_CODE_POINT) === -1 &&
|
|
181
|
+
parameterValue.search(NOT_HTTP_QUOTED_STRING_CODE_POINT) === -1 && !paramsMap.has(parameterString)) {
|
|
182
|
+
paramsMap.set(parameterString, parameterValue);
|
|
183
|
+
}
|
|
184
|
+
position++;
|
|
185
|
+
}
|
|
186
|
+
this.#data = paramsMap;
|
|
187
|
+
this.#processed = true;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const stringifyParams = MIMEParams.prototype.toString;
|
|
192
|
+
Object.defineProperty(MIMEParams.prototype, Symbol.iterator, { configurable: true, value: MIMEParams.prototype.entries, writable: true });
|
|
193
|
+
Object.defineProperty(MIMEParams.prototype, "toJSON", { configurable: true, value: stringifyParams, writable: true });
|
|
194
|
+
|
|
195
|
+
export class MIMEType {
|
|
196
|
+
#type;
|
|
197
|
+
#subtype;
|
|
198
|
+
#parameters;
|
|
199
|
+
|
|
200
|
+
constructor(string) {
|
|
201
|
+
string = `${string}`;
|
|
202
|
+
const data = parseTypeAndSubtype(string);
|
|
203
|
+
this.#type = data.type;
|
|
204
|
+
this.#subtype = data.subtype;
|
|
205
|
+
this.#parameters = instantiateMimeParams(string.slice(data.parametersStringIndex));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
get type() {
|
|
209
|
+
return this.#type;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
set type(v) {
|
|
213
|
+
v = `${v}`;
|
|
214
|
+
const invalidTypeIndex = v.search(NOT_HTTP_TOKEN_CODE_POINT);
|
|
215
|
+
if (v.length === 0 || invalidTypeIndex !== -1) throw invalidMimeSyntax("type", v, invalidTypeIndex);
|
|
216
|
+
this.#type = toASCIILower(v);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
get subtype() {
|
|
220
|
+
return this.#subtype;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
set subtype(v) {
|
|
224
|
+
v = `${v}`;
|
|
225
|
+
const invalidSubtypeIndex = v.search(NOT_HTTP_TOKEN_CODE_POINT);
|
|
226
|
+
if (v.length === 0 || invalidSubtypeIndex !== -1) throw invalidMimeSyntax("subtype", v, invalidSubtypeIndex);
|
|
227
|
+
this.#subtype = toASCIILower(v);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
get essence() {
|
|
231
|
+
return `${this.#type}/${this.#subtype}`;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
get params() {
|
|
235
|
+
return this.#parameters;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
toString() {
|
|
239
|
+
let ret = `${this.#type}/${this.#subtype}`;
|
|
240
|
+
const paramStr = stringifyParams.call(this.#parameters);
|
|
241
|
+
if (paramStr.length) ret += `;${paramStr}`;
|
|
242
|
+
return ret;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
Object.defineProperty(MIMEType.prototype, "toJSON", { configurable: true, value: MIMEType.prototype.toString, writable: true });
|
|
247
|
+
|
|
248
|
+
provideClass(MIMEParamsWrapper, MIMEParams);
|
|
249
|
+
provideClass(MIMETypeWrapper, MIMEType);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// IP address checks (Node's lib/internal/net.js regexes), shared by node:net and node:dns.
|
|
2
|
+
// Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
|
|
2
3
|
|
|
3
4
|
// IPv4 Segment
|
|
4
5
|
const v4Seg = "(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])";
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// net.BoundSocket, as Node's: a TCP or pipe handle bound at once (its errors thrown by the
|
|
2
|
+
// constructor), neither listening nor connecting until one Server (server.listen(bound)) or Socket
|
|
3
|
+
// (new net.Socket({ handle: bound })) adopts it, which then owns it. No DNS: a host is an IP.
|
|
4
|
+
// Linked into programs that name BoundSocket (internal/features.js); net.js adopts the handle
|
|
5
|
+
// through features.adoptBoundSocket.
|
|
6
|
+
import { netAddress, netBind, netClose, netFd, netOpen } from "visaljs:host";
|
|
7
|
+
import { BoundSocket as Wrapper } from "../net.js";
|
|
8
|
+
import { codeError, invalidArgType, invalidArgValue, validateString } from "./errors.js";
|
|
9
|
+
import { features, provideClass } from "./features.js";
|
|
10
|
+
import { isIP } from "./net.js";
|
|
11
|
+
|
|
12
|
+
const kConsume = Symbol("kBoundSocketConsume");
|
|
13
|
+
|
|
14
|
+
const adopted = () => codeError(Error, "ERR_SOCKET_HANDLE_ADOPTED", "The bound socket has already been adopted by a server or socket");
|
|
15
|
+
|
|
16
|
+
function validateBoolean(value, name) {
|
|
17
|
+
if (typeof value !== "boolean") throw invalidArgType(name, "of type boolean", value);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class BoundSocket {
|
|
21
|
+
#handle = null; /* the host handle's id, until adopted or closed */
|
|
22
|
+
#address = {};
|
|
23
|
+
#path;
|
|
24
|
+
|
|
25
|
+
constructor(options = {}) {
|
|
26
|
+
if (options === null || typeof options !== "object" || Array.isArray(options)) throw invalidArgType("options", "of type object", options);
|
|
27
|
+
if (options.path !== undefined) {
|
|
28
|
+
this.#bindPipe(options);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const { exceptionWithHostPort, validatePort } = features.net;
|
|
32
|
+
const port = validatePort(options.port ?? 0, "options.port");
|
|
33
|
+
const ipv6Only = options.ipv6Only ?? false;
|
|
34
|
+
validateBoolean(ipv6Only, "options.ipv6Only");
|
|
35
|
+
const reusePort = options.reusePort ?? false;
|
|
36
|
+
validateBoolean(reusePort, "options.reusePort");
|
|
37
|
+
let { host } = options;
|
|
38
|
+
if (host === undefined || host === null) {
|
|
39
|
+
host = ipv6Only ? "::" : "0.0.0.0";
|
|
40
|
+
} else {
|
|
41
|
+
validateString(host, "options.host");
|
|
42
|
+
if (isIP(host) === 0) {
|
|
43
|
+
throw invalidArgValue("options.host", "must be a numeric IP address; net.BoundSocket does not perform DNS resolution", host);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const id = netOpen(false);
|
|
47
|
+
let err = netBind(id, host, port, (ipv6Only ? 1 : 0) | (reusePort ? 2 : 0));
|
|
48
|
+
/* libuv keeps a bind's EADDRINUSE for the next getsockname, listen or connect: asked now, so it
|
|
49
|
+
* throws here, as Node's */
|
|
50
|
+
if (err === 0) {
|
|
51
|
+
const a = netAddress(id, false);
|
|
52
|
+
if (typeof a === "number") err = a;
|
|
53
|
+
else this.#address = { address: a[0], family: a[1], port: a[2] };
|
|
54
|
+
}
|
|
55
|
+
if (err) {
|
|
56
|
+
netClose(id);
|
|
57
|
+
throw exceptionWithHostPort(err, "bind", host, port);
|
|
58
|
+
}
|
|
59
|
+
this.#handle = id;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* a Unix domain socket's path (or a Windows named pipe's); one starting with "\0" is in Linux's
|
|
63
|
+
* abstract namespace */
|
|
64
|
+
#bindPipe(options) {
|
|
65
|
+
const { path, host, port, ipv6Only, reusePort } = options;
|
|
66
|
+
if (host !== undefined || port !== undefined || ipv6Only !== undefined || reusePort !== undefined) {
|
|
67
|
+
throw invalidArgValue("options", "path is mutually exclusive with host, port, ipv6Only, and reusePort", options);
|
|
68
|
+
}
|
|
69
|
+
validateString(path, "options.path");
|
|
70
|
+
if (path[0] === "\0" && process.platform !== "linux") {
|
|
71
|
+
throw invalidArgValue("options.path", "abstract socket paths are only supported on Linux", path);
|
|
72
|
+
}
|
|
73
|
+
const id = netOpen(true);
|
|
74
|
+
const err = netBind(id, path);
|
|
75
|
+
if (err) {
|
|
76
|
+
netClose(id);
|
|
77
|
+
throw features.net.errnoException(err, "bind");
|
|
78
|
+
}
|
|
79
|
+
this.#handle = id;
|
|
80
|
+
this.#path = path;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* { address, family, port }, or a pipe's path */
|
|
84
|
+
address() {
|
|
85
|
+
if (this.#handle === null) throw adopted();
|
|
86
|
+
return this.#path ?? this.#address;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* the descriptor, or -1 where sockets have none (Windows) */
|
|
90
|
+
fd() {
|
|
91
|
+
if (this.#handle === null) throw adopted();
|
|
92
|
+
const fd = netFd(this.#handle);
|
|
93
|
+
return fd < 0 ? -1 : fd;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
close() {
|
|
97
|
+
if (this.#handle === null) throw adopted();
|
|
98
|
+
netClose(this.#handle);
|
|
99
|
+
this.#handle = null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
[Symbol.dispose]() {
|
|
103
|
+
if (this.#handle !== null) {
|
|
104
|
+
netClose(this.#handle);
|
|
105
|
+
this.#handle = null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
get isPipe() {
|
|
110
|
+
return this.#path !== undefined;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
[kConsume]() {
|
|
114
|
+
if (this.#handle === null) throw adopted();
|
|
115
|
+
const id = this.#handle;
|
|
116
|
+
this.#handle = null;
|
|
117
|
+
return { id, path: this.#path };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* the handle of a BoundSocket being adopted ({ id, path }), or null for anything else */
|
|
122
|
+
features.adoptBoundSocket = (value) => (value instanceof BoundSocket ? value[kConsume]() : null);
|
|
123
|
+
provideClass(Wrapper, BoundSocket);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// net.Socket's onread option, as Node's: the bytes read go into the user's buffer, a buffer's worth
|
|
2
|
+
// at a time, and to its callback instead of 'data'. The callback returning false, or pausing,
|
|
3
|
+
// stops reading, as a read into that buffer would: the bytes not yet given wait for resume().
|
|
4
|
+
// Linked into programs that name onread (internal/features.js).
|
|
5
|
+
import { netReadStart, netReadStop } from "visaljs:host";
|
|
6
|
+
import { features } from "./features.js";
|
|
7
|
+
|
|
8
|
+
function deliver(socket, bytes) {
|
|
9
|
+
for (let at = 0; at < bytes.length;) {
|
|
10
|
+
const { buffer, callback } = socket._onread;
|
|
11
|
+
const buf = typeof buffer === "function" ? buffer() : buffer;
|
|
12
|
+
const n = Math.min(buf.length, bytes.length - at);
|
|
13
|
+
buf.set(bytes.subarray(at, at + n));
|
|
14
|
+
at += n;
|
|
15
|
+
const more = callback.call(socket, n, buf) !== false && socket._reading;
|
|
16
|
+
if (!more) {
|
|
17
|
+
if (at < bytes.length) socket._onreadRest = bytes.subarray(at);
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
features.onread = {
|
|
25
|
+
/* bytes read: false stops reading */
|
|
26
|
+
deliver,
|
|
27
|
+
|
|
28
|
+
/* a TLS socket's decrypted bytes: all of them, false when a callback asks to stop (its reads
|
|
29
|
+
* resume through its own stream, not the bytes kept here) */
|
|
30
|
+
deliverAll(socket, bytes) {
|
|
31
|
+
let more = true;
|
|
32
|
+
for (let at = 0; at < bytes.length;) {
|
|
33
|
+
const { buffer, callback } = socket._onread;
|
|
34
|
+
const buf = typeof buffer === "function" ? buffer() : buffer;
|
|
35
|
+
const n = Math.min(buf.length, bytes.length - at);
|
|
36
|
+
buf.set(bytes.subarray(at, at + n));
|
|
37
|
+
at += n;
|
|
38
|
+
if (callback.call(socket, n, buf) === false) more = false;
|
|
39
|
+
}
|
|
40
|
+
return more;
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
/* libuv takes a buffer for the read that finds EOF too: a buffer function is asked for one */
|
|
44
|
+
eof(socket) {
|
|
45
|
+
if (typeof socket._onread.buffer === "function") socket._onread.buffer();
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
/* Node's: pausing stops reading from the handle, resuming starts it (a TLS socket reads through
|
|
49
|
+
* its own stream) */
|
|
50
|
+
pause(socket) {
|
|
51
|
+
if (socket.encrypted || socket.connecting || socket._handle === null || !socket._reading) return;
|
|
52
|
+
socket._reading = false;
|
|
53
|
+
if (!socket.destroyed) {
|
|
54
|
+
const err = netReadStop(socket._handle);
|
|
55
|
+
if (err) socket.destroy(features.net.errnoException(err, "read"));
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
resume(socket) {
|
|
60
|
+
if (!socket.encrypted && !socket.connecting && socket._handle !== null && !socket._reading) socket._startReading();
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
/* reading again: the bytes left from the last read first, as the next read */
|
|
64
|
+
rest(socket) {
|
|
65
|
+
const rest = socket._onreadRest;
|
|
66
|
+
socket._onreadRest = null;
|
|
67
|
+
process.nextTick(() => {
|
|
68
|
+
if (socket.destroyed || socket._handle === null) return;
|
|
69
|
+
if (deliver(socket, rest)) netReadStart(socket._handle);
|
|
70
|
+
else socket._reading = false;
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
};
|