visaljs 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -2
- package/THIRD_PARTY_LICENSES +1216 -0
- package/cli.js +4413 -324
- package/node/include/js_node.h +57 -1
- package/node/include/js_uv.h +8 -1
- package/node/prelude/_stream_duplex.js +4 -0
- package/node/prelude/_stream_passthrough.js +4 -0
- package/node/prelude/_stream_readable.js +4 -0
- package/node/prelude/_stream_transform.js +4 -0
- package/node/prelude/_stream_writable.js +4 -0
- package/node/prelude/assert.js +1334 -0
- package/node/prelude/assert_strict.js +12 -0
- package/node/prelude/async_hooks.js +1 -1
- package/node/prelude/buffer.js +43 -3
- package/node/prelude/child_process.js +1098 -0
- package/node/prelude/cluster.js +52 -0
- package/node/prelude/console.js +328 -0
- package/node/prelude/constants.js +10 -0
- package/node/prelude/crypto.js +1 -1
- package/node/prelude/diagnostics_channel.js +1 -1
- package/node/prelude/dns.js +1 -1
- package/node/prelude/domain.js +115 -0
- package/node/prelude/events.js +144 -16
- package/node/prelude/fs.js +1138 -151
- package/node/prelude/fs_promises.js +117 -11
- package/node/prelude/http.js +104 -27
- package/node/prelude/http2.js +1 -1
- package/node/prelude/https.js +148 -0
- package/node/prelude/inspector.js +27 -0
- package/node/prelude/inspector_promises.js +4 -0
- package/node/prelude/internal/async_context.js +1 -1
- package/node/prelude/internal/buffer_transcode.js +44 -0
- package/node/prelude/internal/comparisons.js +916 -0
- package/node/prelude/internal/compression_streams.js +153 -0
- package/node/prelude/internal/crypto/asym.js +27 -14
- package/node/prelude/internal/crypto/cipher.js +16 -5
- package/node/prelude/internal/crypto/diffiehellman.js +3 -2
- package/node/prelude/internal/crypto/hash.js +2 -1
- package/node/prelude/internal/crypto/kdf.js +14 -9
- package/node/prelude/internal/crypto/keys.js +63 -50
- package/node/prelude/internal/crypto/random.js +2 -1
- package/node/prelude/internal/crypto/util.js +4 -4
- package/node/prelude/internal/dotenv.js +98 -0
- package/node/prelude/internal/errors.js +21 -5
- package/node/prelude/internal/events_extras.js +116 -0
- package/node/prelude/internal/events_on.js +100 -0
- package/node/prelude/internal/features.js +55 -0
- package/node/prelude/internal/fetch.js +364 -0
- package/node/prelude/internal/form_data.js +376 -0
- package/node/prelude/internal/fs_bigint_stats.js +41 -0
- package/node/prelude/internal/fs_blob.js +19 -0
- package/node/prelude/internal/fs_cp.js +709 -0
- package/node/prelude/internal/fs_dir.js +166 -0
- package/node/prelude/internal/fs_filehandle.js +287 -0
- package/node/prelude/internal/fs_glob.js +296 -0
- package/node/prelude/internal/fs_statfs.js +42 -0
- package/node/prelude/internal/fs_stats.js +89 -0
- package/node/prelude/internal/fs_streams.js +541 -0
- package/node/prelude/internal/fs_utils.js +286 -0
- package/node/prelude/internal/fs_watch.js +580 -0
- package/node/prelude/internal/http_agent.js +26 -0
- package/node/prelude/internal/mime.js +249 -0
- package/node/prelude/internal/net.js +1 -0
- package/node/prelude/internal/parse_args.js +288 -0
- package/node/prelude/internal/perf_histogram.js +435 -0
- package/node/prelude/internal/perf_observe.js +119 -0
- package/node/prelude/internal/performance_global.js +19 -0
- package/node/prelude/internal/process_events.js +49 -1
- package/node/prelude/internal/process_memory.js +14 -0
- package/node/prelude/internal/process_more.js +414 -0
- package/node/prelude/internal/process_signals.js +2 -1
- package/node/prelude/internal/process_stdin.js +52 -0
- package/node/prelude/internal/process_stdio.js +36 -0
- package/node/prelude/internal/querystring.js +0 -0
- package/node/prelude/internal/readline.js +338 -0
- package/node/prelude/internal/socketaddress.js +8 -4
- package/node/prelude/internal/source_map.js +122 -0
- package/node/prelude/internal/stream_compose.js +74 -0
- package/node/prelude/internal/stream_from.js +6 -0
- package/node/prelude/internal/stream_operators.js +23 -0
- package/node/prelude/internal/stream_pipeline.js +7 -0
- package/node/prelude/internal/stream_transform.js +10 -0
- package/node/prelude/internal/stream_web_adapters.js +143 -0
- package/node/prelude/internal/streams/add_abort_signal.js +58 -0
- package/node/prelude/internal/streams/compose.js +244 -0
- package/node/prelude/internal/streams/destroy.js +358 -0
- package/node/prelude/internal/streams/duplex.js +199 -0
- package/node/prelude/internal/streams/duplexify.js +378 -0
- package/node/prelude/internal/streams/end_of_stream.js +387 -0
- package/node/prelude/internal/streams/errors.js +216 -0
- package/node/prelude/internal/streams/from.js +211 -0
- package/node/prelude/internal/streams/legacy.js +120 -0
- package/node/prelude/internal/streams/operators.js +375 -0
- package/node/prelude/internal/streams/passthrough.js +45 -0
- package/node/prelude/internal/streams/pipeline.js +468 -0
- package/node/prelude/internal/streams/readable.js +1835 -0
- package/node/prelude/internal/streams/state.js +48 -0
- package/node/prelude/internal/streams/transform.js +203 -0
- package/node/prelude/internal/streams/utils.js +355 -0
- package/node/prelude/internal/streams/validators.js +108 -0
- package/node/prelude/internal/streams/writable.js +1160 -0
- package/node/prelude/internal/structured_clone.js +238 -0
- package/node/prelude/internal/system_errors.js +37 -0
- package/node/prelude/internal/test_runner/mock.js +431 -0
- package/node/prelude/internal/test_runner/reporters.js +404 -0
- package/node/prelude/internal/test_runner/test.js +1571 -0
- package/node/prelude/internal/timers.js +38 -7
- package/node/prelude/internal/timers_global.js +1 -1
- package/node/prelude/internal/tls/common.js +8 -2
- package/node/prelude/internal/tls/wrap.js +3 -15
- package/node/prelude/internal/tls/x509.js +1 -1
- package/node/prelude/internal/tty_read_stream.js +39 -0
- package/node/prelude/internal/tty_streams.js +3 -0
- package/node/prelude/internal/util_debuglog.js +68 -0
- package/node/prelude/internal/util_diff.js +63 -0
- package/node/prelude/internal/util_more.js +111 -0
- package/node/prelude/internal/util_styles.js +76 -0
- package/node/prelude/internal/zlib_engines.js +1 -1
- package/node/prelude/module.js +194 -7
- package/node/prelude/net.js +2 -1
- package/node/prelude/os.js +88 -11
- package/node/prelude/path.js +11 -7
- package/node/prelude/path_posix.js +1 -1
- package/node/prelude/path_win32.js +1 -1
- package/node/prelude/perf_hooks.js +147 -0
- package/node/prelude/process.js +36 -1
- package/node/prelude/punycode.js +188 -0
- package/node/prelude/querystring.js +1 -1
- package/node/prelude/readline.js +8 -0
- package/node/prelude/readline_promises.js +88 -0
- package/node/prelude/repl.js +38 -0
- package/node/prelude/sea.js +23 -0
- package/node/prelude/stream.js +70 -1332
- package/node/prelude/stream_consumers.js +34 -0
- package/node/prelude/stream_promises.js +1 -1
- package/node/prelude/stream_web.js +15 -2
- package/node/prelude/string_decoder.js +1 -1
- package/node/prelude/sys.js +7 -0
- package/node/prelude/test.js +56 -0
- package/node/prelude/test_reporters.js +269 -0
- package/node/prelude/timers.js +7 -84
- package/node/prelude/timers_promises.js +1 -1
- package/node/prelude/tls.js +2 -1
- package/node/prelude/trace_events.js +52 -0
- package/node/prelude/tty.js +10 -4
- package/node/prelude/url.js +88 -27
- package/node/prelude/util.js +121 -5
- package/node/prelude/util_types.js +4 -3
- package/node/prelude/v8.js +814 -0
- package/node/prelude/vm.js +86 -0
- package/node/prelude/wasi.js +10 -0
- package/node/prelude/worker_threads.js +56 -0
- package/node/prelude/zlib.js +58 -25
- package/node/src/host_brotli.c +59 -11
- package/node/src/host_fs.c +342 -11
- package/node/src/host_fswatch.c +170 -0
- package/node/src/host_http.c +143 -20
- package/node/src/host_loop.c +25 -2
- package/node/src/host_net.c +55 -7
- package/node/src/host_os.c +55 -1
- package/node/src/host_proc.c +291 -0
- package/node/src/host_process.c +488 -0
- package/node/src/host_sys.c +64 -2
- package/node/src/host_zlib.c +27 -7
- package/node/src/host_zstd.c +41 -6
- package/node/third_party/hdrhistogram/LICENSE +42 -0
- package/node/third_party/hdrhistogram/README.md +5 -0
- package/node/third_party/libuv/LICENSE +0 -0
- package/node/third_party/libuv/LICENSE-extra +36 -0
- package/node/third_party/libuv/include/uv/aix.h +0 -0
- package/node/third_party/libuv/include/uv/bsd.h +0 -0
- package/node/third_party/libuv/include/uv/darwin.h +0 -0
- package/node/third_party/libuv/include/uv/errno.h +0 -0
- package/node/third_party/libuv/include/uv/linux.h +0 -0
- package/node/third_party/libuv/include/uv/os390.h +0 -0
- package/node/third_party/libuv/include/uv/posix.h +0 -0
- package/node/third_party/libuv/include/uv/sunos.h +0 -0
- package/node/third_party/libuv/include/uv/threadpool.h +0 -0
- package/node/third_party/libuv/include/uv/tree.h +0 -0
- package/node/third_party/libuv/include/uv/unix.h +0 -0
- package/node/third_party/libuv/include/uv/version.h +0 -0
- package/node/third_party/libuv/include/uv/win.h +0 -0
- package/node/third_party/libuv/include/uv.h +0 -0
- package/node/third_party/libuv/src/fs-poll.c +0 -0
- package/node/third_party/libuv/src/heap-inl.h +0 -0
- package/node/third_party/libuv/src/idna.c +0 -0
- package/node/third_party/libuv/src/idna.h +0 -0
- package/node/third_party/libuv/src/inet.c +0 -0
- package/node/third_party/libuv/src/queue.h +0 -0
- package/node/third_party/libuv/src/random.c +0 -0
- package/node/third_party/libuv/src/strscpy.c +0 -0
- package/node/third_party/libuv/src/strscpy.h +0 -0
- package/node/third_party/libuv/src/strtok.c +0 -0
- package/node/third_party/libuv/src/strtok.h +0 -0
- package/node/third_party/libuv/src/thread-common.c +0 -0
- package/node/third_party/libuv/src/threadpool.c +0 -0
- package/node/third_party/libuv/src/timer.c +0 -0
- package/node/third_party/libuv/src/unix/async.c +0 -0
- package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +0 -0
- package/node/third_party/libuv/src/unix/core.c +0 -0
- package/node/third_party/libuv/src/unix/darwin-proctitle.c +0 -0
- package/node/third_party/libuv/src/unix/darwin-stub.h +0 -0
- package/node/third_party/libuv/src/unix/darwin-syscalls.h +0 -0
- package/node/third_party/libuv/src/unix/darwin.c +0 -0
- package/node/third_party/libuv/src/unix/dl.c +0 -0
- package/node/third_party/libuv/src/unix/fs.c +0 -0
- package/node/third_party/libuv/src/unix/fsevents.c +0 -0
- package/node/third_party/libuv/src/unix/getaddrinfo.c +0 -0
- package/node/third_party/libuv/src/unix/getnameinfo.c +0 -0
- package/node/third_party/libuv/src/unix/internal.h +0 -0
- package/node/third_party/libuv/src/unix/kqueue.c +0 -0
- package/node/third_party/libuv/src/unix/linux.c +0 -0
- package/node/third_party/libuv/src/unix/loop-watcher.c +0 -0
- package/node/third_party/libuv/src/unix/loop.c +0 -0
- package/node/third_party/libuv/src/unix/pipe.c +0 -0
- package/node/third_party/libuv/src/unix/poll.c +0 -0
- package/node/third_party/libuv/src/unix/process.c +0 -0
- package/node/third_party/libuv/src/unix/procfs-exepath.c +0 -0
- package/node/third_party/libuv/src/unix/proctitle.c +0 -0
- package/node/third_party/libuv/src/unix/random-devurandom.c +0 -0
- package/node/third_party/libuv/src/unix/random-getentropy.c +0 -0
- package/node/third_party/libuv/src/unix/random-getrandom.c +0 -0
- package/node/third_party/libuv/src/unix/random-sysctl-linux.c +0 -0
- package/node/third_party/libuv/src/unix/signal.c +0 -0
- package/node/third_party/libuv/src/unix/stream.c +0 -0
- package/node/third_party/libuv/src/unix/tcp.c +0 -0
- package/node/third_party/libuv/src/unix/thread.c +0 -0
- package/node/third_party/libuv/src/unix/tty.c +0 -0
- package/node/third_party/libuv/src/unix/udp.c +0 -0
- package/node/third_party/libuv/src/uv-common.c +0 -0
- package/node/third_party/libuv/src/uv-common.h +0 -0
- package/node/third_party/libuv/src/uv-data-getter-setters.c +0 -0
- package/node/third_party/libuv/src/version.c +0 -0
- package/node/third_party/llhttp/LICENSE +0 -0
- package/node/third_party/llhttp/api.c +0 -0
- package/node/third_party/llhttp/http.c +0 -0
- package/node/third_party/llhttp/llhttp.c +0 -0
- package/node/third_party/llhttp/llhttp.h +0 -0
- package/node/third_party/nodejs/LICENSE +47 -0
- package/node/third_party/nodejs/README.md +5 -0
- package/node/third_party/parseargs/LICENSE +21 -0
- package/node/third_party/parseargs/README.md +5 -0
- package/node/third_party/punycode/LICENSE +20 -0
- package/node/third_party/punycode/README.md +5 -0
- package/node/third_party/zlib/LICENSE.chromium +27 -0
- package/package.json +1 -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 +1 -1
- package/runtime/include/js_bigint.h +1 -1
- package/runtime/include/js_buffer.h +4 -4
- package/runtime/include/js_builtins.h +41 -3
- package/runtime/include/js_console.h +9 -4
- package/runtime/include/js_convert.h +1 -1
- package/runtime/include/js_core.def +5 -4
- package/runtime/include/js_crypto.h +1 -1
- package/runtime/include/js_error.h +1 -1
- package/runtime/include/js_exception.h +21 -1
- package/runtime/include/js_function.h +33 -9
- package/runtime/include/js_gc.h +172 -30
- package/runtime/include/js_generator.h +2 -2
- package/runtime/include/js_host.h +19 -1
- package/runtime/include/js_jobs.h +5 -5
- package/runtime/include/js_module.h +1 -1
- package/runtime/include/js_object.h +142 -15
- package/runtime/include/js_ops.h +107 -5
- package/runtime/include/js_promise.h +3 -3
- package/runtime/include/js_regexp.h +1 -1
- package/runtime/include/js_runtime.h +0 -0
- package/runtime/include/js_symbol.h +1 -1
- package/runtime/include/js_web.h +2 -1
- package/runtime/include/jscell.h +22 -15
- package/runtime/include/jscontext.h +74 -39
- package/runtime/include/jsnum.h +1 -1
- package/runtime/include/jsstring.h +19 -6
- package/runtime/include/jsvalue.h +7 -3
- package/runtime/src/arguments.c +2 -2
- package/runtime/src/array.c +4 -1
- package/runtime/src/arraybuffer.c +19 -7
- package/runtime/src/async_iter.c +4 -3
- package/runtime/src/atoms.c +1 -1
- package/runtime/src/base64.c +2 -2
- package/runtime/src/bigint.c +1 -1
- package/runtime/src/blob.c +22 -9
- package/runtime/src/boringssl_support.cc +1 -1
- package/runtime/src/buffer.c +299 -91
- package/runtime/src/builtin_table.c +1 -1
- package/runtime/src/builtins.c +30 -4
- package/runtime/src/builtins_util.h +0 -0
- package/runtime/src/collections.c +18 -3
- package/runtime/src/components.c +1 -1
- package/runtime/src/console.c +14 -7
- package/runtime/src/convert.c +0 -0
- package/runtime/src/core_all.c +1 -1
- package/runtime/src/crypto.c +1 -1
- package/runtime/src/crypto_asym.c +1 -1
- package/runtime/src/crypto_bn.c +1 -1
- package/runtime/src/crypto_cipher.c +10 -3
- package/runtime/src/crypto_hash.c +1 -1
- package/runtime/src/crypto_host.c +1 -1
- package/runtime/src/crypto_internal.h +1 -1
- package/runtime/src/crypto_kdf.c +1 -1
- package/runtime/src/crypto_key.c +14 -1
- package/runtime/src/crypto_pkey.c +1 -1
- package/runtime/src/crypto_subtle.c +142 -58
- package/runtime/src/crypto_tls.c +1 -1
- package/runtime/src/date.c +5 -2
- package/runtime/src/domexception.c +2 -2
- package/runtime/src/elements.c +56 -17
- package/runtime/src/elements.h +7 -2
- package/runtime/src/encoding.c +1 -1
- package/runtime/src/error.c +4 -4
- package/runtime/src/events.c +23 -14
- package/runtime/src/exception.c +1 -1
- package/runtime/src/fetch.c +241 -17
- package/runtime/src/function.c +31 -19
- package/runtime/src/gc.c +1716 -207
- package/runtime/src/gc_visit.h +87 -0
- package/runtime/src/generator.c +5 -3
- package/runtime/src/global.c +14 -6
- package/runtime/src/headers.c +10 -10
- package/runtime/src/inspect.c +76 -17
- package/runtime/src/internal.h +5 -2
- package/runtime/src/iterate.c +94 -2
- package/runtime/src/iterator.c +1 -1
- package/runtime/src/jobs.c +11 -5
- package/runtime/src/jsnum.c +2 -2
- package/runtime/src/json.c +1 -1
- package/runtime/src/math.c +9 -1
- package/runtime/src/module.c +3 -3
- package/runtime/src/number.c +0 -0
- package/runtime/src/object.c +107 -74
- package/runtime/src/ops.c +21 -3
- package/runtime/src/os.c +192 -1
- package/runtime/src/os.h +33 -2
- package/runtime/src/process.c +73 -8
- package/runtime/src/promise.c +4 -4
- package/runtime/src/proxy.c +1 -1
- package/runtime/src/reflect.c +1 -1
- package/runtime/src/regexp.c +134 -2
- package/runtime/src/regexp_anchor.h +1 -1
- package/runtime/src/regexp_message.h +1 -1
- package/runtime/src/shape.c +10 -19
- package/runtime/src/shape.h +0 -0
- package/runtime/src/streams.c +22 -8
- package/runtime/src/streams.h +0 -0
- package/runtime/src/string.c +64 -25
- package/runtime/src/string_builtins.c +7 -7
- package/runtime/src/symbol.c +2 -7
- package/runtime/src/test_host.c +3 -3
- package/runtime/src/tls_roots.gen.h +102 -620
- package/runtime/src/typedarray.c +8 -3
- package/runtime/src/tznames.gen.h +2 -1
- package/runtime/src/uri.c +1 -1
- package/runtime/src/url.c +42 -39
- package/runtime/src/weak.c +15 -12
- package/runtime/src/web.c +21 -3
- package/runtime/src/wrapper.c +0 -0
- package/runtime/src/writable.c +7 -6
- package/runtime/third_party/ada-idna/LICENSE-MIT +0 -0
- package/runtime/third_party/ada-idna/README.md +7 -7
- package/runtime/third_party/ada-idna/convert.mjs +89 -27
- package/runtime/third_party/ada-idna/idna.c +30 -31
- package/runtime/third_party/ada-idna/idna.h +0 -0
- package/runtime/third_party/ada-idna/idna_tables.h +2272 -1952
- package/runtime/third_party/boringssl/third_party/fiat/LICENSE +15 -0
- package/runtime/third_party/mozilla-ca/LICENSE +373 -0
- package/runtime/third_party/mozilla-ca/README.md +9 -0
- package/runtime/third_party/nodejs/LICENSE +47 -0
- package/runtime/third_party/nodejs/README.md +7 -0
- package/runtime/third_party/quickjs-dtoa/LICENSE +0 -0
- package/runtime/third_party/quickjs-dtoa/README.md +1 -1
- package/runtime/third_party/quickjs-dtoa/dtoa.c +0 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.h +0 -0
- package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +0 -0
- package/runtime/third_party/quickjs-regexp/LICENSE +0 -0
- package/runtime/third_party/quickjs-regexp/README.md +2 -2
- package/runtime/third_party/quickjs-regexp/cutils.c +0 -0
- package/runtime/third_party/quickjs-regexp/cutils.h +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp.c +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp.h +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode-table.h +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode.c +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode.h +0 -0
- package/runtime/third_party/unicode/LICENSE +39 -0
- package/runtime/third_party/unicode/README.md +9 -0
- package/runtime/third_party/v8-ieee754/LICENSE +0 -0
- package/runtime/third_party/v8-ieee754/LICENSE.fdlibm +10 -0
- package/runtime/third_party/v8-ieee754/README.md +3 -2
- package/runtime/third_party/v8-ieee754/convert.py +0 -0
- package/runtime/third_party/v8-ieee754/ieee754.c +0 -0
- package/runtime/third_party/v8-ieee754/ieee754.h +0 -0
- package/runtime/tools/regexp_compile.c +2 -2
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// node:vm: contexts can be made and recognized, and memory measured, but running source text
|
|
2
|
+
// needs a JavaScript engine a compiled program doesn't have: Script runs, compileFunction and the
|
|
3
|
+
// run* functions throw ERR_VISALJS_UNSUPPORTED.
|
|
4
|
+
import { processMemory } from "visaljs:host";
|
|
5
|
+
import { invalidArgType, notSupported } from "./internal/errors.js";
|
|
6
|
+
|
|
7
|
+
const contexts = new WeakSet();
|
|
8
|
+
const kRunning = "vm (running source text)";
|
|
9
|
+
|
|
10
|
+
export const constants = Object.freeze({
|
|
11
|
+
USE_MAIN_CONTEXT_DEFAULT_LOADER: Symbol("vm_dynamic_import_main_context_default"),
|
|
12
|
+
DONT_CONTEXTIFY: Symbol("vm_context_no_contextify"),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
/** createContext([object]): the object, marked as a context. */
|
|
16
|
+
export function createContext(contextObject = {}, options) {
|
|
17
|
+
void options;
|
|
18
|
+
if (contextObject === constants.DONT_CONTEXTIFY) contextObject = {};
|
|
19
|
+
if (contextObject === null || typeof contextObject !== "object") throw invalidArgType("contextObject", "of type object", contextObject);
|
|
20
|
+
contexts.add(contextObject);
|
|
21
|
+
return contextObject;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function isContext(object) {
|
|
25
|
+
if (object === null || typeof object !== "object") throw invalidArgType("object", "of type object", object);
|
|
26
|
+
return contexts.has(object);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Source text to run: kept, but running it throws. */
|
|
30
|
+
export class Script {
|
|
31
|
+
constructor(code, options) {
|
|
32
|
+
if (typeof code !== "string") throw invalidArgType("code", "of type string", code);
|
|
33
|
+
this.code = code;
|
|
34
|
+
this.filename = typeof options === "string" ? options : options?.filename ?? "evalmachine.<anonymous>";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
runInThisContext() {
|
|
38
|
+
throw notSupported(kRunning);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
runInContext() {
|
|
42
|
+
throw notSupported(kRunning);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
runInNewContext() {
|
|
46
|
+
throw notSupported(kRunning);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
createCachedData() {
|
|
50
|
+
return Buffer.alloc(0);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function createScript(code, options) {
|
|
55
|
+
return new Script(code, options);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function runInThisContext() {
|
|
59
|
+
throw notSupported(kRunning);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function runInContext() {
|
|
63
|
+
throw notSupported(kRunning);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function runInNewContext() {
|
|
67
|
+
throw notSupported(kRunning);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function compileFunction() {
|
|
71
|
+
throw notSupported(kRunning);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The program's memory, as V8's estimate is reported: { total: { jsMemoryEstimate, jsMemoryRange } }. */
|
|
75
|
+
let measureWarned = false;
|
|
76
|
+
export function measureMemory(options = {}) {
|
|
77
|
+
if (!measureWarned) {
|
|
78
|
+
measureWarned = true;
|
|
79
|
+
process.emitWarning("vm.measureMemory is an experimental feature and might change at any time", "ExperimentalWarning");
|
|
80
|
+
}
|
|
81
|
+
if (options === null || typeof options !== "object") return Promise.reject(invalidArgType("options", "of type object", options));
|
|
82
|
+
const [, , heapUsed] = processMemory();
|
|
83
|
+
return Promise.resolve({ total: { jsMemoryEstimate: heapUsed, jsMemoryRange: [heapUsed, heapUsed] } });
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default { Script, compileFunction, constants, createContext, createScript, isContext, measureMemory, runInContext, runInNewContext, runInThisContext };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// node:worker_threads: a compiled program is one thread, the main one. What a
|
|
2
|
+
// program reads to find that out is as in Node's main thread (isMainThread, threadId 0, no
|
|
3
|
+
// parentPort or workerData), and the environment data and transfer marks work in it. Starting a
|
|
4
|
+
// thread (Worker) and message ports throw ERR_VISALJS_UNSUPPORTED: libraries that only load the
|
|
5
|
+
// module for a parallel mode (mocha's workerpool) run until asked for it.
|
|
6
|
+
import { notSupported } from "./internal/errors.js";
|
|
7
|
+
|
|
8
|
+
export const isMainThread = true;
|
|
9
|
+
export const isInternalThread = false;
|
|
10
|
+
export const parentPort = null;
|
|
11
|
+
export const workerData = null;
|
|
12
|
+
export const threadId = 0;
|
|
13
|
+
export const threadName = "";
|
|
14
|
+
export const resourceLimits = {};
|
|
15
|
+
export const SHARE_ENV = Symbol.for("nodejs.worker_threads.SHARE_ENV");
|
|
16
|
+
|
|
17
|
+
const environmentData = new Map();
|
|
18
|
+
export function getEnvironmentData(key) {
|
|
19
|
+
return environmentData.get(key);
|
|
20
|
+
}
|
|
21
|
+
export function setEnvironmentData(key, value) {
|
|
22
|
+
if (value === undefined) environmentData.delete(key);
|
|
23
|
+
else environmentData.set(key, value);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const untransferable = new WeakSet();
|
|
27
|
+
export function markAsUntransferable(object) {
|
|
28
|
+
if ((typeof object === "object" && object !== null) || typeof object === "function") untransferable.add(object);
|
|
29
|
+
}
|
|
30
|
+
export function isMarkedAsUntransferable(object) {
|
|
31
|
+
return ((typeof object === "object" && object !== null) || typeof object === "function") && untransferable.has(object);
|
|
32
|
+
}
|
|
33
|
+
/* nothing is sent between threads, so nothing to refuse to clone */
|
|
34
|
+
export function markAsUncloneable() {}
|
|
35
|
+
|
|
36
|
+
export class Worker {
|
|
37
|
+
constructor() { throw notSupported("worker_threads.Worker"); }
|
|
38
|
+
}
|
|
39
|
+
export class MessageChannel {
|
|
40
|
+
constructor() { throw notSupported("worker_threads.MessageChannel"); }
|
|
41
|
+
}
|
|
42
|
+
export class MessagePort {
|
|
43
|
+
constructor() { throw notSupported("worker_threads.MessagePort"); }
|
|
44
|
+
}
|
|
45
|
+
export class BroadcastChannel {
|
|
46
|
+
constructor() { throw notSupported("worker_threads.BroadcastChannel"); }
|
|
47
|
+
}
|
|
48
|
+
export function moveMessagePortToContext() { throw notSupported("worker_threads.moveMessagePortToContext"); }
|
|
49
|
+
export function receiveMessageOnPort() { throw notSupported("worker_threads.receiveMessageOnPort"); }
|
|
50
|
+
export function postMessageToThread() { throw notSupported("worker_threads.postMessageToThread"); }
|
|
51
|
+
|
|
52
|
+
export default {
|
|
53
|
+
isMainThread, isInternalThread, parentPort, workerData, threadId, threadName, resourceLimits, SHARE_ENV,
|
|
54
|
+
getEnvironmentData, setEnvironmentData, markAsUntransferable, isMarkedAsUntransferable, markAsUncloneable,
|
|
55
|
+
Worker, MessageChannel, MessagePort, BroadcastChannel, moveMessagePortToContext, receiveMessageOnPort, postMessageToThread,
|
|
56
|
+
};
|
package/node/prelude/zlib.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
// node:zlib
|
|
1
|
+
// node:zlib: Node's lib/zlib.js (v24) on Node's binding, which is C here
|
|
2
2
|
// (node/src/host_zlib.c over Chromium's zlib, the copy Node vendors): the same streams, the same
|
|
3
3
|
// convenience functions, and the same compressed bytes, Brotli's and zstd's too (node/src/host_brotli.c
|
|
4
4
|
// and host_zstd.c, linked into programs that name them: internal/zlib_engines.js). A write's
|
|
5
5
|
// callback runs a turn later, where Node's thread pool would call it back.
|
|
6
|
+
// Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
|
|
6
7
|
import { timerStart, zlibClose, zlibCrc32, zlibInit, zlibNew, zlibParams, zlibReset, zlibWrite } from "visaljs:host";
|
|
7
8
|
import { Buffer, kMaxLength } from "./buffer.js";
|
|
8
9
|
import { codeError, invalidArgType, outOfRange } from "./internal/errors.js";
|
|
9
|
-
import { finished
|
|
10
|
+
import { finished } from "./stream.js";
|
|
11
|
+
import Transform from "./internal/streams/transform.js";
|
|
10
12
|
import { deprecate } from "./util.js";
|
|
11
13
|
import { engines } from "./internal/zlib_engines.js";
|
|
12
14
|
|
|
@@ -84,6 +86,8 @@ export const codes = {
|
|
|
84
86
|
};
|
|
85
87
|
for (const ckey of Object.keys(codes)) codes[codes[ckey]] = ckey;
|
|
86
88
|
Object.freeze(codes);
|
|
89
|
+
/* each constant read-only and permanent, as NODE_DEFINE_CONSTANT makes them */
|
|
90
|
+
for (const key of Object.keys(constants)) Object.defineProperty(constants, key, { writable: false, configurable: false });
|
|
87
91
|
|
|
88
92
|
const kFlushFlag = Symbol("kFlushFlag");
|
|
89
93
|
const kError = Symbol("kError");
|
|
@@ -158,6 +162,7 @@ class CompressionHandle {
|
|
|
158
162
|
}
|
|
159
163
|
|
|
160
164
|
reset() {
|
|
165
|
+
if (this._writing) throw new Error("Cannot reset zlib stream while a write is in progress");
|
|
161
166
|
const failure = this._ops.reset(this._native);
|
|
162
167
|
if (failure !== 0) this._emitError(failure);
|
|
163
168
|
}
|
|
@@ -179,10 +184,10 @@ class ZlibHandle extends CompressionHandle {
|
|
|
179
184
|
super(zlibOps, zlibNew(mode));
|
|
180
185
|
}
|
|
181
186
|
|
|
182
|
-
init(windowBits, level, memLevel, strategy, writeResult, writeCallback, dictionary) {
|
|
187
|
+
init(windowBits, level, memLevel, strategy, writeResult, writeCallback, dictionary, rejectGarbageAfterEnd) {
|
|
183
188
|
this._writeResult = writeResult;
|
|
184
189
|
this._writeCallback = writeCallback;
|
|
185
|
-
zlibInit(this._native, windowBits, level, memLevel, strategy, isArrayBufferView(dictionary) ? dictionary : undefined);
|
|
190
|
+
zlibInit(this._native, windowBits, level, memLevel, strategy, isArrayBufferView(dictionary) ? dictionary : undefined, rejectGarbageAfterEnd);
|
|
186
191
|
}
|
|
187
192
|
|
|
188
193
|
params(level, strategy) {
|
|
@@ -208,10 +213,10 @@ class BrotliHandle extends CompressionHandle {
|
|
|
208
213
|
super(ops, ops.new(mode));
|
|
209
214
|
}
|
|
210
215
|
|
|
211
|
-
init(params, writeResult, writeCallback) {
|
|
216
|
+
init(params, writeResult, writeCallback, dictionary) {
|
|
212
217
|
this._writeResult = writeResult;
|
|
213
218
|
this._writeCallback = writeCallback;
|
|
214
|
-
const failure = this._ops.init(this._native, params);
|
|
219
|
+
const failure = this._ops.init(this._native, params, dictionary);
|
|
215
220
|
if (failure !== 0) {
|
|
216
221
|
this._emitError(failure);
|
|
217
222
|
throw codeError(Error, "ERR_ZLIB_INITIALIZATION_FAILED", "Initialization failed");
|
|
@@ -231,11 +236,11 @@ class ZstdHandle extends CompressionHandle {
|
|
|
231
236
|
init(params, pledgedSrcSize, writeResult, writeCallback, dictionary) {
|
|
232
237
|
this._writeResult = writeResult;
|
|
233
238
|
this._writeCallback = writeCallback;
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (pledgedSrcSize
|
|
237
|
-
|
|
238
|
-
pledgedSrcSize
|
|
239
|
+
/* Node 24's binding checks it: a number, a safe integer, not negative */
|
|
240
|
+
if (pledgedSrcSize !== undefined) {
|
|
241
|
+
if (typeof pledgedSrcSize !== "number") throw codeError(TypeError, "ERR_INVALID_ARG_TYPE", "pledgedSrcSize must be a number");
|
|
242
|
+
if (!Number.isSafeInteger(pledgedSrcSize)) throw codeError(RangeError, "ERR_OUT_OF_RANGE", "pledgedSrcSize must be a safe integer");
|
|
243
|
+
if (pledgedSrcSize < 0) throw codeError(RangeError, "ERR_OUT_OF_RANGE", "pledgedSrcSize must be non-negative");
|
|
239
244
|
}
|
|
240
245
|
const failure = this._ops.init(this._native, params, pledgedSrcSize, dictionary);
|
|
241
246
|
if (failure !== 0) {
|
|
@@ -334,6 +339,7 @@ function ZlibBase(opts, mode, handle, { flush, finishFlush, fullFlush }) {
|
|
|
334
339
|
assert(mode >= DEFLATE && mode <= ZSTD_DECOMPRESS);
|
|
335
340
|
const brotli = mode === BROTLI_ENCODE || mode === BROTLI_DECODE;
|
|
336
341
|
const zstd = mode === ZSTD_COMPRESS || mode === ZSTD_DECOMPRESS;
|
|
342
|
+
/* FLUSH_BOUND: the flush kinds each engine takes */
|
|
337
343
|
const minFlush = brotli ? BROTLI_OPERATION_PROCESS : zstd ? ZSTD_e_continue : Z_NO_FLUSH;
|
|
338
344
|
const maxFlushFlag = brotli ? BROTLI_OPERATION_EMIT_METADATA : zstd ? ZSTD_e_end : Z_BLOCK;
|
|
339
345
|
|
|
@@ -347,6 +353,9 @@ function ZlibBase(opts, mode, handle, { flush, finishFlush, fullFlush }) {
|
|
|
347
353
|
flush = checkRangesOrGetDefault(opts.flush, "options.flush", minFlush, maxFlushFlag, flush);
|
|
348
354
|
finishFlush = checkRangesOrGetDefault(opts.finishFlush, "options.finishFlush", minFlush, maxFlushFlag, finishFlush);
|
|
349
355
|
maxOutputLength = checkRangesOrGetDefault(opts.maxOutputLength, "options.maxOutputLength", 1, kMaxLength, kMaxLength);
|
|
356
|
+
if (opts.rejectGarbageAfterEnd !== undefined && typeof opts.rejectGarbageAfterEnd !== "boolean") {
|
|
357
|
+
throw invalidArgType("options.rejectGarbageAfterEnd", "of type boolean", opts.rejectGarbageAfterEnd);
|
|
358
|
+
}
|
|
350
359
|
if (opts.encoding || opts.objectMode || opts.writableObjectMode) {
|
|
351
360
|
opts = { ...opts };
|
|
352
361
|
opts.encoding = null;
|
|
@@ -367,6 +376,7 @@ function ZlibBase(opts, mode, handle, { flush, finishFlush, fullFlush }) {
|
|
|
367
376
|
this._defaultFlushFlag = flush;
|
|
368
377
|
this._finishFlushFlag = finishFlush;
|
|
369
378
|
this._defaultFullFlushFlag = fullFlush;
|
|
379
|
+
this._flushBound = [minFlush, maxFlushFlag];
|
|
370
380
|
this._info = opts?.info;
|
|
371
381
|
this._maxOutputLength = maxOutputLength;
|
|
372
382
|
this._rejectGarbageAfterEnd = opts?.rejectGarbageAfterEnd === true;
|
|
@@ -435,6 +445,7 @@ ZlibBase.prototype.flush = function (kind, callback) {
|
|
|
435
445
|
callback = kind;
|
|
436
446
|
kind = this._defaultFullFlushFlag;
|
|
437
447
|
}
|
|
448
|
+
kind = checkRangesOrGetDefault(kind, "kind", this._flushBound[0], this._flushBound[1], this._defaultFullFlushFlag);
|
|
438
449
|
if (this.writableFinished) {
|
|
439
450
|
if (callback) process.nextTick(callback);
|
|
440
451
|
} else if (this.writableEnded) {
|
|
@@ -531,6 +542,11 @@ function processChunkSync(self, chunk, flushFlag) {
|
|
|
531
542
|
}
|
|
532
543
|
}
|
|
533
544
|
|
|
545
|
+
if (availInAfter > 0 && self._rejectGarbageAfterEnd) {
|
|
546
|
+
_close(self);
|
|
547
|
+
throw codeError(TypeError, "ERR_TRAILING_JUNK_AFTER_STREAM_END", "Trailing junk found after the end of the compressed stream");
|
|
548
|
+
}
|
|
549
|
+
|
|
534
550
|
self.bytesWritten = inputRead;
|
|
535
551
|
_close(self);
|
|
536
552
|
|
|
@@ -662,7 +678,7 @@ function Zlib(opts, mode) {
|
|
|
662
678
|
|
|
663
679
|
const handle = new ZlibHandle(mode);
|
|
664
680
|
this._writeState = new Uint32Array(2);
|
|
665
|
-
handle.init(windowBits, level, memLevel, strategy, this._writeState, processCallback, dictionary);
|
|
681
|
+
handle.init(windowBits, level, memLevel, strategy, this._writeState, processCallback, dictionary, opts?.rejectGarbageAfterEnd === true);
|
|
666
682
|
|
|
667
683
|
Reflect.apply(ZlibBase, this, [opts, mode, handle, zlibDefaultOpts]);
|
|
668
684
|
|
|
@@ -694,29 +710,39 @@ Zlib.prototype.params = function params(level, strategy, callback) {
|
|
|
694
710
|
}
|
|
695
711
|
};
|
|
696
712
|
|
|
713
|
+
/* a constructor called without new: Node 24 deprecates it (DEP0184), warning once */
|
|
714
|
+
let warnedInstantiation = false;
|
|
715
|
+
function deprecateInstantiation(target, opts) {
|
|
716
|
+
if (!warnedInstantiation) {
|
|
717
|
+
warnedInstantiation = true;
|
|
718
|
+
process.emitWarning(`Instantiating ${target.name} without the 'new' keyword has been deprecated.`, "DeprecationWarning", "DEP0184");
|
|
719
|
+
}
|
|
720
|
+
return new target(opts);
|
|
721
|
+
}
|
|
722
|
+
|
|
697
723
|
export function Deflate(opts) {
|
|
698
|
-
if (!(this instanceof Deflate)) return
|
|
724
|
+
if (!(this instanceof Deflate)) return deprecateInstantiation(Deflate, opts);
|
|
699
725
|
Reflect.apply(Zlib, this, [opts, DEFLATE]);
|
|
700
726
|
}
|
|
701
727
|
Object.setPrototypeOf(Deflate.prototype, Zlib.prototype);
|
|
702
728
|
Object.setPrototypeOf(Deflate, Zlib);
|
|
703
729
|
|
|
704
730
|
export function Inflate(opts) {
|
|
705
|
-
if (!(this instanceof Inflate)) return
|
|
731
|
+
if (!(this instanceof Inflate)) return deprecateInstantiation(Inflate, opts);
|
|
706
732
|
Reflect.apply(Zlib, this, [opts, INFLATE]);
|
|
707
733
|
}
|
|
708
734
|
Object.setPrototypeOf(Inflate.prototype, Zlib.prototype);
|
|
709
735
|
Object.setPrototypeOf(Inflate, Zlib);
|
|
710
736
|
|
|
711
737
|
export function Gzip(opts) {
|
|
712
|
-
if (!(this instanceof Gzip)) return
|
|
738
|
+
if (!(this instanceof Gzip)) return deprecateInstantiation(Gzip, opts);
|
|
713
739
|
Reflect.apply(Zlib, this, [opts, GZIP]);
|
|
714
740
|
}
|
|
715
741
|
Object.setPrototypeOf(Gzip.prototype, Zlib.prototype);
|
|
716
742
|
Object.setPrototypeOf(Gzip, Zlib);
|
|
717
743
|
|
|
718
744
|
export function Gunzip(opts) {
|
|
719
|
-
if (!(this instanceof Gunzip)) return
|
|
745
|
+
if (!(this instanceof Gunzip)) return deprecateInstantiation(Gunzip, opts);
|
|
720
746
|
Reflect.apply(Zlib, this, [opts, GUNZIP]);
|
|
721
747
|
}
|
|
722
748
|
Object.setPrototypeOf(Gunzip.prototype, Zlib.prototype);
|
|
@@ -724,21 +750,21 @@ Object.setPrototypeOf(Gunzip, Zlib);
|
|
|
724
750
|
|
|
725
751
|
export function DeflateRaw(opts) {
|
|
726
752
|
if (opts && opts.windowBits === 8) opts.windowBits = 9;
|
|
727
|
-
if (!(this instanceof DeflateRaw)) return
|
|
753
|
+
if (!(this instanceof DeflateRaw)) return deprecateInstantiation(DeflateRaw, opts);
|
|
728
754
|
Reflect.apply(Zlib, this, [opts, DEFLATERAW]);
|
|
729
755
|
}
|
|
730
756
|
Object.setPrototypeOf(DeflateRaw.prototype, Zlib.prototype);
|
|
731
757
|
Object.setPrototypeOf(DeflateRaw, Zlib);
|
|
732
758
|
|
|
733
759
|
export function InflateRaw(opts) {
|
|
734
|
-
if (!(this instanceof InflateRaw)) return
|
|
760
|
+
if (!(this instanceof InflateRaw)) return deprecateInstantiation(InflateRaw, opts);
|
|
735
761
|
Reflect.apply(Zlib, this, [opts, INFLATERAW]);
|
|
736
762
|
}
|
|
737
763
|
Object.setPrototypeOf(InflateRaw.prototype, Zlib.prototype);
|
|
738
764
|
Object.setPrototypeOf(InflateRaw, Zlib);
|
|
739
765
|
|
|
740
766
|
export function Unzip(opts) {
|
|
741
|
-
if (!(this instanceof Unzip)) return
|
|
767
|
+
if (!(this instanceof Unzip)) return deprecateInstantiation(Unzip, opts);
|
|
742
768
|
Reflect.apply(Zlib, this, [opts, UNZIP]);
|
|
743
769
|
}
|
|
744
770
|
Object.setPrototypeOf(Unzip.prototype, Zlib.prototype);
|
|
@@ -781,9 +807,15 @@ function Brotli(opts, mode) {
|
|
|
781
807
|
});
|
|
782
808
|
}
|
|
783
809
|
|
|
810
|
+
let dictionary = opts?.dictionary;
|
|
811
|
+
if (dictionary !== undefined && !isArrayBufferView(dictionary)) {
|
|
812
|
+
if (isAnyArrayBuffer(dictionary)) dictionary = Buffer.from(dictionary);
|
|
813
|
+
else throw invalidArgType("options.dictionary", "an instance of Buffer, TypedArray, DataView, or ArrayBuffer", dictionary);
|
|
814
|
+
}
|
|
815
|
+
|
|
784
816
|
const handle = new BrotliHandle(mode);
|
|
785
817
|
this._writeState = new Uint32Array(2);
|
|
786
|
-
handle.init(brotliInitParamsArray, this._writeState, processCallback);
|
|
818
|
+
handle.init(brotliInitParamsArray, this._writeState, processCallback, dictionary);
|
|
787
819
|
|
|
788
820
|
Reflect.apply(ZlibBase, this, [opts, mode, handle, brotliDefaultOpts]);
|
|
789
821
|
}
|
|
@@ -791,14 +823,14 @@ Object.setPrototypeOf(Brotli.prototype, Zlib.prototype);
|
|
|
791
823
|
Object.setPrototypeOf(Brotli, Zlib);
|
|
792
824
|
|
|
793
825
|
export function BrotliCompress(opts) {
|
|
794
|
-
if (!(this instanceof BrotliCompress)) return
|
|
826
|
+
if (!(this instanceof BrotliCompress)) return deprecateInstantiation(BrotliCompress, opts);
|
|
795
827
|
Reflect.apply(Brotli, this, [opts, BROTLI_ENCODE]);
|
|
796
828
|
}
|
|
797
829
|
Object.setPrototypeOf(BrotliCompress.prototype, Brotli.prototype);
|
|
798
830
|
Object.setPrototypeOf(BrotliCompress, Brotli);
|
|
799
831
|
|
|
800
832
|
export function BrotliDecompress(opts) {
|
|
801
|
-
if (!(this instanceof BrotliDecompress)) return
|
|
833
|
+
if (!(this instanceof BrotliDecompress)) return deprecateInstantiation(BrotliDecompress, opts);
|
|
802
834
|
Reflect.apply(Brotli, this, [opts, BROTLI_DECODE]);
|
|
803
835
|
}
|
|
804
836
|
Object.setPrototypeOf(BrotliDecompress.prototype, Brotli.prototype);
|
|
@@ -824,11 +856,12 @@ class Zstd extends ZlibBase {
|
|
|
824
856
|
});
|
|
825
857
|
}
|
|
826
858
|
|
|
859
|
+
let dictionary = opts?.dictionary;
|
|
860
|
+
if (dictionary !== undefined && !isArrayBufferView(dictionary)) dictionary = isAnyArrayBuffer(dictionary) ? new Uint8Array(dictionary) : undefined;
|
|
827
861
|
const handle = new ZstdHandle(mode === ZSTD_COMPRESS);
|
|
828
|
-
const pledgedSrcSize = opts?.pledgedSrcSize
|
|
862
|
+
const pledgedSrcSize = opts?.pledgedSrcSize;
|
|
829
863
|
const writeState = new Uint32Array(2);
|
|
830
|
-
handle.init(initParamsArray, pledgedSrcSize, writeState, processCallback,
|
|
831
|
-
opts?.dictionary && isArrayBufferView(opts.dictionary) ? opts.dictionary : undefined);
|
|
864
|
+
handle.init(initParamsArray, pledgedSrcSize, writeState, processCallback, dictionary);
|
|
832
865
|
|
|
833
866
|
super(opts, mode, handle, zstdDefaultOpts);
|
|
834
867
|
this._writeState = writeState;
|
package/node/src/host_brotli.c
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Host primitives for node:zlib's Brotli streams
|
|
1
|
+
/* Host primitives for node:zlib's Brotli streams: Node's binding (src/node_zlib.cc, its
|
|
2
2
|
* BrotliEncoderContext and BrotliDecoderContext) over Brotli 1.1.0, the copy Node vendors. As
|
|
3
3
|
* host_zlib.c: a stream is a handle object, and a failure is [message, errno, code]. */
|
|
4
4
|
#include <stdio.h>
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
#include "brotli/encode.h"
|
|
10
10
|
#include "js_buffer.h"
|
|
11
11
|
#include "js_exception.h"
|
|
12
|
+
#include "js_gc.h"
|
|
12
13
|
#include "js_node.h"
|
|
14
|
+
#include "js_web.h"
|
|
13
15
|
#include "js_object.h"
|
|
14
16
|
#include "js_ops.h"
|
|
15
17
|
#include "jsstring.h"
|
|
@@ -31,13 +33,26 @@ typedef struct BrotliObject {
|
|
|
31
33
|
bool encode_result; /* the encoder's last result */
|
|
32
34
|
BrotliDecoderResult decode_result;
|
|
33
35
|
BrotliDecoderErrorCode error;
|
|
36
|
+
JSRuntime *rt; /* the allocator's */
|
|
37
|
+
uint8_t *dictionary; /* malloc'd; NULL when none (it outlives what uses it) */
|
|
38
|
+
size_t dictionary_len;
|
|
39
|
+
BrotliEncoderPreparedDictionary *prepared; /* the encoder's, from the dictionary */
|
|
34
40
|
} BrotliObject;
|
|
35
41
|
|
|
42
|
+
/* Brotli's memory is the heap's external memory. */
|
|
43
|
+
static void *brotli_alloc(void *rt, size_t n) { return js_gc_external_malloc(rt, n); }
|
|
44
|
+
static void brotli_free(void *rt, void *p) { js_gc_external_free(rt, p); }
|
|
45
|
+
|
|
36
46
|
static void brotli_end(BrotliObject *b) {
|
|
37
47
|
if (b->encoder) BrotliEncoderDestroyInstance(b->encoder);
|
|
38
48
|
if (b->decoder) BrotliDecoderDestroyInstance(b->decoder);
|
|
49
|
+
if (b->prepared) BrotliEncoderDestroyPreparedDictionary(b->prepared);
|
|
50
|
+
free(b->dictionary);
|
|
39
51
|
b->encoder = NULL;
|
|
40
52
|
b->decoder = NULL;
|
|
53
|
+
b->prepared = NULL;
|
|
54
|
+
b->dictionary = NULL;
|
|
55
|
+
b->dictionary_len = 0;
|
|
41
56
|
}
|
|
42
57
|
|
|
43
58
|
static void brotli_finalize(JSRuntime *rt, JSCell *cell) {
|
|
@@ -59,12 +74,30 @@ static JSValue failure(JSContext *ctx, const char *message, int err, const char
|
|
|
59
74
|
return a;
|
|
60
75
|
}
|
|
61
76
|
|
|
62
|
-
/* Init (and ResetStream, which is Init again: the parameters set before are
|
|
63
|
-
|
|
77
|
+
/* Init (and ResetStream, which is Init again: the parameters and the dictionary set before are
|
|
78
|
+
* gone, as in Node), with a raw shared dictionary when one is given: NULL, or a failure's message
|
|
79
|
+
* (its code in *code) */
|
|
80
|
+
static const char *brotli_init(BrotliObject *b, const uint8_t *dictionary, size_t dictionary_len, const char **code) {
|
|
64
81
|
brotli_end(b);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
82
|
+
*code = "ERR_ZLIB_INITIALIZATION_FAILED";
|
|
83
|
+
if (b->mode == BROTLI_ENCODE) b->encoder = BrotliEncoderCreateInstance(brotli_alloc, brotli_free, b->rt);
|
|
84
|
+
else b->decoder = BrotliDecoderCreateInstance(brotli_alloc, brotli_free, b->rt);
|
|
85
|
+
if (!b->encoder && !b->decoder) return "Could not initialize Brotli instance";
|
|
86
|
+
if (!dictionary_len) return NULL;
|
|
87
|
+
b->dictionary = malloc(dictionary_len);
|
|
88
|
+
if (!b->dictionary) js_fatal("out of memory in Brotli");
|
|
89
|
+
memcpy(b->dictionary, dictionary, dictionary_len);
|
|
90
|
+
b->dictionary_len = dictionary_len;
|
|
91
|
+
*code = "ERR_ZLIB_DICTIONARY_LOAD_FAILED";
|
|
92
|
+
if (b->encoder) {
|
|
93
|
+
b->prepared = BrotliEncoderPrepareDictionary(BROTLI_SHARED_DICTIONARY_RAW, dictionary_len, b->dictionary, BROTLI_MAX_QUALITY,
|
|
94
|
+
brotli_alloc, brotli_free, b->rt);
|
|
95
|
+
if (!b->prepared) return "Failed to prepare brotli dictionary";
|
|
96
|
+
if (!BrotliEncoderAttachPreparedDictionary(b->encoder, b->prepared)) return "Failed to attach brotli dictionary";
|
|
97
|
+
} else if (!BrotliDecoderAttachDictionary(b->decoder, BROTLI_SHARED_DICTIONARY_RAW, dictionary_len, b->dictionary)) {
|
|
98
|
+
return "Failed to attach brotli dictionary";
|
|
99
|
+
}
|
|
100
|
+
return NULL;
|
|
68
101
|
}
|
|
69
102
|
|
|
70
103
|
/* brotliNew(mode) → handle */
|
|
@@ -74,6 +107,10 @@ PRIMITIVE(js_host_brotli_new) {
|
|
|
74
107
|
b->mode = js_is_number(ARG(0)) && js_as_number(ARG(0)) == BROTLI_ENCODE ? BROTLI_ENCODE : BROTLI_DECODE;
|
|
75
108
|
b->encoder = NULL;
|
|
76
109
|
b->decoder = NULL;
|
|
110
|
+
b->rt = ctx->rt;
|
|
111
|
+
b->dictionary = NULL;
|
|
112
|
+
b->dictionary_len = 0;
|
|
113
|
+
b->prepared = NULL;
|
|
77
114
|
b->flush = BROTLI_OPERATION_PROCESS;
|
|
78
115
|
b->encode_result = false;
|
|
79
116
|
b->decode_result = BROTLI_DECODER_RESULT_SUCCESS;
|
|
@@ -81,7 +118,8 @@ PRIMITIVE(js_host_brotli_new) {
|
|
|
81
118
|
return js_object_value(&b->obj);
|
|
82
119
|
}
|
|
83
120
|
|
|
84
|
-
/* brotliInit(handle, params): params a Uint32Array, by parameter number,
|
|
121
|
+
/* brotliInit(handle, params, dictionary | undefined): params a Uint32Array, by parameter number,
|
|
122
|
+
* 0xffffffff unset; the dictionary a raw shared one →
|
|
85
123
|
* 0 | failure */
|
|
86
124
|
PRIMITIVE(js_host_brotli_init) {
|
|
87
125
|
UNUSED_PRIMITIVE_ARGS;
|
|
@@ -89,7 +127,12 @@ PRIMITIVE(js_host_brotli_init) {
|
|
|
89
127
|
uint8_t *p;
|
|
90
128
|
size_t n;
|
|
91
129
|
if (!b || !js_buffer_source_bytes(ARG(1), &p, &n)) return js_throw_type_error(ctx, "brotliInit: a handle and parameters expected");
|
|
92
|
-
|
|
130
|
+
uint8_t *dict = NULL;
|
|
131
|
+
size_t dict_len = 0;
|
|
132
|
+
if (!js_is_undefined(ARG(2))) js_buffer_source_bytes(ARG(2), &dict, &dict_len);
|
|
133
|
+
const char *code;
|
|
134
|
+
const char *message = brotli_init(b, dict, dict_len, &code);
|
|
135
|
+
if (message) return failure(ctx, message, -1, code);
|
|
93
136
|
for (size_t i = 0; i < n / sizeof(uint32_t); i++) {
|
|
94
137
|
uint32_t value;
|
|
95
138
|
memcpy(&value, p + i * sizeof value, sizeof value);
|
|
@@ -113,8 +156,11 @@ PRIMITIVE(js_host_brotli_write) {
|
|
|
113
156
|
return js_throw_type_error(ctx, "brotliWrite: a handle, buffers and a state expected");
|
|
114
157
|
double in_off = in ? js_as_number(ARG(3)) : 0, in_len = in ? js_as_number(ARG(4)) : 0;
|
|
115
158
|
double out_off = js_as_number(ARG(6)), out_len = js_as_number(ARG(7));
|
|
116
|
-
|
|
117
|
-
|
|
159
|
+
/* node_zlib.cc's checks */
|
|
160
|
+
if (!(in_off >= 0 && in_len >= 0 && in_off + in_len <= (double)in_n))
|
|
161
|
+
return js_throw_node_error(ctx, JS_RANGE_ERROR, "ERR_OUT_OF_RANGE", "input buffer is out of bounds");
|
|
162
|
+
if (!(out_off >= 0 && out_len >= 0 && out_off + out_len <= (double)out_n))
|
|
163
|
+
return js_throw_node_error(ctx, JS_RANGE_ERROR, "ERR_OUT_OF_RANGE", "output buffer is out of bounds");
|
|
118
164
|
const uint8_t *next_in = in ? in + (size_t)in_off : NULL;
|
|
119
165
|
uint8_t *next_out = out + (size_t)out_off;
|
|
120
166
|
size_t avail_in = (size_t)in_len, avail_out = (size_t)out_len;
|
|
@@ -144,7 +190,9 @@ PRIMITIVE(js_host_brotli_reset) {
|
|
|
144
190
|
UNUSED_PRIMITIVE_ARGS;
|
|
145
191
|
BrotliObject *b = brotli_arg(ARG(0));
|
|
146
192
|
if (!b) return js_throw_type_error(ctx, "brotliReset: a handle expected");
|
|
147
|
-
|
|
193
|
+
const char *code;
|
|
194
|
+
const char *message = brotli_init(b, NULL, 0, &code);
|
|
195
|
+
if (message) return failure(ctx, message, -1, code);
|
|
148
196
|
return js_int32(0);
|
|
149
197
|
}
|
|
150
198
|
|