@scriptc/compiler 0.4.8 → 0.4.9

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 (536) hide show
  1. package/ambient/node-fallback/buffer.d.ts +2 -0
  2. package/ambient/node-fallback/child_process.d.ts +9 -3
  3. package/ambient/node-fallback/dns-promises.d.ts +25 -0
  4. package/ambient/node-fallback/dns.d.ts +29 -0
  5. package/ambient/node-fallback/test.d.ts +7 -0
  6. package/ambient/scriptc-node-fallback.d.ts +145 -2
  7. package/ambient/scriptc-overrides.d.ts +22 -13
  8. package/dist/backend/build-cache.d.ts +1 -1
  9. package/dist/backend/build-cache.js +1 -1
  10. package/dist/backend/build-cache.js.map +1 -1
  11. package/dist/backend/cache-root.d.ts +7 -0
  12. package/dist/backend/cache-root.js +27 -0
  13. package/dist/backend/cache-root.js.map +1 -1
  14. package/dist/backend/executable-features.js +5 -1
  15. package/dist/backend/executable-features.js.map +1 -1
  16. package/dist/backend/link-plan.js +7 -1
  17. package/dist/backend/link-plan.js.map +1 -1
  18. package/dist/backend/llvm/bytes-loop-versions.d.ts +12 -1
  19. package/dist/backend/llvm/bytes-loop-versions.js +107 -30
  20. package/dist/backend/llvm/bytes-loop-versions.js.map +1 -1
  21. package/dist/backend/llvm/bytes-loop-versions.test.js +96 -0
  22. package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
  23. package/dist/backend/llvm/checked-value-lifetimes.js +1 -0
  24. package/dist/backend/llvm/checked-value-lifetimes.js.map +1 -1
  25. package/dist/backend/llvm/classes.d.ts +16 -5
  26. package/dist/backend/llvm/classes.js +34 -6
  27. package/dist/backend/llvm/classes.js.map +1 -1
  28. package/dist/backend/llvm/classes.test.js +21 -2
  29. package/dist/backend/llvm/classes.test.js.map +1 -1
  30. package/dist/backend/llvm/common.d.ts +9 -0
  31. package/dist/backend/llvm/common.js +9 -0
  32. package/dist/backend/llvm/common.js.map +1 -1
  33. package/dist/backend/llvm/cpu-dispatch.d.ts +36 -2
  34. package/dist/backend/llvm/cpu-dispatch.js +96 -2
  35. package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
  36. package/dist/backend/llvm/dense-array-access.d.ts +5 -2
  37. package/dist/backend/llvm/dense-array-access.js +16 -12
  38. package/dist/backend/llvm/dense-array-access.js.map +1 -1
  39. package/dist/backend/llvm/dense-array-access.test.js +3 -1
  40. package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
  41. package/dist/backend/llvm/dyn.d.ts +24 -0
  42. package/dist/backend/llvm/dyn.js +117 -3
  43. package/dist/backend/llvm/dyn.js.map +1 -1
  44. package/dist/backend/llvm/emit-function.js +6 -0
  45. package/dist/backend/llvm/emit-function.js.map +1 -1
  46. package/dist/backend/llvm/emit-journal.d.ts +1 -0
  47. package/dist/backend/llvm/emit-journal.js.map +1 -1
  48. package/dist/backend/llvm/emit-module.js +48 -5
  49. package/dist/backend/llvm/emit-module.js.map +1 -1
  50. package/dist/backend/llvm/emit-module.test.js +41 -0
  51. package/dist/backend/llvm/emit-module.test.js.map +1 -1
  52. package/dist/backend/llvm/emit-statements.js +11 -0
  53. package/dist/backend/llvm/emit-statements.js.map +1 -1
  54. package/dist/backend/llvm/emitter.d.ts +87 -7
  55. package/dist/backend/llvm/emitter.js +136 -15
  56. package/dist/backend/llvm/emitter.js.map +1 -1
  57. package/dist/backend/llvm/expr-async.js +28 -6
  58. package/dist/backend/llvm/expr-async.js.map +1 -1
  59. package/dist/backend/llvm/expr-containers.js +19 -5
  60. package/dist/backend/llvm/expr-containers.js.map +1 -1
  61. package/dist/backend/llvm/expr-dynamic.js +29 -1
  62. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  63. package/dist/backend/llvm/expr-primitives.js +104 -6
  64. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  65. package/dist/backend/llvm/expr-records.js +15 -1
  66. package/dist/backend/llvm/expr-records.js.map +1 -1
  67. package/dist/backend/llvm/expr-stream-bridges.js +53 -5
  68. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  69. package/dist/backend/llvm/inline-arrays.js +1 -1
  70. package/dist/backend/llvm/inline-arrays.js.map +1 -1
  71. package/dist/backend/llvm/js-ic.js +126 -2
  72. package/dist/backend/llvm/js-ic.js.map +1 -1
  73. package/dist/backend/llvm/lanes.d.ts +38 -0
  74. package/dist/backend/llvm/lanes.js +778 -0
  75. package/dist/backend/llvm/lanes.js.map +1 -0
  76. package/dist/backend/llvm/lanes.test.d.ts +1 -0
  77. package/dist/backend/llvm/lanes.test.js +402 -0
  78. package/dist/backend/llvm/lanes.test.js.map +1 -0
  79. package/dist/backend/llvm/lib-dispatch.js +9 -4
  80. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  81. package/dist/backend/llvm/lib-network.js +20 -0
  82. package/dist/backend/llvm/lib-network.js.map +1 -1
  83. package/dist/backend/llvm/lib-shared.js +27 -0
  84. package/dist/backend/llvm/lib-shared.js.map +1 -1
  85. package/dist/backend/llvm/lib-test.js +11 -0
  86. package/dist/backend/llvm/lib-test.js.map +1 -1
  87. package/dist/backend/llvm/local-array-reads.js +2 -2
  88. package/dist/backend/llvm/local-array-reads.js.map +1 -1
  89. package/dist/backend/llvm/map-number-lookup.js +8 -2
  90. package/dist/backend/llvm/map-number-lookup.js.map +1 -1
  91. package/dist/backend/llvm/nullable-unions.js +5 -2
  92. package/dist/backend/llvm/nullable-unions.js.map +1 -1
  93. package/dist/backend/llvm/publish.d.ts +3 -0
  94. package/dist/backend/llvm/publish.js +2 -2
  95. package/dist/backend/llvm/publish.js.map +1 -1
  96. package/dist/backend/llvm/reference-writes.js +1 -0
  97. package/dist/backend/llvm/reference-writes.js.map +1 -1
  98. package/dist/backend/llvm/region-groups.js +43 -4
  99. package/dist/backend/llvm/region-groups.js.map +1 -1
  100. package/dist/backend/llvm/region-groups.test.js +79 -0
  101. package/dist/backend/llvm/region-groups.test.js.map +1 -1
  102. package/dist/backend/llvm/runtime-registries.test.js +32 -1
  103. package/dist/backend/llvm/runtime-registries.test.js.map +1 -1
  104. package/dist/backend/llvm/shapes.js +10 -1
  105. package/dist/backend/llvm/shapes.js.map +1 -1
  106. package/dist/backend/llvm/string-reads.d.ts +1 -1
  107. package/dist/backend/llvm/string-reads.js +1 -1
  108. package/dist/backend/llvm/string-reads.js.map +1 -1
  109. package/dist/backend/llvm/unwind-abi.js +24 -2
  110. package/dist/backend/llvm/unwind-abi.js.map +1 -1
  111. package/dist/backend/llvm/unwind-abi.test.js +38 -0
  112. package/dist/backend/llvm/unwind-abi.test.js.map +1 -1
  113. package/dist/backend/llvm/walkers.d.ts +3 -0
  114. package/dist/backend/llvm/walkers.js +20 -2
  115. package/dist/backend/llvm/walkers.js.map +1 -1
  116. package/dist/backend/native/contracts.d.ts +15 -3
  117. package/dist/backend/native/executable.js +19 -5
  118. package/dist/backend/native/executable.js.map +1 -1
  119. package/dist/backend/native-codegen-core.d.ts +20 -0
  120. package/dist/backend/native-codegen-core.js +15 -0
  121. package/dist/backend/native-codegen-core.js.map +1 -1
  122. package/dist/backend/native-codegen.d.ts +5 -0
  123. package/dist/backend/native-codegen.js +62 -8
  124. package/dist/backend/native-codegen.js.map +1 -1
  125. package/dist/backend/native-codegen.test.js +48 -8
  126. package/dist/backend/native-codegen.test.js.map +1 -1
  127. package/dist/backend/native-link-info-core.d.ts +27 -3
  128. package/dist/backend/native-link-info-core.js.map +1 -1
  129. package/dist/backend/native-link-info.test.js +17 -1
  130. package/dist/backend/native-link-info.test.js.map +1 -1
  131. package/dist/backend/native-toolchain.d.ts +1 -1
  132. package/dist/backend/native-toolchain.js +1 -1
  133. package/dist/backend/native-toolchain.js.map +1 -1
  134. package/dist/backend/native-toolchain.test.js +14 -1
  135. package/dist/backend/native-toolchain.test.js.map +1 -1
  136. package/dist/backend/runtime-pack-core.d.ts +9 -3
  137. package/dist/backend/runtime-pack-core.js +6 -1
  138. package/dist/backend/runtime-pack-core.js.map +1 -1
  139. package/dist/backend/runtime-pack.test.js +32 -1
  140. package/dist/backend/runtime-pack.test.js.map +1 -1
  141. package/dist/backend/targets.d.ts +9 -1
  142. package/dist/backend/targets.js +11 -2
  143. package/dist/backend/targets.js.map +1 -1
  144. package/dist/backend/targets.test.js +6 -0
  145. package/dist/backend/targets.test.js.map +1 -1
  146. package/dist/cli/command.js +15 -1
  147. package/dist/cli/command.js.map +1 -1
  148. package/dist/cli/host.d.ts +6 -0
  149. package/dist/cli/mcp.d.ts +72 -0
  150. package/dist/cli/mcp.js +601 -0
  151. package/dist/cli/mcp.js.map +1 -0
  152. package/dist/cli/mcp.test.d.ts +1 -0
  153. package/dist/cli/mcp.test.js +380 -0
  154. package/dist/cli/mcp.test.js.map +1 -0
  155. package/dist/cli/output-options.d.ts +1 -0
  156. package/dist/cli/output-options.js +3 -0
  157. package/dist/cli/output-options.js.map +1 -1
  158. package/dist/cli/usage.d.ts +51 -1
  159. package/dist/cli/usage.js +709 -186
  160. package/dist/cli/usage.js.map +1 -1
  161. package/dist/compat/fetch-profile.js +9 -4
  162. package/dist/compat/fetch-profile.js.map +1 -1
  163. package/dist/compile-types.d.ts +17 -0
  164. package/dist/coverage/report.d.ts +5 -9
  165. package/dist/coverage/report.js.map +1 -1
  166. package/dist/executable/executable-cache.d.ts +17 -3
  167. package/dist/executable/executable-cache.js +17 -3
  168. package/dist/executable/executable-cache.js.map +1 -1
  169. package/dist/executable/prepare.js +87 -10
  170. package/dist/executable/prepare.js.map +1 -1
  171. package/dist/frontend/analysis.js +3 -2
  172. package/dist/frontend/analysis.js.map +1 -1
  173. package/dist/frontend/canon-map.js +13 -8
  174. package/dist/frontend/canon-map.js.map +1 -1
  175. package/dist/frontend/decl-projection.d.ts +18 -0
  176. package/dist/frontend/decl-projection.js +90 -22
  177. package/dist/frontend/decl-projection.js.map +1 -1
  178. package/dist/frontend/decl-projection.test.js +47 -1
  179. package/dist/frontend/decl-projection.test.js.map +1 -1
  180. package/dist/frontend/default-library.d.ts +10 -0
  181. package/dist/frontend/default-library.js +43 -0
  182. package/dist/frontend/default-library.js.map +1 -0
  183. package/dist/frontend/fork-target.js +54 -9
  184. package/dist/frontend/fork-target.js.map +1 -1
  185. package/dist/frontend/fork-target.test.js +82 -0
  186. package/dist/frontend/fork-target.test.js.map +1 -1
  187. package/dist/frontend/inferred-js-diagnostics.test.js +73 -0
  188. package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
  189. package/dist/frontend/lowering/abstract-equality.d.ts +2 -1
  190. package/dist/frontend/lowering/abstract-equality.js +7 -1
  191. package/dist/frontend/lowering/abstract-equality.js.map +1 -1
  192. package/dist/frontend/lowering/array-values.js +2 -2
  193. package/dist/frontend/lowering/array-values.js.map +1 -1
  194. package/dist/frontend/lowering/assertion-members.js +52 -2
  195. package/dist/frontend/lowering/assertion-members.js.map +1 -1
  196. package/dist/frontend/lowering/builtin-namespaces.d.ts +5 -0
  197. package/dist/frontend/lowering/builtin-namespaces.js +19 -12
  198. package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
  199. package/dist/frontend/lowering/builtins/callable-aliases.js +42 -6
  200. package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -1
  201. package/dist/frontend/lowering/builtins/child-process.d.ts +12 -11
  202. package/dist/frontend/lowering/builtins/child-process.js +235 -38
  203. package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
  204. package/dist/frontend/lowering/builtins/compression.d.ts +6 -1
  205. package/dist/frontend/lowering/builtins/compression.js +3 -3
  206. package/dist/frontend/lowering/builtins/compression.js.map +1 -1
  207. package/dist/frontend/lowering/builtins/constants.js +2 -2
  208. package/dist/frontend/lowering/builtins/constants.js.map +1 -1
  209. package/dist/frontend/lowering/builtins/crypto.d.ts +3 -1
  210. package/dist/frontend/lowering/builtins/crypto.js +9 -1
  211. package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
  212. package/dist/frontend/lowering/builtins/dates.js +26 -6
  213. package/dist/frontend/lowering/builtins/dates.js.map +1 -1
  214. package/dist/frontend/lowering/builtins/environment.d.ts +13 -1
  215. package/dist/frontend/lowering/builtins/environment.js +15 -4
  216. package/dist/frontend/lowering/builtins/environment.js.map +1 -1
  217. package/dist/frontend/lowering/builtins/module-bindings.d.ts +33 -0
  218. package/dist/frontend/lowering/builtins/module-bindings.js +213 -11
  219. package/dist/frontend/lowering/builtins/module-bindings.js.map +1 -1
  220. package/dist/frontend/lowering/builtins/module-resolution.d.ts +9 -2
  221. package/dist/frontend/lowering/builtins/module-resolution.js +187 -19
  222. package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
  223. package/dist/frontend/lowering/builtins/performance.js +1 -1
  224. package/dist/frontend/lowering/builtins/performance.js.map +1 -1
  225. package/dist/frontend/lowering/builtins/process.js +40 -2
  226. package/dist/frontend/lowering/builtins/process.js.map +1 -1
  227. package/dist/frontend/lowering/builtins/promises.js +33 -0
  228. package/dist/frontend/lowering/builtins/promises.js.map +1 -1
  229. package/dist/frontend/lowering/builtins/readline.d.ts +9 -5
  230. package/dist/frontend/lowering/builtins/readline.js +184 -75
  231. package/dist/frontend/lowering/builtins/readline.js.map +1 -1
  232. package/dist/frontend/lowering/builtins/url.d.ts +4 -0
  233. package/dist/frontend/lowering/builtins/url.js +6 -0
  234. package/dist/frontend/lowering/builtins/url.js.map +1 -1
  235. package/dist/frontend/lowering/call-arguments.js +15 -0
  236. package/dist/frontend/lowering/call-arguments.js.map +1 -1
  237. package/dist/frontend/lowering/callable-properties.d.ts +34 -0
  238. package/dist/frontend/lowering/callable-properties.js +210 -0
  239. package/dist/frontend/lowering/callable-properties.js.map +1 -0
  240. package/dist/frontend/lowering/cjs-inline-require.d.ts +16 -0
  241. package/dist/frontend/lowering/cjs-inline-require.js +105 -0
  242. package/dist/frontend/lowering/cjs-inline-require.js.map +1 -1
  243. package/dist/frontend/lowering/cjs-inline-require.test.d.ts +1 -0
  244. package/dist/frontend/lowering/cjs-inline-require.test.js +61 -0
  245. package/dist/frontend/lowering/cjs-inline-require.test.js.map +1 -0
  246. package/dist/frontend/lowering/class-dynamic-dispatch.js +82 -2
  247. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  248. package/dist/frontend/lowering/class-protocols.d.ts +57 -4
  249. package/dist/frontend/lowering/class-protocols.js +597 -30
  250. package/dist/frontend/lowering/class-protocols.js.map +1 -1
  251. package/dist/frontend/lowering/class-unions.js +2 -2
  252. package/dist/frontend/lowering/class-unions.js.map +1 -1
  253. package/dist/frontend/lowering/coercions/function-adapters.d.ts +12 -0
  254. package/dist/frontend/lowering/coercions/function-adapters.js +62 -0
  255. package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
  256. package/dist/frontend/lowering/coercions/structural-plans.js +56 -1
  257. package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
  258. package/dist/frontend/lowering/coercions/structural.js +9 -4
  259. package/dist/frontend/lowering/coercions/structural.js.map +1 -1
  260. package/dist/frontend/lowering/collection-ingestion.d.ts +9 -0
  261. package/dist/frontend/lowering/collection-ingestion.js +115 -41
  262. package/dist/frontend/lowering/collection-ingestion.js.map +1 -1
  263. package/dist/frontend/lowering/containers/array-callbacks.js +16 -0
  264. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
  265. package/dist/frontend/lowering/containers/bytes.js +66 -10
  266. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  267. package/dist/frontend/lowering/containers/collection-methods.js +61 -5
  268. package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
  269. package/dist/frontend/lowering/containers/filter-predicates.js +11 -0
  270. package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -1
  271. package/dist/frontend/lowering/containers/indexed-objects.d.ts +15 -0
  272. package/dist/frontend/lowering/containers/indexed-objects.js +213 -30
  273. package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
  274. package/dist/frontend/lowering/error-name-order.d.ts +16 -0
  275. package/dist/frontend/lowering/error-name-order.js +61 -0
  276. package/dist/frontend/lowering/error-name-order.js.map +1 -1
  277. package/dist/frontend/lowering/expressions/asserted-receiver.d.ts +17 -0
  278. package/dist/frontend/lowering/expressions/asserted-receiver.js +123 -1
  279. package/dist/frontend/lowering/expressions/asserted-receiver.js.map +1 -1
  280. package/dist/frontend/lowering/expressions/binary.js +147 -20
  281. package/dist/frontend/lowering/expressions/binary.js.map +1 -1
  282. package/dist/frontend/lowering/expressions/element-access.js +63 -14
  283. package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
  284. package/dist/frontend/lowering/expressions/erased-delete.d.ts +59 -0
  285. package/dist/frontend/lowering/expressions/erased-delete.js +247 -0
  286. package/dist/frontend/lowering/expressions/erased-delete.js.map +1 -0
  287. package/dist/frontend/lowering/expressions/hosted-narrowing.d.ts +10 -0
  288. package/dist/frontend/lowering/expressions/hosted-narrowing.js +48 -1
  289. package/dist/frontend/lowering/expressions/hosted-narrowing.js.map +1 -1
  290. package/dist/frontend/lowering/expressions/identifiers.js +20 -0
  291. package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
  292. package/dist/frontend/lowering/expressions/narrowing.d.ts +7 -2
  293. package/dist/frontend/lowering/expressions/narrowing.js +77 -45
  294. package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
  295. package/dist/frontend/lowering/expressions/object-literals.js +62 -19
  296. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  297. package/dist/frontend/lowering/expressions/optional-chains.js +19 -0
  298. package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
  299. package/dist/frontend/lowering/expressions/property-access.d.ts +7 -7
  300. package/dist/frontend/lowering/expressions/property-access.js +247 -48
  301. package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
  302. package/dist/frontend/lowering/expressions/relational.d.ts +1 -0
  303. package/dist/frontend/lowering/expressions/relational.js +18 -8
  304. package/dist/frontend/lowering/expressions/relational.js.map +1 -1
  305. package/dist/frontend/lowering/expressions/union-fields.js +11 -5
  306. package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
  307. package/dist/frontend/lowering/expressions/updates.js +121 -11
  308. package/dist/frontend/lowering/expressions/updates.js.map +1 -1
  309. package/dist/frontend/lowering/function-context.d.ts +10 -0
  310. package/dist/frontend/lowering/function-context.js +36 -0
  311. package/dist/frontend/lowering/function-context.js.map +1 -1
  312. package/dist/frontend/lowering/function-returns.js +8 -8
  313. package/dist/frontend/lowering/function-returns.js.map +1 -1
  314. package/dist/frontend/lowering/handle-properties.d.ts +62 -3
  315. package/dist/frontend/lowering/handle-properties.js +674 -26
  316. package/dist/frontend/lowering/handle-properties.js.map +1 -1
  317. package/dist/frontend/lowering/handle-properties.test.js +95 -2
  318. package/dist/frontend/lowering/handle-properties.test.js.map +1 -1
  319. package/dist/frontend/lowering/lower-builtin-values.d.ts +12 -0
  320. package/dist/frontend/lowering/lower-builtin-values.js +44 -0
  321. package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
  322. package/dist/frontend/lowering/lower-calls.js +328 -136
  323. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  324. package/dist/frontend/lowering/lower-classes.js +82 -17
  325. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  326. package/dist/frontend/lowering/lower-event-emitter.js +113 -9
  327. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  328. package/dist/frontend/lowering/lower-expando.d.ts +13 -21
  329. package/dist/frontend/lowering/lower-expando.js +90 -126
  330. package/dist/frontend/lowering/lower-expando.js.map +1 -1
  331. package/dist/frontend/lowering/lower-exprs.js +2 -2
  332. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  333. package/dist/frontend/lowering/lower-functions.js +65 -0
  334. package/dist/frontend/lowering/lower-functions.js.map +1 -1
  335. package/dist/frontend/lowering/lower-inspect.js +471 -0
  336. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  337. package/dist/frontend/lowering/lower-modules.js +36 -10
  338. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  339. package/dist/frontend/lowering/lower-node-island.js +28 -0
  340. package/dist/frontend/lowering/lower-node-island.js.map +1 -1
  341. package/dist/frontend/lowering/lower-server.d.ts +53 -7
  342. package/dist/frontend/lowering/lower-server.js +213 -42
  343. package/dist/frontend/lowering/lower-server.js.map +1 -1
  344. package/dist/frontend/lowering/lower-stdlib.js +50 -7
  345. package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
  346. package/dist/frontend/lowering/lower-stmts.d.ts +24 -0
  347. package/dist/frontend/lowering/lower-stmts.js +463 -220
  348. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  349. package/dist/frontend/lowering/lower-stream.js +2 -2
  350. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  351. package/dist/frontend/lowering/lower-test.js +71 -2
  352. package/dist/frontend/lowering/lower-test.js.map +1 -1
  353. package/dist/frontend/lowering/lowerer.d.ts +81 -10
  354. package/dist/frontend/lowering/lowerer.js +319 -72
  355. package/dist/frontend/lowering/lowerer.js.map +1 -1
  356. package/dist/frontend/lowering/new-target.js +10 -2
  357. package/dist/frontend/lowering/new-target.js.map +1 -1
  358. package/dist/frontend/lowering/nullish-empty-pattern.js +3 -3
  359. package/dist/frontend/lowering/nullish-empty-pattern.js.map +1 -1
  360. package/dist/frontend/lowering/partial-assertions.js +30 -5
  361. package/dist/frontend/lowering/partial-assertions.js.map +1 -1
  362. package/dist/frontend/lowering/primitive-throws.js +91 -1
  363. package/dist/frontend/lowering/primitive-throws.js.map +1 -1
  364. package/dist/frontend/lowering/primitive-wrappers.d.ts +9 -0
  365. package/dist/frontend/lowering/primitive-wrappers.js +2 -2
  366. package/dist/frontend/lowering/primitive-wrappers.js.map +1 -1
  367. package/dist/frontend/lowering/promise-executor-adapter.js +5 -2
  368. package/dist/frontend/lowering/promise-executor-adapter.js.map +1 -1
  369. package/dist/frontend/lowering/record-links.js +7 -2
  370. package/dist/frontend/lowering/record-links.js.map +1 -1
  371. package/dist/frontend/lowering/surfaces.d.ts +4 -0
  372. package/dist/frontend/lowering/surfaces.js +118 -2
  373. package/dist/frontend/lowering/surfaces.js.map +1 -1
  374. package/dist/frontend/lowering/surfaces.test.d.ts +1 -0
  375. package/dist/frontend/lowering/surfaces.test.js +31 -0
  376. package/dist/frontend/lowering/surfaces.test.js.map +1 -0
  377. package/dist/frontend/mock-shapes.js +3 -3
  378. package/dist/frontend/mock-shapes.js.map +1 -1
  379. package/dist/frontend/npm-static-ladder.d.ts +21 -0
  380. package/dist/frontend/npm-static-ladder.js +2 -0
  381. package/dist/frontend/npm-static-ladder.js.map +1 -0
  382. package/dist/frontend/npm-static-ladder.test.d.ts +1 -0
  383. package/dist/frontend/npm-static-ladder.test.js +138 -0
  384. package/dist/frontend/npm-static-ladder.test.js.map +1 -0
  385. package/dist/frontend/npm-static-status.d.ts +15 -0
  386. package/dist/frontend/npm-static-status.js +2 -0
  387. package/dist/frontend/npm-static-status.js.map +1 -0
  388. package/dist/frontend/package-shims.js +1 -1
  389. package/dist/frontend/package-shims.js.map +1 -1
  390. package/dist/frontend/pipeline.d.ts +1 -1
  391. package/dist/frontend/pipeline.js +222 -25
  392. package/dist/frontend/pipeline.js.map +1 -1
  393. package/dist/frontend/program-analysis.d.ts +4 -0
  394. package/dist/frontend/program-analysis.js +6 -0
  395. package/dist/frontend/program-analysis.js.map +1 -1
  396. package/dist/frontend/program.js +258 -32
  397. package/dist/frontend/program.js.map +1 -1
  398. package/dist/frontend/program.test.js +30 -0
  399. package/dist/frontend/program.test.js.map +1 -1
  400. package/dist/frontend/resolve.js +29 -5
  401. package/dist/frontend/resolve.js.map +1 -1
  402. package/dist/frontend/resolve.test.js +40 -0
  403. package/dist/frontend/resolve.test.js.map +1 -1
  404. package/dist/frontend/services.d.ts +8 -0
  405. package/dist/frontend/services.js +7 -0
  406. package/dist/frontend/services.js.map +1 -1
  407. package/dist/frontend/ts7/checker.d.ts +7 -0
  408. package/dist/frontend/ts7/checker.js +12 -0
  409. package/dist/frontend/ts7/checker.js.map +1 -1
  410. package/dist/frontend/ts7/checker.test.js +1 -0
  411. package/dist/frontend/ts7/checker.test.js.map +1 -1
  412. package/dist/frontend/ts7/program-host.d.ts +39 -2
  413. package/dist/frontend/ts7/program-host.js +62 -8
  414. package/dist/frontend/ts7/program-host.js.map +1 -1
  415. package/dist/frontend/ts7/program-host.test.js +33 -0
  416. package/dist/frontend/ts7/program-host.test.js.map +1 -1
  417. package/dist/frontend/ts7/session-cache.d.ts +5 -1
  418. package/dist/frontend/ts7/session-cache.js +7 -1
  419. package/dist/frontend/ts7/session-cache.js.map +1 -1
  420. package/dist/frontend/ts7/session-cache.test.js +37 -0
  421. package/dist/frontend/ts7/session-cache.test.js.map +1 -1
  422. package/dist/frontend/ts7/session.js +19 -1
  423. package/dist/frontend/ts7/session.js.map +1 -1
  424. package/dist/frontend/ts7/source-parser.d.ts +17 -2
  425. package/dist/frontend/ts7/source-parser.js +61 -2
  426. package/dist/frontend/ts7/source-parser.js.map +1 -1
  427. package/dist/frontend/ts7/source-parser.test.js +55 -2
  428. package/dist/frontend/ts7/source-parser.test.js.map +1 -1
  429. package/dist/frontend/tsc-codes.d.ts +3 -2
  430. package/dist/frontend/tsc-codes.js +129 -22
  431. package/dist/frontend/tsc-codes.js.map +1 -1
  432. package/dist/frontend/type-mapper.d.ts +5 -11
  433. package/dist/frontend/type-mapper.js +380 -70
  434. package/dist/frontend/type-mapper.js.map +1 -1
  435. package/dist/index.d.ts +1 -1
  436. package/dist/index.js +67 -7
  437. package/dist/index.js.map +1 -1
  438. package/dist/ir/builtin-effects.js +29 -0
  439. package/dist/ir/builtin-effects.js.map +1 -1
  440. package/dist/ir/builtin-signatures.d.ts +1 -1
  441. package/dist/ir/builtin-signatures.js +72 -6
  442. package/dist/ir/builtin-signatures.js.map +1 -1
  443. package/dist/ir/codec.generated.d.ts +1 -1
  444. package/dist/ir/codec.generated.js +321 -263
  445. package/dist/ir/codec.generated.js.map +1 -1
  446. package/dist/ir/constant-length-clones.d.ts +26 -0
  447. package/dist/ir/constant-length-clones.js +589 -0
  448. package/dist/ir/constant-length-clones.js.map +1 -0
  449. package/dist/ir/constant-length-clones.test.d.ts +1 -0
  450. package/dist/ir/constant-length-clones.test.js +292 -0
  451. package/dist/ir/constant-length-clones.test.js.map +1 -0
  452. package/dist/ir/constant-tables.d.ts +10 -5
  453. package/dist/ir/constant-tables.js +83 -17
  454. package/dist/ir/constant-tables.js.map +1 -1
  455. package/dist/ir/constant-tables.test.js +58 -1
  456. package/dist/ir/constant-tables.test.js.map +1 -1
  457. package/dist/ir/fields.generated.js +5 -2
  458. package/dist/ir/fields.generated.js.map +1 -1
  459. package/dist/ir/function-references.js +2 -0
  460. package/dist/ir/function-references.js.map +1 -1
  461. package/dist/ir/function-references.test.js +13 -0
  462. package/dist/ir/function-references.test.js.map +1 -1
  463. package/dist/ir/integer-loops.js +1 -0
  464. package/dist/ir/integer-loops.js.map +1 -1
  465. package/dist/ir/integer-loops.test.js +16 -0
  466. package/dist/ir/integer-loops.test.js.map +1 -1
  467. package/dist/ir/ir.d.ts +50 -6
  468. package/dist/ir/ir.js +44 -2
  469. package/dist/ir/ir.js.map +1 -1
  470. package/dist/ir/ir.test.js +83 -1
  471. package/dist/ir/ir.test.js.map +1 -1
  472. package/dist/ir/js-groups.js +5 -1
  473. package/dist/ir/js-groups.js.map +1 -1
  474. package/dist/ir/js-ic.d.ts +20 -0
  475. package/dist/ir/js-ic.js +81 -4
  476. package/dist/ir/js-ic.js.map +1 -1
  477. package/dist/ir/js-ic.test.js +8 -1
  478. package/dist/ir/js-ic.test.js.map +1 -1
  479. package/dist/ir/lane-plans.d.ts +86 -0
  480. package/dist/ir/lane-plans.js +589 -0
  481. package/dist/ir/lane-plans.js.map +1 -0
  482. package/dist/ir/lane-plans.test.d.ts +1 -0
  483. package/dist/ir/lane-plans.test.js +549 -0
  484. package/dist/ir/lane-plans.test.js.map +1 -0
  485. package/dist/ir/runtime-features.d.ts +68 -10
  486. package/dist/ir/runtime-features.js +285 -17
  487. package/dist/ir/runtime-features.js.map +1 -1
  488. package/dist/ir/runtime-features.test.js +190 -1
  489. package/dist/ir/runtime-features.test.js.map +1 -1
  490. package/dist/ir/validate.js +61 -24
  491. package/dist/ir/validate.js.map +1 -1
  492. package/dist/native/cache.d.ts +5 -0
  493. package/dist/native/cache.js +23 -1
  494. package/dist/native/cache.js.map +1 -1
  495. package/dist/native/cache.test.js +29 -1
  496. package/dist/native/cache.test.js.map +1 -1
  497. package/dist/native/cli.js +4 -2
  498. package/dist/native/cli.js.map +1 -1
  499. package/dist/native/compiler.d.ts +11 -3
  500. package/dist/native/compiler.js +102 -16
  501. package/dist/native/compiler.js.map +1 -1
  502. package/dist/native/compiler.test.js +244 -2
  503. package/dist/native/compiler.test.js.map +1 -1
  504. package/dist/native/prepare.d.ts +14 -1
  505. package/dist/native/prepare.js +79 -29
  506. package/dist/native/prepare.js.map +1 -1
  507. package/dist/native/sanitizer.test.js +3 -0
  508. package/dist/native/sanitizer.test.js.map +1 -1
  509. package/dist/native/unchanged.d.ts +80 -0
  510. package/dist/native/unchanged.js +301 -0
  511. package/dist/native/unchanged.js.map +1 -0
  512. package/dist/native/unchanged.test.d.ts +1 -0
  513. package/dist/native/unchanged.test.js +249 -0
  514. package/dist/native/unchanged.test.js.map +1 -0
  515. package/dist/node-islands/boundary.d.ts +16 -0
  516. package/dist/node-islands/boundary.js +70 -7
  517. package/dist/node-islands/boundary.js.map +1 -1
  518. package/dist/node-islands/boundary.test.js +59 -14
  519. package/dist/node-islands/boundary.test.js.map +1 -1
  520. package/dist/node-islands/detect.js +203 -47
  521. package/dist/node-islands/detect.js.map +1 -1
  522. package/dist/node-islands/detect.test.js +45 -0
  523. package/dist/node-islands/detect.test.js.map +1 -1
  524. package/dist/node-islands/growth.js +4 -16
  525. package/dist/node-islands/growth.js.map +1 -1
  526. package/dist/node-islands/modules.d.ts +3 -0
  527. package/dist/node-islands/modules.js +143 -12
  528. package/dist/node-islands/modules.js.map +1 -1
  529. package/dist/node-islands/modules.test.js +125 -0
  530. package/dist/node-islands/modules.test.js.map +1 -1
  531. package/dist/node-islands/report.d.ts +1 -1
  532. package/dist/node-islands/report.js +2 -1
  533. package/dist/node-islands/report.js.map +1 -1
  534. package/package.json +20 -20
  535. package/shims/undici/core/request.ts +7 -1
  536. package/surface-manifest.json +380 -2
