@reopt-ai/opt-devtool 1.0.0 → 1.0.1

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