@checkly/playwright-core 1.51.17-beta.1 → 1.54.2-beta.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 (376) hide show
  1. package/ThirdPartyNotices.txt +65 -123
  2. package/browsers.json +16 -14
  3. package/index.js +1 -1
  4. package/lib/androidServerImpl.js +47 -50
  5. package/lib/browserServerImpl.js +89 -69
  6. package/lib/checkly/escapeRegExp.js +23 -27
  7. package/lib/checkly/fetch.js +64 -46
  8. package/lib/checkly/secretsFilter.js +49 -36
  9. package/lib/cli/driver.js +71 -69
  10. package/lib/cli/program.js +400 -359
  11. package/lib/cli/programWithTestStub.js +51 -45
  12. package/lib/client/accessibility.js +31 -32
  13. package/lib/client/android.js +151 -242
  14. package/lib/client/api.js +135 -283
  15. package/lib/client/artifact.js +39 -36
  16. package/lib/client/browser.js +96 -71
  17. package/lib/client/browserContext.js +314 -345
  18. package/lib/client/browserType.js +103 -127
  19. package/lib/client/cdpSession.js +29 -31
  20. package/lib/client/channelOwner.js +90 -113
  21. package/lib/client/clientHelper.js +48 -39
  22. package/lib/client/clientInstrumentation.js +40 -37
  23. package/lib/client/clientStackTrace.js +41 -37
  24. package/lib/client/clock.js +36 -36
  25. package/lib/client/connection.js +188 -214
  26. package/lib/client/consoleMessage.js +31 -28
  27. package/lib/client/coverage.js +25 -22
  28. package/lib/client/dialog.js +30 -31
  29. package/lib/client/download.js +25 -25
  30. package/lib/client/electron.js +80 -77
  31. package/lib/client/elementHandle.js +120 -159
  32. package/lib/client/errors.js +53 -53
  33. package/lib/client/eventEmitter.js +124 -121
  34. package/lib/client/events.js +72 -68
  35. package/lib/client/fetch.js +166 -190
  36. package/lib/client/fileChooser.js +25 -24
  37. package/lib/client/fileUtils.js +31 -28
  38. package/lib/client/frame.js +207 -306
  39. package/lib/client/harRouter.js +42 -52
  40. package/lib/client/input.js +42 -69
  41. package/lib/client/jsHandle.js +54 -69
  42. package/lib/client/jsonPipe.js +27 -23
  43. package/lib/client/localUtils.js +29 -29
  44. package/lib/client/locator.js +145 -237
  45. package/lib/client/network.js +282 -307
  46. package/lib/client/page.js +269 -318
  47. package/lib/client/platform.js +46 -43
  48. package/lib/client/playwright.js +51 -76
  49. package/lib/client/selectors.js +45 -63
  50. package/lib/client/stream.js +29 -25
  51. package/lib/client/timeoutSettings.js +55 -41
  52. package/lib/client/tracing.js +49 -96
  53. package/lib/client/types.js +26 -22
  54. package/lib/client/video.js +35 -27
  55. package/lib/client/waiter.js +69 -88
  56. package/lib/client/webError.js +25 -23
  57. package/lib/client/webSocket.js +43 -56
  58. package/lib/client/worker.js +48 -56
  59. package/lib/client/writableStream.js +27 -23
  60. package/lib/generated/bindingsControllerSource.js +28 -0
  61. package/lib/generated/clockSource.js +26 -6
  62. package/lib/generated/consoleApiSource.js +26 -6
  63. package/lib/generated/injectedScriptSource.js +26 -6
  64. package/lib/generated/pollingRecorderSource.js +26 -6
  65. package/lib/generated/storageScriptSource.js +28 -0
  66. package/lib/generated/utilityScriptSource.js +26 -6
  67. package/lib/generated/webSocketMockSource.js +333 -5
  68. package/lib/inProcessFactory.js +51 -53
  69. package/lib/inprocess.js +2 -19
  70. package/lib/outofprocess.js +51 -46
  71. package/lib/protocol/serializers.js +153 -134
  72. package/lib/protocol/validator.js +2807 -2739
  73. package/lib/protocol/validatorPrimitives.js +114 -73
  74. package/lib/remote/playwrightConnection.js +88 -242
  75. package/lib/remote/playwrightServer.js +305 -92
  76. package/lib/server/accessibility.js +44 -37
  77. package/lib/server/android/android.js +251 -241
  78. package/lib/server/android/backendAdb.js +87 -82
  79. package/lib/server/artifact.js +78 -55
  80. package/lib/server/bidi/bidiBrowser.js +297 -158
  81. package/lib/server/bidi/bidiChromium.js +119 -89
  82. package/lib/server/bidi/bidiConnection.js +66 -83
  83. package/lib/server/bidi/bidiExecutionContext.js +129 -113
  84. package/lib/server/bidi/bidiFirefox.js +86 -76
  85. package/lib/server/bidi/bidiInput.js +106 -117
  86. package/lib/server/bidi/bidiNetworkManager.js +142 -159
  87. package/lib/server/bidi/bidiOverCdp.js +57 -58
  88. package/lib/server/bidi/bidiPage.js +260 -260
  89. package/lib/server/bidi/bidiPdf.js +52 -86
  90. package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
  91. package/lib/server/bidi/third_party/bidiDeserializer.js +55 -50
  92. package/lib/server/bidi/third_party/bidiKeyboard.js +236 -220
  93. package/lib/server/bidi/third_party/bidiProtocol.js +22 -137
  94. package/lib/server/bidi/third_party/bidiProtocolCore.js +152 -0
  95. package/lib/server/bidi/third_party/bidiProtocolPermissions.js +42 -0
  96. package/lib/server/bidi/third_party/bidiSerializer.js +67 -63
  97. package/lib/server/bidi/third_party/firefoxPrefs.js +141 -119
  98. package/lib/server/browser.js +93 -95
  99. package/lib/server/browserContext.js +419 -429
  100. package/lib/server/browserType.js +186 -216
  101. package/lib/server/callLog.js +47 -44
  102. package/lib/server/chromium/chromium.js +235 -203
  103. package/lib/server/chromium/chromiumSwitches.js +100 -67
  104. package/lib/server/chromium/crAccessibility.js +157 -131
  105. package/lib/server/chromium/crBrowser.js +310 -292
  106. package/lib/server/chromium/crConnection.js +95 -121
  107. package/lib/server/chromium/crCoverage.js +121 -131
  108. package/lib/server/chromium/crDevTools.js +60 -51
  109. package/lib/server/chromium/crDragDrop.js +68 -84
  110. package/lib/server/chromium/crExecutionContext.js +89 -83
  111. package/lib/server/chromium/crInput.js +118 -113
  112. package/lib/server/chromium/crNetworkManager.js +274 -375
  113. package/lib/server/chromium/crPage.js +536 -593
  114. package/lib/server/chromium/crPdf.js +54 -86
  115. package/lib/server/chromium/crProtocolHelper.js +92 -80
  116. package/lib/server/chromium/crServiceWorker.js +84 -73
  117. package/lib/server/chromium/defaultFontFamilies.js +152 -135
  118. package/lib/server/chromium/protocol.d.js +16 -0
  119. package/lib/server/chromium/videoRecorder.js +66 -99
  120. package/lib/server/clock.js +107 -83
  121. package/lib/server/codegen/csharp.js +192 -162
  122. package/lib/server/codegen/java.js +156 -129
  123. package/lib/server/codegen/javascript.js +163 -148
  124. package/lib/server/codegen/jsonl.js +32 -28
  125. package/lib/server/codegen/language.js +75 -52
  126. package/lib/server/codegen/languages.js +65 -27
  127. package/lib/server/codegen/python.js +141 -126
  128. package/lib/server/codegen/types.js +15 -4
  129. package/lib/server/console.js +28 -32
  130. package/lib/server/cookieStore.js +108 -86
  131. package/lib/server/debugController.js +147 -151
  132. package/lib/server/debugger.js +86 -78
  133. package/lib/server/deviceDescriptors.js +37 -24
  134. package/lib/server/deviceDescriptorsSource.json +238 -128
  135. package/lib/server/dialog.js +84 -39
  136. package/lib/server/dispatchers/androidDispatcher.js +257 -148
  137. package/lib/server/dispatchers/artifactDispatcher.js +79 -79
  138. package/lib/server/dispatchers/browserContextDispatcher.js +289 -259
  139. package/lib/server/dispatchers/browserDispatcher.js +96 -148
  140. package/lib/server/dispatchers/browserTypeDispatcher.js +50 -41
  141. package/lib/server/dispatchers/cdpSessionDispatcher.js +35 -39
  142. package/lib/server/dispatchers/debugControllerDispatcher.js +65 -83
  143. package/lib/server/dispatchers/dialogDispatcher.js +34 -31
  144. package/lib/server/dispatchers/dispatcher.js +208 -248
  145. package/lib/server/dispatchers/electronDispatcher.js +66 -70
  146. package/lib/server/dispatchers/elementHandlerDispatcher.js +164 -216
  147. package/lib/server/dispatchers/frameDispatcher.js +211 -272
  148. package/lib/server/dispatchers/jsHandleDispatcher.js +63 -75
  149. package/lib/server/dispatchers/jsonPipeDispatcher.js +37 -38
  150. package/lib/server/dispatchers/localUtilsDispatcher.js +121 -119
  151. package/lib/server/dispatchers/networkDispatchers.js +117 -128
  152. package/lib/server/dispatchers/pageDispatcher.js +256 -248
  153. package/lib/server/dispatchers/playwrightDispatcher.js +92 -87
  154. package/lib/server/dispatchers/streamDispatcher.js +52 -48
  155. package/lib/server/dispatchers/tracingDispatcher.js +47 -52
  156. package/lib/server/dispatchers/webSocketRouteDispatcher.js +126 -150
  157. package/lib/server/dispatchers/writableStreamDispatcher.js +65 -43
  158. package/lib/server/dom.js +485 -582
  159. package/lib/server/download.js +47 -37
  160. package/lib/server/electron/electron.js +216 -243
  161. package/lib/server/electron/loader.js +9 -37
  162. package/lib/server/errors.js +47 -46
  163. package/lib/server/fetch.js +317 -360
  164. package/lib/server/fileChooser.js +25 -24
  165. package/lib/server/fileUploadUtils.js +66 -60
  166. package/lib/server/firefox/ffAccessibility.js +153 -131
  167. package/lib/server/firefox/ffBrowser.js +268 -305
  168. package/lib/server/firefox/ffConnection.js +63 -84
  169. package/lib/server/firefox/ffExecutionContext.js +92 -73
  170. package/lib/server/firefox/ffInput.js +82 -84
  171. package/lib/server/firefox/ffNetworkManager.js +137 -114
  172. package/lib/server/firefox/ffPage.js +261 -293
  173. package/lib/server/firefox/firefox.js +80 -72
  174. package/lib/server/firefox/protocol.d.js +16 -0
  175. package/lib/server/formData.js +107 -35
  176. package/lib/server/frameSelectors.js +98 -114
  177. package/lib/server/frames.js +845 -1055
  178. package/lib/server/har/harRecorder.js +85 -77
  179. package/lib/server/har/harTracer.js +290 -223
  180. package/lib/server/harBackend.js +80 -80
  181. package/lib/server/helper.js +55 -59
  182. package/lib/server/index.js +59 -99
  183. package/lib/server/input.js +151 -189
  184. package/lib/server/instrumentation.js +57 -44
  185. package/lib/server/javascript.js +133 -134
  186. package/lib/server/launchApp.js +113 -75
  187. package/lib/server/localUtils.js +150 -142
  188. package/lib/server/macEditingCommands.js +141 -137
  189. package/lib/server/network.js +299 -303
  190. package/lib/server/page.js +513 -544
  191. package/lib/server/pipeTransport.js +49 -45
  192. package/lib/server/playwright.js +58 -67
  193. package/lib/server/progress.js +137 -68
  194. package/lib/server/protocolError.js +34 -31
  195. package/lib/server/recorder/chat.js +70 -86
  196. package/lib/server/recorder/recorderApp.js +341 -176
  197. package/lib/server/recorder/recorderInTraceViewer.js +65 -94
  198. package/lib/server/recorder/recorderRunner.js +93 -116
  199. package/lib/server/recorder/recorderSignalProcessor.js +83 -0
  200. package/lib/server/recorder/recorderUtils.js +104 -47
  201. package/lib/server/recorder/throttledFile.js +42 -30
  202. package/lib/server/recorder.js +395 -275
  203. package/lib/server/registry/browserFetcher.js +106 -101
  204. package/lib/server/registry/dependencies.js +245 -196
  205. package/lib/server/registry/index.js +930 -803
  206. package/lib/server/registry/nativeDeps.js +1073 -464
  207. package/lib/server/registry/oopDownloadBrowserMain.js +57 -75
  208. package/lib/server/screenshotter.js +160 -191
  209. package/lib/server/selectors.js +90 -51
  210. package/lib/server/socksClientCertificatesInterceptor.js +171 -186
  211. package/lib/server/socksInterceptor.js +62 -70
  212. package/lib/server/trace/recorder/snapshotter.js +76 -102
  213. package/lib/server/trace/recorder/snapshotterInjected.js +238 -217
  214. package/lib/server/trace/recorder/tracing.js +354 -362
  215. package/lib/server/trace/test/inMemorySnapshotter.js +46 -52
  216. package/lib/server/trace/viewer/traceViewer.js +160 -147
  217. package/lib/server/transport.js +119 -134
  218. package/lib/server/types.js +26 -22
  219. package/lib/server/usKeyboardLayout.js +135 -545
  220. package/lib/server/utils/ascii.js +39 -26
  221. package/lib/server/utils/comparators.js +105 -103
  222. package/lib/server/utils/crypto.js +157 -112
  223. package/lib/server/utils/debug.js +36 -32
  224. package/lib/server/utils/debugLogger.js +77 -48
  225. package/lib/server/utils/env.js +52 -37
  226. package/lib/server/utils/eventsHelper.js +29 -28
  227. package/lib/server/utils/expectUtils.js +31 -26
  228. package/lib/server/utils/fileUtils.js +123 -136
  229. package/lib/server/utils/happyEyeballs.js +141 -126
  230. package/lib/server/utils/hostPlatform.js +84 -120
  231. package/lib/server/utils/httpServer.js +106 -121
  232. package/lib/server/utils/image_tools/colorUtils.js +42 -51
  233. package/lib/server/utils/image_tools/compare.js +44 -43
  234. package/lib/server/utils/image_tools/imageChannel.js +38 -30
  235. package/lib/server/utils/image_tools/stats.js +40 -40
  236. package/lib/server/utils/linuxUtils.js +50 -37
  237. package/lib/server/utils/network.js +152 -96
  238. package/lib/server/utils/nodePlatform.js +87 -79
  239. package/lib/server/utils/pipeTransport.js +44 -42
  240. package/lib/server/utils/processLauncher.js +111 -121
  241. package/lib/server/utils/profiler.js +52 -39
  242. package/lib/server/utils/socksProxy.js +280 -339
  243. package/lib/server/utils/spawnAsync.js +37 -41
  244. package/lib/server/utils/task.js +31 -38
  245. package/lib/server/utils/userAgent.js +73 -66
  246. package/lib/server/utils/wsServer.js +68 -75
  247. package/lib/server/utils/zipFile.js +36 -37
  248. package/lib/server/utils/zones.js +37 -34
  249. package/lib/server/webkit/protocol.d.js +16 -0
  250. package/lib/server/webkit/webkit.js +77 -61
  251. package/lib/server/webkit/wkAccessibility.js +161 -118
  252. package/lib/server/webkit/wkBrowser.js +193 -184
  253. package/lib/server/webkit/wkConnection.js +59 -83
  254. package/lib/server/webkit/wkExecutionContext.js +85 -70
  255. package/lib/server/webkit/wkInput.js +97 -95
  256. package/lib/server/webkit/wkInterceptableRequest.js +102 -95
  257. package/lib/server/webkit/wkPage.js +568 -667
  258. package/lib/server/webkit/wkProvisionalPage.js +45 -56
  259. package/lib/server/webkit/wkWorkers.js +79 -79
  260. package/lib/utils/expectUtils.js +31 -26
  261. package/lib/utils/isomorphic/ariaSnapshot.js +149 -152
  262. package/lib/utils/isomorphic/assert.js +28 -22
  263. package/lib/utils/isomorphic/colors.js +66 -59
  264. package/lib/utils/isomorphic/cssParser.js +120 -125
  265. package/lib/utils/isomorphic/cssTokenizer.js +436 -364
  266. package/lib/utils/isomorphic/headers.js +38 -37
  267. package/lib/utils/isomorphic/locatorGenerators.js +358 -357
  268. package/lib/utils/isomorphic/locatorParser.js +96 -105
  269. package/lib/utils/isomorphic/locatorUtils.js +63 -44
  270. package/lib/utils/isomorphic/manualPromise.js +46 -39
  271. package/lib/utils/isomorphic/mimeType.js +447 -25
  272. package/lib/utils/isomorphic/multimap.js +34 -27
  273. package/lib/utils/isomorphic/protocolFormatter.js +68 -0
  274. package/lib/utils/isomorphic/protocolMetainfo.js +321 -0
  275. package/lib/utils/isomorphic/recorderUtils.js +140 -181
  276. package/lib/utils/isomorphic/rtti.js +35 -33
  277. package/lib/utils/isomorphic/selectorParser.js +182 -193
  278. package/lib/utils/isomorphic/semaphore.js +27 -24
  279. package/lib/utils/isomorphic/stackTrace.js +87 -98
  280. package/lib/utils/isomorphic/stringUtils.js +98 -112
  281. package/lib/utils/isomorphic/time.js +46 -22
  282. package/lib/utils/isomorphic/timeoutRunner.js +53 -53
  283. package/lib/utils/isomorphic/traceUtils.js +37 -41
  284. package/lib/utils/isomorphic/types.js +15 -4
  285. package/lib/utils/isomorphic/urlMatch.js +113 -67
  286. package/lib/utils/isomorphic/utilityScriptSerializers.js +251 -0
  287. package/lib/utils.js +101 -443
  288. package/lib/utilsBundle.js +101 -52
  289. package/lib/utilsBundleImpl/index.js +160 -150
  290. package/lib/zipBundle.js +32 -23
  291. package/lib/zipBundleImpl.js +4 -4
  292. package/package.json +1 -1
  293. package/types/protocol.d.ts +1267 -1057
  294. package/types/types.d.ts +131 -29
  295. package/lib/common/socksProxy.js +0 -569
  296. package/lib/common/timeoutSettings.js +0 -73
  297. package/lib/common/types.js +0 -5
  298. package/lib/image_tools/colorUtils.js +0 -98
  299. package/lib/image_tools/compare.js +0 -108
  300. package/lib/image_tools/imageChannel.js +0 -70
  301. package/lib/image_tools/stats.js +0 -102
  302. package/lib/protocol/debug.js +0 -27
  303. package/lib/protocol/transport.js +0 -82
  304. package/lib/server/dispatchers/selectorsDispatcher.js +0 -36
  305. package/lib/server/isomorphic/utilityScriptSerializers.js +0 -229
  306. package/lib/server/recorder/contextRecorder.js +0 -290
  307. package/lib/server/recorder/recorderCollection.js +0 -104
  308. package/lib/server/recorder/recorderFrontend.js +0 -5
  309. package/lib/server/storageScript.js +0 -160
  310. package/lib/server/timeoutSettings.js +0 -74
  311. package/lib/third_party/diff_match_patch.js +0 -2222
  312. package/lib/utils/ascii.js +0 -31
  313. package/lib/utils/comparators.js +0 -171
  314. package/lib/utils/crypto.js +0 -174
  315. package/lib/utils/debug.js +0 -46
  316. package/lib/utils/debugLogger.js +0 -91
  317. package/lib/utils/env.js +0 -49
  318. package/lib/utils/eventsHelper.js +0 -38
  319. package/lib/utils/fileUtils.js +0 -205
  320. package/lib/utils/happy-eyeballs.js +0 -210
  321. package/lib/utils/headers.js +0 -52
  322. package/lib/utils/hostPlatform.js +0 -133
  323. package/lib/utils/httpServer.js +0 -237
  324. package/lib/utils/index.js +0 -368
  325. package/lib/utils/linuxUtils.js +0 -78
  326. package/lib/utils/manualPromise.js +0 -109
  327. package/lib/utils/multimap.js +0 -75
  328. package/lib/utils/network.js +0 -160
  329. package/lib/utils/processLauncher.js +0 -248
  330. package/lib/utils/profiler.js +0 -53
  331. package/lib/utils/rtti.js +0 -44
  332. package/lib/utils/semaphore.js +0 -51
  333. package/lib/utils/spawnAsync.js +0 -45
  334. package/lib/utils/stackTrace.js +0 -121
  335. package/lib/utils/task.js +0 -58
  336. package/lib/utils/time.js +0 -37
  337. package/lib/utils/timeoutRunner.js +0 -66
  338. package/lib/utils/traceUtils.js +0 -44
  339. package/lib/utils/userAgent.js +0 -105
  340. package/lib/utils/wsServer.js +0 -127
  341. package/lib/utils/zipFile.js +0 -75
  342. package/lib/utils/zones.js +0 -62
  343. package/lib/vite/htmlReport/index.html +0 -69
  344. package/lib/vite/recorder/assets/codeMirrorModule-DrMbgOIo.js +0 -16684
  345. package/lib/vite/recorder/assets/codeMirrorModule-DuST8d_k.css +0 -344
  346. package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
  347. package/lib/vite/recorder/assets/index-5NM3V7eb.css +0 -2524
  348. package/lib/vite/recorder/assets/index-CT-scFHn.js +0 -16848
  349. package/lib/vite/recorder/index.html +0 -29
  350. package/lib/vite/recorder/playwright-logo.svg +0 -9
  351. package/lib/vite/traceViewer/assets/codeMirrorModule-CB-2okZ8.js +0 -16684
  352. package/lib/vite/traceViewer/assets/defaultSettingsView-CBiB4avC.js +0 -217
  353. package/lib/vite/traceViewer/assets/inspectorTab-CwgfffWb.js +0 -25143
  354. package/lib/vite/traceViewer/assets/workbench-CWZselvp.js +0 -2470
  355. package/lib/vite/traceViewer/assets/xtermModule-Es_gt_u7.js +0 -5994
  356. package/lib/vite/traceViewer/codeMirrorModule.DuST8d_k.css +0 -344
  357. package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
  358. package/lib/vite/traceViewer/defaultSettingsView.Dp3b_92q.css +0 -41
  359. package/lib/vite/traceViewer/embedded.BeldSa2G.css +0 -68
  360. package/lib/vite/traceViewer/embedded.gzudoghF.js +0 -106
  361. package/lib/vite/traceViewer/embedded.html +0 -18
  362. package/lib/vite/traceViewer/index.DilotR1h.js +0 -314
  363. package/lib/vite/traceViewer/index.QewjJ85u.css +0 -131
  364. package/lib/vite/traceViewer/index.html +0 -47
  365. package/lib/vite/traceViewer/inspectorTab.DnGm18kV.css +0 -3178
  366. package/lib/vite/traceViewer/playwright-logo.svg +0 -9
  367. package/lib/vite/traceViewer/recorder.DLgqV9db.css +0 -15
  368. package/lib/vite/traceViewer/recorder.DVrkq3Um.js +0 -551
  369. package/lib/vite/traceViewer/recorder.html +0 -17
  370. package/lib/vite/traceViewer/snapshot.html +0 -21
  371. package/lib/vite/traceViewer/sw.bundle.js +0 -3
  372. package/lib/vite/traceViewer/uiMode.C9_OcpPU.js +0 -1756
  373. package/lib/vite/traceViewer/uiMode.c5ORgcrX.css +0 -1424
  374. package/lib/vite/traceViewer/uiMode.html +0 -21
  375. package/lib/vite/traceViewer/workbench.xUZSA8PY.css +0 -787
  376. package/lib/vite/traceViewer/xtermModule.EsaqrrTX.css +0 -209