@@ -13,6 +13,7 @@ import { checkedTable, countTable, fixedScalar, flagScalar, functionTable, irDat
13
13
  import { UnitReuse, unitReuseVerify, verifyStoredUnit } from "./unit-reuse.js";
14
14
  import { moduleNamespaceDynValue, moduleNamespaceObject, moduleNamespaceValue, } from "./module-namespace-elements.js";
15
15
  import { keyedHelperName, moduleTagNumber, portableRelativePath } from "./stable-names.js";
16
+ import { noteCodecMode, ZLIB_STREAM_FACTORIES, ZLIB_STREAM_T } from "./builtins/compression.js";
16
17
  import { positionTag, StructuralPositions } from "./structural-positions.js";
17
18
  import { activeNodeIslands, setActiveNodeIslands, } from "../../node-islands/boundary.js";
18
19
  import { bindingSymbolOfRead, onlyForwarded, stripTypeWrappers } from "./typed-arguments.js";
@@ -64,7 +65,7 @@ import { lowerBuiltinCall } from "./builtin-calls.js";
64
65
  import { CoercionState } from "./coercions/state.js";
65
66
  import { widthLiftPlan, unitOnlyElem, recordWidthPlan, describeRecordWidthBlocker, objToRecordPlan, recordToClassPlan, } from "./coercions/structural-plans.js";
66
67
  import { widthCoerce, applyWidthLift, unionRecordWidthHelper, unionArrayWidthHelper, recordWidthHelper, tupleArrayWidthHelper, emptyArrayLiftHelper, arrayWidthHelper, objRecordWidthHelper, recordClassWidthHelper, classStaticsProjection, } from "./coercions/structural.js";
67
- import { funcReturnWidthAdapter, coercibleValue, cleanFuncAdaptable, funcCoerceAdapter, spawnResFnAdapterPlan, spawnResFnAdapter, } from "./coercions/function-adapters.js";
68
+ import { funcReturnWidthAdapter, coercibleValue, cleanFuncAdaptable, funcCoerceAdapter, sortComparatorResultAdapter, spawnResFnAdapterPlan, spawnResFnAdapter, } from "./coercions/function-adapters.js";
68
69
  import { unionRetagMappable, narrowedRetagHelper, uninhabitedArmRetagHelper, strandedUnitTrap, strandedCoercionTrap, recordUnionRouteHelper, recordUnionWrapHelper, unionRetagHelper, narrowedArmHelper, checkedNarrowCall, checkedNarrowOperand, deferredReadHelper, widthNarrowHelper, } from "./coercions/unions.js";
69
70
  import { assertedConversion } from "./coercions/asserted.js";
70
71
  import { boxBuiltinValuesChecked, lowerUtilTypeValue, checkedNativeCallableValue, pathModuleValue, utilTypesModuleValue, } from "./lower-builtin-values.js";
@@ -85,7 +86,7 @@ import { RuntimeOptionalLocals } from "./runtime-optional-locals.js";
85
86
  import { collectContractAnnotations } from "../contract-types.js";
86
87
  import { sanitizeUnregisteredClassTypes } from "./sanitize-class-types.js";
87
88
  import { UnregisteredClassTypes } from "./unregistered-class-types.js";
88
- import { bindingInContext, captureContextBinding, declareContextLocal, declareContextThis, newFnCtx, } from "./function-context.js";
89
+ import { bindingInContext, captureContextBinding, captureContextLocal, declareContextLocal, declareContextThis, newFnCtx, } from "./function-context.js";
89
90
  import { InternalCompilerError } from "../../errors.js";
90
91
  import { defaultAfterUndefined, lowerStaticallyUndefinedArgument } from "./optional-arguments.js";
91
92
  import {} from "./class-protocol-dispatch.js";
@@ -94,12 +95,12 @@ import { addUntypedIntegrityWords, guardClassAttributeWrites } from "./class-att
94
95
  import { inferredCollectionType } from "./js-collection-types.js";
95
96
  import { sloppyDynamicWrites } from "./frozen-records.js";
96
97
  import { guardFrozenWrites, markSloppyRecordWrites } from "./frozen-records.js";
97
- import { applyHandleProperties } from "./handle-properties.js";
98
+ import { alignHandlePropertyChildFact, applyHandleProperties, handlePropertyScanRoots, } from "./handle-properties.js";
98
99
  import { installBufferValue } from "./containers/bytes.js";
99
100
  import { installMutableBuffersArm } from "./buffers.js";
100
101
  import { ClassProtocols } from "./class-protocols.js";
101
102
  import { earlyReadVarSymbols } from "./var-hoisting.js";
102
- import { recordTextCodecClass } from "../../ir/ir.js";
103
+ import { recordTextCodecClass, sortArms } from "../../ir/ir.js";
103
104
  import { assignLegacyTiers } from "../../ir/tiers.js";
104
105
  import { dynamicSlotOperationCounts, dynamicTierWarning } from "./dynamic-tier.js";
105
106
  import { promoteJsvals } from "../../ir/jsval.js";
@@ -137,11 +138,11 @@ import { discriminantOwners, literalUnionArm } from "../union-discriminants.js";
137
138
  import { declarationGroupKey, typeFailureOf } from "./type-failure.js";
138
139
  import { dynamicSlotDiag } from "../../diagnostics/dynamic-slots.js";
139
140
  import { unsupportedAnyOperationDiag, blockedBindingUseDiag, checkerPanicDiag, componentTypeDiag, isCheckerPanic, genericSignatureTypeDiag, hostGlobalDiag, indexSignatureTypeDiag, intersectionTypeDiag, noLoweringDiag, overloadedSignatureTypeDiag, recordShapeMismatchDiag, stdlibSnapshotValueUseDiag, unsupportedNativeApiDiag, unsupportedPackageValueDiag, unionMismatchDiag, UNSUPPORTED, unsupportedDiag, unsupportedTypeDiag, } from "../../diagnostics/diagnostic.js";
140
- import { arrayOf, BOOL, canAdaptDynFuncTo, canBoxFuncIntoDyn, canDynCheckTo, canConvertToDyn, DYN, DYN_HANDLE_KINDS, F64, isDynTypedRefType, isJsonSafeType, isJsonStringifySafeType, isPrimitiveCollectionKey, isSupportedMapKey, isSupportedMapValue, isUndefinedArmedUnion, isUnitType, NULL_T, RUNTIME_ERROR_CLASSES, STRING, typeEquals, UNDEFINED_T, VOID, } from "../../ir/ir.js";
141
+ import { arrayOf, BOOL, canAdaptDynFuncTo, canBoxFuncIntoDyn, canDynCheckTo, canConvertToDyn, DYN, F64, isDynTypedRefType, isJsonSafeType, isJsonStringifySafeType, isPrimitiveCollectionKey, isSupportedMapKey, isSupportedMapValue, isUndefinedArmedUnion, isUnitType, NULL_T, RUNTIME_ERROR_CLASSES, STRING, typeEquals, UNDEFINED_T, VOID, } from "../../ir/ir.js";
141
142
  import { provenanceActive } from "../provenance-registry.js";
142
143
  import { canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, cjsExportsAssignedInFunctions, cjsReexportedModules, cjsNamespaceExportNames, isCheckedJsSourceFile, isCjsExportTableLiteral, isCjsJsFile, isJsSourceFile, isNodeEsmFile, locOf, orderedImportsOf, npmStaticDepSf7, requireSpecOf, isJsWriteTarget7, isStrictCode, resolveImport, workspacePackageOfPath, } from "../program.js";
143
144
  import { containsRecord, containsUnion, describeComponentBlocker, describeRecordMemberBlocker, erasedOverloadMemberType, formatIrType, FETCH_AMBIENT_TYPES, isOsConstantsSymbol, isOverloadedCallableMemberType, isUnitOnlyTsType, isWorkerHandleType, isFetchHandleType, jsOpenObjectType, mapType, computeSymbolProvenance, declaresLegacyUrl, declaresWebAssemblyNamespace, ShapeRegistry, noteScopeSensitiveMapping, typeKey, UnionRegistry, withUndefinedArm as withUndefinedArmCanonical, } from "../type-mapper.js";
144
- import { builtinConstLit, builtinModuleConstOf, builtinModulesArrayLit, builtinFenceHintOf, builtinModuleFnOf, stdlibMemberFence, isStdlibMember, isStdlibSymbol, isStdlibGlobal, stdlibGlobalNameOf, stdlibGlobalMember, nodeTypesOnlySymbol, } from "./surfaces.js";
145
+ import { builtinConstLit, builtinModuleConstOf, builtinModulesArrayLit, builtinFenceHintOf, builtinModuleFnOf, FS_CALLBACK_VALUE_LENGTHS, stdlibMemberFence, isStdlibMember, isStdlibSymbol, isStdlibGlobal, stdlibGlobalNameOf, stdlibGlobalMember, nodeTypesOnlySymbol, } from "./surfaces.js";
145
146
  import { builtinClassAliasOf, runtimeClassValueOfType, } from "./builtins/class-values.js";
146
147
  import { splitFiles, collectProgram, collectNpmImports, collectJsonImports, moduleArtifacts, collectGlobals, declSymbolOf, defaultExportSymbolOf, lowerFileInit, lowerDefaultExport, buildMain, appendDynamicImportModules, appendForkModules, appendWorkerModules, } from "./lower-modules.js";
147
148
  import { prepareCjsModuleGraph, usesCjsTopLevelThis } from "./lower-node-module.js";
@@ -177,10 +178,10 @@ import { lowerTimersPromisesSetInterval, lowerTimeoutMethodCall } from "./builti
177
178
  import { lowerFsToUnixTimestampCall, lowerFsLadderCall, lowerStatsMethodCall, } from "./builtins/filesystem.js";
178
179
  import { lowerSpawnSyncCall, lowerSpawnCall, lowerExecFileCall } from "./builtins/child-process.js";
179
180
  import { lowerExecSyncCall } from "./builtins/child-process-sync.js";
180
- import { isProcessEnv, envValueType, lowerProcessEnvGet, refuseHeldEnvWrite, } from "./builtins/environment.js";
181
+ import { isAmbientProcessEnv, envValueType, lowerProcessEnvGet, refuseHeldEnvWrite, } from "./builtins/environment.js";
181
182
  import { lowerJsonMethodCall, lowerJsonProperty } from "./builtins/json.js";
182
183
  import { lowerCryptoComposedCall, lowerCryptoModuleCall } from "./builtins/crypto.js";
183
- import { lowerUrlMethodCall, lowerSearchParamsMethodCall } from "./builtins/url.js";
184
+ import { legacyUrlClassValue, lowerUrlMethodCall, lowerSearchParamsMethodCall, } from "./builtins/url.js";
184
185
  import { lowerChildMethodCall } from "./builtins/child-process-methods.js";
185
186
  import { lowerAtomicsCall } from "./builtins/atomics.js";
186
187
  import { lowerBuiltinExtraProperty } from "./builtins/properties.js";
@@ -208,7 +209,7 @@ import { assertFunctionValue, lowerAssertModuleCall, lowerAssertDirectCall, } fr
208
209
  import { lowerUtilModuleCall } from "./lower-inspect.js";
209
210
  import { lowerSystemErrorMapValue } from "./lower-system-errors.js";
210
211
  import { lowerComptime, comptimeBakeable, rejectComptimeCaptures, comptimeValueToIr, } from "./lower-comptime.js";
211
- import { lowerStmts, hasJsTypeAnnotation, noteBlockedBindings, isBlockedBinding, lowerScopedBlock, predeclareForwardCapture, predeclareForwardFnDecl, predeclareForwardVar, lowerStmt, lowerVarStatement, lowerDestructuringDecl, lowerDestructuringAssignParts, lowerBindingPattern, checkBindingElement, bindPatternTarget, isParseArgsDynCheckerType, lowerVarDeclList, lowerVarDecl, lowerSwitch, lowerTry, lowerExprStatement, lowerForOf, lowerForStatement, matchGroupsPatternSource, isGuardedRecordRead, holdsEvolvingArray, } from "./lower-stmts.js";
212
+ import { lowerStmts, hasJsTypeAnnotation, noteBlockedBindings, isBlockedBinding, lowerScopedBlock, predeclareForwardCapture, predeclareForwardFnDecl, predeclareForwardVar, lowerStmt, lowerVarStatement, lowerDestructuringDecl, lowerDestructuringAssignParts, lowerBindingPattern, assertedOnlyFieldRead, checkBindingElement, bindPatternTarget, isParseArgsDynCheckerType, lowerVarDeclList, lowerVarDecl, lowerSwitch, lowerTry, lowerExprStatement, lowerForOf, lowerForStatement, matchGroupsPatternSource, isGuardedRecordRead, holdsEvolvingArray, } from "./lower-stmts.js";
212
213
  import { lowerExpr, maybeNarrow, lowerUnitComparison, lowerNullishCoalesce, lowerCondition, ensureBool, requireTruthyUnion, eqComparableUnion, lowerIntrinsicProperty, lowerArrayLiteral, lowerElementAccess, lowerElementWrite, lowerRecordKeyRead, ensureString, lowerTemplate, lowerAsExpression, lowerPrefixUnary, lowerBinary, lowerCaughtTypeofTest, caughtRead, caughtLocalOf, caughtToString, lowerInstanceOf, lowerRegexLiteral, lowerFieldRead, lowerUnionProperty, fieldTarget, fieldGetExpr, fieldSetStmt, lowerFieldCompound, uniqueSymbolKeyOf, matchCallbackParamGroupsOf, } from "./lower-exprs.js";
213
214
  import { finishOptionalChain, isOptionalChainTail, lowerOptionalChain, } from "./expressions/optional-chains.js";
214
215
  import { foldedStringKeyOf, lowerDynObjectLiteral, lowerObjectLiteral, lowerShorthandValue, rejectThisInObjectMethod, } from "./expressions/object-literals.js";
@@ -490,6 +491,7 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
490
491
  projectCheckJs: options.projectCheckJs ?? false,
491
492
  targetPlatform,
492
493
  startupCrash,
494
+ admittedOpinions: options.admittedOpinions,
493
495
  inlineRequireCycleCalls,
494
496
  dynamicImportRejections: options.dynamicImportRejections,
495
497
  ffiImports,
@@ -538,13 +540,23 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
538
540
  let result = emitted.result;
539
541
  let resultLowerer = reachableEmit;
540
542
  timing("reachable-emit", { reachable: reachable.size });
543
+ // The general stream representation (TypeMapperCtx.generalNodeStreams)
544
+ // is a per-program decision: only a program whose reachable code moved
545
+ // a general stream into a stdio-represented stream slot lowers again
546
+ // with it. Every other program keeps the single pass above unchanged.
547
+ // The stream pass below replaces this pass's result outright, so the
548
+ // whole-slot comparison runs after it for those programs (it would
549
+ // otherwise pay for a result the stream pass throws away).
550
+ const generalNodeStreams = reachableEmit.requiresGeneralNodeStreams;
541
551
  // Localized failure (stage L3): push-down must never cost a failing
542
552
  // program more errors than the whole-slot checked dynamic. A pushed-down
543
553
  // type is baked into the globals, fields and signatures that hold it, so
544
554
  // when the program still fails, the emit runs once more with every
545
555
  // degraded type held whole, and the pass with fewer errors wins (ties
546
556
  // keep push-down). A program that compiles never takes this path.
547
- if (result.diagnostics.length > 0 && reachableEmit.hasPartialDegradedTypes()) {
557
+ if (!generalNodeStreams &&
558
+ result.diagnostics.length > 0 &&
559
+ reachableEmit.hasPartialDegradedTypes()) {
548
560
  const whole = new Lowerer(program, entry, moduleOrder, {
549
561
  facts,
550
562
  frontendServices: options.frontendServices,
@@ -576,11 +588,6 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
576
588
  }
577
589
  timing("whole-slot-relower", { reachable: wholeEmitted.reachable.size });
578
590
  }
579
- // The general stream representation (TypeMapperCtx.generalNodeStreams)
580
- // is a per-program decision: only a program whose reachable code moved
581
- // a general stream into a stdio-represented stream slot lowers again
582
- // with it. Every other program keeps the single pass above unchanged.
583
- const generalNodeStreams = reachableEmit.requiresGeneralNodeStreams;
584
591
  // Checked-dynamic stream slots (dyn-streams.ts) are a further per-program
585
592
  // decision under the general representation: only a program that moves an
586
593
  // untyped value into a stream slot lowers again with them.
@@ -665,6 +672,48 @@ function lowerToIrWithIslands(program, entry, moduleOrder, options) {
665
672
  resultLowerer = emit;
666
673
  timing("historical-order-relower");
667
674
  }
675
+ // A stream program whose passes still fail takes the whole-slot
676
+ // comparison here, against the pass whose result stands: the stream pass
677
+ // replaces the earlier result outright, so the comparison is only worth
678
+ // paying for on the pass it would judge. The rule is unchanged — the
679
+ // whole-slot pass is kept only when it has strictly fewer errors.
680
+ if (generalNodeStreams &&
681
+ result.diagnostics.length > 0 &&
682
+ resultLowerer.hasPartialDegradedTypes()) {
683
+ const whole = new Lowerer(program, entry, moduleOrder, {
684
+ facts,
685
+ frontendServices: options.frontendServices,
686
+ projectCheckJs: options.projectCheckJs ?? false,
687
+ generalNodeStreams: true,
688
+ ...(dynNodeStreams ? { dynNodeStreams: true } : {}),
689
+ targetPlatform,
690
+ startupCrash,
691
+ admittedOpinions: options.admittedOpinions,
692
+ inlineRequireCycleCalls,
693
+ dynamicImportRejections: options.dynamicImportRejections,
694
+ ffiImports,
695
+ libraryCallbacks,
696
+ forkTargets,
697
+ workerTargets,
698
+ ffiBindingSymbols: ffiValidation.symbolsByName,
699
+ externalTypes,
700
+ externalTypeSpecifiersByFile,
701
+ tierMode,
702
+ runtimeOptionalReport,
703
+ wholeSlotDegradation: true,
704
+ });
705
+ for (const d of extraModuleCycleDiags)
706
+ whole.pushDiag(d);
707
+ for (const d of ffiValidation.diagnostics)
708
+ whole.pushDiag(d);
709
+ const wholeEmitted = whole.emitReachable(options.libRoots);
710
+ if (wholeEmitted.result.diagnostics.length < result.diagnostics.length) {
711
+ reachable = wholeEmitted.reachable;
712
+ result = wholeEmitted.result;
713
+ resultLowerer = whole;
714
+ }
715
+ timing("whole-slot-relower", { reachable: wholeEmitted.reachable.size });
716
+ }
668
717
  // LIBRARY mode: the profile's export names resolved to the units that
669
718
  // supply them — the entry's own unit for a direct export, the declaring
670
719
  // module's tagged unit for a re-exported one. The export-map resolution
@@ -1952,6 +2001,14 @@ export class Lowerer {
1952
2001
  * program's JavaScript adds to them (handle-properties.ts). */
1953
2002
  writesOntoChildren = false;
1954
2003
  childAdditions = null;
2004
+ /** Whether the program's JavaScript adds own properties to handles, asks
2005
+ * their integrity, and which class members it shadows
2006
+ * (handle-properties.ts). */
2007
+ handleAdditions = undefined;
2008
+ /** Whether the program has a JavaScript implementation file, the only kind
2009
+ * that can add own properties to a handle, so a typed handle operation of
2010
+ * a program without one keeps its own lowering (handle-properties.ts). */
2011
+ handleJsSources = undefined;
1955
2012
  /** Bindings whose unchecked string arithmetic can produce either a number
1956
2013
  * (NaN for an absent read) or a string. Preserve that result union at bare
1957
2014
  * reads instead of applying the checker-bare string narrowing adapter. */
@@ -2299,7 +2356,16 @@ export class Lowerer {
2299
2356
  this.armTag(signature.returnType.unionId, UNDEFINED_T) >= 0));
2300
2357
  }
2301
2358
  if (ts.isIdentifier(origin)) {
2302
- const local = this.resolveLocal(origin);
2359
+ // The whole-program analyses ask this question before any body lowers
2360
+ // (speculativeTypeQueries around analyzeRuntimeOptionalArrayReads), so
2361
+ // there is no function context and no local binding to consult yet: a
2362
+ // binding's storage class settles when its declaration (or its
2363
+ // parameter ABI) lowers, and a query must never mint a capture. Until
2364
+ // then the module global's storage is the only one readable. Every
2365
+ // other caller lowers a body, where an empty stack stays a lowerer bug.
2366
+ const local = this.speculativeTypeQueryDepth > 0 && this.fnStack.length === 0
2367
+ ? null
2368
+ : this.resolveLocal(origin);
2303
2369
  const root = local ? this.runtimeOptionalRootOf(local) : null;
2304
2370
  const global = this.globalOf(origin);
2305
2371
  return ((!!root && this.runtimeOptionalStorageLocals.has(root)) ||
@@ -2951,7 +3017,8 @@ export class Lowerer {
2951
3017
  * record types (finalizeRecordLinks checks them against link sources). */
2952
3018
  recordMethodCalls = [];
2953
3019
  /** Completions of "custom" linked helpers (record-links.ts), which
2954
- * finalizeRecordLinks runs once the links are known. */
3020
+ * finalizeRecordLinks runs once the links are known, with the record
3021
+ * shapes a checked conversion can leave holding a kept source. */
2955
3022
  linkedHelperFinalizers = [];
2956
3023
  /** Helpers over record types that finalizeRecordLinks completes. */
2957
3024
  linkedHelpers = [];
@@ -3755,6 +3822,10 @@ export class Lowerer {
3755
3822
  // are checked against.
3756
3823
  "ownClassProtocols",
3757
3824
  "verifySymbolProvenance",
3825
+ // Whether the program has a JavaScript implementation file depends only on
3826
+ // its modules, so the answer is a memo computed on first use and the
3827
+ // census in handle-properties.ts reads it again when a unit replays.
3828
+ "handleJsSources",
3758
3829
  // The whole-program prepass analyzeJsWidenedBindings computes this set
3759
3830
  // before lowering begins: a pure function of the program's modules.
3760
3831
  "jsWidenedBindings",
@@ -3902,6 +3973,7 @@ export class Lowerer {
3902
3973
  fixed("errorMethodDispatchRevision", () => this.errorMethodDispatchRevision),
3903
3974
  fixed("errorPropertyDispatchRevision", () => this.errorPropertyDispatchRevision),
3904
3975
  fixed("childAdditions", () => this.childAdditions),
3976
+ fixed("handleAdditions", () => this.handleAdditions),
3905
3977
  fixed("emitterEventTable", () => this.emitterEventTable),
3906
3978
  fixed("emitterAnyNameListener", () => this.emitterAnyNameListener),
3907
3979
  fixed("globalThisWrittenNames", () => this.globalThisWrittenNames),
@@ -5257,6 +5329,30 @@ export class Lowerer {
5257
5329
  }
5258
5330
  return createRequireProgramModuleOf(this, decl.initializer)?.dep ?? null;
5259
5331
  }
5332
+ /** The table module a top-level CommonJS `const { a, ...rest } =
5333
+ * require("./m")` pattern's rest elements copy from: Node builds `rest`
5334
+ * from the module's own enumerable export properties at the require, and
5335
+ * the table's statically known members are exactly those properties.
5336
+ * Null when the pattern has no rest element or the target is not a
5337
+ * table module. */
5338
+ cjsRequireRestTableOf(decl) {
5339
+ if (!ts.isObjectBindingPattern(decl.name))
5340
+ return null;
5341
+ if (!decl.name.elements.nodes.some((e) => e.dotDotDotToken !== undefined))
5342
+ return null;
5343
+ const stmt = decl.parent?.parent;
5344
+ if (stmt === undefined || !ts.isVariableStatement(stmt) || !ts.isSourceFile(stmt.parent))
5345
+ return null;
5346
+ if (!isJsSourceFile(stmt.parent) || decl.initializer === undefined)
5347
+ return null;
5348
+ const spec = requireSpecOf(decl.initializer);
5349
+ if (spec === null)
5350
+ return null;
5351
+ const sf = stmt.parent;
5352
+ const dep = resolveImport(this.program, sf, spec, "require") ??
5353
+ npmStaticDepSf7(this.program, sf, spec, "require");
5354
+ return dep !== null && cjsNamespaceModule(this, dep) ? dep : null;
5355
+ }
5260
5356
  createRequireBindingTargets = new Map();
5261
5357
  createRequireElementTargets = new Map();
5262
5358
  /** The program module a `const x = createRequire(...)("./m")` binding
@@ -5493,7 +5589,19 @@ export class Lowerer {
5493
5589
  * calls of these names. Runs in every pass so the ids are
5494
5590
  * deterministic. */
5495
5591
  prepareModuleInits(parts) {
5496
- parts.forEach((fp, i) => this.initNameOf.set(fp.sf, `%init.${i}`));
5592
+ // The entry module's %init is %init.0; every other module's number comes
5593
+ // from its stable file name, so adding or reordering modules leaves every
5594
+ // other module's init name unchanged.
5595
+ const initNumbers = new Set([0]);
5596
+ for (const fp of parts) {
5597
+ if (fp.sf === this.entry) {
5598
+ this.initNameOf.set(fp.sf, "%init.0");
5599
+ continue;
5600
+ }
5601
+ const n = moduleTagNumber(this.stableFileName(fp.sf), initNumbers);
5602
+ initNumbers.add(n);
5603
+ this.initNameOf.set(fp.sf, `%init.${n}`);
5604
+ }
5497
5605
  for (const fp of parts) {
5498
5606
  const rawTag = this.fileTag.get(fp.sf) ?? "";
5499
5607
  const tag = rawTag === "" ? "e." : rawTag.replace(/^%/, "");
@@ -6522,7 +6630,7 @@ export class Lowerer {
6522
6630
  const right = this.mapTypeOf(this.typeOf(e.right));
6523
6631
  const primitive = (t) => t?.kind === "f64" || t?.kind === "string" || t?.kind === "bool";
6524
6632
  if (primitive(left) && primitive(right) && !typeEquals(left, right)) {
6525
- const arms = [left, right].sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
6633
+ const arms = sortArms([left, right]);
6526
6634
  return { kind: "union", unionId: this.unions.intern(arms) };
6527
6635
  }
6528
6636
  return null;
@@ -9212,6 +9320,12 @@ export class Lowerer {
9212
9320
  // becomes its js twin), so coverage's dynamic statements are unchanged.
9213
9321
  if (module && this.dynamicFunctions.length > 0)
9214
9322
  promoteJsvals(module);
9323
+ // The child wrapper a handle-property table asks for must match the
9324
+ // module fact that links scr_child.c (the emitter's childProcess
9325
+ // feature): the census that requests it scans files the program may not
9326
+ // reach. Aligned on the final module, so both sides read one fact.
9327
+ if (module)
9328
+ alignHandlePropertyChildFact(module);
9215
9329
  // A program that replaces a process output stream's write method beside
9216
9330
  // Node islands is refused by the executable planner (SC8006): an
9217
9331
  // island's process.stdout is its own object. Only island builds pay for
@@ -9405,6 +9519,11 @@ export class Lowerer {
9405
9519
  // Establish the same managed header/top-level batch here before
9406
9520
  // collection, while the production path simply finds warm memos.
9407
9521
  this.checker.prefetchSourceFileStructures(parts.map((fp) => fp.sf));
9522
+ // The own-property census decides whether a program's JavaScript may
9523
+ // add properties to a handle. It visits every body, reached or not, so
9524
+ // batch the receiver types it reads before collection; the census then
9525
+ // makes no per-node checker request inside a deferred body.
9526
+ this.checker.prefetchCollectionTypes(handlePropertyScanRoots(parts.map((fp) => fp.sf)));
9408
9527
  // Signature collection may read the initializer type of a default whose
9409
9528
  // body type still admits undefined (for example `value =
9410
9529
  // process.env.VALUE`). The expression executes only when reached, but
@@ -11461,7 +11580,8 @@ export class Lowerer {
11461
11580
  // (constructing a dyn from static values is deliberately out this
11462
11581
  // round; only JSON.parse results are dyn).
11463
11582
  if (actual.kind === "dyn") {
11464
- this.unsupported("SC1100", node, `passing 'unknown' values where '${this.fmt(expected)}' is expected`);
11583
+ this.unsupported("SC1100", node, `passing 'unknown' values where '${this.fmt(expected)}' is expected ` +
11584
+ `(${this.dynCheckBlocker(expected) ?? "this target"} is outside the checked conversion's domain)`);
11465
11585
  }
11466
11586
  if (expected.kind === "dyn") {
11467
11587
  // Function values BOX into dyn when their signature crosses
@@ -11865,33 +11985,10 @@ export class Lowerer {
11865
11985
  // forgiven chains): the VALIDATED extraction — dynCheck, the
11866
11986
  // checked-cast machinery, applied automatically. A value outside the
11867
11987
  // slot's type throws a catchable TypeError instead of misreading the
11868
- // payload. Only dynCheck's own domain (JSON-representable types,
11869
- // undefined-armed unions of those, bytes<u8>, the %Error root)
11870
- // converts; everything else keeps requireExactShape's SC1100 fence.
11988
+ // payload. The domain is EXACTLY the explicit cast's (canDynCheckTo),
11989
+ // so the two crossings can never disagree about what converts;
11990
+ // everything else keeps requireExactShape's SC1100 fence.
11871
11991
  if (expr.type.kind === "dyn" && expected.kind !== "dyn") {
11872
- const undefArmedOk = expected.kind === "union" &&
11873
- (this.unions
11874
- .get(expected.unionId)
11875
- ?.arms.every((a) => a.kind === "undefinedT" ||
11876
- this.jsonSafe(a) ||
11877
- isDynTypedRefType(a) ||
11878
- DYN_HANDLE_KINDS.has(a.kind)) ??
11879
- false);
11880
- const bytesOk = expected.kind === "bytes" && expected.elem === "u8";
11881
- const errorOk = expected.kind === "object" && expected.className === "%Error";
11882
- // Program and runtime class instances can return only from a
11883
- // compiler-owned typed-reference capsule. A parsed/plain dyn object
11884
- // fails the runtime check; an exact capsule unwraps the original
11885
- // instance and preserves identity.
11886
- const classOk = isDynTypedRefType(expected);
11887
- // ADAPTABLE function targets (the checked-dynamic function
11888
- // boundary's OUT direction — `const wrapped: F = mustCall(fn)`):
11889
- // check callable-kind, then unwrap an identical boxed signature
11890
- // directly or adapt through a per-target shim that dynChecks
11891
- // arguments/results per F.
11892
- const funcOk = expected.kind === "func" &&
11893
- canAdaptDynFuncTo(expected, (id) => this.shapes.get(id), (id) => this.unions.get(id));
11894
- const handleOk = DYN_HANDLE_KINDS.has(expected.kind);
11895
11992
  noteUntypedStreamFlow(this, expected);
11896
11993
  // `[EventEmitter]` in JavaScript builds an untyped array of the
11897
11994
  // untyped constructor, which a typed array of the class cannot
@@ -11903,13 +12000,7 @@ export class Lowerer {
11903
12000
  this.pushDiag(unsupportedDiag("SC1090", expr.loc, `holding runtime-provided class values ('${expected.elem.className.slice(1)}') in a typed array`));
11904
12001
  throw new PoisonError();
11905
12002
  }
11906
- if (canDynCheckTo(expected, (id) => this.shapes.get(id), (id) => this.unions.get(id)) ||
11907
- undefArmedOk ||
11908
- bytesOk ||
11909
- errorOk ||
11910
- classOk ||
11911
- funcOk ||
11912
- handleOk) {
12003
+ if (canDynCheckTo(expected, (id) => this.shapes.get(id), (id) => this.unions.get(id))) {
11913
12004
  return { kind: "dynCheck", value: expr, type: expected, loc: expr.loc };
11914
12005
  }
11915
12006
  return expr;
@@ -12369,6 +12460,9 @@ export class Lowerer {
12369
12460
  funcCoerceAdapter(fromT, toT, loc) {
12370
12461
  return funcCoerceAdapter(this, fromT, toT, loc);
12371
12462
  }
12463
+ sortComparatorResultAdapter(fromT, loc) {
12464
+ return sortComparatorResultAdapter(this, fromT, loc);
12465
+ }
12372
12466
  spawnResFnAdapterPlan(fromT, toT) {
12373
12467
  return spawnResFnAdapterPlan(this, fromT, toT);
12374
12468
  }
@@ -13043,6 +13137,65 @@ export class Lowerer {
13043
13137
  return (this.dynConvertible(from) &&
13044
13138
  canDynCheckTo(to, (id) => this.shapes.get(id), (id) => this.unions.get(id)));
13045
13139
  }
13140
+ /** The first reason `t` lies outside the checked conversion's domain
13141
+ * (canDynCheckTo), phrased for a diagnostic; null when it converts. Names
13142
+ * the blocking member rather than restating the whole domain, so an
13143
+ * SC1090/SC1100 fence points at the part that has to change. */
13144
+ dynCheckBlocker(t, seen = new Set()) {
13145
+ const shapes = (id) => this.shapes.get(id);
13146
+ const unions = (id) => this.unions.get(id);
13147
+ if (canDynCheckTo(t, shapes, unions))
13148
+ return null;
13149
+ if (seen.has(typeKey(t)))
13150
+ return `a recursive '${this.fmt(t)}' value`;
13151
+ seen.add(typeKey(t));
13152
+ switch (t.kind) {
13153
+ case "array": {
13154
+ const inner = this.dynCheckBlocker(t.elem, seen);
13155
+ return inner ? `an array whose element is ${inner}` : null;
13156
+ }
13157
+ case "record": {
13158
+ const shape = this.shapes.get(t.shapeId);
13159
+ const field = shape?.fields.find((f) => !canDynCheckTo(f.type, shapes, unions));
13160
+ if (field) {
13161
+ const inner = this.dynCheckBlocker(field.type, seen);
13162
+ return inner
13163
+ ? `a record whose member '${field.name}' is ${inner}`
13164
+ : `a record whose member '${field.name}' is '${this.fmt(field.type)}'`;
13165
+ }
13166
+ if (shape?.indexValue && !canDynCheckTo(shape.indexValue, shapes, unions)) {
13167
+ return `a record whose indexed value is '${this.fmt(shape.indexValue)}'`;
13168
+ }
13169
+ return `a '${this.fmt(t)}' record (a layout a dyn value cannot be checked into)`;
13170
+ }
13171
+ case "func": {
13172
+ const param = t.params.find((p) => p.kind !== "dyn" && !canConvertToDyn(p, shapes, unions));
13173
+ if (param) {
13174
+ return (`a function whose parameter is '${this.fmt(param)}' ` +
13175
+ `(an argument cannot be converted from the dynamic tier)`);
13176
+ }
13177
+ if (t.rest === true && t.restAbi !== undefined && t.params.at(-1)?.kind !== "array") {
13178
+ return `a function whose rest parameter is not an array`;
13179
+ }
13180
+ return `a function returning '${this.fmt(t.ret)}' (a result no checked conversion produces)`;
13181
+ }
13182
+ case "promise": {
13183
+ const inner = this.dynCheckBlocker(t.inner, seen);
13184
+ return inner ? `a promise of ${inner}` : null;
13185
+ }
13186
+ case "union": {
13187
+ const arms = this.unions.get(t.unionId)?.arms ?? [];
13188
+ const arm = arms.find((a) => !isUnitType(a) && !canDynCheckTo(a, shapes, unions));
13189
+ if (arm) {
13190
+ const inner = this.dynCheckBlocker(arm, seen);
13191
+ return inner ? `a union with an arm that is ${inner}` : null;
13192
+ }
13193
+ return `a '${this.fmt(t)}' union`;
13194
+ }
13195
+ default:
13196
+ return `a '${this.fmt(t)}' value`;
13197
+ }
13198
+ }
13046
13199
  /** True when a static type converts to a dyn value (the dynFrom
13047
13200
  * walker's domain): JSON-safe, bytes<u8> (Uint8Array/Buffer — the checked-dynamic tree's
13048
13201
  * bytes kind, payload copied; stdin chunks into unknown-typed helpers),
@@ -13374,7 +13527,7 @@ export class Lowerer {
13374
13527
  * miss (process.env reads). "undefined" sorts last among all arm typeKeys,
13375
13528
  * so the sorted pair is always [t, undefined]. */
13376
13529
  withUndefinedArm(t) {
13377
- const arms = [t, UNDEFINED_T].sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
13530
+ const arms = sortArms([t, UNDEFINED_T]);
13378
13531
  return { kind: "union", unionId: this.unions.intern(arms) };
13379
13532
  }
13380
13533
  paramShape(param) {
@@ -13405,14 +13558,23 @@ export class Lowerer {
13405
13558
  return wrappedUndefined(this, type, loc);
13406
13559
  }
13407
13560
  /** The value an OMITTED or deleted property leaves in a record field
13408
- * slot of `type`: the ABSENT state for undefined-armed unions (the slot
13409
- * reads as undefined but the property does not exist), the dyn
13410
- * undefined for 'unknown' slots, and null when the slot cannot be
13411
- * missing. Only legal as a direct field-slot write (IR fieldAbsent). */
13412
- absentFieldValue(type, loc) {
13561
+ * slot: the ABSENT state for undefined-armed unions (the slot reads as
13562
+ * undefined but the property does not exist), the absent dyn marker for
13563
+ * an OPTIONAL checked-dynamic slot (`optional: true` on the shape field —
13564
+ * an omitted `?: unknown` property is absent, not present-and-undefined),
13565
+ * the dyn undefined for a required 'unknown' slot, and null when the
13566
+ * slot cannot be missing. Pass the shape FIELD when the caller has one:
13567
+ * the bare dyn type cannot tell optional from required. Only legal as a
13568
+ * direct field-slot write (IR fieldAbsent). */
13569
+ absentFieldValue(field, loc) {
13570
+ const type = "kind" in field ? field : field.type;
13571
+ const optional = "kind" in field ? false : field.optional === true;
13413
13572
  if (type.kind === "union" && this.armTag(type.unionId, UNDEFINED_T) >= 0) {
13414
13573
  return { kind: "fieldAbsent", unionId: type.unionId, type, loc };
13415
13574
  }
13575
+ if (type.kind === "dyn" && optional) {
13576
+ return { kind: "fieldAbsent", type, loc };
13577
+ }
13416
13578
  return this.wrappedUndefined(type, loc);
13417
13579
  }
13418
13580
  /** A field copy that keeps absence: `value` (the converted read of
@@ -13420,26 +13582,32 @@ export class Lowerer {
13420
13582
  * property exists, else the target slot's ABSENT state. Fields that are
13421
13583
  * always present, and targets that cannot be absent, copy `value`
13422
13584
  * as-is. Only legal as a direct field-slot write. */
13423
- presenceKeepingCopy(obj, shapeId, field, value, loc) {
13585
+ presenceKeepingCopy(obj, shapeId, field, value, loc,
13586
+ /** The destination field, when the copy changes shape: its optional dyn
13587
+ * flag decides whether an absent source keeps the marker or writes an
13588
+ * ordinary dyn undefined. Defaults to the source field. */
13589
+ target) {
13424
13590
  const present = this.recordFieldPresent(obj, shapeId, field, loc);
13425
13591
  if (present.kind !== "recordHas")
13426
13592
  return value;
13427
- const absent = this.absentFieldValue(value.type, loc);
13593
+ const absent = this.absentFieldValue(target ?? value.type, loc);
13428
13594
  if (absent?.kind !== "fieldAbsent")
13429
13595
  return value;
13430
13596
  return { kind: "ternary", cond: present, then: value, else_: absent, type: value.type, loc };
13431
13597
  }
13432
13598
  /** Own-property presence of declared field `field` on record `obj`
13433
13599
  * (borrowed — callers pass a repeatable receiver): a runtime test for
13434
- * undefined-armed union fields, which can be absent, and `true` for
13435
- * every other declared field. */
13600
+ * undefined-armed union fields and for optional checked-dynamic fields,
13601
+ * which can be absent, and `true` for every other declared field. */
13436
13602
  recordFieldPresent(obj, shapeId, field, loc) {
13437
13603
  // A partial record view (partial-assertions.ts) can lack a field its
13438
13604
  // asserted literal never wrote, whatever the field's required type.
13439
13605
  if (partialAssertionFields(this, shapeId).has(field))
13440
13606
  return { kind: "recordHas", obj, shapeId, field, type: BOOL, loc };
13441
13607
  const f = this.shapes.get(shapeId)?.fields.find((x) => x.name === field);
13442
- if (f && f.type.kind === "union" && this.armTag(f.type.unionId, UNDEFINED_T) >= 0) {
13608
+ if (f &&
13609
+ ((f.type.kind === "union" && this.armTag(f.type.unionId, UNDEFINED_T) >= 0) ||
13610
+ (f.optional === true && f.type.kind === "dyn"))) {
13443
13611
  return { kind: "recordHas", obj, shapeId, field, type: BOOL, loc };
13444
13612
  }
13445
13613
  return { kind: "boolLit", value: true, type: BOOL, loc };
@@ -14169,6 +14337,12 @@ export class Lowerer {
14169
14337
  declareHiddenLocal(name, type) {
14170
14338
  return declareContextLocal(this.ctx, name, type, false, undefined, undefined);
14171
14339
  }
14340
+ /** Read a hidden slot from the current function: the slot itself when it
14341
+ * was declared here, a threaded capture when the read sits in a function
14342
+ * the declaring one encloses. Null when the owner context is gone. */
14343
+ captureHiddenLocal(local, owner) {
14344
+ return captureContextLocal(this.fnStack, local, owner);
14345
+ }
14172
14346
  /** The body binding of a fixed-tuple rest parameter: one native slot per
14173
14347
  * position (the flattened ABI), rebuilt into the tuple the source names.
14174
14348
  * The empty tuple rides the empty-array representation. */
@@ -14832,6 +15006,12 @@ export class Lowerer {
14832
15006
  lowerDestructuringAssignParts(target, rhs, loc) {
14833
15007
  return lowerDestructuringAssignParts(this, target, rhs, loc);
14834
15008
  }
15009
+ /** The asserted-only member answer (lower-stmts.ts): the value one
15010
+ * element reads from a record shape for a property only an asserted
15011
+ * intersection declares, answered from the shape's kept source. */
15012
+ assertedOnlyFieldRead(propName, srcType, srcRef, bodyT, loc) {
15013
+ return assertedOnlyFieldRead(this, propName, srcType, srcRef, bodyT, loc);
15014
+ }
14835
15015
  lowerBindingPattern(pattern, srcRef, srcType, isLet, out, dynSpell, allowDynObject = false) {
14836
15016
  if (ts.isObjectBindingPattern(pattern)) {
14837
15017
  fenceFetchObjectBinding(this, pattern);
@@ -15772,6 +15952,11 @@ export class Lowerer {
15772
15952
  (bi.member === "posix" || bi.member === "win32")) {
15773
15953
  return pathModuleValue(this, `path/${bi.member}`, loc);
15774
15954
  }
15955
+ // url.Url as a value: the legacy Url constructor (JavaScript sources;
15956
+ // @types/node declares Url as a type only). Its prototype is the one
15957
+ // url.parse() results carry.
15958
+ if (bi.module === "url" && bi.member === "Url")
15959
+ return legacyUrlClassValue(loc);
15775
15960
  // events.defaultMaxListeners READS the process-wide default (its
15776
15961
  // write twin routes through emitter.setDefaultMaxChk). Through an ES
15777
15962
  // module namespace it reads the namespace's copy instead.
@@ -15889,22 +16074,81 @@ export class Lowerer {
15889
16074
  return lowerSystemErrorMapValue(this, loc);
15890
16075
  if (bi.module === "fs" &&
15891
16076
  builtinModuleFnOf(this, bi.module, bi.member)?.fn === "fs.callbackCall") {
15892
- return {
15893
- kind: "libCall",
15894
- fn: "fs.callbackValue",
15895
- args: [{ kind: "strLit", value: bi.member, type: STRING, loc }],
15896
- type: DYN,
15897
- loc,
15898
- };
16077
+ return this.lowerFsCallbackValue(bi.member, loc);
15899
16078
  }
15900
16079
  // The buffer module's Buffer is the global constructor's value.
15901
16080
  if (bi.module === "buffer" && bi.member === "Buffer")
15902
16081
  return { kind: "libCall", fn: "buffer.constructor", args: [], type: DYN, loc };
15903
16082
  if (bi.module === "fs" && (bi.member === "realpathSync" || bi.member === "realpathSync.native"))
15904
16083
  return fsRealpathValue(this, bi.member === "realpathSync.native", loc);
16084
+ if (bi.module === "zlib") {
16085
+ const mode = ZLIB_STREAM_FACTORIES[bi.member];
16086
+ if (mode !== undefined)
16087
+ return this.lowerZlibStreamFactoryValue(bi.member, mode, loc);
16088
+ }
15905
16089
  const fn = builtinModuleFnOf(this, bi.module, bi.member);
15906
16090
  return fn ? this.lowerNativeCallableValue(fn, `${bi.module}.${bi.member}`, loc) : null;
15907
16091
  }
16092
+ /** An error-first filesystem function as a value: the checked-dynamic
16093
+ * function the runtime dispatches every argument through, carrying Node's
16094
+ * own name and length for the member. */
16095
+ lowerFsCallbackValue(member, loc) {
16096
+ return {
16097
+ kind: "libCall",
16098
+ fn: "fs.callbackValue",
16099
+ args: [
16100
+ { kind: "strLit", value: member, type: STRING, loc },
16101
+ numLit(FS_CALLBACK_VALUE_LENGTHS[member] ?? 0, loc),
16102
+ ],
16103
+ type: DYN,
16104
+ loc,
16105
+ };
16106
+ }
16107
+ /** A zlib stream factory as a value: the options argument reaches the
16108
+ * same runtime constructor the direct call uses, and the value keeps
16109
+ * Node's name and length. */
16110
+ lowerZlibStreamFactoryValue(member, mode, loc) {
16111
+ // The value is called later, often with no other Brotli or zstd call in
16112
+ // the program: connect the codec at the point the factory is read, the
16113
+ // same way a direct call does.
16114
+ noteCodecMode(this, mode, loc);
16115
+ const key = `zlib.streamNew:${member}`;
16116
+ let fnName = this.builtinCallableValueFns.get(key);
16117
+ if (!fnName) {
16118
+ fnName = keyedHelperName(this, "%builtin.value.zlib.streamNew", key);
16119
+ this.builtinCallableValueFns.set(key, fnName);
16120
+ this.builtinCallableValueNames.set(fnName, member);
16121
+ this.builtinCallableValueLengths.set(fnName, 1);
16122
+ const options = { localId: "options.0", name: "options", type: DYN };
16123
+ this.liftedFns.push({
16124
+ name: fnName,
16125
+ params: [options],
16126
+ returnType: ZLIB_STREAM_T,
16127
+ locals: [{ id: options.localId, name: options.name, type: options.type, mutable: false }],
16128
+ body: [
16129
+ {
16130
+ kind: "return",
16131
+ value: {
16132
+ kind: "libCall",
16133
+ fn: "zlib.streamNew",
16134
+ args: [numLit(mode, loc), varRef(options.localId, DYN, loc)],
16135
+ type: ZLIB_STREAM_T,
16136
+ loc,
16137
+ },
16138
+ loc,
16139
+ },
16140
+ ],
16141
+ loc,
16142
+ });
16143
+ }
16144
+ return {
16145
+ kind: "closure",
16146
+ fnName,
16147
+ captures: [],
16148
+ type: { kind: "func", params: [DYN], ret: ZLIB_STREAM_T },
16149
+ loc,
16150
+ };
16151
+ }
15908
16152
  lowerNativeCallableValue(fn, display, loc) {
15909
16153
  const valueParams = fn.valueParams;
15910
16154
  if (!valueParams)
@@ -16200,8 +16444,11 @@ export class Lowerer {
16200
16444
  lowerProcessStreamProperty(expr) {
16201
16445
  return lowerProcessStreamProperty(this, expr);
16202
16446
  }
16447
+ /** Whether `node` is the ambient `process.env` object a receiver names:
16448
+ * parentheses and the erased wrappers (`as`, `!`, `satisfies`) are looked
16449
+ * through (environment.ts). */
16203
16450
  isProcessEnv(node) {
16204
- return isProcessEnv(this, node);
16451
+ return isAmbientProcessEnv(this, node);
16205
16452
  }
16206
16453
  envValueType() {
16207
16454
  return envValueType(this);