react-dev-insight 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.
@@ -0,0 +1,773 @@
1
+ 'use strict';
2
+
3
+ var chunkSLJD3GYE_js = require('./chunk-SLJD3GYE.js');
4
+ var React3 = require('react');
5
+ var reactDom = require('react-dom');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var React3__default = /*#__PURE__*/_interopDefault(React3);
10
+
11
+ var RenderBadge = ({ count }) => {
12
+ return /* @__PURE__ */ React3__default.default.createElement(
13
+ "div",
14
+ {
15
+ style: {
16
+ position: "absolute",
17
+ top: -10,
18
+ right: -10,
19
+ backgroundColor: "rgba(10, 10, 10, 0.75)",
20
+ backdropFilter: "blur(12px)",
21
+ WebkitBackdropFilter: "blur(12px)",
22
+ border: "1px solid rgba(255, 255, 255, 0.12)",
23
+ borderRadius: "10px",
24
+ padding: "2px 8px",
25
+ color: "#f1f5f9",
26
+ fontSize: "11px",
27
+ fontWeight: 600,
28
+ fontFamily: "system-ui, -apple-system, sans-serif",
29
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.3)",
30
+ zIndex: 1000001,
31
+ pointerEvents: "none",
32
+ display: "flex",
33
+ alignItems: "center",
34
+ justifyContent: "center",
35
+ minWidth: "16px"
36
+ }
37
+ },
38
+ /* @__PURE__ */ React3__default.default.createElement("span", { style: { textShadow: "0 0 8px rgba(255,255,255,0.3)" } }, count)
39
+ );
40
+ };
41
+ var HighlightBox = ({
42
+ rect,
43
+ count,
44
+ changedProps,
45
+ name,
46
+ cause,
47
+ isFrequent,
48
+ showHighlight = true,
49
+ showBadge = true
50
+ }) => {
51
+ const [visible, setVisible] = React3.useState(true);
52
+ React3.useEffect(() => {
53
+ setVisible(true);
54
+ const timer = setTimeout(() => {
55
+ setVisible(false);
56
+ }, 1200);
57
+ return () => clearTimeout(timer);
58
+ }, [count]);
59
+ if (!visible) return null;
60
+ if (!showHighlight && !showBadge) return null;
61
+ const borderColor = isFrequent ? "rgba(248, 113, 113, 0.4)" : "rgba(45, 212, 191, 0.4)";
62
+ const glowColor = isFrequent ? "rgba(248, 113, 113, 0.15)" : "rgba(45, 212, 191, 0.15)";
63
+ return /* @__PURE__ */ React3__default.default.createElement(
64
+ "div",
65
+ {
66
+ style: {
67
+ position: "absolute",
68
+ top: rect.top + window.scrollY,
69
+ left: rect.left + window.scrollX,
70
+ width: rect.width,
71
+ height: rect.height,
72
+ pointerEvents: "none",
73
+ zIndex: 1e6,
74
+ border: showHighlight ? `1px solid ${borderColor}` : "none",
75
+ borderRadius: "4px",
76
+ boxShadow: showHighlight ? `0 0 12px ${glowColor}, inset 0 0 8px ${glowColor}` : "none",
77
+ background: showHighlight ? "rgba(255, 255, 255, 0.02)" : "transparent",
78
+ transition: "opacity 0.2s ease-out",
79
+ animation: showHighlight ? "react-dev-insight-pulse 0.4s cubic-bezier(0.16, 1, 0.3, 1)" : "none"
80
+ }
81
+ },
82
+ showBadge && /* @__PURE__ */ React3__default.default.createElement(RenderBadge, { count }),
83
+ showHighlight && /* @__PURE__ */ React3__default.default.createElement(
84
+ "div",
85
+ {
86
+ style: {
87
+ position: "absolute",
88
+ top: "100%",
89
+ marginTop: "6px",
90
+ left: 0,
91
+ background: "rgba(10, 10, 10, 0.85)",
92
+ backdropFilter: "blur(12px)",
93
+ WebkitBackdropFilter: "blur(12px)",
94
+ color: "#e2e8f0",
95
+ fontSize: "11px",
96
+ padding: "8px 10px",
97
+ borderRadius: "6px",
98
+ whiteSpace: "nowrap",
99
+ fontFamily: "system-ui, -apple-system, sans-serif",
100
+ border: "1px solid rgba(255,255,255,0.08)",
101
+ pointerEvents: "none",
102
+ zIndex: 1000002,
103
+ boxShadow: "0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3)"
104
+ }
105
+ },
106
+ /* @__PURE__ */ React3__default.default.createElement(
107
+ "div",
108
+ {
109
+ style: {
110
+ fontWeight: 600,
111
+ color: "#f8fafc",
112
+ marginBottom: "3px",
113
+ letterSpacing: "0.02em"
114
+ }
115
+ },
116
+ name
117
+ ),
118
+ /* @__PURE__ */ React3__default.default.createElement("div", { style: { display: "flex", gap: "6px", alignItems: "center" } }, /* @__PURE__ */ React3__default.default.createElement("span", { style: { color: "#64748b" } }, "Cause:"), /* @__PURE__ */ React3__default.default.createElement("span", { style: { color: "#e2e8f0" } }, cause)),
119
+ changedProps.length > 0 && /* @__PURE__ */ React3__default.default.createElement("div", { style: { marginTop: "3px", display: "flex", gap: "6px" } }, /* @__PURE__ */ React3__default.default.createElement("span", { style: { color: "#64748b" } }, "Props:"), /* @__PURE__ */ React3__default.default.createElement("span", { style: { color: "#cbd5e1" } }, changedProps.join(", "))),
120
+ isFrequent && /* @__PURE__ */ React3__default.default.createElement(
121
+ "div",
122
+ {
123
+ style: {
124
+ marginTop: "6px",
125
+ color: "#f87171",
126
+ fontWeight: 500,
127
+ display: "flex",
128
+ alignItems: "center",
129
+ gap: "4px",
130
+ fontSize: "10px",
131
+ textTransform: "uppercase",
132
+ letterSpacing: "0.05em"
133
+ }
134
+ },
135
+ /* @__PURE__ */ React3__default.default.createElement(
136
+ "div",
137
+ {
138
+ style: {
139
+ width: "6px",
140
+ height: "6px",
141
+ borderRadius: "50%",
142
+ background: "#f87171",
143
+ boxShadow: "0 0 4px #f87171"
144
+ }
145
+ }
146
+ ),
147
+ "Frequent"
148
+ )
149
+ )
150
+ );
151
+ };
152
+ function useDraggable(initialPos = { x: 20, y: 20 }) {
153
+ const [position, setPosition] = React3.useState(initialPos);
154
+ const [isDragging, setIsDragging] = React3.useState(false);
155
+ const dragRef = React3.useRef(null);
156
+ const offsetRef = React3.useRef({ x: 0, y: 0 });
157
+ React3.useEffect(() => {
158
+ const handleMouseMove = (e) => {
159
+ if (!isDragging) return;
160
+ setPosition({
161
+ x: e.clientX - offsetRef.current.x,
162
+ y: e.clientY - offsetRef.current.y
163
+ });
164
+ };
165
+ const handleMouseUp = () => {
166
+ setIsDragging(false);
167
+ };
168
+ if (isDragging) {
169
+ document.addEventListener("mousemove", handleMouseMove);
170
+ document.addEventListener("mouseup", handleMouseUp);
171
+ }
172
+ return () => {
173
+ document.removeEventListener("mousemove", handleMouseMove);
174
+ document.removeEventListener("mouseup", handleMouseUp);
175
+ };
176
+ }, [isDragging]);
177
+ const onMouseDown = (e) => {
178
+ if (dragRef.current) {
179
+ const rect = dragRef.current.getBoundingClientRect();
180
+ offsetRef.current = {
181
+ x: e.clientX - rect.left,
182
+ y: e.clientY - rect.top
183
+ };
184
+ setIsDragging(true);
185
+ e.preventDefault();
186
+ }
187
+ };
188
+ return { position, isDragging, dragRef, onMouseDown };
189
+ }
190
+
191
+ // src/overlay/Dashboard.tsx
192
+ var Dashboard = ({
193
+ isVisible,
194
+ onClose,
195
+ totalRenders,
196
+ highlightBoxesEnabled,
197
+ setHighlightBoxesEnabled,
198
+ badgesEnabled,
199
+ setBadgesEnabled,
200
+ tracesEnabled,
201
+ setTracesEnabled,
202
+ componentStats
203
+ }) => {
204
+ const { position, dragRef, onMouseDown } = useDraggable({
205
+ x: typeof window !== "undefined" ? window.innerWidth - 300 : 20,
206
+ y: typeof window !== "undefined" ? window.innerHeight - 380 : 20
207
+ });
208
+ if (!isVisible) return null;
209
+ return /* @__PURE__ */ React3__default.default.createElement(
210
+ "div",
211
+ {
212
+ style: {
213
+ position: "fixed",
214
+ left: position.x,
215
+ top: position.y,
216
+ width: "260px",
217
+ maxHeight: "380px",
218
+ display: "flex",
219
+ flexDirection: "column",
220
+ borderRadius: "12px",
221
+ background: "rgba(10, 10, 10, 0.75)",
222
+ backdropFilter: "blur(24px)",
223
+ WebkitBackdropFilter: "blur(24px)",
224
+ border: "1px solid rgba(255, 255, 255, 0.08)",
225
+ boxShadow: "0 10px 40px -10px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05)",
226
+ zIndex: 1000004,
227
+ color: "#e2e8f0",
228
+ fontFamily: "system-ui, -apple-system, sans-serif",
229
+ overflow: "hidden",
230
+ animation: "react-dev-insight-slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1)"
231
+ }
232
+ },
233
+ /* @__PURE__ */ React3__default.default.createElement(
234
+ "div",
235
+ {
236
+ ref: dragRef,
237
+ onMouseDown,
238
+ style: {
239
+ padding: "12px 16px",
240
+ borderBottom: "1px solid rgba(255, 255, 255, 0.06)",
241
+ display: "flex",
242
+ justifyContent: "space-between",
243
+ alignItems: "center",
244
+ cursor: "grab",
245
+ background: "rgba(255,255,255,0.02)"
246
+ }
247
+ },
248
+ /* @__PURE__ */ React3__default.default.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px" } }, /* @__PURE__ */ React3__default.default.createElement(
249
+ "div",
250
+ {
251
+ style: {
252
+ width: "6px",
253
+ height: "6px",
254
+ borderRadius: "50%",
255
+ background: "#f8fafc",
256
+ boxShadow: "0 0 8px rgba(255,255,255,0.8)"
257
+ }
258
+ }
259
+ ), /* @__PURE__ */ React3__default.default.createElement(
260
+ "span",
261
+ {
262
+ style: {
263
+ fontWeight: 500,
264
+ fontSize: "12px",
265
+ letterSpacing: "0.04em",
266
+ color: "#f8fafc"
267
+ }
268
+ },
269
+ "Dev Overlay"
270
+ )),
271
+ /* @__PURE__ */ React3__default.default.createElement(
272
+ "button",
273
+ {
274
+ onClick: onClose,
275
+ style: {
276
+ background: "none",
277
+ border: "none",
278
+ color: "#64748b",
279
+ cursor: "pointer",
280
+ padding: "2px",
281
+ display: "flex",
282
+ alignItems: "center",
283
+ justifyContent: "center",
284
+ borderRadius: "4px",
285
+ transition: "color 0.2s"
286
+ },
287
+ onMouseOver: (e) => e.currentTarget.style.color = "#e2e8f0",
288
+ onMouseOut: (e) => e.currentTarget.style.color = "#64748b"
289
+ },
290
+ /* @__PURE__ */ React3__default.default.createElement(
291
+ "svg",
292
+ {
293
+ width: "14",
294
+ height: "14",
295
+ viewBox: "0 0 24 24",
296
+ fill: "none",
297
+ stroke: "currentColor",
298
+ strokeWidth: "2",
299
+ strokeLinecap: "round",
300
+ strokeLinejoin: "round"
301
+ },
302
+ /* @__PURE__ */ React3__default.default.createElement("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
303
+ /* @__PURE__ */ React3__default.default.createElement("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
304
+ )
305
+ )
306
+ ),
307
+ /* @__PURE__ */ React3__default.default.createElement("div", { style: { padding: "16px", overflowY: "auto" } }, /* @__PURE__ */ React3__default.default.createElement("div", { style: { marginBottom: "24px" } }, /* @__PURE__ */ React3__default.default.createElement(
308
+ "div",
309
+ {
310
+ style: {
311
+ fontSize: "10px",
312
+ color: "#64748b",
313
+ textTransform: "uppercase",
314
+ marginBottom: "8px",
315
+ letterSpacing: "0.06em"
316
+ }
317
+ },
318
+ "Performance"
319
+ ), /* @__PURE__ */ React3__default.default.createElement(
320
+ "div",
321
+ {
322
+ style: {
323
+ display: "flex",
324
+ justifyContent: "space-between",
325
+ alignItems: "center"
326
+ }
327
+ },
328
+ /* @__PURE__ */ React3__default.default.createElement("span", { style: { fontSize: "13px", color: "#cbd5e1" } }, "Total Renders"),
329
+ /* @__PURE__ */ React3__default.default.createElement(
330
+ "span",
331
+ {
332
+ style: { fontSize: "15px", fontWeight: 600, color: "#f8fafc" }
333
+ },
334
+ totalRenders
335
+ )
336
+ )), /* @__PURE__ */ React3__default.default.createElement("div", { style: { marginBottom: "24px" } }, /* @__PURE__ */ React3__default.default.createElement(
337
+ "div",
338
+ {
339
+ style: {
340
+ fontSize: "10px",
341
+ color: "#64748b",
342
+ textTransform: "uppercase",
343
+ marginBottom: "8px",
344
+ letterSpacing: "0.06em"
345
+ }
346
+ },
347
+ "Settings"
348
+ ), /* @__PURE__ */ React3__default.default.createElement(
349
+ "div",
350
+ {
351
+ style: { display: "flex", flexDirection: "column", gap: "10px" }
352
+ },
353
+ /* @__PURE__ */ React3__default.default.createElement(
354
+ "label",
355
+ {
356
+ style: {
357
+ display: "flex",
358
+ alignItems: "center",
359
+ justifyContent: "space-between",
360
+ fontSize: "12px",
361
+ cursor: "pointer",
362
+ color: "#cbd5e1"
363
+ }
364
+ },
365
+ /* @__PURE__ */ React3__default.default.createElement("span", null, "Highlight Boxes"),
366
+ /* @__PURE__ */ React3__default.default.createElement(
367
+ "input",
368
+ {
369
+ type: "checkbox",
370
+ checked: highlightBoxesEnabled,
371
+ onChange: (e) => setHighlightBoxesEnabled(e.target.checked),
372
+ style: {
373
+ accentColor: "#475569",
374
+ width: "14px",
375
+ height: "14px",
376
+ cursor: "pointer"
377
+ }
378
+ }
379
+ )
380
+ ),
381
+ /* @__PURE__ */ React3__default.default.createElement(
382
+ "label",
383
+ {
384
+ style: {
385
+ display: "flex",
386
+ alignItems: "center",
387
+ justifyContent: "space-between",
388
+ fontSize: "12px",
389
+ cursor: "pointer",
390
+ color: "#cbd5e1"
391
+ }
392
+ },
393
+ /* @__PURE__ */ React3__default.default.createElement("span", null, "Render Badges"),
394
+ /* @__PURE__ */ React3__default.default.createElement(
395
+ "input",
396
+ {
397
+ type: "checkbox",
398
+ checked: badgesEnabled,
399
+ onChange: (e) => setBadgesEnabled(e.target.checked),
400
+ style: {
401
+ accentColor: "#475569",
402
+ width: "14px",
403
+ height: "14px",
404
+ cursor: "pointer"
405
+ }
406
+ }
407
+ )
408
+ ),
409
+ /* @__PURE__ */ React3__default.default.createElement(
410
+ "label",
411
+ {
412
+ style: {
413
+ display: "flex",
414
+ alignItems: "center",
415
+ justifyContent: "space-between",
416
+ fontSize: "12px",
417
+ cursor: "pointer",
418
+ color: "#cbd5e1"
419
+ }
420
+ },
421
+ /* @__PURE__ */ React3__default.default.createElement(
422
+ "div",
423
+ {
424
+ style: { display: "flex", alignItems: "center", gap: "6px" }
425
+ },
426
+ /* @__PURE__ */ React3__default.default.createElement("span", null, "Render Traces"),
427
+ /* @__PURE__ */ React3__default.default.createElement(
428
+ "span",
429
+ {
430
+ style: {
431
+ fontSize: "9px",
432
+ padding: "2px 4px",
433
+ background: "rgba(45, 212, 191, 0.2)",
434
+ color: "#2dd4bf",
435
+ borderRadius: "4px"
436
+ }
437
+ },
438
+ "NEW"
439
+ )
440
+ ),
441
+ /* @__PURE__ */ React3__default.default.createElement(
442
+ "input",
443
+ {
444
+ type: "checkbox",
445
+ checked: tracesEnabled,
446
+ onChange: (e) => setTracesEnabled(e.target.checked),
447
+ style: {
448
+ accentColor: "#475569",
449
+ width: "14px",
450
+ height: "14px",
451
+ cursor: "pointer"
452
+ }
453
+ }
454
+ )
455
+ )
456
+ )), /* @__PURE__ */ React3__default.default.createElement("div", null, /* @__PURE__ */ React3__default.default.createElement(
457
+ "div",
458
+ {
459
+ style: {
460
+ fontSize: "10px",
461
+ color: "#64748b",
462
+ textTransform: "uppercase",
463
+ marginBottom: "8px",
464
+ letterSpacing: "0.06em"
465
+ }
466
+ },
467
+ "Most Re-rendered"
468
+ ), componentStats.length === 0 ? /* @__PURE__ */ React3__default.default.createElement(
469
+ "div",
470
+ {
471
+ style: {
472
+ fontSize: "12px",
473
+ color: "#475569",
474
+ fontStyle: "italic"
475
+ }
476
+ },
477
+ "No tracking data."
478
+ ) : /* @__PURE__ */ React3__default.default.createElement(
479
+ "div",
480
+ {
481
+ style: { display: "flex", flexDirection: "column", gap: "6px" }
482
+ },
483
+ componentStats.map((stat, idx) => /* @__PURE__ */ React3__default.default.createElement(
484
+ "div",
485
+ {
486
+ key: idx,
487
+ style: {
488
+ display: "flex",
489
+ justifyContent: "space-between",
490
+ fontSize: "12px",
491
+ alignItems: "center"
492
+ }
493
+ },
494
+ /* @__PURE__ */ React3__default.default.createElement(
495
+ "span",
496
+ {
497
+ style: {
498
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
499
+ color: "#94a3b8"
500
+ }
501
+ },
502
+ stat.name
503
+ ),
504
+ /* @__PURE__ */ React3__default.default.createElement(
505
+ "span",
506
+ {
507
+ style: {
508
+ color: "#e2e8f0",
509
+ fontWeight: 500,
510
+ background: "rgba(255,255,255,0.05)",
511
+ padding: "2px 6px",
512
+ borderRadius: "4px"
513
+ }
514
+ },
515
+ stat.count
516
+ )
517
+ ))
518
+ )))
519
+ );
520
+ };
521
+ var FloatingToggle = ({
522
+ onClick,
523
+ isOpen
524
+ }) => {
525
+ const { position, dragRef, onMouseDown, isDragging } = useDraggable({
526
+ x: typeof window !== "undefined" ? window.innerWidth - 80 : 20,
527
+ y: typeof window !== "undefined" ? window.innerHeight - 80 : 20
528
+ });
529
+ return /* @__PURE__ */ React3__default.default.createElement(
530
+ "div",
531
+ {
532
+ ref: dragRef,
533
+ onMouseDown,
534
+ onClick: () => {
535
+ if (!isDragging) onClick();
536
+ },
537
+ style: {
538
+ position: "fixed",
539
+ left: position.x,
540
+ top: position.y,
541
+ width: "44px",
542
+ height: "44px",
543
+ borderRadius: "50%",
544
+ background: "rgba(10, 10, 10, 0.65)",
545
+ backdropFilter: "blur(16px)",
546
+ WebkitBackdropFilter: "blur(16px)",
547
+ border: "1px solid rgba(255, 255, 255, 0.08)",
548
+ boxShadow: isOpen ? "0 0 16px rgba(255, 255, 255, 0.1), inset 0 0 8px rgba(255, 255, 255, 0.05)" : "0 4px 12px rgba(0, 0, 0, 0.4)",
549
+ display: "flex",
550
+ alignItems: "center",
551
+ justifyContent: "center",
552
+ cursor: isDragging ? "grabbing" : "grab",
553
+ zIndex: 1000005,
554
+ transition: isDragging ? "none" : "box-shadow 0.3s ease, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",
555
+ transform: isDragging ? "scale(1.05)" : "scale(1)",
556
+ color: "#e2e8f0"
557
+ }
558
+ },
559
+ /* @__PURE__ */ React3__default.default.createElement(
560
+ "svg",
561
+ {
562
+ width: "20",
563
+ height: "20",
564
+ viewBox: "0 0 24 24",
565
+ fill: "none",
566
+ stroke: "currentColor",
567
+ strokeWidth: "2",
568
+ strokeLinecap: "round",
569
+ strokeLinejoin: "round",
570
+ style: {
571
+ transition: "transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55)",
572
+ transform: isOpen ? "rotate(90deg)" : "rotate(0deg)"
573
+ }
574
+ },
575
+ /* @__PURE__ */ React3__default.default.createElement("path", { d: "M12 3a9 9 0 0 0-9 9 9 9 0 0 0 9 9 9 9 0 0 0 9-9 9 9 0 0 0-9-9" }),
576
+ /* @__PURE__ */ React3__default.default.createElement("path", { d: "M12 8v8" }),
577
+ /* @__PURE__ */ React3__default.default.createElement("path", { d: "M8 12h8" })
578
+ )
579
+ );
580
+ };
581
+
582
+ // src/overlay/OverlayRoot.tsx
583
+ var OverlayRoot = () => {
584
+ const [renders, setRenders] = React3.useState(/* @__PURE__ */ new Map());
585
+ const [totalRenders, setTotalRenders] = React3.useState(0);
586
+ const [componentStats, setComponentStats] = React3.useState(
587
+ {}
588
+ );
589
+ const [isDashboardVisible, setIsDashboardVisible] = React3.useState(false);
590
+ const [highlightBoxesEnabled, setHighlightBoxesEnabled] = React3.useState(true);
591
+ const [badgesEnabled, setBadgesEnabled] = React3.useState(true);
592
+ const [tracesEnabled, setTracesEnabled] = React3.useState(true);
593
+ React3.useEffect(() => {
594
+ if (typeof document !== "undefined") {
595
+ let style = document.getElementById("react-dev-insight-styles");
596
+ if (!style) {
597
+ style = document.createElement("style");
598
+ style.id = "react-dev-insight-styles";
599
+ style.innerHTML = `
600
+ @keyframes react-dev-insight-pulse {
601
+ 0% { transform: scale(0.98); opacity: 0; }
602
+ 30% { transform: scale(1.01); opacity: 1; }
603
+ 100% { transform: scale(1); opacity: 1; }
604
+ }
605
+ @keyframes react-dev-insight-slide-up {
606
+ from { transform: translateY(10px) scale(0.98); opacity: 0; }
607
+ to { transform: translateY(0) scale(1); opacity: 1; }
608
+ }
609
+ `;
610
+ document.head.appendChild(style);
611
+ }
612
+ }
613
+ const listener = (ref, data) => {
614
+ setTotalRenders((prev) => prev + 1);
615
+ setComponentStats((prev) => ({
616
+ ...prev,
617
+ [data.name]: Math.max(data.count, prev[data.name] || 0)
618
+ }));
619
+ if (!data.elementRef) return;
620
+ const rect = data.elementRef.getBoundingClientRect();
621
+ if (rect.width === 0 && rect.height === 0) return;
622
+ setRenders((prev) => {
623
+ const next = new Map(prev);
624
+ next.set(ref, {
625
+ rect,
626
+ count: data.count,
627
+ changedProps: Object.keys(data.changedProps),
628
+ name: data.name,
629
+ timestamp: data.timestamp,
630
+ cause: data.cause,
631
+ isFrequent: data.isFrequent,
632
+ sourceRef: data.sourceRef
633
+ });
634
+ return next;
635
+ });
636
+ };
637
+ const unsubscribe = chunkSLJD3GYE_js.subscribeToReRenders(listener);
638
+ return () => unsubscribe();
639
+ }, []);
640
+ React3.useEffect(() => {
641
+ const interval = setInterval(() => {
642
+ const now = performance.now();
643
+ setRenders((prev) => {
644
+ let changed = false;
645
+ const next = new Map(prev);
646
+ for (const [key, value] of next.entries()) {
647
+ if (now - value.timestamp > 1200) {
648
+ next.delete(key);
649
+ changed = true;
650
+ }
651
+ }
652
+ return changed ? next : prev;
653
+ });
654
+ }, 1e3);
655
+ return () => clearInterval(interval);
656
+ }, []);
657
+ const statsList = React3.useMemo(() => {
658
+ return Object.entries(componentStats).map(([name, count]) => ({ name, count })).sort((a, b) => b.count - a.count).slice(0, 10);
659
+ }, [componentStats]);
660
+ if (typeof document === "undefined") return null;
661
+ const boxes = Array.from(renders.values()).map((r, i) => /* @__PURE__ */ React3__default.default.createElement(
662
+ HighlightBox,
663
+ {
664
+ key: `${r.name}-${i}`,
665
+ rect: r.rect,
666
+ count: r.count,
667
+ changedProps: r.changedProps,
668
+ name: r.name,
669
+ cause: r.cause,
670
+ isFrequent: r.isFrequent,
671
+ showHighlight: highlightBoxesEnabled,
672
+ showBadge: badgesEnabled
673
+ }
674
+ ));
675
+ const svgTraces = [];
676
+ if (tracesEnabled) {
677
+ const rendersArr = Array.from(renders.entries());
678
+ rendersArr.forEach(([key, r], i) => {
679
+ if (r.sourceRef && renders.has(r.sourceRef)) {
680
+ const sourceRect = renders.get(r.sourceRef).rect;
681
+ const targetRect = r.rect;
682
+ const startX = sourceRect.left + sourceRect.width / 2;
683
+ const startY = sourceRect.top + sourceRect.height / 2;
684
+ const endX = targetRect.left + targetRect.width / 2;
685
+ const endY = targetRect.top + targetRect.height / 2;
686
+ const cx1 = startX;
687
+ const cy1 = startY + (endY - startY) * 0.5;
688
+ const cx2 = endX;
689
+ const cy2 = startY + (endY - startY) * 0.5;
690
+ const age = performance.now() - r.timestamp;
691
+ const opacity = Math.max(0, 1 - age / 1200);
692
+ const pathId = `trace-path-${i}`;
693
+ svgTraces.push(
694
+ /* @__PURE__ */ React3__default.default.createElement("g", { key: pathId, style: { opacity } }, /* @__PURE__ */ React3__default.default.createElement(
695
+ "path",
696
+ {
697
+ d: `M ${startX} ${startY} C ${cx1} ${cy1}, ${cx2} ${cy2}, ${endX} ${endY}`,
698
+ fill: "none",
699
+ stroke: "rgba(45, 212, 191, 0.4)",
700
+ strokeWidth: "2",
701
+ strokeDasharray: "4 4"
702
+ }
703
+ ), /* @__PURE__ */ React3__default.default.createElement("circle", { r: "3", fill: "#2dd4bf" }, /* @__PURE__ */ React3__default.default.createElement(
704
+ "animateMotion",
705
+ {
706
+ dur: "0.8s",
707
+ repeatCount: "1",
708
+ path: `M ${startX} ${startY} C ${cx1} ${cy1}, ${cx2} ${cy2}, ${endX} ${endY}`,
709
+ fill: "freeze"
710
+ }
711
+ )))
712
+ );
713
+ }
714
+ });
715
+ }
716
+ return reactDom.createPortal(
717
+ /* @__PURE__ */ React3__default.default.createElement(React3__default.default.Fragment, null, tracesEnabled && svgTraces.length > 0 && /* @__PURE__ */ React3__default.default.createElement(
718
+ "svg",
719
+ {
720
+ style: {
721
+ position: "fixed",
722
+ top: 0,
723
+ left: 0,
724
+ width: "100vw",
725
+ height: "100vh",
726
+ pointerEvents: "none",
727
+ zIndex: 999998
728
+ }
729
+ },
730
+ svgTraces
731
+ ), /* @__PURE__ */ React3__default.default.createElement(
732
+ "div",
733
+ {
734
+ style: {
735
+ position: "fixed",
736
+ top: 0,
737
+ left: 0,
738
+ width: "100%",
739
+ pointerEvents: "none",
740
+ zIndex: 999999
741
+ }
742
+ },
743
+ boxes
744
+ ), /* @__PURE__ */ React3__default.default.createElement("div", { style: { zIndex: 1000003, position: "fixed", top: 0, left: 0 } }, /* @__PURE__ */ React3__default.default.createElement(
745
+ FloatingToggle,
746
+ {
747
+ isOpen: isDashboardVisible,
748
+ onClick: () => setIsDashboardVisible((prev) => !prev)
749
+ }
750
+ ), /* @__PURE__ */ React3__default.default.createElement(
751
+ Dashboard,
752
+ {
753
+ isVisible: isDashboardVisible,
754
+ onClose: () => setIsDashboardVisible(false),
755
+ totalRenders,
756
+ componentStats: statsList,
757
+ highlightBoxesEnabled,
758
+ setHighlightBoxesEnabled,
759
+ badgesEnabled,
760
+ setBadgesEnabled,
761
+ tracesEnabled,
762
+ setTracesEnabled
763
+ }
764
+ ))),
765
+ document.body
766
+ );
767
+ };
768
+
769
+ exports.HighlightBox = HighlightBox;
770
+ exports.OverlayRoot = OverlayRoot;
771
+ exports.RenderBadge = RenderBadge;
772
+ //# sourceMappingURL=chunk-JOBOK6JI.js.map
773
+ //# sourceMappingURL=chunk-JOBOK6JI.js.map