react-devbelt 0.3.0 → 0.4.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/README.md +41 -257
- package/dist/{chunk-QT3YSHQA.js → chunk-6TOYYHSR.js} +2 -2
- package/dist/chunk-6TOYYHSR.js.map +1 -0
- package/dist/{chunk-C7RMX5PF.js → chunk-C6GPW32O.js} +2 -2
- package/dist/chunk-C6GPW32O.js.map +1 -0
- package/dist/{chunk-6PAFI4BJ.js → chunk-EYWS436C.js} +5 -5
- package/dist/chunk-EYWS436C.js.map +1 -0
- package/dist/{chunk-QRXHNBFY.js → chunk-M4KSKILI.js} +2 -2
- package/dist/chunk-M4KSKILI.js.map +1 -0
- package/dist/{chunk-GB5T3MS2.js → chunk-VVSEYZHW.js} +168 -32
- package/dist/chunk-VVSEYZHW.js.map +1 -0
- package/dist/{context-D2euxPc4.d.ts → context-BLsQOE6l.d.ts} +1 -1
- package/dist/core.js +14 -8
- package/dist/core.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/install.js +5 -5
- package/dist/install.js.map +1 -1
- package/dist/plugins.js +4 -4
- package/dist/{toolbar-entry-QHIQKNOO.js → toolbar-entry-4FUDASJW.js} +24 -24
- package/dist/toolbar-entry-4FUDASJW.js.map +1 -0
- package/dist/ui.d.ts +2 -2
- package/dist/ui.js +2 -2
- package/package.json +6 -2
- package/dist/chunk-6PAFI4BJ.js.map +0 -1
- package/dist/chunk-C7RMX5PF.js.map +0 -1
- package/dist/chunk-GB5T3MS2.js.map +0 -1
- package/dist/chunk-QRXHNBFY.js.map +0 -1
- package/dist/chunk-QT3YSHQA.js.map +0 -1
- package/dist/toolbar-entry-QHIQKNOO.js.map +0 -1
- /package/dist/{plugin-C8VytW9X.d.ts → index-C8VytW9X.d.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
// src/plugin.ts
|
|
3
|
+
// src/plugin-api/index.ts
|
|
4
4
|
var ID = /^[a-z][a-z0-9-]*$/;
|
|
5
5
|
function definePlugin(config) {
|
|
6
6
|
if (!ID.test(config.id)) {
|
|
@@ -19,4 +19,4 @@ function definePlugin(config) {
|
|
|
19
19
|
export {
|
|
20
20
|
definePlugin
|
|
21
21
|
};
|
|
22
|
-
//# sourceMappingURL=chunk-
|
|
22
|
+
//# sourceMappingURL=chunk-M4KSKILI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugin-api/index.ts"],"sourcesContent":["import type { ComponentType, ReactNode } from \"react\";\n\nimport type { AgentTool } from \"../core/agent-tools\";\nimport type { AiTool } from \"../plugins/ai-handoff/ai-tools\";\nimport type { DebugEntry } from \"../core/debug-bundle\";\n\nexport type WindowSize = {\n width: number;\n height: number;\n minWidth: number;\n minHeight: number;\n};\n\n/** What a plugin can ask the toolbar to do. Get it from `useToolbar()` or `run()`. */\nexport interface ToolbarApi {\n /** Opens the window of the plugin with this id, as a floating window or a popover (the panel mode). */\n openWindow(pluginId: string): void;\n closeWindow(pluginId: string): void;\n toggleWindow(pluginId: string): void;\n /** The lines every plugin contributes to the debug bundle's header. */\n debugContext(): DebugEntry[];\n /** The Markdown sections plugins add to the end of the debug bundle. */\n debugSections(): string[];\n /** The AI tools the app offers for \"open in …\" (the `aiTools` prop). Pass one to `openInAiTool`. */\n aiTools: readonly AiTool[];\n /** Overlays that handle Esc themselves call this; the returned function releases it. */\n holdEscape(): () => void;\n /**\n * Hides the toolbar, its windows and popovers (what ⌘/ does), or shows them again. For a plugin\n * that needs the screen clear, like recording it. Whoever hides it should show it again.\n */\n setHidden(hidden: boolean): void;\n /** Whether the toolbar is hidden right now. */\n isHidden(): boolean;\n /** The element the toolbar renders into: inside its shadow root, or a div on the page. */\n container: HTMLElement;\n /** The shadow root or document the toolbar lives in, for queries. */\n root: Document | ShadowRoot;\n}\n\nexport interface DevBeltPlugin {\n /** Plugin API version. `definePlugin` fills it in. */\n apiVersion: 1;\n /** Unique, lowercase, e.g. `react-query`. Also the key for saved layout. */\n id: string;\n /** Shown in menus and as the default window title. */\n name: string;\n icon: ReactNode;\n /** Whether the toolbar shows this plugin by default. Default true. People can change it in More tools. */\n pinned?: boolean;\n /** Not used: the toolbar draws a divider between every two plugins. */\n separatorAfter?: boolean;\n\n /**\n * Runs once in every frame, including the viewport iframe, as early as\n * `installDevBelt` or the first `<DevBelt />` mount. Patch globals or\n * register shortcuts here. Return a cleanup.\n */\n install?: () => void | (() => void);\n /** Tools for the browser's agent (WebMCP) and `window.devbelt`. */\n agentTools?: AgentTool<ToolbarApi>[];\n /**\n * Agent options set by the app. Agent tools marked `writes: true` stay off\n * until `agent: { write: true }` (ADR 0003). Read-only tools are unaffected.\n */\n agent?: { write?: boolean };\n /** Lines for the header of \"Copy debug bundle\". */\n debugContext?: () => DebugEntry[];\n /** Whole Markdown sections for the end of the debug bundle. */\n debugSections?: () => string[];\n\n /**\n * The toolbar item. Without it the toolbar draws a toggle for `window`, or\n * a button for `run`. A custom item is rendered inside the toolbar.\n */\n Item?: ComponentType;\n /** A count or dot inside the default toggle. */\n Badge?: ComponentType;\n /** Extra text after the default toggle's tooltip, e.g. \" · 2 failed\". */\n Hint?: ComponentType;\n /** Accessible name of the default toggle or button. Default: `name`. */\n label?: string;\n\n /**\n * The plugin's panel: a floating, draggable, resizable window, or, in popover\n * panel mode, a popover on its toolbar item at `size.width` × `size.height`.\n */\n window?: {\n title?: string;\n size: WindowSize;\n Component: ComponentType;\n };\n /**\n * An action. Called by the default button and by More tools. A returned\n * string flashes beside the icon, e.g. \"Copied\".\n */\n run?: (api: ToolbarApi) => void | string | Promise<void | string>;\n /** Tooltip of the default `run` button. */\n description?: string;\n\n /**\n * CSS for this plugin's own markup. The toolbar's stylesheet only knows the\n * classes the built-in plugins use, so a plugin that styles itself ships it here.\n */\n styles?: string;\n\n /** Rendered over the page in the top window, e.g. a picker or a device frame. */\n Overlay?: ComponentType;\n /** Rendered inside the More tools menu. Use ui-sdk `Menu*` parts. */\n MenuSection?: ComponentType;\n /** Rendered at the end of the toolbar, e.g. the current frame size. */\n Status?: ComponentType;\n /** Rendered in the collapsed toolbar's chip. */\n ChipStatus?: ComponentType;\n}\n\nexport type PluginConfig = Omit<DevBeltPlugin, \"apiVersion\"> & {\n apiVersion?: 1;\n};\n\nconst ID = /^[a-z][a-z0-9-]*$/;\n\n/** Declares a plugin. Checks the id and stamps the API version. */\nexport function definePlugin(config: PluginConfig): DevBeltPlugin {\n if (!ID.test(config.id)) {\n throw new Error(\n `devbelt: plugin id \"${config.id}\" must be lowercase letters, digits and dashes, starting with a letter.`,\n );\n }\n if (config.apiVersion !== undefined && config.apiVersion !== 1) {\n throw new Error(\n `devbelt: plugin \"${config.id}\" targets plugin API ${String(config.apiVersion)}, this version supports 1.`,\n );\n }\n return { ...config, apiVersion: 1 };\n}\n"],"mappings":";;;AAwHA,IAAM,KAAK;AAGJ,SAAS,aAAa,QAAqC;AAChE,MAAI,CAAC,GAAG,KAAK,OAAO,EAAE,GAAG;AACvB,UAAM,IAAI;AAAA,MACR,uBAAuB,OAAO,EAAE;AAAA,IAClC;AAAA,EACF;AACA,MAAI,OAAO,eAAe,UAAa,OAAO,eAAe,GAAG;AAC9D,UAAM,IAAI;AAAA,MACR,oBAAoB,OAAO,EAAE,wBAAwB,OAAO,OAAO,UAAU,CAAC;AAAA,IAChF;AAAA,EACF;AACA,SAAO,EAAE,GAAG,QAAQ,YAAY,EAAE;AACpC;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
definePlugin
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-M4KSKILI.js";
|
|
5
5
|
import {
|
|
6
6
|
Button,
|
|
7
7
|
Checkbox,
|
|
@@ -143,10 +143,10 @@ import {
|
|
|
143
143
|
usePrimitive,
|
|
144
144
|
valueMissingMessage,
|
|
145
145
|
watchFormDisabled
|
|
146
|
-
} from "./chunk-
|
|
146
|
+
} from "./chunk-EYWS436C.js";
|
|
147
147
|
import {
|
|
148
148
|
useToolbar
|
|
149
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-6TOYYHSR.js";
|
|
150
150
|
import {
|
|
151
151
|
dev,
|
|
152
152
|
onProps,
|
|
@@ -820,6 +820,7 @@ function createHostStore(name, options) {
|
|
|
820
820
|
try {
|
|
821
821
|
const raw = host.sessionStorage.getItem(options.persistKey);
|
|
822
822
|
const parsed = raw ? JSON.parse(raw) : [];
|
|
823
|
+
if (!Array.isArray(parsed)) return [];
|
|
823
824
|
return options.revive ? parsed.map(options.revive) : parsed;
|
|
824
825
|
} catch {
|
|
825
826
|
return [];
|
|
@@ -983,7 +984,7 @@ function describeViewport() {
|
|
|
983
984
|
return `${readStoredViewport() ? findViewport(readString(VIEWPORT_STORAGE_KEY))?.label ?? "Frame" : "Frame"} ${size}`;
|
|
984
985
|
}
|
|
985
986
|
|
|
986
|
-
// src/
|
|
987
|
+
// src/plugins/console/log.ts
|
|
987
988
|
var PATCHED_KEY = "__devbeltConsolePatched";
|
|
988
989
|
var MAX_ENTRIES = 200;
|
|
989
990
|
var MAX_MESSAGE = 8e3;
|
|
@@ -1108,7 +1109,7 @@ ${fence(entry.stack)}`);
|
|
|
1108
1109
|
}).join("\n\n---\n\n");
|
|
1109
1110
|
}
|
|
1110
1111
|
|
|
1111
|
-
// src/
|
|
1112
|
+
// src/plugins/network/log.ts
|
|
1112
1113
|
var PATCHED_KEY2 = "__devbeltNetworkPatched";
|
|
1113
1114
|
var MAX_ENTRIES2 = 300;
|
|
1114
1115
|
var MAX_SAVED_ENTRIES = 100;
|
|
@@ -1214,16 +1215,21 @@ function installFetchLog() {
|
|
|
1214
1215
|
let id = null;
|
|
1215
1216
|
const startedAt = performance.now();
|
|
1216
1217
|
try {
|
|
1217
|
-
const
|
|
1218
|
+
const source = typeof Request !== "undefined" && input instanceof Request;
|
|
1219
|
+
const headers = new Headers(source ? input.headers : void 0);
|
|
1220
|
+
new Headers(init?.headers).forEach(
|
|
1221
|
+
(value, name) => headers.set(name, value)
|
|
1222
|
+
);
|
|
1223
|
+
const rawUrl = source ? input.url : input instanceof URL ? input.href : String(input);
|
|
1218
1224
|
id = add({
|
|
1219
|
-
method:
|
|
1220
|
-
url: new URL(
|
|
1225
|
+
method: (init?.method ?? (source ? input.method : "GET")).toUpperCase(),
|
|
1226
|
+
url: new URL(rawUrl, window.location.href).href,
|
|
1221
1227
|
status: null,
|
|
1222
1228
|
startedAt: Date.now(),
|
|
1223
1229
|
duration: null,
|
|
1224
1230
|
pageUrl: window.location.href,
|
|
1225
1231
|
viewport: describeViewport(),
|
|
1226
|
-
requestHeaders: headersToRecord(
|
|
1232
|
+
requestHeaders: headersToRecord(headers),
|
|
1227
1233
|
// Only what the caller passed as `init.body` is read back; a Request
|
|
1228
1234
|
// body is a stream and cannot be read without consuming it.
|
|
1229
1235
|
requestBody: capInMemory(serializeBody(init?.body)),
|
|
@@ -1563,7 +1569,7 @@ function formatRecentProblems(network2 = getNetworkEntries(), logs = getConsoleE
|
|
|
1563
1569
|
return lines.join("\n");
|
|
1564
1570
|
}
|
|
1565
1571
|
|
|
1566
|
-
// src/ui/more-menu.tsx
|
|
1572
|
+
// src/ui/toolbar/more-menu.tsx
|
|
1567
1573
|
import { Fragment as Fragment3 } from "react";
|
|
1568
1574
|
|
|
1569
1575
|
// ../../node_modules/.pnpm/@ui-sdk+core@0.1.0-beta.5/node_modules/@ui-sdk/core/dist/components/toolbar/toolbar-fields.js
|
|
@@ -1934,20 +1940,20 @@ var ToolbarLink = parts2.Link;
|
|
|
1934
1940
|
var ToolbarInput = parts2.Input;
|
|
1935
1941
|
var ToolbarSeparator = parts2.Separator;
|
|
1936
1942
|
|
|
1937
|
-
// src/ui/more-menu.tsx
|
|
1943
|
+
// src/ui/toolbar/more-menu.tsx
|
|
1938
1944
|
import { CheckIcon, EllipsisIcon } from "lucide-react";
|
|
1939
1945
|
|
|
1940
|
-
// src/ui/menu-highlight.tsx
|
|
1946
|
+
// src/ui/toolbar/menu-highlight.tsx
|
|
1941
1947
|
import { useEffect, useRef, useState as useState2 } from "react";
|
|
1942
1948
|
|
|
1943
|
-
// src/ui/fluid-hover-highlight.tsx
|
|
1949
|
+
// src/ui/vendor/fluid-functionalism/fluid-hover-highlight.tsx
|
|
1944
1950
|
import {
|
|
1945
1951
|
motion,
|
|
1946
1952
|
AnimatePresence,
|
|
1947
1953
|
useReducedMotion
|
|
1948
1954
|
} from "motion/react";
|
|
1949
1955
|
|
|
1950
|
-
// src/ui/springs.ts
|
|
1956
|
+
// src/ui/vendor/fluid-functionalism/springs.ts
|
|
1951
1957
|
var spring = {
|
|
1952
1958
|
fast: {
|
|
1953
1959
|
type: "spring",
|
|
@@ -1969,7 +1975,7 @@ var spring = {
|
|
|
1969
1975
|
}
|
|
1970
1976
|
};
|
|
1971
1977
|
|
|
1972
|
-
// src/ui/fluid-hover-highlight.tsx
|
|
1978
|
+
// src/ui/vendor/fluid-functionalism/fluid-hover-highlight.tsx
|
|
1973
1979
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
1974
1980
|
var cn = (...parts6) => parts6.filter(Boolean).join(" ");
|
|
1975
1981
|
var fade = { duration: 0.08 };
|
|
@@ -2019,7 +2025,7 @@ function FluidHoverHighlight(props) {
|
|
|
2019
2025
|
) });
|
|
2020
2026
|
}
|
|
2021
2027
|
|
|
2022
|
-
// src/ui/menu-highlight.tsx
|
|
2028
|
+
// src/ui/toolbar/menu-highlight.tsx
|
|
2023
2029
|
import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
2024
2030
|
function MenuHighlight() {
|
|
2025
2031
|
const anchor = useRef(null);
|
|
@@ -2063,7 +2069,7 @@ function MenuHighlight() {
|
|
|
2063
2069
|
] });
|
|
2064
2070
|
}
|
|
2065
2071
|
|
|
2066
|
-
// src/ui/toolbar-shortcuts.ts
|
|
2072
|
+
// src/ui/toolbar/toolbar-shortcuts.ts
|
|
2067
2073
|
var COLLAPSE_SHORTCUT = "mod+.";
|
|
2068
2074
|
var HIDE_SHORTCUT = "mod+/";
|
|
2069
2075
|
var collapseLabel = () => formatShortcut(COLLAPSE_SHORTCUT);
|
|
@@ -2101,7 +2107,7 @@ function forwardToTop(name) {
|
|
|
2101
2107
|
}
|
|
2102
2108
|
}
|
|
2103
2109
|
|
|
2104
|
-
// src/ui/more-menu.tsx
|
|
2110
|
+
// src/ui/toolbar/more-menu.tsx
|
|
2105
2111
|
import { Fragment as Fragment4, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2106
2112
|
var menuContentClass = "m-0 max-h-(--available-height) min-w-56 scrollbar-slim scroll-fade overflow-y-auto rounded-xl border border-line bg-surface p-1 text-xs text-fg shadow-2xl";
|
|
2107
2113
|
var menuLabelClass = "px-2 pt-1.5 pb-1 text-[10px] tracking-wide text-fg-tertiary uppercase";
|
|
@@ -2225,11 +2231,11 @@ function MoreMenu({
|
|
|
2225
2231
|
] });
|
|
2226
2232
|
}
|
|
2227
2233
|
|
|
2228
|
-
// src/plugins/ai-handoff.tsx
|
|
2234
|
+
// src/plugins/ai-handoff/index.tsx
|
|
2229
2235
|
import { useSyncExternalStore } from "react";
|
|
2230
2236
|
import { SparklesIcon } from "lucide-react";
|
|
2231
2237
|
|
|
2232
|
-
// src/
|
|
2238
|
+
// src/plugins/ai-handoff/ai-tools.ts
|
|
2233
2239
|
var DEFAULT_MAX_PROMPT = 5e3;
|
|
2234
2240
|
var cursor = {
|
|
2235
2241
|
id: "cursor",
|
|
@@ -2275,7 +2281,7 @@ function describeAiResult(tool, result) {
|
|
|
2275
2281
|
return "Copy failed";
|
|
2276
2282
|
}
|
|
2277
2283
|
|
|
2278
|
-
// src/plugins/ai-
|
|
2284
|
+
// src/plugins/ai-handoff/icons.tsx
|
|
2279
2285
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
2280
2286
|
var common = { "aria-hidden": true, focusable: false };
|
|
2281
2287
|
function CursorLogo({ className }) {
|
|
@@ -2302,7 +2308,7 @@ function CodexLogo({ className }) {
|
|
|
2302
2308
|
) });
|
|
2303
2309
|
}
|
|
2304
2310
|
|
|
2305
|
-
// src/plugins/ai-handoff.tsx
|
|
2311
|
+
// src/plugins/ai-handoff/index.tsx
|
|
2306
2312
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
2307
2313
|
var FLASH_MS = 3e3;
|
|
2308
2314
|
var AI_TOOL_ICONS = {
|
|
@@ -4281,7 +4287,11 @@ var STEPS = [
|
|
|
4281
4287
|
keys: [MOD, "Click"],
|
|
4282
4288
|
text: "Select several elements. Each one gets a note for your AI"
|
|
4283
4289
|
},
|
|
4284
|
-
{
|
|
4290
|
+
{
|
|
4291
|
+
keys: ["\u2191", "\u2193", "\u2190", "\u2192"],
|
|
4292
|
+
text: "Move the highlight to the parent, a child or a sibling"
|
|
4293
|
+
},
|
|
4294
|
+
{ keys: ["Enter"], text: "Copy the highlighted element or the selection" },
|
|
4285
4295
|
{ keys: ["Esc"], text: "Cancel" }
|
|
4286
4296
|
];
|
|
4287
4297
|
var cardClass = "pointer-events-auto fixed inset-x-0 top-4 z-[10000] mx-auto text-xs text-fg shadow-2xl";
|
|
@@ -4517,7 +4527,34 @@ var frameGeometry = () => {
|
|
|
4517
4527
|
return { frame: frame2, box, scale: scale || 1 };
|
|
4518
4528
|
};
|
|
4519
4529
|
var grabbable = (candidate) => isElementGrabbable(candidate) && !candidate.closest("[data-react-grab-ignore]");
|
|
4520
|
-
var
|
|
4530
|
+
var COVERS_PAGE = 0.9;
|
|
4531
|
+
var grabbableInFrame = (candidate) => {
|
|
4532
|
+
const doc = candidate.ownerDocument;
|
|
4533
|
+
if (candidate.closest("[data-react-grab-ignore]") || candidate === doc.documentElement || candidate === doc.body) {
|
|
4534
|
+
return false;
|
|
4535
|
+
}
|
|
4536
|
+
const view = doc.defaultView;
|
|
4537
|
+
if (!view) return true;
|
|
4538
|
+
const style = view.getComputedStyle(candidate);
|
|
4539
|
+
if (style.visibility === "hidden" || Number.parseFloat(style.opacity) < 0.01) {
|
|
4540
|
+
return false;
|
|
4541
|
+
}
|
|
4542
|
+
if (style.position !== "fixed" && style.position !== "absolute") return true;
|
|
4543
|
+
const clear = style.backgroundColor === "transparent" || style.backgroundColor === "rgba(0, 0, 0, 0)";
|
|
4544
|
+
if (!clear) return true;
|
|
4545
|
+
const box = candidate.getBoundingClientRect();
|
|
4546
|
+
const { clientWidth, clientHeight } = doc.documentElement;
|
|
4547
|
+
return !(clientWidth > 0 && clientHeight > 0 && box.width >= clientWidth * COVERS_PAGE && box.height >= clientHeight * COVERS_PAGE);
|
|
4548
|
+
};
|
|
4549
|
+
var isPickable = (candidate) => candidate.ownerDocument === document ? grabbable(candidate) : grabbableInFrame(candidate);
|
|
4550
|
+
var deepStack = (root, x, y) => {
|
|
4551
|
+
const stack = [];
|
|
4552
|
+
for (const el of root.elementsFromPoint(x, y)) {
|
|
4553
|
+
if (el.shadowRoot) stack.push(...deepStack(el.shadowRoot, x, y));
|
|
4554
|
+
stack.push(el);
|
|
4555
|
+
}
|
|
4556
|
+
return stack;
|
|
4557
|
+
};
|
|
4521
4558
|
var hitTest = (x, y) => {
|
|
4522
4559
|
const geo = frameGeometry();
|
|
4523
4560
|
if (!geo) return getElementAtPoint(x, y, { filter: grabbable });
|
|
@@ -4526,8 +4563,32 @@ var hitTest = (x, y) => {
|
|
|
4526
4563
|
if (!doc || x < box.left || x > box.right || y < box.top || y > box.bottom) {
|
|
4527
4564
|
return null;
|
|
4528
4565
|
}
|
|
4529
|
-
return doc
|
|
4566
|
+
return deepStack(doc, (x - box.left) / scale, (y - box.top) / scale).find(
|
|
4567
|
+
grabbableInFrame
|
|
4568
|
+
) ?? null;
|
|
4569
|
+
};
|
|
4570
|
+
var pickableParent = (el) => {
|
|
4571
|
+
let parent = el.parentElement;
|
|
4572
|
+
while (parent && !isPickable(parent)) parent = parent.parentElement;
|
|
4573
|
+
return parent;
|
|
4574
|
+
};
|
|
4575
|
+
var pickableChild = (el) => {
|
|
4576
|
+
const queue = [...el.children];
|
|
4577
|
+
while (queue.length > 0) {
|
|
4578
|
+
const next = queue.shift();
|
|
4579
|
+
if (isPickable(next)) return next;
|
|
4580
|
+
queue.push(...next.children);
|
|
4581
|
+
}
|
|
4582
|
+
return null;
|
|
4583
|
+
};
|
|
4584
|
+
var pickableSibling = (el, step) => {
|
|
4585
|
+
let sibling = step === 1 ? el.nextElementSibling : el.previousElementSibling;
|
|
4586
|
+
while (sibling && !isPickable(sibling)) {
|
|
4587
|
+
sibling = step === 1 ? sibling.nextElementSibling : sibling.previousElementSibling;
|
|
4588
|
+
}
|
|
4589
|
+
return sibling;
|
|
4530
4590
|
};
|
|
4591
|
+
var reducedMotion = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
4531
4592
|
var SELECTED_FLASH_MS = 900;
|
|
4532
4593
|
var tagLabel = (element, bounds) => `${element.tagName.toLowerCase()} \xB7 ${Math.round(bounds.width)}\xD7${Math.round(bounds.height)}`;
|
|
4533
4594
|
function Box({
|
|
@@ -4535,6 +4596,28 @@ function Box({
|
|
|
4535
4596
|
label,
|
|
4536
4597
|
tone
|
|
4537
4598
|
}) {
|
|
4599
|
+
const ref = useRef2(null);
|
|
4600
|
+
useEffect3(() => {
|
|
4601
|
+
const el = ref.current;
|
|
4602
|
+
if (tone !== "selected" || !el?.animate || reducedMotion()) return;
|
|
4603
|
+
const pop = el.animate(
|
|
4604
|
+
[
|
|
4605
|
+
{ transform: "scale(1.04)", opacity: 0.2 },
|
|
4606
|
+
{ transform: "scale(1)", opacity: 1 }
|
|
4607
|
+
],
|
|
4608
|
+
{ duration: 180, easing: "cubic-bezier(0.23, 1, 0.32, 1)" }
|
|
4609
|
+
);
|
|
4610
|
+
const fade2 = el.animate([{ opacity: 1 }, { opacity: 0 }], {
|
|
4611
|
+
duration: 220,
|
|
4612
|
+
delay: SELECTED_FLASH_MS - 220,
|
|
4613
|
+
easing: "ease-out",
|
|
4614
|
+
fill: "forwards"
|
|
4615
|
+
});
|
|
4616
|
+
return () => {
|
|
4617
|
+
pop.cancel();
|
|
4618
|
+
fade2.cancel();
|
|
4619
|
+
};
|
|
4620
|
+
}, [tone]);
|
|
4538
4621
|
const toneClass = {
|
|
4539
4622
|
hover: "border-2 border-accent bg-accent/15",
|
|
4540
4623
|
preview: "border border-accent bg-accent/10",
|
|
@@ -4545,6 +4628,7 @@ function Box({
|
|
|
4545
4628
|
return /* @__PURE__ */ jsx17(
|
|
4546
4629
|
"div",
|
|
4547
4630
|
{
|
|
4631
|
+
ref,
|
|
4548
4632
|
"data-react-grab-ignore": true,
|
|
4549
4633
|
className: `pointer-events-none fixed z-[9999] ${toneClass}`,
|
|
4550
4634
|
style: {
|
|
@@ -4552,7 +4636,9 @@ function Box({
|
|
|
4552
4636
|
top: bounds.y,
|
|
4553
4637
|
width: bounds.width,
|
|
4554
4638
|
height: bounds.height,
|
|
4555
|
-
borderRadius: bounds.borderRadius
|
|
4639
|
+
borderRadius: bounds.borderRadius,
|
|
4640
|
+
// the hover box glides to the next element instead of jumping
|
|
4641
|
+
transition: tone === "hover" && !reducedMotion() ? "left 120ms cubic-bezier(0.23, 1, 0.32, 1), top 120ms cubic-bezier(0.23, 1, 0.32, 1), width 120ms cubic-bezier(0.23, 1, 0.32, 1), height 120ms cubic-bezier(0.23, 1, 0.32, 1), border-radius 120ms ease-out" : void 0
|
|
4556
4642
|
},
|
|
4557
4643
|
children: label ? /* @__PURE__ */ jsx17(
|
|
4558
4644
|
"span",
|
|
@@ -4582,6 +4668,7 @@ function DevGrabPicker({
|
|
|
4582
4668
|
const nextPickId = useRef2(1);
|
|
4583
4669
|
const [guideOpen, setGuideOpen] = useState5(() => !readGuideDismissed());
|
|
4584
4670
|
const [, setTick] = useState5(0);
|
|
4671
|
+
const climbed = useRef2([]);
|
|
4585
4672
|
useEffect3(() => {
|
|
4586
4673
|
const onKey = (event) => {
|
|
4587
4674
|
if (event.defaultPrevented) return;
|
|
@@ -4590,6 +4677,16 @@ function DevGrabPicker({
|
|
|
4590
4677
|
else onDone("cancelled");
|
|
4591
4678
|
return;
|
|
4592
4679
|
}
|
|
4680
|
+
const step = navigate(event);
|
|
4681
|
+
if (step) {
|
|
4682
|
+
event.preventDefault();
|
|
4683
|
+
return;
|
|
4684
|
+
}
|
|
4685
|
+
if (event.key === "Enter" && picks.length === 0 && hover && !dragStart) {
|
|
4686
|
+
event.preventDefault();
|
|
4687
|
+
void finish2([hover.element], "");
|
|
4688
|
+
return;
|
|
4689
|
+
}
|
|
4593
4690
|
if (event.key === "Enter" && picks.length > 0) {
|
|
4594
4691
|
const mod = event.metaKey || event.ctrlKey;
|
|
4595
4692
|
const onControl = event.target instanceof Element && event.target.closest("button, a, input, textarea, select");
|
|
@@ -4601,7 +4698,7 @@ function DevGrabPicker({
|
|
|
4601
4698
|
};
|
|
4602
4699
|
window.addEventListener("keydown", onKey);
|
|
4603
4700
|
return () => window.removeEventListener("keydown", onKey);
|
|
4604
|
-
}, [onDone, noteFor, picks]);
|
|
4701
|
+
}, [onDone, noteFor, picks, hover, dragStart]);
|
|
4605
4702
|
useEffect3(() => {
|
|
4606
4703
|
if (picks.length === 0) return;
|
|
4607
4704
|
let frame2 = 0;
|
|
@@ -4621,6 +4718,44 @@ function DevGrabPicker({
|
|
|
4621
4718
|
return () => cancelAnimationFrame(frame2);
|
|
4622
4719
|
}, [picks]);
|
|
4623
4720
|
const pick = hitTest;
|
|
4721
|
+
const navigate = (event) => {
|
|
4722
|
+
if (!hover || noteFor !== null || event.metaKey || event.ctrlKey || event.altKey) {
|
|
4723
|
+
return false;
|
|
4724
|
+
}
|
|
4725
|
+
if (event.target instanceof Element && event.target.closest("input, textarea, select")) {
|
|
4726
|
+
return false;
|
|
4727
|
+
}
|
|
4728
|
+
const current = hover.element;
|
|
4729
|
+
let next = null;
|
|
4730
|
+
switch (event.key) {
|
|
4731
|
+
case "ArrowUp":
|
|
4732
|
+
next = pickableParent(current);
|
|
4733
|
+
if (next) climbed.current.push(current);
|
|
4734
|
+
break;
|
|
4735
|
+
case "ArrowDown": {
|
|
4736
|
+
const back = climbed.current[climbed.current.length - 1];
|
|
4737
|
+
if (back && current.contains(back)) {
|
|
4738
|
+
next = back;
|
|
4739
|
+
climbed.current.pop();
|
|
4740
|
+
} else {
|
|
4741
|
+
next = pickableChild(current);
|
|
4742
|
+
}
|
|
4743
|
+
break;
|
|
4744
|
+
}
|
|
4745
|
+
case "ArrowLeft":
|
|
4746
|
+
next = pickableSibling(current, -1);
|
|
4747
|
+
break;
|
|
4748
|
+
case "ArrowRight":
|
|
4749
|
+
next = pickableSibling(current, 1);
|
|
4750
|
+
break;
|
|
4751
|
+
default:
|
|
4752
|
+
return false;
|
|
4753
|
+
}
|
|
4754
|
+
if (!next) return true;
|
|
4755
|
+
if (event.key === "ArrowLeft" || event.key === "ArrowRight") climbed.current = [];
|
|
4756
|
+
setHover({ element: next, bounds: getElementBounds(next) });
|
|
4757
|
+
return true;
|
|
4758
|
+
};
|
|
4624
4759
|
const dragging = dragStart && dragEnd && Math.abs(dragEnd.x - dragStart.x) + Math.abs(dragEnd.y - dragStart.y) >= DRAG_THRESHOLD;
|
|
4625
4760
|
const rect = dragging && dragStart && dragEnd ? toRect(dragStart, dragEnd) : null;
|
|
4626
4761
|
const collectRegion = (area) => {
|
|
@@ -4680,7 +4815,7 @@ ${problems}` : ""}`;
|
|
|
4680
4815
|
return {
|
|
4681
4816
|
key,
|
|
4682
4817
|
bounds,
|
|
4683
|
-
label: name ? `<${name}>` : tagLabel(el, bounds)
|
|
4818
|
+
label: `${copied ? "\u2713 " : ""}${name ? `<${name}>` : tagLabel(el, bounds)}`
|
|
4684
4819
|
};
|
|
4685
4820
|
})
|
|
4686
4821
|
);
|
|
@@ -4746,6 +4881,7 @@ ${problems}` : ""}`;
|
|
|
4746
4881
|
}
|
|
4747
4882
|
const element = pick(event.clientX, event.clientY);
|
|
4748
4883
|
if (!element) return setHover(null);
|
|
4884
|
+
if (element !== hover?.element) climbed.current = [];
|
|
4749
4885
|
setHover(
|
|
4750
4886
|
(prev) => prev?.element === element ? prev : { element, bounds: getElementBounds(element) }
|
|
4751
4887
|
);
|
|
@@ -6575,7 +6711,7 @@ function viewport() {
|
|
|
6575
6711
|
import { useEffect as useEffect6, useState as useState8, useSyncExternalStore as useSyncExternalStore6 } from "react";
|
|
6576
6712
|
import { RulerIcon as RulerIcon2, SquareDashedIcon } from "lucide-react";
|
|
6577
6713
|
|
|
6578
|
-
// src/
|
|
6714
|
+
// src/plugins/breakpoint/breakpoints.ts
|
|
6579
6715
|
var DEFAULT_BREAKPOINTS = {
|
|
6580
6716
|
sm: "40rem",
|
|
6581
6717
|
md: "48rem",
|
|
@@ -7288,7 +7424,7 @@ function redact(key, value, pattern) {
|
|
|
7288
7424
|
return isRedacted2(key, pattern) ? redactedForm(value) : value;
|
|
7289
7425
|
}
|
|
7290
7426
|
|
|
7291
|
-
// src/
|
|
7427
|
+
// src/plugins/storage/view.ts
|
|
7292
7428
|
var STORAGE_STORES = ["localStorage", "sessionStorage", "cookies"];
|
|
7293
7429
|
var OWN_PREFIX = "devbelt:";
|
|
7294
7430
|
var reasonOf = (e) => e instanceof Error && e.message ? e.message : "blocked by the browser";
|
|
@@ -7443,7 +7579,7 @@ function clearStorageStore(store) {
|
|
|
7443
7579
|
}
|
|
7444
7580
|
}
|
|
7445
7581
|
|
|
7446
|
-
// src/
|
|
7582
|
+
// src/plugins/storage/watch.ts
|
|
7447
7583
|
var LISTENERS = "__devbeltStorageListeners";
|
|
7448
7584
|
var PATCHED = "__devbeltStoragePatched";
|
|
7449
7585
|
var COOKIE_POLL_MS = 500;
|
|
@@ -8027,4 +8163,4 @@ export {
|
|
|
8027
8163
|
storage,
|
|
8028
8164
|
defaultPlugins
|
|
8029
8165
|
};
|
|
8030
|
-
//# sourceMappingURL=chunk-
|
|
8166
|
+
//# sourceMappingURL=chunk-VVSEYZHW.js.map
|