@velarscript/web 0.31.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (385) hide show
  1. package/README.md +1 -1
  2. package/dist/analysis/calls/intrinsics/config.d.ts +10 -0
  3. package/dist/analysis/calls/intrinsics/config.d.ts.map +1 -0
  4. package/dist/analysis/calls/intrinsics/config.js +19 -0
  5. package/dist/analysis/calls/intrinsics/config.js.map +1 -0
  6. package/dist/analysis/calls/intrinsics/forms.d.ts +10 -0
  7. package/dist/analysis/calls/intrinsics/forms.d.ts.map +1 -0
  8. package/dist/analysis/calls/intrinsics/forms.js +38 -0
  9. package/dist/analysis/calls/intrinsics/forms.js.map +1 -0
  10. package/dist/analysis/calls/intrinsics/http.d.ts +10 -0
  11. package/dist/analysis/calls/intrinsics/http.d.ts.map +1 -0
  12. package/dist/analysis/calls/intrinsics/http.js +37 -0
  13. package/dist/analysis/calls/intrinsics/http.js.map +1 -0
  14. package/dist/analysis/calls/intrinsics/reactive.d.ts +10 -0
  15. package/dist/analysis/calls/intrinsics/reactive.d.ts.map +1 -0
  16. package/dist/analysis/calls/intrinsics/reactive.js +30 -0
  17. package/dist/analysis/calls/intrinsics/reactive.js.map +1 -0
  18. package/dist/analysis/calls/intrinsics/storage.d.ts +12 -0
  19. package/dist/analysis/calls/intrinsics/storage.d.ts.map +1 -0
  20. package/dist/analysis/calls/intrinsics/storage.js +86 -0
  21. package/dist/analysis/calls/intrinsics/storage.js.map +1 -0
  22. package/dist/analysis/calls/intrinsics/web.d.ts +10 -0
  23. package/dist/analysis/calls/intrinsics/web.d.ts.map +1 -0
  24. package/dist/analysis/calls/intrinsics/web.js +100 -0
  25. package/dist/analysis/calls/intrinsics/web.js.map +1 -0
  26. package/dist/analysis/calls/intrinsics.d.ts +13 -0
  27. package/dist/analysis/calls/intrinsics.d.ts.map +1 -0
  28. package/dist/analysis/calls/intrinsics.js +31 -0
  29. package/dist/analysis/calls/intrinsics.js.map +1 -0
  30. package/dist/analysis/components/contracts.d.ts +19 -0
  31. package/dist/analysis/components/contracts.d.ts.map +1 -0
  32. package/dist/analysis/components/contracts.js +83 -0
  33. package/dist/analysis/components/contracts.js.map +1 -0
  34. package/dist/analysis/components/declaration.d.ts +4 -0
  35. package/dist/analysis/components/declaration.d.ts.map +1 -0
  36. package/dist/analysis/components/declaration.js +163 -0
  37. package/dist/analysis/components/declaration.js.map +1 -0
  38. package/dist/analysis/components/host.d.ts +61 -0
  39. package/dist/analysis/components/host.d.ts.map +1 -0
  40. package/dist/analysis/components/host.js +22 -0
  41. package/dist/analysis/components/host.js.map +1 -0
  42. package/dist/analysis/components/lifecycle.d.ts +22 -0
  43. package/dist/analysis/components/lifecycle.d.ts.map +1 -0
  44. package/dist/analysis/components/lifecycle.js +33 -0
  45. package/dist/analysis/components/lifecycle.js.map +1 -0
  46. package/dist/analysis/components/ownership.d.ts +74 -0
  47. package/dist/analysis/components/ownership.d.ts.map +1 -0
  48. package/dist/analysis/components/ownership.js +106 -0
  49. package/dist/analysis/components/ownership.js.map +1 -0
  50. package/dist/analysis/declarations.d.ts +99 -0
  51. package/dist/analysis/declarations.d.ts.map +1 -0
  52. package/dist/analysis/declarations.js +176 -0
  53. package/dist/analysis/declarations.js.map +1 -0
  54. package/dist/analysis/inference.d.ts +67 -0
  55. package/dist/analysis/inference.d.ts.map +1 -0
  56. package/dist/analysis/inference.js +236 -0
  57. package/dist/analysis/inference.js.map +1 -0
  58. package/dist/analysis/jsx/attributes.d.ts +103 -0
  59. package/dist/analysis/jsx/attributes.d.ts.map +1 -0
  60. package/dist/analysis/jsx/attributes.js +601 -0
  61. package/dist/analysis/jsx/attributes.js.map +1 -0
  62. package/dist/analysis/jsx/elements.d.ts +17 -0
  63. package/dist/analysis/jsx/elements.d.ts.map +1 -0
  64. package/dist/analysis/jsx/elements.js +213 -0
  65. package/dist/analysis/jsx/elements.js.map +1 -0
  66. package/dist/analysis/jsx/host.d.ts +61 -0
  67. package/dist/analysis/jsx/host.d.ts.map +1 -0
  68. package/dist/analysis/jsx/host.js +15 -0
  69. package/dist/analysis/jsx/host.js.map +1 -0
  70. package/dist/analysis/jsx/keys.d.ts +15 -0
  71. package/dist/analysis/jsx/keys.d.ts.map +1 -0
  72. package/dist/analysis/jsx/keys.js +67 -0
  73. package/dist/analysis/jsx/keys.js.map +1 -0
  74. package/dist/analysis/jsx/security.d.ts +29 -0
  75. package/dist/analysis/jsx/security.d.ts.map +1 -0
  76. package/dist/analysis/jsx/security.js +61 -0
  77. package/dist/analysis/jsx/security.js.map +1 -0
  78. package/dist/analysis/jsx-detection.d.ts +49 -0
  79. package/dist/analysis/jsx-detection.d.ts.map +1 -0
  80. package/dist/analysis/jsx-detection.js +196 -0
  81. package/dist/analysis/jsx-detection.js.map +1 -0
  82. package/dist/analysis/keyed-rebuild.d.ts +148 -0
  83. package/dist/analysis/keyed-rebuild.d.ts.map +1 -0
  84. package/dist/analysis/keyed-rebuild.js +299 -0
  85. package/dist/analysis/keyed-rebuild.js.map +1 -0
  86. package/dist/analysis/keyframes-analysis.d.ts +6 -0
  87. package/dist/analysis/keyframes-analysis.d.ts.map +1 -0
  88. package/dist/analysis/keyframes-analysis.js +79 -0
  89. package/dist/analysis/keyframes-analysis.js.map +1 -0
  90. package/dist/analysis/look/builders.d.ts +29 -0
  91. package/dist/analysis/look/builders.d.ts.map +1 -0
  92. package/dist/analysis/look/builders.js +168 -0
  93. package/dist/analysis/look/builders.js.map +1 -0
  94. package/dist/analysis/look/conditions.d.ts +13 -0
  95. package/dist/analysis/look/conditions.d.ts.map +1 -0
  96. package/dist/analysis/look/conditions.js +84 -0
  97. package/dist/analysis/look/conditions.js.map +1 -0
  98. package/dist/analysis/look/edits.d.ts +25 -0
  99. package/dist/analysis/look/edits.d.ts.map +1 -0
  100. package/dist/analysis/look/edits.js +57 -0
  101. package/dist/analysis/look/edits.js.map +1 -0
  102. package/dist/analysis/look/entries.d.ts +56 -0
  103. package/dist/analysis/look/entries.d.ts.map +1 -0
  104. package/dist/analysis/look/entries.js +223 -0
  105. package/dist/analysis/look/entries.js.map +1 -0
  106. package/dist/analysis/look/host.d.ts +47 -0
  107. package/dist/analysis/look/host.d.ts.map +1 -0
  108. package/dist/analysis/look/host.js +16 -0
  109. package/dist/analysis/look/host.js.map +1 -0
  110. package/dist/analysis/look/tokens.d.ts +75 -0
  111. package/dist/analysis/look/tokens.d.ts.map +1 -0
  112. package/dist/analysis/look/tokens.js +151 -0
  113. package/dist/analysis/look/tokens.js.map +1 -0
  114. package/dist/analysis/look/values.d.ts +45 -0
  115. package/dist/analysis/look/values.d.ts.map +1 -0
  116. package/dist/analysis/look/values.js +148 -0
  117. package/dist/analysis/look/values.js.map +1 -0
  118. package/dist/analysis/look-conditions.d.ts +47 -0
  119. package/dist/analysis/look-conditions.d.ts.map +1 -0
  120. package/dist/analysis/look-conditions.js +157 -0
  121. package/dist/analysis/look-conditions.js.map +1 -0
  122. package/dist/analysis/look-sites.d.ts +54 -0
  123. package/dist/analysis/look-sites.d.ts.map +1 -0
  124. package/dist/analysis/look-sites.js +104 -0
  125. package/dist/analysis/look-sites.js.map +1 -0
  126. package/dist/analysis/look-vocabulary-guidance.d.ts +76 -0
  127. package/dist/analysis/look-vocabulary-guidance.d.ts.map +1 -0
  128. package/dist/analysis/look-vocabulary-guidance.js +338 -0
  129. package/dist/analysis/look-vocabulary-guidance.js.map +1 -0
  130. package/dist/analysis/media-conditions.d.ts +33 -0
  131. package/dist/analysis/media-conditions.d.ts.map +1 -0
  132. package/dist/analysis/media-conditions.js +92 -0
  133. package/dist/analysis/media-conditions.js.map +1 -0
  134. package/dist/analysis/program-passes.d.ts +106 -0
  135. package/dist/analysis/program-passes.d.ts.map +1 -0
  136. package/dist/analysis/program-passes.js +149 -0
  137. package/dist/analysis/program-passes.js.map +1 -0
  138. package/dist/analysis/reactivity/bindings.d.ts +37 -0
  139. package/dist/analysis/reactivity/bindings.d.ts.map +1 -0
  140. package/dist/analysis/reactivity/bindings.js +88 -0
  141. package/dist/analysis/reactivity/bindings.js.map +1 -0
  142. package/dist/analysis/reactivity/derived.d.ts +39 -0
  143. package/dist/analysis/reactivity/derived.d.ts.map +1 -0
  144. package/dist/analysis/reactivity/derived.js +80 -0
  145. package/dist/analysis/reactivity/derived.js.map +1 -0
  146. package/dist/analysis/reactivity/host.d.ts +38 -0
  147. package/dist/analysis/reactivity/host.d.ts.map +1 -0
  148. package/dist/analysis/reactivity/host.js +14 -0
  149. package/dist/analysis/reactivity/host.js.map +1 -0
  150. package/dist/analysis/reactivity/retired-accessors.d.ts +82 -0
  151. package/dist/analysis/reactivity/retired-accessors.d.ts.map +1 -0
  152. package/dist/analysis/reactivity/retired-accessors.js +118 -0
  153. package/dist/analysis/reactivity/retired-accessors.js.map +1 -0
  154. package/dist/analysis/renderable.d.ts +47 -0
  155. package/dist/analysis/renderable.d.ts.map +1 -0
  156. package/dist/analysis/renderable.js +105 -0
  157. package/dist/analysis/renderable.js.map +1 -0
  158. package/dist/analysis/routes.d.ts +64 -0
  159. package/dist/analysis/routes.d.ts.map +1 -0
  160. package/dist/analysis/routes.js +182 -0
  161. package/dist/analysis/routes.js.map +1 -0
  162. package/dist/analysis/url-attributes.d.ts +12 -0
  163. package/dist/analysis/url-attributes.d.ts.map +1 -0
  164. package/dist/analysis/url-attributes.js +48 -0
  165. package/dist/analysis/url-attributes.js.map +1 -0
  166. package/dist/analysis/watch-cycles.d.ts +102 -0
  167. package/dist/analysis/watch-cycles.d.ts.map +1 -1
  168. package/dist/analysis/watch-cycles.js +240 -1
  169. package/dist/analysis/watch-cycles.js.map +1 -1
  170. package/dist/analysis/watch-subject.d.ts +45 -0
  171. package/dist/analysis/watch-subject.d.ts.map +1 -0
  172. package/dist/analysis/watch-subject.js +272 -0
  173. package/dist/analysis/watch-subject.js.map +1 -0
  174. package/dist/analysis/web-types.d.ts +27 -0
  175. package/dist/analysis/web-types.d.ts.map +1 -0
  176. package/dist/analysis/web-types.js +170 -0
  177. package/dist/analysis/web-types.js.map +1 -0
  178. package/dist/analyzer.d.ts +18 -617
  179. package/dist/analyzer.d.ts.map +1 -1
  180. package/dist/analyzer.js +208 -4853
  181. package/dist/analyzer.js.map +1 -1
  182. package/dist/compiler.d.ts +20 -0
  183. package/dist/compiler.d.ts.map +1 -1
  184. package/dist/compiler.js +29 -864
  185. package/dist/compiler.js.map +1 -1
  186. package/dist/documentation.d.ts +28 -0
  187. package/dist/documentation.d.ts.map +1 -0
  188. package/dist/documentation.js +67 -0
  189. package/dist/documentation.js.map +1 -0
  190. package/dist/editor/completions.d.ts +12 -0
  191. package/dist/editor/completions.d.ts.map +1 -0
  192. package/dist/editor/completions.js +6 -0
  193. package/dist/editor/completions.js.map +1 -0
  194. package/dist/editor/jsx-completion.d.ts +12 -0
  195. package/dist/editor/jsx-completion.d.ts.map +1 -0
  196. package/dist/editor/jsx-completion.js +137 -0
  197. package/dist/editor/jsx-completion.js.map +1 -0
  198. package/dist/editor/look-completion.d.ts +29 -0
  199. package/dist/editor/look-completion.d.ts.map +1 -0
  200. package/dist/editor/look-completion.js +159 -0
  201. package/dist/editor/look-completion.js.map +1 -0
  202. package/dist/editor.d.ts.map +1 -1
  203. package/dist/editor.js +12 -288
  204. package/dist/editor.js.map +1 -1
  205. package/dist/emit/components.d.ts +33 -0
  206. package/dist/emit/components.d.ts.map +1 -0
  207. package/dist/emit/components.js +135 -0
  208. package/dist/emit/components.js.map +1 -0
  209. package/dist/emit/jsx.d.ts +57 -0
  210. package/dist/emit/jsx.d.ts.map +1 -0
  211. package/dist/emit/jsx.js +384 -0
  212. package/dist/emit/jsx.js.map +1 -0
  213. package/dist/emit/look-css.d.ts +44 -0
  214. package/dist/emit/look-css.d.ts.map +1 -0
  215. package/dist/emit/look-css.js +177 -0
  216. package/dist/emit/look-css.js.map +1 -0
  217. package/dist/emit/look.d.ts +39 -0
  218. package/dist/emit/look.d.ts.map +1 -0
  219. package/dist/emit/look.js +218 -0
  220. package/dist/emit/look.js.map +1 -0
  221. package/dist/emit/runtime-imports.d.ts +40 -0
  222. package/dist/emit/runtime-imports.d.ts.map +1 -0
  223. package/dist/emit/runtime-imports.js +184 -0
  224. package/dist/emit/runtime-imports.js.map +1 -0
  225. package/dist/emitter.d.ts +15 -68
  226. package/dist/emitter.d.ts.map +1 -1
  227. package/dist/emitter.js +79 -1008
  228. package/dist/emitter.js.map +1 -1
  229. package/dist/look/animation.d.ts +7 -0
  230. package/dist/look/animation.d.ts.map +1 -0
  231. package/dist/look/animation.js +13 -0
  232. package/dist/look/animation.js.map +1 -0
  233. package/dist/look/builders.d.ts +35 -0
  234. package/dist/look/builders.d.ts.map +1 -0
  235. package/dist/look/builders.js +74 -0
  236. package/dist/look/builders.js.map +1 -0
  237. package/dist/look/css-functions.d.ts +28 -0
  238. package/dist/look/css-functions.d.ts.map +1 -0
  239. package/dist/look/css-functions.js +54 -0
  240. package/dist/look/css-functions.js.map +1 -0
  241. package/dist/look/keyword-sets.d.ts +41 -0
  242. package/dist/look/keyword-sets.d.ts.map +1 -0
  243. package/dist/look/keyword-sets.js +117 -0
  244. package/dist/look/keyword-sets.js.map +1 -0
  245. package/dist/look/keywords.d.ts +55 -0
  246. package/dist/look/keywords.d.ts.map +1 -0
  247. package/dist/look/keywords.js +387 -0
  248. package/dist/look/keywords.js.map +1 -0
  249. package/dist/look/media.d.ts +19 -0
  250. package/dist/look/media.d.ts.map +1 -0
  251. package/dist/look/media.js +27 -0
  252. package/dist/look/media.js.map +1 -0
  253. package/dist/look/naming.d.ts +9 -0
  254. package/dist/look/naming.d.ts.map +1 -0
  255. package/dist/look/naming.js +45 -0
  256. package/dist/look/naming.js.map +1 -0
  257. package/dist/look/properties.d.ts +16 -0
  258. package/dist/look/properties.d.ts.map +1 -0
  259. package/dist/look/properties.js +52 -0
  260. package/dist/look/properties.js.map +1 -0
  261. package/dist/look/shorthands.d.ts +25 -0
  262. package/dist/look/shorthands.d.ts.map +1 -0
  263. package/dist/look/shorthands.js +130 -0
  264. package/dist/look/shorthands.js.map +1 -0
  265. package/dist/look/tokens.d.ts +38 -0
  266. package/dist/look/tokens.d.ts.map +1 -0
  267. package/dist/look/tokens.js +59 -0
  268. package/dist/look/tokens.js.map +1 -0
  269. package/dist/look/units.d.ts +24 -0
  270. package/dist/look/units.d.ts.map +1 -0
  271. package/dist/look/units.js +33 -0
  272. package/dist/look/units.js.map +1 -0
  273. package/dist/look.d.ts +32 -227
  274. package/dist/look.d.ts.map +1 -1
  275. package/dist/look.js +28 -933
  276. package/dist/look.js.map +1 -1
  277. package/dist/module-roster.d.ts +16 -0
  278. package/dist/module-roster.d.ts.map +1 -0
  279. package/dist/module-roster.js +28 -0
  280. package/dist/module-roster.js.map +1 -0
  281. package/dist/modules/app.d.ts +9 -0
  282. package/dist/modules/app.d.ts.map +1 -0
  283. package/dist/modules/app.js +20 -0
  284. package/dist/modules/app.js.map +1 -0
  285. package/dist/modules/browser-test.d.ts +9 -0
  286. package/dist/modules/browser-test.d.ts.map +1 -0
  287. package/dist/modules/browser-test.js +67 -0
  288. package/dist/modules/browser-test.js.map +1 -0
  289. package/dist/modules/browser.d.ts +10 -0
  290. package/dist/modules/browser.d.ts.map +1 -0
  291. package/dist/modules/browser.js +89 -0
  292. package/dist/modules/browser.js.map +1 -0
  293. package/dist/modules/config.d.ts +9 -0
  294. package/dist/modules/config.d.ts.map +1 -0
  295. package/dist/modules/config.js +14 -0
  296. package/dist/modules/config.js.map +1 -0
  297. package/dist/modules/files.d.ts +9 -0
  298. package/dist/modules/files.d.ts.map +1 -0
  299. package/dist/modules/files.js +16 -0
  300. package/dist/modules/files.js.map +1 -0
  301. package/dist/modules/forms.d.ts +9 -0
  302. package/dist/modules/forms.d.ts.map +1 -0
  303. package/dist/modules/forms.js +26 -0
  304. package/dist/modules/forms.js.map +1 -0
  305. package/dist/modules/http.d.ts +9 -0
  306. package/dist/modules/http.d.ts.map +1 -0
  307. package/dist/modules/http.js +127 -0
  308. package/dist/modules/http.js.map +1 -0
  309. package/dist/modules/look.d.ts +9 -0
  310. package/dist/modules/look.d.ts.map +1 -0
  311. package/dist/modules/look.js +58 -0
  312. package/dist/modules/look.js.map +1 -0
  313. package/dist/modules/realtime.d.ts +9 -0
  314. package/dist/modules/realtime.d.ts.map +1 -0
  315. package/dist/modules/realtime.js +163 -0
  316. package/dist/modules/realtime.js.map +1 -0
  317. package/dist/modules/storage.d.ts +9 -0
  318. package/dist/modules/storage.d.ts.map +1 -0
  319. package/dist/modules/storage.js +59 -0
  320. package/dist/modules/storage.js.map +1 -0
  321. package/dist/modules/types.d.ts +78 -0
  322. package/dist/modules/types.d.ts.map +1 -0
  323. package/dist/modules/types.js +154 -0
  324. package/dist/modules/types.js.map +1 -0
  325. package/dist/modules/web.d.ts +9 -0
  326. package/dist/modules/web.d.ts.map +1 -0
  327. package/dist/modules/web.js +63 -0
  328. package/dist/modules/web.js.map +1 -0
  329. package/dist/modules/websocket.d.ts +11 -0
  330. package/dist/modules/websocket.d.ts.map +1 -0
  331. package/dist/modules/websocket.js +75 -0
  332. package/dist/modules/websocket.js.map +1 -0
  333. package/dist/parser/expressions/jsx.d.ts +17 -0
  334. package/dist/parser/expressions/jsx.d.ts.map +1 -0
  335. package/dist/parser/expressions/jsx.js +43 -0
  336. package/dist/parser/expressions/jsx.js.map +1 -0
  337. package/dist/parser/expressions/keyframes.d.ts +15 -0
  338. package/dist/parser/expressions/keyframes.d.ts.map +1 -0
  339. package/dist/parser/expressions/keyframes.js +33 -0
  340. package/dist/parser/expressions/keyframes.js.map +1 -0
  341. package/dist/parser/expressions/look.d.ts +16 -0
  342. package/dist/parser/expressions/look.d.ts.map +1 -0
  343. package/dist/parser/expressions/look.js +37 -0
  344. package/dist/parser/expressions/look.js.map +1 -0
  345. package/dist/parser/expressions/visual-block.d.ts +17 -0
  346. package/dist/parser/expressions/visual-block.d.ts.map +1 -0
  347. package/dist/parser/expressions/visual-block.js +21 -0
  348. package/dist/parser/expressions/visual-block.js.map +1 -0
  349. package/dist/parser/keyframes-source.d.ts +24 -0
  350. package/dist/parser/keyframes-source.d.ts.map +1 -0
  351. package/dist/parser/keyframes-source.js +133 -0
  352. package/dist/parser/keyframes-source.js.map +1 -0
  353. package/dist/parser/look-source.d.ts +25 -0
  354. package/dist/parser/look-source.d.ts.map +1 -0
  355. package/dist/parser/look-source.js +189 -0
  356. package/dist/parser/look-source.js.map +1 -0
  357. package/dist/parser/spans.d.ts +24 -0
  358. package/dist/parser/spans.d.ts.map +1 -0
  359. package/dist/parser/spans.js +113 -0
  360. package/dist/parser/spans.js.map +1 -0
  361. package/dist/parser/statements/components.d.ts +37 -0
  362. package/dist/parser/statements/components.d.ts.map +1 -0
  363. package/dist/parser/statements/components.js +185 -0
  364. package/dist/parser/statements/components.js.map +1 -0
  365. package/dist/parser/statements/heads.d.ts +38 -0
  366. package/dist/parser/statements/heads.d.ts.map +1 -0
  367. package/dist/parser/statements/heads.js +55 -0
  368. package/dist/parser/statements/heads.js.map +1 -0
  369. package/dist/parser/statements/imports.d.ts +9 -0
  370. package/dist/parser/statements/imports.d.ts.map +1 -0
  371. package/dist/parser/statements/imports.js +31 -0
  372. package/dist/parser/statements/imports.js.map +1 -0
  373. package/dist/parser/statements/reactive.d.ts +31 -0
  374. package/dist/parser/statements/reactive.d.ts.map +1 -0
  375. package/dist/parser/statements/reactive.js +68 -0
  376. package/dist/parser/statements/reactive.js.map +1 -0
  377. package/dist/parser/statements/unsafe-css.d.ts +21 -0
  378. package/dist/parser/statements/unsafe-css.d.ts.map +1 -0
  379. package/dist/parser/statements/unsafe-css.js +42 -0
  380. package/dist/parser/statements/unsafe-css.js.map +1 -0
  381. package/dist/parser.d.ts +37 -50
  382. package/dist/parser.d.ts.map +1 -1
  383. package/dist/parser.js +98 -882
  384. package/dist/parser.js.map +1 -1
  385. package/package.json +2 -2
