nudge-ui 0.2.0 → 0.2.1
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/bin/nudge-ui.mjs +3 -1
- package/dist/cli/agentCommand.d.ts +8 -0
- package/dist/cli/agentCommand.js +59 -0
- package/dist/client.mjs +872 -12
- package/dist/hosts/astro/astroRuntimeConfig.js +1 -1
- package/dist/hosts/astro/clientTransport.js +60 -11
- package/dist/hosts/next/sidecar.d.ts +4 -0
- package/dist/hosts/next/sidecar.js +49 -6
- package/dist/hosts/next/wrapper.js +30 -2
- package/dist/hosts/projectBridge.d.ts +20 -0
- package/dist/hosts/projectBridge.js +97 -0
- package/dist/hosts/static/cli.d.ts +1 -1
- package/dist/hosts/static/cli.js +6 -1
- package/dist/hosts/static/manifest.d.ts +1 -1
- package/dist/hosts/static/manifest.js +1 -1
- package/dist/hosts/static/server.js +44 -3
- package/dist/hosts/vite/vite.d.ts +5 -1
- package/dist/hosts/vite/vite.js +78 -14
- package/dist/inspector/agent/McpConnectionDialog.d.ts +2 -2
- package/dist/inspector/agent/McpConnectionDialog.js +11 -35
- package/dist/inspector/agent/client.d.ts +10 -3
- package/dist/inspector/agent/client.js +80 -9
- package/dist/inspector/agent/connectionStatus.js +3 -3
- package/dist/inspector/agent/httpTransport.d.ts +2 -0
- package/dist/inspector/agent/httpTransport.js +37 -17
- package/dist/inspector/agent/protocol.d.ts +8 -3
- package/dist/inspector/agent/protocol.js +1 -1
- package/dist/inspector/agent/verification.d.ts +1 -1
- package/dist/inspector/agent/verification.js +69 -12
- package/dist/inspector/canvas/CanvasCard.d.ts +5 -3
- package/dist/inspector/canvas/CanvasCard.js +181 -91
- package/dist/inspector/canvas/CanvasElementOverlay.js +246 -52
- package/dist/inspector/canvas/CanvasToolbar.d.ts +12 -0
- package/dist/inspector/canvas/CanvasToolbar.js +24 -0
- package/dist/inspector/canvas/CanvasWorkspace.d.ts +4 -1
- package/dist/inspector/canvas/CanvasWorkspace.js +392 -73
- package/dist/inspector/canvas/activeCanvasDocument.d.ts +5 -0
- package/dist/inspector/canvas/activeCanvasDocument.js +23 -0
- package/dist/inspector/canvas/canvasResize.d.ts +30 -0
- package/dist/inspector/canvas/canvasResize.js +52 -0
- package/dist/inspector/canvas/canvasStore.d.ts +30 -6
- package/dist/inspector/canvas/canvasStore.js +128 -61
- package/dist/inspector/canvas/frameProtocol.d.ts +69 -5
- package/dist/inspector/canvas/frameProtocol.js +56 -2
- package/dist/inspector/canvas/keyboardShortcuts.d.ts +3 -0
- package/dist/inspector/canvas/keyboardShortcuts.js +14 -0
- package/dist/inspector/canvas/projection.d.ts +7 -0
- package/dist/inspector/canvas/projection.js +118 -25
- package/dist/inspector/canvas/rendererBootstrap.js +29 -29
- package/dist/inspector/canvas/rendererElementSelector.js +341 -30
- package/dist/inspector/canvas/rendererMessageRouter.d.ts +11 -0
- package/dist/inspector/canvas/rendererMessageRouter.js +43 -0
- package/dist/inspector/canvas/rendererSelectionProxy.js +6 -2
- package/dist/inspector/canvas/sessionStore.d.ts +1 -0
- package/dist/inspector/canvas/sessionStore.js +12 -4
- package/dist/inspector/canvas/staleChangeDetector.js +16 -14
- package/dist/inspector/changes/changesLog.js +31 -1
- package/dist/inspector/changes/managedStyleProjection.d.ts +1 -1
- package/dist/inspector/changes/managedStyleProjection.js +3 -3
- package/dist/inspector/changes/structuralTypes.d.ts +4 -0
- package/dist/inspector/clientManifest.d.ts +5 -0
- package/dist/inspector/clientManifest.js +11 -0
- package/dist/inspector/componentSemantics/adapterRegistry.js +4 -3
- package/dist/inspector/componentSemantics/runtimeBridge.d.ts +2 -2
- package/dist/inspector/componentSemantics/runtimeBridge.js +16 -3
- package/dist/inspector/index.d.ts +2 -0
- package/dist/inspector/index.js +74 -24
- package/dist/inspector/inline-text/inlineTextDiagnostics.d.ts +10 -0
- package/dist/inspector/inline-text/inlineTextDiagnostics.js +65 -0
- package/dist/inspector/inline-text/inlineTextEditor.d.ts +3 -5
- package/dist/inspector/inline-text/inlineTextEditor.js +74 -206
- package/dist/inspector/inline-text/inlineTextFeedback.d.ts +5 -0
- package/dist/inspector/inline-text/inlineTextFeedback.js +27 -0
- package/dist/inspector/inline-text/inlineTextLifecycle.js +2 -0
- package/dist/inspector/inline-text/textEditChange.d.ts +14 -0
- package/dist/inspector/inline-text/textEditChange.js +165 -0
- package/dist/inspector/inspection/selectionProperty.d.ts +1 -0
- package/dist/inspector/inspection/selectionProperty.js +1 -0
- package/dist/inspector/overlay/selectedGeometry.js +21 -2
- package/dist/inspector/overlay/spacingGestures.d.ts +45 -0
- package/dist/inspector/overlay/spacingGestures.js +353 -0
- package/dist/inspector/overlay/structuralGestures.d.ts +2 -2
- package/dist/inspector/overlay/structuralGestures.js +12 -10
- package/dist/inspector/projection/managedStylesheet.js +4 -1
- package/dist/inspector/projection/renderedInstance.d.ts +2 -0
- package/dist/inspector/projection/renderedInstance.js +5 -1
- package/dist/inspector/projection/structuralProjection.d.ts +2 -0
- package/dist/inspector/projection/structuralProjection.js +85 -1
- package/dist/inspector/projection/structuralProjectionBoundary.js +17 -1
- package/dist/inspector/projection/textProjection.d.ts +2 -0
- package/dist/inspector/projection/textProjection.js +10 -4
- package/dist/inspector/prompt/clipboardHandoff.d.ts +1 -1
- package/dist/inspector/prompt/clipboardHandoff.js +3 -3
- package/dist/inspector/prompt/generatePrompt.d.ts +2 -1
- package/dist/inspector/prompt/generatePrompt.js +19 -2
- package/dist/inspector/runtime/editorShell.d.ts +2 -0
- package/dist/inspector/runtime/editorShell.js +4 -0
- package/dist/inspector/runtime/runtimeConfig.d.ts +4 -0
- package/dist/inspector/runtime/runtimeConfig.js +4 -0
- package/dist/inspector/selection/selectionStore.js +2 -0
- package/dist/inspector/settings/SettingsDialog.js +10 -0
- package/dist/inspector/shell/AppShell.js +5 -1
- package/dist/inspector/shell/ChangesLog.js +8 -4
- package/dist/inspector/shell/CopyPromptButton.js +95 -19
- package/dist/inspector/shell/EmptyState.js +1 -1
- package/dist/inspector/shell/InspectorShell.d.ts +0 -1
- package/dist/inspector/shell/InspectorShell.js +37 -38
- package/dist/inspector/shell/PeekOriginalButton.d.ts +7 -0
- package/dist/inspector/shell/PeekOriginalButton.js +57 -0
- package/dist/inspector/shell/PeekOriginalIcon.d.ts +7 -0
- package/dist/inspector/shell/PeekOriginalIcon.js +9 -0
- package/dist/inspector/shell/originalPreview.d.ts +9 -0
- package/dist/inspector/shell/originalPreview.js +61 -0
- package/dist/inspector/shell/shortcuts.d.ts +3 -0
- package/dist/inspector/shell/shortcuts.js +15 -0
- package/dist/inspector/sketch/SketchChanges.d.ts +2 -0
- package/dist/inspector/sketch/SketchChanges.js +72 -0
- package/dist/inspector/sketch/SketchEditor.d.ts +21 -0
- package/dist/inspector/sketch/SketchEditor.js +402 -0
- package/dist/inspector/sketch/SketchEntryButton.d.ts +4 -0
- package/dist/inspector/sketch/SketchEntryButton.js +11 -0
- package/dist/inspector/sketch/SketchFrameOverlay.d.ts +11 -0
- package/dist/inspector/sketch/SketchFrameOverlay.js +119 -0
- package/dist/inspector/sketch/SketchLayersPanel.d.ts +2 -0
- package/dist/inspector/sketch/SketchLayersPanel.js +63 -0
- package/dist/inspector/sketch/SketchOverlay.d.ts +19 -0
- package/dist/inspector/sketch/SketchOverlay.js +420 -0
- package/dist/inspector/sketch/SketchPromptPanel.d.ts +15 -0
- package/dist/inspector/sketch/SketchPromptPanel.js +18 -0
- package/dist/inspector/sketch/SketchWorkspace.d.ts +13 -0
- package/dist/inspector/sketch/SketchWorkspace.js +152 -0
- package/dist/inspector/sketch/capture.d.ts +55 -0
- package/dist/inspector/sketch/capture.js +350 -0
- package/dist/inspector/sketch/freehand.d.ts +13 -0
- package/dist/inspector/sketch/freehand.js +64 -0
- package/dist/inspector/sketch/geometry.d.ts +17 -0
- package/dist/inspector/sketch/geometry.js +98 -0
- package/dist/inspector/sketch/handoff.d.ts +21 -0
- package/dist/inspector/sketch/handoff.js +72 -0
- package/dist/inspector/sketch/interaction.d.ts +21 -0
- package/dist/inspector/sketch/interaction.js +98 -0
- package/dist/inspector/sketch/model.d.ts +104 -0
- package/dist/inspector/sketch/model.js +282 -0
- package/dist/inspector/sketch/persistence.d.ts +21 -0
- package/dist/inspector/sketch/persistence.js +205 -0
- package/dist/inspector/sketch/raster.d.ts +22 -0
- package/dist/inspector/sketch/raster.js +203 -0
- package/dist/inspector/sketch/sketchNote.d.ts +10 -0
- package/dist/inspector/sketch/sketchNote.js +30 -0
- package/dist/inspector/sketch/store.d.ts +47 -0
- package/dist/inspector/sketch/store.js +409 -0
- package/dist/inspector/styleEditors/BorderEditor.js +15 -19
- package/dist/inspector/styleEditors/BorderRadiusEditor.js +6 -6
- package/dist/inspector/styleEditors/BoxShadowEditor.js +12 -1
- package/dist/inspector/styleEditors/ColorPicker.js +11 -36
- package/dist/inspector/styleEditors/GapField.d.ts +3 -2
- package/dist/inspector/styleEditors/GapField.js +2 -2
- package/dist/inspector/styleEditors/GridSection.js +1 -1
- package/dist/inspector/styleEditors/LayoutSection.js +11 -8
- package/dist/inspector/styleEditors/SpacingBox.js +23 -30
- package/dist/inspector/styleEditors/layoutPreviewState.d.ts +5 -0
- package/dist/inspector/styleEditors/layoutPreviewState.js +19 -0
- package/dist/inspector/styleEditors/layoutValue.js +3 -0
- package/dist/inspector/styleEditors/nudgeValue.d.ts +11 -0
- package/dist/inspector/styleEditors/nudgeValue.js +91 -5
- package/dist/inspector/styleEditors/stylePresence.d.ts +7 -0
- package/dist/inspector/styleEditors/stylePresence.js +22 -0
- package/dist/inspector/styleEditors/textRelevance.d.ts +3 -0
- package/dist/inspector/styleEditors/textRelevance.js +35 -0
- package/dist/inspector/styleEditors/useFieldVisibility.d.ts +6 -0
- package/dist/inspector/styleEditors/useFieldVisibility.js +26 -0
- package/dist/inspector/tokens/TokenField.js +111 -7
- package/dist/inspector/tokens/editActions.d.ts +2 -0
- package/dist/inspector/tokens/editActions.js +2 -2
- package/dist/inspector/tokens/resolution/cssomCollector.d.ts +1 -1
- package/dist/inspector/tokens/resolution/cssomCollector.js +9 -5
- package/dist/inspector/tokens/resolution/ruleMatching.d.ts +40 -0
- package/dist/inspector/tokens/resolution/ruleMatching.js +423 -0
- package/dist/inspector/tokens/resolution/selectorSemantics.d.ts +19 -3
- package/dist/inspector/tokens/resolution/selectorSemantics.js +378 -4
- package/dist/inspector/tokens/resolution.d.ts +3 -26
- package/dist/inspector/tokens/resolution.js +44 -735
- package/dist/inspector/tokens/tokenAvailability.d.ts +18 -0
- package/dist/inspector/tokens/tokenAvailability.js +204 -0
- package/dist/inspector/ui/Button.d.ts +1 -1
- package/dist/inspector/ui/SideValuesField.js +2 -2
- package/dist/inspector/ui/StatusCallout.d.ts +4 -1
- package/dist/inspector/ui/StatusCallout.js +2 -2
- package/dist/inspector/ui/styles.js +13 -11
- package/dist/internal/agent-protocol.d.ts +65 -1
- package/dist/internal/agent-protocol.js +183 -3
- package/dist/nudge-ui.mjs +261 -57
- package/dist/transport/editor.d.ts +28 -0
- package/dist/transport/editor.js +132 -0
- package/dist/transport/index.d.ts +1 -0
- package/dist/transport/index.js +1 -0
- package/dist/transport/routes.d.ts +7 -0
- package/dist/transport/routes.js +7 -0
- package/package.json +3 -1
- package/dist/inspector/shell/panelLayout.d.ts +0 -2
- package/dist/inspector/shell/panelLayout.js +0 -29
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Returns the editor URL for one same-origin application location. */
|
|
2
|
+
export declare function createNudgeUiEditorUrl(applicationHref: string): string;
|
|
3
|
+
/** Resolves the application URL carried by an editor URL. */
|
|
4
|
+
export declare function readNudgeUiEditorTarget(editorHref: string): string | null;
|
|
5
|
+
type RequestHeaderValue = string | readonly string[] | undefined;
|
|
6
|
+
/** Returns whether a host request should receive the pure editor document. */
|
|
7
|
+
export declare function isNudgeUiEditorDocumentRequest(requestHref: string, method: string | undefined, headers: Record<string, RequestHeaderValue> | undefined): boolean;
|
|
8
|
+
/** Adds the persistent marker that bypasses editor entry for a plain app view. */
|
|
9
|
+
export declare function createNudgeUiDirectUrl(applicationHref: string): string;
|
|
10
|
+
/** Returns whether this application location explicitly bypasses editor entry. */
|
|
11
|
+
export declare function isNudgeUiDirectUrl(href: string): boolean;
|
|
12
|
+
/** Remembers that this browser tab was explicitly opened outside the editor. */
|
|
13
|
+
export declare function rememberNudgeUiDirectTabIntent(): void;
|
|
14
|
+
/** Returns whether this browser tab should remain outside the editor. */
|
|
15
|
+
export declare function hasNudgeUiDirectTabIntent(): boolean;
|
|
16
|
+
export type NudgeUiClientEntry = {
|
|
17
|
+
readonly kind: "bootstrap";
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: "direct";
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: "redirect";
|
|
22
|
+
readonly href: string;
|
|
23
|
+
};
|
|
24
|
+
/** Chooses the browser-client role before any runtime manifest is fetched. */
|
|
25
|
+
export declare function resolveNudgeUiClientEntry(href: string, editorDocument: boolean, canvasRenderer: boolean, directTab?: boolean): NudgeUiClientEntry;
|
|
26
|
+
/** Renders the host-neutral editor document served by every development Adapter. */
|
|
27
|
+
export declare function createNudgeUiEditorDocument(): string;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { NUDGE_UI_CLIENT_PATH, NUDGE_UI_DIRECT_QUERY_PARAM, NUDGE_UI_EDITOR_QUERY_PARAM, NUDGE_UI_EDITOR_QUERY_VALUE, NUDGE_UI_EDITOR_PATH, NUDGE_UI_MANIFEST_PATH, NUDGE_UI_MOUNT_ID, isReservedNudgeUiRoute, } from "./routes.js";
|
|
2
|
+
const TARGET_QUERY_PARAM = "url";
|
|
3
|
+
const DIRECT_TAB_SESSION_KEY = "nudge-ui:direct-tab";
|
|
4
|
+
/** Returns the editor URL for one same-origin application location. */
|
|
5
|
+
export function createNudgeUiEditorUrl(applicationHref) {
|
|
6
|
+
const applicationUrl = new URL(applicationHref);
|
|
7
|
+
assertApplicationUrl(applicationUrl);
|
|
8
|
+
const retainedSegments = applicationUrl.search.slice(1).split("&").filter((segment) => {
|
|
9
|
+
const entry = new URLSearchParams(segment);
|
|
10
|
+
return entry.get(NUDGE_UI_DIRECT_QUERY_PARAM) !== "1";
|
|
11
|
+
});
|
|
12
|
+
applicationUrl.search = retainedSegments.join("&");
|
|
13
|
+
if (applicationUrl.searchParams.getAll(NUDGE_UI_EDITOR_QUERY_PARAM).includes(NUDGE_UI_EDITOR_QUERY_VALUE)) {
|
|
14
|
+
return applicationUrl.href;
|
|
15
|
+
}
|
|
16
|
+
const hash = applicationUrl.hash;
|
|
17
|
+
applicationUrl.hash = "";
|
|
18
|
+
applicationUrl.search = `${applicationUrl.search}${applicationUrl.search ? "&" : "?"}${NUDGE_UI_EDITOR_QUERY_PARAM}=${NUDGE_UI_EDITOR_QUERY_VALUE}`;
|
|
19
|
+
applicationUrl.hash = hash;
|
|
20
|
+
return applicationUrl.href;
|
|
21
|
+
}
|
|
22
|
+
/** Resolves the application URL carried by an editor URL. */
|
|
23
|
+
export function readNudgeUiEditorTarget(editorHref) {
|
|
24
|
+
const editorUrl = new URL(editorHref);
|
|
25
|
+
if (editorUrl.pathname !== NUDGE_UI_EDITOR_PATH) {
|
|
26
|
+
if (!editorUrl.searchParams.getAll(NUDGE_UI_EDITOR_QUERY_PARAM).includes(NUDGE_UI_EDITOR_QUERY_VALUE)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const retainedSegments = editorUrl.search.slice(1).split("&").filter((segment) => {
|
|
30
|
+
const entry = new URLSearchParams(segment);
|
|
31
|
+
return entry.get(NUDGE_UI_EDITOR_QUERY_PARAM) !== NUDGE_UI_EDITOR_QUERY_VALUE;
|
|
32
|
+
});
|
|
33
|
+
editorUrl.search = retainedSegments.join("&");
|
|
34
|
+
return isApplicationUrl(editorUrl) ? editorUrl.href : null;
|
|
35
|
+
}
|
|
36
|
+
const target = editorUrl.searchParams.get(TARGET_QUERY_PARAM);
|
|
37
|
+
if (!target)
|
|
38
|
+
return null;
|
|
39
|
+
try {
|
|
40
|
+
const targetUrl = new URL(target, editorUrl.origin);
|
|
41
|
+
return targetUrl.origin === editorUrl.origin && isApplicationUrl(targetUrl)
|
|
42
|
+
? targetUrl.href
|
|
43
|
+
: null;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Returns whether a host request should receive the pure editor document. */
|
|
50
|
+
export function isNudgeUiEditorDocumentRequest(requestHref, method, headers) {
|
|
51
|
+
const normalizedMethod = (method ?? "GET").toUpperCase();
|
|
52
|
+
if (normalizedMethod !== "GET" && normalizedMethod !== "HEAD")
|
|
53
|
+
return false;
|
|
54
|
+
const url = new URL(requestHref, "http://nudge-ui.local");
|
|
55
|
+
if (url.pathname === NUDGE_UI_EDITOR_PATH)
|
|
56
|
+
return true;
|
|
57
|
+
if (!isApplicationUrl(url))
|
|
58
|
+
return false;
|
|
59
|
+
if (!url.searchParams.getAll(NUDGE_UI_EDITOR_QUERY_PARAM).includes(NUDGE_UI_EDITOR_QUERY_VALUE))
|
|
60
|
+
return false;
|
|
61
|
+
const header = (name) => {
|
|
62
|
+
const value = headers?.[name] ?? headers?.[name.toLowerCase()];
|
|
63
|
+
return typeof value === "string" ? value : value?.join(",") ?? "";
|
|
64
|
+
};
|
|
65
|
+
return header("sec-fetch-dest").toLowerCase() === "document"
|
|
66
|
+
|| header("accept").toLowerCase().includes("text/html");
|
|
67
|
+
}
|
|
68
|
+
/** Adds the persistent marker that bypasses editor entry for a plain app view. */
|
|
69
|
+
export function createNudgeUiDirectUrl(applicationHref) {
|
|
70
|
+
const url = new URL(applicationHref);
|
|
71
|
+
assertApplicationUrl(url);
|
|
72
|
+
url.searchParams.set(NUDGE_UI_DIRECT_QUERY_PARAM, "1");
|
|
73
|
+
return url.href;
|
|
74
|
+
}
|
|
75
|
+
/** Returns whether this application location explicitly bypasses editor entry. */
|
|
76
|
+
export function isNudgeUiDirectUrl(href) {
|
|
77
|
+
const url = new URL(href);
|
|
78
|
+
return url.searchParams.get(NUDGE_UI_DIRECT_QUERY_PARAM) === "1";
|
|
79
|
+
}
|
|
80
|
+
/** Remembers that this browser tab was explicitly opened outside the editor. */
|
|
81
|
+
export function rememberNudgeUiDirectTabIntent() {
|
|
82
|
+
try {
|
|
83
|
+
sessionStorage.setItem(DIRECT_TAB_SESSION_KEY, "1");
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
// Storage denial must not prevent a one-page direct application view.
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** Returns whether this browser tab should remain outside the editor. */
|
|
90
|
+
export function hasNudgeUiDirectTabIntent() {
|
|
91
|
+
try {
|
|
92
|
+
return sessionStorage.getItem(DIRECT_TAB_SESSION_KEY) === "1";
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** Chooses the browser-client role before any runtime manifest is fetched. */
|
|
99
|
+
export function resolveNudgeUiClientEntry(href, editorDocument, canvasRenderer, directTab = false) {
|
|
100
|
+
if (editorDocument || canvasRenderer)
|
|
101
|
+
return { kind: "bootstrap" };
|
|
102
|
+
if (isNudgeUiDirectUrl(href) || directTab)
|
|
103
|
+
return { kind: "direct" };
|
|
104
|
+
return { kind: "redirect", href: createNudgeUiEditorUrl(href) };
|
|
105
|
+
}
|
|
106
|
+
function isApplicationUrl(url) {
|
|
107
|
+
return (url.protocol === "http:" || url.protocol === "https:")
|
|
108
|
+
&& url.username === ""
|
|
109
|
+
&& url.password === ""
|
|
110
|
+
&& !isReservedNudgeUiRoute(url.pathname);
|
|
111
|
+
}
|
|
112
|
+
function assertApplicationUrl(url) {
|
|
113
|
+
if (!isApplicationUrl(url)) {
|
|
114
|
+
throw new TypeError("Nudge UI application URLs must be HTTP(S) URLs outside its reserved route namespace.");
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/** Renders the host-neutral editor document served by every development Adapter. */
|
|
118
|
+
export function createNudgeUiEditorDocument() {
|
|
119
|
+
return `<!doctype html>
|
|
120
|
+
<html lang="en" data-nudge-ui-editor>
|
|
121
|
+
<head>
|
|
122
|
+
<meta charset="utf-8">
|
|
123
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
124
|
+
<title>Nudge UI</title>
|
|
125
|
+
<style>html,body,#${NUDGE_UI_MOUNT_ID}{width:100%;height:100%;margin:0}body{overflow:hidden}</style>
|
|
126
|
+
</head>
|
|
127
|
+
<body>
|
|
128
|
+
<div id="${NUDGE_UI_MOUNT_ID}"></div>
|
|
129
|
+
<script type="module" src="${NUDGE_UI_CLIENT_PATH}" data-nudge-ui-client data-nudge-ui-manifest="${NUDGE_UI_MANIFEST_PATH}"></script>
|
|
130
|
+
</body>
|
|
131
|
+
</html>`;
|
|
132
|
+
}
|
package/dist/transport/index.js
CHANGED
|
@@ -7,7 +7,14 @@
|
|
|
7
7
|
export declare const NUDGE_UI_ROUTE_PREFIX = "/__nudge_ui__/";
|
|
8
8
|
export declare const NUDGE_UI_MANIFEST_PATH = "/__nudge_ui__/manifest";
|
|
9
9
|
export declare const NUDGE_UI_CLIENT_PATH = "/__nudge_ui__/client.mjs";
|
|
10
|
+
/** Pure controller document that hosts the editor chrome. */
|
|
11
|
+
export declare const NUDGE_UI_EDITOR_PATH = "/__nudge_ui__/editor";
|
|
10
12
|
/** Server-sent events announcing settled project changes. */
|
|
11
13
|
export declare const NUDGE_UI_RELOAD_PATH = "/__nudge_ui__/reload";
|
|
12
14
|
export declare const NUDGE_UI_MOUNT_ID = "nudge-ui-root";
|
|
15
|
+
/** Query marker that presents an application route through the editor shell. */
|
|
16
|
+
export declare const NUDGE_UI_EDITOR_QUERY_PARAM = "nudge-ui";
|
|
17
|
+
export declare const NUDGE_UI_EDITOR_QUERY_VALUE = "editor";
|
|
18
|
+
/** Query parameter that opens an application document without the editor. */
|
|
19
|
+
export declare const NUDGE_UI_DIRECT_QUERY_PARAM = "__nudge_ui_direct";
|
|
13
20
|
export declare function isReservedNudgeUiRoute(pathname: string): boolean;
|
package/dist/transport/routes.js
CHANGED
|
@@ -7,9 +7,16 @@
|
|
|
7
7
|
export const NUDGE_UI_ROUTE_PREFIX = "/__nudge_ui__/";
|
|
8
8
|
export const NUDGE_UI_MANIFEST_PATH = `${NUDGE_UI_ROUTE_PREFIX}manifest`;
|
|
9
9
|
export const NUDGE_UI_CLIENT_PATH = `${NUDGE_UI_ROUTE_PREFIX}client.mjs`;
|
|
10
|
+
/** Pure controller document that hosts the editor chrome. */
|
|
11
|
+
export const NUDGE_UI_EDITOR_PATH = `${NUDGE_UI_ROUTE_PREFIX}editor`;
|
|
10
12
|
/** Server-sent events announcing settled project changes. */
|
|
11
13
|
export const NUDGE_UI_RELOAD_PATH = `${NUDGE_UI_ROUTE_PREFIX}reload`;
|
|
12
14
|
export const NUDGE_UI_MOUNT_ID = "nudge-ui-root";
|
|
15
|
+
/** Query marker that presents an application route through the editor shell. */
|
|
16
|
+
export const NUDGE_UI_EDITOR_QUERY_PARAM = "nudge-ui";
|
|
17
|
+
export const NUDGE_UI_EDITOR_QUERY_VALUE = "editor";
|
|
18
|
+
/** Query parameter that opens an application document without the editor. */
|
|
19
|
+
export const NUDGE_UI_DIRECT_QUERY_PARAM = "__nudge_ui_direct";
|
|
13
20
|
export function isReservedNudgeUiRoute(pathname) {
|
|
14
21
|
return pathname === NUDGE_UI_ROUTE_PREFIX.slice(0, -1)
|
|
15
22
|
|| pathname.startsWith(NUDGE_UI_ROUTE_PREFIX);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nudge-ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Development-only visual UI inspector. One package, one subpath per host.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -79,7 +79,9 @@
|
|
|
79
79
|
"@base-ui/react": "^1.7.0",
|
|
80
80
|
"@tabler/icons-react": "^3.46.0",
|
|
81
81
|
"magic-string": "^0.30.21",
|
|
82
|
+
"modern-screenshot": "^4.7.0",
|
|
82
83
|
"parse5": "^7.3.0",
|
|
84
|
+
"perfect-freehand": "^1.2.3",
|
|
83
85
|
"postcss": "^8.5.26",
|
|
84
86
|
"typescript": "^5.9.3"
|
|
85
87
|
},
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const LAYOUT_STYLE_ID = "nudge-ui-panel-layout";
|
|
2
|
-
const PANEL_LAYOUT_ATTRIBUTE = "data-nudge-ui-panel";
|
|
3
|
-
const LAYOUT_STYLES = `
|
|
4
|
-
html[${PANEL_LAYOUT_ATTRIBUTE}="open"] body {
|
|
5
|
-
margin-right: min(320px, 100vw);
|
|
6
|
-
transition: margin-right 180ms ease;
|
|
7
|
-
}
|
|
8
|
-
`;
|
|
9
|
-
function ensureLayoutStyles() {
|
|
10
|
-
if (document.getElementById(LAYOUT_STYLE_ID))
|
|
11
|
-
return;
|
|
12
|
-
const style = document.createElement("style");
|
|
13
|
-
style.id = LAYOUT_STYLE_ID;
|
|
14
|
-
style.textContent = LAYOUT_STYLES;
|
|
15
|
-
document.head.appendChild(style);
|
|
16
|
-
}
|
|
17
|
-
export function setInspectorLayoutOpen(open) {
|
|
18
|
-
const root = document.documentElement;
|
|
19
|
-
if (open) {
|
|
20
|
-
ensureLayoutStyles();
|
|
21
|
-
root.setAttribute(PANEL_LAYOUT_ATTRIBUTE, "open");
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
root.removeAttribute(PANEL_LAYOUT_ATTRIBUTE);
|
|
25
|
-
}
|
|
26
|
-
export function clearInspectorLayout() {
|
|
27
|
-
document.documentElement.removeAttribute(PANEL_LAYOUT_ATTRIBUTE);
|
|
28
|
-
document.getElementById(LAYOUT_STYLE_ID)?.remove();
|
|
29
|
-
}
|