@kickd0wn/react-dev-companion 0.1.0 → 0.2.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/dist/index.js CHANGED
@@ -3,56 +3,95 @@ import { useEffect as e, useState as t } from "react";
3
3
  var n = (e, t) => () => (t || (e((t = { exports: {} }).exports, t, t.exports), e = null), t.exports), r = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
4
4
  if (typeof require < "u") return require.apply(this, arguments);
5
5
  throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
6
- }), i = (e) => {
6
+ }), i = !1, a = {
7
+ isOffline: !1,
8
+ delayMs: 0
9
+ }, o = (e) => {
10
+ if (i || typeof window > "u") return;
11
+ i = !0;
7
12
  let t = window.fetch;
8
13
  window.fetch = async (...n) => {
9
- let [r, i] = n, a = typeof r == "string" ? r : r instanceof Request ? r.url : String(r), o = i?.method || "GET", s = {
10
- id: Math.random().toString(36).substring(2, 9),
11
- url: a,
12
- method: o.toUpperCase(),
13
- timestamp: (/* @__PURE__ */ new Date()).toLocaleTimeString()
14
- };
14
+ let r = performance.now(), i = Math.random().toString(36).substring(2, 9), o = "", s = "GET";
15
+ if (typeof n[0] == "string" ? o = n[0] : n[0] instanceof URL ? o = n[0].toString() : n[0] instanceof Request && (o = n[0].url, s = n[0].method || "GET"), n[1] && n[1].method && (s = n[1].method.toUpperCase()), a.delayMs > 0 && await new Promise((e) => setTimeout(e, a.delayMs)), a.isOffline) {
16
+ let t = performance.now();
17
+ throw e({
18
+ id: i,
19
+ url: o,
20
+ method: s,
21
+ status: 0,
22
+ duration: Math.round(t - r),
23
+ timestamp: (/* @__PURE__ */ new Date()).toLocaleTimeString()
24
+ }), TypeError("Failed to fetch (Simulated Offline Mode)");
25
+ }
15
26
  try {
16
- let r = await t(...n);
17
- return s.status = r.status, e(s), r;
27
+ let a = await t(...n), c = performance.now();
28
+ return e({
29
+ id: i,
30
+ url: o,
31
+ method: s,
32
+ status: a.status,
33
+ duration: Math.round(c - r),
34
+ timestamp: (/* @__PURE__ */ new Date()).toLocaleTimeString()
35
+ }), a;
18
36
  } catch (t) {
19
- throw s.status = 0, e(s), t;
37
+ let n = performance.now();
38
+ throw e({
39
+ id: i,
40
+ url: o,
41
+ method: s,
42
+ status: 0,
43
+ duration: Math.round(n - r),
44
+ timestamp: (/* @__PURE__ */ new Date()).toLocaleTimeString()
45
+ }), t;
20
46
  }
21
47
  };
22
- }, a = () => {
23
- let e = [];
24
- for (let t = 0; t < localStorage.length; t++) {
25
- let n = localStorage.key(t);
26
- n && e.push({
27
- key: n,
28
- value: localStorage.getItem(n) || "",
29
- type: "local"
30
- });
31
- }
32
- return e;
33
- }, o = () => {
34
- let e = [];
35
- for (let t = 0; t < sessionStorage.length; t++) {
36
- let n = sessionStorage.key(t);
37
- n && e.push({
38
- key: n,
39
- value: sessionStorage.getItem(n) || "",
40
- type: "session"
41
- });
42
- }
43
- return e;
44
- }, s = () => document.cookie ? document.cookie.split("; ").map((e) => {
48
+ }, s = () => typeof document > "u" || !document.cookie ? [] : document.cookie.split("; ").map((e) => {
45
49
  let [t, ...n] = e.split("=");
46
50
  return {
47
- key: t.trim(),
48
- value: decodeURIComponent(n.join("=")),
49
- type: "cookie"
51
+ key: t,
52
+ value: decodeURIComponent(n.join("="))
50
53
  };
51
- }) : [], c = (e, t) => {
52
- t === "local" ? localStorage.removeItem(e) : t === "session" ? sessionStorage.removeItem(e) : t === "cookie" && (document.cookie = `${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`);
53
- }, l = (e, t, n) => {
54
- n === "local" ? localStorage.setItem(e, t) : n === "session" ? sessionStorage.setItem(e, t) : n === "cookie" && (document.cookie = `${e}=${encodeURIComponent(t)}; path=/;`);
55
- }, u = /* @__PURE__ */ n(((e) => {
54
+ }), c = (e, t, n = 7) => {
55
+ if (typeof document > "u") return;
56
+ let r = new Date(Date.now() + n * 864e5).toUTCString();
57
+ document.cookie = `${encodeURIComponent(e)}=${encodeURIComponent(t)}; expires=${r}; path=/`;
58
+ }, l = (e) => {
59
+ typeof document < "u" && (document.cookie = `${encodeURIComponent(e)}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`);
60
+ }, u = (e) => {
61
+ let t = {};
62
+ e === "localStorage" ? t = { ...localStorage } : e === "sessionStorage" ? t = { ...sessionStorage } : e === "cookie" && s().forEach((e) => {
63
+ t[e.key] = e.value;
64
+ });
65
+ let n = {
66
+ type: e,
67
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
68
+ data: t
69
+ }, r = new Blob([JSON.stringify(n, null, 2)], { type: "application/json" }), i = URL.createObjectURL(r), a = document.createElement("a");
70
+ a.href = i, a.download = `dev-companion-${e}-${Date.now()}.json`, a.click(), URL.revokeObjectURL(i);
71
+ }, d = {
72
+ bg: "#0f172a",
73
+ cardBg: "#1e293b",
74
+ hoverBg: "#334155",
75
+ border: "#334155",
76
+ borderSubtle: "#1e293b",
77
+ textPrimary: "#f8fafc",
78
+ textSecondary: "#94a3b8",
79
+ accent: "#0284c7",
80
+ accentHover: "#0369a1",
81
+ success: "#4ade80",
82
+ warning: "#facc15",
83
+ danger: "#f87171",
84
+ methodGet: "#38bdf8",
85
+ methodPost: "#4ade80",
86
+ methodPut: "#facc15",
87
+ methodDelete: "#f87171"
88
+ }, f = () => {
89
+ if (typeof document > "u") return;
90
+ let e = "dev-companion-custom-styles";
91
+ if (document.getElementById(e)) return;
92
+ let t = document.createElement("style");
93
+ t.id = e, t.innerHTML = "\n .dev-companion-scroll::-webkit-scrollbar {\n width: 5px;\n height: 5px;\n }\n .dev-companion-scroll::-webkit-scrollbar-track {\n background: #0f172a;\n }\n .dev-companion-scroll::-webkit-scrollbar-thumb {\n background: #334155;\n border-radius: 4px;\n }\n .dev-companion-scroll::-webkit-scrollbar-thumb:hover {\n background: #475569;\n }\n @keyframes devCompanionSlideUp {\n from {\n opacity: 0;\n transform: translateY(8px) scale(0.98);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n }\n .dev-companion-panel-animate {\n animation: devCompanionSlideUp 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;\n }\n ", document.head.appendChild(t);
94
+ }, p = /* @__PURE__ */ n(((e) => {
56
95
  var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
57
96
  function r(e, n, r) {
58
97
  var i = null;
@@ -67,7 +106,7 @@ var n = (e, t) => () => (t || (e((t = { exports: {} }).exports, t, t.exports), e
67
106
  };
68
107
  }
69
108
  e.Fragment = n, e.jsx = r, e.jsxs = r;
70
- })), d = /* @__PURE__ */ n(((e) => {
109
+ })), m = /* @__PURE__ */ n(((e) => {
71
110
  process.env.NODE_ENV !== "production" && (function() {
72
111
  function t(e) {
73
112
  if (e == null) return null;
@@ -241,283 +280,747 @@ var n = (e, t) => () => (t || (e((t = { exports: {} }).exports, t, t.exports), e
241
280
  return f(e, t, n, !0, o, r ? P(a(e)) : R);
242
281
  };
243
282
  })();
244
- })), f = (/* @__PURE__ */ n(((e, t) => {
245
- t.exports = process.env.NODE_ENV === "production" ? u() : d();
246
- })))(), p = () => {
247
- let [n, r] = t("local"), [i, u] = t([]), [d, p] = t(""), [m, h] = t(""), g = () => {
248
- n === "local" ? u(a()) : n === "session" ? u(o()) : n === "cookie" && u(s());
283
+ })), h = (/* @__PURE__ */ n(((e, t) => {
284
+ t.exports = process.env.NODE_ENV === "production" ? p() : m();
285
+ })))(), g = () => {
286
+ let [n, r] = t("localStorage"), [i, a] = t([]), [o, p] = t(null), [m, g] = t("");
287
+ e(() => {
288
+ f();
289
+ }, []);
290
+ let _ = () => {
291
+ if (typeof window > "u") return;
292
+ let e = [];
293
+ if (n === "localStorage") for (let t = 0; t < localStorage.length; t++) {
294
+ let n = localStorage.key(t);
295
+ n && e.push({
296
+ key: n,
297
+ value: localStorage.getItem(n) || ""
298
+ });
299
+ }
300
+ else if (n === "sessionStorage") for (let t = 0; t < sessionStorage.length; t++) {
301
+ let n = sessionStorage.key(t);
302
+ n && e.push({
303
+ key: n,
304
+ value: sessionStorage.getItem(n) || ""
305
+ });
306
+ }
307
+ else n === "cookie" && e.push(...s());
308
+ a(e);
249
309
  };
250
310
  e(() => {
251
- g();
311
+ _();
252
312
  }, [n]);
253
- let _ = (e) => {
254
- c(e, n), g();
313
+ let v = (e) => {
314
+ n === "localStorage" ? localStorage.setItem(e, m) : n === "sessionStorage" ? sessionStorage.setItem(e, m) : n === "cookie" && c(e, m), p(null), _();
315
+ }, y = (e) => {
316
+ n === "localStorage" ? localStorage.removeItem(e) : n === "sessionStorage" ? sessionStorage.removeItem(e) : n === "cookie" && l(e), _();
255
317
  };
256
- return /* @__PURE__ */ (0, f.jsxs)("div", {
318
+ return /* @__PURE__ */ (0, h.jsxs)("div", {
257
319
  style: {
258
320
  display: "flex",
259
321
  flexDirection: "column",
260
- gap: "10px"
322
+ gap: "10px",
323
+ height: "100%"
261
324
  },
262
- children: [
263
- /* @__PURE__ */ (0, f.jsx)("div", {
325
+ children: [/* @__PURE__ */ (0, h.jsxs)("div", {
326
+ style: {
327
+ display: "flex",
328
+ justifyContent: "space-between",
329
+ alignItems: "center"
330
+ },
331
+ children: [/* @__PURE__ */ (0, h.jsx)("div", {
264
332
  style: {
265
333
  display: "flex",
266
- gap: "6px",
267
- borderBottom: "1px solid #334155",
268
- paddingBottom: "6px"
334
+ gap: "4px",
335
+ background: d.cardBg,
336
+ padding: "3px",
337
+ borderRadius: "6px",
338
+ border: `1px solid ${d.border}`
269
339
  },
270
340
  children: [
271
- "local",
272
- "session",
341
+ "localStorage",
342
+ "sessionStorage",
273
343
  "cookie"
274
- ].map((e) => /* @__PURE__ */ (0, f.jsx)("button", {
344
+ ].map((e) => /* @__PURE__ */ (0, h.jsx)("button", {
275
345
  onClick: () => r(e),
276
346
  style: {
277
- background: n === e ? "#3b82f6" : "#1e293b",
278
- color: "#fff",
279
- border: "none",
280
347
  padding: "4px 8px",
281
348
  borderRadius: "4px",
349
+ border: "none",
350
+ background: n === e ? d.accent : "transparent",
351
+ color: n === e ? "#fff" : d.textSecondary,
352
+ cursor: "pointer",
282
353
  fontSize: "11px",
283
- cursor: "pointer"
354
+ fontWeight: 600,
355
+ transition: "all 0.15s ease"
284
356
  },
285
- children: e.toUpperCase()
357
+ children: e === "localStorage" ? "Local" : e === "sessionStorage" ? "Session" : "Cookies"
286
358
  }, e))
287
- }),
288
- /* @__PURE__ */ (0, f.jsxs)("form", {
289
- onSubmit: (e) => {
290
- e.preventDefault(), d.trim() && (l(d.trim(), m.trim(), n), p(""), h(""), g());
291
- },
359
+ }), /* @__PURE__ */ (0, h.jsxs)("div", {
292
360
  style: {
293
361
  display: "flex",
294
- gap: "4px"
362
+ gap: "6px",
363
+ alignItems: "center"
295
364
  },
296
365
  children: [
297
- /* @__PURE__ */ (0, f.jsx)("input", {
298
- placeholder: "Key",
299
- value: d,
300
- onChange: (e) => p(e.target.value),
366
+ /* @__PURE__ */ (0, h.jsx)("button", {
367
+ onClick: _,
368
+ title: "Refresh storage data",
301
369
  style: {
302
- flex: 1,
303
- padding: "4px",
370
+ padding: "5px 8px",
304
371
  fontSize: "11px",
305
- background: "#1e293b",
306
- color: "#fff",
307
- border: "1px solid #334155",
308
- borderRadius: "4px"
309
- }
372
+ background: d.cardBg,
373
+ color: d.accent,
374
+ border: `1px solid ${d.border}`,
375
+ borderRadius: "6px",
376
+ cursor: "pointer",
377
+ fontWeight: 600
378
+ },
379
+ children: "↻ Refresh"
310
380
  }),
311
- /* @__PURE__ */ (0, f.jsx)("input", {
312
- placeholder: "Value",
313
- value: m,
314
- onChange: (e) => h(e.target.value),
381
+ /* @__PURE__ */ (0, h.jsx)("button", {
382
+ onClick: () => u(n),
315
383
  style: {
316
- flex: 1,
317
- padding: "4px",
384
+ padding: "5px 9px",
318
385
  fontSize: "11px",
319
- background: "#1e293b",
320
- color: "#fff",
321
- border: "1px solid #334155",
322
- borderRadius: "4px"
323
- }
386
+ background: d.cardBg,
387
+ color: d.textPrimary,
388
+ border: `1px solid ${d.border}`,
389
+ borderRadius: "6px",
390
+ cursor: "pointer",
391
+ fontWeight: 500
392
+ },
393
+ children: "Export"
324
394
  }),
325
- /* @__PURE__ */ (0, f.jsx)("button", {
326
- type: "submit",
395
+ /* @__PURE__ */ (0, h.jsxs)("label", {
327
396
  style: {
328
- background: "#22c55e",
329
- color: "#fff",
330
- border: "none",
331
- padding: "4px 8px",
332
- borderRadius: "4px",
397
+ padding: "5px 9px",
333
398
  fontSize: "11px",
334
- cursor: "pointer"
399
+ background: d.cardBg,
400
+ color: d.textPrimary,
401
+ border: `1px solid ${d.border}`,
402
+ borderRadius: "6px",
403
+ cursor: "pointer",
404
+ fontWeight: 500
335
405
  },
336
- children: "Add"
406
+ children: ["Import", /* @__PURE__ */ (0, h.jsx)("input", {
407
+ type: "file",
408
+ accept: ".json",
409
+ onChange: (e) => {
410
+ let t = e.target.files?.[0];
411
+ if (!t) return;
412
+ let r = new FileReader();
413
+ r.onload = (e) => {
414
+ try {
415
+ let t = JSON.parse(e.target?.result);
416
+ t && t.data && (Object.entries(t.data).forEach(([e, t]) => {
417
+ let r = typeof t == "string" ? t : JSON.stringify(t);
418
+ n === "localStorage" && localStorage.setItem(e, r), n === "sessionStorage" && sessionStorage.setItem(e, r), n === "cookie" && c(e, r);
419
+ }), _());
420
+ } catch (e) {
421
+ console.error("[DevCompanion] Failed to import JSON:", e);
422
+ }
423
+ }, r.readAsText(t);
424
+ },
425
+ style: { display: "none" }
426
+ })]
337
427
  })
338
428
  ]
339
- }),
340
- /* @__PURE__ */ (0, f.jsx)("div", {
429
+ })]
430
+ }), /* @__PURE__ */ (0, h.jsx)("div", {
431
+ className: "dev-companion-scroll",
432
+ style: {
433
+ flex: 1,
434
+ overflowY: "auto",
435
+ background: d.cardBg,
436
+ borderRadius: "6px",
437
+ border: `1px solid ${d.border}`
438
+ },
439
+ children: i.length === 0 ? /* @__PURE__ */ (0, h.jsxs)("p", {
440
+ style: {
441
+ color: d.textSecondary,
442
+ fontSize: "12px",
443
+ textAlign: "center",
444
+ padding: "24px 0"
445
+ },
446
+ children: [
447
+ "No items found in ",
448
+ n,
449
+ "."
450
+ ]
451
+ }) : /* @__PURE__ */ (0, h.jsxs)("table", {
452
+ style: {
453
+ width: "100%",
454
+ borderCollapse: "collapse",
455
+ fontSize: "11px",
456
+ color: d.textPrimary
457
+ },
458
+ children: [/* @__PURE__ */ (0, h.jsx)("thead", { children: /* @__PURE__ */ (0, h.jsxs)("tr", {
459
+ style: {
460
+ borderBottom: `1px solid ${d.border}`,
461
+ textAlign: "left",
462
+ background: d.bg,
463
+ color: d.textSecondary
464
+ },
465
+ children: [
466
+ /* @__PURE__ */ (0, h.jsx)("th", {
467
+ style: {
468
+ padding: "8px",
469
+ width: "35%"
470
+ },
471
+ children: "Key"
472
+ }),
473
+ /* @__PURE__ */ (0, h.jsx)("th", {
474
+ style: { padding: "8px" },
475
+ children: "Value"
476
+ }),
477
+ /* @__PURE__ */ (0, h.jsx)("th", {
478
+ style: {
479
+ padding: "8px",
480
+ width: "80px",
481
+ textAlign: "right"
482
+ },
483
+ children: "Actions"
484
+ })
485
+ ]
486
+ }) }), /* @__PURE__ */ (0, h.jsx)("tbody", { children: i.map((e) => /* @__PURE__ */ (0, h.jsxs)("tr", {
487
+ style: { borderBottom: `1px solid ${d.borderSubtle}` },
488
+ children: [
489
+ /* @__PURE__ */ (0, h.jsx)("td", {
490
+ style: {
491
+ padding: "8px",
492
+ fontWeight: 600,
493
+ color: d.methodGet,
494
+ fontFamily: "monospace",
495
+ wordBreak: "break-all"
496
+ },
497
+ children: e.key
498
+ }),
499
+ /* @__PURE__ */ (0, h.jsx)("td", {
500
+ style: { padding: "8px" },
501
+ children: o === e.key ? /* @__PURE__ */ (0, h.jsx)("input", {
502
+ value: m,
503
+ onChange: (e) => g(e.target.value),
504
+ style: {
505
+ width: "100%",
506
+ background: d.bg,
507
+ color: d.textPrimary,
508
+ border: `1px solid ${d.accent}`,
509
+ borderRadius: "4px",
510
+ padding: "3px 6px",
511
+ fontSize: "11px",
512
+ outline: "none"
513
+ }
514
+ }) : /* @__PURE__ */ (0, h.jsx)("span", {
515
+ style: {
516
+ wordBreak: "break-all",
517
+ fontFamily: "monospace",
518
+ color: d.textSecondary
519
+ },
520
+ children: e.value
521
+ })
522
+ }),
523
+ /* @__PURE__ */ (0, h.jsxs)("td", {
524
+ style: {
525
+ padding: "8px",
526
+ textAlign: "right"
527
+ },
528
+ children: [o === e.key ? /* @__PURE__ */ (0, h.jsx)("button", {
529
+ onClick: () => v(e.key),
530
+ style: {
531
+ color: d.success,
532
+ background: "none",
533
+ border: "none",
534
+ cursor: "pointer",
535
+ fontWeight: 600,
536
+ marginRight: "6px"
537
+ },
538
+ children: "Save"
539
+ }) : /* @__PURE__ */ (0, h.jsx)("button", {
540
+ onClick: () => {
541
+ p(e.key), g(e.value);
542
+ },
543
+ style: {
544
+ color: d.warning,
545
+ background: "none",
546
+ border: "none",
547
+ cursor: "pointer",
548
+ marginRight: "6px"
549
+ },
550
+ children: "Edit"
551
+ }), /* @__PURE__ */ (0, h.jsx)("button", {
552
+ onClick: () => y(e.key),
553
+ style: {
554
+ color: d.danger,
555
+ background: "none",
556
+ border: "none",
557
+ cursor: "pointer"
558
+ },
559
+ children: "Del"
560
+ })]
561
+ })
562
+ ]
563
+ }, e.key)) })]
564
+ })
565
+ })]
566
+ });
567
+ }, _ = ({ logs: n = [], onClear: r }) => {
568
+ let [i, o] = t(""), [s, c] = t("ALL"), [l, u] = t(a.isOffline), [p, m] = t(a.delayMs), [g, _] = t(null);
569
+ e(() => {
570
+ f();
571
+ }, []);
572
+ let v = () => {
573
+ let e = !l;
574
+ u(e), a.isOffline = e;
575
+ }, y = (e) => {
576
+ m(e), a.delayMs = e;
577
+ }, b = n.filter((e) => {
578
+ if (!e || !e.url) return !1;
579
+ let t = e.url.toLowerCase().includes((i || "").toLowerCase()), n = s === "ALL" || e.method === s;
580
+ return t && n;
581
+ }), x = (e) => {
582
+ let t = `curl -X ${e.method} "${e.url}"`;
583
+ navigator.clipboard.writeText(t), _(e.id), setTimeout(() => _(null), 1500);
584
+ }, S = (e) => {
585
+ switch (e?.toUpperCase()) {
586
+ case "GET": return d.methodGet;
587
+ case "POST": return d.methodPost;
588
+ case "PUT": return d.methodPut;
589
+ case "DELETE": return d.methodDelete;
590
+ default: return d.textPrimary;
591
+ }
592
+ };
593
+ return /* @__PURE__ */ (0, h.jsxs)("div", {
594
+ style: {
595
+ display: "flex",
596
+ flexDirection: "column",
597
+ gap: "10px",
598
+ height: "100%"
599
+ },
600
+ children: [
601
+ /* @__PURE__ */ (0, h.jsxs)("div", {
341
602
  style: {
342
- maxHeight: "180px",
343
- overflowY: "auto"
603
+ display: "flex",
604
+ alignItems: "center",
605
+ justifyContent: "space-between",
606
+ background: d.cardBg,
607
+ padding: "8px 10px",
608
+ borderRadius: "6px",
609
+ fontSize: "11px",
610
+ border: `1px solid ${d.borderSubtle}`,
611
+ flexShrink: 0
344
612
  },
345
- children: i.length === 0 ? /* @__PURE__ */ (0, f.jsx)("p", {
613
+ children: [/* @__PURE__ */ (0, h.jsxs)("label", {
346
614
  style: {
347
- color: "#94a3b8",
348
- fontSize: "12px"
615
+ display: "flex",
616
+ alignItems: "center",
617
+ gap: "6px",
618
+ cursor: "pointer",
619
+ color: l ? d.danger : d.textSecondary,
620
+ fontWeight: 500
349
621
  },
350
- children: "No items found."
351
- }) : i.map((e) => /* @__PURE__ */ (0, f.jsxs)("div", {
622
+ children: [/* @__PURE__ */ (0, h.jsx)("input", {
623
+ type: "checkbox",
624
+ checked: l,
625
+ onChange: v,
626
+ style: { accentColor: d.danger }
627
+ }), "Offline Mode"]
628
+ }), /* @__PURE__ */ (0, h.jsxs)("div", {
352
629
  style: {
353
630
  display: "flex",
354
- justifyContent: "space-between",
355
631
  alignItems: "center",
356
- padding: "4px 0",
357
- borderBottom: "1px solid #1e293b",
358
- fontSize: "11px"
632
+ gap: "6px"
359
633
  },
360
- children: [/* @__PURE__ */ (0, f.jsxs)("div", {
634
+ children: [/* @__PURE__ */ (0, h.jsx)("span", {
635
+ style: { color: d.textSecondary },
636
+ children: "Delay:"
637
+ }), /* @__PURE__ */ (0, h.jsxs)("select", {
638
+ value: p,
639
+ onChange: (e) => y(Number(e.target.value)),
361
640
  style: {
362
- overflow: "hidden",
363
- textOverflow: "ellipsis",
364
- whiteSpace: "nowrap",
365
- maxWidth: "220px"
641
+ background: d.bg,
642
+ color: d.textPrimary,
643
+ border: `1px solid ${d.border}`,
644
+ borderRadius: "4px",
645
+ padding: "2px 6px",
646
+ fontSize: "11px",
647
+ outline: "none",
648
+ cursor: "pointer"
366
649
  },
367
650
  children: [
368
- /* @__PURE__ */ (0, f.jsxs)("strong", {
369
- style: { color: "#38bdf8" },
370
- children: [e.key, ":"]
651
+ /* @__PURE__ */ (0, h.jsx)("option", {
652
+ value: 0,
653
+ children: "None (0ms)"
654
+ }),
655
+ /* @__PURE__ */ (0, h.jsx)("option", {
656
+ value: 500,
657
+ children: "Fast 3G (500ms)"
371
658
  }),
372
- " ",
373
- e.value
659
+ /* @__PURE__ */ (0, h.jsx)("option", {
660
+ value: 2e3,
661
+ children: "Slow 3G (2s)"
662
+ })
374
663
  ]
375
- }), /* @__PURE__ */ (0, f.jsx)("button", {
376
- onClick: () => _(e.key),
664
+ })]
665
+ })]
666
+ }),
667
+ /* @__PURE__ */ (0, h.jsxs)("div", {
668
+ style: {
669
+ display: "flex",
670
+ gap: "8px",
671
+ flexShrink: 0,
672
+ alignItems: "center"
673
+ },
674
+ children: [
675
+ /* @__PURE__ */ (0, h.jsx)("input", {
676
+ type: "text",
677
+ placeholder: "Filter URL...",
678
+ value: i,
679
+ onChange: (e) => o(e.target.value),
377
680
  style: {
378
- background: "#ef4444",
379
- color: "#fff",
380
- border: "none",
381
- padding: "2px 6px",
382
- borderRadius: "4px",
383
- fontSize: "10px",
681
+ flex: 1,
682
+ background: d.cardBg,
683
+ color: d.textPrimary,
684
+ border: `1px solid ${d.border}`,
685
+ borderRadius: "6px",
686
+ padding: "6px 10px",
687
+ fontSize: "12px",
688
+ outline: "none"
689
+ }
690
+ }),
691
+ /* @__PURE__ */ (0, h.jsxs)("select", {
692
+ value: s,
693
+ onChange: (e) => c(e.target.value),
694
+ style: {
695
+ background: d.cardBg,
696
+ color: d.textPrimary,
697
+ border: `1px solid ${d.border}`,
698
+ borderRadius: "6px",
699
+ padding: "6px 8px",
700
+ fontSize: "12px",
701
+ outline: "none",
384
702
  cursor: "pointer"
385
703
  },
386
- children: "Del"
387
- })]
388
- }, e.key))
704
+ children: [
705
+ /* @__PURE__ */ (0, h.jsx)("option", {
706
+ value: "ALL",
707
+ children: "ALL"
708
+ }),
709
+ /* @__PURE__ */ (0, h.jsx)("option", {
710
+ value: "GET",
711
+ children: "GET"
712
+ }),
713
+ /* @__PURE__ */ (0, h.jsx)("option", {
714
+ value: "POST",
715
+ children: "POST"
716
+ }),
717
+ /* @__PURE__ */ (0, h.jsx)("option", {
718
+ value: "PUT",
719
+ children: "PUT"
720
+ }),
721
+ /* @__PURE__ */ (0, h.jsx)("option", {
722
+ value: "DELETE",
723
+ children: "DELETE"
724
+ })
725
+ ]
726
+ }),
727
+ r && /* @__PURE__ */ (0, h.jsx)("button", {
728
+ onClick: r,
729
+ title: "Clear request history",
730
+ style: {
731
+ padding: "6px 10px",
732
+ fontSize: "11px",
733
+ background: d.cardBg,
734
+ color: d.textSecondary,
735
+ border: `1px solid ${d.border}`,
736
+ borderRadius: "6px",
737
+ cursor: "pointer",
738
+ fontWeight: 600
739
+ },
740
+ children: "Clear"
741
+ })
742
+ ]
743
+ }),
744
+ /* @__PURE__ */ (0, h.jsx)("div", {
745
+ className: "dev-companion-scroll",
746
+ style: {
747
+ flex: 1,
748
+ overflowY: "auto",
749
+ display: "flex",
750
+ flexDirection: "column",
751
+ gap: "4px",
752
+ paddingRight: "2px"
753
+ },
754
+ children: b.length === 0 ? /* @__PURE__ */ (0, h.jsx)("p", {
755
+ style: {
756
+ color: d.textSecondary,
757
+ fontSize: "12px",
758
+ textAlign: "center",
759
+ marginTop: "24px"
760
+ },
761
+ children: "No requests captured."
762
+ }) : b.map((e) => {
763
+ let t = !e.status || e.status >= 400 ? d.danger : d.success;
764
+ return /* @__PURE__ */ (0, h.jsxs)("div", {
765
+ style: {
766
+ display: "flex",
767
+ alignItems: "center",
768
+ justifyContent: "space-between",
769
+ padding: "8px 10px",
770
+ background: d.cardBg,
771
+ borderRadius: "6px",
772
+ border: `1px solid ${d.borderSubtle}`,
773
+ fontSize: "12px",
774
+ flexShrink: 0
775
+ },
776
+ children: [/* @__PURE__ */ (0, h.jsxs)("div", {
777
+ style: {
778
+ display: "flex",
779
+ alignItems: "center",
780
+ gap: "8px",
781
+ overflow: "hidden"
782
+ },
783
+ children: [/* @__PURE__ */ (0, h.jsx)("span", {
784
+ style: {
785
+ fontWeight: 700,
786
+ color: S(e.method),
787
+ fontSize: "11px",
788
+ background: d.bg,
789
+ padding: "2px 6px",
790
+ borderRadius: "4px",
791
+ border: `1px solid ${d.border}`,
792
+ minWidth: "45px",
793
+ textAlign: "center"
794
+ },
795
+ children: e.method
796
+ }), /* @__PURE__ */ (0, h.jsx)("span", {
797
+ title: e.url,
798
+ style: {
799
+ overflow: "hidden",
800
+ textOverflow: "ellipsis",
801
+ whiteSpace: "nowrap",
802
+ maxWidth: "170px",
803
+ color: d.textPrimary,
804
+ fontFamily: "monospace",
805
+ fontSize: "11px"
806
+ },
807
+ children: e.url
808
+ })]
809
+ }), /* @__PURE__ */ (0, h.jsxs)("div", {
810
+ style: {
811
+ display: "flex",
812
+ alignItems: "center",
813
+ gap: "8px",
814
+ flexShrink: 0
815
+ },
816
+ children: [
817
+ e.duration !== void 0 && /* @__PURE__ */ (0, h.jsxs)("span", {
818
+ style: {
819
+ color: d.textSecondary,
820
+ fontSize: "10px",
821
+ fontFamily: "monospace"
822
+ },
823
+ children: [e.duration, "ms"]
824
+ }),
825
+ /* @__PURE__ */ (0, h.jsx)("span", {
826
+ style: {
827
+ color: t,
828
+ fontWeight: 700,
829
+ fontSize: "11px",
830
+ background: `${t}15`,
831
+ padding: "2px 6px",
832
+ borderRadius: "4px"
833
+ },
834
+ children: e.status || "ERR"
835
+ }),
836
+ /* @__PURE__ */ (0, h.jsx)("button", {
837
+ onClick: () => x(e),
838
+ title: "Copy cURL",
839
+ style: {
840
+ background: g === e.id ? d.success : d.hoverBg,
841
+ color: g === e.id ? "#000" : d.textPrimary,
842
+ border: "none",
843
+ borderRadius: "4px",
844
+ padding: "3px 8px",
845
+ fontSize: "10px",
846
+ fontWeight: 600,
847
+ cursor: "pointer",
848
+ transition: "all 0.15s ease"
849
+ },
850
+ children: g === e.id ? "Copied!" : "cURL"
851
+ })
852
+ ]
853
+ })]
854
+ }, e.id);
855
+ })
389
856
  })
390
857
  ]
391
858
  });
392
- }, m = () => {
393
- let [n, r] = t(!1), [a, o] = t("network"), [s, c] = t([]);
394
- return e(() => {
395
- i((e) => {
396
- c((t) => [e, ...t]);
859
+ }, v = (t, n) => {
860
+ e(() => {
861
+ let e = (e) => {
862
+ let r = !t.ctrlOrCmd || e.metaKey || e.ctrlKey, i = !t.shift || e.shiftKey, a = e.key.toLowerCase() === t.key.toLowerCase();
863
+ r && i && a && (e.preventDefault(), n());
864
+ };
865
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
866
+ }, [t, n]);
867
+ }, y = ({ position: n = "bottom-right" }) => {
868
+ let [r, i] = t(!1), [a, s] = t("network"), [c, l] = t([]);
869
+ e(() => {
870
+ f();
871
+ }, []), v({
872
+ key: "d",
873
+ ctrlOrCmd: !0,
874
+ shift: !0
875
+ }, () => {
876
+ i((e) => !e);
877
+ }), e(() => {
878
+ o((e) => {
879
+ l((t) => [e, ...t]);
397
880
  });
398
- }, []), /* @__PURE__ */ (0, f.jsxs)("div", {
881
+ }, []);
882
+ let u = (() => {
883
+ switch (n) {
884
+ case "bottom-left": return {
885
+ bottom: 16,
886
+ left: 16
887
+ };
888
+ case "top-right": return {
889
+ top: 16,
890
+ right: 16
891
+ };
892
+ case "top-left": return {
893
+ top: 16,
894
+ left: 16
895
+ };
896
+ default: return {
897
+ bottom: 16,
898
+ right: 16
899
+ };
900
+ }
901
+ })();
902
+ return /* @__PURE__ */ (0, h.jsxs)("div", {
399
903
  style: {
400
904
  position: "fixed",
401
- bottom: 16,
402
- right: 16,
905
+ ...u,
403
906
  zIndex: 99999,
404
- fontFamily: "sans-serif"
907
+ fontFamily: "system-ui, -apple-system, sans-serif"
405
908
  },
406
- children: [/* @__PURE__ */ (0, f.jsxs)("button", {
407
- onClick: () => r(!n),
909
+ children: [/* @__PURE__ */ (0, h.jsxs)("button", {
910
+ onClick: () => i(!r),
911
+ title: "Shortcut: Ctrl + Shift + D",
408
912
  style: {
409
- background: "#1e293b",
410
- color: "#fff",
411
- border: "none",
412
- padding: "10px 14px",
413
- borderRadius: "8px",
913
+ background: d.bg,
914
+ color: d.textPrimary,
915
+ border: `1px solid ${d.border}`,
916
+ padding: "8px 14px",
917
+ borderRadius: "20px",
414
918
  cursor: "pointer",
415
- fontWeight: "bold",
416
- boxShadow: "0 4px 12px rgba(0,0,0,0.15)"
919
+ fontWeight: 600,
920
+ fontSize: "12px",
921
+ display: "flex",
922
+ alignItems: "center",
923
+ gap: "8px",
924
+ boxShadow: "0 4px 20px rgba(0,0,0,0.35)",
925
+ transition: "transform 0.15s ease"
417
926
  },
418
927
  children: [
419
- "Dev Companion (",
420
- s.length,
421
- ")"
928
+ /* @__PURE__ */ (0, h.jsx)("span", {
929
+ style: { color: d.accent },
930
+ children: "⚡"
931
+ }),
932
+ " DevCompanion",
933
+ c.length > 0 && /* @__PURE__ */ (0, h.jsx)("span", {
934
+ style: {
935
+ background: d.accent,
936
+ color: "#fff",
937
+ fontSize: "10px",
938
+ padding: "2px 6px",
939
+ borderRadius: "10px",
940
+ fontWeight: 700
941
+ },
942
+ children: c.length
943
+ })
422
944
  ]
423
- }), n && /* @__PURE__ */ (0, f.jsxs)("div", {
945
+ }), r && /* @__PURE__ */ (0, h.jsxs)("div", {
946
+ className: "dev-companion-panel-animate",
424
947
  style: {
425
948
  position: "absolute",
426
- bottom: 50,
427
- right: 0,
428
- width: 380,
429
- height: 340,
430
- background: "#0f172a",
431
- color: "#f8fafc",
432
- borderRadius: "8px",
949
+ ...u.bottom === void 0 ? { top: 50 } : { bottom: 50 },
950
+ ...u.right === void 0 ? { left: 0 } : { right: 0 },
951
+ width: 440,
952
+ height: 400,
953
+ background: d.bg,
954
+ color: d.textPrimary,
955
+ borderRadius: "10px",
433
956
  padding: "12px",
434
- boxShadow: "0 8px 24px rgba(0,0,0,0.3)",
957
+ border: `1px solid ${d.border}`,
958
+ boxShadow: "0 12px 32px rgba(0,0,0,0.5)",
435
959
  display: "flex",
436
960
  flexDirection: "column"
437
961
  },
438
- children: [/* @__PURE__ */ (0, f.jsxs)("div", {
962
+ children: [/* @__PURE__ */ (0, h.jsxs)("div", {
439
963
  style: {
440
964
  display: "flex",
441
- gap: "8px",
442
- borderBottom: "1px solid #334155",
965
+ justifyContent: "space-between",
966
+ alignItems: "center",
967
+ borderBottom: `1px solid ${d.border}`,
443
968
  paddingBottom: "8px",
444
- marginBottom: "8px"
969
+ marginBottom: "10px"
445
970
  },
446
- children: [/* @__PURE__ */ (0, f.jsx)("button", {
447
- onClick: () => o("network"),
971
+ children: [/* @__PURE__ */ (0, h.jsxs)("div", {
448
972
  style: {
449
- background: a === "network" ? "#0284c7" : "#1e293b",
450
- color: "#fff",
451
- border: "none",
452
- padding: "6px 12px",
453
- borderRadius: "4px",
454
- fontSize: "12px",
455
- fontWeight: "bold",
456
- cursor: "pointer"
973
+ display: "flex",
974
+ gap: "6px"
457
975
  },
458
- children: "Network"
459
- }), /* @__PURE__ */ (0, f.jsx)("button", {
460
- onClick: () => o("storage"),
976
+ children: [/* @__PURE__ */ (0, h.jsx)("button", {
977
+ onClick: () => s("network"),
978
+ style: {
979
+ background: a === "network" ? d.accent : "transparent",
980
+ color: a === "network" ? "#fff" : d.textSecondary,
981
+ border: "none",
982
+ padding: "5px 12px",
983
+ borderRadius: "6px",
984
+ fontSize: "12px",
985
+ fontWeight: 600,
986
+ cursor: "pointer",
987
+ transition: "all 0.15s ease"
988
+ },
989
+ children: "Network"
990
+ }), /* @__PURE__ */ (0, h.jsx)("button", {
991
+ onClick: () => s("storage"),
992
+ style: {
993
+ background: a === "storage" ? d.accent : "transparent",
994
+ color: a === "storage" ? "#fff" : d.textSecondary,
995
+ border: "none",
996
+ padding: "5px 12px",
997
+ borderRadius: "6px",
998
+ fontSize: "12px",
999
+ fontWeight: 600,
1000
+ cursor: "pointer",
1001
+ transition: "all 0.15s ease"
1002
+ },
1003
+ children: "Storage"
1004
+ })]
1005
+ }), /* @__PURE__ */ (0, h.jsx)("span", {
461
1006
  style: {
462
- background: a === "storage" ? "#0284c7" : "#1e293b",
463
- color: "#fff",
464
- border: "none",
465
- padding: "6px 12px",
466
- borderRadius: "4px",
467
- fontSize: "12px",
468
- fontWeight: "bold",
469
- cursor: "pointer"
1007
+ fontSize: "10px",
1008
+ color: d.textSecondary,
1009
+ fontFamily: "monospace"
470
1010
  },
471
- children: "Storage"
1011
+ children: "Ctrl+Shift+D"
472
1012
  })]
473
- }), a === "network" ? /* @__PURE__ */ (0, f.jsx)("div", {
1013
+ }), /* @__PURE__ */ (0, h.jsx)("div", {
474
1014
  style: {
475
1015
  flex: 1,
476
- overflowY: "auto"
1016
+ overflow: "hidden"
477
1017
  },
478
- children: s.length === 0 ? /* @__PURE__ */ (0, f.jsx)("p", {
479
- style: {
480
- color: "#94a3b8",
481
- fontSize: "13px"
482
- },
483
- children: "No requests captured yet."
484
- }) : s.map((e) => /* @__PURE__ */ (0, f.jsxs)("div", {
485
- style: {
486
- display: "flex",
487
- justifyContent: "space-between",
488
- padding: "6px 0",
489
- borderBottom: "1px solid #1e293b",
490
- fontSize: "12px"
491
- },
492
- children: [
493
- /* @__PURE__ */ (0, f.jsxs)("span", {
494
- style: {
495
- fontWeight: "bold",
496
- color: e.method === "GET" ? "#38bdf8" : "#4ade80"
497
- },
498
- children: [
499
- "[",
500
- e.method,
501
- "]"
502
- ]
503
- }),
504
- /* @__PURE__ */ (0, f.jsx)("span", {
505
- style: {
506
- overflow: "hidden",
507
- textOverflow: "ellipsis",
508
- whiteSpace: "nowrap",
509
- maxWidth: "180px"
510
- },
511
- children: e.url
512
- }),
513
- /* @__PURE__ */ (0, f.jsx)("span", {
514
- style: { color: e.status && e.status >= 400 ? "#f87171" : "#facc15" },
515
- children: e.status || "PENDING"
516
- })
517
- ]
518
- }, e.id))
519
- }) : /* @__PURE__ */ (0, f.jsx)(p, {})]
1018
+ children: a === "network" ? /* @__PURE__ */ (0, h.jsx)(_, {
1019
+ logs: c,
1020
+ onClear: () => l([])
1021
+ }) : /* @__PURE__ */ (0, h.jsx)(g, {})
1022
+ })]
520
1023
  })]
521
1024
  });
522
1025
  };
523
- export { m as DevCompanion };
1026
+ export { y as DevCompanion };