@scriptc/compiler 0.1.7 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1043) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +98 -39
  2. package/ambient/scriptc-overrides.d.ts +10 -6
  3. package/ambient/scriptc.d.ts +15 -0
  4. package/dist/backend/build-cache.d.ts +1 -3
  5. package/dist/backend/build-cache.js +3 -22
  6. package/dist/backend/build-cache.js.map +1 -1
  7. package/dist/backend/cache-root.d.ts +3 -0
  8. package/dist/backend/cache-root.js +23 -0
  9. package/dist/backend/cache-root.js.map +1 -0
  10. package/dist/backend/cycle-analysis.d.ts +15 -0
  11. package/dist/backend/cycle-analysis.js +108 -0
  12. package/dist/backend/cycle-analysis.js.map +1 -0
  13. package/dist/backend/cycle-analysis.test.js +124 -0
  14. package/dist/backend/cycle-analysis.test.js.map +1 -0
  15. package/dist/backend/executable-features.d.ts +4 -0
  16. package/dist/backend/executable-features.js +42 -0
  17. package/dist/backend/executable-features.js.map +1 -0
  18. package/dist/backend/external-c.d.ts +5 -27
  19. package/dist/backend/external-c.js +5 -40
  20. package/dist/backend/external-c.js.map +1 -1
  21. package/dist/backend/ffi-callbacks.d.ts +2 -3
  22. package/dist/backend/ffi-callbacks.js +2 -3
  23. package/dist/backend/ffi-callbacks.js.map +1 -1
  24. package/dist/backend/library-identity-markers.d.ts +4 -9
  25. package/dist/backend/library-identity-markers.js +11 -49
  26. package/dist/backend/library-identity-markers.js.map +1 -1
  27. package/dist/backend/library-pack.d.ts +5 -0
  28. package/dist/backend/library-pack.js +123 -0
  29. package/dist/backend/library-pack.js.map +1 -0
  30. package/dist/backend/link-plan-core.d.ts +20 -0
  31. package/dist/backend/link-plan-core.js +18 -0
  32. package/dist/backend/link-plan-core.js.map +1 -0
  33. package/dist/backend/link-plan.d.ts +1 -1
  34. package/dist/backend/link-plan.js +16 -17
  35. package/dist/backend/link-plan.js.map +1 -1
  36. package/dist/backend/link-trace.d.ts +2 -0
  37. package/dist/backend/link-trace.js +24 -0
  38. package/dist/backend/link-trace.js.map +1 -0
  39. package/dist/backend/linker.js +1 -1
  40. package/dist/backend/linker.js.map +1 -1
  41. package/dist/backend/literals.d.ts +9 -0
  42. package/dist/backend/literals.js +35 -0
  43. package/dist/backend/literals.js.map +1 -0
  44. package/dist/backend/literals.test.d.ts +1 -0
  45. package/dist/backend/literals.test.js +53 -0
  46. package/dist/backend/literals.test.js.map +1 -0
  47. package/dist/backend/llvm/blocks.d.ts +2 -0
  48. package/dist/backend/llvm/blocks.js +9 -4
  49. package/dist/backend/llvm/blocks.js.map +1 -1
  50. package/dist/backend/llvm/blocks.test.d.ts +1 -0
  51. package/dist/backend/llvm/blocks.test.js +91 -0
  52. package/dist/backend/llvm/blocks.test.js.map +1 -0
  53. package/dist/backend/llvm/classes.d.ts +14 -8
  54. package/dist/backend/llvm/classes.js +88 -30
  55. package/dist/backend/llvm/classes.js.map +1 -1
  56. package/dist/backend/llvm/common.d.ts +5 -1
  57. package/dist/backend/llvm/common.js +45 -4
  58. package/dist/backend/llvm/common.js.map +1 -1
  59. package/dist/backend/llvm/debug-info.js +2 -7
  60. package/dist/backend/llvm/debug-info.js.map +1 -1
  61. package/dist/backend/llvm/debug-info.test.d.ts +1 -0
  62. package/dist/backend/llvm/debug-info.test.js +110 -0
  63. package/dist/backend/llvm/debug-info.test.js.map +1 -0
  64. package/dist/backend/llvm/dyn.d.ts +21 -2
  65. package/dist/backend/llvm/dyn.js +647 -251
  66. package/dist/backend/llvm/dyn.js.map +1 -1
  67. package/dist/backend/llvm/emitter.d.ts +596 -1
  68. package/dist/backend/llvm/emitter.js +769 -425
  69. package/dist/backend/llvm/emitter.js.map +1 -1
  70. package/dist/backend/llvm/emitter.test.d.ts +1 -0
  71. package/dist/backend/llvm/emitter.test.js +179 -0
  72. package/dist/backend/llvm/emitter.test.js.map +1 -0
  73. package/dist/backend/llvm/expr-async.js +23 -14
  74. package/dist/backend/llvm/expr-async.js.map +1 -1
  75. package/dist/backend/llvm/expr-bytes.d.ts +2 -2
  76. package/dist/backend/llvm/expr-bytes.js +60 -31
  77. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  78. package/dist/backend/llvm/expr-callbacks.d.ts +1 -1
  79. package/dist/backend/llvm/expr-callbacks.js +25 -22
  80. package/dist/backend/llvm/expr-callbacks.js.map +1 -1
  81. package/dist/backend/llvm/expr-calls.js +136 -35
  82. package/dist/backend/llvm/expr-calls.js.map +1 -1
  83. package/dist/backend/llvm/expr-containers.d.ts +1 -1
  84. package/dist/backend/llvm/expr-containers.js +43 -14
  85. package/dist/backend/llvm/expr-containers.js.map +1 -1
  86. package/dist/backend/llvm/expr-context.d.ts +5 -260
  87. package/dist/backend/llvm/expr-control.js +10 -6
  88. package/dist/backend/llvm/expr-control.js.map +1 -1
  89. package/dist/backend/llvm/expr-dispatch.d.ts +1 -1
  90. package/dist/backend/llvm/expr-dispatch.js +2 -0
  91. package/dist/backend/llvm/expr-dispatch.js.map +1 -1
  92. package/dist/backend/llvm/expr-dynamic.js +78 -81
  93. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  94. package/dist/backend/llvm/expr-island.d.ts +1 -1
  95. package/dist/backend/llvm/expr-island.js +11 -7
  96. package/dist/backend/llvm/expr-island.js.map +1 -1
  97. package/dist/backend/llvm/expr-primitives.d.ts +1 -1
  98. package/dist/backend/llvm/expr-primitives.js +62 -31
  99. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  100. package/dist/backend/llvm/expr-primitives.test.js +1 -1
  101. package/dist/backend/llvm/expr-records.d.ts +5 -1
  102. package/dist/backend/llvm/expr-records.js +54 -7
  103. package/dist/backend/llvm/expr-records.js.map +1 -1
  104. package/dist/backend/llvm/expr-stream-bridges.d.ts +4 -4
  105. package/dist/backend/llvm/expr-stream-bridges.js +220 -131
  106. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  107. package/dist/backend/llvm/expr-stream-bridges.test.d.ts +1 -0
  108. package/dist/backend/llvm/expr-stream-bridges.test.js +55 -0
  109. package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -0
  110. package/dist/backend/llvm/expr-stream-callbacks.d.ts +1 -1
  111. package/dist/backend/llvm/expr-stream-callbacks.js +12 -12
  112. package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
  113. package/dist/backend/llvm/layouts.d.ts +19 -0
  114. package/dist/backend/llvm/layouts.js +12 -0
  115. package/dist/backend/llvm/layouts.js.map +1 -0
  116. package/dist/backend/llvm/lib-abi.d.ts +19 -0
  117. package/dist/backend/llvm/lib-abi.js +82 -0
  118. package/dist/backend/llvm/lib-abi.js.map +1 -0
  119. package/dist/backend/llvm/lib-connect.d.ts +2 -0
  120. package/dist/backend/llvm/lib-connect.js +51 -0
  121. package/dist/backend/llvm/lib-connect.js.map +1 -0
  122. package/dist/backend/llvm/lib-datagram.d.ts +2 -0
  123. package/dist/backend/llvm/lib-datagram.js +135 -0
  124. package/dist/backend/llvm/lib-datagram.js.map +1 -0
  125. package/dist/backend/llvm/lib-dispatch.js +50 -6
  126. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  127. package/dist/backend/llvm/lib-filesystem.js +30 -18
  128. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  129. package/dist/backend/llvm/lib-http2.d.ts +2 -0
  130. package/dist/backend/llvm/lib-http2.js +215 -0
  131. package/dist/backend/llvm/lib-http2.js.map +1 -0
  132. package/dist/backend/llvm/lib-lookup.d.ts +2 -0
  133. package/dist/backend/llvm/lib-lookup.js +39 -0
  134. package/dist/backend/llvm/lib-lookup.js.map +1 -0
  135. package/dist/backend/llvm/lib-network.js +25 -2
  136. package/dist/backend/llvm/lib-network.js.map +1 -1
  137. package/dist/backend/llvm/lib-process.js +44 -19
  138. package/dist/backend/llvm/lib-process.js.map +1 -1
  139. package/dist/backend/llvm/lib-shared.js +162 -3
  140. package/dist/backend/llvm/lib-shared.js.map +1 -1
  141. package/dist/backend/llvm/lib-stream.js +3 -2
  142. package/dist/backend/llvm/lib-stream.js.map +1 -1
  143. package/dist/backend/llvm/lib-test.d.ts +2 -0
  144. package/dist/backend/llvm/lib-test.js +34 -0
  145. package/dist/backend/llvm/lib-test.js.map +1 -0
  146. package/dist/backend/llvm/lib-tls.d.ts +2 -0
  147. package/dist/backend/llvm/lib-tls.js +82 -0
  148. package/dist/backend/llvm/lib-tls.js.map +1 -0
  149. package/dist/backend/llvm/shapes.d.ts +10 -9
  150. package/dist/backend/llvm/shapes.js +42 -131
  151. package/dist/backend/llvm/shapes.js.map +1 -1
  152. package/dist/backend/llvm/unsupported.d.ts +1 -0
  153. package/dist/backend/llvm/unsupported.js +1 -2
  154. package/dist/backend/llvm/unsupported.js.map +1 -1
  155. package/dist/backend/llvm/walkers.js +1 -7
  156. package/dist/backend/llvm/walkers.js.map +1 -1
  157. package/dist/backend/mangle.d.ts +2 -2
  158. package/dist/backend/mangle.js +16 -5
  159. package/dist/backend/mangle.js.map +1 -1
  160. package/dist/backend/{c/may-throw.d.ts → may-throw.d.ts} +1 -1
  161. package/dist/backend/{c/may-throw.js → may-throw.js} +51 -46
  162. package/dist/backend/may-throw.js.map +1 -0
  163. package/dist/backend/may-throw.test.d.ts +1 -0
  164. package/dist/backend/may-throw.test.js +58 -0
  165. package/dist/backend/may-throw.test.js.map +1 -0
  166. package/dist/backend/native-codegen-core.d.ts +22 -0
  167. package/dist/backend/native-codegen-core.js +44 -0
  168. package/dist/backend/native-codegen-core.js.map +1 -0
  169. package/dist/backend/native-codegen.d.ts +3 -19
  170. package/dist/backend/native-codegen.js +5 -44
  171. package/dist/backend/native-codegen.js.map +1 -1
  172. package/dist/backend/native-codegen.test.js +2 -2
  173. package/dist/backend/native-codegen.test.js.map +1 -1
  174. package/dist/backend/native-link-info-core.d.ts +94 -0
  175. package/dist/backend/native-link-info-core.js +62 -0
  176. package/dist/backend/native-link-info-core.js.map +1 -0
  177. package/dist/backend/native-link-info.d.ts +3 -88
  178. package/dist/backend/native-link-info.js +12 -243
  179. package/dist/backend/native-link-info.js.map +1 -1
  180. package/dist/backend/native-link-info.test.js +41 -146
  181. package/dist/backend/native-link-info.test.js.map +1 -1
  182. package/dist/backend/native-toolchain.d.ts +12 -30
  183. package/dist/backend/native-toolchain.js +83 -233
  184. package/dist/backend/native-toolchain.js.map +1 -1
  185. package/dist/backend/native-toolchain.test.js +77 -5
  186. package/dist/backend/native-toolchain.test.js.map +1 -1
  187. package/dist/backend/native-tools.d.ts +24 -0
  188. package/dist/backend/native-tools.js +33 -0
  189. package/dist/backend/native-tools.js.map +1 -0
  190. package/dist/backend/object-localize.js +19 -8
  191. package/dist/backend/object-localize.js.map +1 -1
  192. package/dist/backend/object-localize.test.js +22 -0
  193. package/dist/backend/object-localize.test.js.map +1 -1
  194. package/dist/backend/runtime-abi.d.ts +2 -2
  195. package/dist/backend/runtime-abi.js +2 -2
  196. package/dist/backend/runtime-pack-core.d.ts +101 -0
  197. package/dist/backend/runtime-pack-core.js +172 -0
  198. package/dist/backend/runtime-pack-core.js.map +1 -0
  199. package/dist/backend/runtime-pack-native.d.ts +21 -0
  200. package/dist/backend/runtime-pack-native.js +73 -0
  201. package/dist/backend/runtime-pack-native.js.map +1 -0
  202. package/dist/backend/runtime-pack-targets.test.js +1 -1
  203. package/dist/backend/runtime-pack.d.ts +3 -83
  204. package/dist/backend/runtime-pack.js +8 -151
  205. package/dist/backend/runtime-pack.js.map +1 -1
  206. package/dist/backend/runtime-pack.test.js +24 -1
  207. package/dist/backend/runtime-pack.test.js.map +1 -1
  208. package/dist/backend/target-diagnostics.d.ts +22 -0
  209. package/dist/backend/target-diagnostics.js +108 -0
  210. package/dist/backend/target-diagnostics.js.map +1 -0
  211. package/dist/backend/target-platform.d.ts +15 -0
  212. package/dist/backend/target-platform.js +72 -0
  213. package/dist/backend/target-platform.js.map +1 -0
  214. package/dist/backend/targets.d.ts +13 -4
  215. package/dist/backend/targets.js +103 -34
  216. package/dist/backend/targets.js.map +1 -1
  217. package/dist/backend/targets.test.js +72 -4
  218. package/dist/backend/targets.test.js.map +1 -1
  219. package/dist/backend/toolchain-environment.d.ts +6 -0
  220. package/dist/backend/toolchain-environment.js +99 -0
  221. package/dist/backend/toolchain-environment.js.map +1 -0
  222. package/dist/backend/vendor-archives.d.ts +1 -9
  223. package/dist/backend/vendor-archives.js +2 -9
  224. package/dist/backend/vendor-archives.js.map +1 -1
  225. package/dist/backend/vendor-inputs.d.ts +9 -0
  226. package/dist/backend/vendor-inputs.js +10 -0
  227. package/dist/backend/vendor-inputs.js.map +1 -0
  228. package/dist/backend/warm-cache.d.ts +3 -0
  229. package/dist/backend/warm-cache.js +41 -0
  230. package/dist/backend/warm-cache.js.map +1 -0
  231. package/dist/cli/command.d.ts +3 -0
  232. package/dist/cli/command.js +328 -0
  233. package/dist/cli/command.js.map +1 -0
  234. package/dist/cli/host.d.ts +24 -0
  235. package/dist/cli/host.js +2 -0
  236. package/dist/cli/host.js.map +1 -0
  237. package/dist/cli/output-options.d.ts +26 -0
  238. package/dist/cli/output-options.js +60 -0
  239. package/dist/cli/output-options.js.map +1 -0
  240. package/dist/cli/paths.d.ts +12 -0
  241. package/dist/cli/paths.js +42 -0
  242. package/dist/cli/paths.js.map +1 -0
  243. package/dist/cli/usage.d.ts +74 -0
  244. package/dist/cli/usage.js +86 -0
  245. package/dist/cli/usage.js.map +1 -0
  246. package/dist/cli/wasi-paths.d.ts +8 -0
  247. package/dist/cli/wasi-paths.js +41 -0
  248. package/dist/cli/wasi-paths.js.map +1 -0
  249. package/dist/cli/wasi-runner.d.ts +2 -0
  250. package/dist/cli/wasi-runner.js +28 -0
  251. package/dist/cli/wasi-runner.js.map +1 -0
  252. package/dist/compat/fetch-profile.js +37 -7
  253. package/dist/compat/fetch-profile.js.map +1 -1
  254. package/dist/compile-types.d.ts +162 -0
  255. package/dist/compile-types.js +2 -0
  256. package/dist/compile-types.js.map +1 -0
  257. package/dist/coverage/report.js +11 -5
  258. package/dist/coverage/report.js.map +1 -1
  259. package/dist/coverage/surface-manifest.js +5 -2
  260. package/dist/coverage/surface-manifest.js.map +1 -1
  261. package/dist/diagnostics/diagnostic.js +5 -10
  262. package/dist/diagnostics/diagnostic.js.map +1 -1
  263. package/dist/executable/executable-cache.d.ts +3 -4
  264. package/dist/executable/executable-cache.js +5 -6
  265. package/dist/executable/executable-cache.js.map +1 -1
  266. package/dist/executable/executable-cache.test.js +16 -17
  267. package/dist/executable/executable-cache.test.js.map +1 -1
  268. package/dist/executable/prepare.d.ts +14 -0
  269. package/dist/executable/prepare.js +66 -0
  270. package/dist/executable/prepare.js.map +1 -0
  271. package/dist/ffi/ffi-manifest.d.ts +11 -4
  272. package/dist/ffi/ffi-manifest.js +170 -58
  273. package/dist/ffi/ffi-manifest.js.map +1 -1
  274. package/dist/ffi/ffi-manifest.test.d.ts +1 -0
  275. package/dist/ffi/ffi-manifest.test.js +111 -0
  276. package/dist/ffi/ffi-manifest.test.js.map +1 -0
  277. package/dist/format-integer.d.ts +3 -0
  278. package/dist/format-integer.js +14 -0
  279. package/dist/format-integer.js.map +1 -0
  280. package/dist/frontend/analysis.d.ts +5 -0
  281. package/dist/frontend/analysis.js +88 -0
  282. package/dist/frontend/analysis.js.map +1 -0
  283. package/dist/frontend/arguments-usage.d.ts +1 -3
  284. package/dist/frontend/arguments-usage.js.map +1 -1
  285. package/dist/frontend/builtin-modules.d.ts +1 -1
  286. package/dist/frontend/builtin-modules.js +1 -1
  287. package/dist/frontend/builtin-modules.js.map +1 -1
  288. package/dist/frontend/cjs-lexer.d.ts +4 -25
  289. package/dist/frontend/cjs-lexer.js +6 -806
  290. package/dist/frontend/cjs-lexer.js.map +1 -1
  291. package/dist/frontend/cjs-resolve.d.ts +5 -0
  292. package/dist/frontend/cjs-resolve.js +429 -0
  293. package/dist/frontend/cjs-resolve.js.map +1 -0
  294. package/dist/frontend/cjs-syntax.d.ts +26 -0
  295. package/dist/frontend/cjs-syntax.js +806 -0
  296. package/dist/frontend/cjs-syntax.js.map +1 -0
  297. package/dist/frontend/comptime-node.d.ts +4 -0
  298. package/dist/frontend/comptime-node.js +16 -0
  299. package/dist/frontend/comptime-node.js.map +1 -0
  300. package/dist/frontend/comptime-node.test.d.ts +1 -0
  301. package/dist/frontend/comptime-node.test.js +37 -0
  302. package/dist/frontend/comptime-node.test.js.map +1 -0
  303. package/dist/frontend/dts-paths.d.ts +3 -4
  304. package/dist/frontend/dts-paths.js +15 -8
  305. package/dist/frontend/dts-paths.js.map +1 -1
  306. package/dist/frontend/fork-target.js +2 -2
  307. package/dist/frontend/fork-target.js.map +1 -1
  308. package/dist/frontend/helper-tokens.d.ts +1 -0
  309. package/dist/frontend/helper-tokens.js +147 -0
  310. package/dist/frontend/helper-tokens.js.map +1 -0
  311. package/dist/frontend/helper-tokens.test.d.ts +1 -0
  312. package/dist/frontend/helper-tokens.test.js +35 -0
  313. package/dist/frontend/helper-tokens.test.js.map +1 -0
  314. package/dist/frontend/inferred-js-diagnostics.d.ts +5 -0
  315. package/dist/frontend/inferred-js-diagnostics.js +69 -0
  316. package/dist/frontend/inferred-js-diagnostics.js.map +1 -0
  317. package/dist/frontend/inferred-js-diagnostics.test.d.ts +1 -0
  318. package/dist/frontend/inferred-js-diagnostics.test.js +58 -0
  319. package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -0
  320. package/dist/frontend/input-tracker.d.ts +5 -2
  321. package/dist/frontend/input-tracker.js +24 -3
  322. package/dist/frontend/input-tracker.js.map +1 -1
  323. package/dist/frontend/input-tracker.test.js +23 -0
  324. package/dist/frontend/input-tracker.test.js.map +1 -1
  325. package/dist/frontend/lib-contract.js +32 -24
  326. package/dist/frontend/lib-contract.js.map +1 -1
  327. package/dist/frontend/literal-values.d.ts +4 -0
  328. package/dist/frontend/literal-values.js +21 -0
  329. package/dist/frontend/literal-values.js.map +1 -0
  330. package/dist/frontend/literal-values.test.d.ts +1 -0
  331. package/dist/frontend/literal-values.test.js +91 -0
  332. package/dist/frontend/literal-values.test.js.map +1 -0
  333. package/dist/frontend/lowering/abstract-equality.d.ts +1 -1
  334. package/dist/frontend/lowering/abstract-equality.js +3 -0
  335. package/dist/frontend/lowering/abstract-equality.js.map +1 -1
  336. package/dist/frontend/lowering/array-indexed-mutation.js +11 -6
  337. package/dist/frontend/lowering/array-indexed-mutation.js.map +1 -1
  338. package/dist/frontend/lowering/array-values.d.ts +4 -1
  339. package/dist/frontend/lowering/array-values.js +43 -1
  340. package/dist/frontend/lowering/array-values.js.map +1 -1
  341. package/dist/frontend/lowering/callback-arg.js +1 -0
  342. package/dist/frontend/lowering/callback-arg.js.map +1 -1
  343. package/dist/frontend/lowering/class-callbacks.d.ts +12 -0
  344. package/dist/frontend/lowering/class-callbacks.js +74 -0
  345. package/dist/frontend/lowering/class-callbacks.js.map +1 -0
  346. package/dist/frontend/lowering/class-construction.d.ts +12 -0
  347. package/dist/frontend/lowering/class-construction.js +156 -0
  348. package/dist/frontend/lowering/class-construction.js.map +1 -0
  349. package/dist/frontend/lowering/class-descriptors.d.ts +10 -0
  350. package/dist/frontend/lowering/class-descriptors.js +114 -0
  351. package/dist/frontend/lowering/class-descriptors.js.map +1 -0
  352. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +51 -0
  353. package/dist/frontend/lowering/class-dynamic-dispatch.js +1158 -0
  354. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -0
  355. package/dist/frontend/lowering/class-dynamic-dispatch.test.d.ts +1 -0
  356. package/dist/frontend/lowering/class-dynamic-dispatch.test.js +93 -0
  357. package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -0
  358. package/dist/frontend/lowering/class-instance-constructor.d.ts +7 -0
  359. package/dist/frontend/lowering/class-instance-constructor.js +67 -0
  360. package/dist/frontend/lowering/class-instance-constructor.js.map +1 -0
  361. package/dist/frontend/lowering/class-method-values.d.ts +13 -0
  362. package/dist/frontend/lowering/class-method-values.js +235 -0
  363. package/dist/frontend/lowering/class-method-values.js.map +1 -0
  364. package/dist/frontend/lowering/class-prototypes.d.ts +19 -0
  365. package/dist/frontend/lowering/class-prototypes.js +242 -0
  366. package/dist/frontend/lowering/class-prototypes.js.map +1 -0
  367. package/dist/frontend/lowering/class-runtime-statics.d.ts +8 -0
  368. package/dist/frontend/lowering/class-runtime-statics.js +66 -0
  369. package/dist/frontend/lowering/class-runtime-statics.js.map +1 -0
  370. package/dist/frontend/lowering/class-static-data.d.ts +6 -0
  371. package/dist/frontend/lowering/class-static-data.js +56 -0
  372. package/dist/frontend/lowering/class-static-data.js.map +1 -0
  373. package/dist/frontend/lowering/containers/buffer-numeric-methods.d.ts +4 -0
  374. package/dist/frontend/lowering/containers/buffer-numeric-methods.js +26 -0
  375. package/dist/frontend/lowering/containers/buffer-numeric-methods.js.map +1 -0
  376. package/dist/frontend/lowering/containers/bytes.d.ts +11 -7
  377. package/dist/frontend/lowering/containers/bytes.js +208 -163
  378. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  379. package/dist/frontend/lowering/containers/string-and-regexp.d.ts +2 -2
  380. package/dist/frontend/lowering/containers/string-and-regexp.js +58 -63
  381. package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
  382. package/dist/frontend/lowering/containers/string-replacement.d.ts +7 -0
  383. package/dist/frontend/lowering/containers/string-replacement.js +217 -0
  384. package/dist/frontend/lowering/containers/string-replacement.js.map +1 -0
  385. package/dist/frontend/lowering/error-methods.d.ts +14 -0
  386. package/dist/frontend/lowering/error-methods.js +177 -0
  387. package/dist/frontend/lowering/error-methods.js.map +1 -0
  388. package/dist/frontend/lowering/expressions/global-symbols.d.ts +6 -0
  389. package/dist/frontend/lowering/expressions/global-symbols.js +11 -0
  390. package/dist/frontend/lowering/expressions/global-symbols.js.map +1 -0
  391. package/dist/frontend/lowering/expressions/native-proxy.d.ts +7 -0
  392. package/dist/frontend/lowering/expressions/native-proxy.js +51 -0
  393. package/dist/frontend/lowering/expressions/native-proxy.js.map +1 -0
  394. package/dist/frontend/lowering/expressions/nullish-assignment.d.ts +6 -0
  395. package/dist/frontend/lowering/expressions/nullish-assignment.js +132 -0
  396. package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -0
  397. package/dist/frontend/lowering/expressions/object-literals.d.ts +8 -8
  398. package/dist/frontend/lowering/expressions/object-literals.js +509 -183
  399. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  400. package/dist/frontend/lowering/expressions/optional-chains.d.ts +3 -4
  401. package/dist/frontend/lowering/expressions/optional-chains.js +88 -24
  402. package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
  403. package/dist/frontend/lowering/expressions/try-lower-expression.js +1 -0
  404. package/dist/frontend/lowering/expressions/try-lower-expression.js.map +1 -1
  405. package/dist/frontend/lowering/expressions/union-field-write.d.ts +8 -0
  406. package/dist/frontend/lowering/expressions/union-field-write.js +71 -0
  407. package/dist/frontend/lowering/expressions/union-field-write.js.map +1 -0
  408. package/dist/frontend/lowering/function-context.d.ts +101 -0
  409. package/dist/frontend/lowering/function-context.js +109 -0
  410. package/dist/frontend/lowering/function-context.js.map +1 -0
  411. package/dist/frontend/lowering/generator-delegation.d.ts +7 -0
  412. package/dist/frontend/lowering/generator-delegation.js +85 -0
  413. package/dist/frontend/lowering/generator-delegation.js.map +1 -0
  414. package/dist/frontend/lowering/generator-dynamic-dispatch.d.ts +11 -0
  415. package/dist/frontend/lowering/generator-dynamic-dispatch.js +143 -0
  416. package/dist/frontend/lowering/generator-dynamic-dispatch.js.map +1 -0
  417. package/dist/frontend/lowering/lib-boundary.d.ts +4 -1
  418. package/dist/frontend/lowering/lib-boundary.js +112 -20
  419. package/dist/frontend/lowering/lib-boundary.js.map +1 -1
  420. package/dist/frontend/lowering/lib-boundary.test.d.ts +1 -0
  421. package/dist/frontend/lowering/lib-boundary.test.js +45 -0
  422. package/dist/frontend/lowering/lib-boundary.test.js.map +1 -0
  423. package/dist/frontend/lowering/lower-array-sort.d.ts +1 -1
  424. package/dist/frontend/lowering/lower-assert.d.ts +1 -1
  425. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  426. package/dist/frontend/lowering/lower-async-iteration.d.ts +1 -1
  427. package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
  428. package/dist/frontend/lowering/lower-builtin-values.d.ts +18 -0
  429. package/dist/frontend/lowering/lower-builtin-values.js +249 -0
  430. package/dist/frontend/lowering/lower-builtin-values.js.map +1 -0
  431. package/dist/frontend/lowering/lower-builtins.d.ts +33 -46
  432. package/dist/frontend/lowering/lower-builtins.js +676 -365
  433. package/dist/frontend/lowering/lower-builtins.js.map +1 -1
  434. package/dist/frontend/lowering/lower-calls.d.ts +28 -22
  435. package/dist/frontend/lowering/lower-calls.js +1660 -412
  436. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  437. package/dist/frontend/lowering/lower-classes.d.ts +95 -57
  438. package/dist/frontend/lowering/lower-classes.js +1491 -404
  439. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  440. package/dist/frontend/lowering/lower-comptime.d.ts +1 -1
  441. package/dist/frontend/lowering/lower-comptime.js +23 -32
  442. package/dist/frontend/lowering/lower-comptime.js.map +1 -1
  443. package/dist/frontend/lowering/lower-containers.d.ts +36 -32
  444. package/dist/frontend/lowering/lower-containers.js +925 -181
  445. package/dist/frontend/lowering/lower-containers.js.map +1 -1
  446. package/dist/frontend/lowering/lower-dgram.d.ts +1 -1
  447. package/dist/frontend/lowering/lower-dgram.js +3 -2
  448. package/dist/frontend/lowering/lower-dgram.js.map +1 -1
  449. package/dist/frontend/lowering/lower-enums.d.ts +1 -1
  450. package/dist/frontend/lowering/lower-enums.js.map +1 -1
  451. package/dist/frontend/lowering/lower-event-emitter.d.ts +30 -1
  452. package/dist/frontend/lowering/lower-event-emitter.js +58 -26
  453. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  454. package/dist/frontend/lowering/lower-expando.d.ts +7 -1
  455. package/dist/frontend/lowering/lower-expando.js +14 -6
  456. package/dist/frontend/lowering/lower-expando.js.map +1 -1
  457. package/dist/frontend/lowering/lower-exprs.d.ts +37 -13
  458. package/dist/frontend/lowering/lower-exprs.js +2163 -863
  459. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  460. package/dist/frontend/lowering/lower-generators.d.ts +2 -5
  461. package/dist/frontend/lowering/lower-generators.js +88 -46
  462. package/dist/frontend/lowering/lower-generators.js.map +1 -1
  463. package/dist/frontend/lowering/lower-global-value.d.ts +7 -0
  464. package/dist/frontend/lowering/lower-global-value.js +17 -0
  465. package/dist/frontend/lowering/lower-global-value.js.map +1 -0
  466. package/dist/frontend/lowering/lower-inspect.d.ts +1 -1
  467. package/dist/frontend/lowering/lower-inspect.js +17 -8
  468. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  469. package/dist/frontend/lowering/lower-island.d.ts +7 -8
  470. package/dist/frontend/lowering/lower-island.js +66 -33
  471. package/dist/frontend/lowering/lower-island.js.map +1 -1
  472. package/dist/frontend/lowering/lower-mixins.d.ts +2 -2
  473. package/dist/frontend/lowering/lower-mixins.js +5 -3
  474. package/dist/frontend/lowering/lower-mixins.js.map +1 -1
  475. package/dist/frontend/lowering/lower-modules.d.ts +1 -1
  476. package/dist/frontend/lowering/lower-modules.js +445 -39
  477. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  478. package/dist/frontend/lowering/lower-modules.test.d.ts +1 -0
  479. package/dist/frontend/lowering/lower-modules.test.js +39 -0
  480. package/dist/frontend/lowering/lower-modules.test.js.map +1 -0
  481. package/dist/frontend/lowering/lower-namespaces.d.ts +1 -1
  482. package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
  483. package/dist/frontend/lowering/lower-node-module.d.ts +1 -1
  484. package/dist/frontend/lowering/lower-node-module.js +13 -10
  485. package/dist/frontend/lowering/lower-node-module.js.map +1 -1
  486. package/dist/frontend/lowering/lower-server.d.ts +1 -1
  487. package/dist/frontend/lowering/lower-server.js +6 -10
  488. package/dist/frontend/lowering/lower-server.js.map +1 -1
  489. package/dist/frontend/lowering/lower-stmts.d.ts +17 -17
  490. package/dist/frontend/lowering/lower-stmts.js +855 -514
  491. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  492. package/dist/frontend/lowering/lower-stream.d.ts +1 -1
  493. package/dist/frontend/lowering/lower-stream.js +20 -11
  494. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  495. package/dist/frontend/lowering/lower-test.d.ts +1 -1
  496. package/dist/frontend/lowering/lower-test.js.map +1 -1
  497. package/dist/frontend/lowering/lower-url.d.ts +6 -0
  498. package/dist/frontend/lowering/lower-url.js +77 -0
  499. package/dist/frontend/lowering/lower-url.js.map +1 -0
  500. package/dist/frontend/lowering/lowerer.d.ts +140 -190
  501. package/dist/frontend/lowering/lowerer.js +1193 -712
  502. package/dist/frontend/lowering/lowerer.js.map +1 -1
  503. package/dist/frontend/lowering/lowerer.test.d.ts +1 -0
  504. package/dist/frontend/lowering/lowerer.test.js +172 -0
  505. package/dist/frontend/lowering/lowerer.test.js.map +1 -0
  506. package/dist/frontend/lowering/native-ffi.d.ts +5 -0
  507. package/dist/frontend/lowering/native-ffi.js +40 -0
  508. package/dist/frontend/lowering/native-ffi.js.map +1 -0
  509. package/dist/frontend/lowering/object-enumeration-receiver.d.ts +7 -0
  510. package/dist/frontend/lowering/object-enumeration-receiver.js +33 -0
  511. package/dist/frontend/lowering/object-enumeration-receiver.js.map +1 -0
  512. package/dist/frontend/lowering/object-factory-new.d.ts +8 -0
  513. package/dist/frontend/lowering/object-factory-new.js +68 -0
  514. package/dist/frontend/lowering/object-factory-new.js.map +1 -0
  515. package/dist/frontend/lowering/optional-arguments.js +6 -1
  516. package/dist/frontend/lowering/optional-arguments.js.map +1 -1
  517. package/dist/frontend/lowering/pairs-snapshot.js +2 -1
  518. package/dist/frontend/lowering/pairs-snapshot.js.map +1 -1
  519. package/dist/frontend/lowering/runtime-optional-locals.d.ts +14 -0
  520. package/dist/frontend/lowering/runtime-optional-locals.js +41 -0
  521. package/dist/frontend/lowering/runtime-optional-locals.js.map +1 -0
  522. package/dist/frontend/lowering/runtime-optional-locals.test.d.ts +1 -0
  523. package/dist/frontend/lowering/runtime-optional-locals.test.js +85 -0
  524. package/dist/frontend/lowering/runtime-optional-locals.test.js.map +1 -0
  525. package/dist/frontend/lowering/sanitize-class-types.d.ts +8 -0
  526. package/dist/frontend/lowering/sanitize-class-types.js +79 -0
  527. package/dist/frontend/lowering/sanitize-class-types.js.map +1 -0
  528. package/dist/frontend/lowering/sanitize-class-types.test.d.ts +1 -0
  529. package/dist/frontend/lowering/sanitize-class-types.test.js +60 -0
  530. package/dist/frontend/lowering/sanitize-class-types.test.js.map +1 -0
  531. package/dist/frontend/lowering/static-this.d.ts +5 -1
  532. package/dist/frontend/lowering/static-this.js +28 -2
  533. package/dist/frontend/lowering/static-this.js.map +1 -1
  534. package/dist/frontend/lowering/string-index.d.ts +7 -0
  535. package/dist/frontend/lowering/string-index.js +39 -0
  536. package/dist/frontend/lowering/string-index.js.map +1 -0
  537. package/dist/frontend/lowering/surfaces.d.ts +10 -3
  538. package/dist/frontend/lowering/surfaces.js +86 -37
  539. package/dist/frontend/lowering/surfaces.js.map +1 -1
  540. package/dist/frontend/lowering/symbol-fields.d.ts +22 -0
  541. package/dist/frontend/lowering/symbol-fields.js +183 -0
  542. package/dist/frontend/lowering/symbol-fields.js.map +1 -0
  543. package/dist/frontend/lowering/symbol-methods.d.ts +7 -0
  544. package/dist/frontend/lowering/symbol-methods.js +30 -0
  545. package/dist/frontend/lowering/symbol-methods.js.map +1 -0
  546. package/dist/frontend/lowering/text-decoder-encoding.d.ts +12 -0
  547. package/dist/frontend/lowering/text-decoder-encoding.js +82 -0
  548. package/dist/frontend/lowering/text-decoder-encoding.js.map +1 -0
  549. package/dist/frontend/lowering/text-decoder-encoding.test.d.ts +1 -0
  550. package/dist/frontend/lowering/text-decoder-encoding.test.js +38 -0
  551. package/dist/frontend/lowering/text-decoder-encoding.test.js.map +1 -0
  552. package/dist/frontend/lowering/union-narrow.d.ts +9 -0
  553. package/dist/frontend/lowering/union-narrow.js +59 -0
  554. package/dist/frontend/lowering/union-narrow.js.map +1 -0
  555. package/dist/frontend/lowering/union-narrow.test.d.ts +1 -0
  556. package/dist/frontend/lowering/union-narrow.test.js +72 -0
  557. package/dist/frontend/lowering/union-narrow.test.js.map +1 -0
  558. package/dist/frontend/lowering/union-retag.d.ts +43 -0
  559. package/dist/frontend/lowering/union-retag.js +259 -0
  560. package/dist/frontend/lowering/union-retag.js.map +1 -0
  561. package/dist/frontend/lowering/union-retag.test.d.ts +1 -0
  562. package/dist/frontend/lowering/union-retag.test.js +405 -0
  563. package/dist/frontend/lowering/union-retag.test.js.map +1 -0
  564. package/dist/frontend/lowering/unregistered-class-types.d.ts +14 -0
  565. package/dist/frontend/lowering/unregistered-class-types.js +94 -0
  566. package/dist/frontend/lowering/unregistered-class-types.js.map +1 -0
  567. package/dist/frontend/lowering/unregistered-class-types.test.d.ts +1 -0
  568. package/dist/frontend/lowering/unregistered-class-types.test.js +65 -0
  569. package/dist/frontend/lowering/unregistered-class-types.test.js.map +1 -0
  570. package/dist/frontend/lowering/width-lift.d.ts +40 -0
  571. package/dist/frontend/lowering/width-lift.js +2 -0
  572. package/dist/frontend/lowering/width-lift.js.map +1 -0
  573. package/dist/frontend/module-syntax.d.ts +58 -0
  574. package/dist/frontend/module-syntax.js +123 -0
  575. package/dist/frontend/module-syntax.js.map +1 -0
  576. package/dist/frontend/module-syntax.test.d.ts +1 -0
  577. package/dist/frontend/module-syntax.test.js +78 -0
  578. package/dist/frontend/module-syntax.test.js.map +1 -0
  579. package/dist/frontend/npm-fetch-analysis.d.ts +17 -0
  580. package/dist/frontend/npm-fetch-analysis.js +100 -0
  581. package/dist/frontend/npm-fetch-analysis.js.map +1 -0
  582. package/dist/frontend/npm-fetch-analysis.test.d.ts +1 -0
  583. package/dist/frontend/npm-fetch-analysis.test.js +107 -0
  584. package/dist/frontend/npm-fetch-analysis.test.js.map +1 -0
  585. package/dist/frontend/npm-fetch-node.d.ts +2 -0
  586. package/dist/frontend/npm-fetch-node.js +12 -0
  587. package/dist/frontend/npm-fetch-node.js.map +1 -0
  588. package/dist/frontend/npm-fetch-syntax.d.ts +6 -0
  589. package/dist/frontend/npm-fetch-syntax.js +207 -0
  590. package/dist/frontend/npm-fetch-syntax.js.map +1 -0
  591. package/dist/frontend/npm-node.d.ts +10 -0
  592. package/dist/frontend/npm-node.js +14 -0
  593. package/dist/frontend/npm-node.js.map +1 -0
  594. package/dist/frontend/npm-static-bundled-cjs.d.ts +8 -0
  595. package/dist/frontend/npm-static-bundled-cjs.js +236 -0
  596. package/dist/frontend/npm-static-bundled-cjs.js.map +1 -0
  597. package/dist/frontend/npm-static-bundled-cjs.test.d.ts +1 -0
  598. package/dist/frontend/npm-static-bundled-cjs.test.js +69 -0
  599. package/dist/frontend/npm-static-bundled-cjs.test.js.map +1 -0
  600. package/dist/frontend/npm-static-declaration-syntax.d.ts +57 -0
  601. package/dist/frontend/npm-static-declaration-syntax.js +944 -0
  602. package/dist/frontend/npm-static-declaration-syntax.js.map +1 -0
  603. package/dist/frontend/npm-static-declarations.d.ts +11 -39
  604. package/dist/frontend/npm-static-declarations.js +22 -561
  605. package/dist/frontend/npm-static-declarations.js.map +1 -1
  606. package/dist/frontend/npm-static-declarations.test.js +245 -6
  607. package/dist/frontend/npm-static-declarations.test.js.map +1 -1
  608. package/dist/frontend/npm-static-prune.d.ts +1 -1
  609. package/dist/frontend/npm-static-prune.js +121 -38
  610. package/dist/frontend/npm-static-prune.js.map +1 -1
  611. package/dist/frontend/npm-static-prune.test.js +9 -1
  612. package/dist/frontend/npm-static-prune.test.js.map +1 -1
  613. package/dist/frontend/npm-static-rewrite-host.d.ts +4 -0
  614. package/dist/frontend/npm-static-rewrite-host.js +179 -0
  615. package/dist/frontend/npm-static-rewrite-host.js.map +1 -0
  616. package/dist/frontend/npm-static-rewrite-syntax.d.ts +16 -0
  617. package/dist/frontend/npm-static-rewrite-syntax.js +905 -0
  618. package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -0
  619. package/dist/frontend/npm-static-rewrite.d.ts +0 -5
  620. package/dist/frontend/npm-static-rewrite.js +2 -1079
  621. package/dist/frontend/npm-static-rewrite.js.map +1 -1
  622. package/dist/frontend/npm-static-subtyping.d.ts +5 -0
  623. package/dist/frontend/npm-static-subtyping.js +55 -0
  624. package/dist/frontend/npm-static-subtyping.js.map +1 -0
  625. package/dist/frontend/npm-static-subtyping.test.d.ts +1 -0
  626. package/dist/frontend/npm-static-subtyping.test.js +58 -0
  627. package/dist/frontend/npm-static-subtyping.test.js.map +1 -0
  628. package/dist/frontend/npm-static.d.ts +7 -15
  629. package/dist/frontend/npm-static.js +19 -28
  630. package/dist/frontend/npm-static.js.map +1 -1
  631. package/dist/frontend/npm.d.ts +8 -69
  632. package/dist/frontend/npm.js +21 -361
  633. package/dist/frontend/npm.js.map +1 -1
  634. package/dist/frontend/npm.test.js +2 -2
  635. package/dist/frontend/npm.test.js.map +1 -1
  636. package/dist/frontend/pipeline-native.d.ts +6 -0
  637. package/dist/frontend/pipeline-native.js +32 -0
  638. package/dist/frontend/pipeline-native.js.map +1 -0
  639. package/dist/frontend/pipeline.d.ts +54 -0
  640. package/dist/frontend/pipeline.js +382 -0
  641. package/dist/frontend/pipeline.js.map +1 -0
  642. package/dist/frontend/pipeline.test.d.ts +1 -0
  643. package/dist/frontend/pipeline.test.js +77 -0
  644. package/dist/frontend/pipeline.test.js.map +1 -0
  645. package/dist/frontend/program-analysis.d.ts +10 -0
  646. package/dist/frontend/program-analysis.js +14 -0
  647. package/dist/frontend/program-analysis.js.map +1 -0
  648. package/dist/frontend/program-node.d.ts +9 -0
  649. package/dist/frontend/program-node.js +48 -0
  650. package/dist/frontend/program-node.js.map +1 -0
  651. package/dist/frontend/program.d.ts +39 -20
  652. package/dist/frontend/program.js +393 -189
  653. package/dist/frontend/program.js.map +1 -1
  654. package/dist/frontend/program.test.js +105 -2
  655. package/dist/frontend/program.test.js.map +1 -1
  656. package/dist/frontend/provenance-core.d.ts +9 -0
  657. package/dist/frontend/provenance-core.js +435 -0
  658. package/dist/frontend/provenance-core.js.map +1 -0
  659. package/dist/frontend/provenance.d.ts +0 -4
  660. package/dist/frontend/provenance.js +4 -459
  661. package/dist/frontend/provenance.js.map +1 -1
  662. package/dist/frontend/resolve.d.ts +3 -1
  663. package/dist/frontend/resolve.js +6 -3
  664. package/dist/frontend/resolve.js.map +1 -1
  665. package/dist/frontend/runtime-resolve.d.ts +4 -3
  666. package/dist/frontend/runtime-resolve.js +22 -18
  667. package/dist/frontend/runtime-resolve.js.map +1 -1
  668. package/dist/frontend/runtime-resolve.test.js +53 -0
  669. package/dist/frontend/runtime-resolve.test.js.map +1 -1
  670. package/dist/frontend/services-node.d.ts +5 -0
  671. package/dist/frontend/services-node.js +19 -0
  672. package/dist/frontend/services-node.js.map +1 -0
  673. package/dist/frontend/services-node.test.d.ts +1 -0
  674. package/dist/frontend/services-node.test.js +70 -0
  675. package/dist/frontend/services-node.test.js.map +1 -0
  676. package/dist/frontend/services.d.ts +44 -0
  677. package/dist/frontend/services.js +90 -0
  678. package/dist/frontend/services.js.map +1 -0
  679. package/dist/frontend/services.test.d.ts +1 -0
  680. package/dist/frontend/services.test.js +174 -0
  681. package/dist/frontend/services.test.js.map +1 -0
  682. package/dist/frontend/ts7/adapter.d.ts +3 -3
  683. package/dist/frontend/ts7/adapter.js +14 -31
  684. package/dist/frontend/ts7/adapter.js.map +1 -1
  685. package/dist/frontend/ts7/api.d.ts +16 -0
  686. package/dist/frontend/ts7/api.js +24 -0
  687. package/dist/frontend/ts7/api.js.map +1 -0
  688. package/dist/frontend/ts7/ast-bytes.d.ts +31 -0
  689. package/dist/frontend/ts7/ast-bytes.js +137 -0
  690. package/dist/frontend/ts7/ast-bytes.js.map +1 -0
  691. package/dist/frontend/ts7/ast-bytes.test.d.ts +1 -0
  692. package/dist/frontend/ts7/ast-bytes.test.js +73 -0
  693. package/dist/frontend/ts7/ast-bytes.test.js.map +1 -0
  694. package/dist/frontend/ts7/ast-guards.generated.d.ts +353 -0
  695. package/dist/frontend/ts7/ast-guards.generated.js +1951 -0
  696. package/dist/frontend/ts7/ast-guards.generated.js.map +1 -0
  697. package/dist/frontend/ts7/ast-guards.test.d.ts +1 -0
  698. package/dist/frontend/ts7/ast-guards.test.js +43 -0
  699. package/dist/frontend/ts7/ast-guards.test.js.map +1 -0
  700. package/dist/frontend/ts7/ast-node.d.ts +194 -0
  701. package/dist/frontend/ts7/ast-node.js +448 -0
  702. package/dist/frontend/ts7/ast-node.js.map +1 -0
  703. package/dist/frontend/ts7/ast-node.test.d.ts +1 -0
  704. package/dist/frontend/ts7/ast-node.test.js +266 -0
  705. package/dist/frontend/ts7/ast-node.test.js.map +1 -0
  706. package/dist/frontend/ts7/ast-schema.generated.d.ts +503 -0
  707. package/dist/frontend/ts7/ast-schema.generated.js +1446 -0
  708. package/dist/frontend/ts7/ast-schema.generated.js.map +1 -0
  709. package/dist/frontend/ts7/ast-text.d.ts +6 -0
  710. package/dist/frontend/ts7/ast-text.js +124 -0
  711. package/dist/frontend/ts7/ast-text.js.map +1 -0
  712. package/dist/frontend/ts7/ast-text.test.d.ts +1 -0
  713. package/dist/frontend/ts7/ast-text.test.js +38 -0
  714. package/dist/frontend/ts7/ast-text.test.js.map +1 -0
  715. package/dist/frontend/ts7/ast-tokens.generated.d.ts +2 -0
  716. package/dist/frontend/ts7/ast-tokens.generated.js +155 -0
  717. package/dist/frontend/ts7/ast-tokens.generated.js.map +1 -0
  718. package/dist/frontend/ts7/ast-types.d.ts +42 -0
  719. package/dist/frontend/ts7/ast-types.generated.d.ts +1615 -0
  720. package/dist/frontend/ts7/ast-types.generated.js +5 -0
  721. package/dist/frontend/ts7/ast-types.generated.js.map +1 -0
  722. package/dist/frontend/ts7/ast-types.js +3 -0
  723. package/dist/frontend/ts7/ast-types.js.map +1 -0
  724. package/dist/frontend/ts7/ast-wire.d.ts +58 -0
  725. package/dist/frontend/ts7/ast-wire.js +267 -0
  726. package/dist/frontend/ts7/ast-wire.js.map +1 -0
  727. package/dist/frontend/ts7/ast-wire.test.d.ts +1 -0
  728. package/dist/frontend/ts7/ast-wire.test.js +151 -0
  729. package/dist/frontend/ts7/ast-wire.test.js.map +1 -0
  730. package/dist/frontend/ts7/ast.d.ts +14 -14
  731. package/dist/frontend/ts7/ast.js +25 -18
  732. package/dist/frontend/ts7/ast.js.map +1 -1
  733. package/dist/frontend/ts7/census-check.js +1 -0
  734. package/dist/frontend/ts7/census-check.js.map +1 -1
  735. package/dist/frontend/ts7/checker-cache.d.ts +48 -0
  736. package/dist/frontend/ts7/checker-cache.js +92 -0
  737. package/dist/frontend/ts7/checker-cache.js.map +1 -0
  738. package/dist/frontend/ts7/checker.d.ts +19 -46
  739. package/dist/frontend/ts7/checker.js +231 -161
  740. package/dist/frontend/ts7/checker.js.map +1 -1
  741. package/dist/frontend/ts7/checker.test.d.ts +1 -0
  742. package/dist/frontend/ts7/checker.test.js +335 -0
  743. package/dist/frontend/ts7/checker.test.js.map +1 -0
  744. package/dist/frontend/ts7/enums.d.ts +4 -27
  745. package/dist/frontend/ts7/enums.generated.d.ts +878 -0
  746. package/dist/frontend/ts7/enums.generated.js +1313 -0
  747. package/dist/frontend/ts7/enums.generated.js.map +1 -0
  748. package/dist/frontend/ts7/enums.js +4 -45
  749. package/dist/frontend/ts7/enums.js.map +1 -1
  750. package/dist/frontend/ts7/enums.test.d.ts +1 -0
  751. package/dist/frontend/ts7/enums.test.js +48 -0
  752. package/dist/frontend/ts7/enums.test.js.map +1 -0
  753. package/dist/frontend/ts7/native-api.d.ts +10 -0
  754. package/dist/frontend/ts7/native-api.js +10 -0
  755. package/dist/frontend/ts7/native-api.js.map +1 -0
  756. package/dist/frontend/ts7/native-host.d.ts +2 -0
  757. package/dist/frontend/ts7/native-host.js +11 -0
  758. package/dist/frontend/ts7/native-host.js.map +1 -0
  759. package/dist/frontend/ts7/native-process.d.ts +14 -0
  760. package/dist/frontend/ts7/native-process.js +62 -0
  761. package/dist/frontend/ts7/native-process.js.map +1 -0
  762. package/dist/frontend/ts7/program-adapter.d.ts +10 -98
  763. package/dist/frontend/ts7/program-adapter.js +16 -310
  764. package/dist/frontend/ts7/program-adapter.js.map +1 -1
  765. package/dist/frontend/ts7/program-host.d.ts +115 -0
  766. package/dist/frontend/ts7/program-host.js +347 -0
  767. package/dist/frontend/ts7/program-host.js.map +1 -0
  768. package/dist/frontend/ts7/program-host.test.d.ts +1 -0
  769. package/dist/frontend/ts7/program-host.test.js +207 -0
  770. package/dist/frontend/ts7/program-host.test.js.map +1 -0
  771. package/dist/frontend/ts7/rpc-api.d.ts +12 -0
  772. package/dist/frontend/ts7/rpc-api.js +23 -0
  773. package/dist/frontend/ts7/rpc-api.js.map +1 -0
  774. package/dist/frontend/ts7/rpc-client.d.ts +27 -0
  775. package/dist/frontend/ts7/rpc-client.js +102 -0
  776. package/dist/frontend/ts7/rpc-client.js.map +1 -0
  777. package/dist/frontend/ts7/rpc-client.test.d.ts +1 -0
  778. package/dist/frontend/ts7/rpc-client.test.js +133 -0
  779. package/dist/frontend/ts7/rpc-client.test.js.map +1 -0
  780. package/dist/frontend/ts7/rpc-filesystem.d.ts +16 -0
  781. package/dist/frontend/ts7/rpc-filesystem.js +42 -0
  782. package/dist/frontend/ts7/rpc-filesystem.js.map +1 -0
  783. package/dist/frontend/ts7/rpc-filesystem.test.d.ts +1 -0
  784. package/dist/frontend/ts7/rpc-filesystem.test.js +89 -0
  785. package/dist/frontend/ts7/rpc-filesystem.test.js.map +1 -0
  786. package/dist/frontend/ts7/rpc-process.d.ts +2 -0
  787. package/dist/frontend/ts7/rpc-process.js +148 -0
  788. package/dist/frontend/ts7/rpc-process.js.map +1 -0
  789. package/dist/frontend/ts7/rpc-process.test.d.ts +1 -0
  790. package/dist/frontend/ts7/rpc-process.test.js +29 -0
  791. package/dist/frontend/ts7/rpc-process.test.js.map +1 -0
  792. package/dist/frontend/ts7/rpc-wire.d.ts +46 -0
  793. package/dist/frontend/ts7/rpc-wire.js +195 -0
  794. package/dist/frontend/ts7/rpc-wire.js.map +1 -0
  795. package/dist/frontend/ts7/rpc-wire.test.d.ts +1 -0
  796. package/dist/frontend/ts7/rpc-wire.test.js +168 -0
  797. package/dist/frontend/ts7/rpc-wire.test.js.map +1 -0
  798. package/dist/frontend/ts7/semantic-checker.d.ts +137 -0
  799. package/dist/frontend/ts7/semantic-checker.js +221 -0
  800. package/dist/frontend/ts7/semantic-checker.js.map +1 -0
  801. package/dist/frontend/ts7/semantic-checker.test.d.ts +1 -0
  802. package/dist/frontend/ts7/semantic-checker.test.js +119 -0
  803. package/dist/frontend/ts7/semantic-checker.test.js.map +1 -0
  804. package/dist/frontend/ts7/semantic-json.d.ts +5 -0
  805. package/dist/frontend/ts7/semantic-json.js +47 -0
  806. package/dist/frontend/ts7/semantic-json.js.map +1 -0
  807. package/dist/frontend/ts7/semantic-json.test.d.ts +1 -0
  808. package/dist/frontend/ts7/semantic-json.test.js +42 -0
  809. package/dist/frontend/ts7/semantic-json.test.js.map +1 -0
  810. package/dist/frontend/ts7/semantic-model.d.ts +222 -0
  811. package/dist/frontend/ts7/semantic-model.js +423 -0
  812. package/dist/frontend/ts7/semantic-model.js.map +1 -0
  813. package/dist/frontend/ts7/semantic-model.test.d.ts +1 -0
  814. package/dist/frontend/ts7/semantic-model.test.js +322 -0
  815. package/dist/frontend/ts7/semantic-model.test.js.map +1 -0
  816. package/dist/frontend/ts7/semantic-schema.generated.d.ts +283 -0
  817. package/dist/frontend/ts7/semantic-schema.generated.js +222 -0
  818. package/dist/frontend/ts7/semantic-schema.generated.js.map +1 -0
  819. package/dist/frontend/ts7/semantic-types.d.ts +5 -0
  820. package/dist/frontend/ts7/semantic-types.js +2 -0
  821. package/dist/frontend/ts7/semantic-types.js.map +1 -0
  822. package/dist/frontend/ts7/session-cache.d.ts +17 -0
  823. package/dist/frontend/ts7/session-cache.js +97 -0
  824. package/dist/frontend/ts7/session-cache.js.map +1 -0
  825. package/dist/frontend/ts7/session-cache.test.d.ts +1 -0
  826. package/dist/frontend/ts7/session-cache.test.js +87 -0
  827. package/dist/frontend/ts7/session-cache.test.js.map +1 -0
  828. package/dist/frontend/ts7/session-path.d.ts +18 -0
  829. package/dist/frontend/ts7/session-path.js +203 -0
  830. package/dist/frontend/ts7/session-path.js.map +1 -0
  831. package/dist/frontend/ts7/session-path.test.d.ts +1 -0
  832. package/dist/frontend/ts7/session-path.test.js +34 -0
  833. package/dist/frontend/ts7/session-path.test.js.map +1 -0
  834. package/dist/frontend/ts7/session-schema.generated.d.ts +167 -0
  835. package/dist/frontend/ts7/session-schema.generated.js +5 -0
  836. package/dist/frontend/ts7/session-schema.generated.js.map +1 -0
  837. package/dist/frontend/ts7/session-timing.d.ts +50 -0
  838. package/dist/frontend/ts7/session-timing.js +61 -0
  839. package/dist/frontend/ts7/session-timing.js.map +1 -0
  840. package/dist/frontend/ts7/session-timing.test.d.ts +1 -0
  841. package/dist/frontend/ts7/session-timing.test.js +52 -0
  842. package/dist/frontend/ts7/session-timing.test.js.map +1 -0
  843. package/dist/frontend/ts7/session.d.ts +105 -0
  844. package/dist/frontend/ts7/session.js +233 -0
  845. package/dist/frontend/ts7/session.js.map +1 -0
  846. package/dist/frontend/ts7/session.test.d.ts +1 -0
  847. package/dist/frontend/ts7/session.test.js +215 -0
  848. package/dist/frontend/ts7/session.test.js.map +1 -0
  849. package/dist/frontend/ts7/source-parser-node.d.ts +6 -0
  850. package/dist/frontend/ts7/source-parser-node.js +15 -0
  851. package/dist/frontend/ts7/source-parser-node.js.map +1 -0
  852. package/dist/frontend/ts7/source-parser.d.ts +25 -0
  853. package/dist/frontend/ts7/source-parser.js +96 -0
  854. package/dist/frontend/ts7/source-parser.js.map +1 -0
  855. package/dist/frontend/ts7/source-parser.test.d.ts +1 -0
  856. package/dist/frontend/ts7/source-parser.test.js +151 -0
  857. package/dist/frontend/ts7/source-parser.test.js.map +1 -0
  858. package/dist/frontend/ts7/syntax.d.ts +3 -0
  859. package/dist/frontend/ts7/syntax.js +4 -0
  860. package/dist/frontend/ts7/syntax.js.map +1 -0
  861. package/dist/frontend/tsc-codes.js +3 -0
  862. package/dist/frontend/tsc-codes.js.map +1 -1
  863. package/dist/frontend/type-mapper.d.ts +34 -18
  864. package/dist/frontend/type-mapper.js +552 -131
  865. package/dist/frontend/type-mapper.js.map +1 -1
  866. package/dist/frontend/type-mapper.test.js +146 -2
  867. package/dist/frontend/type-mapper.test.js.map +1 -1
  868. package/dist/frontend/union-discriminants.d.ts +16 -0
  869. package/dist/frontend/union-discriminants.js +98 -0
  870. package/dist/frontend/union-discriminants.js.map +1 -0
  871. package/dist/frontend/union-discriminants.test.d.ts +1 -0
  872. package/dist/frontend/union-discriminants.test.js +182 -0
  873. package/dist/frontend/union-discriminants.test.js.map +1 -0
  874. package/dist/index.d.ts +7 -198
  875. package/dist/index.js +369 -1572
  876. package/dist/index.js.map +1 -1
  877. package/dist/ir/analysis.d.ts +16 -4
  878. package/dist/ir/analysis.js +23 -4
  879. package/dist/ir/analysis.js.map +1 -1
  880. package/dist/ir/analysis.test.js +15 -2
  881. package/dist/ir/analysis.test.js.map +1 -1
  882. package/dist/ir/constant-tables.js +67 -49
  883. package/dist/ir/constant-tables.js.map +1 -1
  884. package/dist/ir/constant-tables.test.js +1 -1
  885. package/dist/ir/control-flow.d.ts +6 -0
  886. package/dist/ir/control-flow.js +142 -0
  887. package/dist/ir/control-flow.js.map +1 -0
  888. package/dist/ir/control-flow.test.d.ts +1 -0
  889. package/dist/ir/control-flow.test.js +113 -0
  890. package/dist/ir/control-flow.test.js.map +1 -0
  891. package/dist/ir/integer-loops.js +7 -18
  892. package/dist/ir/integer-loops.js.map +1 -1
  893. package/dist/ir/integer-ranges.js +53 -27
  894. package/dist/ir/integer-ranges.js.map +1 -1
  895. package/dist/ir/ir.d.ts +334 -176
  896. package/dist/ir/ir.js +710 -903
  897. package/dist/ir/ir.js.map +1 -1
  898. package/dist/ir/ir.test.js +162 -1
  899. package/dist/ir/ir.test.js.map +1 -1
  900. package/dist/ir/scalar-records.js +165 -134
  901. package/dist/ir/scalar-records.js.map +1 -1
  902. package/dist/ir/scalar-records.test.js +1 -1
  903. package/dist/ir/serialize.d.ts +4 -2
  904. package/dist/ir/serialize.js +33 -14
  905. package/dist/ir/serialize.js.map +1 -1
  906. package/dist/ir/serialize.test.d.ts +1 -0
  907. package/dist/ir/serialize.test.js +57 -0
  908. package/dist/ir/serialize.test.js.map +1 -0
  909. package/dist/ir/traverse.d.ts +41 -0
  910. package/dist/ir/traverse.js +660 -0
  911. package/dist/ir/traverse.js.map +1 -0
  912. package/dist/ir/traverse.test.d.ts +1 -0
  913. package/dist/ir/traverse.test.js +242 -0
  914. package/dist/ir/traverse.test.js.map +1 -0
  915. package/dist/ir/validate.js +2018 -1498
  916. package/dist/ir/validate.js.map +1 -1
  917. package/dist/ir/validate.test.js +536 -2
  918. package/dist/ir/validate.test.js.map +1 -1
  919. package/dist/library/cache-primitives.d.ts +2 -3
  920. package/dist/library/cache-primitives.js +4 -6
  921. package/dist/library/cache-primitives.js.map +1 -1
  922. package/dist/library/fence-eval.js +2 -2
  923. package/dist/library/fence-eval.js.map +1 -1
  924. package/dist/library/int-infer.js +7 -6
  925. package/dist/library/int-infer.js.map +1 -1
  926. package/dist/library/int-infer.test.js +4 -4
  927. package/dist/library/library-cache.d.ts +3 -2
  928. package/dist/library/library-cache.js +5 -17
  929. package/dist/library/library-cache.js.map +1 -1
  930. package/dist/library/library-cache.test.js +54 -41
  931. package/dist/library/library-cache.test.js.map +1 -1
  932. package/dist/library/library-profile.d.ts +3 -1
  933. package/dist/library/library-profile.js +15 -6
  934. package/dist/library/library-profile.js.map +1 -1
  935. package/dist/library/prepare.d.ts +15 -0
  936. package/dist/library/prepare.js +584 -0
  937. package/dist/library/prepare.js.map +1 -0
  938. package/dist/library/semantic-source.d.ts +1 -1
  939. package/dist/library/semantic-source.js +8 -6
  940. package/dist/library/semantic-source.js.map +1 -1
  941. package/dist/library/sidecar-validate.js +4 -4
  942. package/dist/library/sidecar-validate.js.map +1 -1
  943. package/dist/library/sidecar.d.ts +2 -0
  944. package/dist/library/sidecar.js +10 -3
  945. package/dist/library/sidecar.js.map +1 -1
  946. package/dist/native/cache.d.ts +11 -0
  947. package/dist/native/cache.js +113 -0
  948. package/dist/native/cache.js.map +1 -0
  949. package/dist/native/cache.test.d.ts +1 -0
  950. package/dist/native/cache.test.js +66 -0
  951. package/dist/native/cache.test.js.map +1 -0
  952. package/dist/native/cli.d.ts +1 -0
  953. package/dist/native/cli.js +112 -0
  954. package/dist/native/cli.js.map +1 -0
  955. package/dist/native/compiler.d.ts +15 -0
  956. package/dist/native/compiler.js +336 -0
  957. package/dist/native/compiler.js.map +1 -0
  958. package/dist/native/compiler.test.d.ts +1 -0
  959. package/dist/native/compiler.test.js +174 -0
  960. package/dist/native/compiler.test.js.map +1 -0
  961. package/dist/native/comptime.d.ts +5 -0
  962. package/dist/native/comptime.js +73 -0
  963. package/dist/native/comptime.js.map +1 -0
  964. package/dist/native/comptime.test.d.ts +1 -0
  965. package/dist/native/comptime.test.js +65 -0
  966. package/dist/native/comptime.test.js.map +1 -0
  967. package/dist/native/executable-cache.d.ts +26 -0
  968. package/dist/native/executable-cache.js +228 -0
  969. package/dist/native/executable-cache.js.map +1 -0
  970. package/dist/native/executable-cache.test.d.ts +1 -0
  971. package/dist/native/executable-cache.test.js +151 -0
  972. package/dist/native/executable-cache.test.js.map +1 -0
  973. package/dist/native/file-identity.d.ts +4 -0
  974. package/dist/native/file-identity.js +14 -0
  975. package/dist/native/file-identity.js.map +1 -0
  976. package/dist/native/file-identity.test.d.ts +1 -0
  977. package/dist/native/file-identity.test.js +43 -0
  978. package/dist/native/file-identity.test.js.map +1 -0
  979. package/dist/native/library.d.ts +22 -0
  980. package/dist/native/library.js +83 -0
  981. package/dist/native/library.js.map +1 -0
  982. package/dist/native/prepare.d.ts +21 -0
  983. package/dist/native/prepare.js +174 -0
  984. package/dist/native/prepare.js.map +1 -0
  985. package/dist/native/prepare.test.d.ts +1 -0
  986. package/dist/native/prepare.test.js +70 -0
  987. package/dist/native/prepare.test.js.map +1 -0
  988. package/dist/native/sanitizer.d.ts +11 -0
  989. package/dist/native/sanitizer.js +137 -0
  990. package/dist/native/sanitizer.js.map +1 -0
  991. package/dist/native/sanitizer.test.d.ts +1 -0
  992. package/dist/native/sanitizer.test.js +58 -0
  993. package/dist/native/sanitizer.test.js.map +1 -0
  994. package/dist/native/task.d.ts +4 -0
  995. package/dist/native/task.js +16 -0
  996. package/dist/native/task.js.map +1 -0
  997. package/dist/native/task.test.d.ts +1 -0
  998. package/dist/native/task.test.js +17 -0
  999. package/dist/native/task.test.js.map +1 -0
  1000. package/dist/native/toolchain.d.ts +45 -0
  1001. package/dist/native/toolchain.js +94 -0
  1002. package/dist/native/toolchain.js.map +1 -0
  1003. package/dist/native/toolchain.test.d.ts +1 -0
  1004. package/dist/native/toolchain.test.js +85 -0
  1005. package/dist/native/toolchain.test.js.map +1 -0
  1006. package/dist/startup-cache.d.ts +1 -1
  1007. package/dist/startup-cache.js +2 -5
  1008. package/dist/startup-cache.js.map +1 -1
  1009. package/dist/timing.d.ts +4 -0
  1010. package/dist/timing.js +19 -0
  1011. package/dist/timing.js.map +1 -0
  1012. package/dist/wasi-paths.js +10 -7
  1013. package/dist/wasi-paths.js.map +1 -1
  1014. package/package.json +28 -19
  1015. package/surface-manifest.json +107 -98
  1016. package/dist/backend/c/async.d.ts +0 -171
  1017. package/dist/backend/c/async.js +0 -1317
  1018. package/dist/backend/c/async.js.map +0 -1
  1019. package/dist/backend/c/c-emitter.d.ts +0 -536
  1020. package/dist/backend/c/c-emitter.js +0 -1932
  1021. package/dist/backend/c/c-emitter.js.map +0 -1
  1022. package/dist/backend/c/exprs.d.ts +0 -15
  1023. package/dist/backend/c/exprs.js +0 -8847
  1024. package/dist/backend/c/exprs.js.map +0 -1
  1025. package/dist/backend/c/island.d.ts +0 -45
  1026. package/dist/backend/c/island.js +0 -281
  1027. package/dist/backend/c/island.js.map +0 -1
  1028. package/dist/backend/c/may-throw.js.map +0 -1
  1029. package/dist/backend/c/shapes.d.ts +0 -142
  1030. package/dist/backend/c/shapes.js +0 -603
  1031. package/dist/backend/c/shapes.js.map +0 -1
  1032. package/dist/backend/c/stmts.d.ts +0 -76
  1033. package/dist/backend/c/stmts.js +0 -1108
  1034. package/dist/backend/c/stmts.js.map +0 -1
  1035. package/dist/backend/c/types.d.ts +0 -71
  1036. package/dist/backend/c/types.js +0 -459
  1037. package/dist/backend/c/types.js.map +0 -1
  1038. package/dist/backend/c/types.test.js +0 -32
  1039. package/dist/backend/c/types.test.js.map +0 -1
  1040. package/dist/backend/c/walkers.d.ts +0 -134
  1041. package/dist/backend/c/walkers.js +0 -1772
  1042. package/dist/backend/c/walkers.js.map +0 -1
  1043. /package/dist/backend/{c/types.test.d.ts → cycle-analysis.test.d.ts} +0 -0
