@scriptc/compiler 0.1.7 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1032) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +73 -24
  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 +107 -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 +70 -28
  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 +16 -2
  65. package/dist/backend/llvm/dyn.js +494 -165
  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 +695 -410
  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 +1 -1
  76. package/dist/backend/llvm/expr-bytes.js +32 -14
  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 +9 -5
  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 +62 -74
  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 +51 -30
  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 +43 -4
  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 +102 -121
  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 +21 -16
  138. package/dist/backend/llvm/lib-process.js.map +1 -1
  139. package/dist/backend/llvm/lib-shared.js +117 -1
  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 +35 -130
  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 +10 -25
  183. package/dist/backend/native-toolchain.js +31 -211
  184. package/dist/backend/native-toolchain.js.map +1 -1
  185. package/dist/backend/native-toolchain.test.js +5 -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 +70 -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 +95 -30
  216. package/dist/backend/targets.js.map +1 -1
  217. package/dist/backend/targets.test.js +65 -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 +3 -3
  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 +3 -3
  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 +63 -0
  345. package/dist/frontend/lowering/class-callbacks.js.map +1 -0
  346. package/dist/frontend/lowering/class-descriptors.d.ts +9 -0
  347. package/dist/frontend/lowering/class-descriptors.js +73 -0
  348. package/dist/frontend/lowering/class-descriptors.js.map +1 -0
  349. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +41 -0
  350. package/dist/frontend/lowering/class-dynamic-dispatch.js +803 -0
  351. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -0
  352. package/dist/frontend/lowering/class-dynamic-dispatch.test.d.ts +1 -0
  353. package/dist/frontend/lowering/class-dynamic-dispatch.test.js +92 -0
  354. package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -0
  355. package/dist/frontend/lowering/class-instance-constructor.d.ts +7 -0
  356. package/dist/frontend/lowering/class-instance-constructor.js +64 -0
  357. package/dist/frontend/lowering/class-instance-constructor.js.map +1 -0
  358. package/dist/frontend/lowering/class-method-values.d.ts +10 -0
  359. package/dist/frontend/lowering/class-method-values.js +170 -0
  360. package/dist/frontend/lowering/class-method-values.js.map +1 -0
  361. package/dist/frontend/lowering/class-prototypes.d.ts +16 -0
  362. package/dist/frontend/lowering/class-prototypes.js +134 -0
  363. package/dist/frontend/lowering/class-prototypes.js.map +1 -0
  364. package/dist/frontend/lowering/class-static-data.d.ts +6 -0
  365. package/dist/frontend/lowering/class-static-data.js +56 -0
  366. package/dist/frontend/lowering/class-static-data.js.map +1 -0
  367. package/dist/frontend/lowering/containers/buffer-numeric-methods.d.ts +4 -0
  368. package/dist/frontend/lowering/containers/buffer-numeric-methods.js +26 -0
  369. package/dist/frontend/lowering/containers/buffer-numeric-methods.js.map +1 -0
  370. package/dist/frontend/lowering/containers/bytes.d.ts +11 -7
  371. package/dist/frontend/lowering/containers/bytes.js +164 -155
  372. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  373. package/dist/frontend/lowering/containers/string-and-regexp.d.ts +2 -2
  374. package/dist/frontend/lowering/containers/string-and-regexp.js +39 -16
  375. package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
  376. package/dist/frontend/lowering/containers/string-replacement.d.ts +7 -0
  377. package/dist/frontend/lowering/containers/string-replacement.js +217 -0
  378. package/dist/frontend/lowering/containers/string-replacement.js.map +1 -0
  379. package/dist/frontend/lowering/error-methods.d.ts +11 -0
  380. package/dist/frontend/lowering/error-methods.js +78 -0
  381. package/dist/frontend/lowering/error-methods.js.map +1 -0
  382. package/dist/frontend/lowering/expressions/global-symbols.d.ts +6 -0
  383. package/dist/frontend/lowering/expressions/global-symbols.js +11 -0
  384. package/dist/frontend/lowering/expressions/global-symbols.js.map +1 -0
  385. package/dist/frontend/lowering/expressions/native-proxy.d.ts +7 -0
  386. package/dist/frontend/lowering/expressions/native-proxy.js +49 -0
  387. package/dist/frontend/lowering/expressions/native-proxy.js.map +1 -0
  388. package/dist/frontend/lowering/expressions/nullish-assignment.d.ts +6 -0
  389. package/dist/frontend/lowering/expressions/nullish-assignment.js +124 -0
  390. package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -0
  391. package/dist/frontend/lowering/expressions/object-literals.d.ts +8 -8
  392. package/dist/frontend/lowering/expressions/object-literals.js +473 -178
  393. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  394. package/dist/frontend/lowering/expressions/optional-chains.js +20 -8
  395. package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
  396. package/dist/frontend/lowering/expressions/try-lower-expression.js +1 -0
  397. package/dist/frontend/lowering/expressions/try-lower-expression.js.map +1 -1
  398. package/dist/frontend/lowering/expressions/union-field-write.d.ts +8 -0
  399. package/dist/frontend/lowering/expressions/union-field-write.js +71 -0
  400. package/dist/frontend/lowering/expressions/union-field-write.js.map +1 -0
  401. package/dist/frontend/lowering/function-context.d.ts +93 -0
  402. package/dist/frontend/lowering/function-context.js +103 -0
  403. package/dist/frontend/lowering/function-context.js.map +1 -0
  404. package/dist/frontend/lowering/generator-delegation.d.ts +7 -0
  405. package/dist/frontend/lowering/generator-delegation.js +85 -0
  406. package/dist/frontend/lowering/generator-delegation.js.map +1 -0
  407. package/dist/frontend/lowering/generator-dynamic-dispatch.d.ts +10 -0
  408. package/dist/frontend/lowering/generator-dynamic-dispatch.js +105 -0
  409. package/dist/frontend/lowering/generator-dynamic-dispatch.js.map +1 -0
  410. package/dist/frontend/lowering/lib-boundary.d.ts +2 -1
  411. package/dist/frontend/lowering/lib-boundary.js +59 -20
  412. package/dist/frontend/lowering/lib-boundary.js.map +1 -1
  413. package/dist/frontend/lowering/lib-boundary.test.d.ts +1 -0
  414. package/dist/frontend/lowering/lib-boundary.test.js +45 -0
  415. package/dist/frontend/lowering/lib-boundary.test.js.map +1 -0
  416. package/dist/frontend/lowering/lower-array-sort.d.ts +1 -1
  417. package/dist/frontend/lowering/lower-assert.d.ts +1 -1
  418. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  419. package/dist/frontend/lowering/lower-async-iteration.d.ts +1 -1
  420. package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
  421. package/dist/frontend/lowering/lower-builtin-values.d.ts +12 -0
  422. package/dist/frontend/lowering/lower-builtin-values.js +139 -0
  423. package/dist/frontend/lowering/lower-builtin-values.js.map +1 -0
  424. package/dist/frontend/lowering/lower-builtins.d.ts +27 -41
  425. package/dist/frontend/lowering/lower-builtins.js +539 -343
  426. package/dist/frontend/lowering/lower-builtins.js.map +1 -1
  427. package/dist/frontend/lowering/lower-calls.d.ts +20 -17
  428. package/dist/frontend/lowering/lower-calls.js +1236 -353
  429. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  430. package/dist/frontend/lowering/lower-classes.d.ts +83 -45
  431. package/dist/frontend/lowering/lower-classes.js +952 -339
  432. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  433. package/dist/frontend/lowering/lower-comptime.d.ts +1 -1
  434. package/dist/frontend/lowering/lower-comptime.js +23 -32
  435. package/dist/frontend/lowering/lower-comptime.js.map +1 -1
  436. package/dist/frontend/lowering/lower-containers.d.ts +27 -32
  437. package/dist/frontend/lowering/lower-containers.js +796 -151
  438. package/dist/frontend/lowering/lower-containers.js.map +1 -1
  439. package/dist/frontend/lowering/lower-dgram.d.ts +1 -1
  440. package/dist/frontend/lowering/lower-dgram.js.map +1 -1
  441. package/dist/frontend/lowering/lower-enums.d.ts +1 -1
  442. package/dist/frontend/lowering/lower-enums.js.map +1 -1
  443. package/dist/frontend/lowering/lower-event-emitter.d.ts +30 -1
  444. package/dist/frontend/lowering/lower-event-emitter.js +58 -26
  445. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  446. package/dist/frontend/lowering/lower-expando.d.ts +7 -1
  447. package/dist/frontend/lowering/lower-expando.js +14 -6
  448. package/dist/frontend/lowering/lower-expando.js.map +1 -1
  449. package/dist/frontend/lowering/lower-exprs.d.ts +35 -11
  450. package/dist/frontend/lowering/lower-exprs.js +1674 -779
  451. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  452. package/dist/frontend/lowering/lower-generators.d.ts +2 -5
  453. package/dist/frontend/lowering/lower-generators.js +77 -46
  454. package/dist/frontend/lowering/lower-generators.js.map +1 -1
  455. package/dist/frontend/lowering/lower-global-value.d.ts +7 -0
  456. package/dist/frontend/lowering/lower-global-value.js +17 -0
  457. package/dist/frontend/lowering/lower-global-value.js.map +1 -0
  458. package/dist/frontend/lowering/lower-inspect.d.ts +1 -1
  459. package/dist/frontend/lowering/lower-inspect.js +17 -8
  460. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  461. package/dist/frontend/lowering/lower-island.d.ts +5 -8
  462. package/dist/frontend/lowering/lower-island.js +34 -23
  463. package/dist/frontend/lowering/lower-island.js.map +1 -1
  464. package/dist/frontend/lowering/lower-mixins.d.ts +2 -2
  465. package/dist/frontend/lowering/lower-mixins.js +5 -3
  466. package/dist/frontend/lowering/lower-mixins.js.map +1 -1
  467. package/dist/frontend/lowering/lower-modules.d.ts +1 -1
  468. package/dist/frontend/lowering/lower-modules.js +233 -30
  469. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  470. package/dist/frontend/lowering/lower-namespaces.d.ts +1 -1
  471. package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
  472. package/dist/frontend/lowering/lower-node-module.d.ts +1 -1
  473. package/dist/frontend/lowering/lower-node-module.js +13 -10
  474. package/dist/frontend/lowering/lower-node-module.js.map +1 -1
  475. package/dist/frontend/lowering/lower-server.d.ts +1 -1
  476. package/dist/frontend/lowering/lower-server.js +6 -10
  477. package/dist/frontend/lowering/lower-server.js.map +1 -1
  478. package/dist/frontend/lowering/lower-stmts.d.ts +10 -14
  479. package/dist/frontend/lowering/lower-stmts.js +728 -496
  480. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  481. package/dist/frontend/lowering/lower-stream.d.ts +1 -1
  482. package/dist/frontend/lowering/lower-stream.js +19 -10
  483. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  484. package/dist/frontend/lowering/lower-test.d.ts +1 -1
  485. package/dist/frontend/lowering/lower-test.js.map +1 -1
  486. package/dist/frontend/lowering/lower-url.d.ts +6 -0
  487. package/dist/frontend/lowering/lower-url.js +77 -0
  488. package/dist/frontend/lowering/lower-url.js.map +1 -0
  489. package/dist/frontend/lowering/lowerer.d.ts +113 -189
  490. package/dist/frontend/lowering/lowerer.js +1031 -672
  491. package/dist/frontend/lowering/lowerer.js.map +1 -1
  492. package/dist/frontend/lowering/lowerer.test.d.ts +1 -0
  493. package/dist/frontend/lowering/lowerer.test.js +26 -0
  494. package/dist/frontend/lowering/lowerer.test.js.map +1 -0
  495. package/dist/frontend/lowering/native-ffi.d.ts +5 -0
  496. package/dist/frontend/lowering/native-ffi.js +40 -0
  497. package/dist/frontend/lowering/native-ffi.js.map +1 -0
  498. package/dist/frontend/lowering/object-enumeration-receiver.d.ts +7 -0
  499. package/dist/frontend/lowering/object-enumeration-receiver.js +33 -0
  500. package/dist/frontend/lowering/object-enumeration-receiver.js.map +1 -0
  501. package/dist/frontend/lowering/object-factory-new.d.ts +8 -0
  502. package/dist/frontend/lowering/object-factory-new.js +68 -0
  503. package/dist/frontend/lowering/object-factory-new.js.map +1 -0
  504. package/dist/frontend/lowering/optional-arguments.js +6 -1
  505. package/dist/frontend/lowering/optional-arguments.js.map +1 -1
  506. package/dist/frontend/lowering/pairs-snapshot.js +2 -1
  507. package/dist/frontend/lowering/pairs-snapshot.js.map +1 -1
  508. package/dist/frontend/lowering/runtime-optional-locals.d.ts +14 -0
  509. package/dist/frontend/lowering/runtime-optional-locals.js +41 -0
  510. package/dist/frontend/lowering/runtime-optional-locals.js.map +1 -0
  511. package/dist/frontend/lowering/runtime-optional-locals.test.d.ts +1 -0
  512. package/dist/frontend/lowering/runtime-optional-locals.test.js +85 -0
  513. package/dist/frontend/lowering/runtime-optional-locals.test.js.map +1 -0
  514. package/dist/frontend/lowering/sanitize-class-types.d.ts +8 -0
  515. package/dist/frontend/lowering/sanitize-class-types.js +79 -0
  516. package/dist/frontend/lowering/sanitize-class-types.js.map +1 -0
  517. package/dist/frontend/lowering/sanitize-class-types.test.d.ts +1 -0
  518. package/dist/frontend/lowering/sanitize-class-types.test.js +60 -0
  519. package/dist/frontend/lowering/sanitize-class-types.test.js.map +1 -0
  520. package/dist/frontend/lowering/static-this.d.ts +5 -1
  521. package/dist/frontend/lowering/static-this.js +28 -2
  522. package/dist/frontend/lowering/static-this.js.map +1 -1
  523. package/dist/frontend/lowering/string-index.d.ts +7 -0
  524. package/dist/frontend/lowering/string-index.js +39 -0
  525. package/dist/frontend/lowering/string-index.js.map +1 -0
  526. package/dist/frontend/lowering/surfaces.d.ts +8 -3
  527. package/dist/frontend/lowering/surfaces.js +61 -29
  528. package/dist/frontend/lowering/surfaces.js.map +1 -1
  529. package/dist/frontend/lowering/symbol-fields.d.ts +22 -0
  530. package/dist/frontend/lowering/symbol-fields.js +183 -0
  531. package/dist/frontend/lowering/symbol-fields.js.map +1 -0
  532. package/dist/frontend/lowering/symbol-methods.d.ts +7 -0
  533. package/dist/frontend/lowering/symbol-methods.js +30 -0
  534. package/dist/frontend/lowering/symbol-methods.js.map +1 -0
  535. package/dist/frontend/lowering/text-decoder-encoding.d.ts +10 -0
  536. package/dist/frontend/lowering/text-decoder-encoding.js +77 -0
  537. package/dist/frontend/lowering/text-decoder-encoding.js.map +1 -0
  538. package/dist/frontend/lowering/text-decoder-encoding.test.d.ts +1 -0
  539. package/dist/frontend/lowering/text-decoder-encoding.test.js +38 -0
  540. package/dist/frontend/lowering/text-decoder-encoding.test.js.map +1 -0
  541. package/dist/frontend/lowering/union-narrow.d.ts +9 -0
  542. package/dist/frontend/lowering/union-narrow.js +59 -0
  543. package/dist/frontend/lowering/union-narrow.js.map +1 -0
  544. package/dist/frontend/lowering/union-narrow.test.d.ts +1 -0
  545. package/dist/frontend/lowering/union-narrow.test.js +72 -0
  546. package/dist/frontend/lowering/union-narrow.test.js.map +1 -0
  547. package/dist/frontend/lowering/union-retag.d.ts +43 -0
  548. package/dist/frontend/lowering/union-retag.js +259 -0
  549. package/dist/frontend/lowering/union-retag.js.map +1 -0
  550. package/dist/frontend/lowering/union-retag.test.d.ts +1 -0
  551. package/dist/frontend/lowering/union-retag.test.js +405 -0
  552. package/dist/frontend/lowering/union-retag.test.js.map +1 -0
  553. package/dist/frontend/lowering/unregistered-class-types.d.ts +14 -0
  554. package/dist/frontend/lowering/unregistered-class-types.js +94 -0
  555. package/dist/frontend/lowering/unregistered-class-types.js.map +1 -0
  556. package/dist/frontend/lowering/unregistered-class-types.test.d.ts +1 -0
  557. package/dist/frontend/lowering/unregistered-class-types.test.js +65 -0
  558. package/dist/frontend/lowering/unregistered-class-types.test.js.map +1 -0
  559. package/dist/frontend/lowering/width-lift.d.ts +40 -0
  560. package/dist/frontend/lowering/width-lift.js +2 -0
  561. package/dist/frontend/lowering/width-lift.js.map +1 -0
  562. package/dist/frontend/module-syntax.d.ts +58 -0
  563. package/dist/frontend/module-syntax.js +123 -0
  564. package/dist/frontend/module-syntax.js.map +1 -0
  565. package/dist/frontend/module-syntax.test.d.ts +1 -0
  566. package/dist/frontend/module-syntax.test.js +78 -0
  567. package/dist/frontend/module-syntax.test.js.map +1 -0
  568. package/dist/frontend/npm-fetch-analysis.d.ts +17 -0
  569. package/dist/frontend/npm-fetch-analysis.js +100 -0
  570. package/dist/frontend/npm-fetch-analysis.js.map +1 -0
  571. package/dist/frontend/npm-fetch-analysis.test.d.ts +1 -0
  572. package/dist/frontend/npm-fetch-analysis.test.js +107 -0
  573. package/dist/frontend/npm-fetch-analysis.test.js.map +1 -0
  574. package/dist/frontend/npm-fetch-node.d.ts +2 -0
  575. package/dist/frontend/npm-fetch-node.js +12 -0
  576. package/dist/frontend/npm-fetch-node.js.map +1 -0
  577. package/dist/frontend/npm-fetch-syntax.d.ts +6 -0
  578. package/dist/frontend/npm-fetch-syntax.js +207 -0
  579. package/dist/frontend/npm-fetch-syntax.js.map +1 -0
  580. package/dist/frontend/npm-node.d.ts +10 -0
  581. package/dist/frontend/npm-node.js +14 -0
  582. package/dist/frontend/npm-node.js.map +1 -0
  583. package/dist/frontend/npm-static-bundled-cjs.d.ts +8 -0
  584. package/dist/frontend/npm-static-bundled-cjs.js +236 -0
  585. package/dist/frontend/npm-static-bundled-cjs.js.map +1 -0
  586. package/dist/frontend/npm-static-bundled-cjs.test.d.ts +1 -0
  587. package/dist/frontend/npm-static-bundled-cjs.test.js +69 -0
  588. package/dist/frontend/npm-static-bundled-cjs.test.js.map +1 -0
  589. package/dist/frontend/npm-static-declaration-syntax.d.ts +57 -0
  590. package/dist/frontend/npm-static-declaration-syntax.js +944 -0
  591. package/dist/frontend/npm-static-declaration-syntax.js.map +1 -0
  592. package/dist/frontend/npm-static-declarations.d.ts +11 -39
  593. package/dist/frontend/npm-static-declarations.js +22 -561
  594. package/dist/frontend/npm-static-declarations.js.map +1 -1
  595. package/dist/frontend/npm-static-declarations.test.js +245 -6
  596. package/dist/frontend/npm-static-declarations.test.js.map +1 -1
  597. package/dist/frontend/npm-static-prune.d.ts +1 -1
  598. package/dist/frontend/npm-static-prune.js +5 -4
  599. package/dist/frontend/npm-static-prune.js.map +1 -1
  600. package/dist/frontend/npm-static-prune.test.js +1 -1
  601. package/dist/frontend/npm-static-prune.test.js.map +1 -1
  602. package/dist/frontend/npm-static-rewrite-host.d.ts +4 -0
  603. package/dist/frontend/npm-static-rewrite-host.js +179 -0
  604. package/dist/frontend/npm-static-rewrite-host.js.map +1 -0
  605. package/dist/frontend/npm-static-rewrite-syntax.d.ts +16 -0
  606. package/dist/frontend/npm-static-rewrite-syntax.js +905 -0
  607. package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -0
  608. package/dist/frontend/npm-static-rewrite.d.ts +0 -5
  609. package/dist/frontend/npm-static-rewrite.js +2 -1079
  610. package/dist/frontend/npm-static-rewrite.js.map +1 -1
  611. package/dist/frontend/npm-static-subtyping.d.ts +5 -0
  612. package/dist/frontend/npm-static-subtyping.js +55 -0
  613. package/dist/frontend/npm-static-subtyping.js.map +1 -0
  614. package/dist/frontend/npm-static-subtyping.test.d.ts +1 -0
  615. package/dist/frontend/npm-static-subtyping.test.js +58 -0
  616. package/dist/frontend/npm-static-subtyping.test.js.map +1 -0
  617. package/dist/frontend/npm-static.d.ts +7 -15
  618. package/dist/frontend/npm-static.js +19 -28
  619. package/dist/frontend/npm-static.js.map +1 -1
  620. package/dist/frontend/npm.d.ts +8 -69
  621. package/dist/frontend/npm.js +21 -361
  622. package/dist/frontend/npm.js.map +1 -1
  623. package/dist/frontend/npm.test.js +2 -2
  624. package/dist/frontend/npm.test.js.map +1 -1
  625. package/dist/frontend/pipeline-native.d.ts +6 -0
  626. package/dist/frontend/pipeline-native.js +32 -0
  627. package/dist/frontend/pipeline-native.js.map +1 -0
  628. package/dist/frontend/pipeline.d.ts +54 -0
  629. package/dist/frontend/pipeline.js +382 -0
  630. package/dist/frontend/pipeline.js.map +1 -0
  631. package/dist/frontend/pipeline.test.d.ts +1 -0
  632. package/dist/frontend/pipeline.test.js +77 -0
  633. package/dist/frontend/pipeline.test.js.map +1 -0
  634. package/dist/frontend/program-analysis.d.ts +10 -0
  635. package/dist/frontend/program-analysis.js +14 -0
  636. package/dist/frontend/program-analysis.js.map +1 -0
  637. package/dist/frontend/program-node.d.ts +9 -0
  638. package/dist/frontend/program-node.js +48 -0
  639. package/dist/frontend/program-node.js.map +1 -0
  640. package/dist/frontend/program.d.ts +38 -19
  641. package/dist/frontend/program.js +344 -169
  642. package/dist/frontend/program.js.map +1 -1
  643. package/dist/frontend/program.test.js +87 -2
  644. package/dist/frontend/program.test.js.map +1 -1
  645. package/dist/frontend/provenance-core.d.ts +9 -0
  646. package/dist/frontend/provenance-core.js +435 -0
  647. package/dist/frontend/provenance-core.js.map +1 -0
  648. package/dist/frontend/provenance.d.ts +0 -4
  649. package/dist/frontend/provenance.js +4 -459
  650. package/dist/frontend/provenance.js.map +1 -1
  651. package/dist/frontend/resolve.d.ts +3 -1
  652. package/dist/frontend/resolve.js +6 -3
  653. package/dist/frontend/resolve.js.map +1 -1
  654. package/dist/frontend/runtime-resolve.d.ts +4 -3
  655. package/dist/frontend/runtime-resolve.js +22 -18
  656. package/dist/frontend/runtime-resolve.js.map +1 -1
  657. package/dist/frontend/runtime-resolve.test.js +53 -0
  658. package/dist/frontend/runtime-resolve.test.js.map +1 -1
  659. package/dist/frontend/services-node.d.ts +5 -0
  660. package/dist/frontend/services-node.js +19 -0
  661. package/dist/frontend/services-node.js.map +1 -0
  662. package/dist/frontend/services-node.test.d.ts +1 -0
  663. package/dist/frontend/services-node.test.js +70 -0
  664. package/dist/frontend/services-node.test.js.map +1 -0
  665. package/dist/frontend/services.d.ts +44 -0
  666. package/dist/frontend/services.js +90 -0
  667. package/dist/frontend/services.js.map +1 -0
  668. package/dist/frontend/services.test.d.ts +1 -0
  669. package/dist/frontend/services.test.js +174 -0
  670. package/dist/frontend/services.test.js.map +1 -0
  671. package/dist/frontend/ts7/adapter.d.ts +3 -3
  672. package/dist/frontend/ts7/adapter.js +14 -31
  673. package/dist/frontend/ts7/adapter.js.map +1 -1
  674. package/dist/frontend/ts7/api.d.ts +16 -0
  675. package/dist/frontend/ts7/api.js +24 -0
  676. package/dist/frontend/ts7/api.js.map +1 -0
  677. package/dist/frontend/ts7/ast-bytes.d.ts +31 -0
  678. package/dist/frontend/ts7/ast-bytes.js +137 -0
  679. package/dist/frontend/ts7/ast-bytes.js.map +1 -0
  680. package/dist/frontend/ts7/ast-bytes.test.d.ts +1 -0
  681. package/dist/frontend/ts7/ast-bytes.test.js +73 -0
  682. package/dist/frontend/ts7/ast-bytes.test.js.map +1 -0
  683. package/dist/frontend/ts7/ast-guards.generated.d.ts +353 -0
  684. package/dist/frontend/ts7/ast-guards.generated.js +1951 -0
  685. package/dist/frontend/ts7/ast-guards.generated.js.map +1 -0
  686. package/dist/frontend/ts7/ast-guards.test.d.ts +1 -0
  687. package/dist/frontend/ts7/ast-guards.test.js +43 -0
  688. package/dist/frontend/ts7/ast-guards.test.js.map +1 -0
  689. package/dist/frontend/ts7/ast-node.d.ts +194 -0
  690. package/dist/frontend/ts7/ast-node.js +448 -0
  691. package/dist/frontend/ts7/ast-node.js.map +1 -0
  692. package/dist/frontend/ts7/ast-node.test.d.ts +1 -0
  693. package/dist/frontend/ts7/ast-node.test.js +266 -0
  694. package/dist/frontend/ts7/ast-node.test.js.map +1 -0
  695. package/dist/frontend/ts7/ast-schema.generated.d.ts +503 -0
  696. package/dist/frontend/ts7/ast-schema.generated.js +1446 -0
  697. package/dist/frontend/ts7/ast-schema.generated.js.map +1 -0
  698. package/dist/frontend/ts7/ast-text.d.ts +6 -0
  699. package/dist/frontend/ts7/ast-text.js +124 -0
  700. package/dist/frontend/ts7/ast-text.js.map +1 -0
  701. package/dist/frontend/ts7/ast-text.test.d.ts +1 -0
  702. package/dist/frontend/ts7/ast-text.test.js +38 -0
  703. package/dist/frontend/ts7/ast-text.test.js.map +1 -0
  704. package/dist/frontend/ts7/ast-tokens.generated.d.ts +2 -0
  705. package/dist/frontend/ts7/ast-tokens.generated.js +155 -0
  706. package/dist/frontend/ts7/ast-tokens.generated.js.map +1 -0
  707. package/dist/frontend/ts7/ast-types.d.ts +42 -0
  708. package/dist/frontend/ts7/ast-types.generated.d.ts +1615 -0
  709. package/dist/frontend/ts7/ast-types.generated.js +5 -0
  710. package/dist/frontend/ts7/ast-types.generated.js.map +1 -0
  711. package/dist/frontend/ts7/ast-types.js +3 -0
  712. package/dist/frontend/ts7/ast-types.js.map +1 -0
  713. package/dist/frontend/ts7/ast-wire.d.ts +58 -0
  714. package/dist/frontend/ts7/ast-wire.js +267 -0
  715. package/dist/frontend/ts7/ast-wire.js.map +1 -0
  716. package/dist/frontend/ts7/ast-wire.test.d.ts +1 -0
  717. package/dist/frontend/ts7/ast-wire.test.js +151 -0
  718. package/dist/frontend/ts7/ast-wire.test.js.map +1 -0
  719. package/dist/frontend/ts7/ast.d.ts +14 -14
  720. package/dist/frontend/ts7/ast.js +21 -15
  721. package/dist/frontend/ts7/ast.js.map +1 -1
  722. package/dist/frontend/ts7/census-check.js +1 -0
  723. package/dist/frontend/ts7/census-check.js.map +1 -1
  724. package/dist/frontend/ts7/checker-cache.d.ts +48 -0
  725. package/dist/frontend/ts7/checker-cache.js +92 -0
  726. package/dist/frontend/ts7/checker-cache.js.map +1 -0
  727. package/dist/frontend/ts7/checker.d.ts +19 -46
  728. package/dist/frontend/ts7/checker.js +231 -161
  729. package/dist/frontend/ts7/checker.js.map +1 -1
  730. package/dist/frontend/ts7/checker.test.d.ts +1 -0
  731. package/dist/frontend/ts7/checker.test.js +335 -0
  732. package/dist/frontend/ts7/checker.test.js.map +1 -0
  733. package/dist/frontend/ts7/enums.d.ts +4 -27
  734. package/dist/frontend/ts7/enums.generated.d.ts +878 -0
  735. package/dist/frontend/ts7/enums.generated.js +1313 -0
  736. package/dist/frontend/ts7/enums.generated.js.map +1 -0
  737. package/dist/frontend/ts7/enums.js +4 -45
  738. package/dist/frontend/ts7/enums.js.map +1 -1
  739. package/dist/frontend/ts7/enums.test.d.ts +1 -0
  740. package/dist/frontend/ts7/enums.test.js +48 -0
  741. package/dist/frontend/ts7/enums.test.js.map +1 -0
  742. package/dist/frontend/ts7/native-api.d.ts +10 -0
  743. package/dist/frontend/ts7/native-api.js +10 -0
  744. package/dist/frontend/ts7/native-api.js.map +1 -0
  745. package/dist/frontend/ts7/native-host.d.ts +2 -0
  746. package/dist/frontend/ts7/native-host.js +11 -0
  747. package/dist/frontend/ts7/native-host.js.map +1 -0
  748. package/dist/frontend/ts7/native-process.d.ts +14 -0
  749. package/dist/frontend/ts7/native-process.js +62 -0
  750. package/dist/frontend/ts7/native-process.js.map +1 -0
  751. package/dist/frontend/ts7/program-adapter.d.ts +10 -98
  752. package/dist/frontend/ts7/program-adapter.js +16 -310
  753. package/dist/frontend/ts7/program-adapter.js.map +1 -1
  754. package/dist/frontend/ts7/program-host.d.ts +115 -0
  755. package/dist/frontend/ts7/program-host.js +347 -0
  756. package/dist/frontend/ts7/program-host.js.map +1 -0
  757. package/dist/frontend/ts7/program-host.test.d.ts +1 -0
  758. package/dist/frontend/ts7/program-host.test.js +207 -0
  759. package/dist/frontend/ts7/program-host.test.js.map +1 -0
  760. package/dist/frontend/ts7/rpc-api.d.ts +12 -0
  761. package/dist/frontend/ts7/rpc-api.js +23 -0
  762. package/dist/frontend/ts7/rpc-api.js.map +1 -0
  763. package/dist/frontend/ts7/rpc-client.d.ts +27 -0
  764. package/dist/frontend/ts7/rpc-client.js +102 -0
  765. package/dist/frontend/ts7/rpc-client.js.map +1 -0
  766. package/dist/frontend/ts7/rpc-client.test.d.ts +1 -0
  767. package/dist/frontend/ts7/rpc-client.test.js +133 -0
  768. package/dist/frontend/ts7/rpc-client.test.js.map +1 -0
  769. package/dist/frontend/ts7/rpc-filesystem.d.ts +16 -0
  770. package/dist/frontend/ts7/rpc-filesystem.js +42 -0
  771. package/dist/frontend/ts7/rpc-filesystem.js.map +1 -0
  772. package/dist/frontend/ts7/rpc-filesystem.test.d.ts +1 -0
  773. package/dist/frontend/ts7/rpc-filesystem.test.js +89 -0
  774. package/dist/frontend/ts7/rpc-filesystem.test.js.map +1 -0
  775. package/dist/frontend/ts7/rpc-process.d.ts +2 -0
  776. package/dist/frontend/ts7/rpc-process.js +148 -0
  777. package/dist/frontend/ts7/rpc-process.js.map +1 -0
  778. package/dist/frontend/ts7/rpc-process.test.d.ts +1 -0
  779. package/dist/frontend/ts7/rpc-process.test.js +29 -0
  780. package/dist/frontend/ts7/rpc-process.test.js.map +1 -0
  781. package/dist/frontend/ts7/rpc-wire.d.ts +46 -0
  782. package/dist/frontend/ts7/rpc-wire.js +195 -0
  783. package/dist/frontend/ts7/rpc-wire.js.map +1 -0
  784. package/dist/frontend/ts7/rpc-wire.test.d.ts +1 -0
  785. package/dist/frontend/ts7/rpc-wire.test.js +168 -0
  786. package/dist/frontend/ts7/rpc-wire.test.js.map +1 -0
  787. package/dist/frontend/ts7/semantic-checker.d.ts +137 -0
  788. package/dist/frontend/ts7/semantic-checker.js +221 -0
  789. package/dist/frontend/ts7/semantic-checker.js.map +1 -0
  790. package/dist/frontend/ts7/semantic-checker.test.d.ts +1 -0
  791. package/dist/frontend/ts7/semantic-checker.test.js +119 -0
  792. package/dist/frontend/ts7/semantic-checker.test.js.map +1 -0
  793. package/dist/frontend/ts7/semantic-json.d.ts +5 -0
  794. package/dist/frontend/ts7/semantic-json.js +52 -0
  795. package/dist/frontend/ts7/semantic-json.js.map +1 -0
  796. package/dist/frontend/ts7/semantic-json.test.d.ts +1 -0
  797. package/dist/frontend/ts7/semantic-json.test.js +42 -0
  798. package/dist/frontend/ts7/semantic-json.test.js.map +1 -0
  799. package/dist/frontend/ts7/semantic-model.d.ts +222 -0
  800. package/dist/frontend/ts7/semantic-model.js +423 -0
  801. package/dist/frontend/ts7/semantic-model.js.map +1 -0
  802. package/dist/frontend/ts7/semantic-model.test.d.ts +1 -0
  803. package/dist/frontend/ts7/semantic-model.test.js +322 -0
  804. package/dist/frontend/ts7/semantic-model.test.js.map +1 -0
  805. package/dist/frontend/ts7/semantic-schema.generated.d.ts +283 -0
  806. package/dist/frontend/ts7/semantic-schema.generated.js +222 -0
  807. package/dist/frontend/ts7/semantic-schema.generated.js.map +1 -0
  808. package/dist/frontend/ts7/semantic-types.d.ts +5 -0
  809. package/dist/frontend/ts7/semantic-types.js +2 -0
  810. package/dist/frontend/ts7/semantic-types.js.map +1 -0
  811. package/dist/frontend/ts7/session-cache.d.ts +17 -0
  812. package/dist/frontend/ts7/session-cache.js +97 -0
  813. package/dist/frontend/ts7/session-cache.js.map +1 -0
  814. package/dist/frontend/ts7/session-cache.test.d.ts +1 -0
  815. package/dist/frontend/ts7/session-cache.test.js +87 -0
  816. package/dist/frontend/ts7/session-cache.test.js.map +1 -0
  817. package/dist/frontend/ts7/session-path.d.ts +18 -0
  818. package/dist/frontend/ts7/session-path.js +203 -0
  819. package/dist/frontend/ts7/session-path.js.map +1 -0
  820. package/dist/frontend/ts7/session-path.test.d.ts +1 -0
  821. package/dist/frontend/ts7/session-path.test.js +34 -0
  822. package/dist/frontend/ts7/session-path.test.js.map +1 -0
  823. package/dist/frontend/ts7/session-schema.generated.d.ts +167 -0
  824. package/dist/frontend/ts7/session-schema.generated.js +5 -0
  825. package/dist/frontend/ts7/session-schema.generated.js.map +1 -0
  826. package/dist/frontend/ts7/session-timing.d.ts +50 -0
  827. package/dist/frontend/ts7/session-timing.js +61 -0
  828. package/dist/frontend/ts7/session-timing.js.map +1 -0
  829. package/dist/frontend/ts7/session-timing.test.d.ts +1 -0
  830. package/dist/frontend/ts7/session-timing.test.js +52 -0
  831. package/dist/frontend/ts7/session-timing.test.js.map +1 -0
  832. package/dist/frontend/ts7/session.d.ts +105 -0
  833. package/dist/frontend/ts7/session.js +233 -0
  834. package/dist/frontend/ts7/session.js.map +1 -0
  835. package/dist/frontend/ts7/session.test.d.ts +1 -0
  836. package/dist/frontend/ts7/session.test.js +215 -0
  837. package/dist/frontend/ts7/session.test.js.map +1 -0
  838. package/dist/frontend/ts7/source-parser-node.d.ts +6 -0
  839. package/dist/frontend/ts7/source-parser-node.js +15 -0
  840. package/dist/frontend/ts7/source-parser-node.js.map +1 -0
  841. package/dist/frontend/ts7/source-parser.d.ts +25 -0
  842. package/dist/frontend/ts7/source-parser.js +96 -0
  843. package/dist/frontend/ts7/source-parser.js.map +1 -0
  844. package/dist/frontend/ts7/source-parser.test.d.ts +1 -0
  845. package/dist/frontend/ts7/source-parser.test.js +151 -0
  846. package/dist/frontend/ts7/source-parser.test.js.map +1 -0
  847. package/dist/frontend/ts7/syntax.d.ts +3 -0
  848. package/dist/frontend/ts7/syntax.js +4 -0
  849. package/dist/frontend/ts7/syntax.js.map +1 -0
  850. package/dist/frontend/tsc-codes.js +3 -0
  851. package/dist/frontend/tsc-codes.js.map +1 -1
  852. package/dist/frontend/type-mapper.d.ts +25 -17
  853. package/dist/frontend/type-mapper.js +465 -121
  854. package/dist/frontend/type-mapper.js.map +1 -1
  855. package/dist/frontend/type-mapper.test.js +123 -2
  856. package/dist/frontend/type-mapper.test.js.map +1 -1
  857. package/dist/frontend/union-discriminants.d.ts +16 -0
  858. package/dist/frontend/union-discriminants.js +98 -0
  859. package/dist/frontend/union-discriminants.js.map +1 -0
  860. package/dist/frontend/union-discriminants.test.d.ts +1 -0
  861. package/dist/frontend/union-discriminants.test.js +182 -0
  862. package/dist/frontend/union-discriminants.test.js.map +1 -0
  863. package/dist/index.d.ts +7 -198
  864. package/dist/index.js +369 -1572
  865. package/dist/index.js.map +1 -1
  866. package/dist/ir/analysis.d.ts +16 -4
  867. package/dist/ir/analysis.js +21 -4
  868. package/dist/ir/analysis.js.map +1 -1
  869. package/dist/ir/analysis.test.js +15 -2
  870. package/dist/ir/analysis.test.js.map +1 -1
  871. package/dist/ir/constant-tables.js +67 -49
  872. package/dist/ir/constant-tables.js.map +1 -1
  873. package/dist/ir/constant-tables.test.js +1 -1
  874. package/dist/ir/control-flow.d.ts +6 -0
  875. package/dist/ir/control-flow.js +142 -0
  876. package/dist/ir/control-flow.js.map +1 -0
  877. package/dist/ir/control-flow.test.d.ts +1 -0
  878. package/dist/ir/control-flow.test.js +113 -0
  879. package/dist/ir/control-flow.test.js.map +1 -0
  880. package/dist/ir/integer-loops.js +7 -18
  881. package/dist/ir/integer-loops.js.map +1 -1
  882. package/dist/ir/integer-ranges.js +53 -27
  883. package/dist/ir/integer-ranges.js.map +1 -1
  884. package/dist/ir/ir.d.ts +291 -152
  885. package/dist/ir/ir.js +588 -881
  886. package/dist/ir/ir.js.map +1 -1
  887. package/dist/ir/ir.test.js +127 -1
  888. package/dist/ir/ir.test.js.map +1 -1
  889. package/dist/ir/scalar-records.js +165 -134
  890. package/dist/ir/scalar-records.js.map +1 -1
  891. package/dist/ir/scalar-records.test.js +1 -1
  892. package/dist/ir/serialize.d.ts +4 -2
  893. package/dist/ir/serialize.js +19 -12
  894. package/dist/ir/serialize.js.map +1 -1
  895. package/dist/ir/serialize.test.d.ts +1 -0
  896. package/dist/ir/serialize.test.js +53 -0
  897. package/dist/ir/serialize.test.js.map +1 -0
  898. package/dist/ir/traverse.d.ts +41 -0
  899. package/dist/ir/traverse.js +660 -0
  900. package/dist/ir/traverse.js.map +1 -0
  901. package/dist/ir/traverse.test.d.ts +1 -0
  902. package/dist/ir/traverse.test.js +242 -0
  903. package/dist/ir/traverse.test.js.map +1 -0
  904. package/dist/ir/validate.js +1942 -1491
  905. package/dist/ir/validate.js.map +1 -1
  906. package/dist/ir/validate.test.js +476 -2
  907. package/dist/ir/validate.test.js.map +1 -1
  908. package/dist/library/cache-primitives.d.ts +2 -3
  909. package/dist/library/cache-primitives.js +4 -6
  910. package/dist/library/cache-primitives.js.map +1 -1
  911. package/dist/library/fence-eval.js +2 -2
  912. package/dist/library/fence-eval.js.map +1 -1
  913. package/dist/library/int-infer.js +7 -6
  914. package/dist/library/int-infer.js.map +1 -1
  915. package/dist/library/int-infer.test.js +4 -4
  916. package/dist/library/library-cache.d.ts +3 -2
  917. package/dist/library/library-cache.js +5 -17
  918. package/dist/library/library-cache.js.map +1 -1
  919. package/dist/library/library-cache.test.js +54 -41
  920. package/dist/library/library-cache.test.js.map +1 -1
  921. package/dist/library/library-profile.d.ts +3 -1
  922. package/dist/library/library-profile.js +15 -6
  923. package/dist/library/library-profile.js.map +1 -1
  924. package/dist/library/prepare.d.ts +15 -0
  925. package/dist/library/prepare.js +584 -0
  926. package/dist/library/prepare.js.map +1 -0
  927. package/dist/library/semantic-source.d.ts +1 -1
  928. package/dist/library/semantic-source.js +8 -6
  929. package/dist/library/semantic-source.js.map +1 -1
  930. package/dist/library/sidecar-validate.js +4 -4
  931. package/dist/library/sidecar-validate.js.map +1 -1
  932. package/dist/library/sidecar.d.ts +2 -0
  933. package/dist/library/sidecar.js +10 -3
  934. package/dist/library/sidecar.js.map +1 -1
  935. package/dist/native/cache.d.ts +11 -0
  936. package/dist/native/cache.js +113 -0
  937. package/dist/native/cache.js.map +1 -0
  938. package/dist/native/cache.test.d.ts +1 -0
  939. package/dist/native/cache.test.js +66 -0
  940. package/dist/native/cache.test.js.map +1 -0
  941. package/dist/native/cli.d.ts +1 -0
  942. package/dist/native/cli.js +112 -0
  943. package/dist/native/cli.js.map +1 -0
  944. package/dist/native/compiler.d.ts +15 -0
  945. package/dist/native/compiler.js +336 -0
  946. package/dist/native/compiler.js.map +1 -0
  947. package/dist/native/compiler.test.d.ts +1 -0
  948. package/dist/native/compiler.test.js +174 -0
  949. package/dist/native/compiler.test.js.map +1 -0
  950. package/dist/native/comptime.d.ts +5 -0
  951. package/dist/native/comptime.js +73 -0
  952. package/dist/native/comptime.js.map +1 -0
  953. package/dist/native/comptime.test.d.ts +1 -0
  954. package/dist/native/comptime.test.js +65 -0
  955. package/dist/native/comptime.test.js.map +1 -0
  956. package/dist/native/executable-cache.d.ts +26 -0
  957. package/dist/native/executable-cache.js +228 -0
  958. package/dist/native/executable-cache.js.map +1 -0
  959. package/dist/native/executable-cache.test.d.ts +1 -0
  960. package/dist/native/executable-cache.test.js +151 -0
  961. package/dist/native/executable-cache.test.js.map +1 -0
  962. package/dist/native/file-identity.d.ts +4 -0
  963. package/dist/native/file-identity.js +14 -0
  964. package/dist/native/file-identity.js.map +1 -0
  965. package/dist/native/file-identity.test.d.ts +1 -0
  966. package/dist/native/file-identity.test.js +43 -0
  967. package/dist/native/file-identity.test.js.map +1 -0
  968. package/dist/native/library.d.ts +22 -0
  969. package/dist/native/library.js +83 -0
  970. package/dist/native/library.js.map +1 -0
  971. package/dist/native/prepare.d.ts +21 -0
  972. package/dist/native/prepare.js +174 -0
  973. package/dist/native/prepare.js.map +1 -0
  974. package/dist/native/prepare.test.d.ts +1 -0
  975. package/dist/native/prepare.test.js +70 -0
  976. package/dist/native/prepare.test.js.map +1 -0
  977. package/dist/native/sanitizer.d.ts +11 -0
  978. package/dist/native/sanitizer.js +135 -0
  979. package/dist/native/sanitizer.js.map +1 -0
  980. package/dist/native/sanitizer.test.d.ts +1 -0
  981. package/dist/native/sanitizer.test.js +58 -0
  982. package/dist/native/sanitizer.test.js.map +1 -0
  983. package/dist/native/task.d.ts +4 -0
  984. package/dist/native/task.js +16 -0
  985. package/dist/native/task.js.map +1 -0
  986. package/dist/native/task.test.d.ts +1 -0
  987. package/dist/native/task.test.js +17 -0
  988. package/dist/native/task.test.js.map +1 -0
  989. package/dist/native/toolchain.d.ts +45 -0
  990. package/dist/native/toolchain.js +74 -0
  991. package/dist/native/toolchain.js.map +1 -0
  992. package/dist/native/toolchain.test.d.ts +1 -0
  993. package/dist/native/toolchain.test.js +33 -0
  994. package/dist/native/toolchain.test.js.map +1 -0
  995. package/dist/startup-cache.d.ts +1 -1
  996. package/dist/startup-cache.js +2 -5
  997. package/dist/startup-cache.js.map +1 -1
  998. package/dist/timing.d.ts +4 -0
  999. package/dist/timing.js +19 -0
  1000. package/dist/timing.js.map +1 -0
  1001. package/dist/wasi-paths.js +10 -7
  1002. package/dist/wasi-paths.js.map +1 -1
  1003. package/package.json +28 -19
  1004. package/surface-manifest.json +52 -18
  1005. package/dist/backend/c/async.d.ts +0 -171
  1006. package/dist/backend/c/async.js +0 -1317
  1007. package/dist/backend/c/async.js.map +0 -1
  1008. package/dist/backend/c/c-emitter.d.ts +0 -536
  1009. package/dist/backend/c/c-emitter.js +0 -1932
  1010. package/dist/backend/c/c-emitter.js.map +0 -1
  1011. package/dist/backend/c/exprs.d.ts +0 -15
  1012. package/dist/backend/c/exprs.js +0 -8847
  1013. package/dist/backend/c/exprs.js.map +0 -1
  1014. package/dist/backend/c/island.d.ts +0 -45
  1015. package/dist/backend/c/island.js +0 -281
  1016. package/dist/backend/c/island.js.map +0 -1
  1017. package/dist/backend/c/may-throw.js.map +0 -1
  1018. package/dist/backend/c/shapes.d.ts +0 -142
  1019. package/dist/backend/c/shapes.js +0 -603
  1020. package/dist/backend/c/shapes.js.map +0 -1
  1021. package/dist/backend/c/stmts.d.ts +0 -76
  1022. package/dist/backend/c/stmts.js +0 -1108
  1023. package/dist/backend/c/stmts.js.map +0 -1
  1024. package/dist/backend/c/types.d.ts +0 -71
  1025. package/dist/backend/c/types.js +0 -459
  1026. package/dist/backend/c/types.js.map +0 -1
  1027. package/dist/backend/c/types.test.js +0 -32
  1028. package/dist/backend/c/types.test.js.map +0 -1
  1029. package/dist/backend/c/walkers.d.ts +0 -134
  1030. package/dist/backend/c/walkers.js +0 -1772
  1031. package/dist/backend/c/walkers.js.map +0 -1
  1032. /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;
