@surfaces-ui/devtools 0.0.0-stage → 0.2.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.
@@ -0,0 +1,379 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ControlIcon, ThemeProvider, useOptionalTheme } from "@surfaces-ui/components";
3
+ import { browserStorage } from "@surfaces-ui/data";
4
+ import { INSPECT_COMPONENT, INSPECT_MARK, INSPECT_POINTED, createRecorder, performanceTracks } from "@surfaces-ui/trace";
5
+ import { TraceProvider } from "@surfaces-ui/trace/react";
6
+ import { Suspense, lazy, useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
7
+ import { createPortal } from "react-dom";
8
+ import { SHELL_CSS, addStyles } from "./styles.js";
9
+ // The panel is a module of its own, fetched the first time the tools are opened: an app that never opens them,
10
+ // or has them off, loads none of it.
11
+ const Panel = lazy(() => import("./Panel.js"));
12
+ /** True in a development build. A bundler replaces `process.env.NODE_ENV`; where nothing does, the tools stay off. */
13
+ function development() {
14
+ try {
15
+ return process.env.NODE_ENV !== "production";
16
+ }
17
+ catch {
18
+ return false;
19
+ }
20
+ }
21
+ /**
22
+ * Developer tools for an app built on Surfaces UI. Place it once, around the
23
+ * app: it records what the library does inside it (messages in, components
24
+ * drawn, problems, state, events out, agent turns, service calls) with no
25
+ * other wiring, and shows a small button, and Ctrl+Shift+D, that open a panel
26
+ * docked to the bottom or the side, with time travel over every surface.
27
+ *
28
+ * Off, it renders its children and nothing else, records nothing, and loads
29
+ * no panel code. A trace never holds row values or credentials.
30
+ */
31
+ export function SurfacesDevTools({ children, enabled, ...rest }) {
32
+ if (!(enabled ?? development()))
33
+ return _jsx(_Fragment, { children: children });
34
+ return _jsx(Enabled, { ...rest, children: children });
35
+ }
36
+ function Enabled({ children, limit, recorder: given, performanceTracks: tracks = false, ...shell }) {
37
+ const recorder = useMemo(() => given ?? createRecorder({ limit }), [given, limit]);
38
+ useEffect(() => (tracks ? performanceTracks(recorder) : undefined), [tracks, recorder]);
39
+ return (_jsxs(TraceProvider, { recorder: recorder, children: [children, _jsx(TraceProvider, { recorder: undefined, children: _jsx(Shell, { recorder: recorder, ...shell }) })] }));
40
+ }
41
+ const STORE = "surfaces.devtools";
42
+ /** Where the panel was left. Saved text is checked: anything else is ignored. */
43
+ const readKept = (text) => {
44
+ try {
45
+ const value = JSON.parse(text ?? "{}");
46
+ if (!value || typeof value !== "object")
47
+ return {};
48
+ return {
49
+ ...(typeof value.open === "boolean" ? { open: value.open } : {}),
50
+ ...(value.dock === "bottom" || value.dock === "right" ? { dock: value.dock } : {}),
51
+ ...(typeof value.size === "number" && Number.isFinite(value.size) ? { size: value.size } : {}),
52
+ };
53
+ }
54
+ catch {
55
+ return {};
56
+ }
57
+ };
58
+ const MIN_SIZE = 160;
59
+ const STEP = 32;
60
+ const ToolsIcon = (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M4 6h16v12H4z M4 10h16 M8 14l2 2-2 2 M13 18h4" }) }));
61
+ const PickIcon = (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M4 4h12v6 M4 4v12h6 M12 12l8 3-3.5 1.5L15 20z" }) }));
62
+ const PopOutIcon = (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M14 4h6v6 M20 4l-8 8 M18 14v6H4V6h6" }) }));
63
+ const DockBottomIcon = (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M4 5h16v14H4z M4 14h16" }) }));
64
+ const DockRightIcon = (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M4 5h16v14H4z M14 5v14" }) }));
65
+ function Shell({ recorder, defaultOpen = false, defaultDock = "bottom", shortcut = true, anchor = "window", catalog, renderers, onOpenChange, storage }) {
66
+ const inline = anchor === "inline";
67
+ const store = useMemo(() => (inline ? null : storage === undefined ? browserStorage() : storage), [inline, storage]);
68
+ // Storage that answers at once (the browser's) places the panel on the first draw; one that answers later moves it then.
69
+ const first = useMemo(() => {
70
+ try {
71
+ return store?.load(STORE);
72
+ }
73
+ catch {
74
+ return undefined;
75
+ }
76
+ }, [store]);
77
+ const kept = useMemo(() => (typeof first === "string" ? readKept(first) : {}), [first]);
78
+ const [open, setOpenState] = useState(kept.open ?? defaultOpen);
79
+ const [dock, setDock] = useState(kept.dock ?? defaultDock);
80
+ const [size, setSize] = useState(kept.size);
81
+ const [popped, setPopped] = useState();
82
+ const [blocked, setBlocked] = useState(false);
83
+ const button = useRef(null);
84
+ const panel = useRef(null);
85
+ const theme = useOptionalTheme();
86
+ useEffect(() => addStyles(document, "sf-devtools-shell-css", SHELL_CSS), []);
87
+ const [loaded, setLoaded] = useState(!(first instanceof Promise));
88
+ useEffect(() => {
89
+ if (!(first instanceof Promise))
90
+ return;
91
+ let cancelled = false;
92
+ void first
93
+ .then((text) => {
94
+ if (cancelled)
95
+ return;
96
+ const later = readKept(text);
97
+ if (later.open !== undefined)
98
+ setOpenState(later.open);
99
+ if (later.dock)
100
+ setDock(later.dock);
101
+ if (later.size !== undefined)
102
+ setSize(later.size);
103
+ })
104
+ .catch(() => { })
105
+ .finally(() => !cancelled && setLoaded(true));
106
+ return () => {
107
+ cancelled = true;
108
+ };
109
+ }, [first]);
110
+ useEffect(() => {
111
+ // Nothing is saved until what was kept has been read, so the defaults never overwrite it.
112
+ if (!store || !loaded)
113
+ return;
114
+ void Promise.resolve(store.save(STORE, JSON.stringify({ open, dock, ...(size !== undefined ? { size } : {}) }))).catch(() => { });
115
+ }, [store, loaded, open, dock, size]);
116
+ const setOpen = useCallback((next) => {
117
+ setOpenState(next);
118
+ onOpenChange?.(next);
119
+ }, [onOpenChange]);
120
+ const moved = useRef(false);
121
+ const toggle = useCallback(() => {
122
+ moved.current = true;
123
+ setOpen(!open);
124
+ }, [open, setOpen]);
125
+ // Focus follows a person's own open or close: into the panel, and back to the button.
126
+ useEffect(() => {
127
+ if (!moved.current)
128
+ return;
129
+ moved.current = false;
130
+ if (open)
131
+ panel.current?.focus();
132
+ else
133
+ button.current?.focus();
134
+ }, [open]);
135
+ useEffect(() => {
136
+ if (!shortcut)
137
+ return;
138
+ const onKey = (event) => {
139
+ if (!(event.ctrlKey || event.metaKey) || !event.shiftKey || event.altKey || event.key.toLowerCase() !== "d")
140
+ return;
141
+ event.preventDefault();
142
+ toggle();
143
+ };
144
+ window.addEventListener("keydown", onKey);
145
+ return () => window.removeEventListener("keydown", onKey);
146
+ }, [shortcut, toggle]);
147
+ // The page makes room for a docked panel, so nothing is left underneath it.
148
+ const docked = open && !popped && !inline;
149
+ // To begin with: about half the window, within sensible bounds.
150
+ const room = typeof window === "undefined" ? 800 : dock === "bottom" ? window.innerHeight : window.innerWidth;
151
+ const span = size ?? Math.round(Math.max(dock === "bottom" ? 320 : 360, Math.min(640, room * (dock === "bottom" ? 0.6 : 0.42))));
152
+ useEffect(() => {
153
+ if (!docked)
154
+ return;
155
+ const narrow = window.matchMedia?.("(max-width: 40rem)").matches;
156
+ const side = dock === "bottom" || narrow ? "paddingBottom" : "paddingRight";
157
+ const body = document.body;
158
+ const before = body.style[side];
159
+ body.style[side] = `${span}px`;
160
+ return () => {
161
+ body.style[side] = before;
162
+ };
163
+ }, [docked, dock, span]);
164
+ // A window of its own: the same panel, on the same recorder, drawn into another window's document.
165
+ const popOut = () => {
166
+ const other = window.open("", "surfaces-devtools", "popup,width=1200,height=760");
167
+ if (!other)
168
+ return setBlocked(true);
169
+ setBlocked(false);
170
+ other.document.title = "Surfaces dev tools";
171
+ other.document.body.replaceChildren();
172
+ other.document.body.style.margin = "0";
173
+ const mount = other.document.createElement("div");
174
+ mount.style.cssText = "display:flex;flex-direction:column;height:100vh";
175
+ other.document.body.appendChild(mount);
176
+ setPopped({ window: other, mount });
177
+ };
178
+ useEffect(() => {
179
+ if (!popped)
180
+ return;
181
+ const other = popped.window;
182
+ // The window looks as the page does: its stylesheets and theme are copied over, and again when they change.
183
+ const copy = () => {
184
+ const root = document.documentElement;
185
+ for (const attribute of [...other.document.documentElement.attributes])
186
+ other.document.documentElement.removeAttribute(attribute.name);
187
+ for (const attribute of [...root.attributes])
188
+ other.document.documentElement.setAttribute(attribute.name, attribute.value);
189
+ for (const old of [...other.document.head.querySelectorAll("[data-sf-copied]")])
190
+ old.remove();
191
+ for (const sheet of document.querySelectorAll('style, link[rel="stylesheet"]')) {
192
+ const clone = other.document.importNode(sheet, true);
193
+ clone.setAttribute("data-sf-copied", "");
194
+ other.document.head.appendChild(clone);
195
+ }
196
+ other.document.body.style.background = "var(--sf-color-bg)";
197
+ };
198
+ copy();
199
+ let waiting = 0;
200
+ const watch = new MutationObserver(() => {
201
+ window.clearTimeout(waiting);
202
+ waiting = window.setTimeout(copy, 100);
203
+ });
204
+ watch.observe(document.documentElement, { attributes: true });
205
+ watch.observe(document.head, { childList: true, subtree: true, characterData: true });
206
+ for (const style of document.body.querySelectorAll("style[data-sf-theme]"))
207
+ watch.observe(style, { childList: true, characterData: true, subtree: true });
208
+ const closed = () => setPopped(undefined);
209
+ other.addEventListener("pagehide", closed);
210
+ const poll = window.setInterval(() => other.closed && closed(), 500);
211
+ const leave = () => other.close();
212
+ window.addEventListener("pagehide", leave);
213
+ return () => {
214
+ watch.disconnect();
215
+ window.clearTimeout(waiting);
216
+ window.clearInterval(poll);
217
+ other.removeEventListener("pagehide", closed);
218
+ window.removeEventListener("pagehide", leave);
219
+ other.close();
220
+ };
221
+ }, [popped]);
222
+ const drag = useRef(undefined);
223
+ const along = (event) => (dock === "bottom" || window.matchMedia?.("(max-width: 40rem)").matches ? -event.clientY : -event.clientX);
224
+ const limit = () => Math.max(MIN_SIZE, (dock === "bottom" ? window.innerHeight : window.innerWidth) - 80);
225
+ const resize = (to) => setSize(Math.round(Math.max(MIN_SIZE, Math.min(limit(), to))));
226
+ const onGripKey = (event) => {
227
+ const grow = dock === "bottom" ? "ArrowUp" : "ArrowLeft";
228
+ const shrink = dock === "bottom" ? "ArrowDown" : "ArrowRight";
229
+ if (event.key !== grow && event.key !== shrink)
230
+ return;
231
+ event.preventDefault();
232
+ resize(span + (event.key === grow ? STEP : -STEP));
233
+ };
234
+ const errors = useSyncExternalStore(recorder.subscribe, () => recorder.get().events.reduce((n, event) => n + (event.status === "error" ? 1 : 0), 0), () => 0);
235
+ // The backends the page's providers handed over, kept current as providers come and go.
236
+ const [services, setServices] = useState({});
237
+ useEffect(() => {
238
+ const read = () => setServices((held) => {
239
+ const next = { dataSource: recorder.service("dataSource"), discovery: recorder.service("discovery"), pipelines: recorder.service("pipelines"), semantics: recorder.service("semantics") };
240
+ return Object.keys(next).every((key) => held[key] === next[key]) ? held : next;
241
+ });
242
+ read();
243
+ return recorder.subscribe(read);
244
+ }, [recorder]);
245
+ const inspected = useSyncExternalStore(recorder.onInspect, recorder.inspected, () => undefined);
246
+ const picking = useSyncExternalStore(recorder.onInspect, recorder.picking, () => false);
247
+ // Picking ends with the tools: closed, nothing is left catching presses on the page.
248
+ useEffect(() => {
249
+ if (!open)
250
+ recorder.pick(false);
251
+ return () => recorder.pick(false);
252
+ }, [open, recorder]);
253
+ const view = (inWindow) => (_jsx(Suspense, { fallback: _jsx("p", { className: "sf-devtools-wait", role: "status", children: "Loading dev tools\u2026" }), children: _jsx(Panel, { feed: recorder, onClear: recorder.clear, onInspect: recorder.inspect, inspected: inspected, catalog: catalog, renderers: renderers, services: services, actions: _jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "sf-devtools-icon", "aria-pressed": picking, "aria-label": "Pick a component on the page", title: picking ? "Picking: press a component on the page, or Escape" : "Pick a component on the page", onClick: () => recorder.pick(!picking), children: _jsx(ControlIcon, { icon: PickIcon }) }), !inWindow && !inline && (_jsx("button", { type: "button", className: "sf-devtools-icon sf-devtools-dockside", "aria-label": dock === "bottom" ? "Dock to the side" : "Dock to the bottom", title: dock === "bottom" ? "Dock to the side" : "Dock to the bottom", onClick: () => setDock(dock === "bottom" ? "right" : "bottom"), children: _jsx(ControlIcon, { icon: dock === "bottom" ? DockRightIcon : DockBottomIcon }) })), !inWindow && (_jsx("button", { type: "button", className: "sf-devtools-icon", "aria-label": "Open in a window of its own", title: "Open in a window of its own", onClick: popOut, children: _jsx(ControlIcon, { icon: PopOutIcon }) })), _jsx("button", { type: "button", className: "sf-devtools-icon", "aria-label": inWindow ? "Put back in the page" : "Close dev tools", title: inWindow ? "Put back in the page" : "Close dev tools (Ctrl+Shift+D)", onClick: () => (inWindow ? setPopped(undefined) : toggle()), children: _jsx(ControlIcon, { icon: inWindow ? "fold" : "close" }) })] }) }) }));
254
+ // A host with no theme of its own still gets a readable panel.
255
+ const themed = (node) => (theme ? node : _jsx(ThemeProvider, { scope: "scoped", storage: null, children: node }));
256
+ const count = errors > 0 ? _jsx("span", { className: "sf-devtools-count", children: errors }) : null;
257
+ const parts = (_jsxs(_Fragment, { children: [(!open || popped) && (_jsxs("button", { ref: button, type: "button", className: "sf-devtools-button", "aria-expanded": open, "aria-label": `${open ? "Close" : "Open"} dev tools${errors > 0 ? `, ${errors} failed` : ""}`, title: "Dev tools (Ctrl+Shift+D)", onClick: toggle, children: [ToolsIcon, count] })), blocked && (_jsx("p", { className: "sf-devtools-wait", role: "alert", children: "The browser did not allow a new window. Allow pop-ups for this page and try again." })), open && !popped && (_jsxs("div", { ref: panel, tabIndex: -1, className: "sf-devtools-dock", "data-dock": dock, style: inline ? { height: span } : dock === "bottom" ? { height: span } : { width: span, ["--sf-devtools-span"]: `${span}px` }, children: [!inline && (_jsx("div", { role: "separator", tabIndex: 0, "aria-label": "Resize dev tools", "aria-orientation": dock === "bottom" ? "horizontal" : "vertical", "aria-valuenow": span, "aria-valuemin": MIN_SIZE, "aria-valuemax": typeof window === "undefined" ? span : limit(), className: "sf-devtools-grip", onKeyDown: onGripKey, onPointerDown: (event) => {
258
+ event.currentTarget.setPointerCapture?.(event.pointerId);
259
+ drag.current = { from: along(event), size: span };
260
+ }, onPointerMove: (event) => drag.current && resize(drag.current.size + (along(event) - drag.current.from)), onPointerUp: () => (drag.current = undefined), onPointerCancel: () => (drag.current = undefined) })), _jsx("div", { className: "sf-devtools-host", children: view(false) })] })), _jsx(InspectOverlay, { recorder: recorder }), popped && createPortal(themed(view(true)), popped.mount)] }));
261
+ return themed(inline ? _jsx("div", { className: "sf-devtools-inline", children: parts }) : parts);
262
+ }
263
+ /** The drawn component an element of the page belongs to: the nearest one, going up, with a mark before it. */
264
+ function componentAt(start) {
265
+ for (let node = start; node && node !== document.body; node = node.parentElement) {
266
+ const mark = node.previousElementSibling;
267
+ const surfaceKey = mark?.tagName === "TEMPLATE" ? mark.getAttribute(INSPECT_MARK) : null;
268
+ const componentId = mark?.getAttribute(INSPECT_COMPONENT);
269
+ if (surfaceKey && componentId)
270
+ return { surfaceKey, componentId, element: node };
271
+ }
272
+ return undefined;
273
+ }
274
+ const OWN = ".sf-devtools-dock, .sf-devtools-button, .sf-devtools, .sf-devtools-inline";
275
+ /**
276
+ * Outlines, on the page, the component picked in the panel, and while picking is on, the one under the pointer; a
277
+ * press then picks it instead of reaching the page. The surface that drew a component puts a mark before it; this
278
+ * follows the element after the mark as the page scrolls and resizes. The outline takes no presses and is hidden
279
+ * from assistive technology: the panel says which component is picked, and its Components list picks one by keyboard.
280
+ */
281
+ function InspectOverlay({ recorder }) {
282
+ const target = useSyncExternalStore(recorder.onInspect, recorder.inspected, () => undefined);
283
+ const picking = useSyncExternalStore(recorder.onInspect, recorder.picking, () => false);
284
+ const box = useRef(null);
285
+ const hovered = useRef(undefined);
286
+ useEffect(() => {
287
+ if (!picking)
288
+ return;
289
+ const mine = (event) => event.target instanceof Element && event.target.closest(OWN) !== null;
290
+ const move = (event) => {
291
+ hovered.current = mine(event) ? undefined : componentAt(event.target)?.element;
292
+ };
293
+ const press = (event) => {
294
+ if (mine(event))
295
+ return;
296
+ // The page does not get this press: it picks a component, or nothing.
297
+ event.preventDefault();
298
+ event.stopPropagation();
299
+ if (event.type !== "click")
300
+ return;
301
+ const found = componentAt(event.target);
302
+ if (found)
303
+ recorder.inspect({ surfaceKey: found.surfaceKey, componentId: found.componentId });
304
+ recorder.pick(false);
305
+ };
306
+ const key = (event) => {
307
+ if (event.key === "Escape")
308
+ recorder.pick(false);
309
+ };
310
+ const pressed = ["pointerdown", "mousedown", "pointerup", "mouseup", "click"];
311
+ document.addEventListener("pointermove", move, true);
312
+ for (const name of pressed)
313
+ document.addEventListener(name, press, true);
314
+ document.addEventListener("keydown", key, true);
315
+ document.documentElement.classList.add("sf-devtools-picking");
316
+ return () => {
317
+ document.removeEventListener("pointermove", move, true);
318
+ for (const name of pressed)
319
+ document.removeEventListener(name, press, true);
320
+ document.removeEventListener("keydown", key, true);
321
+ document.documentElement.classList.remove("sf-devtools-picking");
322
+ hovered.current = undefined;
323
+ };
324
+ }, [picking, recorder]);
325
+ useEffect(() => {
326
+ const el = box.current;
327
+ if ((!target && !picking) || !el)
328
+ return;
329
+ let frame = 0;
330
+ let shown;
331
+ const pointed = () => {
332
+ let next = document.querySelector(`template[${INSPECT_POINTED}]`)?.nextElementSibling ?? undefined;
333
+ while (next && next.tagName === "TEMPLATE")
334
+ next = next.nextElementSibling ?? undefined;
335
+ return next;
336
+ };
337
+ const place = () => {
338
+ frame = requestAnimationFrame(place);
339
+ const found = picking ? (hovered.current?.isConnected ? hovered.current : undefined) : pointed();
340
+ if (!picking && found && found !== shown) {
341
+ shown = found;
342
+ // Brought into view once, without animation, clear of the tools' own drawer.
343
+ reveal(found);
344
+ }
345
+ const rect = found?.getBoundingClientRect();
346
+ if (!rect || (rect.width === 0 && rect.height === 0)) {
347
+ el.hidden = true;
348
+ return;
349
+ }
350
+ el.hidden = false;
351
+ el.style.transform = `translate(${rect.left}px, ${rect.top}px)`;
352
+ el.style.width = `${rect.width}px`;
353
+ el.style.height = `${rect.height}px`;
354
+ };
355
+ place();
356
+ return () => {
357
+ cancelAnimationFrame(frame);
358
+ el.hidden = true;
359
+ };
360
+ }, [target, picking]);
361
+ if (!target && !picking)
362
+ return null;
363
+ return createPortal(_jsx("div", { ref: box, className: "sf-devtools-inspect", "aria-hidden": "true", hidden: true }), document.body);
364
+ }
365
+ /** Scrolls an element of the page into view, keeping it out from under the docked tools. */
366
+ function reveal(element) {
367
+ const dock = document.querySelector(".sf-devtools-dock");
368
+ const styled = element instanceof HTMLElement ? element : undefined;
369
+ const rect = dock?.getBoundingClientRect();
370
+ const side = dock?.dataset.dock === "right" ? "scrollMarginRight" : "scrollMarginBottom";
371
+ const before = styled?.style[side];
372
+ // A scroll margin for this one scroll, then put back: the page's own styles are left as they were.
373
+ if (styled && rect)
374
+ styled.style[side] = `${Math.round(side === "scrollMarginRight" ? rect.width : rect.height)}px`;
375
+ element.scrollIntoView?.({ block: "nearest", inline: "nearest" });
376
+ if (styled && rect)
377
+ styled.style[side] = before ?? "";
378
+ }
379
+ //# sourceMappingURL=SurfacesDevTools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SurfacesDevTools.js","sourceRoot":"","sources":["../src/SurfacesDevTools.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAqB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGtE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,eAAe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C,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IACpH,OAAO,CAAC,cAAc,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAClE,IAAI,MAAM,IAAI,IAAI;QAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,EAAE,CAAC;AACxD,CAAC","sourcesContent":["import { ControlIcon, ThemeProvider, useOptionalTheme } from \"@surfaces-ui/components\";\nimport { type StateStorage, browserStorage } from \"@surfaces-ui/data\";\nimport type { Catalog } from \"@surfaces-ui/spec\";\nimport type { ComponentRenderer } from \"@surfaces-ui/spec/react\";\nimport { INSPECT_COMPONENT, INSPECT_MARK, INSPECT_POINTED, type InspectTarget, type Recorder, createRecorder, performanceTracks } from \"@surfaces-ui/trace\";\nimport { TraceProvider } from \"@surfaces-ui/trace/react\";\nimport { type KeyboardEvent, type PointerEvent, type ReactNode, Suspense, lazy, useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { DevToolsServices } from \"./Panel.js\";\nimport { SHELL_CSS, addStyles } from \"./styles.js\";\n\n// The panel is a module of its own, fetched the first time the tools are opened: an app that never opens them,\n// or has them off, loads none of it.\nconst Panel = lazy(() => import(\"./Panel.js\"));\n\nexport type DevToolsDock = \"bottom\" | \"right\";\n\nexport interface SurfacesDevToolsProps {\n /** The app. Everything inside is traced while the tools are on. */\n children?: ReactNode;\n /**\n * Whether the tools are there at all. Left out, they are on in a\n * development build and absent in production. Pass your own rule to offer\n * them to some people in production: `enabled={user.isDeveloper}`. Nothing\n * a visitor can set (a URL, a stored value) turns them on.\n */\n enabled?: boolean;\n /** The most events kept; the oldest are let go first. Default 2,000. */\n limit?: number;\n /** Open to begin with. */\n defaultOpen?: boolean;\n /** Which edge the panel docks to to begin with. A person can change it; on a narrow screen it is always the bottom. */\n defaultDock?: DevToolsDock;\n /** Whether Ctrl+Shift+D (⌘⇧D on a Mac) opens and closes the tools. Default true. */\n shortcut?: boolean;\n /**\n * \"window\" (the default) floats the button over the page's corner and docks the panel to the window.\n * \"inline\" keeps both in the flow where the component is placed, for a page that documents the tools.\n */\n anchor?: \"window\" | \"inline\";\n /** The catalog recorded surfaces are drawn with when shown again. Defaults to the analytics catalog. */\n catalog?: Catalog;\n renderers?: Record<string, ComponentRenderer>;\n /** Also show spans as custom tracks in the Performance panel of Chrome's developer tools. Default false. */\n performanceTracks?: boolean;\n /** Your own recorder, to read what is recorded from elsewhere (`recorder.get()`, `recorder.subscribe`). One is made when left out. */\n recorder?: Recorder;\n /** Told when the tools are opened or closed. */\n onOpenChange?(open: boolean): void;\n /**\n * Where the panel's place (open, dock, size) is kept between visits: the\n * browser by default, or any `StateStorage`. `null` keeps nothing. It only\n * arranges tools that are already on; nothing kept turns them on.\n */\n storage?: StateStorage | null;\n}\n\ndeclare const process: { env: { NODE_ENV?: string } };\n/** True in a development build. A bundler replaces `process.env.NODE_ENV`; where nothing does, the tools stay off. */\nfunction development(): boolean {\n try {\n return process.env.NODE_ENV !== \"production\";\n } catch {\n return false;\n }\n}\n\n/**\n * Developer tools for an app built on Surfaces UI. Place it once, around the\n * app: it records what the library does inside it (messages in, components\n * drawn, problems, state, events out, agent turns, service calls) with no\n * other wiring, and shows a small button, and Ctrl+Shift+D, that open a panel\n * docked to the bottom or the side, with time travel over every surface.\n *\n * Off, it renders its children and nothing else, records nothing, and loads\n * no panel code. A trace never holds row values or credentials.\n */\nexport function SurfacesDevTools({ children, enabled, ...rest }: SurfacesDevToolsProps) {\n if (!(enabled ?? development())) return <>{children}</>;\n return <Enabled {...rest}>{children}</Enabled>;\n}\n\nfunction Enabled({ children, limit, recorder: given, performanceTracks: tracks = false, ...shell }: Omit<SurfacesDevToolsProps, \"enabled\">) {\n const recorder = useMemo(() => given ?? createRecorder({ limit }), [given, limit]);\n useEffect(() => (tracks ? performanceTracks(recorder) : undefined), [tracks, recorder]);\n return (\n <TraceProvider recorder={recorder}>\n {children}\n {/* The tools do not trace themselves. */}\n <TraceProvider recorder={undefined}>\n <Shell recorder={recorder} {...shell} />\n </TraceProvider>\n </TraceProvider>\n );\n}\n\ninterface Kept {\n open?: boolean;\n dock?: DevToolsDock;\n size?: number;\n}\nconst STORE = \"surfaces.devtools\";\n/** Where the panel was left. Saved text is checked: anything else is ignored. */\nconst readKept = (text: string | null | undefined): Kept => {\n try {\n const value = JSON.parse(text ?? \"{}\") as Kept;\n if (!value || typeof value !== \"object\") return {};\n return {\n ...(typeof value.open === \"boolean\" ? { open: value.open } : {}),\n ...(value.dock === \"bottom\" || value.dock === \"right\" ? { dock: value.dock } : {}),\n ...(typeof value.size === \"number\" && Number.isFinite(value.size) ? { size: value.size } : {}),\n };\n } catch {\n return {};\n }\n};\n\nconst MIN_SIZE = 160;\nconst STEP = 32;\n\nconst ToolsIcon = (\n <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" focusable=\"false\">\n <path d=\"M4 6h16v12H4z M4 10h16 M8 14l2 2-2 2 M13 18h4\" />\n </svg>\n);\nconst PickIcon = (\n <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" focusable=\"false\">\n <path d=\"M4 4h12v6 M4 4v12h6 M12 12l8 3-3.5 1.5L15 20z\" />\n </svg>\n);\nconst PopOutIcon = (\n <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" focusable=\"false\">\n <path d=\"M14 4h6v6 M20 4l-8 8 M18 14v6H4V6h6\" />\n </svg>\n);\nconst DockBottomIcon = (\n <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" focusable=\"false\">\n <path d=\"M4 5h16v14H4z M4 14h16\" />\n </svg>\n);\nconst DockRightIcon = (\n <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" focusable=\"false\">\n <path d=\"M4 5h16v14H4z M14 5v14\" />\n </svg>\n);\n\nfunction Shell({ recorder, defaultOpen = false, defaultDock = \"bottom\", shortcut = true, anchor = \"window\", catalog, renderers, onOpenChange, storage }: Omit<SurfacesDevToolsProps, \"enabled\" | \"children\" | \"limit\" | \"performanceTracks\" | \"recorder\"> & { recorder: Recorder }) {\n const inline = anchor === \"inline\";\n const store = useMemo(() => (inline ? null : storage === undefined ? browserStorage() : storage), [inline, storage]);\n // Storage that answers at once (the browser's) places the panel on the first draw; one that answers later moves it then.\n const first = useMemo(() => {\n try {\n return store?.load(STORE);\n } catch {\n return undefined;\n }\n }, [store]);\n const kept = useMemo(() => (typeof first === \"string\" ? readKept(first) : {}), [first]);\n const [open, setOpenState] = useState(kept.open ?? defaultOpen);\n const [dock, setDock] = useState<DevToolsDock>(kept.dock ?? defaultDock);\n const [size, setSize] = useState<number | undefined>(kept.size);\n const [popped, setPopped] = useState<{ window: Window; mount: HTMLElement } | undefined>();\n const [blocked, setBlocked] = useState(false);\n const button = useRef<HTMLButtonElement>(null);\n const panel = useRef<HTMLDivElement>(null);\n const theme = useOptionalTheme();\n\n useEffect(() => addStyles(document, \"sf-devtools-shell-css\", SHELL_CSS), []);\n const [loaded, setLoaded] = useState(!(first instanceof Promise));\n useEffect(() => {\n if (!(first instanceof Promise)) return;\n let cancelled = false;\n void first\n .then((text) => {\n if (cancelled) return;\n const later = readKept(text);\n if (later.open !== undefined) setOpenState(later.open);\n if (later.dock) setDock(later.dock);\n if (later.size !== undefined) setSize(later.size);\n })\n .catch(() => {})\n .finally(() => !cancelled && setLoaded(true));\n return () => {\n cancelled = true;\n };\n }, [first]);\n useEffect(() => {\n // Nothing is saved until what was kept has been read, so the defaults never overwrite it.\n if (!store || !loaded) return;\n void Promise.resolve(store.save(STORE, JSON.stringify({ open, dock, ...(size !== undefined ? { size } : {}) }))).catch(() => {});\n }, [store, loaded, open, dock, size]);\n\n const setOpen = useCallback(\n (next: boolean) => {\n setOpenState(next);\n onOpenChange?.(next);\n },\n [onOpenChange],\n );\n const moved = useRef(false);\n const toggle = useCallback(() => {\n moved.current = true;\n setOpen(!open);\n }, [open, setOpen]);\n // Focus follows a person's own open or close: into the panel, and back to the button.\n useEffect(() => {\n if (!moved.current) return;\n moved.current = false;\n if (open) panel.current?.focus();\n else button.current?.focus();\n }, [open]);\n\n useEffect(() => {\n if (!shortcut) return;\n const onKey = (event: globalThis.KeyboardEvent) => {\n if (!(event.ctrlKey || event.metaKey) || !event.shiftKey || event.altKey || event.key.toLowerCase() !== \"d\") return;\n event.preventDefault();\n toggle();\n };\n window.addEventListener(\"keydown\", onKey);\n return () => window.removeEventListener(\"keydown\", onKey);\n }, [shortcut, toggle]);\n\n // The page makes room for a docked panel, so nothing is left underneath it.\n const docked = open && !popped && !inline;\n // To begin with: about half the window, within sensible bounds.\n const room = typeof window === \"undefined\" ? 800 : dock === \"bottom\" ? window.innerHeight : window.innerWidth;\n const span = size ?? Math.round(Math.max(dock === \"bottom\" ? 320 : 360, Math.min(640, room * (dock === \"bottom\" ? 0.6 : 0.42))));\n useEffect(() => {\n if (!docked) return;\n const narrow = window.matchMedia?.(\"(max-width: 40rem)\").matches;\n const side = dock === \"bottom\" || narrow ? \"paddingBottom\" : \"paddingRight\";\n const body = document.body;\n const before = body.style[side];\n body.style[side] = `${span}px`;\n return () => {\n body.style[side] = before;\n };\n }, [docked, dock, span]);\n\n // A window of its own: the same panel, on the same recorder, drawn into another window's document.\n const popOut = () => {\n const other = window.open(\"\", \"surfaces-devtools\", \"popup,width=1200,height=760\");\n if (!other) return setBlocked(true);\n setBlocked(false);\n other.document.title = \"Surfaces dev tools\";\n other.document.body.replaceChildren();\n other.document.body.style.margin = \"0\";\n const mount = other.document.createElement(\"div\");\n mount.style.cssText = \"display:flex;flex-direction:column;height:100vh\";\n other.document.body.appendChild(mount);\n setPopped({ window: other, mount });\n };\n useEffect(() => {\n if (!popped) return;\n const other = popped.window;\n // The window looks as the page does: its stylesheets and theme are copied over, and again when they change.\n const copy = () => {\n const root = document.documentElement;\n for (const attribute of [...other.document.documentElement.attributes]) other.document.documentElement.removeAttribute(attribute.name);\n for (const attribute of [...root.attributes]) other.document.documentElement.setAttribute(attribute.name, attribute.value);\n for (const old of [...other.document.head.querySelectorAll(\"[data-sf-copied]\")]) old.remove();\n for (const sheet of document.querySelectorAll('style, link[rel=\"stylesheet\"]')) {\n const clone = other.document.importNode(sheet, true) as HTMLElement;\n clone.setAttribute(\"data-sf-copied\", \"\");\n other.document.head.appendChild(clone);\n }\n other.document.body.style.background = \"var(--sf-color-bg)\";\n };\n copy();\n let waiting = 0;\n const watch = new MutationObserver(() => {\n window.clearTimeout(waiting);\n waiting = window.setTimeout(copy, 100);\n });\n watch.observe(document.documentElement, { attributes: true });\n watch.observe(document.head, { childList: true, subtree: true, characterData: true });\n for (const style of document.body.querySelectorAll(\"style[data-sf-theme]\")) watch.observe(style, { childList: true, characterData: true, subtree: true });\n const closed = () => setPopped(undefined);\n other.addEventListener(\"pagehide\", closed);\n const poll = window.setInterval(() => other.closed && closed(), 500);\n const leave = () => other.close();\n window.addEventListener(\"pagehide\", leave);\n return () => {\n watch.disconnect();\n window.clearTimeout(waiting);\n window.clearInterval(poll);\n other.removeEventListener(\"pagehide\", closed);\n window.removeEventListener(\"pagehide\", leave);\n other.close();\n };\n }, [popped]);\n\n const drag = useRef<{ from: number; size: number } | undefined>(undefined);\n const along = (event: PointerEvent) => (dock === \"bottom\" || window.matchMedia?.(\"(max-width: 40rem)\").matches ? -event.clientY : -event.clientX);\n const limit = () => Math.max(MIN_SIZE, (dock === \"bottom\" ? window.innerHeight : window.innerWidth) - 80);\n const resize = (to: number) => setSize(Math.round(Math.max(MIN_SIZE, Math.min(limit(), to))));\n const onGripKey = (event: KeyboardEvent) => {\n const grow = dock === \"bottom\" ? \"ArrowUp\" : \"ArrowLeft\";\n const shrink = dock === \"bottom\" ? \"ArrowDown\" : \"ArrowRight\";\n if (event.key !== grow && event.key !== shrink) return;\n event.preventDefault();\n resize(span + (event.key === grow ? STEP : -STEP));\n };\n\n const errors = useSyncExternalStore(\n recorder.subscribe,\n () => recorder.get().events.reduce((n, event) => n + (event.status === \"error\" ? 1 : 0), 0),\n () => 0,\n );\n // The backends the page's providers handed over, kept current as providers come and go.\n const [services, setServices] = useState<DevToolsServices>({});\n useEffect(() => {\n const read = () =>\n setServices((held) => {\n const next: DevToolsServices = { dataSource: recorder.service(\"dataSource\"), discovery: recorder.service(\"discovery\"), pipelines: recorder.service(\"pipelines\"), semantics: recorder.service(\"semantics\") };\n return (Object.keys(next) as (keyof DevToolsServices)[]).every((key) => held[key] === next[key]) ? held : next;\n });\n read();\n return recorder.subscribe(read);\n }, [recorder]);\n\n const inspected = useSyncExternalStore(recorder.onInspect, recorder.inspected, () => undefined);\n const picking = useSyncExternalStore(recorder.onInspect, recorder.picking, () => false);\n // Picking ends with the tools: closed, nothing is left catching presses on the page.\n useEffect(() => {\n if (!open) recorder.pick(false);\n return () => recorder.pick(false);\n }, [open, recorder]);\n\n const view = (inWindow: boolean) => (\n <Suspense fallback={<p className=\"sf-devtools-wait\" role=\"status\">Loading dev tools…</p>}>\n <Panel\n feed={recorder}\n onClear={recorder.clear}\n onInspect={recorder.inspect}\n inspected={inspected}\n catalog={catalog}\n renderers={renderers}\n services={services}\n actions={\n <>\n <button type=\"button\" className=\"sf-devtools-icon\" aria-pressed={picking} aria-label=\"Pick a component on the page\" title={picking ? \"Picking: press a component on the page, or Escape\" : \"Pick a component on the page\"} onClick={() => recorder.pick(!picking)}>\n <ControlIcon icon={PickIcon} />\n </button>\n {!inWindow && !inline && (\n <button type=\"button\" className=\"sf-devtools-icon sf-devtools-dockside\" aria-label={dock === \"bottom\" ? \"Dock to the side\" : \"Dock to the bottom\"} title={dock === \"bottom\" ? \"Dock to the side\" : \"Dock to the bottom\"} onClick={() => setDock(dock === \"bottom\" ? \"right\" : \"bottom\")}>\n <ControlIcon icon={dock === \"bottom\" ? DockRightIcon : DockBottomIcon} />\n </button>\n )}\n {!inWindow && (\n <button type=\"button\" className=\"sf-devtools-icon\" aria-label=\"Open in a window of its own\" title=\"Open in a window of its own\" onClick={popOut}>\n <ControlIcon icon={PopOutIcon} />\n </button>\n )}\n <button\n type=\"button\"\n className=\"sf-devtools-icon\"\n aria-label={inWindow ? \"Put back in the page\" : \"Close dev tools\"}\n title={inWindow ? \"Put back in the page\" : \"Close dev tools (Ctrl+Shift+D)\"}\n onClick={() => (inWindow ? setPopped(undefined) : toggle())}\n >\n <ControlIcon icon={inWindow ? \"fold\" : \"close\"} />\n </button>\n </>\n }\n />\n </Suspense>\n );\n // A host with no theme of its own still gets a readable panel.\n const themed = (node: ReactNode) => (theme ? node : <ThemeProvider scope=\"scoped\" storage={null}>{node}</ThemeProvider>);\n\n const count = errors > 0 ? <span className=\"sf-devtools-count\">{errors}</span> : null;\n const parts = (\n <>\n {(!open || popped) && (\n <button ref={button} type=\"button\" className=\"sf-devtools-button\" aria-expanded={open} aria-label={`${open ? \"Close\" : \"Open\"} dev tools${errors > 0 ? `, ${errors} failed` : \"\"}`} title=\"Dev tools (Ctrl+Shift+D)\" onClick={toggle}>\n {ToolsIcon}\n {count}\n </button>\n )}\n {blocked && (\n <p className=\"sf-devtools-wait\" role=\"alert\">\n The browser did not allow a new window. Allow pop-ups for this page and try again.\n </p>\n )}\n {open && !popped && (\n <div\n ref={panel}\n tabIndex={-1}\n className=\"sf-devtools-dock\"\n data-dock={dock}\n style={inline ? { height: span } : dock === \"bottom\" ? { height: span } : { width: span, [\"--sf-devtools-span\" as string]: `${span}px` }}\n >\n {!inline && (\n <div\n role=\"separator\"\n tabIndex={0}\n aria-label=\"Resize dev tools\"\n aria-orientation={dock === \"bottom\" ? \"horizontal\" : \"vertical\"}\n aria-valuenow={span}\n aria-valuemin={MIN_SIZE}\n aria-valuemax={typeof window === \"undefined\" ? span : limit()}\n className=\"sf-devtools-grip\"\n onKeyDown={onGripKey}\n onPointerDown={(event) => {\n event.currentTarget.setPointerCapture?.(event.pointerId);\n drag.current = { from: along(event), size: span };\n }}\n onPointerMove={(event) => drag.current && resize(drag.current.size + (along(event) - drag.current.from))}\n onPointerUp={() => (drag.current = undefined)}\n onPointerCancel={() => (drag.current = undefined)}\n />\n )}\n <div className=\"sf-devtools-host\">{view(false)}</div>\n </div>\n )}\n <InspectOverlay recorder={recorder} />\n {popped && createPortal(themed(view(true)), popped.mount)}\n </>\n );\n return themed(inline ? <div className=\"sf-devtools-inline\">{parts}</div> : parts);\n}\n\n/** The drawn component an element of the page belongs to: the nearest one, going up, with a mark before it. */\nfunction componentAt(start: Element | null): (InspectTarget & { element: Element }) | undefined {\n for (let node = start; node && node !== document.body; node = node.parentElement) {\n const mark = node.previousElementSibling;\n const surfaceKey = mark?.tagName === \"TEMPLATE\" ? mark.getAttribute(INSPECT_MARK) : null;\n const componentId = mark?.getAttribute(INSPECT_COMPONENT);\n if (surfaceKey && componentId) return { surfaceKey, componentId, element: node };\n }\n return undefined;\n}\n\nconst OWN = \".sf-devtools-dock, .sf-devtools-button, .sf-devtools, .sf-devtools-inline\";\n\n/**\n * Outlines, on the page, the component picked in the panel, and while picking is on, the one under the pointer; a\n * press then picks it instead of reaching the page. The surface that drew a component puts a mark before it; this\n * follows the element after the mark as the page scrolls and resizes. The outline takes no presses and is hidden\n * from assistive technology: the panel says which component is picked, and its Components list picks one by keyboard.\n */\nfunction InspectOverlay({ recorder }: { recorder: Recorder }) {\n const target = useSyncExternalStore(recorder.onInspect, recorder.inspected, () => undefined);\n const picking = useSyncExternalStore(recorder.onInspect, recorder.picking, () => false);\n const box = useRef<HTMLDivElement>(null);\n const hovered = useRef<Element | undefined>(undefined);\n\n useEffect(() => {\n if (!picking) return;\n const mine = (event: Event) => event.target instanceof Element && event.target.closest(OWN) !== null;\n const move = (event: Event) => {\n hovered.current = mine(event) ? undefined : componentAt(event.target as Element | null)?.element;\n };\n const press = (event: Event) => {\n if (mine(event)) return;\n // The page does not get this press: it picks a component, or nothing.\n event.preventDefault();\n event.stopPropagation();\n if (event.type !== \"click\") return;\n const found = componentAt(event.target as Element | null);\n if (found) recorder.inspect({ surfaceKey: found.surfaceKey, componentId: found.componentId });\n recorder.pick(false);\n };\n const key = (event: globalThis.KeyboardEvent) => {\n if (event.key === \"Escape\") recorder.pick(false);\n };\n const pressed = [\"pointerdown\", \"mousedown\", \"pointerup\", \"mouseup\", \"click\"] as const;\n document.addEventListener(\"pointermove\", move, true);\n for (const name of pressed) document.addEventListener(name, press, true);\n document.addEventListener(\"keydown\", key, true);\n document.documentElement.classList.add(\"sf-devtools-picking\");\n return () => {\n document.removeEventListener(\"pointermove\", move, true);\n for (const name of pressed) document.removeEventListener(name, press, true);\n document.removeEventListener(\"keydown\", key, true);\n document.documentElement.classList.remove(\"sf-devtools-picking\");\n hovered.current = undefined;\n };\n }, [picking, recorder]);\n\n useEffect(() => {\n const el = box.current;\n if ((!target && !picking) || !el) return;\n let frame = 0;\n let shown: Element | undefined;\n const pointed = (): Element | undefined => {\n let next = document.querySelector(`template[${INSPECT_POINTED}]`)?.nextElementSibling ?? undefined;\n while (next && next.tagName === \"TEMPLATE\") next = next.nextElementSibling ?? undefined;\n return next;\n };\n const place = () => {\n frame = requestAnimationFrame(place);\n const found = picking ? (hovered.current?.isConnected ? hovered.current : undefined) : pointed();\n if (!picking && found && found !== shown) {\n shown = found;\n // Brought into view once, without animation, clear of the tools' own drawer.\n reveal(found);\n }\n const rect = found?.getBoundingClientRect();\n if (!rect || (rect.width === 0 && rect.height === 0)) {\n el.hidden = true;\n return;\n }\n el.hidden = false;\n el.style.transform = `translate(${rect.left}px, ${rect.top}px)`;\n el.style.width = `${rect.width}px`;\n el.style.height = `${rect.height}px`;\n };\n place();\n return () => {\n cancelAnimationFrame(frame);\n el.hidden = true;\n };\n }, [target, picking]);\n if (!target && !picking) return null;\n return createPortal(<div ref={box} className=\"sf-devtools-inspect\" aria-hidden=\"true\" hidden />, document.body);\n}\n\n/** Scrolls an element of the page into view, keeping it out from under the docked tools. */\nfunction reveal(element: Element): void {\n const dock = document.querySelector<HTMLElement>(\".sf-devtools-dock\");\n const styled = element instanceof HTMLElement ? element : undefined;\n const rect = dock?.getBoundingClientRect();\n const side = dock?.dataset.dock === \"right\" ? \"scrollMarginRight\" : \"scrollMarginBottom\";\n const before = styled?.style[side];\n // A scroll margin for this one scroll, then put back: the page's own styles are left as they were.\n if (styled && rect) styled.style[side] = `${Math.round(side === \"scrollMarginRight\" ? rect.width : rect.height)}px`;\n element.scrollIntoView?.({ block: \"nearest\", inline: \"nearest\" });\n if (styled && rect) styled.style[side] = before ?? \"\";\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { type AppComponentDoc } from "@surfaces-ui/components/app-components";
2
+ export declare const surfacesDevToolsDoc: AppComponentDoc;
3
+ export declare const appComponentDocs: AppComponentDoc[];
@@ -0,0 +1,32 @@
1
+ import { describeAppComponent } from "@surfaces-ui/components/app-components";
2
+ /*
3
+ * The dev tools as an app component: described once, as data, like the ones in
4
+ * @surfaces-ui/components. The playground draws its page from this and
5
+ * `pnpm docs:gen` writes docs/components.
6
+ */
7
+ export const surfacesDevToolsDoc = describeAppComponent()({
8
+ name: "SurfacesDevTools",
9
+ from: "@surfaces-ui/devtools",
10
+ description: "Developer tools for agent-generated UI. Placed once around an app, it records what the library does inside it with no other wiring: every message in (with its upgrade and what the catalog said), every component drawn, problems, state, events sent out, agent turns and service calls. A small button, and Ctrl+Shift+D, open a panel docked to the bottom or the side, resizable, which can move to a window of its own: a timeline, the raw messages, the component tree, state, events, services, and a scrubber that draws any surface as it stood at an earlier step. On in a development build and absent in production unless `enabled` says otherwise. A trace never holds row values or credentials, and the panel never calls a model.",
11
+ props: {
12
+ type: "object",
13
+ properties: {
14
+ enabled: { type: "boolean", description: "Whether the tools are there at all. Left out: on in a development build, absent in production. Off, the component renders its children and nothing else." },
15
+ limit: { type: "integer", minimum: 1, description: "The most events kept; the oldest are let go first.", default: 2000 },
16
+ defaultOpen: { type: "boolean", description: "Open to begin with." },
17
+ defaultDock: { type: "string", enum: ["bottom", "right"], description: "Which edge the panel docks to to begin with. On a narrow screen it is always the bottom." },
18
+ shortcut: { type: "boolean", description: "Whether Ctrl+Shift+D (⌘⇧D on a Mac) opens and closes the tools.", default: true },
19
+ anchor: { type: "string", enum: ["window", "inline"], description: "\"window\" floats the button over the page's corner and docks the panel to the window; \"inline\" keeps both where the component is placed." },
20
+ performanceTracks: { type: "boolean", description: "Also show spans as custom tracks in the Performance panel of Chrome's developer tools." },
21
+ },
22
+ },
23
+ parts: [
24
+ { prop: "children", label: "The app", description: "Everything inside is traced while the tools are on.", required: true },
25
+ { prop: "recorder", label: "Your own recorder", description: "A recorder from `createRecorder` in @surfaces-ui/trace, to read what is recorded from elsewhere." },
26
+ { prop: "catalog", label: "Your own catalog", description: "The catalog recorded surfaces are drawn with when shown again, with `renderers`. Defaults to the analytics catalog." },
27
+ ],
28
+ callbacks: [{ prop: "onOpenChange", description: "The tools were opened or closed." }],
29
+ example: { enabled: true, defaultOpen: true, anchor: "inline", defaultDock: "bottom" },
30
+ });
31
+ export const appComponentDocs = [surfacesDevToolsDoc];
32
+ //# sourceMappingURL=appComponents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appComponents.js","sourceRoot":"","sources":["../src/appComponents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,oBAAoB,EAAE,MAAM,wCAAwC,C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H,EAAE;KACnL;IACD,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;IACtF,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE;CACvF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAsB,CAAC,mBAAmB,CAAC,CAAC","sourcesContent":["import { type AppComponentDoc, describeAppComponent } from \"@surfaces-ui/components/app-components\";\nimport type { SurfacesDevToolsProps } from \"./SurfacesDevTools.js\";\n\n/*\n * The dev tools as an app component: described once, as data, like the ones in\n * @surfaces-ui/components. The playground draws its page from this and\n * `pnpm docs:gen` writes docs/components.\n */\nexport const surfacesDevToolsDoc = describeAppComponent<SurfacesDevToolsProps>()({\n name: \"SurfacesDevTools\",\n from: \"@surfaces-ui/devtools\",\n description:\n \"Developer tools for agent-generated UI. Placed once around an app, it records what the library does inside it with no other wiring: every message in (with its upgrade and what the catalog said), every component drawn, problems, state, events sent out, agent turns and service calls. A small button, and Ctrl+Shift+D, open a panel docked to the bottom or the side, resizable, which can move to a window of its own: a timeline, the raw messages, the component tree, state, events, services, and a scrubber that draws any surface as it stood at an earlier step. On in a development build and absent in production unless `enabled` says otherwise. A trace never holds row values or credentials, and the panel never calls a model.\",\n props: {\n type: \"object\",\n properties: {\n enabled: { type: \"boolean\", description: \"Whether the tools are there at all. Left out: on in a development build, absent in production. Off, the component renders its children and nothing else.\" },\n limit: { type: \"integer\", minimum: 1, description: \"The most events kept; the oldest are let go first.\", default: 2000 },\n defaultOpen: { type: \"boolean\", description: \"Open to begin with.\" },\n defaultDock: { type: \"string\", enum: [\"bottom\", \"right\"], description: \"Which edge the panel docks to to begin with. On a narrow screen it is always the bottom.\" },\n shortcut: { type: \"boolean\", description: \"Whether Ctrl+Shift+D (⌘⇧D on a Mac) opens and closes the tools.\", default: true },\n anchor: { type: \"string\", enum: [\"window\", \"inline\"], description: \"\\\"window\\\" floats the button over the page's corner and docks the panel to the window; \\\"inline\\\" keeps both where the component is placed.\" },\n performanceTracks: { type: \"boolean\", description: \"Also show spans as custom tracks in the Performance panel of Chrome's developer tools.\" },\n },\n },\n parts: [\n { prop: \"children\", label: \"The app\", description: \"Everything inside is traced while the tools are on.\", required: true },\n { prop: \"recorder\", label: \"Your own recorder\", description: \"A recorder from `createRecorder` in @surfaces-ui/trace, to read what is recorded from elsewhere.\" },\n { prop: \"catalog\", label: \"Your own catalog\", description: \"The catalog recorded surfaces are drawn with when shown again, with `renderers`. Defaults to the analytics catalog.\" },\n ],\n callbacks: [{ prop: \"onOpenChange\", description: \"The tools were opened or closed.\" }],\n example: { enabled: true, defaultOpen: true, anchor: \"inline\", defaultDock: \"bottom\" },\n});\n\nexport const appComponentDocs: AppComponentDoc[] = [surfacesDevToolsDoc];\n"]}
@@ -0,0 +1,38 @@
1
+ import { type Surface } from "@surfaces-ui/spec";
2
+ import type { TraceEvent } from "@surfaces-ui/trace";
3
+ /** One thing the recording says about why a component is the way it is. */
4
+ export interface Finding {
5
+ /** Which rule found it. */
6
+ rule: "refused" | "invalid" | "unreachable" | "container" | "binding" | "query-failed" | "render-failed" | "contract" | "no-rows" | "cancelled" | "slow";
7
+ /** "error" explains something broken, "warning" something that may be wrong, "info" something worth knowing. */
8
+ severity: "error" | "warning" | "info";
9
+ /** One sentence: what happened. */
10
+ title: string;
11
+ /** What the recording holds about it: a message, a path, a code. Never a row value. */
12
+ detail?: string;
13
+ /** The recorded event it was read from, to open. */
14
+ eventId?: string;
15
+ }
16
+ export interface CauseInput {
17
+ events: readonly TraceEvent[];
18
+ /** The key the surface is held under, and the surface as it stands at the step looked at. */
19
+ surfaceKey: string;
20
+ surface: Surface | undefined;
21
+ componentId: string;
22
+ /** Only events up to this number count. Left out, every event. */
23
+ upTo?: number;
24
+ /** A service call slower than this is mentioned. */
25
+ slowMs?: number;
26
+ }
27
+ /**
28
+ * Why a component is the way it is, worked out from what was recorded by
29
+ * fixed rules, most likely cause first. It reads the trace and the surface
30
+ * and nothing else: it calls no model and runs no query, so it can only say
31
+ * what the recording shows. An empty list means nothing recorded points at a
32
+ * problem, not that there is none.
33
+ *
34
+ * The order follows the chain a component depends on: the message that sent
35
+ * it, the catalog's check, whether anything draws it, what it is bound to,
36
+ * its queries, and only then how it drew.
37
+ */
38
+ export declare function componentFindings({ events, surfaceKey, surface, componentId, upTo, slowMs }: CauseInput): Finding[];