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,231 @@
|
|
|
1
|
+
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { injectIdentity } from "../../compiler/reactIdentity.js";
|
|
5
|
+
import { extractComponentContracts } from "../../compiler/componentContracts.js";
|
|
6
|
+
import { collectPackageComponentModules, extractPackageComponentContractCatalog, } from "../../compiler/packageComponentContracts.js";
|
|
7
|
+
import { defaultReactComponentProtocols, formatComponentPolicyWarning, groupComponentPolicyDiagnostics, mergeComponentModuleProtocols, resolveHostComponentPolicy, } from "../../compiler/index.js";
|
|
8
|
+
/**
|
|
9
|
+
* What React means to a host, with no knowledge of which host is asking. The
|
|
10
|
+
* Vite host owns the build tool; this module owns React semantics. `FrameworkHost`
|
|
11
|
+
* is everything React needs back, and the Vite host accepts `null` in its place,
|
|
12
|
+
* which is what proves it does not secretly depend on any of this.
|
|
13
|
+
*/
|
|
14
|
+
const COMPONENT_EXTENSION = /\.(?:tsx|jsx)(?:$|[?#])/;
|
|
15
|
+
const COMPONENT_RUNTIME_MODULE = "nudge-ui/internal/component-runtime";
|
|
16
|
+
const packageRequire = createRequire(import.meta.url);
|
|
17
|
+
export function createReactSupport(options, host) {
|
|
18
|
+
const contractsByFile = new Map();
|
|
19
|
+
const packageModulesByFile = new Map();
|
|
20
|
+
const reportedPolicyDiagnostics = new Set();
|
|
21
|
+
const manualComponentIds = new Set(options.componentMetadata?.map((contract) => contract.componentId) ?? []);
|
|
22
|
+
let packageFingerprint = "";
|
|
23
|
+
// Aliased so the injected specifier resolves in a packed install, where the
|
|
24
|
+
// application's dependency graph has never heard of it.
|
|
25
|
+
const componentRuntimePath = resolveComponentRuntime();
|
|
26
|
+
if (options.componentMetadata?.length) {
|
|
27
|
+
contractsByFile.set("package-manifests", options.componentMetadata.map((contract) => ({
|
|
28
|
+
...contract,
|
|
29
|
+
provenance: "package-manifest",
|
|
30
|
+
})));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Fingerprinted on the module-to-importer mapping so an unchanged import
|
|
34
|
+
* graph costs nothing; every component edit reaches this path.
|
|
35
|
+
*/
|
|
36
|
+
function refreshPackageContracts() {
|
|
37
|
+
const hostByModule = new Map();
|
|
38
|
+
for (const [hostFile, modules] of [...packageModulesByFile].sort(([left], [right]) => left.localeCompare(right))) {
|
|
39
|
+
for (const moduleSpecifier of modules) {
|
|
40
|
+
if (!hostByModule.has(moduleSpecifier))
|
|
41
|
+
hostByModule.set(moduleSpecifier, hostFile);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const fingerprint = [...hostByModule]
|
|
45
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
46
|
+
.map(([moduleSpecifier, hostFile]) => `${moduleSpecifier}\0${hostFile}`)
|
|
47
|
+
.join("\n");
|
|
48
|
+
if (fingerprint === packageFingerprint)
|
|
49
|
+
return;
|
|
50
|
+
for (const key of [...contractsByFile.keys()]) {
|
|
51
|
+
if (key.startsWith("package-types:"))
|
|
52
|
+
contractsByFile.delete(key);
|
|
53
|
+
}
|
|
54
|
+
const root = host.root();
|
|
55
|
+
const catalog = root
|
|
56
|
+
? extractPackageComponentContractCatalog({
|
|
57
|
+
hostFile: join(root, "__nudge_ui_package_contracts__.tsx"),
|
|
58
|
+
moduleSpecifiers: [...hostByModule.keys()],
|
|
59
|
+
})
|
|
60
|
+
: [];
|
|
61
|
+
for (const moduleSpecifier of hostByModule.keys()) {
|
|
62
|
+
contractsByFile.set(`package-types:${moduleSpecifier}`, catalog.filter((contract) => contract.file === moduleSpecifier && !manualComponentIds.has(contract.componentId)));
|
|
63
|
+
}
|
|
64
|
+
packageFingerprint = fingerprint;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
/** Manifest labels for a host composing React. */
|
|
68
|
+
hostLabel: "vite-react",
|
|
69
|
+
framework: "React",
|
|
70
|
+
virtualModuleId: "virtual:nudge-ui-components",
|
|
71
|
+
owns(id) {
|
|
72
|
+
return COMPONENT_EXTENSION.test(id);
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* Dedupe is the load-bearing part: instrumented callsites must use the
|
|
76
|
+
* application's own React, and a linked or nested copy would create a
|
|
77
|
+
* second runtime.
|
|
78
|
+
*/
|
|
79
|
+
viteConfig(context) {
|
|
80
|
+
const demoAliases = context.demo && options.skipReactAliases !== true
|
|
81
|
+
? resolveReactAliases(context.projectRoot)
|
|
82
|
+
: [];
|
|
83
|
+
const runtimeAliases = componentRuntimePath
|
|
84
|
+
? [{ find: COMPONENT_RUNTIME_MODULE, replacement: componentRuntimePath }]
|
|
85
|
+
: [];
|
|
86
|
+
return {
|
|
87
|
+
...(componentRuntimePath
|
|
88
|
+
? {
|
|
89
|
+
// Vite merges this with the application's own settings, so listing its entries here would duplicate them.
|
|
90
|
+
optimizeDeps: { include: [COMPONENT_RUNTIME_MODULE] },
|
|
91
|
+
}
|
|
92
|
+
: {}),
|
|
93
|
+
resolve: {
|
|
94
|
+
...(demoAliases.length > 0 || runtimeAliases.length > 0
|
|
95
|
+
? { alias: [...demoAliases, ...runtimeAliases] }
|
|
96
|
+
: {}),
|
|
97
|
+
dedupe: [...new Set([...context.existingDedupe, "react", "react-dom"])],
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
/** Not fatal, but a packed install that cannot resolve it fails later at the importing module. */
|
|
102
|
+
unresolvedRuntimeWarning() {
|
|
103
|
+
if (componentRuntimePath)
|
|
104
|
+
return null;
|
|
105
|
+
return `[nudge-ui] Could not resolve ${COMPONENT_RUNTIME_MODULE} from the Vite adapter. `
|
|
106
|
+
+ "Semantic component callsites will fall back to application resolution of that specifier.";
|
|
107
|
+
},
|
|
108
|
+
/** Cold-start scan, so the first manifest is not missing every contract. */
|
|
109
|
+
warmUp() {
|
|
110
|
+
const root = host.root();
|
|
111
|
+
if (!root)
|
|
112
|
+
return;
|
|
113
|
+
for (const file of scanComponentFiles(root)) {
|
|
114
|
+
try {
|
|
115
|
+
this.observe(file, readFileSync(file, "utf8"), false);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// skip unreadable component sources
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
refreshPackageContracts();
|
|
122
|
+
},
|
|
123
|
+
observe(id, code, refreshPackages = true) {
|
|
124
|
+
if (!COMPONENT_EXTENSION.test(id) || !host.isHostSource(id))
|
|
125
|
+
return;
|
|
126
|
+
const fileId = id.split(/[?#]/, 1)[0] ?? id;
|
|
127
|
+
contractsByFile.set(fileId, extractComponentContracts(code, host.catalogPath(fileId)));
|
|
128
|
+
packageModulesByFile.set(fileId, collectPackageComponentModules(code, fileId));
|
|
129
|
+
if (refreshPackages)
|
|
130
|
+
refreshPackageContracts();
|
|
131
|
+
},
|
|
132
|
+
/** Drops a module whose source could not be read after a change. */
|
|
133
|
+
forget(id) {
|
|
134
|
+
contractsByFile.set(id, []);
|
|
135
|
+
packageModulesByFile.delete(id);
|
|
136
|
+
refreshPackageContracts();
|
|
137
|
+
},
|
|
138
|
+
async transform(context, code, id) {
|
|
139
|
+
const instrumentComponents = host.isHostSource(id);
|
|
140
|
+
const isComponent = COMPONENT_EXTENSION.test(id) && instrumentComponents;
|
|
141
|
+
if (isComponent)
|
|
142
|
+
this.observe(id, code);
|
|
143
|
+
const hostPolicy = isComponent
|
|
144
|
+
? await resolveHostComponentPolicy(code, id, {
|
|
145
|
+
resolve: context.resolve,
|
|
146
|
+
read: async (resolvedId) => {
|
|
147
|
+
try {
|
|
148
|
+
return readFileSync(resolvedId, "utf8");
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
isProjectSource: host.isHostSource,
|
|
155
|
+
sourcePath: host.catalogPath,
|
|
156
|
+
}, {
|
|
157
|
+
moduleProtocols: mergeComponentModuleProtocols(defaultReactComponentProtocols, options.componentProtocols),
|
|
158
|
+
compatibleComponentImports: options.compatibleComponentImports,
|
|
159
|
+
})
|
|
160
|
+
: undefined;
|
|
161
|
+
for (const grouped of groupComponentPolicyDiagnostics(hostPolicy?.diagnostics ?? [])) {
|
|
162
|
+
if (reportedPolicyDiagnostics.has(grouped.key))
|
|
163
|
+
continue;
|
|
164
|
+
reportedPolicyDiagnostics.add(grouped.key);
|
|
165
|
+
context.warn(formatComponentPolicyWarning(grouped, host.catalogPath(id)));
|
|
166
|
+
}
|
|
167
|
+
return injectIdentity(code, id, host.root(), {
|
|
168
|
+
instrumentComponents,
|
|
169
|
+
// Already folds compatibleComponentImports in, so identity reads one policy.
|
|
170
|
+
hostPolicy,
|
|
171
|
+
});
|
|
172
|
+
},
|
|
173
|
+
contracts() {
|
|
174
|
+
return [...contractsByFile.values()].flat();
|
|
175
|
+
},
|
|
176
|
+
serializeVirtualModule(contracts) {
|
|
177
|
+
return `export const componentContracts = ${JSON.stringify(contracts)};\n`
|
|
178
|
+
+ "export default componentContracts;\n";
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function scanComponentFiles(rootDir, files = [], dir = rootDir) {
|
|
183
|
+
let entries;
|
|
184
|
+
try {
|
|
185
|
+
entries = readdirSync(dir);
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
return files;
|
|
189
|
+
}
|
|
190
|
+
for (const entry of entries) {
|
|
191
|
+
if (entry === "node_modules" || entry === ".git" || entry.startsWith("dist"))
|
|
192
|
+
continue;
|
|
193
|
+
const full = join(dir, entry);
|
|
194
|
+
try {
|
|
195
|
+
if (statSync(full).isDirectory())
|
|
196
|
+
scanComponentFiles(rootDir, files, full);
|
|
197
|
+
else if (COMPONENT_EXTENSION.test(entry))
|
|
198
|
+
files.push(full);
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
// ignore unreadable entries
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return files;
|
|
205
|
+
}
|
|
206
|
+
function resolveComponentRuntime() {
|
|
207
|
+
try {
|
|
208
|
+
return packageRequire.resolve(COMPONENT_RUNTIME_MODULE);
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function resolveReactAliases(projectRoot) {
|
|
215
|
+
const require = createRequire(`${projectRoot}/package.json`);
|
|
216
|
+
const aliases = [];
|
|
217
|
+
const add = (pattern, specifier) => {
|
|
218
|
+
try {
|
|
219
|
+
aliases.push({ find: pattern, replacement: require.resolve(specifier) });
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
// an unresolvable specifier simply contributes no alias
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
add(/^react$/, "react");
|
|
226
|
+
add(/^react-dom$/, "react-dom");
|
|
227
|
+
add(/^react\/jsx-runtime$/, "react/jsx-runtime");
|
|
228
|
+
add(/^react\/jsx-dev-runtime$/, "react/jsx-dev-runtime");
|
|
229
|
+
add(/^react-dom\/client$/, "react-dom/client");
|
|
230
|
+
return aliases;
|
|
231
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The token catalog must follow only stylesheets the application imports. This
|
|
3
|
+
* small graph walker deliberately has no filesystem traversal: callers supply
|
|
4
|
+
* the host CSS entry files, a Vite-backed resolver, and a reader.
|
|
5
|
+
*/
|
|
6
|
+
export interface CssImportGraph {
|
|
7
|
+
files: Map<string, string>;
|
|
8
|
+
/** CSS cascade order: imported sheets precede the sheet that imports them. */
|
|
9
|
+
order: string[];
|
|
10
|
+
unresolved: Array<{
|
|
11
|
+
importer: string;
|
|
12
|
+
specifier: string;
|
|
13
|
+
}>;
|
|
14
|
+
unreadable: string[];
|
|
15
|
+
}
|
|
16
|
+
export interface CssImportGraphDependencies {
|
|
17
|
+
read(id: string): string;
|
|
18
|
+
resolve(specifier: string, importer: string): Promise<string | null>;
|
|
19
|
+
}
|
|
20
|
+
export declare function stripCssQuery(id: string): string;
|
|
21
|
+
export declare function isCssStylesheet(id: string): boolean;
|
|
22
|
+
/** Extract quoted and url(...) @import targets while ignoring CSS comments. */
|
|
23
|
+
export declare function cssImportSpecifiers(css: string): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Resolve every CSS file reached from the supplied host stylesheets. Missing
|
|
26
|
+
* and unreadable imports are reported but never make the catalog unavailable.
|
|
27
|
+
*/
|
|
28
|
+
export declare function discoverCssImportGraph(entryFiles: readonly string[], dependencies: CssImportGraphDependencies): Promise<CssImportGraph>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export function stripCssQuery(id) {
|
|
2
|
+
return id.split(/[?#]/, 1)[0] ?? id;
|
|
3
|
+
}
|
|
4
|
+
export function isCssStylesheet(id) {
|
|
5
|
+
return /\.css(?:$|[?#])/i.test(id);
|
|
6
|
+
}
|
|
7
|
+
/** Extract quoted and url(...) @import targets while ignoring CSS comments. */
|
|
8
|
+
export function cssImportSpecifiers(css) {
|
|
9
|
+
const withoutComments = css.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
10
|
+
const imports = [];
|
|
11
|
+
const expression = /@import\s+(?:url\(\s*)?(?:"([^"]+)"|'([^']+)'|([^\s)'";]+))\s*\)?/gi;
|
|
12
|
+
let match;
|
|
13
|
+
while ((match = expression.exec(withoutComments))) {
|
|
14
|
+
const specifier = match[1] ?? match[2] ?? match[3];
|
|
15
|
+
if (specifier)
|
|
16
|
+
imports.push(specifier);
|
|
17
|
+
}
|
|
18
|
+
return imports;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Resolve every CSS file reached from the supplied host stylesheets. Missing
|
|
22
|
+
* and unreadable imports are reported but never make the catalog unavailable.
|
|
23
|
+
*/
|
|
24
|
+
export async function discoverCssImportGraph(entryFiles, dependencies) {
|
|
25
|
+
const files = new Map();
|
|
26
|
+
const order = [];
|
|
27
|
+
const visiting = new Set();
|
|
28
|
+
const unresolved = [];
|
|
29
|
+
const unreadable = [];
|
|
30
|
+
async function visit(id) {
|
|
31
|
+
const fileId = stripCssQuery(id);
|
|
32
|
+
if (files.has(fileId) || visiting.has(fileId) || unreadable.includes(fileId))
|
|
33
|
+
return;
|
|
34
|
+
visiting.add(fileId);
|
|
35
|
+
let css;
|
|
36
|
+
try {
|
|
37
|
+
css = dependencies.read(fileId);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
unreadable.push(fileId);
|
|
41
|
+
visiting.delete(fileId);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
files.set(fileId, css);
|
|
45
|
+
for (const specifier of cssImportSpecifiers(css)) {
|
|
46
|
+
let resolved = null;
|
|
47
|
+
try {
|
|
48
|
+
resolved = await dependencies.resolve(specifier, fileId);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// An unresolved package must not prevent the host token catalog loading.
|
|
52
|
+
}
|
|
53
|
+
if (!resolved) {
|
|
54
|
+
unresolved.push({ importer: fileId, specifier });
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
// A processor-owned import such as Tailwind's package entry may resolve
|
|
58
|
+
// to JavaScript and later emit CSS during transform. It is outside this
|
|
59
|
+
// ordinary-CSS graph, but it is not an unresolved stylesheet failure.
|
|
60
|
+
if (!isCssStylesheet(resolved))
|
|
61
|
+
continue;
|
|
62
|
+
await visit(resolved);
|
|
63
|
+
}
|
|
64
|
+
visiting.delete(fileId);
|
|
65
|
+
order.push(fileId);
|
|
66
|
+
}
|
|
67
|
+
for (const entry of entryFiles)
|
|
68
|
+
await visit(entry);
|
|
69
|
+
return { files, order, unresolved, unreadable };
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ArtifactStage, StylesheetArtifact } from "../../../css/token-inventory/index.js";
|
|
2
|
+
import type { CssImportGraph } from "./activeStylesheets.js";
|
|
3
|
+
/**
|
|
4
|
+
* Source directories that a Vite host explicitly owns.
|
|
5
|
+
*
|
|
6
|
+
* Vite's resolved root is always included by the adapter. `sourceRoots` lets a
|
|
7
|
+
* monorepo host add authored workspace packages without treating every file
|
|
8
|
+
* reachable through Vite's module graph as application code. Generated roots
|
|
9
|
+
* are excluded even when a caller accidentally includes them in a source
|
|
10
|
+
* root.
|
|
11
|
+
*/
|
|
12
|
+
export interface ViteSourceScopeOptions {
|
|
13
|
+
readonly sourceRoots?: readonly string[];
|
|
14
|
+
readonly generatedRoots?: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
export declare function isHostApplicationSource(id: string, projectRoot: string | undefined, options?: ViteSourceScopeOptions): boolean;
|
|
17
|
+
export declare function isPackageStylesheet(id: string, projectRoot: string | undefined, options?: ViteSourceScopeOptions): boolean;
|
|
18
|
+
/** Keep package sources useful to people without serialising machine paths. */
|
|
19
|
+
export declare function catalogSourcePath(id: string, projectRoot: string | undefined, options?: ViteSourceScopeOptions): string;
|
|
20
|
+
export interface ViteStylesheetArtifactInput {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly projectRoot: string | undefined;
|
|
23
|
+
readonly sourceRoots?: readonly string[];
|
|
24
|
+
readonly generatedRoots?: readonly string[];
|
|
25
|
+
readonly stage: ArtifactStage;
|
|
26
|
+
readonly content?: string;
|
|
27
|
+
readonly failed?: boolean;
|
|
28
|
+
readonly order?: number;
|
|
29
|
+
readonly discoveryOrder?: number;
|
|
30
|
+
/** Explicit graph-level v4 detection avoids mistaking Tailwind v3 --tw helpers for v4. */
|
|
31
|
+
readonly tailwindV4?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** Map Vite-specific identity and evidence into the neutral artifact contract. */
|
|
34
|
+
export declare function createViteStylesheetArtifact(input: ViteStylesheetArtifactInput): StylesheetArtifact;
|
|
35
|
+
export interface OrderedViteStylesheet {
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly code: string;
|
|
38
|
+
readonly order?: number;
|
|
39
|
+
readonly discoveryOrder?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A single active root proves nested CSS import order. Multiple independent
|
|
43
|
+
* roots have no proven cross-root cascade order, so their traversal rank stays
|
|
44
|
+
* discovery evidence.
|
|
45
|
+
*/
|
|
46
|
+
export declare function orderViteStylesheetGraph(graph: CssImportGraph, activeRootCount: number): OrderedViteStylesheet[];
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { isAbsolute, relative, resolve, sep, } from "node:path";
|
|
2
|
+
import { relativePath } from "../../../compiler/index.js";
|
|
3
|
+
import { detectTailwindV4 } from "../../../css/dialects/index.js";
|
|
4
|
+
import { stripCssQuery } from "./activeStylesheets.js";
|
|
5
|
+
const GENERATED_DIRECTORY_NAMES = new Set([
|
|
6
|
+
".astro",
|
|
7
|
+
".next",
|
|
8
|
+
".svelte-kit",
|
|
9
|
+
"build",
|
|
10
|
+
"coverage",
|
|
11
|
+
"dist",
|
|
12
|
+
"out",
|
|
13
|
+
"storybook-static",
|
|
14
|
+
]);
|
|
15
|
+
export function isHostApplicationSource(id, projectRoot, options = {}) {
|
|
16
|
+
if (!projectRoot || id.startsWith("\0"))
|
|
17
|
+
return false;
|
|
18
|
+
const fileId = stripCssQuery(id).replace(/\\/g, "/");
|
|
19
|
+
if (fileId.split("/").includes("node_modules")) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const absoluteFile = isAbsolute(fileId)
|
|
23
|
+
? resolve(fileId)
|
|
24
|
+
: resolve(projectRoot, fileId);
|
|
25
|
+
const primaryRoot = resolve(projectRoot);
|
|
26
|
+
const roots = [primaryRoot, ...(options.sourceRoots ?? [])
|
|
27
|
+
.map((sourceRoot) => resolve(projectRoot, sourceRoot))];
|
|
28
|
+
const generatedRoots = (options.generatedRoots ?? [])
|
|
29
|
+
.map((generatedRoot) => resolve(projectRoot, generatedRoot));
|
|
30
|
+
if (isInsideAnyRoot(absoluteFile, generatedRoots))
|
|
31
|
+
return false;
|
|
32
|
+
const sourceRoot = roots.find((candidate) => isInsideRoot(absoluteFile, candidate));
|
|
33
|
+
if (!sourceRoot)
|
|
34
|
+
return false;
|
|
35
|
+
// A generated directory can be nested in an authored workspace package, so a
|
|
36
|
+
// declared source root keeps a conservative name-based guard. The primary
|
|
37
|
+
// root does not: there, a directory named `build` may be ordinary authored
|
|
38
|
+
// source, and the resolved output directory is already excluded above.
|
|
39
|
+
if (sourceRoot !== primaryRoot) {
|
|
40
|
+
const pathSegments = relative(sourceRoot, absoluteFile).split(sep).filter(Boolean);
|
|
41
|
+
if (pathSegments.some((segment) => GENERATED_DIRECTORY_NAMES.has(segment))) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
export function isPackageStylesheet(id, projectRoot, options = {}) {
|
|
48
|
+
return !isHostApplicationSource(id, projectRoot, options);
|
|
49
|
+
}
|
|
50
|
+
/** Keep package sources useful to people without serialising machine paths. */
|
|
51
|
+
export function catalogSourcePath(id, projectRoot, options = {}) {
|
|
52
|
+
const fileId = stripCssQuery(id).replace(/\\/g, "/");
|
|
53
|
+
if (!isPackageStylesheet(fileId, projectRoot, options)) {
|
|
54
|
+
return relativePath(fileId, projectRoot);
|
|
55
|
+
}
|
|
56
|
+
const nodeModules = fileId.lastIndexOf("/node_modules/");
|
|
57
|
+
if (nodeModules >= 0)
|
|
58
|
+
return fileId.slice(nodeModules + "/node_modules/".length);
|
|
59
|
+
if (projectRoot)
|
|
60
|
+
return relative(projectRoot, fileId).replace(/\\/g, "/");
|
|
61
|
+
return fileId.replace(/^\//, "");
|
|
62
|
+
}
|
|
63
|
+
/** Map Vite-specific identity and evidence into the neutral artifact contract. */
|
|
64
|
+
export function createViteStylesheetArtifact(input) {
|
|
65
|
+
const fileId = stripCssQuery(input.id);
|
|
66
|
+
// The artifact input already carries the scope fields, so it is the scope.
|
|
67
|
+
const sourceScope = input;
|
|
68
|
+
return {
|
|
69
|
+
buildTool: "vite",
|
|
70
|
+
id: catalogSourcePath(fileId, input.projectRoot, sourceScope),
|
|
71
|
+
stage: input.stage,
|
|
72
|
+
provenance: isHostApplicationSource(fileId, input.projectRoot, sourceScope) ? "project" : "package",
|
|
73
|
+
...(input.order !== undefined ? { order: input.order } : {}),
|
|
74
|
+
...(input.discoveryOrder !== undefined ? { discoveryOrder: input.discoveryOrder } : {}),
|
|
75
|
+
...(input.content !== undefined ? {
|
|
76
|
+
content: input.content,
|
|
77
|
+
adapter: (input.tailwindV4 ?? detectTailwindV4(input.content)) ? "tailwind-v4" : undefined,
|
|
78
|
+
} : {}),
|
|
79
|
+
...(input.failed ? { failed: true } : {}),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function isInsideAnyRoot(file, roots) {
|
|
83
|
+
return roots.some((root) => isInsideRoot(file, root));
|
|
84
|
+
}
|
|
85
|
+
function isInsideRoot(file, root) {
|
|
86
|
+
const relativeFile = relative(resolve(root), resolve(file));
|
|
87
|
+
return relativeFile !== ""
|
|
88
|
+
&& relativeFile !== ".."
|
|
89
|
+
&& !relativeFile.startsWith(`..${sep}`)
|
|
90
|
+
&& !isAbsolute(relativeFile);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A single active root proves nested CSS import order. Multiple independent
|
|
94
|
+
* roots have no proven cross-root cascade order, so their traversal rank stays
|
|
95
|
+
* discovery evidence.
|
|
96
|
+
*/
|
|
97
|
+
export function orderViteStylesheetGraph(graph, activeRootCount) {
|
|
98
|
+
const authoritative = activeRootCount === 1;
|
|
99
|
+
return graph.order.map((id, index) => ({
|
|
100
|
+
id,
|
|
101
|
+
code: graph.files.get(id),
|
|
102
|
+
...(authoritative ? { order: index } : { discoveryOrder: index }),
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TokenCatalogDiagnostic, TokenDefinition, TokenEntry } from "../../../css/model/index.js";
|
|
2
|
+
export type { TokenCatalogDiagnostic, TokenContext, TokenContextWrapper, TokenContextWrapperKind, TokenDeclaration, TokenDefinition, TokenEntry, } from "../../../css/model/index.js";
|
|
3
|
+
export declare const tokenTable: Record<string, TokenEntry>;
|
|
4
|
+
/** Authoritative contextual inventory. Runtime values still come from CSS. */
|
|
5
|
+
export declare const tokenCatalog: TokenDefinition[];
|
|
6
|
+
export declare const tokenDiagnostics: TokenCatalogDiagnostic[];
|
|
7
|
+
/** Inventory snapshot fingerprint; browser inspection refreshes on change. */
|
|
8
|
+
export declare const tokenGeneration: string;
|
|
9
|
+
export default tokenTable;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const tokenTable = {};
|
|
2
|
+
/** Authoritative contextual inventory. Runtime values still come from CSS. */
|
|
3
|
+
export const tokenCatalog = [];
|
|
4
|
+
export const tokenDiagnostics = [];
|
|
5
|
+
/** Inventory snapshot fingerprint; browser inspection refreshes on change. */
|
|
6
|
+
export const tokenGeneration = "";
|
|
7
|
+
export default tokenTable;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference path="../../css/virtual-design-tokens.d.ts" />
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import type { TailwindV3Config, ThemeContract } from "../../css/dialects/index.js";
|
|
3
|
+
import type { FrameworkHost, FrameworkSupport, ReactOptions } from "./react.js";
|
|
4
|
+
/**
|
|
5
|
+
* How to find the project's vanilla-extract theme contract. Loading a module
|
|
6
|
+
* is a host capability, so the specifier lives here; what the contract means
|
|
7
|
+
* is interpreted in `nudge-ui/css/dialects`.
|
|
8
|
+
*/
|
|
9
|
+
export interface VanillaExtractOptions {
|
|
10
|
+
themeContract?: ThemeContract;
|
|
11
|
+
/** A Vite-resolvable module exporting a published compiled contract. */
|
|
12
|
+
themeContractModule?: string;
|
|
13
|
+
/** Defaults to `vars`. */
|
|
14
|
+
themeContractExport?: string;
|
|
15
|
+
themeContractPrefix?: string;
|
|
16
|
+
/** Known compiled values by custom-property name. */
|
|
17
|
+
cssValues?: Readonly<Record<string, string>>;
|
|
18
|
+
source?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface NudgeUiOptions extends ReactOptions {
|
|
21
|
+
enabled?: boolean;
|
|
22
|
+
/** Enables experimental DOM parent/child navigation in the Inspector. */
|
|
23
|
+
debug?: boolean;
|
|
24
|
+
/** The landing app's demo runtime: mounted at root in dev and `nudge-demo` builds, or via `?nudgeDemo=1`. */
|
|
25
|
+
demo?: boolean;
|
|
26
|
+
/** Explicit project ID for browser-storage keys (defaults to root directory basename). */
|
|
27
|
+
projectId?: string;
|
|
28
|
+
/** Optional static v3 config for fixture/app integrations; dynamic configs are not executed. */
|
|
29
|
+
tailwindV3?: {
|
|
30
|
+
config: TailwindV3Config;
|
|
31
|
+
source?: string;
|
|
32
|
+
};
|
|
33
|
+
vanillaExtract?: VanillaExtractOptions;
|
|
34
|
+
/**
|
|
35
|
+
* Authored workspace directories outside Vite's resolved root. Dependencies
|
|
36
|
+
* and generated output stay excluded even when a broad directory is given.
|
|
37
|
+
*/
|
|
38
|
+
sourceRoots?: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Extracts the stylesheet string Vite embeds in dev CSS-module JS wrappers
|
|
42
|
+
* (`const __vite__css = "…"`). Returns null for anything that is not such a
|
|
43
|
+
* wrapper, so callers can feed the original code unchanged.
|
|
44
|
+
*/
|
|
45
|
+
export declare function extractViteModuleCss(code: string): string | null;
|
|
46
|
+
export interface TransformIndexHtmlOptions {
|
|
47
|
+
/** Inject the debug mount div instead of the standard one. */
|
|
48
|
+
debug?: boolean;
|
|
49
|
+
/** Keep the injection in a `build` command (explicit demo builds only). */
|
|
50
|
+
demoBuild?: boolean;
|
|
51
|
+
/** Keep the route-sensitive landing demo on its build-time virtual module. */
|
|
52
|
+
demo?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export declare function transformIndexHtmlHtml(html: string, command: "serve" | "build", { debug, demoBuild, demo }?: TransformIndexHtmlOptions): string | null;
|
|
55
|
+
/**
|
|
56
|
+
* Owns the build tool and nothing else: module graph, CSS observation, token
|
|
57
|
+
* inventory, transport middleware, bootstrap injection, HMR. Framework
|
|
58
|
+
* semantics arrive through `createFramework`; passing `null` is a supported
|
|
59
|
+
* composition, and `vite.noFramework.test.ts` exercises it to prove nothing
|
|
60
|
+
* here has grown a React assumption.
|
|
61
|
+
*/
|
|
62
|
+
export declare function createVitePlugins(options?: NudgeUiOptions, createFramework?: ((options: NudgeUiOptions, host: FrameworkHost) => FrameworkSupport) | null): Plugin[];
|