@@ -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,21 +996,37 @@ 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
1019
  export function canConvertToDyn(t, getRecord, getUnion) {
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
1027
  if (canBoxDynComposite(t, getRecord, getUnion))
984
1028
  return true;
985
- if (t.kind === "bytes" && t.elem === "u8")
1029
+ if (t.kind === "bytes")
986
1030
  return true;
987
1031
  // %Error converts as the checked-dynamic tree's error encoding ({%error, name, message,
988
1032
  // code?} — the caughtToDyn shape, scr_dyn_from_error): the dyn 'error'
@@ -991,6 +1035,10 @@ export function canConvertToDyn(t, getRecord, getUnion) {
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
1043
  return canBoxFuncIntoDyn(t, getRecord, getUnion);
996
1044
  if (DYN_HANDLE_KINDS.has(t.kind))
@@ -1013,14 +1061,14 @@ 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) ||
1064
+ isDynTypedRefType(a) || a.kind === "classval" || DYN_HANDLE_KINDS.has(a.kind) ||
1017
1065
  (a.kind === "func" && canBoxFuncIntoDyn(a, getRecord, getUnion)) ||
1018
1066
  (a.kind === "promise" && canConvertToDyn(a, getRecord, getUnion)));
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
1073
  * sc_td_* walker's capability. Returns false for a composite carrying a
