patchright 1.48.0__py3-none-win32.whl
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.
- patchright/__init__.py +5 -0
- patchright/__main__.py +18 -0
- patchright/_impl/__init__.py +0 -0
- patchright/_impl/__pyinstaller/__init__.py +20 -0
- patchright/_impl/__pyinstaller/hook-playwright.async_api.py +17 -0
- patchright/_impl/__pyinstaller/hook-playwright.sync_api.py +17 -0
- patchright/_impl/_accessibility.py +50 -0
- patchright/_impl/_api_structures.py +271 -0
- patchright/_impl/_artifact.py +45 -0
- patchright/_impl/_assertions.py +779 -0
- patchright/_impl/_async_base.py +92 -0
- patchright/_impl/_browser.py +243 -0
- patchright/_impl/_browser_context.py +724 -0
- patchright/_impl/_browser_type.py +264 -0
- patchright/_impl/_cdp_session.py +21 -0
- patchright/_impl/_clock.py +57 -0
- patchright/_impl/_connection.py +554 -0
- patchright/_impl/_console_message.py +45 -0
- patchright/_impl/_dialog.py +40 -0
- patchright/_impl/_download.py +50 -0
- patchright/_impl/_driver.py +26 -0
- patchright/_impl/_element_handle.py +376 -0
- patchright/_impl/_errors.py +44 -0
- patchright/_impl/_event_context_manager.py +20 -0
- patchright/_impl/_fetch.py +511 -0
- patchright/_impl/_file_chooser.py +43 -0
- patchright/_impl/_frame.py +755 -0
- patchright/_impl/_glob.py +51 -0
- patchright/_impl/_greenlets.py +39 -0
- patchright/_impl/_har_router.py +99 -0
- patchright/_impl/_helper.py +421 -0
- patchright/_impl/_impl_to_api_mapping.py +123 -0
- patchright/_impl/_input.py +71 -0
- patchright/_impl/_js_handle.py +234 -0
- patchright/_impl/_json_pipe.py +56 -0
- patchright/_impl/_local_utils.py +73 -0
- patchright/_impl/_locator.py +784 -0
- patchright/_impl/_map.py +19 -0
- patchright/_impl/_network.py +934 -0
- patchright/_impl/_object_factory.py +91 -0
- patchright/_impl/_page.py +1446 -0
- patchright/_impl/_path_utils.py +11 -0
- patchright/_impl/_playwright.py +51 -0
- patchright/_impl/_selectors.py +62 -0
- patchright/_impl/_set_input_files_helpers.py +135 -0
- patchright/_impl/_str_utils.py +57 -0
- patchright/_impl/_stream.py +32 -0
- patchright/_impl/_sync_base.py +134 -0
- patchright/_impl/_tracing.py +103 -0
- patchright/_impl/_transport.py +150 -0
- patchright/_impl/_video.py +57 -0
- patchright/_impl/_waiter.py +142 -0
- patchright/_impl/_web_error.py +22 -0
- patchright/_impl/_writable_stream.py +27 -0
- patchright/_repo_version.py +12 -0
- patchright/async_api/__init__.py +177 -0
- patchright/async_api/_context_manager.py +39 -0
- patchright/async_api/_generated.py +19960 -0
- patchright/driver/LICENSE +2174 -0
- patchright/driver/README.md +1 -0
- patchright/driver/node.exe +0 -0
- patchright/driver/package/README.md +3 -0
- patchright/driver/package/ThirdPartyNotices.txt +1548 -0
- patchright/driver/package/api.json +1 -0
- patchright/driver/package/bin/PrintDeps.exe +0 -0
- patchright/driver/package/bin/README.md +2 -0
- patchright/driver/package/bin/install_media_pack.ps1 +5 -0
- patchright/driver/package/bin/reinstall_chrome_beta_linux.sh +40 -0
- patchright/driver/package/bin/reinstall_chrome_beta_mac.sh +13 -0
- patchright/driver/package/bin/reinstall_chrome_beta_win.ps1 +24 -0
- patchright/driver/package/bin/reinstall_chrome_stable_linux.sh +40 -0
- patchright/driver/package/bin/reinstall_chrome_stable_mac.sh +12 -0
- patchright/driver/package/bin/reinstall_chrome_stable_win.ps1 +24 -0
- patchright/driver/package/bin/reinstall_msedge_beta_linux.sh +40 -0
- patchright/driver/package/bin/reinstall_msedge_beta_mac.sh +11 -0
- patchright/driver/package/bin/reinstall_msedge_beta_win.ps1 +23 -0
- patchright/driver/package/bin/reinstall_msedge_dev_linux.sh +40 -0
- patchright/driver/package/bin/reinstall_msedge_dev_mac.sh +11 -0
- patchright/driver/package/bin/reinstall_msedge_dev_win.ps1 +23 -0
- patchright/driver/package/bin/reinstall_msedge_stable_linux.sh +40 -0
- patchright/driver/package/bin/reinstall_msedge_stable_mac.sh +11 -0
- patchright/driver/package/bin/reinstall_msedge_stable_win.ps1 +24 -0
- patchright/driver/package/browsers.json +57 -0
- patchright/driver/package/cli.js +18 -0
- patchright/driver/package/index.d.ts +17 -0
- patchright/driver/package/index.js +33 -0
- patchright/driver/package/index.mjs +28 -0
- patchright/driver/package/lib/androidServerImpl.js +69 -0
- patchright/driver/package/lib/browserServerImpl.js +92 -0
- patchright/driver/package/lib/cli/driver.js +95 -0
- patchright/driver/package/lib/cli/program.js +587 -0
- patchright/driver/package/lib/cli/programWithTestStub.js +67 -0
- patchright/driver/package/lib/client/accessibility.js +50 -0
- patchright/driver/package/lib/client/android.js +473 -0
- patchright/driver/package/lib/client/api.js +285 -0
- patchright/driver/package/lib/client/artifact.js +79 -0
- patchright/driver/package/lib/client/browser.js +145 -0
- patchright/driver/package/lib/client/browserContext.js +559 -0
- patchright/driver/package/lib/client/browserType.js +241 -0
- patchright/driver/package/lib/client/cdpSession.js +53 -0
- patchright/driver/package/lib/client/channelOwner.js +235 -0
- patchright/driver/package/lib/client/clientHelper.js +57 -0
- patchright/driver/package/lib/client/clientInstrumentation.js +50 -0
- patchright/driver/package/lib/client/clock.js +68 -0
- patchright/driver/package/lib/client/connection.js +333 -0
- patchright/driver/package/lib/client/consoleMessage.js +55 -0
- patchright/driver/package/lib/client/coverage.js +41 -0
- patchright/driver/package/lib/client/dialog.js +57 -0
- patchright/driver/package/lib/client/download.js +62 -0
- patchright/driver/package/lib/client/electron.js +135 -0
- patchright/driver/package/lib/client/elementHandle.js +321 -0
- patchright/driver/package/lib/client/errors.js +77 -0
- patchright/driver/package/lib/client/eventEmitter.js +314 -0
- patchright/driver/package/lib/client/events.js +94 -0
- patchright/driver/package/lib/client/fetch.js +391 -0
- patchright/driver/package/lib/client/fileChooser.js +45 -0
- patchright/driver/package/lib/client/frame.js +504 -0
- patchright/driver/package/lib/client/harRouter.js +99 -0
- patchright/driver/package/lib/client/input.js +111 -0
- patchright/driver/package/lib/client/jsHandle.js +121 -0
- patchright/driver/package/lib/client/jsonPipe.js +35 -0
- patchright/driver/package/lib/client/localUtils.js +36 -0
- patchright/driver/package/lib/client/locator.js +441 -0
- patchright/driver/package/lib/client/network.js +762 -0
- patchright/driver/package/lib/client/page.js +746 -0
- patchright/driver/package/lib/client/playwright.js +80 -0
- patchright/driver/package/lib/client/selectors.js +67 -0
- patchright/driver/package/lib/client/stream.js +54 -0
- patchright/driver/package/lib/client/tracing.js +134 -0
- patchright/driver/package/lib/client/types.js +24 -0
- patchright/driver/package/lib/client/video.js +51 -0
- patchright/driver/package/lib/client/waiter.js +158 -0
- patchright/driver/package/lib/client/webError.js +37 -0
- patchright/driver/package/lib/client/worker.js +71 -0
- patchright/driver/package/lib/client/writableStream.js +54 -0
- patchright/driver/package/lib/common/socksProxy.js +569 -0
- patchright/driver/package/lib/common/timeoutSettings.js +73 -0
- patchright/driver/package/lib/common/types.js +5 -0
- patchright/driver/package/lib/generated/clockSource.js +7 -0
- patchright/driver/package/lib/generated/consoleApiSource.js +7 -0
- patchright/driver/package/lib/generated/injectedScriptSource.js +7 -0
- patchright/driver/package/lib/generated/pollingRecorderSource.js +7 -0
- patchright/driver/package/lib/generated/utilityScriptSource.js +7 -0
- patchright/driver/package/lib/generated/webSocketMockSource.js +7 -0
- patchright/driver/package/lib/image_tools/colorUtils.js +98 -0
- patchright/driver/package/lib/image_tools/compare.js +108 -0
- patchright/driver/package/lib/image_tools/imageChannel.js +70 -0
- patchright/driver/package/lib/image_tools/stats.js +102 -0
- patchright/driver/package/lib/inProcessFactory.js +54 -0
- patchright/driver/package/lib/inprocess.js +20 -0
- patchright/driver/package/lib/outofprocess.js +67 -0
- patchright/driver/package/lib/protocol/debug.js +27 -0
- patchright/driver/package/lib/protocol/serializers.js +173 -0
- patchright/driver/package/lib/protocol/transport.js +82 -0
- patchright/driver/package/lib/protocol/validator.js +2759 -0
- patchright/driver/package/lib/protocol/validatorPrimitives.js +139 -0
- patchright/driver/package/lib/remote/playwrightConnection.js +274 -0
- patchright/driver/package/lib/remote/playwrightServer.js +110 -0
- patchright/driver/package/lib/server/accessibility.js +62 -0
- patchright/driver/package/lib/server/android/android.js +441 -0
- patchright/driver/package/lib/server/android/backendAdb.js +172 -0
- patchright/driver/package/lib/server/artifact.js +104 -0
- patchright/driver/package/lib/server/bidi/bidiBrowser.js +311 -0
- patchright/driver/package/lib/server/bidi/bidiChromium.js +124 -0
- patchright/driver/package/lib/server/bidi/bidiConnection.js +206 -0
- patchright/driver/package/lib/server/bidi/bidiExecutionContext.js +159 -0
- patchright/driver/package/lib/server/bidi/bidiFirefox.js +104 -0
- patchright/driver/package/lib/server/bidi/bidiInput.js +158 -0
- patchright/driver/package/lib/server/bidi/bidiNetworkManager.js +338 -0
- patchright/driver/package/lib/server/bidi/bidiOverCdp.js +103 -0
- patchright/driver/package/lib/server/bidi/bidiPage.js +529 -0
- patchright/driver/package/lib/server/bidi/bidiPdf.js +140 -0
- patchright/driver/package/lib/server/bidi/third_party/bidiDeserializer.js +93 -0
- patchright/driver/package/lib/server/bidi/third_party/bidiKeyboard.js +238 -0
- patchright/driver/package/lib/server/bidi/third_party/bidiProtocol.js +139 -0
- patchright/driver/package/lib/server/bidi/third_party/bidiSerializer.js +144 -0
- patchright/driver/package/lib/server/bidi/third_party/firefoxPrefs.js +221 -0
- patchright/driver/package/lib/server/browser.js +148 -0
- patchright/driver/package/lib/server/browserContext.js +666 -0
- patchright/driver/package/lib/server/browserType.js +335 -0
- patchright/driver/package/lib/server/chromium/appIcon.png +0 -0
- patchright/driver/package/lib/server/chromium/chromium.js +350 -0
- patchright/driver/package/lib/server/chromium/chromiumSwitches.js +36 -0
- patchright/driver/package/lib/server/chromium/crAccessibility.js +237 -0
- patchright/driver/package/lib/server/chromium/crBrowser.js +522 -0
- patchright/driver/package/lib/server/chromium/crConnection.js +228 -0
- patchright/driver/package/lib/server/chromium/crCoverage.js +246 -0
- patchright/driver/package/lib/server/chromium/crDevTools.js +104 -0
- patchright/driver/package/lib/server/chromium/crDragDrop.js +143 -0
- patchright/driver/package/lib/server/chromium/crExecutionContext.js +149 -0
- patchright/driver/package/lib/server/chromium/crInput.js +171 -0
- patchright/driver/package/lib/server/chromium/crNetworkManager.js +809 -0
- patchright/driver/package/lib/server/chromium/crPage.js +1235 -0
- patchright/driver/package/lib/server/chromium/crPdf.js +153 -0
- patchright/driver/package/lib/server/chromium/crProtocolHelper.js +133 -0
- patchright/driver/package/lib/server/chromium/crServiceWorker.js +111 -0
- patchright/driver/package/lib/server/chromium/defaultFontFamilies.js +145 -0
- patchright/driver/package/lib/server/chromium/videoRecorder.js +155 -0
- patchright/driver/package/lib/server/clock.js +133 -0
- patchright/driver/package/lib/server/codegen/csharp.js +299 -0
- patchright/driver/package/lib/server/codegen/java.js +235 -0
- patchright/driver/package/lib/server/codegen/javascript.js +223 -0
- patchright/driver/package/lib/server/codegen/jsonl.js +47 -0
- patchright/driver/package/lib/server/codegen/language.js +88 -0
- patchright/driver/package/lib/server/codegen/languages.js +30 -0
- patchright/driver/package/lib/server/codegen/python.js +265 -0
- patchright/driver/package/lib/server/codegen/types.js +5 -0
- patchright/driver/package/lib/server/console.js +57 -0
- patchright/driver/package/lib/server/cookieStore.js +185 -0
- patchright/driver/package/lib/server/debugController.js +234 -0
- patchright/driver/package/lib/server/debugger.js +132 -0
- patchright/driver/package/lib/server/deviceDescriptors.js +26 -0
- patchright/driver/package/lib/server/deviceDescriptorsSource.json +1669 -0
- patchright/driver/package/lib/server/dialog.js +71 -0
- patchright/driver/package/lib/server/dispatchers/androidDispatcher.js +193 -0
- patchright/driver/package/lib/server/dispatchers/artifactDispatcher.js +118 -0
- patchright/driver/package/lib/server/dispatchers/browserContextDispatcher.js +368 -0
- patchright/driver/package/lib/server/dispatchers/browserDispatcher.js +170 -0
- patchright/driver/package/lib/server/dispatchers/browserTypeDispatcher.js +55 -0
- patchright/driver/package/lib/server/dispatchers/cdpSessionDispatcher.js +48 -0
- patchright/driver/package/lib/server/dispatchers/debugControllerDispatcher.js +103 -0
- patchright/driver/package/lib/server/dispatchers/dialogDispatcher.js +44 -0
- patchright/driver/package/lib/server/dispatchers/dispatcher.js +395 -0
- patchright/driver/package/lib/server/dispatchers/electronDispatcher.js +93 -0
- patchright/driver/package/lib/server/dispatchers/elementHandlerDispatcher.js +228 -0
- patchright/driver/package/lib/server/dispatchers/frameDispatcher.js +286 -0
- patchright/driver/package/lib/server/dispatchers/jsHandleDispatcher.js +97 -0
- patchright/driver/package/lib/server/dispatchers/jsonPipeDispatcher.js +59 -0
- patchright/driver/package/lib/server/dispatchers/localUtilsDispatcher.js +413 -0
- patchright/driver/package/lib/server/dispatchers/networkDispatchers.js +221 -0
- patchright/driver/package/lib/server/dispatchers/pageDispatcher.js +367 -0
- patchright/driver/package/lib/server/dispatchers/playwrightDispatcher.js +107 -0
- patchright/driver/package/lib/server/dispatchers/selectorsDispatcher.js +36 -0
- patchright/driver/package/lib/server/dispatchers/streamDispatcher.js +62 -0
- patchright/driver/package/lib/server/dispatchers/tracingDispatcher.js +54 -0
- patchright/driver/package/lib/server/dispatchers/webSocketRouteDispatcher.js +189 -0
- patchright/driver/package/lib/server/dispatchers/writableStreamDispatcher.js +58 -0
- patchright/driver/package/lib/server/dom.js +845 -0
- patchright/driver/package/lib/server/download.js +60 -0
- patchright/driver/package/lib/server/electron/electron.js +296 -0
- patchright/driver/package/lib/server/electron/loader.js +57 -0
- patchright/driver/package/lib/server/errors.js +68 -0
- patchright/driver/package/lib/server/fetch.js +656 -0
- patchright/driver/package/lib/server/fileChooser.js +42 -0
- patchright/driver/package/lib/server/fileUploadUtils.js +75 -0
- patchright/driver/package/lib/server/firefox/ffAccessibility.js +216 -0
- patchright/driver/package/lib/server/firefox/ffBrowser.js +460 -0
- patchright/driver/package/lib/server/firefox/ffConnection.js +168 -0
- patchright/driver/package/lib/server/firefox/ffExecutionContext.js +135 -0
- patchright/driver/package/lib/server/firefox/ffInput.js +150 -0
- patchright/driver/package/lib/server/firefox/ffNetworkManager.js +233 -0
- patchright/driver/package/lib/server/firefox/ffPage.js +559 -0
- patchright/driver/package/lib/server/firefox/firefox.js +99 -0
- patchright/driver/package/lib/server/formData.js +75 -0
- patchright/driver/package/lib/server/frameSelectors.js +171 -0
- patchright/driver/package/lib/server/frames.js +1808 -0
- patchright/driver/package/lib/server/har/harRecorder.js +139 -0
- patchright/driver/package/lib/server/har/harTracer.js +542 -0
- patchright/driver/package/lib/server/helper.js +103 -0
- patchright/driver/package/lib/server/index.js +114 -0
- patchright/driver/package/lib/server/input.js +310 -0
- patchright/driver/package/lib/server/instrumentation.js +70 -0
- patchright/driver/package/lib/server/isomorphic/utilityScriptSerializers.js +226 -0
- patchright/driver/package/lib/server/javascript.js +299 -0
- patchright/driver/package/lib/server/launchApp.js +91 -0
- patchright/driver/package/lib/server/macEditingCommands.js +139 -0
- patchright/driver/package/lib/server/network.js +617 -0
- patchright/driver/package/lib/server/page.js +819 -0
- patchright/driver/package/lib/server/pipeTransport.js +85 -0
- patchright/driver/package/lib/server/playwright.js +88 -0
- patchright/driver/package/lib/server/progress.js +102 -0
- patchright/driver/package/lib/server/protocolError.js +49 -0
- patchright/driver/package/lib/server/recorder/contextRecorder.js +299 -0
- patchright/driver/package/lib/server/recorder/recorderApp.js +196 -0
- patchright/driver/package/lib/server/recorder/recorderCollection.js +116 -0
- patchright/driver/package/lib/server/recorder/recorderFrontend.js +5 -0
- patchright/driver/package/lib/server/recorder/recorderInTraceViewer.js +144 -0
- patchright/driver/package/lib/server/recorder/recorderRunner.js +155 -0
- patchright/driver/package/lib/server/recorder/recorderUtils.js +112 -0
- patchright/driver/package/lib/server/recorder/throttledFile.js +46 -0
- patchright/driver/package/lib/server/recorder.js +327 -0
- patchright/driver/package/lib/server/registry/browserFetcher.js +168 -0
- patchright/driver/package/lib/server/registry/dependencies.js +322 -0
- patchright/driver/package/lib/server/registry/index.js +1005 -0
- patchright/driver/package/lib/server/registry/nativeDeps.js +490 -0
- patchright/driver/package/lib/server/registry/oopDownloadBrowserMain.js +138 -0
- patchright/driver/package/lib/server/screenshotter.js +348 -0
- patchright/driver/package/lib/server/selectors.js +73 -0
- patchright/driver/package/lib/server/socksClientCertificatesInterceptor.js +340 -0
- patchright/driver/package/lib/server/socksInterceptor.js +100 -0
- patchright/driver/package/lib/server/trace/recorder/snapshotter.js +172 -0
- patchright/driver/package/lib/server/trace/recorder/snapshotterInjected.js +493 -0
- patchright/driver/package/lib/server/trace/recorder/tracing.js +542 -0
- patchright/driver/package/lib/server/trace/test/inMemorySnapshotter.js +93 -0
- patchright/driver/package/lib/server/trace/viewer/traceViewer.js +213 -0
- patchright/driver/package/lib/server/transport.js +191 -0
- patchright/driver/package/lib/server/types.js +24 -0
- patchright/driver/package/lib/server/usKeyboardLayout.js +555 -0
- patchright/driver/package/lib/server/webkit/webkit.js +87 -0
- patchright/driver/package/lib/server/webkit/wkAccessibility.js +194 -0
- patchright/driver/package/lib/server/webkit/wkBrowser.js +329 -0
- patchright/driver/package/lib/server/webkit/wkConnection.js +173 -0
- patchright/driver/package/lib/server/webkit/wkExecutionContext.js +143 -0
- patchright/driver/package/lib/server/webkit/wkInput.js +169 -0
- patchright/driver/package/lib/server/webkit/wkInterceptableRequest.js +162 -0
- patchright/driver/package/lib/server/webkit/wkPage.js +1219 -0
- patchright/driver/package/lib/server/webkit/wkProvisionalPage.js +94 -0
- patchright/driver/package/lib/server/webkit/wkWorkers.js +104 -0
- patchright/driver/package/lib/third_party/diff_match_patch.js +2222 -0
- patchright/driver/package/lib/third_party/pixelmatch.js +255 -0
- patchright/driver/package/lib/utils/ascii.js +31 -0
- patchright/driver/package/lib/utils/comparators.js +171 -0
- patchright/driver/package/lib/utils/crypto.js +174 -0
- patchright/driver/package/lib/utils/debug.js +46 -0
- patchright/driver/package/lib/utils/debugLogger.js +91 -0
- patchright/driver/package/lib/utils/env.js +49 -0
- patchright/driver/package/lib/utils/eventsHelper.js +38 -0
- patchright/driver/package/lib/utils/expectUtils.js +33 -0
- patchright/driver/package/lib/utils/fileUtils.js +205 -0
- patchright/driver/package/lib/utils/happy-eyeballs.js +194 -0
- patchright/driver/package/lib/utils/headers.js +52 -0
- patchright/driver/package/lib/utils/hostPlatform.js +133 -0
- patchright/driver/package/lib/utils/httpServer.js +237 -0
- patchright/driver/package/lib/utils/index.js +368 -0
- patchright/driver/package/lib/utils/isomorphic/cssParser.js +250 -0
- patchright/driver/package/lib/utils/isomorphic/cssTokenizer.js +979 -0
- patchright/driver/package/lib/utils/isomorphic/locatorGenerators.js +642 -0
- patchright/driver/package/lib/utils/isomorphic/locatorParser.js +179 -0
- patchright/driver/package/lib/utils/isomorphic/locatorUtils.js +62 -0
- patchright/driver/package/lib/utils/isomorphic/mimeType.js +29 -0
- patchright/driver/package/lib/utils/isomorphic/recorderUtils.js +195 -0
- patchright/driver/package/lib/utils/isomorphic/selectorParser.js +397 -0
- patchright/driver/package/lib/utils/isomorphic/stringUtils.js +139 -0
- patchright/driver/package/lib/utils/isomorphic/traceUtils.js +39 -0
- patchright/driver/package/lib/utils/isomorphic/urlMatch.js +120 -0
- patchright/driver/package/lib/utils/linuxUtils.js +78 -0
- patchright/driver/package/lib/utils/manualPromise.js +109 -0
- patchright/driver/package/lib/utils/multimap.js +75 -0
- patchright/driver/package/lib/utils/network.js +160 -0
- patchright/driver/package/lib/utils/processLauncher.js +248 -0
- patchright/driver/package/lib/utils/profiler.js +53 -0
- patchright/driver/package/lib/utils/rtti.js +44 -0
- patchright/driver/package/lib/utils/semaphore.js +51 -0
- patchright/driver/package/lib/utils/spawnAsync.js +45 -0
- patchright/driver/package/lib/utils/stackTrace.js +121 -0
- patchright/driver/package/lib/utils/task.js +58 -0
- patchright/driver/package/lib/utils/time.js +37 -0
- patchright/driver/package/lib/utils/timeoutRunner.js +66 -0
- patchright/driver/package/lib/utils/traceUtils.js +44 -0
- patchright/driver/package/lib/utils/userAgent.js +105 -0
- patchright/driver/package/lib/utils/wsServer.js +127 -0
- patchright/driver/package/lib/utils/zipFile.js +75 -0
- patchright/driver/package/lib/utils/zones.js +62 -0
- patchright/driver/package/lib/utilsBundle.js +82 -0
- patchright/driver/package/lib/utilsBundleImpl/index.js +53 -0
- patchright/driver/package/lib/utilsBundleImpl/xdg-open +1066 -0
- patchright/driver/package/lib/vite/htmlReport/index.html +66 -0
- patchright/driver/package/lib/vite/recorder/assets/codeMirrorModule-d0KhC1qL.js +24 -0
- patchright/driver/package/lib/vite/recorder/assets/codeMirrorModule-ez37Vkbh.css +1 -0
- patchright/driver/package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- patchright/driver/package/lib/vite/recorder/assets/index-BW-aOBcL.css +1 -0
- patchright/driver/package/lib/vite/recorder/assets/index-Bxxcmxlu.js +42 -0
- patchright/driver/package/lib/vite/recorder/index.html +29 -0
- patchright/driver/package/lib/vite/recorder/playwright-logo.svg +9 -0
- patchright/driver/package/lib/vite/traceViewer/assets/codeMirrorModule-CZTtn9l8.js +24 -0
- patchright/driver/package/lib/vite/traceViewer/assets/inspectorTab-DTusvprx.js +64 -0
- patchright/driver/package/lib/vite/traceViewer/assets/testServerConnection-DeE2kSzz.js +1 -0
- patchright/driver/package/lib/vite/traceViewer/assets/workbench-DIEjrm3Z.js +9 -0
- patchright/driver/package/lib/vite/traceViewer/assets/xtermModule-BeNbaIVa.js +9 -0
- patchright/driver/package/lib/vite/traceViewer/codeMirrorModule.ez37Vkbh.css +1 -0
- patchright/driver/package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- patchright/driver/package/lib/vite/traceViewer/embedded.Do_J5Hgs.js +2 -0
- patchright/driver/package/lib/vite/traceViewer/embedded.html +18 -0
- patchright/driver/package/lib/vite/traceViewer/embedded.w7WN2u1R.css +1 -0
- patchright/driver/package/lib/vite/traceViewer/index.B21BXreT.js +2 -0
- patchright/driver/package/lib/vite/traceViewer/index.CrbWWHbf.css +1 -0
- patchright/driver/package/lib/vite/traceViewer/index.html +29 -0
- patchright/driver/package/lib/vite/traceViewer/inspectorTab.DLjBDrQR.css +1 -0
- patchright/driver/package/lib/vite/traceViewer/playwright-logo.svg +9 -0
- patchright/driver/package/lib/vite/traceViewer/recorder.B_SY1GJM.css +0 -0
- patchright/driver/package/lib/vite/traceViewer/recorder.Bfh_9UGt.js +2 -0
- patchright/driver/package/lib/vite/traceViewer/recorder.html +17 -0
- patchright/driver/package/lib/vite/traceViewer/snapshot.html +21 -0
- patchright/driver/package/lib/vite/traceViewer/sw.bundle.js +3 -0
- patchright/driver/package/lib/vite/traceViewer/uiMode.CAYqod-m.css +1 -0
- patchright/driver/package/lib/vite/traceViewer/uiMode.DloKQa-h.js +5 -0
- patchright/driver/package/lib/vite/traceViewer/uiMode.html +20 -0
- patchright/driver/package/lib/vite/traceViewer/workbench.D3JVcA9K.css +1 -0
- patchright/driver/package/lib/vite/traceViewer/xtermModule.DSXBckUd.css +32 -0
- patchright/driver/package/lib/zipBundle.js +25 -0
- patchright/driver/package/lib/zipBundleImpl.js +5 -0
- patchright/driver/package/package.json +44 -0
- patchright/driver/package/protocol.yml +3720 -0
- patchright/driver/package/types/protocol.d.ts +21571 -0
- patchright/driver/package/types/structs.d.ts +45 -0
- patchright/driver/package/types/types.d.ts +22519 -0
- patchright/py.typed +0 -0
- patchright/sync_api/__init__.py +177 -0
- patchright/sync_api/_context_manager.py +74 -0
- patchright/sync_api/_generated.py +20155 -0
- patchright-1.48.0.dist-info/LICENSE +202 -0
- patchright-1.48.0.dist-info/METADATA +83 -0
- patchright-1.48.0.dist-info/RECORD +406 -0
- patchright-1.48.0.dist-info/WHEEL +5 -0
- patchright-1.48.0.dist-info/entry_points.txt +5 -0
- patchright-1.48.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import inspect
|
|
2
|
+
from typing import Any, Callable, Dict, List, Optional, Sequence, Union
|
|
3
|
+
from patchright._impl._errors import Error
|
|
4
|
+
from patchright._impl._map import Map
|
|
5
|
+
|
|
6
|
+
API_ATTR = "_pw_api_instance_"
|
|
7
|
+
IMPL_ATTR = "_pw_impl_instance_"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ImplWrapper:
|
|
11
|
+
|
|
12
|
+
def __init__(self, impl_obj: Any) -> None:
|
|
13
|
+
self._impl_obj = impl_obj
|
|
14
|
+
|
|
15
|
+
def __repr__(self) -> str:
|
|
16
|
+
return self._impl_obj.__repr__()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ImplToApiMapping:
|
|
20
|
+
|
|
21
|
+
def __init__(self) -> None:
|
|
22
|
+
self._mapping: Dict[type, type] = {}
|
|
23
|
+
|
|
24
|
+
def register(self, impl_class: type, api_class: type) -> None:
|
|
25
|
+
self._mapping[impl_class] = api_class
|
|
26
|
+
|
|
27
|
+
def from_maybe_impl(
|
|
28
|
+
self, obj: Any, visited: Optional[Map[Any, Union[List, Dict]]] = None
|
|
29
|
+
) -> Any:
|
|
30
|
+
if not visited:
|
|
31
|
+
visited = Map()
|
|
32
|
+
if not obj:
|
|
33
|
+
return obj
|
|
34
|
+
if isinstance(obj, dict):
|
|
35
|
+
if obj in visited:
|
|
36
|
+
return visited[obj]
|
|
37
|
+
o: Dict = {}
|
|
38
|
+
visited[obj] = o
|
|
39
|
+
for name, value in obj.items():
|
|
40
|
+
o[name] = self.from_maybe_impl(value, visited)
|
|
41
|
+
return o
|
|
42
|
+
if isinstance(obj, list):
|
|
43
|
+
if obj in visited:
|
|
44
|
+
return visited[obj]
|
|
45
|
+
a: List = []
|
|
46
|
+
visited[obj] = a
|
|
47
|
+
for item in obj:
|
|
48
|
+
a.append(self.from_maybe_impl(item, visited))
|
|
49
|
+
return a
|
|
50
|
+
api_class = self._mapping.get(type(obj))
|
|
51
|
+
if api_class:
|
|
52
|
+
api_instance = getattr(obj, API_ATTR, None)
|
|
53
|
+
if not api_instance:
|
|
54
|
+
api_instance = api_class(obj)
|
|
55
|
+
setattr(obj, API_ATTR, api_instance)
|
|
56
|
+
return api_instance
|
|
57
|
+
else:
|
|
58
|
+
return obj
|
|
59
|
+
|
|
60
|
+
def from_impl(self, obj: Any) -> Any:
|
|
61
|
+
assert obj
|
|
62
|
+
result = self.from_maybe_impl(obj)
|
|
63
|
+
assert result
|
|
64
|
+
return result
|
|
65
|
+
|
|
66
|
+
def from_impl_nullable(self, obj: Any = None) -> Optional[Any]:
|
|
67
|
+
return self.from_impl(obj) if obj else None
|
|
68
|
+
|
|
69
|
+
def from_impl_list(self, items: Sequence[Any]) -> List[Any]:
|
|
70
|
+
return list(map(lambda a: self.from_impl(a), items))
|
|
71
|
+
|
|
72
|
+
def from_impl_dict(self, map: Dict[str, Any]) -> Dict[str, Any]:
|
|
73
|
+
return {name: self.from_impl(value) for name, value in map.items()}
|
|
74
|
+
|
|
75
|
+
def to_impl(
|
|
76
|
+
self, obj: Any, visited: Optional[Map[Any, Union[List, Dict]]] = None
|
|
77
|
+
) -> Any:
|
|
78
|
+
if visited is None:
|
|
79
|
+
visited = Map()
|
|
80
|
+
try:
|
|
81
|
+
if not obj:
|
|
82
|
+
return obj
|
|
83
|
+
if isinstance(obj, dict):
|
|
84
|
+
if obj in visited:
|
|
85
|
+
return visited[obj]
|
|
86
|
+
o: Dict = {}
|
|
87
|
+
visited[obj] = o
|
|
88
|
+
for name, value in obj.items():
|
|
89
|
+
o[name] = self.to_impl(value, visited)
|
|
90
|
+
return o
|
|
91
|
+
if isinstance(obj, list):
|
|
92
|
+
if obj in visited:
|
|
93
|
+
return visited[obj]
|
|
94
|
+
a: List = []
|
|
95
|
+
visited[obj] = a
|
|
96
|
+
for item in obj:
|
|
97
|
+
a.append(self.to_impl(item, visited))
|
|
98
|
+
return a
|
|
99
|
+
if isinstance(obj, ImplWrapper):
|
|
100
|
+
return obj._impl_obj
|
|
101
|
+
return obj
|
|
102
|
+
except RecursionError:
|
|
103
|
+
raise Error("Maximum argument depth exceeded")
|
|
104
|
+
|
|
105
|
+
def wrap_handler(self, handler: Callable[..., Any]) -> Callable[..., None]:
|
|
106
|
+
|
|
107
|
+
def wrapper_func(*args: Any) -> Any:
|
|
108
|
+
arg_count = len(inspect.signature(handler).parameters)
|
|
109
|
+
return handler(
|
|
110
|
+
*list(map(lambda a: self.from_maybe_impl(a), args))[:arg_count]
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
if inspect.ismethod(handler):
|
|
114
|
+
wrapper = getattr(handler.__self__, IMPL_ATTR + handler.__name__, None)
|
|
115
|
+
if not wrapper:
|
|
116
|
+
wrapper = wrapper_func
|
|
117
|
+
setattr(handler.__self__, IMPL_ATTR + handler.__name__, wrapper)
|
|
118
|
+
return wrapper
|
|
119
|
+
wrapper = getattr(handler, IMPL_ATTR, None)
|
|
120
|
+
if not wrapper:
|
|
121
|
+
wrapper = wrapper_func
|
|
122
|
+
setattr(handler, IMPL_ATTR, wrapper)
|
|
123
|
+
return wrapper
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from patchright._impl._connection import Channel
|
|
2
|
+
from patchright._impl._helper import MouseButton, locals_to_params
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Keyboard:
|
|
6
|
+
|
|
7
|
+
def __init__(self, channel: Channel) -> None:
|
|
8
|
+
self._channel = channel
|
|
9
|
+
self._loop = channel._connection._loop
|
|
10
|
+
self._dispatcher_fiber = channel._connection._dispatcher_fiber
|
|
11
|
+
|
|
12
|
+
async def down(self, key: str) -> None:
|
|
13
|
+
await self._channel.send("keyboardDown", locals_to_params(locals()))
|
|
14
|
+
|
|
15
|
+
async def up(self, key: str) -> None:
|
|
16
|
+
await self._channel.send("keyboardUp", locals_to_params(locals()))
|
|
17
|
+
|
|
18
|
+
async def insert_text(self, text: str) -> None:
|
|
19
|
+
await self._channel.send("keyboardInsertText", locals_to_params(locals()))
|
|
20
|
+
|
|
21
|
+
async def type(self, text: str, delay: float = None) -> None:
|
|
22
|
+
await self._channel.send("keyboardType", locals_to_params(locals()))
|
|
23
|
+
|
|
24
|
+
async def press(self, key: str, delay: float = None) -> None:
|
|
25
|
+
await self._channel.send("keyboardPress", locals_to_params(locals()))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class Mouse:
|
|
29
|
+
|
|
30
|
+
def __init__(self, channel: Channel) -> None:
|
|
31
|
+
self._channel = channel
|
|
32
|
+
self._loop = channel._connection._loop
|
|
33
|
+
self._dispatcher_fiber = channel._connection._dispatcher_fiber
|
|
34
|
+
|
|
35
|
+
async def move(self, x: float, y: float, steps: int = None) -> None:
|
|
36
|
+
await self._channel.send("mouseMove", locals_to_params(locals()))
|
|
37
|
+
|
|
38
|
+
async def down(self, button: MouseButton = None, clickCount: int = None) -> None:
|
|
39
|
+
await self._channel.send("mouseDown", locals_to_params(locals()))
|
|
40
|
+
|
|
41
|
+
async def up(self, button: MouseButton = None, clickCount: int = None) -> None:
|
|
42
|
+
await self._channel.send("mouseUp", locals_to_params(locals()))
|
|
43
|
+
|
|
44
|
+
async def click(
|
|
45
|
+
self,
|
|
46
|
+
x: float,
|
|
47
|
+
y: float,
|
|
48
|
+
delay: float = None,
|
|
49
|
+
button: MouseButton = None,
|
|
50
|
+
clickCount: int = None,
|
|
51
|
+
) -> None:
|
|
52
|
+
await self._channel.send("mouseClick", locals_to_params(locals()))
|
|
53
|
+
|
|
54
|
+
async def dblclick(
|
|
55
|
+
self, x: float, y: float, delay: float = None, button: MouseButton = None
|
|
56
|
+
) -> None:
|
|
57
|
+
await self.click(x, y, delay=delay, button=button, clickCount=2)
|
|
58
|
+
|
|
59
|
+
async def wheel(self, deltaX: float, deltaY: float) -> None:
|
|
60
|
+
await self._channel.send("mouseWheel", locals_to_params(locals()))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class Touchscreen:
|
|
64
|
+
|
|
65
|
+
def __init__(self, channel: Channel) -> None:
|
|
66
|
+
self._channel = channel
|
|
67
|
+
self._loop = channel._connection._loop
|
|
68
|
+
self._dispatcher_fiber = channel._connection._dispatcher_fiber
|
|
69
|
+
|
|
70
|
+
async def tap(self, x: float, y: float) -> None:
|
|
71
|
+
await self._channel.send("touchscreenTap", locals_to_params(locals()))
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import collections.abc
|
|
2
|
+
import datetime
|
|
3
|
+
import math
|
|
4
|
+
import traceback
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
|
7
|
+
from urllib.parse import ParseResult, urlparse, urlunparse
|
|
8
|
+
from patchright._impl._connection import Channel, ChannelOwner, from_channel
|
|
9
|
+
from patchright._impl._errors import Error, is_target_closed_error
|
|
10
|
+
from patchright._impl._map import Map
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from patchright._impl._element_handle import ElementHandle
|
|
14
|
+
Serializable = Any
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class VisitorInfo:
|
|
18
|
+
visited: Map[Any, int]
|
|
19
|
+
last_id: int
|
|
20
|
+
|
|
21
|
+
def __init__(self) -> None:
|
|
22
|
+
self.visited = Map()
|
|
23
|
+
self.last_id = 0
|
|
24
|
+
|
|
25
|
+
def visit(self, obj: Any) -> int:
|
|
26
|
+
assert obj not in self.visited
|
|
27
|
+
self.last_id += 1
|
|
28
|
+
self.visited[obj] = self.last_id
|
|
29
|
+
return self.last_id
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class JSHandle(ChannelOwner):
|
|
33
|
+
|
|
34
|
+
def __init__(
|
|
35
|
+
self, parent: ChannelOwner, type: str, guid: str, initializer: Dict
|
|
36
|
+
) -> None:
|
|
37
|
+
super().__init__(parent, type, guid, initializer)
|
|
38
|
+
self._preview = self._initializer["preview"]
|
|
39
|
+
self._channel.on(
|
|
40
|
+
"previewUpdated", lambda params: self._on_preview_updated(params["preview"])
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def __repr__(self) -> str:
|
|
44
|
+
return f"<JSHandle preview={self._preview}>"
|
|
45
|
+
|
|
46
|
+
def __str__(self) -> str:
|
|
47
|
+
return self._preview
|
|
48
|
+
|
|
49
|
+
def _on_preview_updated(self, preview: str) -> None:
|
|
50
|
+
self._preview = preview
|
|
51
|
+
|
|
52
|
+
async def evaluate(self, expression: str, arg: Serializable = None) -> Any:
|
|
53
|
+
return parse_result(
|
|
54
|
+
await self._channel.send(
|
|
55
|
+
"evaluateExpression",
|
|
56
|
+
dict(expression=expression, arg=serialize_argument(arg)),
|
|
57
|
+
)
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
async def evaluate_handle(
|
|
61
|
+
self, expression: str, arg: Serializable = None
|
|
62
|
+
) -> "JSHandle":
|
|
63
|
+
return from_channel(
|
|
64
|
+
await self._channel.send(
|
|
65
|
+
"evaluateExpressionHandle",
|
|
66
|
+
dict(expression=expression, arg=serialize_argument(arg)),
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
async def get_property(self, propertyName: str) -> "JSHandle":
|
|
71
|
+
return from_channel(
|
|
72
|
+
await self._channel.send("getProperty", dict(name=propertyName))
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
async def get_properties(self) -> Dict[str, "JSHandle"]:
|
|
76
|
+
return {
|
|
77
|
+
prop["name"]: from_channel(prop["value"])
|
|
78
|
+
for prop in await self._channel.send("getPropertyList")
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
def as_element(self) -> Optional["ElementHandle"]:
|
|
82
|
+
return None
|
|
83
|
+
|
|
84
|
+
async def dispose(self) -> None:
|
|
85
|
+
try:
|
|
86
|
+
await self._channel.send("dispose")
|
|
87
|
+
except Exception as e:
|
|
88
|
+
if not is_target_closed_error(e):
|
|
89
|
+
raise e
|
|
90
|
+
|
|
91
|
+
async def json_value(self) -> Any:
|
|
92
|
+
return parse_result(await self._channel.send("jsonValue"))
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def serialize_value(
|
|
96
|
+
value: Any, handles: List[Channel], visitor_info: Optional[VisitorInfo] = None
|
|
97
|
+
) -> Any:
|
|
98
|
+
if visitor_info is None:
|
|
99
|
+
visitor_info = VisitorInfo()
|
|
100
|
+
if isinstance(value, JSHandle):
|
|
101
|
+
h = len(handles)
|
|
102
|
+
handles.append(value._channel)
|
|
103
|
+
return dict(h=h)
|
|
104
|
+
if value is None:
|
|
105
|
+
return dict(v="null")
|
|
106
|
+
if isinstance(value, float):
|
|
107
|
+
if value == float("inf"):
|
|
108
|
+
return dict(v="Infinity")
|
|
109
|
+
if value == float("-inf"):
|
|
110
|
+
return dict(v="-Infinity")
|
|
111
|
+
if value == float("-0"):
|
|
112
|
+
return dict(v="-0")
|
|
113
|
+
if math.isnan(value):
|
|
114
|
+
return dict(v="NaN")
|
|
115
|
+
if isinstance(value, datetime.datetime):
|
|
116
|
+
return {
|
|
117
|
+
"d": datetime.datetime.strftime(
|
|
118
|
+
value.astimezone(datetime.timezone.utc), "%Y-%m-%dT%H:%M:%S.%fZ"
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
if isinstance(value, Exception):
|
|
122
|
+
return {
|
|
123
|
+
"e": {
|
|
124
|
+
"m": str(value),
|
|
125
|
+
"n": (
|
|
126
|
+
value.name or ""
|
|
127
|
+
if isinstance(value, Error)
|
|
128
|
+
else value.__class__.__name__
|
|
129
|
+
),
|
|
130
|
+
"s": (
|
|
131
|
+
value.stack or ""
|
|
132
|
+
if isinstance(value, Error)
|
|
133
|
+
else "".join(
|
|
134
|
+
traceback.format_exception(type(value), value=value, tb=None)
|
|
135
|
+
)
|
|
136
|
+
),
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if isinstance(value, bool):
|
|
140
|
+
return {"b": value}
|
|
141
|
+
if isinstance(value, (int, float)):
|
|
142
|
+
return {"n": value}
|
|
143
|
+
if isinstance(value, str):
|
|
144
|
+
return {"s": value}
|
|
145
|
+
if isinstance(value, ParseResult):
|
|
146
|
+
return {"u": urlunparse(value)}
|
|
147
|
+
if value in visitor_info.visited:
|
|
148
|
+
return dict(ref=visitor_info.visited[value])
|
|
149
|
+
if isinstance(value, collections.abc.Sequence) and (not isinstance(value, str)):
|
|
150
|
+
id = visitor_info.visit(value)
|
|
151
|
+
a = []
|
|
152
|
+
for e in value:
|
|
153
|
+
a.append(serialize_value(e, handles, visitor_info))
|
|
154
|
+
return dict(a=a, id=id)
|
|
155
|
+
if isinstance(value, dict):
|
|
156
|
+
id = visitor_info.visit(value)
|
|
157
|
+
o = []
|
|
158
|
+
for name in value:
|
|
159
|
+
o.append(
|
|
160
|
+
{"k": name, "v": serialize_value(value[name], handles, visitor_info)}
|
|
161
|
+
)
|
|
162
|
+
return dict(o=o, id=id)
|
|
163
|
+
return dict(v="undefined")
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def serialize_argument(arg: Serializable = None) -> Any:
|
|
167
|
+
handles: List[Channel] = []
|
|
168
|
+
value = serialize_value(arg, handles)
|
|
169
|
+
return dict(value=value, handles=handles)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def parse_value(value: Any, refs: Optional[Dict[int, Any]] = None) -> Any:
|
|
173
|
+
if refs is None:
|
|
174
|
+
refs = {}
|
|
175
|
+
if value is None:
|
|
176
|
+
return None
|
|
177
|
+
if isinstance(value, dict):
|
|
178
|
+
if "ref" in value:
|
|
179
|
+
return refs[value["ref"]]
|
|
180
|
+
if "v" in value:
|
|
181
|
+
v = value["v"]
|
|
182
|
+
if v == "Infinity":
|
|
183
|
+
return float("inf")
|
|
184
|
+
if v == "-Infinity":
|
|
185
|
+
return float("-inf")
|
|
186
|
+
if v == "-0":
|
|
187
|
+
return float("-0")
|
|
188
|
+
if v == "NaN":
|
|
189
|
+
return float("nan")
|
|
190
|
+
if v == "undefined":
|
|
191
|
+
return None
|
|
192
|
+
if v == "null":
|
|
193
|
+
return None
|
|
194
|
+
return v
|
|
195
|
+
if "u" in value:
|
|
196
|
+
return urlparse(value["u"])
|
|
197
|
+
if "bi" in value:
|
|
198
|
+
return int(value["bi"])
|
|
199
|
+
if "e" in value:
|
|
200
|
+
error = Error(value["e"]["m"])
|
|
201
|
+
error._name = value["e"]["n"]
|
|
202
|
+
error._stack = value["e"]["s"]
|
|
203
|
+
return error
|
|
204
|
+
if "a" in value:
|
|
205
|
+
a: List = []
|
|
206
|
+
refs[value["id"]] = a
|
|
207
|
+
for e in value["a"]:
|
|
208
|
+
a.append(parse_value(e, refs))
|
|
209
|
+
return a
|
|
210
|
+
if "d" in value:
|
|
211
|
+
return datetime.datetime.strptime(
|
|
212
|
+
value["d"], "%Y-%m-%dT%H:%M:%S.%fZ"
|
|
213
|
+
).replace(tzinfo=datetime.timezone.utc)
|
|
214
|
+
if "o" in value:
|
|
215
|
+
o: Dict = {}
|
|
216
|
+
refs[value["id"]] = o
|
|
217
|
+
for e in value["o"]:
|
|
218
|
+
o[e["k"]] = parse_value(e["v"], refs)
|
|
219
|
+
return o
|
|
220
|
+
if "n" in value:
|
|
221
|
+
return value["n"]
|
|
222
|
+
if "s" in value:
|
|
223
|
+
return value["s"]
|
|
224
|
+
if "b" in value:
|
|
225
|
+
return value["b"]
|
|
226
|
+
return value
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def parse_result(result: Any) -> Any:
|
|
230
|
+
return parse_value(result)
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def add_source_url_to_script(source: str, path: Union[str, Path]) -> str:
|
|
234
|
+
return source
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from typing import Dict, Optional, cast
|
|
3
|
+
from pyee.asyncio import AsyncIOEventEmitter
|
|
4
|
+
from patchright._impl._connection import Channel
|
|
5
|
+
from patchright._impl._errors import TargetClosedError
|
|
6
|
+
from patchright._impl._helper import Error, ParsedMessagePayload
|
|
7
|
+
from patchright._impl._transport import Transport
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class JsonPipeTransport(AsyncIOEventEmitter, Transport):
|
|
11
|
+
|
|
12
|
+
def __init__(self, loop: asyncio.AbstractEventLoop, pipe_channel: Channel) -> None:
|
|
13
|
+
super().__init__(loop)
|
|
14
|
+
Transport.__init__(self, loop)
|
|
15
|
+
self._stop_requested = False
|
|
16
|
+
self._pipe_channel = pipe_channel
|
|
17
|
+
|
|
18
|
+
def request_stop(self) -> None:
|
|
19
|
+
self._stop_requested = True
|
|
20
|
+
self._pipe_channel.send_no_reply("close", {})
|
|
21
|
+
|
|
22
|
+
def dispose(self) -> None:
|
|
23
|
+
self.on_error_future.cancel()
|
|
24
|
+
self._stopped_future.cancel()
|
|
25
|
+
|
|
26
|
+
async def wait_until_stopped(self) -> None:
|
|
27
|
+
await self._stopped_future
|
|
28
|
+
|
|
29
|
+
async def connect(self) -> None:
|
|
30
|
+
self._stopped_future: asyncio.Future = asyncio.Future()
|
|
31
|
+
|
|
32
|
+
def handle_message(message: Dict) -> None:
|
|
33
|
+
if self._stop_requested:
|
|
34
|
+
return
|
|
35
|
+
self.on_message(cast(ParsedMessagePayload, message))
|
|
36
|
+
|
|
37
|
+
def handle_closed(reason: Optional[str]) -> None:
|
|
38
|
+
self.emit("close", reason)
|
|
39
|
+
if reason:
|
|
40
|
+
self.on_error_future.set_exception(TargetClosedError(reason))
|
|
41
|
+
self._stopped_future.set_result(None)
|
|
42
|
+
|
|
43
|
+
self._pipe_channel.on(
|
|
44
|
+
"message", lambda params: handle_message(params["message"])
|
|
45
|
+
)
|
|
46
|
+
self._pipe_channel.on(
|
|
47
|
+
"closed", lambda params: handle_closed(params.get("reason"))
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
async def run(self) -> None:
|
|
51
|
+
await self._stopped_future
|
|
52
|
+
|
|
53
|
+
def send(self, message: Dict) -> None:
|
|
54
|
+
if self._stop_requested:
|
|
55
|
+
raise Error("Playwright connection closed")
|
|
56
|
+
self._pipe_channel.send_no_reply("send", {"message": message})
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
from typing import Dict, List, Optional, cast
|
|
3
|
+
from patchright._impl._api_structures import HeadersArray
|
|
4
|
+
from patchright._impl._connection import ChannelOwner, StackFrame
|
|
5
|
+
from patchright._impl._helper import HarLookupResult, locals_to_params
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class LocalUtils(ChannelOwner):
|
|
9
|
+
|
|
10
|
+
def __init__(
|
|
11
|
+
self, parent: ChannelOwner, type: str, guid: str, initializer: Dict
|
|
12
|
+
) -> None:
|
|
13
|
+
super().__init__(parent, type, guid, initializer)
|
|
14
|
+
self.mark_as_internal_type()
|
|
15
|
+
self.devices = {
|
|
16
|
+
device["name"]: parse_device_descriptor(device["descriptor"])
|
|
17
|
+
for device in initializer["deviceDescriptors"]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async def zip(self, params: Dict) -> None:
|
|
21
|
+
await self._channel.send("zip", params)
|
|
22
|
+
|
|
23
|
+
async def har_open(self, file: str) -> None:
|
|
24
|
+
params = locals_to_params(locals())
|
|
25
|
+
await self._channel.send("harOpen", params)
|
|
26
|
+
|
|
27
|
+
async def har_lookup(
|
|
28
|
+
self,
|
|
29
|
+
harId: str,
|
|
30
|
+
url: str,
|
|
31
|
+
method: str,
|
|
32
|
+
headers: HeadersArray,
|
|
33
|
+
isNavigationRequest: bool,
|
|
34
|
+
postData: Optional[bytes] = None,
|
|
35
|
+
) -> HarLookupResult:
|
|
36
|
+
params = locals_to_params(locals())
|
|
37
|
+
if "postData" in params:
|
|
38
|
+
params["postData"] = base64.b64encode(params["postData"]).decode()
|
|
39
|
+
return cast(
|
|
40
|
+
HarLookupResult,
|
|
41
|
+
await self._channel.send_return_as_dict("harLookup", params),
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
async def har_close(self, harId: str) -> None:
|
|
45
|
+
params = locals_to_params(locals())
|
|
46
|
+
await self._channel.send("harClose", params)
|
|
47
|
+
|
|
48
|
+
async def har_unzip(self, zipFile: str, harFile: str) -> None:
|
|
49
|
+
params = locals_to_params(locals())
|
|
50
|
+
await self._channel.send("harUnzip", params)
|
|
51
|
+
|
|
52
|
+
async def tracing_started(self, tracesDir: Optional[str], traceName: str) -> str:
|
|
53
|
+
params = locals_to_params(locals())
|
|
54
|
+
return await self._channel.send("tracingStarted", params)
|
|
55
|
+
|
|
56
|
+
async def trace_discarded(self, stacks_id: str) -> None:
|
|
57
|
+
return await self._channel.send("traceDiscarded", {"stacksId": stacks_id})
|
|
58
|
+
|
|
59
|
+
def add_stack_to_tracing_no_reply(self, id: int, frames: List[StackFrame]) -> None:
|
|
60
|
+
self._channel.send_no_reply(
|
|
61
|
+
"addStackToTracingNoReply", {"callData": {"stack": frames, "id": id}}
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def parse_device_descriptor(dict: Dict) -> Dict:
|
|
66
|
+
return {
|
|
67
|
+
"user_agent": dict["userAgent"],
|
|
68
|
+
"viewport": dict["viewport"],
|
|
69
|
+
"device_scale_factor": dict["deviceScaleFactor"],
|
|
70
|
+
"is_mobile": dict["isMobile"],
|
|
71
|
+
"has_touch": dict["hasTouch"],
|
|
72
|
+
"default_browser_type": dict["defaultBrowserType"],
|
|
73
|
+
}
|