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