@oxog/devinspector 1.5.0 → 1.5.2

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 CHANGED
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.5.2] - 2026-12-03
11
+
12
+ ### Fixed
13
+ - Legacy `OriginalDevInspector`: stopping the performance monitor (on `destroy()`) left its throttled `performance:data` emission scheduled, so a pending timer fired up to 100ms later and emitted once more after the monitor had stopped. `stop()` now drops the pending emission and its timer.
14
+
15
+ ## [1.5.1] - 2026-12-02
16
+
17
+ ### Added
18
+ - Real-browser test suite (`npm run test:browser`, `vitest.config.browser.mts`, `tests/browser`; Vitest browser mode with Playwright's Chromium): the browser's own `fetch` (responses still readable by the app, streaming downloads, streaming uploads with `duplex: 'half'` against a local HTTP/2 server, aborts, detached calls), the `XMLHttpRequest` lifecycle (abort, `open()` on a request in flight, synchronous requests and the errors the native methods throw), legacy WebSocket capture against a local echo server, console capture, the panel showing captured markup as text (nothing in it runs), real clicks and hotkeys, and `destroy()` giving back the native `fetch`, `XMLHttpRequest`, `WebSocket`, `sendBeacon` and `console` methods by identity for every destroy order. It runs in the `Browser tests` workflow, not in `npm run check`; locally `PW_CHANNEL=chrome npm run test:browser` uses an installed Chrome.
19
+
20
+ ### Fixed
21
+ - The minimized panel was a fixed 48px tall while its header is 52px, so the bottom of the header and of its minimize/close buttons was cut off. It is now as tall as the header.
22
+ - Legacy `OriginalDevInspector` / `XHRInterceptor`: `open(method, url, undefined)` is a synchronous request in the browser (an explicit `undefined` converts to `false`), but the inspector replaced the missing value with `true` and made it asynchronous. `open()` arguments are now passed through as given.
23
+
10
24
  ## [1.5.0] - 2026-12-02
11
25
 
12
26
  ### Fixed
@@ -13,7 +13,7 @@ function throttle(func, wait, options = {}) {
13
13
  result = func.apply(thisArg, args);
14
14
  return result;
15
15
  };
16
- return function throttled(...args) {
16
+ const throttled = function(...args) {
17
17
  const now = Date.now();
18
18
  const remaining = wait - (now - lastCallTime);
19
19
  lastThis = this;
@@ -38,6 +38,14 @@ function throttle(func, wait, options = {}) {
38
38
  }
39
39
  return result;
40
40
  };
41
+ throttled.cancel = () => {
42
+ if (timeout) {
43
+ clearTimeout(timeout);
44
+ timeout = null;
45
+ }
46
+ lastArgs = lastThis = null;
47
+ };
48
+ return throttled;
41
49
  }
42
50
  function generateId() {
43
51
  return `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
@@ -93,4 +101,4 @@ export {
93
101
  getStackTrace,
94
102
  parseStackFrame
95
103
  };
96
- //# sourceMappingURL=chunk-NP2SAIEA.js.map
104
+ //# sourceMappingURL=chunk-D4LKJXON.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/utils.ts"],"sourcesContent":["export function debounce<T extends (...args: any[]) => any>(\n func: T,\n wait: number,\n options: { leading?: boolean; trailing?: boolean } = {}\n): (...args: Parameters<T>) => void {\n let timeout: ReturnType<typeof setTimeout> | null = null;\n let result: any;\n let lastCallTime: number | null = null;\n let lastThis: any;\n let lastArgs: any[] | null = null;\n\n const { leading = false, trailing = true } = options;\n\n const invokeFunc = (time: number) => {\n const args = lastArgs!;\n const thisArg = lastThis;\n\n lastArgs = lastThis = null;\n lastCallTime = time;\n result = func.apply(thisArg, args);\n return result;\n };\n\n const leadingEdge = (time: number) => {\n lastCallTime = time;\n timeout = setTimeout(timerExpired, wait);\n return leading ? invokeFunc(time) : result;\n };\n\n const timerExpired = () => {\n timeout = null;\n\n if (trailing && lastArgs) {\n return invokeFunc(Date.now());\n }\n lastArgs = lastThis = null;\n };\n\n return function debounced(this: any, ...args: Parameters<T>) {\n const time = Date.now();\n const isInvoking = shouldInvoke(time);\n\n lastArgs = args;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n lastThis = this;\n\n if (isInvoking) {\n if (timeout === null) {\n return leadingEdge(time);\n }\n }\n\n if (timeout !== null) {\n clearTimeout(timeout);\n }\n timeout = setTimeout(timerExpired, wait);\n return result;\n };\n\n function shouldInvoke(time: number): boolean {\n return lastCallTime === null || time - lastCallTime >= wait;\n }\n}\n\nexport function throttle<T extends (...args: any[]) => any>(\n func: T,\n wait: number,\n options: { leading?: boolean; trailing?: boolean } = {}\n): ((...args: Parameters<T>) => void) & { cancel: () => void } {\n let timeout: ReturnType<typeof setTimeout> | null = null;\n let lastCallTime = 0;\n let lastThis: any;\n let lastArgs: any[] | null = null;\n let result: any;\n\n const { leading = true, trailing = true } = options;\n\n const invokeFunc = () => {\n const args = lastArgs!;\n const thisArg = lastThis;\n\n lastArgs = lastThis = null;\n result = func.apply(thisArg, args);\n return result;\n };\n\n const throttled = function (this: any, ...args: Parameters<T>) {\n const now = Date.now();\n const remaining = wait - (now - lastCallTime);\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n lastThis = this;\n lastArgs = args;\n\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n lastCallTime = now;\n if (leading) {\n result = invokeFunc();\n }\n } else if (!timeout && trailing) {\n timeout = setTimeout(() => {\n lastCallTime = Date.now();\n timeout = null;\n if (trailing && lastArgs) {\n invokeFunc();\n }\n }, remaining);\n }\n\n return result;\n };\n\n /** Drops a pending trailing call and its timer. */\n throttled.cancel = () => {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n lastArgs = lastThis = null;\n };\n\n return throttled;\n}\n\nexport function deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as any;\n }\n\n if (obj instanceof Array) {\n return obj.map((item) => deepClone(item)) as any;\n }\n\n if (obj instanceof Set) {\n return new Set(Array.from(obj).map((item) => deepClone(item))) as any;\n }\n\n if (obj instanceof Map) {\n return new Map(\n Array.from(obj.entries()).map(([key, value]) => [deepClone(key), deepClone(value)])\n ) as any;\n }\n\n if (obj instanceof RegExp) {\n return new RegExp(obj.source, obj.flags) as any;\n }\n\n const clonedObj = Object.create(Object.getPrototypeOf(obj));\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n clonedObj[key] = deepClone(obj[key]);\n }\n }\n\n return clonedObj;\n}\n\nexport function formatBytes(bytes: number, precision: number = 2): string {\n const units = ['B', 'KB', 'MB', 'GB', 'TB'];\n\n if (bytes === 0) return '0 B';\n if (bytes < 0) throw new Error('formatBytes: negative values not supported');\n\n const k = 1024;\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n\n return parseFloat((bytes / Math.pow(k, i)).toFixed(precision)) + ' ' + units[i];\n}\n\nexport function formatDuration(ms: number): string {\n if (ms < 1000) return `${ms}ms`;\n if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;\n if (ms < 3600000) return `${Math.floor(ms / 60000)}m ${Math.floor((ms % 60000) / 1000)}s`;\n return `${Math.floor(ms / 3600000)}h ${Math.floor((ms % 3600000) / 60000)}m`;\n}\n\nexport function generateId(): string {\n return `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;\n}\n\nexport function isCircularReference(obj: any, seen = new WeakSet()): boolean {\n if (obj === null || typeof obj !== 'object') {\n return false;\n }\n\n if (seen.has(obj)) {\n return true;\n }\n\n seen.add(obj);\n\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key) && isCircularReference(obj[key], seen)) {\n return true;\n }\n }\n\n seen.delete(obj);\n return false;\n}\n\nexport function safeStringify(obj: any, indent?: number): string {\n const seen = new WeakSet();\n\n return JSON.stringify(\n obj,\n (key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (seen.has(value)) {\n return '[Circular]';\n }\n seen.add(value);\n }\n\n if (typeof value === 'function') {\n return value.toString();\n }\n\n if (value instanceof Error) {\n return {\n name: value.name,\n message: value.message,\n stack: value.stack,\n };\n }\n\n return value;\n },\n indent\n );\n}\n\nexport function getStackTrace(error?: Error): string[] {\n const stack = (error || new Error()).stack || '';\n return stack\n .split('\\n')\n .slice(1)\n .map((line) => line.trim())\n .filter((line) => line.startsWith('at '));\n}\n\nexport function parseStackFrame(frame: string): {\n functionName?: string;\n fileName?: string;\n lineNumber?: number;\n columnNumber?: number;\n} | null {\n const match = frame.match(/at\\s+(?:(.+?)\\s+\\()?(.+?):(\\d+):(\\d+)\\)?$/);\n\n if (!match) {\n return null;\n }\n\n const [, functionName, fileName, lineNumber, columnNumber] = match;\n\n return {\n functionName: functionName || '<anonymous>',\n fileName: fileName || '<unknown>',\n lineNumber: parseInt(lineNumber || '0', 10),\n columnNumber: parseInt(columnNumber || '0', 10),\n };\n}\n\nexport function memoize<T extends (...args: any[]) => any>(\n fn: T,\n options: {\n maxSize?: number;\n ttl?: number;\n keyResolver?: (...args: Parameters<T>) => string;\n } = {}\n): T {\n const { maxSize = 100, ttl, keyResolver = (...args) => JSON.stringify(args) } = options;\n const cache = new Map<string, { value: ReturnType<T>; timestamp: number }>();\n\n return ((...args: Parameters<T>): ReturnType<T> => {\n const key = keyResolver(...args);\n const cached = cache.get(key);\n\n if (cached) {\n if (!ttl || Date.now() - cached.timestamp < ttl) {\n return cached.value;\n }\n cache.delete(key);\n }\n\n // Evict oldest entry BEFORE adding if at capacity\n if (cache.size >= maxSize) {\n const firstKey = cache.keys().next().value;\n if (firstKey !== undefined) {\n cache.delete(firstKey);\n }\n }\n\n const result = fn(...args);\n cache.set(key, { value: result, timestamp: Date.now() });\n\n return result;\n }) as T;\n}\n\nexport function createWorkerScript(fn: (...args: any[]) => any): string {\n return `\n self.addEventListener('message', async (event) => {\n try {\n const result = await (${fn.toString()})(event.data);\n self.postMessage({ type: 'result', data: result });\n } catch (error) {\n self.postMessage({\n type: 'error',\n error: {\n message: error instanceof Error ? error.message : String(error),\n stack: error instanceof Error ? error.stack : undefined\n }\n });\n }\n });\n `;\n}\n\nexport function createObjectURL(content: string, type = 'application/javascript'): string {\n const blob = new Blob([content], { type });\n return URL.createObjectURL(blob);\n}\n\nexport class Deferred<T> {\n promise: Promise<T>;\n resolve!: (value: T | PromiseLike<T>) => void;\n reject!: (reason?: any) => void;\n\n constructor() {\n this.promise = new Promise<T>((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n}\n"],"mappings":";AAgEO,SAAS,SACd,MACA,MACA,UAAqD,CAAC,GACO;AAC7D,MAAI,UAAgD;AACpD,MAAI,eAAe;AACnB,MAAI;AACJ,MAAI,WAAyB;AAC7B,MAAI;AAEJ,QAAM,EAAE,UAAU,MAAM,WAAW,KAAK,IAAI;AAE5C,QAAM,aAAa,MAAM;AACvB,UAAM,OAAO;AACb,UAAM,UAAU;AAEhB,eAAW,WAAW;AACtB,aAAS,KAAK,MAAM,SAAS,IAAI;AACjC,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,YAAwB,MAAqB;AAC7D,UAAM,MAAM,KAAK,IAAI;AACrB,UAAM,YAAY,QAAQ,MAAM;AAGhC,eAAW;AACX,eAAW;AAEX,QAAI,aAAa,KAAK,YAAY,MAAM;AACtC,UAAI,SAAS;AACX,qBAAa,OAAO;AACpB,kBAAU;AAAA,MACZ;AACA,qBAAe;AACf,UAAI,SAAS;AACX,iBAAS,WAAW;AAAA,MACtB;AAAA,IACF,WAAW,CAAC,WAAW,UAAU;AAC/B,gBAAU,WAAW,MAAM;AACzB,uBAAe,KAAK,IAAI;AACxB,kBAAU;AACV,YAAI,YAAY,UAAU;AACxB,qBAAW;AAAA,QACb;AAAA,MACF,GAAG,SAAS;AAAA,IACd;AAEA,WAAO;AAAA,EACT;AAGA,YAAU,SAAS,MAAM;AACvB,QAAI,SAAS;AACX,mBAAa,OAAO;AACpB,gBAAU;AAAA,IACZ;AACA,eAAW,WAAW;AAAA,EACxB;AAEA,SAAO;AACT;AA0DO,SAAS,aAAqB;AACnC,SAAO,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AACjE;AAuBO,SAAS,cAAc,KAAU,QAAyB;AAC/D,QAAM,OAAO,oBAAI,QAAQ;AAEzB,SAAO,KAAK;AAAA,IACV;AAAA,IACA,CAAC,KAAK,UAAU;AACd,UAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,YAAI,KAAK,IAAI,KAAK,GAAG;AACnB,iBAAO;AAAA,QACT;AACA,aAAK,IAAI,KAAK;AAAA,MAChB;AAEA,UAAI,OAAO,UAAU,YAAY;AAC/B,eAAO,MAAM,SAAS;AAAA,MACxB;AAEA,UAAI,iBAAiB,OAAO;AAC1B,eAAO;AAAA,UACL,MAAM,MAAM;AAAA,UACZ,SAAS,MAAM;AAAA,UACf,OAAO,MAAM;AAAA,QACf;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,cAAc,OAAyB;AACrD,QAAM,SAAS,SAAS,IAAI,MAAM,GAAG,SAAS;AAC9C,SAAO,MACJ,MAAM,IAAI,EACV,MAAM,CAAC,EACP,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC,EACzB,OAAO,CAAC,SAAS,KAAK,WAAW,KAAK,CAAC;AAC5C;AAEO,SAAS,gBAAgB,OAKvB;AACP,QAAM,QAAQ,MAAM,MAAM,2CAA2C;AAErE,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,QAAM,CAAC,EAAE,cAAc,UAAU,YAAY,YAAY,IAAI;AAE7D,SAAO;AAAA,IACL,cAAc,gBAAgB;AAAA,IAC9B,UAAU,YAAY;AAAA,IACtB,YAAY,SAAS,cAAc,KAAK,EAAE;AAAA,IAC1C,cAAc,SAAS,gBAAgB,KAAK,EAAE;AAAA,EAChD;AACF;","names":[]}
@@ -5,7 +5,7 @@ import {
5
5
  generateId,
6
6
  getStackTrace,
7
7
  safeStringify
8
- } from "./chunk-NP2SAIEA.js";
8
+ } from "./chunk-D4LKJXON.js";
9
9
 
10
10
  // src/monitors/console/console-interceptor.ts
11
11
  var ConsoleInterceptor = class {
@@ -575,4 +575,4 @@ var ConsoleMonitor = class {
575
575
  export {
576
576
  ConsoleMonitor
577
577
  };
578
- //# sourceMappingURL=console-monitor-AO67CSAK.js.map
578
+ //# sourceMappingURL=console-monitor-4ILYG5HB.js.map
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @oxog/devinspector v1.5.0
2
+ * @oxog/devinspector v1.5.2
3
3
  * (c) Ersin Koc <ersinkoc@gmail.com>
4
4
  * Released under the MIT License
5
5
  */
@@ -335,7 +335,7 @@
335
335
  }
336
336
 
337
337
  /** Package version, kept in sync with package.json (checked by tests). */
338
- const VERSION = '1.5.0';
338
+ const VERSION = '1.5.2';
339
339
 
340
340
  /**
341
341
  * DevInspector - the default inspector: floating widget plus a panel with
@@ -632,8 +632,9 @@
632
632
  if (!this.isEnabled)
633
633
  return;
634
634
  this.isMinimized = !this.isMinimized;
635
+ // Minimized, the panel is as tall as its header (a fixed height clipped it).
635
636
  if (this.panel)
636
- this.panel.style.height = this.isMinimized ? '48px' : '650px';
637
+ this.panel.style.height = this.isMinimized ? 'auto' : '650px';
637
638
  this.render();
638
639
  this.events.emit('inspector:minimize', this.isMinimized);
639
640
  }
@@ -2392,7 +2393,7 @@
2392
2393
  result = func.apply(thisArg, args);
2393
2394
  return result;
2394
2395
  };
2395
- return function throttled(...args) {
2396
+ const throttled = function (...args) {
2396
2397
  const now = Date.now();
2397
2398
  const remaining = wait - (now - lastCallTime);
2398
2399
  // eslint-disable-next-line @typescript-eslint/no-this-alias
@@ -2419,6 +2420,15 @@
2419
2420
  }
2420
2421
  return result;
2421
2422
  };
2423
+ /** Drops a pending trailing call and its timer. */
2424
+ throttled.cancel = () => {
2425
+ if (timeout) {
2426
+ clearTimeout(timeout);
2427
+ timeout = null;
2428
+ }
2429
+ lastArgs = lastThis = null;
2430
+ };
2431
+ return throttled;
2422
2432
  }
2423
2433
  function generateId() {
2424
2434
  return `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
@@ -2807,9 +2817,12 @@
2807
2817
  return;
2808
2818
  // eslint-disable-next-line @typescript-eslint/no-this-alias
2809
2819
  const self = this;
2810
- XMLHttpRequest.prototype.open = function (method, url, async = true, username, password) {
2820
+ XMLHttpRequest.prototype.open = function (...args) {
2811
2821
  var _a;
2812
- const result = self.originalOpen.apply(this, [method, url, async, username, password]);
2822
+ // The arguments go through as given: an explicit `async: undefined` means a
2823
+ // synchronous request, and the native open() distinguishes 2 from 3+ arguments.
2824
+ const result = self.originalOpen.apply(this, args);
2825
+ const [method, url] = args;
2813
2826
  // open() on a request in flight cancels it without abort/loadend events.
2814
2827
  (_a = this._devinspectorCancel) === null || _a === void 0 ? void 0 : _a.call(this);
2815
2828
  this._devinspectorId = generateId();
@@ -4459,7 +4472,9 @@
4459
4472
  this.metricsCollector = new MetricsCollector(this.handleMetrics.bind(this));
4460
4473
  this.longTaskDetector = new LongTaskDetector(this.handleLongTask.bind(this));
4461
4474
  // Throttle the performance data emission
4462
- this.emitPerformanceData = throttle(this.emitPerformanceData.bind(this), 100);
4475
+ const throttledEmit = throttle(this.emitPerformanceData.bind(this), 100);
4476
+ this.emitPerformanceData = throttledEmit;
4477
+ this.cancelPendingEmit = throttledEmit.cancel;
4463
4478
  }
4464
4479
  start() {
4465
4480
  if (this.isActive)
@@ -4479,6 +4494,8 @@
4479
4494
  this.memoryMonitor.stop();
4480
4495
  this.metricsCollector.stop();
4481
4496
  this.longTaskDetector.stop();
4497
+ // A trailing emission still pending must not fire after stop()
4498
+ this.cancelPendingEmit();
4482
4499
  this.isActive = false;
4483
4500
  }
4484
4501
  handleFPSData(data) {