forgebook 0.3.2 → 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 +917 -74
- 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 +54 -6
- package/dist/src/addressArgs.js +72 -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 +58 -14
- 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/PluginBlockHost.js +2 -1
- package/dist/src/shell/PluginTabHost.js +19 -2
- 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 +35 -60
- 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.d.ts +17 -4
- package/dist/src/shell/asideStory.js +21 -4
- 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 +27 -2
- package/dist/src/shell/useAddressArgs.js +71 -14
- 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
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The code a story shows in the catalogue's Code card
|
|
3
|
-
*
|
|
2
|
+
* The code a story shows in the catalogue's Code card, read from its file with Vite's parser, never run: each story's
|
|
3
|
+
* `render` as written, and for a story drawn from its args, each arg the file writes as code.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
* A story
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* A story's render is its own, else the meta's; a story written as a function (CSF 2), or bound from one
|
|
7
|
+
* (`Template.bind({})`), is its render. A render kept in a constant or a function of the file shows as that code; one
|
|
8
|
+
* imported from another file shows as its name, which is what the file says.
|
|
9
|
+
*
|
|
10
|
+
* A story without a render draws the meta's component with its args, and the shell writes that component in the
|
|
11
|
+
* framework's code from the args of the moment. Only plain data crosses from the frame, so a function, an element or
|
|
12
|
+
* any other code would be missing: this module gives the text of each such arg as written (`icon: <IconStar />`,
|
|
13
|
+
* `onClick: fn()`), the meta's args under the story's, following spreads of the file's constants and of another
|
|
14
|
+
* story's args. A plain literal is left to the value the frame reports, which is the same; a constant of the file is
|
|
15
|
+
* written by its value, an import by its name. What a spread or a value it cannot read may replace is forgotten, so
|
|
16
|
+
* the shell writes it from the value, never from a text the story does not draw. Pure: text in, texts out.
|
|
9
17
|
*
|
|
10
18
|
* @module
|
|
11
19
|
*/
|
|
20
|
+
import { keyName, propertyValue, unwrapped } from "./indexFields.js";
|
|
12
21
|
import { parseStoryFile } from "./storyParse.js";
|
|
13
|
-
|
|
14
|
-
const unwrapped = (expression) => {
|
|
15
|
-
if (expression.type === "TSSatisfiesExpression" ||
|
|
16
|
-
expression.type === "TSAsExpression" ||
|
|
17
|
-
expression.type === "ParenthesizedExpression") {
|
|
18
|
-
return unwrapped(expression.expression);
|
|
19
|
-
}
|
|
20
|
-
return expression;
|
|
21
|
-
};
|
|
22
|
-
/** The `render` property of a story object, when it has one. */
|
|
23
|
-
const renderOf = (object) => object.properties.find((property) => property.type === "Property" &&
|
|
24
|
-
!property.computed &&
|
|
25
|
-
property.key.type === "Identifier" &&
|
|
26
|
-
property.key.name === "render");
|
|
22
|
+
import { metaObject, objectOf, storyExports, topLevelOf } from "./storyTopLevel.js";
|
|
27
23
|
/**
|
|
28
24
|
* Removes from every line past the first the indentation of the line the code starts on, so a `render` reads as if
|
|
29
25
|
* written at the left edge.
|
|
@@ -42,19 +38,242 @@ const indentAt = (text, position) => {
|
|
|
42
38
|
const line = text.slice(lineStart, position);
|
|
43
39
|
return line.length - line.trimStart().length;
|
|
44
40
|
};
|
|
45
|
-
/** A
|
|
46
|
-
const
|
|
47
|
-
|
|
41
|
+
/** A node's text, as written, without the indentation of the line it starts on. */
|
|
42
|
+
const textOf = ({ text }, node) => dedented(text.slice(node.start, node.end), indentAt(text, node.start));
|
|
43
|
+
/** The functions the file declares at its top (`function renderGrid() {}`, exported or not), by name. */
|
|
44
|
+
const declaredFunctions = (program) => {
|
|
45
|
+
const functions = new Map();
|
|
46
|
+
for (const statement of program.body) {
|
|
47
|
+
const declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration : statement;
|
|
48
|
+
if (declaration?.type === "FunctionDeclaration" && declaration.id !== null)
|
|
49
|
+
functions.set(declaration.id.name, declaration);
|
|
50
|
+
}
|
|
51
|
+
return functions;
|
|
52
|
+
};
|
|
53
|
+
/** Whether an expression is a function written in place. */
|
|
54
|
+
const isFunction = (expression) => expression.type === "ArrowFunctionExpression" || expression.type === "FunctionExpression";
|
|
55
|
+
/**
|
|
56
|
+
* The function a name of the file holds: a constant written as one, or a function declaration.
|
|
57
|
+
*
|
|
58
|
+
* @param context - the file.
|
|
59
|
+
* @param name - the name.
|
|
60
|
+
*/
|
|
61
|
+
const functionNamed = (context, name) => {
|
|
62
|
+
const value = context.top.values.get(name);
|
|
63
|
+
if (value !== undefined && isFunction(value))
|
|
64
|
+
return value;
|
|
65
|
+
return context.functions.get(name);
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* The render a story's value is itself: a function (CSF 2), or one bound from a function of the file
|
|
69
|
+
* (`Template.bind({})`).
|
|
70
|
+
*/
|
|
71
|
+
const storyFunction = (context, value) => {
|
|
72
|
+
if (value === undefined)
|
|
73
|
+
return undefined;
|
|
74
|
+
if (isFunction(value))
|
|
75
|
+
return value;
|
|
76
|
+
if (value.type !== "CallExpression" || value.callee.type !== "MemberExpression")
|
|
77
|
+
return undefined;
|
|
78
|
+
const { object, property } = value.callee;
|
|
79
|
+
if (object.type !== "Identifier" || property.type !== "Identifier" || property.name !== "bind")
|
|
80
|
+
return undefined;
|
|
81
|
+
return functionNamed(context, object.name);
|
|
82
|
+
};
|
|
83
|
+
/** Whether an expression is `undefined`, which sets a field to none. */
|
|
84
|
+
const isUndefined = (expression) => expression.type === "Identifier" && expression.name === "undefined";
|
|
85
|
+
/**
|
|
86
|
+
* A field of a story by its local name (`args`, `render`): what is assigned to it after its declaration
|
|
87
|
+
* (`A.args = …`), else what its object holds. An assignment that reads the field itself (`A.args = { ...A.args }`)
|
|
88
|
+
* reads the object's, as it does when the file runs.
|
|
89
|
+
*
|
|
90
|
+
* @param context - the file.
|
|
91
|
+
* @param local - the story's local name.
|
|
92
|
+
* @param field - the field's name.
|
|
93
|
+
* @param seen - the places followed so far.
|
|
94
|
+
*/
|
|
95
|
+
const storyField = (context, local, field, seen) => {
|
|
96
|
+
const assignedPlace = `${local}.${field}=`;
|
|
97
|
+
const objectPlace = `${local}.${field}`;
|
|
98
|
+
const assigned = context.top.assigned.get(local)?.get(field);
|
|
99
|
+
if (assigned !== undefined && !seen.has(assignedPlace))
|
|
100
|
+
return { value: isUndefined(assigned) ? null : assigned, seen: new Set([...seen, assignedPlace]) };
|
|
101
|
+
const object = objectOf(context.top, context.top.values.get(local));
|
|
102
|
+
if (object === undefined || seen.has(objectPlace))
|
|
103
|
+
return { value: undefined, seen };
|
|
104
|
+
return objectField(context, object, field, new Set([...seen, objectPlace]));
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* A field a story object holds: its own property, else the field of the story a spread in it names, the later over
|
|
108
|
+
* the earlier, as the object has it when the file runs.
|
|
109
|
+
*
|
|
110
|
+
* @param context - the file.
|
|
111
|
+
* @param object - the story's object.
|
|
112
|
+
* @param field - the field's name.
|
|
113
|
+
* @param seen - the places followed so far.
|
|
114
|
+
*/
|
|
115
|
+
const objectField = (context, object, field, seen) => {
|
|
116
|
+
let read = { value: null, seen };
|
|
117
|
+
for (const property of object.properties) {
|
|
118
|
+
if (property.type === "SpreadElement") {
|
|
119
|
+
const argument = unwrapped(property.argument);
|
|
120
|
+
const spread = argument.type === "Identifier"
|
|
121
|
+
? storyField(context, argument.name, field, seen)
|
|
122
|
+
: { value: undefined, seen };
|
|
123
|
+
if (spread.value !== null)
|
|
124
|
+
read = spread;
|
|
125
|
+
}
|
|
126
|
+
else if (!property.computed && keyName(property.key) === field) {
|
|
127
|
+
const value = unwrapped(property.value);
|
|
128
|
+
read = { value: isUndefined(value) ? null : value, seen };
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return read;
|
|
132
|
+
};
|
|
133
|
+
/** Whether an arg's value is plain data the frame reports as written: a literal, or `undefined`. */
|
|
134
|
+
const isPlainValue = (value) => (value.type === "Literal" && !("regex" in value && value.regex !== undefined) && !("bigint" in value)) ||
|
|
135
|
+
isUndefined(value);
|
|
136
|
+
/**
|
|
137
|
+
* An expression's text as written; a method's function (`render(args) {…}`), whose text starts at its parameters, is
|
|
138
|
+
* written as the function expression it is (`function (args) {…}`), so it can stand on its own.
|
|
139
|
+
*/
|
|
140
|
+
const expressionText = (context, value) => {
|
|
141
|
+
const text = textOf(context, value);
|
|
142
|
+
if (value.type !== "FunctionExpression" || !text.startsWith("("))
|
|
143
|
+
return text;
|
|
144
|
+
return `${value.async ? "async " : ""}function${value.generator ? "*" : ""} ${text}`;
|
|
145
|
+
};
|
|
146
|
+
/** An arg's text: a constant of the file by its value, anything else as written; none for plain data. */
|
|
147
|
+
const argText = (context, value) => {
|
|
148
|
+
if (isPlainValue(value))
|
|
149
|
+
return undefined;
|
|
150
|
+
const held = value.type === "Identifier" ? context.top.values.get(value.name) : undefined;
|
|
151
|
+
if (held !== undefined)
|
|
152
|
+
return isPlainValue(held) ? undefined : expressionText(context, held);
|
|
153
|
+
return expressionText(context, value);
|
|
154
|
+
};
|
|
155
|
+
/** Forgets every arg written so far: a spread or a value that cannot be read may replace any of them. */
|
|
156
|
+
const forgetAll = (written) => {
|
|
157
|
+
for (const name of written.keys())
|
|
158
|
+
written.set(name, undefined);
|
|
159
|
+
};
|
|
160
|
+
/** The story whose args a member expression reads (`First.args`); none for any other. */
|
|
161
|
+
const argsOwner = (member) => {
|
|
162
|
+
const { object, property } = member;
|
|
163
|
+
if (member.computed || object.type !== "Identifier" || property.type !== "Identifier")
|
|
48
164
|
return undefined;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
165
|
+
return property.name === "args" ? object.name : undefined;
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Adds the args an object writes, in order: a later one replaces an earlier one in its place, as a spread does when
|
|
169
|
+
* the file runs.
|
|
170
|
+
*
|
|
171
|
+
* @param context - the file.
|
|
172
|
+
* @param object - the args' object.
|
|
173
|
+
* @param written - the args so far.
|
|
174
|
+
* @param seen - the places followed so far.
|
|
175
|
+
*/
|
|
176
|
+
const writeObjectArgs = (context, object, written, seen) => {
|
|
177
|
+
for (const property of object.properties) {
|
|
178
|
+
if (property.type === "SpreadElement") {
|
|
179
|
+
writeArgsOf(context, property.argument, written, seen);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
const name = property.computed ? undefined : keyName(property.key);
|
|
183
|
+
if (name === undefined)
|
|
184
|
+
forgetAll(written);
|
|
185
|
+
else
|
|
186
|
+
written.set(name, argText(context, unwrapped(property.value)));
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Adds the args a value writes to those written so far: an object in place or a constant of the file, or another
|
|
191
|
+
* story's (`First.args`); one that cannot be read forgets them all.
|
|
192
|
+
*
|
|
193
|
+
* @param context - the file.
|
|
194
|
+
* @param value - the args' value.
|
|
195
|
+
* @param written - the args so far.
|
|
196
|
+
* @param seen - the places followed so far.
|
|
197
|
+
*/
|
|
198
|
+
const writeArgsOf = (context, value, written, seen) => {
|
|
199
|
+
const plain = unwrapped(value);
|
|
200
|
+
if (plain.type === "MemberExpression") {
|
|
201
|
+
const story = argsOwner(plain);
|
|
202
|
+
const read = story === undefined ? { value: undefined, seen } : storyField(context, story, "args", seen);
|
|
203
|
+
if (read.value === undefined)
|
|
204
|
+
forgetAll(written);
|
|
205
|
+
else if (read.value !== null)
|
|
206
|
+
writeArgsOf(context, read.value, written, read.seen);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const object = objectOf(context.top, plain);
|
|
210
|
+
if (object === undefined)
|
|
211
|
+
forgetAll(written);
|
|
212
|
+
else
|
|
213
|
+
writeObjectArgs(context, object, written, seen);
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* An args story's args written as code: the meta's, then the story's over them.
|
|
217
|
+
*
|
|
218
|
+
* @param context - the file.
|
|
219
|
+
* @param meta - the meta's object, when the file has one written plainly.
|
|
220
|
+
* @param local - the story's local name.
|
|
221
|
+
*/
|
|
222
|
+
const writtenArgsOf = (context, meta, local) => {
|
|
223
|
+
const written = new Map();
|
|
224
|
+
const metaArgs = meta === undefined ? undefined : propertyValue(meta, "args");
|
|
225
|
+
if (metaArgs !== undefined)
|
|
226
|
+
writeArgsOf(context, metaArgs, written, new Set());
|
|
227
|
+
const own = storyField(context, local, "args", new Set());
|
|
228
|
+
if (own.value === undefined)
|
|
229
|
+
forgetAll(written);
|
|
230
|
+
else if (own.value !== null)
|
|
231
|
+
writeArgsOf(context, own.value, written, own.seen);
|
|
232
|
+
return Object.fromEntries([...written].flatMap(([name, text]) => (text === undefined ? [] : [[name, text]])));
|
|
233
|
+
};
|
|
234
|
+
/** A render's text: the code a name of the file holds, else the expression as written, a method as a function. */
|
|
235
|
+
const renderText = (context, render) => {
|
|
236
|
+
const held = render.type === "Identifier" ? functionNamed(context, render.name) : undefined;
|
|
237
|
+
return expressionText(context, held ?? render);
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* A story's render text, by its local name: its own `render` (assigned after it, in its object or in a story it
|
|
241
|
+
* spreads), else the story itself when it is a function, else the meta's; none for a story drawn from its args, or
|
|
242
|
+
* one whose render cannot be read (a helper's result), which is written from its values.
|
|
243
|
+
*
|
|
244
|
+
* @param context - the file.
|
|
245
|
+
* @param local - the story's local name.
|
|
246
|
+
* @param metaRender - the meta's render, when it has one.
|
|
247
|
+
*/
|
|
248
|
+
const storyRender = (context, local, metaRender) => {
|
|
249
|
+
const own = storyField(context, local, "render", new Set()).value;
|
|
250
|
+
if (own !== undefined && own !== null)
|
|
251
|
+
return renderText(context, own);
|
|
252
|
+
if (own === null)
|
|
253
|
+
return metaRender === undefined ? undefined : renderText(context, metaRender);
|
|
254
|
+
const value = context.top.values.get(local);
|
|
255
|
+
const asFunction = value === undefined ? context.functions.get(local) : storyFunction(context, value);
|
|
256
|
+
return asFunction === undefined ? undefined : textOf(context, asFunction);
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* One story's code: its render text, or its args written as code; none when reading it failed.
|
|
260
|
+
*
|
|
261
|
+
* @param context - the file.
|
|
262
|
+
* @param meta - the meta's object, when the file has one written plainly.
|
|
263
|
+
* @param local - the story's local name.
|
|
264
|
+
* @param metaRender - the meta's render, when it has one.
|
|
265
|
+
*/
|
|
266
|
+
const storyCodeOf = (context, meta, local, metaRender) => {
|
|
267
|
+
try {
|
|
268
|
+
return storyRender(context, local, metaRender) ?? writtenArgsOf(context, meta, local);
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
// a story the reader trips on is written from its values: the other stories of the file keep their code
|
|
52
272
|
return undefined;
|
|
53
|
-
|
|
54
|
-
return dedented(text.slice(start, end), indentAt(text, start));
|
|
273
|
+
}
|
|
55
274
|
};
|
|
56
275
|
/**
|
|
57
|
-
* Each story's
|
|
276
|
+
* Each story's code in a story file: its render as written, or its args written as code.
|
|
58
277
|
*
|
|
59
278
|
* @param file - the file's path, for the parser (its extension decides TypeScript and JSX) and the messages.
|
|
60
279
|
* @param text - the file's source.
|
|
@@ -65,15 +284,22 @@ export const storyCode = (file, text) => {
|
|
|
65
284
|
const [error] = errors;
|
|
66
285
|
if (error !== undefined)
|
|
67
286
|
return `${file} does not parse: ${error.message}`;
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
287
|
+
const top = topLevelOf(program);
|
|
288
|
+
const context = { text, top, functions: declaredFunctions(program) };
|
|
289
|
+
const meta = metaObject(program, top);
|
|
290
|
+
const metaFields = (name) => meta === undefined ? undefined : propertyValue(meta, name);
|
|
291
|
+
const metaRender = metaFields("render");
|
|
292
|
+
const renders = {};
|
|
293
|
+
const args = {};
|
|
294
|
+
for (const { exportName, local } of storyExports(program, top, metaFields)) {
|
|
295
|
+
// a story from another file is read there: its code is the values of the moment
|
|
296
|
+
if (local === undefined)
|
|
71
297
|
continue;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
298
|
+
const read = storyCodeOf(context, meta, local, metaRender);
|
|
299
|
+
if (typeof read === "string")
|
|
300
|
+
renders[exportName] = read;
|
|
301
|
+
else if (read !== undefined && Object.keys(read).length > 0)
|
|
302
|
+
args[exportName] = read;
|
|
77
303
|
}
|
|
78
|
-
return
|
|
304
|
+
return { renders, args };
|
|
79
305
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which of a project's components have stories and which are drawn by its code: what `forgebook audit` reports as a
|
|
3
|
+
* catalogue's rot, components no story is about and stories of components nothing uses.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Read from the files' text, with no program and no configuration, like the rest of the audit: it has to answer on a
|
|
7
|
+
* project with no catalogue, in a moment. A story file is about the components it imports; a component is used when a file
|
|
8
|
+
* that is neither a story nor a test imports it or writes its tag. Where an import cannot be followed (a barrel, an alias,
|
|
9
|
+
* a package's name), the imported name stands for every exported component of that name. Each guess leans the same way,
|
|
10
|
+
* towards "has stories" and "is used", so a component is listed only when nothing in the project could be it: a list here
|
|
11
|
+
* is worth reading, and a short one is not a promise. A component a framework loads by its file's place (a page, a layout)
|
|
12
|
+
* is in neither list, and stories of a published package's components never count as unused, since what uses them is
|
|
13
|
+
* outside the repository.
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
import type { ScannedComponent } from "./componentScan.ts";
|
|
18
|
+
import type { ProjectFile } from "./projectFiles.ts";
|
|
19
|
+
/** A component as a list of the report names it. */
|
|
20
|
+
export type CoverageComponent = Pick<ScannedComponent, "name" | "file" | "line">;
|
|
21
|
+
/** A component with stories that nothing outside stories and tests draws. */
|
|
22
|
+
export type UnusedStoriedComponent = CoverageComponent & {
|
|
23
|
+
/** The story files about it. */
|
|
24
|
+
readonly storyFiles: readonly string[];
|
|
25
|
+
};
|
|
26
|
+
/** Which components have stories, and which of those the project draws. */
|
|
27
|
+
export type StoryCoverage = {
|
|
28
|
+
/** How many story files were read. */
|
|
29
|
+
readonly storyFileCount: number;
|
|
30
|
+
/** How many exported components some story is about. */
|
|
31
|
+
readonly withStories: number;
|
|
32
|
+
/** Exported components no story file is about, pages and layouts left out. */
|
|
33
|
+
readonly withoutStories: readonly CoverageComponent[];
|
|
34
|
+
/** Components with stories that no file other than a story or a test imports or draws. */
|
|
35
|
+
readonly storiesUnused: readonly UnusedStoriedComponent[];
|
|
36
|
+
/** How many components with stories were not judged unused because their package is published. */
|
|
37
|
+
readonly published: number;
|
|
38
|
+
};
|
|
39
|
+
/** A story file, in any language a catalogue reads. */
|
|
40
|
+
export declare const STORY_FILE: RegExp;
|
|
41
|
+
/**
|
|
42
|
+
* Which of a project's components have stories, and which of those its code draws.
|
|
43
|
+
*
|
|
44
|
+
* @param components - the project's components (`projectComponents`).
|
|
45
|
+
* @param files - every file read: components, story files and scripts that may import them.
|
|
46
|
+
* @param isPublished - whether a file belongs to a package the repository publishes.
|
|
47
|
+
*/
|
|
48
|
+
export declare const storyCoverage: (components: readonly ScannedComponent[], files: readonly ProjectFile[], isPublished: (file: string) => boolean) => StoryCoverage;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { exportAliasesOf, importsOf } from "./importedNames.js";
|
|
2
|
+
/** A story file, in any language a catalogue reads. */
|
|
3
|
+
export const STORY_FILE = /\.(?:stories|story)\.[cm]?[jt]sx?$|\.(?:stories|story)\.(?:vue|svelte|astro)$/;
|
|
4
|
+
/**
|
|
5
|
+
* What is never the project's own use of a component: test files by their names, and the folders only tools read. A folder
|
|
6
|
+
* merely named `tests` may be the application's own (a quiz's `tests/`), so only a file's name says it is a test.
|
|
7
|
+
*/
|
|
8
|
+
const NOT_A_USE = /\.(?:test|spec|e2e|cy)\.|(?:^|\/)(?:__tests__|__stories__|__mocks__|\.storybook|\.forgebook)\//;
|
|
9
|
+
/**
|
|
10
|
+
* A file a framework loads by its place: a route, a page, a layout, an application's entry. Nothing imports it, and no one
|
|
11
|
+
* owes it a story.
|
|
12
|
+
*/
|
|
13
|
+
const LOADED_BY_PLACE = /(?:^|\/)(?:pages|routes|layouts)\/|(?:^|\/)(?:\+page|\+layout|\+error|page|layout|template|loading|error|not-found|default|global-error|_app|_document|App|app|main|root|entry\.client|entry\.server)\.[^/]+$/;
|
|
14
|
+
/** The extensions an import may leave out, in the order a bundler tries them. */
|
|
15
|
+
const EXTENSIONS = ["", ".tsx", ".ts", ".jsx", ".js", ".mts", ".mjs", ".vue", ".svelte", ".astro"];
|
|
16
|
+
/** A prefix projects give their source folder in imports: `@/components/Button`. */
|
|
17
|
+
const ALIAS = /^(?:@|~|~~|@@|#|\$lib)\//;
|
|
18
|
+
/** A tag written in markup: `<Button`, `<my-button`; a namespace's `<UI.Button>` is read with its import. */
|
|
19
|
+
const TAG = /<([A-Z][\w$]*|[a-z][\w]*(?:-[\w]+)+)/g;
|
|
20
|
+
/** An extension an ES module's import writes for a TypeScript file: `./Button.js` is `Button.tsx`. */
|
|
21
|
+
const WRITTEN_EXTENSION = /\.[cm]?jsx?$/;
|
|
22
|
+
/** A path with its `.` and `..` folded away. */
|
|
23
|
+
const folded = (path) => {
|
|
24
|
+
const parts = [];
|
|
25
|
+
for (const part of path.split("/")) {
|
|
26
|
+
if (part === "..")
|
|
27
|
+
parts.pop();
|
|
28
|
+
else if (part !== "." && part !== "")
|
|
29
|
+
parts.push(part);
|
|
30
|
+
}
|
|
31
|
+
return parts.join("/");
|
|
32
|
+
};
|
|
33
|
+
/** A path without its extension, as an import may write it. */
|
|
34
|
+
const bare = (file) => file.replace(/\.[^./]+$/, "").replace(/\/index$/, "");
|
|
35
|
+
/**
|
|
36
|
+
* The project file an import names, when one can be told: a relative path, or an alias whose path one file ends with.
|
|
37
|
+
*
|
|
38
|
+
* @param specifier - the import's module.
|
|
39
|
+
* @param from - the importing file.
|
|
40
|
+
* @param known - the project's files.
|
|
41
|
+
* @param bySuffix - the project's files by every tail of their path without extension.
|
|
42
|
+
*/
|
|
43
|
+
const resolved = (specifier, from, known, bySuffix) => {
|
|
44
|
+
if (specifier.startsWith(".")) {
|
|
45
|
+
const written = folded(`${from.split("/").slice(0, -1).join("/")}/${specifier}`);
|
|
46
|
+
const bases = WRITTEN_EXTENSION.test(written)
|
|
47
|
+
? [written, written.replace(WRITTEN_EXTENSION, "")]
|
|
48
|
+
: [written];
|
|
49
|
+
for (const form of bases.flatMap((base) => [base, `${base}/index`])) {
|
|
50
|
+
for (const extension of EXTENSIONS)
|
|
51
|
+
if (known.has(`${form}${extension}`))
|
|
52
|
+
return `${form}${extension}`;
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
if (!ALIAS.test(specifier))
|
|
57
|
+
return undefined;
|
|
58
|
+
const files = bySuffix.get(bare(specifier.replace(ALIAS, "").replace(WRITTEN_EXTENSION, ""))) ?? [];
|
|
59
|
+
return files.length === 1 ? files[0] : undefined;
|
|
60
|
+
};
|
|
61
|
+
/** The project's files by every tail of their path without extension, `a/b/c` under `a/b/c`, `b/c` and `c`. */
|
|
62
|
+
const suffixIndex = (files) => {
|
|
63
|
+
const index = new Map();
|
|
64
|
+
for (const file of files) {
|
|
65
|
+
const parts = bare(file).split("/");
|
|
66
|
+
for (let start = 0; start < parts.length; start += 1) {
|
|
67
|
+
const suffix = parts.slice(start).join("/");
|
|
68
|
+
const listed = index.get(suffix);
|
|
69
|
+
if (listed === undefined)
|
|
70
|
+
index.set(suffix, [file]);
|
|
71
|
+
else if (!listed.includes(file))
|
|
72
|
+
listed.push(file);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return index;
|
|
76
|
+
};
|
|
77
|
+
/** A key for a component: its file and name. */
|
|
78
|
+
const keyOf = ({ file, name }) => `${file}\0${name}`;
|
|
79
|
+
/** A kebab tag's component name: `my-button` is `MyButton`. */
|
|
80
|
+
const pascal = (tag) => tag
|
|
81
|
+
.split("-")
|
|
82
|
+
.map((part) => `${part.slice(0, 1).toUpperCase()}${part.slice(1)}`)
|
|
83
|
+
.join("");
|
|
84
|
+
/** The components an import of one file reaches, by what the file declares and, failing that, by name. */
|
|
85
|
+
const reached = (name, target, lookup) => {
|
|
86
|
+
const { inFile, byName } = lookup;
|
|
87
|
+
const declared = target === undefined ? [] : (inFile.get(target) ?? []);
|
|
88
|
+
if (name.imported === "*" && declared.length > 0)
|
|
89
|
+
return declared;
|
|
90
|
+
// `export { Root as Dialog }`: the scan knows the component as Root
|
|
91
|
+
const local = (target === undefined ? undefined : lookup.aliasesOf(target).get(name.imported)) ?? name.imported;
|
|
92
|
+
const own = declared.filter((each) => name.imported === "default" ? each.isDefault === true || declared.length === 1 : each.name === local);
|
|
93
|
+
if (own.length > 0)
|
|
94
|
+
return own;
|
|
95
|
+
// a barrel, an alias or a package: the name stands for every exported component of that name
|
|
96
|
+
const asNamed = name.imported === "default" || name.imported === "*" ? name.local : name.imported;
|
|
97
|
+
return byName.get(asNamed) ?? [];
|
|
98
|
+
};
|
|
99
|
+
/** Groups a list by a key. */
|
|
100
|
+
const grouped = (items, key) => {
|
|
101
|
+
const groups = new Map();
|
|
102
|
+
for (const item of items) {
|
|
103
|
+
const group = groups.get(key(item));
|
|
104
|
+
if (group === undefined)
|
|
105
|
+
groups.set(key(item), [item]);
|
|
106
|
+
else
|
|
107
|
+
group.push(item);
|
|
108
|
+
}
|
|
109
|
+
return groups;
|
|
110
|
+
};
|
|
111
|
+
/** The components a file imports. */
|
|
112
|
+
const importedComponents = (file, text, lookup) => importsOf(text).flatMap(({ specifier, names }) => {
|
|
113
|
+
const target = resolved(specifier, file, lookup.known, lookup.bySuffix);
|
|
114
|
+
return names.flatMap((name) => reached(name, target, lookup));
|
|
115
|
+
});
|
|
116
|
+
/** The components a file writes the tag of, among those exported and its own. */
|
|
117
|
+
const taggedComponents = (file, text, lookup) => [...text.matchAll(TAG)].flatMap((match) => {
|
|
118
|
+
const tag = match[1] ?? "";
|
|
119
|
+
const name = tag.includes("-") ? pascal(tag) : tag;
|
|
120
|
+
return [...(lookup.byName.get(name) ?? []), ...(lookup.inFile.get(file) ?? [])].filter((component) => component.name === name);
|
|
121
|
+
});
|
|
122
|
+
/** Which story files are about each component, and which components the rest of the files use, by key. */
|
|
123
|
+
const readUses = (files, lookup) => {
|
|
124
|
+
const storiedBy = new Map();
|
|
125
|
+
const used = new Set();
|
|
126
|
+
for (const { file, text } of files) {
|
|
127
|
+
if (STORY_FILE.test(file)) {
|
|
128
|
+
for (const component of importedComponents(file, text, lookup)) {
|
|
129
|
+
const key = keyOf(component);
|
|
130
|
+
storiedBy.set(key, (storiedBy.get(key) ?? new Set()).add(file));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else if (!NOT_A_USE.test(file)) {
|
|
134
|
+
for (const component of importedComponents(file, text, lookup))
|
|
135
|
+
used.add(keyOf(component));
|
|
136
|
+
for (const component of taggedComponents(file, text, lookup))
|
|
137
|
+
used.add(keyOf(component));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return { storiedBy, used };
|
|
141
|
+
};
|
|
142
|
+
/** A component as a list names it. */
|
|
143
|
+
const listed = ({ name, file, line }) => ({ name, file, line });
|
|
144
|
+
/**
|
|
145
|
+
* Which of a project's components have stories, and which of those its code draws.
|
|
146
|
+
*
|
|
147
|
+
* @param components - the project's components (`projectComponents`).
|
|
148
|
+
* @param files - every file read: components, story files and scripts that may import them.
|
|
149
|
+
* @param isPublished - whether a file belongs to a package the repository publishes.
|
|
150
|
+
*/
|
|
151
|
+
export const storyCoverage = (components, files, isPublished) => {
|
|
152
|
+
const known = new Set(files.map(({ file }) => file));
|
|
153
|
+
const texts = new Map(files.map(({ file, text }) => [file, text]));
|
|
154
|
+
const aliases = new Map();
|
|
155
|
+
const aliasesOf = (file) => {
|
|
156
|
+
const found = aliases.get(file) ?? exportAliasesOf(texts.get(file) ?? "");
|
|
157
|
+
aliases.set(file, found);
|
|
158
|
+
return found;
|
|
159
|
+
};
|
|
160
|
+
const { storiedBy, used } = readUses(files, {
|
|
161
|
+
known,
|
|
162
|
+
bySuffix: suffixIndex(known),
|
|
163
|
+
aliasesOf,
|
|
164
|
+
inFile: grouped(components, ({ file }) => file),
|
|
165
|
+
byName: grouped(components.filter(({ isExported }) => isExported), ({ name }) => name)
|
|
166
|
+
});
|
|
167
|
+
const hasStories = (each) => storiedBy.has(keyOf(each));
|
|
168
|
+
const placed = components.filter(({ file }) => !LOADED_BY_PLACE.test(file));
|
|
169
|
+
const unused = placed.filter((each) => hasStories(each) && !used.has(keyOf(each)));
|
|
170
|
+
return {
|
|
171
|
+
storyFileCount: files.filter(({ file }) => STORY_FILE.test(file)).length,
|
|
172
|
+
withStories: components.filter((each) => each.isExported && hasStories(each)).length,
|
|
173
|
+
withoutStories: placed.filter((each) => each.isExported && !hasStories(each)).map(listed),
|
|
174
|
+
storiesUnused: unused
|
|
175
|
+
.filter(({ file }) => !isPublished(file))
|
|
176
|
+
.map((each) => ({ ...listed(each), storyFiles: [...(storiedBy.get(keyOf(each)) ?? [])].toSorted() })),
|
|
177
|
+
published: unused.filter(({ file }) => isPublished(file)).length
|
|
178
|
+
};
|
|
179
|
+
};
|
|
@@ -91,6 +91,24 @@ export type IndexedStoryFile = {
|
|
|
91
91
|
/** Its index. */
|
|
92
92
|
readonly index: StoryFileIndex;
|
|
93
93
|
};
|
|
94
|
+
/** A story file a group lists whose index cannot be read: the others still draw. */
|
|
95
|
+
export type RefusedStoryFile = {
|
|
96
|
+
/** Its path relative to the declaring module. */
|
|
97
|
+
readonly key: string;
|
|
98
|
+
/** The group's first pattern that lists it. */
|
|
99
|
+
readonly pattern: string;
|
|
100
|
+
/** Its absolute path. */
|
|
101
|
+
readonly file: string;
|
|
102
|
+
/** Why, naming the file (with its line and column when they are known). */
|
|
103
|
+
readonly problem: string;
|
|
104
|
+
};
|
|
105
|
+
/** A group's story files read: those indexed, and those that cannot be. */
|
|
106
|
+
export type StoryFilesRead = {
|
|
107
|
+
/** The story files indexed. */
|
|
108
|
+
readonly files: readonly IndexedStoryFile[];
|
|
109
|
+
/** The story files that cannot be. */
|
|
110
|
+
readonly refused: readonly RefusedStoryFile[];
|
|
111
|
+
};
|
|
94
112
|
/** A group's index as it is kept between starts, by file key. */
|
|
95
113
|
export type KeptIndex = Readonly<Record<string, StoryFileIndex>>;
|
|
96
114
|
/** Whether what a cache file holds is a group's index. */
|
|
@@ -106,14 +124,31 @@ export declare const isKeptIndex: (value: unknown) => value is KeptIndex;
|
|
|
106
124
|
*/
|
|
107
125
|
export declare const storyFileIndex: (root: string, pattern: string, key: string) => StoryFileIndex | string;
|
|
108
126
|
/**
|
|
109
|
-
* Every story file a group's patterns list, indexed.
|
|
127
|
+
* Every story file a group's patterns list, indexed, and those that cannot be. Only the former are kept between starts:
|
|
128
|
+
* the stamps of the others would only say what is already known, and their next read costs one file.
|
|
129
|
+
*
|
|
130
|
+
* @param root - the declaring module's folder.
|
|
131
|
+
* @param patterns - the patterns (`storyFileKeys`).
|
|
132
|
+
* @param watch - adds a file whose edit renews the module that read it: a refused one too, as its fix must.
|
|
133
|
+
* @param cache - the index kept between starts, which holds while the files it came from do; none reads them all.
|
|
134
|
+
* @param isKept - whether a listed file may be read; every one by default.
|
|
135
|
+
*/
|
|
136
|
+
export declare const readStoryFiles: (root: string, patterns: readonly string[], watch: (file: string) => void, cache?: DiskCache<KeptIndex>, isKept?: IsFileKept) => StoryFilesRead;
|
|
137
|
+
/**
|
|
138
|
+
* What fails a module that cannot go on without its files: every file refused, a line each.
|
|
139
|
+
*
|
|
140
|
+
* @param refused - the files, at least one.
|
|
141
|
+
*/
|
|
142
|
+
export declare const refusalError: (refused: readonly RefusedStoryFile[]) => Error;
|
|
143
|
+
/**
|
|
144
|
+
* Every story file a group's patterns list, indexed, for those who cannot go on without one: a build, a test.
|
|
110
145
|
*
|
|
111
146
|
* @param root - the declaring module's folder.
|
|
112
147
|
* @param patterns - the patterns (`storyFileKeys`).
|
|
113
148
|
* @param watch - adds a file whose edit renews the module that read it.
|
|
114
149
|
* @param cache - the index kept between starts, which holds while the files it came from do; none reads them all.
|
|
115
150
|
* @param isKept - whether a listed file may be read; every one by default.
|
|
116
|
-
* @throws when a story file cannot be indexed.
|
|
151
|
+
* @throws when a story file cannot be indexed, naming every one that cannot.
|
|
117
152
|
*/
|
|
118
153
|
export declare const indexedStoryFiles: (root: string, patterns: readonly string[], watch: (file: string) => void, cache?: DiskCache<KeptIndex>, isKept?: IsFileKept) => IndexedStoryFile[];
|
|
119
154
|
/** The loaders a group offers besides its story files'. */
|
|
@@ -136,6 +171,14 @@ export type GroupLoaders = {
|
|
|
136
171
|
* @returns the module's code, or a message saying which file cannot be indexed.
|
|
137
172
|
*/
|
|
138
173
|
export declare const storyFilesModule: (root: string, patterns: readonly string[], watch: (file: string) => void, loaders?: GroupLoaders, cache?: DiskCache<KeptIndex>) => string;
|
|
174
|
+
/**
|
|
175
|
+
* The stories a group needs before its stories are written as rows (`indexCode`). Rows write each key once and the
|
|
176
|
+
* objects once per story, but rows need the function that turns them back, which a small group's first load pays for
|
|
177
|
+
* more than it saves: gzip already shares a key repeated in every story. On the generated library, rows cost the shell's
|
|
178
|
+
* first load 11 bytes more at 100 stories and saved 92 at 500, so the two meet near 150; past 300 they save without
|
|
179
|
+
* doubt, and the build's own weight falls by a quarter of the index.
|
|
180
|
+
*/
|
|
181
|
+
export declare const ROWS_FROM_STORIES = 300;
|
|
139
182
|
/**
|
|
140
183
|
* The code of the module for one group, from its story files indexed.
|
|
141
184
|
*
|
|
@@ -146,5 +189,7 @@ export declare const storyFilesModule: (root: string, patterns: readonly string[
|
|
|
146
189
|
* @param loaders - the group's loaders besides its story files'.
|
|
147
190
|
* @param hasTexts - a build's: whether each file's docs, code and page come from the group's texts module, in the
|
|
148
191
|
* rows' order (`TEXTS_PREFIX`), and not each from its query.
|
|
192
|
+
* @param refused - the story files it lists that cannot be indexed, which the catalogue names among its problems.
|
|
193
|
+
* @param scriptProblems - the project's other scripts that do not parse, named among them too.
|
|
149
194
|
*/
|
|
150
|
-
export declare const storyFilesCode: (root: string, patterns: readonly string[], files: readonly IndexedStoryFile[], loaders: GroupLoaders, hasTexts?: boolean) => string;
|
|
195
|
+
export declare const storyFilesCode: (root: string, patterns: readonly string[], files: readonly IndexedStoryFile[], loaders: GroupLoaders, hasTexts?: boolean, refused?: readonly RefusedStoryFile[], scriptProblems?: readonly string[]) => string;
|