package/dist/ir/ir.js CHANGED
@@ -1,4 +1,12 @@
1
1
  import { InternalCompilerError } from "../errors.js";
2
+ import { everyModuleNode, everyExprChild, everyStmtChild } from "./traverse.js";
3
+ export const BYTES_ELEMENT_SIZE = {
4
+ u8: 1, u8c: 1, i8: 1, u16: 2, i16: 2, u32: 4, i32: 4, f32: 4, f64: 8,
5
+ };
6
+ export const BYTES_ELEMENT_NAME = {
7
+ u8: "Uint8Array", u8c: "Uint8ClampedArray", i8: "Int8Array", u16: "Uint16Array", i16: "Int16Array",
8
+ u32: "Uint32Array", i32: "Int32Array", f32: "Float32Array", f64: "Float64Array",
9
+ };
2
10
  const POINTER_HANDLE_KINDS = [
3
11
  "stats",
4
12
  "fileHandle",
@@ -30,7 +38,7 @@ const HANDLE_KIND_LIST = [
30
38
  "procStream",
31
39
  ];
32
40
  export const HANDLE_KINDS = irKindSet(HANDLE_KIND_LIST);
33
- /** The IR kinds represented as pointers in both native backends. */
41
+ /** The IR kinds represented as pointers in native code. */
34
42
  const POINTER_KIND_LIST = [
35
43
  "string",
36
44
  "bigint",
@@ -185,18 +193,23 @@ export const NULL_T = { kind: "nullT" };
185
193
  export function isUnitType(t) {
186
194
  return t.kind === "undefinedT" || t.kind === "nullT";
187
195
  }
188
- /** Element kinds with a real ScrArr storage/RC representation in BOTH
189
- * backends. Array-producing lowerings can learn their result element from
196
+ /** Element kinds with a real ScrArr storage/RC representation.
197
+ * Array-producing lowerings can learn their result element from
190
198
  * a callback rather than through mapType's ordinary T[] gate, so they must
191
199
  * share this predicate instead of reconstructing an array around an
192
- * otherwise-valid standalone type (Map, Set, dyn, opaque handles, ...). */
200
+ * otherwise-valid standalone type (Date, opaque handles, ...). */
193
201
  export function isSupportedArrayElem(t) {
194
202
  switch (t.kind) {
203
+ // Native collection seeds and drains retain checked values in a
204
+ // temporary vector. User-facing unknown[] still maps to a dyn array.
205
+ case "dyn":
195
206
  case "f64":
196
207
  case "bigint":
197
208
  case "bool":
198
209
  case "string":
199
210
  case "array":
211
+ case "map":
212
+ case "set":
200
213
  case "bytes":
201
214
  case "record":
202
215
  case "object":
@@ -227,35 +240,32 @@ export function mapOf(key, value) {
227
240
  export function setOf(elem) {
228
241
  return { kind: "set", elem };
229
242
  }
230
- /** The Map KEY fence: string (content) or number (SameValueZero) — the two
231
- * kinds a hash of the VALUE is honest for. Booleans, objects, and the rest
232
- * of JS's anything-goes keys stay out. Shared by the frontend's
233
- * type mapping/diagnostics and the validator. Set ELEMENTS use the same
234
- * fence: a set is hashed storage of its elements exactly as a map is of
235
- * its keys (isSupportedSetElem is this predicate under its own name). */
236
- export function isSupportedMapKey(t) {
237
- return t.kind === "f64" || t.kind === "string";
238
- }
239
- /** The Set ELEMENT fence — Map's key fence plus the refcounted HANDLE
240
- * kinds stored under identity hashing (SameValueZero for JS objects IS
241
- * reference identity, so a Set of server handles — portless's auxiliary-
242
- * server registry — is honest hashed storage; SCR_MAP_KEY_REF in the
243
- * runtime). netServer is the one handle admitted so far: it drops its
244
- * listener closures at close, so a set-in-listener cycle is temporary —
245
- * the child precedent's story. Symbols are identity values by DESIGN —
246
- * SameValueZero on a symbol IS pointer identity, so a Set of symbols (the
247
- * sentinel-registry idiom) is the same honest hashed storage with no
248
- * cycle risk at all (symbols hold only strings). */
249
- export function isSupportedSetElem(t) {
250
- return isSupportedMapKey(t) || t.kind === "netServer" || t.kind === "symbol";
251
- }
252
- /** The Map VALUE fence: scalars plus every refcounted kind EXCEPT
253
- * func/promise/dyn/jsval (and map itself — no maps of maps).
243
+ /** Values whose native reference represents JavaScript identity. Records,
244
+ * classes and arrays can point back at their collection, so constructors
245
+ * must carry key tracing as well as retain/release adapters. */
246
+ export function isIdentityCollectionKey(t) {
247
+ return t.kind === "record" || t.kind === "object" || t.kind === "array" ||
248
+ t.kind === "netServer" || t.kind === "symbol";
249
+ }
250
+ /** Numbers use SameValueZero, strings use content, and reference keys use
251
+ * identity. A union of identity arms hashes its payload, never its temporary
252
+ * wrapper. Mixed scalar/reference unions remain outside this contract. */
253
+ export function isSupportedMapKey(t, unionArms) {
254
+ return t.kind === "f64" || t.kind === "string" || t.kind === "dyn" || isIdentityCollectionKey(t) ||
255
+ (t.kind === "union" && unionArms !== undefined && unionArms.length > 0 && unionArms.every(isIdentityCollectionKey));
256
+ }
257
+ /** Set elements and Map keys share storage, equality and ownership rules. */
258
+ export function isSupportedSetElem(t, unionArms) {
259
+ return isSupportedMapKey(t, unionArms);
260
+ }
261
+ /** The Map VALUE fence: scalars, supported native references and checked
262
+ * values. Functions require checked-value boxing; jsval has no native slot.
254
263
  * Record/object/union values can point back at the map holding them, which
255
264
  * is exactly why ref-valued maps are cycle-capable (see the backend's
256
265
  * cycle analysis and docs/memory.md). Shared frontend/validator. */
257
266
  export function isSupportedMapValue(t) {
258
267
  switch (t.kind) {
268
+ case "dyn":
259
269
  case "f64":
260
270
  case "bigint":
261
271
  case "string":
@@ -264,6 +274,10 @@ export function isSupportedMapValue(t) {
264
274
  case "object":
265
275
  case "union":
266
276
  case "array":
277
+ // Nested collections use the existing ref slot and scr_map adapters.
278
+ // Their key/value tracing participates in the cycle-analysis fixpoint.
279
+ case "map":
280
+ case "set":
267
281
  return true;
268
282
  // A spawned child handle (Map<string, ChildProcess> — the mdns
269
283
  // publisher registry): an ordinary refcounted pointer value (the
@@ -305,37 +319,26 @@ export function isSupportedMapValue(t) {
305
319
  /** The INDEX-SIGNATURE value fence (`{ [k: string]: V }` shapes): the map
306
320
  * VALUE kinds — the overflow portion IS a string-keyed map — plus dyn
307
321
  * (`unknown`, an unknown-valued pricing-table shape: overflow reads surface ordinary
308
- * dyn values validated by the usual checked casts) and three kinds the
309
- * overflow store carries that user Maps don't admit yet:
322
+ * dyn values validated by the usual checked casts) and callable values:
310
323
  * func — `Record<string, () => void>`, the command-registry pattern
311
324
  * (scr_closure adapters; closures are cycle-headered and traced,
312
325
  * so a handler capturing its own registry collects)
313
- * map/set — `Record<string, Map<K, V>>`/`Record<string, Set<T>>`
314
- * nested-container tables (scr_map adapters; a map value's own
315
- * cycle capability propagates through the trace fixpoint)
316
326
  * Nested index-signature RECORDS ride the record kind like any other.
317
327
  * Shared frontend (mapType) / validator. */
318
328
  export function isSupportedIndexValue(t) {
319
329
  return (t.kind === "dyn" ||
320
330
  t.kind === "func" ||
321
- t.kind === "map" ||
322
- t.kind === "set" ||
323
331
  isSupportedMapValue(t));
324
332
  }
325
333
  export function funcOf(params, ret) {
326
334
  return { kind: "func", params, ret };
327
335
  }
328
- /** The union FUNC/SET-arm sibling rule, shared by the frontend's union
329
- * builders and the validator: FUNC arms are valid beside ANY sibling —
330
- * `typeof x === "function"` narrows against data arms, unit tag tests
331
- * cover the nullable-callback shape, and between func arms closures
332
- * compare by pointer identity per tag (unionEq), so `x === String` is the
333
- * narrowing (the primitive-constructor tables' `StringConstructor |
334
- * NumberConstructor` field, and LinkOptions' `false | ((s: string) =>
335
- * string)`). A SET arm keeps the unit-only rule (no narrowing test
336
- * against data arms). */
337
- export function unionFuncSetArmsOk(arms) {
338
- return arms.every((a, i) => a.kind !== "set" || arms.every((b, j) => j === i || isUnitType(b)));
336
+ /** Maps, sets and promises may share a union with null/undefined only.
337
+ * Unit tag tests can narrow nullable containers without losing identity;
338
+ * arbitrary data siblings require a separate runtime narrowing operation.
339
+ * Share this rule across checker mapping, synthesized unions and validation. */
340
+ export function unionContainerArmsOk(arms) {
341
+ return arms.every((a, i) => (a.kind !== "map" && a.kind !== "set" && a.kind !== "promise") || arms.every((b, j) => j === i || isUnitType(b)));
339
342
  }
340
343
  /** Canonical, injective text form of an IrType — the building block of
341
344
  * shape/union identity keys, generic-function instantiation keys, and the
@@ -397,47 +400,36 @@ export function typeKey(t) {
397
400
  }
398
401
  }
399
402
  export function typeEquals(a, b) {
400
- if (a.kind === "array")
401
- return b.kind === "array" && typeEquals(a.elem, b.elem);
402
- if (a.kind === "bytes")
403
- return b.kind === "bytes" && a.elem === b.elem;
404
- if (a.kind === "map") {
405
- return b.kind === "map" && typeEquals(a.key, b.key) && typeEquals(a.value, b.value);
406
- }
407
- if (a.kind === "set")
408
- return b.kind === "set" && typeEquals(a.elem, b.elem);
409
- if (a.kind === "func") {
410
- return (b.kind === "func" &&
411
- a.params.length === b.params.length &&
412
- (a.rest === true) === (b.rest === true) &&
413
- a.restAbi === b.restAbi &&
414
- a.argumentsAll === b.argumentsAll &&
415
- a.params.every((p, i) => typeEquals(p, b.params[i])) &&
416
- typeEquals(a.ret, b.ret));
417
- }
418
- if (a.kind === "object")
419
- return b.kind === "object" && a.className === b.className;
420
- if (a.kind === "classval")
421
- return b.kind === "classval" && a.className === b.className;
422
- if (a.kind === "moduleNs")
423
- return b.kind === "moduleNs" && a.moduleId === b.moduleId;
424
- // The frontend deduplicates shapes structurally (one shapeId per canonical
425
- // field list), so id equality IS structural equality.
426
- if (a.kind === "record")
427
- return b.kind === "record" && a.shapeId === b.shapeId;
428
- // Unions are interned like shapes: one unionId per canonical arm list.
429
- if (a.kind === "union")
430
- return b.kind === "union" && a.unionId === b.unionId;
431
- if (a.kind === "promise")
432
- return b.kind === "promise" && typeEquals(a.inner, b.inner);
433
- if (a.kind === "generator") {
434
- return (b.kind === "generator" &&
435
- (a.async === true) === (b.async === true) &&
436
- typeEquals(a.yieldT, b.yieldT) &&
437
- typeEquals(a.retT, b.retT) &&
438
- typeEquals(a.nextT, b.nextT));
403
+ // Dispatch once: a chain of negative narrowing checks repeatedly retags
404
+ // the remaining variants when this comparator runs in the native compiler.
405
+ switch (a.kind) {
406
+ case "array": return b.kind === "array" && typeEquals(a.elem, b.elem);
407
+ case "bytes": return b.kind === "bytes" && a.elem === b.elem;
408
+ case "map": return b.kind === "map" && typeEquals(a.key, b.key) && typeEquals(a.value, b.value);
409
+ case "set": return b.kind === "set" && typeEquals(a.elem, b.elem);
410
+ case "func":
411
+ return (b.kind === "func" &&
412
+ a.params.length === b.params.length &&
413
+ (a.rest === true) === (b.rest === true) &&
414
+ a.restAbi === b.restAbi &&
415
+ a.argumentsAll === b.argumentsAll &&
416
+ a.params.every((p, i) => typeEquals(p, b.params[i])) &&
417
+ typeEquals(a.ret, b.ret));
418
+ case "object": return b.kind === "object" && a.className === b.className;
419
+ case "classval": return b.kind === "classval" && a.className === b.className;
420
+ case "moduleNs": return b.kind === "moduleNs" && a.moduleId === b.moduleId;
421
+ // Shapes and unions are interned, so their ids determine equality.
422
+ case "record": return b.kind === "record" && a.shapeId === b.shapeId;
423
+ case "union": return b.kind === "union" && a.unionId === b.unionId;
424
+ case "promise": return b.kind === "promise" && typeEquals(a.inner, b.inner);
425
+ case "generator":
426
+ return (b.kind === "generator" &&
427
+ (a.async === true) === (b.async === true) &&
428
+ typeEquals(a.yieldT, b.yieldT) &&
429
+ typeEquals(a.retT, b.retT) &&
430
+ typeEquals(a.nextT, b.nextT));
431
+ default: return a.kind === b.kind;
439
432
  }
440
- return a.kind === b.kind;
441
433
  }
442
434
  /** True for types whose values are heap-allocated and reference-counted.
443
435
  * The single dispatch point for the backend's RC machinery: retains,
@@ -459,12 +451,17 @@ export function isFfiContextParam(param) {
459
451
  /** Script-side type represented by one scalar/span FFI class. */
460
452
  export function ffiClassType(cls) {
461
453
  switch (cls) {
454
+ case "i64":
455
+ case "u64":
456
+ case "pointer":
457
+ return BIGINT_T;
462
458
  case "bool":
463
459
  return BOOL;
464
460
  case "cstring":
465
461
  case "string":
466
462
  return STRING;
467
463
  case "bytes":
464
+ case "mutable-bytes":
468
465
  return BYTES_U8;
469
466
  case "void":
470
467
  return VOID;
@@ -474,11 +471,14 @@ export function ffiClassType(cls) {
474
471
  }
475
472
  /** The ordinary TypeScript function type a native callback descriptor consumes. */
476
473
  export function ffiCallbackType(callback) {
474
+ const params = [];
475
+ for (const param of callback.params) {
476
+ if (!isFfiContextParam(param))
477
+ params.push(ffiClassType(param));
478
+ }
477
479
  return {
478
480
  kind: "func",
479
- params: callback.params
480
- .filter((param) => !isFfiContextParam(param))
481
- .map(ffiClassType),
481
+ params,
482
482
  ret: ffiClassType(callback.returns),
483
483
  };
484
484
  }
@@ -499,7 +499,7 @@ export function ffiSourceParamTypes(params) {
499
499
  * `class Error` can never collide). `lib` is the standard-library name the
500
500
  * frontend recognizes; `kind` is the runtime's SCR_ERR_* index (backends
501
501
  * stamp scr_error_vts[kind] and pick constructor kinds by it). Every
502
- * emitted module carries all four class defs (flagged `runtime`) so the
502
+ * emitted module carries the builtin class defs (flagged `runtime`) so the
503
503
  * program's preorder numbering always covers them — the runtime's own
504
504
  * throws (JSON/dynCheck/regex) mint instances of these classes whether or
505
505
  * not user code mentions Error. */
@@ -513,8 +513,11 @@ export const RUNTIME_ERROR_CLASSES = new Map([
513
513
  // cause) lives in runtime-side slots BEYOND the ScrError prefix the IR
514
514
  // fields describe, reached only through the error.dom* libCalls — so
515
515
  // user `extends DOMException` is fenced (the subclass layout would
516
- // overlap the hidden slots), where the other four extend freely.
516
+ // overlap the hidden slots), while the standard Error classes extend freely.
517
517
  ["%DOMException", { lib: "DOMException", kind: 4, base: "%Error" }],
518
+ ["%ReferenceError", { lib: "ReferenceError", kind: 5, base: "%Error" }],
519
+ ["%EvalError", { lib: "EvalError", kind: 6, base: "%Error" }],
520
+ ["%URIError", { lib: "URIError", kind: 7, base: "%Error" }],
518
521
  ]);
519
522
  /** The runtime-provided node:events EventEmitter class (ScrEmitter /
520
523
  * scr_emitter_*, scr_events_emitter.c — link-gated by moduleUsesEmitter,
@@ -548,6 +551,15 @@ export const RUNTIME_STREAM_CLASSES = new Map([
548
551
  ["%Transform", { lib: "Transform", base: "%Duplex", sides: "rw" }],
549
552
  ["%PassThrough", { lib: "PassThrough", base: "%Transform", sides: "rw" }],
550
553
  ]);
554
+ /** Codec records have private native state, not a structurally checkable
555
+ * data surface. Reserve the same '%' namespace as other internal slots. */
556
+ export function recordTextCodecClass(shape) {
557
+ if (shape.fields.some((f) => f.name === "%TextEncoder"))
558
+ return "TextEncoder";
559
+ if (shape.fields.some((f) => f.name === "%TextDecoder"))
560
+ return "TextDecoder";
561
+ return null;
562
+ }
551
563
  /** Object-literal ACCESSOR properties (`{ get x() {...}, set x(v) {...} }`)
552
564
  * live on the shape as reserved '%'-fields holding closures: `%get:x` a
553
565
  * `() => T` invoked once per property READ (side effects and all — JS's
@@ -583,6 +595,7 @@ export const MAY_THROW_BYTES_METHODS = new Set([
583
595
  "toStringVar",
584
596
  "with",
585
597
  "setFrom",
598
+ "setFromDyn",
586
599
  "readNum",
587
600
  "writeNum",
588
601
  "readNumVar",
@@ -704,38 +717,53 @@ export function isJsonSafeType(t, getRecord, getUnion) {
704
717
  export function isJsonStringifySafeType(t, getRecord, getUnion) {
705
718
  return isJsonSafeAt(t, getRecord, getUnion, true, false, new Set());
706
719
  }
720
+ /** A JSON-shaped container with unknown payloads needs the runtime JSON
721
+ * traversal. Its declared structure can be boxed, but payloads may carry
722
+ * omitted values, toJSON methods, or cycles. This predicate does not widen
723
+ * the type-directed serializer, checked-island boundary, or root-undefined
724
+ * contract; callers must select the checked runtime traversal explicitly. */
725
+ export function isJsonStringifyDynamicType(t, getRecord, getUnion) {
726
+ return (t.kind === "record" || t.kind === "array" || t.kind === "union") &&
727
+ isJsonSafeAt(t, getRecord, getUnion, true, false, new Set(), true) &&
728
+ !isJsonStringifySafeType(t, getRecord, getUnion);
729
+ }
707
730
  /** The recursion shared by checked JSON conversion and stringification.
708
731
  * Ordinary record fields always admit undefined by dropping the key. Array
709
- * and tuple slots admit it only for stringification, which writes null. */
710
- function isJsonSafeAt(t, getRecord, getUnion, stringify, undefinedAllowed, visiting) {
732
+ * and tuple slots admit it only for stringification, which writes null.
733
+ * Direct loops avoid allocating captured callbacks at each recursive edge. */
734
+ function isJsonSafeAt(t, getRecord, getUnion, stringify, undefinedAllowed, visiting, nativeFields = false) {
711
735
  if (HANDLE_KINDS.has(t.kind))
712
736
  return false;
713
737
  switch (t.kind) {
738
+ case "dyn":
739
+ return nativeFields;
714
740
  case "f64":
715
741
  case "string":
716
742
  case "bool":
717
743
  return true;
718
744
  case "array":
719
- return isJsonSafeAt(t.elem, getRecord, getUnion, stringify, stringify, visiting);
745
+ return isJsonSafeAt(t.elem, getRecord, getUnion, stringify, stringify, visiting, nativeFields);
720
746
  case "record": {
721
747
  const shape = getRecord(t.shapeId);
722
748
  if (!shape)
723
749
  return false;
750
+ if (recordTextCodecClass(shape) !== null)
751
+ return false;
724
752
  // The recursive knot: answer true and let the rest of the graph
725
- // decide (any unsafe constituent is found on its own path; a false
726
- // short-circuits every `every` up the walk).
753
+ // decide (any unsafe constituent ends the traversal immediately).
727
754
  if (visiting.has(t.shapeId))
728
755
  return true;
729
756
  visiting.add(t.shapeId);
730
- if (!shape.fields.every((f) => isJsonSafeAt(f.type, getRecord, getUnion, stringify, !shape.tuple || stringify, visiting))) {
731
- return false;
757
+ for (const field of shape.fields) {
758
+ if (!isJsonSafeAt(field.type, getRecord, getUnion, stringify, !shape.tuple || stringify, visiting, nativeFields))
759
+ return false;
732
760
  }
733
761
  // Overflow values sit in record-key position too: dyn is JSON-safe
734
762
  // HERE (the checked-dynamic tree serializes itself; undefined-valued entries drop
735
763
  // like any undefined-valued key), everything else follows the
736
764
  // record-field rule.
737
765
  if (shape.indexValue && shape.indexValue.kind !== "dyn") {
738
- return isJsonSafeAt(shape.indexValue, getRecord, getUnion, stringify, true, visiting);
766
+ return isJsonSafeAt(shape.indexValue, getRecord, getUnion, stringify, true, visiting, nativeFields);
739
767
  }
740
768
  return true;
741
769
  }
@@ -747,8 +775,20 @@ function isJsonSafeAt(t, getRecord, getUnion, stringify, undefinedAllowed, visit
747
775
  if (visiting.has(key))
748
776
  return true; // the recursive knot, union-flavored
749
777
  visiting.add(key);
750
- return def.arms.every((a) => a.kind === "undefinedT" ? undefinedAllowed : isJsonSafeAt(a, getRecord, getUnion, stringify, undefinedAllowed, visiting));
778
+ for (const arm of def.arms) {
779
+ if (!(arm.kind === "undefinedT" ? undefinedAllowed : isJsonSafeAt(arm, getRecord, getUnion, stringify, undefinedAllowed, visiting, nativeFields)))
780
+ return false;
781
+ }
782
+ return true;
751
783
  }
784
+ case "set":
785
+ return nativeFields && !stringify && t.elem.kind === "dyn";
786
+ case "bigint":
787
+ case "regex":
788
+ case "url":
789
+ return nativeFields && !stringify;
790
+ case "bytes":
791
+ return nativeFields;
752
792
  case "func":
753
793
  case "object":
754
794
  // Class values stringify as "{}" husks in Node (own enumerable statics
@@ -757,27 +797,13 @@ function isJsonSafeAt(t, getRecord, getUnion, stringify, undefinedAllowed, visit
757
797
  // Maps are not JSON (JSON.stringify(new Map()) is "{}" in Node — an
758
798
  // empty-object husk nobody wants; stringify/dynCheck reject instead).
759
799
  case "map":
760
- // Sets stringify as the same "{}" husk — rejected like Maps.
761
- case "set":
762
- // Regexes are not JSON (JSON.stringify(/a/) is "{}" in Node — the same
763
- // empty-object husk as Maps; stringify/dynCheck reject instead).
764
- case "regex":
765
800
  case "date":
766
- // URLs stringify as "{}" husks in Node too (data properties live on
767
- // internal slots) — rejected the same way; use url.href instead.
768
- case "url":
769
801
  // URLSearchParams stringifies as the same "{}" husk — rejected; use
770
802
  // sp.toString() instead.
771
803
  case "searchParams":
772
804
  // Symbols are DROPPED by Node's stringify (undefined at the top level,
773
805
  // omitted as object values) — silent divergence banned; rejected.
774
806
  case "symbol":
775
- case "bigint":
776
- // Typed arrays stringify as index-keyed objects ({"0":1,...}) and
777
- // Buffers as {type:"Buffer",data:[...]} in Node — neither shape is
778
- // representable type-directedly; rejected like Maps.
779
- case "bytes":
780
- case "dyn":
781
807
  case "jsval":
782
808
  case "caught":
783
809
  case "promise":
@@ -830,7 +856,8 @@ export function canMarshalFuncIntoIsland(t) {
830
856
  }
831
857
  /** Parameter types a TYPED closure may declare when it crosses INTO the
832
858
  * island as a host function: jsval params take the engine argument as a
833
- * handle (the all-'any' shape above); every other admitted type converts
859
+ * handle (the all-'any' shape above); dyn params normalize scalars or retain
860
+ * engine objects by reference. Every other admitted type converts
834
861
  * AT CALL TIME through the validated-exit machinery — strict primitives,
835
862
  * JSON round-trip composites (the dynCheck walker: width-tolerant records,
836
863
  * path-annotated failures). On top of the jsExit set, a bare `T | undefined`
@@ -839,7 +866,7 @@ export function canMarshalFuncIntoIsland(t) {
839
866
  * commander case: `.action((text: string | undefined, opts) => ...)` sees
840
867
  * undefined when the command argument is omitted). */
841
868
  export function isIslandCallbackParamType(t, getRecord, getUnion) {
842
- if (t.kind === "jsval")
869
+ if (t.kind === "jsval" || t.kind === "dyn")
843
870
  return true;
844
871
  if (isJsonSafeType(t, getRecord, getUnion))
845
872
  return true;
@@ -884,8 +911,8 @@ export function islandCallbackRet(t, getRecord, getUnion) {
884
911
  * closures whose params are per-argument-convertible at call time
885
912
  * (isIslandCallbackParamType) and whose return classifies
886
913
  * (islandCallbackRet). Same arity cap — the runtime's host-call argument
887
- * buffer. Closures taking closures and 'unknown'-typed params stay fenced
888
- * (no per-type extraction exists for them inside a host call). */
914
+ * buffer. Statically typed closure parameters stay fenced; unknown values
915
+ * enter as checked-dynamic values and are validated at each typed use. */
889
916
  export function canMarshalTypedFuncIntoIsland(t, getRecord, getUnion) {
890
917
  if (t.kind !== "func")
891
918
  return false;
@@ -932,7 +959,7 @@ export function canMarshalTypedFuncIntoIsland(t, getRecord, getUnion) {
932
959
  * through a dyn value), properties ON function values, and params/results
933
960
  * outside the conversion domains (Maps, class instances, ...). Promises
934
961
  * CONVERT in (canConvertToDyn's promise arm — an async dyn-boxed closure's
935
- * return) but do not check OUT (`u as Promise<T>` stays fenced).
962
+ * return); checking OUT preserves the boxed Promise<unknown> payload ABI.
936
963
  */
937
964
  /** The runtime HANDLE kinds that cross the checked-dynamic boundary as
938
965
  * the checked-dynamic tree's HANDLE kind (SCR_DYN_HANDLE): boxed by REFERENCE (identity —
@@ -946,6 +973,7 @@ export function canMarshalTypedFuncIntoIsland(t, getRecord, getUnion) {
946
973
  * (dynCheck's "expected IncomingMessage ..." texts). */
947
974
  export const DYN_HANDLE_KINDS = new Map([
948
975
  ["child", { tag: "SCR_DYNH_CHILD", cls: "ChildProcess" }],
976
+ ["fileHandle", { tag: "SCR_DYNH_FILE_HANDLE", cls: "FileHandle" }],
949
977
  ["httpReq", { tag: "SCR_DYNH_HTTP_REQ", cls: "IncomingMessage" }],
950
978
  ["httpRes", { tag: "SCR_DYNH_HTTP_RES", cls: "ServerResponse" }],
951
979
  ["netSocket", { tag: "SCR_DYNH_NET_SOCKET", cls: "Socket" }],
@@ -968,31 +996,51 @@ export function isDynTypedRefType(t) {
968
996
  export function isClassOwnEnumerableFieldName(name) {
969
997
  return !name.startsWith("#") && !name.startsWith("%");
970
998
  }
999
+ /** Compiler-owned storage for properties added through untyped references. */
1000
+ export const DYN_CLASS_PROPERTIES = "%dynProperties";
1001
+ /** A class capsule can always preserve its exact native identity. Its
1002
+ * optional property view additionally needs converters in both directions;
1003
+ * fields such as Maps may remain opaque without preventing the round trip. */
1004
+ export function classDynViewSupported(fields, getRecord, getUnion) {
1005
+ const checkable = (type) => {
1006
+ if (isDynTypedRefType(type) || isUnitType(type))
1007
+ return true;
1008
+ if (type.kind === "union")
1009
+ return getUnion(type.unionId)?.arms.every(checkable) ?? false;
1010
+ return canDynCheckTo(type, getRecord, getUnion);
1011
+ };
1012
+ return fields.every((field) => !isClassOwnEnumerableFieldName(field.name) ||
1013
+ (canConvertToDyn(field.type, getRecord, getUnion) && checkable(field.type)));
1014
+ }
971
1015
  /** A static type that CONVERTS into a dyn value — the dynFrom domain:
972
- * JSON-safe data, bytes<u8> (payload copied), identity-preserving class
1016
+ * JSON-safe data, numeric typed arrays (retained views), identity-preserving class
973
1017
  * references, undefined-armed unions of those arms, boxable function types,
974
1018
  * and the runtime HANDLE kinds (boxed by reference — DYN_HANDLE_KINDS). */
975
- export function canConvertToDyn(t, getRecord, getUnion) {
1019
+ export function canConvertToDyn(t, getRecord, getUnion, visiting = new Set()) {
976
1020
  if (isJsonSafeType(t, getRecord, getUnion))
977
1021
  return true;
978
- // bytes<u8> and boxable functions are dyn kinds the walker boxes
979
- // ANYWHERE (bytes copied, functions held by identity), including nested
1022
+ // numeric typed arrays and boxable functions are dyn kinds the walker boxes
1023
+ // ANYWHERE (bytes and functions held by identity), including nested
980
1024
  // in records/arrays/unions. isJsonSafeType rejects them, but dynFrom
981
1025
  // needs only that the walker can build the dyn value, so this composite
982
1026
  // fold extends the JSON-safe core.
983
- if (canBoxDynComposite(t, getRecord, getUnion))
1027
+ if (canBoxDynComposite(t, getRecord, getUnion, visiting))
984
1028
  return true;
985
- if (t.kind === "bytes" && t.elem === "u8")
1029
+ if (t.kind === "bytes")
986
1030
  return true;
987
- // %Error converts as the checked-dynamic tree's error encoding ({%error, name, message,
1031
+ // Built-in errors convert as the checked-dynamic tree's error encoding ({%error, name, message,
988
1032
  // code?} — the caughtToDyn shape, scr_dyn_from_error): the dyn 'error'
989
1033
  // listener boundary (a mustCall-wrapped handler receiving the payload).
990
- if (t.kind === "object" && t.className === "%Error")
1034
+ if (t.kind === "object" && RUNTIME_ERROR_CLASSES.has(t.className))
991
1035
  return true;
992
1036
  if (isDynTypedRefType(t))
993
1037
  return true;
1038
+ if (t.kind === "generator")
1039
+ return true;
1040
+ if (t.kind === "classval")
1041
+ return true;
994
1042
  if (t.kind === "func")
995
- return canBoxFuncIntoDyn(t, getRecord, getUnion);
1043
+ return canBoxFuncIntoDyn(t, getRecord, getUnion, visiting);
996
1044
  if (DYN_HANDLE_KINDS.has(t.kind))
997
1045
  return true;
998
1046
  // Promises box by REFERENCE (SCR_DYN_PROMISE): promise<dyn> carries its
@@ -1004,7 +1052,7 @@ export function canConvertToDyn(t, getRecord, getUnion) {
1004
1052
  if (t.kind === "promise") {
1005
1053
  return (t.inner.kind === "dyn" ||
1006
1054
  t.inner.kind === "void" ||
1007
- canConvertToDyn(t.inner, getRecord, getUnion));
1055
+ canConvertToDyn(t.inner, getRecord, getUnion, visiting));
1008
1056
  }
1009
1057
  if (t.kind === "union") {
1010
1058
  const def = getUnion(t.unionId);
@@ -1013,44 +1061,77 @@ export function canConvertToDyn(t, getRecord, getUnion) {
1013
1061
  // union's func arm crosses through the checked-dynamic function
1014
1062
  // boundary exactly like a bare func dynFrom).
1015
1063
  return !!def && def.arms.every((a) => a.kind === "undefinedT" || isJsonSafeType(a, getRecord, getUnion) ||
1016
- isDynTypedRefType(a) || DYN_HANDLE_KINDS.has(a.kind) ||
1017
- (a.kind === "func" && canBoxFuncIntoDyn(a, getRecord, getUnion)) ||
1018
- (a.kind === "promise" && canConvertToDyn(a, getRecord, getUnion)));
1064
+ isDynTypedRefType(a) || a.kind === "classval" || DYN_HANDLE_KINDS.has(a.kind) ||
1065
+ (a.kind === "func" && canBoxFuncIntoDyn(a, getRecord, getUnion, visiting)) ||
1066
+ (a.kind === "promise" && canConvertToDyn(a, getRecord, getUnion, visiting)));
1019
1067
  }
1020
1068
  return false;
1021
1069
  }
1022
1070
  /** The composite extension of the dynFrom domain: JSON-safe scalars plus
1023
- * bytes<u8> and boxable functions anywhere, recursing through records
1071
+ * numeric typed arrays and boxable functions anywhere, recursing through records
1024
1072
  * (fields + index value), arrays, and unit-armed unions — exactly the
1025
- * sc_td_* walker's capability. Returns false for a composite carrying a
1026
- * kind the walker cannot box (Maps or handles nested in a record); those
1027
- * still fence. */
1073
+ * sc_td_* walker's capability. Map and Set payloads must also support
1074
+ * checked extraction back into native storage. Other unsupported nested
1075
+ * kinds retain their conversion fence. */
1028
1076
  function canBoxDynComposite(t, getRecord, getUnion, visiting = new Set()) {
1077
+ const key = `boxed:${typeKey(t)}`;
1078
+ if (visiting.has(key))
1079
+ return true;
1080
+ const result = canBoxDynCompositeAt(t, getRecord, getUnion, visiting);
1081
+ if (result)
1082
+ visiting.add(key);
1083
+ else
1084
+ clearDynConversionResults(visiting);
1085
+ return result;
1086
+ }
1087
+ function canBoxDynCompositeAt(t, getRecord, getUnion, visiting) {
1029
1088
  switch (t.kind) {
1030
1089
  case "f64":
1090
+ case "bigint":
1091
+ case "symbol":
1031
1092
  case "string":
1032
1093
  case "bool":
1033
1094
  case "dyn":
1034
1095
  case "undefinedT":
1035
1096
  case "nullT":
1097
+ case "classval":
1036
1098
  return true;
1037
1099
  case "bytes":
1038
- return t.elem === "u8";
1100
+ case "regex":
1101
+ case "url":
1102
+ case "searchParams":
1103
+ return true;
1039
1104
  case "func":
1040
- return canBoxFuncIntoDyn(t, getRecord, getUnion);
1105
+ return canBoxFuncIntoDyn(t, getRecord, getUnion, visiting);
1106
+ case "set":
1107
+ return canConvertToDyn(t.elem, getRecord, getUnion, visiting) && canDynCheckTo(t.elem, getRecord, getUnion, visiting);
1108
+ case "map":
1109
+ return canConvertToDyn(t.key, getRecord, getUnion, visiting) && canDynCheckTo(t.key, getRecord, getUnion, visiting) &&
1110
+ canConvertToDyn(t.value, getRecord, getUnion, visiting) && canDynCheckTo(t.value, getRecord, getUnion, visiting);
1111
+ case "object":
1112
+ return RUNTIME_ERROR_CLASSES.has(t.className) || isDynTypedRefType(t);
1041
1113
  case "array":
1042
1114
  return canBoxDynComposite(t.elem, getRecord, getUnion, visiting);
1043
1115
  case "record": {
1044
1116
  const shape = getRecord(t.shapeId);
1045
1117
  if (!shape)
1046
1118
  return false;
1119
+ if (recordTextCodecClass(shape) !== null)
1120
+ return false;
1047
1121
  // Recursive shapes answer coinductively, like isJsonSafeType.
1048
1122
  if (visiting.has(t.shapeId))
1049
1123
  return true;
1050
1124
  visiting.add(t.shapeId);
1051
- if (!shape.fields.every((f) => canBoxDynComposite(f.type, getRecord, getUnion, visiting)))
1052
- return false;
1053
- return !shape.indexValue || canBoxDynComposite(shape.indexValue, getRecord, getUnion, visiting);
1125
+ try {
1126
+ for (const field of shape.fields) {
1127
+ if (!canBoxDynComposite(field.type, getRecord, getUnion, visiting))
1128
+ return false;
1129
+ }
1130
+ return !shape.indexValue || canBoxDynComposite(shape.indexValue, getRecord, getUnion, visiting);
1131
+ }
1132
+ finally {
1133
+ visiting.delete(t.shapeId);
1134
+ }
1054
1135
  }
1055
1136
  case "union": {
1056
1137
  const def = getUnion(t.unionId);
@@ -1059,31 +1140,104 @@ function canBoxDynComposite(t, getRecord, getUnion, visiting = new Set()) {
1059
1140
  if (visiting.has(t.unionId))
1060
1141
  return true;
1061
1142
  visiting.add(t.unionId);
1062
- return def.arms.every((a) => canBoxDynComposite(a, getRecord, getUnion, visiting));
1143
+ try {
1144
+ for (const arm of def.arms) {
1145
+ if (!canBoxDynComposite(arm, getRecord, getUnion, visiting))
1146
+ return false;
1147
+ }
1148
+ return true;
1149
+ }
1150
+ finally {
1151
+ visiting.delete(t.unionId);
1152
+ }
1063
1153
  }
1064
1154
  default:
1065
1155
  return false;
1066
1156
  }
1067
1157
  }
1068
1158
  /** A type a dyn value can be VALIDATED into — the dynCheck domain:
1069
- * JSON-safe data, bytes<u8> (a fresh copy out), the %Error extraction,
1159
+ * JSON-safe data, numeric typed arrays (retained views), the %Error extraction,
1070
1160
  * undefined-armed unions of JSON-safe arms, adaptable function types,
1071
1161
  * and the runtime HANDLE kinds (a tag-checked reference unwrap —
1072
1162
  * DYN_HANDLE_KINDS). */
1073
- export function canDynCheckTo(t, getRecord, getUnion) {
1074
- if (isJsonSafeType(t, getRecord, getUnion))
1163
+ export function canDynCheckTo(t, getRecord, getUnion, visiting = new Set()) {
1164
+ const key = `checked:${typeKey(t)}`;
1165
+ if (visiting.has(key))
1075
1166
  return true;
1076
- if (t.kind === "bytes" && t.elem === "u8")
1167
+ const result = canDynCheckToAt(t, getRecord, getUnion, visiting);
1168
+ if (result)
1169
+ visiting.add(key);
1170
+ else
1171
+ clearDynConversionResults(visiting);
1172
+ return result;
1173
+ }
1174
+ /** Reuse completed subgraphs within one conversion query. A failed branch
1175
+ * invalidates successes that may depend on a coinductive back-edge to it;
1176
+ * active recursion keys remain until their owning calls unwind. */
1177
+ function clearDynConversionResults(visiting) {
1178
+ for (const key of visiting) {
1179
+ if (key.startsWith("boxed:") || key.startsWith("checked:"))
1180
+ visiting.delete(key);
1181
+ }
1182
+ }
1183
+ function canDynCheckToAt(t, getRecord, getUnion, visiting) {
1184
+ // Unknown fields keep an owned dyn subtree; checking the surrounding
1185
+ // record/array still validates its layout. This is broader than the
1186
+ // stringify/island JSON domain, which cannot assume opaque slots are
1187
+ // serializable. Backends already retain dyn fields and fill missing
1188
+ // unknown record fields with the undefined value.
1189
+ if (isJsonSafeAt(t, getRecord, getUnion, false, false, new Set(), true))
1190
+ return true;
1191
+ if (t.kind === "bigint" || t.kind === "symbol" || t.kind === "date" || t.kind === "searchParams")
1192
+ return true;
1193
+ if (t.kind === "map" || t.kind === "set")
1194
+ return canBoxDynComposite(t, getRecord, getUnion, visiting);
1195
+ if (t.kind === "bytes")
1196
+ return true;
1197
+ if (t.kind === "classval")
1198
+ return true;
1199
+ if (t.kind === "generator")
1077
1200
  return true;
1201
+ if (t.kind === "promise")
1202
+ return t.inner.kind === "dyn" || t.inner.kind === "void" || canDynCheckToAt(t.inner, getRecord, getUnion, visiting);
1078
1203
  if (t.kind === "object" && t.className === "%Error")
1079
1204
  return true;
1205
+ // Native class capsules already support checked extraction at ordinary
1206
+ // boundaries. Callable adapters use the same identity/brand check.
1207
+ if (isDynTypedRefType(t))
1208
+ return true;
1209
+ if (t.kind === "array") {
1210
+ const key = typeKey(t);
1211
+ if (visiting.has(key))
1212
+ return false;
1213
+ visiting.add(key);
1214
+ const result = canDynCheckTo(t.elem, getRecord, getUnion, visiting);
1215
+ visiting.delete(key);
1216
+ return result;
1217
+ }
1218
+ if (t.kind === "record") {
1219
+ const key = typeKey(t);
1220
+ if (visiting.has(key))
1221
+ return false;
1222
+ const shape = getRecord(t.shapeId);
1223
+ if (!shape || shapeHasAccessorSlots(shape))
1224
+ return false;
1225
+ visiting.add(key);
1226
+ const result = shape.fields.every((field) => canDynCheckTo(field.type, getRecord, getUnion, visiting)) &&
1227
+ (!shape.indexValue || canDynCheckTo(shape.indexValue, getRecord, getUnion, visiting));
1228
+ visiting.delete(key);
1229
+ return result;
1230
+ }
1080
1231
  if (t.kind === "func")
1081
- return canAdaptDynFuncTo(t, getRecord, getUnion);
1232
+ return canAdaptDynFuncTo(t, getRecord, getUnion, visiting);
1082
1233
  if (DYN_HANDLE_KINDS.has(t.kind))
1083
1234
  return true;
1084
1235
  if (t.kind === "union") {
1085
1236
  const def = getUnion(t.unionId);
1086
- return !!def && def.arms.every((a) => a.kind === "undefinedT" || isJsonSafeType(a, getRecord, getUnion));
1237
+ // Optional native callbacks and handles retain the same checked
1238
+ // conversion as their bare value. The union matcher selects the arm
1239
+ // before its adapter/extractor runs.
1240
+ return !!def && def.arms.every((a) => isUnitType(a) || (a.kind !== "union" && canDynCheckTo(a, getRecord, getUnion, visiting)));
1087
1241
  }
1088
1242
  return false;
1089
1243
  }
@@ -1091,34 +1245,34 @@ export function canDynCheckTo(t, getRecord, getUnion) {
1091
1245
  * every param dyn or dynCheckable (the thunk validates dyn arguments into
1092
1246
  * them), return void, dyn, or dyn-convertible (the thunk converts it
1093
1247
  * back). */
1094
- export function canBoxFuncIntoDyn(t, getRecord, getUnion) {
1248
+ export function canBoxFuncIntoDyn(t, getRecord, getUnion, visiting = new Set()) {
1095
1249
  return (t.kind === "func" &&
1096
- // Only the legacy hidden-dyn rest ABI has a checked-dynamic call thunk.
1097
- // Typed rest stays static (its trailing array is compiler-packed), and
1098
- // island rest has its separate engine host-callback adapter.
1099
- (t.rest !== true || t.restAbi === undefined) &&
1250
+ // Typed rest occupies the final native array parameter; its thunk
1251
+ // checks a fresh array containing all remaining call arguments.
1252
+ // Island rest keeps its separate engine host-callback adapter.
1253
+ (t.rest !== true || t.restAbi === undefined ||
1254
+ (t.restAbi === "typed" && t.params.at(-1)?.kind === "array")) &&
1100
1255
  // A jsval (island) param converts through scr_jsval_from_dyn in the
1101
1256
  // thunk (wrapped cells unwrap by reference, dyn data deep-copies) —
1102
1257
  // the checker-'any' callback params of the routed-dispatch lane
1103
1258
  // (`bag.list.map((x) => ...)` with x typed any).
1104
- t.params.every((p) => p.kind === "dyn" || p.kind === "jsval" || canDynCheckTo(p, getRecord, getUnion)) &&
1259
+ t.params.every((p) => p.kind === "dyn" || p.kind === "jsval" || canDynCheckTo(p, getRecord, getUnion, visiting)) &&
1105
1260
  // A jsval return converts through the by-reference wrap
1106
1261
  // (dynFromJsval — the thunk's result conversion), so engine-returning
1107
1262
  // callbacks box too: the routed-dispatch lane's flatMap shape.
1108
- (t.ret.kind === "void" || t.ret.kind === "dyn" || t.ret.kind === "jsval" || canConvertToDyn(t.ret, getRecord, getUnion)));
1263
+ (t.ret.kind === "void" || t.ret.kind === "dyn" || t.ret.kind === "jsval" || canConvertToDyn(t.ret, getRecord, getUnion, visiting)));
1109
1264
  }
1110
1265
  /** A closure type a dyn function value can ADAPT to (dynCheck): every
1111
1266
  * param dyn or dyn-convertible (the adapter converts typed arguments into
1112
1267
  * dyn), return void, dyn, or dynCheckable (the adapter validates the dyn
1113
1268
  * result). */
1114
- export function canAdaptDynFuncTo(t, getRecord, getUnion) {
1269
+ export function canAdaptDynFuncTo(t, getRecord, getUnion, visiting = new Set()) {
1115
1270
  return (t.kind === "func" &&
1116
- // A variadic (rest-marked) target would need the trailing rest-array
1117
- // param synthesized by the adapter — no adapter models that; variadic
1118
- // values live boxed and are called through their own thunks.
1119
- t.rest !== true &&
1120
- t.params.every((p) => p.kind === "dyn" || canConvertToDyn(p, getRecord, getUnion)) &&
1121
- (t.ret.kind === "void" || t.ret.kind === "dyn" || canDynCheckTo(t.ret, getRecord, getUnion)));
1271
+ // Checked rest and arguments packs retain all actual arguments. Typed
1272
+ // and island rest ABIs still require their own conversion plan.
1273
+ (t.rest !== true || t.restAbi === undefined) &&
1274
+ t.params.every((p) => p.kind === "dyn" || canConvertToDyn(p, getRecord, getUnion, visiting)) &&
1275
+ (t.ret.kind === "void" || t.ret.kind === "dyn" || canDynCheckTo(t.ret, getRecord, getUnion, visiting)));
1122
1276
  }
1123
1277
  /** The MARSHAL-direction boundary (jsMarshal): everything that can cross
1124
1278
  * out and back (canCrossIslandBoundary) plus qualifying closures — those
@@ -1177,130 +1331,227 @@ export function canExitIslandToType(t, getRecord, getUnion) {
1177
1331
  }
1178
1332
  return false;
1179
1333
  }
1334
+ const DYN_ASYNC_LIB_FNS = new Set([
1335
+ "fs.callbackValue", "fs.callbackCall",
1336
+ "async.awaitDyn", "timers.immediatePromise", "crypto.native",
1337
+ "process.onUncaughtException", "process.offUncaughtException",
1338
+ "process.onUnhandledRejection", "process.offUnhandledRejection",
1339
+ "process.onRejectionHandled", "process.offRejectionHandled",
1340
+ "process.onWarning", "process.offWarning", "process.emitWarning",
1341
+ "als.new", "als.get", "als.run", "als.exitRun", "als.enterWith", "als.disable",
1342
+ "dc.chanBindStore", "dc.chanUnbindStore", "dc.chanRunStores",
1343
+ ]);
1344
+ /** Inspect types and expressions together in one traversal. This is a fresh
1345
+ * snapshot: callers may mutate an IR module between compilation passes. */
1346
+ export function moduleRuntimeFeatures(mod) {
1347
+ return scanRuntimeFeatures(mod);
1348
+ }
1349
+ function scanRuntimeFeatures(mod, stopAt) {
1350
+ const features = {
1351
+ regex: false, copying: false, legacyTextDecoder: false, fileHandle: false,
1352
+ fetch: mod.embedded?.modules.some((m) => m.usesFetch === true) ?? false,
1353
+ processEvents: false, emitter: (mod.classes ?? []).some((c) => c.name === RUNTIME_EMITTER_CLASS),
1354
+ stream: (mod.classes ?? []).some((c) => RUNTIME_STREAM_CLASSES.has(c.name)),
1355
+ zlib: mod.embedded?.edges.some((e) => e.to === "node:zlib") ?? false,
1356
+ dc: false, assert: false, dynInvoke: false,
1357
+ dynAsync: mod.functions.some((fn) => fn.async === true && fn.generator === undefined && fn.returnType.kind === "dyn"),
1358
+ inspect: false,
1359
+ childProcess: false, net: false, symbol: false, bigint: false, searchParams: false,
1360
+ qs: false, parseArgs: false, fsWatch: false, nodeTest: false, dgram: false,
1361
+ http: false, http2: false, tls: false, tlsCa: false,
1362
+ };
1363
+ const keepGoing = () => stopAt === undefined || !features[stopAt];
1364
+ const expr = (node) => {
1365
+ if (node.kind === "libCall") {
1366
+ const fn = node.fn;
1367
+ if (fn === "regexp.escape" || fn === "dyn.nativeRegexIs")
1368
+ features.regex = true;
1369
+ if (fn === "text.decodeLegacy" || fn === "text.decodeLegacyOptions" || fn === "text.decodeStream")
1370
+ features.legacyTextDecoder = true;
1371
+ if (fn.startsWith("fetch."))
1372
+ features.fetch = true;
1373
+ if (PROCESS_EVENT_LIB_FNS.has(fn))
1374
+ features.processEvents = true;
1375
+ if (fn.startsWith("emitter."))
1376
+ features.emitter = true;
1377
+ if (fn.startsWith("readable.") || fn.startsWith("writable.") || fn.startsWith("duplex.") ||
1378
+ fn.startsWith("transform.") || fn.startsWith("passthrough.") || fn.startsWith("sc.") ||
1379
+ fn.startsWith("stream.set") || fn === "stream.destroy" || fn === "stream.destroyErr" ||
1380
+ fn === "stream.prop" || fn === "stream.errored" || fn === "sp.finished" || fn === "sp.pipeline")
1381
+ features.stream = true;
1382
+ if (fn.startsWith("zlib."))
1383
+ features.zlib = true;
1384
+ if (fn.startsWith("dc."))
1385
+ features.dc = true;
1386
+ if (fn.startsWith("assert."))
1387
+ features.assert = true;
1388
+ if (fn === "dyn.defineProps" || fn === "dyn.defineProperty" || fn === "dyn.objCreateWithProperties" || fn === "dyn.arrayProtoCall" || fn === "dyn.arrayPrototype" || fn === "dyn.functionApply" || fn === "dyn.builtinMethod")
1389
+ features.dynInvoke = true;
1390
+ if (DYN_ASYNC_LIB_FNS.has(fn))
1391
+ features.dynAsync = true;
1392
+ if (fn.startsWith("insp.") || fn === "console.native" || fn === "global.native")
1393
+ features.inspect = true;
1394
+ if (fn.startsWith("cp.") || fn.startsWith("child.") || fn.startsWith("writer.") || fn.startsWith("spawnRes.") ||
1395
+ fn === "process.forkTarget" || fn === "process.connected" || fn === "process.send" || fn === "process.sendCb" ||
1396
+ fn === "process.disconnect" || fn === "process.onMessage" || fn === "process.onDisconnect")
1397
+ features.childProcess = true;
1398
+ if (fn.startsWith("net."))
1399
+ features.net = true;
1400
+ if (fn.startsWith("http.")) {
1401
+ features.net = true;
1402
+ features.http = true;
1403
+ }
1404
+ if (fn.startsWith("tls.") || fn.startsWith("https.") || fn.startsWith("http2.")) {
1405
+ features.net = true;
1406
+ features.http = true;
1407
+ features.tls = true;
1408
+ }
1409
+ if (fn.startsWith("http2.") && !HTTP2_LEGACY_FNS.has(fn))
1410
+ features.http2 = true;
1411
+ if (fn.startsWith("sym."))
1412
+ features.symbol = true;
1413
+ if (fn === "process.hrtimeValue")
1414
+ features.bigint = true;
1415
+ if (fn.startsWith("bigint."))
1416
+ features.bigint = true;
1417
+ if (fn.startsWith("sp.") || fn === "url.searchParams")
1418
+ features.searchParams = true;
1419
+ if (fn === "qs.parse" || fn === "qs.stringify" || fn === "qs.unescape")
1420
+ features.qs = true;
1421
+ if (fn === "util.parseArgs")
1422
+ features.parseArgs = true;
1423
+ if (fn.startsWith("fs.watch") || fn.startsWith("watcher."))
1424
+ features.fsWatch = true;
1425
+ if (fn.startsWith("test."))
1426
+ features.nodeTest = true;
1427
+ if (fn.startsWith("dgram.") || fn.startsWith("dns."))
1428
+ features.dgram = true;
1429
+ if (fn.startsWith("tlsca."))
1430
+ features.tlsCa = true;
1431
+ }
1432
+ else {
1433
+ switch (node.kind) {
1434
+ case "regexLit":
1435
+ case "regexIntrinsic":
1436
+ features.regex = true;
1437
+ break;
1438
+ case "strIntrinsic":
1439
+ if (node.method === "toLowerCase" || node.method === "toUpperCase")
1440
+ features.regex = true;
1441
+ break;
1442
+ case "arrIntrinsic":
1443
+ if (node.method === "toReversed" || node.method === "toSpliced" || node.method === "with" || node.method === "withUndefined")
1444
+ features.copying = true;
1445
+ break;
1446
+ case "bytesIntrinsic":
1447
+ if (node.method === "toReversed" || node.method === "with" || node.method === "join" || node.method === "toArray")
1448
+ features.copying = true;
1449
+ break;
1450
+ case "jsOp":
1451
+ if (node.op === "globalGet" && node.name === "fetch")
1452
+ features.fetch = true;
1453
+ break;
1454
+ case "dynInvoke":
1455
+ features.dynInvoke = true;
1456
+ break;
1457
+ case "awaitExpr":
1458
+ if (node.type.kind === "dyn")
1459
+ features.dynAsync = true;
1460
+ break;
1461
+ case "dynFrom": {
1462
+ const boxed = node.value.type;
1463
+ if (boxed.kind === "promise" || (boxed.kind === "func" && boxed.ret.kind === "promise"))
1464
+ features.dynAsync = true;
1465
+ break;
1466
+ }
1467
+ }
1468
+ }
1469
+ return keepGoing();
1470
+ };
1471
+ const type = (node) => {
1472
+ switch (node.kind) {
1473
+ case "regex":
1474
+ features.regex = true;
1475
+ break;
1476
+ case "fileHandle":
1477
+ features.fileHandle = true;
1478
+ break;
1479
+ case "child":
1480
+ case "childStream":
1481
+ case "childWriter":
1482
+ case "spawnRes":
1483
+ features.childProcess = true;
1484
+ break;
1485
+ case "netServer":
1486
+ case "netSocket":
1487
+ features.net = true;
1488
+ break;
1489
+ case "http2Session":
1490
+ case "http2Stream":
1491
+ features.net = true;
1492
+ features.http2 = true;
1493
+ break;
1494
+ case "httpReq":
1495
+ case "httpRes":
1496
+ case "httpClientReq":
1497
+ features.net = true;
1498
+ features.http = true;
1499
+ break;
1500
+ case "secureCtx":
1501
+ features.net = true;
1502
+ features.http = true;
1503
+ features.tls = true;
1504
+ break;
1505
+ case "symbol":
1506
+ features.symbol = true;
1507
+ break;
1508
+ case "bigint":
1509
+ features.bigint = true;
1510
+ break;
1511
+ case "searchParams":
1512
+ features.searchParams = true;
1513
+ break;
1514
+ case "fsWatcher":
1515
+ features.fsWatch = true;
1516
+ break;
1517
+ case "testCtx":
1518
+ features.nodeTest = true;
1519
+ break;
1520
+ case "dgramSocket":
1521
+ features.dgram = true;
1522
+ break;
1523
+ }
1524
+ return keepGoing();
1525
+ };
1526
+ if (keepGoing())
1527
+ everyModuleNode(mod, { expr, stmt: keepGoing, type });
1528
+ return features;
1529
+ }
1180
1530
  /** True when the module contains any regex construct — a regexLit /
1181
1531
  * regexIntrinsic node or a regex-typed slot anywhere. This is the link
1182
1532
  * switch that pulls scr_regex.c + the vendored libregexp into the binary
1183
- * (native-toolchain.ts); regex-free programs keep the historical command line. A generic
1184
- * JSON walk: `kind` discriminants live only on IR objects, so user string
1185
- * VALUES can never false-positive. */
1533
+ * (native-toolchain.ts); regex-free programs keep the historical command line. The
1534
+ * typed traversal visits type slots as well as executable nodes. */
1186
1535
  export function moduleUsesRegex(mod) {
1187
- let found = false;
1188
- const visit = (v) => {
1189
- if (found || v === null || typeof v !== "object")
1190
- return;
1191
- if (Array.isArray(v)) {
1192
- for (const item of v)
1193
- visit(item);
1194
- return;
1195
- }
1196
- const kind = v.kind;
1197
- if (kind === "regex" || kind === "regexLit" || kind === "regexIntrinsic") {
1198
- found = true;
1199
- return;
1200
- }
1201
- // The lre-backed case conversions live in scr_regex.c (libunicode's
1202
- // case tables): they ride the same link switch as regex nodes.
1203
- if (kind === "strIntrinsic") {
1204
- const method = v.method;
1205
- if (method === "toLowerCase" || method === "toUpperCase") {
1206
- found = true;
1207
- return;
1208
- }
1209
- }
1210
- // RegExp.escape lives in scr_regex.c too (needing no engine — it
1211
- // keeps the always-linked string TU out of hello-world's size class).
1212
- if (kind === "libCall" && v.fn === "regexp.escape") {
1213
- found = true;
1214
- return;
1215
- }
1216
- for (const key of Object.keys(v))
1217
- visit(v[key]);
1218
- };
1219
- visit(mod);
1220
- return found;
1536
+ return scanRuntimeFeatures(mod, "regex").regex;
1221
1537
  }
1222
1538
  /** True when the module contains an intrinsic whose implementation lives
1223
1539
  * in scr_copying.c. This is the link switch that keeps the optional
1224
1540
  * Array-copying and typed-array bridge TU out of unrelated binaries. */
1225
1541
  export function moduleUsesCopying(mod) {
1226
- let found = false;
1227
- const visit = (v) => {
1228
- if (found || v === null || typeof v !== "object")
1229
- return;
1230
- if (Array.isArray(v)) {
1231
- for (const item of v)
1232
- visit(item);
1233
- return;
1234
- }
1235
- const node = v;
1236
- if (node.kind === "arrIntrinsic" &&
1237
- (node.method === "toReversed" ||
1238
- node.method === "toSpliced" ||
1239
- node.method === "with" ||
1240
- node.method === "withUndefined")) {
1241
- found = true;
1242
- return;
1243
- }
1244
- if (node.kind === "bytesIntrinsic" &&
1245
- (node.method === "toReversed" ||
1246
- node.method === "with" ||
1247
- node.method === "join" ||
1248
- node.method === "toArray")) {
1249
- found = true;
1250
- return;
1251
- }
1252
- for (const key of Object.keys(v))
1253
- visit(v[key]);
1254
- };
1255
- visit(mod);
1256
- return found;
1542
+ return scanRuntimeFeatures(mod, "copying").copying;
1257
1543
  }
1258
1544
  /** True when a non-UTF-8 TextDecoder call survives lowering. This gates the
1259
1545
  * generated legacy mapping tables inside scr_bytes.c; the default UTF-8
1260
1546
  * decoder and unrelated Buffer users keep their prior runtime object. */
1261
1547
  export function moduleUsesLegacyTextDecoder(mod) {
1262
- let found = false;
1263
- const visit = (value) => {
1264
- if (found || value === null || typeof value !== "object")
1265
- return;
1266
- if (Array.isArray(value)) {
1267
- for (const item of value)
1268
- visit(item);
1269
- return;
1270
- }
1271
- const node = value;
1272
- if (node.kind === "libCall" && node.fn === "text.decodeLegacy") {
1273
- found = true;
1274
- return;
1275
- }
1276
- for (const key of Object.keys(value))
1277
- visit(value[key]);
1278
- };
1279
- visit(mod);
1280
- return found;
1548
+ return scanRuntimeFeatures(mod, "legacyTextDecoder").legacyTextDecoder;
1281
1549
  }
1282
1550
  /** True when a FileHandle type survives in the module. This is the link
1283
1551
  * switch for scr_file_handle.c; fs/promises.open carries the type inside its
1284
1552
  * promise result even when no handle method is called. */
1285
1553
  export function moduleUsesFileHandle(mod) {
1286
- let found = false;
1287
- const visit = (v) => {
1288
- if (found || v === null || typeof v !== "object")
1289
- return;
1290
- if (Array.isArray(v)) {
1291
- for (const item of v)
1292
- visit(item);
1293
- return;
1294
- }
1295
- if (v.kind === "fileHandle") {
1296
- found = true;
1297
- return;
1298
- }
1299
- for (const key of Object.keys(v))
1300
- visit(v[key]);
1301
- };
1302
- visit(mod);
1303
- return found;
1554
+ return scanRuntimeFeatures(mod, "fileHandle").fileHandle;
1304
1555
  }
1305
1556
  /** True when user code lowers static fetch or the embedded npm graph
1306
1557
  * reaches the engine's global fetch — the link switch that pulls scr_fetch.c +
@@ -1310,35 +1561,12 @@ export function moduleUsesFileHandle(mod) {
1310
1561
  * and local `fetch` bindings do not change the link or target capability.
1311
1562
  * Fetch-free graphs keep their exact historical link lines. */
1312
1563
  export function moduleUsesFetch(mod) {
1313
- const embedded = mod.embedded;
1314
- if (embedded && embedded.modules.some((m) => m.usesFetch === true))
1315
- return true;
1316
- // User-code fetch is either the engine global or the static libCall pair.
1317
- let found = false;
1318
- const visit = (v) => {
1319
- if (found || v === null || typeof v !== "object")
1320
- return;
1321
- if (Array.isArray(v)) {
1322
- for (const item of v)
1323
- visit(item);
1324
- return;
1325
- }
1326
- const node = v;
1327
- if ((node.kind === "jsOp" && node.op === "globalGet" && node.name === "fetch") ||
1328
- (node.kind === "libCall" &&
1329
- typeof node.fn === "string" && node.fn.startsWith("fetch."))) {
1330
- found = true;
1331
- return;
1332
- }
1333
- for (const key of Object.keys(v))
1334
- visit(v[key]);
1335
- };
1336
- visit(mod);
1337
- return found;
1564
+ return scanRuntimeFeatures(mod, "fetch").fetch;
1338
1565
  }
1339
1566
  /** The libCall fns served by the OPTIONAL events unit (scr_events.c):
1340
1567
  * process signal/exit listeners and the piped-stdin surface. */
1341
1568
  const PROCESS_EVENT_LIB_FNS = new Set([
1569
+ "process.stdio",
1342
1570
  "process.onSignal",
1343
1571
  "process.offSignal",
1344
1572
  "process.onExit",
@@ -1360,25 +1588,7 @@ const PROCESS_EVENT_LIB_FNS = new Set([
1360
1588
  * gating precedent). Event-free programs pay zero bytes and keep their
1361
1589
  * exact link line. Same generic-walk shape as moduleUsesRegex. */
1362
1590
  export function moduleUsesProcessEvents(mod) {
1363
- let found = false;
1364
- const visit = (v) => {
1365
- if (found || v === null || typeof v !== "object")
1366
- return;
1367
- if (Array.isArray(v)) {
1368
- for (const item of v)
1369
- visit(item);
1370
- return;
1371
- }
1372
- const node = v;
1373
- if (node.kind === "libCall" && typeof node.fn === "string" && PROCESS_EVENT_LIB_FNS.has(node.fn)) {
1374
- found = true;
1375
- return;
1376
- }
1377
- for (const key of Object.keys(v))
1378
- visit(v[key]);
1379
- };
1380
- visit(mod);
1381
- return found;
1591
+ return scanRuntimeFeatures(mod, "processEvents").processEvents;
1382
1592
  }
1383
1593
  /** True when the module uses the node:events EventEmitter surface — the
1384
1594
  * link switch that pulls scr_events_emitter.c into the binary (native-toolchain.ts; the
@@ -1390,27 +1600,7 @@ export function moduleUsesProcessEvents(mod) {
1390
1600
  * no emitter-typed value). Emitter-free programs pay zero bytes and keep
1391
1601
  * their exact link line. */
1392
1602
  export function moduleUsesEmitter(mod) {
1393
- if ((mod.classes ?? []).some((c) => c.name === RUNTIME_EMITTER_CLASS))
1394
- return true;
1395
- let found = false;
1396
- const visit = (v) => {
1397
- if (found || v === null || typeof v !== "object")
1398
- return;
1399
- if (Array.isArray(v)) {
1400
- for (const item of v)
1401
- visit(item);
1402
- return;
1403
- }
1404
- const node = v;
1405
- if (node.kind === "libCall" && typeof node.fn === "string" && node.fn.startsWith("emitter.")) {
1406
- found = true;
1407
- return;
1408
- }
1409
- for (const key of Object.keys(v))
1410
- visit(v[key]);
1411
- };
1412
- visit(mod);
1413
- return found;
1603
+ return scanRuntimeFeatures(mod, "emitter").emitter;
1414
1604
  }
1415
1605
  /** True when the program touches the node:stream surface (scr_stream.c —
1416
1606
  * the moduleUsesEmitter story: the class defs ride the module whenever a
@@ -1420,36 +1610,7 @@ export function moduleUsesEmitter(mod) {
1420
1610
  * moduleUsesEmitter answers true whenever this does. Stream-free
1421
1611
  * programs pay zero bytes and keep their exact link line. */
1422
1612
  export function moduleUsesStream(mod) {
1423
- if ((mod.classes ?? []).some((c) => RUNTIME_STREAM_CLASSES.has(c.name)))
1424
- return true;
1425
- let found = false;
1426
- const visit = (v) => {
1427
- if (found || v === null || typeof v !== "object")
1428
- return;
1429
- if (Array.isArray(v)) {
1430
- for (const item of v)
1431
- visit(item);
1432
- return;
1433
- }
1434
- const node = v;
1435
- if (node.kind === "libCall" &&
1436
- typeof node.fn === "string" &&
1437
- (node.fn.startsWith("readable.") || node.fn.startsWith("writable.") ||
1438
- node.fn.startsWith("duplex.") || node.fn.startsWith("transform.") ||
1439
- node.fn.startsWith("passthrough.") ||
1440
- node.fn === "stream.destroy" || node.fn === "stream.destroyErr" ||
1441
- node.fn === "stream.prop" || node.fn === "stream.errored" ||
1442
- node.fn === "sp.finished" || node.fn === "sp.pipeline" ||
1443
- node.fn.startsWith("sc.") ||
1444
- node.fn.startsWith("stream.set"))) {
1445
- found = true;
1446
- return;
1447
- }
1448
- for (const key of Object.keys(v))
1449
- visit(v[key]);
1450
- };
1451
- visit(mod);
1452
- return found;
1613
+ return scanRuntimeFeatures(mod, "stream").stream;
1453
1614
  }
1454
1615
  /** True when the embedded npm graph has an edge into `builtin` — the
1455
1616
  * island shim needs the corresponding native bridge linked (zlib's is
@@ -1458,7 +1619,7 @@ export function moduleEmbedsBuiltin(mod, builtin) {
1458
1619
  return mod.embedded !== undefined && mod.embedded.edges.some((e) => e.to === builtin);
1459
1620
  }
1460
1621
  /** Embedded module texts at least this long are DEFLATE-compressed into
1461
- * the emitted C (island.ts; each stays plain when deflate does not
1622
+ * the emitted LLVM (island.ts; each stays plain when deflate does not
1462
1623
  * shrink it) and inflated lazily by the island's module loader at first
1463
1624
  * load. Below it the zlib round trip cannot pay for itself. */
1464
1625
  export const NPM_COMPRESS_MIN = 1024;
@@ -1478,52 +1639,14 @@ export function moduleEmbedsCompressedNpm(mod) {
1478
1639
  * generic-walk shape as moduleUsesRegex: `kind`/`fn` discriminants live
1479
1640
  * only on IR objects. */
1480
1641
  export function moduleUsesZlib(mod) {
1481
- if (moduleEmbedsBuiltin(mod, "node:zlib"))
1482
- return true;
1483
- let found = false;
1484
- const visit = (v) => {
1485
- if (found || v === null || typeof v !== "object")
1486
- return;
1487
- if (Array.isArray(v)) {
1488
- for (const item of v)
1489
- visit(item);
1490
- return;
1491
- }
1492
- const node = v;
1493
- if (node.kind === "libCall" && typeof node.fn === "string" && node.fn.startsWith("zlib.")) {
1494
- found = true;
1495
- return;
1496
- }
1497
- for (const key of Object.keys(v))
1498
- visit(v[key]);
1499
- };
1500
- visit(mod);
1501
- return found;
1642
+ return scanRuntimeFeatures(mod, "zlib").zlib;
1502
1643
  }
1503
1644
  /** True when the module contains any dc.* libCall — the link switch that
1504
1645
  * pulls scr_dc.c (the diagnostics_channel registry and pub/sub) into the
1505
1646
  * binary (native-toolchain.ts). Channel-free binaries keep their exact size class.
1506
1647
  * Same walk shape as moduleUsesZlib. */
1507
1648
  export function moduleUsesDc(mod) {
1508
- let found = false;
1509
- const visit = (v) => {
1510
- if (found || v === null || typeof v !== "object")
1511
- return;
1512
- if (Array.isArray(v)) {
1513
- for (const item of v)
1514
- visit(item);
1515
- return;
1516
- }
1517
- const node = v;
1518
- if (node.kind === "libCall" && typeof node.fn === "string" && node.fn.startsWith("dc.")) {
1519
- found = true;
1520
- return;
1521
- }
1522
- for (const key of Object.keys(v))
1523
- visit(v[key]);
1524
- };
1525
- visit(mod);
1526
- return found;
1649
+ return scanRuntimeFeatures(mod, "dc").dc;
1527
1650
  }
1528
1651
  /** True when the module contains any assert libCall — the link switch
1529
1652
  * that pulls scr_assert.c into the binary (native-toolchain.ts). scr_regex.c calls the
@@ -1532,25 +1655,7 @@ export function moduleUsesDc(mod) {
1532
1655
  * the historical command line and size. Same walk shape as
1533
1656
  * moduleUsesZlib. */
1534
1657
  export function moduleUsesAssert(mod) {
1535
- let found = false;
1536
- const visit = (v) => {
1537
- if (found || v === null || typeof v !== "object")
1538
- return;
1539
- if (Array.isArray(v)) {
1540
- for (const item of v)
1541
- visit(item);
1542
- return;
1543
- }
1544
- const node = v;
1545
- if (node.kind === "libCall" && typeof node.fn === "string" && node.fn.startsWith("assert.")) {
1546
- found = true;
1547
- return;
1548
- }
1549
- for (const key of Object.keys(v))
1550
- visit(v[key]);
1551
- };
1552
- visit(mod);
1553
- return found;
1658
+ return scanRuntimeFeatures(mod, "assert").assert;
1554
1659
  }
1555
1660
  /** True when the module contains any dynInvoke node or dyn.defineProps
1556
1661
  * libCall — the link switch that pulls scr_dyn_invoke.c (the prototype-
@@ -1559,25 +1664,7 @@ export function moduleUsesAssert(mod) {
1559
1664
  * precedent — dispatch-free binaries keep their exact size class). Same
1560
1665
  * walk shape as moduleUsesZlib. */
1561
1666
  export function moduleUsesDynInvoke(mod) {
1562
- let found = false;
1563
- const visit = (v) => {
1564
- if (found || v === null || typeof v !== "object")
1565
- return;
1566
- if (Array.isArray(v)) {
1567
- for (const item of v)
1568
- visit(item);
1569
- return;
1570
- }
1571
- const node = v;
1572
- if (node.kind === "dynInvoke" || (node.kind === "libCall" && node.fn === "dyn.defineProps")) {
1573
- found = true;
1574
- return;
1575
- }
1576
- for (const key of Object.keys(v))
1577
- visit(v[key]);
1578
- };
1579
- visit(mod);
1580
- return found;
1667
+ return scanRuntimeFeatures(mod, "dynInvoke").dynInvoke;
1581
1668
  }
1582
1669
  /** True when the module contains any insp libCall — the link switch that
1583
1670
  * pulls scr_inspect.c into the binary (native-toolchain.ts; the assert gating
@@ -1590,96 +1677,16 @@ export function moduleUsesDynInvoke(mod) {
1590
1677
  * dynInvoke and dc gates (their TUs call into this one) — native-toolchain.ts. Same
1591
1678
  * walk shape as moduleUsesZlib. */
1592
1679
  export function moduleUsesDynAsync(mod) {
1593
- const fns = new Set([
1594
- "async.awaitDyn", "timers.immediatePromise",
1595
- "process.onUnhandledRejection", "process.offUnhandledRejection",
1596
- "process.onRejectionHandled", "process.offRejectionHandled",
1597
- "process.onWarning", "process.offWarning", "process.emitWarning",
1598
- "als.new", "als.get", "als.run", "als.exitRun", "als.enterWith", "als.disable",
1599
- "dc.chanBindStore", "dc.chanUnbindStore", "dc.chanRunStores",
1600
- ]);
1601
- let found = false;
1602
- const visit = (v) => {
1603
- if (found || v === null || typeof v !== "object")
1604
- return;
1605
- if (Array.isArray(v)) {
1606
- for (const item of v)
1607
- visit(item);
1608
- return;
1609
- }
1610
- const node = v;
1611
- if (node.kind === "libCall" && typeof node.fn === "string" && fns.has(node.fn)) {
1612
- found = true;
1613
- return;
1614
- }
1615
- // A DYN-typed await reads through scr_await_dyn (the checked-dynamic tree-crossing
1616
- // await lives in the gated TU) — promise<dyn> receivers' awaits and
1617
- // the lifted then/catch helpers alike.
1618
- const boxed = node.value?.type;
1619
- if ((node.kind === "awaitExpr" && node.type?.kind === "dyn") ||
1620
- (node.kind === "dynFrom" && (boxed?.kind === "promise" || (boxed?.kind === "func" && boxed.ret?.kind === "promise")))) {
1621
- found = true;
1622
- return;
1623
- }
1624
- for (const key of Object.keys(v))
1625
- visit(v[key]);
1626
- };
1627
- visit(mod);
1628
- return found;
1680
+ return scanRuntimeFeatures(mod, "dynAsync").dynAsync;
1629
1681
  }
1630
1682
  export function moduleUsesInspect(mod) {
1631
- let found = false;
1632
- const visit = (v) => {
1633
- if (found || v === null || typeof v !== "object")
1634
- return;
1635
- if (Array.isArray(v)) {
1636
- for (const item of v)
1637
- visit(item);
1638
- return;
1639
- }
1640
- const node = v;
1641
- if (node.kind === "libCall" && typeof node.fn === "string" && node.fn.startsWith("insp.")) {
1642
- found = true;
1643
- return;
1644
- }
1645
- for (const key of Object.keys(v))
1646
- visit(v[key]);
1647
- };
1648
- visit(mod);
1649
- return found;
1683
+ return scanRuntimeFeatures(mod, "inspect").inspect;
1650
1684
  }
1651
1685
  /** True when the module reaches child_process or carries one of its runtime
1652
1686
  * handle/result types. Besides the existing link consequence, this gates the
1653
1687
  * checked-dynamic ChildProcess handle table installed from scr_child.c. */
1654
1688
  export function moduleUsesChildProcess(mod) {
1655
- let found = false;
1656
- const visit = (v) => {
1657
- if (found || v === null || typeof v !== "object")
1658
- return;
1659
- if (Array.isArray(v)) {
1660
- for (const item of v)
1661
- visit(item);
1662
- return;
1663
- }
1664
- const node = v;
1665
- if (node.kind === "libCall" &&
1666
- typeof node.fn === "string" &&
1667
- (node.fn.startsWith("cp.") || node.fn.startsWith("child.") || node.fn.startsWith("writer.") || node.fn.startsWith("spawnRes.") ||
1668
- node.fn === "process.forkTarget" || node.fn === "process.connected" || node.fn === "process.send" ||
1669
- node.fn === "process.sendCb" || node.fn === "process.disconnect" || node.fn === "process.onMessage" ||
1670
- node.fn === "process.onDisconnect")) {
1671
- found = true;
1672
- return;
1673
- }
1674
- if (node.kind === "child" || node.kind === "childStream" || node.kind === "childWriter" || node.kind === "spawnRes") {
1675
- found = true;
1676
- return;
1677
- }
1678
- for (const key of Object.keys(v))
1679
- visit(v[key]);
1680
- };
1681
- visit(mod);
1682
- return found;
1689
+ return scanRuntimeFeatures(mod, "childProcess").childProcess;
1683
1690
  }
1684
1691
  /** True when the module contains any net libCall — the link switch that
1685
1692
  * pulls scr_net.c into the binary and has the emitted main call
@@ -1687,42 +1694,7 @@ export function moduleUsesChildProcess(mod) {
1687
1694
  * Net-free programs pay zero bytes and keep their exact link line. Same
1688
1695
  * generic-walk shape as moduleUsesZlib. */
1689
1696
  export function moduleUsesNet(mod) {
1690
- let found = false;
1691
- const visit = (v) => {
1692
- if (found || v === null || typeof v !== "object")
1693
- return;
1694
- if (Array.isArray(v)) {
1695
- for (const item of v)
1696
- visit(item);
1697
- return;
1698
- }
1699
- const node = v;
1700
- if (node.kind === "libCall" && typeof node.fn === "string" &&
1701
- (node.fn.startsWith("net.") || node.fn.startsWith("http.") ||
1702
- node.fn.startsWith("tls.") || node.fn.startsWith("https.") ||
1703
- node.fn.startsWith("http2."))) {
1704
- // http/tls/https/http2 all ride ON net: their libCalls need scr_net.c
1705
- // linked and installed too, so the net switch answers for every
1706
- // server-family prefix.
1707
- found = true;
1708
- return;
1709
- }
1710
- // A net-family HANDLE TYPE anywhere in the IR (a global or local whose
1711
- // initializing statement compiled to a runtime fence still carries the
1712
- // type): its emitted release call needs the unit linked even when no
1713
- // libCall survived the fencing.
1714
- if (node.kind === "netServer" || node.kind === "netSocket" ||
1715
- node.kind === "http2Session" || node.kind === "http2Stream" ||
1716
- node.kind === "httpReq" || node.kind === "httpRes" ||
1717
- node.kind === "httpClientReq" || node.kind === "secureCtx") {
1718
- found = true;
1719
- return;
1720
- }
1721
- for (const key of Object.keys(v))
1722
- visit(v[key]);
1723
- };
1724
- visit(mod);
1725
- return found;
1697
+ return scanRuntimeFeatures(mod, "net").net;
1726
1698
  }
1727
1699
  /** True when the module contains any sym.* libCall or a symbol-kind type
1728
1700
  * anywhere in the IR — the link switch that pulls scr_symbol.c into the
@@ -1732,54 +1704,13 @@ export function moduleUsesNet(mod) {
1732
1704
  * fence still emits release calls that need the unit linked. Symbol-free
1733
1705
  * programs pay zero bytes and keep their exact link line. */
1734
1706
  export function moduleUsesSymbol(mod) {
1735
- let found = false;
1736
- const visit = (v) => {
1737
- if (found || v === null || typeof v !== "object")
1738
- return;
1739
- if (Array.isArray(v)) {
1740
- for (const item of v)
1741
- visit(item);
1742
- return;
1743
- }
1744
- const node = v;
1745
- if (node.kind === "libCall" && typeof node.fn === "string" && node.fn.startsWith("sym.")) {
1746
- found = true;
1747
- return;
1748
- }
1749
- if (node.kind === "symbol") {
1750
- found = true;
1751
- return;
1752
- }
1753
- for (const key of Object.keys(v))
1754
- visit(v[key]);
1755
- };
1756
- visit(mod);
1757
- return found;
1707
+ return scanRuntimeFeatures(mod, "symbol").symbol;
1758
1708
  }
1759
1709
  /** True when bigint runtime operations or bigint-typed storage appears in
1760
1710
  * the IR. The type check keeps retain/release references link-safe even
1761
1711
  * when a producing statement was replaced by a runtime fence. */
1762
1712
  export function moduleUsesBigInt(mod) {
1763
- let found = false;
1764
- const visit = (v) => {
1765
- if (found || v === null || typeof v !== "object")
1766
- return;
1767
- if (Array.isArray(v)) {
1768
- for (const item of v)
1769
- visit(item);
1770
- return;
1771
- }
1772
- const node = v;
1773
- if (node.kind === "bigint" ||
1774
- (node.kind === "libCall" && typeof node.fn === "string" && node.fn.startsWith("bigint."))) {
1775
- found = true;
1776
- return;
1777
- }
1778
- for (const key of Object.keys(v))
1779
- visit(v[key]);
1780
- };
1781
- visit(mod);
1782
- return found;
1713
+ return scanRuntimeFeatures(mod, "bigint").bigint;
1783
1714
  }
1784
1715
  /** True when the module uses the URLSearchParams surface — sp.* libCalls,
1785
1716
  * the url.searchParams getter, or a searchParams-kind type anywhere on
@@ -1790,30 +1721,7 @@ export function moduleUsesBigInt(mod) {
1790
1721
  * programs keep their exact link line; scr_url.c itself stays
1791
1722
  * always-linked and never references the unit. */
1792
1723
  export function moduleUsesSearchParams(mod) {
1793
- let found = false;
1794
- const visit = (v) => {
1795
- if (found || v === null || typeof v !== "object")
1796
- return;
1797
- if (Array.isArray(v)) {
1798
- for (const item of v)
1799
- visit(item);
1800
- return;
1801
- }
1802
- const node = v;
1803
- if (node.kind === "libCall" && typeof node.fn === "string" &&
1804
- (node.fn.startsWith("sp.") || node.fn === "url.searchParams")) {
1805
- found = true;
1806
- return;
1807
- }
1808
- if (node.kind === "searchParams") {
1809
- found = true;
1810
- return;
1811
- }
1812
- for (const key of Object.keys(v))
1813
- visit(v[key]);
1814
- };
1815
- visit(mod);
1816
- return found;
1724
+ return scanRuntimeFeatures(mod, "searchParams").searchParams;
1817
1725
  }
1818
1726
  /** True when the module uses the node:querystring surface — the qs.*
1819
1727
  * libCalls that live in scr_qs.c (parse/stringify/unescape; qs.escape
@@ -1823,50 +1731,13 @@ export function moduleUsesSearchParams(mod) {
1823
1731
  * loop hooks, cross-compiles everywhere). qs-free programs keep their
1824
1732
  * exact link line. Same generic-walk shape as moduleUsesZlib. */
1825
1733
  export function moduleUsesQs(mod) {
1826
- let found = false;
1827
- const visit = (v) => {
1828
- if (found || v === null || typeof v !== "object")
1829
- return;
1830
- if (Array.isArray(v)) {
1831
- for (const item of v)
1832
- visit(item);
1833
- return;
1834
- }
1835
- const node = v;
1836
- if (node.kind === "libCall" && typeof node.fn === "string" &&
1837
- (node.fn === "qs.parse" || node.fn === "qs.stringify" || node.fn === "qs.unescape")) {
1838
- found = true;
1839
- return;
1840
- }
1841
- for (const key of Object.keys(v))
1842
- visit(v[key]);
1843
- };
1844
- visit(mod);
1845
- return found;
1734
+ return scanRuntimeFeatures(mod, "qs").qs;
1846
1735
  }
1847
1736
  /** True when the module uses native util.parseArgs — the link switch for
1848
1737
  * scr_util.c. The implementation is a pure checked-dynamic data transform,
1849
1738
  * cross-platform and independent of the island's node:util shim. */
1850
1739
  export function moduleUsesParseArgs(mod) {
1851
- let found = false;
1852
- const visit = (v) => {
1853
- if (found || v === null || typeof v !== "object")
1854
- return;
1855
- if (Array.isArray(v)) {
1856
- for (const item of v)
1857
- visit(item);
1858
- return;
1859
- }
1860
- const node = v;
1861
- if (node.kind === "libCall" && node.fn === "util.parseArgs") {
1862
- found = true;
1863
- return;
1864
- }
1865
- for (const key of Object.keys(v))
1866
- visit(v[key]);
1867
- };
1868
- visit(mod);
1869
- return found;
1740
+ return scanRuntimeFeatures(mod, "parseArgs").parseArgs;
1870
1741
  }
1871
1742
  /** True when the module contains any fs.watch/watcher.* libCall — the
1872
1743
  * link switch that pulls scr_watch.c into the binary and has the emitted
@@ -1874,32 +1745,7 @@ export function moduleUsesParseArgs(mod) {
1874
1745
  * precedent). Watch-free programs pay zero bytes and keep their exact
1875
1746
  * link line. Same generic-walk shape as moduleUsesZlib. */
1876
1747
  export function moduleUsesFsWatch(mod) {
1877
- let found = false;
1878
- const visit = (v) => {
1879
- if (found || v === null || typeof v !== "object")
1880
- return;
1881
- if (Array.isArray(v)) {
1882
- for (const item of v)
1883
- visit(item);
1884
- return;
1885
- }
1886
- const node = v;
1887
- if (node.kind === "libCall" && typeof node.fn === "string" &&
1888
- (node.fn.startsWith("fs.watch") || node.fn.startsWith("watcher."))) {
1889
- found = true;
1890
- return;
1891
- }
1892
- // A watcher HANDLE TYPE left behind by a fenced statement still emits
1893
- // scr_watcher_release — the unit must link.
1894
- if (node.kind === "fsWatcher") {
1895
- found = true;
1896
- return;
1897
- }
1898
- for (const key of Object.keys(v))
1899
- visit(v[key]);
1900
- };
1901
- visit(mod);
1902
- return found;
1748
+ return scanRuntimeFeatures(mod, "fsWatch").fsWatch;
1903
1749
  }
1904
1750
  /** True when the module contains any test.* libCall or a testCtx handle
1905
1751
  * type — the link switch that pulls scr_test.c into the binary and has
@@ -1907,31 +1753,7 @@ export function moduleUsesFsWatch(mod) {
1907
1753
  * (native-toolchain.ts + emitter; the moduleUsesDgram shape). Test-free programs pay
1908
1754
  * zero bytes and keep their exact link line. */
1909
1755
  export function moduleUsesNodeTest(mod) {
1910
- let found = false;
1911
- const visit = (v) => {
1912
- if (found || v === null || typeof v !== "object")
1913
- return;
1914
- if (Array.isArray(v)) {
1915
- for (const item of v)
1916
- visit(item);
1917
- return;
1918
- }
1919
- const node = v;
1920
- if (node.kind === "libCall" && typeof node.fn === "string" && node.fn.startsWith("test.")) {
1921
- found = true;
1922
- return;
1923
- }
1924
- // A TestContext HANDLE TYPE left behind by a fenced statement still
1925
- // emits a release call — the unit must link (the dgram type story).
1926
- if (node.kind === "testCtx") {
1927
- found = true;
1928
- return;
1929
- }
1930
- for (const key of Object.keys(v))
1931
- visit(v[key]);
1932
- };
1933
- visit(mod);
1934
- return found;
1756
+ return scanRuntimeFeatures(mod, "nodeTest").nodeTest;
1935
1757
  }
1936
1758
  /** True when the module contains any dgram.* or dns.* libCall — the
1937
1759
  * link switch that pulls scr_dgram.c into the binary and has the emitted
@@ -1940,69 +1762,13 @@ export function moduleUsesNodeTest(mod) {
1940
1762
  * answers). Dgram-free programs pay zero bytes and keep their exact link
1941
1763
  * line. Same generic-walk shape as moduleUsesZlib. */
1942
1764
  export function moduleUsesDgram(mod) {
1943
- let found = false;
1944
- const visit = (v) => {
1945
- if (found || v === null || typeof v !== "object")
1946
- return;
1947
- if (Array.isArray(v)) {
1948
- for (const item of v)
1949
- visit(item);
1950
- return;
1951
- }
1952
- const node = v;
1953
- if (node.kind === "libCall" && typeof node.fn === "string" &&
1954
- (node.fn.startsWith("dgram.") || node.fn.startsWith("dns."))) {
1955
- found = true;
1956
- return;
1957
- }
1958
- // A dgram HANDLE TYPE left behind by a fenced statement still emits a
1959
- // release call — the unit must link (the moduleUsesNet type story).
1960
- if (node.kind === "dgramSocket") {
1961
- found = true;
1962
- return;
1963
- }
1964
- for (const key of Object.keys(v))
1965
- visit(v[key]);
1966
- };
1967
- visit(mod);
1968
- return found;
1765
+ return scanRuntimeFeatures(mod, "dgram").dgram;
1969
1766
  }
1970
1767
  /** True when the module contains any http.* libCall — the link switch
1971
1768
  * that pulls scr_http.c into the binary (native-toolchain.ts; moduleUsesNet already
1972
1769
  * answers true for these, so scr_net.c comes along). */
1973
1770
  export function moduleUsesHttpServer(mod) {
1974
- let found = false;
1975
- const visit = (v) => {
1976
- if (found || v === null || typeof v !== "object")
1977
- return;
1978
- if (Array.isArray(v)) {
1979
- for (const item of v)
1980
- visit(item);
1981
- return;
1982
- }
1983
- const node = v;
1984
- if (node.kind === "libCall" && typeof node.fn === "string" &&
1985
- (node.fn.startsWith("http.") || node.fn.startsWith("tls.") || node.fn.startsWith("https.") ||
1986
- node.fn.startsWith("http2."))) {
1987
- // scr_tls.c calls into scr_http.c unconditionally (the https server
1988
- // and client are the http ones over a transport), so any tls/https
1989
- // use pulls the http unit too.
1990
- found = true;
1991
- return;
1992
- }
1993
- // An http-family HANDLE TYPE left behind by a fenced statement still
1994
- // emits its release call — the unit must link (the moduleUsesNet type
1995
- // story; secureCtx rides here because scr_tls.c calls into scr_http.c).
1996
- if (node.kind === "httpReq" || node.kind === "httpRes" ||
1997
- node.kind === "httpClientReq" || node.kind === "secureCtx") {
1998
- found = true;
1999
- return;
2000
- }
2001
- for (const key of Object.keys(v))
2002
- visit(v[key]);
2003
- };
2004
- visit(mod);
2005
- return found;
1771
+ return scanRuntimeFeatures(mod, "http").http;
2006
1772
  }
2007
1773
  /** The legacy http2.* libCalls implemented by scr_http.c/scr_tls.c (the
2008
1774
  * allowHTTP1 compatibility slice) — they must NOT pull scr_http2.c, so
@@ -2014,30 +1780,7 @@ const HTTP2_LEGACY_FNS = new Set([
2014
1780
  * http2.* libCall, or an h2 handle type left behind by a fenced statement
2015
1781
  * (its emitted release call needs the unit — the moduleUsesNet story). */
2016
1782
  export function moduleUsesHttp2(mod) {
2017
- let found = false;
2018
- const visit = (v) => {
2019
- if (found || v === null || typeof v !== "object")
2020
- return;
2021
- if (Array.isArray(v)) {
2022
- for (const item of v)
2023
- visit(item);
2024
- return;
2025
- }
2026
- const node = v;
2027
- if (node.kind === "libCall" && typeof node.fn === "string" &&
2028
- node.fn.startsWith("http2.") && !HTTP2_LEGACY_FNS.has(node.fn)) {
2029
- found = true;
2030
- return;
2031
- }
2032
- if (node.kind === "http2Session" || node.kind === "http2Stream") {
2033
- found = true;
2034
- return;
2035
- }
2036
- for (const key of Object.keys(v))
2037
- visit(v[key]);
2038
- };
2039
- visit(mod);
2040
- return found;
1783
+ return scanRuntimeFeatures(mod, "http2").http2;
2041
1784
  }
2042
1785
  /** True when the module contains any tls.* or https.* libCall — the link
2043
1786
  * switch that pulls scr_tls.c and the vendored mbedTLS archive into the
@@ -2045,33 +1788,7 @@ export function moduleUsesHttp2(mod) {
2045
1788
  * true for these, so scr_net.c and scr_http.c come along). TLS-free
2046
1789
  * programs keep their exact link line and never build mbedTLS. */
2047
1790
  export function moduleUsesTls(mod) {
2048
- let found = false;
2049
- const visit = (v) => {
2050
- if (found || v === null || typeof v !== "object")
2051
- return;
2052
- if (Array.isArray(v)) {
2053
- for (const item of v)
2054
- visit(item);
2055
- return;
2056
- }
2057
- const node = v;
2058
- if (node.kind === "libCall" && typeof node.fn === "string" &&
2059
- (node.fn.startsWith("tls.") || node.fn.startsWith("https.") ||
2060
- node.fn.startsWith("http2."))) {
2061
- found = true;
2062
- return;
2063
- }
2064
- // A secureCtx HANDLE TYPE left behind by a fenced statement still
2065
- // emits scr_secure_ctx_release — the unit must link.
2066
- if (node.kind === "secureCtx") {
2067
- found = true;
2068
- return;
2069
- }
2070
- for (const key of Object.keys(v))
2071
- visit(v[key]);
2072
- };
2073
- visit(mod);
2074
- return found;
1791
+ return scanRuntimeFeatures(mod, "tls").tls;
2075
1792
  }
2076
1793
  /** True when the module contains any tlsca.* libCall — the link switch
2077
1794
  * for scr_tls_ca.c, the CA-store introspection unit (getCACertificates /
@@ -2081,25 +1798,7 @@ export function moduleUsesTls(mod) {
2081
1798
  * also compiles the unit whenever TLS itself links — scr_tls.c consults
2082
1799
  * the unit's default-set override for its trust anchors. */
2083
1800
  export function moduleUsesTlsCa(mod) {
2084
- let found = false;
2085
- const visit = (v) => {
2086
- if (found || v === null || typeof v !== "object")
2087
- return;
2088
- if (Array.isArray(v)) {
2089
- for (const item of v)
2090
- visit(item);
2091
- return;
2092
- }
2093
- const node = v;
2094
- if (node.kind === "libCall" && typeof node.fn === "string" && node.fn.startsWith("tlsca.")) {
2095
- found = true;
2096
- return;
2097
- }
2098
- for (const key of Object.keys(v))
2099
- visit(v[key]);
2100
- };
2101
- visit(mod);
2102
- return found;
1801
+ return scanRuntimeFeatures(mod, "tlsCa").tlsCa;
2103
1802
  }
2104
1803
  /* ── library mode's async_free gate ──────────────────────────────────────
2105
1804
  * v1 library mode REQUIRES an async_free module graph (ratified): no async
@@ -2118,6 +1817,7 @@ const LIB_MODE_REFUSED_PREFIXES = [
2118
1817
  // exclude — refuse the surface like the rest of the event-loop family.
2119
1818
  ["fs.existsChk", "the async fs callback surface (fs.exists)"],
2120
1819
  ["fs.renameCb", "the async fs callback surface (fs.rename)"],
1820
+ ["fs.callback", "the async filesystem callback surface"],
2121
1821
  ["zlib.deflateCb", "the async node:zlib callback surface"],
2122
1822
  ["zlib.inflateCb", "the async node:zlib callback surface"],
2123
1823
  ["zlib.deflateRawCb", "the async node:zlib callback surface"],
@@ -2156,10 +1856,6 @@ const LIB_MODE_REFUSED_PREFIXES = [
2156
1856
  ["als.", "AsyncLocalStorage"],
2157
1857
  ["urj.", "unhandled-rejection tracking"],
2158
1858
  ["dc.", "the diagnostics_channel surface"],
2159
- // NOT the whole "dyn." family: the checked-dynamic tree (ScrDyn) is
2160
- // static-tier surface hosted by always-linked units; only defineProps
2161
- // drags the prototype-dispatch unit (scr_dyn_invoke.c → scr_async_dyn.c).
2162
- ["dyn.defineProps", "checked-dynamic prototype dispatch"],
2163
1859
  ];
2164
1860
  /** Value/type kinds whose mere presence means an excluded unit's code (or
2165
1861
  * a fiber) would have to link. */
@@ -2184,12 +1880,11 @@ const LIB_MODE_REFUSED_KINDS = new Map([
2184
1880
  ["httpRes", "the node:http surface"],
2185
1881
  ["httpClientReq", "the node:http surface"],
2186
1882
  ["secureCtx", "the node:tls surface"],
2187
- ["dynInvoke", "checked-dynamic prototype dispatch"],
2188
1883
  ]);
2189
1884
  /** First async/event-loop/ambient-process surface the module graph
2190
1885
  * reaches, or null when the graph is async_free (the v1 library requirement).
2191
- * The generic-walk shape of moduleUsesRegex, tracking the nearest
2192
- * enclosing `loc` so the refusal anchors at the reaching construct; the
1886
+ * Typed slots use their declaration location and executable nodes use their
1887
+ * own location, so the refusal anchors at the reaching construct; the
2193
1888
  * coarse moduleUses* predicates are the safety net behind the fine-grained
2194
1889
  * table (a surface reached only through a spelling the table misses still
2195
1890
  * refuses, anchored at the entry). */
@@ -2203,54 +1898,49 @@ export function moduleLibAsyncSurface(mod) {
2203
1898
  }
2204
1899
  const entryLoc = { file: mod.sourceFile, start: 0, end: 0 };
2205
1900
  let found = null;
2206
- const visit = (v, loc) => {
2207
- if (found !== null || v === null || typeof v !== "object")
2208
- return;
2209
- if (Array.isArray(v)) {
2210
- for (const item of v)
2211
- visit(item, loc);
2212
- return;
2213
- }
2214
- const node = v;
2215
- const here = node.loc ?? loc;
2216
- if (typeof node.kind === "string") {
2217
- const bad = LIB_MODE_REFUSED_KINDS.get(node.kind);
2218
- if (bad !== undefined) {
2219
- found = { surface: bad, loc: here };
2220
- return;
2221
- }
2222
- if (node.kind === "libCall" && typeof node.fn === "string") {
1901
+ const checkKind = (kind, loc) => {
1902
+ const surface = LIB_MODE_REFUSED_KINDS.get(kind);
1903
+ if (surface === undefined)
1904
+ return true;
1905
+ found = { surface, loc };
1906
+ return false;
1907
+ };
1908
+ everyModuleNode(mod, {
1909
+ type: (node, loc) => checkKind(node.kind, loc),
1910
+ stmt: () => true,
1911
+ expr: (node) => {
1912
+ if (!checkKind(node.kind, node.loc))
1913
+ return false;
1914
+ if (node.kind === "libCall") {
2223
1915
  for (const [prefix, surface] of LIB_MODE_REFUSED_PREFIXES) {
2224
1916
  if (node.fn.startsWith(prefix)) {
2225
- found = { surface, loc: here };
2226
- return;
1917
+ found = { surface, loc: node.loc };
1918
+ return false;
2227
1919
  }
2228
1920
  }
2229
1921
  }
2230
- }
2231
- for (const key of Object.keys(v))
2232
- visit(v[key], here);
2233
- };
2234
- visit(mod, entryLoc);
1922
+ return true;
1923
+ },
1924
+ });
2235
1925
  if (found !== null)
2236
1926
  return found;
2237
1927
  // Safety net: the coarse unit predicates, entry-anchored. Every one of
2238
1928
  // these units is excluded from library links, so a true answer that the
2239
1929
  // fine-grained table missed must still refuse.
1930
+ const features = moduleRuntimeFeatures(mod);
2240
1931
  const coarse = [
2241
- [moduleUsesProcessEvents(mod), "process signal/exit listeners or the stdin event surface"],
2242
- [moduleUsesNet(mod), "the node:net surface"],
2243
- [moduleUsesHttpServer(mod), "the node:http surface"],
2244
- [moduleUsesHttp2(mod), "the node:http2 surface"],
2245
- [moduleUsesDgram(mod), "the node:dgram surface"],
2246
- [moduleUsesFsWatch(mod), "fs.watch"],
2247
- [moduleUsesStream(mod), "the node:stream surface"],
2248
- [moduleUsesTls(mod), "the node:tls surface"],
2249
- [moduleUsesFetch(mod), "fetch"],
2250
- [moduleUsesNodeTest(mod), "the node:test surface"],
2251
- [moduleUsesDynAsync(mod), "the checked-dynamic async surface"],
2252
- [moduleUsesDc(mod), "the diagnostics_channel surface"],
2253
- [moduleUsesDynInvoke(mod), "checked-dynamic prototype dispatch"],
1932
+ [features.processEvents, "process signal/exit listeners or the stdin event surface"],
1933
+ [features.net, "the node:net surface"],
1934
+ [features.http, "the node:http surface"],
1935
+ [features.http2, "the node:http2 surface"],
1936
+ [features.dgram, "the node:dgram surface"],
1937
+ [features.fsWatch, "fs.watch"],
1938
+ [features.stream, "the node:stream surface"],
1939
+ [features.tls, "the node:tls surface"],
1940
+ [features.fetch, "fetch"],
1941
+ [features.nodeTest, "the node:test surface"],
1942
+ [features.dynAsync, "the checked-dynamic async surface"],
1943
+ [features.dc, "the diagnostics_channel surface"],
2254
1944
  ];
2255
1945
  for (const [on, surface] of coarse) {
2256
1946
  if (on)
@@ -2321,27 +2011,22 @@ export const LIB_NONDETERMINISTIC_PREFIXES = [
2321
2011
  * attests `deterministic: true`). */
2322
2012
  export function moduleLibNondeterministicSurface(mod) {
2323
2013
  let found = null;
2324
- const visit = (v) => {
2325
- if (found !== null || v === null || typeof v !== "object")
2326
- return;
2327
- if (Array.isArray(v)) {
2328
- for (const item of v)
2329
- visit(item);
2330
- return;
2331
- }
2332
- const node = v;
2333
- if (node.kind === "libCall" && typeof node.fn === "string") {
2014
+ const expr = (node) => {
2015
+ if (node.kind === "libCall") {
2334
2016
  for (const [prefix, surface] of LIB_NONDETERMINISTIC_PREFIXES) {
2335
2017
  if (node.fn.startsWith(prefix)) {
2336
2018
  found = surface;
2337
- return;
2019
+ return false;
2338
2020
  }
2339
2021
  }
2340
2022
  }
2341
- for (const key of Object.keys(v))
2342
- visit(v[key]);
2023
+ return everyExprChild(node, expr, stmt);
2343
2024
  };
2344
- visit(mod);
2025
+ const stmt = (node) => everyStmtChild(node, expr, stmt);
2026
+ for (const fn of mod.functions) {
2027
+ if (!fn.body.every(stmt))
2028
+ break;
2029
+ }
2345
2030
  return found;
2346
2031
  }
2347
2032
  /** The may-throw seed: libCall members that can raise. Every fs.* member
@@ -2352,6 +2037,43 @@ export function moduleLibNondeterministicSurface(mod) {
2352
2037
  * seed on `dynCheck` and `awaitExpr` nodes, which throw on validation
2353
2038
  * failure / promise rejection). */
2354
2039
  export const MAY_THROW_LIB_FNS = new Set([
2040
+ "cp.spawnDynamic",
2041
+ "child.onDyn",
2042
+ "text.decoderEncoding",
2043
+ "dyn.construct",
2044
+ "dyn.reflectApply",
2045
+ "text.decodeOptions",
2046
+ "text.decodeStream",
2047
+ "text.decodeLegacyOptions",
2048
+ "dyn.nativeSetNew",
2049
+ "ffi.argument",
2050
+ "ffi.memoryModule",
2051
+ "process.stdoutWrite",
2052
+ "process.stderrWrite",
2053
+ "process.stdoutWriteBytes",
2054
+ "process.stderrWriteBytes",
2055
+ "procStream.write",
2056
+ "weakMap.new",
2057
+ "weakSet.new",
2058
+ "dyn.fromEntries",
2059
+ "bytes.constructor",
2060
+ "bytes.instanceOf",
2061
+ "buffer.byteLenDyn",
2062
+ "bytes.construct",
2063
+ "arrayBuffer.new",
2064
+ "arrayBuffer.byteLengthGetter",
2065
+ "arrayBuffer.viewU8C",
2066
+ "arrayBuffer.viewI8",
2067
+ "arrayBuffer.viewU16",
2068
+ "arrayBuffer.viewI16",
2069
+ "arrayBuffer.viewU8",
2070
+ "arrayBuffer.viewU32",
2071
+ "arrayBuffer.viewI32",
2072
+ "arrayBuffer.viewF32",
2073
+ "arrayBuffer.viewF64",
2074
+ "arrayBuffer.viewDV",
2075
+ "bytes.bufferSource",
2076
+ "text.decodeBufferSource",
2355
2077
  "bigint.parse",
2356
2078
  "bigint.fromF64",
2357
2079
  "bigint.div",
@@ -2366,12 +2088,15 @@ export const MAY_THROW_LIB_FNS = new Set([
2366
2088
  "bigint.bufferWrite",
2367
2089
  "bigint.dataViewGet",
2368
2090
  "bigint.dataViewSet",
2091
+ "fetch.requestNew",
2092
+ "fetch.headersNew",
2369
2093
  "fetch.responseNew",
2370
2094
  "fetch.abortTimeout",
2371
2095
  "fetch.abortAny",
2372
2096
  "fetch.streamNew",
2373
2097
  "fetch.streamFrom",
2374
2098
  "num.toFixed",
2099
+ "num.toStringRadix",
2375
2100
  "insp.jsonDyn",
2376
2101
  // diagnostics_channel: publish runs subscribers synchronously (a throw
2377
2102
  // propagates — the documented divergence from triggerUncaughtException);
@@ -2387,6 +2112,10 @@ export const MAY_THROW_LIB_FNS = new Set([
2387
2112
  "dc.tcTraceSync",
2388
2113
  "dc.tcTraceCallback",
2389
2114
  "dc.tcTracePromise",
2115
+ "process.onUncaughtException",
2116
+ "process.offUncaughtException",
2117
+ "process.onSignal",
2118
+ "process.offSignal",
2390
2119
  "process.onUnhandledRejection",
2391
2120
  "process.onRejectionHandled",
2392
2121
  "async.awaitDyn",
@@ -2527,6 +2256,8 @@ export const MAY_THROW_LIB_FNS = new Set([
2527
2256
  "readable.unshift",
2528
2257
  "readable.unshiftStr",
2529
2258
  "readable.read",
2259
+ "readable.readDyn",
2260
+ "stream.onDyn",
2530
2261
  "readable.resume",
2531
2262
  "readable.pipe",
2532
2263
  "readable.unpipe",
@@ -2567,9 +2298,32 @@ export const MAY_THROW_LIB_FNS = new Set([
2567
2298
  "error.nodeThrow",
2568
2299
  // USVString coercion runs user toString/valueOf — throws propagate.
2569
2300
  "dyn.toStringCoerce",
2301
+ "dyn.stringConstructor",
2302
+ "dyn.propertyKey",
2303
+ "dyn.toNumeric",
2304
+ "dyn.increment",
2305
+ // Error messages use the same coercion protocol before installing cause.
2306
+ "error.newOptions",
2307
+ "error.ctorOptions",
2308
+ "error.toString",
2309
+ "error.stack",
2310
+ "error.cause",
2311
+ "error.setCause",
2312
+ "error.deleteCause",
2570
2313
  "dyn.objectTag",
2571
2314
  // Numeric coercion runs user valueOf/toString — throws propagate.
2315
+ "dyn.numberConstructor",
2316
+ "dyn.bigintConstructor",
2572
2317
  "dyn.toNumberCoerce",
2318
+ "dyn.add",
2319
+ "dyn.arithmetic",
2320
+ "dyn.compare",
2321
+ "dyn.bitwise",
2322
+ "dyn.proxyNew",
2323
+ "dyn.classBasePrototype",
2324
+ "dyn.classInherit",
2325
+ "dyn.classSuper",
2326
+ "dyn.hasKey",
2573
2327
  "child.kill",
2574
2328
  // The caller's lookup runs synchronously inside the connect call — a
2575
2329
  // throw there propagates like Node's.
@@ -2604,10 +2358,16 @@ export const MAY_THROW_LIB_FNS = new Set([
2604
2358
  "island.import",
2605
2359
  "island.castFail",
2606
2360
  "json.parse",
2361
+ "json.parseReviver",
2362
+ "json.stringifyReplacer",
2363
+ "json.stringifyValue",
2364
+ "date.nativeNew",
2365
+ "date.checkedValue",
2607
2366
  "util.parseArgs",
2608
2367
  // decodeURIComponent throws the spec's URIError on bad hex/invalid
2609
2368
  // UTF-8 octets (encodeURIComponent never throws — see the IrLibFn doc).
2610
2369
  "str.decodeUriComponent",
2370
+ "str.decodeUri",
2611
2371
  // The base64 globals: atob/btoa throw the catchable DOMException
2612
2372
  // InvalidCharacterError on malformed input; the zero-argument form
2613
2373
  // always throws Node's TypeError [ERR_MISSING_ARGS].
@@ -2627,26 +2387,67 @@ export const MAY_THROW_LIB_FNS = new Set([
2627
2387
  "dyn.cloneTransferFail",
2628
2388
  // the dyn Object walks throw on null/undefined receivers
2629
2389
  "dyn.objKeys",
2390
+ "dyn.forInKeys",
2630
2391
  "dyn.hasOwn",
2392
+ "dyn.propertyIsEnumerable",
2631
2393
  "dyn.assign",
2394
+ "dyn.copyDataProperties",
2395
+ "dyn.objectRest",
2632
2396
  // variadic Object.assign: spread flattening throws V8's spread-call
2633
2397
  // TypeErrors; the final copy throws ToObject on a nullish target
2634
2398
  "dyn.packPushSpread",
2635
2399
  "dyn.packPushSpreadIter",
2636
2400
  "dyn.assignAll",
2401
+ "dyn.objCreate",
2402
+ "dyn.objCreateWithProperties",
2403
+ "dyn.getPrototype",
2404
+ "dyn.setPrototype",
2405
+ "dyn.getOwnPropertyNames",
2406
+ "dyn.ownKeys",
2407
+ "dyn.getOwnPropertySymbols",
2408
+ "dyn.getOwnPropertyDescriptors",
2409
+ "dyn.preventExtensions",
2410
+ "dyn.isExtensible",
2411
+ "dyn.seal",
2412
+ "dyn.isSealed",
2637
2413
  "dyn.objValues",
2638
2414
  "dyn.objEntries",
2639
2415
  "error.domClone",
2640
2416
  // new RegExp compiles the pattern eagerly: an invalid pattern or flag
2641
2417
  // throws Node's catchable SyntaxError at construction.
2642
2418
  "regex.new",
2419
+ "regex.resetLastIndex",
2420
+ "regex.newChecked",
2643
2421
  "dyn.keySet",
2422
+ "dyn.keySetComputed",
2423
+ "process.builtinId",
2424
+ "process.builtinModule",
2425
+ "process.builtinUnsupported",
2426
+ "fs.callbackValue",
2427
+ "fs.callbackCall",
2428
+ "dyn.keyDelete",
2429
+ "dyn.keyDeleteComputed",
2430
+ "dyn.hasKeyComputed",
2431
+ "dyn.hasOwnComputed",
2432
+ "dyn.propertyIsEnumerableComputed",
2644
2433
  // the destructuring pack throws V8's TypeError on non-iterable dyn kinds
2645
2434
  "dyn.iterPack",
2435
+ "dyn.arrayFromIterator",
2436
+ "dyn.iterator",
2437
+ "dyn.iteratorResult",
2438
+ "dyn.mapSeedEntries",
2439
+ "dyn.mapSeedEntry",
2440
+ "dyn.freeze",
2441
+ "dyn.isFrozen",
2646
2442
  "dyn.toString",
2443
+ "string.fromCodePoint",
2647
2444
  "dyn.defineProps",
2445
+ "dyn.defineProperty",
2446
+ "dyn.getOwnPropertyDescriptor",
2447
+ "dyn.arrayProtoCall",
2648
2448
  "process.chdir",
2649
2449
  "fs.realpathSync",
2450
+ "fs.realpathNativeSync",
2650
2451
  "fs.readFileSync",
2651
2452
  "fs.writeFileSync",
2652
2453
  "fs.appendFileSync",
@@ -2656,17 +2457,21 @@ export const MAY_THROW_LIB_FNS = new Set([
2656
2457
  "fs.readdirSync",
2657
2458
  "fs.readdirTypesSync",
2658
2459
  "url.new",
2460
+ "url.newBase",
2659
2461
  "url.fileURLToPathUrl",
2462
+ "url.fileURLToPathChecked",
2660
2463
  "url.fileURLToPathStr",
2661
2464
  // The win32-target flavor of pathToFileURL (same runtime entry point —
2662
2465
  // the bridge dispatches by the binary's platform): Node's win32 arm
2663
2466
  // raises ERR_INVALID_ARG_VALUE TypeErrors for malformed UNC inputs, so
2664
2467
  // only THIS flavor seeds may-throw — posix emission stays untouched.
2665
2468
  "url.pathToFileURLWin32",
2469
+ "url.pathToFileURLPlatform",
2666
2470
  // URLSearchParams from a string[][]: Node's ERR_INVALID_TUPLE TypeError
2667
2471
  // on a row that is not a [name, value] pair. The rest of the sp family
2668
2472
  // never throws.
2669
2473
  "sp.fromPairs",
2474
+ "sp.newChecked",
2670
2475
  "fs.statSync",
2671
2476
  "crypto.randomBytesToString",
2672
2477
  "crypto.randomBytes",
@@ -2693,6 +2498,7 @@ export const MAY_THROW_LIB_FNS = new Set([
2693
2498
  "crypto.pbkdf2Cb",
2694
2499
  "buffer.concat",
2695
2500
  "buffer.concatLen",
2501
+ "buffer.fromDyn",
2696
2502
  // The checked-dynamic compare/equals validators: Node's argument
2697
2503
  // ladders throw ERR_INVALID_ARG_TYPE / ERR_OUT_OF_RANGE catchably.
2698
2504
  "buffer.compareChk",
@@ -2720,6 +2526,7 @@ export const MAY_THROW_LIB_FNS = new Set([
2720
2526
  "emitter.setDefaultMaxChk",
2721
2527
  "fs.readFileSyncBytes",
2722
2528
  "fs.writeFileSyncBytes",
2529
+ "fs.appendFileSyncBytes",
2723
2530
  "zlib.inflateSync",
2724
2531
  "zlib.inflateRawSync",
2725
2532
  "zlib.gunzipSync",