@scaffold-ui-kit/preview 0.0.0-stage → 2.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 (350) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1868 -2
  3. package/application/host/bootstrap.ts +43 -0
  4. package/application/host/main.ts +31 -0
  5. package/application/host/shell-host.ts +47 -0
  6. package/application/index.html +12 -0
  7. package/application/lib/base-url.ts +15 -0
  8. package/application/lib/no-code-block.ts +7 -0
  9. package/application/lib/no-setup.ts +3 -0
  10. package/application/lib/no-views.ts +6 -0
  11. package/application/preview/code/code.html +12 -0
  12. package/application/preview/code/main.ts +89 -0
  13. package/application/preview/globals.ts +254 -0
  14. package/application/preview/html/main.ts +93 -0
  15. package/application/preview/html/preview.html +12 -0
  16. package/application/preview/react/main.tsx +146 -0
  17. package/application/preview/react/preview.html +12 -0
  18. package/application/preview/svelte/Preview.svelte +104 -0
  19. package/application/preview/svelte/main.ts +13 -0
  20. package/application/preview/svelte/preview.html +12 -0
  21. package/application/preview/svelte/story-props.ts +172 -0
  22. package/application/preview/view/main.ts +124 -0
  23. package/application/preview/view/view.html +12 -0
  24. package/application/preview/vue/main.ts +145 -0
  25. package/application/preview/vue/preview.html +12 -0
  26. package/application/shells/charcell/components/Application/index.css +37 -0
  27. package/application/shells/charcell/components/Application/index.tsx +65 -0
  28. package/application/shells/charcell/components/Bar/index.css +68 -0
  29. package/application/shells/charcell/components/Bar/index.tsx +60 -0
  30. package/application/shells/charcell/components/CodePane/index.css +60 -0
  31. package/application/shells/charcell/components/CodePane/index.tsx +113 -0
  32. package/application/shells/charcell/components/ComponentStage/index.css +26 -0
  33. package/application/shells/charcell/components/ComponentStage/index.tsx +110 -0
  34. package/application/shells/charcell/components/Control/index.css +20 -0
  35. package/application/shells/charcell/components/Control/index.tsx +118 -0
  36. package/application/shells/charcell/components/CopyLink/index.tsx +35 -0
  37. package/application/shells/charcell/components/Description/index.css +6 -0
  38. package/application/shells/charcell/components/Description/index.tsx +24 -0
  39. package/application/shells/charcell/components/EditorAddDialog/index.css +9 -0
  40. package/application/shells/charcell/components/EditorAddDialog/index.tsx +158 -0
  41. package/application/shells/charcell/components/EditorPanel/index.css +48 -0
  42. package/application/shells/charcell/components/EditorPanel/index.tsx +496 -0
  43. package/application/shells/charcell/components/EventsRow/index.css +42 -0
  44. package/application/shells/charcell/components/EventsRow/index.tsx +68 -0
  45. package/application/shells/charcell/components/HeadingRow/index.css +11 -0
  46. package/application/shells/charcell/components/HeadingRow/index.tsx +16 -0
  47. package/application/shells/charcell/components/Hint/index.css +16 -0
  48. package/application/shells/charcell/components/Hint/index.tsx +81 -0
  49. package/application/shells/charcell/components/HtmlWarnings/index.tsx +45 -0
  50. package/application/shells/charcell/components/KeyHints/index.css +27 -0
  51. package/application/shells/charcell/components/KeyHints/index.tsx +106 -0
  52. package/application/shells/charcell/components/KitCodeBlock/index.css +55 -0
  53. package/application/shells/charcell/components/KitCodeBlock/index.tsx +18 -0
  54. package/application/shells/charcell/components/Markdown/index.tsx +16 -0
  55. package/application/shells/charcell/components/Navigation/index.css +13 -0
  56. package/application/shells/charcell/components/Navigation/index.tsx +98 -0
  57. package/application/shells/charcell/components/NavigationSplit/index.css +16 -0
  58. package/application/shells/charcell/components/NavigationSplit/index.tsx +82 -0
  59. package/application/shells/charcell/components/OptionControls/index.tsx +93 -0
  60. package/application/shells/charcell/components/PaneStatus/index.css +7 -0
  61. package/application/shells/charcell/components/PaneStatus/index.tsx +47 -0
  62. package/application/shells/charcell/components/PaneWidth/index.tsx +45 -0
  63. package/application/shells/charcell/components/PreviewGrid/index.css +39 -0
  64. package/application/shells/charcell/components/PreviewGrid/index.tsx +344 -0
  65. package/application/shells/charcell/components/PreviewPane/index.css +127 -0
  66. package/application/shells/charcell/components/PreviewPane/index.tsx +182 -0
  67. package/application/shells/charcell/components/PromptBar/index.tsx +133 -0
  68. package/application/shells/charcell/components/ScenarioRow/index.css +36 -0
  69. package/application/shells/charcell/components/ScenarioRow/index.tsx +71 -0
  70. package/application/shells/charcell/components/Select/index.tsx +48 -0
  71. package/application/shells/charcell/components/SlotOutlet/index.css +7 -0
  72. package/application/shells/charcell/components/SlotOutlet/index.tsx +25 -0
  73. package/application/shells/charcell/components/StageBar/index.css +7 -0
  74. package/application/shells/charcell/components/StageBar/index.tsx +109 -0
  75. package/application/shells/charcell/components/StageSplit/index.css +11 -0
  76. package/application/shells/charcell/components/StageSplit/index.tsx +99 -0
  77. package/application/shells/charcell/components/StatusBar/index.tsx +30 -0
  78. package/application/shells/charcell/components/ViewControls/index.css +15 -0
  79. package/application/shells/charcell/components/ViewControls/index.tsx +58 -0
  80. package/application/shells/charcell/components/ViewHeading/index.css +13 -0
  81. package/application/shells/charcell/components/ViewHeading/index.tsx +8 -0
  82. package/application/shells/charcell/components/ViewStage/index.css +9 -0
  83. package/application/shells/charcell/components/ViewStage/index.tsx +25 -0
  84. package/application/shells/charcell/components/WrapToggle/index.tsx +27 -0
  85. package/application/shells/charcell/configuration.ts +45 -0
  86. package/application/shells/charcell/controller-context.ts +27 -0
  87. package/application/shells/charcell/fit-labels.ts +42 -0
  88. package/application/shells/charcell/html-warnings.ts +18 -0
  89. package/application/shells/charcell/index.tsx +82 -0
  90. package/application/shells/charcell/page-loading.html +57 -0
  91. package/application/shells/charcell/placement.ts +24 -0
  92. package/application/shells/charcell/shell-options.ts +23 -0
  93. package/application/shells/charcell/shell.css +37 -0
  94. package/application/shells/charcell/shell.tsx +25 -0
  95. package/application/shells/charcell/split-reset.ts +47 -0
  96. package/application/shells/charcell/stacked-rows.ts +117 -0
  97. package/application/shells/charcell/stage-toggles.ts +93 -0
  98. package/application/types/manifest.d.ts +6 -0
  99. package/application/types/preview-configuration.d.ts +10 -0
  100. package/application/types/preview-shell.d.ts +7 -0
  101. package/application/types/react-registry.d.ts +15 -0
  102. package/application/types/vue-registry.d.ts +6 -0
  103. package/dist/build.d.ts +24 -0
  104. package/dist/build.js +34 -0
  105. package/dist/check.d.ts +48 -0
  106. package/dist/check.js +781 -0
  107. package/dist/cli.d.ts +2 -0
  108. package/dist/cli.js +88 -0
  109. package/dist/context.d.ts +179 -0
  110. package/dist/context.js +783 -0
  111. package/dist/controller/catalog.d.ts +339 -0
  112. package/dist/controller/catalog.js +367 -0
  113. package/dist/controller/create-preview-controller.d.ts +532 -0
  114. package/dist/controller/create-preview-controller.js +1707 -0
  115. package/dist/controller/editor-tree.d.ts +161 -0
  116. package/dist/controller/editor-tree.js +373 -0
  117. package/dist/controller/html-source.d.ts +62 -0
  118. package/dist/controller/html-source.js +61 -0
  119. package/dist/controller/index.d.ts +9 -0
  120. package/dist/controller/index.js +12 -0
  121. package/dist/controller/persistence.d.ts +191 -0
  122. package/dist/controller/persistence.js +315 -0
  123. package/dist/controller/regeneration.d.ts +30 -0
  124. package/dist/controller/regeneration.js +27 -0
  125. package/dist/controller/source.d.ts +80 -0
  126. package/dist/controller/source.js +236 -0
  127. package/dist/controller/store.d.ts +27 -0
  128. package/dist/controller/store.js +40 -0
  129. package/dist/declarations/application/shells/charcell/components/Application/index.d.ts +2 -0
  130. package/dist/declarations/application/shells/charcell/components/Bar/index.d.ts +11 -0
  131. package/dist/declarations/application/shells/charcell/components/CodePane/index.d.ts +5 -0
  132. package/dist/declarations/application/shells/charcell/components/ComponentStage/index.d.ts +2 -0
  133. package/dist/declarations/application/shells/charcell/components/Control/index.d.ts +9 -0
  134. package/dist/declarations/application/shells/charcell/components/CopyLink/index.d.ts +1 -0
  135. package/dist/declarations/application/shells/charcell/components/Description/index.d.ts +5 -0
  136. package/dist/declarations/application/shells/charcell/components/EditorAddDialog/index.d.ts +6 -0
  137. package/dist/declarations/application/shells/charcell/components/EditorPanel/index.d.ts +2 -0
  138. package/dist/declarations/application/shells/charcell/components/EventsRow/index.d.ts +4 -0
  139. package/dist/declarations/application/shells/charcell/components/HeadingRow/index.d.ts +6 -0
  140. package/dist/declarations/application/shells/charcell/components/Hint/index.d.ts +11 -0
  141. package/dist/declarations/application/shells/charcell/components/HtmlWarnings/index.d.ts +5 -0
  142. package/dist/declarations/application/shells/charcell/components/KeyHints/index.d.ts +2 -0
  143. package/dist/declarations/application/shells/charcell/components/KitCodeBlock/index.d.ts +5 -0
  144. package/dist/declarations/application/shells/charcell/components/Markdown/index.d.ts +3 -0
  145. package/dist/declarations/application/shells/charcell/components/Navigation/index.d.ts +8 -0
  146. package/dist/declarations/application/shells/charcell/components/NavigationSplit/index.d.ts +7 -0
  147. package/dist/declarations/application/shells/charcell/components/OptionControls/index.d.ts +7 -0
  148. package/dist/declarations/application/shells/charcell/components/PaneStatus/index.d.ts +2 -0
  149. package/dist/declarations/application/shells/charcell/components/PaneWidth/index.d.ts +4 -0
  150. package/dist/declarations/application/shells/charcell/components/PreviewGrid/index.d.ts +7 -0
  151. package/dist/declarations/application/shells/charcell/components/PreviewPane/index.d.ts +9 -0
  152. package/dist/declarations/application/shells/charcell/components/PromptBar/index.d.ts +1 -0
  153. package/dist/declarations/application/shells/charcell/components/ScenarioRow/index.d.ts +2 -0
  154. package/dist/declarations/application/shells/charcell/components/Select/index.d.ts +16 -0
  155. package/dist/declarations/application/shells/charcell/components/SlotOutlet/index.d.ts +5 -0
  156. package/dist/declarations/application/shells/charcell/components/StageBar/index.d.ts +2 -0
  157. package/dist/declarations/application/shells/charcell/components/StageSplit/index.d.ts +17 -0
  158. package/dist/declarations/application/shells/charcell/components/StatusBar/index.d.ts +1 -0
  159. package/dist/declarations/application/shells/charcell/components/ViewControls/index.d.ts +9 -0
  160. package/dist/declarations/application/shells/charcell/components/ViewHeading/index.d.ts +4 -0
  161. package/dist/declarations/application/shells/charcell/components/ViewStage/index.d.ts +4 -0
  162. package/dist/declarations/application/shells/charcell/components/WrapToggle/index.d.ts +1 -0
  163. package/dist/declarations/application/shells/charcell/configuration.d.ts +31 -0
  164. package/dist/declarations/application/shells/charcell/controller-context.d.ts +9 -0
  165. package/dist/declarations/application/shells/charcell/fit-labels.d.ts +18 -0
  166. package/dist/declarations/application/shells/charcell/html-warnings.d.ts +5 -0
  167. package/dist/declarations/application/shells/charcell/index.d.ts +39 -0
  168. package/dist/declarations/application/shells/charcell/placement.d.ts +7 -0
  169. package/dist/declarations/application/shells/charcell/shell-options.d.ts +15 -0
  170. package/dist/declarations/application/shells/charcell/shell.d.ts +9 -0
  171. package/dist/declarations/application/shells/charcell/split-reset.d.ts +30 -0
  172. package/dist/declarations/application/shells/charcell/stacked-rows.d.ts +58 -0
  173. package/dist/declarations/application/shells/charcell/stage-toggles.d.ts +28 -0
  174. package/dist/declarations/src/controller/catalog.d.ts +339 -0
  175. package/dist/declarations/src/controller/create-preview-controller.d.ts +532 -0
  176. package/dist/declarations/src/controller/editor-tree.d.ts +161 -0
  177. package/dist/declarations/src/controller/html-source.d.ts +62 -0
  178. package/dist/declarations/src/controller/index.d.ts +9 -0
  179. package/dist/declarations/src/controller/persistence.d.ts +191 -0
  180. package/dist/declarations/src/controller/regeneration.d.ts +30 -0
  181. package/dist/declarations/src/controller/source.d.ts +80 -0
  182. package/dist/declarations/src/controller/store.d.ts +27 -0
  183. package/dist/declarations/src/emit/common.d.ts +103 -0
  184. package/dist/declarations/src/emit/manifest.d.ts +138 -0
  185. package/dist/declarations/src/emit/source.d.ts +87 -0
  186. package/dist/declarations/src/lib/jsx-roots.d.ts +22 -0
  187. package/dist/declarations/src/lib/module-of-source.d.ts +18 -0
  188. package/dist/declarations/src/lib/naming.d.ts +29 -0
  189. package/dist/declarations/src/lib/react-spelling.d.ts +68 -0
  190. package/dist/declarations/src/lib/scenario-story.d.ts +41 -0
  191. package/dist/declarations/src/lib/slot-fill.d.ts +15 -0
  192. package/dist/declarations/src/lib/types.d.ts +741 -0
  193. package/dist/declarations/src/options.d.ts +224 -0
  194. package/dist/declarations/src/protocol.d.ts +541 -0
  195. package/dist/declarations/src/react-view.d.ts +22 -0
  196. package/dist/declarations/src/react.d.ts +17 -0
  197. package/dist/declarations/src/shell.d.ts +99 -0
  198. package/dist/declarations/src/views.d.ts +152 -0
  199. package/dist/development-server.d.ts +121 -0
  200. package/dist/development-server.js +331 -0
  201. package/dist/emit/common.d.ts +103 -0
  202. package/dist/emit/common.js +170 -0
  203. package/dist/emit/html-source.d.ts +46 -0
  204. package/dist/emit/html-source.js +322 -0
  205. package/dist/emit/manifest.d.ts +138 -0
  206. package/dist/emit/manifest.js +74 -0
  207. package/dist/emit/react.d.ts +16 -0
  208. package/dist/emit/react.js +210 -0
  209. package/dist/emit/scratch.d.ts +40 -0
  210. package/dist/emit/scratch.js +116 -0
  211. package/dist/emit/source.d.ts +87 -0
  212. package/dist/emit/source.js +789 -0
  213. package/dist/emit/svelte.d.ts +9 -0
  214. package/dist/emit/svelte.js +177 -0
  215. package/dist/emit/vue.d.ts +2 -0
  216. package/dist/emit/vue.js +152 -0
  217. package/dist/enumerate.d.ts +2 -0
  218. package/dist/enumerate.js +162 -0
  219. package/dist/generate.d.ts +43 -0
  220. package/dist/generate.js +302 -0
  221. package/dist/html-stylesheet.d.ts +43 -0
  222. package/dist/html-stylesheet.js +145 -0
  223. package/dist/index.d.ts +18 -0
  224. package/dist/index.js +21 -0
  225. package/dist/landing.d.ts +16 -0
  226. package/dist/landing.js +45 -0
  227. package/dist/lib/exported-types.d.ts +42 -0
  228. package/dist/lib/exported-types.js +86 -0
  229. package/dist/lib/html-attributes.d.ts +2 -0
  230. package/dist/lib/html-attributes.js +111 -0
  231. package/dist/lib/html-warnings.d.ts +19 -0
  232. package/dist/lib/html-warnings.js +79 -0
  233. package/dist/lib/jsx-roots.d.ts +22 -0
  234. package/dist/lib/jsx-roots.js +243 -0
  235. package/dist/lib/module-of-source.d.ts +18 -0
  236. package/dist/lib/module-of-source.js +24 -0
  237. package/dist/lib/naming.d.ts +29 -0
  238. package/dist/lib/naming.js +56 -0
  239. package/dist/lib/parse-type.d.ts +32 -0
  240. package/dist/lib/parse-type.js +103 -0
  241. package/dist/lib/react-spelling.d.ts +68 -0
  242. package/dist/lib/react-spelling.js +197 -0
  243. package/dist/lib/scenario-story.d.ts +41 -0
  244. package/dist/lib/scenario-story.js +84 -0
  245. package/dist/lib/slot-fill.d.ts +15 -0
  246. package/dist/lib/slot-fill.js +92 -0
  247. package/dist/lib/template-files.d.ts +14 -0
  248. package/dist/lib/template-files.js +25 -0
  249. package/dist/lib/types.d.ts +741 -0
  250. package/dist/lib/types.js +13 -0
  251. package/dist/lib/void-elements.d.ts +7 -0
  252. package/dist/lib/void-elements.js +13 -0
  253. package/dist/load.d.ts +37 -0
  254. package/dist/load.js +82 -0
  255. package/dist/model.d.ts +44 -0
  256. package/dist/model.js +464 -0
  257. package/dist/options.d.ts +224 -0
  258. package/dist/options.js +223 -0
  259. package/dist/prop-types.d.ts +26 -0
  260. package/dist/prop-types.js +102 -0
  261. package/dist/props-from.d.ts +84 -0
  262. package/dist/props-from.js +510 -0
  263. package/dist/protocol.d.ts +541 -0
  264. package/dist/protocol.js +819 -0
  265. package/dist/react-view.d.ts +22 -0
  266. package/dist/react-view.js +36 -0
  267. package/dist/react.d.ts +17 -0
  268. package/dist/react.js +23 -0
  269. package/dist/sass-importers.d.ts +26 -0
  270. package/dist/sass-importers.js +32 -0
  271. package/dist/shell-acceptance.d.ts +21 -0
  272. package/dist/shell-acceptance.js +37 -0
  273. package/dist/shell-page.d.ts +36 -0
  274. package/dist/shell-page.js +90 -0
  275. package/dist/shell-peers.d.ts +38 -0
  276. package/dist/shell-peers.js +61 -0
  277. package/dist/shell.d.ts +99 -0
  278. package/dist/shell.js +52 -0
  279. package/dist/shells/charcell/page.d.ts +8 -0
  280. package/dist/shells/charcell/page.js +69 -0
  281. package/dist/story-source.d.ts +113 -0
  282. package/dist/story-source.js +271 -0
  283. package/dist/story.d.ts +5 -0
  284. package/dist/story.js +28 -0
  285. package/dist/testing.d.ts +218 -0
  286. package/dist/testing.js +284 -0
  287. package/dist/views.d.ts +152 -0
  288. package/dist/views.js +7 -0
  289. package/dist/vite-configuration.d.ts +114 -0
  290. package/dist/vite-configuration.js +578 -0
  291. package/package.json +123 -3
  292. package/src/build.ts +51 -0
  293. package/src/check.ts +1062 -0
  294. package/src/cli.ts +123 -0
  295. package/src/context.ts +1168 -0
  296. package/src/controller/catalog.ts +719 -0
  297. package/src/controller/create-preview-controller.ts +2683 -0
  298. package/src/controller/editor-tree.ts +530 -0
  299. package/src/controller/html-source.ts +114 -0
  300. package/src/controller/index.ts +105 -0
  301. package/src/controller/persistence.ts +403 -0
  302. package/src/controller/regeneration.ts +55 -0
  303. package/src/controller/source.ts +333 -0
  304. package/src/controller/store.ts +55 -0
  305. package/src/development-server.ts +442 -0
  306. package/src/emit/common.ts +201 -0
  307. package/src/emit/html-source.ts +402 -0
  308. package/src/emit/manifest.ts +241 -0
  309. package/src/emit/react.ts +263 -0
  310. package/src/emit/scratch.ts +175 -0
  311. package/src/emit/source.ts +1094 -0
  312. package/src/emit/svelte.ts +230 -0
  313. package/src/emit/vue.ts +194 -0
  314. package/src/enumerate.ts +220 -0
  315. package/src/generate.ts +443 -0
  316. package/src/html-stylesheet.ts +173 -0
  317. package/src/index.ts +60 -0
  318. package/src/landing.ts +58 -0
  319. package/src/lib/exported-types.ts +114 -0
  320. package/src/lib/html-attributes.ts +113 -0
  321. package/src/lib/html-warnings.ts +81 -0
  322. package/src/lib/jsx-roots.ts +238 -0
  323. package/src/lib/module-of-source.ts +26 -0
  324. package/src/lib/naming.ts +65 -0
  325. package/src/lib/parse-type.ts +143 -0
  326. package/src/lib/react-spelling.ts +235 -0
  327. package/src/lib/scenario-story.ts +97 -0
  328. package/src/lib/slot-fill.ts +102 -0
  329. package/src/lib/template-files.ts +31 -0
  330. package/src/lib/types.ts +778 -0
  331. package/src/lib/void-elements.ts +15 -0
  332. package/src/load.ts +144 -0
  333. package/src/model.ts +568 -0
  334. package/src/options.ts +435 -0
  335. package/src/prop-types.ts +133 -0
  336. package/src/props-from.ts +678 -0
  337. package/src/protocol.ts +1135 -0
  338. package/src/react-view.ts +45 -0
  339. package/src/react.ts +34 -0
  340. package/src/sass-importers.ts +45 -0
  341. package/src/shell-acceptance.ts +45 -0
  342. package/src/shell-page.ts +133 -0
  343. package/src/shell-peers.ts +70 -0
  344. package/src/shell.ts +194 -0
  345. package/src/shells/charcell/page.ts +82 -0
  346. package/src/story-source.ts +391 -0
  347. package/src/story.ts +42 -0
  348. package/src/testing.ts +497 -0
  349. package/src/views.ts +183 -0
  350. package/src/vite-configuration.ts +675 -0
