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,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tiny lifecycle seam keeps canonical-history clearing independent from the
|
|
3
|
+
* editor implementation. The editor registers its active-session disposer;
|
|
4
|
+
* changesLog can then cancel it without importing the editor back through a
|
|
5
|
+
* circular module edge.
|
|
6
|
+
*/
|
|
7
|
+
let clearHandler = null;
|
|
8
|
+
export function registerInlineTextClearHandler(handler) {
|
|
9
|
+
clearHandler = handler;
|
|
10
|
+
return () => {
|
|
11
|
+
if (clearHandler === handler)
|
|
12
|
+
clearHandler = null;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function cancelInlineTextForClear() {
|
|
16
|
+
clearHandler?.();
|
|
17
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility seam for the former inline-text model owner. The shared
|
|
3
|
+
* vocabulary and guards now live in `changes/editModel.ts`.
|
|
4
|
+
*/
|
|
5
|
+
export type { TextBindingEvidence, TextContentChangeRecord, TextProjectionScope, TextProjectionSourceSite, TextProjectionTarget, } from "../changes/editModel.js";
|
|
6
|
+
export { isTextContentChangeListValue, isTextContentChangeValue, isTextProjectionTargetValue, } from "../changes/editModel.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isTextContentChangeListValue, isTextContentChangeValue, isTextProjectionTargetValue, } from "../changes/editModel.js";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { TokenDefinition, TokenEntry } from "../../css/model/index.js";
|
|
2
|
+
import { getChangesList, getPendingRules } from "../changes/changesLog.js";
|
|
3
|
+
import type { InspectorProjection } from "../spacing/projection.js";
|
|
4
|
+
import type { ResolvedProperty } from "../../css/model/index.js";
|
|
5
|
+
export declare const NUDGE_UI_INSPECTION_VERSION: 1;
|
|
6
|
+
export interface InspectionCatalogEntry {
|
|
7
|
+
name: string;
|
|
8
|
+
cssName: string;
|
|
9
|
+
adapter?: string;
|
|
10
|
+
origin?: TokenEntry["origin"];
|
|
11
|
+
editable?: boolean;
|
|
12
|
+
declarations: Array<{
|
|
13
|
+
value: string;
|
|
14
|
+
source: string;
|
|
15
|
+
important: boolean;
|
|
16
|
+
context: TokenDefinition["declarations"][number]["context"];
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
export interface InspectionControl {
|
|
20
|
+
property: string;
|
|
21
|
+
kind: "token" | "raw";
|
|
22
|
+
activeToken: string | null;
|
|
23
|
+
suggestions: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface ElementInspection {
|
|
26
|
+
version: typeof NUDGE_UI_INSPECTION_VERSION;
|
|
27
|
+
identity: {
|
|
28
|
+
cid: string | null;
|
|
29
|
+
src: string;
|
|
30
|
+
file: string;
|
|
31
|
+
line: number;
|
|
32
|
+
column: number;
|
|
33
|
+
};
|
|
34
|
+
catalog: InspectionCatalogEntry[];
|
|
35
|
+
availableTokens: TokenEntry[];
|
|
36
|
+
properties: ResolvedProperty[];
|
|
37
|
+
projection: InspectorProjection;
|
|
38
|
+
controls: InspectionControl[];
|
|
39
|
+
changes: ReturnType<typeof getChangesList>;
|
|
40
|
+
managedPreview: {
|
|
41
|
+
rules: ReturnType<typeof getPendingRules>;
|
|
42
|
+
results: Array<{
|
|
43
|
+
property: string;
|
|
44
|
+
requestedValue: string;
|
|
45
|
+
computedValue: string;
|
|
46
|
+
status: "applied" | "conflict";
|
|
47
|
+
reason?: string;
|
|
48
|
+
}>;
|
|
49
|
+
};
|
|
50
|
+
prompt: string | null;
|
|
51
|
+
}
|
|
52
|
+
export interface InspectElementOptions {
|
|
53
|
+
catalog?: readonly TokenDefinition[];
|
|
54
|
+
tokens?: readonly TokenEntry[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Returns the inspector's stable, read-only facts for one rendered element.
|
|
58
|
+
* Compatibility tests and the React UI cross the same resolver/projection seam;
|
|
59
|
+
* this function deliberately performs no selection or edit side effects.
|
|
60
|
+
*/
|
|
61
|
+
export declare function inspectElement(element: HTMLElement, options?: InspectElementOptions): ElementInspection;
|
|
62
|
+
export interface NudgeUiInspectionBridge {
|
|
63
|
+
version: typeof NUDGE_UI_INSPECTION_VERSION;
|
|
64
|
+
inspect(selector: string): ElementInspection | null;
|
|
65
|
+
}
|
|
66
|
+
declare global {
|
|
67
|
+
interface Window {
|
|
68
|
+
__nudgeUi?: NudgeUiInspectionBridge;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Installs the dev-only browser seam used by compatibility applications. */
|
|
72
|
+
export declare function installInspectionBridge(target?: Window): () => void;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { getChangesList, getPendingRules, isPreviewableChange } from "../changes/changesLog.js";
|
|
2
|
+
import { changeKey } from "../changes/model.js";
|
|
3
|
+
import { getAnyPreviewDiagnostic } from "../changes/previewDiagnostics.js";
|
|
4
|
+
import { detectFramework } from "../prompt/detectFramework.js";
|
|
5
|
+
import { generatePrompt } from "../prompt/generatePrompt.js";
|
|
6
|
+
import { loadCustomInstructions } from "../prompt/promptSettings.js";
|
|
7
|
+
import { resolveSelectionFromElement } from "../selection/resolveSelection.js";
|
|
8
|
+
import { projectInspectorValues } from "../spacing/projection.js";
|
|
9
|
+
import { selectTokens } from "../../css/value-semantics/index.js";
|
|
10
|
+
import { createBrowserCssInspection } from "./browserCssInspection.js";
|
|
11
|
+
import { getBrowserCssInspection } from "./browserCssInspectionRegistry.js";
|
|
12
|
+
import { getNudgeUiRuntimeConfig } from "../runtime/runtimeConfig.js";
|
|
13
|
+
export const NUDGE_UI_INSPECTION_VERSION = 1;
|
|
14
|
+
function inspectBrowserFacts(element, definitions, entries) {
|
|
15
|
+
const doc = element.ownerDocument ?? document;
|
|
16
|
+
if (definitions === getNudgeUiRuntimeConfig().tokenCatalog && entries === undefined) {
|
|
17
|
+
const session = getBrowserCssInspection(doc);
|
|
18
|
+
return {
|
|
19
|
+
element: session.inspect(element, { cascade: "live" }),
|
|
20
|
+
tokens: session.inspectTokens(element),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// Compatibility callers may provide a fixture-local catalog. Keep that
|
|
24
|
+
// Adapter isolated from the document registry so one caller cannot replace
|
|
25
|
+
// the token knowledge used by the live inspector session.
|
|
26
|
+
const session = createBrowserCssInspection({
|
|
27
|
+
document: doc,
|
|
28
|
+
tokenKnowledge: { definitions, entries, generation: "compatibility" },
|
|
29
|
+
});
|
|
30
|
+
try {
|
|
31
|
+
return {
|
|
32
|
+
element: session.inspect(element, { cascade: "live" }),
|
|
33
|
+
tokens: session.inspectTokens(element),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
session.dispose();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function catalogEntry(definition) {
|
|
41
|
+
return {
|
|
42
|
+
name: definition.name,
|
|
43
|
+
cssName: definition.cssName,
|
|
44
|
+
adapter: definition.adapter,
|
|
45
|
+
origin: definition.origin,
|
|
46
|
+
editable: definition.editable,
|
|
47
|
+
declarations: definition.declarations.map((declaration) => ({
|
|
48
|
+
value: declaration.value,
|
|
49
|
+
source: declaration.source,
|
|
50
|
+
important: declaration.important,
|
|
51
|
+
context: declaration.context,
|
|
52
|
+
})),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns the inspector's stable, read-only facts for one rendered element.
|
|
57
|
+
* Compatibility tests and the React UI cross the same resolver/projection seam;
|
|
58
|
+
* this function deliberately performs no selection or edit side effects.
|
|
59
|
+
*/
|
|
60
|
+
export function inspectElement(element, options = {}) {
|
|
61
|
+
const runtimeConfig = getNudgeUiRuntimeConfig();
|
|
62
|
+
const definitions = options.catalog ?? runtimeConfig.tokenCatalog;
|
|
63
|
+
const frameworkHints = options.tokens
|
|
64
|
+
? detectFramework(options.tokens)
|
|
65
|
+
: {
|
|
66
|
+
framework: runtimeConfig.framework,
|
|
67
|
+
stylingSystem: runtimeConfig.stylingSystem,
|
|
68
|
+
};
|
|
69
|
+
const browserFacts = inspectBrowserFacts(element, definitions, options.tokens);
|
|
70
|
+
const availableTokens = options.tokens ? [...options.tokens] : [...browserFacts.element.availableTokens];
|
|
71
|
+
const properties = [...browserFacts.element.properties];
|
|
72
|
+
const selection = resolveSelectionFromElement(element);
|
|
73
|
+
const changes = getChangesList();
|
|
74
|
+
const customInstructions = loadCustomInstructions(runtimeConfig.projectId);
|
|
75
|
+
const managedPreview = {
|
|
76
|
+
rules: getPendingRules(),
|
|
77
|
+
results: changes.flatMap((change) => {
|
|
78
|
+
if (!isPreviewableChange(change))
|
|
79
|
+
return [];
|
|
80
|
+
const diagnostic = getAnyPreviewDiagnostic(changeKey(change));
|
|
81
|
+
return diagnostic ? [{ property: change.property, ...diagnostic.result }] : [];
|
|
82
|
+
}),
|
|
83
|
+
};
|
|
84
|
+
// Local vanilla-extract themes attach contract variables to a theme class,
|
|
85
|
+
// not necessarily :root. The selected element is therefore the correct
|
|
86
|
+
// availability context for an element inspection.
|
|
87
|
+
const controls = properties
|
|
88
|
+
.filter((property) => !property.property.startsWith("--"))
|
|
89
|
+
.map((property) => ({
|
|
90
|
+
property: property.property,
|
|
91
|
+
kind: property.tokenName ? "token" : "raw",
|
|
92
|
+
activeToken: property.tokenName,
|
|
93
|
+
suggestions: Array.from(new Set(selectTokens({
|
|
94
|
+
property: property.property,
|
|
95
|
+
entries: availableTokens,
|
|
96
|
+
currentToken: property.tokenName,
|
|
97
|
+
}).candidates.map((candidate) => candidate.entry.name))),
|
|
98
|
+
}));
|
|
99
|
+
return {
|
|
100
|
+
version: NUDGE_UI_INSPECTION_VERSION,
|
|
101
|
+
identity: {
|
|
102
|
+
cid: selection?.cid ?? element.getAttribute("data-cid"),
|
|
103
|
+
src: selection?.src ?? element.getAttribute("data-src") ?? "",
|
|
104
|
+
file: selection?.file ?? "",
|
|
105
|
+
line: selection?.line ?? 0,
|
|
106
|
+
column: selection?.column ?? 0,
|
|
107
|
+
},
|
|
108
|
+
catalog: browserFacts.tokens.tokens.map((row) => catalogEntry(row.definition)),
|
|
109
|
+
availableTokens,
|
|
110
|
+
properties,
|
|
111
|
+
projection: projectInspectorValues(element, properties),
|
|
112
|
+
controls,
|
|
113
|
+
changes,
|
|
114
|
+
managedPreview,
|
|
115
|
+
prompt: changes.length > 0
|
|
116
|
+
? generatePrompt(changes, frameworkHints, [], customInstructions)
|
|
117
|
+
: null,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/** Installs the dev-only browser seam used by compatibility applications. */
|
|
121
|
+
export function installInspectionBridge(target = window) {
|
|
122
|
+
const bridge = {
|
|
123
|
+
version: NUDGE_UI_INSPECTION_VERSION,
|
|
124
|
+
inspect(selector) {
|
|
125
|
+
const element = target.document.querySelector(selector);
|
|
126
|
+
return element instanceof HTMLElement ? inspectElement(element) : null;
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
target.__nudgeUi = bridge;
|
|
130
|
+
return () => {
|
|
131
|
+
if (target.__nudgeUi === bridge)
|
|
132
|
+
delete target.__nudgeUi;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { TokenDefinition, TokenEntry } from "../../css/model/index.js";
|
|
2
|
+
import type { ResolvedProperty } from "../../css/model/index.js";
|
|
3
|
+
import type { InteractionState } from "../shell/styleState.js";
|
|
4
|
+
import { type TokenCatalogRow } from "../tokens/catalog.js";
|
|
5
|
+
export interface BrowserTokenKnowledge {
|
|
6
|
+
/** Build-time definitions normalized by a build-tool Adapter. */
|
|
7
|
+
definitions: readonly TokenDefinition[];
|
|
8
|
+
/** Optional compiler entries used to resolve authored references that are
|
|
9
|
+
* intentionally not mounted as custom properties in the current document. */
|
|
10
|
+
entries?: readonly TokenEntry[];
|
|
11
|
+
/** Changes whenever the Adapter publishes a new token inventory. */
|
|
12
|
+
generation: string | number;
|
|
13
|
+
}
|
|
14
|
+
export interface BrowserCssInspectionConfig {
|
|
15
|
+
document: Document;
|
|
16
|
+
tokenKnowledge: BrowserTokenKnowledge;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Cascade transform owned exclusively by this module:
|
|
20
|
+
* - authored: interaction-state attribution (default; state defaults to base)
|
|
21
|
+
* - live: raw CSSOM matching as currently painted
|
|
22
|
+
* - stable: drops transient pseudo-class rules for editor token linking
|
|
23
|
+
*/
|
|
24
|
+
export type InspectionCascade = "authored" | "live" | "stable";
|
|
25
|
+
export interface BrowserCssInspectionOptions {
|
|
26
|
+
state?: InteractionState;
|
|
27
|
+
cascade?: InspectionCascade;
|
|
28
|
+
}
|
|
29
|
+
export type InspectionTargetStatus = "attached" | "detached" | "foreign-document" | "unsupported" | "disabled" | "disposed";
|
|
30
|
+
export type InspectionDiagnosticCode = "target-document-mismatch" | "target-detached" | "target-unsupported" | "state-unavailable" | "inspection-failed" | "production-disabled" | "session-disposed";
|
|
31
|
+
export interface InspectionDiagnostic {
|
|
32
|
+
code: InspectionDiagnosticCode;
|
|
33
|
+
message: string;
|
|
34
|
+
}
|
|
35
|
+
export interface InspectionRevision {
|
|
36
|
+
element: number;
|
|
37
|
+
stylesheet: number;
|
|
38
|
+
tokenGeneration: string | number;
|
|
39
|
+
}
|
|
40
|
+
export interface InspectionSnapshot {
|
|
41
|
+
target: {
|
|
42
|
+
status: InspectionTargetStatus;
|
|
43
|
+
};
|
|
44
|
+
cascade: InspectionCascade;
|
|
45
|
+
requestedState: InteractionState;
|
|
46
|
+
authoredState: InteractionState;
|
|
47
|
+
/** Computed values describe what the browser is currently painting. */
|
|
48
|
+
paintedState: "current";
|
|
49
|
+
properties: readonly ResolvedProperty[];
|
|
50
|
+
availableTokens: readonly TokenEntry[];
|
|
51
|
+
availableStates: readonly InteractionState[];
|
|
52
|
+
revision: InspectionRevision;
|
|
53
|
+
diagnostics: readonly InspectionDiagnostic[];
|
|
54
|
+
}
|
|
55
|
+
export interface DocumentTokenInspectionSnapshot {
|
|
56
|
+
/** Complete authored inventory supplied by the build-tool Adapter. */
|
|
57
|
+
inventory: readonly TokenCatalogRow[];
|
|
58
|
+
/** Tokens currently available below the inspected document root. */
|
|
59
|
+
tokens: readonly TokenCatalogRow[];
|
|
60
|
+
revision: InspectionRevision;
|
|
61
|
+
diagnostics: readonly InspectionDiagnostic[];
|
|
62
|
+
}
|
|
63
|
+
export interface BrowserCssInspection {
|
|
64
|
+
inspect(element: HTMLElement, options?: BrowserCssInspectionOptions): InspectionSnapshot;
|
|
65
|
+
inspectTokens(root?: HTMLElement): DocumentTokenInspectionSnapshot;
|
|
66
|
+
subscribe(listener: (revision: InspectionRevision) => void): () => void;
|
|
67
|
+
/** Integration hook for managed CSSOM writes. */
|
|
68
|
+
notifyStylesheetChange(): void;
|
|
69
|
+
/** Optional: warms the CSSOM rule snapshot so the next inspect does not pay
|
|
70
|
+
* the stylesheet walk inside its own budget. Cheap when already warm. */
|
|
71
|
+
prewarmRules?(): void;
|
|
72
|
+
dispose(): void;
|
|
73
|
+
}
|
|
74
|
+
export declare function createBrowserCssInspection(config: BrowserCssInspectionConfig): BrowserCssInspection;
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { isNudgeUiDev } from "../runtime/devFlag.js";
|
|
2
|
+
import { buildTokenTable, getAvailableInteractionStates, getAvailableTokenCatalog, getAvailableTokenEntriesForElement, getResolvedProperties, getResolvedPropertiesForState, getResolvedPropertiesStable, invalidateStyleResolutionCache, prewarmCssomRuleSnapshot, } from "../tokens/resolution.js";
|
|
3
|
+
import { buildTokenCatalogRows } from "../tokens/catalog.js";
|
|
4
|
+
import { documentRevisions, registerResolutionElement, retainDocumentResolution, subscribeDocumentRevision, } from "../tokens/resolution/cssomCollector.js";
|
|
5
|
+
function revisionSnapshot(revisions, tokenGeneration) {
|
|
6
|
+
return {
|
|
7
|
+
element: revisions.element,
|
|
8
|
+
stylesheet: revisions.stylesheet,
|
|
9
|
+
tokenGeneration,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function targetStatus(element, doc) {
|
|
13
|
+
if (element.ownerDocument !== doc)
|
|
14
|
+
return "foreign-document";
|
|
15
|
+
const HTMLElementConstructor = doc.defaultView?.HTMLElement;
|
|
16
|
+
if (HTMLElementConstructor && !(element instanceof HTMLElementConstructor))
|
|
17
|
+
return "unsupported";
|
|
18
|
+
return element.isConnected ? "attached" : "detached";
|
|
19
|
+
}
|
|
20
|
+
function targetDiagnostic(status) {
|
|
21
|
+
if (status === "foreign-document") {
|
|
22
|
+
return {
|
|
23
|
+
code: "target-document-mismatch",
|
|
24
|
+
message: "The inspected element belongs to a different document than this session.",
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (status === "unsupported") {
|
|
28
|
+
return {
|
|
29
|
+
code: "target-unsupported",
|
|
30
|
+
message: "Browser CSS inspection currently supports HTMLElement targets only.",
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (status === "detached") {
|
|
34
|
+
return {
|
|
35
|
+
code: "target-detached",
|
|
36
|
+
message: "The inspected element is detached; browser evidence may be incomplete.",
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
function emptySnapshot(status, cascade, state, revision, diagnostics) {
|
|
42
|
+
return {
|
|
43
|
+
target: { status },
|
|
44
|
+
cascade,
|
|
45
|
+
requestedState: state,
|
|
46
|
+
authoredState: cascade === "authored" ? state : "base",
|
|
47
|
+
paintedState: "current",
|
|
48
|
+
properties: [],
|
|
49
|
+
availableTokens: [],
|
|
50
|
+
availableStates: ["base"],
|
|
51
|
+
revision,
|
|
52
|
+
diagnostics,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function cloneProperties(properties) {
|
|
56
|
+
return properties.map((property) => ({
|
|
57
|
+
...property,
|
|
58
|
+
tokens: property.tokens?.map((token) => ({ ...token })),
|
|
59
|
+
modifiers: property.modifiers?.map((modifier) => ({ ...modifier })),
|
|
60
|
+
opacity: property.opacity ? { ...property.opacity, token: property.opacity.token && { ...property.opacity.token } } : undefined,
|
|
61
|
+
color: property.color && { ...property.color },
|
|
62
|
+
structure: property.structure && { ...property.structure },
|
|
63
|
+
atRules: property.atRules?.map((atRule) => ({ ...atRule })),
|
|
64
|
+
atRuleCandidates: property.atRuleCandidates?.map((candidate) => ({ ...candidate })),
|
|
65
|
+
evidence: { ...property.evidence },
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
function cloneEntries(entries) {
|
|
69
|
+
return entries.map((entry) => ({ ...entry }));
|
|
70
|
+
}
|
|
71
|
+
function cloneCatalogRows(rows) {
|
|
72
|
+
return rows.map((row) => {
|
|
73
|
+
const activeIndex = row.activeDeclaration
|
|
74
|
+
? row.definition.declarations.indexOf(row.activeDeclaration)
|
|
75
|
+
: -1;
|
|
76
|
+
const definition = {
|
|
77
|
+
...row.definition,
|
|
78
|
+
declarations: row.definition.declarations.map((declaration) => ({
|
|
79
|
+
...declaration,
|
|
80
|
+
context: {
|
|
81
|
+
...declaration.context,
|
|
82
|
+
wrappers: declaration.context.wrappers?.map((wrapper) => ({ ...wrapper })),
|
|
83
|
+
},
|
|
84
|
+
})),
|
|
85
|
+
};
|
|
86
|
+
return {
|
|
87
|
+
...row,
|
|
88
|
+
definition,
|
|
89
|
+
activeDeclaration: activeIndex >= 0 ? definition.declarations[activeIndex] ?? null : null,
|
|
90
|
+
styleContext: {
|
|
91
|
+
...row.styleContext,
|
|
92
|
+
wrappers: row.styleContext.wrappers?.map((wrapper) => ({ ...wrapper })),
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function disabledInspection(config) {
|
|
98
|
+
const revision = {
|
|
99
|
+
element: 0,
|
|
100
|
+
stylesheet: 0,
|
|
101
|
+
tokenGeneration: config.tokenKnowledge.generation,
|
|
102
|
+
};
|
|
103
|
+
const diagnostics = [{
|
|
104
|
+
code: "production-disabled",
|
|
105
|
+
message: "Browser CSS inspection is disabled outside development.",
|
|
106
|
+
}];
|
|
107
|
+
return {
|
|
108
|
+
inspect(_element, options = {}) {
|
|
109
|
+
return emptySnapshot("disabled", options.cascade ?? "authored", options.state ?? "base", revision, diagnostics);
|
|
110
|
+
},
|
|
111
|
+
inspectTokens() {
|
|
112
|
+
return { inventory: [], tokens: [], revision, diagnostics };
|
|
113
|
+
},
|
|
114
|
+
subscribe() { return () => undefined; },
|
|
115
|
+
notifyStylesheetChange() { },
|
|
116
|
+
dispose() { },
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function notifyRevision(listener, revisions, tokenGeneration) {
|
|
120
|
+
listener(revisionSnapshot(revisions, tokenGeneration));
|
|
121
|
+
}
|
|
122
|
+
function resolveCascadeProperties(element, table, cascade, state) {
|
|
123
|
+
if (cascade === "live")
|
|
124
|
+
return getResolvedProperties(element, table);
|
|
125
|
+
if (cascade === "stable")
|
|
126
|
+
return getResolvedPropertiesStable(element, table);
|
|
127
|
+
return getResolvedPropertiesForState(element, table, state);
|
|
128
|
+
}
|
|
129
|
+
export function createBrowserCssInspection(config) {
|
|
130
|
+
if (!isNudgeUiDev())
|
|
131
|
+
return disabledInspection(config);
|
|
132
|
+
const definitions = [...config.tokenKnowledge.definitions];
|
|
133
|
+
const knowledgeEntries = [...(config.tokenKnowledge.entries ?? [])];
|
|
134
|
+
const tokenGeneration = config.tokenKnowledge.generation;
|
|
135
|
+
let disposed = false;
|
|
136
|
+
const releaseDocumentResolution = retainDocumentResolution(config.document);
|
|
137
|
+
const revisionUnsubscribers = new Set();
|
|
138
|
+
const elementTables = new WeakMap();
|
|
139
|
+
// When compiler entries are merged ahead of runtime availability, keep one
|
|
140
|
+
// table per availableTokens identity so resolver caches stay warm.
|
|
141
|
+
const mergedTables = new WeakMap();
|
|
142
|
+
const mediaCleanup = [];
|
|
143
|
+
const mediaQueries = new Set(definitions.flatMap((definition) => definition.declarations.flatMap((declaration) => (declaration.context.wrappers ?? [])
|
|
144
|
+
.filter((wrapper) => wrapper.kind === "media")
|
|
145
|
+
.map((wrapper) => wrapper.params))));
|
|
146
|
+
const ownerWindow = config.document.defaultView;
|
|
147
|
+
if (ownerWindow && typeof ownerWindow.matchMedia === "function") {
|
|
148
|
+
for (const query of mediaQueries) {
|
|
149
|
+
const media = ownerWindow.matchMedia(query);
|
|
150
|
+
const onChange = () => {
|
|
151
|
+
if (!disposed)
|
|
152
|
+
invalidateStyleResolutionCache(config.document);
|
|
153
|
+
};
|
|
154
|
+
if (typeof media.addEventListener === "function") {
|
|
155
|
+
media.addEventListener("change", onChange);
|
|
156
|
+
mediaCleanup.push(() => media.removeEventListener("change", onChange));
|
|
157
|
+
}
|
|
158
|
+
else if (typeof media.addListener === "function") {
|
|
159
|
+
media.addListener(onChange);
|
|
160
|
+
mediaCleanup.push(() => media.removeListener(onChange));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const currentRevision = () => revisionSnapshot(documentRevisions(config.document), tokenGeneration);
|
|
165
|
+
function tokenTableFor(element) {
|
|
166
|
+
const availableTokens = getAvailableTokenEntriesForElement(element, definitions);
|
|
167
|
+
const revisions = documentRevisions(config.document);
|
|
168
|
+
const cached = elementTables.get(element);
|
|
169
|
+
if (cached
|
|
170
|
+
&& cached.elementRevision === revisions.element
|
|
171
|
+
&& cached.stylesheetRevision === revisions.stylesheet
|
|
172
|
+
&& cached.availableTokens === availableTokens) {
|
|
173
|
+
return { availableTokens: cached.availableTokens, table: cached.table };
|
|
174
|
+
}
|
|
175
|
+
let table;
|
|
176
|
+
if (knowledgeEntries.length === 0) {
|
|
177
|
+
// Same array identity as the availability cache → buildTokenTable hits.
|
|
178
|
+
table = buildTokenTable(availableTokens);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
const merged = mergedTables.get(availableTokens);
|
|
182
|
+
if (merged) {
|
|
183
|
+
table = merged;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
table = buildTokenTable([...knowledgeEntries, ...availableTokens]);
|
|
187
|
+
mergedTables.set(availableTokens, table);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
elementTables.set(element, {
|
|
191
|
+
elementRevision: revisions.element,
|
|
192
|
+
stylesheetRevision: revisions.stylesheet,
|
|
193
|
+
availableTokens,
|
|
194
|
+
table,
|
|
195
|
+
});
|
|
196
|
+
return { availableTokens, table };
|
|
197
|
+
}
|
|
198
|
+
const session = {
|
|
199
|
+
inspect(element, options = {}) {
|
|
200
|
+
const state = options.state ?? "base";
|
|
201
|
+
const cascade = options.cascade ?? "authored";
|
|
202
|
+
const status = disposed ? "disposed" : targetStatus(element, config.document);
|
|
203
|
+
const diagnostics = [];
|
|
204
|
+
if (disposed)
|
|
205
|
+
diagnostics.push({ code: "session-disposed", message: "This inspection session has been disposed." });
|
|
206
|
+
else {
|
|
207
|
+
const diagnostic = targetDiagnostic(status);
|
|
208
|
+
if (diagnostic)
|
|
209
|
+
diagnostics.push(diagnostic);
|
|
210
|
+
}
|
|
211
|
+
const revision = currentRevision();
|
|
212
|
+
if (status !== "attached" && status !== "detached") {
|
|
213
|
+
return emptySnapshot(status, cascade, state, revision, diagnostics);
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
const { availableTokens, table } = tokenTableFor(element);
|
|
217
|
+
// Only the authored cascade reports which interaction states have
|
|
218
|
+
// authored rules (the panel's state selector reads it there). Stable
|
|
219
|
+
// and live consumers project properties only, so skip the O(rules)
|
|
220
|
+
// per-state matching sweep for them.
|
|
221
|
+
const availableStates = cascade === "stable"
|
|
222
|
+
? ["base"]
|
|
223
|
+
: getAvailableInteractionStates(element);
|
|
224
|
+
if (cascade === "authored" && state !== "base" && !availableStates.includes(state)) {
|
|
225
|
+
diagnostics.push({
|
|
226
|
+
code: "state-unavailable",
|
|
227
|
+
message: `The ${state} interaction state has no matching authored rule for this element.`,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
const properties = resolveCascadeProperties(element, table, cascade, state);
|
|
231
|
+
return {
|
|
232
|
+
target: { status },
|
|
233
|
+
cascade,
|
|
234
|
+
requestedState: state,
|
|
235
|
+
authoredState: cascade === "authored" ? state : "base",
|
|
236
|
+
paintedState: "current",
|
|
237
|
+
properties: cloneProperties(properties),
|
|
238
|
+
availableTokens: cloneEntries(availableTokens),
|
|
239
|
+
availableStates: [...availableStates],
|
|
240
|
+
revision,
|
|
241
|
+
diagnostics,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
diagnostics.push({
|
|
246
|
+
code: "inspection-failed",
|
|
247
|
+
message: error instanceof Error ? error.message : "Browser CSS inspection failed.",
|
|
248
|
+
});
|
|
249
|
+
return emptySnapshot(status, cascade, state, revision, diagnostics);
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
inspectTokens(root = config.document.documentElement) {
|
|
253
|
+
const diagnostics = [];
|
|
254
|
+
const revision = currentRevision();
|
|
255
|
+
if (disposed) {
|
|
256
|
+
diagnostics.push({ code: "session-disposed", message: "This inspection session has been disposed." });
|
|
257
|
+
return { inventory: [], tokens: [], revision, diagnostics };
|
|
258
|
+
}
|
|
259
|
+
if (root.ownerDocument !== config.document) {
|
|
260
|
+
diagnostics.push({
|
|
261
|
+
code: "target-document-mismatch",
|
|
262
|
+
message: "The token inspection root belongs to a different document than this session.",
|
|
263
|
+
});
|
|
264
|
+
return { inventory: [], tokens: [], revision, diagnostics };
|
|
265
|
+
}
|
|
266
|
+
try {
|
|
267
|
+
registerResolutionElement(root);
|
|
268
|
+
const catalog = getAvailableTokenCatalog(root, definitions);
|
|
269
|
+
return {
|
|
270
|
+
inventory: cloneCatalogRows(buildTokenCatalogRows(definitions, root)),
|
|
271
|
+
tokens: cloneCatalogRows(buildTokenCatalogRows(catalog, root)),
|
|
272
|
+
revision,
|
|
273
|
+
diagnostics,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
diagnostics.push({
|
|
278
|
+
code: "inspection-failed",
|
|
279
|
+
message: error instanceof Error ? error.message : "Browser token inspection failed.",
|
|
280
|
+
});
|
|
281
|
+
return { inventory: [], tokens: [], revision, diagnostics };
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
subscribe(listener) {
|
|
285
|
+
if (disposed)
|
|
286
|
+
return () => undefined;
|
|
287
|
+
const unsubscribe = subscribeDocumentRevision(config.document, (revisions) => {
|
|
288
|
+
if (!disposed)
|
|
289
|
+
notifyRevision(listener, revisions, tokenGeneration);
|
|
290
|
+
});
|
|
291
|
+
revisionUnsubscribers.add(unsubscribe);
|
|
292
|
+
return () => {
|
|
293
|
+
unsubscribe();
|
|
294
|
+
revisionUnsubscribers.delete(unsubscribe);
|
|
295
|
+
};
|
|
296
|
+
},
|
|
297
|
+
notifyStylesheetChange() {
|
|
298
|
+
if (!disposed)
|
|
299
|
+
invalidateStyleResolutionCache(config.document);
|
|
300
|
+
},
|
|
301
|
+
prewarmRules() {
|
|
302
|
+
if (!disposed)
|
|
303
|
+
prewarmCssomRuleSnapshot(config.document);
|
|
304
|
+
},
|
|
305
|
+
dispose() {
|
|
306
|
+
if (disposed)
|
|
307
|
+
return;
|
|
308
|
+
disposed = true;
|
|
309
|
+
revisionUnsubscribers.forEach((unsubscribe) => unsubscribe());
|
|
310
|
+
revisionUnsubscribers.clear();
|
|
311
|
+
mediaCleanup.forEach((cleanup) => cleanup());
|
|
312
|
+
mediaCleanup.length = 0;
|
|
313
|
+
releaseDocumentResolution();
|
|
314
|
+
},
|
|
315
|
+
};
|
|
316
|
+
return session;
|
|
317
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type BrowserCssInspection, type BrowserTokenKnowledge } from "./browserCssInspection.js";
|
|
2
|
+
/**
|
|
3
|
+
* Binds a document to token knowledge. When generation changes, the previous
|
|
4
|
+
* session is disposed and replaced so callers never keep a stale catalog.
|
|
5
|
+
*/
|
|
6
|
+
export declare function bindBrowserCssInspection(doc: Document, knowledge: BrowserTokenKnowledge): BrowserCssInspection;
|
|
7
|
+
/** Returns the one browser inspection session owned by a document. */
|
|
8
|
+
export declare function getBrowserCssInspection(doc?: Document): BrowserCssInspection;
|
|
9
|
+
/** Invalidates every browser-inspection snapshot affected by a CSSOM write. */
|
|
10
|
+
export declare function notifyBrowserStylesheetChange(doc?: Document): void;
|
|
11
|
+
/** Releases a document session when its inspector/Canvas lifecycle ends. */
|
|
12
|
+
export declare function disposeBrowserCssInspection(doc: Document): void;
|