patchright-core 1.52.4 → 1.55.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.
Files changed (218) hide show
  1. package/ThirdPartyNotices.txt +65 -123
  2. package/bin/reinstall_chrome_beta_mac.sh +1 -1
  3. package/bin/reinstall_chrome_stable_mac.sh +1 -1
  4. package/bin/reinstall_msedge_beta_mac.sh +1 -1
  5. package/bin/reinstall_msedge_dev_mac.sh +1 -1
  6. package/bin/reinstall_msedge_stable_mac.sh +1 -1
  7. package/browsers.json +14 -14
  8. package/index.js +1 -1
  9. package/lib/androidServerImpl.js +4 -2
  10. package/lib/browserServerImpl.js +47 -12
  11. package/lib/cli/program.js +116 -50
  12. package/lib/cli/programWithTestStub.js +1 -1
  13. package/lib/client/android.js +30 -34
  14. package/lib/client/browser.js +54 -17
  15. package/lib/client/browserContext.js +67 -71
  16. package/lib/client/browserType.js +25 -34
  17. package/lib/client/channelOwner.js +20 -24
  18. package/lib/client/connection.js +6 -10
  19. package/lib/client/electron.js +8 -3
  20. package/lib/client/elementHandle.js +18 -21
  21. package/lib/client/fetch.js +5 -3
  22. package/lib/client/frame.js +57 -35
  23. package/lib/client/input.js +3 -1
  24. package/lib/client/jsHandle.js +4 -0
  25. package/lib/client/localUtils.js +0 -1
  26. package/lib/client/locator.js +32 -28
  27. package/lib/client/network.js +5 -12
  28. package/lib/client/page.js +32 -32
  29. package/lib/client/playwright.js +6 -16
  30. package/lib/client/selectors.js +18 -38
  31. package/lib/client/timeoutSettings.js +12 -8
  32. package/lib/client/tracing.js +24 -20
  33. package/lib/client/waiter.js +2 -2
  34. package/lib/client/webSocket.js +4 -22
  35. package/lib/generated/bindingsControllerSource.js +28 -0
  36. package/lib/generated/clockSource.js +1 -1
  37. package/lib/generated/injectedScriptSource.js +1 -1
  38. package/lib/generated/pollingRecorderSource.js +1 -1
  39. package/lib/generated/storageScriptSource.js +28 -0
  40. package/lib/generated/utilityScriptSource.js +1 -1
  41. package/lib/generated/webSocketMockSource.js +12 -50
  42. package/lib/inProcessFactory.js +9 -6
  43. package/lib/outofprocess.js +0 -2
  44. package/lib/protocol/validator.js +423 -346
  45. package/lib/protocol/validatorPrimitives.js +18 -4
  46. package/lib/remote/playwrightConnection.js +29 -166
  47. package/lib/remote/playwrightServer.js +233 -35
  48. package/lib/server/android/android.js +97 -83
  49. package/lib/server/android/backendAdb.js +0 -2
  50. package/lib/server/bidi/bidiBrowser.js +139 -73
  51. package/lib/server/bidi/bidiChromium.js +23 -22
  52. package/lib/server/bidi/bidiExecutionContext.js +2 -1
  53. package/lib/server/bidi/bidiFirefox.js +17 -14
  54. package/lib/server/bidi/bidiInput.js +22 -22
  55. package/lib/server/bidi/bidiNetworkManager.js +8 -11
  56. package/lib/server/bidi/bidiPage.js +42 -86
  57. package/lib/server/bidi/third_party/bidiProtocol.js +5 -133
  58. package/lib/server/bidi/third_party/bidiProtocolCore.js +179 -0
  59. package/lib/server/{dispatchers/selectorsDispatcher.js → bidi/third_party/bidiProtocolPermissions.js} +20 -18
  60. package/lib/server/browser.js +30 -21
  61. package/lib/server/browserContext.js +203 -165
  62. package/lib/server/browserType.js +109 -107
  63. package/lib/server/chromium/chromium.js +84 -69
  64. package/lib/server/chromium/chromiumSwitches.js +13 -20
  65. package/lib/server/chromium/crBrowser.js +74 -40
  66. package/lib/server/chromium/crConnection.js +8 -9
  67. package/lib/server/chromium/crCoverage.js +11 -8
  68. package/lib/server/chromium/crDragDrop.js +25 -20
  69. package/lib/server/chromium/crExecutionContext.js +2 -1
  70. package/lib/server/chromium/crInput.js +32 -29
  71. package/lib/server/chromium/crNetworkManager.js +45 -33
  72. package/lib/server/chromium/crPage.js +98 -73
  73. package/lib/server/chromium/crServiceWorker.js +13 -18
  74. package/lib/server/chromium/videoRecorder.js +10 -18
  75. package/lib/server/clock.js +51 -39
  76. package/lib/server/codegen/csharp.js +10 -5
  77. package/lib/server/codegen/java.js +1 -1
  78. package/lib/server/codegen/javascript.js +1 -1
  79. package/lib/server/codegen/jsonl.js +2 -1
  80. package/lib/server/codegen/language.js +22 -1
  81. package/lib/server/codegen/languages.js +4 -4
  82. package/lib/server/codegen/python.js +1 -1
  83. package/lib/server/cookieStore.js +3 -1
  84. package/lib/server/debugController.js +105 -71
  85. package/lib/server/debugger.js +6 -23
  86. package/lib/server/deviceDescriptorsSource.json +237 -127
  87. package/lib/server/dialog.js +50 -6
  88. package/lib/server/dispatchers/androidDispatcher.js +77 -62
  89. package/lib/server/dispatchers/artifactDispatcher.js +18 -18
  90. package/lib/server/dispatchers/browserContextDispatcher.js +141 -91
  91. package/lib/server/dispatchers/browserDispatcher.js +55 -88
  92. package/lib/server/dispatchers/browserTypeDispatcher.js +18 -9
  93. package/lib/server/dispatchers/cdpSessionDispatcher.js +4 -4
  94. package/lib/server/dispatchers/debugControllerDispatcher.js +12 -21
  95. package/lib/server/dispatchers/dialogDispatcher.js +4 -4
  96. package/lib/server/dispatchers/dispatcher.js +78 -53
  97. package/lib/server/dispatchers/electronDispatcher.js +19 -20
  98. package/lib/server/dispatchers/elementHandlerDispatcher.js +83 -93
  99. package/lib/server/dispatchers/frameDispatcher.js +99 -102
  100. package/lib/server/dispatchers/jsHandleDispatcher.js +21 -16
  101. package/lib/server/dispatchers/jsonPipeDispatcher.js +4 -4
  102. package/lib/server/dispatchers/localUtilsDispatcher.js +53 -59
  103. package/lib/server/dispatchers/networkDispatchers.js +41 -35
  104. package/lib/server/dispatchers/pageDispatcher.js +156 -107
  105. package/lib/server/dispatchers/playwrightDispatcher.js +37 -25
  106. package/lib/server/dispatchers/streamDispatcher.js +15 -8
  107. package/lib/server/dispatchers/tracingDispatcher.js +22 -13
  108. package/lib/server/dispatchers/webSocketRouteDispatcher.js +46 -35
  109. package/lib/server/dispatchers/writableStreamDispatcher.js +16 -10
  110. package/lib/server/dom.js +198 -266
  111. package/lib/server/download.js +3 -3
  112. package/lib/server/electron/electron.js +96 -103
  113. package/lib/server/electron/loader.js +1 -1
  114. package/lib/server/fetch.js +22 -41
  115. package/lib/server/fileUploadUtils.js +1 -1
  116. package/lib/server/firefox/ffBrowser.js +79 -55
  117. package/lib/server/firefox/ffExecutionContext.js +2 -1
  118. package/lib/server/firefox/ffInput.js +23 -23
  119. package/lib/server/firefox/ffNetworkManager.js +8 -6
  120. package/lib/server/firefox/ffPage.js +39 -36
  121. package/lib/server/firefox/firefox.js +9 -10
  122. package/lib/server/frameSelectors.js +65 -22
  123. package/lib/server/frames.js +516 -544
  124. package/lib/server/har/harRecorder.js +1 -1
  125. package/lib/server/har/harTracer.js +4 -2
  126. package/lib/server/helper.js +3 -7
  127. package/lib/server/index.js +0 -3
  128. package/lib/server/input.js +47 -54
  129. package/lib/server/instrumentation.js +8 -14
  130. package/lib/server/javascript.js +9 -17
  131. package/lib/server/launchApp.js +48 -30
  132. package/lib/server/localUtils.js +45 -38
  133. package/lib/server/network.js +44 -10
  134. package/lib/server/page.js +233 -178
  135. package/lib/server/pageBinding.js +6 -7
  136. package/lib/server/playwright.js +4 -14
  137. package/lib/server/progress.js +57 -49
  138. package/lib/server/recorder/recorderApp.js +298 -95
  139. package/lib/server/recorder/recorderRunner.js +23 -24
  140. package/lib/server/recorder/recorderSignalProcessor.js +83 -0
  141. package/lib/server/recorder/recorderUtils.js +67 -10
  142. package/lib/server/recorder.js +284 -146
  143. package/lib/server/registry/index.js +83 -48
  144. package/lib/server/registry/nativeDeps.js +175 -0
  145. package/lib/server/registry/oopDownloadBrowserMain.js +1 -1
  146. package/lib/server/screenshotter.js +84 -83
  147. package/lib/server/selectors.js +12 -12
  148. package/lib/server/socksClientCertificatesInterceptor.js +198 -136
  149. package/lib/server/trace/recorder/snapshotter.js +12 -19
  150. package/lib/server/trace/recorder/tracing.js +36 -27
  151. package/lib/server/trace/viewer/traceViewer.js +11 -20
  152. package/lib/server/transport.js +20 -22
  153. package/lib/server/utils/comparators.js +2 -2
  154. package/lib/server/utils/debug.js +3 -8
  155. package/lib/server/utils/debugLogger.js +8 -0
  156. package/lib/server/utils/hostPlatform.js +3 -1
  157. package/lib/server/utils/network.js +35 -25
  158. package/lib/server/utils/nodePlatform.js +1 -1
  159. package/lib/server/utils/processLauncher.js +4 -1
  160. package/lib/server/utils/wsServer.js +11 -17
  161. package/lib/server/webkit/webkit.js +5 -2
  162. package/lib/server/webkit/wkBrowser.js +51 -28
  163. package/lib/server/webkit/wkExecutionContext.js +2 -1
  164. package/lib/server/webkit/wkInput.js +25 -25
  165. package/lib/server/webkit/wkInterceptableRequest.js +1 -1
  166. package/lib/server/webkit/wkPage.js +80 -59
  167. package/lib/server/webkit/wkProvisionalPage.js +1 -1
  168. package/lib/server/webkit/wkWorkers.js +7 -7
  169. package/lib/utils/isomorphic/ariaSnapshot.js +13 -7
  170. package/lib/utils/isomorphic/cssParser.js +1 -2
  171. package/lib/utils/isomorphic/locatorGenerators.js +18 -0
  172. package/lib/utils/isomorphic/manualPromise.js +1 -2
  173. package/lib/utils/isomorphic/mimeType.js +1 -2
  174. package/lib/utils/isomorphic/multimap.js +1 -2
  175. package/lib/utils/isomorphic/oldUtilityScriptSerializers.js +248 -0
  176. package/lib/utils/isomorphic/protocolFormatter.js +78 -0
  177. package/lib/utils/isomorphic/protocolMetainfo.js +318 -0
  178. package/lib/utils/isomorphic/selectorParser.js +3 -4
  179. package/lib/utils/isomorphic/stringUtils.js +3 -24
  180. package/lib/utils/isomorphic/time.js +9 -4
  181. package/lib/utils/isomorphic/timeoutRunner.js +3 -4
  182. package/lib/utils/isomorphic/traceUtils.js +2 -3
  183. package/lib/utils/isomorphic/urlMatch.js +21 -7
  184. package/lib/utils/isomorphic/utilityScriptSerializers.js +208 -205
  185. package/lib/utils.js +8 -2
  186. package/lib/utilsBundleImpl/index.js +160 -150
  187. package/lib/vite/htmlReport/index.html +17 -17
  188. package/lib/vite/recorder/assets/{codeMirrorModule-CXVeovup.js → codeMirrorModule-DzQ0k89p.js} +1 -1
  189. package/lib/vite/recorder/assets/{index-eHBmevrY.css → index-CI4HQ-Zb.css} +1 -1
  190. package/lib/vite/recorder/assets/index-D7C7daHH.js +184 -0
  191. package/lib/vite/recorder/index.html +3 -3
  192. package/lib/vite/traceViewer/assets/{codeMirrorModule-_GLjJL-7.js → codeMirrorModule-Di48jgWx.js} +1 -1
  193. package/lib/vite/traceViewer/assets/defaultSettingsView-szBn8781.js +256 -0
  194. package/lib/vite/traceViewer/defaultSettingsView.DVJHpiGt.css +1 -0
  195. package/lib/vite/traceViewer/index.BFsek2M6.css +1 -0
  196. package/lib/vite/traceViewer/index.DQvXoPLL.js +2 -0
  197. package/lib/vite/traceViewer/index.html +6 -6
  198. package/lib/vite/traceViewer/sw.bundle.js +3 -3
  199. package/lib/vite/traceViewer/uiMode.dBV3oN9h.js +5 -0
  200. package/lib/vite/traceViewer/uiMode.html +4 -4
  201. package/lib/zipBundleImpl.js +4 -4
  202. package/package.json +1 -1
  203. package/types/protocol.d.ts +712 -107
  204. package/types/types.d.ts +148 -37
  205. package/lib/generated/consoleApiSource.js +0 -28
  206. package/lib/protocol/debug.js +0 -211
  207. package/lib/server/recorder/contextRecorder.js +0 -286
  208. package/lib/server/recorder/recorderCollection.js +0 -116
  209. package/lib/server/recorder/recorderFrontend.js +0 -16
  210. package/lib/server/storageScript.js +0 -154
  211. package/lib/server/timeoutSettings.js +0 -89
  212. package/lib/utils/isomorphic/builtins.js +0 -86
  213. package/lib/vite/recorder/assets/index-BsWQsSGl.js +0 -184
  214. package/lib/vite/traceViewer/assets/defaultSettingsView-DtCQiGHe.js +0 -265
  215. package/lib/vite/traceViewer/defaultSettingsView.QdHITyLI.css +0 -1
  216. package/lib/vite/traceViewer/index.CFOW-Ezb.css +0 -1
  217. package/lib/vite/traceViewer/index.cFZzK9RN.js +0 -2
  218. package/lib/vite/traceViewer/uiMode.XVPIqBeS.js +0 -5
