nudge-ui 0.2.1 → 0.2.2
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/client.mjs +16 -9
- package/dist/hosts/astro/clientTransport.js +3 -0
- package/dist/hosts/astro/integration.d.ts +2 -2
- package/dist/hosts/astro/integration.js +4 -3
- package/dist/hosts/environment.d.ts +15 -0
- package/dist/hosts/environment.js +16 -0
- package/dist/hosts/next/sidecar.js +7 -1
- package/dist/hosts/next/wrapper.d.ts +2 -0
- package/dist/hosts/next/wrapper.js +2 -1
- package/dist/hosts/projectBridge.d.ts +1 -0
- package/dist/hosts/projectBridge.js +1 -0
- package/dist/hosts/static/manifest.js +2 -0
- package/dist/hosts/static/server.js +1 -0
- package/dist/hosts/vite/vite.d.ts +1 -0
- package/dist/hosts/vite/vite.js +4 -1
- package/dist/inspector/agent/McpConnectionDialog.d.ts +3 -2
- package/dist/inspector/agent/McpConnectionDialog.js +11 -4
- package/dist/inspector/agent/client.d.ts +6 -0
- package/dist/inspector/agent/client.js +36 -4
- package/dist/inspector/agent/connectionStatus.d.ts +3 -3
- package/dist/inspector/agent/connectionStatus.js +8 -1
- package/dist/inspector/agent/httpTransport.d.ts +6 -0
- package/dist/inspector/agent/httpTransport.js +41 -1
- package/dist/inspector/agent/protocol.d.ts +3 -0
- package/dist/inspector/canvas/CanvasElementOverlay.js +49 -7
- package/dist/inspector/canvas/CanvasToolbar.js +4 -4
- package/dist/inspector/canvas/CanvasWorkspace.js +30 -11
- package/dist/inspector/canvas/frameProtocol.d.ts +16 -3
- package/dist/inspector/canvas/frameProtocol.js +9 -2
- package/dist/inspector/canvas/keyboardShortcuts.d.ts +2 -1
- package/dist/inspector/canvas/keyboardShortcuts.js +3 -1
- package/dist/inspector/canvas/linkEligibility.d.ts +0 -5
- package/dist/inspector/canvas/linkEligibility.js +0 -29
- package/dist/inspector/canvas/rendererBootstrap.js +13 -0
- package/dist/inspector/canvas/rendererElementSelector.d.ts +1 -1
- package/dist/inspector/canvas/rendererElementSelector.js +55 -39
- package/dist/inspector/changes/workspaceChanges.d.ts +4 -0
- package/dist/inspector/changes/workspaceChanges.js +29 -3
- package/dist/inspector/clientManifest.d.ts +2 -0
- package/dist/inspector/clientManifest.js +1 -0
- package/dist/inspector/index.js +6 -8
- package/dist/inspector/overlay/DomNavigator.d.ts +10 -0
- package/dist/inspector/overlay/DomNavigator.js +40 -0
- package/dist/inspector/overlay/InspectorOverlay.js +6 -2
- package/dist/inspector/overlay/clickPolicy.d.ts +18 -2
- package/dist/inspector/overlay/clickPolicy.js +34 -3
- package/dist/inspector/overlay/elementSelector.d.ts +1 -1
- package/dist/inspector/overlay/elementSelector.js +18 -7
- package/dist/inspector/overlay/spacingGestures.d.ts +3 -3
- package/dist/inspector/overlay/spacingGestures.js +15 -17
- package/dist/inspector/runtime/runtimeConfig.d.ts +1 -1
- package/dist/inspector/selection/hierarchy.d.ts +6 -0
- package/dist/inspector/selection/hierarchy.js +8 -0
- package/dist/inspector/settings/SettingsDialog.d.ts +1 -1
- package/dist/inspector/settings/SettingsDialog.js +2 -2
- package/dist/inspector/shell/ChangesLog.js +20 -20
- package/dist/inspector/shell/CopyPromptButton.js +9 -2
- package/dist/inspector/shell/InspectorShell.js +2 -5
- package/dist/inspector/sketch/store.js +48 -23
- package/dist/inspector/styleEditors/SpacingBox.js +9 -4
- package/dist/inspector/styleEditors/nudgeValue.d.ts +4 -4
- package/dist/inspector/styleEditors/nudgeValue.js +9 -7
- package/dist/inspector/tokens/TokenField.js +21 -2
- package/dist/inspector/tokens/TokensPanel.js +2 -1
- package/dist/inspector/tokens/dragPointerLock.d.ts +8 -0
- package/dist/inspector/tokens/dragPointerLock.js +70 -0
- package/dist/inspector/ui/Disclosure.d.ts +22 -0
- package/dist/inspector/ui/Disclosure.js +13 -0
- package/dist/inspector/ui/dragCursor.d.ts +8 -0
- package/dist/inspector/ui/dragCursor.js +21 -0
- package/dist/inspector/ui/styles.js +11 -9
- package/dist/nudge-ui.mjs +15 -1
- package/dist/transport/editor.d.ts +20 -1
- package/dist/transport/editor.js +42 -11
- package/dist/transport/routes.d.ts +4 -1
- package/dist/transport/routes.js +4 -1
- package/package.json +1 -1
- package/dist/inspector/shell/DomNavigation.d.ts +0 -8
- package/dist/inspector/shell/DomNavigation.js +0 -30
package/dist/transport/editor.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
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";
|
|
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, NUDGE_UI_OFF_QUERY_VALUE, NUDGE_UI_ON_QUERY_VALUE, isReservedNudgeUiRoute, } from "./routes.js";
|
|
2
2
|
const TARGET_QUERY_PARAM = "url";
|
|
3
3
|
const DIRECT_TAB_SESSION_KEY = "nudge-ui:direct-tab";
|
|
4
|
+
const FORCED_TAB_SESSION_KEY = "nudge-ui:forced-tab";
|
|
4
5
|
/** Returns the editor URL for one same-origin application location. */
|
|
5
6
|
export function createNudgeUiEditorUrl(applicationHref) {
|
|
6
7
|
const applicationUrl = new URL(applicationHref);
|
|
7
8
|
assertApplicationUrl(applicationUrl);
|
|
8
9
|
const retainedSegments = applicationUrl.search.slice(1).split("&").filter((segment) => {
|
|
9
10
|
const entry = new URLSearchParams(segment);
|
|
10
|
-
|
|
11
|
+
const value = entry.get(NUDGE_UI_EDITOR_QUERY_PARAM);
|
|
12
|
+
return entry.get(NUDGE_UI_DIRECT_QUERY_PARAM) !== "1"
|
|
13
|
+
&& value !== NUDGE_UI_OFF_QUERY_VALUE
|
|
14
|
+
&& value !== NUDGE_UI_ON_QUERY_VALUE;
|
|
11
15
|
});
|
|
12
16
|
applicationUrl.search = retainedSegments.join("&");
|
|
13
17
|
if (applicationUrl.searchParams.getAll(NUDGE_UI_EDITOR_QUERY_PARAM).includes(NUDGE_UI_EDITOR_QUERY_VALUE)) {
|
|
@@ -72,36 +76,63 @@ export function createNudgeUiDirectUrl(applicationHref) {
|
|
|
72
76
|
url.searchParams.set(NUDGE_UI_DIRECT_QUERY_PARAM, "1");
|
|
73
77
|
return url.href;
|
|
74
78
|
}
|
|
79
|
+
/** Reads the public `nudge-ui=off` / `nudge-ui=on` switch from an application URL. */
|
|
80
|
+
export function readNudgeUiQuerySwitch(href) {
|
|
81
|
+
const url = new URL(href);
|
|
82
|
+
const values = url.searchParams.getAll(NUDGE_UI_EDITOR_QUERY_PARAM);
|
|
83
|
+
if (values.includes(NUDGE_UI_OFF_QUERY_VALUE) || url.searchParams.get(NUDGE_UI_DIRECT_QUERY_PARAM) === "1") {
|
|
84
|
+
return "off";
|
|
85
|
+
}
|
|
86
|
+
return values.includes(NUDGE_UI_ON_QUERY_VALUE) ? "on" : null;
|
|
87
|
+
}
|
|
75
88
|
/** Returns whether this application location explicitly bypasses editor entry. */
|
|
76
89
|
export function isNudgeUiDirectUrl(href) {
|
|
77
|
-
|
|
78
|
-
return url.searchParams.get(NUDGE_UI_DIRECT_QUERY_PARAM) === "1";
|
|
90
|
+
return readNudgeUiQuerySwitch(href) === "off";
|
|
79
91
|
}
|
|
80
92
|
/** Remembers that this browser tab was explicitly opened outside the editor. */
|
|
81
93
|
export function rememberNudgeUiDirectTabIntent() {
|
|
94
|
+
rememberNudgeUiTabSwitch("off");
|
|
95
|
+
}
|
|
96
|
+
/** Remembers an explicit URL switch so later navigations in this tab keep it. */
|
|
97
|
+
export function rememberNudgeUiTabSwitch(value) {
|
|
82
98
|
try {
|
|
83
|
-
sessionStorage.setItem(DIRECT_TAB_SESSION_KEY, "1");
|
|
99
|
+
sessionStorage.setItem(value === "off" ? DIRECT_TAB_SESSION_KEY : FORCED_TAB_SESSION_KEY, "1");
|
|
100
|
+
sessionStorage.removeItem(value === "off" ? FORCED_TAB_SESSION_KEY : DIRECT_TAB_SESSION_KEY);
|
|
84
101
|
}
|
|
85
102
|
catch {
|
|
86
|
-
// Storage denial must not prevent
|
|
103
|
+
// Storage denial must not prevent the current page from honoring the switch.
|
|
87
104
|
}
|
|
88
105
|
}
|
|
89
106
|
/** Returns whether this browser tab should remain outside the editor. */
|
|
90
107
|
export function hasNudgeUiDirectTabIntent() {
|
|
108
|
+
return readTabFlag(DIRECT_TAB_SESSION_KEY);
|
|
109
|
+
}
|
|
110
|
+
/** Returns whether this browser tab explicitly asked for the editor with `nudge-ui=on`. */
|
|
111
|
+
export function hasNudgeUiForcedTabIntent() {
|
|
112
|
+
return readTabFlag(FORCED_TAB_SESSION_KEY);
|
|
113
|
+
}
|
|
114
|
+
function readTabFlag(key) {
|
|
91
115
|
try {
|
|
92
|
-
return sessionStorage.getItem(
|
|
116
|
+
return sessionStorage.getItem(key) === "1";
|
|
93
117
|
}
|
|
94
118
|
catch {
|
|
95
119
|
return false;
|
|
96
120
|
}
|
|
97
121
|
}
|
|
98
122
|
/** Chooses the browser-client role before any runtime manifest is fetched. */
|
|
99
|
-
export function resolveNudgeUiClientEntry(href,
|
|
100
|
-
if (editorDocument || canvasRenderer)
|
|
123
|
+
export function resolveNudgeUiClientEntry(href, context) {
|
|
124
|
+
if (context.editorDocument || context.canvasRenderer)
|
|
101
125
|
return { kind: "bootstrap" };
|
|
102
|
-
|
|
126
|
+
const urlSwitch = readNudgeUiQuerySwitch(href);
|
|
127
|
+
if (urlSwitch === "off")
|
|
128
|
+
return { kind: "direct" };
|
|
129
|
+
const forced = urlSwitch === "on" || context.forcedTab === true;
|
|
130
|
+
if (!forced && context.directTab === true)
|
|
103
131
|
return { kind: "direct" };
|
|
104
|
-
|
|
132
|
+
const editorHref = createNudgeUiEditorUrl(href);
|
|
133
|
+
if (context.automated === true && !forced)
|
|
134
|
+
return { kind: "automated", href: editorHref };
|
|
135
|
+
return { kind: "redirect", href: editorHref };
|
|
105
136
|
}
|
|
106
137
|
function isApplicationUrl(url) {
|
|
107
138
|
return (url.protocol === "http:" || url.protocol === "https:")
|
|
@@ -15,6 +15,9 @@ export declare const NUDGE_UI_MOUNT_ID = "nudge-ui-root";
|
|
|
15
15
|
/** Query marker that presents an application route through the editor shell. */
|
|
16
16
|
export declare const NUDGE_UI_EDITOR_QUERY_PARAM = "nudge-ui";
|
|
17
17
|
export declare const NUDGE_UI_EDITOR_QUERY_VALUE = "editor";
|
|
18
|
-
/**
|
|
18
|
+
/** Public `nudge-ui` values that turn the inspector off or on for one browser tab. */
|
|
19
|
+
export declare const NUDGE_UI_OFF_QUERY_VALUE = "off";
|
|
20
|
+
export declare const NUDGE_UI_ON_QUERY_VALUE = "on";
|
|
21
|
+
/** Internal alias of `nudge-ui=off` kept for existing direct-view links. */
|
|
19
22
|
export declare const NUDGE_UI_DIRECT_QUERY_PARAM = "__nudge_ui_direct";
|
|
20
23
|
export declare function isReservedNudgeUiRoute(pathname: string): boolean;
|
package/dist/transport/routes.js
CHANGED
|
@@ -15,7 +15,10 @@ export const NUDGE_UI_MOUNT_ID = "nudge-ui-root";
|
|
|
15
15
|
/** Query marker that presents an application route through the editor shell. */
|
|
16
16
|
export const NUDGE_UI_EDITOR_QUERY_PARAM = "nudge-ui";
|
|
17
17
|
export const NUDGE_UI_EDITOR_QUERY_VALUE = "editor";
|
|
18
|
-
/**
|
|
18
|
+
/** Public `nudge-ui` values that turn the inspector off or on for one browser tab. */
|
|
19
|
+
export const NUDGE_UI_OFF_QUERY_VALUE = "off";
|
|
20
|
+
export const NUDGE_UI_ON_QUERY_VALUE = "on";
|
|
21
|
+
/** Internal alias of `nudge-ui=off` kept for existing direct-view links. */
|
|
19
22
|
export const NUDGE_UI_DIRECT_QUERY_PARAM = "__nudge_ui_direct";
|
|
20
23
|
export function isReservedNudgeUiRoute(pathname) {
|
|
21
24
|
return pathname === NUDGE_UI_ROUTE_PREFIX.slice(0, -1)
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ReactElement } from "react";
|
|
2
|
-
import type { SelectedElement } from "../selection/selectionStore.js";
|
|
3
|
-
interface DomNavigationProps {
|
|
4
|
-
selected: SelectedElement;
|
|
5
|
-
hierarchy: HTMLElement[];
|
|
6
|
-
}
|
|
7
|
-
export declare function DomNavigation({ selected, hierarchy }: DomNavigationProps): ReactElement | null;
|
|
8
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { resolveSelectionFromElement } from "../selection/resolveSelection.js";
|
|
3
|
-
import { setSelectedElement } from "../selection/selectionStore.js";
|
|
4
|
-
import { computeDescendants } from "../selection/hierarchy.js";
|
|
5
|
-
import { Button } from "../ui/Button.js";
|
|
6
|
-
const MAX_PARENT_LEVELS = 2;
|
|
7
|
-
const MAX_CHILD_NODES = 2;
|
|
8
|
-
function nodeLabel(node) {
|
|
9
|
-
return node.getAttribute("data-cid") ?? node.localName;
|
|
10
|
-
}
|
|
11
|
-
function nodeDescription(node) {
|
|
12
|
-
const id = node.id ? `#${node.id}` : "";
|
|
13
|
-
const className = typeof node.className === "string"
|
|
14
|
-
? node.className.trim().split(/\s+/).filter(Boolean).slice(0, 2).map((name) => `.${name}`).join("")
|
|
15
|
-
: "";
|
|
16
|
-
const source = node.getAttribute("data-src");
|
|
17
|
-
return `${node.localName}${id}${className}${source ? ` — ${source}` : ""}`;
|
|
18
|
-
}
|
|
19
|
-
function selectNode(node) {
|
|
20
|
-
const resolved = resolveSelectionFromElement(node);
|
|
21
|
-
if (resolved)
|
|
22
|
-
setSelectedElement(resolved);
|
|
23
|
-
}
|
|
24
|
-
export function DomNavigation({ selected, hierarchy }) {
|
|
25
|
-
const parents = hierarchy.slice(1, MAX_PARENT_LEVELS + 1);
|
|
26
|
-
const children = computeDescendants(selected.domElement, 2, MAX_CHILD_NODES);
|
|
27
|
-
if (parents.length === 0 && children.length === 0)
|
|
28
|
-
return null;
|
|
29
|
-
return (_jsxs("section", { className: "dom-navigation", "data-test": "dom-navigation", "aria-label": "DOM navigation", children: [_jsx("div", { className: "dom-navigation__header", children: _jsx("span", { className: "dom-navigation__title", children: "DOM" }) }), parents.length > 0 ? (_jsxs("div", { className: "dom-navigation__group", "data-test": "dom-parents", children: [_jsx("span", { className: "dom-navigation__label", children: "Parents" }), _jsx("div", { className: "dom-navigation__items", children: parents.map((node, index) => (_jsxs(Button, { size: "compact", variant: "quiet", className: "dom-navigation__item", "data-test": "dom-parent-step", "data-depth": index + 1, "data-cid": node.getAttribute("data-cid") ?? undefined, title: nodeDescription(node), onClick: () => selectNode(node), children: [_jsx("span", { "aria-hidden": "true", children: "\u2191" }), index === 0 ? "Parent" : "Grandparent", _jsx("span", { className: "dom-navigation__value", children: nodeLabel(node) })] }, `${index}-${nodeLabel(node)}`))) })] })) : null, children.length > 0 ? (_jsxs("div", { className: "dom-navigation__group", "data-test": "dom-children", children: [_jsx("span", { className: "dom-navigation__label", children: "Children" }), _jsx("div", { className: "dom-navigation__items", children: children.map(({ element, depth }, index) => (_jsxs(Button, { size: "compact", variant: "quiet", className: "dom-navigation__item", "data-test": "dom-child-step", "data-depth": depth, "data-cid": element.getAttribute("data-cid") ?? undefined, title: nodeDescription(element), onClick: () => selectNode(element), children: [_jsx("span", { "aria-hidden": "true", children: "\u2193" }), depth === 1 ? "Child" : "Descendant", _jsx("span", { className: "dom-navigation__value", children: nodeLabel(element) })] }, `${depth}-${index}-${nodeLabel(element)}`))) })] })) : null] }));
|
|
30
|
-
}
|