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,240 @@
|
|
|
1
|
+
import { getElementComputedStyle } from "../runtime/domRealm.js";
|
|
2
|
+
import { notifyBrowserStylesheetChange } from "../inspection/browserCssInspectionRegistry.js";
|
|
3
|
+
import { escapeAttrValue, escapeCssString } from "./cssEscapes.js";
|
|
4
|
+
import { isNudgeUiDev } from "../runtime/devFlag.js";
|
|
5
|
+
export { escapeAttrValue, escapeCssString } from "./cssEscapes.js";
|
|
6
|
+
const SHEET_ID = "nudge-ui-styles";
|
|
7
|
+
let managedHeadGuardDocument = null;
|
|
8
|
+
let managedHeadGuard = null;
|
|
9
|
+
let failedRehydrationCssText = null;
|
|
10
|
+
function installManagedHeadGuard(doc) {
|
|
11
|
+
const Observer = doc.defaultView?.MutationObserver;
|
|
12
|
+
if (!Observer || !doc.head || managedHeadGuardDocument === doc)
|
|
13
|
+
return;
|
|
14
|
+
managedHeadGuard?.disconnect();
|
|
15
|
+
managedHeadGuardDocument = doc;
|
|
16
|
+
managedHeadGuard = new Observer(() => {
|
|
17
|
+
const managed = doc.getElementById(SHEET_ID);
|
|
18
|
+
if (managed && doc.head.lastElementChild !== managed) {
|
|
19
|
+
doc.head.appendChild(managed);
|
|
20
|
+
// SAFETY: managed was created via createElement("style"), so it is an HTMLStyleElement.
|
|
21
|
+
rehydrateManagedSheet(doc, managed);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
managedHeadGuard.observe(doc.head, { childList: true });
|
|
25
|
+
}
|
|
26
|
+
export function ensureManagedSheet() {
|
|
27
|
+
const doc = document;
|
|
28
|
+
// SAFETY: getElementById returns an Element; the managed style element is created as HTMLStyleElement when missing.
|
|
29
|
+
let el = doc.getElementById(SHEET_ID);
|
|
30
|
+
if (!el) {
|
|
31
|
+
el = doc.createElement("style");
|
|
32
|
+
el.id = SHEET_ID;
|
|
33
|
+
el.setAttribute("data-nudge-ui", "managed");
|
|
34
|
+
doc.head.appendChild(el);
|
|
35
|
+
}
|
|
36
|
+
let sheet = el.sheet;
|
|
37
|
+
if (!sheet) {
|
|
38
|
+
// A browser may reject a newly-authored conditional rule (or a test DOM may
|
|
39
|
+
// not implement it). Recreate the managed element so later clear/revert
|
|
40
|
+
// operations can always recover instead of leaving history wedged.
|
|
41
|
+
el.remove();
|
|
42
|
+
el = doc.createElement("style");
|
|
43
|
+
el.id = SHEET_ID;
|
|
44
|
+
el.setAttribute("data-nudge-ui", "managed");
|
|
45
|
+
doc.head.appendChild(el);
|
|
46
|
+
sheet = el.sheet;
|
|
47
|
+
}
|
|
48
|
+
if (!sheet) {
|
|
49
|
+
throw new Error("nudge-ui managed stylesheet could not be initialised");
|
|
50
|
+
}
|
|
51
|
+
if (doc.head.lastElementChild !== el) {
|
|
52
|
+
doc.head.appendChild(el);
|
|
53
|
+
rehydrateManagedSheet(doc, el);
|
|
54
|
+
}
|
|
55
|
+
installManagedHeadGuard(doc);
|
|
56
|
+
if (isNudgeUiDev() && doc.defaultView) {
|
|
57
|
+
// Keep the canonical CSS available to dev diagnostics.
|
|
58
|
+
doc.defaultView.__nudgeUiGetManagedSheetText = getManagedSheetText;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function buildDeclarationsBody(declarations) {
|
|
62
|
+
const parts = [];
|
|
63
|
+
for (const [property, value] of Object.entries(declarations)) {
|
|
64
|
+
const safeValue = String(value ?? "");
|
|
65
|
+
const safeProperty = String(property ?? "");
|
|
66
|
+
if (!safeProperty || !safeValue)
|
|
67
|
+
continue;
|
|
68
|
+
parts.push(`${safeProperty}: ${safeValue};`);
|
|
69
|
+
}
|
|
70
|
+
return parts.join(" ");
|
|
71
|
+
}
|
|
72
|
+
function buildRuleText(rule) {
|
|
73
|
+
const body = buildDeclarationsBody(rule.declarations);
|
|
74
|
+
if (!body)
|
|
75
|
+
return "";
|
|
76
|
+
let text = `${rule.selector} { ${body} }`;
|
|
77
|
+
for (const wrapper of [...(rule.context?.wrappers ?? [])].reverse()) {
|
|
78
|
+
text = `@${wrapper.kind} ${wrapper.params} { ${text} }`;
|
|
79
|
+
}
|
|
80
|
+
return text;
|
|
81
|
+
}
|
|
82
|
+
export function rulesToCssText(rules) {
|
|
83
|
+
const lines = [];
|
|
84
|
+
for (const rule of rules) {
|
|
85
|
+
const text = buildRuleText(rule);
|
|
86
|
+
if (text)
|
|
87
|
+
lines.push(text);
|
|
88
|
+
}
|
|
89
|
+
return lines.join("\n");
|
|
90
|
+
}
|
|
91
|
+
/** Canonical rules retained so a framework can rehydrate a moved style node. */
|
|
92
|
+
let managedRules = [];
|
|
93
|
+
/** Synchronous serialized view of the rules currently projected into the managed sheet. */
|
|
94
|
+
export function getManagedSheetText() {
|
|
95
|
+
return rulesToCssText(managedRules);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Rehydrate the CSSOM after moving the managed style element in <head>.
|
|
99
|
+
*
|
|
100
|
+
* Some browsers replace the CSSStyleSheet when that element is reattached.
|
|
101
|
+
* Rewriting the canonical text keeps the new sheet and the model aligned.
|
|
102
|
+
*/
|
|
103
|
+
function rehydrateManagedSheet(doc, el) {
|
|
104
|
+
const sheet = el.sheet;
|
|
105
|
+
if (!sheet)
|
|
106
|
+
return;
|
|
107
|
+
const rules = managedRules;
|
|
108
|
+
const cssText = rulesToCssText(rules);
|
|
109
|
+
if (sheet.cssRules.length === rules.length) {
|
|
110
|
+
failedRehydrationCssText = null;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (failedRehydrationCssText === cssText)
|
|
114
|
+
return;
|
|
115
|
+
el.textContent = cssText;
|
|
116
|
+
if (!el.sheet) {
|
|
117
|
+
failedRehydrationCssText = cssText;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
failedRehydrationCssText = el.sheet.cssRules.length === rules.length ? null : cssText;
|
|
121
|
+
notifyBrowserStylesheetChange(doc);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Writes the canonical projection to the managed style element and retains a
|
|
125
|
+
* copy for rehydration if a framework moves or reparses that element.
|
|
126
|
+
*/
|
|
127
|
+
function rebuildSheetText(rules) {
|
|
128
|
+
// SAFETY: getElementById returns an Element; the managed style element is created as HTMLStyleElement when missing.
|
|
129
|
+
const el = document.getElementById(SHEET_ID);
|
|
130
|
+
if (!el)
|
|
131
|
+
return;
|
|
132
|
+
const desired = rules.map((rule) => ({
|
|
133
|
+
...rule,
|
|
134
|
+
declarations: { ...rule.declarations },
|
|
135
|
+
}));
|
|
136
|
+
const cssText = rulesToCssText(desired);
|
|
137
|
+
const rulesChanged = rulesToCssText(managedRules) !== cssText;
|
|
138
|
+
const shouldRetryDroppedRules = el.sheet !== null
|
|
139
|
+
&& el.sheet.cssRules.length !== desired.length
|
|
140
|
+
&& failedRehydrationCssText !== cssText;
|
|
141
|
+
managedRules = desired;
|
|
142
|
+
if (!rulesChanged && el.textContent === cssText && !shouldRetryDroppedRules)
|
|
143
|
+
return;
|
|
144
|
+
el.textContent = cssText;
|
|
145
|
+
failedRehydrationCssText = el.sheet && el.sheet.cssRules.length !== desired.length
|
|
146
|
+
? cssText
|
|
147
|
+
: null;
|
|
148
|
+
notifyBrowserStylesheetChange(document);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Replaces the managed sheet with the canonical projection. Keeping the
|
|
152
|
+
* serialized rules authoritative avoids stale CSSStyleRule references when a
|
|
153
|
+
* framework dev server reparses or reattaches style nodes during a render.
|
|
154
|
+
*/
|
|
155
|
+
export function applyRules(rules) {
|
|
156
|
+
ensureManagedSheet();
|
|
157
|
+
const desired = [];
|
|
158
|
+
const desiredIds = new Set();
|
|
159
|
+
for (const rule of rules) {
|
|
160
|
+
const id = buildRuleText(rule);
|
|
161
|
+
if (!id)
|
|
162
|
+
continue;
|
|
163
|
+
if (desiredIds.has(id))
|
|
164
|
+
continue;
|
|
165
|
+
desiredIds.add(id);
|
|
166
|
+
desired.push(rule);
|
|
167
|
+
}
|
|
168
|
+
rebuildSheetText(desired);
|
|
169
|
+
}
|
|
170
|
+
function commaListIncludes(value, property) {
|
|
171
|
+
return value.split(",").map((part) => part.trim()).some((part) => part === "all" || part === property);
|
|
172
|
+
}
|
|
173
|
+
function hasImportantAuthorRule(el, property) {
|
|
174
|
+
for (const sheet of Array.from(el.ownerDocument.styleSheets)) {
|
|
175
|
+
let rules;
|
|
176
|
+
try {
|
|
177
|
+
rules = sheet.cssRules;
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
for (const rule of Array.from(rules)) {
|
|
183
|
+
if (!(rule instanceof CSSStyleRule))
|
|
184
|
+
continue;
|
|
185
|
+
try {
|
|
186
|
+
if (el.matches(rule.selectorText) && rule.style.getPropertyPriority(property) === "important")
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
catch { /* Ignore browser-specific selectors. */ }
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
/** Verify what the browser painted after the managed sheet was projected. */
|
|
195
|
+
export function verifyPreview(el, property, requestedValue) {
|
|
196
|
+
if (!el || !el.isConnected) {
|
|
197
|
+
return { requestedValue, computedValue: "", status: "conflict", reason: "target-missing" };
|
|
198
|
+
}
|
|
199
|
+
const computed = getElementComputedStyle(el);
|
|
200
|
+
const computedValue = computed.getPropertyValue(property).trim();
|
|
201
|
+
const doc = el.ownerDocument;
|
|
202
|
+
const probe = doc.createElement(property.startsWith("--") ? "span" : el.tagName.toLowerCase());
|
|
203
|
+
probe.setAttribute("data-nudge-ui", "value-probe");
|
|
204
|
+
probe.style.setProperty(property, requestedValue);
|
|
205
|
+
probe.style.setProperty("position", "fixed", "important");
|
|
206
|
+
probe.style.setProperty("visibility", "hidden", "important");
|
|
207
|
+
probe.removeAttribute("id");
|
|
208
|
+
if (property.startsWith("--"))
|
|
209
|
+
el.appendChild(probe);
|
|
210
|
+
else
|
|
211
|
+
el.parentElement?.insertBefore(probe, el.nextSibling);
|
|
212
|
+
if (!probe.isConnected)
|
|
213
|
+
doc.body.appendChild(probe);
|
|
214
|
+
const expectedValue = getElementComputedStyle(probe).getPropertyValue(property).trim() || requestedValue.trim();
|
|
215
|
+
probe.remove();
|
|
216
|
+
if (computedValue === expectedValue)
|
|
217
|
+
return { requestedValue, computedValue, status: "applied" };
|
|
218
|
+
let reason = "higher-specificity";
|
|
219
|
+
if (el.style.getPropertyPriority(property) === "important" || hasImportantAuthorRule(el, property))
|
|
220
|
+
reason = "important";
|
|
221
|
+
else if (el.style.getPropertyValue(property))
|
|
222
|
+
reason = "inline-style";
|
|
223
|
+
else if (typeof el.getAnimations === "function" && el.getAnimations().some((animation) => animation.playState !== "finished"))
|
|
224
|
+
reason = "animation";
|
|
225
|
+
else {
|
|
226
|
+
const transitionProperty = computed.transitionProperty || el.style.transitionProperty;
|
|
227
|
+
const transitionDuration = computed.transitionDuration || el.style.transitionDuration;
|
|
228
|
+
if (commaListIncludes(transitionProperty, property) && transitionDuration !== "0s" && transitionDuration !== "")
|
|
229
|
+
reason = "transition";
|
|
230
|
+
}
|
|
231
|
+
return { requestedValue, computedValue, status: "conflict", reason };
|
|
232
|
+
}
|
|
233
|
+
export function removeManagedSheet() {
|
|
234
|
+
const el = document.getElementById(SHEET_ID);
|
|
235
|
+
if (el)
|
|
236
|
+
el.remove();
|
|
237
|
+
managedRules = [];
|
|
238
|
+
failedRehydrationCssText = null;
|
|
239
|
+
notifyBrowserStylesheetChange(document);
|
|
240
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { RenderedInstanceOverride, RenderedInstanceRef } from "../changes/editModel.js";
|
|
2
|
+
export { isRenderedInstanceOverride, isRenderedInstanceRef } from "../changes/editModel.js";
|
|
3
|
+
export type { RenderedInstanceOverride, RenderedInstanceRef, SourceSiteRef } from "../changes/editModel.js";
|
|
4
|
+
export type ResolutionResult = {
|
|
5
|
+
status: "resolved";
|
|
6
|
+
element: HTMLElement;
|
|
7
|
+
} | {
|
|
8
|
+
status: "missing";
|
|
9
|
+
} | {
|
|
10
|
+
status: "ambiguous";
|
|
11
|
+
};
|
|
12
|
+
export type DocumentProjectionStatus = "applied" | "missing" | "ambiguous" | "overridden";
|
|
13
|
+
export interface DocumentProjectionReport {
|
|
14
|
+
overrideId: string;
|
|
15
|
+
status: DocumentProjectionStatus;
|
|
16
|
+
}
|
|
17
|
+
export interface RenderedInstanceChangeDiagnostic extends DocumentProjectionReport {
|
|
18
|
+
document: "Inspect" | `Canvas ${string}`;
|
|
19
|
+
}
|
|
20
|
+
/** Captures conservative, serializable identity at the moment of the action. */
|
|
21
|
+
export declare function captureRenderedInstance(el: HTMLElement): RenderedInstanceRef | null;
|
|
22
|
+
/**
|
|
23
|
+
* Resolves exactly one element, or declines to apply. Occurrence documents the
|
|
24
|
+
* captured placement, but structural previews can legitimately change it.
|
|
25
|
+
* Evidence must therefore identify one current candidate before an edit can
|
|
26
|
+
* be applied.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveRenderedInstance(doc: Document, ref: RenderedInstanceRef): ResolutionResult;
|
|
29
|
+
/** Checks stable source/evidence fields without treating a post-move ordinal as identity. */
|
|
30
|
+
export declare function matchesRenderedInstanceEvidence(el: HTMLElement, ref: RenderedInstanceRef): boolean;
|
|
31
|
+
/** Builds an instance override without changing the element's transient edit scope. */
|
|
32
|
+
export declare function buildRenderedInstanceOverride(el: HTMLElement): RenderedInstanceOverride | null;
|
|
33
|
+
/** Creates a serializable override for identity that was already validated. */
|
|
34
|
+
export declare function buildRenderedInstanceOverrideForTarget(target: RenderedInstanceRef): RenderedInstanceOverride;
|
|
35
|
+
export declare function createRenderedInstanceOverride(el: HTMLElement): RenderedInstanceOverride | null;
|
|
36
|
+
/** Returns an active transient target or the canonical target projected here. */
|
|
37
|
+
export declare function getRenderedInstanceOverride(el: HTMLElement): RenderedInstanceOverride | null;
|
|
38
|
+
export declare function clearRenderedInstanceOverride(el: HTMLElement): RenderedInstanceOverride | null;
|
|
39
|
+
export declare function instanceSelector(override: RenderedInstanceOverride): string | null;
|
|
40
|
+
/** Extracts the distinct canonical targets which renderers must resolve. */
|
|
41
|
+
export declare function collectRenderedInstanceOverrides(changes: ReadonlyArray<unknown>): RenderedInstanceOverride[];
|
|
42
|
+
/**
|
|
43
|
+
* The document-projection adapter only applies a new canonical snapshot. A
|
|
44
|
+
* later reconciliation changes diagnostics but never starts a reapply loop.
|
|
45
|
+
*/
|
|
46
|
+
export declare function applyRenderedInstanceProjection(doc: Document, overrides: ReadonlyArray<RenderedInstanceOverride>): DocumentProjectionReport[];
|
|
47
|
+
export declare function getRenderedInstanceProjectionReports(doc: Document): readonly DocumentProjectionReport[];
|
|
48
|
+
/** Diagnostics arrive independently when a renderer reports or React reconciles. */
|
|
49
|
+
export declare function subscribeRenderedInstanceDiagnostics(listener: () => void): () => void;
|
|
50
|
+
export declare function getRenderedInstanceDiagnosticRevision(): number;
|
|
51
|
+
export declare function recordCanvasRenderedInstanceProjectionReports(cardId: string, revision: number, reports: readonly DocumentProjectionReport[]): void;
|
|
52
|
+
export declare function clearCanvasRenderedInstanceProjectionReports(cardId: string): void;
|
|
53
|
+
export declare function getRenderedInstanceChangeDiagnostics(overrideId: string): RenderedInstanceChangeDiagnostic[];
|
|
54
|
+
export declare function isDocumentProjectionReport(value: unknown): value is DocumentProjectionReport;
|
|
55
|
+
/** Test hook for module-local controller state. */
|
|
56
|
+
export declare function resetRenderedInstanceState(): void;
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { escapeAttrValue } from "./cssEscapes.js";
|
|
2
|
+
import { isNudgeUiDev } from "../runtime/devFlag.js";
|
|
3
|
+
import { sourceSiteSelector } from "../selection/sourceSite.js";
|
|
4
|
+
import { isRenderedInstanceOverride } from "../changes/editModel.js";
|
|
5
|
+
export { isRenderedInstanceOverride, isRenderedInstanceRef } from "../changes/editModel.js";
|
|
6
|
+
const PROJECTION_ATTR = "data-projection-instance";
|
|
7
|
+
let nextOverrideId = 1;
|
|
8
|
+
let transientTargets = new WeakMap();
|
|
9
|
+
let canonicalOverrides = new Map();
|
|
10
|
+
let reportsByDocument = new WeakMap();
|
|
11
|
+
const documentStates = new Map();
|
|
12
|
+
const reportsByCanvasCard = new Map();
|
|
13
|
+
const diagnosticListeners = new Set();
|
|
14
|
+
let diagnosticRevision = 0;
|
|
15
|
+
function normalizedText(el) {
|
|
16
|
+
return el.textContent?.replace(/\s+/g, " ").trim().slice(0, 120) || null;
|
|
17
|
+
}
|
|
18
|
+
function candidates(doc, sourceSite) {
|
|
19
|
+
const selector = sourceSiteSelector(sourceSite.cid, sourceSite.src);
|
|
20
|
+
if (!selector)
|
|
21
|
+
return [];
|
|
22
|
+
try {
|
|
23
|
+
return Array.from(doc.querySelectorAll(selector));
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** Captures conservative, serializable identity at the moment of the action. */
|
|
30
|
+
export function captureRenderedInstance(el) {
|
|
31
|
+
const cid = el.getAttribute("data-cid") ?? "";
|
|
32
|
+
const src = el.getAttribute("data-src") ?? "";
|
|
33
|
+
const sourceSite = { cid, src };
|
|
34
|
+
const sourceCandidates = candidates(el.ownerDocument, sourceSite);
|
|
35
|
+
const occurrence = sourceCandidates.indexOf(el);
|
|
36
|
+
if (!cid || occurrence < 0)
|
|
37
|
+
return null;
|
|
38
|
+
return {
|
|
39
|
+
sourceSite,
|
|
40
|
+
locator: {
|
|
41
|
+
kind: "evidence",
|
|
42
|
+
occurrence,
|
|
43
|
+
props: el.getAttribute("data-cprops"),
|
|
44
|
+
text: normalizedText(el),
|
|
45
|
+
ariaLabel: el.getAttribute("aria-label"),
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Resolves exactly one element, or declines to apply. Occurrence documents the
|
|
51
|
+
* captured placement, but structural previews can legitimately change it.
|
|
52
|
+
* Evidence must therefore identify one current candidate before an edit can
|
|
53
|
+
* be applied.
|
|
54
|
+
*/
|
|
55
|
+
export function resolveRenderedInstance(doc, ref) {
|
|
56
|
+
const sourceCandidates = candidates(doc, ref.sourceSite);
|
|
57
|
+
const { props, text, ariaLabel = null } = ref.locator;
|
|
58
|
+
// An ordinal alone is not an identity for a repeated source site.
|
|
59
|
+
if (sourceCandidates.length > 1 && props === null && text === null && ariaLabel === null) {
|
|
60
|
+
return { status: "ambiguous" };
|
|
61
|
+
}
|
|
62
|
+
const matchingEvidence = sourceCandidates.filter((element) => element.getAttribute("data-cprops") === props
|
|
63
|
+
&& normalizedText(element) === text
|
|
64
|
+
&& element.getAttribute("aria-label") === ariaLabel);
|
|
65
|
+
if (matchingEvidence.length === 0)
|
|
66
|
+
return { status: "missing" };
|
|
67
|
+
// Evidence alone is never enough to choose between two identical rendered
|
|
68
|
+
// outputs. This is particularly important for structural anchors: applying
|
|
69
|
+
// one move to an arbitrary identical parent would reorder the wrong group.
|
|
70
|
+
if (matchingEvidence.length > 1)
|
|
71
|
+
return { status: "ambiguous" };
|
|
72
|
+
return { status: "resolved", element: matchingEvidence[0] };
|
|
73
|
+
}
|
|
74
|
+
/** Checks stable source/evidence fields without treating a post-move ordinal as identity. */
|
|
75
|
+
export function matchesRenderedInstanceEvidence(el, ref) {
|
|
76
|
+
const { props, text, ariaLabel = null } = ref.locator;
|
|
77
|
+
return el.getAttribute("data-cid") === ref.sourceSite.cid
|
|
78
|
+
&& el.getAttribute("data-src") === ref.sourceSite.src
|
|
79
|
+
&& el.getAttribute("data-cprops") === props
|
|
80
|
+
&& normalizedText(el) === text
|
|
81
|
+
&& el.getAttribute("aria-label") === ariaLabel;
|
|
82
|
+
}
|
|
83
|
+
/** Builds an instance override without changing the element's transient edit scope. */
|
|
84
|
+
export function buildRenderedInstanceOverride(el) {
|
|
85
|
+
const target = captureRenderedInstance(el);
|
|
86
|
+
if (!target)
|
|
87
|
+
return null;
|
|
88
|
+
return buildRenderedInstanceOverrideForTarget(target);
|
|
89
|
+
}
|
|
90
|
+
/** Creates a serializable override for identity that was already validated. */
|
|
91
|
+
export function buildRenderedInstanceOverrideForTarget(target) {
|
|
92
|
+
return {
|
|
93
|
+
id: `override-${crypto.randomUUID?.() ?? nextOverrideId++}`,
|
|
94
|
+
target,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export function createRenderedInstanceOverride(el) {
|
|
98
|
+
const override = buildRenderedInstanceOverride(el);
|
|
99
|
+
if (!override)
|
|
100
|
+
return null;
|
|
101
|
+
transientTargets.set(el, override);
|
|
102
|
+
return override;
|
|
103
|
+
}
|
|
104
|
+
/** Returns an active transient target or the canonical target projected here. */
|
|
105
|
+
export function getRenderedInstanceOverride(el) {
|
|
106
|
+
const transient = transientTargets.get(el);
|
|
107
|
+
if (transient)
|
|
108
|
+
return transient;
|
|
109
|
+
const id = el.getAttribute(PROJECTION_ATTR);
|
|
110
|
+
return id ? canonicalOverrides.get(id) ?? null : null;
|
|
111
|
+
}
|
|
112
|
+
export function clearRenderedInstanceOverride(el) {
|
|
113
|
+
const override = getRenderedInstanceOverride(el);
|
|
114
|
+
transientTargets.delete(el);
|
|
115
|
+
return override;
|
|
116
|
+
}
|
|
117
|
+
export function instanceSelector(override) {
|
|
118
|
+
const source = sourceSiteSelector(override.target.sourceSite.cid, override.target.sourceSite.src);
|
|
119
|
+
return source ? `${source}[${PROJECTION_ATTR}="${escapeAttrValue(override.id)}"]` : null;
|
|
120
|
+
}
|
|
121
|
+
/** Extracts the distinct canonical targets which renderers must resolve. */
|
|
122
|
+
export function collectRenderedInstanceOverrides(changes) {
|
|
123
|
+
const result = new Map();
|
|
124
|
+
for (const change of changes) {
|
|
125
|
+
if (!change || typeof change !== "object")
|
|
126
|
+
continue;
|
|
127
|
+
const candidate = change;
|
|
128
|
+
if (candidate.scope === "rendered-instance" && isRenderedInstanceOverride(candidate.instanceOverride)) {
|
|
129
|
+
result.set(candidate.instanceOverride.id, candidate.instanceOverride);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return [...result.values()];
|
|
133
|
+
}
|
|
134
|
+
function notifyDiagnostics() {
|
|
135
|
+
diagnosticRevision += 1;
|
|
136
|
+
for (const listener of diagnosticListeners)
|
|
137
|
+
listener();
|
|
138
|
+
}
|
|
139
|
+
function sameReports(a, b) {
|
|
140
|
+
return a.length === b.length && a.every((report, index) => report.overrideId === b[index]?.overrideId && report.status === b[index]?.status);
|
|
141
|
+
}
|
|
142
|
+
function reportsForSnapshot(state, overrides) {
|
|
143
|
+
return overrides.map((override) => ({
|
|
144
|
+
overrideId: override.id,
|
|
145
|
+
status: state.applied.get(override.id)?.status ?? "missing",
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
function storeReports(doc, reports) {
|
|
149
|
+
const before = reportsByDocument.get(doc) ?? [];
|
|
150
|
+
reportsByDocument.set(doc, reports);
|
|
151
|
+
if (!sameReports(before, reports))
|
|
152
|
+
notifyDiagnostics();
|
|
153
|
+
}
|
|
154
|
+
function validationStatus(doc, applied) {
|
|
155
|
+
if (applied.status === "overridden")
|
|
156
|
+
return "overridden";
|
|
157
|
+
if (!applied.element || !applied.element.isConnected
|
|
158
|
+
|| applied.element.getAttribute(PROJECTION_ATTR) !== applied.override.id)
|
|
159
|
+
return "overridden";
|
|
160
|
+
const resolved = resolveRenderedInstance(doc, applied.override.target);
|
|
161
|
+
return resolved.status === "resolved" && resolved.element === applied.element ? "applied" : "overridden";
|
|
162
|
+
}
|
|
163
|
+
function validateAppliedProjection(doc, state) {
|
|
164
|
+
let changed = false;
|
|
165
|
+
for (const applied of state.applied.values()) {
|
|
166
|
+
const status = validationStatus(doc, applied);
|
|
167
|
+
if (status !== applied.status) {
|
|
168
|
+
applied.status = status;
|
|
169
|
+
changed = true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (changed)
|
|
173
|
+
storeReports(doc, reportsForSnapshot(state, [...canonicalOverrides.values()]));
|
|
174
|
+
}
|
|
175
|
+
function scheduleValidation(doc, state) {
|
|
176
|
+
if (state.validationQueued || state.applied.size === 0)
|
|
177
|
+
return;
|
|
178
|
+
state.validationQueued = true;
|
|
179
|
+
queueMicrotask(() => {
|
|
180
|
+
state.validationQueued = false;
|
|
181
|
+
validateAppliedProjection(doc, state);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function getDocumentState(doc) {
|
|
185
|
+
let state = documentStates.get(doc);
|
|
186
|
+
if (state)
|
|
187
|
+
return state;
|
|
188
|
+
state = {
|
|
189
|
+
applied: new Map(),
|
|
190
|
+
snapshotKey: null,
|
|
191
|
+
observer: null,
|
|
192
|
+
validationQueued: false,
|
|
193
|
+
};
|
|
194
|
+
const Observer = doc.defaultView?.MutationObserver;
|
|
195
|
+
if (Observer && doc.documentElement) {
|
|
196
|
+
state.observer = new Observer(() => scheduleValidation(doc, state));
|
|
197
|
+
state.observer.observe(doc.documentElement, {
|
|
198
|
+
childList: true,
|
|
199
|
+
subtree: true,
|
|
200
|
+
characterData: true,
|
|
201
|
+
attributes: true,
|
|
202
|
+
attributeFilter: ["data-cid", "data-src", "data-cprops", "aria-label", PROJECTION_ATTR],
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
documentStates.set(doc, state);
|
|
206
|
+
return state;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The document-projection adapter only applies a new canonical snapshot. A
|
|
210
|
+
* later reconciliation changes diagnostics but never starts a reapply loop.
|
|
211
|
+
*/
|
|
212
|
+
export function applyRenderedInstanceProjection(doc, overrides) {
|
|
213
|
+
if (!isNudgeUiDev())
|
|
214
|
+
return [];
|
|
215
|
+
const state = getDocumentState(doc);
|
|
216
|
+
canonicalOverrides = new Map(overrides.map((override) => [override.id, override]));
|
|
217
|
+
const key = JSON.stringify(overrides);
|
|
218
|
+
if (state.snapshotKey === key) {
|
|
219
|
+
const reports = reportsForSnapshot(state, overrides);
|
|
220
|
+
storeReports(doc, reports);
|
|
221
|
+
return reports;
|
|
222
|
+
}
|
|
223
|
+
for (const marker of Array.from(doc.querySelectorAll(`[${PROJECTION_ATTR}]`))) {
|
|
224
|
+
marker.removeAttribute(PROJECTION_ATTR);
|
|
225
|
+
}
|
|
226
|
+
state.applied.clear();
|
|
227
|
+
state.snapshotKey = key;
|
|
228
|
+
for (const override of overrides) {
|
|
229
|
+
const resolved = resolveRenderedInstance(doc, override.target);
|
|
230
|
+
if (resolved.status === "resolved") {
|
|
231
|
+
resolved.element.setAttribute(PROJECTION_ATTR, override.id);
|
|
232
|
+
state.applied.set(override.id, { override, element: resolved.element, status: "applied" });
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
state.applied.set(override.id, { override, element: null, status: resolved.status });
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
const reports = reportsForSnapshot(state, overrides);
|
|
239
|
+
storeReports(doc, reports);
|
|
240
|
+
return reports;
|
|
241
|
+
}
|
|
242
|
+
export function getRenderedInstanceProjectionReports(doc) {
|
|
243
|
+
return reportsByDocument.get(doc) ?? [];
|
|
244
|
+
}
|
|
245
|
+
/** Diagnostics arrive independently when a renderer reports or React reconciles. */
|
|
246
|
+
export function subscribeRenderedInstanceDiagnostics(listener) {
|
|
247
|
+
diagnosticListeners.add(listener);
|
|
248
|
+
return () => diagnosticListeners.delete(listener);
|
|
249
|
+
}
|
|
250
|
+
export function getRenderedInstanceDiagnosticRevision() {
|
|
251
|
+
return diagnosticRevision;
|
|
252
|
+
}
|
|
253
|
+
export function recordCanvasRenderedInstanceProjectionReports(cardId, revision, reports) {
|
|
254
|
+
if (!Number.isSafeInteger(revision) || revision < 0 || !reports.every(isDocumentProjectionReport))
|
|
255
|
+
return;
|
|
256
|
+
const expected = new Set(canonicalOverrides.keys());
|
|
257
|
+
if (reports.length !== expected.size || new Set(reports.map((report) => report.overrideId)).size !== reports.length
|
|
258
|
+
|| reports.some((report) => !expected.has(report.overrideId)))
|
|
259
|
+
return;
|
|
260
|
+
const existing = reportsByCanvasCard.get(cardId);
|
|
261
|
+
if (existing && revision < existing.revision)
|
|
262
|
+
return;
|
|
263
|
+
const next = reports.map((report) => ({ ...report }));
|
|
264
|
+
if (existing && existing.revision === revision && sameReports(existing.reports, next))
|
|
265
|
+
return;
|
|
266
|
+
reportsByCanvasCard.set(cardId, { revision, reports: next });
|
|
267
|
+
notifyDiagnostics();
|
|
268
|
+
}
|
|
269
|
+
export function clearCanvasRenderedInstanceProjectionReports(cardId) {
|
|
270
|
+
if (!reportsByCanvasCard.delete(cardId))
|
|
271
|
+
return;
|
|
272
|
+
notifyDiagnostics();
|
|
273
|
+
}
|
|
274
|
+
export function getRenderedInstanceChangeDiagnostics(overrideId) {
|
|
275
|
+
const diagnostics = [];
|
|
276
|
+
const host = reportsByDocument.get(document)?.find((report) => report.overrideId === overrideId);
|
|
277
|
+
if (host)
|
|
278
|
+
diagnostics.push({ ...host, document: "Inspect" });
|
|
279
|
+
for (const [cardId, entry] of reportsByCanvasCard) {
|
|
280
|
+
const report = entry.reports.find((candidate) => candidate.overrideId === overrideId);
|
|
281
|
+
if (report)
|
|
282
|
+
diagnostics.push({ ...report, document: `Canvas ${cardId}` });
|
|
283
|
+
}
|
|
284
|
+
return diagnostics;
|
|
285
|
+
}
|
|
286
|
+
export function isDocumentProjectionReport(value) {
|
|
287
|
+
if (!value || typeof value !== "object")
|
|
288
|
+
return false;
|
|
289
|
+
const report = value;
|
|
290
|
+
return Object.keys(report).every((key) => key === "overrideId" || key === "status")
|
|
291
|
+
&& typeof report.overrideId === "string"
|
|
292
|
+
&& (report.status === "applied" || report.status === "missing"
|
|
293
|
+
|| report.status === "ambiguous" || report.status === "overridden");
|
|
294
|
+
}
|
|
295
|
+
/** Test hook for module-local controller state. */
|
|
296
|
+
export function resetRenderedInstanceState() {
|
|
297
|
+
for (const state of documentStates.values())
|
|
298
|
+
state.observer?.disconnect();
|
|
299
|
+
documentStates.clear();
|
|
300
|
+
nextOverrideId = 1;
|
|
301
|
+
transientTargets = new WeakMap();
|
|
302
|
+
canonicalOverrides = new Map();
|
|
303
|
+
reportsByDocument = new WeakMap();
|
|
304
|
+
reportsByCanvasCard.clear();
|
|
305
|
+
diagnosticRevision = 0;
|
|
306
|
+
}
|