@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.
Files changed (45) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/chunk-5QIYNQ4C.js +19 -0
  3. package/dist/chunk-5QIYNQ4C.js.map +1 -0
  4. package/dist/{chunk-LNBLBFDA.js → chunk-NP2SAIEA.js} +23 -19
  5. package/dist/chunk-NP2SAIEA.js.map +1 -0
  6. package/dist/{chunk-KZ4SDSBO.js → chunk-WUYUDBSC.js} +5 -1
  7. package/dist/chunk-WUYUDBSC.js.map +1 -0
  8. package/dist/{console-monitor-AVTNZCED.js → console-monitor-AO67CSAK.js} +17 -10
  9. package/dist/console-monitor-AO67CSAK.js.map +1 -0
  10. package/dist/devinspector.umd.cjs +772 -491
  11. package/dist/devinspector.umd.cjs.map +1 -1
  12. package/dist/devinspector.umd.js +772 -491
  13. package/dist/devinspector.umd.js.map +1 -1
  14. package/dist/devinspector.umd.min.cjs +2 -2
  15. package/dist/devinspector.umd.min.cjs.map +1 -1
  16. package/dist/devinspector.umd.min.js +2 -2
  17. package/dist/devinspector.umd.min.js.map +1 -1
  18. package/dist/{dom-monitor-JHJVZYS4.js → dom-monitor-D6GHCDBP.js} +1 -1
  19. package/dist/{dom-monitor-JHJVZYS4.js.map → dom-monitor-D6GHCDBP.js.map} +1 -1
  20. package/dist/{error-monitor-3CRFREH3.js → error-monitor-AVTYBTS7.js} +27 -52
  21. package/dist/error-monitor-AVTYBTS7.js.map +1 -0
  22. package/dist/index.cjs +515 -287
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +4 -2
  25. package/dist/index.d.ts +4 -2
  26. package/dist/index.js +269 -99
  27. package/dist/index.js.map +1 -1
  28. package/dist/{inspector-ui-C7WSILKC.js → inspector-ui-TEAZXDPM.js} +17 -7
  29. package/dist/inspector-ui-TEAZXDPM.js.map +1 -0
  30. package/dist/{network-monitor-WNRL2JI7.js → network-monitor-QHVMB5F3.js} +154 -115
  31. package/dist/network-monitor-QHVMB5F3.js.map +1 -0
  32. package/dist/{performance-monitor-UKQFA7ZR.js → performance-monitor-ULNHXBYX.js} +8 -6
  33. package/dist/performance-monitor-ULNHXBYX.js.map +1 -0
  34. package/dist/{state-monitor-JGJLBAD7.js → state-monitor-UNAVEOGH.js} +1 -1
  35. package/dist/{state-monitor-JGJLBAD7.js.map → state-monitor-UNAVEOGH.js.map} +1 -1
  36. package/dist/{storage-monitor-3NPTWRTY.js → storage-monitor-5RCRXYMX.js} +1 -1
  37. package/dist/{storage-monitor-3NPTWRTY.js.map → storage-monitor-5RCRXYMX.js.map} +1 -1
  38. package/package.json +9 -3
  39. package/dist/chunk-KZ4SDSBO.js.map +0 -1
  40. package/dist/chunk-LNBLBFDA.js.map +0 -1
  41. package/dist/console-monitor-AVTNZCED.js.map +0 -1
  42. package/dist/error-monitor-3CRFREH3.js.map +0 -1
  43. package/dist/inspector-ui-C7WSILKC.js.map +0 -1
  44. package/dist/network-monitor-WNRL2JI7.js.map +0 -1
  45. package/dist/performance-monitor-UKQFA7ZR.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,8 +1,12 @@
1
1
  import {
2
2
  defaultEnabled,
3
3
  escapeHtml,
4
- hasDom
5
- } from "./chunk-KZ4SDSBO.js";
4
+ hasDom,
5
+ normalizeLimit
6
+ } from "./chunk-WUYUDBSC.js";
7
+ import {
8
+ restorePatch
9
+ } from "./chunk-5QIYNQ4C.js";
6
10
 
7
11
  // src/core/event-emitter.ts
