@geastack/compiler 1.0.15

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 (966) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +149 -0
  3. package/dist/cli-analyze.d.ts +1 -0
  4. package/dist/cli-analyze.js +61 -0
  5. package/dist/cli-coverage.d.ts +1 -0
  6. package/dist/cli-coverage.js +329 -0
  7. package/dist/cli-emit.d.ts +10 -0
  8. package/dist/cli-emit.js +398 -0
  9. package/dist/cli-module-graph.d.ts +18 -0
  10. package/dist/cli-module-graph.js +123 -0
  11. package/dist/cli-package-source.d.ts +5 -0
  12. package/dist/cli-package-source.js +116 -0
  13. package/dist/cli-project.d.ts +2 -0
  14. package/dist/cli-project.js +60 -0
  15. package/dist/cli.d.ts +2 -0
  16. package/dist/cli.js +199 -0
  17. package/dist/compiler.d.ts +228 -0
  18. package/dist/compiler.js +1029 -0
  19. package/dist/conversion/algebra.d.ts +218 -0
  20. package/dist/conversion/algebra.js +155 -0
  21. package/dist/conversion/build.d.ts +67 -0
  22. package/dist/conversion/build.js +1378 -0
  23. package/dist/conversion/derive.d.ts +37 -0
  24. package/dist/conversion/derive.js +260 -0
  25. package/dist/conversion/graph-validation.d.ts +8 -0
  26. package/dist/conversion/graph-validation.js +97 -0
  27. package/dist/conversion/native-callable-adapter.d.ts +13 -0
  28. package/dist/conversion/native-callable-adapter.js +53 -0
  29. package/dist/conversion/native-class-reference.d.ts +12 -0
  30. package/dist/conversion/native-class-reference.js +39 -0
  31. package/dist/conversion/native-payload-transport.d.ts +25 -0
  32. package/dist/conversion/native-payload-transport.js +33 -0
  33. package/dist/conversion/native-selection.d.ts +49 -0
  34. package/dist/conversion/native-selection.js +135 -0
  35. package/dist/conversion/native-sum.d.ts +42 -0
  36. package/dist/conversion/native-sum.js +115 -0
  37. package/dist/conversion/nodes.d.ts +55 -0
  38. package/dist/conversion/nodes.js +91 -0
  39. package/dist/conversion/operand-view.d.ts +14 -0
  40. package/dist/conversion/operand-view.js +20 -0
  41. package/dist/conversion/record-view.d.ts +157 -0
  42. package/dist/conversion/record-view.js +273 -0
  43. package/dist/conversion/registry.d.ts +217 -0
  44. package/dist/conversion/registry.js +1 -0
  45. package/dist/diagnostics/model.d.ts +76 -0
  46. package/dist/diagnostics/model.js +60 -0
  47. package/dist/diagnostics/sweep.d.ts +31 -0
  48. package/dist/diagnostics/sweep.js +112 -0
  49. package/dist/identity/ids.d.ts +179 -0
  50. package/dist/identity/ids.js +212 -0
  51. package/dist/ir/absent-class-arm.d.ts +48 -0
  52. package/dist/ir/absent-class-arm.js +157 -0
  53. package/dist/ir/borrow-effects.d.ts +23 -0
  54. package/dist/ir/borrow-effects.js +151 -0
  55. package/dist/ir/borrowed-call-arguments.d.ts +40 -0
  56. package/dist/ir/borrowed-call-arguments.js +117 -0
  57. package/dist/ir/build.d.ts +168 -0
  58. package/dist/ir/build.js +459 -0
  59. package/dist/ir/call-dispatch.d.ts +38 -0
  60. package/dist/ir/call-dispatch.js +502 -0
  61. package/dist/ir/call-entry.d.ts +142 -0
  62. package/dist/ir/call-entry.js +386 -0
  63. package/dist/ir/callable-class-flow.d.ts +27 -0
  64. package/dist/ir/callable-class-flow.js +1386 -0
  65. package/dist/ir/callable-field-slots.d.ts +22 -0
  66. package/dist/ir/callable-field-slots.js +166 -0
  67. package/dist/ir/callable-identity-demand.d.ts +52 -0
  68. package/dist/ir/callable-identity-demand.js +460 -0
  69. package/dist/ir/callable-member-candidates.d.ts +9 -0
  70. package/dist/ir/callable-member-candidates.js +39 -0
  71. package/dist/ir/callable-records.d.ts +21 -0
  72. package/dist/ir/callable-records.js +411 -0
  73. package/dist/ir/captures.d.ts +26 -0
  74. package/dist/ir/captures.js +335 -0
  75. package/dist/ir/certificate.d.ts +45 -0
  76. package/dist/ir/certificate.js +47 -0
  77. package/dist/ir/certify/carrier-keys.d.ts +73 -0
  78. package/dist/ir/certify/carrier-keys.js +221 -0
  79. package/dist/ir/certify/function-source.d.ts +4 -0
  80. package/dist/ir/certify/function-source.js +28 -0
  81. package/dist/ir/certify/has-property-key.d.ts +88 -0
  82. package/dist/ir/certify/has-property-key.js +116 -0
  83. package/dist/ir/certify/instanceof-key.d.ts +24 -0
  84. package/dist/ir/certify/instanceof-key.js +35 -0
  85. package/dist/ir/certify/property-access-keys.d.ts +172 -0
  86. package/dist/ir/certify/property-access-keys.js +291 -0
  87. package/dist/ir/certify/property-access.d.ts +3 -0
  88. package/dist/ir/certify/property-access.js +597 -0
  89. package/dist/ir/certify/runtime-helper.d.ts +3 -0
  90. package/dist/ir/certify/runtime-helper.js +326 -0
  91. package/dist/ir/certify/typeof-operand.d.ts +14 -0
  92. package/dist/ir/certify/typeof-operand.js +16 -0
  93. package/dist/ir/certify.d.ts +123 -0
  94. package/dist/ir/certify.js +481 -0
  95. package/dist/ir/class-evaluation.d.ts +26 -0
  96. package/dist/ir/class-evaluation.js +50 -0
  97. package/dist/ir/class-static-fields.d.ts +60 -0
  98. package/dist/ir/class-static-fields.js +108 -0
  99. package/dist/ir/construct-entry.d.ts +26 -0
  100. package/dist/ir/construct-entry.js +117 -0
  101. package/dist/ir/dead-values.d.ts +90 -0
  102. package/dist/ir/dead-values.js +184 -0
  103. package/dist/ir/deferral.d.ts +99 -0
  104. package/dist/ir/deferral.js +409 -0
  105. package/dist/ir/dense-loops.d.ts +230 -0
  106. package/dist/ir/dense-loops.js +697 -0
  107. package/dist/ir/dominance.d.ts +82 -0
  108. package/dist/ir/dominance.js +268 -0
  109. package/dist/ir/emission-representations.d.ts +71 -0
  110. package/dist/ir/emission-representations.js +350 -0
  111. package/dist/ir/facts.d.ts +218 -0
  112. package/dist/ir/facts.js +181 -0
  113. package/dist/ir/fixed-data-definition.d.ts +19 -0
  114. package/dist/ir/fixed-data-definition.js +49 -0
  115. package/dist/ir/generator-split.d.ts +38 -0
  116. package/dist/ir/generator-split.js +329 -0
  117. package/dist/ir/hoist.d.ts +55 -0
  118. package/dist/ir/hoist.js +375 -0
  119. package/dist/ir/instantiation.d.ts +61 -0
  120. package/dist/ir/instantiation.js +137 -0
  121. package/dist/ir/integer-storage.d.ts +170 -0
  122. package/dist/ir/integer-storage.js +822 -0
  123. package/dist/ir/integers.d.ts +161 -0
  124. package/dist/ir/integers.js +539 -0
  125. package/dist/ir/integrity-restrictions.d.ts +50 -0
  126. package/dist/ir/integrity-restrictions.js +118 -0
  127. package/dist/ir/local-iterators.d.ts +4 -0
  128. package/dist/ir/local-iterators.js +27 -0
  129. package/dist/ir/lower-allocation.d.ts +4 -0
  130. package/dist/ir/lower-allocation.js +325 -0
  131. package/dist/ir/lower-completion.d.ts +15 -0
  132. package/dist/ir/lower-completion.js +25 -0
  133. package/dist/ir/lower-destructuring.d.ts +5 -0
  134. package/dist/ir/lower-destructuring.js +693 -0
  135. package/dist/ir/lower-element.d.ts +29 -0
  136. package/dist/ir/lower-element.js +111 -0
  137. package/dist/ir/lower-exceptions.d.ts +47 -0
  138. package/dist/ir/lower-exceptions.js +92 -0
  139. package/dist/ir/lower-flow.d.ts +137 -0
  140. package/dist/ir/lower-flow.js +600 -0
  141. package/dist/ir/lower-graph.d.ts +218 -0
  142. package/dist/ir/lower-graph.js +687 -0
  143. package/dist/ir/lower-invocation.d.ts +4 -0
  144. package/dist/ir/lower-invocation.js +514 -0
  145. package/dist/ir/lower-narrow.d.ts +53 -0
  146. package/dist/ir/lower-narrow.js +320 -0
  147. package/dist/ir/lower-operands.d.ts +272 -0
  148. package/dist/ir/lower-operands.js +461 -0
  149. package/dist/ir/lower-property.d.ts +21 -0
  150. package/dist/ir/lower-property.js +132 -0
  151. package/dist/ir/lower-protocol.d.ts +11 -0
  152. package/dist/ir/lower-protocol.js +118 -0
  153. package/dist/ir/lower-short-circuit.d.ts +41 -0
  154. package/dist/ir/lower-short-circuit.js +63 -0
  155. package/dist/ir/lower.d.ts +82 -0
  156. package/dist/ir/lower.js +1346 -0
  157. package/dist/ir/model.d.ts +1474 -0
  158. package/dist/ir/model.js +6 -0
  159. package/dist/ir/native-absent-property.d.ts +3 -0
  160. package/dist/ir/native-absent-property.js +13 -0
  161. package/dist/ir/native-array-transport.d.ts +7 -0
  162. package/dist/ir/native-array-transport.js +46 -0
  163. package/dist/ir/native-callable-bind.d.ts +9 -0
  164. package/dist/ir/native-callable-bind.js +30 -0
  165. package/dist/ir/native-carrier-predicate.d.ts +34 -0
  166. package/dist/ir/native-carrier-predicate.js +49 -0
  167. package/dist/ir/native-class-accessor.d.ts +18 -0
  168. package/dist/ir/native-class-accessor.js +52 -0
  169. package/dist/ir/native-class-construction.d.ts +16 -0
  170. package/dist/ir/native-class-construction.js +71 -0
  171. package/dist/ir/native-class-initialization.d.ts +15 -0
  172. package/dist/ir/native-class-initialization.js +56 -0
  173. package/dist/ir/native-class-origins.d.ts +13 -0
  174. package/dist/ir/native-class-origins.js +237 -0
  175. package/dist/ir/native-dictionary-transport.d.ts +6 -0
  176. package/dist/ir/native-dictionary-transport.js +37 -0
  177. package/dist/ir/native-enumeration.d.ts +14 -0
  178. package/dist/ir/native-enumeration.js +26 -0
  179. package/dist/ir/native-equality.d.ts +10 -0
  180. package/dist/ir/native-equality.js +18 -0
  181. package/dist/ir/native-field-owner.d.ts +37 -0
  182. package/dist/ir/native-field-owner.js +183 -0
  183. package/dist/ir/native-fixed-layout.d.ts +41 -0
  184. package/dist/ir/native-fixed-layout.js +232 -0
  185. package/dist/ir/native-host-construction.d.ts +53 -0
  186. package/dist/ir/native-host-construction.js +62 -0
  187. package/dist/ir/native-key-query.d.ts +4 -0
  188. package/dist/ir/native-key-query.js +38 -0
  189. package/dist/ir/native-merge-transport.d.ts +25 -0
  190. package/dist/ir/native-merge-transport.js +71 -0
  191. package/dist/ir/native-record-index-transport.d.ts +11 -0
  192. package/dist/ir/native-record-index-transport.js +34 -0
  193. package/dist/ir/native-record-index.d.ts +12 -0
  194. package/dist/ir/native-record-index.js +27 -0
  195. package/dist/ir/native-reflect-field.d.ts +5 -0
  196. package/dist/ir/native-reflect-field.js +33 -0
  197. package/dist/ir/native-sequence-transport.d.ts +7 -0
  198. package/dist/ir/native-sequence-transport.js +53 -0
  199. package/dist/ir/numeric-intrinsics.d.ts +13 -0
  200. package/dist/ir/numeric-intrinsics.js +57 -0
  201. package/dist/ir/object-value-conversions.d.ts +20 -0
  202. package/dist/ir/object-value-conversions.js +50 -0
  203. package/dist/ir/physical-class-reflection.d.ts +9 -0
  204. package/dist/ir/physical-class-reflection.js +57 -0
  205. package/dist/ir/presence-proof.d.ts +42 -0
  206. package/dist/ir/presence-proof.js +490 -0
  207. package/dist/ir/program-facts.d.ts +106 -0
  208. package/dist/ir/program-facts.js +319 -0
  209. package/dist/ir/proven-branches.d.ts +16 -0
  210. package/dist/ir/proven-branches.js +219 -0
  211. package/dist/ir/queries.d.ts +41 -0
  212. package/dist/ir/queries.js +213 -0
  213. package/dist/ir/reflection-demand.d.ts +64 -0
  214. package/dist/ir/reflection-demand.js +1394 -0
  215. package/dist/ir/refusal.d.ts +43 -0
  216. package/dist/ir/refusal.js +28 -0
  217. package/dist/ir/shake.d.ts +37 -0
  218. package/dist/ir/shake.js +1078 -0
  219. package/dist/ir/static-callables.d.ts +11 -0
  220. package/dist/ir/static-callables.js +163 -0
  221. package/dist/ir/string-layout-reuse.d.ts +13 -0
  222. package/dist/ir/string-layout-reuse.js +39 -0
  223. package/dist/ir/string-length-reuse.d.ts +8 -0
  224. package/dist/ir/string-length-reuse.js +47 -0
  225. package/dist/ir/transfer.d.ts +78 -0
  226. package/dist/ir/transfer.js +270 -0
  227. package/dist/ir/type-query-results.d.ts +25 -0
  228. package/dist/ir/type-query-results.js +96 -0
  229. package/dist/ir/typed-property-access.d.ts +100 -0
  230. package/dist/ir/typed-property-access.js +161 -0
  231. package/dist/ir/verify.d.ts +19 -0
  232. package/dist/ir/verify.js +355 -0
  233. package/dist/plugins/apple/constructors.d.ts +112 -0
  234. package/dist/plugins/apple/constructors.js +217 -0
  235. package/dist/plugins/apple/host.d.ts +181 -0
  236. package/dist/plugins/apple/host.js +262 -0
  237. package/dist/plugins/apple/jsx.d.ts +2 -0
  238. package/dist/plugins/apple/jsx.js +293 -0
  239. package/dist/plugins/apple/members.d.ts +16 -0
  240. package/dist/plugins/apple/members.js +190 -0
  241. package/dist/plugins/apple/plugin.d.ts +2 -0
  242. package/dist/plugins/apple/plugin.js +156 -0
  243. package/dist/plugins/gea/component-classes.d.ts +25 -0
  244. package/dist/plugins/gea/component-classes.js +162 -0
  245. package/dist/plugins/gea/component-inline.d.ts +13 -0
  246. package/dist/plugins/gea/component-inline.js +532 -0
  247. package/dist/plugins/gea/constructors.d.ts +23 -0
  248. package/dist/plugins/gea/constructors.js +100 -0
  249. package/dist/plugins/gea/contract.d.ts +150 -0
  250. package/dist/plugins/gea/contract.js +195 -0
  251. package/dist/plugins/gea/element-ref.d.ts +31 -0
  252. package/dist/plugins/gea/element-ref.js +45 -0
  253. package/dist/plugins/gea/host.d.ts +520 -0
  254. package/dist/plugins/gea/host.js +762 -0
  255. package/dist/plugins/gea/lower.d.ts +6 -0
  256. package/dist/plugins/gea/lower.js +195 -0
  257. package/dist/plugins/gea/members.d.ts +22 -0
  258. package/dist/plugins/gea/members.js +221 -0
  259. package/dist/plugins/gea/plugin.d.ts +22 -0
  260. package/dist/plugins/gea/plugin.js +307 -0
  261. package/dist/plugins/gea/prelude.d.ts +78 -0
  262. package/dist/plugins/gea/prelude.js +153 -0
  263. package/dist/plugins/gea/producer.d.ts +5 -0
  264. package/dist/plugins/gea/producer.js +52 -0
  265. package/dist/plugins/gea/reactive-slots.d.ts +49 -0
  266. package/dist/plugins/gea/reactive-slots.js +578 -0
  267. package/dist/plugins/gea/render-bridge.d.ts +6 -0
  268. package/dist/plugins/gea/render-bridge.js +281 -0
  269. package/dist/plugins/gea/slots.d.ts +15 -0
  270. package/dist/plugins/gea/slots.js +36 -0
  271. package/dist/plugins/gea/template-analysis.d.ts +151 -0
  272. package/dist/plugins/gea/template-analysis.js +346 -0
  273. package/dist/plugins/gea/user-agent-styles.d.ts +9 -0
  274. package/dist/plugins/gea/user-agent-styles.js +94 -0
  275. package/dist/plugins/installed.d.ts +19 -0
  276. package/dist/plugins/installed.js +21 -0
  277. package/dist/plugins/load.d.ts +7 -0
  278. package/dist/plugins/load.js +207 -0
  279. package/dist/plugins/model.d.ts +735 -0
  280. package/dist/plugins/model.js +47 -0
  281. package/dist/plugins/webgl/host.d.ts +77 -0
  282. package/dist/plugins/webgl/host.js +162 -0
  283. package/dist/plugins/webgl/plugin.d.ts +40 -0
  284. package/dist/plugins/webgl/plugin.js +99 -0
  285. package/dist/preflight/obligations.d.ts +206 -0
  286. package/dist/preflight/obligations.js +36 -0
  287. package/dist/preflight/report.d.ts +20 -0
  288. package/dist/preflight/report.js +61 -0
  289. package/dist/preflight/run.d.ts +39 -0
  290. package/dist/preflight/run.js +403 -0
  291. package/dist/project-preparation.d.ts +33 -0
  292. package/dist/project-preparation.js +314 -0
  293. package/dist/projection/abi.d.ts +82 -0
  294. package/dist/projection/abi.js +349 -0
  295. package/dist/projection/apply-arguments.d.ts +12 -0
  296. package/dist/projection/apply-arguments.js +20 -0
  297. package/dist/projection/bindings.d.ts +250 -0
  298. package/dist/projection/bindings.js +340 -0
  299. package/dist/projection/callee.d.ts +196 -0
  300. package/dist/projection/callee.js +444 -0
  301. package/dist/projection/class-property-presence.d.ts +28 -0
  302. package/dist/projection/class-property-presence.js +58 -0
  303. package/dist/projection/class-prototype.d.ts +5 -0
  304. package/dist/projection/class-prototype.js +23 -0
  305. package/dist/projection/class-storage.d.ts +26 -0
  306. package/dist/projection/class-storage.js +236 -0
  307. package/dist/projection/classes.d.ts +283 -0
  308. package/dist/projection/classes.js +944 -0
  309. package/dist/projection/coercions.d.ts +20 -0
  310. package/dist/projection/coercions.js +33 -0
  311. package/dist/projection/dispatch.d.ts +167 -0
  312. package/dist/projection/dispatch.js +379 -0
  313. package/dist/projection/fields.d.ts +123 -0
  314. package/dist/projection/fields.js +383 -0
  315. package/dist/projection/instance-test.d.ts +78 -0
  316. package/dist/projection/instance-test.js +156 -0
  317. package/dist/projection/slots.d.ts +146 -0
  318. package/dist/projection/slots.js +663 -0
  319. package/dist/projection/synthesized-abi.d.ts +61 -0
  320. package/dist/projection/synthesized-abi.js +94 -0
  321. package/dist/representation/array-index.d.ts +14 -0
  322. package/dist/representation/array-index.js +17 -0
  323. package/dist/representation/callable-object.d.ts +3 -0
  324. package/dist/representation/callable-object.js +6 -0
  325. package/dist/representation/collections.d.ts +84 -0
  326. package/dist/representation/collections.js +139 -0
  327. package/dist/representation/derive.d.ts +159 -0
  328. package/dist/representation/derive.js +2546 -0
  329. package/dist/representation/difference.d.ts +30 -0
  330. package/dist/representation/difference.js +240 -0
  331. package/dist/representation/field-descriptor-policy.d.ts +19 -0
  332. package/dist/representation/field-descriptor-policy.js +39 -0
  333. package/dist/representation/function-constructor.d.ts +13 -0
  334. package/dist/representation/function-constructor.js +9 -0
  335. package/dist/representation/host-abi.d.ts +32 -0
  336. package/dist/representation/host-abi.js +97 -0
  337. package/dist/representation/host-templates.d.ts +67 -0
  338. package/dist/representation/host-templates.js +94 -0
  339. package/dist/representation/intersection.d.ts +84 -0
  340. package/dist/representation/intersection.js +149 -0
  341. package/dist/representation/literal-destination.d.ts +43 -0
  342. package/dist/representation/literal-destination.js +133 -0
  343. package/dist/representation/merge.d.ts +18 -0
  344. package/dist/representation/merge.js +83 -0
  345. package/dist/representation/model.d.ts +1160 -0
  346. package/dist/representation/model.js +1019 -0
  347. package/dist/representation/numeric-index.d.ts +13 -0
  348. package/dist/representation/numeric-index.js +29 -0
  349. package/dist/representation/object-shape.d.ts +109 -0
  350. package/dist/representation/object-shape.js +123 -0
  351. package/dist/representation/optional.d.ts +12 -0
  352. package/dist/representation/optional.js +87 -0
  353. package/dist/representation/plan.d.ts +60 -0
  354. package/dist/representation/plan.js +78 -0
  355. package/dist/representation/policies.d.ts +589 -0
  356. package/dist/representation/policies.js +107 -0
  357. package/dist/representation/primitive-domain.d.ts +1 -0
  358. package/dist/representation/primitive-domain.js +1 -0
  359. package/dist/representation/primitives.d.ts +44 -0
  360. package/dist/representation/primitives.js +78 -0
  361. package/dist/representation/publish.d.ts +49 -0
  362. package/dist/representation/publish.js +648 -0
  363. package/dist/representation/record-fields.d.ts +96 -0
  364. package/dist/representation/record-fields.js +116 -0
  365. package/dist/representation/template-object.d.ts +11 -0
  366. package/dist/representation/template-object.js +26 -0
  367. package/dist/representation/union.d.ts +30 -0
  368. package/dist/representation/union.js +324 -0
  369. package/dist/representation/value-records.d.ts +3 -0
  370. package/dist/representation/value-records.js +307 -0
  371. package/dist/representation/verify.d.ts +17 -0
  372. package/dist/representation/verify.js +221 -0
  373. package/dist/semantics/alias-this-field-declaration-transform.d.ts +4 -0
  374. package/dist/semantics/alias-this-field-declaration-transform.js +207 -0
  375. package/dist/semantics/ambient-type-realization-transform.d.ts +62 -0
  376. package/dist/semantics/ambient-type-realization-transform.js +168 -0
  377. package/dist/semantics/ambient.d.ts +24 -0
  378. package/dist/semantics/ambient.js +119 -0
  379. package/dist/semantics/borrowed-builtin-call-bind-source-transform.d.ts +4 -0
  380. package/dist/semantics/borrowed-builtin-call-bind-source-transform.js +341 -0
  381. package/dist/semantics/callable-origins.d.ts +46 -0
  382. package/dist/semantics/callable-origins.js +354 -0
  383. package/dist/semantics/class-alias.d.ts +7 -0
  384. package/dist/semantics/class-alias.js +37 -0
  385. package/dist/semantics/class-heritage.d.ts +34 -0
  386. package/dist/semantics/class-heritage.js +104 -0
  387. package/dist/semantics/commonjs-wrapper.d.ts +69 -0
  388. package/dist/semantics/commonjs-wrapper.js +231 -0
  389. package/dist/semantics/constructor-slot-subclasses.d.ts +28 -0
  390. package/dist/semantics/constructor-slot-subclasses.js +112 -0
  391. package/dist/semantics/declaration-overlay-transform.d.ts +35 -0
  392. package/dist/semantics/declaration-overlay-transform.js +2157 -0
  393. package/dist/semantics/define-property-source-transform.d.ts +4 -0
  394. package/dist/semantics/define-property-source-transform.js +437 -0
  395. package/dist/semantics/diagnostic-source-preparation.d.ts +24 -0
  396. package/dist/semantics/diagnostic-source-preparation.js +82 -0
  397. package/dist/semantics/documentation-ranges.d.ts +22 -0
  398. package/dist/semantics/documentation-ranges.js +36 -0
  399. package/dist/semantics/dynamic-fallback.d.ts +86 -0
  400. package/dist/semantics/dynamic-fallback.js +249 -0
  401. package/dist/semantics/frontend-timing.d.ts +6 -0
  402. package/dist/semantics/frontend-timing.js +35 -0
  403. package/dist/semantics/frontend.d.ts +504 -0
  404. package/dist/semantics/frontend.js +1157 -0
  405. package/dist/semantics/host-declaration-provenance.d.ts +11 -0
  406. package/dist/semantics/host-declaration-provenance.js +18 -0
  407. package/dist/semantics/host-methods.d.ts +24 -0
  408. package/dist/semantics/host-methods.js +74 -0
  409. package/dist/semantics/host-protocols.d.ts +429 -0
  410. package/dist/semantics/host-protocols.js +1501 -0
  411. package/dist/semantics/inherited-accessor.d.ts +7 -0
  412. package/dist/semantics/inherited-accessor.js +48 -0
  413. package/dist/semantics/interface-families.d.ts +70 -0
  414. package/dist/semantics/interface-families.js +180 -0
  415. package/dist/semantics/interface-implementors.d.ts +53 -0
  416. package/dist/semantics/interface-implementors.js +87 -0
  417. package/dist/semantics/jsdoc-namepath-transform.d.ts +4 -0
  418. package/dist/semantics/jsdoc-namepath-transform.js +85 -0
  419. package/dist/semantics/model/coverage.d.ts +68 -0
  420. package/dist/semantics/model/coverage.js +73 -0
  421. package/dist/semantics/model/edges.d.ts +103 -0
  422. package/dist/semantics/model/edges.js +20 -0
  423. package/dist/semantics/model/graph.d.ts +55 -0
  424. package/dist/semantics/model/graph.js +129 -0
  425. package/dist/semantics/model/operands.d.ts +159 -0
  426. package/dist/semantics/model/operands.js +26 -0
  427. package/dist/semantics/model/operations.d.ts +496 -0
  428. package/dist/semantics/model/operations.js +2 -0
  429. package/dist/semantics/model/primitive-domain.d.ts +26 -0
  430. package/dist/semantics/model/primitive-domain.js +38 -0
  431. package/dist/semantics/model/selected-signature.d.ts +261 -0
  432. package/dist/semantics/model/selected-signature.js +55 -0
  433. package/dist/semantics/model/structural-type-table.d.ts +93 -0
  434. package/dist/semantics/model/structural-type-table.js +237 -0
  435. package/dist/semantics/model/structural-types.d.ts +367 -0
  436. package/dist/semantics/model/structural-types.js +200 -0
  437. package/dist/semantics/module-resolution.d.ts +23 -0
  438. package/dist/semantics/module-resolution.js +227 -0
  439. package/dist/semantics/new-callee-class-tag-source-transform.d.ts +4 -0
  440. package/dist/semantics/new-callee-class-tag-source-transform.js +64 -0
  441. package/dist/semantics/node-project.d.ts +13 -0
  442. package/dist/semantics/node-project.js +107 -0
  443. package/dist/semantics/node-source-hooks.d.ts +1 -0
  444. package/dist/semantics/node-source-hooks.js +63 -0
  445. package/dist/semantics/normalize/absent-globals.d.ts +143 -0
  446. package/dist/semantics/normalize/absent-globals.js +191 -0
  447. package/dist/semantics/normalize/arguments-objects.d.ts +43 -0
  448. package/dist/semantics/normalize/arguments-objects.js +60 -0
  449. package/dist/semantics/normalize/asserted-arm-absence.d.ts +28 -0
  450. package/dist/semantics/normalize/asserted-arm-absence.js +61 -0
  451. package/dist/semantics/normalize/assignment-patterns.d.ts +70 -0
  452. package/dist/semantics/normalize/assignment-patterns.js +147 -0
  453. package/dist/semantics/normalize/bag-absence.d.ts +8 -0
  454. package/dist/semantics/normalize/bag-absence.js +42 -0
  455. package/dist/semantics/normalize/binding-fixpoint.d.ts +36 -0
  456. package/dist/semantics/normalize/binding-fixpoint.js +140 -0
  457. package/dist/semantics/normalize/callback-parameter-contracts.d.ts +16 -0
  458. package/dist/semantics/normalize/callback-parameter-contracts.js +91 -0
  459. package/dist/semantics/normalize/cells/agreement.d.ts +46 -0
  460. package/dist/semantics/normalize/cells/agreement.js +34 -0
  461. package/dist/semantics/normalize/cells/candidates.d.ts +17 -0
  462. package/dist/semantics/normalize/cells/candidates.js +35 -0
  463. package/dist/semantics/normalize/cells/facts.d.ts +19 -0
  464. package/dist/semantics/normalize/cells/facts.js +90 -0
  465. package/dist/semantics/normalize/cells/index.d.ts +10 -0
  466. package/dist/semantics/normalize/cells/index.js +6 -0
  467. package/dist/semantics/normalize/cells/model.d.ts +98 -0
  468. package/dist/semantics/normalize/cells/model.js +2 -0
  469. package/dist/semantics/normalize/cells/policies/bag.d.ts +44 -0
  470. package/dist/semantics/normalize/cells/policies/bag.js +114 -0
  471. package/dist/semantics/normalize/cells/policies/collection.d.ts +42 -0
  472. package/dist/semantics/normalize/cells/policies/collection.js +218 -0
  473. package/dist/semantics/normalize/cells/policies/field.d.ts +28 -0
  474. package/dist/semantics/normalize/cells/policies/field.js +40 -0
  475. package/dist/semantics/normalize/cells/policies/index.d.ts +49 -0
  476. package/dist/semantics/normalize/cells/policies/index.js +58 -0
  477. package/dist/semantics/normalize/cells/policies/local.d.ts +18 -0
  478. package/dist/semantics/normalize/cells/policies/local.js +37 -0
  479. package/dist/semantics/normalize/cells/policies/parameter.d.ts +28 -0
  480. package/dist/semantics/normalize/cells/policies/parameter.js +39 -0
  481. package/dist/semantics/normalize/cells/policies/return.d.ts +26 -0
  482. package/dist/semantics/normalize/cells/policies/return.js +45 -0
  483. package/dist/semantics/normalize/cells/policies/shared.d.ts +33 -0
  484. package/dist/semantics/normalize/cells/policies/shared.js +45 -0
  485. package/dist/semantics/normalize/cells/policy.d.ts +72 -0
  486. package/dist/semantics/normalize/cells/policy.js +18 -0
  487. package/dist/semantics/normalize/cells/registry.d.ts +14 -0
  488. package/dist/semantics/normalize/cells/registry.js +17 -0
  489. package/dist/semantics/normalize/census-refusal.d.ts +62 -0
  490. package/dist/semantics/normalize/census-refusal.js +27 -0
  491. package/dist/semantics/normalize/census.d.ts +109 -0
  492. package/dist/semantics/normalize/census.js +667 -0
  493. package/dist/semantics/normalize/collection-bindings.d.ts +278 -0
  494. package/dist/semantics/normalize/collection-bindings.js +677 -0
  495. package/dist/semantics/normalize/commonjs-module-record.d.ts +21 -0
  496. package/dist/semantics/normalize/commonjs-module-record.js +289 -0
  497. package/dist/semantics/normalize/commonjs-require.d.ts +13 -0
  498. package/dist/semantics/normalize/commonjs-require.js +1527 -0
  499. package/dist/semantics/normalize/contribution.d.ts +63 -0
  500. package/dist/semantics/normalize/contribution.js +172 -0
  501. package/dist/semantics/normalize/dead-typeof-guards.d.ts +64 -0
  502. package/dist/semantics/normalize/dead-typeof-guards.js +152 -0
  503. package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +57 -0
  504. package/dist/semantics/normalize/deferred-intrinsic-protocols.js +109 -0
  505. package/dist/semantics/normalize/derived-expression-type.d.ts +1070 -0
  506. package/dist/semantics/normalize/derived-expression-type.js +3463 -0
  507. package/dist/semantics/normalize/evaluation-order.d.ts +16 -0
  508. package/dist/semantics/normalize/evaluation-order.js +37 -0
  509. package/dist/semantics/normalize/field-bindings.d.ts +167 -0
  510. package/dist/semantics/normalize/field-bindings.js +1125 -0
  511. package/dist/semantics/normalize/flow/array-element-continuation.d.ts +27 -0
  512. package/dist/semantics/normalize/flow/array-element-continuation.js +1452 -0
  513. package/dist/semantics/normalize/flow/callable-array-origins.d.ts +42 -0
  514. package/dist/semantics/normalize/flow/callable-array-origins.js +318 -0
  515. package/dist/semantics/normalize/flow/callable-completions.d.ts +45 -0
  516. package/dist/semantics/normalize/flow/callable-completions.js +82 -0
  517. package/dist/semantics/normalize/flow/callable-reach.d.ts +237 -0
  518. package/dist/semantics/normalize/flow/callable-reach.js +7174 -0
  519. package/dist/semantics/normalize/flow/class-family-member-read.d.ts +16 -0
  520. package/dist/semantics/normalize/flow/class-family-member-read.js +992 -0
  521. package/dist/semantics/normalize/flow/collection-value-continuation.d.ts +21 -0
  522. package/dist/semantics/normalize/flow/collection-value-continuation.js +192 -0
  523. package/dist/semantics/normalize/flow/component-solver.d.ts +199 -0
  524. package/dist/semantics/normalize/flow/component-solver.js +587 -0
  525. package/dist/semantics/normalize/flow/computed-key-set.d.ts +84 -0
  526. package/dist/semantics/normalize/flow/computed-key-set.js +660 -0
  527. package/dist/semantics/normalize/flow/export-importers.d.ts +24 -0
  528. package/dist/semantics/normalize/flow/export-importers.js +269 -0
  529. package/dist/semantics/normalize/flow/host-text-sink.d.ts +25 -0
  530. package/dist/semantics/normalize/flow/host-text-sink.js +87 -0
  531. package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.d.ts +84 -0
  532. package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.js +180 -0
  533. package/dist/semantics/normalize/flow/intrinsic-data-definition.d.ts +35 -0
  534. package/dist/semantics/normalize/flow/intrinsic-data-definition.js +140 -0
  535. package/dist/semantics/normalize/flow/invocation-facts.d.ts +98 -0
  536. package/dist/semantics/normalize/flow/invocation-facts.js +257 -0
  537. package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +122 -0
  538. package/dist/semantics/normalize/flow/member-call-forwarding.js +835 -0
  539. package/dist/semantics/normalize/flow/model.d.ts +357 -0
  540. package/dist/semantics/normalize/flow/model.js +177 -0
  541. package/dist/semantics/normalize/flow/native-collection-protocol.d.ts +24 -0
  542. package/dist/semantics/normalize/flow/native-collection-protocol.js +252 -0
  543. package/dist/semantics/normalize/flow/node-path-token.d.ts +3 -0
  544. package/dist/semantics/normalize/flow/node-path-token.js +53 -0
  545. package/dist/semantics/normalize/flow/object-binding-continuation.d.ts +11 -0
  546. package/dist/semantics/normalize/flow/object-binding-continuation.js +42 -0
  547. package/dist/semantics/normalize/flow/origin-authority.d.ts +56 -0
  548. package/dist/semantics/normalize/flow/origin-authority.js +2 -0
  549. package/dist/semantics/normalize/flow/owned-class-receivers.d.ts +35 -0
  550. package/dist/semantics/normalize/flow/owned-class-receivers.js +191 -0
  551. package/dist/semantics/normalize/flow/parameter-values.d.ts +27 -0
  552. package/dist/semantics/normalize/flow/parameter-values.js +251 -0
  553. package/dist/semantics/normalize/flow/proof-hypotheses.d.ts +66 -0
  554. package/dist/semantics/normalize/flow/proof-hypotheses.js +162 -0
  555. package/dist/semantics/normalize/flow/record-alias-closure.d.ts +27 -0
  556. package/dist/semantics/normalize/flow/record-alias-closure.js +298 -0
  557. package/dist/semantics/normalize/flow/seeded-origins.d.ts +43 -0
  558. package/dist/semantics/normalize/flow/seeded-origins.js +54 -0
  559. package/dist/semantics/normalize/flow/source-class-data.d.ts +132 -0
  560. package/dist/semantics/normalize/flow/source-class-data.js +838 -0
  561. package/dist/semantics/normalize/flow/source-class-instanceof.d.ts +13 -0
  562. package/dist/semantics/normalize/flow/source-class-instanceof.js +37 -0
  563. package/dist/semantics/normalize/flow/source-class-static-data.d.ts +16 -0
  564. package/dist/semantics/normalize/flow/source-class-static-data.js +47 -0
  565. package/dist/semantics/normalize/flow/source-construction-frames.d.ts +12 -0
  566. package/dist/semantics/normalize/flow/source-construction-frames.js +118 -0
  567. package/dist/semantics/normalize/flow/source-invocation-frame-layout.d.ts +34 -0
  568. package/dist/semantics/normalize/flow/source-invocation-frame-layout.js +78 -0
  569. package/dist/semantics/normalize/flow/source-invocation-receiver.d.ts +37 -0
  570. package/dist/semantics/normalize/flow/source-invocation-receiver.js +95 -0
  571. package/dist/semantics/normalize/flow/source-prototype-method-identity.d.ts +23 -0
  572. package/dist/semantics/normalize/flow/source-prototype-method-identity.js +81 -0
  573. package/dist/semantics/normalize/flow/source-record-data.d.ts +29 -0
  574. package/dist/semantics/normalize/flow/source-record-data.js +626 -0
  575. package/dist/semantics/normalize/flow/source-value-session.d.ts +77 -0
  576. package/dist/semantics/normalize/flow/source-value-session.js +3089 -0
  577. package/dist/semantics/normalize/flow/targets.d.ts +118 -0
  578. package/dist/semantics/normalize/flow/targets.js +405 -0
  579. package/dist/semantics/normalize/flow/value-flow.d.ts +36 -0
  580. package/dist/semantics/normalize/flow/value-flow.js +823 -0
  581. package/dist/semantics/normalize/flow/value-provenance.d.ts +31 -0
  582. package/dist/semantics/normalize/flow/value-provenance.js +112 -0
  583. package/dist/semantics/normalize/gating.d.ts +51 -0
  584. package/dist/semantics/normalize/gating.js +560 -0
  585. package/dist/semantics/normalize/generic-function-choice.d.ts +31 -0
  586. package/dist/semantics/normalize/generic-function-choice.js +115 -0
  587. package/dist/semantics/normalize/global-host-mutations.d.ts +51 -0
  588. package/dist/semantics/normalize/global-host-mutations.js +5989 -0
  589. package/dist/semantics/normalize/host-effect-contracts.d.ts +77 -0
  590. package/dist/semantics/normalize/host-effect-contracts.js +143 -0
  591. package/dist/semantics/normalize/host-mutation-computed-keys.d.ts +38 -0
  592. package/dist/semantics/normalize/host-mutation-computed-keys.js +26 -0
  593. package/dist/semantics/normalize/host-mutation-key-reader.d.ts +66 -0
  594. package/dist/semantics/normalize/host-mutation-key-reader.js +192 -0
  595. package/dist/semantics/normalize/host-mutation-keys.d.ts +114 -0
  596. package/dist/semantics/normalize/host-mutation-keys.js +183 -0
  597. package/dist/semantics/normalize/identities.d.ts +172 -0
  598. package/dist/semantics/normalize/identities.js +426 -0
  599. package/dist/semantics/normalize/implicit-arguments-tuple.d.ts +97 -0
  600. package/dist/semantics/normalize/implicit-arguments-tuple.js +197 -0
  601. package/dist/semantics/normalize/implicit-arguments.d.ts +11 -0
  602. package/dist/semantics/normalize/implicit-arguments.js +39 -0
  603. package/dist/semantics/normalize/instantiation.d.ts +73 -0
  604. package/dist/semantics/normalize/instantiation.js +399 -0
  605. package/dist/semantics/normalize/intrinsic-property-call.d.ts +18 -0
  606. package/dist/semantics/normalize/intrinsic-property-call.js +69 -0
  607. package/dist/semantics/normalize/intrinsic-prototype.d.ts +41 -0
  608. package/dist/semantics/normalize/intrinsic-prototype.js +87 -0
  609. package/dist/semantics/normalize/intrinsic-static-member.d.ts +14 -0
  610. package/dist/semantics/normalize/intrinsic-static-member.js +23 -0
  611. package/dist/semantics/normalize/jsdoc-type-names.d.ts +32 -0
  612. package/dist/semantics/normalize/jsdoc-type-names.js +512 -0
  613. package/dist/semantics/normalize/keyof.d.ts +32 -0
  614. package/dist/semantics/normalize/keyof.js +110 -0
  615. package/dist/semantics/normalize/local-bindings.d.ts +176 -0
  616. package/dist/semantics/normalize/local-bindings.js +1826 -0
  617. package/dist/semantics/normalize/logical-result-type.d.ts +16 -0
  618. package/dist/semantics/normalize/logical-result-type.js +102 -0
  619. package/dist/semantics/normalize/namespace-paths.d.ts +57 -0
  620. package/dist/semantics/normalize/namespace-paths.js +108 -0
  621. package/dist/semantics/normalize/normalize.d.ts +57 -0
  622. package/dist/semantics/normalize/normalize.js +68 -0
  623. package/dist/semantics/normalize/object-bag-bindings.d.ts +305 -0
  624. package/dist/semantics/normalize/object-bag-bindings.js +1290 -0
  625. package/dist/semantics/normalize/omitted-stated-parameter.d.ts +53 -0
  626. package/dist/semantics/normalize/omitted-stated-parameter.js +59 -0
  627. package/dist/semantics/normalize/open-type-form.d.ts +10 -0
  628. package/dist/semantics/normalize/open-type-form.js +32 -0
  629. package/dist/semantics/normalize/parameter-bindings.d.ts +361 -0
  630. package/dist/semantics/normalize/parameter-bindings.js +3339 -0
  631. package/dist/semantics/normalize/parameter-slot.d.ts +264 -0
  632. package/dist/semantics/normalize/parameter-slot.js +491 -0
  633. package/dist/semantics/normalize/physical-overload-result.d.ts +77 -0
  634. package/dist/semantics/normalize/physical-overload-result.js +99 -0
  635. package/dist/semantics/normalize/primitive-property-absence.d.ts +12 -0
  636. package/dist/semantics/normalize/primitive-property-absence.js +60 -0
  637. package/dist/semantics/normalize/producer-context.d.ts +376 -0
  638. package/dist/semantics/normalize/producer-context.js +1 -0
  639. package/dist/semantics/normalize/producers/allocations.d.ts +3 -0
  640. package/dist/semantics/normalize/producers/allocations.js +863 -0
  641. package/dist/semantics/normalize/producers/binding-kind.d.ts +37 -0
  642. package/dist/semantics/normalize/producers/binding-kind.js +36 -0
  643. package/dist/semantics/normalize/producers/bindings.d.ts +85 -0
  644. package/dist/semantics/normalize/producers/bindings.js +710 -0
  645. package/dist/semantics/normalize/producers/boundary.d.ts +34 -0
  646. package/dist/semantics/normalize/producers/boundary.js +123 -0
  647. package/dist/semantics/normalize/producers/class-lifecycle.d.ts +3 -0
  648. package/dist/semantics/normalize/producers/class-lifecycle.js +902 -0
  649. package/dist/semantics/normalize/producers/computations.d.ts +3 -0
  650. package/dist/semantics/normalize/producers/computations.js +613 -0
  651. package/dist/semantics/normalize/producers/control-loops.d.ts +30 -0
  652. package/dist/semantics/normalize/producers/control-loops.js +91 -0
  653. package/dist/semantics/normalize/producers/control.d.ts +30 -0
  654. package/dist/semantics/normalize/producers/control.js +923 -0
  655. package/dist/semantics/normalize/producers/declaration-lifecycle.d.ts +3 -0
  656. package/dist/semantics/normalize/producers/declaration-lifecycle.js +390 -0
  657. package/dist/semantics/normalize/producers/destructuring.d.ts +45 -0
  658. package/dist/semantics/normalize/producers/destructuring.js +1180 -0
  659. package/dist/semantics/normalize/producers/dynamic-language.d.ts +3 -0
  660. package/dist/semantics/normalize/producers/dynamic-language.js +70 -0
  661. package/dist/semantics/normalize/producers/erasure.d.ts +51 -0
  662. package/dist/semantics/normalize/producers/erasure.js +90 -0
  663. package/dist/semantics/normalize/producers/installed.d.ts +3 -0
  664. package/dist/semantics/normalize/producers/installed.js +55 -0
  665. package/dist/semantics/normalize/producers/invocations.d.ts +35 -0
  666. package/dist/semantics/normalize/producers/invocations.js +1796 -0
  667. package/dist/semantics/normalize/producers/iteration-yield.d.ts +59 -0
  668. package/dist/semantics/normalize/producers/iteration-yield.js +235 -0
  669. package/dist/semantics/normalize/producers/jsx.d.ts +3 -0
  670. package/dist/semantics/normalize/producers/jsx.js +360 -0
  671. package/dist/semantics/normalize/producers/mint.d.ts +39 -0
  672. package/dist/semantics/normalize/producers/mint.js +44 -0
  673. package/dist/semantics/normalize/producers/nullish.d.ts +16 -0
  674. package/dist/semantics/normalize/producers/nullish.js +27 -0
  675. package/dist/semantics/normalize/producers/object-assignment.d.ts +8 -0
  676. package/dist/semantics/normalize/producers/object-assignment.js +204 -0
  677. package/dist/semantics/normalize/producers/object-tag.d.ts +9 -0
  678. package/dist/semantics/normalize/producers/object-tag.js +119 -0
  679. package/dist/semantics/normalize/producers/optional-chain.d.ts +44 -0
  680. package/dist/semantics/normalize/producers/optional-chain.js +75 -0
  681. package/dist/semantics/normalize/producers/properties.d.ts +21 -0
  682. package/dist/semantics/normalize/producers/properties.js +1053 -0
  683. package/dist/semantics/normalize/producers/protocol.d.ts +67 -0
  684. package/dist/semantics/normalize/producers/protocol.js +695 -0
  685. package/dist/semantics/normalize/producers/references.d.ts +53 -0
  686. package/dist/semantics/normalize/producers/references.js +1027 -0
  687. package/dist/semantics/normalize/producers/shared.d.ts +561 -0
  688. package/dist/semantics/normalize/producers/shared.js +1683 -0
  689. package/dist/semantics/normalize/producers/spread-arguments.d.ts +72 -0
  690. package/dist/semantics/normalize/producers/spread-arguments.js +375 -0
  691. package/dist/semantics/normalize/producers/tagged-template.d.ts +5 -0
  692. package/dist/semantics/normalize/producers/tagged-template.js +307 -0
  693. package/dist/semantics/normalize/producers/tuple-spread.d.ts +189 -0
  694. package/dist/semantics/normalize/producers/tuple-spread.js +279 -0
  695. package/dist/semantics/normalize/property-key-domain.d.ts +36 -0
  696. package/dist/semantics/normalize/property-key-domain.js +150 -0
  697. package/dist/semantics/normalize/reachability.d.ts +189 -0
  698. package/dist/semantics/normalize/reachability.js +1057 -0
  699. package/dist/semantics/normalize/reassigned-bindings.d.ts +13 -0
  700. package/dist/semantics/normalize/reassigned-bindings.js +41 -0
  701. package/dist/semantics/normalize/record-storage-families.d.ts +11 -0
  702. package/dist/semantics/normalize/record-storage-families.js +109 -0
  703. package/dist/semantics/normalize/return-bindings.d.ts +260 -0
  704. package/dist/semantics/normalize/return-bindings.js +1311 -0
  705. package/dist/semantics/normalize/return-paths.d.ts +2 -0
  706. package/dist/semantics/normalize/return-paths.js +28 -0
  707. package/dist/semantics/normalize/script-global-redefinition.d.ts +44 -0
  708. package/dist/semantics/normalize/script-global-redefinition.js +75 -0
  709. package/dist/semantics/normalize/specialization.d.ts +201 -0
  710. package/dist/semantics/normalize/specialization.js +1824 -0
  711. package/dist/semantics/normalize/structural-array-element.d.ts +176 -0
  712. package/dist/semantics/normalize/structural-array-element.js +700 -0
  713. package/dist/semantics/normalize/structural-array-read.d.ts +13 -0
  714. package/dist/semantics/normalize/structural-array-read.js +124 -0
  715. package/dist/semantics/normalize/structural-callable.d.ts +12 -0
  716. package/dist/semantics/normalize/structural-callable.js +82 -0
  717. package/dist/semantics/normalize/structural-creation-order.d.ts +32 -0
  718. package/dist/semantics/normalize/structural-creation-order.js +111 -0
  719. package/dist/semantics/normalize/structural-declarations.d.ts +395 -0
  720. package/dist/semantics/normalize/structural-declarations.js +968 -0
  721. package/dist/semantics/normalize/structural-declared-body.d.ts +25 -0
  722. package/dist/semantics/normalize/structural-declared-body.js +147 -0
  723. package/dist/semantics/normalize/structural-generics.d.ts +56 -0
  724. package/dist/semantics/normalize/structural-generics.js +120 -0
  725. package/dist/semantics/normalize/structural-indexed-access.d.ts +11 -0
  726. package/dist/semantics/normalize/structural-indexed-access.js +126 -0
  727. package/dist/semantics/normalize/structural-instantiated-member.d.ts +64 -0
  728. package/dist/semantics/normalize/structural-instantiated-member.js +407 -0
  729. package/dist/semantics/normalize/structural-joins.d.ts +44 -0
  730. package/dist/semantics/normalize/structural-joins.js +143 -0
  731. package/dist/semantics/normalize/structural-layout-relevance.d.ts +29 -0
  732. package/dist/semantics/normalize/structural-layout-relevance.js +391 -0
  733. package/dist/semantics/normalize/structural-layout-type.d.ts +11 -0
  734. package/dist/semantics/normalize/structural-layout-type.js +1468 -0
  735. package/dist/semantics/normalize/structural-leaves.d.ts +49 -0
  736. package/dist/semantics/normalize/structural-leaves.js +125 -0
  737. package/dist/semantics/normalize/structural-local-union.d.ts +13 -0
  738. package/dist/semantics/normalize/structural-local-union.js +133 -0
  739. package/dist/semantics/normalize/structural-members.d.ts +26 -0
  740. package/dist/semantics/normalize/structural-members.js +84 -0
  741. package/dist/semantics/normalize/structural-mutable-method.d.ts +15 -0
  742. package/dist/semantics/normalize/structural-mutable-method.js +109 -0
  743. package/dist/semantics/normalize/structural-parts.d.ts +131 -0
  744. package/dist/semantics/normalize/structural-parts.js +737 -0
  745. package/dist/semantics/normalize/structural-receiver.d.ts +66 -0
  746. package/dist/semantics/normalize/structural-receiver.js +551 -0
  747. package/dist/semantics/normalize/structural-rules.d.ts +112 -0
  748. package/dist/semantics/normalize/structural-rules.js +93 -0
  749. package/dist/semantics/normalize/structural-self-reference.d.ts +150 -0
  750. package/dist/semantics/normalize/structural-self-reference.js +494 -0
  751. package/dist/semantics/normalize/structural.d.ts +202 -0
  752. package/dist/semantics/normalize/structural.js +4218 -0
  753. package/dist/semantics/normalize/unreduced-type-form.d.ts +41 -0
  754. package/dist/semantics/normalize/unreduced-type-form.js +53 -0
  755. package/dist/semantics/normalize/unresolvable-names.d.ts +56 -0
  756. package/dist/semantics/normalize/unresolvable-names.js +140 -0
  757. package/dist/semantics/package-sources.d.ts +16 -0
  758. package/dist/semantics/package-sources.js +365 -0
  759. package/dist/semantics/program.d.ts +151 -0
  760. package/dist/semantics/program.js +667 -0
  761. package/dist/semantics/prototype-install-source-transform.d.ts +4 -0
  762. package/dist/semantics/prototype-install-source-transform.js +341 -0
  763. package/dist/semantics/prototype-object-class-source-transform.d.ts +4 -0
  764. package/dist/semantics/prototype-object-class-source-transform.js +525 -0
  765. package/dist/semantics/prototype-reparenting.d.ts +50 -0
  766. package/dist/semantics/prototype-reparenting.js +317 -0
  767. package/dist/semantics/stable-checker.d.ts +10 -0
  768. package/dist/semantics/stable-checker.js +148 -0
  769. package/dist/semantics/subclass-member-overlay-transform.d.ts +35 -0
  770. package/dist/semantics/subclass-member-overlay-transform.js +1418 -0
  771. package/dist/semantics/symbol-keyed-expando-source-transform.d.ts +4 -0
  772. package/dist/semantics/symbol-keyed-expando-source-transform.js +66 -0
  773. package/dist/semantics/this-constructor-source-transform.d.ts +4 -0
  774. package/dist/semantics/this-constructor-source-transform.js +122 -0
  775. package/dist/semantics/uninstantiable-classes.d.ts +22 -0
  776. package/dist/semantics/uninstantiable-classes.js +75 -0
  777. package/dist/targets/cpp/balanced-units.d.ts +3 -0
  778. package/dist/targets/cpp/balanced-units.js +58 -0
  779. package/dist/targets/cpp/borrowed-call-entry.d.ts +30 -0
  780. package/dist/targets/cpp/borrowed-call-entry.js +68 -0
  781. package/dist/targets/cpp/captures.d.ts +68 -0
  782. package/dist/targets/cpp/captures.js +269 -0
  783. package/dist/targets/cpp/class-layout.d.ts +313 -0
  784. package/dist/targets/cpp/class-layout.js +483 -0
  785. package/dist/targets/cpp/class-properties/computed-method-value.d.ts +25 -0
  786. package/dist/targets/cpp/class-properties/computed-method-value.js +22 -0
  787. package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +216 -0
  788. package/dist/targets/cpp/class-properties/emit-class-properties.js +917 -0
  789. package/dist/targets/cpp/class-properties/native-prototype.d.ts +11 -0
  790. package/dist/targets/cpp/class-properties/native-prototype.js +101 -0
  791. package/dist/targets/cpp/class-ref-transport.d.ts +12 -0
  792. package/dist/targets/cpp/class-ref-transport.js +32 -0
  793. package/dist/targets/cpp/conversions.d.ts +3 -0
  794. package/dist/targets/cpp/conversions.js +2027 -0
  795. package/dist/targets/cpp/deferral-safety.d.ts +82 -0
  796. package/dist/targets/cpp/deferral-safety.js +86 -0
  797. package/dist/targets/cpp/direct-call-receivers.d.ts +37 -0
  798. package/dist/targets/cpp/direct-call-receivers.js +79 -0
  799. package/dist/targets/cpp/document.d.ts +74 -0
  800. package/dist/targets/cpp/document.js +106 -0
  801. package/dist/targets/cpp/emit-allocation.d.ts +60 -0
  802. package/dist/targets/cpp/emit-allocation.js +573 -0
  803. package/dist/targets/cpp/emit-arrays.d.ts +119 -0
  804. package/dist/targets/cpp/emit-arrays.js +1047 -0
  805. package/dist/targets/cpp/emit-binding-reference.d.ts +17 -0
  806. package/dist/targets/cpp/emit-binding-reference.js +120 -0
  807. package/dist/targets/cpp/emit-bindings.d.ts +158 -0
  808. package/dist/targets/cpp/emit-bindings.js +769 -0
  809. package/dist/targets/cpp/emit-buffers.d.ts +156 -0
  810. package/dist/targets/cpp/emit-buffers.js +573 -0
  811. package/dist/targets/cpp/emit-callable.d.ts +230 -0
  812. package/dist/targets/cpp/emit-callable.js +2154 -0
  813. package/dist/targets/cpp/emit-carrier-members.d.ts +406 -0
  814. package/dist/targets/cpp/emit-carrier-members.js +1224 -0
  815. package/dist/targets/cpp/emit-coercion.d.ts +26 -0
  816. package/dist/targets/cpp/emit-coercion.js +39 -0
  817. package/dist/targets/cpp/emit-context.d.ts +1882 -0
  818. package/dist/targets/cpp/emit-context.js +904 -0
  819. package/dist/targets/cpp/emit-dynamic-properties.d.ts +174 -0
  820. package/dist/targets/cpp/emit-dynamic-properties.js +1249 -0
  821. package/dist/targets/cpp/emit-equality.d.ts +39 -0
  822. package/dist/targets/cpp/emit-equality.js +472 -0
  823. package/dist/targets/cpp/emit-exceptions.d.ts +104 -0
  824. package/dist/targets/cpp/emit-exceptions.js +513 -0
  825. package/dist/targets/cpp/emit-field-owner.d.ts +4 -0
  826. package/dist/targets/cpp/emit-field-owner.js +27 -0
  827. package/dist/targets/cpp/emit-in.d.ts +31 -0
  828. package/dist/targets/cpp/emit-in.js +426 -0
  829. package/dist/targets/cpp/emit-instanceof.d.ts +19 -0
  830. package/dist/targets/cpp/emit-instanceof.js +601 -0
  831. package/dist/targets/cpp/emit-integers.d.ts +68 -0
  832. package/dist/targets/cpp/emit-integers.js +184 -0
  833. package/dist/targets/cpp/emit-iterator.d.ts +100 -0
  834. package/dist/targets/cpp/emit-iterator.js +1137 -0
  835. package/dist/targets/cpp/emit-json.d.ts +73 -0
  836. package/dist/targets/cpp/emit-json.js +823 -0
  837. package/dist/targets/cpp/emit-jsx.d.ts +74 -0
  838. package/dist/targets/cpp/emit-jsx.js +806 -0
  839. package/dist/targets/cpp/emit-mixed-binary.d.ts +51 -0
  840. package/dist/targets/cpp/emit-mixed-binary.js +60 -0
  841. package/dist/targets/cpp/emit-namespaces.d.ts +101 -0
  842. package/dist/targets/cpp/emit-namespaces.js +133 -0
  843. package/dist/targets/cpp/emit-narrowing.d.ts +738 -0
  844. package/dist/targets/cpp/emit-narrowing.js +3967 -0
  845. package/dist/targets/cpp/emit-native-equality.d.ts +3 -0
  846. package/dist/targets/cpp/emit-native-equality.js +14 -0
  847. package/dist/targets/cpp/emit-native-selection.d.ts +5 -0
  848. package/dist/targets/cpp/emit-native-selection.js +37 -0
  849. package/dist/targets/cpp/emit-object-tag.d.ts +4 -0
  850. package/dist/targets/cpp/emit-object-tag.js +108 -0
  851. package/dist/targets/cpp/emit-owned-record.d.ts +2 -0
  852. package/dist/targets/cpp/emit-owned-record.js +15 -0
  853. package/dist/targets/cpp/emit-presence.d.ts +78 -0
  854. package/dist/targets/cpp/emit-presence.js +376 -0
  855. package/dist/targets/cpp/emit-properties.d.ts +105 -0
  856. package/dist/targets/cpp/emit-properties.js +1640 -0
  857. package/dist/targets/cpp/emit-record-view.d.ts +20 -0
  858. package/dist/targets/cpp/emit-record-view.js +354 -0
  859. package/dist/targets/cpp/emit-return.d.ts +5 -0
  860. package/dist/targets/cpp/emit-return.js +237 -0
  861. package/dist/targets/cpp/emit-sum-widening.d.ts +10 -0
  862. package/dist/targets/cpp/emit-sum-widening.js +69 -0
  863. package/dist/targets/cpp/emit-tonumber.d.ts +38 -0
  864. package/dist/targets/cpp/emit-tonumber.js +177 -0
  865. package/dist/targets/cpp/emit-tostring.d.ts +92 -0
  866. package/dist/targets/cpp/emit-tostring.js +556 -0
  867. package/dist/targets/cpp/emit-typeof.d.ts +49 -0
  868. package/dist/targets/cpp/emit-typeof.js +317 -0
  869. package/dist/targets/cpp/emit-union-properties.d.ts +181 -0
  870. package/dist/targets/cpp/emit-union-properties.js +1281 -0
  871. package/dist/targets/cpp/emit.d.ts +45 -0
  872. package/dist/targets/cpp/emit.js +2225 -0
  873. package/dist/targets/cpp/error-types.d.ts +4 -0
  874. package/dist/targets/cpp/error-types.js +11 -0
  875. package/dist/targets/cpp/function-source-reads.d.ts +72 -0
  876. package/dist/targets/cpp/function-source-reads.js +148 -0
  877. package/dist/targets/cpp/host/atomics.d.ts +25 -0
  878. package/dist/targets/cpp/host/atomics.js +63 -0
  879. package/dist/targets/cpp/host/core-globals.d.ts +108 -0
  880. package/dist/targets/cpp/host/core-globals.js +158 -0
  881. package/dist/targets/cpp/host/dynamic-argument-members.d.ts +42 -0
  882. package/dist/targets/cpp/host/dynamic-argument-members.js +61 -0
  883. package/dist/targets/cpp/host/emit-host-arity.d.ts +139 -0
  884. package/dist/targets/cpp/host/emit-host-arity.js +232 -0
  885. package/dist/targets/cpp/host/emit-host-invoke.d.ts +91 -0
  886. package/dist/targets/cpp/host/emit-host-invoke.js +1105 -0
  887. package/dist/targets/cpp/host/emit-host-object.d.ts +55 -0
  888. package/dist/targets/cpp/host/emit-host-object.js +2206 -0
  889. package/dist/targets/cpp/host/emit-host-properties.d.ts +69 -0
  890. package/dist/targets/cpp/host/emit-host-properties.js +533 -0
  891. package/dist/targets/cpp/host/emit-host-reflect.d.ts +4 -0
  892. package/dist/targets/cpp/host/emit-host-reflect.js +180 -0
  893. package/dist/targets/cpp/host/emit-host-value.d.ts +120 -0
  894. package/dist/targets/cpp/host/emit-host-value.js +392 -0
  895. package/dist/targets/cpp/host/host-members.d.ts +505 -0
  896. package/dist/targets/cpp/host/host-members.js +819 -0
  897. package/dist/targets/cpp/host/host-method-aliases.d.ts +30 -0
  898. package/dist/targets/cpp/host/host-method-aliases.js +76 -0
  899. package/dist/targets/cpp/host/native-protocols.d.ts +47 -0
  900. package/dist/targets/cpp/host/native-protocols.js +183 -0
  901. package/dist/targets/cpp/host/object-protocol.d.ts +351 -0
  902. package/dist/targets/cpp/host/object-protocol.js +671 -0
  903. package/dist/targets/cpp/host-namespace-reads.d.ts +83 -0
  904. package/dist/targets/cpp/host-namespace-reads.js +113 -0
  905. package/dist/targets/cpp/manifest/capabilities.d.ts +39 -0
  906. package/dist/targets/cpp/manifest/capabilities.js +1484 -0
  907. package/dist/targets/cpp/manifest.d.ts +23 -0
  908. package/dist/targets/cpp/manifest.js +113 -0
  909. package/dist/targets/cpp/native-error-base.d.ts +38 -0
  910. package/dist/targets/cpp/native-error-base.js +74 -0
  911. package/dist/targets/cpp/native-narrowing-transport.d.ts +12 -0
  912. package/dist/targets/cpp/native-narrowing-transport.js +151 -0
  913. package/dist/targets/cpp/native-selection-helpers.d.ts +11 -0
  914. package/dist/targets/cpp/native-selection-helpers.js +46 -0
  915. package/dist/targets/cpp/native-symbol-keys.d.ts +8 -0
  916. package/dist/targets/cpp/native-symbol-keys.js +34 -0
  917. package/dist/targets/cpp/ownership.d.ts +43 -0
  918. package/dist/targets/cpp/ownership.js +38 -0
  919. package/dist/targets/cpp/owning-conversion-input.d.ts +14 -0
  920. package/dist/targets/cpp/owning-conversion-input.js +12 -0
  921. package/dist/targets/cpp/property-read-claims.d.ts +62 -0
  922. package/dist/targets/cpp/property-read-claims.js +23 -0
  923. package/dist/targets/cpp/property-store-claims.d.ts +62 -0
  924. package/dist/targets/cpp/property-store-claims.js +26 -0
  925. package/dist/targets/cpp/prototype/emit-prototype-array.d.ts +111 -0
  926. package/dist/targets/cpp/prototype/emit-prototype-array.js +602 -0
  927. package/dist/targets/cpp/prototype/emit-prototype-date.d.ts +133 -0
  928. package/dist/targets/cpp/prototype/emit-prototype-date.js +515 -0
  929. package/dist/targets/cpp/prototype/emit-prototype-error.d.ts +13 -0
  930. package/dist/targets/cpp/prototype/emit-prototype-error.js +54 -0
  931. package/dist/targets/cpp/prototype/emit-prototype-invoke.d.ts +34 -0
  932. package/dist/targets/cpp/prototype/emit-prototype-invoke.js +1003 -0
  933. package/dist/targets/cpp/prototype/emit-prototype-iterator.d.ts +47 -0
  934. package/dist/targets/cpp/prototype/emit-prototype-iterator.js +250 -0
  935. package/dist/targets/cpp/prototype/emit-prototype-promise.d.ts +46 -0
  936. package/dist/targets/cpp/prototype/emit-prototype-promise.js +143 -0
  937. package/dist/targets/cpp/prototype/emit-prototype-regexp.d.ts +335 -0
  938. package/dist/targets/cpp/prototype/emit-prototype-regexp.js +853 -0
  939. package/dist/targets/cpp/prototype/emit-prototype-string.d.ts +42 -0
  940. package/dist/targets/cpp/prototype/emit-prototype-string.js +252 -0
  941. package/dist/targets/cpp/prototype/prototype-method-reads.d.ts +25 -0
  942. package/dist/targets/cpp/prototype/prototype-method-reads.js +182 -0
  943. package/dist/targets/cpp/reactive-dependencies.d.ts +140 -0
  944. package/dist/targets/cpp/reactive-dependencies.js +432 -0
  945. package/dist/targets/cpp/reactive-origins.d.ts +44 -0
  946. package/dist/targets/cpp/reactive-origins.js +82 -0
  947. package/dist/targets/cpp/records.d.ts +277 -0
  948. package/dist/targets/cpp/records.js +2427 -0
  949. package/dist/targets/cpp/recursive-containers.d.ts +43 -0
  950. package/dist/targets/cpp/recursive-containers.js +144 -0
  951. package/dist/targets/cpp/regexp-types.d.ts +56 -0
  952. package/dist/targets/cpp/regexp-types.js +59 -0
  953. package/dist/targets/cpp/substrate.d.ts +125 -0
  954. package/dist/targets/cpp/substrate.js +12 -0
  955. package/dist/targets/cpp/translation-unit.d.ts +219 -0
  956. package/dist/targets/cpp/translation-unit.js +2063 -0
  957. package/dist/targets/cpp/types.d.ts +280 -0
  958. package/dist/targets/cpp/types.js +1135 -0
  959. package/dist/targets/cpp/virtual-methods.d.ts +95 -0
  960. package/dist/targets/cpp/virtual-methods.js +264 -0
  961. package/package.json +95 -0
  962. package/src/targets/cpp/runtime/gea_dynamic_proxy.h +824 -0
  963. package/src/targets/cpp/runtime/gea_eval.h +1376 -0
  964. package/src/targets/cpp/runtime/gea_native_class_prototype.h +44 -0
  965. package/src/targets/cpp/runtime/gea_runtime.h +29222 -0
  966. package/src/targets/cpp/runtime/gea_runtime_builtins.cpp +55 -0
