react-devbelt 0.2.0 → 0.4.0
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-SYBN2CEO.js} +159 -28
- package/dist/chunk-SYBN2CEO.js.map +1 -0
- package/dist/{context-D2euxPc4.d.ts → context-BLsQOE6l.d.ts} +1 -1
- package/dist/core.js +5 -4
- 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-XIKTJ2OG.js} +24 -24
- package/dist/toolbar-entry-XIKTJ2OG.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;
|
|
@@ -1563,7 +1564,7 @@ function formatRecentProblems(network2 = getNetworkEntries(), logs = getConsoleE
|
|
|
1563
1564
|
return lines.join("\n");
|
|
1564
1565
|
}
|
|
1565
1566
|
|
|
1566
|
-
// src/ui/more-menu.tsx
|
|
1567
|
+
// src/ui/toolbar/more-menu.tsx
|
|
1567
1568
|
import { Fragment as Fragment3 } from "react";
|
|
1568
1569
|
|
|
1569
1570
|
// ../../node_modules/.pnpm/@ui-sdk+core@0.1.0-beta.5/node_modules/@ui-sdk/core/dist/components/toolbar/toolbar-fields.js
|
|
@@ -1934,20 +1935,20 @@ var ToolbarLink = parts2.Link;
|
|
|
1934
1935
|
var ToolbarInput = parts2.Input;
|
|
1935
1936
|
var ToolbarSeparator = parts2.Separator;
|
|
1936
1937
|
|
|
1937
|
-
// src/ui/more-menu.tsx
|
|
1938
|
+
// src/ui/toolbar/more-menu.tsx
|
|
1938
1939
|
import { CheckIcon, EllipsisIcon } from "lucide-react";
|
|
1939
1940
|
|
|
1940
|
-
// src/ui/menu-highlight.tsx
|
|
1941
|
+
// src/ui/toolbar/menu-highlight.tsx
|
|
1941
1942
|
import { useEffect, useRef, useState as useState2 } from "react";
|
|
1942
1943
|
|
|
1943
|
-
// src/ui/fluid-hover-highlight.tsx
|
|
1944
|
+
// src/ui/vendor/fluid-functionalism/fluid-hover-highlight.tsx
|
|
1944
1945
|
import {
|
|
1945
1946
|
motion,
|
|
1946
1947
|
AnimatePresence,
|
|
1947
1948
|
useReducedMotion
|
|
1948
1949
|
} from "motion/react";
|
|
1949
1950
|
|
|
1950
|
-
// src/ui/springs.ts
|
|
1951
|
+
// src/ui/vendor/fluid-functionalism/springs.ts
|
|
1951
1952
|
var spring = {
|
|
1952
1953
|
fast: {
|
|
1953
1954
|
type: "spring",
|
|
@@ -1969,7 +1970,7 @@ var spring = {
|
|
|
1969
1970
|
}
|
|
1970
1971
|
};
|
|
1971
1972
|
|
|
1972
|
-
// src/ui/fluid-hover-highlight.tsx
|
|
1973
|
+
// src/ui/vendor/fluid-functionalism/fluid-hover-highlight.tsx
|
|
1973
1974
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
1974
1975
|
var cn = (...parts6) => parts6.filter(Boolean).join(" ");
|
|
1975
1976
|
var fade = { duration: 0.08 };
|
|
@@ -2019,7 +2020,7 @@ function FluidHoverHighlight(props) {
|
|
|
2019
2020
|
) });
|
|
2020
2021
|
}
|
|
2021
2022
|
|
|
2022
|
-
// src/ui/menu-highlight.tsx
|
|
2023
|
+
// src/ui/toolbar/menu-highlight.tsx
|
|
2023
2024
|
import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
2024
2025
|
function MenuHighlight() {
|
|
2025
2026
|
const anchor = useRef(null);
|
|
@@ -2063,7 +2064,7 @@ function MenuHighlight() {
|
|
|
2063
2064
|
] });
|
|
2064
2065
|
}
|
|
2065
2066
|
|
|
2066
|
-
// src/ui/toolbar-shortcuts.ts
|
|
2067
|
+
// src/ui/toolbar/toolbar-shortcuts.ts
|
|
2067
2068
|
var COLLAPSE_SHORTCUT = "mod+.";
|
|
2068
2069
|
var HIDE_SHORTCUT = "mod+/";
|
|
2069
2070
|
var collapseLabel = () => formatShortcut(COLLAPSE_SHORTCUT);
|
|
@@ -2101,7 +2102,7 @@ function forwardToTop(name) {
|
|
|
2101
2102
|
}
|
|
2102
2103
|
}
|
|
2103
2104
|
|
|
2104
|
-
// src/ui/more-menu.tsx
|
|
2105
|
+
// src/ui/toolbar/more-menu.tsx
|
|
2105
2106
|
import { Fragment as Fragment4, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2106
2107
|
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
2108
|
var menuLabelClass = "px-2 pt-1.5 pb-1 text-[10px] tracking-wide text-fg-tertiary uppercase";
|
|
@@ -2225,11 +2226,11 @@ function MoreMenu({
|
|
|
2225
2226
|
] });
|
|
2226
2227
|
}
|
|
2227
2228
|
|
|
2228
|
-
// src/plugins/ai-handoff.tsx
|
|
2229
|
+
// src/plugins/ai-handoff/index.tsx
|
|
2229
2230
|
import { useSyncExternalStore } from "react";
|
|
2230
2231
|
import { SparklesIcon } from "lucide-react";
|
|
2231
2232
|
|
|
2232
|
-
// src/
|
|
2233
|
+
// src/plugins/ai-handoff/ai-tools.ts
|
|
2233
2234
|
var DEFAULT_MAX_PROMPT = 5e3;
|
|
2234
2235
|
var cursor = {
|
|
2235
2236
|
id: "cursor",
|
|
@@ -2275,7 +2276,7 @@ function describeAiResult(tool, result) {
|
|
|
2275
2276
|
return "Copy failed";
|
|
2276
2277
|
}
|
|
2277
2278
|
|
|
2278
|
-
// src/plugins/ai-
|
|
2279
|
+
// src/plugins/ai-handoff/icons.tsx
|
|
2279
2280
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
2280
2281
|
var common = { "aria-hidden": true, focusable: false };
|
|
2281
2282
|
function CursorLogo({ className }) {
|
|
@@ -2302,7 +2303,7 @@ function CodexLogo({ className }) {
|
|
|
2302
2303
|
) });
|
|
2303
2304
|
}
|
|
2304
2305
|
|
|
2305
|
-
// src/plugins/ai-handoff.tsx
|
|
2306
|
+
// src/plugins/ai-handoff/index.tsx
|
|
2306
2307
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
2307
2308
|
var FLASH_MS = 3e3;
|
|
2308
2309
|
var AI_TOOL_ICONS = {
|
|
@@ -4281,7 +4282,11 @@ var STEPS = [
|
|
|
4281
4282
|
keys: [MOD, "Click"],
|
|
4282
4283
|
text: "Select several elements. Each one gets a note for your AI"
|
|
4283
4284
|
},
|
|
4284
|
-
{
|
|
4285
|
+
{
|
|
4286
|
+
keys: ["\u2191", "\u2193", "\u2190", "\u2192"],
|
|
4287
|
+
text: "Move the highlight to the parent, a child or a sibling"
|
|
4288
|
+
},
|
|
4289
|
+
{ keys: ["Enter"], text: "Copy the highlighted element or the selection" },
|
|
4285
4290
|
{ keys: ["Esc"], text: "Cancel" }
|
|
4286
4291
|
];
|
|
4287
4292
|
var cardClass = "pointer-events-auto fixed inset-x-0 top-4 z-[10000] mx-auto text-xs text-fg shadow-2xl";
|
|
@@ -4517,7 +4522,34 @@ var frameGeometry = () => {
|
|
|
4517
4522
|
return { frame: frame2, box, scale: scale || 1 };
|
|
4518
4523
|
};
|
|
4519
4524
|
var grabbable = (candidate) => isElementGrabbable(candidate) && !candidate.closest("[data-react-grab-ignore]");
|
|
4520
|
-
var
|
|
4525
|
+
var COVERS_PAGE = 0.9;
|
|
4526
|
+
var grabbableInFrame = (candidate) => {
|
|
4527
|
+
const doc = candidate.ownerDocument;
|
|
4528
|
+
if (candidate.closest("[data-react-grab-ignore]") || candidate === doc.documentElement || candidate === doc.body) {
|
|
4529
|
+
return false;
|
|
4530
|
+
}
|
|
4531
|
+
const view = doc.defaultView;
|
|
4532
|
+
if (!view) return true;
|
|
4533
|
+
const style = view.getComputedStyle(candidate);
|
|
4534
|
+
if (style.visibility === "hidden" || Number.parseFloat(style.opacity) < 0.01) {
|
|
4535
|
+
return false;
|
|
4536
|
+
}
|
|
4537
|
+
if (style.position !== "fixed" && style.position !== "absolute") return true;
|
|
4538
|
+
const clear = style.backgroundColor === "transparent" || style.backgroundColor === "rgba(0, 0, 0, 0)";
|
|
4539
|
+
if (!clear) return true;
|
|
4540
|
+
const box = candidate.getBoundingClientRect();
|
|
4541
|
+
const { clientWidth, clientHeight } = doc.documentElement;
|
|
4542
|
+
return !(clientWidth > 0 && clientHeight > 0 && box.width >= clientWidth * COVERS_PAGE && box.height >= clientHeight * COVERS_PAGE);
|
|
4543
|
+
};
|
|
4544
|
+
var isPickable = (candidate) => candidate.ownerDocument === document ? grabbable(candidate) : grabbableInFrame(candidate);
|
|
4545
|
+
var deepStack = (root, x, y) => {
|
|
4546
|
+
const stack = [];
|
|
4547
|
+
for (const el of root.elementsFromPoint(x, y)) {
|
|
4548
|
+
if (el.shadowRoot) stack.push(...deepStack(el.shadowRoot, x, y));
|
|
4549
|
+
stack.push(el);
|
|
4550
|
+
}
|
|
4551
|
+
return stack;
|
|
4552
|
+
};
|
|
4521
4553
|
var hitTest = (x, y) => {
|
|
4522
4554
|
const geo = frameGeometry();
|
|
4523
4555
|
if (!geo) return getElementAtPoint(x, y, { filter: grabbable });
|
|
@@ -4526,8 +4558,32 @@ var hitTest = (x, y) => {
|
|
|
4526
4558
|
if (!doc || x < box.left || x > box.right || y < box.top || y > box.bottom) {
|
|
4527
4559
|
return null;
|
|
4528
4560
|
}
|
|
4529
|
-
return doc
|
|
4561
|
+
return deepStack(doc, (x - box.left) / scale, (y - box.top) / scale).find(
|
|
4562
|
+
grabbableInFrame
|
|
4563
|
+
) ?? null;
|
|
4530
4564
|
};
|
|
4565
|
+
var pickableParent = (el) => {
|
|
4566
|
+
let parent = el.parentElement;
|
|
4567
|
+
while (parent && !isPickable(parent)) parent = parent.parentElement;
|
|
4568
|
+
return parent;
|
|
4569
|
+
};
|
|
4570
|
+
var pickableChild = (el) => {
|
|
4571
|
+
const queue = [...el.children];
|
|
4572
|
+
while (queue.length > 0) {
|
|
4573
|
+
const next = queue.shift();
|
|
4574
|
+
if (isPickable(next)) return next;
|
|
4575
|
+
queue.push(...next.children);
|
|
4576
|
+
}
|
|
4577
|
+
return null;
|
|
4578
|
+
};
|
|
4579
|
+
var pickableSibling = (el, step) => {
|
|
4580
|
+
let sibling = step === 1 ? el.nextElementSibling : el.previousElementSibling;
|
|
4581
|
+
while (sibling && !isPickable(sibling)) {
|
|
4582
|
+
sibling = step === 1 ? sibling.nextElementSibling : sibling.previousElementSibling;
|
|
4583
|
+
}
|
|
4584
|
+
return sibling;
|
|
4585
|
+
};
|
|
4586
|
+
var reducedMotion = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
4531
4587
|
var SELECTED_FLASH_MS = 900;
|
|
4532
4588
|
var tagLabel = (element, bounds) => `${element.tagName.toLowerCase()} \xB7 ${Math.round(bounds.width)}\xD7${Math.round(bounds.height)}`;
|
|
4533
4589
|
function Box({
|
|
@@ -4535,6 +4591,28 @@ function Box({
|
|
|
4535
4591
|
label,
|
|
4536
4592
|
tone
|
|
4537
4593
|
}) {
|
|
4594
|
+
const ref = useRef2(null);
|
|
4595
|
+
useEffect3(() => {
|
|
4596
|
+
const el = ref.current;
|
|
4597
|
+
if (tone !== "selected" || !el?.animate || reducedMotion()) return;
|
|
4598
|
+
const pop = el.animate(
|
|
4599
|
+
[
|
|
4600
|
+
{ transform: "scale(1.04)", opacity: 0.2 },
|
|
4601
|
+
{ transform: "scale(1)", opacity: 1 }
|
|
4602
|
+
],
|
|
4603
|
+
{ duration: 180, easing: "cubic-bezier(0.23, 1, 0.32, 1)" }
|
|
4604
|
+
);
|
|
4605
|
+
const fade2 = el.animate([{ opacity: 1 }, { opacity: 0 }], {
|
|
4606
|
+
duration: 220,
|
|
4607
|
+
delay: SELECTED_FLASH_MS - 220,
|
|
4608
|
+
easing: "ease-out",
|
|
4609
|
+
fill: "forwards"
|
|
4610
|
+
});
|
|
4611
|
+
return () => {
|
|
4612
|
+
pop.cancel();
|
|
4613
|
+
fade2.cancel();
|
|
4614
|
+
};
|
|
4615
|
+
}, [tone]);
|
|
4538
4616
|
const toneClass = {
|
|
4539
4617
|
hover: "border-2 border-accent bg-accent/15",
|
|
4540
4618
|
preview: "border border-accent bg-accent/10",
|
|
@@ -4545,6 +4623,7 @@ function Box({
|
|
|
4545
4623
|
return /* @__PURE__ */ jsx17(
|
|
4546
4624
|
"div",
|
|
4547
4625
|
{
|
|
4626
|
+
ref,
|
|
4548
4627
|
"data-react-grab-ignore": true,
|
|
4549
4628
|
className: `pointer-events-none fixed z-[9999] ${toneClass}`,
|
|
4550
4629
|
style: {
|
|
@@ -4552,7 +4631,9 @@ function Box({
|
|
|
4552
4631
|
top: bounds.y,
|
|
4553
4632
|
width: bounds.width,
|
|
4554
4633
|
height: bounds.height,
|
|
4555
|
-
borderRadius: bounds.borderRadius
|
|
4634
|
+
borderRadius: bounds.borderRadius,
|
|
4635
|
+
// the hover box glides to the next element instead of jumping
|
|
4636
|
+
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
4637
|
},
|
|
4557
4638
|
children: label ? /* @__PURE__ */ jsx17(
|
|
4558
4639
|
"span",
|
|
@@ -4582,6 +4663,7 @@ function DevGrabPicker({
|
|
|
4582
4663
|
const nextPickId = useRef2(1);
|
|
4583
4664
|
const [guideOpen, setGuideOpen] = useState5(() => !readGuideDismissed());
|
|
4584
4665
|
const [, setTick] = useState5(0);
|
|
4666
|
+
const climbed = useRef2([]);
|
|
4585
4667
|
useEffect3(() => {
|
|
4586
4668
|
const onKey = (event) => {
|
|
4587
4669
|
if (event.defaultPrevented) return;
|
|
@@ -4590,6 +4672,16 @@ function DevGrabPicker({
|
|
|
4590
4672
|
else onDone("cancelled");
|
|
4591
4673
|
return;
|
|
4592
4674
|
}
|
|
4675
|
+
const step = navigate(event);
|
|
4676
|
+
if (step) {
|
|
4677
|
+
event.preventDefault();
|
|
4678
|
+
return;
|
|
4679
|
+
}
|
|
4680
|
+
if (event.key === "Enter" && picks.length === 0 && hover && !dragStart) {
|
|
4681
|
+
event.preventDefault();
|
|
4682
|
+
void finish2([hover.element], "");
|
|
4683
|
+
return;
|
|
4684
|
+
}
|
|
4593
4685
|
if (event.key === "Enter" && picks.length > 0) {
|
|
4594
4686
|
const mod = event.metaKey || event.ctrlKey;
|
|
4595
4687
|
const onControl = event.target instanceof Element && event.target.closest("button, a, input, textarea, select");
|
|
@@ -4601,7 +4693,7 @@ function DevGrabPicker({
|
|
|
4601
4693
|
};
|
|
4602
4694
|
window.addEventListener("keydown", onKey);
|
|
4603
4695
|
return () => window.removeEventListener("keydown", onKey);
|
|
4604
|
-
}, [onDone, noteFor, picks]);
|
|
4696
|
+
}, [onDone, noteFor, picks, hover, dragStart]);
|
|
4605
4697
|
useEffect3(() => {
|
|
4606
4698
|
if (picks.length === 0) return;
|
|
4607
4699
|
let frame2 = 0;
|
|
@@ -4621,6 +4713,44 @@ function DevGrabPicker({
|
|
|
4621
4713
|
return () => cancelAnimationFrame(frame2);
|
|
4622
4714
|
}, [picks]);
|
|
4623
4715
|
const pick = hitTest;
|
|
4716
|
+
const navigate = (event) => {
|
|
4717
|
+
if (!hover || noteFor !== null || event.metaKey || event.ctrlKey || event.altKey) {
|
|
4718
|
+
return false;
|
|
4719
|
+
}
|
|
4720
|
+
if (event.target instanceof Element && event.target.closest("input, textarea, select")) {
|
|
4721
|
+
return false;
|
|
4722
|
+
}
|
|
4723
|
+
const current = hover.element;
|
|
4724
|
+
let next = null;
|
|
4725
|
+
switch (event.key) {
|
|
4726
|
+
case "ArrowUp":
|
|
4727
|
+
next = pickableParent(current);
|
|
4728
|
+
if (next) climbed.current.push(current);
|
|
4729
|
+
break;
|
|
4730
|
+
case "ArrowDown": {
|
|
4731
|
+
const back = climbed.current[climbed.current.length - 1];
|
|
4732
|
+
if (back && current.contains(back)) {
|
|
4733
|
+
next = back;
|
|
4734
|
+
climbed.current.pop();
|
|
4735
|
+
} else {
|
|
4736
|
+
next = pickableChild(current);
|
|
4737
|
+
}
|
|
4738
|
+
break;
|
|
4739
|
+
}
|
|
4740
|
+
case "ArrowLeft":
|
|
4741
|
+
next = pickableSibling(current, -1);
|
|
4742
|
+
break;
|
|
4743
|
+
case "ArrowRight":
|
|
4744
|
+
next = pickableSibling(current, 1);
|
|
4745
|
+
break;
|
|
4746
|
+
default:
|
|
4747
|
+
return false;
|
|
4748
|
+
}
|
|
4749
|
+
if (!next) return true;
|
|
4750
|
+
if (event.key === "ArrowLeft" || event.key === "ArrowRight") climbed.current = [];
|
|
4751
|
+
setHover({ element: next, bounds: getElementBounds(next) });
|
|
4752
|
+
return true;
|
|
4753
|
+
};
|
|
4624
4754
|
const dragging = dragStart && dragEnd && Math.abs(dragEnd.x - dragStart.x) + Math.abs(dragEnd.y - dragStart.y) >= DRAG_THRESHOLD;
|
|
4625
4755
|
const rect = dragging && dragStart && dragEnd ? toRect(dragStart, dragEnd) : null;
|
|
4626
4756
|
const collectRegion = (area) => {
|
|
@@ -4680,7 +4810,7 @@ ${problems}` : ""}`;
|
|
|
4680
4810
|
return {
|
|
4681
4811
|
key,
|
|
4682
4812
|
bounds,
|
|
4683
|
-
label: name ? `<${name}>` : tagLabel(el, bounds)
|
|
4813
|
+
label: `${copied ? "\u2713 " : ""}${name ? `<${name}>` : tagLabel(el, bounds)}`
|
|
4684
4814
|
};
|
|
4685
4815
|
})
|
|
4686
4816
|
);
|
|
@@ -4746,6 +4876,7 @@ ${problems}` : ""}`;
|
|
|
4746
4876
|
}
|
|
4747
4877
|
const element = pick(event.clientX, event.clientY);
|
|
4748
4878
|
if (!element) return setHover(null);
|
|
4879
|
+
if (element !== hover?.element) climbed.current = [];
|
|
4749
4880
|
setHover(
|
|
4750
4881
|
(prev) => prev?.element === element ? prev : { element, bounds: getElementBounds(element) }
|
|
4751
4882
|
);
|
|
@@ -6575,7 +6706,7 @@ function viewport() {
|
|
|
6575
6706
|
import { useEffect as useEffect6, useState as useState8, useSyncExternalStore as useSyncExternalStore6 } from "react";
|
|
6576
6707
|
import { RulerIcon as RulerIcon2, SquareDashedIcon } from "lucide-react";
|
|
6577
6708
|
|
|
6578
|
-
// src/
|
|
6709
|
+
// src/plugins/breakpoint/breakpoints.ts
|
|
6579
6710
|
var DEFAULT_BREAKPOINTS = {
|
|
6580
6711
|
sm: "40rem",
|
|
6581
6712
|
md: "48rem",
|
|
@@ -7288,7 +7419,7 @@ function redact(key, value, pattern) {
|
|
|
7288
7419
|
return isRedacted2(key, pattern) ? redactedForm(value) : value;
|
|
7289
7420
|
}
|
|
7290
7421
|
|
|
7291
|
-
// src/
|
|
7422
|
+
// src/plugins/storage/view.ts
|
|
7292
7423
|
var STORAGE_STORES = ["localStorage", "sessionStorage", "cookies"];
|
|
7293
7424
|
var OWN_PREFIX = "devbelt:";
|
|
7294
7425
|
var reasonOf = (e) => e instanceof Error && e.message ? e.message : "blocked by the browser";
|
|
@@ -7443,7 +7574,7 @@ function clearStorageStore(store) {
|
|
|
7443
7574
|
}
|
|
7444
7575
|
}
|
|
7445
7576
|
|
|
7446
|
-
// src/
|
|
7577
|
+
// src/plugins/storage/watch.ts
|
|
7447
7578
|
var LISTENERS = "__devbeltStorageListeners";
|
|
7448
7579
|
var PATCHED = "__devbeltStoragePatched";
|
|
7449
7580
|
var COOKIE_POLL_MS = 500;
|
|
@@ -8027,4 +8158,4 @@ export {
|
|
|
8027
8158
|
storage,
|
|
8028
8159
|
defaultPlugins
|
|
8029
8160
|
};
|
|
8030
|
-
//# sourceMappingURL=chunk-
|
|
8161
|
+
//# sourceMappingURL=chunk-SYBN2CEO.js.map
|