1026
1074
  * kind the walker cannot box (Maps or handles nested in a record); those
@@ -1028,28 +1076,43 @@ export function canConvertToDyn(t, getRecord, getUnion) {
1028
1076
  function canBoxDynComposite(t, getRecord, getUnion, visiting = new Set()) {
1029
1077
  switch (t.kind) {
1030
1078
  case "f64":
1079
+ case "bigint":
1080
+ case "symbol":
1031
1081
  case "string":
1032
1082
  case "bool":
1033
1083
  case "dyn":
1034
1084
  case "undefinedT":
1035
1085
  case "nullT":
1086
+ case "classval":
1036
1087
  return true;
1037
1088
  case "bytes":
1038
- return t.elem === "u8";
1089
+ case "regex":
1090
+ case "url":
1091
+ return true;
1039
1092
  case "func":
1040
1093
  return canBoxFuncIntoDyn(t, getRecord, getUnion);
1094
+ case "set":
1095
+ return t.elem.kind === "dyn";
1096
+ case "map":
1097
+ return t.key.kind === "dyn" && t.value.kind === "dyn";
1098
+ case "object":
1099
+ return t.className === "%Error" || isDynTypedRefType(t);
1041
1100
  case "array":
1042
1101
  return canBoxDynComposite(t.elem, getRecord, getUnion, visiting);
1043
1102
  case "record": {
1044
1103
  const shape = getRecord(t.shapeId);
1045
1104
  if (!shape)
1046
1105
  return false;
1106
+ if (recordTextCodecClass(shape) !== null)
1107
+ return false;
1047
1108
  // Recursive shapes answer coinductively, like isJsonSafeType.
1048
1109
  if (visiting.has(t.shapeId))
1049
1110
  return true;
1050
1111
  visiting.add(t.shapeId);
1051
- if (!shape.fields.every((f) => canBoxDynComposite(f.type, getRecord, getUnion, visiting)))
1052
- return false;
1112
+ for (const field of shape.fields) {
1113
+ if (!canBoxDynComposite(field.type, getRecord, getUnion, visiting))
1114
+ return false;
1115
+ }
1053
1116
  return !shape.indexValue || canBoxDynComposite(shape.indexValue, getRecord, getUnion, visiting);
1054
1117
  }
1055
1118
  case "union": {
@@ -1059,31 +1122,57 @@ function canBoxDynComposite(t, getRecord, getUnion, visiting = new Set()) {
1059
1122
  if (visiting.has(t.unionId))
1060
1123
  return true;
1061
1124
  visiting.add(t.unionId);
1062
- return def.arms.every((a) => canBoxDynComposite(a, getRecord, getUnion, visiting));
1125
+ for (const arm of def.arms) {
1126
+ if (!canBoxDynComposite(arm, getRecord, getUnion, visiting))
1127
+ return false;
1128
+ }
1129
+ return true;
1063
1130
  }
1064
1131
  default:
1065
1132
  return false;
1066
1133
  }
1067
1134
  }
1068
1135
  /** 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,
1136
+ * JSON-safe data, numeric typed arrays (retained views), the %Error extraction,
1070
1137
  * undefined-armed unions of JSON-safe arms, adaptable function types,
1071
1138
  * and the runtime HANDLE kinds (a tag-checked reference unwrap —
1072
1139
  * DYN_HANDLE_KINDS). */
1073
1140
  export function canDynCheckTo(t, getRecord, getUnion) {
1074
- if (isJsonSafeType(t, getRecord, getUnion))
1141
+ // Unknown fields keep an owned dyn subtree; checking the surrounding
1142
+ // record/array still validates its layout. This is broader than the
1143
+ // stringify/island JSON domain, which cannot assume opaque slots are
1144
+ // serializable. Backends already retain dyn fields and fill missing
1145
+ // unknown record fields with the undefined value.
1146
+ if (isJsonSafeAt(t, getRecord, getUnion, false, false, new Set(), true))
1075
1147
  return true;
1076
- if (t.kind === "bytes" && t.elem === "u8")
1148
+ if (t.kind === "bigint" || t.kind === "symbol" || t.kind === "set" && t.elem.kind === "dyn")
1149
+ return true;
1150
+ if (t.kind === "map" && t.key.kind === "dyn" && t.value.kind === "dyn")
1151
+ return true;
1152
+ if (t.kind === "bytes")
1153
+ return true;
1154
+ if (t.kind === "classval")
1155
+ return true;
1156
+ if (t.kind === "generator")
1077
1157
  return true;
1078
1158
  if (t.kind === "object" && t.className === "%Error")
1079
1159
  return true;
1160
+ // Native class capsules already support checked extraction at ordinary
1161
+ // boundaries. Callable adapters use the same identity/brand check.
1162
+ if (isDynTypedRefType(t))
1163
+ return true;
1164
+ if (t.kind === "array" && isDynTypedRefType(t.elem))
1165
+ return true;
1080
1166
  if (t.kind === "func")
1081
1167
  return canAdaptDynFuncTo(t, getRecord, getUnion);
1082
1168
  if (DYN_HANDLE_KINDS.has(t.kind))
1083
1169
  return true;
1084
1170
  if (t.kind === "union") {
1085
1171
  const def = getUnion(t.unionId);
1086
- return !!def && def.arms.every((a) => a.kind === "undefinedT" || isJsonSafeType(a, getRecord, getUnion));
1172
+ // Optional native callbacks and handles retain the same checked
1173
+ // conversion as their bare value. The union matcher selects the arm
1174
+ // before its adapter/extractor runs.
1175
+ return !!def && def.arms.every((a) => isUnitType(a) || (a.kind !== "union" && canDynCheckTo(a, getRecord, getUnion)));
1087
1176
  }
1088
1177
  return false;
1089
1178
  }
@@ -1093,10 +1182,11 @@ export function canDynCheckTo(t, getRecord, getUnion) {
1093
1182
  * back). */
1094
1183
  export function canBoxFuncIntoDyn(t, getRecord, getUnion) {
1095
1184
  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) &&
1185
+ // Typed rest occupies the final native array parameter; its thunk
1186
+ // checks a fresh array containing all remaining call arguments.
1187
+ // Island rest keeps its separate engine host-callback adapter.
1188
+ (t.rest !== true || t.restAbi === undefined ||
1189
+ (t.restAbi === "typed" && t.params.at(-1)?.kind === "array")) &&
1100
1190
  // A jsval (island) param converts through scr_jsval_from_dyn in the
1101
1191
  // thunk (wrapped cells unwrap by reference, dyn data deep-copies) —
1102
1192
  // the checker-'any' callback params of the routed-dispatch lane
@@ -1113,10 +1203,9 @@ export function canBoxFuncIntoDyn(t, getRecord, getUnion) {
1113
1203
  * result). */
1114
1204
  export function canAdaptDynFuncTo(t, getRecord, getUnion) {
1115
1205
  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 &&
1206
+ // Checked rest and arguments packs retain all actual arguments. Typed
1207
+ // and island rest ABIs still require their own conversion plan.
1208
+ (t.rest !== true || t.restAbi === undefined) &&
1120
1209
  t.params.every((p) => p.kind === "dyn" || canConvertToDyn(p, getRecord, getUnion)) &&
1121
1210
  (t.ret.kind === "void" || t.ret.kind === "dyn" || canDynCheckTo(t.ret, getRecord, getUnion)));
1122
1211
  }
@@ -1177,130 +1266,224 @@ export function canExitIslandToType(t, getRecord, getUnion) {
1177
1266
  }
1178
1267
  return false;
1179
1268
  }
