@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,47 @@
|
|
|
1
|
+
import type { TokenHealth } from '../shared/tokens'
|
|
2
|
+
import type { ReviewChecks, ReviewItem } from '../shared/types'
|
|
3
|
+
|
|
4
|
+
export type VerifyItemResult = {
|
|
5
|
+
id: string
|
|
6
|
+
kind: string
|
|
7
|
+
token?: string
|
|
8
|
+
status: string
|
|
9
|
+
/** Values and references pass, and snapshots are not failed / waiting for review. */
|
|
10
|
+
ok: boolean
|
|
11
|
+
checks: Omit<ReviewChecks, 'checkedAt'>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type VerifyResult = {
|
|
15
|
+
design: string
|
|
16
|
+
verified: Array<{ id: string; token: string }>
|
|
17
|
+
pending: Array<{ id: string; token: string; reason: string }>
|
|
18
|
+
items: VerifyItemResult[]
|
|
19
|
+
written: boolean
|
|
20
|
+
/** `--item` ids that are archived (reported, not checked). */
|
|
21
|
+
archived?: string[]
|
|
22
|
+
/** Set when `snapshots: true` was requested but rendering was unavailable. */
|
|
23
|
+
snapshotError?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export declare function listReviewDesigns(root: string): string[]
|
|
27
|
+
export declare function verifyReviews(options?: {
|
|
28
|
+
root?: string
|
|
29
|
+
designs?: string[]
|
|
30
|
+
dryRun?: boolean
|
|
31
|
+
items?: string[]
|
|
32
|
+
snapshots?: boolean
|
|
33
|
+
url?: string
|
|
34
|
+
configFile?: string
|
|
35
|
+
}): Promise<VerifyResult[]>
|
|
36
|
+
export declare function healthReport(options?: { root?: string }): Promise<{
|
|
37
|
+
ok: boolean
|
|
38
|
+
stale: string[]
|
|
39
|
+
counts: { total: number; byTier: Record<string, number> }
|
|
40
|
+
errors: string[]
|
|
41
|
+
warnings: string[]
|
|
42
|
+
contrast: Array<{ fg: string; bg: string; ratio: number; pass: boolean }>
|
|
43
|
+
unknownVars: string[]
|
|
44
|
+
health: TokenHealth
|
|
45
|
+
reviews: VerifyResult[]
|
|
46
|
+
}>
|
|
47
|
+
export declare function shouldCheck(item: ReviewItem): boolean
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
// Headless token health and review verification. Neither needs the canvas open:
|
|
2
|
+
// both read the token source and code directly, like `tokens build` does.
|
|
3
|
+
import { existsSync, readdirSync } from 'node:fs'
|
|
4
|
+
import { join } from 'node:path'
|
|
5
|
+
|
|
6
|
+
import { mutateReview, readReviewFile, reviewFilePath } from '../shared/reviewStore.mjs'
|
|
7
|
+
import { isAwaitingVerification, tokenVerificationGapOf } from '../shared/reviewVerify.mjs'
|
|
8
|
+
import { compareSnapshots, waitForBaselines } from '../snapshots/index.mjs'
|
|
9
|
+
import { isCapturingBaseline, snapshotCheck } from '../shared/snapshotCheck.mjs'
|
|
10
|
+
import { createRenderer } from '../snapshots/render.mjs'
|
|
11
|
+
import { analyzeTokens, staleOutputs } from './pipeline.mjs'
|
|
12
|
+
import { buildUsageIndex } from './usage.mjs'
|
|
13
|
+
|
|
14
|
+
export function listReviewDesigns(root) {
|
|
15
|
+
const base = join(root, 'design')
|
|
16
|
+
if (!existsSync(base)) return []
|
|
17
|
+
return readdirSync(base, { withFileTypes: true })
|
|
18
|
+
.filter((entry) => entry.isDirectory() && existsSync(join(base, entry.name, 'review.json')))
|
|
19
|
+
.map((entry) => entry.name)
|
|
20
|
+
.sort()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function verificationContext(analysis) {
|
|
24
|
+
const values = {}
|
|
25
|
+
const aliases = {}
|
|
26
|
+
const deprecated = {}
|
|
27
|
+
const descriptions = {}
|
|
28
|
+
for (const record of analysis.records) {
|
|
29
|
+
if (record.description !== undefined) descriptions[record.cssName] = record.description
|
|
30
|
+
values[record.cssName] = record.value
|
|
31
|
+
if (record.alias) aliases[record.cssName] = record.alias
|
|
32
|
+
if (record.deprecated) deprecated[record.cssName] = record.deprecated
|
|
33
|
+
}
|
|
34
|
+
const literalFiles = (value) =>
|
|
35
|
+
analysis.usage.clusters.find((entry) => entry.value.toLowerCase() === String(value).toLowerCase())?.files ?? []
|
|
36
|
+
return { values, aliases, literalFiles, deprecated, descriptions }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Every check carries `code` + `params` next to its English `detail`; the editor translates them.
|
|
40
|
+
const pass = (code, params, detail, extra = {}) => ({ status: 'pass', code, params, detail, ...extra })
|
|
41
|
+
const fail = (code, params, detail, extra = {}) => ({ status: 'fail', code, params, detail, ...extra })
|
|
42
|
+
const skip = (code, detail) => ({ status: 'skip', code, params: {}, detail })
|
|
43
|
+
|
|
44
|
+
/** Check 1 — token values: the built token source holds the requested value / alias. */
|
|
45
|
+
export function valuesCheck(item, context, staleReason) {
|
|
46
|
+
if (item.kind !== 'token' || item.target?.type !== 'token') return skip('not-token', `${item.kind} item has no token value`)
|
|
47
|
+
if (item.proposalDecision === 'rejected') return skip('rejected', 'rejected proposal: the token must not be written')
|
|
48
|
+
if (staleReason) return fail('stale', { files: staleReason.files }, staleReason.message)
|
|
49
|
+
const gap = tokenVerificationGapOf({ ...item, replaces: undefined }, { ...context, literalFiles: undefined })
|
|
50
|
+
if (gap) return fail(gap.code, gap.params, gap.message)
|
|
51
|
+
const token = item.target.token
|
|
52
|
+
const alias = context.aliases[token]
|
|
53
|
+
if ((item.tokenAction === 'deprecate' || item.tokenAction === 'delete' || item.tokenAction === 'rename') && context.values[token] === undefined) {
|
|
54
|
+
return pass('gone', { token }, `${token} is gone from the token source`)
|
|
55
|
+
}
|
|
56
|
+
return pass(
|
|
57
|
+
'value',
|
|
58
|
+
{ token, alias: alias ?? '', value: context.values[token] ?? '' },
|
|
59
|
+
`${token} = ${alias ? `{${alias}} → ` : ''}${context.values[token]}`,
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Check 2 — references: every reference the change implies is updated (usage index).
|
|
65
|
+
* Replaced literals are gone from the listed files; a deprecated token has no code
|
|
66
|
+
* references left; no code references an undefined token; a new token that replaces a
|
|
67
|
+
* literal is actually referenced.
|
|
68
|
+
*/
|
|
69
|
+
export function referencesCheck(item, { index, analysis, literalFiles }) {
|
|
70
|
+
if (item.kind !== 'token' || item.target?.type !== 'token') return skip('no-references', `${item.kind} item changes no references`)
|
|
71
|
+
if (item.proposalDecision === 'rejected') return skip('rejected', 'rejected proposal')
|
|
72
|
+
const token = item.target.token
|
|
73
|
+
const problems = []
|
|
74
|
+
const left = []
|
|
75
|
+
const problem = (code, params, message) => problems.push({ code, params, message })
|
|
76
|
+
if (item.replaces?.value) {
|
|
77
|
+
const files = literalFiles(item.replaces.value).filter((file) => (item.replaces.files ?? []).includes(file))
|
|
78
|
+
if (files.length) {
|
|
79
|
+
problem('still-hardcoded', { value: item.replaces.value, files: files.join(', ') }, `${item.replaces.value} is still hard-coded in ${files.join(', ')}`)
|
|
80
|
+
left.push(...files.map((file) => ({ file, literal: item.replaces.value })))
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const usage = index.tokenUsage(token)
|
|
84
|
+
const unknown = new Set(analysis.usage.unknown ?? [])
|
|
85
|
+
if (unknown.has(token)) problem('undefined-var', { token }, `var(${token}) is referenced in code but not defined`)
|
|
86
|
+
if (item.tokenAction === 'deprecate' && usage?.code.count) {
|
|
87
|
+
problem('still-referenced', { token, count: usage.code.count }, `${token} still has ${usage.code.count} code reference(s)`)
|
|
88
|
+
left.push(...usage.code.files.map((entry) => ({ file: entry.file, token, lines: entry.lines })))
|
|
89
|
+
}
|
|
90
|
+
if (item.tokenAction === 'create' && item.replaces?.value && usage && !usage.summary.impactCodeRefs) {
|
|
91
|
+
problem('not-referenced', { token }, `${token} is not referenced in code yet`)
|
|
92
|
+
}
|
|
93
|
+
if (problems.length) {
|
|
94
|
+
return fail(
|
|
95
|
+
problems[0].code,
|
|
96
|
+
problems[0].params,
|
|
97
|
+
problems.map((entry) => entry.message).join('; '),
|
|
98
|
+
{ issues: problems.map(({ code, params }) => ({ code, params })), ...(left.length ? { left } : {}) },
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
if (!usage) return pass('none-left', { token }, `${token} has no references left`)
|
|
102
|
+
const { codeRefs, components, screens, tokens } = usage.summary
|
|
103
|
+
return pass(
|
|
104
|
+
'counts',
|
|
105
|
+
{ codeRefs, files: usage.code.files.length, tokens, components, screens },
|
|
106
|
+
`${codeRefs} code ref(s) in ${usage.code.files.length} file(s), ${tokens} referencing token(s), ${components} component(s), ${screens} screen(s)`,
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Items `verify` checks: resolved unverified token items and resolved items with a snapshot
|
|
112
|
+
* baseline (or a baseline capture in progress). Archived items are never checked.
|
|
113
|
+
*/
|
|
114
|
+
export const shouldCheck = (item) =>
|
|
115
|
+
item.status !== 'archived' &&
|
|
116
|
+
(isAwaitingVerification(item) ||
|
|
117
|
+
(item.status === 'resolved' && Boolean(item.snapshots?.baselineAt || item.snapshots?.capturingSince)))
|
|
118
|
+
const isSelected = (item, itemIds) =>
|
|
119
|
+
itemIds?.length ? itemIds.includes(item.id) && item.status !== 'archived' : shouldCheck(item)
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Run the three checks (token values, references, snapshots) on review items and write
|
|
123
|
+
* `checks` + `verifiedAt` (values and references pass) unless `dryRun`. `items` limits the
|
|
124
|
+
* run to given item ids (any status). `snapshots: true` first renders the "after" state of
|
|
125
|
+
* items with a baseline and diffs it (needs Playwright; `url` reuses a running dev server).
|
|
126
|
+
*/
|
|
127
|
+
export async function verifyReviews({
|
|
128
|
+
root = process.cwd(),
|
|
129
|
+
designs,
|
|
130
|
+
dryRun = false,
|
|
131
|
+
analysis,
|
|
132
|
+
items: itemIds,
|
|
133
|
+
snapshots = false,
|
|
134
|
+
url,
|
|
135
|
+
configFile,
|
|
136
|
+
} = {}) {
|
|
137
|
+
const tokens = analysis ?? (await analyzeTokens({ root }))
|
|
138
|
+
const context = verificationContext(tokens)
|
|
139
|
+
const index = await buildUsageIndex({ root, analysis: tokens })
|
|
140
|
+
// The canvas reads the generated files, so an unbuilt source change is not verified yet.
|
|
141
|
+
const stale = staleOutputs(root, tokens.config, tokens.outputs)
|
|
142
|
+
const staleReason = stale.length
|
|
143
|
+
? { files: stale.join(', '), message: `generated tokens are stale (${stale.join(', ')}); run tokens build` }
|
|
144
|
+
: null
|
|
145
|
+
const targetDesigns = designs?.length ? designs : listReviewDesigns(root)
|
|
146
|
+
if (itemIds?.length && targetDesigns.length !== 1) throw new Error('--item needs exactly one design')
|
|
147
|
+
|
|
148
|
+
let snapshotError = null
|
|
149
|
+
let renderer = null
|
|
150
|
+
const results = []
|
|
151
|
+
try {
|
|
152
|
+
for (const design of targetDesigns) {
|
|
153
|
+
let ledger = readReviewFile(reviewFilePath(root, design))
|
|
154
|
+
if (!ledger) throw new Error(`no review ledger for ${design}`)
|
|
155
|
+
// A baseline still being captured (dev server autocapture) must finish before "after"
|
|
156
|
+
// is compared against it.
|
|
157
|
+
const capturing = (ledger.items ?? []).filter((item) => isSelected(item, itemIds) && isCapturingBaseline(item))
|
|
158
|
+
if (snapshots && !dryRun && capturing.length) {
|
|
159
|
+
await waitForBaselines({ root, design, itemIds: capturing.map((item) => item.id) })
|
|
160
|
+
ledger = readReviewFile(reviewFilePath(root, design)) ?? ledger
|
|
161
|
+
}
|
|
162
|
+
const selected = (ledger.items ?? []).filter((item) => isSelected(item, itemIds))
|
|
163
|
+
// `--item` on an archived item reports it instead of writing checks onto history.
|
|
164
|
+
const archived = []
|
|
165
|
+
for (const id of itemIds ?? []) {
|
|
166
|
+
const item = (ledger.items ?? []).find((entry) => entry.id === id)
|
|
167
|
+
if (!item) throw new Error(`review item not found in ${design}: ${id}`)
|
|
168
|
+
if (item.status === 'archived') archived.push(id)
|
|
169
|
+
}
|
|
170
|
+
const withBaseline = selected.filter((item) => item.snapshots?.baselineAt && item.status !== 'archived')
|
|
171
|
+
if (snapshots && !dryRun && withBaseline.length && !snapshotError) {
|
|
172
|
+
try {
|
|
173
|
+
renderer ??= await createRenderer({ root, url, configFile })
|
|
174
|
+
await compareSnapshots({ root, design, itemIds: withBaseline.map((item) => item.id), renderer })
|
|
175
|
+
} catch (error) {
|
|
176
|
+
snapshotError = error instanceof Error ? error.message : String(error)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const check = (items) => {
|
|
180
|
+
const verified = []
|
|
181
|
+
const pending = []
|
|
182
|
+
const entries = []
|
|
183
|
+
for (const item of items) {
|
|
184
|
+
const checks = {
|
|
185
|
+
values: valuesCheck(item, context, staleReason),
|
|
186
|
+
references: referencesCheck(item, { index, analysis: tokens, literalFiles: context.literalFiles }),
|
|
187
|
+
snapshots: snapshotCheck(item),
|
|
188
|
+
}
|
|
189
|
+
const failed = ['values', 'references'].filter((name) => checks[name].status === 'fail')
|
|
190
|
+
if (isAwaitingVerification(item)) {
|
|
191
|
+
if (failed.length) {
|
|
192
|
+
pending.push({ id: item.id, token: item.target.token, reason: failed.map((name) => checks[name].detail).join('; ') })
|
|
193
|
+
} else verified.push({ id: item.id, token: item.target.token })
|
|
194
|
+
}
|
|
195
|
+
entries.push({
|
|
196
|
+
id: item.id,
|
|
197
|
+
kind: item.kind,
|
|
198
|
+
...(item.target?.type === 'token' ? { token: item.target.token } : {}),
|
|
199
|
+
status: item.status,
|
|
200
|
+
ok: !failed.length && !['fail', 'review', 'pending'].includes(checks.snapshots.status),
|
|
201
|
+
checks,
|
|
202
|
+
})
|
|
203
|
+
}
|
|
204
|
+
return { verified, pending, items: entries }
|
|
205
|
+
}
|
|
206
|
+
const pick = (items) => items.filter((item) => isSelected(item, itemIds))
|
|
207
|
+
const extra = archived.length ? { archived } : {}
|
|
208
|
+
if (dryRun) {
|
|
209
|
+
results.push({ design, ...check(selected), ...extra, written: false })
|
|
210
|
+
continue
|
|
211
|
+
}
|
|
212
|
+
let outcome
|
|
213
|
+
const { written } = mutateReview(root, design, (review) => {
|
|
214
|
+
outcome = check(pick(review.items))
|
|
215
|
+
if (!outcome.items.length) return undefined
|
|
216
|
+
const now = new Date().toISOString()
|
|
217
|
+
const verifiedIds = new Set(outcome.verified.map((entry) => entry.id))
|
|
218
|
+
const byId = new Map(outcome.items.map((entry) => [entry.id, entry]))
|
|
219
|
+
return {
|
|
220
|
+
...review,
|
|
221
|
+
items: review.items.map((item) => {
|
|
222
|
+
const entry = byId.get(item.id)
|
|
223
|
+
if (!entry) return item
|
|
224
|
+
return {
|
|
225
|
+
...item,
|
|
226
|
+
checks: { checkedAt: now, ...entry.checks },
|
|
227
|
+
...(verifiedIds.has(item.id) ? { verifiedAt: now, updatedAt: now } : {}),
|
|
228
|
+
}
|
|
229
|
+
}),
|
|
230
|
+
}
|
|
231
|
+
})
|
|
232
|
+
results.push({ design, ...outcome, ...extra, written })
|
|
233
|
+
}
|
|
234
|
+
} finally {
|
|
235
|
+
if (renderer) await renderer.close()
|
|
236
|
+
}
|
|
237
|
+
if (snapshotError) for (const result of results) result.snapshotError = snapshotError
|
|
238
|
+
return results
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Token health report: validation, contrast, structure issues, and review verification status. */
|
|
242
|
+
export async function healthReport({ root = process.cwd() } = {}) {
|
|
243
|
+
const analysis = await analyzeTokens({ root })
|
|
244
|
+
const { outputs, errors, warnings } = analysis
|
|
245
|
+
const reviews = await verifyReviews({ root, dryRun: true, analysis })
|
|
246
|
+
return {
|
|
247
|
+
ok: errors.length === 0,
|
|
248
|
+
stale: staleOutputs(root, analysis.config, outputs),
|
|
249
|
+
counts: outputs.manifest.counts,
|
|
250
|
+
errors,
|
|
251
|
+
warnings,
|
|
252
|
+
contrast: outputs.manifest.contrast,
|
|
253
|
+
unknownVars: outputs.manifest.unknownVars,
|
|
254
|
+
health: outputs.health,
|
|
255
|
+
reviews,
|
|
256
|
+
}
|
|
257
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// Code rewriter: style={{}} / *Styles objects / StyleX create() strings (via the css-in-code
|
|
2
|
+
// adapter walk) and Tailwind class literals (via the tailwindcss adapter walk), parsed with
|
|
3
|
+
// @babel/parser. A string node's inner range comes from the node offsets; inside it, var()
|
|
4
|
+
// names come from postcss-value-parser positions and classes from the class splitter.
|
|
5
|
+
// Every other string that still mentions the token becomes a leftover with a reason.
|
|
6
|
+
import { walkCssInCode } from '../adapters/cssInCode.mjs'
|
|
7
|
+
import { parseSourceAst, walkAst } from '../adapters/oxcShared.mjs'
|
|
8
|
+
import { walkTailwindClasses } from '../adapters/tailwindcss.mjs'
|
|
9
|
+
import { rewriteClassList } from './tailwind.mjs'
|
|
10
|
+
import { applyEdits, createFileResult, finishFileResult } from './text.mjs'
|
|
11
|
+
import { rewriteValueLiteral, rewriteValueVars } from './value.mjs'
|
|
12
|
+
|
|
13
|
+
const TAGGED_TEMPLATE = 'unsupported-scheme: tagged-template CSS-in-JS (styled-components / emotion)'
|
|
14
|
+
const VANILLA_EXTRACT = 'unsupported-scheme: vanilla-extract'
|
|
15
|
+
|
|
16
|
+
/** Inner text range of a static string node, or null when escapes make offsets unsafe. */
|
|
17
|
+
export function stringInner(content, node) {
|
|
18
|
+
if (node.type === 'Identifier') return { at: node.start, text: node.name, identifier: true }
|
|
19
|
+
if (node.type === 'Literal' && typeof node.value === 'string') {
|
|
20
|
+
const inner = content.slice(node.start + 1, node.end - 1)
|
|
21
|
+
return inner === node.value ? { at: node.start + 1, text: inner } : null
|
|
22
|
+
}
|
|
23
|
+
if (node.type === 'TemplateLiteral' && !(node.expressions?.length)) {
|
|
24
|
+
const inner = content.slice(node.start + 1, node.end - 1)
|
|
25
|
+
const cooked = (node.quasis ?? []).map((quasi) => quasi.value?.cooked ?? '').join('')
|
|
26
|
+
return inner === cooked ? { at: node.start + 1, text: inner } : null
|
|
27
|
+
}
|
|
28
|
+
return null
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Collect edits against a string's text, so identifier keys can be re-emitted quoted. */
|
|
32
|
+
function collect() {
|
|
33
|
+
const edits = []
|
|
34
|
+
const leftovers = []
|
|
35
|
+
return {
|
|
36
|
+
edits,
|
|
37
|
+
leftovers,
|
|
38
|
+
handlers: {
|
|
39
|
+
emit: (start, end, text) => edits.push({ start, end, text }),
|
|
40
|
+
leftover: (offset, reason, text) => leftovers.push({ offset, reason, text }),
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Plan rewrites for one code file.
|
|
47
|
+
* spec.mode 'rename': { renames, theme, themeIndex, themeUnsupported }
|
|
48
|
+
* spec.mode 'literal': { literal, token, replacement, property?, properties?, utilities?, namespaceHint?, theme, classes? }
|
|
49
|
+
*/
|
|
50
|
+
export function planCodeFile(file, content, spec) {
|
|
51
|
+
const result = createFileResult(file, content)
|
|
52
|
+
const ctx = { parseCache: new Map() }
|
|
53
|
+
const vanilla = /\.css\.[cm]?[jt]s$/i.test(file)
|
|
54
|
+
const handled = new Set()
|
|
55
|
+
const ranges = []
|
|
56
|
+
|
|
57
|
+
const flush = (node, inner, { edits, leftovers }, info) => {
|
|
58
|
+
for (const entry of leftovers) result.leftover(inner.at + entry.offset, entry.reason, entry.text, info)
|
|
59
|
+
if (!edits.length) return
|
|
60
|
+
if (vanilla) {
|
|
61
|
+
result.leftover(inner.at, VANILLA_EXTRACT, inner.text, info)
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
if (inner.identifier) {
|
|
65
|
+
// `{ active: cond }` keys: a changed class may not be a valid identifier, so quote it.
|
|
66
|
+
result.edit(node.start, node.end, `'${applyEdits(inner.text, edits)}'`, info)
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
for (const edit of edits) result.edit(inner.at + edit.start, inner.at + edit.end, edit.text, info)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const mentions = (text) => {
|
|
73
|
+
if (spec.mode === 'literal') return text.trim().toLowerCase() === spec.literal.trim().toLowerCase()
|
|
74
|
+
if (spec.renames.has(text)) return true
|
|
75
|
+
const probe = collect()
|
|
76
|
+
rewriteValueVars(text, spec.renames, probe.handlers)
|
|
77
|
+
if (probe.edits.length || probe.leftovers.length) return true
|
|
78
|
+
if (spec.themeIndex) {
|
|
79
|
+
rewriteClassList(text, spec, probe.handlers)
|
|
80
|
+
if (probe.edits.length || probe.leftovers.length) return true
|
|
81
|
+
}
|
|
82
|
+
return false
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const hooks = {
|
|
86
|
+
style: {
|
|
87
|
+
onString(node, value, property) {
|
|
88
|
+
handled.add(node)
|
|
89
|
+
const info = { property, scheme: 'css-in-code' }
|
|
90
|
+
const inner = stringInner(content, node)
|
|
91
|
+
if (!inner) {
|
|
92
|
+
if (mentions(value)) result.leftover(node.start, 'escaped-string', value, info)
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
const sink = collect()
|
|
96
|
+
if (spec.mode === 'rename') {
|
|
97
|
+
rewriteValueVars(inner.text, spec.renames, sink.handlers)
|
|
98
|
+
if (!sink.edits.length && !sink.leftovers.length && spec.themeIndex) {
|
|
99
|
+
// A class list stored in a style-named object: not a CSS value, so not ours to change.
|
|
100
|
+
const probe = collect()
|
|
101
|
+
rewriteClassList(inner.text, spec, probe.handlers)
|
|
102
|
+
if (probe.edits.length || probe.leftovers.length) {
|
|
103
|
+
result.leftover(node.start, 'unrecognized-context', value, info)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
} else if ((!spec.property || spec.property === property) && (!spec.properties || spec.properties.includes(property))) {
|
|
107
|
+
rewriteValueLiteral(inner.text, spec.literal, spec.replacement, sink.handlers)
|
|
108
|
+
}
|
|
109
|
+
flush(node, inner, sink, info)
|
|
110
|
+
},
|
|
111
|
+
onUnsupported(node, reason) {
|
|
112
|
+
ranges.push({ start: node.start, end: node.end, reason })
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
classes: {
|
|
116
|
+
onClassString(node, value) {
|
|
117
|
+
handled.add(node)
|
|
118
|
+
const info = { property: 'className', scheme: 'tailwind' }
|
|
119
|
+
const inner = stringInner(content, node)
|
|
120
|
+
if (!inner) {
|
|
121
|
+
if (mentions(value)) result.leftover(node.start, 'escaped-string', value, info)
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
const sink = collect()
|
|
125
|
+
if (spec.mode === 'rename') rewriteClassList(inner.text, spec, sink.handlers)
|
|
126
|
+
else rewriteClassList(inner.text, spec, sink.handlers, 'literal')
|
|
127
|
+
flush(node, inner, sink, info)
|
|
128
|
+
},
|
|
129
|
+
onUnsupported(node, reason) {
|
|
130
|
+
ranges.push({ start: node.start, end: node.end, reason })
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
walkCssInCode(file, content, ctx, hooks.style)
|
|
136
|
+
if (spec.mode === 'rename' || spec.classes !== false) walkTailwindClasses(file, content, ctx, hooks.classes)
|
|
137
|
+
|
|
138
|
+
// Strings no walker claimed: anything that still mentions the target is the agent's.
|
|
139
|
+
const { program } = parseSourceAst(file, content, ctx)
|
|
140
|
+
const rangeReason = (node) =>
|
|
141
|
+
ranges
|
|
142
|
+
.filter((range) => range.start <= node.start && node.end <= range.end)
|
|
143
|
+
.sort((a, b) => a.end - a.start - (b.end - b.start))[0]?.reason
|
|
144
|
+
walkAst(program, (node, parent) => {
|
|
145
|
+
if (handled.has(node)) return
|
|
146
|
+
if (node.type === 'Literal' && typeof node.value === 'string') {
|
|
147
|
+
if (!mentions(node.value)) return
|
|
148
|
+
const reason = vanilla
|
|
149
|
+
? VANILLA_EXTRACT
|
|
150
|
+
: spec.mode === 'rename' && spec.renames.has(node.value)
|
|
151
|
+
? 'token-name-string'
|
|
152
|
+
: rangeReason(node) ?? 'unrecognized-context'
|
|
153
|
+
result.leftover(node.start, reason, node.value)
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
if (node.type === 'TemplateLiteral') {
|
|
157
|
+
for (const quasi of node.quasis ?? []) {
|
|
158
|
+
const text = quasi.value?.cooked ?? quasi.value?.raw ?? ''
|
|
159
|
+
if (!text || !mentions(text)) continue
|
|
160
|
+
const reason =
|
|
161
|
+
parent?.type === 'TaggedTemplateExpression'
|
|
162
|
+
? TAGGED_TEMPLATE
|
|
163
|
+
: vanilla
|
|
164
|
+
? VANILLA_EXTRACT
|
|
165
|
+
: (rangeReason(node) ?? (node.expressions?.length ? 'dynamic-template' : 'unrecognized-context'))
|
|
166
|
+
result.leftover(quasi.start ?? node.start, reason, text)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
return finishFileResult(result)
|
|
172
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// CSS / CSS Modules / SCSS / Less rewriter. postcss (with postcss-scss / postcss-less, like the
|
|
2
|
+
// token adapters) gives each declaration and at-rule a source position; the value or params
|
|
3
|
+
// offset is derived from that node, checked against the file, and the value is walked with
|
|
4
|
+
// postcss-value-parser so only the matched name or literal is replaced.
|
|
5
|
+
import postcss from 'postcss'
|
|
6
|
+
|
|
7
|
+
import { rewriteClassList } from './tailwind.mjs'
|
|
8
|
+
import { createFileResult, finishFileResult } from './text.mjs'
|
|
9
|
+
import { rewriteValueLiteral, rewriteValueVars } from './value.mjs'
|
|
10
|
+
|
|
11
|
+
async function tryImportParser(pkgName) {
|
|
12
|
+
try {
|
|
13
|
+
const mod = await import(pkgName)
|
|
14
|
+
return mod.default ?? mod
|
|
15
|
+
} catch {
|
|
16
|
+
return null
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function cssSyntaxOf(file) {
|
|
21
|
+
if (/\.scss$/i.test(file)) return 'scss'
|
|
22
|
+
if (/\.sass$/i.test(file)) return 'sass'
|
|
23
|
+
if (/\.less$/i.test(file)) return 'less'
|
|
24
|
+
if (/\.css$/i.test(file)) return 'css'
|
|
25
|
+
return null
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function parseStylesheet(file, content) {
|
|
29
|
+
const syntax = cssSyntaxOf(file)
|
|
30
|
+
if (syntax === 'css') return { root: postcss.parse(content, { from: file }) }
|
|
31
|
+
if (syntax === 'sass') return { unsupported: 'unsupported-scheme: indented .sass syntax' }
|
|
32
|
+
const parser = await tryImportParser(syntax === 'scss' ? 'postcss-scss' : 'postcss-less')
|
|
33
|
+
if (!parser || typeof parser.parse !== 'function') {
|
|
34
|
+
return { unsupported: `parser-not-installed: ${syntax === 'scss' ? 'postcss-scss' : 'postcss-less'}` }
|
|
35
|
+
}
|
|
36
|
+
return { root: parser.parse(content, { from: file }) }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function lineStartsOf(content) {
|
|
40
|
+
const starts = [0]
|
|
41
|
+
for (let i = 0; i < content.length; i += 1) if (content.charCodeAt(i) === 10) starts.push(i + 1)
|
|
42
|
+
return starts
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function isTokenDefinitionBlock(decl) {
|
|
46
|
+
if (!decl.prop.startsWith('--')) return false
|
|
47
|
+
const parent = decl.parent
|
|
48
|
+
if (!parent) return false
|
|
49
|
+
if (parent.type === 'atrule' && parent.name.toLowerCase() === 'theme') return true
|
|
50
|
+
if (parent.type === 'rule') {
|
|
51
|
+
return parent.selectors?.some((selector) => selector.trim() === ':root') ?? false
|
|
52
|
+
}
|
|
53
|
+
return false
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Plan rewrites for one stylesheet.
|
|
58
|
+
* spec.mode 'rename': { renames: Map<old, new>, theme, themeIndex, themeUnsupported }
|
|
59
|
+
* spec.mode 'literal': { literal, token, replacement, property?, properties? }
|
|
60
|
+
* (`properties`: only declarations of these properties, e.g. one style category)
|
|
61
|
+
*/
|
|
62
|
+
export async function planStylesheet(file, content, spec) {
|
|
63
|
+
const result = createFileResult(file, content)
|
|
64
|
+
const parsed = await parseStylesheet(file, content).catch((error) => ({
|
|
65
|
+
unsupported: `parse-error: ${error instanceof Error ? error.message.split('\n')[0] : String(error)}`,
|
|
66
|
+
}))
|
|
67
|
+
if (!parsed.root) {
|
|
68
|
+
// Without an AST nothing can be located; report the file once if it mentions the target.
|
|
69
|
+
const probe = spec.mode === 'rename' ? [...spec.renames.keys()] : [spec.literal]
|
|
70
|
+
if (probe.some((name) => content.includes(name))) result.leftover(0, parsed.unsupported, file)
|
|
71
|
+
return finishFileResult(result)
|
|
72
|
+
}
|
|
73
|
+
const starts = lineStartsOf(content)
|
|
74
|
+
const offsetOf = (position) => {
|
|
75
|
+
if (!position) return null
|
|
76
|
+
if (typeof position.offset === 'number') return position.offset
|
|
77
|
+
if (typeof position.line === 'number') return (starts[position.line - 1] ?? 0) + (position.column ?? 1) - 1
|
|
78
|
+
return null
|
|
79
|
+
}
|
|
80
|
+
/** Absolute offset of `text` inside `node`, preferring `guess`; null if it cannot be located. */
|
|
81
|
+
const locate = (node, text, guess) => {
|
|
82
|
+
if (guess !== null && content.slice(guess, guess + text.length) === text) return guess
|
|
83
|
+
const start = offsetOf(node.source?.start)
|
|
84
|
+
const end = offsetOf(node.source?.end)
|
|
85
|
+
if (start === null) return null
|
|
86
|
+
let stop = end === null ? content.length : end + 1
|
|
87
|
+
if (node.type === 'atrule' && node.nodes) {
|
|
88
|
+
// Only the prelude (before the block) can hold the params; never match inside the block.
|
|
89
|
+
const first = node.nodes.length ? offsetOf(node.nodes[0].source?.start) : null
|
|
90
|
+
const brace = content.indexOf('{', start)
|
|
91
|
+
const candidates = [first, brace === -1 ? null : brace].filter((value) => value !== null && value >= start)
|
|
92
|
+
if (candidates.length) stop = Math.min(stop, ...candidates)
|
|
93
|
+
}
|
|
94
|
+
const slice = content.slice(start, stop)
|
|
95
|
+
const index = slice.lastIndexOf(text)
|
|
96
|
+
return index === -1 ? null : start + index
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const valueHandlers = (at, info) => ({
|
|
100
|
+
emit: (s, e, text) => result.edit(at + s, at + e, text, info),
|
|
101
|
+
leftover: (offset, reason, text) => result.leftover(at + offset, reason, text, info),
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
parsed.root.walk((node) => {
|
|
105
|
+
if (node.type === 'decl') {
|
|
106
|
+
const rawValue = node.raws?.value?.raw ?? node.value
|
|
107
|
+
const start = offsetOf(node.source?.start)
|
|
108
|
+
const guess = start === null ? null : start + node.prop.length + (node.raws?.between?.length ?? 0)
|
|
109
|
+
const at = locate(node, rawValue, guess)
|
|
110
|
+
const info = { property: node.prop, scheme: 'css' }
|
|
111
|
+
if (spec.mode === 'rename') {
|
|
112
|
+
if (spec.renames.has(node.prop)) {
|
|
113
|
+
result.leftover(start ?? 0, 'defines-token-locally', `${node.prop}: ${node.value}`, info)
|
|
114
|
+
}
|
|
115
|
+
if (at === null) {
|
|
116
|
+
if ([...spec.renames.keys()].some((name) => rawValue.includes(name))) {
|
|
117
|
+
result.leftover(start ?? 0, 'could-not-locate', rawValue, info)
|
|
118
|
+
}
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
rewriteValueVars(rawValue, spec.renames, valueHandlers(at, info))
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
if (isTokenDefinitionBlock(node)) return
|
|
125
|
+
if (spec.property && node.prop !== spec.property) return
|
|
126
|
+
if (spec.properties && !spec.properties.includes(node.prop.toLowerCase())) return
|
|
127
|
+
if (at === null) return
|
|
128
|
+
rewriteValueLiteral(rawValue, spec.literal, spec.replacement, valueHandlers(at, info))
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
if (node.type === 'atrule' && spec.mode === 'rename') {
|
|
132
|
+
const start = offsetOf(node.source?.start)
|
|
133
|
+
const info = { property: `@${node.name}`, scheme: 'css' }
|
|
134
|
+
// Less `@var: value;` is an at-rule with `variable: true`.
|
|
135
|
+
const text = node.variable ? String(node.value ?? node.params ?? '') : node.raws?.params?.raw ?? node.params ?? ''
|
|
136
|
+
if (!text) return
|
|
137
|
+
const guess =
|
|
138
|
+
start === null || node.variable ? null : start + 1 + node.name.length + (node.raws?.afterName?.length ?? 0)
|
|
139
|
+
const at = locate(node, text, guess)
|
|
140
|
+
if (at === null) {
|
|
141
|
+
if ([...spec.renames.keys()].some((name) => text.includes(name))) {
|
|
142
|
+
result.leftover(start ?? 0, 'could-not-locate', text, info)
|
|
143
|
+
}
|
|
144
|
+
return
|
|
145
|
+
}
|
|
146
|
+
if (node.name === 'apply') {
|
|
147
|
+
rewriteClassList(text, spec, valueHandlers(at, { ...info, scheme: 'tailwind' }))
|
|
148
|
+
return
|
|
149
|
+
}
|
|
150
|
+
rewriteValueVars(text, spec.renames, valueHandlers(at, info))
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
return finishFileResult(result)
|
|
154
|
+
}
|