@scriptc/cli-darwin-x64 0.0.0 → 0.2.0
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/dist/LICENSE +202 -0
- package/dist/THIRD_PARTY_NOTICES +4 -0
- package/dist/bin/scriptc +0 -0
- package/dist/bin/scriptc.json +21 -0
- package/dist/lib/declarations/scriptc-node-fallback.d.ts +3847 -0
- package/dist/lib/declarations/scriptc-overrides.d.ts +92 -0
- package/dist/lib/declarations/scriptc.d.ts +98 -0
- package/dist/lib/llvm/LICENSE +1 -0
- package/dist/lib/llvm/SCRIPTC_LICENSE +1 -0
- package/dist/lib/llvm/THIRD_PARTY_NOTICES +1 -0
- package/dist/lib/llvm/bin/scriptc-llvm-codegen +0 -0
- package/dist/lib/llvm/package.json +35 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bigint_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_dc.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_dgram.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_dyn_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_fetch.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_ffi.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_ffi_queue.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_inspect.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_loop_epoll.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_loop_kqueue.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_loop_wsapoll.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_path.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_readline.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_test.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_tls.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_tls_ca.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_util.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_watch.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_zlib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bigint_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_dc.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_dgram.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_dyn_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_fetch.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_ffi.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_ffi_queue.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_inspect.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_inspect_island.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_island.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_loop_epoll.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_loop_kqueue.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_loop_wsapoll.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_net_island.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_path.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_readline.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_test.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_tls.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_tls_ca.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_util.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_watch.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_web.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_zlib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_zlib_island.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bigint_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_dyn_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_inspect.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_library.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_path.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_zlib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bigint_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_dyn_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_inspect.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_library.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_path.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_zlib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bigint_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_dyn_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_inspect.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_library.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_path.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_zlib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bigint_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_dyn_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_inspect.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_library.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_path.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_zlib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/licenses/mbedtls.txt +553 -0
- package/dist/lib/runtime-darwin-x64/artifacts/licenses/quickjs-ng.txt +24 -0
- package/dist/lib/runtime-darwin-x64/artifacts/licenses/ryu.txt +23 -0
- package/dist/lib/runtime-darwin-x64/artifacts/licenses/scriptc-runtime.txt +202 -0
- package/dist/lib/runtime-darwin-x64/artifacts/licenses/unicode.txt +39 -0
- package/dist/lib/runtime-darwin-x64/artifacts/licenses/zlib.txt +22 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bigint_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_dc.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_dgram.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_dyn_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_fetch.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_ffi.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_ffi_queue.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_inspect.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_loop_epoll.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_loop_kqueue.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_loop_wsapoll.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_path.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_readline.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_test.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_tls.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_tls_ca.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_util.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_watch.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_zlib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bigint_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_closure.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_copying.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_cycle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_dc.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_dgram.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_dyn_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_events_emitter.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_fetch.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_ffi.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_ffi_queue.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_inspect.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_inspect_island.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_island.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_loop_epoll.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_loop_kqueue.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_loop_wsapoll.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_net_island.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_number.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_path.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_readline.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_test.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_tls.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_tls_ca.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_union.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_util.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_watch.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_web.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_zlib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_zlib_island.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/vendor/libregexp/libscriptc-libregexp.a +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/vendor/mbedtls/libscriptc-mbedtls.a +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/vendor/quickjs/libscriptc-quickjs.a +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/vendor/zlib/libscriptc-zlib.a +0 -0
- package/dist/lib/runtime-darwin-x64/package.json +24 -0
- package/dist/lib/runtime-darwin-x64/runtime-pack.json +5758 -0
- package/dist/lib/runtime-sources/LICENSE +202 -0
- package/dist/lib/runtime-sources/package.json +22 -0
- package/dist/lib/runtime-sources/src/scr_array.c +1444 -0
- package/dist/lib/runtime-sources/src/scr_assert.c +1537 -0
- package/dist/lib/runtime-sources/src/scr_async.c +3920 -0
- package/dist/lib/runtime-sources/src/scr_async.test.c +134 -0
- package/dist/lib/runtime-sources/src/scr_async.test.ts +34 -0
- package/dist/lib/runtime-sources/src/scr_async_dyn.c +803 -0
- package/dist/lib/runtime-sources/src/scr_bigint.c +890 -0
- package/dist/lib/runtime-sources/src/scr_bigint_assert.c +22 -0
- package/dist/lib/runtime-sources/src/scr_bytes.c +2518 -0
- package/dist/lib/runtime-sources/src/scr_bytes_io.c +755 -0
- package/dist/lib/runtime-sources/src/scr_child.c +5808 -0
- package/dist/lib/runtime-sources/src/scr_closure.c +213 -0
- package/dist/lib/runtime-sources/src/scr_console.c +259 -0
- package/dist/lib/runtime-sources/src/scr_console_native.c +95 -0
- package/dist/lib/runtime-sources/src/scr_copying.c +146 -0
- package/dist/lib/runtime-sources/src/scr_crypto_async.c +24 -0
- package/dist/lib/runtime-sources/src/scr_cycle.c +565 -0
- package/dist/lib/runtime-sources/src/scr_dc.c +814 -0
- package/dist/lib/runtime-sources/src/scr_dgram.c +1182 -0
- package/dist/lib/runtime-sources/src/scr_dyn_handle.c +96 -0
- package/dist/lib/runtime-sources/src/scr_dyn_invoke.c +1626 -0
- package/dist/lib/runtime-sources/src/scr_error.c +372 -0
- package/dist/lib/runtime-sources/src/scr_events.c +1222 -0
- package/dist/lib/runtime-sources/src/scr_events_emitter.c +842 -0
- package/dist/lib/runtime-sources/src/scr_exception.c +468 -0
- package/dist/lib/runtime-sources/src/scr_fetch.c +7215 -0
- package/dist/lib/runtime-sources/src/scr_fetch_curl.c +666 -0
- package/dist/lib/runtime-sources/src/scr_ffi.c +143 -0
- package/dist/lib/runtime-sources/src/scr_ffi_queue.c +379 -0
- package/dist/lib/runtime-sources/src/scr_file_handle.c +562 -0
- package/dist/lib/runtime-sources/src/scr_grapheme.c +203 -0
- package/dist/lib/runtime-sources/src/scr_grapheme_data.h +842 -0
- package/dist/lib/runtime-sources/src/scr_http.c +5808 -0
- package/dist/lib/runtime-sources/src/scr_http2.c +3243 -0
- package/dist/lib/runtime-sources/src/scr_inspect.c +923 -0
- package/dist/lib/runtime-sources/src/scr_inspect_island.c +51 -0
- package/dist/lib/runtime-sources/src/scr_island.c +9987 -0
- package/dist/lib/runtime-sources/src/scr_island_manifest.h +153 -0
- package/dist/lib/runtime-sources/src/scr_json.c +7928 -0
- package/dist/lib/runtime-sources/src/scr_json.test.c +182 -0
- package/dist/lib/runtime-sources/src/scr_json.test.ts +33 -0
- package/dist/lib/runtime-sources/src/scr_lib.c +6304 -0
- package/dist/lib/runtime-sources/src/scr_library.c +444 -0
- package/dist/lib/runtime-sources/src/scr_loop_epoll.c +241 -0
- package/dist/lib/runtime-sources/src/scr_loop_kqueue.c +121 -0
- package/dist/lib/runtime-sources/src/scr_loop_wsapoll.c +208 -0
- package/dist/lib/runtime-sources/src/scr_map.c +705 -0
- package/dist/lib/runtime-sources/src/scr_musl.c +438 -0
- package/dist/lib/runtime-sources/src/scr_net.c +3708 -0
- package/dist/lib/runtime-sources/src/scr_net_island.c +458 -0
- package/dist/lib/runtime-sources/src/scr_node_builtin.c +281 -0
- package/dist/lib/runtime-sources/src/scr_number.c +192 -0
- package/dist/lib/runtime-sources/src/scr_object.c +80 -0
- package/dist/lib/runtime-sources/src/scr_path.c +1281 -0
- package/dist/lib/runtime-sources/src/scr_platform.h +119 -0
- package/dist/lib/runtime-sources/src/scr_qs.c +496 -0
- package/dist/lib/runtime-sources/src/scr_readline.c +288 -0
- package/dist/lib/runtime-sources/src/scr_regex.c +1274 -0
- package/dist/lib/runtime-sources/src/scr_runtime.h +7207 -0
- package/dist/lib/runtime-sources/src/scr_stream.c +3149 -0
- package/dist/lib/runtime-sources/src/scr_string.c +1849 -0
- package/dist/lib/runtime-sources/src/scr_symbol.c +234 -0
- package/dist/lib/runtime-sources/src/scr_test.c +662 -0
- package/dist/lib/runtime-sources/src/scr_text_decoder_data.h +7389 -0
- package/dist/lib/runtime-sources/src/scr_tls.c +1806 -0
- package/dist/lib/runtime-sources/src/scr_tls_ca.c +433 -0
- package/dist/lib/runtime-sources/src/scr_union.c +105 -0
- package/dist/lib/runtime-sources/src/scr_url.c +1231 -0
- package/dist/lib/runtime-sources/src/scr_url_internal.h +29 -0
- package/dist/lib/runtime-sources/src/scr_url_params.c +526 -0
- package/dist/lib/runtime-sources/src/scr_util.c +984 -0
- package/dist/lib/runtime-sources/src/scr_watch.c +568 -0
- package/dist/lib/runtime-sources/src/scr_web.c +1854 -0
- package/dist/lib/runtime-sources/src/scr_win.c +231 -0
- package/dist/lib/runtime-sources/src/scr_win_stats.h +23 -0
- package/dist/lib/runtime-sources/src/scr_zlib.c +358 -0
- package/dist/lib/runtime-sources/src/scr_zlib_island.c +15 -0
- package/dist/lib/runtime-sources/vendor/README.md +60 -0
- package/dist/lib/runtime-sources/vendor/curl/COPYRIGHT +534 -0
- package/dist/lib/runtime-sources/vendor/curl/include/curl/curl.h +3214 -0
- package/dist/lib/runtime-sources/vendor/curl/include/curl/curlver.h +79 -0
- package/dist/lib/runtime-sources/vendor/curl/include/curl/easy.h +125 -0
- package/dist/lib/runtime-sources/vendor/curl/include/curl/header.h +74 -0
- package/dist/lib/runtime-sources/vendor/curl/include/curl/mprintf.h +52 -0
- package/dist/lib/runtime-sources/vendor/curl/include/curl/multi.h +460 -0
- package/dist/lib/runtime-sources/vendor/curl/include/curl/options.h +70 -0
- package/dist/lib/runtime-sources/vendor/curl/include/curl/stdcheaders.h +35 -0
- package/dist/lib/runtime-sources/vendor/curl/include/curl/system.h +508 -0
- package/dist/lib/runtime-sources/vendor/curl/include/curl/typecheck-gcc.h +716 -0
- package/dist/lib/runtime-sources/vendor/curl/include/curl/urlapi.h +149 -0
- package/dist/lib/runtime-sources/vendor/curl/include/curl/websockets.h +84 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/LICENSE +553 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/CMakeLists.txt +22 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/aes.h +631 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/aria.h +343 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/asn1.h +642 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/asn1write.h +390 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/base64.h +82 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/bignum.h +1088 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/block_cipher.h +76 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/build_info.h +194 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/camellia.h +305 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ccm.h +526 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/chacha20.h +209 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/chachapoly.h +351 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/check_config.h +1149 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/cipher.h +1250 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/cmac.h +246 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/compat-2.x.h +46 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_legacy_crypto.h +578 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_legacy_from_psa.h +873 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_psa_from_legacy.h +359 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_psa_superset_legacy.h +145 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_ssl.h +91 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_x509.h +35 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_psa.h +61 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/constant_time.h +36 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ctr_drbg.h +596 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/debug.h +156 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/des.h +385 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/dhm.h +972 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ecdh.h +455 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ecdsa.h +674 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ecjpake.h +298 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ecp.h +1517 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/entropy.h +274 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/error.h +201 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/gcm.h +387 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/hkdf.h +124 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/hmac_drbg.h +434 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/lms.h +440 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/mbedtls_config.h +4446 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/md.h +526 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/md5.h +190 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/memory_buffer_alloc.h +142 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/net_sockets.h +299 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/nist_kw.h +166 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/oid.h +727 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/pem.h +160 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/pk.h +1303 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/pkcs12.h +186 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/pkcs5.h +198 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/pkcs7.h +252 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/platform.h +516 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/platform_time.h +79 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/platform_util.h +247 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/poly1305.h +168 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/private_access.h +20 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/psa_util.h +207 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ripemd160.h +136 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/rsa.h +1170 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/sha1.h +219 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/sha256.h +200 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/sha3.h +172 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/sha512.h +208 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ssl.h +5887 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ssl_cache.h +187 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ssl_ciphersuites.h +482 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ssl_cookie.h +106 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ssl_ticket.h +199 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/threading.h +167 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/timing.h +94 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/version.h +78 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/x509.h +500 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/x509_crl.h +184 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/x509_crt.h +1208 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/x509_csr.h +382 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/build_info.h +20 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto.h +4998 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_adjust_auto_enabled.h +31 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_adjust_config_dependencies.h +51 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_adjust_config_key_pair_types.h +101 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_adjust_config_synonyms.h +49 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_builtin_composites.h +214 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_builtin_key_derivation.h +118 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_builtin_primitives.h +114 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_compat.h +230 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_config.h +145 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_driver_common.h +44 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_driver_contexts_composites.h +151 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_driver_contexts_key_derivation.h +52 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_driver_contexts_primitives.h +105 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_extra.h +2145 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_legacy.h +88 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_platform.h +102 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_se_driver.h +1383 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_sizes.h +1319 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_struct.h +527 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_types.h +508 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_values.h +2782 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/aes.c +2294 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/aesce.c +624 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/aesce.h +136 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/aesni.c +846 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/aesni.h +162 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/alignment.h +704 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/aria.c +969 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/asn1parse.c +468 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/asn1write.c +440 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/base64.c +322 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/base64_internal.h +45 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum.c +2583 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_core.c +1240 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_core.h +872 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_core_invasive.h +38 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_internal.h +122 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_mod.c +394 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_mod.h +452 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_mod_raw.c +276 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_mod_raw.h +416 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_mod_raw_invasive.h +34 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/block_cipher.c +207 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/block_cipher_internal.h +99 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/bn_mul.h +1094 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/camellia.c +1058 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ccm.c +777 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/chacha20.c +563 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/chacha20_internal.h +23 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/chachapoly.c +487 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/check_crypto_config.h +136 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/cipher.c +1712 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/cipher_invasive.h +28 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/cipher_wrap.c +2482 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/cipher_wrap.h +178 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/cmac.c +1067 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/common.h +487 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/constant_time.c +247 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/constant_time_impl.h +541 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/constant_time_internal.h +579 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ctr.h +35 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ctr_drbg.c +1016 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/debug.c +475 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/debug_internal.h +185 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/des.c +1042 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/dhm.c +700 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ecdh.c +696 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ecdsa.c +858 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ecjpake.c +1216 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ecp.c +3674 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ecp_curves.c +6125 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ecp_curves_new.c +9 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ecp_internal_alt.h +287 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ecp_invasive.h +305 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/entropy.c +680 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/entropy_poll.c +233 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/entropy_poll.h +64 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/error.c +878 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/gcm.c +1330 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/hkdf.c +161 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/hmac_drbg.c +633 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/lmots.c +789 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/lmots.h +288 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/lms.c +778 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/md.c +1108 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/md5.c +426 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/md_psa.h +26 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/md_wrap.h +46 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/memory_buffer_alloc.c +751 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_common.h +181 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_error.h +89 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_reader.c +538 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_reader.h +366 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_trace.c +112 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_trace.h +154 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/net_sockets.c +694 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/nist_kw.c +729 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/oid.c +1166 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/padlock.c +157 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/padlock.h +111 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/pem.c +554 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/pk.c +1602 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/pk_ecc.c +261 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/pk_internal.h +241 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/pk_wrap.c +1618 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/pk_wrap.h +138 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/pkcs12.c +437 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/pkcs5.c +500 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/pkcs7.c +787 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/pkparse.c +1392 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/pkwrite.c +631 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/pkwrite.h +121 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/platform.c +402 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/platform_util.c +258 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/poly1305.c +492 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto.c +9532 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_aead.c +646 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_aead.h +499 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_cipher.c +747 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_cipher.h +316 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_client.c +22 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_core.h +983 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_core_common.h +52 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_driver_wrappers.h +2896 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_driver_wrappers_no_static.c +256 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_driver_wrappers_no_static.h +31 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_ecp.c +594 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_ecp.h +267 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_ffdh.c +361 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_ffdh.h +131 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_hash.c +470 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_hash.h +211 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_invasive.h +92 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_its.h +131 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_mac.c +505 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_mac.h +264 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_pake.c +571 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_pake.h +159 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_random.c +181 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_random.h +72 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_random_impl.h +200 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_rsa.c +714 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_rsa.h +321 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_se.c +373 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_se.h +192 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_slot_management.c +1137 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_slot_management.h +344 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_storage.c +481 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_storage.h +392 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_its_file.c +254 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_util.c +614 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_util_internal.h +100 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ripemd160.c +490 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/rsa.c +3121 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/rsa_alt_helpers.c +455 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/rsa_alt_helpers.h +209 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/rsa_internal.h +188 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/sha1.c +480 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/sha256.c +983 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/sha3.c +721 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/sha512.c +1115 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_cache.c +410 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_ciphersuites.c +2050 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_ciphersuites_internal.h +154 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_client.c +1023 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_client.h +22 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_cookie.c +384 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_debug_helpers.h +85 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_debug_helpers_generated.c +251 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_misc.h +3198 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_msg.c +6619 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_ticket.c +556 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls.c +10234 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls12_client.c +3688 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls12_server.c +4311 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_client.c +3208 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_generic.c +1793 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_invasive.h +23 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_keys.c +1918 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_keys.h +668 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_server.c +3624 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/threading.c +193 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/threading_internal.h +28 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/timing.c +152 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/version.c +32 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/version_features.c +856 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/x509.c +1776 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/x509_create.c +570 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/x509_crl.c +708 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/x509_crt.c +3311 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/x509_csr.c +648 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/x509_internal.h +101 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/x509write.c +174 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/x509write_crt.c +688 -0
- package/dist/lib/runtime-sources/vendor/mbedtls/library/x509write_csr.c +336 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/CMakeLists.txt +566 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/LICENSE +24 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/README.md +24 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/api-test.c +1195 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/builtin-array-fromasync.h +119 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/builtin-iterator-zip-keyed.h +332 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/builtin-iterator-zip.h +337 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/cutils.h +1998 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/dtoa.c +1619 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/dtoa.h +87 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/function_source.c +81 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/hello.c +53 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/hello_module.c +106 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/repl.c +3036 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/standalone.c +323 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/test_fib.c +81 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/libregexp-opcode.h +73 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/libregexp.c +3474 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/libregexp.h +101 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/libunicode-table.h +5173 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/libunicode.c +2069 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/libunicode.h +172 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/list.h +107 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/lre-test.c +52 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/qjs.c +762 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/qjsc.c +673 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs-atom.h +280 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs-c-atomics.h +54 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs-libc.c +5037 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs-libc.h +87 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs-opcode.h +377 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs.c +64041 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs.h +1447 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/run-test262.c +2374 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/unicode_gen.c +3121 -0
- package/dist/lib/runtime-sources/vendor/quickjs-ng/unicode_gen_def.h +310 -0
- package/dist/lib/runtime-sources/vendor/ryu/LICENSE-Boost +23 -0
- package/dist/lib/runtime-sources/vendor/ryu/common.h +114 -0
- package/dist/lib/runtime-sources/vendor/ryu/d2s.c +509 -0
- package/dist/lib/runtime-sources/vendor/ryu/d2s_full_table.h +367 -0
- package/dist/lib/runtime-sources/vendor/ryu/d2s_intrinsics.h +357 -0
- package/dist/lib/runtime-sources/vendor/ryu/d2s_small_table.h +186 -0
- package/dist/lib/runtime-sources/vendor/ryu/digit_table.h +35 -0
- package/dist/lib/runtime-sources/vendor/ryu/ryu.h +46 -0
- package/dist/lib/runtime-sources/vendor/unicode/LICENSE +39 -0
- package/dist/lib/runtime-sources/vendor/zlib/LICENSE +22 -0
- package/dist/lib/runtime-sources/vendor/zlib/adler32.c +164 -0
- package/dist/lib/runtime-sources/vendor/zlib/compress.c +75 -0
- package/dist/lib/runtime-sources/vendor/zlib/crc32.c +1049 -0
- package/dist/lib/runtime-sources/vendor/zlib/crc32.h +9446 -0
- package/dist/lib/runtime-sources/vendor/zlib/deflate.c +2139 -0
- package/dist/lib/runtime-sources/vendor/zlib/deflate.h +377 -0
- package/dist/lib/runtime-sources/vendor/zlib/gzclose.c +23 -0
- package/dist/lib/runtime-sources/vendor/zlib/gzguts.h +214 -0
- package/dist/lib/runtime-sources/vendor/zlib/gzlib.c +582 -0
- package/dist/lib/runtime-sources/vendor/zlib/gzread.c +602 -0
- package/dist/lib/runtime-sources/vendor/zlib/gzwrite.c +631 -0
- package/dist/lib/runtime-sources/vendor/zlib/infback.c +628 -0
- package/dist/lib/runtime-sources/vendor/zlib/inffast.c +320 -0
- package/dist/lib/runtime-sources/vendor/zlib/inffast.h +11 -0
- package/dist/lib/runtime-sources/vendor/zlib/inffixed.h +94 -0
- package/dist/lib/runtime-sources/vendor/zlib/inflate.c +1526 -0
- package/dist/lib/runtime-sources/vendor/zlib/inflate.h +126 -0
- package/dist/lib/runtime-sources/vendor/zlib/inftrees.c +299 -0
- package/dist/lib/runtime-sources/vendor/zlib/inftrees.h +62 -0
- package/dist/lib/runtime-sources/vendor/zlib/trees.c +1117 -0
- package/dist/lib/runtime-sources/vendor/zlib/trees.h +128 -0
- package/dist/lib/runtime-sources/vendor/zlib/uncompr.c +85 -0
- package/dist/lib/runtime-sources/vendor/zlib/zconf.h +543 -0
- package/dist/lib/runtime-sources/vendor/zlib/zlib.h +1938 -0
- package/dist/lib/runtime-sources/vendor/zlib/zutil.c +299 -0
- package/dist/lib/runtime-sources/vendor/zlib/zutil.h +254 -0
- package/dist/lib/scriptc-comptime +0 -0
- package/dist/lib/typescript/LICENSE +55 -0
- package/dist/lib/typescript/NOTICE.txt +436 -0
- package/dist/lib/typescript/lib/lib.d.ts +20 -0
- package/dist/lib/typescript/lib/lib.decorators.d.ts +382 -0
- package/dist/lib/typescript/lib/lib.decorators.legacy.d.ts +20 -0
- package/dist/lib/typescript/lib/lib.dom.asynciterable.d.ts +18 -0
- package/dist/lib/typescript/lib/lib.dom.d.ts +45125 -0
- package/dist/lib/typescript/lib/lib.dom.iterable.d.ts +18 -0
- package/dist/lib/typescript/lib/lib.es2015.collection.d.ts +159 -0
- package/dist/lib/typescript/lib/lib.es2015.core.d.ts +595 -0
- package/dist/lib/typescript/lib/lib.es2015.d.ts +26 -0
- package/dist/lib/typescript/lib/lib.es2015.generator.d.ts +75 -0
- package/dist/lib/typescript/lib/lib.es2015.iterable.d.ts +603 -0
- package/dist/lib/typescript/lib/lib.es2015.promise.d.ts +79 -0
- package/dist/lib/typescript/lib/lib.es2015.proxy.d.ts +126 -0
- package/dist/lib/typescript/lib/lib.es2015.reflect.d.ts +142 -0
- package/dist/lib/typescript/lib/lib.es2015.symbol.d.ts +44 -0
- package/dist/lib/typescript/lib/lib.es2015.symbol.wellknown.d.ts +324 -0
- package/dist/lib/typescript/lib/lib.es2016.array.include.d.ts +114 -0
- package/dist/lib/typescript/lib/lib.es2016.d.ts +19 -0
- package/dist/lib/typescript/lib/lib.es2016.full.d.ts +21 -0
- package/dist/lib/typescript/lib/lib.es2016.intl.d.ts +29 -0
- package/dist/lib/typescript/lib/lib.es2017.arraybuffer.d.ts +19 -0
- package/dist/lib/typescript/lib/lib.es2017.d.ts +24 -0
- package/dist/lib/typescript/lib/lib.es2017.date.d.ts +29 -0
- package/dist/lib/typescript/lib/lib.es2017.full.d.ts +21 -0
- package/dist/lib/typescript/lib/lib.es2017.intl.d.ts +42 -0
- package/dist/lib/typescript/lib/lib.es2017.object.d.ts +47 -0
- package/dist/lib/typescript/lib/lib.es2017.sharedmemory.d.ts +133 -0
- package/dist/lib/typescript/lib/lib.es2017.string.d.ts +47 -0
- package/dist/lib/typescript/lib/lib.es2017.typedarrays.d.ts +51 -0
- package/dist/lib/typescript/lib/lib.es2018.asyncgenerator.d.ts +75 -0
- package/dist/lib/typescript/lib/lib.es2018.asynciterable.d.ts +51 -0
- package/dist/lib/typescript/lib/lib.es2018.d.ts +22 -0
- package/dist/lib/typescript/lib/lib.es2018.full.d.ts +22 -0
- package/dist/lib/typescript/lib/lib.es2018.intl.d.ts +81 -0
- package/dist/lib/typescript/lib/lib.es2018.promise.d.ts +28 -0
- package/dist/lib/typescript/lib/lib.es2018.regexp.d.ts +35 -0
- package/dist/lib/typescript/lib/lib.es2019.array.d.ts +77 -0
- package/dist/lib/typescript/lib/lib.es2019.d.ts +22 -0
- package/dist/lib/typescript/lib/lib.es2019.full.d.ts +22 -0
- package/dist/lib/typescript/lib/lib.es2019.intl.d.ts +21 -0
- package/dist/lib/typescript/lib/lib.es2019.object.d.ts +31 -0
- package/dist/lib/typescript/lib/lib.es2019.string.d.ts +35 -0
- package/dist/lib/typescript/lib/lib.es2019.symbol.d.ts +22 -0
- package/dist/lib/typescript/lib/lib.es2020.bigint.d.ts +763 -0
- package/dist/lib/typescript/lib/lib.es2020.d.ts +25 -0
- package/dist/lib/typescript/lib/lib.es2020.date.d.ts +40 -0
- package/dist/lib/typescript/lib/lib.es2020.full.d.ts +22 -0
- package/dist/lib/typescript/lib/lib.es2020.intl.d.ts +472 -0
- package/dist/lib/typescript/lib/lib.es2020.number.d.ts +26 -0
- package/dist/lib/typescript/lib/lib.es2020.promise.d.ts +45 -0
- package/dist/lib/typescript/lib/lib.es2020.sharedmemory.d.ts +97 -0
- package/dist/lib/typescript/lib/lib.es2020.string.d.ts +42 -0
- package/dist/lib/typescript/lib/lib.es2020.symbol.wellknown.d.ts +39 -0
- package/dist/lib/typescript/lib/lib.es2021.d.ts +21 -0
- package/dist/lib/typescript/lib/lib.es2021.full.d.ts +22 -0
- package/dist/lib/typescript/lib/lib.es2021.intl.d.ts +164 -0
- package/dist/lib/typescript/lib/lib.es2021.promise.d.ts +46 -0
- package/dist/lib/typescript/lib/lib.es2021.string.d.ts +31 -0
- package/dist/lib/typescript/lib/lib.es2021.weakref.d.ts +76 -0
- package/dist/lib/typescript/lib/lib.es2022.array.d.ts +119 -0
- package/dist/lib/typescript/lib/lib.es2022.d.ts +23 -0
- package/dist/lib/typescript/lib/lib.es2022.error.d.ts +73 -0
- package/dist/lib/typescript/lib/lib.es2022.full.d.ts +22 -0
- package/dist/lib/typescript/lib/lib.es2022.intl.d.ts +143 -0
- package/dist/lib/typescript/lib/lib.es2022.object.d.ts +24 -0
- package/dist/lib/typescript/lib/lib.es2022.regexp.d.ts +37 -0
- package/dist/lib/typescript/lib/lib.es2022.string.d.ts +23 -0
- package/dist/lib/typescript/lib/lib.es2023.array.d.ts +922 -0
- package/dist/lib/typescript/lib/lib.es2023.collection.d.ts +19 -0
- package/dist/lib/typescript/lib/lib.es2023.d.ts +20 -0
- package/dist/lib/typescript/lib/lib.es2023.full.d.ts +22 -0
- package/dist/lib/typescript/lib/lib.es2023.intl.d.ts +62 -0
- package/dist/lib/typescript/lib/lib.es2024.arraybuffer.d.ts +63 -0
- package/dist/lib/typescript/lib/lib.es2024.collection.d.ts +27 -0
- package/dist/lib/typescript/lib/lib.es2024.d.ts +24 -0
- package/dist/lib/typescript/lib/lib.es2024.full.d.ts +22 -0
- package/dist/lib/typescript/lib/lib.es2024.object.d.ts +27 -0
- package/dist/lib/typescript/lib/lib.es2024.promise.d.ts +33 -0
- package/dist/lib/typescript/lib/lib.es2024.regexp.d.ts +23 -0
- package/dist/lib/typescript/lib/lib.es2024.sharedmemory.d.ts +66 -0
- package/dist/lib/typescript/lib/lib.es2024.string.d.ts +27 -0
- package/dist/lib/typescript/lib/lib.es2025.collection.d.ts +94 -0
- package/dist/lib/typescript/lib/lib.es2025.d.ts +23 -0
- package/dist/lib/typescript/lib/lib.es2025.float16.d.ts +443 -0
- package/dist/lib/typescript/lib/lib.es2025.full.d.ts +22 -0
- package/dist/lib/typescript/lib/lib.es2025.intl.d.ts +200 -0
- package/dist/lib/typescript/lib/lib.es2025.iterator.d.ts +146 -0
- package/dist/lib/typescript/lib/lib.es2025.promise.d.ts +32 -0
- package/dist/lib/typescript/lib/lib.es2025.regexp.d.ts +30 -0
- package/dist/lib/typescript/lib/lib.es5.d.ts +4599 -0
- package/dist/lib/typescript/lib/lib.es6.d.ts +21 -0
- package/dist/lib/typescript/lib/lib.esnext.array.d.ts +33 -0
- package/dist/lib/typescript/lib/lib.esnext.collection.d.ts +47 -0
- package/dist/lib/typescript/lib/lib.esnext.d.ts +27 -0
- package/dist/lib/typescript/lib/lib.esnext.date.d.ts +21 -0
- package/dist/lib/typescript/lib/lib.esnext.decorators.d.ts +26 -0
- package/dist/lib/typescript/lib/lib.esnext.disposable.d.ts +191 -0
- package/dist/lib/typescript/lib/lib.esnext.error.d.ts +22 -0
- package/dist/lib/typescript/lib/lib.esnext.full.d.ts +22 -0
- package/dist/lib/typescript/lib/lib.esnext.intl.d.ts +107 -0
- package/dist/lib/typescript/lib/lib.esnext.sharedmemory.d.ts +23 -0
- package/dist/lib/typescript/lib/lib.esnext.temporal.d.ts +485 -0
- package/dist/lib/typescript/lib/lib.esnext.typedarrays.d.ts +90 -0
- package/dist/lib/typescript/lib/lib.scripthost.d.ts +320 -0
- package/dist/lib/typescript/lib/lib.webworker.asynciterable.d.ts +18 -0
- package/dist/lib/typescript/lib/lib.webworker.d.ts +15606 -0
- package/dist/lib/typescript/lib/lib.webworker.importscripts.d.ts +21 -0
- package/dist/lib/typescript/lib/lib.webworker.iterable.d.ts +18 -0
- package/dist/lib/typescript/lib/tsc +0 -0
- package/dist/lib/typescript/package.json +45 -0
- package/dist/lib/wasi/cli/wasi-paths.js +41 -0
- package/dist/lib/wasi/cli/wasi-runner.js +28 -0
- package/dist/lib/wasi/package.json +1 -0
- package/dist/lib/wasi/wasi-paths.js +25 -0
- package/package.json +22 -6
- package/README.md +0 -3
- package/index.js +0 -2
|
@@ -0,0 +1,2518 @@
|
|
|
1
|
+
/* Typed arrays / Buffer: ONE runtime representation (ScrBytes — see the
|
|
2
|
+
* header contract). An ScrBytes either OWNS its storage or is a VIEW into
|
|
3
|
+
* an owner's (backing set, chain depth exactly 1): DataView, subarray(),
|
|
4
|
+
* and Buffer's slice() all alias JS-exactly; only the plain typed arrays'
|
|
5
|
+
* slice() copies. Coercions are JS-exact
|
|
6
|
+
* (ToUint8/ToUint32 modular truncation, double→float rounding); the
|
|
7
|
+
* encoding conversions (utf8 with WHATWG replacement, hex, base64) match
|
|
8
|
+
* Node byte-for-byte — the differential corpus holds them to it. */
|
|
9
|
+
#include "scr_runtime.h"
|
|
10
|
+
#ifdef SCR_TEXT_DECODER_LEGACY
|
|
11
|
+
#include "scr_text_decoder_data.h"
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
#include <math.h>
|
|
15
|
+
#include <stdio.h>
|
|
16
|
+
#include <stdlib.h>
|
|
17
|
+
#include <string.h>
|
|
18
|
+
|
|
19
|
+
#ifdef SCR_RC_AUDIT
|
|
20
|
+
static SCR_TL long scr_live_bytes = 0;
|
|
21
|
+
long scr_bytes_live_count(void) { return scr_live_bytes; }
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
static void scr_bytes_oom(void) {
|
|
25
|
+
scr_trap("scriptc: out of memory\n");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
size_t scr_bytes_elem_size(ScrBytesElem elem) {
|
|
29
|
+
switch (elem) {
|
|
30
|
+
case SCR_BYTES_U8: case SCR_BYTES_U8C: case SCR_BYTES_I8: return 1;
|
|
31
|
+
case SCR_BYTES_U16: case SCR_BYTES_I16: return 2;
|
|
32
|
+
case SCR_BYTES_U32: case SCR_BYTES_I32: case SCR_BYTES_F32: return 4;
|
|
33
|
+
case SCR_BYTES_F64: return 8;
|
|
34
|
+
}
|
|
35
|
+
scr_trap("scriptc: invalid typed array element kind\n");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const char *scr_bytes_elem_name(ScrBytesElem elem) {
|
|
39
|
+
switch (elem) {
|
|
40
|
+
case SCR_BYTES_U8: return "Uint8Array";
|
|
41
|
+
case SCR_BYTES_U8C: return "Uint8ClampedArray";
|
|
42
|
+
case SCR_BYTES_I8: return "Int8Array";
|
|
43
|
+
case SCR_BYTES_U16: return "Uint16Array";
|
|
44
|
+
case SCR_BYTES_I16: return "Int16Array";
|
|
45
|
+
case SCR_BYTES_U32: return "Uint32Array";
|
|
46
|
+
case SCR_BYTES_I32: return "Int32Array";
|
|
47
|
+
case SCR_BYTES_F32: return "Float32Array";
|
|
48
|
+
case SCR_BYTES_F64: return "Float64Array";
|
|
49
|
+
}
|
|
50
|
+
scr_trap("scriptc: invalid typed array element kind\n");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
double scr_bytes_to_u8_clamp(double value) {
|
|
54
|
+
if (!(value > 0)) return 0;
|
|
55
|
+
if (value >= 255) return 255;
|
|
56
|
+
double lower = floor(value);
|
|
57
|
+
double fraction = value - lower;
|
|
58
|
+
return fraction > 0.5 || (fraction == 0.5 && ((unsigned)lower & 1)) ? lower + 1 : lower;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* ── lifecycle ─────────────────────────────────────────────────────────── */
|
|
62
|
+
|
|
63
|
+
static ScrBytes *scr_bytes_alloc(ScrBytesElem elem, size_t len) {
|
|
64
|
+
ScrBytes *b = malloc(sizeof(ScrBytes));
|
|
65
|
+
if (!b) scr_bytes_oom();
|
|
66
|
+
b->rc = 1;
|
|
67
|
+
b->len = len;
|
|
68
|
+
b->elem = elem;
|
|
69
|
+
b->data = calloc(len ? len : 1, scr_bytes_elem_size(elem));
|
|
70
|
+
if (!b->data) scr_bytes_oom();
|
|
71
|
+
b->backing = NULL;
|
|
72
|
+
b->is_buffer = false;
|
|
73
|
+
b->external = false;
|
|
74
|
+
#ifdef SCR_RC_AUDIT
|
|
75
|
+
scr_live_bytes++;
|
|
76
|
+
#endif
|
|
77
|
+
return b;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
ScrBytes *scr_bytes_from_external(void *data, size_t length) {
|
|
81
|
+
ScrBytes *b = scr_bytes_alloc(SCR_BYTES_U8, 0);
|
|
82
|
+
/* Keep the owned empty allocation for NULL/zero-length views: existing
|
|
83
|
+
* view operations may add zero to the data pointer. */
|
|
84
|
+
if (data) {
|
|
85
|
+
free(b->data);
|
|
86
|
+
b->data = data;
|
|
87
|
+
b->external = true;
|
|
88
|
+
}
|
|
89
|
+
b->len = length;
|
|
90
|
+
return b;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
ScrBytes *scr_bytes_new(ScrBytesElem elem, double n) {
|
|
94
|
+
/* ToIndex: NaN → 0, truncate toward zero; a negative or > 2^53-1 result
|
|
95
|
+
* throws Node's RangeError ("Invalid typed array length: -1"). A
|
|
96
|
+
* fractional 3.5 is length 3 — ToIndex never compares back. */
|
|
97
|
+
double t = (n != n) ? 0 : trunc(n);
|
|
98
|
+
if (!(t >= 0) || t > 9007199254740991.0 || t > (double)(SIZE_MAX / 8)) {
|
|
99
|
+
char num[32];
|
|
100
|
+
size_t numlen = scr_f64_to_str(t, num);
|
|
101
|
+
char msg[80];
|
|
102
|
+
int mlen = snprintf(msg, sizeof msg, "Invalid typed array length: %.*s",
|
|
103
|
+
(int)numlen, num);
|
|
104
|
+
scr_throw_error_msg(SCR_ERR_RANGE, msg, (size_t)mlen);
|
|
105
|
+
return NULL;
|
|
106
|
+
}
|
|
107
|
+
return scr_bytes_alloc(elem, (size_t)t);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
ScrBytes *scr_bytes_from_data(const uint8_t *data, size_t len) {
|
|
111
|
+
if (data == NULL && len != 0) {
|
|
112
|
+
scr_trap("scriptc: native callback passed a NULL span with nonzero length\n");
|
|
113
|
+
}
|
|
114
|
+
ScrBytes *b = scr_bytes_alloc(SCR_BYTES_U8, len);
|
|
115
|
+
if (len != 0) memcpy(b->data, data, len);
|
|
116
|
+
return b;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
ScrBytes *scr_bytes_copy(const ScrBytes *src) {
|
|
120
|
+
ScrBytes *b = scr_bytes_alloc(src->elem, src->len);
|
|
121
|
+
memcpy(b->data, src->data, src->len * scr_bytes_elem_size(src->elem));
|
|
122
|
+
return b;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
ScrBytes *scr_bytes_raw_view(ScrBytes *bytes) {
|
|
126
|
+
if (bytes->elem == SCR_BYTES_U8) return scr_bytes_retain(bytes);
|
|
127
|
+
return scr_dataview_new(bytes, scr_bytes_byte_offset(bytes), true, scr_bytes_byte_len(bytes));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
ScrBytes *scr_bytes_as_buffer(ScrBytes *bytes) {
|
|
131
|
+
bytes->is_buffer = true;
|
|
132
|
+
return scr_bytes_retain(bytes);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
ScrBytes *scr_bytes_convert(ScrBytesElem elem, const ScrBytes *src) {
|
|
136
|
+
if (elem == src->elem) return scr_bytes_copy(src);
|
|
137
|
+
ScrBytes *out = scr_bytes_alloc(elem, src->len);
|
|
138
|
+
for (size_t i = 0; i < src->len; i++) scr_bytes_set(out, (double)i, scr_bytes_get(src, (double)i));
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
void scr_bytes_release(ScrBytes *b) {
|
|
143
|
+
if (!b || b->rc == SIZE_MAX) return; /* NULL: an uninitialized `let` local */
|
|
144
|
+
if (--b->rc == 0) {
|
|
145
|
+
scr_weak_dispose(b);
|
|
146
|
+
if (b->backing) {
|
|
147
|
+
scr_bytes_release(b->backing); /* a view: data points into the owner */
|
|
148
|
+
} else if (!b->external) {
|
|
149
|
+
free(b->data);
|
|
150
|
+
}
|
|
151
|
+
#ifdef SCR_RC_AUDIT
|
|
152
|
+
scr_live_bytes--;
|
|
153
|
+
#endif
|
|
154
|
+
free(b);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
void *scr_bytes_retain_v(void *b) { return scr_bytes_retain((ScrBytes *)b); }
|
|
159
|
+
void scr_bytes_release_v(void *b) { scr_bytes_release((ScrBytes *)b); }
|
|
160
|
+
|
|
161
|
+
double scr_bytes_len(const ScrBytes *b) { return (double)b->len; }
|
|
162
|
+
|
|
163
|
+
void scr_bytes_copy_contents(ScrBytes *dst, const ScrBytes *src) {
|
|
164
|
+
if (dst->elem != src->elem || dst->len != src->len) {
|
|
165
|
+
scr_trap("scriptc: typed array snapshot shape changed\n");
|
|
166
|
+
}
|
|
167
|
+
memcpy(dst->data, src->data, dst->len * scr_bytes_elem_size(dst->elem));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
double scr_bytes_byte_len(const ScrBytes *b) {
|
|
171
|
+
return (double)(b->len * scr_bytes_elem_size(b->elem));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/* ── element access ────────────────────────────────────────────────────
|
|
175
|
+
* JS reads undefined and IGNORES writes out of bounds on typed arrays;
|
|
176
|
+
* both are unrepresentable here, so any invalid index traps — the array
|
|
177
|
+
* runtime's exact discipline (SEMANTICS.md). */
|
|
178
|
+
|
|
179
|
+
static size_t scr_bytes_check_index(const ScrBytes *b, double i) {
|
|
180
|
+
if (!(i >= 0) || i != trunc(i) || i >= (double)b->len) {
|
|
181
|
+
char buf[32];
|
|
182
|
+
scr_f64_to_str(i, buf);
|
|
183
|
+
scr_trap_fmt("scriptc: RangeError: typed array index %s out of bounds (length %zu)\n",
|
|
184
|
+
buf, b->len);
|
|
185
|
+
}
|
|
186
|
+
return (size_t)i;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/* ToUint32: NaN/±Infinity → 0, truncate toward zero, wrap mod 2^32.
|
|
190
|
+
* ToUint8 is its low byte (2^8 divides 2^32, so the residues agree). */
|
|
191
|
+
static uint32_t scr_bytes_to_u32(double v) {
|
|
192
|
+
if (v != v || isinf(v)) return 0;
|
|
193
|
+
double t = trunc(v);
|
|
194
|
+
t = fmod(t, 4294967296.0);
|
|
195
|
+
if (t < 0) t += 4294967296.0;
|
|
196
|
+
return (uint32_t)t;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
double scr_bytes_get(const ScrBytes *b, double i) {
|
|
200
|
+
size_t idx = scr_bytes_check_index(b, i);
|
|
201
|
+
switch (b->elem) {
|
|
202
|
+
case SCR_BYTES_U8: case SCR_BYTES_U8C:
|
|
203
|
+
return (double)b->data[idx];
|
|
204
|
+
case SCR_BYTES_I8: {
|
|
205
|
+
int8_t v;
|
|
206
|
+
memcpy(&v, b->data + idx, 1);
|
|
207
|
+
return (double)v;
|
|
208
|
+
}
|
|
209
|
+
case SCR_BYTES_U16: {
|
|
210
|
+
uint16_t v;
|
|
211
|
+
memcpy(&v, b->data + idx * 2, 2);
|
|
212
|
+
return (double)v;
|
|
213
|
+
}
|
|
214
|
+
case SCR_BYTES_I16: {
|
|
215
|
+
int16_t v;
|
|
216
|
+
memcpy(&v, b->data + idx * 2, 2);
|
|
217
|
+
return (double)v;
|
|
218
|
+
}
|
|
219
|
+
case SCR_BYTES_U32: {
|
|
220
|
+
uint32_t v;
|
|
221
|
+
memcpy(&v, b->data + idx * 4, 4);
|
|
222
|
+
return (double)v;
|
|
223
|
+
}
|
|
224
|
+
case SCR_BYTES_F32: {
|
|
225
|
+
float v;
|
|
226
|
+
memcpy(&v, b->data + idx * 4, 4);
|
|
227
|
+
return (double)v;
|
|
228
|
+
}
|
|
229
|
+
case SCR_BYTES_F64: {
|
|
230
|
+
double v;
|
|
231
|
+
memcpy(&v, b->data + idx * 8, 8);
|
|
232
|
+
return v;
|
|
233
|
+
}
|
|
234
|
+
case SCR_BYTES_I32: {
|
|
235
|
+
int32_t v;
|
|
236
|
+
memcpy(&v, b->data + idx * 4, 4);
|
|
237
|
+
return (double)v;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return 0; /* unreachable */
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
void scr_bytes_set(ScrBytes *b, double i, double v) {
|
|
244
|
+
size_t idx = scr_bytes_check_index(b, i);
|
|
245
|
+
switch (b->elem) {
|
|
246
|
+
case SCR_BYTES_U8: case SCR_BYTES_I8:
|
|
247
|
+
b->data[idx] = (uint8_t)scr_bytes_to_u32(v);
|
|
248
|
+
break;
|
|
249
|
+
case SCR_BYTES_U8C:
|
|
250
|
+
b->data[idx] = (uint8_t)scr_bytes_to_u8_clamp(v);
|
|
251
|
+
break;
|
|
252
|
+
case SCR_BYTES_U16: case SCR_BYTES_I16: {
|
|
253
|
+
uint16_t u = (uint16_t)scr_bytes_to_u32(v);
|
|
254
|
+
memcpy(b->data + idx * 2, &u, 2);
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
case SCR_BYTES_U32: {
|
|
258
|
+
uint32_t u = scr_bytes_to_u32(v);
|
|
259
|
+
memcpy(b->data + idx * 4, &u, 4);
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
case SCR_BYTES_F32: {
|
|
263
|
+
float f = (float)v; /* round-to-nearest-even, exactly Float32Array */
|
|
264
|
+
memcpy(b->data + idx * 4, &f, 4);
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
case SCR_BYTES_F64:
|
|
268
|
+
memcpy(b->data + idx * 8, &v, 8);
|
|
269
|
+
break;
|
|
270
|
+
case SCR_BYTES_I32: {
|
|
271
|
+
/* ToInt32 is ToUint32 reinterpreted signed (same 2^32 residue). */
|
|
272
|
+
uint32_t u = scr_bytes_to_u32(v);
|
|
273
|
+
int32_t s;
|
|
274
|
+
memcpy(&s, &u, 4);
|
|
275
|
+
memcpy(b->data + idx * 4, &s, 4);
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/* ── slice (copy) / subarray (view) ────────────────────────────────────── */
|
|
282
|
+
|
|
283
|
+
/* Relative index: ToIntegerOrInfinity, negatives from the end, clamped. */
|
|
284
|
+
static size_t scr_bytes_rel_index(double i, size_t len) {
|
|
285
|
+
if (i != i) return 0;
|
|
286
|
+
double t = trunc(i);
|
|
287
|
+
if (t < 0) t += (double)len;
|
|
288
|
+
if (t < 0) return 0;
|
|
289
|
+
if (t > (double)len) return len;
|
|
290
|
+
return (size_t)t;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
ScrBytes *scr_bytes_slice(const ScrBytes *b, double start, double end) {
|
|
294
|
+
size_t s = scr_bytes_rel_index(start, b->len);
|
|
295
|
+
size_t e = scr_bytes_rel_index(end, b->len);
|
|
296
|
+
size_t count = e > s ? e - s : 0;
|
|
297
|
+
size_t esize = scr_bytes_elem_size(b->elem);
|
|
298
|
+
ScrBytes *out = scr_bytes_alloc(b->elem, count);
|
|
299
|
+
memcpy(out->data, b->data + s * esize, count * esize);
|
|
300
|
+
return out;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
ScrBytes *scr_bytes_copy_within(ScrBytes *b, double target, double start, double end) {
|
|
304
|
+
size_t t = scr_bytes_rel_index(target, b->len);
|
|
305
|
+
size_t s = scr_bytes_rel_index(start, b->len);
|
|
306
|
+
size_t e = scr_bytes_rel_index(end, b->len);
|
|
307
|
+
size_t count = e > s ? e - s : 0;
|
|
308
|
+
if (count > b->len - t) count = b->len - t;
|
|
309
|
+
size_t width = scr_bytes_elem_size(b->elem);
|
|
310
|
+
memmove(b->data + t * width, b->data + s * width, count * width);
|
|
311
|
+
return scr_bytes_retain(b);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/* TypedArray.prototype.fill on non-u8 receivers: per-ELEMENT fill with
|
|
315
|
+
* the element write's JS-exact coercion (ToUint32/ToInt32 wrap, f32
|
|
316
|
+
* rounding), slice-clamped relative indices; answers the receiver +1
|
|
317
|
+
* (chaining). Never throws — Buffer's throwing fill family is separate. */
|
|
318
|
+
ScrBytes *scr_bytes_fill_elem(ScrBytes *b, double v, double start, double end) {
|
|
319
|
+
size_t s = scr_bytes_rel_index(start, b->len);
|
|
320
|
+
size_t e = scr_bytes_rel_index(end, b->len);
|
|
321
|
+
for (size_t i = s; i < e; i++) scr_bytes_set(b, (double)i, v);
|
|
322
|
+
return scr_bytes_retain(b);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/* subarray(start, end): a same-elem VIEW over the receiver's storage —
|
|
326
|
+
* TypedArray.prototype.subarray and Buffer's slice()/subarray() all alias
|
|
327
|
+
* in JS (mutations are visible both ways; buffer-swap through a slice is
|
|
328
|
+
* the canonical Node use). Chain depth stays exactly 1: a subarray of a
|
|
329
|
+
* view retains the OWNER, offsets composed here (the DataView rule).
|
|
330
|
+
* Relative indices clamp like slice; never throws. */
|
|
331
|
+
ScrBytes *scr_bytes_subarray(ScrBytes *b, double start, double end) {
|
|
332
|
+
size_t s = scr_bytes_rel_index(start, b->len);
|
|
333
|
+
size_t e = scr_bytes_rel_index(end, b->len);
|
|
334
|
+
size_t count = e > s ? e - s : 0;
|
|
335
|
+
ScrBytes *owner = b->backing ? b->backing : b;
|
|
336
|
+
ScrBytes *v = malloc(sizeof(ScrBytes));
|
|
337
|
+
if (!v) scr_bytes_oom();
|
|
338
|
+
v->rc = 1;
|
|
339
|
+
v->len = count;
|
|
340
|
+
v->elem = b->elem;
|
|
341
|
+
v->data = b->data + s * scr_bytes_elem_size(b->elem);
|
|
342
|
+
v->backing = scr_bytes_retain(owner);
|
|
343
|
+
v->is_buffer = b->is_buffer;
|
|
344
|
+
v->external = false;
|
|
345
|
+
#ifdef SCR_RC_AUDIT
|
|
346
|
+
scr_live_bytes++;
|
|
347
|
+
#endif
|
|
348
|
+
return v;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
void scr_bytes_set_from(ScrBytes *dst, const ScrBytes *src, double offset) {
|
|
352
|
+
double t = (offset != offset) ? 0 : trunc(offset);
|
|
353
|
+
if (!(t >= 0) || (double)src->len + t > (double)dst->len) {
|
|
354
|
+
static const char msg[] = "offset is out of bounds";
|
|
355
|
+
scr_throw_error_msg(SCR_ERR_RANGE, msg, sizeof msg - 1);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
if (dst->elem != src->elem) {
|
|
359
|
+
// Snapshot before writing: views can overlap even with distinct kinds.
|
|
360
|
+
ScrBytes *copy = scr_bytes_convert(dst->elem, src);
|
|
361
|
+
memcpy(dst->data + (size_t)t * scr_bytes_elem_size(dst->elem), copy->data,
|
|
362
|
+
copy->len * scr_bytes_elem_size(copy->elem));
|
|
363
|
+
scr_bytes_release(copy);
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
size_t esize = scr_bytes_elem_size(dst->elem);
|
|
367
|
+
memmove(dst->data + (size_t)t * esize, src->data, src->len * esize);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/* Checked-native array-like sources. Runtime objects with an unsupported
|
|
371
|
+
* prototype/iterator keep a catchable refusal instead of losing hooks. */
|
|
372
|
+
static bool scr_bytes_source_refusal(void) {
|
|
373
|
+
static const char msg[] = "typed-array conversion of an opaque reference is not supported yet";
|
|
374
|
+
scr_throw_error_msg(SCR_ERR_ERROR, msg, sizeof msg - 1);
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
static bool scr_bytes_source_length(const ScrDyn *value, double *length) {
|
|
379
|
+
switch (value->kind) {
|
|
380
|
+
case SCR_DYN_ARR: *length = (double)value->v.arr.len; return true;
|
|
381
|
+
case SCR_DYN_STR: *length = scr_str_utf16_len(value->v.str); return true;
|
|
382
|
+
case SCR_DYN_OBJ: {
|
|
383
|
+
ScrDyn *v = scr_dyn_obj_read(value, "length", 6);
|
|
384
|
+
if (!v) return false;
|
|
385
|
+
double n;
|
|
386
|
+
bool ok = scr_dyn_number_coerce_js(v, &n);
|
|
387
|
+
scr_dyn_release(v);
|
|
388
|
+
if (!ok) return false;
|
|
389
|
+
*length = !(n > 0) ? 0 : fmin(floor(n), 9007199254740991.0);
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
392
|
+
case SCR_DYN_NULL:
|
|
393
|
+
case SCR_DYN_UNDEF: {
|
|
394
|
+
static const char msg[] = "Cannot convert undefined or null to object";
|
|
395
|
+
scr_throw_error_msg(SCR_ERR_TYPE, msg, sizeof msg - 1);
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
case SCR_DYN_NUM:
|
|
399
|
+
case SCR_DYN_BOOL: *length = 0; return true;
|
|
400
|
+
default: return scr_bytes_source_refusal();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
static ScrDyn *scr_bytes_source_at(const ScrDyn *value, size_t i) {
|
|
405
|
+
if (value->kind == SCR_DYN_ARR) return scr_dyn_arr_at(value, (double)i);
|
|
406
|
+
if (value->kind == SCR_DYN_STR) {
|
|
407
|
+
ScrStr *s = scr_str_char_at(value->v.str, (double)i);
|
|
408
|
+
ScrDyn *out = scr_dyn_new_str(s);
|
|
409
|
+
scr_str_release(s);
|
|
410
|
+
return out;
|
|
411
|
+
}
|
|
412
|
+
char key[32];
|
|
413
|
+
int n = snprintf(key, sizeof key, "%zu", i);
|
|
414
|
+
return scr_dyn_obj_read(value, key, (size_t)n);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
static bool scr_bytes_copy_array_like(ScrBytes *dst, const ScrDyn *src, size_t offset, size_t count) {
|
|
418
|
+
for (size_t i = 0; i < count; i++) {
|
|
419
|
+
ScrDyn *value = scr_bytes_source_at(src, i);
|
|
420
|
+
if (!value) return false;
|
|
421
|
+
double number;
|
|
422
|
+
bool ok = scr_dyn_number_coerce_js(value, &number);
|
|
423
|
+
scr_dyn_release(value);
|
|
424
|
+
if (!ok) return false;
|
|
425
|
+
scr_bytes_set(dst, (double)(offset + i), number);
|
|
426
|
+
}
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
ScrBytes *scr_bytes_from_dyn(ScrBytesElem elem, const ScrDyn *value, bool from) {
|
|
431
|
+
if (from && (value->kind == SCR_DYN_NULL || value->kind == SCR_DYN_UNDEF)) {
|
|
432
|
+
const char *msg = value->kind == SCR_DYN_NULL
|
|
433
|
+
? "object null is not iterable (cannot read property Symbol(Symbol.iterator))"
|
|
434
|
+
: "undefined is not iterable (cannot read property Symbol(Symbol.iterator))";
|
|
435
|
+
scr_throw_error_msg(SCR_ERR_TYPE, msg, strlen(msg));
|
|
436
|
+
return NULL;
|
|
437
|
+
}
|
|
438
|
+
if (value->kind == SCR_DYN_TYPED_REF) {
|
|
439
|
+
ScrDyn *view = scr_dyn_typed_ref_materialize(value);
|
|
440
|
+
// Class snapshots omit prototypes, so do not interpret them as plain objects.
|
|
441
|
+
ScrBytes *out = NULL;
|
|
442
|
+
if (view->kind == SCR_DYN_BYTES || view->kind == SCR_DYN_ARR) out = scr_bytes_from_dyn(elem, view, from);
|
|
443
|
+
else scr_bytes_source_refusal();
|
|
444
|
+
scr_dyn_release(view);
|
|
445
|
+
return out;
|
|
446
|
+
}
|
|
447
|
+
if (value->kind == SCR_DYN_BYTES) return scr_bytes_convert(elem, value->v.bytes);
|
|
448
|
+
if (!from && scr_array_buffer_is(value)) return scr_array_buffer_view(elem, value, scr_dyn_undefined(), scr_dyn_undefined());
|
|
449
|
+
if (!from && (value->kind == SCR_DYN_NUM || value->kind == SCR_DYN_BOOL ||
|
|
450
|
+
value->kind == SCR_DYN_STR || value->kind == SCR_DYN_NULL || value->kind == SCR_DYN_UNDEF)) {
|
|
451
|
+
double number;
|
|
452
|
+
if (!scr_dyn_number_coerce_js(value, &number)) return NULL;
|
|
453
|
+
return scr_bytes_new(elem, number);
|
|
454
|
+
}
|
|
455
|
+
// Constructors drain array iterators before element coercion. Node's .from
|
|
456
|
+
// fast path reads ordinary array elements during conversion instead. Strings
|
|
457
|
+
// supplied to .from iterate by code point (set reads UTF-16 code units).
|
|
458
|
+
if ((!from && value->kind == SCR_DYN_ARR) || (from && value->kind == SCR_DYN_STR)) {
|
|
459
|
+
ScrDyn *items = scr_dyn_iter_pack(value, NULL);
|
|
460
|
+
if (!items) return NULL;
|
|
461
|
+
ScrBytes *out = scr_bytes_new(elem, (double)items->v.arr.len);
|
|
462
|
+
if (out && !scr_bytes_copy_array_like(out, items, 0, out->len)) {
|
|
463
|
+
scr_bytes_release(out);
|
|
464
|
+
out = NULL;
|
|
465
|
+
}
|
|
466
|
+
scr_dyn_release(items);
|
|
467
|
+
return out;
|
|
468
|
+
}
|
|
469
|
+
double length;
|
|
470
|
+
if (!scr_bytes_source_length(value, &length)) return NULL;
|
|
471
|
+
if (length >= 9007199254740991.0 || length >= (double)(SIZE_MAX / scr_bytes_elem_size(elem))) {
|
|
472
|
+
static const char msg[] = "Array buffer allocation failed";
|
|
473
|
+
scr_throw_error_msg(SCR_ERR_RANGE, msg, sizeof msg - 1);
|
|
474
|
+
return NULL;
|
|
475
|
+
}
|
|
476
|
+
ScrBytes *out = scr_bytes_new(elem, length);
|
|
477
|
+
if (out && !scr_bytes_copy_array_like(out, value, 0, out->len)) {
|
|
478
|
+
scr_bytes_release(out);
|
|
479
|
+
return NULL;
|
|
480
|
+
}
|
|
481
|
+
return out;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
void scr_bytes_set_from_dyn(ScrBytes *dst, const ScrDyn *src, double offset) {
|
|
485
|
+
double t = isnan(offset) ? 0 : trunc(offset);
|
|
486
|
+
if (!(t >= 0)) {
|
|
487
|
+
static const char msg[] = "offset is out of bounds";
|
|
488
|
+
scr_throw_error_msg(SCR_ERR_RANGE, msg, sizeof msg - 1);
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
if (src->kind == SCR_DYN_TYPED_REF) {
|
|
492
|
+
ScrDyn *view = scr_dyn_typed_ref_materialize(src);
|
|
493
|
+
if (view->kind == SCR_DYN_BYTES || view->kind == SCR_DYN_ARR) scr_bytes_set_from_dyn(dst, view, t);
|
|
494
|
+
else scr_bytes_source_refusal();
|
|
495
|
+
scr_dyn_release(view);
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
if (src->kind == SCR_DYN_BYTES) {
|
|
499
|
+
scr_bytes_set_from(dst, src->v.bytes, t);
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
double length;
|
|
503
|
+
if (!scr_bytes_source_length(src, &length)) return;
|
|
504
|
+
if (t > (double)dst->len || length > (double)dst->len - t) {
|
|
505
|
+
static const char msg[] = "offset is out of bounds";
|
|
506
|
+
scr_throw_error_msg(SCR_ERR_RANGE, msg, sizeof msg - 1);
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
scr_bytes_copy_array_like(dst, src, (size_t)t, (size_t)length);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/* ── DataView (the ONE view kind — see the header contract) ────────────── */
|
|
513
|
+
|
|
514
|
+
double scr_bytes_byte_offset(const ScrBytes *b) {
|
|
515
|
+
return b->backing ? (double)(size_t)(b->data - b->backing->data) : 0;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
ScrBytes *scr_dataview_new(ScrBytes *src, double byte_off, bool has_len, double byte_len) {
|
|
519
|
+
/* `x.buffer` names the ONE buffer behind x — for a view src that is its
|
|
520
|
+
* owner's storage, so indices stay buffer-relative exactly like JS. */
|
|
521
|
+
ScrBytes *owner = src->backing ? src->backing : src;
|
|
522
|
+
double buf_bytes = (double)(owner->len * scr_bytes_elem_size(owner->elem));
|
|
523
|
+
/* ToIndex on the offset; every bad value takes Node's ONE message
|
|
524
|
+
* (negative, > 2^53-1, Infinity, and past-the-end alike). */
|
|
525
|
+
double off = (byte_off != byte_off) ? 0 : trunc(byte_off);
|
|
526
|
+
if (!(off >= 0) || off > 9007199254740991.0 || off > buf_bytes) {
|
|
527
|
+
char num[32];
|
|
528
|
+
size_t numlen = scr_f64_to_str(off, num);
|
|
529
|
+
char msg[96];
|
|
530
|
+
int mlen = snprintf(msg, sizeof msg, "Start offset %.*s is outside the bounds of the buffer",
|
|
531
|
+
(int)numlen, num);
|
|
532
|
+
scr_throw_error_msg(SCR_ERR_RANGE, msg, (size_t)mlen);
|
|
533
|
+
return NULL;
|
|
534
|
+
}
|
|
535
|
+
double len;
|
|
536
|
+
if (has_len) {
|
|
537
|
+
len = (byte_len != byte_len) ? 0 : trunc(byte_len);
|
|
538
|
+
if (!(len >= 0) || len > 9007199254740991.0 || off + len > buf_bytes) {
|
|
539
|
+
char num[32];
|
|
540
|
+
size_t numlen = scr_f64_to_str(len, num);
|
|
541
|
+
char msg[64];
|
|
542
|
+
int mlen = snprintf(msg, sizeof msg, "Invalid DataView length %.*s", (int)numlen, num);
|
|
543
|
+
scr_throw_error_msg(SCR_ERR_RANGE, msg, (size_t)mlen);
|
|
544
|
+
return NULL;
|
|
545
|
+
}
|
|
546
|
+
} else {
|
|
547
|
+
len = buf_bytes - off;
|
|
548
|
+
}
|
|
549
|
+
ScrBytes *v = malloc(sizeof(ScrBytes));
|
|
550
|
+
if (!v) scr_bytes_oom();
|
|
551
|
+
v->rc = 1;
|
|
552
|
+
v->len = (size_t)len; /* elem u8 — len IS the byte length */
|
|
553
|
+
v->elem = SCR_BYTES_U8;
|
|
554
|
+
v->data = owner->data + (size_t)off;
|
|
555
|
+
v->backing = scr_bytes_retain(owner);
|
|
556
|
+
v->is_buffer = false;
|
|
557
|
+
v->external = false;
|
|
558
|
+
#ifdef SCR_RC_AUDIT
|
|
559
|
+
scr_live_bytes++;
|
|
560
|
+
#endif
|
|
561
|
+
return v;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
ScrBytes *scr_bytes_buffer_view(ScrBytes *src, ScrBytesElem elem,
|
|
565
|
+
double offset, bool has_len, double length) {
|
|
566
|
+
ScrBytes *owner = src->backing ? src->backing : src;
|
|
567
|
+
size_t width = scr_bytes_elem_size(elem);
|
|
568
|
+
double available = scr_bytes_byte_len(owner);
|
|
569
|
+
double off = isnan(offset) ? 0 : trunc(offset);
|
|
570
|
+
double count = isnan(length) ? 0 : trunc(length);
|
|
571
|
+
if (off < 0 || off > 9007199254740991.0 || off > available ||
|
|
572
|
+
fmod(off, (double)width) != 0 ||
|
|
573
|
+
(has_len && (count < 0 || count > 9007199254740991.0 || count > (available - off) / (double)width)) ||
|
|
574
|
+
(!has_len && fmod(available - off, (double)width) != 0)) {
|
|
575
|
+
static const char msg[] = "Invalid typed array buffer range";
|
|
576
|
+
scr_throw_error_msg(SCR_ERR_RANGE, msg, sizeof msg - 1);
|
|
577
|
+
return NULL;
|
|
578
|
+
}
|
|
579
|
+
ScrBytes *view = scr_dataview_new(owner, off, true,
|
|
580
|
+
has_len ? count * (double)width : available - off);
|
|
581
|
+
if (!view) return NULL;
|
|
582
|
+
view->elem = elem;
|
|
583
|
+
view->len /= width;
|
|
584
|
+
return view;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
static size_t scr_dataview_get_size(ScrDataViewGet kind) {
|
|
588
|
+
switch (kind) {
|
|
589
|
+
case SCR_DV_U8:
|
|
590
|
+
case SCR_DV_I8:
|
|
591
|
+
return 1;
|
|
592
|
+
case SCR_DV_U16:
|
|
593
|
+
case SCR_DV_I16:
|
|
594
|
+
return 2;
|
|
595
|
+
case SCR_DV_U32:
|
|
596
|
+
case SCR_DV_I32:
|
|
597
|
+
case SCR_DV_F32:
|
|
598
|
+
return 4;
|
|
599
|
+
default:
|
|
600
|
+
return 8;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
double scr_dataview_get(const ScrBytes *b, double byte_off, ScrDataViewGet kind, bool le) {
|
|
605
|
+
size_t width = scr_dataview_get_size(kind);
|
|
606
|
+
/* ToIndex, then the view-relative bounds check — Node's ONE constant
|
|
607
|
+
* message for every failure mode (negative, NaN is fine, too large). */
|
|
608
|
+
double off = (byte_off != byte_off) ? 0 : trunc(byte_off);
|
|
609
|
+
if (!(off >= 0) || off > 9007199254740991.0 || off + (double)width > (double)b->len) {
|
|
610
|
+
static const char msg[] = "Offset is outside the bounds of the DataView";
|
|
611
|
+
scr_throw_error_msg(SCR_ERR_RANGE, msg, sizeof msg - 1);
|
|
612
|
+
return 0;
|
|
613
|
+
}
|
|
614
|
+
const uint8_t *p = b->data + (size_t)off;
|
|
615
|
+
/* Assemble host-independently; le false is the JS big-endian default. */
|
|
616
|
+
uint64_t u = 0;
|
|
617
|
+
for (size_t i = 0; i < width; i++) {
|
|
618
|
+
u |= (uint64_t)p[le ? i : width - 1 - i] << (8 * i);
|
|
619
|
+
}
|
|
620
|
+
switch (kind) {
|
|
621
|
+
case SCR_DV_U8:
|
|
622
|
+
case SCR_DV_U16:
|
|
623
|
+
case SCR_DV_U32:
|
|
624
|
+
return (double)u;
|
|
625
|
+
case SCR_DV_I8:
|
|
626
|
+
return (double)(int8_t)u;
|
|
627
|
+
case SCR_DV_I16:
|
|
628
|
+
return (double)(int16_t)u;
|
|
629
|
+
case SCR_DV_I32:
|
|
630
|
+
return (double)(int32_t)u;
|
|
631
|
+
case SCR_DV_F32: {
|
|
632
|
+
uint32_t bits = (uint32_t)u;
|
|
633
|
+
float f;
|
|
634
|
+
memcpy(&f, &bits, 4);
|
|
635
|
+
return (double)f;
|
|
636
|
+
}
|
|
637
|
+
case SCR_DV_F64: {
|
|
638
|
+
double d;
|
|
639
|
+
memcpy(&d, &u, 8);
|
|
640
|
+
return d;
|
|
641
|
+
}
|
|
642
|
+
case SCR_DV_BIGU64:
|
|
643
|
+
/* Number(view.getBigUint64(...)): u64 → double rounds to nearest
|
|
644
|
+
* even — the same conversion Number(bigint) performs. */
|
|
645
|
+
return (double)u;
|
|
646
|
+
case SCR_DV_BIGI64:
|
|
647
|
+
return (double)(int64_t)u;
|
|
648
|
+
}
|
|
649
|
+
return 0; /* unreachable */
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
void scr_dataview_set(ScrBytes *b, double byte_off, double value, ScrDataViewGet kind, bool le) {
|
|
653
|
+
size_t width = scr_dataview_get_size(kind);
|
|
654
|
+
/* ToIndex + the view-relative bounds check — the getters' ONE message. */
|
|
655
|
+
double off = (byte_off != byte_off) ? 0 : trunc(byte_off);
|
|
656
|
+
if (!(off >= 0) || off > 9007199254740991.0 || off + (double)width > (double)b->len) {
|
|
657
|
+
static const char msg[] = "Offset is outside the bounds of the DataView";
|
|
658
|
+
scr_throw_error_msg(SCR_ERR_RANGE, msg, sizeof msg - 1);
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
/* Coerce to the stored bit pattern. The integer kinds share ToUint32's
|
|
662
|
+
* 2^32 residue (signed/unsigned store the same bits; narrower widths
|
|
663
|
+
* take the low bytes — 2^width divides 2^32, so the residues agree);
|
|
664
|
+
* F32 rounds double→float to nearest even, exactly the spec. */
|
|
665
|
+
uint64_t u = 0;
|
|
666
|
+
switch (kind) {
|
|
667
|
+
case SCR_DV_U8:
|
|
668
|
+
case SCR_DV_I8:
|
|
669
|
+
case SCR_DV_U16:
|
|
670
|
+
case SCR_DV_I16:
|
|
671
|
+
case SCR_DV_U32:
|
|
672
|
+
case SCR_DV_I32:
|
|
673
|
+
u = (uint64_t)scr_bytes_to_u32(value);
|
|
674
|
+
break;
|
|
675
|
+
case SCR_DV_F32: {
|
|
676
|
+
float f = (float)value;
|
|
677
|
+
uint32_t bits;
|
|
678
|
+
memcpy(&bits, &f, 4);
|
|
679
|
+
u = bits;
|
|
680
|
+
break;
|
|
681
|
+
}
|
|
682
|
+
case SCR_DV_F64:
|
|
683
|
+
memcpy(&u, &value, 8);
|
|
684
|
+
break;
|
|
685
|
+
default:
|
|
686
|
+
return; /* BigInt setters use scr_dataview_write_u64_raw. */
|
|
687
|
+
}
|
|
688
|
+
/* Scatter host-independently; le false is the JS big-endian default. */
|
|
689
|
+
uint8_t *p = b->data + (size_t)off;
|
|
690
|
+
for (size_t i = 0; i < width; i++) {
|
|
691
|
+
p[le ? i : width - 1 - i] = (uint8_t)(u >> (8 * i));
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/* ── encodings (u8 only — the compiler routes only u8 receivers here) ──── */
|
|
696
|
+
|
|
697
|
+
static const char scr_hex_digits[] = "0123456789abcdef";
|
|
698
|
+
|
|
699
|
+
/* WHATWG UTF-8 decode with U+FFFD replacement per maximal invalid subpart
|
|
700
|
+
* — what Buffer.prototype.toString("utf8") does. Output re-encodes as
|
|
701
|
+
* (now valid) UTF-8: worst case 3 bytes per input byte. */
|
|
702
|
+
static ScrStr *scr_bytes_decode_utf8(const uint8_t *in, size_t n) {
|
|
703
|
+
if (in == NULL && n != 0) {
|
|
704
|
+
scr_trap("scriptc: native callback passed a NULL span with nonzero length\n");
|
|
705
|
+
}
|
|
706
|
+
if (n > (SIZE_MAX - 1) / 3) scr_bytes_oom();
|
|
707
|
+
char *out = malloc(n * 3 + 1);
|
|
708
|
+
if (!out) scr_bytes_oom();
|
|
709
|
+
size_t o = 0;
|
|
710
|
+
uint32_t cp = 0;
|
|
711
|
+
int needed = 0;
|
|
712
|
+
uint8_t lower = 0x80, upper = 0xbf;
|
|
713
|
+
for (size_t i = 0; i <= n; i++) {
|
|
714
|
+
if (i == n) {
|
|
715
|
+
if (needed > 0) { /* EOF inside a sequence: one replacement */
|
|
716
|
+
memcpy(out + o, "\xef\xbf\xbd", 3);
|
|
717
|
+
o += 3;
|
|
718
|
+
}
|
|
719
|
+
break;
|
|
720
|
+
}
|
|
721
|
+
uint8_t byte = in[i];
|
|
722
|
+
if (needed == 0) {
|
|
723
|
+
if (byte <= 0x7f) {
|
|
724
|
+
out[o++] = (char)byte;
|
|
725
|
+
} else if (byte >= 0xc2 && byte <= 0xdf) {
|
|
726
|
+
needed = 1; cp = byte & 0x1f;
|
|
727
|
+
} else if (byte >= 0xe0 && byte <= 0xef) {
|
|
728
|
+
if (byte == 0xe0) lower = 0xa0;
|
|
729
|
+
if (byte == 0xed) upper = 0x9f;
|
|
730
|
+
needed = 2; cp = byte & 0xf;
|
|
731
|
+
} else if (byte >= 0xf0 && byte <= 0xf4) {
|
|
732
|
+
if (byte == 0xf0) lower = 0x90;
|
|
733
|
+
if (byte == 0xf4) upper = 0x8f;
|
|
734
|
+
needed = 3; cp = byte & 0x7;
|
|
735
|
+
} else {
|
|
736
|
+
memcpy(out + o, "\xef\xbf\xbd", 3);
|
|
737
|
+
o += 3;
|
|
738
|
+
}
|
|
739
|
+
continue;
|
|
740
|
+
}
|
|
741
|
+
if (byte < lower || byte > upper) {
|
|
742
|
+
/* Invalid continuation: replace the subpart, REPROCESS this byte. */
|
|
743
|
+
memcpy(out + o, "\xef\xbf\xbd", 3);
|
|
744
|
+
o += 3;
|
|
745
|
+
needed = 0; lower = 0x80; upper = 0xbf;
|
|
746
|
+
i--;
|
|
747
|
+
continue;
|
|
748
|
+
}
|
|
749
|
+
lower = 0x80; upper = 0xbf;
|
|
750
|
+
cp = (cp << 6) | (byte & 0x3f);
|
|
751
|
+
if (--needed == 0) {
|
|
752
|
+
/* Re-encode the (valid, non-surrogate, <= 10FFFF) code point. */
|
|
753
|
+
if (cp <= 0x7f) {
|
|
754
|
+
out[o++] = (char)cp;
|
|
755
|
+
} else if (cp <= 0x7ff) {
|
|
756
|
+
out[o++] = (char)(0xc0 | (cp >> 6));
|
|
757
|
+
out[o++] = (char)(0x80 | (cp & 0x3f));
|
|
758
|
+
} else if (cp <= 0xffff) {
|
|
759
|
+
out[o++] = (char)(0xe0 | (cp >> 12));
|
|
760
|
+
out[o++] = (char)(0x80 | ((cp >> 6) & 0x3f));
|
|
761
|
+
out[o++] = (char)(0x80 | (cp & 0x3f));
|
|
762
|
+
} else {
|
|
763
|
+
out[o++] = (char)(0xf0 | (cp >> 18));
|
|
764
|
+
out[o++] = (char)(0x80 | ((cp >> 12) & 0x3f));
|
|
765
|
+
out[o++] = (char)(0x80 | ((cp >> 6) & 0x3f));
|
|
766
|
+
out[o++] = (char)(0x80 | (cp & 0x3f));
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
ScrStr *s = scr_str_new(out, o);
|
|
771
|
+
free(out);
|
|
772
|
+
return s;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
ScrStr *scr_str_from_utf8_lossy(const uint8_t *bytes, size_t len) {
|
|
776
|
+
return scr_bytes_decode_utf8(bytes, len);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/* WHATWG TextDecoder.decode (utf-8, default options): the SAME maximal-
|
|
780
|
+
* subpart replacement decode as toString("utf8") above, with one
|
|
781
|
+
* difference — a leading UTF-8 BOM is stripped (ignoreBOM defaults to
|
|
782
|
+
* false in the spec; Buffer.toString keeps the BOM as U+FEFF). */
|
|
783
|
+
ScrStr *scr_text_decode(const ScrBytes *b) {
|
|
784
|
+
const uint8_t *in = b->data;
|
|
785
|
+
size_t n = b->len;
|
|
786
|
+
if (n >= 3 && in[0] == 0xef && in[1] == 0xbb && in[2] == 0xbf) {
|
|
787
|
+
in += 3;
|
|
788
|
+
n -= 3;
|
|
789
|
+
}
|
|
790
|
+
return scr_bytes_decode_utf8(in, n);
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/* ── node:string_decoder, the utf8 StringDecoder ─────────────────────────
|
|
794
|
+
* The decoder VALUE is a one-field record holding the pending partial
|
|
795
|
+
* sequence PACKED into an f64 (count in the low byte, then up to three
|
|
796
|
+
* raw bytes — at most 3 pend, so 32 bits): the compiler's interned
|
|
797
|
+
* %strdec helpers thread it through these three pure functions. The
|
|
798
|
+
* algorithm is Node's utf8 StringDecoder pinned by oracle (corpus 1474):
|
|
799
|
+
* write() decodes pending+chunk minus the trailing INCOMPLETE sequence
|
|
800
|
+
* (the decode above — invalid bytes become U+FFFD immediately, only a
|
|
801
|
+
* truncated valid lead buffers), end() flushes the buffered partial as
|
|
802
|
+
* its replacement chars. */
|
|
803
|
+
|
|
804
|
+
/* Encoding helpers defined beside toString below (the strdec steps share
|
|
805
|
+
* them). */
|
|
806
|
+
static ScrStr *scr_bytes_encode_b64(const uint8_t *in, size_t n, bool url);
|
|
807
|
+
static ScrStr *scr_bytes_decode_utf16le(const uint8_t *in, size_t n);
|
|
808
|
+
static bool scr_enc_is(const ScrStr *enc, const char *name);
|
|
809
|
+
|
|
810
|
+
static size_t scr_strdec_unpack(double pending, uint8_t out[3]) {
|
|
811
|
+
uint32_t p = (uint32_t)pending;
|
|
812
|
+
size_t n = p & 0xff;
|
|
813
|
+
if (n > 3) n = 3;
|
|
814
|
+
out[0] = (uint8_t)((p >> 8) & 0xff);
|
|
815
|
+
out[1] = (uint8_t)((p >> 16) & 0xff);
|
|
816
|
+
out[2] = (uint8_t)((p >> 24) & 0xff);
|
|
817
|
+
return n;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
static double scr_strdec_pack(const uint8_t *bytes, size_t n) {
|
|
821
|
+
uint32_t p = (uint32_t)n;
|
|
822
|
+
if (n > 0) p |= (uint32_t)bytes[0] << 8;
|
|
823
|
+
if (n > 1) p |= (uint32_t)bytes[1] << 16;
|
|
824
|
+
if (n > 2) p |= (uint32_t)bytes[2] << 24;
|
|
825
|
+
return (double)p;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
/* Node's utf8CheckIncomplete over the COMBINED tail: the length (0-3) of
|
|
829
|
+
* a trailing truncated-but-valid sequence prefix. Bare continuations and
|
|
830
|
+
* invalid leads are NOT incomplete — they decode (to U+FFFD) now. */
|
|
831
|
+
static size_t scr_strdec_tail(const uint8_t *buf, size_t n) {
|
|
832
|
+
size_t scan = n < 3 ? n : 3;
|
|
833
|
+
for (size_t back = 1; back <= scan; back++) {
|
|
834
|
+
uint8_t b = buf[n - back];
|
|
835
|
+
if ((b & 0xc0) == 0x80) continue; /* continuation: keep walking */
|
|
836
|
+
size_t need = 0;
|
|
837
|
+
if ((b & 0xe0) == 0xc0) need = 2;
|
|
838
|
+
else if ((b & 0xf0) == 0xe0) need = 3;
|
|
839
|
+
else if ((b & 0xf8) == 0xf0) need = 4;
|
|
840
|
+
else return 0; /* ascii or invalid lead: nothing buffers */
|
|
841
|
+
return back < need ? back : 0; /* complete: decode now */
|
|
842
|
+
}
|
|
843
|
+
return 0; /* 3 continuations (or empty): invalid, decode now */
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/* The combined pending+chunk buffer (malloc'd; *out_n set). */
|
|
847
|
+
static uint8_t *scr_strdec_combined(double pending, const ScrBytes *chunk, size_t *out_n) {
|
|
848
|
+
uint8_t pend[3];
|
|
849
|
+
size_t np = scr_strdec_unpack(pending, pend);
|
|
850
|
+
size_t n = np + chunk->len;
|
|
851
|
+
uint8_t *buf = malloc(n > 0 ? n : 1);
|
|
852
|
+
if (!buf) scr_bytes_oom();
|
|
853
|
+
memcpy(buf, pend, np);
|
|
854
|
+
memcpy(buf + np, chunk->data, chunk->len);
|
|
855
|
+
*out_n = n;
|
|
856
|
+
return buf;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/* The utf16le step, Node's utf16Text/fillLast: a pending partial fills
|
|
860
|
+
* first (an odd byte completes its unit; a held LEAD surrogate completes
|
|
861
|
+
* its pair — 4 bytes total), then the rest holds back an odd tail byte
|
|
862
|
+
* (with NO surrogate check — Node's own quirk emits a lead surrogate
|
|
863
|
+
* before an odd boundary) or a trailing lead surrogate's 2 bytes. The
|
|
864
|
+
* emitted bytes decode JOINTLY, so pair halves split across the fill
|
|
865
|
+
* boundary reassemble exactly like Node's string concatenation. */
|
|
866
|
+
static ScrStr *scr_strdec_u16(double pending, const ScrBytes *chunk, bool want_str, double *out_hold) {
|
|
867
|
+
uint8_t held[3];
|
|
868
|
+
size_t k = scr_strdec_unpack(pending, held);
|
|
869
|
+
const uint8_t *c = chunk->data;
|
|
870
|
+
size_t cn = chunk->len;
|
|
871
|
+
uint8_t complete[4];
|
|
872
|
+
size_t comp_n = 0;
|
|
873
|
+
if (k > 0) {
|
|
874
|
+
size_t total = k == 1 ? 2 : 4; /* 1 = odd byte; 2 or 3 = lead-surrogate hold */
|
|
875
|
+
size_t need = total - k;
|
|
876
|
+
if (cn < need) {
|
|
877
|
+
uint8_t nh[3];
|
|
878
|
+
memcpy(nh, held, k);
|
|
879
|
+
memcpy(nh + k, c, cn);
|
|
880
|
+
*out_hold = scr_strdec_pack(nh, k + cn);
|
|
881
|
+
return want_str ? scr_str_new("", 0) : NULL;
|
|
882
|
+
}
|
|
883
|
+
memcpy(complete, held, k);
|
|
884
|
+
memcpy(complete + k, c, need);
|
|
885
|
+
comp_n = total;
|
|
886
|
+
c += need;
|
|
887
|
+
cn -= need;
|
|
888
|
+
}
|
|
889
|
+
size_t keep = cn;
|
|
890
|
+
if (cn % 2 == 1) {
|
|
891
|
+
keep = cn - 1;
|
|
892
|
+
} else if (cn >= 2) {
|
|
893
|
+
uint32_t last = (uint32_t)c[cn - 2] | ((uint32_t)c[cn - 1] << 8);
|
|
894
|
+
if (last >= 0xd800 && last <= 0xdbff) keep = cn - 2;
|
|
895
|
+
}
|
|
896
|
+
*out_hold = scr_strdec_pack(c + keep, cn - keep);
|
|
897
|
+
if (!want_str) return NULL;
|
|
898
|
+
size_t n = comp_n + keep;
|
|
899
|
+
uint8_t *buf = malloc(n > 0 ? n : 1);
|
|
900
|
+
if (!buf) scr_bytes_oom();
|
|
901
|
+
memcpy(buf, complete, comp_n);
|
|
902
|
+
memcpy(buf + comp_n, c, keep);
|
|
903
|
+
ScrStr *s = scr_bytes_decode_utf16le(buf, n);
|
|
904
|
+
free(buf);
|
|
905
|
+
return s;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
/* The base64/base64url step: complete 3-byte groups encode now, the
|
|
909
|
+
* 1-2-byte remainder buffers (the combined walk is Node's fillLast+text
|
|
910
|
+
* exactly — base64 of a concatenation splits at group boundaries). */
|
|
911
|
+
static ScrStr *scr_strdec_b64(double pending, const ScrBytes *chunk, bool url, bool want_str, double *out_hold) {
|
|
912
|
+
size_t n;
|
|
913
|
+
uint8_t *buf = scr_strdec_combined(pending, chunk, &n);
|
|
914
|
+
size_t tail = n % 3;
|
|
915
|
+
*out_hold = scr_strdec_pack(buf + (n - tail), tail);
|
|
916
|
+
ScrStr *s = want_str ? scr_bytes_encode_b64(buf, n - tail, url) : NULL;
|
|
917
|
+
free(buf);
|
|
918
|
+
return s;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/* One dispatcher computes the decoded string (when wanted) and the new
|
|
922
|
+
* packed pending for a write. latin1/ascii/hex are stateless (write IS
|
|
923
|
+
* toString); utf8 keeps the oracle-pinned combined walk. */
|
|
924
|
+
static ScrStr *scr_strdec_step(const ScrStr *enc, double pending, const ScrBytes *chunk,
|
|
925
|
+
bool want_str, double *out_hold) {
|
|
926
|
+
if (scr_enc_is(enc, "utf16le")) return scr_strdec_u16(pending, chunk, want_str, out_hold);
|
|
927
|
+
if (scr_enc_is(enc, "base64")) return scr_strdec_b64(pending, chunk, false, want_str, out_hold);
|
|
928
|
+
if (scr_enc_is(enc, "base64url")) return scr_strdec_b64(pending, chunk, true, want_str, out_hold);
|
|
929
|
+
if (scr_enc_is(enc, "latin1") || scr_enc_is(enc, "ascii") || scr_enc_is(enc, "hex")) {
|
|
930
|
+
*out_hold = 0;
|
|
931
|
+
return want_str ? scr_bytes_to_str(chunk, enc) : NULL;
|
|
932
|
+
}
|
|
933
|
+
size_t n;
|
|
934
|
+
uint8_t *buf = scr_strdec_combined(pending, chunk, &n);
|
|
935
|
+
size_t tail = scr_strdec_tail(buf, n);
|
|
936
|
+
*out_hold = scr_strdec_pack(buf + (n - tail), tail);
|
|
937
|
+
ScrStr *s = want_str ? scr_bytes_decode_utf8(buf, n - tail) : NULL;
|
|
938
|
+
free(buf);
|
|
939
|
+
return s;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
/* decoder.write(chunk): the decoded complete prefix (+1). */
|
|
943
|
+
ScrStr *scr_strdec_write(const ScrStr *enc, double pending, const ScrBytes *chunk) {
|
|
944
|
+
double hold;
|
|
945
|
+
return scr_strdec_step(enc, pending, chunk, true, &hold);
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/* The decoder state AFTER a write: the packed trailing partial sequence. */
|
|
949
|
+
double scr_strdec_next(const ScrStr *enc, double pending, const ScrBytes *chunk) {
|
|
950
|
+
double hold = 0;
|
|
951
|
+
scr_strdec_step(enc, pending, chunk, false, &hold);
|
|
952
|
+
return hold;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
/* decoder.end(): the buffered partial flushes — utf8's truncated sequence
|
|
956
|
+
* becomes its replacement chars (the maximal-subpart rule), base64's
|
|
957
|
+
* remainder encodes (padded; unpadded for base64url), utf16le's held
|
|
958
|
+
* bytes decode as they stand (an odd byte drops; a held lead surrogate is
|
|
959
|
+
* the documented U+FFFD divergence), and the stateless encodings flush
|
|
960
|
+
* nothing. +1. */
|
|
961
|
+
ScrStr *scr_strdec_end(const ScrStr *enc, double pending) {
|
|
962
|
+
uint8_t pend[3];
|
|
963
|
+
size_t np = scr_strdec_unpack(pending, pend);
|
|
964
|
+
if (scr_enc_is(enc, "base64")) return scr_bytes_encode_b64(pend, np, false);
|
|
965
|
+
if (scr_enc_is(enc, "base64url")) return scr_bytes_encode_b64(pend, np, true);
|
|
966
|
+
if (scr_enc_is(enc, "utf16le")) return scr_bytes_decode_utf16le(pend, np);
|
|
967
|
+
if (scr_enc_is(enc, "latin1") || scr_enc_is(enc, "ascii") || scr_enc_is(enc, "hex")) {
|
|
968
|
+
return scr_str_new("", 0);
|
|
969
|
+
}
|
|
970
|
+
return scr_bytes_decode_utf8(pend, np);
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
static void scr_bytes_to_str_bounds(const ScrBytes *b, double start, double end,
|
|
974
|
+
size_t *s0_out, size_t *e0_out) {
|
|
975
|
+
size_t len = b->len;
|
|
976
|
+
size_t s0 = start <= 0 ? 0 : ((size_t)start > len ? len : (size_t)start);
|
|
977
|
+
size_t e0 = end <= 0 ? 0 : ((size_t)end > len ? len : (size_t)end);
|
|
978
|
+
if (e0 < s0) e0 = s0;
|
|
979
|
+
*s0_out = s0;
|
|
980
|
+
*e0_out = e0;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
/* toString(enc, start, end): Node slices then decodes — start/end clamp
|
|
984
|
+
* to [0, len] with start > end collapsing to empty and negative ends
|
|
985
|
+
* clamping to 0 (Node's slice-then-decode; an OMITTED end never reaches
|
|
986
|
+
* here — the emitter supplies the receiver's length for the 2-arg
|
|
987
|
+
* form). Delegates to the whole-buffer decoder
|
|
988
|
+
* through a stack view — no allocation, no rc traffic. */
|
|
989
|
+
ScrStr *scr_bytes_to_str_range(const ScrBytes *b, const ScrStr *enc, double start, double end) {
|
|
990
|
+
size_t s0, e0;
|
|
991
|
+
scr_bytes_to_str_bounds(b, start, end, &s0, &e0);
|
|
992
|
+
ScrBytes view = { .rc = 1, .len = e0 - s0, .elem = b->elem, .data = b->data + s0, .backing = NULL };
|
|
993
|
+
return scr_bytes_to_str(&view, enc);
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
/* The base64 encoder behind toString("base64") and toString("base64url"):
|
|
997
|
+
* the url flavor swaps the alphabet's last two chars for -_ and drops the
|
|
998
|
+
* padding, exactly Node. */
|
|
999
|
+
static ScrStr *scr_bytes_encode_b64(const uint8_t *in, size_t n, bool url) {
|
|
1000
|
+
static const char std_abc[] =
|
|
1001
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
1002
|
+
static const char url_abc[] =
|
|
1003
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
1004
|
+
const char *abc = url ? url_abc : std_abc;
|
|
1005
|
+
size_t outlen = (n + 2) / 3 * 4;
|
|
1006
|
+
char *out = malloc(outlen + 1);
|
|
1007
|
+
if (!out) scr_bytes_oom();
|
|
1008
|
+
size_t o = 0;
|
|
1009
|
+
for (size_t i = 0; i < n; i += 3) {
|
|
1010
|
+
unsigned v = (unsigned)in[i] << 16;
|
|
1011
|
+
if (i + 1 < n) v |= (unsigned)in[i + 1] << 8;
|
|
1012
|
+
if (i + 2 < n) v |= (unsigned)in[i + 2];
|
|
1013
|
+
out[o++] = abc[(v >> 18) & 63];
|
|
1014
|
+
out[o++] = abc[(v >> 12) & 63];
|
|
1015
|
+
if (i + 1 < n) out[o++] = abc[(v >> 6) & 63];
|
|
1016
|
+
else if (!url) out[o++] = '=';
|
|
1017
|
+
if (i + 2 < n) out[o++] = abc[v & 63];
|
|
1018
|
+
else if (!url) out[o++] = '=';
|
|
1019
|
+
}
|
|
1020
|
+
ScrStr *s = scr_str_new(out, o);
|
|
1021
|
+
free(out);
|
|
1022
|
+
return s;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
/* Append one code point as UTF-8 (the caller sized the buffer). */
|
|
1026
|
+
static size_t scr_bytes_put_cp(char *out, size_t o, uint32_t cp) {
|
|
1027
|
+
if (cp <= 0x7f) {
|
|
1028
|
+
out[o++] = (char)cp;
|
|
1029
|
+
} else if (cp <= 0x7ff) {
|
|
1030
|
+
out[o++] = (char)(0xc0 | (cp >> 6));
|
|
1031
|
+
out[o++] = (char)(0x80 | (cp & 0x3f));
|
|
1032
|
+
} else if (cp <= 0xffff) {
|
|
1033
|
+
out[o++] = (char)(0xe0 | (cp >> 12));
|
|
1034
|
+
out[o++] = (char)(0x80 | ((cp >> 6) & 0x3f));
|
|
1035
|
+
out[o++] = (char)(0x80 | (cp & 0x3f));
|
|
1036
|
+
} else {
|
|
1037
|
+
out[o++] = (char)(0xf0 | (cp >> 18));
|
|
1038
|
+
out[o++] = (char)(0x80 | ((cp >> 12) & 0x3f));
|
|
1039
|
+
out[o++] = (char)(0x80 | ((cp >> 6) & 0x3f));
|
|
1040
|
+
out[o++] = (char)(0x80 | (cp & 0x3f));
|
|
1041
|
+
}
|
|
1042
|
+
return o;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
/* ── WHATWG/Node TextDecoder legacy encodings ──────────────────────────
|
|
1046
|
+
*
|
|
1047
|
+
* The frontend only calls this entry with a compile-time encoding id. The
|
|
1048
|
+
* lookup data is generated from the repository's pinned Node 24 oracle, so
|
|
1049
|
+
* the resulting binary has no ICU/iconv dependency and behaves identically
|
|
1050
|
+
* on Darwin, Linux, and Windows. UTF-8 keeps its older dedicated entry above:
|
|
1051
|
+
* programs using only the default decoder do not retain these legacy tables.
|
|
1052
|
+
*/
|
|
1053
|
+
#ifdef SCR_TEXT_DECODER_LEGACY
|
|
1054
|
+
|
|
1055
|
+
enum {
|
|
1056
|
+
SCR_TD_X_USER_DEFINED = SCR_TD_SINGLE_COUNT,
|
|
1057
|
+
SCR_TD_UTF16LE,
|
|
1058
|
+
SCR_TD_UTF16BE,
|
|
1059
|
+
SCR_TD_GB18030,
|
|
1060
|
+
SCR_TD_BIG5,
|
|
1061
|
+
SCR_TD_EUC_JP,
|
|
1062
|
+
SCR_TD_ISO_2022_JP,
|
|
1063
|
+
SCR_TD_SHIFT_JIS,
|
|
1064
|
+
SCR_TD_EUC_KR,
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
typedef struct {
|
|
1068
|
+
char *data;
|
|
1069
|
+
size_t len;
|
|
1070
|
+
} ScrTdOut;
|
|
1071
|
+
|
|
1072
|
+
static ScrTdOut scr_td_out_new(size_t input_len) {
|
|
1073
|
+
if (input_len > (SIZE_MAX - 8) / 3) scr_bytes_oom();
|
|
1074
|
+
ScrTdOut out = { malloc(input_len * 3 + 8), 0 };
|
|
1075
|
+
if (!out.data) scr_bytes_oom();
|
|
1076
|
+
return out;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
static void scr_td_put(ScrTdOut *out, uint32_t cp) {
|
|
1080
|
+
out->len = scr_bytes_put_cp(out->data, out->len, cp);
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
static void scr_td_error(ScrTdOut *out) {
|
|
1084
|
+
scr_td_put(out, 0xfffd);
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
static ScrStr *scr_td_finish(ScrTdOut *out) {
|
|
1088
|
+
ScrStr *str = scr_str_new(out->data, out->len);
|
|
1089
|
+
free(out->data);
|
|
1090
|
+
return str;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
static ScrStr *scr_td_single_byte(const ScrBytes *b, unsigned encoding) {
|
|
1094
|
+
ScrTdOut out = scr_td_out_new(b->len);
|
|
1095
|
+
for (size_t i = 0; i < b->len; i++) {
|
|
1096
|
+
uint8_t byte = b->data[i];
|
|
1097
|
+
scr_td_put(&out, byte < 0x80 ? byte : scr_td_single[encoding][byte - 0x80]);
|
|
1098
|
+
}
|
|
1099
|
+
return scr_td_finish(&out);
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
static ScrStr *scr_td_x_user_defined(const ScrBytes *b) {
|
|
1103
|
+
ScrTdOut out = scr_td_out_new(b->len);
|
|
1104
|
+
for (size_t i = 0; i < b->len; i++) {
|
|
1105
|
+
uint8_t byte = b->data[i];
|
|
1106
|
+
scr_td_put(&out, byte < 0x80 ? byte : 0xf780 + byte - 0x80);
|
|
1107
|
+
}
|
|
1108
|
+
return scr_td_finish(&out);
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
static ScrStr *scr_td_utf16(const ScrBytes *b, bool be) {
|
|
1112
|
+
const uint8_t *in = b->data;
|
|
1113
|
+
size_t n = b->len;
|
|
1114
|
+
/* TextDecoder's BOM handling strips only the BOM matching the selected
|
|
1115
|
+
* endian decoder. The opposite BOM decodes to U+FFFE and remains. */
|
|
1116
|
+
if (n >= 2 && ((!be && in[0] == 0xff && in[1] == 0xfe) ||
|
|
1117
|
+
(be && in[0] == 0xfe && in[1] == 0xff))) {
|
|
1118
|
+
in += 2;
|
|
1119
|
+
n -= 2;
|
|
1120
|
+
}
|
|
1121
|
+
ScrTdOut out = scr_td_out_new(n);
|
|
1122
|
+
size_t i = 0;
|
|
1123
|
+
while (i + 1 < n) {
|
|
1124
|
+
uint32_t cu = be ? ((uint32_t)in[i] << 8) | in[i + 1]
|
|
1125
|
+
: (uint32_t)in[i] | ((uint32_t)in[i + 1] << 8);
|
|
1126
|
+
i += 2;
|
|
1127
|
+
if (cu >= 0xd800 && cu <= 0xdbff) {
|
|
1128
|
+
if (i + 1 < n) {
|
|
1129
|
+
uint32_t lo = be ? ((uint32_t)in[i] << 8) | in[i + 1]
|
|
1130
|
+
: (uint32_t)in[i] | ((uint32_t)in[i + 1] << 8);
|
|
1131
|
+
if (lo >= 0xdc00 && lo <= 0xdfff) {
|
|
1132
|
+
i += 2;
|
|
1133
|
+
scr_td_put(&out, 0x10000 + ((cu - 0xd800) << 10) + (lo - 0xdc00));
|
|
1134
|
+
continue;
|
|
1135
|
+
}
|
|
1136
|
+
} else if (i < n) {
|
|
1137
|
+
/* ICU treats a lead surrogate plus one final byte as one malformed
|
|
1138
|
+
* UTF-16 subsequence. Consume that byte here so the odd-tail path
|
|
1139
|
+
* below does not emit a second replacement. */
|
|
1140
|
+
i++;
|
|
1141
|
+
}
|
|
1142
|
+
scr_td_error(&out);
|
|
1143
|
+
continue;
|
|
1144
|
+
}
|
|
1145
|
+
if (cu >= 0xdc00 && cu <= 0xdfff) scr_td_error(&out);
|
|
1146
|
+
else scr_td_put(&out, cu);
|
|
1147
|
+
}
|
|
1148
|
+
if (i < n) scr_td_error(&out); /* odd trailing byte */
|
|
1149
|
+
return scr_td_finish(&out);
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
static uint32_t scr_td_gb_range(uint32_t pointer) {
|
|
1153
|
+
size_t lo = 0;
|
|
1154
|
+
size_t hi = sizeof scr_td_gb_ranges / sizeof scr_td_gb_ranges[0];
|
|
1155
|
+
while (lo < hi) {
|
|
1156
|
+
size_t mid = lo + (hi - lo) / 2;
|
|
1157
|
+
const ScrTdGbRange *range = &scr_td_gb_ranges[mid];
|
|
1158
|
+
if (pointer < range->start) hi = mid;
|
|
1159
|
+
else if (pointer > range->end) lo = mid + 1;
|
|
1160
|
+
else return range->code_point + pointer - range->start;
|
|
1161
|
+
}
|
|
1162
|
+
return 0;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
/* A tiny prepend stack models the Encoding Standard's I/O queue restore.
|
|
1166
|
+
* The gb18030 decoder is the only legacy decoder which can restore three
|
|
1167
|
+
* bytes after discovering a malformed four-byte sequence. */
|
|
1168
|
+
static ScrStr *scr_td_gb18030_decode(const ScrBytes *b) {
|
|
1169
|
+
ScrTdOut out = scr_td_out_new(b->len);
|
|
1170
|
+
uint8_t first = 0, second = 0, third = 0;
|
|
1171
|
+
uint8_t replay[3];
|
|
1172
|
+
size_t replay_len = 0;
|
|
1173
|
+
size_t i = 0;
|
|
1174
|
+
while (i < b->len || replay_len > 0) {
|
|
1175
|
+
uint8_t byte = replay_len ? replay[--replay_len] : b->data[i++];
|
|
1176
|
+
if (third) {
|
|
1177
|
+
uint32_t cp = 0;
|
|
1178
|
+
bool valid_fourth = byte >= 0x30 && byte <= 0x39;
|
|
1179
|
+
if (valid_fourth) {
|
|
1180
|
+
uint32_t pointer = (((uint32_t)(first - 0x81) * 10 + second - 0x30) * 126 +
|
|
1181
|
+
third - 0x81) * 10 + byte - 0x30;
|
|
1182
|
+
cp = scr_td_gb_range(pointer);
|
|
1183
|
+
}
|
|
1184
|
+
uint8_t old_second = second, old_third = third;
|
|
1185
|
+
first = second = third = 0;
|
|
1186
|
+
if (cp) {
|
|
1187
|
+
scr_td_put(&out, cp);
|
|
1188
|
+
} else {
|
|
1189
|
+
scr_td_error(&out);
|
|
1190
|
+
/* A structurally valid four-byte sequence with an unmapped pointer
|
|
1191
|
+
* is consumed as one error. Only a malformed fourth byte restores
|
|
1192
|
+
* the preceding payload bytes to Node's input queue. */
|
|
1193
|
+
if (!valid_fourth) {
|
|
1194
|
+
replay[replay_len++] = byte;
|
|
1195
|
+
replay[replay_len++] = old_third;
|
|
1196
|
+
replay[replay_len++] = old_second;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
continue;
|
|
1200
|
+
}
|
|
1201
|
+
if (second) {
|
|
1202
|
+
if (byte >= 0x81 && byte <= 0xfe) {
|
|
1203
|
+
third = byte;
|
|
1204
|
+
} else {
|
|
1205
|
+
uint8_t old_second = second;
|
|
1206
|
+
first = second = 0;
|
|
1207
|
+
scr_td_error(&out);
|
|
1208
|
+
replay[replay_len++] = byte;
|
|
1209
|
+
replay[replay_len++] = old_second;
|
|
1210
|
+
}
|
|
1211
|
+
continue;
|
|
1212
|
+
}
|
|
1213
|
+
if (first) {
|
|
1214
|
+
if (byte >= 0x30 && byte <= 0x39) {
|
|
1215
|
+
second = byte;
|
|
1216
|
+
continue;
|
|
1217
|
+
}
|
|
1218
|
+
uint8_t lead = first;
|
|
1219
|
+
first = 0;
|
|
1220
|
+
uint32_t cp = 0;
|
|
1221
|
+
bool valid_trail = (byte >= 0x40 && byte <= 0x7e) ||
|
|
1222
|
+
(byte >= 0x80 && byte <= 0xfe);
|
|
1223
|
+
if (valid_trail) {
|
|
1224
|
+
unsigned offset = byte < 0x7f ? 0x40 : 0x41;
|
|
1225
|
+
cp = scr_td_gb18030[(lead - 0x81) * 190 + byte - offset];
|
|
1226
|
+
}
|
|
1227
|
+
if (cp) scr_td_put(&out, cp);
|
|
1228
|
+
else {
|
|
1229
|
+
scr_td_error(&out);
|
|
1230
|
+
/* Non-ASCII invalid trails are consumed; ASCII is restored. */
|
|
1231
|
+
if (!valid_trail && byte < 0x80) replay[replay_len++] = byte;
|
|
1232
|
+
}
|
|
1233
|
+
continue;
|
|
1234
|
+
}
|
|
1235
|
+
if (byte < 0x80) scr_td_put(&out, byte);
|
|
1236
|
+
else if (byte == 0x80) scr_td_put(&out, 0x20ac);
|
|
1237
|
+
else if (byte >= 0x81 && byte <= 0xfe) first = byte;
|
|
1238
|
+
else scr_td_error(&out);
|
|
1239
|
+
}
|
|
1240
|
+
if (first || second || third) scr_td_error(&out);
|
|
1241
|
+
return scr_td_finish(&out);
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
static ScrStr *scr_td_big5_decode(const ScrBytes *b) {
|
|
1245
|
+
ScrTdOut out = scr_td_out_new(b->len);
|
|
1246
|
+
uint8_t lead = 0;
|
|
1247
|
+
for (size_t i = 0; i < b->len; i++) {
|
|
1248
|
+
uint8_t byte = b->data[i];
|
|
1249
|
+
if (lead) {
|
|
1250
|
+
uint32_t cp = 0;
|
|
1251
|
+
if ((byte >= 0x40 && byte <= 0x7e) || (byte >= 0xa1 && byte <= 0xfe)) {
|
|
1252
|
+
unsigned offset = byte < 0x7f ? 0x40 : 0x62;
|
|
1253
|
+
cp = scr_td_big5[(lead - 0x81) * 157 + byte - offset];
|
|
1254
|
+
}
|
|
1255
|
+
lead = 0;
|
|
1256
|
+
if (cp) scr_td_put(&out, cp);
|
|
1257
|
+
else {
|
|
1258
|
+
scr_td_error(&out);
|
|
1259
|
+
/* 0xff has a standalone ICU/Node mapping and is restored too. */
|
|
1260
|
+
if (byte < 0x80 || byte == 0xff) i--;
|
|
1261
|
+
}
|
|
1262
|
+
continue;
|
|
1263
|
+
}
|
|
1264
|
+
if (byte < 0x80 || byte == 0x80) scr_td_put(&out, byte);
|
|
1265
|
+
else if (byte >= 0x81 && byte <= 0xfe) lead = byte;
|
|
1266
|
+
else if (byte == 0xff) scr_td_put(&out, 0xf8f8); /* ICU/Node mapping */
|
|
1267
|
+
else scr_td_error(&out);
|
|
1268
|
+
}
|
|
1269
|
+
if (lead) scr_td_error(&out);
|
|
1270
|
+
return scr_td_finish(&out);
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
static ScrStr *scr_td_euc_jp_decode(const ScrBytes *b) {
|
|
1274
|
+
ScrTdOut out = scr_td_out_new(b->len);
|
|
1275
|
+
uint8_t lead = 0;
|
|
1276
|
+
bool jis0212 = false;
|
|
1277
|
+
for (size_t i = 0; i < b->len; i++) {
|
|
1278
|
+
uint8_t byte = b->data[i];
|
|
1279
|
+
if (lead == 0x8e && byte >= 0xa1 && byte <= 0xdf) {
|
|
1280
|
+
lead = 0;
|
|
1281
|
+
scr_td_put(&out, 0xff61 + byte - 0xa1);
|
|
1282
|
+
continue;
|
|
1283
|
+
}
|
|
1284
|
+
/* Node's pinned ICU EUC-JP converter exposes three NEC extensions just
|
|
1285
|
+
* above the half-width katakana trail range. */
|
|
1286
|
+
if (lead == 0x8e && byte >= 0xe0 && byte <= 0xe2) {
|
|
1287
|
+
static const uint16_t extensions[] = { 0x00a2, 0x00a3, 0x00ac };
|
|
1288
|
+
lead = 0;
|
|
1289
|
+
scr_td_put(&out, extensions[byte - 0xe0]);
|
|
1290
|
+
continue;
|
|
1291
|
+
}
|
|
1292
|
+
if (lead == 0x8f && byte >= 0xa1 && byte <= 0xfe) {
|
|
1293
|
+
jis0212 = true;
|
|
1294
|
+
lead = byte;
|
|
1295
|
+
continue;
|
|
1296
|
+
}
|
|
1297
|
+
if (lead) {
|
|
1298
|
+
uint8_t old_lead = lead;
|
|
1299
|
+
lead = 0;
|
|
1300
|
+
uint32_t cp = 0;
|
|
1301
|
+
bool valid_trail = old_lead >= 0xa1 && old_lead <= 0xfe &&
|
|
1302
|
+
byte >= 0xa1 && byte <= 0xfe;
|
|
1303
|
+
if (valid_trail) {
|
|
1304
|
+
unsigned pointer = (old_lead - 0xa1) * 94 + byte - 0xa1;
|
|
1305
|
+
cp = jis0212 ? scr_td_jis0212[pointer] : scr_td_jis0208[pointer];
|
|
1306
|
+
}
|
|
1307
|
+
/* When the third byte of an 0x8f JIS-0212 sequence is malformed,
|
|
1308
|
+
* ICU reports the prefix and restores both following bytes. Model the
|
|
1309
|
+
* saved second byte as the next ordinary EUC-JP lead. */
|
|
1310
|
+
if (jis0212 && !valid_trail) {
|
|
1311
|
+
jis0212 = false;
|
|
1312
|
+
lead = old_lead;
|
|
1313
|
+
scr_td_error(&out);
|
|
1314
|
+
i--;
|
|
1315
|
+
continue;
|
|
1316
|
+
}
|
|
1317
|
+
jis0212 = false;
|
|
1318
|
+
if (cp) scr_td_put(&out, cp);
|
|
1319
|
+
else {
|
|
1320
|
+
scr_td_error(&out);
|
|
1321
|
+
/* C0/C1 bytes are restored; 0xa0 and 0xff are consumed with the
|
|
1322
|
+
* malformed sequence rather than producing a second error. The
|
|
1323
|
+
* 0x8e extension converter additionally restores 0xe5..0xfe. */
|
|
1324
|
+
if (byte < 0xa0 || (old_lead == 0x8e && byte >= 0xe5 && byte <= 0xfe)) i--;
|
|
1325
|
+
}
|
|
1326
|
+
continue;
|
|
1327
|
+
}
|
|
1328
|
+
if (byte < 0xa0 && byte != 0x8e && byte != 0x8f) scr_td_put(&out, byte);
|
|
1329
|
+
else if (byte == 0x8e || byte == 0x8f || (byte >= 0xa1 && byte <= 0xfe)) lead = byte;
|
|
1330
|
+
else scr_td_error(&out);
|
|
1331
|
+
}
|
|
1332
|
+
if (lead) scr_td_error(&out);
|
|
1333
|
+
return scr_td_finish(&out);
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
static ScrStr *scr_td_shift_jis_decode(const ScrBytes *b) {
|
|
1337
|
+
ScrTdOut out = scr_td_out_new(b->len);
|
|
1338
|
+
uint8_t lead = 0;
|
|
1339
|
+
for (size_t i = 0; i < b->len; i++) {
|
|
1340
|
+
uint8_t byte = b->data[i];
|
|
1341
|
+
if (lead) {
|
|
1342
|
+
uint32_t cp = 0;
|
|
1343
|
+
bool valid_trail = (byte >= 0x40 && byte <= 0x7e) ||
|
|
1344
|
+
(byte >= 0x80 && byte <= 0xfc);
|
|
1345
|
+
if (valid_trail) {
|
|
1346
|
+
unsigned offset = byte < 0x7f ? 0x40 : 0x41;
|
|
1347
|
+
unsigned lead_offset = lead < 0xa0 ? 0x81 : 0xc1;
|
|
1348
|
+
unsigned pointer = (lead - lead_offset) * 188 + byte - offset;
|
|
1349
|
+
cp = scr_td_shift_jis[pointer];
|
|
1350
|
+
}
|
|
1351
|
+
lead = 0;
|
|
1352
|
+
if (cp) scr_td_put(&out, cp);
|
|
1353
|
+
else {
|
|
1354
|
+
scr_td_error(&out);
|
|
1355
|
+
if (!valid_trail) i--;
|
|
1356
|
+
}
|
|
1357
|
+
continue;
|
|
1358
|
+
}
|
|
1359
|
+
/* ICU's ibm-943_P15A-2003 converter (Node's Shift_JIS backend) has
|
|
1360
|
+
* three historical C0/DEL swaps which its TextDecoder exposes. */
|
|
1361
|
+
if (byte == 0x1a) scr_td_put(&out, 0x1c);
|
|
1362
|
+
else if (byte == 0x1c) scr_td_put(&out, 0x7f);
|
|
1363
|
+
else if (byte == 0x7f) scr_td_put(&out, 0x1a);
|
|
1364
|
+
else if (byte < 0x80) scr_td_put(&out, byte);
|
|
1365
|
+
else if (byte >= 0xa1 && byte <= 0xdf) scr_td_put(&out, 0xff61 + byte - 0xa1);
|
|
1366
|
+
else if ((byte >= 0x81 && byte <= 0x9f) || (byte >= 0xe0 && byte <= 0xfc)) lead = byte;
|
|
1367
|
+
else scr_td_error(&out);
|
|
1368
|
+
}
|
|
1369
|
+
if (lead) scr_td_error(&out);
|
|
1370
|
+
return scr_td_finish(&out);
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
static ScrStr *scr_td_euc_kr_decode(const ScrBytes *b) {
|
|
1374
|
+
ScrTdOut out = scr_td_out_new(b->len);
|
|
1375
|
+
uint8_t lead = 0;
|
|
1376
|
+
for (size_t i = 0; i < b->len; i++) {
|
|
1377
|
+
uint8_t byte = b->data[i];
|
|
1378
|
+
if (lead) {
|
|
1379
|
+
uint32_t cp = 0;
|
|
1380
|
+
if (lead >= 0xa1 && lead <= 0xfe && byte >= 0xa1 && byte <= 0xfe) {
|
|
1381
|
+
cp = scr_td_euc_kr[(lead - 0xa1) * 94 + byte - 0xa1];
|
|
1382
|
+
}
|
|
1383
|
+
lead = 0;
|
|
1384
|
+
if (cp) scr_td_put(&out, cp);
|
|
1385
|
+
else {
|
|
1386
|
+
scr_td_error(&out);
|
|
1387
|
+
if (byte < 0xa0) i--;
|
|
1388
|
+
}
|
|
1389
|
+
continue;
|
|
1390
|
+
}
|
|
1391
|
+
if (byte < 0xa0 && byte != 0x8e && byte != 0x8f) scr_td_put(&out, byte);
|
|
1392
|
+
else if (byte >= 0xa1 && byte <= 0xfe) lead = byte;
|
|
1393
|
+
else scr_td_error(&out);
|
|
1394
|
+
}
|
|
1395
|
+
if (lead) scr_td_error(&out);
|
|
1396
|
+
return scr_td_finish(&out);
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
enum ScrTdIsoState {
|
|
1400
|
+
SCR_TD_ISO_ASCII,
|
|
1401
|
+
SCR_TD_ISO_ROMAN,
|
|
1402
|
+
SCR_TD_ISO_KATAKANA,
|
|
1403
|
+
SCR_TD_ISO_LEAD,
|
|
1404
|
+
SCR_TD_ISO_TRAIL,
|
|
1405
|
+
SCR_TD_ISO_ESCAPE_START,
|
|
1406
|
+
SCR_TD_ISO_ESCAPE,
|
|
1407
|
+
};
|
|
1408
|
+
|
|
1409
|
+
static ScrStr *scr_td_iso_2022_jp_decode(const ScrBytes *b) {
|
|
1410
|
+
ScrTdOut out = scr_td_out_new(b->len);
|
|
1411
|
+
enum ScrTdIsoState state = SCR_TD_ISO_ASCII;
|
|
1412
|
+
enum ScrTdIsoState output_state = SCR_TD_ISO_ASCII;
|
|
1413
|
+
uint8_t lead = 0;
|
|
1414
|
+
int replay = -1;
|
|
1415
|
+
bool output_flag = false;
|
|
1416
|
+
size_t i = 0;
|
|
1417
|
+
bool at_eof = false;
|
|
1418
|
+
while (!at_eof) {
|
|
1419
|
+
int item;
|
|
1420
|
+
if (replay >= 0) {
|
|
1421
|
+
item = replay;
|
|
1422
|
+
replay = -1;
|
|
1423
|
+
} else {
|
|
1424
|
+
item = i < b->len ? b->data[i++] : -1;
|
|
1425
|
+
}
|
|
1426
|
+
uint8_t byte = item < 0 ? 0 : (uint8_t)item;
|
|
1427
|
+
/* ICU treats CR/LF as line boundaries while a non-ASCII designation is
|
|
1428
|
+
* active: emit the separator and resume in ASCII. A pending JIS lead is
|
|
1429
|
+
* different (TRAIL state below) — there the line break completes an
|
|
1430
|
+
* ill-formed pair and remains a replacement, matching Node. */
|
|
1431
|
+
if (item >= 0 && (byte == 0x0a || byte == 0x0d) &&
|
|
1432
|
+
(state == SCR_TD_ISO_KATAKANA || state == SCR_TD_ISO_LEAD)) {
|
|
1433
|
+
output_flag = false;
|
|
1434
|
+
state = output_state = SCR_TD_ISO_ASCII;
|
|
1435
|
+
scr_td_put(&out, byte);
|
|
1436
|
+
continue;
|
|
1437
|
+
}
|
|
1438
|
+
switch (state) {
|
|
1439
|
+
case SCR_TD_ISO_ASCII:
|
|
1440
|
+
case SCR_TD_ISO_ROMAN:
|
|
1441
|
+
case SCR_TD_ISO_KATAKANA:
|
|
1442
|
+
if (item < 0) { at_eof = true; break; }
|
|
1443
|
+
if (byte == 0x1b) { state = SCR_TD_ISO_ESCAPE_START; break; }
|
|
1444
|
+
if (state == SCR_TD_ISO_ROMAN && byte == 0x5c) {
|
|
1445
|
+
output_flag = false; scr_td_put(&out, 0x00a5); break;
|
|
1446
|
+
}
|
|
1447
|
+
if (state == SCR_TD_ISO_ROMAN && byte == 0x7e) {
|
|
1448
|
+
output_flag = false; scr_td_put(&out, 0x203e); break;
|
|
1449
|
+
}
|
|
1450
|
+
if (state == SCR_TD_ISO_KATAKANA && byte >= 0x21 && byte <= 0x5f) {
|
|
1451
|
+
output_flag = false; scr_td_put(&out, 0xff61 + byte - 0x21); break;
|
|
1452
|
+
}
|
|
1453
|
+
if (state != SCR_TD_ISO_KATAKANA && byte < 0x80 && byte != 0x0e && byte != 0x0f) {
|
|
1454
|
+
output_flag = false; scr_td_put(&out, byte); break;
|
|
1455
|
+
}
|
|
1456
|
+
output_flag = false; scr_td_error(&out); break;
|
|
1457
|
+
|
|
1458
|
+
case SCR_TD_ISO_LEAD:
|
|
1459
|
+
if (item < 0) { at_eof = true; break; }
|
|
1460
|
+
if (byte == 0x1b) { state = SCR_TD_ISO_ESCAPE_START; break; }
|
|
1461
|
+
if (byte >= 0x21 && byte <= 0x7e) {
|
|
1462
|
+
output_flag = false; lead = byte; state = SCR_TD_ISO_TRAIL; break;
|
|
1463
|
+
}
|
|
1464
|
+
/* ICU's fixed-width JIS converter folds two adjacent non-starter
|
|
1465
|
+
* bytes into one malformed subsequence. A valid lead, ESC, and the
|
|
1466
|
+
* SO/SI controls begin their own item and must remain queued; CR/LF
|
|
1467
|
+
* following an invalid byte is payload here rather than the line
|
|
1468
|
+
* reset handled above. */
|
|
1469
|
+
if (byte != 0x0e && byte != 0x0f && i < b->len) {
|
|
1470
|
+
uint8_t next = b->data[i];
|
|
1471
|
+
bool starts_item = next == 0x0e || next == 0x0f || next == 0x1b ||
|
|
1472
|
+
(next >= 0x21 && next <= 0x7e);
|
|
1473
|
+
if (!starts_item) i++;
|
|
1474
|
+
}
|
|
1475
|
+
output_flag = false; scr_td_error(&out); break;
|
|
1476
|
+
|
|
1477
|
+
case SCR_TD_ISO_TRAIL:
|
|
1478
|
+
if (item < 0) { state = SCR_TD_ISO_LEAD; scr_td_error(&out); at_eof = true; break; }
|
|
1479
|
+
if (byte == 0x1b) { state = SCR_TD_ISO_ESCAPE_START; scr_td_error(&out); break; }
|
|
1480
|
+
state = SCR_TD_ISO_LEAD;
|
|
1481
|
+
if (byte >= 0x21 && byte <= 0x7e) {
|
|
1482
|
+
uint32_t cp = scr_td_jis0208[(lead - 0x21) * 94 + byte - 0x21];
|
|
1483
|
+
if (cp) scr_td_put(&out, cp); else scr_td_error(&out);
|
|
1484
|
+
} else {
|
|
1485
|
+
scr_td_error(&out);
|
|
1486
|
+
/* SO/SI are standalone illegal items in ICU's JIS state rather
|
|
1487
|
+
* than trails consumed with the pending lead. Replay them so they
|
|
1488
|
+
* each contribute their own replacement. */
|
|
1489
|
+
if (byte == 0x0e || byte == 0x0f) i--;
|
|
1490
|
+
}
|
|
1491
|
+
break;
|
|
1492
|
+
|
|
1493
|
+
case SCR_TD_ISO_ESCAPE_START:
|
|
1494
|
+
if (item >= 0 && (byte == 0x24 || byte == 0x25 || byte == 0x26 ||
|
|
1495
|
+
byte == 0x28 || byte == 0x2e)) {
|
|
1496
|
+
lead = byte; state = SCR_TD_ISO_ESCAPE; break;
|
|
1497
|
+
}
|
|
1498
|
+
/* ICU recognizes ESC O as a complete but unsupported single-shift
|
|
1499
|
+
* escape, consuming the O with the replacement. */
|
|
1500
|
+
if (item >= 0 && byte == 0x4f) {
|
|
1501
|
+
output_flag = false; state = output_state; scr_td_error(&out); break;
|
|
1502
|
+
}
|
|
1503
|
+
if (item >= 0) i--;
|
|
1504
|
+
output_flag = false; state = output_state; scr_td_error(&out);
|
|
1505
|
+
if (item < 0) at_eof = true;
|
|
1506
|
+
break;
|
|
1507
|
+
|
|
1508
|
+
case SCR_TD_ISO_ESCAPE: {
|
|
1509
|
+
enum ScrTdIsoState next = (enum ScrTdIsoState)-1;
|
|
1510
|
+
if (item >= 0 && lead == 0x28 && byte == 0x42) next = SCR_TD_ISO_ASCII;
|
|
1511
|
+
else if (item >= 0 && lead == 0x28 && (byte == 0x48 || byte == 0x4a)) next = SCR_TD_ISO_ROMAN;
|
|
1512
|
+
else if (item >= 0 && lead == 0x28 && byte == 0x49) next = SCR_TD_ISO_KATAKANA;
|
|
1513
|
+
else if (item >= 0 && lead == 0x24 && (byte == 0x40 || byte == 0x42)) next = SCR_TD_ISO_LEAD;
|
|
1514
|
+
if ((int)next >= 0) {
|
|
1515
|
+
state = output_state = next;
|
|
1516
|
+
bool repeated = output_flag;
|
|
1517
|
+
output_flag = !repeated;
|
|
1518
|
+
if (repeated) scr_td_error(&out);
|
|
1519
|
+
break;
|
|
1520
|
+
}
|
|
1521
|
+
/* Some ICU designation families need one more final byte. A known
|
|
1522
|
+
* final consumes the whole four-byte escape as one error; an unknown
|
|
1523
|
+
* final restores both payload bytes and leaves that final queued. */
|
|
1524
|
+
bool extended_prefix =
|
|
1525
|
+
(lead == 0x24 && (byte == 0x28 || byte == 0x29 || byte == 0x2a || byte == 0x2b)) ||
|
|
1526
|
+
(lead == 0x25 && byte == 0x2f);
|
|
1527
|
+
if (extended_prefix) {
|
|
1528
|
+
if (i == b->len) {
|
|
1529
|
+
output_flag = false; state = output_state; scr_td_error(&out);
|
|
1530
|
+
break;
|
|
1531
|
+
}
|
|
1532
|
+
uint8_t final = b->data[i];
|
|
1533
|
+
bool known_final =
|
|
1534
|
+
(lead == 0x24 && byte == 0x28 &&
|
|
1535
|
+
((final >= 0x40 && final <= 0x45) || (final >= 0x47 && final <= 0x4d))) ||
|
|
1536
|
+
(lead == 0x24 && byte == 0x29 &&
|
|
1537
|
+
(final == 0x41 || final == 0x43 || final == 0x45 || final == 0x47)) ||
|
|
1538
|
+
(lead == 0x24 && byte == 0x2a && final == 0x48) ||
|
|
1539
|
+
(lead == 0x24 && byte == 0x2b && final >= 0x49 && final <= 0x4d) ||
|
|
1540
|
+
(lead == 0x25 && byte == 0x2f &&
|
|
1541
|
+
((final >= 0x40 && final <= 0x41) || (final >= 0x43 && final <= 0x46)));
|
|
1542
|
+
if (known_final) {
|
|
1543
|
+
i++;
|
|
1544
|
+
output_flag = false; state = output_state; scr_td_error(&out);
|
|
1545
|
+
break;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
/* ICU consumes the complete unsupported designations it recognizes,
|
|
1549
|
+
* while other malformed payloads are restored to the input queue. */
|
|
1550
|
+
bool consume_error =
|
|
1551
|
+
(lead == 0x24 && byte == 0x41) ||
|
|
1552
|
+
(lead == 0x28 && ((byte >= 0x40 && byte <= 0x47) || byte == 0x4b || byte == 0x52)) ||
|
|
1553
|
+
(lead == 0x25 && byte == 0x42) ||
|
|
1554
|
+
(lead == 0x2e && (byte == 0x41 || byte == 0x46));
|
|
1555
|
+
if (item >= 0 && lead == 0x26 && byte == 0x40) {
|
|
1556
|
+
state = output_state = SCR_TD_ISO_LEAD;
|
|
1557
|
+
bool repeated = output_flag;
|
|
1558
|
+
output_flag = !repeated;
|
|
1559
|
+
if (repeated) scr_td_error(&out);
|
|
1560
|
+
break;
|
|
1561
|
+
}
|
|
1562
|
+
if (item < 0 || consume_error) {
|
|
1563
|
+
output_flag = false; state = output_state; scr_td_error(&out);
|
|
1564
|
+
if (item < 0) at_eof = true;
|
|
1565
|
+
break;
|
|
1566
|
+
}
|
|
1567
|
+
i--;
|
|
1568
|
+
/* The first escape payload byte is restored before the current
|
|
1569
|
+
* byte. Replay it through the full prior state machine: in JIS
|
|
1570
|
+
* mode it can become the lead paired with the current byte. */
|
|
1571
|
+
replay = lead;
|
|
1572
|
+
output_flag = false; state = output_state; scr_td_error(&out);
|
|
1573
|
+
break;
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
return scr_td_finish(&out);
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
ScrStr *scr_text_decode_legacy(const ScrBytes *b, double encoding_value) {
|
|
1581
|
+
unsigned encoding = (unsigned)encoding_value;
|
|
1582
|
+
if (encoding < SCR_TD_SINGLE_COUNT) return scr_td_single_byte(b, encoding);
|
|
1583
|
+
switch (encoding) {
|
|
1584
|
+
case SCR_TD_X_USER_DEFINED: return scr_td_x_user_defined(b);
|
|
1585
|
+
case SCR_TD_UTF16LE: return scr_td_utf16(b, false);
|
|
1586
|
+
case SCR_TD_UTF16BE: return scr_td_utf16(b, true);
|
|
1587
|
+
case SCR_TD_GB18030: return scr_td_gb18030_decode(b);
|
|
1588
|
+
case SCR_TD_BIG5: return scr_td_big5_decode(b);
|
|
1589
|
+
case SCR_TD_EUC_JP: return scr_td_euc_jp_decode(b);
|
|
1590
|
+
case SCR_TD_ISO_2022_JP: return scr_td_iso_2022_jp_decode(b);
|
|
1591
|
+
case SCR_TD_SHIFT_JIS: return scr_td_shift_jis_decode(b);
|
|
1592
|
+
case SCR_TD_EUC_KR: return scr_td_euc_kr_decode(b);
|
|
1593
|
+
default: return scr_str_new("", 0); /* compiler invariant */
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
#endif /* SCR_TEXT_DECODER_LEGACY */
|
|
1597
|
+
|
|
1598
|
+
/* Decode the next code point from an ScrStr's storage — ALWAYS valid
|
|
1599
|
+
* UTF-8 (the string runtime never stores ill-formed sequences), so no
|
|
1600
|
+
* validation re-runs here. */
|
|
1601
|
+
static uint32_t scr_bytes_next_cp(const uint8_t *in, size_t *ip) {
|
|
1602
|
+
uint8_t b = in[*ip];
|
|
1603
|
+
if (b < 0x80) {
|
|
1604
|
+
*ip += 1;
|
|
1605
|
+
return b;
|
|
1606
|
+
}
|
|
1607
|
+
if ((b & 0xe0) == 0xc0) {
|
|
1608
|
+
uint32_t cp = ((uint32_t)(b & 0x1f) << 6) | (in[*ip + 1] & 0x3f);
|
|
1609
|
+
*ip += 2;
|
|
1610
|
+
return cp;
|
|
1611
|
+
}
|
|
1612
|
+
if ((b & 0xf0) == 0xe0) {
|
|
1613
|
+
uint32_t cp = ((uint32_t)(b & 0xf) << 12) | ((uint32_t)(in[*ip + 1] & 0x3f) << 6) |
|
|
1614
|
+
(in[*ip + 2] & 0x3f);
|
|
1615
|
+
*ip += 3;
|
|
1616
|
+
return cp;
|
|
1617
|
+
}
|
|
1618
|
+
uint32_t cp = ((uint32_t)(b & 0x7) << 18) | ((uint32_t)(in[*ip + 1] & 0x3f) << 12) |
|
|
1619
|
+
((uint32_t)(in[*ip + 2] & 0x3f) << 6) | (in[*ip + 3] & 0x3f);
|
|
1620
|
+
*ip += 4;
|
|
1621
|
+
return cp;
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
static bool scr_enc_is(const ScrStr *enc, const char *name) {
|
|
1625
|
+
size_t n = strlen(name);
|
|
1626
|
+
return enc->len == n && memcmp(enc->data, name, n) == 0;
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
/* toString("utf16le"): LE code-unit pairs (an odd tail byte drops, like
|
|
1630
|
+
* Node). Valid surrogate pairs combine into their code point; a LONE
|
|
1631
|
+
* surrogate becomes U+FFFD — Node keeps it as a lone UTF-16 unit, which
|
|
1632
|
+
* UTF-8 string storage cannot hold (SEMANTICS.md divergence; stdout
|
|
1633
|
+
* agrees byte-for-byte because Node's own write replaces it there too). */
|
|
1634
|
+
static ScrStr *scr_bytes_decode_utf16le(const uint8_t *in, size_t n) {
|
|
1635
|
+
size_t units = n / 2;
|
|
1636
|
+
char *out = malloc(units * 3 + 2);
|
|
1637
|
+
if (!out) scr_bytes_oom();
|
|
1638
|
+
size_t o = 0;
|
|
1639
|
+
for (size_t u = 0; u < units; u++) {
|
|
1640
|
+
uint32_t cu = (uint32_t)in[u * 2] | ((uint32_t)in[u * 2 + 1] << 8);
|
|
1641
|
+
if (cu >= 0xd800 && cu <= 0xdbff && u + 1 < units) {
|
|
1642
|
+
uint32_t lo = (uint32_t)in[(u + 1) * 2] | ((uint32_t)in[(u + 1) * 2 + 1] << 8);
|
|
1643
|
+
if (lo >= 0xdc00 && lo <= 0xdfff) {
|
|
1644
|
+
o = scr_bytes_put_cp(out, o, 0x10000 + ((cu - 0xd800) << 10) + (lo - 0xdc00));
|
|
1645
|
+
u++;
|
|
1646
|
+
continue;
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
o = scr_bytes_put_cp(out, o, cu >= 0xd800 && cu <= 0xdfff ? 0xfffd : cu);
|
|
1650
|
+
}
|
|
1651
|
+
ScrStr *s = scr_str_new(out, o);
|
|
1652
|
+
free(out);
|
|
1653
|
+
return s;
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
ScrStr *scr_bytes_to_str(const ScrBytes *b, const ScrStr *enc) {
|
|
1657
|
+
const uint8_t *in = b->data;
|
|
1658
|
+
size_t n = b->len; /* u8: len == byte length */
|
|
1659
|
+
/* Implicit native string/number coercions have no encoding argument. */
|
|
1660
|
+
if (!enc) return scr_bytes_decode_utf8(in, n);
|
|
1661
|
+
if (scr_enc_is(enc, "hex")) {
|
|
1662
|
+
char *out = malloc(n * 2 + 1);
|
|
1663
|
+
if (!out) scr_bytes_oom();
|
|
1664
|
+
for (size_t i = 0; i < n; i++) {
|
|
1665
|
+
out[i * 2] = scr_hex_digits[in[i] >> 4];
|
|
1666
|
+
out[i * 2 + 1] = scr_hex_digits[in[i] & 0xf];
|
|
1667
|
+
}
|
|
1668
|
+
ScrStr *s = scr_str_new(out, n * 2);
|
|
1669
|
+
free(out);
|
|
1670
|
+
return s;
|
|
1671
|
+
}
|
|
1672
|
+
if (scr_enc_is(enc, "base64")) return scr_bytes_encode_b64(in, n, false);
|
|
1673
|
+
if (scr_enc_is(enc, "base64url")) return scr_bytes_encode_b64(in, n, true);
|
|
1674
|
+
if (scr_enc_is(enc, "latin1")) {
|
|
1675
|
+
/* Each byte is U+00XX ("binary" normalizes here upstream). */
|
|
1676
|
+
char *out = malloc(n * 2 + 1);
|
|
1677
|
+
if (!out) scr_bytes_oom();
|
|
1678
|
+
size_t o = 0;
|
|
1679
|
+
for (size_t i = 0; i < n; i++) o = scr_bytes_put_cp(out, o, in[i]);
|
|
1680
|
+
ScrStr *s = scr_str_new(out, o);
|
|
1681
|
+
free(out);
|
|
1682
|
+
return s;
|
|
1683
|
+
}
|
|
1684
|
+
if (scr_enc_is(enc, "ascii")) {
|
|
1685
|
+
/* Node's ascii decode masks the high bit: byte & 0x7f. */
|
|
1686
|
+
char *out = malloc(n + 1);
|
|
1687
|
+
if (!out) scr_bytes_oom();
|
|
1688
|
+
for (size_t i = 0; i < n; i++) out[i] = (char)(in[i] & 0x7f);
|
|
1689
|
+
ScrStr *s = scr_str_new(out, n);
|
|
1690
|
+
free(out);
|
|
1691
|
+
return s;
|
|
1692
|
+
}
|
|
1693
|
+
if (scr_enc_is(enc, "utf16le")) return scr_bytes_decode_utf16le(in, n);
|
|
1694
|
+
/* utf8 (the compiler completes an omitted encoding to "utf8") */
|
|
1695
|
+
return scr_bytes_decode_utf8(in, n);
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
/* Buffer.toString with a runtime-valued encoding. Literal call sites fold
|
|
1699
|
+
* this same alias table in the frontend; variables arrive here, where Node
|
|
1700
|
+
* also accepts ASCII case variants and rejects unknown names catchably. */
|
|
1701
|
+
static bool scr_enc_eq_ci(const ScrStr *raw, const char *name) {
|
|
1702
|
+
size_t n = strlen(name);
|
|
1703
|
+
if (raw->len != n) return false;
|
|
1704
|
+
for (size_t i = 0; i < n; i++) {
|
|
1705
|
+
char c = raw->data[i];
|
|
1706
|
+
if (c >= 'A' && c <= 'Z') c = (char)(c + ('a' - 'A'));
|
|
1707
|
+
if (c != name[i]) return false;
|
|
1708
|
+
}
|
|
1709
|
+
return true;
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
static ScrStr *scr_bytes_normalize_encoding(const ScrStr *raw) {
|
|
1713
|
+
static const struct { const char *from; const char *to; } map[] = {
|
|
1714
|
+
{"utf8", "utf8"}, {"utf-8", "utf8"}, {"hex", "hex"},
|
|
1715
|
+
{"base64", "base64"}, {"base64url", "base64url"},
|
|
1716
|
+
{"latin1", "latin1"}, {"binary", "latin1"}, {"ascii", "ascii"},
|
|
1717
|
+
{"utf16le", "utf16le"}, {"utf-16le", "utf16le"},
|
|
1718
|
+
{"ucs2", "utf16le"}, {"ucs-2", "utf16le"},
|
|
1719
|
+
};
|
|
1720
|
+
for (size_t i = 0; i < sizeof map / sizeof map[0]; i++) {
|
|
1721
|
+
if (scr_enc_eq_ci(raw, map[i].from)) {
|
|
1722
|
+
return scr_str_new(map[i].to, strlen(map[i].to));
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
static const char prefix[] = "Unknown encoding: ";
|
|
1726
|
+
const size_t prefix_len = sizeof prefix - 1;
|
|
1727
|
+
if (raw->len > SIZE_MAX - prefix_len) scr_bytes_oom();
|
|
1728
|
+
const size_t msg_len = prefix_len + raw->len;
|
|
1729
|
+
char *msg = malloc(msg_len);
|
|
1730
|
+
if (!msg) scr_bytes_oom();
|
|
1731
|
+
memcpy(msg, prefix, prefix_len);
|
|
1732
|
+
memcpy(msg + prefix_len, raw->data, raw->len);
|
|
1733
|
+
scr_throw_error_msg_code(SCR_ERR_TYPE, msg, msg_len,
|
|
1734
|
+
"ERR_UNKNOWN_ENCODING");
|
|
1735
|
+
free(msg);
|
|
1736
|
+
return NULL;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
ScrStr *scr_bytes_to_str_checked(const ScrBytes *b, const ScrStr *enc) {
|
|
1740
|
+
/* Node returns before resolving the encoding when there are no bytes
|
|
1741
|
+
* to decode, so even an unknown runtime name answers the empty string. */
|
|
1742
|
+
if (b->len == 0) return scr_str_new("", 0);
|
|
1743
|
+
ScrStr *normalized = scr_bytes_normalize_encoding(enc);
|
|
1744
|
+
if (!normalized) return NULL;
|
|
1745
|
+
ScrStr *out = scr_bytes_to_str(b, normalized);
|
|
1746
|
+
scr_str_release(normalized);
|
|
1747
|
+
return out;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
ScrStr *scr_bytes_to_str_checked_range(const ScrBytes *b, const ScrStr *enc,
|
|
1751
|
+
double start, double end) {
|
|
1752
|
+
/* The range is selected before Node resolves the encoding. A clamped
|
|
1753
|
+
* empty window therefore answers "" even for an unknown name. */
|
|
1754
|
+
size_t s0, e0;
|
|
1755
|
+
scr_bytes_to_str_bounds(b, start, end, &s0, &e0);
|
|
1756
|
+
if (s0 == e0) return scr_str_new("", 0);
|
|
1757
|
+
ScrStr *normalized = scr_bytes_normalize_encoding(enc);
|
|
1758
|
+
if (!normalized) return NULL;
|
|
1759
|
+
ScrStr *out = scr_bytes_to_str_range(b, normalized, start, end);
|
|
1760
|
+
scr_str_release(normalized);
|
|
1761
|
+
return out;
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
static int scr_hex_val(uint8_t c) {
|
|
1765
|
+
if (c >= '0' && c <= '9') return c - '0';
|
|
1766
|
+
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
|
|
1767
|
+
if (c >= 'A' && c <= 'F') return c - 'A' + 10;
|
|
1768
|
+
return -1;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
static int scr_b64_val(uint8_t c) {
|
|
1772
|
+
if (c >= 'A' && c <= 'Z') return c - 'A';
|
|
1773
|
+
if (c >= 'a' && c <= 'z') return c - 'a' + 26;
|
|
1774
|
+
if (c >= '0' && c <= '9') return c - '0' + 52;
|
|
1775
|
+
if (c == '+' || c == '-') return 62; /* '-': base64url, accepted like Node */
|
|
1776
|
+
if (c == '/' || c == '_') return 63; /* '_': base64url */
|
|
1777
|
+
return -1;
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
ScrBytes *scr_bytes_from_str(const ScrStr *s, const ScrStr *enc) {
|
|
1781
|
+
const uint8_t *in = (const uint8_t *)s->data;
|
|
1782
|
+
size_t n = s->len;
|
|
1783
|
+
if (scr_enc_is(enc, "latin1") || scr_enc_is(enc, "ascii")) {
|
|
1784
|
+
/* Node writes charCodeAt(i) & 0xFF for BOTH spellings — an astral
|
|
1785
|
+
* code point contributes its two surrogates' low bytes. */
|
|
1786
|
+
ScrBytes *b = scr_bytes_alloc(SCR_BYTES_U8, n);
|
|
1787
|
+
size_t o = 0, i = 0;
|
|
1788
|
+
while (i < n) {
|
|
1789
|
+
uint32_t cp = scr_bytes_next_cp(in, &i);
|
|
1790
|
+
if (cp > 0xffff) {
|
|
1791
|
+
cp -= 0x10000;
|
|
1792
|
+
b->data[o++] = (uint8_t)(0xd800 + (cp >> 10));
|
|
1793
|
+
b->data[o++] = (uint8_t)(0xdc00 + (cp & 0x3ff));
|
|
1794
|
+
} else {
|
|
1795
|
+
b->data[o++] = (uint8_t)cp;
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
b->len = o; /* never grows past n: multi-byte cps shrink */
|
|
1799
|
+
return b;
|
|
1800
|
+
}
|
|
1801
|
+
if (scr_enc_is(enc, "utf16le")) {
|
|
1802
|
+
ScrBytes *b = scr_bytes_alloc(SCR_BYTES_U8, n * 2);
|
|
1803
|
+
size_t o = 0, i = 0;
|
|
1804
|
+
while (i < n) {
|
|
1805
|
+
uint32_t cp = scr_bytes_next_cp(in, &i);
|
|
1806
|
+
if (cp > 0xffff) {
|
|
1807
|
+
cp -= 0x10000;
|
|
1808
|
+
uint32_t hi = 0xd800 + (cp >> 10), lo = 0xdc00 + (cp & 0x3ff);
|
|
1809
|
+
b->data[o++] = (uint8_t)hi;
|
|
1810
|
+
b->data[o++] = (uint8_t)(hi >> 8);
|
|
1811
|
+
b->data[o++] = (uint8_t)lo;
|
|
1812
|
+
b->data[o++] = (uint8_t)(lo >> 8);
|
|
1813
|
+
} else {
|
|
1814
|
+
b->data[o++] = (uint8_t)cp;
|
|
1815
|
+
b->data[o++] = (uint8_t)(cp >> 8);
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
b->len = o;
|
|
1819
|
+
return b;
|
|
1820
|
+
}
|
|
1821
|
+
if (enc->len == 3 && memcmp(enc->data, "hex", 3) == 0) {
|
|
1822
|
+
/* Node-lenient: parse pairs, stop at the first invalid pair or the
|
|
1823
|
+
* odd tail (Buffer.from("a1g2", "hex") is <Buffer a1>). */
|
|
1824
|
+
ScrBytes *b = scr_bytes_alloc(SCR_BYTES_U8, n / 2);
|
|
1825
|
+
size_t o = 0;
|
|
1826
|
+
for (size_t i = 0; i + 1 < n; i += 2) {
|
|
1827
|
+
int hi = scr_hex_val(in[i]);
|
|
1828
|
+
int lo = scr_hex_val(in[i + 1]);
|
|
1829
|
+
if (hi < 0 || lo < 0) break;
|
|
1830
|
+
b->data[o++] = (uint8_t)((hi << 4) | lo);
|
|
1831
|
+
}
|
|
1832
|
+
b->len = o; /* never grows: shrinking the count is safe */
|
|
1833
|
+
return b;
|
|
1834
|
+
}
|
|
1835
|
+
if (scr_enc_is(enc, "base64") || scr_enc_is(enc, "base64url")) {
|
|
1836
|
+
/* Node-lenient: skip bytes outside the (standard + url-safe)
|
|
1837
|
+
* alphabets — whitespace, '=', stray punctuation; decode 4-char
|
|
1838
|
+
* groups, and a 2/3-char tail into 1/2 bytes. Both spellings share
|
|
1839
|
+
* the decoder (Node accepts either alphabet under either name). */
|
|
1840
|
+
ScrBytes *b = scr_bytes_alloc(SCR_BYTES_U8, n / 4 * 3 + 2);
|
|
1841
|
+
size_t o = 0;
|
|
1842
|
+
unsigned acc = 0;
|
|
1843
|
+
int have = 0;
|
|
1844
|
+
for (size_t i = 0; i < n; i++) {
|
|
1845
|
+
int v = scr_b64_val(in[i]);
|
|
1846
|
+
if (v < 0) continue;
|
|
1847
|
+
acc = (acc << 6) | (unsigned)v;
|
|
1848
|
+
if (++have == 4) {
|
|
1849
|
+
b->data[o++] = (uint8_t)(acc >> 16);
|
|
1850
|
+
b->data[o++] = (uint8_t)(acc >> 8);
|
|
1851
|
+
b->data[o++] = (uint8_t)acc;
|
|
1852
|
+
acc = 0;
|
|
1853
|
+
have = 0;
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
if (have == 2) b->data[o++] = (uint8_t)(acc >> 4);
|
|
1857
|
+
else if (have == 3) {
|
|
1858
|
+
b->data[o++] = (uint8_t)(acc >> 10);
|
|
1859
|
+
b->data[o++] = (uint8_t)(acc >> 2);
|
|
1860
|
+
}
|
|
1861
|
+
b->len = o;
|
|
1862
|
+
return b;
|
|
1863
|
+
}
|
|
1864
|
+
/* utf8: ScrStr storage IS the bytes */
|
|
1865
|
+
ScrBytes *b = scr_bytes_alloc(SCR_BYTES_U8, n);
|
|
1866
|
+
memcpy(b->data, in, n);
|
|
1867
|
+
return b;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
ScrBytes *scr_bytes_from_arr(ScrBytesElem elem, const ScrArr *arr) {
|
|
1871
|
+
ScrBytes *b = scr_bytes_alloc(elem, arr->len);
|
|
1872
|
+
for (size_t i = 0; i < arr->len; i++) {
|
|
1873
|
+
// Iteration reads holes as undefined: floating arrays store NaN and
|
|
1874
|
+
// integer arrays store zero through their normal element conversion.
|
|
1875
|
+
scr_bytes_set(b, (double)i, scr_arr_get_number(arr, (double)i));
|
|
1876
|
+
}
|
|
1877
|
+
return b;
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
/* ── equals / compare / indexOf / fill / copy / swap / write (u8; the
|
|
1881
|
+
* error ladders mirror Node's validateOffset — 'an integer' first, then
|
|
1882
|
+
* the '>= 0 && <= max' render, ERR_OUT_OF_RANGE's Received rules — and
|
|
1883
|
+
* copy's C++-side ladder; pinned by corpus 1663) ─────────────────────── */
|
|
1884
|
+
|
|
1885
|
+
size_t scr_num_received(double v, char out[48]); /* the numeric section below */
|
|
1886
|
+
|
|
1887
|
+
/* validateOffset(name, 0, max): non-integers are 'an integer' (Number.
|
|
1888
|
+
* isInteger — ±Infinity render 'an integer' too), the rest '>= 0 && <=
|
|
1889
|
+
* max' (Node spells '&&' here, unlike the read/write families' 'and').
|
|
1890
|
+
* max < 0 means copy's no-upper-bound '>= 0' render. Exported: the
|
|
1891
|
+
* checked-dynamic compare/equals validators (scr_bytes_io.c) run the
|
|
1892
|
+
* same ladder after their own type gate. */
|
|
1893
|
+
bool scr_bytes_validate_off(const char *name, double value, double max) {
|
|
1894
|
+
if (isfinite(value) && floor(value) == value && value >= 0 && (max < 0 || value <= max)) return true;
|
|
1895
|
+
char recv[48];
|
|
1896
|
+
scr_num_received(value, recv);
|
|
1897
|
+
char msg[160];
|
|
1898
|
+
int mlen;
|
|
1899
|
+
if (floor(value) != value || !isfinite(value)) {
|
|
1900
|
+
mlen = snprintf(msg, sizeof msg,
|
|
1901
|
+
"The value of \"%s\" is out of range. It must be an integer. Received %s",
|
|
1902
|
+
name, recv);
|
|
1903
|
+
} else if (max < 0) {
|
|
1904
|
+
mlen = snprintf(msg, sizeof msg,
|
|
1905
|
+
"The value of \"%s\" is out of range. It must be >= 0. Received %s", name, recv);
|
|
1906
|
+
} else {
|
|
1907
|
+
char maxb[32];
|
|
1908
|
+
scr_f64_to_str(max, maxb);
|
|
1909
|
+
mlen = snprintf(msg, sizeof msg,
|
|
1910
|
+
"The value of \"%s\" is out of range. It must be >= 0 && <= %s. Received %s",
|
|
1911
|
+
name, maxb, recv);
|
|
1912
|
+
}
|
|
1913
|
+
scr_throw_error_msg_code(SCR_ERR_RANGE, msg, (size_t)mlen, "ERR_OUT_OF_RANGE");
|
|
1914
|
+
return false;
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
bool scr_bytes_equals(const ScrBytes *a, const ScrBytes *b) {
|
|
1918
|
+
return a->len == b->len && memcmp(a->data, b->data, a->len) == 0;
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
/* src.compare(target, targetStart?, targetEnd?, sourceStart?, sourceEnd?)
|
|
1922
|
+
* — nargs counts the PRESENT index args (defaults skip validation, like
|
|
1923
|
+
* Node). Empty-range shortcuts and the memcmp-with-length-tiebreak are
|
|
1924
|
+
* Node's exactly. */
|
|
1925
|
+
double scr_bytes_compare(const ScrBytes *src, const ScrBytes *target, double nargs,
|
|
1926
|
+
double ts, double te, double ss, double se) {
|
|
1927
|
+
size_t n = (size_t)nargs;
|
|
1928
|
+
if (n < 1) ts = 0;
|
|
1929
|
+
else if (!scr_bytes_validate_off("targetStart", ts, 9007199254740991.0)) return 0;
|
|
1930
|
+
if (n < 2) te = (double)target->len;
|
|
1931
|
+
else if (!scr_bytes_validate_off("targetEnd", te, (double)target->len)) return 0;
|
|
1932
|
+
if (n < 3) ss = 0;
|
|
1933
|
+
else if (!scr_bytes_validate_off("sourceStart", ss, 9007199254740991.0)) return 0;
|
|
1934
|
+
if (n < 4) se = (double)src->len;
|
|
1935
|
+
else if (!scr_bytes_validate_off("sourceEnd", se, (double)src->len)) return 0;
|
|
1936
|
+
if (ts >= te) return ss >= se ? 0 : 1;
|
|
1937
|
+
if (ss >= se) return -1;
|
|
1938
|
+
/* Clamp the starts into range (a start past the length reads empty —
|
|
1939
|
+
* handled above; here both windows are non-empty). */
|
|
1940
|
+
size_t t0 = ts > (double)target->len ? target->len : (size_t)ts;
|
|
1941
|
+
size_t s0 = ss > (double)src->len ? src->len : (size_t)ss;
|
|
1942
|
+
size_t tn = (size_t)te - t0, sn = (size_t)se - s0;
|
|
1943
|
+
size_t m = sn < tn ? sn : tn;
|
|
1944
|
+
int c = memcmp(src->data + s0, target->data + t0, m);
|
|
1945
|
+
if (c != 0) return c < 0 ? -1 : 1;
|
|
1946
|
+
if (sn == tn) return 0;
|
|
1947
|
+
return sn < tn ? -1 : 1;
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
/* The shared search core: needle bytes, a coerced byteOffset (trunc; NaN
|
|
1951
|
+
* means 'search everything' — 0 forward, the end backward; negatives
|
|
1952
|
+
* count from the end, and a still-negative backward search answers -1),
|
|
1953
|
+
* and the utf16le alignment stride. */
|
|
1954
|
+
double scr_bytes_index_of(const ScrBytes *b, const ScrBytes *needle, double off, double align, bool fwd) {
|
|
1955
|
+
size_t len = b->len, nlen = needle->len;
|
|
1956
|
+
size_t step = align == 2 ? 2 : 1;
|
|
1957
|
+
double o = (off != off) ? (fwd ? 0 : (double)len) : trunc(off);
|
|
1958
|
+
if (o < 0) {
|
|
1959
|
+
o += (double)len;
|
|
1960
|
+
if (o < 0) {
|
|
1961
|
+
if (!fwd) return -1;
|
|
1962
|
+
o = 0;
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
if (nlen == 0) return o > (double)len ? (double)len : o; /* '' matches at the clamp */
|
|
1966
|
+
if (nlen > len) return -1;
|
|
1967
|
+
if (fwd) {
|
|
1968
|
+
size_t start = o > (double)len ? len : (size_t)o;
|
|
1969
|
+
if (step == 2) start += start % 2;
|
|
1970
|
+
for (size_t i = start; i + nlen <= len; i += step) {
|
|
1971
|
+
if (memcmp(b->data + i, needle->data, nlen) == 0) return (double)i;
|
|
1972
|
+
}
|
|
1973
|
+
return -1;
|
|
1974
|
+
}
|
|
1975
|
+
size_t start = o > (double)(len - nlen) ? len - nlen : (size_t)o;
|
|
1976
|
+
if (step == 2) start -= start % 2;
|
|
1977
|
+
for (size_t i = start;; i -= step) {
|
|
1978
|
+
if (memcmp(b->data + i, needle->data, nlen) == 0) return (double)i;
|
|
1979
|
+
if (i < step) break;
|
|
1980
|
+
}
|
|
1981
|
+
return -1;
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
double scr_bytes_index_of_num(const ScrBytes *b, double v, double off, bool fwd) {
|
|
1985
|
+
uint8_t byte = (uint8_t)scr_bytes_to_u32(v);
|
|
1986
|
+
ScrBytes needle = { .rc = 1, .len = 1, .elem = SCR_BYTES_U8, .data = &byte, .backing = NULL };
|
|
1987
|
+
return scr_bytes_index_of(b, &needle, off, 1, fwd);
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
/* fill's shared core over a normalized byte pattern. nargs counts the
|
|
1991
|
+
* present offset/end args. An EMPTY pattern zero-fills when zero_ok
|
|
1992
|
+
* (Node's '' string) and is the constant TypeError otherwise (an empty
|
|
1993
|
+
* Uint8Array value). Returns the receiver (+1) — fill chains. */
|
|
1994
|
+
static ScrBytes *scr_bytes_fill_core(ScrBytes *b, const uint8_t *pat, size_t patn,
|
|
1995
|
+
bool zero_ok, double nargs, double offset, double end) {
|
|
1996
|
+
if (patn == 0 && !zero_ok) {
|
|
1997
|
+
static const char msg[] = "The argument 'value' is invalid. Received <Buffer >";
|
|
1998
|
+
scr_throw_error_msg_code(SCR_ERR_TYPE, msg, sizeof msg - 1, "ERR_INVALID_ARG_VALUE");
|
|
1999
|
+
return NULL;
|
|
2000
|
+
}
|
|
2001
|
+
size_t n = (size_t)nargs;
|
|
2002
|
+
if (n < 1) offset = 0;
|
|
2003
|
+
else if (!scr_bytes_validate_off("offset", offset, 9007199254740991.0)) return NULL;
|
|
2004
|
+
if (n < 2) end = (double)b->len;
|
|
2005
|
+
else if (!scr_bytes_validate_off("end", end, (double)b->len)) return NULL;
|
|
2006
|
+
if (offset < end) {
|
|
2007
|
+
size_t o = (size_t)offset > b->len ? b->len : (size_t)offset;
|
|
2008
|
+
size_t e = (size_t)end;
|
|
2009
|
+
if (patn == 0) {
|
|
2010
|
+
memset(b->data + o, 0, e - o);
|
|
2011
|
+
} else if (patn == 1) {
|
|
2012
|
+
memset(b->data + o, pat[0], e - o);
|
|
2013
|
+
} else {
|
|
2014
|
+
for (size_t i = o; i < e; i++) b->data[i] = pat[(i - o) % patn];
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
return scr_bytes_retain(b);
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
ScrBytes *scr_bytes_fill(ScrBytes *b, const ScrBytes *pattern, double nargs, double offset, double end) {
|
|
2021
|
+
return scr_bytes_fill_core(b, pattern->data, pattern->len, false, nargs, offset, end);
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
ScrBytes *scr_bytes_fill_num(ScrBytes *b, double v, double nargs, double offset, double end) {
|
|
2025
|
+
uint8_t byte = (uint8_t)scr_bytes_to_u32(v);
|
|
2026
|
+
return scr_bytes_fill_core(b, &byte, 1, false, nargs, offset, end);
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
ScrBytes *scr_bytes_fill_str(ScrBytes *b, const ScrStr *s, const ScrStr *enc,
|
|
2030
|
+
double nargs, double offset, double end) {
|
|
2031
|
+
ScrBytes *pat = scr_bytes_from_str(s, enc);
|
|
2032
|
+
ScrBytes *r = scr_bytes_fill_core(b, pat->data, pat->len, true, nargs, offset, end);
|
|
2033
|
+
scr_bytes_release(pat);
|
|
2034
|
+
return r;
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
/* src.copy(dst, targetStart?, sourceStart?, sourceEnd?): Node's C++-side
|
|
2038
|
+
* ladder — fractional indices TRUNCATE silently, targetStart/sourceEnd
|
|
2039
|
+
* check only >= 0 (past-the-end clamps to nothing), sourceStart is
|
|
2040
|
+
* bounded by the source length. Returns the byte count copied. */
|
|
2041
|
+
double scr_bytes_copy_into(const ScrBytes *src, ScrBytes *dst, double nargs,
|
|
2042
|
+
double ts, double ss, double se) {
|
|
2043
|
+
size_t n = (size_t)nargs;
|
|
2044
|
+
ts = n < 1 ? 0 : trunc(ts);
|
|
2045
|
+
ss = n < 2 ? 0 : trunc(ss);
|
|
2046
|
+
se = n < 3 ? (double)src->len : trunc(se);
|
|
2047
|
+
if (!scr_bytes_validate_off("targetStart", ts, -1)) return 0;
|
|
2048
|
+
if (!scr_bytes_validate_off("sourceStart", ss, (double)src->len)) return 0;
|
|
2049
|
+
if (!scr_bytes_validate_off("sourceEnd", se, -1)) return 0;
|
|
2050
|
+
if (ts >= (double)dst->len) return 0;
|
|
2051
|
+
size_t t0 = (size_t)ts;
|
|
2052
|
+
size_t s0 = (size_t)ss;
|
|
2053
|
+
size_t e0 = se > (double)src->len ? src->len : (size_t)se;
|
|
2054
|
+
if (s0 >= e0) return 0;
|
|
2055
|
+
size_t count = e0 - s0;
|
|
2056
|
+
if (count > dst->len - t0) count = dst->len - t0;
|
|
2057
|
+
memmove(dst->data + t0, src->data + s0, count);
|
|
2058
|
+
return (double)count;
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
/* swap16/32/64: in-place byte reversal per group; the receiver answers
|
|
2062
|
+
* (+1, chaining like fill). A length off the width is Node's constant
|
|
2063
|
+
* ERR_INVALID_BUFFER_SIZE RangeError. */
|
|
2064
|
+
ScrBytes *scr_bytes_swap(ScrBytes *b, double width) {
|
|
2065
|
+
size_t w = (size_t)width;
|
|
2066
|
+
if (b->len % w != 0) {
|
|
2067
|
+
char msg[64];
|
|
2068
|
+
int mlen = snprintf(msg, sizeof msg, "Buffer size must be a multiple of %zu-bits", w * 8);
|
|
2069
|
+
scr_throw_error_msg_code(SCR_ERR_RANGE, msg, (size_t)mlen, "ERR_INVALID_BUFFER_SIZE");
|
|
2070
|
+
return NULL;
|
|
2071
|
+
}
|
|
2072
|
+
for (size_t g = 0; g < b->len; g += w) {
|
|
2073
|
+
for (size_t i = 0; i < w / 2; i++) {
|
|
2074
|
+
uint8_t t = b->data[g + i];
|
|
2075
|
+
b->data[g + i] = b->data[g + w - 1 - i];
|
|
2076
|
+
b->data[g + w - 1 - i] = t;
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
return scr_bytes_retain(b);
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
/* buf.write(string, offset?, length?, enc): encodes, clamps the byte
|
|
2083
|
+
* budget (offset and an explicit length validate against the buffer
|
|
2084
|
+
* length with Node's '&&' render; the length then clamps to the space
|
|
2085
|
+
* left), and truncates at a UNIT boundary — whole UTF-8 code points,
|
|
2086
|
+
* whole utf16le code units (a surrogate pair CAN split — Node writes the
|
|
2087
|
+
* lone lead), byte-level for the rest. Returns the bytes written. */
|
|
2088
|
+
double scr_bytes_write_str(ScrBytes *b, const ScrStr *s, const ScrStr *enc,
|
|
2089
|
+
double offset, double len, bool has_len) {
|
|
2090
|
+
if (!scr_bytes_validate_off("offset", offset, (double)b->len)) return 0;
|
|
2091
|
+
size_t o = (size_t)offset;
|
|
2092
|
+
size_t remaining = b->len - o;
|
|
2093
|
+
size_t budget;
|
|
2094
|
+
if (has_len) {
|
|
2095
|
+
if (!scr_bytes_validate_off("length", len, (double)b->len)) return 0;
|
|
2096
|
+
budget = (size_t)len > remaining ? remaining : (size_t)len;
|
|
2097
|
+
} else {
|
|
2098
|
+
budget = remaining;
|
|
2099
|
+
}
|
|
2100
|
+
ScrBytes *encd = scr_bytes_from_str(s, enc);
|
|
2101
|
+
size_t k = encd->len < budget ? encd->len : budget;
|
|
2102
|
+
if (k < encd->len) {
|
|
2103
|
+
if (scr_enc_is(enc, "utf16le")) {
|
|
2104
|
+
k -= k % 2;
|
|
2105
|
+
} else if (!scr_enc_is(enc, "hex") && !scr_enc_is(enc, "base64") &&
|
|
2106
|
+
!scr_enc_is(enc, "base64url") && !scr_enc_is(enc, "latin1") &&
|
|
2107
|
+
!scr_enc_is(enc, "ascii")) {
|
|
2108
|
+
/* utf8: back off a split multi-byte sequence (whole chars only). */
|
|
2109
|
+
size_t lead = k;
|
|
2110
|
+
while (lead > 0 && (encd->data[lead] & 0xc0) == 0x80) lead--;
|
|
2111
|
+
if (lead < k) {
|
|
2112
|
+
uint8_t l = encd->data[lead];
|
|
2113
|
+
size_t need = (l & 0xf8) == 0xf0 ? 4 : (l & 0xf0) == 0xe0 ? 3 : (l & 0xe0) == 0xc0 ? 2 : 1;
|
|
2114
|
+
if (lead + need > k) k = lead;
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
memcpy(b->data + o, encd->data, k);
|
|
2119
|
+
scr_bytes_release(encd);
|
|
2120
|
+
return (double)k;
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2123
|
+
/* Buffer.concat(list, totalLength): the same concatenation truncated or
|
|
2124
|
+
* zero-padded to the validated total. */
|
|
2125
|
+
static ScrBytes *scr_bytes_concat_item(const ScrArr *list, size_t i) {
|
|
2126
|
+
if (!scr_arr_has(list, (double)i)) {
|
|
2127
|
+
char msg[160];
|
|
2128
|
+
int n = snprintf(
|
|
2129
|
+
msg, sizeof msg,
|
|
2130
|
+
"The \"list[%zu]\" argument must be an instance of Buffer or Uint8Array. Received undefined",
|
|
2131
|
+
i);
|
|
2132
|
+
scr_throw_error_msg_code(SCR_ERR_TYPE, msg, n < 0 ? 0 : (size_t)n,
|
|
2133
|
+
"ERR_INVALID_ARG_TYPE");
|
|
2134
|
+
return NULL;
|
|
2135
|
+
}
|
|
2136
|
+
ScrBytes *part = (ScrBytes *)scr_arr_get_ref((ScrArr *)list, (double)i);
|
|
2137
|
+
if (!part) {
|
|
2138
|
+
char msg[160];
|
|
2139
|
+
int n = snprintf(
|
|
2140
|
+
msg, sizeof msg,
|
|
2141
|
+
"The \"list[%zu]\" argument must be an instance of Buffer or Uint8Array. Received undefined",
|
|
2142
|
+
i);
|
|
2143
|
+
scr_throw_error_msg_code(SCR_ERR_TYPE, msg, n < 0 ? 0 : (size_t)n,
|
|
2144
|
+
"ERR_INVALID_ARG_TYPE");
|
|
2145
|
+
}
|
|
2146
|
+
return part;
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
ScrBytes *scr_bytes_concat_len(const ScrArr *list, double total) {
|
|
2150
|
+
/* An empty list short-circuits BEFORE the total validates — Node's
|
|
2151
|
+
* own `if (list.length === 0) return new FastBuffer()`. */
|
|
2152
|
+
if (list->len == 0) return scr_bytes_alloc(SCR_BYTES_U8, 0);
|
|
2153
|
+
if (!scr_bytes_validate_off("length", total, 9007199254740991.0)) return NULL;
|
|
2154
|
+
ScrBytes *b = scr_bytes_alloc(SCR_BYTES_U8, (size_t)total);
|
|
2155
|
+
size_t o = 0;
|
|
2156
|
+
for (size_t i = 0; i < list->len && o < b->len; i++) {
|
|
2157
|
+
ScrBytes *part = scr_bytes_concat_item(list, i);
|
|
2158
|
+
if (!part) {
|
|
2159
|
+
scr_bytes_release(b);
|
|
2160
|
+
return NULL;
|
|
2161
|
+
}
|
|
2162
|
+
size_t take = part->len < b->len - o ? part->len : b->len - o;
|
|
2163
|
+
memcpy(b->data + o, part->data, take);
|
|
2164
|
+
o += take;
|
|
2165
|
+
scr_bytes_release(part);
|
|
2166
|
+
}
|
|
2167
|
+
return b;
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
/* Buffer.byteLength(string, enc): utf8 is the storage length (ScrStr IS
|
|
2171
|
+
* utf8 bytes), latin1/ascii count UTF-16 units, utf16le doubles them,
|
|
2172
|
+
* hex halves the length, base64/base64url use Node's padding-trimmed
|
|
2173
|
+
* (len * 3) >>> 2. The enc arrives NORMALIZED (the compiler folds
|
|
2174
|
+
* aliases). */
|
|
2175
|
+
double scr_bytes_byte_length_str(ScrStr *s, const ScrStr *enc) {
|
|
2176
|
+
if (scr_enc_is(enc, "latin1") || scr_enc_is(enc, "ascii")) {
|
|
2177
|
+
return scr_str_utf16_len(s);
|
|
2178
|
+
}
|
|
2179
|
+
if (scr_enc_is(enc, "utf16le")) return 2 * scr_str_utf16_len(s);
|
|
2180
|
+
if (scr_enc_is(enc, "hex")) {
|
|
2181
|
+
return floor(scr_str_utf16_len(s) / 2);
|
|
2182
|
+
}
|
|
2183
|
+
if (scr_enc_is(enc, "base64") || scr_enc_is(enc, "base64url")) {
|
|
2184
|
+
size_t units = (size_t)scr_str_utf16_len(s);
|
|
2185
|
+
/* Trailing '=' padding trims (at most two) — checked on the raw
|
|
2186
|
+
* bytes: '=' is ASCII, so the last byte IS the last unit. */
|
|
2187
|
+
if (units > 0 && s->len >= 1 && s->data[s->len - 1] == '=') units--;
|
|
2188
|
+
if (units > 1 && s->len >= 2 && s->data[s->len - 2] == '=') units--;
|
|
2189
|
+
return (double)((units * 3) >> 2);
|
|
2190
|
+
}
|
|
2191
|
+
return (double)s->len; /* utf8 */
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
/* Buffer.isEncoding(name): case-insensitive over Node's alias set. */
|
|
2195
|
+
bool scr_bytes_is_encoding(const ScrStr *s) {
|
|
2196
|
+
static const char *const names[] = {
|
|
2197
|
+
"utf8", "utf-8", "ascii", "latin1", "binary", "base64",
|
|
2198
|
+
"hex", "ucs2", "ucs-2", "utf16le", "utf-16le", "base64url",
|
|
2199
|
+
};
|
|
2200
|
+
if (s->len < 3 || s->len > 9) return false;
|
|
2201
|
+
char low[10];
|
|
2202
|
+
for (size_t i = 0; i < s->len; i++) {
|
|
2203
|
+
char c = s->data[i];
|
|
2204
|
+
low[i] = c >= 'A' && c <= 'Z' ? (char)(c + 32) : c;
|
|
2205
|
+
}
|
|
2206
|
+
low[s->len] = 0;
|
|
2207
|
+
for (size_t i = 0; i < sizeof names / sizeof names[0]; i++) {
|
|
2208
|
+
if (strlen(names[i]) == s->len && memcmp(low, names[i], s->len) == 0) return true;
|
|
2209
|
+
}
|
|
2210
|
+
return false;
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
ScrBytes *scr_bytes_concat(const ScrArr *list) {
|
|
2214
|
+
size_t total = 0;
|
|
2215
|
+
for (size_t i = 0; i < list->len; i++) {
|
|
2216
|
+
ScrBytes *part = scr_bytes_concat_item(list, i);
|
|
2217
|
+
if (!part) return NULL;
|
|
2218
|
+
total += part->len;
|
|
2219
|
+
scr_bytes_release(part);
|
|
2220
|
+
}
|
|
2221
|
+
ScrBytes *b = scr_bytes_alloc(SCR_BYTES_U8, total);
|
|
2222
|
+
size_t o = 0;
|
|
2223
|
+
for (size_t i = 0; i < list->len; i++) {
|
|
2224
|
+
ScrBytes *part = scr_bytes_concat_item(list, i);
|
|
2225
|
+
if (!part) {
|
|
2226
|
+
scr_bytes_release(b);
|
|
2227
|
+
return NULL;
|
|
2228
|
+
}
|
|
2229
|
+
memcpy(b->data + o, part->data, part->len);
|
|
2230
|
+
o += part->len;
|
|
2231
|
+
scr_bytes_release(part);
|
|
2232
|
+
}
|
|
2233
|
+
return b;
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
/* ── the buf.read* / buf.write* numeric families (Node's exact bounds
|
|
2237
|
+
* discipline; the error ladders below mirror lib/internal/buffer.js's
|
|
2238
|
+
* boundsError/checkInt/checkBounds byte-for-byte — pinned by corpus
|
|
2239
|
+
* 1660 against the live Node oracle) ───────────────────────────────── */
|
|
2240
|
+
|
|
2241
|
+
/* ERR_OUT_OF_RANGE's "Received" rendering: integers with |v| > 2^32 get
|
|
2242
|
+
* Node's addNumericalSeparator underscores applied to the plain String()
|
|
2243
|
+
* form — INCLUDING its quirks on exponent renderings ("1e_+21",
|
|
2244
|
+
* "1e+_300"); everything else is the shortest-roundtrip number. Shared
|
|
2245
|
+
* with the fs/net option-ladder validators (scr_num_received). */
|
|
2246
|
+
size_t scr_num_received(double v, char out[48]) {
|
|
2247
|
+
char plain[32];
|
|
2248
|
+
size_t n = scr_f64_to_str(v, plain);
|
|
2249
|
+
if (!(isfinite(v) && trunc(v) == v && fabs(v) > 4294967296.0)) {
|
|
2250
|
+
memcpy(out, plain, n + 1);
|
|
2251
|
+
return n;
|
|
2252
|
+
}
|
|
2253
|
+
/* addNumericalSeparator: head of 1-3 chars (past a leading '-'), then
|
|
2254
|
+
* '_'-joined groups of 3 — walked over the STRING, exactly Node. */
|
|
2255
|
+
size_t start = plain[0] == '-' ? 1 : 0;
|
|
2256
|
+
size_t head = n;
|
|
2257
|
+
while (head >= start + 4) head -= 3;
|
|
2258
|
+
memcpy(out, plain, head);
|
|
2259
|
+
size_t o = head;
|
|
2260
|
+
for (size_t p = head; p < n; p += 3) {
|
|
2261
|
+
out[o++] = '_';
|
|
2262
|
+
memcpy(out + o, plain + p, 3);
|
|
2263
|
+
o += 3;
|
|
2264
|
+
}
|
|
2265
|
+
out[o] = 0;
|
|
2266
|
+
return o;
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
/* Node's boundsError: a non-integer index is "an integer" first, a
|
|
2270
|
+
* negative capacity (buffer shorter than the read/write width) is the
|
|
2271
|
+
* constant ERR_BUFFER_OUT_OF_BOUNDS text, and everything else renders
|
|
2272
|
+
* the ">= min and <= max" range. type NULL means "offset" (min 0);
|
|
2273
|
+
* "byteLength" renders min 1. All catchable RangeErrors. */
|
|
2274
|
+
static void scr_bytes_bounds_error(double value, double length, const char *type) {
|
|
2275
|
+
char recv[48];
|
|
2276
|
+
scr_num_received(value, recv);
|
|
2277
|
+
char msg[160];
|
|
2278
|
+
int mlen;
|
|
2279
|
+
if (floor(value) != value) {
|
|
2280
|
+
mlen = snprintf(msg, sizeof msg,
|
|
2281
|
+
"The value of \"%s\" is out of range. It must be an integer. Received %s",
|
|
2282
|
+
type ? type : "offset", recv);
|
|
2283
|
+
} else if (length < 0) {
|
|
2284
|
+
static const char oob[] = "Attempt to access memory outside buffer bounds";
|
|
2285
|
+
scr_throw_error_msg_code(SCR_ERR_RANGE, oob, sizeof oob - 1, "ERR_BUFFER_OUT_OF_BOUNDS");
|
|
2286
|
+
return;
|
|
2287
|
+
} else {
|
|
2288
|
+
char lenbuf[32];
|
|
2289
|
+
scr_f64_to_str(length, lenbuf);
|
|
2290
|
+
mlen = snprintf(msg, sizeof msg,
|
|
2291
|
+
"The value of \"%s\" is out of range. It must be >= %d and <= %s. Received %s",
|
|
2292
|
+
type ? type : "offset", type ? 1 : 0, lenbuf, recv);
|
|
2293
|
+
}
|
|
2294
|
+
scr_throw_error_msg_code(SCR_ERR_RANGE, msg, (size_t)mlen, "ERR_OUT_OF_RANGE");
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
/* The shared offset gate: width bytes at offset must lie inside b. */
|
|
2298
|
+
static bool scr_bytes_rw_check(const ScrBytes *b, double offset, size_t width) {
|
|
2299
|
+
double cap = (double)b->len - (double)width;
|
|
2300
|
+
if (floor(offset) != offset || cap < 0 || offset < 0 || offset > cap) {
|
|
2301
|
+
scr_bytes_bounds_error(offset, cap, NULL);
|
|
2302
|
+
return false;
|
|
2303
|
+
}
|
|
2304
|
+
return true;
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
/* Node's checkInt for the integer writes: the VALUE range throws before
|
|
2308
|
+
* any offset check; widths past 4 bytes render the "2 ** N" range form
|
|
2309
|
+
* (checkInt's byteLength > 3 branch). NaN passes both comparisons —
|
|
2310
|
+
* exactly Node — and writes zeros downstream. */
|
|
2311
|
+
static bool scr_bytes_check_int(const ScrBytes *b, double value, double offset,
|
|
2312
|
+
size_t width, bool sign) {
|
|
2313
|
+
double max = sign ? exp2((double)(8 * width - 1)) - 1 : exp2((double)(8 * width)) - 1;
|
|
2314
|
+
double min = sign ? -exp2((double)(8 * width - 1)) : 0;
|
|
2315
|
+
if (value > max || value < min) {
|
|
2316
|
+
char recv[48];
|
|
2317
|
+
scr_num_received(value, recv);
|
|
2318
|
+
char msg[160];
|
|
2319
|
+
int mlen;
|
|
2320
|
+
if (width > 4) {
|
|
2321
|
+
if (sign) {
|
|
2322
|
+
mlen = snprintf(msg, sizeof msg,
|
|
2323
|
+
"The value of \"value\" is out of range. It must be >= -(2 ** %zu) and < 2 ** %zu. Received %s",
|
|
2324
|
+
8 * width - 1, 8 * width - 1, recv);
|
|
2325
|
+
} else {
|
|
2326
|
+
mlen = snprintf(msg, sizeof msg,
|
|
2327
|
+
"The value of \"value\" is out of range. It must be >= 0 and < 2 ** %zu. Received %s",
|
|
2328
|
+
8 * width, recv);
|
|
2329
|
+
}
|
|
2330
|
+
} else {
|
|
2331
|
+
char minb[32], maxb[32];
|
|
2332
|
+
scr_f64_to_str(min, minb);
|
|
2333
|
+
scr_f64_to_str(max, maxb);
|
|
2334
|
+
mlen = snprintf(msg, sizeof msg,
|
|
2335
|
+
"The value of \"value\" is out of range. It must be >= %s and <= %s. Received %s",
|
|
2336
|
+
minb, maxb, recv);
|
|
2337
|
+
}
|
|
2338
|
+
scr_throw_error_msg_code(SCR_ERR_RANGE, msg, (size_t)mlen, "ERR_OUT_OF_RANGE");
|
|
2339
|
+
return false;
|
|
2340
|
+
}
|
|
2341
|
+
return scr_bytes_rw_check(b, offset, width);
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
static size_t scr_bytes_num_width(ScrBytesNumKind kind) {
|
|
2345
|
+
switch (kind) {
|
|
2346
|
+
case SCR_BN_U8:
|
|
2347
|
+
case SCR_BN_I8:
|
|
2348
|
+
return 1;
|
|
2349
|
+
case SCR_BN_U16:
|
|
2350
|
+
case SCR_BN_I16:
|
|
2351
|
+
return 2;
|
|
2352
|
+
case SCR_BN_F64:
|
|
2353
|
+
return 8;
|
|
2354
|
+
default:
|
|
2355
|
+
return 4; /* u32 / i32 / f32 */
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
double scr_bytes_read_num(const ScrBytes *b, double offset, ScrBytesNumKind kind, bool le) {
|
|
2360
|
+
size_t width = scr_bytes_num_width(kind);
|
|
2361
|
+
if (!scr_bytes_rw_check(b, offset, width)) return 0;
|
|
2362
|
+
const uint8_t *p = b->data + (size_t)offset;
|
|
2363
|
+
uint64_t u = 0;
|
|
2364
|
+
for (size_t i = 0; i < width; i++) {
|
|
2365
|
+
u |= (uint64_t)p[le ? i : width - 1 - i] << (8 * i);
|
|
2366
|
+
}
|
|
2367
|
+
switch (kind) {
|
|
2368
|
+
case SCR_BN_U8:
|
|
2369
|
+
case SCR_BN_U16:
|
|
2370
|
+
case SCR_BN_U32:
|
|
2371
|
+
return (double)u;
|
|
2372
|
+
case SCR_BN_I8:
|
|
2373
|
+
return (double)(int8_t)u;
|
|
2374
|
+
case SCR_BN_I16:
|
|
2375
|
+
return (double)(int16_t)u;
|
|
2376
|
+
case SCR_BN_I32:
|
|
2377
|
+
return (double)(int32_t)u;
|
|
2378
|
+
case SCR_BN_F32: {
|
|
2379
|
+
uint32_t bits = (uint32_t)u;
|
|
2380
|
+
float f;
|
|
2381
|
+
memcpy(&f, &bits, 4);
|
|
2382
|
+
return (double)f;
|
|
2383
|
+
}
|
|
2384
|
+
case SCR_BN_F64: {
|
|
2385
|
+
double d;
|
|
2386
|
+
memcpy(&d, &u, 8);
|
|
2387
|
+
return d;
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
return 0; /* unreachable */
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
double scr_bytes_write_num(ScrBytes *b, double value, double offset, ScrBytesNumKind kind, bool le) {
|
|
2394
|
+
size_t width = scr_bytes_num_width(kind);
|
|
2395
|
+
uint64_t u;
|
|
2396
|
+
if (kind == SCR_BN_F32 || kind == SCR_BN_F64) {
|
|
2397
|
+
/* Float writes carry no value check (any double stores; the float
|
|
2398
|
+
* cast rounds to nearest exactly like Float32Array assignment). */
|
|
2399
|
+
if (!scr_bytes_rw_check(b, offset, width)) return 0;
|
|
2400
|
+
if (kind == SCR_BN_F32) {
|
|
2401
|
+
float f = (float)value;
|
|
2402
|
+
uint32_t bits;
|
|
2403
|
+
memcpy(&bits, &f, 4);
|
|
2404
|
+
u = bits;
|
|
2405
|
+
} else {
|
|
2406
|
+
memcpy(&u, &value, 8);
|
|
2407
|
+
}
|
|
2408
|
+
} else {
|
|
2409
|
+
bool sign = kind == SCR_BN_I8 || kind == SCR_BN_I16 || kind == SCR_BN_I32;
|
|
2410
|
+
if (!scr_bytes_check_int(b, value, offset, width, sign)) return 0;
|
|
2411
|
+
double t = trunc(value);
|
|
2412
|
+
if (t != t) t = 0; /* NaN passed the range gate: zeros, like Node */
|
|
2413
|
+
u = (uint64_t)(int64_t)t; /* two's complement of the truncation */
|
|
2414
|
+
}
|
|
2415
|
+
uint8_t *p = b->data + (size_t)offset;
|
|
2416
|
+
for (size_t i = 0; i < width; i++) {
|
|
2417
|
+
p[le ? i : width - 1 - i] = (uint8_t)(u >> (8 * i));
|
|
2418
|
+
}
|
|
2419
|
+
return offset + (double)width;
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
/* readUIntLE/BE / readIntLE/BE — the variable-width family: byteLength
|
|
2423
|
+
* validates FIRST (1-6, its own error ladder), then the offset gate. */
|
|
2424
|
+
double scr_bytes_read_var(const ScrBytes *b, double offset, double byte_length, bool sign, bool le) {
|
|
2425
|
+
if (floor(byte_length) != byte_length || byte_length < 1 || byte_length > 6) {
|
|
2426
|
+
scr_bytes_bounds_error(byte_length, 6, "byteLength");
|
|
2427
|
+
return 0;
|
|
2428
|
+
}
|
|
2429
|
+
size_t width = (size_t)byte_length;
|
|
2430
|
+
if (!scr_bytes_rw_check(b, offset, width)) return 0;
|
|
2431
|
+
const uint8_t *p = b->data + (size_t)offset;
|
|
2432
|
+
uint64_t u = 0;
|
|
2433
|
+
for (size_t i = 0; i < width; i++) {
|
|
2434
|
+
u |= (uint64_t)p[le ? i : width - 1 - i] << (8 * i);
|
|
2435
|
+
}
|
|
2436
|
+
if (sign && (u & ((uint64_t)1 << (8 * width - 1)))) {
|
|
2437
|
+
return (double)(int64_t)(u - ((uint64_t)1 << (8 * width)));
|
|
2438
|
+
}
|
|
2439
|
+
return (double)u;
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2442
|
+
/* writeUIntLE/BE / writeIntLE/BE: byteLength, then value, then offset —
|
|
2443
|
+
* Node's exact check order. Returns offset + byteLength. */
|
|
2444
|
+
double scr_bytes_write_var(ScrBytes *b, double value, double offset, double byte_length, bool sign, bool le) {
|
|
2445
|
+
if (floor(byte_length) != byte_length || byte_length < 1 || byte_length > 6) {
|
|
2446
|
+
scr_bytes_bounds_error(byte_length, 6, "byteLength");
|
|
2447
|
+
return 0;
|
|
2448
|
+
}
|
|
2449
|
+
size_t width = (size_t)byte_length;
|
|
2450
|
+
if (!scr_bytes_check_int(b, value, offset, width, sign)) return 0;
|
|
2451
|
+
double t = trunc(value);
|
|
2452
|
+
if (t != t) t = 0;
|
|
2453
|
+
uint64_t u = (uint64_t)(int64_t)t;
|
|
2454
|
+
uint8_t *p = b->data + (size_t)offset;
|
|
2455
|
+
for (size_t i = 0; i < width; i++) {
|
|
2456
|
+
p[le ? i : width - 1 - i] = (uint8_t)(u >> (8 * i));
|
|
2457
|
+
}
|
|
2458
|
+
return offset + (double)width;
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
bool scr_bytes_read_u64_raw(const ScrBytes *b, double offset, bool le, uint64_t *out) {
|
|
2462
|
+
if (!scr_bytes_rw_check(b, offset, 8)) return false;
|
|
2463
|
+
const uint8_t *p = b->data + (size_t)offset;
|
|
2464
|
+
uint64_t value = 0;
|
|
2465
|
+
for (size_t i = 0; i < 8; i++) value |= (uint64_t)p[le ? i : 7 - i] << (8 * i);
|
|
2466
|
+
*out = value;
|
|
2467
|
+
return true;
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
bool scr_bytes_write_u64_raw(ScrBytes *b, double offset, bool le, uint64_t value) {
|
|
2471
|
+
if (!scr_bytes_rw_check(b, offset, 8)) return false;
|
|
2472
|
+
uint8_t *p = b->data + (size_t)offset;
|
|
2473
|
+
for (size_t i = 0; i < 8; i++) p[le ? i : 7 - i] = (uint8_t)(value >> (8 * i));
|
|
2474
|
+
return true;
|
|
2475
|
+
}
|
|
2476
|
+
|
|
2477
|
+
static bool scr_dataview_u64_check(const ScrBytes *b, double byte_off) {
|
|
2478
|
+
double off = (byte_off != byte_off) ? 0 : trunc(byte_off);
|
|
2479
|
+
if (!(off >= 0) || off > 9007199254740991.0 || off + 8 > (double)b->len) {
|
|
2480
|
+
static const char msg[] = "Offset is outside the bounds of the DataView";
|
|
2481
|
+
scr_throw_error_msg(SCR_ERR_RANGE, msg, sizeof msg - 1);
|
|
2482
|
+
return false;
|
|
2483
|
+
}
|
|
2484
|
+
return true;
|
|
2485
|
+
}
|
|
2486
|
+
|
|
2487
|
+
bool scr_dataview_read_u64_raw(const ScrBytes *b, double offset, bool le, uint64_t *out) {
|
|
2488
|
+
double off = (offset != offset) ? 0 : trunc(offset);
|
|
2489
|
+
if (!scr_dataview_u64_check(b, offset)) return false;
|
|
2490
|
+
const uint8_t *p = b->data + (size_t)off;
|
|
2491
|
+
uint64_t value = 0;
|
|
2492
|
+
for (size_t i = 0; i < 8; i++) value |= (uint64_t)p[le ? i : 7 - i] << (8 * i);
|
|
2493
|
+
*out = value;
|
|
2494
|
+
return true;
|
|
2495
|
+
}
|
|
2496
|
+
|
|
2497
|
+
bool scr_dataview_write_u64_raw(ScrBytes *b, double offset, bool le, uint64_t value) {
|
|
2498
|
+
double off = (offset != offset) ? 0 : trunc(offset);
|
|
2499
|
+
if (!scr_dataview_u64_check(b, offset)) return false;
|
|
2500
|
+
uint8_t *p = b->data + (size_t)off;
|
|
2501
|
+
for (size_t i = 0; i < 8; i++) p[le ? i : 7 - i] = (uint8_t)(value >> (8 * i));
|
|
2502
|
+
return true;
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
ScrArr *scr_bytes_to_arr(const ScrBytes *b) {
|
|
2506
|
+
ScrArr *out = scr_arr_new(SCR_ELEM_F64, b->len ? b->len : 1);
|
|
2507
|
+
for (size_t i = 0; i < b->len; i++) {
|
|
2508
|
+
scr_arr_push_f64(out, scr_bytes_get(b, (double)i));
|
|
2509
|
+
}
|
|
2510
|
+
return out;
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
ScrStr *scr_bytes_join(const ScrBytes *b, const ScrStr *separator) {
|
|
2514
|
+
ScrArr *values = scr_bytes_to_arr(b);
|
|
2515
|
+
ScrStr *out = scr_arr_join(values, (ScrStr *)separator);
|
|
2516
|
+
scr_arr_release(values);
|
|
2517
|
+
return out;
|
|
2518
|
+
}
|