patchright-core 1.51.2 → 1.52.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 (303) hide show
  1. package/browsers.json +15 -13
  2. package/lib/androidServerImpl.js +42 -48
  3. package/lib/browserServerImpl.js +54 -67
  4. package/lib/cli/driver.js +71 -69
  5. package/lib/cli/program.js +312 -328
  6. package/lib/cli/programWithTestStub.js +51 -45
  7. package/lib/client/accessibility.js +31 -32
  8. package/lib/client/android.js +141 -228
  9. package/lib/client/api.js +135 -283
  10. package/lib/client/artifact.js +39 -36
  11. package/lib/client/browser.js +57 -61
  12. package/lib/client/browserContext.js +297 -326
  13. package/lib/client/browserType.js +92 -106
  14. package/lib/client/cdpSession.js +29 -31
  15. package/lib/client/channelOwner.js +82 -95
  16. package/lib/client/clientHelper.js +46 -38
  17. package/lib/client/clientInstrumentation.js +40 -37
  18. package/lib/client/clientStackTrace.js +41 -37
  19. package/lib/client/clock.js +36 -36
  20. package/lib/client/connection.js +190 -212
  21. package/lib/client/consoleMessage.js +31 -28
  22. package/lib/client/coverage.js +25 -22
  23. package/lib/client/dialog.js +30 -31
  24. package/lib/client/download.js +25 -25
  25. package/lib/client/electron.js +73 -75
  26. package/lib/client/elementHandle.js +111 -147
  27. package/lib/client/errors.js +53 -53
  28. package/lib/client/eventEmitter.js +124 -121
  29. package/lib/client/events.js +72 -68
  30. package/lib/client/fetch.js +135 -158
  31. package/lib/client/fileChooser.js +25 -24
  32. package/lib/client/fileUtils.js +31 -28
  33. package/lib/client/frame.js +187 -306
  34. package/lib/client/harRouter.js +42 -52
  35. package/lib/client/input.js +40 -69
  36. package/lib/client/jsHandle.js +54 -69
  37. package/lib/client/jsonPipe.js +27 -23
  38. package/lib/client/localUtils.js +29 -28
  39. package/lib/client/locator.js +161 -245
  40. package/lib/client/network.js +277 -295
  41. package/lib/client/page.js +270 -318
  42. package/lib/client/platform.js +46 -43
  43. package/lib/client/playwright.js +51 -66
  44. package/lib/client/selectors.js +48 -46
  45. package/lib/client/stream.js +29 -25
  46. package/lib/client/timeoutSettings.js +49 -39
  47. package/lib/client/tracing.js +48 -84
  48. package/lib/client/types.js +26 -22
  49. package/lib/client/video.js +35 -27
  50. package/lib/client/waiter.js +69 -88
  51. package/lib/client/webError.js +25 -23
  52. package/lib/client/webSocket.js +61 -56
  53. package/lib/client/worker.js +48 -58
  54. package/lib/client/writableStream.js +27 -23
  55. package/lib/generated/clockSource.js +26 -5
  56. package/lib/generated/consoleApiSource.js +26 -5
  57. package/lib/generated/injectedScriptSource.js +26 -5
  58. package/lib/generated/pollingRecorderSource.js +26 -5
  59. package/lib/generated/utilityScriptSource.js +26 -5
  60. package/lib/generated/webSocketMockSource.js +375 -4
  61. package/lib/inProcessFactory.js +53 -53
  62. package/lib/inprocess.js +2 -19
  63. package/lib/outofprocess.js +53 -46
  64. package/lib/protocol/debug.js +209 -25
  65. package/lib/protocol/serializers.js +153 -134
  66. package/lib/protocol/validator.js +2714 -2714
  67. package/lib/protocol/validatorPrimitives.js +114 -73
  68. package/lib/remote/playwrightConnection.js +140 -157
  69. package/lib/remote/playwrightServer.js +99 -84
  70. package/lib/server/accessibility.js +44 -37
  71. package/lib/server/android/android.js +216 -209
  72. package/lib/server/android/backendAdb.js +89 -82
  73. package/lib/server/artifact.js +78 -55
  74. package/lib/server/bidi/bidiBrowser.js +221 -155
  75. package/lib/server/bidi/bidiChromium.js +106 -79
  76. package/lib/server/bidi/bidiConnection.js +66 -83
  77. package/lib/server/bidi/bidiExecutionContext.js +128 -113
  78. package/lib/server/bidi/bidiFirefox.js +76 -69
  79. package/lib/server/bidi/bidiInput.js +86 -97
  80. package/lib/server/bidi/bidiNetworkManager.js +137 -154
  81. package/lib/server/bidi/bidiOverCdp.js +57 -58
  82. package/lib/server/bidi/bidiPage.js +247 -219
  83. package/lib/server/bidi/bidiPdf.js +52 -86
  84. package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
  85. package/lib/server/bidi/third_party/bidiDeserializer.js +55 -50
  86. package/lib/server/bidi/third_party/bidiKeyboard.js +236 -220
  87. package/lib/server/bidi/third_party/bidiProtocol.js +144 -131
  88. package/lib/server/bidi/third_party/bidiSerializer.js +67 -63
  89. package/lib/server/bidi/third_party/firefoxPrefs.js +141 -119
  90. package/lib/server/browser.js +76 -84
  91. package/lib/server/browserContext.js +321 -346
  92. package/lib/server/browserType.js +169 -182
  93. package/lib/server/callLog.js +47 -44
  94. package/lib/server/chromium/chromium.js +212 -190
  95. package/lib/server/chromium/chromiumSwitches.js +86 -64
  96. package/lib/server/chromium/crAccessibility.js +157 -131
  97. package/lib/server/chromium/crBrowser.js +253 -273
  98. package/lib/server/chromium/crConnection.js +91 -116
  99. package/lib/server/chromium/crCoverage.js +113 -127
  100. package/lib/server/chromium/crDevTools.js +59 -51
  101. package/lib/server/chromium/crDragDrop.js +62 -79
  102. package/lib/server/chromium/crExecutionContext.js +88 -83
  103. package/lib/server/chromium/crInput.js +97 -95
  104. package/lib/server/chromium/crNetworkManager.js +288 -403
  105. package/lib/server/chromium/crPage.js +522 -608
  106. package/lib/server/chromium/crPdf.js +54 -86
  107. package/lib/server/chromium/crProtocolHelper.js +92 -80
  108. package/lib/server/chromium/crServiceWorker.js +82 -67
  109. package/lib/server/chromium/defaultFontFamilies.js +152 -135
  110. package/lib/server/chromium/protocol.d.js +16 -0
  111. package/lib/server/chromium/videoRecorder.js +65 -99
  112. package/lib/server/clock.js +62 -50
  113. package/lib/server/codegen/csharp.js +185 -160
  114. package/lib/server/codegen/java.js +155 -128
  115. package/lib/server/codegen/javascript.js +163 -148
  116. package/lib/server/codegen/jsonl.js +32 -28
  117. package/lib/server/codegen/language.js +75 -52
  118. package/lib/server/codegen/languages.js +65 -27
  119. package/lib/server/codegen/python.js +140 -125
  120. package/lib/server/codegen/types.js +15 -4
  121. package/lib/server/console.js +28 -32
  122. package/lib/server/cookieStore.js +105 -86
  123. package/lib/server/debugController.js +97 -124
  124. package/lib/server/debugger.js +82 -78
  125. package/lib/server/deviceDescriptors.js +37 -24
  126. package/lib/server/deviceDescriptorsSource.json +50 -50
  127. package/lib/server/dialog.js +36 -35
  128. package/lib/server/dispatchers/androidDispatcher.js +196 -107
  129. package/lib/server/dispatchers/artifactDispatcher.js +62 -62
  130. package/lib/server/dispatchers/browserContextDispatcher.js +176 -205
  131. package/lib/server/dispatchers/browserDispatcher.js +78 -97
  132. package/lib/server/dispatchers/browserTypeDispatcher.js +35 -35
  133. package/lib/server/dispatchers/cdpSessionDispatcher.js +32 -36
  134. package/lib/server/dispatchers/debugControllerDispatcher.js +48 -66
  135. package/lib/server/dispatchers/dialogDispatcher.js +30 -27
  136. package/lib/server/dispatchers/dispatcher.js +169 -220
  137. package/lib/server/dispatchers/electronDispatcher.js +54 -57
  138. package/lib/server/dispatchers/elementHandlerDispatcher.js +77 -119
  139. package/lib/server/dispatchers/frameDispatcher.js +99 -163
  140. package/lib/server/dispatchers/jsHandleDispatcher.js +49 -66
  141. package/lib/server/dispatchers/jsonPipeDispatcher.js +35 -36
  142. package/lib/server/dispatchers/localUtilsDispatcher.js +95 -80
  143. package/lib/server/dispatchers/networkDispatchers.js +90 -107
  144. package/lib/server/dispatchers/pageDispatcher.js +128 -169
  145. package/lib/server/dispatchers/playwrightDispatcher.js +69 -76
  146. package/lib/server/dispatchers/selectorsDispatcher.js +28 -24
  147. package/lib/server/dispatchers/streamDispatcher.js +42 -45
  148. package/lib/server/dispatchers/tracingDispatcher.js +36 -41
  149. package/lib/server/dispatchers/webSocketRouteDispatcher.js +96 -131
  150. package/lib/server/dispatchers/writableStreamDispatcher.js +54 -38
  151. package/lib/server/dom.js +413 -443
  152. package/lib/server/download.js +45 -35
  153. package/lib/server/electron/electron.js +156 -176
  154. package/lib/server/electron/loader.js +8 -36
  155. package/lib/server/errors.js +47 -46
  156. package/lib/server/fetch.js +289 -323
  157. package/lib/server/fileChooser.js +25 -24
  158. package/lib/server/fileUploadUtils.js +65 -59
  159. package/lib/server/firefox/ffAccessibility.js +153 -131
  160. package/lib/server/firefox/ffBrowser.js +213 -277
  161. package/lib/server/firefox/ffConnection.js +63 -84
  162. package/lib/server/firefox/ffExecutionContext.js +91 -73
  163. package/lib/server/firefox/ffInput.js +67 -69
  164. package/lib/server/firefox/ffNetworkManager.js +131 -110
  165. package/lib/server/firefox/ffPage.js +236 -273
  166. package/lib/server/firefox/firefox.js +76 -67
  167. package/lib/server/firefox/protocol.d.js +16 -0
  168. package/lib/server/formData.js +107 -35
  169. package/lib/server/frameSelectors.js +77 -111
  170. package/lib/server/frames.js +741 -891
  171. package/lib/server/har/harRecorder.js +85 -77
  172. package/lib/server/har/harTracer.js +287 -222
  173. package/lib/server/harBackend.js +80 -80
  174. package/lib/server/helper.js +56 -59
  175. package/lib/server/index.js +59 -99
  176. package/lib/server/input.js +134 -163
  177. package/lib/server/instrumentation.js +49 -44
  178. package/lib/server/javascript.js +143 -134
  179. package/lib/server/launchApp.js +92 -73
  180. package/lib/server/localUtils.js +130 -122
  181. package/lib/server/macEditingCommands.js +141 -137
  182. package/lib/server/network.js +262 -296
  183. package/lib/server/page.js +329 -426
  184. package/lib/server/pageBinding.js +88 -0
  185. package/lib/server/pipeTransport.js +49 -45
  186. package/lib/server/playwright.js +60 -67
  187. package/lib/server/progress.js +56 -51
  188. package/lib/server/protocolError.js +34 -31
  189. package/lib/server/recorder/chat.js +70 -86
  190. package/lib/server/recorder/contextRecorder.js +134 -138
  191. package/lib/server/recorder/recorderApp.js +127 -136
  192. package/lib/server/recorder/recorderCollection.js +56 -44
  193. package/lib/server/recorder/recorderFrontend.js +15 -4
  194. package/lib/server/recorder/recorderRunner.js +79 -103
  195. package/lib/server/recorder/recorderUtils.js +56 -45
  196. package/lib/server/recorder/throttledFile.js +42 -30
  197. package/lib/server/recorder.js +177 -186
  198. package/lib/server/registry/browserFetcher.js +106 -101
  199. package/lib/server/registry/dependencies.js +245 -196
  200. package/lib/server/registry/index.js +904 -792
  201. package/lib/server/registry/nativeDeps.js +1073 -464
  202. package/lib/server/registry/oopDownloadBrowserMain.js +57 -75
  203. package/lib/server/screenshotter.js +166 -182
  204. package/lib/server/selectors.js +85 -46
  205. package/lib/server/socksClientCertificatesInterceptor.js +166 -185
  206. package/lib/server/socksInterceptor.js +62 -70
  207. package/lib/server/storageScript.js +94 -100
  208. package/lib/server/timeoutSettings.js +58 -43
  209. package/lib/server/trace/recorder/snapshotter.js +70 -89
  210. package/lib/server/trace/recorder/snapshotterInjected.js +238 -217
  211. package/lib/server/trace/recorder/tracing.js +321 -333
  212. package/lib/server/trace/test/inMemorySnapshotter.js +46 -52
  213. package/lib/server/trace/viewer/traceViewer.js +168 -146
  214. package/lib/server/transport.js +124 -133
  215. package/lib/server/types.js +26 -22
  216. package/lib/server/usKeyboardLayout.js +135 -545
  217. package/lib/server/utils/ascii.js +39 -26
  218. package/lib/server/utils/comparators.js +105 -103
  219. package/lib/server/utils/crypto.js +157 -112
  220. package/lib/server/utils/debug.js +37 -28
  221. package/lib/server/utils/debugLogger.js +69 -48
  222. package/lib/server/utils/env.js +52 -37
  223. package/lib/server/utils/eventsHelper.js +29 -28
  224. package/lib/server/utils/expectUtils.js +31 -26
  225. package/lib/server/utils/fileUtils.js +123 -136
  226. package/lib/server/utils/happyEyeballs.js +138 -123
  227. package/lib/server/utils/hostPlatform.js +84 -120
  228. package/lib/server/utils/httpServer.js +106 -121
  229. package/lib/server/utils/image_tools/colorUtils.js +42 -51
  230. package/lib/server/utils/image_tools/compare.js +44 -43
  231. package/lib/server/utils/image_tools/imageChannel.js +38 -30
  232. package/lib/server/utils/image_tools/stats.js +40 -40
  233. package/lib/server/utils/linuxUtils.js +50 -37
  234. package/lib/server/utils/network.js +143 -86
  235. package/lib/server/utils/nodePlatform.js +87 -79
  236. package/lib/server/utils/pipeTransport.js +44 -42
  237. package/lib/server/utils/processLauncher.js +111 -121
  238. package/lib/server/utils/profiler.js +52 -39
  239. package/lib/server/utils/socksProxy.js +280 -339
  240. package/lib/server/utils/spawnAsync.js +37 -41
  241. package/lib/server/utils/task.js +31 -38
  242. package/lib/server/utils/userAgent.js +73 -66
  243. package/lib/server/utils/wsServer.js +73 -69
  244. package/lib/server/utils/zipFile.js +36 -37
  245. package/lib/server/utils/zones.js +37 -34
  246. package/lib/server/webkit/protocol.d.js +16 -0
  247. package/lib/server/webkit/webkit.js +76 -63
  248. package/lib/server/webkit/wkAccessibility.js +161 -118
  249. package/lib/server/webkit/wkBrowser.js +159 -176
  250. package/lib/server/webkit/wkConnection.js +59 -83
  251. package/lib/server/webkit/wkExecutionContext.js +84 -70
  252. package/lib/server/webkit/wkInput.js +82 -80
  253. package/lib/server/webkit/wkInterceptableRequest.js +102 -95
  254. package/lib/server/webkit/wkPage.js +525 -619
  255. package/lib/server/webkit/wkProvisionalPage.js +45 -56
  256. package/lib/server/webkit/wkWorkers.js +77 -77
  257. package/lib/utils/isomorphic/ariaSnapshot.js +144 -152
  258. package/lib/utils/isomorphic/assert.js +28 -22
  259. package/lib/utils/isomorphic/builtins.js +90 -0
  260. package/lib/utils/isomorphic/colors.js +66 -59
  261. package/lib/utils/isomorphic/cssParser.js +121 -125
  262. package/lib/utils/isomorphic/cssTokenizer.js +436 -364
  263. package/lib/utils/isomorphic/headers.js +38 -37
  264. package/lib/utils/isomorphic/locatorGenerators.js +340 -357
  265. package/lib/utils/isomorphic/locatorParser.js +96 -105
  266. package/lib/utils/isomorphic/locatorUtils.js +63 -44
  267. package/lib/utils/isomorphic/manualPromise.js +47 -39
  268. package/lib/utils/isomorphic/mimeType.js +448 -25
  269. package/lib/utils/isomorphic/multimap.js +35 -27
  270. package/lib/utils/isomorphic/rtti.js +35 -33
  271. package/lib/utils/isomorphic/selectorParser.js +183 -193
  272. package/lib/utils/isomorphic/semaphore.js +27 -24
  273. package/lib/utils/isomorphic/stackTrace.js +87 -98
  274. package/lib/utils/isomorphic/stringUtils.js +113 -106
  275. package/lib/utils/isomorphic/time.js +41 -22
  276. package/lib/utils/isomorphic/timeoutRunner.js +55 -54
  277. package/lib/utils/isomorphic/traceUtils.js +38 -41
  278. package/lib/utils/isomorphic/types.js +15 -4
  279. package/lib/utils/isomorphic/urlMatch.js +112 -67
  280. package/lib/utils/isomorphic/utilityScriptSerializers.js +248 -0
  281. package/lib/utils.js +97 -443
  282. package/lib/utilsBundle.js +101 -52
  283. package/lib/vite/htmlReport/index.html +21 -15
  284. package/lib/vite/recorder/assets/{codeMirrorModule-B9YMkrwa.js → codeMirrorModule-DVQi6prl.js} +1 -1
  285. package/lib/vite/recorder/assets/index-97EUAAbk.js +184 -0
  286. package/lib/vite/recorder/index.html +1 -1
  287. package/lib/vite/traceViewer/assets/{codeMirrorModule-DpJ-EmBQ.js → codeMirrorModule-dvXVzLxY.js} +1 -1
  288. package/lib/vite/traceViewer/assets/defaultSettingsView-BjymbO6M.js +265 -0
  289. package/lib/vite/traceViewer/{defaultSettingsView.5fN5lw10.css → defaultSettingsView.QdHITyLI.css} +1 -1
  290. package/lib/vite/traceViewer/index.ChIUCJnj.js +2 -0
  291. package/lib/vite/traceViewer/index.html +3 -3
  292. package/lib/vite/traceViewer/sw.bundle.js +3 -3
  293. package/lib/vite/traceViewer/uiMode.html +3 -3
  294. package/lib/vite/traceViewer/uiMode.jUCiCtdp.js +5 -0
  295. package/lib/zipBundle.js +32 -23
  296. package/package.json +1 -1
  297. package/types/protocol.d.ts +436 -17
  298. package/types/types.d.ts +35 -16
  299. package/lib/server/isomorphic/utilityScriptSerializers.js +0 -229
  300. package/lib/vite/recorder/assets/index-ELPgmkwA.js +0 -184
  301. package/lib/vite/traceViewer/assets/defaultSettingsView-DTenqiGw.js +0 -259
  302. package/lib/vite/traceViewer/index.CUq7VgrV.js +0 -2
  303. package/lib/vite/traceViewer/uiMode.CHJSAD7F.js +0 -5
