forgebook 0.0.0-stage → 0.1.0
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 +115 -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 +47 -0
- package/dist/src/shell/StageViewport.d.ts.map +1 -0
- package/dist/src/shell/StageViewport.js +174 -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,303 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The toolbar's switches as a value, read from and written to the URL, so a view is shared with a link and the
|
|
3
|
+
* frames and the tests open the same address.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Only values that differ from the defaults are written; an unknown or invalid value reads as the default. The view
|
|
7
|
+
* holds a value for each switch the catalogue declares (`switches.ts`: the theme, the contrast, the language, the
|
|
8
|
+
* library's own), which the frame applies on its root or hands the story; and Forgebook's own settings: the style
|
|
9
|
+
* sheets, the root font size and the backdrop Forgebook draws behind the story. The stage's width, height, zoom and tools and the panel (open, its tab) are the shell's alone: a frame's address leaves them
|
|
10
|
+
* out. Pure.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import { switchValueOf, switchWithRole } from "./switches.js";
|
|
15
|
+
/** The page's own colour: no backdrop drawn. */
|
|
16
|
+
export const PLAIN_BACKDROP = "plain";
|
|
17
|
+
/** Forgebook's own settings the compare view can set side by side. */
|
|
18
|
+
export const OWN_COMPARE_AXES = ["text", "sheets"];
|
|
19
|
+
/** The view without any change. */
|
|
20
|
+
export const DEFAULT_VIEW = {
|
|
21
|
+
switches: {},
|
|
22
|
+
backdrop: "plain",
|
|
23
|
+
sheets: "full",
|
|
24
|
+
text: 100,
|
|
25
|
+
compare: [],
|
|
26
|
+
width: "fill",
|
|
27
|
+
height: "auto",
|
|
28
|
+
isPanelOpen: true,
|
|
29
|
+
panelTab: "props",
|
|
30
|
+
zoom: 100,
|
|
31
|
+
tools: []
|
|
32
|
+
};
|
|
33
|
+
/** Every style sheet setting, in the menu's order. */
|
|
34
|
+
export const SHEETS_CHOICES = ["full", "structure", "restyled"];
|
|
35
|
+
/**
|
|
36
|
+
* Whether the stage compares the story across a switch's values.
|
|
37
|
+
*
|
|
38
|
+
* @param view - the view.
|
|
39
|
+
*/
|
|
40
|
+
export const isComparing = (view) => view.compare.length > 0;
|
|
41
|
+
/** Every tool, in the bar's order. */
|
|
42
|
+
export const MEASURE_TOOLS = ["outline", "grid", "measure"];
|
|
43
|
+
/** The tools a parameter names (`outline,measure`), in their order; unknown names are left out. */
|
|
44
|
+
const toolsOf = (value) => {
|
|
45
|
+
const names = (value ?? "").split(",");
|
|
46
|
+
return MEASURE_TOOLS.filter((tool) => names.includes(tool));
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* A width kept in a catalogue's range, in whole pixels.
|
|
50
|
+
*
|
|
51
|
+
* @param width - a width in CSS px.
|
|
52
|
+
* @param range - the narrowest and widest a story may be set.
|
|
53
|
+
*/
|
|
54
|
+
export const clampedWidth = (width, range) => Math.round(Math.min(range.max, Math.max(range.min, width)));
|
|
55
|
+
/** The width a parameter names: a whole number of px in the range, otherwise the stage's whole width. */
|
|
56
|
+
const stageWidth = (value, range) => {
|
|
57
|
+
const width = Number(value);
|
|
58
|
+
return value !== null && Number.isInteger(width) && clampedWidth(width, range) === width ? width : "fill";
|
|
59
|
+
};
|
|
60
|
+
/** The lowest and highest story a height in the address or a drag may set, in CSS px. */
|
|
61
|
+
export const STAGE_HEIGHT_RANGE = { min: 48, max: 4000 };
|
|
62
|
+
/**
|
|
63
|
+
* A height kept in the range, in whole pixels.
|
|
64
|
+
*
|
|
65
|
+
* @param height - a height in CSS px.
|
|
66
|
+
*/
|
|
67
|
+
export const clampedHeight = (height) => Math.round(Math.min(STAGE_HEIGHT_RANGE.max, Math.max(STAGE_HEIGHT_RANGE.min, height)));
|
|
68
|
+
/** The height a parameter names: a whole number of px in the range, otherwise the story's own. */
|
|
69
|
+
const stageHeight = (value) => {
|
|
70
|
+
const height = Number(value);
|
|
71
|
+
return value !== null && Number.isInteger(height) && clampedHeight(height) === height ? height : "auto";
|
|
72
|
+
};
|
|
73
|
+
/** The value of a parameter when it is one of the choices, otherwise the default. */
|
|
74
|
+
const choice = (value, choices, fallback) => choices.find((option) => String(option) === value) ?? fallback;
|
|
75
|
+
/**
|
|
76
|
+
* Each declared switch's value an address names, the default for one it leaves out or names wrongly.
|
|
77
|
+
*
|
|
78
|
+
* @param params - the address's parameters.
|
|
79
|
+
* @param switches - the declared switches.
|
|
80
|
+
*/
|
|
81
|
+
const switchValuesOf = (params, switches) => Object.fromEntries(switches.map((each) => [
|
|
82
|
+
each.id,
|
|
83
|
+
switchValueOf(each, params.get(each.id) ?? undefined)?.value ?? each.default
|
|
84
|
+
]));
|
|
85
|
+
/**
|
|
86
|
+
* The compared axes a `compare` parameter names: one or two switch ids, `text` or `sheets`. `theme` (and `1`, the form
|
|
87
|
+
* older addresses wrote) is the colour scheme at both contrasts, `language` the language switch, as the toolbar
|
|
88
|
+
* named them before switches were declared.
|
|
89
|
+
*
|
|
90
|
+
* @param value - the parameter.
|
|
91
|
+
* @param switches - the declared switches.
|
|
92
|
+
*/
|
|
93
|
+
const compareAxesOf = (value, switches) => {
|
|
94
|
+
if (value === null || value === "")
|
|
95
|
+
return [];
|
|
96
|
+
const scheme = switchWithRole(switches, "colorScheme");
|
|
97
|
+
const contrast = switchWithRole(switches, "contrast");
|
|
98
|
+
const legacy = {
|
|
99
|
+
"1": [scheme?.id, contrast?.id],
|
|
100
|
+
theme: [scheme?.id, contrast?.id],
|
|
101
|
+
language: [switchWithRole(switches, "language")?.id]
|
|
102
|
+
};
|
|
103
|
+
const named = legacy[value] ?? value.split(",");
|
|
104
|
+
const known = [...switches.map((each) => each.id), ...OWN_COMPARE_AXES];
|
|
105
|
+
return named.filter((axis) => axis !== undefined && known.includes(axis)).slice(0, 2);
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* The view a URL's query describes.
|
|
109
|
+
*
|
|
110
|
+
* @param search - the query (`?theme=dark&motion=reduced`), with or without `?`.
|
|
111
|
+
* @param catalogue - the catalogue's switches and lists.
|
|
112
|
+
*/
|
|
113
|
+
export const parseView = (search, catalogue) => {
|
|
114
|
+
const params = new URLSearchParams(search);
|
|
115
|
+
return {
|
|
116
|
+
switches: switchValuesOf(params, catalogue.switches),
|
|
117
|
+
backdrop: choice(params.get("backdrop"), catalogue.backdrops.map((backdrop) => backdrop.id), DEFAULT_VIEW.backdrop),
|
|
118
|
+
sheets: choice(params.get("sheets"), SHEETS_CHOICES, DEFAULT_VIEW.sheets),
|
|
119
|
+
text: choice(params.get("text"), catalogue.textSizes, DEFAULT_VIEW.text),
|
|
120
|
+
compare: compareAxesOf(params.get("compare"), catalogue.switches),
|
|
121
|
+
width: stageWidth(params.get("width"), catalogue.widthRange),
|
|
122
|
+
height: stageHeight(params.get("height")),
|
|
123
|
+
isPanelOpen: params.get("panel") !== "closed",
|
|
124
|
+
panelTab: choice(params.get("tab"), catalogue.tabs, catalogue.tabs[0] ?? DEFAULT_VIEW.panelTab),
|
|
125
|
+
zoom: choice(params.get("zoom"), catalogue.zooms, DEFAULT_VIEW.zoom),
|
|
126
|
+
tools: toolsOf(params.get("tools"))
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* The view without any change, for a catalogue.
|
|
131
|
+
*
|
|
132
|
+
* @param catalogue - the catalogue's switches and lists.
|
|
133
|
+
*/
|
|
134
|
+
export const defaultView = (catalogue) => parseView("", catalogue);
|
|
135
|
+
/**
|
|
136
|
+
* Whether a switch's value in a view is its default (a switch the view does not hold counts as its default).
|
|
137
|
+
*
|
|
138
|
+
* @param view - the view.
|
|
139
|
+
* @param each - the switch.
|
|
140
|
+
*/
|
|
141
|
+
const isDefault = (view, each) => (view.switches[each.id] ?? each.default) === each.default;
|
|
142
|
+
/**
|
|
143
|
+
* The parameters a frame's document reads, only what differs from the defaults: the switches in their declared
|
|
144
|
+
* order, then Forgebook's own settings, then the language.
|
|
145
|
+
*/
|
|
146
|
+
const frameParams = (view, switches) => {
|
|
147
|
+
const params = new URLSearchParams();
|
|
148
|
+
const language = switchWithRole(switches, "language");
|
|
149
|
+
const setSwitch = (each) => {
|
|
150
|
+
if (!isDefault(view, each))
|
|
151
|
+
params.set(each.id, view.switches[each.id] ?? each.default);
|
|
152
|
+
};
|
|
153
|
+
for (const each of switches)
|
|
154
|
+
if (each !== language)
|
|
155
|
+
setSwitch(each);
|
|
156
|
+
if (view.backdrop !== DEFAULT_VIEW.backdrop)
|
|
157
|
+
params.set("backdrop", view.backdrop);
|
|
158
|
+
if (view.sheets !== DEFAULT_VIEW.sheets)
|
|
159
|
+
params.set("sheets", view.sheets);
|
|
160
|
+
if (view.text !== DEFAULT_VIEW.text)
|
|
161
|
+
params.set("text", String(view.text));
|
|
162
|
+
if (language !== undefined)
|
|
163
|
+
setSwitch(language);
|
|
164
|
+
return params;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* The query parameters of a view: only what differs from the defaults.
|
|
168
|
+
*
|
|
169
|
+
* @param view - the view.
|
|
170
|
+
* @param switches - the catalogue's switches.
|
|
171
|
+
* @returns the parameters, in a stable order.
|
|
172
|
+
*/
|
|
173
|
+
export const viewParams = (view, switches) => {
|
|
174
|
+
const params = frameParams(view, switches);
|
|
175
|
+
if (isComparing(view))
|
|
176
|
+
params.set("compare", view.compare.join(","));
|
|
177
|
+
if (view.width !== DEFAULT_VIEW.width)
|
|
178
|
+
params.set("width", String(view.width));
|
|
179
|
+
if (view.height !== DEFAULT_VIEW.height)
|
|
180
|
+
params.set("height", String(view.height));
|
|
181
|
+
if (!view.isPanelOpen)
|
|
182
|
+
params.set("panel", "closed");
|
|
183
|
+
if (view.panelTab !== DEFAULT_VIEW.panelTab)
|
|
184
|
+
params.set("tab", view.panelTab);
|
|
185
|
+
if (view.zoom !== DEFAULT_VIEW.zoom)
|
|
186
|
+
params.set("zoom", String(view.zoom));
|
|
187
|
+
if (view.tools.length > 0)
|
|
188
|
+
params.set("tools", view.tools.join(","));
|
|
189
|
+
return params;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Whether one of the View menu's settings is changed (a switch the toolbar does not show itself, the background,
|
|
193
|
+
* the style sheets, the text size): the menu button then shows a dot, so a view is never left changed by mistake.
|
|
194
|
+
*
|
|
195
|
+
* @param view - the view.
|
|
196
|
+
* @param switches - the catalogue's switches.
|
|
197
|
+
*/
|
|
198
|
+
export const hasViewChanges = (view, switches) => switches.some((each) => isMenuSwitch(each) && !isDefault(view, each)) ||
|
|
199
|
+
view.backdrop !== DEFAULT_VIEW.backdrop ||
|
|
200
|
+
view.sheets !== DEFAULT_VIEW.sheets ||
|
|
201
|
+
view.text !== DEFAULT_VIEW.text;
|
|
202
|
+
/**
|
|
203
|
+
* Whether a switch sits in the View menu: every one but the colour scheme and the contrast, which the toolbar shows.
|
|
204
|
+
*
|
|
205
|
+
* @param each - the switch.
|
|
206
|
+
*/
|
|
207
|
+
export const isMenuSwitch = (each) => each.role !== "colorScheme" && each.role !== "contrast";
|
|
208
|
+
/**
|
|
209
|
+
* The address of a story's frame.
|
|
210
|
+
*
|
|
211
|
+
* @param frameUrl - the frame page (`frame.html`).
|
|
212
|
+
* @param id - the story's id.
|
|
213
|
+
* @param view - the view; what only the shell reads (compare, the stage's width, the panel) is left out.
|
|
214
|
+
* @param switches - the catalogue's switches.
|
|
215
|
+
*/
|
|
216
|
+
export const frameAddress = (frameUrl, id, view, switches) => {
|
|
217
|
+
const params = frameParams(view, switches);
|
|
218
|
+
params.set("story", id);
|
|
219
|
+
return `${frameUrl}?${params.toString()}`;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* The part of a view a frame applies live.
|
|
223
|
+
*
|
|
224
|
+
* @param view - the view.
|
|
225
|
+
*/
|
|
226
|
+
export const liveView = (view) => ({
|
|
227
|
+
switches: view.switches,
|
|
228
|
+
backdrop: view.backdrop,
|
|
229
|
+
text: view.text
|
|
230
|
+
});
|
|
231
|
+
/**
|
|
232
|
+
* The scheme a view draws in: its colour scheme switch's, light when the catalogue has none.
|
|
233
|
+
*
|
|
234
|
+
* @param view - the view's switches.
|
|
235
|
+
* @param switches - the catalogue's switches.
|
|
236
|
+
*/
|
|
237
|
+
export const schemeOf = (view, switches) => {
|
|
238
|
+
const scheme = switchWithRole(switches, "colorScheme");
|
|
239
|
+
if (scheme === undefined)
|
|
240
|
+
return "light";
|
|
241
|
+
return switchValueOf(scheme, view.switches[scheme.id])?.scheme ?? "light";
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* Whether a view draws in the higher contrast: its contrast switch's value says so; never without one.
|
|
245
|
+
*
|
|
246
|
+
* @param view - the view's switches.
|
|
247
|
+
* @param switches - the catalogue's switches.
|
|
248
|
+
*/
|
|
249
|
+
export const isMoreContrastOf = (view, switches) => {
|
|
250
|
+
const contrast = switchWithRole(switches, "contrast");
|
|
251
|
+
if (contrast === undefined)
|
|
252
|
+
return false;
|
|
253
|
+
return switchValueOf(contrast, view.switches[contrast.id])?.isMore === true;
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* The language a view shows: the language switch's value, empty for the stories' own text.
|
|
257
|
+
*
|
|
258
|
+
* @param view - the view's switches.
|
|
259
|
+
* @param switches - the catalogue's switches.
|
|
260
|
+
*/
|
|
261
|
+
export const languageOf = (view, switches) => {
|
|
262
|
+
const language = switchWithRole(switches, "language");
|
|
263
|
+
return language === undefined ? "" : (view.switches[language.id] ?? language.default);
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* The values of the switches applied by code, by id: what the story reads as `context.globals`.
|
|
267
|
+
*
|
|
268
|
+
* @param view - the view's switches.
|
|
269
|
+
* @param switches - the catalogue's switches.
|
|
270
|
+
*/
|
|
271
|
+
export const codeGlobalsOf = (view, switches) => Object.fromEntries(switches
|
|
272
|
+
.filter((each) => each.apply.kind === "code")
|
|
273
|
+
.map((each) => [each.id, view.switches[each.id] ?? each.default]));
|
|
274
|
+
/** The parameters only the shell reads: a frame's address leaves them out. */
|
|
275
|
+
const SHELL_PARAMETERS = [
|
|
276
|
+
"compare",
|
|
277
|
+
"width",
|
|
278
|
+
"height",
|
|
279
|
+
"panel",
|
|
280
|
+
"tab",
|
|
281
|
+
"zoom",
|
|
282
|
+
"tools",
|
|
283
|
+
"args",
|
|
284
|
+
"matrix",
|
|
285
|
+
"component"
|
|
286
|
+
];
|
|
287
|
+
/**
|
|
288
|
+
* The address of a story's frame from a catalogue's address query, for a tool that does not know the catalogue's
|
|
289
|
+
* switches (`forgebook-shot`): every parameter but the shell's own is kept as written.
|
|
290
|
+
*
|
|
291
|
+
* @param frameUrl - the frame page (`frame.html`).
|
|
292
|
+
* @param id - the story's id.
|
|
293
|
+
* @param search - the catalogue's query (`theme=dark&lang=it`), with or without `?`.
|
|
294
|
+
*/
|
|
295
|
+
export const frameAddressOf = (frameUrl, id, search) => {
|
|
296
|
+
const params = new URLSearchParams(search);
|
|
297
|
+
for (const name of SHELL_PARAMETERS)
|
|
298
|
+
params.delete(name);
|
|
299
|
+
params.delete("story");
|
|
300
|
+
params.set("story", id);
|
|
301
|
+
return `${frameUrl}?${params.toString()}`;
|
|
302
|
+
};
|
|
303
|
+
//# sourceMappingURL=viewState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewState.js","sourceRoot":"","sources":["../../src/viewState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAmB,MAAM,eAAe,CAAC;AAS/E,gDAAgD;AAChD,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AActC,sEAAsE;AACtE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAU,CAAC;AAiD5D,mCAAmC;AACnC,MAAM,CAAC,MAAM,YAAY,GAAc;IACrC,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,OAAO;IACjB,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,GAAG;IACT,OAAO,EAAE,EAAE;IACX,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,MAAM;IACd,WAAW,EAAE,IAAI;IACjB,QAAQ,EAAE,OAAO;IACjB,IAAI,EAAE,GAAG;IACT,KAAK,EAAE,EAAE;CACV,CAAC;AAEF,sDAAsD;AACtD,MAAM,CAAC,MAAM,cAAc,GAA4B,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AAEzF;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAe,EAAW,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;AAEjF,sCAAsC;AACtC,MAAM,CAAC,MAAM,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c,GAAG,CAAC,QAAgB,EAAE,EAAU,EAAE,MAAc,EAAU,EAAE;IACrF,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;IAC3C,KAAK,MAAM,IAAI,IAAI,gBAAgB;QAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACzD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACvB,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACxB,OAAO,GAAG,QAAQ,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;AAC5C,CAAC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contract between the Vite plugin and a framework, on Node: the module that reads a story file's component docs
|
|
3
|
+
* (its props, events and parts), loaded by the docs' worker and by `forgebook-docs`.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Everything else the plugin does is the same for every framework: the story index, the meta's reading
|
|
7
|
+
* (`storyMeta.ts`), the TypeScript programs (`docsProgram.ts`), the worker, the code and the Markdown. A framework
|
|
8
|
+
* package (`@forgebook/react`) exports a docs module (`./docs`) with an `extractStoryComponent` of this type, and an
|
|
9
|
+
* adapter (`./vite`) that names it.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import type { PluginOption } from "vite";
|
|
14
|
+
import type { ComponentDocs, NoComponentDocs } from "../componentDocs.ts";
|
|
15
|
+
/** A story file's component: its docs and the file that declares it. */
|
|
16
|
+
export type StoryComponent = {
|
|
17
|
+
/** The component's docs. */
|
|
18
|
+
readonly docs: ComponentDocs;
|
|
19
|
+
/** The absolute path of the file that declares it. */
|
|
20
|
+
readonly file: string;
|
|
21
|
+
/**
|
|
22
|
+
* Every file the docs are read from: the component's and those declaring its own props, so an edit to any of them
|
|
23
|
+
* can renew the docs.
|
|
24
|
+
*/
|
|
25
|
+
readonly sources: readonly string[];
|
|
26
|
+
};
|
|
27
|
+
/** What a framework reads of a story file: its component, `{ docs: { name: null } }` without one, or why it cannot. */
|
|
28
|
+
export type StoryComponentResult = StoryComponent | {
|
|
29
|
+
readonly docs: NoComponentDocs;
|
|
30
|
+
} | string;
|
|
31
|
+
/**
|
|
32
|
+
* Reads the component of a story file.
|
|
33
|
+
*
|
|
34
|
+
* @param storyFile - the story file's absolute path.
|
|
35
|
+
*/
|
|
36
|
+
export type ExtractStoryComponent = (storyFile: string) => StoryComponentResult;
|
|
37
|
+
/** A framework, as the plugin uses it. */
|
|
38
|
+
export type FrameworkAdapter = {
|
|
39
|
+
/** The framework's name, as `forgebook-docs --framework` writes it (`react`). */
|
|
40
|
+
readonly name: string;
|
|
41
|
+
/** The URL of the module that exports the framework's `extractStoryComponent`, loaded in the docs' worker. */
|
|
42
|
+
readonly docsModule: string;
|
|
43
|
+
/**
|
|
44
|
+
* The browser modules the generated pages import, as specifiers the catalogue's folder resolves: the frame page's
|
|
45
|
+
* (`mountFrame` with the framework's renderer) and the code writer the shell writes a story's code with
|
|
46
|
+
* (`storyJsx`).
|
|
47
|
+
*/
|
|
48
|
+
readonly pages: {
|
|
49
|
+
/** The module exporting the framework's `mountFrame` (`@forgebook/react/frame`). */
|
|
50
|
+
readonly frame: string;
|
|
51
|
+
/** The module exporting the framework's code writer as `codeOf` (`@forgebook/react/code`). */
|
|
52
|
+
readonly code: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The packages the framework's pages import in the browser (`react-dom/client`): pre-bundled before the first page
|
|
56
|
+
* opens, since Vite's scanner cannot read pages that are generated; none by default.
|
|
57
|
+
*/
|
|
58
|
+
readonly browserDependencies?: readonly string[];
|
|
59
|
+
/** The Vite plugins the framework needs in a catalogue (React's Fast Refresh); none by default. */
|
|
60
|
+
readonly vitePlugins?: () => Promise<readonly PluginOption[]>;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Whether a loaded module is a docs module: it exports an `extractStoryComponent` function.
|
|
64
|
+
*
|
|
65
|
+
* @param module - the module, as `import()` gave it.
|
|
66
|
+
*/
|
|
67
|
+
export declare const isDocsModule: (module: unknown) => module is {
|
|
68
|
+
readonly extractStoryComponent: ExtractStoryComponent;
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/vite/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE1E,wEAAwE;AACxE,MAAM,MAAM,cAAc,GAAG;IAC3B,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC,CAAC;AAEF,uHAAuH;AACvH,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAA;CAAE,GAAG,MAAM,CAAC;AAEhG;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,SAAS,EAAE,MAAM,KAAK,oBAAoB,CAAC;AAEhF,0CAA0C;AAC1C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,iFAAiF;IACjF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8GAA8G;IAC9G,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE;QACd,oFAAoF;QACpF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,8FAA8F;QAC9F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KACvB,CAAC;IACF;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjD,mGAAmG;IACnG,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC,CAAC;CAC/D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GACvB,QAAQ,OAAO,KACd,MAAM,IAAI;IAAE,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB,CAAA;CAIhB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contract between the Vite plugin and a framework, on Node: the module that reads a story file's component docs
|
|
3
|
+
* (its props, events and parts), loaded by the docs' worker and by `forgebook-docs`.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Everything else the plugin does is the same for every framework: the story index, the meta's reading
|
|
7
|
+
* (`storyMeta.ts`), the TypeScript programs (`docsProgram.ts`), the worker, the code and the Markdown. A framework
|
|
8
|
+
* package (`@forgebook/react`) exports a docs module (`./docs`) with an `extractStoryComponent` of this type, and an
|
|
9
|
+
* adapter (`./vite`) that names it.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Whether a loaded module is a docs module: it exports an `extractStoryComponent` function.
|
|
15
|
+
*
|
|
16
|
+
* @param module - the module, as `import()` gave it.
|
|
17
|
+
*/
|
|
18
|
+
export const isDocsModule = (module) => typeof module === "object" &&
|
|
19
|
+
module !== null &&
|
|
20
|
+
"extractStoryComponent" in module &&
|
|
21
|
+
typeof module.extractStoryComponent === "function";
|
|
22
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../src/vite/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAuDH;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,MAAe,EACsD,EAAE,CACvE,OAAO,MAAM,KAAK,QAAQ;IAC1B,MAAM,KAAK,IAAI;IACf,uBAAuB,IAAI,MAAM;IACjC,OAAO,MAAM,CAAC,qBAAqB,KAAK,UAAU,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The title a story file's path makes, for a meta that writes none, as Storybook's auto-title makes it: the file's
|
|
3
|
+
* path from the static start of its pattern, without `.stories.*`.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* `src/**\/*.stories.tsx` matching `src/inputs/Select/Select.stories.tsx` gives `inputs/Select`: the folder and a file
|
|
7
|
+
* of the same name make one segment, and an `index` file takes its folder's name. The plugin, the tests' index and
|
|
8
|
+
* `forgebook-docs` all give the index the same title, so a story's id is the same everywhere. Pure.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
/** A story file's name, by its extension: `.stories.` then a JavaScript or TypeScript extension. */
|
|
13
|
+
export declare const STORY_FILE: RegExp;
|
|
14
|
+
/**
|
|
15
|
+
* The static start of a pattern: its folders before the first segment with a glob character (`../src` for
|
|
16
|
+
* `../src/**\/*.stories.tsx`).
|
|
17
|
+
*
|
|
18
|
+
* @param pattern - the pattern.
|
|
19
|
+
*/
|
|
20
|
+
export declare const patternBase: (pattern: string) => string;
|
|
21
|
+
/**
|
|
22
|
+
* The title a story file's path makes, or none when its path gives no segment.
|
|
23
|
+
*
|
|
24
|
+
* @param base - the folder the title starts from, as `patternBase` gives it (relative paths, `/`-separated).
|
|
25
|
+
* @param file - the file, relative to the same folder as `base`.
|
|
26
|
+
*/
|
|
27
|
+
export declare const autoTitle: (base: string, file: string) => string | undefined;
|
|
28
|
+
//# sourceMappingURL=autoTitle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoTitle.d.ts","sourceRoot":"","sources":["../../../src/vite/autoTitle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,oGAAoG;AACpG,eAAO,MAAM,UAAU,QAAiC,CAAC;AAKzD;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,KAAG,MAK7C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,MAAM,GAAG,SAW/D,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The title a story file's path makes, for a meta that writes none, as Storybook's auto-title makes it: the file's
|
|
3
|
+
* path from the static start of its pattern, without `.stories.*`.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* `src/**\/*.stories.tsx` matching `src/inputs/Select/Select.stories.tsx` gives `inputs/Select`: the folder and a file
|
|
7
|
+
* of the same name make one segment, and an `index` file takes its folder's name. The plugin, the tests' index and
|
|
8
|
+
* `forgebook-docs` all give the index the same title, so a story's id is the same everywhere. Pure.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
/** A story file's name, by its extension: `.stories.` then a JavaScript or TypeScript extension. */
|
|
13
|
+
export const STORY_FILE = /\.stories\.(?:[cm]?[jt]sx?)$/;
|
|
14
|
+
/** Whether a pattern's segment has a glob character, from which point the pattern names no folder. */
|
|
15
|
+
const isGlob = (segment) => /[*?[\]{}!]/.test(segment);
|
|
16
|
+
/**
|
|
17
|
+
* The static start of a pattern: its folders before the first segment with a glob character (`../src` for
|
|
18
|
+
* `../src/**\/*.stories.tsx`).
|
|
19
|
+
*
|
|
20
|
+
* @param pattern - the pattern.
|
|
21
|
+
*/
|
|
22
|
+
export const patternBase = (pattern) => {
|
|
23
|
+
const segments = pattern.split("/");
|
|
24
|
+
const firstGlob = segments.findIndex(isGlob);
|
|
25
|
+
const folders = firstGlob === -1 ? segments.slice(0, -1) : segments.slice(0, firstGlob);
|
|
26
|
+
return folders.join("/");
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The title a story file's path makes, or none when its path gives no segment.
|
|
30
|
+
*
|
|
31
|
+
* @param base - the folder the title starts from, as `patternBase` gives it (relative paths, `/`-separated).
|
|
32
|
+
* @param file - the file, relative to the same folder as `base`.
|
|
33
|
+
*/
|
|
34
|
+
export const autoTitle = (base, file) => {
|
|
35
|
+
const baseSegments = base.split("/").filter((segment) => segment !== "" && segment !== ".");
|
|
36
|
+
const fileSegments = file.split("/").filter((segment) => segment !== "" && segment !== ".");
|
|
37
|
+
const isUnderBase = baseSegments.every((segment, index) => fileSegments[index] === segment);
|
|
38
|
+
const segments = (isUnderBase ? fileSegments.slice(baseSegments.length) : fileSegments).filter((segment) => segment !== "..");
|
|
39
|
+
const last = segments.pop()?.replace(STORY_FILE, "");
|
|
40
|
+
if (last !== undefined && last !== "index" && last.toLowerCase() !== segments.at(-1)?.toLowerCase())
|
|
41
|
+
segments.push(last);
|
|
42
|
+
return segments.length === 0 ? undefined : segments.join("/");
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=autoTitle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoTitle.js","sourceRoot":"","sources":["../../../src/vite/autoTitle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,oGAAoG;AACpG,MAAM,CAAC,MAAM,UAAU,GAAG,8BAA8B,CAAC;AAEzD,sGAAsG;AACtG,MAAM,MAAM,GAAG,CAAC,OAAe,EAAW,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAExE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAe,EAAU,EAAE;IACrD,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;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,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE;QACjG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtB,OAAO,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChE,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** A component's page text, as HTML. */
|
|
2
|
+
export type ComponentPageText = {
|
|
3
|
+
/** The text. */
|
|
4
|
+
readonly html: string;
|
|
5
|
+
/** The documentation file it came from, watched in development. */
|
|
6
|
+
readonly file: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The documentation file beside a story file: its component's name in kebab case, with `.md`.
|
|
10
|
+
*
|
|
11
|
+
* @param storyFile - the story file's absolute path.
|
|
12
|
+
*/
|
|
13
|
+
export declare const pageFileOf: (storyFile: string) => string;
|
|
14
|
+
/**
|
|
15
|
+
* The page's Markdown: without its first `# ` title and without the sections drawn from the types.
|
|
16
|
+
*
|
|
17
|
+
* @param markdown - the documentation file's text.
|
|
18
|
+
*/
|
|
19
|
+
export declare const pageMarkdown: (markdown: string) => string;
|
|
20
|
+
/**
|
|
21
|
+
* A Markdown file as HTML, its first `#` title left out and its headings one level down: a source's introduction on
|
|
22
|
+
* the catalogue's home, which sits under the source's own heading, so the file's `##` sections are its parts.
|
|
23
|
+
*
|
|
24
|
+
* @param text - the file's text.
|
|
25
|
+
*/
|
|
26
|
+
export declare const markdownHtml: (text: string) => string;
|
|
27
|
+
/**
|
|
28
|
+
* The page's text, read from the documentation file beside a story file.
|
|
29
|
+
*
|
|
30
|
+
* @param storyFile - the story file's absolute path.
|
|
31
|
+
* @returns the HTML and the file it came from, or none when the component has no documentation file.
|
|
32
|
+
*/
|
|
33
|
+
export declare const componentPage: (storyFile: string) => ComponentPageText | undefined;
|
|
34
|
+
//# sourceMappingURL=componentPage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentPage.d.ts","sourceRoot":"","sources":["../../../src/vite/componentPage.ts"],"names":[],"mappings":"AAkCA,wCAAwC;AACxC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,gBAAgB;IAChB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAKF;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,WAAW,MAAM,KAAG,MAI9C,CAAC;AAaF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,KAAG,MAQ/C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,MAMxC,CAAC;AAEL;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,WAAW,MAAM,KAAG,iBAAiB,GAAG,SAIrE,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A component's page text: its Markdown documentation beside its story file (`Counter.stories.tsx` → `counter.md`),
|
|
3
|
+
* as HTML for the catalogue's component page.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* The title is left out (the page's header shows the name) and so is the `## Props` section: the page draws the props
|
|
7
|
+
* from the component's types, which a table written by hand would only repeat and drift from. Everything else (the
|
|
8
|
+
* introduction, the usage, Accessibility, Parts and styling, Test ids) follows the demo, its code blocks coloured
|
|
9
|
+
* (`highlightCode.ts`). The page's lead is the component's TSDoc summary, not the file's opening: that summary is
|
|
10
|
+
* written for whoever uses the component, the file's opening often for whoever builds it. The files are the
|
|
11
|
+
* package's, read at build time, so their HTML is trusted as the stories' code is.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
16
|
+
import { basename, dirname, join } from "node:path";
|
|
17
|
+
import { Marked } from "marked";
|
|
18
|
+
import { highlightCode } from "./highlightCode.js";
|
|
19
|
+
/** Markdown with GitHub's tables, its code blocks coloured. */
|
|
20
|
+
const markdown = new Marked({
|
|
21
|
+
async: false,
|
|
22
|
+
gfm: true,
|
|
23
|
+
renderer: {
|
|
24
|
+
code: ({ text, lang }) => {
|
|
25
|
+
const language = lang?.trim().split(/\s+/)[0] || undefined;
|
|
26
|
+
const languageClass = language === undefined ? "" : ` class="language-${language}"`;
|
|
27
|
+
return `<pre><code${languageClass}>${highlightCode(text, language)}</code></pre>\n`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
/** The Markdown sections the page draws from the component's types instead. */
|
|
32
|
+
const GENERATED_SECTIONS = ["Props"];
|
|
33
|
+
/**
|
|
34
|
+
* The documentation file beside a story file: its component's name in kebab case, with `.md`.
|
|
35
|
+
*
|
|
36
|
+
* @param storyFile - the story file's absolute path.
|
|
37
|
+
*/
|
|
38
|
+
export const pageFileOf = (storyFile) => {
|
|
39
|
+
const component = basename(storyFile).replace(/\.stories\.tsx?$/, "");
|
|
40
|
+
const kebab = component.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
41
|
+
return join(dirname(storyFile), `${kebab}.md`);
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* A Markdown text without its first `# ` title: the catalogue shows the name above it.
|
|
45
|
+
*
|
|
46
|
+
* @param markdown - the text.
|
|
47
|
+
*/
|
|
48
|
+
const withoutTitle = (markdown) => {
|
|
49
|
+
const lines = markdown.split("\n");
|
|
50
|
+
const title = lines.findIndex((line) => line.startsWith("# "));
|
|
51
|
+
return (title === -1 ? lines : [...lines.slice(0, title), ...lines.slice(title + 1)]).join("\n").trim();
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The page's Markdown: without its first `# ` title and without the sections drawn from the types.
|
|
55
|
+
*
|
|
56
|
+
* @param markdown - the documentation file's text.
|
|
57
|
+
*/
|
|
58
|
+
export const pageMarkdown = (markdown) => {
|
|
59
|
+
const kept = [];
|
|
60
|
+
let isSkipping = false;
|
|
61
|
+
for (const line of withoutTitle(markdown).split("\n")) {
|
|
62
|
+
if (line.startsWith("## "))
|
|
63
|
+
isSkipping = GENERATED_SECTIONS.includes(line.slice(3).trim());
|
|
64
|
+
if (!isSkipping)
|
|
65
|
+
kept.push(line);
|
|
66
|
+
}
|
|
67
|
+
return kept.join("\n").trim();
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* A Markdown file as HTML, its first `#` title left out and its headings one level down: a source's introduction on
|
|
71
|
+
* the catalogue's home, which sits under the source's own heading, so the file's `##` sections are its parts.
|
|
72
|
+
*
|
|
73
|
+
* @param text - the file's text.
|
|
74
|
+
*/
|
|
75
|
+
export const markdownHtml = (text) => markdown.parse(withoutTitle(text), {
|
|
76
|
+
async: false,
|
|
77
|
+
walkTokens: (token) => {
|
|
78
|
+
if (token.type === "heading")
|
|
79
|
+
token.depth = Math.min(token.depth + 1, 6);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* The page's text, read from the documentation file beside a story file.
|
|
84
|
+
*
|
|
85
|
+
* @param storyFile - the story file's absolute path.
|
|
86
|
+
* @returns the HTML and the file it came from, or none when the component has no documentation file.
|
|
87
|
+
*/
|
|
88
|
+
export const componentPage = (storyFile) => {
|
|
89
|
+
const file = pageFileOf(storyFile);
|
|
90
|
+
if (!existsSync(file))
|
|
91
|
+
return undefined;
|
|
92
|
+
return { html: markdown.parse(pageMarkdown(readFileSync(file, "utf8")), { async: false }), file };
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=componentPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentPage.js","sourceRoot":"","sources":["../../../src/vite/componentPage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAA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