@scriptc/cli-darwin-x64 0.0.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (960) hide show
  1. package/dist/LICENSE +202 -0
  2. package/dist/THIRD_PARTY_NOTICES +4 -0
  3. package/dist/bin/scriptc +0 -0
  4. package/dist/bin/scriptc.json +21 -0
  5. package/dist/lib/declarations/scriptc-node-fallback.d.ts +3847 -0
  6. package/dist/lib/declarations/scriptc-overrides.d.ts +92 -0
  7. package/dist/lib/declarations/scriptc.d.ts +98 -0
  8. package/dist/lib/llvm/LICENSE +1 -0
  9. package/dist/lib/llvm/SCRIPTC_LICENSE +1 -0
  10. package/dist/lib/llvm/THIRD_PARTY_NOTICES +1 -0
  11. package/dist/lib/llvm/bin/scriptc-llvm-codegen +0 -0
  12. package/dist/lib/llvm/package.json +35 -0
  13. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_array.o +0 -0
  14. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_assert.o +0 -0
  15. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_async.o +0 -0
  16. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_async_dyn.o +0 -0
  17. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bigint.o +0 -0
  18. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bigint_assert.o +0 -0
  19. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bytes.o +0 -0
  20. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bytes_io.o +0 -0
  21. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_child.o +0 -0
  22. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_closure.o +0 -0
  23. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_console.o +0 -0
  24. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_console_native.o +0 -0
  25. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_copying.o +0 -0
  26. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_crypto_async.o +0 -0
  27. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_cycle.o +0 -0
  28. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_dc.o +0 -0
  29. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_dgram.o +0 -0
  30. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_dyn_handle.o +0 -0
  31. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_dyn_invoke.o +0 -0
  32. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_error.o +0 -0
  33. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_events.o +0 -0
  34. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_events_emitter.o +0 -0
  35. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_exception.o +0 -0
  36. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_fetch.o +0 -0
  37. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_ffi.o +0 -0
  38. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_ffi_queue.o +0 -0
  39. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_file_handle.o +0 -0
  40. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_grapheme.o +0 -0
  41. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_http.o +0 -0
  42. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_http2.o +0 -0
  43. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_inspect.o +0 -0
  44. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_json.o +0 -0
  45. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_lib.o +0 -0
  46. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_loop_epoll.o +0 -0
  47. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_loop_kqueue.o +0 -0
  48. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_loop_wsapoll.o +0 -0
  49. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_map.o +0 -0
  50. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_net.o +0 -0
  51. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_node_builtin.o +0 -0
  52. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_number.o +0 -0
  53. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_object.o +0 -0
  54. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_path.o +0 -0
  55. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_qs.o +0 -0
  56. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_readline.o +0 -0
  57. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_regex.o +0 -0
  58. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_stream.o +0 -0
  59. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_string.o +0 -0
  60. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_symbol.o +0 -0
  61. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_test.o +0 -0
  62. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_tls.o +0 -0
  63. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_tls_ca.o +0 -0
  64. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_union.o +0 -0
  65. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_url.o +0 -0
  66. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_url_params.o +0 -0
  67. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_util.o +0 -0
  68. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_watch.o +0 -0
  69. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_zlib.o +0 -0
  70. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_array.o +0 -0
  71. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_assert.o +0 -0
  72. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_async.o +0 -0
  73. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_async_dyn.o +0 -0
  74. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bigint.o +0 -0
  75. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bigint_assert.o +0 -0
  76. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bytes.o +0 -0
  77. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bytes_io.o +0 -0
  78. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_child.o +0 -0
  79. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_closure.o +0 -0
  80. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_console.o +0 -0
  81. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_console_native.o +0 -0
  82. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_copying.o +0 -0
  83. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_crypto_async.o +0 -0
  84. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_cycle.o +0 -0
  85. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_dc.o +0 -0
  86. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_dgram.o +0 -0
  87. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_dyn_handle.o +0 -0
  88. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_dyn_invoke.o +0 -0
  89. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_error.o +0 -0
  90. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_events.o +0 -0
  91. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_events_emitter.o +0 -0
  92. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_exception.o +0 -0
  93. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_fetch.o +0 -0
  94. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_ffi.o +0 -0
  95. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_ffi_queue.o +0 -0
  96. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_file_handle.o +0 -0
  97. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_grapheme.o +0 -0
  98. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_http.o +0 -0
  99. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_http2.o +0 -0
  100. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_inspect.o +0 -0
  101. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_inspect_island.o +0 -0
  102. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_island.o +0 -0
  103. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_json.o +0 -0
  104. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_lib.o +0 -0
  105. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_loop_epoll.o +0 -0
  106. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_loop_kqueue.o +0 -0
  107. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_loop_wsapoll.o +0 -0
  108. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_map.o +0 -0
  109. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_net.o +0 -0
  110. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_net_island.o +0 -0
  111. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_node_builtin.o +0 -0
  112. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_number.o +0 -0
  113. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_object.o +0 -0
  114. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_path.o +0 -0
  115. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_qs.o +0 -0
  116. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_readline.o +0 -0
  117. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_regex.o +0 -0
  118. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_stream.o +0 -0
  119. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_string.o +0 -0
  120. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_symbol.o +0 -0
  121. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_test.o +0 -0
  122. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_tls.o +0 -0
  123. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_tls_ca.o +0 -0
  124. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_union.o +0 -0
  125. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_url.o +0 -0
  126. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_url_params.o +0 -0
  127. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_util.o +0 -0
  128. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_watch.o +0 -0
  129. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_web.o +0 -0
  130. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_zlib.o +0 -0
  131. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_zlib_island.o +0 -0
  132. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
  133. package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  134. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_array.o +0 -0
  135. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_assert.o +0 -0
  136. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bigint.o +0 -0
  137. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bigint_assert.o +0 -0
  138. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bytes.o +0 -0
  139. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bytes_io.o +0 -0
  140. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_closure.o +0 -0
  141. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_console.o +0 -0
  142. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_console_native.o +0 -0
  143. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_copying.o +0 -0
  144. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_cycle.o +0 -0
  145. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_dyn_handle.o +0 -0
  146. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_dyn_invoke.o +0 -0
  147. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_error.o +0 -0
  148. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_events_emitter.o +0 -0
  149. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_exception.o +0 -0
  150. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_grapheme.o +0 -0
  151. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_inspect.o +0 -0
  152. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_json.o +0 -0
  153. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_lib.o +0 -0
  154. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_library.o +0 -0
  155. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_map.o +0 -0
  156. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_node_builtin.o +0 -0
  157. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_number.o +0 -0
  158. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_object.o +0 -0
  159. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_path.o +0 -0
  160. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_regex.o +0 -0
  161. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_string.o +0 -0
  162. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_symbol.o +0 -0
  163. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_union.o +0 -0
  164. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_url.o +0 -0
  165. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_url_params.o +0 -0
  166. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_zlib.o +0 -0
  167. package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  168. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_array.o +0 -0
  169. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_assert.o +0 -0
  170. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bigint.o +0 -0
  171. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bigint_assert.o +0 -0
  172. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bytes.o +0 -0
  173. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bytes_io.o +0 -0
  174. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_closure.o +0 -0
  175. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_console.o +0 -0
  176. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_console_native.o +0 -0
  177. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_copying.o +0 -0
  178. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_cycle.o +0 -0
  179. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_dyn_handle.o +0 -0
  180. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_dyn_invoke.o +0 -0
  181. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_error.o +0 -0
  182. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_events_emitter.o +0 -0
  183. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_exception.o +0 -0
  184. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_grapheme.o +0 -0
  185. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_inspect.o +0 -0
  186. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_json.o +0 -0
  187. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_lib.o +0 -0
  188. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_library.o +0 -0
  189. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_map.o +0 -0
  190. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_node_builtin.o +0 -0
  191. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_number.o +0 -0
  192. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_object.o +0 -0
  193. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_path.o +0 -0
  194. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_regex.o +0 -0
  195. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_string.o +0 -0
  196. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_symbol.o +0 -0
  197. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_union.o +0 -0
  198. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_url.o +0 -0
  199. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_url_params.o +0 -0
  200. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_zlib.o +0 -0
  201. package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  202. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_array.o +0 -0
  203. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_assert.o +0 -0
  204. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bigint.o +0 -0
  205. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bigint_assert.o +0 -0
  206. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bytes.o +0 -0
  207. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bytes_io.o +0 -0
  208. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_closure.o +0 -0
  209. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_console.o +0 -0
  210. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_console_native.o +0 -0
  211. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_copying.o +0 -0
  212. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_cycle.o +0 -0
  213. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_dyn_handle.o +0 -0
  214. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_dyn_invoke.o +0 -0
  215. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_error.o +0 -0
  216. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_events_emitter.o +0 -0
  217. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_exception.o +0 -0
  218. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_grapheme.o +0 -0
  219. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_inspect.o +0 -0
  220. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_json.o +0 -0
  221. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_lib.o +0 -0
  222. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_library.o +0 -0
  223. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_map.o +0 -0
  224. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_node_builtin.o +0 -0
  225. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_number.o +0 -0
  226. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_object.o +0 -0
  227. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_path.o +0 -0
  228. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_regex.o +0 -0
  229. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_string.o +0 -0
  230. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_symbol.o +0 -0
  231. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_union.o +0 -0
  232. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_url.o +0 -0
  233. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_url_params.o +0 -0
  234. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_zlib.o +0 -0
  235. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  236. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_array.o +0 -0
  237. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_assert.o +0 -0
  238. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bigint.o +0 -0
  239. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bigint_assert.o +0 -0
  240. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bytes.o +0 -0
  241. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bytes_io.o +0 -0
  242. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_closure.o +0 -0
  243. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_console.o +0 -0
  244. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_console_native.o +0 -0
  245. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_copying.o +0 -0
  246. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_cycle.o +0 -0
  247. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_dyn_handle.o +0 -0
  248. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_dyn_invoke.o +0 -0
  249. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_error.o +0 -0
  250. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_events_emitter.o +0 -0
  251. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_exception.o +0 -0
  252. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_grapheme.o +0 -0
  253. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_inspect.o +0 -0
  254. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_json.o +0 -0
  255. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_lib.o +0 -0
  256. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_library.o +0 -0
  257. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_map.o +0 -0
  258. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_node_builtin.o +0 -0
  259. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_number.o +0 -0
  260. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_object.o +0 -0
  261. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_path.o +0 -0
  262. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_regex.o +0 -0
  263. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_string.o +0 -0
  264. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_symbol.o +0 -0
  265. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_union.o +0 -0
  266. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_url.o +0 -0
  267. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_url_params.o +0 -0
  268. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_zlib.o +0 -0
  269. package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  270. package/dist/lib/runtime-darwin-x64/artifacts/licenses/mbedtls.txt +553 -0
  271. package/dist/lib/runtime-darwin-x64/artifacts/licenses/quickjs-ng.txt +24 -0
  272. package/dist/lib/runtime-darwin-x64/artifacts/licenses/ryu.txt +23 -0
  273. package/dist/lib/runtime-darwin-x64/artifacts/licenses/scriptc-runtime.txt +202 -0
  274. package/dist/lib/runtime-darwin-x64/artifacts/licenses/unicode.txt +39 -0
  275. package/dist/lib/runtime-darwin-x64/artifacts/licenses/zlib.txt +22 -0
  276. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_array.o +0 -0
  277. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_assert.o +0 -0
  278. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_async.o +0 -0
  279. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_async_dyn.o +0 -0
  280. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bigint.o +0 -0
  281. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bigint_assert.o +0 -0
  282. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bytes.o +0 -0
  283. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bytes_io.o +0 -0
  284. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_child.o +0 -0
  285. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_closure.o +0 -0
  286. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_console.o +0 -0
  287. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_console_native.o +0 -0
  288. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_copying.o +0 -0
  289. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_crypto_async.o +0 -0
  290. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_cycle.o +0 -0
  291. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_dc.o +0 -0
  292. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_dgram.o +0 -0
  293. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_dyn_handle.o +0 -0
  294. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_dyn_invoke.o +0 -0
  295. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_error.o +0 -0
  296. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_events.o +0 -0
  297. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_events_emitter.o +0 -0
  298. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_exception.o +0 -0
  299. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_fetch.o +0 -0
  300. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_ffi.o +0 -0
  301. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_ffi_queue.o +0 -0
  302. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_file_handle.o +0 -0
  303. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_grapheme.o +0 -0
  304. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_http.o +0 -0
  305. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_http2.o +0 -0
  306. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_inspect.o +0 -0
  307. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_json.o +0 -0
  308. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_lib.o +0 -0
  309. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_loop_epoll.o +0 -0
  310. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_loop_kqueue.o +0 -0
  311. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_loop_wsapoll.o +0 -0
  312. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_map.o +0 -0
  313. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_net.o +0 -0
  314. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_node_builtin.o +0 -0
  315. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_number.o +0 -0
  316. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_object.o +0 -0
  317. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_path.o +0 -0
  318. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_qs.o +0 -0
  319. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_readline.o +0 -0
  320. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_regex.o +0 -0
  321. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_stream.o +0 -0
  322. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_string.o +0 -0
  323. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_symbol.o +0 -0
  324. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_test.o +0 -0
  325. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_tls.o +0 -0
  326. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_tls_ca.o +0 -0
  327. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_union.o +0 -0
  328. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_url.o +0 -0
  329. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_url_params.o +0 -0
  330. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_util.o +0 -0
  331. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_watch.o +0 -0
  332. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_zlib.o +0 -0
  333. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_array.o +0 -0
  334. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_assert.o +0 -0
  335. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_async.o +0 -0
  336. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_async_dyn.o +0 -0
  337. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bigint.o +0 -0
  338. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bigint_assert.o +0 -0
  339. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bytes.o +0 -0
  340. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bytes_io.o +0 -0
  341. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_child.o +0 -0
  342. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_closure.o +0 -0
  343. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_console.o +0 -0
  344. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_console_native.o +0 -0
  345. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_copying.o +0 -0
  346. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_crypto_async.o +0 -0
  347. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_cycle.o +0 -0
  348. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_dc.o +0 -0
  349. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_dgram.o +0 -0
  350. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_dyn_handle.o +0 -0
  351. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_dyn_invoke.o +0 -0
  352. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_error.o +0 -0
  353. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_events.o +0 -0
  354. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_events_emitter.o +0 -0
  355. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_exception.o +0 -0
  356. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_fetch.o +0 -0
  357. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_ffi.o +0 -0
  358. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_ffi_queue.o +0 -0
  359. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_file_handle.o +0 -0
  360. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_grapheme.o +0 -0
  361. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_http.o +0 -0
  362. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_http2.o +0 -0
  363. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_inspect.o +0 -0
  364. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_inspect_island.o +0 -0
  365. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_island.o +0 -0
  366. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_json.o +0 -0
  367. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_lib.o +0 -0
  368. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_loop_epoll.o +0 -0
  369. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_loop_kqueue.o +0 -0
  370. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_loop_wsapoll.o +0 -0
  371. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_map.o +0 -0
  372. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_net.o +0 -0
  373. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_net_island.o +0 -0
  374. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_node_builtin.o +0 -0
  375. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_number.o +0 -0
  376. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_object.o +0 -0
  377. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_path.o +0 -0
  378. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_qs.o +0 -0
  379. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_readline.o +0 -0
  380. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_regex.o +0 -0
  381. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_stream.o +0 -0
  382. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_string.o +0 -0
  383. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_symbol.o +0 -0
  384. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_test.o +0 -0
  385. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_tls.o +0 -0
  386. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_tls_ca.o +0 -0
  387. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_union.o +0 -0
  388. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_url.o +0 -0
  389. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_url_params.o +0 -0
  390. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_util.o +0 -0
  391. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_watch.o +0 -0
  392. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_web.o +0 -0
  393. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_zlib.o +0 -0
  394. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_zlib_island.o +0 -0
  395. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
  396. package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  397. package/dist/lib/runtime-darwin-x64/artifacts/vendor/libregexp/libscriptc-libregexp.a +0 -0
  398. package/dist/lib/runtime-darwin-x64/artifacts/vendor/mbedtls/libscriptc-mbedtls.a +0 -0
  399. package/dist/lib/runtime-darwin-x64/artifacts/vendor/quickjs/libscriptc-quickjs.a +0 -0
  400. package/dist/lib/runtime-darwin-x64/artifacts/vendor/zlib/libscriptc-zlib.a +0 -0
  401. package/dist/lib/runtime-darwin-x64/package.json +24 -0
  402. package/dist/lib/runtime-darwin-x64/runtime-pack.json +5758 -0
  403. package/dist/lib/runtime-sources/LICENSE +202 -0
  404. package/dist/lib/runtime-sources/package.json +22 -0
  405. package/dist/lib/runtime-sources/src/scr_array.c +1444 -0
  406. package/dist/lib/runtime-sources/src/scr_assert.c +1537 -0
  407. package/dist/lib/runtime-sources/src/scr_async.c +3920 -0
  408. package/dist/lib/runtime-sources/src/scr_async.test.c +134 -0
  409. package/dist/lib/runtime-sources/src/scr_async.test.ts +34 -0
  410. package/dist/lib/runtime-sources/src/scr_async_dyn.c +803 -0
  411. package/dist/lib/runtime-sources/src/scr_bigint.c +890 -0
  412. package/dist/lib/runtime-sources/src/scr_bigint_assert.c +22 -0
  413. package/dist/lib/runtime-sources/src/scr_bytes.c +2518 -0
  414. package/dist/lib/runtime-sources/src/scr_bytes_io.c +755 -0
  415. package/dist/lib/runtime-sources/src/scr_child.c +5808 -0
  416. package/dist/lib/runtime-sources/src/scr_closure.c +213 -0
  417. package/dist/lib/runtime-sources/src/scr_console.c +259 -0
  418. package/dist/lib/runtime-sources/src/scr_console_native.c +95 -0
  419. package/dist/lib/runtime-sources/src/scr_copying.c +146 -0
  420. package/dist/lib/runtime-sources/src/scr_crypto_async.c +24 -0
  421. package/dist/lib/runtime-sources/src/scr_cycle.c +565 -0
  422. package/dist/lib/runtime-sources/src/scr_dc.c +814 -0
  423. package/dist/lib/runtime-sources/src/scr_dgram.c +1182 -0
  424. package/dist/lib/runtime-sources/src/scr_dyn_handle.c +96 -0
  425. package/dist/lib/runtime-sources/src/scr_dyn_invoke.c +1626 -0
  426. package/dist/lib/runtime-sources/src/scr_error.c +372 -0
  427. package/dist/lib/runtime-sources/src/scr_events.c +1222 -0
  428. package/dist/lib/runtime-sources/src/scr_events_emitter.c +842 -0
  429. package/dist/lib/runtime-sources/src/scr_exception.c +468 -0
  430. package/dist/lib/runtime-sources/src/scr_fetch.c +7215 -0
  431. package/dist/lib/runtime-sources/src/scr_fetch_curl.c +666 -0
  432. package/dist/lib/runtime-sources/src/scr_ffi.c +143 -0
  433. package/dist/lib/runtime-sources/src/scr_ffi_queue.c +379 -0
  434. package/dist/lib/runtime-sources/src/scr_file_handle.c +562 -0
  435. package/dist/lib/runtime-sources/src/scr_grapheme.c +203 -0
  436. package/dist/lib/runtime-sources/src/scr_grapheme_data.h +842 -0
  437. package/dist/lib/runtime-sources/src/scr_http.c +5808 -0
  438. package/dist/lib/runtime-sources/src/scr_http2.c +3243 -0
  439. package/dist/lib/runtime-sources/src/scr_inspect.c +923 -0
  440. package/dist/lib/runtime-sources/src/scr_inspect_island.c +51 -0
  441. package/dist/lib/runtime-sources/src/scr_island.c +9987 -0
  442. package/dist/lib/runtime-sources/src/scr_island_manifest.h +153 -0
  443. package/dist/lib/runtime-sources/src/scr_json.c +7928 -0
  444. package/dist/lib/runtime-sources/src/scr_json.test.c +182 -0
  445. package/dist/lib/runtime-sources/src/scr_json.test.ts +33 -0
  446. package/dist/lib/runtime-sources/src/scr_lib.c +6304 -0
  447. package/dist/lib/runtime-sources/src/scr_library.c +444 -0
  448. package/dist/lib/runtime-sources/src/scr_loop_epoll.c +241 -0
  449. package/dist/lib/runtime-sources/src/scr_loop_kqueue.c +121 -0
  450. package/dist/lib/runtime-sources/src/scr_loop_wsapoll.c +208 -0
  451. package/dist/lib/runtime-sources/src/scr_map.c +705 -0
  452. package/dist/lib/runtime-sources/src/scr_musl.c +438 -0
  453. package/dist/lib/runtime-sources/src/scr_net.c +3708 -0
  454. package/dist/lib/runtime-sources/src/scr_net_island.c +458 -0
  455. package/dist/lib/runtime-sources/src/scr_node_builtin.c +281 -0
  456. package/dist/lib/runtime-sources/src/scr_number.c +192 -0
  457. package/dist/lib/runtime-sources/src/scr_object.c +80 -0
  458. package/dist/lib/runtime-sources/src/scr_path.c +1281 -0
  459. package/dist/lib/runtime-sources/src/scr_platform.h +119 -0
  460. package/dist/lib/runtime-sources/src/scr_qs.c +496 -0
  461. package/dist/lib/runtime-sources/src/scr_readline.c +288 -0
  462. package/dist/lib/runtime-sources/src/scr_regex.c +1274 -0
  463. package/dist/lib/runtime-sources/src/scr_runtime.h +7207 -0
  464. package/dist/lib/runtime-sources/src/scr_stream.c +3149 -0
  465. package/dist/lib/runtime-sources/src/scr_string.c +1849 -0
  466. package/dist/lib/runtime-sources/src/scr_symbol.c +234 -0
  467. package/dist/lib/runtime-sources/src/scr_test.c +662 -0
  468. package/dist/lib/runtime-sources/src/scr_text_decoder_data.h +7389 -0
  469. package/dist/lib/runtime-sources/src/scr_tls.c +1806 -0
  470. package/dist/lib/runtime-sources/src/scr_tls_ca.c +433 -0
  471. package/dist/lib/runtime-sources/src/scr_union.c +105 -0
  472. package/dist/lib/runtime-sources/src/scr_url.c +1231 -0
  473. package/dist/lib/runtime-sources/src/scr_url_internal.h +29 -0
  474. package/dist/lib/runtime-sources/src/scr_url_params.c +526 -0
  475. package/dist/lib/runtime-sources/src/scr_util.c +984 -0
  476. package/dist/lib/runtime-sources/src/scr_watch.c +568 -0
  477. package/dist/lib/runtime-sources/src/scr_web.c +1854 -0
  478. package/dist/lib/runtime-sources/src/scr_win.c +231 -0
  479. package/dist/lib/runtime-sources/src/scr_win_stats.h +23 -0
  480. package/dist/lib/runtime-sources/src/scr_zlib.c +358 -0
  481. package/dist/lib/runtime-sources/src/scr_zlib_island.c +15 -0
  482. package/dist/lib/runtime-sources/vendor/README.md +60 -0
  483. package/dist/lib/runtime-sources/vendor/curl/COPYRIGHT +534 -0
  484. package/dist/lib/runtime-sources/vendor/curl/include/curl/curl.h +3214 -0
  485. package/dist/lib/runtime-sources/vendor/curl/include/curl/curlver.h +79 -0
  486. package/dist/lib/runtime-sources/vendor/curl/include/curl/easy.h +125 -0
  487. package/dist/lib/runtime-sources/vendor/curl/include/curl/header.h +74 -0
  488. package/dist/lib/runtime-sources/vendor/curl/include/curl/mprintf.h +52 -0
  489. package/dist/lib/runtime-sources/vendor/curl/include/curl/multi.h +460 -0
  490. package/dist/lib/runtime-sources/vendor/curl/include/curl/options.h +70 -0
  491. package/dist/lib/runtime-sources/vendor/curl/include/curl/stdcheaders.h +35 -0
  492. package/dist/lib/runtime-sources/vendor/curl/include/curl/system.h +508 -0
  493. package/dist/lib/runtime-sources/vendor/curl/include/curl/typecheck-gcc.h +716 -0
  494. package/dist/lib/runtime-sources/vendor/curl/include/curl/urlapi.h +149 -0
  495. package/dist/lib/runtime-sources/vendor/curl/include/curl/websockets.h +84 -0
  496. package/dist/lib/runtime-sources/vendor/mbedtls/LICENSE +553 -0
  497. package/dist/lib/runtime-sources/vendor/mbedtls/include/CMakeLists.txt +22 -0
  498. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/aes.h +631 -0
  499. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/aria.h +343 -0
  500. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/asn1.h +642 -0
  501. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/asn1write.h +390 -0
  502. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/base64.h +82 -0
  503. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/bignum.h +1088 -0
  504. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/block_cipher.h +76 -0
  505. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/build_info.h +194 -0
  506. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/camellia.h +305 -0
  507. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ccm.h +526 -0
  508. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/chacha20.h +209 -0
  509. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/chachapoly.h +351 -0
  510. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/check_config.h +1149 -0
  511. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/cipher.h +1250 -0
  512. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/cmac.h +246 -0
  513. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/compat-2.x.h +46 -0
  514. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_legacy_crypto.h +578 -0
  515. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_legacy_from_psa.h +873 -0
  516. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_psa_from_legacy.h +359 -0
  517. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_psa_superset_legacy.h +145 -0
  518. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_ssl.h +91 -0
  519. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_adjust_x509.h +35 -0
  520. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/config_psa.h +61 -0
  521. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/constant_time.h +36 -0
  522. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ctr_drbg.h +596 -0
  523. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/debug.h +156 -0
  524. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/des.h +385 -0
  525. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/dhm.h +972 -0
  526. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ecdh.h +455 -0
  527. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ecdsa.h +674 -0
  528. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ecjpake.h +298 -0
  529. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ecp.h +1517 -0
  530. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/entropy.h +274 -0
  531. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/error.h +201 -0
  532. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/gcm.h +387 -0
  533. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/hkdf.h +124 -0
  534. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/hmac_drbg.h +434 -0
  535. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/lms.h +440 -0
  536. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/mbedtls_config.h +4446 -0
  537. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/md.h +526 -0
  538. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/md5.h +190 -0
  539. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/memory_buffer_alloc.h +142 -0
  540. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/net_sockets.h +299 -0
  541. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/nist_kw.h +166 -0
  542. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/oid.h +727 -0
  543. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/pem.h +160 -0
  544. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/pk.h +1303 -0
  545. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/pkcs12.h +186 -0
  546. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/pkcs5.h +198 -0
  547. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/pkcs7.h +252 -0
  548. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/platform.h +516 -0
  549. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/platform_time.h +79 -0
  550. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/platform_util.h +247 -0
  551. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/poly1305.h +168 -0
  552. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/private_access.h +20 -0
  553. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/psa_util.h +207 -0
  554. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ripemd160.h +136 -0
  555. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/rsa.h +1170 -0
  556. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/sha1.h +219 -0
  557. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/sha256.h +200 -0
  558. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/sha3.h +172 -0
  559. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/sha512.h +208 -0
  560. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ssl.h +5887 -0
  561. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ssl_cache.h +187 -0
  562. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ssl_ciphersuites.h +482 -0
  563. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ssl_cookie.h +106 -0
  564. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/ssl_ticket.h +199 -0
  565. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/threading.h +167 -0
  566. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/timing.h +94 -0
  567. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/version.h +78 -0
  568. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/x509.h +500 -0
  569. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/x509_crl.h +184 -0
  570. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/x509_crt.h +1208 -0
  571. package/dist/lib/runtime-sources/vendor/mbedtls/include/mbedtls/x509_csr.h +382 -0
  572. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/build_info.h +20 -0
  573. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto.h +4998 -0
  574. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_adjust_auto_enabled.h +31 -0
  575. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_adjust_config_dependencies.h +51 -0
  576. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_adjust_config_key_pair_types.h +101 -0
  577. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_adjust_config_synonyms.h +49 -0
  578. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_builtin_composites.h +214 -0
  579. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_builtin_key_derivation.h +118 -0
  580. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_builtin_primitives.h +114 -0
  581. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_compat.h +230 -0
  582. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_config.h +145 -0
  583. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_driver_common.h +44 -0
  584. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_driver_contexts_composites.h +151 -0
  585. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_driver_contexts_key_derivation.h +52 -0
  586. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_driver_contexts_primitives.h +105 -0
  587. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_extra.h +2145 -0
  588. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_legacy.h +88 -0
  589. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_platform.h +102 -0
  590. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_se_driver.h +1383 -0
  591. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_sizes.h +1319 -0
  592. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_struct.h +527 -0
  593. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_types.h +508 -0
  594. package/dist/lib/runtime-sources/vendor/mbedtls/include/psa/crypto_values.h +2782 -0
  595. package/dist/lib/runtime-sources/vendor/mbedtls/library/aes.c +2294 -0
  596. package/dist/lib/runtime-sources/vendor/mbedtls/library/aesce.c +624 -0
  597. package/dist/lib/runtime-sources/vendor/mbedtls/library/aesce.h +136 -0
  598. package/dist/lib/runtime-sources/vendor/mbedtls/library/aesni.c +846 -0
  599. package/dist/lib/runtime-sources/vendor/mbedtls/library/aesni.h +162 -0
  600. package/dist/lib/runtime-sources/vendor/mbedtls/library/alignment.h +704 -0
  601. package/dist/lib/runtime-sources/vendor/mbedtls/library/aria.c +969 -0
  602. package/dist/lib/runtime-sources/vendor/mbedtls/library/asn1parse.c +468 -0
  603. package/dist/lib/runtime-sources/vendor/mbedtls/library/asn1write.c +440 -0
  604. package/dist/lib/runtime-sources/vendor/mbedtls/library/base64.c +322 -0
  605. package/dist/lib/runtime-sources/vendor/mbedtls/library/base64_internal.h +45 -0
  606. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum.c +2583 -0
  607. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_core.c +1240 -0
  608. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_core.h +872 -0
  609. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_core_invasive.h +38 -0
  610. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_internal.h +122 -0
  611. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_mod.c +394 -0
  612. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_mod.h +452 -0
  613. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_mod_raw.c +276 -0
  614. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_mod_raw.h +416 -0
  615. package/dist/lib/runtime-sources/vendor/mbedtls/library/bignum_mod_raw_invasive.h +34 -0
  616. package/dist/lib/runtime-sources/vendor/mbedtls/library/block_cipher.c +207 -0
  617. package/dist/lib/runtime-sources/vendor/mbedtls/library/block_cipher_internal.h +99 -0
  618. package/dist/lib/runtime-sources/vendor/mbedtls/library/bn_mul.h +1094 -0
  619. package/dist/lib/runtime-sources/vendor/mbedtls/library/camellia.c +1058 -0
  620. package/dist/lib/runtime-sources/vendor/mbedtls/library/ccm.c +777 -0
  621. package/dist/lib/runtime-sources/vendor/mbedtls/library/chacha20.c +563 -0
  622. package/dist/lib/runtime-sources/vendor/mbedtls/library/chacha20_internal.h +23 -0
  623. package/dist/lib/runtime-sources/vendor/mbedtls/library/chachapoly.c +487 -0
  624. package/dist/lib/runtime-sources/vendor/mbedtls/library/check_crypto_config.h +136 -0
  625. package/dist/lib/runtime-sources/vendor/mbedtls/library/cipher.c +1712 -0
  626. package/dist/lib/runtime-sources/vendor/mbedtls/library/cipher_invasive.h +28 -0
  627. package/dist/lib/runtime-sources/vendor/mbedtls/library/cipher_wrap.c +2482 -0
  628. package/dist/lib/runtime-sources/vendor/mbedtls/library/cipher_wrap.h +178 -0
  629. package/dist/lib/runtime-sources/vendor/mbedtls/library/cmac.c +1067 -0
  630. package/dist/lib/runtime-sources/vendor/mbedtls/library/common.h +487 -0
  631. package/dist/lib/runtime-sources/vendor/mbedtls/library/constant_time.c +247 -0
  632. package/dist/lib/runtime-sources/vendor/mbedtls/library/constant_time_impl.h +541 -0
  633. package/dist/lib/runtime-sources/vendor/mbedtls/library/constant_time_internal.h +579 -0
  634. package/dist/lib/runtime-sources/vendor/mbedtls/library/ctr.h +35 -0
  635. package/dist/lib/runtime-sources/vendor/mbedtls/library/ctr_drbg.c +1016 -0
  636. package/dist/lib/runtime-sources/vendor/mbedtls/library/debug.c +475 -0
  637. package/dist/lib/runtime-sources/vendor/mbedtls/library/debug_internal.h +185 -0
  638. package/dist/lib/runtime-sources/vendor/mbedtls/library/des.c +1042 -0
  639. package/dist/lib/runtime-sources/vendor/mbedtls/library/dhm.c +700 -0
  640. package/dist/lib/runtime-sources/vendor/mbedtls/library/ecdh.c +696 -0
  641. package/dist/lib/runtime-sources/vendor/mbedtls/library/ecdsa.c +858 -0
  642. package/dist/lib/runtime-sources/vendor/mbedtls/library/ecjpake.c +1216 -0
  643. package/dist/lib/runtime-sources/vendor/mbedtls/library/ecp.c +3674 -0
  644. package/dist/lib/runtime-sources/vendor/mbedtls/library/ecp_curves.c +6125 -0
  645. package/dist/lib/runtime-sources/vendor/mbedtls/library/ecp_curves_new.c +9 -0
  646. package/dist/lib/runtime-sources/vendor/mbedtls/library/ecp_internal_alt.h +287 -0
  647. package/dist/lib/runtime-sources/vendor/mbedtls/library/ecp_invasive.h +305 -0
  648. package/dist/lib/runtime-sources/vendor/mbedtls/library/entropy.c +680 -0
  649. package/dist/lib/runtime-sources/vendor/mbedtls/library/entropy_poll.c +233 -0
  650. package/dist/lib/runtime-sources/vendor/mbedtls/library/entropy_poll.h +64 -0
  651. package/dist/lib/runtime-sources/vendor/mbedtls/library/error.c +878 -0
  652. package/dist/lib/runtime-sources/vendor/mbedtls/library/gcm.c +1330 -0
  653. package/dist/lib/runtime-sources/vendor/mbedtls/library/hkdf.c +161 -0
  654. package/dist/lib/runtime-sources/vendor/mbedtls/library/hmac_drbg.c +633 -0
  655. package/dist/lib/runtime-sources/vendor/mbedtls/library/lmots.c +789 -0
  656. package/dist/lib/runtime-sources/vendor/mbedtls/library/lmots.h +288 -0
  657. package/dist/lib/runtime-sources/vendor/mbedtls/library/lms.c +778 -0
  658. package/dist/lib/runtime-sources/vendor/mbedtls/library/md.c +1108 -0
  659. package/dist/lib/runtime-sources/vendor/mbedtls/library/md5.c +426 -0
  660. package/dist/lib/runtime-sources/vendor/mbedtls/library/md_psa.h +26 -0
  661. package/dist/lib/runtime-sources/vendor/mbedtls/library/md_wrap.h +46 -0
  662. package/dist/lib/runtime-sources/vendor/mbedtls/library/memory_buffer_alloc.c +751 -0
  663. package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_common.h +181 -0
  664. package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_error.h +89 -0
  665. package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_reader.c +538 -0
  666. package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_reader.h +366 -0
  667. package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_trace.c +112 -0
  668. package/dist/lib/runtime-sources/vendor/mbedtls/library/mps_trace.h +154 -0
  669. package/dist/lib/runtime-sources/vendor/mbedtls/library/net_sockets.c +694 -0
  670. package/dist/lib/runtime-sources/vendor/mbedtls/library/nist_kw.c +729 -0
  671. package/dist/lib/runtime-sources/vendor/mbedtls/library/oid.c +1166 -0
  672. package/dist/lib/runtime-sources/vendor/mbedtls/library/padlock.c +157 -0
  673. package/dist/lib/runtime-sources/vendor/mbedtls/library/padlock.h +111 -0
  674. package/dist/lib/runtime-sources/vendor/mbedtls/library/pem.c +554 -0
  675. package/dist/lib/runtime-sources/vendor/mbedtls/library/pk.c +1602 -0
  676. package/dist/lib/runtime-sources/vendor/mbedtls/library/pk_ecc.c +261 -0
  677. package/dist/lib/runtime-sources/vendor/mbedtls/library/pk_internal.h +241 -0
  678. package/dist/lib/runtime-sources/vendor/mbedtls/library/pk_wrap.c +1618 -0
  679. package/dist/lib/runtime-sources/vendor/mbedtls/library/pk_wrap.h +138 -0
  680. package/dist/lib/runtime-sources/vendor/mbedtls/library/pkcs12.c +437 -0
  681. package/dist/lib/runtime-sources/vendor/mbedtls/library/pkcs5.c +500 -0
  682. package/dist/lib/runtime-sources/vendor/mbedtls/library/pkcs7.c +787 -0
  683. package/dist/lib/runtime-sources/vendor/mbedtls/library/pkparse.c +1392 -0
  684. package/dist/lib/runtime-sources/vendor/mbedtls/library/pkwrite.c +631 -0
  685. package/dist/lib/runtime-sources/vendor/mbedtls/library/pkwrite.h +121 -0
  686. package/dist/lib/runtime-sources/vendor/mbedtls/library/platform.c +402 -0
  687. package/dist/lib/runtime-sources/vendor/mbedtls/library/platform_util.c +258 -0
  688. package/dist/lib/runtime-sources/vendor/mbedtls/library/poly1305.c +492 -0
  689. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto.c +9532 -0
  690. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_aead.c +646 -0
  691. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_aead.h +499 -0
  692. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_cipher.c +747 -0
  693. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_cipher.h +316 -0
  694. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_client.c +22 -0
  695. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_core.h +983 -0
  696. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_core_common.h +52 -0
  697. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_driver_wrappers.h +2896 -0
  698. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_driver_wrappers_no_static.c +256 -0
  699. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_driver_wrappers_no_static.h +31 -0
  700. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_ecp.c +594 -0
  701. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_ecp.h +267 -0
  702. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_ffdh.c +361 -0
  703. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_ffdh.h +131 -0
  704. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_hash.c +470 -0
  705. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_hash.h +211 -0
  706. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_invasive.h +92 -0
  707. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_its.h +131 -0
  708. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_mac.c +505 -0
  709. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_mac.h +264 -0
  710. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_pake.c +571 -0
  711. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_pake.h +159 -0
  712. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_random.c +181 -0
  713. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_random.h +72 -0
  714. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_random_impl.h +200 -0
  715. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_rsa.c +714 -0
  716. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_rsa.h +321 -0
  717. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_se.c +373 -0
  718. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_se.h +192 -0
  719. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_slot_management.c +1137 -0
  720. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_slot_management.h +344 -0
  721. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_storage.c +481 -0
  722. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_crypto_storage.h +392 -0
  723. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_its_file.c +254 -0
  724. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_util.c +614 -0
  725. package/dist/lib/runtime-sources/vendor/mbedtls/library/psa_util_internal.h +100 -0
  726. package/dist/lib/runtime-sources/vendor/mbedtls/library/ripemd160.c +490 -0
  727. package/dist/lib/runtime-sources/vendor/mbedtls/library/rsa.c +3121 -0
  728. package/dist/lib/runtime-sources/vendor/mbedtls/library/rsa_alt_helpers.c +455 -0
  729. package/dist/lib/runtime-sources/vendor/mbedtls/library/rsa_alt_helpers.h +209 -0
  730. package/dist/lib/runtime-sources/vendor/mbedtls/library/rsa_internal.h +188 -0
  731. package/dist/lib/runtime-sources/vendor/mbedtls/library/sha1.c +480 -0
  732. package/dist/lib/runtime-sources/vendor/mbedtls/library/sha256.c +983 -0
  733. package/dist/lib/runtime-sources/vendor/mbedtls/library/sha3.c +721 -0
  734. package/dist/lib/runtime-sources/vendor/mbedtls/library/sha512.c +1115 -0
  735. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_cache.c +410 -0
  736. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_ciphersuites.c +2050 -0
  737. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_ciphersuites_internal.h +154 -0
  738. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_client.c +1023 -0
  739. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_client.h +22 -0
  740. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_cookie.c +384 -0
  741. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_debug_helpers.h +85 -0
  742. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_debug_helpers_generated.c +251 -0
  743. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_misc.h +3198 -0
  744. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_msg.c +6619 -0
  745. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_ticket.c +556 -0
  746. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls.c +10234 -0
  747. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls12_client.c +3688 -0
  748. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls12_server.c +4311 -0
  749. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_client.c +3208 -0
  750. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_generic.c +1793 -0
  751. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_invasive.h +23 -0
  752. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_keys.c +1918 -0
  753. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_keys.h +668 -0
  754. package/dist/lib/runtime-sources/vendor/mbedtls/library/ssl_tls13_server.c +3624 -0
  755. package/dist/lib/runtime-sources/vendor/mbedtls/library/threading.c +193 -0
  756. package/dist/lib/runtime-sources/vendor/mbedtls/library/threading_internal.h +28 -0
  757. package/dist/lib/runtime-sources/vendor/mbedtls/library/timing.c +152 -0
  758. package/dist/lib/runtime-sources/vendor/mbedtls/library/version.c +32 -0
  759. package/dist/lib/runtime-sources/vendor/mbedtls/library/version_features.c +856 -0
  760. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509.c +1776 -0
  761. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509_create.c +570 -0
  762. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509_crl.c +708 -0
  763. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509_crt.c +3311 -0
  764. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509_csr.c +648 -0
  765. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509_internal.h +101 -0
  766. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509write.c +174 -0
  767. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509write_crt.c +688 -0
  768. package/dist/lib/runtime-sources/vendor/mbedtls/library/x509write_csr.c +336 -0
  769. package/dist/lib/runtime-sources/vendor/quickjs-ng/CMakeLists.txt +566 -0
  770. package/dist/lib/runtime-sources/vendor/quickjs-ng/LICENSE +24 -0
  771. package/dist/lib/runtime-sources/vendor/quickjs-ng/README.md +24 -0
  772. package/dist/lib/runtime-sources/vendor/quickjs-ng/api-test.c +1195 -0
  773. package/dist/lib/runtime-sources/vendor/quickjs-ng/builtin-array-fromasync.h +119 -0
  774. package/dist/lib/runtime-sources/vendor/quickjs-ng/builtin-iterator-zip-keyed.h +332 -0
  775. package/dist/lib/runtime-sources/vendor/quickjs-ng/builtin-iterator-zip.h +337 -0
  776. package/dist/lib/runtime-sources/vendor/quickjs-ng/cutils.h +1998 -0
  777. package/dist/lib/runtime-sources/vendor/quickjs-ng/dtoa.c +1619 -0
  778. package/dist/lib/runtime-sources/vendor/quickjs-ng/dtoa.h +87 -0
  779. package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/function_source.c +81 -0
  780. package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/hello.c +53 -0
  781. package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/hello_module.c +106 -0
  782. package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/repl.c +3036 -0
  783. package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/standalone.c +323 -0
  784. package/dist/lib/runtime-sources/vendor/quickjs-ng/gen/test_fib.c +81 -0
  785. package/dist/lib/runtime-sources/vendor/quickjs-ng/libregexp-opcode.h +73 -0
  786. package/dist/lib/runtime-sources/vendor/quickjs-ng/libregexp.c +3474 -0
  787. package/dist/lib/runtime-sources/vendor/quickjs-ng/libregexp.h +101 -0
  788. package/dist/lib/runtime-sources/vendor/quickjs-ng/libunicode-table.h +5173 -0
  789. package/dist/lib/runtime-sources/vendor/quickjs-ng/libunicode.c +2069 -0
  790. package/dist/lib/runtime-sources/vendor/quickjs-ng/libunicode.h +172 -0
  791. package/dist/lib/runtime-sources/vendor/quickjs-ng/list.h +107 -0
  792. package/dist/lib/runtime-sources/vendor/quickjs-ng/lre-test.c +52 -0
  793. package/dist/lib/runtime-sources/vendor/quickjs-ng/qjs.c +762 -0
  794. package/dist/lib/runtime-sources/vendor/quickjs-ng/qjsc.c +673 -0
  795. package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs-atom.h +280 -0
  796. package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs-c-atomics.h +54 -0
  797. package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs-libc.c +5037 -0
  798. package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs-libc.h +87 -0
  799. package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs-opcode.h +377 -0
  800. package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs.c +64041 -0
  801. package/dist/lib/runtime-sources/vendor/quickjs-ng/quickjs.h +1447 -0
  802. package/dist/lib/runtime-sources/vendor/quickjs-ng/run-test262.c +2374 -0
  803. package/dist/lib/runtime-sources/vendor/quickjs-ng/unicode_gen.c +3121 -0
  804. package/dist/lib/runtime-sources/vendor/quickjs-ng/unicode_gen_def.h +310 -0
  805. package/dist/lib/runtime-sources/vendor/ryu/LICENSE-Boost +23 -0
  806. package/dist/lib/runtime-sources/vendor/ryu/common.h +114 -0
  807. package/dist/lib/runtime-sources/vendor/ryu/d2s.c +509 -0
  808. package/dist/lib/runtime-sources/vendor/ryu/d2s_full_table.h +367 -0
  809. package/dist/lib/runtime-sources/vendor/ryu/d2s_intrinsics.h +357 -0
  810. package/dist/lib/runtime-sources/vendor/ryu/d2s_small_table.h +186 -0
  811. package/dist/lib/runtime-sources/vendor/ryu/digit_table.h +35 -0
  812. package/dist/lib/runtime-sources/vendor/ryu/ryu.h +46 -0
  813. package/dist/lib/runtime-sources/vendor/unicode/LICENSE +39 -0
  814. package/dist/lib/runtime-sources/vendor/zlib/LICENSE +22 -0
  815. package/dist/lib/runtime-sources/vendor/zlib/adler32.c +164 -0
  816. package/dist/lib/runtime-sources/vendor/zlib/compress.c +75 -0
  817. package/dist/lib/runtime-sources/vendor/zlib/crc32.c +1049 -0
  818. package/dist/lib/runtime-sources/vendor/zlib/crc32.h +9446 -0
  819. package/dist/lib/runtime-sources/vendor/zlib/deflate.c +2139 -0
  820. package/dist/lib/runtime-sources/vendor/zlib/deflate.h +377 -0
  821. package/dist/lib/runtime-sources/vendor/zlib/gzclose.c +23 -0
  822. package/dist/lib/runtime-sources/vendor/zlib/gzguts.h +214 -0
  823. package/dist/lib/runtime-sources/vendor/zlib/gzlib.c +582 -0
  824. package/dist/lib/runtime-sources/vendor/zlib/gzread.c +602 -0
  825. package/dist/lib/runtime-sources/vendor/zlib/gzwrite.c +631 -0
  826. package/dist/lib/runtime-sources/vendor/zlib/infback.c +628 -0
  827. package/dist/lib/runtime-sources/vendor/zlib/inffast.c +320 -0
  828. package/dist/lib/runtime-sources/vendor/zlib/inffast.h +11 -0
  829. package/dist/lib/runtime-sources/vendor/zlib/inffixed.h +94 -0
  830. package/dist/lib/runtime-sources/vendor/zlib/inflate.c +1526 -0
  831. package/dist/lib/runtime-sources/vendor/zlib/inflate.h +126 -0
  832. package/dist/lib/runtime-sources/vendor/zlib/inftrees.c +299 -0
  833. package/dist/lib/runtime-sources/vendor/zlib/inftrees.h +62 -0
  834. package/dist/lib/runtime-sources/vendor/zlib/trees.c +1117 -0
  835. package/dist/lib/runtime-sources/vendor/zlib/trees.h +128 -0
  836. package/dist/lib/runtime-sources/vendor/zlib/uncompr.c +85 -0
  837. package/dist/lib/runtime-sources/vendor/zlib/zconf.h +543 -0
  838. package/dist/lib/runtime-sources/vendor/zlib/zlib.h +1938 -0
  839. package/dist/lib/runtime-sources/vendor/zlib/zutil.c +299 -0
  840. package/dist/lib/runtime-sources/vendor/zlib/zutil.h +254 -0
  841. package/dist/lib/scriptc-comptime +0 -0
  842. package/dist/lib/typescript/LICENSE +55 -0
  843. package/dist/lib/typescript/NOTICE.txt +436 -0
  844. package/dist/lib/typescript/lib/lib.d.ts +20 -0
  845. package/dist/lib/typescript/lib/lib.decorators.d.ts +382 -0
  846. package/dist/lib/typescript/lib/lib.decorators.legacy.d.ts +20 -0
  847. package/dist/lib/typescript/lib/lib.dom.asynciterable.d.ts +18 -0
  848. package/dist/lib/typescript/lib/lib.dom.d.ts +45125 -0
  849. package/dist/lib/typescript/lib/lib.dom.iterable.d.ts +18 -0
  850. package/dist/lib/typescript/lib/lib.es2015.collection.d.ts +159 -0
  851. package/dist/lib/typescript/lib/lib.es2015.core.d.ts +595 -0
  852. package/dist/lib/typescript/lib/lib.es2015.d.ts +26 -0
  853. package/dist/lib/typescript/lib/lib.es2015.generator.d.ts +75 -0
  854. package/dist/lib/typescript/lib/lib.es2015.iterable.d.ts +603 -0
  855. package/dist/lib/typescript/lib/lib.es2015.promise.d.ts +79 -0
  856. package/dist/lib/typescript/lib/lib.es2015.proxy.d.ts +126 -0
  857. package/dist/lib/typescript/lib/lib.es2015.reflect.d.ts +142 -0
  858. package/dist/lib/typescript/lib/lib.es2015.symbol.d.ts +44 -0
  859. package/dist/lib/typescript/lib/lib.es2015.symbol.wellknown.d.ts +324 -0
  860. package/dist/lib/typescript/lib/lib.es2016.array.include.d.ts +114 -0
  861. package/dist/lib/typescript/lib/lib.es2016.d.ts +19 -0
  862. package/dist/lib/typescript/lib/lib.es2016.full.d.ts +21 -0
  863. package/dist/lib/typescript/lib/lib.es2016.intl.d.ts +29 -0
  864. package/dist/lib/typescript/lib/lib.es2017.arraybuffer.d.ts +19 -0
  865. package/dist/lib/typescript/lib/lib.es2017.d.ts +24 -0
  866. package/dist/lib/typescript/lib/lib.es2017.date.d.ts +29 -0
  867. package/dist/lib/typescript/lib/lib.es2017.full.d.ts +21 -0
  868. package/dist/lib/typescript/lib/lib.es2017.intl.d.ts +42 -0
  869. package/dist/lib/typescript/lib/lib.es2017.object.d.ts +47 -0
  870. package/dist/lib/typescript/lib/lib.es2017.sharedmemory.d.ts +133 -0
  871. package/dist/lib/typescript/lib/lib.es2017.string.d.ts +47 -0
  872. package/dist/lib/typescript/lib/lib.es2017.typedarrays.d.ts +51 -0
  873. package/dist/lib/typescript/lib/lib.es2018.asyncgenerator.d.ts +75 -0
  874. package/dist/lib/typescript/lib/lib.es2018.asynciterable.d.ts +51 -0
  875. package/dist/lib/typescript/lib/lib.es2018.d.ts +22 -0
  876. package/dist/lib/typescript/lib/lib.es2018.full.d.ts +22 -0
  877. package/dist/lib/typescript/lib/lib.es2018.intl.d.ts +81 -0
  878. package/dist/lib/typescript/lib/lib.es2018.promise.d.ts +28 -0
  879. package/dist/lib/typescript/lib/lib.es2018.regexp.d.ts +35 -0
  880. package/dist/lib/typescript/lib/lib.es2019.array.d.ts +77 -0
  881. package/dist/lib/typescript/lib/lib.es2019.d.ts +22 -0
  882. package/dist/lib/typescript/lib/lib.es2019.full.d.ts +22 -0
  883. package/dist/lib/typescript/lib/lib.es2019.intl.d.ts +21 -0
  884. package/dist/lib/typescript/lib/lib.es2019.object.d.ts +31 -0
  885. package/dist/lib/typescript/lib/lib.es2019.string.d.ts +35 -0
  886. package/dist/lib/typescript/lib/lib.es2019.symbol.d.ts +22 -0
  887. package/dist/lib/typescript/lib/lib.es2020.bigint.d.ts +763 -0
  888. package/dist/lib/typescript/lib/lib.es2020.d.ts +25 -0
  889. package/dist/lib/typescript/lib/lib.es2020.date.d.ts +40 -0
  890. package/dist/lib/typescript/lib/lib.es2020.full.d.ts +22 -0
  891. package/dist/lib/typescript/lib/lib.es2020.intl.d.ts +472 -0
  892. package/dist/lib/typescript/lib/lib.es2020.number.d.ts +26 -0
  893. package/dist/lib/typescript/lib/lib.es2020.promise.d.ts +45 -0
  894. package/dist/lib/typescript/lib/lib.es2020.sharedmemory.d.ts +97 -0
  895. package/dist/lib/typescript/lib/lib.es2020.string.d.ts +42 -0
  896. package/dist/lib/typescript/lib/lib.es2020.symbol.wellknown.d.ts +39 -0
  897. package/dist/lib/typescript/lib/lib.es2021.d.ts +21 -0
  898. package/dist/lib/typescript/lib/lib.es2021.full.d.ts +22 -0
  899. package/dist/lib/typescript/lib/lib.es2021.intl.d.ts +164 -0
  900. package/dist/lib/typescript/lib/lib.es2021.promise.d.ts +46 -0
  901. package/dist/lib/typescript/lib/lib.es2021.string.d.ts +31 -0
  902. package/dist/lib/typescript/lib/lib.es2021.weakref.d.ts +76 -0
  903. package/dist/lib/typescript/lib/lib.es2022.array.d.ts +119 -0
  904. package/dist/lib/typescript/lib/lib.es2022.d.ts +23 -0
  905. package/dist/lib/typescript/lib/lib.es2022.error.d.ts +73 -0
  906. package/dist/lib/typescript/lib/lib.es2022.full.d.ts +22 -0
  907. package/dist/lib/typescript/lib/lib.es2022.intl.d.ts +143 -0
  908. package/dist/lib/typescript/lib/lib.es2022.object.d.ts +24 -0
  909. package/dist/lib/typescript/lib/lib.es2022.regexp.d.ts +37 -0
  910. package/dist/lib/typescript/lib/lib.es2022.string.d.ts +23 -0
  911. package/dist/lib/typescript/lib/lib.es2023.array.d.ts +922 -0
  912. package/dist/lib/typescript/lib/lib.es2023.collection.d.ts +19 -0
  913. package/dist/lib/typescript/lib/lib.es2023.d.ts +20 -0
  914. package/dist/lib/typescript/lib/lib.es2023.full.d.ts +22 -0
  915. package/dist/lib/typescript/lib/lib.es2023.intl.d.ts +62 -0
  916. package/dist/lib/typescript/lib/lib.es2024.arraybuffer.d.ts +63 -0
  917. package/dist/lib/typescript/lib/lib.es2024.collection.d.ts +27 -0
  918. package/dist/lib/typescript/lib/lib.es2024.d.ts +24 -0
  919. package/dist/lib/typescript/lib/lib.es2024.full.d.ts +22 -0
  920. package/dist/lib/typescript/lib/lib.es2024.object.d.ts +27 -0
  921. package/dist/lib/typescript/lib/lib.es2024.promise.d.ts +33 -0
  922. package/dist/lib/typescript/lib/lib.es2024.regexp.d.ts +23 -0
  923. package/dist/lib/typescript/lib/lib.es2024.sharedmemory.d.ts +66 -0
  924. package/dist/lib/typescript/lib/lib.es2024.string.d.ts +27 -0
  925. package/dist/lib/typescript/lib/lib.es2025.collection.d.ts +94 -0
  926. package/dist/lib/typescript/lib/lib.es2025.d.ts +23 -0
  927. package/dist/lib/typescript/lib/lib.es2025.float16.d.ts +443 -0
  928. package/dist/lib/typescript/lib/lib.es2025.full.d.ts +22 -0
  929. package/dist/lib/typescript/lib/lib.es2025.intl.d.ts +200 -0
  930. package/dist/lib/typescript/lib/lib.es2025.iterator.d.ts +146 -0
  931. package/dist/lib/typescript/lib/lib.es2025.promise.d.ts +32 -0
  932. package/dist/lib/typescript/lib/lib.es2025.regexp.d.ts +30 -0
  933. package/dist/lib/typescript/lib/lib.es5.d.ts +4599 -0
  934. package/dist/lib/typescript/lib/lib.es6.d.ts +21 -0
  935. package/dist/lib/typescript/lib/lib.esnext.array.d.ts +33 -0
  936. package/dist/lib/typescript/lib/lib.esnext.collection.d.ts +47 -0
  937. package/dist/lib/typescript/lib/lib.esnext.d.ts +27 -0
  938. package/dist/lib/typescript/lib/lib.esnext.date.d.ts +21 -0
  939. package/dist/lib/typescript/lib/lib.esnext.decorators.d.ts +26 -0
  940. package/dist/lib/typescript/lib/lib.esnext.disposable.d.ts +191 -0
  941. package/dist/lib/typescript/lib/lib.esnext.error.d.ts +22 -0
  942. package/dist/lib/typescript/lib/lib.esnext.full.d.ts +22 -0
  943. package/dist/lib/typescript/lib/lib.esnext.intl.d.ts +107 -0
  944. package/dist/lib/typescript/lib/lib.esnext.sharedmemory.d.ts +23 -0
  945. package/dist/lib/typescript/lib/lib.esnext.temporal.d.ts +485 -0
  946. package/dist/lib/typescript/lib/lib.esnext.typedarrays.d.ts +90 -0
  947. package/dist/lib/typescript/lib/lib.scripthost.d.ts +320 -0
  948. package/dist/lib/typescript/lib/lib.webworker.asynciterable.d.ts +18 -0
  949. package/dist/lib/typescript/lib/lib.webworker.d.ts +15606 -0
  950. package/dist/lib/typescript/lib/lib.webworker.importscripts.d.ts +21 -0
  951. package/dist/lib/typescript/lib/lib.webworker.iterable.d.ts +18 -0
  952. package/dist/lib/typescript/lib/tsc +0 -0
  953. package/dist/lib/typescript/package.json +45 -0
  954. package/dist/lib/wasi/cli/wasi-paths.js +41 -0
  955. package/dist/lib/wasi/cli/wasi-runner.js +28 -0
  956. package/dist/lib/wasi/package.json +1 -0
  957. package/dist/lib/wasi/wasi-paths.js +25 -0
  958. package/package.json +22 -6
  959. package/README.md +0 -3
  960. package/index.js +0 -2