@@ -1,33 +1,33 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var clock_exports = {};
20
+ __export(clock_exports, {
21
+ Clock: () => Clock
5
22
  });
6
- exports.Clock = void 0;
7
- /**
8
- * Copyright (c) Microsoft Corporation.
9
- *
10
- * Licensed under the Apache License, Version 2.0 (the "License");
11
- * you may not use this file except in compliance with the License.
12
- * You may obtain a copy of the License at
13
- *
14
- * http://www.apache.org/licenses/LICENSE-2.0
15
- *
16
- * Unless required by applicable law or agreed to in writing, software
17
- * distributed under the License is distributed on an "AS IS" BASIS,
18
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
- * See the License for the specific language governing permissions and
20
- * limitations under the License.
21
- */
22
-
23
+ module.exports = __toCommonJS(clock_exports);
23
24
  class Clock {
24
25
  constructor(browserContext) {
25
- this._browserContext = void 0;
26
26
  this._browserContext = browserContext;
27
27
  }
28
28
  async install(options = {}) {
29
29
  await this._browserContext.installInjectRoute();
30
- await this._browserContext._channel.clockInstall(options.time !== undefined ? parseTime(options.time) : {});
30
+ await this._browserContext._channel.clockInstall(options.time !== void 0 ? parseTime(options.time) : {});
31
31
  }
32
32
  async fastForward(ticks) {
33
33
  await this._browserContext._channel.clockFastForward(parseTicks(ticks));
@@ -48,22 +48,22 @@ class Clock {
48
48
  await this._browserContext._channel.clockSetSystemTime(parseTime(time));
49
49
  }
50
50
  }
51
- exports.Clock = Clock;
52
51
  function parseTime(time) {
53
- if (typeof time === 'number') return {
54
- timeNumber: time
55
- };
56
- if (typeof time === 'string') return {
57
- timeString: time
58
- };
59
- if (!isFinite(time.getTime())) throw new Error(`Invalid date: ${time}`);
60
- return {
61
- timeNumber: time.getTime()
62
- };
52
+ if (typeof time === "number")
53
+ return { timeNumber: time };
54
+ if (typeof time === "string")
55
+ return { timeString: time };
56
+ if (!isFinite(time.getTime()))
57
+ throw new Error(`Invalid date: ${time}`);
58
+ return { timeNumber: time.getTime() };
63
59
  }
64
60
  function parseTicks(ticks) {
65
61
  return {
66
- ticksNumber: typeof ticks === 'number' ? ticks : undefined,
67
- ticksString: typeof ticks === 'string' ? ticks : undefined
62
+ ticksNumber: typeof ticks === "number" ? ticks : void 0,
63
+ ticksString: typeof ticks === "string" ? ticks : void 0
68
64
  };
69
- }
65
+ }
66
+ // Annotate the CommonJS export names for ESM import in node:
67
+ 0 && (module.exports = {
68
+ Clock
69
+ });
@@ -1,83 +1,78 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var connection_exports = {};
20
+ __export(connection_exports, {
21
+ Connection: () => Connection
5
22
  });
