@antheo/morph 0.0.0-stage → 0.3.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 (464) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +266 -2
  3. package/SKILL.md +61 -0
  4. package/dist/ai/cli-provider.d.ts +80 -0
  5. package/dist/ai/cli-provider.js +250 -0
  6. package/dist/ai/gate.d.ts +39 -0
  7. package/dist/ai/gate.js +124 -0
  8. package/dist/ai/provider.d.ts +36 -0
  9. package/dist/ai/provider.js +168 -0
  10. package/dist/ai/repair.d.ts +90 -0
  11. package/dist/ai/repair.js +172 -0
  12. package/dist/analyzer/deps.d.ts +30 -0
  13. package/dist/analyzer/deps.js +265 -0
  14. package/dist/analyzer/manifest.d.ts +5 -0
  15. package/dist/analyzer/manifest.js +119 -0
  16. package/dist/analyzer/parse.d.ts +21 -0
  17. package/dist/analyzer/parse.js +29 -0
  18. package/dist/batch-worker.d.ts +16 -0
  19. package/dist/batch-worker.js +10 -0
  20. package/dist/batch.d.ts +26 -0
  21. package/dist/batch.js +227 -0
  22. package/dist/bridge/index.d.ts +26 -0
  23. package/dist/bridge/index.js +138 -0
  24. package/dist/bridge/props.d.ts +56 -0
  25. package/dist/bridge/props.js +191 -0
  26. package/dist/bridge/wrappers.d.ts +24 -0
  27. package/dist/bridge/wrappers.js +276 -0
  28. package/dist/cli/format.d.ts +7 -0
  29. package/dist/cli/format.js +30 -0
  30. package/dist/cli.d.ts +2 -0
  31. package/dist/cli.js +492 -0
  32. package/dist/fonts/carry.d.ts +34 -0
  33. package/dist/fonts/carry.js +113 -0
  34. package/dist/fonts/fallback.d.ts +11 -0
  35. package/dist/fonts/fallback.js +21 -0
  36. package/dist/fonts/google.d.ts +65 -0
  37. package/dist/fonts/google.js +343 -0
  38. package/dist/fonts/index.d.ts +27 -0
  39. package/dist/fonts/index.js +48 -0
  40. package/dist/fonts/local.d.ts +46 -0
  41. package/dist/fonts/local.js +150 -0
  42. package/dist/fonts/sfnt.d.ts +19 -0
  43. package/dist/fonts/sfnt.js +174 -0
  44. package/dist/fonts/shim.d.ts +14 -0
  45. package/dist/fonts/shim.js +96 -0
  46. package/dist/gate.d.ts +105 -0
  47. package/dist/gate.js +157 -0
  48. package/dist/index.d.ts +55 -0
  49. package/dist/index.js +74 -0
  50. package/dist/ir/annotate.d.ts +16 -0
  51. package/dist/ir/annotate.js +145 -0
  52. package/dist/ir/as-child.d.ts +18 -0
  53. package/dist/ir/as-child.js +239 -0
  54. package/dist/ir/compounds.d.ts +27 -0
  55. package/dist/ir/compounds.js +183 -0
  56. package/dist/ir/contexts.d.ts +26 -0
  57. package/dist/ir/contexts.js +185 -0
  58. package/dist/ir/dom.d.ts +11 -0
  59. package/dist/ir/dom.js +60 -0
  60. package/dist/ir/effect-returns.d.ts +10 -0
  61. package/dist/ir/effect-returns.js +25 -0
  62. package/dist/ir/extract-ui-types.d.ts +33 -0
  63. package/dist/ir/extract-ui-types.js +224 -0
  64. package/dist/ir/extract-ui.d.ts +34 -0
  65. package/dist/ir/extract-ui.js +567 -0
  66. package/dist/ir/falsy.d.ts +13 -0
  67. package/dist/ir/falsy.js +66 -0
  68. package/dist/ir/forward-refs.d.ts +11 -0
  69. package/dist/ir/forward-refs.js +155 -0
  70. package/dist/ir/fragment-source.d.ts +4 -0
  71. package/dist/ir/fragment-source.js +13 -0
  72. package/dist/ir/fragments.d.ts +32 -0
  73. package/dist/ir/fragments.js +192 -0
  74. package/dist/ir/helper-snippets.d.ts +30 -0
  75. package/dist/ir/helper-snippets.js +550 -0
  76. package/dist/ir/latest-refs.d.ts +11 -0
  77. package/dist/ir/latest-refs.js +187 -0
  78. package/dist/ir/live-args.d.ts +26 -0
  79. package/dist/ir/live-args.js +335 -0
  80. package/dist/ir/lower.d.ts +83 -0
  81. package/dist/ir/lower.js +6016 -0
  82. package/dist/ir/markup-values.d.ts +16 -0
  83. package/dist/ir/markup-values.js +188 -0
  84. package/dist/ir/model.d.ts +605 -0
  85. package/dist/ir/model.js +1 -0
  86. package/dist/ir/oracle.d.ts +91 -0
  87. package/dist/ir/oracle.js +610 -0
  88. package/dist/ir/radix.d.ts +122 -0
  89. package/dist/ir/radix.js +344 -0
  90. package/dist/ir/rename.d.ts +15 -0
  91. package/dist/ir/rename.js +151 -0
  92. package/dist/ir/render-props.d.ts +31 -0
  93. package/dist/ir/render-props.js +67 -0
  94. package/dist/ir/rewrite.d.ts +44 -0
  95. package/dist/ir/rewrite.js +381 -0
  96. package/dist/ir/running-index.d.ts +11 -0
  97. package/dist/ir/running-index.js +217 -0
  98. package/dist/ir/snapshots.d.ts +12 -0
  99. package/dist/ir/snapshots.js +140 -0
  100. package/dist/ir/style.d.ts +19 -0
  101. package/dist/ir/style.js +76 -0
  102. package/dist/ir/types.d.ts +42 -0
  103. package/dist/ir/types.js +271 -0
  104. package/dist/ir/walk.d.ts +11 -0
  105. package/dist/ir/walk.js +18 -0
  106. package/dist/mcp/server.d.ts +81 -0
  107. package/dist/mcp/server.js +518 -0
  108. package/dist/pipeline.d.ts +26 -0
  109. package/dist/pipeline.js +750 -0
  110. package/dist/registry/add.d.ts +91 -0
  111. package/dist/registry/add.js +273 -0
  112. package/dist/registry/fetch.d.ts +40 -0
  113. package/dist/registry/fetch.js +186 -0
  114. package/dist/registry/ip.d.ts +18 -0
  115. package/dist/registry/ip.js +153 -0
  116. package/dist/registry/item.d.ts +39 -0
  117. package/dist/registry/item.js +131 -0
  118. package/dist/registry/load.d.ts +35 -0
  119. package/dist/registry/load.js +106 -0
  120. package/dist/registry/paths.d.ts +8 -0
  121. package/dist/registry/paths.js +43 -0
  122. package/dist/registry/publish.d.ts +119 -0
  123. package/dist/registry/publish.js +439 -0
  124. package/dist/targets/angular/bank/bank.d.ts +39 -0
  125. package/dist/targets/angular/bank/bank.js +61 -0
  126. package/dist/targets/angular/bank/helpers.d.ts +64 -0
  127. package/dist/targets/angular/bank/helpers.js +246 -0
  128. package/dist/targets/angular/bank/kept.d.ts +98 -0
  129. package/dist/targets/angular/bank/kept.js +791 -0
  130. package/dist/targets/angular/bank/plan-helpers.d.ts +17 -0
  131. package/dist/targets/angular/bank/plan-helpers.js +286 -0
  132. package/dist/targets/angular/bank/plan.d.ts +22 -0
  133. package/dist/targets/angular/bank/plan.js +152 -0
  134. package/dist/targets/angular/bank/receivers.d.ts +66 -0
  135. package/dist/targets/angular/bank/receivers.js +293 -0
  136. package/dist/targets/angular/bank/runtime.d.ts +14 -0
  137. package/dist/targets/angular/bank/runtime.js +152 -0
  138. package/dist/targets/angular/controlled.d.ts +7 -0
  139. package/dist/targets/angular/controlled.js +37 -0
  140. package/dist/targets/angular/dynamic-tags.d.ts +34 -0
  141. package/dist/targets/angular/dynamic-tags.js +192 -0
  142. package/dist/targets/angular/emit.d.ts +41 -0
  143. package/dist/targets/angular/emit.js +5970 -0
  144. package/dist/targets/angular/exports.d.ts +48 -0
  145. package/dist/targets/angular/exports.js +243 -0
  146. package/dist/targets/angular/helpers.d.ts +15 -0
  147. package/dist/targets/angular/helpers.js +33 -0
  148. package/dist/targets/angular/host-boundary.d.ts +5 -0
  149. package/dist/targets/angular/host-boundary.js +166 -0
  150. package/dist/targets/angular/host-form.d.ts +150 -0
  151. package/dist/targets/angular/host-form.js +727 -0
  152. package/dist/targets/angular/markup-values.d.ts +58 -0
  153. package/dist/targets/angular/markup-values.js +661 -0
  154. package/dist/targets/angular/motion-directive.d.ts +12 -0
  155. package/dist/targets/angular/motion-directive.js +257 -0
  156. package/dist/targets/angular/motion-hooks.d.ts +73 -0
  157. package/dist/targets/angular/motion-hooks.js +293 -0
  158. package/dist/targets/angular/motion-layout.d.ts +14 -0
  159. package/dist/targets/angular/motion-layout.js +74 -0
  160. package/dist/targets/angular/motion-templates.d.ts +10 -0
  161. package/dist/targets/angular/motion-templates.js +65 -0
  162. package/dist/targets/angular/motion.d.ts +57 -0
  163. package/dist/targets/angular/motion.js +202 -0
  164. package/dist/targets/angular/narrowing.d.ts +24 -0
  165. package/dist/targets/angular/narrowing.js +205 -0
  166. package/dist/targets/angular/ngc.d.ts +23 -0
  167. package/dist/targets/angular/ngc.js +134 -0
  168. package/dist/targets/angular/passed-handle.d.ts +39 -0
  169. package/dist/targets/angular/passed-handle.js +154 -0
  170. package/dist/targets/angular/projected.d.ts +9 -0
  171. package/dist/targets/angular/projected.js +63 -0
  172. package/dist/targets/angular/radix/cores/alert-dialog.d.ts +13 -0
  173. package/dist/targets/angular/radix/cores/alert-dialog.js +388 -0
  174. package/dist/targets/angular/radix/cores/index.d.ts +17 -0
  175. package/dist/targets/angular/radix/cores/index.js +50 -0
  176. package/dist/targets/angular/radix/cores/slider.d.ts +8 -0
  177. package/dist/targets/angular/radix/cores/slider.js +202 -0
  178. package/dist/targets/angular/radix/index.d.ts +21 -0
  179. package/dist/targets/angular/radix/index.js +35 -0
  180. package/dist/targets/angular/radix/packages.d.ts +3 -0
  181. package/dist/targets/angular/radix/packages.js +558 -0
  182. package/dist/targets/angular/radix/part.d.ts +236 -0
  183. package/dist/targets/angular/radix/part.js +71 -0
  184. package/dist/targets/angular/radix/prepare.d.ts +66 -0
  185. package/dist/targets/angular/radix/prepare.js +548 -0
  186. package/dist/targets/angular/radix/template.d.ts +43 -0
  187. package/dist/targets/angular/radix/template.js +172 -0
  188. package/dist/targets/angular/refs.d.ts +68 -0
  189. package/dist/targets/angular/refs.js +443 -0
  190. package/dist/targets/angular/slots.d.ts +22 -0
  191. package/dist/targets/angular/slots.js +60 -0
  192. package/dist/targets/angular/source-types.d.ts +10 -0
  193. package/dist/targets/angular/source-types.js +45 -0
  194. package/dist/targets/angular/spread-forward.d.ts +24 -0
  195. package/dist/targets/angular/spread-forward.js +72 -0
  196. package/dist/targets/angular/spread.d.ts +32 -0
  197. package/dist/targets/angular/spread.js +182 -0
  198. package/dist/targets/angular/svg-hosts.d.ts +25 -0
  199. package/dist/targets/angular/svg-hosts.js +107 -0
  200. package/dist/targets/angular/template-expr.d.ts +36 -0
  201. package/dist/targets/angular/template-expr.js +287 -0
  202. package/dist/targets/angular/types.d.ts +9 -0
  203. package/dist/targets/angular/types.js +63 -0
  204. package/dist/targets/angular/walk.d.ts +11 -0
  205. package/dist/targets/angular/walk.js +26 -0
  206. package/dist/targets/react-native/emit.d.ts +14 -0
  207. package/dist/targets/react-native/emit.js +585 -0
  208. package/dist/targets/react-native/fidelity.d.ts +5 -0
  209. package/dist/targets/react-native/fidelity.js +43 -0
  210. package/dist/targets/react-native/motion.d.ts +10 -0
  211. package/dist/targets/react-native/motion.js +290 -0
  212. package/dist/targets/react-native/skia.d.ts +30 -0
  213. package/dist/targets/react-native/skia.js +358 -0
  214. package/dist/targets/shared/context.d.ts +47 -0
  215. package/dist/targets/shared/context.js +195 -0
  216. package/dist/targets/shared/foreign.d.ts +10 -0
  217. package/dist/targets/shared/foreign.js +72 -0
  218. package/dist/targets/shared/fragments.d.ts +21 -0
  219. package/dist/targets/shared/fragments.js +309 -0
  220. package/dist/targets/shared/handles.d.ts +65 -0
  221. package/dist/targets/shared/handles.js +299 -0
  222. package/dist/targets/shared/inline.d.ts +53 -0
  223. package/dist/targets/shared/inline.js +524 -0
  224. package/dist/targets/shared/layout.d.ts +70 -0
  225. package/dist/targets/shared/layout.js +224 -0
  226. package/dist/targets/shared/markup.d.ts +26 -0
  227. package/dist/targets/shared/markup.js +65 -0
  228. package/dist/targets/shared/module.d.ts +84 -0
  229. package/dist/targets/shared/module.js +468 -0
  230. package/dist/targets/shared/motion-hooks.d.ts +37 -0
  231. package/dist/targets/shared/motion-hooks.js +87 -0
  232. package/dist/targets/shared/motion-layout.d.ts +70 -0
  233. package/dist/targets/shared/motion-layout.js +392 -0
  234. package/dist/targets/shared/portal.d.ts +10 -0
  235. package/dist/targets/shared/portal.js +23 -0
  236. package/dist/targets/shared/prop-writes.d.ts +11 -0
  237. package/dist/targets/shared/prop-writes.js +32 -0
  238. package/dist/targets/shared/prune.d.ts +54 -0
  239. package/dist/targets/shared/prune.js +405 -0
  240. package/dist/targets/shared/react-libs.d.ts +25 -0
  241. package/dist/targets/shared/react-libs.js +142 -0
  242. package/dist/targets/shared/react-types.d.ts +16 -0
  243. package/dist/targets/shared/react-types.js +374 -0
  244. package/dist/targets/shared/react-values.d.ts +20 -0
  245. package/dist/targets/shared/react-values.js +145 -0
  246. package/dist/targets/shared/ref-callback.d.ts +16 -0
  247. package/dist/targets/shared/ref-callback.js +114 -0
  248. package/dist/targets/shared/script.d.ts +65 -0
  249. package/dist/targets/shared/script.js +406 -0
  250. package/dist/targets/shared/unused.d.ts +12 -0
  251. package/dist/targets/shared/unused.js +146 -0
  252. package/dist/targets/svelte/dom-spread.d.ts +27 -0
  253. package/dist/targets/svelte/dom-spread.js +146 -0
  254. package/dist/targets/svelte/emit.d.ts +15 -0
  255. package/dist/targets/svelte/emit.js +3784 -0
  256. package/dist/targets/svelte/handle-branches.d.ts +22 -0
  257. package/dist/targets/svelte/handle-branches.js +146 -0
  258. package/dist/targets/svelte/html-keys.d.ts +9 -0
  259. package/dist/targets/svelte/html-keys.js +40 -0
  260. package/dist/targets/svelte/markup-data/data.d.ts +51 -0
  261. package/dist/targets/svelte/markup-data/data.js +305 -0
  262. package/dist/targets/svelte/markup-data/helper.d.ts +12 -0
  263. package/dist/targets/svelte/markup-data/helper.js +81 -0
  264. package/dist/targets/svelte/markup-data/module-data.d.ts +21 -0
  265. package/dist/targets/svelte/markup-data/module-data.js +473 -0
  266. package/dist/targets/svelte/markup-data/sites.d.ts +52 -0
  267. package/dist/targets/svelte/markup-data/sites.js +303 -0
  268. package/dist/targets/svelte/motion-layout.d.ts +13 -0
  269. package/dist/targets/svelte/motion-layout.js +70 -0
  270. package/dist/targets/svelte/motion-table.d.ts +14 -0
  271. package/dist/targets/svelte/motion-table.js +308 -0
  272. package/dist/targets/svelte/motion.d.ts +46 -0
  273. package/dist/targets/svelte/motion.js +405 -0
  274. package/dist/targets/svelte/presence.d.ts +71 -0
  275. package/dist/targets/svelte/presence.js +318 -0
  276. package/dist/targets/svelte/radix/accordion.d.ts +9 -0
  277. package/dist/targets/svelte/radix/accordion.js +24 -0
  278. package/dist/targets/svelte/radix/aspect-ratio.d.ts +6 -0
  279. package/dist/targets/svelte/radix/aspect-ratio.js +8 -0
  280. package/dist/targets/svelte/radix/avatar.d.ts +6 -0
  281. package/dist/targets/svelte/radix/avatar.js +10 -0
  282. package/dist/targets/svelte/radix/checkbox.d.ts +10 -0
  283. package/dist/targets/svelte/radix/checkbox.js +24 -0
  284. package/dist/targets/svelte/radix/collapsible.d.ts +7 -0
  285. package/dist/targets/svelte/radix/collapsible.js +16 -0
  286. package/dist/targets/svelte/radix/context-menu.d.ts +8 -0
  287. package/dist/targets/svelte/radix/context-menu.js +49 -0
  288. package/dist/targets/svelte/radix/cores/alert-dialog.d.ts +17 -0
  289. package/dist/targets/svelte/radix/cores/alert-dialog.js +449 -0
  290. package/dist/targets/svelte/radix/cores/collapsible.d.ts +12 -0
  291. package/dist/targets/svelte/radix/cores/collapsible.js +214 -0
  292. package/dist/targets/svelte/radix/cores/core.d.ts +32 -0
  293. package/dist/targets/svelte/radix/cores/core.js +80 -0
  294. package/dist/targets/svelte/radix/cores/direction.d.ts +10 -0
  295. package/dist/targets/svelte/radix/cores/direction.js +64 -0
  296. package/dist/targets/svelte/radix/cores/index.d.ts +19 -0
  297. package/dist/targets/svelte/radix/cores/index.js +85 -0
  298. package/dist/targets/svelte/radix/cores/modal-layer.d.ts +11 -0
  299. package/dist/targets/svelte/radix/cores/modal-layer.js +244 -0
  300. package/dist/targets/svelte/radix/cores/presence.d.ts +12 -0
  301. package/dist/targets/svelte/radix/cores/presence.js +129 -0
  302. package/dist/targets/svelte/radix/cores/slider-logic.d.ts +10 -0
  303. package/dist/targets/svelte/radix/cores/slider-logic.js +287 -0
  304. package/dist/targets/svelte/radix/cores/slider.d.ts +13 -0
  305. package/dist/targets/svelte/radix/cores/slider.js +267 -0
  306. package/dist/targets/svelte/radix/dialog.d.ts +8 -0
  307. package/dist/targets/svelte/radix/dialog.js +20 -0
  308. package/dist/targets/svelte/radix/dropdown-menu.d.ts +9 -0
  309. package/dist/targets/svelte/radix/dropdown-menu.js +38 -0
  310. package/dist/targets/svelte/radix/emit.d.ts +12 -0
  311. package/dist/targets/svelte/radix/emit.js +1339 -0
  312. package/dist/targets/svelte/radix/hover-card.d.ts +7 -0
  313. package/dist/targets/svelte/radix/hover-card.js +22 -0
  314. package/dist/targets/svelte/radix/index.d.ts +12 -0
  315. package/dist/targets/svelte/radix/index.js +28 -0
  316. package/dist/targets/svelte/radix/label.d.ts +3 -0
  317. package/dist/targets/svelte/radix/label.js +5 -0
  318. package/dist/targets/svelte/radix/menubar.d.ts +7 -0
  319. package/dist/targets/svelte/radix/menubar.js +34 -0
  320. package/dist/targets/svelte/radix/navigation-menu.d.ts +8 -0
  321. package/dist/targets/svelte/radix/navigation-menu.js +25 -0
  322. package/dist/targets/svelte/radix/packages.d.ts +34 -0
  323. package/dist/targets/svelte/radix/packages.js +100 -0
  324. package/dist/targets/svelte/radix/part.d.ts +161 -0
  325. package/dist/targets/svelte/radix/part.js +85 -0
  326. package/dist/targets/svelte/radix/popover.d.ts +7 -0
  327. package/dist/targets/svelte/radix/popover.js +15 -0
  328. package/dist/targets/svelte/radix/progress.d.ts +11 -0
  329. package/dist/targets/svelte/radix/progress.js +27 -0
  330. package/dist/targets/svelte/radix/radio-group.d.ts +9 -0
  331. package/dist/targets/svelte/radix/radio-group.js +26 -0
  332. package/dist/targets/svelte/radix/scroll-area.d.ts +7 -0
  333. package/dist/targets/svelte/radix/scroll-area.js +19 -0
  334. package/dist/targets/svelte/radix/select.d.ts +13 -0
  335. package/dist/targets/svelte/radix/select.js +81 -0
  336. package/dist/targets/svelte/radix/separator.d.ts +3 -0
  337. package/dist/targets/svelte/radix/separator.js +5 -0
  338. package/dist/targets/svelte/radix/slider.d.ts +6 -0
  339. package/dist/targets/svelte/radix/slider.js +8 -0
  340. package/dist/targets/svelte/radix/switch.d.ts +6 -0
  341. package/dist/targets/svelte/radix/switch.js +10 -0
  342. package/dist/targets/svelte/radix/tabs.d.ts +8 -0
  343. package/dist/targets/svelte/radix/tabs.js +15 -0
  344. package/dist/targets/svelte/radix/toggle-group.d.ts +9 -0
  345. package/dist/targets/svelte/radix/toggle-group.js +17 -0
  346. package/dist/targets/svelte/radix/toggle.d.ts +6 -0
  347. package/dist/targets/svelte/radix/toggle.js +9 -0
  348. package/dist/targets/svelte/radix/tooltip.d.ts +6 -0
  349. package/dist/targets/svelte/radix/tooltip.js +24 -0
  350. package/dist/targets/svelte/strip.d.ts +2 -0
  351. package/dist/targets/svelte/strip.js +5 -0
  352. package/dist/targets/vue/emit.d.ts +15 -0
  353. package/dist/targets/vue/emit.js +4092 -0
  354. package/dist/targets/vue/events.d.ts +11 -0
  355. package/dist/targets/vue/events.js +13 -0
  356. package/dist/targets/vue/module-builders.d.ts +28 -0
  357. package/dist/targets/vue/module-builders.js +258 -0
  358. package/dist/targets/vue/motion-layout.d.ts +19 -0
  359. package/dist/targets/vue/motion-layout.js +79 -0
  360. package/dist/targets/vue/motion.d.ts +12 -0
  361. package/dist/targets/vue/motion.js +46 -0
  362. package/dist/targets/vue/radix/accordion.d.ts +3 -0
  363. package/dist/targets/vue/radix/accordion.js +12 -0
  364. package/dist/targets/vue/radix/alert-dialog.d.ts +6 -0
  365. package/dist/targets/vue/radix/alert-dialog.js +18 -0
  366. package/dist/targets/vue/radix/aspect-ratio.d.ts +6 -0
  367. package/dist/targets/vue/radix/aspect-ratio.js +8 -0
  368. package/dist/targets/vue/radix/avatar.d.ts +3 -0
  369. package/dist/targets/vue/radix/avatar.js +7 -0
  370. package/dist/targets/vue/radix/checkbox.d.ts +3 -0
  371. package/dist/targets/vue/radix/checkbox.js +9 -0
  372. package/dist/targets/vue/radix/collapsible.d.ts +7 -0
  373. package/dist/targets/vue/radix/collapsible.js +11 -0
  374. package/dist/targets/vue/radix/context-menu.d.ts +3 -0
  375. package/dist/targets/vue/radix/context-menu.js +30 -0
  376. package/dist/targets/vue/radix/dialog.d.ts +3 -0
  377. package/dist/targets/vue/radix/dialog.js +12 -0
  378. package/dist/targets/vue/radix/direction.d.ts +7 -0
  379. package/dist/targets/vue/radix/direction.js +9 -0
  380. package/dist/targets/vue/radix/dropdown-menu.d.ts +3 -0
  381. package/dist/targets/vue/radix/dropdown-menu.js +29 -0
  382. package/dist/targets/vue/radix/hover-card.d.ts +3 -0
  383. package/dist/targets/vue/radix/hover-card.js +11 -0
  384. package/dist/targets/vue/radix/index.d.ts +65 -0
  385. package/dist/targets/vue/radix/index.js +225 -0
  386. package/dist/targets/vue/radix/label.d.ts +3 -0
  387. package/dist/targets/vue/radix/label.js +5 -0
  388. package/dist/targets/vue/radix/menubar.d.ts +6 -0
  389. package/dist/targets/vue/radix/menubar.js +29 -0
  390. package/dist/targets/vue/radix/navigation-menu.d.ts +6 -0
  391. package/dist/targets/vue/radix/navigation-menu.js +21 -0
  392. package/dist/targets/vue/radix/part.d.ts +41 -0
  393. package/dist/targets/vue/radix/part.js +46 -0
  394. package/dist/targets/vue/radix/popover.d.ts +3 -0
  395. package/dist/targets/vue/radix/popover.js +11 -0
  396. package/dist/targets/vue/radix/progress.d.ts +3 -0
  397. package/dist/targets/vue/radix/progress.js +6 -0
  398. package/dist/targets/vue/radix/radio-group.d.ts +3 -0
  399. package/dist/targets/vue/radix/radio-group.js +10 -0
  400. package/dist/targets/vue/radix/scroll-area.d.ts +3 -0
  401. package/dist/targets/vue/radix/scroll-area.js +11 -0
  402. package/dist/targets/vue/radix/select.d.ts +3 -0
  403. package/dist/targets/vue/radix/select.js +29 -0
  404. package/dist/targets/vue/radix/separator.d.ts +3 -0
  405. package/dist/targets/vue/radix/separator.js +5 -0
  406. package/dist/targets/vue/radix/slider.d.ts +3 -0
  407. package/dist/targets/vue/radix/slider.js +13 -0
  408. package/dist/targets/vue/radix/switch.d.ts +3 -0
  409. package/dist/targets/vue/radix/switch.js +9 -0
  410. package/dist/targets/vue/radix/tabs.d.ts +3 -0
  411. package/dist/targets/vue/radix/tabs.js +12 -0
  412. package/dist/targets/vue/radix/toggle-group.d.ts +3 -0
  413. package/dist/targets/vue/radix/toggle-group.js +10 -0
  414. package/dist/targets/vue/radix/toggle.d.ts +3 -0
  415. package/dist/targets/vue/radix/toggle.js +8 -0
  416. package/dist/targets/vue/radix/tooltip.d.ts +3 -0
  417. package/dist/targets/vue/radix/tooltip.js +14 -0
  418. package/dist/targets/vue/render-fn/h.d.ts +52 -0
  419. package/dist/targets/vue/render-fn/h.js +442 -0
  420. package/dist/targets/vue/render-fn.d.ts +21 -0
  421. package/dist/targets/vue/render-fn.js +357 -0
  422. package/dist/targets/vue/slot.d.ts +9 -0
  423. package/dist/targets/vue/slot.js +57 -0
  424. package/dist/typecheck/host.d.ts +45 -0
  425. package/dist/typecheck/host.js +309 -0
  426. package/dist/typecheck/index.d.ts +16 -0
  427. package/dist/typecheck/index.js +17 -0
  428. package/dist/typecheck/lucide.d.ts +8 -0
  429. package/dist/typecheck/lucide.js +45 -0
  430. package/dist/typecheck/sourcemap.d.ts +9 -0
  431. package/dist/typecheck/sourcemap.js +54 -0
  432. package/dist/typecheck/svelte.d.ts +9 -0
  433. package/dist/typecheck/svelte.js +116 -0
  434. package/dist/typecheck/vue.d.ts +8 -0
  435. package/dist/typecheck/vue.js +78 -0
  436. package/dist/types.d.ts +446 -0
  437. package/dist/types.js +11 -0
  438. package/dist/utils/cleanup.d.ts +32 -0
  439. package/dist/utils/cleanup.js +119 -0
  440. package/dist/utils/errors.d.ts +7 -0
  441. package/dist/utils/errors.js +15 -0
  442. package/dist/utils/fs-safe.d.ts +14 -0
  443. package/dist/utils/fs-safe.js +64 -0
  444. package/dist/validate.d.ts +16 -0
  445. package/dist/validate.js +204 -0
  446. package/dist/verify/auto-steps.d.ts +107 -0
  447. package/dist/verify/auto-steps.js +471 -0
  448. package/dist/verify/bundle.d.ts +68 -0
  449. package/dist/verify/bundle.js +548 -0
  450. package/dist/verify/diff.d.ts +31 -0
  451. package/dist/verify/diff.js +133 -0
  452. package/dist/verify/leaks.d.ts +25 -0
  453. package/dist/verify/leaks.js +261 -0
  454. package/dist/verify/link-worker.d.ts +1 -0
  455. package/dist/verify/link-worker.js +27 -0
  456. package/dist/verify/runner.d.ts +57 -0
  457. package/dist/verify/runner.js +867 -0
  458. package/dist/verify/sandbox.d.ts +40 -0
  459. package/dist/verify/sandbox.js +496 -0
  460. package/dist/verify/steps.d.ts +42 -0
  461. package/dist/verify/steps.js +475 -0
  462. package/dist/verify/verdict.d.ts +15 -0
  463. package/dist/verify/verdict.js +19 -0
  464. package/package.json +118 -4
