@oxog/devinspector 1.4.0 → 1.5.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/CHANGELOG.md +27 -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-VZORB655.js → chunk-WUYUDBSC.js} +6 -2
- 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 +766 -489
- package/dist/devinspector.umd.cjs.map +1 -1
- package/dist/devinspector.umd.js +766 -489
- 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 +513 -286
- 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 +268 -98
- package/dist/index.js.map +1 -1
- package/dist/{inspector-ui-475ZNEHC.js → inspector-ui-TEAZXDPM.js} +17 -7
- package/dist/inspector-ui-TEAZXDPM.js.map +1 -0
- package/dist/{network-monitor-WNRL2JI7.js → network-monitor-6XRFHXMV.js} +152 -114
- package/dist/network-monitor-6XRFHXMV.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 +6 -3
- package/dist/chunk-LNBLBFDA.js.map +0 -1
- package/dist/chunk-VZORB655.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-475ZNEHC.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
|
@@ -23,7 +23,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
23
23
|
// src/core/env.ts
|
|
24
24
|
function readNodeEnv() {
|
|
25
25
|
try {
|
|
26
|
-
return
|
|
26
|
+
return process.env.NODE_ENV;
|
|
27
27
|
} catch (e) {
|
|
28
28
|
return void 0;
|
|
29
29
|
}
|
|
@@ -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 = {}) {
|
|
@@ -418,11 +472,14 @@ var init_xhr_interceptor = __esm({
|
|
|
418
472
|
if (this.installed || typeof XMLHttpRequest === "undefined") return;
|
|
419
473
|
const self = this;
|
|
420
474
|
XMLHttpRequest.prototype.open = function(method, url, async = true, username, password) {
|
|
475
|
+
var _a;
|
|
476
|
+
const result = self.originalOpen.apply(this, [method, url, async, username, password]);
|
|
477
|
+
(_a = this._devinspectorCancel) == null ? void 0 : _a.call(this);
|
|
421
478
|
this._devinspectorId = generateId();
|
|
422
479
|
this._devinspectorMethod = method;
|
|
423
480
|
this._devinspectorUrl = url.toString();
|
|
424
481
|
this._devinspectorRequestHeaders = {};
|
|
425
|
-
return
|
|
482
|
+
return result;
|
|
426
483
|
};
|
|
427
484
|
XMLHttpRequest.prototype.setRequestHeader = function(name, value) {
|
|
428
485
|
if (this._devinspectorRequestHeaders) {
|
|
@@ -432,10 +489,15 @@ var init_xhr_interceptor = __esm({
|
|
|
432
489
|
};
|
|
433
490
|
XMLHttpRequest.prototype.send = function(body) {
|
|
434
491
|
var _a, _b;
|
|
435
|
-
|
|
492
|
+
if (!self.installed || this._devinspectorCancel)
|
|
493
|
+
return self.originalSend.apply(this, [body]);
|
|
494
|
+
const xhr = this;
|
|
495
|
+
const id = this._devinspectorId;
|
|
496
|
+
const startTime = performance.now();
|
|
497
|
+
this._devinspectorStartTime = startTime;
|
|
436
498
|
this._devinspectorRequestBody = self.sanitizeBody(body);
|
|
437
499
|
const request = {
|
|
438
|
-
id
|
|
500
|
+
id,
|
|
439
501
|
method: this._devinspectorMethod,
|
|
440
502
|
url: this._devinspectorUrl,
|
|
441
503
|
headers: this._devinspectorRequestHeaders || {},
|
|
@@ -444,38 +506,46 @@ var init_xhr_interceptor = __esm({
|
|
|
444
506
|
type: "xhr"
|
|
445
507
|
};
|
|
446
508
|
(_b = (_a = self.handlers).onRequest) == null ? void 0 : _b.call(_a, request);
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
509
|
+
const listeners = [];
|
|
510
|
+
const listen = (target, type, handler) => {
|
|
511
|
+
target.addEventListener(type, handler);
|
|
512
|
+
listeners.push([target, type, handler]);
|
|
513
|
+
};
|
|
514
|
+
let ended = false;
|
|
515
|
+
const detach = () => {
|
|
516
|
+
ended = true;
|
|
517
|
+
for (const [target, type, handler] of listeners) target.removeEventListener(type, handler);
|
|
518
|
+
listeners.length = 0;
|
|
519
|
+
if (xhr._devinspectorCancel === cancel) xhr._devinspectorCancel = void 0;
|
|
520
|
+
};
|
|
521
|
+
const fail = (message) => {
|
|
522
|
+
var _a2, _b2;
|
|
523
|
+
(_b2 = (_a2 = self.handlers).onError) == null ? void 0 : _b2.call(_a2, { id, message, timestamp: Date.now() });
|
|
524
|
+
};
|
|
525
|
+
const cancel = () => {
|
|
526
|
+
detach();
|
|
527
|
+
fail("Request aborted");
|
|
528
|
+
};
|
|
529
|
+
const onProgress = (event) => {
|
|
530
|
+
var _a2, _b2;
|
|
531
|
+
if (event.lengthComputable) {
|
|
532
|
+
(_b2 = (_a2 = self.handlers).onProgress) == null ? void 0 : _b2.call(_a2, { id, loaded: event.loaded, total: event.total });
|
|
533
|
+
}
|
|
534
|
+
};
|
|
458
535
|
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
|
-
});
|
|
536
|
+
if (this.upload) listen(this.upload, "progress", onProgress);
|
|
537
|
+
listen(this, "progress", onProgress);
|
|
468
538
|
}
|
|
469
|
-
this
|
|
539
|
+
listen(this, "load", () => {
|
|
470
540
|
var _a2, _b2;
|
|
471
|
-
const duration = performance.now() -
|
|
472
|
-
const responseHeaders = self.parseResponseHeaders(
|
|
473
|
-
const responseBody = self.extractResponseBody(
|
|
541
|
+
const duration = performance.now() - startTime;
|
|
542
|
+
const responseHeaders = self.parseResponseHeaders(xhr.getAllResponseHeaders());
|
|
543
|
+
const responseBody = self.extractResponseBody(xhr);
|
|
474
544
|
const size = self.calculateSize(responseBody, responseHeaders);
|
|
475
545
|
const response = {
|
|
476
|
-
id
|
|
477
|
-
status:
|
|
478
|
-
statusText:
|
|
546
|
+
id,
|
|
547
|
+
status: xhr.status,
|
|
548
|
+
statusText: xhr.statusText,
|
|
479
549
|
headers: responseHeaders,
|
|
480
550
|
body: responseBody,
|
|
481
551
|
size,
|
|
@@ -485,34 +555,20 @@ var init_xhr_interceptor = __esm({
|
|
|
485
555
|
};
|
|
486
556
|
(_b2 = (_a2 = self.handlers).onResponse) == null ? void 0 : _b2.call(_a2, response);
|
|
487
557
|
});
|
|
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]);
|
|
558
|
+
listen(this, "error", () => fail("Network request failed"));
|
|
559
|
+
listen(this, "timeout", () => fail(`Request timeout after ${xhr.timeout}ms`));
|
|
560
|
+
listen(this, "abort", () => fail("Request aborted"));
|
|
561
|
+
listen(this, "loadend", detach);
|
|
562
|
+
this._devinspectorCancel = cancel;
|
|
563
|
+
try {
|
|
564
|
+
return self.originalSend.apply(this, [body]);
|
|
565
|
+
} catch (error) {
|
|
566
|
+
if (!ended) {
|
|
567
|
+
detach();
|
|
568
|
+
fail(error instanceof Error ? error.message : String(error));
|
|
569
|
+
}
|
|
570
|
+
throw error;
|
|
571
|
+
}
|
|
516
572
|
};
|
|
517
573
|
this.installed = {
|
|
518
574
|
open: XMLHttpRequest.prototype.open,
|
|
@@ -523,9 +579,14 @@ var init_xhr_interceptor = __esm({
|
|
|
523
579
|
uninstall() {
|
|
524
580
|
if (!this.installed) return;
|
|
525
581
|
const proto = XMLHttpRequest.prototype;
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
582
|
+
restorePatch(proto, "open", this.installed.open, this.originalOpen);
|
|
583
|
+
restorePatch(proto, "send", this.installed.send, this.originalSend);
|
|
584
|
+
restorePatch(
|
|
585
|
+
proto,
|
|
586
|
+
"setRequestHeader",
|
|
587
|
+
this.installed.setRequestHeader,
|
|
588
|
+
this.originalSetRequestHeader
|
|
589
|
+
);
|
|
529
590
|
this.installed = null;
|
|
530
591
|
}
|
|
531
592
|
sanitizeBody(body) {
|
|
@@ -624,6 +685,7 @@ var WebSocketMonitor;
|
|
|
624
685
|
var init_websocket_monitor = __esm({
|
|
625
686
|
"src/monitors/network/websocket-monitor.ts"() {
|
|
626
687
|
"use strict";
|
|
688
|
+
init_patches();
|
|
627
689
|
init_utils();
|
|
628
690
|
WebSocketMonitor = class {
|
|
629
691
|
constructor(handlers = {}) {
|
|
@@ -637,8 +699,14 @@ var init_websocket_monitor = __esm({
|
|
|
637
699
|
const OriginalWebSocket = this.originalWebSocket;
|
|
638
700
|
if (typeof OriginalWebSocket !== "function" || this.installed) return;
|
|
639
701
|
const MonitoredWebSocket = function(url, protocols) {
|
|
640
|
-
var _a, _b;
|
|
641
|
-
const
|
|
702
|
+
var _a, _b, _c;
|
|
703
|
+
const args = protocols === void 0 ? [url] : [url, protocols];
|
|
704
|
+
const ws = Reflect.construct(
|
|
705
|
+
OriginalWebSocket,
|
|
706
|
+
args,
|
|
707
|
+
(_a = new.target) != null ? _a : OriginalWebSocket
|
|
708
|
+
);
|
|
709
|
+
if (self.installed !== MonitoredWebSocket) return ws;
|
|
642
710
|
const connectionId = generateId();
|
|
643
711
|
ws._devinspectorId = connectionId;
|
|
644
712
|
ws._devinspectorUrl = url.toString();
|
|
@@ -652,7 +720,7 @@ var init_websocket_monitor = __esm({
|
|
|
652
720
|
status: "connecting"
|
|
653
721
|
};
|
|
654
722
|
self.connections.set(connectionId, connection);
|
|
655
|
-
(
|
|
723
|
+
(_c = (_b = self.handlers).onConnection) == null ? void 0 : _c.call(_b, connection);
|
|
656
724
|
ws.addEventListener("open", function() {
|
|
657
725
|
var _a2, _b2;
|
|
658
726
|
const conn = self.connections.get(connectionId);
|
|
@@ -736,9 +804,7 @@ var init_websocket_monitor = __esm({
|
|
|
736
804
|
window.WebSocket = MonitoredWebSocket;
|
|
737
805
|
}
|
|
738
806
|
uninstall() {
|
|
739
|
-
if (this.installed
|
|
740
|
-
window.WebSocket = this.originalWebSocket;
|
|
741
|
-
}
|
|
807
|
+
if (this.installed) restorePatch(window, "WebSocket", this.installed, this.originalWebSocket);
|
|
742
808
|
this.installed = null;
|
|
743
809
|
this.connections.clear();
|
|
744
810
|
}
|
|
@@ -1014,6 +1080,7 @@ var ConsoleInterceptor;
|
|
|
1014
1080
|
var init_console_interceptor = __esm({
|
|
1015
1081
|
"src/monitors/console/console-interceptor.ts"() {
|
|
1016
1082
|
"use strict";
|
|
1083
|
+
init_patches();
|
|
1017
1084
|
init_utils();
|
|
1018
1085
|
ConsoleInterceptor = class {
|
|
1019
1086
|
constructor(handlers = {}, captureStackTraces = true) {
|
|
@@ -1059,9 +1126,7 @@ var init_console_interceptor = __esm({
|
|
|
1059
1126
|
}
|
|
1060
1127
|
uninstall() {
|
|
1061
1128
|
this.originalMethods.forEach((original, method) => {
|
|
1062
|
-
|
|
1063
|
-
console[method] = original;
|
|
1064
|
-
}
|
|
1129
|
+
restorePatch(console, method, this.wrappers.get(method), original);
|
|
1065
1130
|
});
|
|
1066
1131
|
this.originalMethods.clear();
|
|
1067
1132
|
this.wrappers.clear();
|
|
@@ -1429,7 +1494,10 @@ var init_log_formatter = __esm({
|
|
|
1429
1494
|
"default"
|
|
1430
1495
|
];
|
|
1431
1496
|
let highlighted = code;
|
|
1432
|
-
highlighted = highlighted.replace(
|
|
1497
|
+
highlighted = highlighted.replace(
|
|
1498
|
+
/(["'`])(?:(?=(\\?))\2.)*?\1/g,
|
|
1499
|
+
'<span class="string">$&</span>'
|
|
1500
|
+
);
|
|
1433
1501
|
highlighted = highlighted.replace(/\b(\d+)\b/g, '<span class="number">$1</span>');
|
|
1434
1502
|
keywords.forEach((keyword) => {
|
|
1435
1503
|
const regex = new RegExp(`\\b${keyword}\\b`, "g");
|
|
@@ -1461,10 +1529,13 @@ var init_console_monitor = __esm({
|
|
|
1461
1529
|
this.historyIndex = -1;
|
|
1462
1530
|
this.inspector = inspector;
|
|
1463
1531
|
this.formatter = new LogFormatter();
|
|
1464
|
-
this.interceptor = new ConsoleInterceptor(
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1532
|
+
this.interceptor = new ConsoleInterceptor(
|
|
1533
|
+
{
|
|
1534
|
+
onLog: this.handleLog.bind(this),
|
|
1535
|
+
onClear: this.handleClear.bind(this)
|
|
1536
|
+
},
|
|
1537
|
+
inspector.getConfig().captureStackTraces
|
|
1538
|
+
);
|
|
1468
1539
|
}
|
|
1469
1540
|
start() {
|
|
1470
1541
|
if (this.isActive) return;
|
|
@@ -1962,10 +2033,12 @@ var init_long_task_detector = __esm({
|
|
|
1962
2033
|
duration: Math.round(deltaTime),
|
|
1963
2034
|
startTime: Math.round(lastTime),
|
|
1964
2035
|
timestamp: Date.now(),
|
|
1965
|
-
attribution: [
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
2036
|
+
attribution: [
|
|
2037
|
+
{
|
|
2038
|
+
name: "unknown",
|
|
2039
|
+
containerType: "window"
|
|
2040
|
+
}
|
|
2041
|
+
]
|
|
1969
2042
|
};
|
|
1970
2043
|
this.callback(task);
|
|
1971
2044
|
}
|
|
@@ -2173,6 +2246,10 @@ var init_performance_monitor = __esm({
|
|
|
2173
2246
|
});
|
|
2174
2247
|
|
|
2175
2248
|
// src/monitors/error/error-tracker.ts
|
|
2249
|
+
function isInstance(value, name) {
|
|
2250
|
+
const ctor = globalThis[name];
|
|
2251
|
+
return typeof ctor !== "function" || value instanceof ctor;
|
|
2252
|
+
}
|
|
2176
2253
|
var ErrorTracker;
|
|
2177
2254
|
var init_error_tracker = __esm({
|
|
2178
2255
|
"src/monitors/error/error-tracker.ts"() {
|
|
@@ -2230,7 +2307,7 @@ var init_error_tracker = __esm({
|
|
|
2230
2307
|
message: error.message,
|
|
2231
2308
|
stack: error.stack
|
|
2232
2309
|
};
|
|
2233
|
-
} else if ("message" in error && error
|
|
2310
|
+
} else if ("message" in error && isInstance(error, "ErrorEvent")) {
|
|
2234
2311
|
message = error.message;
|
|
2235
2312
|
source = error.filename;
|
|
2236
2313
|
lineno = error.lineno;
|
|
@@ -2239,7 +2316,7 @@ var init_error_tracker = __esm({
|
|
|
2239
2316
|
stack = error.error.stack ? error.error.stack.split("\n").map((line) => line.trim()) : [];
|
|
2240
2317
|
errorObject = error.error;
|
|
2241
2318
|
}
|
|
2242
|
-
} else if ("reason" in error && error
|
|
2319
|
+
} else if ("reason" in error && isInstance(error, "PromiseRejectionEvent")) {
|
|
2243
2320
|
const reason = error.reason;
|
|
2244
2321
|
if (reason instanceof Error) {
|
|
2245
2322
|
message = reason.message || reason.toString();
|
|
@@ -2307,10 +2384,7 @@ var init_error_tracker = __esm({
|
|
|
2307
2384
|
return group;
|
|
2308
2385
|
}
|
|
2309
2386
|
generateFingerprint(errorInfo) {
|
|
2310
|
-
const parts = [
|
|
2311
|
-
errorInfo.type,
|
|
2312
|
-
this.normalizeMessage(errorInfo.message)
|
|
2313
|
-
];
|
|
2387
|
+
const parts = [errorInfo.type, this.normalizeMessage(errorInfo.message)];
|
|
2314
2388
|
if (errorInfo.stackFrames && errorInfo.stackFrames.length > 0) {
|
|
2315
2389
|
const topFrame = errorInfo.stackFrames[0];
|
|
2316
2390
|
if (topFrame.fileName) {
|
|
@@ -2400,11 +2474,7 @@ var init_source_map_support = __esm({
|
|
|
2400
2474
|
if (!sourceMapUrl) return frame;
|
|
2401
2475
|
const sourceMap = await this.loadSourceMap(fileUrl, sourceMapUrl);
|
|
2402
2476
|
if (!sourceMap) return frame;
|
|
2403
|
-
const originalPosition = this.getOriginalPosition(
|
|
2404
|
-
sourceMap,
|
|
2405
|
-
lineNumber,
|
|
2406
|
-
columnNumber
|
|
2407
|
-
);
|
|
2477
|
+
const originalPosition = this.getOriginalPosition(sourceMap, lineNumber, columnNumber);
|
|
2408
2478
|
if (originalPosition) {
|
|
2409
2479
|
const functionPart = functionName ? `${functionName} ` : "";
|
|
2410
2480
|
return `at ${functionPart}(${originalPosition.source}:${originalPosition.line}:${originalPosition.column})`;
|
|
@@ -2510,15 +2580,13 @@ var init_error_monitor = __esm({
|
|
|
2510
2580
|
ErrorMonitor = class {
|
|
2511
2581
|
constructor(inspector) {
|
|
2512
2582
|
this.isActive = false;
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
unhandledrejection: null
|
|
2516
|
-
};
|
|
2583
|
+
/** Set while a window error/rejection event is being tracked (vs. trackError()). */
|
|
2584
|
+
this.trackingUncaught = false;
|
|
2517
2585
|
this.handleErrorEvent = (event) => {
|
|
2518
|
-
this.errorTracker.trackError(event, "error");
|
|
2586
|
+
this.trackUncaught(() => this.errorTracker.trackError(event, "error"));
|
|
2519
2587
|
};
|
|
2520
2588
|
this.handleRejectionEvent = (event) => {
|
|
2521
|
-
this.errorTracker.trackError(event, "unhandledRejection");
|
|
2589
|
+
this.trackUncaught(() => this.errorTracker.trackError(event, "unhandledRejection"));
|
|
2522
2590
|
};
|
|
2523
2591
|
this.inspector = inspector;
|
|
2524
2592
|
this.errorTracker = new ErrorTracker(this.handleError.bind(this));
|
|
@@ -2534,42 +2602,28 @@ var init_error_monitor = __esm({
|
|
|
2534
2602
|
this.uninstallErrorHandlers();
|
|
2535
2603
|
this.isActive = false;
|
|
2536
2604
|
}
|
|
2605
|
+
// One subscription per event type: window.onerror / onunhandledrejection are left
|
|
2606
|
+
// to the page (setting them as well reported every error twice and returning true
|
|
2607
|
+
// from onerror hid the error from the browser console).
|
|
2537
2608
|
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
2609
|
window.addEventListener("error", this.handleErrorEvent);
|
|
2563
2610
|
window.addEventListener("unhandledrejection", this.handleRejectionEvent);
|
|
2564
2611
|
}
|
|
2565
2612
|
uninstallErrorHandlers() {
|
|
2566
|
-
window.onerror = this.originalHandlers.error;
|
|
2567
|
-
window.onunhandledrejection = this.originalHandlers.unhandledrejection;
|
|
2568
2613
|
window.removeEventListener("error", this.handleErrorEvent);
|
|
2569
2614
|
window.removeEventListener("unhandledrejection", this.handleRejectionEvent);
|
|
2570
2615
|
}
|
|
2616
|
+
trackUncaught(track) {
|
|
2617
|
+
this.trackingUncaught = true;
|
|
2618
|
+
try {
|
|
2619
|
+
track();
|
|
2620
|
+
} finally {
|
|
2621
|
+
this.trackingUncaught = false;
|
|
2622
|
+
}
|
|
2623
|
+
}
|
|
2571
2624
|
async handleError(errorInfo) {
|
|
2572
2625
|
var _a, _b;
|
|
2626
|
+
const uncaught = this.trackingUncaught;
|
|
2573
2627
|
if (errorInfo.stack && this.sourceMapSupport.isEnabled()) {
|
|
2574
2628
|
try {
|
|
2575
2629
|
errorInfo.stack = await this.sourceMapSupport.enhanceStackTrace(errorInfo.stack);
|
|
@@ -2579,14 +2633,8 @@ var init_error_monitor = __esm({
|
|
|
2579
2633
|
}
|
|
2580
2634
|
const storage = this.inspector.getStorage("error");
|
|
2581
2635
|
storage.push(errorInfo);
|
|
2582
|
-
this.inspector.getEvents().emit(
|
|
2583
|
-
errorInfo.type === "unhandledRejection" ? "error:uncaught" : "error:caught",
|
|
2584
|
-
errorInfo
|
|
2585
|
-
);
|
|
2636
|
+
this.inspector.getEvents().emit(uncaught ? "error:uncaught" : "error:caught", errorInfo);
|
|
2586
2637
|
(_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
2638
|
}
|
|
2591
2639
|
// Public API
|
|
2592
2640
|
trackError(error) {
|
|
@@ -2785,7 +2833,9 @@ var init_floating_widget = __esm({
|
|
|
2785
2833
|
top: centerY,
|
|
2786
2834
|
bottom: windowHeight - centerY
|
|
2787
2835
|
};
|
|
2788
|
-
const closestEdge = Object.entries(distances).reduce(
|
|
2836
|
+
const closestEdge = Object.entries(distances).reduce(
|
|
2837
|
+
(a, b) => a[1] < b[1] ? a : b
|
|
2838
|
+
)[0];
|
|
2789
2839
|
const margin = 20;
|
|
2790
2840
|
switch (closestEdge) {
|
|
2791
2841
|
case "left":
|
|
@@ -3044,11 +3094,15 @@ var init_main_panel = __esm({
|
|
|
3044
3094
|
removeTab(tabId) {
|
|
3045
3095
|
if (!this.tabs.has(tabId)) return;
|
|
3046
3096
|
this.tabs.delete(tabId);
|
|
3047
|
-
const tab = Array.from(
|
|
3097
|
+
const tab = Array.from(
|
|
3098
|
+
this.tabsElement.querySelectorAll(".devinspector-tab")
|
|
3099
|
+
).find((el) => el.dataset.tabId === tabId);
|
|
3048
3100
|
if (tab) {
|
|
3049
3101
|
tab.remove();
|
|
3050
3102
|
}
|
|
3051
|
-
const panel = Array.from(
|
|
3103
|
+
const panel = Array.from(
|
|
3104
|
+
this.bodyElement.querySelectorAll(".devinspector-panel")
|
|
3105
|
+
).find((el) => el.dataset.panelId === tabId);
|
|
3052
3106
|
if (panel) {
|
|
3053
3107
|
panel.remove();
|
|
3054
3108
|
}
|
|
@@ -3077,7 +3131,9 @@ var init_main_panel = __esm({
|
|
|
3077
3131
|
this.tabs.forEach((config, tabId) => {
|
|
3078
3132
|
if (config.badge) {
|
|
3079
3133
|
const count = config.badge();
|
|
3080
|
-
const tab = Array.from(
|
|
3134
|
+
const tab = Array.from(
|
|
3135
|
+
this.tabsElement.querySelectorAll(".devinspector-tab")
|
|
3136
|
+
).find((el) => el.dataset.tabId === tabId);
|
|
3081
3137
|
const badge = tab == null ? void 0 : tab.querySelector(".devinspector-tab-badge");
|
|
3082
3138
|
if (badge) {
|
|
3083
3139
|
badge.textContent = count.toString();
|
|
@@ -3867,7 +3923,9 @@ var init_inspector_ui = __esm({
|
|
|
3867
3923
|
list.appendChild(entry);
|
|
3868
3924
|
}
|
|
3869
3925
|
updateNetworkEntry(panel, response) {
|
|
3870
|
-
const entry = Array.from(panel.querySelectorAll("[data-request-id]")).find(
|
|
3926
|
+
const entry = Array.from(panel.querySelectorAll("[data-request-id]")).find(
|
|
3927
|
+
(el) => el.dataset.requestId === String(response.id)
|
|
3928
|
+
);
|
|
3871
3929
|
if (!entry) return;
|
|
3872
3930
|
const status = entry.querySelector(".devinspector-status");
|
|
3873
3931
|
if (status) {
|
|
@@ -4064,6 +4122,9 @@ var EventEmitter = class {
|
|
|
4064
4122
|
}
|
|
4065
4123
|
};
|
|
4066
4124
|
|
|
4125
|
+
// src/enhanced-simple.ts
|
|
4126
|
+
init_patches();
|
|
4127
|
+
|
|
4067
4128
|
// src/core/plugin-system.ts
|
|
4068
4129
|
var PluginSystem = class {
|
|
4069
4130
|
constructor(context) {
|
|
@@ -4102,17 +4163,20 @@ var PluginSystem = class {
|
|
|
4102
4163
|
if (!plugin) {
|
|
4103
4164
|
throw new Error(`Plugin "${pluginName}" is not registered`);
|
|
4104
4165
|
}
|
|
4105
|
-
|
|
4106
|
-
plugin.disable
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4166
|
+
try {
|
|
4167
|
+
if (plugin.disable) {
|
|
4168
|
+
plugin.disable();
|
|
4169
|
+
}
|
|
4170
|
+
if (plugin.uninstall) {
|
|
4171
|
+
await plugin.uninstall();
|
|
4172
|
+
}
|
|
4173
|
+
} finally {
|
|
4174
|
+
this.plugins.delete(pluginName);
|
|
4175
|
+
this.activePlugins.delete(pluginName);
|
|
4176
|
+
this.context.events.emit("plugin:unregistered", {
|
|
4177
|
+
name: pluginName
|
|
4178
|
+
});
|
|
4110
4179
|
}
|
|
4111
|
-
this.plugins.delete(pluginName);
|
|
4112
|
-
this.activePlugins.delete(pluginName);
|
|
4113
|
-
this.context.events.emit("plugin:unregistered", {
|
|
4114
|
-
name: pluginName
|
|
4115
|
-
});
|
|
4116
4180
|
}
|
|
4117
4181
|
enable(pluginName) {
|
|
4118
4182
|
const plugin = this.plugins.get(pluginName);
|
|
@@ -4223,7 +4287,7 @@ var BasePlugin = class {
|
|
|
4223
4287
|
};
|
|
4224
4288
|
|
|
4225
4289
|
// src/version.ts
|
|
4226
|
-
var VERSION = "1.
|
|
4290
|
+
var VERSION = "1.5.0";
|
|
4227
4291
|
|
|
4228
4292
|
// src/enhanced-simple.ts
|
|
4229
4293
|
var CONSOLE_METHODS = ["log", "info", "warn", "error", "debug"];
|
|
@@ -4232,28 +4296,57 @@ var MAX_METRIC_ENTRIES = 500;
|
|
|
4232
4296
|
var ASSET_PATTERN = /\.(?:css|js|mjs|map|png|jpe?g|gif|svg|webp|avif|ico|woff2?|ttf|otf|eot)(?:[?#]|$)/i;
|
|
4233
4297
|
var POSITIONS = ["top-left", "top-right", "bottom-left", "bottom-right"];
|
|
4234
4298
|
var PALETTES = {
|
|
4235
|
-
dark: {
|
|
4236
|
-
|
|
4299
|
+
dark: {
|
|
4300
|
+
bg: "#1a1a1a",
|
|
4301
|
+
header: "#262626",
|
|
4302
|
+
toolbar: "#1e1e1e",
|
|
4303
|
+
border: "#333",
|
|
4304
|
+
row: "#2a2a2a",
|
|
4305
|
+
text: "#e4e4e7",
|
|
4306
|
+
muted: "#9ca3af",
|
|
4307
|
+
code: "#0f0f0f"
|
|
4308
|
+
},
|
|
4309
|
+
light: {
|
|
4310
|
+
bg: "#ffffff",
|
|
4311
|
+
header: "#f3f4f6",
|
|
4312
|
+
toolbar: "#f9fafb",
|
|
4313
|
+
border: "#d1d5db",
|
|
4314
|
+
row: "#e5e7eb",
|
|
4315
|
+
text: "#111827",
|
|
4316
|
+
muted: "#4b5563",
|
|
4317
|
+
code: "#f3f4f6"
|
|
4318
|
+
}
|
|
4237
4319
|
};
|
|
4238
4320
|
var idCounter = 0;
|
|
4239
4321
|
function nextId() {
|
|
4240
4322
|
idCounter = (idCounter + 1) % Number.MAX_SAFE_INTEGER;
|
|
4241
4323
|
return `${Date.now().toString(36)}-${idCounter.toString(36)}`;
|
|
4242
4324
|
}
|
|
4243
|
-
function limit(value, fallback) {
|
|
4244
|
-
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.floor(value) : fallback;
|
|
4245
|
-
}
|
|
4246
4325
|
function normalizeCombo(combo) {
|
|
4247
4326
|
if (typeof combo !== "string") return "";
|
|
4248
4327
|
const parts = combo.toLowerCase().split("+").map((part) => part.trim()).filter(Boolean);
|
|
4249
|
-
const key = parts.filter(
|
|
4328
|
+
const key = parts.filter(
|
|
4329
|
+
(part) => !["ctrl", "control", "alt", "shift", "meta", "cmd"].includes(part)
|
|
4330
|
+
);
|
|
4250
4331
|
if (key.length !== 1) return "";
|
|
4251
4332
|
const has = (...names) => names.some((name) => parts.includes(name));
|
|
4252
|
-
return [
|
|
4333
|
+
return [
|
|
4334
|
+
has("ctrl", "control") && "ctrl",
|
|
4335
|
+
has("alt") && "alt",
|
|
4336
|
+
has("shift") && "shift",
|
|
4337
|
+
has("meta", "cmd") && "meta",
|
|
4338
|
+
key[0]
|
|
4339
|
+
].filter(Boolean).join("+");
|
|
4253
4340
|
}
|
|
4254
4341
|
function eventCombo(event) {
|
|
4255
4342
|
if (typeof event.key !== "string") return "";
|
|
4256
|
-
return [
|
|
4343
|
+
return [
|
|
4344
|
+
event.ctrlKey && "ctrl",
|
|
4345
|
+
event.altKey && "alt",
|
|
4346
|
+
event.shiftKey && "shift",
|
|
4347
|
+
event.metaKey && "meta",
|
|
4348
|
+
event.key.toLowerCase()
|
|
4349
|
+
].filter(Boolean).join("+");
|
|
4257
4350
|
}
|
|
4258
4351
|
function truncate(text) {
|
|
4259
4352
|
return text.length > MAX_MESSAGE_LENGTH ? `${text.slice(0, MAX_MESSAGE_LENGTH)}\u2026 (${text.length - MAX_MESSAGE_LENGTH} more characters)` : text;
|
|
@@ -4364,7 +4457,9 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4364
4457
|
this.setupHotkeys();
|
|
4365
4458
|
this.mountWhenReady();
|
|
4366
4459
|
for (const plugin of (_a = config.plugins) != null ? _a : []) {
|
|
4367
|
-
this.use(plugin).catch((error) =>
|
|
4460
|
+
this.use(plugin).catch((error) => {
|
|
4461
|
+
if (!this.destroyed) this.reportInternal("Failed to register plugin", error);
|
|
4462
|
+
});
|
|
4368
4463
|
}
|
|
4369
4464
|
this.events.emit("inspector:ready");
|
|
4370
4465
|
}
|
|
@@ -4399,12 +4494,12 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4399
4494
|
performance: features.performance !== false,
|
|
4400
4495
|
errors: features.errors !== false
|
|
4401
4496
|
},
|
|
4402
|
-
maxNetworkEntries:
|
|
4403
|
-
maxConsoleEntries:
|
|
4404
|
-
maxErrorEntries:
|
|
4497
|
+
maxNetworkEntries: normalizeLimit(config.maxNetworkEntries, 1e3),
|
|
4498
|
+
maxConsoleEntries: normalizeLimit(config.maxConsoleEntries, 500),
|
|
4499
|
+
maxErrorEntries: normalizeLimit(config.maxErrorEntries, 100),
|
|
4405
4500
|
captureStackTraces: config.captureStackTraces !== false,
|
|
4406
4501
|
hideAssets: ((_e = config.networkFilters) == null ? void 0 : _e.hideAssets) === true,
|
|
4407
|
-
slowRequestThreshold:
|
|
4502
|
+
slowRequestThreshold: normalizeLimit(config.slowRequestThreshold, 3e3),
|
|
4408
4503
|
onError: typeof config.onError === "function" ? config.onError : void 0,
|
|
4409
4504
|
onPerformanceIssue: typeof config.onPerformanceIssue === "function" ? config.onPerformanceIssue : void 0
|
|
4410
4505
|
};
|
|
@@ -4479,7 +4574,12 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4479
4574
|
/** Records a custom metric and emits `performance:metric`. */
|
|
4480
4575
|
track(name, data) {
|
|
4481
4576
|
if (!this.isEnabled) return;
|
|
4482
|
-
const entry = {
|
|
4577
|
+
const entry = {
|
|
4578
|
+
id: nextId(),
|
|
4579
|
+
name: String(name),
|
|
4580
|
+
data,
|
|
4581
|
+
timestamp: Date.now()
|
|
4582
|
+
};
|
|
4483
4583
|
this.pushBounded(this.metrics, entry, MAX_METRIC_ENTRIES);
|
|
4484
4584
|
this.emitSafely("performance:metric", entry);
|
|
4485
4585
|
this.scheduleRender();
|
|
@@ -4504,10 +4604,20 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4504
4604
|
const duration = performance.now() - start;
|
|
4505
4605
|
try {
|
|
4506
4606
|
(_a = performance.mark) == null ? void 0 : _a.call(performance, `devinspector-${key}-end`);
|
|
4507
|
-
(_b = performance.measure) == null ? void 0 : _b.call(
|
|
4607
|
+
(_b = performance.measure) == null ? void 0 : _b.call(
|
|
4608
|
+
performance,
|
|
4609
|
+
`devinspector-${key}`,
|
|
4610
|
+
`devinspector-${key}-start`,
|
|
4611
|
+
`devinspector-${key}-end`
|
|
4612
|
+
);
|
|
4508
4613
|
} catch (e) {
|
|
4509
4614
|
}
|
|
4510
|
-
const entry = {
|
|
4615
|
+
const entry = {
|
|
4616
|
+
id: nextId(),
|
|
4617
|
+
name: key,
|
|
4618
|
+
duration,
|
|
4619
|
+
timestamp: Date.now()
|
|
4620
|
+
};
|
|
4511
4621
|
this.pushBounded(this.metrics, entry, MAX_METRIC_ENTRIES);
|
|
4512
4622
|
this.emitSafely("performance:mark", entry);
|
|
4513
4623
|
this.scheduleRender();
|
|
@@ -4516,7 +4626,13 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4516
4626
|
/** Installs a plugin. Resolves once the plugin's install() has finished. */
|
|
4517
4627
|
use(plugin) {
|
|
4518
4628
|
if (this.destroyed) return Promise.reject(new Error("DevInspector has been destroyed"));
|
|
4519
|
-
return this.pluginSystem.register(plugin)
|
|
4629
|
+
return this.pluginSystem.register(plugin).then(async () => {
|
|
4630
|
+
if (!this.destroyed) return;
|
|
4631
|
+
await this.pluginSystem.unregister(plugin.name).catch(
|
|
4632
|
+
(error) => this.reportInternal(`Failed to uninstall plugin "${plugin.name}"`, error)
|
|
4633
|
+
);
|
|
4634
|
+
throw new Error("DevInspector has been destroyed");
|
|
4635
|
+
});
|
|
4520
4636
|
}
|
|
4521
4637
|
on(event, listener) {
|
|
4522
4638
|
return this.events.on(event, listener);
|
|
@@ -4546,9 +4662,12 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4546
4662
|
*/
|
|
4547
4663
|
import(snapshot) {
|
|
4548
4664
|
const data = snapshot && typeof snapshot === "object" ? snapshot.data : void 0;
|
|
4549
|
-
if (!data || typeof data !== "object")
|
|
4665
|
+
if (!data || typeof data !== "object")
|
|
4666
|
+
throw new TypeError("DevInspector.import() expects an object produced by export()");
|
|
4550
4667
|
const source = data;
|
|
4551
|
-
const list = (value) => Array.isArray(value) ? value.filter(
|
|
4668
|
+
const list = (value) => Array.isArray(value) ? value.filter(
|
|
4669
|
+
(item) => !!item && typeof item === "object"
|
|
4670
|
+
) : [];
|
|
4552
4671
|
const str = (value, fallback = "") => typeof value === "string" ? value : fallback;
|
|
4553
4672
|
const num = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
4554
4673
|
this.network = list(source.network).slice(0, this.config.maxNetworkEntries).map((item) => {
|
|
@@ -4605,7 +4724,7 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4605
4724
|
if (this.destroyed) return;
|
|
4606
4725
|
this.destroyed = true;
|
|
4607
4726
|
for (const patch of this.patches.reverse()) {
|
|
4608
|
-
|
|
4727
|
+
restorePatch(patch.target, patch.key, patch.replacement, patch.original);
|
|
4609
4728
|
}
|
|
4610
4729
|
this.patches = [];
|
|
4611
4730
|
for (const cleanup of this.cleanups.splice(0)) {
|
|
@@ -4620,7 +4739,9 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4620
4739
|
this.widget = null;
|
|
4621
4740
|
this.panel = null;
|
|
4622
4741
|
for (const plugin of this.pluginSystem.getAll()) {
|
|
4623
|
-
this.pluginSystem.unregister(plugin.name).catch(
|
|
4742
|
+
this.pluginSystem.unregister(plugin.name).catch(
|
|
4743
|
+
(error) => this.reportInternal(`Failed to uninstall plugin "${plugin.name}"`, error)
|
|
4744
|
+
);
|
|
4624
4745
|
}
|
|
4625
4746
|
this.emitSafely("inspector:destroy", void 0);
|
|
4626
4747
|
this.events.removeAllListeners();
|
|
@@ -4629,7 +4750,9 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4629
4750
|
this.errors = [];
|
|
4630
4751
|
this.metrics = [];
|
|
4631
4752
|
this.marks.clear();
|
|
4632
|
-
_EnhancedDevInspector.instances = _EnhancedDevInspector.instances.filter(
|
|
4753
|
+
_EnhancedDevInspector.instances = _EnhancedDevInspector.instances.filter(
|
|
4754
|
+
(instance) => instance !== this
|
|
4755
|
+
);
|
|
4633
4756
|
}
|
|
4634
4757
|
// ---------------------------------------------------------------------------
|
|
4635
4758
|
// Capture
|
|
@@ -4676,7 +4799,12 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4676
4799
|
if (error !== void 0) entry.error = error;
|
|
4677
4800
|
this.emitSafely(status === "error" ? "network:error" : "network:response", { ...entry });
|
|
4678
4801
|
if (duration > this.config.slowRequestThreshold) {
|
|
4679
|
-
const issue = {
|
|
4802
|
+
const issue = {
|
|
4803
|
+
type: "slow-network",
|
|
4804
|
+
message: `Slow network request: ${entry.url}`,
|
|
4805
|
+
url: entry.url,
|
|
4806
|
+
duration: entry.duration
|
|
4807
|
+
};
|
|
4680
4808
|
this.emitSafely("performance:issue", issue);
|
|
4681
4809
|
this.callUser(this.config.onPerformanceIssue, issue);
|
|
4682
4810
|
}
|
|
@@ -4690,7 +4818,14 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4690
4818
|
let entry = null;
|
|
4691
4819
|
const start = performance.now();
|
|
4692
4820
|
self.capture(() => {
|
|
4693
|
-
entry = {
|
|
4821
|
+
entry = {
|
|
4822
|
+
id: nextId(),
|
|
4823
|
+
type: "fetch",
|
|
4824
|
+
url: requestUrl(args[0]),
|
|
4825
|
+
method: requestMethod(args[0], args[1]),
|
|
4826
|
+
status: "pending",
|
|
4827
|
+
timestamp: Date.now()
|
|
4828
|
+
};
|
|
4694
4829
|
self.addNetworkEntry(entry);
|
|
4695
4830
|
});
|
|
4696
4831
|
if (!entry) return Reflect.apply(originalFetch, this, args);
|
|
@@ -4699,16 +4834,32 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4699
4834
|
try {
|
|
4700
4835
|
result = Reflect.apply(originalFetch, this, args);
|
|
4701
4836
|
} catch (error) {
|
|
4702
|
-
self.capture(
|
|
4837
|
+
self.capture(
|
|
4838
|
+
() => self.finishNetworkEntry(
|
|
4839
|
+
tracked,
|
|
4840
|
+
"error",
|
|
4841
|
+
performance.now() - start,
|
|
4842
|
+
error instanceof Error ? error.message : String(error)
|
|
4843
|
+
)
|
|
4844
|
+
);
|
|
4703
4845
|
throw error;
|
|
4704
4846
|
}
|
|
4705
4847
|
return Promise.resolve(result).then(
|
|
4706
4848
|
(response) => {
|
|
4707
|
-
self.capture(
|
|
4849
|
+
self.capture(
|
|
4850
|
+
() => self.finishNetworkEntry(tracked, response.status, performance.now() - start)
|
|
4851
|
+
);
|
|
4708
4852
|
return response;
|
|
4709
4853
|
},
|
|
4710
4854
|
(error) => {
|
|
4711
|
-
self.capture(
|
|
4855
|
+
self.capture(
|
|
4856
|
+
() => self.finishNetworkEntry(
|
|
4857
|
+
tracked,
|
|
4858
|
+
"error",
|
|
4859
|
+
performance.now() - start,
|
|
4860
|
+
error instanceof Error ? error.message : String(error)
|
|
4861
|
+
)
|
|
4862
|
+
);
|
|
4712
4863
|
throw error;
|
|
4713
4864
|
}
|
|
4714
4865
|
);
|
|
@@ -4723,23 +4874,51 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4723
4874
|
const originalSend = proto.send;
|
|
4724
4875
|
const self = this;
|
|
4725
4876
|
const open = function(...args) {
|
|
4877
|
+
var _a, _b;
|
|
4878
|
+
const result = Reflect.apply(originalOpen, this, args);
|
|
4726
4879
|
if (!self.destroyed) {
|
|
4727
|
-
self.xhrState.
|
|
4880
|
+
(_b = (_a = self.xhrState.get(this)) == null ? void 0 : _a.terminate) == null ? void 0 : _b.call(_a);
|
|
4881
|
+
self.xhrState.set(this, {
|
|
4882
|
+
method: typeof args[0] === "string" ? args[0].toUpperCase() : "GET",
|
|
4883
|
+
url: requestUrl(args[1])
|
|
4884
|
+
});
|
|
4728
4885
|
}
|
|
4729
|
-
return
|
|
4886
|
+
return result;
|
|
4730
4887
|
};
|
|
4731
4888
|
const send = function(...args) {
|
|
4889
|
+
var _a;
|
|
4732
4890
|
const state = self.xhrState.get(this);
|
|
4733
|
-
|
|
4734
|
-
|
|
4891
|
+
const tracking = {};
|
|
4892
|
+
if (state) self.capture(() => tracking.fail = self.trackXhr(this, state));
|
|
4893
|
+
try {
|
|
4894
|
+
return Reflect.apply(originalSend, this, args);
|
|
4895
|
+
} catch (error) {
|
|
4896
|
+
(_a = tracking.fail) == null ? void 0 : _a.call(tracking, error);
|
|
4897
|
+
throw error;
|
|
4898
|
+
}
|
|
4735
4899
|
};
|
|
4736
4900
|
this.patch(proto, "open", open);
|
|
4737
4901
|
this.patch(proto, "send", send);
|
|
4738
4902
|
}
|
|
4739
4903
|
trackXhr(xhr, state) {
|
|
4740
|
-
const
|
|
4904
|
+
const previous = {
|
|
4905
|
+
entry: state.entry,
|
|
4906
|
+
start: state.start,
|
|
4907
|
+
failure: state.failure,
|
|
4908
|
+
terminate: state.terminate
|
|
4909
|
+
};
|
|
4910
|
+
let settled = false;
|
|
4911
|
+
const entry = {
|
|
4912
|
+
id: nextId(),
|
|
4913
|
+
type: "xhr",
|
|
4914
|
+
url: state.url,
|
|
4915
|
+
method: state.method,
|
|
4916
|
+
status: "pending",
|
|
4917
|
+
timestamp: Date.now()
|
|
4918
|
+
};
|
|
4919
|
+
const startedAt = performance.now();
|
|
4741
4920
|
state.entry = entry;
|
|
4742
|
-
state.start =
|
|
4921
|
+
state.start = startedAt;
|
|
4743
4922
|
state.failure = void 0;
|
|
4744
4923
|
const fail = (reason) => () => {
|
|
4745
4924
|
state.failure = reason;
|
|
@@ -4747,25 +4926,59 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4747
4926
|
const onError = fail("Network error");
|
|
4748
4927
|
const onAbort = fail("Request aborted");
|
|
4749
4928
|
const onTimeout = fail("Request timed out");
|
|
4750
|
-
const
|
|
4751
|
-
var _a;
|
|
4929
|
+
const detach = () => {
|
|
4752
4930
|
xhr.removeEventListener("error", onError);
|
|
4753
4931
|
xhr.removeEventListener("abort", onAbort);
|
|
4754
4932
|
xhr.removeEventListener("timeout", onTimeout);
|
|
4755
4933
|
xhr.removeEventListener("loadend", onLoadEnd);
|
|
4756
|
-
|
|
4934
|
+
};
|
|
4935
|
+
const onLoadEnd = () => {
|
|
4936
|
+
var _a;
|
|
4937
|
+
detach();
|
|
4938
|
+
if (settled || state.entry !== entry || this.destroyed) return;
|
|
4939
|
+
settled = true;
|
|
4757
4940
|
const duration = performance.now() - ((_a = state.start) != null ? _a : performance.now());
|
|
4758
4941
|
const failed = state.failure !== void 0 || xhr.status === 0;
|
|
4759
|
-
this.capture(
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4942
|
+
this.capture(
|
|
4943
|
+
() => {
|
|
4944
|
+
var _a2;
|
|
4945
|
+
return this.finishNetworkEntry(
|
|
4946
|
+
entry,
|
|
4947
|
+
failed ? "error" : xhr.status,
|
|
4948
|
+
duration,
|
|
4949
|
+
failed ? (_a2 = state.failure) != null ? _a2 : "Network error" : void 0
|
|
4950
|
+
);
|
|
4951
|
+
}
|
|
4952
|
+
);
|
|
4763
4953
|
};
|
|
4764
4954
|
xhr.addEventListener("error", onError);
|
|
4765
4955
|
xhr.addEventListener("abort", onAbort);
|
|
4766
4956
|
xhr.addEventListener("timeout", onTimeout);
|
|
4767
4957
|
xhr.addEventListener("loadend", onLoadEnd);
|
|
4958
|
+
state.terminate = () => {
|
|
4959
|
+
detach();
|
|
4960
|
+
if (settled || this.destroyed) return;
|
|
4961
|
+
settled = true;
|
|
4962
|
+
this.capture(
|
|
4963
|
+
() => this.finishNetworkEntry(entry, "error", performance.now() - startedAt, "Request aborted")
|
|
4964
|
+
);
|
|
4965
|
+
};
|
|
4768
4966
|
this.addNetworkEntry(entry);
|
|
4967
|
+
return (error) => {
|
|
4968
|
+
detach();
|
|
4969
|
+
if (settled) return;
|
|
4970
|
+
settled = true;
|
|
4971
|
+
if (state.entry === entry) Object.assign(state, previous);
|
|
4972
|
+
if (this.destroyed) return;
|
|
4973
|
+
this.capture(
|
|
4974
|
+
() => this.finishNetworkEntry(
|
|
4975
|
+
entry,
|
|
4976
|
+
"error",
|
|
4977
|
+
performance.now() - startedAt,
|
|
4978
|
+
error instanceof Error ? error.message : String(error)
|
|
4979
|
+
)
|
|
4980
|
+
);
|
|
4981
|
+
};
|
|
4769
4982
|
}
|
|
4770
4983
|
interceptConsole() {
|
|
4771
4984
|
const self = this;
|
|
@@ -4773,7 +4986,11 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4773
4986
|
const original = console[level];
|
|
4774
4987
|
if (typeof original !== "function") continue;
|
|
4775
4988
|
const wrapper = function(...args) {
|
|
4776
|
-
const result = Reflect.apply(
|
|
4989
|
+
const result = Reflect.apply(
|
|
4990
|
+
original,
|
|
4991
|
+
this === void 0 ? console : this,
|
|
4992
|
+
args
|
|
4993
|
+
);
|
|
4777
4994
|
self.capture(() => {
|
|
4778
4995
|
const entry = {
|
|
4779
4996
|
id: nextId(),
|
|
@@ -4869,7 +5086,8 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4869
5086
|
// Performance loop (runs only while the panel is visible)
|
|
4870
5087
|
// ---------------------------------------------------------------------------
|
|
4871
5088
|
startPerformanceLoop() {
|
|
4872
|
-
if (!this.config.features.performance || this.rafId !== null || typeof requestAnimationFrame !== "function")
|
|
5089
|
+
if (!this.config.features.performance || this.rafId !== null || typeof requestAnimationFrame !== "function")
|
|
5090
|
+
return;
|
|
4873
5091
|
let last = performance.now();
|
|
4874
5092
|
let frames = 0;
|
|
4875
5093
|
const tick = () => {
|
|
@@ -4898,7 +5116,8 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4898
5116
|
this.rafId = requestAnimationFrame(tick);
|
|
4899
5117
|
}
|
|
4900
5118
|
stopPerformanceLoop() {
|
|
4901
|
-
if (this.rafId !== null && typeof cancelAnimationFrame === "function")
|
|
5119
|
+
if (this.rafId !== null && typeof cancelAnimationFrame === "function")
|
|
5120
|
+
cancelAnimationFrame(this.rafId);
|
|
4902
5121
|
this.rafId = null;
|
|
4903
5122
|
}
|
|
4904
5123
|
// ---------------------------------------------------------------------------
|
|
@@ -4969,7 +5188,9 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
4969
5188
|
break;
|
|
4970
5189
|
}
|
|
4971
5190
|
case "clear":
|
|
4972
|
-
this.clear(
|
|
5191
|
+
this.clear(
|
|
5192
|
+
(_b = actionable.getAttribute("data-target")) != null ? _b : "all"
|
|
5193
|
+
);
|
|
4973
5194
|
break;
|
|
4974
5195
|
case "toggle-recording":
|
|
4975
5196
|
this.toggleRecording();
|
|
@@ -5081,7 +5302,12 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
|
|
|
5081
5302
|
${selected.error ? `<div><strong>Error:</strong> ${escapeHtml(selected.error)}</div>` : ""}
|
|
5082
5303
|
</div>` : "";
|
|
5083
5304
|
return `${this.toolbar(
|
|
5084
|
-
button("clear", "Clear", 'data-target="network"') + button(
|
|
5305
|
+
button("clear", "Clear", 'data-target="network"') + button(
|
|
5306
|
+
"toggle-recording",
|
|
5307
|
+
this.isRecording ? "Pause" : "Resume",
|
|
5308
|
+
"",
|
|
5309
|
+
this.isRecording ? "#ef4444" : "#22c55e"
|
|
5310
|
+
),
|
|
5085
5311
|
`${visible.length} requests`
|
|
5086
5312
|
)}
|
|
5087
5313
|
<div style="flex: 1; overflow-y: auto;">${rows || this.empty("No network activity")}</div>${details}`;
|
|
@@ -5186,13 +5412,20 @@ var CircularStorage = class {
|
|
|
5186
5412
|
this.tail = 0;
|
|
5187
5413
|
this.size = 0;
|
|
5188
5414
|
this.idCounter = 0;
|
|
5189
|
-
|
|
5415
|
+
const { maxSize } = options;
|
|
5416
|
+
if (typeof maxSize !== "number" || !Number.isFinite(maxSize) || maxSize < 0) {
|
|
5417
|
+
throw new RangeError(
|
|
5418
|
+
`CircularStorage maxSize must be a non-negative finite number, got ${String(maxSize)}`
|
|
5419
|
+
);
|
|
5420
|
+
}
|
|
5421
|
+
this.maxSize = Math.floor(maxSize);
|
|
5190
5422
|
this.ttl = options.ttl;
|
|
5191
5423
|
this.onEvict = options.onEvict;
|
|
5192
5424
|
this.buffer = new Array(this.maxSize);
|
|
5193
5425
|
}
|
|
5194
5426
|
push(data) {
|
|
5195
5427
|
const id = `${Date.now()}-${++this.idCounter}`;
|
|
5428
|
+
if (this.maxSize === 0) return id;
|
|
5196
5429
|
const entry = {
|
|
5197
5430
|
id,
|
|
5198
5431
|
timestamp: Date.now(),
|
|
@@ -5272,6 +5505,7 @@ var CircularStorage = class {
|
|
|
5272
5505
|
return now - entry.timestamp > this.ttl;
|
|
5273
5506
|
}
|
|
5274
5507
|
removeExpired() {
|
|
5508
|
+
var _a;
|
|
5275
5509
|
if (!this.ttl) return 0;
|
|
5276
5510
|
const now = Date.now();
|
|
5277
5511
|
let removedCount = 0;
|
|
@@ -5281,8 +5515,8 @@ var CircularStorage = class {
|
|
|
5281
5515
|
const entry = this.buffer[index];
|
|
5282
5516
|
if (entry && !this.isExpired(entry, now)) {
|
|
5283
5517
|
validEntries.push(entry);
|
|
5284
|
-
} else if (entry
|
|
5285
|
-
this.onEvict(entry);
|
|
5518
|
+
} else if (entry) {
|
|
5519
|
+
(_a = this.onEvict) == null ? void 0 : _a.call(this, entry);
|
|
5286
5520
|
removedCount++;
|
|
5287
5521
|
}
|
|
5288
5522
|
}
|
|
@@ -5415,6 +5649,7 @@ var _DevInspector = class _DevInspector {
|
|
|
5415
5649
|
this.cleanupFunctions = [];
|
|
5416
5650
|
this.initPromise = null;
|
|
5417
5651
|
this.destroyed = false;
|
|
5652
|
+
this.uninstallingPlugins = /* @__PURE__ */ new Set();
|
|
5418
5653
|
if (_DevInspector.instance) {
|
|
5419
5654
|
console.warn("DevInspector instance already exists. Returning existing instance.");
|
|
5420
5655
|
return _DevInspector.instance;
|
|
@@ -5494,7 +5729,11 @@ var _DevInspector = class _DevInspector {
|
|
|
5494
5729
|
...config,
|
|
5495
5730
|
hotkeys: { ...defaultConfig.hotkeys, ...config.hotkeys },
|
|
5496
5731
|
features: { ...defaultConfig.features, ...config.features },
|
|
5497
|
-
networkFilters: { ...defaultConfig.networkFilters, ...config.networkFilters }
|
|
5732
|
+
networkFilters: { ...defaultConfig.networkFilters, ...config.networkFilters },
|
|
5733
|
+
// Invalid limits (negative, NaN, Infinity) fall back to the defaults, as in DevInspector.
|
|
5734
|
+
maxNetworkEntries: normalizeLimit(config.maxNetworkEntries, defaultConfig.maxNetworkEntries),
|
|
5735
|
+
maxConsoleEntries: normalizeLimit(config.maxConsoleEntries, defaultConfig.maxConsoleEntries),
|
|
5736
|
+
maxErrorEntries: normalizeLimit(config.maxErrorEntries, defaultConfig.maxErrorEntries)
|
|
5498
5737
|
};
|
|
5499
5738
|
}
|
|
5500
5739
|
init() {
|
|
@@ -5512,7 +5751,6 @@ var _DevInspector = class _DevInspector {
|
|
|
5512
5751
|
await this.registerPlugins();
|
|
5513
5752
|
if (this.destroyed) return this.teardown();
|
|
5514
5753
|
this.setupHotkeys();
|
|
5515
|
-
this.setupErrorHandlers();
|
|
5516
5754
|
this.initialized = true;
|
|
5517
5755
|
this.events.emit("inspector:ready");
|
|
5518
5756
|
} catch (error) {
|
|
@@ -5596,33 +5834,6 @@ var _DevInspector = class _DevInspector {
|
|
|
5596
5834
|
document.addEventListener("keydown", handleKeydown);
|
|
5597
5835
|
this.cleanupFunctions.push(() => document.removeEventListener("keydown", handleKeydown));
|
|
5598
5836
|
}
|
|
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
5837
|
getKeyCombo(event) {
|
|
5627
5838
|
const parts = [];
|
|
5628
5839
|
if (event.ctrlKey) parts.push("ctrl");
|
|
@@ -5684,6 +5895,17 @@ var _DevInspector = class _DevInspector {
|
|
|
5684
5895
|
this.ui = null;
|
|
5685
5896
|
this.cleanupFunctions.forEach((cleanup) => cleanup());
|
|
5686
5897
|
this.cleanupFunctions = [];
|
|
5898
|
+
this.uninstallPlugins();
|
|
5899
|
+
}
|
|
5900
|
+
/** Disables and uninstalls every registered plugin; failures are reported, not thrown. */
|
|
5901
|
+
uninstallPlugins(names = this.pluginSystem.getAll().map((plugin) => plugin.name)) {
|
|
5902
|
+
for (const name of names) {
|
|
5903
|
+
if (this.uninstallingPlugins.has(name)) continue;
|
|
5904
|
+
this.uninstallingPlugins.add(name);
|
|
5905
|
+
this.pluginSystem.unregister(name).catch((error) => {
|
|
5906
|
+
console.error(`DevInspector: failed to uninstall plugin "${name}"`, error);
|
|
5907
|
+
}).finally(() => this.uninstallingPlugins.delete(name));
|
|
5908
|
+
}
|
|
5687
5909
|
}
|
|
5688
5910
|
destroy() {
|
|
5689
5911
|
this.destroyed = true;
|
|
@@ -5715,7 +5937,12 @@ var _DevInspector = class _DevInspector {
|
|
|
5715
5937
|
}
|
|
5716
5938
|
}
|
|
5717
5939
|
async use(plugin) {
|
|
5940
|
+
if (this.destroyed) throw new Error("DevInspector has been destroyed");
|
|
5718
5941
|
await this.pluginSystem.register(plugin);
|
|
5942
|
+
if (this.destroyed) {
|
|
5943
|
+
this.uninstallPlugins([plugin.name]);
|
|
5944
|
+
throw new Error("DevInspector has been destroyed");
|
|
5945
|
+
}
|
|
5719
5946
|
}
|
|
5720
5947
|
export() {
|
|
5721
5948
|
return {
|