visaljs 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -2
- package/THIRD_PARTY_LICENSES +1216 -0
- package/cli.js +4414 -325
- package/node/include/js_node.h +57 -1
- package/node/include/js_uv.h +8 -1
- package/node/prelude/_stream_duplex.js +4 -0
- package/node/prelude/_stream_passthrough.js +4 -0
- package/node/prelude/_stream_readable.js +4 -0
- package/node/prelude/_stream_transform.js +4 -0
- package/node/prelude/_stream_writable.js +4 -0
- package/node/prelude/assert.js +1334 -0
- package/node/prelude/assert_strict.js +12 -0
- package/node/prelude/async_hooks.js +1 -1
- package/node/prelude/buffer.js +43 -3
- package/node/prelude/child_process.js +1098 -0
- package/node/prelude/cluster.js +52 -0
- package/node/prelude/console.js +328 -0
- package/node/prelude/constants.js +10 -0
- package/node/prelude/crypto.js +1 -1
- package/node/prelude/diagnostics_channel.js +1 -1
- package/node/prelude/dns.js +1 -1
- package/node/prelude/domain.js +115 -0
- package/node/prelude/events.js +144 -16
- package/node/prelude/fs.js +1138 -151
- package/node/prelude/fs_promises.js +117 -11
- package/node/prelude/http.js +104 -27
- package/node/prelude/http2.js +1 -1
- package/node/prelude/https.js +148 -0
- package/node/prelude/inspector.js +27 -0
- package/node/prelude/inspector_promises.js +4 -0
- package/node/prelude/internal/async_context.js +1 -1
- package/node/prelude/internal/buffer_transcode.js +44 -0
- package/node/prelude/internal/comparisons.js +916 -0
- package/node/prelude/internal/compression_streams.js +153 -0
- package/node/prelude/internal/crypto/asym.js +27 -14
- package/node/prelude/internal/crypto/cipher.js +16 -5
- package/node/prelude/internal/crypto/diffiehellman.js +3 -2
- package/node/prelude/internal/crypto/hash.js +2 -1
- package/node/prelude/internal/crypto/kdf.js +14 -9
- package/node/prelude/internal/crypto/keys.js +63 -50
- package/node/prelude/internal/crypto/random.js +2 -1
- package/node/prelude/internal/crypto/util.js +4 -4
- package/node/prelude/internal/dotenv.js +98 -0
- package/node/prelude/internal/errors.js +21 -5
- package/node/prelude/internal/events_extras.js +116 -0
- package/node/prelude/internal/events_on.js +100 -0
- package/node/prelude/internal/features.js +55 -0
- package/node/prelude/internal/fetch.js +364 -0
- package/node/prelude/internal/form_data.js +376 -0
- package/node/prelude/internal/fs_bigint_stats.js +41 -0
- package/node/prelude/internal/fs_blob.js +19 -0
- package/node/prelude/internal/fs_cp.js +709 -0
- package/node/prelude/internal/fs_dir.js +166 -0
- package/node/prelude/internal/fs_filehandle.js +287 -0
- package/node/prelude/internal/fs_glob.js +296 -0
- package/node/prelude/internal/fs_statfs.js +42 -0
- package/node/prelude/internal/fs_stats.js +89 -0
- package/node/prelude/internal/fs_streams.js +541 -0
- package/node/prelude/internal/fs_utils.js +286 -0
- package/node/prelude/internal/fs_watch.js +580 -0
- package/node/prelude/internal/http_agent.js +26 -0
- package/node/prelude/internal/mime.js +249 -0
- package/node/prelude/internal/net.js +1 -0
- package/node/prelude/internal/parse_args.js +288 -0
- package/node/prelude/internal/perf_histogram.js +435 -0
- package/node/prelude/internal/perf_observe.js +119 -0
- package/node/prelude/internal/performance_global.js +19 -0
- package/node/prelude/internal/process_events.js +49 -1
- package/node/prelude/internal/process_memory.js +14 -0
- package/node/prelude/internal/process_more.js +414 -0
- package/node/prelude/internal/process_signals.js +2 -1
- package/node/prelude/internal/process_stdin.js +52 -0
- package/node/prelude/internal/process_stdio.js +36 -0
- package/node/prelude/internal/querystring.js +0 -0
- package/node/prelude/internal/readline.js +338 -0
- package/node/prelude/internal/socketaddress.js +8 -4
- package/node/prelude/internal/source_map.js +122 -0
- package/node/prelude/internal/stream_compose.js +74 -0
- package/node/prelude/internal/stream_from.js +6 -0
- package/node/prelude/internal/stream_operators.js +23 -0
- package/node/prelude/internal/stream_pipeline.js +7 -0
- package/node/prelude/internal/stream_transform.js +10 -0
- package/node/prelude/internal/stream_web_adapters.js +143 -0
- package/node/prelude/internal/streams/add_abort_signal.js +58 -0
- package/node/prelude/internal/streams/compose.js +244 -0
- package/node/prelude/internal/streams/destroy.js +358 -0
- package/node/prelude/internal/streams/duplex.js +199 -0
- package/node/prelude/internal/streams/duplexify.js +378 -0
- package/node/prelude/internal/streams/end_of_stream.js +387 -0
- package/node/prelude/internal/streams/errors.js +216 -0
- package/node/prelude/internal/streams/from.js +211 -0
- package/node/prelude/internal/streams/legacy.js +120 -0
- package/node/prelude/internal/streams/operators.js +375 -0
- package/node/prelude/internal/streams/passthrough.js +45 -0
- package/node/prelude/internal/streams/pipeline.js +468 -0
- package/node/prelude/internal/streams/readable.js +1835 -0
- package/node/prelude/internal/streams/state.js +48 -0
- package/node/prelude/internal/streams/transform.js +203 -0
- package/node/prelude/internal/streams/utils.js +355 -0
- package/node/prelude/internal/streams/validators.js +108 -0
- package/node/prelude/internal/streams/writable.js +1160 -0
- package/node/prelude/internal/structured_clone.js +238 -0
- package/node/prelude/internal/system_errors.js +37 -0
- package/node/prelude/internal/test_runner/mock.js +431 -0
- package/node/prelude/internal/test_runner/reporters.js +404 -0
- package/node/prelude/internal/test_runner/test.js +1571 -0
- package/node/prelude/internal/timers.js +38 -7
- package/node/prelude/internal/timers_global.js +1 -1
- package/node/prelude/internal/tls/common.js +8 -2
- package/node/prelude/internal/tls/wrap.js +3 -15
- package/node/prelude/internal/tls/x509.js +1 -1
- package/node/prelude/internal/tty_read_stream.js +39 -0
- package/node/prelude/internal/tty_streams.js +3 -0
- package/node/prelude/internal/util_debuglog.js +68 -0
- package/node/prelude/internal/util_diff.js +63 -0
- package/node/prelude/internal/util_more.js +111 -0
- package/node/prelude/internal/util_styles.js +76 -0
- package/node/prelude/internal/zlib_engines.js +1 -1
- package/node/prelude/module.js +194 -7
- package/node/prelude/net.js +2 -1
- package/node/prelude/os.js +88 -11
- package/node/prelude/path.js +11 -7
- package/node/prelude/path_posix.js +1 -1
- package/node/prelude/path_win32.js +1 -1
- package/node/prelude/perf_hooks.js +147 -0
- package/node/prelude/process.js +36 -1
- package/node/prelude/punycode.js +188 -0
- package/node/prelude/querystring.js +1 -1
- package/node/prelude/readline.js +8 -0
- package/node/prelude/readline_promises.js +88 -0
- package/node/prelude/repl.js +38 -0
- package/node/prelude/sea.js +23 -0
- package/node/prelude/stream.js +70 -1332
- package/node/prelude/stream_consumers.js +34 -0
- package/node/prelude/stream_promises.js +1 -1
- package/node/prelude/stream_web.js +15 -2
- package/node/prelude/string_decoder.js +1 -1
- package/node/prelude/sys.js +7 -0
- package/node/prelude/test.js +56 -0
- package/node/prelude/test_reporters.js +269 -0
- package/node/prelude/timers.js +7 -84
- package/node/prelude/timers_promises.js +1 -1
- package/node/prelude/tls.js +2 -1
- package/node/prelude/trace_events.js +52 -0
- package/node/prelude/tty.js +10 -4
- package/node/prelude/url.js +88 -27
- package/node/prelude/util.js +121 -5
- package/node/prelude/util_types.js +4 -3
- package/node/prelude/v8.js +814 -0
- package/node/prelude/vm.js +86 -0
- package/node/prelude/wasi.js +10 -0
- package/node/prelude/worker_threads.js +56 -0
- package/node/prelude/zlib.js +58 -25
- package/node/src/host_brotli.c +59 -11
- package/node/src/host_fs.c +342 -11
- package/node/src/host_fswatch.c +170 -0
- package/node/src/host_http.c +143 -20
- package/node/src/host_loop.c +25 -2
- package/node/src/host_net.c +55 -7
- package/node/src/host_os.c +55 -1
- package/node/src/host_proc.c +291 -0
- package/node/src/host_process.c +488 -0
- package/node/src/host_sys.c +64 -2
- package/node/src/host_zlib.c +27 -7
- package/node/src/host_zstd.c +41 -6
- package/node/third_party/hdrhistogram/LICENSE +42 -0
- package/node/third_party/hdrhistogram/README.md +5 -0
- package/node/third_party/libuv/LICENSE +0 -0
- package/node/third_party/libuv/LICENSE-extra +36 -0
- package/node/third_party/libuv/include/uv/aix.h +0 -0
- package/node/third_party/libuv/include/uv/bsd.h +0 -0
- package/node/third_party/libuv/include/uv/darwin.h +0 -0
- package/node/third_party/libuv/include/uv/errno.h +0 -0
- package/node/third_party/libuv/include/uv/linux.h +0 -0
- package/node/third_party/libuv/include/uv/os390.h +0 -0
- package/node/third_party/libuv/include/uv/posix.h +0 -0
- package/node/third_party/libuv/include/uv/sunos.h +0 -0
- package/node/third_party/libuv/include/uv/threadpool.h +0 -0
- package/node/third_party/libuv/include/uv/tree.h +0 -0
- package/node/third_party/libuv/include/uv/unix.h +0 -0
- package/node/third_party/libuv/include/uv/version.h +0 -0
- package/node/third_party/libuv/include/uv/win.h +0 -0
- package/node/third_party/libuv/include/uv.h +0 -0
- package/node/third_party/libuv/src/fs-poll.c +0 -0
- package/node/third_party/libuv/src/heap-inl.h +0 -0
- package/node/third_party/libuv/src/idna.c +0 -0
- package/node/third_party/libuv/src/idna.h +0 -0
- package/node/third_party/libuv/src/inet.c +0 -0
- package/node/third_party/libuv/src/queue.h +0 -0
- package/node/third_party/libuv/src/random.c +0 -0
- package/node/third_party/libuv/src/strscpy.c +0 -0
- package/node/third_party/libuv/src/strscpy.h +0 -0
- package/node/third_party/libuv/src/strtok.c +0 -0
- package/node/third_party/libuv/src/strtok.h +0 -0
- package/node/third_party/libuv/src/thread-common.c +0 -0
- package/node/third_party/libuv/src/threadpool.c +0 -0
- package/node/third_party/libuv/src/timer.c +0 -0
- package/node/third_party/libuv/src/unix/async.c +0 -0
- package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +0 -0
- package/node/third_party/libuv/src/unix/core.c +0 -0
- package/node/third_party/libuv/src/unix/darwin-proctitle.c +0 -0
- package/node/third_party/libuv/src/unix/darwin-stub.h +0 -0
- package/node/third_party/libuv/src/unix/darwin-syscalls.h +0 -0
- package/node/third_party/libuv/src/unix/darwin.c +0 -0
- package/node/third_party/libuv/src/unix/dl.c +0 -0
- package/node/third_party/libuv/src/unix/fs.c +0 -0
- package/node/third_party/libuv/src/unix/fsevents.c +0 -0
- package/node/third_party/libuv/src/unix/getaddrinfo.c +0 -0
- package/node/third_party/libuv/src/unix/getnameinfo.c +0 -0
- package/node/third_party/libuv/src/unix/internal.h +0 -0
- package/node/third_party/libuv/src/unix/kqueue.c +0 -0
- package/node/third_party/libuv/src/unix/linux.c +0 -0
- package/node/third_party/libuv/src/unix/loop-watcher.c +0 -0
- package/node/third_party/libuv/src/unix/loop.c +0 -0
- package/node/third_party/libuv/src/unix/pipe.c +0 -0
- package/node/third_party/libuv/src/unix/poll.c +0 -0
- package/node/third_party/libuv/src/unix/process.c +0 -0
- package/node/third_party/libuv/src/unix/procfs-exepath.c +0 -0
- package/node/third_party/libuv/src/unix/proctitle.c +0 -0
- package/node/third_party/libuv/src/unix/random-devurandom.c +0 -0
- package/node/third_party/libuv/src/unix/random-getentropy.c +0 -0
- package/node/third_party/libuv/src/unix/random-getrandom.c +0 -0
- package/node/third_party/libuv/src/unix/random-sysctl-linux.c +0 -0
- package/node/third_party/libuv/src/unix/signal.c +0 -0
- package/node/third_party/libuv/src/unix/stream.c +0 -0
- package/node/third_party/libuv/src/unix/tcp.c +0 -0
- package/node/third_party/libuv/src/unix/thread.c +0 -0
- package/node/third_party/libuv/src/unix/tty.c +0 -0
- package/node/third_party/libuv/src/unix/udp.c +0 -0
- package/node/third_party/libuv/src/uv-common.c +0 -0
- package/node/third_party/libuv/src/uv-common.h +0 -0
- package/node/third_party/libuv/src/uv-data-getter-setters.c +0 -0
- package/node/third_party/libuv/src/version.c +0 -0
- package/node/third_party/llhttp/LICENSE +0 -0
- package/node/third_party/llhttp/api.c +0 -0
- package/node/third_party/llhttp/http.c +0 -0
- package/node/third_party/llhttp/llhttp.c +0 -0
- package/node/third_party/llhttp/llhttp.h +0 -0
- package/node/third_party/nodejs/LICENSE +47 -0
- package/node/third_party/nodejs/README.md +5 -0
- package/node/third_party/parseargs/LICENSE +21 -0
- package/node/third_party/parseargs/README.md +5 -0
- package/node/third_party/punycode/LICENSE +20 -0
- package/node/third_party/punycode/README.md +5 -0
- package/node/third_party/zlib/LICENSE.chromium +27 -0
- package/package.json +1 -5
- package/prebuilt/darwin-arm64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/darwin-arm64/brotli-7995bbdacc52e51c.a +0 -0
- package/prebuilt/darwin-arm64/uv-72ab666eae197cd8.a +0 -0
- package/prebuilt/darwin-arm64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/darwin-arm64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/darwin-x64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/darwin-x64/brotli-7995bbdacc52e51c.a +0 -0
- package/prebuilt/darwin-x64/uv-72ab666eae197cd8.a +0 -0
- package/prebuilt/darwin-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/darwin-x64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-arm64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-arm64/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-arm64/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-arm64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-arm64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-arm64-musl/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-arm64-musl/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-arm64-musl/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-arm64-musl/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-arm64-musl/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-x64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-x64/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-x64/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-x64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-x64-musl/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-x64-musl/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-x64-musl/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-x64-musl/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-x64-musl/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/win32-x64/boringssl-ce573858472b7fc9.a +0 -0
- package/prebuilt/win32-x64/brotli-20d86a61f30baeb3.a +0 -0
- package/prebuilt/win32-x64/uv-b11bae65d7fced82.a +0 -0
- package/prebuilt/win32-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/win32-x64/zstd-015315ac7c784c73.a +0 -0
- package/runtime/include/js_atoms.gen.h +0 -0
- package/runtime/include/js_atoms.h +1 -1
- package/runtime/include/js_bigint.h +1 -1
- package/runtime/include/js_buffer.h +4 -4
- package/runtime/include/js_builtins.h +41 -3
- package/runtime/include/js_console.h +9 -4
- package/runtime/include/js_convert.h +1 -1
- package/runtime/include/js_core.def +5 -4
- package/runtime/include/js_crypto.h +1 -1
- package/runtime/include/js_error.h +1 -1
- package/runtime/include/js_exception.h +21 -1
- package/runtime/include/js_function.h +33 -9
- package/runtime/include/js_gc.h +172 -30
- package/runtime/include/js_generator.h +2 -2
- package/runtime/include/js_host.h +19 -1
- package/runtime/include/js_jobs.h +5 -5
- package/runtime/include/js_module.h +1 -1
- package/runtime/include/js_object.h +142 -15
- package/runtime/include/js_ops.h +107 -5
- package/runtime/include/js_promise.h +3 -3
- package/runtime/include/js_regexp.h +1 -1
- package/runtime/include/js_runtime.h +0 -0
- package/runtime/include/js_symbol.h +1 -1
- package/runtime/include/js_web.h +2 -1
- package/runtime/include/jscell.h +22 -15
- package/runtime/include/jscontext.h +74 -39
- package/runtime/include/jsnum.h +1 -1
- package/runtime/include/jsstring.h +19 -6
- package/runtime/include/jsvalue.h +7 -3
- package/runtime/src/arguments.c +2 -2
- package/runtime/src/array.c +4 -1
- package/runtime/src/arraybuffer.c +19 -7
- package/runtime/src/async_iter.c +4 -3
- package/runtime/src/atoms.c +1 -1
- package/runtime/src/base64.c +2 -2
- package/runtime/src/bigint.c +1 -1
- package/runtime/src/blob.c +22 -9
- package/runtime/src/boringssl_support.cc +1 -1
- package/runtime/src/buffer.c +299 -91
- package/runtime/src/builtin_table.c +1 -1
- package/runtime/src/builtins.c +30 -4
- package/runtime/src/builtins_util.h +0 -0
- package/runtime/src/collections.c +18 -3
- package/runtime/src/components.c +1 -1
- package/runtime/src/console.c +14 -7
- package/runtime/src/convert.c +0 -0
- package/runtime/src/core_all.c +1 -1
- package/runtime/src/crypto.c +1 -1
- package/runtime/src/crypto_asym.c +1 -1
- package/runtime/src/crypto_bn.c +1 -1
- package/runtime/src/crypto_cipher.c +10 -3
- package/runtime/src/crypto_hash.c +1 -1
- package/runtime/src/crypto_host.c +1 -1
- package/runtime/src/crypto_internal.h +1 -1
- package/runtime/src/crypto_kdf.c +1 -1
- package/runtime/src/crypto_key.c +14 -1
- package/runtime/src/crypto_pkey.c +1 -1
- package/runtime/src/crypto_subtle.c +142 -58
- package/runtime/src/crypto_tls.c +1 -1
- package/runtime/src/date.c +5 -2
- package/runtime/src/domexception.c +2 -2
- package/runtime/src/elements.c +56 -17
- package/runtime/src/elements.h +7 -2
- package/runtime/src/encoding.c +1 -1
- package/runtime/src/error.c +4 -4
- package/runtime/src/events.c +23 -14
- package/runtime/src/exception.c +1 -1
- package/runtime/src/fetch.c +241 -17
- package/runtime/src/function.c +31 -19
- package/runtime/src/gc.c +1716 -207
- package/runtime/src/gc_visit.h +87 -0
- package/runtime/src/generator.c +5 -3
- package/runtime/src/global.c +14 -6
- package/runtime/src/headers.c +10 -10
- package/runtime/src/inspect.c +76 -17
- package/runtime/src/internal.h +5 -2
- package/runtime/src/iterate.c +94 -2
- package/runtime/src/iterator.c +1 -1
- package/runtime/src/jobs.c +11 -5
- package/runtime/src/jsnum.c +2 -2
- package/runtime/src/json.c +1 -1
- package/runtime/src/math.c +9 -1
- package/runtime/src/module.c +3 -3
- package/runtime/src/number.c +0 -0
- package/runtime/src/object.c +107 -74
- package/runtime/src/ops.c +21 -3
- package/runtime/src/os.c +192 -1
- package/runtime/src/os.h +33 -2
- package/runtime/src/process.c +73 -8
- package/runtime/src/promise.c +4 -4
- package/runtime/src/proxy.c +1 -1
- package/runtime/src/reflect.c +1 -1
- package/runtime/src/regexp.c +134 -2
- package/runtime/src/regexp_anchor.h +1 -1
- package/runtime/src/regexp_message.h +1 -1
- package/runtime/src/shape.c +10 -19
- package/runtime/src/shape.h +0 -0
- package/runtime/src/streams.c +22 -8
- package/runtime/src/streams.h +0 -0
- package/runtime/src/string.c +64 -25
- package/runtime/src/string_builtins.c +7 -7
- package/runtime/src/symbol.c +2 -7
- package/runtime/src/test_host.c +3 -3
- package/runtime/src/tls_roots.gen.h +102 -620
- package/runtime/src/typedarray.c +8 -3
- package/runtime/src/tznames.gen.h +2 -1
- package/runtime/src/uri.c +1 -1
- package/runtime/src/url.c +42 -39
- package/runtime/src/weak.c +15 -12
- package/runtime/src/web.c +21 -3
- package/runtime/src/wrapper.c +0 -0
- package/runtime/src/writable.c +7 -6
- package/runtime/third_party/ada-idna/LICENSE-MIT +0 -0
- package/runtime/third_party/ada-idna/README.md +7 -7
- package/runtime/third_party/ada-idna/convert.mjs +89 -27
- package/runtime/third_party/ada-idna/idna.c +30 -31
- package/runtime/third_party/ada-idna/idna.h +0 -0
- package/runtime/third_party/ada-idna/idna_tables.h +2272 -1952
- package/runtime/third_party/boringssl/third_party/fiat/LICENSE +15 -0
- package/runtime/third_party/mozilla-ca/LICENSE +373 -0
- package/runtime/third_party/mozilla-ca/README.md +9 -0
- package/runtime/third_party/nodejs/LICENSE +47 -0
- package/runtime/third_party/nodejs/README.md +7 -0
- package/runtime/third_party/quickjs-dtoa/LICENSE +0 -0
- package/runtime/third_party/quickjs-dtoa/README.md +1 -1
- package/runtime/third_party/quickjs-dtoa/dtoa.c +0 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.h +0 -0
- package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +0 -0
- package/runtime/third_party/quickjs-regexp/LICENSE +0 -0
- package/runtime/third_party/quickjs-regexp/README.md +2 -2
- package/runtime/third_party/quickjs-regexp/cutils.c +0 -0
- package/runtime/third_party/quickjs-regexp/cutils.h +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp.c +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp.h +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode-table.h +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode.c +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode.h +0 -0
- package/runtime/third_party/unicode/LICENSE +39 -0
- package/runtime/third_party/unicode/README.md +9 -0
- package/runtime/third_party/v8-ieee754/LICENSE +0 -0
- package/runtime/third_party/v8-ieee754/LICENSE.fdlibm +10 -0
- package/runtime/third_party/v8-ieee754/README.md +3 -2
- package/runtime/third_party/v8-ieee754/convert.py +0 -0
- package/runtime/third_party/v8-ieee754/ieee754.c +0 -0
- package/runtime/third_party/v8-ieee754/ieee754.h +0 -0
- package/runtime/tools/regexp_compile.c +2 -2
package/runtime/src/os.c
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Memory and time from the operating system
|
|
1
|
+
/* Memory and time from the operating system. */
|
|
2
2
|
#define _GNU_SOURCE /* MAP_ANONYMOUS under -std=c11, pthread_getattr_np */
|
|
3
3
|
#include "os.h"
|
|
4
4
|
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
#ifdef _WIN32
|
|
8
8
|
#include <windows.h>
|
|
9
|
+
#include <malloc.h>
|
|
10
|
+
#include <psapi.h>
|
|
9
11
|
#include <stdlib.h>
|
|
10
12
|
#include <time.h>
|
|
11
13
|
|
|
@@ -34,6 +36,71 @@ void js_os_unmap(void *p, size_t size) {
|
|
|
34
36
|
VirtualFree(p, 0, MEM_RELEASE);
|
|
35
37
|
}
|
|
36
38
|
|
|
39
|
+
void js_os_decommit(void *p, size_t size) {
|
|
40
|
+
VirtualFree(p, size, MEM_DECOMMIT);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
bool js_os_commit(void *p, size_t size) {
|
|
44
|
+
return VirtualAlloc(p, size, MEM_COMMIT, PAGE_READWRITE) != NULL;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
void js_os_trim(void) {
|
|
48
|
+
_heapmin();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
struct JSOsLock { SRWLOCK lock; };
|
|
52
|
+
struct JSOsCond { CONDITION_VARIABLE cond; };
|
|
53
|
+
struct JSOsThread { HANDLE handle; void (*fn)(void *); void *arg; };
|
|
54
|
+
|
|
55
|
+
JSOsLock *js_os_lock_new(void) {
|
|
56
|
+
JSOsLock *l = calloc(1, sizeof *l);
|
|
57
|
+
if (l) InitializeSRWLock(&l->lock);
|
|
58
|
+
return l;
|
|
59
|
+
}
|
|
60
|
+
void js_os_lock_free(JSOsLock *l) { free(l); }
|
|
61
|
+
void js_os_lock(JSOsLock *l) { AcquireSRWLockExclusive(&l->lock); }
|
|
62
|
+
void js_os_unlock(JSOsLock *l) { ReleaseSRWLockExclusive(&l->lock); }
|
|
63
|
+
JSOsCond *js_os_cond_new(void) {
|
|
64
|
+
JSOsCond *c = calloc(1, sizeof *c);
|
|
65
|
+
if (c) InitializeConditionVariable(&c->cond);
|
|
66
|
+
return c;
|
|
67
|
+
}
|
|
68
|
+
void js_os_cond_free(JSOsCond *c) { free(c); }
|
|
69
|
+
void js_os_cond_wait(JSOsCond *c, JSOsLock *l) { SleepConditionVariableSRW(&c->cond, &l->lock, INFINITE, 0); }
|
|
70
|
+
void js_os_cond_signal(JSOsCond *c) { WakeConditionVariable(&c->cond); }
|
|
71
|
+
void js_os_cond_broadcast(JSOsCond *c) { WakeAllConditionVariable(&c->cond); }
|
|
72
|
+
|
|
73
|
+
static DWORD WINAPI thread_main(LPVOID p) {
|
|
74
|
+
JSOsThread *t = p;
|
|
75
|
+
t->fn(t->arg);
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
JSOsThread *js_os_thread_start(void (*fn)(void *), void *arg) {
|
|
79
|
+
JSOsThread *t = calloc(1, sizeof *t);
|
|
80
|
+
if (!t) return NULL;
|
|
81
|
+
t->fn = fn;
|
|
82
|
+
t->arg = arg;
|
|
83
|
+
t->handle = CreateThread(NULL, 0, thread_main, t, 0, NULL);
|
|
84
|
+
if (!t->handle) {
|
|
85
|
+
free(t);
|
|
86
|
+
return NULL;
|
|
87
|
+
}
|
|
88
|
+
return t;
|
|
89
|
+
}
|
|
90
|
+
void js_os_thread_join(JSOsThread *t) {
|
|
91
|
+
WaitForSingleObject(t->handle, INFINITE);
|
|
92
|
+
CloseHandle(t->handle);
|
|
93
|
+
free(t);
|
|
94
|
+
}
|
|
95
|
+
unsigned js_os_cpu_count(void) {
|
|
96
|
+
DWORD_PTR process, system;
|
|
97
|
+
if (!GetProcessAffinityMask(GetCurrentProcess(), &process, &system)) return 1;
|
|
98
|
+
unsigned n = 0;
|
|
99
|
+
for (; process; process &= process - 1) n++;
|
|
100
|
+
return n ? n : 1;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
37
104
|
void js_os_stack_bounds(void **low, void **high) {
|
|
38
105
|
ULONG_PTR lo, hi;
|
|
39
106
|
GetCurrentThreadStackLimits(&lo, &hi);
|
|
@@ -84,15 +151,35 @@ const char *js_os_timezone_id(void) {
|
|
|
84
151
|
return tz && *tz ? tz : ""; /* Windows zone names aren't IANA ids: the offset fallback */
|
|
85
152
|
}
|
|
86
153
|
|
|
154
|
+
|
|
155
|
+
double js_os_thread_cpu_ms(void) {
|
|
156
|
+
FILETIME created, exited, kernel, user;
|
|
157
|
+
if (!GetThreadTimes(GetCurrentThread(), &created, &exited, &kernel, &user)) return js_os_now_ms_precise();
|
|
158
|
+
uint64_t k = ((uint64_t)kernel.dwHighDateTime << 32) | kernel.dwLowDateTime;
|
|
159
|
+
uint64_t u = ((uint64_t)user.dwHighDateTime << 32) | user.dwLowDateTime;
|
|
160
|
+
return (double)(k + u) / 1e4; /* 100 ns units */
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
size_t js_os_peak_rss(void) {
|
|
164
|
+
PROCESS_MEMORY_COUNTERS pmc;
|
|
165
|
+
return K32GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof pmc) ? pmc.PeakWorkingSetSize : 0;
|
|
166
|
+
}
|
|
87
167
|
#else
|
|
88
168
|
#include <errno.h>
|
|
89
169
|
#include <pthread.h>
|
|
170
|
+
#include <sched.h>
|
|
90
171
|
#include <time.h>
|
|
91
172
|
#include <stdlib.h>
|
|
92
173
|
#include <sys/mman.h>
|
|
174
|
+
#include <sys/resource.h>
|
|
93
175
|
#include <unistd.h>
|
|
94
176
|
#include <stdio.h>
|
|
95
177
|
#include <string.h>
|
|
178
|
+
#if defined(__GLIBC__)
|
|
179
|
+
#include <malloc.h>
|
|
180
|
+
#elif defined(__APPLE__)
|
|
181
|
+
#include <malloc/malloc.h>
|
|
182
|
+
#endif
|
|
96
183
|
|
|
97
184
|
size_t js_os_page_size(void) {
|
|
98
185
|
return (size_t)sysconf(_SC_PAGESIZE);
|
|
@@ -118,6 +205,94 @@ void js_os_unmap(void *p, size_t size) {
|
|
|
118
205
|
munmap(p, size);
|
|
119
206
|
}
|
|
120
207
|
|
|
208
|
+
void js_os_decommit(void *p, size_t size) {
|
|
209
|
+
#ifdef __linux__
|
|
210
|
+
madvise(p, size, MADV_DONTNEED); /* private anonymous pages: zero-filled when touched again */
|
|
211
|
+
#else
|
|
212
|
+
/* a fresh mapping in place: MADV_DONTNEED doesn't promise zeros everywhere */
|
|
213
|
+
mmap(p, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
|
|
214
|
+
#endif
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
bool js_os_commit(void *p, size_t size) {
|
|
218
|
+
(void)p, (void)size; /* the pages come back when touched */
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
void js_os_trim(void) {
|
|
223
|
+
#if defined(__GLIBC__)
|
|
224
|
+
malloc_trim(0);
|
|
225
|
+
#elif defined(__APPLE__)
|
|
226
|
+
malloc_zone_pressure_relief(NULL, 0);
|
|
227
|
+
#endif
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
struct JSOsLock { pthread_mutex_t mutex; };
|
|
231
|
+
struct JSOsCond { pthread_cond_t cond; };
|
|
232
|
+
struct JSOsThread { pthread_t thread; void (*fn)(void *); void *arg; };
|
|
233
|
+
|
|
234
|
+
JSOsLock *js_os_lock_new(void) {
|
|
235
|
+
JSOsLock *l = calloc(1, sizeof *l);
|
|
236
|
+
if (l && pthread_mutex_init(&l->mutex, NULL) != 0) {
|
|
237
|
+
free(l);
|
|
238
|
+
return NULL;
|
|
239
|
+
}
|
|
240
|
+
return l;
|
|
241
|
+
}
|
|
242
|
+
void js_os_lock_free(JSOsLock *l) {
|
|
243
|
+
pthread_mutex_destroy(&l->mutex);
|
|
244
|
+
free(l);
|
|
245
|
+
}
|
|
246
|
+
void js_os_lock(JSOsLock *l) { pthread_mutex_lock(&l->mutex); }
|
|
247
|
+
void js_os_unlock(JSOsLock *l) { pthread_mutex_unlock(&l->mutex); }
|
|
248
|
+
JSOsCond *js_os_cond_new(void) {
|
|
249
|
+
JSOsCond *c = calloc(1, sizeof *c);
|
|
250
|
+
if (c && pthread_cond_init(&c->cond, NULL) != 0) {
|
|
251
|
+
free(c);
|
|
252
|
+
return NULL;
|
|
253
|
+
}
|
|
254
|
+
return c;
|
|
255
|
+
}
|
|
256
|
+
void js_os_cond_free(JSOsCond *c) {
|
|
257
|
+
pthread_cond_destroy(&c->cond);
|
|
258
|
+
free(c);
|
|
259
|
+
}
|
|
260
|
+
void js_os_cond_wait(JSOsCond *c, JSOsLock *l) { pthread_cond_wait(&c->cond, &l->mutex); }
|
|
261
|
+
void js_os_cond_signal(JSOsCond *c) { pthread_cond_signal(&c->cond); }
|
|
262
|
+
void js_os_cond_broadcast(JSOsCond *c) { pthread_cond_broadcast(&c->cond); }
|
|
263
|
+
|
|
264
|
+
static void *thread_main(void *p) {
|
|
265
|
+
JSOsThread *t = p;
|
|
266
|
+
t->fn(t->arg);
|
|
267
|
+
return NULL;
|
|
268
|
+
}
|
|
269
|
+
JSOsThread *js_os_thread_start(void (*fn)(void *), void *arg) {
|
|
270
|
+
JSOsThread *t = calloc(1, sizeof *t);
|
|
271
|
+
if (!t) return NULL;
|
|
272
|
+
t->fn = fn;
|
|
273
|
+
t->arg = arg;
|
|
274
|
+
if (pthread_create(&t->thread, NULL, thread_main, t) != 0) {
|
|
275
|
+
free(t);
|
|
276
|
+
return NULL;
|
|
277
|
+
}
|
|
278
|
+
return t;
|
|
279
|
+
}
|
|
280
|
+
void js_os_thread_join(JSOsThread *t) {
|
|
281
|
+
pthread_join(t->thread, NULL);
|
|
282
|
+
free(t);
|
|
283
|
+
}
|
|
284
|
+
unsigned js_os_cpu_count(void) {
|
|
285
|
+
#if defined(__linux__)
|
|
286
|
+
cpu_set_t set;
|
|
287
|
+
if (sched_getaffinity(0, sizeof set, &set) == 0) {
|
|
288
|
+
int n = CPU_COUNT(&set);
|
|
289
|
+
if (n > 0) return (unsigned)n;
|
|
290
|
+
}
|
|
291
|
+
#endif
|
|
292
|
+
long n = sysconf(_SC_NPROCESSORS_ONLN);
|
|
293
|
+
return n > 0 ? (unsigned)n : 1;
|
|
294
|
+
}
|
|
295
|
+
|
|
121
296
|
void js_os_stack_bounds(void **low, void **high) {
|
|
122
297
|
#ifdef __APPLE__
|
|
123
298
|
pthread_t self = pthread_self();
|
|
@@ -193,4 +368,20 @@ const char *js_os_timezone_id(void) {
|
|
|
193
368
|
snprintf(id, sizeof id, "%s", z ? z + 9 : path);
|
|
194
369
|
return id;
|
|
195
370
|
}
|
|
371
|
+
|
|
372
|
+
double js_os_thread_cpu_ms(void) {
|
|
373
|
+
struct timespec ts;
|
|
374
|
+
if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) != 0) return js_os_now_ms_precise();
|
|
375
|
+
return (double)ts.tv_sec * 1000.0 + (double)ts.tv_nsec / 1e6;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
size_t js_os_peak_rss(void) {
|
|
379
|
+
struct rusage ru;
|
|
380
|
+
if (getrusage(RUSAGE_SELF, &ru) != 0) return 0;
|
|
381
|
+
#ifdef __APPLE__
|
|
382
|
+
return (size_t)ru.ru_maxrss; /* bytes */
|
|
383
|
+
#else
|
|
384
|
+
return (size_t)ru.ru_maxrss * 1024; /* KiB */
|
|
385
|
+
#endif
|
|
386
|
+
}
|
|
196
387
|
#endif
|
package/runtime/src/os.h
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* os.h — memory and time from the operating system
|
|
1
|
+
/* os.h — memory and time from the operating system. Runtime-internal. */
|
|
2
2
|
#ifndef JS_OS_H
|
|
3
3
|
#define JS_OS_H
|
|
4
4
|
|
|
@@ -11,13 +11,44 @@ void *js_os_map(size_t size);
|
|
|
11
11
|
/* Mapping aligned to `align` (a power of two, a multiple of 64 KiB). */
|
|
12
12
|
void *js_os_map_aligned(size_t size, size_t align);
|
|
13
13
|
void js_os_unmap(void *p, size_t size);
|
|
14
|
+
/* Gives a mapping's pages back to the OS, keeping the addresses: they read as zeros after
|
|
15
|
+
* js_os_commit, which they need before they're used again. */
|
|
16
|
+
void js_os_decommit(void *p, size_t size);
|
|
17
|
+
bool js_os_commit(void *p, size_t size);
|
|
18
|
+
/* Gives malloc's free memory back to the OS, where the C library can. */
|
|
19
|
+
void js_os_trim(void);
|
|
20
|
+
|
|
21
|
+
/* Threads, for the collector's helpers: a runtime has one mutator
|
|
22
|
+
* thread; these mark alongside it in the pauses. A lock and a condition, allocated. */
|
|
23
|
+
typedef struct JSOsLock JSOsLock;
|
|
24
|
+
typedef struct JSOsCond JSOsCond;
|
|
25
|
+
typedef struct JSOsThread JSOsThread;
|
|
26
|
+
JSOsLock *js_os_lock_new(void);
|
|
27
|
+
void js_os_lock_free(JSOsLock *l);
|
|
28
|
+
void js_os_lock(JSOsLock *l);
|
|
29
|
+
void js_os_unlock(JSOsLock *l);
|
|
30
|
+
JSOsCond *js_os_cond_new(void);
|
|
31
|
+
void js_os_cond_free(JSOsCond *c);
|
|
32
|
+
void js_os_cond_wait(JSOsCond *c, JSOsLock *l);
|
|
33
|
+
void js_os_cond_signal(JSOsCond *c);
|
|
34
|
+
void js_os_cond_broadcast(JSOsCond *c);
|
|
35
|
+
/* NULL when it can't */
|
|
36
|
+
JSOsThread *js_os_thread_start(void (*fn)(void *), void *arg);
|
|
37
|
+
void js_os_thread_join(JSOsThread *t);
|
|
38
|
+
/* The processors this process may run on (at least 1). */
|
|
39
|
+
unsigned js_os_cpu_count(void);
|
|
40
|
+
|
|
14
41
|
size_t js_os_page_size(void);
|
|
15
42
|
/* The calling thread's stack: [*low, *high). Stacks grow down, so *high is the base. */
|
|
16
43
|
void js_os_stack_bounds(void **low, void **high);
|
|
17
|
-
/* The event loop's clock
|
|
44
|
+
/* The event loop's clock: monotonic milliseconds, and sleeping. */
|
|
18
45
|
uint64_t js_os_now_ms(void);
|
|
19
46
|
double js_os_now_ms_precise(void); /* the same clock, with its sub-millisecond part */
|
|
20
47
|
void js_os_sleep_ms(uint64_t ms);
|
|
48
|
+
/* The calling thread's CPU time (user and system) in milliseconds, for the GC's policy. */
|
|
49
|
+
double js_os_thread_cpu_ms(void);
|
|
50
|
+
/* The process's peak resident memory in bytes (0 if unknown), for the GC's statistics. */
|
|
51
|
+
size_t js_os_peak_rss(void);
|
|
21
52
|
|
|
22
53
|
/* Date (the date component): wall-clock milliseconds since the epoch; the local time zone's
|
|
23
54
|
* offset from UTC, in seconds, at an instant (and whether daylight saving applies then); the
|
package/runtime/src/process.c
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* The global process
|
|
1
|
+
/* The global process, natively: the command line, the environment, the exit
|
|
2
2
|
* status, standard output and error, and warnings. js_host_init installs it with console
|
|
3
3
|
* and global before the program runs. Its events ('beforeExit', 'exit') go through its emit,
|
|
4
4
|
* which it has once node/prelude/internal/process_events.js made it an EventEmitter. */
|
|
@@ -285,8 +285,16 @@ NATIVE(process_cwd) {
|
|
|
285
285
|
return dir;
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
+
#ifndef _WIN32
|
|
289
|
+
/* getuid, geteuid, getgid, getegid: the process's ids (POSIX; Node has none of them on Windows) */
|
|
290
|
+
NATIVE(process_getuid) { UNUSED_ARGS; (void)ctx, (void)argc, (void)argv; return js_number((double)getuid()); }
|
|
291
|
+
NATIVE(process_geteuid) { UNUSED_ARGS; (void)ctx, (void)argc, (void)argv; return js_number((double)geteuid()); }
|
|
292
|
+
NATIVE(process_getgid) { UNUSED_ARGS; (void)ctx, (void)argc, (void)argv; return js_number((double)getgid()); }
|
|
293
|
+
NATIVE(process_getegid) { UNUSED_ARGS; (void)ctx, (void)argc, (void)argv; return js_number((double)getegid()); }
|
|
294
|
+
#endif
|
|
295
|
+
|
|
288
296
|
/* nextTick(callback, ...args): Node runs these before promise jobs; visaljs queues them
|
|
289
|
-
* with them
|
|
297
|
+
* with them. */
|
|
290
298
|
NATIVE(process_next_tick) {
|
|
291
299
|
UNUSED_ARGS;
|
|
292
300
|
if (!js_is_callable(ARG(0))) return invalid_arg_type(ctx, "callback", "of type function", ARG(0));
|
|
@@ -319,13 +327,29 @@ NATIVE(process_hrtime) {
|
|
|
319
327
|
return js_new_array_from(ctx, items, 2);
|
|
320
328
|
}
|
|
321
329
|
|
|
330
|
+
/* process.hrtime.bigint(): the time in nanoseconds; a program that calls it has BigInt */
|
|
331
|
+
NATIVE(process_hrtime_bigint) {
|
|
332
|
+
UNUSED_ARGS, (void)argc, (void)argv;
|
|
333
|
+
if (!ctx->rt->bigint) return js_throw_type_error(ctx, "BigInt is not available");
|
|
334
|
+
return ctx->rt->bigint->from_uint64(ctx, (uint64_t)(js_os_now_ms_precise() * 1e6));
|
|
335
|
+
}
|
|
336
|
+
|
|
322
337
|
void js_emit_warning(JSContext *ctx, JSValue message, const char *type, const char *code) {
|
|
338
|
+
const char *quiet = getenv("NODE_NO_WARNINGS"); /* as Node: "1" silences them */
|
|
339
|
+
if (quiet && strcmp(quiet, "1") == 0) return;
|
|
323
340
|
char prefix[96];
|
|
324
341
|
snprintf(prefix, sizeof prefix, "(node:%d) %s%s%s%s: ", (int)getpid(), code ? "[" : "", code ? code : "", code ? "] " : "", type);
|
|
325
342
|
fflush(stdout);
|
|
326
343
|
fputs(prefix, stderr);
|
|
327
344
|
js_write_output(ctx, 2, message);
|
|
328
345
|
fputc('\n', stderr);
|
|
346
|
+
/* after the first warning, Node's hint (it names node, whose flags it is) */
|
|
347
|
+
static bool hinted;
|
|
348
|
+
if (!hinted) {
|
|
349
|
+
hinted = true;
|
|
350
|
+
fprintf(stderr, "(Use `node %s ...` to show where the warning was created)\n",
|
|
351
|
+
strcmp(type, "DeprecationWarning") == 0 ? "--trace-deprecation" : "--trace-warnings");
|
|
352
|
+
}
|
|
329
353
|
}
|
|
330
354
|
|
|
331
355
|
/* emitWarning(warning, type | { type, code }, code): "(node:PID) Warning: …" on stderr. */
|
|
@@ -365,11 +389,18 @@ NATIVE(process_emit_warning) {
|
|
|
365
389
|
return JS_UNDEFINED;
|
|
366
390
|
}
|
|
367
391
|
|
|
368
|
-
/* stdout.write / stderr.write(chunk, encoding, callback)
|
|
392
|
+
/* stdout.write / stderr.write(chunk, encoding, callback): a string as UTF-8, a typed array or a
|
|
393
|
+
* DataView as its bytes; anything else is Node's TypeError */
|
|
369
394
|
static JSValue stream_write(JSContext *ctx, int fd, uint32_t argc, const JSValue *argv) {
|
|
370
|
-
JSValue
|
|
371
|
-
|
|
372
|
-
|
|
395
|
+
JSValue chunk = ARG(0);
|
|
396
|
+
uint8_t *data;
|
|
397
|
+
size_t length;
|
|
398
|
+
if (js_is_string(chunk)) js_write_output(ctx, fd, chunk);
|
|
399
|
+
else if (ctx->rt->view_bytes && ctx->rt->view_bytes(chunk, &data, &length)) js_write_bytes(fd, data, length);
|
|
400
|
+
else if (js_is_null(chunk)) {
|
|
401
|
+
JSValue m = js_new_string_cstr(ctx, "May not write null values to stream");
|
|
402
|
+
return js_is_exception(m) ? m : throw_with_code(ctx, JS_TYPE_ERROR, "ERR_STREAM_NULL_VALUES", m);
|
|
403
|
+
} else return invalid_arg_type(ctx, "chunk", "of type string or an instance of Buffer, TypedArray, or DataView", chunk);
|
|
373
404
|
JSValue callback = js_is_callable(ARG(1)) ? ARG(1) : ARG(2);
|
|
374
405
|
if (js_is_callable(callback)) {
|
|
375
406
|
JSJob job = { JS_JOB_CALLBACK, NULL, callback, JS_UNDEFINED, JS_UNDEFINED, JS_UNDEFINED };
|
|
@@ -460,6 +491,7 @@ static JSValue new_process(JSContext *ctx) {
|
|
|
460
491
|
}
|
|
461
492
|
define(ctx, p, "argv", args);
|
|
462
493
|
define(ctx, p, "argv0", js_new_string_cstr(ctx, argv0));
|
|
494
|
+
define(ctx, p, "execArgv", js_new_array(ctx, 0)); /* Node's own options: a compiled program has none */
|
|
463
495
|
define(ctx, p, "execPath", exec);
|
|
464
496
|
|
|
465
497
|
/* env: a snapshot (writes don't reach the C environment) */
|
|
@@ -477,14 +509,47 @@ static JSValue new_process(JSContext *ctx) {
|
|
|
477
509
|
}
|
|
478
510
|
define(ctx, p, "env", env);
|
|
479
511
|
define(ctx, p, "pid", js_int32((int32_t)getpid()));
|
|
512
|
+
/* version and versions: the Node API implemented, and visaljs's own; read-only, as Node's,
|
|
513
|
+
and versions extensible (Electron's tooling adds to it) */
|
|
514
|
+
js_define_data(ctx, p, js_atom_from_cstr(ctx, "version"), js_new_string_cstr(ctx, "v" JS_NODE_VERSION), JS_PROP_ENUMERABLE | JS_PROP_CONFIGURABLE);
|
|
515
|
+
JSValue versions = js_new_object(ctx);
|
|
516
|
+
if (js_is_exception(versions)) return versions;
|
|
517
|
+
js_define_data(ctx, js_as_object(versions), js_atom_from_cstr(ctx, "node"), js_new_string_cstr(ctx, JS_NODE_VERSION), JS_PROP_ENUMERABLE | JS_PROP_CONFIGURABLE);
|
|
518
|
+
js_define_data(ctx, js_as_object(versions), js_atom_from_cstr(ctx, "visaljs"), js_new_string_cstr(ctx, JS_VISALJS_VERSION), JS_PROP_ENUMERABLE | JS_PROP_CONFIGURABLE);
|
|
519
|
+
js_define_data(ctx, p, js_atom_from_cstr(ctx, "versions"), versions, JS_PROP_ENUMERABLE | JS_PROP_CONFIGURABLE);
|
|
520
|
+
/* features: what this build has, in Node 24's names. No inspector, TLS from
|
|
521
|
+
BoringSSL without OCSP stapling, require() of ES modules, no QUIC, no type stripping */
|
|
522
|
+
static const struct { const char *name; bool on; } features[] = {
|
|
523
|
+
{ "inspector", false }, { "debug", false }, { "uv", true }, { "ipv6", true },
|
|
524
|
+
{ "tls_alpn", true }, { "tls_sni", true }, { "tls_ocsp", false }, { "tls", true },
|
|
525
|
+
{ "openssl_is_boringssl", true }, { "cached_builtins", true }, { "require_module", true }, { "quic", false },
|
|
526
|
+
{ "typescript", false },
|
|
527
|
+
};
|
|
528
|
+
JSValue feats = js_new_object(ctx);
|
|
529
|
+
if (js_is_exception(feats)) return feats;
|
|
530
|
+
for (size_t i = 0; i < sizeof features / sizeof features[0]; i++)
|
|
531
|
+
define(ctx, js_as_object(feats), features[i].name, js_bool(features[i].on));
|
|
532
|
+
define(ctx, p, "features", feats);
|
|
480
533
|
define(ctx, p, "platform", js_new_string_cstr(ctx, platform()));
|
|
481
534
|
define(ctx, p, "arch", js_new_string_cstr(ctx, arch()));
|
|
482
535
|
define(ctx, p, "stdout", new_stream(ctx, 1, stdout_write));
|
|
483
536
|
define(ctx, p, "stderr", new_stream(ctx, 2, stderr_write));
|
|
484
537
|
define_fn(ctx, p, "cwd", process_cwd, 0);
|
|
538
|
+
#ifndef _WIN32
|
|
539
|
+
define_fn(ctx, p, "getuid", process_getuid, 0);
|
|
540
|
+
define_fn(ctx, p, "geteuid", process_geteuid, 0);
|
|
541
|
+
define_fn(ctx, p, "getgid", process_getgid, 0);
|
|
542
|
+
define_fn(ctx, p, "getegid", process_getegid, 0);
|
|
543
|
+
#endif
|
|
485
544
|
define_fn(ctx, p, "exit", process_exit, 1);
|
|
486
545
|
define_fn(ctx, p, "nextTick", process_next_tick, 1);
|
|
487
|
-
|
|
546
|
+
{
|
|
547
|
+
JSValue key = js_atom_from_cstr(ctx, "hrtime");
|
|
548
|
+
JSValue hrtime = js_new_native(ctx, process_hrtime, key, 1, JS_FN_STRICT);
|
|
549
|
+
if (js_is_exception(hrtime)) return JS_EXCEPTION;
|
|
550
|
+
define_fn(ctx, js_as_object(hrtime), "bigint", process_hrtime_bigint, 0);
|
|
551
|
+
js_define_data(ctx, p, key, hrtime, JS_PROP_DEFAULT);
|
|
552
|
+
}
|
|
488
553
|
define_fn(ctx, p, "emitWarning", process_emit_warning, 3);
|
|
489
554
|
/* exitCode: an accessor, as in Node (enumerable, not configurable) */
|
|
490
555
|
JSValue get = js_new_native(ctx, exit_code_get, js_atom_from_cstr(ctx, "get exitCode"), 0, JS_FN_STRICT);
|
|
@@ -496,7 +561,7 @@ static JSValue new_process(JSContext *ctx) {
|
|
|
496
561
|
return process;
|
|
497
562
|
}
|
|
498
563
|
|
|
499
|
-
/* Node's globals the runtime doesn't have: console, process and global
|
|
564
|
+
/* Node's globals the runtime doesn't have: console, process and global. */
|
|
500
565
|
int js_host_init(JSContext *ctx, int argc, char **argv) {
|
|
501
566
|
saved_argc = argc;
|
|
502
567
|
saved_argv = argv;
|
package/runtime/src/promise.c
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Promises (ECMAScript §27.2
|
|
1
|
+
/* Promises (ECMAScript §27.2): the promise object, reactions and their jobs,
|
|
2
2
|
* the Promise constructor, its statics and Promise.prototype. */
|
|
3
3
|
#include "js_promise.h"
|
|
4
4
|
|
|
@@ -74,7 +74,7 @@ typedef struct Reaction {
|
|
|
74
74
|
JSValue on_rejected; /* a function, or EMPTY: the reason passes through */
|
|
75
75
|
JSValue capability; /* the derived promise (settled directly), a Capability cell, or undefined */
|
|
76
76
|
JSValue next; /* the next (older) reaction, or undefined */
|
|
77
|
-
JSValue context; /* the async context of its then() or await, which its job runs under
|
|
77
|
+
JSValue context; /* the async context of its then() or await, which its job runs under */
|
|
78
78
|
} Reaction;
|
|
79
79
|
|
|
80
80
|
static void reaction_visit(JSCell *c, JSTracer *trc) {
|
|
@@ -85,7 +85,7 @@ static void reaction_visit(JSCell *c, JSTracer *trc) {
|
|
|
85
85
|
js_trace_value(trc, r->next);
|
|
86
86
|
js_trace_value(trc, r->context);
|
|
87
87
|
}
|
|
88
|
-
static const JSCellClass reaction_class = { "PromiseReaction", reaction_visit, NULL };
|
|
88
|
+
static const JSCellClass reaction_class = { "PromiseReaction", reaction_visit, NULL, NULL };
|
|
89
89
|
|
|
90
90
|
static void enqueue_reaction(JSContext *ctx, JSValue reaction, JSValue argument, int state) {
|
|
91
91
|
JSJob job = { JS_JOB_PROMISE_REACTION, NULL, reaction, argument, js_int32(state), JS_UNDEFINED };
|
|
@@ -198,7 +198,7 @@ static void capability_visit(JSCell *c, JSTracer *trc) {
|
|
|
198
198
|
js_trace_value(trc, k->resolve);
|
|
199
199
|
js_trace_value(trc, k->reject);
|
|
200
200
|
}
|
|
201
|
-
static const JSCellClass capability_class = { "PromiseCapability", capability_visit, NULL };
|
|
201
|
+
static const JSCellClass capability_class = { "PromiseCapability", capability_visit, NULL, NULL };
|
|
202
202
|
|
|
203
203
|
/* As a value for a reaction: the promise itself when it is settled directly. */
|
|
204
204
|
static JSValue cap_store(JSContext *ctx, const Cap *cap) {
|
package/runtime/src/proxy.c
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Proxy (ECMAScript §10.5, §28.2), an optional component
|
|
1
|
+
/* Proxy (ECMAScript §10.5, §28.2), an optional component.
|
|
2
2
|
*
|
|
3
3
|
* A proxy's class overrides every internal method (JSClass.methods, and the get_own_property,
|
|
4
4
|
* define_own_property and delete_property hooks): each calls the handler's trap, or the target's
|
package/runtime/src/reflect.c
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Reflect (ECMAScript §28.1), an optional component
|
|
1
|
+
/* Reflect (ECMAScript §28.1), an optional component: the object internal methods as
|
|
2
2
|
* functions. Each checks its target is an object, then calls the internal method. */
|
|
3
3
|
#include <stdio.h>
|
|
4
4
|
|
package/runtime/src/regexp.c
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* RegExp (ECMAScript §22.2), the regexp component
|
|
1
|
+
/* RegExp (ECMAScript §22.2), the regexp component.
|
|
2
2
|
*
|
|
3
3
|
* The engine is QuickJS's libregexp (third_party/quickjs-regexp): a pattern compiles to bytecode,
|
|
4
4
|
* and lre_exec runs it straight on a string's Latin-1 or UTF-16 characters. Literals arrive
|
|
@@ -33,6 +33,9 @@ typedef struct RegExpObject {
|
|
|
33
33
|
JSValue source; /* [[OriginalSource]]: a string */
|
|
34
34
|
const uint8_t *bytecode; /* [[RegExpMatcher]]; its flags are [[OriginalFlags]] */
|
|
35
35
|
bool owned; /* malloc'd (compiled at run time): the finalizer frees it */
|
|
36
|
+
bool one_class; /* the pattern is one character class: `units` (see find_class) */
|
|
37
|
+
bool negated; /* ...that matches every unit from U+0100 up */
|
|
38
|
+
uint32_t units[8]; /* its units below U+0100, a bit each */
|
|
36
39
|
} RegExpObject;
|
|
37
40
|
|
|
38
41
|
static void regexp_visit(JSCell *c, JSTracer *trc) { js_trace_value(trc, ((RegExpObject *)c)->source); }
|
|
@@ -232,6 +235,7 @@ static JSValue regexp_new(JSContext *ctx, JSValue proto) {
|
|
|
232
235
|
re->source = js_empty_string();
|
|
233
236
|
re->bytecode = NULL;
|
|
234
237
|
re->owned = false;
|
|
238
|
+
re->one_class = false;
|
|
235
239
|
js_define_data(ctx, &re->obj, JS_ATOM(lastIndex), JS_UNDEFINED, JS_PROP_WRITABLE);
|
|
236
240
|
return js_object_value(&re->obj);
|
|
237
241
|
}
|
|
@@ -242,11 +246,137 @@ static JSValue regexp_alloc(JSContext *ctx, JSValue new_target) {
|
|
|
242
246
|
return js_is_exception(proto) ? proto : regexp_new(ctx, proto);
|
|
243
247
|
}
|
|
244
248
|
|
|
249
|
+
/* ---- One character class, matched without the engine ---------------------------------------
|
|
250
|
+
*
|
|
251
|
+
* A pattern that is a single character, or a single class of characters below U+0100, matches
|
|
252
|
+
* one code unit: builtin_exec scans for it in place of lre_exec (React's and escape-html's
|
|
253
|
+
* /["'&<>]/, a split on /[,;]/). Without i, u or v only: case folding and code points change what
|
|
254
|
+
* a character matches. The source is parsed conservatively: anything else keeps the engine. */
|
|
255
|
+
|
|
256
|
+
typedef struct {
|
|
257
|
+
JSStrView v;
|
|
258
|
+
uint32_t at;
|
|
259
|
+
} Source;
|
|
260
|
+
|
|
261
|
+
static int peek(const Source *s) { return s->at < s->v.length ? (int)js_view_at(s->v, s->at) : -1; }
|
|
262
|
+
|
|
263
|
+
static void add_range(uint32_t units[8], int lo, int hi) {
|
|
264
|
+
for (int c = lo; c <= hi; c++) units[c >> 5] |= 1u << (c & 31);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
enum { NOT_ONE = -1, DIGITS = -2, WORD = -3 };
|
|
268
|
+
|
|
269
|
+
static int hex_digit(int c) {
|
|
270
|
+
return c >= '0' && c <= '9' ? c - '0' : c >= 'a' && c <= 'f' ? c - 'a' + 10 : c >= 'A' && c <= 'F' ? c - 'A' + 10 : -1;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/* The unit an escape stands for (after its backslash), DIGITS or WORD for \d and \w, or NOT_ONE. */
|
|
274
|
+
static int escape_unit(Source *s, bool in_class) {
|
|
275
|
+
int c = peek(s);
|
|
276
|
+
if (c < 0) return NOT_ONE;
|
|
277
|
+
s->at++;
|
|
278
|
+
switch (c) {
|
|
279
|
+
case 'n': return '\n';
|
|
280
|
+
case 'r': return '\r';
|
|
281
|
+
case 't': return '\t';
|
|
282
|
+
case 'f': return '\f';
|
|
283
|
+
case 'v': return '\v';
|
|
284
|
+
case 'd': return DIGITS;
|
|
285
|
+
case 'w': return WORD;
|
|
286
|
+
case 'b': return in_class ? '\b' : NOT_ONE;
|
|
287
|
+
case '0': {
|
|
288
|
+
int d = peek(s);
|
|
289
|
+
return d >= '0' && d <= '9' ? NOT_ONE : 0;
|
|
290
|
+
}
|
|
291
|
+
case 'x': {
|
|
292
|
+
int h = s->at + 1 < s->v.length ? hex_digit(peek(s)) : -1;
|
|
293
|
+
int l = h >= 0 ? hex_digit((int)js_view_at(s->v, s->at + 1)) : -1;
|
|
294
|
+
if (l < 0) return NOT_ONE;
|
|
295
|
+
s->at += 2;
|
|
296
|
+
return h * 16 + l;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return c < 0x80 && strchr("^$\\.*+?()[]{}|/-", c) ? c : NOT_ONE; /* a syntax character, escaped */
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/* A class's unit (after reading it), or DIGITS / WORD (added to `units`), or NOT_ONE. */
|
|
303
|
+
static int class_unit(Source *s, uint32_t units[8]) {
|
|
304
|
+
int c = peek(s);
|
|
305
|
+
s->at++;
|
|
306
|
+
if (c != '\\') return c;
|
|
307
|
+
c = escape_unit(s, true);
|
|
308
|
+
if (c == DIGITS) add_range(units, '0', '9');
|
|
309
|
+
if (c == WORD) add_range(units, '0', '9'), add_range(units, 'A', 'Z'), add_range(units, 'a', 'z'), add_range(units, '_', '_');
|
|
310
|
+
return c;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
static void find_class(JSContext *ctx, RegExpObject *re) {
|
|
314
|
+
re->one_class = false;
|
|
315
|
+
if (lre_get_flags(re->bytecode) & (LRE_FLAG_IGNORECASE | LRE_FLAG_UNICODE | LRE_FLAG_UNICODE_SETS | LRE_FLAG_NAMED_GROUPS)) return;
|
|
316
|
+
Source s = { js_string_view(ctx, re->source), 0 };
|
|
317
|
+
uint32_t units[8] = { 0 };
|
|
318
|
+
bool negated = false;
|
|
319
|
+
int c = peek(&s);
|
|
320
|
+
if (c < 0) return;
|
|
321
|
+
s.at++;
|
|
322
|
+
if (c == '[') {
|
|
323
|
+
negated = peek(&s) == '^';
|
|
324
|
+
if (negated) s.at++;
|
|
325
|
+
for (;;) {
|
|
326
|
+
c = peek(&s);
|
|
327
|
+
if (c < 0) return;
|
|
328
|
+
if (c == ']') break;
|
|
329
|
+
int lo = class_unit(&s, units);
|
|
330
|
+
if (lo == NOT_ONE || lo >= 0x100) return;
|
|
331
|
+
if (peek(&s) == '-' && s.at + 1 < s.v.length && js_view_at(s.v, s.at + 1) != ']') {
|
|
332
|
+
s.at++;
|
|
333
|
+
int hi = class_unit(&s, units);
|
|
334
|
+
if (lo < 0 || hi < lo || hi >= 0x100) return; /* a class escape in a range: Annex B's */
|
|
335
|
+
add_range(units, lo, hi);
|
|
336
|
+
} else if (lo >= 0) {
|
|
337
|
+
add_range(units, lo, lo);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
s.at++;
|
|
341
|
+
if (negated)
|
|
342
|
+
for (int i = 0; i < 8; i++) units[i] = ~units[i];
|
|
343
|
+
} else if (c == '\\') {
|
|
344
|
+
Source t = { s.v, s.at - 1 }; /* from the backslash */
|
|
345
|
+
c = class_unit(&t, units);
|
|
346
|
+
s.at = t.at;
|
|
347
|
+
if (c == NOT_ONE || c == '\b' || c >= 0x100) return; /* \b outside a class: a word boundary */
|
|
348
|
+
if (c >= 0) add_range(units, c, c);
|
|
349
|
+
} else {
|
|
350
|
+
if (c >= 0x100 || (c < 0x80 && strchr("^$.*+?()[]{}|/", c))) return;
|
|
351
|
+
add_range(units, c, c);
|
|
352
|
+
}
|
|
353
|
+
if (s.at != s.v.length) return; /* more than the one class */
|
|
354
|
+
memcpy(re->units, units, sizeof units);
|
|
355
|
+
re->negated = negated;
|
|
356
|
+
re->one_class = true;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/* The first unit from `from` (only there, sticky) in the class: 1 with capture 0 set, as lre_exec. */
|
|
360
|
+
static int scan_class(const RegExpObject *re, const uint8_t *buf, int shift, uint32_t from, uint32_t length, bool sticky,
|
|
361
|
+
uint8_t **capture) {
|
|
362
|
+
uint32_t end = sticky && from < length ? from + 1 : length;
|
|
363
|
+
for (uint32_t i = from; i < end; i++) {
|
|
364
|
+
uint32_t c = shift ? ((const uint16_t *)buf)[i] : buf[i];
|
|
365
|
+
if (c < 0x100 ? (re->units[c >> 5] >> (c & 31)) & 1 : re->negated) {
|
|
366
|
+
capture[0] = (uint8_t *)buf + ((size_t)i << shift);
|
|
367
|
+
capture[1] = capture[0] + ((size_t)1 << shift);
|
|
368
|
+
return 1;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return 0;
|
|
372
|
+
}
|
|
373
|
+
|
|
245
374
|
static void set_matcher(JSContext *ctx, RegExpObject *re, JSValue source, const uint8_t *bytecode, bool owned) {
|
|
246
375
|
if (re->owned) free((void *)re->bytecode);
|
|
247
376
|
js_store(ctx, &re->obj.cell, &re->source, source);
|
|
248
377
|
re->bytecode = bytecode;
|
|
249
378
|
re->owned = owned;
|
|
379
|
+
find_class(ctx, re);
|
|
250
380
|
}
|
|
251
381
|
|
|
252
382
|
/* RegExpInitialize (§22.2.3.3) */
|
|
@@ -544,7 +674,9 @@ static JSValue builtin_exec(JSContext *ctx, JSValue rx, JSValue s) {
|
|
|
544
674
|
if (!capture) js_fatal("out of memory matching a regular expression");
|
|
545
675
|
int shift = v.latin1 ? 0 : 1;
|
|
546
676
|
const uint8_t *buf = v.chars;
|
|
547
|
-
int rc = last_index > v.length ? 2
|
|
677
|
+
int rc = last_index > v.length ? 2
|
|
678
|
+
: re->one_class ? scan_class(re, buf, shift, (uint32_t)last_index, v.length, (flags & LRE_FLAG_STICKY) != 0, capture)
|
|
679
|
+
: lre_exec(capture, bc, buf, (int)last_index, (int)v.length, shift, ctx);
|
|
548
680
|
JSValue result = JS_NULL;
|
|
549
681
|
if (rc < 0) {
|
|
550
682
|
result = throw_exec_failure(ctx, rc);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* regexp_anchor.h — a start-anchored regular expression tries one position
|
|
1
|
+
/* regexp_anchor.h — a start-anchored regular expression tries one position, shared
|
|
2
2
|
* by the runtime (new RegExp) and the compiler's regexp-compile tool (literals).
|
|
3
3
|
*
|
|
4
4
|
* libregexp starts a non-sticky program with a loop that tries every position:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* regexp_message.h — libregexp's error messages in V8's words
|
|
1
|
+
/* regexp_message.h — libregexp's error messages in V8's words, shared by the runtime
|
|
2
2
|
* (new RegExp) and the compiler's regexp-compile tool (literals), so both report alike. */
|
|
3
3
|
#ifndef JS_REGEXP_MESSAGE_H
|
|
4
4
|
#define JS_REGEXP_MESSAGE_H
|