uilint-react 0.1.18 → 0.1.19
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/dist/InspectionPanel-6DBGEWWD.js +9 -0
- package/dist/LocatorOverlay-FQEYAMT6.js +9 -0
- package/dist/SourceOverlays-2SEINA2B.js +9 -0
- package/dist/UILintToolbar-7ZYCQC4M.js +9 -0
- package/dist/chunk-3TA6OKS6.js +725 -0
- package/dist/chunk-7WYVWDRU.js +686 -0
- package/dist/chunk-KUFV22FO.js +213 -0
- package/dist/chunk-MEP7WO7U.js +210 -0
- package/dist/chunk-OWX36QE3.js +595 -0
- package/dist/index.d.ts +284 -6
- package/dist/index.js +62 -1
- package/dist/node.js +1 -4
- package/package.json +2 -2
|
@@ -0,0 +1,725 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
buildEditorUrl,
|
|
4
|
+
useUILintContext
|
|
5
|
+
} from "./chunk-7WYVWDRU.js";
|
|
6
|
+
|
|
7
|
+
// src/components/ui-lint/InspectionPanel.tsx
|
|
8
|
+
import { useState, useEffect, useCallback } from "react";
|
|
9
|
+
import { createPortal } from "react-dom";
|
|
10
|
+
|
|
11
|
+
// src/components/ui-lint/source-fetcher.ts
|
|
12
|
+
var sourceCache = /* @__PURE__ */ new Map();
|
|
13
|
+
var CACHE_TTL = 5 * 60 * 1e3;
|
|
14
|
+
var API_ENDPOINT = "/api/dev/source";
|
|
15
|
+
async function fetchSource(filePath) {
|
|
16
|
+
const cached = sourceCache.get(filePath);
|
|
17
|
+
if (cached && Date.now() - cached.fetchedAt < CACHE_TTL) {
|
|
18
|
+
return {
|
|
19
|
+
content: cached.content,
|
|
20
|
+
relativePath: cached.relativePath
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const response = await fetch(
|
|
25
|
+
`${API_ENDPOINT}?path=${encodeURIComponent(filePath)}`
|
|
26
|
+
);
|
|
27
|
+
if (!response.ok) {
|
|
28
|
+
console.warn(`[UILint] Failed to fetch source: ${response.statusText}`);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const data = await response.json();
|
|
32
|
+
sourceCache.set(filePath, {
|
|
33
|
+
...data,
|
|
34
|
+
fetchedAt: Date.now()
|
|
35
|
+
});
|
|
36
|
+
return data;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error("[UILint] Error fetching source:", error);
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function fetchSourceWithContext(source, contextLines = 5) {
|
|
43
|
+
const result = await fetchSource(source.fileName);
|
|
44
|
+
if (!result) return null;
|
|
45
|
+
const allLines = result.content.split("\n");
|
|
46
|
+
const targetLine = source.lineNumber - 1;
|
|
47
|
+
const startLine = Math.max(0, targetLine - contextLines);
|
|
48
|
+
const endLine = Math.min(allLines.length, targetLine + contextLines + 1);
|
|
49
|
+
return {
|
|
50
|
+
lines: allLines.slice(startLine, endLine),
|
|
51
|
+
startLine: startLine + 1,
|
|
52
|
+
// Back to 1-indexed
|
|
53
|
+
highlightLine: source.lineNumber,
|
|
54
|
+
relativePath: result.relativePath
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function clearSourceCache() {
|
|
58
|
+
sourceCache.clear();
|
|
59
|
+
}
|
|
60
|
+
function getCachedSource(filePath) {
|
|
61
|
+
const cached = sourceCache.get(filePath);
|
|
62
|
+
if (!cached) return null;
|
|
63
|
+
if (Date.now() - cached.fetchedAt >= CACHE_TTL) {
|
|
64
|
+
sourceCache.delete(filePath);
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
content: cached.content,
|
|
69
|
+
relativePath: cached.relativePath
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
async function prefetchSources(filePaths) {
|
|
73
|
+
const uniquePaths = [...new Set(filePaths)].filter((path) => {
|
|
74
|
+
const cached = sourceCache.get(path);
|
|
75
|
+
return !cached || Date.now() - cached.fetchedAt >= CACHE_TTL;
|
|
76
|
+
});
|
|
77
|
+
const BATCH_SIZE = 5;
|
|
78
|
+
for (let i = 0; i < uniquePaths.length; i += BATCH_SIZE) {
|
|
79
|
+
const batch = uniquePaths.slice(i, i + BATCH_SIZE);
|
|
80
|
+
await Promise.all(batch.map(fetchSource));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// src/components/ui-lint/InspectionPanel.tsx
|
|
85
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
86
|
+
var STYLES = {
|
|
87
|
+
bg: "rgba(17, 24, 39, 0.95)",
|
|
88
|
+
bgSurface: "rgba(31, 41, 55, 0.9)",
|
|
89
|
+
border: "rgba(75, 85, 99, 0.5)",
|
|
90
|
+
text: "#F9FAFB",
|
|
91
|
+
textMuted: "#9CA3AF",
|
|
92
|
+
textDim: "#6B7280",
|
|
93
|
+
accent: "#3B82F6",
|
|
94
|
+
accentHover: "#2563EB",
|
|
95
|
+
shadow: "0 -8px 32px rgba(0, 0, 0, 0.4)",
|
|
96
|
+
blur: "blur(16px)",
|
|
97
|
+
font: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
98
|
+
fontMono: 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'
|
|
99
|
+
};
|
|
100
|
+
var PANEL_WIDTH = 400;
|
|
101
|
+
function InspectionPanel() {
|
|
102
|
+
const { selectedElement, setSelectedElement, sourceFiles } = useUILintContext();
|
|
103
|
+
const [mounted, setMounted] = useState(false);
|
|
104
|
+
const [activeTab, setActiveTab] = useState("info");
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
setMounted(true);
|
|
107
|
+
}, []);
|
|
108
|
+
const sourceFile = selectedElement ? sourceFiles.find(
|
|
109
|
+
(f) => f.elements.some((e) => e.id === selectedElement.id)
|
|
110
|
+
) ?? null : null;
|
|
111
|
+
if (!mounted) return null;
|
|
112
|
+
const content = /* @__PURE__ */ jsxs(
|
|
113
|
+
"div",
|
|
114
|
+
{
|
|
115
|
+
"data-ui-lint": true,
|
|
116
|
+
style: {
|
|
117
|
+
position: "fixed",
|
|
118
|
+
top: 0,
|
|
119
|
+
right: 0,
|
|
120
|
+
bottom: 0,
|
|
121
|
+
width: selectedElement ? PANEL_WIDTH : 0,
|
|
122
|
+
backgroundColor: STYLES.bg,
|
|
123
|
+
backdropFilter: STYLES.blur,
|
|
124
|
+
WebkitBackdropFilter: STYLES.blur,
|
|
125
|
+
borderLeft: `1px solid ${STYLES.border}`,
|
|
126
|
+
boxShadow: selectedElement ? STYLES.shadow : "none",
|
|
127
|
+
fontFamily: STYLES.font,
|
|
128
|
+
color: STYLES.text,
|
|
129
|
+
overflow: "hidden",
|
|
130
|
+
transition: "width 0.2s ease-out",
|
|
131
|
+
zIndex: 99998
|
|
132
|
+
},
|
|
133
|
+
children: [
|
|
134
|
+
/* @__PURE__ */ jsx("style", { children: `
|
|
135
|
+
@keyframes uilint-panel-slide-in {
|
|
136
|
+
from { transform: translateX(100%); }
|
|
137
|
+
to { transform: translateX(0); }
|
|
138
|
+
}
|
|
139
|
+
` }),
|
|
140
|
+
selectedElement && /* @__PURE__ */ jsxs(
|
|
141
|
+
"div",
|
|
142
|
+
{
|
|
143
|
+
style: {
|
|
144
|
+
display: "flex",
|
|
145
|
+
flexDirection: "column",
|
|
146
|
+
height: "100%",
|
|
147
|
+
animation: "uilint-panel-slide-in 0.2s ease-out"
|
|
148
|
+
},
|
|
149
|
+
children: [
|
|
150
|
+
/* @__PURE__ */ jsx(
|
|
151
|
+
PanelHeader,
|
|
152
|
+
{
|
|
153
|
+
element: selectedElement,
|
|
154
|
+
sourceFile,
|
|
155
|
+
onClose: () => setSelectedElement(null)
|
|
156
|
+
}
|
|
157
|
+
),
|
|
158
|
+
/* @__PURE__ */ jsxs(
|
|
159
|
+
"div",
|
|
160
|
+
{
|
|
161
|
+
style: {
|
|
162
|
+
display: "flex",
|
|
163
|
+
borderBottom: `1px solid ${STYLES.border}`
|
|
164
|
+
},
|
|
165
|
+
children: [
|
|
166
|
+
/* @__PURE__ */ jsx(
|
|
167
|
+
TabButton,
|
|
168
|
+
{
|
|
169
|
+
label: "Info",
|
|
170
|
+
active: activeTab === "info",
|
|
171
|
+
onClick: () => setActiveTab("info")
|
|
172
|
+
}
|
|
173
|
+
),
|
|
174
|
+
/* @__PURE__ */ jsx(
|
|
175
|
+
TabButton,
|
|
176
|
+
{
|
|
177
|
+
label: "Source",
|
|
178
|
+
active: activeTab === "source",
|
|
179
|
+
onClick: () => setActiveTab("source")
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
/* @__PURE__ */ jsx("div", { style: { flex: 1, overflow: "auto" }, children: activeTab === "info" ? /* @__PURE__ */ jsx(InfoTab, { element: selectedElement, sourceFile }) : /* @__PURE__ */ jsx(SourceTab, { element: selectedElement }) })
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
return createPortal(content, document.body);
|
|
193
|
+
}
|
|
194
|
+
function PanelHeader({
|
|
195
|
+
element,
|
|
196
|
+
sourceFile,
|
|
197
|
+
onClose
|
|
198
|
+
}) {
|
|
199
|
+
const componentName = element.componentStack[0]?.name || element.tagName.toUpperCase();
|
|
200
|
+
const handleOpenInEditor = useCallback(() => {
|
|
201
|
+
if (element.source) {
|
|
202
|
+
const url = buildEditorUrl(element.source, "cursor");
|
|
203
|
+
window.open(url, "_blank");
|
|
204
|
+
}
|
|
205
|
+
}, [element.source]);
|
|
206
|
+
return /* @__PURE__ */ jsxs(
|
|
207
|
+
"div",
|
|
208
|
+
{
|
|
209
|
+
style: {
|
|
210
|
+
display: "flex",
|
|
211
|
+
alignItems: "center",
|
|
212
|
+
justifyContent: "space-between",
|
|
213
|
+
padding: "12px 16px",
|
|
214
|
+
borderBottom: `1px solid ${STYLES.border}`,
|
|
215
|
+
backgroundColor: STYLES.bgSurface
|
|
216
|
+
},
|
|
217
|
+
children: [
|
|
218
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
|
|
219
|
+
sourceFile && /* @__PURE__ */ jsx(
|
|
220
|
+
"div",
|
|
221
|
+
{
|
|
222
|
+
style: {
|
|
223
|
+
width: "12px",
|
|
224
|
+
height: "12px",
|
|
225
|
+
borderRadius: "50%",
|
|
226
|
+
backgroundColor: sourceFile.color
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
),
|
|
230
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
231
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: "14px", fontWeight: 600 }, children: componentName }),
|
|
232
|
+
/* @__PURE__ */ jsxs("div", { style: { fontSize: "11px", color: STYLES.textMuted }, children: [
|
|
233
|
+
"<",
|
|
234
|
+
element.tagName,
|
|
235
|
+
">"
|
|
236
|
+
] })
|
|
237
|
+
] })
|
|
238
|
+
] }),
|
|
239
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
240
|
+
element.source && /* @__PURE__ */ jsxs(
|
|
241
|
+
"button",
|
|
242
|
+
{
|
|
243
|
+
onClick: handleOpenInEditor,
|
|
244
|
+
style: {
|
|
245
|
+
display: "flex",
|
|
246
|
+
alignItems: "center",
|
|
247
|
+
gap: "4px",
|
|
248
|
+
padding: "6px 10px",
|
|
249
|
+
borderRadius: "6px",
|
|
250
|
+
border: "none",
|
|
251
|
+
backgroundColor: STYLES.accent,
|
|
252
|
+
color: "#FFFFFF",
|
|
253
|
+
fontSize: "11px",
|
|
254
|
+
fontWeight: 500,
|
|
255
|
+
cursor: "pointer",
|
|
256
|
+
transition: "background-color 0.15s"
|
|
257
|
+
},
|
|
258
|
+
onMouseEnter: (e) => {
|
|
259
|
+
e.currentTarget.style.backgroundColor = STYLES.accentHover;
|
|
260
|
+
},
|
|
261
|
+
onMouseLeave: (e) => {
|
|
262
|
+
e.currentTarget.style.backgroundColor = STYLES.accent;
|
|
263
|
+
},
|
|
264
|
+
children: [
|
|
265
|
+
/* @__PURE__ */ jsx(OpenIcon, {}),
|
|
266
|
+
"Open"
|
|
267
|
+
]
|
|
268
|
+
}
|
|
269
|
+
),
|
|
270
|
+
/* @__PURE__ */ jsx(
|
|
271
|
+
"button",
|
|
272
|
+
{
|
|
273
|
+
onClick: onClose,
|
|
274
|
+
style: {
|
|
275
|
+
display: "flex",
|
|
276
|
+
alignItems: "center",
|
|
277
|
+
justifyContent: "center",
|
|
278
|
+
width: "28px",
|
|
279
|
+
height: "28px",
|
|
280
|
+
borderRadius: "6px",
|
|
281
|
+
border: "none",
|
|
282
|
+
backgroundColor: "transparent",
|
|
283
|
+
color: STYLES.textMuted,
|
|
284
|
+
cursor: "pointer",
|
|
285
|
+
transition: "all 0.15s"
|
|
286
|
+
},
|
|
287
|
+
onMouseEnter: (e) => {
|
|
288
|
+
e.currentTarget.style.backgroundColor = STYLES.bgSurface;
|
|
289
|
+
e.currentTarget.style.color = STYLES.text;
|
|
290
|
+
},
|
|
291
|
+
onMouseLeave: (e) => {
|
|
292
|
+
e.currentTarget.style.backgroundColor = "transparent";
|
|
293
|
+
e.currentTarget.style.color = STYLES.textMuted;
|
|
294
|
+
},
|
|
295
|
+
children: /* @__PURE__ */ jsx(CloseIcon, {})
|
|
296
|
+
}
|
|
297
|
+
)
|
|
298
|
+
] })
|
|
299
|
+
]
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
function TabButton({
|
|
304
|
+
label,
|
|
305
|
+
active,
|
|
306
|
+
onClick
|
|
307
|
+
}) {
|
|
308
|
+
return /* @__PURE__ */ jsx(
|
|
309
|
+
"button",
|
|
310
|
+
{
|
|
311
|
+
onClick,
|
|
312
|
+
style: {
|
|
313
|
+
flex: 1,
|
|
314
|
+
padding: "10px 16px",
|
|
315
|
+
border: "none",
|
|
316
|
+
backgroundColor: "transparent",
|
|
317
|
+
color: active ? STYLES.accent : STYLES.textMuted,
|
|
318
|
+
fontSize: "12px",
|
|
319
|
+
fontWeight: 500,
|
|
320
|
+
cursor: "pointer",
|
|
321
|
+
borderBottom: active ? `2px solid ${STYLES.accent}` : "2px solid transparent",
|
|
322
|
+
marginBottom: "-1px",
|
|
323
|
+
transition: "all 0.15s"
|
|
324
|
+
},
|
|
325
|
+
children: label
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
function InfoTab({
|
|
330
|
+
element,
|
|
331
|
+
sourceFile
|
|
332
|
+
}) {
|
|
333
|
+
return /* @__PURE__ */ jsxs("div", { style: { padding: "16px" }, children: [
|
|
334
|
+
/* @__PURE__ */ jsxs(Section, { title: "Element", children: [
|
|
335
|
+
/* @__PURE__ */ jsx(InfoRow, { label: "Tag", value: `<${element.tagName}>` }),
|
|
336
|
+
element.className && /* @__PURE__ */ jsx(InfoRow, { label: "Classes", value: element.className, mono: true }),
|
|
337
|
+
element.source && /* @__PURE__ */ jsx(
|
|
338
|
+
InfoRow,
|
|
339
|
+
{
|
|
340
|
+
label: "Location",
|
|
341
|
+
value: `Line ${element.source.lineNumber}${element.source.columnNumber ? `, Col ${element.source.columnNumber}` : ""}`
|
|
342
|
+
}
|
|
343
|
+
)
|
|
344
|
+
] }),
|
|
345
|
+
sourceFile && /* @__PURE__ */ jsxs(Section, { title: "Source File", children: [
|
|
346
|
+
/* @__PURE__ */ jsxs(
|
|
347
|
+
"div",
|
|
348
|
+
{
|
|
349
|
+
style: {
|
|
350
|
+
display: "flex",
|
|
351
|
+
alignItems: "center",
|
|
352
|
+
gap: "8px",
|
|
353
|
+
marginBottom: "8px"
|
|
354
|
+
},
|
|
355
|
+
children: [
|
|
356
|
+
/* @__PURE__ */ jsx(
|
|
357
|
+
"div",
|
|
358
|
+
{
|
|
359
|
+
style: {
|
|
360
|
+
width: "10px",
|
|
361
|
+
height: "10px",
|
|
362
|
+
borderRadius: "50%",
|
|
363
|
+
backgroundColor: sourceFile.color
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
),
|
|
367
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "12px", fontWeight: 500 }, children: sourceFile.displayName })
|
|
368
|
+
]
|
|
369
|
+
}
|
|
370
|
+
),
|
|
371
|
+
/* @__PURE__ */ jsx(
|
|
372
|
+
"div",
|
|
373
|
+
{
|
|
374
|
+
style: {
|
|
375
|
+
fontSize: "11px",
|
|
376
|
+
color: STYLES.textDim,
|
|
377
|
+
fontFamily: STYLES.fontMono,
|
|
378
|
+
wordBreak: "break-all"
|
|
379
|
+
},
|
|
380
|
+
children: sourceFile.path
|
|
381
|
+
}
|
|
382
|
+
)
|
|
383
|
+
] }),
|
|
384
|
+
element.componentStack.length > 0 && /* @__PURE__ */ jsx(Section, { title: "Component Stack", children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
|
|
385
|
+
element.componentStack.slice(0, 10).map((comp, index) => /* @__PURE__ */ jsx(
|
|
386
|
+
ComponentStackItem,
|
|
387
|
+
{
|
|
388
|
+
component: comp,
|
|
389
|
+
index,
|
|
390
|
+
isFirst: index === 0
|
|
391
|
+
},
|
|
392
|
+
index
|
|
393
|
+
)),
|
|
394
|
+
element.componentStack.length > 10 && /* @__PURE__ */ jsxs(
|
|
395
|
+
"div",
|
|
396
|
+
{
|
|
397
|
+
style: {
|
|
398
|
+
fontSize: "11px",
|
|
399
|
+
color: STYLES.textDim,
|
|
400
|
+
marginTop: "4px"
|
|
401
|
+
},
|
|
402
|
+
children: [
|
|
403
|
+
"...and ",
|
|
404
|
+
element.componentStack.length - 10,
|
|
405
|
+
" more"
|
|
406
|
+
]
|
|
407
|
+
}
|
|
408
|
+
)
|
|
409
|
+
] }) }),
|
|
410
|
+
/* @__PURE__ */ jsxs(Section, { title: "Dimensions", children: [
|
|
411
|
+
/* @__PURE__ */ jsx(
|
|
412
|
+
InfoRow,
|
|
413
|
+
{
|
|
414
|
+
label: "Size",
|
|
415
|
+
value: `${Math.round(element.rect.width)} \xD7 ${Math.round(
|
|
416
|
+
element.rect.height
|
|
417
|
+
)}px`
|
|
418
|
+
}
|
|
419
|
+
),
|
|
420
|
+
/* @__PURE__ */ jsx(
|
|
421
|
+
InfoRow,
|
|
422
|
+
{
|
|
423
|
+
label: "Position",
|
|
424
|
+
value: `(${Math.round(element.rect.left)}, ${Math.round(
|
|
425
|
+
element.rect.top
|
|
426
|
+
)})`
|
|
427
|
+
}
|
|
428
|
+
)
|
|
429
|
+
] })
|
|
430
|
+
] });
|
|
431
|
+
}
|
|
432
|
+
function SourceTab({ element }) {
|
|
433
|
+
const [sourceData, setSourceData] = useState(null);
|
|
434
|
+
const [loading, setLoading] = useState(false);
|
|
435
|
+
const [error, setError] = useState(null);
|
|
436
|
+
useEffect(() => {
|
|
437
|
+
if (!element.source) {
|
|
438
|
+
setError("No source information available");
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
setLoading(true);
|
|
442
|
+
setError(null);
|
|
443
|
+
fetchSourceWithContext(element.source, 8).then((data) => {
|
|
444
|
+
if (data) {
|
|
445
|
+
setSourceData(data);
|
|
446
|
+
} else {
|
|
447
|
+
setError("Failed to load source file");
|
|
448
|
+
}
|
|
449
|
+
}).catch(() => {
|
|
450
|
+
setError("Failed to load source file");
|
|
451
|
+
}).finally(() => {
|
|
452
|
+
setLoading(false);
|
|
453
|
+
});
|
|
454
|
+
}, [element.source]);
|
|
455
|
+
if (loading) {
|
|
456
|
+
return /* @__PURE__ */ jsx(
|
|
457
|
+
"div",
|
|
458
|
+
{
|
|
459
|
+
style: {
|
|
460
|
+
display: "flex",
|
|
461
|
+
alignItems: "center",
|
|
462
|
+
justifyContent: "center",
|
|
463
|
+
padding: "48px",
|
|
464
|
+
color: STYLES.textMuted,
|
|
465
|
+
fontSize: "13px"
|
|
466
|
+
},
|
|
467
|
+
children: "Loading source..."
|
|
468
|
+
}
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
if (error) {
|
|
472
|
+
return /* @__PURE__ */ jsx(
|
|
473
|
+
"div",
|
|
474
|
+
{
|
|
475
|
+
style: {
|
|
476
|
+
display: "flex",
|
|
477
|
+
alignItems: "center",
|
|
478
|
+
justifyContent: "center",
|
|
479
|
+
padding: "48px",
|
|
480
|
+
color: STYLES.textMuted,
|
|
481
|
+
fontSize: "13px"
|
|
482
|
+
},
|
|
483
|
+
children: error
|
|
484
|
+
}
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
if (!sourceData) return null;
|
|
488
|
+
return /* @__PURE__ */ jsxs("div", { style: { padding: "12px" }, children: [
|
|
489
|
+
/* @__PURE__ */ jsx(
|
|
490
|
+
"div",
|
|
491
|
+
{
|
|
492
|
+
style: {
|
|
493
|
+
padding: "8px 12px",
|
|
494
|
+
marginBottom: "8px",
|
|
495
|
+
backgroundColor: STYLES.bgSurface,
|
|
496
|
+
borderRadius: "6px",
|
|
497
|
+
fontSize: "11px",
|
|
498
|
+
fontFamily: STYLES.fontMono,
|
|
499
|
+
color: STYLES.textMuted,
|
|
500
|
+
wordBreak: "break-all"
|
|
501
|
+
},
|
|
502
|
+
children: sourceData.relativePath
|
|
503
|
+
}
|
|
504
|
+
),
|
|
505
|
+
/* @__PURE__ */ jsx(
|
|
506
|
+
"div",
|
|
507
|
+
{
|
|
508
|
+
style: {
|
|
509
|
+
backgroundColor: STYLES.bgSurface,
|
|
510
|
+
borderRadius: "8px",
|
|
511
|
+
overflow: "hidden",
|
|
512
|
+
border: `1px solid ${STYLES.border}`
|
|
513
|
+
},
|
|
514
|
+
children: /* @__PURE__ */ jsx(
|
|
515
|
+
"pre",
|
|
516
|
+
{
|
|
517
|
+
style: {
|
|
518
|
+
margin: 0,
|
|
519
|
+
padding: "12px 0",
|
|
520
|
+
overflow: "auto",
|
|
521
|
+
fontSize: "12px",
|
|
522
|
+
lineHeight: "1.6",
|
|
523
|
+
fontFamily: STYLES.fontMono
|
|
524
|
+
},
|
|
525
|
+
children: sourceData.lines.map((line, index) => {
|
|
526
|
+
const lineNumber = sourceData.startLine + index;
|
|
527
|
+
const isHighlight = lineNumber === sourceData.highlightLine;
|
|
528
|
+
return /* @__PURE__ */ jsxs(
|
|
529
|
+
"div",
|
|
530
|
+
{
|
|
531
|
+
style: {
|
|
532
|
+
display: "flex",
|
|
533
|
+
backgroundColor: isHighlight ? "rgba(59, 130, 246, 0.2)" : "transparent",
|
|
534
|
+
borderLeft: isHighlight ? `3px solid ${STYLES.accent}` : "3px solid transparent"
|
|
535
|
+
},
|
|
536
|
+
children: [
|
|
537
|
+
/* @__PURE__ */ jsx(
|
|
538
|
+
"span",
|
|
539
|
+
{
|
|
540
|
+
style: {
|
|
541
|
+
display: "inline-block",
|
|
542
|
+
width: "48px",
|
|
543
|
+
paddingRight: "12px",
|
|
544
|
+
textAlign: "right",
|
|
545
|
+
color: isHighlight ? STYLES.accent : STYLES.textDim,
|
|
546
|
+
userSelect: "none",
|
|
547
|
+
flexShrink: 0
|
|
548
|
+
},
|
|
549
|
+
children: lineNumber
|
|
550
|
+
}
|
|
551
|
+
),
|
|
552
|
+
/* @__PURE__ */ jsx(
|
|
553
|
+
"code",
|
|
554
|
+
{
|
|
555
|
+
style: {
|
|
556
|
+
color: isHighlight ? STYLES.text : STYLES.textMuted,
|
|
557
|
+
whiteSpace: "pre"
|
|
558
|
+
},
|
|
559
|
+
children: line || " "
|
|
560
|
+
}
|
|
561
|
+
)
|
|
562
|
+
]
|
|
563
|
+
},
|
|
564
|
+
lineNumber
|
|
565
|
+
);
|
|
566
|
+
})
|
|
567
|
+
}
|
|
568
|
+
)
|
|
569
|
+
}
|
|
570
|
+
)
|
|
571
|
+
] });
|
|
572
|
+
}
|
|
573
|
+
function Section({
|
|
574
|
+
title,
|
|
575
|
+
children
|
|
576
|
+
}) {
|
|
577
|
+
return /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
578
|
+
/* @__PURE__ */ jsx(
|
|
579
|
+
"div",
|
|
580
|
+
{
|
|
581
|
+
style: {
|
|
582
|
+
fontSize: "11px",
|
|
583
|
+
fontWeight: 600,
|
|
584
|
+
color: STYLES.textDim,
|
|
585
|
+
textTransform: "uppercase",
|
|
586
|
+
letterSpacing: "0.5px",
|
|
587
|
+
marginBottom: "8px"
|
|
588
|
+
},
|
|
589
|
+
children: title
|
|
590
|
+
}
|
|
591
|
+
),
|
|
592
|
+
children
|
|
593
|
+
] });
|
|
594
|
+
}
|
|
595
|
+
function InfoRow({
|
|
596
|
+
label,
|
|
597
|
+
value,
|
|
598
|
+
mono
|
|
599
|
+
}) {
|
|
600
|
+
return /* @__PURE__ */ jsxs(
|
|
601
|
+
"div",
|
|
602
|
+
{
|
|
603
|
+
style: {
|
|
604
|
+
display: "flex",
|
|
605
|
+
justifyContent: "space-between",
|
|
606
|
+
alignItems: "flex-start",
|
|
607
|
+
fontSize: "12px",
|
|
608
|
+
marginBottom: "4px"
|
|
609
|
+
},
|
|
610
|
+
children: [
|
|
611
|
+
/* @__PURE__ */ jsx("span", { style: { color: STYLES.textMuted }, children: label }),
|
|
612
|
+
/* @__PURE__ */ jsx(
|
|
613
|
+
"span",
|
|
614
|
+
{
|
|
615
|
+
style: {
|
|
616
|
+
color: STYLES.text,
|
|
617
|
+
fontFamily: mono ? STYLES.fontMono : void 0,
|
|
618
|
+
textAlign: "right",
|
|
619
|
+
maxWidth: "200px",
|
|
620
|
+
wordBreak: "break-word"
|
|
621
|
+
},
|
|
622
|
+
children: value
|
|
623
|
+
}
|
|
624
|
+
)
|
|
625
|
+
]
|
|
626
|
+
}
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
function ComponentStackItem({
|
|
630
|
+
component,
|
|
631
|
+
index,
|
|
632
|
+
isFirst
|
|
633
|
+
}) {
|
|
634
|
+
const handleClick = useCallback(() => {
|
|
635
|
+
if (component.source) {
|
|
636
|
+
const url = buildEditorUrl(component.source, "cursor");
|
|
637
|
+
window.open(url, "_blank");
|
|
638
|
+
}
|
|
639
|
+
}, [component.source]);
|
|
640
|
+
return /* @__PURE__ */ jsxs(
|
|
641
|
+
"div",
|
|
642
|
+
{
|
|
643
|
+
style: {
|
|
644
|
+
display: "flex",
|
|
645
|
+
alignItems: "center",
|
|
646
|
+
gap: "8px",
|
|
647
|
+
padding: "6px 8px",
|
|
648
|
+
marginLeft: index * 8,
|
|
649
|
+
backgroundColor: isFirst ? "rgba(59, 130, 246, 0.1)" : "transparent",
|
|
650
|
+
borderRadius: "4px",
|
|
651
|
+
cursor: component.source ? "pointer" : "default",
|
|
652
|
+
transition: "background-color 0.15s"
|
|
653
|
+
},
|
|
654
|
+
onClick: handleClick,
|
|
655
|
+
onMouseEnter: (e) => {
|
|
656
|
+
if (component.source) {
|
|
657
|
+
e.currentTarget.style.backgroundColor = "rgba(59, 130, 246, 0.15)";
|
|
658
|
+
}
|
|
659
|
+
},
|
|
660
|
+
onMouseLeave: (e) => {
|
|
661
|
+
e.currentTarget.style.backgroundColor = isFirst ? "rgba(59, 130, 246, 0.1)" : "transparent";
|
|
662
|
+
},
|
|
663
|
+
children: [
|
|
664
|
+
/* @__PURE__ */ jsx(
|
|
665
|
+
"span",
|
|
666
|
+
{
|
|
667
|
+
style: {
|
|
668
|
+
fontSize: "12px",
|
|
669
|
+
fontWeight: isFirst ? 600 : 400,
|
|
670
|
+
color: isFirst ? STYLES.accent : STYLES.textMuted
|
|
671
|
+
},
|
|
672
|
+
children: component.name
|
|
673
|
+
}
|
|
674
|
+
),
|
|
675
|
+
component.source && /* @__PURE__ */ jsxs(
|
|
676
|
+
"span",
|
|
677
|
+
{
|
|
678
|
+
style: {
|
|
679
|
+
fontSize: "10px",
|
|
680
|
+
color: STYLES.textDim,
|
|
681
|
+
fontFamily: STYLES.fontMono
|
|
682
|
+
},
|
|
683
|
+
children: [
|
|
684
|
+
":",
|
|
685
|
+
component.source.lineNumber
|
|
686
|
+
]
|
|
687
|
+
}
|
|
688
|
+
)
|
|
689
|
+
]
|
|
690
|
+
}
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
function OpenIcon() {
|
|
694
|
+
return /* @__PURE__ */ jsx("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
|
|
695
|
+
"path",
|
|
696
|
+
{
|
|
697
|
+
d: "M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6M15 3h6v6M10 14L21 3",
|
|
698
|
+
stroke: "currentColor",
|
|
699
|
+
strokeWidth: "2",
|
|
700
|
+
strokeLinecap: "round",
|
|
701
|
+
strokeLinejoin: "round"
|
|
702
|
+
}
|
|
703
|
+
) });
|
|
704
|
+
}
|
|
705
|
+
function CloseIcon() {
|
|
706
|
+
return /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
|
|
707
|
+
"path",
|
|
708
|
+
{
|
|
709
|
+
d: "M18 6L6 18M6 6l12 12",
|
|
710
|
+
stroke: "currentColor",
|
|
711
|
+
strokeWidth: "2",
|
|
712
|
+
strokeLinecap: "round",
|
|
713
|
+
strokeLinejoin: "round"
|
|
714
|
+
}
|
|
715
|
+
) });
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
export {
|
|
719
|
+
fetchSource,
|
|
720
|
+
fetchSourceWithContext,
|
|
721
|
+
clearSourceCache,
|
|
722
|
+
getCachedSource,
|
|
723
|
+
prefetchSources,
|
|
724
|
+
InspectionPanel
|
|
725
|
+
};
|