package/dist/compiler.js CHANGED
@@ -1,892 +1,57 @@
1
- import { optionalOf as optional } from "@velarscript/compiler";
2
- import { inferWebIntrinsic, routeContextIdentity, VelarWebAnalyzer } from "./analyzer.js";
3
- import { WEB_STATEMENT_CONSTRUCTS, webExpressionContainsDirectAwait, isWebJsx, webStatementConstructKey, webStatementContainsDirectAwait, } from "./ast.js";
1
+ /**
2
+ * The Web extension's composition root. `compiler.ts` was one 1,136-line module;
3
+ * D115 P4 R3e moved each `velar/*` surface's `ValueType` tables into its own
4
+ * `modules/<surface>.ts` file and the editor prose into `documentation.ts`, and
5
+ * left here what a composition root is: the published surface version, the
6
+ * assembled module map, and the frozen extension literal every part of the
7
+ * toolchain reads the Web target through.
8
+ *
9
+ * Where to look:
10
+ *
11
+ * - `modules/types.ts` the type vocabulary every surface table is written in
12
+ * - `modules/<surface>.ts` one file per `velar/*` surface, holding its tables and its entry
13
+ * - `module-roster.ts` the ordered entry list this file assembles the map from
14
+ * - `documentation.ts` the three editor-documentation tables
15
+ */
16
+ import {} from "@velarscript/compiler";
17
+ import { inferWebIntrinsic, VelarWebAnalyzer } from "./analyzer.js";
18
+ import { WEB_STATEMENT_CONSTRUCTS, webExpressionContainsDirectAwait, webStatementConstructKey, webStatementContainsDirectAwait, } from "./ast.js";
4
19
  import { BROWSER_TEST_MODULE, BROWSER_TEST_SOURCE_SUFFIX, browserTestDrivingGuidance } from "./browser-test.js";