@@ -0,0 +1,40 @@
1
+ import type { Browser, BrowserContext, Page } from 'playwright-core';
2
+ export interface SandboxServer {
3
+ origin: string;
4
+ close: () => Promise<void>;
5
+ }
6
+ /** Serves one folder on 127.0.0.1 at an ephemeral port, refusing anything outside it; registered for cleanup. */
7
+ /**
8
+ * Serves the page files from `root`; with `assets`, a path not found there is looked up in that folder too (a site's
9
+ * public files, so `/photos/1.jpg` loads as it does on the site). Both stay on the sandbox's own origin and are checked
10
+ * with the same path rules.
11
+ */
12
+ export declare function startServer(root: string, assets?: string | null): Promise<SandboxServer>;
13
+ export interface SandboxBrowser {
14
+ browser: Browser;
15
+ /** the browser's OS process id, for leak checks */
16
+ pid: number | null;
17
+ close: () => Promise<void>;
18
+ }
19
+ /**
20
+ * X6 (determinism): with GPU rasterization, Chrome's raster of photos in 3D-transformed layers differed between runs of
21
+ * the same page with the same DOM and styles (measured on carousels/variants/turntable.tsx: React's own idle shot
22
+ * differed from run to run by 64,657 to 131,566 pixels, every card's transform string identical). Rasterizing on the CPU
23
+ * gave the same pixels in every run. One flag; nothing compared changes.
24
+ */
25
+ export declare const DETERMINISTIC_RASTER: string[];
26
+ /** Headless Chrome (the installed one unless a path is given), registered so it is killed however the run ends. */
27
+ export declare function launchBrowser(executablePath?: string): Promise<SandboxBrowser>;
28
+ export interface SandboxPage {
29
+ page: Page;
30
+ context: BrowserContext;
31
+ /** every request the sandbox refused */
32
+ blocked: string[];
33
+ errors: string[];
34
+ }
35
+ /**
36
+ * A page that can only talk to the sandbox origin: every other request (and every WebSocket) is aborted, service
37
+ * workers are blocked, and the virtual clock is installed before any page script runs. `probe`, when given, is
38
+ * installed right after the clock (so it sees the virtual timers), still before any page script.
39
+ */
40
+ export declare function newSandboxPage(browser: Browser, origin: string, width: number, height: number, timeoutMs: number, probe?: string): Promise<SandboxPage>;
@@ -0,0 +1,496 @@
1
+ import { createServer } from 'node:http';
2
+ import { existsSync, readFileSync, statSync } from 'node:fs';
3
+ import { extname } from 'node:path';
4
+ import { cleanup } from '../utils/cleanup.js';
5
+ import { isInside, resolveInside } from '../utils/fs-safe.js';
6
+ /** The CSP every sandbox page is served with: only its own origin, no network connections at all. */
7
+ const SANDBOX_CSP = "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data:; connect-src 'none'; frame-src 'none'; object-src 'none'; worker-src 'none'; base-uri 'none'; form-action 'none'";
8
+ const TYPES = {
9
+ '.html': 'text/html; charset=utf-8',
10
+ '.js': 'text/javascript; charset=utf-8',
11
+ '.css': 'text/css; charset=utf-8',
12
+ '.png': 'image/png',
13
+ '.svg': 'image/svg+xml',
14
+ '.json': 'application/json',
15
+ };
16
+ /** Serves one folder on 127.0.0.1 at an ephemeral port, refusing anything outside it; registered for cleanup. */
17
+ /**
18
+ * Serves the page files from `root`; with `assets`, a path not found there is looked up in that folder too (a site's
19
+ * public files, so `/photos/1.jpg` loads as it does on the site). Both stay on the sandbox's own origin and are checked
20
+ * with the same path rules.
21
+ */
22
+ export async function startServer(root, assets = null) {
23
+ const server = createServer((req, res) => {
24
+ const url = new URL(req.url ?? '/', 'http://127.0.0.1');
25
+ let pathname;
26
+ try {
27
+ pathname = decodeURIComponent(url.pathname);
28
+ }
29
+ catch {
30
+ // malformed percent-encoding (e.g. /%E0%A4%A): a bad request, not a crash
31
+ res.writeHead(400).end();
32
+ return;
33
+ }
34
+ const rel = pathname.replace(/^\/+/, '') || 'index.html';
35
+ if (!isInside(root, rel)) {
36
+ res.writeHead(403).end();
37
+ return;
38
+ }
39
+ let file = resolveInside(root, rel);
40
+ if ((!existsSync(file) || !statSync(file).isFile()) && assets && isInside(assets, rel))
41
+ file = resolveInside(assets, rel);
42
+ if (!existsSync(file) || !statSync(file).isFile()) {
43
+ res.writeHead(404).end();
44
+ return;
45
+ }
46
+ res.writeHead(200, {
47
+ 'Content-Type': TYPES[extname(file)] ?? 'application/octet-stream',
48
+ 'Content-Security-Policy': SANDBOX_CSP,
49
+ 'Cache-Control': 'no-store',
50
+ 'X-Content-Type-Options': 'nosniff',
51
+ });
52
+ res.end(readFileSync(file));
53
+ });
54
+ await new Promise((resolve, reject) => {
55
+ server.once('error', reject);
56
+ server.listen(0, '127.0.0.1', () => resolve());
57
+ });
58
+ const port = server.address().port;
59
+ const shut = () => new Promise((resolve) => {
60
+ server.closeAllConnections();
61
+ server.close(() => resolve());
62
+ });
63
+ const dispose = cleanup.add(`server :${port}`, shut, () => {
64
+ server.closeAllConnections();
65
+ server.close();
66
+ });
67
+ return { origin: `http://127.0.0.1:${port}`, close: dispose };
68
+ }
69
+ /**
70
+ * Playwright drives Chrome for `verify` only, so it is an optional dependency: converting never needs it, and a missing
71
+ * install says what to add.
72
+ */
73
+ async function loadChromium() {
74
+ try {
75
+ return (await import('playwright-core')).chromium;
76
+ }
77
+ catch {
78
+ throw new Error('verify needs the optional dependency playwright-core (npm install playwright-core) and an installed Chrome.');
79
+ }
80
+ }
81
+ /**
82
+ * X6 (determinism): with GPU rasterization, Chrome's raster of photos in 3D-transformed layers differed between runs of
83
+ * the same page with the same DOM and styles (measured on carousels/variants/turntable.tsx: React's own idle shot
84
+ * differed from run to run by 64,657 to 131,566 pixels, every card's transform string identical). Rasterizing on the CPU
85
+ * gave the same pixels in every run. One flag; nothing compared changes.
86
+ */
87
+ export const DETERMINISTIC_RASTER = ['--disable-gpu-rasterization'];
88
+ /** Headless Chrome (the installed one unless a path is given), registered so it is killed however the run ends. */
89
+ export async function launchBrowser(executablePath) {
90
+ const launchOptions = {
91
+ headless: true,
92
+ // the cleanup registry owns SIGINT/SIGTERM: Playwright's own handlers would exit before our cleanup finishes
93
+ handleSIGINT: false,
94
+ handleSIGTERM: false,
95
+ handleSIGHUP: false,
96
+ args: ['--disable-gpu-sandbox', '--no-first-run', '--no-default-browser-check', '--disable-extensions', '--disable-background-networking', '--disable-sync', '--force-device-scale-factor=1', '--hide-scrollbars', '--font-render-hinting=none', ...DETERMINISTIC_RASTER],
97
+ ...(executablePath ? { executablePath } : { channel: 'chrome' }),
98
+ };
99
+ const chromium = await loadChromium();
100
+ const server = await chromium.launchServer(launchOptions);
101
+ const proc = server.process();
102
+ const kill = () => {
103
+ try {
104
+ proc.kill('SIGKILL');
105
+ }
106
+ catch {
107
+ // already gone
108
+ return;
109
+ }
110
+ };
111
+ let browser;
112
+ try {
113
+ browser = await chromium.connect(server.wsEndpoint());
114
+ }
115
+ catch (error) {
116
+ await server.close().catch(kill);
117
+ throw error;
118
+ }
119
+ const dispose = cleanup.add(`browser ${proc.pid ?? '?'}`, async () => {
120
+ await browser.close().catch(() => undefined);
121
+ // close normally; if that hangs (a renderer stuck in a loop), kill the process
122
+ await Promise.race([server.close(), new Promise((resolve) => setTimeout(resolve, 3000))]);
123
+ if (proc.exitCode === null && proc.signalCode === null)
124
+ kill();
125
+ }, kill);
126
+ return { browser, pid: proc.pid ?? null, close: dispose };
127
+ }
128
+ /**
129
+ * A page that can only talk to the sandbox origin: every other request (and every WebSocket) is aborted, service
130
+ * workers are blocked, and the virtual clock is installed before any page script runs. `probe`, when given, is
131
+ * installed right after the clock (so it sees the virtual timers), still before any page script.
132
+ */
133
+ export async function newSandboxPage(browser, origin, width, height, timeoutMs, probe) {
134
+ const context = await browser.newContext({ viewport: { width, height }, deviceScaleFactor: 1, serviceWorkers: 'block', reducedMotion: 'no-preference', colorScheme: 'light', locale: 'en-US', timezoneId: 'UTC' });
135
+ const blocked = [];
136
+ const errors = [];
137
+ await context.route('**/*', async (route) => {
138
+ const url = route.request().url();
139
+ if (url === origin || url.startsWith(`${origin}/`))
140
+ await route.continue();
141
+ else {
142
+ blocked.push(url);
143
+ await route.abort('blockedbyclient');
144
+ }
145
+ });
146
+ await context.routeWebSocket(/.*/, (ws) => {
147
+ blocked.push(ws.url());
148
+ void ws.close();
149
+ });
150
+ await context.addInitScript({ content: CLOCK_SCRIPT });
151
+ await context.addInitScript({ content: NAVIGATION_GUARD });
152
+ if (probe)
153
+ await context.addInitScript({ content: probe });
154
+ const page = await context.newPage();
155
+ page.setDefaultTimeout(timeoutMs);
156
+ page.setDefaultNavigationTimeout(timeoutMs);
157
+ page.on('pageerror', (e) => errors.push(e.message));
158
+ page.on('console', (m) => {
159
+ if (m.type() === 'error')
160
+ errors.push(m.text());
161
+ });
162
+ return { page, context, blocked, errors };
163
+ }
164
+ /**
165
+ * The page never leaves itself: a link, a form, `location.href = …` or a reload that would load another document is
166
+ * cancelled through the Navigation API's `navigate` event, which fires after the click (or the code) that started it
167
+ * has run in full, so every handler still runs and nothing is prevented on the event itself. Same-document navigations
168
+ * (a hash change, `history.pushState`) pass. Navigations Playwright starts itself (`page.goto`) are not page-initiated,
169
+ * fire no cancelable event, and still meet the route guard.
170
+ */
171
+ const NAVIGATION_GUARD = `(() => {
172
+ const nav = window.navigation;
173
+ if (!nav || typeof nav.addEventListener !== 'function') return;
174
+ nav.addEventListener('navigate', (event) => {
175
+ if (event.destination && event.destination.sameDocument) return;
176
+ if (event.cancelable) event.preventDefault();
177
+ });
178
+ })();`;
179
+ /**
180
+ * A steppable virtual clock, installed before page scripts: performance.now, Date, timers and requestAnimationFrame
181
+ * follow `window.__morphClock.advance(ms)` in 16 ms frames, and every CSS transition, CSS animation and Web Animation
182
+ * is paused and seeked to the same virtual time. React, Vue and Svelte renders therefore land on the same frame, while
183
+ * hovers and presses still animate when time is stepped.
184
+ */
185
+ const CLOCK_SCRIPT = `(() => {
186
+ const realTimeout = window.setTimeout.bind(window);
187
+ const realRaf = window.requestAnimationFrame.bind(window);
188
+ const BASE = 1700000000000;
189
+ let now = 0;
190
+ let nextId = 1;
191
+ const timers = new Map();
192
+ const frames = new Map();
193
+ const started = new WeakMap();
194
+ const RealDate = Date;
195
+ performance.now = () => now;
196
+ class VirtualDate extends RealDate {
197
+ constructor(...args) { if (args.length === 0) super(BASE + now); else super(...args); }
198
+ static now() { return BASE + now; }
199
+ }
200
+ window.Date = VirtualDate;
201
+ window.setTimeout = (fn, ms = 0, ...args) => { const id = nextId++; timers.set(id, { at: now + Math.max(0, Number(ms) || 0), fn, args, every: null }); return id; };
202
+ window.setInterval = (fn, ms = 0, ...args) => { const id = nextId++; const every = Math.max(1, Number(ms) || 0); timers.set(id, { at: now + every, fn, args, every }); return id; };
203
+ window.clearTimeout = (id) => { timers.delete(id); };
204
+ window.clearInterval = (id) => { timers.delete(id); };
205
+ window.requestAnimationFrame = (cb) => { const id = nextId++; frames.set(id, cb); return id; };
206
+ window.cancelAnimationFrame = (id) => { frames.delete(id); };
207
+ // X6 (determinism): the other clocks a page can read are put on the virtual one too.
208
+ // An event's timeStamp is on performance.now's scale: it reads the virtual time when it is first read (input that
209
+ // arrives between two steps is at the time of the step before it), the same value every later read.
210
+ const stamps = new WeakMap();
211
+ Object.defineProperty(Event.prototype, 'timeStamp', { configurable: true, get() { if (!stamps.has(this)) stamps.set(this, now); return stamps.get(this); } });
212
+ // document.timeline is the clock Web Animations run on (sync below seeks each one); code that reads it reads virtual time
213
+ if (window.AnimationTimeline) Object.defineProperty(AnimationTimeline.prototype, 'currentTime', { configurable: true, get() { return now; } });
214
+ // the page's time origin is the virtual epoch Date counts from, not the real moment the page loaded
215
+ Object.defineProperty(performance, 'timeOrigin', { configurable: true, get() { return BASE; } });
216
+ // idle callbacks run on the virtual clock (a real idle period comes when the machine allows, not at a set frame)
217
+ window.requestIdleCallback = (cb, opts) => window.setTimeout(() => cb({ didTimeout: false, timeRemaining: () => 50 }), 1);
218
+ window.cancelIdleCallback = (id) => window.clearTimeout(id);
219
+ // X6: random numbers are seeded, the same seed on every page (mulberry32 from RANDOM_SEED): Math.random,
220
+ // crypto.getRandomValues and crypto.randomUUID. This makes each page's own sequence repeatable from run to run, and
221
+ // makes two pages draw the same values only when they ask for random numbers in the same order, which a faithful
222
+ // conversion does; one that asks in another order still draws other values, and verify shows it.
223
+ const RANDOM_SEED = 0x9e3779b9;
224
+ let seed = RANDOM_SEED >>> 0;
225
+ const nextRandom = () => {
226
+ seed = (seed + 0x6d2b79f5) >>> 0;
227
+ let t = seed;
228
+ t = Math.imul(t ^ (t >>> 15), t | 1);
229
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
230
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
231
+ };
232
+ Math.random = nextRandom;
233
+ // X6: the entry calls this right before it mounts the component (verify/bundle.ts), after the page's imports ran: a
234
+ // framework that draws random numbers when it loads (react-dom draws its internal keys) would otherwise have shifted
235
+ // the sequence, so each framework's component code would start from a different value. Not covered: a framework that
236
+ // draws during mount or render still shifts its page (measured: see tests/visual/sandbox-clock.test.ts and the report).
237
+ window.__morphReseed = () => { seed = RANDOM_SEED >>> 0; };
238
+ if (window.crypto) {
239
+ const fill = function (array) {
240
+ const bytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
241
+ for (let i = 0; i < bytes.length; i++) bytes[i] = Math.floor(nextRandom() * 256);
242
+ return array;
243
+ };
244
+ Object.defineProperty(Crypto.prototype, 'getRandomValues', { configurable: true, writable: true, value: fill });
245
+ Object.defineProperty(Crypto.prototype, 'randomUUID', {
246
+ configurable: true,
247
+ writable: true,
248
+ value: function () {
249
+ const b = fill(new Uint8Array(16));
250
+ b[6] = (b[6] & 0x0f) | 0x40;
251
+ b[8] = (b[8] & 0x3f) | 0x80;
252
+ const h = [...b].map((x) => x.toString(16).padStart(2, '0')).join('');
253
+ return h.slice(0, 8) + '-' + h.slice(8, 12) + '-' + h.slice(12, 16) + '-' + h.slice(16, 20) + '-' + h.slice(20);
254
+ },
255
+ });
256
+ }
257
+ // An image arrives when the network and decoder are done, in real time: its load or error event would reach the page
258
+ // at whatever virtual frame is current then. Each image's events are held and handed over at the next step, after
259
+ // the step has waited (real time, at most IMAGE_WAIT ms) for every image still loading, so the page meets its images at
260
+ // the same virtual frame every run.
261
+ const IMAGE_WAIT = 3000;
262
+ const pendingImages = new Map();
263
+ const heldImages = [];
264
+ const watched = new WeakSet();
265
+ const watchImage = (img) => {
266
+ pendingImages.set(img, Date.prototype.getTime.call(new RealDate()));
267
+ if (watched.has(img)) return;
268
+ watched.add(img);
269
+ const hold = (e) => {
270
+ if (!e.isTrusted) return;
271
+ e.stopImmediatePropagation();
272
+ pendingImages.delete(img);
273
+ heldImages.push([img, e.type]);
274
+ };
275
+ img.addEventListener('load', hold, true);
276
+ img.addEventListener('error', hold, true);
277
+ };
278
+ const srcDesc = Object.getOwnPropertyDescriptor(HTMLImageElement.prototype, 'src');
279
+ const srcsetDesc = Object.getOwnPropertyDescriptor(HTMLImageElement.prototype, 'srcset');
280
+ for (const [name, desc] of [['src', srcDesc], ['srcset', srcsetDesc]]) {
281
+ if (!desc || !desc.set) continue;
282
+ Object.defineProperty(HTMLImageElement.prototype, name, { configurable: true, enumerable: desc.enumerable, get: desc.get, set(v) { watchImage(this); desc.set.call(this, v); } });
283
+ }
284
+ const realSetAttribute = Element.prototype.setAttribute;
285
+ Element.prototype.setAttribute = function (name, value) {
286
+ if (this instanceof HTMLImageElement && (String(name).toLowerCase() === 'src' || String(name).toLowerCase() === 'srcset')) watchImage(this);
287
+ return realSetAttribute.call(this, name, value);
288
+ };
289
+ // A CSS background image (url(...) in a style) is fetched and decoded in real time too, and painted on whatever frame
290
+ // it is ready: every element whose style or class changes, or that is added, is looked at on the next step, each new
291
+ // url is decoded (real time, at most IMAGE_WAIT ms) and a real frame is let pass to paint it, before time moves.
292
+ const touched = new Set();
293
+ const decodes = new Map();
294
+ // An image whose source arrives by HTML parsing (innerHTML, a cloned <template>, insertAdjacentHTML), setAttributeNS
295
+ // or a <picture> <source> never meets the property and setAttribute paths above: the observer below watches it when
296
+ // it is added or its source attributes change. The observer's callback is a microtask, run at the end of the task
297
+ // that added the image, and an image's load or error event is always a later task, so the hold is in place before the
298
+ // event (tests/visual/sandbox-clock.test.ts proves the three ways give the same virtual time). An image already
299
+ // complete when first seen (loaded before, or served from memory at once) is not held.
300
+ const IMAGE_ATTRS = ['src', 'srcset', 'sizes', 'href', 'xlink:href'];
301
+ const watchFromDom = (el) => {
302
+ if (el instanceof HTMLImageElement) {
303
+ if ((el.getAttribute('src') || el.getAttribute('srcset')) && !el.complete) watchImage(el);
304
+ } else if (window.SVGImageElement && el instanceof SVGImageElement) {
305
+ if (!watched.has(el) && (el.getAttribute('href') || el.getAttribute('xlink:href'))) watchImage(el);
306
+ } else if (el instanceof HTMLSourceElement && el.parentElement instanceof HTMLPictureElement) {
307
+ const img = el.parentElement.querySelector('img');
308
+ if (img && !img.complete) watchImage(img);
309
+ }
310
+ };
311
+ const notice = (node) => {
312
+ if (!node || node.nodeType !== 1) return;
313
+ touched.add(node);
314
+ watchFromDom(node);
315
+ for (const el of node.querySelectorAll('*')) { touched.add(el); watchFromDom(el); }
316
+ };
317
+ new MutationObserver((records) => {
318
+ for (const r of records) {
319
+ if (r.type === 'attributes') {
320
+ touched.add(r.target);
321
+ if (IMAGE_ATTRS.includes(r.attributeName)) watchFromDom(r.target);
322
+ } else for (const n of r.addedNodes) notice(n);
323
+ }
324
+ }).observe(document, { subtree: true, childList: true, attributes: true, attributeFilter: ['style', 'class', ...IMAGE_ATTRS] });
325
+ const urlsIn = (v) => {
326
+ const out = [];
327
+ const re = /url\\(\\s*(?:"([^"]*)"|'([^']*)'|([^)"']*))\\s*\\)/g;
328
+ let m;
329
+ while ((m = re.exec(v))) out.push(m[1] ?? m[2] ?? m[3] ?? '');
330
+ return out;
331
+ };
332
+ const settleBackgrounds = async () => {
333
+ const waits = [];
334
+ for (const el of touched) {
335
+ if (!el.isConnected) continue;
336
+ const v = getComputedStyle(el).backgroundImage;
337
+ if (!v || v.indexOf('url(') < 0) continue;
338
+ for (const u of urlsIn(v)) {
339
+ if (!u || decodes.has(u)) continue;
340
+ const img = document.createElement('img');
341
+ const done = { ready: false };
342
+ decodes.set(u, done);
343
+ srcDesc.set.call(img, u);
344
+ waits.push(img.decode().then(() => undefined, () => undefined).then(() => { done.ready = true; }));
345
+ }
346
+ }
347
+ touched.clear();
348
+ if (!waits.length) return;
349
+ await Promise.race([Promise.all(waits), new Promise((resolve) => realTimeout(resolve, IMAGE_WAIT))]);
350
+ // the decoded image is painted on the next real frames
351
+ await new Promise((resolve) => realRaf(() => resolve()));
352
+ await new Promise((resolve) => realRaf(() => resolve()));
353
+ };
354
+ const settleImages = async () => {
355
+ for (;;) {
356
+ const nowReal = Date.prototype.getTime.call(new RealDate());
357
+ // an image leaves the wait when its event is held (above), or after IMAGE_WAIT (one that never loads: lazy, offscreen)
358
+ for (const [img, since] of pendingImages) if (nowReal - since > IMAGE_WAIT) pendingImages.delete(img);
359
+ if (!pendingImages.size) break;
360
+ await new Promise((resolve) => realTimeout(resolve, 5));
361
+ }
362
+ // a complete image's event may still be queued: one real turn lets it reach the hold
363
+ await new Promise((resolve) => realTimeout(resolve, 0));
364
+ for (const [img, type] of heldImages.splice(0)) run(() => img.dispatchEvent(new Event(type)), []);
365
+ };
366
+ // An animation whose virtual time has reached its end is finished, not held paused past it: its finish handlers run as
367
+ // they would in a browser (Svelte removes an element after its out: transition, motion commits its final style and
368
+ // cancels), so an exit completes on the virtual clock instead of never.
369
+ const sync = () => {
370
+ for (const a of document.getAnimations()) {
371
+ if (!started.has(a)) started.set(a, now);
372
+ const t = now - started.get(a);
373
+ try {
374
+ const end = a.effect ? a.effect.getComputedTiming().endTime : Infinity;
375
+ if (a.playState !== 'finished' && a.playbackRate > 0 && Number.isFinite(end) && t >= end) {
376
+ if (a.playState === 'paused') a.play();
377
+ a.finish();
378
+ continue;
379
+ }
380
+ if (a.playState === 'finished') continue;
381
+ a.pause(); a.currentTime = t;
382
+ } catch (e) { /* a finished, detached animation */ }
383
+ }
384
+ };
385
+ // Observers report on virtual steps too: their real callbacks come on real frames, which arrive at a different virtual
386
+ // time under load, so a component that waits to be on screen (or sized) would start a different number of frames in.
387
+ const observers = new Set();
388
+ const rectOf = (el) => el.getBoundingClientRect();
389
+ const visible = (r) => r.width > 0 && r.height > 0 && r.bottom > 0 && r.right > 0 && r.top < innerHeight && r.left < innerWidth;
390
+ const contentSize = (el) => {
391
+ const cs = getComputedStyle(el);
392
+ const w = Math.max(0, el.clientWidth - parseFloat(cs.paddingLeft) - parseFloat(cs.paddingRight));
393
+ const h = Math.max(0, el.clientHeight - parseFloat(cs.paddingTop) - parseFloat(cs.paddingBottom));
394
+ return { w, h };
395
+ };
396
+ class VirtualIntersectionObserver {
397
+ constructor(cb, options) { this.cb = cb; this.options = options || {}; this.root = this.options.root || null; this.rootMargin = this.options.rootMargin || '0px'; this.thresholds = [].concat(this.options.threshold ?? 0); this.seen = new Map(); observers.add(this); }
398
+ observe(el) { if (!this.seen.has(el)) this.seen.set(el, null); }
399
+ unobserve(el) { this.seen.delete(el); }
400
+ disconnect() { this.seen.clear(); observers.delete(this); }
401
+ takeRecords() { return []; }
402
+ check() {
403
+ const entries = [];
404
+ for (const [el, was] of this.seen) {
405
+ const r = rectOf(el);
406
+ const is = visible(r);
407
+ if (was === is) continue;
408
+ this.seen.set(el, is);
409
+ entries.push({ target: el, isIntersecting: is, intersectionRatio: is ? 1 : 0, boundingClientRect: r, intersectionRect: is ? r : new DOMRect(), rootBounds: new DOMRect(0, 0, innerWidth, innerHeight), time: now });
410
+ }
411
+ if (entries.length) run(this.cb, [entries, this]);
412
+ }
413
+ }
414
+ class VirtualResizeObserver {
415
+ constructor(cb) { this.cb = cb; this.seen = new Map(); observers.add(this); }
416
+ observe(el) { if (!this.seen.has(el)) this.seen.set(el, null); }
417
+ unobserve(el) { this.seen.delete(el); }
418
+ disconnect() { this.seen.clear(); observers.delete(this); }
419
+ check() {
420
+ const entries = [];
421
+ for (const [el, was] of this.seen) {
422
+ const { w, h } = contentSize(el);
423
+ if (was && was.w === w && was.h === h) continue;
424
+ this.seen.set(el, { w, h });
425
+ const r = rectOf(el);
426
+ entries.push({ target: el, contentRect: new DOMRect(0, 0, w, h), borderBoxSize: [{ inlineSize: r.width, blockSize: r.height }], contentBoxSize: [{ inlineSize: w, blockSize: h }], devicePixelContentBoxSize: [{ inlineSize: w * devicePixelRatio, blockSize: h * devicePixelRatio }] });
427
+ }
428
+ if (entries.length) run(this.cb, [entries, this]);
429
+ }
430
+ }
431
+ window.IntersectionObserver = VirtualIntersectionObserver;
432
+ window.ResizeObserver = VirtualResizeObserver;
433
+ // Shaders compiled in parallel finish on the GPU's own time; code that waits for them would start its animation a
434
+ // real-time-dependent number of frames in. Without the extension a program is ready when linked, the same every run.
435
+ for (const Ctx of [window.WebGLRenderingContext, window.WebGL2RenderingContext]) {
436
+ if (!Ctx) continue;
437
+ const getExtension = Ctx.prototype.getExtension;
438
+ const getSupported = Ctx.prototype.getSupportedExtensions;
439
+ Ctx.prototype.getExtension = function (name) { return name === 'KHR_parallel_shader_compile' ? null : getExtension.call(this, name); };
440
+ Ctx.prototype.getSupportedExtensions = function () { return (getSupported.call(this) || []).filter((n) => n !== 'KHR_parallel_shader_compile'); };
441
+ }
442
+ const run = (fn, args) => { try { if (typeof fn === 'function') fn(...args); } catch (e) { setTimeoutReport(e); } };
443
+ const setTimeoutReport = (e) => realTimeout(() => { throw e; }, 0);
444
+ const step = async (dt) => {
445
+ // X6: images still loading are waited for, and their held events handed over, before time moves
446
+ if (pendingImages.size || heldImages.length) await settleImages();
447
+ now += dt;
448
+ for (const o of [...observers]) o.check();
449
+ for (;;) {
450
+ let due = null;
451
+ for (const [id, t] of timers) if (t.at <= now && (!due || t.at < due[1].at)) due = [id, t];
452
+ if (!due) break;
453
+ const [id, t] = due;
454
+ if (t.every) t.at += t.every; else timers.delete(id);
455
+ run(t.fn, t.args);
456
+ }
457
+ const batch = [...frames.entries()];
458
+ frames.clear();
459
+ for (const [, cb] of batch) run(cb, [now]);
460
+ // X6: background images the page now shows are decoded and painted before the frame counts
461
+ if (touched.size) await settleBackgrounds();
462
+ await new Promise((resolve) => realRaf(() => resolve()));
463
+ sync();
464
+ await new Promise((resolve) => realTimeout(resolve, 0));
465
+ };
466
+ window.__morphClock = {
467
+ async advance(ms) {
468
+ let left = ms;
469
+ if (left <= 0) { await step(0); return now; }
470
+ while (left > 0) { const dt = Math.min(16, left); await step(dt); left -= dt; }
471
+ return now;
472
+ },
473
+ // Jumps ms ahead firing only the timers due on the way, in order, each at its own time, and no frames: the unmount
474
+ // check uses it to see whether a timeout re-arms without stepping seconds frame by frame. A few microtask turns
475
+ // after each callback let a promise-based re-arm happen in its place.
476
+ async elapse(ms) {
477
+ const end = now + Math.max(0, ms);
478
+ for (let fired = 0; fired < 100000; fired++) {
479
+ let due = null;
480
+ for (const [id, t] of timers) if (t.at <= end && (!due || t.at < due[1].at)) due = [id, t];
481
+ if (!due) break;
482
+ const [id, t] = due;
483
+ now = Math.max(now, t.at);
484
+ if (t.every) t.at += t.every; else timers.delete(id);
485
+ run(t.fn, t.args);
486
+ await null; await null; await null;
487
+ }
488
+ now = end;
489
+ await new Promise((resolve) => realRaf(() => resolve()));
490
+ sync();
491
+ await new Promise((resolve) => realTimeout(resolve, 0));
492
+ return now;
493
+ },
494
+ now: () => now,
495
+ };
496
+ })();`;
@@ -0,0 +1,42 @@
1
+ import type { Locator, Page } from 'playwright-core';
2
+ import { type StepLocator, type StepStateMismatch, type VerifyStep } from '../types.js';
3
+ /** The longest virtual wait one step may ask for, ms: stepping virtual time costs about as much real time. */
4
+ export declare const MAX_STEP_WAIT = 5000;
5
+ /** The longest script verify runs: every step costs a shot and a few evaluations in every framework. */
6
+ export declare const MAX_STEPS = 24;
7
+ /** A drag (X6): at most this many pointer moves, and an offset at most this far in each axis, CSS px. */
8
+ export declare const MAX_DRAG_MOVES = 30;
9
+ export declare const MAX_DRAG_PX = 2000;
10
+ /** A step that could not be carried out on a page: its target matched nothing there, or the action itself failed. */
11
+ export declare class StepError extends Error {
12
+ readonly kind: 'missing' | 'failed';
13
+ constructor(kind: 'missing' | 'failed', message: string);
14
+ }
15
+ export declare function describeLocator(loc: StepLocator): string;
16
+ /**
17
+ * Checks a script before anything renders (it may come from JSON): every step is named, uniquely, has an action it can
18
+ * carry out and the target and text or key that action needs, and waits a finite virtual time under the cap.
19
+ */
20
+ export declare function checkSteps(steps: VerifyStep[]): void;
21
+ /** Every element a locator matches on a page, searched the way a step searches (exported for auto-steps' confirmation). */
22
+ export declare function locate(page: Page, loc: StepLocator): Locator;
23
+ /** Carries out one step's action on a page (not its wait or its shot). A failure is a StepError; a stopped run rethrows. */
24
+ export declare function performStep(page: Page, step: VerifyStep, alive: () => void): Promise<void>;
25
+ /** One fact per line: `[fact, value]`, in document order. */
26
+ export type StepFacts = [string, string][];
27
+ /**
28
+ * The framework-neutral DOM state of the component after a step: each element's ARIA and `data-state` state, form
29
+ * values and checked states, disabled controls, and what has focus, each keyed by the element's role and accessible
30
+ * name (its `aria-label`, `aria-labelledby` text, `<label>` text, placeholder, or rendered text content), over the
31
+ * page's whole body so portalled content counts. Generated ids and classes never appear, so React and every target
32
+ * describe the same element the same way.
33
+ */
34
+ export declare function collectFacts(page: Page, alive: () => void): Promise<StepFacts>;
35
+ /**
36
+ * The facts that differ between React and a target. Facts are matched by their key with whitespace taken out (one
37
+ * framework keeps a space between a label and a count where another does not, which no pixel shows); values must be
38
+ * equal exactly.
39
+ */
40
+ export declare function diffFacts(react: StepFacts, actual: StepFacts): StepStateMismatch[];
41
+ /** One line for a diagnostic: `aria-checked of switch "Email notifications" is "true" (React: "false")`. */
42
+ export declare function describeMismatches(list: StepStateMismatch[]): string;