1269
+ const DYN_ASYNC_LIB_FNS = new Set([
1270
+ "async.awaitDyn", "timers.immediatePromise",
1271
+ "process.onUncaughtException", "process.offUncaughtException",
1272
+ "process.onUnhandledRejection", "process.offUnhandledRejection",
1273
+ "process.onRejectionHandled", "process.offRejectionHandled",
1274
+ "process.onWarning", "process.offWarning", "process.emitWarning",
1275
+ "als.new", "als.get", "als.run", "als.exitRun", "als.enterWith", "als.disable",
1276
+ "dc.chanBindStore", "dc.chanUnbindStore", "dc.chanRunStores",
1277
+ ]);
1278
+ /** Inspect types and expressions together in one traversal. This is a fresh
1279
+ * snapshot: callers may mutate an IR module between compilation passes. */
1280
+ export function moduleRuntimeFeatures(mod) {
1281
+ return scanRuntimeFeatures(mod);
1282
+ }
1283
+ function scanRuntimeFeatures(mod, stopAt) {
1284
+ const features = {
1285
+ regex: false, copying: false, legacyTextDecoder: false, fileHandle: false,
1286
+ fetch: mod.embedded?.modules.some((m) => m.usesFetch === true) ?? false,
1287
+ processEvents: false, emitter: (mod.classes ?? []).some((c) => c.name === RUNTIME_EMITTER_CLASS),
1288
+ stream: (mod.classes ?? []).some((c) => RUNTIME_STREAM_CLASSES.has(c.name)),
1289
+ zlib: mod.embedded?.edges.some((e) => e.to === "node:zlib") ?? false,
1290
+ dc: false, assert: false, dynInvoke: false, dynAsync: false, inspect: false,
1291
+ childProcess: false, net: false, symbol: false, bigint: false, searchParams: false,
1292
+ qs: false, parseArgs: false, fsWatch: false, nodeTest: false, dgram: false,
1293
+ http: false, http2: false, tls: false, tlsCa: false,
1294
+ };
1295
+ const keepGoing = () => stopAt === undefined || !features[stopAt];
1296
+ const expr = (node) => {
1297
+ if (node.kind === "libCall") {
1298
+ const fn = node.fn;
1299
+ if (fn === "regexp.escape" || fn === "dyn.nativeRegexIs")
1300
+ features.regex = true;
1301
+ if (fn === "text.decodeLegacy")
1302
+ features.legacyTextDecoder = true;
1303
+ if (fn.startsWith("fetch."))
1304
+ features.fetch = true;
1305
+ if (PROCESS_EVENT_LIB_FNS.has(fn))
1306
+ features.processEvents = true;
1307
+ if (fn.startsWith("emitter."))
1308
+ features.emitter = true;
1309
+ if (fn.startsWith("readable.") || fn.startsWith("writable.") || fn.startsWith("duplex.") ||
1310
+ fn.startsWith("transform.") || fn.startsWith("passthrough.") || fn.startsWith("sc.") ||
1311
+ fn.startsWith("stream.set") || fn === "stream.destroy" || fn === "stream.destroyErr" ||
1312
+ fn === "stream.prop" || fn === "stream.errored" || fn === "sp.finished" || fn === "sp.pipeline")
1313
+ features.stream = true;
1314
+ if (fn.startsWith("zlib."))
1315
+ features.zlib = true;
1316
+ if (fn.startsWith("dc."))
1317
+ features.dc = true;
1318
+ if (fn.startsWith("assert."))
1319
+ features.assert = true;
1320
+ if (fn === "dyn.defineProps" || fn === "dyn.defineProperty" || fn === "dyn.objCreateWithProperties" || fn === "dyn.arrayProtoCall" || fn === "dyn.arrayPrototype")
1321
+ features.dynInvoke = true;
1322
+ if (DYN_ASYNC_LIB_FNS.has(fn))
1323
+ features.dynAsync = true;
1324
+ if (fn.startsWith("insp.") || fn === "console.native" || fn === "global.native")
1325
+ features.inspect = true;
1326
+ if (fn.startsWith("cp.") || fn.startsWith("child.") || fn.startsWith("writer.") || fn.startsWith("spawnRes.") ||
1327
+ fn === "process.forkTarget" || fn === "process.connected" || fn === "process.send" || fn === "process.sendCb" ||
1328
+ fn === "process.disconnect" || fn === "process.onMessage" || fn === "process.onDisconnect")
1329
+ features.childProcess = true;
1330
+ if (fn.startsWith("net."))
1331
+ features.net = true;
1332
+ if (fn.startsWith("http.")) {
1333
+ features.net = true;
1334
+ features.http = true;
1335
+ }
1336
+ if (fn.startsWith("tls.") || fn.startsWith("https.") || fn.startsWith("http2.")) {
1337
+ features.net = true;
1338
+ features.http = true;
1339
+ features.tls = true;
1340
+ }
1341
+ if (fn.startsWith("http2.") && !HTTP2_LEGACY_FNS.has(fn))
1342
+ features.http2 = true;
1343
+ if (fn.startsWith("sym."))
1344
+ features.symbol = true;
1345
+ if (fn === "process.hrtimeValue")
1346
+ features.bigint = true;
1347
+ if (fn.startsWith("bigint."))
1348
+ features.bigint = true;
1349
+ if (fn.startsWith("sp.") || fn === "url.searchParams")
1350
+ features.searchParams = true;
1351
+ if (fn === "qs.parse" || fn === "qs.stringify" || fn === "qs.unescape")
1352
+ features.qs = true;
1353
+ if (fn === "util.parseArgs")
1354
+ features.parseArgs = true;
1355
+ if (fn.startsWith("fs.watch") || fn.startsWith("watcher."))
1356
+ features.fsWatch = true;
1357
+ if (fn.startsWith("test."))
1358
+ features.nodeTest = true;
1359
+ if (fn.startsWith("dgram.") || fn.startsWith("dns."))
1360
+ features.dgram = true;
1361
+ if (fn.startsWith("tlsca."))
1362
+ features.tlsCa = true;
1363
+ }
1364
+ else {
1365
+ switch (node.kind) {
1366
+ case "regexLit":
1367
+ case "regexIntrinsic":
1368
+ features.regex = true;
1369
+ break;
1370
+ case "strIntrinsic":
1371
+ if (node.method === "toLowerCase" || node.method === "toUpperCase")
1372
+ features.regex = true;
1373
+ break;
1374
+ case "arrIntrinsic":
1375
+ if (node.method === "toReversed" || node.method === "toSpliced" || node.method === "with" || node.method === "withUndefined")
1376
+ features.copying = true;
1377
+ break;
1378
+ case "bytesIntrinsic":
1379
+ if (node.method === "toReversed" || node.method === "with" || node.method === "join" || node.method === "toArray")
1380
+ features.copying = true;
1381
+ break;
1382
+ case "jsOp":
1383
+ if (node.op === "globalGet" && node.name === "fetch")
1384
+ features.fetch = true;
1385
+ break;
1386
+ case "dynInvoke":
1387
+ features.dynInvoke = true;
1388
+ break;
1389
+ case "awaitExpr":
1390
+ if (node.type.kind === "dyn")
1391
+ features.dynAsync = true;
1392
+ break;
1393
+ case "dynFrom": {
1394
+ const boxed = node.value.type;
1395
+ if (boxed.kind === "promise" || (boxed.kind === "func" && boxed.ret.kind === "promise"))
1396
+ features.dynAsync = true;
1397
+ break;
1398
+ }
1399
+ }
1400
+ }
1401
+ return keepGoing();
1402
+ };
1403
+ const type = (node) => {
1404
+ switch (node.kind) {
1405
+ case "regex":
1406
+ features.regex = true;
1407
+ break;
1408
+ case "fileHandle":
1409
+ features.fileHandle = true;
1410
+ break;
1411
+ case "child":
1412
+ case "childStream":
1413
+ case "childWriter":
1414
+ case "spawnRes":
1415
+ features.childProcess = true;
1416
+ break;
1417
+ case "netServer":
1418
+ case "netSocket":
1419
+ features.net = true;
1420
+ break;
1421
+ case "http2Session":
1422
+ case "http2Stream":
1423
+ features.net = true;
1424
+ features.http2 = true;
1425
+ break;
1426
+ case "httpReq":
1427
+ case "httpRes":
1428
+ case "httpClientReq":
1429
+ features.net = true;
1430
+ features.http = true;
1431
+ break;
1432
+ case "secureCtx":
1433
+ features.net = true;
1434
+ features.http = true;
1435
+ features.tls = true;
1436
+ break;
1437
+ case "symbol":
1438
+ features.symbol = true;
1439
+ break;
1440
+ case "bigint":
1441
+ features.bigint = true;
1442
+ break;
1443
+ case "searchParams":
1444
+ features.searchParams = true;
1445
+ break;
1446
+ case "fsWatcher":
1447
+ features.fsWatch = true;
1448
+ break;
1449
+ case "testCtx":
1450
+ features.nodeTest = true;
1451
+ break;
1452
+ case "dgramSocket":
1453
+ features.dgram = true;
1454
+ break;
1455
+ }
1456
+ return keepGoing();
1457
+ };
1458
+ if (keepGoing())
1459
+ everyModuleNode(mod, { expr, stmt: keepGoing, type });
1460
+ return features;
1461
+ }
1180
1462
  /** True when the module contains any regex construct — a regexLit /
1181
1463
  * regexIntrinsic node or a regex-typed slot anywhere. This is the link
1182
1464
  * 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. */
