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.
- package/LICENSE +21 -0
- package/README.md +136 -2
- package/dist/bin/forgebook/catalogueVite.d.ts +16 -0
- package/dist/bin/forgebook/catalogueVite.d.ts.map +1 -0
- package/dist/bin/forgebook/catalogueVite.js +15 -0
- package/dist/bin/forgebook/catalogueVite.js.map +1 -0
- package/dist/bin/forgebook/forgebook.d.mts +3 -0
- package/dist/bin/forgebook/forgebook.d.mts.map +1 -0
- package/dist/bin/forgebook/forgebook.mjs +93 -0
- package/dist/bin/forgebook/forgebook.mjs.map +1 -0
- package/dist/bin/forgebook-docs/catalogueDocs.types.d.ts +90 -0
- package/dist/bin/forgebook-docs/catalogueDocs.types.d.ts.map +1 -0
- package/dist/bin/forgebook-docs/catalogueDocs.types.js +1 -0
- package/dist/bin/forgebook-docs/catalogueDocs.types.js.map +1 -0
- package/dist/bin/forgebook-docs/catalogueMarkdown.d.ts +9 -0
- package/dist/bin/forgebook-docs/catalogueMarkdown.d.ts.map +1 -0
- package/dist/bin/forgebook-docs/catalogueMarkdown.js +132 -0
- package/dist/bin/forgebook-docs/catalogueMarkdown.js.map +1 -0
- package/dist/bin/forgebook-docs/collectDocs.d.ts +17 -0
- package/dist/bin/forgebook-docs/collectDocs.d.ts.map +1 -0
- package/dist/bin/forgebook-docs/collectDocs.js +115 -0
- package/dist/bin/forgebook-docs/collectDocs.js.map +1 -0
- package/dist/bin/forgebook-docs/forgebook-docs.d.mts +3 -0
- package/dist/bin/forgebook-docs/forgebook-docs.d.mts.map +1 -0
- package/dist/bin/forgebook-docs/forgebook-docs.mjs +114 -0
- package/dist/bin/forgebook-docs/forgebook-docs.mjs.map +1 -0
- package/dist/bin/forgebook-docs/moduleDocs.d.ts +9 -0
- package/dist/bin/forgebook-docs/moduleDocs.d.ts.map +1 -0
- package/dist/bin/forgebook-docs/moduleDocs.js +62 -0
- package/dist/bin/forgebook-docs/moduleDocs.js.map +1 -0
- package/dist/bin/forgebook-docs/sassDocs.d.ts +20 -0
- package/dist/bin/forgebook-docs/sassDocs.d.ts.map +1 -0
- package/dist/bin/forgebook-docs/sassDocs.js +77 -0
- package/dist/bin/forgebook-docs/sassDocs.js.map +1 -0
- package/dist/bin/forgebook-texts/forgebook-texts.d.mts +3 -0
- package/dist/bin/forgebook-texts/forgebook-texts.d.mts.map +1 -0
- package/dist/bin/forgebook-texts/forgebook-texts.mjs +94 -0
- package/dist/bin/forgebook-texts/forgebook-texts.mjs.map +1 -0
- package/dist/bin/forgebook-texts/storyTextsReport.d.ts +26 -0
- package/dist/bin/forgebook-texts/storyTextsReport.d.ts.map +1 -0
- package/dist/bin/forgebook-texts/storyTextsReport.js +35 -0
- package/dist/bin/forgebook-texts/storyTextsReport.js.map +1 -0
- package/dist/bin/forgebook-texts/storyTextsReport.types.d.ts +25 -0
- package/dist/bin/forgebook-texts/storyTextsReport.types.d.ts.map +1 -0
- package/dist/bin/forgebook-texts/storyTextsReport.types.js +7 -0
- package/dist/bin/forgebook-texts/storyTextsReport.types.js.map +1 -0
- package/dist/src/a11y.d.ts +28 -0
- package/dist/src/a11y.d.ts.map +1 -0
- package/dist/src/a11y.js +29 -0
- package/dist/src/a11y.js.map +1 -0
- package/dist/src/argTypes.d.ts +114 -0
- package/dist/src/argTypes.d.ts.map +1 -0
- package/dist/src/argTypes.js +254 -0
- package/dist/src/argTypes.js.map +1 -0
- package/dist/src/backdrops.d.ts +88 -0
- package/dist/src/backdrops.d.ts.map +1 -0
- package/dist/src/backdrops.js +202 -0
- package/dist/src/backdrops.js.map +1 -0
- package/dist/src/catalogue.d.ts +120 -0
- package/dist/src/catalogue.d.ts.map +1 -0
- package/dist/src/catalogue.js +80 -0
- package/dist/src/catalogue.js.map +1 -0
- package/dist/src/componentDocs.d.ts +98 -0
- package/dist/src/componentDocs.d.ts.map +1 -0
- package/dist/src/componentDocs.js +47 -0
- package/dist/src/componentDocs.js.map +1 -0
- package/dist/src/frame/checkStory.d.ts +20 -0
- package/dist/src/frame/checkStory.d.ts.map +1 -0
- package/dist/src/frame/checkStory.js +31 -0
- package/dist/src/frame/checkStory.js.map +1 -0
- package/dist/src/frame/frame.css +51 -0
- package/dist/src/frame/frameClock.d.ts +53 -0
- package/dist/src/frame/frameClock.d.ts.map +1 -0
- package/dist/src/frame/frameClock.js +80 -0
- package/dist/src/frame/frameClock.js.map +1 -0
- package/dist/src/frame/frameStatus.d.ts +8 -0
- package/dist/src/frame/frameStatus.d.ts.map +1 -0
- package/dist/src/frame/frameStatus.js +8 -0
- package/dist/src/frame/frameStatus.js.map +1 -0
- package/dist/src/frame/frameView.d.ts +33 -0
- package/dist/src/frame/frameView.d.ts.map +1 -0
- package/dist/src/frame/frameView.js +134 -0
- package/dist/src/frame/frameView.js.map +1 -0
- package/dist/src/frame/matrixLayout.d.ts +36 -0
- package/dist/src/frame/matrixLayout.d.ts.map +1 -0
- package/dist/src/frame/matrixLayout.js +87 -0
- package/dist/src/frame/matrixLayout.js.map +1 -0
- package/dist/src/frame/measureTools.d.ts +24 -0
- package/dist/src/frame/measureTools.d.ts.map +1 -0
- package/dist/src/frame/measureTools.js +141 -0
- package/dist/src/frame/measureTools.js.map +1 -0
- package/dist/src/frame/mountFrame.d.ts +47 -0
- package/dist/src/frame/mountFrame.d.ts.map +1 -0
- package/dist/src/frame/mountFrame.js +229 -0
- package/dist/src/frame/mountFrame.js.map +1 -0
- package/dist/src/frame/playStory.d.ts +40 -0
- package/dist/src/frame/playStory.d.ts.map +1 -0
- package/dist/src/frame/playStory.js +55 -0
- package/dist/src/frame/playStory.js.map +1 -0
- package/dist/src/frame/renderer.d.ts +85 -0
- package/dist/src/frame/renderer.d.ts.map +1 -0
- package/dist/src/frame/renderer.js +18 -0
- package/dist/src/frame/renderer.js.map +1 -0
- package/dist/src/frame/settle.d.ts +24 -0
- package/dist/src/frame/settle.d.ts.map +1 -0
- package/dist/src/frame/settle.js +25 -0
- package/dist/src/frame/settle.js.map +1 -0
- package/dist/src/frame/staleModule.d.ts +40 -0
- package/dist/src/frame/staleModule.d.ts.map +1 -0
- package/dist/src/frame/staleModule.js +74 -0
- package/dist/src/frame/staleModule.js.map +1 -0
- package/dist/src/frame/storyCanvas.d.ts +21 -0
- package/dist/src/frame/storyCanvas.d.ts.map +1 -0
- package/dist/src/frame/storyCanvas.js +30 -0
- package/dist/src/frame/storyCanvas.js.map +1 -0
- package/dist/src/frame/storyHooks.d.ts +31 -0
- package/dist/src/frame/storyHooks.d.ts.map +1 -0
- package/dist/src/frame/storyHooks.js +59 -0
- package/dist/src/frame/storyHooks.js.map +1 -0
- package/dist/src/frame/storyModule.d.ts +104 -0
- package/dist/src/frame/storyModule.d.ts.map +1 -0
- package/dist/src/frame/storyModule.js +205 -0
- package/dist/src/frame/storyModule.js.map +1 -0
- package/dist/src/frame/storyRun.d.ts +96 -0
- package/dist/src/frame/storyRun.d.ts.map +1 -0
- package/dist/src/frame/storyRun.js +318 -0
- package/dist/src/frame/storyRun.js.map +1 -0
- package/dist/src/languages.d.ts +15 -0
- package/dist/src/languages.d.ts.map +1 -0
- package/dist/src/languages.js +8 -0
- package/dist/src/languages.js.map +1 -0
- package/dist/src/matrix.d.ts +56 -0
- package/dist/src/matrix.d.ts.map +1 -0
- package/dist/src/matrix.js +61 -0
- package/dist/src/matrix.js.map +1 -0
- package/dist/src/messages.d.ts +203 -0
- package/dist/src/messages.d.ts.map +1 -0
- package/dist/src/messages.js +193 -0
- package/dist/src/messages.js.map +1 -0
- package/dist/src/namedValues.d.ts +38 -0
- package/dist/src/namedValues.d.ts.map +1 -0
- package/dist/src/namedValues.js +48 -0
- package/dist/src/namedValues.js.map +1 -0
- package/dist/src/pageConfig.d.ts +23 -0
- package/dist/src/pageConfig.d.ts.map +1 -0
- package/dist/src/pageConfig.js +1 -0
- package/dist/src/pageConfig.js.map +1 -0
- package/dist/src/playTrace.d.ts +41 -0
- package/dist/src/playTrace.d.ts.map +1 -0
- package/dist/src/playTrace.js +35 -0
- package/dist/src/playTrace.js.map +1 -0
- package/dist/src/shell/A11yTab.d.ts +44 -0
- package/dist/src/shell/A11yTab.d.ts.map +1 -0
- package/dist/src/shell/A11yTab.js +30 -0
- package/dist/src/shell/A11yTab.js.map +1 -0
- package/dist/src/shell/ApiReference.d.ts +18 -0
- package/dist/src/shell/ApiReference.d.ts.map +1 -0
- package/dist/src/shell/ApiReference.js +41 -0
- package/dist/src/shell/ApiReference.js.map +1 -0
- package/dist/src/shell/ClockControls.d.ts +43 -0
- package/dist/src/shell/ClockControls.d.ts.map +1 -0
- package/dist/src/shell/ClockControls.js +53 -0
- package/dist/src/shell/ClockControls.js.map +1 -0
- package/dist/src/shell/Code.d.ts +16 -0
- package/dist/src/shell/Code.d.ts.map +1 -0
- package/dist/src/shell/Code.js +9 -0
- package/dist/src/shell/Code.js.map +1 -0
- package/dist/src/shell/CodeTab.d.ts +17 -0
- package/dist/src/shell/CodeTab.d.ts.map +1 -0
- package/dist/src/shell/CodeTab.js +17 -0
- package/dist/src/shell/CodeTab.js.map +1 -0
- package/dist/src/shell/CodeText.d.ts +16 -0
- package/dist/src/shell/CodeText.d.ts.map +1 -0
- package/dist/src/shell/CodeText.js +10 -0
- package/dist/src/shell/CodeText.js.map +1 -0
- package/dist/src/shell/ComponentPage.d.ts +38 -0
- package/dist/src/shell/ComponentPage.d.ts.map +1 -0
- package/dist/src/shell/ComponentPage.js +146 -0
- package/dist/src/shell/ComponentPage.js.map +1 -0
- package/dist/src/shell/Dock.d.ts +42 -0
- package/dist/src/shell/Dock.d.ts.map +1 -0
- package/dist/src/shell/Dock.js +90 -0
- package/dist/src/shell/Dock.js.map +1 -0
- package/dist/src/shell/EventsTab.d.ts +25 -0
- package/dist/src/shell/EventsTab.d.ts.map +1 -0
- package/dist/src/shell/EventsTab.js +26 -0
- package/dist/src/shell/EventsTab.js.map +1 -0
- package/dist/src/shell/FrameView.d.ts +49 -0
- package/dist/src/shell/FrameView.d.ts.map +1 -0
- package/dist/src/shell/FrameView.js +29 -0
- package/dist/src/shell/FrameView.js.map +1 -0
- package/dist/src/shell/HomePage.d.ts +39 -0
- package/dist/src/shell/HomePage.d.ts.map +1 -0
- package/dist/src/shell/HomePage.js +85 -0
- package/dist/src/shell/HomePage.js.map +1 -0
- package/dist/src/shell/InteractionsTab.d.ts +28 -0
- package/dist/src/shell/InteractionsTab.d.ts.map +1 -0
- package/dist/src/shell/InteractionsTab.js +17 -0
- package/dist/src/shell/InteractionsTab.js.map +1 -0
- package/dist/src/shell/MatrixPicker.d.ts +24 -0
- package/dist/src/shell/MatrixPicker.d.ts.map +1 -0
- package/dist/src/shell/MatrixPicker.js +29 -0
- package/dist/src/shell/MatrixPicker.js.map +1 -0
- package/dist/src/shell/PackageHtml.d.ts +17 -0
- package/dist/src/shell/PackageHtml.d.ts.map +1 -0
- package/dist/src/shell/PackageHtml.js +13 -0
- package/dist/src/shell/PackageHtml.js.map +1 -0
- package/dist/src/shell/PartsTab.d.ts +23 -0
- package/dist/src/shell/PartsTab.d.ts.map +1 -0
- package/dist/src/shell/PartsTab.js +23 -0
- package/dist/src/shell/PartsTab.js.map +1 -0
- package/dist/src/shell/PropFields.d.ts +31 -0
- package/dist/src/shell/PropFields.d.ts.map +1 -0
- package/dist/src/shell/PropFields.js +81 -0
- package/dist/src/shell/PropFields.js.map +1 -0
- package/dist/src/shell/PropsTab.d.ts +45 -0
- package/dist/src/shell/PropsTab.d.ts.map +1 -0
- package/dist/src/shell/PropsTab.js +81 -0
- package/dist/src/shell/PropsTab.js.map +1 -0
- package/dist/src/shell/SchemeSwitches.d.ts +24 -0
- package/dist/src/shell/SchemeSwitches.d.ts.map +1 -0
- package/dist/src/shell/SchemeSwitches.js +36 -0
- package/dist/src/shell/SchemeSwitches.js.map +1 -0
- package/dist/src/shell/Segmented.d.ts +41 -0
- package/dist/src/shell/Segmented.d.ts.map +1 -0
- package/dist/src/shell/Segmented.js +19 -0
- package/dist/src/shell/Segmented.js.map +1 -0
- package/dist/src/shell/Shell.d.ts +49 -0
- package/dist/src/shell/Shell.d.ts.map +1 -0
- package/dist/src/shell/Shell.js +279 -0
- package/dist/src/shell/Shell.js.map +1 -0
- package/dist/src/shell/Sidebar.d.ts +52 -0
- package/dist/src/shell/Sidebar.d.ts.map +1 -0
- package/dist/src/shell/Sidebar.js +132 -0
- package/dist/src/shell/Sidebar.js.map +1 -0
- package/dist/src/shell/SidebarHandle.d.ts +29 -0
- package/dist/src/shell/SidebarHandle.d.ts.map +1 -0
- package/dist/src/shell/SidebarHandle.js +46 -0
- package/dist/src/shell/SidebarHandle.js.map +1 -0
- package/dist/src/shell/Stage.d.ts +68 -0
- package/dist/src/shell/Stage.d.ts.map +1 -0
- package/dist/src/shell/Stage.js +218 -0
- package/dist/src/shell/Stage.js.map +1 -0
- package/dist/src/shell/StageTools.d.ts +27 -0
- package/dist/src/shell/StageTools.d.ts.map +1 -0
- package/dist/src/shell/StageTools.js +34 -0
- package/dist/src/shell/StageTools.js.map +1 -0
- package/dist/src/shell/StageViewport.d.ts +46 -0
- package/dist/src/shell/StageViewport.d.ts.map +1 -0
- package/dist/src/shell/StageViewport.js +173 -0
- package/dist/src/shell/StageViewport.js.map +1 -0
- package/dist/src/shell/StoryCodeBlock.d.ts +35 -0
- package/dist/src/shell/StoryCodeBlock.d.ts.map +1 -0
- package/dist/src/shell/StoryCodeBlock.js +27 -0
- package/dist/src/shell/StoryCodeBlock.js.map +1 -0
- package/dist/src/shell/StoryPicker.d.ts +26 -0
- package/dist/src/shell/StoryPicker.d.ts.map +1 -0
- package/dist/src/shell/StoryPicker.js +32 -0
- package/dist/src/shell/StoryPicker.js.map +1 -0
- package/dist/src/shell/Toolbar.d.ts +40 -0
- package/dist/src/shell/Toolbar.d.ts.map +1 -0
- package/dist/src/shell/Toolbar.js +125 -0
- package/dist/src/shell/Toolbar.js.map +1 -0
- package/dist/src/shell/WidthField.d.ts +24 -0
- package/dist/src/shell/WidthField.d.ts.map +1 -0
- package/dist/src/shell/WidthField.js +40 -0
- package/dist/src/shell/WidthField.js.map +1 -0
- package/dist/src/shell/catalogueContext.d.ts +6 -0
- package/dist/src/shell/catalogueContext.d.ts.map +1 -0
- package/dist/src/shell/catalogueContext.js +14 -0
- package/dist/src/shell/catalogueContext.js.map +1 -0
- package/dist/src/shell/codeTokens.d.ts +23 -0
- package/dist/src/shell/codeTokens.d.ts.map +1 -0
- package/dist/src/shell/codeTokens.js +48 -0
- package/dist/src/shell/codeTokens.js.map +1 -0
- package/dist/src/shell/codeWriter.d.ts +6 -0
- package/dist/src/shell/codeWriter.d.ts.map +1 -0
- package/dist/src/shell/codeWriter.js +14 -0
- package/dist/src/shell/codeWriter.js.map +1 -0
- package/dist/src/shell/compareVariants.d.ts +35 -0
- package/dist/src/shell/compareVariants.d.ts.map +1 -0
- package/dist/src/shell/compareVariants.js +68 -0
- package/dist/src/shell/compareVariants.js.map +1 -0
- package/dist/src/shell/dockTabs.d.ts +63 -0
- package/dist/src/shell/dockTabs.d.ts.map +1 -0
- package/dist/src/shell/dockTabs.js +140 -0
- package/dist/src/shell/dockTabs.js.map +1 -0
- package/dist/src/shell/icons.d.ts +47 -0
- package/dist/src/shell/icons.d.ts.map +1 -0
- package/dist/src/shell/icons.js +36 -0
- package/dist/src/shell/icons.js.map +1 -0
- package/dist/src/shell/keyboard.d.ts +35 -0
- package/dist/src/shell/keyboard.d.ts.map +1 -0
- package/dist/src/shell/keyboard.js +51 -0
- package/dist/src/shell/keyboard.js.map +1 -0
- package/dist/src/shell/mountShell.d.ts +22 -0
- package/dist/src/shell/mountShell.d.ts.map +1 -0
- package/dist/src/shell/mountShell.js +39 -0
- package/dist/src/shell/mountShell.js.map +1 -0
- package/dist/src/shell/shell.css +1831 -0
- package/dist/src/shell/strings.d.ts +184 -0
- package/dist/src/shell/strings.d.ts.map +1 -0
- package/dist/src/shell/strings.js +188 -0
- package/dist/src/shell/strings.js.map +1 -0
- package/dist/src/shell/switchView.d.ts +23 -0
- package/dist/src/shell/switchView.d.ts.map +1 -0
- package/dist/src/shell/switchView.js +19 -0
- package/dist/src/shell/switchView.js.map +1 -0
- package/dist/src/shell/treeSearch.d.ts +35 -0
- package/dist/src/shell/treeSearch.d.ts.map +1 -0
- package/dist/src/shell/treeSearch.js +60 -0
- package/dist/src/shell/treeSearch.js.map +1 -0
- package/dist/src/shell/useComponentDocs.d.ts +16 -0
- package/dist/src/shell/useComponentDocs.d.ts.map +1 -0
- package/dist/src/shell/useComponentDocs.js +25 -0
- package/dist/src/shell/useComponentDocs.js.map +1 -0
- package/dist/src/shell/useCopy.d.ts +10 -0
- package/dist/src/shell/useCopy.d.ts.map +1 -0
- package/dist/src/shell/useCopy.js +23 -0
- package/dist/src/shell/useCopy.js.map +1 -0
- package/dist/src/shell/useFrameMessages.d.ts +54 -0
- package/dist/src/shell/useFrameMessages.d.ts.map +1 -0
- package/dist/src/shell/useFrameMessages.js +90 -0
- package/dist/src/shell/useFrameMessages.js.map +1 -0
- package/dist/src/shell/useFrameQueue.d.ts +29 -0
- package/dist/src/shell/useFrameQueue.d.ts.map +1 -0
- package/dist/src/shell/useFrameQueue.js +72 -0
- package/dist/src/shell/useFrameQueue.js.map +1 -0
- package/dist/src/shell/useLiveView.d.ts +29 -0
- package/dist/src/shell/useLiveView.d.ts.map +1 -0
- package/dist/src/shell/useLiveView.js +51 -0
- package/dist/src/shell/useLiveView.js.map +1 -0
- package/dist/src/shell/useLoaded.d.ts +20 -0
- package/dist/src/shell/useLoaded.d.ts.map +1 -0
- package/dist/src/shell/useLoaded.js +40 -0
- package/dist/src/shell/useLoaded.js.map +1 -0
- package/dist/src/shell/usePageDoc.d.ts +20 -0
- package/dist/src/shell/usePageDoc.d.ts.map +1 -0
- package/dist/src/shell/usePageDoc.js +21 -0
- package/dist/src/shell/usePageDoc.js.map +1 -0
- package/dist/src/shell/usePopover.d.ts +23 -0
- package/dist/src/shell/usePopover.d.ts.map +1 -0
- package/dist/src/shell/usePopover.js +39 -0
- package/dist/src/shell/usePopover.js.map +1 -0
- package/dist/src/shell/useRecentPages.d.ts +21 -0
- package/dist/src/shell/useRecentPages.d.ts.map +1 -0
- package/dist/src/shell/useRecentPages.js +62 -0
- package/dist/src/shell/useRecentPages.js.map +1 -0
- package/dist/src/shell/useScrollMemory.d.ts +40 -0
- package/dist/src/shell/useScrollMemory.d.ts.map +1 -0
- package/dist/src/shell/useScrollMemory.js +69 -0
- package/dist/src/shell/useScrollMemory.js.map +1 -0
- package/dist/src/shell/useSidebarLayout.d.ts +14 -0
- package/dist/src/shell/useSidebarLayout.d.ts.map +1 -0
- package/dist/src/shell/useSidebarLayout.js +19 -0
- package/dist/src/shell/useSidebarLayout.js.map +1 -0
- package/dist/src/shell/useStored.d.ts +11 -0
- package/dist/src/shell/useStored.d.ts.map +1 -0
- package/dist/src/shell/useStored.js +68 -0
- package/dist/src/shell/useStored.js.map +1 -0
- package/dist/src/shell/useStoryCode.d.ts +14 -0
- package/dist/src/shell/useStoryCode.d.ts.map +1 -0
- package/dist/src/shell/useStoryCode.js +29 -0
- package/dist/src/shell/useStoryCode.js.map +1 -0
- package/dist/src/shell/useStoryHeights.d.ts +9 -0
- package/dist/src/shell/useStoryHeights.d.ts.map +1 -0
- package/dist/src/shell/useStoryHeights.js +31 -0
- package/dist/src/shell/useStoryHeights.js.map +1 -0
- package/dist/src/shell/useStoryIdsElement.d.ts +7 -0
- package/dist/src/shell/useStoryIdsElement.d.ts.map +1 -0
- package/dist/src/shell/useStoryIdsElement.js +29 -0
- package/dist/src/shell/useStoryIdsElement.js.map +1 -0
- package/dist/src/shell/useStoryKeys.d.ts +11 -0
- package/dist/src/shell/useStoryKeys.d.ts.map +1 -0
- package/dist/src/shell/useStoryKeys.js +40 -0
- package/dist/src/shell/useStoryKeys.js.map +1 -0
- package/dist/src/shell/useSystemDark.d.ts +3 -0
- package/dist/src/shell/useSystemDark.d.ts.map +1 -0
- package/dist/src/shell/useSystemDark.js +19 -0
- package/dist/src/shell/useSystemDark.js.map +1 -0
- package/dist/src/sourceFiles.d.ts +18 -0
- package/dist/src/sourceFiles.d.ts.map +1 -0
- package/dist/src/sourceFiles.js +22 -0
- package/dist/src/sourceFiles.js.map +1 -0
- package/dist/src/storyBackground.d.ts +21 -0
- package/dist/src/storyBackground.d.ts.map +1 -0
- package/dist/src/storyBackground.js +27 -0
- package/dist/src/storyBackground.js.map +1 -0
- package/dist/src/storyClock.d.ts +62 -0
- package/dist/src/storyClock.d.ts.map +1 -0
- package/dist/src/storyClock.js +51 -0
- package/dist/src/storyClock.js.map +1 -0
- package/dist/src/storyGlobals.d.ts +60 -0
- package/dist/src/storyGlobals.d.ts.map +1 -0
- package/dist/src/storyGlobals.js +117 -0
- package/dist/src/storyGlobals.js.map +1 -0
- package/dist/src/storyHeights.d.ts +37 -0
- package/dist/src/storyHeights.d.ts.map +1 -0
- package/dist/src/storyHeights.js +53 -0
- package/dist/src/storyHeights.js.map +1 -0
- package/dist/src/storyIdsElement.d.ts +9 -0
- package/dist/src/storyIdsElement.d.ts.map +1 -0
- package/dist/src/storyIdsElement.js +9 -0
- package/dist/src/storyIdsElement.js.map +1 -0
- package/dist/src/storyTexts.d.ts +43 -0
- package/dist/src/storyTexts.d.ts.map +1 -0
- package/dist/src/storyTexts.js +71 -0
- package/dist/src/storyTexts.js.map +1 -0
- package/dist/src/storyTree.d.ts +215 -0
- package/dist/src/storyTree.d.ts.map +1 -0
- package/dist/src/storyTree.js +308 -0
- package/dist/src/storyTree.js.map +1 -0
- package/dist/src/switches.d.ts +156 -0
- package/dist/src/switches.d.ts.map +1 -0
- package/dist/src/switches.js +193 -0
- package/dist/src/switches.js.map +1 -0
- package/dist/src/viewState.d.ts +194 -0
- package/dist/src/viewState.d.ts.map +1 -0
- package/dist/src/viewState.js +303 -0
- package/dist/src/viewState.js.map +1 -0
- package/dist/src/vite/adapter.d.ts +70 -0
- package/dist/src/vite/adapter.d.ts.map +1 -0
- package/dist/src/vite/adapter.js +22 -0
- package/dist/src/vite/adapter.js.map +1 -0
- package/dist/src/vite/autoTitle.d.ts +28 -0
- package/dist/src/vite/autoTitle.d.ts.map +1 -0
- package/dist/src/vite/autoTitle.js +44 -0
- package/dist/src/vite/autoTitle.js.map +1 -0
- package/dist/src/vite/componentPage.d.ts +34 -0
- package/dist/src/vite/componentPage.d.ts.map +1 -0
- package/dist/src/vite/componentPage.js +94 -0
- package/dist/src/vite/componentPage.js.map +1 -0
- package/dist/src/vite/config.d.ts +72 -0
- package/dist/src/vite/config.d.ts.map +1 -0
- package/dist/src/vite/config.js +25 -0
- package/dist/src/vite/config.js.map +1 -0
- package/dist/src/vite/configFile.d.ts +76 -0
- package/dist/src/vite/configFile.d.ts.map +1 -0
- package/dist/src/vite/configFile.js +190 -0
- package/dist/src/vite/configFile.js.map +1 -0
- package/dist/src/vite/docsExtractor.d.ts +46 -0
- package/dist/src/vite/docsExtractor.d.ts.map +1 -0
- package/dist/src/vite/docsExtractor.js +88 -0
- package/dist/src/vite/docsExtractor.js.map +1 -0
- package/dist/src/vite/docsProgram.d.ts +42 -0
- package/dist/src/vite/docsProgram.d.ts.map +1 -0
- package/dist/src/vite/docsProgram.js +144 -0
- package/dist/src/vite/docsProgram.js.map +1 -0
- package/dist/src/vite/docsWorker.d.ts +2 -0
- package/dist/src/vite/docsWorker.d.ts.map +1 -0
- package/dist/src/vite/docsWorker.js +68 -0
- package/dist/src/vite/docsWorker.js.map +1 -0
- package/dist/src/vite/forcedStates.d.ts +27 -0
- package/dist/src/vite/forcedStates.d.ts.map +1 -0
- package/dist/src/vite/forcedStates.js +60 -0
- package/dist/src/vite/forcedStates.js.map +1 -0
- package/dist/src/vite/forgebookPlugin.d.ts +28 -0
- package/dist/src/vite/forgebookPlugin.d.ts.map +1 -0
- package/dist/src/vite/forgebookPlugin.js +375 -0
- package/dist/src/vite/forgebookPlugin.js.map +1 -0
- package/dist/src/vite/highlightCode.d.ts +16 -0
- package/dist/src/vite/highlightCode.d.ts.map +1 -0
- package/dist/src/vite/highlightCode.js +82 -0
- package/dist/src/vite/highlightCode.js.map +1 -0
- package/dist/src/vite/indexStoryFile.d.ts +35 -0
- package/dist/src/vite/indexStoryFile.d.ts.map +1 -0
- package/dist/src/vite/indexStoryFile.js +458 -0
- package/dist/src/vite/indexStoryFile.js.map +1 -0
- package/dist/src/vite/pages.d.ts +49 -0
- package/dist/src/vite/pages.d.ts.map +1 -0
- package/dist/src/vite/pages.js +171 -0
- package/dist/src/vite/pages.js.map +1 -0
- package/dist/src/vite/prebundled.d.ts +30 -0
- package/dist/src/vite/prebundled.d.ts.map +1 -0
- package/dist/src/vite/prebundled.js +81 -0
- package/dist/src/vite/prebundled.js.map +1 -0
- package/dist/src/vite/storyCode.d.ts +28 -0
- package/dist/src/vite/storyCode.d.ts.map +1 -0
- package/dist/src/vite/storyCode.js +80 -0
- package/dist/src/vite/storyCode.js.map +1 -0
- package/dist/src/vite/storyFilesModule.d.ts +17 -0
- package/dist/src/vite/storyFilesModule.d.ts.map +1 -0
- package/dist/src/vite/storyFilesModule.js +64 -0
- package/dist/src/vite/storyFilesModule.js.map +1 -0
- package/dist/src/vite/storyMeta.d.ts +34 -0
- package/dist/src/vite/storyMeta.d.ts.map +1 -0
- package/dist/src/vite/storyMeta.js +74 -0
- package/dist/src/vite/storyMeta.js.map +1 -0
- package/dist/src/vite/typeScriptPieces.d.ts +23 -0
- package/dist/src/vite/typeScriptPieces.d.ts.map +1 -0
- package/dist/src/vite/typeScriptPieces.js +236 -0
- package/dist/src/vite/typeScriptPieces.js.map +1 -0
- package/package.json +202 -3
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/** The id of the style sheet that draws the outlines and the grid. */
|
|
2
|
+
const STYLE_ID = "forgebook-measure-style";
|
|
3
|
+
/** The id of the overlay that draws the measured box. */
|
|
4
|
+
const OVERLAY_ID = "forgebook-measure-overlay";
|
|
5
|
+
/**
|
|
6
|
+
* The sheet for the outline and the grid tools.
|
|
7
|
+
*
|
|
8
|
+
* @param tools - the tools drawn.
|
|
9
|
+
* @param gridStep - the grid's step, in CSS px.
|
|
10
|
+
*/
|
|
11
|
+
const toolSheet = (tools, gridStep) => [
|
|
12
|
+
tools.includes("outline")
|
|
13
|
+
? `body *:not(#root, #${OVERLAY_ID}, #${OVERLAY_ID} *) { ` +
|
|
14
|
+
"outline: 1px solid rgb(232 62 140 / 0.55) !important; outline-offset: -1px !important; }"
|
|
15
|
+
: "",
|
|
16
|
+
tools.includes("grid")
|
|
17
|
+
? "#root { background-image: linear-gradient(rgb(23 104 228 / 0.12) 1px, transparent 1px), " +
|
|
18
|
+
"linear-gradient(90deg, rgb(23 104 228 / 0.12) 1px, transparent 1px) !important; " +
|
|
19
|
+
`background-size: ${gridStep}px ${gridStep}px !important; }`
|
|
20
|
+
: ""
|
|
21
|
+
].join("\n");
|
|
22
|
+
/** A length in CSS px, written short. */
|
|
23
|
+
const px = (value) => `${Math.round(value * 10) / 10}`;
|
|
24
|
+
/** The overlay of the measured box, made once. */
|
|
25
|
+
const overlayOf = (document) => {
|
|
26
|
+
const existing = document.getElementById(OVERLAY_ID);
|
|
27
|
+
if (existing !== null)
|
|
28
|
+
return existing;
|
|
29
|
+
const overlay = document.createElement("div");
|
|
30
|
+
overlay.id = OVERLAY_ID;
|
|
31
|
+
overlay.setAttribute("aria-hidden", "true");
|
|
32
|
+
Object.assign(overlay.style, {
|
|
33
|
+
position: "fixed",
|
|
34
|
+
zIndex: "2147483647",
|
|
35
|
+
pointerEvents: "none",
|
|
36
|
+
boxSizing: "border-box",
|
|
37
|
+
display: "none"
|
|
38
|
+
});
|
|
39
|
+
document.body.append(overlay);
|
|
40
|
+
return overlay;
|
|
41
|
+
};
|
|
42
|
+
/** Draws an element's box on the overlay: its padding and margin shaded, its size in a label. */
|
|
43
|
+
const drawBox = (overlay, element) => {
|
|
44
|
+
const view = element.ownerDocument.defaultView;
|
|
45
|
+
if (view === null)
|
|
46
|
+
return;
|
|
47
|
+
const rect = element.getBoundingClientRect();
|
|
48
|
+
const style = view.getComputedStyle(element);
|
|
49
|
+
const sides = ["top", "right", "bottom", "left"];
|
|
50
|
+
const lengths = (property) => sides.map((side) => Number.parseFloat(style.getPropertyValue(`${property}-${side}`)) || 0);
|
|
51
|
+
const margin = lengths("margin");
|
|
52
|
+
const padding = lengths("padding");
|
|
53
|
+
const [mt = 0, mr = 0, mb = 0, ml = 0] = margin;
|
|
54
|
+
const [pt = 0, pr = 0, pb = 0, pl = 0] = padding;
|
|
55
|
+
Object.assign(overlay.style, {
|
|
56
|
+
display: "block",
|
|
57
|
+
left: `${rect.left - ml}px`,
|
|
58
|
+
top: `${rect.top - mt}px`,
|
|
59
|
+
width: `${rect.width + ml + mr}px`,
|
|
60
|
+
height: `${rect.height + mt + mb}px`,
|
|
61
|
+
// the margin in orange, the padding in green, the content in blue: the colours browsers' inspectors use
|
|
62
|
+
borderStyle: "solid",
|
|
63
|
+
borderColor: "rgb(246 178 107 / 0.5)",
|
|
64
|
+
borderWidth: `${mt}px ${mr}px ${mb}px ${ml}px`,
|
|
65
|
+
background: "rgb(147 196 125 / 0.45)",
|
|
66
|
+
backgroundClip: "padding-box"
|
|
67
|
+
});
|
|
68
|
+
overlay.innerHTML = "";
|
|
69
|
+
const content = overlay.ownerDocument.createElement("div");
|
|
70
|
+
Object.assign(content.style, {
|
|
71
|
+
position: "absolute",
|
|
72
|
+
left: `${pl}px`,
|
|
73
|
+
top: `${pt}px`,
|
|
74
|
+
right: `${pr}px`,
|
|
75
|
+
bottom: `${pb}px`,
|
|
76
|
+
background: "rgb(111 168 220 / 0.55)"
|
|
77
|
+
});
|
|
78
|
+
const label = overlay.ownerDocument.createElement("div");
|
|
79
|
+
label.textContent = `${px(rect.width)} × ${px(rect.height)}`;
|
|
80
|
+
Object.assign(label.style, {
|
|
81
|
+
position: "absolute",
|
|
82
|
+
left: "0",
|
|
83
|
+
top: rect.top - mt >= 20 ? "-20px" : "100%",
|
|
84
|
+
padding: "1px 5px",
|
|
85
|
+
borderRadius: "3px",
|
|
86
|
+
background: "#1d1d1f",
|
|
87
|
+
color: "#fff",
|
|
88
|
+
font: "500 11px/16px ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
89
|
+
whiteSpace: "nowrap"
|
|
90
|
+
});
|
|
91
|
+
overlay.append(content, label);
|
|
92
|
+
};
|
|
93
|
+
/** Stops measuring: the listener a call of `applyTools` added, if any. */
|
|
94
|
+
let stopMeasuring;
|
|
95
|
+
/**
|
|
96
|
+
* Draws the tools over the story, replacing the ones drawn before.
|
|
97
|
+
*
|
|
98
|
+
* @param document - the frame's document.
|
|
99
|
+
* @param tools - the tools to draw; none removes them all.
|
|
100
|
+
* @param gridStep - the grid's step, in CSS px; 8 by default.
|
|
101
|
+
*/
|
|
102
|
+
export const applyTools = (document, tools, gridStep = 8) => {
|
|
103
|
+
const sheet = toolSheet(tools, gridStep);
|
|
104
|
+
let style = document.getElementById(STYLE_ID);
|
|
105
|
+
if (style === null) {
|
|
106
|
+
style = document.createElement("style");
|
|
107
|
+
style.id = STYLE_ID;
|
|
108
|
+
document.head.append(style);
|
|
109
|
+
}
|
|
110
|
+
style.textContent = sheet;
|
|
111
|
+
stopMeasuring?.();
|
|
112
|
+
stopMeasuring = undefined;
|
|
113
|
+
const overlay = overlayOf(document);
|
|
114
|
+
overlay.style.display = "none";
|
|
115
|
+
if (!tools.includes("measure"))
|
|
116
|
+
return;
|
|
117
|
+
const measure = (event) => {
|
|
118
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
119
|
+
// the story's elements and its portals: anything in the body but the root itself and the overlay
|
|
120
|
+
const isStoryElement = target !== null &&
|
|
121
|
+
target !== document.body &&
|
|
122
|
+
target.id !== "root" &&
|
|
123
|
+
document.body.contains(target) &&
|
|
124
|
+
!overlay.contains(target);
|
|
125
|
+
if (!isStoryElement) {
|
|
126
|
+
overlay.style.display = "none";
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
drawBox(overlay, target);
|
|
130
|
+
};
|
|
131
|
+
const hide = () => {
|
|
132
|
+
overlay.style.display = "none";
|
|
133
|
+
};
|
|
134
|
+
document.addEventListener("pointermove", measure);
|
|
135
|
+
document.addEventListener("pointerleave", hide);
|
|
136
|
+
stopMeasuring = () => {
|
|
137
|
+
document.removeEventListener("pointermove", measure);
|
|
138
|
+
document.removeEventListener("pointerleave", hide);
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=measureTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measureTools.js","sourceRoot":"","sources":["../../../src/frame/measureTools.ts"],"names":[],"mappings":"AAgBA,sEAAsE;AACtE,MAAM,QAAQ,GAAG,yBAAyB,CAAC;AAE3C,yDAAyD;AACzD,MAAM,UAAU,GAAG,2BAA2B,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,SAAS,GAAG,CAAC,KAA6B,EAAE,QAAgB,EAAU,EAAE,CAC5E;IACE,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC;QACvB,CAAC,CAAC,sBAAsB,UAAU,MAAM,UAAU,QAAQ;YACxD,0FAA0F;QAC5F,CAAC,CAAC,EAAE;IACN,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QACpB,CAAC,CAAC,0FAA0F;YAC1F,kFAAkF;YAClF,oBAAoB,QAAQ,MAAM,QAAQ,kBAAkB;QAC9D,CAAC,CAAC,EAAE;CACP,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEf,yCAAyC;AACzC,MAAM,EAAE,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC;AAEvE,kDAAkD;AAClD,MAAM,SAAS,GAAG,CAAC,QAAkB,EAAe,EAAE;IACpD,MAAM,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IACrD,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,QAAQ,CAAC;IACvC,MAAM,O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
2
|
+
* The entry of a story's frame: reads the story and the view from the address, loads the source's style sheets for
|
|
3
|
+
* the view, then has the framework draw the story and, once its play function is over, tells the shell it is ready.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* One document per story: the style sheets of the Styles setting, the switches on the root and anything the
|
|
7
|
+
* story mounts on `body` stay in this document. The tests open the same address and wait for `data-forgebook-status`
|
|
8
|
+
* on the root (`ready` or `error`), never for a delay. A Live story's clock runs from its start, or stays held there when
|
|
9
|
+
* the address says so (`clock=held`, what the tests open). The framework is the renderer the framework package
|
|
10
|
+
* passes (`renderer.ts`); nothing here depends on one.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import "./frame.scss";
|
|
15
|
+
import type { StoryLanguage, StorySource } from "@forgebook/story-format/source";
|
|
16
|
+
import { type CatalogueLists } from "../catalogue.ts";
|
|
17
|
+
import { type ViewSwitch } from "../switches.ts";
|
|
18
|
+
import type { PlayToolsLoader } from "./playStory.ts";
|
|
19
|
+
import type { StoryRenderer } from "./renderer.ts";
|
|
20
|
+
/** What an app passes to the frame. */
|
|
21
|
+
export type FrameConfig = {
|
|
22
|
+
/** The framework that draws the stories (`@forgebook/react` passes its own). */
|
|
23
|
+
readonly renderer: StoryRenderer;
|
|
24
|
+
/** The sources the shell shows, in the same order. */
|
|
25
|
+
readonly sources: readonly StorySource[];
|
|
26
|
+
/** The languages every story can be drawn in, as the shell's configuration gives them; none turns them off. */
|
|
27
|
+
readonly languages?: readonly StoryLanguage[];
|
|
28
|
+
/**
|
|
29
|
+
* The catalogue's previews, as their modules: its presets' first, its own last (`forgebook.preview.ts`). Their
|
|
30
|
+
* decorators wrap every story, their parameters sit under every meta's, their setups run before any story renders.
|
|
31
|
+
*/
|
|
32
|
+
readonly previews?: readonly unknown[];
|
|
33
|
+
/** The switches of the toolbar and the View menu, as the shell's configuration gives them; the theme and contrast by default. */
|
|
34
|
+
readonly switches?: readonly ViewSwitch[];
|
|
35
|
+
/** The catalogue's lists (its backgrounds, text sizes, grid step, accessibility rules…); the defaults when none. */
|
|
36
|
+
readonly lists?: CatalogueLists;
|
|
37
|
+
/** Loads the play tools, when the project installs Testing Library (the generated frame passes it then). */
|
|
38
|
+
readonly playTools?: PlayToolsLoader;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Shows the story the address names in the given element.
|
|
42
|
+
*
|
|
43
|
+
* @param container - the element the story renders into.
|
|
44
|
+
* @param config - the sources.
|
|
45
|
+
*/
|
|
46
|
+
export declare const mountFrame: (container: HTMLElement, config: FrameConfig) => Promise<void>;
|
|
47
|
+
//# sourceMappingURL=mountFrame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mountFrame.d.ts","sourceRoot":"","sources":["../../../src/frame/mountFrame.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAIjF,OAAO,EAAqB,KAAK,cAAc,EAAqB,MAAM,iBAAiB,CAAC;AAiB5F,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAOpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,eAAe,CAAC;AAKjE,uCAAuC;AACvC,MAAM,MAAM,WAAW,GAAG;IACxB,gFAAgF;IAChF,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,sDAAsD;IACtD,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IACzC,+GAA+G;IAC/G,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IAC9C;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IACvC,iIAAiI;IACjI,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IAC1C,oHAAoH;IACpH,QAAQ,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;IAChC,4GAA4G;IAC5G,QAAQ,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC;CACtC,CAAC;AA0CF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAU,WAAW,WAAW,EAAE,QAAQ,WAAW,KAAG,OAAO,CAAC,IAAI,CAqJ1F,CAAC"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The entry of a story's frame: reads the story and the view from the address, loads the source's style sheets for
|
|
3
|
+
* the view, then has the framework draw the story and, once its play function is over, tells the shell it is ready.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* One document per story: the style sheets of the Styles setting, the switches on the root and anything the
|
|
7
|
+
* story mounts on `body` stay in this document. The tests open the same address and wait for `data-forgebook-status`
|
|
8
|
+
* on the root (`ready` or `error`), never for a delay. A Live story's clock runs from its start, or stays held there when
|
|
9
|
+
* the address says so (`clock=held`, what the tests open). The framework is the renderer the framework package
|
|
10
|
+
* passes (`renderer.ts`); nothing here depends on one.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import "./frame.css";
|
|
15
|
+
import { storyTextOf } from "@forgebook/story-format/texts";
|
|
16
|
+
import { actionNames, excludedControls, panelArgTypesOf } from "../argTypes.js";
|
|
17
|
+
import { catalogueSettings } from "../catalogue.js";
|
|
18
|
+
import { shownLanguage } from "../languages.js";
|
|
19
|
+
import { detailOf, isShellMessage, previewValue } from "../messages.js";
|
|
20
|
+
import { panelArgsOf, storyArgsOf } from "../namedValues.js";
|
|
21
|
+
import { sourceFiles } from "../sourceFiles.js";
|
|
22
|
+
import { isClockHeldIn } from "../storyClock.js";
|
|
23
|
+
import { fixedViewOf, NOT_FIXED, withFixed } from "../storyGlobals.js";
|
|
24
|
+
import { shownTexts, storyTextKeysOf, withStoryTexts } from "../storyTexts.js";
|
|
25
|
+
import { findStory, storyTree } from "../storyTree.js";
|
|
26
|
+
import { catalogueSwitches } from "../switches.js";
|
|
27
|
+
import { codeGlobalsOf, frameAddress, languageOf, parseView } from "../viewState.js";
|
|
28
|
+
import { checkStory } from "./checkStory.js";
|
|
29
|
+
import { storyFrameClock } from "./frameClock.js";
|
|
30
|
+
import { STATUS_ATTRIBUTE } from "./frameStatus.js";
|
|
31
|
+
import { applyView, loadSheets, viewSheets } from "./frameView.js";
|
|
32
|
+
import { applyTools } from "./measureTools.js";
|
|
33
|
+
import { clearRetry, isStaleModuleError, markRetry, sessionStorageOf } from "./staleModule.js";
|
|
34
|
+
import { mergedPreviews, readPreview, readStory } from "./storyModule.js";
|
|
35
|
+
import { runStory } from "./storyRun.js";
|
|
36
|
+
/** Tells the shell, which is the parent page on the same origin. */
|
|
37
|
+
const tellShell = (message) => {
|
|
38
|
+
if (window.parent !== window)
|
|
39
|
+
window.parent.postMessage(message, window.location.origin);
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Does what a message of the shell asks of the rendered story; the view's live part is applied apart, before the story
|
|
43
|
+
* loads.
|
|
44
|
+
*
|
|
45
|
+
* @param message - the message.
|
|
46
|
+
* @param controls - the rendered story's controls.
|
|
47
|
+
* @param storyId - the story's id, for the answers.
|
|
48
|
+
* @param rules - the catalogue's accessibility rules, for a check.
|
|
49
|
+
*/
|
|
50
|
+
const answerShell = (message, controls, storyId, rules) => {
|
|
51
|
+
if (message.type === "forgebook:replay")
|
|
52
|
+
void controls.replay();
|
|
53
|
+
else if (message.type === "forgebook:args")
|
|
54
|
+
controls.setPanelArgs(message.args);
|
|
55
|
+
else if (message.type === "forgebook:events")
|
|
56
|
+
controls.setEvents(message.names);
|
|
57
|
+
else if (message.type === "forgebook:matrix")
|
|
58
|
+
controls.setMatrix(message.matrix ?? undefined);
|
|
59
|
+
else if (message.type === "forgebook:play-again")
|
|
60
|
+
controls.playAgain();
|
|
61
|
+
else if (message.type === "forgebook:clock")
|
|
62
|
+
controls.setClock(message.state);
|
|
63
|
+
else if (message.type === "forgebook:clock-restart")
|
|
64
|
+
controls.restartClock();
|
|
65
|
+
else if (message.type === "forgebook:check") {
|
|
66
|
+
checkStory(document, rules)
|
|
67
|
+
.then((violations) => tellShell({ type: "forgebook:checked", storyId, violations }))
|
|
68
|
+
.catch((error) => tellShell({
|
|
69
|
+
type: "forgebook:check-error",
|
|
70
|
+
storyId,
|
|
71
|
+
message: error instanceof Error ? error.message : String(error)
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Shows the story the address names in the given element.
|
|
77
|
+
*
|
|
78
|
+
* @param container - the element the story renders into.
|
|
79
|
+
* @param config - the sources.
|
|
80
|
+
*/
|
|
81
|
+
export const mountFrame = async (container, config) => {
|
|
82
|
+
const params = new URLSearchParams(window.location.search);
|
|
83
|
+
const storyId = params.get("story") ?? "";
|
|
84
|
+
const languages = config.languages ?? [];
|
|
85
|
+
const switches = catalogueSwitches(config.switches, languages);
|
|
86
|
+
const catalogue = catalogueSettings("", switches, config.lists);
|
|
87
|
+
const preview = mergedPreviews((config.previews ?? []).map(readPreview));
|
|
88
|
+
const view = parseView(window.location.search, catalogue);
|
|
89
|
+
applyView(document.documentElement, view, catalogue);
|
|
90
|
+
// what the story fixes of the view, once it is read: every view the frame applies has it over the shell's
|
|
91
|
+
let fixed = NOT_FIXED;
|
|
92
|
+
// set once the story runs: a view the shell sends then changes its language and its globals without a new mount
|
|
93
|
+
let changeShown;
|
|
94
|
+
// the shell sends the live part of a changed view: applied on the root, and kept in the address so a reload (an
|
|
95
|
+
// edit, a stale module) shows the same view
|
|
96
|
+
window.addEventListener("message", (event) => {
|
|
97
|
+
if (event.origin !== window.location.origin || !isShellMessage(event.data))
|
|
98
|
+
return;
|
|
99
|
+
if (event.data.type === "forgebook:tools")
|
|
100
|
+
applyTools(document, event.data.tools, catalogue.gridStep);
|
|
101
|
+
if (event.data.type !== "forgebook:view")
|
|
102
|
+
return;
|
|
103
|
+
applyView(document.documentElement, withFixed(event.data.view, fixed), catalogue);
|
|
104
|
+
changeShown?.(event.data.view);
|
|
105
|
+
const address = frameAddress(window.location.pathname, storyId, { ...view, ...event.data.view }, switches);
|
|
106
|
+
window.history.replaceState(null, "", address);
|
|
107
|
+
});
|
|
108
|
+
// observed from the start, so the shell sizes the frame to an error as well as to a story
|
|
109
|
+
const reportSize = () => {
|
|
110
|
+
// the body's own height: the root's scroll height never drops below the frame's, so a story could not shrink
|
|
111
|
+
const height = Math.ceil(document.body.getBoundingClientRect().height);
|
|
112
|
+
tellShell({ type: "forgebook:size", storyId, height });
|
|
113
|
+
};
|
|
114
|
+
new ResizeObserver(reportSize).observe(document.body);
|
|
115
|
+
const reportError = (message) => {
|
|
116
|
+
document.documentElement.setAttribute(STATUS_ATTRIBUTE, "error");
|
|
117
|
+
tellShell({ type: "forgebook:error", storyId, message });
|
|
118
|
+
};
|
|
119
|
+
const fail = (message) => {
|
|
120
|
+
const box = document.createElement("div");
|
|
121
|
+
box.className = "forgebook-frame-error";
|
|
122
|
+
box.setAttribute("role", "alert");
|
|
123
|
+
const text = document.createElement("p");
|
|
124
|
+
text.className = "forgebook-frame-error__message";
|
|
125
|
+
text.textContent = message;
|
|
126
|
+
box.append(text);
|
|
127
|
+
container.replaceChildren(box);
|
|
128
|
+
reportError(message);
|
|
129
|
+
};
|
|
130
|
+
const location = findStory(storyTree(config.sources), storyId);
|
|
131
|
+
const source = config.sources.find((candidate) => candidate.id === location?.source.id);
|
|
132
|
+
const load = location === undefined || source === undefined
|
|
133
|
+
? undefined
|
|
134
|
+
: sourceFiles(source).stories[location.component.file];
|
|
135
|
+
if (location === undefined || source === undefined || load === undefined) {
|
|
136
|
+
fail(`No story "${storyId}"`);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
await source.setup?.();
|
|
141
|
+
await preview.setup?.();
|
|
142
|
+
await loadSheets(document, viewSheets(source.sheets, view));
|
|
143
|
+
const story = readStory(await load(), location.story.exportName, preview);
|
|
144
|
+
if (typeof story === "string") {
|
|
145
|
+
fail(story);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
fixed = fixedViewOf(story.globals, story.parameters, catalogue);
|
|
149
|
+
applyView(document.documentElement, withFixed(view, fixed), catalogue);
|
|
150
|
+
let controls;
|
|
151
|
+
const clock = storyFrameClock(story.clockStart, isClockHeldIn(window.location.search));
|
|
152
|
+
window.addEventListener("message", (event) => {
|
|
153
|
+
if (event.origin !== window.location.origin || !isShellMessage(event.data))
|
|
154
|
+
return;
|
|
155
|
+
if (controls !== undefined)
|
|
156
|
+
answerShell(event.data, controls, storyId, catalogue.a11y);
|
|
157
|
+
});
|
|
158
|
+
// the language's texts, and the switches the story reads (the language's provider reads its id among them)
|
|
159
|
+
const shownFor = (live) => {
|
|
160
|
+
const switchesShown = { switches: { ...live.switches, ...fixed.switches } };
|
|
161
|
+
return {
|
|
162
|
+
texts: shownTexts(source.texts, shownLanguage(languages, languageOf(switchesShown, switches))),
|
|
163
|
+
globals: codeGlobalsOf(switchesShown, switches)
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
const shown = shownFor(view);
|
|
167
|
+
const { texts } = shown;
|
|
168
|
+
const running = runStory({
|
|
169
|
+
container,
|
|
170
|
+
story,
|
|
171
|
+
identity: { id: storyId, name: location.story.name, title: location.component.title },
|
|
172
|
+
...(config.playTools === undefined ? {} : { playTools: config.playTools }),
|
|
173
|
+
renderer: config.renderer,
|
|
174
|
+
clock,
|
|
175
|
+
decorators: preview.decorators,
|
|
176
|
+
...shown,
|
|
177
|
+
resolveArgs: (args) => storyArgsOf(args, source.namedValues),
|
|
178
|
+
onControlsReady: (next) => {
|
|
179
|
+
controls = next;
|
|
180
|
+
clearRetry(sessionStorageOf(window), window.location.href);
|
|
181
|
+
// the height first: the shell sizes the frame to the drawn story before anything reads it as ready, instead of
|
|
182
|
+
// waiting on the resize observer, which may report after the ready status
|
|
183
|
+
reportSize();
|
|
184
|
+
document.documentElement.setAttribute(STATUS_ATTRIBUTE, "ready");
|
|
185
|
+
// the panel shows a text an arg names as the story shows it, with its key beside it
|
|
186
|
+
const args = panelArgsOf(withStoryTexts(story.args, storyTextOf(texts)), source.namedValues);
|
|
187
|
+
const textKeys = storyTextKeysOf(story.args);
|
|
188
|
+
tellShell({
|
|
189
|
+
type: "forgebook:ready",
|
|
190
|
+
storyId,
|
|
191
|
+
canReplay: story.replay !== undefined,
|
|
192
|
+
hasClock: story.clockStart !== undefined,
|
|
193
|
+
args,
|
|
194
|
+
textKeys,
|
|
195
|
+
argTypes: panelArgTypesOf(story.argTypes, excludedControls(story.parameters["controls"])),
|
|
196
|
+
controls: story.controls,
|
|
197
|
+
actions: actionNames(story.args, story.argTypes),
|
|
198
|
+
fixed
|
|
199
|
+
});
|
|
200
|
+
changeShown = (live) => running.setShown(shownFor(live));
|
|
201
|
+
},
|
|
202
|
+
onError: reportError,
|
|
203
|
+
onTrace: (trace) => tellShell({ type: "forgebook:play", storyId, trace }),
|
|
204
|
+
onEvent: (name, values) => tellShell({
|
|
205
|
+
type: "forgebook:call",
|
|
206
|
+
storyId,
|
|
207
|
+
name,
|
|
208
|
+
values: values.map(previewValue),
|
|
209
|
+
details: values.map(detailOf)
|
|
210
|
+
})
|
|
211
|
+
});
|
|
212
|
+
// the shell opens another story by loading another page: the set-ups' cleanups run as this one goes (a page kept
|
|
213
|
+
// for the back button keeps its story)
|
|
214
|
+
window.addEventListener("pagehide", (event) => {
|
|
215
|
+
if (!event.persisted)
|
|
216
|
+
running.leave();
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
221
|
+
// a stale module (dependencies prepared again, a new build): one reload fetches the new one
|
|
222
|
+
if (isStaleModuleError(message) && markRetry(sessionStorageOf(window), window.location.href)) {
|
|
223
|
+
window.location.reload();
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
fail(message);
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
//# sourceMappingURL=mountFrame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mountFrame.js","sourceRoot":"","sources":["../../../src/frame/mountFrame.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,cAAc,CAAC;AAGtB,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAA0C,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,QAAQ,EAER,cAAc,EAEd,YAAY,EAEb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAkB,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAmB,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAiB,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACpG,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,E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|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs a story's play function, records its trace, and says when it is over, so the frame tells the tests it is
|
|
3
|
+
* ready only then.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* A play may change the story over time (press buttons, wait for a state); a check that ran before it finished would
|
|
7
|
+
* read a half-played story. The frame's ready status therefore waits for this. A play that fails is still over: the
|
|
8
|
+
* frame becomes ready and the failure surfaces as an unhandled rejection, which the tests record as a page error.
|
|
9
|
+
* The trace (the play's status, its time, each `step` it named) goes to the shell's Interactions tab after every
|
|
10
|
+
* change; a story without a play has no trace.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import type { StoryContext } from "@forgebook/story-format/csf";
|
|
15
|
+
import type { PlayTrace } from "../playTrace.ts";
|
|
16
|
+
import type { LoadedArgs, LoadedStory } from "./storyModule.ts";
|
|
17
|
+
/** The play tools a project's Testing Library gives, as the frame uses them without depending on it. */
|
|
18
|
+
export type PlayTools = {
|
|
19
|
+
/** Testing Library's `within`: its queries bound to an element. */
|
|
20
|
+
readonly within: (element: HTMLElement) => unknown;
|
|
21
|
+
/** Testing Library's `userEvent`. */
|
|
22
|
+
readonly userEvent: unknown;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Loads the play tools, on the first play that runs: a catalogue whose stories have no play never loads them. The
|
|
26
|
+
* generated frame passes one when the project installs Testing Library.
|
|
27
|
+
*/
|
|
28
|
+
export type PlayToolsLoader = () => Promise<PlayTools>;
|
|
29
|
+
/**
|
|
30
|
+
* Plays a story, then calls `onPlayed`.
|
|
31
|
+
*
|
|
32
|
+
* @param play - the story's play function, if it has one.
|
|
33
|
+
* @param context - the args and the canvas the play reads; the play's `step` is added here.
|
|
34
|
+
* @param onPlayed - called once the play is over, at once when there is none, whether it passed or failed.
|
|
35
|
+
* @param onTrace - called with the trace after every change; never without a play.
|
|
36
|
+
* @param tools - the play tools to hand the play (`canvas` bound to its canvas, `userEvent`); none without them.
|
|
37
|
+
* @returns the play's promise, rejected when the play failed.
|
|
38
|
+
*/
|
|
39
|
+
export declare const playStory: (play: LoadedStory["play"], context: Omit<StoryContext<LoadedArgs>, "step">, onPlayed: () => void, onTrace?: (trace: PlayTrace) => void, tools?: PlayTools | undefined) => Promise<void>;
|
|
40
|
+
//# sourceMappingURL=playStory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playStory.d.ts","sourceRoot":"","sources":["../../../src/frame/playStory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE9E,OAAO,KAAK,EAAY,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQhE,wGAAwG;AACxG,MAAM,MAAM,SAAS,GAAG;IACtB,mEAAmE;IACnE,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC;IACnD,qCAAqC;IACrC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;AAEvD;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,GACpB,MAAM,WAAW,CAAC,MAAM,CAAC,EACzB,SAAS,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,EAC/C,UAAU,MAAM,IAAI,EACpB,UAAS,CAAC,KAAK,EAAE,SAAS,KAAK,IAA4B,EAC3D,QAAO,SAAS,GAAG,SAAqB,KACvC,OAAO,CAAC,IAAI,CAqCd,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** A thrown value's message. */
|
|
2
|
+
const messageOf = (error) => (error instanceof Error ? error.message : String(error));
|
|
3
|
+
/** Milliseconds since an instant, rounded. */
|
|
4
|
+
const since = (start) => Math.round(performance.now() - start);
|
|
5
|
+
/**
|
|
6
|
+
* Plays a story, then calls `onPlayed`.
|
|
7
|
+
*
|
|
8
|
+
* @param play - the story's play function, if it has one.
|
|
9
|
+
* @param context - the args and the canvas the play reads; the play's `step` is added here.
|
|
10
|
+
* @param onPlayed - called once the play is over, at once when there is none, whether it passed or failed.
|
|
11
|
+
* @param onTrace - called with the trace after every change; never without a play.
|
|
12
|
+
* @param tools - the play tools to hand the play (`canvas` bound to its canvas, `userEvent`); none without them.
|
|
13
|
+
* @returns the play's promise, rejected when the play failed.
|
|
14
|
+
*/
|
|
15
|
+
export const playStory = async (play, context, onPlayed, onTrace = () => undefined, tools = undefined) => {
|
|
16
|
+
if (play === undefined) {
|
|
17
|
+
onPlayed();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
let steps = [];
|
|
21
|
+
const report = (trace) => onTrace({ ...trace, steps });
|
|
22
|
+
const setStep = (index, step) => {
|
|
23
|
+
steps = steps.map((current, at) => (at === index ? step : current));
|
|
24
|
+
report({ status: "running" });
|
|
25
|
+
};
|
|
26
|
+
const step = async (label, run) => {
|
|
27
|
+
const index = steps.length;
|
|
28
|
+
const start = performance.now();
|
|
29
|
+
steps = [...steps, { label, status: "running" }];
|
|
30
|
+
report({ status: "running" });
|
|
31
|
+
try {
|
|
32
|
+
await run();
|
|
33
|
+
setStep(index, { label, status: "passed", ms: since(start) });
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
setStep(index, { label, status: "failed", ms: since(start), error: messageOf(error) });
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const start = performance.now();
|
|
41
|
+
report({ status: "running" });
|
|
42
|
+
try {
|
|
43
|
+
const toolsContext = tools === undefined ? {} : { canvas: tools.within(context.canvasElement), userEvent: tools.userEvent };
|
|
44
|
+
await play({ ...context, step, ...toolsContext });
|
|
45
|
+
report({ status: "passed", ms: since(start) });
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
report({ status: "failed", ms: since(start), error: messageOf(error) });
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
onPlayed();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=playStory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playStory.js","sourceRoot":"","sources":["../../../src/frame/playStory.ts"],"names":[],"mappings":"AAkBA,gCAAgC;AAChC,MAAM,SAAS,GAAG,CAAC,KAAc,EAAU,EAAE,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAEvG,8CAA8C;AAC9C,MAAM,KAAK,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC;AAgB/E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAC5B,IAAyB,EACzB,OAA+C,EAC/C,QAAoB,EACpB,UAAsC,GAAS,EAAE,CAAC,SAAS,EAC3D,QAA+B,SAAS,EACzB,EAAE;IACjB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,QAAQ,EAAE,CAAC;QACX,OAAO;IACT,CAAC;IACD,IAAI,KAAK,GAAwB,EAAE,CAAC;IACpC,MAAM,MAAM,GAAG,CAAC,KAA+B,EAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACvF,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,IAAc,EAAQ,EAAE;QACtD,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,EAAE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AE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;QACzG,MAAM,IAAI,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC;QAClD,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACxE,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,QAAQ,EAAE,CAAC;IACb,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contract between Forgebook and a framework: how the frame draws one story in one canvas, draws it again with
|
|
3
|
+
* other args and takes it away, and how the shell writes a story drawn from its args as code.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* The frame owns everything a framework does not need to know: the address and the view, the messages with the
|
|
7
|
+
* shell, the style sheets, the play function, Replay, the matrix's layout, the story clock and the error shown in
|
|
8
|
+
* place of a story. A framework package (`@forgebook/react`) implements this type and hands it to the frame; another
|
|
9
|
+
* framework implements the same type. A story's decorators, providers and error capture are the framework's, since
|
|
10
|
+
* they return or catch the framework's own output.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import type { StoryClock } from "@forgebook/story-format/clock";
|
|
15
|
+
import type { StepFunction, StoryContext } from "@forgebook/story-format/csf";
|
|
16
|
+
import type { StoryTextTable } from "@forgebook/story-format/texts";
|
|
17
|
+
import type { PanelArgs } from "../messages.ts";
|
|
18
|
+
import type { LoadedArgs, LoadedDecorator, LoadedStory } from "./storyModule.ts";
|
|
19
|
+
/** Which story is drawn: its id, its name and its file's title, as its context gives them. */
|
|
20
|
+
export type StoryIdentity = Pick<StoryContext<LoadedArgs>, "id" | "name" | "title">;
|
|
21
|
+
/** One story to draw, as the frame hands it to the framework. */
|
|
22
|
+
export type StoryDrawing = {
|
|
23
|
+
/** Which story it is. */
|
|
24
|
+
readonly identity: StoryIdentity;
|
|
25
|
+
/** The story: its render or component, its decorators, its layout. */
|
|
26
|
+
readonly story: LoadedStory;
|
|
27
|
+
/** The args as the story receives them: the texts named by key resolved, the recorded events wrapped. */
|
|
28
|
+
readonly args: LoadedArgs;
|
|
29
|
+
/** The texts inside the stories in the shown language, for the story's `text` and its text hooks. */
|
|
30
|
+
readonly texts: StoryTextTable;
|
|
31
|
+
/** The story clock the story reads (held at its start, or running for a Live story). */
|
|
32
|
+
readonly clock: StoryClock;
|
|
33
|
+
/**
|
|
34
|
+
* The catalogue's decorators (its preview's), outside the meta's and the story's own: the providers every story
|
|
35
|
+
* is drawn in, the language's among them (it reads `context.globals.lang`).
|
|
36
|
+
*/
|
|
37
|
+
readonly decorators: readonly LoadedDecorator[];
|
|
38
|
+
/** The values of the switches applied by code, by id: the story's `context.globals`. */
|
|
39
|
+
readonly globals: Readonly<Record<string, string>>;
|
|
40
|
+
/** What the story's loaders returned: its `context.loaded`. */
|
|
41
|
+
readonly loaded: Readonly<Record<string, unknown>>;
|
|
42
|
+
};
|
|
43
|
+
/** What the frame keeps of a story drawn in a canvas. */
|
|
44
|
+
export type MountedStory = {
|
|
45
|
+
/**
|
|
46
|
+
* Resolves once the story is drawn in its canvas, so the play function finds what it drives; never resolves when the
|
|
47
|
+
* story throws while it is first drawn (the error goes to `onError` instead).
|
|
48
|
+
*/
|
|
49
|
+
readonly drawn: Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Draws the story again, keeping its state: other args, other switch values, another language; a story that threw
|
|
52
|
+
* is tried again.
|
|
53
|
+
*/
|
|
54
|
+
readonly update: (drawing: StoryDrawing) => void;
|
|
55
|
+
/** Takes the story away from its canvas. */
|
|
56
|
+
readonly unmount: () => void;
|
|
57
|
+
};
|
|
58
|
+
/** A framework, as the frame uses it. */
|
|
59
|
+
export type StoryRenderer = {
|
|
60
|
+
/**
|
|
61
|
+
* Draws a story in a canvas the frame owns.
|
|
62
|
+
*
|
|
63
|
+
* @param canvas - the element the story is drawn in.
|
|
64
|
+
* @param drawing - the story, its args, texts, clock and language.
|
|
65
|
+
* @param onError - called with the error when the story throws while it is drawn; the frame shows it instead.
|
|
66
|
+
*/
|
|
67
|
+
readonly mount: (canvas: HTMLElement, drawing: StoryDrawing, onError: (error: Error) => void) => MountedStory;
|
|
68
|
+
/**
|
|
69
|
+
* The story drawn as HTML on the server, for the generated server tests; throws when the story throws.
|
|
70
|
+
*
|
|
71
|
+
* @param drawing - the story, its args, texts, clock and language.
|
|
72
|
+
*/
|
|
73
|
+
readonly renderToString: (drawing: StoryDrawing) => string;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Writes a story drawn from its args as the framework's code, for the Code tab and Show code (`<Button tone="danger" />`
|
|
77
|
+
* in React): the shell knows the component's name and the panel's values, and the framework knows its syntax.
|
|
78
|
+
*
|
|
79
|
+
* @param component - the component's name, as its documentation names it.
|
|
80
|
+
* @param args - the values of the moment, a named value by its name.
|
|
81
|
+
*/
|
|
82
|
+
export type StoryCodeWriter = (component: string, args: PanelArgs) => string;
|
|
83
|
+
/** The `step` a render and a decorator receive: outside a play there is no trace, so a step only runs its part. */
|
|
84
|
+
export declare const untracedStep: StepFunction;
|
|
85
|
+
//# sourceMappingURL=renderer.d.ts.map
|