@@ -0,0 +1,1849 @@
1
+ #include "scr_runtime.h"
2
+
3
+ #include <math.h>
4
+ #include <stdio.h>
5
+ #include <stdlib.h>
6
+ #include <string.h>
7
+
8
+ /* Live heap-string count for the RC audit lane (-DSCR_RC_AUDIT): the test
9
+ * harness builds with it to prove the emitted retain/release discipline
10
+ * leaks nothing and frees nothing twice (double-free shows up as ASan
11
+ * use-after-free on the rc field or a negative count here). */
12
+ #ifdef SCR_RC_AUDIT
13
+ static SCR_TL long scr_live_strings = 0;
14
+ long scr_str_live_count(void) { return scr_live_strings; }
15
+ #endif
16
+
17
+ static void scr_oom(void) {
18
+ scr_trap("scriptc: out of memory\n");
19
+ }
20
+
21
+ /* Weak, bounded interning for tiny slices (including non-ASCII characters).
22
+ * Unlike an owning cache, this never keeps a string alive: its last release
23
+ * removes the entry. Collisions simply replace the weak pointer. A unique
24
+ * string can still be appended to or reallocated, so those paths invalidate
25
+ * the entry before touching its bytes/address. No ScrStr ABI change. */
26
+ #define SCR_SHORT_N 64
27
+ static SCR_TL ScrStr *scr_short_tab[SCR_SHORT_N];
28
+
29
+ static size_t scr_short_hash(const char *bytes, size_t len) {
30
+ size_t h = len;
31
+ for (size_t i = 0; i < len; i++) h = h * 31 + (unsigned char)bytes[i];
32
+ return h % SCR_SHORT_N;
33
+ }
34
+
35
+ static void scr_short_forget(const ScrStr *s) {
36
+ if (s->len < 2 || s->len > 4) return;
37
+ size_t h = scr_short_hash(s->data, s->len);
38
+ if (scr_short_tab[h] == s) scr_short_tab[h] = NULL;
39
+ }
40
+
41
+ /* ── UTF-16 index cache ───────────────────────────────────────────────
42
+ * JS string semantics are UTF-16 indices over our UTF-8 storage, so
43
+ * .length, charCodeAt, charAt, indexOf and slice all need unit↔byte
44
+ * conversions. A four-entry direct cursor cache keeps the old hot cursor for
45
+ * tiny and allocation-failure traffic. A separate four-entry sparse cache
46
+ * owns `{ UTF-16 unit, UTF-8 byte }` checkpoints, so a warmed non-local
47
+ * lookup decodes at most one checkpoint interval instead of a prefix
48
+ * proportional to its requested index.
49
+ *
50
+ * Checkpoints are owned by the entry, not the ScrStr ABI: the representation
51
+ * remains the three-word UTF-8 ScrStr used by literals, FFI and generated
52
+ * code. Checkpoints cost two size_ts every 4 KiB (about 0.39% of indexed
53
+ * bytes). There are exactly four sparse entries per runtime instance;
54
+ * eviction, release, realloc, executable exit, and every library reset free
55
+ * retained metadata. The cursor and sparse tiers are deliberately separate:
56
+ * fresh short receivers never evict a retained large-string index. This
57
+ * fixed residency is intentional: registry lookup and the release of
58
+ * unrelated strings never scale with the number of live indexed receivers.
59
+ * SCR_TL makes both tables and owned buffers instance-local for
60
+ * SCR_THREAD_INSTANCES. Metadata allocation is strictly an optimization:
61
+ * overflow or malloc failure falls back to the cursor mapper.
62
+ */
63
+ #define SCR_SIDX_N 4
64
+ #define SCR_U16_UNKNOWN SIZE_MAX
65
+ #define SCR_SIDX_MIN_BYTES ((size_t)64 * 1024)
66
+ #define SCR_SIDX_STRIDE_BYTES ((size_t)4 * 1024)
67
+ typedef struct {
68
+ size_t cu; /* UTF-16 code-unit offset, always a code-point boundary */
69
+ size_t cb; /* matching UTF-8 byte offset, never a continuation byte */
70
+ } ScrSidxPoint;
71
+ typedef struct ScrSidx {
72
+ const ScrStr *s; /* NULL = empty slot */
73
+ size_t u16len; /* SCR_U16_UNKNOWN until the whole current string */
74
+ size_t cu, cb; /* hot cursor: cb starts the char at unit cu */
75
+ ScrSidxPoint *points; /* sparse, ordered code-point-boundary anchors */
76
+ size_t npoints, cap; /* owned points length/capacity */
77
+ size_t indexed_cu; /* exact contiguous prefix indexed from byte zero */
78
+ size_t indexed_cb;
79
+ bool no_more_points; /* metadata allocation failed/overflowed: fail open */
80
+ bool points_complete; /* points cover every stride of indexed prefix */
81
+ } ScrSidx;
82
+ /* Keep short-string cursor traffic out of the sparse cache. A short-lived
83
+ * one-byte receiver can be far more common than a large indexed one; sharing
84
+ * the round-robin slots would otherwise rebuild a warm index every few calls.
85
+ */
86
+ static SCR_TL ScrSidx scr_sidx_sparse_tab[SCR_SIDX_N];
87
+ static SCR_TL ScrSidx scr_sidx_cursor_tab[SCR_SIDX_N];
88
+ static SCR_TL unsigned scr_sidx_sparse_clock;
89
+ static SCR_TL unsigned scr_sidx_cursor_clock;
90
+ static SCR_TL bool scr_sidx_cleanup_registered;
91
+
92
+ static void scr_sidx_clear(ScrSidx *e) {
93
+ free(e->points);
94
+ memset(e, 0, sizeof(*e));
95
+ }
96
+
97
+ static void scr_sidx_reset_all(void) {
98
+ for (int i = 0; i < SCR_SIDX_N; i++) {
99
+ scr_sidx_clear(&scr_sidx_sparse_tab[i]);
100
+ scr_sidx_clear(&scr_sidx_cursor_tab[i]);
101
+ }
102
+ scr_sidx_sparse_clock = 0;
103
+ scr_sidx_cursor_clock = 0;
104
+ }
105
+
106
+ static void scr_sidx_register_cleanup(void) {
107
+ if (!scr_sidx_cleanup_registered) {
108
+ scr_sidx_cleanup_registered = true;
109
+ scr_atexit(scr_sidx_reset_all);
110
+ }
111
+ }
112
+
113
+ #ifdef SCR_SIDX_TEST
114
+ static SCR_TL size_t scr_sidx_walk_steps;
115
+ void scr_sidx_test_reset_steps(void) { scr_sidx_walk_steps = 0; }
116
+ size_t scr_sidx_test_walk_steps(void) { return scr_sidx_walk_steps; }
117
+ void scr_sidx_test_reset_cache(void) { scr_sidx_reset_all(); }
118
+ size_t scr_sidx_test_entries(void) {
119
+ size_t n = 0;
120
+ for (int i = 0; i < SCR_SIDX_N; i++)
121
+ n += scr_sidx_sparse_tab[i].s != NULL;
122
+ return n;
123
+ }
124
+ size_t scr_sidx_test_points(void) {
125
+ size_t n = 0;
126
+ for (int i = 0; i < SCR_SIDX_N; i++)
127
+ n += scr_sidx_sparse_tab[i].npoints;
128
+ return n;
129
+ }
130
+ #define SCR_SIDX_STEP() (scr_sidx_walk_steps++)
131
+ #else
132
+ #define SCR_SIDX_STEP() ((void)0)
133
+ #endif
134
+
135
+ static void scr_sidx_purge(const ScrStr *s) {
136
+ /* These are deliberately fixed four-entry tables, never an unbounded
137
+ * receiver registry. Releasing an unrelated temporary therefore does at
138
+ * most eight pointer comparisons and cannot grow with live strings. */
139
+ for (int i = 0; i < SCR_SIDX_N; i++) {
140
+ if (scr_sidx_sparse_tab[i].s == s)
141
+ scr_sidx_clear(&scr_sidx_sparse_tab[i]);
142
+ if (scr_sidx_cursor_tab[i].s == s)
143
+ scr_sidx_clear(&scr_sidx_cursor_tab[i]);
144
+ }
145
+ }
146
+
147
+ static void scr_sidx_init(ScrSidx *e, const ScrStr *s) {
148
+ memset(e, 0, sizeof(*e));
149
+ e->s = s;
150
+ e->u16len = SCR_U16_UNKNOWN;
151
+ }
152
+
153
+ /* Short strings retain the historical hot cursor without contending with the
154
+ * sparse residency. Large strings claim only the sparse tier; an in-place
155
+ * append that crosses the threshold moves its exact cursor frontier into
156
+ * that tier rather than scanning the unchanged prefix again. All-ASCII
157
+ * receivers still shed their point buffer after proving identity mapping.
158
+ * Both tiers remain fixed-size and allocation-free until a non-ASCII sparse
159
+ * receiver actually needs checkpoints. */
160
+ static ScrSidx *scr_sidx(const ScrStr *s) {
161
+ if (s->len >= SCR_SIDX_MIN_BYTES) {
162
+ for (int i = 0; i < SCR_SIDX_N; i++) {
163
+ if (scr_sidx_sparse_tab[i].s == s) return &scr_sidx_sparse_tab[i];
164
+ }
165
+ /* The only in-place mutation is append. A formerly short receiver can
166
+ * therefore cross the threshold with an exact, useful cursor frontier
167
+ * already in the cursor tier; transfer it before evicting a sparse slot.
168
+ * No checkpoint buffer can exist below the threshold, but moving the
169
+ * whole record also preserves the fail-open allocation state. */
170
+ for (int i = 0; i < SCR_SIDX_N; i++) {
171
+ ScrSidx *old = &scr_sidx_cursor_tab[i];
172
+ if (old->s != s) continue;
173
+ ScrSidx *e = &scr_sidx_sparse_tab[
174
+ scr_sidx_sparse_clock++ % SCR_SIDX_N];
175
+ scr_sidx_clear(e);
176
+ *e = *old;
177
+ memset(old, 0, sizeof(*old)); /* ownership moved to the sparse tier */
178
+ return e;
179
+ }
180
+ ScrSidx *e =
181
+ &scr_sidx_sparse_tab[scr_sidx_sparse_clock++ % SCR_SIDX_N];
182
+ scr_sidx_clear(e);
183
+ scr_sidx_init(e, s);
184
+ return e;
185
+ }
186
+ ScrSidx *tab = scr_sidx_cursor_tab;
187
+ unsigned *clock = &scr_sidx_cursor_clock;
188
+ for (int i = 0; i < SCR_SIDX_N; i++) {
189
+ if (tab[i].s == s) return &tab[i];
190
+ }
191
+ ScrSidx *e = &tab[(*clock)++ % SCR_SIDX_N];
192
+ scr_sidx_clear(e);
193
+ scr_sidx_init(e, s);
194
+ return e;
195
+ }
196
+
197
+ /* In-place concat changes only the suffix. Keep every exact prefix anchor
198
+ * (including the former end, which is now an ordinary boundary), but remove
199
+ * the sole fact that described the old complete string. A threshold-crossing
200
+ * receiver may move from the cursor tier to the sparse tier on its next
201
+ * lookup, so invalidate either possible entry. */
202
+ static void scr_sidx_concat_append(const ScrStr *s, size_t oldlen) {
203
+ for (int i = 0; i < SCR_SIDX_N; i++) {
204
+ ScrSidx *entries[] = {&scr_sidx_sparse_tab[i], &scr_sidx_cursor_tab[i]};
205
+ for (size_t j = 0; j < sizeof(entries) / sizeof(entries[0]); j++) {
206
+ ScrSidx *e = entries[j];
207
+ if (e->s != s) continue;
208
+ e->u16len = SCR_U16_UNKNOWN;
209
+ if (e->indexed_cb > oldlen) e->indexed_cb = oldlen;
210
+ }
211
+ }
212
+ }
213
+
214
+ /* ── allocation ─────────────────────────────────────────────────────── */
215
+
216
+ static ScrStr *scr_str_alloc(size_t len, size_t cap) {
217
+ if (len > cap || cap > SIZE_MAX - sizeof(ScrStr) - 1) scr_oom();
218
+ ScrStr *s = malloc(sizeof(ScrStr) + cap + 1);
219
+ if (!s) scr_oom();
220
+ s->rc = 1;
221
+ s->len = len;
222
+ s->cap = cap;
223
+ #ifdef SCR_RC_AUDIT
224
+ scr_live_strings++;
225
+ #endif
226
+ return s;
227
+ }
228
+
229
+ ScrStr *scr_str_new(const char *bytes, size_t len) {
230
+ ScrStr *s = scr_str_alloc(len, len);
231
+ memcpy(s->data, bytes, len);
232
+ s->data[len] = '\0';
233
+ return s;
234
+ }
235
+
236
+ /* One-slot free-block cache for concat callers that must copy: observable
237
+ * aliases, `s = s + s`, and non-canonical concat shapes still allocate a
238
+ * replacement result. The compiler's canonical self-assignment handoff
239
+ * leaves its left snapshot uniquely owned, so it instead uses the in-place
240
+ * path below; this cache remains useful for the copy cases. Disabled in the
241
+ * audit lane so ASan sees every logical free as a real free. */
242
+ #ifndef SCR_RC_AUDIT
243
+ static SCR_TL ScrStr *scr_str_spare;
244
+ #endif
245
+
246
+ /* A spare-block reuse must not waste grossly (cap <= 4x the need) and only
247
+ * sizable blocks are worth stashing (>= 512). */
248
+ static ScrStr *scr_str_take_spare(size_t len) {
249
+ #ifndef SCR_RC_AUDIT
250
+ ScrStr *s = scr_str_spare;
251
+ if (s && s->cap >= len && s->cap / 4 <= len) {
252
+ scr_str_spare = NULL;
253
+ s->rc = 1;
254
+ s->len = len; /* keeps its larger cap */
255
+ return s;
256
+ }
257
+ #else
258
+ (void)len;
259
+ #endif
260
+ return NULL;
261
+ }
262
+
263
+ /* Builder entry points (scr_json.c): raw block with undefined bytes, and
264
+ * an rc==1-only grow. The spare block is worth trying first — a stringify
265
+ * loop's previous output is usually the right size for the next one. */
266
+ ScrStr *scr_str_alloc_raw(size_t len, size_t cap) {
267
+ ScrStr *s = scr_str_take_spare(cap);
268
+ if (!s) return scr_str_alloc(len, cap);
269
+ s->len = len; /* keeps its (possibly larger) cap */
270
+ return s;
271
+ }
272
+
273
+ ScrStr *scr_str_regrow(ScrStr *s, size_t newcap) {
274
+ scr_short_forget(s);
275
+ scr_sidx_purge(s); /* realloc may move; the old address may be recycled */
276
+ ScrStr *r = realloc(s, sizeof(ScrStr) + newcap + 1);
277
+ if (!r) scr_oom();
278
+ r->cap = newcap;
279
+ return r;
280
+ }
281
+
282
+ void scr_str_release(ScrStr *s) {
283
+ if (!s || s->rc == SIZE_MAX) return; /* NULL: an uninitialized `let` local */
284
+ if (--s->rc == 0) {
285
+ scr_short_forget(s);
286
+ scr_sidx_purge(s); /* the address may be recycled by the next malloc */
287
+ #ifdef SCR_RC_AUDIT
288
+ scr_live_strings--;
289
+ #endif
290
+ #ifndef SCR_RC_AUDIT
291
+ if (s->cap >= 512) {
292
+ ScrStr *old = scr_str_spare;
293
+ scr_str_spare = s;
294
+ if (!old) return;
295
+ s = old; /* evict the previous spare */
296
+ }
297
+ #endif
298
+ free(s);
299
+ }
300
+ }
301
+
302
+ ScrStr *scr_str_concat(ScrStr *a, ScrStr *b) {
303
+ if (a->len > SIZE_MAX - b->len - sizeof(ScrStr) - 1) scr_oom();
304
+ size_t newlen = a->len + b->len;
305
+ /* In-place append: a is uniquely owned by the caller's borrow (rc == 1 —
306
+ * never an interned literal, those are SIZE_MAX) and has room. Fires on
307
+ * concat chains (`a + b + c`, template literals), where each intermediate
308
+ * result reaches the next concat as a sole-reference temp. Any string
309
+ * with rc > 1 might be aliased and is copied, never mutated. */
310
+ if (a->rc == 1 && a != b && a->cap >= newlen) {
311
+ size_t oldlen = a->len;
312
+ scr_short_forget(a);
313
+ memcpy(a->data + a->len, b->data, b->len);
314
+ a->len = newlen;
315
+ a->data[newlen] = '\0';
316
+ /* A cached UTF-16 length for a is stale now; checkpoints and the exact
317
+ * old prefix remain valid. Its old terminal point is no longer an END
318
+ * fact (u16len is invalidated below), but remains an excellent ordinary
319
+ * checkpoint for accesses around the append boundary. The next mapper
320
+ * lazily continues from oldlen rather than scanning the unchanged prefix
321
+ * again. */
322
+ scr_sidx_concat_append(a, oldlen);
323
+ a->rc = 2; /* +1 for the returned reference, beside the caller's borrow */
324
+ return a;
325
+ }
326
+ /* Copy path. Geometric slack keeps uniquely-owned concat chains and the
327
+ * optimized self-assignment handoff amortized when they outgrow capacity.
328
+ * Aliases and `s = s + s` deliberately arrive with rc > 1 and stay on this
329
+ * path, preserving string immutability; their sizable replacement results
330
+ * can still benefit from the spare-block cache above. */
331
+ size_t newcap = newlen;
332
+ if (a->rc == 1) {
333
+ size_t grown = a->cap + (a->cap >> 1) + 16;
334
+ if (grown > newcap) newcap = grown;
335
+ } else if (newlen >= 512 && newlen <= (SIZE_MAX - sizeof(ScrStr) - 1) / 2) {
336
+ newcap = newlen + (newlen >> 1);
337
+ }
338
+ ScrStr *s = scr_str_take_spare(newlen);
339
+ if (!s) s = scr_str_alloc(newlen, newcap);
340
+ memcpy(s->data, a->data, a->len);
341
+ memcpy(s->data + a->len, b->data, b->len);
342
+ s->data[newlen] = '\0';
343
+ return s;
344
+ }
345
+
346
+ bool scr_str_eq(ScrStr *a, ScrStr *b) {
347
+ return a == b || (a->len == b->len && memcmp(a->data, b->data, a->len) == 0);
348
+ }
349
+
350
+ int scr_str_cmp(ScrStr *a, ScrStr *b) {
351
+ size_t min = a->len < b->len ? a->len : b->len;
352
+ int c = memcmp(a->data, b->data, min);
353
+ if (c != 0) return c;
354
+ return a->len < b->len ? -1 : (a->len > b->len ? 1 : 0);
355
+ }
356
+
357
+ /* UTF-16 code-unit comparison over well-formed UTF-8 (the default
358
+ * Array.sort/toSorted and URLSearchParams.sort order). Byte order ALMOST
359
+ * matches — the exception is U+E000..U+FFFF (3-byte UTF-8, single high code
360
+ * units) vs supplementary code points (4-byte UTF-8, surrogate pairs
361
+ * 0xD800..0xDFFF): bytes put the 4-byte form last, code units put it first.
362
+ * Decode code points and compare their leading UTF-16 units. */
363
+ static uint32_t scr_str_lead_u16(const unsigned char *s, size_t len,
364
+ size_t *adv) {
365
+ unsigned char b = s[0];
366
+ uint32_t cp;
367
+ size_t n;
368
+ if (b < 0x80) {
369
+ cp = b; n = 1;
370
+ } else if ((b & 0xe0) == 0xc0) {
371
+ cp = b & 0x1fu; n = 2;
372
+ } else if ((b & 0xf0) == 0xe0) {
373
+ cp = b & 0x0fu; n = 3;
374
+ } else {
375
+ cp = b & 0x07u; n = 4;
376
+ }
377
+ if (n > len) n = len; /* defensive: strings are well-formed by contract */
378
+ for (size_t i = 1; i < n; i++) cp = (cp << 6) | (s[i] & 0x3fu);
379
+ *adv = n;
380
+ if (cp >= 0x10000) return 0xd800 + ((cp - 0x10000) >> 10);
381
+ return cp;
382
+ }
383
+
384
+ int scr_str_cmp_u16(ScrStr *a, ScrStr *b) {
385
+ size_t ia = 0, ib = 0;
386
+ while (ia < a->len && ib < b->len) {
387
+ size_t na, nb;
388
+ uint32_t ua = scr_str_lead_u16(
389
+ (const unsigned char *)a->data + ia, a->len - ia, &na);
390
+ uint32_t ub = scr_str_lead_u16(
391
+ (const unsigned char *)b->data + ib, b->len - ib, &nb);
392
+ if (ua != ub) return ua < ub ? -1 : 1;
393
+ /* Equal leading units: equal whole code points (both single units or
394
+ * both pairs with equal highs — lows only differ if cps differ). */
395
+ if (na == 4 && nb == 4) {
396
+ uint32_t cpa = 0, cpb = 0;
397
+ for (size_t i = 0; i < 4; i++) {
398
+ cpa = (cpa << 6) |
399
+ (i == 0 ? (unsigned char)a->data[ia] & 0x07u
400
+ : (unsigned char)a->data[ia + i] & 0x3fu);
401
+ cpb = (cpb << 6) |
402
+ (i == 0 ? (unsigned char)b->data[ib] & 0x07u
403
+ : (unsigned char)b->data[ib + i] & 0x3fu);
404
+ }
405
+ if (cpa != cpb) return cpa < cpb ? -1 : 1;
406
+ }
407
+ ia += na;
408
+ ib += nb;
409
+ }
410
+ if (ia < a->len) return 1;
411
+ if (ib < b->len) return -1;
412
+ return 0;
413
+ }
414
+
415
+ /* ── interned strings ─────────────────────────────────────────────────
416
+ * The empty string and every single-character ASCII string are immortal
417
+ * statics (same layout the emitter uses for literals): charAt/slice churn
418
+ * in tight loops returns these without allocating.
419
+ */
420
+ typedef struct { size_t rc; size_t len; size_t cap; char data[2]; } ScrChar1;
421
+ #define SCR_A(c) {SIZE_MAX, 1, 1, {(char)(c), 0}}
422
+ #define SCR_A8(c) \
423
+ SCR_A(c), SCR_A(c + 1), SCR_A(c + 2), SCR_A(c + 3), \
424
+ SCR_A(c + 4), SCR_A(c + 5), SCR_A(c + 6), SCR_A(c + 7)
425
+ static const ScrChar1 scr_ascii1[128] = {
426
+ SCR_A8(0), SCR_A8(8), SCR_A8(16), SCR_A8(24),
427
+ SCR_A8(32), SCR_A8(40), SCR_A8(48), SCR_A8(56),
428
+ SCR_A8(64), SCR_A8(72), SCR_A8(80), SCR_A8(88),
429
+ SCR_A8(96), SCR_A8(104), SCR_A8(112), SCR_A8(120),
430
+ };
431
+ static const struct { size_t rc; size_t len; size_t cap; char data[1]; }
432
+ scr_lit_empty = {SIZE_MAX, 0, 0, ""};
433
+
434
+ static ScrStr *scr_str_empty(void) { return (ScrStr *)&scr_lit_empty; }
435
+
436
+ /* Empty/ASCII characters are immortal; tiny spans share live heap strings. */
437
+ static ScrStr *scr_str_from_span(const char *bytes, size_t len) {
438
+ if (len == 0) return scr_str_empty();
439
+ if (len == 1 && (unsigned char)bytes[0] < 0x80) {
440
+ return (ScrStr *)&scr_ascii1[(unsigned char)bytes[0]];
441
+ }
442
+ if (len >= 2 && len <= 4) {
443
+ size_t h = scr_short_hash(bytes, len);
444
+ ScrStr *cached = scr_short_tab[h];
445
+ if (cached && cached->len == len && memcmp(cached->data, bytes, len) == 0)
446
+ return scr_str_retain(cached);
447
+ ScrStr *s = scr_str_new(bytes, len);
448
+ scr_short_tab[h] = s;
449
+ return s;
450
+ }
451
+ return scr_str_new(bytes, len);
452
+ }
453
+
454
+ /* A scalar fromCharCode needs neither the variadic argument array nor an
455
+ * encoding buffer. Reuse the same empty/ASCII/tiny-span storage policy as
456
+ * character indexing. A lone surrogate keeps the existing U+FFFD policy. */
457
+ ScrStr *scr_str_from_char_code_one(double code) {
458
+ uint32_t cp = scr_to_uint32(code) & 0xFFFFu;
459
+ if (cp < 0x80) return (ScrStr *)&scr_ascii1[cp];
460
+ if (cp >= 0xD800 && cp <= 0xDFFF) cp = 0xFFFD;
461
+ char bytes[3];
462
+ if (cp < 0x800) {
463
+ bytes[0] = (char)(0xC0 | (cp >> 6));
464
+ bytes[1] = (char)(0x80 | (cp & 0x3F));
465
+ return scr_str_from_span(bytes, 2);
466
+ }
467
+ bytes[0] = (char)(0xE0 | (cp >> 12));
468
+ bytes[1] = (char)(0x80 | ((cp >> 6) & 0x3F));
469
+ bytes[2] = (char)(0x80 | (cp & 0x3F));
470
+ return scr_str_from_span(bytes, 3);
471
+ }
472
+
473
+ /* ── string methods: UTF-16 semantics over UTF-8 storage ──────────
474
+ * All strings in the system are well-formed UTF-8 (the compiler replaces
475
+ * lone surrogates in literals with U+FFFD), so the decode helpers below
476
+ * may assume valid sequences and never validate.
477
+ */
478
+
479
+ /* UTF-8 encoding of U+FFFD REPLACEMENT CHARACTER — stands in for the lone
480
+ * surrogate JS would produce when charAt/slice split an astral pair. */
481
+ #define SCR_REPLACEMENT "\xEF\xBF\xBD"
482
+ #define SCR_REPLACEMENT_LEN ((size_t)3)
483
+
484
+ /* Byte length of the well-formed UTF-8 sequence starting at lead byte c. */
485
+ static size_t scr_utf8_seq_len(unsigned char c) {
486
+ if (c < 0x80) return 1;
487
+ if (c < 0xE0) return 2;
488
+ if (c < 0xF0) return 3;
489
+ return 4;
490
+ }
491
+
492
+ /* Decode the code point at p (well-formed UTF-8); *adv gets the byte
493
+ * length of the sequence. */
494
+ static uint32_t scr_utf8_decode(const char *p, size_t *adv) {
495
+ unsigned char c = (unsigned char)p[0];
496
+ if (c < 0x80) {
497
+ *adv = 1;
498
+ return c;
499
+ }
500
+ if (c < 0xE0) {
501
+ *adv = 2;
502
+ return ((uint32_t)(c & 0x1F) << 6) | ((unsigned char)p[1] & 0x3F);
503
+ }
504
+ if (c < 0xF0) {
505
+ *adv = 3;
506
+ return ((uint32_t)(c & 0x0F) << 12) |
507
+ ((uint32_t)((unsigned char)p[1] & 0x3F) << 6) |
508
+ ((unsigned char)p[2] & 0x3F);
509
+ }
510
+ *adv = 4;
511
+ return ((uint32_t)(c & 0x07) << 18) |
512
+ ((uint32_t)((unsigned char)p[1] & 0x3F) << 12) |
513
+ ((uint32_t)((unsigned char)p[2] & 0x3F) << 6) |
514
+ ((unsigned char)p[3] & 0x3F);
515
+ }
516
+
517
+ /* Number of UTF-16 code units in a valid UTF-8 span (BMP char = 1, astral
518
+ * char = 2). Byte classification is position-independent, so sparse-index
519
+ * construction can count one checkpoint interval at a time without giving
520
+ * up the word-at-a-time length fast path. */
521
+ static size_t scr_utf16_units_span(const char *data, size_t len,
522
+ bool *all_ascii) {
523
+ const unsigned char *d = (const unsigned char *)data;
524
+ const uint64_t hibits = 0x8080808080808080ull;
525
+ size_t units = 0, i = 0;
526
+ bool ascii = true;
527
+ while (i + 8 <= len) {
528
+ uint64_t w;
529
+ memcpy(&w, d + i, 8);
530
+ i += 8;
531
+ if ((w & hibits) == 0) { /* all ASCII */
532
+ units += 8;
533
+ continue;
534
+ }
535
+ ascii = false;
536
+ uint64_t cont = w & ~(w << 1) & hibits;
537
+ uint64_t lead4 = w & (w << 1) & (w << 2) & (w << 3) & hibits;
538
+ units += 8 - (size_t)__builtin_popcountll(cont) +
539
+ (size_t)__builtin_popcountll(lead4);
540
+ }
541
+ while (i < len) {
542
+ unsigned char c = d[i++];
543
+ if ((c & 0xC0) == 0x80) continue; /* continuation byte */
544
+ if (c >= 0x80) ascii = false;
545
+ units += c >= 0xF0 ? 2 : 1;
546
+ }
547
+ if (all_ascii) *all_ascii = ascii;
548
+ return units;
549
+ }
550
+
551
+ /* Keep a start anchor, every stride crossed, and an exact final/prefix
552
+ * anchor. All calls arrive at character boundaries. Returning false simply
553
+ * means allocation failed and the hot cursor should handle this string. */
554
+ static bool scr_sidx_add_point(ScrSidx *e, size_t cu, size_t cb,
555
+ bool force) {
556
+ if (e->no_more_points) return false;
557
+ if (e->npoints != 0) {
558
+ ScrSidxPoint last = e->points[e->npoints - 1];
559
+ if (last.cb == cb) return true;
560
+ if (!force && cb - last.cb < SCR_SIDX_STRIDE_BYTES) return true;
561
+ }
562
+ if (e->npoints == e->cap) {
563
+ size_t cap = e->cap == 0 ? 16 : e->cap;
564
+ if (e->cap != 0) {
565
+ if (cap > SIZE_MAX / 2) {
566
+ e->no_more_points = true;
567
+ return false;
568
+ }
569
+ cap *= 2;
570
+ }
571
+ if (cap > SIZE_MAX / sizeof(*e->points)) {
572
+ e->no_more_points = true;
573
+ return false;
574
+ }
575
+ ScrSidxPoint *points = realloc(e->points, cap * sizeof(*points));
576
+ if (!points) {
577
+ e->no_more_points = true;
578
+ return false;
579
+ }
580
+ e->points = points;
581
+ e->cap = cap;
582
+ scr_sidx_register_cleanup();
583
+ }
584
+ e->points[e->npoints++] = (ScrSidxPoint){cu, cb};
585
+ return true;
586
+ }
587
+
588
+ /* Enable sparse state only where a 16-byte checkpoint buffer is a much
589
+ * better trade than repeatedly walking a short string. If a completed
590
+ * ASCII scan later proves identity mapping, all of this storage is freed. */
591
+ static bool scr_sidx_prepare_points(const ScrStr *s, ScrSidx *e) {
592
+ if (s->len < SCR_SIDX_MIN_BYTES || e->no_more_points) return false;
593
+ if (e->npoints == 0) {
594
+ if (!scr_sidx_add_point(e, 0, 0, true)) return false;
595
+ /* concat may have left an exact old end/frontier without a previous
596
+ * buffer (notably an all-ASCII prefix). Backfill that known identity
597
+ * span arithmetically — never rescan it just to create anchors. Exact
598
+ * identity means every stride is also a UTF-16/code-point boundary. */
599
+ if (e->indexed_cb != 0 && e->indexed_cb == e->indexed_cu) {
600
+ for (size_t at = SCR_SIDX_STRIDE_BYTES; at < e->indexed_cb;) {
601
+ if (!scr_sidx_add_point(e, at, at, true)) return false;
602
+ if (at > e->indexed_cb - SCR_SIDX_STRIDE_BYTES) break;
603
+ at += SCR_SIDX_STRIDE_BYTES;
604
+ }
605
+ }
606
+ if (e->indexed_cb != 0 &&
607
+ !scr_sidx_add_point(e, e->indexed_cu, e->indexed_cb, true)) {
608
+ return false;
609
+ }
610
+ /* A pre-existing mixed prefix can only belong to a receiver that grew
611
+ * across the admission threshold while it was in the cursor tier. Its
612
+ * exact terminal anchor is useful immediately, but it does not promise
613
+ * a stride-bounded route through that old prefix. On completion, rebuild
614
+ * once from zero rather than mistaking this short-history anchor for a
615
+ * fully formed sparse index. */
616
+ e->points_complete = e->indexed_cb == e->indexed_cu;
617
+ }
618
+ return true;
619
+ }
620
+
621
+ /* The first code-point boundary at or after cb + SCR_SIDX_STRIDE_BYTES. */
622
+ static size_t scr_sidx_next_boundary(const ScrStr *s, size_t cb) {
623
+ size_t remain = s->len - cb;
624
+ size_t end = cb + (remain < SCR_SIDX_STRIDE_BYTES
625
+ ? remain : SCR_SIDX_STRIDE_BYTES);
626
+ while (end < s->len && ((unsigned char)s->data[end] & 0xC0) == 0x80) end++;
627
+ return end;
628
+ }
629
+
630
+ /* Extend the exact prefix frontier by one sparse interval. The span helper
631
+ * retains the old length throughput; the resulting point is always a real
632
+ * UTF-8 character boundary. */
633
+ static bool scr_sidx_extend_one(const ScrStr *s, ScrSidx *e) {
634
+ if (e->indexed_cb == s->len) return false;
635
+ size_t end = scr_sidx_next_boundary(s, e->indexed_cb);
636
+ bool ascii;
637
+ size_t units = scr_utf16_units_span(s->data + e->indexed_cb,
638
+ end - e->indexed_cb, &ascii);
639
+ /* Defer metadata until a large string proves it needs UTF-8 navigation.
640
+ * A long ASCII prefix is already an exact identity map; when this is the
641
+ * first mixed interval, prepare_points backfills that prefix arithmetically
642
+ * before it is ever rescanned. */
643
+ if (ascii && e->npoints == 0 && !e->no_more_points) {
644
+ e->indexed_cu += units;
645
+ e->indexed_cb = end;
646
+ return true;
647
+ }
648
+ if (e->npoints == 0) (void)scr_sidx_prepare_points(s, e);
649
+ e->indexed_cu += units;
650
+ e->indexed_cb = end;
651
+ if (e->npoints != 0) (void)scr_sidx_add_point(e, e->indexed_cu,
652
+ e->indexed_cb, true);
653
+ return true;
654
+ }
655
+
656
+ /* A formerly small mixed string can cross the sparse-index threshold through
657
+ * an ASCII in-place append. Its exact prefix already covers the whole new
658
+ * string, so the ordinary extension path has no non-ASCII interval that
659
+ * would cause prepare_points() to allocate anchors. Rebuild once in that
660
+ * narrow transition instead of leaving a threshold-sized non-ASCII string
661
+ * with only the hot cursor. This is still fail-open: an allocation failure
662
+ * leaves the completed length/cursor cache fully usable. */
663
+ static void scr_sidx_rebuild_points(const ScrStr *s, ScrSidx *e) {
664
+ if (s->len < SCR_SIDX_MIN_BYTES || e->points_complete ||
665
+ e->no_more_points)
666
+ return;
667
+ free(e->points);
668
+ e->points = NULL;
669
+ e->npoints = 0;
670
+ e->cap = 0;
671
+ size_t cu = 0, cb = 0;
672
+ if (!scr_sidx_add_point(e, cu, cb, true)) return;
673
+ while (cb < s->len) {
674
+ size_t end = scr_sidx_next_boundary(s, cb);
675
+ cu += scr_utf16_units_span(s->data + cb, end - cb, NULL);
676
+ cb = end;
677
+ if (!scr_sidx_add_point(e, cu, cb, true)) return;
678
+ }
679
+ e->points_complete = true;
680
+ }
681
+
682
+ static void scr_sidx_finish(const ScrStr *s, ScrSidx *e) {
683
+ if (e->indexed_cb != s->len) return;
684
+ e->u16len = e->indexed_cu;
685
+ if (e->u16len == s->len) { /* proven all ASCII: identity needs no index */
686
+ free(e->points);
687
+ e->points = NULL;
688
+ e->npoints = 0;
689
+ e->cap = 0;
690
+ e->points_complete = false;
691
+ } else {
692
+ scr_sidx_rebuild_points(s, e);
693
+ }
694
+ }
695
+
696
+ /* Index complete 4 KiB spans until the requested unit lies inside the
697
+ * indexed prefix. It deliberately completes that interval: a lookup just
698
+ * before an anchor and the next distant lookup both reuse the same work. */
699
+ static void scr_sidx_extend_to_u16(const ScrStr *s, ScrSidx *e, size_t u16) {
700
+ if (u16 <= e->indexed_cu) return;
701
+ while (e->indexed_cb < s->len) {
702
+ size_t start_cu = e->indexed_cu;
703
+ scr_sidx_extend_one(s, e);
704
+ if (u16 <= e->indexed_cu || e->indexed_cu == start_cu) break;
705
+ }
706
+ scr_sidx_finish(s, e);
707
+ }
708
+
709
+ /* A large, not-yet-complete string can have a long proven-ASCII prefix
710
+ * before its first non-ASCII byte. That prefix is an exact identity map, but
711
+ * merely advancing indexed_{cu,cb} through it leaves alternating on-demand
712
+ * lookups with only the hot cursor and therefore linear backtracks. Once an
713
+ * indexed conversion reaches such a prefix, retain its arithmetic stride
714
+ * anchors too. A later full scan still drops them if the whole string proves
715
+ * ASCII, so the all-ASCII steady state remains the allocation-free identity
716
+ * fast path. */
717
+ static void scr_sidx_materialize_identity_prefix(const ScrStr *s, ScrSidx *e) {
718
+ if (e->npoints == 0 && e->indexed_cb != 0 &&
719
+ e->indexed_cb == e->indexed_cu) {
720
+ (void)scr_sidx_prepare_points(s, e);
721
+ }
722
+ }
723
+
724
+ /* Cached UTF-16 length. Large strings extend from their exact previously
725
+ * indexed prefix, retaining sparse start/end anchors; short strings keep the
726
+ * historical single word-wise scan. `u16len == byte len` proves ASCII and
727
+ * restores identity mapping with zero retained checkpoint memory. */
728
+ static size_t scr_sidx_len(const ScrStr *s, ScrSidx *e) {
729
+ if (e->u16len != SCR_U16_UNKNOWN) return e->u16len;
730
+ while (e->indexed_cb < s->len) scr_sidx_extend_one(s, e);
731
+ scr_sidx_finish(s, e);
732
+ return e->u16len;
733
+ }
734
+
735
+ /* Step the cursor back one char (cb must be > 0 and on a boundary). */
736
+ static void scr_sidx_back(const ScrStr *s, size_t *cu, size_t *cb) {
737
+ SCR_SIDX_STEP();
738
+ size_t p = *cb - 1;
739
+ while (p > 0 && ((unsigned char)s->data[p] & 0xC0) == 0x80) p--;
740
+ *cu -= scr_utf8_seq_len((unsigned char)s->data[p]) == 4 ? 2 : 1;
741
+ *cb = p;
742
+ }
743
+
744
+ static size_t scr_sidx_abs_diff(size_t a, size_t b) {
745
+ return a < b ? b - a : a - b;
746
+ }
747
+
748
+ /* Pick the nearest known UTF-16 anchor. The sparse list is ordered both by
749
+ * unit and byte, so the predecessor/successor binary-search candidates are
750
+ * sufficient; the hot cursor retains sequential-access locality. */
751
+ static ScrSidxPoint scr_sidx_near_u16(const ScrStr *s, const ScrSidx *e,
752
+ size_t u16) {
753
+ ScrSidxPoint best = {0, 0};
754
+ size_t best_dist = u16;
755
+ if (e->npoints != 0) {
756
+ size_t lo = 0, hi = e->npoints;
757
+ while (lo < hi) {
758
+ size_t m = lo + (hi - lo) / 2;
759
+ if (e->points[m].cu < u16) lo = m + 1;
760
+ else hi = m;
761
+ }
762
+ if (lo < e->npoints &&
763
+ scr_sidx_abs_diff(e->points[lo].cu, u16) < best_dist) {
764
+ best = e->points[lo];
765
+ best_dist = scr_sidx_abs_diff(best.cu, u16);
766
+ }
767
+ if (lo != 0 &&
768
+ scr_sidx_abs_diff(e->points[lo - 1].cu, u16) < best_dist) {
769
+ best = e->points[lo - 1];
770
+ best_dist = scr_sidx_abs_diff(best.cu, u16);
771
+ }
772
+ }
773
+ if (e->cb <= s->len && scr_sidx_abs_diff(e->cu, u16) < best_dist) {
774
+ best = (ScrSidxPoint){e->cu, e->cb};
775
+ best_dist = scr_sidx_abs_diff(best.cu, u16);
776
+ }
777
+ if (e->u16len != SCR_U16_UNKNOWN &&
778
+ scr_sidx_abs_diff(e->u16len, u16) < best_dist) {
779
+ best = (ScrSidxPoint){e->u16len, s->len};
780
+ }
781
+ return best;
782
+ }
783
+
784
+ static ScrSidxPoint scr_sidx_near_byte(const ScrStr *s, const ScrSidx *e,
785
+ size_t byte_off) {
786
+ ScrSidxPoint best = {0, 0};
787
+ size_t best_dist = byte_off;
788
+ if (e->npoints != 0) {
789
+ size_t lo = 0, hi = e->npoints;
790
+ while (lo < hi) {
791
+ size_t m = lo + (hi - lo) / 2;
792
+ if (e->points[m].cb < byte_off) lo = m + 1;
793
+ else hi = m;
794
+ }
795
+ if (lo < e->npoints &&
796
+ scr_sidx_abs_diff(e->points[lo].cb, byte_off) < best_dist) {
797
+ best = e->points[lo];
798
+ best_dist = scr_sidx_abs_diff(best.cb, byte_off);
799
+ }
800
+ if (lo != 0 &&
801
+ scr_sidx_abs_diff(e->points[lo - 1].cb, byte_off) < best_dist) {
802
+ best = e->points[lo - 1];
803
+ best_dist = scr_sidx_abs_diff(best.cb, byte_off);
804
+ }
805
+ }
806
+ if (e->cb <= s->len && scr_sidx_abs_diff(e->cb, byte_off) < best_dist) {
807
+ best = (ScrSidxPoint){e->cu, e->cb};
808
+ best_dist = scr_sidx_abs_diff(best.cb, byte_off);
809
+ }
810
+ if (e->u16len != SCR_U16_UNKNOWN &&
811
+ scr_sidx_abs_diff(s->len, byte_off) < best_dist) {
812
+ best = (ScrSidxPoint){e->u16len, s->len};
813
+ }
814
+ return best;
815
+ }
816
+
817
+ /* Convert a UTF-16 index to a byte offset from the closest sparse anchor or
818
+ * hot cursor. If u16 addresses the second (low-surrogate) unit of
819
+ * an astral char, *mid is set and the returned offset is the START of that
820
+ * 4-byte sequence. u16 at or past the end returns s->len with *mid false.
821
+ * Same contract as a from-scratch scan. */
822
+ static size_t scr_u16_to_byte_c(const ScrStr *s, ScrSidx *e, size_t u16,
823
+ bool *mid) {
824
+ if (e->u16len == s->len) { /* all ASCII: identity mapping */
825
+ *mid = false;
826
+ return u16 < s->len ? u16 : s->len;
827
+ }
828
+ scr_sidx_extend_to_u16(s, e, u16);
829
+ /* Extending a far-end lookup can just have proved identity. Do not
830
+ * materialize an index that the identity fast path will never consult. */
831
+ if (e->u16len == s->len) {
832
+ *mid = false;
833
+ return u16 < s->len ? u16 : s->len;
834
+ }
835
+ scr_sidx_materialize_identity_prefix(s, e);
836
+ ScrSidxPoint near = scr_sidx_near_u16(s, e, u16);
837
+ size_t cu = near.cu, cb = near.cb;
838
+ while (cu > u16) scr_sidx_back(s, &cu, &cb);
839
+ bool m = false;
840
+ while (cu < u16 && cb < s->len) {
841
+ SCR_SIDX_STEP();
842
+ size_t seq = scr_utf8_seq_len((unsigned char)s->data[cb]);
843
+ size_t w = seq == 4 ? 2 : 1;
844
+ if (cu + w > u16) { /* u16 lands between the halves of an astral char */
845
+ m = true;
846
+ break;
847
+ }
848
+ cu += w;
849
+ cb += seq;
850
+ }
851
+ e->cu = cu;
852
+ e->cb = cb;
853
+ *mid = m;
854
+ return cb;
855
+ }
856
+
857
+ /* Convert a byte offset (must be a char boundary) to a UTF-16 index from
858
+ * the closest sparse anchor or hot cursor. */
859
+ static size_t scr_byte_to_u16_c(const ScrStr *s, ScrSidx *e,
860
+ size_t byte_off) {
861
+ if (e->u16len == s->len) return byte_off; /* all ASCII */
862
+ /* A byte search result may be far beyond the existing prefix. Build the
863
+ * same sparse intervals first, then choose the closest boundary anchor. */
864
+ if (byte_off > e->indexed_cb) {
865
+ while (e->indexed_cb < byte_off) scr_sidx_extend_one(s, e);
866
+ scr_sidx_finish(s, e);
867
+ }
868
+ /* As above, a completed all-ASCII scan is its own index. In particular,
869
+ * do not rebuild points that scr_sidx_finish() deliberately discarded. */
870
+ if (e->u16len == s->len) return byte_off;
871
+ scr_sidx_materialize_identity_prefix(s, e);
872
+ ScrSidxPoint near = scr_sidx_near_byte(s, e, byte_off);
873
+ size_t cu = near.cu, cb = near.cb;
874
+ while (cb > byte_off) scr_sidx_back(s, &cu, &cb);
875
+ while (cb < byte_off) {
876
+ SCR_SIDX_STEP();
877
+ size_t seq = scr_utf8_seq_len((unsigned char)s->data[cb]);
878
+ cu += seq == 4 ? 2 : 1;
879
+ cb += seq;
880
+ }
881
+ e->cu = cu;
882
+ e->cb = cb;
883
+ return cu;
884
+ }
885
+
886
+ /* ECMA-262 ToIntegerOrInfinity for a double already known to be a Number:
887
+ * NaN → +0, otherwise truncate toward zero, ±Infinity preserved. */
888
+ static double scr_to_integer_or_infinity(double x) {
889
+ if (isnan(x)) return 0.0;
890
+ return trunc(x);
891
+ }
892
+
893
+ /* Naive byte substring search (needle and hay are both well-formed UTF-8,
894
+ * so any byte-level match starts on a char boundary — UTF-8 is
895
+ * self-synchronizing). Empty needle matches at hay. */
896
+ static const char *scr_byte_find(const char *hay, size_t hay_len,
897
+ const char *nee, size_t nee_len) {
898
+ if (nee_len == 0) return hay;
899
+ if (nee_len > hay_len) return NULL;
900
+ for (size_t i = 0; i + nee_len <= hay_len; i++) {
901
+ if (hay[i] == nee[0] && memcmp(hay + i, nee, nee_len) == 0)
902
+ return hay + i;
903
+ }
904
+ return NULL;
905
+ }
906
+
907
+ /* Search backwards from a clamped UTF-16 position. A low-surrogate position
908
+ * maps to its scalar's first byte, so that scalar remains searchable. */
909
+ double scr_str_last_index_of_from(ScrStr *s, ScrStr *needle, double position) {
910
+ ScrSidx *e = scr_sidx(s);
911
+ size_t len16 = scr_sidx_len(s, e);
912
+ size_t start16 = isnan(position) || position >= (double)len16 ? len16
913
+ : position <= 0 ? 0 : (size_t)trunc(position);
914
+ if (needle->len == 0) return (double)start16;
915
+ if (needle->len > s->len) return -1.0;
916
+ bool mid;
917
+ size_t start_byte = scr_u16_to_byte_c(s, e, start16, &mid);
918
+ size_t max_start = s->len - needle->len;
919
+ if (start_byte < max_start) max_start = start_byte;
920
+ for (size_t i = max_start + 1; i-- > 0;) {
921
+ if (memcmp(s->data + i, needle->data, needle->len) == 0) {
922
+ return (double)scr_byte_to_u16_c(s, e, i);
923
+ }
924
+ }
925
+ return -1.0;
926
+ }
927
+
928
+ double scr_str_last_index_of(ScrStr *s, ScrStr *needle) {
929
+ return scr_str_last_index_of_from(s, needle, INFINITY);
930
+ }
931
+
932
+ double scr_str_utf16_len(ScrStr *s) {
933
+ return (double)scr_sidx_len(s, scr_sidx(s));
934
+ }
935
+
936
+ double scr_str_char_code_at(ScrStr *s, double i) {
937
+ double idx = scr_to_integer_or_infinity(i);
938
+ if (!(idx >= 0)) return NAN; /* negative or -Infinity */
939
+ /* UTF-16 length <= byte length always, so this also fences the cast. */
940
+ if (idx >= (double)s->len) return NAN;
941
+ ScrSidx *e = scr_sidx(s);
942
+ if (e->u16len == s->len) return (double)(unsigned char)s->data[(size_t)idx];
943
+ bool mid;
944
+ size_t off = scr_u16_to_byte_c(s, e, (size_t)idx, &mid);
945
+ if (off >= s->len) return NAN; /* idx >= length */
946
+ size_t adv;
947
+ uint32_t cp = scr_utf8_decode(s->data + off, &adv);
948
+ if (cp < 0x10000) return (double)cp;
949
+ uint32_t v = cp - 0x10000;
950
+ return mid ? (double)(0xDC00 + (v & 0x3FF)) : (double)(0xD800 + (v >> 10));
951
+ }
952
+
953
+ double scr_str_index_of(ScrStr *s, ScrStr *needle, double fromIndex) {
954
+ double pos = scr_to_integer_or_infinity(fromIndex);
955
+ ScrSidx *e = scr_sidx(s);
956
+ size_t len16 = scr_sidx_len(s, e);
957
+ size_t start16 = pos <= 0 ? 0
958
+ : pos >= (double)len16 ? len16
959
+ : (size_t)pos;
960
+ /* Per spec, the empty needle is found at the clamped fromIndex itself —
961
+ * even when that index is between the halves of an astral pair. */
962
+ if (needle->len == 0) return (double)start16;
963
+ bool mid;
964
+ size_t start_b = scr_u16_to_byte_c(s, e, start16, &mid);
965
+ /* A match can't begin on a low-surrogate half (needles are well-formed),
966
+ * so resume at the next char boundary. */
967
+ if (mid) start_b += 4;
968
+ const char *found =
969
+ scr_byte_find(s->data + start_b, s->len - start_b, needle->data,
970
+ needle->len);
971
+ if (!found) return -1.0;
972
+ return (double)scr_byte_to_u16_c(s, e, (size_t)(found - s->data));
973
+ }
974
+
975
+ /* substring: slice's clamp-and-swap sibling — ToIntegerOrInfinity both
976
+ * boundaries (NaN → 0), clamp each to [0, len16] (negatives clamp to 0,
977
+ * NOT relative like slice's), swap when start > end, then extract exactly
978
+ * like slice (whose relative/negative handling is inert on the
979
+ * already-clamped values — delegation is exact). */
980
+ ScrStr *scr_str_substring(ScrStr *s, double start, double end) {
981
+ ScrSidx *e = scr_sidx(s);
982
+ double len16 = (double)scr_sidx_len(s, e);
983
+ double a = scr_to_integer_or_infinity(start);
984
+ double b = scr_to_integer_or_infinity(end);
985
+ double fa = a < 0 ? 0 : a > len16 ? len16 : a;
986
+ double fb = b < 0 ? 0 : b > len16 ? len16 : b;
987
+ return fa < fb ? scr_str_slice(s, fa, fb) : scr_str_slice(s, fb, fa);
988
+ }
989
+
990
+ bool scr_str_includes(ScrStr *s, ScrStr *needle) {
991
+ return scr_byte_find(s->data, s->len, needle->data, needle->len) != NULL;
992
+ }
993
+
994
+ bool scr_str_starts_with(ScrStr *s, ScrStr *needle) {
995
+ return needle->len <= s->len &&
996
+ memcmp(s->data, needle->data, needle->len) == 0;
997
+ }
998
+
999
+ bool scr_str_ends_with(ScrStr *s, ScrStr *needle) {
1000
+ return needle->len <= s->len &&
1001
+ memcmp(s->data + (s->len - needle->len), needle->data,
1002
+ needle->len) == 0;
1003
+ }
1004
+
1005
+ static size_t scr_str_clamp_u16_position(double position, size_t len16) {
1006
+ double pos = scr_to_integer_or_infinity(position);
1007
+ return pos <= 0 ? 0 : pos >= (double)len16 ? len16 : (size_t)pos;
1008
+ }
1009
+
1010
+ bool scr_str_starts_with_from(ScrStr *s, ScrStr *needle, double position) {
1011
+ ScrSidx *e = scr_sidx(s);
1012
+ size_t len16 = scr_sidx_len(s, e);
1013
+ size_t start16 = scr_str_clamp_u16_position(position, len16);
1014
+ if (needle->len == 0) return true;
1015
+ bool mid;
1016
+ size_t start_byte = scr_u16_to_byte_c(s, e, start16, &mid);
1017
+ return !mid && needle->len <= s->len - start_byte &&
1018
+ memcmp(s->data + start_byte, needle->data, needle->len) == 0;
1019
+ }
1020
+
1021
+ bool scr_str_ends_with_from(ScrStr *s, ScrStr *needle, double end_position) {
1022
+ ScrSidx *e = scr_sidx(s);
1023
+ size_t len16 = scr_sidx_len(s, e);
1024
+ size_t end16 = scr_str_clamp_u16_position(end_position, len16);
1025
+ size_t needle16 = scr_sidx_len(needle, scr_sidx(needle));
1026
+ if (needle16 == 0) return true;
1027
+ if (needle16 > end16) return false;
1028
+ bool start_mid, end_mid;
1029
+ size_t start_byte = scr_u16_to_byte_c(s, e, end16 - needle16, &start_mid);
1030
+ size_t end_byte = scr_u16_to_byte_c(s, e, end16, &end_mid);
1031
+ return !start_mid && !end_mid && end_byte - start_byte == needle->len &&
1032
+ memcmp(s->data + start_byte, needle->data, needle->len) == 0;
1033
+ }
1034
+
1035
+ /* Resolve one slice() boundary: negatives are relative to the end, then
1036
+ * clamp to [0, len16]. Handles ±Infinity (already through
1037
+ * ToIntegerOrInfinity). */
1038
+ static size_t scr_slice_boundary(double v, size_t len16) {
1039
+ if (v < 0) {
1040
+ double t = v + (double)len16; /* -Infinity stays -Infinity */
1041
+ return t <= 0 ? 0 : (size_t)t;
1042
+ }
1043
+ return v >= (double)len16 ? len16 : (size_t)v;
1044
+ }
1045
+
1046
+ ScrStr *scr_str_slice(ScrStr *s, double start, double end) {
1047
+ ScrSidx *e = scr_sidx(s);
1048
+ size_t len16 = scr_sidx_len(s, e);
1049
+ size_t from = scr_slice_boundary(scr_to_integer_or_infinity(start), len16);
1050
+ size_t to = scr_slice_boundary(scr_to_integer_or_infinity(end), len16);
1051
+ if (from >= to) return scr_str_empty();
1052
+
1053
+ bool from_mid, to_mid;
1054
+ size_t from_b = scr_u16_to_byte_c(s, e, from, &from_mid);
1055
+ size_t to_b = scr_u16_to_byte_c(s, e, to, &to_mid);
1056
+ /* Both *_mid offsets point at the start of the split astral char; the
1057
+ * kept content is the whole chars strictly inside the boundaries. */
1058
+ size_t content_b = from_mid ? from_b + 4 : from_b;
1059
+ size_t content_len = to_b - content_b;
1060
+
1061
+ if (!from_mid && !to_mid)
1062
+ return scr_str_from_span(s->data + from_b, content_len);
1063
+
1064
+ /* Divergence: JS would emit the lone surrogate half; we emit U+FFFD. */
1065
+ size_t total = content_len + (from_mid ? SCR_REPLACEMENT_LEN : 0) +
1066
+ (to_mid ? SCR_REPLACEMENT_LEN : 0);
1067
+ char *tmp = malloc(total);
1068
+ if (!tmp) scr_oom();
1069
+ size_t o = 0;
1070
+ if (from_mid) {
1071
+ memcpy(tmp + o, SCR_REPLACEMENT, SCR_REPLACEMENT_LEN);
1072
+ o += SCR_REPLACEMENT_LEN;
1073
+ }
1074
+ memcpy(tmp + o, s->data + content_b, content_len);
1075
+ o += content_len;
1076
+ if (to_mid) memcpy(tmp + o, SCR_REPLACEMENT, SCR_REPLACEMENT_LEN);
1077
+ ScrStr *r = scr_str_new(tmp, total);
1078
+ free(tmp);
1079
+ return r;
1080
+ }
1081
+
1082
+ ScrStr *scr_str_repeat(ScrStr *s, double count) {
1083
+ double n = scr_to_integer_or_infinity(count);
1084
+ if (n < 0 || (isinf(n) && n > 0)) {
1085
+ scr_trap("scriptc: RangeError: Invalid count value\n");
1086
+ }
1087
+ if (n == 0 || s->len == 0) return scr_str_empty();
1088
+ /* n is a finite non-negative integer here. Reject sizes malloc could not
1089
+ * satisfy anyway before the double→size_t conversion can overflow. */
1090
+ if (n > (double)((SIZE_MAX - sizeof(ScrStr) - 1) / s->len)) scr_oom();
1091
+ size_t total = (size_t)n * s->len;
1092
+ ScrStr *r = scr_str_alloc(total, total);
1093
+ memcpy(r->data, s->data, s->len);
1094
+ size_t filled = s->len;
1095
+ while (filled < total) { /* doubling fill */
1096
+ size_t chunk = filled <= total - filled ? filled : total - filled;
1097
+ memcpy(r->data + filled, r->data, chunk);
1098
+ filled += chunk;
1099
+ }
1100
+ r->data[total] = '\0';
1101
+ return r;
1102
+ }
1103
+
1104
+ /* Exact ECMA-262 WhiteSpace ∪ LineTerminator membership. */
1105
+ static bool scr_is_js_whitespace(uint32_t cp) {
1106
+ switch (cp) {
1107
+ case 0x0009: case 0x000A: case 0x000B: case 0x000C: case 0x000D:
1108
+ case 0x0020: case 0x00A0: case 0x1680: case 0x2028: case 0x2029:
1109
+ case 0x202F: case 0x205F: case 0x3000: case 0xFEFF:
1110
+ return true;
1111
+ default:
1112
+ return cp >= 0x2000 && cp <= 0x200A;
1113
+ }
1114
+ }
1115
+
1116
+ ScrStr *scr_str_trim(ScrStr *s) {
1117
+ size_t b = 0, e = s->len;
1118
+ while (b < e) {
1119
+ size_t adv;
1120
+ uint32_t cp = scr_utf8_decode(s->data + b, &adv);
1121
+ if (!scr_is_js_whitespace(cp)) break;
1122
+ b += adv;
1123
+ }
1124
+ while (e > b) {
1125
+ size_t cs = e - 1; /* back up to the lead byte of the last char */
1126
+ while (cs > b && ((unsigned char)s->data[cs] & 0xC0) == 0x80) cs--;
1127
+ size_t adv;
1128
+ uint32_t cp = scr_utf8_decode(s->data + cs, &adv);
1129
+ if (!scr_is_js_whitespace(cp)) break;
1130
+ e = cs;
1131
+ }
1132
+ return scr_str_from_span(s->data + b, e - b);
1133
+ }
1134
+
1135
+ ScrStr *scr_str_char_at(ScrStr *s, double i) {
1136
+ double idx = scr_to_integer_or_infinity(i);
1137
+ if (!(idx >= 0)) return scr_str_empty();
1138
+ if (idx >= (double)s->len) return scr_str_empty(); /* len16 <= len */
1139
+ ScrSidx *e = scr_sidx(s);
1140
+ if (e->u16len == s->len) { /* all ASCII */
1141
+ return (ScrStr *)&scr_ascii1[(unsigned char)s->data[(size_t)idx]];
1142
+ }
1143
+ bool mid;
1144
+ size_t off = scr_u16_to_byte_c(s, e, (size_t)idx, &mid);
1145
+ if (off >= s->len) return scr_str_empty(); /* out of range */
1146
+ size_t adv;
1147
+ uint32_t cp = scr_utf8_decode(s->data + off, &adv);
1148
+ if (cp >= 0x10000) {
1149
+ /* Divergence: JS returns the lone surrogate half; we return U+FFFD. */
1150
+ return scr_str_new(SCR_REPLACEMENT, SCR_REPLACEMENT_LEN);
1151
+ }
1152
+ return scr_str_from_span(s->data + off, adv);
1153
+ }
1154
+
1155
+ /* trimStart()/trimEnd(): the one-sided halves of trim — same exact JS
1156
+ * WhiteSpace ∪ LineTerminator set, same scan loops. */
1157
+ ScrStr *scr_str_trim_start(ScrStr *s) {
1158
+ size_t b = 0;
1159
+ while (b < s->len) {
1160
+ size_t adv;
1161
+ uint32_t cp = scr_utf8_decode(s->data + b, &adv);
1162
+ if (!scr_is_js_whitespace(cp)) break;
1163
+ b += adv;
1164
+ }
1165
+ return scr_str_from_span(s->data + b, s->len - b);
1166
+ }
1167
+
1168
+ ScrStr *scr_str_trim_end(ScrStr *s) {
1169
+ size_t e = s->len;
1170
+ while (e > 0) {
1171
+ size_t cs = e - 1; /* back up to the lead byte of the last char */
1172
+ while (cs > 0 && ((unsigned char)s->data[cs] & 0xC0) == 0x80) cs--;
1173
+ size_t adv;
1174
+ uint32_t cp = scr_utf8_decode(s->data + cs, &adv);
1175
+ if (!scr_is_js_whitespace(cp)) break;
1176
+ e = cs;
1177
+ }
1178
+ return scr_str_from_span(s->data, e);
1179
+ }
1180
+
1181
+ /* Immortal U+FFFD — the divergence-2 stand-in wherever JS would produce a
1182
+ * lone surrogate (empty-separator split of an astral char, a pad fill
1183
+ * truncated mid-pair). */
1184
+ static const struct { size_t rc; size_t len; size_t cap; char data[4]; }
1185
+ scr_lit_fffd = {SIZE_MAX, 3, 3, "\xEF\xBF\xBD"};
1186
+
1187
+ /* split(separator, limit) with a STRING separator (ECMA-262 22.1.3.23):
1188
+ * limit is ToUint32'd; zero returns [] and reaching the limit stops before
1189
+ * any later separator probes. The no-limit wrapper supplies 2^32-1.
1190
+ * an empty separator splits into single UTF-16 code units ("".split("") is
1191
+ * [] — no probe matches nothing); a non-empty separator splits on every
1192
+ * byte-level occurrence (well-formed UTF-8 is self-synchronizing, so byte
1193
+ * matches are exactly code-point matches), keeping empty pieces at the
1194
+ * ends and between adjacent separators; an empty subject with a non-empty
1195
+ * separator is [""]. Where JS's per-unit split of an astral char would
1196
+ * yield the two lone surrogate halves, each half is U+FFFD here
1197
+ * (divergence 2 — the same substitution the island's boundary marshal
1198
+ * applied). Borrows both; returns a +1 string[]. */
1199
+ ScrArr *scr_str_split_limit(ScrStr *s, ScrStr *sep, double limit_num) {
1200
+ ScrArr *out = scr_arr_new(SCR_ELEM_STR, 0);
1201
+ uint32_t limit = scr_to_uint32(limit_num);
1202
+ if (limit == 0) return out;
1203
+ if (sep->len == 0) {
1204
+ size_t i = 0;
1205
+ while (i < s->len) {
1206
+ size_t adv;
1207
+ uint32_t cp = scr_utf8_decode(s->data + i, &adv);
1208
+ if (cp >= 0x10000) { /* two units in JS: both halves become U+FFFD */
1209
+ scr_arr_push_ref(out, scr_str_retain((ScrStr *)&scr_lit_fffd));
1210
+ if (out->len == limit) return out;
1211
+ scr_arr_push_ref(out, scr_str_retain((ScrStr *)&scr_lit_fffd));
1212
+ } else {
1213
+ scr_arr_push_ref(out, scr_str_from_span(s->data + i, adv));
1214
+ }
1215
+ if (out->len == limit) return out;
1216
+ i += adv;
1217
+ }
1218
+ return out;
1219
+ }
1220
+ size_t start = 0;
1221
+ for (;;) {
1222
+ const char *found = scr_byte_find(s->data + start, s->len - start,
1223
+ sep->data, sep->len);
1224
+ if (!found) break;
1225
+ size_t at = (size_t)(found - s->data);
1226
+ scr_arr_push_ref(out, scr_str_from_span(s->data + start, at - start));
1227
+ if (out->len == limit) return out;
1228
+ start = at + sep->len;
1229
+ }
1230
+ scr_arr_push_ref(out, scr_str_from_span(s->data + start, s->len - start));
1231
+ return out;
1232
+ }
1233
+
1234
+ ScrArr *scr_str_split(ScrStr *s, ScrStr *sep) {
1235
+ return scr_str_split_limit(s, sep, 4294967295.0);
1236
+ }
1237
+
1238
+ /* StringPad (ECMA-262 22.1.3.16/17): target length in UTF-16 units, the
1239
+ * filler built from whole repetitions of `fill` plus a truncated prefix.
1240
+ * A target at or below the length (or an empty fill) returns the receiver
1241
+ * unchanged. A truncation that would split an astral char in the fill
1242
+ * emits U+FFFD for the kept half (one unit, like the lone surrogate JS
1243
+ * keeps — divergence 2). Sizes beyond what malloc can satisfy abort (the
1244
+ * repeat() policy; JS's RangeError fires around 2^29 units). Borrows both;
1245
+ * returns +1. */
1246
+ static ScrStr *scr_pad_impl(ScrStr *s, double maxLength, ScrStr *fill,
1247
+ bool at_start) {
1248
+ double target = scr_to_integer_or_infinity(maxLength);
1249
+ ScrSidx *e = scr_sidx(s);
1250
+ size_t len16 = scr_sidx_len(s, e);
1251
+ if (!(target > (double)len16) || fill->len == 0) return scr_str_retain(s);
1252
+ /* Reject pad sizes malloc could not satisfy before the double→size_t
1253
+ * conversion can overflow (each unit is at most 3 bytes here: BMP chars
1254
+ * and the U+FFFD stand-in; astral chars are 4 bytes for 2 units). */
1255
+ if (target > (double)((SIZE_MAX - sizeof(ScrStr) - 1) / 4)) scr_oom();
1256
+ size_t pad16 = (size_t)target - len16;
1257
+ size_t fill16 = scr_sidx_len(fill, scr_sidx(fill));
1258
+ size_t reps = pad16 / fill16, rem16 = pad16 % fill16;
1259
+ /* The truncated prefix of fill: whole chars while they fit in rem16
1260
+ * units; a final astral char that doesn't fit contributes U+FFFD. */
1261
+ size_t prefix_b = 0, prefix_units = 0;
1262
+ bool prefix_fffd = false;
1263
+ while (prefix_units < rem16) {
1264
+ size_t seq = scr_utf8_seq_len((unsigned char)fill->data[prefix_b]);
1265
+ size_t w = seq == 4 ? 2 : 1;
1266
+ if (prefix_units + w > rem16) { /* astral char split by the truncation */
1267
+ prefix_fffd = true;
1268
+ prefix_units += 1;
1269
+ break;
1270
+ }
1271
+ prefix_b += seq;
1272
+ prefix_units += w;
1273
+ }
1274
+ size_t pad_b = reps * fill->len + prefix_b +
1275
+ (prefix_fffd ? SCR_REPLACEMENT_LEN : 0);
1276
+ if (pad_b > SIZE_MAX - sizeof(ScrStr) - 1 - s->len) scr_oom();
1277
+ size_t total = s->len + pad_b;
1278
+ ScrStr *r = scr_str_alloc(total, total);
1279
+ char *w = r->data + (at_start ? 0 : s->len);
1280
+ for (size_t i = 0; i < reps; i++) {
1281
+ memcpy(w, fill->data, fill->len);
1282
+ w += fill->len;
1283
+ }
1284
+ memcpy(w, fill->data, prefix_b);
1285
+ w += prefix_b;
1286
+ if (prefix_fffd) {
1287
+ memcpy(w, SCR_REPLACEMENT, SCR_REPLACEMENT_LEN);
1288
+ w += SCR_REPLACEMENT_LEN;
1289
+ }
1290
+ memcpy(at_start ? w : r->data, s->data, s->len);
1291
+ r->data[total] = '\0';
1292
+ return r;
1293
+ }
1294
+
1295
+ ScrStr *scr_str_pad_start(ScrStr *s, double maxLength, ScrStr *fill) {
1296
+ return scr_pad_impl(s, maxLength, fill, true);
1297
+ }
1298
+
1299
+ ScrStr *scr_str_pad_end(ScrStr *s, double maxLength, ScrStr *fill) {
1300
+ return scr_pad_impl(s, maxLength, fill, false);
1301
+ }
1302
+
1303
+ /* ── parseInt: ECMA-262 19.2.5, exactly ───────────────────────────────
1304
+ * Skip JS whitespace, take an optional sign, resolve the radix through
1305
+ * ToInt32 (0 → 10 with a 0x/0X hex escape; 16 also strips the prefix;
1306
+ * outside 2..36 → NaN), scan the longest digit prefix, and round the
1307
+ * EXACT mathematical value to double. The fast path accumulates in u64
1308
+ * (u64→double conversion is correctly rounded); digit strings that
1309
+ * overflow 64 bits go through a small base-2^32 bignum and round-to-
1310
+ * nearest-even on the top 53 bits, so thousand-digit inputs in any radix
1311
+ * are Node-exact, Infinity overflow included. */
1312
+
1313
+ static double scr_to_int32_d(double d) {
1314
+ if (!isfinite(d) || d == 0) return 0;
1315
+ double m = fmod(trunc(d), 4294967296.0);
1316
+ if (m < 0) m += 4294967296.0;
1317
+ return m >= 2147483648.0 ? m - 4294967296.0 : m;
1318
+ }
1319
+
1320
+ static int scr_digit_value(char c) {
1321
+ if (c >= '0' && c <= '9') return c - '0';
1322
+ if (c >= 'a' && c <= 'z') return c - 'a' + 10;
1323
+ if (c >= 'A' && c <= 'Z') return c - 'A' + 10;
1324
+ return 99;
1325
+ }
1326
+
1327
+ /* Digit string → double (digits already validated against the radix,
1328
+ * leading zeros stripped, count >= 1). Node (V8) is the oracle, and V8 is
1329
+ * only EXACT where the spec requires it (radix 2, 4, 8, 10, 16, 32); for
1330
+ * every other radix it runs a 32-bit-chunked double accumulation whose
1331
+ * rounding error the spec explicitly permits ("mathInt may be an
1332
+ * implementation-dependent approximation"). Reproduce both behaviors
1333
+ * bit-exactly: the chunk loop for the approximate radixes, correct
1334
+ * rounding (u64 fast path, bignum beyond) for the exact ones. */
1335
+ static double scr_digits_to_double(const char *p, size_t n, int radix) {
1336
+ if (radix != 10 && (radix & (radix - 1)) != 0) {
1337
+ /* V8's generic-radix loop (numbers/conversions.cc): consume the
1338
+ * longest digit run whose multiplier stays below 0xFFFFFFFF/36, then
1339
+ * fold with one double multiply-add per chunk — the rounding of each
1340
+ * fold IS the observable Node behavior. */
1341
+ const uint32_t kMaximumMultiplier = 0xFFFFFFFFu / 36u;
1342
+ double v = 0.0;
1343
+ size_t i = 0;
1344
+ bool done = false;
1345
+ do {
1346
+ uint32_t part = 0, multiplier = 1;
1347
+ for (;;) {
1348
+ if (i == n) {
1349
+ done = true;
1350
+ break;
1351
+ }
1352
+ uint32_t d = (uint32_t)scr_digit_value(p[i]);
1353
+ uint32_t m = multiplier * (uint32_t)radix;
1354
+ if (m > kMaximumMultiplier) break; /* digit starts the next chunk */
1355
+ part = part * (uint32_t)radix + d;
1356
+ multiplier = m;
1357
+ i++;
1358
+ }
1359
+ v = v * (double)multiplier + (double)part;
1360
+ } while (!done);
1361
+ return v;
1362
+ }
1363
+ /* u64 fast path: exact while the accumulator fits. */
1364
+ uint64_t acc = 0;
1365
+ size_t i = 0;
1366
+ for (; i < n; i++) {
1367
+ int dv = scr_digit_value(p[i]);
1368
+ if (acc > (UINT64_MAX - (uint64_t)dv) / (uint64_t)radix) break;
1369
+ acc = acc * (uint64_t)radix + (uint64_t)dv;
1370
+ }
1371
+ if (i == n) return (double)acc;
1372
+ /* Bignum path: base-2^32 limbs, little-endian, multiply-add per digit. */
1373
+ size_t cap = 4 + (n * 6) / 32; /* log2(36) < 6 bits per digit */
1374
+ uint32_t *limbs = malloc(cap * sizeof(uint32_t));
1375
+ if (!limbs) scr_oom();
1376
+ limbs[0] = (uint32_t)acc;
1377
+ limbs[1] = (uint32_t)(acc >> 32);
1378
+ size_t nl = limbs[1] ? 2 : 1;
1379
+ for (; i < n; i++) {
1380
+ uint64_t carry = (uint64_t)scr_digit_value(p[i]);
1381
+ for (size_t j = 0; j < nl; j++) {
1382
+ uint64_t t = (uint64_t)limbs[j] * (uint64_t)radix + carry;
1383
+ limbs[j] = (uint32_t)t;
1384
+ carry = t >> 32;
1385
+ }
1386
+ if (carry) {
1387
+ if (nl == cap) { /* unreachable by the cap bound; belt and braces */
1388
+ cap *= 2;
1389
+ limbs = realloc(limbs, cap * sizeof(uint32_t));
1390
+ if (!limbs) scr_oom();
1391
+ }
1392
+ limbs[nl++] = (uint32_t)carry;
1393
+ }
1394
+ }
1395
+ /* Round the bignum to double: top 53 bits, guard, sticky, half-even. */
1396
+ size_t topbits = 32 - (size_t)__builtin_clz(limbs[nl - 1]);
1397
+ size_t bitlen = 32 * (nl - 1) + topbits;
1398
+ /* bitlen > 64 here (the fast path overflowed), so shift > 0. */
1399
+ size_t shift = bitlen - 54; /* keep 53 mantissa bits + 1 guard bit */
1400
+ uint64_t top = 0;
1401
+ for (size_t k = 0; k < 54; k++) {
1402
+ size_t bit = shift + k;
1403
+ uint64_t b = (limbs[bit / 32] >> (bit % 32)) & 1u;
1404
+ top |= b << k;
1405
+ }
1406
+ bool sticky = false;
1407
+ for (size_t bit = 0; bit < shift && !sticky; bit++) {
1408
+ sticky = ((limbs[bit / 32] >> (bit % 32)) & 1u) != 0;
1409
+ }
1410
+ free(limbs);
1411
+ uint64_t mant = top >> 1;
1412
+ bool guard = (top & 1u) != 0;
1413
+ if (guard && (sticky || (mant & 1u))) mant++;
1414
+ int exp2 = (int)shift + 1;
1415
+ if (mant == (1ull << 53)) { /* rounding carried into a new bit */
1416
+ mant >>= 1;
1417
+ exp2++;
1418
+ }
1419
+ return ldexp((double)mant, exp2); /* overflow → HUGE_VAL, JS's Infinity */
1420
+ }
1421
+
1422
+ double scr_parse_int(ScrStr *s, double radix) {
1423
+ double r32 = scr_to_int32_d(radix);
1424
+ const char *p = s->data;
1425
+ size_t n = s->len, i = 0;
1426
+ while (i < n) {
1427
+ size_t adv;
1428
+ uint32_t cp = scr_utf8_decode(p + i, &adv);
1429
+ if (!scr_is_js_whitespace(cp)) break;
1430
+ i += adv;
1431
+ }
1432
+ double sign = 1.0;
1433
+ if (i < n && (p[i] == '+' || p[i] == '-')) {
1434
+ if (p[i] == '-') sign = -1.0;
1435
+ i++;
1436
+ }
1437
+ int radix_i;
1438
+ bool strip_prefix = true;
1439
+ if (r32 != 0) {
1440
+ if (r32 < 2 || r32 > 36) return NAN;
1441
+ radix_i = (int)r32;
1442
+ if (radix_i != 16) strip_prefix = false;
1443
+ } else {
1444
+ radix_i = 10;
1445
+ }
1446
+ if (strip_prefix && i + 1 < n && p[i] == '0' &&
1447
+ (p[i + 1] == 'x' || p[i + 1] == 'X')) {
1448
+ i += 2;
1449
+ radix_i = 16;
1450
+ }
1451
+ size_t dig_start = i;
1452
+ while (i < n && scr_digit_value(p[i]) < radix_i) i++;
1453
+ if (i == dig_start) return NAN;
1454
+ while (dig_start < i && p[dig_start] == '0') dig_start++;
1455
+ if (dig_start == i) return sign * 0.0; /* all zeros; "-0" is -0 */
1456
+ return sign * scr_digits_to_double(p + dig_start, i - dig_start, radix_i);
1457
+ }
1458
+
1459
+ /* ES parseFloat (ECMA-262 StrDecimalLiteral prefix over the trimmed
1460
+ * input): skip JS whitespace, then take the LONGEST decimal-literal
1461
+ * prefix — [+-]? (Infinity | digits [. digits*] | . digits) with an
1462
+ * optional [eE][+-]?digits exponent — and answer NaN when none exists.
1463
+ * Deliberately narrower than strtod's own grammar (no hex, no
1464
+ * "inf"/"nan" spellings, "Infinity" exact-case only), so the validated
1465
+ * span is COPIED before strtod sees it — handing strtod the raw tail
1466
+ * would let it claim "0x10" as hex where JS answers 0. strtod on the
1467
+ * validated span is correctly rounded (the JSON parser's precedent). */
1468
+ double scr_parse_float(ScrStr *s) {
1469
+ const char *p = s->data;
1470
+ size_t n = s->len, i = 0;
1471
+ while (i < n) {
1472
+ size_t adv;
1473
+ uint32_t cp = scr_utf8_decode(p + i, &adv);
1474
+ if (!scr_is_js_whitespace(cp)) break;
1475
+ i += adv;
1476
+ }
1477
+ size_t start = i;
1478
+ double sign = 1.0;
1479
+ if (i < n && (p[i] == '+' || p[i] == '-')) {
1480
+ if (p[i] == '-') sign = -1.0;
1481
+ i++;
1482
+ }
1483
+ if (i + 8 <= n && memcmp(p + i, "Infinity", 8) == 0) {
1484
+ return sign * (double)INFINITY;
1485
+ }
1486
+ size_t int_digits = 0, frac_digits = 0;
1487
+ while (i < n && p[i] >= '0' && p[i] <= '9') {
1488
+ i++;
1489
+ int_digits++;
1490
+ }
1491
+ if (i < n && p[i] == '.') {
1492
+ size_t j = i + 1;
1493
+ while (j < n && p[j] >= '0' && p[j] <= '9') {
1494
+ j++;
1495
+ frac_digits++;
1496
+ }
1497
+ /* "." alone is not a literal; "1." is (trailing dot, no fraction). */
1498
+ if (int_digits > 0 || frac_digits > 0) i = j;
1499
+ }
1500
+ if (int_digits == 0 && frac_digits == 0) return NAN;
1501
+ size_t end = i;
1502
+ if (i < n && (p[i] == 'e' || p[i] == 'E')) {
1503
+ size_t j = i + 1;
1504
+ if (j < n && (p[j] == '+' || p[j] == '-')) j++;
1505
+ size_t ed = j;
1506
+ while (j < n && p[j] >= '0' && p[j] <= '9') j++;
1507
+ if (j > ed) end = j; /* exponent joins only with digits ("1e" is 1) */
1508
+ }
1509
+ size_t span = end - start;
1510
+ char buf[64];
1511
+ char *tmp = span < sizeof(buf) ? buf : malloc(span + 1);
1512
+ if (!tmp) scr_oom();
1513
+ memcpy(tmp, p + start, span);
1514
+ tmp[span] = '\0';
1515
+ double r = strtod(tmp, NULL);
1516
+ if (tmp != buf) free(tmp);
1517
+ return r;
1518
+ }
1519
+
1520
+ /* ToNumber(string) — ECMA-262 7.1.4.1 StringToNumber, exactly. The
1521
+ * grammar (StringNumericLiteral) differs from parseFloat's in all three
1522
+ * directions: the WHOLE trimmed span must match (trailing garbage → NaN,
1523
+ * where parseFloat keeps the longest prefix), the non-decimal 0x/0o/0b
1524
+ * integer literals join (UNSIGNED only — a sign on them is NaN), and the
1525
+ * empty/whitespace-only string is +0 (parseFloat: NaN). Decimal spans
1526
+ * convert through strtod like parseFloat (copied first — strtod's own
1527
+ * grammar is wider — inheriting correct rounding, the JSON precedent);
1528
+ * 0x/0o/0b digits are the exact mathematical value rounded to nearest-
1529
+ * even via scr_digits_to_double (u64 fast path, bignum beyond 2^64 —
1530
+ * Node-exact for giant hex, Infinity overflow included: power-of-two
1531
+ * radixes take the exact path, never V8's approximate chunk loop). */
1532
+ double scr_string_to_number(ScrStr *s) {
1533
+ const char *p = s->data;
1534
+ size_t b = 0, e = s->len;
1535
+ while (b < e) {
1536
+ size_t adv;
1537
+ uint32_t cp = scr_utf8_decode(p + b, &adv);
1538
+ if (!scr_is_js_whitespace(cp)) break;
1539
+ b += adv;
1540
+ }
1541
+ while (e > b) {
1542
+ size_t cs = e - 1; /* back up to the lead byte of the last char */
1543
+ while (cs > b && ((unsigned char)p[cs] & 0xC0) == 0x80) cs--;
1544
+ size_t adv;
1545
+ uint32_t cp = scr_utf8_decode(p + cs, &adv);
1546
+ if (!scr_is_js_whitespace(cp)) break;
1547
+ e = cs;
1548
+ }
1549
+ if (b == e) return 0.0; /* empty or all StrWhiteSpace */
1550
+ p += b;
1551
+ size_t n = e - b;
1552
+ /* NonDecimalIntegerLiteral: 0x/0X, 0o/0O, 0b/0B — no sign admitted. */
1553
+ if (n >= 2 && p[0] == '0' &&
1554
+ (p[1] == 'x' || p[1] == 'X' || p[1] == 'o' || p[1] == 'O' ||
1555
+ p[1] == 'b' || p[1] == 'B')) {
1556
+ int radix = (p[1] == 'x' || p[1] == 'X') ? 16
1557
+ : (p[1] == 'o' || p[1] == 'O') ? 8
1558
+ : 2;
1559
+ size_t i = 2, dig_start = 2;
1560
+ while (i < n && scr_digit_value(p[i]) < radix) i++;
1561
+ if (i == dig_start || i != n) return NAN; /* no digits, or garbage */
1562
+ while (dig_start < i && p[dig_start] == '0') dig_start++;
1563
+ if (dig_start == i) return 0.0;
1564
+ return scr_digits_to_double(p + dig_start, i - dig_start, radix);
1565
+ }
1566
+ /* StrDecimalLiteral, whole-span: [+-]? (Infinity | digits [. digits*]
1567
+ * | . digits) ([eE][+-]?digits)? — nothing before, nothing after. */
1568
+ size_t i = 0;
1569
+ double sign = 1.0;
1570
+ if (p[0] == '+' || p[0] == '-') {
1571
+ if (p[0] == '-') sign = -1.0;
1572
+ i = 1;
1573
+ }
1574
+ if (n - i == 8 && memcmp(p + i, "Infinity", 8) == 0) {
1575
+ return sign * (double)INFINITY;
1576
+ }
1577
+ size_t int_digits = 0, frac_digits = 0;
1578
+ while (i < n && p[i] >= '0' && p[i] <= '9') {
1579
+ i++;
1580
+ int_digits++;
1581
+ }
1582
+ if (i < n && p[i] == '.') {
1583
+ i++;
1584
+ while (i < n && p[i] >= '0' && p[i] <= '9') {
1585
+ i++;
1586
+ frac_digits++;
1587
+ }
1588
+ }
1589
+ if (int_digits == 0 && frac_digits == 0) return NAN; /* ".", "+", "e5" */
1590
+ if (i < n && (p[i] == 'e' || p[i] == 'E')) {
1591
+ i++;
1592
+ if (i < n && (p[i] == '+' || p[i] == '-')) i++;
1593
+ size_t ed = i;
1594
+ while (i < n && p[i] >= '0' && p[i] <= '9') i++;
1595
+ if (i == ed) return NAN; /* "1e", "1e+" — exponent needs digits */
1596
+ }
1597
+ if (i != n) return NAN; /* trailing garbage ("1_000", "1.2.3", "12px") */
1598
+ char buf[64];
1599
+ char *tmp = n < sizeof(buf) ? buf : malloc(n + 1);
1600
+ if (!tmp) scr_oom();
1601
+ memcpy(tmp, p, n);
1602
+ tmp[n] = '\0';
1603
+ double r = strtod(tmp, NULL);
1604
+ if (tmp != buf) free(tmp);
1605
+ return r;
1606
+ }
1607
+
1608
+ ScrStr *scr_f64_to_scrstr(double x) {
1609
+ char buf[32];
1610
+ size_t len = scr_f64_to_str(x, buf);
1611
+ return scr_str_new(buf, len);
1612
+ }
1613
+
1614
+ /* ── encodeURIComponent / encodeURI ───────────────────────────────────
1615
+ * ECMA-262 Encode() over the UTF-8 storage. The spec transcodes UTF-16
1616
+ * to UTF-8 and percent-encodes every byte outside the unescaped set —
1617
+ * storage here already IS well-formed UTF-8 (lone surrogates were
1618
+ * substituted with U+FFFD at their producers, SEMANTICS.md 2), so the
1619
+ * walk is byte-wise and the spec's URIError arm (unpaired surrogates)
1620
+ * is unreachable: the encoders are total. Unescaped sets are the
1621
+ * spec's: uriUnescaped = ALPHA / DIGIT / -_.!~*'() for
1622
+ * encodeURIComponent; encodeURI keeps uriReserved ;/?:@&=+$, and #
1623
+ * too. Hex digits are uppercase, per spec. Borrows s; result +1. */
1624
+ static bool scr_uri_unescaped(unsigned char c, bool keep_reserved) {
1625
+ if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')) return true;
1626
+ switch (c) {
1627
+ case '-': case '_': case '.': case '!': case '~': case '*': case '\'': case '(': case ')':
1628
+ return true;
1629
+ default:
1630
+ break;
1631
+ }
1632
+ if (!keep_reserved) return false;
1633
+ switch (c) {
1634
+ case ';': case '/': case '?': case ':': case '@': case '&': case '=':
1635
+ case '+': case '$': case ',': case '#':
1636
+ return true;
1637
+ default:
1638
+ return false;
1639
+ }
1640
+ }
1641
+
1642
+ static ScrStr *scr_encode_uri_impl(ScrStr *s, bool keep_reserved) {
1643
+ const unsigned char *b = (const unsigned char *)s->data;
1644
+ size_t n = s->len, out_len = 0;
1645
+ for (size_t i = 0; i < n; i++) out_len += scr_uri_unescaped(b[i], keep_reserved) ? 1 : 3;
1646
+ if (out_len == n) return scr_str_retain(s); /* nothing escapes — share */
1647
+ ScrStr *out = scr_str_alloc_raw(out_len, out_len);
1648
+ static const char hex[] = "0123456789ABCDEF";
1649
+ char *w = out->data;
1650
+ for (size_t i = 0; i < n; i++) {
1651
+ if (scr_uri_unescaped(b[i], keep_reserved)) {
1652
+ *w++ = (char)b[i];
1653
+ } else {
1654
+ *w++ = '%';
1655
+ *w++ = hex[b[i] >> 4];
1656
+ *w++ = hex[b[i] & 0xF];
1657
+ }
1658
+ }
1659
+ out->len = out_len;
1660
+ out->data[out_len] = '\0';
1661
+ return out;
1662
+ }
1663
+
1664
+ ScrStr *scr_encode_uri_component(ScrStr *s) { return scr_encode_uri_impl(s, false); }
1665
+
1666
+ ScrStr *scr_encode_uri(ScrStr *s) { return scr_encode_uri_impl(s, true); }
1667
+
1668
+ /* ── isWellFormed / toWellFormed ──────────────────────────────────────
1669
+ * Storage here IS well-formed by invariant: every producer substitutes
1670
+ * the lone surrogates JS strings could carry with U+FFFD at creation
1671
+ * (SEMANTICS.md 2), so no string this runtime can hold is ill-formed.
1672
+ * isWellFormed answers the constant the invariant guarantees and
1673
+ * toWellFormed is the identity (per spec both are no-ops on well-formed
1674
+ * input). A program whose Node run would see `false` already diverged
1675
+ * at the string's creation, not here. */
1676
+ bool scr_str_is_well_formed(ScrStr *s) {
1677
+ (void)s;
1678
+ return true;
1679
+ }
1680
+
1681
+ ScrStr *scr_str_to_well_formed(ScrStr *s) { return scr_str_retain(s); }
1682
+
1683
+ /* Immortal interned booleans (same layout trick the emitter uses for
1684
+ * string literals). */
1685
+ static const struct { size_t rc; size_t len; size_t cap; char data[5]; }
1686
+ scr_lit_true = {SIZE_MAX, 4, 4, "true"};
1687
+ static const struct { size_t rc; size_t len; size_t cap; char data[6]; }
1688
+ scr_lit_false = {SIZE_MAX, 5, 5, "false"};
1689
+
1690
+ ScrStr *scr_bool_to_scrstr(bool b) {
1691
+ return b ? (ScrStr *)&scr_lit_true : (ScrStr *)&scr_lit_false;
1692
+ }
1693
+
1694
+ /* The string iterator's step (for-of over strings): the full CHARACTER at
1695
+ * UTF-16 index i — one code POINT, so an astral char comes back as its
1696
+ * whole two-unit string where charAt would truncate to U+FFFD. The
1697
+ * iterating loop advances by the result's UTF-16 length, exactly JS's
1698
+ * String[Symbol.iterator] contract. Storage is valid UTF-8 by invariant
1699
+ * (literals canonicalized lone surrogates to U+FFFD at creation), so every
1700
+ * decode is a whole char; an i addressing the LOW half of an astral pair
1701
+ * (unreachable from the iterator, which only lands on char starts) answers
1702
+ * the containing char. Out of range → empty string. Borrows s; +1. */
1703
+ ScrStr *scr_str_cp_at(ScrStr *s, double i) {
1704
+ double idx = scr_to_integer_or_infinity(i);
1705
+ if (!(idx >= 0)) return scr_str_empty();
1706
+ if (idx >= (double)s->len) return scr_str_empty(); /* len16 <= len */
1707
+ ScrSidx *e = scr_sidx(s);
1708
+ if (e->u16len == s->len) { /* all ASCII */
1709
+ return (ScrStr *)&scr_ascii1[(unsigned char)s->data[(size_t)idx]];
1710
+ }
1711
+ bool mid;
1712
+ size_t off = scr_u16_to_byte_c(s, e, (size_t)idx, &mid);
1713
+ if (off >= s->len) return scr_str_empty(); /* out of range */
1714
+ size_t adv;
1715
+ (void)scr_utf8_decode(s->data + off, &adv);
1716
+ return scr_str_from_span(s->data + off, adv);
1717
+ }
1718
+
1719
+
1720
+ /* ── the URI component codecs (encodeURIComponent/decodeURIComponent) ──
1721
+ * ECMA-262 Encode/Decode with the component sets, byte-wise over the
1722
+ * runtime's UTF-8 storage: the spec percent-encodes each code point's
1723
+ * UTF-8 bytes, which over UTF-8 storage is exactly a byte scan, and
1724
+ * Decode's "octets must form a valid UTF-8 encoding" is a strict
1725
+ * validation of the assembled escape bytes (raw bytes copy through —
1726
+ * they are the already-valid encoding of code points the spec leaves
1727
+ * untouched). */
1728
+
1729
+ /* The component unreserved set: ALPHA / DIGIT / - _ . ! ~ * ' ( ). */
1730
+ static bool scr_uri_unreserved(unsigned char c) {
1731
+ if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')) return true;
1732
+ switch (c) {
1733
+ case '-': case '_': case '.': case '!': case '~':
1734
+ case '*': case '\'': case '(': case ')':
1735
+ return true;
1736
+ default:
1737
+ return false;
1738
+ }
1739
+ }
1740
+
1741
+ ScrStr *scr_str_encode_uri_component(ScrStr *s) {
1742
+ size_t extra = 0;
1743
+ for (size_t i = 0; i < s->len; i++) {
1744
+ if (!scr_uri_unreserved((unsigned char)s->data[i])) extra += 2;
1745
+ }
1746
+ if (extra == 0) {
1747
+ scr_str_retain(s);
1748
+ return s;
1749
+ }
1750
+ static const char hex[] = "0123456789ABCDEF";
1751
+ ScrStr *out = scr_str_alloc_raw(s->len + extra, s->len + extra);
1752
+ char *w = out->data;
1753
+ for (size_t i = 0; i < s->len; i++) {
1754
+ unsigned char c = (unsigned char)s->data[i];
1755
+ if (scr_uri_unreserved(c)) {
1756
+ *w++ = (char)c;
1757
+ } else {
1758
+ *w++ = '%';
1759
+ *w++ = hex[c >> 4];
1760
+ *w++ = hex[c & 0xf];
1761
+ }
1762
+ }
1763
+ out->data[out->len] = '\0';
1764
+ return out;
1765
+ }
1766
+
1767
+ static void scr_uri_malformed(void) {
1768
+ scr_throw_error_named(scr_str_new("URIError", 8),
1769
+ scr_str_new("URI malformed", 13));
1770
+ }
1771
+
1772
+ /* One %XX escape's byte, or -1 (bad hex / truncated). */
1773
+ static int scr_uri_hex_byte(const char *p, size_t rem) {
1774
+ if (rem < 3 || p[0] != '%') return -1;
1775
+ int hi, lo;
1776
+ char a = p[1], b = p[2];
1777
+ if (a >= '0' && a <= '9') hi = a - '0';
1778
+ else if (a >= 'A' && a <= 'F') hi = a - 'A' + 10;
1779
+ else if (a >= 'a' && a <= 'f') hi = a - 'a' + 10;
1780
+ else return -1;
1781
+ if (b >= '0' && b <= '9') lo = b - '0';
1782
+ else if (b >= 'A' && b <= 'F') lo = b - 'A' + 10;
1783
+ else if (b >= 'a' && b <= 'f') lo = b - 'a' + 10;
1784
+ else return -1;
1785
+ return (hi << 4) | lo;
1786
+ }
1787
+
1788
+ /* The non-throwing core of decodeURIComponent: NULL on malformed input
1789
+ * (bad hex, invalid UTF-8 octets) instead of the URIError — the
1790
+ * querystring unit's unescape needs exactly the try/catch shape Node's
1791
+ * qsUnescape wraps around decodeURIComponent (scr_qs.c), and the throwing
1792
+ * entry point below stays byte-identical by rethrowing over NULL. */
1793
+ ScrStr *scr_str_decode_uri_component_try(ScrStr *s) {
1794
+ /* Decoding only ever shrinks (%XX → 1 byte), so len is a safe cap. */
1795
+ ScrStr *out = scr_str_alloc_raw(0, s->len);
1796
+ size_t w = 0;
1797
+ const char *p = s->data;
1798
+ size_t n = s->len, i = 0;
1799
+ while (i < n) {
1800
+ if (p[i] != '%') {
1801
+ out->data[w++] = p[i++];
1802
+ continue;
1803
+ }
1804
+ int b0 = scr_uri_hex_byte(p + i, n - i);
1805
+ if (b0 < 0) goto malformed;
1806
+ i += 3;
1807
+ if (b0 < 0x80) {
1808
+ /* The empty component reserved set: every ASCII escape decodes. */
1809
+ out->data[w++] = (char)b0;
1810
+ continue;
1811
+ }
1812
+ /* Multibyte: the continuation bytes must ALSO be escapes (a raw byte
1813
+ * is its own code point in the spec's string, never a continuation),
1814
+ * and the whole sequence must be strictly valid UTF-8. */
1815
+ int need; /* continuation count */
1816
+ int lo = 0x80, hi = 0xBF; /* first continuation's tightened range */
1817
+ if (b0 >= 0xC2 && b0 <= 0xDF) need = 1;
1818
+ else if (b0 == 0xE0) { need = 2; lo = 0xA0; }
1819
+ else if (b0 == 0xED) { need = 2; hi = 0x9F; } /* no surrogates */
1820
+ else if (b0 >= 0xE1 && b0 <= 0xEF) need = 2;
1821
+ else if (b0 == 0xF0) { need = 3; lo = 0x90; }
1822
+ else if (b0 == 0xF4) { need = 3; hi = 0x8F; } /* <= U+10FFFF */
1823
+ else if (b0 >= 0xF1 && b0 <= 0xF3) need = 3;
1824
+ else goto malformed; /* 0x80..0xC1, 0xF5..0xFF: never a leading byte */
1825
+ out->data[w++] = (char)b0;
1826
+ for (int k = 0; k < need; k++) {
1827
+ int bc = scr_uri_hex_byte(p + i, n - i);
1828
+ if (bc < 0) goto malformed;
1829
+ if (k == 0 ? (bc < lo || bc > hi) : (bc < 0x80 || bc > 0xBF)) goto malformed;
1830
+ i += 3;
1831
+ out->data[w++] = (char)bc;
1832
+ }
1833
+ }
1834
+ out->len = w;
1835
+ out->data[w] = '\0';
1836
+ return out;
1837
+ malformed:
1838
+ scr_str_release(out);
1839
+ return NULL;
1840
+ }
1841
+
1842
+ ScrStr *scr_str_decode_uri_component(ScrStr *s) {
1843
+ ScrStr *out = scr_str_decode_uri_component_try(s);
1844
+ if (!out) {
1845
+ scr_uri_malformed();
1846
+ return NULL;
1847
+ }
1848
+ return out;
1849
+ }