@scriptc/runtime 0.0.0 → 0.0.1

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.
Files changed (416) hide show
  1. package/LICENSE +202 -0
  2. package/package.json +16 -6
  3. package/src/scr_array.c +488 -0
  4. package/src/scr_assert.c +1393 -0
  5. package/src/scr_async.c +2593 -0
  6. package/src/scr_async_dyn.c +607 -0
  7. package/src/scr_bytes.c +1425 -0
  8. package/src/scr_bytes_io.c +161 -0
  9. package/src/scr_child.c +3587 -0
  10. package/src/scr_closure.c +214 -0
  11. package/src/scr_console.c +143 -0
  12. package/src/scr_cycle.c +218 -0
  13. package/src/scr_dc.c +805 -0
  14. package/src/scr_dgram.c +1007 -0
  15. package/src/scr_dyn_handle.c +154 -0
  16. package/src/scr_dyn_invoke.c +644 -0
  17. package/src/scr_error.c +332 -0
  18. package/src/scr_events.c +714 -0
  19. package/src/scr_events_emitter.c +699 -0
  20. package/src/scr_exception.c +242 -0
  21. package/src/scr_fetch.c +1130 -0
  22. package/src/scr_fetch_curl.c +654 -0
  23. package/src/scr_http.c +3482 -0
  24. package/src/scr_http2.c +3030 -0
  25. package/src/scr_inspect.c +803 -0
  26. package/src/scr_inspect_island.c +51 -0
  27. package/src/scr_island.c +9363 -0
  28. package/src/scr_json.c +2151 -0
  29. package/src/scr_lib.c +3612 -0
  30. package/src/scr_loop_epoll.c +241 -0
  31. package/src/scr_loop_kqueue.c +121 -0
  32. package/src/scr_loop_wsapoll.c +208 -0
  33. package/src/scr_map.c +591 -0
  34. package/src/scr_net.c +3017 -0
  35. package/src/scr_net_island.c +458 -0
  36. package/src/scr_number.c +115 -0
  37. package/src/scr_object.c +25 -0
  38. package/src/scr_path.c +1266 -0
  39. package/src/scr_platform.h +119 -0
  40. package/src/scr_readline.c +287 -0
  41. package/src/scr_regex.c +1080 -0
  42. package/src/scr_runtime.h +5036 -0
  43. package/src/scr_stream.c +2877 -0
  44. package/src/scr_string.c +1176 -0
  45. package/src/scr_symbol.c +132 -0
  46. package/src/scr_test.c +662 -0
  47. package/src/scr_tls.c +1520 -0
  48. package/src/scr_union.c +105 -0
  49. package/src/scr_url.c +911 -0
  50. package/src/scr_url_internal.h +29 -0
  51. package/src/scr_url_params.c +561 -0
  52. package/src/scr_watch.c +568 -0
  53. package/src/scr_web.c +1778 -0
  54. package/src/scr_win.c +76 -0
  55. package/src/scr_zlib.c +197 -0
  56. package/src/scr_zlib_island.c +15 -0
  57. package/vendor/README.md +52 -0
  58. package/vendor/curl/COPYRIGHT +534 -0
  59. package/vendor/curl/include/curl/curl.h +3214 -0
  60. package/vendor/curl/include/curl/curlver.h +79 -0
  61. package/vendor/curl/include/curl/easy.h +125 -0
  62. package/vendor/curl/include/curl/header.h +74 -0
  63. package/vendor/curl/include/curl/mprintf.h +52 -0
  64. package/vendor/curl/include/curl/multi.h +460 -0
  65. package/vendor/curl/include/curl/options.h +70 -0
  66. package/vendor/curl/include/curl/stdcheaders.h +35 -0
  67. package/vendor/curl/include/curl/system.h +508 -0
  68. package/vendor/curl/include/curl/typecheck-gcc.h +716 -0
  69. package/vendor/curl/include/curl/urlapi.h +149 -0
  70. package/vendor/curl/include/curl/websockets.h +84 -0
  71. package/vendor/mbedtls/LICENSE +553 -0
  72. package/vendor/mbedtls/include/CMakeLists.txt +22 -0
  73. package/vendor/mbedtls/include/mbedtls/aes.h +631 -0
  74. package/vendor/mbedtls/include/mbedtls/aria.h +343 -0
  75. package/vendor/mbedtls/include/mbedtls/asn1.h +642 -0
  76. package/vendor/mbedtls/include/mbedtls/asn1write.h +390 -0
  77. package/vendor/mbedtls/include/mbedtls/base64.h +82 -0
  78. package/vendor/mbedtls/include/mbedtls/bignum.h +1088 -0
  79. package/vendor/mbedtls/include/mbedtls/block_cipher.h +76 -0
  80. package/vendor/mbedtls/include/mbedtls/build_info.h +194 -0
  81. package/vendor/mbedtls/include/mbedtls/camellia.h +305 -0
  82. package/vendor/mbedtls/include/mbedtls/ccm.h +526 -0
  83. package/vendor/mbedtls/include/mbedtls/chacha20.h +209 -0
  84. package/vendor/mbedtls/include/mbedtls/chachapoly.h +351 -0
  85. package/vendor/mbedtls/include/mbedtls/check_config.h +1149 -0
  86. package/vendor/mbedtls/include/mbedtls/cipher.h +1250 -0
  87. package/vendor/mbedtls/include/mbedtls/cmac.h +246 -0
  88. package/vendor/mbedtls/include/mbedtls/compat-2.x.h +46 -0
  89. package/vendor/mbedtls/include/mbedtls/config_adjust_legacy_crypto.h +578 -0
  90. package/vendor/mbedtls/include/mbedtls/config_adjust_legacy_from_psa.h +873 -0
  91. package/vendor/mbedtls/include/mbedtls/config_adjust_psa_from_legacy.h +359 -0
  92. package/vendor/mbedtls/include/mbedtls/config_adjust_psa_superset_legacy.h +145 -0
  93. package/vendor/mbedtls/include/mbedtls/config_adjust_ssl.h +91 -0
  94. package/vendor/mbedtls/include/mbedtls/config_adjust_x509.h +35 -0
  95. package/vendor/mbedtls/include/mbedtls/config_psa.h +61 -0
  96. package/vendor/mbedtls/include/mbedtls/constant_time.h +36 -0
  97. package/vendor/mbedtls/include/mbedtls/ctr_drbg.h +596 -0
  98. package/vendor/mbedtls/include/mbedtls/debug.h +156 -0
  99. package/vendor/mbedtls/include/mbedtls/des.h +385 -0
  100. package/vendor/mbedtls/include/mbedtls/dhm.h +972 -0
  101. package/vendor/mbedtls/include/mbedtls/ecdh.h +455 -0
  102. package/vendor/mbedtls/include/mbedtls/ecdsa.h +674 -0
  103. package/vendor/mbedtls/include/mbedtls/ecjpake.h +298 -0
  104. package/vendor/mbedtls/include/mbedtls/ecp.h +1517 -0
  105. package/vendor/mbedtls/include/mbedtls/entropy.h +274 -0
  106. package/vendor/mbedtls/include/mbedtls/error.h +201 -0
  107. package/vendor/mbedtls/include/mbedtls/gcm.h +387 -0
  108. package/vendor/mbedtls/include/mbedtls/hkdf.h +124 -0
  109. package/vendor/mbedtls/include/mbedtls/hmac_drbg.h +434 -0
  110. package/vendor/mbedtls/include/mbedtls/lms.h +440 -0
  111. package/vendor/mbedtls/include/mbedtls/mbedtls_config.h +4446 -0
  112. package/vendor/mbedtls/include/mbedtls/md.h +526 -0
  113. package/vendor/mbedtls/include/mbedtls/md5.h +190 -0
  114. package/vendor/mbedtls/include/mbedtls/memory_buffer_alloc.h +142 -0
  115. package/vendor/mbedtls/include/mbedtls/net_sockets.h +299 -0
  116. package/vendor/mbedtls/include/mbedtls/nist_kw.h +166 -0
  117. package/vendor/mbedtls/include/mbedtls/oid.h +727 -0
  118. package/vendor/mbedtls/include/mbedtls/pem.h +160 -0
  119. package/vendor/mbedtls/include/mbedtls/pk.h +1303 -0
  120. package/vendor/mbedtls/include/mbedtls/pkcs12.h +186 -0
  121. package/vendor/mbedtls/include/mbedtls/pkcs5.h +198 -0
  122. package/vendor/mbedtls/include/mbedtls/pkcs7.h +252 -0
  123. package/vendor/mbedtls/include/mbedtls/platform.h +516 -0
  124. package/vendor/mbedtls/include/mbedtls/platform_time.h +79 -0
  125. package/vendor/mbedtls/include/mbedtls/platform_util.h +247 -0
  126. package/vendor/mbedtls/include/mbedtls/poly1305.h +168 -0
  127. package/vendor/mbedtls/include/mbedtls/private_access.h +20 -0
  128. package/vendor/mbedtls/include/mbedtls/psa_util.h +207 -0
  129. package/vendor/mbedtls/include/mbedtls/ripemd160.h +136 -0
  130. package/vendor/mbedtls/include/mbedtls/rsa.h +1170 -0
  131. package/vendor/mbedtls/include/mbedtls/sha1.h +219 -0
  132. package/vendor/mbedtls/include/mbedtls/sha256.h +200 -0
  133. package/vendor/mbedtls/include/mbedtls/sha3.h +172 -0
  134. package/vendor/mbedtls/include/mbedtls/sha512.h +208 -0
  135. package/vendor/mbedtls/include/mbedtls/ssl.h +5887 -0
  136. package/vendor/mbedtls/include/mbedtls/ssl_cache.h +187 -0
  137. package/vendor/mbedtls/include/mbedtls/ssl_ciphersuites.h +482 -0
  138. package/vendor/mbedtls/include/mbedtls/ssl_cookie.h +106 -0
  139. package/vendor/mbedtls/include/mbedtls/ssl_ticket.h +199 -0
  140. package/vendor/mbedtls/include/mbedtls/threading.h +167 -0
  141. package/vendor/mbedtls/include/mbedtls/timing.h +94 -0
  142. package/vendor/mbedtls/include/mbedtls/version.h +78 -0
  143. package/vendor/mbedtls/include/mbedtls/x509.h +500 -0
  144. package/vendor/mbedtls/include/mbedtls/x509_crl.h +184 -0
  145. package/vendor/mbedtls/include/mbedtls/x509_crt.h +1208 -0
  146. package/vendor/mbedtls/include/mbedtls/x509_csr.h +382 -0
  147. package/vendor/mbedtls/include/psa/build_info.h +20 -0
  148. package/vendor/mbedtls/include/psa/crypto.h +4998 -0
  149. package/vendor/mbedtls/include/psa/crypto_adjust_auto_enabled.h +31 -0
  150. package/vendor/mbedtls/include/psa/crypto_adjust_config_dependencies.h +51 -0
  151. package/vendor/mbedtls/include/psa/crypto_adjust_config_key_pair_types.h +101 -0
  152. package/vendor/mbedtls/include/psa/crypto_adjust_config_synonyms.h +49 -0
  153. package/vendor/mbedtls/include/psa/crypto_builtin_composites.h +214 -0
  154. package/vendor/mbedtls/include/psa/crypto_builtin_key_derivation.h +118 -0
  155. package/vendor/mbedtls/include/psa/crypto_builtin_primitives.h +114 -0
  156. package/vendor/mbedtls/include/psa/crypto_compat.h +230 -0
  157. package/vendor/mbedtls/include/psa/crypto_config.h +145 -0
  158. package/vendor/mbedtls/include/psa/crypto_driver_common.h +44 -0
  159. package/vendor/mbedtls/include/psa/crypto_driver_contexts_composites.h +151 -0
  160. package/vendor/mbedtls/include/psa/crypto_driver_contexts_key_derivation.h +52 -0
  161. package/vendor/mbedtls/include/psa/crypto_driver_contexts_primitives.h +105 -0
  162. package/vendor/mbedtls/include/psa/crypto_extra.h +2145 -0
  163. package/vendor/mbedtls/include/psa/crypto_legacy.h +88 -0
  164. package/vendor/mbedtls/include/psa/crypto_platform.h +102 -0
  165. package/vendor/mbedtls/include/psa/crypto_se_driver.h +1383 -0
  166. package/vendor/mbedtls/include/psa/crypto_sizes.h +1319 -0
  167. package/vendor/mbedtls/include/psa/crypto_struct.h +527 -0
  168. package/vendor/mbedtls/include/psa/crypto_types.h +508 -0
  169. package/vendor/mbedtls/include/psa/crypto_values.h +2782 -0
  170. package/vendor/mbedtls/library/aes.c +2294 -0
  171. package/vendor/mbedtls/library/aesce.c +624 -0
  172. package/vendor/mbedtls/library/aesce.h +136 -0
  173. package/vendor/mbedtls/library/aesni.c +846 -0
  174. package/vendor/mbedtls/library/aesni.h +162 -0
  175. package/vendor/mbedtls/library/alignment.h +704 -0
  176. package/vendor/mbedtls/library/aria.c +969 -0
  177. package/vendor/mbedtls/library/asn1parse.c +468 -0
  178. package/vendor/mbedtls/library/asn1write.c +440 -0
  179. package/vendor/mbedtls/library/base64.c +322 -0
  180. package/vendor/mbedtls/library/base64_internal.h +45 -0
  181. package/vendor/mbedtls/library/bignum.c +2583 -0
  182. package/vendor/mbedtls/library/bignum_core.c +1240 -0
  183. package/vendor/mbedtls/library/bignum_core.h +872 -0
  184. package/vendor/mbedtls/library/bignum_core_invasive.h +38 -0
  185. package/vendor/mbedtls/library/bignum_internal.h +122 -0
  186. package/vendor/mbedtls/library/bignum_mod.c +394 -0
  187. package/vendor/mbedtls/library/bignum_mod.h +452 -0
  188. package/vendor/mbedtls/library/bignum_mod_raw.c +276 -0
  189. package/vendor/mbedtls/library/bignum_mod_raw.h +416 -0
  190. package/vendor/mbedtls/library/bignum_mod_raw_invasive.h +34 -0
  191. package/vendor/mbedtls/library/block_cipher.c +207 -0
  192. package/vendor/mbedtls/library/block_cipher_internal.h +99 -0
  193. package/vendor/mbedtls/library/bn_mul.h +1094 -0
  194. package/vendor/mbedtls/library/camellia.c +1058 -0
  195. package/vendor/mbedtls/library/ccm.c +777 -0
  196. package/vendor/mbedtls/library/chacha20.c +563 -0
  197. package/vendor/mbedtls/library/chacha20_internal.h +23 -0
  198. package/vendor/mbedtls/library/chachapoly.c +487 -0
  199. package/vendor/mbedtls/library/check_crypto_config.h +136 -0
  200. package/vendor/mbedtls/library/cipher.c +1712 -0
  201. package/vendor/mbedtls/library/cipher_invasive.h +28 -0
  202. package/vendor/mbedtls/library/cipher_wrap.c +2482 -0
  203. package/vendor/mbedtls/library/cipher_wrap.h +178 -0
  204. package/vendor/mbedtls/library/cmac.c +1067 -0
  205. package/vendor/mbedtls/library/common.h +487 -0
  206. package/vendor/mbedtls/library/constant_time.c +247 -0
  207. package/vendor/mbedtls/library/constant_time_impl.h +541 -0
  208. package/vendor/mbedtls/library/constant_time_internal.h +579 -0
  209. package/vendor/mbedtls/library/ctr.h +35 -0
  210. package/vendor/mbedtls/library/ctr_drbg.c +1016 -0
  211. package/vendor/mbedtls/library/debug.c +475 -0
  212. package/vendor/mbedtls/library/debug_internal.h +185 -0
  213. package/vendor/mbedtls/library/des.c +1042 -0
  214. package/vendor/mbedtls/library/dhm.c +700 -0
  215. package/vendor/mbedtls/library/ecdh.c +696 -0
  216. package/vendor/mbedtls/library/ecdsa.c +858 -0
  217. package/vendor/mbedtls/library/ecjpake.c +1216 -0
  218. package/vendor/mbedtls/library/ecp.c +3674 -0
  219. package/vendor/mbedtls/library/ecp_curves.c +6125 -0
  220. package/vendor/mbedtls/library/ecp_curves_new.c +9 -0
  221. package/vendor/mbedtls/library/ecp_internal_alt.h +287 -0
  222. package/vendor/mbedtls/library/ecp_invasive.h +305 -0
  223. package/vendor/mbedtls/library/entropy.c +680 -0
  224. package/vendor/mbedtls/library/entropy_poll.c +233 -0
  225. package/vendor/mbedtls/library/entropy_poll.h +64 -0
  226. package/vendor/mbedtls/library/error.c +878 -0
  227. package/vendor/mbedtls/library/gcm.c +1330 -0
  228. package/vendor/mbedtls/library/hkdf.c +161 -0
  229. package/vendor/mbedtls/library/hmac_drbg.c +633 -0
  230. package/vendor/mbedtls/library/lmots.c +789 -0
  231. package/vendor/mbedtls/library/lmots.h +288 -0
  232. package/vendor/mbedtls/library/lms.c +778 -0
  233. package/vendor/mbedtls/library/md.c +1108 -0
  234. package/vendor/mbedtls/library/md5.c +426 -0
  235. package/vendor/mbedtls/library/md_psa.h +26 -0
  236. package/vendor/mbedtls/library/md_wrap.h +46 -0
  237. package/vendor/mbedtls/library/memory_buffer_alloc.c +751 -0
  238. package/vendor/mbedtls/library/mps_common.h +181 -0
  239. package/vendor/mbedtls/library/mps_error.h +89 -0
  240. package/vendor/mbedtls/library/mps_reader.c +538 -0
  241. package/vendor/mbedtls/library/mps_reader.h +366 -0
  242. package/vendor/mbedtls/library/mps_trace.c +112 -0
  243. package/vendor/mbedtls/library/mps_trace.h +154 -0
  244. package/vendor/mbedtls/library/net_sockets.c +694 -0
  245. package/vendor/mbedtls/library/nist_kw.c +729 -0
  246. package/vendor/mbedtls/library/oid.c +1166 -0
  247. package/vendor/mbedtls/library/padlock.c +157 -0
  248. package/vendor/mbedtls/library/padlock.h +111 -0
  249. package/vendor/mbedtls/library/pem.c +554 -0
  250. package/vendor/mbedtls/library/pk.c +1602 -0
  251. package/vendor/mbedtls/library/pk_ecc.c +261 -0
  252. package/vendor/mbedtls/library/pk_internal.h +241 -0
  253. package/vendor/mbedtls/library/pk_wrap.c +1618 -0
  254. package/vendor/mbedtls/library/pk_wrap.h +138 -0
  255. package/vendor/mbedtls/library/pkcs12.c +437 -0
  256. package/vendor/mbedtls/library/pkcs5.c +500 -0
  257. package/vendor/mbedtls/library/pkcs7.c +787 -0
  258. package/vendor/mbedtls/library/pkparse.c +1392 -0
  259. package/vendor/mbedtls/library/pkwrite.c +631 -0
  260. package/vendor/mbedtls/library/pkwrite.h +121 -0
  261. package/vendor/mbedtls/library/platform.c +402 -0
  262. package/vendor/mbedtls/library/platform_util.c +258 -0
  263. package/vendor/mbedtls/library/poly1305.c +492 -0
  264. package/vendor/mbedtls/library/psa_crypto.c +9532 -0
  265. package/vendor/mbedtls/library/psa_crypto_aead.c +646 -0
  266. package/vendor/mbedtls/library/psa_crypto_aead.h +499 -0
  267. package/vendor/mbedtls/library/psa_crypto_cipher.c +747 -0
  268. package/vendor/mbedtls/library/psa_crypto_cipher.h +316 -0
  269. package/vendor/mbedtls/library/psa_crypto_client.c +22 -0
  270. package/vendor/mbedtls/library/psa_crypto_core.h +983 -0
  271. package/vendor/mbedtls/library/psa_crypto_core_common.h +52 -0
  272. package/vendor/mbedtls/library/psa_crypto_driver_wrappers.h +2896 -0
  273. package/vendor/mbedtls/library/psa_crypto_driver_wrappers_no_static.c +256 -0
  274. package/vendor/mbedtls/library/psa_crypto_driver_wrappers_no_static.h +31 -0
  275. package/vendor/mbedtls/library/psa_crypto_ecp.c +594 -0
  276. package/vendor/mbedtls/library/psa_crypto_ecp.h +267 -0
  277. package/vendor/mbedtls/library/psa_crypto_ffdh.c +361 -0
  278. package/vendor/mbedtls/library/psa_crypto_ffdh.h +131 -0
  279. package/vendor/mbedtls/library/psa_crypto_hash.c +470 -0
  280. package/vendor/mbedtls/library/psa_crypto_hash.h +211 -0
  281. package/vendor/mbedtls/library/psa_crypto_invasive.h +92 -0
  282. package/vendor/mbedtls/library/psa_crypto_its.h +131 -0
  283. package/vendor/mbedtls/library/psa_crypto_mac.c +505 -0
  284. package/vendor/mbedtls/library/psa_crypto_mac.h +264 -0
  285. package/vendor/mbedtls/library/psa_crypto_pake.c +571 -0
  286. package/vendor/mbedtls/library/psa_crypto_pake.h +159 -0
  287. package/vendor/mbedtls/library/psa_crypto_random.c +181 -0
  288. package/vendor/mbedtls/library/psa_crypto_random.h +72 -0
  289. package/vendor/mbedtls/library/psa_crypto_random_impl.h +200 -0
  290. package/vendor/mbedtls/library/psa_crypto_rsa.c +714 -0
  291. package/vendor/mbedtls/library/psa_crypto_rsa.h +321 -0
  292. package/vendor/mbedtls/library/psa_crypto_se.c +373 -0
  293. package/vendor/mbedtls/library/psa_crypto_se.h +192 -0
  294. package/vendor/mbedtls/library/psa_crypto_slot_management.c +1137 -0
  295. package/vendor/mbedtls/library/psa_crypto_slot_management.h +344 -0
  296. package/vendor/mbedtls/library/psa_crypto_storage.c +481 -0
  297. package/vendor/mbedtls/library/psa_crypto_storage.h +392 -0
  298. package/vendor/mbedtls/library/psa_its_file.c +254 -0
  299. package/vendor/mbedtls/library/psa_util.c +614 -0
  300. package/vendor/mbedtls/library/psa_util_internal.h +100 -0
  301. package/vendor/mbedtls/library/ripemd160.c +490 -0
  302. package/vendor/mbedtls/library/rsa.c +3121 -0
  303. package/vendor/mbedtls/library/rsa_alt_helpers.c +455 -0
  304. package/vendor/mbedtls/library/rsa_alt_helpers.h +209 -0
  305. package/vendor/mbedtls/library/rsa_internal.h +188 -0
  306. package/vendor/mbedtls/library/sha1.c +480 -0
  307. package/vendor/mbedtls/library/sha256.c +983 -0
  308. package/vendor/mbedtls/library/sha3.c +721 -0
  309. package/vendor/mbedtls/library/sha512.c +1115 -0
  310. package/vendor/mbedtls/library/ssl_cache.c +410 -0
  311. package/vendor/mbedtls/library/ssl_ciphersuites.c +2050 -0
  312. package/vendor/mbedtls/library/ssl_ciphersuites_internal.h +154 -0
  313. package/vendor/mbedtls/library/ssl_client.c +1023 -0
  314. package/vendor/mbedtls/library/ssl_client.h +22 -0
  315. package/vendor/mbedtls/library/ssl_cookie.c +384 -0
  316. package/vendor/mbedtls/library/ssl_debug_helpers.h +85 -0
  317. package/vendor/mbedtls/library/ssl_debug_helpers_generated.c +251 -0
  318. package/vendor/mbedtls/library/ssl_misc.h +3198 -0
  319. package/vendor/mbedtls/library/ssl_msg.c +6619 -0
  320. package/vendor/mbedtls/library/ssl_ticket.c +556 -0
  321. package/vendor/mbedtls/library/ssl_tls.c +10234 -0
  322. package/vendor/mbedtls/library/ssl_tls12_client.c +3688 -0
  323. package/vendor/mbedtls/library/ssl_tls12_server.c +4311 -0
  324. package/vendor/mbedtls/library/ssl_tls13_client.c +3208 -0
  325. package/vendor/mbedtls/library/ssl_tls13_generic.c +1793 -0
  326. package/vendor/mbedtls/library/ssl_tls13_invasive.h +23 -0
  327. package/vendor/mbedtls/library/ssl_tls13_keys.c +1918 -0
  328. package/vendor/mbedtls/library/ssl_tls13_keys.h +668 -0
  329. package/vendor/mbedtls/library/ssl_tls13_server.c +3624 -0
  330. package/vendor/mbedtls/library/threading.c +193 -0
  331. package/vendor/mbedtls/library/threading_internal.h +28 -0
  332. package/vendor/mbedtls/library/timing.c +152 -0
  333. package/vendor/mbedtls/library/version.c +32 -0
  334. package/vendor/mbedtls/library/version_features.c +856 -0
  335. package/vendor/mbedtls/library/x509.c +1776 -0
  336. package/vendor/mbedtls/library/x509_create.c +570 -0
  337. package/vendor/mbedtls/library/x509_crl.c +708 -0
  338. package/vendor/mbedtls/library/x509_crt.c +3311 -0
  339. package/vendor/mbedtls/library/x509_csr.c +648 -0
  340. package/vendor/mbedtls/library/x509_internal.h +101 -0
  341. package/vendor/mbedtls/library/x509write.c +174 -0
  342. package/vendor/mbedtls/library/x509write_crt.c +688 -0
  343. package/vendor/mbedtls/library/x509write_csr.c +336 -0
  344. package/vendor/quickjs-ng/CMakeLists.txt +566 -0
  345. package/vendor/quickjs-ng/LICENSE +24 -0
  346. package/vendor/quickjs-ng/README.md +24 -0
  347. package/vendor/quickjs-ng/api-test.c +1195 -0
  348. package/vendor/quickjs-ng/builtin-array-fromasync.h +119 -0
  349. package/vendor/quickjs-ng/builtin-iterator-zip-keyed.h +332 -0
  350. package/vendor/quickjs-ng/builtin-iterator-zip.h +337 -0
  351. package/vendor/quickjs-ng/cutils.h +1998 -0
  352. package/vendor/quickjs-ng/dtoa.c +1619 -0
  353. package/vendor/quickjs-ng/dtoa.h +87 -0
  354. package/vendor/quickjs-ng/gen/function_source.c +81 -0
  355. package/vendor/quickjs-ng/gen/hello.c +53 -0
  356. package/vendor/quickjs-ng/gen/hello_module.c +106 -0
  357. package/vendor/quickjs-ng/gen/repl.c +3036 -0
  358. package/vendor/quickjs-ng/gen/standalone.c +323 -0
  359. package/vendor/quickjs-ng/gen/test_fib.c +81 -0
  360. package/vendor/quickjs-ng/libregexp-opcode.h +73 -0
  361. package/vendor/quickjs-ng/libregexp.c +3474 -0
  362. package/vendor/quickjs-ng/libregexp.h +101 -0
  363. package/vendor/quickjs-ng/libunicode-table.h +5173 -0
  364. package/vendor/quickjs-ng/libunicode.c +2069 -0
  365. package/vendor/quickjs-ng/libunicode.h +172 -0
  366. package/vendor/quickjs-ng/list.h +107 -0
  367. package/vendor/quickjs-ng/lre-test.c +52 -0
  368. package/vendor/quickjs-ng/qjs.c +762 -0
  369. package/vendor/quickjs-ng/qjsc.c +673 -0
  370. package/vendor/quickjs-ng/quickjs-atom.h +280 -0
  371. package/vendor/quickjs-ng/quickjs-c-atomics.h +54 -0
  372. package/vendor/quickjs-ng/quickjs-libc.c +5037 -0
  373. package/vendor/quickjs-ng/quickjs-libc.h +87 -0
  374. package/vendor/quickjs-ng/quickjs-opcode.h +377 -0
  375. package/vendor/quickjs-ng/quickjs.c +64041 -0
  376. package/vendor/quickjs-ng/quickjs.h +1447 -0
  377. package/vendor/quickjs-ng/run-test262.c +2374 -0
  378. package/vendor/quickjs-ng/unicode_gen.c +3121 -0
  379. package/vendor/quickjs-ng/unicode_gen_def.h +310 -0
  380. package/vendor/ryu/LICENSE-Boost +23 -0
  381. package/vendor/ryu/common.h +114 -0
  382. package/vendor/ryu/d2s.c +509 -0
  383. package/vendor/ryu/d2s_full_table.h +367 -0
  384. package/vendor/ryu/d2s_intrinsics.h +357 -0
  385. package/vendor/ryu/d2s_small_table.h +186 -0
  386. package/vendor/ryu/digit_table.h +35 -0
  387. package/vendor/ryu/ryu.h +46 -0
  388. package/vendor/zlib/LICENSE +22 -0
  389. package/vendor/zlib/adler32.c +164 -0
  390. package/vendor/zlib/compress.c +75 -0
  391. package/vendor/zlib/crc32.c +1049 -0
  392. package/vendor/zlib/crc32.h +9446 -0
  393. package/vendor/zlib/deflate.c +2139 -0
  394. package/vendor/zlib/deflate.h +377 -0
  395. package/vendor/zlib/gzclose.c +23 -0
  396. package/vendor/zlib/gzguts.h +214 -0
  397. package/vendor/zlib/gzlib.c +582 -0
  398. package/vendor/zlib/gzread.c +602 -0
  399. package/vendor/zlib/gzwrite.c +631 -0
  400. package/vendor/zlib/infback.c +628 -0
  401. package/vendor/zlib/inffast.c +320 -0
  402. package/vendor/zlib/inffast.h +11 -0
  403. package/vendor/zlib/inffixed.h +94 -0
  404. package/vendor/zlib/inflate.c +1526 -0
  405. package/vendor/zlib/inflate.h +126 -0
  406. package/vendor/zlib/inftrees.c +299 -0
  407. package/vendor/zlib/inftrees.h +62 -0
  408. package/vendor/zlib/trees.c +1117 -0
  409. package/vendor/zlib/trees.h +128 -0
  410. package/vendor/zlib/uncompr.c +85 -0
  411. package/vendor/zlib/zconf.h +543 -0
  412. package/vendor/zlib/zlib.h +1938 -0
  413. package/vendor/zlib/zutil.c +299 -0
  414. package/vendor/zlib/zutil.h +254 -0
  415. package/README.md +0 -3
  416. package/index.js +0 -2