8
12
  var EventEmitter = class {
@@ -130,17 +134,20 @@ var PluginSystem = class {
130
134
  if (!plugin) {
131
135
  throw new Error(`Plugin "${pluginName}" is not registered`);
132
136
  }
133
- if (plugin.disable) {
134
- plugin.disable();
135
- }
136
- if (plugin.uninstall) {
137
- await plugin.uninstall();
137
+ try {
138
+ if (plugin.disable) {
139
+ plugin.disable();
140
+ }
141
+ if (plugin.uninstall) {
142
+ await plugin.uninstall();
143
+ }
144
+ } finally {
145
+ this.plugins.delete(pluginName);
146
+ this.activePlugins.delete(pluginName);
147
+ this.context.events.emit("plugin:unregistered", {
148
+ name: pluginName
149
+ });
138
150
  }
139
- this.plugins.delete(pluginName);
140
- this.activePlugins.delete(pluginName);
141
- this.context.events.emit("plugin:unregistered", {
142
- name: pluginName
143
- });
144
151
  }
145
152
  enable(pluginName) {
146
153
  const plugin = this.plugins.get(pluginName);
@@ -251,7 +258,7 @@ var BasePlugin = class {
251
258
  };
252
259
 
253
260
  // src/version.ts
254
- var VERSION = "1.4.1";
261
+ var VERSION = "1.5.1";
255
262
 
256
263
  // src/enhanced-simple.ts
257
264
  var CONSOLE_METHODS = ["log", "info", "warn", "error", "debug"];
@@ -260,28 +267,57 @@ var MAX_METRIC_ENTRIES = 500;
260
267
  var ASSET_PATTERN = /\.(?:css|js|mjs|map|png|jpe?g|gif|svg|webp|avif|ico|woff2?|ttf|otf|eot)(?:[?#]|$)/i;
261
268
  var POSITIONS = ["top-left", "top-right", "bottom-left", "bottom-right"];
262
269
  var PALETTES = {
263
- dark: { bg: "#1a1a1a", header: "#262626", toolbar: "#1e1e1e", border: "#333", row: "#2a2a2a", text: "#e4e4e7", muted: "#9ca3af", code: "#0f0f0f" },
264
- light: { bg: "#ffffff", header: "#f3f4f6", toolbar: "#f9fafb", border: "#d1d5db", row: "#e5e7eb", text: "#111827", muted: "#4b5563", code: "#f3f4f6" }
270
+ dark: {
271
+ bg: "#1a1a1a",
272
+ header: "#262626",
273
+ toolbar: "#1e1e1e",
274
+ border: "#333",
275
+ row: "#2a2a2a",
276
+ text: "#e4e4e7",
277
+ muted: "#9ca3af",
278
+ code: "#0f0f0f"
279
+ },
280
+ light: {
281
+ bg: "#ffffff",
282
+ header: "#f3f4f6",
283
+ toolbar: "#f9fafb",
284
+ border: "#d1d5db",
285
+ row: "#e5e7eb",
286
+ text: "#111827",
287
+ muted: "#4b5563",
288
+ code: "#f3f4f6"
289
+ }
265
290
  };
266
291
  var idCounter = 0;
267
292
  function nextId() {
268
293
  idCounter = (idCounter + 1) % Number.MAX_SAFE_INTEGER;
269
294
  return `${Date.now().toString(36)}-${idCounter.toString(36)}`;
270
295
  }
271
- function limit(value, fallback) {
272
- return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.floor(value) : fallback;
273
- }
274
296
  function normalizeCombo(combo) {
275
297
  if (typeof combo !== "string") return "";
276
298
  const parts = combo.toLowerCase().split("+").map((part) => part.trim()).filter(Boolean);
277
- const key = parts.filter((part) => !["ctrl", "control", "alt", "shift", "meta", "cmd"].includes(part));
299
+ const key = parts.filter(
300
+ (part) => !["ctrl", "control", "alt", "shift", "meta", "cmd"].includes(part)
301
+ );
278
302
  if (key.length !== 1) return "";
279
303
  const has = (...names) => names.some((name) => parts.includes(name));
280
- return [has("ctrl", "control") && "ctrl", has("alt") && "alt", has("shift") && "shift", has("meta", "cmd") && "meta", key[0]].filter(Boolean).join("+");
304
+ return [
305
+ has("ctrl", "control") && "ctrl",
306
+ has("alt") && "alt",
307
+ has("shift") && "shift",
308
+ has("meta", "cmd") && "meta",
309
+ key[0]
310
+ ].filter(Boolean).join("+");
281
311
  }
282
312
  function eventCombo(event) {
283
313
  if (typeof event.key !== "string") return "";
284
- return [event.ctrlKey && "ctrl", event.altKey && "alt", event.shiftKey && "shift", event.metaKey && "meta", event.key.toLowerCase()].filter(Boolean).join("+");
314
+ return [
315
+ event.ctrlKey && "ctrl",
316
+ event.altKey && "alt",
317
+ event.shiftKey && "shift",
318
+ event.metaKey && "meta",
319
+ event.key.toLowerCase()
320
+ ].filter(Boolean).join("+");
285
321
  }
286
322
  function truncate(text) {
287
323
  return text.length > MAX_MESSAGE_LENGTH ? `${text.slice(0, MAX_MESSAGE_LENGTH)}\u2026 (${text.length - MAX_MESSAGE_LENGTH} more characters)` : text;
@@ -392,7 +428,9 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
392
428
  this.setupHotkeys();
393
429
  this.mountWhenReady();
394
430
  for (const plugin of (_a = config.plugins) != null ? _a : []) {
395
- this.use(plugin).catch((error) => this.reportInternal("Failed to register plugin", error));
431
+ this.use(plugin).catch((error) => {
432
+ if (!this.destroyed) this.reportInternal("Failed to register plugin", error);
433
+ });
396
434
  }
397
435
  this.events.emit("inspector:ready");
398
436
  }
@@ -427,12 +465,12 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
427
465
  performance: features.performance !== false,
428
466
  errors: features.errors !== false
429
467
  },
430
- maxNetworkEntries: limit(config.maxNetworkEntries, 1e3),
431
- maxConsoleEntries: limit(config.maxConsoleEntries, 500),
432
- maxErrorEntries: limit(config.maxErrorEntries, 100),
468
+ maxNetworkEntries: normalizeLimit(config.maxNetworkEntries, 1e3),
469
+ maxConsoleEntries: normalizeLimit(config.maxConsoleEntries, 500),
470
+ maxErrorEntries: normalizeLimit(config.maxErrorEntries, 100),
433
471
  captureStackTraces: config.captureStackTraces !== false,
434
472
  hideAssets: ((_e = config.networkFilters) == null ? void 0 : _e.hideAssets) === true,
435
- slowRequestThreshold: limit(config.slowRequestThreshold, 3e3),
473
+ slowRequestThreshold: normalizeLimit(config.slowRequestThreshold, 3e3),
436
474
  onError: typeof config.onError === "function" ? config.onError : void 0,
437
475
  onPerformanceIssue: typeof config.onPerformanceIssue === "function" ? config.onPerformanceIssue : void 0
438
476
  };
@@ -469,7 +507,7 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
469
507
  minimize() {
470
508
  if (!this.isEnabled) return;
471
509
  this.isMinimized = !this.isMinimized;
472
- if (this.panel) this.panel.style.height = this.isMinimized ? "48px" : "650px";
510
+ if (this.panel) this.panel.style.height = this.isMinimized ? "auto" : "650px";
473
511
  this.render();
474
512
  this.events.emit("inspector:minimize", this.isMinimized);
475
513
  }
@@ -507,7 +545,12 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
507
545
  /** Records a custom metric and emits `performance:metric`. */
508
546
  track(name, data) {
509
547
  if (!this.isEnabled) return;
510
- const entry = { id: nextId(), name: String(name), data, timestamp: Date.now() };
548
+ const entry = {
549
+ id: nextId(),
550
+ name: String(name),
551
+ data,
552
+ timestamp: Date.now()
553
+ };
511
554
  this.pushBounded(this.metrics, entry, MAX_METRIC_ENTRIES);
512
555
  this.emitSafely("performance:metric", entry);
513
556
  this.scheduleRender();
@@ -532,10 +575,20 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
532
575
  const duration = performance.now() - start;
533
576
  try {
534
577
  (_a = performance.mark) == null ? void 0 : _a.call(performance, `devinspector-${key}-end`);
535
- (_b = performance.measure) == null ? void 0 : _b.call(performance, `devinspector-${key}`, `devinspector-${key}-start`, `devinspector-${key}-end`);
578
+ (_b = performance.measure) == null ? void 0 : _b.call(
579
+ performance,
580
+ `devinspector-${key}`,
581
+ `devinspector-${key}-start`,
582
+ `devinspector-${key}-end`
583
+ );
536
584
  } catch (e) {
537
585
  }
538
- const entry = { id: nextId(), name: key, duration, timestamp: Date.now() };
586
+ const entry = {
587
+ id: nextId(),
588
+ name: key,
589
+ duration,
590
+ timestamp: Date.now()
591
+ };
539
592
  this.pushBounded(this.metrics, entry, MAX_METRIC_ENTRIES);
540
593
  this.emitSafely("performance:mark", entry);
541
594
  this.scheduleRender();
@@ -544,7 +597,13 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
544
597
  /** Installs a plugin. Resolves once the plugin's install() has finished. */
545
598
  use(plugin) {
546
599
  if (this.destroyed) return Promise.reject(new Error("DevInspector has been destroyed"));
547
- return this.pluginSystem.register(plugin);
600
+ return this.pluginSystem.register(plugin).then(async () => {
601
+ if (!this.destroyed) return;
602
+ await this.pluginSystem.unregister(plugin.name).catch(
603
+ (error) => this.reportInternal(`Failed to uninstall plugin "${plugin.name}"`, error)
604
+ );
605
+ throw new Error("DevInspector has been destroyed");
606
+ });
548
607
  }
549
608
  on(event, listener) {
550
609
  return this.events.on(event, listener);
@@ -574,9 +633,12 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
574
633
  */
575
634
  import(snapshot) {
576
635
  const data = snapshot && typeof snapshot === "object" ? snapshot.data : void 0;
577
- if (!data || typeof data !== "object") throw new TypeError("DevInspector.import() expects an object produced by export()");
636
+ if (!data || typeof data !== "object")
637
+ throw new TypeError("DevInspector.import() expects an object produced by export()");
578
638
  const source = data;
579
- const list = (value) => Array.isArray(value) ? value.filter((item) => !!item && typeof item === "object") : [];
639
+ const list = (value) => Array.isArray(value) ? value.filter(
640
+ (item) => !!item && typeof item === "object"
641
+ ) : [];
580
642
  const str = (value, fallback = "") => typeof value === "string" ? value : fallback;
581
643
  const num = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
582
644
  this.network = list(source.network).slice(0, this.config.maxNetworkEntries).map((item) => {
@@ -633,7 +695,7 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
633
695
  if (this.destroyed) return;
634
696
  this.destroyed = true;
635
697
  for (const patch of this.patches.reverse()) {
636
- if (patch.target[patch.key] === patch.replacement) patch.target[patch.key] = patch.original;
698
+ restorePatch(patch.target, patch.key, patch.replacement, patch.original);
637
699
  }
638
700
  this.patches = [];
639
701
  for (const cleanup of this.cleanups.splice(0)) {
@@ -648,7 +710,9 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
648
710
  this.widget = null;
649
711
  this.panel = null;
650
712
  for (const plugin of this.pluginSystem.getAll()) {
651
- this.pluginSystem.unregister(plugin.name).catch((error) => this.reportInternal(`Failed to uninstall plugin "${plugin.name}"`, error));
713
+ this.pluginSystem.unregister(plugin.name).catch(
714
+ (error) => this.reportInternal(`Failed to uninstall plugin "${plugin.name}"`, error)
715
+ );
652
716
  }
653
717
  this.emitSafely("inspector:destroy", void 0);
654
718
  this.events.removeAllListeners();
@@ -657,7 +721,9 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
657
721
  this.errors = [];
658
722
  this.metrics = [];
659
723
  this.marks.clear();
660
- _EnhancedDevInspector.instances = _EnhancedDevInspector.instances.filter((instance) => instance !== this);
724
+ _EnhancedDevInspector.instances = _EnhancedDevInspector.instances.filter(
725
+ (instance) => instance !== this
726
+ );
661
727
  }
662
728
  // ---------------------------------------------------------------------------
663
729
  // Capture
@@ -704,7 +770,12 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
704
770
  if (error !== void 0) entry.error = error;
705
771
  this.emitSafely(status === "error" ? "network:error" : "network:response", { ...entry });
706
772
  if (duration > this.config.slowRequestThreshold) {
707
- const issue = { type: "slow-network", message: `Slow network request: ${entry.url}`, url: entry.url, duration: entry.duration };
773
+ const issue = {
774
+ type: "slow-network",
775
+ message: `Slow network request: ${entry.url}`,
776
+ url: entry.url,
777
+ duration: entry.duration
778
+ };
708
779
  this.emitSafely("performance:issue", issue);
709
780
  this.callUser(this.config.onPerformanceIssue, issue);
710
781
  }
@@ -718,7 +789,14 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
718
789
  let entry = null;
719
790
  const start = performance.now();
720
791
  self.capture(() => {
721
- entry = { id: nextId(), type: "fetch", url: requestUrl(args[0]), method: requestMethod(args[0], args[1]), status: "pending", timestamp: Date.now() };
792
+ entry = {
793
+ id: nextId(),
794
+ type: "fetch",
795
+ url: requestUrl(args[0]),
796
+ method: requestMethod(args[0], args[1]),
797
+ status: "pending",
798
+ timestamp: Date.now()
799
+ };
722
800
  self.addNetworkEntry(entry);
723
801
  });
724
802
  if (!entry) return Reflect.apply(originalFetch, this, args);
@@ -727,16 +805,32 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
727
805
  try {
728
806
  result = Reflect.apply(originalFetch, this, args);
729
807
  } catch (error) {
730
- self.capture(() => self.finishNetworkEntry(tracked, "error", performance.now() - start, error instanceof Error ? error.message : String(error)));
808
+ self.capture(
809
+ () => self.finishNetworkEntry(
810
+ tracked,
811
+ "error",
812
+ performance.now() - start,
813
+ error instanceof Error ? error.message : String(error)
814
+ )
815
+ );
731
816
  throw error;
732
817
  }
733
818
  return Promise.resolve(result).then(
734
819
  (response) => {
735
- self.capture(() => self.finishNetworkEntry(tracked, response.status, performance.now() - start));
820
+ self.capture(
821
+ () => self.finishNetworkEntry(tracked, response.status, performance.now() - start)
822
+ );
736
823
  return response;
737
824
  },
738
825
  (error) => {
739
- self.capture(() => self.finishNetworkEntry(tracked, "error", performance.now() - start, error instanceof Error ? error.message : String(error)));
826
+ self.capture(
827
+ () => self.finishNetworkEntry(
828
+ tracked,
829
+ "error",
830
+ performance.now() - start,
831
+ error instanceof Error ? error.message : String(error)
832
+ )
833
+ );
740
834
  throw error;
741
835
  }
742
836
  );
@@ -751,23 +845,51 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
751
845
  const originalSend = proto.send;
752
846
  const self = this;
753
847
  const open = function(...args) {
848
+ var _a, _b;
849
+ const result = Reflect.apply(originalOpen, this, args);
754
850
  if (!self.destroyed) {
755
- self.xhrState.set(this, { method: typeof args[0] === "string" ? args[0].toUpperCase() : "GET", url: requestUrl(args[1]) });
851
+ (_b = (_a = self.xhrState.get(this)) == null ? void 0 : _a.terminate) == null ? void 0 : _b.call(_a);
852
+ self.xhrState.set(this, {
853
+ method: typeof args[0] === "string" ? args[0].toUpperCase() : "GET",
854
+ url: requestUrl(args[1])
855
+ });
756
856
  }
757
- return Reflect.apply(originalOpen, this, args);
857
+ return result;
758
858
  };
759
859
  const send = function(...args) {
860
+ var _a;
760
861
  const state = self.xhrState.get(this);
761
- if (state) self.capture(() => self.trackXhr(this, state));
762
- return Reflect.apply(originalSend, this, args);
862
+ const tracking = {};
863
+ if (state) self.capture(() => tracking.fail = self.trackXhr(this, state));
864
+ try {
865
+ return Reflect.apply(originalSend, this, args);
866
+ } catch (error) {
867
+ (_a = tracking.fail) == null ? void 0 : _a.call(tracking, error);
868
+ throw error;
869
+ }
763
870
  };
764
871
  this.patch(proto, "open", open);
765
872
  this.patch(proto, "send", send);
766
873
  }
767
874
  trackXhr(xhr, state) {
768
- const entry = { id: nextId(), type: "xhr", url: state.url, method: state.method, status: "pending", timestamp: Date.now() };
875
+ const previous = {
876
+ entry: state.entry,
877
+ start: state.start,
878
+ failure: state.failure,
879
+ terminate: state.terminate
880
+ };
881
+ let settled = false;
882
+ const entry = {
883
+ id: nextId(),
884
+ type: "xhr",
885
+ url: state.url,
886
+ method: state.method,
887
+ status: "pending",
888
+ timestamp: Date.now()
889
+ };
890
+ const startedAt = performance.now();
769
891
  state.entry = entry;
770
- state.start = performance.now();
892
+ state.start = startedAt;
771
893
  state.failure = void 0;
772
894
  const fail = (reason) => () => {
773
895
  state.failure = reason;
@@ -775,25 +897,59 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
775
897
  const onError = fail("Network error");
776
898
  const onAbort = fail("Request aborted");
777
899
  const onTimeout = fail("Request timed out");
778
- const onLoadEnd = () => {
779
- var _a;
900
+ const detach = () => {
780
901
  xhr.removeEventListener("error", onError);
781
902
  xhr.removeEventListener("abort", onAbort);
782
903
  xhr.removeEventListener("timeout", onTimeout);
783
904
  xhr.removeEventListener("loadend", onLoadEnd);
784
- if (state.entry !== entry || this.destroyed) return;
905
+ };
906
+ const onLoadEnd = () => {
907
+ var _a;
908
+ detach();
909
+ if (settled || state.entry !== entry || this.destroyed) return;
910
+ settled = true;
785
911
  const duration = performance.now() - ((_a = state.start) != null ? _a : performance.now());
786
912
  const failed = state.failure !== void 0 || xhr.status === 0;
787
- this.capture(() => {
788
- var _a2;
789
- return this.finishNetworkEntry(entry, failed ? "error" : xhr.status, duration, failed ? (_a2 = state.failure) != null ? _a2 : "Network error" : void 0);
790
- });
913
+ this.capture(
914
+ () => {
915
+ var _a2;
916
+ return this.finishNetworkEntry(
917
+ entry,
918
+ failed ? "error" : xhr.status,
919
+ duration,
920
+ failed ? (_a2 = state.failure) != null ? _a2 : "Network error" : void 0
921
+ );
922
+ }
923
+ );
791
924
  };
792
925
  xhr.addEventListener("error", onError);
793
926
  xhr.addEventListener("abort", onAbort);
794
927
  xhr.addEventListener("timeout", onTimeout);
795
928
  xhr.addEventListener("loadend", onLoadEnd);
929
+ state.terminate = () => {
930
+ detach();
931
+ if (settled || this.destroyed) return;
932
+ settled = true;
933
+ this.capture(
934
+ () => this.finishNetworkEntry(entry, "error", performance.now() - startedAt, "Request aborted")
935
+ );
936
+ };
796
937
  this.addNetworkEntry(entry);
938
+ return (error) => {
939
+ detach();
940
+ if (settled) return;
941
+ settled = true;
942
+ if (state.entry === entry) Object.assign(state, previous);
943
+ if (this.destroyed) return;
944
+ this.capture(
945
+ () => this.finishNetworkEntry(
946
+ entry,
947
+ "error",
948
+ performance.now() - startedAt,
949
+ error instanceof Error ? error.message : String(error)
950
+ )
951
+ );
952
+ };
797
953
  }
798
954
  interceptConsole() {
799
955
  const self = this;
@@ -801,7 +957,11 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
801
957
  const original = console[level];
802
958
  if (typeof original !== "function") continue;
803
959
  const wrapper = function(...args) {
804
- const result = Reflect.apply(original, this === void 0 ? console : this, args);
960
+ const result = Reflect.apply(
961
+ original,
962
+ this === void 0 ? console : this,
963
+ args
964
+ );
805
965
  self.capture(() => {
806
966
  const entry = {
807
967
  id: nextId(),
@@ -897,7 +1057,8 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
897
1057
  // Performance loop (runs only while the panel is visible)
898
1058
  // ---------------------------------------------------------------------------
899
1059
  startPerformanceLoop() {
900
- if (!this.config.features.performance || this.rafId !== null || typeof requestAnimationFrame !== "function") return;
1060
+ if (!this.config.features.performance || this.rafId !== null || typeof requestAnimationFrame !== "function")
1061
+ return;
901
1062
  let last = performance.now();
902
1063
  let frames = 0;
903
1064
  const tick = () => {
@@ -926,7 +1087,8 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
926
1087
  this.rafId = requestAnimationFrame(tick);
927
1088
  }
928
1089
  stopPerformanceLoop() {
929
- if (this.rafId !== null && typeof cancelAnimationFrame === "function") cancelAnimationFrame(this.rafId);
1090
+ if (this.rafId !== null && typeof cancelAnimationFrame === "function")
1091
+ cancelAnimationFrame(this.rafId);
930
1092
  this.rafId = null;
931
1093
  }
932
1094
  // ---------------------------------------------------------------------------
@@ -997,7 +1159,9 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
997
1159
  break;
998
1160
  }
999
1161
  case "clear":
1000
- this.clear((_b = actionable.getAttribute("data-target")) != null ? _b : "all");
1162
+ this.clear(
1163
+ (_b = actionable.getAttribute("data-target")) != null ? _b : "all"
1164
+ );
1001
1165
  break;
1002
1166
  case "toggle-recording":
1003
1167
  this.toggleRecording();
@@ -1109,7 +1273,12 @@ var _EnhancedDevInspector = class _EnhancedDevInspector {
1109
1273
  ${selected.error ? `<div><strong>Error:</strong> ${escapeHtml(selected.error)}</div>` : ""}
1110
1274
  </div>` : "";
1111
1275
  return `${this.toolbar(
1112
- button("clear", "Clear", 'data-target="network"') + button("toggle-recording", this.isRecording ? "Pause" : "Resume", "", this.isRecording ? "#ef4444" : "#22c55e"),
1276
+ button("clear", "Clear", 'data-target="network"') + button(
1277
+ "toggle-recording",
1278
+ this.isRecording ? "Pause" : "Resume",
1279
+ "",
1280
+ this.isRecording ? "#ef4444" : "#22c55e"
1281
+ ),
1113
1282
  `${visible.length} requests`
1114
1283
  )}
1115
1284
  <div style="flex: 1; overflow-y: auto;">${rows || this.empty("No network activity")}</div>${details}`;
@@ -1214,13 +1383,20 @@ var CircularStorage = class {
1214
1383
  this.tail = 0;
1215
1384
  this.size = 0;
1216
1385
  this.idCounter = 0;
1217
- this.maxSize = options.maxSize;
1386
+ const { maxSize } = options;
1387
+ if (typeof maxSize !== "number" || !Number.isFinite(maxSize) || maxSize < 0) {
1388
+ throw new RangeError(
1389
+ `CircularStorage maxSize must be a non-negative finite number, got ${String(maxSize)}`
1390
+ );
1391
+ }
1392
+ this.maxSize = Math.floor(maxSize);
1218
1393
  this.ttl = options.ttl;
1219
1394
  this.onEvict = options.onEvict;
1220
1395
  this.buffer = new Array(this.maxSize);
1221
1396
  }
1222
1397
  push(data) {
1223
1398
  const id = `${Date.now()}-${++this.idCounter}`;
1399
+ if (this.maxSize === 0) return id;
1224
1400
  const entry = {
1225
1401
  id,
1226
1402
  timestamp: Date.now(),
@@ -1300,6 +1476,7 @@ var CircularStorage = class {
1300
1476
  return now - entry.timestamp > this.ttl;
1301
1477
  }
1302
1478
  removeExpired() {
1479
+ var _a;
1303
1480
  if (!this.ttl) return 0;
1304
1481
  const now = Date.now();
1305
1482
  let removedCount = 0;
@@ -1309,8 +1486,8 @@ var CircularStorage = class {
1309
1486
  const entry = this.buffer[index];
1310
1487
  if (entry && !this.isExpired(entry, now)) {
1311
1488
  validEntries.push(entry);
1312
- } else if (entry && this.onEvict) {
1313
- this.onEvict(entry);
1489
+ } else if (entry) {
1490
+ (_a = this.onEvict) == null ? void 0 : _a.call(this, entry);
1314
1491
  removedCount++;
1315
1492
  }
1316
1493
  }
@@ -1442,6 +1619,7 @@ var _DevInspector = class _DevInspector {
1442
1619
  this.cleanupFunctions = [];
1443
1620
  this.initPromise = null;
1444
1621
  this.destroyed = false;
1622
+ this.uninstallingPlugins = /* @__PURE__ */ new Set();
1445
1623
  if (_DevInspector.instance) {
1446
1624
  console.warn("DevInspector instance already exists. Returning existing instance.");
1447
1625
  return _DevInspector.instance;
@@ -1521,7 +1699,11 @@ var _DevInspector = class _DevInspector {
1521
1699
  ...config,
1522
1700
  hotkeys: { ...defaultConfig.hotkeys, ...config.hotkeys },
1523
1701
  features: { ...defaultConfig.features, ...config.features },
1524
- networkFilters: { ...defaultConfig.networkFilters, ...config.networkFilters }
1702
+ networkFilters: { ...defaultConfig.networkFilters, ...config.networkFilters },
1703
+ // Invalid limits (negative, NaN, Infinity) fall back to the defaults, as in DevInspector.
1704
+ maxNetworkEntries: normalizeLimit(config.maxNetworkEntries, defaultConfig.maxNetworkEntries),
1705
+ maxConsoleEntries: normalizeLimit(config.maxConsoleEntries, defaultConfig.maxConsoleEntries),
1706
+ maxErrorEntries: normalizeLimit(config.maxErrorEntries, defaultConfig.maxErrorEntries)
1525
1707
  };
1526
1708
  }
1527
1709
  init() {
@@ -1539,7 +1721,6 @@ var _DevInspector = class _DevInspector {
1539
1721
  await this.registerPlugins();
1540
1722
  if (this.destroyed) return this.teardown();
1541
1723
  this.setupHotkeys();
1542
- this.setupErrorHandlers();
1543
1724
  this.initialized = true;
1544
1725
  this.events.emit("inspector:ready");
1545
1726
  } catch (error) {
@@ -1552,50 +1733,50 @@ var _DevInspector = class _DevInspector {
1552
1733
  async loadMonitors() {
1553
1734
  const features = this.config.features;
1554
1735
  if (features.network) {
1555
- const { NetworkMonitor } = await import("./network-monitor-WNRL2JI7.js");
1736
+ const { NetworkMonitor } = await import("./network-monitor-QHVMB5F3.js");
1556
1737
  const monitor = new NetworkMonitor(this);
1557
1738
  this.monitors.set("network", monitor);
1558
1739
  monitor.start();
1559
1740
  }
1560
1741
  if (features.console) {
1561
- const { ConsoleMonitor } = await import("./console-monitor-AVTNZCED.js");
1742
+ const { ConsoleMonitor } = await import("./console-monitor-AO67CSAK.js");
1562
1743
  const monitor = new ConsoleMonitor(this);
1563
1744
  this.monitors.set("console", monitor);
1564
1745
  monitor.start();
1565
1746
  }
1566
1747
  if (features.performance) {
1567
- const { PerformanceMonitor } = await import("./performance-monitor-UKQFA7ZR.js");
1748
+ const { PerformanceMonitor } = await import("./performance-monitor-ULNHXBYX.js");
1568
1749
  const monitor = new PerformanceMonitor(this);
1569
1750
  this.monitors.set("performance", monitor);
1570
1751
  monitor.start();
1571
1752
  }
1572
1753
  if (features.errors) {
1573
- const { ErrorMonitor } = await import("./error-monitor-3CRFREH3.js");
1754
+ const { ErrorMonitor } = await import("./error-monitor-AVTYBTS7.js");
1574
1755
  const monitor = new ErrorMonitor(this);
1575
1756
  this.monitors.set("error", monitor);
1576
1757
  monitor.start();
1577
1758
  }
1578
1759
  if (features.state) {
1579
- const { StateMonitor } = await import("./state-monitor-JGJLBAD7.js");
1760
+ const { StateMonitor } = await import("./state-monitor-UNAVEOGH.js");
1580
1761
  const monitor = new StateMonitor(this);
1581
1762
  this.monitors.set("state", monitor);
1582
1763
  monitor.start();
1583
1764
  }
1584
1765
  if (features.dom) {
1585
- const { DOMMonitor } = await import("./dom-monitor-JHJVZYS4.js");
1766
+ const { DOMMonitor } = await import("./dom-monitor-D6GHCDBP.js");
1586
1767
  const monitor = new DOMMonitor(this);
1587
1768
  this.monitors.set("dom", monitor);
1588
1769
  monitor.start();
1589
1770
  }
1590
1771
  if (features.storage) {
1591
- const { StorageMonitor } = await import("./storage-monitor-3NPTWRTY.js");
1772
+ const { StorageMonitor } = await import("./storage-monitor-5RCRXYMX.js");
1592
1773
  const monitor = new StorageMonitor(this);
1593
1774
  this.monitors.set("storage", monitor);
1594
1775
  monitor.start();
1595
1776
  }
1596
1777
  }
1597
1778
  async loadUI() {
1598
- const { DevInspectorUI } = await import("./inspector-ui-C7WSILKC.js");
1779
+ const { DevInspectorUI } = await import("./inspector-ui-TEAZXDPM.js");
1599
1780
  this.ui = new DevInspectorUI(this);
1600
1781
  await this.ui.init();
1601
1782
  }
@@ -1623,33 +1804,6 @@ var _DevInspector = class _DevInspector {
1623
1804
  document.addEventListener("keydown", handleKeydown);
1624
1805
  this.cleanupFunctions.push(() => document.removeEventListener("keydown", handleKeydown));
1625
1806
  }
1626
- setupErrorHandlers() {
1627
- if (!this.config.features.errors) return;
1628
- const handleError = (event) => {
1629
- this.events.emit("error:uncaught", {
1630
- message: event.message,
1631
- filename: event.filename,
1632
- lineno: event.lineno,
1633
- colno: event.colno,
1634
- error: event.error,
1635
- timestamp: Date.now()
1636
- });
1637
- };
1638
- const handleRejection = (event) => {
1639
- this.events.emit("error:uncaught", {
1640
- message: "Unhandled promise rejection",
1641
- reason: event.reason,
1642
- promise: event.promise,
1643
- timestamp: Date.now()
1644
- });
1645
- };
1646
- window.addEventListener("error", handleError);
1647
- window.addEventListener("unhandledrejection", handleRejection);
1648
- this.cleanupFunctions.push(() => {
1649
- window.removeEventListener("error", handleError);
1650
- window.removeEventListener("unhandledrejection", handleRejection);
1651
- });
1652
- }
1653
1807
  getKeyCombo(event) {
1654
1808
  const parts = [];
1655
1809
  if (event.ctrlKey) parts.push("ctrl");
@@ -1711,6 +1865,17 @@ var _DevInspector = class _DevInspector {
1711
1865
  this.ui = null;
1712
1866
  this.cleanupFunctions.forEach((cleanup) => cleanup());
1713
1867
  this.cleanupFunctions = [];
1868
+ this.uninstallPlugins();
1869
+ }
1870
+ /** Disables and uninstalls every registered plugin; failures are reported, not thrown. */
1871
+ uninstallPlugins(names = this.pluginSystem.getAll().map((plugin) => plugin.name)) {
1872
+ for (const name of names) {
1873
+ if (this.uninstallingPlugins.has(name)) continue;
1874
+ this.uninstallingPlugins.add(name);
1875
+ this.pluginSystem.unregister(name).catch((error) => {
1876
+ console.error(`DevInspector: failed to uninstall plugin "${name}"`, error);
1877
+ }).finally(() => this.uninstallingPlugins.delete(name));
1878
+ }
1714
1879
  }
1715
1880
  destroy() {
1716
1881
  this.destroyed = true;
@@ -1742,7 +1907,12 @@ var _DevInspector = class _DevInspector {
1742
1907
  }
1743
1908
  }
1744
1909
  async use(plugin) {
1910
+ if (this.destroyed) throw new Error("DevInspector has been destroyed");
1745
1911
  await this.pluginSystem.register(plugin);
1912
+ if (this.destroyed) {
1913
+ this.uninstallPlugins([plugin.name]);
1914
+ throw new Error("DevInspector has been destroyed");
1915
+ }
1746
1916
  }
1747
1917
  export() {
1748
1918
  return {