@reopt-ai/opt-devtool 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +11 -2
  3. package/dist/brandapp/index.cjs +457 -363
  4. package/dist/brandapp/index.d.cts +80 -81
  5. package/dist/brandapp/index.d.ts +80 -81
  6. package/dist/brandapp/index.js +451 -361
  7. package/dist/datagrid/index.cjs +170 -180
  8. package/dist/datagrid/index.d.cts +9 -11
  9. package/dist/datagrid/index.d.ts +9 -11
  10. package/dist/datagrid/index.js +167 -179
  11. package/dist/editor/index.cjs +209 -228
  12. package/dist/editor/index.d.cts +9 -11
  13. package/dist/editor/index.d.ts +9 -11
  14. package/dist/editor/index.js +206 -227
  15. package/dist/harness/index.cjs +5 -12
  16. package/dist/harness/index.d.cts +14 -16
  17. package/dist/harness/index.d.ts +14 -16
  18. package/dist/harness/index.js +1 -11
  19. package/dist/harness-CJZXBH3w.js +528 -0
  20. package/dist/harness-CPOp9Wlj.cjs +582 -0
  21. package/dist/index.cjs +3619 -3782
  22. package/dist/index.d.cts +9 -17
  23. package/dist/index.d.ts +9 -17
  24. package/dist/index.js +3611 -3781
  25. package/dist/provider-Cjg2rSYG.js +110 -0
  26. package/dist/provider-H53ZWHCo.cjs +161 -0
  27. package/dist/theme/index.cjs +298 -12
  28. package/dist/theme/index.d.cts +26 -28
  29. package/dist/theme/index.d.ts +26 -28
  30. package/dist/theme/index.js +294 -11
  31. package/dist/theme-isolate-BOo3J259.js +42 -0
  32. package/dist/theme-isolate-D9AMkYrD.cjs +53 -0
  33. package/dist/types-BKmW0EBr.js +4 -0
  34. package/dist/types-Bz4DijhU.cjs +9 -0
  35. package/dist/types-D_lNT2Nr.d.cts +91 -0
  36. package/dist/types-D_lNT2Nr.d.ts +91 -0
  37. package/dist/ui/index.cjs +4 -8
  38. package/dist/ui/index.d.cts +3 -2
  39. package/dist/ui/index.d.ts +3 -2
  40. package/dist/ui/index.js +1 -7
  41. package/package.json +4 -4
  42. package/dist/chunk-4MJKIAXH.cjs +0 -65
  43. package/dist/chunk-5HRIQSVF.js +0 -32
  44. package/dist/chunk-6AGUYGVT.cjs +0 -77
  45. package/dist/chunk-EQPETYJJ.cjs +0 -32
  46. package/dist/chunk-H3F2WACS.cjs +0 -568
  47. package/dist/chunk-N7YO56TN.cjs +0 -25
  48. package/dist/chunk-SQ3E3QLA.cjs +0 -253
  49. package/dist/chunk-SW2FF6EV.js +0 -568
  50. package/dist/chunk-UJSIQF3A.js +0 -25
  51. package/dist/chunk-UQY5I3WS.js +0 -253
  52. package/dist/chunk-YCYIUFB4.js +0 -65
  53. package/dist/chunk-Z2KFRHSI.js +0 -77
  54. package/dist/index-Bakx4o8Z.d.cts +0 -91
  55. package/dist/index-Bakx4o8Z.d.ts +0 -91
