forgebook 0.3.3 → 0.4.1
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 +994 -72
- package/dist/bin/forgebook/agentClient.d.ts +2 -1
- package/dist/bin/forgebook/agentClient.js +13 -6
- package/dist/bin/forgebook/agentGuide.d.ts +59 -0
- package/dist/bin/forgebook/agentGuide.js +203 -0
- package/dist/bin/forgebook/agentLoopCommands.mjs +22 -42
- package/dist/bin/forgebook/agentSetup/agentFiles.d.ts +55 -0
- package/dist/bin/forgebook/agentSetup/agentFiles.js +319 -0
- package/dist/bin/forgebook/agentSetup/assistantHooks.d.ts +71 -0
- package/dist/bin/forgebook/agentSetup/assistantHooks.js +125 -0
- package/dist/bin/forgebook/agentSetup/ciWorkflow.d.ts +23 -0
- package/dist/bin/forgebook/agentSetup/ciWorkflow.js +55 -0
- package/dist/bin/forgebook/agentSetup/drawCandidates.d.ts +25 -0
- package/dist/bin/forgebook/agentSetup/drawCandidates.js +116 -0
- package/dist/bin/forgebook/agentSetup/drawDiagnosis.d.ts +28 -0
- package/dist/bin/forgebook/agentSetup/drawDiagnosis.js +134 -0
- package/dist/bin/forgebook/agentSetup/drawRun.d.ts +91 -0
- package/dist/bin/forgebook/agentSetup/drawRun.js +353 -0
- package/dist/bin/forgebook/agentSetup/hookNames.d.ts +7 -0
- package/dist/bin/forgebook/agentSetup/hookNames.js +7 -0
- package/dist/bin/forgebook/agentSetup/initAgentSteps.d.ts +48 -0
- package/dist/bin/forgebook/agentSetup/initAgentSteps.js +104 -0
- package/dist/bin/forgebook/agentSetup/liftedProviders.d.ts +17 -0
- package/dist/bin/forgebook/agentSetup/liftedProviders.js +186 -0
- package/dist/bin/forgebook/agentSetup/projectRunner.d.ts +46 -0
- package/dist/bin/forgebook/agentSetup/projectRunner.js +85 -0
- package/dist/bin/forgebook/agentSetup/stopHook.d.ts +65 -0
- package/dist/bin/forgebook/agentSetup/stopHook.js +202 -0
- package/dist/bin/forgebook/agentSetup/uniformPicture.d.ts +7 -0
- package/dist/bin/forgebook/agentSetup/uniformPicture.js +98 -0
- package/dist/bin/forgebook/agentSetupCommands.d.mts +14 -0
- package/dist/bin/forgebook/agentSetupCommands.mjs +98 -0
- package/dist/bin/forgebook/agentText.d.ts +23 -3
- package/dist/bin/forgebook/agentText.js +182 -28
- package/dist/bin/forgebook/agents.md +20 -191
- package/dist/bin/forgebook/agentsText.js +2 -1
- package/dist/bin/forgebook/appBuild/appBuild.d.ts +59 -0
- package/dist/bin/forgebook/appBuild/appBuild.js +213 -0
- package/dist/bin/forgebook/appBuild/appViteConfig.d.ts +96 -0
- package/dist/bin/forgebook/appBuild/appViteConfig.js +320 -0
- package/dist/bin/forgebook/appBuild/tsconfigPaths.d.ts +14 -0
- package/dist/bin/forgebook/appBuild/tsconfigPaths.js +80 -0
- package/dist/bin/forgebook/auditCommand.d.mts +8 -0
- package/dist/bin/forgebook/auditCommand.mjs +75 -0
- package/dist/bin/forgebook/auditRun.d.ts +95 -0
- package/dist/bin/forgebook/auditRun.js +270 -0
- package/dist/bin/forgebook/browserRun.d.ts +21 -0
- package/dist/bin/forgebook/browserRun.js +57 -0
- package/dist/bin/forgebook/buildFailure.d.ts +7 -0
- package/dist/bin/forgebook/buildFailure.js +47 -0
- package/dist/bin/forgebook/buildWatch.d.ts +52 -0
- package/dist/bin/forgebook/buildWatch.js +137 -0
- package/dist/bin/forgebook/builtCatalogue.js +9 -5
- package/dist/bin/forgebook/catalogueCommands.d.ts +9 -0
- package/dist/bin/forgebook/catalogueCommands.js +23 -0
- package/dist/bin/forgebook/catalogueVite.d.ts +5 -1
- package/dist/bin/forgebook/catalogueVite.js +14 -6
- package/dist/bin/forgebook/commandCacheClaim.d.ts +18 -0
- package/dist/bin/forgebook/commandCacheClaim.js +170 -0
- package/dist/bin/forgebook/commandServer.d.ts +8 -0
- package/dist/bin/forgebook/commandServer.js +61 -13
- package/dist/bin/forgebook/forgebookCommands.mjs +105 -28
- package/dist/bin/forgebook/graphCommand.d.mts +8 -0
- package/dist/bin/forgebook/graphCommand.mjs +84 -0
- package/dist/bin/forgebook/guide/commands.md +62 -0
- package/dist/bin/forgebook/guide/devices.md +17 -0
- package/dist/bin/forgebook/guide/docs-pages.md +13 -0
- package/dist/bin/forgebook/guide/frameworks/angular.md +22 -0
- package/dist/bin/forgebook/guide/frameworks/html.md +22 -0
- package/dist/bin/forgebook/guide/frameworks/nextjs.md +23 -0
- package/dist/bin/forgebook/guide/frameworks/nuxt.md +22 -0
- package/dist/bin/forgebook/guide/frameworks/preact.md +16 -0
- package/dist/bin/forgebook/guide/frameworks/react-native-web.md +21 -0
- package/dist/bin/forgebook/guide/frameworks/react.md +16 -0
- package/dist/bin/forgebook/guide/frameworks/solid.md +18 -0
- package/dist/bin/forgebook/guide/frameworks/svelte.md +18 -0
- package/dist/bin/forgebook/guide/frameworks/sveltekit.md +23 -0
- package/dist/bin/forgebook/guide/frameworks/vue.md +18 -0
- package/dist/bin/forgebook/guide/frameworks/web-components.md +21 -0
- package/dist/bin/forgebook/guide/links.md +29 -0
- package/dist/bin/forgebook/guide/setup.md +23 -0
- package/dist/bin/forgebook/guide/stories.md +95 -0
- package/dist/bin/forgebook/guide/switches.md +43 -0
- package/dist/bin/forgebook/guideCommand.d.mts +13 -0
- package/dist/bin/forgebook/guideCommand.mjs +37 -0
- package/dist/bin/forgebook/importers/storybook.d.ts +21 -0
- package/dist/bin/forgebook/importers/storybook.js +11 -5
- package/dist/bin/forgebook/importers/storybookFrameworks.js +1 -1
- package/dist/bin/forgebook/initCommands.d.mts +11 -0
- package/dist/bin/forgebook/initCommands.mjs +51 -78
- package/dist/bin/forgebook/initConfig.d.ts +5 -3
- package/dist/bin/forgebook/initConfig.js +6 -3
- package/dist/bin/forgebook/initInstall.d.ts +15 -0
- package/dist/bin/forgebook/initInstall.js +77 -0
- package/dist/bin/forgebook/initPrint.d.ts +9 -0
- package/dist/bin/forgebook/initPrint.js +60 -0
- package/dist/bin/forgebook/initRefusals.d.ts +45 -0
- package/dist/bin/forgebook/initRefusals.js +91 -0
- package/dist/bin/forgebook/initRun.d.ts +28 -0
- package/dist/bin/forgebook/initRun.js +311 -0
- package/dist/bin/forgebook/mcpCommand.mjs +38 -4
- package/dist/bin/forgebook/mcpGraph.d.ts +13 -0
- package/dist/bin/forgebook/mcpGraph.js +24 -0
- package/dist/bin/forgebook/mcpTokens.d.ts +14 -0
- package/dist/bin/forgebook/mcpTokens.js +58 -0
- package/dist/bin/forgebook/mcpToolParts.d.ts +7 -0
- package/dist/bin/forgebook/mcpToolParts.js +10 -0
- package/dist/bin/forgebook/mcpTools.d.ts +13 -6
- package/dist/bin/forgebook/mcpTools.js +57 -90
- package/dist/bin/forgebook/mcpVerify.d.ts +16 -0
- package/dist/bin/forgebook/mcpVerify.js +36 -0
- package/dist/bin/forgebook/migrate/codemods.d.ts +11 -0
- package/dist/bin/forgebook/migrate/codemods.js +61 -0
- package/dist/bin/forgebook/migrate/migrate.types.d.ts +117 -0
- package/dist/bin/forgebook/migrate/migrate.types.js +5 -0
- package/dist/bin/forgebook/migrate/migrateCommand.d.mts +8 -0
- package/dist/bin/forgebook/migrate/migrateCommand.mjs +76 -0
- package/dist/bin/forgebook/migrate/migrateRun.d.ts +61 -0
- package/dist/bin/forgebook/migrate/migrateRun.js +210 -0
- package/dist/bin/forgebook/migrate/migrateText.d.ts +12 -0
- package/dist/bin/forgebook/migrate/migrateText.js +30 -0
- package/dist/bin/forgebook/migrate/migrateWrite.d.ts +27 -0
- package/dist/bin/forgebook/migrate/migrateWrite.js +66 -0
- package/dist/bin/forgebook/migrate/objectEdits.d.ts +70 -0
- package/dist/bin/forgebook/migrate/objectEdits.js +241 -0
- package/dist/bin/forgebook/migrate/playOnInBuilds.d.ts +3 -0
- package/dist/bin/forgebook/migrate/playOnInBuilds.js +86 -0
- package/dist/bin/forgebook/migrate/propGroupStrings.d.ts +5 -0
- package/dist/bin/forgebook/migrate/propGroupStrings.js +81 -0
- package/dist/bin/forgebook/newProject/newProject.d.ts +39 -0
- package/dist/bin/forgebook/newProject/newProject.js +180 -0
- package/dist/bin/forgebook/newProject/newProject.types.d.ts +97 -0
- package/dist/bin/forgebook/newProject/newProject.types.js +6 -0
- package/dist/bin/forgebook/newProject/packageManagers.d.ts +51 -0
- package/dist/bin/forgebook/newProject/packageManagers.js +121 -0
- package/dist/bin/forgebook/newProject/projectEntries.d.ts +62 -0
- package/dist/bin/forgebook/newProject/projectEntries.js +191 -0
- package/dist/bin/forgebook/newProject/projectFrameworks.d.ts +57 -0
- package/dist/bin/forgebook/newProject/projectFrameworks.js +148 -0
- package/dist/bin/forgebook/newProject/projectLook.d.ts +23 -0
- package/dist/bin/forgebook/newProject/projectLook.js +293 -0
- package/dist/bin/forgebook/newProject/projectPackages.d.ts +66 -0
- package/dist/bin/forgebook/newProject/projectPackages.js +178 -0
- package/dist/bin/forgebook/newRepair.d.ts +45 -0
- package/dist/bin/forgebook/newRepair.js +157 -0
- package/dist/bin/forgebook/newRepairRun.d.ts +69 -0
- package/dist/bin/forgebook/newRepairRun.js +148 -0
- package/dist/bin/forgebook/newStories.d.ts +23 -1
- package/dist/bin/forgebook/newStories.js +101 -11
- package/dist/bin/forgebook/newStoriesFile.d.ts +20 -1
- package/dist/bin/forgebook/newStoriesFile.js +43 -4
- package/dist/bin/forgebook/prebundleRun.d.ts +3 -1
- package/dist/bin/forgebook/prebundleRun.js +28 -8
- package/dist/bin/forgebook/proofCommand.d.mts +15 -0
- package/dist/bin/forgebook/proofCommand.mjs +212 -0
- package/dist/bin/forgebook/proofRun.d.ts +63 -0
- package/dist/bin/forgebook/proofRun.js +412 -0
- package/dist/bin/forgebook/proofText.d.ts +36 -0
- package/dist/bin/forgebook/proofText.js +131 -0
- package/dist/bin/forgebook/proofWorkflow.d.ts +29 -0
- package/dist/bin/forgebook/proofWorkflow.js +205 -0
- package/dist/bin/forgebook/setArgsTool.d.ts +8 -0
- package/dist/bin/forgebook/setArgsTool.js +70 -0
- package/dist/bin/forgebook/storyCheckCommands.mjs +42 -3
- package/dist/bin/forgebook/storyCheckRun.d.ts +50 -0
- package/dist/bin/forgebook/storyCheckRun.js +83 -9
- package/dist/bin/forgebook/storyFileIds.d.ts +15 -0
- package/dist/bin/forgebook/storyFileIds.js +14 -0
- package/dist/bin/forgebook/stressCases.d.ts +31 -0
- package/dist/bin/forgebook/stressCases.js +79 -0
- package/dist/bin/forgebook/stressRun.d.ts +12 -0
- package/dist/bin/forgebook/stressRun.js +61 -0
- package/dist/bin/forgebook/stressText.d.ts +27 -0
- package/dist/bin/forgebook/stressText.js +46 -0
- package/dist/bin/forgebook/verifyBase.d.ts +45 -0
- package/dist/bin/forgebook/verifyBase.js +204 -0
- package/dist/bin/forgebook/verifyCommand.d.mts +13 -0
- package/dist/bin/forgebook/verifyCommand.mjs +125 -0
- package/dist/bin/forgebook/verifyRun.d.ts +63 -0
- package/dist/bin/forgebook/verifyRun.js +108 -0
- package/dist/bin/forgebook/verifyVerdict.d.ts +40 -0
- package/dist/bin/forgebook/verifyVerdict.js +323 -0
- package/dist/bin/forgebook/workflowActions.d.ts +23 -0
- package/dist/bin/forgebook/workflowActions.js +23 -0
- package/dist/bin/forgebook-docs/catalogueMarkdown.js +12 -1
- package/dist/src/addressArgs.d.ts +29 -5
- package/dist/src/addressArgs.js +58 -16
- package/dist/src/addressArgsParam.d.ts +54 -0
- package/dist/src/addressArgsParam.js +51 -0
- package/dist/src/addressTexts.d.ts +14 -0
- package/dist/src/addressTexts.js +28 -21
- package/dist/src/agentIndexFile.d.ts +11 -0
- package/dist/src/agentIndexFile.js +11 -0
- package/dist/src/argConditions.d.ts +52 -0
- package/dist/src/argConditions.js +80 -0
- package/dist/src/argControl.d.ts +148 -0
- package/dist/src/argControl.js +0 -0
- package/dist/src/argExpression.d.ts +21 -0
- package/dist/src/argExpression.js +30 -0
- package/dist/src/argTypes.d.ts +40 -51
- package/dist/src/argTypes.js +69 -185
- package/dist/src/argsProps.d.ts +3 -3
- package/dist/src/argsProps.js +11 -5
- package/dist/src/bundlerErrors.d.ts +29 -0
- package/dist/src/bundlerErrors.js +49 -0
- package/dist/src/catalogue.d.ts +31 -0
- package/dist/src/catalogue.js +13 -2
- package/dist/src/catalogueRefs.d.ts +75 -0
- package/dist/src/catalogueRefs.js +122 -0
- package/dist/src/componentDocs.d.ts +83 -0
- package/dist/src/componentDocs.js +20 -3
- package/dist/src/controlCode.d.ts +27 -0
- package/dist/src/controlCode.js +41 -0
- package/dist/src/frame/callValues.d.ts +19 -0
- package/dist/src/frame/callValues.js +58 -0
- package/dist/src/frame/canvasScheme.d.ts +33 -0
- package/dist/src/frame/canvasScheme.js +67 -0
- package/dist/src/frame/controlValues.d.ts +39 -0
- package/dist/src/frame/controlValues.js +143 -0
- package/dist/src/frame/frame.css +36 -3
- package/dist/src/frame/frameStatus.d.ts +16 -1
- package/dist/src/frame/frameStatus.js +16 -1
- package/dist/src/frame/frameView.js +4 -3
- package/dist/src/frame/mountFrame.d.ts +10 -1
- package/dist/src/frame/mountFrame.js +160 -55
- package/dist/src/frame/panelControls.d.ts +67 -0
- package/dist/src/frame/panelControls.js +110 -0
- package/dist/src/frame/panelValues.d.ts +35 -0
- package/dist/src/frame/panelValues.js +127 -0
- package/dist/src/frame/playActions.d.ts +39 -0
- package/dist/src/frame/playActions.js +98 -0
- package/dist/src/frame/playStepper.d.ts +28 -0
- package/dist/src/frame/playStepper.js +38 -0
- package/dist/src/frame/playStory.d.ts +9 -1
- package/dist/src/frame/playStory.js +49 -3
- package/dist/src/frame/renderer.d.ts +34 -1
- package/dist/src/frame/renderer.js +24 -0
- package/dist/src/frame/shellChannel.d.ts +1 -1
- package/dist/src/frame/shellChannel.js +1 -1
- package/dist/src/frame/shellCheck.d.ts +17 -0
- package/dist/src/frame/shellCheck.js +25 -0
- package/dist/src/frame/shellMessageCheck.d.ts +7 -0
- package/dist/src/frame/shellMessageCheck.js +53 -0
- package/dist/src/frame/storyContent.d.ts +50 -0
- package/dist/src/frame/storyContent.js +73 -0
- package/dist/src/frame/storyModule.d.ts +9 -0
- package/dist/src/frame/storyModule.js +20 -2
- package/dist/src/frame/storyRun.d.ts +15 -7
- package/dist/src/frame/storyRun.js +64 -15
- package/dist/src/frame/valueSheets.d.ts +35 -0
- package/dist/src/frame/valueSheets.js +99 -0
- package/dist/src/hotModules.d.ts +20 -0
- package/dist/src/hotModules.js +23 -0
- package/dist/src/jsxCode.d.ts +1 -14
- package/dist/src/jsxCode.js +46 -10
- package/dist/src/liveErrors.d.ts +30 -4
- package/dist/src/liveErrors.js +18 -3
- package/dist/src/messages.d.ts +77 -27
- package/dist/src/messages.js +58 -100
- package/dist/src/namedValues.d.ts +2 -26
- package/dist/src/namedValues.js +0 -47
- package/dist/src/pageConfig.d.ts +2 -0
- package/dist/src/playTrace.d.ts +19 -2
- package/dist/src/playTrace.js +10 -5
- package/dist/src/plugin.d.ts +10 -3
- package/dist/src/previewRelay.js +9 -1
- package/dist/src/printable.d.ts +12 -0
- package/dist/src/printable.js +22 -0
- package/dist/src/propsSignature.d.ts +37 -0
- package/dist/src/propsSignature.js +40 -0
- package/dist/src/search.d.ts +41 -5
- package/dist/src/search.js +93 -23
- package/dist/src/searchMatch.d.ts +4 -1
- package/dist/src/searchMatch.js +26 -5
- package/dist/src/searchTypos.d.ts +88 -0
- package/dist/src/searchTypos.js +178 -0
- package/dist/src/shapeValues.d.ts +86 -0
- package/dist/src/shapeValues.js +295 -0
- package/dist/src/shell/ApiReference.js +6 -3
- package/dist/src/shell/ApiTableBox.d.ts +15 -0
- package/dist/src/shell/ApiTableBox.js +11 -0
- package/dist/src/shell/AppearanceMenu.d.ts +4 -1
- package/dist/src/shell/AppearanceMenu.js +9 -6
- package/dist/src/shell/AuthoredHome.js +3 -1
- package/dist/src/shell/CodeTab.d.ts +12 -6
- package/dist/src/shell/CodeTab.js +47 -3
- package/dist/src/shell/CodeText.d.ts +1 -1
- package/dist/src/shell/CodeText.js +2 -3
- package/dist/src/shell/CompareGrid.js +1 -1
- package/dist/src/shell/ComponentPage.d.ts +6 -6
- package/dist/src/shell/ComponentPage.js +8 -2
- package/dist/src/shell/CustomControl.d.ts +34 -0
- package/dist/src/shell/CustomControl.js +125 -0
- package/dist/src/shell/DocContainers.js +1 -1
- package/dist/src/shell/DocPage.js +2 -2
- package/dist/src/shell/DroppedArgsList.d.ts +2 -2
- package/dist/src/shell/DroppedArgsList.js +1 -1
- package/dist/src/shell/EmbedPage.js +30 -12
- package/dist/src/shell/Example.d.ts +5 -1
- package/dist/src/shell/Example.js +16 -8
- package/dist/src/shell/FrameView.d.ts +6 -3
- package/dist/src/shell/FrameView.js +2 -2
- package/dist/src/shell/HomePage.d.ts +3 -1
- package/dist/src/shell/HomePage.js +18 -6
- package/dist/src/shell/InfoTip.js +2 -2
- package/dist/src/shell/InteractionsTab.d.ts +11 -4
- package/dist/src/shell/InteractionsTab.js +18 -2
- package/dist/src/shell/LazyPage.js +1 -1
- package/dist/src/shell/PackageHtml.js +3 -1
- package/dist/src/shell/PageWidth.d.ts +29 -0
- package/dist/src/shell/PageWidth.js +18 -0
- package/dist/src/shell/PinnedControl.js +14 -62
- package/dist/src/shell/PinnedControlMenu.d.ts +44 -0
- package/dist/src/shell/PinnedControlMenu.js +72 -0
- package/dist/src/shell/PropFields.d.ts +3 -1
- package/dist/src/shell/PropFields.js +9 -6
- package/dist/src/shell/PropRows.d.ts +22 -11
- package/dist/src/shell/PropRows.js +62 -24
- package/dist/src/shell/PropsTab.d.ts +12 -5
- package/dist/src/shell/PropsTab.js +9 -22
- package/dist/src/shell/RefStoryPage.d.ts +33 -0
- package/dist/src/shell/RefStoryPage.js +123 -0
- package/dist/src/shell/SearchPanel.js +51 -24
- package/dist/src/shell/Shell.d.ts +18 -0
- package/dist/src/shell/Shell.js +141 -23
- package/dist/src/shell/ShortcutHelp.d.ts +22 -0
- package/dist/src/shell/ShortcutHelp.js +66 -0
- package/dist/src/shell/Sidebar.d.ts +17 -4
- package/dist/src/shell/Sidebar.js +92 -41
- package/dist/src/shell/SidebarDocs.js +2 -2
- package/dist/src/shell/SidebarEntries.js +5 -3
- package/dist/src/shell/SidebarHandle.d.ts +3 -5
- package/dist/src/shell/SidebarHandle.js +4 -4
- package/dist/src/shell/SidebarRefs.d.ts +39 -0
- package/dist/src/shell/SidebarRefs.js +99 -0
- package/dist/src/shell/SidebarSearch.js +37 -9
- package/dist/src/shell/SignatureReference.js +3 -1
- package/dist/src/shell/Stage.d.ts +10 -2
- package/dist/src/shell/Stage.js +29 -49
- package/dist/src/shell/StatusBadges.d.ts +54 -0
- package/dist/src/shell/StatusBadges.js +77 -0
- package/dist/src/shell/StoryCodeBlock.d.ts +8 -19
- package/dist/src/shell/StoryCodeBlock.js +7 -6
- package/dist/src/shell/StoryPicker.d.ts +4 -2
- package/dist/src/shell/StoryPicker.js +3 -3
- package/dist/src/shell/Switch.d.ts +29 -0
- package/dist/src/shell/Switch.js +11 -0
- package/dist/src/shell/SwitchGallery.d.ts +36 -0
- package/dist/src/shell/SwitchGallery.js +17 -0
- package/dist/src/shell/SwitchGalleryPanel.d.ts +37 -0
- package/dist/src/shell/SwitchGalleryPanel.js +99 -0
- package/dist/src/shell/TagFilter.d.ts +24 -0
- package/dist/src/shell/TagFilter.js +45 -0
- package/dist/src/shell/TagViews.d.ts +39 -0
- package/dist/src/shell/TagViews.js +20 -0
- package/dist/src/shell/Toolbar.d.ts +4 -1
- package/dist/src/shell/Toolbar.js +17 -7
- package/dist/src/shell/ToolbarControl.d.ts +3 -0
- package/dist/src/shell/ToolbarControl.js +23 -6
- package/dist/src/shell/ViewMenuPanel.js +6 -1
- package/dist/src/shell/argChecks.d.ts +22 -0
- package/dist/src/shell/argChecks.js +20 -0
- package/dist/src/shell/asideStory.js +7 -2
- package/dist/src/shell/audienceSections.css +9 -9
- package/dist/src/shell/catalogueContext.d.ts +1 -1
- package/dist/src/shell/catalogueContext.js +6 -1
- package/dist/src/shell/codeSpans.d.ts +27 -0
- package/dist/src/shell/codeSpans.js +76 -0
- package/dist/src/shell/compareVariants.d.ts +4 -2
- package/dist/src/shell/compareVariants.js +16 -8
- package/dist/src/shell/composition.d.ts +23 -0
- package/dist/src/shell/composition.js +26 -0
- package/dist/src/shell/controlCycle.d.ts +1 -1
- package/dist/src/shell/controlCycle.js +3 -2
- package/dist/src/shell/customControls.d.ts +62 -0
- package/dist/src/shell/customControls.js +81 -0
- package/dist/src/shell/docPage.css +22 -22
- package/dist/src/shell/dockTabs.d.ts +19 -3
- package/dist/src/shell/dockTabs.js +29 -20
- package/dist/src/shell/embed.css +7 -7
- package/dist/src/shell/frameOrder.d.ts +35 -0
- package/dist/src/shell/frameOrder.js +45 -0
- package/dist/src/shell/framesOrigin.d.ts +7 -0
- package/dist/src/shell/framesOrigin.js +1 -1
- package/dist/src/shell/galleryPlace.d.ts +20 -0
- package/dist/src/shell/galleryPlace.js +26 -0
- package/dist/src/shell/icons.d.ts +1 -0
- package/dist/src/shell/icons.js +1 -0
- package/dist/src/shell/keyboard.d.ts +14 -12
- package/dist/src/shell/keyboard.js +21 -6
- package/dist/src/shell/laterStrings.d.ts +30 -0
- package/dist/src/shell/laterStrings.js +43 -3
- package/dist/src/shell/mountShell.js +3 -0
- package/dist/src/shell/pageStrings.d.ts +4 -0
- package/dist/src/shell/pageStrings.js +4 -0
- package/dist/src/shell/pageTagView.d.ts +18 -0
- package/dist/src/shell/pageTagView.js +10 -0
- package/dist/src/shell/playMemory.d.ts +14 -0
- package/dist/src/shell/playMemory.js +8 -0
- package/dist/src/shell/propNotes.d.ts +23 -0
- package/dist/src/shell/propNotes.js +37 -0
- package/dist/src/shell/refIndexLoad.d.ts +17 -0
- package/dist/src/shell/refIndexLoad.js +38 -0
- package/dist/src/shell/refParts.d.ts +34 -0
- package/dist/src/shell/refParts.js +9 -0
- package/dist/src/shell/refStory.css +21 -0
- package/dist/src/shell/refStrings.d.ts +13 -0
- package/dist/src/shell/refStrings.js +21 -0
- package/dist/src/shell/search.css +11 -11
- package/dist/src/shell/shell.css +376 -169
- package/dist/src/shell/shellScheme.js +2 -2
- package/dist/src/shell/shortcutHelp.css +64 -0
- package/dist/src/shell/stageArgs.d.ts +53 -0
- package/dist/src/shell/stageArgs.js +64 -0
- package/dist/src/shell/statusBadges.css +51 -0
- package/dist/src/shell/strings.d.ts +7 -16
- package/dist/src/shell/strings.js +12 -17
- package/dist/src/shell/switchGallery.css +104 -0
- package/dist/src/shell/tagFilter.css +46 -0
- package/dist/src/shell/tagView.d.ts +20 -0
- package/dist/src/shell/tagView.js +10 -0
- package/dist/src/shell/useAddressArgs.d.ts +9 -0
- package/dist/src/shell/useAddressArgs.js +56 -11
- package/dist/src/shell/useControlKeys.js +2 -2
- package/dist/src/shell/useEditedProblems.d.ts +6 -0
- package/dist/src/shell/useEditedProblems.js +40 -0
- package/dist/src/shell/useFrameMessages.js +3 -0
- package/dist/src/shell/useFrameQueue.d.ts +8 -3
- package/dist/src/shell/useFrameQueue.js +42 -12
- package/dist/src/shell/useListedTree.d.ts +13 -0
- package/dist/src/shell/useListedTree.js +32 -0
- package/dist/src/shell/usePageFrames.js +2 -2
- package/dist/src/shell/usePopover.d.ts +5 -0
- package/dist/src/shell/usePopover.js +7 -1
- package/dist/src/shell/useRefIndex.d.ts +22 -0
- package/dist/src/shell/useRefIndex.js +36 -0
- package/dist/src/shell/useScrollSettled.d.ts +18 -0
- package/dist/src/shell/useScrollSettled.js +56 -0
- package/dist/src/shell/useScrollStops.d.ts +20 -0
- package/dist/src/shell/useScrollStops.js +41 -0
- package/dist/src/shell/useShortcutHelp.d.ts +18 -0
- package/dist/src/shell/useShortcutHelp.js +32 -0
- package/dist/src/shell/useSidebarOverlay.d.ts +2 -1
- package/dist/src/shell/useSidebarOverlay.js +12 -4
- package/dist/src/shell/useStoryCode.d.ts +2 -1
- package/dist/src/shell/useStoryCode.js +12 -7
- package/dist/src/shell/useToolbarLayout.d.ts +5 -1
- package/dist/src/shell/useToolbarLayout.js +2 -2
- package/dist/src/shell/useWorstCase.d.ts +8 -2
- package/dist/src/shell/useWorstCase.js +2 -2
- package/dist/src/shell/valueEditors/FileEditor.d.ts +28 -0
- package/dist/src/shell/valueEditors/FileEditor.js +66 -0
- package/dist/src/shell/valueEditors/JsonEditor.d.ts +14 -0
- package/dist/src/shell/valueEditors/JsonEditor.js +53 -0
- package/dist/src/shell/valueEditors/ListEditor.d.ts +24 -0
- package/dist/src/shell/valueEditors/ListEditor.js +82 -0
- package/dist/src/shell/valueEditors/ObjectEditor.d.ts +32 -0
- package/dist/src/shell/valueEditors/ObjectEditor.js +70 -0
- package/dist/src/shell/valueEditors/PropEditor.d.ts +37 -0
- package/dist/src/shell/valueEditors/PropEditor.js +53 -0
- package/dist/src/shell/valueEditors/RecordEditor.d.ts +20 -0
- package/dist/src/shell/valueEditors/RecordEditor.js +84 -0
- package/dist/src/shell/valueEditors/SearchSelect.d.ts +42 -0
- package/dist/src/shell/valueEditors/SearchSelect.js +80 -0
- package/dist/src/shell/valueEditors/TokenEditor.d.ts +49 -0
- package/dist/src/shell/valueEditors/TokenEditor.js +74 -0
- package/dist/src/shell/valueEditors/UnionEditor.d.ts +20 -0
- package/dist/src/shell/valueEditors/UnionEditor.js +64 -0
- package/dist/src/shell/valueEditors/ValueField.d.ts +15 -0
- package/dist/src/shell/valueEditors/ValueField.js +148 -0
- package/dist/src/shell/valueEditors/editorStrings.d.ts +56 -0
- package/dist/src/shell/valueEditors/editorStrings.js +66 -0
- package/dist/src/shell/valueEditors/fieldTypes.d.ts +31 -0
- package/dist/src/shell/valueEditors/fieldTypes.js +0 -0
- package/dist/src/shell/valueEditors/valueEditors.css +153 -0
- package/dist/src/shell/worstArgs.d.ts +8 -5
- package/dist/src/shell/worstArgs.js +14 -7
- package/dist/src/shellTheme.d.ts +1 -1
- package/dist/src/shellTheme.js +15 -1
- package/dist/src/shellTheme.types.d.ts +4 -0
- package/dist/src/shellWord.d.ts +12 -0
- package/dist/src/shellWord.js +15 -0
- package/dist/src/sourceFiles.js +2 -1
- package/dist/src/storyArgTypes.d.ts +57 -0
- package/dist/src/storyArgTypes.js +195 -0
- package/dist/src/storyBackground.js +14 -3
- package/dist/src/storyCheck.d.ts +99 -3
- package/dist/src/storyCheck.js +39 -1
- package/dist/src/storyCodeText.d.ts +52 -0
- package/dist/src/storyCodeText.js +30 -0
- package/dist/src/storyControls.d.ts +103 -0
- package/dist/src/storyControls.js +100 -0
- package/dist/src/storyStatuses.d.ts +55 -0
- package/dist/src/storyStatuses.js +104 -0
- package/dist/src/storyTagNames.d.ts +25 -0
- package/dist/src/storyTagNames.js +25 -0
- package/dist/src/storyTags.d.ts +29 -0
- package/dist/src/storyTags.js +85 -0
- package/dist/src/storyTree.d.ts +13 -0
- package/dist/src/storyTree.js +24 -4
- package/dist/src/storybookArgs.d.ts +24 -0
- package/dist/src/storybookArgs.js +185 -0
- package/dist/src/switches.d.ts +66 -3
- package/dist/src/switches.js +42 -1
- package/dist/src/valueSchema.d.ts +28 -0
- package/dist/src/valueSchema.js +196 -0
- package/dist/src/valueShape.d.ts +94 -0
- package/dist/src/valueShape.js +25 -0
- package/dist/src/viewState.d.ts +8 -3
- package/dist/src/viewState.js +27 -10
- package/dist/src/vite/adapter.d.ts +40 -2
- package/dist/src/vite/adapter.js +1 -0
- package/dist/src/vite/agent.types.d.ts +354 -7
- package/dist/src/vite/agentApi.d.ts +23 -0
- package/dist/src/vite/agentApi.js +90 -17
- package/dist/src/vite/agentIndex.d.ts +0 -2
- package/dist/src/vite/agentIndex.js +5 -6
- package/dist/src/vite/agentRoutes.d.ts +20 -1
- package/dist/src/vite/agentRoutes.js +135 -66
- package/dist/src/vite/agentStatuses.d.ts +42 -0
- package/dist/src/vite/agentStatuses.js +67 -0
- package/dist/src/vite/agentStoryCode.d.ts +51 -0
- package/dist/src/vite/agentStoryCode.js +44 -0
- package/dist/src/vite/agentVisibility.d.ts +47 -0
- package/dist/src/vite/agentVisibility.js +174 -0
- package/dist/src/vite/appAudit.d.ts +134 -0
- package/dist/src/vite/appAudit.js +333 -0
- package/dist/src/vite/appBuildOption.d.ts +53 -0
- package/dist/src/vite/appBuildOption.js +55 -0
- package/dist/src/vite/appTokenFiles.d.ts +92 -0
- package/dist/src/vite/appTokenFiles.js +433 -0
- package/dist/src/vite/appTokens.d.ts +23 -0
- package/dist/src/vite/appTokens.js +275 -0
- package/dist/src/vite/argControlsConfig.d.ts +30 -0
- package/dist/src/vite/argControlsConfig.js +176 -0
- package/dist/src/vite/builtTexts.d.ts +10 -0
- package/dist/src/vite/builtTexts.js +59 -22
- package/dist/src/vite/catalogueConfig.d.ts +3 -1
- package/dist/src/vite/catalogueConfig.js +21 -4
- package/dist/src/vite/changeCoverage.d.ts +74 -0
- package/dist/src/vite/changeCoverage.js +120 -0
- package/dist/src/vite/changedRoute.d.ts +30 -0
- package/dist/src/vite/changedRoute.js +197 -0
- package/dist/src/vite/checkCode.d.ts +105 -3
- package/dist/src/vite/checkCode.js +323 -36
- package/dist/src/vite/checkoutWatch.d.ts +97 -0
- package/dist/src/vite/checkoutWatch.js +287 -0
- package/dist/src/vite/closeWatch.d.ts +8 -0
- package/dist/src/vite/closeWatch.js +1 -1
- package/dist/src/vite/componentCache.d.ts +8 -0
- package/dist/src/vite/componentCache.js +66 -0
- package/dist/src/vite/componentGraph.d.ts +71 -0
- package/dist/src/vite/componentGraph.js +133 -0
- package/dist/src/vite/componentRules.d.ts +33 -0
- package/dist/src/vite/componentRules.js +105 -0
- package/dist/src/vite/componentScan.d.ts +69 -0
- package/dist/src/vite/componentScan.js +418 -0
- package/dist/src/vite/compositionCheck.d.ts +15 -0
- package/dist/src/vite/compositionCheck.js +243 -0
- package/dist/src/vite/config.d.ts +67 -1
- package/dist/src/vite/configFile.d.ts +15 -2
- package/dist/src/vite/configFile.js +109 -40
- package/dist/src/vite/configKeys.d.ts +15 -0
- package/dist/src/vite/configKeys.js +172 -0
- package/dist/src/vite/configLoadError.d.ts +23 -0
- package/dist/src/vite/configLoadError.js +71 -0
- package/dist/src/vite/cssDeclarations.d.ts +71 -0
- package/dist/src/vite/cssDeclarations.js +290 -0
- package/dist/src/vite/cssImports.d.ts +14 -0
- package/dist/src/vite/cssImports.js +48 -0
- package/dist/src/vite/cssReferences.d.ts +54 -0
- package/dist/src/vite/cssReferences.js +157 -0
- package/dist/src/vite/cssTokenValues.d.ts +50 -0
- package/dist/src/vite/cssTokenValues.js +233 -0
- package/dist/src/vite/designTokens.d.ts +24 -0
- package/dist/src/vite/designTokens.js +5 -1
- package/dist/src/vite/docsExtractor.d.ts +9 -3
- package/dist/src/vite/docsExtractor.js +11 -3
- package/dist/src/vite/docsProgram.d.ts +17 -4
- package/dist/src/vite/docsProgram.js +52 -11
- package/dist/src/vite/docsWorker.js +7 -2
- package/dist/src/vite/emptyStoryGlobs.d.ts +41 -0
- package/dist/src/vite/emptyStoryGlobs.js +52 -0
- package/dist/src/vite/fileImports.d.ts +17 -0
- package/dist/src/vite/fileImports.js +57 -0
- package/dist/src/vite/findComponent.d.ts +10 -2
- package/dist/src/vite/findComponent.js +27 -22
- package/dist/src/vite/findRoute.js +3 -2
- package/dist/src/vite/forcedStates.d.ts +9 -2
- package/dist/src/vite/forcedStates.js +12 -3
- package/dist/src/vite/forgebookPlugin.d.ts +2 -0
- package/dist/src/vite/forgebookPlugin.js +55 -73
- package/dist/src/vite/frameErrors.d.ts +19 -0
- package/dist/src/vite/frameErrors.js +70 -0
- package/dist/src/vite/framesServer.d.ts +12 -0
- package/dist/src/vite/framesServer.js +21 -4
- package/dist/src/vite/functionComponentDocs.js +81 -12
- package/dist/src/vite/generatedModules.js +4 -2
- package/dist/src/vite/gitChange.d.ts +38 -5
- package/dist/src/vite/gitChange.js +71 -11
- package/dist/src/vite/hiddenStoryFiles.d.ts +23 -0
- package/dist/src/vite/hiddenStoryFiles.js +107 -0
- package/dist/src/vite/hotSnippets.d.ts +38 -14
- package/dist/src/vite/hotSnippets.js +137 -39
- package/dist/src/vite/importedNames.d.ts +37 -0
- package/dist/src/vite/importedNames.js +138 -0
- package/dist/src/vite/indexFields.d.ts +6 -0
- package/dist/src/vite/indexFields.js +21 -0
- package/dist/src/vite/indexStoryFile.d.ts +8 -1
- package/dist/src/vite/indexStoryFile.js +22 -157
- package/dist/src/vite/jsxCallSites.d.ts +33 -0
- package/dist/src/vite/jsxCallSites.js +200 -0
- package/dist/src/vite/jsxInScripts.d.ts +67 -0
- package/dist/src/vite/jsxInScripts.js +138 -0
- package/dist/src/vite/jsxTree.d.ts +20 -0
- package/dist/src/vite/jsxTree.js +163 -0
- package/dist/src/vite/lineAndColumn.d.ts +13 -0
- package/dist/src/vite/lineAndColumn.js +18 -0
- package/dist/src/vite/lookAlikes.d.ts +65 -0
- package/dist/src/vite/lookAlikes.js +228 -0
- package/dist/src/vite/nearestToken.d.ts +17 -0
- package/dist/src/vite/nearestToken.js +9 -2
- package/dist/src/vite/packageEntries.d.ts +42 -0
- package/dist/src/vite/packageEntries.js +127 -0
- package/dist/src/vite/pages.d.ts +9 -1
- package/dist/src/vite/pages.js +119 -4
- package/dist/src/vite/pluginConfig.js +4 -0
- package/dist/src/vite/pluginIds.d.ts +2 -0
- package/dist/src/vite/pluginIds.js +5 -1
- package/dist/src/vite/pluginModules.d.ts +81 -11
- package/dist/src/vite/pluginModules.js +109 -21
- package/dist/src/vite/prebundled.d.ts +57 -15
- package/dist/src/vite/prebundled.js +80 -0
- package/dist/src/vite/previewTags.d.ts +25 -0
- package/dist/src/vite/previewTags.js +56 -0
- package/dist/src/vite/projectFiles.d.ts +54 -0
- package/dist/src/vite/projectFiles.js +116 -0
- package/dist/src/vite/projectPostcss.d.ts +70 -0
- package/dist/src/vite/projectPostcss.js +250 -0
- package/dist/src/vite/propDocs.d.ts +12 -0
- package/dist/src/vite/propDocs.js +187 -60
- package/dist/src/vite/propKind.d.ts +40 -0
- package/dist/src/vite/propKind.js +71 -0
- package/dist/src/vite/propTypeNotes.d.ts +22 -0
- package/dist/src/vite/propTypeNotes.js +51 -0
- package/dist/src/vite/publishedExports.d.ts +27 -0
- package/dist/src/vite/publishedExports.js +298 -0
- package/dist/src/vite/realFolder.d.ts +6 -0
- package/dist/src/vite/realFolder.js +25 -0
- package/dist/src/vite/refsConfig.d.ts +39 -0
- package/dist/src/vite/refsConfig.js +54 -0
- package/dist/src/vite/reuseCheck.d.ts +45 -0
- package/dist/src/vite/reuseCheck.js +260 -0
- package/dist/src/vite/runningVersions.d.ts +33 -0
- package/dist/src/vite/runningVersions.js +25 -0
- package/dist/src/vite/scriptProblems.d.ts +60 -0
- package/dist/src/vite/scriptProblems.js +155 -0
- package/dist/src/vite/searchModule.js +3 -2
- package/dist/src/vite/searchRoute.js +4 -2
- package/dist/src/vite/shapeDocs.d.ts +36 -0
- package/dist/src/vite/shapeDocs.js +177 -0
- package/dist/src/vite/singleFileComponent.d.ts +17 -0
- package/dist/src/vite/singleFileComponent.js +83 -0
- package/dist/src/vite/sourceText.d.ts +34 -0
- package/dist/src/vite/sourceText.js +72 -0
- package/dist/src/vite/sourceTokens.d.ts +7 -0
- package/dist/src/vite/sourceTokens.js +7 -2
- package/dist/src/vite/stackLines.d.ts +49 -0
- package/dist/src/vite/stackLines.js +96 -0
- package/dist/src/vite/storyCode.d.ts +22 -7
- package/dist/src/vite/storyCode.js +263 -37
- package/dist/src/vite/storyCoverage.d.ts +48 -0
- package/dist/src/vite/storyCoverage.js +179 -0
- package/dist/src/vite/storyFilesModule.d.ts +48 -3
- package/dist/src/vite/storyFilesModule.js +105 -15
- package/dist/src/vite/storyPatterns.d.ts +31 -0
- package/dist/src/vite/storyPatterns.js +140 -5
- package/dist/src/vite/storyReach.d.ts +10 -2
- package/dist/src/vite/storyReach.js +15 -11
- package/dist/src/vite/storyTopLevel.d.ts +51 -0
- package/dist/src/vite/storyTopLevel.js +146 -0
- package/dist/src/vite/storylessRoutes.d.ts +4 -3
- package/dist/src/vite/storylessRoutes.js +210 -19
- package/dist/src/vite/switchValuesCheck.d.ts +19 -0
- package/dist/src/vite/switchValuesCheck.js +164 -0
- package/dist/src/vite/switchesDocument.d.ts +15 -0
- package/dist/src/vite/switchesDocument.js +47 -0
- package/dist/src/vite/tailwindConfigTokens.d.ts +41 -0
- package/dist/src/vite/tailwindConfigTokens.js +306 -0
- package/dist/src/vite/textImports.d.ts +15 -0
- package/dist/src/vite/textImports.js +58 -0
- package/dist/src/vite/textModules.d.ts +6 -5
- package/dist/src/vite/textModules.js +13 -8
- package/dist/src/vite/tokenAnswers.d.ts +6 -2
- package/dist/src/vite/tokenAnswers.js +11 -7
- package/dist/src/vite/typeParameters.d.ts +83 -0
- package/dist/src/vite/typeParameters.js +270 -0
- package/dist/src/vite/typedControls.d.ts +31 -0
- package/dist/src/vite/typedControls.js +66 -0
- package/dist/src/vite/unionProps.d.ts +37 -0
- package/dist/src/vite/unionProps.js +121 -0
- package/dist/src/vite/unresolvedTokens.d.ts +20 -0
- package/dist/src/vite/unresolvedTokens.js +193 -0
- package/dist/src/vite/usageGraph.js +10 -52
- package/dist/src/vite/usageGuidance.d.ts +9 -2
- package/dist/src/vite/usageGuidance.js +36 -8
- package/dist/src/vite/usageImports.d.ts +35 -0
- package/dist/src/vite/usageImports.js +280 -0
- package/dist/src/vite/visibilityRoute.d.ts +16 -0
- package/dist/src/vite/visibilityRoute.js +320 -0
- package/dist/src/worstCase.d.ts +2 -0
- package/dist/src/worstCase.js +2 -0
- package/package.json +28 -8
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a change writes against how a design system says its components fit together: allowed parents, children and
|
|
3
|
+
* siblings, and plain elements a component stands in for.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Pure, from the syntax tree of the changed files, for what the lines a change adds put there. It says only what the file
|
|
7
|
+
* shows: an element at the root of what a component returns, or held in a prop, may be drawn anywhere, so its parent is not
|
|
8
|
+
* known and it is left alone. Only what an author wrote is enforced, so a design system with no rules gets no findings. A
|
|
9
|
+
* `.vue` or `.svelte` template has no tree here, so only scripts with JSX are read, and the answer does not claim more.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { basename, dirname } from "node:path";
|
|
14
|
+
import { parseSync } from "vite";
|
|
15
|
+
import { rootsOf } from "./jsxTree.js";
|
|
16
|
+
import { isTooDeep, lineStarts } from "./sourceText.js";
|
|
17
|
+
/** What says a composition is meant: its rule and why, in a comment. */
|
|
18
|
+
const IGNORE = /(?:\/\/|\/\*|<!--|\{\/\*)\s*forgebook-ignore\s+composition\s*:\s*([^*\n]{3,120})/;
|
|
19
|
+
/** A script that can hold JSX. */
|
|
20
|
+
const SCRIPT_FILE = /\.[jt]sx$/;
|
|
21
|
+
/** What a file imports: each local name, what the module calls it, and from where. */
|
|
22
|
+
const localNames = (program) => new Map(program.body.flatMap((statement) => statement.type !== "ImportDeclaration"
|
|
23
|
+
? []
|
|
24
|
+
: statement.specifiers.map((each) => {
|
|
25
|
+
const module = statement.source.value;
|
|
26
|
+
const name = each.type === "ImportSpecifier" && "name" in each.imported
|
|
27
|
+
? String(each.imported.name)
|
|
28
|
+
: each.local.name;
|
|
29
|
+
return [each.local.name, { name, module }];
|
|
30
|
+
})));
|
|
31
|
+
/** Whether a module is a third party's: what it exports is not the project's component of that name. */
|
|
32
|
+
const isThirdParty = (module, packages) => {
|
|
33
|
+
if (/^(?:\.{1,2}\/|[@~#]\/)/.test(module))
|
|
34
|
+
return false;
|
|
35
|
+
return !packages.some(({ name }) => name !== "" && (module === name || module.startsWith(`${name}/`)));
|
|
36
|
+
};
|
|
37
|
+
/** Whether a name is a component's and not a plain element's. */
|
|
38
|
+
const isComponent = (name) => /^[A-Z]/.test(name) || /^[a-zA-Z]+\.[A-Z]/.test(name);
|
|
39
|
+
/** Whether a name means a listed one: `Select.Root` is a `Select`, and `UI.Select` too. */
|
|
40
|
+
const isListedName = (list, name) => {
|
|
41
|
+
const parts = name.split(".");
|
|
42
|
+
return list.includes(name) || list.includes(parts[0] ?? "") || list.includes(parts.at(-1) ?? "");
|
|
43
|
+
};
|
|
44
|
+
/** What an added element breaks of what may stand around it. */
|
|
45
|
+
const checkParents = ({ real, line }, ancestors, rules, walk) => {
|
|
46
|
+
const { parents } = rules;
|
|
47
|
+
const inComponents = ancestors.filter(isComponent);
|
|
48
|
+
if (parents === undefined || inComponents.length === 0)
|
|
49
|
+
return;
|
|
50
|
+
// a component above that renders an allowed parent itself passes its children on to it
|
|
51
|
+
if (ancestors.some((each) => isListedName(parents, each) || walk.rendersAny(each, parents)))
|
|
52
|
+
return;
|
|
53
|
+
walk.found.push({
|
|
54
|
+
line,
|
|
55
|
+
value: real,
|
|
56
|
+
message: `${real} belongs inside ${parents.join(" or ")}, not ${inComponents.at(-1) ?? ""}.`
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
/** What an element's added children break of what may stand inside it. */
|
|
60
|
+
const checkChildren = (real, children, rules, walk) => {
|
|
61
|
+
const allowed = rules.children;
|
|
62
|
+
if (allowed === undefined)
|
|
63
|
+
return;
|
|
64
|
+
for (const child of children) {
|
|
65
|
+
const name = walk.real(child.name);
|
|
66
|
+
const isFine = !isComponent(name) || isListedName(allowed, name) || walk.rendersAny(name, allowed);
|
|
67
|
+
if (!isFine && walk.isAdded(child.line)) {
|
|
68
|
+
walk.found.push({
|
|
69
|
+
line: child.line,
|
|
70
|
+
value: name,
|
|
71
|
+
message: `${real} takes ${allowed.join(" or ")} inside it, not ${name}.`
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
/** What an element and those beside it break of what may stand beside it, where either is added. */
|
|
77
|
+
const checkSiblings = (element, siblings, rules, walk) => {
|
|
78
|
+
const allowed = rules.siblings;
|
|
79
|
+
if (allowed === undefined || element.isAlternative)
|
|
80
|
+
return;
|
|
81
|
+
const real = walk.real(element.name);
|
|
82
|
+
for (const sibling of siblings) {
|
|
83
|
+
const other = walk.real(sibling.name);
|
|
84
|
+
const isFine = sibling.isAlternative || other === real || !isComponent(other) || isListedName(allowed, other);
|
|
85
|
+
if (!isFine && (walk.isAdded(element.line) || walk.isAdded(sibling.line))) {
|
|
86
|
+
walk.found.push({
|
|
87
|
+
line: sibling.line,
|
|
88
|
+
value: real,
|
|
89
|
+
message: `${real} stands beside ${allowed.join(" or ")}, not ${other}.`
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
/** What one element breaks, standing where it stands. */
|
|
95
|
+
const checkElement = (element, { ancestors, siblings }, walk) => {
|
|
96
|
+
const { name, line, children, isOutOfSight: isHidden } = element;
|
|
97
|
+
const isAdded = walk.isAdded(line);
|
|
98
|
+
const standIn = walk.standIn.get(name);
|
|
99
|
+
if (isAdded && standIn !== undefined && !isHidden) {
|
|
100
|
+
walk.found.push({ line, value: name, fix: standIn, message: `A plain <${name}>: use ${standIn}.` });
|
|
101
|
+
}
|
|
102
|
+
const rules = walk.rulesOf(name);
|
|
103
|
+
if (rules === undefined)
|
|
104
|
+
return;
|
|
105
|
+
const real = walk.real(name);
|
|
106
|
+
if (isAdded)
|
|
107
|
+
checkParents({ real, line }, ancestors, rules, walk);
|
|
108
|
+
checkChildren(real, children, rules, walk);
|
|
109
|
+
checkSiblings(element, siblings, rules, walk);
|
|
110
|
+
};
|
|
111
|
+
/** Walks elements with what stands above and beside each. */
|
|
112
|
+
const walked = (elements, ancestors, walk) => {
|
|
113
|
+
for (const element of elements) {
|
|
114
|
+
checkElement(element, { ancestors, siblings: elements.filter((each) => each !== element) }, walk);
|
|
115
|
+
walked(element.children, [...ancestors, walk.real(element.name)], walk);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* The rules of each name. A name the project gives twice with different rules could be either, and one component of it
|
|
120
|
+
* with none says the rules may not be meant for this use, so neither counts; copies that agree do.
|
|
121
|
+
*/
|
|
122
|
+
const rulesByName = (components) => {
|
|
123
|
+
const named = new Map();
|
|
124
|
+
for (const each of components) {
|
|
125
|
+
const list = named.get(each.name);
|
|
126
|
+
if (list === undefined)
|
|
127
|
+
named.set(each.name, [each]);
|
|
128
|
+
else
|
|
129
|
+
list.push(each);
|
|
130
|
+
}
|
|
131
|
+
return new Map([...named].flatMap(([name, list]) => {
|
|
132
|
+
const [first] = list;
|
|
133
|
+
const written = new Set(list.map((each) => JSON.stringify(each.rules ?? null)));
|
|
134
|
+
return written.size === 1 && first?.rules !== undefined ? [[name, first.rules]] : [];
|
|
135
|
+
}));
|
|
136
|
+
};
|
|
137
|
+
/** What each name renders, whichever component of the name: looked up for every element of a change. */
|
|
138
|
+
const rendersByName = (components) => {
|
|
139
|
+
const renders = new Map();
|
|
140
|
+
for (const { name, renders: own } of components) {
|
|
141
|
+
const list = renders.get(name);
|
|
142
|
+
if (list === undefined)
|
|
143
|
+
renders.set(name, [...own]);
|
|
144
|
+
else
|
|
145
|
+
list.push(...own);
|
|
146
|
+
}
|
|
147
|
+
return renders;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Whether a file is in a component's own library, whose files are what the stand-in is made of: its folder, or the folder
|
|
151
|
+
* above when each component has a folder of its own (`ui/button/Button.tsx`).
|
|
152
|
+
*/
|
|
153
|
+
const isInLibraryOf = (component, file) => {
|
|
154
|
+
const folder = dirname(component);
|
|
155
|
+
const isOwnFolder = basename(component)
|
|
156
|
+
.replace(/\.[^.]+$/, "")
|
|
157
|
+
.toLowerCase() === basename(folder).toLowerCase();
|
|
158
|
+
return file.startsWith(`${isOwnFolder ? dirname(folder) : folder}/`);
|
|
159
|
+
};
|
|
160
|
+
/** The walk for one file, its imports followed. */
|
|
161
|
+
const walkOf = ({ file, program, lines }, { components, ruled, renders, packages }) => {
|
|
162
|
+
const added = new Set(lines.map(({ line }) => line));
|
|
163
|
+
const imported = localNames(program);
|
|
164
|
+
const real = (written) => {
|
|
165
|
+
const [head = "", ...rest] = written.split(".");
|
|
166
|
+
return [imported.get(head)?.name ?? head, ...rest].join(".");
|
|
167
|
+
};
|
|
168
|
+
const rulesOf = (written) => {
|
|
169
|
+
const module = imported.get(written.split(".")[0] ?? "")?.module;
|
|
170
|
+
if (module !== undefined && isThirdParty(module, packages))
|
|
171
|
+
return undefined;
|
|
172
|
+
const name = real(written);
|
|
173
|
+
return ruled.get(name) ?? ruled.get(name.split(".").at(-1) ?? "");
|
|
174
|
+
};
|
|
175
|
+
return {
|
|
176
|
+
rulesOf,
|
|
177
|
+
real,
|
|
178
|
+
standIn: new Map(components.flatMap((each) => isInLibraryOf(each.file, file) || each.rules?.insteadOf === undefined
|
|
179
|
+
? []
|
|
180
|
+
: each.rules.insteadOf.map((element) => [element, each.name]))),
|
|
181
|
+
rendersAny: (name, wanted) => (renders.get(name) ?? []).some((each) => wanted.includes(each) || (renders.get(each) ?? []).some((inner) => wanted.includes(inner))),
|
|
182
|
+
isAdded: (line) => added.has(line),
|
|
183
|
+
found: []
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
/** What composition found in one file, with what a comment excuses set apart. */
|
|
187
|
+
const inFile = ({ file, text }, lines, system) => {
|
|
188
|
+
if (!SCRIPT_FILE.test(file) || isTooDeep(text))
|
|
189
|
+
return { problems: [], excused: [] };
|
|
190
|
+
const { program, errors } = parseSync(file, text);
|
|
191
|
+
if (errors.length > 0)
|
|
192
|
+
return { problems: [], excused: [] };
|
|
193
|
+
const walk = walkOf({ file, program, lines }, system);
|
|
194
|
+
for (const root of rootsOf(program, lineStarts(text)))
|
|
195
|
+
walked(root, [], walk);
|
|
196
|
+
const reasons = new Map(lines.flatMap(({ line, text: written }) => {
|
|
197
|
+
const reason = IGNORE.exec(written)?.[1];
|
|
198
|
+
return reason === undefined
|
|
199
|
+
? []
|
|
200
|
+
: [
|
|
201
|
+
[line, reason.trim()],
|
|
202
|
+
[line + 1, reason.trim()]
|
|
203
|
+
];
|
|
204
|
+
}));
|
|
205
|
+
return {
|
|
206
|
+
problems: walk.found
|
|
207
|
+
.filter(({ line }) => !reasons.has(line))
|
|
208
|
+
.map(({ line, value, fix, message }) => ({
|
|
209
|
+
rule: "composition",
|
|
210
|
+
file,
|
|
211
|
+
line,
|
|
212
|
+
value,
|
|
213
|
+
...(fix === undefined ? {} : { fix }),
|
|
214
|
+
message
|
|
215
|
+
})),
|
|
216
|
+
excused: walk.found.flatMap(({ line, value }) => {
|
|
217
|
+
const reason = reasons.get(line);
|
|
218
|
+
return reason === undefined
|
|
219
|
+
? []
|
|
220
|
+
: [{ file, line, rule: "composition", reason: `${value}: ${reason}` }];
|
|
221
|
+
})
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* What a change writes against how the system says its components fit together.
|
|
226
|
+
*
|
|
227
|
+
* @param added - the lines it adds.
|
|
228
|
+
* @param changed - the changed files as they are now.
|
|
229
|
+
* @param components - every component of the project.
|
|
230
|
+
* @param packages - the repository's packages, to tell a third party's component of the same name; none by default.
|
|
231
|
+
*/
|
|
232
|
+
export const compositionFindings = (added, changed, components, packages = []) => {
|
|
233
|
+
if (!components.some((each) => each.rules !== undefined))
|
|
234
|
+
return { problems: [], excused: [] };
|
|
235
|
+
const system = {
|
|
236
|
+
components,
|
|
237
|
+
ruled: rulesByName(components),
|
|
238
|
+
renders: rendersByName(components),
|
|
239
|
+
packages
|
|
240
|
+
};
|
|
241
|
+
const found = changed.map((file) => inFile(file, added.filter((line) => line.file === file.file), system));
|
|
242
|
+
return { problems: found.flatMap((each) => each.problems), excused: found.flatMap((each) => each.excused) };
|
|
243
|
+
};
|
|
@@ -16,6 +16,7 @@ import type { ForgebookPlugin } from "../plugin.ts";
|
|
|
16
16
|
import type { ShellOptions } from "../shellTheme.types.ts";
|
|
17
17
|
import type { ViewSwitch } from "../switches.ts";
|
|
18
18
|
import type { FrameworkAdapter } from "./adapter.ts";
|
|
19
|
+
import type { AppBuildOption } from "./appBuildOption.ts";
|
|
19
20
|
import type { FramesOption } from "./framesConfig.ts";
|
|
20
21
|
/** What a library's preset gives a catalogue. */
|
|
21
22
|
export type ForgebookPreset = CatalogueLists & {
|
|
@@ -31,6 +32,40 @@ export type ForgebookPreset = CatalogueLists & {
|
|
|
31
32
|
readonly head?: string;
|
|
32
33
|
/** The shell's look, under the catalogue's: its theme, and a style sheet by absolute path. */
|
|
33
34
|
readonly shell?: ShellOptions;
|
|
35
|
+
/**
|
|
36
|
+
* Custom controls of the props panel it brings to every catalogue that lists it, by name, each module by absolute path
|
|
37
|
+
* or a package's specifier: a catalogue's registration of the same name replaces it. They run in the catalogue's page
|
|
38
|
+
* with a plugin's trust, as the catalogue's own do.
|
|
39
|
+
*/
|
|
40
|
+
readonly argControls?: Readonly<Record<string, string | ArgControlOption>>;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Which props a custom control takes without a story naming it: each field given must hold, so `{ typeName, propName }`
|
|
44
|
+
* takes only that prop of that type.
|
|
45
|
+
*/
|
|
46
|
+
export type ArgControlMatch = {
|
|
47
|
+
/**
|
|
48
|
+
* The type's name as the props are read: as the source writes it (`IconComponent`), or any alias it is declared
|
|
49
|
+
* through (`type ButtonIcon = IconComponent`), without `undefined` and `null`; a union only when every member goes by it.
|
|
50
|
+
*/
|
|
51
|
+
readonly typeName?: string;
|
|
52
|
+
/** The prop's name (`icon`). */
|
|
53
|
+
readonly propName?: string;
|
|
54
|
+
};
|
|
55
|
+
/** A custom control with more than its module: its frame module, and the props it takes on its own. */
|
|
56
|
+
export type ArgControlOption = {
|
|
57
|
+
/** The module the panel draws it with, exporting `mount` and `schema`. */
|
|
58
|
+
readonly module: string;
|
|
59
|
+
/**
|
|
60
|
+
* A module of the stories' frames exporting `toStoryValue(value, argType)`, which turns the panel's JSON value into
|
|
61
|
+
* what the story receives (a name into an icon); none gives the story the JSON value.
|
|
62
|
+
*/
|
|
63
|
+
readonly frame?: string;
|
|
64
|
+
/**
|
|
65
|
+
* The props it is the control of in every story that names no control for them, by type or by name; one or a list,
|
|
66
|
+
* of which any may match. A match by name wins over one by type, then the catalogue's controls over its presets'.
|
|
67
|
+
*/
|
|
68
|
+
readonly matches?: ArgControlMatch | readonly ArgControlMatch[];
|
|
34
69
|
};
|
|
35
70
|
/** A tokens file: its path from the configuration's folder, with its theme when it is a theme's. */
|
|
36
71
|
export type TokensFile = StoryTokensFile;
|
|
@@ -74,9 +109,18 @@ export type ForgebookConfig = CatalogueLists & {
|
|
|
74
109
|
/**
|
|
75
110
|
* Its design tokens, DTCG 2025.10 files by path from the configuration's folder, the base first; a theme is a file of
|
|
76
111
|
* its own (`["tokens.json", { file: "dark.tokens.json", mode: "dark" }]`). What tools and agents read tokens from,
|
|
77
|
-
* after each source's: a name given twice takes the catalogue's value, and tools report the clash.
|
|
112
|
+
* after each source's: a name given twice takes the catalogue's value, and tools report the clash. With none named here
|
|
113
|
+
* or on a source, what the application already declares is read instead (custom properties, Tailwind, `components.json`);
|
|
114
|
+
* `[]` says there is no system, so nothing is.
|
|
78
115
|
*/
|
|
79
116
|
readonly tokens?: readonly TokensFile[];
|
|
117
|
+
/**
|
|
118
|
+
* Custom controls of the props panel, by the name a story's `argTypes` use (`{ rating: "./controls/rating.ts" }`): each a
|
|
119
|
+
* module, by path from the configuration's folder or a package's specifier, exporting `mount` and `schema`, or an
|
|
120
|
+
* `ArgControlOption` with a frame module and the props it matches. It loads when a story's panel shows it, and runs in
|
|
121
|
+
* the shell's page with a plugin's trust. A name its presets register is replaced; `false` removes theirs.
|
|
122
|
+
*/
|
|
123
|
+
readonly argControls?: Readonly<Record<string, string | ArgControlOption | false>>;
|
|
80
124
|
/** Its preview's path from the configuration's folder; `forgebook.preview.ts` (or `.tsx`) beside it when there. */
|
|
81
125
|
readonly preview?: string;
|
|
82
126
|
/** Tags for every frame's `<head>` (a font's link); none by default. */
|
|
@@ -95,6 +139,28 @@ export type ForgebookConfig = CatalogueLists & {
|
|
|
95
139
|
readonly frames?: FramesOption;
|
|
96
140
|
/** How `forgebook build` writes the catalogue. */
|
|
97
141
|
readonly build?: BuildOptions;
|
|
142
|
+
/**
|
|
143
|
+
* How much of the app's own build its stories are drawn with: `tsconfig.json`'s `paths`, the `vite.config` beside this
|
|
144
|
+
* file (its aliases, its plugins except the framework's and those only an app's build needs) and its PostCSS. All by
|
|
145
|
+
* default; loading a `vite.config` or a `postcss.config` runs its code, as the app's build does. `false` reads none,
|
|
146
|
+
* and each part can be turned off.
|
|
147
|
+
*/
|
|
148
|
+
readonly appBuild?: AppBuildOption;
|
|
149
|
+
/**
|
|
150
|
+
* Other catalogues, built and deployed, shown in the sidebar after this one's stories, by an id of lower-case words
|
|
151
|
+
* (`{ "design-system": { title: "Design system", url: "https://ds.example.com/" } }`). Each is read from the index
|
|
152
|
+
* its `forgebook build --agent-index` writes, when its section is first opened, and its stories are drawn by its own
|
|
153
|
+
* page on its own origin, read-only, with this catalogue's switches. Its host must let this catalogue fetch the index
|
|
154
|
+
* (CORS) and frame its page. None by default.
|
|
155
|
+
*/
|
|
156
|
+
readonly refs?: Readonly<Record<string, RefOption>>;
|
|
157
|
+
};
|
|
158
|
+
/** A catalogue shown in another's sidebar (`refs`). */
|
|
159
|
+
export type RefOption = {
|
|
160
|
+
/** Its name, as its section's heading. */
|
|
161
|
+
readonly title: string;
|
|
162
|
+
/** The address it is served at, its folder (`https://ds.example.com/catalogue/`). */
|
|
163
|
+
readonly url: string;
|
|
98
164
|
};
|
|
99
165
|
/** How `forgebook build` writes the catalogue. */
|
|
100
166
|
export type BuildOptions = {
|
|
@@ -10,12 +10,15 @@
|
|
|
10
10
|
* @module
|
|
11
11
|
*/
|
|
12
12
|
import type { StoryLanguage } from "@forgebook/story-format/source";
|
|
13
|
-
import type
|
|
13
|
+
import { type CatalogueLists } from "../catalogue.ts";
|
|
14
14
|
import type { ForgebookPlugin } from "../plugin.ts";
|
|
15
15
|
import { type ViewSwitch } from "../switches.ts";
|
|
16
16
|
import type { FrameworkAdapter } from "./adapter.ts";
|
|
17
|
+
import { type ResolvedAppBuild } from "./appBuildOption.ts";
|
|
18
|
+
import { type ResolvedArgControls } from "./argControlsConfig.ts";
|
|
17
19
|
import type { BuildOptions, ForgebookConfig } from "./config.ts";
|
|
18
20
|
import { type ResolvedFrames } from "./framesConfig.ts";
|
|
21
|
+
import { type ResolvedRefs } from "./refsConfig.ts";
|
|
19
22
|
import { type VitePaths } from "./vitePaths.ts";
|
|
20
23
|
/** The names a configuration file may have, in the order they are looked for. */
|
|
21
24
|
export declare const CONFIG_FILES: string[];
|
|
@@ -24,6 +27,8 @@ export declare const CONFIG_FILES: string[];
|
|
|
24
27
|
* keeps for another reason never replaces the generated home of a catalogue that did not ask for it.
|
|
25
28
|
*/
|
|
26
29
|
export declare const HOME_FILE = "forgebook.home.md";
|
|
30
|
+
/** The names a preview may have beside the configuration, in the order they are looked for. */
|
|
31
|
+
export declare const PREVIEW_FILES: string[];
|
|
27
32
|
/** The shell's look, ready for its page. */
|
|
28
33
|
export type ResolvedShell = {
|
|
29
34
|
/** The theme, as CSS; empty for none. */
|
|
@@ -79,6 +84,10 @@ export type ResolvedConfig = {
|
|
|
79
84
|
readonly shell: ResolvedShell;
|
|
80
85
|
/** The tokens files, absolute, the base first. */
|
|
81
86
|
readonly tokens: readonly ResolvedTokensFile[];
|
|
87
|
+
/** Whether the configuration says `tokens: []`: no system at all, so the application's own files are not read for one. */
|
|
88
|
+
readonly isAppTokensOff?: boolean;
|
|
89
|
+
/** The custom controls by name, the catalogue's and its presets', in their precedence. */
|
|
90
|
+
readonly argControls: ResolvedArgControls;
|
|
82
91
|
/** The folders the dev server watches for new story files, absolute. */
|
|
83
92
|
readonly watch: readonly string[];
|
|
84
93
|
/** The lists (widths, backgrounds, story groups…), the presets' and the catalogue's merged. */
|
|
@@ -89,8 +98,12 @@ export type ResolvedConfig = {
|
|
|
89
98
|
readonly plugins: readonly ForgebookPlugin[];
|
|
90
99
|
/** Where the stories' frames run. */
|
|
91
100
|
readonly frames: ResolvedFrames;
|
|
101
|
+
/** The catalogues shown in the sidebar after this one's stories, in the configuration's order. */
|
|
102
|
+
readonly refs: ResolvedRefs;
|
|
92
103
|
/** How `forgebook build` writes the catalogue, every option given its default. */
|
|
93
104
|
readonly build: Required<BuildOptions>;
|
|
105
|
+
/** How much of the app's own build its stories are drawn with. */
|
|
106
|
+
readonly appBuild: ResolvedAppBuild;
|
|
94
107
|
};
|
|
95
108
|
/** The packages of the play tools: both installed, or the plays get neither. */
|
|
96
109
|
export declare const PLAY_TOOLS_PACKAGES: readonly ["@testing-library/dom", "@testing-library/user-event"];
|
|
@@ -110,7 +123,7 @@ export declare const findConfigFile: (dir: string) => string | undefined;
|
|
|
110
123
|
* The lists of the presets and the catalogue, in that order, merged: a single value (a width range, the grid's step)
|
|
111
124
|
* the last that gives one; the backgrounds, the story groups and the texts entry by entry, a later one replacing an
|
|
112
125
|
* earlier one with the same id or name; the tabs, the controls and the rules turned off by any, and the accessibility
|
|
113
|
-
* check too (`a11y: false`); the toolbar, the prop groups' order, where the required props go and whether the
|
|
126
|
+
* check too (`a11y: false`); the statuses status by status and field by field; the toolbar, the prop groups' order, where the required props go and whether the
|
|
114
127
|
* component docs are read the last that names one; the device field by field.
|
|
115
128
|
*
|
|
116
129
|
* @param all - the presets' lists, then the catalogue's.
|
|
@@ -19,16 +19,25 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
19
19
|
};
|
|
20
20
|
import { existsSync, statSync } from "node:fs";
|
|
21
21
|
import { createRequire } from "node:module";
|
|
22
|
-
import { dirname, resolve } from "node:path";
|
|
22
|
+
import { dirname, join, resolve } from "node:path";
|
|
23
23
|
import { pathToFileURL } from "node:url";
|
|
24
24
|
import { AUDIENCE_IDS } from "../audiences.js";
|
|
25
|
+
import { catalogueSettings, playProblem } from "../catalogue.js";
|
|
25
26
|
import { deviceSettingProblem } from "../deviceView.js";
|
|
26
27
|
import { REQUIRED_FIRST_LAYOUTS } from "../propGroups.js";
|
|
27
28
|
import { frameThemeCss, mergedThemes, shellThemeCss, shellThemeProblems, themeValueProblem } from "../shellTheme.js";
|
|
28
|
-
import {
|
|
29
|
+
import { mergedStatuses, statusesProblem } from "../storyStatuses.js";
|
|
30
|
+
import { catalogueSwitches, switchesProblem } from "../switches.js";
|
|
31
|
+
import { appBuildProblem, resolvedAppBuild } from "./appBuildOption.js";
|
|
32
|
+
import { resolvedArgControls } from "./argControlsConfig.js";
|
|
33
|
+
import { saysNoTokens, unknownKeysProblem } from "./configKeys.js";
|
|
34
|
+
import { configLoadMessage } from "./configLoadError.js";
|
|
29
35
|
import { framesProblem, resolvedFrames } from "./framesConfig.js";
|
|
30
36
|
import { pluginsProblem, withPluginSwitches } from "./pluginConfig.js";
|
|
31
|
-
import {
|
|
37
|
+
import { realFolder } from "./realFolder.js";
|
|
38
|
+
import { refsProblem, resolvedRefs } from "./refsConfig.js";
|
|
39
|
+
import { filesProblem } from "./storyPatterns.js";
|
|
40
|
+
import { switchValuesProblem, withAbsoluteValueFiles } from "./switchValuesCheck.js";
|
|
32
41
|
import { tokenThemeOf } from "./themeFromTokens.js";
|
|
33
42
|
import { VITE_PATHS } from "./vitePaths.js";
|
|
34
43
|
/** The names a configuration file may have, in the order they are looked for. */
|
|
@@ -39,15 +48,38 @@ export const CONFIG_FILES = ["forgebook.config.ts", "forgebook.config.mts", "for
|
|
|
39
48
|
*/
|
|
40
49
|
export const HOME_FILE = "forgebook.home.md";
|
|
41
50
|
/** The names a preview may have beside the configuration, in the order they are looked for. */
|
|
42
|
-
const PREVIEW_FILES = ["forgebook.preview.ts", "forgebook.preview.tsx", "forgebook.preview.js"];
|
|
51
|
+
export const PREVIEW_FILES = ["forgebook.preview.ts", "forgebook.preview.tsx", "forgebook.preview.js"];
|
|
43
52
|
/** The packages of the play tools: both installed, or the plays get neither. */
|
|
44
53
|
export const PLAY_TOOLS_PACKAGES = ["@testing-library/dom", "@testing-library/user-event"];
|
|
54
|
+
/**
|
|
55
|
+
* Whether a package's folder is in the `node_modules` folders going up from a folder. Node also reads `NODE_PATH`, which
|
|
56
|
+
* pnpm's command shims point at its own store's hoisted packages, and Vite does not: a package found that way alone is one
|
|
57
|
+
* Vite then fails on, for every story.
|
|
58
|
+
*
|
|
59
|
+
* @param dir - the folder.
|
|
60
|
+
* @param name - the package or one of its subpaths.
|
|
61
|
+
*/
|
|
62
|
+
const isUnderNodeModules = (dir, name) => {
|
|
63
|
+
const parts = name.split("/");
|
|
64
|
+
const packageName = parts.slice(0, name.startsWith("@") ? 2 : 1).join("/");
|
|
65
|
+
let current = resolve(dir);
|
|
66
|
+
while (true) {
|
|
67
|
+
if (existsSync(join(current, "node_modules", packageName)))
|
|
68
|
+
return true;
|
|
69
|
+
const parent = dirname(current);
|
|
70
|
+
if (parent === current)
|
|
71
|
+
return false;
|
|
72
|
+
current = parent;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
45
75
|
/**
|
|
46
76
|
* Resolves packages as Node does from a folder: a package's (or subpath's) file, or none when it is not there.
|
|
47
77
|
*
|
|
48
78
|
* @param dir - the folder, the configuration's.
|
|
49
79
|
*/
|
|
50
80
|
export const packageResolver = (dir) => (name) => {
|
|
81
|
+
if (!isUnderNodeModules(dir, name))
|
|
82
|
+
return undefined;
|
|
51
83
|
const require = createRequire(resolve(dir, "package.json"));
|
|
52
84
|
try {
|
|
53
85
|
return require.resolve(name);
|
|
@@ -102,13 +134,26 @@ const singleValues = (lists) => ({
|
|
|
102
134
|
...(lists.audience === undefined ? {} : { audience: lists.audience }),
|
|
103
135
|
...(lists.appearance === undefined ? {} : { appearance: lists.appearance }),
|
|
104
136
|
...(lists.propGroups === undefined ? {} : { propGroups: lists.propGroups }),
|
|
105
|
-
...(lists.requiredFirst === undefined ? {} : { requiredFirst: lists.requiredFirst })
|
|
137
|
+
...(lists.requiredFirst === undefined ? {} : { requiredFirst: lists.requiredFirst }),
|
|
138
|
+
...(lists.play === undefined ? {} : { play: lists.play })
|
|
106
139
|
});
|
|
140
|
+
/**
|
|
141
|
+
* Checks a list's statuses, which a configuration writes by JavaScript too, where no type stops a mistake.
|
|
142
|
+
*
|
|
143
|
+
* @param statuses - the statuses written.
|
|
144
|
+
* @param dir - the configuration's folder, for the message.
|
|
145
|
+
* @throws when a status cannot be used.
|
|
146
|
+
*/
|
|
147
|
+
const checkStatuses = (statuses, dir) => {
|
|
148
|
+
const problem = statusesProblem(statuses);
|
|
149
|
+
if (problem !== undefined)
|
|
150
|
+
throw new Error(`${resolve(dir, "forgebook.config")}: ${problem}`);
|
|
151
|
+
};
|
|
107
152
|
/**
|
|
108
153
|
* The lists of the presets and the catalogue, in that order, merged: a single value (a width range, the grid's step)
|
|
109
154
|
* the last that gives one; the backgrounds, the story groups and the texts entry by entry, a later one replacing an
|
|
110
155
|
* earlier one with the same id or name; the tabs, the controls and the rules turned off by any, and the accessibility
|
|
111
|
-
* check too (`a11y: false`); the toolbar, the prop groups' order, where the required props go and whether the
|
|
156
|
+
* check too (`a11y: false`); the statuses status by status and field by field; the toolbar, the prop groups' order, where the required props go and whether the
|
|
112
157
|
* component docs are read the last that names one; the device field by field.
|
|
113
158
|
*
|
|
114
159
|
* @param all - the presets' lists, then the catalogue's.
|
|
@@ -152,27 +197,14 @@ export const mergedLists = (all) => {
|
|
|
152
197
|
},
|
|
153
198
|
strings,
|
|
154
199
|
keys,
|
|
200
|
+
...mergedStatuses(all.map((lists) => lists.statuses)),
|
|
155
201
|
// a later list's view of the same name replaces an earlier one's, where it was
|
|
156
202
|
views: [...new Map(all.flatMap((lists) => lists.views ?? []).map((view) => [view.name, view])).values()]
|
|
157
203
|
};
|
|
158
204
|
};
|
|
159
|
-
/**
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
return Array.isArray(list) && list.length > 0;
|
|
163
|
-
};
|
|
164
|
-
/**
|
|
165
|
-
* Why a configuration's list of globs lists nothing by construction (only `!` patterns), or none.
|
|
166
|
-
*
|
|
167
|
-
* @param config - what the file exports by default.
|
|
168
|
-
* @param key - the list's key.
|
|
169
|
-
*/
|
|
170
|
-
const globsProblem = (config, key) => {
|
|
171
|
-
const list = Reflect.get(config, key);
|
|
172
|
-
return Array.isArray(list)
|
|
173
|
-
? patternsProblem(list.filter((item) => typeof item === "string"))
|
|
174
|
-
: undefined;
|
|
175
|
-
};
|
|
205
|
+
/** Why where its frames run or what it reads of the app's build cannot be used, or none. */
|
|
206
|
+
const placementProblem = (config) => framesProblem("frames" in config ? config.frames : undefined) ??
|
|
207
|
+
appBuildProblem("appBuild" in config ? config.appBuild : undefined);
|
|
176
208
|
/**
|
|
177
209
|
* Why a loaded configuration cannot be used, or none.
|
|
178
210
|
*
|
|
@@ -181,6 +213,10 @@ const globsProblem = (config, key) => {
|
|
|
181
213
|
const configProblem = (config) => {
|
|
182
214
|
if (typeof config !== "object" || config === null)
|
|
183
215
|
return "it exports no configuration (`export default defineConfig({ … })`)";
|
|
216
|
+
// first: a misspelt `title` or `framework` is better named as such than as one left out
|
|
217
|
+
const keysProblem = unknownKeysProblem(config);
|
|
218
|
+
if (keysProblem !== undefined)
|
|
219
|
+
return keysProblem;
|
|
184
220
|
if (!("framework" in config) || typeof config.framework !== "object" || config.framework === null)
|
|
185
221
|
return "it names no framework (`framework: react()`)";
|
|
186
222
|
if (!("title" in config) || typeof config.title !== "string")
|
|
@@ -190,14 +226,7 @@ const configProblem = (config) => {
|
|
|
190
226
|
config.home !== false &&
|
|
191
227
|
typeof config.home !== "string")
|
|
192
228
|
return 'its home is neither a path (`home: "docs/home.md"`) nor false';
|
|
193
|
-
|
|
194
|
-
return 'it names no stories (`stories: ["src/**/*.stories.tsx"]`) and no sources';
|
|
195
|
-
for (const key of ["stories", "docs"]) {
|
|
196
|
-
const problem = globsProblem(config, key);
|
|
197
|
-
if (problem !== undefined)
|
|
198
|
-
return `its ${key} list nothing: ${problem}`;
|
|
199
|
-
}
|
|
200
|
-
return framesProblem("frames" in config ? config.frames : undefined);
|
|
229
|
+
return filesProblem(config) ?? placementProblem(config) ?? refsProblem(config);
|
|
201
230
|
};
|
|
202
231
|
/**
|
|
203
232
|
* Whether a loaded configuration is one: checked by `configProblem`.
|
|
@@ -240,18 +269,19 @@ const deviceProblem = (device) => {
|
|
|
240
269
|
/**
|
|
241
270
|
* The configuration's and the presets' lists, once checked where the shell would leave a mistake out: a device that
|
|
242
271
|
* cannot be used, a place for the required props that is none, an accessibility setting that is neither rules nor
|
|
243
|
-
* `false
|
|
272
|
+
* `false`, a status that is no tag of the catalogue's or reads wrongly.
|
|
244
273
|
*
|
|
245
274
|
* @param all - the presets' lists, then the configuration's.
|
|
246
275
|
* @param dir - the configuration's folder, for the message.
|
|
247
|
-
* @throws when a device cannot be used, `requiredFirst` is none of its layouts,
|
|
248
|
-
* `false
|
|
276
|
+
* @throws when a device cannot be used, `requiredFirst` is none of its layouts, `a11y` is neither rules nor
|
|
277
|
+
* `false`, or a status cannot be used.
|
|
249
278
|
*/
|
|
250
279
|
const checkedLists = (all, dir) => {
|
|
251
280
|
for (const lists of all) {
|
|
252
281
|
const problem = lists.device === undefined ? undefined : deviceProblem(lists.device);
|
|
253
282
|
if (problem !== undefined)
|
|
254
283
|
throw new Error(`${resolve(dir, "forgebook.config")}: Forgebook's device: ${problem}`);
|
|
284
|
+
checkStatuses(lists.statuses, dir);
|
|
255
285
|
// a configuration is written by JavaScript too, which no type stops
|
|
256
286
|
if (lists.requiredFirst !== undefined && !REQUIRED_FIRST_LAYOUTS.includes(lists.requiredFirst))
|
|
257
287
|
throw new Error(`${resolve(dir, "forgebook.config")}: requiredFirst is ${typeof lists.requiredFirst === "string" ? `"${lists.requiredFirst}"` : String(lists.requiredFirst)}, none of "in-groups", "section" and false`);
|
|
@@ -275,7 +305,29 @@ const mergedListsProblem = (lists) => {
|
|
|
275
305
|
return `the audience "${lists.audience}" is none of ${AUDIENCE_IDS.join(", ")}`;
|
|
276
306
|
if (lists.usedIn === true && lists.componentDocs === false)
|
|
277
307
|
return "usedIn is true with componentDocs false: Used in reads the import graph with the programs componentDocs turns off";
|
|
278
|
-
return
|
|
308
|
+
return playProblem(lists.play);
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* What the shell would refuse when it starts, refused on Node instead: a toolbar naming no control, a key that cannot be
|
|
312
|
+
* used, a view that cannot be read. Without this a command or a build succeeds, and the mistake surfaces as a blank page
|
|
313
|
+
* in a reader's browser. The same call the shell makes (`catalogueContext.ts`), so both refuse the same things.
|
|
314
|
+
*
|
|
315
|
+
* @param resolved - the configuration's merged title, switches, languages, lists and plugins, with its folder.
|
|
316
|
+
* @throws what the shell would, with the configuration's name.
|
|
317
|
+
*/
|
|
318
|
+
const checkSettings = (resolved) => {
|
|
319
|
+
const { dir, title, switches, languages, lists, plugins } = resolved;
|
|
320
|
+
try {
|
|
321
|
+
const shown = catalogueSwitches(switches, languages, lists.controls);
|
|
322
|
+
const problem = switchValuesProblem(shown, dir);
|
|
323
|
+
if (problem !== undefined)
|
|
324
|
+
throw new Error(problem);
|
|
325
|
+
catalogueSettings(title, shown, lists, plugins.flatMap((plugin) => (plugin.tabs ?? []).map((tab) => tab.id)));
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
329
|
+
throw new Error(`${resolve(dir, "forgebook.config")}: ${message}`);
|
|
330
|
+
}
|
|
279
331
|
};
|
|
280
332
|
/** What a catalogue shows: its own stories and docs pages, and the sources; none where it names none. */
|
|
281
333
|
const shownFiles = (config) => ({
|
|
@@ -357,6 +409,8 @@ export const resolveConfig = (config, fileDir, paths = VITE_PATHS) => {
|
|
|
357
409
|
const themeProblem = themeValueProblem(theme);
|
|
358
410
|
if (themeProblem !== undefined)
|
|
359
411
|
throw new Error(`${resolve(dir, "forgebook.config")}: ${themeProblem}`);
|
|
412
|
+
const languages = mergedById([...presets.map((preset) => preset.languages), config.languages]);
|
|
413
|
+
checkSettings({ dir, title: config.title, switches, languages, lists, plugins });
|
|
360
414
|
const ownPreview = config.preview === undefined
|
|
361
415
|
? PREVIEW_FILES.map((name) => paths.join(dir, name)).find((file) => existsSync(file))
|
|
362
416
|
: absolute(config.preview);
|
|
@@ -368,8 +422,8 @@ export const resolveConfig = (config, fileDir, paths = VITE_PATHS) => {
|
|
|
368
422
|
logo: config.logo === undefined ? undefined : absolute(config.logo),
|
|
369
423
|
heights: config.heights,
|
|
370
424
|
...shownFiles(config),
|
|
371
|
-
switches,
|
|
372
|
-
languages
|
|
425
|
+
switches: switches === undefined ? undefined : withAbsoluteValueFiles(switches, dir, paths),
|
|
426
|
+
languages,
|
|
373
427
|
previews: [
|
|
374
428
|
...presets.flatMap((preset) => (preset.preview === undefined ? [] : [ownPath(preset.preview)])),
|
|
375
429
|
...(ownPreview === undefined ? [] : [ownPreview])
|
|
@@ -388,12 +442,20 @@ export const resolveConfig = (config, fileDir, paths = VITE_PATHS) => {
|
|
|
388
442
|
problems: [...tokenThemed.problems, ...shellThemeProblems(theme)]
|
|
389
443
|
},
|
|
390
444
|
tokens,
|
|
445
|
+
isAppTokensOff: saysNoTokens(config),
|
|
446
|
+
argControls: resolvedArgControls(config, dir, {
|
|
447
|
+
absolute,
|
|
448
|
+
isAbsolute: paths.isAbsolute,
|
|
449
|
+
normalize: paths.normalize
|
|
450
|
+
}),
|
|
391
451
|
watch: (config.watch ?? []).map(absolute),
|
|
392
452
|
lists,
|
|
393
453
|
hasPlayTools: hasPlayToolsIn(dir),
|
|
394
454
|
plugins,
|
|
395
455
|
frames: resolvedFrames(config.frames),
|
|
396
|
-
|
|
456
|
+
refs: resolvedRefs(config.refs),
|
|
457
|
+
build: { readableNames: config.build?.readableNames === true },
|
|
458
|
+
appBuild: resolvedAppBuild(config.appBuild)
|
|
397
459
|
};
|
|
398
460
|
};
|
|
399
461
|
/**
|
|
@@ -403,9 +465,16 @@ export const resolveConfig = (config, fileDir, paths = VITE_PATHS) => {
|
|
|
403
465
|
* @throws when the file does not load, or exports no usable configuration.
|
|
404
466
|
*/
|
|
405
467
|
export const loadConfigFile = async (file) => {
|
|
406
|
-
|
|
468
|
+
let module;
|
|
469
|
+
try {
|
|
470
|
+
module = await import(__rewriteRelativeImportExtension(pathToFileURL(file).href));
|
|
471
|
+
}
|
|
472
|
+
catch (error) {
|
|
473
|
+
throw new Error(await configLoadMessage(file, error));
|
|
474
|
+
}
|
|
407
475
|
const config = typeof module === "object" && module !== null && "default" in module ? module.default : undefined;
|
|
408
476
|
if (!isConfig(config))
|
|
409
477
|
throw new Error(`${file}: ${configProblem(config) ?? "it cannot be read"}`);
|
|
410
|
-
|
|
478
|
+
// the folder as Vite makes its root, so the pages named under it compare with it
|
|
479
|
+
return resolveConfig(config, realFolder(dirname(file)));
|
|
411
480
|
};
|