@@ -0,0 +1,1501 @@
1
+ import ts from 'typescript';
2
+ import { declaredBaseTypesOf, isAmbientSymbol } from './ambient.js';
3
+ import { isValueReference } from './normalize/census.js';
4
+ import { valueSymbolAt } from './normalize/unresolvable-names.js';
5
+ import { commonJsBindingIdentifiers, createCommonJsWrapperIdentity, isCommonJsWrapperVarDeclaration } from './commonjs-wrapper.js';
6
+ import { hasExactHostDeclaration } from './host-declaration-provenance.js';
7
+ /**
8
+ * The declared type the language gives a JSX element, bound to the JSX host
9
+ * protocol.
10
+ *
11
+ * A JSX element is the one construction whose result type the *language*
12
+ * defines by lookup rather than the program defining it by declaration: the
13
+ * checker resolves `JSX.Element` through the JSX namespace in scope, and every
14
+ * element expression in the program has that type. So asking the checker for
15
+ * the type of an element -- which the element producer already does -- is what
16
+ * identifies the declaration, and no name, path, or package is consulted to do
17
+ * it.
18
+ *
19
+ * Binding it matters because the answer would otherwise be structurally
20
+ * plausible and physically wrong. `interface Element extends GeaJsxElement {}`
21
+ * where `GeaJsxElement` is `{}` derives a `native-record-ref` to an empty
22
+ * struct: C++ that compiles, holds nothing, and renders nothing. An element is
23
+ * an opaque host handle, and `native-handle` is the carrier that says so.
24
+ *
25
+ * The binding is only a *claim* -- `preflight/run.ts` still censuses the
26
+ * protocol against `manifest.nativeProtocols`, so a target that has not
27
+ * implemented it refuses the program instead of emitting against glue that
28
+ * does not exist.
29
+ *
30
+ * An element the checker types `any` binds nothing: no JSX namespace was in
31
+ * scope, and binding a protocol to `any`'s declaration -- if it even had one --
32
+ * would claim a contract the program never established. The element producer
33
+ * refuses that program by its own route, and this stays silent rather than
34
+ * manufacturing a second, weaker answer to the same question.
35
+ *
36
+ * The carrier is asked of the host by the protocol's own name, exactly as every
37
+ * other host protocol's is (`declaredHostShape` below): a host that states what
38
+ * it holds a JSX element in gets its own type spelled, and one that states
39
+ * nothing gets the tagged handle. Leaving it unconditionally unstated is what
40
+ * made every element in a gea program a `gea::NativeHandle<...jsx_element_v1>`
41
+ * -- a tag type with no tree behind it, so an app compiled, ran, and rendered
42
+ * nothing, while the engine's real `NodeHandle` sat in the same table one
43
+ * lookup away.
44
+ */
45
+ export const hostProtocolBindings = (input, census) => {
46
+ const native = input.nativeTypes.get('jsx-element') ?? null;
47
+ for (const candidate of input.census) {
48
+ if (candidate.family !== 'element')
49
+ continue;
50
+ const shape = input.table.get(input.types.typeAt(candidate.node))?.shape;
51
+ if (shape?.kind !== 'declared')
52
+ continue;
53
+ census.protocols.set(shape.declaration, { protocol: 'jsx-element', version: 1, native, opaque: true });
54
+ }
55
+ };
56
+ /**
57
+ * Whether this checker symbol is a host namespace root.
58
+ *
59
+ * An exact row masks the legacy name table even when it does not match. That
60
+ * is the fail-closed case for declaration merging: adding a caller declaration
61
+ * to `Buffer` must revoke the host claim rather than falling back to the same
62
+ * spelling in `hostNamespaces.roots`.
63
+ */
64
+ const isHostNamespaceRoot = (input, symbol) => {
65
+ const configured = input.hostNamespaceRootDeclarations.filter((row) => row.declarationName === symbol.name);
66
+ if (configured.length > 0)
67
+ return configured.some((row) => hasExactHostDeclaration(symbol, row));
68
+ return input.hostNamespaceRoots.has(symbol.name);
69
+ };
70
+ /**
71
+ * A name-only native row remains supported for compiler-owned and existing
72
+ * host surfaces. A declaration-owned row deliberately masks that fallback:
73
+ * once a host says the spelling belongs to one declaration, a same-named or
74
+ * merged declaration is not an alternate ABI.
75
+ */
76
+ const nativeTypeOf = (input, symbol) => {
77
+ const configured = input.nativeTypesByDeclaration.get(symbol.name);
78
+ if (configured !== undefined)
79
+ return hasExactHostDeclaration(symbol, configured) ? configured.native : null;
80
+ return input.nativeTypes.get(symbol.name) ?? null;
81
+ };
82
+ /**
83
+ * The host objects this program reads: `Math`, `Date`, `JSON`, `document`, and
84
+ * whatever else its own declarations say a host supplies.
85
+ *
86
+ * Each of these is an ambient *value* whose type is a named interface -- the
87
+ * exact shape of "a host owns this object; the program only reads it". The
88
+ * carrier for one is a host handle, not a struct, and the difference is not
89
+ * cosmetic. `Math`'s interface carries `[Symbol.toStringTag]`, `String`'s
90
+ * result carries a numeric index signature, and `DateConstructor` carries four
91
+ * construct signatures with four different frames -- all of which correctly
92
+ * refuse to become a record layout, because none of them *is* one. Laying them
93
+ * out structurally produced 108 unresolved carriers in one application, every
94
+ * one of them describing a struct nothing was ever going to allocate.
95
+ *
96
+ * The protocol is named by the *type's* own declared name, so two globals of
97
+ * one interface share one protocol. That is a spelling, and it is the same
98
+ * admitted exception `BindingOperation.external`'s linkage name is: an ambient
99
+ * declaration's name is its ABI contract with whatever defines it, and there is
100
+ * no other handle on a thing this program never defines. Nothing is assumed
101
+ * about which names exist -- a program whose declarations mention none of them
102
+ * binds nothing, and `preflight/run.ts` still censuses every protocol against
103
+ * `manifest.nativeProtocols`, so a target that has not implemented one refuses
104
+ * rather than emitting against glue that is not there.
105
+ *
106
+ * A *class* declared ambiently does not bind here: its value is a constructor
107
+ * object, not a `declared` type, and constructing one is a different question
108
+ * from reading a member off a host singleton.
109
+ */
110
+ /**
111
+ * A declared type an installed host states a carrier for.
112
+ *
113
+ * `bindAmbientValue` below finds only what a host *value* hands out, and most
114
+ * of a host's object model is never handed out by one. `GeaElement` is written
115
+ * by the framework as a type-parameter constraint and default and never as a
116
+ * value; `Node`, `Text` and `DOMTokenList` are parameter annotations in a
117
+ * program that may never touch `document`. Nothing bound any of them, so
118
+ * `derive.ts` expanded them structurally -- straight into `HTMLElement`'s own
119
+ * `childNodes` cycle, which is the "no record layout ... carries unresolved"
120
+ * failure `bindAmbientValue`'s own comment already predicted, three layers
121
+ * downstream of the actual gap.
122
+ *
123
+ * The name is the join key. That is the same admitted exception an ambient
124
+ * declaration's linkage name already is (`BindingOperation.external`): a host
125
+ * type this program never defines has no other handle on it. What keeps it from
126
+ * being a guess is that the table is the *plugin's*, supplied as input -- a
127
+ * name it does not state binds nothing, and this file names none of them.
128
+ */
129
+ const bindNativeType = (input, census, reference) => {
130
+ const local = input.checker.getSymbolAtLocation(reference);
131
+ if (!local)
132
+ return null;
133
+ // The same alias step `bindAmbientValue` takes, for the same reason: an
134
+ // imported name's own symbol is the import specifier, which lives in this
135
+ // program's file and is not ambient at all. `GeaElement` is imported by the
136
+ // framework's own `runtime/compiler.ts`, so without this it is an `Alias`
137
+ // with no `Type` flag and binds nothing -- measured, not supposed.
138
+ const symbol = (local.flags & ts.SymbolFlags.Alias) !== 0 ? input.checker.getAliasedSymbol(local) : local;
139
+ if ((symbol.flags & ts.SymbolFlags.Type) === 0 || !isAmbientSymbol(symbol))
140
+ return null;
141
+ const stated = nativeTypeOf(input, symbol);
142
+ if (stated === null)
143
+ return null;
144
+ // Routed through `identities.symbolDeclarationId` -- the same route
145
+ // `promiseDeclarationOf` takes, and deliberately NOT through
146
+ // `types.typeOf(...)`. Asking the structural mapper would *intern* every
147
+ // named type this table mentions, and interning is order-sensitive: which
148
+ // member of a type cycle gets the nominal anchor depends on which was interned
149
+ // first, so a pass that interned thirty-nine extra types would move that
150
+ // anchor. It did: an early version of this took the three.js app from 2
151
+ // guard violations to 269, all of them
152
+ // `unresolved(a self-referential type of this shape is not modelled)`
153
+ // propagating out of three.js's `Object3D`/`Mesh` cycle. The declaration
154
+ // identity is all a binding needs, and the identity table answers it without
155
+ // interning anything.
156
+ //
157
+ // No shape check either, and none is needed: `derive.ts` consults
158
+ // `binding.forDeclaration` only in its `declared`, `class-instance` and
159
+ // `class-constructor` cases, so a binding for a declaration that never
160
+ // derives as one of those is simply never read.
161
+ const declaration = input.identities.symbolDeclarationId(symbol, reference);
162
+ if (!declaration)
163
+ return null;
164
+ const declared = input.checker.getDeclaredTypeOfSymbol(symbol);
165
+ // ...and one check the NAME cannot make on its own.
166
+ //
167
+ // The join key is a bare name, which is the admitted exception this
168
+ // function's own comment states -- but a name is not unique, and a plugin's
169
+ // row means *its* declaration, never whichever same-named one a program
170
+ // happens to import. The three.js app shims `troika-three-text` as
171
+ // `declare module 'troika-three-text' { export class Text extends Object3D }`,
172
+ // and the gea plugin states `Text -> gea::embedded::ui::NodeHandle` for the
173
+ // DOM text node. Same name, unrelated types: every troika `Text` in the HUD
174
+ // bound as a gea UI node handle, and the closure walk then followed that
175
+ // handle's `userData`/`toJSON` into `lib.es5`'s own `Object` and `Function`
176
+ // and demanded host boundaries for them -- 1329 of the three.js app's 3394 root
177
+ // diagnostics, all from one collision, on top of a silent miscompile of
178
+ // every text object in the program.
179
+ //
180
+ // What separates the two is not the name but the hierarchy. A host protocol
181
+ // is OPAQUE: the host owns the type and everything it derives from, which is
182
+ // why `@geastack/core`'s `Element extends Node` and AppKit's
183
+ // `NSView extends NSResponder` bind exactly as before -- every base of each
184
+ // is itself declared, never defined. troika's `Text` derives from three.js's
185
+ // `Object3D`, an ordinary class this program COMPILES FROM SOURCE; a handle
186
+ // with no layout cannot be the carrier of a type half of whose members this
187
+ // compilation is emitting. So a declaration with a defined base is not the
188
+ // host's, whatever it is called.
189
+ for (const base of declaredBaseTypesOf(input.checker, declared)) {
190
+ const baseSymbol = base.getSymbol();
191
+ if (baseSymbol && !isAmbientSymbol(baseSymbol))
192
+ return null;
193
+ }
194
+ if (!census.protocols.has(declaration))
195
+ census.protocols.set(declaration, { protocol: symbol.name, version: 1, native: stated, opaque: false });
196
+ return declared;
197
+ };
198
+ /**
199
+ * A host type reached only through a CONTEXTUAL type -- never spelled.
200
+ *
201
+ * `bindNativeType` above joins on a name the program writes. A JSX event
202
+ * handler writes none: `onTouchMove={e => pan(e.clientX, e.clientY)}` gets `e`'s
203
+ * type from the attribute's own declaration (`onTouchMove?: TouchEventHandler`)
204
+ * in the framework's ambient file, so the identifier `TouchEvent` never appears
205
+ * in any file this walk visits and the table's row for it never fired.
206
+ *
207
+ * The parameter's own name IS in the program, though, and it is the identifier
208
+ * this walk is already standing on -- so the join is the same one, asked of the
209
+ * checker instead of the source text. Restricted to a parameter with no written
210
+ * annotation, because an annotation is itself an identifier `bindNativeType`
211
+ * binds one line above; asking twice would just re-answer it.
212
+ *
213
+ * Narrow on purpose. Binding every name the table states, wherever a type
214
+ * happens to carry it, is what `bindNativeType`'s own comment warns is
215
+ * order-sensitive -- it interns types, and which member of a cycle gets the
216
+ * nominal anchor depends on which was interned first.
217
+ *
218
+ * Without this, an event parameter derived structurally: a `TouchEvent` became
219
+ * a generated record of doubles rather than the engine's own `PointerEvent`,
220
+ * so the handler was an arity-1 callable the listener runtime had no way to
221
+ * call, and every drag, pan and swipe in a JSX app did nothing at all.
222
+ */
223
+ const bindNativeContextualType = (input, census, reference) => {
224
+ const parameter = reference.parent;
225
+ if (!ts.isParameter(parameter) || parameter.name !== reference || parameter.type !== undefined)
226
+ return null;
227
+ // STATED, not HOLDS -- deliberately not `censusedTypeAt`. This asks what
228
+ // AMBIENT CONTEXTUAL type a framework's own `.d.ts` gave this unannotated
229
+ // parameter (`onTouchMove?: TouchEventHandler` -> `e: TouchEvent`), so it
230
+ // can bind a HOST-PROTOCOL identity -- a different question from "what
231
+ // value does this parameter hold", which is what the parameter-binding
232
+ // census answers from real call-site evidence. The two domains overlap
233
+ // syntactically (both fire only on unannotated parameters), but a
234
+ // parameter used BOTH as a JSX handler and called directly elsewhere with
235
+ // unrelated arguments could have a census-bound value type that disagrees
236
+ // with its ambient host type; substituting it here risks losing the host
237
+ // binding (`type.getSymbol()`/`aliasSymbol` needs the AMBIENT type's
238
+ // identity, not an unrelated value-derived one) for no boxing benefit --
239
+ // this function feeds `census.protocols`, never a value carrier. Left as a
240
+ // direct checker call.
241
+ const type = input.checker.getTypeAtLocation(reference);
242
+ const symbol = type.getSymbol() ?? type.aliasSymbol;
243
+ if (!symbol)
244
+ return null;
245
+ const stated = nativeTypeOf(input, symbol);
246
+ if (stated === null || !isAmbientSymbol(symbol))
247
+ return null;
248
+ const declaration = input.identities.symbolDeclarationId(symbol, reference);
249
+ if (!declaration)
250
+ return null;
251
+ if (!census.protocols.has(declaration))
252
+ census.protocols.set(declaration, { protocol: symbol.name, version: 1, native: stated, opaque: false });
253
+ return type;
254
+ };
255
+ /**
256
+ * Node wraps a CommonJS source in a function whose parameters already bind
257
+ * require/exports/module. A module-scope `var` of one of those names therefore
258
+ * redeclares that parameter; it does not allocate the local Symbol TypeScript
259
+ * gives a standalone source file. Index that Symbol's declaration identity as
260
+ * the same wrapper cell, including binding patterns and `for (var ... of/in)`.
261
+ */
262
+ const indexCommonJsVarRedeclarations = (input, census, identity) => {
263
+ const bindName = (name, declaration) => {
264
+ if (ts.isIdentifier(name)) {
265
+ const configured = input.commonJsGlobals.get(name.text);
266
+ if (!configured)
267
+ return;
268
+ const id = input.identities.declarationIdOf(declaration);
269
+ const global = identity.globalOfDeclaration(declaration);
270
+ if (global === configured.global)
271
+ census.commonJsBindings.set(id, global);
272
+ else
273
+ census.commonJsProvenanceFailures.add(id);
274
+ return;
275
+ }
276
+ for (const element of name.elements) {
277
+ if (ts.isOmittedExpression(element))
278
+ continue;
279
+ bindName(element.name, element);
280
+ }
281
+ };
282
+ const visitSource = (node) => {
283
+ if (ts.isVariableDeclaration(node) && isCommonJsWrapperVarDeclaration(node)) {
284
+ if (ts.isIdentifier(node.name))
285
+ bindName(node.name, node);
286
+ else {
287
+ for (const identifier of commonJsBindingIdentifiers(node.name)) {
288
+ const declaration = ts.isBindingElement(identifier.parent) ? identifier.parent : node;
289
+ bindName(identifier, declaration);
290
+ }
291
+ }
292
+ }
293
+ ts.forEachChild(node, visitSource);
294
+ };
295
+ for (const file of input.files)
296
+ visitSource(file);
297
+ };
298
+ /** An exact host binding reached only as `globalThis.name` or `globalThis['name']`. */
299
+ const bindAmbientGlobalMember = (input, census, node, seedPaths) => {
300
+ if (!input.isIntrinsicGlobalThis(node.expression))
301
+ return null;
302
+ const key = ts.isPropertyAccessExpression(node)
303
+ ? node.name.text
304
+ : ts.isStringLiteralLike(node.argumentExpression) || ts.isNumericLiteral(node.argumentExpression)
305
+ ? node.argumentExpression.text
306
+ : null;
307
+ if (key === null)
308
+ return null;
309
+ const symbol = ts.isPropertyAccessExpression(node)
310
+ ? input.checker.getSymbolAtLocation(node.name)
311
+ : input.checker.getPropertyOfType(input.checker.getTypeAtLocation(node.expression), key);
312
+ if (!symbol || (symbol.flags & ts.SymbolFlags.Value) === 0 || !isAmbientSymbol(symbol))
313
+ return null;
314
+ const declaration = input.identities.valueDeclarationOfSymbol(symbol);
315
+ if (!declaration)
316
+ return null;
317
+ const singleton = input.hostSingletonDeclarations.get(symbol.name);
318
+ const exactSingleton = singleton !== undefined && hasExactHostDeclaration(symbol, singleton);
319
+ const namespace = isHostNamespaceRoot(input, symbol);
320
+ if (!exactSingleton && !namespace)
321
+ return null;
322
+ const id = input.identities.symbolValueDeclarationId(symbol, node);
323
+ if (id === null)
324
+ return null;
325
+ if (exactSingleton)
326
+ census.hostSingletonBindings.add(id);
327
+ if (namespace)
328
+ census.hostNamespaceBindings.add(id);
329
+ census.externals.set(id, symbol.name);
330
+ census.externalFiles.set(id, declaration.getSourceFile().fileName);
331
+ const type = input.checker.getTypeOfSymbolAtLocation(symbol, node);
332
+ const typeId = input.types.typeOf(type);
333
+ if (namespace) {
334
+ const rootType = input.hostNamespaceRootTypes.get(symbol.name);
335
+ if (rootType !== undefined)
336
+ census.namespaceRoots.set(typeId, rootType);
337
+ seedPaths.set(type, symbol.name);
338
+ }
339
+ return type;
340
+ };
341
+ export const ambientHostBindings = (input, census, typedArrayElements) => {
342
+ const seeds = [];
343
+ const commonJsIdentity = createCommonJsWrapperIdentity(input.checker, [...input.files, ...input.commonJsDeclarationFiles], input.commonJsGlobals);
344
+ // A seed a bare namespace-root reference resolved to (`navigator`, `window`)
345
+ // carries the root's own name as the path it was reached by -- see
346
+ // `bindAmbientValue`'s own namespace-root branch. `bindHostObjectClosure`
347
+ // reads this to keep extending the path into that seed's OWN members,
348
+ // exactly as far as the host states members under it and no further.
349
+ const seedPaths = new Map();
350
+ const visit = (node) => {
351
+ if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) {
352
+ const global = bindAmbientGlobalMember(input, census, node, seedPaths);
353
+ if (global)
354
+ seeds.push(global);
355
+ }
356
+ // `isValueReference` is the census's own rule, reused rather than restated:
357
+ // it is what excludes a JSX intrinsic tag (whose symbol is a *type* member
358
+ // on `IntrinsicElements`, not a cell), a property key, and an import
359
+ // specifier's own name. Writing a second rule here bound `div` and `span`
360
+ // as host objects and gave their props interfaces host protocols.
361
+ if (ts.isIdentifier(node)) {
362
+ const value = isValueReference(node, input.namespacePaths) ? bindAmbientValue(input, census, node, seedPaths, commonJsIdentity) : null;
363
+ if (value)
364
+ seeds.push(value);
365
+ // Deliberately NOT an `else`. `isValueReference` is true for plenty of
366
+ // identifiers whose `bindAmbientValue` then answers `null`, so an `else`
367
+ // here never ran at all -- measured: with it, not one of the thirty-nine
368
+ // names bound. The two walks ask different questions of the same
369
+ // identifier and both answers are wanted.
370
+ const stated = bindNativeType(input, census, node);
371
+ // Seeded into the closure below like any other binding, so a host type
372
+ // reached only through a bound type's members -- never spelled by the
373
+ // program itself -- is found the same way `document`'s are.
374
+ if (stated)
375
+ seeds.push(stated);
376
+ const contextual = bindNativeContextualType(input, census, node);
377
+ if (contextual)
378
+ seeds.push(contextual);
379
+ }
380
+ ts.forEachChild(node, visit);
381
+ };
382
+ for (const file of input.files)
383
+ ts.forEachChild(file, visit);
384
+ indexCommonJsVarRedeclarations(input, census, commonJsIdentity);
385
+ bindHostObjectClosure(input, census, seeds, seedPaths);
386
+ typedArrayElementBindings(input, seeds, typedArrayElements);
387
+ };
388
+ /**
389
+ * The checker's own name for each standard-library TypedArray *constructor*
390
+ * type, to the element width/encoding that constructor's instances store.
391
+ *
392
+ * These eight interfaces are core ECMAScript (`lib.es5.d.ts`,
393
+ * `lib.es2015.iterable.d.ts`, `lib.es2017.typedarrays.d.ts`), not a host
394
+ * protocol -- nothing here is framework-shaped or configurable, the same way
395
+ * `primitiveCarrier` (representation/derive.ts) hardcodes `number`/`string`/
396
+ * `boolean` rather than reading them from an installed table.
397
+ *
398
+ * `BigInt64Array`/`BigUint64Array` remain deliberately absent: their elements
399
+ * are BigInts, which no `ScalarDomain`/`TypedArrayElementDomain` models and
400
+ * this backend has no carrier for at all, so a program naming one gets no
401
+ * typed-array carrier and refuses by name rather than being handed a 64-bit
402
+ * integer view whose reads would have to lie about their type. That is the
403
+ * same rule that kept `Uint8ClampedArray` out until its own write rule
404
+ * (ECMA-262 7.1.11) had a verified implementation -- admitting a kind with no
405
+ * verified truncation rule is worse than refusing it -- and it now has one.
406
+ */
407
+ /**
408
+ * The same nine kinds, keyed by the INSTANCE interface's own name.
409
+ *
410
+ * Two tables for two different questions, not one table duplicated.
411
+ * `typedArrayConstructorDomains` below answers "which constructor type is
412
+ * this ambient VALUE?", asked of a seed the program's own text produced;
413
+ * this one answers "which declared TYPE is this?", asked of the standard
414
+ * library directly with no use site at all -- the same independence
415
+ * `standardBufferDeclarationsOf` and `keyedCollectionDeclarationsOf` are
416
+ * written for, and for a reason the seed walk cannot cover:
417
+ * `TextEncoder.prototype.encode` is declared to return `Uint8Array<ArrayBuffer>`,
418
+ * so a program can HOLD a typed array while never naming one. Its declaration
419
+ * then had no element width, so it derived the interface's structural body --
420
+ * a `gea_record_type_N` whose `set`/`subarray`/`fill` are `CallableObject`
421
+ * fields nothing defines -- instead of `gea::TypedArray<std::uint8_t>`.
422
+ *
423
+ * The nine rows are identical in both because they are the same nine kinds
424
+ * for the same reason, `BigInt64Array`/`BigUint64Array` excluded from both by
425
+ * the rule stated below.
426
+ */
427
+ const typedArrayInstanceDomains = new Map([
428
+ ['Int8Array', 'int8'],
429
+ ['Uint8Array', 'uint8'],
430
+ ['Uint8ClampedArray', 'uint8-clamped'],
431
+ ['Int16Array', 'int16'],
432
+ ['Uint16Array', 'uint16'],
433
+ ['Int32Array', 'int32'],
434
+ ['Uint32Array', 'uint32'],
435
+ ['Float32Array', 'float32'],
436
+ ['Float64Array', 'float64']
437
+ ]);
438
+ /**
439
+ * The same nine names, for a caller that only needs to ask "is this receiver
440
+ * one of the standard TypedArray instance interfaces" and has no
441
+ * `IdentityTable`/`DeclarationId` machinery available yet to consume
442
+ * `typedArrayDeclarationsOf` below -- `flow/value-flow.ts` is built in
443
+ * `frontend.ts` before `identities` exists (see that file's own doc comment
444
+ * on `isStandardInterfaceType`). Exported so that caller can resolve each
445
+ * name through the checker itself rather than re-typing this list as a
446
+ * second, independently-maintained answer to "which nine names."
447
+ */
448
+ export const typedArrayInstanceInterfaceNames = [...typedArrayInstanceDomains.keys()];
449
+ /** The nine instance interfaces' declaration identities, resolved by name exactly as `standardBufferDeclarationsOf` resolves `ArrayBuffer`/`DataView` -- see `typedArrayInstanceDomains`. */
450
+ export const typedArrayDeclarationsOf = (checker, identities, files, program, hostDeclarations = []) => {
451
+ const found = new Map();
452
+ const anchor = files[0];
453
+ if (!anchor)
454
+ return found;
455
+ for (const [name, domain] of typedArrayInstanceDomains) {
456
+ const symbol = checker.resolveName(name, anchor, ts.SymbolFlags.Interface, false);
457
+ if (!symbol)
458
+ continue;
459
+ const declaration = identities.symbolDeclarationId(symbol, anchor);
460
+ if (declaration)
461
+ found.set(declaration, domain);
462
+ }
463
+ extendedTypedArrayDeclarations(checker, identities, files, program, hostDeclarations, found);
464
+ return found;
465
+ };
466
+ /**
467
+ * An interface that EXTENDS one of the nine carries the same elements.
468
+ *
469
+ * `interface Buffer extends Uint8Array<ArrayBuffer>` is node's own declaration
470
+ * of its byte view, and TypeScript's answer for it is unambiguous: a `Buffer`
471
+ * has every member a `Uint8Array` has and is assignable to one, which is why
472
+ * bson and the mongodb driver pass a `Buffer` to every `Uint8Array` parameter
473
+ * in the codebase. A physical carrier that is not the typed array cannot be
474
+ * right for such a type, and the one it got instead is the failure this file
475
+ * already records for `TextEncoder.encode`'s return type: the interface's
476
+ * structural body, a record whose `set`/`subarray`/`fill` are
477
+ * `CallableObject` fields nothing defines.
478
+ *
479
+ * Members the extending interface adds of its OWN (`readUInt32LE`,
480
+ * `toString(encoding)`) are not in the carrier and refuse BY NAME at their own
481
+ * access unless a host installs a row for them -- the same rule every typed
482
+ * array already lives under, and the honest one: an added member is the host's
483
+ * to implement, and inventing a record field for it is what produced the
484
+ * undefined callables above.
485
+ *
486
+ * `files` are the program implementation files. A declaration file joins
487
+ * them only when an installed host has authenticated that exact declaration
488
+ * identity; caller `.d.ts` files, and unrelated declarations
489
+ * in the same host file, remain out of this traversal. Run to a fixpoint so a
490
+ * chain (`interface A extends Uint8Array`, `interface B extends A`) resolves
491
+ * whatever order the files are in; the pass is bounded by the number of
492
+ * interfaces, since every lap either adds one or stops.
493
+ */
494
+ const extendedTypedArrayDeclarations = (checker, identities, files, program, hostDeclarations, found) => {
495
+ const interfaces = [];
496
+ const configuredByName = new Map();
497
+ for (const configured of hostDeclarations) {
498
+ const rows = configuredByName.get(configured.declarationName) ?? [];
499
+ rows.push(configured);
500
+ configuredByName.set(configured.declarationName, rows);
501
+ }
502
+ const collect = (node) => {
503
+ if (ts.isInterfaceDeclaration(node))
504
+ interfaces.push(node);
505
+ ts.forEachChild(node, collect);
506
+ };
507
+ for (const file of files)
508
+ ts.forEachChild(file, collect);
509
+ const hostOwners = new Set();
510
+ for (const configured of hostDeclarations) {
511
+ const file = program.getSourceFile(configured.declarationFileName);
512
+ if (!file)
513
+ continue;
514
+ const collectHost = (node) => {
515
+ if (ts.isInterfaceDeclaration(node) && node.name.text === configured.declarationName) {
516
+ const symbol = checker.getSymbolAtLocation(node.name);
517
+ if (symbol && hasExactHostDeclaration(symbol, configured)) {
518
+ hostOwners.add(`${file.fileName}\u0000${configured.declarationName}`);
519
+ interfaces.push(node);
520
+ }
521
+ }
522
+ ts.forEachChild(node, collectHost);
523
+ };
524
+ ts.forEachChild(file, collectHost);
525
+ }
526
+ let added = true;
527
+ while (added) {
528
+ added = false;
529
+ for (const declaration of interfaces) {
530
+ // Resolved with NO use site, exactly as the nine above are resolved
531
+ // against the anchor file: `useSitePath` answers a SPECIALIZATION path
532
+ // for a generic interface named inside a copy, and `Uint8Array<T>` is
533
+ // generic -- so asking at the heritage node minted an id for a copy
534
+ // while the nine were registered at the root, and the two never
535
+ // compared equal. Measured: the rule fired for nothing at all.
536
+ const ownSymbol = checker.getSymbolAtLocation(declaration.name);
537
+ const own = ownSymbol ? identities.symbolDeclarationId(ownSymbol) : null;
538
+ if (!own || found.has(own))
539
+ continue;
540
+ // An exact host row masks the ordinary source-file route too. This is
541
+ // load-bearing for declaration-only `.ts` modules such as node-compat's
542
+ // buffer-types.ts: they are part of `files`, but a caller augmentation
543
+ // must still revoke the host's Buffer carrier claim.
544
+ const configured = configuredByName.get(declaration.name.text);
545
+ if (configured && (!ownSymbol || !configured.some((row) => hasExactHostDeclaration(ownSymbol, row))))
546
+ continue;
547
+ const sourceOwned = files.includes(declaration.getSourceFile());
548
+ if (!sourceOwned && !hostOwners.has(`${declaration.getSourceFile().fileName}\u0000${declaration.name.text}`))
549
+ continue;
550
+ for (const clause of declaration.heritageClauses ?? []) {
551
+ if (clause.token !== ts.SyntaxKind.ExtendsKeyword)
552
+ continue;
553
+ for (const base of clause.types) {
554
+ const symbol = checker.getSymbolAtLocation(base.expression);
555
+ const baseDeclaration = symbol ? identities.symbolDeclarationId(symbol) : null;
556
+ const domain = baseDeclaration ? found.get(baseDeclaration) : undefined;
557
+ if (domain === undefined)
558
+ continue;
559
+ found.set(own, domain);
560
+ added = true;
561
+ }
562
+ }
563
+ }
564
+ }
565
+ };
566
+ const typedArrayConstructorDomains = new Map([
567
+ ['Int8ArrayConstructor', 'int8'],
568
+ ['Uint8ArrayConstructor', 'uint8'],
569
+ // `Uint8ClampedArray` is admitted with its siblings now that its write rule
570
+ // has a verified implementation and a carrier of its own to hold it:
571
+ // ECMA-262 7.1.11 `ToUint8Clamp` -- clamp to [0, 255], round halves to EVEN
572
+ // -- ported from v1's `gea_cpp_typed_array::coerce_element`
573
+ // (`runtime/typed_array.h`), specialized on `gea::ClampedUint8` so the rule
574
+ // is chosen at compile time. See `TypedArrayElementDomain`.
575
+ ['Uint8ClampedArrayConstructor', 'uint8-clamped'],
576
+ ['Int16ArrayConstructor', 'int16'],
577
+ ['Uint16ArrayConstructor', 'uint16'],
578
+ ['Int32ArrayConstructor', 'int32'],
579
+ ['Uint32ArrayConstructor', 'uint32'],
580
+ ['Float32ArrayConstructor', 'float32'],
581
+ ['Float64ArrayConstructor', 'float64']
582
+ ]);
583
+ /**
584
+ * Which declarations name a standard TypedArray *instance* interface, found
585
+ * from the same ambient-value seeds `bindHostObjectClosure` already walks.
586
+ *
587
+ * Reusing `bindAmbientValue`'s seeds rather than `hostObjectTypeOf`'s member
588
+ * closure is deliberate: `hostObjectTypeOf` unwraps a *single* type argument
589
+ * off a container generic (correct for `Promise<Element>`, wrong here --
590
+ * `Uint8ArrayConstructor.from(...)`'s modern return type is
591
+ * `Uint8Array<ArrayBuffer>`, one type argument, and unwrapping it hands back
592
+ * `ArrayBuffer` instead of the typed array itself). A constructor's own
593
+ * construct signatures already state the instance type directly, with no
594
+ * unwrapping needed -- `new (length: number) => Uint8Array<ArrayBuffer>` is
595
+ * the answer as written, not a container to look inside.
596
+ *
597
+ * A seed with no matching name (every ordinary host global) costs one map
598
+ * lookup and contributes nothing, so this runs over every seed unconditionally
599
+ * rather than needing its own identifier walk. This runs whether or not the
600
+ * program ever actually constructs one -- a program that only ever receives a
601
+ * `Uint8Array` as a parameter still mentions the ambient `Uint8Array` name
602
+ * once in that parameter's type position, and `bindAmbientValue` already
603
+ * resolves that mention's merged type/value symbol to the constructor type
604
+ * (`getTypeOfSymbolAtLocation` answers with the value meaning regardless of
605
+ * which position the reference sat in), so the seed is present either way.
606
+ */
607
+ // The five `.getReturnType()`/`getTypeOfSymbolAtLocation` calls in this
608
+ // function and in `bindHostObjectClosure`/`bindAmbientValue` below all walk
609
+ // TYPE-SYSTEM STRUCTURE -- a `ts.Signature`'s own return type, a `ts.Symbol`
610
+ // member's own declared type -- reached from ambient lib.d.ts seeds
611
+ // (`Uint8ArrayConstructor`, `document`, `navigator`, ...), never from a
612
+ // program `ts.Node`. There is no `censusedTypeAt(checker, census, node)`
613
+ // question to ask: the parameter/local/return/field binding censuses answer
614
+ // about program-AUTHORED positions a call site or a write could fill in
615
+ // (an unannotated parameter, a `let` with no initializer, a class field);
616
+ // they carry no information about a host's OWN ambient declarations, and an
617
+ // ambient member/signature has no such node to key on regardless. This
618
+ // whole file's subject is host-protocol IDENTITY -- STATED by the platform's
619
+ // own types -- not a value carrier this compiler could box. Left as direct
620
+ // checker calls throughout.
621
+ const typedArrayElementBindings = (input, seeds, elements) => {
622
+ for (const type of seeds) {
623
+ const domain = typedArrayConstructorDomains.get(type.getSymbol()?.name ?? '');
624
+ if (!domain)
625
+ continue;
626
+ for (const signature of input.checker.getSignaturesOfType(type, ts.SignatureKind.Construct)) {
627
+ const instance = signature.getReturnType();
628
+ const shape = input.table.get(input.types.typeOf(instance))?.shape;
629
+ if (shape?.kind === 'declared' && !elements.has(shape.declaration))
630
+ elements.set(shape.declaration, domain);
631
+ }
632
+ }
633
+ };
634
+ /**
635
+ * The host owns what the host hands you.
636
+ *
637
+ * An ambient value binds a protocol for its own type -- `document` is a
638
+ * `Document`. But the objects that value *returns* are host objects too:
639
+ * `document.getElementById(id)` yields an `Element` the program did not
640
+ * construct, whose members are the host's implementation and not a struct
641
+ * layout this compiler is free to invent. Binding only the seed leaves
642
+ * `Element` deriving as an ordinary record, and a call to `setAttribute` then
643
+ * looks for a struct field that does not exist.
644
+ *
645
+ * The closure is transitive because the relationship is: an `Element`'s
646
+ * `children` are `Element`s. It stops at types that are not ambient, which is
647
+ * what keeps a program's own interface from being turned into a host object
648
+ * merely by being mentioned in a host signature.
649
+ */
650
+ const hostObjectTypeOf = (input, type) => {
651
+ // A member that hands back `Element | null` hands back an Element; the
652
+ // absence is the optional carrier's business, not the protocol's. Array and
653
+ // readonly-array members (`querySelectorAll`) are the same fact once.
654
+ const unwrapped = type.isUnion() ? type.types.filter((arm) => !isNullish(arm)) : [type];
655
+ const single = unwrapped.length === 1 ? unwrapped[0] : undefined;
656
+ if (!single)
657
+ return null;
658
+ const reference = input.checker.getTypeArguments(single);
659
+ const element = reference.length === 1 ? reference[0] : undefined;
660
+ const object = element ?? single;
661
+ // A generic host signature can hand back its caller's T. The structural
662
+ // mapper may already substitute T with a program-owned document type;
663
+ // registering that declaration under the ambient spelling "T" would turn
664
+ // every instance of the document into an imaginary native host handle.
665
+ // An open type parameter is not evidence of host ownership.
666
+ return (object.flags & ts.TypeFlags.TypeParameter) !== 0 ? null : object;
667
+ };
668
+ const isNullish = (type) => (type.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined | ts.TypeFlags.Void)) !== 0;
669
+ /**
670
+ * The declaration identity of the standard library's own `Promise<T>`
671
+ * interface -- resolved independent of whether the program's own text ever
672
+ * names `Promise`, because an `async` function's return type mentions it
673
+ * without a single textual reference the ambient-value seed walk above could
674
+ * pick up (`typedArrayElementBindings`/`bindHostObjectClosure` both start
675
+ * from identifiers actually written in value position; `async function f()
676
+ * {}` has none).
677
+ *
678
+ * `checker.resolveName` is the public TypeChecker API for exactly this:
679
+ * "what does this name mean here", independent of any use site. Any source
680
+ * file anchors the lookup -- `Promise` is a single ambient global, not
681
+ * scoped per-file, so which file supplies the location does not change the
682
+ * answer.
683
+ *
684
+ * Routed through `identities.symbolDeclarationId` rather than a bespoke
685
+ * declaration walk: it already does alias-following and specialization-path
686
+ * resolution the same way every other declaration identity in this file is
687
+ * computed, so a program that re-exports or augments `Promise` is not a
688
+ * second code path to get wrong.
689
+ */
690
+ export const promiseDeclarationOf = (checker, identities, files) => {
691
+ const anchor = files[0];
692
+ if (!anchor)
693
+ return null;
694
+ const symbol = checker.resolveName('Promise', anchor, ts.SymbolFlags.Interface, false);
695
+ if (!symbol)
696
+ return null;
697
+ return identities.symbolDeclarationId(symbol, anchor);
698
+ };
699
+ /**
700
+ * The declaration identity of the standard library's own `Date` INTERFACE --
701
+ * `lib.es5.d.ts`'s `interface Date`, the type of a Date instance, never the
702
+ * `DateConstructor` the global `Date` VALUE has.
703
+ *
704
+ * Resolved exactly the way `promiseDeclarationOf` above resolves `Promise`,
705
+ * and for the same reason: a program can receive a Date purely through an
706
+ * imported signature and never name the type itself, so `checker.resolveName`
707
+ * -- which answers "what does this name mean here" with no use site at all --
708
+ * is what makes the policy installable either way.
709
+ *
710
+ * Date is core ECMAScript with a compiler-owned native layout, the category
711
+ * `Promise<T>`, the eight TypedArray views and the four keyed collections are
712
+ * already in -- NOT a host protocol. Nothing installs it; `lib.es5.d.ts`
713
+ * declares it, and `gea::runtime::Date` (runtime/gea_runtime.h) implements
714
+ * it. Its C++ spelling therefore belongs to the backend's own tables
715
+ * (`targets/cpp/prototype/emit-prototype-date.ts`), never to a plugin package.
716
+ *
717
+ * Consulted ahead of `HostBindingPolicy` in `derive.ts` for the reason
718
+ * `PromiseDeclarationPolicy` states for itself: `Date`'s ambient interface
719
+ * body, run through `declaredBodyOf`'s data-only member stripping, is an
720
+ * EMPTY object shape (every member of `interface Date` is a method), so
721
+ * falling through seals a layout of nothing and the emitter then spells
722
+ * `d.getFullYear` as a struct field that does not exist.
723
+ */
724
+ export const dateDeclarationOf = (checker, identities, files) => {
725
+ const anchor = files[0];
726
+ if (!anchor)
727
+ return null;
728
+ const symbol = checker.resolveName('Date', anchor, ts.SymbolFlags.Interface, false);
729
+ if (!symbol)
730
+ return null;
731
+ return identities.symbolDeclarationId(symbol, anchor);
732
+ };
733
+ /**
734
+ * The declaration identity of the standard `String` WRAPPER-OBJECT interface
735
+ * (`lib.es5.d.ts`'s `interface String`), resolved exactly the way
736
+ * `dateDeclarationOf` immediately above resolves `Date`, and for the same
737
+ * reasons: `new String(x)` can reach the type through an imported signature's
738
+ * return type and never name it directly, so `checker.resolveName` -- which
739
+ * answers "what does this name mean here" independent of any use site -- is
740
+ * what makes the policy installable either way.
741
+ *
742
+ * `String` (the interface, not the `string` primitive or `StringConstructor`
743
+ * the value `String` resolves to) is core ECMAScript with a compiler-owned
744
+ * native layout, the same category `Date` is in -- see
745
+ * `StringObjectDeclarationPolicy` (representation/policies.ts) for the full
746
+ * reasoning on why this must be resolved and checked ahead of
747
+ * `HostBindingPolicy`.
748
+ */
749
+ export const stringObjectDeclarationOf = (checker, identities, files) => {
750
+ const anchor = files[0];
751
+ if (!anchor)
752
+ return null;
753
+ const symbol = checker.resolveName('String', anchor, ts.SymbolFlags.Interface, false);
754
+ if (!symbol)
755
+ return null;
756
+ return identities.symbolDeclarationId(symbol, anchor);
757
+ };
758
+ /** Resolve intrinsic Error interfaces by declaration identity, never at a property use site. */
759
+ export const errorDeclarationsOf = (checker, identities, files) => {
760
+ const anchor = files[0];
761
+ const declarations = new Set();
762
+ if (!anchor)
763
+ return declarations;
764
+ for (const name of ['Error', 'EvalError', 'RangeError', 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError']) {
765
+ const symbol = checker.resolveName(name, anchor, ts.SymbolFlags.Interface, false);
766
+ if (!symbol || !symbol.declarations?.some((declaration) => declaration.getSourceFile().isDeclarationFile))
767
+ continue;
768
+ const declaration = identities.symbolDeclarationId(symbol, anchor);
769
+ if (declaration)
770
+ declarations.add(declaration);
771
+ }
772
+ return declarations;
773
+ };
774
+ /**
775
+ * The declaration identity of the standard `Generator<T, TReturn, TNext>`
776
+ * interface, resolved exactly the way `promiseDeclarationOf` above resolves
777
+ * `Promise` and for the same reasons: independence from whether the program
778
+ * ever writes the name, and one alias-following implementation shared with
779
+ * every other declaration identity in this file.
780
+ *
781
+ * `ts.SymbolFlags.Interface`, because that is what `lib.es2015.generator.d.ts`
782
+ * declares it as. A `lib` that does not install it (an `ES5`-only project)
783
+ * answers `null`, and every `function*` in such a program is then refused
784
+ * rather than mis-carried -- which is correct, since `function*` is not
785
+ * expressible under that `lib` either.
786
+ */
787
+ /**
788
+ * The declaration identity of the bare `Function` interface (`lib.es5.d.ts`'s
789
+ * `interface Function`), resolved exactly the way `stringObjectDeclarationOf`
790
+ * above resolves `String` and for the same reason: a program almost never
791
+ * writes the name, yet reaches the type constantly --
792
+ * `typeof x === 'function'` narrows an `unknown` to it, and
793
+ * `Object.prototype.constructor` is declared as it -- so `checker.resolveName`,
794
+ * which answers "what does this name mean here" independent of any use site,
795
+ * is what makes the policy installable at all.
796
+ *
797
+ * `ts.SymbolFlags.Interface`, because that is what declares it; the value
798
+ * `Function` resolves to `FunctionConstructor`, which is a different symbol
799
+ * and deliberately untouched -- an ambient constructor object really is a host
800
+ * boundary. See `FunctionDeclarationPolicy` (representation/policies.ts).
801
+ */
802
+ export const functionDeclarationOf = (checker, identities, files) => {
803
+ const anchor = files[0];
804
+ if (!anchor)
805
+ return null;
806
+ const symbol = checker.resolveName('Function', anchor, ts.SymbolFlags.Interface, false);
807
+ if (!symbol)
808
+ return null;
809
+ return identities.symbolDeclarationId(symbol, anchor);
810
+ };
811
+ /** Standard `SymbolConstructor` unique-symbol declarations, keyed by declaration identity. */
812
+ export const wellKnownSymbolDeclarationsOf = (checker, identities, files) => {
813
+ const anchor = files[0];
814
+ if (!anchor)
815
+ return new Map();
816
+ const symbol = checker.resolveName('SymbolConstructor', anchor, ts.SymbolFlags.Interface, false);
817
+ if (!symbol)
818
+ return new Map();
819
+ const declared = checker.getDeclaredTypeOfSymbol(symbol);
820
+ const result = new Map();
821
+ for (const member of declared.getProperties()) {
822
+ const declaration = identities.declarationOfSymbol(member);
823
+ if (!declaration)
824
+ continue;
825
+ const type = checker.getTypeOfSymbolAtLocation(member, declaration);
826
+ if ((type.flags & ts.TypeFlags.UniqueESSymbol) === 0)
827
+ continue;
828
+ result.set(identities.declarationIdOf(declaration), member.getName());
829
+ }
830
+ return result;
831
+ };
832
+ /**
833
+ * The declaration identity of the standard `AsyncGenerator<T, TReturn, TNext>`
834
+ * interface -- what an `async function*` returns -- resolved exactly the way
835
+ * `generatorDeclarationOf` below resolves `Generator`.
836
+ *
837
+ * It carries the SAME `iterator(T)` cursor, and that is not an approximation:
838
+ * `gea::Promise<V>` is a settled-value box with no job queue, so every `await`
839
+ * this compiler emits is a synchronous read and an async body has run to
840
+ * completion by the time it returns. Under that model an async generator's
841
+ * `next()` hands back an already-settled result, which is exactly what the
842
+ * synchronous cursor already is (see `producers/control.ts`'s yield comment
843
+ * for the full argument, and for what a port with a real job queue would have
844
+ * to revisit alongside it).
845
+ */
846
+ export const asyncGeneratorDeclarationOf = (checker, identities, files) => {
847
+ const anchor = files[0];
848
+ if (!anchor)
849
+ return null;
850
+ const symbol = checker.resolveName('AsyncGenerator', anchor, ts.SymbolFlags.Interface, false);
851
+ if (!symbol)
852
+ return null;
853
+ return identities.symbolDeclarationId(symbol, anchor);
854
+ };
855
+ export const generatorDeclarationOf = (checker, identities, files) => {
856
+ const anchor = files[0];
857
+ if (!anchor)
858
+ return null;
859
+ const symbol = checker.resolveName('Generator', anchor, ts.SymbolFlags.Interface, false);
860
+ if (!symbol)
861
+ return null;
862
+ return identities.symbolDeclarationId(symbol, anchor);
863
+ };
864
+ /** The standard `MapIterator<T>` returned by `Map.prototype.entries()`. */
865
+ export const mapIteratorDeclarationOf = (checker, identities, files) => {
866
+ const anchor = files[0];
867
+ if (!anchor)
868
+ return null;
869
+ const symbol = checker.resolveName('MapIterator', anchor, ts.SymbolFlags.Interface, false);
870
+ if (!symbol)
871
+ return null;
872
+ return identities.symbolDeclarationId(symbol, anchor);
873
+ };
874
+ /**
875
+ * The four standard keyed-collection interface names, to the family each one
876
+ * is. Hardcoded for exactly the reason `typedArrayConstructorDomains` above
877
+ * is: these are core ECMAScript (`lib.es2015.collection.d.ts`), not something
878
+ * a host installs, so there is no table to read them from and nothing
879
+ * framework-shaped about naming them -- the same way `primitiveCarrier`
880
+ * (representation/derive.ts) names `number`/`string`/`boolean` outright.
881
+ *
882
+ * `ReadonlyMap`/`ReadonlySet` are deliberately absent. They are separate
883
+ * declarations with their own identities, and admitting one here would claim
884
+ * that a `ReadonlyMap<K, V>` parameter and the `Map<K, V>` handed to it are
885
+ * one carrier -- which is true physically and *unproven* here, since nothing
886
+ * in this compiler yet renders the read-only half's own member set. A program
887
+ * that names one still refuses by name rather than silently sharing storage.
888
+ */
889
+ const keyedCollectionFamilies = new Map([
890
+ ['Map', 'map'],
891
+ ['Set', 'set'],
892
+ ['WeakMap', 'weak-map'],
893
+ ['WeakSet', 'weak-set']
894
+ ]);
895
+ /**
896
+ * The declaration identity of each standard keyed-collection interface this
897
+ * compilation's `lib` installs.
898
+ *
899
+ * Resolved exactly the way `promiseDeclarationOf` above resolves `Promise`,
900
+ * and for the same two reasons. First, independence from the program's own
901
+ * text: `const seen: Set<string> = new Set()` names `Set` twice, but
902
+ * `function f(m: Map<string, number>)` in a program that never writes `new
903
+ * Map()` names only the TYPE, and the ambient-VALUE seed walk
904
+ * (`bindAmbientValue`) would still find it -- while a program that receives
905
+ * one purely through an imported signature names neither. `checker.resolveName`
906
+ * answers "what does this name mean here" with no use site at all, so the
907
+ * policy is installed identically either way.
908
+ *
909
+ * Second, and the reason this cannot be left to the host census: that census
910
+ * ALREADY reaches `Map` and binds it as a host protocol, through
911
+ * `MapConstructor.groupBy`'s `Map<K, T[]>` return type. That binding gives
912
+ * every `Map<K, V>` an opaque `native-handle` with no key or value carrier --
913
+ * measured, not supposed: `native-boundary:Map@1` was the missing obligation
914
+ * on a two-line `new Map<string, number>()` probe. `derive.ts` consults this
915
+ * policy first, so the concrete carrier wins over the opaque one; the
916
+ * constructor's own handle (`MapConstructor@1`) is untouched and stays a host
917
+ * boundary, which is correct -- `Map` the value really is a host-supplied
918
+ * constructor object.
919
+ */
920
+ /**
921
+ * The two standard ArrayBuffer-family object types, by the interface name the
922
+ * standard library declares each under.
923
+ *
924
+ * `SharedArrayBuffer` has its own carrier. It is not an `ArrayBuffer` alias:
925
+ * its backing state is what makes Atomics' concurrent protocol truthful.
926
+ */
927
+ const standardBufferKinds = new Map([
928
+ ['ArrayBuffer', 'array-buffer'],
929
+ ['SharedArrayBuffer', 'shared-array-buffer'],
930
+ ['DataView', 'data-view']
931
+ ]);
932
+ /**
933
+ * The declaration identity of the standard `ArrayBuffer` and `DataView`
934
+ * interfaces, resolved exactly the way `keyedCollectionDeclarationsOf` below
935
+ * resolves `Map`/`Set` and for the same two reasons.
936
+ *
937
+ * Independence from the program's own text is the first: `three.js` writes
938
+ * `function f(b: ArrayBuffer)` in files that never construct one, and a
939
+ * program that only ever receives a `DataView` from a signature names neither
940
+ * as a value. `checker.resolveName` answers "what does this name mean here"
941
+ * with no use site at all.
942
+ *
943
+ * The second is the same collision the `Map` comment describes: the
944
+ * ambient-value census ALREADY reaches `ArrayBuffer` -- through
945
+ * `Uint8ArrayConstructor`'s own modern return type `Uint8Array<ArrayBuffer>`,
946
+ * among others -- and binds it as an opaque host protocol, which is what the
947
+ * corpus's three `native-boundary:ArrayBufferConstructor@1` rows were. Consulted
948
+ * first in `derive.ts`, this policy gives the concrete byte-block carrier
949
+ * instead; the CONSTRUCTOR's own handle stays a host boundary, which is
950
+ * correct, because `ArrayBuffer` the value really is a constructor object.
951
+ */
952
+ export const standardBufferDeclarationsOf = (checker, identities, files) => {
953
+ const found = new Map();
954
+ const anchor = files[0];
955
+ if (!anchor)
956
+ return found;
957
+ for (const [name, kind] of standardBufferKinds) {
958
+ const symbol = checker.resolveName(name, anchor, ts.SymbolFlags.Interface, false);
959
+ if (!symbol)
960
+ continue;
961
+ const declaration = identities.symbolDeclarationId(symbol, anchor);
962
+ if (declaration)
963
+ found.set(declaration, kind);
964
+ }
965
+ return found;
966
+ };
967
+ /**
968
+ * The standard library's own NATIVE-BACKED CLASSES, bound to the carrier the
969
+ * backend implements them in.
970
+ *
971
+ * `TextEncoder` and `TextDecoder` are the pair this exists for. They are not a
972
+ * host's protocol -- nothing installs them, no plugin declares them -- and they
973
+ * are not `ArrayBuffer`'s shape either: each is a real object with methods, so
974
+ * the honest carrier is the backend's own C++ class, spelled verbatim through
975
+ * `native-handle`, exactly as an installed host's stated `nativeTypes` carrier
976
+ * is. Which names are in the set, and what each is spelled as, is the
977
+ * BACKEND's answer (`targets/cpp/host/core-globals.ts`); this function knows
978
+ * only how to resolve a name to the two declarations that carry it.
979
+ *
980
+ * Only the INSTANCE type is bound here, and the reason the CONSTRUCTOR is not
981
+ * is worth stating, because it is what shapes the rest of the route:
982
+ *
983
+ * interface TextEncoder extends TextEncoderCommon { encode(...): Uint8Array }
984
+ * declare var TextEncoder: { prototype: TextEncoder; new(): TextEncoder }
985
+ *
986
+ * The instance type is a named interface, so it binds the way every other
987
+ * declared type does. The constructor's type is an ANONYMOUS type literal --
988
+ * unlike `Uint8Array`, whose constructor is the named `Uint8ArrayConstructor`
989
+ * -- and an anonymous type reaches `representation/derive.ts` through its
990
+ * structural body, never through the declaration-keyed binding this function
991
+ * writes, so a row for it here would be a claim nothing reads. The class
992
+ * OBJECT is answered one layer down instead, by name:
993
+ * `projection/bindings.ts` gives it `host-class` storage (no cell, no extern)
994
+ * and `targets/cpp/emit-buffers.ts`'s `emitTextCodecConstruct` spells the
995
+ * construction whole. See `coreGlobalClasses`.
996
+ *
997
+ * Run AFTER `ambientHostBindings`, so it overwrites the weaker binding that
998
+ * census may already have made from the same declaration -- the identical
999
+ * precedence `standardBufferDeclarationsOf` states for `ArrayBuffer`.
1000
+ */
1001
+ export const bindStandardClasses = (input, census, names) => {
1002
+ const anchor = input.files[0];
1003
+ if (!anchor)
1004
+ return;
1005
+ for (const name of names) {
1006
+ const instance = input.checker.resolveName(name, anchor, ts.SymbolFlags.Interface, false);
1007
+ const instanceDeclaration = instance ? input.identities.symbolDeclarationId(instance, anchor) : null;
1008
+ if (instanceDeclaration) {
1009
+ census.protocols.set(instanceDeclaration, { protocol: name, version: 1, native: input.nativeTypes.get(name) ?? null, opaque: false });
1010
+ }
1011
+ }
1012
+ };
1013
+ export const keyedCollectionDeclarationsOf = (checker, identities, files) => {
1014
+ const found = new Map();
1015
+ const anchor = files[0];
1016
+ if (!anchor)
1017
+ return found;
1018
+ for (const [name, family] of keyedCollectionFamilies) {
1019
+ const symbol = checker.resolveName(name, anchor, ts.SymbolFlags.Interface, false);
1020
+ if (!symbol)
1021
+ continue;
1022
+ const declaration = identities.symbolDeclarationId(symbol, anchor);
1023
+ if (declaration)
1024
+ found.set(declaration, family);
1025
+ }
1026
+ return found;
1027
+ };
1028
+ /**
1029
+ * The three standard regular-expression interface names, to the role each one
1030
+ * plays. Hardcoded for exactly the reason `keyedCollectionFamilies` above is:
1031
+ * these are core ECMAScript (`lib.es5.d.ts`), not something a host installs,
1032
+ * so there is no table to read them from.
1033
+ *
1034
+ * `RegExpConstructor` is deliberately absent, and that absence is the point.
1035
+ * `RegExp` the VALUE is an ambient constructor object, and carrying it as a
1036
+ * host handle is the right answer -- `new RegExp(src, flags)` is a boundary
1037
+ * crossing into the runtime. Only the three INSTANCE shapes have a
1038
+ * compiler-owned layout. `RegExpStringIterator` is absent for a different
1039
+ * reason: nothing here mints a standalone iterator, so a program that names
1040
+ * one has to refuse by name rather than silently share a carrier.
1041
+ */
1042
+ const regexpDeclarationKinds = new Map([
1043
+ ['RegExp', 'pattern'],
1044
+ ['RegExpExecArray', 'exec-result'],
1045
+ ['RegExpMatchArray', 'match-result']
1046
+ ]);
1047
+ /**
1048
+ * The declaration identity of each standard regular-expression interface this
1049
+ * compilation's `lib` installs.
1050
+ *
1051
+ * Resolved exactly the way `keyedCollectionDeclarationsOf` above resolves
1052
+ * `Map`, and for both of the same reasons. Independence from the program's own
1053
+ * text first: a regexp LITERAL (`/ab+c/g`) names `RegExp` nowhere, and neither
1054
+ * does `s.match(re)`'s `RegExpMatchArray | null` result -- the ambient-VALUE
1055
+ * seed walk starts from identifiers written in value position, and a literal
1056
+ * writes none. `checker.resolveName` answers "what does this name mean here"
1057
+ * with no use site at all.
1058
+ *
1059
+ * Second, and again the reason this cannot be left to the host census: that
1060
+ * census ALREADY reaches `RegExp` and binds it as a host protocol, through
1061
+ * `RegExpConstructor`'s `new (pattern: string): RegExp` result. That binding
1062
+ * gives every pattern an opaque `native-handle` with no layout -- so
1063
+ * `re.source` has nowhere to go, and `re.lastIndex = 0` has nothing to store
1064
+ * into. `derive.ts` consults this policy first, so the concrete record carrier
1065
+ * wins over the opaque handle; `RegExpConstructor@1` itself is untouched.
1066
+ */
1067
+ export const regexpDeclarationsOf = (checker, identities, files) => {
1068
+ const found = new Map();
1069
+ const anchor = files[0];
1070
+ if (!anchor)
1071
+ return found;
1072
+ for (const [name, kind] of regexpDeclarationKinds) {
1073
+ const symbol = checker.resolveName(name, anchor, ts.SymbolFlags.Interface, false);
1074
+ if (!symbol)
1075
+ continue;
1076
+ const declaration = identities.symbolDeclarationId(symbol, anchor);
1077
+ if (declaration)
1078
+ found.set(declaration, kind);
1079
+ }
1080
+ return found;
1081
+ };
1082
+ const bindHostObjectClosure = (input, census, seeds, seedPaths = new Map()) => {
1083
+ const pending = [...seeds];
1084
+ const visited = new Set();
1085
+ // The path a type was reached by, for the types reached purely as a
1086
+ // namespace segment (`seedPaths`' own seeds, and whatever `admitHandedType`
1087
+ // below extends them into). Absent for every ordinary host object, which is
1088
+ // the common case and needs none of this: `document`'s own closure carries
1089
+ // no path at all, exactly as it did before this table existed.
1090
+ const pathOf = new Map(seedPaths);
1091
+ while (pending.length > 0) {
1092
+ const type = pending.pop();
1093
+ if (!type || visited.has(type))
1094
+ continue;
1095
+ visited.add(type);
1096
+ const path = pathOf.get(type) ?? null;
1097
+ // A host value that is itself CALLABLE hands back what it returns, and an
1098
+ // ambient free FUNCTION is exactly that and nothing else. It has no
1099
+ // receiver, so it is nobody's member and the walk below never reaches it --
1100
+ // which left `MKCoordinateRegionMakeWithDistance`'s `MKCoordinateRegion`
1101
+ // unbound and deriving as an ordinary record, while the identical struct
1102
+ // reached through `map.region` would have been bound. The two routes to one
1103
+ // host type have to agree, for the same reason the three shapes below do.
1104
+ //
1105
+ // A value that can be `new`-ed is not that. `ErrorConstructor` is callable
1106
+ // as well as constructible (`Error(m)` and `new Error(m)` are the same
1107
+ // object), so following its call signature binds `Error` itself as a host
1108
+ // protocol -- which is precisely what the `prototype` skip below refuses,
1109
+ // arriving by a second route. Measured: it cost 44 programs their
1110
+ // certificate at once, every one of them for `native-boundary:Error@1`.
1111
+ // What a program CONSTRUCTS is the program's, and reaching its type through
1112
+ // a construct signature is a separate question this walk does not ask.
1113
+ if (input.checker.getSignaturesOfType(type, ts.SignatureKind.Construct).length === 0) {
1114
+ for (const signature of input.checker.getSignaturesOfType(type, ts.SignatureKind.Call)) {
1115
+ admitHandedType(input, census, pending, signature.getReturnType(), null, null, pathOf);
1116
+ }
1117
+ }
1118
+ for (const member of input.checker.getPropertiesOfType(type)) {
1119
+ // The member is NOT ambient-tested. An interface's own members never
1120
+ // carry the `declare` modifier -- it sits on the interface -- so testing
1121
+ // them rejects every real host member. What has to be ambient is the type
1122
+ // handed back, checked below: the seed already established that this
1123
+ // container is a host's, and a host's member is part of that declaration
1124
+ // by construction.
1125
+ // `prototype` is not something the host hands the program. It is the
1126
+ // constructor's prototype slot, and its type is the *instance* type --
1127
+ // so following it binds every constructed object as a host protocol.
1128
+ // `new Error(m)` would stop being a record the program reads `.message`
1129
+ // off and become an opaque handle, which is the opposite of what the
1130
+ // declaration says. The instance type is reached through the construct
1131
+ // signature when it really is the host's, not through this slot.
1132
+ //
1133
+ // The slot itself, read as a VALUE (`Date.prototype`), is a different
1134
+ // thing again: a namespace-shaped intrinsic whose own members are the
1135
+ // instance methods (`verifyProperty(Date.prototype, "getTime", ...)`).
1136
+ // It is registered under its own protocol, keyed by the slot's
1137
+ // declaration -- which only a `X.prototype` read is ever typed by
1138
+ // (`prototypeObjectTypeAt`) -- so constructed instances stay what the
1139
+ // construct signature says they are.
1140
+ if (member.getName() === 'prototype') {
1141
+ const slot = member.valueDeclaration ?? member.declarations?.[0];
1142
+ if (!slot)
1143
+ continue;
1144
+ const instanceType = input.checker.getTypeOfSymbolAtLocation(member, slot);
1145
+ const instanceName = instanceType.getSymbol()?.name;
1146
+ if (instanceName === undefined)
1147
+ continue;
1148
+ // `X.prototype.constructor` is the one own member the instance
1149
+ // interface does not spell (10.2.4 / every builtin prototype's own
1150
+ // `constructor` data property, writable and configurable); the
1151
+ // backend names its value from the protocol.
1152
+ const constructorMember = { name: 'constructor', kind: 'method', arity: null };
1153
+ census.protocols.set(input.identities.declarationIdOf(slot), {
1154
+ protocol: `${instanceName}.prototype`,
1155
+ version: 1,
1156
+ native: null,
1157
+ opaque: false,
1158
+ members: [...hostIntrinsicMembersOf(input.checker, instanceType), constructorMember]
1159
+ });
1160
+ continue;
1161
+ }
1162
+ const declaration = member.valueDeclaration ?? member.declarations?.[0];
1163
+ if (!declaration)
1164
+ continue;
1165
+ const memberType = input.checker.getTypeOfSymbolAtLocation(member, declaration);
1166
+ // A method hands back its return type; a data member is itself the thing
1167
+ // handed back. Both are objects the host produced.
1168
+ //
1169
+ // A member that can be `new`-ed is the second kind, not the first, and
1170
+ // this is the same rule the seed walk above states: what a program
1171
+ // CONSTRUCTS is the program's. `lib.es5`'s own `Error: ErrorConstructor`
1172
+ // is a member of a host's anonymous shape, and `ErrorConstructor` is
1173
+ // callable as well as constructible -- so following its call signature
1174
+ // bound the `Error` INTERFACE as a host protocol, in nine corpus
1175
+ // programs, none of which mention `Error` at all. A boundary was then
1176
+ // required for `Error@1`, which nothing claims and nothing could: an
1177
+ // error in this compiler is a record the program reads `.message` off,
1178
+ // built by `gea::host::ErrorConstructor::create`, and an opaque handle is
1179
+ // the opposite of that. The constructor object itself is still admitted
1180
+ // below -- it really is a host value, and `ErrorConstructor@1` really is
1181
+ // claimed -- which is what the `[memberType]` fallback already does.
1182
+ const constructible = input.checker.getSignaturesOfType(memberType, ts.SignatureKind.Construct).length > 0;
1183
+ const signatures = constructible ? [] : input.checker.getSignaturesOfType(memberType, ts.SignatureKind.Call);
1184
+ const handed = signatures.length > 0 ? signatures.map((signature) => signature.getReturnType()) : [memberType];
1185
+ // `admitHandedType` combines this with the member's own name -- the
1186
+ // path a member reached purely as a namespace segment continues by
1187
+ // (`navigator` at `"navigator"` hands `mediaDevices` the candidate path
1188
+ // `"navigator.mediaDevices"`) -- and separately checks the bare member
1189
+ // name against the namespace roots on its own, since `window`'s own
1190
+ // `navigator` member names a root (`"navigator"`) independent of
1191
+ // whatever path reached `Window` itself.
1192
+ for (const candidate of handed)
1193
+ admitHandedType(input, census, pending, candidate, path, member.getName(), pathOf);
1194
+ }
1195
+ }
1196
+ };
1197
+ /**
1198
+ * Whether a dotted path names a namespace segment rather than a value -- the
1199
+ * closure walk's own version of `targets/cpp/host-members.ts`'s
1200
+ * `isHostNamespacePath`, asked of the same two facts a plugin states
1201
+ * (`hostNamespaceRoots`, and every leaf key its `hostNamespaces.methods`/
1202
+ * `.properties` publish) rather than the emitter's own table shape, since the
1203
+ * frontend has no `HostNamespaceTable` to ask and needs none: a prefix test
1204
+ * over the leaf paths is the entire fact either layer needs.
1205
+ */
1206
+ const isHostNamespacePathLike = (input, path) => {
1207
+ if (input.hostNamespaceRoots.has(path))
1208
+ return true;
1209
+ const prefix = `${path}.`;
1210
+ for (const leaf of input.hostNamespacePaths)
1211
+ if (leaf.startsWith(prefix))
1212
+ return true;
1213
+ return false;
1214
+ };
1215
+ /**
1216
+ * One type a host handed the program, bound as that host's protocol.
1217
+ *
1218
+ * Shared by both routes into `bindHostObjectClosure` -- what a member yields
1219
+ * and what a call yields -- because they are one question asked twice, and a
1220
+ * second copy of this admission is how the two came to disagree before.
1221
+ *
1222
+ * `path`/`name` are `bindHostObjectClosure`'s own bookkeeping for a candidate
1223
+ * reached as a struct/interface MEMBER: `path` is the path the CONTAINING type
1224
+ * was itself reached by (`null` for an ordinary host object, which is every
1225
+ * caller before this existed), and `name` is the member's own name. Both are
1226
+ * `null` for a candidate reached through a CALL signature's return, which
1227
+ * names no member and so extends no path.
1228
+ *
1229
+ * A candidate whose combined path (or bare member name alone -- `window`'s own
1230
+ * `navigator` member names the root `"navigator"` independent of whatever path
1231
+ * reached `Window`) is a stated namespace segment is never claimed as a
1232
+ * protocol: the host states no carrier for it and states instead that it is a
1233
+ * PATH, exactly as `bindAmbientValue` already treats a bare namespace-root
1234
+ * reference. It is still enqueued for further exploration, because a namespace
1235
+ * segment can still hand back a REAL host object one level further in --
1236
+ * `navigator.mediaDevices.getUserMedia(...)` hands back a `MediaStream`, which
1237
+ * has its own stated carrier and needs its own boundary claimed here as
1238
+ * usual.
1239
+ */
1240
+ const admitHandedType = (input, census, pending, candidate, path, name, pathOf) => {
1241
+ const object = hostObjectTypeOf(input, candidate);
1242
+ const symbol = object?.getSymbol();
1243
+ if (!object || !symbol || !isAmbientSymbol(symbol))
1244
+ return;
1245
+ const shape = input.table.get(input.types.typeOf(object))?.shape;
1246
+ // The same three shapes `bindAmbientValue` admits, and for the reason
1247
+ // it states there: a host declared with `interface` + `declare var` hands back
1248
+ // a `declared` shape, and one declared with `declare class` hands back
1249
+ // `class-instance` (or `class-constructor`, when the member is the class
1250
+ // itself). Admitting only `declared` here made the two walks disagree about
1251
+ // what a host type is -- a host object the program NAMES was bound and the
1252
+ // identical host object the program only RECEIVES was not.
1253
+ //
1254
+ // The gap was invisible until a host was declared entirely in class syntax.
1255
+ // `view.leadingAnchor` hands back `NSLayoutXAxisAnchor`, an ambient
1256
+ // `declare class` the program never writes in value position, so this walk
1257
+ // was its only route to a protocol -- and dropping it left an ambient class
1258
+ // whose members no evaluation publishes, which surfaced at emission as "a get
1259
+ // of constraintEqualToAnchor reaches class decl|f0|531, whose members no class
1260
+ // evaluation published": three layers from the binding that was never made.
1261
+ if (shape === undefined)
1262
+ return;
1263
+ if (shape.kind !== 'declared' && shape.kind !== 'class-constructor' && shape.kind !== 'class-instance')
1264
+ return;
1265
+ // A member whose own bare name is itself a stated root re-roots the path
1266
+ // there rather than nesting under whatever reached the containing type --
1267
+ // `window`'s `navigator` member is the root `"navigator"`, never
1268
+ // `"window.navigator"`, because nothing downstream states members under the
1269
+ // latter and a child reached through it must still extend the path the
1270
+ // host's own tables recognise.
1271
+ const combinedPath = name === null ? null : input.hostNamespaceRoots.has(name) ? name : path === null ? null : `${path}.${name}`;
1272
+ const namespacePath = combinedPath !== null && isHostNamespacePathLike(input, combinedPath);
1273
+ if (namespacePath) {
1274
+ if (combinedPath !== null && !pathOf.has(object))
1275
+ pathOf.set(object, combinedPath);
1276
+ pending.push(object);
1277
+ return;
1278
+ }
1279
+ if (census.protocols.has(shape.declaration))
1280
+ return;
1281
+ // `GEA_PROTOCOL_TRACE=<name substring>` names the path the closure walk took
1282
+ // to reach a protocol, and the declaration file it bound. A protocol with a
1283
+ // null carrier demands `native-boundary:<name>@1`, which nothing can
1284
+ // satisfy, and the only actionable question about one is which host root
1285
+ // reached it -- a question no other output answers.
1286
+ if (process.env['GEA_PROTOCOL_TRACE'] && symbol.name.includes(String(process.env['GEA_PROTOCOL_TRACE']))) {
1287
+ const where = (symbol.declarations ?? [])[0]?.getSourceFile().fileName ?? '?';
1288
+ process.stderr.write(`[PROTOCOL] ${symbol.name} native=${input.nativeTypes.get(symbol.name) ?? '-'} via=${path ?? '(root)'}.${name ?? '?'} decl=${where}\n`);
1289
+ }
1290
+ census.protocols.set(shape.declaration, {
1291
+ opaque: false,
1292
+ protocol: symbol.name,
1293
+ version: 1,
1294
+ native: nativeTypeOf(input, symbol)
1295
+ });
1296
+ pending.push(object);
1297
+ };
1298
+ /**
1299
+ * A signature's own required parameter count: every parameter up to the
1300
+ * first optional or rest one. TypeScript requires optional and rest
1301
+ * parameters to be trailing, so a single forward scan that stops at the
1302
+ * first one it meets is exact, not an approximation of a general rule.
1303
+ */
1304
+ const requiredArityOf = (signature) => {
1305
+ let count = 0;
1306
+ for (const parameter of signature.getParameters()) {
1307
+ const declaration = parameter.valueDeclaration;
1308
+ if (declaration && ts.isParameter(declaration) && (declaration.questionToken || declaration.dotDotDotToken))
1309
+ break;
1310
+ count++;
1311
+ }
1312
+ return count;
1313
+ };
1314
+ /**
1315
+ * The own members of a host intrinsic's declared type, read from the
1316
+ * checker's OWN lib declaration rather than hand-listed here -- see
1317
+ * `HostProtocolBinding.members`'s own comment for why that distinction
1318
+ * matters. `Math` is the type this exists for: `checker.getPropertiesOfType`
1319
+ * on its `lib.es5.d.ts` interface is the SAME list `Object.keys` on a real
1320
+ * `Math` would walk if this compiler modeled Math as a real object rather
1321
+ * than a zero-size tag, so a reflection question over the tag answers from
1322
+ * the identical source of truth.
1323
+ *
1324
+ * The method/value split reuses `bindHostObjectClosure`'s own test (a call
1325
+ * signature on the member's type) rather than inventing a second one: the
1326
+ * two questions -- "is this member a host object to keep walking into" and
1327
+ * "is this member a function" -- read the same signature list, and asking it
1328
+ * twice with two different answers is exactly the drift this compiler's own
1329
+ * "two authorities" defect pattern names.
1330
+ */
1331
+ const hostIntrinsicMembersOf = (checker, type) => {
1332
+ const members = [];
1333
+ for (const member of checker.getPropertiesOfType(type)) {
1334
+ if (member.getName() === 'prototype')
1335
+ continue;
1336
+ // A well-known-symbol-keyed member (`Math[Symbol.toStringTag]`) escapes
1337
+ // with the checker's own internal `__@<name>@<id>` spelling rather than a
1338
+ // string -- `Object.getOwnPropertyNames`, `for...in` and this table's own
1339
+ // consumers all answer STRING-keyed reflection questions only (19.1.2.10,
1340
+ // 13.7.5.6), so a symbol-keyed member is never a candidate answer and
1341
+ // must not enter a table keyed by, and switched over, plain strings.
1342
+ if (member.getName().startsWith('__@'))
1343
+ continue;
1344
+ const declaration = member.valueDeclaration ?? member.declarations?.[0];
1345
+ if (!declaration)
1346
+ continue;
1347
+ const memberType = checker.getTypeOfSymbolAtLocation(member, declaration);
1348
+ const signature = checker.getSignaturesOfType(memberType, ts.SignatureKind.Call)[0];
1349
+ members.push(signature === undefined
1350
+ ? { name: member.getName(), kind: 'value', arity: null }
1351
+ : { name: member.getName(), kind: 'method', arity: requiredArityOf(signature) });
1352
+ }
1353
+ return members;
1354
+ };
1355
+ const bindAmbientValue = (input, census, reference, seedPaths, commonJsIdentity) => {
1356
+ // The same name-to-symbol rule the reference producer applies
1357
+ // (`valueSymbolAt`): checked JavaScript's `module`/`exports` resolve past
1358
+ // the checker's export synthesis to the wrapper declaration the host owns,
1359
+ // or the census below never sees the wrapper cell and the read is emitted
1360
+ // against a declaration the program never introduces.
1361
+ const local = valueSymbolAt(input.checker, reference);
1362
+ if (!local)
1363
+ return null;
1364
+ // An imported name's own symbol is the import specifier, which lives in this
1365
+ // program's file and is not ambient at all. The declaration the program is
1366
+ // really reading is the one the alias points at, and that is the identity
1367
+ // every other layer resolves to as well -- so following the alias is what
1368
+ // makes this walk's answer and the reference producer's the same answer.
1369
+ const symbol = (local.flags & ts.SymbolFlags.Alias) !== 0 ? input.checker.getAliasedSymbol(local) : local;
1370
+ if ((symbol.flags & ts.SymbolFlags.Value) === 0 || !isAmbientSymbol(symbol))
1371
+ return null;
1372
+ const declaration = symbol.valueDeclaration ?? symbol.declarations?.[0];
1373
+ if (!declaration)
1374
+ return null;
1375
+ // Every ambient value gets a linkage entry, whatever its type: the program
1376
+ // reads a cell it never introduces, so something has to say where that cell
1377
+ // lives, and "a host defines it under this name" is the only true answer.
1378
+ // Without it the cell has no placement at all, and emission refuses an
1379
+ // ordinary `import { mount }` for a reason the program cannot act on. Whether
1380
+ // the host really does define it is a link-time fact no static census can
1381
+ // see, and a linker already reports it.
1382
+ const externalId = input.identities.declarationIdOf(declaration);
1383
+ const commonJs = commonJsIdentity.classify(reference);
1384
+ if (commonJs.kind === 'wrapper') {
1385
+ census.commonJsBindings.set(externalId, commonJs.global);
1386
+ // A CommonJS wrapper parameter is supplied by a per-module record. It is
1387
+ // neither an external cell nor an ambient native protocol handle.
1388
+ return null;
1389
+ }
1390
+ if (commonJs.kind === 'provenance-failure') {
1391
+ // Record every declaration in a merged Symbol. A caller cannot make a
1392
+ // host-owned `require` look authentic by arranging declaration order, and
1393
+ // the invocation producer can fail closed from whichever declaration the
1394
+ // checker selected as the value declaration.
1395
+ for (const candidate of symbol.declarations ?? [])
1396
+ census.commonJsProvenanceFailures.add(input.identities.declarationIdOf(candidate));
1397
+ }
1398
+ const configuredSingleton = input.hostSingletonDeclarations.get(symbol.name);
1399
+ if (configuredSingleton !== undefined && hasExactHostDeclaration(symbol, configuredSingleton)) {
1400
+ // Keep the authenticated declaration identity, not merely its file name:
1401
+ // declaration merging can otherwise arrange for the host file to become
1402
+ // `valueDeclaration` while a caller contributes a second declaration.
1403
+ census.hostSingletonBindings.add(externalId);
1404
+ }
1405
+ census.externals.set(externalId, symbol.name);
1406
+ const file = declaration.getSourceFile();
1407
+ census.externalFiles.set(externalId, file.fileName);
1408
+ // See `HostCensus.standardLibrary`. Recorded here, beside the linkage name,
1409
+ // because this is the one walk that has both the declaration identity and
1410
+ // the file it came from in hand.
1411
+ if (file.hasNoDefaultLib)
1412
+ census.standardLibrary.add(externalId);
1413
+ const type = input.checker.getTypeOfSymbolAtLocation(symbol, reference);
1414
+ if ((type.flags & ts.TypeFlags.TypeParameter) !== 0)
1415
+ return null;
1416
+ const typeId = input.types.typeOf(type);
1417
+ // What carries a namespace ROOT, recorded before anything asks what SHAPE it
1418
+ // has -- and deliberately not folded into the shape-gated branch below.
1419
+ //
1420
+ // The two answer different questions. That branch decides what the closure
1421
+ // walk does with a root's own MEMBERS, and its gate is about the member
1422
+ // walk's needs. This one decides what the ROOT ITSELF is carried by, and the
1423
+ // shape is exactly the thing that must not gate it: `window`'s type is
1424
+ // `Window & typeof globalThis`, an `intersection`, so the branch below never
1425
+ // fires for the one global that most needs an answer, and the root fell
1426
+ // through to `deriveIntersection` flattening lib.dom's `Window` into a
1427
+ // 26-field struct naming protocol tags no host declares. The plugin's own
1428
+ // table is the whole of the authority: a root it states no type for records
1429
+ // nothing and derives exactly as it did before.
1430
+ const namespaceRoot = isHostNamespaceRoot(input, symbol);
1431
+ if (namespaceRoot) {
1432
+ census.hostNamespaceBindings.add(externalId);
1433
+ const rootType = input.hostNamespaceRootTypes.get(symbol.name);
1434
+ if (rootType !== undefined)
1435
+ census.namespaceRoots.set(typeId, rootType);
1436
+ }
1437
+ const shape = input.table.get(typeId)?.shape;
1438
+ // An ambient `declare class`'s value reference (`UIColor` read, not
1439
+ // constructed) resolves to the class's own constructor type, whose shape
1440
+ // is `class-constructor` -- and a value typed by that class (a parameter,
1441
+ // a `new`-constructed local, or what a static factory hands back)
1442
+ // resolves to `class-instance`. Both anchor the SAME declaration id (one
1443
+ // class, two structural views of it, `structural.ts`'s
1444
+ // `declaredAnchorOf`), so admitting them here reaches the identical "a
1445
+ // host owns this identity" fact `declared` already states for `declare
1446
+ // var Map: MapConstructor` -- through the class syntax instead of the
1447
+ // interface-plus-var one. `derive.ts`'s `deriveClassConstructor` and its
1448
+ // `class-instance` case are what actually read this binding back.
1449
+ //
1450
+ // A seed with none of those three shapes still has to reach
1451
+ // `bindHostObjectClosure` below, unclaimed or not. `declare const
1452
+ // __gea_Display: { ctx: CanvasRenderingContext2D; width: number; ... }`
1453
+ // states an anonymous *shape* for `__gea_Display` itself -- there is no
1454
+ // name to bind the seed to, so it claims no protocol of its own -- but
1455
+ // `ctx` is exactly as host-owned as `document`'s own members are, and the
1456
+ // closure below is what finds a named protocol underneath an anonymous
1457
+ // seed's fields. Returning `null` here (as this used to) drops that
1458
+ // reachability entirely: `bindHostObjectClosure` never learns
1459
+ // `CanvasRenderingContext2D` is a host protocol, so it never walks into
1460
+ // `CanvasRenderingContext2D.canvas` either, and `HTMLCanvasElement` is
1461
+ // left as an ordinary, unbound `declared` shape. `derive.ts`'s `declared`
1462
+ // case then finds no policy for it and falls through to expanding the
1463
+ // full interface as a struct, which reaches `HTMLElement`'s own
1464
+ // `childNodes: NodeListOf<ChildNode>` cycle -- a shape
1465
+ // `structural-self-reference.ts` does not model (only union, intersection,
1466
+ // tuple, array and callable close a cycle without a declared name) -- so
1467
+ // the failure surfaces three layers downstream, at emission, as "no record
1468
+ // layout ... carries unresolved", naming the struct instead of the actual
1469
+ // gap: an ambient value's own type having no name is not evidence its
1470
+ // members are not a host's.
1471
+ if (shape?.kind === 'declared' || shape?.kind === 'class-constructor' || shape?.kind === 'class-instance') {
1472
+ const protocol = type.getSymbol()?.name;
1473
+ // A namespace root claims nothing: a host states that name as a PATH, and
1474
+ // a path has no value to carry. Three apps lost their certificate to the
1475
+ // `Window@1` this used to demand.
1476
+ if (protocol && namespaceRoot) {
1477
+ // The seed is still returned below and still walked by
1478
+ // `bindHostObjectClosure` -- a namespace root's OWN members are exactly
1479
+ // as reachable as `document`'s are (`window.navigator`,
1480
+ // `navigator.mediaDevices`) -- but recorded under the root's own name so
1481
+ // that walk can tell a member that only continues the path from one
1482
+ // that hands back a real, separately-claimed host object.
1483
+ seedPaths.set(type, symbol.name);
1484
+ }
1485
+ else if (protocol) {
1486
+ if (process.env['GEA_PROTOCOL_TRACE'] && protocol.includes(String(process.env['GEA_PROTOCOL_TRACE']))) {
1487
+ const where = (type.getSymbol()?.declarations ?? [])[0]?.getSourceFile().fileName ?? '?';
1488
+ process.stderr.write(`[SEED] ${protocol} native=${input.nativeTypes.get(protocol) ?? '-'} ref=${symbol.name} at=${reference.getSourceFile().fileName} decl=${where}\n`);
1489
+ }
1490
+ const native = nativeTypeOf(input, type.getSymbol() ?? type.aliasSymbol ?? symbol);
1491
+ // Reflectable member list computed only for the opaque tag: a protocol
1492
+ // with a stated host carrier (`native !== null`) is a real value this
1493
+ // backend has some OTHER runtime representation for, and its own
1494
+ // properties -- if it needs to answer for any -- are that carrier's
1495
+ // question, not this compile-time tag's.
1496
+ const members = native === null ? hostIntrinsicMembersOf(input.checker, type) : null;
1497
+ census.protocols.set(shape.declaration, { protocol, version: 1, native, opaque: false, members });
1498
+ }
1499
+ }
1500
+ return type;
1501
+ };