5
- import { WEB_NATIVE_ELEMENTS, WEB_VOID_ELEMENTS } from "./elements.js";
20
+ import { webKeywordDocumentation } from "./documentation.js";
21
+ import { WEB_VOID_ELEMENTS } from "./elements.js";
6
22
  import { WebJavaScriptEmitter } from "./emitter.js";
7
- import { velarWebProjectEditorExtension, webLookPropertyDocumentation } from "./editor.js";
23
+ import { velarWebProjectEditorExtension } from "./editor.js";
8
24
  import { velarWebInspectionExtension } from "./inspection.js";
25
+ import { webModuleEntries } from "./module-roster.js";
26
+ import { mountTargetType, namedFunction, nodeType, nullType, webCanonicalCollectionProjection } from "./modules/types.js";
9
27
  import { VelarWebParser } from "./parser.js";
10
28
  import { scanWebToken, scanWebUnsafeCssLiteral, WEB_CONTEXTUAL_KEYWORDS } from "./lexer.js";
11
29
  import { webModuleSource, webModuleSources } from "./runtime.js";
12
30
  import { velarWebSemanticExtension } from "./semantic.js";
13
- import { LOOK_BUILDER_SIGNATURES, LOOK_BUILDERS, LOOK_HOOKS, LOOK_MEDIA_SUBJECTS, LOOK_PUBLIC_TYPE_NAMES, LOOK_TARGETS, LOOK_UNIT_TYPES } from "./look.js";
14
- import { isWebTypeAssignable, resolveWebTypeSyntax, WEB_OWNED_TYPE_NAMES, webComponentConstructor, webLengthPercentageInput, webNodeType } from "./types.js";
31
+ import { LOOK_BUILDERS, LOOK_MEDIA_SUBJECTS, LOOK_UNIT_TYPES } from "./look.js";
32
+ import { isWebTypeAssignable, resolveWebTypeSyntax, WEB_OWNED_TYPE_NAMES } from "./types.js";
15
33
  export const VELAR_WEB_API_VERSION = "0.14";
16
- const bytesType = { kind: "named", name: "Bytes", identity: "velar/binary#type:Bytes" };
17
34
  // D57 rule 138 gave the browser-test boundary teeth, so the two names it is
18
35
  // written in are part of the published contract: the framework host hands the
19
36
  // suffix to the CLI runner, and tooling that has to name a browser test module
20
37
  // reads both from here instead of spelling them again.
21
38
  export { BROWSER_TEST_MODULE, BROWSER_TEST_SOURCE_SUFFIX } from "./browser-test.js";
22
- const nullType = { kind: "null" };
23
- const stringType = { kind: "string" };
24
- const numberType = { kind: "number" };
25
- const boolType = { kind: "bool" };
26
- const nodeType = webNodeType;
27
- const elementType = { kind: "named", name: "Element" };
28
- const inputElementType = { kind: "named", name: "InputElement" };
29
- const textAreaElementType = { kind: "named", name: "TextAreaElement" };
30
- const canvasElementType = { kind: "named", name: "CanvasElement" };
31
- const dialogElementType = { kind: "named", name: "DialogElement" };
32
- const blobType = { kind: "named", name: "Blob" };
33
- const lengthType = { kind: "named", name: "Length" };
34
- const percentageType = { kind: "named", name: "Percentage" };
35
- const lengthPercentageType = { kind: "named", name: "LengthPercentage" };
36
- const trackFractionType = { kind: "named", name: "TrackFraction" };
37
- const colorType = { kind: "named", name: "Color" };
38
- const colorInputType = colorType;
39
- const borderType = { kind: "named", name: "Border" };
40
- const shadowType = { kind: "named", name: "Shadow" };
41
- const filterType = { kind: "named", name: "Filter" };
42
- const imageType = { kind: "named", name: "Image" };
43
- const trackType = { kind: "named", name: "Track" };
44
- const trackListType = { kind: "named", name: "TrackList" };
45
- /**
46
- * Native JSX construction preserves the order and count of a collection
47
- * projection. Attribute and child holes still have to pass Core's stability
48
- * proof; event arrows are inert values here and run only after dispatch.
49
- * Components, custom elements, refs, and bindings keep the explicit loop
50
- * because their setup can execute user code or write through a binding.
51
- */
52
- function webCanonicalCollectionProjection(expression, pure) {
53
- if (!isWebJsx(expression))
54
- return undefined;
55
- if (expression.tag !== "" && !WEB_NATIVE_ELEMENTS.has(expression.tag))
56
- return false;
57
- for (const attribute of expression.attributes) {
58
- if (attribute.name === "ref" || attribute.name.startsWith("bind:"))
59
- return false;
60
- if (typeof attribute.value === "string" || attribute.value === null)
61
- continue;
62
- if (attribute.name.startsWith("on:") && attribute.value.kind === "ArrowFunctionExpression")
63
- continue;
64
- if (!pure(attribute.value))
65
- return false;
66
- }
67
- for (const child of expression.children) {
68
- if (child.kind === "JSXText")
69
- continue;
70
- if (child.kind === "ExtensionExpression:web:jsx") {
71
- if (webCanonicalCollectionProjection(child, pure) !== true)
72
- return false;
73
- continue;
74
- }
75
- if (!pure(child.expression))
76
- return false;
77
- }
78
- return true;
79
- }
80
- const transitionType = { kind: "named", name: "Transition" };
81
- const keyframesType = { kind: "named", name: "Keyframes" };
82
- const animationType = { kind: "named", name: "Animation" };
83
- const durationType = { kind: "named", name: "Duration" };
84
- const angleType = { kind: "named", name: "Angle" };
85
- const spacingType = { kind: "named", name: "Spacing" };
86
- const mountTargetType = { kind: "union", members: [stringType, elementType] };
87
- const lookScalarType = { kind: "union", members: [numberType, stringType, lengthType, percentageType, lengthPercentageType] };
88
- const trackInputType = { kind: "union", members: [numberType, stringType, lengthType, percentageType, lengthPercentageType, trackFractionType, trackType, trackListType] };
89
- const repeatCountType = { kind: "union", members: [numberType, stringType] };
90
- const lookBuilderResultTypes = {
91
- animation: animationType,
92
- border: borderType,
93
- color: colorType,
94
- filter: filterType,
95
- image: imageType,
96
- length: lengthType, "length-percentage": lengthPercentageType,
97
- shadow: shadowType,
98
- spacing: spacingType,
99
- string: stringType,
100
- track: trackType,
101
- "track-list": trackListType,
102
- transition: transitionType,
103
- };
104
- function namedFunction(parameterNames, parameters, result, requiredParameters = parameters.length) {
105
- return { kind: "function", parameterNames, parameters, requiredParameters, result };
106
- }
107
- /**
108
- * A velar/look builder's published type, with its parameter names and required
109
- * count read from LOOK_BUILDER_SIGNATURES rather than repeated here. The static
110
- * keyframe lowering places named arguments from that same table, so the two
111
- * cannot disagree about what `spread=0px` means.
112
- */
113
- function lookBuilder(name, parameters, rest) {
114
- const signature = LOOK_BUILDER_SIGNATURES.get(name);
115
- if (!signature)
116
- throw new Error(`velar/look builder '${name}' has no declared signature`);
117
- if (signature.parameters.length !== parameters.length) {
118
- throw new Error(`velar/look builder '${name}' declares ${signature.parameters.length} parameters but types ${parameters.length}`);
119
- }
120
- if ((signature.rest ?? false) !== (rest !== undefined)) {
121
- throw new Error(`velar/look builder '${name}' disagrees with its declared rest parameter`);
122
- }
123
- return {
124
- kind: "function",
125
- parameterNames: signature.parameters,
126
- parameters,
127
- requiredParameters: signature.required,
128
- ...(rest ? { rest } : {}),
129
- result: lookBuilderResultTypes[signature.result],
130
- };
131
- }
132
- const unknownType = { kind: "unknown" };
133
39
  const webGlobals = new Map([
134
40
  ["mount", namedFunction(["node", "target"], [nodeType, mountTargetType], nullType)],
135
41
  ["tick", namedFunction([], [], { kind: "promise", value: nullType })],
136
42
  ]);