1465
+ * (native-toolchain.ts); regex-free programs keep the historical command line. The
1466
+ * typed traversal visits type slots as well as executable nodes. */
1186
1467
  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;
1468
+ return scanRuntimeFeatures(mod, "regex").regex;
1221
1469
  }
1222
1470
  /** True when the module contains an intrinsic whose implementation lives
1223
1471
  * in scr_copying.c. This is the link switch that keeps the optional
1224
1472
  * Array-copying and typed-array bridge TU out of unrelated binaries. */
1225
1473
  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;
1474
+ return scanRuntimeFeatures(mod, "copying").copying;
1257
1475
  }
1258
1476
  /** True when a non-UTF-8 TextDecoder call survives lowering. This gates the
1259
1477
  * generated legacy mapping tables inside scr_bytes.c; the default UTF-8
1260
1478
  * decoder and unrelated Buffer users keep their prior runtime object. */
1261
1479
  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;
1480
+ return scanRuntimeFeatures(mod, "legacyTextDecoder").legacyTextDecoder;
1281
1481
  }
1282
1482
  /** True when a FileHandle type survives in the module. This is the link
1283
1483
  * switch for scr_file_handle.c; fs/promises.open carries the type inside its
1284
1484
  * promise result even when no handle method is called. */
1285
1485
  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;
