forgebook 0.0.0-stage → 0.1.2

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 (493) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +136 -2
  3. package/dist/bin/forgebook/catalogueVite.d.ts +16 -0
  4. package/dist/bin/forgebook/catalogueVite.d.ts.map +1 -0
  5. package/dist/bin/forgebook/catalogueVite.js +15 -0
  6. package/dist/bin/forgebook/catalogueVite.js.map +1 -0
  7. package/dist/bin/forgebook/forgebook.d.mts +3 -0
  8. package/dist/bin/forgebook/forgebook.d.mts.map +1 -0
  9. package/dist/bin/forgebook/forgebook.mjs +93 -0
  10. package/dist/bin/forgebook/forgebook.mjs.map +1 -0
  11. package/dist/bin/forgebook-docs/catalogueDocs.types.d.ts +90 -0
  12. package/dist/bin/forgebook-docs/catalogueDocs.types.d.ts.map +1 -0
  13. package/dist/bin/forgebook-docs/catalogueDocs.types.js +1 -0
  14. package/dist/bin/forgebook-docs/catalogueDocs.types.js.map +1 -0
  15. package/dist/bin/forgebook-docs/catalogueMarkdown.d.ts +9 -0
  16. package/dist/bin/forgebook-docs/catalogueMarkdown.d.ts.map +1 -0
  17. package/dist/bin/forgebook-docs/catalogueMarkdown.js +132 -0
  18. package/dist/bin/forgebook-docs/catalogueMarkdown.js.map +1 -0
  19. package/dist/bin/forgebook-docs/collectDocs.d.ts +17 -0
  20. package/dist/bin/forgebook-docs/collectDocs.d.ts.map +1 -0
  21. package/dist/bin/forgebook-docs/collectDocs.js +115 -0
  22. package/dist/bin/forgebook-docs/collectDocs.js.map +1 -0
  23. package/dist/bin/forgebook-docs/forgebook-docs.d.mts +3 -0
  24. package/dist/bin/forgebook-docs/forgebook-docs.d.mts.map +1 -0
  25. package/dist/bin/forgebook-docs/forgebook-docs.mjs +114 -0
  26. package/dist/bin/forgebook-docs/forgebook-docs.mjs.map +1 -0
  27. package/dist/bin/forgebook-docs/moduleDocs.d.ts +9 -0
  28. package/dist/bin/forgebook-docs/moduleDocs.d.ts.map +1 -0
  29. package/dist/bin/forgebook-docs/moduleDocs.js +62 -0
  30. package/dist/bin/forgebook-docs/moduleDocs.js.map +1 -0
  31. package/dist/bin/forgebook-docs/sassDocs.d.ts +20 -0
  32. package/dist/bin/forgebook-docs/sassDocs.d.ts.map +1 -0
  33. package/dist/bin/forgebook-docs/sassDocs.js +77 -0
  34. package/dist/bin/forgebook-docs/sassDocs.js.map +1 -0
  35. package/dist/bin/forgebook-texts/forgebook-texts.d.mts +3 -0
  36. package/dist/bin/forgebook-texts/forgebook-texts.d.mts.map +1 -0
  37. package/dist/bin/forgebook-texts/forgebook-texts.mjs +94 -0
  38. package/dist/bin/forgebook-texts/forgebook-texts.mjs.map +1 -0
  39. package/dist/bin/forgebook-texts/storyTextsReport.d.ts +26 -0
  40. package/dist/bin/forgebook-texts/storyTextsReport.d.ts.map +1 -0
  41. package/dist/bin/forgebook-texts/storyTextsReport.js +35 -0
  42. package/dist/bin/forgebook-texts/storyTextsReport.js.map +1 -0
  43. package/dist/bin/forgebook-texts/storyTextsReport.types.d.ts +25 -0
  44. package/dist/bin/forgebook-texts/storyTextsReport.types.d.ts.map +1 -0
  45. package/dist/bin/forgebook-texts/storyTextsReport.types.js +7 -0
  46. package/dist/bin/forgebook-texts/storyTextsReport.types.js.map +1 -0
  47. package/dist/src/a11y.d.ts +28 -0
  48. package/dist/src/a11y.d.ts.map +1 -0
  49. package/dist/src/a11y.js +29 -0
  50. package/dist/src/a11y.js.map +1 -0
  51. package/dist/src/argTypes.d.ts +114 -0
  52. package/dist/src/argTypes.d.ts.map +1 -0
  53. package/dist/src/argTypes.js +254 -0
  54. package/dist/src/argTypes.js.map +1 -0
  55. package/dist/src/backdrops.d.ts +88 -0
  56. package/dist/src/backdrops.d.ts.map +1 -0
  57. package/dist/src/backdrops.js +202 -0
  58. package/dist/src/backdrops.js.map +1 -0
  59. package/dist/src/catalogue.d.ts +120 -0
  60. package/dist/src/catalogue.d.ts.map +1 -0
  61. package/dist/src/catalogue.js +80 -0
  62. package/dist/src/catalogue.js.map +1 -0
  63. package/dist/src/componentDocs.d.ts +98 -0
  64. package/dist/src/componentDocs.d.ts.map +1 -0
  65. package/dist/src/componentDocs.js +47 -0
  66. package/dist/src/componentDocs.js.map +1 -0
  67. package/dist/src/frame/checkStory.d.ts +20 -0
  68. package/dist/src/frame/checkStory.d.ts.map +1 -0
  69. package/dist/src/frame/checkStory.js +31 -0
  70. package/dist/src/frame/checkStory.js.map +1 -0
  71. package/dist/src/frame/frame.css +51 -0
  72. package/dist/src/frame/frameClock.d.ts +53 -0
  73. package/dist/src/frame/frameClock.d.ts.map +1 -0
  74. package/dist/src/frame/frameClock.js +80 -0
  75. package/dist/src/frame/frameClock.js.map +1 -0
  76. package/dist/src/frame/frameStatus.d.ts +8 -0
  77. package/dist/src/frame/frameStatus.d.ts.map +1 -0
  78. package/dist/src/frame/frameStatus.js +8 -0
  79. package/dist/src/frame/frameStatus.js.map +1 -0
  80. package/dist/src/frame/frameView.d.ts +33 -0
  81. package/dist/src/frame/frameView.d.ts.map +1 -0
  82. package/dist/src/frame/frameView.js +134 -0
  83. package/dist/src/frame/frameView.js.map +1 -0
  84. package/dist/src/frame/matrixLayout.d.ts +36 -0
  85. package/dist/src/frame/matrixLayout.d.ts.map +1 -0
  86. package/dist/src/frame/matrixLayout.js +87 -0
  87. package/dist/src/frame/matrixLayout.js.map +1 -0
  88. package/dist/src/frame/measureTools.d.ts +24 -0
  89. package/dist/src/frame/measureTools.d.ts.map +1 -0
  90. package/dist/src/frame/measureTools.js +141 -0
  91. package/dist/src/frame/measureTools.js.map +1 -0
  92. package/dist/src/frame/mountFrame.d.ts +47 -0
  93. package/dist/src/frame/mountFrame.d.ts.map +1 -0
  94. package/dist/src/frame/mountFrame.js +229 -0
  95. package/dist/src/frame/mountFrame.js.map +1 -0
  96. package/dist/src/frame/playStory.d.ts +40 -0
  97. package/dist/src/frame/playStory.d.ts.map +1 -0
  98. package/dist/src/frame/playStory.js +55 -0
  99. package/dist/src/frame/playStory.js.map +1 -0
  100. package/dist/src/frame/renderer.d.ts +85 -0
  101. package/dist/src/frame/renderer.d.ts.map +1 -0
  102. package/dist/src/frame/renderer.js +18 -0
  103. package/dist/src/frame/renderer.js.map +1 -0
  104. package/dist/src/frame/settle.d.ts +24 -0
  105. package/dist/src/frame/settle.d.ts.map +1 -0
  106. package/dist/src/frame/settle.js +25 -0
  107. package/dist/src/frame/settle.js.map +1 -0
  108. package/dist/src/frame/staleModule.d.ts +40 -0
  109. package/dist/src/frame/staleModule.d.ts.map +1 -0
  110. package/dist/src/frame/staleModule.js +74 -0
  111. package/dist/src/frame/staleModule.js.map +1 -0
  112. package/dist/src/frame/storyCanvas.d.ts +21 -0
  113. package/dist/src/frame/storyCanvas.d.ts.map +1 -0
  114. package/dist/src/frame/storyCanvas.js +30 -0
  115. package/dist/src/frame/storyCanvas.js.map +1 -0
  116. package/dist/src/frame/storyHooks.d.ts +31 -0
  117. package/dist/src/frame/storyHooks.d.ts.map +1 -0
  118. package/dist/src/frame/storyHooks.js +59 -0
  119. package/dist/src/frame/storyHooks.js.map +1 -0
  120. package/dist/src/frame/storyModule.d.ts +104 -0
  121. package/dist/src/frame/storyModule.d.ts.map +1 -0
  122. package/dist/src/frame/storyModule.js +205 -0
  123. package/dist/src/frame/storyModule.js.map +1 -0
  124. package/dist/src/frame/storyRun.d.ts +96 -0
  125. package/dist/src/frame/storyRun.d.ts.map +1 -0
  126. package/dist/src/frame/storyRun.js +318 -0
  127. package/dist/src/frame/storyRun.js.map +1 -0
  128. package/dist/src/languages.d.ts +15 -0
  129. package/dist/src/languages.d.ts.map +1 -0
  130. package/dist/src/languages.js +8 -0
  131. package/dist/src/languages.js.map +1 -0
  132. package/dist/src/matrix.d.ts +56 -0
  133. package/dist/src/matrix.d.ts.map +1 -0
  134. package/dist/src/matrix.js +61 -0
  135. package/dist/src/matrix.js.map +1 -0
  136. package/dist/src/messages.d.ts +203 -0
  137. package/dist/src/messages.d.ts.map +1 -0
  138. package/dist/src/messages.js +193 -0
  139. package/dist/src/messages.js.map +1 -0
  140. package/dist/src/namedValues.d.ts +38 -0
  141. package/dist/src/namedValues.d.ts.map +1 -0
  142. package/dist/src/namedValues.js +48 -0
  143. package/dist/src/namedValues.js.map +1 -0
  144. package/dist/src/pageConfig.d.ts +23 -0
  145. package/dist/src/pageConfig.d.ts.map +1 -0
  146. package/dist/src/pageConfig.js +1 -0
  147. package/dist/src/pageConfig.js.map +1 -0
  148. package/dist/src/playTrace.d.ts +41 -0
  149. package/dist/src/playTrace.d.ts.map +1 -0
  150. package/dist/src/playTrace.js +35 -0
  151. package/dist/src/playTrace.js.map +1 -0
  152. package/dist/src/shell/A11yTab.d.ts +44 -0
  153. package/dist/src/shell/A11yTab.d.ts.map +1 -0
  154. package/dist/src/shell/A11yTab.js +30 -0
  155. package/dist/src/shell/A11yTab.js.map +1 -0
  156. package/dist/src/shell/ApiReference.d.ts +18 -0
  157. package/dist/src/shell/ApiReference.d.ts.map +1 -0
  158. package/dist/src/shell/ApiReference.js +41 -0
  159. package/dist/src/shell/ApiReference.js.map +1 -0
  160. package/dist/src/shell/ClockControls.d.ts +43 -0
  161. package/dist/src/shell/ClockControls.d.ts.map +1 -0
  162. package/dist/src/shell/ClockControls.js +53 -0
  163. package/dist/src/shell/ClockControls.js.map +1 -0
  164. package/dist/src/shell/Code.d.ts +16 -0
  165. package/dist/src/shell/Code.d.ts.map +1 -0
  166. package/dist/src/shell/Code.js +9 -0
  167. package/dist/src/shell/Code.js.map +1 -0
  168. package/dist/src/shell/CodeTab.d.ts +17 -0
  169. package/dist/src/shell/CodeTab.d.ts.map +1 -0
  170. package/dist/src/shell/CodeTab.js +17 -0
  171. package/dist/src/shell/CodeTab.js.map +1 -0
  172. package/dist/src/shell/CodeText.d.ts +16 -0
  173. package/dist/src/shell/CodeText.d.ts.map +1 -0
  174. package/dist/src/shell/CodeText.js +10 -0
  175. package/dist/src/shell/CodeText.js.map +1 -0
  176. package/dist/src/shell/ComponentPage.d.ts +38 -0
  177. package/dist/src/shell/ComponentPage.d.ts.map +1 -0
  178. package/dist/src/shell/ComponentPage.js +146 -0
  179. package/dist/src/shell/ComponentPage.js.map +1 -0
  180. package/dist/src/shell/Dock.d.ts +42 -0
  181. package/dist/src/shell/Dock.d.ts.map +1 -0
  182. package/dist/src/shell/Dock.js +90 -0
  183. package/dist/src/shell/Dock.js.map +1 -0
  184. package/dist/src/shell/EventsTab.d.ts +25 -0
  185. package/dist/src/shell/EventsTab.d.ts.map +1 -0
  186. package/dist/src/shell/EventsTab.js +26 -0
  187. package/dist/src/shell/EventsTab.js.map +1 -0
  188. package/dist/src/shell/FrameView.d.ts +49 -0
  189. package/dist/src/shell/FrameView.d.ts.map +1 -0
  190. package/dist/src/shell/FrameView.js +29 -0
  191. package/dist/src/shell/FrameView.js.map +1 -0
  192. package/dist/src/shell/HomePage.d.ts +39 -0
  193. package/dist/src/shell/HomePage.d.ts.map +1 -0
  194. package/dist/src/shell/HomePage.js +85 -0
  195. package/dist/src/shell/HomePage.js.map +1 -0
  196. package/dist/src/shell/InteractionsTab.d.ts +28 -0
  197. package/dist/src/shell/InteractionsTab.d.ts.map +1 -0
  198. package/dist/src/shell/InteractionsTab.js +17 -0
  199. package/dist/src/shell/InteractionsTab.js.map +1 -0
  200. package/dist/src/shell/MatrixPicker.d.ts +24 -0
  201. package/dist/src/shell/MatrixPicker.d.ts.map +1 -0
  202. package/dist/src/shell/MatrixPicker.js +29 -0
  203. package/dist/src/shell/MatrixPicker.js.map +1 -0
  204. package/dist/src/shell/PackageHtml.d.ts +17 -0
  205. package/dist/src/shell/PackageHtml.d.ts.map +1 -0
  206. package/dist/src/shell/PackageHtml.js +13 -0
  207. package/dist/src/shell/PackageHtml.js.map +1 -0
  208. package/dist/src/shell/PartsTab.d.ts +23 -0
  209. package/dist/src/shell/PartsTab.d.ts.map +1 -0
  210. package/dist/src/shell/PartsTab.js +23 -0
  211. package/dist/src/shell/PartsTab.js.map +1 -0
  212. package/dist/src/shell/PropFields.d.ts +31 -0
  213. package/dist/src/shell/PropFields.d.ts.map +1 -0
  214. package/dist/src/shell/PropFields.js +81 -0
  215. package/dist/src/shell/PropFields.js.map +1 -0
  216. package/dist/src/shell/PropsTab.d.ts +45 -0
  217. package/dist/src/shell/PropsTab.d.ts.map +1 -0
  218. package/dist/src/shell/PropsTab.js +81 -0
  219. package/dist/src/shell/PropsTab.js.map +1 -0
  220. package/dist/src/shell/SchemeSwitches.d.ts +24 -0
  221. package/dist/src/shell/SchemeSwitches.d.ts.map +1 -0
  222. package/dist/src/shell/SchemeSwitches.js +36 -0
  223. package/dist/src/shell/SchemeSwitches.js.map +1 -0
  224. package/dist/src/shell/Segmented.d.ts +41 -0
  225. package/dist/src/shell/Segmented.d.ts.map +1 -0
  226. package/dist/src/shell/Segmented.js +19 -0
  227. package/dist/src/shell/Segmented.js.map +1 -0
  228. package/dist/src/shell/Shell.d.ts +49 -0
  229. package/dist/src/shell/Shell.d.ts.map +1 -0
  230. package/dist/src/shell/Shell.js +279 -0
  231. package/dist/src/shell/Shell.js.map +1 -0
  232. package/dist/src/shell/Sidebar.d.ts +52 -0
  233. package/dist/src/shell/Sidebar.d.ts.map +1 -0
  234. package/dist/src/shell/Sidebar.js +132 -0
  235. package/dist/src/shell/Sidebar.js.map +1 -0
  236. package/dist/src/shell/SidebarHandle.d.ts +29 -0
  237. package/dist/src/shell/SidebarHandle.d.ts.map +1 -0
  238. package/dist/src/shell/SidebarHandle.js +46 -0
  239. package/dist/src/shell/SidebarHandle.js.map +1 -0
  240. package/dist/src/shell/Stage.d.ts +68 -0
  241. package/dist/src/shell/Stage.d.ts.map +1 -0
  242. package/dist/src/shell/Stage.js +218 -0
  243. package/dist/src/shell/Stage.js.map +1 -0
  244. package/dist/src/shell/StageTools.d.ts +27 -0
  245. package/dist/src/shell/StageTools.d.ts.map +1 -0
  246. package/dist/src/shell/StageTools.js +34 -0
  247. package/dist/src/shell/StageTools.js.map +1 -0
  248. package/dist/src/shell/StageViewport.d.ts +46 -0
  249. package/dist/src/shell/StageViewport.d.ts.map +1 -0
  250. package/dist/src/shell/StageViewport.js +173 -0
  251. package/dist/src/shell/StageViewport.js.map +1 -0
  252. package/dist/src/shell/StoryCodeBlock.d.ts +35 -0
  253. package/dist/src/shell/StoryCodeBlock.d.ts.map +1 -0
  254. package/dist/src/shell/StoryCodeBlock.js +27 -0
  255. package/dist/src/shell/StoryCodeBlock.js.map +1 -0
  256. package/dist/src/shell/StoryPicker.d.ts +26 -0
  257. package/dist/src/shell/StoryPicker.d.ts.map +1 -0
  258. package/dist/src/shell/StoryPicker.js +32 -0
  259. package/dist/src/shell/StoryPicker.js.map +1 -0
  260. package/dist/src/shell/Toolbar.d.ts +40 -0
  261. package/dist/src/shell/Toolbar.d.ts.map +1 -0
  262. package/dist/src/shell/Toolbar.js +125 -0
  263. package/dist/src/shell/Toolbar.js.map +1 -0
  264. package/dist/src/shell/WidthField.d.ts +24 -0
  265. package/dist/src/shell/WidthField.d.ts.map +1 -0
  266. package/dist/src/shell/WidthField.js +40 -0
  267. package/dist/src/shell/WidthField.js.map +1 -0
  268. package/dist/src/shell/catalogueContext.d.ts +6 -0
  269. package/dist/src/shell/catalogueContext.d.ts.map +1 -0
  270. package/dist/src/shell/catalogueContext.js +14 -0
  271. package/dist/src/shell/catalogueContext.js.map +1 -0
  272. package/dist/src/shell/codeTokens.d.ts +23 -0
  273. package/dist/src/shell/codeTokens.d.ts.map +1 -0
  274. package/dist/src/shell/codeTokens.js +48 -0
  275. package/dist/src/shell/codeTokens.js.map +1 -0
  276. package/dist/src/shell/codeWriter.d.ts +6 -0
  277. package/dist/src/shell/codeWriter.d.ts.map +1 -0
  278. package/dist/src/shell/codeWriter.js +14 -0
  279. package/dist/src/shell/codeWriter.js.map +1 -0
  280. package/dist/src/shell/compareVariants.d.ts +35 -0
  281. package/dist/src/shell/compareVariants.d.ts.map +1 -0
  282. package/dist/src/shell/compareVariants.js +68 -0
  283. package/dist/src/shell/compareVariants.js.map +1 -0
  284. package/dist/src/shell/dockTabs.d.ts +63 -0
  285. package/dist/src/shell/dockTabs.d.ts.map +1 -0
  286. package/dist/src/shell/dockTabs.js +140 -0
  287. package/dist/src/shell/dockTabs.js.map +1 -0
  288. package/dist/src/shell/icons.d.ts +47 -0
  289. package/dist/src/shell/icons.d.ts.map +1 -0
  290. package/dist/src/shell/icons.js +36 -0
  291. package/dist/src/shell/icons.js.map +1 -0
  292. package/dist/src/shell/keyboard.d.ts +35 -0
  293. package/dist/src/shell/keyboard.d.ts.map +1 -0
  294. package/dist/src/shell/keyboard.js +51 -0
  295. package/dist/src/shell/keyboard.js.map +1 -0
  296. package/dist/src/shell/mountShell.d.ts +22 -0
  297. package/dist/src/shell/mountShell.d.ts.map +1 -0
  298. package/dist/src/shell/mountShell.js +39 -0
  299. package/dist/src/shell/mountShell.js.map +1 -0
  300. package/dist/src/shell/shell.css +1831 -0
  301. package/dist/src/shell/strings.d.ts +184 -0
  302. package/dist/src/shell/strings.d.ts.map +1 -0
  303. package/dist/src/shell/strings.js +188 -0
  304. package/dist/src/shell/strings.js.map +1 -0
  305. package/dist/src/shell/switchView.d.ts +23 -0
  306. package/dist/src/shell/switchView.d.ts.map +1 -0
  307. package/dist/src/shell/switchView.js +19 -0
  308. package/dist/src/shell/switchView.js.map +1 -0
  309. package/dist/src/shell/treeSearch.d.ts +35 -0
  310. package/dist/src/shell/treeSearch.d.ts.map +1 -0
  311. package/dist/src/shell/treeSearch.js +60 -0
  312. package/dist/src/shell/treeSearch.js.map +1 -0
  313. package/dist/src/shell/useComponentDocs.d.ts +16 -0
  314. package/dist/src/shell/useComponentDocs.d.ts.map +1 -0
  315. package/dist/src/shell/useComponentDocs.js +25 -0
  316. package/dist/src/shell/useComponentDocs.js.map +1 -0
  317. package/dist/src/shell/useCopy.d.ts +10 -0
  318. package/dist/src/shell/useCopy.d.ts.map +1 -0
  319. package/dist/src/shell/useCopy.js +23 -0
  320. package/dist/src/shell/useCopy.js.map +1 -0
  321. package/dist/src/shell/useFrameMessages.d.ts +54 -0
  322. package/dist/src/shell/useFrameMessages.d.ts.map +1 -0
  323. package/dist/src/shell/useFrameMessages.js +90 -0
  324. package/dist/src/shell/useFrameMessages.js.map +1 -0
  325. package/dist/src/shell/useFrameQueue.d.ts +29 -0
  326. package/dist/src/shell/useFrameQueue.d.ts.map +1 -0
  327. package/dist/src/shell/useFrameQueue.js +72 -0
  328. package/dist/src/shell/useFrameQueue.js.map +1 -0
  329. package/dist/src/shell/useLiveView.d.ts +29 -0
  330. package/dist/src/shell/useLiveView.d.ts.map +1 -0
  331. package/dist/src/shell/useLiveView.js +51 -0
  332. package/dist/src/shell/useLiveView.js.map +1 -0
  333. package/dist/src/shell/useLoaded.d.ts +20 -0
  334. package/dist/src/shell/useLoaded.d.ts.map +1 -0
  335. package/dist/src/shell/useLoaded.js +40 -0
  336. package/dist/src/shell/useLoaded.js.map +1 -0
  337. package/dist/src/shell/usePageDoc.d.ts +20 -0
  338. package/dist/src/shell/usePageDoc.d.ts.map +1 -0
  339. package/dist/src/shell/usePageDoc.js +21 -0
  340. package/dist/src/shell/usePageDoc.js.map +1 -0
  341. package/dist/src/shell/usePopover.d.ts +23 -0
  342. package/dist/src/shell/usePopover.d.ts.map +1 -0
  343. package/dist/src/shell/usePopover.js +39 -0
  344. package/dist/src/shell/usePopover.js.map +1 -0
  345. package/dist/src/shell/useRecentPages.d.ts +21 -0
  346. package/dist/src/shell/useRecentPages.d.ts.map +1 -0
  347. package/dist/src/shell/useRecentPages.js +62 -0
  348. package/dist/src/shell/useRecentPages.js.map +1 -0
  349. package/dist/src/shell/useScrollMemory.d.ts +40 -0
  350. package/dist/src/shell/useScrollMemory.d.ts.map +1 -0
  351. package/dist/src/shell/useScrollMemory.js +69 -0
  352. package/dist/src/shell/useScrollMemory.js.map +1 -0
  353. package/dist/src/shell/useSidebarLayout.d.ts +14 -0
  354. package/dist/src/shell/useSidebarLayout.d.ts.map +1 -0
  355. package/dist/src/shell/useSidebarLayout.js +19 -0
  356. package/dist/src/shell/useSidebarLayout.js.map +1 -0
  357. package/dist/src/shell/useStored.d.ts +11 -0
  358. package/dist/src/shell/useStored.d.ts.map +1 -0
  359. package/dist/src/shell/useStored.js +68 -0
  360. package/dist/src/shell/useStored.js.map +1 -0
  361. package/dist/src/shell/useStoryCode.d.ts +14 -0
  362. package/dist/src/shell/useStoryCode.d.ts.map +1 -0
  363. package/dist/src/shell/useStoryCode.js +29 -0
  364. package/dist/src/shell/useStoryCode.js.map +1 -0
  365. package/dist/src/shell/useStoryHeights.d.ts +9 -0
  366. package/dist/src/shell/useStoryHeights.d.ts.map +1 -0
  367. package/dist/src/shell/useStoryHeights.js +31 -0
  368. package/dist/src/shell/useStoryHeights.js.map +1 -0
  369. package/dist/src/shell/useStoryIdsElement.d.ts +7 -0
  370. package/dist/src/shell/useStoryIdsElement.d.ts.map +1 -0
  371. package/dist/src/shell/useStoryIdsElement.js +29 -0
  372. package/dist/src/shell/useStoryIdsElement.js.map +1 -0
  373. package/dist/src/shell/useStoryKeys.d.ts +11 -0
  374. package/dist/src/shell/useStoryKeys.d.ts.map +1 -0
  375. package/dist/src/shell/useStoryKeys.js +40 -0
  376. package/dist/src/shell/useStoryKeys.js.map +1 -0
  377. package/dist/src/shell/useSystemDark.d.ts +3 -0
  378. package/dist/src/shell/useSystemDark.d.ts.map +1 -0
  379. package/dist/src/shell/useSystemDark.js +19 -0
  380. package/dist/src/shell/useSystemDark.js.map +1 -0
  381. package/dist/src/sourceFiles.d.ts +18 -0
  382. package/dist/src/sourceFiles.d.ts.map +1 -0
  383. package/dist/src/sourceFiles.js +22 -0
  384. package/dist/src/sourceFiles.js.map +1 -0
  385. package/dist/src/storyBackground.d.ts +21 -0
  386. package/dist/src/storyBackground.d.ts.map +1 -0
  387. package/dist/src/storyBackground.js +27 -0
  388. package/dist/src/storyBackground.js.map +1 -0
  389. package/dist/src/storyClock.d.ts +62 -0
  390. package/dist/src/storyClock.d.ts.map +1 -0
  391. package/dist/src/storyClock.js +51 -0
  392. package/dist/src/storyClock.js.map +1 -0
  393. package/dist/src/storyGlobals.d.ts +60 -0
  394. package/dist/src/storyGlobals.d.ts.map +1 -0
  395. package/dist/src/storyGlobals.js +117 -0
  396. package/dist/src/storyGlobals.js.map +1 -0
  397. package/dist/src/storyHeights.d.ts +37 -0
  398. package/dist/src/storyHeights.d.ts.map +1 -0
  399. package/dist/src/storyHeights.js +53 -0
  400. package/dist/src/storyHeights.js.map +1 -0
  401. package/dist/src/storyIdsElement.d.ts +9 -0
  402. package/dist/src/storyIdsElement.d.ts.map +1 -0
  403. package/dist/src/storyIdsElement.js +9 -0
  404. package/dist/src/storyIdsElement.js.map +1 -0
  405. package/dist/src/storyTexts.d.ts +43 -0
  406. package/dist/src/storyTexts.d.ts.map +1 -0
  407. package/dist/src/storyTexts.js +71 -0
  408. package/dist/src/storyTexts.js.map +1 -0
  409. package/dist/src/storyTree.d.ts +215 -0
  410. package/dist/src/storyTree.d.ts.map +1 -0
  411. package/dist/src/storyTree.js +308 -0
  412. package/dist/src/storyTree.js.map +1 -0
  413. package/dist/src/switches.d.ts +156 -0
  414. package/dist/src/switches.d.ts.map +1 -0
  415. package/dist/src/switches.js +193 -0
  416. package/dist/src/switches.js.map +1 -0
  417. package/dist/src/viewState.d.ts +194 -0
  418. package/dist/src/viewState.d.ts.map +1 -0
  419. package/dist/src/viewState.js +303 -0
  420. package/dist/src/viewState.js.map +1 -0
  421. package/dist/src/vite/adapter.d.ts +70 -0
  422. package/dist/src/vite/adapter.d.ts.map +1 -0
  423. package/dist/src/vite/adapter.js +22 -0
  424. package/dist/src/vite/adapter.js.map +1 -0
  425. package/dist/src/vite/autoTitle.d.ts +28 -0
  426. package/dist/src/vite/autoTitle.d.ts.map +1 -0
  427. package/dist/src/vite/autoTitle.js +44 -0
  428. package/dist/src/vite/autoTitle.js.map +1 -0
  429. package/dist/src/vite/componentPage.d.ts +34 -0
  430. package/dist/src/vite/componentPage.d.ts.map +1 -0
  431. package/dist/src/vite/componentPage.js +94 -0
  432. package/dist/src/vite/componentPage.js.map +1 -0
  433. package/dist/src/vite/config.d.ts +72 -0
  434. package/dist/src/vite/config.d.ts.map +1 -0
  435. package/dist/src/vite/config.js +25 -0
  436. package/dist/src/vite/config.js.map +1 -0
  437. package/dist/src/vite/configFile.d.ts +76 -0
  438. package/dist/src/vite/configFile.d.ts.map +1 -0
  439. package/dist/src/vite/configFile.js +190 -0
  440. package/dist/src/vite/configFile.js.map +1 -0
  441. package/dist/src/vite/docsExtractor.d.ts +46 -0
  442. package/dist/src/vite/docsExtractor.d.ts.map +1 -0
  443. package/dist/src/vite/docsExtractor.js +88 -0
  444. package/dist/src/vite/docsExtractor.js.map +1 -0
  445. package/dist/src/vite/docsProgram.d.ts +42 -0
  446. package/dist/src/vite/docsProgram.d.ts.map +1 -0
  447. package/dist/src/vite/docsProgram.js +144 -0
  448. package/dist/src/vite/docsProgram.js.map +1 -0
  449. package/dist/src/vite/docsWorker.d.ts +2 -0
  450. package/dist/src/vite/docsWorker.d.ts.map +1 -0
  451. package/dist/src/vite/docsWorker.js +68 -0
  452. package/dist/src/vite/docsWorker.js.map +1 -0
  453. package/dist/src/vite/forcedStates.d.ts +27 -0
  454. package/dist/src/vite/forcedStates.d.ts.map +1 -0
  455. package/dist/src/vite/forcedStates.js +60 -0
  456. package/dist/src/vite/forcedStates.js.map +1 -0
  457. package/dist/src/vite/forgebookPlugin.d.ts +28 -0
  458. package/dist/src/vite/forgebookPlugin.d.ts.map +1 -0
  459. package/dist/src/vite/forgebookPlugin.js +375 -0
  460. package/dist/src/vite/forgebookPlugin.js.map +1 -0
  461. package/dist/src/vite/highlightCode.d.ts +16 -0
  462. package/dist/src/vite/highlightCode.d.ts.map +1 -0
  463. package/dist/src/vite/highlightCode.js +82 -0
  464. package/dist/src/vite/highlightCode.js.map +1 -0
  465. package/dist/src/vite/indexStoryFile.d.ts +35 -0
  466. package/dist/src/vite/indexStoryFile.d.ts.map +1 -0
  467. package/dist/src/vite/indexStoryFile.js +458 -0
  468. package/dist/src/vite/indexStoryFile.js.map +1 -0
  469. package/dist/src/vite/pages.d.ts +49 -0
  470. package/dist/src/vite/pages.d.ts.map +1 -0
  471. package/dist/src/vite/pages.js +171 -0
  472. package/dist/src/vite/pages.js.map +1 -0
  473. package/dist/src/vite/prebundled.d.ts +30 -0
  474. package/dist/src/vite/prebundled.d.ts.map +1 -0
  475. package/dist/src/vite/prebundled.js +81 -0
  476. package/dist/src/vite/prebundled.js.map +1 -0
  477. package/dist/src/vite/storyCode.d.ts +28 -0
  478. package/dist/src/vite/storyCode.d.ts.map +1 -0
  479. package/dist/src/vite/storyCode.js +80 -0
  480. package/dist/src/vite/storyCode.js.map +1 -0
  481. package/dist/src/vite/storyFilesModule.d.ts +17 -0
  482. package/dist/src/vite/storyFilesModule.d.ts.map +1 -0
  483. package/dist/src/vite/storyFilesModule.js +64 -0
  484. package/dist/src/vite/storyFilesModule.js.map +1 -0
  485. package/dist/src/vite/storyMeta.d.ts +34 -0
  486. package/dist/src/vite/storyMeta.d.ts.map +1 -0
  487. package/dist/src/vite/storyMeta.js +74 -0
  488. package/dist/src/vite/storyMeta.js.map +1 -0
  489. package/dist/src/vite/typeScriptPieces.d.ts +23 -0
  490. package/dist/src/vite/typeScriptPieces.d.ts.map +1 -0
  491. package/dist/src/vite/typeScriptPieces.js +236 -0
  492. package/dist/src/vite/typeScriptPieces.js.map +1 -0
  493. package/package.json +202 -3