@@ -1,8 +1,336 @@
1
1
  "use strict";
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 webSocketMockSource_exports = {};
20
+ __export(webSocketMockSource_exports, {
21
+ source: () => source
22
+ });
23
+ module.exports = __toCommonJS(webSocketMockSource_exports);
24
+ const source = `
25
+ var __commonJS = obj => {
26
+ let required = false;
27
+ let result;
28
+ return function __require() {
29
+ if (!required) {
30
+ required = true;
31
+ let fn;
32
+ for (const name in obj) { fn = obj[name]; break; }
33
+ const module = { exports: {} };
34
+ fn(module.exports, module);
35
+ result = module.exports;
36
+ }
37
+ return result;
38
+ }
39
+ };
40
+ var __export = (target, all) => {for (var name in all) target[name] = all[name];};
41
+ var __toESM = mod => ({ ...mod, 'default': mod });
42
+ var __toCommonJS = mod => ({ ...mod, __esModule: true });
43
+
2
44
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
45
+ // packages/injected/src/webSocketMock.ts
46
+ var webSocketMock_exports = {};
47
+ __export(webSocketMock_exports, {
48
+ inject: () => inject
49
+ });
50
+ module.exports = __toCommonJS(webSocketMock_exports);
51
+ function inject(globalThis) {
52
+ if (globalThis.__pwWebSocketDispatch)
53
+ return;
54
+ function generateId() {
55
+ const bytes = new Uint8Array(32);
56
+ globalThis.crypto.getRandomValues(bytes);
57
+ const hex = "0123456789abcdef";
58
+ return [...bytes].map((value) => {
59
+ const high = Math.floor(value / 16);
60
+ const low = value % 16;
61
+ return hex[high] + hex[low];
62
+ }).join("");
63
+ }
64
+ function bufferToData(b) {
65
+ let s = "";
66
+ for (let i = 0; i < b.length; i++)
67
+ s += String.fromCharCode(b[i]);
68
+ return { data: globalThis.btoa(s), isBase64: true };
69
+ }
70
+ function stringToBuffer(s) {
71
+ s = globalThis.atob(s);
72
+ const b = new Uint8Array(s.length);
73
+ for (let i = 0; i < s.length; i++)
74
+ b[i] = s.charCodeAt(i);
75
+ return b.buffer;
76
+ }
77
+ function messageToData(message, cb) {
78
+ if (message instanceof globalThis.Blob)
79
+ return message.arrayBuffer().then((buffer) => cb(bufferToData(new Uint8Array(buffer))));
80
+ if (typeof message === "string")
81
+ return cb({ data: message, isBase64: false });
82
+ if (ArrayBuffer.isView(message))
83
+ return cb(bufferToData(new Uint8Array(message.buffer, message.byteOffset, message.byteLength)));
84
+ return cb(bufferToData(new Uint8Array(message)));
85
+ }
86
+ function dataToMessage(data, binaryType) {
87
+ if (!data.isBase64)
88
+ return data.data;
89
+ const buffer = stringToBuffer(data.data);
90
+ return binaryType === "arraybuffer" ? buffer : new Blob([buffer]);
91
+ }
92
+ const binding = globalThis.__pwWebSocketBinding;
93
+ const NativeWebSocket = globalThis.WebSocket;
94
+ const idToWebSocket = /* @__PURE__ */ new Map();
95
+ globalThis.__pwWebSocketDispatch = (request) => {
96
+ const ws = idToWebSocket.get(request.id);
97
+ if (!ws)
98
+ return;
99
+ if (request.type === "connect")
100
+ ws._apiConnect();
101
+ if (request.type === "passthrough")
102
+ ws._apiPassThrough();
103
+ if (request.type === "ensureOpened")
104
+ ws._apiEnsureOpened();
105
+ if (request.type === "sendToPage")
106
+ ws._apiSendToPage(dataToMessage(request.data, ws.binaryType));
107
+ if (request.type === "closePage")
108
+ ws._apiClosePage(request.code, request.reason, request.wasClean);
109
+ if (request.type === "sendToServer")
110
+ ws._apiSendToServer(dataToMessage(request.data, ws.binaryType));
111
+ if (request.type === "closeServer")
112
+ ws._apiCloseServer(request.code, request.reason, request.wasClean);
113
+ };
114
+ const _WebSocketMock = class _WebSocketMock extends EventTarget {
115
+ constructor(url, protocols) {
116
+ var _a, _b;
117
+ super();
118
+ // WebSocket.CLOSED
119
+ this.CONNECTING = 0;
120
+ // WebSocket.CONNECTING
121
+ this.OPEN = 1;
122
+ // WebSocket.OPEN
123
+ this.CLOSING = 2;
124
+ // WebSocket.CLOSING
125
+ this.CLOSED = 3;
126
+ // WebSocket.CLOSED
127
+ this._oncloseListener = null;
128
+ this._onerrorListener = null;
129
+ this._onmessageListener = null;
130
+ this._onopenListener = null;
131
+ this.bufferedAmount = 0;
132
+ this.extensions = "";
133
+ this.protocol = "";
134
+ this.readyState = 0;
135
+ this._origin = "";
136
+ this._passthrough = false;
137
+ this._wsBufferedMessages = [];
138
+ this._binaryType = "blob";
139
+ this.url = new URL(url, globalThis.window.document.baseURI).href.replace(/^http/, "ws");
140
+ this._origin = (_b = (_a = URL.parse(this.url)) == null ? void 0 : _a.origin) != null ? _b : "";
141
+ this._protocols = protocols;
142
+ this._id = generateId();
143
+ idToWebSocket.set(this._id, this);
144
+ binding({ type: "onCreate", id: this._id, url: this.url });
145
+ }
146
+ // --- native WebSocket implementation ---
147
+ get binaryType() {
148
+ return this._binaryType;
149
+ }
150
+ set binaryType(type) {
151
+ this._binaryType = type;
152
+ if (this._ws)
153
+ this._ws.binaryType = type;
154
+ }
155
+ get onclose() {
156
+ return this._oncloseListener;
157
+ }
158
+ set onclose(listener) {
159
+ if (this._oncloseListener)
160
+ this.removeEventListener("close", this._oncloseListener);
161
+ this._oncloseListener = listener;
162
+ if (this._oncloseListener)
163
+ this.addEventListener("close", this._oncloseListener);
164
+ }
165
+ get onerror() {
166
+ return this._onerrorListener;
167
+ }
168
+ set onerror(listener) {
169
+ if (this._onerrorListener)
170
+ this.removeEventListener("error", this._onerrorListener);
171
+ this._onerrorListener = listener;
172
+ if (this._onerrorListener)
173
+ this.addEventListener("error", this._onerrorListener);
174
+ }
175
+ get onopen() {
176
+ return this._onopenListener;
177
+ }
178
+ set onopen(listener) {
179
+ if (this._onopenListener)
180
+ this.removeEventListener("open", this._onopenListener);
181
+ this._onopenListener = listener;
182
+ if (this._onopenListener)
183
+ this.addEventListener("open", this._onopenListener);
184
+ }
185
+ get onmessage() {
186
+ return this._onmessageListener;
187
+ }
188
+ set onmessage(listener) {
189
+ if (this._onmessageListener)
190
+ this.removeEventListener("message", this._onmessageListener);
191
+ this._onmessageListener = listener;
192
+ if (this._onmessageListener)
193
+ this.addEventListener("message", this._onmessageListener);
194
+ }
195
+ send(message) {
196
+ if (this.readyState === _WebSocketMock.CONNECTING)
197
+ throw new DOMException(\`Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.\`);
198
+ if (this.readyState !== _WebSocketMock.OPEN)
199
+ throw new DOMException(\`WebSocket is already in CLOSING or CLOSED state.\`);
200
+ if (this._passthrough) {
201
+ if (this._ws)
202
+ this._apiSendToServer(message);
203
+ } else {
204
+ messageToData(message, (data) => binding({ type: "onMessageFromPage", id: this._id, data }));
205
+ }
206
+ }
207
+ close(code, reason) {
208
+ if (code !== void 0 && code !== 1e3 && (code < 3e3 || code > 4999))
209
+ throw new DOMException(\`Failed to execute 'close' on 'WebSocket': The close code must be either 1000, or between 3000 and 4999. \${code} is neither.\`);
210
+ if (this.readyState === _WebSocketMock.OPEN || this.readyState === _WebSocketMock.CONNECTING)
211
+ this.readyState = _WebSocketMock.CLOSING;
212
+ if (this._passthrough)
213
+ this._apiCloseServer(code, reason, true);
214
+ else
215
+ binding({ type: "onClosePage", id: this._id, code, reason, wasClean: true });
216
+ }
217
+ // --- methods called from the routing API ---
218
+ _apiEnsureOpened() {
219
+ if (!this._ws)
220
+ this._ensureOpened();
221
+ }
222
+ _apiSendToPage(message) {
223
+ this._ensureOpened();
224
+ if (this.readyState !== _WebSocketMock.OPEN)
225
+ throw new DOMException(\`WebSocket is already in CLOSING or CLOSED state.\`);
226
+ this.dispatchEvent(new MessageEvent("message", { data: message, origin: this._origin, cancelable: true }));
227
+ }
228
+ _apiSendToServer(message) {
229
+ if (!this._ws)
230
+ throw new Error("Cannot send a message before connecting to the server");
231
+ if (this._ws.readyState === _WebSocketMock.CONNECTING)
232
+ this._wsBufferedMessages.push(message);
233
+ else
234
+ this._ws.send(message);
235
+ }
236
+ _apiConnect() {
237
+ if (this._ws)
238
+ throw new Error("Can only connect to the server once");
239
+ this._ws = new NativeWebSocket(this.url, this._protocols);
240
+ this._ws.binaryType = this._binaryType;
241
+ this._ws.onopen = () => {
242
+ for (const message of this._wsBufferedMessages)
243
+ this._ws.send(message);
244
+ this._wsBufferedMessages = [];
245
+ this._ensureOpened();
246
+ };
247
+ this._ws.onclose = (event) => {
248
+ this._onWSClose(event.code, event.reason, event.wasClean);
249
+ };
250
+ this._ws.onmessage = (event) => {
251
+ if (this._passthrough)
252
+ this._apiSendToPage(event.data);
253
+ else
254
+ messageToData(event.data, (data) => binding({ type: "onMessageFromServer", id: this._id, data }));
255
+ };
256
+ this._ws.onerror = () => {
257
+ const event = new Event("error", { cancelable: true });
258
+ this.dispatchEvent(event);
259
+ };
260
+ }
261
+ // This method connects to the server, and passes all messages through,
262
+ // as if WebSocketMock was not engaged.
263
+ _apiPassThrough() {
264
+ this._passthrough = true;
265
+ this._apiConnect();
266
+ }
267
+ _apiCloseServer(code, reason, wasClean) {
268
+ if (!this._ws) {
269
+ this._onWSClose(code, reason, wasClean);
270
+ return;
271
+ }
272
+ if (this._ws.readyState === _WebSocketMock.CONNECTING || this._ws.readyState === _WebSocketMock.OPEN)
273
+ this._ws.close(code, reason);
274
+ }
275
+ _apiClosePage(code, reason, wasClean) {
276
+ if (this.readyState === _WebSocketMock.CLOSED)
277
+ return;
278
+ this.readyState = _WebSocketMock.CLOSED;
279
+ this.dispatchEvent(new CloseEvent("close", { code, reason, wasClean, cancelable: true }));
280
+ this._maybeCleanup();
281
+ if (this._passthrough)
282
+ this._apiCloseServer(code, reason, wasClean);
283
+ else
284
+ binding({ type: "onClosePage", id: this._id, code, reason, wasClean });
285
+ }
286
+ // --- internals ---
287
+ _ensureOpened() {
288
+ var _a;
289
+ if (this.readyState !== _WebSocketMock.CONNECTING)
290
+ return;
291
+ this.extensions = ((_a = this._ws) == null ? void 0 : _a.extensions) || "";
292
+ if (this._ws)
293
+ this.protocol = this._ws.protocol;
294
+ else if (Array.isArray(this._protocols))
295
+ this.protocol = this._protocols[0] || "";
296
+ else
297
+ this.protocol = this._protocols || "";
298
+ this.readyState = _WebSocketMock.OPEN;
299
+ this.dispatchEvent(new Event("open", { cancelable: true }));
300
+ }
301
+ _onWSClose(code, reason, wasClean) {
302
+ if (this._passthrough)
303
+ this._apiClosePage(code, reason, wasClean);
304
+ else
305
+ binding({ type: "onCloseServer", id: this._id, code, reason, wasClean });
306
+ if (this._ws) {
307
+ this._ws.onopen = null;
308
+ this._ws.onclose = null;
309
+ this._ws.onmessage = null;
310
+ this._ws.onerror = null;
311
+ this._ws = void 0;
312
+ this._wsBufferedMessages = [];
313
+ }
314
+ this._maybeCleanup();
315
+ }
316
+ _maybeCleanup() {
317
+ if (this.readyState === _WebSocketMock.CLOSED && !this._ws)
318
+ idToWebSocket.delete(this._id);
319
+ }
320
+ };
321
+ _WebSocketMock.CONNECTING = 0;
322
+ // WebSocket.CONNECTING
323
+ _WebSocketMock.OPEN = 1;
324
+ // WebSocket.OPEN
325
+ _WebSocketMock.CLOSING = 2;
326
+ // WebSocket.CLOSING
327
+ _WebSocketMock.CLOSED = 3;
328
+ let WebSocketMock = _WebSocketMock;
329
+ globalThis.WebSocket = class WebSocket extends WebSocketMock {
330
+ };
331
+ }
332
+ `;
333
+ // Annotate the CommonJS export names for ESM import in node:
334
+ 0 && (module.exports = {
335
+ source
5
336
  });
