forgebook 0.1.3 → 0.1.4

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 (339) hide show
  1. package/README.md +74 -6
  2. package/dist/bin/forgebook/agentClient.d.ts +17 -0
  3. package/dist/bin/forgebook/agentClient.d.ts.map +1 -1
  4. package/dist/bin/forgebook/agentClient.js +21 -0
  5. package/dist/bin/forgebook/agentClient.js.map +1 -1
  6. package/dist/bin/forgebook/agentLoopCommands.d.mts +9 -0
  7. package/dist/bin/forgebook/agentLoopCommands.d.mts.map +1 -0
  8. package/dist/bin/forgebook/agentLoopCommands.mjs +217 -0
  9. package/dist/bin/forgebook/agentLoopCommands.mjs.map +1 -0
  10. package/dist/bin/forgebook/agentText.d.ts +37 -1
  11. package/dist/bin/forgebook/agentText.d.ts.map +1 -1
  12. package/dist/bin/forgebook/agentText.js +49 -2
  13. package/dist/bin/forgebook/agentText.js.map +1 -1
  14. package/dist/bin/forgebook/agents.md +46 -0
  15. package/dist/bin/forgebook/agentsText.d.ts +29 -0
  16. package/dist/bin/forgebook/agentsText.d.ts.map +1 -0
  17. package/dist/bin/forgebook/agentsText.js +48 -0
  18. package/dist/bin/forgebook/agentsText.js.map +1 -0
  19. package/dist/bin/forgebook/catalogueCommands.d.ts +51 -0
  20. package/dist/bin/forgebook/catalogueCommands.d.ts.map +1 -0
  21. package/dist/bin/forgebook/catalogueCommands.js +90 -0
  22. package/dist/bin/forgebook/catalogueCommands.js.map +1 -0
  23. package/dist/bin/forgebook/errorsRun.d.ts +27 -0
  24. package/dist/bin/forgebook/errorsRun.d.ts.map +1 -0
  25. package/dist/bin/forgebook/errorsRun.js +60 -0
  26. package/dist/bin/forgebook/errorsRun.js.map +1 -0
  27. package/dist/bin/forgebook/forgebook.mjs +109 -84
  28. package/dist/bin/forgebook/forgebook.mjs.map +1 -1
  29. package/dist/bin/forgebook/importers/storybook.d.ts +53 -0
  30. package/dist/bin/forgebook/importers/storybook.d.ts.map +1 -0
  31. package/dist/bin/forgebook/importers/storybook.js +318 -0
  32. package/dist/bin/forgebook/importers/storybook.js.map +1 -0
  33. package/dist/bin/forgebook/initCommands.d.mts +9 -0
  34. package/dist/bin/forgebook/initCommands.d.mts.map +1 -0
  35. package/dist/bin/forgebook/initCommands.mjs +86 -0
  36. package/dist/bin/forgebook/initCommands.mjs.map +1 -0
  37. package/dist/bin/forgebook/initConfig.d.ts +22 -0
  38. package/dist/bin/forgebook/initConfig.d.ts.map +1 -0
  39. package/dist/bin/forgebook/initConfig.js +51 -0
  40. package/dist/bin/forgebook/initConfig.js.map +1 -0
  41. package/dist/bin/forgebook/mcpTools.d.ts +29 -3
  42. package/dist/bin/forgebook/mcpTools.d.ts.map +1 -1
  43. package/dist/bin/forgebook/mcpTools.js +130 -7
  44. package/dist/bin/forgebook/mcpTools.js.map +1 -1
  45. package/dist/bin/forgebook/newStories.d.ts +27 -0
  46. package/dist/bin/forgebook/newStories.d.ts.map +1 -0
  47. package/dist/bin/forgebook/newStories.js +109 -0
  48. package/dist/bin/forgebook/newStories.js.map +1 -0
  49. package/dist/bin/forgebook/newStoriesFile.d.ts +18 -0
  50. package/dist/bin/forgebook/newStoriesFile.d.ts.map +1 -0
  51. package/dist/bin/forgebook/newStoriesFile.js +58 -0
  52. package/dist/bin/forgebook/newStoriesFile.js.map +1 -0
  53. package/dist/bin/forgebook/storyCheckRun.d.ts +39 -0
  54. package/dist/bin/forgebook/storyCheckRun.d.ts.map +1 -0
  55. package/dist/bin/forgebook/storyCheckRun.js +177 -0
  56. package/dist/bin/forgebook/storyCheckRun.js.map +1 -0
  57. package/dist/bin/forgebook-docs/catalogueDocs.d.ts +24 -0
  58. package/dist/bin/forgebook-docs/catalogueDocs.d.ts.map +1 -0
  59. package/dist/bin/forgebook-docs/catalogueDocs.js +71 -0
  60. package/dist/bin/forgebook-docs/catalogueDocs.js.map +1 -0
  61. package/dist/bin/forgebook-docs/catalogueDocs.types.d.ts +8 -0
  62. package/dist/bin/forgebook-docs/catalogueDocs.types.d.ts.map +1 -1
  63. package/dist/bin/forgebook-docs/catalogueMarkdown.d.ts +3 -1
  64. package/dist/bin/forgebook-docs/catalogueMarkdown.d.ts.map +1 -1
  65. package/dist/bin/forgebook-docs/catalogueMarkdown.js +62 -42
  66. package/dist/bin/forgebook-docs/catalogueMarkdown.js.map +1 -1
  67. package/dist/bin/forgebook-docs/catalogueOptions.d.ts +39 -0
  68. package/dist/bin/forgebook-docs/catalogueOptions.d.ts.map +1 -0
  69. package/dist/bin/forgebook-docs/catalogueOptions.js +76 -0
  70. package/dist/bin/forgebook-docs/catalogueOptions.js.map +1 -0
  71. package/dist/bin/forgebook-docs/collectDocs.d.ts +3 -1
  72. package/dist/bin/forgebook-docs/collectDocs.d.ts.map +1 -1
  73. package/dist/bin/forgebook-docs/collectDocs.js +37 -13
  74. package/dist/bin/forgebook-docs/collectDocs.js.map +1 -1
  75. package/dist/bin/forgebook-docs/forgebook-docs.mjs +17 -80
  76. package/dist/bin/forgebook-docs/forgebook-docs.mjs.map +1 -1
  77. package/dist/bin/forgebook-docs/llmsText.d.ts +24 -0
  78. package/dist/bin/forgebook-docs/llmsText.d.ts.map +1 -0
  79. package/dist/bin/forgebook-docs/llmsText.js +33 -0
  80. package/dist/bin/forgebook-docs/llmsText.js.map +1 -0
  81. package/dist/bin/forgebook-docs/sourceId.d.ts +9 -0
  82. package/dist/bin/forgebook-docs/sourceId.d.ts.map +1 -0
  83. package/dist/bin/forgebook-docs/sourceId.js +45 -0
  84. package/dist/bin/forgebook-docs/sourceId.js.map +1 -0
  85. package/dist/bin/frameworkDocs.d.ts +10 -0
  86. package/dist/bin/frameworkDocs.d.ts.map +1 -0
  87. package/dist/bin/frameworkDocs.js +43 -0
  88. package/dist/bin/frameworkDocs.js.map +1 -0
  89. package/dist/src/argTypes.d.ts +23 -0
  90. package/dist/src/argTypes.d.ts.map +1 -1
  91. package/dist/src/argTypes.js +27 -0
  92. package/dist/src/argTypes.js.map +1 -1
  93. package/dist/src/catalogue.d.ts +70 -3
  94. package/dist/src/catalogue.d.ts.map +1 -1
  95. package/dist/src/catalogue.js +85 -3
  96. package/dist/src/catalogue.js.map +1 -1
  97. package/dist/src/controlKeys.d.ts +85 -0
  98. package/dist/src/controlKeys.d.ts.map +1 -0
  99. package/dist/src/controlKeys.js +118 -0
  100. package/dist/src/controlKeys.js.map +1 -0
  101. package/dist/src/frame/frame.css +33 -2
  102. package/dist/src/frame/frameView.d.ts +2 -2
  103. package/dist/src/frame/frameView.d.ts.map +1 -1
  104. package/dist/src/frame/frameView.js +7 -3
  105. package/dist/src/frame/frameView.js.map +1 -1
  106. package/dist/src/frame/mountFrame.d.ts.map +1 -1
  107. package/dist/src/frame/mountFrame.js +26 -2
  108. package/dist/src/frame/mountFrame.js.map +1 -1
  109. package/dist/src/frame/spillOutline.d.ts +10 -0
  110. package/dist/src/frame/spillOutline.d.ts.map +1 -0
  111. package/dist/src/frame/spillOutline.js +80 -0
  112. package/dist/src/frame/spillOutline.js.map +1 -0
  113. package/dist/src/liveErrors.d.ts +57 -0
  114. package/dist/src/liveErrors.d.ts.map +1 -0
  115. package/dist/src/liveErrors.js +52 -0
  116. package/dist/src/liveErrors.js.map +1 -0
  117. package/dist/src/messages.d.ts +12 -0
  118. package/dist/src/messages.d.ts.map +1 -1
  119. package/dist/src/messages.js +4 -0
  120. package/dist/src/messages.js.map +1 -1
  121. package/dist/src/namedViews.d.ts +80 -0
  122. package/dist/src/namedViews.d.ts.map +1 -0
  123. package/dist/src/namedViews.js +88 -0
  124. package/dist/src/namedViews.js.map +1 -0
  125. package/dist/src/shell/AppearanceMenu.d.ts +15 -0
  126. package/dist/src/shell/AppearanceMenu.d.ts.map +1 -0
  127. package/dist/src/shell/AppearanceMenu.js +28 -0
  128. package/dist/src/shell/AppearanceMenu.js.map +1 -0
  129. package/dist/src/shell/BoxWidth.d.ts +40 -0
  130. package/dist/src/shell/BoxWidth.d.ts.map +1 -0
  131. package/dist/src/shell/BoxWidth.js +56 -0
  132. package/dist/src/shell/BoxWidth.js.map +1 -0
  133. package/dist/src/shell/ComponentPage.d.ts +17 -1
  134. package/dist/src/shell/ComponentPage.d.ts.map +1 -1
  135. package/dist/src/shell/ComponentPage.js +19 -54
  136. package/dist/src/shell/ComponentPage.js.map +1 -1
  137. package/dist/src/shell/ControlKeyField.d.ts +21 -0
  138. package/dist/src/shell/ControlKeyField.d.ts.map +1 -0
  139. package/dist/src/shell/ControlKeyField.js +46 -0
  140. package/dist/src/shell/ControlKeyField.js.map +1 -0
  141. package/dist/src/shell/ControlRow.d.ts +31 -0
  142. package/dist/src/shell/ControlRow.d.ts.map +1 -0
  143. package/dist/src/shell/ControlRow.js +27 -0
  144. package/dist/src/shell/ControlRow.js.map +1 -0
  145. package/dist/src/shell/Example.d.ts +58 -0
  146. package/dist/src/shell/Example.d.ts.map +1 -0
  147. package/dist/src/shell/Example.js +89 -0
  148. package/dist/src/shell/Example.js.map +1 -0
  149. package/dist/src/shell/NamedViews.d.ts +23 -0
  150. package/dist/src/shell/NamedViews.d.ts.map +1 -0
  151. package/dist/src/shell/NamedViews.js +49 -0
  152. package/dist/src/shell/NamedViews.js.map +1 -0
  153. package/dist/src/shell/PinnedControl.d.ts +25 -0
  154. package/dist/src/shell/PinnedControl.d.ts.map +1 -0
  155. package/dist/src/shell/PinnedControl.js +81 -0
  156. package/dist/src/shell/PinnedControl.js.map +1 -0
  157. package/dist/src/shell/PropsTab.d.ts +5 -2
  158. package/dist/src/shell/PropsTab.d.ts.map +1 -1
  159. package/dist/src/shell/PropsTab.js +12 -15
  160. package/dist/src/shell/PropsTab.js.map +1 -1
  161. package/dist/src/shell/Shell.d.ts.map +1 -1
  162. package/dist/src/shell/Shell.js +27 -2
  163. package/dist/src/shell/Shell.js.map +1 -1
  164. package/dist/src/shell/Sidebar.d.ts +11 -9
  165. package/dist/src/shell/Sidebar.d.ts.map +1 -1
  166. package/dist/src/shell/Sidebar.js +48 -42
  167. package/dist/src/shell/Sidebar.js.map +1 -1
  168. package/dist/src/shell/SidebarEntries.d.ts +50 -0
  169. package/dist/src/shell/SidebarEntries.d.ts.map +1 -0
  170. package/dist/src/shell/SidebarEntries.js +51 -0
  171. package/dist/src/shell/SidebarEntries.js.map +1 -0
  172. package/dist/src/shell/Stage.d.ts.map +1 -1
  173. package/dist/src/shell/Stage.js +19 -2
  174. package/dist/src/shell/Stage.js.map +1 -1
  175. package/dist/src/shell/Toolbar.d.ts +7 -3
  176. package/dist/src/shell/Toolbar.d.ts.map +1 -1
  177. package/dist/src/shell/Toolbar.js +38 -68
  178. package/dist/src/shell/Toolbar.js.map +1 -1
  179. package/dist/src/shell/ToolbarControl.d.ts +47 -0
  180. package/dist/src/shell/ToolbarControl.d.ts.map +1 -0
  181. package/dist/src/shell/ToolbarControl.js +150 -0
  182. package/dist/src/shell/ToolbarControl.js.map +1 -0
  183. package/dist/src/shell/UsedIn.d.ts +38 -0
  184. package/dist/src/shell/UsedIn.d.ts.map +1 -0
  185. package/dist/src/shell/UsedIn.js +77 -0
  186. package/dist/src/shell/UsedIn.js.map +1 -0
  187. package/dist/src/shell/ViewMenu.d.ts +37 -0
  188. package/dist/src/shell/ViewMenu.d.ts.map +1 -0
  189. package/dist/src/shell/ViewMenu.js +216 -0
  190. package/dist/src/shell/ViewMenu.js.map +1 -0
  191. package/dist/src/shell/controlCycle.d.ts +28 -0
  192. package/dist/src/shell/controlCycle.d.ts.map +1 -0
  193. package/dist/src/shell/controlCycle.js +51 -0
  194. package/dist/src/shell/controlCycle.js.map +1 -0
  195. package/dist/src/shell/dockTabs.d.ts +3 -0
  196. package/dist/src/shell/dockTabs.d.ts.map +1 -1
  197. package/dist/src/shell/dockTabs.js +1 -1
  198. package/dist/src/shell/dockTabs.js.map +1 -1
  199. package/dist/src/shell/icons.d.ts +6 -0
  200. package/dist/src/shell/icons.d.ts.map +1 -1
  201. package/dist/src/shell/icons.js +7 -1
  202. package/dist/src/shell/icons.js.map +1 -1
  203. package/dist/src/shell/keyboard.d.ts +2 -1
  204. package/dist/src/shell/keyboard.d.ts.map +1 -1
  205. package/dist/src/shell/keyboard.js +5 -2
  206. package/dist/src/shell/keyboard.js.map +1 -1
  207. package/dist/src/shell/shell.css +826 -243
  208. package/dist/src/shell/strings.d.ts +45 -0
  209. package/dist/src/shell/strings.d.ts.map +1 -1
  210. package/dist/src/shell/strings.js +45 -0
  211. package/dist/src/shell/strings.js.map +1 -1
  212. package/dist/src/shell/useAppearance.d.ts +17 -0
  213. package/dist/src/shell/useAppearance.d.ts.map +1 -0
  214. package/dist/src/shell/useAppearance.js +36 -0
  215. package/dist/src/shell/useAppearance.js.map +1 -0
  216. package/dist/src/shell/useControlKeys.d.ts +23 -0
  217. package/dist/src/shell/useControlKeys.d.ts.map +1 -0
  218. package/dist/src/shell/useControlKeys.js +44 -0
  219. package/dist/src/shell/useControlKeys.js.map +1 -0
  220. package/dist/src/shell/useFold.d.ts +27 -0
  221. package/dist/src/shell/useFold.d.ts.map +1 -0
  222. package/dist/src/shell/useFold.js +87 -0
  223. package/dist/src/shell/useFold.js.map +1 -0
  224. package/dist/src/shell/useFrameMessages.d.ts +2 -0
  225. package/dist/src/shell/useFrameMessages.d.ts.map +1 -1
  226. package/dist/src/shell/useFrameMessages.js +3 -0
  227. package/dist/src/shell/useFrameMessages.js.map +1 -1
  228. package/dist/src/shell/useFullPage.d.ts +45 -0
  229. package/dist/src/shell/useFullPage.d.ts.map +1 -0
  230. package/dist/src/shell/useFullPage.js +149 -0
  231. package/dist/src/shell/useFullPage.js.map +1 -0
  232. package/dist/src/shell/usePopover.d.ts +17 -3
  233. package/dist/src/shell/usePopover.d.ts.map +1 -1
  234. package/dist/src/shell/usePopover.js +65 -4
  235. package/dist/src/shell/usePopover.js.map +1 -1
  236. package/dist/src/shell/useStored.d.ts +13 -2
  237. package/dist/src/shell/useStored.d.ts.map +1 -1
  238. package/dist/src/shell/useStored.js +1 -1
  239. package/dist/src/shell/useStored.js.map +1 -1
  240. package/dist/src/shell/useToolbarLayout.d.ts +39 -0
  241. package/dist/src/shell/useToolbarLayout.d.ts.map +1 -0
  242. package/dist/src/shell/useToolbarLayout.js +58 -0
  243. package/dist/src/shell/useToolbarLayout.js.map +1 -0
  244. package/dist/src/shell/useToolbarOverflow.d.ts +31 -0
  245. package/dist/src/shell/useToolbarOverflow.d.ts.map +1 -0
  246. package/dist/src/shell/useToolbarOverflow.js +62 -0
  247. package/dist/src/shell/useToolbarOverflow.js.map +1 -0
  248. package/dist/src/shell/useWorstCase.d.ts +46 -0
  249. package/dist/src/shell/useWorstCase.d.ts.map +1 -0
  250. package/dist/src/shell/useWorstCase.js +42 -0
  251. package/dist/src/shell/useWorstCase.js.map +1 -0
  252. package/dist/src/shell/worstArgs.d.ts +42 -0
  253. package/dist/src/shell/worstArgs.d.ts.map +1 -0
  254. package/dist/src/shell/worstArgs.js +47 -0
  255. package/dist/src/shell/worstArgs.js.map +1 -0
  256. package/dist/src/spills.d.ts +31 -0
  257. package/dist/src/spills.d.ts.map +1 -0
  258. package/dist/src/spills.js +65 -0
  259. package/dist/src/spills.js.map +1 -0
  260. package/dist/src/storyCheck.d.ts +105 -0
  261. package/dist/src/storyCheck.d.ts.map +1 -0
  262. package/dist/src/storyCheck.js +63 -0
  263. package/dist/src/storyCheck.js.map +1 -0
  264. package/dist/src/switches.d.ts +16 -4
  265. package/dist/src/switches.d.ts.map +1 -1
  266. package/dist/src/switches.js +30 -5
  267. package/dist/src/switches.js.map +1 -1
  268. package/dist/src/toolbarLayout.d.ts +119 -0
  269. package/dist/src/toolbarLayout.d.ts.map +1 -0
  270. package/dist/src/toolbarLayout.js +155 -0
  271. package/dist/src/toolbarLayout.js.map +1 -0
  272. package/dist/src/usedIn.d.ts +60 -0
  273. package/dist/src/usedIn.d.ts.map +1 -0
  274. package/dist/src/usedIn.js +92 -0
  275. package/dist/src/usedIn.js.map +1 -0
  276. package/dist/src/viewState.d.ts +6 -10
  277. package/dist/src/viewState.d.ts.map +1 -1
  278. package/dist/src/viewState.js +20 -18
  279. package/dist/src/viewState.js.map +1 -1
  280. package/dist/src/viewWords.d.ts +26 -0
  281. package/dist/src/viewWords.d.ts.map +1 -0
  282. package/dist/src/viewWords.js +29 -0
  283. package/dist/src/viewWords.js.map +1 -0
  284. package/dist/src/vite/adapter.d.ts +13 -4
  285. package/dist/src/vite/adapter.d.ts.map +1 -1
  286. package/dist/src/vite/adapter.js +4 -2
  287. package/dist/src/vite/adapter.js.map +1 -1
  288. package/dist/src/vite/agent.types.d.ts +32 -2
  289. package/dist/src/vite/agent.types.d.ts.map +1 -1
  290. package/dist/src/vite/agentApi.d.ts +15 -3
  291. package/dist/src/vite/agentApi.d.ts.map +1 -1
  292. package/dist/src/vite/agentApi.js +63 -9
  293. package/dist/src/vite/agentApi.js.map +1 -1
  294. package/dist/src/vite/agentRoutes.d.ts +8 -3
  295. package/dist/src/vite/agentRoutes.d.ts.map +1 -1
  296. package/dist/src/vite/agentRoutes.js +84 -23
  297. package/dist/src/vite/agentRoutes.js.map +1 -1
  298. package/dist/src/vite/configFile.d.ts +2 -1
  299. package/dist/src/vite/configFile.d.ts.map +1 -1
  300. package/dist/src/vite/configFile.js +29 -11
  301. package/dist/src/vite/configFile.js.map +1 -1
  302. package/dist/src/vite/docsExtractor.d.ts +26 -2
  303. package/dist/src/vite/docsExtractor.d.ts.map +1 -1
  304. package/dist/src/vite/docsExtractor.js +12 -9
  305. package/dist/src/vite/docsExtractor.js.map +1 -1
  306. package/dist/src/vite/docsWorker.js +18 -2
  307. package/dist/src/vite/docsWorker.js.map +1 -1
  308. package/dist/src/vite/forgebookPlugin.d.ts.map +1 -1
  309. package/dist/src/vite/forgebookPlugin.js +109 -16
  310. package/dist/src/vite/forgebookPlugin.js.map +1 -1
  311. package/dist/src/vite/indexStoryFile.d.ts +14 -0
  312. package/dist/src/vite/indexStoryFile.d.ts.map +1 -1
  313. package/dist/src/vite/indexStoryFile.js +13 -4
  314. package/dist/src/vite/indexStoryFile.js.map +1 -1
  315. package/dist/src/vite/mcpProtocol.d.ts +9 -0
  316. package/dist/src/vite/mcpProtocol.d.ts.map +1 -1
  317. package/dist/src/vite/mcpProtocol.js +6 -3
  318. package/dist/src/vite/mcpProtocol.js.map +1 -1
  319. package/dist/src/vite/storyFilesModule.d.ts +28 -1
  320. package/dist/src/vite/storyFilesModule.d.ts.map +1 -1
  321. package/dist/src/vite/storyFilesModule.js +34 -14
  322. package/dist/src/vite/storyFilesModule.js.map +1 -1
  323. package/dist/src/vite/usageGraph.d.ts +45 -0
  324. package/dist/src/vite/usageGraph.d.ts.map +1 -0
  325. package/dist/src/vite/usageGraph.js +246 -0
  326. package/dist/src/vite/usageGraph.js.map +1 -0
  327. package/dist/src/vite/usageModule.d.ts +33 -0
  328. package/dist/src/vite/usageModule.d.ts.map +1 -0
  329. package/dist/src/vite/usageModule.js +135 -0
  330. package/dist/src/vite/usageModule.js.map +1 -0
  331. package/dist/src/worstCase.d.ts +16 -0
  332. package/dist/src/worstCase.d.ts.map +1 -0
  333. package/dist/src/worstCase.js +16 -0
  334. package/dist/src/worstCase.js.map +1 -0
  335. package/package.json +14 -2
  336. package/dist/src/shell/SchemeSwitches.d.ts +0 -24
  337. package/dist/src/shell/SchemeSwitches.d.ts.map +0 -1
  338. package/dist/src/shell/SchemeSwitches.js +0 -36
  339. package/dist/src/shell/SchemeSwitches.js.map +0 -1
