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