6
- exports.source = void 0;
7
- const source = exports.source = "\nvar __commonJS = obj => {\n let required = false;\n let result;\n return function __require() {\n if (!required) {\n required = true;\n let fn;\n for (const name in obj) { fn = obj[name]; break; }\n const module = { exports: {} };\n fn(module.exports, module);\n result = module.exports;\n }\n return result;\n }\n};\nvar __export = (target, all) => {for (var name in all) target[name] = all[name];};\nvar __toESM = mod => ({ ...mod, 'default': mod });\nvar __toCommonJS = mod => ({ ...mod, __esModule: true });\n\n\n// packages/playwright-core/src/server/injected/webSocketMock.ts\nvar webSocketMock_exports = {};\n__export(webSocketMock_exports, {\n inject: () => inject\n});\nmodule.exports = __toCommonJS(webSocketMock_exports);\nfunction inject(globalThis) {\n if (globalThis.__pwWebSocketDispatch)\n return;\n function generateId() {\n const bytes = new Uint8Array(32);\n globalThis.crypto.getRandomValues(bytes);\n const hex = \"0123456789abcdef\";\n return [...bytes].map((value) => {\n const high = Math.floor(value / 16);\n const low = value % 16;\n return hex[high] + hex[low];\n }).join(\"\");\n }\n function bufferToData(b) {\n let s = \"\";\n for (let i = 0; i < b.length; i++)\n s += String.fromCharCode(b[i]);\n return { data: globalThis.btoa(s), isBase64: true };\n }\n function stringToBuffer(s) {\n s = globalThis.atob(s);\n const b = new Uint8Array(s.length);\n for (let i = 0; i < s.length; i++)\n b[i] = s.charCodeAt(i);\n return b.buffer;\n }\n function messageToData(message, cb) {\n if (message instanceof globalThis.Blob)\n return message.arrayBuffer().then((buffer) => cb(bufferToData(new Uint8Array(buffer))));\n if (typeof message === \"string\")\n return cb({ data: message, isBase64: false });\n if (ArrayBuffer.isView(message))\n return cb(bufferToData(new Uint8Array(message.buffer, message.byteOffset, message.byteLength)));\n return cb(bufferToData(new Uint8Array(message)));\n }\n function dataToMessage(data, binaryType) {\n if (!data.isBase64)\n return data.data;\n const buffer = stringToBuffer(data.data);\n return binaryType === \"arraybuffer\" ? buffer : new Blob([buffer]);\n }\n const binding = globalThis.__pwWebSocketBinding;\n const NativeWebSocket = globalThis.WebSocket;\n const idToWebSocket = /* @__PURE__ */ new Map();\n globalThis.__pwWebSocketDispatch = (request) => {\n const ws = idToWebSocket.get(request.id);\n if (!ws)\n return;\n if (request.type === \"connect\")\n ws._apiConnect();\n if (request.type === \"passthrough\")\n ws._apiPassThrough();\n if (request.type === \"ensureOpened\")\n ws._apiEnsureOpened();\n if (request.type === \"sendToPage\")\n ws._apiSendToPage(dataToMessage(request.data, ws.binaryType));\n if (request.type === \"closePage\")\n ws._apiClosePage(request.code, request.reason, request.wasClean);\n if (request.type === \"sendToServer\")\n ws._apiSendToServer(dataToMessage(request.data, ws.binaryType));\n if (request.type === \"closeServer\")\n ws._apiCloseServer(request.code, request.reason, request.wasClean);\n };\n const _WebSocketMock = class _WebSocketMock extends EventTarget {\n constructor(url, protocols) {\n super();\n // WebSocket.CLOSED\n this.CONNECTING = 0;\n // WebSocket.CONNECTING\n this.OPEN = 1;\n // WebSocket.OPEN\n this.CLOSING = 2;\n // WebSocket.CLOSING\n this.CLOSED = 3;\n // WebSocket.CLOSED\n this._oncloseListener = null;\n this._onerrorListener = null;\n this._onmessageListener = null;\n this._onopenListener = null;\n this.bufferedAmount = 0;\n this.extensions = \"\";\n this.protocol = \"\";\n this.readyState = 0;\n this._origin = \"\";\n this._passthrough = false;\n this._wsBufferedMessages = [];\n this._binaryType = \"blob\";\n this.url = typeof url === \"string\" ? url : url.href;\n try {\n this.url = new URL(url).href;\n this._origin = new URL(url).origin;\n } catch {\n }\n this._protocols = protocols;\n this._id = generateId();\n idToWebSocket.set(this._id, this);\n binding({ type: \"onCreate\", id: this._id, url: this.url });\n }\n // --- native WebSocket implementation ---\n get binaryType() {\n return this._binaryType;\n }\n set binaryType(type) {\n this._binaryType = type;\n if (this._ws)\n this._ws.binaryType = type;\n }\n get onclose() {\n return this._oncloseListener;\n }\n set onclose(listener) {\n if (this._oncloseListener)\n this.removeEventListener(\"close\", this._oncloseListener);\n this._oncloseListener = listener;\n if (this._oncloseListener)\n this.addEventListener(\"close\", this._oncloseListener);\n }\n get onerror() {\n return this._onerrorListener;\n }\n set onerror(listener) {\n if (this._onerrorListener)\n this.removeEventListener(\"error\", this._onerrorListener);\n this._onerrorListener = listener;\n if (this._onerrorListener)\n this.addEventListener(\"error\", this._onerrorListener);\n }\n get onopen() {\n return this._onopenListener;\n }\n set onopen(listener) {\n if (this._onopenListener)\n this.removeEventListener(\"open\", this._onopenListener);\n this._onopenListener = listener;\n if (this._onopenListener)\n this.addEventListener(\"open\", this._onopenListener);\n }\n get onmessage() {\n return this._onmessageListener;\n }\n set onmessage(listener) {\n if (this._onmessageListener)\n this.removeEventListener(\"message\", this._onmessageListener);\n this._onmessageListener = listener;\n if (this._onmessageListener)\n this.addEventListener(\"message\", this._onmessageListener);\n }\n send(message) {\n if (this.readyState === _WebSocketMock.CONNECTING)\n throw new DOMException(`Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.`);\n if (this.readyState !== _WebSocketMock.OPEN)\n throw new DOMException(`WebSocket is already in CLOSING or CLOSED state.`);\n if (this._passthrough) {\n if (this._ws)\n this._apiSendToServer(message);\n } else {\n messageToData(message, (data) => binding({ type: \"onMessageFromPage\", id: this._id, data }));\n }\n }\n close(code, reason) {\n if (code !== void 0 && code !== 1e3 && (code < 3e3 || code > 4999))\n throw new DOMException(`Failed to execute 'close' on 'WebSocket': The close code must be either 1000, or between 3000 and 4999. ${code} is neither.`);\n if (this.readyState === _WebSocketMock.OPEN || this.readyState === _WebSocketMock.CONNECTING)\n this.readyState = _WebSocketMock.CLOSING;\n if (this._passthrough)\n this._apiCloseServer(code, reason, true);\n else\n binding({ type: \"onClosePage\", id: this._id, code, reason, wasClean: true });\n }\n // --- methods called from the routing API ---\n _apiEnsureOpened() {\n if (!this._ws)\n this._ensureOpened();\n }\n _apiSendToPage(message) {\n this._ensureOpened();\n if (this.readyState !== _WebSocketMock.OPEN)\n throw new DOMException(`WebSocket is already in CLOSING or CLOSED state.`);\n this.dispatchEvent(new MessageEvent(\"message\", { data: message, origin: this._origin, cancelable: true }));\n }\n _apiSendToServer(message) {\n if (!this._ws)\n throw new Error(\"Cannot send a message before connecting to the server\");\n if (this._ws.readyState === _WebSocketMock.CONNECTING)\n this._wsBufferedMessages.push(message);\n else\n this._ws.send(message);\n }\n _apiConnect() {\n if (this._ws)\n throw new Error(\"Can only connect to the server once\");\n this._ws = new NativeWebSocket(this.url, this._protocols);\n this._ws.binaryType = this._binaryType;\n this._ws.onopen = () => {\n for (const message of this._wsBufferedMessages)\n this._ws.send(message);\n this._wsBufferedMessages = [];\n this._ensureOpened();\n };\n this._ws.onclose = (event) => {\n this._onWSClose(event.code, event.reason, event.wasClean);\n };\n this._ws.onmessage = (event) => {\n if (this._passthrough)\n this._apiSendToPage(event.data);\n else\n messageToData(event.data, (data) => binding({ type: \"onMessageFromServer\", id: this._id, data }));\n };\n this._ws.onerror = () => {\n const event = new Event(\"error\", { cancelable: true });\n this.dispatchEvent(event);\n };\n }\n // This method connects to the server, and passes all messages through,\n // as if WebSocketMock was not engaged.\n _apiPassThrough() {\n this._passthrough = true;\n this._apiConnect();\n }\n _apiCloseServer(code, reason, wasClean) {\n if (!this._ws) {\n this._onWSClose(code, reason, wasClean);\n return;\n }\n if (this._ws.readyState === _WebSocketMock.CONNECTING || this._ws.readyState === _WebSocketMock.OPEN)\n this._ws.close(code, reason);\n }\n _apiClosePage(code, reason, wasClean) {\n if (this.readyState === _WebSocketMock.CLOSED)\n return;\n this.readyState = _WebSocketMock.CLOSED;\n this.dispatchEvent(new CloseEvent(\"close\", { code, reason, wasClean, cancelable: true }));\n this._maybeCleanup();\n if (this._passthrough)\n this._apiCloseServer(code, reason, wasClean);\n else\n binding({ type: \"onClosePage\", id: this._id, code, reason, wasClean });\n }\n // --- internals ---\n _ensureOpened() {\n var _a;\n if (this.readyState !== _WebSocketMock.CONNECTING)\n return;\n this.extensions = ((_a = this._ws) == null ? void 0 : _a.extensions) || \"\";\n if (this._ws)\n this.protocol = this._ws.protocol;\n else if (Array.isArray(this._protocols))\n this.protocol = this._protocols[0] || \"\";\n else\n this.protocol = this._protocols || \"\";\n this.readyState = _WebSocketMock.OPEN;\n this.dispatchEvent(new Event(\"open\", { cancelable: true }));\n }\n _onWSClose(code, reason, wasClean) {\n if (this._passthrough)\n this._apiClosePage(code, reason, wasClean);\n else\n binding({ type: \"onCloseServer\", id: this._id, code, reason, wasClean });\n if (this._ws) {\n this._ws.onopen = null;\n this._ws.onclose = null;\n this._ws.onmessage = null;\n this._ws.onerror = null;\n this._ws = void 0;\n this._wsBufferedMessages = [];\n }\n this._maybeCleanup();\n }\n _maybeCleanup() {\n if (this.readyState === _WebSocketMock.CLOSED && !this._ws)\n idToWebSocket.delete(this._id);\n }\n };\n _WebSocketMock.CONNECTING = 0;\n // WebSocket.CONNECTING\n _WebSocketMock.OPEN = 1;\n // WebSocket.OPEN\n _WebSocketMock.CLOSING = 2;\n // WebSocket.CLOSING\n _WebSocketMock.CLOSED = 3;\n let WebSocketMock = _WebSocketMock;\n globalThis.WebSocket = class WebSocket extends WebSocketMock {\n };\n}\n";
8
- //# sourceMappingURL=webSocketMockSource.js.map
@@ -1,59 +1,57 @@
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 inProcessFactory_exports = {};
20
+ __export(inProcessFactory_exports, {
21
+ createInProcessPlaywright: () => createInProcessPlaywright
5
22
  });
