forgebook 0.3.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +914 -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 +175 -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 +57 -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 +90 -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 +196 -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 +297 -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 +100 -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 +66 -184
- 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 +71 -0
- package/dist/src/componentDocs.js +15 -2
- 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/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 +7 -1
- package/dist/src/frame/mountFrame.js +153 -46
- 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/CodeTab.d.ts +3 -2
- package/dist/src/shell/CodeTab.js +3 -2
- 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 +1 -1
- package/dist/src/shell/ComponentPage.js +5 -1
- package/dist/src/shell/CustomControl.d.ts +34 -0
- package/dist/src/shell/CustomControl.js +132 -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 +16 -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/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 +23 -2
- package/dist/src/shell/PropRows.js +58 -19
- package/dist/src/shell/PropsTab.d.ts +12 -5
- package/dist/src/shell/PropsTab.js +9 -21
- 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 +137 -22
- 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/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 +55 -0
- package/dist/src/shell/customControls.js +70 -0
- package/dist/src/shell/docPage.css +22 -22
- package/dist/src/shell/dockTabs.d.ts +19 -3
- package/dist/src/shell/dockTabs.js +28 -20
- package/dist/src/shell/embed.css +7 -7
- 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 +29 -0
- package/dist/src/shell/laterStrings.js +42 -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 +348 -168
- 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/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/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 +147 -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 +85 -3
- package/dist/src/storyCheck.js +23 -1
- package/dist/src/storyCodeText.d.ts +46 -0
- package/dist/src/storyCodeText.js +27 -0
- package/dist/src/storyControls.d.ts +100 -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 +347 -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 +106 -65
- package/dist/src/vite/agentStatuses.d.ts +42 -0
- package/dist/src/vite/agentStatuses.js +67 -0
- package/dist/src/vite/agentStoryCode.d.ts +48 -0
- package/dist/src/vite/agentStoryCode.js +38 -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/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 +15 -3
- 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 +32 -1
- package/dist/src/vite/configFile.d.ts +14 -2
- package/dist/src/vite/configFile.js +124 -40
- package/dist/src/vite/configKeys.d.ts +15 -0
- package/dist/src/vite/configKeys.js +171 -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 +52 -72
- 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 +108 -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 +130 -58
- 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/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
|
@@ -129,31 +129,31 @@ export const storyFileIndex = (root, pattern, key) => {
|
|
|
129
129
|
return indexStoryFile(file, readFileSync(file, "utf8"), title === undefined ? {} : { autoTitle: title });
|
|
130
130
|
};
|
|
131
131
|
/**
|
|
132
|
-
* Every story file a group's patterns list, indexed.
|
|
132
|
+
* Every story file a group's patterns list, indexed, and those that cannot be. Only the former are kept between starts:
|
|
133
|
+
* the stamps of the others would only say what is already known, and their next read costs one file.
|
|
133
134
|
*
|
|
134
135
|
* @param root - the declaring module's folder.
|
|
135
136
|
* @param patterns - the patterns (`storyFileKeys`).
|
|
136
|
-
* @param watch - adds a file whose edit renews the module that read it.
|
|
137
|
+
* @param watch - adds a file whose edit renews the module that read it: a refused one too, as its fix must.
|
|
137
138
|
* @param cache - the index kept between starts, which holds while the files it came from do; none reads them all.
|
|
138
139
|
* @param isKept - whether a listed file may be read; every one by default.
|
|
139
|
-
* @throws when a story file cannot be indexed.
|
|
140
140
|
*/
|
|
141
|
-
export const
|
|
141
|
+
export const readStoryFiles = (root, patterns, watch, cache, isKept = EVERY_FILE) => {
|
|
142
142
|
const name = storyFilesGroupText(VITE_PATHS.normalize(root), patterns);
|
|
143
143
|
const since = nowNs();
|
|
144
144
|
const kept = cache?.read(name);
|
|
145
145
|
const listed = listedFiles(root, patterns).filter(({ key }) => isKept(VITE_PATHS.resolve(root, key)));
|
|
146
|
-
const files =
|
|
146
|
+
const files = [];
|
|
147
|
+
const refused = [];
|
|
148
|
+
for (const { key, pattern } of listed) {
|
|
147
149
|
const file = VITE_PATHS.resolve(root, key);
|
|
148
150
|
watch(file);
|
|
149
|
-
const
|
|
150
|
-
if (known !== undefined)
|
|
151
|
-
return { key, pattern, file, index: known };
|
|
152
|
-
const index = storyFileIndex(root, pattern, key);
|
|
151
|
+
const index = kept?.[key] ?? storyFileIndex(root, pattern, key);
|
|
153
152
|
if (typeof index === "string")
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
refused.push({ key, pattern, file, problem: index });
|
|
154
|
+
else
|
|
155
|
+
files.push({ key, pattern, file, index });
|
|
156
|
+
}
|
|
157
157
|
// kept again when anything was read anew: a file added, or the kept index out of date
|
|
158
158
|
if (cache !== undefined && files.some(({ key }) => kept?.[key] === undefined)) {
|
|
159
159
|
const stamps = stampPaths(files.map((each) => each.file));
|
|
@@ -161,7 +161,29 @@ export const indexedStoryFiles = (root, patterns, watch, cache, isKept = EVERY_F
|
|
|
161
161
|
if (isSettledSince(stamps, since))
|
|
162
162
|
cache.write(name, index, stamps);
|
|
163
163
|
}
|
|
164
|
-
return files;
|
|
164
|
+
return { files, refused };
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* What fails a module that cannot go on without its files: every file refused, a line each.
|
|
168
|
+
*
|
|
169
|
+
* @param refused - the files, at least one.
|
|
170
|
+
*/
|
|
171
|
+
export const refusalError = (refused) => new Error(refused.map(({ problem }) => problem).join("\n"));
|
|
172
|
+
/**
|
|
173
|
+
* Every story file a group's patterns list, indexed, for those who cannot go on without one: a build, a test.
|
|
174
|
+
*
|
|
175
|
+
* @param root - the declaring module's folder.
|
|
176
|
+
* @param patterns - the patterns (`storyFileKeys`).
|
|
177
|
+
* @param watch - adds a file whose edit renews the module that read it.
|
|
178
|
+
* @param cache - the index kept between starts, which holds while the files it came from do; none reads them all.
|
|
179
|
+
* @param isKept - whether a listed file may be read; every one by default.
|
|
180
|
+
* @throws when a story file cannot be indexed, naming every one that cannot.
|
|
181
|
+
*/
|
|
182
|
+
export const indexedStoryFiles = (root, patterns, watch, cache, isKept = EVERY_FILE) => {
|
|
183
|
+
const { files, refused } = readStoryFiles(root, patterns, watch, cache, isKept);
|
|
184
|
+
if (refused.length > 0)
|
|
185
|
+
throw refusalError(refused);
|
|
186
|
+
return [...files];
|
|
165
187
|
};
|
|
166
188
|
/**
|
|
167
189
|
* The code of the module for one group.
|
|
@@ -174,6 +196,55 @@ export const indexedStoryFiles = (root, patterns, watch, cache, isKept = EVERY_F
|
|
|
174
196
|
* @returns the module's code, or a message saying which file cannot be indexed.
|
|
175
197
|
*/
|
|
176
198
|
export const storyFilesModule = (root, patterns, watch, loaders = { hasUsage: true, hasReach: true }, cache) => storyFilesCode(root, patterns, indexedStoryFiles(root, patterns, watch, cache), loaders);
|
|
199
|
+
/**
|
|
200
|
+
* The stories a group needs before its stories are written as rows (`indexCode`). Rows write each key once and the
|
|
201
|
+
* objects once per story, but rows need the function that turns them back, which a small group's first load pays for
|
|
202
|
+
* more than it saves: gzip already shares a key repeated in every story. On the generated library, rows cost the shell's
|
|
203
|
+
* first load 11 bytes more at 100 stories and saved 92 at 500, so the two meet near 150; past 300 they save without
|
|
204
|
+
* doubt, and the build's own weight falls by a quarter of the index.
|
|
205
|
+
*/
|
|
206
|
+
export const ROWS_FROM_STORIES = 300;
|
|
207
|
+
/** The function the generated module rebuilds each file's stories with, from their rows. */
|
|
208
|
+
const STORY_TABLE = "storyTable";
|
|
209
|
+
/**
|
|
210
|
+
* The keys of a group's stories, each once, in the order the first story to have each writes it.
|
|
211
|
+
*
|
|
212
|
+
* @param files - the group's story files, indexed.
|
|
213
|
+
*/
|
|
214
|
+
const storyKeysOf = (files) => [
|
|
215
|
+
...new Set(files.flatMap(({ index }) => index.stories.flatMap((story) => Object.keys(story).filter((key) => Reflect.get(story, key) !== undefined))))
|
|
216
|
+
];
|
|
217
|
+
/**
|
|
218
|
+
* A story file's index as code: its stories as rows of values in the group's key order, which the module turns back
|
|
219
|
+
* into the same objects (`STORY_TABLE`), in a group of `ROWS_FROM_STORIES` stories or more.
|
|
220
|
+
*
|
|
221
|
+
* @remarks
|
|
222
|
+
* A catalogue's first load fetches every group's index, and an object per story writes its keys again for every
|
|
223
|
+
* story: on a library of 500 stories, a quarter of the index was the words `exportName` and `description`. A row
|
|
224
|
+
* writes each value once and leaves a key a story does not have as a hole, which the module leaves out of its object
|
|
225
|
+
* as the literal did.
|
|
226
|
+
*
|
|
227
|
+
* @param index - the file's index.
|
|
228
|
+
* @param keys - the group's keys (`storyKeysOf`).
|
|
229
|
+
*/
|
|
230
|
+
const indexCode = (index, keys) => {
|
|
231
|
+
const rows = index.stories.map((story) => {
|
|
232
|
+
const values = keys.map((key) => {
|
|
233
|
+
const value = Reflect.get(story, key);
|
|
234
|
+
return value === undefined ? "" : codeLiteral(value);
|
|
235
|
+
});
|
|
236
|
+
// a story's last keys it does not have are left out: a row ends with its last value, never with a hole
|
|
237
|
+
while (values.at(-1) === "")
|
|
238
|
+
values.pop();
|
|
239
|
+
return `[${values.join(",")}]`;
|
|
240
|
+
});
|
|
241
|
+
const fields = Object.entries(index)
|
|
242
|
+
.filter(([, value]) => value !== undefined)
|
|
243
|
+
.map(([key, value]) => key === "stories"
|
|
244
|
+
? `${codeLiteral(key)}:${STORY_TABLE}([${rows.join(",")}])`
|
|
245
|
+
: `${codeLiteral(key)}:${codeLiteral(value)}`);
|
|
246
|
+
return `{${fields.join(",")}}`;
|
|
247
|
+
};
|
|
177
248
|
/**
|
|
178
249
|
* The code of the module for one group, from its story files indexed.
|
|
179
250
|
*
|
|
@@ -184,8 +255,10 @@ export const storyFilesModule = (root, patterns, watch, loaders = { hasUsage: tr
|
|
|
184
255
|
* @param loaders - the group's loaders besides its story files'.
|
|
185
256
|
* @param hasTexts - a build's: whether each file's docs, code and page come from the group's texts module, in the
|
|
186
257
|
* rows' order (`TEXTS_PREFIX`), and not each from its query.
|
|
258
|
+
* @param refused - the story files it lists that cannot be indexed, which the catalogue names among its problems.
|
|
259
|
+
* @param scriptProblems - the project's other scripts that do not parse, named among them too.
|
|
187
260
|
*/
|
|
188
|
-
export const storyFilesCode = (root, patterns, files, loaders, hasTexts = false) => {
|
|
261
|
+
export const storyFilesCode = (root, patterns, files, loaders, hasTexts = false, refused = [], scriptProblems = []) => {
|
|
189
262
|
const { hasDocs = true, hasUsage, hasReach } = loaders;
|
|
190
263
|
// the group's id in Vite's form, as the plugin names the declaring module's folder
|
|
191
264
|
const folder = VITE_PATHS.normalize(root);
|
|
@@ -208,10 +281,24 @@ export const storyFilesCode = (root, patterns, files, loaders, hasTexts = false)
|
|
|
208
281
|
];
|
|
209
282
|
// a row per file, its name written once and not once per column (its index, each loader): a large catalogue's
|
|
210
283
|
// names are a tenth of its index
|
|
211
|
-
const
|
|
284
|
+
const keys = storyKeysOf(files);
|
|
285
|
+
const isTable = files.reduce((count, { index }) => count + index.stories.length, 0) >= ROWS_FROM_STORIES;
|
|
286
|
+
const rows = files.map(({ key, index }) => [
|
|
287
|
+
codeLiteral(key),
|
|
288
|
+
isTable ? indexCode(index, keys) : codeLiteral(index),
|
|
289
|
+
`() => import(${path(key)})`,
|
|
290
|
+
...textLoaders(key)
|
|
291
|
+
].join(", "));
|
|
212
292
|
const written = `[${rows.map((row) => `[${row}]`).join(",\n")}]`;
|
|
213
293
|
return [
|
|
214
294
|
...(hasTexts ? [`import texts from ${texts};`] : []),
|
|
295
|
+
...(isTable
|
|
296
|
+
? [
|
|
297
|
+
`const storyKeys = ${codeLiteral(keys)};`,
|
|
298
|
+
// `flatMap` passes over a row's holes, the keys its story lacks
|
|
299
|
+
`const ${STORY_TABLE} = (rows) => rows.map((row) => Object.fromEntries(row.flatMap((value, at) => [[storyKeys[at], value]])));`
|
|
300
|
+
]
|
|
301
|
+
: []),
|
|
215
302
|
// a build's texts are their module's rows, in the same order: each joins its file's
|
|
216
303
|
`const rows = ${hasTexts ? `${written}.map((row, at) => row.concat(texts[at]))` : written};`,
|
|
217
304
|
"const column = (at) => Object.fromEntries(rows.map((row) => [row[0], row[at]]));",
|
|
@@ -221,6 +308,9 @@ export const storyFilesCode = (root, patterns, files, loaders, hasTexts = false)
|
|
|
221
308
|
hasDocs ? "docs: column(3)," : "docs: {},",
|
|
222
309
|
"code: column(4),",
|
|
223
310
|
"pages: column(5),",
|
|
311
|
+
...(refused.length === 0 && scriptProblems.length === 0
|
|
312
|
+
? []
|
|
313
|
+
: [`problems: ${codeLiteral([...refused.map(({ problem }) => problem), ...scriptProblems])},`]),
|
|
224
314
|
`search: () => import(${search}).then((module) => module.default),`,
|
|
225
315
|
...(hasUsage ? [`usage: () => import(${usage}).then((module) => module.default),`] : []),
|
|
226
316
|
...(hasReach ? [`reach: () => import(${reach}).then((module) => module.default),`] : []),
|
|
@@ -20,6 +20,13 @@ export declare const patternsProblem: (patterns: readonly string[]) => string |
|
|
|
20
20
|
* @param pattern - the pattern, without a `!`.
|
|
21
21
|
*/
|
|
22
22
|
export type FindFiles = (root: string, pattern: string) => readonly string[];
|
|
23
|
+
/**
|
|
24
|
+
* A pattern or an address without its trailing slashes (`src/drafts/`): the glob gives the folder it names without them.
|
|
25
|
+
* A loop, not a regular expression, whose backtracking a long run of slashes would make quadratic.
|
|
26
|
+
*
|
|
27
|
+
* @param pattern - the pattern or the address.
|
|
28
|
+
*/
|
|
29
|
+
export declare const withoutTrailingSlashes: (pattern: string) => string;
|
|
23
30
|
/** A file a list of patterns lists, with the pattern that lists it. */
|
|
24
31
|
export type ListedFile = {
|
|
25
32
|
/** Its path relative to the patterns' folder, starting with `./` or `../`, with forward slashes. */
|
|
@@ -37,3 +44,27 @@ export type ListedFile = {
|
|
|
37
44
|
* @throws when every pattern is a `!` one (`patternsProblem`).
|
|
38
45
|
*/
|
|
39
46
|
export declare const listedFiles: (root: string, patterns: readonly string[], find?: FindFiles, paths?: VitePaths) => ListedFile[];
|
|
47
|
+
/**
|
|
48
|
+
* The patterns of a list that list no file, left out by the `!` ones as they are when the catalogue lists its files. Each
|
|
49
|
+
* is read on its own: a mistaken pattern beside one that works is as silent as a list that lists nothing.
|
|
50
|
+
*
|
|
51
|
+
* @param root - the folder the patterns are relative to.
|
|
52
|
+
* @param patterns - the patterns.
|
|
53
|
+
*/
|
|
54
|
+
export declare const unmatchedPatterns: (root: string, patterns: readonly string[]) => readonly string[];
|
|
55
|
+
/**
|
|
56
|
+
* Whether a pattern matches a file, the walk from the pattern's static folder ending at the first one: telling that a
|
|
57
|
+
* pattern lists something should not cost a walk of the whole tree, which on a large library is a tenth of a second
|
|
58
|
+
* on the thread that starts the server, before anything is drawn. It finds only files the glob would list (the same
|
|
59
|
+
* matching, the dependencies left out); finding none decides nothing, and the full listing is asked then.
|
|
60
|
+
*
|
|
61
|
+
* @param root - the folder the pattern is relative to.
|
|
62
|
+
* @param pattern - the pattern, without a `!`.
|
|
63
|
+
*/
|
|
64
|
+
export declare const hasMatchingFile: (root: string, pattern: string) => boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Why what a configuration lists to show cannot be used, or none.
|
|
67
|
+
*
|
|
68
|
+
* @param config - what the file exports by default.
|
|
69
|
+
*/
|
|
70
|
+
export declare const filesProblem: (config: object) => string | undefined;
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @module
|
|
14
14
|
*/
|
|
15
|
-
import { globSync } from "node:fs";
|
|
15
|
+
import { globSync, readdirSync, statSync } from "node:fs";
|
|
16
|
+
import { posix } from "node:path";
|
|
17
|
+
import { patternBase } from "./autoTitle.js";
|
|
16
18
|
import { VITE_PATHS } from "./vitePaths.js";
|
|
17
19
|
/** What starts a pattern that leaves files out. */
|
|
18
20
|
const NEGATION = "!";
|
|
@@ -55,12 +57,12 @@ const isLeftOut = (key, left) => {
|
|
|
55
57
|
return segments.some((_segment, at) => at > 0 && left.has(segments.slice(0, at + 1).join("/")));
|
|
56
58
|
};
|
|
57
59
|
/**
|
|
58
|
-
* A pattern without its trailing slashes (`src/drafts/`): the glob gives the folder it names without them.
|
|
59
|
-
* not a regular expression, whose backtracking a long run of slashes would make quadratic.
|
|
60
|
+
* A pattern or an address without its trailing slashes (`src/drafts/`): the glob gives the folder it names without them.
|
|
61
|
+
* A loop, not a regular expression, whose backtracking a long run of slashes would make quadratic.
|
|
60
62
|
*
|
|
61
|
-
* @param pattern - the pattern.
|
|
63
|
+
* @param pattern - the pattern or the address.
|
|
62
64
|
*/
|
|
63
|
-
const withoutTrailingSlashes = (pattern) => {
|
|
65
|
+
export const withoutTrailingSlashes = (pattern) => {
|
|
64
66
|
let end = pattern.length;
|
|
65
67
|
while (end > 0 && pattern[end - 1] === "/")
|
|
66
68
|
end -= 1;
|
|
@@ -98,3 +100,136 @@ export const listedFiles = (root, patterns, find = globbed, paths = VITE_PATHS)
|
|
|
98
100
|
.sort(([first], [second]) => (first < second ? -1 : 1))
|
|
99
101
|
.map(([key, pattern]) => ({ key, pattern }));
|
|
100
102
|
};
|
|
103
|
+
/**
|
|
104
|
+
* The patterns of a list that list no file, left out by the `!` ones as they are when the catalogue lists its files. Each
|
|
105
|
+
* is read on its own: a mistaken pattern beside one that works is as silent as a list that lists nothing.
|
|
106
|
+
*
|
|
107
|
+
* @param root - the folder the patterns are relative to.
|
|
108
|
+
* @param patterns - the patterns.
|
|
109
|
+
*/
|
|
110
|
+
export const unmatchedPatterns = (root, patterns) => {
|
|
111
|
+
const leftOut = patterns.filter(isNegated);
|
|
112
|
+
// a pattern can match folders alone (`stories/**` over empty ones), which hold no story
|
|
113
|
+
const isFile = ({ key }) => statSync(VITE_PATHS.resolve(root, key), { throwIfNoEntry: false })?.isFile() === true;
|
|
114
|
+
// a `!` pattern left out of a pattern that lists nothing anyway changes nothing, so the walk ignores them: with any,
|
|
115
|
+
// the full listing decides
|
|
116
|
+
return patterns
|
|
117
|
+
.filter((pattern) => !isNegated(pattern))
|
|
118
|
+
.filter((pattern) => !(leftOut.length === 0 && hasMatchingFile(root, pattern)) &&
|
|
119
|
+
!listedFiles(root, [pattern, ...leftOut]).some(isFile));
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* A folder's entries, none when it cannot be read (gone, or not a folder): the walk goes on with the others.
|
|
123
|
+
*
|
|
124
|
+
* @param root - the folder the path is relative to.
|
|
125
|
+
* @param folder - the folder, relative to the root; `""` for the root itself.
|
|
126
|
+
*/
|
|
127
|
+
const folderEntries = (root, folder) => {
|
|
128
|
+
try {
|
|
129
|
+
return readdirSync(VITE_PATHS.resolve(root, folder === "" ? "." : folder), { withFileTypes: true });
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Whether a pattern matches a file, the walk from the pattern's static folder ending at the first one: telling that a
|
|
137
|
+
* pattern lists something should not cost a walk of the whole tree, which on a large library is a tenth of a second
|
|
138
|
+
* on the thread that starts the server, before anything is drawn. It finds only files the glob would list (the same
|
|
139
|
+
* matching, the dependencies left out); finding none decides nothing, and the full listing is asked then.
|
|
140
|
+
*
|
|
141
|
+
* @param root - the folder the pattern is relative to.
|
|
142
|
+
* @param pattern - the pattern, without a `!`.
|
|
143
|
+
*/
|
|
144
|
+
export const hasMatchingFile = (root, pattern) => {
|
|
145
|
+
const plain = pattern.replace(/^(?:\.\/)+/, "");
|
|
146
|
+
const isDependencyNamed = pattern.includes(DEPENDENCIES);
|
|
147
|
+
// the glob enters no hidden folder (`.git`) unless the pattern names one, and nor does the walk
|
|
148
|
+
const isHiddenNamed = plain.split("/").some((segment) => segment.startsWith(".") && segment !== "..");
|
|
149
|
+
const isWalked = (entry) => (isDependencyNamed || entry.name !== DEPENDENCIES) && (isHiddenNamed || !entry.name.startsWith("."));
|
|
150
|
+
const shape = patternShape(plain);
|
|
151
|
+
const folders = [patternBase(plain)];
|
|
152
|
+
while (folders.length > 0) {
|
|
153
|
+
const folder = folders.pop() ?? "";
|
|
154
|
+
for (const entry of folderEntries(root, folder)) {
|
|
155
|
+
const path = folder === "" ? entry.name : `${folder}/${entry.name}`;
|
|
156
|
+
if (entry.isFile() && shape.isFileDepth(path) && posix.matchesGlob(path, plain))
|
|
157
|
+
return true;
|
|
158
|
+
if (entry.isDirectory() && isWalked(entry) && shape.couldHold(path))
|
|
159
|
+
folders.push(path);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
};
|
|
164
|
+
/** Whether a pattern has a `/` inside a group (`{a,b/c}`, `@(a|b/c)`), which splitting it at its slashes would cut. */
|
|
165
|
+
const hasSlashInGroup = (pattern) => {
|
|
166
|
+
let depth = 0;
|
|
167
|
+
for (const character of pattern) {
|
|
168
|
+
if (character === "{" || character === "(")
|
|
169
|
+
depth += 1;
|
|
170
|
+
else if ((character === "}" || character === ")") && depth > 0)
|
|
171
|
+
depth -= 1;
|
|
172
|
+
else if (character === "/" && depth > 0)
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
return false;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Where a pattern's files can be. Without it the walk reads every folder under the pattern's static one and matches
|
|
179
|
+
* every file there: in a monorepo whose pattern names packages by a group (`packages/@{a,b}/*\/stories/*`), that is
|
|
180
|
+
* every package's sources, most of a second, longer than the full listing the walk is there to spare. A pattern with
|
|
181
|
+
* `**` reaches any depth past it; one with a `/` inside a group cannot be cut at its slashes, and lets everything through.
|
|
182
|
+
*
|
|
183
|
+
* @param pattern - the pattern, without a `!` or a leading `./`.
|
|
184
|
+
*/
|
|
185
|
+
const patternShape = (pattern) => {
|
|
186
|
+
if (hasSlashInGroup(pattern))
|
|
187
|
+
return { couldHold: () => true, isFileDepth: () => true };
|
|
188
|
+
const segments = pattern.split("/");
|
|
189
|
+
const globstar = segments.indexOf("**");
|
|
190
|
+
const isAnyDepth = (depth) => globstar !== -1 && globstar < depth;
|
|
191
|
+
return {
|
|
192
|
+
couldHold: (folder) => {
|
|
193
|
+
const depth = folder.split("/").length;
|
|
194
|
+
if (isAnyDepth(depth))
|
|
195
|
+
return true;
|
|
196
|
+
return depth < segments.length && posix.matchesGlob(folder, segments.slice(0, depth).join("/"));
|
|
197
|
+
},
|
|
198
|
+
isFileDepth: (file) => {
|
|
199
|
+
const depth = file.split("/").length;
|
|
200
|
+
return isAnyDepth(depth) || depth === segments.length;
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
/** Whether a configuration's list has something in it. */
|
|
205
|
+
const isListed = (config, key) => {
|
|
206
|
+
const list = Reflect.get(config, key);
|
|
207
|
+
return Array.isArray(list) && list.length > 0;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Why a configuration's list of globs lists nothing by construction (only `!` patterns), or none.
|
|
211
|
+
*
|
|
212
|
+
* @param config - what the file exports by default.
|
|
213
|
+
* @param key - the list's key.
|
|
214
|
+
*/
|
|
215
|
+
const globsProblem = (config, key) => {
|
|
216
|
+
const list = Reflect.get(config, key);
|
|
217
|
+
return Array.isArray(list)
|
|
218
|
+
? patternsProblem(list.filter((item) => typeof item === "string"))
|
|
219
|
+
: undefined;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Why what a configuration lists to show cannot be used, or none.
|
|
223
|
+
*
|
|
224
|
+
* @param config - what the file exports by default.
|
|
225
|
+
*/
|
|
226
|
+
export const filesProblem = (config) => {
|
|
227
|
+
if (!["stories", "sources", "docs"].some((key) => isListed(config, key)))
|
|
228
|
+
return 'it names no stories (`stories: ["src/**/*.stories.tsx"]`) and no sources';
|
|
229
|
+
for (const key of ["stories", "docs"]) {
|
|
230
|
+
const problem = globsProblem(config, key);
|
|
231
|
+
if (problem !== undefined)
|
|
232
|
+
return `its ${key} list nothing: ${problem}`;
|
|
233
|
+
}
|
|
234
|
+
return undefined;
|
|
235
|
+
};
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* @remarks
|
|
5
5
|
* Pure, on the same graph "Used in" reads (`usageGraph.ts`), so what cannot be followed there cannot be followed here: a
|
|
6
6
|
* computed lazy import, a component handed in as a prop. A story file reaches its meta's component whatever its stories
|
|
7
|
-
* render, since a story with no JSX draws that component.
|
|
8
|
-
*
|
|
7
|
+
* render, since a story with no JSX draws that component. A file no edge reaches is not known to reach anything:
|
|
8
|
+
* `verify` lists it as not verified rather than claim it is safe. A deleted file has no node, only the edge of whatever
|
|
9
|
+
* still imports it, written without its extension when the import was: the stories behind that edge are the ones it
|
|
10
|
+
* breaks.
|
|
9
11
|
*
|
|
10
12
|
* @module
|
|
11
13
|
*/
|
|
@@ -25,6 +27,12 @@ export type ReachedStory = {
|
|
|
25
27
|
readonly exportName: string;
|
|
26
28
|
/** Every file it reaches, its own story file included, absolute. */
|
|
27
29
|
readonly files: readonly string[];
|
|
30
|
+
/** Its story file, the components it draws and what the story file imports itself: the rest it reaches through them. */
|
|
31
|
+
readonly own: readonly string[];
|
|
32
|
+
/** Its story file, absolute. */
|
|
33
|
+
readonly storyFile: string;
|
|
34
|
+
/** The file its meta's component is declared in, absolute; none when its meta names none the checker resolves. */
|
|
35
|
+
readonly metaFile?: string;
|
|
28
36
|
};
|
|
29
37
|
/**
|
|
30
38
|
* Each story with the files it reaches.
|
|
@@ -19,17 +19,21 @@ const reachedFrom = (imports, starts) => {
|
|
|
19
19
|
*/
|
|
20
20
|
export const storyReach = (graph, files) => {
|
|
21
21
|
const titles = new Map(files.map((file) => [file.storyFile, file.title]));
|
|
22
|
-
return graph.files.flatMap((file) => file.stories.map((story) =>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
...
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
return graph.files.flatMap((file) => file.stories.map((story) => {
|
|
23
|
+
const starts = [
|
|
24
|
+
file.storyFile,
|
|
25
|
+
...(file.component === undefined ? [] : [file.component.file]),
|
|
26
|
+
...story.renders.map((ref) => ref.file)
|
|
27
|
+
];
|
|
28
|
+
return {
|
|
29
|
+
title: titles.get(file.storyFile) ?? "",
|
|
30
|
+
exportName: story.exportName,
|
|
31
|
+
storyFile: file.storyFile,
|
|
32
|
+
files: [...reachedFrom(graph.imports, starts)],
|
|
33
|
+
own: [...new Set([...starts, ...(graph.imports[file.storyFile] ?? [])])],
|
|
34
|
+
...(file.component === undefined ? {} : { metaFile: file.component.file })
|
|
35
|
+
};
|
|
36
|
+
}));
|
|
33
37
|
};
|
|
34
38
|
/**
|
|
35
39
|
* The stories that reach any of the changed files, each once, in the graph's order.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A story file's top level as the index and the story's code read it: its constants, the properties assigned to names
|
|
3
|
+
* after them, its meta object and the exports that are stories.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Internal to the plugin: the index (`indexStoryFile.ts`) and the Code tab's texts (`storyCode.ts`) read a file the same
|
|
7
|
+
* way through it. Pure.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import type { ESTree } from "vite";
|
|
12
|
+
import { type Fields } from "./indexFields.ts";
|
|
13
|
+
import { type NamedExport } from "./storyExports.ts";
|
|
14
|
+
/** The file's top level, read once: its constants and the properties assigned to names. */
|
|
15
|
+
export type TopLevel = {
|
|
16
|
+
/** Each constant's value, by name. */
|
|
17
|
+
readonly values: ReadonlyMap<string, ESTree.Expression>;
|
|
18
|
+
/** The properties assigned to a name after it (`A.storyName = "…"`), by name then property. */
|
|
19
|
+
readonly assigned: ReadonlyMap<string, ReadonlyMap<string, ESTree.Expression>>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The file's top level: its constants, exported or not, and the properties assigned to names.
|
|
23
|
+
*
|
|
24
|
+
* @param program - the parsed file.
|
|
25
|
+
*/
|
|
26
|
+
export declare const topLevelOf: (program: ESTree.Program) => TopLevel;
|
|
27
|
+
/**
|
|
28
|
+
* The object a value is, or the one the constants it names lead to (`export const B = A`); `undefined` for any other
|
|
29
|
+
* value, or for names that lead back to themselves.
|
|
30
|
+
*
|
|
31
|
+
* @param top - the file's top level.
|
|
32
|
+
* @param value - the value.
|
|
33
|
+
* @param seen - the names followed so far.
|
|
34
|
+
*/
|
|
35
|
+
export declare const objectOf: (top: TopLevel, value: ESTree.Expression | undefined, seen?: ReadonlySet<string>) => ESTree.ObjectExpression | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* The meta's object: the default export, inline or a constant of the file (`export default meta`,
|
|
38
|
+
* `export { meta as default }`).
|
|
39
|
+
*
|
|
40
|
+
* @param program - the parsed file.
|
|
41
|
+
* @param top - the file's top level.
|
|
42
|
+
*/
|
|
43
|
+
export declare const metaObject: (program: ESTree.Program, top: TopLevel) => ESTree.ObjectExpression | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* The exports that are stories, in the order of `__namedExportsOrder` when the file writes one, else of the file.
|
|
46
|
+
*
|
|
47
|
+
* @param program - the parsed file.
|
|
48
|
+
* @param top - the file's top level.
|
|
49
|
+
* @param meta - the meta's fields, for `includeStories` and `excludeStories`.
|
|
50
|
+
*/
|
|
51
|
+
export declare const storyExports: (program: ESTree.Program, top: TopLevel, meta: Fields) => NamedExport[];
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { unwrapped } from "./indexFields.js";
|
|
2
|
+
import { moduleName, namedExports } from "./storyExports.js";
|
|
3
|
+
/**
|
|
4
|
+
* The property a top-level statement assigns to a name, when it assigns one.
|
|
5
|
+
*
|
|
6
|
+
* @param statement - the statement.
|
|
7
|
+
*/
|
|
8
|
+
const assignedProperty = (statement) => {
|
|
9
|
+
if (statement.type !== "ExpressionStatement")
|
|
10
|
+
return undefined;
|
|
11
|
+
const { expression } = statement;
|
|
12
|
+
if (expression.type !== "AssignmentExpression" || expression.left.type !== "MemberExpression")
|
|
13
|
+
return undefined;
|
|
14
|
+
const { object, property } = expression.left;
|
|
15
|
+
if (object.type !== "Identifier" || property.type !== "Identifier")
|
|
16
|
+
return undefined;
|
|
17
|
+
return { name: object.name, property: property.name, value: unwrapped(expression.right) };
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The constants a top-level statement declares with a value, exported or not.
|
|
21
|
+
*
|
|
22
|
+
* @param statement - the statement.
|
|
23
|
+
*/
|
|
24
|
+
const declaredBy = (statement) => {
|
|
25
|
+
const declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration : statement;
|
|
26
|
+
if (declaration?.type !== "VariableDeclaration")
|
|
27
|
+
return [];
|
|
28
|
+
return declaration.declarations.flatMap(({ id, init }) => id.type === "Identifier" && init !== null ? [{ name: id.name, value: unwrapped(init) }] : []);
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The file's top level: its constants, exported or not, and the properties assigned to names.
|
|
32
|
+
*
|
|
33
|
+
* @param program - the parsed file.
|
|
34
|
+
*/
|
|
35
|
+
export const topLevelOf = (program) => {
|
|
36
|
+
const values = new Map();
|
|
37
|
+
const assigned = new Map();
|
|
38
|
+
for (const statement of program.body) {
|
|
39
|
+
for (const declared of declaredBy(statement))
|
|
40
|
+
values.set(declared.name, declared.value);
|
|
41
|
+
const property = assignedProperty(statement);
|
|
42
|
+
if (property === undefined)
|
|
43
|
+
continue;
|
|
44
|
+
const properties = assigned.get(property.name) ?? new Map();
|
|
45
|
+
properties.set(property.property, property.value);
|
|
46
|
+
assigned.set(property.name, properties);
|
|
47
|
+
}
|
|
48
|
+
return { values, assigned };
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The object a value is, or the one the constants it names lead to (`export const B = A`); `undefined` for any other
|
|
52
|
+
* value, or for names that lead back to themselves.
|
|
53
|
+
*
|
|
54
|
+
* @param top - the file's top level.
|
|
55
|
+
* @param value - the value.
|
|
56
|
+
* @param seen - the names followed so far.
|
|
57
|
+
*/
|
|
58
|
+
export const objectOf = (top, value, seen = new Set()) => {
|
|
59
|
+
if (value?.type === "ObjectExpression")
|
|
60
|
+
return value;
|
|
61
|
+
if (value?.type !== "Identifier" || seen.has(value.name))
|
|
62
|
+
return undefined;
|
|
63
|
+
return objectOf(top, top.values.get(value.name), new Set([...seen, value.name]));
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Whether an export is a story, as the meta's `includeStories` and `excludeStories` say (a list of names or a regular
|
|
67
|
+
* expression, written plainly).
|
|
68
|
+
*
|
|
69
|
+
* @param meta - the meta's fields.
|
|
70
|
+
* @param exportName - the export.
|
|
71
|
+
*/
|
|
72
|
+
const isIncluded = (meta, exportName) => {
|
|
73
|
+
const matches = (name) => {
|
|
74
|
+
const filter = meta(name);
|
|
75
|
+
if (filter?.type === "ArrayExpression")
|
|
76
|
+
return filter.elements.some((element) => element?.type === "Literal" && element.value === exportName);
|
|
77
|
+
if (filter?.type === "Literal" && "regex" in filter && filter.regex !== undefined)
|
|
78
|
+
return new RegExp(filter.regex.pattern, filter.regex.flags).test(exportName);
|
|
79
|
+
return undefined;
|
|
80
|
+
};
|
|
81
|
+
return matches("includeStories") !== false && matches("excludeStories") !== true;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* The order `__namedExportsOrder` writes, when the file writes one plainly.
|
|
85
|
+
*
|
|
86
|
+
* @param top - the file's top level.
|
|
87
|
+
*/
|
|
88
|
+
const exportsOrder = (top) => {
|
|
89
|
+
const order = top.values.get("__namedExportsOrder");
|
|
90
|
+
if (order?.type !== "ArrayExpression")
|
|
91
|
+
return undefined;
|
|
92
|
+
return order.elements.flatMap((element) => element?.type === "Literal" && typeof element.value === "string" ? [element.value] : []);
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* The meta exported by name (`export { meta as default }`), when it is a constant of the file written as an object.
|
|
96
|
+
*
|
|
97
|
+
* @param program - the parsed file.
|
|
98
|
+
* @param top - the file's top level.
|
|
99
|
+
*/
|
|
100
|
+
const namedMeta = (program, top) => {
|
|
101
|
+
for (const statement of program.body) {
|
|
102
|
+
if (statement.type !== "ExportNamedDeclaration" || statement.source !== null)
|
|
103
|
+
continue;
|
|
104
|
+
const specifier = statement.specifiers.find((each) => moduleName(each.exported) === "default");
|
|
105
|
+
if (specifier === undefined)
|
|
106
|
+
continue;
|
|
107
|
+
const value = top.values.get(moduleName(specifier.local));
|
|
108
|
+
return value?.type === "ObjectExpression" ? value : undefined;
|
|
109
|
+
}
|
|
110
|
+
return undefined;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* The meta's object: the default export, inline or a constant of the file (`export default meta`,
|
|
114
|
+
* `export { meta as default }`).
|
|
115
|
+
*
|
|
116
|
+
* @param program - the parsed file.
|
|
117
|
+
* @param top - the file's top level.
|
|
118
|
+
*/
|
|
119
|
+
export const metaObject = (program, top) => {
|
|
120
|
+
const meta = program.body.find((statement) => statement.type === "ExportDefaultDeclaration");
|
|
121
|
+
if (meta === undefined)
|
|
122
|
+
return namedMeta(program, top);
|
|
123
|
+
const { declaration } = meta;
|
|
124
|
+
if (declaration.type === "FunctionDeclaration" ||
|
|
125
|
+
declaration.type === "ClassDeclaration" ||
|
|
126
|
+
declaration.type === "TSInterfaceDeclaration")
|
|
127
|
+
return undefined;
|
|
128
|
+
const expression = unwrapped(declaration);
|
|
129
|
+
const value = expression.type === "Identifier" ? top.values.get(expression.name) : expression;
|
|
130
|
+
return value?.type === "ObjectExpression" ? value : undefined;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* The exports that are stories, in the order of `__namedExportsOrder` when the file writes one, else of the file.
|
|
134
|
+
*
|
|
135
|
+
* @param program - the parsed file.
|
|
136
|
+
* @param top - the file's top level.
|
|
137
|
+
* @param meta - the meta's fields, for `includeStories` and `excludeStories`.
|
|
138
|
+
*/
|
|
139
|
+
export const storyExports = (program, top, meta) => {
|
|
140
|
+
const exported = namedExports(program).filter(({ exportName }) => exportName !== "__namedExportsOrder" && isIncluded(meta, exportName));
|
|
141
|
+
const order = exportsOrder(top);
|
|
142
|
+
if (order === undefined)
|
|
143
|
+
return exported;
|
|
144
|
+
const rank = (name) => (order.includes(name) ? order.indexOf(name) : order.length);
|
|
145
|
+
return [...exported].sort((first, second) => rank(first.exportName) - rank(second.exportName));
|
|
146
|
+
};
|
|
@@ -4,12 +4,13 @@ import { type TokenReading } from "./tokenAnswers.ts";
|
|
|
4
4
|
/** Finds the file of a source's module specifier. */
|
|
5
5
|
export type ResolveSource = (specifier: string) => Promise<string | undefined>;
|
|
6
6
|
/**
|
|
7
|
-
* The
|
|
8
|
-
*
|
|
7
|
+
* The tokens an agent is answered from: what the catalogue and its sources name or, when they name none, what the
|
|
8
|
+
* application already declares, which is read from its files and never run. A catalogue that says `tokens: []` wants
|
|
9
|
+
* none, so a named file is not the only way to say so.
|
|
9
10
|
*
|
|
10
11
|
* @param config - the catalogue's configuration.
|
|
11
12
|
* @param resolveSource - finds the file of a source's module.
|
|
12
|
-
* @param watch - told of every file read
|
|
13
|
+
* @param watch - told of every file read; none by default.
|
|
13
14
|
*/
|
|
14
15
|
export declare const catalogueTokens: (config: ResolvedConfig, resolveSource: ResolveSource, watch?: (file: string) => void) => Promise<TokenReading>;
|
|
15
16
|
/**
|