@@ -0,0 +1,72 @@
1
+ /**
2
+ * A catalogue's configuration, as `forgebook.config.ts` writes it (`export default defineConfig({ … })`), and a
3
+ * library's preset, as its package ships it (`definePreset`).
4
+ *
5
+ * @remarks
6
+ * The configuration is read on Node, by the Vite plugin and the `forgebook` command: data only, plus the framework's
7
+ * adapter. What runs in the frames (decorators, providers, a setup) is the preview's (`forgebook.preview.ts`), named
8
+ * here by its path. A preset is the same data a library gives every catalogue that shows it (its switches, its
9
+ * languages, its preview); the catalogue's own configuration wins over its presets' (O2).
10
+ *
11
+ * @module
12
+ */
13
+ import type { StoryLanguage } from "@forgebook/story-format/source";
14
+ import type { CatalogueLists } from "../catalogue.ts";
15
+ import type { ViewSwitch } from "../switches.ts";
16
+ import type { FrameworkAdapter } from "./adapter.ts";
17
+ /** What a library's preset gives a catalogue. */
18
+ export type ForgebookPreset = CatalogueLists & {
19
+ /** The preset's name, in a problem's message (`acme-ui`). */
20
+ readonly name: string;
21
+ /** The switches it declares, before the catalogue's. */
22
+ readonly switches?: readonly ViewSwitch[];
23
+ /** The languages its stories can be drawn in, before the catalogue's. */
24
+ readonly languages?: readonly StoryLanguage[];
25
+ /** The absolute path of its preview module (decorators, parameters, a setup), under the catalogue's. */
26
+ readonly preview?: string;
27
+ /** Tags for every frame's `<head>`, before the catalogue's. */
28
+ readonly head?: string;
29
+ };
30
+ /** A catalogue's configuration: the lists of `CatalogueLists` (widths, backgrounds, story groups…) besides these. */
31
+ export type ForgebookConfig = CatalogueLists & {
32
+ /** The framework its stories are written for (`react()` of `@forgebook/react/vite`). */
33
+ readonly framework: FrameworkAdapter;
34
+ /** Its name, in the page's title and the sidebar. */
35
+ readonly title: string;
36
+ /** Its logo: a square image, by path from the configuration's folder; Forgebook's own mark by default. */
37
+ readonly logo?: string;
38
+ /** The stories' measured heights, the file `forgebook-heights` writes, served from the public folder; none by default. */
39
+ readonly heights?: string;
40
+ /**
41
+ * The project's own story files, as globs from the configuration's folder (`["src/**\/*.stories.tsx"]`): one source
42
+ * named after the catalogue. Give `stories` or `sources`, or both.
43
+ */
44
+ readonly stories?: readonly string[];
45
+ /** The packages' story sources, as module specifiers exporting a `source` (`["@acme/ui/stories"]`). */
46
+ readonly sources?: readonly string[];
47
+ /** The switches of the toolbar and the View menu; the theme and the contrast when neither it nor a preset declares any. */
48
+ readonly switches?: readonly ViewSwitch[];
49
+ /** The languages its stories can be drawn in; none turns the Language row off. */
50
+ readonly languages?: readonly StoryLanguage[];
51
+ /** Its preview's path from the configuration's folder; `forgebook.preview.ts` (or `.tsx`) beside it when there. */
52
+ readonly preview?: string;
53
+ /** Tags for every frame's `<head>` (a font's link); none by default. */
54
+ readonly head?: string;
55
+ /** Folders outside the configuration's whose new story files the dev server watches (each source's `src`). */
56
+ readonly watch?: readonly string[];
57
+ /** The libraries' presets, in order; the configuration's own values win over theirs. */
58
+ readonly presets?: readonly ForgebookPreset[];
59
+ };
60
+ /**
61
+ * A catalogue's configuration, typed: what `forgebook.config.ts` exports by default.
62
+ *
63
+ * @param config - the configuration.
64
+ */
65
+ export declare const defineConfig: (config: ForgebookConfig) => ForgebookConfig;
66
+ /**
67
+ * A library's preset, typed: what its package's `./forgebook` export returns.
68
+ *
69
+ * @param preset - the preset.
70
+ */
71
+ export declare const definePreset: (preset: ForgebookPreset) => ForgebookPreset;
72
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/vite/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,iDAAiD;AACjD,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG;IAC7C,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IAC1C,yEAAyE;IACzE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IAC9C,wGAAwG;IACxG,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,qHAAqH;AACrH,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG;IAC7C,wFAAwF;IACxF,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,qDAAqD;IACrD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,0GAA0G;IAC1G,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,0HAA0H;IAC1H,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,uGAAuG;IACvG,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,2HAA2H;IAC3H,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IAC1C,kFAAkF;IAClF,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IAC9C,mHAAmH;IACnH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,8GAA8G;IAC9G,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,wFAAwF;IACxF,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;CAC/C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,eAAe,KAAG,eAAyB,CAAC;AAEjF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,eAAe,KAAG,eAAyB,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * A catalogue's configuration, as `forgebook.config.ts` writes it (`export default defineConfig({ … })`), and a
3
+ * library's preset, as its package ships it (`definePreset`).
4
+ *
5
+ * @remarks
6
+ * The configuration is read on Node, by the Vite plugin and the `forgebook` command: data only, plus the framework's
7
+ * adapter. What runs in the frames (decorators, providers, a setup) is the preview's (`forgebook.preview.ts`), named
8
+ * here by its path. A preset is the same data a library gives every catalogue that shows it (its switches, its
9
+ * languages, its preview); the catalogue's own configuration wins over its presets' (O2).
10
+ *
11
+ * @module
12
+ */
13
+ /**
14
+ * A catalogue's configuration, typed: what `forgebook.config.ts` exports by default.
15
+ *
16
+ * @param config - the configuration.
17
+ */
18
+ export const defineConfig = (config) => config;
19
+ /**
20
+ * A library's preset, typed: what its package's `./forgebook` export returns.
21
+ *
22
+ * @param preset - the preset.
23
+ */
24
+ export const definePreset = (preset) => preset;
25
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/vite/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAqDH;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAuB,EAAmB,EAAE,CAAC,MAAM,CAAC;AAEjF;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAuB,EAAmB,EAAE,CAAC,MAAM,CAAC"}
@@ -0,0 +1,76 @@
1
+ import type { StoryLanguage } from "@forgebook/story-format/source";
2
+ import type { CatalogueLists } from "../catalogue.ts";
3
+ import { type ViewSwitch } from "../switches.ts";
4
+ import type { FrameworkAdapter } from "./adapter.ts";
5
+ import type { ForgebookConfig } from "./config.ts";
6
+ /** The names a configuration file may have, in the order they are looked for. */
7
+ export declare const CONFIG_FILES: string[];
8
+ /** A configuration ready for the pages: its folder, its presets merged, its paths absolute. */
9
+ export type ResolvedConfig = {
10
+ /** The folder the configuration file is in: Vite's root. */
11
+ readonly dir: string;
12
+ /** The framework. */
13
+ readonly framework: FrameworkAdapter;
14
+ /** The catalogue's name. */
15
+ readonly title: string;
16
+ /** The logo's absolute path; none for Forgebook's own mark. */
17
+ readonly logo: string | undefined;
18
+ /** The heights file's address, relative to the pages. */
19
+ readonly heights: string | undefined;
20
+ /** The project's own story globs, from the configuration's folder. */
21
+ readonly stories: readonly string[];
22
+ /** The sources' module specifiers. */
23
+ readonly sources: readonly string[];
24
+ /** The switches, the presets' and the catalogue's merged; none when neither declares any. */
25
+ readonly switches: readonly ViewSwitch[] | undefined;
26
+ /** The languages, the presets' and the catalogue's merged. */
27
+ readonly languages: readonly StoryLanguage[];
28
+ /** The previews' absolute paths, the presets' first, the catalogue's last. */
29
+ readonly previews: readonly string[];
30
+ /** The tags for every frame's `<head>`. */
31
+ readonly head: string;
32
+ /** The folders the dev server watches for new story files, absolute. */
33
+ readonly watch: readonly string[];
34
+ /** The lists (widths, backgrounds, story groups…), the presets' and the catalogue's merged. */
35
+ readonly lists: CatalogueLists;
36
+ /** Whether the project installs Testing Library, whose `canvas` and `userEvent` every play then receives. */
37
+ readonly hasPlayTools: boolean;
38
+ };
39
+ /** The packages of the play tools: both installed, or the plays get neither. */
40
+ export declare const PLAY_TOOLS_PACKAGES: readonly ["@testing-library/dom", "@testing-library/user-event"];
41
+ /**
42
+ * Resolves packages as Node does from a folder: a package's (or subpath's) file, or none when it is not there.
43
+ *
44
+ * @param dir - the folder, the configuration's.
45
+ */
46
+ export declare const packageResolver: (dir: string) => (name: string) => string | undefined;
47
+ /**
48
+ * The configuration file in a folder, when there is one.
49
+ *
50
+ * @param dir - the folder.
51
+ */
52
+ export declare const findConfigFile: (dir: string) => string | undefined;
53
+ /**
54
+ * The lists of the presets and the catalogue, in that order, merged: a single value (a width range, the grid's step)
55
+ * the last that gives one; the backgrounds, the story groups and the texts entry by entry, a later one replacing an
56
+ * earlier one with the same id or name; the tabs turned off and the rules turned off by any.
57
+ *
58
+ * @param all - the presets' lists, then the catalogue's.
59
+ */
60
+ export declare const mergedLists: (all: readonly CatalogueLists[]) => CatalogueLists;
61
+ /**
62
+ * A configuration with its presets merged and its paths made absolute.
63
+ *
64
+ * @param config - the configuration.
65
+ * @param dir - the folder of its file.
66
+ * @throws when the merged switches cannot be used.
67
+ */
68
+ export declare const resolveConfig: (config: ForgebookConfig, dir: string) => ResolvedConfig;
69
+ /**
70
+ * Loads a configuration file and resolves it.
71
+ *
72
+ * @param file - the file's absolute path.
73
+ * @throws when the file does not load, or exports no usable configuration.
74
+ */
75
+ export declare const loadConfigFile: (file: string) => Promise<ResolvedConfig>;
76
+ //# sourceMappingURL=configFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configFile.d.ts","sourceRoot":"","sources":["../../../src/vite/configFile.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,iFAAiF;AACjF,eAAO,MAAM,YAAY,UAAyE,CAAC;AAKnG,+FAA+F;AAC/F,MAAM,MAAM,cAAc,GAAG;IAC3B,4DAA4D;IAC5D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,qBAAqB;IACrB,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,4BAA4B;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,yDAAyD;IACzD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,sCAAsC;IACtC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,6FAA6F;IAC7F,QAAQ,CAAC,QAAQ,EAAE,SAAS,UAAU,EAAE,GAAG,SAAS,CAAC;IACrD,8DAA8D;IAC9D,QAAQ,CAAC,SAAS,EAAE,SAAS,aAAa,EAAE,CAAC;IAC7C,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wEAAwE;IACxE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,+FAA+F;IAC/F,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,6GAA6G;IAC7G,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,kEAAmE,CAAC;AAEpG;;;;GAIG;AACH,eAAO,MAAM,eAAe,GACzB,KAAK,MAAM,MACX,MAAM,MAAM,KAAG,MAAM,GAAG,SAOxB,CAAC;AAYJ;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAC2B,CAAC;AAelF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,SAAS,cAAc,EAAE,KAAG,cAiC5D,CAAC;AA2BF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,eAAe,EAAE,KAAK,MAAM,KAAG,cAgCpE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,cAAc,CAMzE,CAAC"}
@@ -0,0 +1,190 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ /**
10
+ * A catalogue's configuration file read: found in its folder, loaded, checked, and merged with its presets, as the
11
+ * plugin and the `forgebook` command use it.
12
+ *
13
+ * @remarks
14
+ * Node loads the file with its types stripped (`forgebook.config.ts`, `.mts` or `.js`). A preset's switches,
15
+ * languages and head come before the catalogue's, and a switch or language the catalogue declares with the same id
16
+ * replaces the preset's; its preview sits under the catalogue's. Every problem is named with the file it comes from.
17
+ *
18
+ * @module
19
+ */
20
+ import { existsSync } from "node:fs";
21
+ import { createRequire } from "node:module";
22
+ import { dirname, isAbsolute, resolve } from "node:path";
23
+ import { pathToFileURL } from "node:url";
24
+ import { switchesProblem } from "../switches.js";
25
+ /** The names a configuration file may have, in the order they are looked for. */
26
+ export const CONFIG_FILES = ["forgebook.config.ts", "forgebook.config.mts", "forgebook.config.js"];
27
+ /** The names a preview may have beside the configuration, in the order they are looked for. */
28
+ const PREVIEW_FILES = ["forgebook.preview.ts", "forgebook.preview.tsx", "forgebook.preview.js"];
29
+ /** The packages of the play tools: both installed, or the plays get neither. */
30
+ export const PLAY_TOOLS_PACKAGES = ["@testing-library/dom", "@testing-library/user-event"];
31
+ /**
32
+ * Resolves packages as Node does from a folder: a package's (or subpath's) file, or none when it is not there.
33
+ *
34
+ * @param dir - the folder, the configuration's.
35
+ */
36
+ export const packageResolver = (dir) => (name) => {
37
+ const require = createRequire(resolve(dir, "package.json"));
38
+ try {
39
+ return require.resolve(name);
40
+ }
41
+ catch {
42
+ return undefined;
43
+ }
44
+ };
45
+ /**
46
+ * Whether the project in a folder installs the play tools' packages, found as Node finds them from there.
47
+ *
48
+ * @param dir - the configuration's folder.
49
+ */
50
+ const hasPlayToolsIn = (dir) => {
51
+ const resolvePackage = packageResolver(dir);
52
+ return PLAY_TOOLS_PACKAGES.every((name) => resolvePackage(name) !== undefined);
53
+ };
54
+ /**
55
+ * The configuration file in a folder, when there is one.
56
+ *
57
+ * @param dir - the folder.
58
+ */
59
+ export const findConfigFile = (dir) => CONFIG_FILES.map((name) => resolve(dir, name)).find((file) => existsSync(file));
60
+ /**
61
+ * Entries by id, a later one replacing an earlier one with the same id in its place.
62
+ *
63
+ * @param lists - the lists, in order.
64
+ */
65
+ const mergedById = (lists) => {
66
+ const merged = new Map();
67
+ for (const list of lists)
68
+ for (const entry of list ?? [])
69
+ merged.set(entry.id, entry);
70
+ return [...merged.values()];
71
+ };
72
+ /**
73
+ * The lists of the presets and the catalogue, in that order, merged: a single value (a width range, the grid's step)
74
+ * the last that gives one; the backgrounds, the story groups and the texts entry by entry, a later one replacing an
75
+ * earlier one with the same id or name; the tabs turned off and the rules turned off by any.
76
+ *
77
+ * @param all - the presets' lists, then the catalogue's.
78
+ */
79
+ export const mergedLists = (all) => {
80
+ const tabs = {};
81
+ const strings = {};
82
+ let merged = {};
83
+ for (const lists of all) {
84
+ Object.assign(tabs, lists.tabs);
85
+ Object.assign(strings, lists.strings);
86
+ merged = {
87
+ ...merged,
88
+ ...(lists.id === undefined ? {} : { id: lists.id }),
89
+ ...(lists.widths === undefined ? {} : { widths: lists.widths }),
90
+ ...(lists.widthRange === undefined ? {} : { widthRange: lists.widthRange }),
91
+ ...(lists.zooms === undefined ? {} : { zooms: lists.zooms }),
92
+ ...(lists.textSizes === undefined ? {} : { textSizes: lists.textSizes }),
93
+ ...(lists.gridStep === undefined ? {} : { gridStep: lists.gridStep })
94
+ };
95
+ }
96
+ const builtIn = all.findLast((lists) => lists.backgrounds?.builtIn !== undefined)?.backgrounds?.builtIn;
97
+ const tags = all.findLast((lists) => lists.a11y?.tags !== undefined)?.a11y?.tags;
98
+ return {
99
+ ...merged,
100
+ backgrounds: {
101
+ ...(builtIn === undefined ? {} : { builtIn }),
102
+ custom: mergedById(all.map((lists) => lists.backgrounds?.custom))
103
+ },
104
+ storyGroups: mergedById(all.map((lists) => lists.storyGroups)),
105
+ tabs,
106
+ a11y: {
107
+ ...(tags === undefined ? {} : { tags }),
108
+ disabledRules: [...new Set(all.flatMap((lists) => lists.a11y?.disabledRules ?? []))]
109
+ },
110
+ strings
111
+ };
112
+ };
113
+ /**
114
+ * Why a loaded configuration cannot be used, or none.
115
+ *
116
+ * @param config - what the file exports by default.
117
+ */
118
+ const configProblem = (config) => {
119
+ if (typeof config !== "object" || config === null)
120
+ return "it exports no configuration (`export default defineConfig({ … })`)";
121
+ if (!("framework" in config) || typeof config.framework !== "object" || config.framework === null)
122
+ return "it names no framework (`framework: react()`)";
123
+ if (!("title" in config) || typeof config.title !== "string")
124
+ return "it names no title";
125
+ const hasStories = "stories" in config && Array.isArray(config.stories) && config.stories.length > 0;
126
+ const hasSources = "sources" in config && Array.isArray(config.sources) && config.sources.length > 0;
127
+ if (!hasStories && !hasSources)
128
+ return 'it names no stories (`stories: ["src/**/*.stories.tsx"]`) and no sources';
129
+ return undefined;
130
+ };
131
+ /**
132
+ * Whether a loaded configuration is one: checked by `configProblem`.
133
+ *
134
+ * @param config - what the file exports by default.
135
+ */
136
+ const isConfig = (config) => configProblem(config) === undefined;
137
+ /**
138
+ * A configuration with its presets merged and its paths made absolute.
139
+ *
140
+ * @param config - the configuration.
141
+ * @param dir - the folder of its file.
142
+ * @throws when the merged switches cannot be used.
143
+ */
144
+ export const resolveConfig = (config, dir) => {
145
+ const presets = config.presets ?? [];
146
+ const absolute = (path) => (isAbsolute(path) ? path : resolve(dir, path));
147
+ const declared = [...presets.map((preset) => preset.switches), config.switches];
148
+ const switches = declared.some((list) => list !== undefined) ? mergedById(declared) : undefined;
149
+ const problem = switches === undefined ? undefined : switchesProblem(switches);
150
+ if (problem !== undefined)
151
+ throw new Error(`${resolve(dir, "forgebook.config")}: ${problem}`);
152
+ const ownPreview = config.preview === undefined
153
+ ? PREVIEW_FILES.map((name) => resolve(dir, name)).find((file) => existsSync(file))
154
+ : absolute(config.preview);
155
+ return {
156
+ dir,
157
+ framework: config.framework,
158
+ title: config.title,
159
+ logo: config.logo === undefined ? undefined : absolute(config.logo),
160
+ heights: config.heights,
161
+ stories: config.stories ?? [],
162
+ sources: config.sources ?? [],
163
+ switches,
164
+ languages: mergedById([...presets.map((preset) => preset.languages), config.languages]),
165
+ previews: [
166
+ ...presets.flatMap((preset) => (preset.preview === undefined ? [] : [preset.preview])),
167
+ ...(ownPreview === undefined ? [] : [ownPreview])
168
+ ],
169
+ head: [...presets.map((preset) => preset.head ?? ""), config.head ?? ""]
170
+ .filter((tags) => tags !== "")
171
+ .join("\n"),
172
+ watch: (config.watch ?? []).map(absolute),
173
+ lists: mergedLists([...presets, config]),
174
+ hasPlayTools: hasPlayToolsIn(dir)
175
+ };
176
+ };
177
+ /**
178
+ * Loads a configuration file and resolves it.
179
+ *
180
+ * @param file - the file's absolute path.
181
+ * @throws when the file does not load, or exports no usable configuration.
182
+ */
183
+ export const loadConfigFile = async (file) => {
184
+ const module = await import(__rewriteRelativeImportExtension(pathToFileURL(file).href));
185
+ const config = typeof module === "object" && module !== null && "default" in module ? module.default : undefined;
186
+ if (!isConfig(config))
187
+ throw new Error(`${file}: ${configProblem(config) ?? "it cannot be read"}`);
188
+ return resolveConfig(config, dirname(file));
189
+ };
190
+ //# sourceMappingURL=configFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configFile.js","sourceRoot":"","sources":["../../../src/vite/configFile.ts"],"names":[],"mappings":";;;;;;;;AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAKzC,OAAO,EAAE,eAAe,EAAmB,MAAM,gBAAgB,CAAC;AAIlE,iFAAiF;AACjF,MAAM,CAAC,MAAM,YA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,EAAE;IAC5E,MAAM,MAAM,GAAY,MAAM,MAAM,kCAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAC,CAAC;IAC/D,MAAM,MAAM,GACV,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IACpG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,aAAa,CAAC,MAAM,CAAC,IAAI,mBAAmB,EAAE,CAAC,CAAC;IACnG,OAAO,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { StoryComponentResult } from "./adapter.ts";
2
+ /** What the extractor answers for a story file: its component's docs, none, or why it cannot be read. */
3
+ export type DocsResult = StoryComponentResult;
4
+ /** A message to the worker: a story file's docs to read, or the news that a source file changed. */
5
+ export type DocsRequest = {
6
+ /** Read a story file's docs. */
7
+ readonly kind: "extract";
8
+ /** The request's number, repeated in its answer. */
9
+ readonly id: number;
10
+ /** The story file's absolute path. */
11
+ readonly storyFile: string;
12
+ } | {
13
+ /** A source file changed: the programs are renewed on their next read. */
14
+ readonly kind: "changed";
15
+ };
16
+ /** The worker's answer to a request. */
17
+ export type DocsResponse = {
18
+ /** The request's number. */
19
+ readonly id: number;
20
+ /** The extractor's result. */
21
+ readonly result: DocsResult;
22
+ };
23
+ /** The docs, read off the dev server's thread. */
24
+ export type DocsExtractor = {
25
+ /** The component docs of a story file. */
26
+ readonly extract: (storyFile: string) => Promise<DocsResult>;
27
+ /** Builds the program that holds a story file, ahead of its first read. */
28
+ readonly warm: (storyFile: string) => void;
29
+ /** Tells the worker a source file changed, so the next read sees it. */
30
+ readonly changed: () => void;
31
+ /** Ends the worker; a later request starts a new one. */
32
+ readonly close: () => Promise<void>;
33
+ };
34
+ /** What the worker is started with: the framework's docs module, which it loads before its first answer. */
35
+ export type DocsWorkerData = {
36
+ /** The URL of the module exporting the framework's `extractStoryComponent`. */
37
+ readonly docsModule: string;
38
+ };
39
+ /**
40
+ * A docs extractor with its worker, started on its first request.
41
+ *
42
+ * @param docsModule - the URL of the framework's docs module (`FrameworkAdapter.docsModule`).
43
+ * @returns the extractor.
44
+ */
45
+ export declare const createDocsExtractor: (docsModule: string) => DocsExtractor;
46
+ //# sourceMappingURL=docsExtractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docsExtractor.d.ts","sourceRoot":"","sources":["../../../src/vite/docsExtractor.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEzD,yGAAyG;AACzG,MAAM,MAAM,UAAU,GAAG,oBAAoB,CAAC;AAE9C,oGAAoG;AACpG,MAAM,MAAM,WAAW,GACnB;IACE,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,GACD;IACE,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B,CAAC;AAEN,wCAAwC;AACxC,MAAM,MAAM,YAAY,GAAG;IACzB,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B,CAAC;AAEF,kDAAkD;AAClD,MAAM,MAAM,aAAa,GAAG;IAC1B,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7D,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;IAC7B,yDAAyD;IACzD,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC,CAAC;AAQF,4GAA4G;AAC5G,MAAM,MAAM,cAAc,GAAG;IAC3B,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,YAAY,MAAM,KAAG,aAuDxD,CAAC"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * The story files' component docs, read in a worker thread (`docsWorker.ts`) so the dev server keeps answering while
3
+ * a package's TypeScript program is built.
4
+ *
5
+ * @remarks
6
+ * One worker per plugin, started on the first request and kept: its programs make every later read quick, until a
7
+ * source file changes (`changed`, which the dev server's watcher sends). Requests
8
+ * are answered in order; a warm-up (`warm`) builds a package's program before a page asks for it, one at a time and
9
+ * only while the worker has nothing else to do, so a page's request waits behind one warm-up at most, never behind
10
+ * them all. The worker never keeps the process alive (`unref`), and `close` ends it when the build or the server
11
+ * ends.
12
+ *
13
+ * @module
14
+ */
15
+ import { extname } from "node:path";
16
+ import { Worker } from "node:worker_threads";
17
+ /**
18
+ * The worker's module, beside this one and with its extension: `.ts` in the sources, whose types Node strips, `.js`
19
+ * once built for npm, where Node strips none.
20
+ */
21
+ const WORKER_URL = new URL(`./docsWorker${extname(import.meta.url)}`, import.meta.url);
22
+ /**
23
+ * A docs extractor with its worker, started on its first request.
24
+ *
25
+ * @param docsModule - the URL of the framework's docs module (`FrameworkAdapter.docsModule`).
26
+ * @returns the extractor.
27
+ */
28
+ export const createDocsExtractor = (docsModule) => {
29
+ let worker;
30
+ let nextId = 0;
31
+ // every request sent and not answered yet, a warm-up's answer included (none reads it)
32
+ const pending = new Map();
33
+ // the warm-ups not sent yet: one goes out only when nothing is pending
34
+ const warmUps = [];
35
+ const started = () => {
36
+ if (worker !== undefined)
37
+ return worker;
38
+ const workerData = { docsModule };
39
+ const created = new Worker(WORKER_URL, { workerData });
40
+ created.unref();
41
+ created.on("message", (response) => {
42
+ pending.get(response.id)?.(response.result);
43
+ pending.delete(response.id);
44
+ sendWarmUp();
45
+ });
46
+ // a worker that dies answers every request still waiting with why, and the next request starts a new one
47
+ created.on("error", (error) => {
48
+ for (const resolve of pending.values())
49
+ resolve(`The docs' worker stopped: ${error.message}`);
50
+ pending.clear();
51
+ worker = undefined;
52
+ });
53
+ worker = created;
54
+ return created;
55
+ };
56
+ const send = (storyFile, resolve) => {
57
+ const id = nextId++;
58
+ pending.set(id, resolve);
59
+ const request = { kind: "extract", id, storyFile };
60
+ started().postMessage(request);
61
+ };
62
+ const sendWarmUp = () => {
63
+ if (pending.size > 0)
64
+ return;
65
+ const storyFile = warmUps.shift();
66
+ if (storyFile !== undefined)
67
+ send(storyFile, () => undefined);
68
+ };
69
+ return {
70
+ extract: (storyFile) => new Promise((resolve) => send(storyFile, resolve)),
71
+ warm: (storyFile) => {
72
+ warmUps.push(storyFile);
73
+ sendWarmUp();
74
+ },
75
+ changed: () => {
76
+ // a worker not started yet has no program to renew
77
+ const request = { kind: "changed" };
78
+ worker?.postMessage(request);
79
+ },
80
+ close: async () => {
81
+ const running = worker;
82
+ worker = undefined;
83
+ warmUps.length = 0;
84
+ await running?.terminate();
85
+ }
86
+ };
87
+ };
88
+ //# sourceMappingURL=docsExtractor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docsExtractor.js","sourceRoot":"","sources":["../../../src/vite/docsExtractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AA0C7C;;;GAGG;AACH,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,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SAAS,EAAE,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,42 @@
1
+ import ts from "typescript-6";
2
+ /** A program and its type checker. */
3
+ export type DocsProgram = {
4
+ /** The program. */
5
+ readonly program: ts.Program;
6
+ /** Its type checker. */
7
+ readonly checker: ts.TypeChecker;
8
+ };
9
+ /** Marks every program as maybe holding an edited file: each is renewed on its next read. */
10
+ export declare const markSourcesChanged: () => void;
11
+ /**
12
+ * The program that holds a file: the one of the nearest `tsconfig.json` up its folders, or, when none holds it, a
13
+ * program of the file alone (`FALLBACK_OPTIONS`, or the configuration's with JavaScript allowed).
14
+ *
15
+ * @param file - an absolute path to a source file.
16
+ * @returns the program, or a message when the configuration above it cannot be read.
17
+ */
18
+ export declare const programFor: (file: string) => DocsProgram | string;
19
+ /**
20
+ * The first paragraph of a symbol's TSDoc.
21
+ *
22
+ * @param symbol - a declared symbol.
23
+ * @param checker - the program's type checker.
24
+ */
25
+ export declare const summaryOf: (symbol: ts.Symbol, checker: ts.TypeChecker) => string;
26
+ /**
27
+ * The first paragraph of a file's leading comment, its `@module` TSDoc: what the file holds, in a sentence. A
28
+ * component's own TSDoc is often a bare name ("A button."); its file's comment says what it is and does.
29
+ *
30
+ * @param sourceFile - the file.
31
+ * @returns the paragraph on one line, or an empty text when the file does not open with a `@module` comment.
32
+ */
33
+ export declare const moduleSummaryOf: (sourceFile: ts.SourceFile) => string;
34
+ /**
35
+ * A TSDoc tag's text, without the backticks it is often written in.
36
+ *
37
+ * @param symbol - a declared symbol.
38
+ * @param checker - the program's type checker.
39
+ * @param name - the tag (`defaultValue`).
40
+ */
41
+ export declare const tagOf: (symbol: ts.Symbol, checker: ts.TypeChecker, name: string) => string | undefined;
42
+ //# sourceMappingURL=docsProgram.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docsProgram.d.ts","sourceRoot":"","sources":["../../../src/vite/docsProgram.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,MAAM,cAAc,CAAC;AAE9B,sCAAsC;AACtC,MAAM,MAAM,WAAW,GAAG;IACxB,mBAAmB;IACnB,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC;IAC7B,wBAAwB;IACxB,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC;CAClC,CAAC;AAWF,6FAA6F;AAC7F,eAAO,MAAM,kBAAkB,QAAO,IAErC,CAAC;AA+CF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,KAAG,WAAW,GAAG,MAevD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,WAAW,KAAG,MAG5D,CAAC;AAEZ;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,YAAY,EAAE,CAAC,UAAU,KAAG,MAkB3D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,GAAI,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,WAAW,EAAE,MAAM,MAAM,KAAG,MAAM,GAAG,SAOzF,CAAC"}