6
- exports.createInProcessPlaywright = createInProcessPlaywright;
7
- var _androidServerImpl = require("./androidServerImpl");
8
- var _browserServerImpl = require("./browserServerImpl");
9
- var _server = require("./server");
10
- var _nodePlatform = require("./server/utils/nodePlatform");
11
- var _connection = require("./client/connection");
12
- var _selectors = require("./client/selectors");
13
- /**
14
- * Copyright (c) Microsoft Corporation.
15
- *
16
- * Licensed under the Apache License, Version 2.0 (the 'License");
17
- * you may not use this file except in compliance with the License.
18
- * You may obtain a copy of the License at
19
- *
20
- * http://www.apache.org/licenses/LICENSE-2.0
21
- *
22
- * Unless required by applicable law or agreed to in writing, software
23
- * distributed under the License is distributed on an "AS IS" BASIS,
24
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
- * See the License for the specific language governing permissions and
26
- * limitations under the License.
27
- */
28
-
23
+ module.exports = __toCommonJS(inProcessFactory_exports);
24
+ var import_androidServerImpl = require("./androidServerImpl");
25
+ var import_browserServerImpl = require("./browserServerImpl");
26
+ var import_server = require("./server");
27
+ var import_nodePlatform = require("./server/utils/nodePlatform");
28
+ var import_connection = require("./client/connection");
29
29
  function createInProcessPlaywright() {
30
- const playwright = (0, _server.createPlaywright)({
31
- sdkLanguage: process.env.PW_LANG_NAME || 'javascript'
32
- });
33
- (0, _selectors.setPlatformForSelectors)(_nodePlatform.nodePlatform);
34
- const clientConnection = new _connection.Connection(_nodePlatform.nodePlatform);
30
+ const playwright = (0, import_server.createPlaywright)({ sdkLanguage: process.env.PW_LANG_NAME || "javascript" });
31
+ const clientConnection = new import_connection.Connection(import_nodePlatform.nodePlatform);
35
32
  clientConnection.useRawBuffers();
36
- const dispatcherConnection = new _server.DispatcherConnection(true /* local */);
37
-
38
- // Dispatch synchronously at first.
39
- dispatcherConnection.onmessage = message => clientConnection.dispatch(message);
40
- clientConnection.onmessage = message => dispatcherConnection.dispatch(message);
41
- const rootScope = new _server.RootDispatcher(dispatcherConnection);
42
-
43
- // Initialize Playwright channel.
44
- new _server.PlaywrightDispatcher(rootScope, playwright);
45
- const playwrightAPI = clientConnection.getObjectWithKnownName('Playwright');
46
- playwrightAPI.chromium._serverLauncher = new _browserServerImpl.BrowserServerLauncherImpl('chromium');
47
- playwrightAPI.firefox._serverLauncher = new _browserServerImpl.BrowserServerLauncherImpl('firefox');
48
- playwrightAPI.webkit._serverLauncher = new _browserServerImpl.BrowserServerLauncherImpl('webkit');
49
- playwrightAPI._android._serverLauncher = new _androidServerImpl.AndroidServerLauncherImpl();
50
- playwrightAPI._bidiChromium._serverLauncher = new _browserServerImpl.BrowserServerLauncherImpl('bidiChromium');
51
- playwrightAPI._bidiFirefox._serverLauncher = new _browserServerImpl.BrowserServerLauncherImpl('bidiFirefox');
52
-
53
- // Switch to async dispatch after we got Playwright object.
54
- dispatcherConnection.onmessage = message => setImmediate(() => clientConnection.dispatch(message));
55
- clientConnection.onmessage = message => setImmediate(() => dispatcherConnection.dispatch(message));
56
- clientConnection.toImpl = x => x ? dispatcherConnection._dispatchers.get(x._guid)._object : dispatcherConnection._dispatchers.get('');
33
+ const dispatcherConnection = new import_server.DispatcherConnection(
34
+ true
35
+ /* local */
36
+ );
37
+ dispatcherConnection.onmessage = (message) => clientConnection.dispatch(message);
38
+ clientConnection.onmessage = (message) => dispatcherConnection.dispatch(message);
39
+ const rootScope = new import_server.RootDispatcher(dispatcherConnection);
40
+ new import_server.PlaywrightDispatcher(rootScope, playwright);
41
+ const playwrightAPI = clientConnection.getObjectWithKnownName("Playwright");
42
+ playwrightAPI.chromium._serverLauncher = new import_browserServerImpl.BrowserServerLauncherImpl("chromium");
43
+ playwrightAPI.firefox._serverLauncher = new import_browserServerImpl.BrowserServerLauncherImpl("firefox");
44
+ playwrightAPI.webkit._serverLauncher = new import_browserServerImpl.BrowserServerLauncherImpl("webkit");
45
+ playwrightAPI._android._serverLauncher = new import_androidServerImpl.AndroidServerLauncherImpl();
46
+ playwrightAPI._bidiChromium._serverLauncher = new import_browserServerImpl.BrowserServerLauncherImpl("_bidiChromium");
47
+ playwrightAPI._bidiFirefox._serverLauncher = new import_browserServerImpl.BrowserServerLauncherImpl("_bidiFirefox");
48
+ dispatcherConnection.onmessage = (message) => setImmediate(() => clientConnection.dispatch(message));
49
+ clientConnection.onmessage = (message) => setImmediate(() => dispatcherConnection.dispatch(message));
50
+ clientConnection.toImpl = (x) => x ? dispatcherConnection._dispatcherByGuid.get(x._guid)._object : dispatcherConnection._dispatcherByGuid.get("");
57
51
  playwrightAPI._toImpl = clientConnection.toImpl;
58
52
  return playwrightAPI;
59
- }
53
+ }
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ createInProcessPlaywright
57
+ });
package/lib/inprocess.js CHANGED
@@ -1,20 +1,3 @@
1
1
  "use strict";
