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,51 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
const packageRequire = createRequire(import.meta.url);
|
|
5
|
+
/**
|
|
6
|
+
* Creates the Astro handler for the shared, immutable inspector client.
|
|
7
|
+
* Resolution and reads remain lazy so disabled and production integrations do
|
|
8
|
+
* not depend on a development asset being present.
|
|
9
|
+
*/
|
|
10
|
+
export function createAstroClientAssetHandler(dependencies = {}) {
|
|
11
|
+
const resolveClientPath = dependencies.resolveClientPath
|
|
12
|
+
?? (() => packageRequire.resolve("nudge-ui/internal/client"));
|
|
13
|
+
const readClientFile = dependencies.readClientFile ?? readFile;
|
|
14
|
+
let cachedAsset;
|
|
15
|
+
return async (request, response) => {
|
|
16
|
+
const asset = await loadClientAsset();
|
|
17
|
+
response.setHeader("Cache-Control", "no-cache");
|
|
18
|
+
response.setHeader("ETag", asset.etag);
|
|
19
|
+
if (request.headers["if-none-match"] === asset.etag) {
|
|
20
|
+
response.statusCode = 304;
|
|
21
|
+
response.end();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
response.statusCode = 200;
|
|
25
|
+
response.setHeader("Content-Type", "text/javascript; charset=utf-8");
|
|
26
|
+
response.end(request.method === "HEAD" ? undefined : asset.body);
|
|
27
|
+
};
|
|
28
|
+
function loadClientAsset() {
|
|
29
|
+
if (cachedAsset)
|
|
30
|
+
return cachedAsset;
|
|
31
|
+
const current = load();
|
|
32
|
+
cachedAsset = current;
|
|
33
|
+
void current.catch(() => {
|
|
34
|
+
if (cachedAsset === current)
|
|
35
|
+
cachedAsset = undefined;
|
|
36
|
+
});
|
|
37
|
+
return current;
|
|
38
|
+
}
|
|
39
|
+
async function load() {
|
|
40
|
+
try {
|
|
41
|
+
const body = await readClientFile(resolveClientPath());
|
|
42
|
+
const digest = createHash("sha256").update(body).digest("base64url");
|
|
43
|
+
return { body, etag: `"sha256-${digest}"` };
|
|
44
|
+
}
|
|
45
|
+
catch (cause) {
|
|
46
|
+
throw new Error("Nudge UI could not load its inspector client. "
|
|
47
|
+
+ "Build nudge-ui (`pnpm --filter nudge-ui build`) "
|
|
48
|
+
+ "in a source workspace, or reinstall nudge-ui in an installed project.", { cause });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {} from "../../inspector/clientManifest.js";
|
|
2
|
+
import { createAstroRuntimeConfig } from "./astroRuntimeConfig.js";
|
|
3
|
+
import { createAstroClientAssetHandler } from "./clientAsset.js";
|
|
4
|
+
import { NUDGE_UI_CLIENT_PATH, NUDGE_UI_MANIFEST_PATH, } from "../../transport/index.js";
|
|
5
|
+
const serveClient = createAstroClientAssetHandler();
|
|
6
|
+
/** Serves the prebuilt client and its host-neutral manifest in Astro dev. */
|
|
7
|
+
export function createAstroClientTransportPlugin() {
|
|
8
|
+
return {
|
|
9
|
+
name: "nudge-ui-astro-client-transport",
|
|
10
|
+
// The shared Vite plugin exposes the same route for React hosts. Astro's
|
|
11
|
+
// host-specific manifest must be installed first so that its middleware
|
|
12
|
+
// is the handler that answers /__nudge_ui__/manifest.
|
|
13
|
+
enforce: "pre",
|
|
14
|
+
apply: "serve",
|
|
15
|
+
configureServer(server) {
|
|
16
|
+
server.middlewares.use((request, response, next) => {
|
|
17
|
+
const pathname = new URL(request.url ?? "/", "http://nudge-ui.local").pathname;
|
|
18
|
+
if (pathname === NUDGE_UI_CLIENT_PATH) {
|
|
19
|
+
void serveClient(request, response).catch(next);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (pathname === NUDGE_UI_MANIFEST_PATH) {
|
|
23
|
+
void createManifest(server)
|
|
24
|
+
.then((manifest) => {
|
|
25
|
+
response.statusCode = 200;
|
|
26
|
+
response.setHeader("Content-Type", "application/json; charset=utf-8");
|
|
27
|
+
response.setHeader("Cache-Control", "no-store");
|
|
28
|
+
response.end(JSON.stringify(manifest));
|
|
29
|
+
})
|
|
30
|
+
.catch(next);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
next();
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async function createManifest(server) {
|
|
39
|
+
// SAFETY: these virtual modules are generated by the shared Nudge UI plugin
|
|
40
|
+
// with the exact exports described by TokenModule and ComponentModule.
|
|
41
|
+
const [tokenModule, componentModule] = await Promise.all([
|
|
42
|
+
server.ssrLoadModule("virtual:design-tokens"),
|
|
43
|
+
server.ssrLoadModule("virtual:nudge-ui-components"),
|
|
44
|
+
]);
|
|
45
|
+
return {
|
|
46
|
+
version: 1,
|
|
47
|
+
revision: 0,
|
|
48
|
+
runtime: createAstroRuntimeConfig({
|
|
49
|
+
projectId: tokenModule.nudgeUiProjectId,
|
|
50
|
+
tokenCatalog: tokenModule.tokenCatalog,
|
|
51
|
+
tokens: tokenModule.tokens,
|
|
52
|
+
tokenDiagnostics: tokenModule.tokenDiagnostics,
|
|
53
|
+
tokenGeneration: tokenModule.tokenGeneration,
|
|
54
|
+
componentContracts: componentModule.componentContracts,
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { instrumentRenderedHtml, type HtmlIdentityDiagnostic, type HtmlIdentityDiagnosticCode, type HtmlIdentityResult, type RenderedHtmlIdentityOptions, } from "../../html/identity.js";
|
|
2
|
+
export { nudgeUiAstro, withNudgeUi } from "./integration.js";
|
|
3
|
+
export type { NudgeUiAstroOptions, NudgeUiOptions } from "./integration.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AstroIntegration, AstroUserConfig } from "astro";
|
|
2
|
+
import { type NudgeUiOptions } from "../vite/index.js";
|
|
3
|
+
export type { NudgeUiOptions };
|
|
4
|
+
/**
|
|
5
|
+
* Options for `nudgeUiAstro`. The token/component knowledge options are
|
|
6
|
+
* forwarded to the shared Vite plugin unchanged; Astro-specific concerns
|
|
7
|
+
* (gating, injection, instrumentation) stay internal.
|
|
8
|
+
*/
|
|
9
|
+
export interface NudgeUiAstroOptions extends NudgeUiOptions {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Nudge UI host Adapter for Astro dev servers (ADR-0011).
|
|
13
|
+
*
|
|
14
|
+
* Dev-only by contract (ADR-0002): unless `command === "dev"` and
|
|
15
|
+
* `enabled !== false`, the integration registers nothing at all — no Vite
|
|
16
|
+
* plugins, no injected scripts, no middleware — so `astro build` output is
|
|
17
|
+
* byte-identical to a project without the integration.
|
|
18
|
+
*
|
|
19
|
+
* In dev it wires three pieces:
|
|
20
|
+
* 1. the shared `nudgeUi()` Vite plugin (token knowledge and island JSX
|
|
21
|
+
* identity transforms), the client transport, and project context;
|
|
22
|
+
* 2. one external client script, injected on every rendered page;
|
|
23
|
+
* 3. an `addMiddleware` response instrumentation that buffers rendered HTML
|
|
24
|
+
* responses and adds the response-level identity layer through the
|
|
25
|
+
* identity Module.
|
|
26
|
+
*/
|
|
27
|
+
export declare function nudgeUiAstro(options?: NudgeUiAstroOptions): AstroIntegration;
|
|
28
|
+
/**
|
|
29
|
+
* Adds Nudge UI to an Astro configuration without inspecting its shape.
|
|
30
|
+
*
|
|
31
|
+
* This wrapper is the stable installer seam. It works with shorthand,
|
|
32
|
+
* variable, spread, and computed integration lists because it treats the
|
|
33
|
+
* configuration as a value rather than rewriting `integrations`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function withNudgeUi(config: AstroUserConfig, options?: NudgeUiAstroOptions): AstroUserConfig;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { nudgeUi } from "../vite/index.js";
|
|
2
|
+
import { NUDGE_UI_CLIENT_PATH, NUDGE_UI_MANIFEST_PATH } from "../../transport/index.js";
|
|
3
|
+
import { createAstroClientTransportPlugin, } from "./clientTransport.js";
|
|
4
|
+
import { createProjectContextPlugin } from "./projectContext.js";
|
|
5
|
+
/**
|
|
6
|
+
* Adds the prebuilt client as an external module. The inspector dependency
|
|
7
|
+
* graph therefore never enters Astro's Vite optimizer.
|
|
8
|
+
*/
|
|
9
|
+
const BOOTSTRAP_ENTRY_CONTENT = [
|
|
10
|
+
'if (!document.querySelector("script[data-nudge-ui-client]")) {',
|
|
11
|
+
' const script = document.createElement("script");',
|
|
12
|
+
' script.type = "module";',
|
|
13
|
+
` script.src = ${JSON.stringify(NUDGE_UI_CLIENT_PATH)};`,
|
|
14
|
+
' script.setAttribute("data-nudge-ui-client", "");',
|
|
15
|
+
` script.dataset.nudgeUiManifest = ${JSON.stringify(NUDGE_UI_MANIFEST_PATH)};`,
|
|
16
|
+
" document.head.append(script);",
|
|
17
|
+
"}",
|
|
18
|
+
].join("\n");
|
|
19
|
+
// Astro loads this URL directly from the installed package. Keep the source
|
|
20
|
+
// suffix for the workspace test/dev path and select the compiled sibling in a
|
|
21
|
+
// published package, where `middleware.ts` is intentionally not shipped.
|
|
22
|
+
const MIDDLEWARE_ENTRYPOINT = new URL(import.meta.url.endsWith(".ts") ? "./middleware.ts" : "./middleware.js", import.meta.url);
|
|
23
|
+
/**
|
|
24
|
+
* Nudge UI host Adapter for Astro dev servers (ADR-0011).
|
|
25
|
+
*
|
|
26
|
+
* Dev-only by contract (ADR-0002): unless `command === "dev"` and
|
|
27
|
+
* `enabled !== false`, the integration registers nothing at all — no Vite
|
|
28
|
+
* plugins, no injected scripts, no middleware — so `astro build` output is
|
|
29
|
+
* byte-identical to a project without the integration.
|
|
30
|
+
*
|
|
31
|
+
* In dev it wires three pieces:
|
|
32
|
+
* 1. the shared `nudgeUi()` Vite plugin (token knowledge and island JSX
|
|
33
|
+
* identity transforms), the client transport, and project context;
|
|
34
|
+
* 2. one external client script, injected on every rendered page;
|
|
35
|
+
* 3. an `addMiddleware` response instrumentation that buffers rendered HTML
|
|
36
|
+
* responses and adds the response-level identity layer through the
|
|
37
|
+
* identity Module.
|
|
38
|
+
*/
|
|
39
|
+
export function nudgeUiAstro(options = {}) {
|
|
40
|
+
const enabled = options.enabled ?? true;
|
|
41
|
+
const sharedOptions = { ...options };
|
|
42
|
+
return {
|
|
43
|
+
name: "nudge-ui",
|
|
44
|
+
hooks: {
|
|
45
|
+
"astro:config:setup"({ command, updateConfig, injectScript, addMiddleware }) {
|
|
46
|
+
if (!enabled || command !== "dev")
|
|
47
|
+
return;
|
|
48
|
+
// The shared plugin objects are plain Vite plugin records, but this
|
|
49
|
+
// monorepo typechecks them against a different Vite major than the
|
|
50
|
+
// installed Astro resolves internally; the runtime contract
|
|
51
|
+
// (config/resolveId/load/transform hooks) is identical.
|
|
52
|
+
updateConfig({
|
|
53
|
+
vite: {
|
|
54
|
+
// SAFETY: Astro and this package resolve different Vite type
|
|
55
|
+
// versions, but both consume the same runtime Plugin contract.
|
|
56
|
+
plugins: [
|
|
57
|
+
createAstroClientTransportPlugin(),
|
|
58
|
+
...nudgeUi(sharedOptions),
|
|
59
|
+
createProjectContextPlugin(),
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
// The page stage runs on every rendered page. It only appends an
|
|
64
|
+
// external script; no inspector dependency enters Vite's graph.
|
|
65
|
+
injectScript("page", BOOTSTRAP_ENTRY_CONTENT);
|
|
66
|
+
addMiddleware({ entrypoint: MIDDLEWARE_ENTRYPOINT, order: "pre" });
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Adds Nudge UI to an Astro configuration without inspecting its shape.
|
|
73
|
+
*
|
|
74
|
+
* This wrapper is the stable installer seam. It works with shorthand,
|
|
75
|
+
* variable, spread, and computed integration lists because it treats the
|
|
76
|
+
* configuration as a value rather than rewriting `integrations`.
|
|
77
|
+
*/
|
|
78
|
+
export function withNudgeUi(config, options = {}) {
|
|
79
|
+
const integrations = config.integrations ?? [];
|
|
80
|
+
if (containsNudgeUiIntegration(integrations))
|
|
81
|
+
return config;
|
|
82
|
+
return {
|
|
83
|
+
...config,
|
|
84
|
+
integrations: [...integrations, nudgeUiAstro(options)],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function containsNudgeUiIntegration(integrations) {
|
|
88
|
+
return integrations.some((integration) => {
|
|
89
|
+
if (Array.isArray(integration))
|
|
90
|
+
return containsNudgeUiIntegration(integration);
|
|
91
|
+
return integration !== false
|
|
92
|
+
&& integration !== null
|
|
93
|
+
&& integration !== undefined
|
|
94
|
+
&& integration.name === "nudge-ui";
|
|
95
|
+
});
|
|
96
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev-only response instrumentation middleware (ADR-0011).
|
|
3
|
+
*
|
|
4
|
+
* Registered through `addMiddleware({ order: "pre" })`, this runs inside
|
|
5
|
+
* Astro's own middleware chain — before user middleware, around page
|
|
6
|
+
* rendering. It buffers the rendered HTML response, adds the Nudge UI
|
|
7
|
+
* identity layer server-side (before any client script can strip Astro's
|
|
8
|
+
* annotations), and forwards every non-HTML response untouched.
|
|
9
|
+
*
|
|
10
|
+
* Identity diagnostics are logged rather than swallowed so degraded identity
|
|
11
|
+
* (for example a disabled dev toolbar) is observable in the dev server output.
|
|
12
|
+
*/
|
|
13
|
+
export declare const onRequest: (_context: unknown, next: () => Promise<Response>) => Promise<Response>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { projectRoot } from "virtual:nudge-ui-astro-context";
|
|
2
|
+
import { instrumentAstroResponse } from "./responseInstrumentation.js";
|
|
3
|
+
/**
|
|
4
|
+
* Dev-only response instrumentation middleware (ADR-0011).
|
|
5
|
+
*
|
|
6
|
+
* Registered through `addMiddleware({ order: "pre" })`, this runs inside
|
|
7
|
+
* Astro's own middleware chain — before user middleware, around page
|
|
8
|
+
* rendering. It buffers the rendered HTML response, adds the Nudge UI
|
|
9
|
+
* identity layer server-side (before any client script can strip Astro's
|
|
10
|
+
* annotations), and forwards every non-HTML response untouched.
|
|
11
|
+
*
|
|
12
|
+
* Identity diagnostics are logged rather than swallowed so degraded identity
|
|
13
|
+
* (for example a disabled dev toolbar) is observable in the dev server output.
|
|
14
|
+
*/
|
|
15
|
+
export const onRequest = async (_context, next) => {
|
|
16
|
+
const response = await next();
|
|
17
|
+
const result = await instrumentAstroResponse(response, projectRoot === "" ? undefined : projectRoot);
|
|
18
|
+
for (const diagnostic of result.diagnostics) {
|
|
19
|
+
console.warn(`[nudge-ui] ${diagnostic.code}: ${diagnostic.message}`);
|
|
20
|
+
}
|
|
21
|
+
return result.response;
|
|
22
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
/**
|
|
3
|
+
* Supplies the dev-only server context (project root) to the instrumentation
|
|
4
|
+
* middleware through a virtual module.
|
|
5
|
+
*
|
|
6
|
+
* The middleware entrypoint is loaded by Astro's SSR pipeline, where no
|
|
7
|
+
* integration hook argument is available; the Vite-resolved project root is
|
|
8
|
+
* therefore published as a module value instead of being read from ambient
|
|
9
|
+
* process state.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createProjectContextPlugin(): Plugin;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const VIRTUAL_CONTEXT_ID = "virtual:nudge-ui-astro-context";
|
|
2
|
+
const RESOLVED_CONTEXT_ID = `\0${VIRTUAL_CONTEXT_ID}`;
|
|
3
|
+
/**
|
|
4
|
+
* Supplies the dev-only server context (project root) to the instrumentation
|
|
5
|
+
* middleware through a virtual module.
|
|
6
|
+
*
|
|
7
|
+
* The middleware entrypoint is loaded by Astro's SSR pipeline, where no
|
|
8
|
+
* integration hook argument is available; the Vite-resolved project root is
|
|
9
|
+
* therefore published as a module value instead of being read from ambient
|
|
10
|
+
* process state.
|
|
11
|
+
*/
|
|
12
|
+
export function createProjectContextPlugin() {
|
|
13
|
+
let projectRoot;
|
|
14
|
+
return {
|
|
15
|
+
name: "nudge-ui-astro-context",
|
|
16
|
+
apply: "serve",
|
|
17
|
+
configResolved(config) {
|
|
18
|
+
projectRoot = config.root;
|
|
19
|
+
},
|
|
20
|
+
resolveId(id) {
|
|
21
|
+
if (id === VIRTUAL_CONTEXT_ID || id === RESOLVED_CONTEXT_ID) {
|
|
22
|
+
return RESOLVED_CONTEXT_ID;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
},
|
|
26
|
+
load(id) {
|
|
27
|
+
if (id !== RESOLVED_CONTEXT_ID)
|
|
28
|
+
return null;
|
|
29
|
+
// An empty root degrades to undefined so annotation paths forward
|
|
30
|
+
// unchanged instead of relativizing against the wrong base.
|
|
31
|
+
return `export const projectRoot = ${JSON.stringify(projectRoot ?? "")};\n`;
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { instrumentRenderedHtml, type HtmlIdentityDiagnostic } from "../../html/identity.js";
|
|
2
|
+
/**
|
|
3
|
+
* Classifies a response Content-Type header. Only `text/html` responses
|
|
4
|
+
* (with optional parameters such as charset) are eligible for identity
|
|
5
|
+
* instrumentation; everything else must pass through untouched.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isHtmlContentType(contentType: string | undefined): boolean;
|
|
8
|
+
/** The instrumented response plus the identity diagnostics it produced. */
|
|
9
|
+
export interface InstrumentedAstroResponse {
|
|
10
|
+
/** A response safe to hand back to Astro. */
|
|
11
|
+
readonly response: Response;
|
|
12
|
+
/** Identity diagnostics in source order; empty for untouched responses. */
|
|
13
|
+
readonly diagnostics: readonly HtmlIdentityDiagnostic[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The identity transform applied to an eligible HTML body. Injectable so the
|
|
17
|
+
* failure-tolerance suite can drive the catch branch through a real seam
|
|
18
|
+
* instead of replacing the identity module wholesale.
|
|
19
|
+
*/
|
|
20
|
+
export type AstroHtmlInstrumenter = typeof instrumentRenderedHtml;
|
|
21
|
+
/**
|
|
22
|
+
* Instruments one rendered dev response at the Astro middleware seam
|
|
23
|
+
* (ADR-0011).
|
|
24
|
+
*
|
|
25
|
+
* HTML bodies are materialized once, transformed through the identity Module,
|
|
26
|
+
* and re-emitted as a new `Response` whose headers carry a corrected
|
|
27
|
+
* `Content-Length`; every other response is returned by reference with its
|
|
28
|
+
* stream untouched. If the body read or instrumentation throws, the original
|
|
29
|
+
* response forwards so identity extraction can never break a dev page load —
|
|
30
|
+
* a failed read returns the original response by reference (its stream is the
|
|
31
|
+
* only remaining representation), while a failed transform returns a fresh
|
|
32
|
+
* `Response` over the already-materialized body. Diagnostics always
|
|
33
|
+
* accompany the result so callers can surface degraded identity.
|
|
34
|
+
*
|
|
35
|
+
* @param response The response produced downstream (the rendered page).
|
|
36
|
+
* @param projectRoot Project root used to relativize annotation paths.
|
|
37
|
+
* @param instrument Identity transform to apply; defaults to the real
|
|
38
|
+
* `instrumentRenderedHtml`. Tests inject a failing implementation to exercise
|
|
39
|
+
* the catch branch.
|
|
40
|
+
*/
|
|
41
|
+
export declare function instrumentAstroResponse(response: Response, projectRoot: string | undefined, instrument?: AstroHtmlInstrumenter): Promise<InstrumentedAstroResponse>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { instrumentRenderedHtml } from "../../html/identity.js";
|
|
2
|
+
const HTML_MEDIA_TYPE_PATTERN = /^text\/html$/i;
|
|
3
|
+
/**
|
|
4
|
+
* Measures `Content-Length` in bytes without assuming a Node global; the
|
|
5
|
+
* middleware itself may run on any runtime that serves Astro's dev server.
|
|
6
|
+
*/
|
|
7
|
+
const HTML_BYTE_LENGTH_ENCODER = new TextEncoder();
|
|
8
|
+
/**
|
|
9
|
+
* Classifies a response Content-Type header. Only `text/html` responses
|
|
10
|
+
* (with optional parameters such as charset) are eligible for identity
|
|
11
|
+
* instrumentation; everything else must pass through untouched.
|
|
12
|
+
*/
|
|
13
|
+
export function isHtmlContentType(contentType) {
|
|
14
|
+
if (contentType === undefined)
|
|
15
|
+
return false;
|
|
16
|
+
const mediaType = contentType.split(";", 1)[0]?.trim() ?? "";
|
|
17
|
+
return HTML_MEDIA_TYPE_PATTERN.test(mediaType);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Instruments one rendered dev response at the Astro middleware seam
|
|
21
|
+
* (ADR-0011).
|
|
22
|
+
*
|
|
23
|
+
* HTML bodies are materialized once, transformed through the identity Module,
|
|
24
|
+
* and re-emitted as a new `Response` whose headers carry a corrected
|
|
25
|
+
* `Content-Length`; every other response is returned by reference with its
|
|
26
|
+
* stream untouched. If the body read or instrumentation throws, the original
|
|
27
|
+
* response forwards so identity extraction can never break a dev page load —
|
|
28
|
+
* a failed read returns the original response by reference (its stream is the
|
|
29
|
+
* only remaining representation), while a failed transform returns a fresh
|
|
30
|
+
* `Response` over the already-materialized body. Diagnostics always
|
|
31
|
+
* accompany the result so callers can surface degraded identity.
|
|
32
|
+
*
|
|
33
|
+
* @param response The response produced downstream (the rendered page).
|
|
34
|
+
* @param projectRoot Project root used to relativize annotation paths.
|
|
35
|
+
* @param instrument Identity transform to apply; defaults to the real
|
|
36
|
+
* `instrumentRenderedHtml`. Tests inject a failing implementation to exercise
|
|
37
|
+
* the catch branch.
|
|
38
|
+
*/
|
|
39
|
+
export async function instrumentAstroResponse(response, projectRoot, instrument = instrumentRenderedHtml) {
|
|
40
|
+
const contentType = response.headers.get("content-type") ?? undefined;
|
|
41
|
+
if (!isHtmlContentType(contentType))
|
|
42
|
+
return { response, diagnostics: [] };
|
|
43
|
+
if (response.body === null)
|
|
44
|
+
return { response, diagnostics: [] };
|
|
45
|
+
let source;
|
|
46
|
+
try {
|
|
47
|
+
source = await response.text();
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// The body read itself failed; the original response is the only
|
|
51
|
+
// remaining representation of the body, so forward it by reference
|
|
52
|
+
// instead of rejecting into the middleware chain.
|
|
53
|
+
return { response, diagnostics: [] };
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const result = instrument(source, { projectRoot });
|
|
57
|
+
const headers = new Headers(response.headers);
|
|
58
|
+
headers.set("content-length", String(HTML_BYTE_LENGTH_ENCODER.encode(result.html).length));
|
|
59
|
+
return {
|
|
60
|
+
response: new Response(result.html, {
|
|
61
|
+
status: response.status,
|
|
62
|
+
statusText: response.statusText,
|
|
63
|
+
headers,
|
|
64
|
+
}),
|
|
65
|
+
diagnostics: result.diagnostics,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Identity extraction must never break a dev page load; forward the
|
|
70
|
+
// untouched body instead.
|
|
71
|
+
return {
|
|
72
|
+
response: new Response(source, {
|
|
73
|
+
status: response.status,
|
|
74
|
+
statusText: response.statusText,
|
|
75
|
+
headers: response.headers,
|
|
76
|
+
}),
|
|
77
|
+
diagnostics: [],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { withNudgeUi, type NudgeUiNextConfig, type NudgeUiNextOptions, type RewritesShape, type RewritesSource, } from "./wrapper.js";
|
|
2
|
+
export { buildManifest, nextjsProjectId, type NudgeUiManifest } from "./manifest.js";
|
|
3
|
+
export { ensureSidecar, clearStaleSidecarState, type SidecarHandle, } from "./sidecar.js";
|
|
4
|
+
export { transformNextModuleSource, hasUseClientDirective, directivePrologueEnd, instrumentRootLayout, type NextModuleTransformOptions, type NextModuleTransformResult, } from "./loader.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { withNudgeUi, } from "./wrapper.js";
|
|
2
|
+
export { buildManifest, nextjsProjectId } from "./manifest.js";
|
|
3
|
+
export { ensureSidecar, clearStaleSidecarState, } from "./sidecar.js";
|
|
4
|
+
export { transformNextModuleSource, hasUseClientDirective, directivePrologueEnd, instrumentRootLayout, } from "./loader.js";
|
|
5
|
+
// `./loader-plugin.cts` is the compiler-facing entry; it is CommonJS by
|
|
6
|
+
// contract (see its header) and is therefore not re-exported through this
|
|
7
|
+
// ESM surface.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { SourceMap } from "magic-string";
|
|
2
|
+
import type { HostComponentPolicy } from "../../compiler/componentPolicyResolution.js";
|
|
3
|
+
export interface NextModuleTransformOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Project root used to compute project-relative `data-src` values. Matches
|
|
6
|
+
* the Vite Adapter's semantics: paths outside the root fall back to the
|
|
7
|
+
* absolute path with its leading slash stripped.
|
|
8
|
+
*/
|
|
9
|
+
root?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Directory name of the Pages Router route root. Modules resolved under it
|
|
12
|
+
* are client components even without a `"use client"` directive.
|
|
13
|
+
*/
|
|
14
|
+
pagesDir?: string;
|
|
15
|
+
/** Import provenance and slot policy resolved by the Next host Adapter. */
|
|
16
|
+
hostPolicy?: HostComponentPolicy;
|
|
17
|
+
/** Whether this module belongs to the Adapter's explicit semantic source scope. */
|
|
18
|
+
instrumentComponents?: boolean;
|
|
19
|
+
/** Module specifier resolved by the Next host for semantic boundaries. */
|
|
20
|
+
componentRuntimeModule?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface NextModuleTransformResult {
|
|
23
|
+
code: string;
|
|
24
|
+
map: SourceMap | null;
|
|
25
|
+
/** True when the module qualifies as a client component (directive or Pages Router rule). */
|
|
26
|
+
clientComponent: boolean;
|
|
27
|
+
/** True when a root-layout mount element was appended. */
|
|
28
|
+
layoutInstrumented: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Transforms one application module for development rendering, or returns
|
|
32
|
+
* `null` when nothing applies and the caller must serve the original bytes.
|
|
33
|
+
*
|
|
34
|
+
* `moduleId` is an absolute or project-relative path; only path shapes are
|
|
35
|
+
* inspected, never the filesystem.
|
|
36
|
+
*/
|
|
37
|
+
export declare function transformNextModuleSource(source: string, moduleId: string, options?: NextModuleTransformOptions): NextModuleTransformResult | null;
|
|
38
|
+
/**
|
|
39
|
+
* Detects a module-level `"use client"` directive without a full parse.
|
|
40
|
+
*
|
|
41
|
+
* Only comments, whitespace, a shebang, and other directive prologues may
|
|
42
|
+
* precede it; anything else ends the directive prologue per the ECMAScript
|
|
43
|
+
* spec, which keeps the scan exact rather than a loose substring search.
|
|
44
|
+
*/
|
|
45
|
+
export declare function hasUseClientDirective(source: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Appends the inspector mount as the last child of a literal rendered `<body>`
|
|
48
|
+
* element. The server-rendered script must be in the initial document so it
|
|
49
|
+
* does not rely on hydration of a client component in the root layout. A
|
|
50
|
+
* layout with no literal body is left unchanged rather than emitting an
|
|
51
|
+
* invalid direct child of `<html>`.
|
|
52
|
+
*
|
|
53
|
+
* Idempotence: the aliased mount import doubles as the marker — a module that
|
|
54
|
+
* already carries it is left untouched, so running the loader twice (as
|
|
55
|
+
* Turbopack does across react-server and client conditions) cannot stack
|
|
56
|
+
* duplicates.
|
|
57
|
+
*/
|
|
58
|
+
export declare function instrumentRootLayout(source: string): {
|
|
59
|
+
code: string;
|
|
60
|
+
map: SourceMap;
|
|
61
|
+
} | null;
|
|
62
|
+
/**
|
|
63
|
+
* Offset just past the directive prologue (shebang, comments, directive
|
|
64
|
+
* statements) — the only legal insertion point for new import statements.
|
|
65
|
+
*/
|
|
66
|
+
export declare function directivePrologueEnd(source: string): number;
|