@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,309 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { basename, dirname, join, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import ts from 'typescript';
5
+ /**
6
+ * The package's own folder (the first one up from here with a node_modules): the virtual files sit in a folder inside
7
+ * it, so `vue`, `svelte`, `motion-v` and the rest resolve from its node_modules, offline.
8
+ */
9
+ export const MORPH_ROOT = (() => {
10
+ let dir = dirname(fileURLToPath(import.meta.url));
11
+ for (;;) {
12
+ if (existsSync(join(dir, 'node_modules', 'typescript')))
13
+ return dir;
14
+ const up = dirname(dir);
15
+ if (up === dir)
16
+ return resolve(dirname(fileURLToPath(import.meta.url)), '..', '..');
17
+ dir = up;
18
+ }
19
+ })();
20
+ export const key = (p) => resolve(p).replace(/\\/g, '/');
21
+ /** The libraries a check runs with when the compiled project names none: today's language and the DOM. */
22
+ const DEFAULT_LIB = ['lib.esnext.d.ts', 'lib.dom.d.ts', 'lib.dom.iterable.d.ts'];
23
+ let projectLib = DEFAULT_LIB;
24
+ /**
25
+ * The libraries of the project being compiled (its tsconfig's `lib`, read as the TypeOracle reads it): the output may
26
+ * call what its source could (`findLastIndex`), so the check knows the same library. Without a tsconfig or a `lib`,
27
+ * esnext with the DOM.
28
+ */
29
+ export function useProjectLib(root) {
30
+ projectLib = DEFAULT_LIB;
31
+ const configPath = join(root, 'tsconfig.json');
32
+ if (!existsSync(configPath))
33
+ return;
34
+ const config = ts.readConfigFile(configPath, ts.sys.readFile);
35
+ if (config.error)
36
+ return;
37
+ const lib = ts.parseJsonConfigFileContent(config.config, ts.sys, root).options.lib;
38
+ if (lib?.length)
39
+ projectLib = lib.map((l) => basename(l));
40
+ }
41
+ /** What a Vite + Vue or SvelteKit scaffold's tsconfig sets, strict, with no emit; the libraries are the project's. */
42
+ export function baseOptions() {
43
+ return {
44
+ target: ts.ScriptTarget.ES2022,
45
+ module: ts.ModuleKind.ESNext,
46
+ moduleResolution: ts.ModuleResolutionKind.Bundler,
47
+ lib: [...projectLib],
48
+ types: [],
49
+ strict: true,
50
+ skipLibCheck: true,
51
+ noEmit: true,
52
+ esModuleInterop: true,
53
+ resolveJsonModule: true,
54
+ allowImportingTsExtensions: true,
55
+ verbatimModuleSyntax: true,
56
+ useDefineForClassFields: true,
57
+ forceConsistentCasingInFileNames: true,
58
+ };
59
+ }
60
+ /** Ambient declarations every bundler project has (Vite's client types): stylesheet imports. */
61
+ export const AMBIENT = [
62
+ "declare module '*.css';",
63
+ "declare module '*.svg' { const src: string; export default src; }",
64
+ "declare module '*.png' { const src: string; export default src; }",
65
+ "declare module '*.jpg' { const src: string; export default src; }",
66
+ "declare module '*.webp' { const src: string; export default src; }",
67
+ '',
68
+ ].join('\n');
69
+ /**
70
+ * Parsed library files (lib.*.d.ts, node_modules types) and file probes outside the virtual folder are kept for the
71
+ * life of the process: they are the same for every check, and parsing them is most of a cold run.
72
+ */
73
+ const sourceCache = new Map();
74
+ const existsCache = new Map();
75
+ const dirCache = new Map();
76
+ const textCache = new Map();
77
+ /** Files every check shares, generated once (absolute path, forward slashes): parsed once, like library files. */
78
+ const shared = new Map();
79
+ export function shareFile(path, text) {
80
+ shared.set(key(path), text);
81
+ for (const cache of [sourceCache, existsCache, dirCache, textCache])
82
+ for (const k of [...cache.keys()])
83
+ if (k.startsWith(key(path)))
84
+ cache.delete(k);
85
+ }
86
+ /**
87
+ * A compiler host over a virtual folder inside the package: files in `virtual` (absolute paths, forward slashes) are
88
+ * read from memory, the rest from disk. `scriptKind` picks how a virtual file is parsed (a .svelte file holds TS).
89
+ */
90
+ export function createVirtualHost(options, root, virtual, scriptKind, projectRoot = null) {
91
+ const host = ts.createCompilerHost(options, true);
92
+ const readFile = host.readFile.bind(host);
93
+ const fileExists = host.fileExists.bind(host);
94
+ const getSourceFile = host.getSourceFile.bind(host);
95
+ const directoryExists = host.directoryExists?.bind(host);
96
+ const rootKey = key(root);
97
+ const inRoot = (p) => p === rootKey || p.startsWith(rootKey + '/');
98
+ // the compiled project's packages: the virtual folder's own node_modules is the project's (the nearest one that has
99
+ // the package, walking up from the project), so TypeScript finds them before the compiler's, by its own resolution
100
+ const projectModules = projectRoot ? nodeModulesChain(projectRoot) : [];
101
+ const modulesKey = `${rootKey}/node_modules`;
102
+ const packageDir = new Map();
103
+ const toProject = (k) => {
104
+ if (!projectModules.length || !k.startsWith(modulesKey + '/'))
105
+ return null;
106
+ const rest = k.slice(modulesKey.length + 1);
107
+ const parts = rest.split('/');
108
+ const pkg = rest.startsWith('@') ? parts.slice(0, 2).join('/') : (parts[0] ?? '');
109
+ if (!pkg || (rest.startsWith('@') && parts.length < 2) || FRAMEWORK_PACKAGES.test(pkg))
110
+ return null;
111
+ let dir = packageDir.get(pkg);
112
+ if (dir === undefined) {
113
+ dir = projectModules.find((m) => existsSync(join(m, pkg))) ?? null;
114
+ packageDir.set(pkg, dir);
115
+ }
116
+ return dir ? key(join(dir, rest)) : null;
117
+ };
118
+ const dirs = new Set();
119
+ for (const f of virtual.keys()) {
120
+ for (let d = dirname(f).replace(/\\/g, '/'); d.length >= rootKey.length; d = dirname(d).replace(/\\/g, '/')) {
121
+ if (dirs.has(d))
122
+ break;
123
+ dirs.add(d);
124
+ if (d === rootKey)
125
+ break;
126
+ }
127
+ }
128
+ host.getCurrentDirectory = () => root;
129
+ host.readFile = (f) => {
130
+ const k = key(f);
131
+ const text = virtual.get(k) ?? shared.get(k);
132
+ const mapped = text === undefined ? toProject(k) : null;
133
+ if (mapped)
134
+ return readFile(mapped);
135
+ if (text !== undefined || inRoot(k))
136
+ return text;
137
+ // package.json files are read again by every program's module resolution
138
+ if (!textCache.has(k))
139
+ textCache.set(k, readFile(f));
140
+ return textCache.get(k);
141
+ };
142
+ host.fileExists = (f) => {
143
+ const k = key(f);
144
+ if (virtual.has(k) || shared.has(k))
145
+ return true;
146
+ const mapped = toProject(k);
147
+ if (mapped)
148
+ return fileExists(mapped);
149
+ if (inRoot(k))
150
+ return false;
151
+ let hit = existsCache.get(k);
152
+ if (hit === undefined)
153
+ existsCache.set(k, (hit = fileExists(f)));
154
+ return hit;
155
+ };
156
+ host.directoryExists = (d) => {
157
+ const k = key(d);
158
+ if (dirs.has(k))
159
+ return true;
160
+ if (k === modulesKey)
161
+ return projectModules.length > 0;
162
+ const mapped = toProject(k);
163
+ if (mapped)
164
+ return directoryExists ? directoryExists(mapped) : true;
165
+ // a scope folder (`node_modules/@radix-ui`): there when the project has it
166
+ if (projectModules.length && k.startsWith(modulesKey + '/@') && !k.slice(modulesKey.length + 1).includes('/'))
167
+ return projectModules.some((m) => existsSync(join(m, k.slice(modulesKey.length + 1))));
168
+ if (inRoot(k))
169
+ return false;
170
+ for (const s of shared.keys())
171
+ if (s.startsWith(k + '/'))
172
+ return true;
173
+ let hit = dirCache.get(k);
174
+ if (hit === undefined)
175
+ dirCache.set(k, (hit = directoryExists ? directoryExists(d) : true));
176
+ return hit;
177
+ };
178
+ host.getSourceFile = (f, language, onError, create) => {
179
+ const k = key(f);
180
+ const text = virtual.get(k);
181
+ if (text !== undefined) {
182
+ const kind = scriptKind?.(k);
183
+ return ts.createSourceFile(f, text, language, true, kind);
184
+ }
185
+ const mapped = toProject(k);
186
+ if (mapped) {
187
+ // read where it is, named where TypeScript found it (its own imports resolve from there, through this host)
188
+ const source = readFile(mapped);
189
+ return source === undefined ? undefined : ts.createSourceFile(f, source, language, true);
190
+ }
191
+ if (inRoot(k))
192
+ return undefined;
193
+ const version = typeof language === 'object' ? `${language.languageVersion}|${language.impliedNodeFormat ?? ''}` : String(language);
194
+ const cacheKey = `${k}|${version}`;
195
+ let sf = sourceCache.get(cacheKey);
196
+ if (!sf) {
197
+ const sharedText = shared.get(k);
198
+ sf = sharedText !== undefined ? ts.createSourceFile(f, sharedText, language, true) : getSourceFile(f, language, onError, create);
199
+ if (sf)
200
+ sourceCache.set(cacheKey, sf);
201
+ }
202
+ return sf;
203
+ };
204
+ host.writeFile = () => { };
205
+ return host;
206
+ }
207
+ /**
208
+ * The packages the output's own code imports for its framework (the target's runtime, its motion and icon packages):
209
+ * they resolve from the compiler's node_modules, whose versions the emitters write for. Every other package resolves
210
+ * from the compiled project first.
211
+ */
212
+ const FRAMEWORK_PACKAGES = /^(vue|@vue\/[^/]+|svelte|motion|motion-v|lucide-vue-next|@lucide\/vue|@lucide\/svelte|@angular\/[^/]+|rxjs|tslib)(\/|$)/;
213
+ const projectOptionsCache = new Map();
214
+ /** Every node_modules folder from the project's root up to the drive's, nearest first. */
215
+ function nodeModulesChain(projectRoot) {
216
+ const out = [];
217
+ for (let dir = resolve(projectRoot);; dir = dirname(dir)) {
218
+ const candidate = join(dir, 'node_modules');
219
+ if (existsSync(candidate))
220
+ out.push(candidate);
221
+ if (dirname(dir) === dir)
222
+ return out;
223
+ }
224
+ }
225
+ /** The compiled project's own compiler options (its tsconfig: `paths`, `baseUrl`, module resolution). */
226
+ function projectOptions(projectRoot) {
227
+ const hit = projectOptionsCache.get(projectRoot);
228
+ if (hit)
229
+ return hit;
230
+ let options = {};
231
+ const configPath = join(projectRoot, 'tsconfig.json');
232
+ if (existsSync(configPath)) {
233
+ const config = ts.readConfigFile(configPath, ts.sys.readFile);
234
+ if (!config.error)
235
+ options = ts.parseJsonConfigFileContent(config.config, ts.sys, projectRoot).options;
236
+ }
237
+ const resolved = { ...options, moduleResolution: options.moduleResolution ?? ts.ModuleResolutionKind.Bundler, module: options.module ?? ts.ModuleKind.ESNext, resolveJsonModule: true, noEmit: true };
238
+ projectOptionsCache.set(projectRoot, resolved);
239
+ return resolved;
240
+ }
241
+ /**
242
+ * Resolves the bare imports of the checked files (`class-variance-authority`, `clsx`) where the compiled project's
243
+ * own code finds them: each virtual file stands where its source stands in the project (its path under `virtualRoot`
244
+ * is its path under `projectRoot`), so the lookup walks up from there through the project's node_modules, with the
245
+ * project's tsconfig `paths`. Only a package (a node_modules file) or a declaration file is taken: the project's own
246
+ * React sources are never part of the check. Undefined when the project does not have it (the caller falls back to
247
+ * the compiler's own copy).
248
+ */
249
+ export function projectModuleResolver(projectRoot, virtualRoot) {
250
+ // no file system (the browser build): nothing to find
251
+ if (!ts.sys)
252
+ return () => undefined;
253
+ const options = projectOptions(projectRoot);
254
+ const cache = ts.createModuleResolutionCache(projectRoot, (f) => f, options);
255
+ const rootKey = key(virtualRoot);
256
+ return (name, containingFile) => {
257
+ if (name.startsWith('.') || name.startsWith('/') || FRAMEWORK_PACKAGES.test(name))
258
+ return undefined;
259
+ const k = key(containingFile);
260
+ if (!k.startsWith(rootKey + '/'))
261
+ return undefined;
262
+ const standIn = join(projectRoot, k.slice(rootKey.length + 1));
263
+ const found = ts.resolveModuleName(name, standIn, options, ts.sys, cache).resolvedModule;
264
+ if (!found)
265
+ return undefined;
266
+ const file = found.resolvedFileName.replace(/\\/g, '/');
267
+ return found.isExternalLibraryImport || file.endsWith('.d.ts') || file.includes('/node_modules/') ? found : undefined;
268
+ };
269
+ }
270
+ /**
271
+ * Installs module resolution on a host: `special` first (a generated file, a shim), then the compiled project's own
272
+ * packages, then TypeScript's resolution from the virtual folder (the compiler's node_modules).
273
+ */
274
+ export function resolveWithProject(host, options, root, projectRoot, special) {
275
+ const cache = ts.createModuleResolutionCache(root, (f) => f, options);
276
+ const fromProject = projectRoot ? projectModuleResolver(projectRoot, root) : null;
277
+ host.resolveModuleNameLiterals = (literals, containingFile, redirected, compilerOptions, containingSourceFile) => literals.map((literal) => {
278
+ const name = literal.text;
279
+ const own = special?.(name, containingFile) ?? fromProject?.(name, containingFile);
280
+ if (own)
281
+ return { resolvedModule: own };
282
+ const mode = ts.getModeForUsageLocation(containingSourceFile, literal, compilerOptions);
283
+ return ts.resolveModuleName(name, containingFile, compilerOptions, host, cache, redirected, mode);
284
+ });
285
+ }
286
+ /** Offsets of the line starts of a text, for offset → line lookups. */
287
+ export function lineStarts(text) {
288
+ const starts = [0];
289
+ for (let i = 0; i < text.length; i++)
290
+ if (text.charCodeAt(i) === 10)
291
+ starts.push(i + 1);
292
+ return starts;
293
+ }
294
+ /** 0-based line and column of an offset. */
295
+ export function lineCol(starts, offset) {
296
+ let lo = 0;
297
+ let hi = starts.length - 1;
298
+ while (lo < hi) {
299
+ const mid = (lo + hi + 1) >> 1;
300
+ if ((starts[mid] ?? 0) <= offset)
301
+ lo = mid;
302
+ else
303
+ hi = mid - 1;
304
+ }
305
+ return { line: lo, col: offset - (starts[lo] ?? 0) };
306
+ }
307
+ export function messageOf(d) {
308
+ return `TS${d.code}: ${ts.flattenDiagnosticMessageText(d.messageText, '\n')}`;
309
+ }
@@ -0,0 +1,16 @@
1
+ import type { EmittedFile } from '../types.js';
2
+ /** One TypeScript error: the emitted file's path (as given), its 1-based line when it has one, and `TS<code>: text`. */
3
+ export interface TypeProblem {
4
+ path: string;
5
+ line: number | null;
6
+ message: string;
7
+ }
8
+ /**
9
+ * Type-checks one compile's emitted Vue 3 or Svelte 5 files together, strict, offline: what vue-tsc or svelte-check
10
+ * would report. Components (.vue, .svelte), modules (.ts, .svelte.ts) and stylesheets go in as one project in a
11
+ * virtual folder inside the package, so `vue`, `svelte`, `motion-v`, `motion`, `@lucide/vue` and `@lucide/svelte`
12
+ * resolve from its node_modules. With `projectRoot` (the compiled project, whose root the emitted paths are relative
13
+ * to), every other package resolves from that project's node_modules first, as its own code does.
14
+ * Returns every error, mapped back to the emitted file and line.
15
+ */
16
+ export declare function typecheckWeb(files: EmittedFile[], target: 'vue' | 'svelte', projectRoot?: string | null): Promise<TypeProblem[]>;
@@ -0,0 +1,17 @@
1
+ import { join } from 'node:path';
2
+ import { MORPH_ROOT } from './host.js';
3
+ import { typecheckSvelte } from './svelte.js';
4
+ import { typecheckVue } from './vue.js';
5
+ /**
6
+ * Type-checks one compile's emitted Vue 3 or Svelte 5 files together, strict, offline: what vue-tsc or svelte-check
7
+ * would report. Components (.vue, .svelte), modules (.ts, .svelte.ts) and stylesheets go in as one project in a
8
+ * virtual folder inside the package, so `vue`, `svelte`, `motion-v`, `motion`, `@lucide/vue` and `@lucide/svelte`
9
+ * resolve from its node_modules. With `projectRoot` (the compiled project, whose root the emitted paths are relative
10
+ * to), every other package resolves from that project's node_modules first, as its own code does.
11
+ * Returns every error, mapped back to the emitted file and line.
12
+ */
13
+ export async function typecheckWeb(files, target, projectRoot = null) {
14
+ const root = join(MORPH_ROOT, '.typecheck-virtual', Math.random().toString(36).slice(2));
15
+ const code = files.filter((f) => f.kind !== 'report');
16
+ return target === 'vue' ? typecheckVue(code, root, projectRoot) : typecheckSvelte(code, root, projectRoot);
17
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @lucide/svelte's types are one .svelte.d.ts per icon (4,600 files): a program that imports the package reads every
3
+ * one, 10 s cold and 2 s warm. Every icon has the same type, `Component<LucideProps, {}, ''>`, so the same module is
4
+ * declared in two shared files that name each export (icons and aliases) with that type and pass the rest (Icon, the
5
+ * props and context types) through from the real files: same names, same types. Returns the path `@lucide/svelte`
6
+ * resolves to, or null when the package is not installed.
7
+ */
8
+ export declare function lucideSvelteShim(): string | null;
@@ -0,0 +1,45 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { createRequire } from 'node:module';
3
+ import { dirname, join } from 'node:path';
4
+ import { MORPH_ROOT, key, shareFile } from './host.js';
5
+ const require = createRequire(import.meta.url);
6
+ let cached;
7
+ /**
8
+ * @lucide/svelte's types are one .svelte.d.ts per icon (4,600 files): a program that imports the package reads every
9
+ * one, 10 s cold and 2 s warm. Every icon has the same type, `Component<LucideProps, {}, ''>`, so the same module is
10
+ * declared in two shared files that name each export (icons and aliases) with that type and pass the rest (Icon, the
11
+ * props and context types) through from the real files: same names, same types. Returns the path `@lucide/svelte`
12
+ * resolves to, or null when the package is not installed.
13
+ */
14
+ export function lucideSvelteShim() {
15
+ if (cached !== undefined)
16
+ return cached;
17
+ try {
18
+ // the package exports no package.json; its entry sits in dist/
19
+ const dist = dirname(require.resolve('@lucide/svelte')).replace(/\\/g, '/');
20
+ const names = (file) => [...readFileSync(join(dist, file), 'utf8').matchAll(/default as (\w+)\s*\}/g)].map((m) => m[1] ?? '').filter(Boolean);
21
+ const icons = names('icons/index.d.ts');
22
+ const aliases = ['aliases/aliases.d.ts', 'aliases/prefixed.d.ts', 'aliases/suffixed.d.ts'].flatMap(names);
23
+ if (!icons.length)
24
+ throw new Error('no icons found');
25
+ const head = [`import type { Component } from 'svelte';`, `import type { LucideProps } from '${dist}/types.js';`, `type LucideIcon = Component<LucideProps, {}, ''>;`];
26
+ const declare = (list) => [...new Set(list)].map((n) => `export declare const ${n}: LucideIcon;`);
27
+ const dir = key(join(MORPH_ROOT, '.typecheck-shared', 'lucide-svelte'));
28
+ shareFile(`${dir}/icons.d.ts`, [...head, ...declare(icons), ''].join('\n'));
29
+ shareFile(`${dir}/index.d.ts`, [
30
+ ...head,
31
+ ...declare([...icons, ...aliases]),
32
+ `export * as icons from '${dir}/icons';`,
33
+ `export { default as defaultAttributes } from '${dist}/utils/defaultAttributes.js';`,
34
+ `export * from '${dist}/types.js';`,
35
+ `export { default as Icon } from '${dist}/Icon.svelte';`,
36
+ `export * from '${dist}/context.js';`,
37
+ '',
38
+ ].join('\n'));
39
+ cached = `${dir}/index.d.ts`;
40
+ }
41
+ catch {
42
+ cached = null;
43
+ }
44
+ return cached;
45
+ }
@@ -0,0 +1,9 @@
1
+ /** A source map's mappings, decoded: for each generated line, its segments sorted by generated column. */
2
+ export type DecodedLines = {
3
+ col: number;
4
+ line: number;
5
+ }[][];
6
+ /** Decodes a v3 `mappings` string, keeping each segment's generated column and original line (one source). */
7
+ export declare function decodeMappings(mappings: string): DecodedLines;
8
+ /** The original 0-based line of a generated position: the last segment at or before the column, on that line only. */
9
+ export declare function originalLine(lines: DecodedLines, line: number, col: number): number | null;
@@ -0,0 +1,54 @@
1
+ const B64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
2
+ const DIGIT = new Map([...B64].map((c, i) => [c, i]));
3
+ /** Decodes a v3 `mappings` string, keeping each segment's generated column and original line (one source). */
4
+ export function decodeMappings(mappings) {
5
+ const lines = [];
6
+ let srcLine = 0;
7
+ for (const lineText of mappings.split(';')) {
8
+ const segments = [];
9
+ let genCol = 0;
10
+ for (const segment of lineText.split(',')) {
11
+ if (!segment)
12
+ continue;
13
+ const values = vlq(segment);
14
+ genCol += values[0] ?? 0;
15
+ if (values.length >= 4) {
16
+ srcLine += values[2] ?? 0;
17
+ segments.push({ col: genCol, line: srcLine });
18
+ }
19
+ }
20
+ segments.sort((a, b) => a.col - b.col);
21
+ lines.push(segments);
22
+ }
23
+ return lines;
24
+ }
25
+ function vlq(segment) {
26
+ const out = [];
27
+ let value = 0;
28
+ let shift = 0;
29
+ for (const c of segment) {
30
+ const digit = DIGIT.get(c) ?? 0;
31
+ value += (digit & 31) << shift;
32
+ if (digit & 32) {
33
+ shift += 5;
34
+ continue;
35
+ }
36
+ out.push(value & 1 ? -(value >>> 1) : value >>> 1);
37
+ value = 0;
38
+ shift = 0;
39
+ }
40
+ return out;
41
+ }
42
+ /** The original 0-based line of a generated position: the last segment at or before the column, on that line only. */
43
+ export function originalLine(lines, line, col) {
44
+ const segments = lines[line];
45
+ if (!segments?.length)
46
+ return null;
47
+ let found = null;
48
+ for (const s of segments) {
49
+ if (s.col > col)
50
+ break;
51
+ found = s.line;
52
+ }
53
+ return found;
54
+ }
@@ -0,0 +1,9 @@
1
+ import type { EmittedFile } from '../types.js';
2
+ import type { TypeProblem } from './index.js';
3
+ /**
4
+ * Svelte 5: each .svelte file goes through svelte2tsx (the engine of svelte-check) into TypeScript that keeps its
5
+ * .svelte name; .ts and .svelte.ts modules go in as they are; one strict program over all of them. Errors map back to
6
+ * the .svelte line through svelte2tsx's source map; errors inside code svelte2tsx writes for itself are dropped, as
7
+ * svelte-check drops them.
8
+ */
9
+ export declare function typecheckSvelte(files: EmittedFile[], root: string, projectRoot?: string | null): Promise<TypeProblem[]>;
@@ -0,0 +1,116 @@
1
+ import { createRequire } from 'node:module';
2
+ import { dirname, join, resolve } from 'node:path';
3
+ import ts from 'typescript';
4
+ import { errorMessage } from '../utils/errors.js';
5
+ import { AMBIENT, baseOptions, createVirtualHost, key, lineCol, lineStarts, messageOf, resolveWithProject } from './host.js';
6
+ import { decodeMappings, originalLine } from './sourcemap.js';
7
+ import { lucideSvelteShim } from './lucide.js';
8
+ const require = createRequire(import.meta.url);
9
+ let engine = null;
10
+ async function load() {
11
+ if (engine)
12
+ return engine;
13
+ const s2t = (await import('svelte2tsx'));
14
+ const compiler = await import('svelte/compiler');
15
+ const dir = dirname(require.resolve('svelte2tsx/package.json'));
16
+ engine = {
17
+ svelte2tsx: s2t.svelte2tsx ?? s2t.default?.svelte2tsx,
18
+ parse: compiler.parse,
19
+ version: compiler.VERSION,
20
+ // what svelte-check puts in every program: the template's element and attribute types, and the helpers the
21
+ // generated code calls
22
+ shims: [join(dir, 'svelte-shims-v4.d.ts'), join(dir, 'svelte-jsx-v4.d.ts')],
23
+ };
24
+ return engine;
25
+ }
26
+ const IGNORE_START = '/*Ωignore_startΩ*/';
27
+ const IGNORE_END = '/*Ωignore_endΩ*/';
28
+ function ignoredRanges(code) {
29
+ const out = [];
30
+ let from = 0;
31
+ for (;;) {
32
+ const s = code.indexOf(IGNORE_START, from);
33
+ if (s < 0)
34
+ break;
35
+ const e = code.indexOf(IGNORE_END, s);
36
+ out.push([s, e < 0 ? code.length : e + IGNORE_END.length]);
37
+ from = e < 0 ? code.length : e;
38
+ }
39
+ return out;
40
+ }
41
+ /**
42
+ * Svelte 5: each .svelte file goes through svelte2tsx (the engine of svelte-check) into TypeScript that keeps its
43
+ * .svelte name; .ts and .svelte.ts modules go in as they are; one strict program over all of them. Errors map back to
44
+ * the .svelte line through svelte2tsx's source map; errors inside code svelte2tsx writes for itself are dropped, as
45
+ * svelte-check drops them.
46
+ */
47
+ export async function typecheckSvelte(files, root, projectRoot = null) {
48
+ const { svelte2tsx, parse, version, shims } = await load();
49
+ const problems = [];
50
+ const virtual = new Map();
51
+ const generated = new Map();
52
+ for (const f of files) {
53
+ const abs = key(resolve(root, f.path));
54
+ if (f.path.endsWith('.svelte')) {
55
+ try {
56
+ const out = svelte2tsx(f.contents, { filename: f.path.split('/').pop() ?? f.path, isTsFile: true, mode: 'ts', version, parse, emitOnTemplateError: false });
57
+ virtual.set(abs, out.code);
58
+ generated.set(abs, { path: f.path, map: decodeMappings(out.map.mappings), starts: lineStarts(out.code), ignored: ignoredRanges(out.code) });
59
+ }
60
+ catch (error) {
61
+ const start = error.start;
62
+ problems.push({ path: f.path, line: start?.line ?? null, message: `svelte2tsx: ${errorMessage(error).split('\n')[0] ?? ''}` });
63
+ }
64
+ }
65
+ else
66
+ virtual.set(abs, f.contents);
67
+ }
68
+ const ambient = key(join(root, '__ambient.d.ts'));
69
+ virtual.set(ambient, AMBIENT);
70
+ const options = { ...baseOptions(), allowNonTsExtensions: true };
71
+ const host = createVirtualHost(options, root, virtual, (f) => (f.endsWith('.svelte') ? ts.ScriptKind.TS : undefined), projectRoot);
72
+ const lucide = lucideSvelteShim();
73
+ // `./Foo.svelte` resolves to the generated TypeScript kept under the .svelte name, `@lucide/svelte` to its one-file
74
+ // declaration; other packages from the compiled project, then as TS does
75
+ resolveWithProject(host, options, root, projectRoot, (name, containingFile) => {
76
+ if (lucide && (name === '@lucide/svelte' || name === '@lucide/svelte/icons'))
77
+ return { resolvedFileName: lucide, extension: ts.Extension.Dts, isExternalLibraryImport: true };
78
+ if (name.endsWith('.svelte') && name.startsWith('.')) {
79
+ const abs = key(resolve(dirname(containingFile), name));
80
+ if (virtual.has(abs))
81
+ return { resolvedFileName: abs, extension: ts.Extension.Ts, isExternalLibraryImport: false };
82
+ }
83
+ return undefined;
84
+ });
85
+ const rootNames = [...shims, ambient, ...[...virtual.keys()].filter((f) => f.endsWith('.svelte') || (f.endsWith('.ts') && f !== ambient))];
86
+ const program = ts.createProgram({ rootNames, options, host });
87
+ const diagnostics = [...program.getOptionsDiagnostics(), ...program.getGlobalDiagnostics(), ...program.getSyntacticDiagnostics(), ...program.getSemanticDiagnostics()];
88
+ const rootKey = key(root);
89
+ for (const d of diagnostics) {
90
+ if (d.category !== ts.DiagnosticCategory.Error)
91
+ continue;
92
+ const file = d.file ? key(d.file.fileName) : '';
93
+ if (file === ambient)
94
+ continue;
95
+ if (!file || !file.startsWith(rootKey + '/')) {
96
+ problems.push({ path: file ? file : '(project)', line: null, message: messageOf(d) });
97
+ continue;
98
+ }
99
+ const gen = generated.get(file);
100
+ const rel = file.slice(rootKey.length + 1);
101
+ if (!gen || d.start === undefined) {
102
+ problems.push({ path: rel, line: d.file && d.start !== undefined ? d.file.getLineAndCharacterOfPosition(d.start).line + 1 : null, message: messageOf(d) });
103
+ continue;
104
+ }
105
+ const start = d.start;
106
+ if (gen.ignored.some(([s, e]) => start >= s && start < e))
107
+ continue;
108
+ const { line, col } = lineCol(gen.starts, start);
109
+ const original = originalLine(gen.map, line, col) ?? gen.map[line]?.[0]?.line ?? null;
110
+ // a line with no mapping at all is svelte2tsx's own scaffolding
111
+ if (original === null)
112
+ continue;
113
+ problems.push({ path: gen.path, line: original + 1, message: messageOf(d) });
114
+ }
115
+ return problems;
116
+ }
@@ -0,0 +1,8 @@
1
+ import type { EmittedFile } from '../types.js';
2
+ import type { TypeProblem } from './index.js';
3
+ /**
4
+ * Vue 3: the program vue-tsc builds. @vue/language-core turns each SFC (script, script setup and template) into
5
+ * virtual TypeScript, @volar/typescript wraps ts.createProgram to use it and maps every error back to its place in
6
+ * the .vue file (errors in code it wrote for itself are dropped, as vue-tsc drops them).
7
+ */
8
+ export declare function typecheckVue(files: EmittedFile[], root: string, projectRoot?: string | null): Promise<TypeProblem[]>;