1486
+ return scanRuntimeFeatures(mod, "fileHandle").fileHandle;
1304
1487
  }
1305
1488
  /** True when user code lowers static fetch or the embedded npm graph
1306
1489
  * reaches the engine's global fetch — the link switch that pulls scr_fetch.c +
@@ -1310,35 +1493,12 @@ export function moduleUsesFileHandle(mod) {
1310
1493
  * and local `fetch` bindings do not change the link or target capability.
1311
1494
  * Fetch-free graphs keep their exact historical link lines. */
1312
1495
  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;
1496
+ return scanRuntimeFeatures(mod, "fetch").fetch;
1338
1497
  }
1339
1498
  /** The libCall fns served by the OPTIONAL events unit (scr_events.c):
1340
1499
  * process signal/exit listeners and the piped-stdin surface. */
1341
1500
  const PROCESS_EVENT_LIB_FNS = new Set([
1501
+ "process.stdio",
1342
1502
  "process.onSignal",
1343
1503
  "process.offSignal",
1344
1504
  "process.onExit",
@@ -1360,25 +1520,7 @@ const PROCESS_EVENT_LIB_FNS = new Set([
1360
1520
  * gating precedent). Event-free programs pay zero bytes and keep their
1361
1521
  * exact link line. Same generic-walk shape as moduleUsesRegex. */
1362
1522
  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;
1523
+ return scanRuntimeFeatures(mod, "processEvents").processEvents;
1382
1524
  }
1383
1525
  /** True when the module uses the node:events EventEmitter surface — the
1384
1526
  * link switch that pulls scr_events_emitter.c into the binary (native-toolchain.ts; the
@@ -1390,27 +1532,7 @@ export function moduleUsesProcessEvents(mod) {
1390
1532
  * no emitter-typed value). Emitter-free programs pay zero bytes and keep
1391
1533
  * their exact link line. */
1392
1534
  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;
1535
+ return scanRuntimeFeatures(mod, "emitter").emitter;
1414
1536
  }
1415
1537
  /** True when the program touches the node:stream surface (scr_stream.c —
1416
1538
  * the moduleUsesEmitter story: the class defs ride the module whenever a
@@ -1420,36 +1542,7 @@ export function moduleUsesEmitter(mod) {
1420
1542
  * moduleUsesEmitter answers true whenever this does. Stream-free
1421
1543
  * programs pay zero bytes and keep their exact link line. */
1422
1544
  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;
1545
+ return scanRuntimeFeatures(mod, "stream").stream;
1453
1546
  }
1454
1547
  /** True when the embedded npm graph has an edge into `builtin` — the
1455
1548
  * island shim needs the corresponding native bridge linked (zlib's is
@@ -1458,7 +1551,7 @@ export function moduleEmbedsBuiltin(mod, builtin) {
1458
1551
  return mod.embedded !== undefined && mod.embedded.edges.some((e) => e.to === builtin);
1459
1552
  }
1460
1553
  /** Embedded module texts at least this long are DEFLATE-compressed into
1461
- * the emitted C (island.ts; each stays plain when deflate does not
1554
+ * the emitted LLVM (island.ts; each stays plain when deflate does not
1462
1555
  * shrink it) and inflated lazily by the island's module loader at first
1463
1556
  * load. Below it the zlib round trip cannot pay for itself. */