6
- exports.Connection = void 0;
7
- var _eventEmitter = require("./eventEmitter");
8
- var _android = require("./android");
9
- var _artifact = require("./artifact");
10
- var _browser = require("./browser");
11
- var _browserContext = require("./browserContext");
12
- var _browserType = require("./browserType");
13
- var _cdpSession = require("./cdpSession");
14
- var _channelOwner = require("./channelOwner");
15
- var _clientInstrumentation = require("./clientInstrumentation");
16
- var _dialog = require("./dialog");
17
- var _electron = require("./electron");
18
- var _elementHandle = require("./elementHandle");
19
- var _errors = require("./errors");
20
- var _fetch = require("./fetch");
21
- var _frame = require("./frame");
22
- var _jsHandle = require("./jsHandle");
23
- var _jsonPipe = require("./jsonPipe");
24
- var _localUtils = require("./localUtils");
25
- var _network = require("./network");
26
- var _page = require("./page");
27
- var _playwright = require("./playwright");
28
- var _selectors = require("./selectors");
29
- var _stream = require("./stream");
30
- var _tracing = require("./tracing");
31
- var _worker = require("./worker");
32
- var _writableStream = require("./writableStream");
33
- var _validator = require("../protocol/validator");
34
- var _stackTrace = require("../utils/isomorphic/stackTrace");
35
- /**
36
- * Copyright (c) Microsoft Corporation.
37
- *
38
- * Licensed under the Apache License, Version 2.0 (the 'License");
39
- * you may not use this file except in compliance with the License.
40
- * You may obtain a copy of the License at
41
- *
42
- * http://www.apache.org/licenses/LICENSE-2.0
43
- *
44
- * Unless required by applicable law or agreed to in writing, software
45
- * distributed under the License is distributed on an "AS IS" BASIS,
46
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
47
- * See the License for the specific language governing permissions and
48
- * limitations under the License.
49
- */
50
-
51
- class Root extends _channelOwner.ChannelOwner {
23
+ module.exports = __toCommonJS(connection_exports);
24
+ var import_eventEmitter = require("./eventEmitter");
25
+ var import_android = require("./android");
26
+ var import_artifact = require("./artifact");
27
+ var import_browser = require("./browser");
28
+ var import_browserContext = require("./browserContext");
29
+ var import_browserType = require("./browserType");
30
+ var import_cdpSession = require("./cdpSession");
31
+ var import_channelOwner = require("./channelOwner");
32
+ var import_clientInstrumentation = require("./clientInstrumentation");
33
+ var import_dialog = require("./dialog");
34
+ var import_electron = require("./electron");
35
+ var import_elementHandle = require("./elementHandle");
36
+ var import_errors = require("./errors");
37
+ var import_fetch = require("./fetch");
38
+ var import_frame = require("./frame");
39
+ var import_jsHandle = require("./jsHandle");
40
+ var import_jsonPipe = require("./jsonPipe");
41
+ var import_localUtils = require("./localUtils");
42
+ var import_network = require("./network");
43
+ var import_page = require("./page");
44
+ var import_playwright = require("./playwright");
45
+ var import_selectors = require("./selectors");
46
+ var import_stream = require("./stream");
47
+ var import_tracing = require("./tracing");
48
+ var import_worker = require("./worker");
49
+ var import_writableStream = require("./writableStream");
50
+ var import_validator = require("../protocol/validator");
51
+ var import_stackTrace = require("../utils/isomorphic/stackTrace");
52
+ class Root extends import_channelOwner.ChannelOwner {
52
53
  constructor(connection) {
53
- super(connection, 'Root', '', {});
54
+ super(connection, "Root", "", {});
54
55
  }
55
56
  async initialize() {
56
- return _playwright.Playwright.from((await this._channel.initialize({
57
- sdkLanguage: 'javascript'
57
+ return import_playwright.Playwright.from((await this._channel.initialize({
58
+ sdkLanguage: "javascript"
58
59
  })).playwright);
59
60
  }
60
61
  }
61
- class DummyChannelOwner extends _channelOwner.ChannelOwner {}
62
- class Connection extends _eventEmitter.EventEmitter {
62
+ class DummyChannelOwner extends import_channelOwner.ChannelOwner {
63
+ }
64
+ class Connection extends import_eventEmitter.EventEmitter {
63
65
  constructor(platform, localUtils, instrumentation, headers = []) {
64
66
  super(platform);
65
- this._objects = new Map();
66
- this.onmessage = message => {};
67
+ this._objects = /* @__PURE__ */ new Map();
68
+ this.onmessage = (message) => {
69
+ };
67
70
  this._lastId = 0;
68
- this._callbacks = new Map();
69
- this._rootObject = void 0;
70
- this._closedError = void 0;
71
+ this._callbacks = /* @__PURE__ */ new Map();
71
72
  this._isRemote = false;
72
- this._localUtils = void 0;
73
73
  this._rawBuffers = false;
74
- // Some connections allow resolving in-process dispatchers.
75
- this.toImpl = void 0;
76
74
  this._tracingCount = 0;
77
- this._instrumentation = void 0;
78
- // Used from @playwright/test fixtures -> TODO remove?
79
- this.headers = void 0;
80
- this._instrumentation = instrumentation || (0, _clientInstrumentation.createInstrumentation)();
75
+ this._instrumentation = instrumentation || (0, import_clientInstrumentation.createInstrumentation)();
81
76
  this._localUtils = localUtils;
82
77
  this._rootObject = new Root(this);
83
78
  this.headers = headers;
@@ -104,237 +99,220 @@ class Connection extends _eventEmitter.EventEmitter {
104
99
  return this._objects.get(guid);
105
100
  }
106
101
  setIsTracing(isTracing) {
107
- if (isTracing) this._tracingCount++;else this._tracingCount--;
102
+ if (isTracing)
103
+ this._tracingCount++;
104
+ else
105
+ this._tracingCount--;
108
106
  }
109
107
  async sendMessageToServer(object, method, params, apiName, frames, stepId) {
110
- var _this$_localUtils;
111
- if (this._closedError) throw this._closedError;
112
- if (object._wasCollected) throw new Error('The object has been collected to prevent unbounded heap growth.');
108
+ if (this._closedError)
109
+ throw this._closedError;
110
+ if (object._wasCollected)
111
+ throw new Error("The object has been collected to prevent unbounded heap growth.");
113
112
  const guid = object._guid;
114
113
  const type = object._type;
115
114
  const id = ++this._lastId;
116
- const message = {
117
- id,
118
- guid,
119
- method,
120
- params
121
- };
122
- if (this._platform.isLogEnabled('channel')) {
123
- // Do not include metadata in debug logs to avoid noise.
124
- this._platform.log('channel', 'SEND> ' + JSON.stringify(message));
115
+ const message = { id, guid, method, params };
116
+ if (this._platform.isLogEnabled("channel")) {
117
+ this._platform.log("channel", "SEND> " + JSON.stringify(message));
125
118
  }
126
- const location = frames[0] ? {
127
- file: frames[0].file,
128
- line: frames[0].line,
129
- column: frames[0].column
130
- } : undefined;
131
- const metadata = {
132
- apiName,
133
- location,
134
- internal: !apiName,
135
- stepId
136
- };
137
- if (this._tracingCount && frames && type !== 'LocalUtils') (_this$_localUtils = this._localUtils) === null || _this$_localUtils === void 0 || _this$_localUtils.addStackToTracingNoReply({
138
- callData: {
139
- stack: frames,
140
- id
141
- }
142
- }).catch(() => {});
143
- // We need to exit zones before calling into the server, otherwise
144
- // when we receive events from the server, we would be in an API zone.
145
- this._platform.zones.empty.run(() => this.onmessage({
146
- ...message,
147
- metadata
148
- }));
149
- return await new Promise((resolve, reject) => this._callbacks.set(id, {
150
- resolve,
151
- reject,
152
- apiName,
153
- type,
154
- method
155
- }));
119
+ const location = frames[0] ? { file: frames[0].file, line: frames[0].line, column: frames[0].column } : void 0;
120
+ const metadata = { apiName, location, internal: !apiName, stepId };
121
+ if (this._tracingCount && frames && type !== "LocalUtils")
122
+ this._localUtils?.addStackToTracingNoReply({ callData: { stack: frames, id } }).catch(() => {
123
+ });
124
+ this._platform.zones.empty.run(() => this.onmessage({ ...message, metadata }));
125
+ return await new Promise((resolve, reject) => this._callbacks.set(id, { resolve, reject, apiName, type, method }));
156
126
  }
157
127
  _validatorFromWireContext() {
158
128
  return {
159
129
  tChannelImpl: this._tChannelImplFromWire.bind(this),
160
- binary: this._rawBuffers ? 'buffer' : 'fromBase64',
130
+ binary: this._rawBuffers ? "buffer" : "fromBase64",
161
131
  isUnderTest: () => this._platform.isUnderTest()
162
132
  };
163
133
  }
164
134
  dispatch(message) {
165
- if (this._closedError) return;
166
- const {
167
- id,
168
- guid,
169
- method,
170
- params,
171
- result,
172
- error,
173
- log
174
- } = message;
135
+ if (this._closedError)
136
+ return;
137
+ const { id, guid, method, params, result, error, log } = message;
175
138
  if (id) {
176
- if (this._platform.isLogEnabled('channel')) this._platform.log('channel', '<RECV ' + JSON.stringify(message));
139
+ if (this._platform.isLogEnabled("channel"))
140
+ this._platform.log("channel", "<RECV " + JSON.stringify(message));
177
141
  const callback = this._callbacks.get(id);
178
- if (!callback) throw new Error(`Cannot find command to respond: ${id}`);
142
+ if (!callback)
143
+ throw new Error(`Cannot find command to respond: ${id}`);
179
144
  this._callbacks.delete(id);
180
145
  if (error && !result) {
181
- const parsedError = (0, _errors.parseError)(error);
182
- (0, _stackTrace.rewriteErrorMessage)(parsedError, parsedError.message + formatCallLog(this._platform, log));
146
+ const parsedError = (0, import_errors.parseError)(error);
147
+ (0, import_stackTrace.rewriteErrorMessage)(parsedError, parsedError.message + formatCallLog(this._platform, log));
183
148
  callback.reject(parsedError);
184
149
  } else {
185
- const validator = (0, _validator.findValidator)(callback.type, callback.method, 'Result');
186
- callback.resolve(validator(result, '', this._validatorFromWireContext()));
150
+ const validator2 = (0, import_validator.findValidator)(callback.type, callback.method, "Result");
151
+ callback.resolve(validator2(result, "", this._validatorFromWireContext()));
187
152
  }
188
153
  return;
189
154
  }
190
- if (this._platform.isLogEnabled('channel')) this._platform.log('channel', '<EVENT ' + JSON.stringify(message));
191
- if (method === '__create__') {
155
+ if (this._platform.isLogEnabled("channel"))
156
+ this._platform.log("channel", "<EVENT " + JSON.stringify(message));
157
+ if (method === "__create__") {
192
158
  this._createRemoteObject(guid, params.type, params.guid, params.initializer);
193
159
  return;
194
160
  }
195
161
  const object = this._objects.get(guid);
196
- if (!object) throw new Error(`Cannot find object to "${method}": ${guid}`);
197
- if (method === '__adopt__') {
162
+ if (!object)
163
+ throw new Error(`Cannot find object to "${method}": ${guid}`);
164
+ if (method === "__adopt__") {
198
165
  const child = this._objects.get(params.guid);
199
- if (!child) throw new Error(`Unknown new child: ${params.guid}`);
166
+ if (!child)
167
+ throw new Error(`Unknown new child: ${params.guid}`);
200
168
  object._adopt(child);
201
169
  return;
202
170
  }
203
- if (method === '__dispose__') {
171
+ if (method === "__dispose__") {
204
172
  object._dispose(params.reason);
205
173
  return;
206
174
  }
207
- const validator = (0, _validator.findValidator)(object._type, method, 'Event');
208
- object._channel.emit(method, validator(params, '', this._validatorFromWireContext()));
175
+ const validator = (0, import_validator.findValidator)(object._type, method, "Event");
176
+ object._channel.emit(method, validator(params, "", this._validatorFromWireContext()));
209
177
  }
210
178
  close(cause) {
211
- if (this._closedError) return;
212
- this._closedError = new _errors.TargetClosedError(cause);
213
- for (const callback of this._callbacks.values()) callback.reject(this._closedError);
179
+ if (this._closedError)
180
+ return;
181
+ this._closedError = new import_errors.TargetClosedError(cause);
182
+ for (const callback of this._callbacks.values())
183
+ callback.reject(this._closedError);
214
184
  this._callbacks.clear();
215
- this.emit('close');
185
+ this.emit("close");
216
186
  }
217
187
  _tChannelImplFromWire(names, arg, path, context) {
218
- if (arg && typeof arg === 'object' && typeof arg.guid === 'string') {
188
+ if (arg && typeof arg === "object" && typeof arg.guid === "string") {
219
189
  const object = this._objects.get(arg.guid);
220
- if (!object) throw new Error(`Object with guid ${arg.guid} was not bound in the connection`);
221
- if (names !== '*' && !names.includes(object._type)) throw new _validator.ValidationError(`${path}: expected channel ${names.toString()}`);
190
+ if (!object)
191
+ throw new Error(`Object with guid ${arg.guid} was not bound in the connection`);
192
+ if (names !== "*" && !names.includes(object._type))
193
+ throw new import_validator.ValidationError(`${path}: expected channel ${names.toString()}`);
222
194
  return object._channel;
223
195
  }
224
- throw new _validator.ValidationError(`${path}: expected channel ${names.toString()}`);
196
+ throw new import_validator.ValidationError(`${path}: expected channel ${names.toString()}`);
225
197
  }
226
198
  _createRemoteObject(parentGuid, type, guid, initializer) {
227
199
  const parent = this._objects.get(parentGuid);
228
- if (!parent) throw new Error(`Cannot find parent object ${parentGuid} to create ${guid}`);
200
+ if (!parent)
201
+ throw new Error(`Cannot find parent object ${parentGuid} to create ${guid}`);
229
202
  let result;
230
- const validator = (0, _validator.findValidator)(type, '', 'Initializer');
231
- initializer = validator(initializer, '', this._validatorFromWireContext());
203
+ const validator = (0, import_validator.findValidator)(type, "", "Initializer");
204
+ initializer = validator(initializer, "", this._validatorFromWireContext());
232
205
  switch (type) {
233
- case 'Android':
234
- result = new _android.Android(parent, type, guid, initializer);
206
+ case "Android":
207
+ result = new import_android.Android(parent, type, guid, initializer);
235
208
  break;
236
- case 'AndroidSocket':
237
- result = new _android.AndroidSocket(parent, type, guid, initializer);
209
+ case "AndroidSocket":
210
+ result = new import_android.AndroidSocket(parent, type, guid, initializer);
238
211
  break;
239
- case 'AndroidDevice':
240
- result = new _android.AndroidDevice(parent, type, guid, initializer);
212
+ case "AndroidDevice":
213
+ result = new import_android.AndroidDevice(parent, type, guid, initializer);
241
214
  break;
242
- case 'APIRequestContext':
243
- result = new _fetch.APIRequestContext(parent, type, guid, initializer);
215
+ case "APIRequestContext":
216
+ result = new import_fetch.APIRequestContext(parent, type, guid, initializer);
244
217
  break;
245
- case 'Artifact':
246
- result = new _artifact.Artifact(parent, type, guid, initializer);
218
+ case "Artifact":
219
+ result = new import_artifact.Artifact(parent, type, guid, initializer);
247
220
  break;
248
- case 'BindingCall':
249
- result = new _page.BindingCall(parent, type, guid, initializer);
221
+ case "BindingCall":
222
+ result = new import_page.BindingCall(parent, type, guid, initializer);
250
223
  break;
251
- case 'Browser':
252
- result = new _browser.Browser(parent, type, guid, initializer);
224
+ case "Browser":
225
+ result = new import_browser.Browser(parent, type, guid, initializer);
253
226
  break;
254
- case 'BrowserContext':
255
- result = new _browserContext.BrowserContext(parent, type, guid, initializer);
227
+ case "BrowserContext":
228
+ result = new import_browserContext.BrowserContext(parent, type, guid, initializer);
256
229
  break;
257
- case 'BrowserType':
258
- result = new _browserType.BrowserType(parent, type, guid, initializer);
230
+ case "BrowserType":
231
+ result = new import_browserType.BrowserType(parent, type, guid, initializer);
259
232
  break;
260
- case 'CDPSession':
261
- result = new _cdpSession.CDPSession(parent, type, guid, initializer);
233
+ case "CDPSession":
234
+ result = new import_cdpSession.CDPSession(parent, type, guid, initializer);
262
235
  break;
263
- case 'Dialog':
264
- result = new _dialog.Dialog(parent, type, guid, initializer);
236
+ case "Dialog":
237
+ result = new import_dialog.Dialog(parent, type, guid, initializer);
265
238
  break;
266
- case 'Electron':
267
- result = new _electron.Electron(parent, type, guid, initializer);
239
+ case "Electron":
240
+ result = new import_electron.Electron(parent, type, guid, initializer);
268
241
  break;
269
- case 'ElectronApplication':
270
- result = new _electron.ElectronApplication(parent, type, guid, initializer);
242
+ case "ElectronApplication":
243
+ result = new import_electron.ElectronApplication(parent, type, guid, initializer);
271
244
  break;
272
- case 'ElementHandle':
273
- result = new _elementHandle.ElementHandle(parent, type, guid, initializer);
245
+ case "ElementHandle":
246
+ result = new import_elementHandle.ElementHandle(parent, type, guid, initializer);
274
247
  break;
275
- case 'Frame':
276
- result = new _frame.Frame(parent, type, guid, initializer);
248
+ case "Frame":
249
+ result = new import_frame.Frame(parent, type, guid, initializer);
277
250
  break;
278
- case 'JSHandle':
279
- result = new _jsHandle.JSHandle(parent, type, guid, initializer);
251
+ case "JSHandle":
252
+ result = new import_jsHandle.JSHandle(parent, type, guid, initializer);
280
253
  break;
281
- case 'JsonPipe':
282
- result = new _jsonPipe.JsonPipe(parent, type, guid, initializer);
254
+ case "JsonPipe":
255
+ result = new import_jsonPipe.JsonPipe(parent, type, guid, initializer);
283
256
  break;
284
- case 'LocalUtils':
285
- result = new _localUtils.LocalUtils(parent, type, guid, initializer);
286
- if (!this._localUtils) this._localUtils = result;
257
+ case "LocalUtils":
258
+ result = new import_localUtils.LocalUtils(parent, type, guid, initializer);
259
+ if (!this._localUtils)
260
+ this._localUtils = result;
287
261
  break;
288
- case 'Page':
289
- result = new _page.Page(parent, type, guid, initializer);
262
+ case "Page":
263
+ result = new import_page.Page(parent, type, guid, initializer);
290
264
  break;
291
- case 'Playwright':
292
- result = new _playwright.Playwright(parent, type, guid, initializer);
265
+ case "Playwright":
266
+ result = new import_playwright.Playwright(parent, type, guid, initializer);
293
267
  break;
294
- case 'Request':
295
- result = new _network.Request(parent, type, guid, initializer);
268
+ case "Request":
269
+ result = new import_network.Request(parent, type, guid, initializer);
296
270
  break;
297
- case 'Response':
298
- result = new _network.Response(parent, type, guid, initializer);
271
+ case "Response":
272
+ result = new import_network.Response(parent, type, guid, initializer);
299
273
  break;
300
- case 'Route':
301
- result = new _network.Route(parent, type, guid, initializer);
274
+ case "Route":
275
+ result = new import_network.Route(parent, type, guid, initializer);
302
276
  break;
303
- case 'Stream':
304
- result = new _stream.Stream(parent, type, guid, initializer);
277
+ case "Stream":
278
+ result = new import_stream.Stream(parent, type, guid, initializer);
305
279
  break;
306
- case 'Selectors':
307
- result = new _selectors.SelectorsOwner(parent, type, guid, initializer);
280
+ case "Selectors":
281
+ result = new import_selectors.SelectorsOwner(parent, type, guid, initializer);
308
282
  break;
309
- case 'SocksSupport':
283
+ case "SocksSupport":
310
284
  result = new DummyChannelOwner(parent, type, guid, initializer);
311
285
  break;
312
- case 'Tracing':
313
- result = new _tracing.Tracing(parent, type, guid, initializer);
286
+ case "Tracing":
287
+ result = new import_tracing.Tracing(parent, type, guid, initializer);
314
288
  break;
315
- case 'WebSocket':
316
- result = new _network.WebSocket(parent, type, guid, initializer);
289
+ case "WebSocket":
290
+ result = new import_network.WebSocket(parent, type, guid, initializer);
317
291
  break;
318
- case 'WebSocketRoute':
319
- result = new _network.WebSocketRoute(parent, type, guid, initializer);
292
+ case "WebSocketRoute":
293
+ result = new import_network.WebSocketRoute(parent, type, guid, initializer);
320
294
  break;
321
- case 'Worker':
322
- result = new _worker.Worker(parent, type, guid, initializer);
295
+ case "Worker":
296
+ result = new import_worker.Worker(parent, type, guid, initializer);
323
297
  break;
324
- case 'WritableStream':
325
- result = new _writableStream.WritableStream(parent, type, guid, initializer);
298
+ case "WritableStream":
299
+ result = new import_writableStream.WritableStream(parent, type, guid, initializer);
326
300
  break;
327
301
  default:
328
- throw new Error('Missing type ' + type);
302
+ throw new Error("Missing type " + type);
329
303
  }
330
304
  return result;
331
305
  }
332
306
  }
333
- exports.Connection = Connection;
334
307
  function formatCallLog(platform, log) {
335
- if (!log || !log.some(l => !!l)) return '';
308
+ if (!log || !log.some((l) => !!l))
309
+ return "";
336
310
  return `
337
311
  Call log:
338
- ${platform.colors.dim(log.join('\n'))}
312
+ ${platform.colors.dim(log.join("\n"))}
339
313
  `;
340
- }
314
+ }
315
+ // Annotate the CommonJS export names for ESM import in node:
316
+ 0 && (module.exports = {
317
+ Connection
318
+ });