2
-
3
- var _inProcessFactory = require("./inProcessFactory");
4
- /**
5
- * Copyright (c) Microsoft Corporation.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the 'License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- */
19
-
20
- module.exports = (0, _inProcessFactory.createInProcessPlaywright)();
2
+ var import_inProcessFactory = require("./inProcessFactory");
3
+ module.exports = (0, import_inProcessFactory.createInProcessPlaywright)();
@@ -1,52 +1,53 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var outofprocess_exports = {};
30
+ __export(outofprocess_exports, {
31
+ start: () => start
5
32
  });
6
- exports.start = start;
7
- var childProcess = _interopRequireWildcard(require("child_process"));
8
- var _path = _interopRequireDefault(require("path"));
9
- var _connection = require("./client/connection");
10
- var _pipeTransport = require("./server/utils/pipeTransport");
11
- var _manualPromise = require("./utils/isomorphic/manualPromise");
12
- var _nodePlatform = require("./server/utils/nodePlatform");
13
- var _selectors = require("./client/selectors");
14
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
- /**
18
- * Copyright (c) Microsoft Corporation.
19
- *
20
- * Licensed under the Apache License, Version 2.0 (the "License");
21
- * you may not use this file except in compliance with the License.
22
- * You may obtain a copy of the License at
23
- *
24
- * http://www.apache.org/licenses/LICENSE-2.0
25
- *
26
- * Unless required by applicable law or agreed to in writing, software
27
- * distributed under the License is distributed on an "AS IS" BASIS,
28
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
- * See the License for the specific language governing permissions and
30
- * limitations under the License.
31
- */
32
-
33
+ module.exports = __toCommonJS(outofprocess_exports);
34
+ var childProcess = __toESM(require("child_process"));
35
+ var import_path = __toESM(require("path"));
36
+ var import_connection = require("./client/connection");
37
+ var import_pipeTransport = require("./server/utils/pipeTransport");
38
+ var import_manualPromise = require("./utils/isomorphic/manualPromise");
39
+ var import_nodePlatform = require("./server/utils/nodePlatform");
33
40
  async function start(env = {}) {
34
- (0, _selectors.setPlatformForSelectors)(_nodePlatform.nodePlatform);
35
41
  const client = new PlaywrightClient(env);
36
42
  const playwright = await client._playwright;
37
43
  playwright.driverProcess = client._driverProcess;
38
- return {
39
- playwright,
40
- stop: () => client.stop()
41
- };
44
+ return { playwright, stop: () => client.stop() };
42
45
  }
