forgebook 0.3.3 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +994 -72
- package/dist/bin/forgebook/agentClient.d.ts +2 -1
- package/dist/bin/forgebook/agentClient.js +13 -6
- package/dist/bin/forgebook/agentGuide.d.ts +59 -0
- package/dist/bin/forgebook/agentGuide.js +203 -0
- package/dist/bin/forgebook/agentLoopCommands.mjs +22 -42
- package/dist/bin/forgebook/agentSetup/agentFiles.d.ts +55 -0
- package/dist/bin/forgebook/agentSetup/agentFiles.js +319 -0
- package/dist/bin/forgebook/agentSetup/assistantHooks.d.ts +71 -0
- package/dist/bin/forgebook/agentSetup/assistantHooks.js +125 -0
- package/dist/bin/forgebook/agentSetup/ciWorkflow.d.ts +23 -0
- package/dist/bin/forgebook/agentSetup/ciWorkflow.js +55 -0
- package/dist/bin/forgebook/agentSetup/drawCandidates.d.ts +25 -0
- package/dist/bin/forgebook/agentSetup/drawCandidates.js +116 -0
- package/dist/bin/forgebook/agentSetup/drawDiagnosis.d.ts +28 -0
- package/dist/bin/forgebook/agentSetup/drawDiagnosis.js +134 -0
- package/dist/bin/forgebook/agentSetup/drawRun.d.ts +91 -0
- package/dist/bin/forgebook/agentSetup/drawRun.js +353 -0
- package/dist/bin/forgebook/agentSetup/hookNames.d.ts +7 -0
- package/dist/bin/forgebook/agentSetup/hookNames.js +7 -0
- package/dist/bin/forgebook/agentSetup/initAgentSteps.d.ts +48 -0
- package/dist/bin/forgebook/agentSetup/initAgentSteps.js +104 -0
- package/dist/bin/forgebook/agentSetup/liftedProviders.d.ts +17 -0
- package/dist/bin/forgebook/agentSetup/liftedProviders.js +186 -0
- package/dist/bin/forgebook/agentSetup/projectRunner.d.ts +46 -0
- package/dist/bin/forgebook/agentSetup/projectRunner.js +85 -0
- package/dist/bin/forgebook/agentSetup/stopHook.d.ts +65 -0
- package/dist/bin/forgebook/agentSetup/stopHook.js +202 -0
- package/dist/bin/forgebook/agentSetup/uniformPicture.d.ts +7 -0
- package/dist/bin/forgebook/agentSetup/uniformPicture.js +98 -0
- package/dist/bin/forgebook/agentSetupCommands.d.mts +14 -0
- package/dist/bin/forgebook/agentSetupCommands.mjs +98 -0
- package/dist/bin/forgebook/agentText.d.ts +23 -3
- package/dist/bin/forgebook/agentText.js +182 -28
- package/dist/bin/forgebook/agents.md +20 -191
- package/dist/bin/forgebook/agentsText.js +2 -1
- package/dist/bin/forgebook/appBuild/appBuild.d.ts +59 -0
- package/dist/bin/forgebook/appBuild/appBuild.js +213 -0
- package/dist/bin/forgebook/appBuild/appViteConfig.d.ts +96 -0
- package/dist/bin/forgebook/appBuild/appViteConfig.js +320 -0
- package/dist/bin/forgebook/appBuild/tsconfigPaths.d.ts +14 -0
- package/dist/bin/forgebook/appBuild/tsconfigPaths.js +80 -0
- package/dist/bin/forgebook/auditCommand.d.mts +8 -0
- package/dist/bin/forgebook/auditCommand.mjs +75 -0
- package/dist/bin/forgebook/auditRun.d.ts +95 -0
- package/dist/bin/forgebook/auditRun.js +270 -0
- package/dist/bin/forgebook/browserRun.d.ts +21 -0
- package/dist/bin/forgebook/browserRun.js +57 -0
- package/dist/bin/forgebook/buildFailure.d.ts +7 -0
- package/dist/bin/forgebook/buildFailure.js +47 -0
- package/dist/bin/forgebook/buildWatch.d.ts +52 -0
- package/dist/bin/forgebook/buildWatch.js +137 -0
- package/dist/bin/forgebook/builtCatalogue.js +9 -5
- package/dist/bin/forgebook/catalogueCommands.d.ts +9 -0
- package/dist/bin/forgebook/catalogueCommands.js +23 -0
- package/dist/bin/forgebook/catalogueVite.d.ts +5 -1
- package/dist/bin/forgebook/catalogueVite.js +14 -6
- package/dist/bin/forgebook/commandCacheClaim.d.ts +18 -0
- package/dist/bin/forgebook/commandCacheClaim.js +170 -0
- package/dist/bin/forgebook/commandServer.d.ts +8 -0
- package/dist/bin/forgebook/commandServer.js +61 -13
- package/dist/bin/forgebook/forgebookCommands.mjs +105 -28
- package/dist/bin/forgebook/graphCommand.d.mts +8 -0
- package/dist/bin/forgebook/graphCommand.mjs +84 -0
- package/dist/bin/forgebook/guide/commands.md +62 -0
- package/dist/bin/forgebook/guide/devices.md +17 -0
- package/dist/bin/forgebook/guide/docs-pages.md +13 -0
- package/dist/bin/forgebook/guide/frameworks/angular.md +22 -0
- package/dist/bin/forgebook/guide/frameworks/html.md +22 -0
- package/dist/bin/forgebook/guide/frameworks/nextjs.md +23 -0
- package/dist/bin/forgebook/guide/frameworks/nuxt.md +22 -0
- package/dist/bin/forgebook/guide/frameworks/preact.md +16 -0
- package/dist/bin/forgebook/guide/frameworks/react-native-web.md +21 -0
- package/dist/bin/forgebook/guide/frameworks/react.md +16 -0
- package/dist/bin/forgebook/guide/frameworks/solid.md +18 -0
- package/dist/bin/forgebook/guide/frameworks/svelte.md +18 -0
- package/dist/bin/forgebook/guide/frameworks/sveltekit.md +23 -0
- package/dist/bin/forgebook/guide/frameworks/vue.md +18 -0
- package/dist/bin/forgebook/guide/frameworks/web-components.md +21 -0
- package/dist/bin/forgebook/guide/links.md +29 -0
- package/dist/bin/forgebook/guide/setup.md +23 -0
- package/dist/bin/forgebook/guide/stories.md +95 -0
- package/dist/bin/forgebook/guide/switches.md +43 -0
- package/dist/bin/forgebook/guideCommand.d.mts +13 -0
- package/dist/bin/forgebook/guideCommand.mjs +37 -0
- package/dist/bin/forgebook/importers/storybook.d.ts +21 -0
- package/dist/bin/forgebook/importers/storybook.js +11 -5
- package/dist/bin/forgebook/importers/storybookFrameworks.js +1 -1
- package/dist/bin/forgebook/initCommands.d.mts +11 -0
- package/dist/bin/forgebook/initCommands.mjs +51 -78
- package/dist/bin/forgebook/initConfig.d.ts +5 -3
- package/dist/bin/forgebook/initConfig.js +6 -3
- package/dist/bin/forgebook/initInstall.d.ts +15 -0
- package/dist/bin/forgebook/initInstall.js +77 -0
- package/dist/bin/forgebook/initPrint.d.ts +9 -0
- package/dist/bin/forgebook/initPrint.js +60 -0
- package/dist/bin/forgebook/initRefusals.d.ts +45 -0
- package/dist/bin/forgebook/initRefusals.js +91 -0
- package/dist/bin/forgebook/initRun.d.ts +28 -0
- package/dist/bin/forgebook/initRun.js +311 -0
- package/dist/bin/forgebook/mcpCommand.mjs +38 -4
- package/dist/bin/forgebook/mcpGraph.d.ts +13 -0
- package/dist/bin/forgebook/mcpGraph.js +24 -0
- package/dist/bin/forgebook/mcpTokens.d.ts +14 -0
- package/dist/bin/forgebook/mcpTokens.js +58 -0
- package/dist/bin/forgebook/mcpToolParts.d.ts +7 -0
- package/dist/bin/forgebook/mcpToolParts.js +10 -0
- package/dist/bin/forgebook/mcpTools.d.ts +13 -6
- package/dist/bin/forgebook/mcpTools.js +57 -90
- package/dist/bin/forgebook/mcpVerify.d.ts +16 -0
- package/dist/bin/forgebook/mcpVerify.js +36 -0
- package/dist/bin/forgebook/migrate/codemods.d.ts +11 -0
- package/dist/bin/forgebook/migrate/codemods.js +61 -0
- package/dist/bin/forgebook/migrate/migrate.types.d.ts +117 -0
- package/dist/bin/forgebook/migrate/migrate.types.js +5 -0
- package/dist/bin/forgebook/migrate/migrateCommand.d.mts +8 -0
- package/dist/bin/forgebook/migrate/migrateCommand.mjs +76 -0
- package/dist/bin/forgebook/migrate/migrateRun.d.ts +61 -0
- package/dist/bin/forgebook/migrate/migrateRun.js +210 -0
- package/dist/bin/forgebook/migrate/migrateText.d.ts +12 -0
- package/dist/bin/forgebook/migrate/migrateText.js +30 -0
- package/dist/bin/forgebook/migrate/migrateWrite.d.ts +27 -0
- package/dist/bin/forgebook/migrate/migrateWrite.js +66 -0
- package/dist/bin/forgebook/migrate/objectEdits.d.ts +70 -0
- package/dist/bin/forgebook/migrate/objectEdits.js +241 -0
- package/dist/bin/forgebook/migrate/playOnInBuilds.d.ts +3 -0
- package/dist/bin/forgebook/migrate/playOnInBuilds.js +86 -0
- package/dist/bin/forgebook/migrate/propGroupStrings.d.ts +5 -0
- package/dist/bin/forgebook/migrate/propGroupStrings.js +81 -0
- package/dist/bin/forgebook/newProject/newProject.d.ts +39 -0
- package/dist/bin/forgebook/newProject/newProject.js +180 -0
- package/dist/bin/forgebook/newProject/newProject.types.d.ts +97 -0
- package/dist/bin/forgebook/newProject/newProject.types.js +6 -0
- package/dist/bin/forgebook/newProject/packageManagers.d.ts +51 -0
- package/dist/bin/forgebook/newProject/packageManagers.js +121 -0
- package/dist/bin/forgebook/newProject/projectEntries.d.ts +62 -0
- package/dist/bin/forgebook/newProject/projectEntries.js +191 -0
- package/dist/bin/forgebook/newProject/projectFrameworks.d.ts +57 -0
- package/dist/bin/forgebook/newProject/projectFrameworks.js +148 -0
- package/dist/bin/forgebook/newProject/projectLook.d.ts +23 -0
- package/dist/bin/forgebook/newProject/projectLook.js +293 -0
- package/dist/bin/forgebook/newProject/projectPackages.d.ts +66 -0
- package/dist/bin/forgebook/newProject/projectPackages.js +178 -0
- package/dist/bin/forgebook/newRepair.d.ts +45 -0
- package/dist/bin/forgebook/newRepair.js +157 -0
- package/dist/bin/forgebook/newRepairRun.d.ts +69 -0
- package/dist/bin/forgebook/newRepairRun.js +148 -0
- package/dist/bin/forgebook/newStories.d.ts +23 -1
- package/dist/bin/forgebook/newStories.js +101 -11
- package/dist/bin/forgebook/newStoriesFile.d.ts +20 -1
- package/dist/bin/forgebook/newStoriesFile.js +43 -4
- package/dist/bin/forgebook/prebundleRun.d.ts +3 -1
- package/dist/bin/forgebook/prebundleRun.js +28 -8
- package/dist/bin/forgebook/proofCommand.d.mts +15 -0
- package/dist/bin/forgebook/proofCommand.mjs +212 -0
- package/dist/bin/forgebook/proofRun.d.ts +63 -0
- package/dist/bin/forgebook/proofRun.js +412 -0
- package/dist/bin/forgebook/proofText.d.ts +36 -0
- package/dist/bin/forgebook/proofText.js +131 -0
- package/dist/bin/forgebook/proofWorkflow.d.ts +29 -0
- package/dist/bin/forgebook/proofWorkflow.js +205 -0
- package/dist/bin/forgebook/setArgsTool.d.ts +8 -0
- package/dist/bin/forgebook/setArgsTool.js +70 -0
- package/dist/bin/forgebook/storyCheckCommands.mjs +42 -3
- package/dist/bin/forgebook/storyCheckRun.d.ts +50 -0
- package/dist/bin/forgebook/storyCheckRun.js +83 -9
- package/dist/bin/forgebook/storyFileIds.d.ts +15 -0
- package/dist/bin/forgebook/storyFileIds.js +14 -0
- package/dist/bin/forgebook/stressCases.d.ts +31 -0
- package/dist/bin/forgebook/stressCases.js +79 -0
- package/dist/bin/forgebook/stressRun.d.ts +12 -0
- package/dist/bin/forgebook/stressRun.js +61 -0
- package/dist/bin/forgebook/stressText.d.ts +27 -0
- package/dist/bin/forgebook/stressText.js +46 -0
- package/dist/bin/forgebook/verifyBase.d.ts +45 -0
- package/dist/bin/forgebook/verifyBase.js +204 -0
- package/dist/bin/forgebook/verifyCommand.d.mts +13 -0
- package/dist/bin/forgebook/verifyCommand.mjs +125 -0
- package/dist/bin/forgebook/verifyRun.d.ts +63 -0
- package/dist/bin/forgebook/verifyRun.js +108 -0
- package/dist/bin/forgebook/verifyVerdict.d.ts +40 -0
- package/dist/bin/forgebook/verifyVerdict.js +323 -0
- package/dist/bin/forgebook/workflowActions.d.ts +23 -0
- package/dist/bin/forgebook/workflowActions.js +23 -0
- package/dist/bin/forgebook-docs/catalogueMarkdown.js +12 -1
- package/dist/src/addressArgs.d.ts +29 -5
- package/dist/src/addressArgs.js +58 -16
- package/dist/src/addressArgsParam.d.ts +54 -0
- package/dist/src/addressArgsParam.js +51 -0
- package/dist/src/addressTexts.d.ts +14 -0
- package/dist/src/addressTexts.js +28 -21
- package/dist/src/agentIndexFile.d.ts +11 -0
- package/dist/src/agentIndexFile.js +11 -0
- package/dist/src/argConditions.d.ts +52 -0
- package/dist/src/argConditions.js +80 -0
- package/dist/src/argControl.d.ts +148 -0
- package/dist/src/argControl.js +0 -0
- package/dist/src/argExpression.d.ts +21 -0
- package/dist/src/argExpression.js +30 -0
- package/dist/src/argTypes.d.ts +40 -51
- package/dist/src/argTypes.js +69 -185
- package/dist/src/argsProps.d.ts +3 -3
- package/dist/src/argsProps.js +11 -5
- package/dist/src/bundlerErrors.d.ts +29 -0
- package/dist/src/bundlerErrors.js +49 -0
- package/dist/src/catalogue.d.ts +31 -0
- package/dist/src/catalogue.js +13 -2
- package/dist/src/catalogueRefs.d.ts +75 -0
- package/dist/src/catalogueRefs.js +122 -0
- package/dist/src/componentDocs.d.ts +83 -0
- package/dist/src/componentDocs.js +20 -3
- package/dist/src/controlCode.d.ts +27 -0
- package/dist/src/controlCode.js +41 -0
- package/dist/src/frame/callValues.d.ts +19 -0
- package/dist/src/frame/callValues.js +58 -0
- package/dist/src/frame/canvasScheme.d.ts +33 -0
- package/dist/src/frame/canvasScheme.js +67 -0
- package/dist/src/frame/controlValues.d.ts +39 -0
- package/dist/src/frame/controlValues.js +143 -0
- package/dist/src/frame/frame.css +36 -3
- package/dist/src/frame/frameStatus.d.ts +16 -1
- package/dist/src/frame/frameStatus.js +16 -1
- package/dist/src/frame/frameView.js +4 -3
- package/dist/src/frame/mountFrame.d.ts +10 -1
- package/dist/src/frame/mountFrame.js +160 -55
- package/dist/src/frame/panelControls.d.ts +67 -0
- package/dist/src/frame/panelControls.js +110 -0
- package/dist/src/frame/panelValues.d.ts +35 -0
- package/dist/src/frame/panelValues.js +127 -0
- package/dist/src/frame/playActions.d.ts +39 -0
- package/dist/src/frame/playActions.js +98 -0
- package/dist/src/frame/playStepper.d.ts +28 -0
- package/dist/src/frame/playStepper.js +38 -0
- package/dist/src/frame/playStory.d.ts +9 -1
- package/dist/src/frame/playStory.js +49 -3
- package/dist/src/frame/renderer.d.ts +34 -1
- package/dist/src/frame/renderer.js +24 -0
- package/dist/src/frame/shellChannel.d.ts +1 -1
- package/dist/src/frame/shellChannel.js +1 -1
- package/dist/src/frame/shellCheck.d.ts +17 -0
- package/dist/src/frame/shellCheck.js +25 -0
- package/dist/src/frame/shellMessageCheck.d.ts +7 -0
- package/dist/src/frame/shellMessageCheck.js +53 -0
- package/dist/src/frame/storyContent.d.ts +50 -0
- package/dist/src/frame/storyContent.js +73 -0
- package/dist/src/frame/storyModule.d.ts +9 -0
- package/dist/src/frame/storyModule.js +20 -2
- package/dist/src/frame/storyRun.d.ts +15 -7
- package/dist/src/frame/storyRun.js +64 -15
- package/dist/src/frame/valueSheets.d.ts +35 -0
- package/dist/src/frame/valueSheets.js +99 -0
- package/dist/src/hotModules.d.ts +20 -0
- package/dist/src/hotModules.js +23 -0
- package/dist/src/jsxCode.d.ts +1 -14
- package/dist/src/jsxCode.js +46 -10
- package/dist/src/liveErrors.d.ts +30 -4
- package/dist/src/liveErrors.js +18 -3
- package/dist/src/messages.d.ts +77 -27
- package/dist/src/messages.js +58 -100
- package/dist/src/namedValues.d.ts +2 -26
- package/dist/src/namedValues.js +0 -47
- package/dist/src/pageConfig.d.ts +2 -0
- package/dist/src/playTrace.d.ts +19 -2
- package/dist/src/playTrace.js +10 -5
- package/dist/src/plugin.d.ts +10 -3
- package/dist/src/previewRelay.js +9 -1
- package/dist/src/printable.d.ts +12 -0
- package/dist/src/printable.js +22 -0
- package/dist/src/propsSignature.d.ts +37 -0
- package/dist/src/propsSignature.js +40 -0
- package/dist/src/search.d.ts +41 -5
- package/dist/src/search.js +93 -23
- package/dist/src/searchMatch.d.ts +4 -1
- package/dist/src/searchMatch.js +26 -5
- package/dist/src/searchTypos.d.ts +88 -0
- package/dist/src/searchTypos.js +178 -0
- package/dist/src/shapeValues.d.ts +86 -0
- package/dist/src/shapeValues.js +295 -0
- package/dist/src/shell/ApiReference.js +6 -3
- package/dist/src/shell/ApiTableBox.d.ts +15 -0
- package/dist/src/shell/ApiTableBox.js +11 -0
- package/dist/src/shell/AppearanceMenu.d.ts +4 -1
- package/dist/src/shell/AppearanceMenu.js +9 -6
- package/dist/src/shell/AuthoredHome.js +3 -1
- package/dist/src/shell/CodeTab.d.ts +12 -6
- package/dist/src/shell/CodeTab.js +47 -3
- package/dist/src/shell/CodeText.d.ts +1 -1
- package/dist/src/shell/CodeText.js +2 -3
- package/dist/src/shell/CompareGrid.js +1 -1
- package/dist/src/shell/ComponentPage.d.ts +6 -6
- package/dist/src/shell/ComponentPage.js +8 -2
- package/dist/src/shell/CustomControl.d.ts +34 -0
- package/dist/src/shell/CustomControl.js +125 -0
- package/dist/src/shell/DocContainers.js +1 -1
- package/dist/src/shell/DocPage.js +2 -2
- package/dist/src/shell/DroppedArgsList.d.ts +2 -2
- package/dist/src/shell/DroppedArgsList.js +1 -1
- package/dist/src/shell/EmbedPage.js +30 -12
- package/dist/src/shell/Example.d.ts +5 -1
- package/dist/src/shell/Example.js +16 -8
- package/dist/src/shell/FrameView.d.ts +6 -3
- package/dist/src/shell/FrameView.js +2 -2
- package/dist/src/shell/HomePage.d.ts +3 -1
- package/dist/src/shell/HomePage.js +18 -6
- package/dist/src/shell/InfoTip.js +2 -2
- package/dist/src/shell/InteractionsTab.d.ts +11 -4
- package/dist/src/shell/InteractionsTab.js +18 -2
- package/dist/src/shell/LazyPage.js +1 -1
- package/dist/src/shell/PackageHtml.js +3 -1
- package/dist/src/shell/PageWidth.d.ts +29 -0
- package/dist/src/shell/PageWidth.js +18 -0
- package/dist/src/shell/PinnedControl.js +14 -62
- package/dist/src/shell/PinnedControlMenu.d.ts +44 -0
- package/dist/src/shell/PinnedControlMenu.js +72 -0
- package/dist/src/shell/PropFields.d.ts +3 -1
- package/dist/src/shell/PropFields.js +9 -6
- package/dist/src/shell/PropRows.d.ts +22 -11
- package/dist/src/shell/PropRows.js +62 -24
- package/dist/src/shell/PropsTab.d.ts +12 -5
- package/dist/src/shell/PropsTab.js +9 -22
- package/dist/src/shell/RefStoryPage.d.ts +33 -0
- package/dist/src/shell/RefStoryPage.js +123 -0
- package/dist/src/shell/SearchPanel.js +51 -24
- package/dist/src/shell/Shell.d.ts +18 -0
- package/dist/src/shell/Shell.js +141 -23
- package/dist/src/shell/ShortcutHelp.d.ts +22 -0
- package/dist/src/shell/ShortcutHelp.js +66 -0
- package/dist/src/shell/Sidebar.d.ts +17 -4
- package/dist/src/shell/Sidebar.js +92 -41
- package/dist/src/shell/SidebarDocs.js +2 -2
- package/dist/src/shell/SidebarEntries.js +5 -3
- package/dist/src/shell/SidebarHandle.d.ts +3 -5
- package/dist/src/shell/SidebarHandle.js +4 -4
- package/dist/src/shell/SidebarRefs.d.ts +39 -0
- package/dist/src/shell/SidebarRefs.js +99 -0
- package/dist/src/shell/SidebarSearch.js +37 -9
- package/dist/src/shell/SignatureReference.js +3 -1
- package/dist/src/shell/Stage.d.ts +10 -2
- package/dist/src/shell/Stage.js +29 -49
- package/dist/src/shell/StatusBadges.d.ts +54 -0
- package/dist/src/shell/StatusBadges.js +77 -0
- package/dist/src/shell/StoryCodeBlock.d.ts +8 -19
- package/dist/src/shell/StoryCodeBlock.js +7 -6
- package/dist/src/shell/StoryPicker.d.ts +4 -2
- package/dist/src/shell/StoryPicker.js +3 -3
- package/dist/src/shell/Switch.d.ts +29 -0
- package/dist/src/shell/Switch.js +11 -0
- package/dist/src/shell/SwitchGallery.d.ts +36 -0
- package/dist/src/shell/SwitchGallery.js +17 -0
- package/dist/src/shell/SwitchGalleryPanel.d.ts +37 -0
- package/dist/src/shell/SwitchGalleryPanel.js +99 -0
- package/dist/src/shell/TagFilter.d.ts +24 -0
- package/dist/src/shell/TagFilter.js +45 -0
- package/dist/src/shell/TagViews.d.ts +39 -0
- package/dist/src/shell/TagViews.js +20 -0
- package/dist/src/shell/Toolbar.d.ts +4 -1
- package/dist/src/shell/Toolbar.js +17 -7
- package/dist/src/shell/ToolbarControl.d.ts +3 -0
- package/dist/src/shell/ToolbarControl.js +23 -6
- package/dist/src/shell/ViewMenuPanel.js +6 -1
- package/dist/src/shell/argChecks.d.ts +22 -0
- package/dist/src/shell/argChecks.js +20 -0
- package/dist/src/shell/asideStory.js +7 -2
- package/dist/src/shell/audienceSections.css +9 -9
- package/dist/src/shell/catalogueContext.d.ts +1 -1
- package/dist/src/shell/catalogueContext.js +6 -1
- package/dist/src/shell/codeSpans.d.ts +27 -0
- package/dist/src/shell/codeSpans.js +76 -0
- package/dist/src/shell/compareVariants.d.ts +4 -2
- package/dist/src/shell/compareVariants.js +16 -8
- package/dist/src/shell/composition.d.ts +23 -0
- package/dist/src/shell/composition.js +26 -0
- package/dist/src/shell/controlCycle.d.ts +1 -1
- package/dist/src/shell/controlCycle.js +3 -2
- package/dist/src/shell/customControls.d.ts +62 -0
- package/dist/src/shell/customControls.js +81 -0
- package/dist/src/shell/docPage.css +22 -22
- package/dist/src/shell/dockTabs.d.ts +19 -3
- package/dist/src/shell/dockTabs.js +29 -20
- package/dist/src/shell/embed.css +7 -7
- package/dist/src/shell/frameOrder.d.ts +35 -0
- package/dist/src/shell/frameOrder.js +45 -0
- package/dist/src/shell/framesOrigin.d.ts +7 -0
- package/dist/src/shell/framesOrigin.js +1 -1
- package/dist/src/shell/galleryPlace.d.ts +20 -0
- package/dist/src/shell/galleryPlace.js +26 -0
- package/dist/src/shell/icons.d.ts +1 -0
- package/dist/src/shell/icons.js +1 -0
- package/dist/src/shell/keyboard.d.ts +14 -12
- package/dist/src/shell/keyboard.js +21 -6
- package/dist/src/shell/laterStrings.d.ts +30 -0
- package/dist/src/shell/laterStrings.js +43 -3
- package/dist/src/shell/mountShell.js +3 -0
- package/dist/src/shell/pageStrings.d.ts +4 -0
- package/dist/src/shell/pageStrings.js +4 -0
- package/dist/src/shell/pageTagView.d.ts +18 -0
- package/dist/src/shell/pageTagView.js +10 -0
- package/dist/src/shell/playMemory.d.ts +14 -0
- package/dist/src/shell/playMemory.js +8 -0
- package/dist/src/shell/propNotes.d.ts +23 -0
- package/dist/src/shell/propNotes.js +37 -0
- package/dist/src/shell/refIndexLoad.d.ts +17 -0
- package/dist/src/shell/refIndexLoad.js +38 -0
- package/dist/src/shell/refParts.d.ts +34 -0
- package/dist/src/shell/refParts.js +9 -0
- package/dist/src/shell/refStory.css +21 -0
- package/dist/src/shell/refStrings.d.ts +13 -0
- package/dist/src/shell/refStrings.js +21 -0
- package/dist/src/shell/search.css +11 -11
- package/dist/src/shell/shell.css +376 -169
- package/dist/src/shell/shellScheme.js +2 -2
- package/dist/src/shell/shortcutHelp.css +64 -0
- package/dist/src/shell/stageArgs.d.ts +53 -0
- package/dist/src/shell/stageArgs.js +64 -0
- package/dist/src/shell/statusBadges.css +51 -0
- package/dist/src/shell/strings.d.ts +7 -16
- package/dist/src/shell/strings.js +12 -17
- package/dist/src/shell/switchGallery.css +104 -0
- package/dist/src/shell/tagFilter.css +46 -0
- package/dist/src/shell/tagView.d.ts +20 -0
- package/dist/src/shell/tagView.js +10 -0
- package/dist/src/shell/useAddressArgs.d.ts +9 -0
- package/dist/src/shell/useAddressArgs.js +56 -11
- package/dist/src/shell/useControlKeys.js +2 -2
- package/dist/src/shell/useEditedProblems.d.ts +6 -0
- package/dist/src/shell/useEditedProblems.js +40 -0
- package/dist/src/shell/useFrameMessages.js +3 -0
- package/dist/src/shell/useFrameQueue.d.ts +8 -3
- package/dist/src/shell/useFrameQueue.js +42 -12
- package/dist/src/shell/useListedTree.d.ts +13 -0
- package/dist/src/shell/useListedTree.js +32 -0
- package/dist/src/shell/usePageFrames.js +2 -2
- package/dist/src/shell/usePopover.d.ts +5 -0
- package/dist/src/shell/usePopover.js +7 -1
- package/dist/src/shell/useRefIndex.d.ts +22 -0
- package/dist/src/shell/useRefIndex.js +36 -0
- package/dist/src/shell/useScrollSettled.d.ts +18 -0
- package/dist/src/shell/useScrollSettled.js +56 -0
- package/dist/src/shell/useScrollStops.d.ts +20 -0
- package/dist/src/shell/useScrollStops.js +41 -0
- package/dist/src/shell/useShortcutHelp.d.ts +18 -0
- package/dist/src/shell/useShortcutHelp.js +32 -0
- package/dist/src/shell/useSidebarOverlay.d.ts +2 -1
- package/dist/src/shell/useSidebarOverlay.js +12 -4
- package/dist/src/shell/useStoryCode.d.ts +2 -1
- package/dist/src/shell/useStoryCode.js +12 -7
- package/dist/src/shell/useToolbarLayout.d.ts +5 -1
- package/dist/src/shell/useToolbarLayout.js +2 -2
- package/dist/src/shell/useWorstCase.d.ts +8 -2
- package/dist/src/shell/useWorstCase.js +2 -2
- package/dist/src/shell/valueEditors/FileEditor.d.ts +28 -0
- package/dist/src/shell/valueEditors/FileEditor.js +66 -0
- package/dist/src/shell/valueEditors/JsonEditor.d.ts +14 -0
- package/dist/src/shell/valueEditors/JsonEditor.js +53 -0
- package/dist/src/shell/valueEditors/ListEditor.d.ts +24 -0
- package/dist/src/shell/valueEditors/ListEditor.js +82 -0
- package/dist/src/shell/valueEditors/ObjectEditor.d.ts +32 -0
- package/dist/src/shell/valueEditors/ObjectEditor.js +70 -0
- package/dist/src/shell/valueEditors/PropEditor.d.ts +37 -0
- package/dist/src/shell/valueEditors/PropEditor.js +53 -0
- package/dist/src/shell/valueEditors/RecordEditor.d.ts +20 -0
- package/dist/src/shell/valueEditors/RecordEditor.js +84 -0
- package/dist/src/shell/valueEditors/SearchSelect.d.ts +42 -0
- package/dist/src/shell/valueEditors/SearchSelect.js +80 -0
- package/dist/src/shell/valueEditors/TokenEditor.d.ts +49 -0
- package/dist/src/shell/valueEditors/TokenEditor.js +74 -0
- package/dist/src/shell/valueEditors/UnionEditor.d.ts +20 -0
- package/dist/src/shell/valueEditors/UnionEditor.js +64 -0
- package/dist/src/shell/valueEditors/ValueField.d.ts +15 -0
- package/dist/src/shell/valueEditors/ValueField.js +148 -0
- package/dist/src/shell/valueEditors/editorStrings.d.ts +56 -0
- package/dist/src/shell/valueEditors/editorStrings.js +66 -0
- package/dist/src/shell/valueEditors/fieldTypes.d.ts +31 -0
- package/dist/src/shell/valueEditors/fieldTypes.js +0 -0
- package/dist/src/shell/valueEditors/valueEditors.css +153 -0
- package/dist/src/shell/worstArgs.d.ts +8 -5
- package/dist/src/shell/worstArgs.js +14 -7
- package/dist/src/shellTheme.d.ts +1 -1
- package/dist/src/shellTheme.js +15 -1
- package/dist/src/shellTheme.types.d.ts +4 -0
- package/dist/src/shellWord.d.ts +12 -0
- package/dist/src/shellWord.js +15 -0
- package/dist/src/sourceFiles.js +2 -1
- package/dist/src/storyArgTypes.d.ts +57 -0
- package/dist/src/storyArgTypes.js +195 -0
- package/dist/src/storyBackground.js +14 -3
- package/dist/src/storyCheck.d.ts +99 -3
- package/dist/src/storyCheck.js +39 -1
- package/dist/src/storyCodeText.d.ts +52 -0
- package/dist/src/storyCodeText.js +30 -0
- package/dist/src/storyControls.d.ts +103 -0
- package/dist/src/storyControls.js +100 -0
- package/dist/src/storyStatuses.d.ts +55 -0
- package/dist/src/storyStatuses.js +104 -0
- package/dist/src/storyTagNames.d.ts +25 -0
- package/dist/src/storyTagNames.js +25 -0
- package/dist/src/storyTags.d.ts +29 -0
- package/dist/src/storyTags.js +85 -0
- package/dist/src/storyTree.d.ts +13 -0
- package/dist/src/storyTree.js +24 -4
- package/dist/src/storybookArgs.d.ts +24 -0
- package/dist/src/storybookArgs.js +185 -0
- package/dist/src/switches.d.ts +66 -3
- package/dist/src/switches.js +42 -1
- package/dist/src/valueSchema.d.ts +28 -0
- package/dist/src/valueSchema.js +196 -0
- package/dist/src/valueShape.d.ts +94 -0
- package/dist/src/valueShape.js +25 -0
- package/dist/src/viewState.d.ts +8 -3
- package/dist/src/viewState.js +27 -10
- package/dist/src/vite/adapter.d.ts +40 -2
- package/dist/src/vite/adapter.js +1 -0
- package/dist/src/vite/agent.types.d.ts +354 -7
- package/dist/src/vite/agentApi.d.ts +23 -0
- package/dist/src/vite/agentApi.js +90 -17
- package/dist/src/vite/agentIndex.d.ts +0 -2
- package/dist/src/vite/agentIndex.js +5 -6
- package/dist/src/vite/agentRoutes.d.ts +20 -1
- package/dist/src/vite/agentRoutes.js +135 -66
- package/dist/src/vite/agentStatuses.d.ts +42 -0
- package/dist/src/vite/agentStatuses.js +67 -0
- package/dist/src/vite/agentStoryCode.d.ts +51 -0
- package/dist/src/vite/agentStoryCode.js +44 -0
- package/dist/src/vite/agentVisibility.d.ts +47 -0
- package/dist/src/vite/agentVisibility.js +174 -0
- package/dist/src/vite/appAudit.d.ts +134 -0
- package/dist/src/vite/appAudit.js +333 -0
- package/dist/src/vite/appBuildOption.d.ts +53 -0
- package/dist/src/vite/appBuildOption.js +55 -0
- package/dist/src/vite/appTokenFiles.d.ts +92 -0
- package/dist/src/vite/appTokenFiles.js +433 -0
- package/dist/src/vite/appTokens.d.ts +23 -0
- package/dist/src/vite/appTokens.js +275 -0
- package/dist/src/vite/argControlsConfig.d.ts +30 -0
- package/dist/src/vite/argControlsConfig.js +176 -0
- package/dist/src/vite/builtTexts.d.ts +10 -0
- package/dist/src/vite/builtTexts.js +59 -22
- package/dist/src/vite/catalogueConfig.d.ts +3 -1
- package/dist/src/vite/catalogueConfig.js +21 -4
- package/dist/src/vite/changeCoverage.d.ts +74 -0
- package/dist/src/vite/changeCoverage.js +120 -0
- package/dist/src/vite/changedRoute.d.ts +30 -0
- package/dist/src/vite/changedRoute.js +197 -0
- package/dist/src/vite/checkCode.d.ts +105 -3
- package/dist/src/vite/checkCode.js +323 -36
- package/dist/src/vite/checkoutWatch.d.ts +97 -0
- package/dist/src/vite/checkoutWatch.js +287 -0
- package/dist/src/vite/closeWatch.d.ts +8 -0
- package/dist/src/vite/closeWatch.js +1 -1
- package/dist/src/vite/componentCache.d.ts +8 -0
- package/dist/src/vite/componentCache.js +66 -0
- package/dist/src/vite/componentGraph.d.ts +71 -0
- package/dist/src/vite/componentGraph.js +133 -0
- package/dist/src/vite/componentRules.d.ts +33 -0
- package/dist/src/vite/componentRules.js +105 -0
- package/dist/src/vite/componentScan.d.ts +69 -0
- package/dist/src/vite/componentScan.js +418 -0
- package/dist/src/vite/compositionCheck.d.ts +15 -0
- package/dist/src/vite/compositionCheck.js +243 -0
- package/dist/src/vite/config.d.ts +67 -1
- package/dist/src/vite/configFile.d.ts +15 -2
- package/dist/src/vite/configFile.js +109 -40
- package/dist/src/vite/configKeys.d.ts +15 -0
- package/dist/src/vite/configKeys.js +172 -0
- package/dist/src/vite/configLoadError.d.ts +23 -0
- package/dist/src/vite/configLoadError.js +71 -0
- package/dist/src/vite/cssDeclarations.d.ts +71 -0
- package/dist/src/vite/cssDeclarations.js +290 -0
- package/dist/src/vite/cssImports.d.ts +14 -0
- package/dist/src/vite/cssImports.js +48 -0
- package/dist/src/vite/cssReferences.d.ts +54 -0
- package/dist/src/vite/cssReferences.js +157 -0
- package/dist/src/vite/cssTokenValues.d.ts +50 -0
- package/dist/src/vite/cssTokenValues.js +233 -0
- package/dist/src/vite/designTokens.d.ts +24 -0
- package/dist/src/vite/designTokens.js +5 -1
- package/dist/src/vite/docsExtractor.d.ts +9 -3
- package/dist/src/vite/docsExtractor.js +11 -3
- package/dist/src/vite/docsProgram.d.ts +17 -4
- package/dist/src/vite/docsProgram.js +52 -11
- package/dist/src/vite/docsWorker.js +7 -2
- package/dist/src/vite/emptyStoryGlobs.d.ts +41 -0
- package/dist/src/vite/emptyStoryGlobs.js +52 -0
- package/dist/src/vite/fileImports.d.ts +17 -0
- package/dist/src/vite/fileImports.js +57 -0
- package/dist/src/vite/findComponent.d.ts +10 -2
- package/dist/src/vite/findComponent.js +27 -22
- package/dist/src/vite/findRoute.js +3 -2
- package/dist/src/vite/forcedStates.d.ts +9 -2
- package/dist/src/vite/forcedStates.js +12 -3
- package/dist/src/vite/forgebookPlugin.d.ts +2 -0
- package/dist/src/vite/forgebookPlugin.js +55 -73
- package/dist/src/vite/frameErrors.d.ts +19 -0
- package/dist/src/vite/frameErrors.js +70 -0
- package/dist/src/vite/framesServer.d.ts +12 -0
- package/dist/src/vite/framesServer.js +21 -4
- package/dist/src/vite/functionComponentDocs.js +81 -12
- package/dist/src/vite/generatedModules.js +4 -2
- package/dist/src/vite/gitChange.d.ts +38 -5
- package/dist/src/vite/gitChange.js +71 -11
- package/dist/src/vite/hiddenStoryFiles.d.ts +23 -0
- package/dist/src/vite/hiddenStoryFiles.js +107 -0
- package/dist/src/vite/hotSnippets.d.ts +38 -14
- package/dist/src/vite/hotSnippets.js +137 -39
- package/dist/src/vite/importedNames.d.ts +37 -0
- package/dist/src/vite/importedNames.js +138 -0
- package/dist/src/vite/indexFields.d.ts +6 -0
- package/dist/src/vite/indexFields.js +21 -0
- package/dist/src/vite/indexStoryFile.d.ts +8 -1
- package/dist/src/vite/indexStoryFile.js +22 -157
- package/dist/src/vite/jsxCallSites.d.ts +33 -0
- package/dist/src/vite/jsxCallSites.js +200 -0
- package/dist/src/vite/jsxInScripts.d.ts +67 -0
- package/dist/src/vite/jsxInScripts.js +138 -0
- package/dist/src/vite/jsxTree.d.ts +20 -0
- package/dist/src/vite/jsxTree.js +163 -0
- package/dist/src/vite/lineAndColumn.d.ts +13 -0
- package/dist/src/vite/lineAndColumn.js +18 -0
- package/dist/src/vite/lookAlikes.d.ts +65 -0
- package/dist/src/vite/lookAlikes.js +228 -0
- package/dist/src/vite/nearestToken.d.ts +17 -0
- package/dist/src/vite/nearestToken.js +9 -2
- package/dist/src/vite/packageEntries.d.ts +42 -0
- package/dist/src/vite/packageEntries.js +127 -0
- package/dist/src/vite/pages.d.ts +9 -1
- package/dist/src/vite/pages.js +119 -4
- package/dist/src/vite/pluginConfig.js +4 -0
- package/dist/src/vite/pluginIds.d.ts +2 -0
- package/dist/src/vite/pluginIds.js +5 -1
- package/dist/src/vite/pluginModules.d.ts +81 -11
- package/dist/src/vite/pluginModules.js +109 -21
- package/dist/src/vite/prebundled.d.ts +57 -15
- package/dist/src/vite/prebundled.js +80 -0
- package/dist/src/vite/previewTags.d.ts +25 -0
- package/dist/src/vite/previewTags.js +56 -0
- package/dist/src/vite/projectFiles.d.ts +54 -0
- package/dist/src/vite/projectFiles.js +116 -0
- package/dist/src/vite/projectPostcss.d.ts +70 -0
- package/dist/src/vite/projectPostcss.js +250 -0
- package/dist/src/vite/propDocs.d.ts +12 -0
- package/dist/src/vite/propDocs.js +187 -60
- package/dist/src/vite/propKind.d.ts +40 -0
- package/dist/src/vite/propKind.js +71 -0
- package/dist/src/vite/propTypeNotes.d.ts +22 -0
- package/dist/src/vite/propTypeNotes.js +51 -0
- package/dist/src/vite/publishedExports.d.ts +27 -0
- package/dist/src/vite/publishedExports.js +298 -0
- package/dist/src/vite/realFolder.d.ts +6 -0
- package/dist/src/vite/realFolder.js +25 -0
- package/dist/src/vite/refsConfig.d.ts +39 -0
- package/dist/src/vite/refsConfig.js +54 -0
- package/dist/src/vite/reuseCheck.d.ts +45 -0
- package/dist/src/vite/reuseCheck.js +260 -0
- package/dist/src/vite/runningVersions.d.ts +33 -0
- package/dist/src/vite/runningVersions.js +25 -0
- package/dist/src/vite/scriptProblems.d.ts +60 -0
- package/dist/src/vite/scriptProblems.js +155 -0
- package/dist/src/vite/searchModule.js +3 -2
- package/dist/src/vite/searchRoute.js +4 -2
- package/dist/src/vite/shapeDocs.d.ts +36 -0
- package/dist/src/vite/shapeDocs.js +177 -0
- package/dist/src/vite/singleFileComponent.d.ts +17 -0
- package/dist/src/vite/singleFileComponent.js +83 -0
- package/dist/src/vite/sourceText.d.ts +34 -0
- package/dist/src/vite/sourceText.js +72 -0
- package/dist/src/vite/sourceTokens.d.ts +7 -0
- package/dist/src/vite/sourceTokens.js +7 -2
- package/dist/src/vite/stackLines.d.ts +49 -0
- package/dist/src/vite/stackLines.js +96 -0
- package/dist/src/vite/storyCode.d.ts +22 -7
- package/dist/src/vite/storyCode.js +263 -37
- package/dist/src/vite/storyCoverage.d.ts +48 -0
- package/dist/src/vite/storyCoverage.js +179 -0
- package/dist/src/vite/storyFilesModule.d.ts +48 -3
- package/dist/src/vite/storyFilesModule.js +105 -15
- package/dist/src/vite/storyPatterns.d.ts +31 -0
- package/dist/src/vite/storyPatterns.js +140 -5
- package/dist/src/vite/storyReach.d.ts +10 -2
- package/dist/src/vite/storyReach.js +15 -11
- package/dist/src/vite/storyTopLevel.d.ts +51 -0
- package/dist/src/vite/storyTopLevel.js +146 -0
- package/dist/src/vite/storylessRoutes.d.ts +4 -3
- package/dist/src/vite/storylessRoutes.js +210 -19
- package/dist/src/vite/switchValuesCheck.d.ts +19 -0
- package/dist/src/vite/switchValuesCheck.js +164 -0
- package/dist/src/vite/switchesDocument.d.ts +15 -0
- package/dist/src/vite/switchesDocument.js +47 -0
- package/dist/src/vite/tailwindConfigTokens.d.ts +41 -0
- package/dist/src/vite/tailwindConfigTokens.js +306 -0
- package/dist/src/vite/textImports.d.ts +15 -0
- package/dist/src/vite/textImports.js +58 -0
- package/dist/src/vite/textModules.d.ts +6 -5
- package/dist/src/vite/textModules.js +13 -8
- package/dist/src/vite/tokenAnswers.d.ts +6 -2
- package/dist/src/vite/tokenAnswers.js +11 -7
- package/dist/src/vite/typeParameters.d.ts +83 -0
- package/dist/src/vite/typeParameters.js +270 -0
- package/dist/src/vite/typedControls.d.ts +31 -0
- package/dist/src/vite/typedControls.js +66 -0
- package/dist/src/vite/unionProps.d.ts +37 -0
- package/dist/src/vite/unionProps.js +121 -0
- package/dist/src/vite/unresolvedTokens.d.ts +20 -0
- package/dist/src/vite/unresolvedTokens.js +193 -0
- package/dist/src/vite/usageGraph.js +10 -52
- package/dist/src/vite/usageGuidance.d.ts +9 -2
- package/dist/src/vite/usageGuidance.js +36 -8
- package/dist/src/vite/usageImports.d.ts +35 -0
- package/dist/src/vite/usageImports.js +280 -0
- package/dist/src/vite/visibilityRoute.d.ts +16 -0
- package/dist/src/vite/visibilityRoute.js +320 -0
- package/dist/src/worstCase.d.ts +2 -0
- package/dist/src/worstCase.js +2 -0
- package/package.json +28 -8
|
@@ -4,27 +4,87 @@ const HEX_COLOR = /(?:^|[\s:'"`(,[=])(#(?:[0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{3,4})
|
|
|
4
4
|
/** A colour function, not a function of that name being declared or a template being written. */
|
|
5
5
|
const COLOR_FUNCTION = /(?<![\w.])(?:rgba?|hsla?|oklch|oklab)\((?![^)]*\$\{)[\d\s.,%/-]+\)/gi;
|
|
6
6
|
/** A size, signed or in Tailwind's brackets. */
|
|
7
|
-
const SIZE = /(?:^|[\s:'"`(,[-])(\d*\.?\d+(?:px|rem))\b/g;
|
|
7
|
+
export const SIZE = /(?:^|[\s:'"`(,[-])(\d*\.?\d+(?:px|rem))\b/g;
|
|
8
8
|
/** A comment that turns a check off. */
|
|
9
9
|
const SUPPRESSION = /(?:\/\/|\/\*|<!--|\{\/\*)\s*(?:@ts-ignore|@ts-expect-error|@ts-nocheck|eslint-disable|biome-ignore|stylelint-disable)/;
|
|
10
|
+
/**
|
|
11
|
+
* What the check is told a value is meant, on its line or the one above: its rule and why. A value this cannot judge (a
|
|
12
|
+
* default a user may change, a brand's colour) has to have a way out that says so in the code, or the whole check goes.
|
|
13
|
+
*/
|
|
14
|
+
const IGNORE_COMMENT = /(?:\/\/|\/\*|<!--)\s*forgebook-ignore\s+(raw-color|raw-size)\s*:\s*([^*\n]{3,120})/g;
|
|
10
15
|
/** What says why after a suppression: the repository's rule allows one with a reason. */
|
|
11
16
|
const HAS_REASON = /(?:biome-ignore [^:]+:\s*\S|eslint-disable[^*]*--\s*\S|@ts-expect-error\s+\S)/;
|
|
12
17
|
/** The files where a raw value is a mistake: styles and components. */
|
|
13
|
-
const CHECKED_FILE = /\.(?:css|scss|sass|less|tsx|jsx|vue|svelte|astro)$/;
|
|
14
|
-
/**
|
|
15
|
-
|
|
18
|
+
export const CHECKED_FILE = /\.(?:css|scss|sass|less|tsx|jsx|vue|svelte|astro)$/;
|
|
19
|
+
/**
|
|
20
|
+
* Where raw values belong: stories, tests, tokens and what a tool wrote; and what is drawn where a page's custom
|
|
21
|
+
* properties do not reach, as an email or a generated social image.
|
|
22
|
+
*/
|
|
23
|
+
export const LEFT_ALONE = /(?:\.stories\.|\.test\.|\.spec\.|\.e2e\.|\.min\.|opengraph|twitter-image|(?:^|\/)_?(?:design-)?tokens?(?:\.|\/)|\.tokens?\.|(?:^|\/)theme\.|(?:^|\/)(?:__tests__|tests?|e2e|dist|build|generated|vendor|og|emails?)\/)/;
|
|
24
|
+
/** A style sheet. */
|
|
25
|
+
const SHEET_FILE = /\.(?:css|scss|sass|less)$/;
|
|
16
26
|
/** A test file. */
|
|
17
27
|
const TEST_FILE = /(?:\.test\.|\.spec\.|\.e2e\.|_test\.|(?:^|\/)(?:__tests__|tests?|e2e)\/)/;
|
|
18
28
|
/** A hunk's header: where its lines start in the new file. */
|
|
19
29
|
const HUNK = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
|
|
20
30
|
/** A line that defines a value: a custom property or a Sass variable, where raw values belong. */
|
|
21
|
-
const DEFINES_VALUE = /^\s*(?:--[\w-]+|\$[\w-]+)\s*:/;
|
|
31
|
+
export const DEFINES_VALUE = /^\s*(?:--[\w-]+|\$[\w-]+)\s*:/;
|
|
32
|
+
/** How far before a size its property or class is looked for, in characters. */
|
|
33
|
+
const LOOK_BACK = 200;
|
|
34
|
+
/** Past this a line is data or a minified bundle, written by no one, and these patterns would take long to read it. */
|
|
35
|
+
export const LONGEST_LINE = 2000;
|
|
36
|
+
/** A line inside a block comment, whose start this cannot see when only added lines are read. */
|
|
37
|
+
const COMMENT_LINE = /^\s*\*(?:\s|\/|$)/;
|
|
38
|
+
/** A custom property declared in the middle of a line, as a sheet's one-line `:root { … }` does. */
|
|
39
|
+
const CUSTOM_PROPERTY = /(?<![\w-])--[\w-]+\s*:[^;}]*;?/g;
|
|
22
40
|
/** A media condition, where `var()` does not work, so a token cannot stand in. */
|
|
23
41
|
const MEDIA_CONDITION = /@(?:media|container)\b/;
|
|
24
|
-
/** A
|
|
25
|
-
const
|
|
26
|
-
/** A
|
|
27
|
-
const
|
|
42
|
+
/** A custom property read from a script, with what shows if it is missing: the token being used, as in `var()`. */
|
|
43
|
+
const SCRIPT_FALLBACK = /getPropertyValue\([^()]*\)[^"'`]{0,20}(?:\|\||\?\?)\s*["'`][^"'`]*["'`]/g;
|
|
44
|
+
/** A Vue slot's shorthand, whose name may read as a colour (`<template #add>`). */
|
|
45
|
+
const SLOT_SHORTHAND = /<template\s+#[\w-]+/;
|
|
46
|
+
/** A Tailwind class holding a mask, whose colours only give it alpha. */
|
|
47
|
+
const MASK_CLASS = /\bmask-\[[^\]]*\]/g;
|
|
48
|
+
/** A `var()` with a fallback, one level of parentheses inside it. */
|
|
49
|
+
const VAR_FALLBACK = /var\(\s*--[\w-]+\s*,[^()]*(?:\([^()]*\)[^()]*)*\)/g;
|
|
50
|
+
/**
|
|
51
|
+
* Where a colour is not the system's to give: the shapes of a drawing (a logo keeps its own colours), a mask (only its
|
|
52
|
+
* alpha counts), a canvas, and what the browser reads from the page's head (`theme-color`), which a custom property
|
|
53
|
+
* cannot reach.
|
|
54
|
+
*/
|
|
55
|
+
const NOT_A_COLOUR_OF_THE_SYSTEM = /^\s*(?:fill|stroke|stop-?color)=|<(?:path|circle|rect|g|stop|ellipse|polygon|polyline|line|linearGradient|radialGradient)\b|\bstop-?color\s*[=:]|(?:\b-?webkit-?|\b)mask(?:-?image)?\s*:|theme[-_]?color|<meta\b|\bmeta\d*\.|\b(?:fillStyle|strokeStyle|shadowColor)\b/i;
|
|
56
|
+
/**
|
|
57
|
+
* A line of a table of colours, keyed by a step (`500: "#3b82f6"`): a palette shown or converted, written as data, and a
|
|
58
|
+
* single table would otherwise be hundreds of findings.
|
|
59
|
+
*/
|
|
60
|
+
const PALETTE_ROW = /^\s*["']?\d+["']?\s*:\s*["'`][^"'`]*["'`],?\s*$/;
|
|
61
|
+
/** Black or white picked by what is underneath: the contrast of a colour a user chose, which no token can know. */
|
|
62
|
+
const CONTRAST_PICK = /\?\s*["'`]#(?:fff|ffffff|000|000000)["'`]\s*:\s*["'`]#(?:fff|ffffff|000|000000)["'`]/i;
|
|
63
|
+
/** A selector, whose `#` is an id; an object's line ends in a comma too, but holds its value in quotes. */
|
|
64
|
+
const SELECTOR_LINE = /\{\s*$|^[^"'`]*,\s*$/;
|
|
65
|
+
/** A name's last part that makes it a step of a scale. */
|
|
66
|
+
const SCALE_STEP = /-(?:\d+(?:\.\d+)?|\d*x[sl]|sm|md|lg|small|medium|large|tiny|huge)$/i;
|
|
67
|
+
/** Tailwind's utilities whose arbitrary sizes have an equal on a scale. */
|
|
68
|
+
const UTILITY_ROLES = [
|
|
69
|
+
[/^rounded/, "radius"],
|
|
70
|
+
[/^text$/, "font"],
|
|
71
|
+
[
|
|
72
|
+
/^(?:[pm][xytrblse]?|gap(?:-[xy])?|space-[xy]|[wh]|size|(?:min|max)-[wh]|inset(?:-[xy])?|top|right|bottom|left)$/,
|
|
73
|
+
"space"
|
|
74
|
+
]
|
|
75
|
+
];
|
|
76
|
+
/** The properties whose sizes have an equal on a scale. */
|
|
77
|
+
const PROPERTY_ROLES = [
|
|
78
|
+
[/radius/i, "radius"],
|
|
79
|
+
[/^font-?size$/i, "font"],
|
|
80
|
+
[/^(?:margin|padding|gap|row-?gap|column-?gap)/i, "space"]
|
|
81
|
+
];
|
|
82
|
+
/**
|
|
83
|
+
* A line's code, without what follows a `//` or a comment's start.
|
|
84
|
+
*
|
|
85
|
+
* @param text - the line.
|
|
86
|
+
*/
|
|
87
|
+
export const withoutComment = (text) => text.replace(/(?:^|\s)\/\/.*$/, "").replace(/\/\*.*$/, "");
|
|
28
88
|
/**
|
|
29
89
|
* The lines a unified diff adds. A header is read only outside a hunk, since an added line of `++ x` looks like one.
|
|
30
90
|
*
|
|
@@ -72,30 +132,125 @@ export const deletedTests = (deleted) => deleted
|
|
|
72
132
|
value: file,
|
|
73
133
|
message: "A test was deleted: fix what it found, or say why it no longer applies."
|
|
74
134
|
}));
|
|
75
|
-
/**
|
|
135
|
+
/** How a token is written, for a message: with the Tailwind class's end when it has one. */
|
|
136
|
+
const writtenAs = (name, tokens) => {
|
|
137
|
+
const utility = tokens.find((token) => token.name === name)?.utility;
|
|
138
|
+
return utility === undefined ? name : `${name} (…-${utility} in a class)`;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* The problem of a raw colour: a fix only from one token that holds in every theme. Two tokens with one value say what it
|
|
142
|
+
* is for, which this cannot tell (white is `--card` and `--primary-foreground`), so they are named and neither is the fix.
|
|
143
|
+
*/
|
|
76
144
|
const colorProblem = ({ file, line }, value, tokens) => {
|
|
77
|
-
const
|
|
145
|
+
const matches = nearestTokens(tokens, value, "color").matches.filter((each) => each.isClose);
|
|
146
|
+
const close = matches.filter((each) => each.mode === undefined);
|
|
147
|
+
const [match] = close;
|
|
148
|
+
const base = { rule: "raw-color", file, line, value };
|
|
149
|
+
if (match === undefined) {
|
|
150
|
+
const themed = matches[0];
|
|
151
|
+
return {
|
|
152
|
+
...base,
|
|
153
|
+
message: themed === undefined
|
|
154
|
+
? "A colour written by hand, and no token is close: ask whether the design system has it."
|
|
155
|
+
: `A colour written by hand: ${writtenAs(themed.name, tokens)} is ${themed.value} in the ${themed.mode ?? ""} theme, so use it if it is meant to follow the theme.`
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
// read back from text, an equal colour may differ past what the answer rounds: zero there is the same colour
|
|
159
|
+
const same = close.filter((each) => each.distance === 0);
|
|
160
|
+
if (new Set(same.map((each) => each.alias ?? each.name)).size > 1) {
|
|
161
|
+
const names = same.map((each) => each.name).join(" or ");
|
|
162
|
+
return { ...base, message: `A colour written by hand: use ${names}, whichever it is for.` };
|
|
163
|
+
}
|
|
78
164
|
return {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
value,
|
|
83
|
-
...(match === undefined ? {} : { fix: match.name }),
|
|
84
|
-
message: match === undefined
|
|
85
|
-
? "A colour written by hand, and no token is close: ask whether the design system has it."
|
|
86
|
-
: `A colour written by hand: use the token ${match.name} (${match.value}).`
|
|
165
|
+
...base,
|
|
166
|
+
fix: match.name,
|
|
167
|
+
message: `A colour written by hand: use the token ${writtenAs(match.name, tokens)} (${match.value}).`
|
|
87
168
|
};
|
|
88
169
|
};
|
|
89
|
-
/**
|
|
90
|
-
const
|
|
170
|
+
/** Whether a value has no alpha at all: a gradient's end, which shows nothing of its colour. */
|
|
171
|
+
const isFullyTransparent = (value) => /[,/]\s*0*\.?0*%?\s*\)$/.test(value);
|
|
172
|
+
/** Whether a value is black or white made translucent: a shadow's or a scrim's darkening, which no palette holds. */
|
|
173
|
+
const isNeutralShade = (value) => /^rgba?\(\s*(?:0[\s,]+0[\s,]+0|255[\s,]+255[\s,]+255)\b/i.test(value) ||
|
|
174
|
+
/^oklch\(\s*[01](?:\.0+)?%?\s+0\s+0\s*\//i.test(value) ||
|
|
175
|
+
/^hsla?\(\s*0[\s,]+0%[\s,]+(?:0|100)%[\s,/]/i.test(value) ||
|
|
176
|
+
/^#(?:0{6}|f{6})[0-9a-f]{2}$/i.test(value) ||
|
|
177
|
+
/^#(?:0{3}|f{3})[0-9a-f]$/i.test(value);
|
|
178
|
+
/**
|
|
179
|
+
* The colours written by hand in a line of code, leaving out what is not the system's to give.
|
|
180
|
+
*
|
|
181
|
+
* @param written - the line, its comment taken off.
|
|
182
|
+
*/
|
|
183
|
+
export const rawColorsOf = (written) => {
|
|
184
|
+
// a fallback in `var()` is the token being used; the value is what shows only if it is missing
|
|
185
|
+
const plain = written.replace(VAR_FALLBACK, "var()").replace(SCRIPT_FALLBACK, "").replace(MASK_CLASS, "");
|
|
186
|
+
// a theme's pair of values is what a token is for; a pick on anything else is a contrast
|
|
187
|
+
const code = /theme|mode|dark\s*[=?]/i.test(plain) ? plain : plain.replace(CONTRAST_PICK, "");
|
|
91
188
|
if (SELECTOR_LINE.test(code) || /(?:href|url)\s*[=(]/.test(code))
|
|
92
189
|
return [];
|
|
190
|
+
if (NOT_A_COLOUR_OF_THE_SYSTEM.test(code) || PALETTE_ROW.test(code))
|
|
191
|
+
return [];
|
|
192
|
+
if (SLOT_SHORTHAND.test(code))
|
|
193
|
+
return [];
|
|
93
194
|
// digits alone are a number more often than a colour (`Order #1042`), unless they stand as a value
|
|
94
195
|
const hexes = [...code.matchAll(HEX_COLOR)]
|
|
95
196
|
.flatMap((match) => match[1] ?? [])
|
|
96
197
|
.filter((value) => !/^#\d+$/.test(value) || new RegExp(`[:=]\\s*['"\`]?${value}`).test(code));
|
|
97
198
|
const functions = [...code.matchAll(COLOR_FUNCTION)].map((match) => match[0]);
|
|
98
|
-
|
|
199
|
+
const isShadow = /shadow/i.test(code);
|
|
200
|
+
return [...hexes, ...functions].filter((value) => !isFullyTransparent(value) && !(isShadow && isNeutralShade(value)));
|
|
201
|
+
};
|
|
202
|
+
/** The raw colours in a line of code, as problems. */
|
|
203
|
+
const colorProblems = (added, written, tokens) => rawColorsOf(written).map((value) => colorProblem(added, value, tokens));
|
|
204
|
+
/**
|
|
205
|
+
* What a token read from an application is for, from its name, when it is a step of a scale (`--radius-lg`, `--space-2`):
|
|
206
|
+
* `--sidebar-padding` and `--custom-block-font-size` are one place's values, and do not make every equal size a mistake.
|
|
207
|
+
*/
|
|
208
|
+
const tokenRole = (name) => {
|
|
209
|
+
if (!SCALE_STEP.test(name))
|
|
210
|
+
return undefined;
|
|
211
|
+
if (/radius|rounded/i.test(name))
|
|
212
|
+
return "radius";
|
|
213
|
+
if (/^--text-|font-?size|^--fs-/i.test(name))
|
|
214
|
+
return "font";
|
|
215
|
+
return /spac|gap|gutter|margin|padding|^--size-/i.test(name) ? "space" : undefined;
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* What a size in a line is for, and whether a class holds it; none when it stands in a sum no token can replace.
|
|
219
|
+
*
|
|
220
|
+
* @param before - the line up to the size.
|
|
221
|
+
*/
|
|
222
|
+
export const roleInLine = (before) => {
|
|
223
|
+
// what decides is close by: a limit keeps these patterns linear on a long line
|
|
224
|
+
const near = before.slice(-LOOK_BACK);
|
|
225
|
+
if (/-\[[^\]]*$/.test(near)) {
|
|
226
|
+
// only where the brackets hold the value: `calc()` inside them has no class to replace it
|
|
227
|
+
const utility = /(?:^|[\s"'`:])-?([a-z]+(?:-[a-z]+)*)-\[[^\](]*$/.exec(near)?.[1];
|
|
228
|
+
const role = UTILITY_ROLES.find(([pattern]) => utility !== undefined && pattern.test(utility))?.[1];
|
|
229
|
+
return role === undefined ? undefined : { role, isClass: true };
|
|
230
|
+
}
|
|
231
|
+
const [, property = "", value = ""] = /([a-zA-Z-]+)["']?\s*:([^:;{}]*)$/.exec(near) ?? [];
|
|
232
|
+
if (value.split("(").length > value.split(")").length)
|
|
233
|
+
return undefined;
|
|
234
|
+
const role = PROPERTY_ROLES.find(([pattern]) => pattern.test(property))?.[1];
|
|
235
|
+
return role === undefined ? undefined : { role, isClass: false };
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* The tokens a size can be compared with where it stands: a tokens file's all, an application's of its role. Tailwind's
|
|
239
|
+
* own scale counts only in a class's brackets, where a class of that scale says the same (`p-[16px]`, `p-4`): in a sheet
|
|
240
|
+
* or a style, a size equal to a step of a scale nobody there chose means nothing.
|
|
241
|
+
*
|
|
242
|
+
* @param tokens - the tokens.
|
|
243
|
+
* @param before - the line up to the size.
|
|
244
|
+
*/
|
|
245
|
+
export const sizeTokens = (tokens, before) => {
|
|
246
|
+
const where = roleInLine(before);
|
|
247
|
+
return tokens.filter((token) => {
|
|
248
|
+
if (token.origin === undefined)
|
|
249
|
+
return true;
|
|
250
|
+
if (where === undefined || tokenRole(token.name) !== where.role)
|
|
251
|
+
return false;
|
|
252
|
+
return token.origin.kind !== "tailwind-default" || where.isClass;
|
|
253
|
+
});
|
|
99
254
|
};
|
|
100
255
|
/** The sizes in a line that equal one token: two that do say what the size is for, which this cannot tell. */
|
|
101
256
|
const sizeProblems = ({ file, line }, code, tokens) => {
|
|
@@ -103,17 +258,73 @@ const sizeProblems = ({ file, line }, code, tokens) => {
|
|
|
103
258
|
return [];
|
|
104
259
|
return [...code.matchAll(SIZE)].flatMap((found) => {
|
|
105
260
|
const value = found[1] ?? "";
|
|
106
|
-
const
|
|
261
|
+
const candidates = sizeTokens(tokens, code.slice(0, found.index + found[0].indexOf(value)));
|
|
262
|
+
const exact = nearestTokens(candidates, value, "dimension").matches.filter((each) => each.isExact && each.mode === undefined);
|
|
107
263
|
const [only] = exact;
|
|
108
264
|
if (only === undefined)
|
|
109
265
|
return [];
|
|
110
266
|
const fix = exact.length === 1 ? { fix: only.name } : {};
|
|
111
|
-
const names = exact.map((each) => each.name).join(" or ");
|
|
267
|
+
const names = exact.map((each) => writtenAs(each.name, tokens)).join(" or ");
|
|
112
268
|
return [
|
|
113
269
|
{ rule: "raw-size", file, line, value, ...fix, message: `A size written by hand: use ${names}.` }
|
|
114
270
|
];
|
|
115
271
|
});
|
|
116
272
|
};
|
|
273
|
+
/**
|
|
274
|
+
* A size a style object writes as a bare number, which React reads as pixels: `marginTop: 6`, `style={{ padding: 12 }}`,
|
|
275
|
+
* a styled component's object. Only the properties whose sizes have an equal on a scale, spelled as a style object spells
|
|
276
|
+
* them, and only a number that ends the value: `padding: 8 * scale` is a sum no token replaces.
|
|
277
|
+
*/
|
|
278
|
+
const OBJECT_SIZE = /(?:^|[\s{,(])["']?((?:margin|padding)(?:Top|Right|Bottom|Left|Inline|Block|InlineStart|InlineEnd|BlockStart|BlockEnd|Horizontal|Vertical)?|gap|rowGap|columnGap|fontSize|border(?:TopLeft|TopRight|BottomLeft|BottomRight|StartStart|StartEnd|EndStart|EndEnd)?Radius)["']?\s*:\s*-?(\d*\.?\d+)(?=\s*(?:[,})]|$))/g;
|
|
279
|
+
/** The files where a bare number in a style object is pixels: React's, which adds the unit; Vue, Svelte and Solid do not. */
|
|
280
|
+
const PIXELS_FOR_NUMBERS = /\.[jt]sx$/;
|
|
281
|
+
/**
|
|
282
|
+
* What says on the line itself that an object is a style. The same keys are options elsewhere (`fitView({ padding: 0.3 })`,
|
|
283
|
+
* `measureText(text, { fontSize: 12 })`, an export's `padding: 16`), and an added line seldom shows the object's start.
|
|
284
|
+
*/
|
|
285
|
+
const STYLE_OBJECT = /\b(?:style|sx)\s*=\s*\{\{|\bstyle\s*:\s*\{|:\s*(?:React\.)?CSSProperties\b|\bstyled(?:\.\w+|\([^)]*\))\s*\(|\bcss\(\s*\{|\bStyleSheet\.create\(/;
|
|
286
|
+
/** The role of a style object's property: the same scales as the sheet's property, which every key it reads has. */
|
|
287
|
+
const objectRole = (property) => PROPERTY_ROLES.find(([pattern]) => pattern.test(property))?.[1] ?? "space";
|
|
288
|
+
/**
|
|
289
|
+
* The bare numbers of an object in a line that equal one token, as sizes in pixels: a problem where the line says the
|
|
290
|
+
* object is a style, advice where it does not, since an option of the same name is no style.
|
|
291
|
+
*/
|
|
292
|
+
const objectSizeFindings = ({ file, line }, code, tokens) => {
|
|
293
|
+
if (!PIXELS_FOR_NUMBERS.test(file))
|
|
294
|
+
return { problems: [], advice: [] };
|
|
295
|
+
const isStyle = STYLE_OBJECT.test(code);
|
|
296
|
+
const found = [...code.matchAll(OBJECT_SIZE)].flatMap((match) => {
|
|
297
|
+
const [, property = "", number = ""] = match;
|
|
298
|
+
if (Number(number) === 0)
|
|
299
|
+
return [];
|
|
300
|
+
const role = objectRole(property);
|
|
301
|
+
const candidates = tokens.filter((token) => token.origin === undefined ||
|
|
302
|
+
(token.origin.kind !== "tailwind-default" && tokenRole(token.name) === role));
|
|
303
|
+
const exact = nearestTokens(candidates, `${number}px`, "dimension").matches.filter((each) => each.isExact && each.mode === undefined);
|
|
304
|
+
const [only] = exact;
|
|
305
|
+
if (only === undefined)
|
|
306
|
+
return [];
|
|
307
|
+
const names = exact.map((each) => writtenAs(each.name, tokens)).join(" or ");
|
|
308
|
+
return [{ value: `${property}: ${number}`, fix: exact.length === 1 ? only.name : undefined, names }];
|
|
309
|
+
});
|
|
310
|
+
if (!isStyle) {
|
|
311
|
+
const advice = found.map(({ value, names }) => ({
|
|
312
|
+
file,
|
|
313
|
+
line,
|
|
314
|
+
message: `\`${value}\` is a size written by hand if this object is a style: use ${names}.`
|
|
315
|
+
}));
|
|
316
|
+
return { problems: [], advice };
|
|
317
|
+
}
|
|
318
|
+
const problems = found.map(({ value, fix, names }) => ({
|
|
319
|
+
rule: "raw-size",
|
|
320
|
+
file,
|
|
321
|
+
line,
|
|
322
|
+
value,
|
|
323
|
+
...(fix === undefined ? {} : { fix }),
|
|
324
|
+
message: `A size written by hand, pixels in a style: use ${names}.`
|
|
325
|
+
}));
|
|
326
|
+
return { problems, advice: [] };
|
|
327
|
+
};
|
|
117
328
|
/** The suppression a line adds, unless it says why. */
|
|
118
329
|
const suppressionProblem = ({ file, line, text }) => SUPPRESSION.test(text) && !HAS_REASON.test(text)
|
|
119
330
|
? [
|
|
@@ -127,19 +338,95 @@ const suppressionProblem = ({ file, line, text }) => SUPPRESSION.test(text) && !
|
|
|
127
338
|
]
|
|
128
339
|
: [];
|
|
129
340
|
/**
|
|
130
|
-
*
|
|
341
|
+
* Whether raw colours have something to be compared with: a tokens file is the system whatever it holds, and what an
|
|
342
|
+
* application declares has to hold colours for a colour to read as a mistake.
|
|
343
|
+
*/
|
|
344
|
+
const comparesColors = (tokens) => tokens.some((token) => token.type === "color" || token.origin === undefined);
|
|
345
|
+
/**
|
|
346
|
+
* A file with its block comments blanked and its lines kept, so what is commented out does not count as used. A `/*` right
|
|
347
|
+
* after a word or a star or a quote is a path's pattern (`src/**` then `/*.ts`), not a comment.
|
|
348
|
+
*
|
|
349
|
+
* @param text - the file.
|
|
350
|
+
*/
|
|
351
|
+
export const withoutBlockComments = (text) => {
|
|
352
|
+
let out = "";
|
|
353
|
+
let index = 0;
|
|
354
|
+
while (index < text.length) {
|
|
355
|
+
const open = text.slice(index).search(/(?<![*"'`\w])\/\*|<!--/);
|
|
356
|
+
if (open === -1)
|
|
357
|
+
return out + text.slice(index);
|
|
358
|
+
const start = index + open;
|
|
359
|
+
const close = text.startsWith("/*", start) ? "*/" : "-->";
|
|
360
|
+
const end = text.indexOf(close, start + 2);
|
|
361
|
+
const stop = end === -1 ? text.length : end + close.length;
|
|
362
|
+
out += text.slice(index, start) + text.slice(start, stop).replace(/[^\n]/g, " ");
|
|
363
|
+
index = stop;
|
|
364
|
+
}
|
|
365
|
+
return out;
|
|
366
|
+
};
|
|
367
|
+
/** The rules a line's comment excuses. */
|
|
368
|
+
const ignoredRules = (text) => [...text.matchAll(IGNORE_COMMENT)].flatMap((match) => match[1] ?? []);
|
|
369
|
+
/** The raw values in a line of a checked file, but for those a comment excuses. */
|
|
370
|
+
const valueFindings = (added, above, tokens) => {
|
|
371
|
+
const none = { problems: [], advice: [] };
|
|
372
|
+
if (added.text.length > LONGEST_LINE)
|
|
373
|
+
return none;
|
|
374
|
+
const written = withoutComment(added.text);
|
|
375
|
+
const isSheet = SHEET_FILE.test(added.file);
|
|
376
|
+
const code = isSheet ? written.replace(CUSTOM_PROPERTY, "") : written;
|
|
377
|
+
// in a sheet, a line with no property continues a value started above, usually a token's
|
|
378
|
+
if ((isSheet && !code.includes(":")) || COMMENT_LINE.test(code))
|
|
379
|
+
return none;
|
|
380
|
+
const ignored = [...ignoredRules(added.text), ...(above === undefined ? [] : ignoredRules(above.text))];
|
|
381
|
+
const colors = comparesColors(tokens) ? colorProblems(added, code, tokens) : [];
|
|
382
|
+
const objects = objectSizeFindings(added, code, tokens);
|
|
383
|
+
const problems = [...colors, ...sizeProblems(added, code, tokens), ...objects.problems];
|
|
384
|
+
return {
|
|
385
|
+
problems: problems.filter(({ rule }) => !ignored.includes(rule)),
|
|
386
|
+
advice: ignored.includes("raw-size") ? [] : objects.advice
|
|
387
|
+
};
|
|
388
|
+
};
|
|
389
|
+
/**
|
|
390
|
+
* The values a change excuses with a comment: said in the answer, so a reader sees every one, and an agent gains nothing
|
|
391
|
+
* by hiding a value this way.
|
|
392
|
+
*
|
|
393
|
+
* @param lines - the added lines.
|
|
394
|
+
*/
|
|
395
|
+
export const excusedValues = (lines) => lines.flatMap(({ file, line, text }) => [...text.matchAll(IGNORE_COMMENT)].map((match) => ({
|
|
396
|
+
file,
|
|
397
|
+
line,
|
|
398
|
+
rule: match[1] === "raw-size" ? "raw-size" : "raw-color",
|
|
399
|
+
reason: (match[2] ?? "").trim()
|
|
400
|
+
})));
|
|
401
|
+
/**
|
|
402
|
+
* What lines a change adds break, and what they hold to weigh. Only code is read: a rule named in a sentence is not that
|
|
403
|
+
* rule.
|
|
131
404
|
*
|
|
132
405
|
* @param lines - the added lines.
|
|
133
406
|
* @param tokens - the catalogue's tokens; none skips the checks on values, which have nothing to compare with.
|
|
134
407
|
*/
|
|
135
|
-
export const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
408
|
+
export const codeFindings = (lines, tokens) => {
|
|
409
|
+
const found = lines.map((added, index) => {
|
|
410
|
+
if (!CHECKED_FILE.test(added.file) && !/\.[cm]?[jt]s$/.test(added.file))
|
|
411
|
+
return { problems: [], advice: [] };
|
|
412
|
+
if (LEFT_ALONE.test(added.file))
|
|
413
|
+
return { problems: [], advice: [] };
|
|
414
|
+
const suppression = suppressionProblem(added);
|
|
415
|
+
if (tokens.length === 0 || !CHECKED_FILE.test(added.file) || DEFINES_VALUE.test(added.text))
|
|
416
|
+
return { problems: suppression, advice: [] };
|
|
417
|
+
const above = lines[index - 1];
|
|
418
|
+
const lineAbove = above?.file === added.file && above.line === added.line - 1 ? above : undefined;
|
|
419
|
+
const values = valueFindings(added, lineAbove, tokens);
|
|
420
|
+
return { problems: [...suppression, ...values.problems], advice: values.advice };
|
|
421
|
+
});
|
|
422
|
+
return { problems: found.flatMap((each) => each.problems), advice: found.flatMap((each) => each.advice) };
|
|
423
|
+
};
|
|
424
|
+
/**
|
|
425
|
+
* What lines a change adds break.
|
|
426
|
+
*
|
|
427
|
+
* @param lines - the added lines.
|
|
428
|
+
* @param tokens - the catalogue's tokens; none skips the checks on values, which have nothing to compare with.
|
|
429
|
+
*/
|
|
430
|
+
export const checkedCode = (lines, tokens) => [
|
|
431
|
+
...codeFindings(lines, tokens).problems
|
|
432
|
+
];
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { ViteDevServer } from "vite";
|
|
2
|
+
import { type WatchFile } from "./closeWatch.ts";
|
|
3
|
+
/** An event handed to the watcher, as Vite's watcher names its own. */
|
|
4
|
+
export type CheckoutEvent = {
|
|
5
|
+
/** What happened to the file. */
|
|
6
|
+
readonly kind: "add" | "change" | "unlink";
|
|
7
|
+
/** The file, absolute, in Vite's form. */
|
|
8
|
+
readonly file: string;
|
|
9
|
+
};
|
|
10
|
+
/** A file as the disk has it now: when its status last changed, in milliseconds; none when it is not there. */
|
|
11
|
+
export type FileStatus = (file: string) => {
|
|
12
|
+
readonly changedAt: number;
|
|
13
|
+
} | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* The events a checkout's files make: what `git diff --name-status -z --no-renames` lists between two commits, kept to
|
|
16
|
+
* the files the checkout wrote.
|
|
17
|
+
*
|
|
18
|
+
* @param listed - git's output.
|
|
19
|
+
* @param top - the repository's folder, which git's paths are relative to.
|
|
20
|
+
* @param since - when the commit before was seen, in milliseconds: a file unchanged since is not the checkout's.
|
|
21
|
+
* @param status - a file's status now; the disk's by default.
|
|
22
|
+
*/
|
|
23
|
+
export declare const checkoutEvents: (listed: string, top: string, since: number, status?: FileStatus) => CheckoutEvent[];
|
|
24
|
+
/** A move of `HEAD` from one commit to another, as git's reflog of `HEAD` records it. */
|
|
25
|
+
export type HeadMove = {
|
|
26
|
+
/** The commit before. */
|
|
27
|
+
readonly from: string;
|
|
28
|
+
/** The commit after. */
|
|
29
|
+
readonly to: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The moves of `HEAD` in what git appended to its reflog, in order, each that changed the commit: a branch switched and
|
|
33
|
+
* switched back before a check reads `HEAD` is two moves, though `HEAD` ends where it was.
|
|
34
|
+
*
|
|
35
|
+
* @param appended - the reflog's lines written since the last check.
|
|
36
|
+
*/
|
|
37
|
+
export declare const headMoves: (appended: string) => HeadMove[];
|
|
38
|
+
/** Runs git in a folder and gives what it wrote, trimmed; none when it fails (no repository, no commit yet). */
|
|
39
|
+
export type RunGit = (dir: string, args: readonly string[]) => Promise<string | undefined>;
|
|
40
|
+
/** What `checkoutWatch` is made with. */
|
|
41
|
+
export type CheckoutWatchOptions = {
|
|
42
|
+
/** A folder of the repository: the dev server's root. */
|
|
43
|
+
readonly dir: string;
|
|
44
|
+
/**
|
|
45
|
+
* Hands an event to the dev server's watcher.
|
|
46
|
+
*
|
|
47
|
+
* @param event - the event.
|
|
48
|
+
*/
|
|
49
|
+
readonly onEvent: (event: CheckoutEvent) => void;
|
|
50
|
+
/** Opens a file's watch; Node's `fs.watch` by default. */
|
|
51
|
+
readonly watchFile?: WatchFile;
|
|
52
|
+
/** Runs git; the installed git by default. */
|
|
53
|
+
readonly git?: RunGit;
|
|
54
|
+
/** A file's status; the disk's by default. */
|
|
55
|
+
readonly status?: FileStatus;
|
|
56
|
+
/** How long to wait for git to finish writing, in milliseconds; `SETTLE_MS` by default. */
|
|
57
|
+
readonly settleMs?: number;
|
|
58
|
+
};
|
|
59
|
+
/** A checkout watch: it can be stopped, and says when it has read where the repository stands. */
|
|
60
|
+
export type CheckoutWatch = {
|
|
61
|
+
/** Resolves once it watches, or knows there is nothing to watch (no repository). */
|
|
62
|
+
readonly ready: Promise<void>;
|
|
63
|
+
/** Resolves once every checkout heard so far has been handed on. */
|
|
64
|
+
readonly settled: () => Promise<void>;
|
|
65
|
+
/** Stops watching. */
|
|
66
|
+
readonly close: () => void;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Watches a repository's checkouts and hands the files each one wrote to `onEvent`.
|
|
70
|
+
*
|
|
71
|
+
* @param options - the repository, where events go, and how files are watched and git is run.
|
|
72
|
+
*/
|
|
73
|
+
export declare const checkoutWatch: (options: CheckoutWatchOptions) => CheckoutWatch;
|
|
74
|
+
/**
|
|
75
|
+
* A dev server's checkout watch, where its watcher reads FSEvents and it sends updates: what a checkout wrote goes to
|
|
76
|
+
* its watcher. Closed with the server's HTTP server.
|
|
77
|
+
*
|
|
78
|
+
* @param server - the dev server.
|
|
79
|
+
* @param platform - the system, `process.platform` by default.
|
|
80
|
+
* @returns the watch; none where the watcher hears of changes at once, or polls.
|
|
81
|
+
*/
|
|
82
|
+
export declare const serverCheckoutWatch: (server: ViteDevServer, platform?: NodeJS.Platform) => CheckoutWatch | undefined;
|
|
83
|
+
/** The checkout watch of the dev server that runs now, as the plugin holds it across restarts. */
|
|
84
|
+
export type CurrentCheckoutWatch = {
|
|
85
|
+
/**
|
|
86
|
+
* Ends the watch of the server before, if any, and starts this server's: a restart configures the new server before
|
|
87
|
+
* it closes the old one.
|
|
88
|
+
*
|
|
89
|
+
* @param server - the dev server; none in a run where no person waits for a page (a test run).
|
|
90
|
+
* @param platform - the system, `process.platform` by default.
|
|
91
|
+
*/
|
|
92
|
+
readonly serve: (server: ViteDevServer | undefined, platform?: NodeJS.Platform) => void;
|
|
93
|
+
/** Stops watching. */
|
|
94
|
+
readonly close: () => void;
|
|
95
|
+
};
|
|
96
|
+
/** The checkout watch of the dev server that runs now; none watches until a server is served. */
|
|
97
|
+
export declare const currentCheckoutWatch: () => CurrentCheckoutWatch;
|