forgebook 0.1.2 → 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 (345) hide show
  1. package/README.md +94 -5
  2. package/dist/bin/forgebook/agentClient.d.ts +39 -0
  3. package/dist/bin/forgebook/agentClient.d.ts.map +1 -0
  4. package/dist/bin/forgebook/agentClient.js +91 -0
  5. package/dist/bin/forgebook/agentClient.js.map +1 -0
  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 +54 -0
  11. package/dist/bin/forgebook/agentText.d.ts.map +1 -0
  12. package/dist/bin/forgebook/agentText.js +91 -0
  13. package/dist/bin/forgebook/agentText.js.map +1 -0
  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 +283 -79
  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 +38 -0
  42. package/dist/bin/forgebook/mcpTools.d.ts.map +1 -0
  43. package/dist/bin/forgebook/mcpTools.js +212 -0
  44. package/dist/bin/forgebook/mcpTools.js.map +1 -0
  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 +15 -10
  277. package/dist/src/viewState.d.ts.map +1 -1
  278. package/dist/src/viewState.js +35 -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 +120 -0
  289. package/dist/src/vite/agent.types.d.ts.map +1 -0
  290. package/dist/src/vite/agent.types.js +1 -0
  291. package/dist/src/vite/agent.types.js.map +1 -0
  292. package/dist/src/vite/agentApi.d.ts +106 -0
  293. package/dist/src/vite/agentApi.d.ts.map +1 -0
  294. package/dist/src/vite/agentApi.js +216 -0
  295. package/dist/src/vite/agentApi.js.map +1 -0
  296. package/dist/src/vite/agentRoutes.d.ts +50 -0
  297. package/dist/src/vite/agentRoutes.d.ts.map +1 -0
  298. package/dist/src/vite/agentRoutes.js +155 -0
  299. package/dist/src/vite/agentRoutes.js.map +1 -0
  300. package/dist/src/vite/configFile.d.ts +2 -1
  301. package/dist/src/vite/configFile.d.ts.map +1 -1
  302. package/dist/src/vite/configFile.js +29 -11
  303. package/dist/src/vite/configFile.js.map +1 -1
  304. package/dist/src/vite/docsExtractor.d.ts +26 -2
  305. package/dist/src/vite/docsExtractor.d.ts.map +1 -1
  306. package/dist/src/vite/docsExtractor.js +12 -9
  307. package/dist/src/vite/docsExtractor.js.map +1 -1
  308. package/dist/src/vite/docsWorker.js +18 -2
  309. package/dist/src/vite/docsWorker.js.map +1 -1
  310. package/dist/src/vite/forgebookPlugin.d.ts.map +1 -1
  311. package/dist/src/vite/forgebookPlugin.js +116 -16
  312. package/dist/src/vite/forgebookPlugin.js.map +1 -1
  313. package/dist/src/vite/indexStoryFile.d.ts +14 -0
  314. package/dist/src/vite/indexStoryFile.d.ts.map +1 -1
  315. package/dist/src/vite/indexStoryFile.js +13 -4
  316. package/dist/src/vite/indexStoryFile.js.map +1 -1
  317. package/dist/src/vite/mcpProtocol.d.ts +82 -0
  318. package/dist/src/vite/mcpProtocol.d.ts.map +1 -0
  319. package/dist/src/vite/mcpProtocol.js +184 -0
  320. package/dist/src/vite/mcpProtocol.js.map +1 -0
  321. package/dist/src/vite/pages.d.ts +12 -0
  322. package/dist/src/vite/pages.d.ts.map +1 -1
  323. package/dist/src/vite/pages.js +21 -0
  324. package/dist/src/vite/pages.js.map +1 -1
  325. package/dist/src/vite/storyFilesModule.d.ts +28 -1
  326. package/dist/src/vite/storyFilesModule.d.ts.map +1 -1
  327. package/dist/src/vite/storyFilesModule.js +34 -14
  328. package/dist/src/vite/storyFilesModule.js.map +1 -1
  329. package/dist/src/vite/usageGraph.d.ts +45 -0
  330. package/dist/src/vite/usageGraph.d.ts.map +1 -0
  331. package/dist/src/vite/usageGraph.js +246 -0
  332. package/dist/src/vite/usageGraph.js.map +1 -0
  333. package/dist/src/vite/usageModule.d.ts +33 -0
  334. package/dist/src/vite/usageModule.d.ts.map +1 -0
  335. package/dist/src/vite/usageModule.js +135 -0
  336. package/dist/src/vite/usageModule.js.map +1 -0
  337. package/dist/src/worstCase.d.ts +16 -0
  338. package/dist/src/worstCase.d.ts.map +1 -0
  339. package/dist/src/worstCase.js +16 -0
  340. package/dist/src/worstCase.js.map +1 -0
  341. package/package.json +18 -2
  342. package/dist/src/shell/SchemeSwitches.d.ts +0 -24
  343. package/dist/src/shell/SchemeSwitches.d.ts.map +0 -1
  344. package/dist/src/shell/SchemeSwitches.js +0 -36
  345. package/dist/src/shell/SchemeSwitches.js.map +0 -1
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Where each control of the toolbar and the View menu sits for the person using a catalogue: whether it is pinned on
3
+ * the toolbar, whether it is hidden in the View menu, and one order both follow.
4
+ *
5
+ * @remarks
6
+ * Two levels, kept apart: the catalogue decides which controls exist (its switches, and Forgebook's own it did not turn
7
+ * off) and which start on the toolbar; the person decides where each one shows and in what order. Pinned and hidden
8
+ * are two choices, not one: a control can sit on the toolbar and take no row in the View menu, sit in both, sit in
9
+ * the View menu only, or show nowhere (its value still applies from the address; it only takes no room, and the
10
+ * menu's hidden list still reaches it). The arrangement is a convenience of the person's, kept in their browser
11
+ * (`useStored`), never in the address: a link shares the values, not how someone arranged their bar. A stored
12
+ * arrangement is resolved against the catalogue as it is now: a control it no longer has is dropped, a new one goes to
13
+ * the View menu, at the end. Pure.
14
+ *
15
+ * @module
16
+ */
17
+ import type { CatalogueSettings, OwnControlId } from "./catalogue.ts";
18
+ import type { ViewSwitch } from "./switches.ts";
19
+ /** A control of the toolbar and the View menu: one of the catalogue's switches, or one of Forgebook's own. */
20
+ export type ToolbarControl = {
21
+ /** A switch the catalogue declares. */
22
+ readonly kind: "switch";
23
+ /** The switch's id. */
24
+ readonly id: string;
25
+ /** The switch. */
26
+ readonly switch: ViewSwitch;
27
+ } | {
28
+ /** One of Forgebook's own controls. */
29
+ readonly kind: "own";
30
+ /** The control's id. */
31
+ readonly id: OwnControlId;
32
+ };
33
+ /** A control and where it shows. */
34
+ export type PlacedControl = {
35
+ /** The control. */
36
+ readonly control: ToolbarControl;
37
+ /** Whether it sits on the toolbar. */
38
+ readonly isPinned: boolean;
39
+ /** Whether it takes no row in the View menu (its hidden list still holds it). */
40
+ readonly isHidden: boolean;
41
+ };
42
+ /** A person's arrangement, as their browser keeps it: every control's id in their order, and the pinned and hidden. */
43
+ export type ToolbarArrangement = {
44
+ /** The controls' ids, in the order the View menu lists them and the toolbar shows the pinned ones. */
45
+ readonly order: readonly string[];
46
+ /** The ids of the controls on the toolbar. */
47
+ readonly pinned: readonly string[];
48
+ /** The ids of the controls hidden in the View menu. */
49
+ readonly hidden: readonly string[];
50
+ };
51
+ /** The part of a catalogue's settings the arrangement reads. */
52
+ type ArrangedCatalogue = Pick<CatalogueSettings, "switches" | "ownControls" | "toolbar">;
53
+ /**
54
+ * Every control a catalogue shows, in its own order: its switches as it declares them, then Forgebook's own.
55
+ *
56
+ * @param catalogue - the catalogue's switches and controls.
57
+ */
58
+ export declare const catalogueControls: (catalogue: Pick<CatalogueSettings, "switches" | "ownControls">) => ToolbarControl[];
59
+ /**
60
+ * The controls as the catalogue places them before a person arranges anything: those it starts on the toolbar first,
61
+ * in its order and pinned, then the others, in their own order; none hidden.
62
+ *
63
+ * @param catalogue - the catalogue's switches, controls and starting toolbar.
64
+ */
65
+ export declare const defaultControls: (catalogue: ArrangedCatalogue) => PlacedControl[];
66
+ /**
67
+ * The controls placed by a person's arrangement, or by the catalogue when there is none: the arrangement's controls
68
+ * the catalogue still has, in its order, then the catalogue's new ones in the View menu.
69
+ *
70
+ * @param catalogue - the catalogue's switches, controls and starting toolbar.
71
+ * @param arrangement - the person's arrangement, when they made one.
72
+ */
73
+ export declare const placedControls: (catalogue: ArrangedCatalogue, arrangement: ToolbarArrangement | undefined) => PlacedControl[];
74
+ /**
75
+ * The arrangement that places the controls as they are.
76
+ *
77
+ * @param placed - the placed controls.
78
+ */
79
+ export declare const arrangementOf: (placed: readonly PlacedControl[]) => ToolbarArrangement;
80
+ /**
81
+ * The controls with one pinned on the toolbar or taken off it, keeping its position in the order.
82
+ *
83
+ * @param placed - the placed controls.
84
+ * @param id - the control's id.
85
+ * @param isPinned - whether it sits on the toolbar.
86
+ */
87
+ export declare const withPinned: (placed: readonly PlacedControl[], id: string, isPinned: boolean) => PlacedControl[];
88
+ /**
89
+ * The controls with one hidden in the View menu or shown there again, keeping its position in the order.
90
+ *
91
+ * @param placed - the placed controls.
92
+ * @param id - the control's id.
93
+ * @param isHidden - whether it takes no row in the View menu.
94
+ */
95
+ export declare const withHidden: (placed: readonly PlacedControl[], id: string, isHidden: boolean) => PlacedControl[];
96
+ /**
97
+ * The controls with one moved to a position among the View menu's rows (hidden ones left out); a hidden control
98
+ * keeps its position in the whole order, so showing it again brings it back where it was.
99
+ *
100
+ * @param placed - the placed controls.
101
+ * @param id - the moved control's id; a hidden one or an unknown one leaves the order as it is.
102
+ * @param index - its new position among the shown controls, clamped to them.
103
+ */
104
+ export declare const withPosition: (placed: readonly PlacedControl[], id: string, index: number) => PlacedControl[];
105
+ /**
106
+ * A stored arrangement read back, or none when the text holds none or not one this module wrote (an older format,
107
+ * an edit by hand): the catalogue's placing then applies.
108
+ *
109
+ * @param stored - the stored text, or none.
110
+ */
111
+ export declare const readArrangement: (stored: string | null) => ToolbarArrangement | undefined;
112
+ /**
113
+ * The text an arrangement is stored as; empty for none, so the catalogue's placing applies.
114
+ *
115
+ * @param arrangement - the arrangement, or none.
116
+ */
117
+ export declare const arrangementText: (arrangement: ToolbarArrangement | undefined) => string;
118
+ export {};
119
+ //# sourceMappingURL=toolbarLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolbarLayout.d.ts","sourceRoot":"","sources":["../../src/toolbarLayout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,8GAA8G;AAC9G,MAAM,MAAM,cAAc,GACtB;IACE,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,uBAAuB;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,kBAAkB;IAClB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B,GACD;IACE,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,wBAAwB;IACxB,QAAQ,CAAC,EAAE,EAAE,YAAY,CAAC;CAC3B,CAAC;AAEN,oCAAoC;AACpC,MAAM,MAAM,aAAa,GAAG;IAC1B,mBAAmB;IACnB,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,sCAAsC;IACtC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IA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,MAAM,EACV,OAAO,MAAM,KACZ,aAAa,EAef,CAAC;AAUF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,GAAG,IAAI,KAAG,kBAAkB,GAAG,SAa5E,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,aAAa,kBAAkB,GAAG,SAAS,KAAG,MAChB,CAAC"}
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Where each control of the toolbar and the View menu sits for the person using a catalogue: whether it is pinned on
3
+ * the toolbar, whether it is hidden in the View menu, and one order both follow.
4
+ *
5
+ * @remarks
6
+ * Two levels, kept apart: the catalogue decides which controls exist (its switches, and Forgebook's own it did not turn
7
+ * off) and which start on the toolbar; the person decides where each one shows and in what order. Pinned and hidden
8
+ * are two choices, not one: a control can sit on the toolbar and take no row in the View menu, sit in both, sit in
9
+ * the View menu only, or show nowhere (its value still applies from the address; it only takes no room, and the
10
+ * menu's hidden list still reaches it). The arrangement is a convenience of the person's, kept in their browser
11
+ * (`useStored`), never in the address: a link shares the values, not how someone arranged their bar. A stored
12
+ * arrangement is resolved against the catalogue as it is now: a control it no longer has is dropped, a new one goes to
13
+ * the View menu, at the end. Pure.
14
+ *
15
+ * @module
16
+ */
17
+ /**
18
+ * Every control a catalogue shows, in its own order: its switches as it declares them, then Forgebook's own.
19
+ *
20
+ * @param catalogue - the catalogue's switches and controls.
21
+ */
22
+ export const catalogueControls = (catalogue) => [
23
+ ...catalogue.switches.map((each) => ({ kind: "switch", id: each.id, switch: each })),
24
+ ...catalogue.ownControls.map((id) => ({ kind: "own", id }))
25
+ ];
26
+ /**
27
+ * The controls as the catalogue places them before a person arranges anything: those it starts on the toolbar first,
28
+ * in its order and pinned, then the others, in their own order; none hidden.
29
+ *
30
+ * @param catalogue - the catalogue's switches, controls and starting toolbar.
31
+ */
32
+ export const defaultControls = (catalogue) => {
33
+ const controls = catalogueControls(catalogue);
34
+ const pinned = catalogue.toolbar.flatMap((id) => controls.filter((control) => control.id === id));
35
+ return [
36
+ ...pinned.map((control) => ({ control, isPinned: true, isHidden: false })),
37
+ ...controls
38
+ .filter((control) => !catalogue.toolbar.includes(control.id))
39
+ .map((control) => ({ control, isPinned: false, isHidden: false }))
40
+ ];
41
+ };
42
+ /**
43
+ * The controls placed by a person's arrangement, or by the catalogue when there is none: the arrangement's controls
44
+ * the catalogue still has, in its order, then the catalogue's new ones in the View menu.
45
+ *
46
+ * @param catalogue - the catalogue's switches, controls and starting toolbar.
47
+ * @param arrangement - the person's arrangement, when they made one.
48
+ */
49
+ export const placedControls = (catalogue, arrangement) => {
50
+ if (arrangement === undefined)
51
+ return defaultControls(catalogue);
52
+ const controls = catalogueControls(catalogue);
53
+ const kept = arrangement.order.flatMap((id) => controls
54
+ .filter((control) => control.id === id)
55
+ .map((control) => ({
56
+ control,
57
+ isPinned: arrangement.pinned.includes(id),
58
+ isHidden: arrangement.hidden.includes(id)
59
+ })));
60
+ const added = controls
61
+ .filter((control) => !arrangement.order.includes(control.id))
62
+ .map((control) => ({ control, isPinned: false, isHidden: false }));
63
+ return [...kept, ...added];
64
+ };
65
+ /**
66
+ * The arrangement that places the controls as they are.
67
+ *
68
+ * @param placed - the placed controls.
69
+ */
70
+ export const arrangementOf = (placed) => ({
71
+ order: placed.map((each) => each.control.id),
72
+ pinned: placed.filter((each) => each.isPinned).map((each) => each.control.id),
73
+ hidden: placed.filter((each) => each.isHidden).map((each) => each.control.id)
74
+ });
75
+ /**
76
+ * The controls with one pinned on the toolbar or taken off it, keeping its position in the order.
77
+ *
78
+ * @param placed - the placed controls.
79
+ * @param id - the control's id.
80
+ * @param isPinned - whether it sits on the toolbar.
81
+ */
82
+ export const withPinned = (placed, id, isPinned) => placed.map((each) => (each.control.id === id ? { ...each, isPinned } : each));
83
+ /**
84
+ * The controls with one hidden in the View menu or shown there again, keeping its position in the order.
85
+ *
86
+ * @param placed - the placed controls.
87
+ * @param id - the control's id.
88
+ * @param isHidden - whether it takes no row in the View menu.
89
+ */
90
+ export const withHidden = (placed, id, isHidden) => placed.map((each) => (each.control.id === id ? { ...each, isHidden } : each));
91
+ /**
92
+ * The controls with one moved to a position among the View menu's rows (hidden ones left out); a hidden control
93
+ * keeps its position in the whole order, so showing it again brings it back where it was.
94
+ *
95
+ * @param placed - the placed controls.
96
+ * @param id - the moved control's id; a hidden one or an unknown one leaves the order as it is.
97
+ * @param index - its new position among the shown controls, clamped to them.
98
+ */
99
+ export const withPosition = (placed, id, index) => {
100
+ const shown = placed.filter((each) => !each.isHidden);
101
+ const moved = shown.find((each) => each.control.id === id);
102
+ if (moved === undefined)
103
+ return [...placed];
104
+ const others = shown.filter((each) => each !== moved);
105
+ const at = Math.min(Math.max(index, 0), others.length);
106
+ const reordered = [...others.slice(0, at), moved, ...others.slice(at)];
107
+ // the shown controls take the shown positions, in their new order; the hidden ones stay where they were
108
+ let next = 0;
109
+ return placed.map((each) => {
110
+ if (each.isHidden)
111
+ return each;
112
+ const taken = reordered[next] ?? each;
113
+ next += 1;
114
+ return taken;
115
+ });
116
+ };
117
+ /**
118
+ * The strings of a list read back, the rest left out.
119
+ *
120
+ * @param value - what the stored text holds there.
121
+ */
122
+ const idsOf = (value) => Array.isArray(value) ? value.filter((id) => typeof id === "string") : [];
123
+ /**
124
+ * A stored arrangement read back, or none when the text holds none or not one this module wrote (an older format,
125
+ * an edit by hand): the catalogue's placing then applies.
126
+ *
127
+ * @param stored - the stored text, or none.
128
+ */
129
+ export const readArrangement = (stored) => {
130
+ if (stored === null || stored === "")
131
+ return undefined;
132
+ let parsed;
133
+ try {
134
+ parsed = JSON.parse(stored);
135
+ }
136
+ catch {
137
+ return undefined;
138
+ }
139
+ if (typeof parsed !== "object" || parsed === null)
140
+ return undefined;
141
+ if (!("order" in parsed) || !Array.isArray(parsed.order))
142
+ return undefined;
143
+ if (!("pinned" in parsed) || !Array.isArray(parsed.pinned))
144
+ return undefined;
145
+ if (!("hidden" in parsed) || !Array.isArray(parsed.hidden))
146
+ return undefined;
147
+ return { order: idsOf(parsed.order), pinned: idsOf(parsed.pinned), hidden: idsOf(parsed.hidden) };
148
+ };
149
+ /**
150
+ * The text an arrangement is stored as; empty for none, so the catalogue's placing applies.
151
+ *
152
+ * @param arrangement - the arrangement, or none.
153
+ */
154
+ export const arrangementText = (arrangement) => arrangement === undefined ? "" : JSON.stringify(arrangement);
155
+ //# sourceMappingURL=toolbarLayout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolbarLayout.js","sourceRoot":"","sources":["../../src/toolbarLayout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA6CH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,SAA8D,EAC5C,EAAE,CAAC;IACrB,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACpG,GAAG,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,EAAkB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;CAC5E,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,SAA4B,EAAmB,EAAE;IAC/E,MAAM,QAAQ,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAClG,OAAO;QACL,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAiB,EAAE,CAAC,CAAC,EAAE,OAAO,EA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,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;AACpG,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,WAA2C,EAAU,EAAE,CACrF,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * "Used in": for each component of a source, the other components whose stories use it, directly (their JSX renders
3
+ * it) or through another component that renders it; the shape the plugin's usage modules answer, read by the
4
+ * component page and the agents' answers.
5
+ *
6
+ * @remarks
7
+ * Each `?forgebook-files` group answers for its own files (`usage`, loaded only when asked): a source's groups are
8
+ * merged here. A component lists the stories of its own source only, never its own stories nor the components its meta
9
+ * names in `related`. Pure apart from the loaders it calls.
10
+ *
11
+ * @module
12
+ */
13
+ import type { StorySource } from "@forgebook/story-format/source";
14
+ /** A component whose stories use another. */
15
+ export type UsingComponent = {
16
+ /** Its title (`Navigation/Tree`). */
17
+ readonly title: string;
18
+ /** Whether one of its stories renders the component itself, not only through another component. */
19
+ readonly isDirect: boolean;
20
+ /** The exports of its stories that use the component, in their file's order. */
21
+ readonly stories: readonly string[];
22
+ };
23
+ /** For each component of a group or a source, by title, the components that use it, direct ones first. */
24
+ export type UsageIndex = Readonly<Record<string, readonly UsingComponent[]>>;
25
+ /** How many using components a page shows before "and N more". */
26
+ export declare const USED_IN_SHOWN = 12;
27
+ /**
28
+ * Whether a usage module's answer is a usage index.
29
+ *
30
+ * @param value - what the module exports by default.
31
+ */
32
+ export declare const isUsageIndex: (value: unknown) => value is UsageIndex;
33
+ /**
34
+ * The using components in the order a page shows them: direct ones first, then by how many stories use the
35
+ * component, then by title.
36
+ *
37
+ * @param users - the using components.
38
+ */
39
+ export declare const usersInOrder: (users: readonly UsingComponent[]) => UsingComponent[];
40
+ /**
41
+ * Several groups' usage as one: a component's users from every group, in the page's order.
42
+ *
43
+ * @param indexes - the groups' usage.
44
+ */
45
+ export declare const mergedUsage: (indexes: readonly UsageIndex[]) => UsageIndex;
46
+ /**
47
+ * A source's usage: each group's usage module loaded and merged; an empty index when its groups have none (a
48
+ * catalogue that turned "Used in" off, a source built before it).
49
+ *
50
+ * @param source - the source.
51
+ * @returns the usage, or why a group's could not be read.
52
+ */
53
+ export declare const sourceUsage: (source: StorySource) => Promise<UsageIndex | string>;
54
+ /**
55
+ * A source's usage loader: the same function for the same source, its answer read once.
56
+ *
57
+ * @param source - the source.
58
+ */
59
+ export declare const usageLoader: (source: StorySource) => (() => Promise<UsageIndex | string>);
60
+ //# sourceMappingURL=usedIn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usedIn.d.ts","sourceRoot":"","sources":["../../src/usedIn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAElE,6CAA6C;AAC7C,MAAM,MAAM,cAAc,GAAG;IAC3B,qCAAqC;IACrC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,mGAAmG;IACnG,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,gFAAgF;IAChF,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC,CAAC;AAEF,0GAA0G;AAC1G,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC,CAAC,CAAC;AAE7E,kEAAkE;AAClE,eAAO,MAAM,aAAa,KAAK,CAAC;AAyBhC;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,UAGuC,CAAC;AAE/F;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,SAAS,cAAc,EAAE,KAAG,cAAc,EAM3E,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,SAAS,UAAU,EAAE,KAAG,UAK5D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAU,QAAQ,WAAW,KAAG,OAAO,CAAC,UAAU,GAAG,MAAM,CAiBlF,CAAC;AAKF;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,WAAW,KAAG,CAAC,MAAM,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,CAUpF,CAAC"}
@@ -0,0 +1,92 @@
1
+ /** How many using components a page shows before "and N more". */
2
+ export const USED_IN_SHOWN = 12;
3
+ /**
4
+ * Whether a value is a list of strings.
5
+ *
6
+ * @param value - the value.
7
+ */
8
+ const isStrings = (value) => Array.isArray(value) && value.every((each) => typeof each === "string");
9
+ /**
10
+ * Whether a value is a using component.
11
+ *
12
+ * @param value - the value.
13
+ */
14
+ const isUsingComponent = (value) => typeof value === "object" &&
15
+ value !== null &&
16
+ "title" in value &&
17
+ typeof value.title === "string" &&
18
+ "isDirect" in value &&
19
+ typeof value.isDirect === "boolean" &&
20
+ "stories" in value &&
21
+ isStrings(value.stories);
22
+ /**
23
+ * Whether a usage module's answer is a usage index.
24
+ *
25
+ * @param value - what the module exports by default.
26
+ */
27
+ export const isUsageIndex = (value) => typeof value === "object" &&
28
+ value !== null &&
29
+ Object.values(value).every((users) => Array.isArray(users) && users.every(isUsingComponent));
30
+ /**
31
+ * The using components in the order a page shows them: direct ones first, then by how many stories use the
32
+ * component, then by title.
33
+ *
34
+ * @param users - the using components.
35
+ */
36
+ export const usersInOrder = (users) => [...users].sort((first, second) => Number(second.isDirect) - Number(first.isDirect) ||
37
+ second.stories.length - first.stories.length ||
38
+ first.title.localeCompare(second.title));
39
+ /**
40
+ * Several groups' usage as one: a component's users from every group, in the page's order.
41
+ *
42
+ * @param indexes - the groups' usage.
43
+ */
44
+ export const mergedUsage = (indexes) => {
45
+ const merged = {};
46
+ for (const index of indexes)
47
+ for (const [title, users] of Object.entries(index))
48
+ merged[title] = [...(merged[title] ?? []), ...users];
49
+ return Object.fromEntries(Object.entries(merged).map(([title, users]) => [title, usersInOrder(users)]));
50
+ };
51
+ /**
52
+ * A source's usage: each group's usage module loaded and merged; an empty index when its groups have none (a
53
+ * catalogue that turned "Used in" off, a source built before it).
54
+ *
55
+ * @param source - the source.
56
+ * @returns the usage, or why a group's could not be read.
57
+ */
58
+ export const sourceUsage = async (source) => {
59
+ const loaded = await Promise.all(source.files.flatMap((group) => (group.usage === undefined ? [] : [group.usage()])));
60
+ const indexes = [];
61
+ for (const answer of loaded) {
62
+ if (typeof answer === "object" &&
63
+ answer !== null &&
64
+ "error" in answer &&
65
+ typeof answer.error === "string")
66
+ return answer.error;
67
+ if (!isUsageIndex(answer))
68
+ return "A usage module answered something that is not a usage index";
69
+ indexes.push(answer);
70
+ }
71
+ return mergedUsage(indexes);
72
+ };
73
+ /** Each source's loader, made once, so a page asks for its usage once and its loader keeps one identity. */
74
+ const LOADERS = new WeakMap();
75
+ /**
76
+ * A source's usage loader: the same function for the same source, its answer read once.
77
+ *
78
+ * @param source - the source.
79
+ */
80
+ export const usageLoader = (source) => {
81
+ const known = LOADERS.get(source);
82
+ if (known !== undefined)
83
+ return known;
84
+ let answer;
85
+ const load = () => {
86
+ answer ??= sourceUsage(source);
87
+ return answer;
88
+ };
89
+ LOADERS.set(source, load);
90
+ return load;
91
+ };
92
+ //# sourceMappingURL=usedIn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usedIn.js","sourceRoot":"","sources":["../../src/usedIn.ts"],"names":[],"mappings":"AA2BA,kEAAkE;AAClE,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAEhC;;;;GAIG;AACH,MAAM,SAAS,GAAG,CAAC,KAAc,EAA8B,EAAE,CAC/D,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC;AAE1E;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I,OAAO,EAAmD,CAAC;AAE/E;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAmB,EAAwC,EAAE;IACvF,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,MAAgD,CAAC;IACrD,MAAM,IAAI,GAAG,GAAiC,EAAE;QAC9C,MAAM,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC;QAC/B,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC1B,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -85,7 +85,7 @@ export declare const isComparing: (view: ViewState) => boolean;
85
85
  /** Every tool, in the bar's order. */
86
86
  export declare const MEASURE_TOOLS: readonly MeasureTool[];
87
87
  /** What the view reads of a catalogue: its switches and the lists its values are checked against. */
88
- export type ViewCatalogue = Pick<CatalogueSettings, "switches" | "widthRange" | "zooms" | "textSizes" | "backdrops" | "tabs">;
88
+ export type ViewCatalogue = Pick<CatalogueSettings, "switches" | "widthRange" | "zooms" | "textSizes" | "backdrops" | "tabs" | "ownControls">;
89
89
  /**
90
90
  * A width kept in a catalogue's range, in whole pixels.
91
91
  *
@@ -126,19 +126,15 @@ export declare const defaultView: (catalogue: ViewCatalogue) => ViewState;
126
126
  */
127
127
  export declare const viewParams: (view: ViewState, switches: readonly ViewSwitch[]) => URLSearchParams;
128
128
  /**
129
- * Whether one of the View menu's settings is changed (a switch the toolbar does not show itself, the background,
130
- * the style sheets, the text size): the menu button then shows a dot, so a view is never left changed by mistake.
129
+ * Whether one of the given controls' values is changed (a switch, the background, the style sheets, the text size;
130
+ * the stage's width is not a view setting): the View menu's button shows a dot for the controls it holds, so a view
131
+ * is never left changed by mistake, even by a control the person hid.
131
132
  *
132
133
  * @param view - the view.
133
134
  * @param switches - the catalogue's switches.
135
+ * @param ids - the controls' ids.
134
136
  */
135
- export declare const hasViewChanges: (view: ViewState, switches: readonly ViewSwitch[]) => boolean;
136
- /**
137
- * Whether a switch sits in the View menu: every one but the colour scheme and the contrast, which the toolbar shows.
138
- *
139
- * @param each - the switch.
140
- */
141
- export declare const isMenuSwitch: (each: ViewSwitch) => boolean;
137
+ export declare const hasViewChanges: (view: ViewState, switches: readonly ViewSwitch[], ids: readonly string[]) => boolean;
142
138
  /**
143
139
  * The address of a story's frame.
144
140
  *
@@ -191,4 +187,13 @@ export declare const codeGlobalsOf: (view: Pick<ViewState, "switches">, switches
191
187
  * @param search - the catalogue's query (`theme=dark&lang=it`), with or without `?`.
192
188
  */
193
189
  export declare const frameAddressOf: (frameUrl: string, id: string, search: string) => string;
190
+ /**
191
+ * The address of a story's page in the catalogue from a catalogue's address query, for a tool that does not know the
192
+ * catalogue's switches: the story selected, the view kept as written.
193
+ *
194
+ * @param pageUrl - the catalogue's page (`http://localhost:5173/`).
195
+ * @param id - the story's id.
196
+ * @param search - the view's query (`theme=dark&lang=it`), with or without `?`.
197
+ */
198
+ export declare const storyAddressOf: (pageUrl: string, id: string, search: string) => string;
194
199
  //# sourceMappingURL=viewState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"viewState.d.ts","sourceRoot":"","sources":["../../src/viewState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAiC,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAE/E;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AAEpC,gDAAgD;AAChD,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC,oEAAoE;AACpE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,CAAC;AAE7D,qHAAqH;AACrH,MAAM,MAAM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;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,EAAE,IAAI,MAAM,EAAE,QAAQ,MAAM,KAAG,MAM5E,CAAC"}
@@ -90,7 +90,8 @@ const switchValuesOf = (params, switches) => Object.fromEntries(switches.map((ea
90
90
  * @param value - the parameter.
91
91
  * @param switches - the declared switches.
92
92
  */
93
- const compareAxesOf = (value, switches) => {
93
+ const compareAxesOf = (value, catalogue) => {
94
+ const { switches, ownControls } = catalogue;
94
95
  if (value === null || value === "")
95
96
  return [];
96
97
  const scheme = switchWithRole(switches, "colorScheme");
@@ -101,7 +102,10 @@ const compareAxesOf = (value, switches) => {
101
102
  language: [switchWithRole(switches, "language")?.id]
102
103
  };
103
104
  const named = legacy[value] ?? value.split(",");
104
- const known = [...switches.map((each) => each.id), ...OWN_COMPARE_AXES];
105
+ const known = [
106
+ ...switches.map((each) => each.id),
107
+ ...OWN_COMPARE_AXES.filter((axis) => ownControls.includes(axis))
108
+ ];
105
109
  return named.filter((axis) => axis !== undefined && known.includes(axis)).slice(0, 2);
106
110
  };
107
111
  /**
@@ -112,12 +116,14 @@ const compareAxesOf = (value, switches) => {
112
116
  */
113
117
  export const parseView = (search, catalogue) => {
114
118
  const params = new URLSearchParams(search);
119
+ // a control the catalogue turned off keeps its default, whatever the address says
120
+ const shown = (control) => catalogue.ownControls.includes(control) ? params.get(control) : null;
115
121
  return {
116
122
  switches: switchValuesOf(params, catalogue.switches),
117
- backdrop: choice(params.get("backdrop"), catalogue.backdrops.map((backdrop) => backdrop.id), DEFAULT_VIEW.backdrop),
118
- sheets: choice(params.get("sheets"), SHEETS_CHOICES, DEFAULT_VIEW.sheets),
119
- text: choice(params.get("text"), catalogue.textSizes, DEFAULT_VIEW.text),
120
- compare: compareAxesOf(params.get("compare"), catalogue.switches),
123
+ backdrop: choice(shown("backdrop"), catalogue.backdrops.map((backdrop) => backdrop.id), DEFAULT_VIEW.backdrop),
124
+ sheets: choice(shown("sheets"), SHEETS_CHOICES, DEFAULT_VIEW.sheets),
125
+ text: choice(shown("text"), catalogue.textSizes, DEFAULT_VIEW.text),
126
+ compare: compareAxesOf(params.get("compare"), catalogue),
121
127
  width: stageWidth(params.get("width"), catalogue.widthRange),
122
128
  height: stageHeight(params.get("height")),
123
129
  isPanelOpen: params.get("panel") !== "closed",
@@ -189,22 +195,18 @@ export const viewParams = (view, switches) => {
189
195
  return params;
190
196
  };
191
197
  /**
192
- * Whether one of the View menu's settings is changed (a switch the toolbar does not show itself, the background,
193
- * the style sheets, the text size): the menu button then shows a dot, so a view is never left changed by mistake.
198
+ * Whether one of the given controls' values is changed (a switch, the background, the style sheets, the text size;
199
+ * the stage's width is not a view setting): the View menu's button shows a dot for the controls it holds, so a view
200
+ * is never left changed by mistake, even by a control the person hid.
194
201
  *
195
202
  * @param view - the view.
196
203
  * @param switches - the catalogue's switches.
204
+ * @param ids - the controls' ids.
197
205
  */
198
- export const hasViewChanges = (view, switches) => switches.some((each) => isMenuSwitch(each) && !isDefault(view, each)) ||
199
- view.backdrop !== DEFAULT_VIEW.backdrop ||
200
- view.sheets !== DEFAULT_VIEW.sheets ||
201
- view.text !== DEFAULT_VIEW.text;
202
- /**
203
- * Whether a switch sits in the View menu: every one but the colour scheme and the contrast, which the toolbar shows.
204
- *
205
- * @param each - the switch.
206
- */
207
- export const isMenuSwitch = (each) => each.role !== "colorScheme" && each.role !== "contrast";
206
+ export const hasViewChanges = (view, switches, ids) => switches.some((each) => ids.includes(each.id) && !isDefault(view, each)) ||
207
+ (ids.includes("backdrop") && view.backdrop !== DEFAULT_VIEW.backdrop) ||
208
+ (ids.includes("sheets") && view.sheets !== DEFAULT_VIEW.sheets) ||
209
+ (ids.includes("text") && view.text !== DEFAULT_VIEW.text);
208
210
  /**
209
211
  * The address of a story's frame.
210
212
  *
@@ -300,4 +302,19 @@ export const frameAddressOf = (frameUrl, id, search) => {
300
302
  params.set("story", id);
301
303
  return `${frameUrl}?${params.toString()}`;
302
304
  };
305
+ /**
306
+ * The address of a story's page in the catalogue from a catalogue's address query, for a tool that does not know the
307
+ * catalogue's switches: the story selected, the view kept as written.
308
+ *
309
+ * @param pageUrl - the catalogue's page (`http://localhost:5173/`).
310
+ * @param id - the story's id.
311
+ * @param search - the view's query (`theme=dark&lang=it`), with or without `?`.
312
+ */
313
+ export const storyAddressOf = (pageUrl, id, search) => {
314
+ const params = new URLSearchParams(search);
315
+ params.delete("component");
316
+ params.delete("story");
317
+ params.set("story", id);
318
+ return `${pageUrl}?${params.toString()}`;
319
+ };
303
320
  //# sourceMappingURL=viewState.js.map