forgebook 0.1.3 → 0.1.5
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/README.md +99 -6
- package/dist/bin/forgebook/agentClient.d.ts +17 -0
- package/dist/bin/forgebook/agentClient.d.ts.map +1 -1
- package/dist/bin/forgebook/agentClient.js +21 -0
- package/dist/bin/forgebook/agentClient.js.map +1 -1
- package/dist/bin/forgebook/agentLoopCommands.d.mts +9 -0
- package/dist/bin/forgebook/agentLoopCommands.d.mts.map +1 -0
- package/dist/bin/forgebook/agentLoopCommands.mjs +217 -0
- package/dist/bin/forgebook/agentLoopCommands.mjs.map +1 -0
- package/dist/bin/forgebook/agentText.d.ts +37 -1
- package/dist/bin/forgebook/agentText.d.ts.map +1 -1
- package/dist/bin/forgebook/agentText.js +49 -2
- package/dist/bin/forgebook/agentText.js.map +1 -1
- package/dist/bin/forgebook/agents.md +51 -0
- package/dist/bin/forgebook/agentsText.d.ts +29 -0
- package/dist/bin/forgebook/agentsText.d.ts.map +1 -0
- package/dist/bin/forgebook/agentsText.js +48 -0
- package/dist/bin/forgebook/agentsText.js.map +1 -0
- package/dist/bin/forgebook/catalogueCommands.d.ts +51 -0
- package/dist/bin/forgebook/catalogueCommands.d.ts.map +1 -0
- package/dist/bin/forgebook/catalogueCommands.js +90 -0
- package/dist/bin/forgebook/catalogueCommands.js.map +1 -0
- package/dist/bin/forgebook/errorsRun.d.ts +27 -0
- package/dist/bin/forgebook/errorsRun.d.ts.map +1 -0
- package/dist/bin/forgebook/errorsRun.js +60 -0
- package/dist/bin/forgebook/errorsRun.js.map +1 -0
- package/dist/bin/forgebook/forgebook.mjs +121 -86
- package/dist/bin/forgebook/forgebook.mjs.map +1 -1
- package/dist/bin/forgebook/importers/storybook.d.ts +53 -0
- package/dist/bin/forgebook/importers/storybook.d.ts.map +1 -0
- package/dist/bin/forgebook/importers/storybook.js +318 -0
- package/dist/bin/forgebook/importers/storybook.js.map +1 -0
- package/dist/bin/forgebook/initCommands.d.mts +9 -0
- package/dist/bin/forgebook/initCommands.d.mts.map +1 -0
- package/dist/bin/forgebook/initCommands.mjs +86 -0
- package/dist/bin/forgebook/initCommands.mjs.map +1 -0
- package/dist/bin/forgebook/initConfig.d.ts +22 -0
- package/dist/bin/forgebook/initConfig.d.ts.map +1 -0
- package/dist/bin/forgebook/initConfig.js +51 -0
- package/dist/bin/forgebook/initConfig.js.map +1 -0
- package/dist/bin/forgebook/mcpTools.d.ts +29 -3
- package/dist/bin/forgebook/mcpTools.d.ts.map +1 -1
- package/dist/bin/forgebook/mcpTools.js +130 -7
- package/dist/bin/forgebook/mcpTools.js.map +1 -1
- package/dist/bin/forgebook/newStories.d.ts +27 -0
- package/dist/bin/forgebook/newStories.d.ts.map +1 -0
- package/dist/bin/forgebook/newStories.js +109 -0
- package/dist/bin/forgebook/newStories.js.map +1 -0
- package/dist/bin/forgebook/newStoriesFile.d.ts +18 -0
- package/dist/bin/forgebook/newStoriesFile.d.ts.map +1 -0
- package/dist/bin/forgebook/newStoriesFile.js +58 -0
- package/dist/bin/forgebook/newStoriesFile.js.map +1 -0
- package/dist/bin/forgebook/storyCheckRun.d.ts +49 -0
- package/dist/bin/forgebook/storyCheckRun.d.ts.map +1 -0
- package/dist/bin/forgebook/storyCheckRun.js +178 -0
- package/dist/bin/forgebook/storyCheckRun.js.map +1 -0
- package/dist/bin/forgebook/touchWindowRun.d.ts +17 -0
- package/dist/bin/forgebook/touchWindowRun.d.ts.map +1 -0
- package/dist/bin/forgebook/touchWindowRun.js +21 -0
- package/dist/bin/forgebook/touchWindowRun.js.map +1 -0
- package/dist/bin/forgebook-docs/catalogueDocs.d.ts +24 -0
- package/dist/bin/forgebook-docs/catalogueDocs.d.ts.map +1 -0
- package/dist/bin/forgebook-docs/catalogueDocs.js +71 -0
- package/dist/bin/forgebook-docs/catalogueDocs.js.map +1 -0
- package/dist/bin/forgebook-docs/catalogueDocs.types.d.ts +8 -0
- package/dist/bin/forgebook-docs/catalogueDocs.types.d.ts.map +1 -1
- package/dist/bin/forgebook-docs/catalogueMarkdown.d.ts +3 -1
- package/dist/bin/forgebook-docs/catalogueMarkdown.d.ts.map +1 -1
- package/dist/bin/forgebook-docs/catalogueMarkdown.js +62 -42
- package/dist/bin/forgebook-docs/catalogueMarkdown.js.map +1 -1
- package/dist/bin/forgebook-docs/catalogueOptions.d.ts +39 -0
- package/dist/bin/forgebook-docs/catalogueOptions.d.ts.map +1 -0
- package/dist/bin/forgebook-docs/catalogueOptions.js +76 -0
- package/dist/bin/forgebook-docs/catalogueOptions.js.map +1 -0
- package/dist/bin/forgebook-docs/collectDocs.d.ts +3 -1
- package/dist/bin/forgebook-docs/collectDocs.d.ts.map +1 -1
- package/dist/bin/forgebook-docs/collectDocs.js +37 -13
- package/dist/bin/forgebook-docs/collectDocs.js.map +1 -1
- package/dist/bin/forgebook-docs/forgebook-docs.mjs +17 -80
- package/dist/bin/forgebook-docs/forgebook-docs.mjs.map +1 -1
- package/dist/bin/forgebook-docs/llmsText.d.ts +24 -0
- package/dist/bin/forgebook-docs/llmsText.d.ts.map +1 -0
- package/dist/bin/forgebook-docs/llmsText.js +33 -0
- package/dist/bin/forgebook-docs/llmsText.js.map +1 -0
- package/dist/bin/forgebook-docs/sourceId.d.ts +9 -0
- package/dist/bin/forgebook-docs/sourceId.d.ts.map +1 -0
- package/dist/bin/forgebook-docs/sourceId.js +45 -0
- package/dist/bin/forgebook-docs/sourceId.js.map +1 -0
- package/dist/bin/frameworkDocs.d.ts +10 -0
- package/dist/bin/frameworkDocs.d.ts.map +1 -0
- package/dist/bin/frameworkDocs.js +43 -0
- package/dist/bin/frameworkDocs.js.map +1 -0
- package/dist/src/argTypes.d.ts +23 -0
- package/dist/src/argTypes.d.ts.map +1 -1
- package/dist/src/argTypes.js +27 -0
- package/dist/src/argTypes.js.map +1 -1
- package/dist/src/catalogue.d.ts +70 -3
- package/dist/src/catalogue.d.ts.map +1 -1
- package/dist/src/catalogue.js +85 -3
- package/dist/src/catalogue.js.map +1 -1
- package/dist/src/controlKeys.d.ts +85 -0
- package/dist/src/controlKeys.d.ts.map +1 -0
- package/dist/src/controlKeys.js +118 -0
- package/dist/src/controlKeys.js.map +1 -0
- package/dist/src/frame/frame.css +33 -2
- package/dist/src/frame/frameView.d.ts +2 -2
- package/dist/src/frame/frameView.d.ts.map +1 -1
- package/dist/src/frame/frameView.js +7 -3
- package/dist/src/frame/frameView.js.map +1 -1
- package/dist/src/frame/mountFrame.d.ts.map +1 -1
- package/dist/src/frame/mountFrame.js +30 -2
- package/dist/src/frame/mountFrame.js.map +1 -1
- package/dist/src/frame/spillOutline.d.ts +10 -0
- package/dist/src/frame/spillOutline.d.ts.map +1 -0
- package/dist/src/frame/spillOutline.js +80 -0
- package/dist/src/frame/spillOutline.js.map +1 -0
- package/dist/src/frame/touchDots.d.ts +32 -0
- package/dist/src/frame/touchDots.d.ts.map +1 -0
- package/dist/src/frame/touchDots.js +52 -0
- package/dist/src/frame/touchDots.js.map +1 -0
- package/dist/src/frame/touchEvents.d.ts +66 -0
- package/dist/src/frame/touchEvents.d.ts.map +1 -0
- package/dist/src/frame/touchEvents.js +152 -0
- package/dist/src/frame/touchEvents.js.map +1 -0
- package/dist/src/frame/touchGesture.d.ts +80 -0
- package/dist/src/frame/touchGesture.d.ts.map +1 -0
- package/dist/src/frame/touchGesture.js +87 -0
- package/dist/src/frame/touchGesture.js.map +1 -0
- package/dist/src/frame/touchLayer.d.ts +7 -0
- package/dist/src/frame/touchLayer.d.ts.map +1 -0
- package/dist/src/frame/touchLayer.js +399 -0
- package/dist/src/frame/touchLayer.js.map +1 -0
- package/dist/src/frame/touchScroll.d.ts +51 -0
- package/dist/src/frame/touchScroll.d.ts.map +1 -0
- package/dist/src/frame/touchScroll.js +137 -0
- package/dist/src/frame/touchScroll.js.map +1 -0
- package/dist/src/liveErrors.d.ts +57 -0
- package/dist/src/liveErrors.d.ts.map +1 -0
- package/dist/src/liveErrors.js +52 -0
- package/dist/src/liveErrors.js.map +1 -0
- package/dist/src/messages.d.ts +12 -0
- package/dist/src/messages.d.ts.map +1 -1
- package/dist/src/messages.js +4 -0
- package/dist/src/messages.js.map +1 -1
- package/dist/src/namedViews.d.ts +80 -0
- package/dist/src/namedViews.d.ts.map +1 -0
- package/dist/src/namedViews.js +88 -0
- package/dist/src/namedViews.js.map +1 -0
- package/dist/src/realTouch.d.ts +21 -0
- package/dist/src/realTouch.d.ts.map +1 -0
- package/dist/src/realTouch.js +16 -0
- package/dist/src/realTouch.js.map +1 -0
- package/dist/src/shell/AppearanceMenu.d.ts +15 -0
- package/dist/src/shell/AppearanceMenu.d.ts.map +1 -0
- package/dist/src/shell/AppearanceMenu.js +28 -0
- package/dist/src/shell/AppearanceMenu.js.map +1 -0
- package/dist/src/shell/BoxWidth.d.ts +40 -0
- package/dist/src/shell/BoxWidth.d.ts.map +1 -0
- package/dist/src/shell/BoxWidth.js +56 -0
- package/dist/src/shell/BoxWidth.js.map +1 -0
- package/dist/src/shell/ComponentPage.d.ts +17 -1
- package/dist/src/shell/ComponentPage.d.ts.map +1 -1
- package/dist/src/shell/ComponentPage.js +19 -54
- package/dist/src/shell/ComponentPage.js.map +1 -1
- package/dist/src/shell/ControlKeyField.d.ts +21 -0
- package/dist/src/shell/ControlKeyField.d.ts.map +1 -0
- package/dist/src/shell/ControlKeyField.js +46 -0
- package/dist/src/shell/ControlKeyField.js.map +1 -0
- package/dist/src/shell/ControlRow.d.ts +31 -0
- package/dist/src/shell/ControlRow.d.ts.map +1 -0
- package/dist/src/shell/ControlRow.js +30 -0
- package/dist/src/shell/ControlRow.js.map +1 -0
- package/dist/src/shell/Example.d.ts +58 -0
- package/dist/src/shell/Example.d.ts.map +1 -0
- package/dist/src/shell/Example.js +89 -0
- package/dist/src/shell/Example.js.map +1 -0
- package/dist/src/shell/InfoTip.d.ts +23 -0
- package/dist/src/shell/InfoTip.d.ts.map +1 -0
- package/dist/src/shell/InfoTip.js +51 -0
- package/dist/src/shell/InfoTip.js.map +1 -0
- package/dist/src/shell/NamedViews.d.ts +23 -0
- package/dist/src/shell/NamedViews.d.ts.map +1 -0
- package/dist/src/shell/NamedViews.js +49 -0
- package/dist/src/shell/NamedViews.js.map +1 -0
- package/dist/src/shell/PinnedControl.d.ts +25 -0
- package/dist/src/shell/PinnedControl.d.ts.map +1 -0
- package/dist/src/shell/PinnedControl.js +82 -0
- package/dist/src/shell/PinnedControl.js.map +1 -0
- package/dist/src/shell/PropsTab.d.ts +5 -2
- package/dist/src/shell/PropsTab.d.ts.map +1 -1
- package/dist/src/shell/PropsTab.js +12 -15
- package/dist/src/shell/PropsTab.js.map +1 -1
- package/dist/src/shell/Shell.d.ts.map +1 -1
- package/dist/src/shell/Shell.js +27 -2
- package/dist/src/shell/Shell.js.map +1 -1
- package/dist/src/shell/Sidebar.d.ts +11 -9
- package/dist/src/shell/Sidebar.d.ts.map +1 -1
- package/dist/src/shell/Sidebar.js +48 -42
- package/dist/src/shell/Sidebar.js.map +1 -1
- package/dist/src/shell/SidebarEntries.d.ts +50 -0
- package/dist/src/shell/SidebarEntries.d.ts.map +1 -0
- package/dist/src/shell/SidebarEntries.js +51 -0
- package/dist/src/shell/SidebarEntries.js.map +1 -0
- package/dist/src/shell/Stage.d.ts.map +1 -1
- package/dist/src/shell/Stage.js +19 -2
- package/dist/src/shell/Stage.js.map +1 -1
- package/dist/src/shell/Toolbar.d.ts +7 -3
- package/dist/src/shell/Toolbar.d.ts.map +1 -1
- package/dist/src/shell/Toolbar.js +38 -68
- package/dist/src/shell/Toolbar.js.map +1 -1
- package/dist/src/shell/ToolbarControl.d.ts +47 -0
- package/dist/src/shell/ToolbarControl.d.ts.map +1 -0
- package/dist/src/shell/ToolbarControl.js +150 -0
- package/dist/src/shell/ToolbarControl.js.map +1 -0
- package/dist/src/shell/UsedIn.d.ts +38 -0
- package/dist/src/shell/UsedIn.d.ts.map +1 -0
- package/dist/src/shell/UsedIn.js +77 -0
- package/dist/src/shell/UsedIn.js.map +1 -0
- package/dist/src/shell/ViewMenu.d.ts +37 -0
- package/dist/src/shell/ViewMenu.d.ts.map +1 -0
- package/dist/src/shell/ViewMenu.js +219 -0
- package/dist/src/shell/ViewMenu.js.map +1 -0
- package/dist/src/shell/controlCycle.d.ts +28 -0
- package/dist/src/shell/controlCycle.d.ts.map +1 -0
- package/dist/src/shell/controlCycle.js +51 -0
- package/dist/src/shell/controlCycle.js.map +1 -0
- package/dist/src/shell/dockTabs.d.ts +3 -0
- package/dist/src/shell/dockTabs.d.ts.map +1 -1
- package/dist/src/shell/dockTabs.js +1 -1
- package/dist/src/shell/dockTabs.js.map +1 -1
- package/dist/src/shell/icons.d.ts +7 -0
- package/dist/src/shell/icons.d.ts.map +1 -1
- package/dist/src/shell/icons.js +8 -1
- package/dist/src/shell/icons.js.map +1 -1
- package/dist/src/shell/keyboard.d.ts +2 -1
- package/dist/src/shell/keyboard.d.ts.map +1 -1
- package/dist/src/shell/keyboard.js +5 -2
- package/dist/src/shell/keyboard.js.map +1 -1
- package/dist/src/shell/shell.css +876 -244
- package/dist/src/shell/strings.d.ts +46 -0
- package/dist/src/shell/strings.d.ts.map +1 -1
- package/dist/src/shell/strings.js +46 -0
- package/dist/src/shell/strings.js.map +1 -1
- package/dist/src/shell/useAppearance.d.ts +17 -0
- package/dist/src/shell/useAppearance.d.ts.map +1 -0
- package/dist/src/shell/useAppearance.js +36 -0
- package/dist/src/shell/useAppearance.js.map +1 -0
- package/dist/src/shell/useControlKeys.d.ts +23 -0
- package/dist/src/shell/useControlKeys.d.ts.map +1 -0
- package/dist/src/shell/useControlKeys.js +44 -0
- package/dist/src/shell/useControlKeys.js.map +1 -0
- package/dist/src/shell/useFold.d.ts +27 -0
- package/dist/src/shell/useFold.d.ts.map +1 -0
- package/dist/src/shell/useFold.js +87 -0
- package/dist/src/shell/useFold.js.map +1 -0
- package/dist/src/shell/useFrameMessages.d.ts +2 -0
- package/dist/src/shell/useFrameMessages.d.ts.map +1 -1
- package/dist/src/shell/useFrameMessages.js +3 -0
- package/dist/src/shell/useFrameMessages.js.map +1 -1
- package/dist/src/shell/useFullPage.d.ts +45 -0
- package/dist/src/shell/useFullPage.d.ts.map +1 -0
- package/dist/src/shell/useFullPage.js +149 -0
- package/dist/src/shell/useFullPage.js.map +1 -0
- package/dist/src/shell/usePopover.d.ts +17 -3
- package/dist/src/shell/usePopover.d.ts.map +1 -1
- package/dist/src/shell/usePopover.js +65 -4
- package/dist/src/shell/usePopover.js.map +1 -1
- package/dist/src/shell/useStored.d.ts +13 -2
- package/dist/src/shell/useStored.d.ts.map +1 -1
- package/dist/src/shell/useStored.js +1 -1
- package/dist/src/shell/useStored.js.map +1 -1
- package/dist/src/shell/useToolbarLayout.d.ts +39 -0
- package/dist/src/shell/useToolbarLayout.d.ts.map +1 -0
- package/dist/src/shell/useToolbarLayout.js +58 -0
- package/dist/src/shell/useToolbarLayout.js.map +1 -0
- package/dist/src/shell/useToolbarOverflow.d.ts +31 -0
- package/dist/src/shell/useToolbarOverflow.d.ts.map +1 -0
- package/dist/src/shell/useToolbarOverflow.js +62 -0
- package/dist/src/shell/useToolbarOverflow.js.map +1 -0
- package/dist/src/shell/useWorstCase.d.ts +46 -0
- package/dist/src/shell/useWorstCase.d.ts.map +1 -0
- package/dist/src/shell/useWorstCase.js +42 -0
- package/dist/src/shell/useWorstCase.js.map +1 -0
- package/dist/src/shell/worstArgs.d.ts +42 -0
- package/dist/src/shell/worstArgs.d.ts.map +1 -0
- package/dist/src/shell/worstArgs.js +47 -0
- package/dist/src/shell/worstArgs.js.map +1 -0
- package/dist/src/spills.d.ts +31 -0
- package/dist/src/spills.d.ts.map +1 -0
- package/dist/src/spills.js +65 -0
- package/dist/src/spills.js.map +1 -0
- package/dist/src/storyCheck.d.ts +105 -0
- package/dist/src/storyCheck.d.ts.map +1 -0
- package/dist/src/storyCheck.js +63 -0
- package/dist/src/storyCheck.js.map +1 -0
- package/dist/src/switches.d.ts +26 -4
- package/dist/src/switches.d.ts.map +1 -1
- package/dist/src/switches.js +50 -5
- package/dist/src/switches.js.map +1 -1
- package/dist/src/toolbarLayout.d.ts +119 -0
- package/dist/src/toolbarLayout.d.ts.map +1 -0
- package/dist/src/toolbarLayout.js +155 -0
- package/dist/src/toolbarLayout.js.map +1 -0
- package/dist/src/usedIn.d.ts +60 -0
- package/dist/src/usedIn.d.ts.map +1 -0
- package/dist/src/usedIn.js +92 -0
- package/dist/src/usedIn.js.map +1 -0
- package/dist/src/viewState.d.ts +9 -11
- package/dist/src/viewState.d.ts.map +1 -1
- package/dist/src/viewState.js +24 -20
- package/dist/src/viewState.js.map +1 -1
- package/dist/src/viewWords.d.ts +26 -0
- package/dist/src/viewWords.d.ts.map +1 -0
- package/dist/src/viewWords.js +29 -0
- package/dist/src/viewWords.js.map +1 -0
- package/dist/src/vite/adapter.d.ts +13 -4
- package/dist/src/vite/adapter.d.ts.map +1 -1
- package/dist/src/vite/adapter.js +4 -2
- package/dist/src/vite/adapter.js.map +1 -1
- package/dist/src/vite/agent.types.d.ts +32 -2
- package/dist/src/vite/agent.types.d.ts.map +1 -1
- package/dist/src/vite/agentApi.d.ts +15 -3
- package/dist/src/vite/agentApi.d.ts.map +1 -1
- package/dist/src/vite/agentApi.js +63 -9
- package/dist/src/vite/agentApi.js.map +1 -1
- package/dist/src/vite/agentRoutes.d.ts +8 -3
- package/dist/src/vite/agentRoutes.d.ts.map +1 -1
- package/dist/src/vite/agentRoutes.js +84 -23
- package/dist/src/vite/agentRoutes.js.map +1 -1
- package/dist/src/vite/configFile.d.ts +2 -1
- package/dist/src/vite/configFile.d.ts.map +1 -1
- package/dist/src/vite/configFile.js +29 -11
- package/dist/src/vite/configFile.js.map +1 -1
- package/dist/src/vite/docsExtractor.d.ts +26 -2
- package/dist/src/vite/docsExtractor.d.ts.map +1 -1
- package/dist/src/vite/docsExtractor.js +12 -9
- package/dist/src/vite/docsExtractor.js.map +1 -1
- package/dist/src/vite/docsWorker.js +18 -2
- package/dist/src/vite/docsWorker.js.map +1 -1
- package/dist/src/vite/forcedStates.d.ts +6 -2
- package/dist/src/vite/forcedStates.d.ts.map +1 -1
- package/dist/src/vite/forcedStates.js +20 -4
- package/dist/src/vite/forcedStates.js.map +1 -1
- package/dist/src/vite/forgebookPlugin.d.ts.map +1 -1
- package/dist/src/vite/forgebookPlugin.js +104 -16
- package/dist/src/vite/forgebookPlugin.js.map +1 -1
- package/dist/src/vite/indexStoryFile.d.ts +14 -0
- package/dist/src/vite/indexStoryFile.d.ts.map +1 -1
- package/dist/src/vite/indexStoryFile.js +13 -4
- package/dist/src/vite/indexStoryFile.js.map +1 -1
- package/dist/src/vite/mcpProtocol.d.ts +9 -0
- package/dist/src/vite/mcpProtocol.d.ts.map +1 -1
- package/dist/src/vite/mcpProtocol.js +6 -3
- package/dist/src/vite/mcpProtocol.js.map +1 -1
- package/dist/src/vite/storyFilesModule.d.ts +44 -1
- package/dist/src/vite/storyFilesModule.d.ts.map +1 -1
- package/dist/src/vite/storyFilesModule.js +49 -14
- package/dist/src/vite/storyFilesModule.js.map +1 -1
- package/dist/src/vite/touchMedia.d.ts +35 -0
- package/dist/src/vite/touchMedia.d.ts.map +1 -0
- package/dist/src/vite/touchMedia.js +187 -0
- package/dist/src/vite/touchMedia.js.map +1 -0
- package/dist/src/vite/usageGraph.d.ts +45 -0
- package/dist/src/vite/usageGraph.d.ts.map +1 -0
- package/dist/src/vite/usageGraph.js +246 -0
- package/dist/src/vite/usageGraph.js.map +1 -0
- package/dist/src/vite/usageModule.d.ts +33 -0
- package/dist/src/vite/usageModule.d.ts.map +1 -0
- package/dist/src/vite/usageModule.js +135 -0
- package/dist/src/vite/usageModule.js.map +1 -0
- package/dist/src/worstCase.d.ts +16 -0
- package/dist/src/worstCase.d.ts.map +1 -0
- package/dist/src/worstCase.js +16 -0
- package/dist/src/worstCase.js.map +1 -0
- package/package.json +18 -2
- package/dist/src/shell/SchemeSwitches.d.ts +0 -24
- package/dist/src/shell/SchemeSwitches.d.ts.map +0 -1
- package/dist/src/shell/SchemeSwitches.js +0 -36
- package/dist/src/shell/SchemeSwitches.js.map +0 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The stage's worst case: the args the Props tab's button sets, whether the values shown are those, and the spills the
|
|
3
|
+
* story's frames count while they are.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* The frames are asked to outline their spills only while the worst case is on (`forgebook:spills`), so a story shown
|
|
7
|
+
* with its own data never pays for the measure; a frame that loads again is asked again when it is ready (`sendTo`).
|
|
8
|
+
* The count is kept by story: in the compare view each frame measures its own, and the last to report is shown.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { useEffect, useMemo, useState } from "react";
|
|
13
|
+
import { tellFrames } from "./FrameView.js";
|
|
14
|
+
import { isWorstCase, worstArgs } from "./worstArgs.js";
|
|
15
|
+
/**
|
|
16
|
+
* The stage's worst case.
|
|
17
|
+
*
|
|
18
|
+
* @param input - the frames, the story, its settable props and its values.
|
|
19
|
+
*/
|
|
20
|
+
export const useWorstCase = ({ storyRef, storyId, settable, values, panelArgs, onPanelArgsChange }) => {
|
|
21
|
+
const args = useMemo(() => worstArgs(settable), [settable]);
|
|
22
|
+
const isOn = isWorstCase(args, values);
|
|
23
|
+
const [counts, setCounts] = useState(new Map());
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const message = { type: "forgebook:spills", isOn };
|
|
26
|
+
tellFrames(storyRef.current, message);
|
|
27
|
+
}, [storyRef, isOn]);
|
|
28
|
+
return {
|
|
29
|
+
state: {
|
|
30
|
+
canApply: Object.keys(args).length > 0,
|
|
31
|
+
isOn,
|
|
32
|
+
spillCount: isOn ? counts.get(storyId) : undefined,
|
|
33
|
+
onApply: () => onPanelArgsChange({ ...panelArgs, ...args })
|
|
34
|
+
},
|
|
35
|
+
sendTo: (frame) => {
|
|
36
|
+
const message = { type: "forgebook:spills", isOn };
|
|
37
|
+
frame.postMessage(message, window.location.origin);
|
|
38
|
+
},
|
|
39
|
+
receive: (reported, count) => setCounts((current) => new Map(current).set(reported, count))
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=useWorstCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWorstCase.js","sourceRoot":"","sources":["../../../src/shell/useWorstCase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAkB,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIrE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAuB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA4B7E;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAC3B,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,MAAM,EACN,SAAS,EACT,iBAAiB,EACF,EAAa,EAAE;IAC9B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC5D,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACvC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAA8B,IAAI,GAAG,EAAE,CAAC,CAAC;IAC7E,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,OAAO,GAAiB,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC;QACjE,UAAU,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;IACrB,OAAO;QACL,KAAK,EAAE;YACL,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC;YACtC,IAAI;YACJ,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS;YAClD,OAAO,EAAE,GAAS,EAAE,CAAC,iBAAiB,CAAC,EAAE,GAAG,SAAS,EAAE,GAAG,IAAI,EAAE,CAAC;SAClE;QACD,MAAM,EAAE,CAAC,KAAa,EAAQ,EAAE;YAC9B,MAAM,OAAO,GAAiB,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC;YACjE,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,EAAE,CAAC,QAAgB,EAAE,KAAa,EAAQ,EAAE,CACjD,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;KAChE,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The worst case the Props tab sets with one button: every prop that takes a text given a long one with a word too
|
|
3
|
+
* long to break in it, every number given a huge one, from the component's docs.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* The values are the ones `forgebook new` writes in a story's worst case (`worstCase.ts`). The text joins the long text
|
|
7
|
+
* and the unbreakable word, so one value shows both a box that must wrap and one that must cut or scroll. A colour, a
|
|
8
|
+
* date and a prop whose `argTypes` give it a list keep their values: a long text there is not a case, only an invalid
|
|
9
|
+
* value. A number with a highest value takes that value, the largest the story says it accepts.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { type PanelProp } from "../argTypes.ts";
|
|
14
|
+
import type { PanelArgs } from "../messages.ts";
|
|
15
|
+
/** The worst text: a long one, with a word that cannot break. */
|
|
16
|
+
export declare const WORST_ARG_TEXT = "A label long enough to wrap onto several lines in any box it is given, with words of every length in it Supercalifragilisticexpialidocious_with_no_place_to_break_it_at_all_1234567890";
|
|
17
|
+
/**
|
|
18
|
+
* The worst-case args for the props the panel can set.
|
|
19
|
+
*
|
|
20
|
+
* @param props - the props the panel can set.
|
|
21
|
+
* @returns the args, by prop name; empty when no prop takes a text or a number.
|
|
22
|
+
*/
|
|
23
|
+
export declare const worstArgs: (props: readonly PanelProp[]) => PanelArgs;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the values shown are the worst case: every worst-case arg is set to its worst value.
|
|
26
|
+
*
|
|
27
|
+
* @param worst - the worst-case args.
|
|
28
|
+
* @param values - the values shown.
|
|
29
|
+
*/
|
|
30
|
+
export declare const isWorstCase: (worst: PanelArgs, values: PanelArgs) => boolean;
|
|
31
|
+
/** The worst case as the Props tab shows it. */
|
|
32
|
+
export type WorstCaseState = {
|
|
33
|
+
/** Whether a prop the panel can set takes a text or a number: the button is shown only then. */
|
|
34
|
+
readonly canApply: boolean;
|
|
35
|
+
/** Whether the values shown are the worst case: the frame then outlines the spills. */
|
|
36
|
+
readonly isOn: boolean;
|
|
37
|
+
/** How many elements spill, as the frame last measured them while the worst case is on; none before. */
|
|
38
|
+
readonly spillCount: number | undefined;
|
|
39
|
+
/** Sets the worst case over the panel's values. */
|
|
40
|
+
readonly onApply: () => void;
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=worstArgs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worstArgs.d.ts","sourceRoot":"","sources":["../../../src/shell/worstArgs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,iEAAiE;AACjE,eAAO,MAAM,cAAc,2LAAgC,CAAC;AAa5D;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,SAAS,SAAS,EAAE,KAAG,SAOrD,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,SAAS,EAAE,QAAQ,SAAS,KAAG,OAGjE,CAAC;AAEF,gDAAgD;AAChD,MAAM,MAAM,cAAc,GAAG;IAC3B,gGAAgG;IAChG,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,uFAAuF;IACvF,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,wGAAwG;IACxG,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,mDAAmD;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The worst case the Props tab sets with one button: every prop that takes a text given a long one with a word too
|
|
3
|
+
* long to break in it, every number given a huge one, from the component's docs.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* The values are the ones `forgebook new` writes in a story's worst case (`worstCase.ts`). The text joins the long text
|
|
7
|
+
* and the unbreakable word, so one value shows both a box that must wrap and one that must cut or scroll. A colour, a
|
|
8
|
+
* date and a prop whose `argTypes` give it a list keep their values: a long text there is not a case, only an invalid
|
|
9
|
+
* value. A number with a highest value takes that value, the largest the story says it accepts.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { isColorProp } from "../argTypes.js";
|
|
14
|
+
import { WORST_NUMBER, WORST_TEXT, WORST_WORD } from "../worstCase.js";
|
|
15
|
+
/** The worst text: a long one, with a word that cannot break. */
|
|
16
|
+
export const WORST_ARG_TEXT = `${WORST_TEXT} ${WORST_WORD}`;
|
|
17
|
+
/** Whether a prop is set as a text: of kind text, or a node that takes one, with no other control named. */
|
|
18
|
+
const isText = (prop) => (prop.kind === "text" || (prop.kind === "other" && prop.canTakeText === true)) &&
|
|
19
|
+
(prop.control === undefined || prop.control === "text") &&
|
|
20
|
+
!isColorProp(prop);
|
|
21
|
+
/** Whether a prop is set as a number, with no other control named. */
|
|
22
|
+
const isNumber = (prop) => prop.kind === "number" &&
|
|
23
|
+
(prop.control === undefined || prop.control === "number" || prop.control === "range");
|
|
24
|
+
/**
|
|
25
|
+
* The worst-case args for the props the panel can set.
|
|
26
|
+
*
|
|
27
|
+
* @param props - the props the panel can set.
|
|
28
|
+
* @returns the args, by prop name; empty when no prop takes a text or a number.
|
|
29
|
+
*/
|
|
30
|
+
export const worstArgs = (props) => Object.fromEntries(props.flatMap((prop) => {
|
|
31
|
+
if (isText(prop))
|
|
32
|
+
return [[prop.name, WORST_ARG_TEXT]];
|
|
33
|
+
if (isNumber(prop))
|
|
34
|
+
return [[prop.name, prop.max ?? WORST_NUMBER]];
|
|
35
|
+
return [];
|
|
36
|
+
}));
|
|
37
|
+
/**
|
|
38
|
+
* Whether the values shown are the worst case: every worst-case arg is set to its worst value.
|
|
39
|
+
*
|
|
40
|
+
* @param worst - the worst-case args.
|
|
41
|
+
* @param values - the values shown.
|
|
42
|
+
*/
|
|
43
|
+
export const isWorstCase = (worst, values) => {
|
|
44
|
+
const entries = Object.entries(worst);
|
|
45
|
+
return entries.length > 0 && entries.every(([name, value]) => values[name] === value);
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=worstArgs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worstArgs.js","sourceRoot":"","sources":["../../../src/shell/worstArgs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,WAAW,EAAkB,MAAM,gBAAgB,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEvE,iEAAiE;AACjE,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,UAAU,IAAI,UAAU,EAAE,CAAC;AAE5D,4GAA4G;AAC5G,MAAM,MAAM,GAAG,CAAC,IAAe,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,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;AACxF,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The elements of a story that spill out of their parent: what overlaps a neighbour or runs off the frame when the
|
|
3
|
+
* story is narrower than it was drawn for.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Runs in the story's page (`page.evaluate`), so it takes no import. An element spills when its box reaches past its
|
|
7
|
+
* parent's box by more than a pixel, sideways, and the parent shows its overflow: a parent that clips or scrolls
|
|
8
|
+
* (`overflow` other than `visible`) and an element taken out of the flow (`absolute`, `fixed`) are left out, as is
|
|
9
|
+
* anything inside a frame-level layer (`data-forgebook-allow-spill`, for a story that shows a spill on purpose). The
|
|
10
|
+
* same finder serves the browser tests (`@forgebook/testing`) and the frame's outline of a worst case, so both find the
|
|
11
|
+
* same spills; the frame passes an attribute to mark the elements with, which a style sheet outlines.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
/** One spill: the element, its parent, and by how many pixels it reaches past. */
|
|
16
|
+
export type Spill = {
|
|
17
|
+
/** The element, as a short CSS path (`div.story-settings`). */
|
|
18
|
+
readonly element: string;
|
|
19
|
+
/** Its parent, the same way. */
|
|
20
|
+
readonly parent: string;
|
|
21
|
+
/** How far it reaches past the parent, in CSS px. */
|
|
22
|
+
readonly by: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The spills inside a root, measured in the page.
|
|
26
|
+
*
|
|
27
|
+
* @param rootSelector - the story's root (`.forgebook-frame`).
|
|
28
|
+
* @param markAttribute - an attribute set on each element that spills, taken off the others first; none marks nothing.
|
|
29
|
+
*/
|
|
30
|
+
export declare const findSpills: (rootSelector: string, markAttribute?: string) => Spill[];
|
|
31
|
+
//# sourceMappingURL=spills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spills.d.ts","sourceRoot":"","sources":["../../src/spills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,kFAAkF;AAClF,MAAM,MAAM,KAAK,GAAG;IAClB,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,gCAAgC;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,cAAc,MAAM,EAAE,gBAAgB,MAAM,KAAG,KAAK,EAqC9E,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The elements of a story that spill out of their parent: what overlaps a neighbour or runs off the frame when the
|
|
3
|
+
* story is narrower than it was drawn for.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Runs in the story's page (`page.evaluate`), so it takes no import. An element spills when its box reaches past its
|
|
7
|
+
* parent's box by more than a pixel, sideways, and the parent shows its overflow: a parent that clips or scrolls
|
|
8
|
+
* (`overflow` other than `visible`) and an element taken out of the flow (`absolute`, `fixed`) are left out, as is
|
|
9
|
+
* anything inside a frame-level layer (`data-forgebook-allow-spill`, for a story that shows a spill on purpose). The
|
|
10
|
+
* same finder serves the browser tests (`@forgebook/testing`) and the frame's outline of a worst case, so both find the
|
|
11
|
+
* same spills; the frame passes an attribute to mark the elements with, which a style sheet outlines.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* The spills inside a root, measured in the page.
|
|
17
|
+
*
|
|
18
|
+
* @param rootSelector - the story's root (`.forgebook-frame`).
|
|
19
|
+
* @param markAttribute - an attribute set on each element that spills, taken off the others first; none marks nothing.
|
|
20
|
+
*/
|
|
21
|
+
export const findSpills = (rootSelector, markAttribute) => {
|
|
22
|
+
const pathOf = (element) => {
|
|
23
|
+
const classes = [...element.classList].slice(0, 2).join(".");
|
|
24
|
+
return classes === "" ? element.tagName.toLowerCase() : `${element.tagName.toLowerCase()}.${classes}`;
|
|
25
|
+
};
|
|
26
|
+
// an element out of the flow, a parent that clips or scrolls, and an allowed spill are not measured
|
|
27
|
+
const isMeasured = (element, parent) => {
|
|
28
|
+
if (element.closest("[data-forgebook-allow-spill]") !== null)
|
|
29
|
+
return false;
|
|
30
|
+
const style = getComputedStyle(element);
|
|
31
|
+
const parentStyle = getComputedStyle(parent);
|
|
32
|
+
return (style.position !== "absolute" &&
|
|
33
|
+
style.position !== "fixed" &&
|
|
34
|
+
style.display !== "contents" &&
|
|
35
|
+
parentStyle.display !== "contents" &&
|
|
36
|
+
parentStyle.overflowX === "visible");
|
|
37
|
+
};
|
|
38
|
+
const overreach = (element, parent) => {
|
|
39
|
+
const box = element.getBoundingClientRect();
|
|
40
|
+
const parentBox = parent.getBoundingClientRect();
|
|
41
|
+
if (box.width === 0 || box.height === 0)
|
|
42
|
+
return 0;
|
|
43
|
+
return Math.max(box.right - parentBox.right, parentBox.left - box.left);
|
|
44
|
+
};
|
|
45
|
+
const root = document.querySelector(rootSelector);
|
|
46
|
+
if (root === null)
|
|
47
|
+
return [];
|
|
48
|
+
const elements = [...root.querySelectorAll("*")];
|
|
49
|
+
// the marks of the last measure come off first, so an element that no longer spills loses its outline
|
|
50
|
+
if (markAttribute !== undefined)
|
|
51
|
+
for (const element of elements)
|
|
52
|
+
element.removeAttribute(markAttribute);
|
|
53
|
+
return elements.flatMap((element) => {
|
|
54
|
+
const parent = element.parentElement;
|
|
55
|
+
if (parent === null || !isMeasured(element, parent))
|
|
56
|
+
return [];
|
|
57
|
+
const by = overreach(element, parent);
|
|
58
|
+
if (by <= 1)
|
|
59
|
+
return [];
|
|
60
|
+
if (markAttribute !== undefined)
|
|
61
|
+
element.setAttribute(markAttribute, "");
|
|
62
|
+
return [{ element: pathOf(element), parent: pathOf(parent), by: Math.round(by) }];
|
|
63
|
+
});
|
|
64
|
+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AK,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACpF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes of a story check and of a story's pictures, shared by `forgebook check` and `forgebook shot` (which ask)
|
|
3
|
+
* and `@forgebook/testing/check` and `/shot` (which run them in a browser): the stories and views, and the problems
|
|
4
|
+
* found in each or the pictures taken.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* The command builds the request from the catalogue it runs against, loads the testing package from the project only
|
|
8
|
+
* when it runs (the core has no browser), and reads the report back through `isStoryCheckReport`, since it crossed a
|
|
9
|
+
* dynamic import. The problems are those the catalogue's browser tests fail on, with the same messages: a frame that
|
|
10
|
+
* could not show its story, axe's rules, spills, overlays past the frame, and the page's errors (a failed play among
|
|
11
|
+
* them: its rejection reaches the page). Pure.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import type { CatalogueLists } from "./catalogue.ts";
|
|
16
|
+
import type { ViewSwitch } from "./switches.ts";
|
|
17
|
+
/** What kind of check found a problem. */
|
|
18
|
+
export type StoryProblemKind = "frame" | "axe" | "spill" | "overlay" | "error";
|
|
19
|
+
/** One problem a check found. */
|
|
20
|
+
export type StoryProblem = {
|
|
21
|
+
/** The check that found it. */
|
|
22
|
+
readonly kind: StoryProblemKind;
|
|
23
|
+
/** The rule broken, for axe (`color-contrast`). */
|
|
24
|
+
readonly rule?: string;
|
|
25
|
+
/** The element at fault, as a selector, when the check names one. */
|
|
26
|
+
readonly element?: string;
|
|
27
|
+
/** What is wrong, as the catalogue's tests say it. */
|
|
28
|
+
readonly message: string;
|
|
29
|
+
};
|
|
30
|
+
/** A story to check: its id, and the height its scene declares. */
|
|
31
|
+
export type StoryCheckStory = {
|
|
32
|
+
/** The story's id. */
|
|
33
|
+
readonly id: string;
|
|
34
|
+
/** Its `parameters.height`, in CSS px, when it declares one: an overlay inside it is not a problem. */
|
|
35
|
+
readonly height?: number;
|
|
36
|
+
};
|
|
37
|
+
/** What a check is asked to do. */
|
|
38
|
+
export type StoryCheckRequest = {
|
|
39
|
+
/** The frame page's absolute address (`http://localhost:5173/frame.html`). */
|
|
40
|
+
readonly frameUrl: string;
|
|
41
|
+
/** The stories. */
|
|
42
|
+
readonly stories: readonly StoryCheckStory[];
|
|
43
|
+
/** The catalogue's switches, as its configuration gives them. */
|
|
44
|
+
readonly switches: readonly ViewSwitch[];
|
|
45
|
+
/** The catalogue's lists: its accessibility rules, backgrounds, text sizes. */
|
|
46
|
+
readonly lists: CatalogueLists;
|
|
47
|
+
/** The views, each in the address's form (`theme=dark&lang=it`); none for the default view alone. */
|
|
48
|
+
readonly views: readonly string[];
|
|
49
|
+
/** Check every variant the catalogue's browser tests check instead of the views given. */
|
|
50
|
+
readonly isAllVariants: boolean;
|
|
51
|
+
};
|
|
52
|
+
/** One story in one view, and its problems. */
|
|
53
|
+
export type StoryCheckResult = {
|
|
54
|
+
/** The story's id. */
|
|
55
|
+
readonly storyId: string;
|
|
56
|
+
/** The view, as asked (`theme=dark`), or the variant's name; empty for the default view. */
|
|
57
|
+
readonly view: string;
|
|
58
|
+
/** Where it was opened: its frame in that view. */
|
|
59
|
+
readonly frame: string;
|
|
60
|
+
/** The problems; none when it passes. */
|
|
61
|
+
readonly problems: readonly StoryProblem[];
|
|
62
|
+
};
|
|
63
|
+
/** What a check found. */
|
|
64
|
+
export type StoryCheckReport = {
|
|
65
|
+
/** The shape's version. */
|
|
66
|
+
readonly schema: 1;
|
|
67
|
+
/** One result per story and view. */
|
|
68
|
+
readonly results: readonly StoryCheckResult[];
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Whether what the testing package answered is a check's report.
|
|
72
|
+
*
|
|
73
|
+
* @param value - the answer.
|
|
74
|
+
*/
|
|
75
|
+
export declare const isStoryCheckReport: (value: unknown) => value is StoryCheckReport;
|
|
76
|
+
/** What a picture run is asked to do: a check's stories and views, and where the pictures go. */
|
|
77
|
+
export type StoryShotRequest = StoryCheckRequest & {
|
|
78
|
+
/** The folder the pictures are written in, absolute; made when missing. */
|
|
79
|
+
readonly outDir: string;
|
|
80
|
+
};
|
|
81
|
+
/** One story's picture in one view. */
|
|
82
|
+
export type StoryShot = {
|
|
83
|
+
/** The story's id. */
|
|
84
|
+
readonly storyId: string;
|
|
85
|
+
/** The view, as asked, or the variant's name; empty for the default view. */
|
|
86
|
+
readonly view: string;
|
|
87
|
+
/** Where it was opened. */
|
|
88
|
+
readonly frame: string;
|
|
89
|
+
/** The picture, a PNG file's absolute path. */
|
|
90
|
+
readonly file: string;
|
|
91
|
+
};
|
|
92
|
+
/** The pictures taken. */
|
|
93
|
+
export type StoryShotReport = {
|
|
94
|
+
/** The shape's version. */
|
|
95
|
+
readonly schema: 1;
|
|
96
|
+
/** One picture per story and view. */
|
|
97
|
+
readonly shots: readonly StoryShot[];
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Whether what the testing package answered is a picture run's report.
|
|
101
|
+
*
|
|
102
|
+
* @param value - the answer.
|
|
103
|
+
*/
|
|
104
|
+
export declare const isStoryShotReport: (value: unknown) => value is StoryShotReport;
|
|
105
|
+
//# sourceMappingURL=storyCheck.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storyCheck.d.ts","sourceRoot":"","sources":["../../src/storyCheck.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,0CAA0C;AAC1C,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;AAE/E,iCAAiC;AACjC,MAAM,MAAM,YAAY,GAAG;IACzB,+BAA+B;IAC/B,QAAQ,CAAC,IAAI,EA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AQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACnB,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,SAAS,gBAAgB,EAAE,CAAC;CAC/C,CAAC;AAoCF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,gBAO9B,CAAC;AAEhC,iGAAiG;AACjG,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,GAAG;IACjD,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,uCAAuC;AACvC,MAAM,MAAM,SAAS,GAAG;IACtB,sBAAsB;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2BAA2B;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,0BAA0B;AAC1B,MAAM,MAAM,eAAe,GAAG;IAC5B,2BAA2B;IAC3B,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACnB,sCAAsC;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;CACtC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,eAmBzD,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** Every kind, for reading a report back. */
|
|
2
|
+
const KINDS = ["frame", "axe", "spill", "overlay", "error"];
|
|
3
|
+
/**
|
|
4
|
+
* Whether a value is a problem.
|
|
5
|
+
*
|
|
6
|
+
* @param value - the value.
|
|
7
|
+
*/
|
|
8
|
+
const isProblem = (value) => typeof value === "object" &&
|
|
9
|
+
value !== null &&
|
|
10
|
+
"kind" in value &&
|
|
11
|
+
KINDS.some((kind) => kind === value.kind) &&
|
|
12
|
+
"message" in value &&
|
|
13
|
+
typeof value.message === "string";
|
|
14
|
+
/**
|
|
15
|
+
* Whether a value is a result.
|
|
16
|
+
*
|
|
17
|
+
* @param value - the value.
|
|
18
|
+
*/
|
|
19
|
+
const isResult = (value) => typeof value === "object" &&
|
|
20
|
+
value !== null &&
|
|
21
|
+
"storyId" in value &&
|
|
22
|
+
typeof value.storyId === "string" &&
|
|
23
|
+
"view" in value &&
|
|
24
|
+
typeof value.view === "string" &&
|
|
25
|
+
"frame" in value &&
|
|
26
|
+
typeof value.frame === "string" &&
|
|
27
|
+
"problems" in value &&
|
|
28
|
+
Array.isArray(value.problems) &&
|
|
29
|
+
value.problems.every(isProblem);
|
|
30
|
+
/**
|
|
31
|
+
* Whether what the testing package answered is a check's report.
|
|
32
|
+
*
|
|
33
|
+
* @param value - the answer.
|
|
34
|
+
*/
|
|
35
|
+
export const isStoryCheckReport = (value) => typeof value === "object" &&
|
|
36
|
+
value !== null &&
|
|
37
|
+
"schema" in value &&
|
|
38
|
+
value.schema === 1 &&
|
|
39
|
+
"results" in value &&
|
|
40
|
+
Array.isArray(value.results) &&
|
|
41
|
+
value.results.every(isResult);
|
|
42
|
+
/**
|
|
43
|
+
* Whether what the testing package answered is a picture run's report.
|
|
44
|
+
*
|
|
45
|
+
* @param value - the answer.
|
|
46
|
+
*/
|
|
47
|
+
export const isStoryShotReport = (value) => typeof value === "object" &&
|
|
48
|
+
value !== null &&
|
|
49
|
+
"schema" in value &&
|
|
50
|
+
value.schema === 1 &&
|
|
51
|
+
"shots" in value &&
|
|
52
|
+
Array.isArray(value.shots) &&
|
|
53
|
+
value.shots.every((shot) => typeof shot === "object" &&
|
|
54
|
+
shot !== null &&
|
|
55
|
+
"storyId" in shot &&
|
|
56
|
+
typeof shot.storyId === "string" &&
|
|
57
|
+
"view" in shot &&
|
|
58
|
+
typeof shot.view === "string" &&
|
|
59
|
+
"frame" in shot &&
|
|
60
|
+
typeof shot.frame === "string" &&
|
|
61
|
+
"file" in shot &&
|
|
62
|
+
typeof shot.file === "string");
|
|
63
|
+
//# sourceMappingURL=storyCheck.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storyCheck.js","sourceRoot":"","sources":["../../src/storyCheck.ts"],"names":[],"mappings":"AA4EA,6CAA6C;AAC7C,MAAM,KAAK,GAAgC,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAEzF;;;;GAIG;AACH,MAAM,SAAS,GAAG,CAAC,KAAc,EAAyB,EAAE,CAC1D,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACd,MAAM,IAAI,KAAK;IACf,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC;IACzC,SAAS,IAAI,KAAK;IAClB,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC;AAEpC;;;;GAIG;AACH,MAAM,QAAQ,GAAG,CAAC,KAAc,EAA6B,EAAE,CAC7D,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACd,SAAS,IAAI,KAAK;IAClB,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;IACjC,MAAM,IAAI,KAAK;IACf,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;IAC9B,OAAO,IAAI,KAAK;IAChB,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;IAC/B,UAAU,IAAI,KAAK;IACnB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAElC;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAA6B,EAAE,CAC9E,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACd,QAAQ,IAAI,KAAK;IACjB,KAAK,CAAC,MAAM,KAAK,CAAC;IAClB,SAAS,IAAI,KAAK;IAClB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;IAC5B,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AA4BhC;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAA4B,EAAE,CAC5E,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACd,QAAQ,IAAI,KAAK;IACjB,KAAK,CAAC,MAAM,KAAK,CAAC;IAClB,OAAO,IAAI,KAAK;IAChB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;IAC1B,KAAK,CAAC,KAAK,CAAC,KAAK,CACf,CAAC,IAAa,EAAE,EAAE,CAChB,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,SAAS,IAAI,IAAI;QACjB,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ;QAChC,MAAM,IAAI,IAAI;QACd,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;QAC7B,OAAO,IAAI,IAAI;QACf,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ;QAC9B,MAAM,IAAI,IAAI;QACd,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAChC,CAAC"}
|
package/dist/src/switches.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export type SwitchValue = {
|
|
|
24
24
|
readonly scheme?: "light" | "dark" | "system";
|
|
25
25
|
/** For a `contrast` switch: whether the value is the higher contrast. */
|
|
26
26
|
readonly isMore?: boolean;
|
|
27
|
+
/** For a `language` switch: whether the language reads right to left, which draws the story right to left. */
|
|
28
|
+
readonly isRightToLeft?: boolean;
|
|
27
29
|
};
|
|
28
30
|
/** Where a switch applies. */
|
|
29
31
|
export type SwitchApply =
|
|
@@ -53,9 +55,9 @@ export type SwitchApply =
|
|
|
53
55
|
/**
|
|
54
56
|
* What the catalogue itself reads of a switch: the colour scheme (the loading boxes' and backgrounds' colours, the
|
|
55
57
|
* tests' themes), the contrast (the source's more-contrast colours, the tests' variants), the language (the stories'
|
|
56
|
-
* texts and the language's provider).
|
|
58
|
+
* texts and the language's provider), the direction (a catalogue's own switch in place of the ready-made one).
|
|
57
59
|
*/
|
|
58
|
-
export type SwitchRole = "colorScheme" | "contrast" | "language";
|
|
60
|
+
export type SwitchRole = "colorScheme" | "contrast" | "language" | "direction" | "touch";
|
|
59
61
|
/** A switch of the toolbar or the View menu. */
|
|
60
62
|
export type ViewSwitch = {
|
|
61
63
|
/** A stable id, the address's parameter (`theme`). */
|
|
@@ -72,6 +74,8 @@ export type ViewSwitch = {
|
|
|
72
74
|
readonly role?: SwitchRole;
|
|
73
75
|
/** How the View menu offers it: a row of segments (by default, up to six values) or a list. */
|
|
74
76
|
readonly control?: "segments" | "list";
|
|
77
|
+
/** What a reader should know of it, in a sentence or two: under its row in the View menu and in its tooltip. */
|
|
78
|
+
readonly description?: string;
|
|
75
79
|
};
|
|
76
80
|
/**
|
|
77
81
|
* Why a list of switches cannot be used, or none: ids unique and not the address's own, a default among the values,
|
|
@@ -97,7 +101,22 @@ export declare const LANGUAGE_SWITCH_ID = "lang";
|
|
|
97
101
|
export declare const languageSwitch: (languages: readonly {
|
|
98
102
|
readonly id: string;
|
|
99
103
|
readonly label: string;
|
|
104
|
+
readonly dir?: "rtl";
|
|
100
105
|
}[]) => ViewSwitch;
|
|
106
|
+
/**
|
|
107
|
+
* The direction the stories are drawn in: left to right (the root's own, no attribute) or right to left, as `dir` on
|
|
108
|
+
* the frame's root, so a library sees every component mirrored as a right-to-left page shows it.
|
|
109
|
+
*/
|
|
110
|
+
export declare const directionSwitch: () => ViewSwitch;
|
|
111
|
+
/**
|
|
112
|
+
* How the stories are touched: with the mouse (no attribute), or as a finger, simulated in the frame
|
|
113
|
+
* (`data-forgebook-touch` on its root: the frame's touch layer and the catalogue's CSS rewrite read it). A simulation:
|
|
114
|
+
* events made by a page are not trusted, so native scrolling, focus, a virtual keyboard and real Safari stay a
|
|
115
|
+
* device's, or `forgebook dev --touch`'s.
|
|
116
|
+
*/
|
|
117
|
+
export declare const touchSwitch: () => ViewSwitch;
|
|
118
|
+
/** The ready-made switches a catalogue may turn off (`controls: { direction: false }`). */
|
|
119
|
+
export type ReadySwitchesOff = Readonly<Partial<Record<"direction" | "touch", false>>>;
|
|
101
120
|
/**
|
|
102
121
|
* The switch with a role, among a catalogue's.
|
|
103
122
|
*
|
|
@@ -120,16 +139,19 @@ export declare const switchValueOf: (each: ViewSwitch, value: string | undefined
|
|
|
120
139
|
export declare const switchControl: (each: ViewSwitch) => "segments" | "list";
|
|
121
140
|
/**
|
|
122
141
|
* A catalogue's switches: the ones it declares (the theme and the contrast when it declares none), then, when it or a
|
|
123
|
-
* source offers languages, the language switch over all of them
|
|
142
|
+
* source offers languages, the language switch over all of them, then the ready-made direction and touch switches,
|
|
143
|
+
* each unless the catalogue declares its own (the `direction` or `touch` role) or turned it off.
|
|
124
144
|
*
|
|
125
145
|
* @param declared - the switches the catalogue declares; none for the default ones.
|
|
126
146
|
* @param languages - every language the catalogue and its sources offer, by id and name; the first of an id wins.
|
|
147
|
+
* @param turnedOff - the ready-made switches the catalogue turned off (its `controls`); none by default.
|
|
127
148
|
* @throws when the switches cannot be used (`switchesProblem`): a catalogue's configuration error, shown at once.
|
|
128
149
|
*/
|
|
129
150
|
export declare const catalogueSwitches: (declared: readonly ViewSwitch[] | undefined, languages: readonly {
|
|
130
151
|
readonly id: string;
|
|
131
152
|
readonly label: string;
|
|
132
|
-
|
|
153
|
+
readonly dir?: "rtl";
|
|
154
|
+
}[], turnedOff?: ReadySwitchesOff) => readonly ViewSwitch[];
|
|
133
155
|
/** What a switch made from a `globalType` may take besides it: where it applies, what the catalogue reads of it. */
|
|
134
156
|
export type GlobalTypeSwitchOverride = Partial<Pick<ViewSwitch, "label" | "apply" | "role" | "control">>;
|
|
135
157
|
/** How `switchesFromGlobalTypes` reads Storybook's preview. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switches.d.ts","sourceRoot":"","sources":["../../src/switches.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,iCAAiC;AACjC,MAAM,MAAM,WAAW,GAAG;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,2GAA2G;IAC3G,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,8FAA8F;IAC9F,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;IAC9C,yEAAyE;IACzE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"switches.d.ts","sourceRoot":"","sources":["../../src/switches.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,iCAAiC;AACjC,MAAM,MAAM,WAAW,GAAG;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,2GAA2G;IAC3G,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,8FAA8F;IAC9F,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;IAC9C,yEAAyE;IACzE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,8GAA8G;IAC9G,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAEF,8BAA8B;AAC9B,MAAM,MAAM,WAAW;AACrB,uDAAuD;AACrD;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,IAA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AK,CAAA;CAAE,EAAE,EAC3F,YAAW,gBAAqB,KAC/B,SAAS,UAAU,EAgBrB,CAAC;AAEF,oHAAoH;AACpH,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAEzG,+DAA+D;AAC/D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,qGAAqG;IACrG,QAAQ,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5D;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC,CAAC;CACzE,CAAC;AAuBF;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,GAClC,aAAa,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAC9C,UAAS,kBAAuB,KAC/B,UAAU,EAmBT,CAAC"}
|
package/dist/src/switches.js
CHANGED
|
@@ -99,7 +99,46 @@ export const languageSwitch = (languages) => ({
|
|
|
99
99
|
default: "",
|
|
100
100
|
values: [
|
|
101
101
|
{ value: "", label: "Stories' own", isUnset: true },
|
|
102
|
-
...languages.map((language) => ({
|
|
102
|
+
...languages.map((language) => ({
|
|
103
|
+
value: language.id,
|
|
104
|
+
label: language.label,
|
|
105
|
+
...(language.dir === "rtl" ? { isRightToLeft: true } : {})
|
|
106
|
+
}))
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
/**
|
|
110
|
+
* The direction the stories are drawn in: left to right (the root's own, no attribute) or right to left, as `dir` on
|
|
111
|
+
* the frame's root, so a library sees every component mirrored as a right-to-left page shows it.
|
|
112
|
+
*/
|
|
113
|
+
export const directionSwitch = () => ({
|
|
114
|
+
id: "dir",
|
|
115
|
+
label: "Direction",
|
|
116
|
+
role: "direction",
|
|
117
|
+
apply: { kind: "attribute", name: "dir" },
|
|
118
|
+
default: "ltr",
|
|
119
|
+
values: [
|
|
120
|
+
{ value: "ltr", label: "Left to right", isUnset: true },
|
|
121
|
+
{ value: "rtl", label: "Right to left" }
|
|
122
|
+
]
|
|
123
|
+
});
|
|
124
|
+
/**
|
|
125
|
+
* How the stories are touched: with the mouse (no attribute), or as a finger, simulated in the frame
|
|
126
|
+
* (`data-forgebook-touch` on its root: the frame's touch layer and the catalogue's CSS rewrite read it). A simulation:
|
|
127
|
+
* events made by a page are not trusted, so native scrolling, focus, a virtual keyboard and real Safari stay a
|
|
128
|
+
* device's, or `forgebook dev --touch`'s.
|
|
129
|
+
*/
|
|
130
|
+
export const touchSwitch = () => ({
|
|
131
|
+
id: "touch",
|
|
132
|
+
label: "Touch",
|
|
133
|
+
role: "touch",
|
|
134
|
+
description: "Simulated: the story receives a finger's events and a phone's hover and pointer media, Shift for two fingers. " +
|
|
135
|
+
"Native scrolling, focus from a touch, the virtual keyboard and real Safari still need a device, or " +
|
|
136
|
+
"forgebook dev --touch for Chromium's real touch.",
|
|
137
|
+
apply: { kind: "attribute", name: "data-forgebook-touch" },
|
|
138
|
+
default: "mouse",
|
|
139
|
+
values: [
|
|
140
|
+
{ value: "mouse", label: "Mouse", isUnset: true },
|
|
141
|
+
{ value: "touch", label: "Touch" }
|
|
103
142
|
]
|
|
104
143
|
});
|
|
105
144
|
/**
|
|
@@ -124,17 +163,23 @@ export const switchValueOf = (each, value) => each.values.find((candidate) => ca
|
|
|
124
163
|
export const switchControl = (each) => each.control ?? (each.values.length <= 6 ? "segments" : "list");
|
|
125
164
|
/**
|
|
126
165
|
* A catalogue's switches: the ones it declares (the theme and the contrast when it declares none), then, when it or a
|
|
127
|
-
* source offers languages, the language switch over all of them
|
|
166
|
+
* source offers languages, the language switch over all of them, then the ready-made direction and touch switches,
|
|
167
|
+
* each unless the catalogue declares its own (the `direction` or `touch` role) or turned it off.
|
|
128
168
|
*
|
|
129
169
|
* @param declared - the switches the catalogue declares; none for the default ones.
|
|
130
170
|
* @param languages - every language the catalogue and its sources offer, by id and name; the first of an id wins.
|
|
171
|
+
* @param turnedOff - the ready-made switches the catalogue turned off (its `controls`); none by default.
|
|
131
172
|
* @throws when the switches cannot be used (`switchesProblem`): a catalogue's configuration error, shown at once.
|
|
132
173
|
*/
|
|
133
|
-
export const catalogueSwitches = (declared, languages) => {
|
|
174
|
+
export const catalogueSwitches = (declared, languages, turnedOff = {}) => {
|
|
134
175
|
const unique = languages.filter((language, index) => languages.findIndex((other) => other.id === language.id) === index);
|
|
176
|
+
const own = declared ?? DEFAULT_SWITCHES;
|
|
177
|
+
const isOffered = (role) => turnedOff[role] !== false && switchWithRole(own, role) === undefined;
|
|
135
178
|
const switches = [
|
|
136
|
-
...
|
|
137
|
-
...(unique.length > 0 ? [languageSwitch(unique)] : [])
|
|
179
|
+
...own,
|
|
180
|
+
...(unique.length > 0 ? [languageSwitch(unique)] : []),
|
|
181
|
+
...(isOffered("direction") ? [directionSwitch()] : []),
|
|
182
|
+
...(isOffered("touch") ? [touchSwitch()] : [])
|
|
138
183
|
];
|
|
139
184
|
const problem = switchesProblem(switches);
|
|
140
185
|
if (problem !== undefined)
|