@@ -0,0 +1,331 @@
1
+ // The `dev` command's server: generate, serve, and keep the preview in step
2
+ // with the kit while it runs. The kit's templates, story files and manual
3
+ // component modules load in Node for generation, not through Vite, so Vite
4
+ // does not watch them; this module adds them to Vite's watcher and
5
+ // regenerates when one changes. The generated registries and manifest are in
6
+ // Vite's module graph, so writing a changed one reloads the pages that import
7
+ // it. An edit to the kit configuration starts a new server from the new
8
+ // configuration, since it can change the port, the sources, the shell, the
9
+ // aliases and the data the pages are served.
10
+ import { realpathSync } from 'node:fs';
11
+ import { createRequire } from 'node:module';
12
+ import { dirname, resolve, sep } from 'node:path';
13
+ import { createServer } from 'vite';
14
+ import { loadPreviewContext } from './context.js';
15
+ import { generatePreview } from './generate.js';
16
+ import { buildViteConfiguration, } from './vite-configuration.js';
17
+ import { isTemplateFile } from './lib/template-files.js';
18
+ /** How long a burst of saves settles before the preview regenerates. */
19
+ export const REGENERATION_DELAY_MILLISECONDS = 100;
20
+ /** The module cache the kit's modules load into (Node's, shared by every importer). */
21
+ const moduleCache = createRequire(import.meta.url).cache;
22
+ /** The kit root as written and as resolved, since a loaded module is cached
23
+ * under the path it resolved to. */
24
+ function kitRoots(context) {
25
+ const roots = new Set([context.kitRoot]);
26
+ try {
27
+ roots.add(realpathSync(context.kitRoot));
28
+ }
29
+ catch {
30
+ // A kit root that does not resolve is only known as written.
31
+ }
32
+ return [...roots].map((root) => root + sep);
33
+ }
34
+ /** Whether `path` is one of the kit's own modules: under its root, and
35
+ * neither an installed package nor generated output. */
36
+ function isKitModule(path, context, roots) {
37
+ return (roots.some((root) => path.startsWith(root)) &&
38
+ !path.includes(`${sep}node_modules${sep}`) &&
39
+ !path.startsWith(context.generatedRoot + sep));
40
+ }
41
+ /**
42
+ * The kit's own modules generation has loaded: the templates and story files,
43
+ * and every module of the kit they import.
44
+ *
45
+ * @param context - The kit's preview context.
46
+ * @returns Their absolute paths.
47
+ */
48
+ export function loadedKitModules(context) {
49
+ const roots = kitRoots(context);
50
+ return Object.keys(moduleCache).filter((path) => isKitModule(path, context, roots));
51
+ }
52
+ /**
53
+ * Forgets the kit's loaded modules, so the next generation imports each one
54
+ * afresh from disk. Installed packages stay loaded.
55
+ *
56
+ * @param context - The kit's preview context.
57
+ * @returns The absolute paths forgotten.
58
+ */
59
+ export function forgetKitModules(context) {
60
+ const forgotten = loadedKitModules(context);
61
+ for (const path of forgotten)
62
+ delete moduleCache[path];
63
+ return forgotten;
64
+ }
65
+ /**
66
+ * The paths the development server watches in a kit: each source's templates
67
+ * and stories directories (so an added or deleted component is noticed),
68
+ * its manual components module, the shared
69
+ * modules templates import, every other kit module generation loaded, and
70
+ * the themes' stylesheets and assets. The custom views module, the shell and
71
+ * the setup modules are left to Vite, which serves them and reloads them
72
+ * itself; generation reads none of them.
73
+ *
74
+ * @param context - The kit's preview context.
75
+ * @param inputs - What the last successful generation read.
76
+ * @returns The paths, absolute.
77
+ */
78
+ export function kitWatchPaths(context, inputs = {}) {
79
+ const regeneration = new Set();
80
+ for (const source of context.sources) {
81
+ for (const path of [
82
+ source.templatesDirectoryAbsolute,
83
+ source.storiesDirectoryAbsolute,
84
+ source.manualModuleAbsolute,
85
+ ]) {
86
+ if (path)
87
+ regeneration.add(path);
88
+ }
89
+ }
90
+ for (const path of context.sharedModulesAbsolute)
91
+ regeneration.add(path);
92
+ for (const path of inputs.loadedModules ?? [])
93
+ regeneration.add(path);
94
+ for (const path of inputs.themeSources ?? [])
95
+ regeneration.add(path);
96
+ return {
97
+ regeneration: [...regeneration],
98
+ kitConfiguration: context.configurationPath,
99
+ configurationModules: context.configurationModules,
100
+ };
101
+ }
102
+ /**
103
+ * What a change to `path` asks of the development server: a restart for the
104
+ * kit configuration file and the kit modules it loads; a regeneration for a template (a TypeScript module
105
+ * directly in a templates directory), a story file, a theme's stylesheet or a
106
+ * file in its assets, or a module named in `kitWatchPaths`; nothing for any
107
+ * other file.
108
+ *
109
+ * @param path - The absolute path that changed, was added or was deleted.
110
+ * @param context - The kit's preview context.
111
+ * @param inputs - What the last successful generation read.
112
+ * @returns The change, or `undefined` when the file is none of the kit's inputs.
113
+ */
114
+ export function classifyKitChange(path, context, inputs = {}) {
115
+ const paths = kitWatchPaths(context, inputs);
116
+ if (path === paths.kitConfiguration ||
117
+ paths.configurationModules.includes(path))
118
+ return 'restart';
119
+ const directory = dirname(path);
120
+ for (const source of context.sources) {
121
+ if (directory === source.templatesDirectoryAbsolute &&
122
+ isTemplateFile(path)) {
123
+ return 'regenerate';
124
+ }
125
+ if (directory === source.storiesDirectoryAbsolute &&
126
+ path.endsWith('.story.ts')) {
127
+ return 'regenerate';
128
+ }
129
+ }
130
+ if ((inputs.themeSources ?? []).some((source) => path === source || path.startsWith(source + sep))) {
131
+ return 'regenerate';
132
+ }
133
+ const files = new Set(paths.regeneration.filter((each) => !context.sources.some((source) => each === source.templatesDirectoryAbsolute ||
134
+ each === source.storiesDirectoryAbsolute)));
135
+ return files.has(path) ? 'regenerate' : undefined;
136
+ }
137
+ /**
138
+ * A Vite plugin that watches a kit's preview inputs while the development
139
+ * server runs and regenerates the preview when one changes. Saves arriving
140
+ * within the delay of each other regenerate once. A regeneration imports the
141
+ * kit's modules afresh, keeps Vite's cache and the scenario editor's story,
142
+ * and writes only the files whose content changed; Vite then reloads the
143
+ * pages importing them. A kit with an html pane also reloads its pages when
144
+ * a regeneration writes nothing, since the pane prints the templates' markup
145
+ * itself and a change to it writes no generated file. A kit module that fails to load is
146
+ * logged and the last good output stays until a later save loads.
147
+ *
148
+ * @param context - The kit's preview context.
149
+ * @param options - What a change to the kit configuration file does, and the delay.
150
+ * @returns The plugin.
151
+ */
152
+ export function kitWatchPlugin(context, options) {
153
+ const delay = options.delayMilliseconds ?? REGENERATION_DELAY_MILLISECONDS;
154
+ return {
155
+ name: 'preview-kit-watch',
156
+ configureServer(server) {
157
+ const logger = server.config.logger;
158
+ let inputs = {
159
+ loadedModules: loadedKitModules(context),
160
+ ...options.inputs,
161
+ };
162
+ let watched = new Set();
163
+ // Watch what the latest generation read, and stop watching what it no
164
+ // longer reads, unless Vite serves that file itself.
165
+ const watch = () => {
166
+ const paths = kitWatchPaths(context, inputs);
167
+ const next = new Set([
168
+ ...paths.regeneration,
169
+ paths.kitConfiguration,
170
+ ...paths.configurationModules,
171
+ ]);
172
+ const dropped = [...watched].filter((path) => !next.has(path) && !server.moduleGraph?.getModulesByFile(path)?.size);
173
+ if (dropped.length > 0)
174
+ server.watcher.unwatch(dropped);
175
+ server.watcher.add([...next].filter((path) => !watched.has(path)));
176
+ watched = next;
177
+ };
178
+ watch();
179
+ let closed = false;
180
+ let timer;
181
+ let running;
182
+ let pendingRegeneration = false;
183
+ let pendingRestart = false;
184
+ const regenerate = async () => {
185
+ forgetKitModules(context);
186
+ try {
187
+ const { written, removed, themeSources } = await generatePreview(context, { clean: false });
188
+ inputs = { loadedModules: loadedKitModules(context), themeSources };
189
+ watch();
190
+ const changed = written.length + removed.length;
191
+ logger.info(changed === 0
192
+ ? '[preview] regenerated: no generated files changed'
193
+ : `[preview] regenerated: ${changed} ${changed === 1 ? 'file' : 'files'} changed`, { timestamp: true });
194
+ // The theme stylesheets are served as files, outside the module
195
+ // graph: a changed one reloads the pages here. The html pane's
196
+ // markup is printed on request from the templates just loaded, and
197
+ // a change to a template's markup writes no generated file, so
198
+ // that kit reloads here when nothing was written for Vite to act on.
199
+ const publicRoot = resolve(context.generatedRoot, 'public') + sep;
200
+ if ((context.buildsHtml && changed === 0) ||
201
+ written.some((path) => path.startsWith(publicRoot))) {
202
+ server.ws.send({ type: 'full-reload', path: '*' });
203
+ }
204
+ }
205
+ catch (error) {
206
+ const detail = error instanceof Error ? (error.stack ?? error.message) : error;
207
+ logger.error(`[preview] regeneration failed; the preview keeps its last output until a save loads:\n${String(detail)}`, { timestamp: true });
208
+ }
209
+ };
210
+ const work = async () => {
211
+ if (pendingRestart) {
212
+ pendingRestart = false;
213
+ await options.onKitConfigurationChange();
214
+ }
215
+ if (pendingRegeneration && !closed) {
216
+ pendingRegeneration = false;
217
+ await regenerate();
218
+ }
219
+ };
220
+ const settle = () => {
221
+ timer = undefined;
222
+ if (closed)
223
+ return;
224
+ if (running)
225
+ return;
226
+ running = work().finally(() => {
227
+ running = undefined;
228
+ if ((pendingRestart || pendingRegeneration) && !closed && !timer) {
229
+ settle();
230
+ }
231
+ });
232
+ };
233
+ server.watcher.on('all', (event, path) => {
234
+ if (closed)
235
+ return;
236
+ if (event !== 'add' && event !== 'change' && event !== 'unlink')
237
+ return;
238
+ const change = classifyKitChange(path, context, inputs);
239
+ if (!change)
240
+ return;
241
+ if (change === 'restart')
242
+ pendingRestart = true;
243
+ else
244
+ pendingRegeneration = true;
245
+ if (timer)
246
+ clearTimeout(timer);
247
+ timer = setTimeout(settle, delay);
248
+ });
249
+ server.httpServer?.once('close', () => {
250
+ closed = true;
251
+ if (timer)
252
+ clearTimeout(timer);
253
+ });
254
+ },
255
+ };
256
+ }
257
+ /**
258
+ * Generates a kit's preview and serves it, regenerating as the kit's
259
+ * preview inputs change and starting a new server, from the new
260
+ * configuration, when the kit configuration changes. A configuration that
261
+ * fails to load is logged and the running server kept.
262
+ *
263
+ * @param kitRoot - The kit root (where its package.json lives).
264
+ * @param overrides - The port and host, over the kit's configured ones.
265
+ * @param options - The kit configuration file, when it is not the one the
266
+ * kit root gives.
267
+ * @returns The running server.
268
+ * @example
269
+ * ```ts
270
+ * const development = await startDevelopmentServer(kitRoot, { port: 6100 });
271
+ * ```
272
+ */
273
+ export async function startDevelopmentServer(kitRoot, overrides = {}, options = {}) {
274
+ let server;
275
+ let restarting;
276
+ const listen = async (context, generated) => {
277
+ const configuration = buildViteConfiguration(context, overrides);
278
+ configuration.plugins = [
279
+ ...(configuration.plugins ?? []),
280
+ kitWatchPlugin(context, {
281
+ onKitConfigurationChange: () => (restarting = restart()),
282
+ inputs: {
283
+ loadedModules: loadedKitModules(context),
284
+ themeSources: generated.themeSources,
285
+ },
286
+ }),
287
+ ];
288
+ const started = await createServer(configuration);
289
+ await started.listen();
290
+ started.printUrls();
291
+ return started;
292
+ };
293
+ const restart = async () => {
294
+ const logger = server.config.logger;
295
+ let context;
296
+ let generated;
297
+ try {
298
+ context = loadPreviewContext(kitRoot, options);
299
+ forgetKitModules(context);
300
+ generated = await generatePreview(context, { clean: false });
301
+ }
302
+ catch (error) {
303
+ logger.error(`[preview] the kit configuration changed but did not load; the server keeps its previous configuration until a save loads:\n${error instanceof Error ? error.message : String(error)}`, { timestamp: true });
304
+ return;
305
+ }
306
+ logger.info('[preview] the kit configuration changed: restarting', {
307
+ timestamp: true,
308
+ });
309
+ await server.close();
310
+ try {
311
+ server = await listen(context, generated);
312
+ }
313
+ catch (error) {
314
+ logger.error(`[preview] the server did not restart:\n${error instanceof Error ? error.message : String(error)}`, { timestamp: true });
315
+ process.exitCode = 1;
316
+ }
317
+ };
318
+ const context = loadPreviewContext(kitRoot, options);
319
+ for (const warning of context.warnings)
320
+ console.warn(`[preview] ${warning}`);
321
+ server = await listen(context, await generatePreview(context));
322
+ return {
323
+ get server() {
324
+ return server;
325
+ },
326
+ async close() {
327
+ await restarting;
328
+ await server.close();
329
+ },
330
+ };
331
+ }
@@ -0,0 +1,103 @@
1
+ import type { JsonValue, SlotFill, ResolvedStory } from '../lib/types.js';
2
+ export declare function serialize(value: JsonValue): string;
3
+ /**
4
+ * Text as a Vue or Svelte template reads it back: `&` and `<` escaped, as
5
+ * either would start a character reference or open a tag.
6
+ *
7
+ * @param value - The text as the story gives it.
8
+ * @returns The text as markup.
9
+ */
10
+ export declare function markupText(value: string): string;
11
+ /**
12
+ * Whether a text has whitespace a template does not keep as written:
13
+ * whitespace at an edge, a run of it or a line break, which a template
14
+ * trims, collapses, or loses where the printed element breaks over lines.
15
+ *
16
+ * @param value - The text as the story gives it.
17
+ * @returns Whether the text has to be printed as a string expression.
18
+ */
19
+ export declare function hasFragileWhitespace(value: string): boolean;
20
+ /**
21
+ * Text as a Vue template reads it back: markup text with each `{{` held in
22
+ * an interpolation of its own, so it does not open one.
23
+ *
24
+ * @param value - The text as the story gives it.
25
+ * @returns The text as Vue template content.
26
+ * @example
27
+ * vueText('Type {{ name }} here');
28
+ * // 'Type {{ "{{" }} name }} here'
29
+ */
30
+ export declare function vueText(value: string): string;
31
+ /**
32
+ * Text as a printed Vue template keeps it: {@link vueText}, or one string
33
+ * interpolation for a text with whitespace at an edge, a run of it or a
34
+ * line break, which Vue condenses and a printed element's line breaks
35
+ * replace.
36
+ *
37
+ * @param value - The text as the story gives it.
38
+ * @returns The text as Vue template content.
39
+ * @example
40
+ * vueSourceText(' 1 ripburger');
41
+ * // '{{ " 1 ripburger" }}'
42
+ */
43
+ export declare function vueSourceText(value: string): string;
44
+ /**
45
+ * The Vue template content before a junction, given the content joined onto
46
+ * it: a trailing `{` before content starting with one is held in an
47
+ * interpolation of its own, as the two would otherwise open one.
48
+ *
49
+ * @param before - The content before the junction.
50
+ * @param next - The content joined onto it.
51
+ * @returns The content before the junction, safe to join.
52
+ * @example
53
+ * vueJunction('Price: {', '{ amount }}');
54
+ * // "Price: {{ '{' }}"
55
+ */
56
+ export declare function vueJunction(before: string, next: string): string;
57
+ /**
58
+ * Vue template pieces joined into one, each junction separated by
59
+ * {@link vueJunction}.
60
+ *
61
+ * @param pieces - The template content, in order.
62
+ * @returns The joined content.
63
+ */
64
+ export declare function joinVue(pieces: string[]): string;
65
+ /**
66
+ * Text as a Svelte template reads it back: markup text with each brace held
67
+ * in an expression of its own, so none opens one. Svelte trims the whitespace
68
+ * at the edges of an element's or a component's content and collapses a run
69
+ * of it, so a text with whitespace at an edge, a run of it or a line break
70
+ * is one string expression instead, which Svelte renders as it is.
71
+ *
72
+ * @param value - The text as the story gives it.
73
+ * @returns The text as Svelte markup.
74
+ * @example
75
+ * svelteText('Price: {amount}');
76
+ * // "Price: {'{'}amount{'}'}"
77
+ * svelteText(' 1 ripburger');
78
+ * // '{" 1 ripburger"}'
79
+ */
80
+ export declare function svelteText(value: string): string;
81
+ /**
82
+ * A value as a Vue template's bound attribute holds it, single-quoted:
83
+ * the value's expression with `&` and `'` as character references, which
84
+ * the template reads back as the characters, so neither ends the attribute
85
+ * nor starts a reference of its own.
86
+ *
87
+ * @param value - The prop's value.
88
+ * @returns The attribute's text, quotes included.
89
+ * @example
90
+ * vueBoundAttribute("Don't");
91
+ * // `'"Don&#39;t"'`
92
+ */
93
+ export declare function vueBoundAttribute(value: JsonValue): string;
94
+ export declare function needsColor(model: ResolvedStory): boolean;
95
+ export declare function propTypesBody(model: ResolvedStory): string;
96
+ /** The effective default-slot fill: an explicit story file fill, or the `children`
97
+ * text prop for components that have a default slot and no story file fill. */
98
+ export type DefaultSlot = SlotFill | {
99
+ kind: 'propText';
100
+ prop: string;
101
+ } | undefined;
102
+ export declare function effectiveDefaultSlot(model: ResolvedStory): DefaultSlot;
103
+ export declare function namedSlots(model: ResolvedStory): Record<string, SlotFill>;
@@ -0,0 +1,170 @@
1
+ // Shared helpers used by every per-target emitter. The propTypes/props are
2
+ // identical across targets (same model); only imports, render syntax, and
3
+ // slot-fill translation differ - those live in the per-target emitters.
4
+ export function serialize(value) {
5
+ if (value === undefined)
6
+ return 'undefined';
7
+ if (value === null)
8
+ return 'null';
9
+ if (Array.isArray(value))
10
+ return `[${value.map(serialize).join(', ')}]`;
11
+ if (typeof value === 'string')
12
+ return JSON.stringify(value);
13
+ if (typeof value === 'object') {
14
+ const body = Object.entries(value)
15
+ .map(([key, entryValue]) => `${JSON.stringify(key)}: ${serialize(entryValue)}`)
16
+ .join(', ');
17
+ return `{ ${body} }`;
18
+ }
19
+ return String(value);
20
+ }
21
+ /**
22
+ * Text as a Vue or Svelte template reads it back: `&` and `<` escaped, as
23
+ * either would start a character reference or open a tag.
24
+ *
25
+ * @param value - The text as the story gives it.
26
+ * @returns The text as markup.
27
+ */
28
+ export function markupText(value) {
29
+ return value.replace(/&/g, '&amp;').replace(/</g, '&lt;');
30
+ }
31
+ /**
32
+ * Whether a text has whitespace a template does not keep as written:
33
+ * whitespace at an edge, a run of it or a line break, which a template
34
+ * trims, collapses, or loses where the printed element breaks over lines.
35
+ *
36
+ * @param value - The text as the story gives it.
37
+ * @returns Whether the text has to be printed as a string expression.
38
+ */
39
+ export function hasFragileWhitespace(value) {
40
+ return /^\s|\s$|\s\s|[\t\n\r\f]/.test(value);
41
+ }
42
+ /**
43
+ * Text as a Vue template reads it back: markup text with each `{{` held in
44
+ * an interpolation of its own, so it does not open one.
45
+ *
46
+ * @param value - The text as the story gives it.
47
+ * @returns The text as Vue template content.
48
+ * @example
49
+ * vueText('Type {{ name }} here');
50
+ * // 'Type {{ "{{" }} name }} here'
51
+ */
52
+ export function vueText(value) {
53
+ return markupText(value).replace(/\{\{/g, '{{ "{{" }}');
54
+ }
55
+ /**
56
+ * Text as a printed Vue template keeps it: {@link vueText}, or one string
57
+ * interpolation for a text with whitespace at an edge, a run of it or a
58
+ * line break, which Vue condenses and a printed element's line breaks
59
+ * replace.
60
+ *
61
+ * @param value - The text as the story gives it.
62
+ * @returns The text as Vue template content.
63
+ * @example
64
+ * vueSourceText(' 1 ripburger');
65
+ * // '{{ " 1 ripburger" }}'
66
+ */
67
+ export function vueSourceText(value) {
68
+ if (hasFragileWhitespace(value)) {
69
+ // A `}}` inside the string would close the interpolation.
70
+ return `{{ ${JSON.stringify(value).replace(/\}\}/g, '}\\u007d')} }}`;
71
+ }
72
+ return vueText(value);
73
+ }
74
+ /**
75
+ * The Vue template content before a junction, given the content joined onto
76
+ * it: a trailing `{` before content starting with one is held in an
77
+ * interpolation of its own, as the two would otherwise open one.
78
+ *
79
+ * @param before - The content before the junction.
80
+ * @param next - The content joined onto it.
81
+ * @returns The content before the junction, safe to join.
82
+ * @example
83
+ * vueJunction('Price: {', '{ amount }}');
84
+ * // "Price: {{ '{' }}"
85
+ */
86
+ export function vueJunction(before, next) {
87
+ return before.endsWith('{') && next.startsWith('{')
88
+ ? `${before.slice(0, -1)}{{ '{' }}`
89
+ : before;
90
+ }
91
+ /**
92
+ * Vue template pieces joined into one, each junction separated by
93
+ * {@link vueJunction}.
94
+ *
95
+ * @param pieces - The template content, in order.
96
+ * @returns The joined content.
97
+ */
98
+ export function joinVue(pieces) {
99
+ return pieces.reduce((joined, piece) => (joined ? vueJunction(joined, piece) : joined) + piece, '');
100
+ }
101
+ /**
102
+ * Text as a Svelte template reads it back: markup text with each brace held
103
+ * in an expression of its own, so none opens one. Svelte trims the whitespace
104
+ * at the edges of an element's or a component's content and collapses a run
105
+ * of it, so a text with whitespace at an edge, a run of it or a line break
106
+ * is one string expression instead, which Svelte renders as it is.
107
+ *
108
+ * @param value - The text as the story gives it.
109
+ * @returns The text as Svelte markup.
110
+ * @example
111
+ * svelteText('Price: {amount}');
112
+ * // "Price: {'{'}amount{'}'}"
113
+ * svelteText(' 1 ripburger');
114
+ * // '{" 1 ripburger"}'
115
+ */
116
+ export function svelteText(value) {
117
+ if (hasFragileWhitespace(value)) {
118
+ return `{${JSON.stringify(value)}}`;
119
+ }
120
+ return markupText(value).replace(/[{}]/g, (brace) => `{'${brace}'}`);
121
+ }
122
+ /**
123
+ * A value as a Vue template's bound attribute holds it, single-quoted:
124
+ * the value's expression with `&` and `'` as character references, which
125
+ * the template reads back as the characters, so neither ends the attribute
126
+ * nor starts a reference of its own.
127
+ *
128
+ * @param value - The prop's value.
129
+ * @returns The attribute's text, quotes included.
130
+ * @example
131
+ * vueBoundAttribute("Don't");
132
+ * // `'"Don&#39;t"'`
133
+ */
134
+ export function vueBoundAttribute(value) {
135
+ return `'${serialize(value).replace(/&/g, '&amp;').replace(/'/g, '&#39;')}'`;
136
+ }
137
+ export function needsColor(model) {
138
+ return model.propTypes.some((propType) => propType.include && propType.control === 'color-select');
139
+ }
140
+ function propTypeLine(specification) {
141
+ if (!specification.include)
142
+ return ` ${specification.name}: { table: { disable: true } },`;
143
+ switch (specification.control) {
144
+ case 'color-select':
145
+ return ` ${specification.name}: { control: 'select', options: colorOptions },`;
146
+ case 'select':
147
+ return ` ${specification.name}: { control: 'select', options: ${serialize(specification.options ?? [])} },`;
148
+ case 'number':
149
+ return specification.number
150
+ ? ` ${specification.name}: { control: { type: 'number', min: ${specification.number.min}, max: ${specification.number.max}, step: ${specification.number.step} } },`
151
+ : ` ${specification.name}: { control: 'number' },`;
152
+ case 'boolean':
153
+ return ` ${specification.name}: { control: 'boolean' },`;
154
+ case 'text':
155
+ return ` ${specification.name}: { control: 'text' },`;
156
+ }
157
+ }
158
+ export function propTypesBody(model) {
159
+ return model.propTypes.map(propTypeLine).join('\n');
160
+ }
161
+ export function effectiveDefaultSlot(model) {
162
+ if (model.slots?.default)
163
+ return model.slots.default;
164
+ if (model.defaultProps.children !== undefined)
165
+ return { kind: 'propText', prop: 'children' };
166
+ return undefined;
167
+ }
168
+ export function namedSlots(model) {
169
+ return model.slots?.named ?? {};
170
+ }
@@ -0,0 +1,46 @@
1
+ import type { KitStyling } from '../context.js';
2
+ import type { EnumeratedComponent, HandWrittenMapping, JsonValue, SlotFill, StoryAround } from '../lib/types.js';
3
+ /** What the html printer needs beside the story itself. */
4
+ export interface HtmlStory {
5
+ /** The component the story renders. */
6
+ component: EnumeratedComponent;
7
+ props: Record<string, JsonValue>;
8
+ children?: SlotFill;
9
+ named: Record<string, SlotFill>;
10
+ /** The content beside the component, rendered as its siblings. */
11
+ around?: StoryAround;
12
+ /** Every component of the kit, for the references a template or fill makes. */
13
+ components: readonly EnumeratedComponent[];
14
+ styling: KitStyling;
15
+ /** Values every expression can read: the kit's shared helpers. */
16
+ scope: Record<string, unknown>;
17
+ /** What each hand-written component renders as: `'content'`, or a template. */
18
+ handWrittenComponents: Readonly<Record<string, HandWrittenMapping>>;
19
+ }
20
+ /** The story's markup, or what keeps it from having one. */
21
+ export type HtmlSourceResult = {
22
+ markup: string;
23
+ /** The kit components the markup renders, by name: the story's own
24
+ * first, then each it composes or its slot content holds. */
25
+ components: string[];
26
+ /** What the render could not work out at rest - an expression reading
27
+ * a name only the component's script defines, such as its state - so
28
+ * the markup leaves it out and shows that part at a default. */
29
+ warnings: string[];
30
+ } | {
31
+ markup?: undefined;
32
+ missing: string[];
33
+ };
34
+ /**
35
+ * Renders a story to markup. A component written by hand renders as the kit
36
+ * maps it - the content passed into it, at rest, or the template it names -
37
+ * inside one comment saying its behavior is not included; a slot fill
38
+ * written per framework (`raw`, `scoped`) renders its `html`. A part renders
39
+ * as a component whose template is its `html`, calling itself as deep as
40
+ * the data it is given goes. A component without a template that the kit
41
+ * does not map, or such a fill or part without `html`, leaves the story
42
+ * with no markup, and the result names them. What the render cannot work
43
+ * out at rest, such as an expression reading the component's script state,
44
+ * is left out of the markup and named in the result's warnings.
45
+ */
46
+ export declare function htmlSource(story: HtmlStory): HtmlSourceResult;