@rien7/seji 0.0.0 → 0.6.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/bin/design-surface.mjs +6 -0
- package/bin/postinstall.mjs +19 -0
- package/bin/seji.mjs +585 -0
- package/dist/agent/host.d.mts +34 -0
- package/dist/agent/host.mjs +387 -0
- package/dist/agent/messages.d.mts +9 -0
- package/dist/agent/messages.mjs +70 -0
- package/dist/agent/runtimes.mjs +157 -0
- package/dist/cli/app.mjs +321 -0
- package/dist/cli/appScan.mjs +284 -0
- package/dist/cli/catalog.mjs +78 -0
- package/dist/cli/component.mjs +165 -0
- package/dist/cli/consolidate.mjs +159 -0
- package/dist/cli/cssImport.mjs +68 -0
- package/dist/cli/dev.mjs +339 -0
- package/dist/cli/doctor.mjs +311 -0
- package/dist/cli/init.mjs +338 -0
- package/dist/cli/legacyNames.mjs +266 -0
- package/dist/cli/migrate.mjs +163 -0
- package/dist/cli/prompt.mjs +34 -0
- package/dist/cli/propose.mjs +208 -0
- package/dist/cli/providers.mjs +344 -0
- package/dist/cli/reviewOps.mjs +110 -0
- package/dist/cli/semver.mjs +45 -0
- package/dist/cli/setup.mjs +360 -0
- package/dist/cli/sketches.mjs +47 -0
- package/dist/cli/skills.mjs +150 -0
- package/dist/cli/snapshot.mjs +107 -0
- package/dist/cli/tokenOps.mjs +120 -0
- package/dist/cli/types.mjs +191 -0
- package/dist/cli/updater.mjs +274 -0
- package/dist/components/astIndex.mjs +992 -0
- package/dist/components/ops.mjs +1069 -0
- package/dist/editor/AgentProposalCard.d.ts +10 -0
- package/dist/editor/AgentProposalCard.d.ts.map +1 -0
- package/dist/editor/AgentProposalCard.js +31 -0
- package/dist/editor/AgentProposalCard.js.map +1 -0
- package/dist/editor/App.d.ts +2 -0
- package/dist/editor/App.d.ts.map +1 -0
- package/dist/editor/App.js +2834 -0
- package/dist/editor/App.js.map +1 -0
- package/dist/editor/CanvasHud.d.ts +12 -0
- package/dist/editor/CanvasHud.d.ts.map +1 -0
- package/dist/editor/CanvasHud.js +13 -0
- package/dist/editor/CanvasHud.js.map +1 -0
- package/dist/editor/CanvasSurface.d.ts +31 -0
- package/dist/editor/CanvasSurface.d.ts.map +1 -0
- package/dist/editor/CanvasSurface.js +270 -0
- package/dist/editor/CanvasSurface.js.map +1 -0
- package/dist/editor/CommentPopover.d.ts +17 -0
- package/dist/editor/CommentPopover.d.ts.map +1 -0
- package/dist/editor/CommentPopover.js +62 -0
- package/dist/editor/CommentPopover.js.map +1 -0
- package/dist/editor/Comments.d.ts +13 -0
- package/dist/editor/Comments.d.ts.map +1 -0
- package/dist/editor/Comments.js +41 -0
- package/dist/editor/Comments.js.map +1 -0
- package/dist/editor/ComponentPage.d.ts +28 -0
- package/dist/editor/ComponentPage.d.ts.map +1 -0
- package/dist/editor/ComponentPage.js +55 -0
- package/dist/editor/ComponentPage.js.map +1 -0
- package/dist/editor/ComponentPanel.d.ts +38 -0
- package/dist/editor/ComponentPanel.d.ts.map +1 -0
- package/dist/editor/ComponentPanel.js +275 -0
- package/dist/editor/ComponentPanel.js.map +1 -0
- package/dist/editor/Glyph.d.ts +51 -0
- package/dist/editor/Glyph.d.ts.map +1 -0
- package/dist/editor/Glyph.js +50 -0
- package/dist/editor/Glyph.js.map +1 -0
- package/dist/editor/History.d.ts +7 -0
- package/dist/editor/History.d.ts.map +1 -0
- package/dist/editor/History.js +51 -0
- package/dist/editor/History.js.map +1 -0
- package/dist/editor/Inspector.d.ts +56 -0
- package/dist/editor/Inspector.d.ts.map +1 -0
- package/dist/editor/Inspector.js +510 -0
- package/dist/editor/Inspector.js.map +1 -0
- package/dist/editor/LazyMount.d.ts +10 -0
- package/dist/editor/LazyMount.d.ts.map +1 -0
- package/dist/editor/LazyMount.js +29 -0
- package/dist/editor/LazyMount.js.map +1 -0
- package/dist/editor/LocaleSwitch.d.ts +3 -0
- package/dist/editor/LocaleSwitch.d.ts.map +1 -0
- package/dist/editor/LocaleSwitch.js +9 -0
- package/dist/editor/LocaleSwitch.js.map +1 -0
- package/dist/editor/PreviewFrame.d.ts +10 -0
- package/dist/editor/PreviewFrame.d.ts.map +1 -0
- package/dist/editor/PreviewFrame.js +22 -0
- package/dist/editor/PreviewFrame.js.map +1 -0
- package/dist/editor/ProjectIndex.d.ts +12 -0
- package/dist/editor/ProjectIndex.d.ts.map +1 -0
- package/dist/editor/ProjectIndex.js +43 -0
- package/dist/editor/ProjectIndex.js.map +1 -0
- package/dist/editor/PromoteComponent.d.ts +28 -0
- package/dist/editor/PromoteComponent.d.ts.map +1 -0
- package/dist/editor/PromoteComponent.js +33 -0
- package/dist/editor/PromoteComponent.js.map +1 -0
- package/dist/editor/PromoteForm.d.ts +18 -0
- package/dist/editor/PromoteForm.d.ts.map +1 -0
- package/dist/editor/PromoteForm.js +35 -0
- package/dist/editor/PromoteForm.js.map +1 -0
- package/dist/editor/PromoteToken.d.ts +31 -0
- package/dist/editor/PromoteToken.d.ts.map +1 -0
- package/dist/editor/PromoteToken.js +94 -0
- package/dist/editor/PromoteToken.js.map +1 -0
- package/dist/editor/StatePreviews.d.ts +28 -0
- package/dist/editor/StatePreviews.d.ts.map +1 -0
- package/dist/editor/StatePreviews.js +113 -0
- package/dist/editor/StatePreviews.js.map +1 -0
- package/dist/editor/ValueCombo.d.ts +51 -0
- package/dist/editor/ValueCombo.d.ts.map +1 -0
- package/dist/editor/ValueCombo.js +260 -0
- package/dist/editor/ValueCombo.js.map +1 -0
- package/dist/editor/agent/AgentPanel.d.ts +19 -0
- package/dist/editor/agent/AgentPanel.d.ts.map +1 -0
- package/dist/editor/agent/AgentPanel.js +271 -0
- package/dist/editor/agent/AgentPanel.js.map +1 -0
- package/dist/editor/agent/Markdown.d.ts +5 -0
- package/dist/editor/agent/Markdown.d.ts.map +1 -0
- package/dist/editor/agent/Markdown.js +28 -0
- package/dist/editor/agent/Markdown.js.map +1 -0
- package/dist/editor/agent/agentApi.d.ts +106 -0
- package/dist/editor/agent/agentApi.d.ts.map +1 -0
- package/dist/editor/agent/agentApi.js +66 -0
- package/dist/editor/agent/agentApi.js.map +1 -0
- package/dist/editor/agent/toolLines.d.ts +38 -0
- package/dist/editor/agent/toolLines.d.ts.map +1 -0
- package/dist/editor/agent/toolLines.js +159 -0
- package/dist/editor/agent/toolLines.js.map +1 -0
- package/dist/editor/agent/useAgent.d.ts +15 -0
- package/dist/editor/agent/useAgent.d.ts.map +1 -0
- package/dist/editor/agent/useAgent.js +65 -0
- package/dist/editor/agent/useAgent.js.map +1 -0
- package/dist/editor/api.d.ts +378 -0
- package/dist/editor/api.d.ts.map +1 -0
- package/dist/editor/api.js +247 -0
- package/dist/editor/api.js.map +1 -0
- package/dist/editor/camera.d.ts +18 -0
- package/dist/editor/camera.d.ts.map +1 -0
- package/dist/editor/camera.js +40 -0
- package/dist/editor/camera.js.map +1 -0
- package/dist/editor/canvas.d.ts +25 -0
- package/dist/editor/canvas.d.ts.map +1 -0
- package/dist/editor/canvas.js +35 -0
- package/dist/editor/canvas.js.map +1 -0
- package/dist/editor/changes/ChangesPage.d.ts +25 -0
- package/dist/editor/changes/ChangesPage.d.ts.map +1 -0
- package/dist/editor/changes/ChangesPage.js +132 -0
- package/dist/editor/changes/ChangesPage.js.map +1 -0
- package/dist/editor/changes/changeModel.d.ts +25 -0
- package/dist/editor/changes/changeModel.d.ts.map +1 -0
- package/dist/editor/changes/changeModel.js +81 -0
- package/dist/editor/changes/changeModel.js.map +1 -0
- package/dist/editor/changes/changeState.d.mts +29 -0
- package/dist/editor/changes/changeState.mjs +187 -0
- package/dist/editor/chrome/EditorChrome.d.ts +49 -0
- package/dist/editor/chrome/EditorChrome.d.ts.map +1 -0
- package/dist/editor/chrome/EditorChrome.js +21 -0
- package/dist/editor/chrome/EditorChrome.js.map +1 -0
- package/dist/editor/drafts.d.ts +46 -0
- package/dist/editor/drafts.d.ts.map +1 -0
- package/dist/editor/drafts.js +38 -0
- package/dist/editor/drafts.js.map +1 -0
- package/dist/editor/i18n.d.ts +29 -0
- package/dist/editor/i18n.d.ts.map +1 -0
- package/dist/editor/i18n.js +2320 -0
- package/dist/editor/i18n.js.map +1 -0
- package/dist/editor/iconStroke.d.ts +6 -0
- package/dist/editor/iconStroke.d.ts.map +1 -0
- package/dist/editor/iconStroke.js +6 -0
- package/dist/editor/iconStroke.js.map +1 -0
- package/dist/editor/main.d.ts +2 -0
- package/dist/editor/main.d.ts.map +1 -0
- package/dist/editor/main.js +14 -0
- package/dist/editor/main.js.map +1 -0
- package/dist/editor/model.d.ts +16 -0
- package/dist/editor/model.d.ts.map +1 -0
- package/dist/editor/model.js +11 -0
- package/dist/editor/model.js.map +1 -0
- package/dist/editor/reasons.d.ts +44 -0
- package/dist/editor/reasons.d.ts.map +1 -0
- package/dist/editor/reasons.js +131 -0
- package/dist/editor/reasons.js.map +1 -0
- package/dist/editor/reviewLifecycle.d.ts +8 -0
- package/dist/editor/reviewLifecycle.d.ts.map +1 -0
- package/dist/editor/reviewLifecycle.js +21 -0
- package/dist/editor/reviewLifecycle.js.map +1 -0
- package/dist/editor/styles.css +8737 -0
- package/dist/editor/tokenMatch.d.ts +59 -0
- package/dist/editor/tokenMatch.d.ts.map +1 -0
- package/dist/editor/tokenMatch.js +198 -0
- package/dist/editor/tokenMatch.js.map +1 -0
- package/dist/editor/tokens/ConsolidatePage.d.ts +16 -0
- package/dist/editor/tokens/ConsolidatePage.d.ts.map +1 -0
- package/dist/editor/tokens/ConsolidatePage.js +244 -0
- package/dist/editor/tokens/ConsolidatePage.js.map +1 -0
- package/dist/editor/tokens/TokenActivity.d.ts +18 -0
- package/dist/editor/tokens/TokenActivity.d.ts.map +1 -0
- package/dist/editor/tokens/TokenActivity.js +18 -0
- package/dist/editor/tokens/TokenActivity.js.map +1 -0
- package/dist/editor/tokens/TokenDialogs.d.ts +26 -0
- package/dist/editor/tokens/TokenDialogs.d.ts.map +1 -0
- package/dist/editor/tokens/TokenDialogs.js +119 -0
- package/dist/editor/tokens/TokenDialogs.js.map +1 -0
- package/dist/editor/tokens/TokenList.d.ts +21 -0
- package/dist/editor/tokens/TokenList.d.ts.map +1 -0
- package/dist/editor/tokens/TokenList.js +98 -0
- package/dist/editor/tokens/TokenList.js.map +1 -0
- package/dist/editor/tokens/TokenPage.d.ts +25 -0
- package/dist/editor/tokens/TokenPage.d.ts.map +1 -0
- package/dist/editor/tokens/TokenPage.js +108 -0
- package/dist/editor/tokens/TokenPage.js.map +1 -0
- package/dist/editor/tokens/tokenModel.d.ts +35 -0
- package/dist/editor/tokens/tokenModel.d.ts.map +1 -0
- package/dist/editor/tokens/tokenModel.js +72 -0
- package/dist/editor/tokens/tokenModel.js.map +1 -0
- package/dist/editor/ui/Button.d.ts +3 -0
- package/dist/editor/ui/Button.d.ts.map +1 -0
- package/dist/editor/ui/Button.js +6 -0
- package/dist/editor/ui/Button.js.map +1 -0
- package/dist/editor/ui/CommentBox.d.ts +23 -0
- package/dist/editor/ui/CommentBox.d.ts.map +1 -0
- package/dist/editor/ui/CommentBox.js +41 -0
- package/dist/editor/ui/CommentBox.js.map +1 -0
- package/dist/editor/ui/Icon.d.ts +8 -0
- package/dist/editor/ui/Icon.d.ts.map +1 -0
- package/dist/editor/ui/Icon.js +6 -0
- package/dist/editor/ui/Icon.js.map +1 -0
- package/dist/editor/ui/IconButton.d.ts +11 -0
- package/dist/editor/ui/IconButton.d.ts.map +1 -0
- package/dist/editor/ui/IconButton.js +6 -0
- package/dist/editor/ui/IconButton.js.map +1 -0
- package/dist/editor/ui/NumberInput.d.ts +14 -0
- package/dist/editor/ui/NumberInput.d.ts.map +1 -0
- package/dist/editor/ui/NumberInput.js +6 -0
- package/dist/editor/ui/NumberInput.js.map +1 -0
- package/dist/editor/ui/PageLine.d.ts +14 -0
- package/dist/editor/ui/PageLine.d.ts.map +1 -0
- package/dist/editor/ui/PageLine.js +7 -0
- package/dist/editor/ui/PageLine.js.map +1 -0
- package/dist/editor/ui/SearchPicker.d.ts +41 -0
- package/dist/editor/ui/SearchPicker.d.ts.map +1 -0
- package/dist/editor/ui/SearchPicker.js +82 -0
- package/dist/editor/ui/SearchPicker.js.map +1 -0
- package/dist/editor/ui/Select.d.ts +19 -0
- package/dist/editor/ui/Select.d.ts.map +1 -0
- package/dist/editor/ui/Select.js +12 -0
- package/dist/editor/ui/Select.js.map +1 -0
- package/dist/editor/ui/TokenField.d.ts +14 -0
- package/dist/editor/ui/TokenField.d.ts.map +1 -0
- package/dist/editor/ui/TokenField.js +41 -0
- package/dist/editor/ui/TokenField.js.map +1 -0
- package/dist/editor/ui/TokenPicker.d.ts +31 -0
- package/dist/editor/ui/TokenPicker.d.ts.map +1 -0
- package/dist/editor/ui/TokenPicker.js +26 -0
- package/dist/editor/ui/TokenPicker.js.map +1 -0
- package/dist/editor/useBuildError.d.ts +7 -0
- package/dist/editor/useBuildError.d.ts.map +1 -0
- package/dist/editor/useBuildError.js +30 -0
- package/dist/editor/useBuildError.js.map +1 -0
- package/dist/editor/useLatestRequest.d.ts +22 -0
- package/dist/editor/useLatestRequest.d.ts.map +1 -0
- package/dist/editor/useLatestRequest.js +49 -0
- package/dist/editor/useLatestRequest.js.map +1 -0
- package/dist/editor-bundle/editor.css +2 -0
- package/dist/editor-bundle/editor.js +83 -0
- package/dist/editor-ui.d.ts +15 -0
- package/dist/editor-ui.d.ts.map +1 -0
- package/dist/editor-ui.js +14 -0
- package/dist/editor-ui.js.map +1 -0
- package/dist/inspector/runtime.d.ts +18 -0
- package/dist/inspector/runtime.d.ts.map +1 -0
- package/dist/inspector/runtime.js +1280 -0
- package/dist/inspector/runtime.js.map +1 -0
- package/dist/preview/main.d.ts +3 -0
- package/dist/preview/main.d.ts.map +1 -0
- package/dist/preview/main.js +320 -0
- package/dist/preview/main.js.map +1 -0
- package/dist/preview/preview.css +40 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/shared/buildError.d.mts +27 -0
- package/dist/shared/buildError.mjs +141 -0
- package/dist/shared/cameraFit.d.mts +16 -0
- package/dist/shared/cameraFit.mjs +47 -0
- package/dist/shared/canvasLayout.d.mts +13 -0
- package/dist/shared/canvasLayout.mjs +171 -0
- package/dist/shared/commentShots.d.mts +12 -0
- package/dist/shared/commentShots.mjs +53 -0
- package/dist/shared/componentExtract.d.mts +43 -0
- package/dist/shared/componentExtract.mjs +136 -0
- package/dist/shared/componentMeta.d.mts +26 -0
- package/dist/shared/componentMeta.mjs +87 -0
- package/dist/shared/componentOps.d.mts +70 -0
- package/dist/shared/componentOps.mjs +407 -0
- package/dist/shared/componentTarget.d.mts +15 -0
- package/dist/shared/componentTarget.mjs +58 -0
- package/dist/shared/components.d.mts +30 -0
- package/dist/shared/components.mjs +106 -0
- package/dist/shared/consolidateCategories.d.mts +2 -0
- package/dist/shared/consolidateCategories.mjs +6 -0
- package/dist/shared/env.d.mts +4 -0
- package/dist/shared/env.mjs +18 -0
- package/dist/shared/gitChanges.d.mts +2 -0
- package/dist/shared/gitChanges.mjs +30 -0
- package/dist/shared/legacyPaths.d.mts +1 -0
- package/dist/shared/legacyPaths.mjs +9 -0
- package/dist/shared/oklab.d.mts +6 -0
- package/dist/shared/oklab.mjs +56 -0
- package/dist/shared/optimizeEntries.d.mts +5 -0
- package/dist/shared/optimizeEntries.mjs +24 -0
- package/dist/shared/packages.d.mts +11 -0
- package/dist/shared/packages.mjs +96 -0
- package/dist/shared/projectFiles.d.mts +23 -0
- package/dist/shared/projectFiles.mjs +72 -0
- package/dist/shared/prompt.d.mts +25 -0
- package/dist/shared/prompt.mjs +217 -0
- package/dist/shared/proposals.d.mts +11 -0
- package/dist/shared/proposals.mjs +42 -0
- package/dist/shared/protocol.d.ts +122 -0
- package/dist/shared/protocol.d.ts.map +1 -0
- package/dist/shared/protocol.js +7 -0
- package/dist/shared/protocol.js.map +1 -0
- package/dist/shared/reviewArchive.d.mts +4 -0
- package/dist/shared/reviewArchive.mjs +19 -0
- package/dist/shared/reviewStore.d.mts +30 -0
- package/dist/shared/reviewStore.mjs +218 -0
- package/dist/shared/reviewVerify.d.mts +21 -0
- package/dist/shared/reviewVerify.mjs +158 -0
- package/dist/shared/sizeModes.d.mts +15 -0
- package/dist/shared/sizeModes.mjs +53 -0
- package/dist/shared/sketches.d.mts +10 -0
- package/dist/shared/sketches.mjs +64 -0
- package/dist/shared/snapshotCheck.d.mts +13 -0
- package/dist/shared/snapshotCheck.mjs +81 -0
- package/dist/shared/timeout.d.mts +1 -0
- package/dist/shared/timeout.mjs +15 -0
- package/dist/shared/tokens.d.ts +2 -0
- package/dist/shared/tokens.d.ts.map +1 -0
- package/dist/shared/tokens.js +2 -0
- package/dist/shared/tokens.js.map +1 -0
- package/dist/shared/types.d.ts +689 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +13 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/shared/wheelRouting.d.mts +9 -0
- package/dist/shared/wheelRouting.mjs +31 -0
- package/dist/shared/writeScope.mjs +96 -0
- package/dist/snapshots/diff.d.mts +28 -0
- package/dist/snapshots/diff.mjs +263 -0
- package/dist/snapshots/index.d.mts +110 -0
- package/dist/snapshots/index.mjs +638 -0
- package/dist/snapshots/render.d.mts +24 -0
- package/dist/snapshots/render.mjs +250 -0
- package/dist/snapshots/toolOps.d.mts +25 -0
- package/dist/snapshots/toolOps.mjs +69 -0
- package/dist/tokens/adapters/css.mjs +51 -0
- package/dist/tokens/adapters/cssInCode.mjs +314 -0
- package/dist/tokens/adapters/oxcShared.mjs +80 -0
- package/dist/tokens/adapters/preprocessor.mjs +63 -0
- package/dist/tokens/adapters/registry.mjs +53 -0
- package/dist/tokens/adapters/tailwindcss.mjs +424 -0
- package/dist/tokens/adapters/types.mjs +117 -0
- package/dist/tokens/consolidate/index.d.mts +42 -0
- package/dist/tokens/consolidate/index.mjs +111 -0
- package/dist/tokens/consolidate/normalize.mjs +479 -0
- package/dist/tokens/consolidate/plan.mjs +726 -0
- package/dist/tokens/consolidate/scan.mjs +928 -0
- package/dist/tokens/extract.mjs +441 -0
- package/dist/tokens/moduleData.d.mts +14 -0
- package/dist/tokens/moduleData.mjs +32 -0
- package/dist/tokens/opLock.d.mts +4 -0
- package/dist/tokens/opLock.mjs +108 -0
- package/dist/tokens/ops.d.mts +71 -0
- package/dist/tokens/ops.mjs +1511 -0
- package/dist/tokens/pipeline.mjs +813 -0
- package/dist/tokens/report.d.mts +47 -0
- package/dist/tokens/report.mjs +257 -0
- package/dist/tokens/rewrite/code.mjs +172 -0
- package/dist/tokens/rewrite/css.mjs +154 -0
- package/dist/tokens/rewrite/index.mjs +244 -0
- package/dist/tokens/rewrite/tailwind.mjs +288 -0
- package/dist/tokens/rewrite/text.mjs +116 -0
- package/dist/tokens/rewrite/value.mjs +115 -0
- package/dist/tokens/usage.d.mts +97 -0
- package/dist/tokens/usage.mjs +680 -0
- package/dist/vite/agent.d.ts +21 -0
- package/dist/vite/agent.d.ts.map +1 -0
- package/dist/vite/agent.js +165 -0
- package/dist/vite/agent.js.map +1 -0
- package/dist/vite/events.d.ts +27 -0
- package/dist/vite/events.d.ts.map +1 -0
- package/dist/vite/events.js +156 -0
- package/dist/vite/events.js.map +1 -0
- package/dist/vite/layout.d.ts +2 -0
- package/dist/vite/layout.d.ts.map +1 -0
- package/dist/vite/layout.js +4 -0
- package/dist/vite/layout.js.map +1 -0
- package/dist/vite/plugin.d.ts +40 -0
- package/dist/vite/plugin.d.ts.map +1 -0
- package/dist/vite/plugin.js +1264 -0
- package/dist/vite/plugin.js.map +1 -0
- package/dist/vite/requestGuard.d.mts +3 -0
- package/dist/vite/requestGuard.mjs +43 -0
- package/dist/vite/review.d.ts +11 -0
- package/dist/vite/review.d.ts.map +1 -0
- package/dist/vite/review.js +283 -0
- package/dist/vite/review.js.map +1 -0
- package/package.json +106 -1
- package/skills/seji/SKILL.md +400 -0
- package/skills/seji-authoring/SKILL.md +397 -0
- package/skills/seji-tokens/SKILL.md +432 -0
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import { parseSourceAst, staticStringOf, walkAst } from './oxcShared.mjs'
|
|
2
|
+
|
|
3
|
+
const CODE_EXT_RE = /\.(?:tsx|jsx|ts|js|mts|cts|mjs|cjs)$/i
|
|
4
|
+
const CLASS_HELPERS = new Set(['clsx', 'cn', 'classNames', 'classnames', 'twMerge', 'cva'])
|
|
5
|
+
|
|
6
|
+
const TW_COLOR_PREFIXES = new Set([
|
|
7
|
+
'bg',
|
|
8
|
+
'text',
|
|
9
|
+
'border',
|
|
10
|
+
'border-t',
|
|
11
|
+
'border-r',
|
|
12
|
+
'border-b',
|
|
13
|
+
'border-l',
|
|
14
|
+
'border-x',
|
|
15
|
+
'border-y',
|
|
16
|
+
'outline',
|
|
17
|
+
'ring',
|
|
18
|
+
'ring-offset',
|
|
19
|
+
'divide',
|
|
20
|
+
'accent',
|
|
21
|
+
'caret',
|
|
22
|
+
'fill',
|
|
23
|
+
'stroke',
|
|
24
|
+
'decoration',
|
|
25
|
+
'shadow',
|
|
26
|
+
'from',
|
|
27
|
+
'via',
|
|
28
|
+
'to',
|
|
29
|
+
'placeholder',
|
|
30
|
+
])
|
|
31
|
+
|
|
32
|
+
const TW_PALETTE_COLORS = new Set([
|
|
33
|
+
'slate',
|
|
34
|
+
'gray',
|
|
35
|
+
'zinc',
|
|
36
|
+
'neutral',
|
|
37
|
+
'stone',
|
|
38
|
+
'red',
|
|
39
|
+
'orange',
|
|
40
|
+
'amber',
|
|
41
|
+
'yellow',
|
|
42
|
+
'lime',
|
|
43
|
+
'green',
|
|
44
|
+
'emerald',
|
|
45
|
+
'teal',
|
|
46
|
+
'cyan',
|
|
47
|
+
'sky',
|
|
48
|
+
'blue',
|
|
49
|
+
'indigo',
|
|
50
|
+
'violet',
|
|
51
|
+
'purple',
|
|
52
|
+
'fuchsia',
|
|
53
|
+
'pink',
|
|
54
|
+
'rose',
|
|
55
|
+
])
|
|
56
|
+
|
|
57
|
+
const TW_SHADES = new Set([
|
|
58
|
+
'50',
|
|
59
|
+
'100',
|
|
60
|
+
'200',
|
|
61
|
+
'300',
|
|
62
|
+
'400',
|
|
63
|
+
'500',
|
|
64
|
+
'600',
|
|
65
|
+
'700',
|
|
66
|
+
'800',
|
|
67
|
+
'900',
|
|
68
|
+
'950',
|
|
69
|
+
])
|
|
70
|
+
|
|
71
|
+
const COLOR_LITERAL_VALUE_RE =
|
|
72
|
+
/^(?:#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})|(?:rgba?|hsla?|oklch|oklab|color-mix|color)\(.*\))$/i
|
|
73
|
+
|
|
74
|
+
function stripVariants(token) {
|
|
75
|
+
let bracketDepth = 0
|
|
76
|
+
let parenDepth = 0
|
|
77
|
+
let lastColon = -1
|
|
78
|
+
for (let i = 0; i < token.length; i += 1) {
|
|
79
|
+
const ch = token[i]
|
|
80
|
+
if (ch === '[') bracketDepth += 1
|
|
81
|
+
else if (ch === ']' && bracketDepth > 0) bracketDepth -= 1
|
|
82
|
+
else if (ch === '(') parenDepth += 1
|
|
83
|
+
else if (ch === ')' && parenDepth > 0) parenDepth -= 1
|
|
84
|
+
else if (ch === ':' && bracketDepth === 0 && parenDepth === 0) lastColon = i
|
|
85
|
+
}
|
|
86
|
+
const core = lastColon >= 0 ? token.slice(lastColon + 1) : token
|
|
87
|
+
return core.startsWith('!') ? core.slice(1) : core
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function splitClasses(raw) {
|
|
91
|
+
const tokens = []
|
|
92
|
+
let current = ''
|
|
93
|
+
let bracketDepth = 0
|
|
94
|
+
let parenDepth = 0
|
|
95
|
+
for (let i = 0; i < raw.length; i += 1) {
|
|
96
|
+
const ch = raw[i]
|
|
97
|
+
if (ch === '[') bracketDepth += 1
|
|
98
|
+
else if (ch === ']' && bracketDepth > 0) bracketDepth -= 1
|
|
99
|
+
else if (ch === '(') parenDepth += 1
|
|
100
|
+
else if (ch === ')' && parenDepth > 0) parenDepth -= 1
|
|
101
|
+
if (/\s/.test(ch) && bracketDepth === 0 && parenDepth === 0) {
|
|
102
|
+
if (current) {
|
|
103
|
+
tokens.push(current)
|
|
104
|
+
current = ''
|
|
105
|
+
}
|
|
106
|
+
continue
|
|
107
|
+
}
|
|
108
|
+
current += ch
|
|
109
|
+
}
|
|
110
|
+
if (current) tokens.push(current)
|
|
111
|
+
return tokens
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function analyzeClassString(raw, { file, line, column, diagnostics }) {
|
|
115
|
+
for (const fullToken of splitClasses(raw)) {
|
|
116
|
+
const core = stripVariants(fullToken)
|
|
117
|
+
if (!core) continue
|
|
118
|
+
|
|
119
|
+
// Tailwind v4 shorthand: bg-(--color-surface), border-(--color-border), etc.
|
|
120
|
+
const parenVarMatch = /^([a-z-]+)-\((--[a-zA-Z0-9_-]+)\)$/.exec(core)
|
|
121
|
+
if (parenVarMatch) {
|
|
122
|
+
diagnostics.push({
|
|
123
|
+
file,
|
|
124
|
+
line,
|
|
125
|
+
column,
|
|
126
|
+
adapter: 'tailwindcss',
|
|
127
|
+
kind: 'token-ref',
|
|
128
|
+
property: parenVarMatch[1],
|
|
129
|
+
value: fullToken,
|
|
130
|
+
token: parenVarMatch[2],
|
|
131
|
+
})
|
|
132
|
+
continue
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Arbitrary value: bg-[var(--xxx)] or bg-[#2563eb] or text-[rgb(...)]
|
|
136
|
+
const bracketMatch = /^([a-z-]+)-\[([^\]]+)\]$/.exec(core)
|
|
137
|
+
if (bracketMatch) {
|
|
138
|
+
const property = bracketMatch[1]
|
|
139
|
+
const inner = bracketMatch[2].trim()
|
|
140
|
+
const varMatch = /^var\(\s*(--[a-zA-Z0-9_-]+)/.exec(inner)
|
|
141
|
+
if (varMatch) {
|
|
142
|
+
diagnostics.push({
|
|
143
|
+
file,
|
|
144
|
+
line,
|
|
145
|
+
column,
|
|
146
|
+
adapter: 'tailwindcss',
|
|
147
|
+
kind: 'token-ref',
|
|
148
|
+
property,
|
|
149
|
+
value: fullToken,
|
|
150
|
+
token: varMatch[1],
|
|
151
|
+
})
|
|
152
|
+
continue
|
|
153
|
+
}
|
|
154
|
+
if (COLOR_LITERAL_VALUE_RE.test(inner)) {
|
|
155
|
+
diagnostics.push({
|
|
156
|
+
file,
|
|
157
|
+
line,
|
|
158
|
+
column,
|
|
159
|
+
adapter: 'tailwindcss',
|
|
160
|
+
kind: 'literal',
|
|
161
|
+
property,
|
|
162
|
+
value: inner,
|
|
163
|
+
})
|
|
164
|
+
continue
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Default Tailwind palette classes: bg-blue-600, border-red-500/50, text-black, bg-white/80
|
|
169
|
+
const withoutOpacity = core.replace(/\/(?:\d+(?:\.\d+)?|\[[^\]]+\])$/, '')
|
|
170
|
+
const parts = withoutOpacity.split('-')
|
|
171
|
+
if (parts.length >= 2) {
|
|
172
|
+
const last = parts[parts.length - 1]
|
|
173
|
+
const secondLast = parts[parts.length - 2]
|
|
174
|
+
if (parts.length >= 3 && TW_SHADES.has(last) && TW_PALETTE_COLORS.has(secondLast)) {
|
|
175
|
+
const prefix = parts.slice(0, -2).join('-')
|
|
176
|
+
if (TW_COLOR_PREFIXES.has(prefix)) {
|
|
177
|
+
diagnostics.push({
|
|
178
|
+
file,
|
|
179
|
+
line,
|
|
180
|
+
column,
|
|
181
|
+
adapter: 'tailwindcss',
|
|
182
|
+
kind: 'literal',
|
|
183
|
+
property: prefix,
|
|
184
|
+
value: fullToken,
|
|
185
|
+
})
|
|
186
|
+
continue
|
|
187
|
+
}
|
|
188
|
+
} else if (last === 'black' || last === 'white') {
|
|
189
|
+
const prefix = parts.slice(0, -1).join('-')
|
|
190
|
+
if (TW_COLOR_PREFIXES.has(prefix)) {
|
|
191
|
+
diagnostics.push({
|
|
192
|
+
file,
|
|
193
|
+
line,
|
|
194
|
+
column,
|
|
195
|
+
adapter: 'tailwindcss',
|
|
196
|
+
kind: 'literal',
|
|
197
|
+
property: prefix,
|
|
198
|
+
value: fullToken,
|
|
199
|
+
})
|
|
200
|
+
continue
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function analyzeClassExpression(expr, { file, content, locationAt, diagnostics, hooks }) {
|
|
208
|
+
if (!expr) return
|
|
209
|
+
const strVal = staticStringOf(expr)
|
|
210
|
+
if (strVal !== null) {
|
|
211
|
+
hooks?.onClassString?.(expr, strVal)
|
|
212
|
+
const loc = locationAt(expr.start)
|
|
213
|
+
analyzeClassString(strVal, { file, ...loc, diagnostics })
|
|
214
|
+
return
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (expr.type === 'TemplateLiteral' && (expr.expressions?.length ?? 0) > 0) {
|
|
218
|
+
hooks?.onUnsupported?.(expr, 'dynamic-class')
|
|
219
|
+
const loc = locationAt(expr.start)
|
|
220
|
+
diagnostics.push({
|
|
221
|
+
file,
|
|
222
|
+
...loc,
|
|
223
|
+
adapter: 'tailwindcss',
|
|
224
|
+
kind: 'unsupported',
|
|
225
|
+
property: 'className',
|
|
226
|
+
value: content.slice(expr.start, Math.min(expr.end, expr.start + 60)),
|
|
227
|
+
reason: 'dynamic-class',
|
|
228
|
+
})
|
|
229
|
+
return
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (expr.type === 'ArrayExpression') {
|
|
233
|
+
for (const elem of expr.elements ?? []) {
|
|
234
|
+
if (elem) analyzeClassExpression(elem, { file, content, locationAt, diagnostics, hooks })
|
|
235
|
+
}
|
|
236
|
+
return
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (expr.type === 'ConditionalExpression') {
|
|
240
|
+
analyzeClassExpression(expr.consequent, { file, content, locationAt, diagnostics, hooks })
|
|
241
|
+
analyzeClassExpression(expr.alternate, { file, content, locationAt, diagnostics, hooks })
|
|
242
|
+
return
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (expr.type === 'LogicalExpression') {
|
|
246
|
+
analyzeClassExpression(expr.right, { file, content, locationAt, diagnostics, hooks })
|
|
247
|
+
return
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (expr.type === 'ObjectExpression') {
|
|
251
|
+
for (const prop of expr.properties ?? []) {
|
|
252
|
+
if (prop.type !== 'Property') {
|
|
253
|
+
hooks?.onUnsupported?.(prop, 'dynamic-class')
|
|
254
|
+
const loc = locationAt(prop.start)
|
|
255
|
+
diagnostics.push({
|
|
256
|
+
file,
|
|
257
|
+
...loc,
|
|
258
|
+
adapter: 'tailwindcss',
|
|
259
|
+
kind: 'unsupported',
|
|
260
|
+
property: 'className',
|
|
261
|
+
value: content.slice(prop.start, Math.min(prop.end, prop.start + 60)),
|
|
262
|
+
reason: 'dynamic-class',
|
|
263
|
+
})
|
|
264
|
+
continue
|
|
265
|
+
}
|
|
266
|
+
if (prop.key?.type === 'Literal' && typeof prop.key.value === 'string') {
|
|
267
|
+
hooks?.onClassString?.(prop.key, prop.key.value)
|
|
268
|
+
const loc = locationAt(prop.key.start)
|
|
269
|
+
analyzeClassString(prop.key.value, { file, ...loc, diagnostics })
|
|
270
|
+
} else if (prop.key?.type === 'Identifier' && !prop.computed) {
|
|
271
|
+
hooks?.onClassString?.(prop.key, prop.key.name)
|
|
272
|
+
const loc = locationAt(prop.key.start)
|
|
273
|
+
analyzeClassString(prop.key.name, { file, ...loc, diagnostics })
|
|
274
|
+
} else {
|
|
275
|
+
hooks?.onUnsupported?.(prop, 'dynamic-class')
|
|
276
|
+
const loc = locationAt(prop.start)
|
|
277
|
+
diagnostics.push({
|
|
278
|
+
file,
|
|
279
|
+
...loc,
|
|
280
|
+
adapter: 'tailwindcss',
|
|
281
|
+
kind: 'unsupported',
|
|
282
|
+
property: 'className',
|
|
283
|
+
value: content.slice(prop.start, Math.min(prop.end, prop.start + 60)),
|
|
284
|
+
reason: 'dynamic-class',
|
|
285
|
+
})
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (expr.type === 'CallExpression') {
|
|
292
|
+
const calleeName =
|
|
293
|
+
expr.callee?.type === 'Identifier'
|
|
294
|
+
? expr.callee.name
|
|
295
|
+
: expr.callee?.type === 'MemberExpression' && expr.callee.property?.type === 'Identifier'
|
|
296
|
+
? expr.callee.property.name
|
|
297
|
+
: ''
|
|
298
|
+
if (calleeName === 'cva') {
|
|
299
|
+
analyzeCvaCall(expr, { file, content, locationAt, diagnostics, hooks })
|
|
300
|
+
return
|
|
301
|
+
}
|
|
302
|
+
if (CLASS_HELPERS.has(calleeName)) {
|
|
303
|
+
for (const arg of expr.arguments ?? []) {
|
|
304
|
+
analyzeClassExpression(arg, { file, content, locationAt, diagnostics, hooks })
|
|
305
|
+
}
|
|
306
|
+
return
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (expr.type === 'Literal' && (expr.value === null || expr.value === false || expr.value === undefined)) {
|
|
311
|
+
return
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
hooks?.onUnsupported?.(expr, 'dynamic-class')
|
|
315
|
+
const loc = locationAt(expr.start)
|
|
316
|
+
diagnostics.push({
|
|
317
|
+
file,
|
|
318
|
+
...loc,
|
|
319
|
+
adapter: 'tailwindcss',
|
|
320
|
+
kind: 'unsupported',
|
|
321
|
+
property: 'className',
|
|
322
|
+
value: content.slice(expr.start, Math.min(expr.end, expr.start + 60)),
|
|
323
|
+
reason: 'dynamic-class',
|
|
324
|
+
})
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const propertyName = (prop) =>
|
|
328
|
+
prop?.type === 'Property' && !prop.computed
|
|
329
|
+
? prop.key?.type === 'Identifier'
|
|
330
|
+
? prop.key.name
|
|
331
|
+
: prop.key?.type === 'Literal'
|
|
332
|
+
? String(prop.key.value)
|
|
333
|
+
: null
|
|
334
|
+
: null
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* cva(base, { variants: { size: { sm: '...' } }, compoundVariants: [{ ..., class: '...' }] }):
|
|
338
|
+
* the base and every variant value / compound `class` / `className` are class lists; variant
|
|
339
|
+
* names and defaultVariants are not.
|
|
340
|
+
*/
|
|
341
|
+
function analyzeCvaCall(expr, options) {
|
|
342
|
+
const [base, config] = expr.arguments ?? []
|
|
343
|
+
if (base) analyzeClassExpression(base, options)
|
|
344
|
+
if (config?.type !== 'ObjectExpression') return
|
|
345
|
+
for (const section of config.properties ?? []) {
|
|
346
|
+
const name = propertyName(section)
|
|
347
|
+
if (name === 'variants' && section.value?.type === 'ObjectExpression') {
|
|
348
|
+
for (const variant of section.value.properties ?? []) {
|
|
349
|
+
if (variant.type !== 'Property' || variant.value?.type !== 'ObjectExpression') continue
|
|
350
|
+
for (const option of variant.value.properties ?? []) {
|
|
351
|
+
if (option.type === 'Property' && option.value) analyzeClassExpression(option.value, options)
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
} else if (name === 'compoundVariants' && section.value?.type === 'ArrayExpression') {
|
|
355
|
+
for (const compound of section.value.elements ?? []) {
|
|
356
|
+
if (compound?.type !== 'ObjectExpression') continue
|
|
357
|
+
for (const prop of compound.properties ?? []) {
|
|
358
|
+
const key = propertyName(prop)
|
|
359
|
+
if ((key === 'class' || key === 'className') && prop.value) analyzeClassExpression(prop.value, options)
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Walk className / class attributes and clsx / cn / classNames / twMerge / cva arguments.
|
|
368
|
+
* `hooks.onClassString(node, value)` sees every static class-list node (string literal or
|
|
369
|
+
* identifier key) and `hooks.onUnsupported(node, reason)` every dynamic one.
|
|
370
|
+
*/
|
|
371
|
+
export function walkTailwindClasses(file, content, ctx, hooks) {
|
|
372
|
+
const { program, locationAt } = parseSourceAst(file, content, ctx)
|
|
373
|
+
const diagnostics = []
|
|
374
|
+
|
|
375
|
+
walkAst(program, (node) => {
|
|
376
|
+
if (
|
|
377
|
+
node.type === 'JSXAttribute' &&
|
|
378
|
+
node.name?.type === 'JSXIdentifier' &&
|
|
379
|
+
(node.name.name === 'className' || node.name.name === 'class')
|
|
380
|
+
) {
|
|
381
|
+
const value = node.value
|
|
382
|
+
if (!value) return false
|
|
383
|
+
if (value.type === 'Literal' && typeof value.value === 'string') {
|
|
384
|
+
hooks?.onClassString?.(value, value.value)
|
|
385
|
+
const loc = locationAt(value.start)
|
|
386
|
+
analyzeClassString(value.value, { file, ...loc, diagnostics })
|
|
387
|
+
} else if (value.type === 'JSXExpressionContainer') {
|
|
388
|
+
analyzeClassExpression(value.expression, { file, content, locationAt, diagnostics, hooks })
|
|
389
|
+
}
|
|
390
|
+
return false
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if (node.type === 'CallExpression') {
|
|
394
|
+
const calleeName =
|
|
395
|
+
node.callee?.type === 'Identifier'
|
|
396
|
+
? node.callee.name
|
|
397
|
+
: node.callee?.type === 'MemberExpression' && node.callee.property?.type === 'Identifier'
|
|
398
|
+
? node.callee.property.name
|
|
399
|
+
: ''
|
|
400
|
+
if (calleeName === 'cva') {
|
|
401
|
+
analyzeCvaCall(node, { file, content, locationAt, diagnostics, hooks })
|
|
402
|
+
return false
|
|
403
|
+
}
|
|
404
|
+
if (CLASS_HELPERS.has(calleeName)) {
|
|
405
|
+
for (const arg of node.arguments ?? []) {
|
|
406
|
+
analyzeClassExpression(arg, { file, content, locationAt, diagnostics, hooks })
|
|
407
|
+
}
|
|
408
|
+
return false
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
})
|
|
412
|
+
|
|
413
|
+
return diagnostics
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
export const tailwindcssAdapter = {
|
|
417
|
+
id: 'tailwindcss',
|
|
418
|
+
detect(file) {
|
|
419
|
+
return CODE_EXT_RE.test(file)
|
|
420
|
+
},
|
|
421
|
+
analyze(file, content, ctx) {
|
|
422
|
+
return walkTailwindClasses(file, content, ctx)
|
|
423
|
+
},
|
|
424
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import valueParser from 'postcss-value-parser'
|
|
2
|
+
|
|
3
|
+
const COLOR_FN_RE = /^(?:rgba?|hsla?|oklch|oklab|color-mix|color)$/i
|
|
4
|
+
const HEX_COLOR_RE = /^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/
|
|
5
|
+
|
|
6
|
+
export function createLineIndex(content) {
|
|
7
|
+
const lineStarts = [0]
|
|
8
|
+
for (let i = 0; i < content.length; i += 1) {
|
|
9
|
+
if (content.charCodeAt(i) === 10) lineStarts.push(i + 1)
|
|
10
|
+
}
|
|
11
|
+
return (offset) => {
|
|
12
|
+
const clamped = Math.max(0, Math.min(offset ?? 0, content.length))
|
|
13
|
+
let low = 0
|
|
14
|
+
let high = lineStarts.length - 1
|
|
15
|
+
while (low <= high) {
|
|
16
|
+
const mid = (low + high) >> 1
|
|
17
|
+
if (lineStarts[mid] <= clamped) low = mid + 1
|
|
18
|
+
else high = mid - 1
|
|
19
|
+
}
|
|
20
|
+
const lineIdx = Math.max(0, high)
|
|
21
|
+
return {
|
|
22
|
+
line: lineIdx + 1,
|
|
23
|
+
column: clamped - lineStarts[lineIdx] + 1,
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function nodeContainsVar(node) {
|
|
29
|
+
if (!node) return false
|
|
30
|
+
if (node.type === 'function' && node.value.toLowerCase() === 'var') {
|
|
31
|
+
return Array.isArray(node.nodes) && node.nodes.some((child) => child.type === 'word' && child.value.startsWith('--'))
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(node.nodes)) {
|
|
34
|
+
return node.nodes.some(nodeContainsVar)
|
|
35
|
+
}
|
|
36
|
+
return false
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function extractCssValueDiagnostics({
|
|
40
|
+
file,
|
|
41
|
+
line,
|
|
42
|
+
column = 1,
|
|
43
|
+
adapter,
|
|
44
|
+
property,
|
|
45
|
+
value,
|
|
46
|
+
includeLiterals = true,
|
|
47
|
+
}) {
|
|
48
|
+
const diagnostics = []
|
|
49
|
+
const parsed = valueParser(String(value ?? ''))
|
|
50
|
+
|
|
51
|
+
const visitNodes = (nodes) => {
|
|
52
|
+
for (const node of nodes) {
|
|
53
|
+
if (node.type === 'comment' || node.type === 'string') continue
|
|
54
|
+
|
|
55
|
+
if (node.type === 'function') {
|
|
56
|
+
const fnName = node.value.toLowerCase()
|
|
57
|
+
if (fnName === 'url') continue
|
|
58
|
+
if (fnName === 'var') {
|
|
59
|
+
const arg = (node.nodes ?? []).find((child) => child.type === 'word' && child.value.startsWith('--'))
|
|
60
|
+
if (arg) {
|
|
61
|
+
diagnostics.push({
|
|
62
|
+
file,
|
|
63
|
+
line,
|
|
64
|
+
column: column + (node.sourceIndex ?? 0),
|
|
65
|
+
adapter,
|
|
66
|
+
kind: 'token-ref',
|
|
67
|
+
...(property ? { property } : {}),
|
|
68
|
+
value: valueParser.stringify(node),
|
|
69
|
+
token: arg.value,
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
// Also inspect nested var(...) fallbacks without treating literal fallbacks as hardcoded errors.
|
|
73
|
+
const nestedVars = (node.nodes ?? []).filter(
|
|
74
|
+
(child) => child.type === 'function' && child.value.toLowerCase() === 'var',
|
|
75
|
+
)
|
|
76
|
+
if (nestedVars.length) visitNodes(nestedVars)
|
|
77
|
+
continue
|
|
78
|
+
}
|
|
79
|
+
if (COLOR_FN_RE.test(fnName)) {
|
|
80
|
+
if (nodeContainsVar(node)) {
|
|
81
|
+
visitNodes(node.nodes ?? [])
|
|
82
|
+
} else if (includeLiterals) {
|
|
83
|
+
diagnostics.push({
|
|
84
|
+
file,
|
|
85
|
+
line,
|
|
86
|
+
column: column + (node.sourceIndex ?? 0),
|
|
87
|
+
adapter,
|
|
88
|
+
kind: 'literal',
|
|
89
|
+
...(property ? { property } : {}),
|
|
90
|
+
value: valueParser.stringify(node),
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
continue
|
|
94
|
+
}
|
|
95
|
+
if (Array.isArray(node.nodes) && node.nodes.length) {
|
|
96
|
+
visitNodes(node.nodes)
|
|
97
|
+
}
|
|
98
|
+
continue
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (node.type === 'word' && includeLiterals && HEX_COLOR_RE.test(node.value)) {
|
|
102
|
+
diagnostics.push({
|
|
103
|
+
file,
|
|
104
|
+
line,
|
|
105
|
+
column: column + (node.sourceIndex ?? 0),
|
|
106
|
+
adapter,
|
|
107
|
+
kind: 'literal',
|
|
108
|
+
...(property ? { property } : {}),
|
|
109
|
+
value: node.value,
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
visitNodes(parsed.nodes)
|
|
116
|
+
return diagnostics
|
|
117
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type ConsolidateCommand = 'scan' | 'plan' | 'show' | 'list' | 'set' | 'apply' | 'revert' | 'discard'
|
|
2
|
+
|
|
3
|
+
export declare const CONSOLIDATE_COMMANDS: ConsolidateCommand[]
|
|
4
|
+
export declare const CONSOLIDATE_MUTATING: Set<string>
|
|
5
|
+
export declare const CATEGORIES: string[]
|
|
6
|
+
export declare const DEFAULT_CATEGORIES: string[]
|
|
7
|
+
export declare const DEFAULT_TOLERANCE: Record<string, number>
|
|
8
|
+
|
|
9
|
+
export declare class ConsolidateError extends Error {
|
|
10
|
+
details?: Record<string, unknown>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type ConsolidateArgs = {
|
|
14
|
+
scope?: string | string[]
|
|
15
|
+
category?: string | string[]
|
|
16
|
+
categories?: string | string[]
|
|
17
|
+
tolerance?: number | string | Record<string, number>
|
|
18
|
+
rootPx?: number | string
|
|
19
|
+
design?: string
|
|
20
|
+
plan?: string
|
|
21
|
+
row?: string | number
|
|
22
|
+
action?: 'reuse' | 'create' | 'merge' | 'skip'
|
|
23
|
+
token?: string
|
|
24
|
+
name?: string
|
|
25
|
+
tier?: 'primitive' | 'semantic' | 'component' | string
|
|
26
|
+
description?: string
|
|
27
|
+
value?: string
|
|
28
|
+
merge?: string | string[]
|
|
29
|
+
acceptVisibleChange?: boolean
|
|
30
|
+
dryRun?: boolean
|
|
31
|
+
force?: boolean
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export declare function validateConsolidateArgs(command: string, args: unknown): ConsolidateArgs
|
|
35
|
+
export declare function runConsolidate(options: {
|
|
36
|
+
root?: string
|
|
37
|
+
command: string
|
|
38
|
+
args?: ConsolidateArgs
|
|
39
|
+
/** `apply`: same hooks as runTokenOp (`beforeWrite` takes the snapshot baseline). */
|
|
40
|
+
hooks?: import('../ops.mjs').TokenOpHooks
|
|
41
|
+
}): Promise<Record<string, unknown>>
|
|
42
|
+
export declare function consolidateErrorStatus(error: unknown): number
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// One entry point for `seji consolidate <command>` and
|
|
2
|
+
// `/__seji/api/consolidate/<command>`: same arguments (camelCase JSON), same results.
|
|
3
|
+
import { TokenOpError } from '../ops.mjs'
|
|
4
|
+
import { applyPlan, createPlan, discardPlan, listPlans, planCandidates, planReadiness, readPlan, revertPlan, setPlanRow } from './plan.mjs'
|
|
5
|
+
import { ConsolidateError, scanConsolidation } from './scan.mjs'
|
|
6
|
+
|
|
7
|
+
export { ConsolidateError } from './scan.mjs'
|
|
8
|
+
export { CATEGORIES, DEFAULT_CATEGORIES, DEFAULT_TOLERANCE } from './normalize.mjs'
|
|
9
|
+
|
|
10
|
+
export const CONSOLIDATE_COMMANDS = ['scan', 'plan', 'show', 'list', 'set', 'apply', 'revert', 'discard']
|
|
11
|
+
/** Commands that write (plan files, token sources, code, the review ledger). */
|
|
12
|
+
export const CONSOLIDATE_MUTATING = new Set(['plan', 'set', 'apply', 'revert', 'discard'])
|
|
13
|
+
|
|
14
|
+
const SCAN_ARGS = { scope: 'strings', category: 'strings', categories: 'strings', tolerance: 'tolerance', rootPx: 'number' }
|
|
15
|
+
const ARGS = {
|
|
16
|
+
scan: SCAN_ARGS,
|
|
17
|
+
plan: { ...SCAN_ARGS, design: 'string' },
|
|
18
|
+
show: { plan: 'string' },
|
|
19
|
+
list: {},
|
|
20
|
+
set: {
|
|
21
|
+
plan: 'string',
|
|
22
|
+
row: 'row',
|
|
23
|
+
action: 'string',
|
|
24
|
+
token: 'string',
|
|
25
|
+
name: 'string',
|
|
26
|
+
tier: 'string',
|
|
27
|
+
description: 'string',
|
|
28
|
+
value: 'string',
|
|
29
|
+
merge: 'strings',
|
|
30
|
+
acceptVisibleChange: 'boolean',
|
|
31
|
+
},
|
|
32
|
+
apply: { plan: 'string', dryRun: 'boolean', design: 'string' },
|
|
33
|
+
revert: { plan: 'string', force: 'boolean', dryRun: 'boolean' },
|
|
34
|
+
discard: { plan: 'string' },
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const invalid = (message, argument) => new ConsolidateError(message, { code: 'invalid-args', ...(argument ? { argument } : {}) })
|
|
38
|
+
|
|
39
|
+
/** Reject unknown or mistyped arguments (HTTP bodies are not parsed by the CLI). */
|
|
40
|
+
export function validateConsolidateArgs(command, args) {
|
|
41
|
+
const spec = ARGS[command]
|
|
42
|
+
if (!spec) throw invalid(`unknown consolidate command: ${command ?? '(missing)'} (expected ${CONSOLIDATE_COMMANDS.join(', ')})`)
|
|
43
|
+
if (args === null || typeof args !== 'object' || Array.isArray(args)) throw invalid('arguments must be a JSON object')
|
|
44
|
+
for (const [key, value] of Object.entries(args)) {
|
|
45
|
+
if (value === undefined) continue
|
|
46
|
+
const type = spec[key]
|
|
47
|
+
if (!type) throw invalid(`unknown argument for consolidate ${command}: ${key}`, key)
|
|
48
|
+
const ok =
|
|
49
|
+
type === 'string'
|
|
50
|
+
? typeof value === 'string'
|
|
51
|
+
: type === 'boolean'
|
|
52
|
+
? typeof value === 'boolean'
|
|
53
|
+
: type === 'number'
|
|
54
|
+
? typeof value === 'number' || (typeof value === 'string' && value.trim() !== '' && Number.isFinite(Number(value)))
|
|
55
|
+
: type === 'row'
|
|
56
|
+
? typeof value === 'string' || Number.isInteger(value)
|
|
57
|
+
: type === 'strings'
|
|
58
|
+
? typeof value === 'string' || (Array.isArray(value) && value.every((entry) => typeof entry === 'string'))
|
|
59
|
+
: type === 'tolerance'
|
|
60
|
+
? typeof value === 'number' ||
|
|
61
|
+
typeof value === 'string' ||
|
|
62
|
+
(value && typeof value === 'object' && !Array.isArray(value) && Object.values(value).every((entry) => typeof entry === 'number'))
|
|
63
|
+
: false
|
|
64
|
+
if (!ok) throw invalid(`${key} has the wrong type (${JSON.stringify(value)})`, key)
|
|
65
|
+
}
|
|
66
|
+
return args
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Run one consolidate command. Throws ConsolidateError / TokenOpError on refusal. */
|
|
70
|
+
export async function runConsolidate({ root = process.cwd(), command, args = {}, hooks } = {}) {
|
|
71
|
+
validateConsolidateArgs(command, args)
|
|
72
|
+
const scanArgs = { scope: args.scope, categories: args.categories ?? args.category, tolerance: args.tolerance, rootPx: args.rootPx }
|
|
73
|
+
switch (command) {
|
|
74
|
+
case 'scan':
|
|
75
|
+
return scanConsolidation({ root, ...scanArgs })
|
|
76
|
+
case 'plan':
|
|
77
|
+
return createPlan({ root, ...scanArgs, design: args.design })
|
|
78
|
+
case 'show': {
|
|
79
|
+
if (!args.plan) throw invalid('<plan> is required', 'plan')
|
|
80
|
+
const plan = readPlan(root, args.plan)
|
|
81
|
+
return { ...plan, readiness: planReadiness(root, plan), candidates: planCandidates(root, plan) }
|
|
82
|
+
}
|
|
83
|
+
case 'list':
|
|
84
|
+
return { plans: listPlans(root) }
|
|
85
|
+
case 'set': {
|
|
86
|
+
if (!args.plan) throw invalid('<plan> is required', 'plan')
|
|
87
|
+
const { plan, row, ...changes } = args
|
|
88
|
+
return setPlanRow({ root, plan, row: row === undefined ? undefined : String(row), ...changes })
|
|
89
|
+
}
|
|
90
|
+
case 'apply':
|
|
91
|
+
if (!args.plan) throw invalid('<plan> is required', 'plan')
|
|
92
|
+
return applyPlan({ root, plan: args.plan, dryRun: args.dryRun === true, design: args.design, hooks })
|
|
93
|
+
case 'revert':
|
|
94
|
+
if (!args.plan) throw invalid('<plan> is required', 'plan')
|
|
95
|
+
return revertPlan({ root, plan: args.plan, force: args.force === true, dryRun: args.dryRun === true })
|
|
96
|
+
case 'discard':
|
|
97
|
+
if (!args.plan) throw invalid('<plan> is required', 'plan')
|
|
98
|
+
return discardPlan({ root, plan: args.plan })
|
|
99
|
+
default:
|
|
100
|
+
throw invalid(`unknown consolidate command: ${command}`)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** HTTP status for an error thrown by `runConsolidate`. */
|
|
105
|
+
export function consolidateErrorStatus(error) {
|
|
106
|
+
const code = error?.details?.code
|
|
107
|
+
if (code === 'invalid-args') return 400
|
|
108
|
+
if (code === 'not-found') return 404
|
|
109
|
+
if (error instanceof ConsolidateError || error instanceof TokenOpError) return 409
|
|
110
|
+
return 500
|
|
111
|
+
}
|