137
- const lookModuleExports = new Map([
138
- ...LOOK_PUBLIC_TYPE_NAMES.map((name) => [name, { kind: "typeObject", name, value: { kind: "named", name } }]),
139
- // D103: a token reference has no visual kind of its own, because the design
140
- // system owns the value and the compiler cannot see it. `string` is the type
141
- // every checked Look property kind already admits alongside its own visual
142
- // type, which is what makes one spelling legal in all of them; the kinds keep
143
- // their D37 keyword tables, which read literals and folded keywords and so
144
- // never see a call.
145
- ["token", lookBuilder("token", [stringType])],
146
- ["color", lookBuilder("color", [stringType])],
147
- ["rgb", lookBuilder("rgb", [numberType, numberType, numberType])],
148
- ["rgba", lookBuilder("rgba", [numberType, numberType, numberType, numberType])],
149
- ["hsl", lookBuilder("hsl", [numberType, percentageType, percentageType])], // LK-I3: CSS spells those two slots as percentages and so does this language.
150
- ["alpha", lookBuilder("alpha", [colorInputType, numberType])],
151
- ["lighten", lookBuilder("lighten", [colorInputType, numberType])],
152
- ["darken", lookBuilder("darken", [colorInputType, numberType])],
153
- ["border", lookBuilder("border", [lengthType, colorInputType, stringType])],
154
- ["shadow", lookBuilder("shadow", [lengthType, lengthType, lengthType, colorInputType, lengthType, boolType])],
155
- ["blur", lookBuilder("blur", [lengthType])],
156
- ["brightness", lookBuilder("brightness", [numberType])],
157
- ["contrast", lookBuilder("contrast", [numberType])],
158
- ["dropShadow", lookBuilder("dropShadow", [lengthType, lengthType, lengthType, colorInputType])],
159
- ["grayscale", lookBuilder("grayscale", [numberType])],
160
- ["hueRotate", lookBuilder("hueRotate", [angleType])],
161
- ["invert", lookBuilder("invert", [numberType])],
162
- ["filterOpacity", lookBuilder("filterOpacity", [numberType])],
163
- ["saturate", lookBuilder("saturate", [numberType])],
164
- ["sepia", lookBuilder("sepia", [numberType])],
165
- ["filters", lookBuilder("filters", [filterType], filterType)],
166
- ["linearGradient", lookBuilder("linearGradient", [angleType, colorInputType, colorInputType])],
167
- ["asset", lookBuilder("asset", [stringType])],
168
- ["minmax", lookBuilder("minmax", [trackInputType, trackInputType])],
169
- ["repeat", lookBuilder("repeat", [repeatCountType, trackInputType])],
170
- ["tracks", lookBuilder("tracks", [trackInputType], trackInputType)],
171
- ["transition", lookBuilder("transition", [stringType, durationType, stringType, durationType])],
172
- ["spacing", lookBuilder("spacing", [lookScalarType, lookScalarType, lookScalarType, lookScalarType])],
173
- ["min", lookBuilder("min", [webLengthPercentageInput, webLengthPercentageInput])],
174
- ["max", lookBuilder("max", [webLengthPercentageInput, webLengthPercentageInput])],
175
- ["clamp", lookBuilder("clamp", [webLengthPercentageInput, webLengthPercentageInput, webLengthPercentageInput])],
176
- ["animate", lookBuilder("animate", [keyframesType, durationType, stringType, durationType, numberType, boolType, stringType, stringType])],
177
- ]);
178
- // D52 rule 114: `Look.` is gone. JavaScript has no `Look` global, so the
179
- // prefix was ours to invent and ours to withdraw — and a look block is the
180
- // densest run of calls in the language, which is the worst place to spend four
181
- // characters per call on a word that adds nothing. The builders are named
182
- // imports again; `Look` survives only as the type of a look value.
183
43
  const webTextFormTypes = new Set(LOOK_UNIT_TYPES.values());
184
44
  // D72 rule 186: derived from the one published table. `Component` is the only
185
45
  // name that answers `textForm` differently — it is a constructor contract
186
46
  // rather than a value type — so it is subtracted here rather than kept in a
187
47
  // second list.
188
48
  const webOwnedNamedTypes = new Set([...WEB_OWNED_TYPE_NAMES].filter((name) => name !== "Component"));
189
- function functionType(parameters, result, requiredParameters = parameters.length) {
190
- return { kind: "function", parameters, requiredParameters, result };
191
- }
192
- function namedIntrinsic(name, parameterNames, parameters, result, requiredParameters = parameters.length) {
193
- return { kind: "intrinsic", name, parameterNames, parameters, requiredParameters, result };
194
- }
195
- function promise(value) {
196
- return { kind: "promise", value };
197
- }
198
- function object(fields) {
199
- return { kind: "object", fields: new Map(Object.entries(fields)) };
200
- }
201
- /** A structurally declared standard capability handle; see ValueType.capabilityHandle. */
202
- function capabilityHandle(fields) {
203
- return { kind: "object", fields: new Map(Object.entries(fields)), capabilityHandle: true };
204
- }
205
- const errorType = { kind: "class", name: "Error" };
206
- const cleanupType = namedFunction([], [], nullType);
207
- const arrayString = { kind: "list", element: stringType };
208
- const arrayNumber = { kind: "list", element: numberType };
209
- const mapString = (value) => ({ kind: "map", key: stringType, value });
210
- const webElementType = { kind: "union", members: [elementType, inputElementType, canvasElementType, dialogElementType] };
211
- const fileType = { kind: "named", name: "File" };
212
- const fileArrayType = { kind: "list", element: fileType };
213
- const formBodyType = object({
214
- field: namedFunction(["name", "value"], [stringType, stringType], nullType),
215
- file: namedFunction(["name", "value", "fileName"], [stringType, fileType, stringType], nullType, 2),
216
- files: namedFunction(["name", "values"], [stringType, fileArrayType], nullType),
217
- remove: namedFunction(["name"], [stringType], nullType),
218
- has: namedFunction(["name"], [stringType], boolType),
219
- names: namedFunction([], [], arrayString),
220
- });
221
- const httpChunkConsumerType = namedFunction(["chunk"], [stringType], promise(nullType));
222
- const httpTransportPhaseIdentity = "velar/http#enum:HttpTransportPhase";
223
- const httpTransportPhaseMembers = new Set(["request", "response"]);
224
- const httpTransportPhaseWireValues = new Map([...httpTransportPhaseMembers].map((member) => [member, member]));
225
- const httpTransportPhaseType = { kind: "enum", name: "HttpTransportPhase", identity: httpTransportPhaseIdentity };
226
- const httpTransportErrorIdentity = "velar/http#class:HttpTransportError";
227
- // D90 R20: `ok` is gone from the response. `response()` throws
228
- // `HttpResponseError` for every non-2xx, so the only response an author can
229
- // hold has `ok === true` — a field that is always true is a lie in the type,
230
- // and `if not r.ok:` was a dead branch the tour taught twice. The failure
231
- // path is a `catch` that narrows with `is HttpResponseError`, and the
232
- // analyzer says so when the old field is read.
233
- const httpResponseType = object({
234
- status: numberType,
235
- statusText: stringType,
236
- url: stringType,
237
- headers: mapString(stringType),
238
- json: namedFunction([], [], promise(unknownType)),
239
- text: namedFunction([], [], promise(stringType)),
240
- bytes: namedFunction([], [], promise(bytesType)),
241
- streamText: namedFunction(["consume"], [httpChunkConsumerType], promise(nullType)),
242
- blob: namedFunction([], [], promise(blobType)),
243
- parse: namedIntrinsic("runtime.parseAsync", ["target"], [unknownType], promise(unknownType)),
244
- });
245
- const requestType = object({
246
- response: namedFunction([], [], promise(httpResponseType)),
247
- json: namedFunction([], [], promise(unknownType)),
248
- text: namedFunction([], [], promise(stringType)),
249
- bytes: namedFunction([], [], promise(bytesType)),
250
- streamText: namedFunction(["consume"], [httpChunkConsumerType], promise(nullType)),
251
- blob: namedFunction([], [], promise(blobType)),
252
- parse: namedIntrinsic("runtime.parseAsync", ["target"], [unknownType], promise(unknownType)),
253
- cancel: namedFunction([], [], nullType),
254
- });
255
- const httpOptionsType = object({
256
- headers: optional(mapString(stringType)),
257
- body: optional(unknownType),
258
- timeout: optional(numberType),
259
- maxBytes: optional(numberType),
260
- credentials: optional(stringType),
261
- cache: optional(stringType),
262
- });
263
- const httpType = object({
264
- request: namedIntrinsic("http.request", ["method", "url", "options"], [stringType, stringType, httpOptionsType], requestType, 2),
265
- get: namedIntrinsic("http.request", ["url", "options"], [stringType, httpOptionsType], requestType, 1),
266
- post: namedIntrinsic("http.request", ["url", "options"], [stringType, httpOptionsType], requestType, 1),
267
- put: namedIntrinsic("http.request", ["url", "options"], [stringType, httpOptionsType], requestType, 1),
268
- patch: namedIntrinsic("http.request", ["url", "options"], [stringType, httpOptionsType], requestType, 1),
269
- delete: namedIntrinsic("http.request", ["url", "options"], [stringType, httpOptionsType], requestType, 1),
270
- head: namedIntrinsic("http.request", ["url", "options"], [stringType, httpOptionsType], requestType, 1),
271
- });
272
- function createStorageType() {
273
- const common = () => new Map([
274
- ["get", namedIntrinsic("storage.get", ["key", "target", "fallback", "maxBytes"], [stringType, unknownType, unknownType, numberType], unknownType, 2)],
275
- ["set", namedIntrinsic("storage.set", ["key", "value", "maxBytes"], [stringType, unknownType, numberType], nullType, 2)],
276
- ["has", namedFunction(["key"], [stringType], boolType)],
277
- ["keys", namedFunction([], [], arrayString)],
278
- ["remove", namedFunction(["key"], [stringType], nullType)],
279
- ["clear", namedFunction([], [], nullType)],
280
- ["watch", namedIntrinsic("storage.watch", ["key", "target", "callback", "maxBytes"], [stringType, unknownType, unknownType, numberType], cleanupType, 3)],
281
- ]);
282
- const scoped = { kind: "object", fields: common() };
283
- const fields = common();
284
- fields.set("scope", namedFunction(["name"], [stringType], scoped));
285
- return { kind: "object", fields };
286
- }
287
- const storageType = createStorageType();
288
- const storageBatchChangeType = object({ key: stringType, bytes: optional(bytesType) });
289
- const databaseType = object({
290
- get: namedIntrinsic("storage.databaseGet", ["key", "target", "fallback", "maxBytes"], [stringType, unknownType, unknownType, numberType], promise(unknownType), 2),
291
- set: namedIntrinsic("storage.set", ["key", "value", "maxBytes"], [stringType, unknownType, numberType], promise(nullType), 2),
292
- getBytes: namedFunction(["key", "fallback", "maxBytes"], [stringType, optional(bytesType), numberType], promise(optional(bytesType)), 1),
293
- setBytes: namedFunction(["key", "value", "maxBytes"], [stringType, bytesType, numberType], promise(nullType), 2),
294
- batch: namedFunction(["changes"], [{ kind: "list", element: storageBatchChangeType }], promise(nullType)),
295
- has: namedFunction(["key"], [stringType], promise(boolType)),
296
- keys: namedFunction([], [], promise(arrayString)),
297
- remove: namedFunction(["key"], [stringType], promise(nullType)),
298
- clear: namedFunction([], [], promise(nullType)),
299
- });
300
- const storageQuotaErrorIdentity = "velar/storage#class:StorageQuotaError";
301
- const storageTransactionErrorIdentity = "velar/storage#class:StorageTransactionError";
302
- const storageUpgradeErrorIdentity = "velar/storage#class:StorageUpgradeError";
303
- function storageErrorClass(identity) {
304
- return {
305
- identity, parameters: [stringType], parameterNames: ["message"], requiredParameters: 0,
306
- base: "Error", abstract: false, fields: new Map(), getters: new Set(), abstractGetters: new Set(),
307
- methods: new Map(), abstractMethods: new Set(), staticFields: new Map(), staticGetters: new Set(), staticMethods: new Map(),
308
- };
309
- }
310
49
  /**
311
- * D90 R17-a left exactly one `any` standing in this file, and this is it.
312
- *
313
- * `component` holds a component constructor, not a rendered node, so
314
- * `webNodeType` is the wrong family — the two referees that check this slot
315
- * (`checkRouteComponent` and `checkWebRouteComponent`) match it with
316
- * `isWebComponentType`, and `isWebTypeAssignable` refuses a component against a
317
- * node outright. `unknown`, the answer R17 gives every other boundary position
318
- * here, is refused by the shape of assignability rather than by the ruling: a
319
- * writable object field and a List element are both compared *invariantly*, and
320
- * `unknown` is invariant with nothing, so `List<{path, component: Page}>` — the
321
- * type a route list bound to a name actually has — would stop being assignable
322
- * to the Router's `routes` prop. `any` is the only spelling that is invariant
323
- * with every component type at once, and no published name means "some
324
- * component"; R17-a declined to mint one. The slot is checked by its two
325
- * referees, not by this declaration.
50
+ * The `velar/*` surfaces this capability publishes. One `modules/<surface>.ts`
51
+ * file owns each entry's tables; `module-roster.ts` owns the order they are
52
+ * assembled in, because a file this map is built from cannot import the map.
326
53
  */