1464
1557
  export const NPM_COMPRESS_MIN = 1024;
@@ -1478,52 +1571,14 @@ export function moduleEmbedsCompressedNpm(mod) {
1478
1571
  * generic-walk shape as moduleUsesRegex: `kind`/`fn` discriminants live
1479
1572
  * only on IR objects. */
1480
1573
  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;
1574
+ return scanRuntimeFeatures(mod, "zlib").zlib;
1502
1575
  }
1503
1576
  /** True when the module contains any dc.* libCall — the link switch that
1504
1577
  * pulls scr_dc.c (the diagnostics_channel registry and pub/sub) into the
1505
1578
  * binary (native-toolchain.ts). Channel-free binaries keep their exact size class.
1506
1579
  * Same walk shape as moduleUsesZlib. */
1507
1580
  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;
1581
+ return scanRuntimeFeatures(mod, "dc").dc;
1527
1582
  }
1528
1583
  /** True when the module contains any assert libCall — the link switch
1529
1584
  * that pulls scr_assert.c into the binary (native-toolchain.ts). scr_regex.c calls the
@@ -1532,25 +1587,7 @@ export function moduleUsesDc(mod) {
1532
1587
  * the historical command line and size. Same walk shape as
1533
1588
  * moduleUsesZlib. */
1534
1589
  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;
1590
+ return scanRuntimeFeatures(mod, "assert").assert;
1554
1591
  }
1555
1592
  /** True when the module contains any dynInvoke node or dyn.defineProps
1556
1593
  * libCall — the link switch that pulls scr_dyn_invoke.c (the prototype-
@@ -1559,25 +1596,7 @@ export function moduleUsesAssert(mod) {
1559
1596
  * precedent — dispatch-free binaries keep their exact size class). Same
1560
1597
  * walk shape as moduleUsesZlib. */
1561
1598
  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;
1599
+ return scanRuntimeFeatures(mod, "dynInvoke").dynInvoke;
1581
1600
  }
1582
1601
  /** True when the module contains any insp libCall — the link switch that
1583
1602
  * pulls scr_inspect.c into the binary (native-toolchain.ts; the assert gating
@@ -1590,96 +1609,16 @@ export function moduleUsesDynInvoke(mod) {
1590
1609
  * dynInvoke and dc gates (their TUs call into this one) — native-toolchain.ts. Same
1591
1610
  * walk shape as moduleUsesZlib. */
1592
1611
  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;
1612
+ return scanRuntimeFeatures(mod, "dynAsync").dynAsync;
1629
1613
  }
1630
1614
  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;
1615
+ return scanRuntimeFeatures(mod, "inspect").inspect;
1650
1616
  }
1651
1617
  /** True when the module reaches child_process or carries one of its runtime
1652
1618
  * handle/result types. Besides the existing link consequence, this gates the
1653
1619
  * checked-dynamic ChildProcess handle table installed from scr_child.c. */
1654
1620
  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;
1621
+ return scanRuntimeFeatures(mod, "childProcess").childProcess;
1683
1622
  }
1684
1623
  /** True when the module contains any net libCall — the link switch that
1685
1624
  * pulls scr_net.c into the binary and has the emitted main call
@@ -1687,42 +1626,7 @@ export function moduleUsesChildProcess(mod) {
1687
1626
  * Net-free programs pay zero bytes and keep their exact link line. Same
1688
1627
  * generic-walk shape as moduleUsesZlib. */
1689
1628
  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;
1629
+ return scanRuntimeFeatures(mod, "net").net;
1726
1630
  }
1727
1631
  /** True when the module contains any sym.* libCall or a symbol-kind type
1728
1632
  * anywhere in the IR — the link switch that pulls scr_symbol.c into the
@@ -1732,54 +1636,13 @@ export function moduleUsesNet(mod) {
1732
1636
  * fence still emits release calls that need the unit linked. Symbol-free
1733
1637
  * programs pay zero bytes and keep their exact link line. */
1734
1638
  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;
1639
+ return scanRuntimeFeatures(mod, "symbol").symbol;
1758
1640
  }
1759
1641
  /** True when bigint runtime operations or bigint-typed storage appears in
1760
1642
  * the IR. The type check keeps retain/release references link-safe even
1761
1643
  * when a producing statement was replaced by a runtime fence. */
1762
1644
  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;
1645
+ return scanRuntimeFeatures(mod, "bigint").bigint;
1783
1646
  }
1784
1647
  /** True when the module uses the URLSearchParams surface — sp.* libCalls,
1785
1648
  * the url.searchParams getter, or a searchParams-kind type anywhere on
@@ -1790,30 +1653,7 @@ export function moduleUsesBigInt(mod) {
1790
1653
  * programs keep their exact link line; scr_url.c itself stays
1791
1654
  * always-linked and never references the unit. */
1792
1655
  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;
1656
+ return scanRuntimeFeatures(mod, "searchParams").searchParams;
1817
1657
  }
1818
1658
  /** True when the module uses the node:querystring surface — the qs.*
1819
1659
  * libCalls that live in scr_qs.c (parse/stringify/unescape; qs.escape
@@ -1823,50 +1663,13 @@ export function moduleUsesSearchParams(mod) {
1823
1663
  * loop hooks, cross-compiles everywhere). qs-free programs keep their
1824
1664
  * exact link line. Same generic-walk shape as moduleUsesZlib. */
1825
1665
  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;
1666
+ return scanRuntimeFeatures(mod, "qs").qs;
1846
1667
  }
1847
1668
  /** True when the module uses native util.parseArgs — the link switch for
1848
1669
  * scr_util.c. The implementation is a pure checked-dynamic data transform,
1849
1670
  * cross-platform and independent of the island's node:util shim. */
1850
1671
  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;
1672
+ return scanRuntimeFeatures(mod, "parseArgs").parseArgs;
1870
1673
  }
1871
1674
  /** True when the module contains any fs.watch/watcher.* libCall — the
1872
1675
  * link switch that pulls scr_watch.c into the binary and has the emitted
@@ -1874,32 +1677,7 @@ export function moduleUsesParseArgs(mod) {
1874
1677
  * precedent). Watch-free programs pay zero bytes and keep their exact
1875
1678
  * link line. Same generic-walk shape as moduleUsesZlib. */
1876
1679
  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;
1680
+ return scanRuntimeFeatures(mod, "fsWatch").fsWatch;
1903
1681
  }
1904
1682
  /** True when the module contains any test.* libCall or a testCtx handle
1905
1683
  * type — the link switch that pulls scr_test.c into the binary and has
@@ -1907,31 +1685,7 @@ export function moduleUsesFsWatch(mod) {
1907
1685
  * (native-toolchain.ts + emitter; the moduleUsesDgram shape). Test-free programs pay
1908
1686
  * zero bytes and keep their exact link line. */
1909
1687
  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;
1688
+ return scanRuntimeFeatures(mod, "nodeTest").nodeTest;
1935
1689
  }
1936
1690
  /** True when the module contains any dgram.* or dns.* libCall — the
1937
1691
  * link switch that pulls scr_dgram.c into the binary and has the emitted
@@ -1940,69 +1694,13 @@ export function moduleUsesNodeTest(mod) {
1940
1694
  * answers). Dgram-free programs pay zero bytes and keep their exact link
1941
1695
  * line. Same generic-walk shape as moduleUsesZlib. */
1942
1696
  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;
1697
+ return scanRuntimeFeatures(mod, "dgram").dgram;
1969
1698
  }
1970
1699
  /** True when the module contains any http.* libCall — the link switch
1971
1700
  * that pulls scr_http.c into the binary (native-toolchain.ts; moduleUsesNet already
1972
1701
  * answers true for these, so scr_net.c comes along). */
1973
1702
  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;
1703
+ return scanRuntimeFeatures(mod, "http").http;
2006
1704
  }
2007
1705
  /** The legacy http2.* libCalls implemented by scr_http.c/scr_tls.c (the
2008
1706
  * allowHTTP1 compatibility slice) — they must NOT pull scr_http2.c, so
@@ -2014,30 +1712,7 @@ const HTTP2_LEGACY_FNS = new Set([
2014
1712
  * http2.* libCall, or an h2 handle type left behind by a fenced statement
2015
1713
  * (its emitted release call needs the unit — the moduleUsesNet story). */
2016
1714
  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;
1715
+ return scanRuntimeFeatures(mod, "http2").http2;
2041
1716
  }
2042
1717
  /** True when the module contains any tls.* or https.* libCall — the link
2043
1718
  * switch that pulls scr_tls.c and the vendored mbedTLS archive into the
@@ -2045,33 +1720,7 @@ export function moduleUsesHttp2(mod) {
2045
1720
  * true for these, so scr_net.c and scr_http.c come along). TLS-free
2046
1721
  * programs keep their exact link line and never build mbedTLS. */
2047
1722
  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;
1723
+ return scanRuntimeFeatures(mod, "tls").tls;
2075
1724
  }
2076
1725
  /** True when the module contains any tlsca.* libCall — the link switch
2077
1726
  * for scr_tls_ca.c, the CA-store introspection unit (getCACertificates /
@@ -2081,25 +1730,7 @@ export function moduleUsesTls(mod) {
2081
1730
  * also compiles the unit whenever TLS itself links — scr_tls.c consults
2082
1731
  * the unit's default-set override for its trust anchors. */
2083
1732
  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;
1733
+ return scanRuntimeFeatures(mod, "tlsCa").tlsCa;
2103
1734
  }
2104
1735
  /* ── library mode's async_free gate ──────────────────────────────────────
2105
1736
  * v1 library mode REQUIRES an async_free module graph (ratified): no async
@@ -2156,10 +1787,6 @@ const LIB_MODE_REFUSED_PREFIXES = [
2156
1787
  ["als.", "AsyncLocalStorage"],
2157
1788
  ["urj.", "unhandled-rejection tracking"],
2158
1789
  ["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
1790
  ];
2164
1791
  /** Value/type kinds whose mere presence means an excluded unit's code (or
2165
1792
  * a fiber) would have to link. */
@@ -2184,12 +1811,11 @@ const LIB_MODE_REFUSED_KINDS = new Map([
2184
1811
  ["httpRes", "the node:http surface"],
2185
1812
  ["httpClientReq", "the node:http surface"],
2186
1813
  ["secureCtx", "the node:tls surface"],
2187
- ["dynInvoke", "checked-dynamic prototype dispatch"],
2188
1814
  ]);
2189
1815
  /** First async/event-loop/ambient-process surface the module graph
2190
1816
  * 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
1817
+ * Typed slots use their declaration location and executable nodes use their
1818
+ * own location, so the refusal anchors at the reaching construct; the
2193
1819
  * coarse moduleUses* predicates are the safety net behind the fine-grained
2194
1820
  * table (a surface reached only through a spelling the table misses still
2195
1821
  * refuses, anchored at the entry). */
@@ -2203,54 +1829,49 @@ export function moduleLibAsyncSurface(mod) {
2203
1829
  }
2204
1830
  const entryLoc = { file: mod.sourceFile, start: 0, end: 0 };
2205
1831
  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") {
1832
+ const checkKind = (kind, loc) => {
1833
+ const surface = LIB_MODE_REFUSED_KINDS.get(kind);
1834
+ if (surface === undefined)
1835
+ return true;
1836
+ found = { surface, loc };
1837
+ return false;
1838
+ };
1839
+ everyModuleNode(mod, {
1840
+ type: (node, loc) => checkKind(node.kind, loc),
1841
+ stmt: () => true,
1842
+ expr: (node) => {
1843
+ if (!checkKind(node.kind, node.loc))
1844
+ return false;
1845
+ if (node.kind === "libCall") {
2223
1846
  for (const [prefix, surface] of LIB_MODE_REFUSED_PREFIXES) {
2224
1847
  if (node.fn.startsWith(prefix)) {
2225
- found = { surface, loc: here };
2226
- return;
1848
+ found = { surface, loc: node.loc };
1849
+ return false;
2227
1850
  }
2228
1851
  }
2229
1852
  }
2230
- }
2231
- for (const key of Object.keys(v))
2232
- visit(v[key], here);
2233
- };
2234
- visit(mod, entryLoc);
1853
+ return true;
1854
+ },
1855
+ });
2235
1856
  if (found !== null)