43
46
  class PlaywrightClient {
44
47
  constructor(env) {
45
- this._playwright = void 0;
46
- this._driverProcess = void 0;
47
- this._closePromise = new _manualPromise.ManualPromise();
48
- this._driverProcess = childProcess.fork(_path.default.join(__dirname, '..', 'cli.js'), ['run-driver'], {
49
- stdio: 'pipe',
48
+ this._closePromise = new import_manualPromise.ManualPromise();
49
+ this._driverProcess = childProcess.fork(import_path.default.join(__dirname, "..", "cli.js"), ["run-driver"], {
50
+ stdio: "pipe",
50
51
  detached: true,
51
52
  env: {
52
53
  ...process.env,
@@ -54,11 +55,11 @@ class PlaywrightClient {
54
55
  }
55
56
  });
56
57
  this._driverProcess.unref();
57
- this._driverProcess.stderr.on('data', data => process.stderr.write(data));
58
- const connection = new _connection.Connection(_nodePlatform.nodePlatform);
59
- const transport = new _pipeTransport.PipeTransport(this._driverProcess.stdin, this._driverProcess.stdout);
60
- connection.onmessage = message => transport.send(JSON.stringify(message));
61
- transport.onmessage = message => connection.dispatch(JSON.parse(message));
58
+ this._driverProcess.stderr.on("data", (data) => process.stderr.write(data));
59
+ const connection = new import_connection.Connection(import_nodePlatform.nodePlatform);
60
+ const transport = new import_pipeTransport.PipeTransport(this._driverProcess.stdin, this._driverProcess.stdout);
61
+ connection.onmessage = (message) => transport.send(JSON.stringify(message));
62
+ transport.onmessage = (message) => connection.dispatch(JSON.parse(message));
62
63
  transport.onclose = () => this._closePromise.resolve();
63
64
  this._playwright = connection.initializePlaywright();
64
65
  }
@@ -68,4 +69,8 @@ class PlaywrightClient {
68
69
  this._driverProcess.stderr.destroy();
69
70
  await this._closePromise;
70
71
  }
71
- }
72
+ }
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ start
76
+ });