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,140 @@
|
|
|
1
|
+
import { getRenderedInstanceOverride, createRenderedInstanceOverride, buildRenderedInstanceOverrideForTarget, captureRenderedInstance, clearRenderedInstanceOverride, resolveRenderedInstance, } from "../projection/renderedInstance.js";
|
|
2
|
+
import { sourceSiteSelector } from "./sourceSite.js";
|
|
3
|
+
export { sourceSiteSelector } from "./sourceSite.js";
|
|
4
|
+
let sourceSiteMatchCounts = new WeakMap();
|
|
5
|
+
/** Test hook: clears the memoized source-site match counts. */
|
|
6
|
+
export function resetSourceSiteMatchCounts() {
|
|
7
|
+
sourceSiteMatchCounts = new WeakMap();
|
|
8
|
+
}
|
|
9
|
+
function querySourceSiteMatches(el) {
|
|
10
|
+
const cid = el.getAttribute("data-cid") ?? "";
|
|
11
|
+
const src = el.getAttribute("data-src") ?? "";
|
|
12
|
+
const selector = sourceSiteSelector(cid, src);
|
|
13
|
+
if (!selector)
|
|
14
|
+
return 0;
|
|
15
|
+
const doc = el.ownerDocument ?? document;
|
|
16
|
+
try {
|
|
17
|
+
return doc.querySelectorAll(selector).length;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Counts the rendered elements matching a source site. The result is memoized
|
|
25
|
+
* per (element identity, scope revision) so the selection render path no longer
|
|
26
|
+
* runs a full-document querySelectorAll on every render; it only recomputes
|
|
27
|
+
* when the caller's scope revision changes.
|
|
28
|
+
*/
|
|
29
|
+
export function countSourceSiteMatches(el, revision = 0) {
|
|
30
|
+
const cid = el.getAttribute("data-cid") ?? "";
|
|
31
|
+
const src = el.getAttribute("data-src") ?? "";
|
|
32
|
+
const doc = el.ownerDocument ?? document;
|
|
33
|
+
const key = `${cid}\u0000${src}\u0000${revision}`;
|
|
34
|
+
let documentCache = sourceSiteMatchCounts.get(doc);
|
|
35
|
+
if (!documentCache) {
|
|
36
|
+
documentCache = new WeakMap();
|
|
37
|
+
sourceSiteMatchCounts.set(doc, documentCache);
|
|
38
|
+
}
|
|
39
|
+
let cache = documentCache.get(el);
|
|
40
|
+
if (!cache) {
|
|
41
|
+
cache = new Map();
|
|
42
|
+
documentCache.set(el, cache);
|
|
43
|
+
}
|
|
44
|
+
const cached = cache.get(key);
|
|
45
|
+
if (cached !== undefined)
|
|
46
|
+
return cached;
|
|
47
|
+
const count = querySourceSiteMatches(el);
|
|
48
|
+
if (cache.size >= 4096)
|
|
49
|
+
cache.clear();
|
|
50
|
+
cache.set(key, count);
|
|
51
|
+
return count;
|
|
52
|
+
}
|
|
53
|
+
export function unlinkElement(el) {
|
|
54
|
+
return getRenderedInstanceOverride(el)?.id ?? createRenderedInstanceOverride(el)?.id ?? null;
|
|
55
|
+
}
|
|
56
|
+
export function relinkElement(el) {
|
|
57
|
+
return clearRenderedInstanceOverride(el)?.id ?? null;
|
|
58
|
+
}
|
|
59
|
+
export function getEditScope(el) {
|
|
60
|
+
return getRenderedInstanceOverride(el) ? "rendered-instance" : "source-site";
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Plans the scope for every target in a batch edit without mutating the DOM or
|
|
64
|
+
* transient instance state. A partial repeated-source group is editable only
|
|
65
|
+
* when each selected output has evidence that resolves uniquely.
|
|
66
|
+
*/
|
|
67
|
+
function analyzeBatchEditScopes(selectedElements) {
|
|
68
|
+
const plan = new Map();
|
|
69
|
+
if (selectedElements.length <= 1) {
|
|
70
|
+
for (const element of selectedElements) {
|
|
71
|
+
const existing = getRenderedInstanceOverride(element);
|
|
72
|
+
plan.set(element, existing
|
|
73
|
+
? { scope: "rendered-instance", instanceOverride: existing }
|
|
74
|
+
: { scope: "source-site" });
|
|
75
|
+
}
|
|
76
|
+
return plan;
|
|
77
|
+
}
|
|
78
|
+
const selectedBySource = new Map();
|
|
79
|
+
for (const element of selectedElements) {
|
|
80
|
+
const selector = selectorForElement(element);
|
|
81
|
+
if (selector)
|
|
82
|
+
selectedBySource.set(selector, (selectedBySource.get(selector) ?? 0) + 1);
|
|
83
|
+
}
|
|
84
|
+
for (const element of selectedElements) {
|
|
85
|
+
const existing = getRenderedInstanceOverride(element);
|
|
86
|
+
if (existing) {
|
|
87
|
+
plan.set(element, { scope: "rendered-instance", instanceOverride: existing });
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const selector = selectorForElement(element);
|
|
91
|
+
if (!selector) {
|
|
92
|
+
plan.set(element, { scope: "source-site" });
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const selectedForSource = selectedBySource.get(selector) ?? 0;
|
|
96
|
+
const totalForSource = querySourceSiteMatches(element);
|
|
97
|
+
if (totalForSource <= 1 || selectedForSource >= totalForSource) {
|
|
98
|
+
plan.set(element, { scope: "source-site" });
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const target = captureRenderedInstance(element);
|
|
102
|
+
if (!target)
|
|
103
|
+
return null;
|
|
104
|
+
const resolution = resolveRenderedInstance(element.ownerDocument, target);
|
|
105
|
+
if (resolution.status !== "resolved" || resolution.element !== element)
|
|
106
|
+
return null;
|
|
107
|
+
plan.set(element, { scope: "new-rendered-instance", target });
|
|
108
|
+
}
|
|
109
|
+
return plan;
|
|
110
|
+
}
|
|
111
|
+
/** Returns whether every element can be addressed safely by one batch edit. */
|
|
112
|
+
export function canPlanBatchEditScopes(selectedElements) {
|
|
113
|
+
return analyzeBatchEditScopes(selectedElements) !== null;
|
|
114
|
+
}
|
|
115
|
+
/** Resolves safe scopes immediately before a write is committed. */
|
|
116
|
+
export function planBatchEditScopes(selectedElements) {
|
|
117
|
+
const decisions = analyzeBatchEditScopes(selectedElements);
|
|
118
|
+
if (!decisions)
|
|
119
|
+
return null;
|
|
120
|
+
const plan = new Map();
|
|
121
|
+
for (const [element, decision] of decisions) {
|
|
122
|
+
plan.set(element, decision.scope === "new-rendered-instance"
|
|
123
|
+
? {
|
|
124
|
+
scope: "rendered-instance",
|
|
125
|
+
instanceOverride: buildRenderedInstanceOverrideForTarget(decision.target),
|
|
126
|
+
}
|
|
127
|
+
: decision);
|
|
128
|
+
}
|
|
129
|
+
return plan;
|
|
130
|
+
}
|
|
131
|
+
export function selectorForElement(el) {
|
|
132
|
+
return sourceSiteSelector(el.getAttribute("data-cid") ?? "", el.getAttribute("data-src") ?? "");
|
|
133
|
+
}
|
|
134
|
+
export function getInstanceEvidence(el) {
|
|
135
|
+
const selector = sourceSiteSelector(el.getAttribute("data-cid") ?? "", el.getAttribute("data-src") ?? "");
|
|
136
|
+
const matches = selector ? Array.from(el.ownerDocument.querySelectorAll(selector)) : [];
|
|
137
|
+
const renderedIndex = Math.max(0, matches.indexOf(el));
|
|
138
|
+
const text = el.textContent?.replace(/\s+/g, " ").trim().slice(0, 120) || null;
|
|
139
|
+
return { renderedIndex, props: el.getAttribute("data-cprops"), text, ariaLabel: el.getAttribute("aria-label") };
|
|
140
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A style edit target is deliberately smaller than the selection model. The
|
|
3
|
+
* editor only needs the rendered DOM nodes that will receive one declaration;
|
|
4
|
+
* source metadata and selection ordering stay inside the selection module.
|
|
5
|
+
*/
|
|
6
|
+
export type EditTarget = HTMLElement | readonly HTMLElement[];
|
|
7
|
+
export declare function targetElements(target: EditTarget): readonly HTMLElement[];
|
|
8
|
+
export declare function isMultiTarget(target: EditTarget): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function isElementList(target) {
|
|
2
|
+
return Array.isArray(target);
|
|
3
|
+
}
|
|
4
|
+
export function targetElements(target) {
|
|
5
|
+
if (isElementList(target))
|
|
6
|
+
return target;
|
|
7
|
+
return [target];
|
|
8
|
+
}
|
|
9
|
+
export function isMultiTarget(target) {
|
|
10
|
+
return targetElements(target).length > 1;
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function computeHierarchy(el: HTMLElement): HTMLElement[];
|
|
2
|
+
export interface DescendantNode {
|
|
3
|
+
element: HTMLElement;
|
|
4
|
+
depth: number;
|
|
5
|
+
}
|
|
6
|
+
/** Returns the nearest tracked descendants, breadth-first and document-ordered. */
|
|
7
|
+
export declare function computeDescendants(el: HTMLElement, maxDepth?: number, maxNodes?: number): DescendantNode[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { isShadowRootInDocument } from "../runtime/domRealm.js";
|
|
2
|
+
function isInsideInspector(el) {
|
|
3
|
+
if (el.id === "nudge-ui-root")
|
|
4
|
+
return true;
|
|
5
|
+
if (el.closest("#nudge-ui-root"))
|
|
6
|
+
return true;
|
|
7
|
+
const root = el.getRootNode();
|
|
8
|
+
return isShadowRootInDocument(root, el.ownerDocument) && root.host.id === "nudge-ui-root";
|
|
9
|
+
}
|
|
10
|
+
export function computeHierarchy(el) {
|
|
11
|
+
if (isInsideInspector(el))
|
|
12
|
+
return [];
|
|
13
|
+
const chain = [];
|
|
14
|
+
let node = el;
|
|
15
|
+
while (node && node !== el.ownerDocument.body && node.tagName !== "BODY") {
|
|
16
|
+
if (node.id === "nudge-ui-root")
|
|
17
|
+
break;
|
|
18
|
+
if (node.hasAttribute("data-cid"))
|
|
19
|
+
chain.push(node);
|
|
20
|
+
node = node.parentElement;
|
|
21
|
+
}
|
|
22
|
+
return chain;
|
|
23
|
+
}
|
|
24
|
+
/** Returns the nearest tracked descendants, breadth-first and document-ordered. */
|
|
25
|
+
export function computeDescendants(el, maxDepth = 2, maxNodes = 2) {
|
|
26
|
+
if (maxDepth < 1 || maxNodes < 1)
|
|
27
|
+
return [];
|
|
28
|
+
const descendants = Array.from(el.querySelectorAll('[data-cid]'))
|
|
29
|
+
.map((element, order) => {
|
|
30
|
+
let depth = 1;
|
|
31
|
+
let ancestor = element.parentElement;
|
|
32
|
+
while (ancestor && ancestor !== el) {
|
|
33
|
+
if (ancestor.hasAttribute('data-cid'))
|
|
34
|
+
depth += 1;
|
|
35
|
+
ancestor = ancestor.parentElement;
|
|
36
|
+
}
|
|
37
|
+
return ancestor === el ? { element, depth, order } : null;
|
|
38
|
+
})
|
|
39
|
+
.filter((node) => node !== null && node.depth <= maxDepth)
|
|
40
|
+
.sort((left, right) => left.depth - right.depth || left.order - right.order);
|
|
41
|
+
return descendants.slice(0, maxNodes).map(({ element, depth }) => ({ element, depth }));
|
|
42
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SelectedElement } from "./selectionStore.js";
|
|
2
|
+
import { type SelectionTargetMode } from "./selectionTarget.js";
|
|
3
|
+
export interface ParsedSrc {
|
|
4
|
+
file: string;
|
|
5
|
+
line: number;
|
|
6
|
+
column: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function parseDataSrc(src: string): ParsedSrc | null;
|
|
9
|
+
export declare function resolveSelectionFromElement(el: HTMLElement): SelectedElement | null;
|
|
10
|
+
export declare function resolveSelectionFromEvent(e: MouseEvent, inspectorHost: Element, mode?: SelectionTargetMode): SelectedElement | null;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { inspectComponentTargets } from "../componentSemantics/index.js";
|
|
2
|
+
import { resolveSelectionTarget, selectionTargetMode } from "./selectionTarget.js";
|
|
3
|
+
const REACT_FIBER_KEY = /^__reactFiber\$/;
|
|
4
|
+
const REACT_INTERNAL_KEY = /^__reactInternalInstance\$/;
|
|
5
|
+
const SRC_PATTERN = /^(.*):(\d+):(\d+)$/;
|
|
6
|
+
export function parseDataSrc(src) {
|
|
7
|
+
const match = SRC_PATTERN.exec(src);
|
|
8
|
+
if (!match)
|
|
9
|
+
return null;
|
|
10
|
+
const file = match[1];
|
|
11
|
+
const line = Number(match[2]);
|
|
12
|
+
const column = Number(match[3]);
|
|
13
|
+
if (file === undefined || Number.isNaN(line) || Number.isNaN(column))
|
|
14
|
+
return null;
|
|
15
|
+
return { file, line, column };
|
|
16
|
+
}
|
|
17
|
+
function findReactFiber(el) {
|
|
18
|
+
const keys = Object.keys(el);
|
|
19
|
+
for (const key of keys) {
|
|
20
|
+
if (REACT_FIBER_KEY.test(key) || REACT_INTERNAL_KEY.test(key)) {
|
|
21
|
+
return Reflect.get(el, key);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
export function resolveSelectionFromElement(el) {
|
|
27
|
+
const componentTargets = inspectComponentTargets(el);
|
|
28
|
+
const nearestComponent = componentTargets[0];
|
|
29
|
+
const cid = el.getAttribute("data-cid") ?? nearestComponent?.meta.componentName ?? null;
|
|
30
|
+
if (!cid)
|
|
31
|
+
return null;
|
|
32
|
+
const src = el.getAttribute("data-src") ?? nearestComponent?.meta.callsiteId ?? "";
|
|
33
|
+
const parsed = parseDataSrc(src);
|
|
34
|
+
const cpropsAttr = el.getAttribute("data-cprops");
|
|
35
|
+
const fiber = findReactFiber(el);
|
|
36
|
+
return {
|
|
37
|
+
cid,
|
|
38
|
+
src,
|
|
39
|
+
cprops: cpropsAttr,
|
|
40
|
+
file: parsed?.file ?? src,
|
|
41
|
+
line: parsed?.line ?? 0,
|
|
42
|
+
column: parsed?.column ?? 0,
|
|
43
|
+
domElement: el,
|
|
44
|
+
fiber,
|
|
45
|
+
componentTargets,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function resolveSelectionFromEvent(e, inspectorHost, mode = selectionTargetMode(e)) {
|
|
49
|
+
const target = e.target;
|
|
50
|
+
if (!(target instanceof Element))
|
|
51
|
+
return null;
|
|
52
|
+
if (inspectorHost === target || inspectorHost.contains(target))
|
|
53
|
+
return null;
|
|
54
|
+
const root = target.getRootNode();
|
|
55
|
+
if (root instanceof ShadowRoot && root.host instanceof HTMLElement && root.host.id === "nudge-ui-root") {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const el = resolveSelectionTarget(target, mode);
|
|
59
|
+
return el ? resolveSelectionFromElement(el) : null;
|
|
60
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { RuntimeComponentTarget } from "../componentSemantics/types.js";
|
|
2
|
+
export interface SelectedElement {
|
|
3
|
+
cid: string;
|
|
4
|
+
src: string;
|
|
5
|
+
cprops: string | null;
|
|
6
|
+
file: string;
|
|
7
|
+
line: number;
|
|
8
|
+
column: number;
|
|
9
|
+
domElement: HTMLElement;
|
|
10
|
+
fiber?: unknown;
|
|
11
|
+
componentTargets: RuntimeComponentTarget[];
|
|
12
|
+
}
|
|
13
|
+
/** The ordered selection presented to the inspector. */
|
|
14
|
+
export interface Selection {
|
|
15
|
+
elements: readonly SelectedElement[];
|
|
16
|
+
primary: SelectedElement;
|
|
17
|
+
}
|
|
18
|
+
declare function subscribe(cb: () => void): () => void;
|
|
19
|
+
declare function getSelectedElement(): SelectedElement | null;
|
|
20
|
+
declare function getSelectedElements(): readonly SelectedElement[];
|
|
21
|
+
declare function getSelection(): Selection | null;
|
|
22
|
+
declare function getHierarchy(): HTMLElement[];
|
|
23
|
+
declare function getHierarchyIndex(): number;
|
|
24
|
+
export declare function setSelectedElement(el: SelectedElement | null): void;
|
|
25
|
+
/** Replaces the selection with one or more ordered targets. */
|
|
26
|
+
export declare function setSelectedElements(elements: readonly SelectedElement[]): void;
|
|
27
|
+
/** Adds or removes one target while keeping the toggled target primary. */
|
|
28
|
+
export declare function toggleSelectedElement(el: SelectedElement): void;
|
|
29
|
+
/** Removes one rendered node from the group, preserving the remaining order. */
|
|
30
|
+
export declare function removeSelectedElement(el: HTMLElement): void;
|
|
31
|
+
/** Refreshes metadata for one selected DOM node without collapsing a group. */
|
|
32
|
+
export declare function refreshSelectedElement(el: SelectedElement): void;
|
|
33
|
+
export declare function stepUp(): void;
|
|
34
|
+
export declare function stepDown(): void;
|
|
35
|
+
export declare function setHierarchyIndex(i: number): void;
|
|
36
|
+
export { subscribe, getSelectedElement, getSelectedElements, getSelection, getHierarchy, getHierarchyIndex, };
|
|
37
|
+
export declare function useSelectedElement(): SelectedElement | null;
|
|
38
|
+
export declare function useSelectedElements(): readonly SelectedElement[];
|
|
39
|
+
export declare function useSelection(): Selection | null;
|
|
40
|
+
export declare function useHierarchy(): HTMLElement[];
|
|
41
|
+
export declare function useHierarchyIndex(): number;
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
|
+
import { computeHierarchy } from "./hierarchy.js";
|
|
3
|
+
import { resolveSelectionFromElement } from "./resolveSelection.js";
|
|
4
|
+
let currentSelection = null;
|
|
5
|
+
const EMPTY_SELECTION = [];
|
|
6
|
+
let chain = [];
|
|
7
|
+
let index = 0;
|
|
8
|
+
const listeners = new Set();
|
|
9
|
+
function subscribe(cb) {
|
|
10
|
+
listeners.add(cb);
|
|
11
|
+
return () => {
|
|
12
|
+
listeners.delete(cb);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function getSelectedElement() {
|
|
16
|
+
return currentSelection?.primary ?? null;
|
|
17
|
+
}
|
|
18
|
+
function getSelectedElements() {
|
|
19
|
+
return currentSelection?.elements ?? EMPTY_SELECTION;
|
|
20
|
+
}
|
|
21
|
+
function getSelection() {
|
|
22
|
+
return currentSelection;
|
|
23
|
+
}
|
|
24
|
+
function getHierarchy() {
|
|
25
|
+
return chain;
|
|
26
|
+
}
|
|
27
|
+
function getHierarchyIndex() {
|
|
28
|
+
return index;
|
|
29
|
+
}
|
|
30
|
+
function notify() {
|
|
31
|
+
listeners.forEach((l) => l());
|
|
32
|
+
}
|
|
33
|
+
function sameComponentTargets(a, b) {
|
|
34
|
+
if (a.length !== b.length)
|
|
35
|
+
return false;
|
|
36
|
+
return a.every((left, index) => {
|
|
37
|
+
const right = b[index];
|
|
38
|
+
if (!right || left.framework !== right.framework)
|
|
39
|
+
return false;
|
|
40
|
+
const leftMeta = left.meta;
|
|
41
|
+
const rightMeta = right.meta;
|
|
42
|
+
if (leftMeta.callsiteId !== rightMeta.callsiteId
|
|
43
|
+
|| leftMeta.componentId !== rightMeta.componentId
|
|
44
|
+
|| leftMeta.componentName !== rightMeta.componentName
|
|
45
|
+
|| leftMeta.file !== rightMeta.file
|
|
46
|
+
|| leftMeta.line !== rightMeta.line
|
|
47
|
+
|| leftMeta.column !== rightMeta.column
|
|
48
|
+
|| JSON.stringify(leftMeta.authoredProps) !== JSON.stringify(rightMeta.authoredProps)) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
// Runtime props can contain React elements and fibers with circular or
|
|
52
|
+
// intentionally unstable object identities. Only primitive values are
|
|
53
|
+
// consumed by the editable component-prop controls, so compare those and
|
|
54
|
+
// ignore opaque values that cannot affect this panel.
|
|
55
|
+
const keys = new Set([...Object.keys(left.props), ...Object.keys(right.props)]);
|
|
56
|
+
for (const key of keys) {
|
|
57
|
+
const leftValue = left.props[key];
|
|
58
|
+
const rightValue = right.props[key];
|
|
59
|
+
const leftPrimitive = typeof leftValue === "string"
|
|
60
|
+
|| typeof leftValue === "number"
|
|
61
|
+
|| typeof leftValue === "boolean";
|
|
62
|
+
const rightPrimitive = typeof rightValue === "string"
|
|
63
|
+
|| typeof rightValue === "number"
|
|
64
|
+
|| typeof rightValue === "boolean";
|
|
65
|
+
if (leftPrimitive || rightPrimitive) {
|
|
66
|
+
if (leftValue !== rightValue)
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return true;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function sameResolvedMetadata(a, b) {
|
|
74
|
+
return a.cprops === b.cprops
|
|
75
|
+
&& a.file === b.file
|
|
76
|
+
&& a.line === b.line
|
|
77
|
+
&& a.column === b.column
|
|
78
|
+
&& sameComponentTargets(a.componentTargets, b.componentTargets);
|
|
79
|
+
}
|
|
80
|
+
export function setSelectedElement(el) {
|
|
81
|
+
if (!el) {
|
|
82
|
+
if (!currentSelection)
|
|
83
|
+
return;
|
|
84
|
+
currentSelection = null;
|
|
85
|
+
chain = [];
|
|
86
|
+
index = 0;
|
|
87
|
+
notify();
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const current = currentSelection?.primary ?? null;
|
|
91
|
+
if ((currentSelection?.elements.length ?? 0) > 1) {
|
|
92
|
+
// setSelectedElement is the replacement API used by an ordinary click,
|
|
93
|
+
// Canvas selection, and single-target actions. It must collapse a group
|
|
94
|
+
// even when the clicked node is already the primary target.
|
|
95
|
+
publishSelection([el], el);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (current === el)
|
|
99
|
+
return;
|
|
100
|
+
// Re-clicks and post-edit refreshes re-resolve a fresh object with the same
|
|
101
|
+
// source-site identity. Keep the existing selection and hierarchy step so
|
|
102
|
+
// the panel pipeline does not churn (including after step-up); edits still
|
|
103
|
+
// refresh the panel via the document revision subscription.
|
|
104
|
+
if (el && current
|
|
105
|
+
&& current.cid === el.cid
|
|
106
|
+
&& current.src === el.src
|
|
107
|
+
&& current.domElement === el.domElement) {
|
|
108
|
+
if (!sameResolvedMetadata(current, el)) {
|
|
109
|
+
currentSelection = { elements: [el], primary: el };
|
|
110
|
+
notify();
|
|
111
|
+
}
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
currentSelection = { elements: [el], primary: el };
|
|
115
|
+
chain = computeHierarchy(el.domElement);
|
|
116
|
+
index = 0;
|
|
117
|
+
notify();
|
|
118
|
+
}
|
|
119
|
+
function sameSelection(left, right) {
|
|
120
|
+
if (left === right)
|
|
121
|
+
return true;
|
|
122
|
+
if (!left || !right)
|
|
123
|
+
return false;
|
|
124
|
+
if (left.primary.domElement !== right.primary.domElement)
|
|
125
|
+
return false;
|
|
126
|
+
if (left.elements.length !== right.elements.length)
|
|
127
|
+
return false;
|
|
128
|
+
return left.elements.every((element, elementIndex) => {
|
|
129
|
+
const candidate = right.elements[elementIndex];
|
|
130
|
+
return candidate
|
|
131
|
+
&& candidate.domElement === element.domElement
|
|
132
|
+
&& candidate.cid === element.cid
|
|
133
|
+
&& candidate.src === element.src
|
|
134
|
+
&& sameResolvedMetadata(candidate, element);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function publishSelection(elements, primary) {
|
|
138
|
+
const unique = [];
|
|
139
|
+
const seen = new Set();
|
|
140
|
+
for (const element of elements) {
|
|
141
|
+
if (seen.has(element.domElement))
|
|
142
|
+
continue;
|
|
143
|
+
seen.add(element.domElement);
|
|
144
|
+
unique.push(element);
|
|
145
|
+
}
|
|
146
|
+
if (unique.length === 0) {
|
|
147
|
+
setSelectedElement(null);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const nextPrimary = unique.find((element) => element.domElement === primary.domElement) ?? unique.at(-1);
|
|
151
|
+
const next = { elements: unique, primary: nextPrimary };
|
|
152
|
+
if (sameSelection(currentSelection, next))
|
|
153
|
+
return;
|
|
154
|
+
currentSelection = next;
|
|
155
|
+
if (unique.length === 1) {
|
|
156
|
+
chain = computeHierarchy(nextPrimary.domElement);
|
|
157
|
+
index = 0;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
// Hierarchy stepping is a single-element operation. Clearing it here also
|
|
161
|
+
// prevents a stale parent chain from being rendered for a group.
|
|
162
|
+
chain = [];
|
|
163
|
+
index = 0;
|
|
164
|
+
}
|
|
165
|
+
notify();
|
|
166
|
+
}
|
|
167
|
+
/** Replaces the selection with one or more ordered targets. */
|
|
168
|
+
export function setSelectedElements(elements) {
|
|
169
|
+
const primary = elements.at(-1);
|
|
170
|
+
if (!primary) {
|
|
171
|
+
setSelectedElement(null);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
publishSelection(elements, primary);
|
|
175
|
+
}
|
|
176
|
+
/** Adds or removes one target while keeping the toggled target primary. */
|
|
177
|
+
export function toggleSelectedElement(el) {
|
|
178
|
+
const selectedElements = getSelectedElements();
|
|
179
|
+
const existingIndex = selectedElements.findIndex((selected) => selected.domElement === el.domElement);
|
|
180
|
+
if (existingIndex >= 0) {
|
|
181
|
+
const remaining = selectedElements.filter((_, index) => index !== existingIndex);
|
|
182
|
+
if (remaining.length === 0) {
|
|
183
|
+
setSelectedElement(null);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const primary = remaining.at(-1);
|
|
187
|
+
publishSelection(remaining, primary);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
publishSelection([...selectedElements, el], el);
|
|
191
|
+
}
|
|
192
|
+
/** Removes one rendered node from the group, preserving the remaining order. */
|
|
193
|
+
export function removeSelectedElement(el) {
|
|
194
|
+
const selectedElements = getSelectedElements();
|
|
195
|
+
const remaining = selectedElements.filter((selected) => selected.domElement !== el);
|
|
196
|
+
if (remaining.length === selectedElements.length)
|
|
197
|
+
return;
|
|
198
|
+
if (remaining.length === 0) {
|
|
199
|
+
setSelectedElement(null);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const primary = currentSelection?.primary.domElement === el
|
|
203
|
+
? remaining.at(-1)
|
|
204
|
+
: currentSelection?.primary ?? remaining.at(-1);
|
|
205
|
+
publishSelection(remaining, primary);
|
|
206
|
+
}
|
|
207
|
+
/** Refreshes metadata for one selected DOM node without collapsing a group. */
|
|
208
|
+
export function refreshSelectedElement(el) {
|
|
209
|
+
const selectedElements = getSelectedElements();
|
|
210
|
+
const targetIndex = selectedElements.findIndex((selected) => selected.domElement === el.domElement);
|
|
211
|
+
if (targetIndex < 0) {
|
|
212
|
+
setSelectedElement(el);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const refreshed = selectedElements.slice();
|
|
216
|
+
refreshed[targetIndex] = el;
|
|
217
|
+
const primary = currentSelection?.primary.domElement === el.domElement
|
|
218
|
+
? el
|
|
219
|
+
: currentSelection?.primary ?? el;
|
|
220
|
+
publishSelection(refreshed, primary);
|
|
221
|
+
}
|
|
222
|
+
function applyStep(newIndex) {
|
|
223
|
+
if (newIndex < 0 || newIndex >= chain.length)
|
|
224
|
+
return;
|
|
225
|
+
if (newIndex === index)
|
|
226
|
+
return;
|
|
227
|
+
index = newIndex;
|
|
228
|
+
const node = chain[index];
|
|
229
|
+
if (node) {
|
|
230
|
+
const resolved = resolveSelectionFromElement(node);
|
|
231
|
+
if (resolved)
|
|
232
|
+
currentSelection = { elements: [resolved], primary: resolved };
|
|
233
|
+
}
|
|
234
|
+
notify();
|
|
235
|
+
}
|
|
236
|
+
export function stepUp() {
|
|
237
|
+
if (index < chain.length - 1)
|
|
238
|
+
applyStep(index + 1);
|
|
239
|
+
}
|
|
240
|
+
export function stepDown() {
|
|
241
|
+
if (index > 0)
|
|
242
|
+
applyStep(index - 1);
|
|
243
|
+
}
|
|
244
|
+
export function setHierarchyIndex(i) {
|
|
245
|
+
applyStep(i);
|
|
246
|
+
}
|
|
247
|
+
export { subscribe, getSelectedElement, getSelectedElements, getSelection, getHierarchy, getHierarchyIndex, };
|
|
248
|
+
export function useSelectedElement() {
|
|
249
|
+
return useSyncExternalStore(subscribe, getSelectedElement, getSelectedElement);
|
|
250
|
+
}
|
|
251
|
+
export function useSelectedElements() {
|
|
252
|
+
return useSyncExternalStore(subscribe, getSelectedElements, getSelectedElements);
|
|
253
|
+
}
|
|
254
|
+
export function useSelection() {
|
|
255
|
+
return useSyncExternalStore(subscribe, getSelection, getSelection);
|
|
256
|
+
}
|
|
257
|
+
export function useHierarchy() {
|
|
258
|
+
return useSyncExternalStore(subscribe, getHierarchy, getHierarchy);
|
|
259
|
+
}
|
|
260
|
+
export function useHierarchyIndex() {
|
|
261
|
+
return useSyncExternalStore(subscribe, getHierarchyIndex, getHierarchyIndex);
|
|
262
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ClickModifiers } from "../overlay/clickPolicy.js";
|
|
2
|
+
export type SelectionTargetMode = "primary" | "deep";
|
|
3
|
+
export declare function selectionTargetMode(event: ClickModifiers): SelectionTargetMode;
|
|
4
|
+
export declare function trackedElementStack(target: EventTarget | null): HTMLElement[];
|
|
5
|
+
export declare function resolveSelectionTarget(target: EventTarget | null, mode?: SelectionTargetMode): HTMLElement | null;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { isDeepSelectionClick } from "../overlay/clickPolicy.js";
|
|
2
|
+
const INTERACTIVE_TAGS = new Set([
|
|
3
|
+
"a",
|
|
4
|
+
"area",
|
|
5
|
+
"button",
|
|
6
|
+
"input",
|
|
7
|
+
"option",
|
|
8
|
+
"select",
|
|
9
|
+
"summary",
|
|
10
|
+
"textarea",
|
|
11
|
+
]);
|
|
12
|
+
const INTERACTIVE_ROLES = new Set([
|
|
13
|
+
"button",
|
|
14
|
+
"checkbox",
|
|
15
|
+
"link",
|
|
16
|
+
"menuitem",
|
|
17
|
+
"option",
|
|
18
|
+
"radio",
|
|
19
|
+
"switch",
|
|
20
|
+
"tab",
|
|
21
|
+
]);
|
|
22
|
+
export function selectionTargetMode(event) {
|
|
23
|
+
return isDeepSelectionClick(event) ? "deep" : "primary";
|
|
24
|
+
}
|
|
25
|
+
export function trackedElementStack(target) {
|
|
26
|
+
if (!(target instanceof Element))
|
|
27
|
+
return [];
|
|
28
|
+
const stack = [];
|
|
29
|
+
let element = target;
|
|
30
|
+
while (element) {
|
|
31
|
+
if (element instanceof HTMLElement && element.hasAttribute("data-cid")) {
|
|
32
|
+
stack.push(element);
|
|
33
|
+
}
|
|
34
|
+
element = element.parentElement;
|
|
35
|
+
}
|
|
36
|
+
return stack;
|
|
37
|
+
}
|
|
38
|
+
function isPrimaryElement(element) {
|
|
39
|
+
const tag = element.localName.toLowerCase();
|
|
40
|
+
if (INTERACTIVE_TAGS.has(tag))
|
|
41
|
+
return true;
|
|
42
|
+
const role = element.getAttribute("role")?.trim().toLowerCase();
|
|
43
|
+
return role ? INTERACTIVE_ROLES.has(role) : false;
|
|
44
|
+
}
|
|
45
|
+
export function resolveSelectionTarget(target, mode = "primary") {
|
|
46
|
+
const stack = trackedElementStack(target);
|
|
47
|
+
if (mode === "deep")
|
|
48
|
+
return stack[0] ?? null;
|
|
49
|
+
return stack.find(isPrimaryElement) ?? stack[0] ?? null;
|
|
50
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { escapeAttrValue } from "../projection/cssEscapes.js";
|
|
2
|
+
/** Stable JSX instrumentation selector, shared by source and instance edits. */
|
|
3
|
+
export function sourceSiteSelector(cid, src) {
|
|
4
|
+
if (!cid)
|
|
5
|
+
return null;
|
|
6
|
+
if (!src)
|
|
7
|
+
return `[data-cid="${escapeAttrValue(cid)}"]`;
|
|
8
|
+
// A source site is the complete file:line:column identity injected by the
|
|
9
|
+
// Vite transform. Keeping only file:line makes separate JSX elements on a
|
|
10
|
+
// single formatted line share a managed rule.
|
|
11
|
+
return `[data-cid="${escapeAttrValue(cid)}"][data-src="${escapeAttrValue(src)}"]`;
|
|
12
|
+
}
|