2236
1857
  return found;
2237
1858
  // Safety net: the coarse unit predicates, entry-anchored. Every one of
2238
1859
  // these units is excluded from library links, so a true answer that the
2239
1860
  // fine-grained table missed must still refuse.
1861
+ const features = moduleRuntimeFeatures(mod);
2240
1862
  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"],
1863
+ [features.processEvents, "process signal/exit listeners or the stdin event surface"],
1864
+ [features.net, "the node:net surface"],
1865
+ [features.http, "the node:http surface"],
1866
+ [features.http2, "the node:http2 surface"],
1867
+ [features.dgram, "the node:dgram surface"],
1868
+ [features.fsWatch, "fs.watch"],
1869
+ [features.stream, "the node:stream surface"],
1870
+ [features.tls, "the node:tls surface"],
1871
+ [features.fetch, "fetch"],
1872
+ [features.nodeTest, "the node:test surface"],
1873
+ [features.dynAsync, "the checked-dynamic async surface"],
1874
+ [features.dc, "the diagnostics_channel surface"],
2254
1875
  ];
2255
1876
  for (const [on, surface] of coarse) {
2256
1877
  if (on)
@@ -2321,27 +1942,22 @@ export const LIB_NONDETERMINISTIC_PREFIXES = [
2321
1942
  * attests `deterministic: true`). */
2322
1943
  export function moduleLibNondeterministicSurface(mod) {
2323
1944
  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") {
1945
+ const expr = (node) => {
1946
+ if (node.kind === "libCall") {
2334
1947
  for (const [prefix, surface] of LIB_NONDETERMINISTIC_PREFIXES) {
2335
1948
  if (node.fn.startsWith(prefix)) {
2336
1949
  found = surface;
2337
- return;
1950
+ return false;
2338
1951
  }
2339
1952
  }
2340
1953
  }
2341
- for (const key of Object.keys(v))
2342
- visit(v[key]);
1954
+ return everyExprChild(node, expr, stmt);
2343
1955
  };
2344
- visit(mod);
1956
+ const stmt = (node) => everyStmtChild(node, expr, stmt);
1957
+ for (const fn of mod.functions) {
1958
+ if (!fn.body.every(stmt))
1959
+ break;
1960
+ }
2345
1961
  return found;
2346
1962
  }
2347
1963
  /** The may-throw seed: libCall members that can raise. Every fs.* member
@@ -2352,6 +1968,29 @@ export function moduleLibNondeterministicSurface(mod) {
2352
1968
  * seed on `dynCheck` and `awaitExpr` nodes, which throw on validation
2353
1969
  * failure / promise rejection). */
2354
1970
  export const MAY_THROW_LIB_FNS = new Set([
1971
+ "dyn.nativeSetNew",
1972
+ "ffi.argument",
1973
+ "ffi.memoryModule",
1974
+ "process.stdoutWrite",
1975
+ "process.stderrWrite",
1976
+ "process.stdoutWriteBytes",
1977
+ "process.stderrWriteBytes",
1978
+ "procStream.write",
1979
+ "weakMap.new",
1980
+ "weakSet.new",
1981
+ "dyn.fromEntries",
1982
+ "arrayBuffer.new",
1983
+ "arrayBuffer.byteLengthGetter",
1984
+ "arrayBuffer.viewU8C",
1985
+ "arrayBuffer.viewI8",
1986
+ "arrayBuffer.viewU16",
1987
+ "arrayBuffer.viewI16",
1988
+ "arrayBuffer.viewU8",
1989
+ "arrayBuffer.viewU32",
1990
+ "arrayBuffer.viewI32",
1991
+ "arrayBuffer.viewF32",
1992
+ "arrayBuffer.viewF64",
1993
+ "arrayBuffer.viewDV",
2355
1994
  "bigint.parse",
2356
1995
  "bigint.fromF64",
2357
1996
  "bigint.div",
@@ -2387,6 +2026,10 @@ export const MAY_THROW_LIB_FNS = new Set([
2387
2026
  "dc.tcTraceSync",
2388
2027
  "dc.tcTraceCallback",
2389
2028
  "dc.tcTracePromise",
2029
+ "process.onUncaughtException",
2030
+ "process.offUncaughtException",
2031
+ "process.onSignal",
2032
+ "process.offSignal",
2390
2033
  "process.onUnhandledRejection",
2391
2034
  "process.onRejectionHandled",
2392
2035
  "async.awaitDyn",
@@ -2567,9 +2210,27 @@ export const MAY_THROW_LIB_FNS = new Set([
2567
2210
  "error.nodeThrow",
2568
2211
  // USVString coercion runs user toString/valueOf — throws propagate.
2569
2212
  "dyn.toStringCoerce",
2213
+ "dyn.stringConstructor",
2214
+ "dyn.propertyKey",
2215
+ "dyn.toNumeric",
2216
+ "dyn.increment",
2217
+ // Error messages use the same coercion protocol before installing cause.
2218
+ "error.newOptions",
2219
+ "error.ctorOptions",
2220
+ "error.cause",
2221
+ "error.setCause",
2222
+ "error.deleteCause",
2570
2223
  "dyn.objectTag",
2571
2224
  // Numeric coercion runs user valueOf/toString — throws propagate.
2225
+ "dyn.numberConstructor",
2572
2226
  "dyn.toNumberCoerce",
2227
+ "dyn.add",
2228
+ "dyn.arithmetic",
2229
+ "dyn.bitwise",
2230
+ "dyn.proxyNew",
2231
+ "dyn.classBasePrototype",
2232
+ "dyn.classSuper",
2233
+ "dyn.hasKey",
2573
2234
  "child.kill",
2574
2235
  // The caller's lookup runs synchronously inside the connect call — a
2575
2236
  // throw there propagates like Node's.
@@ -2604,6 +2265,11 @@ export const MAY_THROW_LIB_FNS = new Set([
2604
2265
  "island.import",
2605
2266
  "island.castFail",
2606
2267
  "json.parse",
2268
+ "json.parseReviver",
2269
+ "json.stringifyReplacer",
2270
+ "json.stringifyValue",
2271
+ "date.nativeNew",
2272
+ "date.checkedValue",
2607
2273
  "util.parseArgs",
2608
2274
  // decodeURIComponent throws the spec's URIError on bad hex/invalid
2609
2275
  // UTF-8 octets (encodeURIComponent never throws — see the IrLibFn doc).
@@ -2627,26 +2293,62 @@ export const MAY_THROW_LIB_FNS = new Set([
2627
2293
  "dyn.cloneTransferFail",
2628
2294
  // the dyn Object walks throw on null/undefined receivers
2629
2295
  "dyn.objKeys",
2296
+ "dyn.forInKeys",
2630
2297
  "dyn.hasOwn",
2298
+ "dyn.propertyIsEnumerable",
2631
2299
  "dyn.assign",
2300
+ "dyn.copyDataProperties",
2632
2301
  // variadic Object.assign: spread flattening throws V8's spread-call
2633
2302
  // TypeErrors; the final copy throws ToObject on a nullish target
2634
2303
  "dyn.packPushSpread",
2635
2304
  "dyn.packPushSpreadIter",
2636
2305
  "dyn.assignAll",
2306
+ "dyn.objCreate",
2307
+ "dyn.objCreateWithProperties",
2308
+ "dyn.getPrototype",
2309
+ "dyn.setPrototype",
2310
+ "dyn.getOwnPropertyNames",
2311
+ "dyn.getOwnPropertySymbols",
2312
+ "dyn.getOwnPropertyDescriptors",
2313
+ "dyn.preventExtensions",
2314
+ "dyn.isExtensible",
2315
+ "dyn.seal",
2316
+ "dyn.isSealed",
2637
2317
  "dyn.objValues",
2638
2318
  "dyn.objEntries",
2639
2319
  "error.domClone",
2640
2320
  // new RegExp compiles the pattern eagerly: an invalid pattern or flag
2641
2321
  // throws Node's catchable SyntaxError at construction.
2642
2322
  "regex.new",
2323
+ "regex.newChecked",
2643
2324
  "dyn.keySet",
2325
+ "dyn.keySetComputed",
2326
+ "process.builtinId",
2327
+ "process.builtinModule",
2328
+ "process.builtinUnsupported",
2329
+ "dyn.keyDelete",
2330
+ "dyn.keyDeleteComputed",
2331
+ "dyn.hasKeyComputed",
2332
+ "dyn.hasOwnComputed",
2333
+ "dyn.propertyIsEnumerableComputed",
2644
2334
  // the destructuring pack throws V8's TypeError on non-iterable dyn kinds
2645
2335
  "dyn.iterPack",
2336
+ "dyn.arrayFromIterator",
2337
+ "dyn.iterator",
2338
+ "dyn.iteratorResult",
2339
+ "dyn.mapSeedEntries",
2340
+ "dyn.mapSeedEntry",
2341
+ "dyn.freeze",
2342
+ "dyn.isFrozen",
2646
2343
  "dyn.toString",
2344
+ "string.fromCodePoint",
2647
2345
  "dyn.defineProps",
2346
+ "dyn.defineProperty",
2347
+ "dyn.getOwnPropertyDescriptor",
2348
+ "dyn.arrayProtoCall",
2648
2349
  "process.chdir",
2649
2350
  "fs.realpathSync",
2351
+ "fs.realpathNativeSync",
2650
2352
  "fs.readFileSync",
2651
2353
  "fs.writeFileSync",
2652
2354
  "fs.appendFileSync",
@@ -2656,13 +2358,16 @@ export const MAY_THROW_LIB_FNS = new Set([
2656
2358
  "fs.readdirSync",
2657
2359
  "fs.readdirTypesSync",
2658
2360
  "url.new",
2361
+ "url.newBase",
2659
2362
  "url.fileURLToPathUrl",
2363
+ "url.fileURLToPathChecked",
2660
2364
  "url.fileURLToPathStr",
2661
2365
  // The win32-target flavor of pathToFileURL (same runtime entry point —
2662
2366
  // the bridge dispatches by the binary's platform): Node's win32 arm
2663
2367
  // raises ERR_INVALID_ARG_VALUE TypeErrors for malformed UNC inputs, so
2664
2368
  // only THIS flavor seeds may-throw — posix emission stays untouched.
2665
2369
  "url.pathToFileURLWin32",
2370
+ "url.pathToFileURLPlatform",
2666
2371
  // URLSearchParams from a string[][]: Node's ERR_INVALID_TUPLE TypeError
2667
2372
  // on a row that is not a [name, value] pair. The rest of the sp family
2668
2373
  // never throws.
@@ -2693,6 +2398,7 @@ export const MAY_THROW_LIB_FNS = new Set([
2693
2398
  "crypto.pbkdf2Cb",
2694
2399
  "buffer.concat",
2695
2400
  "buffer.concatLen",
2401
+ "buffer.fromDyn",
2696
2402
  // The checked-dynamic compare/equals validators: Node's argument
2697
2403
  // ladders throw ERR_INVALID_ARG_TYPE / ERR_OUT_OF_RANGE catchably.
2698
2404
  "buffer.compareChk",
@@ -2720,6 +2426,7 @@ export const MAY_THROW_LIB_FNS = new Set([
2720
2426
  "emitter.setDefaultMaxChk",
2721
2427
  "fs.readFileSyncBytes",
2722
2428
  "fs.writeFileSyncBytes",
2429
+ "fs.appendFileSyncBytes",
2723
2430
  "zlib.inflateSync",
2724
2431
  "zlib.inflateRawSync",
2725
2432
  "zlib.gunzipSync",