nudge-ui 0.2.3 → 0.2.5
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/dist/cli/agentCommand.js +4 -28
- package/dist/client.mjs +870 -212
- package/dist/hosts/next/wrapper.js +1 -7
- package/dist/hosts/projectBridge.js +3 -17
- package/dist/inspector/agent/McpConnectionDialog.js +7 -3
- package/dist/inspector/agent/activity.d.ts +1 -1
- package/dist/inspector/agent/activity.js +3 -2
- package/dist/inspector/agent/client.d.ts +2 -2
- package/dist/inspector/agent/client.js +28 -29
- package/dist/inspector/agent/connectionStatus.d.ts +3 -1
- package/dist/inspector/agent/connectionStatus.js +25 -0
- package/dist/inspector/agent/httpTransport.js +31 -147
- package/dist/inspector/agent/protocol.d.ts +1 -1
- package/dist/inspector/agent/protocol.js +1 -1
- package/dist/inspector/agent/verification.d.ts +5 -7
- package/dist/inspector/agent/verification.js +67 -20
- package/dist/inspector/boot.d.ts +3 -0
- package/dist/inspector/boot.js +297 -0
- package/dist/inspector/canvas/AgentActivityOverlay.d.ts +2 -1
- package/dist/inspector/canvas/AgentActivityOverlay.js +6 -3
- package/dist/inspector/canvas/CanvasCard.js +23 -12
- package/dist/inspector/canvas/CanvasElementOverlay.js +97 -128
- package/dist/inspector/canvas/CanvasToolbar.js +2 -1
- package/dist/inspector/canvas/CanvasWorkspace.js +119 -162
- package/dist/inspector/canvas/LockedWorkspaceNotice.d.ts +3 -2
- package/dist/inspector/canvas/LockedWorkspaceNotice.js +10 -6
- package/dist/inspector/canvas/PageCard.d.ts +10 -0
- package/dist/inspector/canvas/PageCard.js +51 -0
- package/dist/inspector/canvas/SketchToolOptions.d.ts +5 -0
- package/dist/inspector/canvas/SketchToolOptions.js +86 -0
- package/dist/inspector/canvas/StaleChangeIndicator.d.ts +1 -1
- package/dist/inspector/canvas/StaleChangeIndicator.js +1 -1
- package/dist/inspector/canvas/ToolOptionsDrawer.d.ts +21 -0
- package/dist/inspector/canvas/ToolOptionsDrawer.js +77 -0
- package/dist/inspector/canvas/activeCanvasDocument.d.ts +3 -2
- package/dist/inspector/canvas/assets/eraser.svg +28 -0
- package/dist/inspector/canvas/assets/pen.svg +25 -0
- package/dist/inspector/canvas/canvasFrame.d.ts +16 -0
- package/dist/inspector/canvas/canvasFrame.js +10 -0
- package/dist/inspector/canvas/canvasGestures.d.ts +0 -1
- package/dist/inspector/canvas/canvasGestures.js +0 -6
- package/dist/inspector/canvas/canvasStore.d.ts +6 -0
- package/dist/inspector/canvas/canvasStore.js +36 -1
- package/dist/inspector/canvas/frameConnection.d.ts +48 -0
- package/dist/inspector/canvas/frameConnection.js +73 -0
- package/dist/inspector/canvas/frameProtocol.d.ts +18 -1
- package/dist/inspector/canvas/frameProtocol.js +36 -0
- package/dist/inspector/canvas/frameScrollbarStyles.d.ts +3 -0
- package/dist/inspector/canvas/frameScrollbarStyles.js +21 -0
- package/dist/inspector/canvas/pageSurface.d.ts +11 -0
- package/dist/inspector/canvas/pageSurface.js +34 -0
- package/dist/inspector/canvas/projection.d.ts +19 -9
- package/dist/inspector/canvas/projection.js +58 -31
- package/dist/inspector/canvas/rendererBootstrap.js +4 -1
- package/dist/inspector/canvas/rendererElementSelector.js +9 -1
- package/dist/inspector/canvas/rendererMessageRouter.d.ts +4 -5
- package/dist/inspector/canvas/rendererMessageRouter.js +12 -16
- package/dist/inspector/canvas/rendererSelectionProxy.d.ts +7 -1
- package/dist/inspector/canvas/rendererSelectionProxy.js +8 -36
- package/dist/inspector/canvas/rendererStylesheet.js +15 -0
- package/dist/inspector/canvas/sessionStore.d.ts +2 -2
- package/dist/inspector/canvas/sessionStore.js +12 -9
- package/dist/inspector/canvas/staleChangeDetector.d.ts +1 -1
- package/dist/inspector/canvas/staleChangeDetector.js +10 -22
- package/dist/inspector/changes/codecs.d.ts +2 -0
- package/dist/inspector/changes/codecs.js +27 -3
- package/dist/inspector/changes/draftPreview.d.ts +12 -0
- package/dist/inspector/changes/draftPreview.js +133 -0
- package/dist/inspector/changes/editModel.d.ts +18 -0
- package/dist/inspector/changes/editModel.js +16 -3
- package/dist/inspector/changes/managedStyleProjection.js +2 -1
- package/dist/inspector/changes/previewDiagnostics.js +1 -1
- package/dist/inspector/changes/types.d.ts +18 -1
- package/dist/inspector/comments/CommentsOverlay.js +18 -16
- package/dist/inspector/comments/element.js +10 -3
- package/dist/inspector/comments/store.js +3 -2
- package/dist/inspector/comments/verification.js +1 -1
- package/dist/inspector/componentSemantics/ComponentPropsSection.js +2 -1
- package/dist/inspector/componentSemantics/adapterRegistry.d.ts +6 -1
- package/dist/inspector/componentSemantics/adapterRegistry.js +23 -1
- package/dist/inspector/componentSemantics/changeAction.js +1 -1
- package/dist/inspector/componentSemantics/reactRuntime.d.ts +2 -1
- package/dist/inspector/componentSemantics/reactRuntime.js +38 -0
- package/dist/inspector/componentSemantics/runtimeBridge.d.ts +4 -2
- package/dist/inspector/componentSemantics/runtimeBridge.js +17 -0
- package/dist/inspector/componentSemantics/textBinding.d.ts +1 -2
- package/dist/inspector/componentSemantics/textBinding.js +4 -45
- package/dist/inspector/componentSemantics/types.d.ts +11 -0
- package/dist/inspector/drafts/draftStore.d.ts +109 -0
- package/dist/inspector/drafts/draftStore.js +451 -0
- package/dist/inspector/drafts/model.d.ts +9 -1
- package/dist/inspector/drafts/model.js +5 -1
- package/dist/inspector/drafts/store.d.ts +53 -15
- package/dist/inspector/drafts/store.js +143 -169
- package/dist/inspector/index.d.ts +2 -4
- package/dist/inspector/index.js +2 -264
- package/dist/inspector/inline-text/inlineTextEditor.d.ts +1 -1
- package/dist/inspector/inline-text/inlineTextEditor.js +1 -2
- package/dist/inspector/inline-text/textEditChange.d.ts +1 -1
- package/dist/inspector/inspection/bridge.d.ts +1 -1
- package/dist/inspector/inspection/bridge.js +2 -1
- package/dist/inspector/inspection/browserCssInspection.d.ts +8 -0
- package/dist/inspector/inspection/browserCssInspection.js +28 -6
- package/dist/inspector/inspection/inspectionSnapshot.d.ts +6 -0
- package/dist/inspector/inspection/inspectionSnapshot.js +10 -0
- package/dist/inspector/inspection/performanceDiagnostics.d.ts +18 -0
- package/dist/inspector/inspection/performanceDiagnostics.js +31 -0
- package/dist/inspector/inspection/useBrowserCssInspection.js +17 -38
- package/dist/inspector/iterations/capture.d.ts +2 -1
- package/dist/inspector/iterations/capture.js +2 -1
- package/dist/inspector/iterations/client.d.ts +2 -1
- package/dist/inspector/iterations/coordinator.d.ts +4 -3
- package/dist/inspector/iterations/coordinator.js +5 -3
- package/dist/inspector/iterations/prompt.js +9 -8
- package/dist/inspector/overlay/interactionStyles.js +17 -0
- package/dist/inspector/pageInspector.d.ts +42 -0
- package/dist/inspector/pageInspector.js +342 -0
- package/dist/inspector/projection/draftProjection.d.ts +10 -2
- package/dist/inspector/projection/draftProjection.js +9 -1
- package/dist/inspector/projection/managedStylesheet.js +24 -4
- package/dist/inspector/projection/renderedInstance.d.ts +15 -2
- package/dist/inspector/projection/renderedInstance.js +60 -7
- package/dist/inspector/projection/structuralProjection.d.ts +0 -9
- package/dist/inspector/projection/structuralProjection.js +16 -46
- package/dist/inspector/projection/textProjection.d.ts +8 -2
- package/dist/inspector/projection/textProjection.js +77 -24
- package/dist/inspector/prompt/clipboardHandoff.d.ts +14 -0
- package/dist/inspector/prompt/clipboardHandoff.js +47 -16
- package/dist/inspector/prompt/generatePrompt.d.ts +1 -1
- package/dist/inspector/prompt/generatePrompt.js +248 -148
- package/dist/inspector/prompt/promptDocument.d.ts +3 -0
- package/dist/inspector/prompt/promptDocument.js +8 -0
- package/dist/inspector/prompt/promptSettings.js +7 -5
- package/dist/inspector/runtime/inspectorStorage.d.ts +17 -0
- package/dist/inspector/runtime/inspectorStorage.js +42 -0
- package/dist/inspector/runtime/ownedStylesheets.d.ts +20 -0
- package/dist/inspector/runtime/ownedStylesheets.js +72 -0
- package/dist/inspector/runtime/runtimeConfig.d.ts +4 -0
- package/dist/inspector/runtime/runtimeConfig.js +10 -1
- package/dist/inspector/runtime/runtimeIdentityClaims.d.ts +29 -0
- package/dist/inspector/runtime/runtimeIdentityClaims.js +188 -0
- package/dist/inspector/runtime/staticHtmlRuntimeIdentity.d.ts +15 -0
- package/dist/inspector/runtime/staticHtmlRuntimeIdentity.js +113 -29
- package/dist/inspector/selection/editScope.d.ts +1 -0
- package/dist/inspector/selection/editScope.js +13 -2
- package/dist/inspector/selection/sourceSite.d.ts +12 -0
- package/dist/inspector/selection/sourceSite.js +28 -0
- package/dist/inspector/shell/AgentStatusButton.js +2 -2
- package/dist/inspector/shell/AppShell.js +6 -2
- package/dist/inspector/shell/ChangesLog.js +27 -9
- package/dist/inspector/shell/CopyPromptButton.js +74 -26
- package/dist/inspector/shell/EmptyState.js +3 -3
- package/dist/inspector/shell/InspectorShell.d.ts +0 -3
- package/dist/inspector/shell/InspectorShell.js +21 -13
- package/dist/inspector/shell/PeekOriginalButton.js +3 -3
- package/dist/inspector/shell/interactionStatePreview.d.ts +9 -0
- package/dist/inspector/shell/interactionStatePreview.js +112 -0
- package/dist/inspector/shell/originalPreview.d.ts +3 -2
- package/dist/inspector/shell/originalPreview.js +10 -37
- package/dist/inspector/shell/stateValue.js +2 -3
- package/dist/inspector/sketch/SketchEditor.js +5 -4
- package/dist/inspector/sketch/SketchFrameOverlay.d.ts +2 -1
- package/dist/inspector/sketch/SketchFrameOverlay.js +5 -4
- package/dist/inspector/sketch/SketchOverlay.d.ts +3 -5
- package/dist/inspector/sketch/SketchOverlay.js +139 -263
- package/dist/inspector/sketch/SketchPromptPanel.d.ts +1 -1
- package/dist/inspector/sketch/SketchPromptPanel.js +8 -1
- package/dist/inspector/sketch/SketchThumbnail.d.ts +5 -0
- package/dist/inspector/sketch/SketchThumbnail.js +18 -0
- package/dist/inspector/sketch/SketchWorkspace.d.ts +1 -2
- package/dist/inspector/sketch/SketchWorkspace.js +69 -34
- package/dist/inspector/sketch/capture.js +19 -3
- package/dist/inspector/sketch/copySketch.d.ts +10 -0
- package/dist/inspector/sketch/copySketch.js +52 -0
- package/dist/inspector/sketch/drawingTools.d.ts +17 -0
- package/dist/inspector/sketch/drawingTools.js +47 -0
- package/dist/inspector/sketch/frameHeading.d.ts +9 -0
- package/dist/inspector/sketch/frameHeading.js +30 -0
- package/dist/inspector/sketch/freehand.js +3 -3
- package/dist/inspector/sketch/geometry.d.ts +6 -0
- package/dist/inspector/sketch/geometry.js +19 -0
- package/dist/inspector/sketch/history.d.ts +30 -0
- package/dist/inspector/sketch/history.js +58 -0
- package/dist/inspector/sketch/interaction.d.ts +1 -3
- package/dist/inspector/sketch/interaction.js +6 -9
- package/dist/inspector/sketch/model.d.ts +35 -1
- package/dist/inspector/sketch/model.js +116 -61
- package/dist/inspector/sketch/persistence.d.ts +14 -0
- package/dist/inspector/sketch/persistence.js +63 -7
- package/dist/inspector/sketch/raster.d.ts +6 -2
- package/dist/inspector/sketch/raster.js +43 -17
- package/dist/inspector/sketch/store.d.ts +1 -1
- package/dist/inspector/sketch/store.js +1 -1
- package/dist/inspector/sketch/videoFrames.d.ts +6 -0
- package/dist/inspector/sketch/videoFrames.js +81 -0
- package/dist/inspector/styleEditors/BackgroundEditor.js +3 -2
- package/dist/inspector/styleEditors/BorderEditor.js +30 -130
- package/dist/inspector/styleEditors/BorderRadiusEditor.js +8 -3
- package/dist/inspector/styleEditors/ImageBackgroundEditor.js +1 -1
- package/dist/inspector/styleEditors/LayoutSection.js +2 -2
- package/dist/inspector/styleEditors/borderModel.d.ts +42 -0
- package/dist/inspector/styleEditors/borderModel.js +114 -0
- package/dist/inspector/styleEditors/layoutValue.js +2 -3
- package/dist/inspector/tokens/TokenField.js +40 -7
- package/dist/inspector/tokens/TokensPanel.js +2 -1
- package/dist/inspector/tokens/editActions.d.ts +3 -3
- package/dist/inspector/tokens/editActions.js +15 -3
- package/dist/inspector/tokens/resolution/containerQueryEvaluator.d.ts +15 -0
- package/dist/inspector/tokens/resolution/containerQueryEvaluator.js +86 -0
- package/dist/inspector/tokens/resolution/cssomCollector.js +44 -9
- package/dist/inspector/tokens/resolution/nestedSelectors.d.ts +6 -0
- package/dist/inspector/tokens/resolution/nestedSelectors.js +67 -0
- package/dist/inspector/tokens/resolution/ruleMatching.js +23 -4
- package/dist/inspector/tokens/resolution.d.ts +6 -3
- package/dist/inspector/tokens/resolution.js +91 -112
- package/dist/inspector/tokens/tokenEdits.d.ts +1 -1
- package/dist/inspector/tokens/tokenEdits.js +1 -1
- package/dist/inspector/ui/InlineStyleWarning.js +2 -2
- package/dist/inspector/ui/InspectorStyle.d.ts +8 -0
- package/dist/inspector/ui/InspectorStyle.js +26 -0
- package/dist/inspector/ui/PopoverListbox.d.ts +2 -1
- package/dist/inspector/ui/PopoverListbox.js +3 -3
- package/dist/inspector/ui/Toast.d.ts +14 -0
- package/dist/inspector/ui/Toast.js +30 -0
- package/dist/inspector/ui/assets/canvasIllustration.d.ts +2 -0
- package/dist/inspector/ui/assets/canvasIllustration.js +21 -0
- package/dist/inspector/ui/assets/gridIllustration.d.ts +2 -0
- package/dist/inspector/ui/assets/{grid.svg → gridIllustration.js} +3 -2
- package/dist/inspector/ui/customCursors.d.ts +5 -0
- package/dist/inspector/ui/customCursors.js +32 -6
- package/dist/inspector/ui/styles.js +12 -10
- package/dist/inspector/workspace/commands.js +1 -2
- package/dist/inspector/workspace/controller.js +1 -2
- package/dist/inspector/workspace/handoff.js +3 -2
- package/dist/inspector/workspace/sentItems.d.ts +16 -0
- package/dist/inspector/workspace/sentItems.js +33 -0
- package/dist/inspector/workspace/timeline.d.ts +24 -10
- package/dist/inspector/workspace/timeline.js +118 -96
- package/dist/internal/agent-protocol.d.ts +50 -13
- package/dist/internal/agent-protocol.js +145 -19
- package/dist/nudge-ui.mjs +81 -65
- package/dist/project/mcpPackage.d.ts +8 -0
- package/dist/project/mcpPackage.js +60 -0
- package/package.json +13 -3
- package/dist/inspector/canvas/measurementProjection.d.ts +0 -8
- package/dist/inspector/canvas/measurementProjection.js +0 -16
- package/dist/inspector/changes/changesLog.d.ts +0 -47
- package/dist/inspector/changes/changesLog.js +0 -247
- package/dist/inspector/changes/draftChanges.d.ts +0 -56
- package/dist/inspector/changes/draftChanges.js +0 -300
- package/dist/inspector/conformance/projection.d.ts +0 -2
- package/dist/inspector/conformance/projection.js +0 -3
- package/dist/inspector/inline-text/textChangeBoundary.d.ts +0 -6
- package/dist/inspector/inline-text/textChangeBoundary.js +0 -1
- package/dist/inspector/overlay/InspectorOverlay.d.ts +0 -5
- package/dist/inspector/overlay/InspectorOverlay.js +0 -332
- package/dist/inspector/overlay/elementSelector.d.ts +0 -1
- package/dist/inspector/overlay/elementSelector.js +0 -111
- package/dist/inspector/sketch/SketchChanges.d.ts +0 -2
- package/dist/inspector/sketch/SketchChanges.js +0 -72
- package/dist/inspector/sketch/SketchEntryButton.d.ts +0 -4
- package/dist/inspector/sketch/SketchEntryButton.js +0 -11
- package/dist/inspector/sketch/SketchLayersPanel.d.ts +0 -2
- package/dist/inspector/sketch/SketchLayersPanel.js +0 -71
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { useLayoutEffect } from "react";
|
|
2
|
+
import { collectRules, invalidateStyleResolutionCache, subscribeDocumentRevision } from "../tokens/resolution/cssomCollector.js";
|
|
3
|
+
import { selectorPseudoClasses, splitSelectorAtTopLevel } from "../tokens/resolution/selectorSemantics.js";
|
|
4
|
+
import { adoptStylesheet, allowsStyleElements, releaseAdoptedStylesheet, STATE_PREVIEW_SHEET_ID } from "../runtime/ownedStylesheets.js";
|
|
5
|
+
import { INTERACTION_STATES } from "./styleState.js";
|
|
6
|
+
const MARKER = "data-nudge-ui-state-preview";
|
|
7
|
+
const interactionStates = new Set(INTERACTION_STATES);
|
|
8
|
+
/** Matches native interaction states and the Inspector's temporary CSS state. */
|
|
9
|
+
export function selectorForInteractionStatePreview(selector) {
|
|
10
|
+
let transformed = selector;
|
|
11
|
+
for (const pseudo of [...selectorPseudoClasses(selector)].reverse()) {
|
|
12
|
+
if (!interactionStates.has(pseudo.name))
|
|
13
|
+
continue;
|
|
14
|
+
// Keep native states on other elements, but use the chosen state on the
|
|
15
|
+
// selected element. :where() keeps the original pseudo-class specificity.
|
|
16
|
+
const replacement = `:is(:${pseudo.name}:where(:not([${MARKER}])), [${MARKER}="${pseudo.name}"])`;
|
|
17
|
+
transformed = transformed.slice(0, pseudo.start) + replacement + transformed.slice(pseudo.end);
|
|
18
|
+
}
|
|
19
|
+
return transformed;
|
|
20
|
+
}
|
|
21
|
+
function previewSelector(selector) {
|
|
22
|
+
const transformed = selectorForInteractionStatePreview(selector);
|
|
23
|
+
// Add the same specificity to every copied branch. This preserves their
|
|
24
|
+
// relative cascade while overriding native pointer states on the target.
|
|
25
|
+
const scope = `:where([${MARKER}], [${MARKER}] *):is(#${STATE_PREVIEW_SHEET_ID}, *)`;
|
|
26
|
+
// A scope must precede a pseudo-element, which cannot take an attribute.
|
|
27
|
+
let parentheses = 0;
|
|
28
|
+
let brackets = 0;
|
|
29
|
+
let quote = null;
|
|
30
|
+
for (let index = 0; index < transformed.length; index++) {
|
|
31
|
+
const character = transformed[index];
|
|
32
|
+
if (character === "\\") {
|
|
33
|
+
index++;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (quote) {
|
|
37
|
+
if (character === quote)
|
|
38
|
+
quote = null;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (character === '"' || character === "'") {
|
|
42
|
+
quote = character;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (character === "[")
|
|
46
|
+
brackets++;
|
|
47
|
+
else if (character === "]")
|
|
48
|
+
brackets--;
|
|
49
|
+
else if (brackets === 0) {
|
|
50
|
+
if (character === "(")
|
|
51
|
+
parentheses++;
|
|
52
|
+
else if (character === ")")
|
|
53
|
+
parentheses--;
|
|
54
|
+
else if (parentheses === 0 && /^::|^:(?:before|after|first-line|first-letter)\b/.test(transformed.slice(index))) {
|
|
55
|
+
return transformed.slice(0, index) + scope + transformed.slice(index);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return transformed + scope;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Projects CSS interaction states into the selected element's document.
|
|
63
|
+
* This previews styles without dispatching events or changing application state.
|
|
64
|
+
*/
|
|
65
|
+
export function startInteractionStatePreview(element, state) {
|
|
66
|
+
if (state === "base")
|
|
67
|
+
return () => undefined;
|
|
68
|
+
const doc = element.ownerDocument;
|
|
69
|
+
const previousMarker = element.getAttribute(MARKER);
|
|
70
|
+
element.setAttribute(MARKER, state);
|
|
71
|
+
const style = allowsStyleElements(doc) ? doc.createElement("style") : null;
|
|
72
|
+
if (style) {
|
|
73
|
+
style.id = STATE_PREVIEW_SHEET_ID;
|
|
74
|
+
style.setAttribute("data-nudge-ui", "state-preview");
|
|
75
|
+
(doc.head ?? doc.documentElement).appendChild(style);
|
|
76
|
+
}
|
|
77
|
+
const refresh = () => {
|
|
78
|
+
const css = collectRules(doc).rules.map((rule) => {
|
|
79
|
+
const selector = splitSelectorAtTopLevel(rule.selectorText, ",")
|
|
80
|
+
.map((branch) => previewSelector(branch.trim())).join(", ");
|
|
81
|
+
const declarations = rule.declarations.map(({ property, value, important }) => `${property}: ${value}${important ? " !important" : ""};`).join(" ");
|
|
82
|
+
let text = `${selector} { ${declarations} }`;
|
|
83
|
+
for (const wrapper of [...(rule.atRules ?? [])].reverse()) {
|
|
84
|
+
text = `@${wrapper.kind} ${wrapper.params} { ${text} }`;
|
|
85
|
+
}
|
|
86
|
+
if (rule.layer)
|
|
87
|
+
text = `@layer ${rule.layer} { ${text} }`;
|
|
88
|
+
return text;
|
|
89
|
+
}).join("\n");
|
|
90
|
+
if (style)
|
|
91
|
+
style.textContent = css;
|
|
92
|
+
else
|
|
93
|
+
adoptStylesheet(doc, STATE_PREVIEW_SHEET_ID, css);
|
|
94
|
+
};
|
|
95
|
+
refresh();
|
|
96
|
+
// Inspection excludes the preview sheet, but its painted values have changed.
|
|
97
|
+
invalidateStyleResolutionCache(doc);
|
|
98
|
+
const unsubscribe = subscribeDocumentRevision(doc, refresh);
|
|
99
|
+
return () => {
|
|
100
|
+
unsubscribe();
|
|
101
|
+
style?.remove();
|
|
102
|
+
releaseAdoptedStylesheet(doc, STATE_PREVIEW_SHEET_ID);
|
|
103
|
+
if (previousMarker === null)
|
|
104
|
+
element.removeAttribute(MARKER);
|
|
105
|
+
else
|
|
106
|
+
element.setAttribute(MARKER, previousMarker);
|
|
107
|
+
invalidateStyleResolutionCache(doc);
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export function useInteractionStatePreview(element, state) {
|
|
111
|
+
useLayoutEffect(() => element ? startInteractionStatePreview(element, state) : undefined, [element, state]);
|
|
112
|
+
}
|
|
@@ -3,7 +3,8 @@ export declare function subscribeOriginalPreview(listener: () => void): () => vo
|
|
|
3
3
|
export declare function useOriginalPreviewActive(): boolean;
|
|
4
4
|
/**
|
|
5
5
|
* Hold-to-view-original (NUD-30). While active the host document shows the
|
|
6
|
-
* page without any inspector changes
|
|
7
|
-
*
|
|
6
|
+
* page without any inspector changes; the draft preview owns that projection.
|
|
7
|
+
* Canonical intent stays in the workspace, so releasing restores the edited
|
|
8
|
+
* preview without loss.
|
|
8
9
|
*/
|
|
9
10
|
export declare function setOriginalPreviewActive(next: boolean): void;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { useSyncExternalStore } from "react";
|
|
2
|
-
import { draftChangeStore } from "../changes/draftChanges.js";
|
|
3
|
-
import { applyHostDraftProjection, compileDraftProjection, } from "../projection/draftProjection.js";
|
|
4
|
-
import { isEditorShellDocument } from "../runtime/editorShell.js";
|
|
5
2
|
let previewingOriginal = false;
|
|
6
3
|
const listeners = new Set();
|
|
7
4
|
export function isOriginalPreviewActive() {
|
|
@@ -16,7 +13,16 @@ export function subscribeOriginalPreview(listener) {
|
|
|
16
13
|
export function useOriginalPreviewActive() {
|
|
17
14
|
return useSyncExternalStore(subscribeOriginalPreview, () => previewingOriginal, () => false);
|
|
18
15
|
}
|
|
19
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Hold-to-view-original (NUD-30). While active the host document shows the
|
|
18
|
+
* page without any inspector changes; the draft preview owns that projection.
|
|
19
|
+
* Canonical intent stays in the workspace, so releasing restores the edited
|
|
20
|
+
* preview without loss.
|
|
21
|
+
*/
|
|
22
|
+
export function setOriginalPreviewActive(next) {
|
|
23
|
+
if (next === previewingOriginal)
|
|
24
|
+
return;
|
|
25
|
+
previewingOriginal = next;
|
|
20
26
|
for (const listener of listeners) {
|
|
21
27
|
try {
|
|
22
28
|
listener();
|
|
@@ -26,36 +32,3 @@ function notifyOriginalPreviewListeners() {
|
|
|
26
32
|
}
|
|
27
33
|
}
|
|
28
34
|
}
|
|
29
|
-
function applyEmptyHostProjection() {
|
|
30
|
-
if (isEditorShellDocument())
|
|
31
|
-
return;
|
|
32
|
-
const { revision } = draftChangeStore.getSnapshot();
|
|
33
|
-
applyHostDraftProjection({
|
|
34
|
-
sourceRevision: revision,
|
|
35
|
-
managedStyles: { rules: [], css: "" },
|
|
36
|
-
instanceOverrides: [],
|
|
37
|
-
structuralChanges: [],
|
|
38
|
-
textContentChanges: [],
|
|
39
|
-
componentOverrides: [],
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
function applyCanonicalHostProjection() {
|
|
43
|
-
if (isEditorShellDocument())
|
|
44
|
-
return;
|
|
45
|
-
applyHostDraftProjection(compileDraftProjection(draftChangeStore.getSnapshot()));
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Hold-to-view-original (NUD-30). While active the host document shows the
|
|
49
|
-
* page without any inspector changes. Canonical intent stays in the workspace
|
|
50
|
-
* store, so releasing restores the edited preview without loss.
|
|
51
|
-
*/
|
|
52
|
-
export function setOriginalPreviewActive(next) {
|
|
53
|
-
if (next === previewingOriginal)
|
|
54
|
-
return;
|
|
55
|
-
previewingOriginal = next;
|
|
56
|
-
if (previewingOriginal)
|
|
57
|
-
applyEmptyHostProjection();
|
|
58
|
-
else
|
|
59
|
-
applyCanonicalHostProjection();
|
|
60
|
-
notifyOriginalPreviewListeners();
|
|
61
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getActiveStyleState } from "./styleState.js";
|
|
2
|
-
import {
|
|
2
|
+
import { readInspectionSnapshot } from "../inspection/inspectionSnapshot.js";
|
|
3
3
|
import { getElementComputedStyle } from "../runtime/domRealm.js";
|
|
4
4
|
/** Read an inspector value from the selected authored state, falling back to
|
|
5
5
|
* the browser only when CSSOM has no declaration to attribute. */
|
|
@@ -20,8 +20,7 @@ export function getStateStyleValue(el, property, fallback = "") {
|
|
|
20
20
|
if (state === "base" && !hasLiveInteraction) {
|
|
21
21
|
return getElementComputedStyle(el).getPropertyValue(property).trim() || fallback;
|
|
22
22
|
}
|
|
23
|
-
const rows =
|
|
24
|
-
.inspect(el, { state }).properties;
|
|
23
|
+
const rows = readInspectionSnapshot(el, state)?.properties ?? [];
|
|
25
24
|
const row = rows.find((candidate) => candidate.property === property)
|
|
26
25
|
?? (property === "background-color" ? rows.find((candidate) => candidate.property === "background") : undefined);
|
|
27
26
|
if (row?.resolvedValue)
|
|
@@ -7,9 +7,10 @@ import { IconButton } from "../ui/IconButton.js";
|
|
|
7
7
|
import { StatusCallout } from "../ui/StatusCallout.js";
|
|
8
8
|
import { Tooltip } from "../ui/Tooltip.js";
|
|
9
9
|
import { renderAnnotatedPng } from "./raster.js";
|
|
10
|
+
import { sketchFrameHeading } from "./frameHeading.js";
|
|
10
11
|
import { SketchSvgLayer } from "./freehand.js";
|
|
11
12
|
import { findSketchElementAt, translateSketchAnnotation, translateSketchStroke, } from "./geometry.js";
|
|
12
|
-
import { SKETCH_LIMITS, SKETCH_ANNOTATION_RADIUS, SKETCH_STROKE_COLOR, SKETCH_STROKE_OUTLINE, SKETCH_STROKE_WIDTH, } from "./model.js";
|
|
13
|
+
import { SKETCH_LIMITS, SKETCH_ANNOTATION_RADIUS, SKETCH_STROKE_COLOR, SKETCH_STROKE_OUTLINE, SKETCH_RECTANGLE_STROKE_WIDTH, SKETCH_STROKE_WIDTH, } from "./model.js";
|
|
13
14
|
import { DRAG_CURSOR, SKETCH_CURSOR } from "../ui/customCursors.js";
|
|
14
15
|
import { portalContainer } from "../ui/portalContainer.js";
|
|
15
16
|
const SKETCH_TOOLS = [
|
|
@@ -298,7 +299,7 @@ export function SketchEditor({ open, document: sketchDocument, captured, onCance
|
|
|
298
299
|
const stroke = {
|
|
299
300
|
id: `stroke-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
300
301
|
kind: tool === "rectangle" ? "rectangle" : "freehand",
|
|
301
|
-
width: SKETCH_STROKE_WIDTH,
|
|
302
|
+
width: tool === "rectangle" ? SKETCH_RECTANGLE_STROKE_WIDTH : SKETCH_STROKE_WIDTH,
|
|
302
303
|
color: SKETCH_STROKE_COLOR,
|
|
303
304
|
outlineColor: SKETCH_STROKE_OUTLINE,
|
|
304
305
|
points: points.map((point) => ({ ...point })),
|
|
@@ -365,7 +366,7 @@ export function SketchEditor({ open, document: sketchDocument, captured, onCance
|
|
|
365
366
|
setSaving(true);
|
|
366
367
|
setError(null);
|
|
367
368
|
try {
|
|
368
|
-
const rendered = await renderAnnotatedPng(image, imageWidth, imageHeight, strokes, committedAnnotations, description.trim());
|
|
369
|
+
const rendered = await renderAnnotatedPng(image, imageWidth, imageHeight, strokes, committedAnnotations, description.trim(), sketchFrameHeading(capture.url));
|
|
369
370
|
await onSave({
|
|
370
371
|
...(sketchDocument ? { id: sketchDocument.id } : {}),
|
|
371
372
|
capture,
|
|
@@ -387,7 +388,7 @@ export function SketchEditor({ open, document: sketchDocument, captured, onCance
|
|
|
387
388
|
? {
|
|
388
389
|
id: "draft",
|
|
389
390
|
kind: tool === "rectangle" ? "rectangle" : "freehand",
|
|
390
|
-
width: SKETCH_STROKE_WIDTH,
|
|
391
|
+
width: tool === "rectangle" ? SKETCH_RECTANGLE_STROKE_WIDTH : SKETCH_STROKE_WIDTH,
|
|
391
392
|
color: SKETCH_STROKE_COLOR,
|
|
392
393
|
outlineColor: SKETCH_STROKE_OUTLINE,
|
|
393
394
|
points: tool === "rectangle" && draftPoints.length > 1
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { type CanvasFrame } from "../canvas/canvasFrame.js";
|
|
1
2
|
import type { ReactElement } from "react";
|
|
2
3
|
import type { SketchDocument, SketchPoint } from "./model.js";
|
|
3
4
|
interface SketchFrameOverlayProps {
|
|
4
|
-
readonly iframe:
|
|
5
|
+
readonly iframe: CanvasFrame | null;
|
|
5
6
|
readonly cardId?: string;
|
|
6
7
|
readonly cardUrl: string;
|
|
7
8
|
readonly artifactId?: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { canvasFrameElement } from "../canvas/canvasFrame.js";
|
|
2
3
|
import { useEffect, useMemo, useState } from "react";
|
|
3
4
|
import { SketchSvgLayer } from "./freehand.js";
|
|
4
5
|
import { useSketchStore } from "./store.js";
|
|
@@ -80,10 +81,10 @@ export function SketchFrameOverlay({ cardId, iframe, cardUrl, artifactId, ready
|
|
|
80
81
|
window.addEventListener("resize", refresh);
|
|
81
82
|
frameWindow.addEventListener("resize", refresh);
|
|
82
83
|
frameWindow.addEventListener("scroll", refresh, true);
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
const element = canvasFrameElement(iframe);
|
|
85
|
+
const observer = element && typeof ResizeObserver !== "undefined" ? new ResizeObserver(refresh) : null;
|
|
86
|
+
if (element)
|
|
87
|
+
observer?.observe(element);
|
|
87
88
|
return () => {
|
|
88
89
|
window.removeEventListener("resize", refresh);
|
|
89
90
|
frameWindow.removeEventListener("resize", refresh);
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import { type SketchViewport } from "./capture.js";
|
|
3
|
-
import { type
|
|
4
|
-
import type { SketchEntryTool } from "./interaction.js";
|
|
3
|
+
import { type SketchPoint, type SketchStroke } from "./model.js";
|
|
5
4
|
export interface SketchLiveDraft {
|
|
6
5
|
/** Kept for compatibility with sketches created with the original editor. */
|
|
7
6
|
readonly description: string;
|
|
8
7
|
readonly strokes: readonly SketchStroke[];
|
|
9
|
-
readonly annotations: readonly SketchAnnotation[];
|
|
10
8
|
readonly viewport: SketchViewport;
|
|
11
9
|
}
|
|
12
10
|
export interface SketchOverlayProps {
|
|
13
11
|
readonly open: boolean;
|
|
14
12
|
readonly hostElement: HTMLElement;
|
|
15
|
-
readonly
|
|
13
|
+
readonly selectTarget?: (point: SketchPoint, lockedTarget: HTMLElement | null) => HTMLElement | null;
|
|
16
14
|
readonly onCancel: () => void;
|
|
17
15
|
readonly onDone: (draft: SketchLiveDraft) => Promise<void>;
|
|
18
16
|
}
|
|
19
|
-
export declare function SketchOverlay({ open, hostElement,
|
|
17
|
+
export declare function SketchOverlay({ open, hostElement, selectTarget, onCancel, onDone }: SketchOverlayProps): ReactElement | null;
|