nudge-ui 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -0
- package/bin/nudge-ui.mjs +7 -0
- package/dist/LICENSE +21 -0
- package/dist/client.mjs +261 -0
- package/dist/compiler/ast.d.ts +18 -0
- package/dist/compiler/ast.js +75 -0
- package/dist/compiler/componentContractTypes.d.ts +19 -0
- package/dist/compiler/componentContractTypes.js +1 -0
- package/dist/compiler/componentContracts.d.ts +2 -0
- package/dist/compiler/componentContracts.js +260 -0
- package/dist/compiler/componentInstrumentation.d.ts +32 -0
- package/dist/compiler/componentInstrumentation.js +140 -0
- package/dist/compiler/componentPolicyResolution.d.ts +71 -0
- package/dist/compiler/componentPolicyResolution.js +388 -0
- package/dist/compiler/index.d.ts +9 -0
- package/dist/compiler/index.js +9 -0
- package/dist/compiler/packageComponentContracts.d.ts +32 -0
- package/dist/compiler/packageComponentContracts.js +308 -0
- package/dist/compiler/reactComponentProtocols.d.ts +145 -0
- package/dist/compiler/reactComponentProtocols.js +47 -0
- package/dist/compiler/reactIdentity.d.ts +15 -0
- package/dist/compiler/reactIdentity.js +339 -0
- package/dist/compiler/sourcePaths.d.ts +12 -0
- package/dist/compiler/sourcePaths.js +27 -0
- package/dist/css/dialects/index.d.ts +62 -0
- package/dist/css/dialects/index.js +103 -0
- package/dist/css/dialects/tailwind.d.ts +46 -0
- package/dist/css/dialects/tailwind.js +119 -0
- package/dist/css/dialects/vanillaExtract.d.ts +20 -0
- package/dist/css/dialects/vanillaExtract.js +32 -0
- package/dist/css/index.d.ts +10 -0
- package/dist/css/index.js +10 -0
- package/dist/css/model/index.d.ts +190 -0
- package/dist/css/model/index.js +10 -0
- package/dist/css/token-inventory/index.d.ts +26 -0
- package/dist/css/token-inventory/index.js +24 -0
- package/dist/css/token-inventory/inventory.d.ts +8 -0
- package/dist/css/token-inventory/inventory.js +421 -0
- package/dist/css/token-inventory/parseStylesheet.d.ts +16 -0
- package/dist/css/token-inventory/parseStylesheet.js +155 -0
- package/dist/css/token-inventory/policy.d.ts +47 -0
- package/dist/css/token-inventory/policy.js +50 -0
- package/dist/css/token-inventory/types.d.ts +97 -0
- package/dist/css/token-inventory/types.js +1 -0
- package/dist/css/value-semantics/borderSemantics.d.ts +28 -0
- package/dist/css/value-semantics/borderSemantics.js +91 -0
- package/dist/css/value-semantics/boxSemantics.d.ts +37 -0
- package/dist/css/value-semantics/boxSemantics.js +71 -0
- package/dist/css/value-semantics/colorSemantics.d.ts +99 -0
- package/dist/css/value-semantics/colorSemantics.js +526 -0
- package/dist/css/value-semantics/cssSyntax.d.ts +19 -0
- package/dist/css/value-semantics/cssSyntax.js +111 -0
- package/dist/css/value-semantics/fontSemantics.d.ts +35 -0
- package/dist/css/value-semantics/fontSemantics.js +131 -0
- package/dist/css/value-semantics/index.d.ts +20 -0
- package/dist/css/value-semantics/index.js +15 -0
- package/dist/css/value-semantics/propertyPolicy.d.ts +118 -0
- package/dist/css/value-semantics/propertyPolicy.js +356 -0
- package/dist/css/value-semantics/stringMaps.d.ts +2 -0
- package/dist/css/value-semantics/stringMaps.js +1 -0
- package/dist/css/value-semantics/structuredValues.d.ts +64 -0
- package/dist/css/value-semantics/structuredValues.js +250 -0
- package/dist/css/value-semantics/tokenInterpretation.d.ts +90 -0
- package/dist/css/value-semantics/tokenInterpretation.js +193 -0
- package/dist/css/virtual-design-tokens.d.ts +17 -0
- package/dist/hosts/astro/astroRuntimeConfig.d.ts +12 -0
- package/dist/hosts/astro/astroRuntimeConfig.js +26 -0
- package/dist/hosts/astro/clientAsset.d.ts +12 -0
- package/dist/hosts/astro/clientAsset.js +51 -0
- package/dist/hosts/astro/clientTransport.d.ts +3 -0
- package/dist/hosts/astro/clientTransport.js +57 -0
- package/dist/hosts/astro/index.d.ts +3 -0
- package/dist/hosts/astro/index.js +2 -0
- package/dist/hosts/astro/integration.d.ts +35 -0
- package/dist/hosts/astro/integration.js +96 -0
- package/dist/hosts/astro/middleware.d.ts +13 -0
- package/dist/hosts/astro/middleware.js +22 -0
- package/dist/hosts/astro/projectContext.d.ts +11 -0
- package/dist/hosts/astro/projectContext.js +34 -0
- package/dist/hosts/astro/responseInstrumentation.d.ts +41 -0
- package/dist/hosts/astro/responseInstrumentation.js +80 -0
- package/dist/hosts/next/index.d.ts +4 -0
- package/dist/hosts/next/index.js +7 -0
- package/dist/hosts/next/loader.d.ts +66 -0
- package/dist/hosts/next/loader.js +346 -0
- package/dist/hosts/next/loaders/identity-loader.cjs +228257 -0
- package/dist/hosts/next/loaders/loader-plugin.cjs +228257 -0
- package/dist/hosts/next/manifest.d.ts +38 -0
- package/dist/hosts/next/manifest.js +30 -0
- package/dist/hosts/next/mount.d.ts +12 -0
- package/dist/hosts/next/mount.js +23 -0
- package/dist/hosts/next/repositoryScope.d.ts +20 -0
- package/dist/hosts/next/repositoryScope.js +33 -0
- package/dist/hosts/next/sidecar.d.ts +27 -0
- package/dist/hosts/next/sidecar.js +526 -0
- package/dist/hosts/next/wrapper.d.ts +67 -0
- package/dist/hosts/next/wrapper.js +310 -0
- package/dist/hosts/static/cli.d.ts +12 -0
- package/dist/hosts/static/cli.js +77 -0
- package/dist/hosts/static/html/bootstrap.d.ts +27 -0
- package/dist/hosts/static/html/bootstrap.js +93 -0
- package/dist/hosts/static/index.d.ts +4 -0
- package/dist/hosts/static/index.js +4 -0
- package/dist/hosts/static/manifest.d.ts +18 -0
- package/dist/hosts/static/manifest.js +51 -0
- package/dist/hosts/static/server.d.ts +72 -0
- package/dist/hosts/static/server.js +554 -0
- package/dist/hosts/vite/index.d.ts +20 -0
- package/dist/hosts/vite/index.js +48 -0
- package/dist/hosts/vite/react.d.ts +67 -0
- package/dist/hosts/vite/react.js +231 -0
- package/dist/hosts/vite/tokens/activeStylesheets.d.ts +28 -0
- package/dist/hosts/vite/tokens/activeStylesheets.js +70 -0
- package/dist/hosts/vite/tokens/fileMap.d.ts +2 -0
- package/dist/hosts/vite/tokens/fileMap.js +1 -0
- package/dist/hosts/vite/tokens/viteStylesheetArtifacts.d.ts +46 -0
- package/dist/hosts/vite/tokens/viteStylesheetArtifacts.js +104 -0
- package/dist/hosts/vite/virtual/design-tokens.d.ts +9 -0
- package/dist/hosts/vite/virtual/design-tokens.js +7 -0
- package/dist/hosts/vite/virtual-design-tokens.d.ts +1 -0
- package/dist/hosts/vite/vite.d.ts +62 -0
- package/dist/hosts/vite/vite.js +854 -0
- package/dist/html/dom.d.ts +13 -0
- package/dist/html/dom.js +46 -0
- package/dist/html/identity.d.ts +40 -0
- package/dist/html/identity.js +196 -0
- package/dist/html/insertions.d.ts +26 -0
- package/dist/html/insertions.js +59 -0
- package/dist/inspector/agent/McpConnectionDialog.d.ts +26 -0
- package/dist/inspector/agent/McpConnectionDialog.js +135 -0
- package/dist/inspector/agent/client.d.ts +98 -0
- package/dist/inspector/agent/client.js +728 -0
- package/dist/inspector/agent/connectionStatus.d.ts +13 -0
- package/dist/inspector/agent/connectionStatus.js +35 -0
- package/dist/inspector/agent/httpTransport.d.ts +21 -0
- package/dist/inspector/agent/httpTransport.js +347 -0
- package/dist/inspector/agent/protocol.d.ts +95 -0
- package/dist/inspector/agent/protocol.js +9 -0
- package/dist/inspector/agent/verification.d.ts +39 -0
- package/dist/inspector/agent/verification.js +207 -0
- package/dist/inspector/canvas/CanvasCard.d.ts +10 -0
- package/dist/inspector/canvas/CanvasCard.js +275 -0
- package/dist/inspector/canvas/CanvasElementOverlay.d.ts +2 -0
- package/dist/inspector/canvas/CanvasElementOverlay.js +301 -0
- package/dist/inspector/canvas/CanvasWorkspace.d.ts +2 -0
- package/dist/inspector/canvas/CanvasWorkspace.js +301 -0
- package/dist/inspector/canvas/LockedWorkspaceNotice.d.ts +6 -0
- package/dist/inspector/canvas/LockedWorkspaceNotice.js +17 -0
- package/dist/inspector/canvas/StaleChangeIndicator.d.ts +7 -0
- package/dist/inspector/canvas/StaleChangeIndicator.js +43 -0
- package/dist/inspector/canvas/agentPresentation.d.ts +87 -0
- package/dist/inspector/canvas/agentPresentation.js +421 -0
- package/dist/inspector/canvas/canvasGestures.d.ts +12 -0
- package/dist/inspector/canvas/canvasGestures.js +21 -0
- package/dist/inspector/canvas/canvasStore.d.ts +108 -0
- package/dist/inspector/canvas/canvasStore.js +448 -0
- package/dist/inspector/canvas/frameProtocol.d.ts +231 -0
- package/dist/inspector/canvas/frameProtocol.js +165 -0
- package/dist/inspector/canvas/linkEligibility.d.ts +8 -0
- package/dist/inspector/canvas/linkEligibility.js +68 -0
- package/dist/inspector/canvas/measurementProjection.d.ts +8 -0
- package/dist/inspector/canvas/measurementProjection.js +16 -0
- package/dist/inspector/canvas/normalizeUrl.d.ts +7 -0
- package/dist/inspector/canvas/normalizeUrl.js +27 -0
- package/dist/inspector/canvas/projection.d.ts +41 -0
- package/dist/inspector/canvas/projection.js +232 -0
- package/dist/inspector/canvas/rendererBootstrap.d.ts +4 -0
- package/dist/inspector/canvas/rendererBootstrap.js +410 -0
- package/dist/inspector/canvas/rendererCidIndex.d.ts +11 -0
- package/dist/inspector/canvas/rendererCidIndex.js +21 -0
- package/dist/inspector/canvas/rendererElementSelector.d.ts +2 -0
- package/dist/inspector/canvas/rendererElementSelector.js +378 -0
- package/dist/inspector/canvas/rendererSelectionProxy.d.ts +2 -0
- package/dist/inspector/canvas/rendererSelectionProxy.js +61 -0
- package/dist/inspector/canvas/rendererStylesheet.d.ts +16 -0
- package/dist/inspector/canvas/rendererStylesheet.js +221 -0
- package/dist/inspector/canvas/resizeHandleScale.d.ts +13 -0
- package/dist/inspector/canvas/resizeHandleScale.js +20 -0
- package/dist/inspector/canvas/roleDetection.d.ts +5 -0
- package/dist/inspector/canvas/roleDetection.js +21 -0
- package/dist/inspector/canvas/sessionStore.d.ts +71 -0
- package/dist/inspector/canvas/sessionStore.js +453 -0
- package/dist/inspector/canvas/staleChangeDetector.d.ts +11 -0
- package/dist/inspector/canvas/staleChangeDetector.js +217 -0
- package/dist/inspector/canvas/toolbarScale.d.ts +7 -0
- package/dist/inspector/canvas/toolbarScale.js +11 -0
- package/dist/inspector/canvas/workspaceLease.d.ts +26 -0
- package/dist/inspector/canvas/workspaceLease.js +214 -0
- package/dist/inspector/changes/changesLog.d.ts +46 -0
- package/dist/inspector/changes/changesLog.js +209 -0
- package/dist/inspector/changes/codecs.d.ts +98 -0
- package/dist/inspector/changes/codecs.js +389 -0
- package/dist/inspector/changes/editModel.d.ts +74 -0
- package/dist/inspector/changes/editModel.js +120 -0
- package/dist/inspector/changes/managedStyleProjection.d.ts +6 -0
- package/dist/inspector/changes/managedStyleProjection.js +109 -0
- package/dist/inspector/changes/model.d.ts +13 -0
- package/dist/inspector/changes/model.js +163 -0
- package/dist/inspector/changes/presentation.d.ts +14 -0
- package/dist/inspector/changes/presentation.js +81 -0
- package/dist/inspector/changes/previewDiagnostics.d.ts +39 -0
- package/dist/inspector/changes/previewDiagnostics.js +172 -0
- package/dist/inspector/changes/structuralTypes.d.ts +35 -0
- package/dist/inspector/changes/structuralTypes.js +1 -0
- package/dist/inspector/changes/types.d.ts +76 -0
- package/dist/inspector/changes/types.js +16 -0
- package/dist/inspector/changes/workspaceChanges.d.ts +43 -0
- package/dist/inspector/changes/workspaceChanges.js +239 -0
- package/dist/inspector/clientManifest.d.ts +24 -0
- package/dist/inspector/clientManifest.js +69 -0
- package/dist/inspector/componentSemantics/ComponentPropsSection.d.ts +5 -0
- package/dist/inspector/componentSemantics/ComponentPropsSection.js +44 -0
- package/dist/inspector/componentSemantics/adapterRegistry.d.ts +11 -0
- package/dist/inspector/componentSemantics/adapterRegistry.js +75 -0
- package/dist/inspector/componentSemantics/boundaries.d.ts +2 -0
- package/dist/inspector/componentSemantics/boundaries.js +10 -0
- package/dist/inspector/componentSemantics/changeAction.d.ts +3 -0
- package/dist/inspector/componentSemantics/changeAction.js +6 -0
- package/dist/inspector/componentSemantics/changeModel.d.ts +8 -0
- package/dist/inspector/componentSemantics/changeModel.js +60 -0
- package/dist/inspector/componentSemantics/index.d.ts +4 -0
- package/dist/inspector/componentSemantics/index.js +2 -0
- package/dist/inspector/componentSemantics/reactRuntime.d.ts +10 -0
- package/dist/inspector/componentSemantics/reactRuntime.js +186 -0
- package/dist/inspector/componentSemantics/runtimeBridge.d.ts +25 -0
- package/dist/inspector/componentSemantics/runtimeBridge.js +161 -0
- package/dist/inspector/componentSemantics/runtimeTypes.d.ts +2 -0
- package/dist/inspector/componentSemantics/runtimeTypes.js +1 -0
- package/dist/inspector/componentSemantics/textBinding.d.ts +69 -0
- package/dist/inspector/componentSemantics/textBinding.js +514 -0
- package/dist/inspector/componentSemantics/types.d.ts +96 -0
- package/dist/inspector/componentSemantics/types.js +5 -0
- package/dist/inspector/conformance/borderCases.d.ts +7 -0
- package/dist/inspector/conformance/borderCases.js +428 -0
- package/dist/inspector/conformance/colorCases.d.ts +8 -0
- package/dist/inspector/conformance/colorCases.js +470 -0
- package/dist/inspector/conformance/fixture.d.ts +68 -0
- package/dist/inspector/conformance/fixture.js +153 -0
- package/dist/inspector/conformance/projection.d.ts +2 -0
- package/dist/inspector/conformance/projection.js +3 -0
- package/dist/inspector/conformance/spacingCases.d.ts +6 -0
- package/dist/inspector/conformance/spacingCases.js +417 -0
- package/dist/inspector/conformance/typographyCases.d.ts +7 -0
- package/dist/inspector/conformance/typographyCases.js +174 -0
- package/dist/inspector/editScope.d.ts +4 -0
- package/dist/inspector/editScope.js +5 -0
- package/dist/inspector/index.d.ts +20 -0
- package/dist/inspector/index.js +236 -0
- package/dist/inspector/inline-text/inlineTextEditor.d.ts +74 -0
- package/dist/inspector/inline-text/inlineTextEditor.js +1207 -0
- package/dist/inspector/inline-text/inlineTextLifecycle.d.ts +2 -0
- package/dist/inspector/inline-text/inlineTextLifecycle.js +17 -0
- package/dist/inspector/inline-text/textChangeBoundary.d.ts +6 -0
- package/dist/inspector/inline-text/textChangeBoundary.js +1 -0
- package/dist/inspector/inspection/bridge.d.ts +72 -0
- package/dist/inspector/inspection/bridge.js +134 -0
- package/dist/inspector/inspection/browserCssInspection.d.ts +74 -0
- package/dist/inspector/inspection/browserCssInspection.js +317 -0
- package/dist/inspector/inspection/browserCssInspectionRegistry.d.ts +12 -0
- package/dist/inspector/inspection/browserCssInspectionRegistry.js +66 -0
- package/dist/inspector/inspection/selectionProperty.d.ts +32 -0
- package/dist/inspector/inspection/selectionProperty.js +33 -0
- package/dist/inspector/inspection/useBrowserCssInspection.d.ts +20 -0
- package/dist/inspector/inspection/useBrowserCssInspection.js +159 -0
- package/dist/inspector/overlay/DropGuideOverlay.d.ts +17 -0
- package/dist/inspector/overlay/DropGuideOverlay.js +17 -0
- package/dist/inspector/overlay/InspectorOverlay.d.ts +5 -0
- package/dist/inspector/overlay/InspectorOverlay.js +328 -0
- package/dist/inspector/overlay/MeasurementGuideOverlay.d.ts +19 -0
- package/dist/inspector/overlay/MeasurementGuideOverlay.js +40 -0
- package/dist/inspector/overlay/clickPolicy.d.ts +7 -0
- package/dist/inspector/overlay/clickPolicy.js +13 -0
- package/dist/inspector/overlay/dropGuide.d.ts +22 -0
- package/dist/inspector/overlay/dropGuide.js +48 -0
- package/dist/inspector/overlay/elementSelector.d.ts +1 -0
- package/dist/inspector/overlay/elementSelector.js +100 -0
- package/dist/inspector/overlay/frameThrottle.d.ts +10 -0
- package/dist/inspector/overlay/frameThrottle.js +38 -0
- package/dist/inspector/overlay/interactionStyles.d.ts +3 -0
- package/dist/inspector/overlay/interactionStyles.js +70 -0
- package/dist/inspector/overlay/measurementGeometry.d.ts +25 -0
- package/dist/inspector/overlay/measurementGeometry.js +104 -0
- package/dist/inspector/overlay/overlayGeometry.d.ts +40 -0
- package/dist/inspector/overlay/overlayGeometry.js +59 -0
- package/dist/inspector/overlay/selectedGeometry.d.ts +7 -0
- package/dist/inspector/overlay/selectedGeometry.js +51 -0
- package/dist/inspector/overlay/structuralGestures.d.ts +28 -0
- package/dist/inspector/overlay/structuralGestures.js +180 -0
- package/dist/inspector/projection/cssEscapes.d.ts +3 -0
- package/dist/inspector/projection/cssEscapes.js +20 -0
- package/dist/inspector/projection/managedStylesheet.d.ts +33 -0
- package/dist/inspector/projection/managedStylesheet.js +240 -0
- package/dist/inspector/projection/renderedInstance.d.ts +56 -0
- package/dist/inspector/projection/renderedInstance.js +306 -0
- package/dist/inspector/projection/structuralProjection.d.ts +93 -0
- package/dist/inspector/projection/structuralProjection.js +560 -0
- package/dist/inspector/projection/structuralProjectionBoundary.d.ts +5 -0
- package/dist/inspector/projection/structuralProjectionBoundary.js +65 -0
- package/dist/inspector/projection/textProjection.d.ts +53 -0
- package/dist/inspector/projection/textProjection.js +705 -0
- package/dist/inspector/projection/workspaceProjection.d.ts +43 -0
- package/dist/inspector/projection/workspaceProjection.js +58 -0
- package/dist/inspector/prompt/PromptSettingsDialog.d.ts +15 -0
- package/dist/inspector/prompt/PromptSettingsDialog.js +17 -0
- package/dist/inspector/prompt/clipboardHandoff.d.ts +34 -0
- package/dist/inspector/prompt/clipboardHandoff.js +212 -0
- package/dist/inspector/prompt/copyToClipboard.d.ts +1 -0
- package/dist/inspector/prompt/copyToClipboard.js +34 -0
- package/dist/inspector/prompt/detectFramework.d.ts +6 -0
- package/dist/inspector/prompt/detectFramework.js +4 -0
- package/dist/inspector/prompt/generatePrompt.d.ts +7 -0
- package/dist/inspector/prompt/generatePrompt.js +391 -0
- package/dist/inspector/prompt/promptSettings.d.ts +8 -0
- package/dist/inspector/prompt/promptSettings.js +28 -0
- package/dist/inspector/runtime/devFlag.d.ts +28 -0
- package/dist/inspector/runtime/devFlag.js +50 -0
- package/dist/inspector/runtime/documentStylesheetOrder.d.ts +19 -0
- package/dist/inspector/runtime/documentStylesheetOrder.js +89 -0
- package/dist/inspector/runtime/domRealm.d.ts +4 -0
- package/dist/inspector/runtime/domRealm.js +11 -0
- package/dist/inspector/runtime/runtimeConfig.d.ts +119 -0
- package/dist/inspector/runtime/runtimeConfig.js +276 -0
- package/dist/inspector/runtime/staticHtmlRuntimeIdentity.d.ts +32 -0
- package/dist/inspector/runtime/staticHtmlRuntimeIdentity.js +149 -0
- package/dist/inspector/runtime/useRuntimeConfig.d.ts +10 -0
- package/dist/inspector/runtime/useRuntimeConfig.js +13 -0
- package/dist/inspector/selection/editScope.d.ts +32 -0
- package/dist/inspector/selection/editScope.js +140 -0
- package/dist/inspector/selection/editTarget.d.ts +8 -0
- package/dist/inspector/selection/editTarget.js +11 -0
- package/dist/inspector/selection/hierarchy.d.ts +7 -0
- package/dist/inspector/selection/hierarchy.js +42 -0
- package/dist/inspector/selection/resolveSelection.d.ts +10 -0
- package/dist/inspector/selection/resolveSelection.js +60 -0
- package/dist/inspector/selection/selectionStore.d.ts +41 -0
- package/dist/inspector/selection/selectionStore.js +262 -0
- package/dist/inspector/selection/selectionTarget.d.ts +5 -0
- package/dist/inspector/selection/selectionTarget.js +50 -0
- package/dist/inspector/selection/sourceSite.d.ts +2 -0
- package/dist/inspector/selection/sourceSite.js +12 -0
- package/dist/inspector/selection/styleSelection.d.ts +22 -0
- package/dist/inspector/selection/styleSelection.js +104 -0
- package/dist/inspector/session/index.d.ts +3 -0
- package/dist/inspector/session/index.js +2 -0
- package/dist/inspector/session/lifecycle.d.ts +22 -0
- package/dist/inspector/session/lifecycle.js +63 -0
- package/dist/inspector/session/sessionContext.d.ts +21 -0
- package/dist/inspector/session/sessionContext.js +28 -0
- package/dist/inspector/session/sessionFactory.d.ts +29 -0
- package/dist/inspector/session/sessionFactory.js +73 -0
- package/dist/inspector/settings/SettingsDialog.d.ts +12 -0
- package/dist/inspector/settings/SettingsDialog.js +46 -0
- package/dist/inspector/shell/AppShell.d.ts +2 -0
- package/dist/inspector/shell/AppShell.js +9 -0
- package/dist/inspector/shell/ChangesLog.d.ts +6 -0
- package/dist/inspector/shell/ChangesLog.js +92 -0
- package/dist/inspector/shell/CopyPromptButton.d.ts +9 -0
- package/dist/inspector/shell/CopyPromptButton.js +159 -0
- package/dist/inspector/shell/DomNavigation.d.ts +8 -0
- package/dist/inspector/shell/DomNavigation.js +30 -0
- package/dist/inspector/shell/EmptyState.d.ts +2 -0
- package/dist/inspector/shell/EmptyState.js +15 -0
- package/dist/inspector/shell/InspectorShell.d.ts +11 -0
- package/dist/inspector/shell/InspectorShell.js +268 -0
- package/dist/inspector/shell/openStore.d.ts +6 -0
- package/dist/inspector/shell/openStore.js +29 -0
- package/dist/inspector/shell/panelLayout.d.ts +2 -0
- package/dist/inspector/shell/panelLayout.js +29 -0
- package/dist/inspector/shell/shortcuts.d.ts +3 -0
- package/dist/inspector/shell/shortcuts.js +25 -0
- package/dist/inspector/shell/stateValue.d.ts +3 -0
- package/dist/inspector/shell/stateValue.js +34 -0
- package/dist/inspector/shell/styleState.d.ts +7 -0
- package/dist/inspector/shell/styleState.js +13 -0
- package/dist/inspector/spacing/projection.d.ts +43 -0
- package/dist/inspector/spacing/projection.js +136 -0
- package/dist/inspector/styleEditors/AppearanceSection.d.ts +13 -0
- package/dist/inspector/styleEditors/AppearanceSection.js +6 -0
- package/dist/inspector/styleEditors/AspectRatioField.d.ts +17 -0
- package/dist/inspector/styleEditors/AspectRatioField.js +10 -0
- package/dist/inspector/styleEditors/BorderEditor.d.ts +13 -0
- package/dist/inspector/styleEditors/BorderEditor.js +295 -0
- package/dist/inspector/styleEditors/BorderRadiusEditor.d.ts +14 -0
- package/dist/inspector/styleEditors/BorderRadiusEditor.js +108 -0
- package/dist/inspector/styleEditors/BoxShadowEditor.d.ts +13 -0
- package/dist/inspector/styleEditors/BoxShadowEditor.js +13 -0
- package/dist/inspector/styleEditors/ColorPicker.d.ts +15 -0
- package/dist/inspector/styleEditors/ColorPicker.js +73 -0
- package/dist/inspector/styleEditors/GapField.d.ts +17 -0
- package/dist/inspector/styleEditors/GapField.js +12 -0
- package/dist/inspector/styleEditors/GridChildSection.d.ts +14 -0
- package/dist/inspector/styleEditors/GridChildSection.js +91 -0
- package/dist/inspector/styleEditors/GridPicker.d.ts +13 -0
- package/dist/inspector/styleEditors/GridPicker.js +179 -0
- package/dist/inspector/styleEditors/GridSection.d.ts +17 -0
- package/dist/inspector/styleEditors/GridSection.js +27 -0
- package/dist/inspector/styleEditors/GridValueField.d.ts +17 -0
- package/dist/inspector/styleEditors/GridValueField.js +70 -0
- package/dist/inspector/styleEditors/InsetSection.d.ts +15 -0
- package/dist/inspector/styleEditors/InsetSection.js +15 -0
- package/dist/inspector/styleEditors/LayoutBlockedIndicator.d.ts +6 -0
- package/dist/inspector/styleEditors/LayoutBlockedIndicator.js +6 -0
- package/dist/inspector/styleEditors/LayoutComboField.d.ts +18 -0
- package/dist/inspector/styleEditors/LayoutComboField.js +138 -0
- package/dist/inspector/styleEditors/LayoutDropdown.d.ts +14 -0
- package/dist/inspector/styleEditors/LayoutDropdown.js +34 -0
- package/dist/inspector/styleEditors/LayoutSection.d.ts +13 -0
- package/dist/inspector/styleEditors/LayoutSection.js +342 -0
- package/dist/inspector/styleEditors/OpacityEditor.d.ts +13 -0
- package/dist/inspector/styleEditors/OpacityEditor.js +34 -0
- package/dist/inspector/styleEditors/PositionInsets.d.ts +15 -0
- package/dist/inspector/styleEditors/PositionInsets.js +12 -0
- package/dist/inspector/styleEditors/SpacingBox.d.ts +29 -0
- package/dist/inspector/styleEditors/SpacingBox.js +189 -0
- package/dist/inspector/styleEditors/Typography.d.ts +13 -0
- package/dist/inspector/styleEditors/Typography.js +137 -0
- package/dist/inspector/styleEditors/completeCssValue.d.ts +8 -0
- package/dist/inspector/styleEditors/completeCssValue.js +34 -0
- package/dist/inspector/styleEditors/gridChildModel.d.ts +74 -0
- package/dist/inspector/styleEditors/gridChildModel.js +138 -0
- package/dist/inspector/styleEditors/layoutValue.d.ts +24 -0
- package/dist/inspector/styleEditors/layoutValue.js +103 -0
- package/dist/inspector/styleEditors/nudgeValue.d.ts +8 -0
- package/dist/inspector/styleEditors/nudgeValue.js +71 -0
- package/dist/inspector/styleEditors/rowLookup.d.ts +11 -0
- package/dist/inspector/styleEditors/rowLookup.js +13 -0
- package/dist/inspector/styleEditors/stringRecord.d.ts +4 -0
- package/dist/inspector/styleEditors/stringRecord.js +1 -0
- package/dist/inspector/styleEditors/valuePolicy.d.ts +20 -0
- package/dist/inspector/styleEditors/valuePolicy.js +82 -0
- package/dist/inspector/testing.d.ts +10 -0
- package/dist/inspector/testing.js +9 -0
- package/dist/inspector/tokens/TokenChip.d.ts +24 -0
- package/dist/inspector/tokens/TokenChip.js +23 -0
- package/dist/inspector/tokens/TokenDropdown.d.ts +13 -0
- package/dist/inspector/tokens/TokenDropdown.js +59 -0
- package/dist/inspector/tokens/TokenField.d.ts +68 -0
- package/dist/inspector/tokens/TokenField.js +485 -0
- package/dist/inspector/tokens/TokenLabel.d.ts +7 -0
- package/dist/inspector/tokens/TokenLabel.js +23 -0
- package/dist/inspector/tokens/TokensPanel.d.ts +5 -0
- package/dist/inspector/tokens/TokensPanel.js +47 -0
- package/dist/inspector/tokens/catalog.d.ts +51 -0
- package/dist/inspector/tokens/catalog.js +184 -0
- package/dist/inspector/tokens/editActions.d.ts +35 -0
- package/dist/inspector/tokens/editActions.js +164 -0
- package/dist/inspector/tokens/resolution/cascade.d.ts +14 -0
- package/dist/inspector/tokens/resolution/cascade.js +31 -0
- package/dist/inspector/tokens/resolution/cssomCollector.d.ts +43 -0
- package/dist/inspector/tokens/resolution/cssomCollector.js +528 -0
- package/dist/inspector/tokens/resolution/selectorSemantics.d.ts +12 -0
- package/dist/inspector/tokens/resolution/selectorSemantics.js +106 -0
- package/dist/inspector/tokens/resolution.d.ts +56 -0
- package/dist/inspector/tokens/resolution.js +1401 -0
- package/dist/inspector/tokens/tokenEdits.d.ts +3 -0
- package/dist/inspector/tokens/tokenEdits.js +22 -0
- package/dist/inspector/tokens/valueSemanticsAdapter.d.ts +6 -0
- package/dist/inspector/tokens/valueSemanticsAdapter.js +68 -0
- package/dist/inspector/ui/AtRuleContext.d.ts +18 -0
- package/dist/inspector/ui/AtRuleContext.js +54 -0
- package/dist/inspector/ui/Button.d.ts +9 -0
- package/dist/inspector/ui/Button.js +4 -0
- package/dist/inspector/ui/ColorSwatch.d.ts +7 -0
- package/dist/inspector/ui/ColorSwatch.js +6 -0
- package/dist/inspector/ui/ControlSurface.d.ts +14 -0
- package/dist/inspector/ui/ControlSurface.js +10 -0
- package/dist/inspector/ui/FieldRow.d.ts +14 -0
- package/dist/inspector/ui/FieldRow.js +15 -0
- package/dist/inspector/ui/IconButton.d.ts +14 -0
- package/dist/inspector/ui/IconButton.js +5 -0
- package/dist/inspector/ui/InspectorPopover.d.ts +17 -0
- package/dist/inspector/ui/InspectorPopover.js +13 -0
- package/dist/inspector/ui/PopoverListbox.d.ts +37 -0
- package/dist/inspector/ui/PopoverListbox.js +21 -0
- package/dist/inspector/ui/SegmentedControl.d.ts +24 -0
- package/dist/inspector/ui/SegmentedControl.js +16 -0
- package/dist/inspector/ui/Select.d.ts +25 -0
- package/dist/inspector/ui/Select.js +56 -0
- package/dist/inspector/ui/SideValuesField.d.ts +44 -0
- package/dist/inspector/ui/SideValuesField.js +76 -0
- package/dist/inspector/ui/StatusCallout.d.ts +9 -0
- package/dist/inspector/ui/StatusCallout.js +4 -0
- package/dist/inspector/ui/TextInput.d.ts +12 -0
- package/dist/inspector/ui/TextInput.js +5 -0
- package/dist/inspector/ui/ToggleButton.d.ts +11 -0
- package/dist/inspector/ui/ToggleButton.js +6 -0
- package/dist/inspector/ui/assets/grid.svg +14 -0
- package/dist/inspector/ui/css.d.ts +9 -0
- package/dist/inspector/ui/labels.d.ts +1 -0
- package/dist/inspector/ui/labels.js +7 -0
- package/dist/inspector/ui/styles.d.ts +1 -0
- package/dist/inspector/ui/styles.js +68 -0
- package/dist/inspector/virtual-modules.d.ts +7 -0
- package/dist/inspector/vite-env.d.ts +10 -0
- package/dist/internal/agent-protocol.d.ts +232 -0
- package/dist/internal/agent-protocol.js +237 -0
- package/dist/nudge-ui.mjs +15722 -0
- package/dist/project/files.d.ts +19 -0
- package/dist/project/files.js +226 -0
- package/dist/project/identity.d.ts +6 -0
- package/dist/project/identity.js +19 -0
- package/dist/project/pathPolicy.d.ts +8 -0
- package/dist/project/pathPolicy.js +12 -0
- package/dist/project/tokens.d.ts +36 -0
- package/dist/project/tokens.js +223 -0
- package/dist/transport/index.d.ts +8 -0
- package/dist/transport/index.js +8 -0
- package/dist/transport/routes.d.ts +13 -0
- package/dist/transport/routes.js +16 -0
- package/package.json +137 -0
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
import { parseStylesheetArtifact } from "./parseStylesheet.js";
|
|
2
|
+
function artifactKey(value) {
|
|
3
|
+
return `${value.buildTool}\u0000${value.id}`;
|
|
4
|
+
}
|
|
5
|
+
function effectiveObservation(entry) {
|
|
6
|
+
return entry.transformFailed ? entry.authored : (entry.transformed ?? entry.authored);
|
|
7
|
+
}
|
|
8
|
+
function effectiveOrder(entry) {
|
|
9
|
+
return effectiveObservation(entry)?.artifact.order ?? entry.authored?.artifact.order;
|
|
10
|
+
}
|
|
11
|
+
function effectiveDiscoveryOrder(entry) {
|
|
12
|
+
return effectiveObservation(entry)?.artifact.discoveryOrder
|
|
13
|
+
?? entry.authored?.artifact.discoveryOrder;
|
|
14
|
+
}
|
|
15
|
+
function compareArtifacts(a, b) {
|
|
16
|
+
const aOrder = effectiveOrder(a);
|
|
17
|
+
const bOrder = effectiveOrder(b);
|
|
18
|
+
const aHasOrder = aOrder !== undefined;
|
|
19
|
+
const bHasOrder = bOrder !== undefined;
|
|
20
|
+
if (aHasOrder !== bHasOrder)
|
|
21
|
+
return aHasOrder ? -1 : 1;
|
|
22
|
+
if (aOrder !== undefined && bOrder !== undefined && aOrder !== bOrder) {
|
|
23
|
+
return aOrder - bOrder;
|
|
24
|
+
}
|
|
25
|
+
const discovery = (effectiveDiscoveryOrder(a) ?? Infinity)
|
|
26
|
+
- (effectiveDiscoveryOrder(b) ?? Infinity);
|
|
27
|
+
return discovery || artifactKey(a).localeCompare(artifactKey(b));
|
|
28
|
+
}
|
|
29
|
+
function compareContributions(a, b) {
|
|
30
|
+
const order = (a.order ?? Infinity) - (b.order ?? Infinity);
|
|
31
|
+
return order || a.id.localeCompare(b.id);
|
|
32
|
+
}
|
|
33
|
+
function copyArtifact(artifact) {
|
|
34
|
+
return {
|
|
35
|
+
...artifact,
|
|
36
|
+
diagnostics: artifact.diagnostics?.map((diagnostic) => ({ ...diagnostic })),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function copyToken(entry) {
|
|
40
|
+
return { ...entry };
|
|
41
|
+
}
|
|
42
|
+
function copyDefinition(definition) {
|
|
43
|
+
return {
|
|
44
|
+
...definition,
|
|
45
|
+
declarations: definition.declarations.map((declaration) => ({
|
|
46
|
+
...declaration,
|
|
47
|
+
context: {
|
|
48
|
+
...declaration.context,
|
|
49
|
+
wrappers: declaration.context.wrappers?.map((wrapper) => ({ ...wrapper })),
|
|
50
|
+
},
|
|
51
|
+
})),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function copyContribution(contribution) {
|
|
55
|
+
return {
|
|
56
|
+
...contribution,
|
|
57
|
+
tokens: contribution.tokens?.map(copyToken),
|
|
58
|
+
definitions: contribution.definitions?.map(copyDefinition),
|
|
59
|
+
relabellings: contribution.relabellings?.map((relabelling) => ({ ...relabelling })),
|
|
60
|
+
diagnostics: contribution.diagnostics?.map((diagnostic) => ({ ...diagnostic })),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function sameObservationFacts(observation, artifact) {
|
|
64
|
+
return JSON.stringify(observation.artifact) === JSON.stringify(artifact);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Scalar-only equality over stylesheet artifacts, used as a cheap pre-parse
|
|
68
|
+
* no-op guard: identical re-feeds (the common HMR case) must not pay for a
|
|
69
|
+
* PostCSS parse. Every field is enumerated so a future artifact field cannot
|
|
70
|
+
* silently bypass the guard; diagnostics are rare and small, so they alone
|
|
71
|
+
* compare by serialization — content strings never do.
|
|
72
|
+
*/
|
|
73
|
+
function sameArtifactScalars(a, b) {
|
|
74
|
+
return a.buildTool === b.buildTool
|
|
75
|
+
&& a.id === b.id
|
|
76
|
+
&& a.stage === b.stage
|
|
77
|
+
&& a.provenance === b.provenance
|
|
78
|
+
&& a.order === b.order
|
|
79
|
+
&& a.discoveryOrder === b.discoveryOrder
|
|
80
|
+
&& a.content === b.content
|
|
81
|
+
&& a.adapter === b.adapter
|
|
82
|
+
&& a.failed === b.failed
|
|
83
|
+
&& ((a.diagnostics === undefined && b.diagnostics === undefined)
|
|
84
|
+
|| (a.diagnostics !== undefined && b.diagnostics !== undefined
|
|
85
|
+
&& JSON.stringify(a.diagnostics) === JSON.stringify(b.diagnostics)));
|
|
86
|
+
}
|
|
87
|
+
function sameContributionFacts(a, b) {
|
|
88
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
89
|
+
}
|
|
90
|
+
function parseObservation(artifact) {
|
|
91
|
+
const storedArtifact = copyArtifact(artifact);
|
|
92
|
+
const parsed = artifact.content === undefined
|
|
93
|
+
? { definitions: [], diagnostics: [] }
|
|
94
|
+
: parseStylesheetArtifact(storedArtifact);
|
|
95
|
+
const adapterDiagnostics = (artifact.diagnostics ?? []).map((diagnostic) => ({ ...diagnostic, artifact: artifact.id }));
|
|
96
|
+
return {
|
|
97
|
+
artifact: storedArtifact,
|
|
98
|
+
contribution: {
|
|
99
|
+
definitions: parsed.definitions,
|
|
100
|
+
diagnostics: [...adapterDiagnostics, ...parsed.diagnostics],
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function orderEvidence(entries) {
|
|
105
|
+
const discoveryEntries = entries.filter((entry) => effectiveOrder(entry) === undefined);
|
|
106
|
+
const explicit = discoveryEntries.flatMap((entry) => {
|
|
107
|
+
const value = effectiveDiscoveryOrder(entry);
|
|
108
|
+
return value === undefined ? [] : [value];
|
|
109
|
+
});
|
|
110
|
+
let next = explicit.length > 0 ? Math.max(...explicit) + 1 : 0;
|
|
111
|
+
const result = new Map();
|
|
112
|
+
for (const entry of entries) {
|
|
113
|
+
const artifact = effectiveObservation(entry)?.artifact;
|
|
114
|
+
if (!artifact)
|
|
115
|
+
continue;
|
|
116
|
+
const order = effectiveOrder(entry);
|
|
117
|
+
result.set(artifactKey(entry), order !== undefined
|
|
118
|
+
? { kind: "stylesheet", index: order }
|
|
119
|
+
: { kind: "discovery", index: effectiveDiscoveryOrder(entry) ?? next++ });
|
|
120
|
+
}
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
/** Preserve an authored declaration id when the transform retains its position. */
|
|
124
|
+
function reconciledDeclarationId(authored, cssName, declaration) {
|
|
125
|
+
const authoredDefinition = authored?.contribution.definitions.find((definition) => definition.cssName === cssName);
|
|
126
|
+
const match = authoredDefinition?.declarations.find((candidate) => candidate.order === declaration.order
|
|
127
|
+
&& candidate.source === declaration.source
|
|
128
|
+
&& JSON.stringify(candidate.context) === JSON.stringify(declaration.context));
|
|
129
|
+
return match?.id ?? declaration.id;
|
|
130
|
+
}
|
|
131
|
+
function reconcileObservations(entry) {
|
|
132
|
+
const authored = entry.authored;
|
|
133
|
+
const facts = effectiveObservation(entry);
|
|
134
|
+
if (!facts)
|
|
135
|
+
return [];
|
|
136
|
+
const authoredNames = new Set(authored?.contribution.definitions.map((definition) => definition.cssName) ?? []);
|
|
137
|
+
return facts.contribution.definitions.map((definition) => {
|
|
138
|
+
const transformOnly = authored !== undefined && !authoredNames.has(definition.cssName);
|
|
139
|
+
// Project compilers own transform-only names, but package ownership is
|
|
140
|
+
// stronger provenance and survives compilation.
|
|
141
|
+
const origin = transformOnly && facts.artifact.provenance !== "package"
|
|
142
|
+
? "generated"
|
|
143
|
+
: facts.artifact.provenance;
|
|
144
|
+
const adapter = facts.artifact.adapter ?? authored?.artifact.adapter;
|
|
145
|
+
const base = {
|
|
146
|
+
...definition,
|
|
147
|
+
origin,
|
|
148
|
+
declarations: definition.declarations.map((declaration) => ({
|
|
149
|
+
...declaration,
|
|
150
|
+
id: facts.artifact.stage === "transformed"
|
|
151
|
+
? reconciledDeclarationId(authored, definition.cssName, declaration)
|
|
152
|
+
: declaration.id,
|
|
153
|
+
})),
|
|
154
|
+
};
|
|
155
|
+
if (origin === "package" || origin === "generated")
|
|
156
|
+
base.editable = false;
|
|
157
|
+
if (adapter && origin !== "package")
|
|
158
|
+
base.adapter = adapter;
|
|
159
|
+
return { definition: base, artifact: facts.artifact };
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function adapterDeclaration(entry, contributionId, contributionOrder, order) {
|
|
163
|
+
const key = entry.cssName ?? entry.name;
|
|
164
|
+
return {
|
|
165
|
+
id: `adapter\x00${contributionId}\x00${key}\x00${entry.source}`,
|
|
166
|
+
order,
|
|
167
|
+
value: entry.value,
|
|
168
|
+
source: entry.source,
|
|
169
|
+
important: false,
|
|
170
|
+
context: {},
|
|
171
|
+
contribution: {
|
|
172
|
+
kind: "adapter",
|
|
173
|
+
id: contributionId,
|
|
174
|
+
provenance: entry.origin,
|
|
175
|
+
editable: entry.editable,
|
|
176
|
+
order: contributionOrder,
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function setLiteralToken(merged, entry, contributionId, contributionOrder, order) {
|
|
181
|
+
const key = entry.cssName ?? entry.name;
|
|
182
|
+
merged.set(key, {
|
|
183
|
+
base: {
|
|
184
|
+
cssName: key,
|
|
185
|
+
name: entry.name,
|
|
186
|
+
cssValue: entry.cssValue,
|
|
187
|
+
adapter: entry.adapter,
|
|
188
|
+
origin: entry.origin,
|
|
189
|
+
editable: entry.editable,
|
|
190
|
+
},
|
|
191
|
+
declarations: [adapterDeclaration(entry, contributionId, contributionOrder, order)],
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/** FNV-1a 32-bit fingerprint. */
|
|
195
|
+
function fnv1a(input) {
|
|
196
|
+
let hash = 0x811c9dc5;
|
|
197
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
198
|
+
hash ^= input.charCodeAt(index);
|
|
199
|
+
hash = Math.imul(hash, 0x01000193) >>> 0;
|
|
200
|
+
}
|
|
201
|
+
return hash.toString(16).padStart(8, "0");
|
|
202
|
+
}
|
|
203
|
+
function canonicalSnapshotFacts(definitions, diagnostics) {
|
|
204
|
+
const parts = [];
|
|
205
|
+
for (const definition of definitions) {
|
|
206
|
+
parts.push(`D\x00${definition.cssName}\x00${definition.name}\x00${definition.origin ?? ""}`
|
|
207
|
+
+ `\x00${String(definition.editable ?? "")}\x00${definition.adapter ?? ""}`
|
|
208
|
+
+ `\x00${definition.cssValue ?? ""}`);
|
|
209
|
+
for (const declaration of definition.declarations) {
|
|
210
|
+
parts.push(`d\x00${declaration.id ?? ""}\x00${declaration.order}`
|
|
211
|
+
+ `\x00${declaration.value}\x00${declaration.source}\x00${String(declaration.important)}`
|
|
212
|
+
+ `\x00${JSON.stringify(declaration.context)}\x00${JSON.stringify(declaration.contribution)}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
for (const diagnostic of diagnostics) {
|
|
216
|
+
parts.push(`X\x00${diagnostic.code}\x00${diagnostic.artifact ?? ""}\x00${diagnostic.module ?? ""}`
|
|
217
|
+
+ `\x00${diagnostic.exportName ?? ""}\x00${diagnostic.message}`);
|
|
218
|
+
}
|
|
219
|
+
return parts.join("\n");
|
|
220
|
+
}
|
|
221
|
+
function deepFreeze(value) {
|
|
222
|
+
if (value === null || typeof value !== "object" || Object.isFrozen(value))
|
|
223
|
+
return value;
|
|
224
|
+
if (Array.isArray(value)) {
|
|
225
|
+
for (const item of value)
|
|
226
|
+
deepFreeze(item);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
for (const item of Object.values(value)) {
|
|
230
|
+
deepFreeze(item);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return Object.freeze(value);
|
|
234
|
+
}
|
|
235
|
+
export function createTokenInventory() {
|
|
236
|
+
const artifacts = new Map();
|
|
237
|
+
const contributions = new Map();
|
|
238
|
+
let snapshotCache = null;
|
|
239
|
+
const invalidate = () => { snapshotCache = null; };
|
|
240
|
+
function apply(artifact) {
|
|
241
|
+
const key = artifactKey(artifact);
|
|
242
|
+
const hasDiagnostics = (artifact.diagnostics?.length ?? 0) > 0;
|
|
243
|
+
if (artifact.content === undefined && !artifact.failed && !hasDiagnostics) {
|
|
244
|
+
if (artifacts.delete(key))
|
|
245
|
+
invalidate();
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const entry = artifacts.get(key) ?? { buildTool: artifact.buildTool, id: artifact.id };
|
|
249
|
+
if (artifact.failed) {
|
|
250
|
+
if (artifact.stage !== "transformed" || entry.transformFailed === true)
|
|
251
|
+
return;
|
|
252
|
+
entry.transformFailed = true;
|
|
253
|
+
artifacts.set(key, entry);
|
|
254
|
+
invalidate();
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const current = artifact.stage === "authored" ? entry.authored : entry.transformed;
|
|
258
|
+
const isRecoveringFailedTransform = artifact.stage === "transformed" && entry.transformFailed === true;
|
|
259
|
+
// Cheap pre-parse guard. A transformed-stage re-feed while the failure
|
|
260
|
+
// flag is set always falls through so recovery still lands.
|
|
261
|
+
if (current && !isRecoveringFailedTransform
|
|
262
|
+
&& sameArtifactScalars(current.artifact, artifact))
|
|
263
|
+
return;
|
|
264
|
+
const observation = parseObservation(artifact);
|
|
265
|
+
if (current && sameObservationFacts(current, observation.artifact)
|
|
266
|
+
&& !isRecoveringFailedTransform)
|
|
267
|
+
return;
|
|
268
|
+
if (artifact.stage === "authored")
|
|
269
|
+
entry.authored = observation;
|
|
270
|
+
else {
|
|
271
|
+
entry.transformed = observation;
|
|
272
|
+
entry.transformFailed = false;
|
|
273
|
+
}
|
|
274
|
+
artifacts.set(key, entry);
|
|
275
|
+
invalidate();
|
|
276
|
+
}
|
|
277
|
+
function applyContribution(contribution) {
|
|
278
|
+
const copied = copyContribution(contribution);
|
|
279
|
+
const existing = contributions.get(copied.id);
|
|
280
|
+
if (existing && sameContributionFacts(existing, copied))
|
|
281
|
+
return;
|
|
282
|
+
contributions.set(copied.id, copied);
|
|
283
|
+
invalidate();
|
|
284
|
+
}
|
|
285
|
+
function removeContribution(id) {
|
|
286
|
+
if (contributions.delete(id))
|
|
287
|
+
invalidate();
|
|
288
|
+
}
|
|
289
|
+
function snapshot() {
|
|
290
|
+
if (snapshotCache)
|
|
291
|
+
return snapshotCache;
|
|
292
|
+
const sortedArtifacts = [...artifacts.values()].sort(compareArtifacts);
|
|
293
|
+
const sortedContributions = [...contributions.values()].sort(compareContributions);
|
|
294
|
+
const evidence = orderEvidence(sortedArtifacts);
|
|
295
|
+
const merged = new Map();
|
|
296
|
+
let provisionalOrder = 0;
|
|
297
|
+
for (const entry of sortedArtifacts) {
|
|
298
|
+
const rows = reconcileObservations(entry)
|
|
299
|
+
.flatMap(({ definition, artifact }) => definition.declarations.map((declaration) => ({ definition, declaration, artifact })))
|
|
300
|
+
.sort((a, b) => (a.declaration.order ?? 0) - (b.declaration.order ?? 0));
|
|
301
|
+
for (const { definition, declaration, artifact } of rows) {
|
|
302
|
+
const enriched = {
|
|
303
|
+
...declaration,
|
|
304
|
+
order: provisionalOrder++,
|
|
305
|
+
contribution: {
|
|
306
|
+
kind: "stylesheet",
|
|
307
|
+
buildTool: artifact.buildTool,
|
|
308
|
+
id: artifact.id,
|
|
309
|
+
stage: artifact.stage,
|
|
310
|
+
provenance: definition.origin ?? artifact.provenance,
|
|
311
|
+
editable: definition.editable ?? artifact.provenance !== "package",
|
|
312
|
+
orderEvidence: evidence.get(artifactKey(artifact)),
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
const existing = merged.get(definition.cssName);
|
|
316
|
+
if (existing)
|
|
317
|
+
existing.declarations.push(enriched);
|
|
318
|
+
else {
|
|
319
|
+
const { declarations: _declarations, ...base } = definition;
|
|
320
|
+
merged.set(definition.cssName, { base, declarations: [enriched] });
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
for (const [contributionIndex, contribution] of sortedContributions.entries()) {
|
|
325
|
+
const contributionOrder = contribution.order ?? contributionIndex;
|
|
326
|
+
const tokens = [...(contribution.tokens ?? [])]
|
|
327
|
+
.sort((a, b) => (a.cssName ?? a.name).localeCompare(b.cssName ?? b.name));
|
|
328
|
+
for (const token of tokens) {
|
|
329
|
+
setLiteralToken(merged, token, contribution.id, contributionOrder, provisionalOrder++);
|
|
330
|
+
}
|
|
331
|
+
for (const relabelling of contribution.relabellings ?? []) {
|
|
332
|
+
for (const entry of merged.values()) {
|
|
333
|
+
if (entry.base.adapter !== relabelling.adapter
|
|
334
|
+
|| entry.base.origin !== relabelling.fromOrigin)
|
|
335
|
+
continue;
|
|
336
|
+
entry.base = {
|
|
337
|
+
...entry.base,
|
|
338
|
+
origin: relabelling.origin ?? entry.base.origin,
|
|
339
|
+
editable: relabelling.editable ?? entry.base.editable,
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
// Definition-level enrichment by cssName: contributed declarations
|
|
344
|
+
// append, `name`/`adapter` win, and
|
|
345
|
+
// `origin`/`editable` are applied only when the stylesheet-derived
|
|
346
|
+
// definition has none. Unmatched entries are ignored (a contract
|
|
347
|
+
// variable absent from active CSS adds no row).
|
|
348
|
+
for (const definition of contribution.definitions ?? []) {
|
|
349
|
+
const existing = merged.get(definition.cssName);
|
|
350
|
+
if (!existing)
|
|
351
|
+
continue;
|
|
352
|
+
for (const declaration of definition.declarations) {
|
|
353
|
+
existing.declarations.push({
|
|
354
|
+
...declaration,
|
|
355
|
+
order: provisionalOrder++,
|
|
356
|
+
contribution: {
|
|
357
|
+
kind: "adapter",
|
|
358
|
+
id: contribution.id,
|
|
359
|
+
provenance: definition.origin,
|
|
360
|
+
editable: definition.editable,
|
|
361
|
+
order: contributionOrder,
|
|
362
|
+
},
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
existing.base = {
|
|
366
|
+
...existing.base,
|
|
367
|
+
name: definition.name,
|
|
368
|
+
adapter: definition.adapter ?? existing.base.adapter,
|
|
369
|
+
origin: existing.base.origin ?? definition.origin,
|
|
370
|
+
editable: existing.base.editable ?? definition.editable,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
const allDeclarations = [...merged.values()]
|
|
375
|
+
.flatMap((entry) => entry.declarations)
|
|
376
|
+
.sort((a, b) => a.order - b.order);
|
|
377
|
+
const compactOrder = new Map(allDeclarations.map((declaration, index) => [declaration, index]));
|
|
378
|
+
const definitions = [...merged.values()].map(({ base, declarations }) => ({
|
|
379
|
+
...base,
|
|
380
|
+
declarations: declarations.map((declaration) => ({
|
|
381
|
+
...declaration,
|
|
382
|
+
order: compactOrder.get(declaration),
|
|
383
|
+
})),
|
|
384
|
+
}));
|
|
385
|
+
const tokens = definitions.map((definition) => ({
|
|
386
|
+
name: definition.name,
|
|
387
|
+
cssName: definition.cssName,
|
|
388
|
+
value: definition.declarations[0]?.value ?? "",
|
|
389
|
+
source: definition.declarations[0]?.source ?? "",
|
|
390
|
+
cssValue: definition.cssValue,
|
|
391
|
+
adapter: definition.adapter,
|
|
392
|
+
origin: definition.origin,
|
|
393
|
+
editable: definition.editable,
|
|
394
|
+
}));
|
|
395
|
+
const diagnostics = [];
|
|
396
|
+
for (const entry of sortedArtifacts) {
|
|
397
|
+
const facts = effectiveObservation(entry);
|
|
398
|
+
if (facts)
|
|
399
|
+
diagnostics.push(...facts.contribution.diagnostics);
|
|
400
|
+
if (entry.transformFailed) {
|
|
401
|
+
diagnostics.push({
|
|
402
|
+
code: "transform-observation-failed",
|
|
403
|
+
artifact: entry.id,
|
|
404
|
+
message: `The transformed observation for "${entry.id}" is unavailable or failed; `
|
|
405
|
+
+ "the last valid authored observation is retained.",
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
for (const contribution of sortedContributions) {
|
|
410
|
+
diagnostics.push(...(contribution.diagnostics ?? []));
|
|
411
|
+
}
|
|
412
|
+
snapshotCache = deepFreeze({
|
|
413
|
+
generation: `g${fnv1a(canonicalSnapshotFacts(definitions, diagnostics))}`,
|
|
414
|
+
definitions,
|
|
415
|
+
tokens,
|
|
416
|
+
diagnostics,
|
|
417
|
+
});
|
|
418
|
+
return snapshotCache;
|
|
419
|
+
}
|
|
420
|
+
return { apply, snapshot, applyContribution, removeContribution };
|
|
421
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TokenDefinition } from "../model/index.js";
|
|
2
|
+
import type { InventoryDiagnostic, StylesheetArtifact } from "./types.js";
|
|
3
|
+
/** The parsed contribution of one stylesheet artifact. */
|
|
4
|
+
export interface ParsedContribution {
|
|
5
|
+
readonly definitions: readonly TokenDefinition[];
|
|
6
|
+
readonly diagnostics: readonly InventoryDiagnostic[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Parse one stylesheet artifact into grouped definitions plus diagnostics.
|
|
10
|
+
*
|
|
11
|
+
* The returned declarations carry `id` (stable per declaration) and the
|
|
12
|
+
* definition list preserves source order. `order` is assigned by the
|
|
13
|
+
* inventory during snapshot assembly because it is a positional fact across
|
|
14
|
+
* artifacts, not a per-artifact one.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseStylesheetArtifact(artifact: StylesheetArtifact): ParsedContribution;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal ordinary-CSS parsing for the token inventory.
|
|
3
|
+
*
|
|
4
|
+
* This is the canonical home of the parsing previously owned by the plugin's
|
|
5
|
+
* legacy `parseTokens`/`parseTokenCatalog` projections (removed in S2-D).
|
|
6
|
+
* Behavior is preserved exactly for root/host themes, contextual selectors,
|
|
7
|
+
* wrapper capture, duplicate declarations, importance, and source locations;
|
|
8
|
+
* the two differences are:
|
|
9
|
+
*
|
|
10
|
+
* 1. Declarations carry a deterministic `id` and a `source`-anchored local
|
|
11
|
+
* order so the inventory can aggregate without Vite.
|
|
12
|
+
* 2. Malformed CSS no longer silently yields an empty list — it produces a
|
|
13
|
+
* structured `stylesheet-parse-failed` diagnostic plus an empty
|
|
14
|
+
* contribution for that artifact.
|
|
15
|
+
*
|
|
16
|
+
* This module runs at build time only (Node) and is not reachable from the
|
|
17
|
+
* browser-safe subpaths.
|
|
18
|
+
*/
|
|
19
|
+
import postcss, {} from "postcss";
|
|
20
|
+
import { GLOBAL_TOKEN_AT_RULES, MIN_THEME_TABLE_DECLARATIONS } from "./policy.js";
|
|
21
|
+
/**
|
|
22
|
+
* Deterministic declaration identity, keyed by (artifact id, cssName, source
|
|
23
|
+
* line, context, local order). The id does not depend on event-batch timing:
|
|
24
|
+
* the same facts always produce the same ids.
|
|
25
|
+
*/
|
|
26
|
+
function declarationId(artifact, cssName, source, context, localOrder) {
|
|
27
|
+
return `${artifact.buildTool}\u0000${artifact.id}\u0000${artifact.stage}`
|
|
28
|
+
+ `\u0000${cssName}\u0000${source}\u0000${JSON.stringify(context)}\u0000${localOrder}`;
|
|
29
|
+
}
|
|
30
|
+
function isRootSelectorPart(sel) {
|
|
31
|
+
return sel === ":root"
|
|
32
|
+
|| sel === ":host"
|
|
33
|
+
|| /^:root[:.[]/.test(sel)
|
|
34
|
+
|| /^:host[:.[]/.test(sel);
|
|
35
|
+
}
|
|
36
|
+
function isRootOnlySelector(rule) {
|
|
37
|
+
const parts = rule.selector.split(",").map((s) => s.trim());
|
|
38
|
+
return parts.length > 0 && parts.every(isRootSelectorPart);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Scoped theme-table policy — see `policy.ts` for the named constant and
|
|
42
|
+
* rationale. A sufficiently large rule made entirely of custom properties is a
|
|
43
|
+
* theme table, not a component-local variable declaration; its selector is
|
|
44
|
+
* retained in the catalog and resolved against the selected element later.
|
|
45
|
+
*/
|
|
46
|
+
function isScopedThemeTable(rule) {
|
|
47
|
+
const declarations = rule.nodes?.filter((node) => node.type === "decl") ?? [];
|
|
48
|
+
return declarations.length >= MIN_THEME_TABLE_DECLARATIONS
|
|
49
|
+
&& declarations.every((declaration) => declaration.prop.startsWith("--"));
|
|
50
|
+
}
|
|
51
|
+
function isRule(node) {
|
|
52
|
+
return node.type === "rule";
|
|
53
|
+
}
|
|
54
|
+
function isAtRule(node) {
|
|
55
|
+
return node.type === "atrule";
|
|
56
|
+
}
|
|
57
|
+
function nearestGlobalAncestor(decl) {
|
|
58
|
+
// Walk up; return true ONLY if we encounter a :root rule or a global at-rule
|
|
59
|
+
// BEFORE encountering any non-:root rule. A non-:root rule (e.g. .button)
|
|
60
|
+
// inside @layer still means the declaration is local, not a global token.
|
|
61
|
+
let cur = decl.parent;
|
|
62
|
+
while (cur) {
|
|
63
|
+
if (isRule(cur)) {
|
|
64
|
+
return isRootOnlySelector(cur) || isScopedThemeTable(cur);
|
|
65
|
+
}
|
|
66
|
+
if (isAtRule(cur)) {
|
|
67
|
+
if (GLOBAL_TOKEN_AT_RULES.has(cur.name))
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
cur = cur.parent;
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
function belongsToGlobalTokenContext(decl) {
|
|
75
|
+
return nearestGlobalAncestor(decl);
|
|
76
|
+
}
|
|
77
|
+
function declarationContext(decl) {
|
|
78
|
+
const context = {};
|
|
79
|
+
const wrappers = [];
|
|
80
|
+
let current = decl.parent;
|
|
81
|
+
while (current) {
|
|
82
|
+
if (isRule(current) && context.selector === undefined) {
|
|
83
|
+
context.selector = current.selector;
|
|
84
|
+
}
|
|
85
|
+
else if (isAtRule(current)) {
|
|
86
|
+
if (current.name === "media" || current.name === "supports" || current.name === "scope" || current.name === "layer") {
|
|
87
|
+
// Parents are visited inner-to-outer; prepend to preserve the source
|
|
88
|
+
// nesting order and retain repeated/interleaved wrapper kinds.
|
|
89
|
+
wrappers.unshift({ kind: current.name, params: current.params });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
current = current.parent;
|
|
93
|
+
}
|
|
94
|
+
if (wrappers.length > 0)
|
|
95
|
+
context.wrappers = wrappers;
|
|
96
|
+
return context;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Parse one stylesheet artifact into grouped definitions plus diagnostics.
|
|
100
|
+
*
|
|
101
|
+
* The returned declarations carry `id` (stable per declaration) and the
|
|
102
|
+
* definition list preserves source order. `order` is assigned by the
|
|
103
|
+
* inventory during snapshot assembly because it is a positional fact across
|
|
104
|
+
* artifacts, not a per-artifact one.
|
|
105
|
+
*/
|
|
106
|
+
export function parseStylesheetArtifact(artifact) {
|
|
107
|
+
const content = artifact.content ?? "";
|
|
108
|
+
let root;
|
|
109
|
+
try {
|
|
110
|
+
root = postcss.parse(content, { from: artifact.id });
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
return {
|
|
114
|
+
definitions: [],
|
|
115
|
+
diagnostics: [{
|
|
116
|
+
code: "stylesheet-parse-failed",
|
|
117
|
+
artifact: artifact.id,
|
|
118
|
+
message: `Stylesheet artifact "${artifact.id}" could not be parsed as CSS: ${error instanceof Error ? error.message : String(error)}`,
|
|
119
|
+
}],
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const definitions = new Map();
|
|
123
|
+
let localOrder = 0;
|
|
124
|
+
root.walkDecls((decl) => {
|
|
125
|
+
if (!decl.prop.startsWith("--"))
|
|
126
|
+
return;
|
|
127
|
+
if (!belongsToGlobalTokenContext(decl))
|
|
128
|
+
return;
|
|
129
|
+
let value = decl.value;
|
|
130
|
+
if (decl.important) {
|
|
131
|
+
value = value.replace(/!\s*important\s*$/i, "").trim();
|
|
132
|
+
}
|
|
133
|
+
value = value.trim();
|
|
134
|
+
const line = decl.source?.start?.line;
|
|
135
|
+
if (typeof line !== "number")
|
|
136
|
+
return;
|
|
137
|
+
const source = `${artifact.id}:${line}`;
|
|
138
|
+
const context = declarationContext(decl);
|
|
139
|
+
const declaration = {
|
|
140
|
+
id: declarationId(artifact, decl.prop, source, context, localOrder),
|
|
141
|
+
order: localOrder,
|
|
142
|
+
value,
|
|
143
|
+
source,
|
|
144
|
+
important: Boolean(decl.important),
|
|
145
|
+
context,
|
|
146
|
+
};
|
|
147
|
+
const existing = definitions.get(decl.prop);
|
|
148
|
+
if (existing)
|
|
149
|
+
existing.declarations.push(declaration);
|
|
150
|
+
else
|
|
151
|
+
definitions.set(decl.prop, { cssName: decl.prop, name: decl.prop, declarations: [declaration] });
|
|
152
|
+
localOrder += 1;
|
|
153
|
+
});
|
|
154
|
+
return { definitions: [...definitions.values()], diagnostics: [] };
|
|
155
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explicit inventory policies behind ordinary CSS parsing.
|
|
3
|
+
*
|
|
4
|
+
* Parsing must not bury heuristics as unexplained constants. This module names
|
|
5
|
+
* each policy, documents its rationale, and pins both directions of the
|
|
6
|
+
* trade-off with tests in `parseStylesheet.test.ts`.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* At-rules that make a nested custom-property declaration global regardless of
|
|
10
|
+
* an enclosing selector: `@theme` (Tailwind v4), `@layer`, and `@scope`.
|
|
11
|
+
*
|
|
12
|
+
* Deliberately NOT included: `@media`, `@supports`, and `@container`. A bare
|
|
13
|
+
* custom property directly inside those wrappers (without `:root`/`:host`) is
|
|
14
|
+
* not a global token — see the false-positive guards in the parsing tests.
|
|
15
|
+
*/
|
|
16
|
+
export declare const GLOBAL_TOKEN_AT_RULES: Set<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Minimum declaration count for a scoped rule to be treated as a theme table.
|
|
19
|
+
*
|
|
20
|
+
* Rationale: published design systems often scope an entire theme beneath a
|
|
21
|
+
* class on the application shell (for example to support multiple themes on
|
|
22
|
+
* one page) instead of `:root`. A rule that is large enough AND made entirely
|
|
23
|
+
* of custom-property declarations is treated as a theme table, so its selector
|
|
24
|
+
* is retained in the catalog and resolved against the selected element later.
|
|
25
|
+
*
|
|
26
|
+
* The threshold is a deliberately explicit policy with two documented edges,
|
|
27
|
+
* both pinned by tests:
|
|
28
|
+
*
|
|
29
|
+
* - False positive: a component-local rule with many custom properties (at or
|
|
30
|
+
* above the threshold) is admitted as a theme table even though it is local
|
|
31
|
+
* to the component. Accepted so genuine multi-variable theme tables keep
|
|
32
|
+
* working; a cleaner fix needs selector heuristics that are out of scope for
|
|
33
|
+
* ordinary-CSS parsing.
|
|
34
|
+
* - False negative: a real theme table with fewer than the threshold
|
|
35
|
+
* declarations is rejected. Accepted so small component-local rules do not
|
|
36
|
+
* leak into the global catalog.
|
|
37
|
+
*
|
|
38
|
+
* The threshold is a count of direct custom-property declarations on the rule,
|
|
39
|
+
* not a line count and not an estimate of selector breadth.
|
|
40
|
+
*/
|
|
41
|
+
export declare const MIN_THEME_TABLE_DECLARATIONS = 8;
|
|
42
|
+
export interface ScopedThemeTablePolicy {
|
|
43
|
+
readonly minDeclarations: number;
|
|
44
|
+
readonly requiresOnlyCustomProperties: boolean;
|
|
45
|
+
readonly rationale: string;
|
|
46
|
+
}
|
|
47
|
+
export declare const SCOPED_THEME_TABLE_POLICY: ScopedThemeTablePolicy;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explicit inventory policies behind ordinary CSS parsing.
|
|
3
|
+
*
|
|
4
|
+
* Parsing must not bury heuristics as unexplained constants. This module names
|
|
5
|
+
* each policy, documents its rationale, and pins both directions of the
|
|
6
|
+
* trade-off with tests in `parseStylesheet.test.ts`.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* At-rules that make a nested custom-property declaration global regardless of
|
|
10
|
+
* an enclosing selector: `@theme` (Tailwind v4), `@layer`, and `@scope`.
|
|
11
|
+
*
|
|
12
|
+
* Deliberately NOT included: `@media`, `@supports`, and `@container`. A bare
|
|
13
|
+
* custom property directly inside those wrappers (without `:root`/`:host`) is
|
|
14
|
+
* not a global token — see the false-positive guards in the parsing tests.
|
|
15
|
+
*/
|
|
16
|
+
export const GLOBAL_TOKEN_AT_RULES = new Set(["theme", "layer", "scope"]);
|
|
17
|
+
/**
|
|
18
|
+
* Minimum declaration count for a scoped rule to be treated as a theme table.
|
|
19
|
+
*
|
|
20
|
+
* Rationale: published design systems often scope an entire theme beneath a
|
|
21
|
+
* class on the application shell (for example to support multiple themes on
|
|
22
|
+
* one page) instead of `:root`. A rule that is large enough AND made entirely
|
|
23
|
+
* of custom-property declarations is treated as a theme table, so its selector
|
|
24
|
+
* is retained in the catalog and resolved against the selected element later.
|
|
25
|
+
*
|
|
26
|
+
* The threshold is a deliberately explicit policy with two documented edges,
|
|
27
|
+
* both pinned by tests:
|
|
28
|
+
*
|
|
29
|
+
* - False positive: a component-local rule with many custom properties (at or
|
|
30
|
+
* above the threshold) is admitted as a theme table even though it is local
|
|
31
|
+
* to the component. Accepted so genuine multi-variable theme tables keep
|
|
32
|
+
* working; a cleaner fix needs selector heuristics that are out of scope for
|
|
33
|
+
* ordinary-CSS parsing.
|
|
34
|
+
* - False negative: a real theme table with fewer than the threshold
|
|
35
|
+
* declarations is rejected. Accepted so small component-local rules do not
|
|
36
|
+
* leak into the global catalog.
|
|
37
|
+
*
|
|
38
|
+
* The threshold is a count of direct custom-property declarations on the rule,
|
|
39
|
+
* not a line count and not an estimate of selector breadth.
|
|
40
|
+
*/
|
|
41
|
+
export const MIN_THEME_TABLE_DECLARATIONS = 8;
|
|
42
|
+
export const SCOPED_THEME_TABLE_POLICY = {
|
|
43
|
+
minDeclarations: MIN_THEME_TABLE_DECLARATIONS,
|
|
44
|
+
requiresOnlyCustomProperties: true,
|
|
45
|
+
rationale: "A scoped rule is a theme table only when it is large enough and made entirely "
|
|
46
|
+
+ "of custom-property declarations. This admits multi-variable theme tables on "
|
|
47
|
+
+ "an application shell while keeping small component-local variable blocks out "
|
|
48
|
+
+ "of the global catalog. Both directions of the trade-off are pinned by tests "
|
|
49
|
+
+ "in parseStylesheet.test.ts.",
|
|
50
|
+
};
|