@@ -0,0 +1,803 @@
1
+ /* util.inspect — the runtime half of the static rendering. The compiler
2
+ * synthesizes one traversal helper per static type (lower-inspect.ts, the
3
+ * deepStrictEqual precedent); THIS file owns everything the static type
4
+ * cannot know: Node's exact scalar formatting (number -0, the
5
+ * single→double→backtick quoting ladder with C0/C1/DEL/lone-surrogate
6
+ * escapes, the 10000-char string cap and the per-line ` +` continuation
7
+ * form), Buffer's <Buffer aa bb> hex form, and the LAYOUT engine — a
8
+ * frame stack reproducing reduceToSingleString, isBelowBreakLength, and
9
+ * groupArrayElements from Node v24's lib/internal/util/inspect.js for the
10
+ * DEFAULT options (compact: 3, breakLength: 80, maxArrayLength: 100,
11
+ * maxStringLength: 10000; non-default options fence in the frontend).
12
+ *
13
+ * Lengths follow Node exactly: the break-length math counts UTF-16 code
14
+ * units (JS .length); the grid-grouping math counts DISPLAY WIDTH. Node
15
+ * with ICU measures width via icu::getStringWidth over NFC-normalized
16
+ * text; this file ports the non-ICU fallback tables (full-width/
17
+ * zero-width code points, no NFC) — pure-ASCII entries agree exactly,
18
+ * exotic grouped entries may not (SEMANTICS.md divergence).
19
+ *
20
+ * The frame stack is process-global (single-threaded runtime, and the
21
+ * synthesized traversals never call user code — no getters, no custom
22
+ * inspect — so renders never nest re-entrantly mid-frame).
23
+ *
24
+ * Ownership: ScrStr/ScrBytes/ScrDyn/ScrError arguments are BORROWED;
25
+ * ScrStr results return +1. Nothing here throws; OOM aborts. */
26
+ #include "scr_runtime.h"
27
+
28
+ #include <math.h>
29
+ #include <stdio.h>
30
+ #include <stdlib.h>
31
+ #include <string.h>
32
+
33
+ static void insp_oom(void) {
34
+ fputs("scriptc: out of memory\n", stderr);
35
+ abort();
36
+ }
37
+
38
+ /* ── a tiny append-only byte buffer ──────────────────────────────────── */
39
+
40
+ typedef struct {
41
+ char *data;
42
+ size_t len;
43
+ size_t cap;
44
+ } InspBuf;
45
+
46
+ static void ib_grow(InspBuf *b, size_t need) {
47
+ if (b->len + need <= b->cap) return;
48
+ size_t cap = b->cap ? b->cap * 2 : 64;
49
+ while (cap < b->len + need) cap *= 2;
50
+ char *data = realloc(b->data, cap);
51
+ if (!data) insp_oom();
52
+ b->data = data;
53
+ b->cap = cap;
54
+ }
55
+
56
+ static void ib_bytes(InspBuf *b, const char *s, size_t len) {
57
+ ib_grow(b, len);
58
+ memcpy(b->data + b->len, s, len);
59
+ b->len += len;
60
+ }
61
+
62
+ static void ib_cstr(InspBuf *b, const char *s) { ib_bytes(b, s, strlen(s)); }
63
+ static void ib_char(InspBuf *b, char c) { ib_bytes(b, &c, 1); }
64
+ static void ib_str(InspBuf *b, const ScrStr *s) { ib_bytes(b, s->data, s->len); }
65
+
66
+ static void ib_spaces(InspBuf *b, size_t n) {
67
+ ib_grow(b, n);
68
+ memset(b->data + b->len, ' ', n);
69
+ b->len += n;
70
+ }
71
+
72
+ static ScrStr *ib_take(InspBuf *b) {
73
+ ScrStr *out = scr_str_new(b->data ? b->data : "", b->len);
74
+ free(b->data);
75
+ return out;
76
+ }
77
+
78
+ /* ── WTF-8 iteration + JS length/width measures ──────────────────────── */
79
+
80
+ /* Decode the code point at data[i] (WTF-8: lone surrogates ride 3-byte
81
+ * ED A0..BF xx sequences). Malformed bytes decode as themselves — the
82
+ * runtime never produces them, this is belt-and-braces. Advances *i. */
83
+ static uint32_t insp_cp_at(const char *data, size_t len, size_t *i) {
84
+ const unsigned char *p = (const unsigned char *)data;
85
+ unsigned char c = p[*i];
86
+ if (c < 0x80) {
87
+ *i += 1;
88
+ return c;
89
+ }
90
+ if ((c & 0xe0) == 0xc0 && *i + 1 < len) {
91
+ uint32_t cp = ((uint32_t)(c & 0x1f) << 6) | (p[*i + 1] & 0x3f);
92
+ *i += 2;
93
+ return cp;
94
+ }
95
+ if ((c & 0xf0) == 0xe0 && *i + 2 < len) {
96
+ uint32_t cp = ((uint32_t)(c & 0x0f) << 12) | ((uint32_t)(p[*i + 1] & 0x3f) << 6) |
97
+ (p[*i + 2] & 0x3f);
98
+ *i += 3;
99
+ return cp;
100
+ }
101
+ if ((c & 0xf8) == 0xf0 && *i + 3 < len) {
102
+ uint32_t cp = ((uint32_t)(c & 0x07) << 18) | ((uint32_t)(p[*i + 1] & 0x3f) << 12) |
103
+ ((uint32_t)(p[*i + 2] & 0x3f) << 6) | (p[*i + 3] & 0x3f);
104
+ *i += 4;
105
+ return cp;
106
+ }
107
+ *i += 1;
108
+ return c;
109
+ }
110
+
111
+ /* JS .length: UTF-16 code units (astral code points count 2). */
112
+ static size_t insp_utf16_len(const char *data, size_t len) {
113
+ size_t units = 0;
114
+ for (size_t i = 0; i < len;) {
115
+ uint32_t cp = insp_cp_at(data, len, &i);
116
+ units += cp >= 0x10000 ? 2 : 1;
117
+ }
118
+ return units;
119
+ }
120
+
121
+ /* Node's non-ICU isFullWidthCodePoint table (inspect.js). */
122
+ static bool insp_full_width(uint32_t code) {
123
+ return code >= 0x1100 &&
124
+ (code <= 0x115f || code == 0x2329 || code == 0x232a ||
125
+ (code >= 0x2e80 && code <= 0x3247 && code != 0x303f) ||
126
+ (code >= 0x3250 && code <= 0x4dbf) || (code >= 0x4e00 && code <= 0xa4c6) ||
127
+ (code >= 0xa960 && code <= 0xa97c) || (code >= 0xac00 && code <= 0xd7a3) ||
128
+ (code >= 0xf900 && code <= 0xfaff) || (code >= 0xfe10 && code <= 0xfe19) ||
129
+ (code >= 0xfe30 && code <= 0xfe6b) || (code >= 0xff01 && code <= 0xff60) ||
130
+ (code >= 0xffe0 && code <= 0xffe6) || (code >= 0x1b000 && code <= 0x1b001) ||
131
+ (code >= 0x1f200 && code <= 0x1f251) || (code >= 0x1f300 && code <= 0x1f64f) ||
132
+ (code >= 0x20000 && code <= 0x3fffd));
133
+ }
134
+
135
+ /* Node's non-ICU isZeroWidthCodePoint table (inspect.js). */
136
+ static bool insp_zero_width(uint32_t code) {
137
+ return code <= 0x1f || (code >= 0x7f && code <= 0x9f) ||
138
+ (code >= 0x300 && code <= 0x36f) || (code >= 0x200b && code <= 0x200f) ||
139
+ (code >= 0x20d0 && code <= 0x20ff) || (code >= 0xfe00 && code <= 0xfe0f) ||
140
+ (code >= 0xfe20 && code <= 0xfe2f) || (code >= 0xe0100 && code <= 0xe01ef);
141
+ }
142
+
143
+ /* Display width (grouping math only): Node's non-ICU getStringWidth,
144
+ * without the NFC normalization ICU builds apply (SEMANTICS.md). */
145
+ static size_t insp_width(const char *data, size_t len) {
146
+ size_t width = 0;
147
+ for (size_t i = 0; i < len;) {
148
+ uint32_t cp = insp_cp_at(data, len, &i);
149
+ if (insp_full_width(cp)) width += 2;
150
+ else if (!insp_zero_width(cp)) width += 1;
151
+ }
152
+ return width;
153
+ }
154
+
155
+ /* ── number rendering ────────────────────────────────────────────────── */
156
+
157
+ /* formatNumber: JS ToString EXCEPT -0 renders as '-0'. */
158
+ ScrStr *scr_insp_f64(double x) {
159
+ if (x == 0.0 && signbit(x)) return scr_str_new("-0", 2);
160
+ char buf[40];
161
+ size_t n = scr_f64_to_str(x, buf);
162
+ return scr_str_new(buf, n);
163
+ }
164
+
165
+ /* ── string quoting (strEscape) ──────────────────────────────────────── */
166
+
167
+ /* The C0 escape table (inspect.js `meta`, entries 0x00-0x1f). */
168
+ static const char *const INSP_C0[32] = {
169
+ "\\x00", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\x07",
170
+ "\\b", "\\t", "\\n", "\\x0B", "\\f", "\\r", "\\x0E", "\\x0F",
171
+ "\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17",
172
+ "\\x18", "\\x19", "\\x1A", "\\x1B", "\\x1C", "\\x1D", "\\x1E", "\\x1F",
173
+ };
174
+
175
+ static bool insp_contains_byte(const char *data, size_t len, char c) {
176
+ return memchr(data, c, len) != NULL;
177
+ }
178
+
179
+ static bool insp_contains_dollar_brace(const char *data, size_t len) {
180
+ for (size_t i = 0; i + 1 < len; i++) {
181
+ if (data[i] == '$' && data[i + 1] == '{') return true;
182
+ }
183
+ return false;
184
+ }
185
+
186
+ /* Quote selection: single quotes; double when the text has ' but no ";
187
+ * backtick when it has both but no ` and no ${. -1 = ", -2 = `, 39 = '. */
188
+ static int insp_pick_quote(const char *data, size_t len) {
189
+ if (!insp_contains_byte(data, len, '\'')) return 39;
190
+ if (!insp_contains_byte(data, len, '"')) return -1;
191
+ if (!insp_contains_byte(data, len, '`') && !insp_contains_dollar_brace(data, len)) return -2;
192
+ return 39;
193
+ }
194
+
195
+ static char insp_quote_char(int quote) { return quote == -1 ? '"' : quote == -2 ? '`' : '\''; }
196
+
197
+ /* strEscape's body between the quotes: escape backslash, C0 (the meta
198
+ * table), DEL + C1 as \xNN (uppercase), lone surrogates as \udNNN
199
+ * (lowercase — Number.prototype.toString(16)), and the single quote only
200
+ * when quoting with '. */
201
+ static void insp_escape_into(InspBuf *b, const char *data, size_t len, int quote) {
202
+ for (size_t i = 0; i < len;) {
203
+ size_t start = i;
204
+ uint32_t cp = insp_cp_at(data, len, &i);
205
+ if (cp < 0x20) {
206
+ ib_cstr(b, INSP_C0[cp]);
207
+ } else if (cp == '\'' && quote == 39) {
208
+ ib_cstr(b, "\\'");
209
+ } else if (cp == '\\') {
210
+ ib_cstr(b, "\\\\");
211
+ } else if (cp >= 0x7f && cp <= 0x9f) {
212
+ char esc[8];
213
+ snprintf(esc, sizeof esc, "\\x%02X", cp);
214
+ ib_cstr(b, esc);
215
+ } else if (cp >= 0xd800 && cp <= 0xdfff) {
216
+ char esc[8];
217
+ snprintf(esc, sizeof esc, "\\u%x", cp);
218
+ ib_cstr(b, esc);
219
+ } else {
220
+ ib_bytes(b, data + start, i - start);
221
+ }
222
+ }
223
+ }
224
+
225
+ static void insp_quote_into(InspBuf *b, const char *data, size_t len) {
226
+ int quote = insp_pick_quote(data, len);
227
+ ib_char(b, insp_quote_char(quote));
228
+ insp_escape_into(b, data, len, quote);
229
+ ib_char(b, insp_quote_char(quote));
230
+ }
231
+
232
+ /* ── the frame stack ─────────────────────────────────────────────────── */
233
+
234
+ typedef struct {
235
+ ScrStr **items;
236
+ size_t len;
237
+ size_t cap;
238
+ bool all_num; /* every entry so far flagged numeric (grouping order) */
239
+ } InspFrame;
240
+
241
+ static InspFrame *g_frames;
242
+ static size_t g_nframes;
243
+ static size_t g_frames_cap;
244
+ static size_t g_indent; /* ctx.indentationLvl */
245
+ static double g_cur_depth; /* ctx.currentDepth (last-entered composite) */
246
+
247
+ static InspFrame *insp_top(void) { return &g_frames[g_nframes - 1]; }
248
+
249
+ /* Begin a non-empty composite: formatRaw's `recurseTimes += 1;
250
+ * ctx.currentDepth = recurseTimes` plus the uniform +2 the children
251
+ * format under. `recurse` is the CHILDREN's recursion depth. */
252
+ void scr_insp_begin(double recurse) {
253
+ if (g_nframes == g_frames_cap) {
254
+ g_frames_cap = g_frames_cap ? g_frames_cap * 2 : 8;
255
+ g_frames = realloc(g_frames, g_frames_cap * sizeof(InspFrame));
256
+ if (!g_frames) insp_oom();
257
+ }
258
+ InspFrame *f = &g_frames[g_nframes++];
259
+ f->items = NULL;
260
+ f->len = 0;
261
+ f->cap = 0;
262
+ f->all_num = true;
263
+ g_cur_depth = recurse;
264
+ g_indent += 2;
265
+ }
266
+
267
+ /* Append one already-rendered entry (borrowed; retained here). is_num
268
+ * mirrors `typeof value[i] === 'number'` — it decides grid grouping's
269
+ * padStart/padEnd order. */
270
+ void scr_insp_entry(ScrStr *s, bool is_num) {
271
+ InspFrame *f = insp_top();
272
+ if (f->len == f->cap) {
273
+ f->cap = f->cap ? f->cap * 2 : 8;
274
+ f->items = realloc(f->items, f->cap * sizeof(ScrStr *));
275
+ if (!f->items) insp_oom();
276
+ }
277
+ f->items[f->len++] = scr_str_retain(s);
278
+ if (!is_num) f->all_num = false;
279
+ }
280
+
281
+ /* remainingText: the "... N more items" tail entry. */
282
+ ScrStr *scr_insp_more_items(double remaining) {
283
+ char buf[64];
284
+ int n = snprintf(buf, sizeof buf, "... %.0f more item%s", remaining, remaining > 1 ? "s" : "");
285
+ return scr_str_new(buf, (size_t)n);
286
+ }
287
+
288
+ /* groupArrayElements: the grid layout for arrays with more than six
289
+ * entries. Rewrites the frame's items in place when grouping applies. */
290
+ static void insp_group(InspFrame *f, bool trailing_more) {
291
+ size_t output_len = f->len - (trailing_more ? 1 : 0);
292
+ double total_length = 0;
293
+ double max_length = 0;
294
+ size_t *data_len = malloc((output_len ? output_len : 1) * sizeof(size_t));
295
+ if (!data_len) insp_oom();
296
+ for (size_t i = 0; i < output_len; i++) {
297
+ size_t w = insp_width(f->items[i]->data, f->items[i]->len);
298
+ data_len[i] = w;
299
+ total_length += (double)w + 2;
300
+ if ((double)w > max_length) max_length = (double)w;
301
+ }
302
+ double actual_max = max_length + 2;
303
+ if (actual_max * 3 + (double)g_indent < 80 &&
304
+ (total_length / actual_max > 5 || max_length <= 6)) {
305
+ double approx_char_heights = 2.5;
306
+ double average_bias = sqrt(actual_max - total_length / (double)f->len);
307
+ double biased_max = fmax(actual_max - 3 - average_bias, 1);
308
+ double columns_d = fmin(
309
+ fmin(round(sqrt(approx_char_heights * biased_max * (double)output_len) / biased_max),
310
+ floor((80 - (double)g_indent) / actual_max)),
311
+ fmin(3 * 4 /* ctx.compact * 4 */, 15));
312
+ if (columns_d <= 1) {
313
+ free(data_len);
314
+ return;
315
+ }
316
+ size_t columns = (size_t)columns_d;
317
+ size_t *max_line_length = malloc(columns * sizeof(size_t));
318
+ if (!max_line_length) insp_oom();
319
+ for (size_t i = 0; i < columns; i++) {
320
+ size_t line_max = 0;
321
+ for (size_t j = i; j < output_len; j += columns) {
322
+ if (data_len[j] > line_max) line_max = data_len[j];
323
+ }
324
+ max_line_length[i] = line_max + 2;
325
+ }
326
+ bool pad_start = f->all_num;
327
+ ScrStr **tmp = NULL;
328
+ size_t tmp_len = 0, tmp_cap = 0;
329
+ for (size_t i = 0; i < output_len; i += columns) {
330
+ size_t max = i + columns < output_len ? i + columns : output_len;
331
+ InspBuf line = {0};
332
+ size_t j = i;
333
+ for (; j + 1 < max; j++) {
334
+ size_t width = data_len[j];
335
+ size_t target = max_line_length[j - i];
336
+ if (pad_start) {
337
+ if (target > width + 2) ib_spaces(&line, target - width - 2);
338
+ ib_str(&line, f->items[j]);
339
+ ib_cstr(&line, ", ");
340
+ } else {
341
+ ib_str(&line, f->items[j]);
342
+ ib_cstr(&line, ", ");
343
+ if (target > width + 2) ib_spaces(&line, target - width - 2);
344
+ }
345
+ }
346
+ if (pad_start) {
347
+ size_t width = data_len[j];
348
+ size_t target = max_line_length[j - i] - 2;
349
+ if (target > width) ib_spaces(&line, target - width);
350
+ ib_str(&line, f->items[j]);
351
+ } else {
352
+ ib_str(&line, f->items[j]);
353
+ }
354
+ if (tmp_len == tmp_cap) {
355
+ tmp_cap = tmp_cap ? tmp_cap * 2 : 8;
356
+ tmp = realloc(tmp, tmp_cap * sizeof(ScrStr *));
357
+ if (!tmp) insp_oom();
358
+ }
359
+ tmp[tmp_len++] = ib_take(&line);
360
+ }
361
+ if (trailing_more) {
362
+ if (tmp_len == tmp_cap) {
363
+ tmp_cap += 1;
364
+ tmp = realloc(tmp, tmp_cap * sizeof(ScrStr *));
365
+ if (!tmp) insp_oom();
366
+ }
367
+ tmp[tmp_len++] = scr_str_retain(f->items[f->len - 1]);
368
+ }
369
+ for (size_t i = 0; i < f->len; i++) scr_str_release(f->items[i]);
370
+ free(f->items);
371
+ f->items = tmp;
372
+ f->len = tmp_len;
373
+ f->cap = tmp_cap;
374
+ free(max_line_length);
375
+ }
376
+ free(data_len);
377
+ }
378
+
379
+ /* isBelowBreakLength: UTF-16 lengths against breakLength 80. */
380
+ static bool insp_below_break_length(InspFrame *f, size_t start, const ScrStr *base) {
381
+ size_t total = f->len + start;
382
+ if (total + f->len > 80) return false;
383
+ for (size_t i = 0; i < f->len; i++) {
384
+ total += insp_utf16_len(f->items[i]->data, f->items[i]->len);
385
+ if (total > 80) return false;
386
+ }
387
+ return base->len == 0 || !insp_contains_byte(base->data, base->len, '\n');
388
+ }
389
+
390
+ /* reduceToSingleString for the default options (compact: 3). Pops the
391
+ * frame. base/b0/b1 are borrowed; +1 result. `recurse` is the frame's
392
+ * recurseTimes (the children's depth); array_extras marks kArrayExtrasType
393
+ * (grid grouping applies); trailing_more marks a "... N more items" tail
394
+ * entry (excluded from the grid). */
395
+ ScrStr *scr_insp_end(ScrStr *base, ScrStr *b0, ScrStr *b1, double recurse, bool array_extras,
396
+ bool trailing_more) {
397
+ InspFrame *f = insp_top();
398
+ g_indent -= 2;
399
+ size_t entries = f->len;
400
+ if (array_extras && entries > 6) insp_group(f, trailing_more);
401
+ InspBuf out = {0};
402
+ if (g_cur_depth - recurse < 3 && entries == f->len) {
403
+ size_t start = f->len + g_indent + insp_utf16_len(b0->data, b0->len) +
404
+ insp_utf16_len(base->data, base->len) + 10;
405
+ if (insp_below_break_length(f, start, base)) {
406
+ bool multiline = false;
407
+ for (size_t i = 0; i < f->len && !multiline; i++) {
408
+ multiline = insp_contains_byte(f->items[i]->data, f->items[i]->len, '\n');
409
+ }
410
+ if (!multiline) {
411
+ if (base->len) {
412
+ ib_str(&out, base);
413
+ ib_char(&out, ' ');
414
+ }
415
+ ib_str(&out, b0);
416
+ ib_char(&out, ' ');
417
+ for (size_t i = 0; i < f->len; i++) {
418
+ if (i) ib_cstr(&out, ", ");
419
+ ib_str(&out, f->items[i]);
420
+ }
421
+ ib_char(&out, ' ');
422
+ ib_str(&out, b1);
423
+ goto done;
424
+ }
425
+ }
426
+ }
427
+ if (base->len) {
428
+ ib_str(&out, base);
429
+ ib_char(&out, ' ');
430
+ }
431
+ ib_str(&out, b0);
432
+ for (size_t i = 0; i < f->len; i++) {
433
+ ib_cstr(&out, i ? ",\n" : "\n");
434
+ ib_spaces(&out, g_indent + 2);
435
+ ib_str(&out, f->items[i]);
436
+ }
437
+ ib_char(&out, '\n');
438
+ ib_spaces(&out, g_indent);
439
+ ib_str(&out, b1);
440
+ done:;
441
+ for (size_t i = 0; i < f->len; i++) scr_str_release(f->items[i]);
442
+ free(f->items);
443
+ g_nframes--;
444
+ return ib_take(&out);
445
+ }
446
+
447
+ /* ── string values (formatPrimitive's string half) ───────────────────── */
448
+
449
+ /* Byte offset of UTF-16 unit `units` — when the boundary splits an astral
450
+ * code point (JS slice splitting a surrogate pair), the left half keeps
451
+ * the HIGH surrogate: *lone_high is set and the offset excludes the
452
+ * 4-byte sequence. */
453
+ static size_t insp_utf16_offset(const char *data, size_t len, size_t units, bool *lone_high,
454
+ uint32_t *high_cp) {
455
+ size_t count = 0;
456
+ *lone_high = false;
457
+ for (size_t i = 0; i < len;) {
458
+ if (count == units) return i;
459
+ size_t start = i;
460
+ uint32_t cp = insp_cp_at(data, len, &i);
461
+ size_t w = cp >= 0x10000 ? 2 : 1;
462
+ if (count + w > units) {
463
+ /* boundary splits this astral pair: keep its high surrogate */
464
+ *lone_high = true;
465
+ *high_cp = 0xd800 + ((cp - 0x10000) >> 10);
466
+ return start;
467
+ }
468
+ count += w;
469
+ }
470
+ return len;
471
+ }
472
+
473
+ /* formatPrimitive over a string value under the default options:
474
+ * maxStringLength 10000, then the per-line ` +` continuation when the
475
+ * (truncated) text is longer than 16 chars AND breakLength(80) -
476
+ * indentationLvl - 4, split after each newline; the trailer counts the
477
+ * cut characters. Uses the CURRENT indentation. */
478
+ ScrStr *scr_insp_str(ScrStr *s) {
479
+ InspBuf out = {0};
480
+ const char *data = s->data;
481
+ size_t byte_len = s->len;
482
+ size_t units = insp_utf16_len(data, byte_len);
483
+ char trailer[64] = "";
484
+ char surrogate_tail[4];
485
+ size_t surrogate_tail_len = 0;
486
+ if (units > 10000) {
487
+ size_t remaining = units - 10000;
488
+ bool lone_high;
489
+ uint32_t high_cp = 0;
490
+ byte_len = insp_utf16_offset(data, byte_len, 10000, &lone_high, &high_cp);
491
+ if (lone_high) {
492
+ /* re-encode the kept high surrogate as WTF-8 */
493
+ surrogate_tail[0] = (char)(0xe0 | (high_cp >> 12));
494
+ surrogate_tail[1] = (char)(0x80 | ((high_cp >> 6) & 0x3f));
495
+ surrogate_tail[2] = (char)(0x80 | (high_cp & 0x3f));
496
+ surrogate_tail_len = 3;
497
+ }
498
+ snprintf(trailer, sizeof trailer, "... %zu more character%s", remaining,
499
+ remaining > 1 ? "s" : "");
500
+ units = 10000;
501
+ }
502
+ /* the (possibly truncated) value as one buffer */
503
+ InspBuf val = {0};
504
+ ib_bytes(&val, data, byte_len);
505
+ if (surrogate_tail_len) ib_bytes(&val, surrogate_tail, surrogate_tail_len);
506
+ size_t vlen = val.len;
507
+ const char *v = val.data ? val.data : "";
508
+ if (units > 16 && units > 80 - g_indent - 4 && memchr(v, '\n', vlen) != NULL) {
509
+ /* split after each newline; quote each chunk; join with ` +\n<indent+2>` */
510
+ size_t chunk_start = 0;
511
+ bool first = true;
512
+ for (size_t i = 0; i <= vlen; i++) {
513
+ bool at_end = i == vlen;
514
+ if (at_end ? i > chunk_start : v[i] == '\n') {
515
+ size_t end = at_end ? i : i + 1;
516
+ if (!first) {
517
+ ib_cstr(&out, " +\n");
518
+ ib_spaces(&out, g_indent + 2);
519
+ }
520
+ insp_quote_into(&out, v + chunk_start, end - chunk_start);
521
+ chunk_start = end;
522
+ first = false;
523
+ }
524
+ }
525
+ } else {
526
+ insp_quote_into(&out, v, vlen);
527
+ }
528
+ if (trailer[0]) ib_cstr(&out, trailer);
529
+ free(val.data);
530
+ return ib_take(&out);
531
+ }
532
+
533
+ /* ── regex / Buffer / Error leaves ───────────────────────────────────── */
534
+
535
+ /* RegExp: `/source/flags` (RegExp.prototype.toString — regexes render
536
+ * fully at any depth; our regexes never carry extra own properties). */
537
+ ScrStr *scr_insp_regex(ScrRegex *re) {
538
+ InspBuf out = {0};
539
+ ib_char(&out, '/');
540
+ ib_bytes(&out, re->source->data, re->source->len);
541
+ ib_char(&out, '/');
542
+ ib_bytes(&out, re->flags->data, re->flags->len);
543
+ return ib_take(&out);
544
+ }
545
+
546
+ /* Buffer: the custom-inspect hex form `<Buffer aa bb ...>`, capped at
547
+ * INSPECT_MAX_BYTES (50); renders fully at any depth (custom inspection
548
+ * runs before the depth check in Node). u8 element kind only (the
549
+ * frontend fences the rest). */
550
+ ScrStr *scr_insp_buffer(ScrBytes *b) {
551
+ InspBuf out = {0};
552
+ ib_cstr(&out, "<Buffer ");
553
+ size_t max = b->len < 50 ? b->len : 50;
554
+ for (size_t i = 0; i < max; i++) {
555
+ char hex[4];
556
+ snprintf(hex, sizeof hex, "%02x", ((const unsigned char *)b->data)[i]);
557
+ if (i) ib_char(&out, ' ');
558
+ ib_bytes(&out, hex, 2);
559
+ }
560
+ if (b->len > 50) {
561
+ char more[48];
562
+ size_t remaining = b->len - 50;
563
+ int n = snprintf(more, sizeof more, " ... %zu more byte%s", remaining,
564
+ remaining > 1 ? "s" : "");
565
+ ib_bytes(&out, more, (size_t)n);
566
+ }
567
+ ib_char(&out, '>');
568
+ return ib_take(&out);
569
+ }
570
+
571
+ /* Errors: the STACKLESS rendering — compiled binaries carry no stack, so
572
+ * the base is formatError's bracket form `[Name: message]` / `[Name]`
573
+ * (Node prints these exact forms for an error whose stack is empty;
574
+ * stack-carrying Node output is a documented divergence). A stamped
575
+ * `code` slot renders as the one extra own property Node would show:
576
+ * `[Error: m] { code: 'X' }`, `[Error]` beyond depth. Message newlines
577
+ * indent like Node's formatError tail. */
578
+ ScrStr *scr_insp_error(ScrError *e, double recurse, double depth) {
579
+ bool has_code = e->code != NULL; /* the stamped slot, read directly (borrowed) */
580
+ if (has_code && recurse > depth) {
581
+ /* `[${getCtxStyle(...)}]` with the trailing space sliced: [Name] */
582
+ InspBuf out = {0};
583
+ ib_char(&out, '[');
584
+ ib_str(&out, e->name);
585
+ ib_char(&out, ']');
586
+ return ib_take(&out);
587
+ }
588
+ InspBuf base = {0};
589
+ ib_char(&base, '[');
590
+ ib_str(&base, e->name);
591
+ if (e->message->len) {
592
+ ib_cstr(&base, ": ");
593
+ /* indent embedded newlines by the CURRENT level (formatError's
594
+ * final replaceAll — g_indent is the property's own level here). */
595
+ for (size_t i = 0; i < e->message->len; i++) {
596
+ char c = e->message->data[i];
597
+ ib_char(&base, c);
598
+ if (c == '\n') ib_spaces(&base, g_indent);
599
+ }
600
+ }
601
+ ib_char(&base, ']');
602
+ ScrStr *base_str = ib_take(&base);
603
+ if (!has_code) return base_str;
604
+ scr_insp_begin(recurse + 1);
605
+ {
606
+ InspBuf entry = {0};
607
+ ib_cstr(&entry, "code: ");
608
+ insp_quote_into(&entry, e->code->data, e->code->len);
609
+ ScrStr *entry_str = ib_take(&entry);
610
+ scr_insp_entry(entry_str, false);
611
+ scr_str_release(entry_str);
612
+ }
613
+ ScrStr *b0 = scr_str_new("{", 1);
614
+ ScrStr *b1 = scr_str_new("}", 1);
615
+ ScrStr *out = scr_insp_end(base_str, b0, b1, recurse + 1, false, false);
616
+ scr_str_release(b0);
617
+ scr_str_release(b1);
618
+ scr_str_release(base_str);
619
+ return out;
620
+ }
621
+
622
+ /* ── dyn values (the checked-dynamic JSON DOM) ───────────────────────── */
623
+
624
+ /* Property-name rendering: bare when the key matches Node's keyStrRegExp
625
+ * (/^[a-zA-Z_][a-zA-Z_0-9]*$/, '__proto__' excepted), quoted otherwise. */
626
+ static void insp_key_into(InspBuf *b, const char *key, size_t len) {
627
+ if (len == 9 && memcmp(key, "__proto__", 9) == 0) {
628
+ ib_cstr(b, "['__proto__']");
629
+ return;
630
+ }
631
+ bool bare = len > 0;
632
+ for (size_t i = 0; bare && i < len; i++) {
633
+ char c = key[i];
634
+ bool head_ok = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_';
635
+ bool tail_ok = head_ok || (c >= '0' && c <= '9');
636
+ bare = i == 0 ? head_ok : tail_ok;
637
+ }
638
+ if (bare) {
639
+ ib_bytes(b, key, len);
640
+ } else {
641
+ insp_quote_into(b, key, len);
642
+ }
643
+ }
644
+
645
+ /* Property-name rendering for the synthesized index-signature record
646
+ * helpers (their keys are runtime strings, so the bare-or-quoted ladder
647
+ * must run here): insp_key_into over a ScrStr. Borrows; result +1. */
648
+ ScrStr *scr_insp_key(ScrStr *k) {
649
+ InspBuf b = {0};
650
+ insp_key_into(&b, k->data, k->len);
651
+ return ib_take(&b);
652
+ }
653
+
654
+ /* The full inspect over a dyn tree — the one runtime type whose SHAPE
655
+ * lives in the value, so the traversal lives here instead of a
656
+ * synthesized helper. Same engine, same defaults. dyn-boxed bytes render
657
+ * in the DOM's documented Uint8Array identity (SEMANTICS.md). */
658
+ ScrStr *scr_insp_dyn(ScrDyn *d, double recurse, double depth) {
659
+ switch (d->kind) {
660
+ case SCR_DYN_NULL:
661
+ return scr_str_new("null", 4);
662
+ case SCR_DYN_UNDEF:
663
+ return scr_str_new("undefined", 9);
664
+ case SCR_DYN_BOOL:
665
+ return d->v.b ? scr_str_new("true", 4) : scr_str_new("false", 5);
666
+ case SCR_DYN_NUM:
667
+ return scr_insp_f64(d->v.num);
668
+ case SCR_DYN_STR:
669
+ return scr_insp_str(d->v.str);
670
+ case SCR_DYN_ARR: {
671
+ if (d->v.arr.len == 0) return scr_str_new("[]", 2);
672
+ if (recurse > depth) return scr_str_new("[Array]", 7);
673
+ scr_insp_begin(recurse + 1);
674
+ size_t shown = d->v.arr.len < 100 ? d->v.arr.len : 100;
675
+ for (size_t i = 0; i < shown; i++) {
676
+ ScrDyn *item = d->v.arr.items[i];
677
+ ScrStr *s = scr_insp_dyn(item, recurse + 1, depth);
678
+ scr_insp_entry(s, item->kind == SCR_DYN_NUM);
679
+ scr_str_release(s);
680
+ }
681
+ bool more = d->v.arr.len > 100;
682
+ if (more) {
683
+ ScrStr *m = scr_insp_more_items((double)(d->v.arr.len - 100));
684
+ scr_insp_entry(m, d->v.arr.items[100]->kind == SCR_DYN_NUM);
685
+ scr_str_release(m);
686
+ }
687
+ ScrStr *base = scr_str_new("", 0);
688
+ ScrStr *b0 = scr_str_new("[", 1);
689
+ ScrStr *b1 = scr_str_new("]", 1);
690
+ ScrStr *out = scr_insp_end(base, b0, b1, recurse + 1, true, more);
691
+ scr_str_release(base);
692
+ scr_str_release(b0);
693
+ scr_str_release(b1);
694
+ return out;
695
+ }
696
+ case SCR_DYN_OBJ: {
697
+ if (d->v.obj.len == 0) return scr_str_new("{}", 2);
698
+ if (recurse > depth) return scr_str_new("[Object]", 8);
699
+ scr_insp_begin(recurse + 1);
700
+ for (size_t i = 0; i < d->v.obj.len; i++) {
701
+ ScrDynEntry *ent = &d->v.obj.entries[i];
702
+ ScrStr *val = scr_insp_dyn(ent->value, recurse + 1, depth);
703
+ InspBuf eb = {0};
704
+ insp_key_into(&eb, ent->key, ent->key_len);
705
+ ib_cstr(&eb, ": ");
706
+ ib_bytes(&eb, val->data, val->len);
707
+ scr_str_release(val);
708
+ ScrStr *entry = ib_take(&eb);
709
+ scr_insp_entry(entry, false);
710
+ scr_str_release(entry);
711
+ }
712
+ ScrStr *base = scr_str_new("", 0);
713
+ ScrStr *b0 = scr_str_new("{", 1);
714
+ ScrStr *b1 = scr_str_new("}", 1);
715
+ ScrStr *out = scr_insp_end(base, b0, b1, recurse + 1, false, false);
716
+ scr_str_release(base);
717
+ scr_str_release(b0);
718
+ scr_str_release(b1);
719
+ return out;
720
+ }
721
+ case SCR_DYN_FUNC: {
722
+ /* Node's function rendering: [Function: name] / [Function
723
+ * (anonymous)]. The boxed name is the compiler's best-effort static
724
+ * spelling (SEMANTICS.md — reference-site naming). */
725
+ const char *name = d->v.fn.name;
726
+ InspBuf out = {0};
727
+ if (name && name[0]) {
728
+ ib_cstr(&out, "[Function: ");
729
+ ib_cstr(&out, name);
730
+ ib_char(&out, ']');
731
+ } else {
732
+ ib_cstr(&out, "[Function (anonymous)]");
733
+ }
734
+ return ib_take(&out);
735
+ }
736
+ case SCR_DYN_HANDLE: {
737
+ /* Node prints the class's full property dump (ServerResponse {
738
+ * ... }) — internals we do not model. Fence loudly instead of a
739
+ * silent-wrong shape (SEMANTICS.md). */
740
+ InspBuf out = {0};
741
+ ib_cstr(&out, "util.inspect of a dynamic ");
742
+ ib_cstr(&out, scr_dyn_handle_cls(d));
743
+ ib_cstr(&out, " is not supported yet");
744
+ scr_throw_error(SCR_ERR_ERROR, ib_take(&out));
745
+ return scr_str_new("", 0);
746
+ }
747
+ case SCR_DYN_PROMISE: {
748
+ /* Node renders Promise { <pending> } / Promise { value } — the
749
+ * settled-value rendering pulls in the whole inspector; fence
750
+ * loudly instead of a silent-wrong shape (the handle stance). */
751
+ InspBuf out = {0};
752
+ ib_cstr(&out, "util.inspect of a promise value is not supported yet");
753
+ scr_throw_error(SCR_ERR_ERROR, ib_take(&out));
754
+ return scr_str_new("", 0);
755
+ }
756
+ case SCR_DYN_BYTES: {
757
+ ScrBytes *b = d->v.bytes;
758
+ if (d->buffer) {
759
+ /* Buffer-flavored (a stream chunk): Node's <Buffer ..> form. */
760
+ return scr_insp_buffer(b);
761
+ }
762
+ char prefix[48];
763
+ int pn = snprintf(prefix, sizeof prefix, "Uint8Array(%zu) [", b->len);
764
+ if (b->len == 0) {
765
+ InspBuf out = {0};
766
+ ib_bytes(&out, prefix, (size_t)pn);
767
+ ib_char(&out, ']');
768
+ return ib_take(&out);
769
+ }
770
+ if (recurse > depth) return scr_str_new("[Uint8Array]", 12);
771
+ scr_insp_begin(recurse + 1);
772
+ size_t shown = b->len < 100 ? b->len : 100;
773
+ for (size_t i = 0; i < shown; i++) {
774
+ ScrStr *s = scr_insp_f64((double)((const unsigned char *)b->data)[i]);
775
+ scr_insp_entry(s, true);
776
+ scr_str_release(s);
777
+ }
778
+ bool more = b->len > 100;
779
+ if (more) {
780
+ ScrStr *m = scr_insp_more_items((double)(b->len - 100));
781
+ scr_insp_entry(m, true);
782
+ scr_str_release(m);
783
+ }
784
+ ScrStr *base = scr_str_new("", 0);
785
+ ScrStr *b0 = scr_str_new(prefix, (size_t)pn);
786
+ ScrStr *b1 = scr_str_new("]", 1);
787
+ ScrStr *out = scr_insp_end(base, b0, b1, recurse + 1, true, more);
788
+ scr_str_release(base);
789
+ scr_str_release(b0);
790
+ scr_str_release(b1);
791
+ return out;
792
+ }
793
+ }
794
+ return scr_str_new("undefined", 9); /* unreachable */
795
+ }
796
+
797
+ /* util.format's %s over a dyn value: strings pass VERBATIM (Node's
798
+ * `typeof arg === 'string' ? arg : inspect(arg)` — the %s depth is 0,
799
+ * the rest-args depth 2); everything else inspects at the given depth. */
800
+ ScrStr *scr_insp_dyn_s(ScrDyn *d, double depth) {
801
+ if (d->kind == SCR_DYN_STR) return scr_str_retain(d->v.str);
802
+ return scr_insp_dyn(d, 0, depth);
803
+ }