@@ -18,231 +18,234 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var utilityScriptSerializers_exports = {};
20
20
  __export(utilityScriptSerializers_exports, {
21
- source: () => source
21
+ parseEvaluationResultValue: () => parseEvaluationResultValue,
22
+ serializeAsCallArgument: () => serializeAsCallArgument
22
23
  });
23
24
  module.exports = __toCommonJS(utilityScriptSerializers_exports);
24
- function source(builtins) {
25
- function isRegExp(obj) {
26
- try {
27
- return obj instanceof RegExp || Object.prototype.toString.call(obj) === "[object RegExp]";
28
- } catch (error) {
29
- return false;
30
- }
25
+ function isRegExp(obj) {
26
+ try {
27
+ return obj instanceof RegExp || Object.prototype.toString.call(obj) === "[object RegExp]";
28
+ } catch (error) {
29
+ return false;
31
30
  }
32
- function isDate(obj) {
33
- try {
34
- return obj instanceof builtins.Date || Object.prototype.toString.call(obj) === "[object Date]";
35
- } catch (error) {
36
- return false;
37
- }
38
- }
39
- function isURL(obj) {
40
- try {
41
- return obj instanceof URL || Object.prototype.toString.call(obj) === "[object URL]";
42
- } catch (error) {
43
- return false;
44
- }
45
- }
46
- function isError(obj) {
47
- try {
48
- return obj instanceof Error || obj && Object.getPrototypeOf(obj)?.name === "Error";
49
- } catch (error) {
50
- return false;
51
- }
31
+ }
32
+ function isDate(obj) {
33
+ try {
34
+ return obj instanceof Date || Object.prototype.toString.call(obj) === "[object Date]";
35
+ } catch (error) {
36
+ return false;
52
37
  }
53
- function isTypedArray(obj, constructor) {
54
- try {
55
- return obj instanceof constructor || Object.prototype.toString.call(obj) === `[object ${constructor.name}]`;
56
- } catch (error) {
57
- return false;
58
- }
38
+ }
39
+ function isURL(obj) {
40
+ try {
41
+ return obj instanceof URL || Object.prototype.toString.call(obj) === "[object URL]";
42
+ } catch (error) {
43
+ return false;
59
44
  }
60
- const typedArrayConstructors = {
61
- i8: Int8Array,
62
- ui8: Uint8Array,
63
- ui8c: Uint8ClampedArray,
64
- i16: Int16Array,
65
- ui16: Uint16Array,
66
- i32: Int32Array,
67
- ui32: Uint32Array,
68
- // TODO: add Float16Array once it's in baseline
69
- f32: Float32Array,
70
- f64: Float64Array,
71
- bi64: BigInt64Array,
72
- bui64: BigUint64Array
73
- };
74
- function typedArrayToBase64(array) {
75
- if ("toBase64" in array)
76
- return array.toBase64();
77
- const binary = Array.from(new Uint8Array(array.buffer, array.byteOffset, array.byteLength)).map((b) => String.fromCharCode(b)).join("");
78
- return btoa(binary);
45
+ }
46
+ function isError(obj) {
47
+ try {
48
+ return obj instanceof Error || obj && Object.getPrototypeOf(obj)?.name === "Error";
49
+ } catch (error) {
50
+ return false;
79
51
  }
80
- function base64ToTypedArray(base64, TypedArrayConstructor) {
81
- const binary = atob(base64);
82
- const bytes = new Uint8Array(binary.length);
83
- for (let i = 0; i < binary.length; i++)
84
- bytes[i] = binary.charCodeAt(i);
85
- return new TypedArrayConstructor(bytes.buffer);
52
+ }
53
+ function isTypedArray(obj, constructor) {
54
+ try {
55
+ return obj instanceof constructor || Object.prototype.toString.call(obj) === `[object ${constructor.name}]`;
56
+ } catch (error) {
57
+ return false;
86
58
  }
87
- function parseEvaluationResultValue(value, handles = [], refs = new builtins.Map()) {
88
- if (Object.is(value, void 0))
89
- return void 0;
90
- if (typeof value === "object" && value) {
91
- if ("ref" in value)
92
- return refs.get(value.ref);
93
- if ("v" in value) {
94
- if (value.v === "undefined")
95
- return void 0;
96
- if (value.v === "null")
97
- return null;
98
- if (value.v === "NaN")
99
- return NaN;
100
- if (value.v === "Infinity")
101
- return Infinity;
102
- if (value.v === "-Infinity")
103
- return -Infinity;
104
- if (value.v === "-0")
105
- return -0;
59
+ }
60
+ const typedArrayConstructors = {
61
+ i8: Int8Array,
62
+ ui8: Uint8Array,
63
+ ui8c: Uint8ClampedArray,
64
+ i16: Int16Array,
65
+ ui16: Uint16Array,
66
+ i32: Int32Array,
67
+ ui32: Uint32Array,
68
+ // TODO: add Float16Array once it's in baseline
69
+ f32: Float32Array,
70
+ f64: Float64Array,
71
+ bi64: BigInt64Array,
72
+ bui64: BigUint64Array
73
+ };
74
+ function typedArrayToBase64(array) {
75
+ if ("toBase64" in array)
76
+ return array.toBase64();
77
+ const binary = Array.from(new Uint8Array(array.buffer, array.byteOffset, array.byteLength)).map((b) => String.fromCharCode(b)).join("");
78
+ return btoa(binary);
79
+ }
80
+ function base64ToTypedArray(base64, TypedArrayConstructor) {
81
+ const binary = atob(base64);
82
+ const bytes = new Uint8Array(binary.length);
83
+ for (let i = 0; i < binary.length; i++)
84
+ bytes[i] = binary.charCodeAt(i);
85
+ return new TypedArrayConstructor(bytes.buffer);
86
+ }
87
+ function parseEvaluationResultValue(value, handles = [], refs = /* @__PURE__ */ new Map()) {
88
+ if (Object.is(value, void 0))
89
+ return void 0;
90
+ if (typeof value === "object" && value) {
91
+ if ("ref" in value)
92
+ return refs.get(value.ref);
93
+ if ("v" in value) {
94
+ if (value.v === "undefined")
106
95
  return void 0;
107
- }
108
- if ("d" in value)
109
- return new builtins.Date(value.d);
110
- if ("u" in value)
111
- return new URL(value.u);
112
- if ("bi" in value)
113
- return BigInt(value.bi);
114
- if ("e" in value) {
115
- const error = new Error(value.e.m);
116
- error.name = value.e.n;
117
- error.stack = value.e.s;
118
- return error;
119
- }
120
- if ("r" in value)
121
- return new RegExp(value.r.p, value.r.f);
122
- if ("a" in value) {
123
- const result = [];
124
- refs.set(value.id, result);
125
- for (const a of value.a)
126
- result.push(parseEvaluationResultValue(a, handles, refs));
127
- return result;
128
- }
129
- if ("o" in value) {
130
- const result = {};
131
- refs.set(value.id, result);
132
- for (const { k, v } of value.o)
133
- result[k] = parseEvaluationResultValue(v, handles, refs);
134
- return result;
135
- }
136
- if ("h" in value)
137
- return handles[value.h];
138
- if ("ta" in value)
139
- return base64ToTypedArray(value.ta.b, typedArrayConstructors[value.ta.k]);
140
- }
141
- return value;
142
- }
143
- function serializeAsCallArgument(value, handleSerializer) {
144
- return serialize(value, handleSerializer, { visited: new builtins.Map(), lastId: 0 });
145
- }
146
- function serialize(value, handleSerializer, visitorInfo) {
147
- if (value && typeof value === "object") {
148
- if (typeof globalThis.Window === "function" && value instanceof globalThis.Window)
149
- return "ref: <Window>";
150
- if (typeof globalThis.Document === "function" && value instanceof globalThis.Document)
151
- return "ref: <Document>";
152
- if (typeof globalThis.Node === "function" && value instanceof globalThis.Node)
153
- return "ref: <Node>";
96
+ if (value.v === "null")
97
+ return null;
98
+ if (value.v === "NaN")
99
+ return NaN;
100
+ if (value.v === "Infinity")
101
+ return Infinity;
102
+ if (value.v === "-Infinity")
103
+ return -Infinity;
104
+ if (value.v === "-0")
105
+ return -0;
106
+ return void 0;
154
107
  }
155
- return innerSerialize(value, handleSerializer, visitorInfo);
156
- }
157
- function innerSerialize(value, handleSerializer, visitorInfo) {
158
- const result = handleSerializer(value);
159
- if ("fallThrough" in result)
160
- value = result.fallThrough;
161
- else
162
- return result;
163
- if (typeof value === "symbol")
164
- return { v: "undefined" };
165
- if (Object.is(value, void 0))
166
- return { v: "undefined" };
167
- if (Object.is(value, null))
168
- return { v: "null" };
169
- if (Object.is(value, NaN))
170
- return { v: "NaN" };
171
- if (Object.is(value, Infinity))
172
- return { v: "Infinity" };
173
- if (Object.is(value, -Infinity))
174
- return { v: "-Infinity" };
175
- if (Object.is(value, -0))
176
- return { v: "-0" };
177
- if (typeof value === "boolean")
178
- return value;
179
- if (typeof value === "number")
180
- return value;
181
- if (typeof value === "string")
182
- return value;
183
- if (typeof value === "bigint")
184
- return { bi: value.toString() };
185
- if (isError(value)) {
186
- let stack;
187
- if (value.stack?.startsWith(value.name + ": " + value.message)) {
188
- stack = value.stack;
189
- } else {
190
- stack = `${value.name}: ${value.message}
191
- ${value.stack}`;
192
- }
193
- return { e: { n: value.name, m: value.message, s: stack } };
108
+ if ("d" in value) {
109
+ return new Date(value.d);
194
110
  }
195
- if (isDate(value))
196
- return { d: value.toJSON() };
197
- if (isURL(value))
198
- return { u: value.toJSON() };
199
- if (isRegExp(value))
200
- return { r: { p: value.source, f: value.flags } };
201
- for (const [k, ctor] of Object.entries(typedArrayConstructors)) {
202
- if (isTypedArray(value, ctor))
203
- return { ta: { b: typedArrayToBase64(value), k } };
111
+ if ("u" in value)
112
+ return new URL(value.u);
113
+ if ("bi" in value)
114
+ return BigInt(value.bi);
115
+ if ("e" in value) {
116
+ const error = new Error(value.e.m);
117
+ error.name = value.e.n;
118
+ error.stack = value.e.s;
119
+ return error;
204
120
  }
205
- const id = visitorInfo.visited.get(value);
206
- if (id)
207
- return { ref: id };
208
- if (Array.isArray(value)) {
209
- const a = [];
210
- const id2 = ++visitorInfo.lastId;
211
- visitorInfo.visited.set(value, id2);
212
- for (let i = 0; i < value.length; ++i)
213
- a.push(serialize(value[i], handleSerializer, visitorInfo));
214
- return { a, id: id2 };
121
+ if ("r" in value)
122
+ return new RegExp(value.r.p, value.r.f);
123
+ if ("a" in value) {
124
+ const result = [];
125
+ refs.set(value.id, result);
126
+ for (const a of value.a)
127
+ result.push(parseEvaluationResultValue(a, handles, refs));
128
+ return result;
215
129
  }
216
- if (typeof value === "object") {
217
- const o = [];
218
- const id2 = ++visitorInfo.lastId;
219
- visitorInfo.visited.set(value, id2);
220
- for (const name of Object.keys(value)) {
221
- let item;
222
- try {
223
- item = value[name];
224
- } catch (e) {
130
+ if ("o" in value) {
131
+ const result = {};
132
+ refs.set(value.id, result);
133
+ for (const { k, v } of value.o) {
134
+ if (k === "__proto__")
225
135
  continue;
226
- }
227
- if (name === "toJSON" && typeof item === "function")
228
- o.push({ k: name, v: { o: [], id: 0 } });
229
- else
230
- o.push({ k: name, v: serialize(item, handleSerializer, visitorInfo) });
136
+ result[k] = parseEvaluationResultValue(v, handles, refs);
231
137
  }
232
- let jsonWrapper;
138
+ return result;
139
+ }
140
+ if ("h" in value)
141
+ return handles[value.h];
142
+ if ("ta" in value)
143
+ return base64ToTypedArray(value.ta.b, typedArrayConstructors[value.ta.k]);
144
+ }
145
+ return value;
146
+ }
147
+ function serializeAsCallArgument(value, handleSerializer) {
148
+ return serialize(value, handleSerializer, { visited: /* @__PURE__ */ new Map(), lastId: 0 });
149
+ }
150
+ function serialize(value, handleSerializer, visitorInfo) {
151
+ if (value && typeof value === "object") {
152
+ if (typeof globalThis.Window === "function" && value instanceof globalThis.Window)
153
+ return "ref: <Window>";
154
+ if (typeof globalThis.Document === "function" && value instanceof globalThis.Document)
155
+ return "ref: <Document>";
156
+ if (typeof globalThis.Node === "function" && value instanceof globalThis.Node)
157
+ return "ref: <Node>";
158
+ }
159
+ return innerSerialize(value, handleSerializer, visitorInfo);
160
+ }
161
+ function innerSerialize(value, handleSerializer, visitorInfo) {
162
+ const result = handleSerializer(value);
163
+ if ("fallThrough" in result)
164
+ value = result.fallThrough;
165
+ else
166
+ return result;
167
+ if (typeof value === "symbol")
168
+ return { v: "undefined" };
169
+ if (Object.is(value, void 0))
170
+ return { v: "undefined" };
171
+ if (Object.is(value, null))
172
+ return { v: "null" };
173
+ if (Object.is(value, NaN))
174
+ return { v: "NaN" };
175
+ if (Object.is(value, Infinity))
176
+ return { v: "Infinity" };
177
+ if (Object.is(value, -Infinity))
178
+ return { v: "-Infinity" };
179
+ if (Object.is(value, -0))
180
+ return { v: "-0" };
181
+ if (typeof value === "boolean")
182
+ return value;
183
+ if (typeof value === "number")
184
+ return value;
185
+ if (typeof value === "string")
186
+ return value;
187
+ if (typeof value === "bigint")
188
+ return { bi: value.toString() };
189
+ if (isError(value)) {
190
+ let stack;
191
+ if (value.stack?.startsWith(value.name + ": " + value.message)) {
192
+ stack = value.stack;
193
+ } else {
194
+ stack = `${value.name}: ${value.message}
195
+ ${value.stack}`;
196
+ }
197
+ return { e: { n: value.name, m: value.message, s: stack } };
198
+ }
199
+ if (isDate(value))
200
+ return { d: value.toJSON() };
201
+ if (isURL(value))
202
+ return { u: value.toJSON() };
203
+ if (isRegExp(value))
204
+ return { r: { p: value.source, f: value.flags } };
205
+ for (const [k, ctor] of Object.entries(typedArrayConstructors)) {
206
+ if (isTypedArray(value, ctor))
207
+ return { ta: { b: typedArrayToBase64(value), k } };
208
+ }
209
+ const id = visitorInfo.visited.get(value);
210
+ if (id)
211
+ return { ref: id };
212
+ if (Array.isArray(value)) {
213
+ const a = [];
214
+ const id2 = ++visitorInfo.lastId;
215
+ visitorInfo.visited.set(value, id2);
216
+ for (let i = 0; i < value.length; ++i)
217
+ a.push(serialize(value[i], handleSerializer, visitorInfo));
218
+ return { a, id: id2 };
219
+ }
220
+ if (typeof value === "object") {
221
+ const o = [];
222
+ const id2 = ++visitorInfo.lastId;
223
+ visitorInfo.visited.set(value, id2);
224
+ for (const name of Object.keys(value)) {
225
+ let item;
233
226
  try {
234
- if (o.length === 0 && value.toJSON && typeof value.toJSON === "function")
235
- jsonWrapper = { value: value.toJSON() };
227
+ item = value[name];
236
228
  } catch (e) {
229
+ continue;
237
230
  }
238
- if (jsonWrapper)
239
- return innerSerialize(jsonWrapper.value, handleSerializer, visitorInfo);
240
- return { o, id: id2 };
231
+ if (name === "toJSON" && typeof item === "function")
232
+ o.push({ k: name, v: { o: [], id: 0 } });
233
+ else
234
+ o.push({ k: name, v: serialize(item, handleSerializer, visitorInfo) });
235
+ }
236
+ let jsonWrapper;
237
+ try {
238
+ if (o.length === 0 && value.toJSON && typeof value.toJSON === "function")
239
+ jsonWrapper = { value: value.toJSON() };
240
+ } catch (e) {
241
241
  }
242
+ if (jsonWrapper)
243
+ return innerSerialize(jsonWrapper.value, handleSerializer, visitorInfo);
244
+ return { o, id: id2 };
242
245
  }
243
- return { parseEvaluationResultValue, serializeAsCallArgument };
244
246
  }
245
247
  // Annotate the CommonJS export names for ESM import in node:
246
248
  0 && (module.exports = {
247
- source
249
+ parseEvaluationResultValue,
250
+ serializeAsCallArgument
248
251
  });
package/lib/utils.js CHANGED
@@ -22,13 +22,16 @@ __export(utils_exports, {
22
22
  colors: () => import_utilsBundle.colors
23
23
  });
24
24
  module.exports = __toCommonJS(utils_exports);
25
- __reExport(utils_exports, require("./utils/isomorphic/colors"), module.exports);
25
+ __reExport(utils_exports, require("./utils/isomorphic/ariaSnapshot"), module.exports);
26
26
  __reExport(utils_exports, require("./utils/isomorphic/assert"), module.exports);
27
+ __reExport(utils_exports, require("./utils/isomorphic/colors"), module.exports);
27
28
  __reExport(utils_exports, require("./utils/isomorphic/headers"), module.exports);
28
29
  __reExport(utils_exports, require("./utils/isomorphic/locatorGenerators"), module.exports);
29
30
  __reExport(utils_exports, require("./utils/isomorphic/manualPromise"), module.exports);
30
31
  __reExport(utils_exports, require("./utils/isomorphic/mimeType"), module.exports);
31
32
  __reExport(utils_exports, require("./utils/isomorphic/multimap"), module.exports);
33
+ __reExport(utils_exports, require("./utils/isomorphic/protocolFormatter"), module.exports);
34
+ __reExport(utils_exports, require("./utils/isomorphic/protocolMetainfo"), module.exports);
32
35
  __reExport(utils_exports, require("./utils/isomorphic/rtti"), module.exports);
33
36
  __reExport(utils_exports, require("./utils/isomorphic/semaphore"), module.exports);
34
37
  __reExport(utils_exports, require("./utils/isomorphic/stackTrace"), module.exports);
@@ -62,13 +65,16 @@ var import_utilsBundle = require("./utilsBundle");
62
65
  // Annotate the CommonJS export names for ESM import in node:
63
66
  0 && (module.exports = {
64
67
  colors,
65
- ...require("./utils/isomorphic/colors"),
68
+ ...require("./utils/isomorphic/ariaSnapshot"),
66
69
  ...require("./utils/isomorphic/assert"),
70
+ ...require("./utils/isomorphic/colors"),
67
71
  ...require("./utils/isomorphic/headers"),
68
72
  ...require("./utils/isomorphic/locatorGenerators"),
69
73
  ...require("./utils/isomorphic/manualPromise"),
70
74
  ...require("./utils/isomorphic/mimeType"),
71
75
  ...require("./utils/isomorphic/multimap"),
76
+ ...require("./utils/isomorphic/protocolFormatter"),
77
+ ...require("./utils/isomorphic/protocolMetainfo"),
72
78
  ...require("./utils/isomorphic/rtti"),
73
79
  ...require("./utils/isomorphic/semaphore"),
74
80
  ...require("./utils/isomorphic/stackTrace"),