@stablyai/internal-playwright-core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +3 -0
- package/ThirdPartyNotices.txt +1134 -0
- package/bin/install_media_pack.ps1 +5 -0
- package/bin/install_webkit_wsl.ps1 +35 -0
- package/bin/reinstall_chrome_beta_linux.sh +42 -0
- package/bin/reinstall_chrome_beta_mac.sh +13 -0
- package/bin/reinstall_chrome_beta_win.ps1 +24 -0
- package/bin/reinstall_chrome_stable_linux.sh +42 -0
- package/bin/reinstall_chrome_stable_mac.sh +12 -0
- package/bin/reinstall_chrome_stable_win.ps1 +24 -0
- package/bin/reinstall_msedge_beta_linux.sh +48 -0
- package/bin/reinstall_msedge_beta_mac.sh +11 -0
- package/bin/reinstall_msedge_beta_win.ps1 +23 -0
- package/bin/reinstall_msedge_dev_linux.sh +48 -0
- package/bin/reinstall_msedge_dev_mac.sh +11 -0
- package/bin/reinstall_msedge_dev_win.ps1 +23 -0
- package/bin/reinstall_msedge_stable_linux.sh +48 -0
- package/bin/reinstall_msedge_stable_mac.sh +11 -0
- package/bin/reinstall_msedge_stable_win.ps1 +24 -0
- package/browsers.json +80 -0
- package/cli.js +18 -0
- package/index.d.ts +17 -0
- package/index.js +32 -0
- package/index.mjs +28 -0
- package/lib/androidServerImpl.js +65 -0
- package/lib/browserServerImpl.js +120 -0
- package/lib/cli/cli.js +58 -0
- package/lib/cli/driver.js +97 -0
- package/lib/cli/program.js +634 -0
- package/lib/cli/programWithTestStub.js +74 -0
- package/lib/client/accessibility.js +49 -0
- package/lib/client/android.js +361 -0
- package/lib/client/api.js +137 -0
- package/lib/client/artifact.js +79 -0
- package/lib/client/browser.js +163 -0
- package/lib/client/browserContext.js +529 -0
- package/lib/client/browserType.js +184 -0
- package/lib/client/cdpSession.js +51 -0
- package/lib/client/channelOwner.js +194 -0
- package/lib/client/clientHelper.js +64 -0
- package/lib/client/clientInstrumentation.js +55 -0
- package/lib/client/clientStackTrace.js +69 -0
- package/lib/client/clock.js +68 -0
- package/lib/client/connection.js +314 -0
- package/lib/client/consoleMessage.js +54 -0
- package/lib/client/coverage.js +44 -0
- package/lib/client/dialog.js +56 -0
- package/lib/client/download.js +62 -0
- package/lib/client/electron.js +138 -0
- package/lib/client/elementHandle.js +281 -0
- package/lib/client/errors.js +77 -0
- package/lib/client/eventEmitter.js +314 -0
- package/lib/client/events.js +99 -0
- package/lib/client/fetch.js +369 -0
- package/lib/client/fileChooser.js +46 -0
- package/lib/client/fileUtils.js +34 -0
- package/lib/client/frame.js +408 -0
- package/lib/client/harRouter.js +87 -0
- package/lib/client/input.js +84 -0
- package/lib/client/jsHandle.js +109 -0
- package/lib/client/jsonPipe.js +39 -0
- package/lib/client/localUtils.js +60 -0
- package/lib/client/locator.js +368 -0
- package/lib/client/network.js +747 -0
- package/lib/client/page.js +721 -0
- package/lib/client/platform.js +74 -0
- package/lib/client/playwright.js +71 -0
- package/lib/client/selectors.js +55 -0
- package/lib/client/stream.js +39 -0
- package/lib/client/timeoutSettings.js +79 -0
- package/lib/client/tracing.js +117 -0
- package/lib/client/types.js +28 -0
- package/lib/client/video.js +59 -0
- package/lib/client/waiter.js +142 -0
- package/lib/client/webError.js +39 -0
- package/lib/client/webSocket.js +93 -0
- package/lib/client/worker.js +63 -0
- package/lib/client/writableStream.js +39 -0
- package/lib/common/debugLogger.js +90 -0
- package/lib/common/socksProxy.js +569 -0
- package/lib/common/timeoutSettings.js +73 -0
- package/lib/common/types.js +5 -0
- package/lib/generated/bindingsControllerSource.js +28 -0
- package/lib/generated/clockSource.js +28 -0
- package/lib/generated/consoleApiSource.js +28 -0
- package/lib/generated/injectedScriptSource.js +28 -0
- package/lib/generated/pollingRecorderSource.js +28 -0
- package/lib/generated/recorderSource.js +28 -0
- package/lib/generated/storageScriptSource.js +28 -0
- package/lib/generated/utilityScriptSource.js +28 -0
- package/lib/generated/webSocketMockSource.js +336 -0
- package/lib/image_tools/colorUtils.js +98 -0
- package/lib/image_tools/compare.js +108 -0
- package/lib/image_tools/imageChannel.js +70 -0
- package/lib/image_tools/stats.js +102 -0
- package/lib/inProcessFactory.js +60 -0
- package/lib/index.js +19 -0
- package/lib/inprocess.js +3 -0
- package/lib/outofprocess.js +76 -0
- package/lib/protocol/debug.js +27 -0
- package/lib/protocol/serializers.js +192 -0
- package/lib/protocol/transport.js +82 -0
- package/lib/protocol/validator.js +2919 -0
- package/lib/protocol/validatorPrimitives.js +193 -0
- package/lib/remote/playwrightConnection.js +129 -0
- package/lib/remote/playwrightServer.js +335 -0
- package/lib/server/accessibility.js +69 -0
- package/lib/server/android/android.js +465 -0
- package/lib/server/android/backendAdb.js +177 -0
- package/lib/server/artifact.js +127 -0
- package/lib/server/bidi/bidiBrowser.js +490 -0
- package/lib/server/bidi/bidiChromium.js +153 -0
- package/lib/server/bidi/bidiConnection.js +212 -0
- package/lib/server/bidi/bidiExecutionContext.js +221 -0
- package/lib/server/bidi/bidiFirefox.js +130 -0
- package/lib/server/bidi/bidiInput.js +146 -0
- package/lib/server/bidi/bidiNetworkManager.js +383 -0
- package/lib/server/bidi/bidiOverCdp.js +102 -0
- package/lib/server/bidi/bidiPage.js +552 -0
- package/lib/server/bidi/bidiPdf.js +106 -0
- package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
- package/lib/server/bidi/third_party/bidiDeserializer.js +98 -0
- package/lib/server/bidi/third_party/bidiKeyboard.js +256 -0
- package/lib/server/bidi/third_party/bidiProtocol.js +24 -0
- package/lib/server/bidi/third_party/bidiProtocolCore.js +179 -0
- package/lib/server/bidi/third_party/bidiProtocolPermissions.js +42 -0
- package/lib/server/bidi/third_party/bidiSerializer.js +148 -0
- package/lib/server/bidi/third_party/firefoxPrefs.js +259 -0
- package/lib/server/browser.js +149 -0
- package/lib/server/browserContext.js +695 -0
- package/lib/server/browserType.js +328 -0
- package/lib/server/callLog.js +82 -0
- package/lib/server/chromium/appIcon.png +0 -0
- package/lib/server/chromium/chromium.js +402 -0
- package/lib/server/chromium/chromiumSwitches.js +95 -0
- package/lib/server/chromium/crAccessibility.js +263 -0
- package/lib/server/chromium/crBrowser.js +501 -0
- package/lib/server/chromium/crConnection.js +202 -0
- package/lib/server/chromium/crCoverage.js +235 -0
- package/lib/server/chromium/crDevTools.js +113 -0
- package/lib/server/chromium/crDragDrop.js +131 -0
- package/lib/server/chromium/crExecutionContext.js +146 -0
- package/lib/server/chromium/crInput.js +187 -0
- package/lib/server/chromium/crNetworkManager.js +666 -0
- package/lib/server/chromium/crPage.js +1069 -0
- package/lib/server/chromium/crPdf.js +121 -0
- package/lib/server/chromium/crProtocolHelper.js +145 -0
- package/lib/server/chromium/crServiceWorker.js +123 -0
- package/lib/server/chromium/defaultFontFamilies.js +162 -0
- package/lib/server/chromium/protocol.d.js +16 -0
- package/lib/server/chromium/videoRecorder.js +113 -0
- package/lib/server/clock.js +149 -0
- package/lib/server/codegen/csharp.js +327 -0
- package/lib/server/codegen/java.js +274 -0
- package/lib/server/codegen/javascript.js +270 -0
- package/lib/server/codegen/jsonl.js +52 -0
- package/lib/server/codegen/language.js +132 -0
- package/lib/server/codegen/languages.js +68 -0
- package/lib/server/codegen/python.js +279 -0
- package/lib/server/codegen/types.js +16 -0
- package/lib/server/console.js +53 -0
- package/lib/server/cookieStore.js +206 -0
- package/lib/server/debugController.js +191 -0
- package/lib/server/debugger.js +119 -0
- package/lib/server/deviceDescriptors.js +39 -0
- package/lib/server/deviceDescriptorsSource.json +1779 -0
- package/lib/server/dialog.js +116 -0
- package/lib/server/dispatchers/androidDispatcher.js +325 -0
- package/lib/server/dispatchers/artifactDispatcher.js +118 -0
- package/lib/server/dispatchers/browserContextDispatcher.js +364 -0
- package/lib/server/dispatchers/browserDispatcher.js +118 -0
- package/lib/server/dispatchers/browserTypeDispatcher.js +64 -0
- package/lib/server/dispatchers/cdpSessionDispatcher.js +44 -0
- package/lib/server/dispatchers/debugControllerDispatcher.js +78 -0
- package/lib/server/dispatchers/dialogDispatcher.js +47 -0
- package/lib/server/dispatchers/dispatcher.js +371 -0
- package/lib/server/dispatchers/electronDispatcher.js +89 -0
- package/lib/server/dispatchers/elementHandlerDispatcher.js +181 -0
- package/lib/server/dispatchers/frameDispatcher.js +227 -0
- package/lib/server/dispatchers/jsHandleDispatcher.js +85 -0
- package/lib/server/dispatchers/jsonPipeDispatcher.js +58 -0
- package/lib/server/dispatchers/localUtilsDispatcher.js +149 -0
- package/lib/server/dispatchers/networkDispatchers.js +213 -0
- package/lib/server/dispatchers/pageDispatcher.js +401 -0
- package/lib/server/dispatchers/playwrightDispatcher.js +108 -0
- package/lib/server/dispatchers/selectorsDispatcher.js +36 -0
- package/lib/server/dispatchers/streamDispatcher.js +67 -0
- package/lib/server/dispatchers/tracingDispatcher.js +68 -0
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +165 -0
- package/lib/server/dispatchers/writableStreamDispatcher.js +79 -0
- package/lib/server/dom.js +806 -0
- package/lib/server/download.js +70 -0
- package/lib/server/electron/electron.js +270 -0
- package/lib/server/electron/loader.js +29 -0
- package/lib/server/errors.js +69 -0
- package/lib/server/fetch.js +621 -0
- package/lib/server/fileChooser.js +43 -0
- package/lib/server/fileUploadUtils.js +84 -0
- package/lib/server/firefox/ffAccessibility.js +238 -0
- package/lib/server/firefox/ffBrowser.js +428 -0
- package/lib/server/firefox/ffConnection.js +147 -0
- package/lib/server/firefox/ffExecutionContext.js +150 -0
- package/lib/server/firefox/ffInput.js +159 -0
- package/lib/server/firefox/ffNetworkManager.js +256 -0
- package/lib/server/firefox/ffPage.js +503 -0
- package/lib/server/firefox/firefox.js +116 -0
- package/lib/server/firefox/protocol.d.js +16 -0
- package/lib/server/formData.js +147 -0
- package/lib/server/frameSelectors.js +156 -0
- package/lib/server/frames.js +1502 -0
- package/lib/server/har/harRecorder.js +147 -0
- package/lib/server/har/harTracer.js +607 -0
- package/lib/server/harBackend.js +157 -0
- package/lib/server/helper.js +96 -0
- package/lib/server/index.js +58 -0
- package/lib/server/input.js +273 -0
- package/lib/server/instrumentation.js +69 -0
- package/lib/server/isomorphic/utilityScriptSerializers.js +212 -0
- package/lib/server/javascript.js +291 -0
- package/lib/server/launchApp.js +128 -0
- package/lib/server/localUtils.js +218 -0
- package/lib/server/macEditingCommands.js +143 -0
- package/lib/server/network.js +629 -0
- package/lib/server/page.js +871 -0
- package/lib/server/pipeTransport.js +89 -0
- package/lib/server/playwright.js +69 -0
- package/lib/server/progress.js +112 -0
- package/lib/server/protocolError.js +52 -0
- package/lib/server/recorder/chat.js +161 -0
- package/lib/server/recorder/codeGenerator.js +153 -0
- package/lib/server/recorder/csharp.js +310 -0
- package/lib/server/recorder/java.js +248 -0
- package/lib/server/recorder/javascript.js +229 -0
- package/lib/server/recorder/jsonl.js +47 -0
- package/lib/server/recorder/language.js +44 -0
- package/lib/server/recorder/python.js +276 -0
- package/lib/server/recorder/recorderActions.js +5 -0
- package/lib/server/recorder/recorderApp.js +387 -0
- package/lib/server/recorder/recorderRunner.js +138 -0
- package/lib/server/recorder/recorderSignalProcessor.js +83 -0
- package/lib/server/recorder/recorderUtils.js +157 -0
- package/lib/server/recorder/throttledFile.js +57 -0
- package/lib/server/recorder/utils.js +45 -0
- package/lib/server/recorder.js +499 -0
- package/lib/server/registry/browserFetcher.js +175 -0
- package/lib/server/registry/dependencies.js +371 -0
- package/lib/server/registry/index.js +1331 -0
- package/lib/server/registry/nativeDeps.js +1280 -0
- package/lib/server/registry/oopDownloadBrowserMain.js +120 -0
- package/lib/server/screenshotter.js +333 -0
- package/lib/server/selectors.js +112 -0
- package/lib/server/socksClientCertificatesInterceptor.js +383 -0
- package/lib/server/socksInterceptor.js +95 -0
- package/lib/server/stably/ai-tools/http-request.js +70 -0
- package/lib/server/stably/ai-tools/stablyApiCaller.js +137 -0
- package/lib/server/stably/autohealing/elementHandleFromCoordinates.js +64 -0
- package/lib/server/stably/autohealing/healingService.js +228 -0
- package/lib/server/stably/autohealing/screenshotFrame.js +41 -0
- package/lib/server/stably/constants.js +31 -0
- package/lib/server/trace/recorder/snapshotter.js +147 -0
- package/lib/server/trace/recorder/snapshotterInjected.js +541 -0
- package/lib/server/trace/recorder/tracing.js +602 -0
- package/lib/server/trace/test/inMemorySnapshotter.js +87 -0
- package/lib/server/trace/viewer/traceViewer.js +240 -0
- package/lib/server/transport.js +181 -0
- package/lib/server/types.js +28 -0
- package/lib/server/usKeyboardLayout.js +145 -0
- package/lib/server/utils/ascii.js +44 -0
- package/lib/server/utils/comparators.js +161 -0
- package/lib/server/utils/crypto.js +216 -0
- package/lib/server/utils/debug.js +42 -0
- package/lib/server/utils/debugLogger.js +122 -0
- package/lib/server/utils/env.js +73 -0
- package/lib/server/utils/eventsHelper.js +39 -0
- package/lib/server/utils/expectUtils.js +38 -0
- package/lib/server/utils/fileUtils.js +191 -0
- package/lib/server/utils/happyEyeballs.js +207 -0
- package/lib/server/utils/hostPlatform.js +111 -0
- package/lib/server/utils/httpServer.js +218 -0
- package/lib/server/utils/image_tools/colorUtils.js +89 -0
- package/lib/server/utils/image_tools/compare.js +109 -0
- package/lib/server/utils/image_tools/imageChannel.js +78 -0
- package/lib/server/utils/image_tools/stats.js +102 -0
- package/lib/server/utils/linuxUtils.js +71 -0
- package/lib/server/utils/network.js +233 -0
- package/lib/server/utils/nodePlatform.js +148 -0
- package/lib/server/utils/pipeTransport.js +84 -0
- package/lib/server/utils/processLauncher.js +241 -0
- package/lib/server/utils/profiler.js +65 -0
- package/lib/server/utils/socksProxy.js +511 -0
- package/lib/server/utils/spawnAsync.js +41 -0
- package/lib/server/utils/task.js +51 -0
- package/lib/server/utils/userAgent.js +98 -0
- package/lib/server/utils/wsServer.js +121 -0
- package/lib/server/utils/zipFile.js +74 -0
- package/lib/server/utils/zones.js +57 -0
- package/lib/server/webkit/protocol.d.js +16 -0
- package/lib/server/webkit/webkit.js +119 -0
- package/lib/server/webkit/wkAccessibility.js +237 -0
- package/lib/server/webkit/wkBrowser.js +339 -0
- package/lib/server/webkit/wkConnection.js +149 -0
- package/lib/server/webkit/wkExecutionContext.js +154 -0
- package/lib/server/webkit/wkInput.js +181 -0
- package/lib/server/webkit/wkInterceptableRequest.js +169 -0
- package/lib/server/webkit/wkPage.js +1134 -0
- package/lib/server/webkit/wkProvisionalPage.js +83 -0
- package/lib/server/webkit/wkWorkers.js +104 -0
- package/lib/server/webkit/wsl/webkit-wsl-transport-client.js +74 -0
- package/lib/server/webkit/wsl/webkit-wsl-transport-server.js +113 -0
- package/lib/third_party/diff_match_patch.js +2222 -0
- package/lib/third_party/pixelmatch.js +255 -0
- package/lib/utils/ascii.js +31 -0
- package/lib/utils/comparators.js +171 -0
- package/lib/utils/crypto.js +33 -0
- package/lib/utils/debug.js +46 -0
- package/lib/utils/debugLogger.js +89 -0
- package/lib/utils/env.js +49 -0
- package/lib/utils/eventsHelper.js +38 -0
- package/lib/utils/fileUtils.js +205 -0
- package/lib/utils/glob.js +83 -0
- package/lib/utils/happy-eyeballs.js +160 -0
- package/lib/utils/headers.js +52 -0
- package/lib/utils/hostPlatform.js +128 -0
- package/lib/utils/httpServer.js +236 -0
- package/lib/utils/index.js +346 -0
- package/lib/utils/isomorphic/ariaSnapshot.js +392 -0
- package/lib/utils/isomorphic/assert.js +31 -0
- package/lib/utils/isomorphic/colors.js +72 -0
- package/lib/utils/isomorphic/cssParser.js +245 -0
- package/lib/utils/isomorphic/cssTokenizer.js +1051 -0
- package/lib/utils/isomorphic/headers.js +53 -0
- package/lib/utils/isomorphic/locatorGenerators.js +673 -0
- package/lib/utils/isomorphic/locatorParser.js +176 -0
- package/lib/utils/isomorphic/locatorUtils.js +81 -0
- package/lib/utils/isomorphic/manualPromise.js +114 -0
- package/lib/utils/isomorphic/mimeType.js +459 -0
- package/lib/utils/isomorphic/multimap.js +80 -0
- package/lib/utils/isomorphic/protocolFormatter.js +78 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +321 -0
- package/lib/utils/isomorphic/rtti.js +43 -0
- package/lib/utils/isomorphic/selectorParser.js +386 -0
- package/lib/utils/isomorphic/semaphore.js +54 -0
- package/lib/utils/isomorphic/stackTrace.js +158 -0
- package/lib/utils/isomorphic/stringUtils.js +155 -0
- package/lib/utils/isomorphic/time.js +49 -0
- package/lib/utils/isomorphic/timeoutRunner.js +66 -0
- package/lib/utils/isomorphic/traceUtils.js +58 -0
- package/lib/utils/isomorphic/types.js +16 -0
- package/lib/utils/isomorphic/urlMatch.js +176 -0
- package/lib/utils/isomorphic/utilityScriptSerializers.js +251 -0
- package/lib/utils/linuxUtils.js +78 -0
- package/lib/utils/manualPromise.js +109 -0
- package/lib/utils/mimeType.js +29 -0
- package/lib/utils/multimap.js +75 -0
- package/lib/utils/network.js +188 -0
- package/lib/utils/processLauncher.js +248 -0
- package/lib/utils/profiler.js +53 -0
- package/lib/utils/rtti.js +44 -0
- package/lib/utils/semaphore.js +51 -0
- package/lib/utils/spawnAsync.js +45 -0
- package/lib/utils/stackTrace.js +121 -0
- package/lib/utils/task.js +58 -0
- package/lib/utils/time.js +37 -0
- package/lib/utils/timeoutRunner.js +66 -0
- package/lib/utils/traceUtils.js +44 -0
- package/lib/utils/userAgent.js +105 -0
- package/lib/utils/wsServer.js +127 -0
- package/lib/utils/zipFile.js +75 -0
- package/lib/utils/zones.js +62 -0
- package/lib/utils.js +107 -0
- package/lib/utilsBundle.js +109 -0
- package/lib/utilsBundleImpl/index.js +218 -0
- package/lib/utilsBundleImpl/xdg-open +1066 -0
- package/lib/vite/htmlReport/index.html +84 -0
- package/lib/vite/recorder/assets/codeMirrorModule-C3UTv-Ge.css +1 -0
- package/lib/vite/recorder/assets/codeMirrorModule-RJCXzfmE.js +24 -0
- package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- package/lib/vite/recorder/assets/index-Ri0uHF7I.css +1 -0
- package/lib/vite/recorder/assets/index-Y-X2TGJv.js +193 -0
- package/lib/vite/recorder/index.html +29 -0
- package/lib/vite/recorder/playwright-logo.svg +9 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-Bhnc5o2x.js +24 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-ClwvkA2N.js +265 -0
- package/lib/vite/traceViewer/assets/xtermModule-CsJ4vdCR.js +9 -0
- package/lib/vite/traceViewer/codeMirrorModule.C3UTv-Ge.css +1 -0
- package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/lib/vite/traceViewer/defaultSettingsView.TQ8_7ybu.css +1 -0
- package/lib/vite/traceViewer/index.DFO9NNF5.js +2 -0
- package/lib/vite/traceViewer/index.I8N9v4jT.css +1 -0
- package/lib/vite/traceViewer/index.html +43 -0
- package/lib/vite/traceViewer/playwright-logo.svg +9 -0
- package/lib/vite/traceViewer/snapshot.html +21 -0
- package/lib/vite/traceViewer/sw.bundle.js +3 -0
- package/lib/vite/traceViewer/uiMode.Btcz36p_.css +1 -0
- package/lib/vite/traceViewer/uiMode.Shu3QS-1.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +17 -0
- package/lib/vite/traceViewer/xtermModule.DYP7pi_n.css +32 -0
- package/lib/zipBundle.js +34 -0
- package/lib/zipBundleImpl.js +5 -0
- package/package.json +43 -0
- package/types/protocol.d.ts +23130 -0
- package/types/structs.d.ts +45 -0
- package/types/types.d.ts +22857 -0
@@ -0,0 +1,193 @@
|
|
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 validatorPrimitives_exports = {};
|
20
|
+
__export(validatorPrimitives_exports, {
|
21
|
+
ValidationError: () => ValidationError,
|
22
|
+
createMetadataValidator: () => createMetadataValidator,
|
23
|
+
findValidator: () => findValidator,
|
24
|
+
maybeFindValidator: () => maybeFindValidator,
|
25
|
+
scheme: () => scheme,
|
26
|
+
tAny: () => tAny,
|
27
|
+
tArray: () => tArray,
|
28
|
+
tBinary: () => tBinary,
|
29
|
+
tBoolean: () => tBoolean,
|
30
|
+
tChannel: () => tChannel,
|
31
|
+
tEnum: () => tEnum,
|
32
|
+
tFloat: () => tFloat,
|
33
|
+
tInt: () => tInt,
|
34
|
+
tObject: () => tObject,
|
35
|
+
tOptional: () => tOptional,
|
36
|
+
tString: () => tString,
|
37
|
+
tType: () => tType,
|
38
|
+
tUndefined: () => tUndefined
|
39
|
+
});
|
40
|
+
module.exports = __toCommonJS(validatorPrimitives_exports);
|
41
|
+
class ValidationError extends Error {
|
42
|
+
}
|
43
|
+
const scheme = {};
|
44
|
+
function findValidator(type, method, kind) {
|
45
|
+
const validator = maybeFindValidator(type, method, kind);
|
46
|
+
if (!validator)
|
47
|
+
throw new ValidationError(`Unknown scheme for ${kind}: ${type}.${method}`);
|
48
|
+
return validator;
|
49
|
+
}
|
50
|
+
function maybeFindValidator(type, method, kind) {
|
51
|
+
const schemeName = type + (kind === "Initializer" ? "" : method[0].toUpperCase() + method.substring(1)) + kind;
|
52
|
+
return scheme[schemeName];
|
53
|
+
}
|
54
|
+
function createMetadataValidator() {
|
55
|
+
return tOptional(scheme["Metadata"]);
|
56
|
+
}
|
57
|
+
const tFloat = (arg, path, context) => {
|
58
|
+
if (arg instanceof Number)
|
59
|
+
return arg.valueOf();
|
60
|
+
if (typeof arg === "number")
|
61
|
+
return arg;
|
62
|
+
throw new ValidationError(`${path}: expected float, got ${typeof arg}`);
|
63
|
+
};
|
64
|
+
const tInt = (arg, path, context) => {
|
65
|
+
let value;
|
66
|
+
if (arg instanceof Number)
|
67
|
+
value = arg.valueOf();
|
68
|
+
else if (typeof arg === "number")
|
69
|
+
value = arg;
|
70
|
+
else
|
71
|
+
throw new ValidationError(`${path}: expected integer, got ${typeof arg}`);
|
72
|
+
if (!Number.isInteger(value))
|
73
|
+
throw new ValidationError(`${path}: expected integer, got float ${value}`);
|
74
|
+
return value;
|
75
|
+
};
|
76
|
+
const tBoolean = (arg, path, context) => {
|
77
|
+
if (arg instanceof Boolean)
|
78
|
+
return arg.valueOf();
|
79
|
+
if (typeof arg === "boolean")
|
80
|
+
return arg;
|
81
|
+
throw new ValidationError(`${path}: expected boolean, got ${typeof arg}`);
|
82
|
+
};
|
83
|
+
const tString = (arg, path, context) => {
|
84
|
+
if (arg instanceof String)
|
85
|
+
return arg.valueOf();
|
86
|
+
if (typeof arg === "string")
|
87
|
+
return arg;
|
88
|
+
throw new ValidationError(`${path}: expected string, got ${typeof arg}`);
|
89
|
+
};
|
90
|
+
const tBinary = (arg, path, context) => {
|
91
|
+
if (context.binary === "fromBase64") {
|
92
|
+
if (arg instanceof String)
|
93
|
+
return Buffer.from(arg.valueOf(), "base64");
|
94
|
+
if (typeof arg === "string")
|
95
|
+
return Buffer.from(arg, "base64");
|
96
|
+
throw new ValidationError(`${path}: expected base64-encoded buffer, got ${typeof arg}`);
|
97
|
+
}
|
98
|
+
if (context.binary === "toBase64") {
|
99
|
+
if (!(arg instanceof Buffer))
|
100
|
+
throw new ValidationError(`${path}: expected Buffer, got ${typeof arg}`);
|
101
|
+
return arg.toString("base64");
|
102
|
+
}
|
103
|
+
if (context.binary === "buffer") {
|
104
|
+
if (!(arg instanceof Buffer))
|
105
|
+
throw new ValidationError(`${path}: expected Buffer, got ${typeof arg}`);
|
106
|
+
return arg;
|
107
|
+
}
|
108
|
+
throw new ValidationError(`Unsupported binary behavior "${context.binary}"`);
|
109
|
+
};
|
110
|
+
const tUndefined = (arg, path, context) => {
|
111
|
+
if (Object.is(arg, void 0))
|
112
|
+
return arg;
|
113
|
+
throw new ValidationError(`${path}: expected undefined, got ${typeof arg}`);
|
114
|
+
};
|
115
|
+
const tAny = (arg, path, context) => {
|
116
|
+
return arg;
|
117
|
+
};
|
118
|
+
const tOptional = (v) => {
|
119
|
+
return (arg, path, context) => {
|
120
|
+
if (Object.is(arg, void 0))
|
121
|
+
return arg;
|
122
|
+
return v(arg, path, context);
|
123
|
+
};
|
124
|
+
};
|
125
|
+
const tArray = (v) => {
|
126
|
+
return (arg, path, context) => {
|
127
|
+
if (!Array.isArray(arg))
|
128
|
+
throw new ValidationError(`${path}: expected array, got ${typeof arg}`);
|
129
|
+
return arg.map((x, index) => v(x, path + "[" + index + "]", context));
|
130
|
+
};
|
131
|
+
};
|
132
|
+
const tObject = (s) => {
|
133
|
+
return (arg, path, context) => {
|
134
|
+
if (Object.is(arg, null))
|
135
|
+
throw new ValidationError(`${path}: expected object, got null`);
|
136
|
+
if (typeof arg !== "object")
|
137
|
+
throw new ValidationError(`${path}: expected object, got ${typeof arg}`);
|
138
|
+
const result = {};
|
139
|
+
for (const [key, v] of Object.entries(s)) {
|
140
|
+
const value = v(arg[key], path ? path + "." + key : key, context);
|
141
|
+
if (!Object.is(value, void 0))
|
142
|
+
result[key] = value;
|
143
|
+
}
|
144
|
+
if (context.isUnderTest()) {
|
145
|
+
for (const [key, value] of Object.entries(arg)) {
|
146
|
+
if (key.startsWith("__testHook"))
|
147
|
+
result[key] = value;
|
148
|
+
}
|
149
|
+
}
|
150
|
+
return result;
|
151
|
+
};
|
152
|
+
};
|
153
|
+
const tEnum = (e) => {
|
154
|
+
return (arg, path, context) => {
|
155
|
+
if (!e.includes(arg))
|
156
|
+
throw new ValidationError(`${path}: expected one of (${e.join("|")})`);
|
157
|
+
return arg;
|
158
|
+
};
|
159
|
+
};
|
160
|
+
const tChannel = (names) => {
|
161
|
+
return (arg, path, context) => {
|
162
|
+
return context.tChannelImpl(names, arg, path, context);
|
163
|
+
};
|
164
|
+
};
|
165
|
+
const tType = (name) => {
|
166
|
+
return (arg, path, context) => {
|
167
|
+
const v = scheme[name];
|
168
|
+
if (!v)
|
169
|
+
throw new ValidationError(path + ': unknown type "' + name + '"');
|
170
|
+
return v(arg, path, context);
|
171
|
+
};
|
172
|
+
};
|
173
|
+
// Annotate the CommonJS export names for ESM import in node:
|
174
|
+
0 && (module.exports = {
|
175
|
+
ValidationError,
|
176
|
+
createMetadataValidator,
|
177
|
+
findValidator,
|
178
|
+
maybeFindValidator,
|
179
|
+
scheme,
|
180
|
+
tAny,
|
181
|
+
tArray,
|
182
|
+
tBinary,
|
183
|
+
tBoolean,
|
184
|
+
tChannel,
|
185
|
+
tEnum,
|
186
|
+
tFloat,
|
187
|
+
tInt,
|
188
|
+
tObject,
|
189
|
+
tOptional,
|
190
|
+
tString,
|
191
|
+
tType,
|
192
|
+
tUndefined
|
193
|
+
});
|
@@ -0,0 +1,129 @@
|
|
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 playwrightConnection_exports = {};
|
20
|
+
__export(playwrightConnection_exports, {
|
21
|
+
PlaywrightConnection: () => PlaywrightConnection
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(playwrightConnection_exports);
|
24
|
+
var import_server = require("../server");
|
25
|
+
var import_android = require("../server/android/android");
|
26
|
+
var import_browser = require("../server/browser");
|
27
|
+
var import_debugControllerDispatcher = require("../server/dispatchers/debugControllerDispatcher");
|
28
|
+
var import_profiler = require("../server/utils/profiler");
|
29
|
+
var import_utils = require("../utils");
|
30
|
+
var import_debugLogger = require("../server/utils/debugLogger");
|
31
|
+
class PlaywrightConnection {
|
32
|
+
constructor(semaphore, ws, controller, playwright, initialize, id) {
|
33
|
+
this._cleanups = [];
|
34
|
+
this._disconnected = false;
|
35
|
+
this._ws = ws;
|
36
|
+
this._semaphore = semaphore;
|
37
|
+
this._id = id;
|
38
|
+
this._profileName = (/* @__PURE__ */ new Date()).toISOString();
|
39
|
+
const lock = this._semaphore.acquire();
|
40
|
+
this._dispatcherConnection = new import_server.DispatcherConnection();
|
41
|
+
this._dispatcherConnection.onmessage = async (message) => {
|
42
|
+
await lock;
|
43
|
+
if (ws.readyState !== ws.CLOSING) {
|
44
|
+
const messageString = JSON.stringify(message);
|
45
|
+
if (import_debugLogger.debugLogger.isEnabled("server:channel"))
|
46
|
+
import_debugLogger.debugLogger.log("server:channel", `[${this._id}] ${(0, import_utils.monotonicTime)() * 1e3} SEND \u25BA ${messageString}`);
|
47
|
+
if (import_debugLogger.debugLogger.isEnabled("server:metadata"))
|
48
|
+
this.logServerMetadata(message, messageString, "SEND");
|
49
|
+
ws.send(messageString);
|
50
|
+
}
|
51
|
+
};
|
52
|
+
ws.on("message", async (message) => {
|
53
|
+
await lock;
|
54
|
+
const messageString = Buffer.from(message).toString();
|
55
|
+
const jsonMessage = JSON.parse(messageString);
|
56
|
+
if (import_debugLogger.debugLogger.isEnabled("server:channel"))
|
57
|
+
import_debugLogger.debugLogger.log("server:channel", `[${this._id}] ${(0, import_utils.monotonicTime)() * 1e3} \u25C0 RECV ${messageString}`);
|
58
|
+
if (import_debugLogger.debugLogger.isEnabled("server:metadata"))
|
59
|
+
this.logServerMetadata(jsonMessage, messageString, "RECV");
|
60
|
+
this._dispatcherConnection.dispatch(jsonMessage);
|
61
|
+
});
|
62
|
+
ws.on("close", () => this._onDisconnect());
|
63
|
+
ws.on("error", (error) => this._onDisconnect(error));
|
64
|
+
if (controller) {
|
65
|
+
import_debugLogger.debugLogger.log("server", `[${this._id}] engaged reuse controller mode`);
|
66
|
+
this._root = new import_debugControllerDispatcher.DebugControllerDispatcher(this._dispatcherConnection, playwright.debugController);
|
67
|
+
return;
|
68
|
+
}
|
69
|
+
this._root = new import_server.RootDispatcher(this._dispatcherConnection, async (scope, params) => {
|
70
|
+
await (0, import_profiler.startProfiling)();
|
71
|
+
const options = await initialize();
|
72
|
+
if (options.preLaunchedBrowser) {
|
73
|
+
const browser = options.preLaunchedBrowser;
|
74
|
+
browser.options.sdkLanguage = params.sdkLanguage;
|
75
|
+
browser.on(import_browser.Browser.Events.Disconnected, () => {
|
76
|
+
this.close({ code: 1001, reason: "Browser closed" });
|
77
|
+
});
|
78
|
+
}
|
79
|
+
if (options.preLaunchedAndroidDevice) {
|
80
|
+
const androidDevice = options.preLaunchedAndroidDevice;
|
81
|
+
androidDevice.on(import_android.AndroidDevice.Events.Close, () => {
|
82
|
+
this.close({ code: 1001, reason: "Android device disconnected" });
|
83
|
+
});
|
84
|
+
}
|
85
|
+
if (options.dispose)
|
86
|
+
this._cleanups.push(options.dispose);
|
87
|
+
const dispatcher = new import_server.PlaywrightDispatcher(scope, playwright, options);
|
88
|
+
this._cleanups.push(() => dispatcher.cleanup());
|
89
|
+
return dispatcher;
|
90
|
+
});
|
91
|
+
}
|
92
|
+
async _onDisconnect(error) {
|
93
|
+
this._disconnected = true;
|
94
|
+
import_debugLogger.debugLogger.log("server", `[${this._id}] disconnected. error: ${error}`);
|
95
|
+
await this._root.stopPendingOperations(new Error("Disconnected")).catch(() => {
|
96
|
+
});
|
97
|
+
this._root._dispose();
|
98
|
+
import_debugLogger.debugLogger.log("server", `[${this._id}] starting cleanup`);
|
99
|
+
for (const cleanup of this._cleanups)
|
100
|
+
await cleanup().catch(() => {
|
101
|
+
});
|
102
|
+
await (0, import_profiler.stopProfiling)(this._profileName);
|
103
|
+
this._semaphore.release();
|
104
|
+
import_debugLogger.debugLogger.log("server", `[${this._id}] finished cleanup`);
|
105
|
+
}
|
106
|
+
logServerMetadata(message, messageString, direction) {
|
107
|
+
const serverLogMetadata = {
|
108
|
+
wallTime: Date.now(),
|
109
|
+
id: message.id,
|
110
|
+
guid: message.guid,
|
111
|
+
method: message.method,
|
112
|
+
payloadSizeInBytes: Buffer.byteLength(messageString, "utf-8")
|
113
|
+
};
|
114
|
+
import_debugLogger.debugLogger.log("server:metadata", (direction === "SEND" ? "SEND \u25BA " : "\u25C0 RECV ") + JSON.stringify(serverLogMetadata));
|
115
|
+
}
|
116
|
+
async close(reason) {
|
117
|
+
if (this._disconnected)
|
118
|
+
return;
|
119
|
+
import_debugLogger.debugLogger.log("server", `[${this._id}] force closing connection: ${reason?.reason || ""} (${reason?.code || 0})`);
|
120
|
+
try {
|
121
|
+
this._ws.close(reason?.code, reason?.reason);
|
122
|
+
} catch (e) {
|
123
|
+
}
|
124
|
+
}
|
125
|
+
}
|
126
|
+
// Annotate the CommonJS export names for ESM import in node:
|
127
|
+
0 && (module.exports = {
|
128
|
+
PlaywrightConnection
|
129
|
+
});
|
@@ -0,0 +1,335 @@
|
|
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 playwrightServer_exports = {};
|
20
|
+
__export(playwrightServer_exports, {
|
21
|
+
PlaywrightServer: () => PlaywrightServer
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(playwrightServer_exports);
|
24
|
+
var import_playwrightConnection = require("./playwrightConnection");
|
25
|
+
var import_playwright = require("../server/playwright");
|
26
|
+
var import_semaphore = require("../utils/isomorphic/semaphore");
|
27
|
+
var import_time = require("../utils/isomorphic/time");
|
28
|
+
var import_wsServer = require("../server/utils/wsServer");
|
29
|
+
var import_ascii = require("../server/utils/ascii");
|
30
|
+
var import_userAgent = require("../server/utils/userAgent");
|
31
|
+
var import_utils = require("../utils");
|
32
|
+
var import_socksProxy = require("../server/utils/socksProxy");
|
33
|
+
var import_browser = require("../server/browser");
|
34
|
+
var import_progress = require("../server/progress");
|
35
|
+
class PlaywrightServer {
|
36
|
+
constructor(options) {
|
37
|
+
this._dontReuseBrowsers = /* @__PURE__ */ new Set();
|
38
|
+
this._options = options;
|
39
|
+
if (options.preLaunchedBrowser) {
|
40
|
+
this._playwright = options.preLaunchedBrowser.attribution.playwright;
|
41
|
+
this._dontReuse(options.preLaunchedBrowser);
|
42
|
+
}
|
43
|
+
if (options.preLaunchedAndroidDevice)
|
44
|
+
this._playwright = options.preLaunchedAndroidDevice._android.attribution.playwright;
|
45
|
+
this._playwright ??= (0, import_playwright.createPlaywright)({ sdkLanguage: "javascript", isServer: true });
|
46
|
+
const browserSemaphore = new import_semaphore.Semaphore(this._options.maxConnections);
|
47
|
+
const controllerSemaphore = new import_semaphore.Semaphore(1);
|
48
|
+
const reuseBrowserSemaphore = new import_semaphore.Semaphore(1);
|
49
|
+
this._wsServer = new import_wsServer.WSServer({
|
50
|
+
onRequest: (request, response) => {
|
51
|
+
if (request.method === "GET" && request.url === "/json") {
|
52
|
+
response.setHeader("Content-Type", "application/json");
|
53
|
+
response.end(JSON.stringify({
|
54
|
+
wsEndpointPath: this._options.path
|
55
|
+
}));
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
response.end("Running");
|
59
|
+
},
|
60
|
+
onUpgrade: (request, socket) => {
|
61
|
+
const uaError = userAgentVersionMatchesErrorMessage(request.headers["user-agent"] || "");
|
62
|
+
if (uaError)
|
63
|
+
return { error: `HTTP/${request.httpVersion} 428 Precondition Required\r
|
64
|
+
\r
|
65
|
+
${uaError}` };
|
66
|
+
},
|
67
|
+
onHeaders: (headers) => {
|
68
|
+
if (process.env.PWTEST_SERVER_WS_HEADERS)
|
69
|
+
headers.push(process.env.PWTEST_SERVER_WS_HEADERS);
|
70
|
+
},
|
71
|
+
onConnection: (request, url, ws, id) => {
|
72
|
+
const browserHeader = request.headers["x-playwright-browser"];
|
73
|
+
const browserName = url.searchParams.get("browser") || (Array.isArray(browserHeader) ? browserHeader[0] : browserHeader) || null;
|
74
|
+
const proxyHeader = request.headers["x-playwright-proxy"];
|
75
|
+
const proxyValue = url.searchParams.get("proxy") || (Array.isArray(proxyHeader) ? proxyHeader[0] : proxyHeader);
|
76
|
+
const launchOptionsHeader = request.headers["x-playwright-launch-options"] || "";
|
77
|
+
const launchOptionsHeaderValue = Array.isArray(launchOptionsHeader) ? launchOptionsHeader[0] : launchOptionsHeader;
|
78
|
+
const launchOptionsParam = url.searchParams.get("launch-options");
|
79
|
+
let launchOptions = { timeout: import_time.DEFAULT_PLAYWRIGHT_LAUNCH_TIMEOUT };
|
80
|
+
try {
|
81
|
+
launchOptions = JSON.parse(launchOptionsParam || launchOptionsHeaderValue);
|
82
|
+
if (!launchOptions.timeout)
|
83
|
+
launchOptions.timeout = import_time.DEFAULT_PLAYWRIGHT_LAUNCH_TIMEOUT;
|
84
|
+
} catch (e) {
|
85
|
+
}
|
86
|
+
const isExtension = this._options.mode === "extension";
|
87
|
+
const allowFSPaths = isExtension;
|
88
|
+
launchOptions = filterLaunchOptions(launchOptions, allowFSPaths);
|
89
|
+
if (isExtension) {
|
90
|
+
const connectFilter = url.searchParams.get("connect");
|
91
|
+
if (connectFilter) {
|
92
|
+
if (connectFilter !== "first")
|
93
|
+
throw new Error(`Unknown connect filter: ${connectFilter}`);
|
94
|
+
return new import_playwrightConnection.PlaywrightConnection(
|
95
|
+
browserSemaphore,
|
96
|
+
ws,
|
97
|
+
false,
|
98
|
+
this._playwright,
|
99
|
+
() => this._initConnectMode(id, connectFilter, browserName, launchOptions),
|
100
|
+
id
|
101
|
+
);
|
102
|
+
}
|
103
|
+
if (url.searchParams.has("debug-controller")) {
|
104
|
+
return new import_playwrightConnection.PlaywrightConnection(
|
105
|
+
controllerSemaphore,
|
106
|
+
ws,
|
107
|
+
true,
|
108
|
+
this._playwright,
|
109
|
+
async () => {
|
110
|
+
throw new Error("shouldnt be used");
|
111
|
+
},
|
112
|
+
id
|
113
|
+
);
|
114
|
+
}
|
115
|
+
return new import_playwrightConnection.PlaywrightConnection(
|
116
|
+
reuseBrowserSemaphore,
|
117
|
+
ws,
|
118
|
+
false,
|
119
|
+
this._playwright,
|
120
|
+
() => this._initReuseBrowsersMode(browserName, launchOptions, id),
|
121
|
+
id
|
122
|
+
);
|
123
|
+
}
|
124
|
+
if (this._options.mode === "launchServer" || this._options.mode === "launchServerShared") {
|
125
|
+
if (this._options.preLaunchedBrowser) {
|
126
|
+
return new import_playwrightConnection.PlaywrightConnection(
|
127
|
+
browserSemaphore,
|
128
|
+
ws,
|
129
|
+
false,
|
130
|
+
this._playwright,
|
131
|
+
() => this._initPreLaunchedBrowserMode(id),
|
132
|
+
id
|
133
|
+
);
|
134
|
+
}
|
135
|
+
return new import_playwrightConnection.PlaywrightConnection(
|
136
|
+
browserSemaphore,
|
137
|
+
ws,
|
138
|
+
false,
|
139
|
+
this._playwright,
|
140
|
+
() => this._initPreLaunchedAndroidMode(id),
|
141
|
+
id
|
142
|
+
);
|
143
|
+
}
|
144
|
+
return new import_playwrightConnection.PlaywrightConnection(
|
145
|
+
browserSemaphore,
|
146
|
+
ws,
|
147
|
+
false,
|
148
|
+
this._playwright,
|
149
|
+
() => this._initLaunchBrowserMode(browserName, proxyValue, launchOptions, id),
|
150
|
+
id
|
151
|
+
);
|
152
|
+
}
|
153
|
+
});
|
154
|
+
}
|
155
|
+
async _initReuseBrowsersMode(browserName, launchOptions, id) {
|
156
|
+
import_utils.debugLogger.log("server", `[${id}] engaged reuse browsers mode for ${browserName}`);
|
157
|
+
const requestedOptions = launchOptionsHash(launchOptions);
|
158
|
+
let browser = this._playwright.allBrowsers().find((b) => {
|
159
|
+
if (b.options.name !== browserName)
|
160
|
+
return false;
|
161
|
+
if (this._dontReuseBrowsers.has(b))
|
162
|
+
return false;
|
163
|
+
const existingOptions = launchOptionsHash({ ...b.options.originalLaunchOptions, timeout: import_time.DEFAULT_PLAYWRIGHT_LAUNCH_TIMEOUT });
|
164
|
+
return existingOptions === requestedOptions;
|
165
|
+
});
|
166
|
+
for (const b of this._playwright.allBrowsers()) {
|
167
|
+
if (b === browser)
|
168
|
+
continue;
|
169
|
+
if (this._dontReuseBrowsers.has(b))
|
170
|
+
continue;
|
171
|
+
if (b.options.name === browserName && b.options.channel === launchOptions.channel)
|
172
|
+
await b.close({ reason: "Connection terminated" });
|
173
|
+
}
|
174
|
+
if (!browser) {
|
175
|
+
const browserType = this._playwright[browserName || "chromium"];
|
176
|
+
const controller = new import_progress.ProgressController();
|
177
|
+
browser = await controller.run((progress) => browserType.launch(progress, {
|
178
|
+
...launchOptions,
|
179
|
+
headless: !!process.env.PW_DEBUG_CONTROLLER_HEADLESS
|
180
|
+
}), launchOptions.timeout);
|
181
|
+
}
|
182
|
+
return {
|
183
|
+
preLaunchedBrowser: browser,
|
184
|
+
denyLaunch: true,
|
185
|
+
dispose: async () => {
|
186
|
+
for (const context of browser.contexts()) {
|
187
|
+
if (!context.pages().length)
|
188
|
+
await context.close({ reason: "Connection terminated" });
|
189
|
+
}
|
190
|
+
}
|
191
|
+
};
|
192
|
+
}
|
193
|
+
async _initConnectMode(id, filter, browserName, launchOptions) {
|
194
|
+
browserName ??= "chromium";
|
195
|
+
import_utils.debugLogger.log("server", `[${id}] engaged connect mode`);
|
196
|
+
let browser = this._playwright.allBrowsers().find((b) => b.options.name === browserName);
|
197
|
+
if (!browser) {
|
198
|
+
const browserType = this._playwright[browserName];
|
199
|
+
const controller = new import_progress.ProgressController();
|
200
|
+
browser = await controller.run((progress) => browserType.launch(progress, launchOptions), launchOptions.timeout);
|
201
|
+
this._dontReuse(browser);
|
202
|
+
}
|
203
|
+
return {
|
204
|
+
preLaunchedBrowser: browser,
|
205
|
+
denyLaunch: true,
|
206
|
+
sharedBrowser: true
|
207
|
+
};
|
208
|
+
}
|
209
|
+
async _initPreLaunchedBrowserMode(id) {
|
210
|
+
import_utils.debugLogger.log("server", `[${id}] engaged pre-launched (browser) mode`);
|
211
|
+
const browser = this._options.preLaunchedBrowser;
|
212
|
+
for (const b of this._playwright.allBrowsers()) {
|
213
|
+
if (b !== browser)
|
214
|
+
await b.close({ reason: "Connection terminated" });
|
215
|
+
}
|
216
|
+
return {
|
217
|
+
preLaunchedBrowser: browser,
|
218
|
+
socksProxy: this._options.preLaunchedSocksProxy,
|
219
|
+
sharedBrowser: this._options.mode === "launchServerShared",
|
220
|
+
denyLaunch: true
|
221
|
+
};
|
222
|
+
}
|
223
|
+
async _initPreLaunchedAndroidMode(id) {
|
224
|
+
import_utils.debugLogger.log("server", `[${id}] engaged pre-launched (Android) mode`);
|
225
|
+
const androidDevice = this._options.preLaunchedAndroidDevice;
|
226
|
+
return {
|
227
|
+
preLaunchedAndroidDevice: androidDevice,
|
228
|
+
denyLaunch: true
|
229
|
+
};
|
230
|
+
}
|
231
|
+
async _initLaunchBrowserMode(browserName, proxyValue, launchOptions, id) {
|
232
|
+
import_utils.debugLogger.log("server", `[${id}] engaged launch mode for "${browserName}"`);
|
233
|
+
let socksProxy;
|
234
|
+
if (proxyValue) {
|
235
|
+
socksProxy = new import_socksProxy.SocksProxy();
|
236
|
+
socksProxy.setPattern(proxyValue);
|
237
|
+
launchOptions.socksProxyPort = await socksProxy.listen(0);
|
238
|
+
import_utils.debugLogger.log("server", `[${id}] started socks proxy on port ${launchOptions.socksProxyPort}`);
|
239
|
+
} else {
|
240
|
+
launchOptions.socksProxyPort = void 0;
|
241
|
+
}
|
242
|
+
const browserType = this._playwright[browserName];
|
243
|
+
const controller = new import_progress.ProgressController();
|
244
|
+
const browser = await controller.run((progress) => browserType.launch(progress, launchOptions), launchOptions.timeout);
|
245
|
+
this._dontReuseBrowsers.add(browser);
|
246
|
+
return {
|
247
|
+
preLaunchedBrowser: browser,
|
248
|
+
socksProxy,
|
249
|
+
denyLaunch: true,
|
250
|
+
dispose: async () => {
|
251
|
+
await browser.close({ reason: "Connection terminated" });
|
252
|
+
socksProxy?.close();
|
253
|
+
}
|
254
|
+
};
|
255
|
+
}
|
256
|
+
_dontReuse(browser) {
|
257
|
+
this._dontReuseBrowsers.add(browser);
|
258
|
+
browser.on(import_browser.Browser.Events.Disconnected, () => {
|
259
|
+
this._dontReuseBrowsers.delete(browser);
|
260
|
+
});
|
261
|
+
}
|
262
|
+
async listen(port = 0, hostname) {
|
263
|
+
return this._wsServer.listen(port, hostname, this._options.path);
|
264
|
+
}
|
265
|
+
async close() {
|
266
|
+
await this._wsServer.close();
|
267
|
+
}
|
268
|
+
}
|
269
|
+
function userAgentVersionMatchesErrorMessage(userAgent) {
|
270
|
+
const match = userAgent.match(/^Playwright\/(\d+\.\d+\.\d+)/);
|
271
|
+
if (!match) {
|
272
|
+
return;
|
273
|
+
}
|
274
|
+
const received = match[1].split(".").slice(0, 2).join(".");
|
275
|
+
const expected = (0, import_userAgent.getPlaywrightVersion)(true);
|
276
|
+
if (received !== expected) {
|
277
|
+
return (0, import_ascii.wrapInASCIIBox)([
|
278
|
+
`Playwright version mismatch:`,
|
279
|
+
` - server version: v${expected}`,
|
280
|
+
` - client version: v${received}`,
|
281
|
+
``,
|
282
|
+
`If you are using VSCode extension, restart VSCode.`,
|
283
|
+
``,
|
284
|
+
`If you are connecting to a remote service,`,
|
285
|
+
`keep your local Playwright version in sync`,
|
286
|
+
`with the remote service version.`,
|
287
|
+
``,
|
288
|
+
`<3 Playwright Team`
|
289
|
+
].join("\n"), 1);
|
290
|
+
}
|
291
|
+
}
|
292
|
+
function launchOptionsHash(options) {
|
293
|
+
const copy = { ...options };
|
294
|
+
for (const k of Object.keys(copy)) {
|
295
|
+
const key = k;
|
296
|
+
if (copy[key] === defaultLaunchOptions[key])
|
297
|
+
delete copy[key];
|
298
|
+
}
|
299
|
+
for (const key of optionsThatAllowBrowserReuse)
|
300
|
+
delete copy[key];
|
301
|
+
return JSON.stringify(copy);
|
302
|
+
}
|
303
|
+
function filterLaunchOptions(options, allowFSPaths) {
|
304
|
+
return {
|
305
|
+
channel: options.channel,
|
306
|
+
args: options.args,
|
307
|
+
ignoreAllDefaultArgs: options.ignoreAllDefaultArgs,
|
308
|
+
ignoreDefaultArgs: options.ignoreDefaultArgs,
|
309
|
+
timeout: options.timeout,
|
310
|
+
headless: options.headless,
|
311
|
+
proxy: options.proxy,
|
312
|
+
chromiumSandbox: options.chromiumSandbox,
|
313
|
+
firefoxUserPrefs: options.firefoxUserPrefs,
|
314
|
+
slowMo: options.slowMo,
|
315
|
+
executablePath: (0, import_utils.isUnderTest)() || allowFSPaths ? options.executablePath : void 0,
|
316
|
+
downloadsPath: allowFSPaths ? options.downloadsPath : void 0
|
317
|
+
};
|
318
|
+
}
|
319
|
+
const defaultLaunchOptions = {
|
320
|
+
ignoreAllDefaultArgs: false,
|
321
|
+
handleSIGINT: false,
|
322
|
+
handleSIGTERM: false,
|
323
|
+
handleSIGHUP: false,
|
324
|
+
headless: true,
|
325
|
+
devtools: false
|
326
|
+
};
|
327
|
+
const optionsThatAllowBrowserReuse = [
|
328
|
+
"headless",
|
329
|
+
"timeout",
|
330
|
+
"tracesDir"
|
331
|
+
];
|
332
|
+
// Annotate the CommonJS export names for ESM import in node:
|
333
|
+
0 && (module.exports = {
|
334
|
+
PlaywrightServer
|
335
|
+
});
|