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
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
// FormData, as Node's (undici's lib/web/fetch/formdata.js), and what Request and Response do with
|
|
2
|
+
// one: a FormData body is sent as multipart/form-data (body.js's extractBody), and formData()
|
|
3
|
+
// parses a multipart/form-data or application/x-www-form-urlencoded body (formdata-parser.js).
|
|
4
|
+
// The fetch component (runtime/src/fetch.c) calls the two through fetchFormDataHooks. A program
|
|
5
|
+
// that names FormData or formData gets this module first (implicitModules in node/index.ts).
|
|
6
|
+
// Ported from Node.js's undici (Copyright Node.js contributors and undici contributors, MIT):
|
|
7
|
+
// node/third_party/nodejs/LICENSE.
|
|
8
|
+
import { fetchFormDataHooks } from "visaljs:host";
|
|
9
|
+
import { Buffer } from "../buffer.js";
|
|
10
|
+
import { MIMEType } from "./mime.js";
|
|
11
|
+
|
|
12
|
+
const kInspect = Symbol.for("nodejs.util.inspect.custom");
|
|
13
|
+
const fileName = Object.getOwnPropertyDescriptor(File.prototype, "name").get;
|
|
14
|
+
const isBlob = (value) => value instanceof Blob;
|
|
15
|
+
|
|
16
|
+
function isFile(value) {
|
|
17
|
+
try {
|
|
18
|
+
fileName.call(value);
|
|
19
|
+
return true;
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** webidl's USVString: a string, its lone surrogates replaced */
|
|
26
|
+
const usv = (value) => String(value).toWellFormed();
|
|
27
|
+
|
|
28
|
+
function argumentLengthCheck(args, min, prefix) {
|
|
29
|
+
if (args.length < min) {
|
|
30
|
+
throw new TypeError(`${prefix}: ${min} argument${min === 1 ? "" : "s"} required, but${args.length ? " only" : ""} ${args.length} found.`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** create an entry: a Blob value becomes a File ("blob", or the filename given) */
|
|
35
|
+
function makeEntry(name, value, filename) {
|
|
36
|
+
if (typeof value !== "string") {
|
|
37
|
+
if (!isFile(value)) value = new File([value], "blob", { type: value.type });
|
|
38
|
+
if (filename !== undefined) value = new File([value], filename, { type: value.type, lastModified: value.lastModified });
|
|
39
|
+
}
|
|
40
|
+
return { name, value };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function entryArguments(args, prefix) {
|
|
44
|
+
argumentLengthCheck(args, 2, prefix);
|
|
45
|
+
const name = usv(args[0]);
|
|
46
|
+
let value = args[1];
|
|
47
|
+
let filename = args[2];
|
|
48
|
+
if (args.length === 3 || isBlob(value)) {
|
|
49
|
+
if (!isBlob(value)) throw new TypeError(`${prefix}: Expected value ("${JSON.stringify(value)}") to be an instance of Blob.`);
|
|
50
|
+
if (filename !== undefined) filename = usv(filename);
|
|
51
|
+
} else {
|
|
52
|
+
value = usv(value);
|
|
53
|
+
}
|
|
54
|
+
return makeEntry(name, value, filename);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const states = new WeakMap();
|
|
58
|
+
function stateOf(formData, prefix) {
|
|
59
|
+
const state = states.get(formData);
|
|
60
|
+
if (state === undefined) throw new TypeError(`${prefix}: Illegal invocation`);
|
|
61
|
+
return state;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
class FormData {
|
|
65
|
+
constructor(form = undefined) {
|
|
66
|
+
if (form !== undefined) throw new TypeError("FormData constructor: Argument 1 could not be converted to: undefined.");
|
|
67
|
+
states.set(this, { entries: [] });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
append(name, value, filename = undefined) {
|
|
71
|
+
const state = stateOf(this, "FormData.append");
|
|
72
|
+
state.entries.push(entryArguments([name, value, filename].slice(0, arguments.length), "FormData.append"));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
delete(name) {
|
|
76
|
+
const state = stateOf(this, "FormData.delete");
|
|
77
|
+
argumentLengthCheck(arguments, 1, "FormData.delete");
|
|
78
|
+
name = usv(name);
|
|
79
|
+
state.entries = state.entries.filter((entry) => entry.name !== name);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
get(name) {
|
|
83
|
+
const state = stateOf(this, "FormData.get");
|
|
84
|
+
argumentLengthCheck(arguments, 1, "FormData.get");
|
|
85
|
+
name = usv(name);
|
|
86
|
+
const entry = state.entries.find((e) => e.name === name);
|
|
87
|
+
return entry === undefined ? null : entry.value;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
getAll(name) {
|
|
91
|
+
const state = stateOf(this, "FormData.getAll");
|
|
92
|
+
argumentLengthCheck(arguments, 1, "FormData.getAll");
|
|
93
|
+
name = usv(name);
|
|
94
|
+
return state.entries.filter((entry) => entry.name === name).map((entry) => entry.value);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
has(name) {
|
|
98
|
+
const state = stateOf(this, "FormData.has");
|
|
99
|
+
argumentLengthCheck(arguments, 1, "FormData.has");
|
|
100
|
+
name = usv(name);
|
|
101
|
+
return state.entries.some((entry) => entry.name === name);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
set(name, value, filename = undefined) {
|
|
105
|
+
const state = stateOf(this, "FormData.set");
|
|
106
|
+
const entry = entryArguments([name, value, filename].slice(0, arguments.length), "FormData.set");
|
|
107
|
+
const idx = state.entries.findIndex((e) => e.name === entry.name);
|
|
108
|
+
if (idx === -1) state.entries.push(entry);
|
|
109
|
+
else state.entries = [...state.entries.slice(0, idx), entry, ...state.entries.slice(idx + 1).filter((e) => e.name !== entry.name)];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
*entries() {
|
|
113
|
+
const state = stateOf(this, "FormData.entries");
|
|
114
|
+
for (let i = 0; i < state.entries.length; i++) yield [state.entries[i].name, state.entries[i].value];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
*keys() {
|
|
118
|
+
for (const [name] of this.entries()) yield name;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
*values() {
|
|
122
|
+
for (const [, value] of this.entries()) yield value;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
forEach(callbackFn, thisArg = undefined) {
|
|
126
|
+
stateOf(this, "FormData.forEach");
|
|
127
|
+
argumentLengthCheck(arguments, 1, "FormData.forEach");
|
|
128
|
+
if (typeof callbackFn !== "function") {
|
|
129
|
+
throw new TypeError("Failed to execute 'forEach' on 'FormData': parameter 1 is not of type 'Function'.");
|
|
130
|
+
}
|
|
131
|
+
for (const [key, value] of this) Reflect.apply(callbackFn, thisArg, [value, key, this]);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
[kInspect](depth, options, inspect) {
|
|
135
|
+
const state = { __proto__: null };
|
|
136
|
+
for (const { name, value } of stateOf(this, "FormData").entries) {
|
|
137
|
+
if (!(name in state)) state[name] = value;
|
|
138
|
+
else if (Array.isArray(state[name])) state[name].push(value);
|
|
139
|
+
else state[name] = [state[name], value];
|
|
140
|
+
}
|
|
141
|
+
const output = inspect(state, { ...options, depth: options.depth ?? depth });
|
|
142
|
+
/* without "[Object: null prototype]" */
|
|
143
|
+
return `FormData ${output.slice(output.indexOf("]") + 2)}`;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
FormData.prototype[Symbol.iterator] = FormData.prototype.entries;
|
|
147
|
+
for (const key of ["append", "delete", "get", "getAll", "has", "set", "entries", "keys", "values", "forEach"]) {
|
|
148
|
+
Object.defineProperty(FormData.prototype, key, { enumerable: true });
|
|
149
|
+
}
|
|
150
|
+
Object.defineProperty(FormData.prototype, Symbol.toStringTag, { value: "FormData", configurable: true });
|
|
151
|
+
|
|
152
|
+
/* ---- multipart/form-data: a FormData body (body.js's extractBody) ------------------------------ */
|
|
153
|
+
|
|
154
|
+
const encoder = new TextEncoder();
|
|
155
|
+
const escape = (str) => str.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
|
|
156
|
+
const normalizeLinefeeds = (value) => value.replace(/\r?\n|\r/g, "\r\n");
|
|
157
|
+
|
|
158
|
+
/** A FormData's body as a Blob and its Content-Type; undefined for anything else. */
|
|
159
|
+
function serialize(object) {
|
|
160
|
+
const state = states.get(object);
|
|
161
|
+
if (state === undefined) return undefined;
|
|
162
|
+
const boundary = `----formdata-undici-0${`${Math.floor(Math.random() * 1e11)}`.padStart(11, "0")}`;
|
|
163
|
+
const prefix = `--${boundary}\r\nContent-Disposition: form-data`;
|
|
164
|
+
const parts = [];
|
|
165
|
+
for (const { name, value } of state.entries) {
|
|
166
|
+
if (typeof value === "string") {
|
|
167
|
+
parts.push(encoder.encode(`${prefix}; name="${escape(normalizeLinefeeds(name))}"\r\n\r\n${normalizeLinefeeds(value)}\r\n`));
|
|
168
|
+
} else {
|
|
169
|
+
parts.push(encoder.encode(`${prefix}; name="${escape(normalizeLinefeeds(name))}"` +
|
|
170
|
+
(value.name ? `; filename="${escape(value.name)}"` : "") + "\r\n" +
|
|
171
|
+
`Content-Type: ${value.type || "application/octet-stream"}\r\n\r\n`), value, encoder.encode("\r\n"));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
parts.push(encoder.encode(`--${boundary}--\r\n`));
|
|
175
|
+
return [new Blob(parts), `multipart/form-data; boundary=${boundary}`];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/* ---- formData(): parsing (formdata-parser.js) --------------------------------------------------- */
|
|
179
|
+
|
|
180
|
+
const decoder = new TextDecoder();
|
|
181
|
+
const decoderIgnoreBOM = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
182
|
+
const HTTP_TOKEN_CODEPOINTS = /^[-!#$%&'*+.^_|~A-Za-z0-9]+$/u;
|
|
183
|
+
const dd = Buffer.from("--");
|
|
184
|
+
|
|
185
|
+
const parsingError = (cause) => new TypeError("Failed to parse body as FormData.", { cause: new TypeError(cause) });
|
|
186
|
+
const isCTL = (char) => char <= 0x1f || char === 0x7f;
|
|
187
|
+
const isTSpecial = (char) => char === 0x28 || char === 0x29 || char === 0x3c || char === 0x3e || char === 0x40 || char === 0x2c ||
|
|
188
|
+
char === 0x3b || char === 0x3a || char === 0x5c || char === 0x22 || char === 0x2f || char === 0x5b || char === 0x5d || char === 0x3f ||
|
|
189
|
+
char === 0x3d;
|
|
190
|
+
const isToken = (char) => char <= 0x7f && char !== 0x20 && char !== 0x09 && !isCTL(char) && !isTSpecial(char);
|
|
191
|
+
|
|
192
|
+
function isAsciiString(chars) {
|
|
193
|
+
for (let i = 0; i < chars.length; ++i) if ((chars.charCodeAt(i) & ~0x7f) !== 0) return false;
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function collectASequenceOfBytes(condition, input, position) {
|
|
198
|
+
let start = position.position;
|
|
199
|
+
while (start < input.length && condition(input[start])) ++start;
|
|
200
|
+
return input.subarray(position.position, (position.position = start));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function removeChars(buf, leading, trailing, predicate) {
|
|
204
|
+
let lead = 0;
|
|
205
|
+
let trail = buf.length - 1;
|
|
206
|
+
if (leading) while (lead < buf.length && predicate(buf[lead])) lead++;
|
|
207
|
+
if (trailing) while (trail > 0 && predicate(buf[trail])) trail--;
|
|
208
|
+
return lead === 0 && trail === buf.length - 1 ? buf : buf.subarray(lead, trail + 1);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function bufferStartsWith(buffer, start, position) {
|
|
212
|
+
if (buffer.length < start.length) return false;
|
|
213
|
+
for (let i = 0; i < start.length; i++) if (start[i] !== buffer[position.position + i]) return false;
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const isomorphicDecode = (bytes) => Buffer.from(bytes).toString("latin1");
|
|
218
|
+
|
|
219
|
+
function parseContentDispositionAttribute(input, position) {
|
|
220
|
+
if (input[position.position] === 0x3b) position.position++;
|
|
221
|
+
collectASequenceOfBytes((char) => char === 0x20 || char === 0x09, input, position);
|
|
222
|
+
const attributeName = collectASequenceOfBytes((char) => isToken(char) && char !== 0x3d && char !== 0x2a, input, position);
|
|
223
|
+
if (attributeName.length === 0) return null;
|
|
224
|
+
const attrNameStr = attributeName.toString("ascii").toLowerCase();
|
|
225
|
+
const isExtended = input[position.position] === 0x2a;
|
|
226
|
+
if (isExtended) position.position++;
|
|
227
|
+
if (input[position.position] !== 0x3d) return null;
|
|
228
|
+
position.position++;
|
|
229
|
+
collectASequenceOfBytes((char) => char === 0x20 || char === 0x09, input, position);
|
|
230
|
+
let value;
|
|
231
|
+
if (isExtended) {
|
|
232
|
+
const headerValue = collectASequenceOfBytes((char) => char !== 0x20 && char !== 0x0d && char !== 0x0a && char !== 0x3b, input, position);
|
|
233
|
+
if ((headerValue[0] !== 0x75 && headerValue[0] !== 0x55) || (headerValue[1] !== 0x74 && headerValue[1] !== 0x54) ||
|
|
234
|
+
(headerValue[2] !== 0x66 && headerValue[2] !== 0x46) || headerValue[3] !== 0x2d || headerValue[4] !== 0x38) {
|
|
235
|
+
throw parsingError("unknown encoding, expected utf-8''");
|
|
236
|
+
}
|
|
237
|
+
value = decodeURIComponent(decoder.decode(headerValue.subarray(7)));
|
|
238
|
+
} else if (input[position.position] === 0x22) {
|
|
239
|
+
position.position++;
|
|
240
|
+
const quotedValue = collectASequenceOfBytes((char) => char !== 0x0a && char !== 0x0d && char !== 0x22, input, position);
|
|
241
|
+
if (input[position.position] !== 0x22) throw parsingError("Closing quote not found");
|
|
242
|
+
position.position++;
|
|
243
|
+
value = decoder.decode(quotedValue).replace(/%0A/ig, "\n").replace(/%0D/ig, "\r").replace(/%22/g, '"');
|
|
244
|
+
} else {
|
|
245
|
+
value = decoder.decode(collectASequenceOfBytes((char) => isToken(char) && char !== 0x3b, input, position));
|
|
246
|
+
}
|
|
247
|
+
return { name: attrNameStr, value, extended: isExtended };
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function parseMultipartFormDataHeaders(input, position) {
|
|
251
|
+
let name = null;
|
|
252
|
+
let filename = null;
|
|
253
|
+
let contentType = null;
|
|
254
|
+
let encoding = null;
|
|
255
|
+
while (true) {
|
|
256
|
+
if (input[position.position] === 0x0d && input[position.position + 1] === 0x0a) {
|
|
257
|
+
if (name === null) throw parsingError("header name is null");
|
|
258
|
+
return { name, filename, contentType, encoding };
|
|
259
|
+
}
|
|
260
|
+
let headerName = collectASequenceOfBytes((char) => char !== 0x0a && char !== 0x0d && char !== 0x3a, input, position);
|
|
261
|
+
headerName = removeChars(headerName, true, true, (char) => char === 0x9 || char === 0x20);
|
|
262
|
+
if (!HTTP_TOKEN_CODEPOINTS.test(headerName.toString())) throw parsingError("header name does not match the field-name token production");
|
|
263
|
+
if (input[position.position] !== 0x3a) throw parsingError("expected :");
|
|
264
|
+
position.position++;
|
|
265
|
+
collectASequenceOfBytes((char) => char === 0x20 || char === 0x09, input, position);
|
|
266
|
+
switch (headerName.toString("latin1").toLowerCase()) {
|
|
267
|
+
case "content-disposition": {
|
|
268
|
+
name = filename = null;
|
|
269
|
+
let filenameIsExtended = false;
|
|
270
|
+
const dispositionType = collectASequenceOfBytes((char) => isToken(char), input, position);
|
|
271
|
+
if (dispositionType.toString("ascii").toLowerCase() !== "form-data") throw parsingError("expected form-data for content-disposition header");
|
|
272
|
+
while (position.position < input.length && (input[position.position] !== 0x0d || input[position.position + 1] !== 0x0a)) {
|
|
273
|
+
const attribute = parseContentDispositionAttribute(input, position);
|
|
274
|
+
if (!attribute) break;
|
|
275
|
+
if (attribute.name === "name") {
|
|
276
|
+
name = attribute.value;
|
|
277
|
+
} else if (attribute.name === "filename") {
|
|
278
|
+
if (attribute.extended) {
|
|
279
|
+
filename = attribute.value;
|
|
280
|
+
filenameIsExtended = true;
|
|
281
|
+
} else if (!filenameIsExtended) {
|
|
282
|
+
filename = attribute.value;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (name === null) throw parsingError("name attribute is required in content-disposition header");
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
case "content-type": {
|
|
290
|
+
let headerValue = collectASequenceOfBytes((char) => char !== 0x0a && char !== 0x0d, input, position);
|
|
291
|
+
headerValue = removeChars(headerValue, false, true, (char) => char === 0x9 || char === 0x20);
|
|
292
|
+
contentType = isomorphicDecode(headerValue);
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
case "content-transfer-encoding": {
|
|
296
|
+
let headerValue = collectASequenceOfBytes((char) => char !== 0x0a && char !== 0x0d, input, position);
|
|
297
|
+
headerValue = removeChars(headerValue, false, true, (char) => char === 0x9 || char === 0x20);
|
|
298
|
+
encoding = isomorphicDecode(headerValue);
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
default:
|
|
302
|
+
collectASequenceOfBytes((char) => char !== 0x0a && char !== 0x0d, input, position);
|
|
303
|
+
}
|
|
304
|
+
if (input[position.position] !== 0x0d || input[position.position + 1] !== 0x0a) throw parsingError("expected CRLF");
|
|
305
|
+
position.position += 2;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function multipartFormDataParser(input, boundaryString) {
|
|
310
|
+
if (boundaryString === undefined || boundaryString === null) throw parsingError("missing boundary in content-type header");
|
|
311
|
+
const boundary = Buffer.from(`--${boundaryString}`, "utf8");
|
|
312
|
+
const entryList = [];
|
|
313
|
+
const position = { position: 0 };
|
|
314
|
+
const firstBoundaryIndex = input.indexOf(boundary);
|
|
315
|
+
if (firstBoundaryIndex === -1) throw parsingError("no boundary found in multipart body");
|
|
316
|
+
position.position = firstBoundaryIndex;
|
|
317
|
+
while (true) {
|
|
318
|
+
if (input.subarray(position.position, position.position + boundary.length).equals(boundary)) position.position += boundary.length;
|
|
319
|
+
else throw parsingError("expected a value starting with -- and the boundary");
|
|
320
|
+
if (bufferStartsWith(input, dd, position)) return entryList;
|
|
321
|
+
if (input[position.position] !== 0x0d || input[position.position + 1] !== 0x0a) throw parsingError("expected CRLF");
|
|
322
|
+
position.position += 2;
|
|
323
|
+
const result = parseMultipartFormDataHeaders(input, position);
|
|
324
|
+
const { name, filename, encoding } = result;
|
|
325
|
+
let { contentType } = result;
|
|
326
|
+
position.position += 2;
|
|
327
|
+
let body;
|
|
328
|
+
{
|
|
329
|
+
const boundaryIndex = input.indexOf(boundary.subarray(2), position.position);
|
|
330
|
+
if (boundaryIndex === -1) throw parsingError("expected boundary after body");
|
|
331
|
+
body = input.subarray(position.position, boundaryIndex - 4);
|
|
332
|
+
position.position += body.length;
|
|
333
|
+
if (encoding === "base64") body = Buffer.from(body.toString(), "base64");
|
|
334
|
+
}
|
|
335
|
+
if (input[position.position] !== 0x0d || input[position.position + 1] !== 0x0a) throw parsingError("expected CRLF");
|
|
336
|
+
position.position += 2;
|
|
337
|
+
let value;
|
|
338
|
+
if (filename !== null) {
|
|
339
|
+
contentType ??= "text/plain";
|
|
340
|
+
if (!isAsciiString(contentType)) contentType = "";
|
|
341
|
+
value = new File([body], filename, { type: contentType });
|
|
342
|
+
} else {
|
|
343
|
+
value = decoderIgnoreBOM.decode(Buffer.from(body));
|
|
344
|
+
}
|
|
345
|
+
entryList.push(makeEntry(name, value, filename ?? undefined));
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/** formData(): the body's bytes (a promise of them) parsed as the Content-Type says. */
|
|
350
|
+
function parse(bytes, contentType) {
|
|
351
|
+
return bytes.then((value) => {
|
|
352
|
+
let mime = null;
|
|
353
|
+
if (contentType !== null) {
|
|
354
|
+
try {
|
|
355
|
+
mime = new MIMEType(contentType);
|
|
356
|
+
} catch {
|
|
357
|
+
mime = null;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
const input = Buffer.from(value.buffer, value.byteOffset, value.byteLength);
|
|
361
|
+
if (mime !== null && mime.essence === "multipart/form-data") {
|
|
362
|
+
const fd = new FormData();
|
|
363
|
+
states.get(fd).entries = multipartFormDataParser(input, mime.params.get("boundary"));
|
|
364
|
+
return fd;
|
|
365
|
+
}
|
|
366
|
+
if (mime !== null && mime.essence === "application/x-www-form-urlencoded") {
|
|
367
|
+
const fd = new FormData();
|
|
368
|
+
for (const [name, entry] of new URLSearchParams(input.toString())) fd.append(name, entry);
|
|
369
|
+
return fd;
|
|
370
|
+
}
|
|
371
|
+
throw new TypeError('Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".');
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
fetchFormDataHooks(serialize, parse);
|
|
376
|
+
Object.defineProperty(globalThis, "FormData", { value: FormData, writable: true, enumerable: false, configurable: true });
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// fs's BigIntStats: a stat call's figures as BigInts, its times in nanoseconds too (atimeNs, …), for
|
|
2
|
+
// the `bigint: true` option, as Node's. A module of its own, linked into programs that name the
|
|
3
|
+
// option (implicitModules in node/index.ts): it names BigInt, which links the runtime's BigInt.
|
|
4
|
+
import { lazyDateFields, StatsBase } from "./fs_stats.js";
|
|
5
|
+
import { features } from "./features.js";
|
|
6
|
+
|
|
7
|
+
const kNsPerMsBigInt = BigInt(1000000);
|
|
8
|
+
|
|
9
|
+
/* a time the host gives in milliseconds (fractional) as nanoseconds, the whole part exactly */
|
|
10
|
+
function nanoseconds(ms) {
|
|
11
|
+
const whole = Math.floor(ms);
|
|
12
|
+
return BigInt(whole) * kNsPerMsBigInt + BigInt(Math.round((ms - whole) * 1e6));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function BigIntStats(dev, mode, nlink, uid, gid, rdev, blksize, ino, size, blocks, atimeNs, mtimeNs, ctimeNs, birthtimeNs) {
|
|
16
|
+
StatsBase.call(this, dev, mode, nlink, uid, gid, rdev, blksize, ino, size, blocks);
|
|
17
|
+
this.atimeMs = atimeNs / kNsPerMsBigInt;
|
|
18
|
+
this.mtimeMs = mtimeNs / kNsPerMsBigInt;
|
|
19
|
+
this.ctimeMs = ctimeNs / kNsPerMsBigInt;
|
|
20
|
+
this.birthtimeMs = birthtimeNs / kNsPerMsBigInt;
|
|
21
|
+
this.atimeNs = atimeNs;
|
|
22
|
+
this.mtimeNs = mtimeNs;
|
|
23
|
+
this.ctimeNs = ctimeNs;
|
|
24
|
+
this.birthtimeNs = birthtimeNs;
|
|
25
|
+
}
|
|
26
|
+
Object.setPrototypeOf(BigIntStats.prototype, StatsBase.prototype);
|
|
27
|
+
Object.setPrototypeOf(BigIntStats, StatsBase);
|
|
28
|
+
Object.defineProperties(BigIntStats.prototype, lazyDateFields);
|
|
29
|
+
|
|
30
|
+
BigIntStats.prototype._checkModeProperty = function (property) {
|
|
31
|
+
if (process.platform === "win32" && (property === 0o010000 || property === 0o060000 || property === 0o140000)) return false;
|
|
32
|
+
return (this.mode & BigInt(0o170000)) === BigInt(property);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/* the host's stat array (fs.js's statsFrom) */
|
|
36
|
+
features.BigIntStats = function fromHost(r) {
|
|
37
|
+
const [mode, size, mtimeMs, atimeMs, ctimeMs, birthtimeMs, ino, dev, nlink, uid, gid, rdev, blksize, blocks] = r;
|
|
38
|
+
const big = (n) => BigInt(Math.trunc(n));
|
|
39
|
+
return new BigIntStats(big(dev), big(mode), big(nlink), big(uid), big(gid), big(rdev), big(blksize), big(ino), big(size), big(blocks),
|
|
40
|
+
nanoseconds(atimeMs), nanoseconds(mtimeMs), nanoseconds(ctimeMs), nanoseconds(birthtimeMs));
|
|
41
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// fs.openAsBlob: a file's contents as a Blob. Linked into programs that name it (internal/features.js):
|
|
2
|
+
// it links the runtime's Blob.
|
|
3
|
+
import { readFileSync } from "../fs.js";
|
|
4
|
+
import { invalidArgType } from "./errors.js";
|
|
5
|
+
import { features } from "./features.js";
|
|
6
|
+
|
|
7
|
+
/** openAsBlob(path[, { type }]): a promise of the file's Blob (read now, as fs's other calls). */
|
|
8
|
+
function openAsBlob(path, options = {}) {
|
|
9
|
+
if (typeof path !== "string" && !(path instanceof URL) && !(path instanceof Uint8Array)) {
|
|
10
|
+
throw invalidArgType("path", "of type string or an instance of Buffer or URL", path);
|
|
11
|
+
}
|
|
12
|
+
if (options === null || typeof options !== "object") throw invalidArgType("options", "of type object", options);
|
|
13
|
+
const type = options.type ?? "";
|
|
14
|
+
if (typeof type !== "string") throw invalidArgType("options.type", "of type string", type);
|
|
15
|
+
const file = path instanceof URL ? decodeURIComponent(path.pathname) : path instanceof Uint8Array ? Buffer.from(path).toString() : path;
|
|
16
|
+
return Promise.resolve(new globalThis.Blob([readFileSync(file)], { type }));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
features.openAsBlob = openAsBlob;
|