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,28 +1,142 @@
|
|
|
1
|
+
import { inspectorStorage } from "../runtime/inspectorStorage.js";
|
|
1
2
|
import { useSyncExternalStore } from "react";
|
|
2
3
|
import { getCanvasCards, selectCard, focusCanvasCards, activateIframeWorkspace } from "../canvas/canvasStore.js";
|
|
3
4
|
import { contentEditTarget } from "../canvas/frameContent.js";
|
|
4
|
-
import { deserializeChange, isSerializableChange, serializeChange, } from "../changes/codecs.js";
|
|
5
|
-
import { getActiveDraftChanges, getDraftChanges, restoreDraftChanges, subscribeDraftChanges, setActiveDraft, clearDraftChanges, listDraftIds, resetDraftChanges, } from "../changes/draftChanges.js";
|
|
6
|
-
import { refreshDraftPreview } from "../changes/changesLog.js";
|
|
7
|
-
import { isStructuralChange } from "../projection/structuralProjection.js";
|
|
8
5
|
import { canWriteWorkspace } from "../canvas/workspaceLease.js";
|
|
6
|
+
import { createDraftPreview } from "../changes/draftPreview.js";
|
|
7
|
+
import { buildManagedStyleRules } from "../changes/managedStyleProjection.js";
|
|
8
|
+
import { cancelInlineTextForClear } from "../inline-text/inlineTextLifecycle.js";
|
|
9
9
|
import { getSketchStoreSnapshot, subscribeSketchStore } from "../sketch/store.js";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
import { sessionTimeline } from "../workspace/timeline.js";
|
|
11
|
+
import { createDraftStore } from "./draftStore.js";
|
|
12
|
+
import { targetFromKey, targetKey } from "./model.js";
|
|
13
|
+
const preview = createDraftPreview(() => drafts.getActive());
|
|
14
|
+
/** The Workspace's drafts, wired to the Canvas lease, session timeline, local storage, and host preview. */
|
|
15
|
+
const drafts = createDraftStore({
|
|
16
|
+
canWrite: () => canWriteWorkspace(),
|
|
17
|
+
timeline: sessionTimeline,
|
|
18
|
+
storage: {
|
|
19
|
+
read: (key) => inspectorStorage()?.getItem(key) ?? null,
|
|
20
|
+
write: (key, value) => inspectorStorage()?.setItem(key, value),
|
|
21
|
+
remove: (key) => inspectorStorage()?.removeItem(key),
|
|
22
|
+
},
|
|
23
|
+
sketches: { getSnapshot: () => getSketchStoreSnapshot(), subscribe: (listener) => subscribeSketchStore(listener) },
|
|
24
|
+
project: (snapshot, event) => preview.project(snapshot, event),
|
|
25
|
+
});
|
|
15
26
|
const contentDrafts = new WeakMap();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
function
|
|
27
|
+
export function getActiveDraftChanges() {
|
|
28
|
+
return drafts.getActive();
|
|
29
|
+
}
|
|
30
|
+
export function subscribeActiveDraftChanges(listener) {
|
|
31
|
+
return drafts.subscribeActive(listener);
|
|
32
|
+
}
|
|
33
|
+
export function getDraftChanges(id) {
|
|
34
|
+
return drafts.get(id);
|
|
35
|
+
}
|
|
36
|
+
export function listDraftIds() {
|
|
37
|
+
return drafts.ids();
|
|
38
|
+
}
|
|
39
|
+
export function getDraft(id) {
|
|
40
|
+
return drafts.getDraft(id);
|
|
41
|
+
}
|
|
42
|
+
export function getDraftsSnapshot() {
|
|
43
|
+
return drafts.getSnapshot();
|
|
44
|
+
}
|
|
45
|
+
export function subscribeDrafts(listener) {
|
|
46
|
+
return drafts.subscribe(listener);
|
|
47
|
+
}
|
|
48
|
+
export function useDrafts() {
|
|
49
|
+
return useSyncExternalStore(subscribeDrafts, getDraftsSnapshot, getDraftsSnapshot);
|
|
50
|
+
}
|
|
51
|
+
export function canEditDraft(id) {
|
|
52
|
+
return drafts.canEdit(id);
|
|
53
|
+
}
|
|
54
|
+
export function isDraftLocked(id) {
|
|
55
|
+
return drafts.isLocked(id);
|
|
56
|
+
}
|
|
57
|
+
export function lockDraft(id) {
|
|
58
|
+
return drafts.lock(id);
|
|
59
|
+
}
|
|
60
|
+
function activeChanges() {
|
|
61
|
+
// SAFETY: The public change model is the concrete record union stored by
|
|
62
|
+
// the workspace snapshot; React consumers keep the mutable array type.
|
|
63
|
+
return drafts.getActive().changes;
|
|
64
|
+
}
|
|
65
|
+
export function useChanges() {
|
|
66
|
+
return useSyncExternalStore(subscribeActiveDraftChanges, activeChanges, activeChanges);
|
|
67
|
+
}
|
|
68
|
+
export function getChangesList() {
|
|
69
|
+
return [...activeChanges()];
|
|
70
|
+
}
|
|
71
|
+
export function getPendingRules() {
|
|
72
|
+
return buildManagedStyleRules(activeChanges());
|
|
73
|
+
}
|
|
74
|
+
/** Appends records and reports whether canonical workspace state changed. */
|
|
75
|
+
export function appendChanges(incoming, options = {}) {
|
|
76
|
+
return drafts.commitChanges(incoming, options.verificationTargets);
|
|
77
|
+
}
|
|
78
|
+
export function appendChange(change) {
|
|
79
|
+
return drafts.commitChanges([change]);
|
|
80
|
+
}
|
|
81
|
+
export function revertChange(change) {
|
|
82
|
+
drafts.revertChange(change);
|
|
83
|
+
}
|
|
84
|
+
export function discardChangesForSelector(selector) {
|
|
85
|
+
drafts.discardChanges({ kind: "selector", selector });
|
|
86
|
+
}
|
|
87
|
+
/** Relink removes every CSS declaration owned by one durable rendered target. */
|
|
88
|
+
export function discardChangesForInstanceOverride(overrideId) {
|
|
89
|
+
drafts.discardChanges({ kind: "instance-override", id: overrideId });
|
|
90
|
+
}
|
|
91
|
+
export function commitStructuralChange(change) {
|
|
92
|
+
return drafts.commitStructuralChange(change);
|
|
93
|
+
}
|
|
94
|
+
export function revertStructuralChange(changeId) {
|
|
95
|
+
return drafts.revertStructuralChange(changeId);
|
|
96
|
+
}
|
|
97
|
+
/** Replaces ordinary and structural intent as one undoable edit. */
|
|
98
|
+
export function commitDraftContents(changes, structuralChanges) {
|
|
99
|
+
return drafts.commitContents({ changes, structuralChanges });
|
|
100
|
+
}
|
|
101
|
+
export function undo() {
|
|
102
|
+
return drafts.undo();
|
|
103
|
+
}
|
|
104
|
+
export function redo() {
|
|
105
|
+
return drafts.redo();
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Removes source-verified records without letting older undo snapshots
|
|
109
|
+
* resurrect their previews. Newer, unsent edits and their history survive.
|
|
110
|
+
*/
|
|
111
|
+
export function reconcileDraftChanges(id, verifiedKeys, verifiedStructuralIds) {
|
|
112
|
+
return drafts.reconcile(id, verifiedKeys, verifiedStructuralIds);
|
|
113
|
+
}
|
|
114
|
+
/** Clears the active draft and its edit steps, preserving other session history. */
|
|
115
|
+
export function clearActiveDraft() {
|
|
116
|
+
if (!drafts.canEdit())
|
|
117
|
+
return;
|
|
118
|
+
// A pending blur/composition timer must not be able to append a draft after
|
|
119
|
+
// the canonical set has been cleared.
|
|
120
|
+
cancelInlineTextForClear();
|
|
121
|
+
drafts.clearActive();
|
|
122
|
+
}
|
|
123
|
+
/** Drops a draft whose content no longer exists, such as a deleted iteration. */
|
|
124
|
+
export function forgetDraft(id) {
|
|
125
|
+
drafts.forget(id);
|
|
126
|
+
}
|
|
127
|
+
export function loadDrafts(projectId, options = {}) {
|
|
128
|
+
drafts.load(projectId, options);
|
|
129
|
+
}
|
|
130
|
+
export function persistDrafts() {
|
|
131
|
+
drafts.persist();
|
|
132
|
+
}
|
|
133
|
+
/** Discards stored and in-memory drafts for the current project. */
|
|
134
|
+
export function clearDrafts() {
|
|
135
|
+
drafts.discardAll();
|
|
136
|
+
}
|
|
137
|
+
export function resetDrafts() {
|
|
138
|
+
drafts.reset();
|
|
139
|
+
}
|
|
26
140
|
export function draftIdForContent(content) {
|
|
27
141
|
let id = contentDrafts.get(content);
|
|
28
142
|
if (id === undefined) {
|
|
@@ -35,116 +149,12 @@ export function draftIdForCard(cardId) {
|
|
|
35
149
|
const card = getCanvasCards().find((candidate) => candidate.id === cardId);
|
|
36
150
|
return card ? draftIdForContent(card.content) : null;
|
|
37
151
|
}
|
|
38
|
-
export function sketchOwner(document) {
|
|
39
|
-
const owner = sketchOwners.get(document.id);
|
|
40
|
-
if (owner)
|
|
41
|
-
return owner;
|
|
42
|
-
try {
|
|
43
|
-
return targetKey(documentTarget(document.capture.url));
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function readDraft(id, target) {
|
|
50
|
-
const workspace = getDraftChanges(id);
|
|
51
|
-
return {
|
|
52
|
-
id,
|
|
53
|
-
target,
|
|
54
|
-
revision: workspace.revision,
|
|
55
|
-
contents: { changes: workspace.changes, structuralChanges: workspace.structuralChanges },
|
|
56
|
-
sketchIds: getSketchStoreSnapshot().documents.filter((document) => sketchOwner(document) === id).map((document) => document.id),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
export function getDraft(id) {
|
|
60
|
-
const target = targetFromKey(id);
|
|
61
|
-
return target ? readDraft(id, target) : null;
|
|
62
|
-
}
|
|
63
152
|
export function getDraftForCard(cardId) {
|
|
64
153
|
const id = draftIdForCard(cardId);
|
|
65
|
-
return id ? getDraft(id) : null;
|
|
154
|
+
return id ? drafts.getDraft(id) : null;
|
|
66
155
|
}
|
|
67
156
|
export function getDraftContentsForCard(cardId) {
|
|
68
|
-
|
|
69
|
-
return draft ? { changes: draft.contents.changes, structuralChanges: draft.contents.structuralChanges } : null;
|
|
70
|
-
}
|
|
71
|
-
export function persistDrafts() {
|
|
72
|
-
if (!projectId || !persistent || !canWriteWorkspace())
|
|
73
|
-
return;
|
|
74
|
-
const sketches = getSketchStoreSnapshot();
|
|
75
|
-
const liveSketches = new Set(sketches.documents.map((document) => document.id));
|
|
76
|
-
const value = {
|
|
77
|
-
schemaVersion: 2, projectId,
|
|
78
|
-
drafts: listDraftIds().flatMap((id) => {
|
|
79
|
-
const target = targetFromKey(id);
|
|
80
|
-
const workspace = getDraftChanges(id);
|
|
81
|
-
if (!target || workspace.changes.length + workspace.structuralChanges.length === 0)
|
|
82
|
-
return [];
|
|
83
|
-
return [{
|
|
84
|
-
target,
|
|
85
|
-
revision: workspace.revision,
|
|
86
|
-
contents: {
|
|
87
|
-
changes: workspace.changes.flatMap((change) => {
|
|
88
|
-
const serialized = serializeChange(change);
|
|
89
|
-
return serialized ? [serialized] : [];
|
|
90
|
-
}),
|
|
91
|
-
structuralChanges: workspace.structuralChanges,
|
|
92
|
-
},
|
|
93
|
-
}];
|
|
94
|
-
}),
|
|
95
|
-
sketchOwners: Object.fromEntries([...sketchOwners].filter(([id]) => !sketches.ready || liveSketches.has(id))),
|
|
96
|
-
};
|
|
97
|
-
try {
|
|
98
|
-
localStorage.setItem(storageKey(), JSON.stringify(value));
|
|
99
|
-
}
|
|
100
|
-
catch {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function validPersisted(value) {
|
|
105
|
-
if (!value || typeof value !== "object")
|
|
106
|
-
return false;
|
|
107
|
-
const candidate = value;
|
|
108
|
-
if (candidate.schemaVersion !== 2 || candidate.projectId !== projectId || !Array.isArray(candidate.drafts))
|
|
109
|
-
return false;
|
|
110
|
-
const targets = new Set();
|
|
111
|
-
for (const draft of candidate.drafts) {
|
|
112
|
-
if (!draft || !isDraftTarget(draft.target) || targets.has(targetKey(draft.target))
|
|
113
|
-
|| !Number.isSafeInteger(draft.revision) || draft.revision < 1
|
|
114
|
-
|| !draft.contents || !Array.isArray(draft.contents.changes) || !draft.contents.changes.every(isSerializableChange)
|
|
115
|
-
|| !Array.isArray(draft.contents.structuralChanges) || !draft.contents.structuralChanges.every(isStructuralChange))
|
|
116
|
-
return false;
|
|
117
|
-
const textIds = draft.contents.changes.filter((change) => change.kind === "text-content").map((change) => "id" in change ? change.id : "");
|
|
118
|
-
if (new Set(textIds).size !== textIds.length)
|
|
119
|
-
return false;
|
|
120
|
-
targets.add(targetKey(draft.target));
|
|
121
|
-
}
|
|
122
|
-
return !!candidate.sketchOwners && typeof candidate.sketchOwners === "object" && !Array.isArray(candidate.sketchOwners)
|
|
123
|
-
&& Object.values(candidate.sketchOwners).every((id) => typeof id === "string" && targetFromKey(id) !== null);
|
|
124
|
-
}
|
|
125
|
-
/** Replaces every in-memory draft with the stored drafts, so a tab that takes over never writes stale edits. */
|
|
126
|
-
export function loadDrafts(nextProjectId, options = {}) {
|
|
127
|
-
projectId = nextProjectId;
|
|
128
|
-
persistent = options.persistent ?? true;
|
|
129
|
-
sketchOwners.clear();
|
|
130
|
-
resetDraftChanges();
|
|
131
|
-
try {
|
|
132
|
-
const raw = persistent ? localStorage.getItem(storageKey()) : null;
|
|
133
|
-
const stored = raw ? JSON.parse(raw) : null;
|
|
134
|
-
if (validPersisted(stored)) {
|
|
135
|
-
for (const draft of stored.drafts) {
|
|
136
|
-
restoreDraftChanges(targetKey(draft.target), { changes: draft.contents.changes.map(deserializeChange), structuralChanges: draft.contents.structuralChanges }, draft.revision);
|
|
137
|
-
}
|
|
138
|
-
for (const [sketchId, draftId] of Object.entries(stored.sketchOwners))
|
|
139
|
-
sketchOwners.set(sketchId, draftId);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
catch {
|
|
143
|
-
resetDraftChanges();
|
|
144
|
-
sketchOwners.clear();
|
|
145
|
-
}
|
|
146
|
-
publish();
|
|
147
|
-
refreshDraftPreview();
|
|
157
|
+
return getDraftForCard(cardId)?.contents ?? null;
|
|
148
158
|
}
|
|
149
159
|
export function activateDraftForCard(cardId) {
|
|
150
160
|
const draftId = draftIdForCard(cardId);
|
|
@@ -152,10 +162,7 @@ export function activateDraftForCard(cardId) {
|
|
|
152
162
|
activateDraft(draftId, cardId);
|
|
153
163
|
}
|
|
154
164
|
export function activateDraft(draftId, preferredCardId) {
|
|
155
|
-
|
|
156
|
-
setActiveDraft(draftId, () => revealDraft(draftId, preferredCardId));
|
|
157
|
-
if (previous !== draftId)
|
|
158
|
-
refreshDraftPreview();
|
|
165
|
+
drafts.activate(draftId, () => revealDraft(draftId, preferredCardId));
|
|
159
166
|
}
|
|
160
167
|
function revealDraft(draftId, preferredCardId) {
|
|
161
168
|
const cards = getCanvasCards();
|
|
@@ -177,55 +184,22 @@ function revealDraft(draftId, preferredCardId) {
|
|
|
177
184
|
}
|
|
178
185
|
export function clearSavedIterationDraft(cardId, expectedRevision) {
|
|
179
186
|
const draftId = draftIdForCard(cardId);
|
|
180
|
-
return !!draftId &&
|
|
187
|
+
return !!draftId && drafts.clear(draftId, expectedRevision);
|
|
181
188
|
}
|
|
182
189
|
/** Returns the first preferred frame that exists, then the first frame. */
|
|
183
190
|
export function getEditableCardId(...preferredCardIds) {
|
|
184
191
|
const cards = getCanvasCards();
|
|
185
192
|
return preferredCardIds.find((id) => !!id && cards.some((card) => card.id === id)) ?? cards[0]?.id ?? null;
|
|
186
193
|
}
|
|
194
|
+
export function sketchOwner(document) {
|
|
195
|
+
return drafts.sketchOwner(document);
|
|
196
|
+
}
|
|
187
197
|
export function assignSketchToDraft(draftId, sketchId) {
|
|
188
|
-
|
|
189
|
-
return;
|
|
190
|
-
sketchOwners.set(sketchId, draftId);
|
|
191
|
-
publish();
|
|
198
|
+
drafts.assignSketch(draftId, sketchId);
|
|
192
199
|
}
|
|
193
200
|
export function sketchBelongsToCard(document, cardId) {
|
|
194
|
-
if (!projectId || !cardId)
|
|
201
|
+
if (!drafts.getSnapshot().projectId || !cardId)
|
|
195
202
|
return true;
|
|
196
203
|
const draftId = draftIdForCard(cardId);
|
|
197
|
-
return !!draftId && sketchOwner(document) === draftId;
|
|
198
|
-
}
|
|
199
|
-
export function subscribeDrafts(listener) {
|
|
200
|
-
listeners.add(listener);
|
|
201
|
-
return () => listeners.delete(listener);
|
|
202
|
-
}
|
|
203
|
-
export function getDraftsSnapshot() {
|
|
204
|
-
if (!snapshot) {
|
|
205
|
-
const ids = new Set([...listDraftIds(), ...getSketchStoreSnapshot().documents.flatMap((document) => sketchOwner(document) ?? [])]);
|
|
206
|
-
snapshot = { projectId, drafts: [...ids].flatMap((id) => getDraft(id) ?? []) };
|
|
207
|
-
}
|
|
208
|
-
return snapshot;
|
|
209
|
-
}
|
|
210
|
-
export function useDrafts() { return useSyncExternalStore(subscribeDrafts, getDraftsSnapshot, getDraftsSnapshot); }
|
|
211
|
-
/** Discards stored and in-memory drafts for the current project. */
|
|
212
|
-
export function clearDrafts() {
|
|
213
|
-
if (projectId && persistent && canWriteWorkspace()) {
|
|
214
|
-
try {
|
|
215
|
-
localStorage.removeItem(storageKey());
|
|
216
|
-
}
|
|
217
|
-
catch {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
sketchOwners.clear();
|
|
222
|
-
resetDraftChanges();
|
|
223
|
-
publish();
|
|
224
|
-
}
|
|
225
|
-
export function resetDrafts() {
|
|
226
|
-
projectId = "";
|
|
227
|
-
persistent = true;
|
|
228
|
-
sketchOwners.clear();
|
|
229
|
-
resetDraftChanges();
|
|
230
|
-
publish();
|
|
204
|
+
return !!draftId && drafts.sketchOwner(document) === draftId;
|
|
231
205
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
export { bootstrapNudgeUi, mountInspector, unmountInspector } from "./boot.js";
|
|
1
2
|
export { resolveNudgeUiClientEntry } from "../transport/editor.js";
|
|
2
|
-
export
|
|
3
|
-
export declare function mountInspector(host: HTMLElement): void;
|
|
4
|
-
export declare function unmountInspector(): void;
|
|
5
|
-
export { toggleInspector, setInspectorOpen } from "./shell/InspectorShell.js";
|
|
3
|
+
export { toggleInspector, setInspectorOpen } from "./shell/openStore.js";
|
|
6
4
|
export { InspectorShell } from "./shell/InspectorShell.js";
|
|
7
5
|
export { detectFramework } from "./prompt/detectFramework.js";
|
|
8
6
|
export { installStaticHtmlRuntimeIdentity, isRuntimeGeneratedSource, RUNTIME_ELEMENT_CID_PREFIX, RUNTIME_UNKNOWN_SOURCE_PREFIX, } from "./runtime/staticHtmlRuntimeIdentity.js";
|
package/dist/inspector/index.js
CHANGED
|
@@ -1,268 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { createElement } from "react";
|
|
3
|
-
import { createRoot } from "react-dom/client";
|
|
4
|
-
import { InspectorShell, toggleInspector, setInspectorOpen } from "./shell/InspectorShell.js";
|
|
5
|
-
import { setSelectedElement } from "./selection/selectionStore.js";
|
|
6
|
-
import { removeManagedSheet } from "./projection/managedStylesheet.js";
|
|
7
|
-
import { isInspectorToggleShortcut, isOriginalPreviewShortcut, SEND_PROMPT_HOTKEY_EVENT, } from "./shell/shortcuts.js";
|
|
8
|
-
import { isCanvasRenderer } from "./canvas/roleDetection.js";
|
|
9
|
-
import { isKeyboardShortcutMessage } from "./canvas/frameProtocol.js";
|
|
10
|
-
import { subscribeCanvasRendererMessages } from "./canvas/rendererMessageRouter.js";
|
|
11
|
-
import { bootstrapRenderer } from "./canvas/rendererBootstrap.js";
|
|
12
|
-
import { setRestoreCount, } from "./canvas/sessionStore.js";
|
|
13
|
-
import { getChangesList } from "./changes/changesLog.js";
|
|
14
|
-
import { acquireLease, enableWriteGuard, hasWriteLease, subscribeOwnership, } from "./canvas/workspaceLease.js";
|
|
15
|
-
import { cancelStaleDetection, startStaleDetection } from "./canvas/staleChangeDetector.js";
|
|
16
|
-
import { LockedWorkspaceNotice } from "./canvas/LockedWorkspaceNotice.js";
|
|
17
|
-
import { AppShell } from "./shell/AppShell.js";
|
|
18
|
-
import { installInspectionBridge } from "./inspection/bridge.js";
|
|
19
|
-
import { releaseDocumentProjection, getStructuralChanges } from "./projection/structuralProjection.js";
|
|
20
|
-
import { cancelInlineTextEdit } from "./inline-text/inlineTextEditor.js";
|
|
21
|
-
import { configureNudgeUiRuntime, getNudgeUiRuntimeConfig, isDemoRuntime } from "./runtime/runtimeConfig.js";
|
|
22
|
-
import { setCanvasMode } from "./canvas/viewStore.js";
|
|
23
|
-
import { isNudgeUiDev, setNudgeUiHostDevFlag } from "./runtime/devFlag.js";
|
|
24
|
-
import { clearClipboardHandoff, } from "./prompt/clipboardHandoff.js";
|
|
25
|
-
import { createWorkspace, InspectorSessionProvider, } from "./session/index.js";
|
|
26
|
-
import { clearSketchClipboardHandoff } from "./sketch/handoff.js";
|
|
27
|
-
import { cancelSketchInteraction, isSketchInteractionActive } from "./sketch/interaction.js";
|
|
28
|
-
import { setOriginalPreviewActive } from "./shell/originalPreview.js";
|
|
29
|
-
import { initializeSketchStore } from "./sketch/store.js";
|
|
1
|
+
export { bootstrapNudgeUi, mountInspector, unmountInspector } from "./boot.js";
|
|
30
2
|
export { resolveNudgeUiClientEntry } from "../transport/editor.js";
|
|
31
|
-
|
|
32
|
-
let reactRoot = null;
|
|
33
|
-
let lockedRoot = null;
|
|
34
|
-
const workspace = createWorkspace();
|
|
35
|
-
let inspectorSession = null;
|
|
36
|
-
let rendererBootstrapHandle = null;
|
|
37
|
-
let workspaceController = null;
|
|
38
|
-
let unsubscribeOwnership = null;
|
|
39
|
-
let removeInspectionBridge = null;
|
|
40
|
-
let keyboardPeekHeld = false;
|
|
41
|
-
function onKeydown(e) {
|
|
42
|
-
if (isSketchInteractionActive())
|
|
43
|
-
return;
|
|
44
|
-
if (isInspectorToggleShortcut(e)) {
|
|
45
|
-
toggleInspector();
|
|
46
|
-
e.preventDefault();
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (isOriginalPreviewShortcut(e)) {
|
|
50
|
-
keyboardPeekHeld = true;
|
|
51
|
-
setOriginalPreviewActive(true);
|
|
52
|
-
e.preventDefault();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function onKeyup(e) {
|
|
56
|
-
// Release only a keyboard-started peek so a button-held preview survives
|
|
57
|
-
// unrelated Backslash keyups (e.g. the panel-toggle shortcuts pressed
|
|
58
|
-
// mid-hold). A guarded keydown never sets the flag, so this stays a no-op
|
|
59
|
-
// for keyups without a matching hold.
|
|
60
|
-
if (e.code === "Backslash" && keyboardPeekHeld) {
|
|
61
|
-
keyboardPeekHeld = false;
|
|
62
|
-
setOriginalPreviewActive(false);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function onRendererKeyboardShortcut(message, identity) {
|
|
66
|
-
if (!isKeyboardShortcutMessage(message, identity))
|
|
67
|
-
return;
|
|
68
|
-
if (message.code === "KeyS" && message.phase === "keydown") {
|
|
69
|
-
window.dispatchEvent(new Event(SEND_PROMPT_HOTKEY_EVENT));
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (message.code !== "Backslash")
|
|
73
|
-
return;
|
|
74
|
-
if (message.phase === "keydown") {
|
|
75
|
-
keyboardPeekHeld = true;
|
|
76
|
-
setOriginalPreviewActive(true);
|
|
77
|
-
}
|
|
78
|
-
else if (keyboardPeekHeld) {
|
|
79
|
-
keyboardPeekHeld = false;
|
|
80
|
-
setOriginalPreviewActive(false);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function disposeInspectorSession() {
|
|
84
|
-
const session = inspectorSession;
|
|
85
|
-
inspectorSession = null;
|
|
86
|
-
session?.dispose();
|
|
87
|
-
}
|
|
88
|
-
export function bootstrapNudgeUi(inspectorHost) {
|
|
89
|
-
const runtimeConfig = getNudgeUiRuntimeConfig();
|
|
90
|
-
const explicitDemo = isDemoRuntime();
|
|
91
|
-
if (!isNudgeUiDev() && !explicitDemo)
|
|
92
|
-
return;
|
|
93
|
-
if (explicitDemo) {
|
|
94
|
-
rendererBootstrapHandle?.teardown();
|
|
95
|
-
rendererBootstrapHandle = null;
|
|
96
|
-
// ADR-0014: only the configured demo runtime opens the shared dev gate
|
|
97
|
-
// for its own document. The bundle mode name alone must never flip it,
|
|
98
|
-
// so every build without both opt-ins stays governed by ADR-0002.
|
|
99
|
-
setNudgeUiHostDevFlag(true);
|
|
100
|
-
if (runtimeConfig.capabilities.canvas && isCanvasRenderer()) {
|
|
101
|
-
rendererBootstrapHandle = bootstrapRenderer() ?? null;
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
// The public demo shares the iframe editor while keeping the write lease,
|
|
105
|
-
// persistence, and agent bridge disabled.
|
|
106
|
-
setCanvasMode("canvas");
|
|
107
|
-
workspaceController?.dispose();
|
|
108
|
-
workspaceController = startWorkspaceController();
|
|
109
|
-
mountInspector(inspectorHost);
|
|
110
|
-
setInspectorOpen(false);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
if (!runtimeConfig.capabilities.canvas) {
|
|
114
|
-
// A project can be reopened with a runtime that does not expose Canvas.
|
|
115
|
-
// Clear any stale in-memory mode before mounting the static inspector.
|
|
116
|
-
setCanvasMode("inspect");
|
|
117
|
-
}
|
|
118
|
-
rendererBootstrapHandle?.teardown();
|
|
119
|
-
rendererBootstrapHandle = null;
|
|
120
|
-
removeInspectionBridge?.();
|
|
121
|
-
removeInspectionBridge = installInspectionBridge();
|
|
122
|
-
if (getNudgeUiRuntimeConfig().capabilities.canvas && isCanvasRenderer()) {
|
|
123
|
-
rendererBootstrapHandle = bootstrapRenderer() ?? null;
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
enableWriteGuard();
|
|
127
|
-
const leaseGranted = acquireLease();
|
|
128
|
-
if (!leaseGranted) {
|
|
129
|
-
mountLockedNotice(inspectorHost);
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
startController(inspectorHost);
|
|
133
|
-
}
|
|
134
|
-
function startController(inspectorHost) {
|
|
135
|
-
if (!hasWriteLease()) {
|
|
136
|
-
mountLockedNotice(inspectorHost);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
if (lockedRoot) {
|
|
140
|
-
lockedRoot.unmount();
|
|
141
|
-
lockedRoot = null;
|
|
142
|
-
}
|
|
143
|
-
void initializeSketchStore(getNudgeUiRuntimeConfig().projectId).catch(() => undefined);
|
|
144
|
-
unsubscribeOwnership?.();
|
|
145
|
-
unsubscribeOwnership = subscribeOwnership((hasLease) => {
|
|
146
|
-
if (!hasLease) {
|
|
147
|
-
workspaceController?.dispose();
|
|
148
|
-
workspaceController = null;
|
|
149
|
-
mountLockedNotice(inspectorHost);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
workspaceController?.dispose();
|
|
153
|
-
const result = startWorkspaceController();
|
|
154
|
-
workspaceController = result;
|
|
155
|
-
if (result.restored) {
|
|
156
|
-
setRestoreCount(getChangesList().length + getStructuralChanges().length);
|
|
157
|
-
const restored = getChangesList();
|
|
158
|
-
if (restored.length > 0) {
|
|
159
|
-
startStaleDetection(restored);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
if (getNudgeUiRuntimeConfig().capabilities.canvas) {
|
|
163
|
-
// Normal controllers always host the iframe workspace. Hydration runs
|
|
164
|
-
// first so this mode change cannot discard cards, camera, or edits.
|
|
165
|
-
setCanvasMode("canvas");
|
|
166
|
-
}
|
|
167
|
-
mountInspector(inspectorHost);
|
|
168
|
-
}
|
|
169
|
-
function mountLockedNotice(host) {
|
|
170
|
-
if (reactRoot) {
|
|
171
|
-
reactRoot.unmount();
|
|
172
|
-
reactRoot = null;
|
|
173
|
-
}
|
|
174
|
-
try {
|
|
175
|
-
disposeInspectorSession();
|
|
176
|
-
}
|
|
177
|
-
finally {
|
|
178
|
-
cancelStaleDetection();
|
|
179
|
-
setInspectorOpen(false);
|
|
180
|
-
cancelInlineTextEdit();
|
|
181
|
-
cancelSketchInteraction();
|
|
182
|
-
clearSketchClipboardHandoff();
|
|
183
|
-
setSelectedElement(null);
|
|
184
|
-
removeManagedSheet();
|
|
185
|
-
releaseDocumentProjection(document);
|
|
186
|
-
hostElement = null;
|
|
187
|
-
unsubscribeOwnership?.();
|
|
188
|
-
unsubscribeOwnership = null;
|
|
189
|
-
}
|
|
190
|
-
const shadow = host.shadowRoot ?? host.attachShadow({ mode: "open" });
|
|
191
|
-
if (!lockedRoot) {
|
|
192
|
-
lockedRoot = createRoot(shadow);
|
|
193
|
-
}
|
|
194
|
-
lockedRoot.render(createElement(LockedWorkspaceNotice, {
|
|
195
|
-
onTakeover: () => startController(host),
|
|
196
|
-
}));
|
|
197
|
-
}
|
|
198
|
-
export function mountInspector(host) {
|
|
199
|
-
const demo = isDemoRuntime();
|
|
200
|
-
if (!demo && !hasWriteLease())
|
|
201
|
-
return;
|
|
202
|
-
const runtimeConfig = getNudgeUiRuntimeConfig();
|
|
203
|
-
if (runtimeConfig.capabilities.domNavigation !== true) {
|
|
204
|
-
configureNudgeUiRuntime({
|
|
205
|
-
...runtimeConfig,
|
|
206
|
-
capabilities: { ...runtimeConfig.capabilities, domNavigation: true },
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
if (lockedRoot) {
|
|
210
|
-
lockedRoot.unmount();
|
|
211
|
-
lockedRoot = null;
|
|
212
|
-
}
|
|
213
|
-
if (!hostElement)
|
|
214
|
-
hostElement = host;
|
|
215
|
-
const shadow = host.shadowRoot ?? host.attachShadow({ mode: "open" });
|
|
216
|
-
if (!reactRoot) {
|
|
217
|
-
reactRoot = createRoot(shadow);
|
|
218
|
-
inspectorSession = workspace.createInspectorSession(host);
|
|
219
|
-
inspectorSession.registerCleanup(() => window.removeEventListener("keydown", onKeydown));
|
|
220
|
-
inspectorSession.registerCleanup(() => window.removeEventListener("keyup", onKeyup));
|
|
221
|
-
inspectorSession.registerCleanup(subscribeCanvasRendererMessages(({ identity, message }) => {
|
|
222
|
-
onRendererKeyboardShortcut(message, identity);
|
|
223
|
-
}));
|
|
224
|
-
reactRoot.render(createElement(InspectorSessionProvider, { inspector: inspectorSession, documentSession: null }, createElement(AppShell)));
|
|
225
|
-
window.addEventListener("keydown", onKeydown);
|
|
226
|
-
window.addEventListener("keyup", onKeyup);
|
|
227
|
-
}
|
|
228
|
-
setInspectorOpen(true);
|
|
229
|
-
}
|
|
230
|
-
export function unmountInspector() {
|
|
231
|
-
rendererBootstrapHandle?.teardown();
|
|
232
|
-
rendererBootstrapHandle = null;
|
|
233
|
-
workspaceController?.dispose();
|
|
234
|
-
workspaceController = null;
|
|
235
|
-
unsubscribeOwnership?.();
|
|
236
|
-
unsubscribeOwnership = null;
|
|
237
|
-
if (lockedRoot) {
|
|
238
|
-
lockedRoot.unmount();
|
|
239
|
-
lockedRoot = null;
|
|
240
|
-
}
|
|
241
|
-
cancelStaleDetection();
|
|
242
|
-
cancelInlineTextEdit();
|
|
243
|
-
cancelSketchInteraction();
|
|
244
|
-
setSelectedElement(null);
|
|
245
|
-
if (reactRoot) {
|
|
246
|
-
reactRoot.unmount();
|
|
247
|
-
reactRoot = null;
|
|
248
|
-
}
|
|
249
|
-
try {
|
|
250
|
-
disposeInspectorSession();
|
|
251
|
-
}
|
|
252
|
-
finally {
|
|
253
|
-
// Document-session cleanup already releases host projection when a
|
|
254
|
-
// session exists; release directly as well so projection applied outside
|
|
255
|
-
// a session (gestures, workspace projection) cannot leak across unmount.
|
|
256
|
-
releaseDocumentProjection(document);
|
|
257
|
-
clearClipboardHandoff();
|
|
258
|
-
clearSketchClipboardHandoff();
|
|
259
|
-
removeManagedSheet();
|
|
260
|
-
removeInspectionBridge?.();
|
|
261
|
-
removeInspectionBridge = null;
|
|
262
|
-
hostElement = null;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
export { toggleInspector, setInspectorOpen } from "./shell/InspectorShell.js";
|
|
3
|
+
export { toggleInspector, setInspectorOpen } from "./shell/openStore.js";
|
|
266
4
|
export { InspectorShell } from "./shell/InspectorShell.js";
|
|
267
5
|
export { detectFramework } from "./prompt/detectFramework.js";
|
|
268
6
|
export { installStaticHtmlRuntimeIdentity, isRuntimeGeneratedSource, RUNTIME_ELEMENT_CID_PREFIX, RUNTIME_UNKNOWN_SOURCE_PREFIX, } from "./runtime/staticHtmlRuntimeIdentity.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type TextBindingChoice, type TextEditBinding, type TextEditRejection, type TextEditRejectionReason } from "../componentSemantics/textBinding.js";
|
|
2
2
|
import type { ChangeRecord } from "../changes/types.js";
|
|
3
|
-
import type { TextProjectionScope } from "
|
|
3
|
+
import type { TextProjectionScope } from "../changes/editModel.js";
|
|
4
4
|
export type { TextEditBinding, TextEditRejection } from "../componentSemantics/textBinding.js";
|
|
5
5
|
export type { TextBindingCandidate } from "../componentSemantics/textBinding.js";
|
|
6
6
|
export interface InlineTextSession {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { canEditDraft } from "../
|
|
1
|
+
import { appendChange, canEditDraft } from "../drafts/store.js";
|
|
2
2
|
import { useSyncExternalStore } from "react";
|
|
3
|
-
import { appendChange } from "../changes/changesLog.js";
|
|
4
3
|
import { registerInlineTextClearHandler } from "./inlineTextLifecycle.js";
|
|
5
4
|
import { isNudgeUiDev } from "../runtime/devFlag.js";
|
|
6
5
|
import { initialTextEditDecision, chooseTextEditBinding, getTextEditScopeChoices, getTextEditBinding, prepareTextEditChange, } from "./textEditChange.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TextBindingCandidate, TextEditBinding } from "../componentSemantics/textBinding.js";
|
|
2
2
|
import type { ChangeRecord } from "../changes/types.js";
|
|
3
|
-
import type { TextProjectionScope, TextProjectionTarget } from "
|
|
3
|
+
import type { TextProjectionScope, TextProjectionTarget } from "../changes/editModel.js";
|
|
4
4
|
/** Binding and scope decisions, independent of native editor lifecycle state. */
|
|
5
5
|
export interface TextEditDecision {
|
|
6
6
|
bindingIndex: number | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TokenDefinition, TokenEntry } from "../../css/model/index.js";
|
|
2
|
-
import { getChangesList, getPendingRules } from "../
|
|
2
|
+
import { getChangesList, getPendingRules } from "../drafts/store.js";
|
|
3
3
|
import type { InspectorProjection } from "../spacing/projection.js";
|
|
4
4
|
import type { ResolvedProperty } from "../../css/model/index.js";
|
|
5
5
|
export declare const NUDGE_UI_INSPECTION_VERSION: 1;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getChangesList, getPendingRules
|
|
1
|
+
import { getChangesList, getPendingRules } from "../drafts/store.js";
|
|
2
|
+
import { isPreviewableChange } from "../changes/types.js";
|
|
2
3
|
import { changeKey } from "../changes/model.js";
|
|
3
4
|
import { getAnyPreviewDiagnostic } from "../changes/previewDiagnostics.js";
|
|
4
5
|
import { detectFramework } from "../prompt/detectFramework.js";
|