@bereasoftware/nexa 1.6.0 → 1.8.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/README.en.md +32 -0
- package/README.md +35 -2
- package/dist/bereasoftware-nexa-1.8.0.tgz +0 -0
- package/dist/nexa.cjs.js +163 -163
- package/dist/nexa.cjs.js.map +1 -1
- package/dist/nexa.es.js +479 -365
- package/dist/nexa.es.js.map +1 -1
- package/dist/nexa.iife.js +163 -163
- package/dist/nexa.iife.js.map +1 -1
- package/dist/nexa.umd.js +163 -163
- package/dist/nexa.umd.js.map +1 -1
- package/dist/types/dev-overlay/env.d.ts +1 -0
- package/dist/types/dev-overlay/format.d.ts +3 -0
- package/dist/types/dev-overlay/overlay.d.ts +1 -2
- package/dist/types/dev-overlay/render.d.ts +6 -0
- package/dist/types/dev-overlay/theme.d.ts +40 -0
- package/dist/types/dev-overlay/tracker.d.ts +7 -1
- package/dist/types/http-client/http-client.d.ts +7 -0
- package/dist/types/http-client/index.d.ts +1 -1
- package/dist/types/realtime/index.d.ts +1 -1
- package/dist/types/types/index.d.ts +31 -6
- package/dist/types/utils/index.d.ts +1 -1
- package/package.json +16 -16
- package/dist/bereasoftware-nexa-1.6.0.tgz +0 -0
package/dist/nexa.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Nexa v1.
|
|
1
|
+
/*! Nexa v1.8.0 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/Nexa */
|
|
2
2
|
//#region src/types/index.ts
|
|
3
3
|
var e = (e) => ({
|
|
4
4
|
ok: !0,
|
|
@@ -11,6 +11,10 @@ var e = (e) => ({
|
|
|
11
11
|
//#region src/utils/index.ts
|
|
12
12
|
function n(n) {
|
|
13
13
|
return { validate(r) {
|
|
14
|
+
if (typeof r != "object" || !r) return t({
|
|
15
|
+
message: "Validation failed: expected an object",
|
|
16
|
+
code: "VALIDATION_ERROR"
|
|
17
|
+
});
|
|
14
18
|
let i = r;
|
|
15
19
|
for (let [e, r] of Object.entries(n)) if (!r(i[e])) return t({
|
|
16
20
|
message: `Validation failed: field "${e}" is invalid`,
|
|
@@ -21,6 +25,10 @@ function n(n) {
|
|
|
21
25
|
}
|
|
22
26
|
function r(n) {
|
|
23
27
|
return { validate(r) {
|
|
28
|
+
if (typeof r != "object" || !r) return t({
|
|
29
|
+
message: "Validation failed: expected an object",
|
|
30
|
+
code: "VALIDATION_ERROR"
|
|
31
|
+
});
|
|
24
32
|
let i = r, a = n.filter((e) => !(e in i));
|
|
25
33
|
return a.length > 0 ? t({
|
|
26
34
|
message: `Validation failed: missing fields: ${a.join(", ")}`,
|
|
@@ -39,9 +47,9 @@ var i = { validate(n) {
|
|
|
39
47
|
code: "VALIDATION_ERROR"
|
|
40
48
|
});
|
|
41
49
|
} }, o = { transform(e) {
|
|
42
|
-
return h(e, ee);
|
|
43
|
-
} }, s = { transform(e) {
|
|
44
50
|
return h(e, m);
|
|
51
|
+
} }, s = { transform(e) {
|
|
52
|
+
return h(e, ee);
|
|
45
53
|
} }, c = { transform(e) {
|
|
46
54
|
return g(e);
|
|
47
55
|
} };
|
|
@@ -104,10 +112,10 @@ var d = class {
|
|
|
104
112
|
this.failureCount = 0, this.lastFailureTime = 0;
|
|
105
113
|
}
|
|
106
114
|
};
|
|
107
|
-
function
|
|
115
|
+
function m(e) {
|
|
108
116
|
return e.replace(/_([a-z])/g, (e, t) => t.toUpperCase());
|
|
109
117
|
}
|
|
110
|
-
function
|
|
118
|
+
function ee(e) {
|
|
111
119
|
return e.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`);
|
|
112
120
|
}
|
|
113
121
|
function h(e, t) {
|
|
@@ -125,7 +133,7 @@ function g(e, t = "") {
|
|
|
125
133
|
});
|
|
126
134
|
else if (e && typeof e == "object") for (let [r, i] of Object.entries(e)) {
|
|
127
135
|
let e = t ? `${t}.${r}` : r;
|
|
128
|
-
i && typeof i == "object"
|
|
136
|
+
i && typeof i == "object" ? Object.assign(n, g(i, e)) : n[e] = i;
|
|
129
137
|
}
|
|
130
138
|
return n;
|
|
131
139
|
}
|
|
@@ -277,9 +285,13 @@ function T(e) {
|
|
|
277
285
|
case "DELETE":
|
|
278
286
|
i = await t.delete(r);
|
|
279
287
|
break;
|
|
288
|
+
case "QUERY":
|
|
289
|
+
i = await t.query(r, n);
|
|
290
|
+
break;
|
|
280
291
|
default: throw Error(`Unsupported method: ${e.method}`);
|
|
281
292
|
}
|
|
282
|
-
|
|
293
|
+
if (!i.ok) throw Error(i.error.message);
|
|
294
|
+
return i.value.data;
|
|
283
295
|
};
|
|
284
296
|
}
|
|
285
297
|
function ae(e) {
|
|
@@ -288,7 +300,7 @@ function ae(e) {
|
|
|
288
300
|
return await T(i)(t, r);
|
|
289
301
|
} };
|
|
290
302
|
}
|
|
291
|
-
var
|
|
303
|
+
var oe = class e {
|
|
292
304
|
subscribers = [];
|
|
293
305
|
errorSubscribers = [];
|
|
294
306
|
completeSubscribers = [];
|
|
@@ -317,19 +329,19 @@ var E = class e {
|
|
|
317
329
|
}, (e) => n.error(e), () => n.complete()), n;
|
|
318
330
|
}
|
|
319
331
|
};
|
|
320
|
-
function
|
|
332
|
+
function se(e) {
|
|
321
333
|
return (t) => {
|
|
322
334
|
if (!e(t)) throw TypeError("Value does not match expected type");
|
|
323
335
|
return t;
|
|
324
336
|
};
|
|
325
337
|
}
|
|
326
|
-
function
|
|
338
|
+
function E(e) {
|
|
327
339
|
return e;
|
|
328
340
|
}
|
|
329
|
-
function
|
|
330
|
-
return
|
|
341
|
+
function ce(e) {
|
|
342
|
+
return E(e);
|
|
331
343
|
}
|
|
332
|
-
var
|
|
344
|
+
var D = class {
|
|
333
345
|
_promise;
|
|
334
346
|
resolveFunc;
|
|
335
347
|
rejectFunc;
|
|
@@ -351,7 +363,7 @@ var oe = class {
|
|
|
351
363
|
return this._promise;
|
|
352
364
|
}
|
|
353
365
|
};
|
|
354
|
-
async function
|
|
366
|
+
async function O(e, t = {}) {
|
|
355
367
|
let n = e.body?.getReader();
|
|
356
368
|
if (!n) throw Error("Response body is not readable");
|
|
357
369
|
let r = [], i = 0, a = parseInt(e.headers.get("content-length") || "0", 10);
|
|
@@ -360,22 +372,22 @@ async function A(e, t = {}) {
|
|
|
360
372
|
if (e) break;
|
|
361
373
|
r.push(o), i += o.length, t.onChunk && await t.onChunk(o), t.onProgress && a > 0 && t.onProgress(i, a);
|
|
362
374
|
}
|
|
363
|
-
return
|
|
375
|
+
return k(r, i);
|
|
364
376
|
}
|
|
365
|
-
function
|
|
377
|
+
function k(e, t) {
|
|
366
378
|
let n = new Uint8Array(t), r = 0;
|
|
367
379
|
for (let t of e) n.set(t, r), r += t.byteLength;
|
|
368
380
|
return n;
|
|
369
381
|
}
|
|
370
|
-
async function
|
|
371
|
-
let n = await
|
|
382
|
+
async function A(e, t) {
|
|
383
|
+
let n = await O(e);
|
|
372
384
|
if (typeof window > "u") await (await import("fs").then((e) => e.promises)).writeFile(t, n);
|
|
373
385
|
else {
|
|
374
386
|
let e = new Blob([n.buffer], { type: "application/octet-stream" }), r = URL.createObjectURL(e), i = document.createElement("a");
|
|
375
387
|
i.href = r, i.download = t, i.click(), URL.revokeObjectURL(r);
|
|
376
388
|
}
|
|
377
389
|
}
|
|
378
|
-
function
|
|
390
|
+
function j(e = {}) {
|
|
379
391
|
return async (t, n) => {
|
|
380
392
|
if (await n(), t.response && t.response.body && typeof t.response.body == "object" && "getReader" in t.response.body) {
|
|
381
393
|
let n = t.response.body.getReader(), r = [], i = 0, a = parseInt(t.response.headers?.["content-length"] || "0", 10);
|
|
@@ -385,7 +397,7 @@ function M(e = {}) {
|
|
|
385
397
|
if (o) break;
|
|
386
398
|
r.push(s), i += s.length, e.onChunk && await e.onChunk(s), e.onProgress && a > 0 && e.onProgress(i, a), t.state.streamedChunks = t.state.streamedChunks || [], t.state.streamedChunks.push(s);
|
|
387
399
|
}
|
|
388
|
-
let o =
|
|
400
|
+
let o = k(r, i);
|
|
389
401
|
t.response.body = o, t.state.streaming = !0, t.state.streamedBytes = i;
|
|
390
402
|
} finally {
|
|
391
403
|
n.releaseLock();
|
|
@@ -393,12 +405,12 @@ function M(e = {}) {
|
|
|
393
405
|
}
|
|
394
406
|
};
|
|
395
407
|
}
|
|
396
|
-
var
|
|
408
|
+
var le = j({ onProgress: (e, t) => {
|
|
397
409
|
if (t > 0) {
|
|
398
410
|
let n = Math.round(e / t * 100);
|
|
399
411
|
console.warn(`Streaming: ${n}% (${e}/${t} bytes)`);
|
|
400
412
|
}
|
|
401
|
-
} }),
|
|
413
|
+
} }), M = class {
|
|
402
414
|
plugins = [];
|
|
403
415
|
cache = new y();
|
|
404
416
|
deduplicator = new S();
|
|
@@ -440,7 +452,7 @@ var ce = M({ onProgress: (e, t) => {
|
|
|
440
452
|
clear() {
|
|
441
453
|
this.plugins = [], this.middlewares = [], this.listeners.clear(), this.cache.clear(), this.deduplicator.clear();
|
|
442
454
|
}
|
|
443
|
-
},
|
|
455
|
+
}, ue = {
|
|
444
456
|
name: "logger",
|
|
445
457
|
setup(e) {
|
|
446
458
|
e.on("request:start", (...e) => {
|
|
@@ -454,7 +466,7 @@ var ce = M({ onProgress: (e, t) => {
|
|
|
454
466
|
console.error(`❌ Request failed: ${t}`, n);
|
|
455
467
|
});
|
|
456
468
|
}
|
|
457
|
-
},
|
|
469
|
+
}, de = class {
|
|
458
470
|
name = "metrics";
|
|
459
471
|
metrics = {
|
|
460
472
|
requests: 0,
|
|
@@ -471,7 +483,7 @@ var ce = M({ onProgress: (e, t) => {
|
|
|
471
483
|
getMetrics() {
|
|
472
484
|
return { ...this.metrics };
|
|
473
485
|
}
|
|
474
|
-
},
|
|
486
|
+
}, fe = class {
|
|
475
487
|
name = "cache";
|
|
476
488
|
ttlMs;
|
|
477
489
|
constructor(e = 6e4) {
|
|
@@ -480,12 +492,12 @@ var ce = M({ onProgress: (e, t) => {
|
|
|
480
492
|
setup(e) {
|
|
481
493
|
e.addMiddleware(b({ ttlMs: this.ttlMs }));
|
|
482
494
|
}
|
|
483
|
-
},
|
|
495
|
+
}, pe = class {
|
|
484
496
|
name = "dedupe";
|
|
485
497
|
setup(e) {
|
|
486
498
|
e.addMiddleware(C());
|
|
487
499
|
}
|
|
488
|
-
},
|
|
500
|
+
}, me = class {
|
|
489
501
|
store = new y();
|
|
490
502
|
get(e) {
|
|
491
503
|
return this.store.get(e);
|
|
@@ -499,7 +511,7 @@ var ce = M({ onProgress: (e, t) => {
|
|
|
499
511
|
clear() {
|
|
500
512
|
this.store.clear();
|
|
501
513
|
}
|
|
502
|
-
},
|
|
514
|
+
}, he = class {
|
|
503
515
|
maxAttempts;
|
|
504
516
|
baseDelayMs;
|
|
505
517
|
constructor(e = 3, t = 100) {
|
|
@@ -513,7 +525,7 @@ var ce = M({ onProgress: (e, t) => {
|
|
|
513
525
|
let t = this.baseDelayMs * 2 ** (e - 1), n = Math.random() * t * .1;
|
|
514
526
|
return Math.min(t + n, 3e4);
|
|
515
527
|
}
|
|
516
|
-
},
|
|
528
|
+
}, ge = class {
|
|
517
529
|
running = 0;
|
|
518
530
|
queue = [];
|
|
519
531
|
maxConcurrent;
|
|
@@ -543,7 +555,7 @@ var ce = M({ onProgress: (e, t) => {
|
|
|
543
555
|
return this.running;
|
|
544
556
|
}
|
|
545
557
|
};
|
|
546
|
-
function
|
|
558
|
+
function N(e) {
|
|
547
559
|
return e == null ? {
|
|
548
560
|
serialized: void 0,
|
|
549
561
|
contentType: null
|
|
@@ -567,14 +579,21 @@ function I(e) {
|
|
|
567
579
|
contentType: "application/json"
|
|
568
580
|
};
|
|
569
581
|
}
|
|
570
|
-
function
|
|
582
|
+
function P(e, t) {
|
|
571
583
|
return t ? e.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g, (e, n) => {
|
|
572
584
|
let r = t[n];
|
|
573
585
|
if (r === void 0) throw Error(`Missing path parameter: :${n}`);
|
|
574
586
|
return encodeURIComponent(String(r));
|
|
575
587
|
}) : e;
|
|
576
588
|
}
|
|
577
|
-
|
|
589
|
+
function F(e) {
|
|
590
|
+
let t = new URLSearchParams();
|
|
591
|
+
for (let [n, r] of Object.entries(e)) if (r != null) if (Array.isArray(r)) for (let e of r) t.append(n, String(e));
|
|
592
|
+
else if (typeof r == "object") for (let [e, i] of Object.entries(r)) i != null && t.append(`${n}[${e}]`, String(i));
|
|
593
|
+
else t.append(n, String(r));
|
|
594
|
+
return t.toString();
|
|
595
|
+
}
|
|
596
|
+
var I = class n {
|
|
578
597
|
requestInterceptors = [];
|
|
579
598
|
responseInterceptors = [];
|
|
580
599
|
cache;
|
|
@@ -588,12 +607,12 @@ var R = class n {
|
|
|
588
607
|
defaultHeaders: e.defaultHeaders ?? { "Content-Type": "application/json" },
|
|
589
608
|
defaultTimeout: e.defaultTimeout ?? 3e4,
|
|
590
609
|
validateStatus: e.validateStatus ?? ((e) => e >= 200 && e < 300),
|
|
591
|
-
cacheStrategy: e.cacheStrategy ?? new
|
|
610
|
+
cacheStrategy: e.cacheStrategy ?? new me(),
|
|
592
611
|
maxConcurrent: e.maxConcurrent ?? 0,
|
|
593
612
|
defaultResponseType: e.defaultResponseType ?? "auto",
|
|
594
613
|
defaultHooks: e.defaultHooks ?? {},
|
|
595
614
|
adapter: e.adapter
|
|
596
|
-
}, this.cache = this.config.cacheStrategy, this.requestQueue = this.config.maxConcurrent > 0 ? new
|
|
615
|
+
}, this.cache = this.config.cacheStrategy, this.requestQueue = this.config.maxConcurrent > 0 ? new ge(this.config.maxConcurrent) : null, this.devTracker = e.devTracker ?? null;
|
|
597
616
|
}
|
|
598
617
|
async request(n) {
|
|
599
618
|
if (!this.requestInterceptors.length && !this.responseInterceptors.length && !n.cache?.enabled && !n.hooks && !Object.keys(this.config.defaultHooks).length && !n.retry && !n.validate && !n.transform && !this.requestQueue && !n.onDownloadProgress && !n.signal) return this.fastPath(n);
|
|
@@ -604,9 +623,9 @@ var R = class n {
|
|
|
604
623
|
r.onStart?.(o), this.requestQueue && await this.requestQueue.acquire();
|
|
605
624
|
try {
|
|
606
625
|
for (let s = 1; s <= i; s++) {
|
|
607
|
-
let c;
|
|
626
|
+
let c, l;
|
|
608
627
|
try {
|
|
609
|
-
if ((n.method
|
|
628
|
+
if (this.isCacheableMethod(n.method) && n.cache?.enabled) {
|
|
610
629
|
let t = this.getCacheKey(n), i = this.cache.get(t);
|
|
611
630
|
if (i) {
|
|
612
631
|
let t = i;
|
|
@@ -625,38 +644,38 @@ var R = class n {
|
|
|
625
644
|
}
|
|
626
645
|
let t = o;
|
|
627
646
|
for (let e of this.requestInterceptors) t = await e.onRequest(t);
|
|
628
|
-
c = new AbortController(), this.pendingRequests.add(c), n.signal &&
|
|
629
|
-
let i = performance.now(), a = await this.fetchWithTimeout(t, this.resolveTimeoutMs(n.timeout ?? this.config.defaultTimeout), c),
|
|
630
|
-
n.onDownloadProgress && a.body && (
|
|
631
|
-
let
|
|
632
|
-
if (!this.config.validateStatus(
|
|
633
|
-
message: `Request failed with status ${
|
|
634
|
-
status:
|
|
635
|
-
statusText:
|
|
647
|
+
c = new AbortController(), this.pendingRequests.add(c), n.signal && (l = () => c.abort(), n.signal.addEventListener("abort", l, { once: !0 }));
|
|
648
|
+
let i = performance.now(), a = await this.fetchWithTimeout(t, this.resolveTimeoutMs(n.timeout ?? this.config.defaultTimeout), c), u = performance.now() - i, d = a;
|
|
649
|
+
n.onDownloadProgress && a.body && (d = this.trackDownloadProgress(a, n.onDownloadProgress));
|
|
650
|
+
let f = n.responseType ?? this.config.defaultResponseType, p = await this.parseResponse(d, t, u, f);
|
|
651
|
+
if (!this.config.validateStatus(p.status)) throw {
|
|
652
|
+
message: `Request failed with status ${p.status}`,
|
|
653
|
+
status: p.status,
|
|
654
|
+
statusText: p.statusText,
|
|
636
655
|
code: "HTTP_ERROR"
|
|
637
656
|
};
|
|
638
657
|
if (n.validate) {
|
|
639
|
-
let e = n.validate.validate(
|
|
658
|
+
let e = n.validate.validate(p.data);
|
|
640
659
|
if (!e.ok) return e;
|
|
641
660
|
}
|
|
642
|
-
n.transform && (
|
|
643
|
-
let
|
|
644
|
-
for (let e of this.responseInterceptors)
|
|
645
|
-
if ((n.method
|
|
661
|
+
n.transform && (p.data = n.transform.transform(p.data));
|
|
662
|
+
let m = p;
|
|
663
|
+
for (let e of this.responseInterceptors) m = await e.onResponse(m);
|
|
664
|
+
if (this.isCacheableMethod(n.method) && n.cache?.enabled) {
|
|
646
665
|
let e = this.getCacheKey(n);
|
|
647
|
-
this.cache.set(e,
|
|
666
|
+
this.cache.set(e, m, n.cache.ttlMs);
|
|
648
667
|
}
|
|
649
|
-
return r.onSuccess?.(
|
|
668
|
+
return r.onSuccess?.(m), this.pendingRequests.delete(c), this.trackDev({
|
|
650
669
|
method: n.method ?? "GET",
|
|
651
670
|
url: o.url,
|
|
652
|
-
status:
|
|
653
|
-
duration:
|
|
671
|
+
status: m.status,
|
|
672
|
+
duration: m.duration,
|
|
654
673
|
cached: !1,
|
|
655
674
|
ok: !0,
|
|
656
675
|
headers: { ...o.headers },
|
|
657
676
|
body: n.body,
|
|
658
677
|
retryCount: s - 1
|
|
659
|
-
}), e(
|
|
678
|
+
}), e(m);
|
|
660
679
|
} catch (e) {
|
|
661
680
|
let l;
|
|
662
681
|
if (l = e instanceof DOMException ? e.name === "TimeoutError" ? {
|
|
@@ -689,6 +708,8 @@ var R = class n {
|
|
|
689
708
|
body: n.body,
|
|
690
709
|
retryCount: s - 1
|
|
691
710
|
}), t(u);
|
|
711
|
+
} finally {
|
|
712
|
+
n.signal && l && n.signal.removeEventListener("abort", l);
|
|
692
713
|
}
|
|
693
714
|
}
|
|
694
715
|
let s = {
|
|
@@ -711,33 +732,34 @@ var R = class n {
|
|
|
711
732
|
}
|
|
712
733
|
}
|
|
713
734
|
async fastPath(n) {
|
|
714
|
-
let r =
|
|
735
|
+
let r = P(n.url, n.params), i = this.buildUrl(r, n.query), { serialized: a, contentType: o } = N(n.body), s = {
|
|
715
736
|
...this.config.defaultHeaders,
|
|
716
737
|
...n.headers
|
|
717
738
|
};
|
|
718
739
|
o ? s["Content-Type"] = o : a instanceof FormData && delete s["Content-Type"];
|
|
719
740
|
let c = new AbortController(), l = this.resolveTimeoutMs(n.timeout ?? this.config.defaultTimeout);
|
|
720
741
|
this.pendingRequests.add(c);
|
|
742
|
+
let u = performance.now();
|
|
721
743
|
try {
|
|
722
|
-
let r =
|
|
744
|
+
let r = await this.fetchWithTimeout({
|
|
723
745
|
url: i,
|
|
724
746
|
method: n.method ?? "GET",
|
|
725
747
|
headers: s,
|
|
726
748
|
body: n.body,
|
|
727
749
|
params: n.params
|
|
728
|
-
}, l, c),
|
|
729
|
-
if (!this.config.validateStatus(
|
|
750
|
+
}, l, c), a = performance.now() - u, o = await this.parseBody(r, n.responseType ?? this.config.defaultResponseType);
|
|
751
|
+
if (!this.config.validateStatus(r.status)) {
|
|
730
752
|
let e = t({
|
|
731
|
-
message: `Request failed with status ${
|
|
732
|
-
status:
|
|
733
|
-
statusText:
|
|
753
|
+
message: `Request failed with status ${r.status}`,
|
|
754
|
+
status: r.status,
|
|
755
|
+
statusText: r.statusText,
|
|
734
756
|
code: "HTTP_ERROR"
|
|
735
757
|
});
|
|
736
758
|
return this.trackDev({
|
|
737
759
|
method: n.method ?? "GET",
|
|
738
760
|
url: i,
|
|
739
|
-
status:
|
|
740
|
-
duration:
|
|
761
|
+
status: r.status,
|
|
762
|
+
duration: a,
|
|
741
763
|
cached: !1,
|
|
742
764
|
ok: !1,
|
|
743
765
|
code: "HTTP_ERROR",
|
|
@@ -749,18 +771,18 @@ var R = class n {
|
|
|
749
771
|
return this.pendingRequests.delete(c), this.trackDev({
|
|
750
772
|
method: n.method ?? "GET",
|
|
751
773
|
url: i,
|
|
752
|
-
status:
|
|
753
|
-
duration:
|
|
774
|
+
status: r.status,
|
|
775
|
+
duration: a,
|
|
754
776
|
cached: !1,
|
|
755
777
|
ok: !0,
|
|
756
778
|
headers: s,
|
|
757
779
|
body: n.body,
|
|
758
780
|
retryCount: 0
|
|
759
781
|
}), e({
|
|
760
|
-
status:
|
|
761
|
-
statusText:
|
|
762
|
-
headers:
|
|
763
|
-
data:
|
|
782
|
+
status: r.status,
|
|
783
|
+
statusText: r.statusText,
|
|
784
|
+
headers: r.headers,
|
|
785
|
+
data: o,
|
|
764
786
|
request: {
|
|
765
787
|
url: i,
|
|
766
788
|
method: n.method ?? "GET",
|
|
@@ -768,7 +790,7 @@ var R = class n {
|
|
|
768
790
|
body: n.body,
|
|
769
791
|
params: n.params
|
|
770
792
|
},
|
|
771
|
-
duration:
|
|
793
|
+
duration: a
|
|
772
794
|
});
|
|
773
795
|
} catch (e) {
|
|
774
796
|
this.pendingRequests.delete(c);
|
|
@@ -776,7 +798,7 @@ var R = class n {
|
|
|
776
798
|
if (e instanceof DOMException ? e.name === "TimeoutError" ? r = "TIMEOUT" : e.name === "AbortError" && (r = "ABORTED") : e instanceof Error && (e.name === "TimeoutError" ? r = "TIMEOUT" : e.name === "AbortError" || e.message.includes("abort") ? r = "ABORTED" : e.name === "TypeError" && (r = "NETWORK_ERROR")), this.trackDev({
|
|
777
799
|
method: n.method ?? "GET",
|
|
778
800
|
url: i,
|
|
779
|
-
duration: performance.now() -
|
|
801
|
+
duration: performance.now() - u,
|
|
780
802
|
cached: !1,
|
|
781
803
|
ok: !1,
|
|
782
804
|
code: r,
|
|
@@ -839,6 +861,14 @@ var R = class n {
|
|
|
839
861
|
body: t
|
|
840
862
|
});
|
|
841
863
|
}
|
|
864
|
+
query(e, t, n) {
|
|
865
|
+
return this.request({
|
|
866
|
+
...n,
|
|
867
|
+
url: e,
|
|
868
|
+
method: "QUERY",
|
|
869
|
+
body: t
|
|
870
|
+
});
|
|
871
|
+
}
|
|
842
872
|
delete(e, t) {
|
|
843
873
|
return this.request({
|
|
844
874
|
...t,
|
|
@@ -938,7 +968,7 @@ var R = class n {
|
|
|
938
968
|
});
|
|
939
969
|
}
|
|
940
970
|
buildRequest(e) {
|
|
941
|
-
let t =
|
|
971
|
+
let t = P(e.url, e.params);
|
|
942
972
|
return {
|
|
943
973
|
url: this.buildUrl(t, e.query),
|
|
944
974
|
method: e.method ?? "GET",
|
|
@@ -952,22 +982,21 @@ var R = class n {
|
|
|
952
982
|
}
|
|
953
983
|
buildUrl(e, t) {
|
|
954
984
|
let n = this.config.baseURL + e;
|
|
955
|
-
if (t) {
|
|
956
|
-
let e =
|
|
957
|
-
|
|
958
|
-
let r = new URLSearchParams();
|
|
959
|
-
for (let n = 0; n < e.length; n++) r.append(e[n], String(t[e[n]]));
|
|
960
|
-
n += `?${r.toString()}`;
|
|
961
|
-
}
|
|
985
|
+
if (t && Object.keys(t).length > 0) {
|
|
986
|
+
let e = F(t);
|
|
987
|
+
e && (n += `?${e}`);
|
|
962
988
|
}
|
|
963
989
|
return n;
|
|
964
990
|
}
|
|
991
|
+
isCacheableMethod(e) {
|
|
992
|
+
return e === "GET" || e === "QUERY" || !e;
|
|
993
|
+
}
|
|
965
994
|
getCacheKey(e) {
|
|
966
|
-
let t =
|
|
967
|
-
return `${e.method ?? "GET"}:${t}${n ? ":" + n : ""}`;
|
|
995
|
+
let t = P(e.url, e.params), n = e.query ? JSON.stringify(e.query) : "", r = e.method === "QUERY" && e.body !== void 0 ? JSON.stringify(e.body) : "";
|
|
996
|
+
return `${e.method ?? "GET"}:${t}${n ? ":" + n : ""}${r ? ":" + r : ""}`;
|
|
968
997
|
}
|
|
969
998
|
fetchWithTimeout(e, t, n) {
|
|
970
|
-
let { serialized: r, contentType: i } =
|
|
999
|
+
let { serialized: r, contentType: i } = N(e.body), a = { ...e.headers };
|
|
971
1000
|
return i ? a["Content-Type"] = i : r instanceof FormData && delete a["Content-Type"], new Promise((i, o) => {
|
|
972
1001
|
let s = setTimeout(() => {
|
|
973
1002
|
n.abort(), o(new DOMException("Request timed out", "TimeoutError"));
|
|
@@ -1072,7 +1101,7 @@ var R = class n {
|
|
|
1072
1101
|
return e ? "maxAttempts" in e ? e.maxAttempts ?? 1 : 100 : 1;
|
|
1073
1102
|
}
|
|
1074
1103
|
getRetryStrategy(e) {
|
|
1075
|
-
return e ? "shouldRetry" in e ? e : new
|
|
1104
|
+
return e ? "shouldRetry" in e ? e : new he(e.maxAttempts, e.backoffMs) : {
|
|
1076
1105
|
shouldRetry: () => !1,
|
|
1077
1106
|
delayMs: () => 0
|
|
1078
1107
|
};
|
|
@@ -1086,7 +1115,7 @@ var R = class n {
|
|
|
1086
1115
|
trackDev(e) {
|
|
1087
1116
|
this.devTracker && this.devTracker.track(e);
|
|
1088
1117
|
}
|
|
1089
|
-
},
|
|
1118
|
+
}, L = class extends Error {
|
|
1090
1119
|
status;
|
|
1091
1120
|
code;
|
|
1092
1121
|
response;
|
|
@@ -1094,18 +1123,18 @@ var R = class n {
|
|
|
1094
1123
|
super(e), this.name = "HttpError", this.status = t, this.code = n, this.response = r;
|
|
1095
1124
|
}
|
|
1096
1125
|
};
|
|
1097
|
-
function
|
|
1098
|
-
return e instanceof
|
|
1126
|
+
function _e(e) {
|
|
1127
|
+
return e instanceof L;
|
|
1099
1128
|
}
|
|
1100
|
-
function
|
|
1101
|
-
return new
|
|
1129
|
+
function ve(e) {
|
|
1130
|
+
return new I(e);
|
|
1102
1131
|
}
|
|
1103
1132
|
//#endregion
|
|
1104
1133
|
//#region src/realtime/websocket-client.ts
|
|
1105
|
-
function
|
|
1134
|
+
function R() {
|
|
1106
1135
|
return typeof window > "u" && typeof process < "u" && process.versions?.node !== void 0;
|
|
1107
1136
|
}
|
|
1108
|
-
var
|
|
1137
|
+
var ye = class {
|
|
1109
1138
|
url;
|
|
1110
1139
|
options;
|
|
1111
1140
|
pluginManager;
|
|
@@ -1113,6 +1142,7 @@ var he = class {
|
|
|
1113
1142
|
reconnectAttempt = 0;
|
|
1114
1143
|
reconnectTimer = null;
|
|
1115
1144
|
heartbeatTimer = null;
|
|
1145
|
+
stopHeartbeatMessageListener = null;
|
|
1116
1146
|
stats = {
|
|
1117
1147
|
messagesSent: 0,
|
|
1118
1148
|
messagesReceived: 0,
|
|
@@ -1127,7 +1157,7 @@ var he = class {
|
|
|
1127
1157
|
message: /* @__PURE__ */ new Set()
|
|
1128
1158
|
};
|
|
1129
1159
|
constructor(e, t = {}) {
|
|
1130
|
-
this.url = e, this.options = t, this.pluginManager = new
|
|
1160
|
+
this.url = e, this.options = t, this.pluginManager = new M();
|
|
1131
1161
|
}
|
|
1132
1162
|
updateStatus(e) {
|
|
1133
1163
|
this.status = e, e === "open" ? this.connectionStartTime = Date.now() : e === "closed" && this.connectionStartTime > 0 && (this.stats.connectionTime += Date.now() - this.connectionStartTime, this.connectionStartTime = 0);
|
|
@@ -1177,12 +1207,12 @@ var he = class {
|
|
|
1177
1207
|
this.pluginManager.emit("websocket:reconnect:failed", this.url, this.reconnectAttempt);
|
|
1178
1208
|
return;
|
|
1179
1209
|
}
|
|
1180
|
-
let t = this.options.reconnect?.baseDelay ?? 1e3, n = this.options.reconnect?.maxDelay ?? 3e4, r =
|
|
1181
|
-
this.reconnectAttempt++, this.stats.reconnectAttempts = this.reconnectAttempt, this.options.reconnect?.onReconnecting?.(this.reconnectAttempt,
|
|
1210
|
+
let t = this.options.reconnect?.baseDelay ?? 1e3, n = this.options.reconnect?.maxDelay ?? 3e4, r = t * 2 ** this.reconnectAttempt, i = Math.random() * r * .1, a = Math.min(n, r + i);
|
|
1211
|
+
this.reconnectAttempt++, this.stats.reconnectAttempts = this.reconnectAttempt, this.options.reconnect?.onReconnecting?.(this.reconnectAttempt, a), this.pluginManager.emit("websocket:reconnecting", this.url, this.reconnectAttempt, a), this.reconnectTimer = setTimeout(() => {
|
|
1182
1212
|
this.connect().catch((e) => {
|
|
1183
1213
|
this.emitError(e instanceof Error ? e : Error(String(e)));
|
|
1184
1214
|
});
|
|
1185
|
-
},
|
|
1215
|
+
}, a);
|
|
1186
1216
|
}
|
|
1187
1217
|
startHeartbeat() {
|
|
1188
1218
|
if (!this.options.heartbeat) return;
|
|
@@ -1191,20 +1221,22 @@ var he = class {
|
|
|
1191
1221
|
this.pluginManager.emit("websocket:heartbeat:timeout", this.url), this.disconnect();
|
|
1192
1222
|
return;
|
|
1193
1223
|
}
|
|
1194
|
-
r = !1
|
|
1195
|
-
|
|
1196
|
-
|
|
1224
|
+
r = !1;
|
|
1225
|
+
let n = this.send(t);
|
|
1226
|
+
n.ok || this.pluginManager.emit("websocket:heartbeat:send-failed", this.url, n.error), this.heartbeatTimer = setTimeout(i, e);
|
|
1227
|
+
}, a = (e) => {
|
|
1197
1228
|
let t = e.raw;
|
|
1198
1229
|
typeof t == "string" && t === n && (r = !0);
|
|
1199
|
-
}
|
|
1230
|
+
};
|
|
1231
|
+
this.stopHeartbeatMessageListener?.(), this.stopHeartbeatMessageListener = this.onMessage(a), this.heartbeatTimer = setTimeout(i, e);
|
|
1200
1232
|
}
|
|
1201
1233
|
stopHeartbeat() {
|
|
1202
|
-
this.heartbeatTimer &&= (clearTimeout(this.heartbeatTimer), null);
|
|
1234
|
+
this.heartbeatTimer &&= (clearTimeout(this.heartbeatTimer), null), this.stopHeartbeatMessageListener?.(), this.stopHeartbeatMessageListener = null;
|
|
1203
1235
|
}
|
|
1204
1236
|
cleanup() {
|
|
1205
1237
|
this.reconnectTimer &&= (clearTimeout(this.reconnectTimer), null), this.stopHeartbeat();
|
|
1206
1238
|
}
|
|
1207
|
-
},
|
|
1239
|
+
}, z = class extends ye {
|
|
1208
1240
|
socket = null;
|
|
1209
1241
|
messageTypeListeners = /* @__PURE__ */ new Map();
|
|
1210
1242
|
constructor(e, t = {}) {
|
|
@@ -1242,12 +1274,23 @@ var he = class {
|
|
|
1242
1274
|
disconnect() {
|
|
1243
1275
|
this.cleanup(), this.socket && (this.updateStatus("closing"), this.socket.close(1e3, "Client disconnected"), this.socket = null, this.updateStatus("closed"));
|
|
1244
1276
|
}
|
|
1245
|
-
send(
|
|
1246
|
-
if (!this.socket || this.socket.readyState !== WebSocket.OPEN)
|
|
1247
|
-
|
|
1277
|
+
send(n) {
|
|
1278
|
+
if (!this.socket || this.socket.readyState !== WebSocket.OPEN) return t({
|
|
1279
|
+
message: "WebSocket is not connected",
|
|
1280
|
+
code: "NOT_CONNECTED"
|
|
1281
|
+
});
|
|
1282
|
+
try {
|
|
1283
|
+
this.socket.send(n);
|
|
1284
|
+
} catch (e) {
|
|
1285
|
+
return t({
|
|
1286
|
+
message: e instanceof Error ? e.message : "Failed to send WebSocket message",
|
|
1287
|
+
code: "SEND_FAILED"
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
return this.stats.messagesSent++, this.pluginManager.emit("websocket:message:sent", this.url, n), e(void 0);
|
|
1248
1291
|
}
|
|
1249
1292
|
sendJson(e) {
|
|
1250
|
-
this.send(JSON.stringify(e));
|
|
1293
|
+
return this.send(JSON.stringify(e));
|
|
1251
1294
|
}
|
|
1252
1295
|
onMessageType(e, t) {
|
|
1253
1296
|
return this.messageTypeListeners.has(e) || this.messageTypeListeners.set(e, /* @__PURE__ */ new Set()), this.messageTypeListeners.get(e).add(t), () => {
|
|
@@ -1263,9 +1306,9 @@ var he = class {
|
|
|
1263
1306
|
}
|
|
1264
1307
|
return e;
|
|
1265
1308
|
}
|
|
1266
|
-
},
|
|
1309
|
+
}, be = class extends z {
|
|
1267
1310
|
async connect() {
|
|
1268
|
-
if (
|
|
1311
|
+
if (R()) try {
|
|
1269
1312
|
let { default: e } = await import("ws");
|
|
1270
1313
|
return super.connect();
|
|
1271
1314
|
} catch {
|
|
@@ -1274,15 +1317,15 @@ var he = class {
|
|
|
1274
1317
|
return super.connect();
|
|
1275
1318
|
}
|
|
1276
1319
|
};
|
|
1277
|
-
function
|
|
1278
|
-
return
|
|
1320
|
+
function xe(e, t = {}) {
|
|
1321
|
+
return R() ? new be(e, t) : new z(e, t);
|
|
1279
1322
|
}
|
|
1280
1323
|
//#endregion
|
|
1281
1324
|
//#region src/realtime/sse-client.ts
|
|
1282
|
-
function
|
|
1325
|
+
function Se() {
|
|
1283
1326
|
return typeof window > "u" && typeof process < "u" && process.versions?.node !== void 0;
|
|
1284
1327
|
}
|
|
1285
|
-
var
|
|
1328
|
+
var B = class {
|
|
1286
1329
|
url;
|
|
1287
1330
|
options;
|
|
1288
1331
|
_source = null;
|
|
@@ -1305,8 +1348,9 @@ var W = class {
|
|
|
1305
1348
|
event: /* @__PURE__ */ new Map()
|
|
1306
1349
|
};
|
|
1307
1350
|
_lastEventId = null;
|
|
1351
|
+
nativeEventListeners = /* @__PURE__ */ new Map();
|
|
1308
1352
|
constructor(e, t = {}) {
|
|
1309
|
-
this.url = e, this.options = t, this.pluginManager = new
|
|
1353
|
+
this.url = e, this.options = t, this.pluginManager = new M();
|
|
1310
1354
|
}
|
|
1311
1355
|
updateStatus(e) {
|
|
1312
1356
|
this.status = e, e === "open" ? this.connectionStartTime = Date.now() : e === "closed" && this.connectionStartTime > 0 && (this.stats.connectionTime += Date.now() - this.connectionStartTime, this.connectionStartTime = 0);
|
|
@@ -1314,7 +1358,7 @@ var W = class {
|
|
|
1314
1358
|
async connect() {
|
|
1315
1359
|
if (!(this.status === "connecting" || this.status === "open")) return this.updateStatus("connecting"), this.pluginManager.emit("sse:connect:start", this.url), new Promise((e, t) => {
|
|
1316
1360
|
let n = this.options.timeout ?? 1e4, r = setTimeout(() => {
|
|
1317
|
-
this.updateStatus("closed"), this._source?.close(), this._source = null;
|
|
1361
|
+
this.updateStatus("closed"), this._source?.close(), this._source = null, this.nativeEventListeners.clear();
|
|
1318
1362
|
let e = /* @__PURE__ */ Error(`SSE connection timeout after ${n}ms`);
|
|
1319
1363
|
this.emitError(e), t(e);
|
|
1320
1364
|
}, n);
|
|
@@ -1334,17 +1378,20 @@ var W = class {
|
|
|
1334
1378
|
this.emitMessage(t), this.pluginManager.emit("sse:message:received", this.url, t);
|
|
1335
1379
|
let n = e.type || "message", r = this.listeners.event.get(n);
|
|
1336
1380
|
if (r) for (let e of r) e(t.data);
|
|
1337
|
-
}, this.
|
|
1381
|
+
}, this.attachAllNamedListeners();
|
|
1338
1382
|
} catch (e) {
|
|
1339
1383
|
clearTimeout(r), this.updateStatus("closed"), this.pluginManager.emit("sse:connect:error", this.url, e), t(e);
|
|
1340
1384
|
}
|
|
1341
1385
|
});
|
|
1342
1386
|
}
|
|
1343
1387
|
disconnect() {
|
|
1344
|
-
this.cleanup(), this._source && (this.updateStatus("closing"), this._source.close(), this._source = null, this.updateStatus("closed"), this.emitClose(), this.options.onClose?.());
|
|
1388
|
+
this.cleanup(), this._source && (this.updateStatus("closing"), this._source.close(), this._source = null, this.nativeEventListeners.clear(), this.updateStatus("closed"), this.emitClose(), this.options.onClose?.());
|
|
1345
1389
|
}
|
|
1346
1390
|
send(e) {
|
|
1347
|
-
|
|
1391
|
+
return t({
|
|
1392
|
+
message: "SSE is a receive-only protocol. Use HTTP requests to send data to server.",
|
|
1393
|
+
code: "UNSUPPORTED"
|
|
1394
|
+
});
|
|
1348
1395
|
}
|
|
1349
1396
|
onMessage(e) {
|
|
1350
1397
|
return this.listeners.message.add(e), () => this.listeners.message.delete(e);
|
|
@@ -1358,17 +1405,30 @@ var W = class {
|
|
|
1358
1405
|
onError(e) {
|
|
1359
1406
|
return this.listeners.error.add(e), () => this.listeners.error.delete(e);
|
|
1360
1407
|
}
|
|
1361
|
-
|
|
1362
|
-
|
|
1408
|
+
attachNamedListener(e, t) {
|
|
1409
|
+
if (!this._source) return;
|
|
1410
|
+
let n = (n) => {
|
|
1363
1411
|
t({
|
|
1364
1412
|
data: this.tryParseData(n.data),
|
|
1365
1413
|
raw: n.data,
|
|
1366
1414
|
type: e,
|
|
1367
1415
|
timestamp: Date.now()
|
|
1368
1416
|
}.data);
|
|
1369
|
-
}
|
|
1417
|
+
};
|
|
1418
|
+
this._source.addEventListener(e, n), this.nativeEventListeners.has(e) || this.nativeEventListeners.set(e, /* @__PURE__ */ new Map()), this.nativeEventListeners.get(e).set(t, n);
|
|
1419
|
+
}
|
|
1420
|
+
detachNamedListener(e, t) {
|
|
1421
|
+
let n = this.nativeEventListeners.get(e)?.get(t);
|
|
1422
|
+
n && (this._source?.removeEventListener(e, n), this.nativeEventListeners.get(e).delete(t), this.nativeEventListeners.get(e).size === 0 && this.nativeEventListeners.delete(e));
|
|
1423
|
+
}
|
|
1424
|
+
attachAllNamedListeners() {
|
|
1425
|
+
this.nativeEventListeners.clear();
|
|
1426
|
+
for (let [e, t] of this.listeners.event) for (let n of t) this.attachNamedListener(e, n);
|
|
1427
|
+
}
|
|
1428
|
+
onEvent(e, t) {
|
|
1429
|
+
return this.listeners.event.has(e) || this.listeners.event.set(e, /* @__PURE__ */ new Set()), this.listeners.event.get(e).add(t), this.attachNamedListener(e, t), () => {
|
|
1370
1430
|
let n = this.listeners.event.get(e);
|
|
1371
|
-
n && (n.delete(t), n.size === 0 && this.listeners.event.delete(e));
|
|
1431
|
+
n && (n.delete(t), n.size === 0 && this.listeners.event.delete(e)), this.detachNamedListener(e, t);
|
|
1372
1432
|
};
|
|
1373
1433
|
}
|
|
1374
1434
|
getStatus() {
|
|
@@ -1410,12 +1470,12 @@ var W = class {
|
|
|
1410
1470
|
this.pluginManager.emit("sse:reconnect:failed", this.url, this.reconnectAttempt);
|
|
1411
1471
|
return;
|
|
1412
1472
|
}
|
|
1413
|
-
let t = this.options.reconnect?.baseDelay ?? 1e3, n = this.options.reconnect?.maxDelay ?? 3e4, r =
|
|
1414
|
-
this.reconnectAttempt++, this.stats.reconnectAttempts = this.reconnectAttempt, this.options.reconnect?.onReconnecting?.(this.reconnectAttempt,
|
|
1473
|
+
let t = this.options.reconnect?.baseDelay ?? 1e3, n = this.options.reconnect?.maxDelay ?? 3e4, r = t * 2 ** this.reconnectAttempt, i = Math.random() * r * .1, a = Math.min(n, r + i);
|
|
1474
|
+
this.reconnectAttempt++, this.stats.reconnectAttempts = this.reconnectAttempt, this.options.reconnect?.onReconnecting?.(this.reconnectAttempt, a), this.pluginManager.emit("sse:reconnecting", this.url, this.reconnectAttempt, a), this.reconnectTimer = setTimeout(() => {
|
|
1415
1475
|
this.connect().catch((e) => {
|
|
1416
1476
|
this.emitError(e instanceof Error ? e : Error(String(e)));
|
|
1417
1477
|
});
|
|
1418
|
-
},
|
|
1478
|
+
}, a);
|
|
1419
1479
|
}
|
|
1420
1480
|
cleanup() {
|
|
1421
1481
|
this.reconnectTimer &&= (clearTimeout(this.reconnectTimer), null);
|
|
@@ -1427,18 +1487,17 @@ var W = class {
|
|
|
1427
1487
|
return e;
|
|
1428
1488
|
}
|
|
1429
1489
|
}
|
|
1430
|
-
},
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
return super.connect();
|
|
1490
|
+
}, Ce = class extends B {
|
|
1491
|
+
constructor(e, t = {}) {
|
|
1492
|
+
throw super(e, t), Error("Nexa's SSE client is browser-only (it relies on the native EventSource API). Node.js has no built-in EventSource. Use a polyfill (e.g. the \"eventsource\" package) and pass it via a custom implementation, or run this client in a browser environment.");
|
|
1434
1493
|
}
|
|
1435
1494
|
};
|
|
1436
|
-
function
|
|
1437
|
-
return
|
|
1495
|
+
function we(e, t = {}) {
|
|
1496
|
+
return Se() ? new Ce(e, t) : new B(e, t);
|
|
1438
1497
|
}
|
|
1439
1498
|
//#endregion
|
|
1440
1499
|
//#region src/realtime/plugin.ts
|
|
1441
|
-
var
|
|
1500
|
+
var Te = class {
|
|
1442
1501
|
name = "realtime";
|
|
1443
1502
|
setup(e) {
|
|
1444
1503
|
e.on("websocket:connect:start", (...t) => {
|
|
@@ -1462,35 +1521,37 @@ var be = class {
|
|
|
1462
1521
|
});
|
|
1463
1522
|
}
|
|
1464
1523
|
};
|
|
1465
|
-
function
|
|
1466
|
-
return new
|
|
1524
|
+
function Ee() {
|
|
1525
|
+
return new Te();
|
|
1467
1526
|
}
|
|
1468
1527
|
//#endregion
|
|
1469
1528
|
//#region src/dev-overlay/tracker.ts
|
|
1470
|
-
var
|
|
1471
|
-
function
|
|
1529
|
+
var V = "nexa.devOverlay.config";
|
|
1530
|
+
function H() {
|
|
1472
1531
|
try {
|
|
1473
1532
|
if (typeof localStorage > "u") return {};
|
|
1474
|
-
let e = localStorage.getItem(
|
|
1533
|
+
let e = localStorage.getItem(V);
|
|
1475
1534
|
return e ? JSON.parse(e) : {};
|
|
1476
1535
|
} catch {
|
|
1477
1536
|
return {};
|
|
1478
1537
|
}
|
|
1479
1538
|
}
|
|
1480
|
-
function
|
|
1539
|
+
function De(e) {
|
|
1481
1540
|
try {
|
|
1482
1541
|
if (typeof localStorage > "u") return;
|
|
1483
|
-
localStorage.setItem(
|
|
1542
|
+
localStorage.setItem(V, JSON.stringify(e));
|
|
1484
1543
|
} catch {}
|
|
1485
1544
|
}
|
|
1486
|
-
var
|
|
1487
|
-
|
|
1545
|
+
var U = class {
|
|
1546
|
+
buffer = [];
|
|
1547
|
+
writeIndex = 0;
|
|
1548
|
+
count = 0;
|
|
1488
1549
|
maxHistory;
|
|
1489
1550
|
listeners = /* @__PURE__ */ new Set();
|
|
1490
1551
|
startTime = Date.now();
|
|
1491
1552
|
config;
|
|
1492
1553
|
constructor(e = {}) {
|
|
1493
|
-
this.maxHistory = e.maxHistory ?? 500, this.config = {
|
|
1554
|
+
this.maxHistory = Math.max(1, e.maxHistory ?? 500), this.buffer = Array(this.maxHistory), this.config = {
|
|
1494
1555
|
enabled: e.enabled ?? !0,
|
|
1495
1556
|
maxHistory: this.maxHistory,
|
|
1496
1557
|
keyboardShortcut: e.keyboardShortcut ?? "ctrl+shift+n",
|
|
@@ -1510,29 +1571,34 @@ var q = class {
|
|
|
1510
1571
|
id: this.generateId(),
|
|
1511
1572
|
timestamp: Date.now()
|
|
1512
1573
|
};
|
|
1513
|
-
this.
|
|
1574
|
+
this.buffer[this.writeIndex] = t, this.writeIndex = (this.writeIndex + 1) % this.maxHistory, this.count = Math.min(this.count + 1, this.maxHistory);
|
|
1514
1575
|
for (let e of this.listeners) e(t);
|
|
1515
1576
|
return t;
|
|
1516
1577
|
}
|
|
1517
1578
|
getHistory() {
|
|
1518
|
-
|
|
1579
|
+
let e = [];
|
|
1580
|
+
for (let t = 0; t < this.count; t++) {
|
|
1581
|
+
let n = ((this.writeIndex - 1 - t) % this.maxHistory + this.maxHistory) % this.maxHistory;
|
|
1582
|
+
e.push(this.buffer[n]);
|
|
1583
|
+
}
|
|
1584
|
+
return e;
|
|
1519
1585
|
}
|
|
1520
1586
|
getMetrics() {
|
|
1521
|
-
let e = this.
|
|
1587
|
+
let e = this.getHistory(), t = e.map((e) => e.duration), n = (Date.now() - this.startTime) / 1e3;
|
|
1522
1588
|
return {
|
|
1523
|
-
totalRequests:
|
|
1524
|
-
successfulRequests:
|
|
1525
|
-
failedRequests:
|
|
1526
|
-
cachedRequests:
|
|
1527
|
-
avgDuration:
|
|
1528
|
-
maxDuration:
|
|
1529
|
-
minDuration:
|
|
1530
|
-
requestsPerSecond:
|
|
1531
|
-
slowestRequests:
|
|
1589
|
+
totalRequests: e.length,
|
|
1590
|
+
successfulRequests: e.filter((e) => e.ok).length,
|
|
1591
|
+
failedRequests: e.filter((e) => !e.ok).length,
|
|
1592
|
+
cachedRequests: e.filter((e) => e.cached).length,
|
|
1593
|
+
avgDuration: t.length ? t.reduce((e, t) => e + t, 0) / t.length : 0,
|
|
1594
|
+
maxDuration: t.length ? Math.max(...t) : 0,
|
|
1595
|
+
minDuration: t.length ? Math.min(...t) : 0,
|
|
1596
|
+
requestsPerSecond: n > 0 ? e.length / n : 0,
|
|
1597
|
+
slowestRequests: e.sort((e, t) => t.duration - e.duration).slice(0, 5)
|
|
1532
1598
|
};
|
|
1533
1599
|
}
|
|
1534
1600
|
clear() {
|
|
1535
|
-
this.
|
|
1601
|
+
this.buffer = Array(this.maxHistory), this.writeIndex = 0, this.count = 0, this.startTime = Date.now();
|
|
1536
1602
|
}
|
|
1537
1603
|
onChange(e) {
|
|
1538
1604
|
return this.listeners.add(e), () => this.listeners.delete(e);
|
|
@@ -1544,16 +1610,23 @@ var q = class {
|
|
|
1544
1610
|
this.config = {
|
|
1545
1611
|
...this.config,
|
|
1546
1612
|
...e
|
|
1547
|
-
}
|
|
1613
|
+
};
|
|
1614
|
+
let t = Math.max(1, this.config.maxHistory);
|
|
1615
|
+
t !== this.maxHistory && this.resizeHistory(t);
|
|
1548
1616
|
try {
|
|
1549
|
-
|
|
1617
|
+
De(this.config);
|
|
1550
1618
|
} catch {}
|
|
1551
1619
|
return this.config;
|
|
1552
1620
|
}
|
|
1621
|
+
resizeHistory(e) {
|
|
1622
|
+
let t = this.getHistory().slice(0, e);
|
|
1623
|
+
this.maxHistory = e, this.buffer = Array(e), this.writeIndex = 0, this.count = 0;
|
|
1624
|
+
for (let e = t.length - 1; e >= 0; e--) this.buffer[this.writeIndex] = t[e], this.writeIndex = (this.writeIndex + 1) % this.maxHistory, this.count++;
|
|
1625
|
+
}
|
|
1553
1626
|
generateId() {
|
|
1554
1627
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
1555
1628
|
}
|
|
1556
|
-
},
|
|
1629
|
+
}, W = {
|
|
1557
1630
|
gear: "<svg width=\"16\" height=\"16\" viewBox=\"0 0 48 48\" fill=\"currentColor\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M 24 4 C 22.423103 4 20.902664 4.1994284 19.451172 4.5371094 A 1.50015 1.50015 0 0 0 18.300781 5.8359375 L 17.982422 8.7382812 C 17.878304 9.6893592 17.328913 10.530853 16.5 11.009766 C 15.672739 11.487724 14.66862 11.540667 13.792969 11.15625 L 13.791016 11.15625 L 11.125 9.9824219 A 1.50015 1.50015 0 0 0 9.4257812 10.330078 C 7.3532865 12.539588 5.7626807 15.215064 4.859375 18.201172 A 1.50015 1.50015 0 0 0 5.4082031 19.845703 L 7.7734375 21.580078 C 8.5457929 22.147918 9 23.042801 9 24 C 9 24.95771 8.5458041 25.853342 7.7734375 26.419922 L 5.4082031 28.152344 A 1.50015 1.50015 0 0 0 4.859375 29.796875 C 5.7625845 32.782665 7.3519262 35.460112 9.4257812 37.669922 A 1.50015 1.50015 0 0 0 11.125 38.015625 L 13.791016 36.841797 C 14.667094 36.456509 15.672169 36.511947 16.5 36.990234 C 17.328913 37.469147 17.878304 38.310641 17.982422 39.261719 L 18.300781 42.164062 A 1.50015 1.50015 0 0 0 19.449219 43.460938 C 20.901371 43.799844 22.423103 44 24 44 C 25.576897 44 27.097336 43.800572 28.548828 43.462891 A 1.50015 1.50015 0 0 0 29.699219 42.164062 L 30.017578 39.261719 C 30.121696 38.310641 30.671087 37.469147 31.5 36.990234 C 32.327261 36.512276 33.33138 36.45738 34.207031 36.841797 L 36.875 38.015625 A 1.50015 1.50015 0 0 0 38.574219 37.669922 C 40.646713 35.460412 42.237319 32.782983 43.140625 29.796875 A 1.50015 1.50015 0 0 0 42.591797 28.152344 L 40.226562 26.419922 C 39.454197 25.853342 39 24.95771 39 24 C 39 23.04229 39.454197 22.146658 40.226562 21.580078 L 42.591797 19.847656 A 1.50015 1.50015 0 0 0 43.140625 18.203125 C 42.237319 15.217017 40.646713 12.539588 38.574219 10.330078 A 1.50015 1.50015 0 0 0 36.875 9.984375 L 34.207031 11.158203 C 33.33138 11.54262 32.327261 11.487724 31.5 11.009766 C 30.671087 10.530853 30.121696 9.6893592 30.017578 8.7382812 L 29.699219 5.8359375 A 1.50015 1.50015 0 0 0 28.550781 4.5390625 C 27.098629 4.2001555 25.576897 4 24 4 z M 24 7 C 24.974302 7 25.90992 7.1748796 26.847656 7.3398438 L 27.035156 9.0644531 C 27.243038 10.963375 28.346913 12.652335 30 13.607422 C 31.654169 14.563134 33.668094 14.673009 35.416016 13.904297 L 37.001953 13.207031 C 38.219788 14.669402 39.183985 16.321182 39.857422 18.130859 L 38.451172 19.162109 C 36.911538 20.291529 36 22.08971 36 24 C 36 25.91029 36.911538 27.708471 38.451172 28.837891 L 39.857422 29.869141 C 39.183985 31.678818 38.219788 33.330598 37.001953 34.792969 L 35.416016 34.095703 C 33.668094 33.326991 31.654169 33.436866 30 34.392578 C 28.346913 35.347665 27.243038 37.036625 27.035156 38.935547 L 26.847656 40.660156 C 25.910002 40.82466 24.973817 41 24 41 C 23.025698 41 22.09008 40.82512 21.152344 40.660156 L 20.964844 38.935547 C 20.756962 37.036625 19.653087 35.347665 18 34.392578 C 16.345831 33.436866 14.331906 33.326991 12.583984 34.095703 L 10.998047 34.792969 C 9.7799772 33.330806 8.8159425 31.678964 8.1425781 29.869141 L 9.5488281 28.837891 C 11.088462 27.708471 12 25.91029 12 24 C 12 22.08971 11.087719 20.290363 9.5488281 19.160156 L 8.1425781 18.128906 C 8.8163325 16.318532 9.7814501 14.667839 11 13.205078 L 12.583984 13.902344 C 14.331906 14.671056 16.345831 14.563134 18 13.607422 C 19.653087 12.652335 20.756962 10.963375 20.964844 9.0644531 L 21.152344 7.3398438 C 22.089998 7.1753403 23.026183 7 24 7 z M 24 16 C 19.599487 16 16 19.59949 16 24 C 16 28.40051 19.599487 32 24 32 C 28.400513 32 32 28.40051 32 24 C 32 19.59949 28.400513 16 24 16 z M 24 19 C 26.779194 19 29 21.220808 29 24 C 29 26.779192 26.779194 29 24 29 C 21.220806 29 19 26.779192 19 24 C 19 21.220808 21.220806 19 24 19 z\"></path>\n</svg>",
|
|
1558
1631
|
close: "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 6L6 18M6 6l12 12\"/></svg>",
|
|
1559
1632
|
chevron: "<svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M9 18l6-6-6-6\"/></svg>",
|
|
@@ -1565,7 +1638,7 @@ var q = class {
|
|
|
1565
1638
|
zap: "<svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><polygon points=\"13 2 3 14 12 14 11 22 21 10 12 10 13 2\"/></svg>",
|
|
1566
1639
|
download: "<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v4\"/><polyline points=\"7 10 12 15 17 10\"/><line x1=\"12\" y1=\"15\" x2=\"12\" y2=\"3\"/></svg>",
|
|
1567
1640
|
copy: "<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" ry=\"2\"/><path d=\"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1\"/></svg>"
|
|
1568
|
-
},
|
|
1641
|
+
}, G = {
|
|
1569
1642
|
bg: "#0b1120",
|
|
1570
1643
|
bgElevated: "#111827",
|
|
1571
1644
|
bgSurface: "#172033",
|
|
@@ -1590,13 +1663,13 @@ var q = class {
|
|
|
1590
1663
|
put: "#fbbf24",
|
|
1591
1664
|
patch: "#a78bfa",
|
|
1592
1665
|
delete: "#fb7185"
|
|
1593
|
-
},
|
|
1666
|
+
}, Oe = `
|
|
1594
1667
|
#nexa-dev-overlay * { margin: 0; padding: 0; box-sizing: border-box; }
|
|
1595
1668
|
#nexa-dev-overlay {
|
|
1596
1669
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
1597
|
-
background: ${
|
|
1598
|
-
color: ${
|
|
1599
|
-
border: 1px solid ${
|
|
1670
|
+
background: ${G.bg};
|
|
1671
|
+
color: ${G.text};
|
|
1672
|
+
border: 1px solid ${G.border};
|
|
1600
1673
|
border-radius: 16px;
|
|
1601
1674
|
box-shadow: 0 28px 60px -24px rgba(2, 6, 23, 0.78), 0 0 0 1px rgba(148, 163, 184, 0.08);
|
|
1602
1675
|
overflow: hidden;
|
|
@@ -1606,8 +1679,8 @@ var q = class {
|
|
|
1606
1679
|
align-items: center;
|
|
1607
1680
|
justify-content: space-between;
|
|
1608
1681
|
padding: 16px 20px;
|
|
1609
|
-
border-bottom: 1px solid ${
|
|
1610
|
-
background: ${
|
|
1682
|
+
border-bottom: 1px solid ${G.border};
|
|
1683
|
+
background: ${G.bgElevated};
|
|
1611
1684
|
}
|
|
1612
1685
|
#nexa-dev-overlay .nexa-header-left {
|
|
1613
1686
|
display: flex;
|
|
@@ -1620,7 +1693,7 @@ var q = class {
|
|
|
1620
1693
|
display: flex;
|
|
1621
1694
|
align-items: center;
|
|
1622
1695
|
justify-content: center;
|
|
1623
|
-
background: linear-gradient(135deg, ${
|
|
1696
|
+
background: linear-gradient(135deg, ${G.accentSoft}, rgba(255,255,255,0.02));
|
|
1624
1697
|
border-radius: 8px;
|
|
1625
1698
|
overflow: hidden;
|
|
1626
1699
|
}
|
|
@@ -1642,20 +1715,20 @@ var q = class {
|
|
|
1642
1715
|
background: transparent;
|
|
1643
1716
|
border: none;
|
|
1644
1717
|
border-radius: 8px;
|
|
1645
|
-
color: ${
|
|
1718
|
+
color: ${G.textMuted};
|
|
1646
1719
|
cursor: pointer;
|
|
1647
1720
|
transition: all 0.15s;
|
|
1648
1721
|
}
|
|
1649
1722
|
#nexa-dev-overlay .nexa-icon-btn:hover {
|
|
1650
|
-
background: ${
|
|
1651
|
-
color: ${
|
|
1723
|
+
background: ${G.bgSurface};
|
|
1724
|
+
color: ${G.text};
|
|
1652
1725
|
}
|
|
1653
1726
|
#nexa-dev-overlay .nexa-metrics-bar {
|
|
1654
1727
|
display: flex;
|
|
1655
1728
|
gap: 4px;
|
|
1656
1729
|
padding: 12px 16px;
|
|
1657
|
-
background: ${
|
|
1658
|
-
border-bottom: 1px solid ${
|
|
1730
|
+
background: ${G.bg};
|
|
1731
|
+
border-bottom: 1px solid ${G.border};
|
|
1659
1732
|
}
|
|
1660
1733
|
#nexa-dev-overlay .nexa-metric {
|
|
1661
1734
|
flex: 1;
|
|
@@ -1664,7 +1737,7 @@ var q = class {
|
|
|
1664
1737
|
align-items: center;
|
|
1665
1738
|
gap: 2px;
|
|
1666
1739
|
padding: 8px 12px;
|
|
1667
|
-
background: ${
|
|
1740
|
+
background: ${G.bgSurface};
|
|
1668
1741
|
border-radius: 10px;
|
|
1669
1742
|
transition: all 0.2s;
|
|
1670
1743
|
}
|
|
@@ -1675,19 +1748,19 @@ var q = class {
|
|
|
1675
1748
|
font-size: 18px;
|
|
1676
1749
|
font-weight: 700;
|
|
1677
1750
|
letter-spacing: -0.03em;
|
|
1678
|
-
color: ${
|
|
1751
|
+
color: ${G.text};
|
|
1679
1752
|
}
|
|
1680
|
-
#nexa-dev-overlay .nexa-metric-ok .nexa-metric-value { color: ${
|
|
1681
|
-
#nexa-dev-overlay .nexa-metric-err .nexa-metric-value { color: ${
|
|
1753
|
+
#nexa-dev-overlay .nexa-metric-ok .nexa-metric-value { color: ${G.success}; }
|
|
1754
|
+
#nexa-dev-overlay .nexa-metric-err .nexa-metric-value { color: ${G.error}; }
|
|
1682
1755
|
#nexa-dev-overlay .nexa-metric-label {
|
|
1683
1756
|
font-size: 11px;
|
|
1684
|
-
color: ${
|
|
1757
|
+
color: ${G.textDim};
|
|
1685
1758
|
text-transform: uppercase;
|
|
1686
1759
|
letter-spacing: 0.05em;
|
|
1687
1760
|
}
|
|
1688
1761
|
#nexa-dev-overlay .nexa-search {
|
|
1689
1762
|
padding: 12px 16px;
|
|
1690
|
-
border-bottom: 1px solid ${
|
|
1763
|
+
border-bottom: 1px solid ${G.border};
|
|
1691
1764
|
position: relative;
|
|
1692
1765
|
}
|
|
1693
1766
|
#nexa-dev-overlay .nexa-search-icon {
|
|
@@ -1695,29 +1768,29 @@ var q = class {
|
|
|
1695
1768
|
left: 28px;
|
|
1696
1769
|
top: 50%;
|
|
1697
1770
|
transform: translateY(-50%);
|
|
1698
|
-
color: ${
|
|
1771
|
+
color: ${G.textDim};
|
|
1699
1772
|
}
|
|
1700
1773
|
#nexa-dev-overlay .nexa-search-input {
|
|
1701
1774
|
width: 100%;
|
|
1702
1775
|
padding: 10px 12px 10px 38px;
|
|
1703
|
-
background: ${
|
|
1704
|
-
border: 1px solid ${
|
|
1776
|
+
background: ${G.bg};
|
|
1777
|
+
border: 1px solid ${G.border};
|
|
1705
1778
|
border-radius: 10px;
|
|
1706
|
-
color: ${
|
|
1779
|
+
color: ${G.text};
|
|
1707
1780
|
font-size: 13px;
|
|
1708
1781
|
outline: none;
|
|
1709
1782
|
transition: all 0.15s;
|
|
1710
1783
|
}
|
|
1711
1784
|
#nexa-dev-overlay .nexa-search-input:focus {
|
|
1712
|
-
border-color: ${
|
|
1713
|
-
box-shadow: 0 0 0 3px ${
|
|
1785
|
+
border-color: ${G.accent};
|
|
1786
|
+
box-shadow: 0 0 0 3px ${G.accentSoft};
|
|
1714
1787
|
}
|
|
1715
|
-
#nexa-dev-overlay .nexa-search-input::placeholder { color: ${
|
|
1788
|
+
#nexa-dev-overlay .nexa-search-input::placeholder { color: ${G.textDim}; }
|
|
1716
1789
|
#nexa-dev-overlay .nexa-filters {
|
|
1717
1790
|
display: flex;
|
|
1718
1791
|
gap: 6px;
|
|
1719
1792
|
padding: 12px 16px 12px 16px;
|
|
1720
|
-
border-bottom: 1px solid ${
|
|
1793
|
+
border-bottom: 1px solid ${G.border};
|
|
1721
1794
|
overflow-x: auto;
|
|
1722
1795
|
scrollbar-width: none;
|
|
1723
1796
|
min-height: 50px;
|
|
@@ -1725,27 +1798,27 @@ var q = class {
|
|
|
1725
1798
|
#nexa-dev-overlay .nexa-filters::-webkit-scrollbar { display: none; }
|
|
1726
1799
|
#nexa-dev-overlay .nexa-filter-chip {
|
|
1727
1800
|
padding: 4px 10px;
|
|
1728
|
-
background: ${
|
|
1729
|
-
border: 1px solid ${
|
|
1801
|
+
background: ${G.bgSurface};
|
|
1802
|
+
border: 1px solid ${G.border};
|
|
1730
1803
|
border-radius: 20px;
|
|
1731
|
-
color: ${
|
|
1804
|
+
color: ${G.textDim};
|
|
1732
1805
|
font-size: 11px;
|
|
1733
1806
|
font-weight: 600;
|
|
1734
1807
|
white-space: nowrap;
|
|
1735
1808
|
cursor: pointer;
|
|
1736
1809
|
transition: all 0.15s;
|
|
1737
1810
|
}
|
|
1738
|
-
#nexa-dev-overlay .nexa-filter-chip:hover { border-color: ${
|
|
1811
|
+
#nexa-dev-overlay .nexa-filter-chip:hover { border-color: ${G.borderFocus}; color: ${G.textMuted}; }
|
|
1739
1812
|
#nexa-dev-overlay .nexa-filter-chip-active {
|
|
1740
|
-
background: ${
|
|
1741
|
-
border-color: ${
|
|
1742
|
-
color: ${
|
|
1813
|
+
background: ${G.accentSoft};
|
|
1814
|
+
border-color: ${G.accent};
|
|
1815
|
+
color: ${G.accent};
|
|
1743
1816
|
}
|
|
1744
1817
|
#nexa-dev-overlay .nexa-tabs {
|
|
1745
1818
|
display: flex;
|
|
1746
1819
|
gap: 4px;
|
|
1747
1820
|
padding: 8px 16px;
|
|
1748
|
-
border-bottom: 1px solid ${
|
|
1821
|
+
border-bottom: 1px solid ${G.border};
|
|
1749
1822
|
}
|
|
1750
1823
|
#nexa-dev-overlay .nexa-tab {
|
|
1751
1824
|
display: flex;
|
|
@@ -1755,14 +1828,14 @@ var q = class {
|
|
|
1755
1828
|
background: transparent;
|
|
1756
1829
|
border: none;
|
|
1757
1830
|
border-radius: 8px;
|
|
1758
|
-
color: ${
|
|
1831
|
+
color: ${G.textMuted};
|
|
1759
1832
|
font-size: 13px;
|
|
1760
1833
|
font-weight: 500;
|
|
1761
1834
|
cursor: pointer;
|
|
1762
1835
|
transition: all 0.15s;
|
|
1763
1836
|
}
|
|
1764
|
-
#nexa-dev-overlay .nexa-tab:hover { color: ${
|
|
1765
|
-
#nexa-dev-overlay .nexa-tab-active { color: ${
|
|
1837
|
+
#nexa-dev-overlay .nexa-tab:hover { color: ${G.text}; background: ${G.bgElevated}; }
|
|
1838
|
+
#nexa-dev-overlay .nexa-tab-active { color: ${G.text}; background: ${G.accent} !important; }
|
|
1766
1839
|
#nexa-dev-overlay .nexa-tab-count {
|
|
1767
1840
|
font-size: 11px;
|
|
1768
1841
|
padding: 2px 6px;
|
|
@@ -1783,7 +1856,7 @@ var q = class {
|
|
|
1783
1856
|
align-items: center;
|
|
1784
1857
|
justify-content: space-between;
|
|
1785
1858
|
padding: 12px 14px;
|
|
1786
|
-
background: ${
|
|
1859
|
+
background: ${G.bgSurface};
|
|
1787
1860
|
border: 1px solid transparent;
|
|
1788
1861
|
border-radius: 12px;
|
|
1789
1862
|
cursor: pointer;
|
|
@@ -1794,7 +1867,7 @@ var q = class {
|
|
|
1794
1867
|
@keyframes nexaFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
|
|
1795
1868
|
#nexa-dev-overlay .nexa-request-item:hover {
|
|
1796
1869
|
background: rgba(23, 32, 51, 0.92);
|
|
1797
|
-
border-color: ${
|
|
1870
|
+
border-color: ${G.borderFocus};
|
|
1798
1871
|
transform: translateX(2px);
|
|
1799
1872
|
}
|
|
1800
1873
|
#nexa-dev-overlay .nexa-req-left {
|
|
@@ -1810,11 +1883,11 @@ var q = class {
|
|
|
1810
1883
|
text-transform: uppercase;
|
|
1811
1884
|
letter-spacing: 0.03em;
|
|
1812
1885
|
}
|
|
1813
|
-
#nexa-dev-overlay .nexa-method-get { background: ${
|
|
1814
|
-
#nexa-dev-overlay .nexa-method-post { background: ${
|
|
1815
|
-
#nexa-dev-overlay .nexa-method-put { background: ${
|
|
1816
|
-
#nexa-dev-overlay .nexa-method-patch { background: ${
|
|
1817
|
-
#nexa-dev-overlay .nexa-method-delete { background: ${
|
|
1886
|
+
#nexa-dev-overlay .nexa-method-get { background: ${G.successBg}; color: ${G.get}; }
|
|
1887
|
+
#nexa-dev-overlay .nexa-method-post { background: ${G.accentSoft}; color: ${G.post}; }
|
|
1888
|
+
#nexa-dev-overlay .nexa-method-put { background: ${G.warningBg}; color: ${G.put}; }
|
|
1889
|
+
#nexa-dev-overlay .nexa-method-patch { background: ${G.infoBg}; color: ${G.patch}; }
|
|
1890
|
+
#nexa-dev-overlay .nexa-method-delete { background: ${G.errorBg}; color: ${G.delete}; }
|
|
1818
1891
|
#nexa-dev-overlay .nexa-status {
|
|
1819
1892
|
font-size: 12px;
|
|
1820
1893
|
font-weight: 600;
|
|
@@ -1823,11 +1896,11 @@ var q = class {
|
|
|
1823
1896
|
min-width: 36px;
|
|
1824
1897
|
text-align: center;
|
|
1825
1898
|
}
|
|
1826
|
-
#nexa-dev-overlay .nexa-ok { background: ${
|
|
1827
|
-
#nexa-dev-overlay .nexa-err { background: ${
|
|
1899
|
+
#nexa-dev-overlay .nexa-ok { background: ${G.successBg}; color: ${G.success}; }
|
|
1900
|
+
#nexa-dev-overlay .nexa-err { background: ${G.errorBg}; color: ${G.error}; }
|
|
1828
1901
|
#nexa-dev-overlay .nexa-url {
|
|
1829
1902
|
font-size: 13px;
|
|
1830
|
-
color: ${
|
|
1903
|
+
color: ${G.textMuted};
|
|
1831
1904
|
max-width: 180px;
|
|
1832
1905
|
overflow: hidden;
|
|
1833
1906
|
text-overflow: ellipsis;
|
|
@@ -1846,15 +1919,15 @@ var q = class {
|
|
|
1846
1919
|
text-transform: uppercase;
|
|
1847
1920
|
letter-spacing: 0.03em;
|
|
1848
1921
|
}
|
|
1849
|
-
#nexa-dev-overlay .nexa-badge-cache { background: ${
|
|
1850
|
-
#nexa-dev-overlay .nexa-badge-retry { background: ${
|
|
1922
|
+
#nexa-dev-overlay .nexa-badge-cache { background: ${G.infoBg}; color: ${G.info}; }
|
|
1923
|
+
#nexa-dev-overlay .nexa-badge-retry { background: ${G.warningBg}; color: ${G.warning}; }
|
|
1851
1924
|
#nexa-dev-overlay .nexa-duration {
|
|
1852
1925
|
font-size: 12px;
|
|
1853
1926
|
font-weight: 600;
|
|
1854
|
-
color: ${
|
|
1927
|
+
color: ${G.textDim};
|
|
1855
1928
|
font-variant-numeric: tabular-nums;
|
|
1856
1929
|
}
|
|
1857
|
-
#nexa-dev-overlay .nexa-slow { color: ${
|
|
1930
|
+
#nexa-dev-overlay .nexa-slow { color: ${G.warning}; }
|
|
1858
1931
|
#nexa-dev-overlay .nexa-empty {
|
|
1859
1932
|
display: flex;
|
|
1860
1933
|
flex-direction: column;
|
|
@@ -1862,11 +1935,11 @@ var q = class {
|
|
|
1862
1935
|
justify-content: center;
|
|
1863
1936
|
padding: 48px 24px;
|
|
1864
1937
|
text-align: center;
|
|
1865
|
-
color: ${
|
|
1938
|
+
color: ${G.textDim};
|
|
1866
1939
|
}
|
|
1867
1940
|
#nexa-dev-overlay .nexa-empty svg { margin-bottom: 16px; opacity: 0.4; }
|
|
1868
|
-
#nexa-dev-overlay .nexa-empty p { font-size: 14px; color: ${
|
|
1869
|
-
#nexa-dev-overlay .nexa-empty span { font-size: 12px; color: ${
|
|
1941
|
+
#nexa-dev-overlay .nexa-empty p { font-size: 14px; color: ${G.textMuted}; margin-bottom: 4px; }
|
|
1942
|
+
#nexa-dev-overlay .nexa-empty span { font-size: 12px; color: ${G.textDim}; }
|
|
1870
1943
|
#nexa-dev-overlay .nexa-detail {
|
|
1871
1944
|
flex-direction: column;
|
|
1872
1945
|
padding: 16px;
|
|
@@ -1890,23 +1963,23 @@ var q = class {
|
|
|
1890
1963
|
align-items: center;
|
|
1891
1964
|
gap: 6px;
|
|
1892
1965
|
padding: 8px 14px;
|
|
1893
|
-
background: ${
|
|
1894
|
-
border: 1px solid ${
|
|
1966
|
+
background: ${G.bgSurface};
|
|
1967
|
+
border: 1px solid ${G.border};
|
|
1895
1968
|
border-radius: 8px;
|
|
1896
|
-
color: ${
|
|
1969
|
+
color: ${G.textMuted};
|
|
1897
1970
|
font-size: 13px;
|
|
1898
1971
|
font-weight: 500;
|
|
1899
1972
|
cursor: pointer;
|
|
1900
1973
|
transition: all 0.15s;
|
|
1901
1974
|
}
|
|
1902
|
-
#nexa-dev-overlay .nexa-btn:hover { background: rgba(53, 80, 122, 0.24); color: ${
|
|
1903
|
-
#nexa-dev-overlay .nexa-btn-retry { background: ${
|
|
1904
|
-
#nexa-dev-overlay .nexa-btn-retry:hover { background: ${
|
|
1905
|
-
#nexa-dev-overlay .nexa-btn-copy { background: ${
|
|
1906
|
-
#nexa-dev-overlay .nexa-btn-copy:hover { background: ${
|
|
1975
|
+
#nexa-dev-overlay .nexa-btn:hover { background: rgba(53, 80, 122, 0.24); color: ${G.text}; }
|
|
1976
|
+
#nexa-dev-overlay .nexa-btn-retry { background: ${G.successBg}; border-color: transparent; color: ${G.success}; }
|
|
1977
|
+
#nexa-dev-overlay .nexa-btn-retry:hover { background: ${G.success}; color: #052e26; }
|
|
1978
|
+
#nexa-dev-overlay .nexa-btn-copy { background: ${G.accentSoft}; border-color: transparent; color: ${G.accent}; }
|
|
1979
|
+
#nexa-dev-overlay .nexa-btn-copy:hover { background: ${G.accent}; color: #ffffff; }
|
|
1907
1980
|
#nexa-dev-overlay .nexa-card {
|
|
1908
|
-
background: ${
|
|
1909
|
-
border: 1px solid ${
|
|
1981
|
+
background: ${G.bgSurface};
|
|
1982
|
+
border: 1px solid ${G.border};
|
|
1910
1983
|
border-radius: 12px;
|
|
1911
1984
|
padding: 16px;
|
|
1912
1985
|
margin-bottom: 12px;
|
|
@@ -1914,7 +1987,7 @@ var q = class {
|
|
|
1914
1987
|
#nexa-dev-overlay .nexa-card h3 {
|
|
1915
1988
|
font-size: 12px;
|
|
1916
1989
|
font-weight: 600;
|
|
1917
|
-
color: ${
|
|
1990
|
+
color: ${G.textDim};
|
|
1918
1991
|
text-transform: uppercase;
|
|
1919
1992
|
letter-spacing: 0.05em;
|
|
1920
1993
|
margin-bottom: 12px;
|
|
@@ -1924,11 +1997,11 @@ var q = class {
|
|
|
1924
1997
|
bottom: 24px;
|
|
1925
1998
|
left: 50%;
|
|
1926
1999
|
transform: translateX(-50%) translateY(20px);
|
|
1927
|
-
background: ${
|
|
1928
|
-
color: ${
|
|
2000
|
+
background: ${G.bgElevated};
|
|
2001
|
+
color: ${G.text};
|
|
1929
2002
|
padding: 10px 18px;
|
|
1930
2003
|
border-radius: 12px;
|
|
1931
|
-
border: 1px solid ${
|
|
2004
|
+
border: 1px solid ${G.borderFocus};
|
|
1932
2005
|
font-size: 13px;
|
|
1933
2006
|
font-weight: 500;
|
|
1934
2007
|
box-shadow: 0 12px 32px rgba(0,0,0,0.4);
|
|
@@ -1947,20 +2020,20 @@ var q = class {
|
|
|
1947
2020
|
align-items: center;
|
|
1948
2021
|
padding: 6px 0;
|
|
1949
2022
|
font-size: 13px;
|
|
1950
|
-
border-bottom: 1px solid ${
|
|
2023
|
+
border-bottom: 1px solid ${G.border};
|
|
1951
2024
|
}
|
|
1952
2025
|
#nexa-dev-overlay .nexa-row:last-child { border-bottom: none; }
|
|
1953
|
-
#nexa-dev-overlay .nexa-row span { color: ${
|
|
1954
|
-
#nexa-dev-overlay .nexa-row strong { color: ${
|
|
1955
|
-
#nexa-dev-overlay .nexa-row .nexa-ok { color: ${
|
|
1956
|
-
#nexa-dev-overlay .nexa-row .nexa-err { color: ${
|
|
2026
|
+
#nexa-dev-overlay .nexa-row span { color: ${G.textMuted}; }
|
|
2027
|
+
#nexa-dev-overlay .nexa-row strong { color: ${G.text}; font-weight: 500; font-variant-numeric: tabular-nums; }
|
|
2028
|
+
#nexa-dev-overlay .nexa-row .nexa-ok { color: ${G.success}; }
|
|
2029
|
+
#nexa-dev-overlay .nexa-row .nexa-err { color: ${G.error}; }
|
|
1957
2030
|
#nexa-dev-overlay .nexa-code {
|
|
1958
|
-
background: ${
|
|
2031
|
+
background: ${G.bg};
|
|
1959
2032
|
border-radius: 8px;
|
|
1960
2033
|
padding: 12px;
|
|
1961
2034
|
font-size: 11px;
|
|
1962
2035
|
font-family: 'JetBrains Mono', 'Fira Code', monospace;
|
|
1963
|
-
color: ${
|
|
2036
|
+
color: ${G.textMuted};
|
|
1964
2037
|
overflow-x: auto;
|
|
1965
2038
|
white-space: pre;
|
|
1966
2039
|
max-height: 200px;
|
|
@@ -1969,7 +2042,7 @@ var q = class {
|
|
|
1969
2042
|
#nexa-dev-overlay .nexa-url-full {
|
|
1970
2043
|
font-size: 12px;
|
|
1971
2044
|
word-break: break-all;
|
|
1972
|
-
color: ${
|
|
2045
|
+
color: ${G.accent};
|
|
1973
2046
|
}
|
|
1974
2047
|
#nexa-dev-overlay .nexa-metrics-content {
|
|
1975
2048
|
padding: 16px;
|
|
@@ -1989,14 +2062,14 @@ var q = class {
|
|
|
1989
2062
|
gap: 12px;
|
|
1990
2063
|
padding: 16px;
|
|
1991
2064
|
border-radius: 12px;
|
|
1992
|
-
background: ${
|
|
1993
|
-
border: 1px solid ${
|
|
2065
|
+
background: ${G.bgElevated};
|
|
2066
|
+
border: 1px solid ${G.border};
|
|
1994
2067
|
box-shadow: 0 28px 60px -24px rgba(2, 6, 23, 0.76);
|
|
1995
2068
|
overflow: auto;
|
|
1996
2069
|
}
|
|
1997
2070
|
#nexa-dev-overlay .nexa-settings-row { display:flex;align-items:center;gap:8px;margin-bottom:8px }
|
|
1998
|
-
#nexa-dev-overlay .nexa-settings-row label{font-size:13px;color:${
|
|
1999
|
-
#nexa-dev-overlay .nexa-settings-row select{padding:6px 8px;border-radius:8px;border:1px solid ${
|
|
2071
|
+
#nexa-dev-overlay .nexa-settings-row label{font-size:13px;color:${G.textDim};min-width:70px}
|
|
2072
|
+
#nexa-dev-overlay .nexa-settings-row select{padding:6px 8px;border-radius:8px;border:1px solid ${G.border};background:${G.bg};color:${G.text}}
|
|
2000
2073
|
|
|
2001
2074
|
#nexa-dev-overlay.nexa-theme-light {
|
|
2002
2075
|
background: #f8fbff;
|
|
@@ -2095,7 +2168,9 @@ var q = class {
|
|
|
2095
2168
|
display: none !important;
|
|
2096
2169
|
}
|
|
2097
2170
|
`;
|
|
2098
|
-
|
|
2171
|
+
//#endregion
|
|
2172
|
+
//#region src/dev-overlay/env.ts
|
|
2173
|
+
function K() {
|
|
2099
2174
|
try {
|
|
2100
2175
|
if (typeof process < "u") {
|
|
2101
2176
|
let e = process;
|
|
@@ -2110,7 +2185,114 @@ function X() {
|
|
|
2110
2185
|
} catch {}
|
|
2111
2186
|
return !1;
|
|
2112
2187
|
}
|
|
2113
|
-
|
|
2188
|
+
//#endregion
|
|
2189
|
+
//#region src/dev-overlay/format.ts
|
|
2190
|
+
function q(e) {
|
|
2191
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2192
|
+
}
|
|
2193
|
+
function J(e, t = 35) {
|
|
2194
|
+
try {
|
|
2195
|
+
let t = new URL(e);
|
|
2196
|
+
return t.pathname + (t.search || "");
|
|
2197
|
+
} catch {
|
|
2198
|
+
return e.length > t ? e.slice(0, t) + "..." : e;
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
function Y(e) {
|
|
2202
|
+
try {
|
|
2203
|
+
return JSON.stringify(e, null, 2);
|
|
2204
|
+
} catch {
|
|
2205
|
+
return String(e);
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
//#endregion
|
|
2209
|
+
//#region src/dev-overlay/render.ts
|
|
2210
|
+
function ke(e, t, n) {
|
|
2211
|
+
let r = e;
|
|
2212
|
+
return t === "err" ? r = r.filter((e) => !e.ok) : t === "xhr" ? r = r.filter((e) => e.headers["content-type"] && e.headers["content-type"].includes("json") || e.responseHeaders && e.responseHeaders["content-type"] && e.responseHeaders["content-type"].includes("json")) : t === "slow" && (r = r.filter((e) => e.duration > 500)), n && (r = r.filter((e) => e.url.toLowerCase().includes(n) || e.method.toLowerCase().includes(n) || String(e.status).includes(n))), r;
|
|
2213
|
+
}
|
|
2214
|
+
function X(e, t) {
|
|
2215
|
+
return e.length === 0 ? `
|
|
2216
|
+
<div class="nexa-empty">
|
|
2217
|
+
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
2218
|
+
<circle cx="12" cy="12" r="10"/><path d="M8 12h8M12 8v8"/>
|
|
2219
|
+
</svg>
|
|
2220
|
+
<p>${t ? "No matching requests" : "No requests yet"}</p>
|
|
2221
|
+
<span>${t ? "Try a different search term" : "Make a request to see it here"}</span>
|
|
2222
|
+
</div>` : e.map((e, t) => `
|
|
2223
|
+
<div class="nexa-request-item" data-id="${e.id}" style="animation-delay: ${Math.min(t * 20, 300)}ms">
|
|
2224
|
+
<div class="nexa-req-left">
|
|
2225
|
+
<span class="nexa-method nexa-method-${e.method.toLowerCase()}">${e.method}</span>
|
|
2226
|
+
<span class="nexa-status ${e.ok ? "nexa-ok" : "nexa-err"}">${e.status || "ERR"}</span>
|
|
2227
|
+
<span class="nexa-url" title="${q(e.url)}">${q(J(e.url))}</span>
|
|
2228
|
+
</div>
|
|
2229
|
+
<div class="nexa-req-right">
|
|
2230
|
+
${e.cached ? "<span class=\"nexa-badge nexa-badge-cache\">Cache</span>" : ""}
|
|
2231
|
+
${e.retryCount > 0 ? `<span class="nexa-badge nexa-badge-retry">${e.retryCount}R</span>` : ""}
|
|
2232
|
+
<span class="nexa-duration ${e.duration > 500 ? "nexa-slow" : ""}">${e.duration.toFixed(0)}ms</span>
|
|
2233
|
+
${W.chevron}
|
|
2234
|
+
</div>
|
|
2235
|
+
</div>
|
|
2236
|
+
`).join("");
|
|
2237
|
+
}
|
|
2238
|
+
function Ae(e) {
|
|
2239
|
+
let t = e.totalRequests > 0 ? (e.successfulRequests / e.totalRequests * 100).toFixed(1) : "0";
|
|
2240
|
+
return `
|
|
2241
|
+
<div class="nexa-card">
|
|
2242
|
+
<h3>Overview</h3>
|
|
2243
|
+
<div class="nexa-row"><span>Total Requests</span><strong>${e.totalRequests}</strong></div>
|
|
2244
|
+
<div class="nexa-row"><span>Successful</span><strong class="nexa-ok">${e.successfulRequests}</strong></div>
|
|
2245
|
+
<div class="nexa-row"><span>Failed</span><strong class="nexa-err">${e.failedRequests}</strong></div>
|
|
2246
|
+
<div class="nexa-row"><span>Cached</span><strong>${e.cachedRequests}</strong></div>
|
|
2247
|
+
<div class="nexa-row"><span>Success Rate</span><strong>${t}%</strong></div>
|
|
2248
|
+
</div>
|
|
2249
|
+
<div class="nexa-card">
|
|
2250
|
+
<h3>Performance</h3>
|
|
2251
|
+
<div class="nexa-row"><span>Average</span><strong>${e.avgDuration.toFixed(1)}ms</strong></div>
|
|
2252
|
+
<div class="nexa-row"><span>Fastest</span><strong class="nexa-ok">${e.minDuration.toFixed(1)}ms</strong></div>
|
|
2253
|
+
<div class="nexa-row"><span>Slowest</span><strong class="nexa-err">${e.maxDuration.toFixed(1)}ms</strong></div>
|
|
2254
|
+
<div class="nexa-row"><span>Throughput</span><strong>${e.requestsPerSecond.toFixed(2)} req/s</strong></div>
|
|
2255
|
+
</div>
|
|
2256
|
+
${e.slowestRequests.length > 0 ? `
|
|
2257
|
+
<div class="nexa-card">
|
|
2258
|
+
<h3>Slowest Requests</h3>
|
|
2259
|
+
${e.slowestRequests.map((e) => `
|
|
2260
|
+
<div class="nexa-row nexa-slow-req">
|
|
2261
|
+
<span><span class="nexa-method nexa-method-${e.method.toLowerCase()}" style="font-size:10px;padding:2px 5px;">${e.method}</span> ${q(J(e.url, 25))}</span>
|
|
2262
|
+
<strong class="nexa-err">${e.duration.toFixed(0)}ms</strong>
|
|
2263
|
+
</div>
|
|
2264
|
+
`).join("")}
|
|
2265
|
+
</div>
|
|
2266
|
+
` : ""}`;
|
|
2267
|
+
}
|
|
2268
|
+
function je(e) {
|
|
2269
|
+
return `
|
|
2270
|
+
<div class="nexa-card">
|
|
2271
|
+
<h3>Request</h3>
|
|
2272
|
+
<div class="nexa-row"><span>Method</span><strong style="color:${e.method === "GET" ? G.get : e.method === "POST" ? G.post : e.method === "DELETE" ? G.delete : G.warning}">${e.method}</strong></div>
|
|
2273
|
+
<div class="nexa-row"><span>URL</span><span class="nexa-url-full">${q(e.url)}</span></div>
|
|
2274
|
+
<div class="nexa-row"><span>Status</span><strong class="${e.ok ? "nexa-ok" : "nexa-err"}">${e.status || "N/A"}</strong></div>
|
|
2275
|
+
<div class="nexa-row"><span>Duration</span><strong>${e.duration.toFixed(1)}ms</strong></div>
|
|
2276
|
+
<div class="nexa-row"><span>Cached</span><strong>${e.cached ? "Yes" : "No"}</strong></div>
|
|
2277
|
+
<div class="nexa-row"><span>Retries</span><strong>${e.retryCount}</strong></div>
|
|
2278
|
+
<div class="nexa-row"><span>Timestamp</span><strong>${new Date(e.timestamp).toLocaleTimeString()}</strong></div>
|
|
2279
|
+
</div>
|
|
2280
|
+
${e.body === void 0 ? "" : `
|
|
2281
|
+
<div class="nexa-card">
|
|
2282
|
+
<h3>Request Body</h3>
|
|
2283
|
+
<pre class="nexa-code">${q(Y(e.body))}</pre>
|
|
2284
|
+
</div>
|
|
2285
|
+
`}
|
|
2286
|
+
${Object.keys(e.headers).length > 0 ? `
|
|
2287
|
+
<div class="nexa-card">
|
|
2288
|
+
<h3>Headers</h3>
|
|
2289
|
+
<pre class="nexa-code">${q(Y(e.headers))}</pre>
|
|
2290
|
+
</div>
|
|
2291
|
+
` : ""}`;
|
|
2292
|
+
}
|
|
2293
|
+
//#endregion
|
|
2294
|
+
//#region src/dev-overlay/overlay.ts
|
|
2295
|
+
var Me = class {
|
|
2114
2296
|
panel = null;
|
|
2115
2297
|
floatingIcon = null;
|
|
2116
2298
|
tracker;
|
|
@@ -2133,7 +2315,7 @@ var we = class {
|
|
|
2133
2315
|
hide() {
|
|
2134
2316
|
this.panel && (this.panel.style.transition = "all 0.15s ease-out", this.panel.style.opacity = "0", this.panel.style.transform = "scale(0.96) translateY(8px)", setTimeout(() => {
|
|
2135
2317
|
this.panel && (this.panel.style.display = "none");
|
|
2136
|
-
}, 150), this.visible = !1, this.config.enabled && (!this.config.devOnly ||
|
|
2318
|
+
}, 150), this.visible = !1, this.config.enabled && (!this.config.devOnly || K()) && this.showFloatingIcon());
|
|
2137
2319
|
}
|
|
2138
2320
|
toggle() {
|
|
2139
2321
|
this.visible ? this.hide() : this.show();
|
|
@@ -2172,7 +2354,7 @@ var we = class {
|
|
|
2172
2354
|
display: flex;
|
|
2173
2355
|
flex-direction: column;
|
|
2174
2356
|
overflow: hidden;
|
|
2175
|
-
`, this.panel.innerHTML = `<style>${
|
|
2357
|
+
`, this.panel.innerHTML = `<style>${Oe}</style>
|
|
2176
2358
|
|
|
2177
2359
|
<div class="nexa-header">
|
|
2178
2360
|
<div class="nexa-header-left">
|
|
@@ -2182,10 +2364,10 @@ var we = class {
|
|
|
2182
2364
|
<span class="nexa-title">${i}</span>
|
|
2183
2365
|
</div>
|
|
2184
2366
|
<div class="nexa-header-actions">
|
|
2185
|
-
<button class="nexa-icon-btn nexa-btn-export" title="Export history (JSON)">${
|
|
2186
|
-
<button class="nexa-icon-btn nexa-btn-settings" title="Settings">${
|
|
2187
|
-
<button class="nexa-icon-btn nexa-btn-clear" title="Clear history">${
|
|
2188
|
-
<button class="nexa-icon-btn nexa-btn-close" title="Close (Esc)">${
|
|
2367
|
+
<button class="nexa-icon-btn nexa-btn-export" title="Export history (JSON)">${W.download}</button>
|
|
2368
|
+
<button class="nexa-icon-btn nexa-btn-settings" title="Settings">${W.gear}</button>
|
|
2369
|
+
<button class="nexa-icon-btn nexa-btn-clear" title="Clear history">${W.clear}</button>
|
|
2370
|
+
<button class="nexa-icon-btn nexa-btn-close" title="Close (Esc)">${W.close}</button>
|
|
2189
2371
|
</div>
|
|
2190
2372
|
</div>
|
|
2191
2373
|
|
|
@@ -2223,7 +2405,7 @@ var we = class {
|
|
|
2223
2405
|
</div>
|
|
2224
2406
|
|
|
2225
2407
|
<div class="nexa-search">
|
|
2226
|
-
<span class="nexa-search-icon">${
|
|
2408
|
+
<span class="nexa-search-icon">${W.search}</span>
|
|
2227
2409
|
<input type="text" class="nexa-search-input" placeholder="Filter by URL, method, or status..." />
|
|
2228
2410
|
</div>
|
|
2229
2411
|
|
|
@@ -2246,17 +2428,17 @@ var we = class {
|
|
|
2246
2428
|
|
|
2247
2429
|
<div class="nexa-detail" style="display:none">
|
|
2248
2430
|
<div class="nexa-detail-header">
|
|
2249
|
-
<button class="nexa-btn nexa-btn-back">${
|
|
2431
|
+
<button class="nexa-btn nexa-btn-back">${W.back} Back</button>
|
|
2250
2432
|
<div class="nexa-btn-group">
|
|
2251
|
-
<button class="nexa-btn nexa-btn-copy">${
|
|
2252
|
-
<button class="nexa-btn nexa-btn-retry">${
|
|
2433
|
+
<button class="nexa-btn nexa-btn-copy">${W.copy} Copy as fetch</button>
|
|
2434
|
+
<button class="nexa-btn nexa-btn-retry">${W.retry} Retry</button>
|
|
2253
2435
|
</div>
|
|
2254
2436
|
</div>
|
|
2255
2437
|
<div class="nexa-detail-body"></div>
|
|
2256
2438
|
</div>
|
|
2257
2439
|
`, document.body.appendChild(this.panel), this.config.theme === "light" ? this.panel.classList.add("nexa-theme-light") : this.panel.classList.remove("nexa-theme-light"), this.bindEvents(), this.removeTrackerListener = this.tracker.onChange(() => this.render());
|
|
2258
|
-
let o = !this.config.devOnly ||
|
|
2259
|
-
this.config.enabled && o && this.createFloatingIcon(), this.hide(), this.globalKeyboardHandler = (e) => {
|
|
2440
|
+
let o = !this.config.devOnly || K();
|
|
2441
|
+
this.config.enabled && o && this.createFloatingIcon(), this.updateHeaderActionsVisibility(), this.hide(), this.globalKeyboardHandler = (e) => {
|
|
2260
2442
|
if (e.key === "Escape" && this.visible) {
|
|
2261
2443
|
this.hide();
|
|
2262
2444
|
return;
|
|
@@ -2303,38 +2485,17 @@ var we = class {
|
|
|
2303
2485
|
}
|
|
2304
2486
|
renderMetricsBar() {
|
|
2305
2487
|
let e = this.tracker.getMetrics(), t = this.panel;
|
|
2306
|
-
t && (t.querySelector("[data-metric=\"total\"]").textContent = String(e.totalRequests), t.querySelector("[data-metric=\"avg\"]").textContent = `${e.avgDuration.toFixed(0)}ms`, t.querySelector("[data-metric=\"rate\"]").textContent = `${e.requestsPerSecond.toFixed(1)}`, t.querySelector("[data-metric=\"success\"]").textContent = String(e.successfulRequests), t.querySelector("[data-metric=\"fail\"]").textContent = String(e.failedRequests), t.querySelector("[data-count=\"requests\"]").textContent = String(e.totalRequests));
|
|
2488
|
+
t && (t.querySelector("[data-metric=\"total\"]").textContent = String(e.totalRequests), t.querySelector("[data-metric=\"avg\"]").textContent = `${e.avgDuration.toFixed(0)}ms`, t.querySelector("[data-metric=\"rate\"]").textContent = `${e.requestsPerSecond.toFixed(1)}`, t.querySelector("[data-metric=\"success\"]").textContent = String(e.successfulRequests), t.querySelector("[data-metric=\"fail\"]").textContent = String(e.failedRequests), t.querySelector("[data-count=\"requests\"]").textContent = String(e.totalRequests), this.updateHeaderActionsVisibility());
|
|
2489
|
+
}
|
|
2490
|
+
updateHeaderActionsVisibility() {
|
|
2491
|
+
let e = this.tracker.getHistory().length > 0, t = this.panel?.querySelector(".nexa-btn-export"), n = this.panel?.querySelector(".nexa-btn-clear");
|
|
2492
|
+
t && (t.style.display = e ? "flex" : "none"), n && (n.style.display = e ? "flex" : "none");
|
|
2307
2493
|
}
|
|
2308
2494
|
renderRequestList() {
|
|
2309
2495
|
let e = this.panel?.querySelector(".nexa-request-list");
|
|
2310
2496
|
if (!e) return;
|
|
2311
|
-
let t = this.tracker.getHistory();
|
|
2312
|
-
|
|
2313
|
-
e.innerHTML = `
|
|
2314
|
-
<div class="nexa-empty">
|
|
2315
|
-
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
2316
|
-
<circle cx="12" cy="12" r="10"/><path d="M8 12h8M12 8v8"/>
|
|
2317
|
-
</svg>
|
|
2318
|
-
<p>${this.searchQuery ? "No matching requests" : "No requests yet"}</p>
|
|
2319
|
-
<span>${this.searchQuery ? "Try a different search term" : "Make a request to see it here"}</span>
|
|
2320
|
-
</div>`;
|
|
2321
|
-
return;
|
|
2322
|
-
}
|
|
2323
|
-
e.innerHTML = t.map((e, t) => `
|
|
2324
|
-
<div class="nexa-request-item" data-id="${e.id}" style="animation-delay: ${Math.min(t * 20, 300)}ms">
|
|
2325
|
-
<div class="nexa-req-left">
|
|
2326
|
-
<span class="nexa-method nexa-method-${e.method.toLowerCase()}">${e.method}</span>
|
|
2327
|
-
<span class="nexa-status ${e.ok ? "nexa-ok" : "nexa-err"}">${e.status || "ERR"}</span>
|
|
2328
|
-
<span class="nexa-url" title="${e.url}">${this.truncateUrl(e.url)}</span>
|
|
2329
|
-
</div>
|
|
2330
|
-
<div class="nexa-req-right">
|
|
2331
|
-
${e.cached ? "<span class=\"nexa-badge nexa-badge-cache\">Cache</span>" : ""}
|
|
2332
|
-
${e.retryCount > 0 ? `<span class="nexa-badge nexa-badge-retry">${e.retryCount}R</span>` : ""}
|
|
2333
|
-
<span class="nexa-duration ${e.duration > 500 ? "nexa-slow" : ""}">${e.duration.toFixed(0)}ms</span>
|
|
2334
|
-
${J.chevron}
|
|
2335
|
-
</div>
|
|
2336
|
-
</div>
|
|
2337
|
-
`).join(""), e.querySelectorAll(".nexa-request-item").forEach((e) => {
|
|
2497
|
+
let t = ke(this.tracker.getHistory(), this.filterType, this.searchQuery);
|
|
2498
|
+
e.innerHTML = X(t, this.searchQuery), e.querySelectorAll(".nexa-request-item").forEach((e) => {
|
|
2338
2499
|
e.addEventListener("click", () => {
|
|
2339
2500
|
let n = e.dataset.id, r = t.find((e) => e.id === n);
|
|
2340
2501
|
r && this.showDetail(r);
|
|
@@ -2342,63 +2503,13 @@ var we = class {
|
|
|
2342
2503
|
});
|
|
2343
2504
|
}
|
|
2344
2505
|
renderMetrics() {
|
|
2345
|
-
let e = this.
|
|
2346
|
-
|
|
2347
|
-
let n = e.totalRequests > 0 ? (e.successfulRequests / e.totalRequests * 100).toFixed(1) : "0";
|
|
2348
|
-
t.innerHTML = `
|
|
2349
|
-
<div class="nexa-card">
|
|
2350
|
-
<h3>Overview</h3>
|
|
2351
|
-
<div class="nexa-row"><span>Total Requests</span><strong>${e.totalRequests}</strong></div>
|
|
2352
|
-
<div class="nexa-row"><span>Successful</span><strong class="nexa-ok">${e.successfulRequests}</strong></div>
|
|
2353
|
-
<div class="nexa-row"><span>Failed</span><strong class="nexa-err">${e.failedRequests}</strong></div>
|
|
2354
|
-
<div class="nexa-row"><span>Cached</span><strong>${e.cachedRequests}</strong></div>
|
|
2355
|
-
<div class="nexa-row"><span>Success Rate</span><strong>${n}%</strong></div>
|
|
2356
|
-
</div>
|
|
2357
|
-
<div class="nexa-card">
|
|
2358
|
-
<h3>Performance</h3>
|
|
2359
|
-
<div class="nexa-row"><span>Average</span><strong>${e.avgDuration.toFixed(1)}ms</strong></div>
|
|
2360
|
-
<div class="nexa-row"><span>Fastest</span><strong class="nexa-ok">${e.minDuration.toFixed(1)}ms</strong></div>
|
|
2361
|
-
<div class="nexa-row"><span>Slowest</span><strong class="nexa-err">${e.maxDuration.toFixed(1)}ms</strong></div>
|
|
2362
|
-
<div class="nexa-row"><span>Throughput</span><strong>${e.requestsPerSecond.toFixed(2)} req/s</strong></div>
|
|
2363
|
-
</div>
|
|
2364
|
-
${e.slowestRequests.length > 0 ? `
|
|
2365
|
-
<div class="nexa-card">
|
|
2366
|
-
<h3>Slowest Requests</h3>
|
|
2367
|
-
${e.slowestRequests.map((e) => `
|
|
2368
|
-
<div class="nexa-row nexa-slow-req">
|
|
2369
|
-
<span><span class="nexa-method nexa-method-${e.method.toLowerCase()}" style="font-size:10px;padding:2px 5px;">${e.method}</span> ${this.truncateUrl(e.url, 25)}</span>
|
|
2370
|
-
<strong class="nexa-err">${e.duration.toFixed(0)}ms</strong>
|
|
2371
|
-
</div>
|
|
2372
|
-
`).join("")}
|
|
2373
|
-
</div>
|
|
2374
|
-
` : ""}`;
|
|
2506
|
+
let e = this.panel?.querySelector(".nexa-metrics-content");
|
|
2507
|
+
e && (e.innerHTML = Ae(this.tracker.getMetrics()));
|
|
2375
2508
|
}
|
|
2376
2509
|
showDetail(e) {
|
|
2377
2510
|
if (this.selectedRequest = e, !this.panel) return;
|
|
2378
2511
|
let t = this.panel.querySelector(".nexa-body"), n = this.panel.querySelector(".nexa-detail"), r = this.panel.querySelector(".nexa-detail-body");
|
|
2379
|
-
!t || !n || !r || (this.panel.classList.add("nexa-view-detail"), t.style.display = "none", n.style.display = "flex", r.innerHTML =
|
|
2380
|
-
<div class="nexa-card">
|
|
2381
|
-
<h3>Request</h3>
|
|
2382
|
-
<div class="nexa-row"><span>Method</span><strong style="color:${e.method === "GET" ? Y.get : e.method === "POST" ? Y.post : e.method === "DELETE" ? Y.delete : Y.warning}">${e.method}</strong></div>
|
|
2383
|
-
<div class="nexa-row"><span>URL</span><span class="nexa-url-full">${e.url}</span></div>
|
|
2384
|
-
<div class="nexa-row"><span>Status</span><strong class="${e.ok ? "nexa-ok" : "nexa-err"}">${e.status || "N/A"}</strong></div>
|
|
2385
|
-
<div class="nexa-row"><span>Duration</span><strong>${e.duration.toFixed(1)}ms</strong></div>
|
|
2386
|
-
<div class="nexa-row"><span>Cached</span><strong>${e.cached ? "Yes" : "No"}</strong></div>
|
|
2387
|
-
<div class="nexa-row"><span>Retries</span><strong>${e.retryCount}</strong></div>
|
|
2388
|
-
<div class="nexa-row"><span>Timestamp</span><strong>${new Date(e.timestamp).toLocaleTimeString()}</strong></div>
|
|
2389
|
-
</div>
|
|
2390
|
-
${e.body === void 0 ? "" : `
|
|
2391
|
-
<div class="nexa-card">
|
|
2392
|
-
<h3>Request Body</h3>
|
|
2393
|
-
<pre class="nexa-code">${this.formatJson(e.body)}</pre>
|
|
2394
|
-
</div>
|
|
2395
|
-
`}
|
|
2396
|
-
${Object.keys(e.headers).length > 0 ? `
|
|
2397
|
-
<div class="nexa-card">
|
|
2398
|
-
<h3>Headers</h3>
|
|
2399
|
-
<pre class="nexa-code">${this.formatJson(e.headers)}</pre>
|
|
2400
|
-
</div>
|
|
2401
|
-
` : ""}`);
|
|
2512
|
+
!t || !n || !r || (this.panel.classList.add("nexa-view-detail"), t.style.display = "none", n.style.display = "flex", r.innerHTML = je(e));
|
|
2402
2513
|
}
|
|
2403
2514
|
showMainView() {
|
|
2404
2515
|
this.panel && this.panel.classList.remove("nexa-view-detail");
|
|
@@ -2407,20 +2518,38 @@ var we = class {
|
|
|
2407
2518
|
}
|
|
2408
2519
|
retrySelected() {
|
|
2409
2520
|
if (!this.selectedRequest) return;
|
|
2410
|
-
let { method: e, url: t, body: n, headers: r } = this.selectedRequest;
|
|
2521
|
+
let { method: e, url: t, body: n, headers: r } = this.selectedRequest, i = performance.now();
|
|
2411
2522
|
fetch(t, {
|
|
2412
2523
|
method: e,
|
|
2413
2524
|
headers: r,
|
|
2414
2525
|
body: n ? JSON.stringify(n) : void 0
|
|
2415
|
-
}).then(
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
duration:
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2526
|
+
}).then((a) => {
|
|
2527
|
+
let o = this.tracker.track({
|
|
2528
|
+
method: e,
|
|
2529
|
+
url: t,
|
|
2530
|
+
status: a.status,
|
|
2531
|
+
duration: performance.now() - i,
|
|
2532
|
+
cached: !1,
|
|
2533
|
+
ok: a.ok,
|
|
2534
|
+
headers: r,
|
|
2535
|
+
body: n,
|
|
2536
|
+
retryCount: 0
|
|
2537
|
+
});
|
|
2538
|
+
this.showDetail(o);
|
|
2539
|
+
}).catch(() => {
|
|
2540
|
+
let a = this.tracker.track({
|
|
2541
|
+
method: e,
|
|
2542
|
+
url: t,
|
|
2543
|
+
duration: performance.now() - i,
|
|
2544
|
+
cached: !1,
|
|
2545
|
+
ok: !1,
|
|
2546
|
+
code: "NETWORK_ERROR",
|
|
2547
|
+
headers: r,
|
|
2548
|
+
body: n,
|
|
2549
|
+
retryCount: 0
|
|
2550
|
+
});
|
|
2551
|
+
this.showDetail(a);
|
|
2552
|
+
});
|
|
2424
2553
|
}
|
|
2425
2554
|
exportHistory() {
|
|
2426
2555
|
let e = this.tracker.getHistory(), t = JSON.stringify(e, null, 2), n = new Blob([t], { type: "application/json" }), r = URL.createObjectURL(n), i = document.createElement("a");
|
|
@@ -2443,21 +2572,6 @@ var we = class {
|
|
|
2443
2572
|
t.classList.remove("nexa-notification-show");
|
|
2444
2573
|
}, 2500));
|
|
2445
2574
|
}
|
|
2446
|
-
truncateUrl(e, t = 35) {
|
|
2447
|
-
try {
|
|
2448
|
-
let t = new URL(e);
|
|
2449
|
-
return t.pathname + (t.search || "");
|
|
2450
|
-
} catch {
|
|
2451
|
-
return e.length > t ? e.slice(0, t) + "..." : e;
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2454
|
-
formatJson(e) {
|
|
2455
|
-
try {
|
|
2456
|
-
return JSON.stringify(e, null, 2);
|
|
2457
|
-
} catch {
|
|
2458
|
-
return String(e);
|
|
2459
|
-
}
|
|
2460
|
-
}
|
|
2461
2575
|
canUseDOM() {
|
|
2462
2576
|
return typeof document < "u" && typeof document.createElement == "function" && !!document.body;
|
|
2463
2577
|
}
|
|
@@ -2512,7 +2626,7 @@ var we = class {
|
|
|
2512
2626
|
let e = this.panel.querySelector(".nexa-logo img"), t = this.panel.querySelector(".nexa-title"), a = this.config.branding || "Nexa DevTools", o = this.config.icon || "https://raw.githubusercontent.com/Berea-Soft/nexa/refs/heads/main/src/assets/faviconNew.png";
|
|
2513
2627
|
e && (e.src = o, e.alt = a), t && (t.textContent = a);
|
|
2514
2628
|
}
|
|
2515
|
-
this.floatingIcon &&= (this.floatingIcon.remove(), null), this.config.enabled && (!this.config.devOnly ||
|
|
2629
|
+
this.floatingIcon &&= (this.floatingIcon.remove(), null), this.config.enabled && (!this.config.devOnly || K()) && this.createFloatingIcon();
|
|
2516
2630
|
}
|
|
2517
2631
|
refreshConfig(e) {
|
|
2518
2632
|
this.applyConfigToUI(e);
|
|
@@ -2530,9 +2644,9 @@ var we = class {
|
|
|
2530
2644
|
branding: "Nexa DevTools",
|
|
2531
2645
|
icon: "https://raw.githubusercontent.com/Berea-Soft/nexa/refs/heads/main/src/assets/faviconNew.png"
|
|
2532
2646
|
};
|
|
2533
|
-
function
|
|
2647
|
+
function Ne(e = {}) {
|
|
2534
2648
|
if (Z && Q) {
|
|
2535
|
-
let t =
|
|
2649
|
+
let t = H(), n = {
|
|
2536
2650
|
...$,
|
|
2537
2651
|
...e,
|
|
2538
2652
|
...t
|
|
@@ -2546,27 +2660,27 @@ function Te(e = {}) {
|
|
|
2546
2660
|
config: r
|
|
2547
2661
|
};
|
|
2548
2662
|
}
|
|
2549
|
-
let t =
|
|
2550
|
-
return Q = new
|
|
2663
|
+
let t = H();
|
|
2664
|
+
return Q = new U({
|
|
2551
2665
|
...$,
|
|
2552
2666
|
...e,
|
|
2553
2667
|
...t
|
|
2554
|
-
}), Z = new
|
|
2668
|
+
}), Z = new Me(Q), {
|
|
2555
2669
|
tracker: Q,
|
|
2556
2670
|
ui: Z,
|
|
2557
2671
|
config: Q.getConfig()
|
|
2558
2672
|
};
|
|
2559
2673
|
}
|
|
2560
|
-
function
|
|
2674
|
+
function Pe() {
|
|
2561
2675
|
return {
|
|
2562
2676
|
tracker: Q,
|
|
2563
2677
|
ui: Z
|
|
2564
2678
|
};
|
|
2565
2679
|
}
|
|
2566
|
-
function
|
|
2680
|
+
function Fe() {
|
|
2567
2681
|
Z?.destroy(), Z = null, Q = null;
|
|
2568
2682
|
}
|
|
2569
2683
|
//#endregion
|
|
2570
|
-
export { d as AggressiveRetry,
|
|
2684
|
+
export { d as AggressiveRetry, fe as CachePlugin, y as CacheStore, p as CircuitBreakerRetry, f as ConservativeRetry, pe as DedupePlugin, D as Defer, t as Err, I as HttpClient, L as HttpError, ue as LoggerPlugin, de as MetricsPlugin, re as MiddlewarePipeline, e as Ok, M as PluginManager, S as RequestDeduplicator, U as RequestTracker, oe as TypedObservable, x as cacheMiddleware, ce as createApiUrl, b as createCacheMiddleware, C as createDedupeMiddleware, Ne as createDevOverlay, ve as createHttpClient, w as createPipeline, l as createProjectionTransformer, Ee as createRealtimePlugin, r as createRequiredFieldsValidator, we as createSSEClient, n as createSchemaValidator, j as createStreamingMiddleware, se as createTypeGuard, ae as createTypedApiClient, T as createTypedRequest, ie as createTypedResponse, E as createUrl, xe as createWebSocketClient, u as createWrapperTransformer, ne as dedupeMiddleware, Fe as destroyDevOverlay, Pe as getDevOverlay, O as handleStream, _e as isHttpError, v as retry, A as streamToFile, le as streamingMiddleware, s as transformCamelToSnake, c as transformFlatten, o as transformSnakeToCamel, i as validatorIsArray, a as validatorIsObject, te as withTimeout };
|
|
2571
2685
|
|
|
2572
2686
|
//# sourceMappingURL=nexa.es.js.map
|