forgebook 0.0.0-stage → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (493) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +136 -2
  3. package/dist/bin/forgebook/catalogueVite.d.ts +16 -0
  4. package/dist/bin/forgebook/catalogueVite.d.ts.map +1 -0
  5. package/dist/bin/forgebook/catalogueVite.js +15 -0
  6. package/dist/bin/forgebook/catalogueVite.js.map +1 -0
  7. package/dist/bin/forgebook/forgebook.d.mts +3 -0
  8. package/dist/bin/forgebook/forgebook.d.mts.map +1 -0
  9. package/dist/bin/forgebook/forgebook.mjs +93 -0
  10. package/dist/bin/forgebook/forgebook.mjs.map +1 -0
  11. package/dist/bin/forgebook-docs/catalogueDocs.types.d.ts +90 -0
  12. package/dist/bin/forgebook-docs/catalogueDocs.types.d.ts.map +1 -0
  13. package/dist/bin/forgebook-docs/catalogueDocs.types.js +1 -0
  14. package/dist/bin/forgebook-docs/catalogueDocs.types.js.map +1 -0
  15. package/dist/bin/forgebook-docs/catalogueMarkdown.d.ts +9 -0
  16. package/dist/bin/forgebook-docs/catalogueMarkdown.d.ts.map +1 -0
  17. package/dist/bin/forgebook-docs/catalogueMarkdown.js +132 -0
  18. package/dist/bin/forgebook-docs/catalogueMarkdown.js.map +1 -0
  19. package/dist/bin/forgebook-docs/collectDocs.d.ts +17 -0
  20. package/dist/bin/forgebook-docs/collectDocs.d.ts.map +1 -0
  21. package/dist/bin/forgebook-docs/collectDocs.js +115 -0
  22. package/dist/bin/forgebook-docs/collectDocs.js.map +1 -0
  23. package/dist/bin/forgebook-docs/forgebook-docs.d.mts +3 -0
  24. package/dist/bin/forgebook-docs/forgebook-docs.d.mts.map +1 -0
  25. package/dist/bin/forgebook-docs/forgebook-docs.mjs +114 -0
  26. package/dist/bin/forgebook-docs/forgebook-docs.mjs.map +1 -0
  27. package/dist/bin/forgebook-docs/moduleDocs.d.ts +9 -0
  28. package/dist/bin/forgebook-docs/moduleDocs.d.ts.map +1 -0
  29. package/dist/bin/forgebook-docs/moduleDocs.js +62 -0
  30. package/dist/bin/forgebook-docs/moduleDocs.js.map +1 -0
  31. package/dist/bin/forgebook-docs/sassDocs.d.ts +20 -0
  32. package/dist/bin/forgebook-docs/sassDocs.d.ts.map +1 -0
  33. package/dist/bin/forgebook-docs/sassDocs.js +77 -0
  34. package/dist/bin/forgebook-docs/sassDocs.js.map +1 -0
  35. package/dist/bin/forgebook-texts/forgebook-texts.d.mts +3 -0
  36. package/dist/bin/forgebook-texts/forgebook-texts.d.mts.map +1 -0
  37. package/dist/bin/forgebook-texts/forgebook-texts.mjs +94 -0
  38. package/dist/bin/forgebook-texts/forgebook-texts.mjs.map +1 -0
  39. package/dist/bin/forgebook-texts/storyTextsReport.d.ts +26 -0
  40. package/dist/bin/forgebook-texts/storyTextsReport.d.ts.map +1 -0
  41. package/dist/bin/forgebook-texts/storyTextsReport.js +35 -0
  42. package/dist/bin/forgebook-texts/storyTextsReport.js.map +1 -0
  43. package/dist/bin/forgebook-texts/storyTextsReport.types.d.ts +25 -0
  44. package/dist/bin/forgebook-texts/storyTextsReport.types.d.ts.map +1 -0
  45. package/dist/bin/forgebook-texts/storyTextsReport.types.js +7 -0
  46. package/dist/bin/forgebook-texts/storyTextsReport.types.js.map +1 -0
  47. package/dist/src/a11y.d.ts +28 -0
  48. package/dist/src/a11y.d.ts.map +1 -0
  49. package/dist/src/a11y.js +29 -0
  50. package/dist/src/a11y.js.map +1 -0
  51. package/dist/src/argTypes.d.ts +114 -0
  52. package/dist/src/argTypes.d.ts.map +1 -0
  53. package/dist/src/argTypes.js +254 -0
  54. package/dist/src/argTypes.js.map +1 -0
  55. package/dist/src/backdrops.d.ts +88 -0
  56. package/dist/src/backdrops.d.ts.map +1 -0
  57. package/dist/src/backdrops.js +202 -0
  58. package/dist/src/backdrops.js.map +1 -0
  59. package/dist/src/catalogue.d.ts +120 -0
  60. package/dist/src/catalogue.d.ts.map +1 -0
  61. package/dist/src/catalogue.js +80 -0
  62. package/dist/src/catalogue.js.map +1 -0
  63. package/dist/src/componentDocs.d.ts +98 -0
  64. package/dist/src/componentDocs.d.ts.map +1 -0
  65. package/dist/src/componentDocs.js +47 -0
  66. package/dist/src/componentDocs.js.map +1 -0
  67. package/dist/src/frame/checkStory.d.ts +20 -0
  68. package/dist/src/frame/checkStory.d.ts.map +1 -0
  69. package/dist/src/frame/checkStory.js +31 -0
  70. package/dist/src/frame/checkStory.js.map +1 -0
  71. package/dist/src/frame/frame.css +51 -0
  72. package/dist/src/frame/frameClock.d.ts +53 -0
  73. package/dist/src/frame/frameClock.d.ts.map +1 -0
  74. package/dist/src/frame/frameClock.js +80 -0
  75. package/dist/src/frame/frameClock.js.map +1 -0
  76. package/dist/src/frame/frameStatus.d.ts +8 -0
  77. package/dist/src/frame/frameStatus.d.ts.map +1 -0
  78. package/dist/src/frame/frameStatus.js +8 -0
  79. package/dist/src/frame/frameStatus.js.map +1 -0
  80. package/dist/src/frame/frameView.d.ts +33 -0
  81. package/dist/src/frame/frameView.d.ts.map +1 -0
  82. package/dist/src/frame/frameView.js +134 -0
  83. package/dist/src/frame/frameView.js.map +1 -0
  84. package/dist/src/frame/matrixLayout.d.ts +36 -0
  85. package/dist/src/frame/matrixLayout.d.ts.map +1 -0
  86. package/dist/src/frame/matrixLayout.js +87 -0
  87. package/dist/src/frame/matrixLayout.js.map +1 -0
  88. package/dist/src/frame/measureTools.d.ts +24 -0
  89. package/dist/src/frame/measureTools.d.ts.map +1 -0
  90. package/dist/src/frame/measureTools.js +141 -0
  91. package/dist/src/frame/measureTools.js.map +1 -0
  92. package/dist/src/frame/mountFrame.d.ts +47 -0
  93. package/dist/src/frame/mountFrame.d.ts.map +1 -0
  94. package/dist/src/frame/mountFrame.js +229 -0
  95. package/dist/src/frame/mountFrame.js.map +1 -0
  96. package/dist/src/frame/playStory.d.ts +40 -0
  97. package/dist/src/frame/playStory.d.ts.map +1 -0
  98. package/dist/src/frame/playStory.js +55 -0
  99. package/dist/src/frame/playStory.js.map +1 -0
  100. package/dist/src/frame/renderer.d.ts +85 -0
  101. package/dist/src/frame/renderer.d.ts.map +1 -0
  102. package/dist/src/frame/renderer.js +18 -0
  103. package/dist/src/frame/renderer.js.map +1 -0
  104. package/dist/src/frame/settle.d.ts +24 -0
  105. package/dist/src/frame/settle.d.ts.map +1 -0
  106. package/dist/src/frame/settle.js +25 -0
  107. package/dist/src/frame/settle.js.map +1 -0
  108. package/dist/src/frame/staleModule.d.ts +40 -0
  109. package/dist/src/frame/staleModule.d.ts.map +1 -0
  110. package/dist/src/frame/staleModule.js +74 -0
  111. package/dist/src/frame/staleModule.js.map +1 -0
  112. package/dist/src/frame/storyCanvas.d.ts +21 -0
  113. package/dist/src/frame/storyCanvas.d.ts.map +1 -0
  114. package/dist/src/frame/storyCanvas.js +30 -0
  115. package/dist/src/frame/storyCanvas.js.map +1 -0
  116. package/dist/src/frame/storyHooks.d.ts +31 -0
  117. package/dist/src/frame/storyHooks.d.ts.map +1 -0
  118. package/dist/src/frame/storyHooks.js +59 -0
  119. package/dist/src/frame/storyHooks.js.map +1 -0
  120. package/dist/src/frame/storyModule.d.ts +104 -0
  121. package/dist/src/frame/storyModule.d.ts.map +1 -0
  122. package/dist/src/frame/storyModule.js +205 -0
  123. package/dist/src/frame/storyModule.js.map +1 -0
  124. package/dist/src/frame/storyRun.d.ts +96 -0
  125. package/dist/src/frame/storyRun.d.ts.map +1 -0
  126. package/dist/src/frame/storyRun.js +318 -0
  127. package/dist/src/frame/storyRun.js.map +1 -0
  128. package/dist/src/languages.d.ts +15 -0
  129. package/dist/src/languages.d.ts.map +1 -0
  130. package/dist/src/languages.js +8 -0
  131. package/dist/src/languages.js.map +1 -0
  132. package/dist/src/matrix.d.ts +56 -0
  133. package/dist/src/matrix.d.ts.map +1 -0
  134. package/dist/src/matrix.js +61 -0
  135. package/dist/src/matrix.js.map +1 -0
  136. package/dist/src/messages.d.ts +203 -0
  137. package/dist/src/messages.d.ts.map +1 -0
  138. package/dist/src/messages.js +193 -0
  139. package/dist/src/messages.js.map +1 -0
  140. package/dist/src/namedValues.d.ts +38 -0
  141. package/dist/src/namedValues.d.ts.map +1 -0
  142. package/dist/src/namedValues.js +48 -0
  143. package/dist/src/namedValues.js.map +1 -0
  144. package/dist/src/pageConfig.d.ts +23 -0
  145. package/dist/src/pageConfig.d.ts.map +1 -0
  146. package/dist/src/pageConfig.js +1 -0
  147. package/dist/src/pageConfig.js.map +1 -0
  148. package/dist/src/playTrace.d.ts +41 -0
  149. package/dist/src/playTrace.d.ts.map +1 -0
  150. package/dist/src/playTrace.js +35 -0
  151. package/dist/src/playTrace.js.map +1 -0
  152. package/dist/src/shell/A11yTab.d.ts +44 -0
  153. package/dist/src/shell/A11yTab.d.ts.map +1 -0
  154. package/dist/src/shell/A11yTab.js +30 -0
  155. package/dist/src/shell/A11yTab.js.map +1 -0
  156. package/dist/src/shell/ApiReference.d.ts +18 -0
  157. package/dist/src/shell/ApiReference.d.ts.map +1 -0
  158. package/dist/src/shell/ApiReference.js +41 -0
  159. package/dist/src/shell/ApiReference.js.map +1 -0
  160. package/dist/src/shell/ClockControls.d.ts +43 -0
  161. package/dist/src/shell/ClockControls.d.ts.map +1 -0
  162. package/dist/src/shell/ClockControls.js +53 -0
  163. package/dist/src/shell/ClockControls.js.map +1 -0
  164. package/dist/src/shell/Code.d.ts +16 -0
  165. package/dist/src/shell/Code.d.ts.map +1 -0
  166. package/dist/src/shell/Code.js +9 -0
  167. package/dist/src/shell/Code.js.map +1 -0
  168. package/dist/src/shell/CodeTab.d.ts +17 -0
  169. package/dist/src/shell/CodeTab.d.ts.map +1 -0
  170. package/dist/src/shell/CodeTab.js +17 -0
  171. package/dist/src/shell/CodeTab.js.map +1 -0
  172. package/dist/src/shell/CodeText.d.ts +16 -0
  173. package/dist/src/shell/CodeText.d.ts.map +1 -0
  174. package/dist/src/shell/CodeText.js +10 -0
  175. package/dist/src/shell/CodeText.js.map +1 -0
  176. package/dist/src/shell/ComponentPage.d.ts +38 -0
  177. package/dist/src/shell/ComponentPage.d.ts.map +1 -0
  178. package/dist/src/shell/ComponentPage.js +146 -0
  179. package/dist/src/shell/ComponentPage.js.map +1 -0
  180. package/dist/src/shell/Dock.d.ts +42 -0
  181. package/dist/src/shell/Dock.d.ts.map +1 -0
  182. package/dist/src/shell/Dock.js +90 -0
  183. package/dist/src/shell/Dock.js.map +1 -0
  184. package/dist/src/shell/EventsTab.d.ts +25 -0
  185. package/dist/src/shell/EventsTab.d.ts.map +1 -0
  186. package/dist/src/shell/EventsTab.js +26 -0
  187. package/dist/src/shell/EventsTab.js.map +1 -0
  188. package/dist/src/shell/FrameView.d.ts +49 -0
  189. package/dist/src/shell/FrameView.d.ts.map +1 -0
  190. package/dist/src/shell/FrameView.js +29 -0
  191. package/dist/src/shell/FrameView.js.map +1 -0
  192. package/dist/src/shell/HomePage.d.ts +39 -0
  193. package/dist/src/shell/HomePage.d.ts.map +1 -0
  194. package/dist/src/shell/HomePage.js +85 -0
  195. package/dist/src/shell/HomePage.js.map +1 -0
  196. package/dist/src/shell/InteractionsTab.d.ts +28 -0
  197. package/dist/src/shell/InteractionsTab.d.ts.map +1 -0
  198. package/dist/src/shell/InteractionsTab.js +17 -0
  199. package/dist/src/shell/InteractionsTab.js.map +1 -0
  200. package/dist/src/shell/MatrixPicker.d.ts +24 -0
  201. package/dist/src/shell/MatrixPicker.d.ts.map +1 -0
  202. package/dist/src/shell/MatrixPicker.js +29 -0
  203. package/dist/src/shell/MatrixPicker.js.map +1 -0
  204. package/dist/src/shell/PackageHtml.d.ts +17 -0
  205. package/dist/src/shell/PackageHtml.d.ts.map +1 -0
  206. package/dist/src/shell/PackageHtml.js +13 -0
  207. package/dist/src/shell/PackageHtml.js.map +1 -0
  208. package/dist/src/shell/PartsTab.d.ts +23 -0
  209. package/dist/src/shell/PartsTab.d.ts.map +1 -0
  210. package/dist/src/shell/PartsTab.js +23 -0
  211. package/dist/src/shell/PartsTab.js.map +1 -0
  212. package/dist/src/shell/PropFields.d.ts +31 -0
  213. package/dist/src/shell/PropFields.d.ts.map +1 -0
  214. package/dist/src/shell/PropFields.js +81 -0
  215. package/dist/src/shell/PropFields.js.map +1 -0
  216. package/dist/src/shell/PropsTab.d.ts +45 -0
  217. package/dist/src/shell/PropsTab.d.ts.map +1 -0
  218. package/dist/src/shell/PropsTab.js +81 -0
  219. package/dist/src/shell/PropsTab.js.map +1 -0
  220. package/dist/src/shell/SchemeSwitches.d.ts +24 -0
  221. package/dist/src/shell/SchemeSwitches.d.ts.map +1 -0
  222. package/dist/src/shell/SchemeSwitches.js +36 -0
  223. package/dist/src/shell/SchemeSwitches.js.map +1 -0
  224. package/dist/src/shell/Segmented.d.ts +41 -0
  225. package/dist/src/shell/Segmented.d.ts.map +1 -0
  226. package/dist/src/shell/Segmented.js +19 -0
  227. package/dist/src/shell/Segmented.js.map +1 -0
  228. package/dist/src/shell/Shell.d.ts +49 -0
  229. package/dist/src/shell/Shell.d.ts.map +1 -0
  230. package/dist/src/shell/Shell.js +279 -0
  231. package/dist/src/shell/Shell.js.map +1 -0
  232. package/dist/src/shell/Sidebar.d.ts +52 -0
  233. package/dist/src/shell/Sidebar.d.ts.map +1 -0
  234. package/dist/src/shell/Sidebar.js +132 -0
  235. package/dist/src/shell/Sidebar.js.map +1 -0
  236. package/dist/src/shell/SidebarHandle.d.ts +29 -0
  237. package/dist/src/shell/SidebarHandle.d.ts.map +1 -0
  238. package/dist/src/shell/SidebarHandle.js +46 -0
  239. package/dist/src/shell/SidebarHandle.js.map +1 -0
  240. package/dist/src/shell/Stage.d.ts +68 -0
  241. package/dist/src/shell/Stage.d.ts.map +1 -0
  242. package/dist/src/shell/Stage.js +218 -0
  243. package/dist/src/shell/Stage.js.map +1 -0
  244. package/dist/src/shell/StageTools.d.ts +27 -0
  245. package/dist/src/shell/StageTools.d.ts.map +1 -0
  246. package/dist/src/shell/StageTools.js +34 -0
  247. package/dist/src/shell/StageTools.js.map +1 -0
  248. package/dist/src/shell/StageViewport.d.ts +46 -0
  249. package/dist/src/shell/StageViewport.d.ts.map +1 -0
  250. package/dist/src/shell/StageViewport.js +173 -0
  251. package/dist/src/shell/StageViewport.js.map +1 -0
  252. package/dist/src/shell/StoryCodeBlock.d.ts +35 -0
  253. package/dist/src/shell/StoryCodeBlock.d.ts.map +1 -0
  254. package/dist/src/shell/StoryCodeBlock.js +27 -0
  255. package/dist/src/shell/StoryCodeBlock.js.map +1 -0
  256. package/dist/src/shell/StoryPicker.d.ts +26 -0
  257. package/dist/src/shell/StoryPicker.d.ts.map +1 -0
  258. package/dist/src/shell/StoryPicker.js +32 -0
  259. package/dist/src/shell/StoryPicker.js.map +1 -0
  260. package/dist/src/shell/Toolbar.d.ts +40 -0
  261. package/dist/src/shell/Toolbar.d.ts.map +1 -0
  262. package/dist/src/shell/Toolbar.js +125 -0
  263. package/dist/src/shell/Toolbar.js.map +1 -0
  264. package/dist/src/shell/WidthField.d.ts +24 -0
  265. package/dist/src/shell/WidthField.d.ts.map +1 -0
  266. package/dist/src/shell/WidthField.js +40 -0
  267. package/dist/src/shell/WidthField.js.map +1 -0
  268. package/dist/src/shell/catalogueContext.d.ts +6 -0
  269. package/dist/src/shell/catalogueContext.d.ts.map +1 -0
  270. package/dist/src/shell/catalogueContext.js +14 -0
  271. package/dist/src/shell/catalogueContext.js.map +1 -0
  272. package/dist/src/shell/codeTokens.d.ts +23 -0
  273. package/dist/src/shell/codeTokens.d.ts.map +1 -0
  274. package/dist/src/shell/codeTokens.js +48 -0
  275. package/dist/src/shell/codeTokens.js.map +1 -0
  276. package/dist/src/shell/codeWriter.d.ts +6 -0
  277. package/dist/src/shell/codeWriter.d.ts.map +1 -0
  278. package/dist/src/shell/codeWriter.js +14 -0
  279. package/dist/src/shell/codeWriter.js.map +1 -0
  280. package/dist/src/shell/compareVariants.d.ts +35 -0
  281. package/dist/src/shell/compareVariants.d.ts.map +1 -0
  282. package/dist/src/shell/compareVariants.js +68 -0
  283. package/dist/src/shell/compareVariants.js.map +1 -0
  284. package/dist/src/shell/dockTabs.d.ts +63 -0
  285. package/dist/src/shell/dockTabs.d.ts.map +1 -0
  286. package/dist/src/shell/dockTabs.js +140 -0
  287. package/dist/src/shell/dockTabs.js.map +1 -0
  288. package/dist/src/shell/icons.d.ts +47 -0
  289. package/dist/src/shell/icons.d.ts.map +1 -0
  290. package/dist/src/shell/icons.js +36 -0
  291. package/dist/src/shell/icons.js.map +1 -0
  292. package/dist/src/shell/keyboard.d.ts +35 -0
  293. package/dist/src/shell/keyboard.d.ts.map +1 -0
  294. package/dist/src/shell/keyboard.js +51 -0
  295. package/dist/src/shell/keyboard.js.map +1 -0
  296. package/dist/src/shell/mountShell.d.ts +22 -0
  297. package/dist/src/shell/mountShell.d.ts.map +1 -0
  298. package/dist/src/shell/mountShell.js +39 -0
  299. package/dist/src/shell/mountShell.js.map +1 -0
  300. package/dist/src/shell/shell.css +1831 -0
  301. package/dist/src/shell/strings.d.ts +184 -0
  302. package/dist/src/shell/strings.d.ts.map +1 -0
  303. package/dist/src/shell/strings.js +188 -0
  304. package/dist/src/shell/strings.js.map +1 -0
  305. package/dist/src/shell/switchView.d.ts +23 -0
  306. package/dist/src/shell/switchView.d.ts.map +1 -0
  307. package/dist/src/shell/switchView.js +19 -0
  308. package/dist/src/shell/switchView.js.map +1 -0
  309. package/dist/src/shell/treeSearch.d.ts +35 -0
  310. package/dist/src/shell/treeSearch.d.ts.map +1 -0
  311. package/dist/src/shell/treeSearch.js +60 -0
  312. package/dist/src/shell/treeSearch.js.map +1 -0
  313. package/dist/src/shell/useComponentDocs.d.ts +16 -0
  314. package/dist/src/shell/useComponentDocs.d.ts.map +1 -0
  315. package/dist/src/shell/useComponentDocs.js +25 -0
  316. package/dist/src/shell/useComponentDocs.js.map +1 -0
  317. package/dist/src/shell/useCopy.d.ts +10 -0
  318. package/dist/src/shell/useCopy.d.ts.map +1 -0
  319. package/dist/src/shell/useCopy.js +23 -0
  320. package/dist/src/shell/useCopy.js.map +1 -0
  321. package/dist/src/shell/useFrameMessages.d.ts +54 -0
  322. package/dist/src/shell/useFrameMessages.d.ts.map +1 -0
  323. package/dist/src/shell/useFrameMessages.js +90 -0
  324. package/dist/src/shell/useFrameMessages.js.map +1 -0
  325. package/dist/src/shell/useFrameQueue.d.ts +29 -0
  326. package/dist/src/shell/useFrameQueue.d.ts.map +1 -0
  327. package/dist/src/shell/useFrameQueue.js +72 -0
  328. package/dist/src/shell/useFrameQueue.js.map +1 -0
  329. package/dist/src/shell/useLiveView.d.ts +29 -0
  330. package/dist/src/shell/useLiveView.d.ts.map +1 -0
  331. package/dist/src/shell/useLiveView.js +51 -0
  332. package/dist/src/shell/useLiveView.js.map +1 -0
  333. package/dist/src/shell/useLoaded.d.ts +20 -0
  334. package/dist/src/shell/useLoaded.d.ts.map +1 -0
  335. package/dist/src/shell/useLoaded.js +40 -0
  336. package/dist/src/shell/useLoaded.js.map +1 -0
  337. package/dist/src/shell/usePageDoc.d.ts +20 -0
  338. package/dist/src/shell/usePageDoc.d.ts.map +1 -0
  339. package/dist/src/shell/usePageDoc.js +21 -0
  340. package/dist/src/shell/usePageDoc.js.map +1 -0
  341. package/dist/src/shell/usePopover.d.ts +23 -0
  342. package/dist/src/shell/usePopover.d.ts.map +1 -0
  343. package/dist/src/shell/usePopover.js +39 -0
  344. package/dist/src/shell/usePopover.js.map +1 -0
  345. package/dist/src/shell/useRecentPages.d.ts +21 -0
  346. package/dist/src/shell/useRecentPages.d.ts.map +1 -0
  347. package/dist/src/shell/useRecentPages.js +62 -0
  348. package/dist/src/shell/useRecentPages.js.map +1 -0
  349. package/dist/src/shell/useScrollMemory.d.ts +40 -0
  350. package/dist/src/shell/useScrollMemory.d.ts.map +1 -0
  351. package/dist/src/shell/useScrollMemory.js +69 -0
  352. package/dist/src/shell/useScrollMemory.js.map +1 -0
  353. package/dist/src/shell/useSidebarLayout.d.ts +14 -0
  354. package/dist/src/shell/useSidebarLayout.d.ts.map +1 -0
  355. package/dist/src/shell/useSidebarLayout.js +19 -0
  356. package/dist/src/shell/useSidebarLayout.js.map +1 -0
  357. package/dist/src/shell/useStored.d.ts +11 -0
  358. package/dist/src/shell/useStored.d.ts.map +1 -0
  359. package/dist/src/shell/useStored.js +68 -0
  360. package/dist/src/shell/useStored.js.map +1 -0
  361. package/dist/src/shell/useStoryCode.d.ts +14 -0
  362. package/dist/src/shell/useStoryCode.d.ts.map +1 -0
  363. package/dist/src/shell/useStoryCode.js +29 -0
  364. package/dist/src/shell/useStoryCode.js.map +1 -0
  365. package/dist/src/shell/useStoryHeights.d.ts +9 -0
  366. package/dist/src/shell/useStoryHeights.d.ts.map +1 -0
  367. package/dist/src/shell/useStoryHeights.js +31 -0
  368. package/dist/src/shell/useStoryHeights.js.map +1 -0
  369. package/dist/src/shell/useStoryIdsElement.d.ts +7 -0
  370. package/dist/src/shell/useStoryIdsElement.d.ts.map +1 -0
  371. package/dist/src/shell/useStoryIdsElement.js +29 -0
  372. package/dist/src/shell/useStoryIdsElement.js.map +1 -0
  373. package/dist/src/shell/useStoryKeys.d.ts +11 -0
  374. package/dist/src/shell/useStoryKeys.d.ts.map +1 -0
  375. package/dist/src/shell/useStoryKeys.js +40 -0
  376. package/dist/src/shell/useStoryKeys.js.map +1 -0
  377. package/dist/src/shell/useSystemDark.d.ts +3 -0
  378. package/dist/src/shell/useSystemDark.d.ts.map +1 -0
  379. package/dist/src/shell/useSystemDark.js +19 -0
  380. package/dist/src/shell/useSystemDark.js.map +1 -0
  381. package/dist/src/sourceFiles.d.ts +18 -0
  382. package/dist/src/sourceFiles.d.ts.map +1 -0
  383. package/dist/src/sourceFiles.js +22 -0
  384. package/dist/src/sourceFiles.js.map +1 -0
  385. package/dist/src/storyBackground.d.ts +21 -0
  386. package/dist/src/storyBackground.d.ts.map +1 -0
  387. package/dist/src/storyBackground.js +27 -0
  388. package/dist/src/storyBackground.js.map +1 -0
  389. package/dist/src/storyClock.d.ts +62 -0
  390. package/dist/src/storyClock.d.ts.map +1 -0
  391. package/dist/src/storyClock.js +51 -0
  392. package/dist/src/storyClock.js.map +1 -0
  393. package/dist/src/storyGlobals.d.ts +60 -0
  394. package/dist/src/storyGlobals.d.ts.map +1 -0
  395. package/dist/src/storyGlobals.js +117 -0
  396. package/dist/src/storyGlobals.js.map +1 -0
  397. package/dist/src/storyHeights.d.ts +37 -0
  398. package/dist/src/storyHeights.d.ts.map +1 -0
  399. package/dist/src/storyHeights.js +53 -0
  400. package/dist/src/storyHeights.js.map +1 -0
  401. package/dist/src/storyIdsElement.d.ts +9 -0
  402. package/dist/src/storyIdsElement.d.ts.map +1 -0
  403. package/dist/src/storyIdsElement.js +9 -0
  404. package/dist/src/storyIdsElement.js.map +1 -0
  405. package/dist/src/storyTexts.d.ts +43 -0
  406. package/dist/src/storyTexts.d.ts.map +1 -0
  407. package/dist/src/storyTexts.js +71 -0
  408. package/dist/src/storyTexts.js.map +1 -0
  409. package/dist/src/storyTree.d.ts +215 -0
  410. package/dist/src/storyTree.d.ts.map +1 -0
  411. package/dist/src/storyTree.js +308 -0
  412. package/dist/src/storyTree.js.map +1 -0
  413. package/dist/src/switches.d.ts +156 -0
  414. package/dist/src/switches.d.ts.map +1 -0
  415. package/dist/src/switches.js +193 -0
  416. package/dist/src/switches.js.map +1 -0
  417. package/dist/src/viewState.d.ts +194 -0
  418. package/dist/src/viewState.d.ts.map +1 -0
  419. package/dist/src/viewState.js +303 -0
  420. package/dist/src/viewState.js.map +1 -0
  421. package/dist/src/vite/adapter.d.ts +70 -0
  422. package/dist/src/vite/adapter.d.ts.map +1 -0
  423. package/dist/src/vite/adapter.js +22 -0
  424. package/dist/src/vite/adapter.js.map +1 -0
  425. package/dist/src/vite/autoTitle.d.ts +28 -0
  426. package/dist/src/vite/autoTitle.d.ts.map +1 -0
  427. package/dist/src/vite/autoTitle.js +44 -0
  428. package/dist/src/vite/autoTitle.js.map +1 -0
  429. package/dist/src/vite/componentPage.d.ts +34 -0
  430. package/dist/src/vite/componentPage.d.ts.map +1 -0
  431. package/dist/src/vite/componentPage.js +94 -0
  432. package/dist/src/vite/componentPage.js.map +1 -0
  433. package/dist/src/vite/config.d.ts +72 -0
  434. package/dist/src/vite/config.d.ts.map +1 -0
  435. package/dist/src/vite/config.js +25 -0
  436. package/dist/src/vite/config.js.map +1 -0
  437. package/dist/src/vite/configFile.d.ts +76 -0
  438. package/dist/src/vite/configFile.d.ts.map +1 -0
  439. package/dist/src/vite/configFile.js +190 -0
  440. package/dist/src/vite/configFile.js.map +1 -0
  441. package/dist/src/vite/docsExtractor.d.ts +46 -0
  442. package/dist/src/vite/docsExtractor.d.ts.map +1 -0
  443. package/dist/src/vite/docsExtractor.js +88 -0
  444. package/dist/src/vite/docsExtractor.js.map +1 -0
  445. package/dist/src/vite/docsProgram.d.ts +42 -0
  446. package/dist/src/vite/docsProgram.d.ts.map +1 -0
  447. package/dist/src/vite/docsProgram.js +144 -0
  448. package/dist/src/vite/docsProgram.js.map +1 -0
  449. package/dist/src/vite/docsWorker.d.ts +2 -0
  450. package/dist/src/vite/docsWorker.d.ts.map +1 -0
  451. package/dist/src/vite/docsWorker.js +68 -0
  452. package/dist/src/vite/docsWorker.js.map +1 -0
  453. package/dist/src/vite/forcedStates.d.ts +27 -0
  454. package/dist/src/vite/forcedStates.d.ts.map +1 -0
  455. package/dist/src/vite/forcedStates.js +60 -0
  456. package/dist/src/vite/forcedStates.js.map +1 -0
  457. package/dist/src/vite/forgebookPlugin.d.ts +28 -0
  458. package/dist/src/vite/forgebookPlugin.d.ts.map +1 -0
  459. package/dist/src/vite/forgebookPlugin.js +375 -0
  460. package/dist/src/vite/forgebookPlugin.js.map +1 -0
  461. package/dist/src/vite/highlightCode.d.ts +16 -0
  462. package/dist/src/vite/highlightCode.d.ts.map +1 -0
  463. package/dist/src/vite/highlightCode.js +82 -0
  464. package/dist/src/vite/highlightCode.js.map +1 -0
  465. package/dist/src/vite/indexStoryFile.d.ts +35 -0
  466. package/dist/src/vite/indexStoryFile.d.ts.map +1 -0
  467. package/dist/src/vite/indexStoryFile.js +458 -0
  468. package/dist/src/vite/indexStoryFile.js.map +1 -0
  469. package/dist/src/vite/pages.d.ts +49 -0
  470. package/dist/src/vite/pages.d.ts.map +1 -0
  471. package/dist/src/vite/pages.js +171 -0
  472. package/dist/src/vite/pages.js.map +1 -0
  473. package/dist/src/vite/prebundled.d.ts +30 -0
  474. package/dist/src/vite/prebundled.d.ts.map +1 -0
  475. package/dist/src/vite/prebundled.js +81 -0
  476. package/dist/src/vite/prebundled.js.map +1 -0
  477. package/dist/src/vite/storyCode.d.ts +28 -0
  478. package/dist/src/vite/storyCode.d.ts.map +1 -0
  479. package/dist/src/vite/storyCode.js +80 -0
  480. package/dist/src/vite/storyCode.js.map +1 -0
  481. package/dist/src/vite/storyFilesModule.d.ts +17 -0
  482. package/dist/src/vite/storyFilesModule.d.ts.map +1 -0
  483. package/dist/src/vite/storyFilesModule.js +64 -0
  484. package/dist/src/vite/storyFilesModule.js.map +1 -0
  485. package/dist/src/vite/storyMeta.d.ts +34 -0
  486. package/dist/src/vite/storyMeta.d.ts.map +1 -0
  487. package/dist/src/vite/storyMeta.js +74 -0
  488. package/dist/src/vite/storyMeta.js.map +1 -0
  489. package/dist/src/vite/typeScriptPieces.d.ts +23 -0
  490. package/dist/src/vite/typeScriptPieces.d.ts.map +1 -0
  491. package/dist/src/vite/typeScriptPieces.js +236 -0
  492. package/dist/src/vite/typeScriptPieces.js.map +1 -0
  493. package/package.json +202 -3
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The language a view shows, among the catalogue's (the View menu's Language row): its texts table is the source's
3
+ * (`StorySource.texts`), its provider a decorator of the catalogue's preview. Pure.
4
+ *
5
+ * @module
6
+ */
7
+ import type { StoryLanguage } from "@forgebook/story-format/source";
8
+ /**
9
+ * The language a view shows, among the catalogue's: none for the stories' own text, or for an id it does not offer.
10
+ *
11
+ * @param languages - the catalogue's languages.
12
+ * @param id - the view's language id; empty for the stories' own text.
13
+ */
14
+ export declare const shownLanguage: (languages: readonly StoryLanguage[], id: string) => StoryLanguage | undefined;
15
+ //# sourceMappingURL=languages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../src/languages.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEpE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,WAAW,SAAS,aAAa,EAAE,EAAE,IAAI,MAAM,KAAG,aAAa,GAAG,SAC9C,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The language a view shows, among the catalogue's: none for the stories' own text, or for an id it does not offer.
3
+ *
4
+ * @param languages - the catalogue's languages.
5
+ * @param id - the view's language id; empty for the stories' own text.
6
+ */
7
+ export const shownLanguage = (languages, id) => languages.find((language) => language.id === id);
8
+ //# sourceMappingURL=languages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"languages.js","sourceRoot":"","sources":["../../src/languages.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAmC,EAAE,EAAU,EAA6B,EAAE,CAC1G,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The matrix of a story: the story drawn once per value of one prop (the rows), or of two (rows by columns), in one
3
+ * frame, so every variant, tone and size is seen side by side without a story written for it.
4
+ *
5
+ * @remarks
6
+ * Only props with a known, short set of values make an axis: a choice (its literal values) or a toggle (`false`,
7
+ * `true`). The shell builds the matrix from the component's docs and the axes in the address, and sends it to the
8
+ * frames, which draw it over the story's args. Pure.
9
+ *
10
+ * @module
11
+ */
12
+ import type { PropDocs } from "./componentDocs.ts";
13
+ /** A value an axis takes: what a choice or a toggle prop can be set to. */
14
+ export type MatrixValue = string | number | boolean;
15
+ /** One axis: a prop and the values it takes, in order. */
16
+ export type MatrixAxis = {
17
+ /** The prop's name. */
18
+ readonly name: string;
19
+ /** Its values. */
20
+ readonly values: readonly MatrixValue[];
21
+ };
22
+ /** The matrix: the rows' axis, and the columns' when there are two. */
23
+ export type Matrix = {
24
+ /** One row per value. */
25
+ readonly rows: MatrixAxis;
26
+ /** One column per value; a single column without. */
27
+ readonly columns?: MatrixAxis;
28
+ };
29
+ /** The most values an axis takes: past it, the grid is no longer read at a glance. */
30
+ export declare const MATRIX_MAX_VALUES = 12;
31
+ /**
32
+ * The axis a prop makes, when it can make one.
33
+ *
34
+ * @param prop - the prop's docs.
35
+ */
36
+ export declare const axisOf: (prop: PropDocs) => MatrixAxis | undefined;
37
+ /**
38
+ * The props a story's matrix can use as an axis, in the docs' order.
39
+ *
40
+ * @param props - the component's props.
41
+ */
42
+ export declare const matrixProps: (props: readonly PropDocs[]) => PropDocs[];
43
+ /**
44
+ * The matrix of the named axes: the first is the rows, the second the columns; none when the first names no axis.
45
+ *
46
+ * @param props - the component's props.
47
+ * @param names - the axes' prop names, from the address.
48
+ */
49
+ export declare const matrixOf: (props: readonly PropDocs[], names: readonly string[]) => Matrix | undefined;
50
+ /**
51
+ * Whether a value is a matrix, as it arrives in a message.
52
+ *
53
+ * @param value - the message's matrix.
54
+ */
55
+ export declare const isMatrix: (value: unknown) => value is Matrix;
56
+ //# sourceMappingURL=matrix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../../src/matrix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,2EAA2E;AAC3E,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpD,0DAA0D;AAC1D,MAAM,MAAM,UAAU,GAAG;IACvB,uBAAuB;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kBAAkB;IAClB,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;CACzC,CAAC;AAEF,uEAAuE;AACvE,MAAM,MAAM,MAAM,GAAG;IACnB,yBAAyB;IACzB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,qDAAqD;IACrD,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC;CAC/B,CAAC;AAEF,sFAAsF;AACtF,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC;;;;GAIG;AACH,eAAO,MAAM,MAAM,GAAI,MAAM,QAAQ,KAAG,UAAU,GAAG,SAKpD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,SAAS,QAAQ,EAAE,KAAG,QAAQ,EACb,CAAC;AAErD;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,SAAS,QAAQ,EAAE,EAAE,OAAO,SAAS,MAAM,EAAE,KAAG,MAAM,GAAG,SAUxF,CAAC;AAcF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAIlD,CAAC"}
@@ -0,0 +1,61 @@
1
+ /** The most values an axis takes: past it, the grid is no longer read at a glance. */
2
+ export const MATRIX_MAX_VALUES = 12;
3
+ /**
4
+ * The axis a prop makes, when it can make one.
5
+ *
6
+ * @param prop - the prop's docs.
7
+ */
8
+ export const axisOf = (prop) => {
9
+ if (prop.kind === "toggle")
10
+ return { name: prop.name, values: [false, true] };
11
+ if (prop.kind !== "choice")
12
+ return undefined;
13
+ const values = prop.choices ?? [];
14
+ return values.length >= 2 && values.length <= MATRIX_MAX_VALUES ? { name: prop.name, values } : undefined;
15
+ };
16
+ /**
17
+ * The props a story's matrix can use as an axis, in the docs' order.
18
+ *
19
+ * @param props - the component's props.
20
+ */
21
+ export const matrixProps = (props) => props.filter((prop) => axisOf(prop) !== undefined);
22
+ /**
23
+ * The matrix of the named axes: the first is the rows, the second the columns; none when the first names no axis.
24
+ *
25
+ * @param props - the component's props.
26
+ * @param names - the axes' prop names, from the address.
27
+ */
28
+ export const matrixOf = (props, names) => {
29
+ const axisNamed = (name) => {
30
+ const prop = props.find((candidate) => candidate.name === name);
31
+ return prop === undefined ? undefined : axisOf(prop);
32
+ };
33
+ const [rowName, columnName] = names;
34
+ const rows = axisNamed(rowName);
35
+ if (rows === undefined)
36
+ return undefined;
37
+ const columns = columnName === rowName ? undefined : axisNamed(columnName);
38
+ return columns === undefined ? { rows } : { rows, columns };
39
+ };
40
+ /** Whether a value is an axis, as it arrives in a message. */
41
+ const isAxis = (value) => {
42
+ if (typeof value !== "object" || value === null)
43
+ return false;
44
+ const record = { ...value };
45
+ const values = record["values"];
46
+ return (typeof record["name"] === "string" &&
47
+ Array.isArray(values) &&
48
+ values.every((item) => typeof item === "string" || typeof item === "number" || typeof item === "boolean"));
49
+ };
50
+ /**
51
+ * Whether a value is a matrix, as it arrives in a message.
52
+ *
53
+ * @param value - the message's matrix.
54
+ */
55
+ export const isMatrix = (value) => {
56
+ if (typeof value !== "object" || value === null)
57
+ return false;
58
+ const record = { ...value };
59
+ return isAxis(record["rows"]) && (record["columns"] === undefined || isAxis(record["columns"]));
60
+ };
61
+ //# sourceMappingURL=matrix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrix.js","sourceRoot":"","sources":["../../src/matrix.ts"],"names":[],"mappings":"AAgCA,sFAAsF;AACtF,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAc,EAA0B,EAAE;IAC/D,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC;IAC9E,IAAI,IAAI,CAAC,IAAI,KA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,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC9D,CAAC,CAAC;AAEF,8DAA8D;AAC9D,MAAM,MAAM,GAAG,CAAC,KAAc,EAAuB,EAAE;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,MAAM,GAAsC,EAAE,GAAG,KAAK,EAAE,CAAC;IAC/D,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChC,OAAO,CACL,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,QAAQ;QAClC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QACrB,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,SAAS,CAAC,CAC1G,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE;IAC1D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,MAAM,GAAsC,EAAE,GAAG,KAAK,EAAE,CAAC;IAC/D,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAClG,CAAC,CAAC"}
@@ -0,0 +1,203 @@
1
+ /**
2
+ * The messages between the shell and a story's frame, both on the same origin.
3
+ *
4
+ * @remarks
5
+ * The frame tells the shell what the loaded story can do (Replay, a story clock, its args), how tall it is (the shell sizes the frame
6
+ * to it, so a story never scrolls inside a box), every call of an event, or why it failed. The shell asks the frame to
7
+ * replay, sends the props panel's values, names the events to record, and runs, holds, speeds up or restarts the
8
+ * story clock. Every message is checked on arrival
9
+ * (`isFrameMessage`, `isShellMessage`): a page may receive messages from anything it embeds or is embedded in.
10
+ *
11
+ * @module
12
+ */
13
+ import type { StoryControlsSetting } from "@forgebook/story-format/source";
14
+ import { type Violation } from "./a11y.ts";
15
+ import { type PanelArgTypes } from "./argTypes.ts";
16
+ import { type Matrix } from "./matrix.ts";
17
+ import { type PlayTrace } from "./playTrace.ts";
18
+ import { type ClockState } from "./storyClock.ts";
19
+ import { type FixedView } from "./storyGlobals.ts";
20
+ import { type LiveView, type MeasureTool } from "./viewState.ts";
21
+ /**
22
+ * An arg the props panel can show and set: what crosses between the documents as is. A list of texts or numbers is a
23
+ * multiple choice's (`check`, `multi-select`); a date is a number of ms since the Unix epoch, as Storybook's.
24
+ */
25
+ export type ArgValue = string | number | boolean | null | readonly (string | number)[] | NamedArg;
26
+ /**
27
+ * A value the panel names instead of sending it: one of the source's `namedValues` (an icon component), which cannot
28
+ * cross between the documents; the frame looks the name up in its own copy of the source.
29
+ */
30
+ export type NamedArg = {
31
+ /** The type the value is offered for, as the props write it (`IconComponent`). */
32
+ readonly of: string;
33
+ /** The value's name (`IconFolder`). */
34
+ readonly named: string;
35
+ };
36
+ /** The args of a story the panel can show, by name. */
37
+ export type PanelArgs = Readonly<Record<string, ArgValue>>;
38
+ /** From a frame to the shell. */
39
+ export type FrameMessage = {
40
+ /** The story rendered. */
41
+ readonly type: "forgebook:ready";
42
+ /** The story's id. */
43
+ readonly storyId: string;
44
+ /** Whether the story declares a replay. */
45
+ readonly canReplay: boolean;
46
+ /** Whether the story reads the story clock (`parameters.clock`): the stage then shows its controls. */
47
+ readonly hasClock: boolean;
48
+ /** The story's own args the panel can show (strings, numbers, booleans), a named text in the shown language. */
49
+ readonly args: PanelArgs;
50
+ /** The args written `storyText("key")`, with their keys, for the panel to show beside the text. */
51
+ readonly textKeys: Readonly<Record<string, string>>;
52
+ /** How the panel shows the args, from the story's `argTypes`, by arg. */
53
+ readonly argTypes: PanelArgTypes;
54
+ /** The props the panel can set, as the story's parameters say once it ran (written by code too). */
55
+ readonly controls: StoryControlsSetting;
56
+ /** The args the frame records as actions (a spy, an `argTypes` action), whatever the shell names. */
57
+ readonly actions: readonly string[];
58
+ /** What the story fixes of the view (its `globals`, Storybook's backgrounds and viewport). */
59
+ readonly fixed: FixedView;
60
+ } | {
61
+ /** The story's height changed. */
62
+ readonly type: "forgebook:size";
63
+ /** The story's id. */
64
+ readonly storyId: string;
65
+ /** The document's height, in CSS px. */
66
+ readonly height: number;
67
+ } | {
68
+ /** An event of the story's component was called. */
69
+ readonly type: "forgebook:call";
70
+ /** The story's id. */
71
+ readonly storyId: string;
72
+ /** The event's prop (`onValueChange`). */
73
+ readonly name: string;
74
+ /** Each argument, written short for the log (`"monthly"`, `Event`, `{…}`). */
75
+ readonly values: readonly string[];
76
+ /** Each argument's content as JSON for an object or a list, to open in the log; `null` for any other. */
77
+ readonly details: readonly (string | null)[];
78
+ } | {
79
+ /** The play function's trace changed: a step began or ended, or the play did. */
80
+ readonly type: "forgebook:play";
81
+ /** The story's id. */
82
+ readonly storyId: string;
83
+ /** The trace. */
84
+ readonly trace: PlayTrace;
85
+ } | {
86
+ /** The accessibility check the shell asked for is over. */
87
+ readonly type: "forgebook:checked";
88
+ /** The story's id. */
89
+ readonly storyId: string;
90
+ /** The rules the story breaks; empty when it passes. */
91
+ readonly violations: readonly Violation[];
92
+ } | {
93
+ /** The accessibility check could not run. */
94
+ readonly type: "forgebook:check-error";
95
+ /** The story's id. */
96
+ readonly storyId: string;
97
+ /** What went wrong. */
98
+ readonly message: string;
99
+ } | {
100
+ /** The story could not be shown. */
101
+ readonly type: "forgebook:error";
102
+ /** The story's id. */
103
+ readonly storyId: string;
104
+ /** What went wrong. */
105
+ readonly message: string;
106
+ };
107
+ /** From the shell to a frame. */
108
+ export type ShellMessage = {
109
+ /** Replay the story, as it declares. */
110
+ readonly type: "forgebook:replay";
111
+ } | {
112
+ /** The props panel's values, over the story's own args. */
113
+ readonly type: "forgebook:args";
114
+ /** The values set in the panel. */
115
+ readonly args: PanelArgs;
116
+ } | {
117
+ /** The events to record: the component's `on…` props. */
118
+ readonly type: "forgebook:events";
119
+ /** Their names. */
120
+ readonly names: readonly string[];
121
+ } | {
122
+ /** The tools drawn over the story changed: the frame draws these, without loading again. */
123
+ readonly type: "forgebook:tools";
124
+ /** The tools; none removes them. */
125
+ readonly tools: readonly MeasureTool[];
126
+ } | {
127
+ /** Draw the story once per value of the matrix's axes, or as it is with none. */
128
+ readonly type: "forgebook:matrix";
129
+ /** The matrix; `null` draws the story alone. */
130
+ readonly matrix: Matrix | null;
131
+ } | {
132
+ /** Mount the story again, so its play function runs again. */
133
+ readonly type: "forgebook:play-again";
134
+ } | {
135
+ /** Run the accessibility check on the story as it is now. */
136
+ readonly type: "forgebook:check";
137
+ } | {
138
+ /** Set whether the story clock runs, and how fast. */
139
+ readonly type: "forgebook:clock";
140
+ /** The clock's state. */
141
+ readonly state: ClockState;
142
+ } | {
143
+ /** Bring the story clock back to its start and mount the story again. */
144
+ readonly type: "forgebook:clock-restart";
145
+ } | {
146
+ /** The view's live part changed: the frame applies it on its root, without loading again. */
147
+ readonly type: "forgebook:view";
148
+ /** The switches' values, the backdrop and the text size. */
149
+ readonly view: LiveView;
150
+ };
151
+ /** Whether a value is a set of args the panel can show. */
152
+ export declare const isPanelArgs: (value: unknown) => value is PanelArgs;
153
+ /**
154
+ * Whether a value is a multiple choice's values: a list of texts and numbers.
155
+ *
156
+ * @param value - any value.
157
+ */
158
+ export declare const isChoiceList: (value: unknown) => value is readonly (string | number)[];
159
+ /**
160
+ * Whether a value is a named arg.
161
+ *
162
+ * @param value - any value.
163
+ */
164
+ export declare const isNamedArg: (value: unknown) => value is NamedArg;
165
+ /**
166
+ * Whether a received message is one a frame sends.
167
+ *
168
+ * @param value - the message's data.
169
+ */
170
+ export declare const isFrameMessage: (value: unknown) => value is FrameMessage;
171
+ /**
172
+ * Whether a received message is one the shell sends.
173
+ *
174
+ * @param value - the message's data.
175
+ */
176
+ export declare const isShellMessage: (value: unknown) => value is ShellMessage;
177
+ /**
178
+ * An event's argument written short for the call log.
179
+ *
180
+ * @param value - anything a callback received.
181
+ */
182
+ export declare const previewValue: (value: unknown) => string;
183
+ /**
184
+ * An argument's content for the log, when it is an object or a list: JSON, two spaces deep, a function as `ƒ`, an
185
+ * object met again as `[circular]`, cut past `DETAIL_LENGTH`; `null` for anything else (a text, a number, an event).
186
+ *
187
+ * @param value - anything a callback received.
188
+ */
189
+ export declare const detailOf: (value: unknown) => string | null;
190
+ /**
191
+ * The panel's values written in an address (`args`): JSON, the only form that keeps `"12"` and `12` apart.
192
+ *
193
+ * @param args - the values.
194
+ * @returns the parameter's text; empty when there is no value.
195
+ */
196
+ export declare const panelArgsParam: (args: PanelArgs) => string;
197
+ /**
198
+ * The panel's values an address names: none when the parameter is missing, not JSON, or not values the panel sets.
199
+ *
200
+ * @param param - the `args` parameter.
201
+ */
202
+ export declare const parsePanelArgsParam: (param: string | null) => PanelArgs;
203
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAY,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,KAAK,UAAU,EAAe,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,KAAK,QAAQ,EAAiB,KAA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UnD,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EACoB,CAAC;AAEtG;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,QACqC,CAAC;AA0B3F;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,YAiCxD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,YAmBxD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,KAAG,MAS7C,CAAC;AAKF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,MAAM,GAAG,IAmBlD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,SAAS,KAAG,MACW,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,GAAG,IAAI,KAAG,SAQ1D,CAAC"}
@@ -0,0 +1,193 @@
1
+ /**
2
+ * The messages between the shell and a story's frame, both on the same origin.
3
+ *
4
+ * @remarks
5
+ * The frame tells the shell what the loaded story can do (Replay, a story clock, its args), how tall it is (the shell sizes the frame
6
+ * to it, so a story never scrolls inside a box), every call of an event, or why it failed. The shell asks the frame to
7
+ * replay, sends the props panel's values, names the events to record, and runs, holds, speeds up or restarts the
8
+ * story clock. Every message is checked on arrival
9
+ * (`isFrameMessage`, `isShellMessage`): a page may receive messages from anything it embeds or is embedded in.
10
+ *
11
+ * @module
12
+ */
13
+ import { isViolation } from "./a11y.js";
14
+ import { isPanelArgTypes } from "./argTypes.js";
15
+ import { isMatrix } from "./matrix.js";
16
+ import { isPlayTrace } from "./playTrace.js";
17
+ import { isClockRate } from "./storyClock.js";
18
+ import { isFixedView } from "./storyGlobals.js";
19
+ import { MEASURE_TOOLS } from "./viewState.js";
20
+ /** Whether a value is a plain object. */
21
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
22
+ /** Whether a value is a set of args the panel can show. */
23
+ export const isPanelArgs = (value) => isRecord(value) &&
24
+ Object.values(value).every((arg) => arg === null ||
25
+ typeof arg === "string" ||
26
+ typeof arg === "number" ||
27
+ typeof arg === "boolean" ||
28
+ isChoiceList(arg) ||
29
+ isNamedArg(arg));
30
+ /**
31
+ * Whether a value is a multiple choice's values: a list of texts and numbers.
32
+ *
33
+ * @param value - any value.
34
+ */
35
+ export const isChoiceList = (value) => Array.isArray(value) && value.every((item) => typeof item === "string" || typeof item === "number");
36
+ /**
37
+ * Whether a value is a named arg.
38
+ *
39
+ * @param value - any value.
40
+ */
41
+ export const isNamedArg = (value) => isRecord(value) && typeof value["of"] === "string" && typeof value["named"] === "string";
42
+ /** Whether a value is the view's live part. */
43
+ const isLiveView = (value) => isRecord(value) &&
44
+ isRecord(value["switches"]) &&
45
+ Object.values(value["switches"]).every((switchValue) => typeof switchValue === "string") &&
46
+ typeof value["backdrop"] === "string" &&
47
+ typeof value["text"] === "number";
48
+ /** Whether a value is a story clock's state. */
49
+ const isClockState = (value) => isRecord(value) && typeof value["isRunning"] === "boolean" && isClockRate(value["rate"]);
50
+ /** Whether a value is a list of strings. */
51
+ const isStringList = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
52
+ /** Whether a value is a controls setting: every prop, or the listed ones. */
53
+ const isControlsSetting = (value) => value === "all" || isStringList(value);
54
+ /** Whether a value is the text keys of a story's args: names to keys. */
55
+ const isTextKeys = (value) => isRecord(value) && Object.values(value).every((key) => typeof key === "string");
56
+ /**
57
+ * Whether a received message is one a frame sends.
58
+ *
59
+ * @param value - the message's data.
60
+ */
61
+ export const isFrameMessage = (value) => {
62
+ if (!isRecord(value) || typeof value["storyId"] !== "string")
63
+ return false;
64
+ switch (value["type"]) {
65
+ case "forgebook:ready":
66
+ return (typeof value["canReplay"] === "boolean" &&
67
+ typeof value["hasClock"] === "boolean" &&
68
+ isPanelArgs(value["args"]) &&
69
+ isTextKeys(value["textKeys"]) &&
70
+ isPanelArgTypes(value["argTypes"]) &&
71
+ isControlsSetting(value["controls"]) &&
72
+ isStringList(value["actions"]) &&
73
+ isFixedView(value["fixed"]));
74
+ case "forgebook:size":
75
+ return typeof value["height"] === "number";
76
+ case "forgebook:call":
77
+ return (typeof value["name"] === "string" &&
78
+ isStringList(value["values"]) &&
79
+ Array.isArray(value["details"]) &&
80
+ value["details"].every((detail) => detail === null || typeof detail === "string"));
81
+ case "forgebook:error":
82
+ case "forgebook:check-error":
83
+ return typeof value["message"] === "string";
84
+ case "forgebook:play":
85
+ return isPlayTrace(value["trace"]);
86
+ case "forgebook:checked":
87
+ return Array.isArray(value["violations"]) && value["violations"].every(isViolation);
88
+ default:
89
+ return false;
90
+ }
91
+ };
92
+ /**
93
+ * Whether a received message is one the shell sends.
94
+ *
95
+ * @param value - the message's data.
96
+ */
97
+ export const isShellMessage = (value) => {
98
+ if (!isRecord(value))
99
+ return false;
100
+ if (value["type"] === "forgebook:replay" ||
101
+ value["type"] === "forgebook:check" ||
102
+ value["type"] === "forgebook:play-again" ||
103
+ value["type"] === "forgebook:clock-restart") {
104
+ return true;
105
+ }
106
+ if (value["type"] === "forgebook:args")
107
+ return isPanelArgs(value["args"]);
108
+ if (value["type"] === "forgebook:view")
109
+ return isLiveView(value["view"]);
110
+ if (value["type"] === "forgebook:clock")
111
+ return isClockState(value["state"]);
112
+ if (value["type"] === "forgebook:tools") {
113
+ const tools = value["tools"];
114
+ return Array.isArray(tools) && tools.every((tool) => MEASURE_TOOLS.some((known) => known === tool));
115
+ }
116
+ if (value["type"] === "forgebook:matrix")
117
+ return value["matrix"] === null || isMatrix(value["matrix"]);
118
+ return value["type"] === "forgebook:events" && isStringList(value["names"]);
119
+ };
120
+ /**
121
+ * An event's argument written short for the call log.
122
+ *
123
+ * @param value - anything a callback received.
124
+ */
125
+ export const previewValue = (value) => {
126
+ if (typeof value === "string")
127
+ return JSON.stringify(value.length > 60 ? `${value.slice(0, 60)}…` : value);
128
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint")
129
+ return String(value);
130
+ if (value === null || value === undefined)
131
+ return String(value);
132
+ if (typeof value === "function")
133
+ return "ƒ";
134
+ if (typeof Event !== "undefined" && value instanceof Event)
135
+ return value.constructor.name;
136
+ if (isRecord(value) && "nativeEvent" in value)
137
+ return "SyntheticEvent";
138
+ return Array.isArray(value) ? `[…${value.length}]` : "{…}";
139
+ };
140
+ /** The most characters an argument's content keeps in the log. */
141
+ const DETAIL_LENGTH = 2000;
142
+ /**
143
+ * An argument's content for the log, when it is an object or a list: JSON, two spaces deep, a function as `ƒ`, an
144
+ * object met again as `[circular]`, cut past `DETAIL_LENGTH`; `null` for anything else (a text, a number, an event).
145
+ *
146
+ * @param value - anything a callback received.
147
+ */
148
+ export const detailOf = (value) => {
149
+ if (typeof value !== "object" || value === null)
150
+ return null;
151
+ if (typeof Event !== "undefined" && value instanceof Event)
152
+ return null;
153
+ if ("nativeEvent" in value)
154
+ return null;
155
+ const seen = new WeakSet();
156
+ const text = JSON.stringify(value, (_key, inner) => {
157
+ if (typeof inner === "function")
158
+ return "ƒ";
159
+ if (typeof inner === "bigint")
160
+ return `${inner}n`;
161
+ if (typeof inner === "object" && inner !== null) {
162
+ if (seen.has(inner))
163
+ return "[circular]";
164
+ seen.add(inner);
165
+ }
166
+ return inner;
167
+ }, 2);
168
+ return text.length > DETAIL_LENGTH ? `${text.slice(0, DETAIL_LENGTH)}…` : text;
169
+ };
170
+ /**
171
+ * The panel's values written in an address (`args`): JSON, the only form that keeps `"12"` and `12` apart.
172
+ *
173
+ * @param args - the values.
174
+ * @returns the parameter's text; empty when there is no value.
175
+ */
176
+ export const panelArgsParam = (args) => Object.keys(args).length === 0 ? "" : JSON.stringify(args);
177
+ /**
178
+ * The panel's values an address names: none when the parameter is missing, not JSON, or not values the panel sets.
179
+ *
180
+ * @param param - the `args` parameter.
181
+ */
182
+ export const parsePanelArgsParam = (param) => {
183
+ if (param === null || param === "")
184
+ return {};
185
+ try {
186
+ const value = JSON.parse(param);
187
+ return isPanelArgs(value) ? value : {};
188
+ }
189
+ catch {
190
+ return {};
191
+ }
192
+ };
193
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,WAAW,EAAkB,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,eAAe,EAAsB,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAe,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,WAAW,EAAkB,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAmB,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAkB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAiB,aAAa,EAAoB,MAAM,gBAAgB,CAAC;AA0JhF,yCAAyC;AACzC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAA8C,EAAE,CAC9E,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEvE,2DAA2D;AAC3D,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAc,EAAsB,EAAE,CAChE,QAAQ,CAAC,KAAK,CAAC;IACf,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CACxB,CAAC,GAAG,EAAE,EAAE,CACN,GAAG,KAAK,IAAI;QACZ,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAO,GAAG,KAAK,SAAS;QACxB,YAAY,CAAC,GAAG,CAAC;QACjB,UAAU,CA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BAAE,OAAO,YAAY,CAAC;YACzC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,EACD,CAAC,CACF,CAAC;IACF,OAAO,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AACjF,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAe,EAAU,EAAE,CACxD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAE7D;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAoB,EAAa,EAAE;IACrE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IAC9C,IAAI,CAAC;QACH,MAAM,KAAK,GAAY,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACzC,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The values a source names for the props panel (`StorySource.namedValues`): a story's own value found by name for
3
+ * the panel to show, and a name the panel sent turned back into the value for the story.
4
+ *
5
+ * @remarks
6
+ * A component or a function cannot cross between the shell and a frame; its name can, and each side holds the same
7
+ * source. Pure.
8
+ *
9
+ * @module
10
+ */
11
+ import type { StorySource } from "@forgebook/story-format/source";
12
+ import { type NamedArg, type PanelArgs } from "./messages.ts";
13
+ /** A source's named values: by the type as the props write it, then by name. */
14
+ export type NamedValues = NonNullable<StorySource["namedValues"]>;
15
+ /**
16
+ * The name of a value among the named ones, when it is one of them.
17
+ *
18
+ * @param value - a story's own arg.
19
+ * @param namedValues - the source's named values.
20
+ */
21
+ export declare const nameOf: (value: unknown, namedValues: NamedValues) => NamedArg | undefined;
22
+ /**
23
+ * A story's own args as the panel can show them: texts, numbers, booleans, `null` and lists of texts and numbers (a
24
+ * multiple choice's) as they are, a named value by its name; anything else is left out.
25
+ *
26
+ * @param args - the story's args.
27
+ * @param namedValues - the source's named values; none by default.
28
+ */
29
+ export declare const panelArgsOf: (args: Readonly<Record<string, unknown>>, namedValues?: NamedValues) => PanelArgs;
30
+ /**
31
+ * The panel's values as the story takes them: a name turned back into its value; a name the source no longer offers
32
+ * is left out, so the story keeps its own.
33
+ *
34
+ * @param args - the panel's values.
35
+ * @param namedValues - the source's named values; none by default.
36
+ */
37
+ export declare const storyArgsOf: (args: PanelArgs, namedValues?: NamedValues) => Readonly<Record<string, unknown>>;
38
+ //# sourceMappingURL=namedValues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namedValues.d.ts","sourceRoot":"","sources":["../../src/namedValues.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,EAA2C,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAEvG,gFAAgF;AAChF,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,OAAO,EAAE,aAAa,WAAW,KAAG,QAAQ,GAAG,SAO5E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GACtB,MAAM,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACvC,cAAa,WAAgB,KAC5B,SAeA,CAAC;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GACtB,MAAM,SAAS,EACf,cAAa,WAAgB,KAC5B,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOhC,CAAC"}