react-reinspect 0.1.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/LICENSE +21 -0
- package/README.md +66 -0
- package/dist/lib/autoWrap.d.ts +9 -0
- package/dist/lib/autoWrap.d.ts.map +1 -0
- package/dist/lib/constants.d.ts +7 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/context.d.ts +4 -0
- package/dist/lib/context.d.ts.map +1 -0
- package/dist/lib/index.cjs +1 -0
- package/dist/lib/index.d.ts +10 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +1263 -0
- package/dist/lib/propsInspector.d.ts +31 -0
- package/dist/lib/propsInspector.d.ts.map +1 -0
- package/dist/lib/store.d.ts +3 -0
- package/dist/lib/store.d.ts.map +1 -0
- package/dist/lib/style.css +2 -0
- package/dist/lib/types.d.ts +57 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/useReinspect.d.ts +3 -0
- package/dist/lib/useReinspect.d.ts.map +1 -0
- package/dist/lib/utils.d.ts +13 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/withReinspect.d.ts +11 -0
- package/dist/lib/withReinspect.d.ts.map +1 -0
- package/dist/lib/wrapInspectableMap.d.ts +9 -0
- package/dist/lib/wrapInspectableMap.d.ts.map +1 -0
- package/dist/lib/wrapMarker.d.ts +11 -0
- package/dist/lib/wrapMarker.d.ts.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,1263 @@
|
|
|
1
|
+
import { createContext as e, useCallback as t, useContext as n, useEffect as r, useId as i, useMemo as a, useRef as o, useState as s } from "react";
|
|
2
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
3
|
+
import { createPortal as d } from "react-dom";
|
|
4
|
+
//#region src/reinspect/store.ts
|
|
5
|
+
var f = e(null);
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/reinspect/useReinspect.ts
|
|
8
|
+
function p() {
|
|
9
|
+
let e = n(f);
|
|
10
|
+
if (!e) throw Error("useReinspect must be used within ReinspectProvider");
|
|
11
|
+
return e;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/reinspect/constants.ts
|
|
15
|
+
var m = [
|
|
16
|
+
"backgroundColor",
|
|
17
|
+
"color",
|
|
18
|
+
"fontSize",
|
|
19
|
+
"padding",
|
|
20
|
+
"margin",
|
|
21
|
+
"borderRadius",
|
|
22
|
+
"borderWidth",
|
|
23
|
+
"borderColor",
|
|
24
|
+
"opacity",
|
|
25
|
+
"width",
|
|
26
|
+
"height",
|
|
27
|
+
"gap"
|
|
28
|
+
], h = [
|
|
29
|
+
"#f97316",
|
|
30
|
+
"#2563eb",
|
|
31
|
+
"#16a34a",
|
|
32
|
+
"#db2777",
|
|
33
|
+
"#ca8a04",
|
|
34
|
+
"#0f766e"
|
|
35
|
+
], g = new Set([
|
|
36
|
+
"backgroundColor",
|
|
37
|
+
"color",
|
|
38
|
+
"borderColor"
|
|
39
|
+
]), _ = new Set([
|
|
40
|
+
"fontSize",
|
|
41
|
+
"padding",
|
|
42
|
+
"margin",
|
|
43
|
+
"borderRadius",
|
|
44
|
+
"borderWidth",
|
|
45
|
+
"width",
|
|
46
|
+
"height",
|
|
47
|
+
"gap"
|
|
48
|
+
]), v = 2147483e3, y = "reinspect.inspectMode", b = [
|
|
49
|
+
"wrapped",
|
|
50
|
+
"first-party",
|
|
51
|
+
"all"
|
|
52
|
+
], x = [
|
|
53
|
+
"attempts",
|
|
54
|
+
"commits",
|
|
55
|
+
"both"
|
|
56
|
+
];
|
|
57
|
+
function S() {
|
|
58
|
+
return !1;
|
|
59
|
+
}
|
|
60
|
+
function C(e) {
|
|
61
|
+
return typeof e == "string" && b.includes(e);
|
|
62
|
+
}
|
|
63
|
+
function w(e) {
|
|
64
|
+
return typeof e == "string" && x.includes(e);
|
|
65
|
+
}
|
|
66
|
+
function T() {
|
|
67
|
+
if (!(typeof window > "u")) try {
|
|
68
|
+
let e = window.sessionStorage.getItem(y);
|
|
69
|
+
return C(e) ? e : void 0;
|
|
70
|
+
} catch {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function E(e) {
|
|
75
|
+
return T() || (C(e) ? e : "wrapped");
|
|
76
|
+
}
|
|
77
|
+
function D(e) {
|
|
78
|
+
if (!(typeof window > "u")) try {
|
|
79
|
+
window.sessionStorage.setItem(y, e);
|
|
80
|
+
} catch {}
|
|
81
|
+
}
|
|
82
|
+
function ee() {
|
|
83
|
+
if (!(typeof window > "u")) try {
|
|
84
|
+
window.location.reload();
|
|
85
|
+
} catch {}
|
|
86
|
+
}
|
|
87
|
+
function O(e = {}) {
|
|
88
|
+
let t = e.enabled ?? S(), n = e.editableProps && e.editableProps.length > 0 ? e.editableProps : m, r = e.palette && e.palette.length > 0 ? e.palette : h;
|
|
89
|
+
return {
|
|
90
|
+
enabled: t,
|
|
91
|
+
startActive: e.startActive ?? !0,
|
|
92
|
+
showFloatingToggle: e.showFloatingToggle ?? t,
|
|
93
|
+
inspectMode: E(e.inspectMode),
|
|
94
|
+
editableProps: n,
|
|
95
|
+
palette: r,
|
|
96
|
+
zIndexBase: e.zIndexBase ?? v,
|
|
97
|
+
shouldCountRenders: e.shouldCountRenders ?? !1,
|
|
98
|
+
countRendersForComponents: e.countRendersForComponents ?? [],
|
|
99
|
+
renderCaptureMode: w(e.renderCaptureMode) ? e.renderCaptureMode : "attempts"
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function k(e) {
|
|
103
|
+
let t = 0;
|
|
104
|
+
for (let n = 0; n < e.length; n += 1) t = (t << 5) - t + e.charCodeAt(n), t |= 0;
|
|
105
|
+
return Math.abs(t);
|
|
106
|
+
}
|
|
107
|
+
function A(e, t) {
|
|
108
|
+
return t.length === 0 ? h[0] : t[k(e) % t.length];
|
|
109
|
+
}
|
|
110
|
+
function te(e, t) {
|
|
111
|
+
if (!e) return {};
|
|
112
|
+
let n = {};
|
|
113
|
+
for (let r of t) {
|
|
114
|
+
let t = e[r];
|
|
115
|
+
t == null || t === "" || (n[r] = t);
|
|
116
|
+
}
|
|
117
|
+
return n;
|
|
118
|
+
}
|
|
119
|
+
function ne(e) {
|
|
120
|
+
if (!e) return "#1f2937";
|
|
121
|
+
if (/^#[0-9a-fA-F]{6}$/.test(e)) return e;
|
|
122
|
+
if (/^#[0-9a-fA-F]{3}$/.test(e)) {
|
|
123
|
+
let [, t, n, r] = e;
|
|
124
|
+
return `#${t}${t}${n}${n}${r}${r}`;
|
|
125
|
+
}
|
|
126
|
+
return "#1f2937";
|
|
127
|
+
}
|
|
128
|
+
function re(e) {
|
|
129
|
+
let t = Number(e);
|
|
130
|
+
if (Number.isFinite(t)) return t;
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/reinspect/context.tsx
|
|
134
|
+
var ie = "Capture rerenders and show totals next to component badges.", j = "Tracks every rerender after initial mount for wrapped components. Use this toggle to capture for all components, or enable a specific component from its right-click inspector menu.", M = "Choose whether to count render attempts, committed renders, or both.", N = "Render attempts track render-phase executions (includes Strict Mode extra passes). Committed renders track completed DOM commits. Both shows both counters together.", P = "Controls which components are automatically discoverable by Reinspect.", ae = "Only wrapped components uses explicit withReinspect wrappers only. All 1st-party components auto-discovers components under your source tree. All components also attempts dependency components (with safety skips).";
|
|
135
|
+
function oe(e) {
|
|
136
|
+
let t = {};
|
|
137
|
+
for (let n of e) t[n] = !0;
|
|
138
|
+
return t;
|
|
139
|
+
}
|
|
140
|
+
function se({ children: e, config: n }) {
|
|
141
|
+
let r = a(() => O(n), [n]), [i, o] = s(r.startActive), [c] = s(r.inspectMode), [d, p] = s(r.inspectMode), [m, h] = s(r.shouldCountRenders), [g, _] = s(r.renderCaptureMode), [v, y] = s(() => oe(r.countRendersForComponents)), [b, x] = s({}), S = t((e, t, n) => {
|
|
142
|
+
x((r) => {
|
|
143
|
+
let i = { ...r[e] ?? {} };
|
|
144
|
+
if (n == null || n === "" ? delete i[t] : i[t] = n, Object.keys(i).length === 0) {
|
|
145
|
+
let t = { ...r };
|
|
146
|
+
return delete t[e], t;
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
...r,
|
|
150
|
+
[e]: i
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
}, []), C = t((e, t) => {
|
|
154
|
+
y((n) => {
|
|
155
|
+
if (t) return {
|
|
156
|
+
...n,
|
|
157
|
+
[e]: !0
|
|
158
|
+
};
|
|
159
|
+
if (!n[e]) return n;
|
|
160
|
+
let r = { ...n };
|
|
161
|
+
return delete r[e], r;
|
|
162
|
+
});
|
|
163
|
+
}, []), w = t((e) => m || !!v[e], [m, v]), T = d !== c, E = t(() => {
|
|
164
|
+
T && (D(d), ee());
|
|
165
|
+
}, [T, d]), k = t((e) => A(e, r.palette), [r.palette]), te = a(() => ({
|
|
166
|
+
config: r,
|
|
167
|
+
isActive: r.enabled && i,
|
|
168
|
+
setIsActive: o,
|
|
169
|
+
inspectMode: c,
|
|
170
|
+
pendingInspectMode: d,
|
|
171
|
+
setPendingInspectMode: p,
|
|
172
|
+
hasPendingInspectModeChange: T,
|
|
173
|
+
applyInspectMode: E,
|
|
174
|
+
shouldCountRenders: m,
|
|
175
|
+
setShouldCountRenders: h,
|
|
176
|
+
renderCaptureMode: g,
|
|
177
|
+
setRenderCaptureMode: _,
|
|
178
|
+
renderCountComponents: v,
|
|
179
|
+
setRenderCountingForComponent: C,
|
|
180
|
+
isRenderCountingEnabledFor: w,
|
|
181
|
+
overrides: b,
|
|
182
|
+
updateOverride: S,
|
|
183
|
+
getBorderColor: k
|
|
184
|
+
}), [
|
|
185
|
+
r,
|
|
186
|
+
i,
|
|
187
|
+
c,
|
|
188
|
+
d,
|
|
189
|
+
p,
|
|
190
|
+
T,
|
|
191
|
+
E,
|
|
192
|
+
m,
|
|
193
|
+
g,
|
|
194
|
+
v,
|
|
195
|
+
C,
|
|
196
|
+
w,
|
|
197
|
+
b,
|
|
198
|
+
S,
|
|
199
|
+
k
|
|
200
|
+
]);
|
|
201
|
+
return /* @__PURE__ */ u(f.Provider, {
|
|
202
|
+
value: te,
|
|
203
|
+
children: [e, r.enabled && r.showFloatingToggle ? /* @__PURE__ */ l(F, {}) : null]
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function F() {
|
|
207
|
+
let { config: e, isActive: t, setIsActive: n, inspectMode: i, pendingInspectMode: a, setPendingInspectMode: c, hasPendingInspectModeChange: d, applyInspectMode: f, shouldCountRenders: m, setShouldCountRenders: h, renderCaptureMode: g, setRenderCaptureMode: _ } = p(), [v, y] = s(!1), b = o(null);
|
|
208
|
+
return r(() => {
|
|
209
|
+
if (!v) return;
|
|
210
|
+
let e = (e) => {
|
|
211
|
+
let t = e.target;
|
|
212
|
+
b.current?.contains(t) || y(!1);
|
|
213
|
+
}, t = (e) => {
|
|
214
|
+
e.key === "Escape" && y(!1);
|
|
215
|
+
};
|
|
216
|
+
return document.addEventListener("mousedown", e), document.addEventListener("keydown", t), () => {
|
|
217
|
+
document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
|
|
218
|
+
};
|
|
219
|
+
}, [v]), e.enabled ? /* @__PURE__ */ u("div", {
|
|
220
|
+
className: "reinspect-floating-root",
|
|
221
|
+
ref: b,
|
|
222
|
+
children: [/* @__PURE__ */ l("button", {
|
|
223
|
+
type: "button",
|
|
224
|
+
className: "reinspect-floating-toggle",
|
|
225
|
+
"data-testid": "reinspect-floating-toggle",
|
|
226
|
+
onClick: () => y((e) => !e),
|
|
227
|
+
"aria-expanded": v,
|
|
228
|
+
"aria-controls": "reinspect-settings-menu",
|
|
229
|
+
children: "Reinspect settings"
|
|
230
|
+
}), v ? /* @__PURE__ */ u("div", {
|
|
231
|
+
id: "reinspect-settings-menu",
|
|
232
|
+
className: "reinspect-settings-menu",
|
|
233
|
+
role: "dialog",
|
|
234
|
+
"aria-label": "Reinspect settings",
|
|
235
|
+
"data-testid": "reinspect-settings-menu",
|
|
236
|
+
children: [
|
|
237
|
+
/* @__PURE__ */ l("p", {
|
|
238
|
+
className: "reinspect-settings-title",
|
|
239
|
+
children: "Reinspect settings"
|
|
240
|
+
}),
|
|
241
|
+
/* @__PURE__ */ u("label", {
|
|
242
|
+
className: "reinspect-settings-toggle-row",
|
|
243
|
+
children: [/* @__PURE__ */ l("span", {
|
|
244
|
+
className: "reinspect-settings-toggle-label",
|
|
245
|
+
children: "Inspector enabled"
|
|
246
|
+
}), /* @__PURE__ */ l("input", {
|
|
247
|
+
"data-testid": "reinspect-setting-inspector-active",
|
|
248
|
+
type: "checkbox",
|
|
249
|
+
checked: t,
|
|
250
|
+
onChange: (e) => n(e.currentTarget.checked)
|
|
251
|
+
})]
|
|
252
|
+
}),
|
|
253
|
+
/* @__PURE__ */ l("div", { className: "reinspect-settings-divider" }),
|
|
254
|
+
/* @__PURE__ */ u("section", {
|
|
255
|
+
className: "reinspect-setting-block",
|
|
256
|
+
children: [
|
|
257
|
+
/* @__PURE__ */ u("header", {
|
|
258
|
+
className: "reinspect-setting-header",
|
|
259
|
+
children: [/* @__PURE__ */ u("div", { children: [/* @__PURE__ */ l("p", {
|
|
260
|
+
className: "reinspect-setting-name",
|
|
261
|
+
children: "INSPECT_MODE"
|
|
262
|
+
}), /* @__PURE__ */ l("p", {
|
|
263
|
+
className: "reinspect-setting-short-description",
|
|
264
|
+
children: P
|
|
265
|
+
})] }), /* @__PURE__ */ u("span", {
|
|
266
|
+
className: "reinspect-tooltip-host",
|
|
267
|
+
children: [/* @__PURE__ */ l("button", {
|
|
268
|
+
type: "button",
|
|
269
|
+
className: "reinspect-tooltip-trigger",
|
|
270
|
+
"aria-label": "Explain INSPECT_MODE",
|
|
271
|
+
children: "?"
|
|
272
|
+
}), /* @__PURE__ */ l("span", {
|
|
273
|
+
className: "reinspect-tooltip-content",
|
|
274
|
+
role: "tooltip",
|
|
275
|
+
children: ae
|
|
276
|
+
})]
|
|
277
|
+
})]
|
|
278
|
+
}),
|
|
279
|
+
/* @__PURE__ */ u("label", {
|
|
280
|
+
className: "reinspect-settings-select-row",
|
|
281
|
+
children: [/* @__PURE__ */ l("span", {
|
|
282
|
+
className: "reinspect-settings-toggle-label",
|
|
283
|
+
children: "Inspect Mode"
|
|
284
|
+
}), /* @__PURE__ */ u("select", {
|
|
285
|
+
"data-testid": "reinspect-setting-inspect-mode",
|
|
286
|
+
value: a,
|
|
287
|
+
onChange: (e) => {
|
|
288
|
+
let t = e.currentTarget.value;
|
|
289
|
+
C(t) && c(t);
|
|
290
|
+
},
|
|
291
|
+
children: [
|
|
292
|
+
/* @__PURE__ */ l("option", {
|
|
293
|
+
value: "wrapped",
|
|
294
|
+
children: "Only wrapped components"
|
|
295
|
+
}),
|
|
296
|
+
/* @__PURE__ */ l("option", {
|
|
297
|
+
value: "first-party",
|
|
298
|
+
children: "All 1st-party components"
|
|
299
|
+
}),
|
|
300
|
+
/* @__PURE__ */ l("option", {
|
|
301
|
+
value: "all",
|
|
302
|
+
children: "All components"
|
|
303
|
+
})
|
|
304
|
+
]
|
|
305
|
+
})]
|
|
306
|
+
}),
|
|
307
|
+
/* @__PURE__ */ l("button", {
|
|
308
|
+
type: "button",
|
|
309
|
+
className: "reinspect-apply-button",
|
|
310
|
+
"data-testid": "reinspect-apply-inspect-mode",
|
|
311
|
+
onClick: f,
|
|
312
|
+
disabled: !d,
|
|
313
|
+
children: "Apply & Reload"
|
|
314
|
+
}),
|
|
315
|
+
d ? /* @__PURE__ */ l("p", {
|
|
316
|
+
className: "reinspect-setting-note",
|
|
317
|
+
"data-testid": "reinspect-inspect-mode-reload-note",
|
|
318
|
+
children: "Inspect mode changes are applied after reload."
|
|
319
|
+
}) : /* @__PURE__ */ u("p", {
|
|
320
|
+
className: "reinspect-setting-note",
|
|
321
|
+
children: ["Current mode: ", i]
|
|
322
|
+
})
|
|
323
|
+
]
|
|
324
|
+
}),
|
|
325
|
+
/* @__PURE__ */ l("div", { className: "reinspect-settings-divider" }),
|
|
326
|
+
/* @__PURE__ */ u("section", {
|
|
327
|
+
className: "reinspect-setting-block",
|
|
328
|
+
children: [
|
|
329
|
+
/* @__PURE__ */ u("header", {
|
|
330
|
+
className: "reinspect-setting-header",
|
|
331
|
+
children: [/* @__PURE__ */ u("div", { children: [/* @__PURE__ */ l("p", {
|
|
332
|
+
className: "reinspect-setting-name",
|
|
333
|
+
children: "SHOULD_COUNT_RENDERS"
|
|
334
|
+
}), /* @__PURE__ */ l("p", {
|
|
335
|
+
className: "reinspect-setting-short-description",
|
|
336
|
+
children: ie
|
|
337
|
+
})] }), /* @__PURE__ */ u("span", {
|
|
338
|
+
className: "reinspect-tooltip-host",
|
|
339
|
+
children: [/* @__PURE__ */ l("button", {
|
|
340
|
+
type: "button",
|
|
341
|
+
className: "reinspect-tooltip-trigger",
|
|
342
|
+
"aria-label": "Explain SHOULD_COUNT_RENDERS",
|
|
343
|
+
children: "?"
|
|
344
|
+
}), /* @__PURE__ */ l("span", {
|
|
345
|
+
className: "reinspect-tooltip-content",
|
|
346
|
+
role: "tooltip",
|
|
347
|
+
children: j
|
|
348
|
+
})]
|
|
349
|
+
})]
|
|
350
|
+
}),
|
|
351
|
+
/* @__PURE__ */ u("label", {
|
|
352
|
+
className: "reinspect-settings-toggle-row",
|
|
353
|
+
children: [/* @__PURE__ */ l("span", {
|
|
354
|
+
className: "reinspect-settings-toggle-label",
|
|
355
|
+
children: "Capture render for all components"
|
|
356
|
+
}), /* @__PURE__ */ l("input", {
|
|
357
|
+
"data-testid": "reinspect-setting-should-count-renders",
|
|
358
|
+
type: "checkbox",
|
|
359
|
+
checked: m,
|
|
360
|
+
onChange: (e) => h(e.currentTarget.checked)
|
|
361
|
+
})]
|
|
362
|
+
}),
|
|
363
|
+
/* @__PURE__ */ u("header", {
|
|
364
|
+
className: "reinspect-setting-header",
|
|
365
|
+
children: [/* @__PURE__ */ u("div", { children: [/* @__PURE__ */ l("p", {
|
|
366
|
+
className: "reinspect-setting-name",
|
|
367
|
+
children: "RENDER_CAPTURE_MODE"
|
|
368
|
+
}), /* @__PURE__ */ l("p", {
|
|
369
|
+
className: "reinspect-setting-short-description",
|
|
370
|
+
children: M
|
|
371
|
+
})] }), /* @__PURE__ */ u("span", {
|
|
372
|
+
className: "reinspect-tooltip-host",
|
|
373
|
+
children: [/* @__PURE__ */ l("button", {
|
|
374
|
+
type: "button",
|
|
375
|
+
className: "reinspect-tooltip-trigger",
|
|
376
|
+
"aria-label": "Explain RENDER_CAPTURE_MODE",
|
|
377
|
+
children: "?"
|
|
378
|
+
}), /* @__PURE__ */ l("span", {
|
|
379
|
+
className: "reinspect-tooltip-content",
|
|
380
|
+
role: "tooltip",
|
|
381
|
+
children: N
|
|
382
|
+
})]
|
|
383
|
+
})]
|
|
384
|
+
}),
|
|
385
|
+
/* @__PURE__ */ u("label", {
|
|
386
|
+
className: "reinspect-settings-select-row",
|
|
387
|
+
children: [/* @__PURE__ */ l("span", {
|
|
388
|
+
className: "reinspect-settings-toggle-label",
|
|
389
|
+
children: "Capture mode"
|
|
390
|
+
}), /* @__PURE__ */ u("select", {
|
|
391
|
+
"data-testid": "reinspect-setting-render-capture-mode",
|
|
392
|
+
value: g,
|
|
393
|
+
onChange: (e) => {
|
|
394
|
+
let t = e.currentTarget.value;
|
|
395
|
+
w(t) && _(t);
|
|
396
|
+
},
|
|
397
|
+
children: [
|
|
398
|
+
/* @__PURE__ */ l("option", {
|
|
399
|
+
value: "attempts",
|
|
400
|
+
children: "Render attempts"
|
|
401
|
+
}),
|
|
402
|
+
/* @__PURE__ */ l("option", {
|
|
403
|
+
value: "commits",
|
|
404
|
+
children: "Committed renders"
|
|
405
|
+
}),
|
|
406
|
+
/* @__PURE__ */ l("option", {
|
|
407
|
+
value: "both",
|
|
408
|
+
children: "Both"
|
|
409
|
+
})
|
|
410
|
+
]
|
|
411
|
+
})]
|
|
412
|
+
})
|
|
413
|
+
]
|
|
414
|
+
})
|
|
415
|
+
]
|
|
416
|
+
}) : null]
|
|
417
|
+
}) : null;
|
|
418
|
+
}
|
|
419
|
+
//#endregion
|
|
420
|
+
//#region src/reinspect/propsInspector.ts
|
|
421
|
+
var I = 4, L = 40, R = 40, z = "__reinspect_placeholder__";
|
|
422
|
+
function B(e, t) {
|
|
423
|
+
return {
|
|
424
|
+
[z]: e,
|
|
425
|
+
display: t
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
function V(e) {
|
|
429
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
430
|
+
}
|
|
431
|
+
function H(e) {
|
|
432
|
+
if (!V(e)) return !1;
|
|
433
|
+
let t = Object.getPrototypeOf(e);
|
|
434
|
+
return t === Object.prototype || t === null;
|
|
435
|
+
}
|
|
436
|
+
function U(e) {
|
|
437
|
+
return V(e) && typeof e.__reinspect_placeholder__ == "string" && typeof e.display == "string";
|
|
438
|
+
}
|
|
439
|
+
function ce(e) {
|
|
440
|
+
try {
|
|
441
|
+
return JSON.stringify(e, null, 2);
|
|
442
|
+
} catch {
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
function W(e) {
|
|
447
|
+
try {
|
|
448
|
+
let t = Function.prototype.toString.call(e);
|
|
449
|
+
return typeof t != "string" || t.trim().length === 0 ? "[Function source unavailable]" : t;
|
|
450
|
+
} catch {
|
|
451
|
+
return "[Function source unavailable]";
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
function le(e) {
|
|
455
|
+
let t = e.replace(/\s+/g, " ").trim();
|
|
456
|
+
return t.length <= 120 ? t : `${t.slice(0, 117)}...`;
|
|
457
|
+
}
|
|
458
|
+
function G(e, t, n) {
|
|
459
|
+
if (n > I) return B("truncated", "[Max depth reached]");
|
|
460
|
+
if (e === null) return null;
|
|
461
|
+
let r = typeof e;
|
|
462
|
+
if (r === "string" || r === "boolean") return e;
|
|
463
|
+
if (r === "number") return Number.isFinite(e) ? e : B("non-finite-number", String(e));
|
|
464
|
+
if (r === "undefined") return B("undefined", "undefined");
|
|
465
|
+
if (r === "bigint") return B("bigint", `${String(e)}n`);
|
|
466
|
+
if (r === "symbol") return B("symbol", String(e));
|
|
467
|
+
if (r === "function") return B("function", `[Function ${e.name || "anonymous"}]`);
|
|
468
|
+
if (e instanceof Date) return B("date", Number.isNaN(e.getTime()) ? "Invalid Date" : e.toISOString());
|
|
469
|
+
if (e instanceof RegExp) return B("regexp", e.toString());
|
|
470
|
+
if (r === "object") {
|
|
471
|
+
let r = e;
|
|
472
|
+
if (t.has(r)) return B("circular", "[Circular]");
|
|
473
|
+
if (t.add(r), Array.isArray(e)) {
|
|
474
|
+
let i = [], a = Math.min(e.length, R);
|
|
475
|
+
for (let r = 0; r < a; r += 1) i.push(G(e[r], t, n + 1));
|
|
476
|
+
return e.length > R && i.push(B("truncated", `${e.length - R} more items`)), t.delete(r), i;
|
|
477
|
+
}
|
|
478
|
+
let i = {}, a = Object.entries(e), o = Math.min(a.length, L);
|
|
479
|
+
for (let e = 0; e < o; e += 1) {
|
|
480
|
+
let [r, o] = a[e];
|
|
481
|
+
i[r] = G(o, t, n + 1);
|
|
482
|
+
}
|
|
483
|
+
return a.length > L && (i.__reinspect_truncated__ = B("truncated", `${a.length - L} more keys`)), t.delete(r), i;
|
|
484
|
+
}
|
|
485
|
+
return B("unsupported", "[Unsupported value]");
|
|
486
|
+
}
|
|
487
|
+
function ue(e) {
|
|
488
|
+
if (e === null) return {
|
|
489
|
+
kind: "null",
|
|
490
|
+
summary: "null",
|
|
491
|
+
copyText: "null"
|
|
492
|
+
};
|
|
493
|
+
let t = typeof e;
|
|
494
|
+
if (t === "undefined") return {
|
|
495
|
+
kind: "undefined",
|
|
496
|
+
summary: "undefined",
|
|
497
|
+
copyText: "undefined"
|
|
498
|
+
};
|
|
499
|
+
if (t === "boolean") return {
|
|
500
|
+
kind: "boolean",
|
|
501
|
+
summary: String(e),
|
|
502
|
+
copyText: String(e)
|
|
503
|
+
};
|
|
504
|
+
if (t === "number") return {
|
|
505
|
+
kind: "number",
|
|
506
|
+
summary: String(e),
|
|
507
|
+
copyText: String(e)
|
|
508
|
+
};
|
|
509
|
+
if (t === "string") return {
|
|
510
|
+
kind: "string",
|
|
511
|
+
summary: JSON.stringify(e),
|
|
512
|
+
copyText: String(e)
|
|
513
|
+
};
|
|
514
|
+
if (t === "bigint") return {
|
|
515
|
+
kind: "bigint",
|
|
516
|
+
summary: `${String(e)}n`,
|
|
517
|
+
copyText: `${String(e)}n`
|
|
518
|
+
};
|
|
519
|
+
if (t === "symbol") {
|
|
520
|
+
let t = String(e);
|
|
521
|
+
return {
|
|
522
|
+
kind: "symbol",
|
|
523
|
+
summary: t,
|
|
524
|
+
copyText: t
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
if (t === "function") {
|
|
528
|
+
let t = e, n = W(t), r = t.name || "anonymous";
|
|
529
|
+
return {
|
|
530
|
+
kind: "function",
|
|
531
|
+
summary: `Function ${r}(${t.length})`,
|
|
532
|
+
copyText: n,
|
|
533
|
+
functionMeta: {
|
|
534
|
+
name: r,
|
|
535
|
+
arity: t.length,
|
|
536
|
+
preview: le(n),
|
|
537
|
+
source: n
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
if (e instanceof Date) {
|
|
542
|
+
let t = Number.isNaN(e.getTime()) ? "Invalid Date" : e.toISOString();
|
|
543
|
+
return {
|
|
544
|
+
kind: "date",
|
|
545
|
+
summary: `Date ${t}`,
|
|
546
|
+
copyText: t
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
if (e instanceof RegExp) {
|
|
550
|
+
let t = e.toString();
|
|
551
|
+
return {
|
|
552
|
+
kind: "regexp",
|
|
553
|
+
summary: t,
|
|
554
|
+
copyText: t
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
return Array.isArray(e) ? {
|
|
558
|
+
kind: "array",
|
|
559
|
+
summary: `Array(${e.length})`
|
|
560
|
+
} : V(e) ? {
|
|
561
|
+
kind: "object",
|
|
562
|
+
summary: `Object(${Object.keys(e).length})`
|
|
563
|
+
} : {
|
|
564
|
+
kind: "unknown",
|
|
565
|
+
summary: String(e)
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
function K(e) {
|
|
569
|
+
if (!U(e)) {
|
|
570
|
+
if (Array.isArray(e)) {
|
|
571
|
+
let t = [];
|
|
572
|
+
for (let n of e) {
|
|
573
|
+
let e = K(n);
|
|
574
|
+
if (e === void 0) return;
|
|
575
|
+
t.push(e);
|
|
576
|
+
}
|
|
577
|
+
return t;
|
|
578
|
+
}
|
|
579
|
+
if (V(e)) {
|
|
580
|
+
let t = {};
|
|
581
|
+
for (let [n, r] of Object.entries(e)) {
|
|
582
|
+
let e = K(r);
|
|
583
|
+
e !== void 0 && (t[n] = e);
|
|
584
|
+
}
|
|
585
|
+
return t;
|
|
586
|
+
}
|
|
587
|
+
return e;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
function de(e) {
|
|
591
|
+
return Object.keys(e).map((t) => ({
|
|
592
|
+
key: t,
|
|
593
|
+
value: ue(e[t])
|
|
594
|
+
}));
|
|
595
|
+
}
|
|
596
|
+
function fe(e) {
|
|
597
|
+
return ce(G(e, /* @__PURE__ */ new WeakSet(), 0)) ?? "{}";
|
|
598
|
+
}
|
|
599
|
+
function pe(e) {
|
|
600
|
+
return ce(G(e, /* @__PURE__ */ new WeakSet(), 0));
|
|
601
|
+
}
|
|
602
|
+
function me(e) {
|
|
603
|
+
if (e === null) return !0;
|
|
604
|
+
let t = typeof e;
|
|
605
|
+
return t === "string" || t === "number" || t === "boolean" || Array.isArray(e) ? !0 : H(e);
|
|
606
|
+
}
|
|
607
|
+
function he(e) {
|
|
608
|
+
let t = e.trim();
|
|
609
|
+
if (t.length === 0) return {
|
|
610
|
+
parsed: null,
|
|
611
|
+
error: "Value JSON cannot be empty."
|
|
612
|
+
};
|
|
613
|
+
try {
|
|
614
|
+
let e = K(JSON.parse(t));
|
|
615
|
+
return e === void 0 || !me(e) ? {
|
|
616
|
+
parsed: null,
|
|
617
|
+
error: "Only objects, arrays, and primitive JSON values are editable."
|
|
618
|
+
} : {
|
|
619
|
+
parsed: e,
|
|
620
|
+
error: null
|
|
621
|
+
};
|
|
622
|
+
} catch {
|
|
623
|
+
return {
|
|
624
|
+
parsed: null,
|
|
625
|
+
error: "Invalid JSON. Fix syntax and try Apply again."
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
function ge(e) {
|
|
630
|
+
let t = e.trim();
|
|
631
|
+
if (t.length === 0) return {
|
|
632
|
+
parsed: {},
|
|
633
|
+
error: null
|
|
634
|
+
};
|
|
635
|
+
try {
|
|
636
|
+
let e = JSON.parse(t);
|
|
637
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return {
|
|
638
|
+
parsed: null,
|
|
639
|
+
error: "Props JSON must be an object (example: {\"title\":\"Demo\"})."
|
|
640
|
+
};
|
|
641
|
+
let n = {};
|
|
642
|
+
for (let [t, r] of Object.entries(e)) {
|
|
643
|
+
let e = K(r);
|
|
644
|
+
e !== void 0 && (n[t] = e);
|
|
645
|
+
}
|
|
646
|
+
return {
|
|
647
|
+
parsed: n,
|
|
648
|
+
error: null
|
|
649
|
+
};
|
|
650
|
+
} catch {
|
|
651
|
+
return {
|
|
652
|
+
parsed: null,
|
|
653
|
+
error: "Invalid JSON. Fix syntax and try Apply again."
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
//#endregion
|
|
658
|
+
//#region src/reinspect/wrapMarker.ts
|
|
659
|
+
var _e = Symbol.for("reinspect.wrapped");
|
|
660
|
+
function ve(e) {
|
|
661
|
+
return e[_e];
|
|
662
|
+
}
|
|
663
|
+
//#endregion
|
|
664
|
+
//#region src/reinspect/withReinspect.tsx
|
|
665
|
+
var ye = {
|
|
666
|
+
enabled: !1,
|
|
667
|
+
startActive: !1,
|
|
668
|
+
showFloatingToggle: !1,
|
|
669
|
+
inspectMode: "wrapped",
|
|
670
|
+
editableProps: [],
|
|
671
|
+
palette: [],
|
|
672
|
+
zIndexBase: 0,
|
|
673
|
+
shouldCountRenders: !1,
|
|
674
|
+
countRendersForComponents: [],
|
|
675
|
+
renderCaptureMode: "attempts"
|
|
676
|
+
}, be = /* @__PURE__ */ new Map();
|
|
677
|
+
function q(e) {
|
|
678
|
+
let t = be.get(e);
|
|
679
|
+
if (t) return t;
|
|
680
|
+
let n = {
|
|
681
|
+
attempts: 0,
|
|
682
|
+
commits: 0,
|
|
683
|
+
hasCommitted: !1,
|
|
684
|
+
wasCountingEnabled: !1,
|
|
685
|
+
shouldCountCommit: !1
|
|
686
|
+
};
|
|
687
|
+
return be.set(e, n), n;
|
|
688
|
+
}
|
|
689
|
+
function xe(e, t) {
|
|
690
|
+
let n = q(e);
|
|
691
|
+
if (!t) return n.wasCountingEnabled = !1, n.shouldCountCommit = !1, {
|
|
692
|
+
attempts: n.attempts,
|
|
693
|
+
commits: n.commits
|
|
694
|
+
};
|
|
695
|
+
let r = n.hasCommitted && n.wasCountingEnabled;
|
|
696
|
+
return r && (n.attempts += 1), n.wasCountingEnabled = !0, n.shouldCountCommit = r, {
|
|
697
|
+
attempts: n.attempts,
|
|
698
|
+
commits: n.commits + +!!r
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
function Se(e) {
|
|
702
|
+
let t = q(e);
|
|
703
|
+
t.hasCommitted && t.shouldCountCommit && (t.commits += 1), t.hasCommitted = !0, t.shouldCountCommit = !1;
|
|
704
|
+
}
|
|
705
|
+
function Ce(e, t) {
|
|
706
|
+
return t === "commits" ? `${e.commits} commits` : t === "both" ? `${e.attempts} attempts | ${e.commits} commits` : `${e.attempts} attempts`;
|
|
707
|
+
}
|
|
708
|
+
function we(e) {
|
|
709
|
+
let t = e.replace(/([A-Z])/g, " $1").trim();
|
|
710
|
+
return t.length > 0 ? t[0].toUpperCase() + t.slice(1) : e;
|
|
711
|
+
}
|
|
712
|
+
function Te(e) {
|
|
713
|
+
return e.trim().toLowerCase().replace(/[\s_-]+/g, "");
|
|
714
|
+
}
|
|
715
|
+
function J(e) {
|
|
716
|
+
return e != null && e !== "";
|
|
717
|
+
}
|
|
718
|
+
function Ee(e) {
|
|
719
|
+
return e.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
720
|
+
}
|
|
721
|
+
async function De(e) {
|
|
722
|
+
if (typeof navigator > "u" || !navigator.clipboard?.writeText) return !1;
|
|
723
|
+
try {
|
|
724
|
+
return await navigator.clipboard.writeText(e), !0;
|
|
725
|
+
} catch {
|
|
726
|
+
return !1;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
function Oe({ value: e, onCopy: t }) {
|
|
730
|
+
if (e.kind === "function" && e.functionMeta) {
|
|
731
|
+
let n = e.functionMeta;
|
|
732
|
+
return /* @__PURE__ */ u("div", {
|
|
733
|
+
className: "reinspect-prop-function",
|
|
734
|
+
children: [
|
|
735
|
+
/* @__PURE__ */ l("code", { children: e.summary }),
|
|
736
|
+
/* @__PURE__ */ l("pre", { children: n.preview }),
|
|
737
|
+
/* @__PURE__ */ l("button", {
|
|
738
|
+
type: "button",
|
|
739
|
+
onClick: () => t(n.source, "Function source"),
|
|
740
|
+
disabled: !n.source,
|
|
741
|
+
children: "Copy function source"
|
|
742
|
+
})
|
|
743
|
+
]
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
return /* @__PURE__ */ u("div", {
|
|
747
|
+
className: "reinspect-prop-scalar",
|
|
748
|
+
children: [/* @__PURE__ */ l("code", { children: e.summary }), e.copyText ? /* @__PURE__ */ l("button", {
|
|
749
|
+
type: "button",
|
|
750
|
+
onClick: () => t(e.copyText ?? "", "Value"),
|
|
751
|
+
children: "Copy"
|
|
752
|
+
}) : null]
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
function ke(e, t) {
|
|
756
|
+
return t?.name?.trim() || e.displayName?.trim() || e.name?.trim() || t?.fallbackName?.trim() || "Component";
|
|
757
|
+
}
|
|
758
|
+
function Ae(e, t, n) {
|
|
759
|
+
return e === "manual" || n === "all" || n === "first-party" && t === "first-party";
|
|
760
|
+
}
|
|
761
|
+
function Y(e, t) {
|
|
762
|
+
let a = t?.source ?? "manual", p = t?.scope ?? "first-party", m = ve(e);
|
|
763
|
+
if (m && a === "auto") return e;
|
|
764
|
+
let h = m && a === "manual" ? m.original : e, v = ke(h, t);
|
|
765
|
+
function y(e) {
|
|
766
|
+
let t = i(), m = o(null), y = o(null), [b, x] = s(null), [S, C] = s("css"), [w, T] = s("detected"), [E, D] = s(""), [ee, O] = s({}), [k, A] = s("{}"), [ie, j] = s(null), [M, N] = s(null), [P, ae] = s({}), [oe, se] = s({}), [F, I] = s({}), [L, R] = s(null), [z, B] = s(""), [V, H] = s(null), U = n(f), ce = !!U, W = U?.config ?? ye, le = U?.getBorderColor ?? (() => "#f97316"), G = U?.isActive ?? !1, ue = U?.inspectMode ?? "wrapped", K = U?.shouldCountRenders ?? !1, _e = U?.renderCaptureMode ?? ye.renderCaptureMode, ve = U?.overrides ?? {}, q = U?.updateOverride ?? (() => void 0), ke = U?.renderCountComponents ?? {}, Y = U?.setRenderCountingForComponent ?? (() => void 0), je = U?.isRenderCountingEnabledFor ?? (() => !1), X = `${v}-${t}`, Me = le(v), Ne = Ae(a, p, ue), Z = W.enabled && G && Ne, Pe = Ne && je(v), Fe = !!ke[v], Ie = xe(X, Pe), Le = ve[X], Re = Z ? te(Le, W.editableProps) : {}, Q = {
|
|
767
|
+
...e,
|
|
768
|
+
...ee
|
|
769
|
+
}, ze = Q, $ = Z && b !== null, Be = Te(E), Ve = Be.length === 0 ? W.editableProps : W.editableProps.filter((e) => Te(e).includes(Be)), He = $ && S === "props" && w === "detected" ? de(ze) : [];
|
|
770
|
+
r(() => (Se(X), () => {
|
|
771
|
+
be.delete(X);
|
|
772
|
+
}), [X]), r(() => {
|
|
773
|
+
if (!$) return;
|
|
774
|
+
let e = (e) => {
|
|
775
|
+
let t = e.target;
|
|
776
|
+
m.current?.contains(t) || y.current?.contains(t) || (x(null), R(null), B(""), H(null));
|
|
777
|
+
}, t = (e) => {
|
|
778
|
+
if (e.key === "Escape") {
|
|
779
|
+
if (L) {
|
|
780
|
+
R(null), B(""), H(null);
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
x(null);
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
return document.addEventListener("mousedown", e), document.addEventListener("keydown", t), () => {
|
|
787
|
+
document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
|
|
788
|
+
};
|
|
789
|
+
}, [L, $]), r(() => {
|
|
790
|
+
if (!M) return;
|
|
791
|
+
let e = globalThis.setTimeout(() => {
|
|
792
|
+
N(null);
|
|
793
|
+
}, 1400);
|
|
794
|
+
return () => {
|
|
795
|
+
globalThis.clearTimeout(e);
|
|
796
|
+
};
|
|
797
|
+
}, [M]);
|
|
798
|
+
let Ue = {
|
|
799
|
+
"--reinspect-color": Me,
|
|
800
|
+
"--reinspect-z-base": W.zIndexBase
|
|
801
|
+
}, We = (e) => {
|
|
802
|
+
Z && (e.preventDefault(), C("css"), T("detected"), D(""), j(null), N(null), ae({}), se({}), I({}), R(null), B(""), H(null), A("{}"), x({
|
|
803
|
+
x: e.clientX,
|
|
804
|
+
y: e.clientY
|
|
805
|
+
}));
|
|
806
|
+
}, Ge = () => {
|
|
807
|
+
let { parsed: e, error: t } = ge(k);
|
|
808
|
+
if (t || !e) {
|
|
809
|
+
j(t);
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
O(e), j(null);
|
|
813
|
+
}, Ke = () => {
|
|
814
|
+
O({}), w === "raw" && A(fe(e)), j(null);
|
|
815
|
+
}, qe = (e, t) => {
|
|
816
|
+
De(e).then((e) => {
|
|
817
|
+
N(e ? `${t} copied.` : "Clipboard access is unavailable.");
|
|
818
|
+
});
|
|
819
|
+
}, Je = (e, t) => {
|
|
820
|
+
if (F[e]) {
|
|
821
|
+
I((t) => ({
|
|
822
|
+
...t,
|
|
823
|
+
[e]: !1
|
|
824
|
+
}));
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
if (!(e in P) && !(e in oe)) {
|
|
828
|
+
let n = pe(t);
|
|
829
|
+
n === null ? se((t) => ({
|
|
830
|
+
...t,
|
|
831
|
+
[e]: "JSON preview is unavailable for this value."
|
|
832
|
+
})) : ae((t) => ({
|
|
833
|
+
...t,
|
|
834
|
+
[e]: n
|
|
835
|
+
}));
|
|
836
|
+
}
|
|
837
|
+
I((t) => ({
|
|
838
|
+
...t,
|
|
839
|
+
[e]: !0
|
|
840
|
+
}));
|
|
841
|
+
}, Ye = (e, t) => {
|
|
842
|
+
if (!me(t)) return;
|
|
843
|
+
let n = pe(t);
|
|
844
|
+
if (n === null) {
|
|
845
|
+
N("Unable to open editor for this value.");
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
R(e), B(n), H(null);
|
|
849
|
+
}, Xe = () => {
|
|
850
|
+
if (!L) return;
|
|
851
|
+
let { parsed: e, error: t } = he(z);
|
|
852
|
+
if (t || e === null) {
|
|
853
|
+
H(t);
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
O((t) => ({
|
|
857
|
+
...t,
|
|
858
|
+
[L]: e
|
|
859
|
+
})), R(null), B(""), H(null);
|
|
860
|
+
}, Ze = $ ? /* @__PURE__ */ u("div", {
|
|
861
|
+
ref: m,
|
|
862
|
+
className: "reinspect-menu",
|
|
863
|
+
role: "dialog",
|
|
864
|
+
"aria-label": `${v} inspector controls`,
|
|
865
|
+
style: {
|
|
866
|
+
top: `${b.y}px`,
|
|
867
|
+
left: `${b.x}px`
|
|
868
|
+
},
|
|
869
|
+
children: [
|
|
870
|
+
/* @__PURE__ */ u("p", {
|
|
871
|
+
className: "reinspect-menu-title",
|
|
872
|
+
children: [v, " inspector"]
|
|
873
|
+
}),
|
|
874
|
+
/* @__PURE__ */ u("label", {
|
|
875
|
+
className: "reinspect-menu-component-setting",
|
|
876
|
+
children: [/* @__PURE__ */ l("span", { children: "Capture renders for this component" }), /* @__PURE__ */ l("input", {
|
|
877
|
+
type: "checkbox",
|
|
878
|
+
checked: K ? !0 : Fe,
|
|
879
|
+
onChange: (e) => Y(v, e.currentTarget.checked),
|
|
880
|
+
disabled: K,
|
|
881
|
+
"aria-label": `Capture renders for ${v}`,
|
|
882
|
+
"data-testid": `reinspect-component-render-toggle-${v}`
|
|
883
|
+
})]
|
|
884
|
+
}),
|
|
885
|
+
K ? /* @__PURE__ */ l("p", {
|
|
886
|
+
className: "reinspect-setting-note",
|
|
887
|
+
children: "Global capture is enabled from Reinspect settings."
|
|
888
|
+
}) : null,
|
|
889
|
+
/* @__PURE__ */ u("div", {
|
|
890
|
+
className: "reinspect-submenu",
|
|
891
|
+
children: [/* @__PURE__ */ l("button", {
|
|
892
|
+
type: "button",
|
|
893
|
+
"data-state": S === "css" ? "active" : "idle",
|
|
894
|
+
onClick: () => C("css"),
|
|
895
|
+
children: "CSS"
|
|
896
|
+
}), /* @__PURE__ */ l("button", {
|
|
897
|
+
type: "button",
|
|
898
|
+
"data-state": S === "props" ? "active" : "idle",
|
|
899
|
+
onClick: () => C("props"),
|
|
900
|
+
children: "Props"
|
|
901
|
+
})]
|
|
902
|
+
}),
|
|
903
|
+
S === "css" ? /* @__PURE__ */ u(c, { children: [
|
|
904
|
+
/* @__PURE__ */ u("div", {
|
|
905
|
+
className: "reinspect-menu-filter",
|
|
906
|
+
children: [/* @__PURE__ */ l("span", {
|
|
907
|
+
className: "reinspect-menu-filter-icon",
|
|
908
|
+
"aria-hidden": "true",
|
|
909
|
+
children: /* @__PURE__ */ l("svg", {
|
|
910
|
+
viewBox: "0 0 24 24",
|
|
911
|
+
focusable: "false",
|
|
912
|
+
children: /* @__PURE__ */ l("path", {
|
|
913
|
+
d: "M10.5 3a7.5 7.5 0 015.92 12.1l4.24 4.23a1 1 0 01-1.42 1.42l-4.23-4.24A7.5 7.5 0 1110.5 3zm0 2a5.5 5.5 0 100 11 5.5 5.5 0 000-11z",
|
|
914
|
+
fill: "currentColor"
|
|
915
|
+
})
|
|
916
|
+
})
|
|
917
|
+
}), /* @__PURE__ */ l("input", {
|
|
918
|
+
id: `${X}-css-filter`,
|
|
919
|
+
"data-testid": "reinspect-css-filter-input",
|
|
920
|
+
type: "search",
|
|
921
|
+
value: E,
|
|
922
|
+
placeholder: "Filter",
|
|
923
|
+
"aria-label": "Filter CSS properties",
|
|
924
|
+
onChange: (e) => D(e.currentTarget.value)
|
|
925
|
+
})]
|
|
926
|
+
}),
|
|
927
|
+
/* @__PURE__ */ l("div", {
|
|
928
|
+
className: "reinspect-menu-grid",
|
|
929
|
+
children: Ve.map((e) => {
|
|
930
|
+
let t = Le?.[e], n = `${X}-${e}`;
|
|
931
|
+
if (g.has(e)) {
|
|
932
|
+
let r = typeof t == "string" ? ne(t) : "#1f2937";
|
|
933
|
+
return /* @__PURE__ */ u("div", {
|
|
934
|
+
className: "reinspect-field",
|
|
935
|
+
children: [/* @__PURE__ */ l("label", {
|
|
936
|
+
htmlFor: n,
|
|
937
|
+
children: we(e)
|
|
938
|
+
}), /* @__PURE__ */ u("div", {
|
|
939
|
+
className: "reinspect-inline-controls",
|
|
940
|
+
children: [/* @__PURE__ */ l("input", {
|
|
941
|
+
id: n,
|
|
942
|
+
type: "color",
|
|
943
|
+
value: r,
|
|
944
|
+
onChange: (t) => q(X, e, t.currentTarget.value)
|
|
945
|
+
}), /* @__PURE__ */ l("button", {
|
|
946
|
+
type: "button",
|
|
947
|
+
onClick: () => q(X, e, void 0),
|
|
948
|
+
disabled: !J(t),
|
|
949
|
+
children: "reset"
|
|
950
|
+
})]
|
|
951
|
+
})]
|
|
952
|
+
}, e);
|
|
953
|
+
}
|
|
954
|
+
if (e === "opacity") {
|
|
955
|
+
let r = typeof t == "number" ? t : 1;
|
|
956
|
+
return /* @__PURE__ */ u("div", {
|
|
957
|
+
className: "reinspect-field",
|
|
958
|
+
children: [/* @__PURE__ */ l("label", {
|
|
959
|
+
htmlFor: n,
|
|
960
|
+
children: "Opacity"
|
|
961
|
+
}), /* @__PURE__ */ u("div", {
|
|
962
|
+
className: "reinspect-inline-controls reinspect-opacity-controls",
|
|
963
|
+
children: [
|
|
964
|
+
/* @__PURE__ */ l("input", {
|
|
965
|
+
id: n,
|
|
966
|
+
type: "range",
|
|
967
|
+
min: "0",
|
|
968
|
+
max: "1",
|
|
969
|
+
step: "0.05",
|
|
970
|
+
value: r,
|
|
971
|
+
onChange: (t) => {
|
|
972
|
+
let n = re(t.currentTarget.value);
|
|
973
|
+
n !== void 0 && q(X, e, n);
|
|
974
|
+
}
|
|
975
|
+
}),
|
|
976
|
+
/* @__PURE__ */ l("output", { children: r.toFixed(2) }),
|
|
977
|
+
/* @__PURE__ */ l("button", {
|
|
978
|
+
type: "button",
|
|
979
|
+
onClick: () => q(X, e, void 0),
|
|
980
|
+
disabled: !J(t),
|
|
981
|
+
children: "reset"
|
|
982
|
+
})
|
|
983
|
+
]
|
|
984
|
+
})]
|
|
985
|
+
}, e);
|
|
986
|
+
}
|
|
987
|
+
if (_.has(e)) {
|
|
988
|
+
let r = typeof t == "number" ? t : "";
|
|
989
|
+
return /* @__PURE__ */ u("div", {
|
|
990
|
+
className: "reinspect-field",
|
|
991
|
+
children: [/* @__PURE__ */ u("label", {
|
|
992
|
+
htmlFor: n,
|
|
993
|
+
children: [we(e), " (px)"]
|
|
994
|
+
}), /* @__PURE__ */ u("div", {
|
|
995
|
+
className: "reinspect-inline-controls",
|
|
996
|
+
children: [/* @__PURE__ */ l("input", {
|
|
997
|
+
id: n,
|
|
998
|
+
type: "number",
|
|
999
|
+
step: "1",
|
|
1000
|
+
value: r,
|
|
1001
|
+
onChange: (t) => {
|
|
1002
|
+
if (t.currentTarget.value === "") {
|
|
1003
|
+
q(X, e, void 0);
|
|
1004
|
+
return;
|
|
1005
|
+
}
|
|
1006
|
+
let n = re(t.currentTarget.value);
|
|
1007
|
+
n !== void 0 && q(X, e, n);
|
|
1008
|
+
}
|
|
1009
|
+
}), /* @__PURE__ */ l("button", {
|
|
1010
|
+
type: "button",
|
|
1011
|
+
onClick: () => q(X, e, void 0),
|
|
1012
|
+
disabled: !J(t),
|
|
1013
|
+
children: "reset"
|
|
1014
|
+
})]
|
|
1015
|
+
})]
|
|
1016
|
+
}, e);
|
|
1017
|
+
}
|
|
1018
|
+
return /* @__PURE__ */ u("div", {
|
|
1019
|
+
className: "reinspect-field",
|
|
1020
|
+
children: [/* @__PURE__ */ l("label", {
|
|
1021
|
+
htmlFor: n,
|
|
1022
|
+
children: we(e)
|
|
1023
|
+
}), /* @__PURE__ */ u("div", {
|
|
1024
|
+
className: "reinspect-inline-controls",
|
|
1025
|
+
children: [/* @__PURE__ */ l("input", {
|
|
1026
|
+
id: n,
|
|
1027
|
+
type: "text",
|
|
1028
|
+
value: typeof t == "string" ? t : "",
|
|
1029
|
+
onChange: (t) => q(X, e, t.currentTarget.value || void 0)
|
|
1030
|
+
}), /* @__PURE__ */ l("button", {
|
|
1031
|
+
type: "button",
|
|
1032
|
+
onClick: () => q(X, e, void 0),
|
|
1033
|
+
disabled: !J(t),
|
|
1034
|
+
children: "reset"
|
|
1035
|
+
})]
|
|
1036
|
+
})]
|
|
1037
|
+
}, e);
|
|
1038
|
+
})
|
|
1039
|
+
}),
|
|
1040
|
+
Ve.length === 0 ? /* @__PURE__ */ u("p", {
|
|
1041
|
+
className: "reinspect-menu-empty-state",
|
|
1042
|
+
children: [
|
|
1043
|
+
"No CSS properties match \"",
|
|
1044
|
+
E.trim(),
|
|
1045
|
+
"\"."
|
|
1046
|
+
]
|
|
1047
|
+
}) : null
|
|
1048
|
+
] }) : /* @__PURE__ */ u("div", {
|
|
1049
|
+
className: "reinspect-props-panel",
|
|
1050
|
+
children: [
|
|
1051
|
+
/* @__PURE__ */ u("div", {
|
|
1052
|
+
className: "reinspect-props-submenu",
|
|
1053
|
+
children: [/* @__PURE__ */ l("button", {
|
|
1054
|
+
type: "button",
|
|
1055
|
+
"data-state": w === "detected" ? "active" : "idle",
|
|
1056
|
+
onClick: () => T("detected"),
|
|
1057
|
+
children: "Detected"
|
|
1058
|
+
}), /* @__PURE__ */ l("button", {
|
|
1059
|
+
type: "button",
|
|
1060
|
+
"data-state": w === "raw" ? "active" : "idle",
|
|
1061
|
+
onClick: () => {
|
|
1062
|
+
T("raw"), j(null), A(fe(ze));
|
|
1063
|
+
},
|
|
1064
|
+
children: "Raw"
|
|
1065
|
+
})]
|
|
1066
|
+
}),
|
|
1067
|
+
w === "detected" ? He.length > 0 ? /* @__PURE__ */ u("div", {
|
|
1068
|
+
className: "reinspect-props-table",
|
|
1069
|
+
children: [/* @__PURE__ */ u("div", {
|
|
1070
|
+
className: "reinspect-props-header",
|
|
1071
|
+
children: [/* @__PURE__ */ l("span", { children: "Key" }), /* @__PURE__ */ l("span", { children: "Value" })]
|
|
1072
|
+
}), He.map((e) => {
|
|
1073
|
+
let t = Ee(e.key), n = ze[e.key], r = e.value.kind === "object" || e.value.kind === "array", i = !!F[e.key], a = P[e.key], o = oe[e.key], s = me(n);
|
|
1074
|
+
return /* @__PURE__ */ u("div", {
|
|
1075
|
+
className: "reinspect-props-row",
|
|
1076
|
+
"data-testid": `reinspect-prop-row-${t}`,
|
|
1077
|
+
children: [/* @__PURE__ */ l("code", {
|
|
1078
|
+
className: "reinspect-prop-key",
|
|
1079
|
+
children: e.key
|
|
1080
|
+
}), /* @__PURE__ */ u("div", {
|
|
1081
|
+
className: "reinspect-prop-cell",
|
|
1082
|
+
"data-testid": `reinspect-prop-value-${t}`,
|
|
1083
|
+
children: [
|
|
1084
|
+
Oe({
|
|
1085
|
+
value: e.value,
|
|
1086
|
+
onCopy: qe
|
|
1087
|
+
}),
|
|
1088
|
+
r || s ? /* @__PURE__ */ u("div", {
|
|
1089
|
+
className: "reinspect-prop-actions",
|
|
1090
|
+
children: [r ? /* @__PURE__ */ l("button", {
|
|
1091
|
+
type: "button",
|
|
1092
|
+
"data-testid": `reinspect-prop-show-json-${t}`,
|
|
1093
|
+
onClick: () => Je(e.key, n),
|
|
1094
|
+
children: i ? "Hide JSON" : "Show JSON"
|
|
1095
|
+
}) : null, s ? /* @__PURE__ */ l("button", {
|
|
1096
|
+
type: "button",
|
|
1097
|
+
"data-testid": `reinspect-prop-edit-${t}`,
|
|
1098
|
+
onClick: () => Ye(e.key, n),
|
|
1099
|
+
children: "Edit"
|
|
1100
|
+
}) : null]
|
|
1101
|
+
}) : null,
|
|
1102
|
+
i ? /* @__PURE__ */ l("div", {
|
|
1103
|
+
className: "reinspect-prop-json-preview",
|
|
1104
|
+
"data-testid": `reinspect-prop-json-preview-${t}`,
|
|
1105
|
+
children: o ? /* @__PURE__ */ l("p", {
|
|
1106
|
+
className: "reinspect-error",
|
|
1107
|
+
children: o
|
|
1108
|
+
}) : /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("pre", { children: a }), a ? /* @__PURE__ */ l("button", {
|
|
1109
|
+
type: "button",
|
|
1110
|
+
"data-testid": `reinspect-prop-copy-json-${t}`,
|
|
1111
|
+
onClick: () => qe(a, "JSON value"),
|
|
1112
|
+
children: "Copy JSON"
|
|
1113
|
+
}) : null] })
|
|
1114
|
+
}) : null
|
|
1115
|
+
]
|
|
1116
|
+
})]
|
|
1117
|
+
}, e.key);
|
|
1118
|
+
})]
|
|
1119
|
+
}) : /* @__PURE__ */ l("p", {
|
|
1120
|
+
className: "reinspect-menu-empty-state",
|
|
1121
|
+
children: "No props detected."
|
|
1122
|
+
}) : /* @__PURE__ */ u(c, { children: [
|
|
1123
|
+
/* @__PURE__ */ l("label", {
|
|
1124
|
+
htmlFor: `${X}-props-json`,
|
|
1125
|
+
children: "Props JSON"
|
|
1126
|
+
}),
|
|
1127
|
+
/* @__PURE__ */ l("textarea", {
|
|
1128
|
+
id: `${X}-props-json`,
|
|
1129
|
+
value: k,
|
|
1130
|
+
onChange: (e) => {
|
|
1131
|
+
A(e.currentTarget.value), j(null);
|
|
1132
|
+
},
|
|
1133
|
+
rows: 9
|
|
1134
|
+
}),
|
|
1135
|
+
ie ? /* @__PURE__ */ l("p", {
|
|
1136
|
+
className: "reinspect-error",
|
|
1137
|
+
children: ie
|
|
1138
|
+
}) : null,
|
|
1139
|
+
/* @__PURE__ */ u("div", {
|
|
1140
|
+
className: "reinspect-inline-controls",
|
|
1141
|
+
children: [/* @__PURE__ */ l("button", {
|
|
1142
|
+
type: "button",
|
|
1143
|
+
onClick: Ge,
|
|
1144
|
+
children: "apply"
|
|
1145
|
+
}), /* @__PURE__ */ l("button", {
|
|
1146
|
+
type: "button",
|
|
1147
|
+
onClick: Ke,
|
|
1148
|
+
children: "reset"
|
|
1149
|
+
})]
|
|
1150
|
+
})
|
|
1151
|
+
] }),
|
|
1152
|
+
M ? /* @__PURE__ */ l("p", {
|
|
1153
|
+
className: "reinspect-setting-note",
|
|
1154
|
+
"data-testid": "reinspect-props-copy-status",
|
|
1155
|
+
children: M
|
|
1156
|
+
}) : null
|
|
1157
|
+
]
|
|
1158
|
+
})
|
|
1159
|
+
]
|
|
1160
|
+
}) : null, Qe = L ? d(/* @__PURE__ */ l("div", {
|
|
1161
|
+
className: "reinspect-modal-backdrop",
|
|
1162
|
+
role: "dialog",
|
|
1163
|
+
"aria-modal": "true",
|
|
1164
|
+
"aria-label": `Edit ${L} prop`,
|
|
1165
|
+
"data-testid": "reinspect-prop-edit-modal",
|
|
1166
|
+
children: /* @__PURE__ */ u("div", {
|
|
1167
|
+
className: "reinspect-modal",
|
|
1168
|
+
ref: y,
|
|
1169
|
+
children: [
|
|
1170
|
+
/* @__PURE__ */ u("p", {
|
|
1171
|
+
className: "reinspect-menu-title",
|
|
1172
|
+
children: ["Edit prop: ", L]
|
|
1173
|
+
}),
|
|
1174
|
+
/* @__PURE__ */ l("label", {
|
|
1175
|
+
htmlFor: `${X}-prop-edit-json`,
|
|
1176
|
+
children: "JSON value"
|
|
1177
|
+
}),
|
|
1178
|
+
/* @__PURE__ */ l("textarea", {
|
|
1179
|
+
id: `${X}-prop-edit-json`,
|
|
1180
|
+
"data-testid": "reinspect-prop-edit-textarea",
|
|
1181
|
+
value: z,
|
|
1182
|
+
onChange: (e) => {
|
|
1183
|
+
B(e.currentTarget.value), H(null);
|
|
1184
|
+
},
|
|
1185
|
+
rows: 10
|
|
1186
|
+
}),
|
|
1187
|
+
V ? /* @__PURE__ */ l("p", {
|
|
1188
|
+
className: "reinspect-error",
|
|
1189
|
+
"data-testid": "reinspect-prop-edit-error",
|
|
1190
|
+
children: V
|
|
1191
|
+
}) : null,
|
|
1192
|
+
/* @__PURE__ */ u("div", {
|
|
1193
|
+
className: "reinspect-inline-controls",
|
|
1194
|
+
children: [/* @__PURE__ */ l("button", {
|
|
1195
|
+
type: "button",
|
|
1196
|
+
onClick: Xe,
|
|
1197
|
+
children: "apply"
|
|
1198
|
+
}), /* @__PURE__ */ l("button", {
|
|
1199
|
+
type: "button",
|
|
1200
|
+
onClick: () => {
|
|
1201
|
+
R(null), B(""), H(null);
|
|
1202
|
+
},
|
|
1203
|
+
children: "cancel"
|
|
1204
|
+
})]
|
|
1205
|
+
})
|
|
1206
|
+
]
|
|
1207
|
+
})
|
|
1208
|
+
}), document.body) : null;
|
|
1209
|
+
if (!ce) {
|
|
1210
|
+
if (a === "manual") throw Error("useReinspect must be used within ReinspectProvider");
|
|
1211
|
+
return /* @__PURE__ */ l(h, { ...Q });
|
|
1212
|
+
}
|
|
1213
|
+
return a === "auto" && !Ne ? /* @__PURE__ */ l(h, { ...Q }) : /* @__PURE__ */ u("div", {
|
|
1214
|
+
className: "reinspect-shell",
|
|
1215
|
+
"data-reinspect-component": v,
|
|
1216
|
+
"data-reinspect-active": Z,
|
|
1217
|
+
"data-testid": `reinspect-shell-${v}`,
|
|
1218
|
+
style: Ue,
|
|
1219
|
+
onContextMenu: We,
|
|
1220
|
+
children: [
|
|
1221
|
+
Z ? /* @__PURE__ */ u("span", {
|
|
1222
|
+
className: "reinspect-name-badge",
|
|
1223
|
+
children: [v, Pe ? ` | ${Ce(Ie, _e)}` : ""]
|
|
1224
|
+
}) : null,
|
|
1225
|
+
Ze ? d(Ze, document.body) : null,
|
|
1226
|
+
Qe,
|
|
1227
|
+
/* @__PURE__ */ l("div", {
|
|
1228
|
+
className: "reinspect-content",
|
|
1229
|
+
"data-reinspect-content": "true",
|
|
1230
|
+
style: Re,
|
|
1231
|
+
children: /* @__PURE__ */ l(h, { ...Q })
|
|
1232
|
+
})
|
|
1233
|
+
]
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1236
|
+
return y.displayName = `withReinspect(${v})`, y[_e] = {
|
|
1237
|
+
source: a,
|
|
1238
|
+
scope: p,
|
|
1239
|
+
original: h
|
|
1240
|
+
}, y;
|
|
1241
|
+
}
|
|
1242
|
+
//#endregion
|
|
1243
|
+
//#region src/reinspect/autoWrap.ts
|
|
1244
|
+
function je(e, t) {
|
|
1245
|
+
return ve(e)?.source === "manual" ? e : Y(e, {
|
|
1246
|
+
source: "auto",
|
|
1247
|
+
scope: t.scope,
|
|
1248
|
+
name: t.componentName,
|
|
1249
|
+
fallbackName: t.fallbackName
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
//#endregion
|
|
1253
|
+
//#region src/reinspect/wrapInspectableMap.ts
|
|
1254
|
+
function X(e, t) {
|
|
1255
|
+
let n = {};
|
|
1256
|
+
for (let r of Object.keys(e)) {
|
|
1257
|
+
let i = e[r];
|
|
1258
|
+
n[r] = Y(i, typeof t == "function" ? t(r, i) : t?.[r]);
|
|
1259
|
+
}
|
|
1260
|
+
return n;
|
|
1261
|
+
}
|
|
1262
|
+
//#endregion
|
|
1263
|
+
export { m as DEFAULT_EDITABLE_PROPS, h as DEFAULT_PALETTE, F as ReinspectFloatingToggle, se as ReinspectProvider, je as autoWrapInspectable, p as useReinspect, Y as withReinspect, X as wrapInspectableMap };
|