@@ -0,0 +1,582 @@
1
+ "use client";
2
+ const require_provider = require("./provider-H53ZWHCo.cjs");
3
+ const require_theme_isolate = require("./theme-isolate-D9AMkYrD.cjs");
4
+ let react = require("react");
5
+ react = require_provider.__toESM(react, 1);
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+ // src/shell-events.ts
8
+ /**
9
+ * Window event names emitted by `@reopt-ai/opt-shell`.
10
+ *
11
+ * Mirrored as literals (instead of imported) so the devtool root entry does
12
+ * not statically import opt-shell, which is an optional peer. Parity with the
13
+ * opt-shell constants is asserted in `__tests__/shell-events.test.ts`.
14
+ */
15
+ const SHELL_SNAPSHOT_EVENT = "opt-shell:snapshot";
16
+ const SHELL_THEME_EVENT = "opt-shell:theme";
17
+ // src/harness-store.ts
18
+ let snapshot = null;
19
+ const snapshotListeners = /* @__PURE__ */ new Set();
20
+ function notifySnapshot() {
21
+ snapshotListeners.forEach((fn) => fn());
22
+ }
23
+ /** setShellSnapshot — see usage in callers. */
24
+ function setShellSnapshot(next) {
25
+ snapshot = next;
26
+ notifySnapshot();
27
+ }
28
+ /** clearShellSnapshot — see usage in callers. */
29
+ function clearShellSnapshot() {
30
+ snapshot = null;
31
+ notifySnapshot();
32
+ }
33
+ /** subscribeShellSnapshot — see usage in callers. */
34
+ function subscribeShellSnapshot(cb) {
35
+ initAutoListener();
36
+ snapshotListeners.add(cb);
37
+ return () => snapshotListeners.delete(cb);
38
+ }
39
+ /** getShellSnapshot — see usage in callers. */
40
+ function getShellSnapshot() {
41
+ return snapshot;
42
+ }
43
+ let autoListenerInitialized = false;
44
+ function initAutoListener() {
45
+ if (autoListenerInitialized || typeof window === "undefined") return;
46
+ autoListenerInitialized = true;
47
+ window.addEventListener(SHELL_SNAPSHOT_EVENT, ((e) => {
48
+ const detail = e.detail;
49
+ if (detail) {
50
+ setShellSnapshot(detail.snapshot);
51
+ setShellManagerHref(detail.managerHref);
52
+ } else {
53
+ clearShellSnapshot();
54
+ setShellManagerHref(void 0);
55
+ }
56
+ }));
57
+ }
58
+ let overlayVisible = false;
59
+ const overlayListeners = /* @__PURE__ */ new Set();
60
+ function notifyOverlay() {
61
+ overlayListeners.forEach((fn) => fn());
62
+ }
63
+ /** toggleShellOverlay — see usage in callers. */
64
+ function toggleShellOverlay() {
65
+ overlayVisible = !overlayVisible;
66
+ notifyOverlay();
67
+ }
68
+ /** getShellOverlay — see usage in callers. */
69
+ function getShellOverlay() {
70
+ return overlayVisible;
71
+ }
72
+ /** subscribeShellOverlay — see usage in callers. */
73
+ function subscribeShellOverlay(cb) {
74
+ overlayListeners.add(cb);
75
+ return () => overlayListeners.delete(cb);
76
+ }
77
+ let managerHref;
78
+ /** setShellManagerHref — see usage in callers. */
79
+ function setShellManagerHref(href) {
80
+ managerHref = href;
81
+ }
82
+ /** getShellManagerHref — see usage in callers. */
83
+ function getShellManagerHref() {
84
+ return managerHref;
85
+ }
86
+ // src/harness/index.tsx
87
+ function StatusDot({ active, label }) {
88
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
89
+ className: "inline-flex items-center gap-1",
90
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `inline-block h-1.5 w-1.5 rounded-full ${active ? "bg-emerald-400" : "bg-white/20"}` }), label]
91
+ });
92
+ }
93
+ function CollapsibleSection({ title, color, summary, defaultOpen = true, children }) {
94
+ const [open, setOpen] = react.useState(defaultOpen);
95
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
96
+ tabIndex: -1,
97
+ onClick: () => setOpen((prev) => !prev),
98
+ className: "flex w-full items-center gap-1.5 text-left",
99
+ children: [
100
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
101
+ className: `text-[10px] font-semibold ${color}`,
102
+ children: title
103
+ }),
104
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
105
+ className: "text-[9px] text-white/30",
106
+ children: open ? "▾" : "▸"
107
+ }),
108
+ !open && summary && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
109
+ className: "ml-auto truncate text-[9px] text-white/40",
110
+ children: summary
111
+ })
112
+ ]
113
+ }), open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
114
+ className: "mt-1.5",
115
+ children
116
+ })] });
117
+ }
118
+ function ShellDevtoolPanel({ snapshot, showOverlay, onToggleOverlay, managerHref }) {
119
+ if (!snapshot) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
120
+ className: "text-[11px] text-white/55",
121
+ children: "Waiting for Harness snapshot."
122
+ });
123
+ const hasActiveAdapter = snapshot.adapters.datagrid.active || snapshot.adapters.editor.active;
124
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
125
+ className: "flex flex-col gap-3 text-[11px]",
126
+ children: [
127
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
128
+ className: "mb-2 flex items-center gap-1.5 text-[10px]",
129
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
130
+ tabIndex: -1,
131
+ onClick: onToggleOverlay,
132
+ className: `rounded px-1.5 py-0.5 text-[10px] transition-colors ${showOverlay ? "bg-amber-600 text-white" : "bg-white/10 text-white/55 hover:text-white/80"}`,
133
+ children: ["슬롯 경계 ", showOverlay ? "ON" : "OFF"]
134
+ })
135
+ }),
136
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
137
+ className: "mb-2 flex items-center gap-1.5 text-[10px]",
138
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `inline-block h-1.5 w-1.5 rounded-full ${snapshot.staleness.stale ? "bg-amber-400" : "bg-emerald-400"}` }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
139
+ className: snapshot.staleness.stale ? "text-amber-300" : "text-emerald-300",
140
+ children: snapshot.staleness.stale ? `Stale (${Math.round((Date.now() - snapshot.staleness.capturedAt) / 1e3)}s ago)` : "Fresh"
141
+ })]
142
+ }),
143
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CollapsibleSection, {
144
+ title: `Manifest v${snapshot.version}`,
145
+ color: "text-emerald-400",
146
+ summary: `${snapshot.manifestId} · ${snapshot.density} · ${snapshot.contentWidth}`,
147
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
148
+ className: "grid grid-cols-2 gap-x-3 gap-y-1 text-[10px] text-white/70",
149
+ children: [
150
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
151
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
152
+ className: "text-white/40",
153
+ children: "ID"
154
+ }),
155
+ " ",
156
+ snapshot.manifestId
157
+ ] }),
158
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
159
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
160
+ className: "text-white/40",
161
+ children: "Label"
162
+ }),
163
+ " ",
164
+ snapshot.manifestLabel
165
+ ] }),
166
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
167
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
168
+ className: "text-white/40",
169
+ children: "Density"
170
+ }),
171
+ " ",
172
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
173
+ className: "text-emerald-300",
174
+ children: snapshot.density
175
+ })
176
+ ] }),
177
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
178
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
179
+ className: "text-white/40",
180
+ children: "Width"
181
+ }),
182
+ " ",
183
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
184
+ className: "text-emerald-300",
185
+ children: snapshot.contentWidth
186
+ })
187
+ ] }),
188
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
189
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
190
+ className: "text-white/40",
191
+ children: "Nav"
192
+ }),
193
+ " ",
194
+ snapshot.navigationMode
195
+ ] }),
196
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
197
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
198
+ className: "text-white/40",
199
+ children: "Sticky"
200
+ }),
201
+ " aside",
202
+ " ",
203
+ snapshot.panelBehavior.stickyAside ? "✓" : "—",
204
+ " toolbar",
205
+ " ",
206
+ snapshot.panelBehavior.stickyToolbar ? "✓" : "—"
207
+ ] })
208
+ ]
209
+ }), managerHref && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
210
+ href: `${managerHref}?manifest=${encodeURIComponent(snapshot.manifestId)}`,
211
+ target: "_blank",
212
+ rel: "noopener noreferrer",
213
+ className: "mt-2 inline-flex items-center gap-1 rounded bg-emerald-900/40 px-2 py-1 text-[10px] text-emerald-400 transition-colors hover:bg-emerald-900/60 hover:text-emerald-300",
214
+ style: { pointerEvents: "auto" },
215
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
216
+ width: "10",
217
+ height: "10",
218
+ viewBox: "0 0 10 10",
219
+ fill: "none",
220
+ stroke: "currentColor",
221
+ strokeWidth: "1.5",
222
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M4 1H2a1 1 0 00-1 1v6a1 1 0 001 1h6a1 1 0 001-1V6" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M6 1h3v3M9 1L4.5 5.5" })]
223
+ }), "Harness Manager"]
224
+ })]
225
+ }),
226
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CollapsibleSection, {
227
+ title: "Boundaries",
228
+ color: "text-emerald-400",
229
+ summary: snapshot.stateBoundary ? `${snapshot.stateBoundary.loading ? "loading" : ""}${snapshot.stateBoundary.empty ? "empty" : ""}${snapshot.stateBoundary.error ? "error" : ""}${!snapshot.stateBoundary.loading && !snapshot.stateBoundary.empty && !snapshot.stateBoundary.error ? "idle" : ""}` : "—",
230
+ defaultOpen: Boolean(snapshot.stateBoundary),
231
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
232
+ className: "text-white/70",
233
+ children: snapshot.stateBoundary ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
234
+ className: "flex flex-wrap gap-2",
235
+ children: [
236
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, {
237
+ active: snapshot.stateBoundary.loading,
238
+ label: "loading"
239
+ }),
240
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, {
241
+ active: snapshot.stateBoundary.empty,
242
+ label: "empty"
243
+ }),
244
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, {
245
+ active: snapshot.stateBoundary.error,
246
+ label: "error"
247
+ }),
248
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: ["chrome ", snapshot.stateBoundary.chrome] })
249
+ ]
250
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: "No active ShellStateBoundary signal." })
251
+ })
252
+ }),
253
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CollapsibleSection, {
254
+ title: snapshot.diff && !snapshot.diff.empty ? `Changes (v${snapshot.diff.baseVersion} → v${snapshot.diff.headVersion})` : "Changes",
255
+ color: snapshot.diff && !snapshot.diff.empty ? "text-amber-400" : "text-emerald-400",
256
+ summary: snapshot.diff ? snapshot.diff.empty ? "none" : `${snapshot.diff.entries.length} change(s)` : "—",
257
+ defaultOpen: Boolean(snapshot.diff && !snapshot.diff.empty),
258
+ children: snapshot.diff && !snapshot.diff.empty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
259
+ className: "flex flex-col gap-1 text-[10px] text-white/70",
260
+ children: snapshot.diff.entries.map((entry, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
261
+ className: "flex gap-1",
262
+ children: [
263
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
264
+ className: "text-amber-300",
265
+ children: [entry.path, ":"]
266
+ }),
267
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
268
+ className: "text-red-400/70 line-through",
269
+ children: JSON.stringify(entry.prev)
270
+ }),
271
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
272
+ className: "text-white/30",
273
+ children: "→"
274
+ }),
275
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
276
+ className: "text-emerald-400",
277
+ children: JSON.stringify(entry.next)
278
+ })
279
+ ]
280
+ }, i))
281
+ }) : snapshot.diff ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
282
+ className: "text-[10px] text-white/40",
283
+ children: "No changes from previous snapshot"
284
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
285
+ className: "text-[10px] text-white/40",
286
+ children: "No diff available"
287
+ })
288
+ }),
289
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CollapsibleSection, {
290
+ title: "Adapters",
291
+ color: "text-emerald-400",
292
+ summary: hasActiveAdapter ? `${snapshot.adapters.datagrid.active ? "DataGrid" : ""}${snapshot.adapters.datagrid.active && snapshot.adapters.editor.active ? " + " : ""}${snapshot.adapters.editor.active ? "Editor" : ""}` : "idle",
293
+ defaultOpen: hasActiveAdapter,
294
+ children: !hasActiveAdapter ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
295
+ className: "text-[10px] text-white/40",
296
+ children: "No active adapters"
297
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
298
+ className: "flex flex-col gap-1.5 text-[10px] text-white/70",
299
+ children: [snapshot.adapters.datagrid.active && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
300
+ className: "flex flex-wrap gap-2",
301
+ children: [
302
+ "DataGrid:",
303
+ " ",
304
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, {
305
+ active: snapshot.adapters.datagrid.active,
306
+ label: "active"
307
+ }),
308
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: ["chrome ", snapshot.adapters.datagrid.chrome] }),
309
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, {
310
+ active: snapshot.adapters.datagrid.loading,
311
+ label: "loading"
312
+ }),
313
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, {
314
+ active: snapshot.adapters.datagrid.empty,
315
+ label: "empty"
316
+ }),
317
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, {
318
+ active: snapshot.adapters.datagrid.error,
319
+ label: "error"
320
+ })
321
+ ]
322
+ }), snapshot.adapters.editor.active && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
323
+ className: "flex flex-wrap gap-2",
324
+ children: [
325
+ "Editor:",
326
+ " ",
327
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, {
328
+ active: snapshot.adapters.editor.active,
329
+ label: "active"
330
+ }),
331
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: ["chrome ", snapshot.adapters.editor.chrome] }),
332
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, {
333
+ active: snapshot.adapters.editor.loading,
334
+ label: "loading"
335
+ }),
336
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, {
337
+ active: snapshot.adapters.editor.empty,
338
+ label: "empty"
339
+ }),
340
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, {
341
+ active: snapshot.adapters.editor.error,
342
+ label: "error"
343
+ }),
344
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, {
345
+ active: snapshot.adapters.editor.hasInspector,
346
+ label: "inspector"
347
+ })
348
+ ]
349
+ })]
350
+ })
351
+ })
352
+ ]
353
+ });
354
+ }
355
+ const SLOT_COLORS = {
356
+ header: {
357
+ border: "border-amber-400/60",
358
+ bg: "bg-amber-400/10",
359
+ text: "text-amber-400"
360
+ },
361
+ toolbar: {
362
+ border: "border-blue-400/60",
363
+ bg: "bg-blue-400/10",
364
+ text: "text-blue-400"
365
+ },
366
+ filters: {
367
+ border: "border-purple-400/60",
368
+ bg: "bg-purple-400/10",
369
+ text: "text-purple-400"
370
+ },
371
+ content: {
372
+ border: "border-emerald-400/60",
373
+ bg: "bg-emerald-400/10",
374
+ text: "text-emerald-400"
375
+ },
376
+ aside: {
377
+ border: "border-cyan-400/60",
378
+ bg: "bg-cyan-400/10",
379
+ text: "text-cyan-400"
380
+ },
381
+ footer: {
382
+ border: "border-zinc-400/60",
383
+ bg: "bg-zinc-400/10",
384
+ text: "text-zinc-400"
385
+ }
386
+ };
387
+ const DEFAULT_COLOR = {
388
+ border: "border-white/30",
389
+ bg: "bg-white/5",
390
+ text: "text-white/60"
391
+ };
392
+ function ShellOverlay({ snapshot }) {
393
+ const [slots, setSlots] = react.useState([]);
394
+ const [recipe, setRecipe] = react.useState(null);
395
+ react.useEffect(() => {
396
+ let rafId = 0;
397
+ function scan() {
398
+ const slotEls = document.querySelectorAll("[data-harness-slot]");
399
+ const newSlots = [];
400
+ slotEls.forEach((el) => {
401
+ const rect = el.getBoundingClientRect();
402
+ if (rect.width > 0 && rect.height > 0) {
403
+ var _el$getAttribute;
404
+ newSlots.push({
405
+ name: (_el$getAttribute = el.getAttribute("data-harness-slot")) !== null && _el$getAttribute !== void 0 ? _el$getAttribute : "",
406
+ rect
407
+ });
408
+ }
409
+ });
410
+ setSlots(newSlots);
411
+ const recipeEl = document.querySelector("[data-harness-recipe]");
412
+ if (recipeEl) {
413
+ var _recipeEl$getAttribut;
414
+ const rect = recipeEl.getBoundingClientRect();
415
+ setRecipe({
416
+ name: (_recipeEl$getAttribut = recipeEl.getAttribute("data-harness-recipe")) !== null && _recipeEl$getAttribut !== void 0 ? _recipeEl$getAttribut : "",
417
+ rect
418
+ });
419
+ } else setRecipe(null);
420
+ }
421
+ function debouncedScan() {
422
+ cancelAnimationFrame(rafId);
423
+ rafId = requestAnimationFrame(scan);
424
+ }
425
+ scan();
426
+ const observer = new MutationObserver(debouncedScan);
427
+ observer.observe(document.body, {
428
+ childList: true,
429
+ subtree: true,
430
+ attributes: true
431
+ });
432
+ window.addEventListener("resize", debouncedScan);
433
+ window.addEventListener("scroll", debouncedScan, true);
434
+ return () => {
435
+ observer.disconnect();
436
+ cancelAnimationFrame(rafId);
437
+ window.removeEventListener("resize", debouncedScan);
438
+ window.removeEventListener("scroll", debouncedScan, true);
439
+ };
440
+ }, []);
441
+ if (slots.length === 0 && !recipe) return null;
442
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
443
+ "data-opt-devtool": true,
444
+ style: require_provider._objectSpread2(require_provider._objectSpread2({}, require_theme_isolate.ISOLATE_STYLE), {}, {
445
+ position: "fixed",
446
+ inset: 0,
447
+ pointerEvents: "none",
448
+ zIndex: 9997
449
+ }),
450
+ children: [recipe && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
451
+ style: {
452
+ position: "absolute",
453
+ left: recipe.rect.left,
454
+ top: recipe.rect.top - 20
455
+ },
456
+ className: "rounded bg-amber-500/90 px-1.5 py-0.5 text-[9px] font-bold text-black",
457
+ children: [
458
+ recipe.name,
459
+ " workspace",
460
+ snapshot ? ` · ${snapshot.density} · ${snapshot.contentWidth}` : ""
461
+ ]
462
+ }), slots.map((slot, i) => {
463
+ var _SLOT_COLORS$slot$nam;
464
+ const colors = (_SLOT_COLORS$slot$nam = SLOT_COLORS[slot.name]) !== null && _SLOT_COLORS$slot$nam !== void 0 ? _SLOT_COLORS$slot$nam : DEFAULT_COLOR;
465
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
466
+ style: {
467
+ position: "absolute",
468
+ left: slot.rect.left,
469
+ top: slot.rect.top,
470
+ width: slot.rect.width,
471
+ height: slot.rect.height
472
+ },
473
+ className: `border ${colors.border} ${colors.bg} rounded-sm`,
474
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
475
+ className: `absolute -top-3.5 left-1 rounded px-1 py-0 text-[8px] font-semibold ${colors.text}`,
476
+ style: { backgroundColor: "rgba(0,0,0,0.8)" },
477
+ children: slot.name
478
+ })
479
+ }, `${slot.name}-${i}`);
480
+ })]
481
+ });
482
+ }
483
+ /**
484
+ * Register the harness devtool bridge.
485
+ *
486
+ * Note on the snapshot wiring (intentional asymmetry vs the editor /
487
+ * datagrid / theme bridges): harness state is mirrored into the shared
488
+ * `harness-store` module singleton in addition to local hook state.
489
+ * `<OptDevtool>` itself reads the store directly so it can render the
490
+ * harness *overlay* outside the panel chrome, even when the panel is on a
491
+ * different tab. The other bridges only render inside their tab and so can
492
+ * keep their snapshot fully local.
493
+ */
494
+ function useShellDevtoolBridge({ id, label, order = 10, managerHref }) {
495
+ const [snapshot, setSnapshot] = react.useState(null);
496
+ const [showOverlay, setShowOverlay] = react.useState(false);
497
+ const inspect = react.useCallback((nextSnapshot) => {
498
+ setSnapshot(nextSnapshot);
499
+ setShellSnapshot(nextSnapshot);
500
+ }, []);
501
+ react.useEffect(() => {
502
+ setShellManagerHref(managerHref);
503
+ return () => {
504
+ clearShellSnapshot();
505
+ setShellManagerHref(void 0);
506
+ };
507
+ }, [managerHref]);
508
+ const plugin = react.useMemo(() => ({
509
+ id,
510
+ label,
511
+ order,
512
+ renderPanel: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShellDevtoolPanel, {
513
+ snapshot,
514
+ showOverlay,
515
+ onToggleOverlay: () => setShowOverlay((prev) => !prev),
516
+ managerHref
517
+ }),
518
+ renderOverlay: () => showOverlay ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShellOverlay, { snapshot }) : null
519
+ }), [
520
+ id,
521
+ label,
522
+ order,
523
+ snapshot,
524
+ showOverlay
525
+ ]);
526
+ require_provider.useOptDevtoolPlugin(plugin);
527
+ return { inspect };
528
+ }
529
+ Object.defineProperty(exports, "SHELL_THEME_EVENT", {
530
+ enumerable: true,
531
+ get: function() {
532
+ return SHELL_THEME_EVENT;
533
+ }
534
+ });
535
+ Object.defineProperty(exports, "ShellOverlay", {
536
+ enumerable: true,
537
+ get: function() {
538
+ return ShellOverlay;
539
+ }
540
+ });
541
+ Object.defineProperty(exports, "getShellManagerHref", {
542
+ enumerable: true,
543
+ get: function() {
544
+ return getShellManagerHref;
545
+ }
546
+ });
547
+ Object.defineProperty(exports, "getShellOverlay", {
548
+ enumerable: true,
549
+ get: function() {
550
+ return getShellOverlay;
551
+ }
552
+ });
553
+ Object.defineProperty(exports, "getShellSnapshot", {
554
+ enumerable: true,
555
+ get: function() {
556
+ return getShellSnapshot;
557
+ }
558
+ });
559
+ Object.defineProperty(exports, "subscribeShellOverlay", {
560
+ enumerable: true,
561
+ get: function() {
562
+ return subscribeShellOverlay;
563
+ }
564
+ });
565
+ Object.defineProperty(exports, "subscribeShellSnapshot", {
566
+ enumerable: true,
567
+ get: function() {
568
+ return subscribeShellSnapshot;
569
+ }
570
+ });
571
+ Object.defineProperty(exports, "toggleShellOverlay", {
572
+ enumerable: true,
573
+ get: function() {
574
+ return toggleShellOverlay;
575
+ }
576
+ });
577
+ Object.defineProperty(exports, "useShellDevtoolBridge", {
578
+ enumerable: true,
579
+ get: function() {
580
+ return useShellDevtoolBridge;
581
+ }
582
+ });