nudge-ui 0.2.2 → 0.2.4
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 +164 -46
- package/dist/client.mjs +260 -61
- package/dist/css/value-semantics/colorSemantics.d.ts +4 -0
- package/dist/css/value-semantics/colorSemantics.js +17 -0
- package/dist/hosts/astro/astroRuntimeConfig.js +1 -0
- package/dist/hosts/astro/clientTransport.js +38 -32
- package/dist/hosts/astro/integration.js +5 -1
- package/dist/hosts/astro/markdownIdentity.d.ts +28 -0
- package/dist/hosts/astro/markdownIdentity.js +81 -0
- package/dist/hosts/next/manifest.js +1 -1
- package/dist/hosts/next/sidecar.js +5 -1
- package/dist/hosts/static/manifest.js +1 -1
- package/dist/hosts/static/server.js +3 -0
- package/dist/hosts/vite/vite.d.ts +3 -0
- package/dist/hosts/vite/vite.js +24 -4
- package/dist/inspector/agent/McpConnectionDialog.js +13 -19
- package/dist/inspector/agent/activity.d.ts +18 -0
- package/dist/inspector/agent/activity.js +70 -0
- package/dist/inspector/agent/client.d.ts +2 -0
- package/dist/inspector/agent/client.js +29 -1
- package/dist/inspector/agent/connectionStatus.js +1 -1
- package/dist/inspector/agent/httpTransport.js +9 -2
- package/dist/inspector/agent/protocol.d.ts +6 -3
- package/dist/inspector/agent/protocol.js +1 -1
- package/dist/inspector/agent/verification.d.ts +15 -7
- package/dist/inspector/agent/verification.js +113 -41
- package/dist/inspector/canvas/AgentActivityOverlay.d.ts +13 -0
- package/dist/inspector/canvas/AgentActivityOverlay.js +111 -0
- package/dist/inspector/canvas/CanvasCard.d.ts +9 -2
- package/dist/inspector/canvas/CanvasCard.js +135 -38
- package/dist/inspector/canvas/CanvasElementOverlay.js +166 -16
- package/dist/inspector/canvas/CanvasToolIcons.d.ts +10 -0
- package/dist/inspector/canvas/CanvasToolIcons.js +20 -0
- package/dist/inspector/canvas/CanvasToolbar.js +8 -4
- package/dist/inspector/canvas/CanvasWorkspace.js +270 -122
- package/dist/inspector/canvas/StaleChangeIndicator.js +3 -13
- package/dist/inspector/canvas/agentPresentation.d.ts +8 -8
- package/dist/inspector/canvas/agentPresentation.js +64 -52
- package/dist/inspector/canvas/canvasGestures.d.ts +1 -1
- package/dist/inspector/canvas/canvasGestures.js +1 -1
- package/dist/inspector/canvas/canvasStore.d.ts +46 -82
- package/dist/inspector/canvas/canvasStore.js +251 -284
- package/dist/inspector/canvas/frameContent.d.ts +21 -0
- package/dist/inspector/canvas/frameContent.js +44 -0
- package/dist/inspector/canvas/frameProtocol.d.ts +21 -4
- package/dist/inspector/canvas/frameProtocol.js +3 -3
- package/dist/inspector/canvas/frameScrollbarStyles.d.ts +3 -0
- package/dist/inspector/canvas/frameScrollbarStyles.js +21 -0
- package/dist/inspector/canvas/keyboardShortcuts.d.ts +3 -1
- package/dist/inspector/canvas/keyboardShortcuts.js +4 -4
- package/dist/inspector/canvas/layout.d.ts +52 -0
- package/dist/inspector/canvas/layout.js +106 -0
- package/dist/inspector/canvas/projection.d.ts +15 -5
- package/dist/inspector/canvas/projection.js +69 -13
- package/dist/inspector/canvas/rendererBootstrap.js +32 -4
- package/dist/inspector/canvas/rendererElementSelector.js +47 -6
- package/dist/inspector/canvas/rendererStylesheet.js +2 -2
- package/dist/inspector/canvas/resizeHandleScale.js +1 -1
- package/dist/inspector/canvas/sessionStore.d.ts +11 -26
- package/dist/inspector/canvas/sessionStore.js +43 -183
- package/dist/inspector/canvas/staleChangeDetector.js +9 -3
- package/dist/inspector/canvas/useCanvasLayoutAnimation.d.ts +5 -0
- package/dist/inspector/canvas/useCanvasLayoutAnimation.js +107 -0
- package/dist/inspector/canvas/viewStore.d.ts +38 -0
- package/dist/inspector/canvas/viewStore.js +104 -0
- package/dist/inspector/canvas/wheelPan.d.ts +8 -0
- package/dist/inspector/canvas/wheelPan.js +8 -0
- package/dist/inspector/changes/changesLog.d.ts +9 -6
- package/dist/inspector/changes/changesLog.js +48 -32
- package/dist/inspector/changes/codecs.d.ts +1 -0
- package/dist/inspector/changes/codecs.js +10 -1
- package/dist/inspector/changes/draftChanges.d.ts +58 -0
- package/dist/inspector/changes/draftChanges.js +304 -0
- package/dist/inspector/changes/editModel.d.ts +10 -0
- package/dist/inspector/changes/editModel.js +9 -2
- package/dist/inspector/changes/previewDiagnostics.d.ts +4 -2
- package/dist/inspector/changes/previewDiagnostics.js +11 -25
- package/dist/inspector/changes/types.d.ts +7 -0
- package/dist/inspector/clientManifest.d.ts +1 -1
- package/dist/inspector/comments/CommentsOverlay.d.ts +2 -0
- package/dist/inspector/comments/CommentsOverlay.js +250 -0
- package/dist/inspector/comments/element.d.ts +6 -0
- package/dist/inspector/comments/element.js +54 -0
- package/dist/inspector/comments/store.d.ts +29 -0
- package/dist/inspector/comments/store.js +121 -0
- package/dist/inspector/comments/verification.d.ts +5 -0
- package/dist/inspector/comments/verification.js +52 -0
- package/dist/inspector/componentSemantics/adapterRegistry.d.ts +6 -1
- package/dist/inspector/componentSemantics/adapterRegistry.js +23 -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/types.d.ts +11 -0
- package/dist/inspector/drafts/model.d.ts +35 -0
- package/dist/inspector/drafts/model.js +45 -0
- package/dist/inspector/drafts/store.d.ts +28 -0
- package/dist/inspector/drafts/store.js +231 -0
- package/dist/inspector/index.js +20 -27
- package/dist/inspector/inline-text/inlineTextEditor.js +7 -0
- package/dist/inspector/inspection/useBrowserCssInspection.js +15 -1
- package/dist/inspector/iterations/capture.d.ts +2 -0
- package/dist/inspector/iterations/capture.js +174 -0
- package/dist/inspector/iterations/client.d.ts +7 -0
- package/dist/inspector/iterations/client.js +52 -0
- package/dist/inspector/iterations/coordinator.d.ts +15 -0
- package/dist/inspector/iterations/coordinator.js +130 -0
- package/dist/inspector/iterations/prompt.d.ts +3 -0
- package/dist/inspector/iterations/prompt.js +26 -0
- package/dist/inspector/overlay/DomNavigator.js +21 -15
- package/dist/inspector/overlay/interactionStyles.js +3 -1
- package/dist/inspector/overlay/spacingGestures.d.ts +13 -1
- package/dist/inspector/overlay/spacingGestures.js +82 -5
- package/dist/inspector/projection/{workspaceProjection.d.ts → draftProjection.d.ts} +6 -6
- package/dist/inspector/projection/{workspaceProjection.js → draftProjection.js} +4 -4
- package/dist/inspector/projection/renderedInstance.d.ts +17 -3
- package/dist/inspector/projection/renderedInstance.js +62 -11
- package/dist/inspector/projection/structuralProjection.d.ts +2 -1
- package/dist/inspector/projection/structuralProjection.js +21 -17
- package/dist/inspector/projection/textProjection.d.ts +2 -1
- package/dist/inspector/projection/textProjection.js +64 -15
- package/dist/inspector/prompt/PromptSettingsDialog.js +1 -5
- package/dist/inspector/prompt/clipboardHandoff.d.ts +15 -18
- package/dist/inspector/prompt/clipboardHandoff.js +97 -143
- package/dist/inspector/prompt/generatePrompt.d.ts +4 -1
- package/dist/inspector/prompt/generatePrompt.js +22 -17
- package/dist/inspector/runtime/runtimeConfig.d.ts +9 -0
- package/dist/inspector/runtime/runtimeConfig.js +24 -0
- package/dist/inspector/selection/sourceSite.d.ts +12 -0
- package/dist/inspector/selection/sourceSite.js +28 -0
- package/dist/inspector/settings/SettingsDialog.js +21 -8
- package/dist/inspector/shell/AgentStatusButton.d.ts +11 -0
- package/dist/inspector/shell/AgentStatusButton.js +36 -0
- package/dist/inspector/shell/AppShell.js +4 -2
- package/dist/inspector/shell/ChangesLog.js +46 -26
- package/dist/inspector/shell/CopyPromptButton.js +184 -93
- package/dist/inspector/shell/EmptyState.js +9 -8
- package/dist/inspector/shell/InspectorShell.js +13 -21
- package/dist/inspector/shell/PeekOriginalButton.js +24 -23
- package/dist/inspector/shell/originalPreview.js +5 -5
- package/dist/inspector/shell/shortcuts.d.ts +3 -0
- package/dist/inspector/shell/shortcuts.js +11 -0
- package/dist/inspector/sketch/SketchEditor.js +14 -14
- package/dist/inspector/sketch/SketchEntryButton.js +1 -1
- package/dist/inspector/sketch/SketchFrameOverlay.d.ts +3 -1
- package/dist/inspector/sketch/SketchFrameOverlay.js +11 -8
- package/dist/inspector/sketch/SketchLayersPanel.js +13 -5
- package/dist/inspector/sketch/SketchOverlay.js +7 -7
- package/dist/inspector/sketch/SketchWorkspace.js +18 -12
- package/dist/inspector/sketch/interaction.d.ts +1 -0
- package/dist/inspector/sketch/interaction.js +8 -4
- package/dist/inspector/sketch/model.d.ts +5 -0
- package/dist/inspector/sketch/model.js +6 -2
- package/dist/inspector/sketch/raster.d.ts +1 -2
- package/dist/inspector/sketch/raster.js +68 -4
- package/dist/inspector/styleEditors/BackgroundEditor.d.ts +4 -0
- package/dist/inspector/styleEditors/BackgroundEditor.js +195 -0
- package/dist/inspector/styleEditors/BorderEditor.js +49 -78
- package/dist/inspector/styleEditors/BorderRadiusEditor.js +6 -1
- package/dist/inspector/styleEditors/BoxShadowEditor.d.ts +1 -2
- package/dist/inspector/styleEditors/BoxShadowEditor.js +132 -4
- package/dist/inspector/styleEditors/ColorPicker.d.ts +5 -1
- package/dist/inspector/styleEditors/ColorPicker.js +10 -4
- package/dist/inspector/styleEditors/GapField.js +3 -5
- package/dist/inspector/styleEditors/GridChildSection.d.ts +1 -1
- package/dist/inspector/styleEditors/GridChildSection.js +18 -9
- package/dist/inspector/styleEditors/GridPicker.d.ts +1 -1
- package/dist/inspector/styleEditors/GridPicker.js +8 -2
- package/dist/inspector/styleEditors/GridSection.js +1 -1
- package/dist/inspector/styleEditors/GridValueField.js +19 -14
- package/dist/inspector/styleEditors/ImageBackgroundEditor.d.ts +18 -0
- package/dist/inspector/styleEditors/ImageBackgroundEditor.js +118 -0
- package/dist/inspector/styleEditors/LayoutBlockedIndicator.d.ts +2 -2
- package/dist/inspector/styleEditors/LayoutBlockedIndicator.js +3 -3
- package/dist/inspector/styleEditors/LayoutComboField.js +6 -4
- package/dist/inspector/styleEditors/LayoutDropdown.js +6 -3
- package/dist/inspector/styleEditors/LayoutSection.js +32 -11
- package/dist/inspector/styleEditors/SpacingBox.js +7 -5
- package/dist/inspector/styleEditors/Typography.js +11 -3
- package/dist/inspector/styleEditors/backgroundLayers.d.ts +24 -0
- package/dist/inspector/styleEditors/backgroundLayers.js +51 -0
- package/dist/inspector/styleEditors/gradientValue.d.ts +17 -0
- package/dist/inspector/styleEditors/gradientValue.js +114 -0
- package/dist/inspector/styleEditors/inlineAuthored.d.ts +10 -0
- package/dist/inspector/styleEditors/inlineAuthored.js +114 -0
- package/dist/inspector/styleEditors/layoutValue.d.ts +0 -8
- package/dist/inspector/styleEditors/layoutValue.js +0 -42
- package/dist/inspector/styleEditors/nudgeValue.d.ts +2 -2
- package/dist/inspector/styleEditors/nudgeValue.js +36 -8
- package/dist/inspector/tokens/TokenField.d.ts +7 -0
- package/dist/inspector/tokens/TokenField.js +35 -25
- package/dist/inspector/tokens/TokenLabel.js +5 -14
- package/dist/inspector/tokens/editActions.d.ts +1 -1
- package/dist/inspector/tokens/editActions.js +7 -1
- package/dist/inspector/ui/AtRuleContext.js +4 -6
- package/dist/inspector/ui/Button.d.ts +6 -2
- package/dist/inspector/ui/Button.js +4 -3
- package/dist/inspector/ui/ControlSurface.d.ts +2 -2
- package/dist/inspector/ui/ControlSurface.js +4 -3
- package/dist/inspector/ui/InlineStyleWarning.d.ts +11 -0
- package/dist/inspector/ui/InlineStyleWarning.js +13 -0
- package/dist/inspector/ui/InspectorPopover.d.ts +2 -1
- package/dist/inspector/ui/InspectorPopover.js +4 -5
- package/dist/inspector/ui/PopoverListbox.d.ts +2 -1
- package/dist/inspector/ui/PopoverListbox.js +8 -7
- package/dist/inspector/ui/SegmentedControl.d.ts +2 -1
- package/dist/inspector/ui/SegmentedControl.js +2 -2
- package/dist/inspector/ui/Select.d.ts +6 -1
- package/dist/inspector/ui/Select.js +7 -11
- package/dist/inspector/ui/SideValuesField.js +1 -1
- package/dist/inspector/ui/Tooltip.d.ts +26 -0
- package/dist/inspector/ui/Tooltip.js +32 -0
- package/dist/inspector/ui/classNames.d.ts +2 -0
- package/dist/inspector/ui/classNames.js +4 -0
- package/dist/inspector/ui/customCursors.d.ts +23 -0
- package/dist/inspector/ui/customCursors.js +122 -0
- package/dist/inspector/ui/dragCursor.d.ts +0 -2
- package/dist/inspector/ui/dragCursor.js +2 -10
- package/dist/inspector/ui/portalContainer.d.ts +2 -0
- package/dist/inspector/ui/portalContainer.js +6 -0
- package/dist/inspector/ui/styles.js +29 -21
- package/dist/inspector/workspace/commands.d.ts +9 -0
- package/dist/inspector/workspace/commands.js +82 -0
- package/dist/inspector/workspace/controller.d.ts +4 -0
- package/dist/inspector/workspace/controller.js +66 -0
- package/dist/inspector/workspace/handoff.d.ts +42 -0
- package/dist/inspector/workspace/handoff.js +115 -0
- package/dist/inspector/workspace/sentItems.d.ts +19 -0
- package/dist/inspector/workspace/sentItems.js +51 -0
- package/dist/inspector/workspace/timeline.d.ts +30 -0
- package/dist/inspector/workspace/timeline.js +108 -0
- package/dist/internal/agent-protocol.d.ts +19 -2
- package/dist/internal/agent-protocol.js +13 -0
- package/dist/nudge-ui.mjs +558 -311
- package/dist/project/artifacts.d.ts +13 -0
- package/dist/project/artifacts.js +253 -0
- package/dist/transport/artifacts.d.ts +8 -0
- package/dist/transport/artifacts.js +9 -0
- package/dist/transport/editor.js +3 -1
- package/dist/transport/routes.d.ts +2 -0
- package/dist/transport/routes.js +2 -0
- package/package.json +7 -3
- package/dist/inspector/changes/workspaceChanges.d.ts +0 -47
- package/dist/inspector/changes/workspaceChanges.js +0 -265
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { DESIGN_SELECT_CURSOR, INTERACTION_CURSOR_PROPERTY } from "../ui/customCursors.js";
|
|
1
2
|
const INTERACTION_STYLE_ID = "nudge-ui-interaction-styles";
|
|
2
3
|
const interactionStyleDocuments = new Set();
|
|
3
4
|
const INTERACTION_CSS = `
|
|
5
|
+
html, body,
|
|
4
6
|
[data-cid], [data-cid] * {
|
|
5
|
-
cursor:
|
|
7
|
+
cursor: var(${INTERACTION_CURSOR_PROPERTY}, ${DESIGN_SELECT_CURSOR}) !important;
|
|
6
8
|
-webkit-user-select: none !important;
|
|
7
9
|
user-select: none !important;
|
|
8
10
|
}
|
|
@@ -30,9 +30,21 @@ export interface SpacingDescriptor {
|
|
|
30
30
|
export declare const SPACING_GUIDE_HANDLE_LENGTH = 40;
|
|
31
31
|
/** Finds the spacing target under a document-local pointer location. */
|
|
32
32
|
export declare function getSpacingAffordanceAtPoint(doc: Document, x: number, y: number): SpacingAffordance | null;
|
|
33
|
+
/** Finds the spacing target whose visible padding or gap area contains the
|
|
34
|
+
* pointer, even when the pointer is outside the drag handle. Hover previews use
|
|
35
|
+
* this; drags and the resize cursor still require the handle hit from
|
|
36
|
+
* getSpacingAffordanceAtPoint. */
|
|
37
|
+
export declare function getSpacingHoverAtPoint(doc: Document, x: number, y: number): SpacingAffordance | null;
|
|
33
38
|
/** Re-resolves a renderer-reported spacing descriptor in its owner document. */
|
|
34
39
|
export declare function getSpacingAffordanceForDescriptor(element: HTMLElement, descriptor: SpacingDescriptor): SpacingAffordance | null;
|
|
35
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Calculates a direct-manipulation value, optionally stepping changes by 8px.
|
|
42
|
+
* While Shift is held the value snaps to a step anchor: the first displacement
|
|
43
|
+
* picks the nearest multiple of 8 from the authored value in the drag
|
|
44
|
+
* direction (ties resolve upward), and further movement adds whole 8px steps
|
|
45
|
+
* from that anchor, so the result is always a multiple of 8 once the drag
|
|
46
|
+
* moves. At the exact start point the authored value is preserved.
|
|
47
|
+
*/
|
|
36
48
|
export declare function spacingValueForDrag(affordance: Pick<SpacingAffordance, "dragAxis" | "direction" | "value">, start: {
|
|
37
49
|
x: number;
|
|
38
50
|
y: number;
|
|
@@ -263,6 +263,52 @@ function gapDragHit(segment) {
|
|
|
263
263
|
const orientation = segment.axis === "horizontal" ? "vertical" : "horizontal";
|
|
264
264
|
return guideHit(gapGuide(segment), orientation);
|
|
265
265
|
}
|
|
266
|
+
/** Matches the padding bar whose visible area contains the pointer, whether or
|
|
267
|
+
* not the point is inside the drag handle. Returns the first side by the same
|
|
268
|
+
* priority order as the drag affordances so both paths agree on overlaps. */
|
|
269
|
+
function paddingAffordanceInAreaAtPoint(element, x, y) {
|
|
270
|
+
const model = boxModel(element);
|
|
271
|
+
if (!containsPoint(model.outer, x, y))
|
|
272
|
+
return null;
|
|
273
|
+
const sides = ["top", "right", "bottom", "left"];
|
|
274
|
+
for (const side of sides) {
|
|
275
|
+
const affordance = paddingAffordanceForSide(element, side, model);
|
|
276
|
+
if (affordance
|
|
277
|
+
&& affordance.affectedAreas.some((area) => containsRectPoint(area, x, y))) {
|
|
278
|
+
return affordance;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
/** Matches a layout gap whose visible area contains the pointer, whether or not
|
|
284
|
+
* the point is inside the drag handle. Shares segment priority and geometry
|
|
285
|
+
* with gapAffordanceAtPoint so hover and drag agree on crossed gap properties. */
|
|
286
|
+
function gapAffordanceInAreaAtPoint(element, x, y) {
|
|
287
|
+
const segments = gapSegments(element);
|
|
288
|
+
if (segments.length === 0)
|
|
289
|
+
return null;
|
|
290
|
+
const candidate = segments.find((segment) => containsRectPoint(gapArea(segment), x, y));
|
|
291
|
+
if (!candidate)
|
|
292
|
+
return null;
|
|
293
|
+
const matchingSegments = segments.filter((segment) => segment.property === candidate.property);
|
|
294
|
+
const first = matchingSegments[0];
|
|
295
|
+
const guide = gapGuide(first);
|
|
296
|
+
return {
|
|
297
|
+
kind: "gap",
|
|
298
|
+
property: first.property,
|
|
299
|
+
side: null,
|
|
300
|
+
axis: first.axis,
|
|
301
|
+
dragAxis: first.axis === "horizontal" ? "x" : "y",
|
|
302
|
+
value: gapValue(getElementComputedStyle(element), first.property),
|
|
303
|
+
cursor: first.axis === "horizontal" ? "ew-resize" : "ns-resize",
|
|
304
|
+
guide,
|
|
305
|
+
affectedGuides: matchingSegments.map(gapGuide),
|
|
306
|
+
affectedAreas: matchingSegments.map(gapArea),
|
|
307
|
+
hit: gapDragHit(first),
|
|
308
|
+
direction: 1,
|
|
309
|
+
element,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
266
312
|
function gapValue(style, property) {
|
|
267
313
|
const direct = style.getPropertyValue(property)
|
|
268
314
|
|| (property === "row-gap" ? style.rowGap : style.columnGap);
|
|
@@ -313,6 +359,24 @@ export function getSpacingAffordanceAtPoint(doc, x, y) {
|
|
|
313
359
|
}
|
|
314
360
|
return null;
|
|
315
361
|
}
|
|
362
|
+
/** Finds the spacing target whose visible padding or gap area contains the
|
|
363
|
+
* pointer, even when the pointer is outside the drag handle. Hover previews use
|
|
364
|
+
* this; drags and the resize cursor still require the handle hit from
|
|
365
|
+
* getSpacingAffordanceAtPoint. */
|
|
366
|
+
export function getSpacingHoverAtPoint(doc, x, y) {
|
|
367
|
+
const candidates = trackedElementsAtPoint(doc, x, y);
|
|
368
|
+
for (const element of candidates) {
|
|
369
|
+
const padding = paddingAffordanceInAreaAtPoint(element, x, y);
|
|
370
|
+
if (padding)
|
|
371
|
+
return padding;
|
|
372
|
+
}
|
|
373
|
+
for (const element of candidates) {
|
|
374
|
+
const gap = gapAffordanceInAreaAtPoint(element, x, y);
|
|
375
|
+
if (gap)
|
|
376
|
+
return gap;
|
|
377
|
+
}
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
316
380
|
/** Re-resolves a renderer-reported spacing descriptor in its owner document. */
|
|
317
381
|
export function getSpacingAffordanceForDescriptor(element, descriptor) {
|
|
318
382
|
if (descriptor.kind === "padding") {
|
|
@@ -329,14 +393,27 @@ export function getSpacingAffordanceForDescriptor(element, descriptor) {
|
|
|
329
393
|
const guide = gapGuide(segment);
|
|
330
394
|
return gapAffordanceAtPoint(element, guide.left + guide.width / 2, guide.top + guide.height / 2, descriptor.property);
|
|
331
395
|
}
|
|
332
|
-
/**
|
|
396
|
+
/**
|
|
397
|
+
* Calculates a direct-manipulation value, optionally stepping changes by 8px.
|
|
398
|
+
* While Shift is held the value snaps to a step anchor: the first displacement
|
|
399
|
+
* picks the nearest multiple of 8 from the authored value in the drag
|
|
400
|
+
* direction (ties resolve upward), and further movement adds whole 8px steps
|
|
401
|
+
* from that anchor, so the result is always a multiple of 8 once the drag
|
|
402
|
+
* moves. At the exact start point the authored value is preserved.
|
|
403
|
+
*/
|
|
333
404
|
export function spacingValueForDrag(affordance, start, point, shiftKey = false) {
|
|
334
405
|
const delta = affordance.dragAxis === "x" ? point.x - start.x : point.y - start.y;
|
|
335
406
|
const signedDelta = delta * affordance.direction;
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
407
|
+
if (shiftKey) {
|
|
408
|
+
const step = SPACING_SHIFT_STEP;
|
|
409
|
+
if (signedDelta !== 0) {
|
|
410
|
+
const anchor = signedDelta > 0
|
|
411
|
+
? Math.ceil(affordance.value / step) * step
|
|
412
|
+
: Math.floor(affordance.value / step) * step;
|
|
413
|
+
return Math.max(0, anchor + Math.trunc(signedDelta / step) * step);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return Math.max(0, Math.round(affordance.value + signedDelta));
|
|
340
417
|
}
|
|
341
418
|
export function spacingValueCss(value) {
|
|
342
419
|
return `${Math.max(0, Math.round(value))}px`;
|
|
@@ -3,8 +3,8 @@ import type { RenderedInstanceOverride } from "../changes/editModel.js";
|
|
|
3
3
|
import { type StructuralChange } from "./structuralProjection.js";
|
|
4
4
|
import type { ComponentOverride } from "../componentSemantics/types.js";
|
|
5
5
|
import { type TextContentChangeRecord } from "../changes/types.js";
|
|
6
|
-
import type {
|
|
7
|
-
export interface
|
|
6
|
+
import type { DraftContents } from "../changes/draftChanges.js";
|
|
7
|
+
export interface DraftProjectionSource extends DraftContents {
|
|
8
8
|
readonly revision: number;
|
|
9
9
|
}
|
|
10
10
|
export interface CompiledManagedStyles {
|
|
@@ -15,7 +15,7 @@ export interface SerializedManagedStyles {
|
|
|
15
15
|
readonly css: string;
|
|
16
16
|
}
|
|
17
17
|
/** A complete, read-only projection for one document-local runtime. */
|
|
18
|
-
export interface
|
|
18
|
+
export interface DraftProjectionPlan<ManagedStyles> {
|
|
19
19
|
readonly sourceRevision: number;
|
|
20
20
|
readonly managedStyles: ManagedStyles;
|
|
21
21
|
readonly instanceOverrides: readonly RenderedInstanceOverride[];
|
|
@@ -31,7 +31,7 @@ export interface DocumentProjectionAdapter<ManagedStyles> {
|
|
|
31
31
|
applyComponents(overrides: readonly ComponentOverride[]): void;
|
|
32
32
|
applyManagedStyles(styles: ManagedStyles): void;
|
|
33
33
|
}
|
|
34
|
-
export declare function
|
|
34
|
+
export declare function compileDraftProjection(snapshot: DraftProjectionSource): DraftProjectionPlan<CompiledManagedStyles>;
|
|
35
35
|
/**
|
|
36
36
|
* Replaces one document projection in the required order.
|
|
37
37
|
*
|
|
@@ -39,5 +39,5 @@ export declare function compileWorkspaceProjection(snapshot: WorkspaceProjection
|
|
|
39
39
|
* can depend on the restored element order. Managed CSS is applied last so
|
|
40
40
|
* selectors can use the document-local instance markers installed above.
|
|
41
41
|
*/
|
|
42
|
-
export declare function
|
|
43
|
-
export declare function
|
|
42
|
+
export declare function applyDraftProjection<ManagedStyles>(adapter: DocumentProjectionAdapter<ManagedStyles>, plan: DraftProjectionPlan<ManagedStyles>): void;
|
|
43
|
+
export declare function applyHostDraftProjection(plan: DraftProjectionPlan<CompiledManagedStyles>): void;
|
|
@@ -6,7 +6,7 @@ import { replaceComponentOverrideProjection } from "../componentSemantics/index.
|
|
|
6
6
|
import { componentChangeToOverride } from "../componentSemantics/changeModel.js";
|
|
7
7
|
import { isComponentChange } from "../changes/types.js";
|
|
8
8
|
import { buildManagedStyleRules } from "../changes/managedStyleProjection.js";
|
|
9
|
-
export function
|
|
9
|
+
export function compileDraftProjection(snapshot) {
|
|
10
10
|
const changes = [...snapshot.changes];
|
|
11
11
|
const rules = buildManagedStyleRules(changes);
|
|
12
12
|
return {
|
|
@@ -31,7 +31,7 @@ export function compileWorkspaceProjection(snapshot) {
|
|
|
31
31
|
* can depend on the restored element order. Managed CSS is applied last so
|
|
32
32
|
* selectors can use the document-local instance markers installed above.
|
|
33
33
|
*/
|
|
34
|
-
export function
|
|
34
|
+
export function applyDraftProjection(adapter, plan) {
|
|
35
35
|
adapter.applyStructural(plan.structuralChanges);
|
|
36
36
|
adapter.applyRenderedInstances(plan.instanceOverrides);
|
|
37
37
|
adapter.applyText(plan.textContentChanges);
|
|
@@ -53,6 +53,6 @@ const hostDocumentProjectionAdapter = {
|
|
|
53
53
|
applyRules([...styles.rules]);
|
|
54
54
|
},
|
|
55
55
|
};
|
|
56
|
-
export function
|
|
57
|
-
|
|
56
|
+
export function applyHostDraftProjection(plan) {
|
|
57
|
+
applyDraftProjection(hostDocumentProjectionAdapter, plan);
|
|
58
58
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FrameProjection } from "../canvas/projection.js";
|
|
1
2
|
import type { RenderedInstanceOverride, RenderedInstanceRef } from "../changes/editModel.js";
|
|
2
3
|
export { isRenderedInstanceOverride, isRenderedInstanceRef } from "../changes/editModel.js";
|
|
3
4
|
export type { RenderedInstanceOverride, RenderedInstanceRef, SourceSiteRef } from "../changes/editModel.js";
|
|
@@ -22,10 +23,23 @@ export declare function captureRenderedInstance(el: HTMLElement): RenderedInstan
|
|
|
22
23
|
/**
|
|
23
24
|
* Resolves exactly one element, or declines to apply. Occurrence documents the
|
|
24
25
|
* captured placement, but structural previews can legitimately change it.
|
|
25
|
-
* Evidence
|
|
26
|
-
* be applied.
|
|
26
|
+
* Evidence, narrowed by a recorded invocation when present, must therefore
|
|
27
|
+
* identify one current candidate before an edit can be applied.
|
|
27
28
|
*/
|
|
28
29
|
export declare function resolveRenderedInstance(doc: Document, ref: RenderedInstanceRef): ResolutionResult;
|
|
30
|
+
/**
|
|
31
|
+
* Resolves a reference whose source position may have moved since capture.
|
|
32
|
+
* A relocated site still renders matching authored evidence, so an evidence
|
|
33
|
+
* miss there is reported as ambiguous rather than as proof of absence.
|
|
34
|
+
*/
|
|
35
|
+
export declare function resolveMovedRenderedInstance(doc: Document, ref: RenderedInstanceRef): ResolutionResult;
|
|
36
|
+
/**
|
|
37
|
+
* Captures identity for a structural target. When evidence matches several
|
|
38
|
+
* identical outputs, the nearest component invocation whose entire output is
|
|
39
|
+
* this element can still identify it. Otherwise the evidence-only reference
|
|
40
|
+
* is returned and resolves as ambiguous.
|
|
41
|
+
*/
|
|
42
|
+
export declare function captureStructuralTarget(el: HTMLElement): RenderedInstanceRef | null;
|
|
29
43
|
/** Checks stable source/evidence fields without treating a post-move ordinal as identity. */
|
|
30
44
|
export declare function matchesRenderedInstanceEvidence(el: HTMLElement, ref: RenderedInstanceRef): boolean;
|
|
31
45
|
/** Builds an instance override without changing the element's transient edit scope. */
|
|
@@ -50,7 +64,7 @@ export declare function getRenderedInstanceProjectionReports(doc: Document): rea
|
|
|
50
64
|
/** Diagnostics arrive independently when a renderer reports or React reconciles. */
|
|
51
65
|
export declare function subscribeRenderedInstanceDiagnostics(listener: () => void): () => void;
|
|
52
66
|
export declare function getRenderedInstanceDiagnosticRevision(): number;
|
|
53
|
-
export declare function recordCanvasRenderedInstanceProjectionReports(cardId: string, revision: number, reports: readonly DocumentProjectionReport[]): void;
|
|
67
|
+
export declare function recordCanvasRenderedInstanceProjectionReports(cardId: string, revision: number, reports: readonly DocumentProjectionReport[], projection?: FrameProjection): void;
|
|
54
68
|
export declare function clearCanvasRenderedInstanceProjectionReports(cardId: string): void;
|
|
55
69
|
export declare function getRenderedInstanceChangeDiagnostics(overrideId: string): RenderedInstanceChangeDiagnostic[];
|
|
56
70
|
export declare function isDocumentProjectionReport(value: unknown): value is DocumentProjectionReport;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { getActiveDraftChanges, getDraftChanges } from "../changes/draftChanges.js";
|
|
2
|
+
import { inspectRootInvocations } from "../componentSemantics/adapterRegistry.js";
|
|
1
3
|
import { escapeAttrValue } from "./cssEscapes.js";
|
|
2
4
|
import { isNudgeUiDev } from "../runtime/devFlag.js";
|
|
3
|
-
import { sourceSiteSelector } from "../selection/sourceSite.js";
|
|
5
|
+
import { relocateSourceSite, sourceSiteSelector } from "../selection/sourceSite.js";
|
|
4
6
|
import { isRenderedInstanceOverride } from "../changes/editModel.js";
|
|
5
7
|
export { isRenderedInstanceOverride, isRenderedInstanceRef } from "../changes/editModel.js";
|
|
6
8
|
const PROJECTION_ATTR = "data-projection-instance";
|
|
@@ -49,19 +51,31 @@ export function captureRenderedInstance(el) {
|
|
|
49
51
|
/**
|
|
50
52
|
* Resolves exactly one element, or declines to apply. Occurrence documents the
|
|
51
53
|
* captured placement, but structural previews can legitimately change it.
|
|
52
|
-
* Evidence
|
|
53
|
-
* be applied.
|
|
54
|
+
* Evidence, narrowed by a recorded invocation when present, must therefore
|
|
55
|
+
* identify one current candidate before an edit can be applied.
|
|
54
56
|
*/
|
|
55
57
|
export function resolveRenderedInstance(doc, ref) {
|
|
56
58
|
const sourceCandidates = candidates(doc, ref.sourceSite);
|
|
57
|
-
const { props, text, ariaLabel = null } = ref.locator;
|
|
59
|
+
const { props, text, ariaLabel = null, invocation } = ref.locator;
|
|
58
60
|
// An ordinal alone is not an identity for a repeated source site.
|
|
59
|
-
if (sourceCandidates.length > 1 && props === null && text === null && ariaLabel === null) {
|
|
61
|
+
if (!invocation && sourceCandidates.length > 1 && props === null && text === null && ariaLabel === null) {
|
|
60
62
|
return { status: "ambiguous" };
|
|
61
63
|
}
|
|
62
|
-
|
|
64
|
+
let matchingEvidence = sourceCandidates.filter((element) => element.getAttribute("data-cprops") === props
|
|
63
65
|
&& normalizedText(element) === text
|
|
64
66
|
&& element.getAttribute("aria-label") === ariaLabel);
|
|
67
|
+
if (invocation) {
|
|
68
|
+
const scoped = [];
|
|
69
|
+
for (const element of matchingEvidence) {
|
|
70
|
+
const invocations = inspectRootInvocations(element);
|
|
71
|
+
// Without readable ancestry, absence of the invocation proves nothing.
|
|
72
|
+
if (invocations === null)
|
|
73
|
+
return { status: "ambiguous" };
|
|
74
|
+
if (invocations.some((candidate) => candidate.callsiteId === invocation.callsiteId))
|
|
75
|
+
scoped.push(element);
|
|
76
|
+
}
|
|
77
|
+
matchingEvidence = scoped;
|
|
78
|
+
}
|
|
65
79
|
if (matchingEvidence.length === 0)
|
|
66
80
|
return { status: "missing" };
|
|
67
81
|
// Evidence alone is never enough to choose between two identical rendered
|
|
@@ -71,11 +85,45 @@ export function resolveRenderedInstance(doc, ref) {
|
|
|
71
85
|
return { status: "ambiguous" };
|
|
72
86
|
return { status: "resolved", element: matchingEvidence[0] };
|
|
73
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Resolves a reference whose source position may have moved since capture.
|
|
90
|
+
* A relocated site still renders matching authored evidence, so an evidence
|
|
91
|
+
* miss there is reported as ambiguous rather than as proof of absence.
|
|
92
|
+
*/
|
|
93
|
+
export function resolveMovedRenderedInstance(doc, ref) {
|
|
94
|
+
const exact = resolveRenderedInstance(doc, ref);
|
|
95
|
+
if (exact.status !== "missing")
|
|
96
|
+
return exact;
|
|
97
|
+
const { props, ariaLabel = null } = ref.locator;
|
|
98
|
+
const sourceSite = relocateSourceSite(doc, ref.sourceSite, (element) => element.getAttribute("data-cprops") === props && element.getAttribute("aria-label") === ariaLabel);
|
|
99
|
+
if (!sourceSite)
|
|
100
|
+
return exact;
|
|
101
|
+
const moved = resolveRenderedInstance(doc, { ...ref, sourceSite });
|
|
102
|
+
return moved.status === "missing" ? { status: "ambiguous" } : moved;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Captures identity for a structural target. When evidence matches several
|
|
106
|
+
* identical outputs, the nearest component invocation whose entire output is
|
|
107
|
+
* this element can still identify it. Otherwise the evidence-only reference
|
|
108
|
+
* is returned and resolves as ambiguous.
|
|
109
|
+
*/
|
|
110
|
+
export function captureStructuralTarget(el) {
|
|
111
|
+
const ref = captureRenderedInstance(el);
|
|
112
|
+
if (!ref || resolveRenderedInstance(el.ownerDocument, ref).status !== "ambiguous")
|
|
113
|
+
return ref;
|
|
114
|
+
for (const invocation of inspectRootInvocations(el) ?? []) {
|
|
115
|
+
const scoped = { ...ref, locator: { ...ref.locator, invocation } };
|
|
116
|
+
const resolved = resolveRenderedInstance(el.ownerDocument, scoped);
|
|
117
|
+
if (resolved.status === "resolved" && resolved.element === el)
|
|
118
|
+
return scoped;
|
|
119
|
+
}
|
|
120
|
+
return ref;
|
|
121
|
+
}
|
|
74
122
|
/** Checks stable source/evidence fields without treating a post-move ordinal as identity. */
|
|
75
123
|
export function matchesRenderedInstanceEvidence(el, ref) {
|
|
76
124
|
const { props, text, ariaLabel = null } = ref.locator;
|
|
77
|
-
return el.getAttribute("data-cid") === ref.sourceSite.cid
|
|
78
|
-
&& el.getAttribute("data-src") === ref.sourceSite.src
|
|
125
|
+
return (el.getAttribute("data-cid") ?? "") === ref.sourceSite.cid
|
|
126
|
+
&& (el.getAttribute("data-src") ?? "") === ref.sourceSite.src
|
|
79
127
|
&& el.getAttribute("data-cprops") === props
|
|
80
128
|
&& normalizedText(el) === text
|
|
81
129
|
&& el.getAttribute("aria-label") === ariaLabel;
|
|
@@ -254,10 +302,10 @@ export function subscribeRenderedInstanceDiagnostics(listener) {
|
|
|
254
302
|
export function getRenderedInstanceDiagnosticRevision() {
|
|
255
303
|
return diagnosticRevision;
|
|
256
304
|
}
|
|
257
|
-
export function recordCanvasRenderedInstanceProjectionReports(cardId, revision, reports) {
|
|
305
|
+
export function recordCanvasRenderedInstanceProjectionReports(cardId, revision, reports, projection) {
|
|
258
306
|
if (!Number.isSafeInteger(revision) || revision < 0 || !reports.every(isDocumentProjectionReport))
|
|
259
307
|
return;
|
|
260
|
-
const expected = new Set(canonicalOverrides.keys());
|
|
308
|
+
const expected = projection ? new Set(projection.instanceOverrides.map((record) => record.id)) : new Set(canonicalOverrides.keys());
|
|
261
309
|
if (reports.length !== expected.size || new Set(reports.map((report) => report.overrideId)).size !== reports.length
|
|
262
310
|
|| reports.some((report) => !expected.has(report.overrideId)))
|
|
263
311
|
return;
|
|
@@ -267,7 +315,8 @@ export function recordCanvasRenderedInstanceProjectionReports(cardId, revision,
|
|
|
267
315
|
const next = reports.map((report) => ({ ...report }));
|
|
268
316
|
if (existing && existing.revision === revision && sameReports(existing.reports, next))
|
|
269
317
|
return;
|
|
270
|
-
|
|
318
|
+
const current = getActiveDraftChanges();
|
|
319
|
+
reportsByCanvasCard.set(cardId, { revision, reports: next, draftId: projection?.draftId ?? current.draftId, draftRevision: projection?.draftRevision ?? current.revision });
|
|
271
320
|
notifyDiagnostics();
|
|
272
321
|
}
|
|
273
322
|
export function clearCanvasRenderedInstanceProjectionReports(cardId) {
|
|
@@ -281,6 +330,8 @@ export function getRenderedInstanceChangeDiagnostics(overrideId) {
|
|
|
281
330
|
if (host)
|
|
282
331
|
diagnostics.push({ ...host, document: "Inspect" });
|
|
283
332
|
for (const [cardId, entry] of reportsByCanvasCard) {
|
|
333
|
+
if (entry.draftId !== getActiveDraftChanges().draftId || entry.draftRevision !== getDraftChanges(entry.draftId).revision)
|
|
334
|
+
continue;
|
|
284
335
|
const report = entry.reports.find((candidate) => candidate.overrideId === overrideId);
|
|
285
336
|
if (report)
|
|
286
337
|
diagnostics.push({ ...report, document: `Canvas ${cardId}` });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FrameProjection } from "../canvas/projection.js";
|
|
1
2
|
import type { StructuralChange, StructuralDelete, StructuralMove, StructuralProjectionReason, StructuralProjectionReport } from "../changes/structuralTypes.js";
|
|
2
3
|
export { isStructuralChange, isStructuralDelete, isStructuralMove, isStructuralProjectionReport, } from "./structuralProjectionBoundary.js";
|
|
3
4
|
/**
|
|
@@ -76,7 +77,7 @@ export declare function getStructuralProjectionReports(doc: Document): readonly
|
|
|
76
77
|
* Frames may report only their document-local outcome. The controller owns
|
|
77
78
|
* these reports and filters them against its current canonical change set.
|
|
78
79
|
*/
|
|
79
|
-
export declare function recordCanvasStructuralProjectionReports(cardId: string, revision: number, reports: readonly StructuralProjectionReport[]): void;
|
|
80
|
+
export declare function recordCanvasStructuralProjectionReports(cardId: string, revision: number, reports: readonly StructuralProjectionReport[], projection?: FrameProjection): void;
|
|
80
81
|
export declare function clearCanvasStructuralProjectionReports(cardId: string): void;
|
|
81
82
|
/** Removes document-local reports for canonical intents that no longer exist. */
|
|
82
83
|
export declare function pruneStructuralProjectionReports(changeIds: ReadonlySet<string>): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getActiveDraftChanges, getDraftChanges } from "../changes/draftChanges.js";
|
|
2
|
+
import { captureRenderedInstance, captureStructuralTarget, matchesRenderedInstanceEvidence, resolveRenderedInstance, } from "./renderedInstance.js";
|
|
2
3
|
import { isStructuralProjectionReport } from "./structuralProjectionBoundary.js";
|
|
3
|
-
import {
|
|
4
|
+
import { resetDraftChanges, draftChangeStore, } from "../changes/draftChanges.js";
|
|
4
5
|
export { isStructuralChange, isStructuralDelete, isStructuralMove, isStructuralProjectionReport, } from "./structuralProjectionBoundary.js";
|
|
5
6
|
const VOID_PARENT_TAGS = new Set([
|
|
6
7
|
"area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr",
|
|
@@ -181,7 +182,7 @@ function projectStructuralChanges(snapshot) {
|
|
|
181
182
|
}
|
|
182
183
|
/** Captures a delete intent once, in the controller, at the user gesture. */
|
|
183
184
|
export function createStructuralDelete(element, id = structuralId()) {
|
|
184
|
-
const target =
|
|
185
|
+
const target = captureStructuralTarget(element);
|
|
185
186
|
if (!target)
|
|
186
187
|
return null;
|
|
187
188
|
const route = documentRoute(element.ownerDocument);
|
|
@@ -193,9 +194,9 @@ export function createStructuralDelete(element, id = structuralId()) {
|
|
|
193
194
|
...(route ? { route } : {}),
|
|
194
195
|
...(state ? { state } : {}),
|
|
195
196
|
};
|
|
196
|
-
if (!
|
|
197
|
+
if (!draftChangeStore.commitStructuralChange(change))
|
|
197
198
|
return null;
|
|
198
|
-
projectStructuralChanges(
|
|
199
|
+
projectStructuralChanges(draftChangeStore.getSnapshot());
|
|
199
200
|
return change;
|
|
200
201
|
}
|
|
201
202
|
/**
|
|
@@ -236,22 +237,22 @@ export function createStructuralMove(element, destination, id = structuralId())
|
|
|
236
237
|
: destinationChildren.length - (sameParent ? 1 : 0),
|
|
237
238
|
},
|
|
238
239
|
};
|
|
239
|
-
if (!
|
|
240
|
+
if (!draftChangeStore.commitStructuralChange(change))
|
|
240
241
|
return null;
|
|
241
|
-
projectStructuralChanges(
|
|
242
|
+
projectStructuralChanges(draftChangeStore.getSnapshot());
|
|
242
243
|
return change;
|
|
243
244
|
}
|
|
244
245
|
export function getStructuralChanges() {
|
|
245
|
-
return
|
|
246
|
+
return draftChangeStore.getSnapshot().structuralChanges;
|
|
246
247
|
}
|
|
247
248
|
export function getStructuralDeletes() {
|
|
248
249
|
return getStructuralChanges().filter((change) => change.kind === "delete");
|
|
249
250
|
}
|
|
250
251
|
/** Revert removes one canonical intent and leaves every other intent intact. */
|
|
251
252
|
export function revertStructuralChange(changeId) {
|
|
252
|
-
const changed =
|
|
253
|
+
const changed = draftChangeStore.revertStructuralChangeRecord(changeId);
|
|
253
254
|
if (changed)
|
|
254
|
-
projectStructuralChanges(
|
|
255
|
+
projectStructuralChanges(draftChangeStore.getSnapshot());
|
|
255
256
|
return changed;
|
|
256
257
|
}
|
|
257
258
|
/**
|
|
@@ -265,10 +266,10 @@ export function revertStructuralChange(changeId) {
|
|
|
265
266
|
export function reconcileVerifiedStructuralChanges(verifiedIds) {
|
|
266
267
|
if (verifiedIds.size === 0)
|
|
267
268
|
return 0;
|
|
268
|
-
const removed =
|
|
269
|
+
const removed = draftChangeStore.reconcileActiveDraftChanges(new Set(), verifiedIds);
|
|
269
270
|
if (removed === 0)
|
|
270
271
|
return 0;
|
|
271
|
-
projectStructuralChanges(
|
|
272
|
+
projectStructuralChanges(draftChangeStore.getSnapshot());
|
|
272
273
|
for (const [cardId, canvasReports] of reportsByCanvasCard) {
|
|
273
274
|
reportsByCanvasCard.set(cardId, {
|
|
274
275
|
...canvasReports,
|
|
@@ -280,7 +281,7 @@ export function reconcileVerifiedStructuralChanges(verifiedIds) {
|
|
|
280
281
|
}
|
|
281
282
|
/** State changes drive controller-to-renderer projection. Diagnostics do not. */
|
|
282
283
|
export function subscribeStructuralChanges(listener) {
|
|
283
|
-
return
|
|
284
|
+
return draftChangeStore.subscribe(listener);
|
|
284
285
|
}
|
|
285
286
|
/** Compatibility name retained while the controller moved to a full union. */
|
|
286
287
|
export const subscribeStructuralDeletes = subscribeStructuralChanges;
|
|
@@ -549,10 +550,10 @@ export function getStructuralProjectionReports(doc) {
|
|
|
549
550
|
* Frames may report only their document-local outcome. The controller owns
|
|
550
551
|
* these reports and filters them against its current canonical change set.
|
|
551
552
|
*/
|
|
552
|
-
export function recordCanvasStructuralProjectionReports(cardId, revision, reports) {
|
|
553
|
+
export function recordCanvasStructuralProjectionReports(cardId, revision, reports, projection) {
|
|
553
554
|
if (!Number.isSafeInteger(revision) || revision < 0 || !reports.every(isStructuralProjectionReport))
|
|
554
555
|
return;
|
|
555
|
-
const expected = new Set(getStructuralChanges().map((change) => change.id));
|
|
556
|
+
const expected = projection ? new Set(projection.structuralChanges.map((record) => record.id)) : new Set(getStructuralChanges().map((change) => change.id));
|
|
556
557
|
if (reports.length !== expected.size || new Set(reports.map((report) => report.changeId)).size !== reports.length
|
|
557
558
|
|| reports.some((report) => !expected.has(report.changeId)))
|
|
558
559
|
return;
|
|
@@ -562,7 +563,8 @@ export function recordCanvasStructuralProjectionReports(cardId, revision, report
|
|
|
562
563
|
const next = reports.map((report) => ({ ...report }));
|
|
563
564
|
if (existing && existing.revision === revision && sameReports(existing.reports, next))
|
|
564
565
|
return;
|
|
565
|
-
|
|
566
|
+
const current = getActiveDraftChanges();
|
|
567
|
+
reportsByCanvasCard.set(cardId, { revision, reports: next, draftId: projection?.draftId ?? current.draftId, draftRevision: projection?.draftRevision ?? current.revision });
|
|
566
568
|
notifyDiagnostics();
|
|
567
569
|
}
|
|
568
570
|
export function clearCanvasStructuralProjectionReports(cardId) {
|
|
@@ -594,6 +596,8 @@ export function getStructuralChangeDiagnostics(changeId) {
|
|
|
594
596
|
if (host)
|
|
595
597
|
diagnostics.push({ ...host, document: "Inspect" });
|
|
596
598
|
for (const [cardId, entry] of reportsByCanvasCard) {
|
|
599
|
+
if (entry.draftId !== getActiveDraftChanges().draftId || entry.draftRevision !== getDraftChanges(entry.draftId).revision)
|
|
600
|
+
continue;
|
|
597
601
|
const report = entry.reports.find((candidate) => candidate.changeId === changeId);
|
|
598
602
|
if (report)
|
|
599
603
|
diagnostics.push({ ...report, document: `Canvas ${cardId}` });
|
|
@@ -615,7 +619,7 @@ export function resetStructuralDeleteProjection() {
|
|
|
615
619
|
reportsByCanvasCard.clear();
|
|
616
620
|
nextStructuralId = 1;
|
|
617
621
|
diagnosticRevision = 0;
|
|
618
|
-
|
|
622
|
+
resetDraftChanges();
|
|
619
623
|
notifyDiagnostics();
|
|
620
624
|
}
|
|
621
625
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FrameProjection } from "../canvas/projection.js";
|
|
1
2
|
import { isTextProjectionTargetValue, type TextContentChangeRecord, type TextProjectionTarget, type TextProjectionScope, type TextBindingEvidence } from "../inline-text/textChangeBoundary.js";
|
|
2
3
|
/** Strict JSON boundary guard for a text projection target. */
|
|
3
4
|
export declare const isTextProjectionTarget: typeof isTextProjectionTargetValue;
|
|
@@ -48,7 +49,7 @@ export declare function setCanonicalTextContentChanges(changes: ReadonlyArray<Te
|
|
|
48
49
|
export declare function getTextProjectionReports(doc: Document): readonly TextProjectionReport[];
|
|
49
50
|
export declare function subscribeTextProjectionDiagnostics(listener: () => void): () => void;
|
|
50
51
|
export declare function getTextProjectionDiagnosticRevision(): number;
|
|
51
|
-
export declare function recordCanvasTextProjectionReports(cardId: string, revision: number, reports: readonly TextProjectionReport[]): void;
|
|
52
|
+
export declare function recordCanvasTextProjectionReports(cardId: string, revision: number, reports: readonly TextProjectionReport[], projection?: FrameProjection): void;
|
|
52
53
|
export declare function clearCanvasTextProjectionReports(cardId: string): void;
|
|
53
54
|
export declare function getTextContentChangeDiagnostics(changeId: string): TextContentProjectionDiagnostic[];
|
|
54
55
|
export declare function isTextProjectionReport(value: unknown): value is TextProjectionReport;
|