@wdio/devtools-script 1.2.1 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/devtools-script",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "Script to be injected into a page to trace the page",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "repository": {
@@ -16,10 +16,10 @@
16
16
  "htm": "^3.1.1",
17
17
  "parse5": "^8.0.0",
18
18
  "preact": "^10.27.1",
19
- "vite-plugin-singlefile": "^2.3.0"
19
+ "vite-plugin-singlefile": "^2.3.2"
20
20
  },
21
21
  "devDependencies": {
22
- "vite": "7.3.1"
22
+ "vite": "8.0.7"
23
23
  },
24
24
  "license": "MIT",
25
25
  "scripts": {
package/src/collector.ts CHANGED
@@ -5,7 +5,15 @@ import { NetworkRequestCollector } from './collectors/networkRequests.js'
5
5
  class DataCollector {
6
6
  #metadata = {
7
7
  url: window.location.href,
8
- viewport: window.visualViewport!
8
+ // Serialize viewport values explicitly — VisualViewport properties are
9
+ // prototype getters and won't survive JSON.stringify otherwise.
10
+ viewport: {
11
+ width: window.visualViewport?.width ?? window.innerWidth,
12
+ height: window.visualViewport?.height ?? window.innerHeight,
13
+ offsetLeft: window.visualViewport?.offsetLeft ?? 0,
14
+ offsetTop: window.visualViewport?.offsetTop ?? 0,
15
+ scale: window.visualViewport?.scale ?? 1
16
+ }
9
17
  }
10
18
  #errors: string[] = []
11
19
  #mutations: TraceMutation[] = []
@@ -4,6 +4,7 @@ import type { NetworkRequest } from '../../types.js'
4
4
  export class NetworkRequestCollector implements Collector<NetworkRequest> {
5
5
  #requests: NetworkRequest[] = []
6
6
  #pendingRequests = new Map<string, Partial<NetworkRequest>>()
7
+ #pendingXHRRequests = new WeakMap<XMLHttpRequest, Partial<NetworkRequest>>()
7
8
  #originalFetch?: typeof fetch
8
9
  #originalXhrOpen?: typeof XMLHttpRequest.prototype.open
9
10
  #originalXhrSend?: typeof XMLHttpRequest.prototype.send
@@ -194,8 +195,7 @@ export class NetworkRequestCollector implements Collector<NetworkRequest> {
194
195
  )
195
196
  }
196
197
 
197
- ;(this as any)._networkRequestId = id
198
- ;(this as any)._networkRequestData = {
198
+ self.#pendingXHRRequests.set(this, {
199
199
  id,
200
200
  url: urlString,
201
201
  method: method.toUpperCase(),
@@ -203,7 +203,7 @@ export class NetworkRequestCollector implements Collector<NetworkRequest> {
203
203
  timestamp: Date.now(),
204
204
  startTime: performance.now(),
205
205
  requestHeaders: {}
206
- }
206
+ })
207
207
 
208
208
  return self.#originalXhrOpen!.call(
209
209
  this,
@@ -218,8 +218,7 @@ export class NetworkRequestCollector implements Collector<NetworkRequest> {
218
218
  XMLHttpRequest.prototype.send = function (
219
219
  body?: Document | XMLHttpRequestBodyInit | null
220
220
  ) {
221
- const requestData = (this as any)
222
- ._networkRequestData as Partial<NetworkRequest>
221
+ const requestData = self.#pendingXHRRequests.get(this)
223
222
 
224
223
  // If no request data, this request was filtered out - just send it
225
224
  if (!requestData) {
package/tsconfig.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
+ "ignoreDeprecations": "6.0",
4
5
  "moduleResolution": "NodeNext",
5
6
  "module": "NodeNext"
6
7
  }