nudge-ui 0.2.4 → 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 +863 -213
- 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 +1 -1
- package/dist/inspector/agent/verification.js +7 -4
- 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 +21 -12
- package/dist/inspector/canvas/CanvasElementOverlay.js +82 -127
- package/dist/inspector/canvas/CanvasToolbar.js +2 -1
- package/dist/inspector/canvas/CanvasWorkspace.js +74 -97
- 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/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 +1 -0
- package/dist/inspector/changes/codecs.js +20 -5
- package/dist/inspector/changes/draftPreview.d.ts +12 -0
- package/dist/inspector/changes/draftPreview.js +133 -0
- package/dist/inspector/changes/editModel.d.ts +8 -0
- package/dist/inspector/changes/editModel.js +8 -2
- package/dist/inspector/changes/managedStyleProjection.js +2 -1
- package/dist/inspector/changes/previewDiagnostics.js +1 -1
- package/dist/inspector/changes/types.d.ts +11 -1
- package/dist/inspector/comments/CommentsOverlay.js +18 -16
- 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/changeAction.js +1 -1
- package/dist/inspector/componentSemantics/textBinding.d.ts +1 -2
- package/dist/inspector/componentSemantics/textBinding.js +4 -45
- 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/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.js +7 -1
- package/dist/inspector/projection/structuralProjection.d.ts +0 -9
- package/dist/inspector/projection/structuralProjection.js +14 -44
- package/dist/inspector/projection/textProjection.d.ts +8 -2
- package/dist/inspector/projection/textProjection.js +21 -13
- package/dist/inspector/prompt/clipboardHandoff.d.ts +9 -0
- package/dist/inspector/prompt/clipboardHandoff.js +42 -16
- package/dist/inspector/prompt/generatePrompt.d.ts +1 -1
- package/dist/inspector/prompt/generatePrompt.js +243 -147
- 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/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 +60 -54
- 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 +2 -1
- 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 +34 -3
- package/dist/inspector/tokens/TokensPanel.js +2 -1
- package/dist/inspector/tokens/editActions.d.ts +3 -3
- package/dist/inspector/tokens/editActions.js +9 -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 +3 -6
- package/dist/inspector/workspace/sentItems.js +6 -24
- 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 +12 -2
- 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 -49
- package/dist/inspector/changes/changesLog.js +0 -255
- package/dist/inspector/changes/draftChanges.d.ts +0 -58
- package/dist/inspector/changes/draftChanges.js +0 -304
- 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
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import { canEditDraft } from "./draftChanges.js";
|
|
2
|
-
import { useSyncExternalStore } from "react";
|
|
3
|
-
import { getSelectedElement } from "../selection/selectionStore.js";
|
|
4
|
-
import { changeKey, } from "./model.js";
|
|
5
|
-
import { buildManagedStyleRules, verifyManagedStyleProjection, } from "./managedStyleProjection.js";
|
|
6
|
-
import { isPreviewableChange } from "./types.js";
|
|
7
|
-
import { cancelInlineTextForClear } from "../inline-text/inlineTextLifecycle.js";
|
|
8
|
-
import { draftChangeStore, } from "./draftChanges.js";
|
|
9
|
-
import { beginPreviewAttempt, clearPreviewDiagnostics, getHostPreviewDocument, publishPreviewDiagnostic, } from "./previewDiagnostics.js";
|
|
10
|
-
import { clearStructuralProjectionReports, pruneStructuralProjectionReports } from "../projection/structuralProjection.js";
|
|
11
|
-
import { applyHostDraftProjection, compileDraftProjection, } from "../projection/draftProjection.js";
|
|
12
|
-
import { isEditorShellDocument } from "../runtime/editorShell.js";
|
|
13
|
-
import { isOriginalPreviewActive, subscribeOriginalPreview, } from "../shell/originalPreview.js";
|
|
14
|
-
export { isComponentChange, isElementChange, isTextContentChange, isTextContentChangeValue, isPreviewableChange, isTokenChange, } from "./types.js";
|
|
15
|
-
/**
|
|
16
|
-
* Deferred delta verification (0044). Only the keys touched by a mutation are
|
|
17
|
-
* re-verified, and the probe work runs coalesced off the synchronous commit
|
|
18
|
-
* path (requestIdleCallback, falling back to rAF / a macrotask).
|
|
19
|
-
*/
|
|
20
|
-
let pendingVerificationTargets = new Map();
|
|
21
|
-
let verificationHandle = null;
|
|
22
|
-
function subscribe(cb) {
|
|
23
|
-
return draftChangeStore.subscribe(cb);
|
|
24
|
-
}
|
|
25
|
-
function getChangesSnapshot() {
|
|
26
|
-
// SAFETY: The public change model is the concrete record union stored by
|
|
27
|
-
// the workspace snapshot; this module preserves the mutable array facade.
|
|
28
|
-
return draftChangeStore.getSnapshot().changes;
|
|
29
|
-
}
|
|
30
|
-
export function getPendingRules() {
|
|
31
|
-
return buildManagedStyleRules(getChangesSnapshot());
|
|
32
|
-
}
|
|
33
|
-
function reapply(workspace) {
|
|
34
|
-
// While hold-to-view-original is active the host document intentionally
|
|
35
|
-
// shows the page without inspector changes. Commits still land in the
|
|
36
|
-
// canonical store; the release path re-projects the latest snapshot.
|
|
37
|
-
if (isOriginalPreviewActive())
|
|
38
|
-
return;
|
|
39
|
-
if (!isEditorShellDocument())
|
|
40
|
-
applyHostDraftProjection(compileDraftProjection(workspace));
|
|
41
|
-
}
|
|
42
|
-
function flushVerification() {
|
|
43
|
-
verificationHandle = null;
|
|
44
|
-
// Probing the original preview would report the held-back changes as
|
|
45
|
-
// conflicts. Keep the pending targets; releasing re-verifies them.
|
|
46
|
-
if (isOriginalPreviewActive())
|
|
47
|
-
return;
|
|
48
|
-
const targets = pendingVerificationTargets;
|
|
49
|
-
pendingVerificationTargets = new Map();
|
|
50
|
-
if (targets.size === 0)
|
|
51
|
-
return;
|
|
52
|
-
// The editor shell has no application document. Renderer diagnostics are
|
|
53
|
-
// owned by renderer projection reports.
|
|
54
|
-
if (isEditorShellDocument())
|
|
55
|
-
return;
|
|
56
|
-
const current = getChangesSnapshot();
|
|
57
|
-
const attempt = beginPreviewAttempt(getHostPreviewDocument(), draftChangeStore.getSnapshot().revision);
|
|
58
|
-
if (!attempt)
|
|
59
|
-
return;
|
|
60
|
-
for (let i = 0; i < current.length; i++) {
|
|
61
|
-
const change = current[i];
|
|
62
|
-
if (!isPreviewableChange(change))
|
|
63
|
-
continue;
|
|
64
|
-
const key = changeKey(change);
|
|
65
|
-
if (!targets.has(key))
|
|
66
|
-
continue;
|
|
67
|
-
const result = verifyManagedStyleProjection(change, targets.get(key) ?? null);
|
|
68
|
-
if (result) {
|
|
69
|
-
publishPreviewDiagnostic(attempt, key, result);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function scheduleVerification() {
|
|
74
|
-
if (verificationHandle !== null)
|
|
75
|
-
return;
|
|
76
|
-
const view = typeof window !== "undefined" ? window : undefined;
|
|
77
|
-
if (view && typeof view.requestIdleCallback === "function") {
|
|
78
|
-
verificationHandle = view.requestIdleCallback(() => {
|
|
79
|
-
flushVerification();
|
|
80
|
-
}, { timeout: 200 });
|
|
81
|
-
}
|
|
82
|
-
else if (view && typeof view.requestAnimationFrame === "function") {
|
|
83
|
-
verificationHandle = view.requestAnimationFrame(() => {
|
|
84
|
-
flushVerification();
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
verificationHandle = setTimeout(() => {
|
|
89
|
-
flushVerification();
|
|
90
|
-
}, 0);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Marks the given change keys for deferred re-verification. Undo/redo/revert
|
|
95
|
-
* re-verify the surviving set (their sheet projection changed globally).
|
|
96
|
-
* A plain commit re-verifies the full surviving set as well: a new rule can
|
|
97
|
-
* change cascade/specificity for earlier changes, so verifying only incoming
|
|
98
|
-
* records would drop their conflict warnings.
|
|
99
|
-
*/
|
|
100
|
-
function markForVerification(keys, verificationTargets) {
|
|
101
|
-
const selectedElement = getSelectedElement()?.domElement ?? null;
|
|
102
|
-
let added = false;
|
|
103
|
-
for (const key of keys) {
|
|
104
|
-
if (!pendingVerificationTargets.has(key))
|
|
105
|
-
added = true;
|
|
106
|
-
// Keep the latest commit context for a merged key. The element may be in
|
|
107
|
-
// an iframe, so this is also the document boundary for verification.
|
|
108
|
-
pendingVerificationTargets.set(key, verificationTargets?.get(key) ?? selectedElement);
|
|
109
|
-
}
|
|
110
|
-
if (added)
|
|
111
|
-
scheduleVerification();
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Releasing hold-to-view-original restores the edited preview; re-verify the
|
|
115
|
-
* surviving set against the restored DOM instead of leaving peek-era state.
|
|
116
|
-
* The retry is forced: a flush that ran during the hold retains its targets
|
|
117
|
-
* without scheduling, so markForVerification alone would see every key
|
|
118
|
-
* already present and schedule nothing.
|
|
119
|
-
*/
|
|
120
|
-
subscribeOriginalPreview(() => {
|
|
121
|
-
if (isOriginalPreviewActive())
|
|
122
|
-
return;
|
|
123
|
-
markForVerification(getChangesSnapshot().map(changeKey));
|
|
124
|
-
if (pendingVerificationTargets.size > 0)
|
|
125
|
-
scheduleVerification();
|
|
126
|
-
});
|
|
127
|
-
/** Append records and report whether canonical workspace state changed. */
|
|
128
|
-
export function appendChanges(incoming, options = {}) {
|
|
129
|
-
const result = draftChangeStore.commitChangeRecords(incoming);
|
|
130
|
-
if (result !== "applied")
|
|
131
|
-
return result;
|
|
132
|
-
reapply(draftChangeStore.getSnapshot());
|
|
133
|
-
// Re-verify the full surviving set so earlier diagnostics are refreshed at
|
|
134
|
-
// the new revision instead of being orphaned at the old one.
|
|
135
|
-
markForVerification(getChangesSnapshot().map(changeKey), options.verificationTargets);
|
|
136
|
-
return result;
|
|
137
|
-
}
|
|
138
|
-
export function appendChange(change) {
|
|
139
|
-
return appendChanges([change]);
|
|
140
|
-
}
|
|
141
|
-
export function revertChange(change) {
|
|
142
|
-
if (!draftChangeStore.revertChangeRecord(change))
|
|
143
|
-
return;
|
|
144
|
-
reapply(draftChangeStore.getSnapshot());
|
|
145
|
-
markForVerification(getChangesSnapshot().map(changeKey));
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Removes source-verified records without allowing older undo snapshots to
|
|
149
|
-
* resurrect their managed previews.
|
|
150
|
-
*
|
|
151
|
-
* Agent handoff revisions identify records by the same stable key used by the
|
|
152
|
-
* canonical change model. Verification can therefore reconcile a subset while
|
|
153
|
-
* preserving newer, unsent edits and their remaining undo history.
|
|
154
|
-
*/
|
|
155
|
-
export function reconcileVerifiedChanges(verifiedKeys) {
|
|
156
|
-
const removed = reconcileVerifiedDraftChanges(verifiedKeys, new Set());
|
|
157
|
-
if (removed === 0)
|
|
158
|
-
return 0;
|
|
159
|
-
return removed;
|
|
160
|
-
}
|
|
161
|
-
/** Atomically reconciles ordinary and structural intent from one agent handoff. */
|
|
162
|
-
export function reconcileVerifiedDraftChanges(verifiedKeys, verifiedStructuralIds) {
|
|
163
|
-
const removed = draftChangeStore.reconcileActiveDraftChanges(verifiedKeys, verifiedStructuralIds);
|
|
164
|
-
if (removed === 0)
|
|
165
|
-
return 0;
|
|
166
|
-
reapply(draftChangeStore.getSnapshot());
|
|
167
|
-
pruneStructuralProjectionReports(verifiedStructuralIds);
|
|
168
|
-
markForVerification(getChangesSnapshot().map(changeKey));
|
|
169
|
-
return removed;
|
|
170
|
-
}
|
|
171
|
-
/** Replaces ordinary and structural intent as one undoable edit. */
|
|
172
|
-
export function commitDraftContents(changes, structuralChanges) {
|
|
173
|
-
if (!draftChangeStore.commitContents({ changes: [...changes], structuralChanges: [...structuralChanges] }))
|
|
174
|
-
return false;
|
|
175
|
-
reapply(draftChangeStore.getSnapshot());
|
|
176
|
-
markForVerification(getChangesSnapshot().map(changeKey));
|
|
177
|
-
return true;
|
|
178
|
-
}
|
|
179
|
-
export function discardChangesForSelector(selector) {
|
|
180
|
-
if (!draftChangeStore.discardChangeRecords({ kind: "selector", selector }))
|
|
181
|
-
return;
|
|
182
|
-
reapply(draftChangeStore.getSnapshot());
|
|
183
|
-
markForVerification(getChangesSnapshot().map(changeKey));
|
|
184
|
-
}
|
|
185
|
-
/** Relink removes every CSS declaration owned by one durable rendered target. */
|
|
186
|
-
export function discardChangesForInstanceOverride(overrideId) {
|
|
187
|
-
if (!draftChangeStore.discardChangeRecords({ kind: "instance-override", id: overrideId }))
|
|
188
|
-
return;
|
|
189
|
-
reapply(draftChangeStore.getSnapshot());
|
|
190
|
-
markForVerification(getChangesSnapshot().map(changeKey));
|
|
191
|
-
}
|
|
192
|
-
export function undo() {
|
|
193
|
-
const undone = draftChangeStore.undoChange();
|
|
194
|
-
if (undone)
|
|
195
|
-
reapply(draftChangeStore.getSnapshot());
|
|
196
|
-
if (undone)
|
|
197
|
-
markForVerification(getChangesSnapshot().map(changeKey));
|
|
198
|
-
return undone;
|
|
199
|
-
}
|
|
200
|
-
export function redo() {
|
|
201
|
-
const redone = draftChangeStore.redoChange();
|
|
202
|
-
if (redone)
|
|
203
|
-
reapply(draftChangeStore.getSnapshot());
|
|
204
|
-
if (redone)
|
|
205
|
-
markForVerification(getChangesSnapshot().map(changeKey));
|
|
206
|
-
return redone;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Replaces ordinary records while preserving structural intent. Restoring any
|
|
210
|
-
* dimension is terminal for the unified workspace timeline, so undo and redo
|
|
211
|
-
* history are reset for both dimensions.
|
|
212
|
-
*/
|
|
213
|
-
export function restoreChangeRecords(incoming) {
|
|
214
|
-
// A restored session replaces the change set and may also switch the active
|
|
215
|
-
// document. Do not let a deferred verification from the previous session
|
|
216
|
-
// inspect a newly loaded record with its old selection context.
|
|
217
|
-
pendingVerificationTargets.clear();
|
|
218
|
-
clearPreviewDiagnostics();
|
|
219
|
-
const workspace = draftChangeStore.getSnapshot();
|
|
220
|
-
draftChangeStore.restoreActiveDraftChanges({ changes: incoming, structuralChanges: workspace.structuralChanges });
|
|
221
|
-
reapply(draftChangeStore.getSnapshot());
|
|
222
|
-
}
|
|
223
|
-
/** Restores every canonical workspace intent as one subscriber-visible snapshot. */
|
|
224
|
-
export function loadActiveDraftChanges(incoming, structuralChanges, preserveHistory = false) {
|
|
225
|
-
pendingVerificationTargets.clear();
|
|
226
|
-
clearPreviewDiagnostics();
|
|
227
|
-
clearStructuralProjectionReports();
|
|
228
|
-
draftChangeStore.restoreActiveDraftChanges({ changes: incoming, structuralChanges }, preserveHistory);
|
|
229
|
-
reapply(draftChangeStore.getSnapshot());
|
|
230
|
-
}
|
|
231
|
-
/** Clears the active draft and its edit steps, preserving other session history. */
|
|
232
|
-
export function clearActiveDraft() {
|
|
233
|
-
if (!canEditDraft())
|
|
234
|
-
return;
|
|
235
|
-
// A pending blur/composition timer must not be able to append a draft after
|
|
236
|
-
// the canonical set has been cleared.
|
|
237
|
-
cancelInlineTextForClear();
|
|
238
|
-
pendingVerificationTargets.clear();
|
|
239
|
-
clearPreviewDiagnostics();
|
|
240
|
-
clearStructuralProjectionReports();
|
|
241
|
-
draftChangeStore.clearActiveDraftChanges();
|
|
242
|
-
reapply(draftChangeStore.getSnapshot());
|
|
243
|
-
}
|
|
244
|
-
export function getChangesList() {
|
|
245
|
-
return [...getChangesSnapshot()];
|
|
246
|
-
}
|
|
247
|
-
export { subscribe as subscribeChanges, getChangesSnapshot as getChanges };
|
|
248
|
-
export function useChanges() {
|
|
249
|
-
return useSyncExternalStore(subscribe, getChangesSnapshot, getChangesSnapshot);
|
|
250
|
-
}
|
|
251
|
-
export function refreshDraftPreview() {
|
|
252
|
-
pendingVerificationTargets.clear();
|
|
253
|
-
reapply(draftChangeStore.getSnapshot());
|
|
254
|
-
markForVerification(getChangesSnapshot().map(changeKey));
|
|
255
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { type ChangeRecord } from "./types.js";
|
|
2
|
-
import type { StructuralChange } from "./structuralTypes.js";
|
|
3
|
-
export { recordCanvasChange, discardCanvasHistory, discardDraftHistory, clearSessionUndoHistory, createChangeHistoryGroup, } from "../workspace/timeline.js";
|
|
4
|
-
export interface DraftContents {
|
|
5
|
-
readonly changes: readonly ChangeRecord[];
|
|
6
|
-
readonly structuralChanges: readonly StructuralChange[];
|
|
7
|
-
}
|
|
8
|
-
export interface DraftChangesSnapshot extends DraftContents {
|
|
9
|
-
readonly draftId: string;
|
|
10
|
-
readonly revision: number;
|
|
11
|
-
readonly canUndo: boolean;
|
|
12
|
-
readonly canRedo: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare function lockDraft(id: string): () => void;
|
|
15
|
-
export declare function isDraftLocked(id?: string): boolean;
|
|
16
|
-
export declare function canEditDraft(id?: string): boolean;
|
|
17
|
-
export declare function setActiveDraft(id: string, activate?: () => void): void;
|
|
18
|
-
export type DraftProjector = (snapshot: DraftChangesSnapshot) => void;
|
|
19
|
-
export type CommitResult = "applied" | "unchanged" | "blocked";
|
|
20
|
-
export interface DraftChangeStore {
|
|
21
|
-
getSnapshot(): DraftChangesSnapshot;
|
|
22
|
-
subscribe(listener: () => void): () => void;
|
|
23
|
-
commitChangeRecords(incoming: readonly ChangeRecord[]): CommitResult;
|
|
24
|
-
revertChangeRecord(change: ChangeRecord): boolean;
|
|
25
|
-
discardChangeRecords(target: {
|
|
26
|
-
kind: "selector";
|
|
27
|
-
selector: string;
|
|
28
|
-
} | {
|
|
29
|
-
kind: "instance-override";
|
|
30
|
-
id: string;
|
|
31
|
-
}): boolean;
|
|
32
|
-
commitStructuralChange(change: StructuralChange): boolean;
|
|
33
|
-
revertStructuralChangeRecord(changeId: string): boolean;
|
|
34
|
-
/** Replaces the active draft as one undoable edit. */
|
|
35
|
-
commitContents(next: DraftContents): boolean;
|
|
36
|
-
reconcileActiveDraftChanges(verifiedKeys: ReadonlySet<string>, verifiedStructuralIds: ReadonlySet<string>): number;
|
|
37
|
-
undoChange(): boolean;
|
|
38
|
-
redoChange(): boolean;
|
|
39
|
-
restoreActiveDraftChanges(next: DraftContents, preserveHistory?: boolean): void;
|
|
40
|
-
clearActiveDraftChanges(): void;
|
|
41
|
-
}
|
|
42
|
-
export declare function subscribeDraftChanges(listener: (draftId: string) => void): () => void;
|
|
43
|
-
export declare function getDraftChanges(id: string): DraftChangesSnapshot;
|
|
44
|
-
export declare function restoreDraftChanges(id: string, next: DraftContents, revision?: number): void;
|
|
45
|
-
export declare function reconcileDraftChanges(id: string, verifiedKeys: ReadonlySet<string>, verifiedStructuralIds: ReadonlySet<string>): number;
|
|
46
|
-
export declare function clearDraftChanges(id: string, expectedRevision?: number): boolean;
|
|
47
|
-
export declare function listDraftIds(): readonly string[];
|
|
48
|
-
/** Drops a draft whose content no longer exists, such as a deleted iteration. */
|
|
49
|
-
export declare function forgetDraft(id: string): void;
|
|
50
|
-
export declare const draftChangeStore: DraftChangeStore;
|
|
51
|
-
export declare function getActiveDraftChanges(): DraftChangesSnapshot;
|
|
52
|
-
export declare function subscribeActiveDraftChanges(listener: () => void): () => void;
|
|
53
|
-
export declare function commitChangeRecords(incoming: readonly ChangeRecord[], project: DraftProjector): CommitResult;
|
|
54
|
-
export declare function commitStructuralChange(change: StructuralChange, project: DraftProjector): boolean;
|
|
55
|
-
export declare function undoChange(project: DraftProjector): boolean;
|
|
56
|
-
export declare function redoChange(project: DraftProjector): boolean;
|
|
57
|
-
export declare function restoreActiveDraftChanges(next: DraftContents, project: DraftProjector): void;
|
|
58
|
-
export declare function resetDraftChanges(): void;
|
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
import { canWriteWorkspace } from "../canvas/workspaceLease.js";
|
|
2
|
-
import { applicationTarget, targetKey } from "../drafts/model.js";
|
|
3
|
-
import { changeKey, mergeChange, sameEffectiveChanges, selectorForChange } from "./model.js";
|
|
4
|
-
import { isElementChange } from "./types.js";
|
|
5
|
-
import { recordEdit, replayTimeline, pruneDraftHistory, timelineStatus, subscribeTimeline, clearSessionUndoHistory, discardDraftHistory, } from "../workspace/timeline.js";
|
|
6
|
-
export { recordCanvasChange, discardCanvasHistory, discardDraftHistory, clearSessionUndoHistory, createChangeHistoryGroup, } from "../workspace/timeline.js";
|
|
7
|
-
const drafts = new Map();
|
|
8
|
-
const lockedDrafts = new Set();
|
|
9
|
-
const listeners = new Set();
|
|
10
|
-
const draftListeners = new Set();
|
|
11
|
-
/** Until a frame is activated, edits belong to the current page's draft. */
|
|
12
|
-
let activeDraftId = null;
|
|
13
|
-
function activeId() {
|
|
14
|
-
return activeDraftId ??= targetKey(applicationTarget());
|
|
15
|
-
}
|
|
16
|
-
function draftState(id = activeId()) {
|
|
17
|
-
let draft = drafts.get(id);
|
|
18
|
-
if (!draft) {
|
|
19
|
-
draft = { id, revision: 0, contents: { changes: [], structuralChanges: [] } };
|
|
20
|
-
drafts.set(id, draft);
|
|
21
|
-
}
|
|
22
|
-
return draft;
|
|
23
|
-
}
|
|
24
|
-
export function lockDraft(id) {
|
|
25
|
-
if (lockedDrafts.has(id))
|
|
26
|
-
throw new Error("This iteration is already saving.");
|
|
27
|
-
lockedDrafts.add(id);
|
|
28
|
-
return () => { lockedDrafts.delete(id); };
|
|
29
|
-
}
|
|
30
|
-
export function isDraftLocked(id) {
|
|
31
|
-
return id === undefined ? lockedDrafts.size > 0 : lockedDrafts.has(id);
|
|
32
|
-
}
|
|
33
|
-
export function canEditDraft(id = activeId()) {
|
|
34
|
-
return canWriteWorkspace() && !lockedDrafts.has(id);
|
|
35
|
-
}
|
|
36
|
-
export function setActiveDraft(id, activate) {
|
|
37
|
-
draftState(id).activate = activate;
|
|
38
|
-
if (activeId() === id)
|
|
39
|
-
return;
|
|
40
|
-
activeDraftId = id;
|
|
41
|
-
publishSelection();
|
|
42
|
-
}
|
|
43
|
-
let snapshot = null;
|
|
44
|
-
function cloneContents(value) {
|
|
45
|
-
return {
|
|
46
|
-
changes: value.changes.map((change) => cloneValue(change)),
|
|
47
|
-
structuralChanges: value.structuralChanges.map((change) => cloneValue(change)),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function cloneValue(value, key) {
|
|
51
|
-
if (key === "oldToken" || key === "newToken")
|
|
52
|
-
return value;
|
|
53
|
-
if (Array.isArray(value))
|
|
54
|
-
return value.map((item) => cloneValue(item));
|
|
55
|
-
if (value !== null && typeof value === "object") {
|
|
56
|
-
const clone = {};
|
|
57
|
-
for (const [key, child] of Object.entries(value)) {
|
|
58
|
-
clone[key] = cloneValue(child, key);
|
|
59
|
-
}
|
|
60
|
-
return clone;
|
|
61
|
-
}
|
|
62
|
-
return value;
|
|
63
|
-
}
|
|
64
|
-
function freezeValue(value, key) {
|
|
65
|
-
if (key === "oldToken" || key === "newToken")
|
|
66
|
-
return value;
|
|
67
|
-
if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
|
|
68
|
-
for (const [childKey, child] of Object.entries(value))
|
|
69
|
-
freezeValue(child, childKey);
|
|
70
|
-
Object.freeze(value);
|
|
71
|
-
}
|
|
72
|
-
return value;
|
|
73
|
-
}
|
|
74
|
-
function createSnapshot() {
|
|
75
|
-
const draft = draftState();
|
|
76
|
-
return Object.freeze({ draftId: draft.id, revision: draft.revision, ...draft.contents, ...timelineStatus() });
|
|
77
|
-
}
|
|
78
|
-
let notificationDepth = 0;
|
|
79
|
-
let notificationPending = false;
|
|
80
|
-
function mutate(operation) {
|
|
81
|
-
notificationDepth += 1;
|
|
82
|
-
try {
|
|
83
|
-
return operation();
|
|
84
|
-
}
|
|
85
|
-
finally {
|
|
86
|
-
notificationDepth -= 1;
|
|
87
|
-
if (notificationDepth === 0 && notificationPending) {
|
|
88
|
-
notificationPending = false;
|
|
89
|
-
publishSelection();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function publishSelection() {
|
|
94
|
-
if (notificationDepth > 0) {
|
|
95
|
-
notificationPending = true;
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
snapshot = null;
|
|
99
|
-
for (const listener of listeners)
|
|
100
|
-
listener();
|
|
101
|
-
}
|
|
102
|
-
subscribeTimeline(publishSelection);
|
|
103
|
-
function replaceContents(draft, next) {
|
|
104
|
-
draft.contents = freezeValue(cloneContents(next));
|
|
105
|
-
draft.revision += 1;
|
|
106
|
-
for (const listener of draftListeners)
|
|
107
|
-
listener(draft.id);
|
|
108
|
-
publishSelection();
|
|
109
|
-
}
|
|
110
|
-
export function subscribeDraftChanges(listener) {
|
|
111
|
-
draftListeners.add(listener);
|
|
112
|
-
return () => draftListeners.delete(listener);
|
|
113
|
-
}
|
|
114
|
-
export function getDraftChanges(id) {
|
|
115
|
-
const draft = drafts.get(id);
|
|
116
|
-
return {
|
|
117
|
-
draftId: id,
|
|
118
|
-
revision: draft?.revision ?? 0,
|
|
119
|
-
changes: draft?.contents.changes ?? [],
|
|
120
|
-
structuralChanges: draft?.contents.structuralChanges ?? [],
|
|
121
|
-
...timelineStatus(),
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
export function restoreDraftChanges(id, next, revision = 1) {
|
|
125
|
-
const draft = draftState(id);
|
|
126
|
-
draft.contents = freezeValue(cloneContents(next));
|
|
127
|
-
draft.revision = revision;
|
|
128
|
-
publishSelection();
|
|
129
|
-
}
|
|
130
|
-
function commit(next) {
|
|
131
|
-
if (!canEditDraft())
|
|
132
|
-
return false;
|
|
133
|
-
const draft = draftState();
|
|
134
|
-
const before = draft.contents;
|
|
135
|
-
mutate(() => {
|
|
136
|
-
replaceContents(draft, next);
|
|
137
|
-
recordEdit({ draftId: draft.id, activate: draft.activate, before, after: draft.contents }, sameDraftContents);
|
|
138
|
-
});
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
function getSnapshot() { return snapshot ??= createSnapshot(); }
|
|
142
|
-
function subscribe(listener) {
|
|
143
|
-
listeners.add(listener);
|
|
144
|
-
return () => listeners.delete(listener);
|
|
145
|
-
}
|
|
146
|
-
function commitChangeRecordsImpl(incoming) {
|
|
147
|
-
if (incoming.length === 0)
|
|
148
|
-
return "unchanged";
|
|
149
|
-
const contents = draftState().contents;
|
|
150
|
-
const changes = incoming.reduce((current, change) => mergeChange(current, change), [...contents.changes]);
|
|
151
|
-
if (sameEffectiveChanges([...contents.changes], changes))
|
|
152
|
-
return "unchanged";
|
|
153
|
-
return commit({ ...contents, changes }) ? "applied" : "blocked";
|
|
154
|
-
}
|
|
155
|
-
function revertChangeRecordImpl(change) {
|
|
156
|
-
const contents = draftState().contents;
|
|
157
|
-
const changes = contents.changes.filter((candidate) => changeKey(candidate) !== changeKey(change));
|
|
158
|
-
return changes.length !== contents.changes.length && commit({ ...contents, changes });
|
|
159
|
-
}
|
|
160
|
-
function discardChangeRecordsImpl(target) {
|
|
161
|
-
const contents = draftState().contents;
|
|
162
|
-
const changes = contents.changes.filter((change) => target.kind === "selector"
|
|
163
|
-
? selectorForChange(change) !== target.selector
|
|
164
|
-
: !isElementChange(change) || change.instanceOverride?.id !== target.id);
|
|
165
|
-
return changes.length !== contents.changes.length && commit({ ...contents, changes });
|
|
166
|
-
}
|
|
167
|
-
function commitStructuralChangeImpl(change) {
|
|
168
|
-
const contents = draftState().contents;
|
|
169
|
-
if (contents.structuralChanges.some((candidate) => candidate.id === change.id))
|
|
170
|
-
return false;
|
|
171
|
-
return commit({ ...contents, structuralChanges: [...contents.structuralChanges, change] });
|
|
172
|
-
}
|
|
173
|
-
function revertStructuralChangeRecordImpl(changeId) {
|
|
174
|
-
const contents = draftState().contents;
|
|
175
|
-
const structuralChanges = contents.structuralChanges.filter((change) => change.id !== changeId);
|
|
176
|
-
return structuralChanges.length !== contents.structuralChanges.length && commit({ ...contents, structuralChanges });
|
|
177
|
-
}
|
|
178
|
-
function commitContentsImpl(next) {
|
|
179
|
-
return !sameDraftContents(draftState().contents, next) && commit(next);
|
|
180
|
-
}
|
|
181
|
-
export function reconcileDraftChanges(id, verifiedKeys, verifiedStructuralIds) {
|
|
182
|
-
if (!canEditDraft(id))
|
|
183
|
-
return 0;
|
|
184
|
-
const draft = draftState(id);
|
|
185
|
-
const retain = (value) => ({
|
|
186
|
-
changes: value.changes.filter((change) => !verifiedKeys.has(changeKey(change))),
|
|
187
|
-
structuralChanges: value.structuralChanges.filter((change) => !verifiedStructuralIds.has(change.id)),
|
|
188
|
-
});
|
|
189
|
-
const next = retain(draft.contents);
|
|
190
|
-
const removed = draft.contents.changes.length - next.changes.length + draft.contents.structuralChanges.length - next.structuralChanges.length;
|
|
191
|
-
if (removed === 0)
|
|
192
|
-
return 0;
|
|
193
|
-
mutate(() => {
|
|
194
|
-
replaceContents(draft, next);
|
|
195
|
-
pruneDraftHistory(id, retain, sameDraftContents);
|
|
196
|
-
});
|
|
197
|
-
return removed;
|
|
198
|
-
}
|
|
199
|
-
function reconcileActiveDraftChangesImpl(keys, ids) {
|
|
200
|
-
return reconcileDraftChanges(activeId(), keys, ids);
|
|
201
|
-
}
|
|
202
|
-
function sameDraftContents(left, right) {
|
|
203
|
-
return sameEffectiveChanges([...left.changes], [...right.changes])
|
|
204
|
-
&& JSON.stringify(left.structuralChanges) === JSON.stringify(right.structuralChanges);
|
|
205
|
-
}
|
|
206
|
-
function replay(direction) {
|
|
207
|
-
if (isDraftLocked() || !canWriteWorkspace())
|
|
208
|
-
return false;
|
|
209
|
-
return mutate(() => replayTimeline(direction, (entry, next) => {
|
|
210
|
-
replaceContents(draftState(entry.draftId), next);
|
|
211
|
-
entry.activate?.();
|
|
212
|
-
if (!entry.activate)
|
|
213
|
-
setActiveDraft(entry.draftId);
|
|
214
|
-
}));
|
|
215
|
-
}
|
|
216
|
-
function restoreActiveDraftChangesImpl(next, preserveHistory = false) {
|
|
217
|
-
mutate(() => {
|
|
218
|
-
replaceContents(draftState(), next);
|
|
219
|
-
if (!preserveHistory)
|
|
220
|
-
clearSessionUndoHistory();
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
export function clearDraftChanges(id, expectedRevision) {
|
|
224
|
-
const draft = draftState(id);
|
|
225
|
-
if (!canEditDraft(id) || (expectedRevision !== undefined && draft.revision !== expectedRevision))
|
|
226
|
-
return false;
|
|
227
|
-
mutate(() => {
|
|
228
|
-
replaceContents(draft, { changes: [], structuralChanges: [] });
|
|
229
|
-
discardDraftHistory(id);
|
|
230
|
-
});
|
|
231
|
-
return true;
|
|
232
|
-
}
|
|
233
|
-
export function listDraftIds() {
|
|
234
|
-
return [...drafts.keys()];
|
|
235
|
-
}
|
|
236
|
-
/** Drops a draft whose content no longer exists, such as a deleted iteration. */
|
|
237
|
-
export function forgetDraft(id) {
|
|
238
|
-
if (!drafts.has(id) || lockedDrafts.has(id))
|
|
239
|
-
return;
|
|
240
|
-
discardDraftHistory(id);
|
|
241
|
-
drafts.delete(id);
|
|
242
|
-
for (const listener of draftListeners)
|
|
243
|
-
listener(id);
|
|
244
|
-
publishSelection();
|
|
245
|
-
}
|
|
246
|
-
function clearActiveDraftChangesImpl() { clearDraftChanges(activeId()); }
|
|
247
|
-
function resetDraftChangesImpl() {
|
|
248
|
-
drafts.clear();
|
|
249
|
-
lockedDrafts.clear();
|
|
250
|
-
activeDraftId = null;
|
|
251
|
-
clearSessionUndoHistory();
|
|
252
|
-
publishSelection();
|
|
253
|
-
}
|
|
254
|
-
export const draftChangeStore = {
|
|
255
|
-
getSnapshot, subscribe,
|
|
256
|
-
commitChangeRecords: commitChangeRecordsImpl,
|
|
257
|
-
revertChangeRecord: revertChangeRecordImpl,
|
|
258
|
-
discardChangeRecords: discardChangeRecordsImpl,
|
|
259
|
-
commitStructuralChange: commitStructuralChangeImpl,
|
|
260
|
-
revertStructuralChangeRecord: revertStructuralChangeRecordImpl,
|
|
261
|
-
commitContents: commitContentsImpl,
|
|
262
|
-
reconcileActiveDraftChanges: reconcileActiveDraftChangesImpl,
|
|
263
|
-
undoChange: () => replay("undo"),
|
|
264
|
-
redoChange: () => replay("redo"),
|
|
265
|
-
restoreActiveDraftChanges: restoreActiveDraftChangesImpl,
|
|
266
|
-
clearActiveDraftChanges: clearActiveDraftChangesImpl,
|
|
267
|
-
};
|
|
268
|
-
export function getActiveDraftChanges() {
|
|
269
|
-
return draftChangeStore.getSnapshot();
|
|
270
|
-
}
|
|
271
|
-
export function subscribeActiveDraftChanges(listener) {
|
|
272
|
-
return draftChangeStore.subscribe(listener);
|
|
273
|
-
}
|
|
274
|
-
export function commitChangeRecords(incoming, project) {
|
|
275
|
-
const result = draftChangeStore.commitChangeRecords(incoming);
|
|
276
|
-
if (result === "applied")
|
|
277
|
-
project(draftChangeStore.getSnapshot());
|
|
278
|
-
return result;
|
|
279
|
-
}
|
|
280
|
-
export function commitStructuralChange(change, project) {
|
|
281
|
-
const changed = draftChangeStore.commitStructuralChange(change);
|
|
282
|
-
if (changed)
|
|
283
|
-
project(draftChangeStore.getSnapshot());
|
|
284
|
-
return changed;
|
|
285
|
-
}
|
|
286
|
-
export function undoChange(project) {
|
|
287
|
-
const changed = draftChangeStore.undoChange();
|
|
288
|
-
if (changed)
|
|
289
|
-
project(draftChangeStore.getSnapshot());
|
|
290
|
-
return changed;
|
|
291
|
-
}
|
|
292
|
-
export function redoChange(project) {
|
|
293
|
-
const changed = draftChangeStore.redoChange();
|
|
294
|
-
if (changed)
|
|
295
|
-
project(draftChangeStore.getSnapshot());
|
|
296
|
-
return changed;
|
|
297
|
-
}
|
|
298
|
-
export function restoreActiveDraftChanges(next, project) {
|
|
299
|
-
draftChangeStore.restoreActiveDraftChanges(next);
|
|
300
|
-
project(draftChangeStore.getSnapshot());
|
|
301
|
-
}
|
|
302
|
-
export function resetDraftChanges() {
|
|
303
|
-
resetDraftChangesImpl();
|
|
304
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export { projectInspectorValues, projectionSides, } from "../spacing/projection.js";
|
|
2
|
-
export type { InspectorAxisProjection, InspectorFieldProjection, InspectorProjection, InspectorSpacingProjection, ProjectionAxis, ProjectionGroup, ProjectionSide, ProjectionState, } from "../spacing/projection.js";
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compatibility seam for the former inline-text model owner. The shared
|
|
3
|
-
* vocabulary and guards now live in `changes/editModel.ts`.
|
|
4
|
-
*/
|
|
5
|
-
export type { TextBindingEvidence, TextContentChangeRecord, TextProjectionScope, TextProjectionSourceSite, TextProjectionTarget, } from "../changes/editModel.js";
|
|
6
|
-
export { isTextContentChangeListValue, isTextContentChangeValue, isTextProjectionTargetValue, } from "../changes/editModel.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { isTextContentChangeListValue, isTextContentChangeValue, isTextProjectionTargetValue, } from "../changes/editModel.js";
|