@oxog/devinspector 1.4.1 → 1.5.1
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/CHANGELOG.md +31 -0
- package/dist/chunk-5QIYNQ4C.js +19 -0
- package/dist/chunk-5QIYNQ4C.js.map +1 -0
- package/dist/{chunk-LNBLBFDA.js → chunk-NP2SAIEA.js} +23 -19
- package/dist/chunk-NP2SAIEA.js.map +1 -0
- package/dist/{chunk-KZ4SDSBO.js → chunk-WUYUDBSC.js} +5 -1
- package/dist/chunk-WUYUDBSC.js.map +1 -0
- package/dist/{console-monitor-AVTNZCED.js → console-monitor-AO67CSAK.js} +17 -10
- package/dist/console-monitor-AO67CSAK.js.map +1 -0
- package/dist/devinspector.umd.cjs +772 -491
- package/dist/devinspector.umd.cjs.map +1 -1
- package/dist/devinspector.umd.js +772 -491
- package/dist/devinspector.umd.js.map +1 -1
- package/dist/devinspector.umd.min.cjs +2 -2
- package/dist/devinspector.umd.min.cjs.map +1 -1
- package/dist/devinspector.umd.min.js +2 -2
- package/dist/devinspector.umd.min.js.map +1 -1
- package/dist/{dom-monitor-JHJVZYS4.js → dom-monitor-D6GHCDBP.js} +1 -1
- package/dist/{dom-monitor-JHJVZYS4.js.map → dom-monitor-D6GHCDBP.js.map} +1 -1
- package/dist/{error-monitor-3CRFREH3.js → error-monitor-AVTYBTS7.js} +27 -52
- package/dist/error-monitor-AVTYBTS7.js.map +1 -0
- package/dist/index.cjs +515 -287
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +269 -99
- package/dist/index.js.map +1 -1
- package/dist/{inspector-ui-C7WSILKC.js → inspector-ui-TEAZXDPM.js} +17 -7
- package/dist/inspector-ui-TEAZXDPM.js.map +1 -0
- package/dist/{network-monitor-WNRL2JI7.js → network-monitor-QHVMB5F3.js} +154 -115
- package/dist/network-monitor-QHVMB5F3.js.map +1 -0
- package/dist/{performance-monitor-UKQFA7ZR.js → performance-monitor-ULNHXBYX.js} +8 -6
- package/dist/performance-monitor-ULNHXBYX.js.map +1 -0
- package/dist/{state-monitor-JGJLBAD7.js → state-monitor-UNAVEOGH.js} +1 -1
- package/dist/{state-monitor-JGJLBAD7.js.map → state-monitor-UNAVEOGH.js.map} +1 -1
- package/dist/{storage-monitor-3NPTWRTY.js → storage-monitor-5RCRXYMX.js} +1 -1
- package/dist/{storage-monitor-3NPTWRTY.js.map → storage-monitor-5RCRXYMX.js.map} +1 -1
- package/package.json +9 -3
- package/dist/chunk-KZ4SDSBO.js.map +0 -1
- package/dist/chunk-LNBLBFDA.js.map +0 -1
- package/dist/console-monitor-AVTNZCED.js.map +0 -1
- package/dist/error-monitor-3CRFREH3.js.map +0 -1
- package/dist/inspector-ui-C7WSILKC.js.map +0 -1
- package/dist/network-monitor-WNRL2JI7.js.map +0 -1
- package/dist/performance-monitor-UKQFA7ZR.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,9 @@ function readNodeEnv() {
|
|
|
31
31
|
function defaultEnabled() {
|
|
32
32
|
return readNodeEnv() !== "production";
|
|
33
33
|
}
|
|
34
|
+
function normalizeLimit(value, fallback) {
|
|
35
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.floor(value) : fallback;
|
|
36
|
+
}
|
|
34
37
|
function hasDom() {
|
|
35
38
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
36
39
|
}
|
|
@@ -52,6 +55,27 @@ var init_env = __esm({
|
|
|
52
55
|
}
|
|
53
56
|
});
|
|
54
57
|
|
|
58
|
+
// src/core/patches.ts
|
|
59
|
+
function unwrapRetired(value) {
|
|
60
|
+
let current = value;
|
|
61
|
+
while (current !== null && typeof current === "function" && retired.has(current))
|
|
62
|
+
current = retired.get(current);
|
|
63
|
+
return current;
|
|
64
|
+
}
|
|
65
|
+
function restorePatch(target, key, replacement, original) {
|
|
66
|
+
const record = target;
|
|
67
|
+
if (record[key] === replacement) record[key] = unwrapRetired(original);
|
|
68
|
+
else if (replacement !== null && typeof replacement === "function")
|
|
69
|
+
retired.set(replacement, original);
|
|
70
|
+
}
|
|
71
|
+
var retired;
|
|
72
|
+
var init_patches = __esm({
|
|
73
|
+
"src/core/patches.ts"() {
|
|
74
|
+
"use strict";
|
|
75
|
+
retired = /* @__PURE__ */ new WeakMap();
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
55
79
|
// src/core/utils.ts
|
|
56
80
|
function throttle(func, wait, options = {}) {
|
|
57
81
|
let timeout = null;
|
|
@@ -98,25 +122,29 @@ function generateId() {
|
|
|
98
122
|
}
|
|
99
123
|
function safeStringify(obj, indent) {
|
|
100
124
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
101
|
-
return JSON.stringify(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
125
|
+
return JSON.stringify(
|
|
126
|
+
obj,
|
|
127
|
+
(key, value) => {
|
|
128
|
+
if (typeof value === "object" && value !== null) {
|
|
129
|
+
if (seen.has(value)) {
|
|
130
|
+
return "[Circular]";
|
|
131
|
+
}
|
|
132
|
+
seen.add(value);
|
|
105
133
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
134
|
+
if (typeof value === "function") {
|
|
135
|
+
return value.toString();
|
|
136
|
+
}
|
|
137
|
+
if (value instanceof Error) {
|
|
138
|
+
return {
|
|
139
|
+
name: value.name,
|
|
140
|
+
message: value.message,
|
|
141
|
+
stack: value.stack
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
return value;
|
|
145
|
+
},
|
|
146
|
+
indent
|
|
147
|
+
);
|
|
120
148
|
}
|
|
121
149
|
function getStackTrace(error) {
|
|
122
150
|
const stack = (error || new Error()).stack || "";
|
|
@@ -146,6 +174,7 @@ var MAX_BODY_PREVIEW, FetchInterceptor;
|
|
|
146
174
|
var init_fetch_interceptor = __esm({
|
|
147
175
|
"src/monitors/network/fetch-interceptor.ts"() {
|
|
148
176
|
"use strict";
|
|
177
|
+
init_patches();
|
|
149
178
|
init_utils();
|
|
150
179
|
MAX_BODY_PREVIEW = 64 * 1024;
|
|
151
180
|
FetchInterceptor = class {
|
|
@@ -159,24 +188,24 @@ var init_fetch_interceptor = __esm({
|
|
|
159
188
|
const self = this;
|
|
160
189
|
if (this.installed || typeof this.originalFetch !== "function") return;
|
|
161
190
|
const instrumented = async function(input, init) {
|
|
162
|
-
|
|
191
|
+
if (self.installed !== instrumented)
|
|
192
|
+
return self.originalFetch.apply(this != null ? this : window, [input, init]);
|
|
163
193
|
const id = generateId();
|
|
164
194
|
const startTime = performance.now();
|
|
165
195
|
let url;
|
|
166
196
|
let method;
|
|
167
197
|
let headers = {};
|
|
168
198
|
let body;
|
|
199
|
+
let bodyPreview;
|
|
200
|
+
let stopPreview;
|
|
201
|
+
const previewStopped = new Promise((resolve) => stopPreview = resolve);
|
|
169
202
|
if (typeof Request !== "undefined" && input instanceof Request) {
|
|
170
203
|
url = input.url;
|
|
171
204
|
method = input.method;
|
|
172
205
|
input.headers.forEach((value, key) => {
|
|
173
206
|
headers[key] = value;
|
|
174
207
|
});
|
|
175
|
-
|
|
176
|
-
body = await self.extractBody(input);
|
|
177
|
-
} catch (e) {
|
|
178
|
-
body = "[Body unavailable - request already used]";
|
|
179
|
-
}
|
|
208
|
+
bodyPreview = self.extractBody(input, previewStopped);
|
|
180
209
|
} else {
|
|
181
210
|
url = input.toString();
|
|
182
211
|
method = (init == null ? void 0 : init.method) || "GET";
|
|
@@ -195,39 +224,56 @@ var init_fetch_interceptor = __esm({
|
|
|
195
224
|
}
|
|
196
225
|
body = init == null ? void 0 : init.body;
|
|
197
226
|
}
|
|
198
|
-
|
|
199
|
-
id,
|
|
200
|
-
method,
|
|
201
|
-
url,
|
|
202
|
-
headers,
|
|
203
|
-
body: self.sanitizeBody(body),
|
|
204
|
-
timestamp: Date.now(),
|
|
205
|
-
type: "fetch"
|
|
206
|
-
};
|
|
207
|
-
self.requestMap.set(id, request);
|
|
208
|
-
(_b = (_a = self.handlers).onRequest) == null ? void 0 : _b.call(_a, request);
|
|
209
|
-
let response;
|
|
227
|
+
let pending;
|
|
210
228
|
try {
|
|
211
|
-
|
|
229
|
+
pending = Promise.resolve(self.originalFetch.apply(this != null ? this : window, [input, init]));
|
|
212
230
|
} catch (error) {
|
|
213
|
-
|
|
231
|
+
pending = Promise.reject(error);
|
|
232
|
+
}
|
|
233
|
+
const requestReported = (async () => {
|
|
234
|
+
var _a, _b;
|
|
235
|
+
if (bodyPreview) body = await bodyPreview;
|
|
236
|
+
const request = {
|
|
214
237
|
id,
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
238
|
+
method,
|
|
239
|
+
url,
|
|
240
|
+
headers,
|
|
241
|
+
body: self.sanitizeBody(body),
|
|
242
|
+
timestamp: Date.now(),
|
|
243
|
+
type: "fetch"
|
|
218
244
|
};
|
|
219
|
-
|
|
220
|
-
self.
|
|
245
|
+
self.requestMap.set(id, request);
|
|
246
|
+
(_b = (_a = self.handlers).onRequest) == null ? void 0 : _b.call(_a, request);
|
|
247
|
+
})().catch(() => void 0);
|
|
248
|
+
let response;
|
|
249
|
+
try {
|
|
250
|
+
response = await pending;
|
|
251
|
+
} catch (error) {
|
|
252
|
+
stopPreview();
|
|
253
|
+
void requestReported.then(() => {
|
|
254
|
+
var _a, _b;
|
|
255
|
+
const networkError = {
|
|
256
|
+
id,
|
|
257
|
+
message: (error == null ? void 0 : error.message) || "Network request failed",
|
|
258
|
+
stack: error == null ? void 0 : error.stack,
|
|
259
|
+
timestamp: Date.now()
|
|
260
|
+
};
|
|
261
|
+
try {
|
|
262
|
+
(_b = (_a = self.handlers).onError) == null ? void 0 : _b.call(_a, networkError);
|
|
263
|
+
} catch (e) {
|
|
264
|
+
}
|
|
265
|
+
self.requestMap.delete(id);
|
|
266
|
+
});
|
|
221
267
|
throw error;
|
|
222
268
|
}
|
|
223
269
|
const duration = performance.now() - startTime;
|
|
224
|
-
void self.reportResponse(id, response, duration);
|
|
270
|
+
void self.reportResponse(id, response, duration, requestReported);
|
|
225
271
|
return response;
|
|
226
272
|
};
|
|
227
273
|
this.installed = instrumented;
|
|
228
274
|
window.fetch = instrumented;
|
|
229
275
|
}
|
|
230
|
-
async reportResponse(id, response, duration) {
|
|
276
|
+
async reportResponse(id, response, duration, after) {
|
|
231
277
|
var _a, _b;
|
|
232
278
|
try {
|
|
233
279
|
const responseHeaders = {};
|
|
@@ -240,6 +286,7 @@ var init_fetch_interceptor = __esm({
|
|
|
240
286
|
} catch (e) {
|
|
241
287
|
responseBody = "[Unable to read response]";
|
|
242
288
|
}
|
|
289
|
+
await after;
|
|
243
290
|
(_b = (_a = this.handlers).onResponse) == null ? void 0 : _b.call(_a, {
|
|
244
291
|
id,
|
|
245
292
|
status: response.status,
|
|
@@ -257,26 +304,29 @@ var init_fetch_interceptor = __esm({
|
|
|
257
304
|
}
|
|
258
305
|
}
|
|
259
306
|
uninstall() {
|
|
260
|
-
if (this.installed
|
|
261
|
-
window.fetch = this.originalFetch;
|
|
262
|
-
}
|
|
307
|
+
if (this.installed) restorePatch(window, "fetch", this.installed, this.originalFetch);
|
|
263
308
|
this.installed = null;
|
|
264
309
|
this.requestMap.clear();
|
|
265
310
|
}
|
|
266
|
-
|
|
311
|
+
/**
|
|
312
|
+
* Previews a Request body. Everything up to the clone runs synchronously, so
|
|
313
|
+
* call it before the real fetch takes the body. Only previewable bodies are
|
|
314
|
+
* cloned (an unread clone would buffer the whole upload).
|
|
315
|
+
*/
|
|
316
|
+
async extractBody(request, stop) {
|
|
267
317
|
try {
|
|
268
|
-
const contentType = request.headers.get("content-type") || "";
|
|
269
318
|
if (request.bodyUsed) {
|
|
270
319
|
return "[Body already read]";
|
|
271
320
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
return await this.readPreview(
|
|
279
|
-
}
|
|
321
|
+
if (!request.body) {
|
|
322
|
+
return void 0;
|
|
323
|
+
}
|
|
324
|
+
const contentType = request.headers.get("content-type") || "";
|
|
325
|
+
const asJson = contentType.includes("application/json");
|
|
326
|
+
if (asJson || contentType.includes("text/") || contentType.includes("application/x-www-form-urlencoded")) {
|
|
327
|
+
return await this.readPreview(request.clone(), asJson, stop);
|
|
328
|
+
}
|
|
329
|
+
if (contentType.includes("multipart/form-data")) {
|
|
280
330
|
return "[FormData]";
|
|
281
331
|
}
|
|
282
332
|
return "[Binary data]";
|
|
@@ -285,7 +335,7 @@ var init_fetch_interceptor = __esm({
|
|
|
285
335
|
}
|
|
286
336
|
}
|
|
287
337
|
/** Reads at most MAX_BODY_PREVIEW bytes from a cloned body, then cancels the clone. */
|
|
288
|
-
async readCapped(body) {
|
|
338
|
+
async readCapped(body, stop) {
|
|
289
339
|
const stream = body.body;
|
|
290
340
|
if (!stream || typeof stream.getReader !== "function") {
|
|
291
341
|
const text2 = await body.text();
|
|
@@ -297,18 +347,21 @@ var init_fetch_interceptor = __esm({
|
|
|
297
347
|
let received = 0;
|
|
298
348
|
try {
|
|
299
349
|
for (; ; ) {
|
|
300
|
-
const
|
|
350
|
+
const next = await (stop ? Promise.race([reader.read(), stop.then(() => null)]) : reader.read());
|
|
351
|
+
if (!next) return { text: text + decoder.decode(), truncated: true };
|
|
352
|
+
const { done, value } = next;
|
|
301
353
|
if (done) return { text: text + decoder.decode(), truncated: false };
|
|
302
354
|
received += value.byteLength;
|
|
303
355
|
text += decoder.decode(value, { stream: true });
|
|
304
|
-
if (received >= MAX_BODY_PREVIEW)
|
|
356
|
+
if (received >= MAX_BODY_PREVIEW)
|
|
357
|
+
return { text: text.slice(0, MAX_BODY_PREVIEW), truncated: true };
|
|
305
358
|
}
|
|
306
359
|
} finally {
|
|
307
360
|
reader.cancel().catch(() => void 0);
|
|
308
361
|
}
|
|
309
362
|
}
|
|
310
|
-
async readPreview(body, asJson) {
|
|
311
|
-
const { text, truncated } = await this.readCapped(body);
|
|
363
|
+
async readPreview(body, asJson, stop) {
|
|
364
|
+
const { text, truncated } = await this.readCapped(body, stop);
|
|
312
365
|
if (truncated) return `${text}... [truncated]`;
|
|
313
366
|
if (asJson) {
|
|
314
367
|
try {
|
|
@@ -405,6 +458,7 @@ var XHRInterceptor;
|
|
|
405
458
|
var init_xhr_interceptor = __esm({
|
|
406
459
|
"src/monitors/network/xhr-interceptor.ts"() {
|
|
407
460
|
"use strict";
|
|
461
|
+
init_patches();
|
|
408
462
|
init_utils();
|
|
409
463
|
XHRInterceptor = class {
|
|
410
464
|
constructor(handlers = {}) {
|
|
@@ -417,12 +471,16 @@ var init_xhr_interceptor = __esm({
|
|
|
417
471
|
install() {
|
|
418
472
|
if (this.installed || typeof XMLHttpRequest === "undefined") return;
|
|
419
473
|
const self = this;
|
|
420
|
-
XMLHttpRequest.prototype.open = function(
|
|
474
|
+
XMLHttpRequest.prototype.open = function(...args) {
|
|
475
|
+
var _a;
|
|
476
|
+
const result = self.originalOpen.apply(this, args);
|
|
477
|
+
const [method, url] = args;
|
|
478
|
+
(_a = this._devinspectorCancel) == null ? void 0 : _a.call(this);
|
|
421
479
|
this._devinspectorId = generateId();
|
|
422
480
|
this._devinspectorMethod = method;
|
|
423
481
|
this._devinspectorUrl = url.toString();
|
|
424
482
|
this._devinspectorRequestHeaders = {};
|
|
425
|
-
return
|
|
483
|
+
return result;
|
|
426
484
|
};
|
|
427
485
|
XMLHttpRequest.prototype.setRequestHeader = function(name, value) {
|
|
428
486
|
if (this._devinspectorRequestHeaders) {
|
|
@@ -432,10 +490,15 @@ var init_xhr_interceptor = __esm({
|
|
|
432
490
|
};
|
|
433
491
|
XMLHttpRequest.prototype.send = function(body) {
|
|
434
492
|
var _a, _b;
|
|
435
|
-
|
|
493
|
+
if (!self.installed || this._devinspectorCancel)
|
|
494
|
+
return self.originalSend.apply(this, [body]);
|
|
495
|
+
const xhr = this;
|
|
496
|
+
const id = this._devinspectorId;
|
|
497
|
+
const startTime = performance.now();
|
|
498
|
+
this._devinspectorStartTime = startTime;
|
|
436
499
|
this._devinspectorRequestBody = self.sanitizeBody(body);
|
|
437
500
|
const request = {
|
|
438
|
-
id
|
|
501
|
+
id,
|
|
439
502
|
method: this._devinspectorMethod,
|
|
440
503
|
url: this._devinspectorUrl,
|
|
441
504
|
headers: this._devinspectorRequestHeaders || {},
|
|
@@ -444,38 +507,46 @@ var init_xhr_interceptor = __esm({
|
|
|
444
507
|
type: "xhr"
|
|
445
508
|
};
|
|
446
509
|
(_b = (_a = self.handlers).onRequest) == null ? void 0 : _b.call(_a, request);
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
510
|
+
const listeners = [];
|
|
511
|
+
const listen = (target, type, handler) => {
|
|
512
|
+
target.addEventListener(type, handler);
|
|
513
|
+
listeners.push([target, type, handler]);
|
|
514
|
+
};
|
|
515
|
+
let ended = false;
|
|
516
|
+
const detach = () => {
|
|
517
|
+
ended = true;
|
|
518
|
+
for (const [target, type, handler] of listeners) target.removeEventListener(type, handler);
|
|
519
|
+
listeners.length = 0;
|
|
520
|
+
if (xhr._devinspectorCancel === cancel) xhr._devinspectorCancel = void 0;
|
|
521
|
+
};
|
|
522
|
+
const fail = (message) => {
|
|
523
|
+
var _a2, _b2;
|
|
524
|
+
(_b2 = (_a2 = self.handlers).onError) == null ? void 0 : _b2.call(_a2, { id, message, timestamp: Date.now() });
|
|
525
|
+
};
|
|
526
|
+
const cancel = () => {
|
|
527
|
+
detach();
|
|
528
|
+
fail("Request aborted");
|
|
529
|
+
};
|
|
530
|
+
const onProgress = (event) => {
|
|
531
|
+
var _a2, _b2;
|
|
532
|
+
if (event.lengthComputable) {
|
|
533
|
+
(_b2 = (_a2 = self.handlers).onProgress) == null ? void 0 : _b2.call(_a2, { id, loaded: event.loaded, total: event.total });
|
|
534
|
+
}
|
|
535
|
+
};
|
|
458
536
|
if (self.handlers.onProgress) {
|
|
459
|
-
this.
|
|
460
|
-
|
|
461
|
-
self.handlers.onProgress({
|
|
462
|
-
id: this._devinspectorId,
|
|
463
|
-
loaded: event.loaded,
|
|
464
|
-
total: event.total
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
});
|
|
537
|
+
if (this.upload) listen(this.upload, "progress", onProgress);
|
|
538
|
+
listen(this, "progress", onProgress);
|
|
468
539
|
}
|
|
469
|
-
this
|
|
540
|
+
listen(this, "load", () => {
|
|
470
541
|
var _a2, _b2;
|
|
471
|
-
const duration = performance.now() -
|
|
472
|
-
const responseHeaders = self.parseResponseHeaders(
|
|
473
|
-
const responseBody = self.extractResponseBody(
|
|
542
|
+
const duration = performance.now() - startTime;
|
|
543
|
+
const responseHeaders = self.parseResponseHeaders(xhr.getAllResponseHeaders());
|
|
544
|
+
const responseBody = self.extractResponseBody(xhr);
|
|
474
545
|
const size = self.calculateSize(responseBody, responseHeaders);
|
|
475
546
|
const response = {
|
|
476
|
-
id
|
|
477
|
-
status:
|
|
478
|
-
statusText:
|
|
547
|
+
id,
|
|
548
|
+
status: xhr.status,
|
|
549
|
+
statusText: xhr.statusText,
|
|
479
550
|
headers: responseHeaders,
|
|
480
551
|
body: responseBody,
|
|
481
552
|
size,
|
|
@@ -485,34 +556,20 @@ var init_xhr_interceptor = __esm({
|
|
|
485
556
|
};
|
|
486
557
|
(_b2 = (_a2 = self.handlers).onResponse) == null ? void 0 : _b2.call(_a2, response);
|
|
487
558
|
});
|
|
488
|
-
this
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
timestamp: Date.now()
|
|
503
|
-
};
|
|
504
|
-
(_b2 = (_a2 = self.handlers).onError) == null ? void 0 : _b2.call(_a2, error);
|
|
505
|
-
});
|
|
506
|
-
this.addEventListener("abort", function() {
|
|
507
|
-
var _a2, _b2;
|
|
508
|
-
const error = {
|
|
509
|
-
id: this._devinspectorId,
|
|
510
|
-
message: "Request aborted",
|
|
511
|
-
timestamp: Date.now()
|
|
512
|
-
};
|
|
513
|
-
(_b2 = (_a2 = self.handlers).onError) == null ? void 0 : _b2.call(_a2, error);
|
|
514
|
-
});
|
|
515
|
-
return self.originalSend.apply(this, [body]);
|
|
559
|
+
listen(this, "error", () => fail("Network request failed"));
|
|
560
|
+
listen(this, "timeout", () => fail(`Request timeout after ${xhr.timeout}ms`));
|
|
561
|
+
listen(this, "abort", () => fail("Request aborted"));
|
|
562
|
+
listen(this, "loadend", detach);
|
|
563
|
+
this._devinspectorCancel = cancel;
|
|
564
|
+
try {
|
|
565
|
+
return self.originalSend.apply(this, [body]);
|
|
566
|
+
} catch (error) {
|
|
567
|
+
if (!ended) {
|
|
568
|
+
detach();
|
|
569
|
+
fail(error instanceof Error ? error.message : String(error));
|
|
570
|
+
}
|
|
571
|
+
throw error;
|
|
572
|
+
}
|
|
516
573
|
};
|
|
517
574
|
this.installed = {
|
|
518
575
|
open: XMLHttpRequest.prototype.open,
|
|
@@ -523,9 +580,14 @@ var init_xhr_interceptor = __esm({
|
|
|
523
580
|
uninstall() {
|
|
524
581
|
if (!this.installed) return;
|
|
525
582
|
const proto = XMLHttpRequest.prototype;
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
583
|
+
restorePatch(proto, "open", this.installed.open, this.originalOpen);
|
|
584
|
+
restorePatch(proto, "send", this.installed.send, this.originalSend);
|
|
585
|
+
restorePatch(
|
|
586
|
+
proto,
|
|
587
|
+
"setRequestHeader",
|
|
588
|
+
this.installed.setRequestHeader,
|
|
589
|
+
this.originalSetRequestHeader
|
|
590
|
+
);
|
|
529
591
|
this.installed = null;
|
|
530
592
|
}
|
|
531
593
|
sanitizeBody(body) {
|
|
@@ -624,6 +686,7 @@ var WebSocketMonitor;
|
|
|
624
686
|
var init_websocket_monitor = __esm({
|
|
625
687
|
"src/monitors/network/websocket-monitor.ts"() {
|
|
626
688
|
"use strict";
|
|
689
|
+
init_patches();
|
|
627
690
|
init_utils();
|
|
628
691
|
WebSocketMonitor = class {
|
|
629
692
|
constructor(handlers = {}) {
|
|
@@ -637,8 +700,14 @@ var init_websocket_monitor = __esm({
|
|
|
637
700
|
const OriginalWebSocket = this.originalWebSocket;
|
|
638
701
|
if (typeof OriginalWebSocket !== "function" || this.installed) return;
|
|
639
702
|
const MonitoredWebSocket = function(url, protocols) {
|
|
640
|
-
var _a, _b;
|
|
641
|
-
const
|
|
703
|
+
var _a, _b, _c;
|
|
704
|
+
const args = protocols === void 0 ? [url] : [url, protocols];
|
|
705
|
+
const ws = Reflect.construct(
|
|
706
|
+
OriginalWebSocket,
|
|
707
|
+
args,
|
|
708
|
+
(_a = new.target) != null ? _a : OriginalWebSocket
|
|
709
|
+
);
|
|
710
|
+
if (self.installed !== MonitoredWebSocket) return ws;
|
|
642
711
|
const connectionId = generateId();
|
|
643
712
|
ws._devinspectorId = connectionId;
|
|
644
713
|
ws._devinspectorUrl = url.toString();
|
|
@@ -652,7 +721,7 @@ var init_websocket_monitor = __esm({
|
|
|
652
721
|
status: "connecting"
|
|
653
722
|
};
|
|
654
723
|
self.connections.set(connectionId, connection);
|
|
655
|
-
(
|
|
724
|
+
(_c = (_b = self.handlers).onConnection) == null ? void 0 : _c.call(_b, connection);
|
|
656
725
|
ws.addEventListener("open", function() {
|
|
657
726
|
var _a2, _b2;
|
|
658
727
|
const conn = self.connections.get(connectionId);
|
|
@@ -736,9 +805,7 @@ var init_websocket_monitor = __esm({
|
|
|
736
805
|
window.WebSocket = MonitoredWebSocket;
|
|
737
806
|
}
|
|
738
807
|
uninstall() {
|
|
739
|
-
if (this.installed
|
|
740
|
-
window.WebSocket = this.originalWebSocket;
|
|
741
|
-
}
|
|
808
|
+
if (this.installed) restorePatch(window, "WebSocket", this.installed, this.originalWebSocket);
|
|
742
809
|
this.installed = null;
|
|
743
810
|
this.connections.clear();
|
|
744
811
|
}
|
|
@@ -1014,6 +1081,7 @@ var ConsoleInterceptor;
|
|
|
1014
1081
|
var init_console_interceptor = __esm({
|
|
1015
1082
|
"src/monitors/console/console-interceptor.ts"() {
|
|
1016
1083
|
"use strict";
|
|
1084
|
+
init_patches();
|
|
1017
1085
|
init_utils();
|
|
1018
1086
|
ConsoleInterceptor = class {
|
|
1019
1087
|
constructor(handlers = {}, captureStackTraces = true) {
|
|
@@ -1059,9 +1127,7 @@ var init_console_interceptor = __esm({
|
|
|
1059
1127
|
}
|
|
1060
1128
|
uninstall() {
|
|
1061
1129
|
this.originalMethods.forEach((original, method) => {
|
|
1062
|
-
|
|
1063
|
-
console[method] = original;
|
|
1064
|
-
}
|
|
1130
|
+
restorePatch(console, method, this.wrappers.get(method), original);
|
|
1065
1131
|
});
|
|
1066
1132
|
this.originalMethods.clear();
|
|
1067
1133
|
this.wrappers.clear();
|
|
@@ -1429,7 +1495,10 @@ var init_log_formatter = __esm({
|
|
|
1429
1495
|
"default"
|
|
1430
1496
|
];
|
|
1431
1497
|
let highlighted = code;
|
|
1432
|
-
highlighted = highlighted.replace(
|
|
1498
|
+
highlighted = highlighted.replace(
|
|
1499
|
+
/(["'`])(?:(?=(\\?))\2.)*?\1/g,
|
|
1500
|
+
'<span class="string">$&</span>'
|
|
1501
|
+
);
|
|
1433
1502
|
highlighted = highlighted.replace(/\b(\d+)\b/g, '<span class="number">$1</span>');
|
|
1434
1503
|
keywords.forEach((keyword) => {
|
|
1435
1504
|
const regex = new RegExp(`\\b${keyword}\\b`, "g");
|
|
@@ -1461,10 +1530,13 @@ var init_console_monitor = __esm({
|
|
|
1461
1530
|
this.historyIndex = -1;
|
|
1462
1531
|
this.inspector = inspector;
|
|
1463
1532
|
this.formatter = new LogFormatter();
|
|
1464
|
-
this.interceptor = new ConsoleInterceptor(
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1533
|
+
this.interceptor = new ConsoleInterceptor(
|
|
1534
|
+
{
|
|
1535
|
+
onLog: this.handleLog.bind(this),
|
|
1536
|
+
onClear: this.handleClear.bind(this)
|
|
1537
|
+
},
|
|
1538
|
+
inspector.getConfig().captureStackTraces
|
|
1539
|
+
);
|
|
1468
1540
|
}
|
|
1469
1541
|
start() {
|
|
1470
1542
|
if (this.isActive) return;
|
|
@@ -1962,10 +2034,12 @@ var init_long_task_detector = __esm({
|
|
|
1962
2034
|
duration: Math.round(deltaTime),
|
|
1963
2035
|
startTime: Math.round(lastTime),
|
|
1964
2036
|
timestamp: Date.now(),
|
|
1965
|
-
attribution: [
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
2037
|
+
attribution: [
|
|
2038
|
+
{
|
|
2039
|
+
name: "unknown",
|
|
2040
|
+
containerType: "window"
|
|
2041
|
+
}
|
|
2042
|
+
]
|
|
1969
2043
|
};
|
|
1970
2044
|
this.callback(task);
|
|
1971
2045
|
}
|
|
@@ -2173,6 +2247,10 @@ var init_performance_monitor = __esm({
|
|
|
2173
2247
|
});
|
|
2174
2248
|
|
|
2175
2249
|
// src/monitors/error/error-tracker.ts
|
|
2250
|
+
function isInstance(value, name) {
|
|
2251
|
+
const ctor = globalThis[name];
|
|
2252
|
+
return typeof ctor !== "function" || value instanceof ctor;
|
|
2253
|
+
}
|
|
2176
2254
|
var ErrorTracker;
|
|
2177
2255
|
var init_error_tracker = __esm({
|
|
2178
2256
|
"src/monitors/error/error-tracker.ts"() {
|
|
@@ -2230,7 +2308,7 @@ var init_error_tracker = __esm({
|
|
|
2230
2308
|
message: error.message,
|
|
2231
2309
|
stack: error.stack
|
|
2232
2310
|
};
|
|
2233
|
-
} else if ("message" in error && error
|
|
2311
|
+
} else if ("message" in error && isInstance(error, "ErrorEvent")) {
|
|
2234
2312
|
message = error.message;
|
|
2235
2313
|
source = error.filename;
|
|
2236
2314
|
lineno = error.lineno;
|
|
@@ -2239,7 +2317,7 @@ var init_error_tracker = __esm({
|
|
|
2239
2317
|
stack = error.error.stack ? error.error.stack.split("\n").map((line) => line.trim()) : [];
|
|
2240
2318
|
errorObject = error.error;
|
|
2241
2319
|
}
|
|
2242
|
-
} else if ("reason" in error && error
|
|
2320
|
+
} else if ("reason" in error && isInstance(error, "PromiseRejectionEvent")) {
|
|
2243
2321
|
const reason = error.reason;
|
|
2244
2322
|
if (reason instanceof Error) {
|
|
2245
2323
|
message = reason.message || reason.toString();
|
|
@@ -2307,10 +2385,7 @@ var init_error_tracker = __esm({
|
|
|
2307
2385
|
return group;
|
|
2308
2386
|
}
|
|
2309
2387
|
generateFingerprint(errorInfo) {
|
|
2310
|
-
const parts = [
|
|
2311
|
-
errorInfo.type,
|
|
2312
|
-
this.normalizeMessage(errorInfo.message)
|
|
2313
|
-
];
|
|
2388
|
+
const parts = [errorInfo.type, this.normalizeMessage(errorInfo.message)];
|
|
2314
2389
|
if (errorInfo.stackFrames && errorInfo.stackFrames.length > 0) {
|
|
2315
2390
|
const topFrame = errorInfo.stackFrames[0];
|
|
2316
2391
|
if (topFrame.fileName) {
|
|
@@ -2400,11 +2475,7 @@ var init_source_map_support = __esm({
|
|
|
2400
2475
|
if (!sourceMapUrl) return frame;
|
|
2401
2476
|
const sourceMap = await this.loadSourceMap(fileUrl, sourceMapUrl);
|
|
2402
2477
|
if (!sourceMap) return frame;
|
|
2403
|
-
const originalPosition = this.getOriginalPosition(
|
|
2404
|
-
sourceMap,
|
|
2405
|
-
lineNumber,
|
|
2406
|
-
columnNumber
|
|
2407
|
-
);
|
|
2478
|
+
const originalPosition = this.getOriginalPosition(sourceMap, lineNumber, columnNumber);
|
|
2408
2479
|
if (originalPosition) {
|
|
2409
2480
|
const functionPart = functionName ? `${functionName} ` : "";
|
|
2410
2481
|
return `at ${functionPart}(${originalPosition.source}:${originalPosition.line}:${originalPosition.column})`;
|
|
@@ -2510,15 +2581,13 @@ var init_error_monitor = __esm({
|
|
|
2510
2581
|
ErrorMonitor = class {
|
|
2511
2582
|
constructor(inspector) {
|
|
2512
2583
|
this.isActive = false;
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
unhandledrejection: null
|
|
2516
|
-
};
|
|
2584
|
+
/** Set while a window error/rejection event is being tracked (vs. trackError()). */
|
|
2585
|
+
this.trackingUncaught = false;
|
|
2517
2586
|
this.handleErrorEvent = (event) => {
|
|
2518
|
-
this.errorTracker.trackError(event, "error");
|
|
2587
|
+
this.trackUncaught(() => this.errorTracker.trackError(event, "error"));
|
|
2519
2588
|
};
|
|
2520
2589
|
this.handleRejectionEvent = (event) => {
|
|
2521
|
-
this.errorTracker.trackError(event, "unhandledRejection");
|
|
2590
|
+
this.trackUncaught(() => this.errorTracker.trackError(event, "unhandledRejection"));
|
|
2522
2591
|
};
|
|
2523
2592
|
this.inspector = inspector;
|
|
2524
2593
|
this.errorTracker = new ErrorTracker(this.handleError.bind(this));
|
|
@@ -2534,42 +2603,28 @@ var init_error_monitor = __esm({
|
|
|
2534
2603
|
this.uninstallErrorHandlers();
|
|
2535
2604
|
this.isActive = false;
|
|
2536
2605
|
}
|
|
2606
|
+
// One subscription per event type: window.onerror / onunhandledrejection are left
|
|
2607
|
+
// to the page (setting them as well reported every error twice and returning true
|
|
2608
|
+
// from onerror hid the error from the browser console).
|
|
2537
2609
|
installErrorHandlers() {
|
|
2538
|
-
this.originalHandlers.error = window.onerror;
|
|
2539
|
-
this.originalHandlers.unhandledrejection = window.onunhandledrejection;
|
|
2540
|
-
window.onerror = (message, source, lineno, colno, error) => {
|
|
2541
|
-
const errorEvent = new ErrorEvent("error", {
|
|
2542
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string -- onerror passes a string or an Event
|
|
2543
|
-
message: String(message),
|
|
2544
|
-
filename: source,
|
|
2545
|
-
lineno,
|
|
2546
|
-
colno,
|
|
2547
|
-
error
|
|
2548
|
-
});
|
|
2549
|
-
this.errorTracker.trackError(errorEvent, "error");
|
|
2550
|
-
if (this.originalHandlers.error) {
|
|
2551
|
-
return this.originalHandlers.error(message, source, lineno, colno, error);
|
|
2552
|
-
}
|
|
2553
|
-
return true;
|
|
2554
|
-
};
|
|
2555
|
-
window.onunhandledrejection = (event) => {
|
|
2556
|
-
this.errorTracker.trackError(event, "unhandledRejection");
|
|
2557
|
-
if (this.originalHandlers.unhandledrejection) {
|
|
2558
|
-
return this.originalHandlers.unhandledrejection(event);
|
|
2559
|
-
}
|
|
2560
|
-
return true;
|
|
2561
|
-
};
|
|
2562
2610
|
window.addEventListener("error", this.handleErrorEvent);
|
|
2563
2611
|
window.addEventListener("unhandledrejection", this.handleRejectionEvent);
|
|
2564
2612
|
}
|
|
2565
2613
|
uninstallErrorHandlers() {
|
|
2566
|
-
window.onerror = this.originalHandlers.error;
|
|
2567
|
-
window.onunhandledrejection = this.originalHandlers.unhandledrejection;
|
|
2568
2614
|
window.removeEventListener("error", this.handleErrorEvent);
|
|
2569
2615
|
window.removeEventListener("unhandledrejection", this.handleRejectionEvent);
|
|
2570
2616
|
}
|
|
2617
|
+
trackUncaught(track) {
|
|
2618
|
+
this.trackingUncaught = true;
|
|
2619
|
+
try {
|
|
2620
|
+
track();
|
|
2621
|
+
} finally {
|
|
2622
|
+
this.trackingUncaught = false;
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2571
2625
|
async handleError(errorInfo) {
|
|
2572
2626
|
var _a, _b;
|
|
2627
|
+
const uncaught = this.trackingUncaught;
|
|
2573
2628
|
if (errorInfo.stack && this.sourceMapSupport.isEnabled()) {
|
|
2574
2629
|
try {
|
|
2575
2630
|
errorInfo.stack = await this.sourceMapSupport.enhanceStackTrace(errorInfo.stack);
|
|
@@ -2579,14 +2634,8 @@ var init_error_monitor = __esm({
|
|
|
2579
2634
|
}
|
|
2580
2635
|
const storage = this.inspector.getStorage("error");
|
|
2581
2636
|
storage.push(errorInfo);
|
|
2582
|
-
this.inspector.getEvents().emit(
|
|
2583
|
-
errorInfo.type === "unhandledRejection" ? "error:uncaught" : "error:caught",
|
|
2584
|
-
errorInfo
|
|
2585
|
-
);
|
|
2637
|
+
this.inspector.getEvents().emit(uncaught ? "error:uncaught" : "error:caught", errorInfo);
|
|
2586
2638
|
(_b = (_a = this.inspector.getConfig()).onError) == null ? void 0 : _b.call(_a, new Error(errorInfo.message));
|
|
2587
|
-
if (this.inspector.getConfig().enabled) {
|
|
2588
|
-
console.error("[DevInspector] Error captured:", errorInfo);
|
|
2589
|
-
}
|
|
2590
2639
|
}
|
|
2591
2640
|
// Public API
|
|
2592
2641
|
trackError(error) {
|
|
@@ -2785,7 +2834,9 @@ var init_floating_widget = __esm({
|
|
|
2785
2834
|
top: centerY,
|
|
2786
2835
|
bottom: windowHeight - centerY
|
|
2787
2836
|
};
|
|
2788
|
-
const closestEdge = Object.entries(distances).reduce(
|
|
2837
|
+
const closestEdge = Object.entries(distances).reduce(
|
|
2838
|
+
(a, b) => a[1] < b[1] ? a : b
|
|
2839
|
+
)[0];
|
|
2789
2840
|
const margin = 20;
|
|
2790
2841
|
switch (closestEdge) {
|
|
2791
2842
|
case "left":
|
|
@@ -3044,11 +3095,15 @@ var init_main_panel = __esm({
|
|
|
3044
3095
|
removeTab(tabId) {
|
|
3045
3096
|
if (!this.tabs.has(tabId)) return;
|
|
3046
3097
|
this.tabs.delete(tabId);
|
|
3047
|
-
const tab = Array.from(
|
|
3098
|
+
const tab = Array.from(
|
|
3099
|
+
this.tabsElement.querySelectorAll(".devinspector-tab")
|
|
3100
|
+
).find((el) => el.dataset.tabId === tabId);
|
|
3048
3101
|
if (tab) {
|
|
3049
3102
|
tab.remove();
|
|
3050
3103
|
}
|
|
3051
|
-
const panel = Array.from(
|
|
3104
|
+
const panel = Array.from(
|
|
3105
|
+
this.bodyElement.querySelectorAll(".devinspector-panel")
|
|
3106
|
+
).find((el) => el.dataset.panelId === tabId);
|
|
3052
3107
|
if (panel) {
|
|
3053
3108
|
panel.remove();
|
|
3054
3109
|
}
|
|
@@ -3077,7 +3132,9 @@ var init_main_panel = __esm({
|
|
|
3077
3132
|
this.tabs.forEach((config, tabId) => {
|
|
3078
3133
|
if (config.badge) {
|
|
3079
3134
|
const count = config.badge();
|
|
3080
|
-
const tab = Array.from(
|
|
3135
|
+
const tab = Array.from(
|
|
3136
|
+
this.tabsElement.querySelectorAll(".devinspector-tab")
|
|
3137
|
+
).find((el) => el.dataset.tabId === tabId);
|
|
3081
3138
|
const badge = tab == null ? void 0 : tab.querySelector(".devinspector-tab-badge");
|
|
3082
3139
|
if (badge) {
|
|
3083
3140
|
badge.textContent = count.toString();
|
|
@@ -3867,7 +3924,9 @@ var init_inspector_ui = __esm({
|
|
|
3867
3924
|
list.appendChild(entry);
|
|
3868
3925
|
}
|
|
3869
3926
|
updateNetworkEntry(panel, response) {
|
|
3870
|
-
const entry = Array.from(panel.querySelectorAll("[data-request-id]")).find(
|
|
3927
|
+
const entry = Array.from(panel.querySelectorAll("[data-request-id]")).find(
|
|
3928
|
+
(el) => el.dataset.requestId === String(response.id)
|
|
3929
|
+
);
|
|
3871
3930
|
if (!entry) return;
|
|
3872
3931
|
const status = entry.querySelector(".devinspector-status");
|
|
3873
3932
|
if (status) {
|
|
@@ -4064,6 +4123,9 @@ var EventEmitter = class {
|
|
|
4064
4123
|
}
|
|
4065
4124
|
};
|
|
4066
4125
|
|
|
4126
|
+
// src/enhanced-simple.ts
|
|
4127
|
+
init_patches();
|
|
4128
|
+
|
|
4067
4129
|
// src/core/plugin-system.ts
|
|
4068
4130
|
var PluginSystem = class {
|
|
4069
4131
|
constructor(context) {
|
|
@@ -4102,17 +4164,20 @@ var PluginSystem = class {
|
|
|
4102
4164
|
if (!plugin) {
|
|
4103
4165
|
throw new Error(`Plugin "${pluginName}" is not registered`);
|
|
4104
4166
|
}
|
|
4105
|
-
|
|
4106
|
-
plugin.disable
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4167
|
+
try {
|
|
4168
|
+
if (plugin.disable) {
|
|
4169
|
+
plugin.disable();
|
|
4170
|
+
}
|
|
4171
|
+
if (plugin.uninstall) {
|
|
4172
|
+
await plugin.uninstall();
|
|
4173
|
+
}
|
|
4174
|
+
} finally {
|
|
4175
|
+
this.plugins.delete(pluginName);
|
|
4176
|
+
this.activePlugins.delete(pluginName);
|
|
4177
|
+
this.context.events.emit("plugin:unregistered", {
|
|
4178
|
+
name: pluginName
|
|
4179
|
+
});
|
|
4110
4180
|
}
|
|
4111
|
-
this.plugins.delete(pluginName);
|
|
4112
|
-
this.activePlugins.delete(pluginName);
|
|
4113
|
-
this.context.events.emit("plugin:unregistered", {
|
|
4114
|
-
name: pluginName
|
|
4115
|
-
});
|
|
4116
4181
|
}
|
|
4117
4182
|
enable(pluginName) {
|
|
4118
4183
|
const plugin = this.plugins.get(pluginName);
|
|
@@ -4223,7 +4288,7 @@ var BasePlugin = class {
|
|
|
4223
4288
|
};
|
|
4224
4289
|
|
|
4225
4290
|
// src/version.ts
|
|
4226
|
-
var VERSION = "1.
|
|
4291
|
+
var VERSION = "1.5.1";
|
|
4227
4292
|
|
|
4228
4293
|
// src/enhanced-simple.ts
|
|
4229
4294
|
var CONSOLE_METHODS = ["log", "info", "warn", "error", "debug"];
|
|
@@ -4232,28 +4297,57 @@ var MAX_METRIC_ENTRIES = 500;
|
|
|
4232
4297
|
var ASSET_PATTERN = /\.(?:css|js|mjs|map|png|jpe?g|gif|svg|webp|avif|ico|woff2?|ttf|otf|eot)(?:[?#]|$)/i;
|
|
4233
4298
|
var POSITIONS = ["top-left", "top-right", "bottom-left", "bottom-right"];
|
|
4234
4299
|
var PALETTES = {
|
|
4235
|
-
dark: {
|
|
4236
|
-
|
|
4300
|
+
dark: {
|
|
4301
|
+
bg: "#1a1a1a",
|
|
4302
|
+
header: "#262626",
|
|
4303
|
+
toolbar: "#1e1e1e",
|
|
4304
|
+
border: "#333",
|
|
4305
|
+
row: "#2a2a2a",
|
|
4306
|
+
text: "#e4e4e7",
|
|
4307
|
+
muted: "#9ca3af",
|
|
4308
|
+
code: "#0f0f0f"
|
|
4309
|
+
},
|
|
4310
|
+
light: {
|
|
4311
|
+
bg: "#ffffff",
|
|
4312
|
+
header: "#f3f4f6",
|
|
4313
|
+
toolbar: "#f9fafb",
|
|
4314
|
+
border: "#d1d5db",
|
|
4315
|
+
row: "#e5e7eb",
|
|
4316
|
+
text: "#111827",
|
|
4317
|
+
muted: "#4b5563",
|
|
4318
|
+
code: "#f3f4f6"
|
|
4319
|
+
}
|
|
4237
4320
|
};
|
|
4238
4321
|
var idCounter = 0;
|
|
4239
4322
|
function nextId() {
|
|
4240
4323
|
idCounter = (idCounter + 1) % Number.MAX_SAFE_INTEGER;
|
|
4241
4324
|
return `${Date.now().toString(36)}-${idCounter.toString(36)}`;
|
|
4242
4325
|
}
|
|
4243
|
-
function limit(value, fallback) {
|
|
4244
|
-
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.floor(value) : fallback;
|
|
4245
|
-
}
|
|
4246
4326
|
function normalizeCombo(combo) {
|
|
4247
4327
|
if (typeof combo !== "string") return "";
|
|
4248
4328
|
const parts = combo.toLowerCase().split("+").map((part) => part.trim()).filter(Boolean);
|
|
4249
|
-
const key = parts.filter(
|
|
4329
|
+
const key = parts.filter(
|
|
4330
|
+
(part) => !["ctrl", "control", "alt", "shift", "meta", "cmd"].includes(part)
|
|
4331
|
+
);
|
|
4250
4332
|
if (key.length !== 1) return "";
|
|
4251
4333
|
const has = (...names) => names.some((name) => parts.includes(name));
|
|
4252
|
-
return [
|
|
4334
|
+
return [
|
|
4335
|
+
has("ctrl", "control") && "ctrl",
|
|
4336
|
+
has("alt") && "alt",
|
|
4337
|
+
has("shift") && "shift",
|
|
4338
|
+
has("meta", "cmd") && "meta",
|
|
4339
|
+
key[0]
|
|
4340
|
+
].filter(Boolean).join("+");
|
|
4253
4341
|
}
|
|
4254
4342
|
function eventCombo(event) {
|
|
4255
4343
|
if (typeof event.key !== "string") return "";
|
|
4256
|
-
return [
|
|
4344
|
+
return [
|
|
4345
|
+
event.ctrlKey && "ctrl",
|
|
4346
|
+
event.altKey && "alt",
|
|
4347
|
+
event.shiftKey && "shift",
|
|
4348
|
+
event.metaKey && "meta",
|
|
4349
|
+
event.key.toLowerCase()
|
|
4350
|
+
].filter(Boolean).join("+");
|
|
4257
4351
|
}
|
|
4258
4352
|
function truncate(text) {
|
|
4259
4353
|
return text.length > MAX_MESSAGE_LENGTH ? `${text.slice(0, MAX_MESSAGE_LENGTH)}\u2026 (${text.length - MAX_MESSAGE_LENGTH} more characters)` : text;
|
|
@@ -4364,7 +4458,9 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4364
4458
|
this.setupHotkeys();
|
|
4365
4459
|
this.mountWhenReady();
|
|
4366
4460
|
for (const plugin of (_a = config.plugins) != null ? _a : []) {
|
|
4367
|
-
this.use(plugin).catch((error) =>
|
|
4461
|
+
this.use(plugin).catch((error) => {
|
|
4462
|
+
if (!this.destroyed) this.reportInternal("Failed to register plugin", error);
|
|
4463
|
+
});
|
|
4368
4464
|
}
|
|
4369
4465
|
this.events.emit("inspector:ready");
|
|
4370
4466
|
}
|
|
@@ -4399,12 +4495,12 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4399
4495
|
performance: features.performance !== false,
|
|
4400
4496
|
errors: features.errors !== false
|
|
4401
4497
|
},
|
|
4402
|
-
maxNetworkEntries:
|
|
4403
|
-
maxConsoleEntries:
|
|
4404
|
-
maxErrorEntries:
|
|
4498
|
+
maxNetworkEntries: normalizeLimit(config.maxNetworkEntries, 1e3),
|
|
4499
|
+
maxConsoleEntries: normalizeLimit(config.maxConsoleEntries, 500),
|
|
4500
|
+
maxErrorEntries: normalizeLimit(config.maxErrorEntries, 100),
|
|
4405
4501
|
captureStackTraces: config.captureStackTraces !== false,
|
|
4406
4502
|
hideAssets: ((_e = config.networkFilters) == null ? void 0 : _e.hideAssets) === true,
|
|
4407
|
-
slowRequestThreshold:
|
|
4503
|
+
slowRequestThreshold: normalizeLimit(config.slowRequestThreshold, 3e3),
|
|
4408
4504
|
onError: typeof config.onError === "function" ? config.onError : void 0,
|
|
4409
4505
|
onPerformanceIssue: typeof config.onPerformanceIssue === "function" ? config.onPerformanceIssue : void 0
|
|
4410
4506
|
};
|
|
@@ -4441,7 +4537,7 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4441
4537
|
minimize() {
|
|
4442
4538
|
if (!this.isEnabled) return;
|
|
4443
4539
|
this.isMinimized = !this.isMinimized;
|
|
4444
|
-
if (this.panel) this.panel.style.height = this.isMinimized ? "
|
|
4540
|
+
if (this.panel) this.panel.style.height = this.isMinimized ? "auto" : "650px";
|
|
4445
4541
|
this.render();
|
|
4446
4542
|
this.events.emit("inspector:minimize", this.isMinimized);
|
|
4447
4543
|
}
|
|
@@ -4479,7 +4575,12 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4479
4575
|
/** Records a custom metric and emits `performance:metric`. */
|
|
4480
4576
|
track(name, data) {
|
|
4481
4577
|
if (!this.isEnabled) return;
|
|
4482
|
-
const entry = {
|
|
4578
|
+
const entry = {
|
|
4579
|
+
id: nextId(),
|
|
4580
|
+
name: String(name),
|
|
4581
|
+
data,
|
|
4582
|
+
timestamp: Date.now()
|
|
4583
|
+
};
|
|
4483
4584
|
this.pushBounded(this.metrics, entry, MAX_METRIC_ENTRIES);
|
|
4484
4585
|
this.emitSafely("performance:metric", entry);
|
|
4485
4586
|
this.scheduleRender();
|
|
@@ -4504,10 +4605,20 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4504
4605
|
const duration = performance.now() - start;
|
|
4505
4606
|
try {
|
|
4506
4607
|
(_a = performance.mark) == null ? void 0 : _a.call(performance, `devinspector-${key}-end`);
|
|
4507
|
-
(_b = performance.measure) == null ? void 0 : _b.call(
|
|
4608
|
+
(_b = performance.measure) == null ? void 0 : _b.call(
|
|
4609
|
+
performance,
|
|
4610
|
+
`devinspector-${key}`,
|
|
4611
|
+
`devinspector-${key}-start`,
|
|
4612
|
+
`devinspector-${key}-end`
|
|
4613
|
+
);
|
|
4508
4614
|
} catch (e) {
|
|
4509
4615
|
}
|
|
4510
|
-
const entry = {
|
|
4616
|
+
const entry = {
|
|
4617
|
+
id: nextId(),
|
|
4618
|
+
name: key,
|
|
4619
|
+
duration,
|
|
4620
|
+
timestamp: Date.now()
|
|
4621
|
+
};
|
|
4511
4622
|
this.pushBounded(this.metrics, entry, MAX_METRIC_ENTRIES);
|
|
4512
4623
|
this.emitSafely("performance:mark", entry);
|
|
4513
4624
|
this.scheduleRender();
|
|
@@ -4516,7 +4627,13 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4516
4627
|
/** Installs a plugin. Resolves once the plugin's install() has finished. */
|
|
4517
4628
|
use(plugin) {
|
|
4518
4629
|
if (this.destroyed) return Promise.reject(new Error("DevInspector has been destroyed"));
|
|
4519
|
-
return this.pluginSystem.register(plugin)
|
|
4630
|
+
return this.pluginSystem.register(plugin).then(async () => {
|
|
4631
|
+
if (!this.destroyed) return;
|
|
4632
|
+
await this.pluginSystem.unregister(plugin.name).catch(
|
|
4633
|
+
(error) => this.reportInternal(`Failed to uninstall plugin "${plugin.name}"`, error)
|
|
4634
|
+
);
|
|
4635
|
+
throw new Error("DevInspector has been destroyed");
|
|
4636
|
+
});
|
|
4520
4637
|
}
|
|
4521
4638
|
on(event, listener) {
|
|
4522
4639
|
return this.events.on(event, listener);
|
|
@@ -4546,9 +4663,12 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4546
4663
|
*/
|
|
4547
4664
|
import(snapshot) {
|
|
4548
4665
|
const data = snapshot && typeof snapshot === "object" ? snapshot.data : void 0;
|
|
4549
|
-
if (!data || typeof data !== "object")
|
|
4666
|
+
if (!data || typeof data !== "object")
|
|
4667
|
+
throw new TypeError("DevInspector.import() expects an object produced by export()");
|
|
4550
4668
|
const source = data;
|
|
4551
|
-
const list = (value) => Array.isArray(value) ? value.filter(
|
|
4669
|
+
const list = (value) => Array.isArray(value) ? value.filter(
|
|
4670
|
+
(item) => !!item && typeof item === "object"
|
|
4671
|
+
) : [];
|
|
4552
4672
|
const str = (value, fallback = "") => typeof value === "string" ? value : fallback;
|
|
4553
4673
|
const num = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
4554
4674
|
this.network = list(source.network).slice(0, this.config.maxNetworkEntries).map((item) => {
|
|
@@ -4605,7 +4725,7 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4605
4725
|
if (this.destroyed) return;
|
|
4606
4726
|
this.destroyed = true;
|
|
4607
4727
|
for (const patch of this.patches.reverse()) {
|
|
4608
|
-
|
|
4728
|
+
restorePatch(patch.target, patch.key, patch.replacement, patch.original);
|
|
4609
4729
|
}
|
|
4610
4730
|
this.patches = [];
|
|
4611
4731
|
for (const cleanup of this.cleanups.splice(0)) {
|
|
@@ -4620,7 +4740,9 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4620
4740
|
this.widget = null;
|
|
4621
4741
|
this.panel = null;
|
|
4622
4742
|
for (const plugin of this.pluginSystem.getAll()) {
|
|
4623
|
-
this.pluginSystem.unregister(plugin.name).catch(
|
|
4743
|
+
this.pluginSystem.unregister(plugin.name).catch(
|
|
4744
|
+
(error) => this.reportInternal(`Failed to uninstall plugin "${plugin.name}"`, error)
|
|
4745
|
+
);
|
|
4624
4746
|
}
|
|
4625
4747
|
this.emitSafely("inspector:destroy", void 0);
|
|
4626
4748
|
this.events.removeAllListeners();
|
|
@@ -4629,7 +4751,9 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4629
4751
|
this.errors = [];
|
|
4630
4752
|
this.metrics = [];
|
|
4631
4753
|
this.marks.clear();
|
|
4632
|
-
_EnhancedDevInspector.instances = _EnhancedDevInspector.instances.filter(
|
|
4754
|
+
_EnhancedDevInspector.instances = _EnhancedDevInspector.instances.filter(
|
|
4755
|
+
(instance) => instance !== this
|
|
4756
|
+
);
|
|
4633
4757
|
}
|
|
4634
4758
|
// ---------------------------------------------------------------------------
|
|
4635
4759
|
// Capture
|
|
@@ -4676,7 +4800,12 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4676
4800
|
if (error !== void 0) entry.error = error;
|
|
4677
4801
|
this.emitSafely(status === "error" ? "network:error" : "network:response", { ...entry });
|
|
4678
4802
|
if (duration > this.config.slowRequestThreshold) {
|
|
4679
|
-
const issue = {
|
|
4803
|
+
const issue = {
|
|
4804
|
+
type: "slow-network",
|
|
4805
|
+
message: `Slow network request: ${entry.url}`,
|
|
4806
|
+
url: entry.url,
|
|
4807
|
+
duration: entry.duration
|
|
4808
|
+
};
|
|
4680
4809
|
this.emitSafely("performance:issue", issue);
|
|
4681
4810
|
this.callUser(this.config.onPerformanceIssue, issue);
|
|
4682
4811
|
}
|
|
@@ -4690,7 +4819,14 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4690
4819
|
let entry = null;
|
|
4691
4820
|
const start = performance.now();
|
|
4692
4821
|
self.capture(() => {
|
|
4693
|
-
entry = {
|
|
4822
|
+
entry = {
|
|
4823
|
+
id: nextId(),
|
|
4824
|
+
type: "fetch",
|
|
4825
|
+
url: requestUrl(args[0]),
|
|
4826
|
+
method: requestMethod(args[0], args[1]),
|
|
4827
|
+
status: "pending",
|
|
4828
|
+
timestamp: Date.now()
|
|
4829
|
+
};
|
|
4694
4830
|
self.addNetworkEntry(entry);
|
|
4695
4831
|
});
|
|
4696
4832
|
if (!entry) return Reflect.apply(originalFetch, this, args);
|
|
@@ -4699,16 +4835,32 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4699
4835
|
try {
|
|
4700
4836
|
result = Reflect.apply(originalFetch, this, args);
|
|
4701
4837
|
} catch (error) {
|
|
4702
|
-
self.capture(
|
|
4838
|
+
self.capture(
|
|
4839
|
+
() => self.finishNetworkEntry(
|
|
4840
|
+
tracked,
|
|
4841
|
+
"error",
|
|
4842
|
+
performance.now() - start,
|
|
4843
|
+
error instanceof Error ? error.message : String(error)
|
|
4844
|
+
)
|
|
4845
|
+
);
|
|
4703
4846
|
throw error;
|
|
4704
4847
|
}
|
|
4705
4848
|
return Promise.resolve(result).then(
|
|
4706
4849
|
(response) => {
|
|
4707
|
-
self.capture(
|
|
4850
|
+
self.capture(
|
|
4851
|
+
() => self.finishNetworkEntry(tracked, response.status, performance.now() - start)
|
|
4852
|
+
);
|
|
4708
4853
|
return response;
|
|
4709
4854
|
},
|
|
4710
4855
|
(error) => {
|
|
4711
|
-
self.capture(
|
|
4856
|
+
self.capture(
|
|
4857
|
+
() => self.finishNetworkEntry(
|
|
4858
|
+
tracked,
|
|
4859
|
+
"error",
|
|
4860
|
+
performance.now() - start,
|
|
4861
|
+
error instanceof Error ? error.message : String(error)
|
|
4862
|
+
)
|
|
4863
|
+
);
|
|
4712
4864
|
throw error;
|
|
4713
4865
|
}
|
|
4714
4866
|
);
|
|
@@ -4723,23 +4875,51 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4723
4875
|
const originalSend = proto.send;
|
|
4724
4876
|
const self = this;
|
|
4725
4877
|
const open = function(...args) {
|
|
4878
|
+
var _a, _b;
|
|
4879
|
+
const result = Reflect.apply(originalOpen, this, args);
|
|
4726
4880
|
if (!self.destroyed) {
|
|
4727
|
-
self.xhrState.
|
|
4881
|
+
(_b = (_a = self.xhrState.get(this)) == null ? void 0 : _a.terminate) == null ? void 0 : _b.call(_a);
|
|
4882
|
+
self.xhrState.set(this, {
|
|
4883
|
+
method: typeof args[0] === "string" ? args[0].toUpperCase() : "GET",
|
|
4884
|
+
url: requestUrl(args[1])
|
|
4885
|
+
});
|
|
4728
4886
|
}
|
|
4729
|
-
return
|
|
4887
|
+
return result;
|
|
4730
4888
|
};
|
|
4731
4889
|
const send = function(...args) {
|
|
4890
|
+
var _a;
|
|
4732
4891
|
const state = self.xhrState.get(this);
|
|
4733
|
-
|
|
4734
|
-
|
|
4892
|
+
const tracking = {};
|
|
4893
|
+
if (state) self.capture(() => tracking.fail = self.trackXhr(this, state));
|
|
4894
|
+
try {
|
|
4895
|
+
return Reflect.apply(originalSend, this, args);
|
|
4896
|
+
} catch (error) {
|
|
4897
|
+
(_a = tracking.fail) == null ? void 0 : _a.call(tracking, error);
|
|
4898
|
+
throw error;
|
|
4899
|
+
}
|
|
4735
4900
|
};
|
|
4736
4901
|
this.patch(proto, "open", open);
|
|
4737
4902
|
this.patch(proto, "send", send);
|
|
4738
4903
|
}
|
|
4739
4904
|
trackXhr(xhr, state) {
|
|
4740
|
-
const
|
|
4905
|
+
const previous = {
|
|
4906
|
+
entry: state.entry,
|
|
4907
|
+
start: state.start,
|
|
4908
|
+
failure: state.failure,
|
|
4909
|
+
terminate: state.terminate
|
|
4910
|
+
};
|
|
4911
|
+
let settled = false;
|
|
4912
|
+
const entry = {
|
|
4913
|
+
id: nextId(),
|
|
4914
|
+
type: "xhr",
|
|
4915
|
+
url: state.url,
|
|
4916
|
+
method: state.method,
|
|
4917
|
+
status: "pending",
|
|
4918
|
+
timestamp: Date.now()
|
|
4919
|
+
};
|
|
4920
|
+
const startedAt = performance.now();
|
|
4741
4921
|
state.entry = entry;
|
|
4742
|
-
state.start =
|
|
4922
|
+
state.start = startedAt;
|
|
4743
4923
|
state.failure = void 0;
|
|
4744
4924
|
const fail = (reason) => () => {
|
|
4745
4925
|
state.failure = reason;
|
|
@@ -4747,25 +4927,59 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4747
4927
|
const onError = fail("Network error");
|
|
4748
4928
|
const onAbort = fail("Request aborted");
|
|
4749
4929
|
const onTimeout = fail("Request timed out");
|
|
4750
|
-
const
|
|
4751
|
-
var _a;
|
|
4930
|
+
const detach = () => {
|
|
4752
4931
|
xhr.removeEventListener("error", onError);
|
|
4753
4932
|
xhr.removeEventListener("abort", onAbort);
|
|
4754
4933
|
xhr.removeEventListener("timeout", onTimeout);
|
|
4755
4934
|
xhr.removeEventListener("loadend", onLoadEnd);
|
|
4756
|
-
|
|
4935
|
+
};
|
|
4936
|
+
const onLoadEnd = () => {
|
|
4937
|
+
var _a;
|
|
4938
|
+
detach();
|
|
4939
|
+
if (settled || state.entry !== entry || this.destroyed) return;
|
|
4940
|
+
settled = true;
|
|
4757
4941
|
const duration = performance.now() - ((_a = state.start) != null ? _a : performance.now());
|
|
4758
4942
|
const failed = state.failure !== void 0 || xhr.status === 0;
|
|
4759
|
-
this.capture(
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4943
|
+
this.capture(
|
|
4944
|
+
() => {
|
|
4945
|
+
var _a2;
|
|
4946
|
+
return this.finishNetworkEntry(
|
|
4947
|
+
entry,
|
|
4948
|
+
failed ? "error" : xhr.status,
|
|
4949
|
+
duration,
|
|
4950
|
+
failed ? (_a2 = state.failure) != null ? _a2 : "Network error" : void 0
|
|
4951
|
+
);
|
|
4952
|
+
}
|
|
4953
|
+
);
|
|
4763
4954
|
};
|
|
4764
4955
|
xhr.addEventListener("error", onError);
|
|
4765
4956
|
xhr.addEventListener("abort", onAbort);
|
|
4766
4957
|
xhr.addEventListener("timeout", onTimeout);
|
|
4767
4958
|
xhr.addEventListener("loadend", onLoadEnd);
|
|
4959
|
+
state.terminate = () => {
|
|
4960
|
+
detach();
|
|
4961
|
+
if (settled || this.destroyed) return;
|
|
4962
|
+
settled = true;
|
|
4963
|
+
this.capture(
|
|
4964
|
+
() => this.finishNetworkEntry(entry, "error", performance.now() - startedAt, "Request aborted")
|
|
4965
|
+
);
|
|
4966
|
+
};
|
|
4768
4967
|
this.addNetworkEntry(entry);
|
|
4968
|
+
return (error) => {
|
|
4969
|
+
detach();
|
|
4970
|
+
if (settled) return;
|
|
4971
|
+
settled = true;
|
|
4972
|
+
if (state.entry === entry) Object.assign(state, previous);
|
|
4973
|
+
if (this.destroyed) return;
|
|
4974
|
+
this.capture(
|
|
4975
|
+
() => this.finishNetworkEntry(
|
|
4976
|
+
entry,
|
|
4977
|
+
"error",
|
|
4978
|
+
performance.now() - startedAt,
|
|
4979
|
+
error instanceof Error ? error.message : String(error)
|
|
4980
|
+
)
|
|
4981
|
+
);
|
|
4982
|
+
};
|
|
4769
4983
|
}
|
|
4770
4984
|
interceptConsole() {
|
|
4771
4985
|
const self = this;
|
|
@@ -4773,7 +4987,11 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4773
4987
|
const original = console[level];
|
|
4774
4988
|
if (typeof original !== "function") continue;
|
|
4775
4989
|
const wrapper = function(...args) {
|
|
4776
|
-
const result = Reflect.apply(
|
|
4990
|
+
const result = Reflect.apply(
|
|
4991
|
+
original,
|
|
4992
|
+
this === void 0 ? console : this,
|
|
4993
|
+
args
|
|
4994
|
+
);
|
|
4777
4995
|
self.capture(() => {
|
|
4778
4996
|
const entry = {
|
|
4779
4997
|
id: nextId(),
|
|
@@ -4869,7 +5087,8 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4869
5087
|
// Performance loop (runs only while the panel is visible)
|
|
4870
5088
|
// ---------------------------------------------------------------------------
|
|
4871
5089
|
startPerformanceLoop() {
|
|
4872
|
-
if (!this.config.features.performance || this.rafId !== null || typeof requestAnimationFrame !== "function")
|
|
5090
|
+
if (!this.config.features.performance || this.rafId !== null || typeof requestAnimationFrame !== "function")
|
|
5091
|
+
return;
|
|
4873
5092
|
let last = performance.now();
|
|
4874
5093
|
let frames = 0;
|
|
4875
5094
|
const tick = () => {
|
|
@@ -4898,7 +5117,8 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4898
5117
|
this.rafId = requestAnimationFrame(tick);
|
|
4899
5118
|
}
|
|
4900
5119
|
stopPerformanceLoop() {
|
|
4901
|
-
if (this.rafId !== null && typeof cancelAnimationFrame === "function")
|
|
5120
|
+
if (this.rafId !== null && typeof cancelAnimationFrame === "function")
|
|
5121
|
+
cancelAnimationFrame(this.rafId);
|
|
4902
5122
|
this.rafId = null;
|
|
4903
5123
|
}
|
|
4904
5124
|
// ---------------------------------------------------------------------------
|
|
@@ -4969,7 +5189,9 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4969
5189
|
break;
|
|
4970
5190
|
}
|
|
4971
5191
|
case "clear":
|
|
4972
|
-
this.clear(
|
|
5192
|
+
this.clear(
|
|
5193
|
+
(_b = actionable.getAttribute("data-target")) != null ? _b : "all"
|
|
5194
|
+
);
|
|
4973
5195
|
break;
|
|
4974
5196
|
case "toggle-recording":
|
|
4975
5197
|
this.toggleRecording();
|
|
@@ -5081,7 +5303,12 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
5081
5303
|
${selected.error ? `<div><strong>Error:</strong> ${escapeHtml(selected.error)}</div>` : ""}
|
|
5082
5304
|
</div>` : "";
|
|
5083
5305
|
return `${this.toolbar(
|
|
5084
|
-
button("clear", "Clear", 'data-target="network"') + button(
|
|
5306
|
+
button("clear", "Clear", 'data-target="network"') + button(
|
|
5307
|
+
"toggle-recording",
|
|
5308
|
+
this.isRecording ? "Pause" : "Resume",
|
|
5309
|
+
"",
|
|
5310
|
+
this.isRecording ? "#ef4444" : "#22c55e"
|
|
5311
|
+
),
|
|
5085
5312
|
`${visible.length} requests`
|
|
5086
5313
|
)}
|
|
5087
5314
|
<div style="flex: 1; overflow-y: auto;">${rows || this.empty("No network activity")}</div>${details}`;
|
|
@@ -5186,13 +5413,20 @@ var CircularStorage = class {
|
|
|
5186
5413
|
this.tail = 0;
|
|
5187
5414
|
this.size = 0;
|
|
5188
5415
|
this.idCounter = 0;
|
|
5189
|
-
|
|
5416
|
+
const { maxSize } = options;
|
|
5417
|
+
if (typeof maxSize !== "number" || !Number.isFinite(maxSize) || maxSize < 0) {
|
|
5418
|
+
throw new RangeError(
|
|
5419
|
+
`CircularStorage maxSize must be a non-negative finite number, got ${String(maxSize)}`
|
|
5420
|
+
);
|
|
5421
|
+
}
|
|
5422
|
+
this.maxSize = Math.floor(maxSize);
|
|
5190
5423
|
this.ttl = options.ttl;
|
|
5191
5424
|
this.onEvict = options.onEvict;
|
|
5192
5425
|
this.buffer = new Array(this.maxSize);
|
|
5193
5426
|
}
|
|
5194
5427
|
push(data) {
|
|
5195
5428
|
const id = `${Date.now()}-${++this.idCounter}`;
|
|
5429
|
+
if (this.maxSize === 0) return id;
|
|
5196
5430
|
const entry = {
|
|
5197
5431
|
id,
|
|
5198
5432
|
timestamp: Date.now(),
|
|
@@ -5272,6 +5506,7 @@ var CircularStorage = class {
|
|
|
5272
5506
|
return now - entry.timestamp > this.ttl;
|
|
5273
5507
|
}
|
|
5274
5508
|
removeExpired() {
|
|
5509
|
+
var _a;
|
|
5275
5510
|
if (!this.ttl) return 0;
|
|
5276
5511
|
const now = Date.now();
|
|
5277
5512
|
let removedCount = 0;
|
|
@@ -5281,8 +5516,8 @@ var CircularStorage = class {
|
|
|
5281
5516
|
const entry = this.buffer[index];
|
|
5282
5517
|
if (entry && !this.isExpired(entry, now)) {
|
|
5283
5518
|
validEntries.push(entry);
|
|
5284
|
-
} else if (entry
|
|
5285
|
-
this.onEvict(entry);
|
|
5519
|
+
} else if (entry) {
|
|
5520
|
+
(_a = this.onEvict) == null ? void 0 : _a.call(this, entry);
|
|
5286
5521
|
removedCount++;
|
|
5287
5522
|
}
|
|
5288
5523
|
}
|
|
@@ -5415,6 +5650,7 @@ var _DevInspector = class _DevInspector {
|
|
|
5415
5650
|
this.cleanupFunctions = [];
|
|
5416
5651
|
this.initPromise = null;
|
|
5417
5652
|
this.destroyed = false;
|
|
5653
|
+
this.uninstallingPlugins = /* @__PURE__ */ new Set();
|
|
5418
5654
|
if (_DevInspector.instance) {
|
|
5419
5655
|
console.warn("DevInspector instance already exists. Returning existing instance.");
|
|
5420
5656
|
return _DevInspector.instance;
|
|
@@ -5494,7 +5730,11 @@ var _DevInspector = class _DevInspector {
|
|
|
5494
5730
|
...config,
|
|
5495
5731
|
hotkeys: { ...defaultConfig.hotkeys, ...config.hotkeys },
|
|
5496
5732
|
features: { ...defaultConfig.features, ...config.features },
|
|
5497
|
-
networkFilters: { ...defaultConfig.networkFilters, ...config.networkFilters }
|
|
5733
|
+
networkFilters: { ...defaultConfig.networkFilters, ...config.networkFilters },
|
|
5734
|
+
// Invalid limits (negative, NaN, Infinity) fall back to the defaults, as in DevInspector.
|
|
5735
|
+
maxNetworkEntries: normalizeLimit(config.maxNetworkEntries, defaultConfig.maxNetworkEntries),
|
|
5736
|
+
maxConsoleEntries: normalizeLimit(config.maxConsoleEntries, defaultConfig.maxConsoleEntries),
|
|
5737
|
+
maxErrorEntries: normalizeLimit(config.maxErrorEntries, defaultConfig.maxErrorEntries)
|
|
5498
5738
|
};
|
|
5499
5739
|
}
|
|
5500
5740
|
init() {
|
|
@@ -5512,7 +5752,6 @@ var _DevInspector = class _DevInspector {
|
|
|
5512
5752
|
await this.registerPlugins();
|
|
5513
5753
|
if (this.destroyed) return this.teardown();
|
|
5514
5754
|
this.setupHotkeys();
|
|
5515
|
-
this.setupErrorHandlers();
|
|
5516
5755
|
this.initialized = true;
|
|
5517
5756
|
this.events.emit("inspector:ready");
|
|
5518
5757
|
} catch (error) {
|
|
@@ -5596,33 +5835,6 @@ var _DevInspector = class _DevInspector {
|
|
|
5596
5835
|
document.addEventListener("keydown", handleKeydown);
|
|
5597
5836
|
this.cleanupFunctions.push(() => document.removeEventListener("keydown", handleKeydown));
|
|
5598
5837
|
}
|
|
5599
|
-
setupErrorHandlers() {
|
|
5600
|
-
if (!this.config.features.errors) return;
|
|
5601
|
-
const handleError = (event) => {
|
|
5602
|
-
this.events.emit("error:uncaught", {
|
|
5603
|
-
message: event.message,
|
|
5604
|
-
filename: event.filename,
|
|
5605
|
-
lineno: event.lineno,
|
|
5606
|
-
colno: event.colno,
|
|
5607
|
-
error: event.error,
|
|
5608
|
-
timestamp: Date.now()
|
|
5609
|
-
});
|
|
5610
|
-
};
|
|
5611
|
-
const handleRejection = (event) => {
|
|
5612
|
-
this.events.emit("error:uncaught", {
|
|
5613
|
-
message: "Unhandled promise rejection",
|
|
5614
|
-
reason: event.reason,
|
|
5615
|
-
promise: event.promise,
|
|
5616
|
-
timestamp: Date.now()
|
|
5617
|
-
});
|
|
5618
|
-
};
|
|
5619
|
-
window.addEventListener("error", handleError);
|
|
5620
|
-
window.addEventListener("unhandledrejection", handleRejection);
|
|
5621
|
-
this.cleanupFunctions.push(() => {
|
|
5622
|
-
window.removeEventListener("error", handleError);
|
|
5623
|
-
window.removeEventListener("unhandledrejection", handleRejection);
|
|
5624
|
-
});
|
|
5625
|
-
}
|
|
5626
5838
|
getKeyCombo(event) {
|
|
5627
5839
|
const parts = [];
|
|
5628
5840
|
if (event.ctrlKey) parts.push("ctrl");
|
|
@@ -5684,6 +5896,17 @@ var _DevInspector = class _DevInspector {
|
|
|
5684
5896
|
this.ui = null;
|
|
5685
5897
|
this.cleanupFunctions.forEach((cleanup) => cleanup());
|
|
5686
5898
|
this.cleanupFunctions = [];
|
|
5899
|
+
this.uninstallPlugins();
|
|
5900
|
+
}
|
|
5901
|
+
/** Disables and uninstalls every registered plugin; failures are reported, not thrown. */
|
|
5902
|
+
uninstallPlugins(names = this.pluginSystem.getAll().map((plugin) => plugin.name)) {
|
|
5903
|
+
for (const name of names) {
|
|
5904
|
+
if (this.uninstallingPlugins.has(name)) continue;
|
|
5905
|
+
this.uninstallingPlugins.add(name);
|
|
5906
|
+
this.pluginSystem.unregister(name).catch((error) => {
|
|
5907
|
+
console.error(`DevInspector: failed to uninstall plugin "${name}"`, error);
|
|
5908
|
+
}).finally(() => this.uninstallingPlugins.delete(name));
|
|
5909
|
+
}
|
|
5687
5910
|
}
|
|
5688
5911
|
destroy() {
|
|
5689
5912
|
this.destroyed = true;
|
|
@@ -5715,7 +5938,12 @@ var _DevInspector = class _DevInspector {
|
|
|
5715
5938
|
}
|
|
5716
5939
|
}
|
|
5717
5940
|
async use(plugin) {
|
|
5941
|
+
if (this.destroyed) throw new Error("DevInspector has been destroyed");
|
|
5718
5942
|
await this.pluginSystem.register(plugin);
|
|
5943
|
+
if (this.destroyed) {
|
|
5944
|
+
this.uninstallPlugins([plugin.name]);
|
|
5945
|
+
throw new Error("DevInspector has been destroyed");
|
|
5946
|
+
}
|
|
5719
5947
|
}
|
|
5720
5948
|
export() {
|
|
5721
5949
|
return {
|