@scriptc/cli-darwin-arm64 0.2.0 → 0.2.2
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/THIRD_PARTY_NOTICES +1 -1
- package/dist/bin/scriptc +0 -0
- package/dist/bin/scriptc.json +1 -1
- package/dist/lib/declarations/scriptc-node-fallback.d.ts +84 -19
- package/dist/lib/llvm/bin/scriptc-llvm-codegen +0 -0
- package/dist/lib/llvm/package.json +1 -1
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_fetch.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_island.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_web.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/licenses/v8-number-radix.txt +61 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_fetch.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_island.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_web.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/package.json +1 -1
- package/dist/lib/runtime-darwin-arm64/runtime-pack.json +549 -545
- package/dist/lib/runtime-sources/package.json +1 -1
- package/dist/lib/runtime-sources/src/scr_abort.c +5 -0
- package/dist/lib/runtime-sources/src/scr_array.c +16 -0
- package/dist/lib/runtime-sources/src/scr_assert.c +1 -0
- package/dist/lib/runtime-sources/src/scr_async.c +38 -5
- package/dist/lib/runtime-sources/src/scr_async_dyn.c +208 -40
- package/dist/lib/runtime-sources/src/scr_bigint.c +8 -0
- package/dist/lib/runtime-sources/src/scr_bytes.c +431 -41
- package/dist/lib/runtime-sources/src/scr_bytes_io.c +628 -12
- package/dist/lib/runtime-sources/src/scr_child.c +544 -17
- package/dist/lib/runtime-sources/src/scr_console.c +1 -1
- package/dist/lib/runtime-sources/src/scr_crypto_async.c +22 -2
- package/dist/lib/runtime-sources/src/scr_dyn_invoke.c +344 -73
- package/dist/lib/runtime-sources/src/scr_error.c +52 -5
- package/dist/lib/runtime-sources/src/scr_exception.c +21 -5
- package/dist/lib/runtime-sources/src/scr_fetch.c +311 -3
- package/dist/lib/runtime-sources/src/scr_file_handle.c +31 -0
- package/dist/lib/runtime-sources/src/scr_http.c +3 -0
- package/dist/lib/runtime-sources/src/scr_island.c +1226 -405
- package/dist/lib/runtime-sources/src/scr_island_manifest.h +11 -9
- package/dist/lib/runtime-sources/src/scr_json.c +1594 -139
- package/dist/lib/runtime-sources/src/scr_json.test.ts +1 -0
- package/dist/lib/runtime-sources/src/scr_lib.c +816 -34
- package/dist/lib/runtime-sources/src/scr_map.c +47 -0
- package/dist/lib/runtime-sources/src/scr_node_builtin.c +10 -0
- package/dist/lib/runtime-sources/src/scr_object.c +11 -0
- package/dist/lib/runtime-sources/src/scr_qs.c +10 -0
- package/dist/lib/runtime-sources/src/scr_regex.c +148 -72
- package/dist/lib/runtime-sources/src/scr_runtime.h +257 -41
- package/dist/lib/runtime-sources/src/scr_stream.c +197 -0
- package/dist/lib/runtime-sources/src/scr_string.c +16 -1
- package/dist/lib/runtime-sources/src/scr_symbol.c +5 -0
- package/dist/lib/runtime-sources/src/scr_text_decoder_labels.h +225 -0
- package/dist/lib/runtime-sources/src/scr_url.c +206 -10
- package/dist/lib/runtime-sources/src/scr_web.c +129 -26
- package/dist/lib/runtime-sources/vendor/v8-number-radix/LICENSE +61 -0
- package/package.json +1 -1
|
@@ -135,6 +135,7 @@ void scr_error_init(void *obj, int kind, ScrStr *message) {
|
|
|
135
135
|
const char *n = scr_error_names[kind];
|
|
136
136
|
e->name = scr_str_new(n, strlen(n));
|
|
137
137
|
e->message = message ? scr_str_retain(message) : scr_str_new("", 0);
|
|
138
|
+
e->message_present = message != NULL;
|
|
138
139
|
e->stack_frames = scr_stack_capture();
|
|
139
140
|
}
|
|
140
141
|
|
|
@@ -172,9 +173,28 @@ ScrError *scr_error_new(int kind, ScrStr *message) {
|
|
|
172
173
|
return e;
|
|
173
174
|
}
|
|
174
175
|
|
|
175
|
-
ScrStr *
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
static SCR_TL ScrStr *(*scr_error_message_reader)(ScrError *);
|
|
177
|
+
static SCR_TL ScrStr *(*scr_error_name_reader)(ScrError *);
|
|
178
|
+
|
|
179
|
+
void scr_error_install_message_reader(ScrStr *(*reader)(ScrError *)) {
|
|
180
|
+
scr_error_message_reader = reader;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
void scr_error_install_name_reader(ScrStr *(*reader)(ScrError *)) {
|
|
184
|
+
scr_error_name_reader = reader;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
ScrStr *scr_error_default_name(const ScrError *e) {
|
|
188
|
+
for (int i = 1; i < SCR_ERR_COUNT; i++) {
|
|
189
|
+
if (i == SCR_ERR_DOMEX) continue;
|
|
190
|
+
if (scr_error_vts[i].pre <= e->vt->pre && e->vt->pre <= scr_error_vts[i].post)
|
|
191
|
+
return scr_str_new(scr_error_names[i], strlen(scr_error_names[i]));
|
|
192
|
+
}
|
|
193
|
+
return scr_str_new("Error", 5);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
static ScrStr *scr_error_format(ScrError *e, ScrStr *name, ScrStr *message) {
|
|
197
|
+
/* ECMA-262 Error.prototype.toString over the resolved properties — except Node's
|
|
178
198
|
* OWN error classes: AssertionError's toString and the NodeError
|
|
179
199
|
* family's construction-time name both render "name [code]: message".
|
|
180
200
|
* Every ERR_*-coded error this runtime mints IS one of those classes
|
|
@@ -182,8 +202,6 @@ ScrStr *scr_error_to_string(ScrError *e) {
|
|
|
182
202
|
* the code-prefix test is exact for runtime-thrown errors; a user
|
|
183
203
|
* assigning an ERR_* code onto a plain Error would bracket here where
|
|
184
204
|
* Node would not (documented — user code owns that spelling). */
|
|
185
|
-
ScrStr *name = e->name;
|
|
186
|
-
ScrStr *message = e->message;
|
|
187
205
|
bool assertion = name && e->code && e->code->len >= 4 &&
|
|
188
206
|
memcmp(e->code->data, "ERR_", 4) == 0;
|
|
189
207
|
if (!name || name->len == 0) {
|
|
@@ -214,9 +232,36 @@ ScrStr *scr_error_to_string(ScrError *e) {
|
|
|
214
232
|
return out;
|
|
215
233
|
}
|
|
216
234
|
|
|
235
|
+
ScrStr *scr_error_to_string(ScrError *e) {
|
|
236
|
+
// Diagnostic formatting can run with the original error still pending.
|
|
237
|
+
// Accessors execute with a clear cell, and cannot replace that error.
|
|
238
|
+
ScrCaught *pending = scr_exc_pending() ? scr_exc_take() : NULL;
|
|
239
|
+
ScrStr *name = !e->name_present && scr_error_name_reader
|
|
240
|
+
? scr_error_name_reader(scr_error_retain(e)) : scr_str_retain(e->name);
|
|
241
|
+
ScrStr *message = scr_exc_pending() ? NULL : !e->message_present && scr_error_message_reader
|
|
242
|
+
? scr_error_message_reader(scr_error_retain(e)) : scr_str_retain(e->message);
|
|
243
|
+
if (pending) {
|
|
244
|
+
if (scr_exc_pending()) {
|
|
245
|
+
scr_exc_clear();
|
|
246
|
+
scr_str_release(message);
|
|
247
|
+
message = scr_str_retain(e->message);
|
|
248
|
+
scr_str_release(name);
|
|
249
|
+
name = scr_str_retain(e->name);
|
|
250
|
+
}
|
|
251
|
+
scr_rethrow(pending);
|
|
252
|
+
scr_caught_release(pending);
|
|
253
|
+
}
|
|
254
|
+
if (!name || !message) { scr_str_release(name); scr_str_release(message); return NULL; }
|
|
255
|
+
ScrStr *result = scr_error_format(e, name, message);
|
|
256
|
+
scr_str_release(name);
|
|
257
|
+
scr_str_release(message);
|
|
258
|
+
return result;
|
|
259
|
+
}
|
|
260
|
+
|
|
217
261
|
ScrStr *scr_error_stack(ScrError *e) {
|
|
218
262
|
if (!e->stack) {
|
|
219
263
|
ScrStr *heading = scr_error_to_string(e);
|
|
264
|
+
if (!heading) return NULL;
|
|
220
265
|
e->stack = e->stack_frames ? scr_str_concat(heading, e->stack_frames) : scr_str_retain(heading);
|
|
221
266
|
scr_str_release(heading);
|
|
222
267
|
}
|
|
@@ -367,6 +412,8 @@ void scr_throw_error_named(ScrStr *name, ScrStr *message) {
|
|
|
367
412
|
ScrError *e = scr_error_alloc(kind);
|
|
368
413
|
e->name = name; /* ownership moves in (engine names may be custom) */
|
|
369
414
|
e->message = message; /* ownership moves in */
|
|
415
|
+
e->name_present = kind == SCR_ERR_ERROR && !(name->len == 5 && memcmp(name->data, "Error", 5) == 0);
|
|
416
|
+
e->message_present = true;
|
|
370
417
|
scr_throw_obj(e, &scr_error_retain_v, &scr_error_release_v,
|
|
371
418
|
scr_error_traced ? &scr_error_trace : NULL);
|
|
372
419
|
}
|
|
@@ -139,11 +139,24 @@ void scr_exc_clear(void) { scr_exc_reset(); }
|
|
|
139
139
|
|
|
140
140
|
/* ── catch bindings (ScrCaught — contract in scr_runtime.h) ──────────── */
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
ScrCaught *c =
|
|
144
|
-
if (
|
|
145
|
-
|
|
142
|
+
void scr_caught_trace_v(void *object, ScrTraceVisit visit, void *ctx) {
|
|
143
|
+
ScrCaught *c = object;
|
|
144
|
+
if (c->payload && c->trace_fn) visit(c->payload, ctx);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
static void scr_caught_gcfree(void *object) {
|
|
148
|
+
ScrCaught *c = object;
|
|
149
|
+
if (c->kind == SCR_EXC_STR) {
|
|
150
|
+
scr_str_release((ScrStr *)c->payload);
|
|
151
|
+
} else if (c->payload && c->release_fn && !c->trace_fn) {
|
|
152
|
+
c->release_fn(c->payload);
|
|
146
153
|
}
|
|
154
|
+
scr_obj_free_note();
|
|
155
|
+
scr_cyc_free(c);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
ScrCaught *scr_exc_take(void) {
|
|
159
|
+
ScrCaught *c = scr_cyc_alloc(sizeof *c, scr_caught_trace_v, scr_caught_gcfree);
|
|
147
160
|
c->rc = 1;
|
|
148
161
|
c->kind = scr_exc_kind;
|
|
149
162
|
c->f64 = scr_exc_f64;
|
|
@@ -169,6 +182,7 @@ ScrCaught *scr_caught_retain(ScrCaught *c) {
|
|
|
169
182
|
void scr_caught_release(ScrCaught *c) {
|
|
170
183
|
if (!c) return;
|
|
171
184
|
if (--c->rc == 0) {
|
|
185
|
+
scr_cyc_on_dead(c);
|
|
172
186
|
if (c->kind == SCR_EXC_STR) {
|
|
173
187
|
scr_str_release((ScrStr *)c->payload);
|
|
174
188
|
} else if (c->kind == SCR_EXC_REF || c->kind == SCR_EXC_OBJ ||
|
|
@@ -176,7 +190,9 @@ void scr_caught_release(ScrCaught *c) {
|
|
|
176
190
|
c->release_fn(c->payload);
|
|
177
191
|
}
|
|
178
192
|
scr_obj_free_note();
|
|
179
|
-
|
|
193
|
+
scr_cyc_free(c);
|
|
194
|
+
} else {
|
|
195
|
+
scr_cyc_on_release(c);
|
|
180
196
|
}
|
|
181
197
|
}
|
|
182
198
|
|
|
@@ -92,7 +92,11 @@
|
|
|
92
92
|
#include <stdlib.h>
|
|
93
93
|
#include <string.h>
|
|
94
94
|
|
|
95
|
+
#ifndef SCR_FETCH_SIGNAL_ONLY
|
|
95
96
|
#include <zlib.h>
|
|
97
|
+
#else
|
|
98
|
+
static void sf_signal_install(void);
|
|
99
|
+
#endif
|
|
96
100
|
|
|
97
101
|
/*
|
|
98
102
|
* The static tier is a small native Web-platform island of its own:
|
|
@@ -289,6 +293,7 @@ struct SfResponse {
|
|
|
289
293
|
bool null_body;
|
|
290
294
|
};
|
|
291
295
|
|
|
296
|
+
#ifndef SCR_FETCH_SIGNAL_ONLY
|
|
292
297
|
struct SfTransfer {
|
|
293
298
|
size_t rc; /* live registry + one per listener closure */
|
|
294
299
|
ScrPromise *promise; /* owned */
|
|
@@ -323,12 +328,15 @@ struct SfTransfer {
|
|
|
323
328
|
};
|
|
324
329
|
|
|
325
330
|
static SfTransfer *sf_live;
|
|
331
|
+
#endif
|
|
326
332
|
/* Weak registries: owners unlink themselves on destruction. They let the
|
|
327
333
|
* fetch teardown sever opaque native→dyn edges before final cycle collection,
|
|
328
334
|
* including otherwise-untraceable callback/reason→handle backedges. */
|
|
329
335
|
static SfSignal *sf_callback_signals;
|
|
330
336
|
static SfSignal *sf_reason_signals;
|
|
337
|
+
#ifndef SCR_FETCH_SIGNAL_ONLY
|
|
331
338
|
static SfStream *sf_callback_streams;
|
|
339
|
+
#endif
|
|
332
340
|
|
|
333
341
|
static void sf_oom(void) {
|
|
334
342
|
fputs("scriptc: out of memory\n", stderr);
|
|
@@ -484,6 +492,9 @@ static void sf_signal_drop_reason(SfSignal *s) {
|
|
|
484
492
|
}
|
|
485
493
|
|
|
486
494
|
static SfSignal *sf_signal_new(void) {
|
|
495
|
+
#ifdef SCR_FETCH_SIGNAL_ONLY
|
|
496
|
+
sf_signal_install();
|
|
497
|
+
#endif
|
|
487
498
|
SfSignal *s = calloc(1, sizeof *s);
|
|
488
499
|
if (!s) sf_oom();
|
|
489
500
|
s->rc = 1;
|
|
@@ -1340,6 +1351,8 @@ static bool sf_signal_set(void *ptr, const char *key, size_t len,
|
|
|
1340
1351
|
|
|
1341
1352
|
/* ── ReadableStream ──────────────────────────────────────────────── */
|
|
1342
1353
|
|
|
1354
|
+
#ifndef SCR_FETCH_SIGNAL_ONLY
|
|
1355
|
+
|
|
1343
1356
|
static void sf_stream_track_callbacks(SfStream *s) {
|
|
1344
1357
|
if (s->callbacks_tracked || (!s->pull_cb && !s->cancel_cb)) return;
|
|
1345
1358
|
s->callbacks_tracked = true;
|
|
@@ -3176,6 +3189,7 @@ static SfResponse *sf_response_retain(SfResponse *r) {
|
|
|
3176
3189
|
|
|
3177
3190
|
static void sf_response_release(SfResponse *r) {
|
|
3178
3191
|
if (!r || --r->rc > 0) return;
|
|
3192
|
+
scr_weak_dispose(r);
|
|
3179
3193
|
sf_stream_release(r->body);
|
|
3180
3194
|
sf_headers_release(r->headers);
|
|
3181
3195
|
scr_str_release(r->url);
|
|
@@ -4057,11 +4071,17 @@ static ScrArr *sf_headers_convert_init(const ScrDyn *headers) {
|
|
|
4057
4071
|
if (headers->kind == SCR_DYN_ARR) {
|
|
4058
4072
|
for (size_t i = 0; i < headers->v.arr.len; i++) {
|
|
4059
4073
|
ScrDyn *pair = scr_dyn_retain(headers->v.arr.items[i]);
|
|
4074
|
+
if (pair->kind == SCR_DYN_TYPED_REF) {
|
|
4075
|
+
ScrDyn *materialized = scr_dyn_typed_ref_materialize(pair);
|
|
4076
|
+
scr_dyn_release(pair);
|
|
4077
|
+
pair = materialized;
|
|
4078
|
+
}
|
|
4060
4079
|
if (pair->kind != SCR_DYN_ARR || pair->v.arr.len != 2) {
|
|
4080
|
+
bool sequence = pair->kind == SCR_DYN_ARR;
|
|
4061
4081
|
size_t pair_len = pair->kind == SCR_DYN_ARR ? pair->v.arr.len : 0;
|
|
4062
4082
|
scr_dyn_release(pair);
|
|
4063
4083
|
if (!scr_exc_pending()) {
|
|
4064
|
-
if (
|
|
4084
|
+
if (sequence) {
|
|
4065
4085
|
sf_headers_pair_length_error(pair_len);
|
|
4066
4086
|
} else {
|
|
4067
4087
|
sf_headers_constructor_type_error();
|
|
@@ -5169,7 +5189,250 @@ fail:
|
|
|
5169
5189
|
return NULL;
|
|
5170
5190
|
}
|
|
5171
5191
|
|
|
5192
|
+
/* Request uses the same body stream and Headers ownership as Response. */
|
|
5193
|
+
typedef struct SfRequest {
|
|
5194
|
+
size_t rc;
|
|
5195
|
+
SfResponse *payload;
|
|
5196
|
+
ScrStr *url;
|
|
5197
|
+
ScrStr *method;
|
|
5198
|
+
ScrStr *redirect;
|
|
5199
|
+
SfSignal *signal;
|
|
5200
|
+
} SfRequest;
|
|
5201
|
+
|
|
5202
|
+
static void *sf_request_retain_v(void *ptr) {
|
|
5203
|
+
SfRequest *r = ptr; r->rc++; return r;
|
|
5204
|
+
}
|
|
5205
|
+
static void sf_request_release_v(void *ptr) {
|
|
5206
|
+
SfRequest *r = ptr;
|
|
5207
|
+
if (--r->rc) return;
|
|
5208
|
+
scr_weak_dispose(r);
|
|
5209
|
+
sf_response_release(r->payload);
|
|
5210
|
+
scr_str_release(r->url); scr_str_release(r->method); scr_str_release(r->redirect);
|
|
5211
|
+
sf_signal_release(r->signal); free(r);
|
|
5212
|
+
}
|
|
5213
|
+
static ScrDyn *sf_request_get(void *ptr, const char *key, size_t len) {
|
|
5214
|
+
SfRequest *r = ptr;
|
|
5215
|
+
if (sf_name(key, len, "url")) return scr_dyn_new_str(r->url);
|
|
5216
|
+
if (sf_name(key, len, "method")) return scr_dyn_new_str(r->method);
|
|
5217
|
+
if (sf_name(key, len, "redirect")) return scr_dyn_new_str(r->redirect);
|
|
5218
|
+
if (sf_name(key, len, "signal")) return scr_dyn_new_handle(r->signal, SCR_DYNH_ABORT_SIGNAL);
|
|
5219
|
+
if (sf_name(key, len, "duplex")) { ScrStr *s = scr_str_new("half", 4); ScrDyn *v = scr_dyn_new_str(s); scr_str_release(s); return v; }
|
|
5220
|
+
const char *default_value = NULL;
|
|
5221
|
+
if (sf_name(key, len, "destination") || sf_name(key, len, "integrity") || sf_name(key, len, "referrerPolicy")) default_value = "";
|
|
5222
|
+
if (sf_name(key, len, "mode")) default_value = "cors";
|
|
5223
|
+
if (sf_name(key, len, "credentials")) default_value = "same-origin";
|
|
5224
|
+
if (sf_name(key, len, "cache")) default_value = "default";
|
|
5225
|
+
if (sf_name(key, len, "referrer")) default_value = "about:client";
|
|
5226
|
+
if (default_value) { ScrStr *s = scr_str_new(default_value, strlen(default_value)); ScrDyn *v = scr_dyn_new_str(s); scr_str_release(s); return v; }
|
|
5227
|
+
if (sf_name(key, len, "keepalive") || sf_name(key, len, "isReloadNavigation") || sf_name(key, len, "isHistoryNavigation")) return scr_dyn_new_bool(false);
|
|
5228
|
+
if (sf_name(key, len, "body") || sf_name(key, len, "bodyUsed") || sf_name(key, len, "headers")) return sf_response_get(r->payload, key, len);
|
|
5229
|
+
return scr_dyn_undefined();
|
|
5230
|
+
}
|
|
5231
|
+
static ScrDyn *sf_request_invoke(void *ptr, ScrDyn *self, const char *method, ScrDyn *const *args, size_t argc, const char *what) {
|
|
5232
|
+
SfRequest *r = ptr;
|
|
5233
|
+
return sf_response_invoke(r->payload, self, method, args, argc, what);
|
|
5234
|
+
}
|
|
5235
|
+
|
|
5236
|
+
ScrDyn *scr_fetch_headers_new(ScrDyn *init) {
|
|
5237
|
+
ScrArr *converted = sf_headers_convert_init(init);
|
|
5238
|
+
if (!converted) return NULL;
|
|
5239
|
+
ScrArr *pairs = scr_arr_new(SCR_ELEM_STR, 8);
|
|
5240
|
+
bool ok = sf_add_converted_headers(pairs, converted, false);
|
|
5241
|
+
scr_arr_release(converted);
|
|
5242
|
+
if (!ok) { scr_arr_release(pairs); return NULL; }
|
|
5243
|
+
SfHeaders *headers = sf_headers_new(pairs, false);
|
|
5244
|
+
ScrDyn *result = scr_dyn_new_handle(headers, SCR_DYNH_FETCH_HEADERS);
|
|
5245
|
+
sf_headers_release(headers);
|
|
5246
|
+
return result;
|
|
5247
|
+
}
|
|
5248
|
+
|
|
5249
|
+
ScrDyn *scr_fetch_request_new(ScrDyn *input, ScrDyn *init) {
|
|
5250
|
+
SfRequest *source = input && input->kind == SCR_DYN_HANDLE && input->v.handle.tag == SCR_DYNH_FETCH_REQUEST ? input->v.handle.ptr : NULL;
|
|
5251
|
+
if (init && init->kind != SCR_DYN_UNDEF && init->kind != SCR_DYN_NULL && !sf_response_init_object_like(init)) {
|
|
5252
|
+
sf_type_error("Request constructor init must be an object"); return NULL;
|
|
5253
|
+
}
|
|
5254
|
+
ScrStr *url_text = source ? scr_str_retain(source->url) : scr_dyn_string_coerce_js(input);
|
|
5255
|
+
if (!url_text) return NULL;
|
|
5256
|
+
ScrUrl *url = scr_url_new(url_text);
|
|
5257
|
+
scr_str_release(url_text);
|
|
5258
|
+
if (!url) return NULL;
|
|
5259
|
+
if (url->userinfo->len) { scr_url_release(url); sf_type_error("Request cannot be constructed from a URL that includes credentials"); return NULL; }
|
|
5260
|
+
ScrDyn *dictionary = scr_dyn_new_obj();
|
|
5261
|
+
ScrDyn *method = sf_response_init_get(init, "method", 6);
|
|
5262
|
+
if ((!method || method->kind == SCR_DYN_UNDEF) && source) { scr_dyn_release(method); method = scr_dyn_new_str(source->method); }
|
|
5263
|
+
if (method) scr_dyn_obj_set(dictionary, "method", 6, method);
|
|
5264
|
+
ScrStr *method_text = sf_method_value(dictionary);
|
|
5265
|
+
scr_dyn_release(dictionary);
|
|
5266
|
+
if (!method_text || !sf_method_validate(&method_text)) { scr_str_release(method_text); scr_url_release(url); return NULL; }
|
|
5267
|
+
ScrDyn *body = sf_response_init_get(init, "body", 4);
|
|
5268
|
+
bool supplied = body && body->kind != SCR_DYN_UNDEF && body->kind != SCR_DYN_NULL;
|
|
5269
|
+
if (!supplied && source && !source->payload->null_body) {
|
|
5270
|
+
if (source->payload->body->disturbed || source->payload->body->reader || source->payload->body->internal_lock) {
|
|
5271
|
+
scr_dyn_release(body); scr_str_release(method_text); scr_url_release(url);
|
|
5272
|
+
sf_type_error("Cannot construct a Request with a Request object that has already been used."); return NULL;
|
|
5273
|
+
}
|
|
5274
|
+
scr_dyn_release(body); body = scr_dyn_new_handle(source->payload->body, SCR_DYNH_WEB_STREAM);
|
|
5275
|
+
}
|
|
5276
|
+
bool has_body = body && body->kind != SCR_DYN_UNDEF && body->kind != SCR_DYN_NULL;
|
|
5277
|
+
if (has_body && (sf_name(method_text->data, method_text->len, "GET") || sf_name(method_text->data, method_text->len, "HEAD"))) {
|
|
5278
|
+
scr_dyn_release(body); scr_str_release(method_text); scr_url_release(url); sf_type_error("Request with GET/HEAD method cannot have body."); return NULL;
|
|
5279
|
+
}
|
|
5280
|
+
if (supplied && body->kind == SCR_DYN_HANDLE && body->v.handle.tag == SCR_DYNH_WEB_STREAM) {
|
|
5281
|
+
ScrDyn *duplex = sf_response_init_get(init, "duplex", 6);
|
|
5282
|
+
ScrStr *text = duplex && duplex->kind != SCR_DYN_UNDEF ? scr_dyn_string_coerce_js(duplex) : NULL;
|
|
5283
|
+
scr_dyn_release(duplex);
|
|
5284
|
+
bool half = text && sf_name(text->data, text->len, "half"); scr_str_release(text);
|
|
5285
|
+
if (!half) { scr_dyn_release(body); scr_str_release(method_text); scr_url_release(url); sf_type_error("RequestInit: duplex option is required when sending a body."); return NULL; }
|
|
5286
|
+
}
|
|
5287
|
+
ScrDyn *headers = sf_response_init_get(init, "headers", 7);
|
|
5288
|
+
if ((!headers || headers->kind == SCR_DYN_UNDEF) && source) { scr_dyn_release(headers); headers = scr_dyn_new_handle(source->payload->headers, SCR_DYNH_FETCH_HEADERS); }
|
|
5289
|
+
ScrDyn *payload_init = scr_dyn_new_obj();
|
|
5290
|
+
if (headers) scr_dyn_obj_set(payload_init, "headers", 7, headers);
|
|
5291
|
+
ScrDyn *payload = scr_fetch_response_new(body, payload_init);
|
|
5292
|
+
scr_dyn_release(payload_init); scr_dyn_release(body);
|
|
5293
|
+
if (!payload) { scr_str_release(method_text); scr_url_release(url); return NULL; }
|
|
5294
|
+
ScrDyn *signal = sf_response_init_get(init, "signal", 6);
|
|
5295
|
+
if ((!signal || signal->kind == SCR_DYN_UNDEF) && source) { scr_dyn_release(signal); signal = scr_dyn_new_handle(source->signal, SCR_DYNH_ABORT_SIGNAL); }
|
|
5296
|
+
SfSignal *following = NULL;
|
|
5297
|
+
if (signal && signal->kind != SCR_DYN_UNDEF && signal->kind != SCR_DYN_NULL) {
|
|
5298
|
+
ScrDyn *signals = scr_dyn_new_arr(); scr_dyn_arr_push(signals, scr_dyn_retain(signal));
|
|
5299
|
+
ScrDyn *dependent = scr_fetch_abort_any(signals); scr_dyn_release(signals);
|
|
5300
|
+
if (dependent) { following = sf_signal_retain(dependent->v.handle.ptr); scr_dyn_release(dependent); }
|
|
5301
|
+
} else following = sf_signal_new();
|
|
5302
|
+
scr_dyn_release(signal);
|
|
5303
|
+
if (!following) { scr_dyn_release(payload); scr_str_release(method_text); scr_url_release(url); return NULL; }
|
|
5304
|
+
ScrDyn *redirect = sf_response_init_get(init, "redirect", 8);
|
|
5305
|
+
ScrStr *redirect_text = redirect && redirect->kind != SCR_DYN_UNDEF ? scr_dyn_string_coerce_js(redirect) : source ? scr_str_retain(source->redirect) : scr_str_new("follow", 6);
|
|
5306
|
+
scr_dyn_release(redirect);
|
|
5307
|
+
if (!redirect_text || !(sf_name(redirect_text->data, redirect_text->len, "follow") || sf_name(redirect_text->data, redirect_text->len, "manual") || sf_name(redirect_text->data, redirect_text->len, "error"))) {
|
|
5308
|
+
scr_str_release(redirect_text); sf_signal_release(following); scr_dyn_release(payload); scr_str_release(method_text); scr_url_release(url); sf_type_error("Invalid Request redirect value"); return NULL;
|
|
5309
|
+
}
|
|
5310
|
+
SfRequest *r = calloc(1, sizeof *r); if (!r) sf_oom();
|
|
5311
|
+
r->rc = 1; r->payload = sf_response_retain(payload->v.handle.ptr); scr_dyn_release(payload);
|
|
5312
|
+
r->url = scr_url_href(url); scr_url_release(url); r->method = method_text; r->redirect = redirect_text; r->signal = following;
|
|
5313
|
+
ScrDyn *result = scr_dyn_new_handle(r, SCR_DYNH_FETCH_REQUEST); sf_request_release_v(r); return result;
|
|
5314
|
+
}
|
|
5315
|
+
|
|
5316
|
+
ScrPromise *scr_fetch_input(ScrDyn *input, ScrDyn *init) {
|
|
5317
|
+
if (init && init->kind == SCR_DYN_TYPED_REF) {
|
|
5318
|
+
ScrDyn *view = scr_dyn_typed_ref_materialize(init);
|
|
5319
|
+
if (scr_exc_pending()) { scr_dyn_release(view); ScrPromise *p = scr_promise_new(); scr_promise_reject_pending(p); return p; }
|
|
5320
|
+
ScrPromise *result = scr_fetch_input(input, view);
|
|
5321
|
+
scr_dyn_release(view);
|
|
5322
|
+
return result;
|
|
5323
|
+
}
|
|
5324
|
+
if (input && input->kind == SCR_DYN_HANDLE && input->v.handle.tag == SCR_DYNH_FETCH_REQUEST) {
|
|
5325
|
+
ScrDyn *converted = scr_fetch_request_new(input, init);
|
|
5326
|
+
if (!converted) { ScrPromise *p = scr_promise_new(); scr_promise_reject_pending(p); return p; }
|
|
5327
|
+
SfRequest *r = converted->v.handle.ptr;
|
|
5328
|
+
ScrDyn *dictionary = scr_dyn_new_obj();
|
|
5329
|
+
scr_dyn_obj_set(dictionary, "method", 6, scr_dyn_new_str(r->method));
|
|
5330
|
+
scr_dyn_obj_set(dictionary, "headers", 7, scr_dyn_new_handle(r->payload->headers, SCR_DYNH_FETCH_HEADERS));
|
|
5331
|
+
scr_dyn_obj_set(dictionary, "signal", 6, scr_dyn_new_handle(r->signal, SCR_DYNH_ABORT_SIGNAL));
|
|
5332
|
+
scr_dyn_obj_set(dictionary, "redirect", 8, scr_dyn_new_str(r->redirect));
|
|
5333
|
+
if (!r->payload->null_body) {
|
|
5334
|
+
scr_dyn_obj_set(dictionary, "body", 4, scr_dyn_new_handle(r->payload->body, SCR_DYNH_WEB_STREAM));
|
|
5335
|
+
ScrStr *half = scr_str_new("half", 4); scr_dyn_obj_set(dictionary, "duplex", 6, scr_dyn_new_str(half)); scr_str_release(half);
|
|
5336
|
+
}
|
|
5337
|
+
ScrPromise *result = scr_fetch_static(r->url, dictionary);
|
|
5338
|
+
scr_dyn_release(dictionary); scr_dyn_release(converted); return result;
|
|
5339
|
+
}
|
|
5340
|
+
ScrStr *url = scr_dyn_string_coerce_js(input);
|
|
5341
|
+
if (!url) { ScrPromise *p = scr_promise_new(); scr_promise_reject_pending(p); return p; }
|
|
5342
|
+
ScrPromise *result = scr_fetch_static(url, init); scr_str_release(url); return result;
|
|
5343
|
+
}
|
|
5344
|
+
|
|
5345
|
+
static ScrDyn *sf_fetch_function_call(ScrClosure *closure, ScrDyn *const *args, size_t argc) {
|
|
5346
|
+
(void)closure;
|
|
5347
|
+
ScrPromise *p = scr_fetch_input(argc ? args[0] : scr_dyn_undefined(), argc > 1 ? args[1] : scr_dyn_undefined());
|
|
5348
|
+
ScrDyn *result = scr_dyn_new_promise(p); scr_promise_release(p); return result;
|
|
5349
|
+
}
|
|
5350
|
+
static ScrDyn *sf_fetch_function_value;
|
|
5351
|
+
static void sf_fetch_function_cleanup(void) {
|
|
5352
|
+
ScrDyn *value = sf_fetch_function_value;
|
|
5353
|
+
sf_fetch_function_value = NULL;
|
|
5354
|
+
scr_dyn_release(value);
|
|
5355
|
+
}
|
|
5356
|
+
bool scr_fetch_web_is(const ScrDyn *value, const ScrStr *name) {
|
|
5357
|
+
if (value->kind != SCR_DYN_HANDLE) return false;
|
|
5358
|
+
if (sf_name(name->data, name->len, "Response")) return value->v.handle.tag == SCR_DYNH_FETCH_RESPONSE;
|
|
5359
|
+
if (sf_name(name->data, name->len, "Request")) return value->v.handle.tag == SCR_DYNH_FETCH_REQUEST;
|
|
5360
|
+
return sf_name(name->data, name->len, "Headers") && value->v.handle.tag == SCR_DYNH_FETCH_HEADERS;
|
|
5361
|
+
}
|
|
5362
|
+
|
|
5363
|
+
bool scr_fetch_stream_is(const ScrDyn *value) {
|
|
5364
|
+
return value && value->kind == SCR_DYN_HANDLE && value->v.handle.tag == SCR_DYNH_WEB_STREAM;
|
|
5365
|
+
}
|
|
5366
|
+
ScrDyn *scr_fetch_function(void) {
|
|
5367
|
+
if (!sf_fetch_function_value) {
|
|
5368
|
+
sf_fetch_function_value = scr_dyn_new_func(scr_closure_new(NULL, 0), sf_fetch_function_call, 1, "fetch", "fetch");
|
|
5369
|
+
scr_atexit(sf_fetch_function_cleanup);
|
|
5370
|
+
}
|
|
5371
|
+
return scr_dyn_retain(sf_fetch_function_value);
|
|
5372
|
+
}
|
|
5373
|
+
|
|
5374
|
+
static int sf_data_hex(unsigned char ch) {
|
|
5375
|
+
if (ch >= '0' && ch <= '9') return ch - '0';
|
|
5376
|
+
if (ch >= 'a' && ch <= 'f') return ch - 'a' + 10;
|
|
5377
|
+
if (ch >= 'A' && ch <= 'F') return ch - 'A' + 10;
|
|
5378
|
+
return -1;
|
|
5379
|
+
}
|
|
5380
|
+
|
|
5381
|
+
static ScrDyn *sf_data_response(ScrStr *url) {
|
|
5382
|
+
size_t end = url->len;
|
|
5383
|
+
for (size_t i = 5; i < end; i++) if (url->data[i] == '#') { end = i; break; }
|
|
5384
|
+
size_t comma = 5;
|
|
5385
|
+
while (comma < end && url->data[comma] != ',') comma++;
|
|
5386
|
+
if (comma == end) { sf_type_error("fetch failed"); return NULL; }
|
|
5387
|
+
size_t meta_end = comma;
|
|
5388
|
+
bool base64 = meta_end >= 12 && strncasecmp(url->data + meta_end - 7, ";base64", 7) == 0;
|
|
5389
|
+
if (base64) meta_end -= 7;
|
|
5390
|
+
ScrBytes *bytes = scr_bytes_new(SCR_BYTES_U8, (double)(end - comma - 1));
|
|
5391
|
+
size_t n = 0;
|
|
5392
|
+
for (size_t i = comma + 1; i < end; i++) {
|
|
5393
|
+
int a, b;
|
|
5394
|
+
if (url->data[i] == '%' && i + 2 < end && (a = sf_data_hex(url->data[i + 1])) >= 0 && (b = sf_data_hex(url->data[i + 2])) >= 0) {
|
|
5395
|
+
bytes->data[n++] = (unsigned char)((a << 4) | b); i += 2;
|
|
5396
|
+
} else bytes->data[n++] = (unsigned char)url->data[i];
|
|
5397
|
+
}
|
|
5398
|
+
bytes->len = n;
|
|
5399
|
+
if (base64) {
|
|
5400
|
+
ScrStr *encoded = scr_str_new((const char *)bytes->data, bytes->len);
|
|
5401
|
+
ScrStr *encoding = scr_str_new("base64", 6);
|
|
5402
|
+
ScrBytes *decoded = scr_bytes_from_str(encoded, encoding);
|
|
5403
|
+
scr_str_release(encoded); scr_str_release(encoding); scr_bytes_release(bytes); bytes = decoded;
|
|
5404
|
+
}
|
|
5405
|
+
ScrDyn *body = scr_dyn_new_bytes(bytes); scr_bytes_release(bytes);
|
|
5406
|
+
ScrStr *mime = meta_end == 5 ? scr_str_new("text/plain;charset=US-ASCII", 26) : scr_str_new(url->data + 5, meta_end - 5);
|
|
5407
|
+
if (mime->len && mime->data[0] == ';') {
|
|
5408
|
+
ScrJsonBuf b; scr_jb_init(&b); scr_jb_puts(&b, "text/plain"); for (size_t i = 0; i < mime->len; i++) scr_jb_putc(&b, mime->data[i]);
|
|
5409
|
+
scr_str_release(mime); mime = scr_jb_finish(&b);
|
|
5410
|
+
}
|
|
5411
|
+
ScrDyn *headers = scr_dyn_new_obj(); scr_dyn_obj_set(headers, "content-type", 12, scr_dyn_new_str(mime)); scr_str_release(mime);
|
|
5412
|
+
ScrDyn *init = scr_dyn_new_obj(); scr_dyn_obj_set(init, "headers", 7, headers);
|
|
5413
|
+
ScrStr *ok = scr_str_new("OK", 2); scr_dyn_obj_set(init, "statusText", 10, scr_dyn_new_str(ok)); scr_str_release(ok);
|
|
5414
|
+
ScrDyn *result = scr_fetch_response_new(body, init); scr_dyn_release(body); scr_dyn_release(init);
|
|
5415
|
+
if (result) {
|
|
5416
|
+
SfResponse *response = result->v.handle.ptr;
|
|
5417
|
+
scr_str_release(response->url); response->url = scr_str_new(url->data, end);
|
|
5418
|
+
response->headers->immutable = true;
|
|
5419
|
+
}
|
|
5420
|
+
return result;
|
|
5421
|
+
}
|
|
5422
|
+
|
|
5172
5423
|
ScrPromise *scr_fetch_static(ScrStr *url, ScrDyn *init) {
|
|
5424
|
+
if (init && init->kind == SCR_DYN_TYPED_REF) {
|
|
5425
|
+
ScrDyn *view = scr_dyn_typed_ref_materialize(init);
|
|
5426
|
+
if (scr_exc_pending()) {
|
|
5427
|
+
scr_dyn_release(view);
|
|
5428
|
+
ScrPromise *promise = scr_promise_new();
|
|
5429
|
+
scr_promise_reject_pending(promise);
|
|
5430
|
+
return promise;
|
|
5431
|
+
}
|
|
5432
|
+
ScrPromise *result = scr_fetch_static(url, view);
|
|
5433
|
+
scr_dyn_release(view);
|
|
5434
|
+
return result;
|
|
5435
|
+
}
|
|
5173
5436
|
ScrPromise *promise = scr_promise_new();
|
|
5174
5437
|
if (init && init->kind != SCR_DYN_OBJ &&
|
|
5175
5438
|
init->kind != SCR_DYN_UNDEF && init->kind != SCR_DYN_NULL) {
|
|
@@ -5324,7 +5587,8 @@ ScrPromise *scr_fetch_static(ScrStr *url, ScrDyn *init) {
|
|
|
5324
5587
|
return sf_reject_now(promise, "fetch failed");
|
|
5325
5588
|
}
|
|
5326
5589
|
bool https = sf_eq_ci(u->scheme, "https");
|
|
5327
|
-
|
|
5590
|
+
bool data_url = sf_eq_ci(u->scheme, "data");
|
|
5591
|
+
if (!https && !sf_eq_ci(u->scheme, "http") && !data_url) {
|
|
5328
5592
|
scr_dyn_release(coerced_body);
|
|
5329
5593
|
scr_arr_release(headers);
|
|
5330
5594
|
scr_str_release(method);
|
|
@@ -5406,6 +5670,14 @@ ScrPromise *scr_fetch_static(ScrStr *url, ScrDyn *init) {
|
|
|
5406
5670
|
return promise;
|
|
5407
5671
|
}
|
|
5408
5672
|
|
|
5673
|
+
if (data_url) {
|
|
5674
|
+
ScrDyn *response = sf_data_response(url);
|
|
5675
|
+
scr_dyn_release(coerced_body); scr_arr_release(headers); scr_str_release(method); scr_url_release(u);
|
|
5676
|
+
if (response) { scr_promise_resolve_dyn(promise, response); }
|
|
5677
|
+
else scr_promise_reject_pending(promise);
|
|
5678
|
+
return promise;
|
|
5679
|
+
}
|
|
5680
|
+
|
|
5409
5681
|
SfTransfer *t = calloc(1, sizeof *t);
|
|
5410
5682
|
if (!t) sf_oom();
|
|
5411
5683
|
t->rc = 1; /* registry */
|
|
@@ -5457,6 +5729,9 @@ static const ScrDynHandleOps sf_controller_ops = {
|
|
|
5457
5729
|
"ReadableStreamDefaultController", &sf_stream_retain_v,
|
|
5458
5730
|
&sf_stream_release_v, &sf_controller_invoke, &sf_controller_get,
|
|
5459
5731
|
&sf_no_set, NULL};
|
|
5732
|
+
static const ScrDynHandleOps sf_request_ops = {
|
|
5733
|
+
"Request", &sf_request_retain_v, &sf_request_release_v,
|
|
5734
|
+
&sf_request_invoke, &sf_request_get, &sf_no_set, NULL};
|
|
5460
5735
|
static const ScrDynHandleOps sf_response_ops = {
|
|
5461
5736
|
"Response", &sf_response_retain_v, &sf_response_release_v,
|
|
5462
5737
|
&sf_response_invoke, &sf_response_get, &sf_no_set, NULL};
|
|
@@ -5497,6 +5772,7 @@ void scr_fetch_install(void) {
|
|
|
5497
5772
|
if (installed) return;
|
|
5498
5773
|
installed = true;
|
|
5499
5774
|
scr_tls_ca_install();
|
|
5775
|
+
scr_global_fetch_install(scr_fetch_function);
|
|
5500
5776
|
sf_proxy_snapshot();
|
|
5501
5777
|
scr_net_install();
|
|
5502
5778
|
scr_dyn_handle_install(SCR_DYNH_ABORT_SIGNAL, &sf_signal_ops);
|
|
@@ -5505,13 +5781,45 @@ void scr_fetch_install(void) {
|
|
|
5505
5781
|
scr_dyn_handle_install(SCR_DYNH_WEB_STREAM, &sf_stream_ops);
|
|
5506
5782
|
scr_dyn_handle_install(SCR_DYNH_WEB_READER, &sf_reader_ops);
|
|
5507
5783
|
scr_dyn_handle_install(SCR_DYNH_WEB_CONTROLLER, &sf_controller_ops);
|
|
5784
|
+
scr_dyn_handle_install(SCR_DYNH_FETCH_REQUEST, &sf_request_ops);
|
|
5508
5785
|
scr_dyn_handle_install(SCR_DYNH_FETCH_RESPONSE, &sf_response_ops);
|
|
5509
5786
|
scr_dyn_handle_install(SCR_DYNH_FETCH_HEADERS, &sf_headers_ops);
|
|
5510
5787
|
scr_dyn_handle_install(SCR_DYNH_EVENT, &sf_event_ops);
|
|
5511
5788
|
scr_atexit(sf_teardown);
|
|
5512
5789
|
}
|
|
5513
5790
|
|
|
5514
|
-
#else
|
|
5791
|
+
#else /* SCR_FETCH_SIGNAL_ONLY */
|
|
5792
|
+
|
|
5793
|
+
static bool sf_no_set(void *ptr, const char *key, size_t len, const ScrDyn *value) {
|
|
5794
|
+
(void)ptr; (void)key; (void)len; (void)value;
|
|
5795
|
+
return false;
|
|
5796
|
+
}
|
|
5797
|
+
static const ScrDynHandleOps sf_signal_ops = {
|
|
5798
|
+
"AbortSignal", &sf_signal_retain_v, &sf_signal_release_v,
|
|
5799
|
+
&sf_signal_invoke, &sf_signal_get, &sf_signal_set, NULL };
|
|
5800
|
+
static const ScrDynHandleOps sf_abort_controller_ops = {
|
|
5801
|
+
"AbortController", &sf_signal_retain_v, &sf_signal_release_v,
|
|
5802
|
+
&sf_abort_controller_invoke, &sf_abort_controller_get, &sf_no_set, NULL };
|
|
5803
|
+
static const ScrDynHandleOps sf_event_ops = {
|
|
5804
|
+
"Event", &sf_event_retain_v, &sf_event_release_v,
|
|
5805
|
+
&sf_event_invoke, &sf_event_get, &sf_event_set, NULL };
|
|
5806
|
+
static void sf_signal_teardown(void) {
|
|
5807
|
+
while (sf_callback_signals) sf_signal_drop_callbacks(sf_callback_signals);
|
|
5808
|
+
while (sf_reason_signals) sf_signal_drop_reason(sf_reason_signals);
|
|
5809
|
+
}
|
|
5810
|
+
static void sf_signal_install(void) {
|
|
5811
|
+
static bool installed;
|
|
5812
|
+
if (installed) return;
|
|
5813
|
+
installed = true;
|
|
5814
|
+
scr_dyn_handle_install(SCR_DYNH_ABORT_SIGNAL, &sf_signal_ops);
|
|
5815
|
+
scr_dyn_handle_install(SCR_DYNH_ABORT_CONTROLLER, &sf_abort_controller_ops);
|
|
5816
|
+
scr_dyn_handle_install(SCR_DYNH_EVENT, &sf_event_ops);
|
|
5817
|
+
scr_atexit(sf_signal_teardown);
|
|
5818
|
+
}
|
|
5819
|
+
|
|
5820
|
+
#endif /* SCR_FETCH_SIGNAL_ONLY */
|
|
5821
|
+
|
|
5822
|
+
#else /* SCR_DYNAMIC */
|
|
5515
5823
|
|
|
5516
5824
|
#include "scr_runtime.h"
|
|
5517
5825
|
#include "scr_url_internal.h"
|
|
@@ -476,6 +476,37 @@ ScrPromise *scr_file_handle_close_promise(ScrFileHandle *h) {
|
|
|
476
476
|
return scr_promise_settled_void();
|
|
477
477
|
}
|
|
478
478
|
|
|
479
|
+
ScrPromise *scr_file_handle_sync_promise(ScrFileHandle *h) {
|
|
480
|
+
if (scr_file_handle_require_open(h)) scr_fs_fsync((double)h->fd);
|
|
481
|
+
return scr_promise_settled_void();
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
ScrPromise *scr_file_handle_datasync_promise(ScrFileHandle *h) {
|
|
485
|
+
if (scr_file_handle_require_open(h)) scr_fs_fdatasync((double)h->fd);
|
|
486
|
+
return scr_promise_settled_void();
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
ScrPromise *scr_file_handle_truncate_promise(ScrFileHandle *h, double length) {
|
|
490
|
+
if (scr_file_handle_require_open(h)) scr_fs_ftruncate((double)h->fd, length);
|
|
491
|
+
return scr_promise_settled_void();
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
ScrPromise *scr_file_handle_chmod_promise(ScrFileHandle *h, double mode) {
|
|
495
|
+
if (scr_file_handle_require_open(h) && scr_file_handle_mode_valid(mode))
|
|
496
|
+
scr_fs_fchmod((double)h->fd, mode);
|
|
497
|
+
return scr_promise_settled_void();
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
double scr_file_handle_readv(ScrFileHandle *h, ScrArr *buffers, double position) {
|
|
501
|
+
if (!scr_file_handle_require_open(h)) return 0;
|
|
502
|
+
return scr_fs_readv_sync((double)h->fd, buffers, position);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
double scr_file_handle_writev(ScrFileHandle *h, ScrArr *buffers, double position) {
|
|
506
|
+
if (!scr_file_handle_require_open(h)) return 0;
|
|
507
|
+
return scr_fs_writev_sync((double)h->fd, buffers, position);
|
|
508
|
+
}
|
|
509
|
+
|
|
479
510
|
ScrPromise *scr_file_handle_read_file_promise(ScrFileHandle *h,
|
|
480
511
|
ScrStr *encoding) {
|
|
481
512
|
(void)encoding;
|
|
@@ -5567,6 +5567,8 @@ static ScrDyn *scr_http_dynh_agent_invoke(void *h, ScrDyn *self, const char *met
|
|
|
5567
5567
|
}
|
|
5568
5568
|
if (strcmp(method, "getName") == 0) {
|
|
5569
5569
|
const ScrDyn *opts = argc > 0 ? args[0] : scr_dyn_undefined();
|
|
5570
|
+
ScrDyn *view = opts->kind == SCR_DYN_TYPED_REF ? scr_dyn_typed_ref_materialize(opts) : NULL;
|
|
5571
|
+
if (view != NULL) opts = view;
|
|
5570
5572
|
ScrStr *host = scr_http_dynh_opt_str(opts, "host");
|
|
5571
5573
|
ScrStr *port = scr_http_dynh_opt_str(opts, "port");
|
|
5572
5574
|
ScrStr *laddr = scr_http_dynh_opt_str(opts, "localAddress");
|
|
@@ -5587,6 +5589,7 @@ static ScrDyn *scr_http_dynh_agent_invoke(void *h, ScrDyn *self, const char *met
|
|
|
5587
5589
|
scr_str_release(port);
|
|
5588
5590
|
scr_str_release(laddr);
|
|
5589
5591
|
scr_str_release(spath);
|
|
5592
|
+
scr_dyn_release(view);
|
|
5590
5593
|
ScrDyn *d = scr_dyn_new_str(name);
|
|
5591
5594
|
scr_str_release(name);
|
|
5592
5595
|
return d;
|