@scriptc/runtime 0.0.0 → 0.0.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/LICENSE +202 -0
- package/package.json +16 -6
- package/src/scr_array.c +488 -0
- package/src/scr_assert.c +1393 -0
- package/src/scr_async.c +2593 -0
- package/src/scr_async_dyn.c +607 -0
- package/src/scr_bytes.c +1425 -0
- package/src/scr_bytes_io.c +161 -0
- package/src/scr_child.c +3587 -0
- package/src/scr_closure.c +214 -0
- package/src/scr_console.c +143 -0
- package/src/scr_cycle.c +218 -0
- package/src/scr_dc.c +805 -0
- package/src/scr_dgram.c +1007 -0
- package/src/scr_dyn_handle.c +154 -0
- package/src/scr_dyn_invoke.c +644 -0
- package/src/scr_error.c +332 -0
- package/src/scr_events.c +714 -0
- package/src/scr_events_emitter.c +699 -0
- package/src/scr_exception.c +242 -0
- package/src/scr_fetch.c +1130 -0
- package/src/scr_fetch_curl.c +654 -0
- package/src/scr_http.c +3482 -0
- package/src/scr_http2.c +3030 -0
- package/src/scr_inspect.c +803 -0
- package/src/scr_inspect_island.c +51 -0
- package/src/scr_island.c +9363 -0
- package/src/scr_json.c +2151 -0
- package/src/scr_lib.c +3612 -0
- package/src/scr_loop_epoll.c +241 -0
- package/src/scr_loop_kqueue.c +121 -0
- package/src/scr_loop_wsapoll.c +208 -0
- package/src/scr_map.c +591 -0
- package/src/scr_net.c +3017 -0
- package/src/scr_net_island.c +458 -0
- package/src/scr_number.c +115 -0
- package/src/scr_object.c +25 -0
- package/src/scr_path.c +1266 -0
- package/src/scr_platform.h +119 -0
- package/src/scr_readline.c +287 -0
- package/src/scr_regex.c +1080 -0
- package/src/scr_runtime.h +5046 -0
- package/src/scr_stream.c +2877 -0
- package/src/scr_string.c +1264 -0
- package/src/scr_symbol.c +132 -0
- package/src/scr_test.c +662 -0
- package/src/scr_tls.c +1520 -0
- package/src/scr_union.c +105 -0
- package/src/scr_url.c +911 -0
- package/src/scr_url_internal.h +29 -0
- package/src/scr_url_params.c +561 -0
- package/src/scr_watch.c +568 -0
- package/src/scr_web.c +1778 -0
- package/src/scr_win.c +76 -0
- package/src/scr_zlib.c +197 -0
- package/src/scr_zlib_island.c +15 -0
- package/vendor/README.md +52 -0
- package/vendor/curl/COPYRIGHT +534 -0
- package/vendor/curl/include/curl/curl.h +3214 -0
- package/vendor/curl/include/curl/curlver.h +79 -0
- package/vendor/curl/include/curl/easy.h +125 -0
- package/vendor/curl/include/curl/header.h +74 -0
- package/vendor/curl/include/curl/mprintf.h +52 -0
- package/vendor/curl/include/curl/multi.h +460 -0
- package/vendor/curl/include/curl/options.h +70 -0
- package/vendor/curl/include/curl/stdcheaders.h +35 -0
- package/vendor/curl/include/curl/system.h +508 -0
- package/vendor/curl/include/curl/typecheck-gcc.h +716 -0
- package/vendor/curl/include/curl/urlapi.h +149 -0
- package/vendor/curl/include/curl/websockets.h +84 -0
- package/vendor/mbedtls/LICENSE +553 -0
- package/vendor/mbedtls/include/CMakeLists.txt +22 -0
- package/vendor/mbedtls/include/mbedtls/aes.h +631 -0
- package/vendor/mbedtls/include/mbedtls/aria.h +343 -0
- package/vendor/mbedtls/include/mbedtls/asn1.h +642 -0
- package/vendor/mbedtls/include/mbedtls/asn1write.h +390 -0
- package/vendor/mbedtls/include/mbedtls/base64.h +82 -0
- package/vendor/mbedtls/include/mbedtls/bignum.h +1088 -0
- package/vendor/mbedtls/include/mbedtls/block_cipher.h +76 -0
- package/vendor/mbedtls/include/mbedtls/build_info.h +194 -0
- package/vendor/mbedtls/include/mbedtls/camellia.h +305 -0
- package/vendor/mbedtls/include/mbedtls/ccm.h +526 -0
- package/vendor/mbedtls/include/mbedtls/chacha20.h +209 -0
- package/vendor/mbedtls/include/mbedtls/chachapoly.h +351 -0
- package/vendor/mbedtls/include/mbedtls/check_config.h +1149 -0
- package/vendor/mbedtls/include/mbedtls/cipher.h +1250 -0
- package/vendor/mbedtls/include/mbedtls/cmac.h +246 -0
- package/vendor/mbedtls/include/mbedtls/compat-2.x.h +46 -0
- package/vendor/mbedtls/include/mbedtls/config_adjust_legacy_crypto.h +578 -0
- package/vendor/mbedtls/include/mbedtls/config_adjust_legacy_from_psa.h +873 -0
- package/vendor/mbedtls/include/mbedtls/config_adjust_psa_from_legacy.h +359 -0
- package/vendor/mbedtls/include/mbedtls/config_adjust_psa_superset_legacy.h +145 -0
- package/vendor/mbedtls/include/mbedtls/config_adjust_ssl.h +91 -0
- package/vendor/mbedtls/include/mbedtls/config_adjust_x509.h +35 -0
- package/vendor/mbedtls/include/mbedtls/config_psa.h +61 -0
- package/vendor/mbedtls/include/mbedtls/constant_time.h +36 -0
- package/vendor/mbedtls/include/mbedtls/ctr_drbg.h +596 -0
- package/vendor/mbedtls/include/mbedtls/debug.h +156 -0
- package/vendor/mbedtls/include/mbedtls/des.h +385 -0
- package/vendor/mbedtls/include/mbedtls/dhm.h +972 -0
- package/vendor/mbedtls/include/mbedtls/ecdh.h +455 -0
- package/vendor/mbedtls/include/mbedtls/ecdsa.h +674 -0
- package/vendor/mbedtls/include/mbedtls/ecjpake.h +298 -0
- package/vendor/mbedtls/include/mbedtls/ecp.h +1517 -0
- package/vendor/mbedtls/include/mbedtls/entropy.h +274 -0
- package/vendor/mbedtls/include/mbedtls/error.h +201 -0
- package/vendor/mbedtls/include/mbedtls/gcm.h +387 -0
- package/vendor/mbedtls/include/mbedtls/hkdf.h +124 -0
- package/vendor/mbedtls/include/mbedtls/hmac_drbg.h +434 -0
- package/vendor/mbedtls/include/mbedtls/lms.h +440 -0
- package/vendor/mbedtls/include/mbedtls/mbedtls_config.h +4446 -0
- package/vendor/mbedtls/include/mbedtls/md.h +526 -0
- package/vendor/mbedtls/include/mbedtls/md5.h +190 -0
- package/vendor/mbedtls/include/mbedtls/memory_buffer_alloc.h +142 -0
- package/vendor/mbedtls/include/mbedtls/net_sockets.h +299 -0
- package/vendor/mbedtls/include/mbedtls/nist_kw.h +166 -0
- package/vendor/mbedtls/include/mbedtls/oid.h +727 -0
- package/vendor/mbedtls/include/mbedtls/pem.h +160 -0
- package/vendor/mbedtls/include/mbedtls/pk.h +1303 -0
- package/vendor/mbedtls/include/mbedtls/pkcs12.h +186 -0
- package/vendor/mbedtls/include/mbedtls/pkcs5.h +198 -0
- package/vendor/mbedtls/include/mbedtls/pkcs7.h +252 -0
- package/vendor/mbedtls/include/mbedtls/platform.h +516 -0
- package/vendor/mbedtls/include/mbedtls/platform_time.h +79 -0
- package/vendor/mbedtls/include/mbedtls/platform_util.h +247 -0
- package/vendor/mbedtls/include/mbedtls/poly1305.h +168 -0
- package/vendor/mbedtls/include/mbedtls/private_access.h +20 -0
- package/vendor/mbedtls/include/mbedtls/psa_util.h +207 -0
- package/vendor/mbedtls/include/mbedtls/ripemd160.h +136 -0
- package/vendor/mbedtls/include/mbedtls/rsa.h +1170 -0
- package/vendor/mbedtls/include/mbedtls/sha1.h +219 -0
- package/vendor/mbedtls/include/mbedtls/sha256.h +200 -0
- package/vendor/mbedtls/include/mbedtls/sha3.h +172 -0
- package/vendor/mbedtls/include/mbedtls/sha512.h +208 -0
- package/vendor/mbedtls/include/mbedtls/ssl.h +5887 -0
- package/vendor/mbedtls/include/mbedtls/ssl_cache.h +187 -0
- package/vendor/mbedtls/include/mbedtls/ssl_ciphersuites.h +482 -0
- package/vendor/mbedtls/include/mbedtls/ssl_cookie.h +106 -0
- package/vendor/mbedtls/include/mbedtls/ssl_ticket.h +199 -0
- package/vendor/mbedtls/include/mbedtls/threading.h +167 -0
- package/vendor/mbedtls/include/mbedtls/timing.h +94 -0
- package/vendor/mbedtls/include/mbedtls/version.h +78 -0
- package/vendor/mbedtls/include/mbedtls/x509.h +500 -0
- package/vendor/mbedtls/include/mbedtls/x509_crl.h +184 -0
- package/vendor/mbedtls/include/mbedtls/x509_crt.h +1208 -0
- package/vendor/mbedtls/include/mbedtls/x509_csr.h +382 -0
- package/vendor/mbedtls/include/psa/build_info.h +20 -0
- package/vendor/mbedtls/include/psa/crypto.h +4998 -0
- package/vendor/mbedtls/include/psa/crypto_adjust_auto_enabled.h +31 -0
- package/vendor/mbedtls/include/psa/crypto_adjust_config_dependencies.h +51 -0
- package/vendor/mbedtls/include/psa/crypto_adjust_config_key_pair_types.h +101 -0
- package/vendor/mbedtls/include/psa/crypto_adjust_config_synonyms.h +49 -0
- package/vendor/mbedtls/include/psa/crypto_builtin_composites.h +214 -0
- package/vendor/mbedtls/include/psa/crypto_builtin_key_derivation.h +118 -0
- package/vendor/mbedtls/include/psa/crypto_builtin_primitives.h +114 -0
- package/vendor/mbedtls/include/psa/crypto_compat.h +230 -0
- package/vendor/mbedtls/include/psa/crypto_config.h +145 -0
- package/vendor/mbedtls/include/psa/crypto_driver_common.h +44 -0
- package/vendor/mbedtls/include/psa/crypto_driver_contexts_composites.h +151 -0
- package/vendor/mbedtls/include/psa/crypto_driver_contexts_key_derivation.h +52 -0
- package/vendor/mbedtls/include/psa/crypto_driver_contexts_primitives.h +105 -0
- package/vendor/mbedtls/include/psa/crypto_extra.h +2145 -0
- package/vendor/mbedtls/include/psa/crypto_legacy.h +88 -0
- package/vendor/mbedtls/include/psa/crypto_platform.h +102 -0
- package/vendor/mbedtls/include/psa/crypto_se_driver.h +1383 -0
- package/vendor/mbedtls/include/psa/crypto_sizes.h +1319 -0
- package/vendor/mbedtls/include/psa/crypto_struct.h +527 -0
- package/vendor/mbedtls/include/psa/crypto_types.h +508 -0
- package/vendor/mbedtls/include/psa/crypto_values.h +2782 -0
- package/vendor/mbedtls/library/aes.c +2294 -0
- package/vendor/mbedtls/library/aesce.c +624 -0
- package/vendor/mbedtls/library/aesce.h +136 -0
- package/vendor/mbedtls/library/aesni.c +846 -0
- package/vendor/mbedtls/library/aesni.h +162 -0
- package/vendor/mbedtls/library/alignment.h +704 -0
- package/vendor/mbedtls/library/aria.c +969 -0
- package/vendor/mbedtls/library/asn1parse.c +468 -0
- package/vendor/mbedtls/library/asn1write.c +440 -0
- package/vendor/mbedtls/library/base64.c +322 -0
- package/vendor/mbedtls/library/base64_internal.h +45 -0
- package/vendor/mbedtls/library/bignum.c +2583 -0
- package/vendor/mbedtls/library/bignum_core.c +1240 -0
- package/vendor/mbedtls/library/bignum_core.h +872 -0
- package/vendor/mbedtls/library/bignum_core_invasive.h +38 -0
- package/vendor/mbedtls/library/bignum_internal.h +122 -0
- package/vendor/mbedtls/library/bignum_mod.c +394 -0
- package/vendor/mbedtls/library/bignum_mod.h +452 -0
- package/vendor/mbedtls/library/bignum_mod_raw.c +276 -0
- package/vendor/mbedtls/library/bignum_mod_raw.h +416 -0
- package/vendor/mbedtls/library/bignum_mod_raw_invasive.h +34 -0
- package/vendor/mbedtls/library/block_cipher.c +207 -0
- package/vendor/mbedtls/library/block_cipher_internal.h +99 -0
- package/vendor/mbedtls/library/bn_mul.h +1094 -0
- package/vendor/mbedtls/library/camellia.c +1058 -0
- package/vendor/mbedtls/library/ccm.c +777 -0
- package/vendor/mbedtls/library/chacha20.c +563 -0
- package/vendor/mbedtls/library/chacha20_internal.h +23 -0
- package/vendor/mbedtls/library/chachapoly.c +487 -0
- package/vendor/mbedtls/library/check_crypto_config.h +136 -0
- package/vendor/mbedtls/library/cipher.c +1712 -0
- package/vendor/mbedtls/library/cipher_invasive.h +28 -0
- package/vendor/mbedtls/library/cipher_wrap.c +2482 -0
- package/vendor/mbedtls/library/cipher_wrap.h +178 -0
- package/vendor/mbedtls/library/cmac.c +1067 -0
- package/vendor/mbedtls/library/common.h +487 -0
- package/vendor/mbedtls/library/constant_time.c +247 -0
- package/vendor/mbedtls/library/constant_time_impl.h +541 -0
- package/vendor/mbedtls/library/constant_time_internal.h +579 -0
- package/vendor/mbedtls/library/ctr.h +35 -0
- package/vendor/mbedtls/library/ctr_drbg.c +1016 -0
- package/vendor/mbedtls/library/debug.c +475 -0
- package/vendor/mbedtls/library/debug_internal.h +185 -0
- package/vendor/mbedtls/library/des.c +1042 -0
- package/vendor/mbedtls/library/dhm.c +700 -0
- package/vendor/mbedtls/library/ecdh.c +696 -0
- package/vendor/mbedtls/library/ecdsa.c +858 -0
- package/vendor/mbedtls/library/ecjpake.c +1216 -0
- package/vendor/mbedtls/library/ecp.c +3674 -0
- package/vendor/mbedtls/library/ecp_curves.c +6125 -0
- package/vendor/mbedtls/library/ecp_curves_new.c +9 -0
- package/vendor/mbedtls/library/ecp_internal_alt.h +287 -0
- package/vendor/mbedtls/library/ecp_invasive.h +305 -0
- package/vendor/mbedtls/library/entropy.c +680 -0
- package/vendor/mbedtls/library/entropy_poll.c +233 -0
- package/vendor/mbedtls/library/entropy_poll.h +64 -0
- package/vendor/mbedtls/library/error.c +878 -0
- package/vendor/mbedtls/library/gcm.c +1330 -0
- package/vendor/mbedtls/library/hkdf.c +161 -0
- package/vendor/mbedtls/library/hmac_drbg.c +633 -0
- package/vendor/mbedtls/library/lmots.c +789 -0
- package/vendor/mbedtls/library/lmots.h +288 -0
- package/vendor/mbedtls/library/lms.c +778 -0
- package/vendor/mbedtls/library/md.c +1108 -0
- package/vendor/mbedtls/library/md5.c +426 -0
- package/vendor/mbedtls/library/md_psa.h +26 -0
- package/vendor/mbedtls/library/md_wrap.h +46 -0
- package/vendor/mbedtls/library/memory_buffer_alloc.c +751 -0
- package/vendor/mbedtls/library/mps_common.h +181 -0
- package/vendor/mbedtls/library/mps_error.h +89 -0
- package/vendor/mbedtls/library/mps_reader.c +538 -0
- package/vendor/mbedtls/library/mps_reader.h +366 -0
- package/vendor/mbedtls/library/mps_trace.c +112 -0
- package/vendor/mbedtls/library/mps_trace.h +154 -0
- package/vendor/mbedtls/library/net_sockets.c +694 -0
- package/vendor/mbedtls/library/nist_kw.c +729 -0
- package/vendor/mbedtls/library/oid.c +1166 -0
- package/vendor/mbedtls/library/padlock.c +157 -0
- package/vendor/mbedtls/library/padlock.h +111 -0
- package/vendor/mbedtls/library/pem.c +554 -0
- package/vendor/mbedtls/library/pk.c +1602 -0
- package/vendor/mbedtls/library/pk_ecc.c +261 -0
- package/vendor/mbedtls/library/pk_internal.h +241 -0
- package/vendor/mbedtls/library/pk_wrap.c +1618 -0
- package/vendor/mbedtls/library/pk_wrap.h +138 -0
- package/vendor/mbedtls/library/pkcs12.c +437 -0
- package/vendor/mbedtls/library/pkcs5.c +500 -0
- package/vendor/mbedtls/library/pkcs7.c +787 -0
- package/vendor/mbedtls/library/pkparse.c +1392 -0
- package/vendor/mbedtls/library/pkwrite.c +631 -0
- package/vendor/mbedtls/library/pkwrite.h +121 -0
- package/vendor/mbedtls/library/platform.c +402 -0
- package/vendor/mbedtls/library/platform_util.c +258 -0
- package/vendor/mbedtls/library/poly1305.c +492 -0
- package/vendor/mbedtls/library/psa_crypto.c +9532 -0
- package/vendor/mbedtls/library/psa_crypto_aead.c +646 -0
- package/vendor/mbedtls/library/psa_crypto_aead.h +499 -0
- package/vendor/mbedtls/library/psa_crypto_cipher.c +747 -0
- package/vendor/mbedtls/library/psa_crypto_cipher.h +316 -0
- package/vendor/mbedtls/library/psa_crypto_client.c +22 -0
- package/vendor/mbedtls/library/psa_crypto_core.h +983 -0
- package/vendor/mbedtls/library/psa_crypto_core_common.h +52 -0
- package/vendor/mbedtls/library/psa_crypto_driver_wrappers.h +2896 -0
- package/vendor/mbedtls/library/psa_crypto_driver_wrappers_no_static.c +256 -0
- package/vendor/mbedtls/library/psa_crypto_driver_wrappers_no_static.h +31 -0
- package/vendor/mbedtls/library/psa_crypto_ecp.c +594 -0
- package/vendor/mbedtls/library/psa_crypto_ecp.h +267 -0
- package/vendor/mbedtls/library/psa_crypto_ffdh.c +361 -0
- package/vendor/mbedtls/library/psa_crypto_ffdh.h +131 -0
- package/vendor/mbedtls/library/psa_crypto_hash.c +470 -0
- package/vendor/mbedtls/library/psa_crypto_hash.h +211 -0
- package/vendor/mbedtls/library/psa_crypto_invasive.h +92 -0
- package/vendor/mbedtls/library/psa_crypto_its.h +131 -0
- package/vendor/mbedtls/library/psa_crypto_mac.c +505 -0
- package/vendor/mbedtls/library/psa_crypto_mac.h +264 -0
- package/vendor/mbedtls/library/psa_crypto_pake.c +571 -0
- package/vendor/mbedtls/library/psa_crypto_pake.h +159 -0
- package/vendor/mbedtls/library/psa_crypto_random.c +181 -0
- package/vendor/mbedtls/library/psa_crypto_random.h +72 -0
- package/vendor/mbedtls/library/psa_crypto_random_impl.h +200 -0
- package/vendor/mbedtls/library/psa_crypto_rsa.c +714 -0
- package/vendor/mbedtls/library/psa_crypto_rsa.h +321 -0
- package/vendor/mbedtls/library/psa_crypto_se.c +373 -0
- package/vendor/mbedtls/library/psa_crypto_se.h +192 -0
- package/vendor/mbedtls/library/psa_crypto_slot_management.c +1137 -0
- package/vendor/mbedtls/library/psa_crypto_slot_management.h +344 -0
- package/vendor/mbedtls/library/psa_crypto_storage.c +481 -0
- package/vendor/mbedtls/library/psa_crypto_storage.h +392 -0
- package/vendor/mbedtls/library/psa_its_file.c +254 -0
- package/vendor/mbedtls/library/psa_util.c +614 -0
- package/vendor/mbedtls/library/psa_util_internal.h +100 -0
- package/vendor/mbedtls/library/ripemd160.c +490 -0
- package/vendor/mbedtls/library/rsa.c +3121 -0
- package/vendor/mbedtls/library/rsa_alt_helpers.c +455 -0
- package/vendor/mbedtls/library/rsa_alt_helpers.h +209 -0
- package/vendor/mbedtls/library/rsa_internal.h +188 -0
- package/vendor/mbedtls/library/sha1.c +480 -0
- package/vendor/mbedtls/library/sha256.c +983 -0
- package/vendor/mbedtls/library/sha3.c +721 -0
- package/vendor/mbedtls/library/sha512.c +1115 -0
- package/vendor/mbedtls/library/ssl_cache.c +410 -0
- package/vendor/mbedtls/library/ssl_ciphersuites.c +2050 -0
- package/vendor/mbedtls/library/ssl_ciphersuites_internal.h +154 -0
- package/vendor/mbedtls/library/ssl_client.c +1023 -0
- package/vendor/mbedtls/library/ssl_client.h +22 -0
- package/vendor/mbedtls/library/ssl_cookie.c +384 -0
- package/vendor/mbedtls/library/ssl_debug_helpers.h +85 -0
- package/vendor/mbedtls/library/ssl_debug_helpers_generated.c +251 -0
- package/vendor/mbedtls/library/ssl_misc.h +3198 -0
- package/vendor/mbedtls/library/ssl_msg.c +6619 -0
- package/vendor/mbedtls/library/ssl_ticket.c +556 -0
- package/vendor/mbedtls/library/ssl_tls.c +10234 -0
- package/vendor/mbedtls/library/ssl_tls12_client.c +3688 -0
- package/vendor/mbedtls/library/ssl_tls12_server.c +4311 -0
- package/vendor/mbedtls/library/ssl_tls13_client.c +3208 -0
- package/vendor/mbedtls/library/ssl_tls13_generic.c +1793 -0
- package/vendor/mbedtls/library/ssl_tls13_invasive.h +23 -0
- package/vendor/mbedtls/library/ssl_tls13_keys.c +1918 -0
- package/vendor/mbedtls/library/ssl_tls13_keys.h +668 -0
- package/vendor/mbedtls/library/ssl_tls13_server.c +3624 -0
- package/vendor/mbedtls/library/threading.c +193 -0
- package/vendor/mbedtls/library/threading_internal.h +28 -0
- package/vendor/mbedtls/library/timing.c +152 -0
- package/vendor/mbedtls/library/version.c +32 -0
- package/vendor/mbedtls/library/version_features.c +856 -0
- package/vendor/mbedtls/library/x509.c +1776 -0
- package/vendor/mbedtls/library/x509_create.c +570 -0
- package/vendor/mbedtls/library/x509_crl.c +708 -0
- package/vendor/mbedtls/library/x509_crt.c +3311 -0
- package/vendor/mbedtls/library/x509_csr.c +648 -0
- package/vendor/mbedtls/library/x509_internal.h +101 -0
- package/vendor/mbedtls/library/x509write.c +174 -0
- package/vendor/mbedtls/library/x509write_crt.c +688 -0
- package/vendor/mbedtls/library/x509write_csr.c +336 -0
- package/vendor/quickjs-ng/CMakeLists.txt +566 -0
- package/vendor/quickjs-ng/LICENSE +24 -0
- package/vendor/quickjs-ng/README.md +24 -0
- package/vendor/quickjs-ng/api-test.c +1195 -0
- package/vendor/quickjs-ng/builtin-array-fromasync.h +119 -0
- package/vendor/quickjs-ng/builtin-iterator-zip-keyed.h +332 -0
- package/vendor/quickjs-ng/builtin-iterator-zip.h +337 -0
- package/vendor/quickjs-ng/cutils.h +1998 -0
- package/vendor/quickjs-ng/dtoa.c +1619 -0
- package/vendor/quickjs-ng/dtoa.h +87 -0
- package/vendor/quickjs-ng/gen/function_source.c +81 -0
- package/vendor/quickjs-ng/gen/hello.c +53 -0
- package/vendor/quickjs-ng/gen/hello_module.c +106 -0
- package/vendor/quickjs-ng/gen/repl.c +3036 -0
- package/vendor/quickjs-ng/gen/standalone.c +323 -0
- package/vendor/quickjs-ng/gen/test_fib.c +81 -0
- package/vendor/quickjs-ng/libregexp-opcode.h +73 -0
- package/vendor/quickjs-ng/libregexp.c +3474 -0
- package/vendor/quickjs-ng/libregexp.h +101 -0
- package/vendor/quickjs-ng/libunicode-table.h +5173 -0
- package/vendor/quickjs-ng/libunicode.c +2069 -0
- package/vendor/quickjs-ng/libunicode.h +172 -0
- package/vendor/quickjs-ng/list.h +107 -0
- package/vendor/quickjs-ng/lre-test.c +52 -0
- package/vendor/quickjs-ng/qjs.c +762 -0
- package/vendor/quickjs-ng/qjsc.c +673 -0
- package/vendor/quickjs-ng/quickjs-atom.h +280 -0
- package/vendor/quickjs-ng/quickjs-c-atomics.h +54 -0
- package/vendor/quickjs-ng/quickjs-libc.c +5037 -0
- package/vendor/quickjs-ng/quickjs-libc.h +87 -0
- package/vendor/quickjs-ng/quickjs-opcode.h +377 -0
- package/vendor/quickjs-ng/quickjs.c +64041 -0
- package/vendor/quickjs-ng/quickjs.h +1447 -0
- package/vendor/quickjs-ng/run-test262.c +2374 -0
- package/vendor/quickjs-ng/unicode_gen.c +3121 -0
- package/vendor/quickjs-ng/unicode_gen_def.h +310 -0
- package/vendor/ryu/LICENSE-Boost +23 -0
- package/vendor/ryu/common.h +114 -0
- package/vendor/ryu/d2s.c +509 -0
- package/vendor/ryu/d2s_full_table.h +367 -0
- package/vendor/ryu/d2s_intrinsics.h +357 -0
- package/vendor/ryu/d2s_small_table.h +186 -0
- package/vendor/ryu/digit_table.h +35 -0
- package/vendor/ryu/ryu.h +46 -0
- package/vendor/zlib/LICENSE +22 -0
- package/vendor/zlib/adler32.c +164 -0
- package/vendor/zlib/compress.c +75 -0
- package/vendor/zlib/crc32.c +1049 -0
- package/vendor/zlib/crc32.h +9446 -0
- package/vendor/zlib/deflate.c +2139 -0
- package/vendor/zlib/deflate.h +377 -0
- package/vendor/zlib/gzclose.c +23 -0
- package/vendor/zlib/gzguts.h +214 -0
- package/vendor/zlib/gzlib.c +582 -0
- package/vendor/zlib/gzread.c +602 -0
- package/vendor/zlib/gzwrite.c +631 -0
- package/vendor/zlib/infback.c +628 -0
- package/vendor/zlib/inffast.c +320 -0
- package/vendor/zlib/inffast.h +11 -0
- package/vendor/zlib/inffixed.h +94 -0
- package/vendor/zlib/inflate.c +1526 -0
- package/vendor/zlib/inflate.h +126 -0
- package/vendor/zlib/inftrees.c +299 -0
- package/vendor/zlib/inftrees.h +62 -0
- package/vendor/zlib/trees.c +1117 -0
- package/vendor/zlib/trees.h +128 -0
- package/vendor/zlib/uncompr.c +85 -0
- package/vendor/zlib/zconf.h +543 -0
- package/vendor/zlib/zlib.h +1938 -0
- package/vendor/zlib/zutil.c +299 -0
- package/vendor/zlib/zutil.h +254 -0
- package/README.md +0 -3
- package/index.js +0 -2
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
/* The island's node:http/node:https CLIENT ↔ the socket units — the one
|
|
2
|
+
* translation unit referencing BOTH scr_http/scr_tls and the engine (the
|
|
3
|
+
* scr_zlib_island.c precedent): cc.ts compiles it exactly when a
|
|
4
|
+
* --dynamic build links the socket units, and the emitted main calls
|
|
5
|
+
* scr_net_island_install before any island entry. Builds without it keep
|
|
6
|
+
* the island's "does not provide the 'node:http' builtin" refusal.
|
|
7
|
+
*
|
|
8
|
+
* The shape is the native fetch bridge's, one level lower: the island's
|
|
9
|
+
* http/https shims (scr_island.c's bootstrap) call host.httpStart with a
|
|
10
|
+
* request description and a callbacks object; this unit runs ONE
|
|
11
|
+
* ScrHttpClientReq per exchange over scr_net (+ the scr_tls client
|
|
12
|
+
* transport for https, SNI/verify against the request hostname while the
|
|
13
|
+
* socket dials the blocking-lookup answer), and minted runtime closures
|
|
14
|
+
* feed status/headers/body/error events back into the engine from the
|
|
15
|
+
* net dispatch station. No redirects, no decompression, no default
|
|
16
|
+
* accept-* headers — node:http's client semantics, not fetch's; the wire
|
|
17
|
+
* head is the static lane's (scr_http_client_send_head: user headers,
|
|
18
|
+
* Host, Connection: keep-alive, the framing header), with the Host
|
|
19
|
+
* header pre-filled here from the HOSTNAME because the dial target may
|
|
20
|
+
* be a resolved IP.
|
|
21
|
+
*
|
|
22
|
+
* Ownership mirrors scr_fetch.c exactly: each exchange is refcounted —
|
|
23
|
+
* the live registry holds +1 and every minted listener closure's box
|
|
24
|
+
* holds +1; settling releases the engine callbacks object and the client
|
|
25
|
+
* handle, and teardown (registered with the island) frees whatever is
|
|
26
|
+
* still live before the engine goes down, so the island audit stays
|
|
27
|
+
* zero. */
|
|
28
|
+
#ifdef SCR_DYNAMIC
|
|
29
|
+
|
|
30
|
+
#include "scr_runtime.h"
|
|
31
|
+
|
|
32
|
+
#include <stdio.h>
|
|
33
|
+
#include <stdlib.h>
|
|
34
|
+
#include <string.h>
|
|
35
|
+
|
|
36
|
+
#include "quickjs.h"
|
|
37
|
+
|
|
38
|
+
static void ni_oom(void) {
|
|
39
|
+
fputs("scriptc: out of memory\n", stderr);
|
|
40
|
+
abort();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* ── exchanges ───────────────────────────────────────────────────────── */
|
|
44
|
+
|
|
45
|
+
typedef struct NiReq {
|
|
46
|
+
size_t rc; /* the live registry's +1 plus one per minted listener box */
|
|
47
|
+
int id;
|
|
48
|
+
JSContext *ctx;
|
|
49
|
+
JSValue cbs; /* { onResponse, onData, onEnd, onError, onResError,
|
|
50
|
+
* onTimeout, onClose } — owned while live */
|
|
51
|
+
bool cbs_live;
|
|
52
|
+
ScrHttpClientReq *client; /* +1 */
|
|
53
|
+
bool responded;
|
|
54
|
+
bool done; /* settled: no callback ever fires again */
|
|
55
|
+
struct NiReq *next;
|
|
56
|
+
} NiReq;
|
|
57
|
+
|
|
58
|
+
static NiReq *ni_live = NULL; /* registry: +1 each */
|
|
59
|
+
static int ni_next_id = 1;
|
|
60
|
+
|
|
61
|
+
static NiReq *ni_retain(NiReq *t) {
|
|
62
|
+
t->rc++;
|
|
63
|
+
return t;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static void ni_release(NiReq *t) {
|
|
67
|
+
if (--t->rc > 0) return;
|
|
68
|
+
if (t->client) scr_http_client_release(t->client);
|
|
69
|
+
if (t->cbs_live) JS_FreeValue(t->ctx, t->cbs);
|
|
70
|
+
free(t);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static void *ni_retain_v(void *p) { return ni_retain((NiReq *)p); }
|
|
74
|
+
static void ni_release_v(void *p) { ni_release((NiReq *)p); }
|
|
75
|
+
|
|
76
|
+
/* Settle: drop the client, free the engine callbacks, leave the registry.
|
|
77
|
+
* Idempotent. */
|
|
78
|
+
static void ni_settle(NiReq *t) {
|
|
79
|
+
if (t->done) return;
|
|
80
|
+
t->done = true;
|
|
81
|
+
if (t->client) {
|
|
82
|
+
scr_http_client_release(t->client);
|
|
83
|
+
t->client = NULL;
|
|
84
|
+
}
|
|
85
|
+
if (t->cbs_live) {
|
|
86
|
+
JS_FreeValue(t->ctx, t->cbs);
|
|
87
|
+
t->cbs = JS_UNDEFINED;
|
|
88
|
+
t->cbs_live = false;
|
|
89
|
+
}
|
|
90
|
+
for (NiReq **link = &ni_live; *link; link = &(*link)->next) {
|
|
91
|
+
if (*link == t) {
|
|
92
|
+
*link = t->next;
|
|
93
|
+
ni_release(t); /* the registry's +1 */
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static NiReq *ni_find(int id) {
|
|
100
|
+
for (NiReq *t = ni_live; t; t = t->next) {
|
|
101
|
+
if (t->id == id) return t;
|
|
102
|
+
}
|
|
103
|
+
return NULL;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* Entered from the net dispatch station: re-anchor, call, swallow (but
|
|
107
|
+
* report) engine exceptions — the callbacks are our own shim glue. */
|
|
108
|
+
static void ni_call(NiReq *t, const char *name, int argc, JSValueConst *argv) {
|
|
109
|
+
if (!t->cbs_live) return;
|
|
110
|
+
scr_island_host_enter();
|
|
111
|
+
JSContext *ctx = t->ctx;
|
|
112
|
+
JSValue fn = JS_GetPropertyStr(ctx, t->cbs, name);
|
|
113
|
+
JSValue r = JS_Call(ctx, fn, JS_UNDEFINED, argc, argv);
|
|
114
|
+
JS_FreeValue(ctx, fn);
|
|
115
|
+
if (JS_IsException(r)) {
|
|
116
|
+
JSValue e = JS_GetException(ctx);
|
|
117
|
+
const char *msg = JS_ToCString(ctx, e);
|
|
118
|
+
fprintf(stderr, "scriptc: island http callback '%s' threw: %s\n", name, msg ? msg : "?");
|
|
119
|
+
if (msg) JS_FreeCString(ctx, msg);
|
|
120
|
+
JS_FreeValue(ctx, e);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
JS_FreeValue(ctx, r);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* ── minted listener closures (caps[0] boxes the exchange) ───────────── */
|
|
127
|
+
|
|
128
|
+
static ScrClosure *ni_closure(NiReq *t, void *fn) {
|
|
129
|
+
ScrClosure *cb = scr_closure_new(fn, 1);
|
|
130
|
+
ScrBox *box = scr_box_new_obj(&ni_retain_v, &ni_release_v, NULL);
|
|
131
|
+
scr_box_set_ref(box, ni_retain(t));
|
|
132
|
+
cb->caps[0] = box;
|
|
133
|
+
return cb;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
static NiReq *ni_from(ScrClosure *cb) { return (NiReq *)scr_box_get_ref(cb->caps[0]); }
|
|
137
|
+
|
|
138
|
+
/* ── listener callbacks ──────────────────────────────────────────────── */
|
|
139
|
+
|
|
140
|
+
static void ni_on_data(ScrClosure *cb, ScrBytes *chunk /*borrowed*/) {
|
|
141
|
+
NiReq *t = ni_from(cb);
|
|
142
|
+
if (t == NULL) return;
|
|
143
|
+
if (!t->done && chunk->len > 0) {
|
|
144
|
+
JSValue u8 = JS_NewUint8ArrayCopy(t->ctx, chunk->data, chunk->len);
|
|
145
|
+
ni_call(t, "onData", 1, (JSValueConst *)&u8);
|
|
146
|
+
JS_FreeValue(t->ctx, u8);
|
|
147
|
+
}
|
|
148
|
+
ni_release(t);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static void ni_on_end(ScrClosure *cb) {
|
|
152
|
+
NiReq *t = ni_from(cb);
|
|
153
|
+
if (t == NULL) return;
|
|
154
|
+
if (!t->done) ni_call(t, "onEnd", 0, NULL);
|
|
155
|
+
ni_release(t);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* Mid-body death: 'aborted' on the RESPONSE (Node's shape — the shim
|
|
159
|
+
* emits it on the res). */
|
|
160
|
+
static void ni_on_res_error(ScrClosure *cb, ScrStr *msg /*borrowed*/) {
|
|
161
|
+
NiReq *t = ni_from(cb);
|
|
162
|
+
if (t == NULL) return;
|
|
163
|
+
if (!t->done) {
|
|
164
|
+
JSValue m = JS_NewStringLen(t->ctx, msg->data, msg->len);
|
|
165
|
+
ni_call(t, "onResError", 1, (JSValueConst *)&m);
|
|
166
|
+
JS_FreeValue(t->ctx, m);
|
|
167
|
+
}
|
|
168
|
+
ni_release(t);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
static void ni_on_response(ScrClosure *cb, ScrHttpReq *res /*+1*/) {
|
|
172
|
+
NiReq *t = ni_from(cb);
|
|
173
|
+
if (t == NULL) {
|
|
174
|
+
scr_http_req_release(res);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (t->done) {
|
|
178
|
+
scr_http_req_release(res);
|
|
179
|
+
ni_release(t);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
t->responded = true;
|
|
183
|
+
JSContext *ctx = t->ctx;
|
|
184
|
+
ScrArr *raw = scr_http_req_raw_headers(res);
|
|
185
|
+
size_t nraw = (size_t)scr_arr_len(raw);
|
|
186
|
+
JSValue hdrs = JS_NewArray(ctx);
|
|
187
|
+
for (size_t i = 0; i < nraw; i++) {
|
|
188
|
+
ScrStr *s = (ScrStr *)scr_arr_get_ref(raw, (double)i);
|
|
189
|
+
JS_SetPropertyUint32(ctx, hdrs, (uint32_t)i, JS_NewStringLen(ctx, s->data, s->len));
|
|
190
|
+
scr_str_release(s);
|
|
191
|
+
}
|
|
192
|
+
scr_arr_release(raw);
|
|
193
|
+
ScrStr *stext = scr_http_req_status_message(res);
|
|
194
|
+
JSValue argv[3] = {
|
|
195
|
+
JS_NewInt32(ctx, (int)scr_http_req_status(res)),
|
|
196
|
+
JS_NewStringLen(ctx, stext ? stext->data : "", stext ? stext->len : 0),
|
|
197
|
+
hdrs,
|
|
198
|
+
};
|
|
199
|
+
if (stext) scr_str_release(stext);
|
|
200
|
+
ni_call(t, "onResponse", 3, argv);
|
|
201
|
+
for (int i = 0; i < 3; i++) JS_FreeValue(ctx, argv[i]);
|
|
202
|
+
/* body listeners, registered inside the 'response' emit (the parser
|
|
203
|
+
* delivers body bytes only after this returns) */
|
|
204
|
+
scr_http_req_on_data(res, ni_closure(t, (void *)&ni_on_data), &ni_on_data, false);
|
|
205
|
+
scr_http_req_on_end(res, ni_closure(t, (void *)&ni_on_end), false);
|
|
206
|
+
scr_http_req_on_error(res, ni_closure(t, (void *)&ni_on_res_error), &ni_on_res_error, false);
|
|
207
|
+
scr_http_req_release(res);
|
|
208
|
+
ni_release(t);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
static void ni_on_client_error(ScrClosure *cb, ScrStr *msg /*borrowed*/) {
|
|
212
|
+
NiReq *t = ni_from(cb);
|
|
213
|
+
if (t == NULL) return;
|
|
214
|
+
if (!t->done && !t->responded) {
|
|
215
|
+
/* the net layer's message IS Node's ('connect ECONNREFUSED ip:port',
|
|
216
|
+
* 'getaddrinfo ENOTFOUND host', 'socket hang up') — the shim shapes
|
|
217
|
+
* the Error and derives the code. The exchange settles at the close
|
|
218
|
+
* that always follows, so 'error' precedes 'close' like Node. */
|
|
219
|
+
JSValue m = JS_NewStringLen(t->ctx, msg->data, msg->len);
|
|
220
|
+
ni_call(t, "onError", 1, (JSValueConst *)&m);
|
|
221
|
+
JS_FreeValue(t->ctx, m);
|
|
222
|
+
}
|
|
223
|
+
ni_release(t);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
static void ni_on_timeout(ScrClosure *cb) {
|
|
227
|
+
NiReq *t = ni_from(cb);
|
|
228
|
+
if (t == NULL) return;
|
|
229
|
+
if (!t->done) ni_call(t, "onTimeout", 0, NULL);
|
|
230
|
+
ni_release(t);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* The exchange's 'close' (deferred through the http emit queue — Node's
|
|
234
|
+
* later-than-the-handler ordering: res 'end', req 'close', res 'close'). */
|
|
235
|
+
static void ni_on_close(ScrClosure *cb) {
|
|
236
|
+
NiReq *t = ni_from(cb);
|
|
237
|
+
if (t == NULL) return;
|
|
238
|
+
ni_call(t, "onClose", 0, NULL); /* no-op once settled */
|
|
239
|
+
ni_settle(t);
|
|
240
|
+
ni_release(t);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/* ── host functions (called by the http shim, inside the engine) ─────── */
|
|
244
|
+
|
|
245
|
+
/* host.httpStart(secure, host, port, path, method, timeoutMs,
|
|
246
|
+
* headersFlat, cbs) → id. The request head buffers until write/end
|
|
247
|
+
* pushes bytes; the shim starts the exchange lazily at first write/end/
|
|
248
|
+
* flushHeaders so setHeader-after-construction keeps working. */
|
|
249
|
+
static JSValue ni_host_start(JSContext *ctx, JSValueConst this_val, int argc,
|
|
250
|
+
JSValueConst *argv) {
|
|
251
|
+
(void)this_val;
|
|
252
|
+
if (argc < 8) return JS_ThrowTypeError(ctx, "httpStart: bad arity");
|
|
253
|
+
bool secure = JS_ToBool(ctx, argv[0]) > 0;
|
|
254
|
+
const char *host = JS_ToCString(ctx, argv[1]);
|
|
255
|
+
if (!host) return JS_EXCEPTION;
|
|
256
|
+
int32_t port = 0;
|
|
257
|
+
JS_ToInt32(ctx, &port, argv[2]);
|
|
258
|
+
const char *path = JS_ToCString(ctx, argv[3]);
|
|
259
|
+
const char *method = JS_ToCString(ctx, argv[4]);
|
|
260
|
+
double timeout_ms = 0;
|
|
261
|
+
JS_ToFloat64(ctx, &timeout_ms, argv[5]);
|
|
262
|
+
if (!path || !method) {
|
|
263
|
+
JS_FreeCString(ctx, host);
|
|
264
|
+
if (path) JS_FreeCString(ctx, path);
|
|
265
|
+
if (method) JS_FreeCString(ctx, method);
|
|
266
|
+
return JS_EXCEPTION;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
ScrStr *hostname = scr_str_new(host, strlen(host));
|
|
270
|
+
ScrStr *pathstr = scr_str_new(path, strlen(path));
|
|
271
|
+
ScrStr *methodstr = scr_str_new(method, strlen(method));
|
|
272
|
+
JS_FreeCString(ctx, host);
|
|
273
|
+
JS_FreeCString(ctx, path);
|
|
274
|
+
JS_FreeCString(ctx, method);
|
|
275
|
+
|
|
276
|
+
/* user headers, plus Host from the HOSTNAME (the dial target below may
|
|
277
|
+
* be a resolved IP; Node's rule — the default port stays off) */
|
|
278
|
+
JSValue lenv = JS_GetPropertyStr(ctx, argv[6], "length");
|
|
279
|
+
uint32_t hn = 0;
|
|
280
|
+
JS_ToUint32(ctx, &hn, lenv);
|
|
281
|
+
JS_FreeValue(ctx, lenv);
|
|
282
|
+
ScrArr *pairs = scr_arr_new(SCR_ELEM_STR, hn + 2);
|
|
283
|
+
bool has_host = false;
|
|
284
|
+
for (uint32_t i = 0; i + 1 < hn; i += 2) {
|
|
285
|
+
JSValue nv = JS_GetPropertyUint32(ctx, argv[6], i);
|
|
286
|
+
JSValue vv = JS_GetPropertyUint32(ctx, argv[6], i + 1);
|
|
287
|
+
size_t nlen = 0, vlen = 0;
|
|
288
|
+
const char *hname = JS_ToCStringLen(ctx, &nlen, nv);
|
|
289
|
+
const char *hvalue = JS_ToCStringLen(ctx, &vlen, vv);
|
|
290
|
+
if (hname && hvalue) {
|
|
291
|
+
if (nlen == 4) {
|
|
292
|
+
char l[4];
|
|
293
|
+
for (int k = 0; k < 4; k++) l[k] = (char)(hname[k] | 0x20);
|
|
294
|
+
if (memcmp(l, "host", 4) == 0) has_host = true;
|
|
295
|
+
}
|
|
296
|
+
scr_arr_push_ref(pairs, scr_str_new(hname, nlen));
|
|
297
|
+
scr_arr_push_ref(pairs, scr_str_new(hvalue, vlen));
|
|
298
|
+
}
|
|
299
|
+
if (hname) JS_FreeCString(ctx, hname);
|
|
300
|
+
if (hvalue) JS_FreeCString(ctx, hvalue);
|
|
301
|
+
JS_FreeValue(ctx, nv);
|
|
302
|
+
JS_FreeValue(ctx, vv);
|
|
303
|
+
}
|
|
304
|
+
int default_port = secure ? 443 : 80;
|
|
305
|
+
if (!has_host) {
|
|
306
|
+
char authority[300];
|
|
307
|
+
int alen;
|
|
308
|
+
bool v6 = memchr(hostname->data, ':', hostname->len) != NULL;
|
|
309
|
+
if (port != default_port) {
|
|
310
|
+
alen = snprintf(authority, sizeof authority, v6 ? "[%.*s]:%d" : "%.*s:%d",
|
|
311
|
+
(int)hostname->len, hostname->data, port);
|
|
312
|
+
} else {
|
|
313
|
+
alen = snprintf(authority, sizeof authority, v6 ? "[%.*s]" : "%.*s",
|
|
314
|
+
(int)hostname->len, hostname->data);
|
|
315
|
+
}
|
|
316
|
+
scr_arr_push_ref(pairs, scr_str_new("Host", 4));
|
|
317
|
+
scr_arr_push_ref(pairs, scr_str_new(authority, (size_t)alen));
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
NiReq *t = calloc(1, sizeof *t);
|
|
321
|
+
if (!t) ni_oom();
|
|
322
|
+
t->rc = 1; /* the registry's */
|
|
323
|
+
t->ctx = ctx;
|
|
324
|
+
t->id = ni_next_id++;
|
|
325
|
+
t->cbs = JS_DupValue(ctx, argv[7]);
|
|
326
|
+
t->cbs_live = true;
|
|
327
|
+
|
|
328
|
+
ScrStr *dial = scr_net_blocking_lookup(hostname);
|
|
329
|
+
ScrHttpClientReq *c;
|
|
330
|
+
if (secure) {
|
|
331
|
+
void *cli = scr_tls_fetch_client_ctx(hostname, true);
|
|
332
|
+
c = scr_http_request_ex(dial, (double)port, pathstr, methodstr, timeout_ms, pairs, false,
|
|
333
|
+
NULL, NULL, 443, &scr_tls_fetch_client_wrap, cli);
|
|
334
|
+
} else {
|
|
335
|
+
c = scr_http_request_ex(dial, (double)port, pathstr, methodstr, timeout_ms, pairs, false,
|
|
336
|
+
NULL, NULL, 80, NULL, NULL);
|
|
337
|
+
}
|
|
338
|
+
scr_str_release(dial);
|
|
339
|
+
scr_str_release(hostname);
|
|
340
|
+
scr_str_release(pathstr);
|
|
341
|
+
scr_str_release(methodstr);
|
|
342
|
+
scr_arr_release(pairs);
|
|
343
|
+
|
|
344
|
+
t->client = c; /* the constructor's +1 */
|
|
345
|
+
scr_http_client_on_response(c, ni_closure(t, (void *)&ni_on_response), &ni_on_response, true);
|
|
346
|
+
scr_http_client_on_error(c, ni_closure(t, (void *)&ni_on_client_error), &ni_on_client_error, false);
|
|
347
|
+
scr_http_client_on_timeout(c, ni_closure(t, (void *)&ni_on_timeout), false);
|
|
348
|
+
scr_http_client_on_close(c, ni_closure(t, (void *)&ni_on_close), true);
|
|
349
|
+
|
|
350
|
+
t->next = ni_live;
|
|
351
|
+
ni_live = t;
|
|
352
|
+
return JS_NewInt32(ctx, t->id);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/* host.httpWrite(id, u8) / host.httpEnd(id[, u8]) — body bytes. */
|
|
356
|
+
static JSValue ni_host_write(JSContext *ctx, JSValueConst this_val, int argc,
|
|
357
|
+
JSValueConst *argv) {
|
|
358
|
+
(void)this_val;
|
|
359
|
+
(void)argc;
|
|
360
|
+
int32_t id = 0;
|
|
361
|
+
JS_ToInt32(ctx, &id, argv[0]);
|
|
362
|
+
NiReq *t = ni_find(id);
|
|
363
|
+
if (t == NULL || t->client == NULL) return JS_UNDEFINED;
|
|
364
|
+
size_t blen = 0;
|
|
365
|
+
uint8_t *bytes = JS_GetUint8Array(ctx, &blen, argv[1]);
|
|
366
|
+
if (bytes != NULL && blen > 0) {
|
|
367
|
+
ScrBytes *b = scr_bytes_new(SCR_BYTES_U8, (double)blen);
|
|
368
|
+
memcpy(b->data, bytes, blen);
|
|
369
|
+
scr_http_client_write_bytes(t->client, b);
|
|
370
|
+
scr_bytes_release(b);
|
|
371
|
+
}
|
|
372
|
+
return JS_UNDEFINED;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
static JSValue ni_host_end(JSContext *ctx, JSValueConst this_val, int argc,
|
|
376
|
+
JSValueConst *argv) {
|
|
377
|
+
(void)this_val;
|
|
378
|
+
int32_t id = 0;
|
|
379
|
+
JS_ToInt32(ctx, &id, argv[0]);
|
|
380
|
+
NiReq *t = ni_find(id);
|
|
381
|
+
if (t == NULL || t->client == NULL) return JS_UNDEFINED;
|
|
382
|
+
if (argc > 1 && !JS_IsUndefined(argv[1]) && !JS_IsNull(argv[1])) {
|
|
383
|
+
size_t blen = 0;
|
|
384
|
+
uint8_t *bytes = JS_GetUint8Array(ctx, &blen, argv[1]);
|
|
385
|
+
if (bytes != NULL || blen == 0) {
|
|
386
|
+
ScrBytes *b = scr_bytes_new(SCR_BYTES_U8, (double)blen);
|
|
387
|
+
if (blen > 0) memcpy(b->data, bytes, blen);
|
|
388
|
+
scr_http_client_end_bytes(t->client, b);
|
|
389
|
+
scr_bytes_release(b);
|
|
390
|
+
return JS_UNDEFINED;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
scr_http_client_end(t->client);
|
|
394
|
+
return JS_UNDEFINED;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/* host.httpDestroy(id): tears the connection down NOW and lets the
|
|
398
|
+
* natural teardown events flow — Node's destroy() mid-flight emits
|
|
399
|
+
* 'socket hang up' then 'close' (oracle-pinned by the island-http
|
|
400
|
+
* fixture), which is exactly the premature-close path scr_http.c
|
|
401
|
+
* classifies; after a completed response the teardown is quiet. The
|
|
402
|
+
* close event settles the exchange. */
|
|
403
|
+
static JSValue ni_host_destroy(JSContext *ctx, JSValueConst this_val, int argc,
|
|
404
|
+
JSValueConst *argv) {
|
|
405
|
+
(void)this_val;
|
|
406
|
+
(void)argc;
|
|
407
|
+
int32_t id = 0;
|
|
408
|
+
JS_ToInt32(ctx, &id, argv[0]);
|
|
409
|
+
NiReq *t = ni_find(id);
|
|
410
|
+
if (t != NULL && t->client != NULL) scr_http_client_destroy(t->client);
|
|
411
|
+
return JS_UNDEFINED;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/* host.httpSetTimeout(id, ms): the socket idle timer (0 disables). */
|
|
415
|
+
static JSValue ni_host_set_timeout(JSContext *ctx, JSValueConst this_val, int argc,
|
|
416
|
+
JSValueConst *argv) {
|
|
417
|
+
(void)this_val;
|
|
418
|
+
(void)argc;
|
|
419
|
+
int32_t id = 0;
|
|
420
|
+
JS_ToInt32(ctx, &id, argv[0]);
|
|
421
|
+
double ms = 0;
|
|
422
|
+
JS_ToFloat64(ctx, &ms, argv[1]);
|
|
423
|
+
NiReq *t = ni_find(id);
|
|
424
|
+
if (t != NULL && t->client != NULL) scr_http_client_set_timeout(t->client, ms);
|
|
425
|
+
return JS_UNDEFINED;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/* ── attach / teardown (registered with the island) ──────────────────── */
|
|
429
|
+
|
|
430
|
+
static void ni_attach(void *jsctx, void *host_obj) {
|
|
431
|
+
JSContext *ctx = (JSContext *)jsctx;
|
|
432
|
+
JSValueConst host = *(JSValueConst *)host_obj;
|
|
433
|
+
JS_SetPropertyStr(ctx, host, "httpStart", JS_NewCFunction(ctx, ni_host_start, "httpStart", 8));
|
|
434
|
+
JS_SetPropertyStr(ctx, host, "httpWrite", JS_NewCFunction(ctx, ni_host_write, "httpWrite", 2));
|
|
435
|
+
JS_SetPropertyStr(ctx, host, "httpEnd", JS_NewCFunction(ctx, ni_host_end, "httpEnd", 2));
|
|
436
|
+
JS_SetPropertyStr(ctx, host, "httpDestroy", JS_NewCFunction(ctx, ni_host_destroy, "httpDestroy", 1));
|
|
437
|
+
JS_SetPropertyStr(ctx, host, "httpSetTimeout", JS_NewCFunction(ctx, ni_host_set_timeout, "httpSetTimeout", 2));
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/* Exchanges still live at engine teardown free their engine values FIRST
|
|
441
|
+
* so the island's counting allocator returns to zero (the net/http exit
|
|
442
|
+
* cleanups — atexit LIFO, registered later so run earlier — have already
|
|
443
|
+
* dropped the listener closures). */
|
|
444
|
+
static void ni_teardown(void) {
|
|
445
|
+
while (ni_live) ni_settle(ni_live);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
void scr_net_island_install(void) {
|
|
449
|
+
static bool installed = false;
|
|
450
|
+
if (installed) return;
|
|
451
|
+
installed = true;
|
|
452
|
+
/* the loop hooks, exactly the fetch unit's reasoning: a graph whose
|
|
453
|
+
* only socket user is the island's http client must still pump */
|
|
454
|
+
scr_net_install();
|
|
455
|
+
scr_island_set_netmod(&ni_attach, &ni_teardown);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
#endif /* SCR_DYNAMIC */
|
package/src/scr_number.c
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/* JS-exact double → string.
|
|
2
|
+
*
|
|
3
|
+
* ECMA-262 §6.1.6.1.20 (Number::toString, radix 10) requires the shortest
|
|
4
|
+
* digit string s (with digit count k and scale n, so that the value is
|
|
5
|
+
* s * 10^(n-k)) that round-trips to the exact double — among equally short
|
|
6
|
+
* candidates the closest, ties to even — then fixed placement for
|
|
7
|
+
* -6 < n <= 21 and exponential notation otherwise.
|
|
8
|
+
*
|
|
9
|
+
* Digit generation is Ryū (vendored, see ../vendor/ryu/README.md): d2d()
|
|
10
|
+
* computes exactly that shortest/closest/ties-even digit string with pure
|
|
11
|
+
* integer arithmetic — no snprintf/strtod probing, no locale dependence.
|
|
12
|
+
* The ECMA placement logic below is ours and unchanged; only the digit
|
|
13
|
+
* source moved. Byte-exactness vs Node is pinned by the oracle case file
|
|
14
|
+
* and the 1M-double fuzz gate (packages/runtime/test/gen-number-cases.mjs).
|
|
15
|
+
*/
|
|
16
|
+
#include "scr_runtime.h"
|
|
17
|
+
|
|
18
|
+
#include <math.h>
|
|
19
|
+
#include <stdint.h>
|
|
20
|
+
#include <stdio.h>
|
|
21
|
+
#include <string.h>
|
|
22
|
+
|
|
23
|
+
/* Ryū d2s core, textually included so the build's runtime source list is
|
|
24
|
+
* unchanged. Provides d2d(), d2d_small_int(), decimalLength17(), div10(). */
|
|
25
|
+
#include "../vendor/ryu/d2s.c"
|
|
26
|
+
|
|
27
|
+
size_t scr_f64_to_str(double x, char *buf) {
|
|
28
|
+
if (isnan(x)) return (size_t)(stpcpy(buf, "NaN") - buf);
|
|
29
|
+
if (x == 0) return (size_t)(stpcpy(buf, "0") - buf); /* covers -0 */
|
|
30
|
+
if (isinf(x)) {
|
|
31
|
+
return (size_t)(stpcpy(buf, x < 0 ? "-Infinity" : "Infinity") - buf);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
char *out = buf;
|
|
35
|
+
if (x < 0) {
|
|
36
|
+
*out++ = '-';
|
|
37
|
+
x = -x;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* Shortest round-tripping digits via Ryū. Mirrors d2s_buffered_n's
|
|
41
|
+
* dispatch: the exact small-integer fast path first (trailing decimal
|
|
42
|
+
* zeros folded into the exponent), the full algorithm otherwise. */
|
|
43
|
+
uint64_t bits;
|
|
44
|
+
memcpy(&bits, &x, sizeof bits);
|
|
45
|
+
const uint64_t ieeeMantissa = bits & ((1ull << DOUBLE_MANTISSA_BITS) - 1);
|
|
46
|
+
const uint32_t ieeeExponent =
|
|
47
|
+
(uint32_t)(bits >> DOUBLE_MANTISSA_BITS); /* sign already stripped */
|
|
48
|
+
floating_decimal_64 v;
|
|
49
|
+
if (d2d_small_int(ieeeMantissa, ieeeExponent, &v)) {
|
|
50
|
+
for (;;) {
|
|
51
|
+
const uint64_t q = div10(v.mantissa);
|
|
52
|
+
const uint32_t r = ((uint32_t)v.mantissa) - 10 * ((uint32_t)q);
|
|
53
|
+
if (r != 0) break;
|
|
54
|
+
v.mantissa = q;
|
|
55
|
+
++v.exponent;
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
v = d2d(ieeeMantissa, ieeeExponent);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Ryū's (mantissa, exponent) → ECMA's (digits, k, n): the k mantissa
|
|
62
|
+
* digits have no trailing zeros, and value = 0.digits * 10^n. */
|
|
63
|
+
char digits[18];
|
|
64
|
+
int k = (int)decimalLength17(v.mantissa);
|
|
65
|
+
int n = v.exponent + k;
|
|
66
|
+
digits[k] = '\0';
|
|
67
|
+
uint64_t m = v.mantissa;
|
|
68
|
+
for (int i = k - 1; i >= 0; i--) {
|
|
69
|
+
const uint64_t q = div10(m);
|
|
70
|
+
digits[i] = (char)('0' + (uint32_t)m - 10 * (uint32_t)q);
|
|
71
|
+
m = q;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (k <= n && n <= 21) {
|
|
75
|
+
/* Integer: digits followed by n-k zeros. */
|
|
76
|
+
memcpy(out, digits, (size_t)k);
|
|
77
|
+
out += k;
|
|
78
|
+
for (int i = 0; i < n - k; i++) *out++ = '0';
|
|
79
|
+
} else if (0 < n && n <= 21) {
|
|
80
|
+
/* ddd.ddd */
|
|
81
|
+
memcpy(out, digits, (size_t)n);
|
|
82
|
+
out += n;
|
|
83
|
+
*out++ = '.';
|
|
84
|
+
memcpy(out, digits + n, (size_t)(k - n));
|
|
85
|
+
out += k - n;
|
|
86
|
+
} else if (-6 < n && n <= 0) {
|
|
87
|
+
/* 0.000ddd */
|
|
88
|
+
*out++ = '0';
|
|
89
|
+
*out++ = '.';
|
|
90
|
+
for (int i = 0; i < -n; i++) *out++ = '0';
|
|
91
|
+
memcpy(out, digits, (size_t)k);
|
|
92
|
+
out += k;
|
|
93
|
+
} else {
|
|
94
|
+
/* d.ddde±e — exponent is n-1, printed without leading zeros. */
|
|
95
|
+
*out++ = digits[0];
|
|
96
|
+
if (k > 1) {
|
|
97
|
+
*out++ = '.';
|
|
98
|
+
memcpy(out, digits + 1, (size_t)(k - 1));
|
|
99
|
+
out += k - 1;
|
|
100
|
+
}
|
|
101
|
+
*out++ = 'e';
|
|
102
|
+
int e = n - 1;
|
|
103
|
+
*out++ = e < 0 ? '-' : '+';
|
|
104
|
+
if (e < 0) e = -e;
|
|
105
|
+
char etmp[8];
|
|
106
|
+
int elen = 0;
|
|
107
|
+
do {
|
|
108
|
+
etmp[elen++] = (char)('0' + e % 10);
|
|
109
|
+
e /= 10;
|
|
110
|
+
} while (e > 0);
|
|
111
|
+
while (elen > 0) *out++ = etmp[--elen];
|
|
112
|
+
}
|
|
113
|
+
*out = '\0';
|
|
114
|
+
return (size_t)(out - buf);
|
|
115
|
+
}
|
package/src/scr_object.c
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* Class instances are per-class C structs emitted by the compiler; the
|
|
2
|
+
* runtime only provides the RC-audit hooks their emitted new/release
|
|
3
|
+
* helpers call — plus the class-OBJECT entry points (classes as values:
|
|
4
|
+
* every class object is an emitted immortal static, so the adapters are
|
|
5
|
+
* no-ops behind the uniform container RC machinery). */
|
|
6
|
+
#include "scr_runtime.h"
|
|
7
|
+
|
|
8
|
+
void *scr_classobj_retain_v(void *c) {
|
|
9
|
+
return scr_classobj_retain((ScrClassObj *)c);
|
|
10
|
+
}
|
|
11
|
+
void scr_classobj_release_v(void *c) { scr_classobj_release((ScrClassObj *)c); }
|
|
12
|
+
|
|
13
|
+
ScrStr *scr_classobj_name(ScrClassObj *c) {
|
|
14
|
+
return scr_str_retain((ScrStr *)c->name);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
#ifdef SCR_RC_AUDIT
|
|
18
|
+
static long scr_live_objects = 0;
|
|
19
|
+
long scr_obj_live_count(void) { return scr_live_objects; }
|
|
20
|
+
void scr_obj_alloc_note(void) { scr_live_objects++; }
|
|
21
|
+
void scr_obj_free_note(void) { scr_live_objects--; }
|
|
22
|
+
#else
|
|
23
|
+
void scr_obj_alloc_note(void) {}
|
|
24
|
+
void scr_obj_free_note(void) {}
|
|
25
|
+
#endif
|