327
- const routeComponentType = { kind: "any" };
328
- const routeType = object({
329
- path: stringType,
330
- component: routeComponentType,
331
- });
332
- const routeContextFields = new Map([
333
- ["path", stringType],
334
- ["params", mapString(stringType)],
335
- ["query", mapString(stringType)],
336
- ["hash", stringType],
337
- ]);
338
- const routeContextType = { kind: "named", name: "RouteContext", identity: routeContextIdentity };
339
- const navigationOptionsType = object({ replace: optional(boolType), scroll: optional(boolType) });
340
- const formValuesType = { kind: "map", key: stringType, value: unknownType };
341
- const browserLocationType = object({
342
- href: stringType,
343
- origin: stringType,
344
- path: stringType,
345
- query: mapString(stringType),
346
- hash: stringType,
347
- });
348
- const browserEnvironmentType = object({
349
- language: stringType,
350
- languages: arrayString,
351
- online: boolType,
352
- visible: boolType,
353
- colorScheme: stringType,
354
- reducedMotion: boolType,
355
- touch: boolType,
356
- });
357
- const rectType = object({
358
- x: numberType, y: numberType, width: numberType, height: numberType,
359
- top: numberType, right: numberType, bottom: numberType, left: numberType,
360
- });
361
- const scrollMetricsType = object({
362
- x: numberType, y: numberType,
363
- viewportWidth: numberType, viewportHeight: numberType,
364
- contentWidth: numberType, contentHeight: numberType,
365
- });
366
- // P2a-4 — `watchIntersection` completes the `velar/browser` watcher family for
367
- // the one question the family could not answer: has *this element* entered or
368
- // left the viewport. The family's shape is kept exactly — a callback plus a
369
- // `() -> null` cleanup, never a live host object — and the entry carries the
370
- // two fields the platform actually guarantees for a single observed target.
371
- // `time` and the four rectangles are deliberately absent: a rectangle read from
372
- // an observer entry is a layout snapshot from the *observation* moment rather
373
- // than from now, so publishing it would invite exactly the read-a-stale-box
374
- // mistake `measure` exists to avoid.
375
- //
376
- // The configuration is closed rather than an options passthrough: a `root` that
377
- // scopes the observation to a scroll container, and a bounded threshold list.
378
- // `rootMargin` is not in it — it is a CSS-string dialect parsed by the host,
379
- // which is the one thing a checked surface must not accept as a string.
380
- const intersectionEntryType = object({ intersecting: boolType, ratio: numberType });
381
- const intersectionOptionsType = object({ root: optional(webElementType), thresholds: optional(arrayNumber) });
382
- const textSelectionType = object({ start: numberType, end: numberType, direction: stringType });
383
- const fileOptionsType = object({ accept: optional(stringType), multiple: optional(boolType) });
384
- // D51 (audit 12): the realtime handle is a standard capability handle that
385
- // publishes `close()`, so `using` supplies its release contract (charter
386
- // section 16). It is declared structurally rather than as a named type, and
387
- // the marker is what lets Core see it without ever detecting a shape.
388
- //
389
- // `velar/websocket.connect` remains the sole raw WebSocket transport. The
390
- // higher-level `realtimeClient` below composes it with typed codecs, lifecycle,
391
- // and reconnect policy; it does not duplicate framing or invent a second
392
- // socket contract.
393
- const eventStreamHandlersType = object({
394
- open: optional(functionType([], unknownType)),
395
- message: optional(functionType([stringType, stringType], unknownType)),
396
- error: optional(functionType([stringType], unknownType)),
397
- });
398
- const eventStreamType = capabilityHandle({ url: stringType, state: namedFunction([], [], stringType), close: namedFunction([], [], nullType) });
399
- const appErrorType = object({
400
- error: errorType,
401
- phase: stringType,
402
- detail: stringType,
403
- component: stringType,
404
- timestamp: numberType,
405
- });
406
- const browserTestNavigationTimingType = object({
407
- firstContentfulPaintMs: optional(numberType),
408
- domContentLoadedMs: numberType,
409
- loadMs: numberType,
410
- });
411
- const browserTestInteractionTimingType = object({
412
- inputDelayMs: numberType,
413
- processingDurationMs: numberType,
414
- nextFrameMs: numberType,
415
- });
416
- const browserTestAnimationType = object({
417
- count: numberType,
418
- name: stringType,
419
- rotating: boolType,
420
- });
421
- const browserTestControllerType = object({
422
- open: namedFunction(["path"], [stringType], promise(nullType), 0),
423
- reload: namedFunction([], [], promise(nullType)),
424
- click: namedFunction(["selector"], [stringType], promise(nullType)),
425
- fill: namedFunction(["selector", "value"], [stringType, stringType], promise(nullType)),
426
- select: namedFunction(["selector", "value"], [stringType, stringType], promise(nullType)),
427
- press: namedFunction(["selector", "key"], [stringType, stringType], promise(nullType)),
428
- scroll: namedFunction(["selector", "x", "y"], [stringType, numberType, numberType], promise(nullType)),
429
- text: namedFunction(["selector"], [stringType], promise(stringType)),
430
- attribute: namedFunction(["selector", "name"], [stringType, stringType], promise(optional(stringType))),
431
- box: namedFunction(["selector"], [stringType], promise(rectType)),
432
- style: namedFunction(["selector", "property"], [stringType, stringType], promise(stringType)),
433
- namespace: namedFunction(["selector"], [stringType], promise(stringType)),
434
- count: namedFunction(["selector"], [stringType], promise(numberType)),
435
- visible: namedFunction(["selector"], [stringType], promise(boolType)),
436
- waitFor: namedFunction(["selector", "until"], [stringType, stringType], promise(nullType), 1),
437
- waitForText: namedFunction(["selector", "text"], [stringType, stringType], promise(nullType)),
438
- currentPath: namedFunction([], [], promise(stringType)),
439
- viewport: namedFunction(["width", "height"], [numberType, numberType], promise(nullType)),
440
- timings: namedFunction([], [], promise(browserTestNavigationTimingType)),
441
- animation: namedFunction(["selector"], [stringType], promise(browserTestAnimationType)),
442
- measureClick: namedFunction(["selector"], [stringType], promise(browserTestInteractionTimingType)),
443
- measureFill: namedFunction(["selector", "value"], [stringType, stringType], promise(browserTestInteractionTimingType)),
444
- measurePress: namedFunction(["selector", "key"], [stringType, stringType], promise(browserTestInteractionTimingType)),
445
- });
446
- const browserTestStorageControllerType = object({
447
- get: namedFunction(["key"], [stringType], promise(optional(stringType))),
448
- set: namedFunction(["key", "value"], [stringType, stringType], promise(nullType)),
449
- remove: namedFunction(["key"], [stringType], promise(nullType)),
450
- clear: namedFunction([], [], promise(nullType)),
451
- });
452
- const browserTestNetworkControllerType = object({
453
- respond: namedFunction(["path", "body", "status", "contentType", "delayMs"], [stringType, stringType, numberType, stringType, numberType], promise(nullType), 2),
454
- clear: namedFunction([], [], promise(nullType)),
455
- });
456
- const webSocketConnectionIdentity = "velar/websocket#type:WebSocketConnection";
457
- const webSocketCloseIdentity = "velar/websocket#type:WebSocketClose";
458
- const webSocketConnectionType = { kind: "named", name: "WebSocketConnection", identity: webSocketConnectionIdentity };
459
- const webSocketCloseType = { kind: "named", name: "WebSocketClose", identity: webSocketCloseIdentity };
460
- const webSocketMessageType = { kind: "union", members: [stringType, bytesType] };
461
- const webSocketCloseFields = new Map([
462
- ["code", numberType],
463
- ["reason", stringType],
464
- ]);
465
- const webSocketConnectionFields = new Map([
466
- // D90 fr-4: one identity, one field roster. A Web connection is always an
467
- // outbound `connect()` result, which was never upgraded from an Origin and
468
- // therefore reads back null — the same value the Node runtime gives an
469
- // outbound connection. Leaving the field off Web instead would make
470
- // `velar/websocket#type:WebSocketConnection` mean two different things.
471
- ["origin", optional(stringType)],
472
- ["state", namedFunction([], [], stringType)],
473
- ["send", namedFunction(["message"], [webSocketMessageType], promise(nullType))],
474
- ["next", namedFunction([], [], promise(optional(webSocketMessageType)))],
475
- ["closeInfo", namedFunction([], [], promise(webSocketCloseType))],
476
- ["close", namedFunction(["code", "reason"], [numberType, stringType], promise(nullType), 0)],
477
- ]);
478
- const webSocketConnectOptions = object({
479
- timeout: optional(durationType),
480
- maxMessageBytes: optional(numberType),
481
- maxQueuedMessages: optional(numberType),
482
- maxQueuedBytes: optional(numberType),
483
- maxPendingSendBytes: optional(numberType),
484
- });
485
- const webSocketErrorIdentities = new Map([
486
- ["WebSocketBackpressureError", "velar/websocket#class:WebSocketBackpressureError"],
487
- ["WebSocketClosedError", "velar/websocket#class:WebSocketClosedError"],
488
- ["WebSocketProtocolError", "velar/websocket#class:WebSocketProtocolError"],
489
- ["WebSocketTimeoutError", "velar/websocket#class:WebSocketTimeoutError"],
490
- ]);
491
- const webSocketErrorClass = (identity) => ({
492
- identity,
493
- parameters: [stringType],
494
- parameterNames: ["message"],
495
- requiredParameters: 0,
496
- base: "Error",
497
- abstract: false,
498
- fields: new Map(),
499
- getters: new Set(),
500
- abstractGetters: new Set(),
501
- methods: new Map(),
502
- abstractMethods: new Set(),
503
- staticFields: new Map(),
504
- staticGetters: new Set(),
505
- staticMethods: new Map(),
506
- });
507
- const realtimeWireType = webSocketMessageType;
508
- const realtimeCodecIdentity = "velar/realtime#type:RealtimeCodec";
509
- const realtimeClientIdentity = "velar/realtime#type:RealtimeClient";
510
- const realtimeFailureIdentity = "velar/realtime#type:RealtimeFailure";
511
- const realtimeOpenIdentity = "velar/realtime#type:RealtimeOpen";
512
- const realtimeClientStateIdentity = "velar/realtime#enum:RealtimeClientState";
513
- const realtimeFailureActionIdentity = "velar/realtime#enum:RealtimeClientFailureAction";
514
- const realtimeUnavailableIdentity = "velar/realtime#class:RealtimeUnavailableError";
515
- const realtimeClientStates = new Set(["idle", "connecting", "open", "reconnecting", "closed"]);
516
- const realtimeFailureActions = new Set(["continue", "reconnect", "stop"]);
517
- const realtimeClientStateType = { kind: "enum", name: "RealtimeClientState", identity: realtimeClientStateIdentity };
518
- const realtimeFailureActionType = { kind: "enum", name: "RealtimeClientFailureAction", identity: realtimeFailureActionIdentity };
519
- const realtimeFailureType = { kind: "named", name: "RealtimeFailure", identity: realtimeFailureIdentity };
520
- const realtimeOpenType = { kind: "named", name: "RealtimeOpen", identity: realtimeOpenIdentity };
521
- const realtimeCodecIncoming = { kind: "parameter", name: "Incoming", index: 0 };
522
- const realtimeCodecOutgoing = { kind: "parameter", name: "Outgoing", index: 1 };
523
- const realtimeClientOutgoing = { kind: "parameter", name: "T", index: 0 };
524
- const realtimeInput = { kind: "parameter", name: "Incoming", index: 0 };
525
- const realtimeOutput = { kind: "parameter", name: "Outgoing", index: 1 };
526
- function realtimeGenericApplication(name, identity, arguments_) {
527
- const labels = arguments_.map((argument, index) => argument.kind === "parameter" ? argument.name : `T${index + 1}`);
528
- return { kind: "named", name: `${name}<${labels.join(", ")}>`, identity, application: { declaration: identity, name, arguments: arguments_ } };
529
- }
530
- const realtimeCodecOf = (incoming, outgoing) => realtimeGenericApplication("RealtimeCodec", realtimeCodecIdentity, [incoming, outgoing]);
531
- const realtimeClientOf = (outgoing) => realtimeGenericApplication("RealtimeClient", realtimeClientIdentity, [outgoing]);
532
- const realtimeCodecTemplate = {
533
- identity: realtimeCodecIdentity,
534
- name: "RealtimeCodec",
535
- parameterNames: ["Incoming", "Outgoing"],
536
- parameterBounds: [null, null],
537
- fields: new Map([
538
- ["decode", namedFunction(["message"], [realtimeWireType], realtimeCodecIncoming)],
539
- ["encode", namedFunction(["message"], [realtimeCodecOutgoing], realtimeWireType)],
540
- ]),
541
- readonlyFields: new Set(["decode", "encode"]),
542
- };
543
- const realtimeClientTemplate = {
544
- identity: realtimeClientIdentity,
545
- name: "RealtimeClient",
546
- parameterNames: ["T"],
547
- parameterBounds: [null],
548
- fields: new Map([
549
- ["state", namedFunction([], [], realtimeClientStateType)],
550
- ["generation", namedFunction([], [], numberType)],
551
- ["start", namedFunction([], [], promise(nullType))],
552
- ["whenOpen", namedFunction([], [], promise(numberType))],
553
- ["whenClosed", namedFunction([], [], promise(nullType))],
554
- ["send", namedFunction(["message"], [realtimeClientOutgoing], promise(nullType))],
555
- ["close", namedFunction(["code", "reason"], [numberType, stringType], promise(nullType), 0)],
556
- ]),
557
- readonlyFields: new Set(["state", "generation", "start", "whenOpen", "whenClosed", "send", "close"]),
558
- };
559
- const realtimeGenericTypes = new Map([
560
- ["RealtimeCodec", realtimeCodecTemplate],
561
- ["RealtimeClient", realtimeClientTemplate],
562
- ]);
563
- const realtimeFailureFields = new Map([
564
- ["phase", stringType],
565
- ["error", errorType],
566
- ["recoverable", boolType],
567
- ]);
568
- const realtimeOpenFields = new Map([
569
- ["generation", numberType],
570
- ["reconnected", boolType],
571
- ]);
572
- const realtimeClientOptions = object({
573
- connectTimeout: optional(durationType),
574
- maxMessageBytes: optional(numberType),
575
- maxQueuedMessages: optional(numberType),
576
- maxQueuedBytes: optional(numberType),
577
- maxPendingSendBytes: optional(numberType),
578
- reconnectDelays: optional({ kind: "list", element: durationType }),
579
- reconnectJitter: optional(numberType),
580
- retryInitial: optional(boolType),
581
- });
582
- const realtimeClientOutput = realtimeClientOf(realtimeOutput);
583
- const realtimeUrlType = { kind: "union", members: [stringType, namedFunction([], [], stringType)] };
584
- const realtimeReceive = namedFunction(["message", "client"], [realtimeInput, realtimeClientOutput], promise(nullType));
585
- const realtimeOpened = namedFunction(["client", "open"], [realtimeClientOutput, realtimeOpenType], promise(nullType));
586
- const realtimeFailed = namedFunction(["failure", "client"], [realtimeFailureType, realtimeClientOutput], promise(realtimeFailureActionType));
587
- const realtimeClosed = namedFunction(["client", "close"], [realtimeClientOutput, webSocketCloseType], promise(nullType));
588
- const realtimeStateChanged = namedFunction(["client", "state"], [realtimeClientOutput, realtimeClientStateType], promise(nullType));
589
- const realtimeClientFunction = {
590
- kind: "function",
591
- typeParameterNames: ["Incoming", "Outgoing"],
592
- parameterNames: ["url", "codec", "receive", "opened", "failed", "closed", "stateChanged", "options"],
593
- parameters: [
594
- realtimeUrlType,
595
- realtimeCodecOf(realtimeInput, realtimeOutput),
596
- realtimeReceive,
597
- optional(realtimeOpened),
598
- optional(realtimeFailed),
599
- optional(realtimeClosed),
600
- optional(realtimeStateChanged),
601
- realtimeClientOptions,
602
- ],
603
- requiredParameters: 3,
604
- result: realtimeClientOutput,
605
- };
606
- const realtimeUnavailableClass = {
607
- identity: realtimeUnavailableIdentity,
608
- parameters: [stringType],
609
- parameterNames: ["message"],
610
- requiredParameters: 0,
611
- base: "Error",
612
- abstract: false,
613
- fields: new Map(),
614
- getters: new Set(),
615
- abstractGetters: new Set(),
616
- methods: new Map(),
617
- abstractMethods: new Set(),
618
- staticFields: new Map(),
619
- staticGetters: new Set(),
620
- staticMethods: new Map(),
621
- };
622
- export const webModuleInterfaces = new Map([
623
- ["velar/websocket", moduleInterface(new Map([
624
- ["WebSocketConnection", { kind: "typeObject", name: "WebSocketConnection", value: webSocketConnectionType }],
625
- ["WebSocketClose", { kind: "typeObject", name: "WebSocketClose", value: webSocketCloseType }],
626
- ...[...webSocketErrorIdentities].map(([name, identity]) => [name, { kind: "classConstructor", name, identity }]),
627
- ["connect", namedFunction(["url", "options"], [stringType, webSocketConnectOptions], promise(webSocketConnectionType), 1)],
628
- ]), new Map([...webSocketErrorIdentities].map(([name, identity]) => [name, webSocketErrorClass(identity)])), new Map([
629
- ["WebSocketConnection", webSocketConnectionFields],
630
- ["WebSocketClose", webSocketCloseFields],
631
- ]), new Map([
632
- ["WebSocketConnection", webSocketConnectionIdentity],
633
- ["WebSocketClose", webSocketCloseIdentity],
634
- ]), new Map(), new Map([
635
- ["WebSocketConnection", new Set(webSocketConnectionFields.keys())],
636
- ["WebSocketClose", new Set(webSocketCloseFields.keys())],
637
- ]))],
638
- ["velar/look", moduleInterface(lookModuleExports)],
639
- ["velar/app", moduleInterface(new Map([
640
- ["onError", namedFunction(["handler"], [functionType([appErrorType], unknownType)], cleanupType)],
641
- ["reportError", namedFunction(["error", "phase", "detail"], [errorType, stringType, stringType], nullType, 1)],
642
- ]))],
643
- ["velar/config", moduleInterface(new Map([
644
- ["publicConfig", namedIntrinsic("config.public", ["target"], [unknownType], unknownType)],
645
- ["has", namedFunction(["key"], [stringType], boolType)],
646
- ["keys", namedFunction([], [], arrayString)],
647
- ]))],
648
- ["velar/web", moduleInterface(new Map([
649
- ["RouteContext", { kind: "typeObject", name: "RouteContext" }],
650
- ["route", namedIntrinsic("web.route", ["path", "view"], [stringType, unknownType], routeType)],
651
- ["lazy", namedIntrinsic("web.lazy", ["loader", "exportName", "loading", "failed"], [functionType([], promise(unknownType)), stringType, unknownType, unknownType], unknownType, 2)],
652
- ["navigate", namedFunction(["to", "options"], [stringType, navigationOptionsType], nullType, 1)],
653
- ["redirect", namedFunction(["to"], [stringType], nullType)],
654
- ["back", namedFunction([], [], nullType)],
655
- ["forward", namedFunction([], [], nullType)],
656
- ["reload", namedFunction([], [], nullType)],
657
- ["currentRoute", namedFunction([], [], routeContextType)],
658
- ["announce", namedFunction(["message", "priority"], [stringType, stringType], nullType, 1)],
659
- ["domId", namedFunction(["prefix"], [stringType], stringType, 0)],
660
- ["Head", webComponentConstructor("Head", new Map([
661
- ["title", stringType], ["description", stringType], ["canonical", stringType], ["robots", stringType],
662
- ["image", stringType], ["themeColor", stringType], ["language", stringType],
663
- ]), new Set(["title"]), null)],
664
- ["Router", webComponentConstructor("Router", new Map([["routes", { kind: "list", element: routeType }], ["fallback", unknownType]]), new Set(["routes"]), null, "web.router")],
665
- ["Link", webComponentConstructor("Link", new Map([["to", stringType], ["replace", boolType], ["class", optional(stringType)], ["look", optional({ kind: "named", name: "Look" })], ["children", nodeType]]), new Set(["to"]), null)],
666
- ["NavLink", webComponentConstructor("NavLink", new Map([["to", stringType], ["exact", boolType], ["replace", boolType], ["class", optional(stringType)], ["look", optional({ kind: "named", name: "Look" })], ["children", nodeType]]), new Set(["to"]), null)],
667
- ]), new Map(), new Map([["RouteContext", routeContextFields]]), new Map([
668
- ["RouteContext", "@velarscript/web:velar/web#type:RouteContext"],
669
- ]))],
670
- ["velar/http", moduleInterface(new Map([
671
- ["http", httpType],
672
- ["formBody", namedFunction([], [], formBodyType)],
673
- ["HttpTransportPhase", { kind: "enumObject", name: "HttpTransportPhase", identity: httpTransportPhaseIdentity, members: httpTransportPhaseMembers }],
674
- ["HttpAbortError", { kind: "classConstructor", name: "HttpAbortError" }],
675
- ["HttpResponseError", { kind: "classConstructor", name: "HttpResponseError" }],
676
- ["HttpTransportError", { kind: "classConstructor", name: "HttpTransportError", identity: httpTransportErrorIdentity }],
677
- ]), new Map([
678
- ["HttpAbortError", {
679
- parameters: [stringType],
680
- parameterNames: ["reason"],
681
- requiredParameters: 1,
682
- base: "Error",
683
- abstract: false,
684
- fields: new Map([["reason", { mutable: false, type: stringType }]]),
685
- getters: new Set(),
686
- abstractGetters: new Set(),
687
- methods: new Map(),
688
- abstractMethods: new Set(),
689
- staticFields: new Map(),
690
- staticGetters: new Set(),
691
- staticMethods: new Map(),
692
- }],
693
- ["HttpResponseError", {
694
- parameters: [stringType, numberType, stringType, unknownType],
695
- parameterNames: ["message", "status", "url", "body"],
696
- requiredParameters: 3,
697
- base: "Error",
698
- abstract: false,
699
- fields: new Map([
700
- ["status", { mutable: false, type: numberType }],
701
- ["url", { mutable: false, type: stringType }],
702
- ["body", { mutable: false, type: unknownType }],
703
- ]),
704
- getters: new Set(),
705
- abstractGetters: new Set(),
706
- methods: new Map(),
707
- abstractMethods: new Set(),
708
- staticFields: new Map(),
709
- staticGetters: new Set(),
710
- staticMethods: new Map(),
711
- }],
712
- ["HttpTransportError", {
713
- identity: httpTransportErrorIdentity,
714
- parameters: [stringType, httpTransportPhaseType],
715
- parameterNames: ["message", "phase"],
716
- requiredParameters: 2,
717
- base: "Error",
718
- abstract: false,
719
- fields: new Map([["phase", { mutable: false, type: httpTransportPhaseType }]]),
720
- getters: new Set(),
721
- abstractGetters: new Set(),
722
- methods: new Map(),
723
- abstractMethods: new Set(),
724
- staticFields: new Map(),
725
- staticGetters: new Set(),
726
- staticMethods: new Map(),
727
- }],
728
- ]), new Map(), new Map(), new Map([["HttpTransportPhase", { identity: httpTransportPhaseIdentity, members: httpTransportPhaseMembers, wireValues: httpTransportPhaseWireValues }]]))],
729
- ["velar/storage", moduleInterface(new Map([
730
- ["storage", storageType],
731
- ["session", storageType],
732
- ["database", namedFunction(["name"], [stringType], databaseType)],
733
- ["StorageQuotaError", { kind: "classConstructor", name: "StorageQuotaError", identity: storageQuotaErrorIdentity }],
734
- ["StorageTransactionError", { kind: "classConstructor", name: "StorageTransactionError", identity: storageTransactionErrorIdentity }],
735
- ["StorageUpgradeError", { kind: "classConstructor", name: "StorageUpgradeError", identity: storageUpgradeErrorIdentity }],
736
- ]), new Map([
737
- ["StorageQuotaError", storageErrorClass(storageQuotaErrorIdentity)],
738
- ["StorageTransactionError", storageErrorClass(storageTransactionErrorIdentity)],
739
- ["StorageUpgradeError", storageErrorClass(storageUpgradeErrorIdentity)],
740
- ]))],
741
- ["velar/forms", moduleInterface(new Map([
742
- ["values", namedFunction(["form"], [elementType], formValuesType)],
743
- ["read", namedIntrinsic("forms.read", ["form", "target"], [elementType, unknownType], unknownType)],
744
- ["fieldValue", namedFunction(["form", "name"], [elementType, stringType], optional(unknownType))],
745
- ["textValue", namedFunction(["form", "name", "fallback"], [elementType, stringType, stringType], stringType, 2)],
746
- ["numberValue", namedFunction(["form", "name"], [elementType, stringType], optional(numberType))],
747
- ["checkedValue", namedFunction(["form", "name"], [elementType, stringType], boolType)],
748
- ["fieldValues", namedFunction(["form", "name"], [elementType, stringType], arrayString)],
749
- ["setError", namedFunction(["form", "name", "message"], [elementType, stringType, stringType], nullType)],
750
- ["clearError", namedFunction(["form", "name"], [elementType, stringType], nullType)],
751
- ["clearErrors", namedFunction(["form"], [elementType], nullType)],
752
- ["errors", namedFunction(["form"], [elementType], mapString(stringType))],
753
- ["focusFirstError", namedFunction(["form"], [elementType], boolType)],
754
- ["setPending", namedFunction(["form", "pending"], [elementType, boolType], nullType)],
755
- ["reset", namedFunction(["form"], [elementType], nullType)],
756
- ]))],
757
- ["velar/browser", moduleInterface(new Map([
758
- ["after", namedFunction(["duration", "callback"], [durationType, functionType([], unknownType)], cleanupType)],
759
- ["location", namedFunction([], [], browserLocationType)],
760
- ["environment", namedFunction([], [], browserEnvironmentType)],
761
- // D104 rule 4: the two halves of the system clipboard read as a pair. The
762
- // write used to be `copyText`, and a consumer surveying this table for a
763
- // "copy this answer" button found `readClipboardText`, `clipboardText` and
764
- // `setClipboardText` — a read and an event pair — and concluded the module
765
- // could not write. The capability was there under a name that did not
766
- // answer the question being asked, which is the same defect as a missing
767
- // capability from where the author is standing.
768
- ["readClipboardText", namedFunction([], [], promise(stringType))],
769
- ["writeClipboardText", namedFunction(["value"], [stringType], promise(nullType))],
770
- ["open", namedFunction(["url", "target"], [stringType, stringType], nullType, 1)],
771
- ["scrollTo", namedFunction(["x", "y", "behavior"], [numberType, numberType, stringType], nullType, 2)],
772
- ["scrollIntoView", namedFunction(["element", "behavior"], [webElementType, stringType], nullType, 1)],
773
- ["scrollMetrics", namedFunction(["element"], [webElementType], scrollMetricsType)],
774
- ["scrollElementTo", namedFunction(["element", "x", "y", "behavior"], [webElementType, numberType, numberType, stringType], nullType, 3)],
775
- ["focus", namedFunction(["element", "preventScroll"], [webElementType, boolType], nullType, 1)],
776
- ["blur", namedFunction(["element"], [webElementType], nullType)],
777
- ["measure", namedFunction(["element"], [webElementType], rectType)],
778
- ["textSelection", namedFunction(["element"], [textAreaElementType], textSelectionType)],
779
- ["setTextSelection", namedFunction(["element", "start", "end", "direction"], [textAreaElementType, numberType, numberType, stringType], nullType, 3)],
780
- ["clipboardText", namedFunction(["event"], [{ kind: "named", name: "ClipboardEvent" }], stringType)],
781
- ["setClipboardText", namedFunction(["event", "value"], [{ kind: "named", name: "ClipboardEvent" }, stringType], nullType)],
782
- ["capturePointer", namedFunction(["element", "pointerId"], [webElementType, numberType], nullType)],
783
- ["releasePointer", namedFunction(["element", "pointerId"], [webElementType, numberType], nullType)],
784
- ["media", namedFunction(["query"], [stringType], boolType)],
785
- ["watchIntersection", namedFunction(["element", "callback", "options"], [webElementType, functionType([intersectionEntryType], unknownType), intersectionOptionsType], cleanupType, 2)],
786
- ["watchMedia", namedFunction(["query", "callback"], [stringType, functionType([boolType], unknownType)], cleanupType)],
787
- ["watchOnline", namedFunction(["callback"], [functionType([boolType], unknownType)], cleanupType)],
788
- ["watchVisibility", namedFunction(["callback"], [functionType([boolType], unknownType)], cleanupType)],
789
- ["showDialog", namedFunction(["dialog"], [dialogElementType], nullType)],
790
- ["closeDialog", namedFunction(["dialog", "result"], [dialogElementType, stringType], nullType, 1)],
791
- ["dialogResult", namedFunction(["dialog"], [dialogElementType], stringType)],
792
- ["every", namedFunction(["duration", "callback"], [durationType, functionType([], unknownType)], cleanupType)],
793
- ["frame", namedFunction([], [], promise(numberType))],
794
- ]))],
795
- ["velar/files", moduleInterface(new Map([
796
- ["pick", namedFunction(["options"], [fileOptionsType], promise(fileArrayType), 0)],
797
- ["readText", namedFunction(["file", "maxBytes"], [fileType, numberType], promise(stringType), 1)],
798
- ["readDataUrl", namedFunction(["file", "maxBytes"], [fileType, numberType], promise(stringType), 1)],
799
- ["download", namedFunction(["name", "data", "mime"], [stringType, stringType, stringType], nullType, 2)],
800
- ]))],
801
- ["velar/realtime", moduleInterface(new Map([
802
- ["RealtimeClient", { kind: "typeObject", name: "RealtimeClient", value: realtimeClientOf(realtimeClientOutgoing) }],
803
- ["RealtimeClientFailureAction", { kind: "enumObject", name: "RealtimeClientFailureAction", identity: realtimeFailureActionIdentity, members: realtimeFailureActions }],
804
- ["RealtimeClientState", { kind: "enumObject", name: "RealtimeClientState", identity: realtimeClientStateIdentity, members: realtimeClientStates }],
805
- ["RealtimeCodec", { kind: "typeObject", name: "RealtimeCodec", value: realtimeCodecOf(realtimeCodecIncoming, realtimeCodecOutgoing) }],
806
- ["RealtimeFailure", { kind: "typeObject", name: "RealtimeFailure", value: realtimeFailureType }],
807
- ["RealtimeOpen", { kind: "typeObject", name: "RealtimeOpen", value: realtimeOpenType }],
808
- ["RealtimeUnavailableError", { kind: "classConstructor", name: "RealtimeUnavailableError", identity: realtimeUnavailableIdentity }],
809
- ["eventStream", namedFunction(["url", "handlers", "credentials"], [stringType, eventStreamHandlersType, boolType], eventStreamType, 1)],
810
- ["realtimeClient", realtimeClientFunction],
811
- ]), new Map([["RealtimeUnavailableError", realtimeUnavailableClass]]), new Map([
812
- ["RealtimeFailure", realtimeFailureFields],
813
- ["RealtimeOpen", realtimeOpenFields],
814
- ]), new Map([
815
- ["RealtimeFailure", realtimeFailureIdentity],
816
- ["RealtimeOpen", realtimeOpenIdentity],
817
- ]), new Map([
818
- ["RealtimeClientFailureAction", { identity: realtimeFailureActionIdentity, members: realtimeFailureActions, wireValues: new Map([...realtimeFailureActions].map((member) => [member, member])) }],
819
- ["RealtimeClientState", { identity: realtimeClientStateIdentity, members: realtimeClientStates, wireValues: new Map([...realtimeClientStates].map((member) => [member, member])) }],
820
- ]), new Map([
821
- ["RealtimeFailure", new Set(realtimeFailureFields.keys())],
822
- ["RealtimeOpen", new Set(realtimeOpenFields.keys())],
823
- ]), realtimeGenericTypes)],
824
- [BROWSER_TEST_MODULE, moduleInterface(new Map([
825
- ["browser", browserTestControllerType],
826
- ["localStorage", browserTestStorageControllerType],
827
- ["sessionStorage", browserTestStorageControllerType],
828
- ["network", browserTestNetworkControllerType],
829
- ]))],
830
- ]);
831
- function moduleInterface(exports, classes = new Map(), namedTypes = new Map(), namedTypeIdentities = new Map(), enums = new Map(), namedTypeReadonlyFields = new Map(), genericTypes = new Map()) {
832
- return { exports, mutableExports: new Set(), reactiveExports: new Map(), reExports: new Map(), namedTypes, namedTypeReadonlyFields, namedTypeIdentities, genericTypes, typeAliases: new Map(), enums, classes, tests: [], extensionExports: new Map(), extensionData: new Map() };
833
- }
834
- const webLookHookDocumentation = Object.fromEntries([...LOOK_HOOKS].map((name) => [
835
- `@${name}`,
836
- [
837
- `Matches the element's compiler-owned \`${name}\` state inside a \`look:\` condition. It is not a decorator, variable, or runtime callback.`,
838
- "",
839
- "```velar",
840
- `if @${name}:`,
841
- " color = \"blue\"",
842
- "```",
843
- "",
844
- "The condition lowers to the corresponding live CSS state. A Look literal cannot read reactive application state; apply a different Look from JSX for that.",
845
- ].join("\n"),
846
- ]));
847
- const webLookTargetDocumentation = Object.fromEntries([...LOOK_TARGETS].map((name) => [
848
- `@${name}`,
849
- [
850
- `Selects the compiler-owned \`::${name}\` visual target inside a \`look:\` value. It is not a decorator or user-defined nested selector.`,
851
- "",
852
- "```velar",
853
- `@${name}:`,
854
- " content = \"\"",
855
- "```",
856
- "",
857
- "Only the closed target vocabulary accepted by the Web compiler is available, and every nested property remains checked by Look.",
858
- ].join("\n"),
859
- ]));
860
- const webKeywordDocumentation = Object.freeze({
861
- component: "Declares a compiler-managed Web component. Props are its parameters, the body initializes once per mounted instance, and JSX is returned directly.\n\n```velar\ncomponent Greeting(name: string):\n return <p>Hello {name}</p>\n```",
862
- state: "Declares writable reactive state. Reading it records a dependency and assigning it schedules the owning Web update.\n\n```velar\nstate count = 0\n```",
863
- computed: "Declares a read-only reactive value derived synchronously from what its initializer reads. Read the value directly; it is not a function.\n\n```velar\ncomputed doubled = count * 2\n```",
864
- resource: "Declares component-owned asynchronous data with reactive `value`, `loading`, `ready`, `error`, and `reload` fields.\n\n```velar\nresource article: Article = loadArticle(id)\n```",
865
- action: "Declares an asynchronous user operation with reactive `pending` and `error` fields.\n\n```velar\naction save():\n await saveDraft(draft)\n```",
866
- watch: "Runs after the watched reactive path changes and the corresponding DOM update commits. Watch a state/computed path, not an arbitrary effectful expression.\n\n```velar\nwatch query as current, previous:\n print(f\"{previous} -> {current}\")\n```",
867
- "@mounted": "Runs once after the component DOM has been inserted. It is a compiler-owned component lifecycle role, not a decorator or callable hook, and its body may `await`.\n\n```velar\n@mounted:\n await focusInitialField()\n```",
868
- "@cleanup": "Runs once before the component and its owned resources are destroyed. It is a compiler-owned component lifecycle role, not a decorator or callable hook, and cleanup is synchronous.\n\n```velar\n@cleanup:\n subscription.close()\n```",
869
- exposes: "Declares the explicit typed Handle a component permits a parent to receive through JSX `ref`.\n\n```velar\ncomponent Dialog() exposes DialogHandle:\n```",
870
- expose: "Provides the Handle value promised by the component's `exposes` clause.\n\n```velar\nexpose {open, close}\n```",
871
- look: "Builds a typed, composable Web appearance value. Properties, units, conditions, targets, and imported `velar/look` builders are checked by the compiler.\n\n```velar\nconst card = look:\n padding = 16px\n if @hover:\n color = \"blue\"\n```",
872
- keyframes: "Builds checked animation stops as a first-class `Keyframes` value for the `animate` builder.\n\n```velar\nconst spin = keyframes:\n from:\n rotate = 0deg\n to:\n rotate = 1turn\n```",
873
- css: "Marks an explicit unsafe native CSS import or raw block. Prefer Look; when CSS is necessary, its order before or after generated Look output must be stated in source.",
874
- "jsx:on:*": "Attaches a checked DOM event handler. Write `on:event` and optional `.prevent`, `.stop`, `.once`, `.capture`, or `.self` modifiers.\n\n```velar\n<button on:click.prevent={save}>Save</button>\n```",
875
- "jsx:bind:value": "Two-way binds the value of an input, textarea, or select to writable state.\n\n```velar\n<input bind:value={name} />\n```",
876
- "jsx:bind:checked": "Two-way binds an input's checked flag to writable bool state.\n\n```velar\n<input type=\"checkbox\" bind:checked={enabled} />\n```",
877
- "jsx:bind:group": "Binds a radio choice or checkbox group to writable group state using the element's checked value contract.",
878
- "jsx:class:*": "Adds or removes one CSS class from a bool expression. The suffix is the class name.\n\n```velar\n<section class:active={selected}></section>\n```",
879
- "jsx:look": "Applies a `Look`, optional Look, or ordered list of Look values to this JSX element.\n\n```velar\n<article look={cardLook}></article>\n```",
880
- "jsx:look:*": "Applies one checked Look property as a normal-priority JSX visual directive. Prefer a named Look for conditions, targets, or several properties.",
881
- "jsx:style:*": "Applies one checked high-priority inline visual override. Prefer Look for ordinary styling.",
882
- "jsx:ref": "Stores the mounted native element or exposed component Handle in a mutable optional `let` binding, then restores `null` during cleanup.",
883
- "jsx:key": "Gives a repeated JSX child stable identity. Keys must be strings, numbers, or string-backed enum values and must be stable across renders.",
884
- "jsx:host": "Marks the one native element that receives a component's forwarded host attributes and events.",
885
- "jsx:unsafe:html": "Writes explicitly unsafe HTML text into a native element. The value must be string or string?; use ordinary JSX for trusted structured content.",
886
- ...webLookHookDocumentation,
887
- ...webLookTargetDocumentation,
888
- ...webLookPropertyDocumentation,
889
- });
54
+ export const webModuleInterfaces = new Map(webModuleEntries);
890
55
  export const velarCompilerExtension = Object.freeze({
891
56
  id: "@velarscript/web",
892
57
  contract: Object.freeze({ protocolVersion: 1, apiVersion: VELAR_WEB_API_VERSION, kind: "application", extends: Object.freeze({}) }),