@@ -0,0 +1,246 @@
1
+ /**
2
+ * What each story renders and what each module imports, read from the TypeScript programs the docs already build:
3
+ * the facts "Used in" is joined from (`usageModule.ts`).
4
+ *
5
+ * @remarks
6
+ * Runs in the docs worker (`docsWorker.ts`), which holds the programs; a package's first read builds its program,
7
+ * the API tables reuse it. A story renders the components its JSX names, resolved by the type checker as its types are
8
+ * (a package-name import, an alias, `<Menu.Item>`); a component declared in the story file itself (a scene) is followed
9
+ * into its own JSX; a story without JSX renders its meta's component. A component is known by the file that declares
10
+ * it and its name there, so two imports of one component are one. The import graph holds the modules the rendered
11
+ * components reach through the package's own imports, never a dependency's (`node_modules`): "used through" follows
12
+ * those edges. A lowercase tag is an element (`<div>`), not a component. A component reached only through code the
13
+ * checker cannot follow (a computed lazy import, a component handed in as a prop) is not found.
14
+ *
15
+ * @module
16
+ */
17
+ import ts from "typescript-6";
18
+ import { programFor } from "./docsProgram.js";
19
+ /**
20
+ * The symbol a name stands for, through its imports and re-exports.
21
+ *
22
+ * @param symbol - the symbol at the name.
23
+ * @param checker - the program's checker.
24
+ */
25
+ const declared = (symbol, checker) => symbol !== undefined && (symbol.flags & ts.SymbolFlags.Alias) !== 0
26
+ ? checker.getAliasedSymbol(symbol)
27
+ : symbol;
28
+ /**
29
+ * A component's reference from its symbol: the file of its first declaration, and its name.
30
+ *
31
+ * @param symbol - the component's symbol.
32
+ */
33
+ const refOf = (symbol) => {
34
+ const declaration = symbol?.declarations?.[0];
35
+ if (symbol === undefined || declaration === undefined)
36
+ return undefined;
37
+ return { file: declaration.getSourceFile().fileName, name: symbol.getName() };
38
+ };
39
+ /**
40
+ * An expression without the wrappers a meta is written with (`satisfies Meta<…>`, `as Meta`, parentheses).
41
+ *
42
+ * @param expression - the expression.
43
+ */
44
+ const unwrap = (expression) => {
45
+ if (ts.isSatisfiesExpression(expression) ||
46
+ ts.isAsExpression(expression) ||
47
+ ts.isParenthesizedExpression(expression))
48
+ return unwrap(expression.expression);
49
+ return expression;
50
+ };
51
+ /**
52
+ * The meta's object: the default export, written inline or as a constant.
53
+ *
54
+ * @param source - the story file.
55
+ * @param checker - the program's checker.
56
+ */
57
+ const metaObject = (source, checker) => {
58
+ const assignment = source.statements.find((statement) => ts.isExportAssignment(statement) && !statement.isExportEquals);
59
+ if (assignment === undefined)
60
+ return undefined;
61
+ let value = unwrap(assignment.expression);
62
+ if (ts.isIdentifier(value)) {
63
+ const declaration = declared(checker.getSymbolAtLocation(value), checker)?.valueDeclaration;
64
+ if (declaration !== undefined &&
65
+ ts.isVariableDeclaration(declaration) &&
66
+ declaration.initializer !== undefined)
67
+ value = unwrap(declaration.initializer);
68
+ }
69
+ return ts.isObjectLiteralExpression(value) ? value : undefined;
70
+ };
71
+ /**
72
+ * The meta's component, as the checker resolves its `component` property.
73
+ *
74
+ * @param meta - the meta's object.
75
+ * @param checker - the program's checker.
76
+ */
77
+ const metaComponent = (meta, checker) => {
78
+ const property = meta.properties.find((each) => each.name !== undefined && each.name.getText() === "component");
79
+ if (property === undefined)
80
+ return undefined;
81
+ if (ts.isShorthandPropertyAssignment(property))
82
+ return refOf(declared(checker.getShorthandAssignmentValueSymbol(property), checker));
83
+ if (ts.isPropertyAssignment(property))
84
+ return refOf(declared(checker.getSymbolAtLocation(unwrap(property.initializer)), checker));
85
+ return undefined;
86
+ };
87
+ /**
88
+ * The symbol a JSX element's tag stands for; none for an element of the page (a lowercase name, `<div>`).
89
+ *
90
+ * @param element - the element's opening or self-closing tag.
91
+ * @param checker - the program's checker.
92
+ */
93
+ const tagSymbol = (element, checker) => {
94
+ const tag = element.tagName;
95
+ if (ts.isIdentifier(tag) && /^[a-z]/.test(tag.text))
96
+ return undefined;
97
+ return declared(checker.getSymbolAtLocation(tag), checker);
98
+ };
99
+ /**
100
+ * The components a node's JSX names: those declared elsewhere as references, those declared in the story file followed
101
+ * into their own declarations, each declaration once.
102
+ *
103
+ * @param node - the story's node.
104
+ * @param source - the story file.
105
+ * @param checker - the program's checker.
106
+ * @param seen - the declarations already followed.
107
+ */
108
+ const jsxRenders = (node, source, checker, seen) => {
109
+ const found = [];
110
+ const named = (symbol) => {
111
+ const declaration = symbol?.declarations?.[0];
112
+ const isLocal = declaration !== undefined && declaration.getSourceFile() === source;
113
+ if (!isLocal) {
114
+ const ref = refOf(symbol);
115
+ if (ref !== undefined)
116
+ found.push(ref);
117
+ return;
118
+ }
119
+ if (seen.has(declaration))
120
+ return;
121
+ seen.add(declaration);
122
+ found.push(...jsxRenders(declaration, source, checker, seen));
123
+ };
124
+ const visit = (current) => {
125
+ if (ts.isJsxOpeningElement(current) || ts.isJsxSelfClosingElement(current))
126
+ named(tagSymbol(current, checker));
127
+ ts.forEachChild(current, visit);
128
+ };
129
+ visit(node);
130
+ return found;
131
+ };
132
+ /**
133
+ * References without repeats, in their first order.
134
+ *
135
+ * @param refs - the references.
136
+ */
137
+ const unique = (refs) => {
138
+ const keys = new Set();
139
+ return refs.filter((ref) => {
140
+ const key = `${ref.file}#${ref.name}`;
141
+ if (keys.has(key))
142
+ return false;
143
+ keys.add(key);
144
+ return true;
145
+ });
146
+ };
147
+ /**
148
+ * One story file's facts, from the program that holds it.
149
+ *
150
+ * @param request - the story file and its stories' exports.
151
+ * @param program - the program.
152
+ */
153
+ const fileUsage = (request, program) => {
154
+ const source = program.getSourceFile(request.storyFile);
155
+ if (source === undefined)
156
+ return undefined;
157
+ const checker = program.getTypeChecker();
158
+ const meta = metaObject(source, checker);
159
+ const component = meta === undefined ? undefined : metaComponent(meta, checker);
160
+ const moduleSymbol = checker.getSymbolAtLocation(source);
161
+ const exported = moduleSymbol === undefined ? [] : checker.getExportsOfModule(moduleSymbol);
162
+ const stories = request.exports.map((exportName) => {
163
+ const symbol = declared(exported.find((each) => each.getName() === exportName), checker);
164
+ const declaration = symbol?.declarations?.[0];
165
+ const named = declaration === undefined ? [] : jsxRenders(declaration, source, checker, new Set([declaration]));
166
+ const renders = named.length === 0 && component !== undefined ? [component] : unique(named);
167
+ return { exportName, renders };
168
+ });
169
+ return { storyFile: request.storyFile, ...(component === undefined ? {} : { component }), stories };
170
+ };
171
+ /**
172
+ * The package's own modules a module imports or re-exports from, resolved as its program resolves them.
173
+ *
174
+ * @param source - the module.
175
+ * @param program - its program.
176
+ * @param cache - the program's resolution cache.
177
+ */
178
+ const importsOf = (source, program, cache) => {
179
+ const targets = [];
180
+ for (const statement of source.statements) {
181
+ const specifier = (ts.isImportDeclaration(statement) || ts.isExportDeclaration(statement)) &&
182
+ statement.moduleSpecifier !== undefined &&
183
+ ts.isStringLiteral(statement.moduleSpecifier)
184
+ ? statement.moduleSpecifier.text
185
+ : undefined;
186
+ if (specifier === undefined)
187
+ continue;
188
+ const resolved = ts.resolveModuleName(specifier, source.fileName, program.getCompilerOptions(), ts.sys, cache).resolvedModule;
189
+ if (resolved !== undefined && !resolved.isExternalLibraryImport)
190
+ targets.push(resolved.resolvedFileName);
191
+ }
192
+ return targets;
193
+ };
194
+ /**
195
+ * The import graph of the modules the given files reach, through the package's own imports.
196
+ *
197
+ * @param starts - the files to start from.
198
+ * @param programs - the programs that may hold them.
199
+ */
200
+ const reachedImports = (starts, programs) => {
201
+ const caches = new Map(programs.map((program) => [
202
+ program,
203
+ ts.createModuleResolutionCache(program.getCurrentDirectory(), (name) => name, program.getCompilerOptions())
204
+ ]));
205
+ const imports = {};
206
+ const queue = [...starts];
207
+ while (queue.length > 0) {
208
+ const file = queue.pop() ?? "";
209
+ if (file in imports)
210
+ continue;
211
+ const program = programs.find((candidate) => candidate.getSourceFile(file) !== undefined);
212
+ const source = program?.getSourceFile(file);
213
+ const cache = program === undefined ? undefined : caches.get(program);
214
+ const targets = program === undefined || source === undefined || cache === undefined
215
+ ? []
216
+ : importsOf(source, program, cache);
217
+ imports[file] = targets;
218
+ queue.push(...targets);
219
+ }
220
+ return imports;
221
+ };
222
+ /**
223
+ * The facts of a group of story files: what each story renders, and the import graph the rendered components reach.
224
+ *
225
+ * @param requests - the story files and their stories' exports.
226
+ * @returns the facts, or why a story file's program could not be read.
227
+ */
228
+ export const usageGraph = (requests) => {
229
+ const files = [];
230
+ const programs = new Set();
231
+ for (const request of requests) {
232
+ const docsProgram = programFor(request.storyFile);
233
+ if (typeof docsProgram === "string")
234
+ return docsProgram;
235
+ programs.add(docsProgram.program);
236
+ const usage = fileUsage(request, docsProgram.program);
237
+ if (usage !== undefined)
238
+ files.push(usage);
239
+ }
240
+ const starts = files.flatMap((file) => [
241
+ ...(file.component === undefined ? [] : [file.component.file]),
242
+ ...file.stories.flatMap((story) => story.renders.map((ref) => ref.file))
243
+ ]);
244
+ return { files, imports: reachedImports([...new Set(starts)], [...programs]) };
245
+ };
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AO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,OAAO,WAAW,KAAK,QAAQ;YAAE,OAAO,WAAW,CAAC;QACxD,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAClC,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;QACtD,IAAI,KAAK,KAAK,SAAS;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IACD,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QACrC,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC9D,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;KACzE,CAAC,CAAC;IACH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC;AACjF,CAAC,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * "Used in" joined from the facts the docs worker reads (`usageGraph.ts`): for each component of a `?forgebook-files`
3
+ * group, the other components whose stories render it or render a component whose modules import it.
4
+ *
5
+ * @remarks
6
+ * A story uses a component directly when its JSX renders it, and through another when a component it renders reaches
7
+ * the component's file through the package's own imports, followed all the way (Tree renders Row, Row renders
8
+ * DropLine: Tree's stories use DropLine). The file of a component the story renders counts only when an import reaches
9
+ * it, so a file's other exports are not used just for sitting beside one. The component's own stories, the components
10
+ * its meta names in `related`, and another page of the same component (two story files with one meta component) are
11
+ * left out. Pure: facts in, index out.
12
+ *
13
+ * @module
14
+ */
15
+ import { type UsageIndex } from "../usedIn.ts";
16
+ import type { UsageGraph } from "./usageGraph.ts";
17
+ /** What the join knows of a story file besides its facts: its component's title and its meta's `related`. */
18
+ export type UsageFile = {
19
+ /** The story file's absolute path. */
20
+ readonly storyFile: string;
21
+ /** Its title. */
22
+ readonly title: string;
23
+ /** The titles its meta names in `related`. */
24
+ readonly related: readonly string[];
25
+ };
26
+ /**
27
+ * A group's "Used in".
28
+ *
29
+ * @param graph - the facts the worker read.
30
+ * @param files - each story file's title and `related`.
31
+ */
32
+ export declare const joinedUsage: (graph: UsageGraph, files: readonly UsageFile[]) => UsageIndex;
33
+ //# sourceMappingURL=usageModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usageModule.d.ts","sourceRoot":"","sources":["../../../src/vite/usageModule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,KAAK,UAAU,EAAqC,MAAM,cAAc,CAAC;AAClF,OAAO,KAAK,EAAgB,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEhE,6GAA6G;AAC7G,MAAM,MAAM,SAAS,GAAG;IACtB,sCAAsC;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,iBAAiB;IACjB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC,CAAC;AAyHF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,UAAU,EAAE,OAAO,SAAS,SAAS,EAAE,KAAG,UAuB5E,CAAC"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * "Used in" joined from the facts the docs worker reads (`usageGraph.ts`): for each component of a `?forgebook-files`
3
+ * group, the other components whose stories render it or render a component whose modules import it.
4
+ *
5
+ * @remarks
6
+ * A story uses a component directly when its JSX renders it, and through another when a component it renders reaches
7
+ * the component's file through the package's own imports, followed all the way (Tree renders Row, Row renders
8
+ * DropLine: Tree's stories use DropLine). The file of a component the story renders counts only when an import reaches
9
+ * it, so a file's other exports are not used just for sitting beside one. The component's own stories, the components
10
+ * its meta names in `related`, and another page of the same component (two story files with one meta component) are
11
+ * left out. Pure: facts in, index out.
12
+ *
13
+ * @module
14
+ */
15
+ import { usersInOrder } from "../usedIn.js";
16
+ /**
17
+ * A component's key, unique across files.
18
+ *
19
+ * @param ref - the component.
20
+ */
21
+ const keyOf = (ref) => `${ref.file}#${ref.name}`;
22
+ /**
23
+ * The files a module reaches through its imports, itself left out unless an import comes back to it.
24
+ *
25
+ * @param imports - the import graph.
26
+ * @param start - the module.
27
+ */
28
+ const reachedFrom = (imports, start) => {
29
+ const reached = new Set();
30
+ const queue = [...(imports[start] ?? [])];
31
+ while (queue.length > 0) {
32
+ const file = queue.pop() ?? "";
33
+ if (reached.has(file))
34
+ continue;
35
+ reached.add(file);
36
+ queue.push(...(imports[file] ?? []));
37
+ }
38
+ return reached;
39
+ };
40
+ /**
41
+ * Values pushed into a map's list, the list made when it is missing.
42
+ *
43
+ * @param map - the map.
44
+ * @param key - the key.
45
+ * @param value - the value.
46
+ */
47
+ const pushed = (map, key, value) => {
48
+ map.set(key, [...(map.get(key) ?? []), value]);
49
+ };
50
+ /**
51
+ * The pages of the group's components.
52
+ *
53
+ * @param graph - the facts.
54
+ * @param fileOf - each story file's title and `related`, by its path.
55
+ */
56
+ const pagesOf = (graph, fileOf) => {
57
+ const byComponent = new Map();
58
+ const byFile = new Map();
59
+ const componentOf = new Map();
60
+ for (const facts of graph.files) {
61
+ const page = fileOf.get(facts.storyFile);
62
+ if (page === undefined || facts.component === undefined)
63
+ continue;
64
+ pushed(byComponent, keyOf(facts.component), page);
65
+ pushed(byFile, facts.component.file, page);
66
+ componentOf.set(page.title, keyOf(facts.component));
67
+ }
68
+ return { byComponent, byFile, componentOf };
69
+ };
70
+ /**
71
+ * Notes that a story uses a component, unless it is the component's own, the component's meta names it in `related`,
72
+ * or it is another page of the same component.
73
+ *
74
+ * @param found - what the join found so far.
75
+ * @param pages - the group's pages.
76
+ * @param target - the used component's page.
77
+ * @param user - the using component's page.
78
+ * @param story - the story's export.
79
+ * @param isDirect - whether the story renders the component itself.
80
+ */
81
+ const note = (found, pages, target, user, story, isDirect) => {
82
+ if (target.title === user.title || target.related.includes(user.title))
83
+ return;
84
+ const component = pages.componentOf.get(target.title);
85
+ if (component !== undefined && component === pages.componentOf.get(user.title))
86
+ return;
87
+ const users = found.get(target.title) ?? new Map();
88
+ found.set(target.title, users);
89
+ const entry = users.get(user.title) ?? { isDirect: false, stories: [] };
90
+ users.set(user.title, entry);
91
+ entry.isDirect ||= isDirect;
92
+ if (!entry.stories.includes(story))
93
+ entry.stories.push(story);
94
+ };
95
+ /**
96
+ * The pages a story uses: those of the components it renders (directly), those of the files they reach (through).
97
+ *
98
+ * @param renders - what the story renders.
99
+ * @param pages - the group's pages.
100
+ * @param reach - the files a module reaches.
101
+ */
102
+ const usedBy = (renders, pages, reach) => [
103
+ ...renders.flatMap((ref) => (pages.byComponent.get(keyOf(ref)) ?? []).map((target) => ({ target, isDirect: true }))),
104
+ ...[...new Set(renders.flatMap((ref) => [...reach(ref.file)]))].flatMap((file) => (pages.byFile.get(file) ?? []).map((target) => ({ target, isDirect: false })))
105
+ ];
106
+ /**
107
+ * A group's "Used in".
108
+ *
109
+ * @param graph - the facts the worker read.
110
+ * @param files - each story file's title and `related`.
111
+ */
112
+ export const joinedUsage = (graph, files) => {
113
+ const fileOf = new Map(files.map((file) => [file.storyFile, file]));
114
+ const pages = pagesOf(graph, fileOf);
115
+ const reachMemo = new Map();
116
+ const reach = (file) => {
117
+ const known = reachMemo.get(file) ?? reachedFrom(graph.imports, file);
118
+ reachMemo.set(file, known);
119
+ return known;
120
+ };
121
+ const found = new Map();
122
+ for (const facts of graph.files) {
123
+ const user = fileOf.get(facts.storyFile);
124
+ if (user === undefined)
125
+ continue;
126
+ for (const story of facts.stories)
127
+ for (const { target, isDirect } of usedBy(story.renders, pages, reach))
128
+ note(found, pages, target, user, story.exportName, isDirect);
129
+ }
130
+ return Object.fromEntries([...found].map(([title, users]) => [
131
+ title,
132
+ usersInOrder([...users].map(([user, entry]) => ({ title: user, ...entry })))
133
+ ]));
134
+ };
135
+ //# sourceMappingURL=usageModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usageModule.js","sourceRoot":"","sources":["../../../src/vite/usageModule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAwC,YAAY,EAAE,MAAM,cAAc,CAAC;AAalF;;;;GAIG;AACH,MAAM,KAAK,GAAG,CAAC,GAAiB,EAAU,EAAE,CAAC,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,WAAW,GAAG,CAAC,OAA8B,EAAE,KAAa,EAAe,EAAE;IACjF,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1C,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;QAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAS;QAChC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AA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K,CAAC,SAAS,CAAC,CAAC;QACzC,IAAI,IAAI,KAAK,SAAS;YAAE,SAAS;QACjC,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,OAAO;YAC/B,KAAK,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC;gBACpE,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,MAAM,CAAC,WAAW,CACvB,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QACjC,KAAK;QACL,YAAY,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAkB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC;KAC7F,CAAC,CACH,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The worst-case values a story can give a component: a long text with spaces, a word too long to break, scripts and
3
+ * emoji that change a line's height and width, a huge number. One set, for the stories `forgebook new` writes and for
4
+ * the catalogue's worst-case data, so both test the same edges.
5
+ *
6
+ * @module
7
+ */
8
+ /** A text long enough to wrap several times in any box. */
9
+ export declare const WORST_TEXT = "A label long enough to wrap onto several lines in any box it is given, with words of every length in it";
10
+ /** A word with no place to break, for a box that must cut or scroll it. */
11
+ export declare const WORST_WORD = "Supercalifragilisticexpialidocious_with_no_place_to_break_it_at_all_1234567890";
12
+ /** Scripts and emoji that change a line's height and width. */
13
+ export declare const WORST_SCRIPTS = "\u00DCn\u00EFc\u00F6d\u00E9 \u540D\u524D \u0645\u0631\u062D\u0628\u0627 \uD83D\uDC69\uD83C\uDFFD\u200D\uD83D\uDCBB";
14
+ /** A number with more digits than a box usually holds. */
15
+ export declare const WORST_NUMBER = 123456789012;
16
+ //# sourceMappingURL=worstCase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worstCase.d.ts","sourceRoot":"","sources":["../../src/worstCase.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,2DAA2D;AAC3D,eAAO,MAAM,UAAU,4GACoF,CAAC;AAE5G,2EAA2E;AAC3E,eAAO,MAAM,UAAU,mFAAmF,CAAC;AAE3G,+DAA+D;AAC/D,eAAO,MAAM,aAAa,uHAA6B,CAAC;AAExD,0DAA0D;AAC1D,eAAO,MAAM,YAAY,eAAkB,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The worst-case values a story can give a component: a long text with spaces, a word too long to break, scripts and
3
+ * emoji that change a line's height and width, a huge number. One set, for the stories `forgebook new` writes and for
4
+ * the catalogue's worst-case data, so both test the same edges.
5
+ *
6
+ * @module
7
+ */
8
+ /** A text long enough to wrap several times in any box. */
9
+ export const WORST_TEXT = "A label long enough to wrap onto several lines in any box it is given, with words of every length in it";
10
+ /** A word with no place to break, for a box that must cut or scroll it. */
11
+ export const WORST_WORD = "Supercalifragilisticexpialidocious_with_no_place_to_break_it_at_all_1234567890";
12
+ /** Scripts and emoji that change a line's height and width. */
13
+ export const WORST_SCRIPTS = "Ünïcödé 名前 مرحبا 👩🏽‍💻";
14
+ /** A number with more digits than a box usually holds. */
15
+ export const WORST_NUMBER = 123_456_789_012;
16
+ //# sourceMappingURL=worstCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worstCase.js","sourceRoot":"","sources":["../../src/worstCase.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,UAAU,GACrB,yGAAyG,CAAC;AAE5G,2EAA2E;AAC3E,MAAM,CAAC,MAAM,UAAU,GAAG,gFAAgF,CAAC;AAE3G,+DAA+D;AAC/D,MAAM,CAAC,MAAM,aAAa,GAAG,0BAA0B,CAAC;AAExD,0DAA0D;AAC1D,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forgebook",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "See every component in every theme, contrast, language and width: CSF stories, one frame per story, and a props table from the components' types.",
5
5
  "keywords": [
6
6
  "react",
@@ -97,6 +97,10 @@
97
97
  "types": "./dist/bin/forgebook-docs/catalogueMarkdown.d.ts",
98
98
  "default": "./dist/bin/forgebook-docs/catalogueMarkdown.js"
99
99
  },
100
+ "./catalogue-options": {
101
+ "types": "./dist/bin/forgebook-docs/catalogueOptions.d.ts",
102
+ "default": "./dist/bin/forgebook-docs/catalogueOptions.js"
103
+ },
100
104
  "./a11y": {
101
105
  "types": "./dist/src/a11y.d.ts",
102
106
  "default": "./dist/src/a11y.js"
@@ -152,6 +156,14 @@
152
156
  "./catalogue": {
153
157
  "types": "./dist/src/catalogue.d.ts",
154
158
  "default": "./dist/src/catalogue.js"
159
+ },
160
+ "./story-check": {
161
+ "types": "./dist/src/storyCheck.d.ts",
162
+ "default": "./dist/src/storyCheck.js"
163
+ },
164
+ "./spills": {
165
+ "types": "./dist/src/spills.d.ts",
166
+ "default": "./dist/src/spills.js"
155
167
  }
156
168
  },
157
169
  "dependencies": {
@@ -161,7 +173,7 @@
161
173
  "lightningcss": "1.33.0",
162
174
  "marked": "18.1.0",
163
175
  "typescript-6": "npm:typescript@6.0.3",
164
- "@forgebook/story-format": "0.1.2"
176
+ "@forgebook/story-format": "0.1.3"
165
177
  },
166
178
  "peerDependencies": {
167
179
  "@testing-library/dom": "^10.4.0",
@@ -1,24 +0,0 @@
1
- /**
2
- * The colour scheme and contrast switches at the toolbar's start, off while the compare view sets them or the story
3
- * fixes them.
4
- *
5
- * @module
6
- */
7
- import type { ReactNode } from "react";
8
- import type { FixedView } from "../storyGlobals.ts";
9
- import type { ViewState } from "../viewState.ts";
10
- /**
11
- * The colour scheme switch and the contrast switch, at the toolbar's start: the scheme as segments with icons, a
12
- * two-value contrast as a toggle (a longer one as segments).
13
- *
14
- * @param props - the view, its setter, and whether a story's page is shown (the compare view sets them there).
15
- */
16
- export declare const SchemeSwitches: ({ view, onViewChange, isStoryPage, fixed }: {
17
- /** The view shown. */
18
- readonly view: ViewState;
19
- /** Called with the changed view. */
20
- readonly onViewChange: (view: ViewState) => void;
21
- readonly isStoryPage: boolean;
22
- readonly fixed: FixedView;
23
- }) => ReactNode;
24
- //# sourceMappingURL=SchemeSwitches.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SchemeSwitches.d.ts","sourceRoot":"","sources":["../../../src/shell/SchemeSwitches.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAcjD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,4CAK5B;IACD,sBAAsB;IACtB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,oCAAoC;IACpC,QAAQ,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACjD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B,KAAG,SAiDH,CAAC"}
@@ -1,36 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { switchWithRole } from "../switches.js";
3
- import { useCatalogue } from "./catalogueContext.js";
4
- import { Icon } from "./icons.js";
5
- import { Segmented } from "./Segmented.js";
6
- import { STRINGS } from "./strings.js";
7
- import { switchValueIn, withSwitch } from "./switchView.js";
8
- /** The icon of each scheme a colour scheme switch's values draw in. */
9
- const SCHEME_ICONS = {
10
- light: "sun",
11
- dark: "moon",
12
- system: "monitor"
13
- };
14
- /**
15
- * The colour scheme switch and the contrast switch, at the toolbar's start: the scheme as segments with icons, a
16
- * two-value contrast as a toggle (a longer one as segments).
17
- *
18
- * @param props - the view, its setter, and whether a story's page is shown (the compare view sets them there).
19
- */
20
- export const SchemeSwitches = ({ view, onViewChange, isStoryPage, fixed }) => {
21
- const switches = useCatalogue().switches;
22
- const scheme = switchWithRole(switches, "colorScheme");
23
- const contrast = switchWithRole(switches, "contrast");
24
- const isFixed = (each) => fixed.switches[each.id] !== undefined;
25
- const isCompared = (each) => (isStoryPage && view.compare.includes(each.id)) || isFixed(each);
26
- const more = contrast?.values.find((value) => value.isMore === true);
27
- const standard = contrast?.values.find((value) => value.isMore !== true);
28
- if (scheme === undefined && contrast === undefined)
29
- return null;
30
- return (_jsxs("div", { className: "forgebook-toolbar__group", children: [scheme === undefined ? null : (_jsx(Segmented, { label: scheme.label, isDisabled: isCompared(scheme), disabledNote: isFixed(scheme) ? STRINGS.setByStory : undefined, options: scheme.values.map((value) => ({
31
- value: value.value,
32
- label: value.label,
33
- icon: SCHEME_ICONS[value.scheme ?? "light"]
34
- })), value: switchValueIn(view, scheme), onValueChange: (value) => onViewChange(withSwitch(view, scheme, value)) })), contrast === undefined || more === undefined || standard === undefined ? null : (_jsxs("button", { type: "button", className: "forgebook-button", title: isFixed(contrast) ? STRINGS.setByStory : contrast.label, "aria-pressed": switchValueIn(view, contrast) === more.value, disabled: isCompared(contrast), onClick: () => onViewChange(withSwitch(view, contrast, switchValueIn(view, contrast) === more.value ? standard.value : more.value)), children: [_jsx(Icon, { name: "contrast", size: 14 }), _jsx("span", { className: "forgebook-button__label", children: contrast.label })] }))] }));
35
- };
36
- //# sourceMappingURL=SchemeSwitches.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SchemeSwitches.js","sourceRoot":"","sources":["../../../src/shell/SchemeS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