pure-patchright 1.52.5__py3-none-any.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.
Files changed (381) hide show
  1. patchright/__init__.py +5 -0
  2. patchright/__main__.py +18 -0
  3. patchright/_impl/__init__.py +0 -0
  4. patchright/_impl/__pyinstaller/__init__.py +20 -0
  5. patchright/_impl/__pyinstaller/hook-playwright.async_api.py +3 -0
  6. patchright/_impl/__pyinstaller/hook-playwright.sync_api.py +3 -0
  7. patchright/_impl/_accessibility.py +50 -0
  8. patchright/_impl/_api_structures.py +277 -0
  9. patchright/_impl/_artifact.py +45 -0
  10. patchright/_impl/_assertions.py +867 -0
  11. patchright/_impl/_async_base.py +92 -0
  12. patchright/_impl/_browser.py +248 -0
  13. patchright/_impl/_browser_context.py +743 -0
  14. patchright/_impl/_browser_type.py +276 -0
  15. patchright/_impl/_cdp_session.py +21 -0
  16. patchright/_impl/_clock.py +57 -0
  17. patchright/_impl/_connection.py +562 -0
  18. patchright/_impl/_console_message.py +45 -0
  19. patchright/_impl/_dialog.py +40 -0
  20. patchright/_impl/_download.py +50 -0
  21. patchright/_impl/_driver.py +24 -0
  22. patchright/_impl/_element_handle.py +376 -0
  23. patchright/_impl/_errors.py +44 -0
  24. patchright/_impl/_event_context_manager.py +20 -0
  25. patchright/_impl/_fetch.py +518 -0
  26. patchright/_impl/_file_chooser.py +43 -0
  27. patchright/_impl/_frame.py +779 -0
  28. patchright/_impl/_glob.py +46 -0
  29. patchright/_impl/_greenlets.py +39 -0
  30. patchright/_impl/_har_router.py +99 -0
  31. patchright/_impl/_helper.py +481 -0
  32. patchright/_impl/_impl_to_api_mapping.py +123 -0
  33. patchright/_impl/_input.py +71 -0
  34. patchright/_impl/_js_handle.py +300 -0
  35. patchright/_impl/_json_pipe.py +56 -0
  36. patchright/_impl/_local_utils.py +73 -0
  37. patchright/_impl/_locator.py +814 -0
  38. patchright/_impl/_map.py +19 -0
  39. patchright/_impl/_network.py +958 -0
  40. patchright/_impl/_object_factory.py +91 -0
  41. patchright/_impl/_page.py +1485 -0
  42. patchright/_impl/_path_utils.py +11 -0
  43. patchright/_impl/_playwright.py +51 -0
  44. patchright/_impl/_selectors.py +62 -0
  45. patchright/_impl/_set_input_files_helpers.py +135 -0
  46. patchright/_impl/_str_utils.py +57 -0
  47. patchright/_impl/_stream.py +32 -0
  48. patchright/_impl/_sync_base.py +134 -0
  49. patchright/_impl/_tracing.py +110 -0
  50. patchright/_impl/_transport.py +150 -0
  51. patchright/_impl/_video.py +57 -0
  52. patchright/_impl/_waiter.py +142 -0
  53. patchright/_impl/_web_error.py +27 -0
  54. patchright/_impl/_writable_stream.py +27 -0
  55. patchright/_repo_version.py +1 -0
  56. patchright/async_api/__init__.py +179 -0
  57. patchright/async_api/_context_manager.py +39 -0
  58. patchright/async_api/_generated.py +20416 -0
  59. patchright/driver/README.md +1 -0
  60. patchright/driver/package/README.md +3 -0
  61. patchright/driver/package/ThirdPartyNotices.txt +1560 -0
  62. patchright/driver/package/bin/install_media_pack.ps1 +5 -0
  63. patchright/driver/package/bin/reinstall_chrome_beta_linux.sh +42 -0
  64. patchright/driver/package/bin/reinstall_chrome_beta_mac.sh +13 -0
  65. patchright/driver/package/bin/reinstall_chrome_beta_win.ps1 +24 -0
  66. patchright/driver/package/bin/reinstall_chrome_stable_linux.sh +42 -0
  67. patchright/driver/package/bin/reinstall_chrome_stable_mac.sh +12 -0
  68. patchright/driver/package/bin/reinstall_chrome_stable_win.ps1 +24 -0
  69. patchright/driver/package/bin/reinstall_msedge_beta_linux.sh +48 -0
  70. patchright/driver/package/bin/reinstall_msedge_beta_mac.sh +11 -0
  71. patchright/driver/package/bin/reinstall_msedge_beta_win.ps1 +23 -0
  72. patchright/driver/package/bin/reinstall_msedge_dev_linux.sh +48 -0
  73. patchright/driver/package/bin/reinstall_msedge_dev_mac.sh +11 -0
  74. patchright/driver/package/bin/reinstall_msedge_dev_win.ps1 +23 -0
  75. patchright/driver/package/bin/reinstall_msedge_stable_linux.sh +48 -0
  76. patchright/driver/package/bin/reinstall_msedge_stable_mac.sh +11 -0
  77. patchright/driver/package/bin/reinstall_msedge_stable_win.ps1 +24 -0
  78. patchright/driver/package/browsers.json +80 -0
  79. patchright/driver/package/cli.js +18 -0
  80. patchright/driver/package/index.js +32 -0
  81. patchright/driver/package/index.mjs +28 -0
  82. patchright/driver/package/lib/androidServerImpl.js +63 -0
  83. patchright/driver/package/lib/browserServerImpl.js +88 -0
  84. patchright/driver/package/lib/cli/driver.js +97 -0
  85. patchright/driver/package/lib/cli/program.js +567 -0
  86. patchright/driver/package/lib/cli/programWithTestStub.js +74 -0
  87. patchright/driver/package/lib/client/accessibility.js +49 -0
  88. patchright/driver/package/lib/client/android.js +365 -0
  89. patchright/driver/package/lib/client/api.js +137 -0
  90. patchright/driver/package/lib/client/artifact.js +79 -0
  91. patchright/driver/package/lib/client/browser.js +136 -0
  92. patchright/driver/package/lib/client/browserContext.js +539 -0
  93. patchright/driver/package/lib/client/browserType.js +193 -0
  94. patchright/driver/package/lib/client/cdpSession.js +51 -0
  95. patchright/driver/package/lib/client/channelOwner.js +205 -0
  96. patchright/driver/package/lib/client/clientHelper.js +64 -0
  97. patchright/driver/package/lib/client/clientInstrumentation.js +55 -0
  98. patchright/driver/package/lib/client/clientStackTrace.js +69 -0
  99. patchright/driver/package/lib/client/clock.js +68 -0
  100. patchright/driver/package/lib/client/connection.js +318 -0
  101. patchright/driver/package/lib/client/consoleMessage.js +55 -0
  102. patchright/driver/package/lib/client/coverage.js +44 -0
  103. patchright/driver/package/lib/client/dialog.js +56 -0
  104. patchright/driver/package/lib/client/download.js +62 -0
  105. patchright/driver/package/lib/client/electron.js +133 -0
  106. patchright/driver/package/lib/client/elementHandle.js +284 -0
  107. patchright/driver/package/lib/client/errors.js +77 -0
  108. patchright/driver/package/lib/client/eventEmitter.js +314 -0
  109. patchright/driver/package/lib/client/events.js +98 -0
  110. patchright/driver/package/lib/client/fetch.js +367 -0
  111. patchright/driver/package/lib/client/fileChooser.js +46 -0
  112. patchright/driver/package/lib/client/fileUtils.js +34 -0
  113. patchright/driver/package/lib/client/frame.js +386 -0
  114. patchright/driver/package/lib/client/harRouter.js +87 -0
  115. patchright/driver/package/lib/client/input.js +82 -0
  116. patchright/driver/package/lib/client/jsHandle.js +105 -0
  117. patchright/driver/package/lib/client/jsonPipe.js +39 -0
  118. patchright/driver/package/lib/client/localUtils.js +61 -0
  119. patchright/driver/package/lib/client/locator.js +362 -0
  120. patchright/driver/package/lib/client/network.js +751 -0
  121. patchright/driver/package/lib/client/page.js +709 -0
  122. patchright/driver/package/lib/client/platform.js +74 -0
  123. patchright/driver/package/lib/client/playwright.js +85 -0
  124. patchright/driver/package/lib/client/selectors.js +75 -0
  125. patchright/driver/package/lib/client/stream.js +39 -0
  126. patchright/driver/package/lib/client/timeoutSettings.js +75 -0
  127. patchright/driver/package/lib/client/tracing.js +114 -0
  128. patchright/driver/package/lib/client/types.js +28 -0
  129. patchright/driver/package/lib/client/video.js +59 -0
  130. patchright/driver/package/lib/client/waiter.js +142 -0
  131. patchright/driver/package/lib/client/webError.js +39 -0
  132. patchright/driver/package/lib/client/webSocket.js +111 -0
  133. patchright/driver/package/lib/client/worker.js +63 -0
  134. patchright/driver/package/lib/client/writableStream.js +39 -0
  135. patchright/driver/package/lib/generated/clockSource.js +28 -0
  136. patchright/driver/package/lib/generated/consoleApiSource.js +28 -0
  137. patchright/driver/package/lib/generated/injectedScriptSource.js +28 -0
  138. patchright/driver/package/lib/generated/pollingRecorderSource.js +28 -0
  139. patchright/driver/package/lib/generated/utilityScriptSource.js +28 -0
  140. patchright/driver/package/lib/generated/webSocketMockSource.js +374 -0
  141. patchright/driver/package/lib/inProcessFactory.js +59 -0
  142. patchright/driver/package/lib/inprocess.js +3 -0
  143. patchright/driver/package/lib/outofprocess.js +78 -0
  144. patchright/driver/package/lib/protocol/debug.js +211 -0
  145. patchright/driver/package/lib/protocol/serializers.js +192 -0
  146. patchright/driver/package/lib/protocol/validator.js +2832 -0
  147. patchright/driver/package/lib/protocol/validatorPrimitives.js +179 -0
  148. patchright/driver/package/lib/remote/playwrightConnection.js +266 -0
  149. patchright/driver/package/lib/remote/playwrightServer.js +139 -0
  150. patchright/driver/package/lib/server/accessibility.js +69 -0
  151. patchright/driver/package/lib/server/android/android.js +451 -0
  152. patchright/driver/package/lib/server/android/backendAdb.js +179 -0
  153. patchright/driver/package/lib/server/artifact.js +127 -0
  154. patchright/driver/package/lib/server/bidi/bidiBrowser.js +380 -0
  155. patchright/driver/package/lib/server/bidi/bidiChromium.js +152 -0
  156. patchright/driver/package/lib/server/bidi/bidiConnection.js +187 -0
  157. patchright/driver/package/lib/server/bidi/bidiExecutionContext.js +220 -0
  158. patchright/driver/package/lib/server/bidi/bidiFirefox.js +112 -0
  159. patchright/driver/package/lib/server/bidi/bidiInput.js +146 -0
  160. patchright/driver/package/lib/server/bidi/bidiNetworkManager.js +320 -0
  161. patchright/driver/package/lib/server/bidi/bidiOverCdp.js +102 -0
  162. patchright/driver/package/lib/server/bidi/bidiPage.js +530 -0
  163. patchright/driver/package/lib/server/bidi/bidiPdf.js +106 -0
  164. patchright/driver/package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
  165. patchright/driver/package/lib/server/bidi/third_party/bidiDeserializer.js +98 -0
  166. patchright/driver/package/lib/server/bidi/third_party/bidiKeyboard.js +256 -0
  167. patchright/driver/package/lib/server/bidi/third_party/bidiProtocol.js +152 -0
  168. patchright/driver/package/lib/server/bidi/third_party/bidiSerializer.js +148 -0
  169. patchright/driver/package/lib/server/bidi/third_party/firefoxPrefs.js +259 -0
  170. patchright/driver/package/lib/server/browser.js +140 -0
  171. patchright/driver/package/lib/server/browserContext.js +646 -0
  172. patchright/driver/package/lib/server/browserType.js +326 -0
  173. patchright/driver/package/lib/server/callLog.js +82 -0
  174. patchright/driver/package/lib/server/chromium/appIcon.png +0 -0
  175. patchright/driver/package/lib/server/chromium/chromium.js +376 -0
  176. patchright/driver/package/lib/server/chromium/chromiumSwitches.js +89 -0
  177. patchright/driver/package/lib/server/chromium/crAccessibility.js +263 -0
  178. patchright/driver/package/lib/server/chromium/crBrowser.js +503 -0
  179. patchright/driver/package/lib/server/chromium/crConnection.js +203 -0
  180. patchright/driver/package/lib/server/chromium/crCoverage.js +232 -0
  181. patchright/driver/package/lib/server/chromium/crDevTools.js +112 -0
  182. patchright/driver/package/lib/server/chromium/crDragDrop.js +126 -0
  183. patchright/driver/package/lib/server/chromium/crExecutionContext.js +145 -0
  184. patchright/driver/package/lib/server/chromium/crInput.js +184 -0
  185. patchright/driver/package/lib/server/chromium/crNetworkManager.js +742 -0
  186. patchright/driver/package/lib/server/chromium/crPage.js +1134 -0
  187. patchright/driver/package/lib/server/chromium/crPdf.js +121 -0
  188. patchright/driver/package/lib/server/chromium/crProtocolHelper.js +145 -0
  189. patchright/driver/package/lib/server/chromium/crServiceWorker.js +126 -0
  190. patchright/driver/package/lib/server/chromium/defaultFontFamilies.js +162 -0
  191. patchright/driver/package/lib/server/chromium/protocol.d.js +16 -0
  192. patchright/driver/package/lib/server/chromium/videoRecorder.js +121 -0
  193. patchright/driver/package/lib/server/clock.js +145 -0
  194. patchright/driver/package/lib/server/codegen/csharp.js +329 -0
  195. patchright/driver/package/lib/server/codegen/java.js +270 -0
  196. patchright/driver/package/lib/server/codegen/javascript.js +268 -0
  197. patchright/driver/package/lib/server/codegen/jsonl.js +51 -0
  198. patchright/driver/package/lib/server/codegen/language.js +111 -0
  199. patchright/driver/package/lib/server/codegen/languages.js +68 -0
  200. patchright/driver/package/lib/server/codegen/python.js +277 -0
  201. patchright/driver/package/lib/server/codegen/types.js +16 -0
  202. patchright/driver/package/lib/server/console.js +53 -0
  203. patchright/driver/package/lib/server/cookieStore.js +204 -0
  204. patchright/driver/package/lib/server/debugController.js +185 -0
  205. patchright/driver/package/lib/server/debugger.js +136 -0
  206. patchright/driver/package/lib/server/deviceDescriptors.js +39 -0
  207. patchright/driver/package/lib/server/deviceDescriptorsSource.json +1669 -0
  208. patchright/driver/package/lib/server/dialog.js +72 -0
  209. patchright/driver/package/lib/server/dispatchers/androidDispatcher.js +293 -0
  210. patchright/driver/package/lib/server/dispatchers/artifactDispatcher.js +118 -0
  211. patchright/driver/package/lib/server/dispatchers/browserContextDispatcher.js +328 -0
  212. patchright/driver/package/lib/server/dispatchers/browserDispatcher.js +151 -0
  213. patchright/driver/package/lib/server/dispatchers/browserTypeDispatcher.js +55 -0
  214. patchright/driver/package/lib/server/dispatchers/cdpSessionDispatcher.js +44 -0
  215. patchright/driver/package/lib/server/dispatchers/debugControllerDispatcher.js +87 -0
  216. patchright/driver/package/lib/server/dispatchers/dialogDispatcher.js +47 -0
  217. patchright/driver/package/lib/server/dispatchers/dispatcher.js +346 -0
  218. patchright/driver/package/lib/server/dispatchers/electronDispatcher.js +90 -0
  219. patchright/driver/package/lib/server/dispatchers/elementHandlerDispatcher.js +191 -0
  220. patchright/driver/package/lib/server/dispatchers/frameDispatcher.js +230 -0
  221. patchright/driver/package/lib/server/dispatchers/jsHandleDispatcher.js +80 -0
  222. patchright/driver/package/lib/server/dispatchers/jsonPipeDispatcher.js +58 -0
  223. patchright/driver/package/lib/server/dispatchers/localUtilsDispatcher.js +155 -0
  224. patchright/driver/package/lib/server/dispatchers/networkDispatchers.js +204 -0
  225. patchright/driver/package/lib/server/dispatchers/pageDispatcher.js +328 -0
  226. patchright/driver/package/lib/server/dispatchers/playwrightDispatcher.js +100 -0
  227. patchright/driver/package/lib/server/dispatchers/selectorsDispatcher.js +40 -0
  228. patchright/driver/package/lib/server/dispatchers/streamDispatcher.js +60 -0
  229. patchright/driver/package/lib/server/dispatchers/tracingDispatcher.js +59 -0
  230. patchright/driver/package/lib/server/dispatchers/webSocketRouteDispatcher.js +154 -0
  231. patchright/driver/package/lib/server/dispatchers/writableStreamDispatcher.js +73 -0
  232. patchright/driver/package/lib/server/dom.js +869 -0
  233. patchright/driver/package/lib/server/download.js +70 -0
  234. patchright/driver/package/lib/server/electron/electron.js +277 -0
  235. patchright/driver/package/lib/server/electron/loader.js +29 -0
  236. patchright/driver/package/lib/server/errors.js +69 -0
  237. patchright/driver/package/lib/server/fetch.js +640 -0
  238. patchright/driver/package/lib/server/fileChooser.js +43 -0
  239. patchright/driver/package/lib/server/fileUploadUtils.js +84 -0
  240. patchright/driver/package/lib/server/firefox/ffAccessibility.js +238 -0
  241. patchright/driver/package/lib/server/firefox/ffBrowser.js +404 -0
  242. patchright/driver/package/lib/server/firefox/ffConnection.js +147 -0
  243. patchright/driver/package/lib/server/firefox/ffExecutionContext.js +149 -0
  244. patchright/driver/package/lib/server/firefox/ffInput.js +159 -0
  245. patchright/driver/package/lib/server/firefox/ffNetworkManager.js +254 -0
  246. patchright/driver/package/lib/server/firefox/ffPage.js +501 -0
  247. patchright/driver/package/lib/server/firefox/firefox.js +106 -0
  248. patchright/driver/package/lib/server/firefox/protocol.d.js +16 -0
  249. patchright/driver/package/lib/server/formData.js +147 -0
  250. patchright/driver/package/lib/server/frameSelectors.js +274 -0
  251. patchright/driver/package/lib/server/frames.js +1834 -0
  252. patchright/driver/package/lib/server/har/harRecorder.js +147 -0
  253. patchright/driver/package/lib/server/har/harTracer.js +606 -0
  254. patchright/driver/package/lib/server/harBackend.js +157 -0
  255. patchright/driver/package/lib/server/helper.js +100 -0
  256. patchright/driver/package/lib/server/index.js +61 -0
  257. patchright/driver/package/lib/server/input.js +280 -0
  258. patchright/driver/package/lib/server/instrumentation.js +75 -0
  259. patchright/driver/package/lib/server/javascript.js +315 -0
  260. patchright/driver/package/lib/server/launchApp.js +110 -0
  261. patchright/driver/package/lib/server/localUtils.js +211 -0
  262. patchright/driver/package/lib/server/macEditingCommands.js +143 -0
  263. patchright/driver/package/lib/server/network.js +583 -0
  264. patchright/driver/package/lib/server/page.js +775 -0
  265. patchright/driver/package/lib/server/pageBinding.js +88 -0
  266. patchright/driver/package/lib/server/pipeTransport.js +89 -0
  267. patchright/driver/package/lib/server/playwright.js +81 -0
  268. patchright/driver/package/lib/server/progress.js +104 -0
  269. patchright/driver/package/lib/server/protocolError.js +52 -0
  270. patchright/driver/package/lib/server/recorder/chat.js +161 -0
  271. patchright/driver/package/lib/server/recorder/contextRecorder.js +286 -0
  272. patchright/driver/package/lib/server/recorder/recorderApp.js +184 -0
  273. patchright/driver/package/lib/server/recorder/recorderCollection.js +116 -0
  274. patchright/driver/package/lib/server/recorder/recorderFrontend.js +16 -0
  275. patchright/driver/package/lib/server/recorder/recorderRunner.js +135 -0
  276. patchright/driver/package/lib/server/recorder/recorderUtils.js +100 -0
  277. patchright/driver/package/lib/server/recorder/throttledFile.js +57 -0
  278. patchright/driver/package/lib/server/recorder.js +360 -0
  279. patchright/driver/package/lib/server/registry/browserFetcher.js +175 -0
  280. patchright/driver/package/lib/server/registry/dependencies.js +371 -0
  281. patchright/driver/package/lib/server/registry/index.js +1271 -0
  282. patchright/driver/package/lib/server/registry/nativeDeps.js +1105 -0
  283. patchright/driver/package/lib/server/registry/oopDownloadBrowserMain.js +120 -0
  284. patchright/driver/package/lib/server/screenshotter.js +332 -0
  285. patchright/driver/package/lib/server/selectors.js +112 -0
  286. patchright/driver/package/lib/server/socksClientCertificatesInterceptor.js +321 -0
  287. patchright/driver/package/lib/server/socksInterceptor.js +95 -0
  288. patchright/driver/package/lib/server/storageScript.js +154 -0
  289. patchright/driver/package/lib/server/timeoutSettings.js +89 -0
  290. patchright/driver/package/lib/server/trace/recorder/snapshotter.js +143 -0
  291. patchright/driver/package/lib/server/trace/recorder/snapshotterInjected.js +539 -0
  292. patchright/driver/package/lib/server/trace/recorder/tracing.js +593 -0
  293. patchright/driver/package/lib/server/trace/test/inMemorySnapshotter.js +87 -0
  294. patchright/driver/package/lib/server/trace/viewer/traceViewer.js +249 -0
  295. patchright/driver/package/lib/server/transport.js +183 -0
  296. patchright/driver/package/lib/server/types.js +28 -0
  297. patchright/driver/package/lib/server/usKeyboardLayout.js +145 -0
  298. patchright/driver/package/lib/server/utils/ascii.js +44 -0
  299. patchright/driver/package/lib/server/utils/comparators.js +161 -0
  300. patchright/driver/package/lib/server/utils/crypto.js +216 -0
  301. patchright/driver/package/lib/server/utils/debug.js +47 -0
  302. patchright/driver/package/lib/server/utils/debugLogger.js +114 -0
  303. patchright/driver/package/lib/server/utils/env.js +68 -0
  304. patchright/driver/package/lib/server/utils/eventsHelper.js +39 -0
  305. patchright/driver/package/lib/server/utils/expectUtils.js +38 -0
  306. patchright/driver/package/lib/server/utils/fileUtils.js +191 -0
  307. patchright/driver/package/lib/server/utils/happyEyeballs.js +207 -0
  308. patchright/driver/package/lib/server/utils/hostPlatform.js +109 -0
  309. patchright/driver/package/lib/server/utils/httpServer.js +218 -0
  310. patchright/driver/package/lib/server/utils/image_tools/colorUtils.js +89 -0
  311. patchright/driver/package/lib/server/utils/image_tools/compare.js +109 -0
  312. patchright/driver/package/lib/server/utils/image_tools/imageChannel.js +78 -0
  313. patchright/driver/package/lib/server/utils/image_tools/stats.js +102 -0
  314. patchright/driver/package/lib/server/utils/linuxUtils.js +71 -0
  315. patchright/driver/package/lib/server/utils/network.js +217 -0
  316. patchright/driver/package/lib/server/utils/nodePlatform.js +148 -0
  317. patchright/driver/package/lib/server/utils/pipeTransport.js +84 -0
  318. patchright/driver/package/lib/server/utils/processLauncher.js +238 -0
  319. patchright/driver/package/lib/server/utils/profiler.js +65 -0
  320. patchright/driver/package/lib/server/utils/socksProxy.js +511 -0
  321. patchright/driver/package/lib/server/utils/spawnAsync.js +41 -0
  322. patchright/driver/package/lib/server/utils/task.js +51 -0
  323. patchright/driver/package/lib/server/utils/userAgent.js +98 -0
  324. patchright/driver/package/lib/server/utils/wsServer.js +132 -0
  325. patchright/driver/package/lib/server/utils/zipFile.js +74 -0
  326. patchright/driver/package/lib/server/utils/zones.js +57 -0
  327. patchright/driver/package/lib/server/webkit/protocol.d.js +16 -0
  328. patchright/driver/package/lib/server/webkit/webkit.js +100 -0
  329. patchright/driver/package/lib/server/webkit/wkAccessibility.js +237 -0
  330. patchright/driver/package/lib/server/webkit/wkBrowser.js +312 -0
  331. patchright/driver/package/lib/server/webkit/wkConnection.js +149 -0
  332. patchright/driver/package/lib/server/webkit/wkExecutionContext.js +153 -0
  333. patchright/driver/package/lib/server/webkit/wkInput.js +181 -0
  334. patchright/driver/package/lib/server/webkit/wkInterceptableRequest.js +169 -0
  335. patchright/driver/package/lib/server/webkit/wkPage.js +1114 -0
  336. patchright/driver/package/lib/server/webkit/wkProvisionalPage.js +83 -0
  337. patchright/driver/package/lib/server/webkit/wkWorkers.js +104 -0
  338. patchright/driver/package/lib/third_party/pixelmatch.js +255 -0
  339. patchright/driver/package/lib/utils/isomorphic/ariaSnapshot.js +384 -0
  340. patchright/driver/package/lib/utils/isomorphic/assert.js +31 -0
  341. patchright/driver/package/lib/utils/isomorphic/builtins.js +86 -0
  342. patchright/driver/package/lib/utils/isomorphic/colors.js +72 -0
  343. patchright/driver/package/lib/utils/isomorphic/cssParser.js +246 -0
  344. patchright/driver/package/lib/utils/isomorphic/cssTokenizer.js +1051 -0
  345. patchright/driver/package/lib/utils/isomorphic/headers.js +53 -0
  346. patchright/driver/package/lib/utils/isomorphic/locatorGenerators.js +655 -0
  347. patchright/driver/package/lib/utils/isomorphic/locatorParser.js +176 -0
  348. patchright/driver/package/lib/utils/isomorphic/locatorUtils.js +81 -0
  349. patchright/driver/package/lib/utils/isomorphic/manualPromise.js +115 -0
  350. patchright/driver/package/lib/utils/isomorphic/mimeType.js +460 -0
  351. patchright/driver/package/lib/utils/isomorphic/multimap.js +81 -0
  352. patchright/driver/package/lib/utils/isomorphic/rtti.js +43 -0
  353. patchright/driver/package/lib/utils/isomorphic/selectorParser.js +387 -0
  354. patchright/driver/package/lib/utils/isomorphic/semaphore.js +54 -0
  355. patchright/driver/package/lib/utils/isomorphic/stackTrace.js +158 -0
  356. patchright/driver/package/lib/utils/isomorphic/stringUtils.js +176 -0
  357. patchright/driver/package/lib/utils/isomorphic/time.js +44 -0
  358. patchright/driver/package/lib/utils/isomorphic/timeoutRunner.js +67 -0
  359. patchright/driver/package/lib/utils/isomorphic/traceUtils.js +59 -0
  360. patchright/driver/package/lib/utils/isomorphic/types.js +16 -0
  361. patchright/driver/package/lib/utils/isomorphic/urlMatch.js +167 -0
  362. patchright/driver/package/lib/utils/isomorphic/utilityScriptSerializers.js +248 -0
  363. patchright/driver/package/lib/utils.js +101 -0
  364. patchright/driver/package/lib/utilsBundle.js +106 -0
  365. patchright/driver/package/lib/utilsBundleImpl/index.js +208 -0
  366. patchright/driver/package/lib/utilsBundleImpl/xdg-open +1066 -0
  367. patchright/driver/package/lib/zipBundle.js +34 -0
  368. patchright/driver/package/lib/zipBundleImpl.js +5 -0
  369. patchright/driver/package/package.json +44 -0
  370. patchright/driver/package/protocol.yml +3313 -0
  371. patchright/py.typed +0 -0
  372. patchright/sync_api/__init__.py +179 -0
  373. patchright/sync_api/_context_manager.py +74 -0
  374. patchright/sync_api/_generated.py +20632 -0
  375. pure_patchright-1.52.5.dist-info/LICENSE +201 -0
  376. pure_patchright-1.52.5.dist-info/METADATA +96 -0
  377. pure_patchright-1.52.5.dist-info/RECORD +381 -0
  378. pure_patchright-1.52.5.dist-info/WHEEL +4 -0
  379. pure_patchright-1.52.5.dist-info/entry_points.txt +5 -0
  380. pure_patchright-1.52.5.dist-info/licenses/LICENSE +202 -0
  381. pure_patchright-1.52.5.dist-info/top_level.txt +1 -0
@@ -0,0 +1,518 @@
1
+ import base64
2
+ import json
3
+ import pathlib
4
+ import typing
5
+ from pathlib import Path
6
+ from typing import Any, Dict, List, Optional, Union, cast
7
+ import patchright._impl._network as network
8
+ from patchright._impl._api_structures import (
9
+ ClientCertificate,
10
+ FilePayload,
11
+ FormField,
12
+ Headers,
13
+ HttpCredentials,
14
+ ProxySettings,
15
+ ServerFilePayload,
16
+ StorageState,
17
+ )
18
+ from patchright._impl._connection import ChannelOwner, from_channel
19
+ from patchright._impl._errors import is_target_closed_error
20
+ from patchright._impl._helper import (
21
+ Error,
22
+ NameValue,
23
+ TargetClosedError,
24
+ async_readfile,
25
+ async_writefile,
26
+ is_file_payload,
27
+ locals_to_params,
28
+ object_to_array,
29
+ to_impl,
30
+ )
31
+ from patchright._impl._network import serialize_headers, to_client_certificates_protocol
32
+ from patchright._impl._tracing import Tracing
33
+
34
+ if typing.TYPE_CHECKING:
35
+ from patchright._impl._playwright import Playwright
36
+ FormType = Dict[str, Union[bool, float, str]]
37
+ DataType = Union[Any, bytes, str]
38
+ MultipartType = Dict[str, Union[bytes, bool, float, str, FilePayload]]
39
+ ParamsType = Union[Dict[str, Union[bool, float, str]], str]
40
+
41
+
42
+ class APIRequest:
43
+
44
+ def __init__(self, playwright: "Playwright") -> None:
45
+ self.playwright = playwright
46
+ self._loop = playwright._loop
47
+ self._dispatcher_fiber = playwright._connection._dispatcher_fiber
48
+
49
+ async def new_context(
50
+ self,
51
+ baseURL: str = None,
52
+ extraHTTPHeaders: Dict[str, str] = None,
53
+ httpCredentials: HttpCredentials = None,
54
+ ignoreHTTPSErrors: bool = None,
55
+ proxy: ProxySettings = None,
56
+ userAgent: str = None,
57
+ timeout: float = None,
58
+ storageState: Union[StorageState, str, Path] = None,
59
+ clientCertificates: List[ClientCertificate] = None,
60
+ failOnStatusCode: bool = None,
61
+ maxRedirects: int = None,
62
+ ) -> "APIRequestContext":
63
+ params = locals_to_params(locals())
64
+ if "storageState" in params:
65
+ storage_state = params["storageState"]
66
+ if not isinstance(storage_state, dict) and storage_state:
67
+ params["storageState"] = json.loads(
68
+ (await async_readfile(storage_state)).decode()
69
+ )
70
+ if "extraHTTPHeaders" in params:
71
+ params["extraHTTPHeaders"] = serialize_headers(params["extraHTTPHeaders"])
72
+ params["clientCertificates"] = await to_client_certificates_protocol(
73
+ params.get("clientCertificates")
74
+ )
75
+ context = cast(
76
+ APIRequestContext,
77
+ from_channel(await self.playwright._channel.send("newRequest", params)),
78
+ )
79
+ return context
80
+
81
+
82
+ class APIRequestContext(ChannelOwner):
83
+
84
+ def __init__(
85
+ self, parent: ChannelOwner, type: str, guid: str, initializer: Dict
86
+ ) -> None:
87
+ super().__init__(parent, type, guid, initializer)
88
+ self._tracing: Tracing = from_channel(initializer["tracing"])
89
+ self._close_reason: Optional[str] = None
90
+
91
+ async def dispose(self, reason: str = None) -> None:
92
+ self._close_reason = reason
93
+ try:
94
+ await self._channel.send("dispose", {"reason": reason})
95
+ except Error as e:
96
+ if is_target_closed_error(e):
97
+ return
98
+ raise e
99
+ self._tracing._reset_stack_counter()
100
+
101
+ async def delete(
102
+ self,
103
+ url: str,
104
+ params: ParamsType = None,
105
+ headers: Headers = None,
106
+ data: DataType = None,
107
+ form: FormType = None,
108
+ multipart: MultipartType = None,
109
+ timeout: float = None,
110
+ failOnStatusCode: bool = None,
111
+ ignoreHTTPSErrors: bool = None,
112
+ maxRedirects: int = None,
113
+ maxRetries: int = None,
114
+ ) -> "APIResponse":
115
+ return await self.fetch(
116
+ url,
117
+ method="DELETE",
118
+ params=params,
119
+ headers=headers,
120
+ data=data,
121
+ form=form,
122
+ multipart=multipart,
123
+ timeout=timeout,
124
+ failOnStatusCode=failOnStatusCode,
125
+ ignoreHTTPSErrors=ignoreHTTPSErrors,
126
+ maxRedirects=maxRedirects,
127
+ maxRetries=maxRetries,
128
+ )
129
+
130
+ async def head(
131
+ self,
132
+ url: str,
133
+ params: ParamsType = None,
134
+ headers: Headers = None,
135
+ data: DataType = None,
136
+ form: FormType = None,
137
+ multipart: MultipartType = None,
138
+ timeout: float = None,
139
+ failOnStatusCode: bool = None,
140
+ ignoreHTTPSErrors: bool = None,
141
+ maxRedirects: int = None,
142
+ maxRetries: int = None,
143
+ ) -> "APIResponse":
144
+ return await self.fetch(
145
+ url,
146
+ method="HEAD",
147
+ params=params,
148
+ headers=headers,
149
+ data=data,
150
+ form=form,
151
+ multipart=multipart,
152
+ timeout=timeout,
153
+ failOnStatusCode=failOnStatusCode,
154
+ ignoreHTTPSErrors=ignoreHTTPSErrors,
155
+ maxRedirects=maxRedirects,
156
+ maxRetries=maxRetries,
157
+ )
158
+
159
+ async def get(
160
+ self,
161
+ url: str,
162
+ params: ParamsType = None,
163
+ headers: Headers = None,
164
+ data: DataType = None,
165
+ form: FormType = None,
166
+ multipart: MultipartType = None,
167
+ timeout: float = None,
168
+ failOnStatusCode: bool = None,
169
+ ignoreHTTPSErrors: bool = None,
170
+ maxRedirects: int = None,
171
+ maxRetries: int = None,
172
+ ) -> "APIResponse":
173
+ return await self.fetch(
174
+ url,
175
+ method="GET",
176
+ params=params,
177
+ headers=headers,
178
+ data=data,
179
+ form=form,
180
+ multipart=multipart,
181
+ timeout=timeout,
182
+ failOnStatusCode=failOnStatusCode,
183
+ ignoreHTTPSErrors=ignoreHTTPSErrors,
184
+ maxRedirects=maxRedirects,
185
+ maxRetries=maxRetries,
186
+ )
187
+
188
+ async def patch(
189
+ self,
190
+ url: str,
191
+ params: ParamsType = None,
192
+ headers: Headers = None,
193
+ data: DataType = None,
194
+ form: FormType = None,
195
+ multipart: Dict[str, Union[bytes, bool, float, str, FilePayload]] = None,
196
+ timeout: float = None,
197
+ failOnStatusCode: bool = None,
198
+ ignoreHTTPSErrors: bool = None,
199
+ maxRedirects: int = None,
200
+ maxRetries: int = None,
201
+ ) -> "APIResponse":
202
+ return await self.fetch(
203
+ url,
204
+ method="PATCH",
205
+ params=params,
206
+ headers=headers,
207
+ data=data,
208
+ form=form,
209
+ multipart=multipart,
210
+ timeout=timeout,
211
+ failOnStatusCode=failOnStatusCode,
212
+ ignoreHTTPSErrors=ignoreHTTPSErrors,
213
+ maxRedirects=maxRedirects,
214
+ maxRetries=maxRetries,
215
+ )
216
+
217
+ async def put(
218
+ self,
219
+ url: str,
220
+ params: ParamsType = None,
221
+ headers: Headers = None,
222
+ data: DataType = None,
223
+ form: FormType = None,
224
+ multipart: Dict[str, Union[bytes, bool, float, str, FilePayload]] = None,
225
+ timeout: float = None,
226
+ failOnStatusCode: bool = None,
227
+ ignoreHTTPSErrors: bool = None,
228
+ maxRedirects: int = None,
229
+ maxRetries: int = None,
230
+ ) -> "APIResponse":
231
+ return await self.fetch(
232
+ url,
233
+ method="PUT",
234
+ params=params,
235
+ headers=headers,
236
+ data=data,
237
+ form=form,
238
+ multipart=multipart,
239
+ timeout=timeout,
240
+ failOnStatusCode=failOnStatusCode,
241
+ ignoreHTTPSErrors=ignoreHTTPSErrors,
242
+ maxRedirects=maxRedirects,
243
+ maxRetries=maxRetries,
244
+ )
245
+
246
+ async def post(
247
+ self,
248
+ url: str,
249
+ params: ParamsType = None,
250
+ headers: Headers = None,
251
+ data: DataType = None,
252
+ form: FormType = None,
253
+ multipart: Dict[str, Union[bytes, bool, float, str, FilePayload]] = None,
254
+ timeout: float = None,
255
+ failOnStatusCode: bool = None,
256
+ ignoreHTTPSErrors: bool = None,
257
+ maxRedirects: int = None,
258
+ maxRetries: int = None,
259
+ ) -> "APIResponse":
260
+ return await self.fetch(
261
+ url,
262
+ method="POST",
263
+ params=params,
264
+ headers=headers,
265
+ data=data,
266
+ form=form,
267
+ multipart=multipart,
268
+ timeout=timeout,
269
+ failOnStatusCode=failOnStatusCode,
270
+ ignoreHTTPSErrors=ignoreHTTPSErrors,
271
+ maxRedirects=maxRedirects,
272
+ maxRetries=maxRetries,
273
+ )
274
+
275
+ async def fetch(
276
+ self,
277
+ urlOrRequest: Union[str, network.Request],
278
+ params: ParamsType = None,
279
+ method: str = None,
280
+ headers: Headers = None,
281
+ data: DataType = None,
282
+ form: FormType = None,
283
+ multipart: Dict[str, Union[bytes, bool, float, str, FilePayload]] = None,
284
+ timeout: float = None,
285
+ failOnStatusCode: bool = None,
286
+ ignoreHTTPSErrors: bool = None,
287
+ maxRedirects: int = None,
288
+ maxRetries: int = None,
289
+ ) -> "APIResponse":
290
+ url = urlOrRequest if isinstance(urlOrRequest, str) else None
291
+ request = (
292
+ cast(network.Request, to_impl(urlOrRequest))
293
+ if isinstance(to_impl(urlOrRequest), network.Request)
294
+ else None
295
+ )
296
+ assert request or isinstance(
297
+ urlOrRequest, str
298
+ ), "First argument must be either URL string or Request"
299
+ return await self._inner_fetch(
300
+ request,
301
+ url,
302
+ method,
303
+ headers,
304
+ data,
305
+ params,
306
+ form,
307
+ multipart,
308
+ timeout,
309
+ failOnStatusCode,
310
+ ignoreHTTPSErrors,
311
+ maxRedirects,
312
+ maxRetries,
313
+ )
314
+
315
+ async def _inner_fetch(
316
+ self,
317
+ request: Optional[network.Request],
318
+ url: Optional[str],
319
+ method: str = None,
320
+ headers: Headers = None,
321
+ data: DataType = None,
322
+ params: ParamsType = None,
323
+ form: FormType = None,
324
+ multipart: Dict[str, Union[bytes, bool, float, str, FilePayload]] = None,
325
+ timeout: float = None,
326
+ failOnStatusCode: bool = None,
327
+ ignoreHTTPSErrors: bool = None,
328
+ maxRedirects: int = None,
329
+ maxRetries: int = None,
330
+ ) -> "APIResponse":
331
+ if self._close_reason:
332
+ raise TargetClosedError(self._close_reason)
333
+ assert (1 if data else 0) + (1 if form else 0) + (
334
+ 1 if multipart else 0
335
+ ) <= 1, "Only one of 'data', 'form' or 'multipart' can be specified"
336
+ assert (
337
+ maxRedirects is None or maxRedirects >= 0
338
+ ), "'max_redirects' must be greater than or equal to '0'"
339
+ assert (
340
+ maxRetries is None or maxRetries >= 0
341
+ ), "'max_retries' must be greater than or equal to '0'"
342
+ url = url or (request.url if request else url)
343
+ method = method or (request.method if request else "GET")
344
+ headers_obj = headers or (request.headers if request else None)
345
+ serialized_headers = serialize_headers(headers_obj) if headers_obj else None
346
+ json_data: Any = None
347
+ form_data: Optional[List[NameValue]] = None
348
+ multipart_data: Optional[List[FormField]] = None
349
+ post_data_buffer: Optional[bytes] = None
350
+ if data is not None:
351
+ if isinstance(data, str):
352
+ if is_json_content_type(serialized_headers):
353
+ json_data = data if is_json_parsable(data) else json.dumps(data)
354
+ else:
355
+ post_data_buffer = data.encode()
356
+ elif isinstance(data, bytes):
357
+ post_data_buffer = data
358
+ elif isinstance(data, (dict, list, int, bool)):
359
+ json_data = json.dumps(data)
360
+ else:
361
+ raise Error(f"Unsupported 'data' type: {type(data)}")
362
+ elif form:
363
+ form_data = object_to_array(form)
364
+ elif multipart:
365
+ multipart_data = []
366
+ for name, value in multipart.items():
367
+ if is_file_payload(value):
368
+ payload = cast(FilePayload, value)
369
+ assert isinstance(
370
+ payload["buffer"], bytes
371
+ ), f"Unexpected buffer type of 'data.{name}'"
372
+ multipart_data.append(
373
+ FormField(name=name, file=file_payload_to_json(payload))
374
+ )
375
+ elif isinstance(value, str):
376
+ multipart_data.append(FormField(name=name, value=value))
377
+ if (
378
+ post_data_buffer is None
379
+ and json_data is None
380
+ and (form_data is None)
381
+ and (multipart_data is None)
382
+ ):
383
+ post_data_buffer = request.post_data_buffer if request else None
384
+ post_data = (
385
+ base64.b64encode(post_data_buffer).decode() if post_data_buffer else None
386
+ )
387
+ response = await self._channel.send(
388
+ "fetch",
389
+ {
390
+ "url": url,
391
+ "params": object_to_array(params) if isinstance(params, dict) else None,
392
+ "encodedParams": params if isinstance(params, str) else None,
393
+ "method": method,
394
+ "headers": serialized_headers,
395
+ "postData": post_data,
396
+ "jsonData": json_data,
397
+ "formData": form_data,
398
+ "multipartData": multipart_data,
399
+ "timeout": timeout,
400
+ "failOnStatusCode": failOnStatusCode,
401
+ "ignoreHTTPSErrors": ignoreHTTPSErrors,
402
+ "maxRedirects": maxRedirects,
403
+ "maxRetries": maxRetries,
404
+ },
405
+ )
406
+ return APIResponse(self, response)
407
+
408
+ async def storage_state(
409
+ self, path: Union[pathlib.Path, str] = None, indexedDB: bool = None
410
+ ) -> StorageState:
411
+ result = await self._channel.send_return_as_dict(
412
+ "storageState", {"indexedDB": indexedDB}
413
+ )
414
+ if path:
415
+ await async_writefile(path, json.dumps(result))
416
+ return result
417
+
418
+
419
+ def file_payload_to_json(payload: FilePayload) -> ServerFilePayload:
420
+ return ServerFilePayload(
421
+ name=payload["name"],
422
+ mimeType=payload["mimeType"],
423
+ buffer=base64.b64encode(payload["buffer"]).decode(),
424
+ )
425
+
426
+
427
+ class APIResponse:
428
+
429
+ def __init__(self, context: APIRequestContext, initializer: Dict) -> None:
430
+ self._loop = context._loop
431
+ self._dispatcher_fiber = context._connection._dispatcher_fiber
432
+ self._request = context
433
+ self._initializer = initializer
434
+ self._headers = network.RawHeaders(initializer["headers"])
435
+
436
+ def __repr__(self) -> str:
437
+ return f"<APIResponse url={self.url!r} status={self.status!r} status_text={self.status_text!r}>"
438
+
439
+ @property
440
+ def ok(self) -> bool:
441
+ return self.status >= 200 and self.status <= 299
442
+
443
+ @property
444
+ def url(self) -> str:
445
+ return self._initializer["url"]
446
+
447
+ @property
448
+ def status(self) -> int:
449
+ return self._initializer["status"]
450
+
451
+ @property
452
+ def status_text(self) -> str:
453
+ return self._initializer["statusText"]
454
+
455
+ @property
456
+ def headers(self) -> Headers:
457
+ return self._headers.headers()
458
+
459
+ @property
460
+ def headers_array(self) -> network.HeadersArray:
461
+ return self._headers.headers_array()
462
+
463
+ async def body(self) -> bytes:
464
+ try:
465
+ result = await self._request._connection.wrap_api_call(
466
+ lambda: self._request._channel.send_return_as_dict(
467
+ "fetchResponseBody", {"fetchUid": self._fetch_uid}
468
+ ),
469
+ True,
470
+ )
471
+ if result is None:
472
+ raise Error("Response has been disposed")
473
+ return base64.b64decode(result["binary"])
474
+ except Error as exc:
475
+ if is_target_closed_error(exc):
476
+ raise Error("Response has been disposed")
477
+ raise exc
478
+
479
+ async def text(self) -> str:
480
+ content = await self.body()
481
+ return content.decode()
482
+
483
+ async def json(self) -> Any:
484
+ content = await self.text()
485
+ return json.loads(content)
486
+
487
+ async def dispose(self) -> None:
488
+ await self._request._channel.send(
489
+ "disposeAPIResponse", {"fetchUid": self._fetch_uid}
490
+ )
491
+
492
+ @property
493
+ def _fetch_uid(self) -> str:
494
+ return self._initializer["fetchUid"]
495
+
496
+ async def _fetch_log(self) -> List[str]:
497
+ return await self._request._channel.send(
498
+ "fetchLog", {"fetchUid": self._fetch_uid}
499
+ )
500
+
501
+
502
+ def is_json_content_type(headers: network.HeadersArray = None) -> bool:
503
+ if not headers:
504
+ return False
505
+ for header in headers:
506
+ if header["name"] == "Content-Type":
507
+ return header["value"].startswith("application/json")
508
+ return False
509
+
510
+
511
+ def is_json_parsable(value: Any) -> bool:
512
+ if not isinstance(value, str):
513
+ return False
514
+ try:
515
+ json.loads(value)
516
+ return True
517
+ except json.JSONDecodeError:
518
+ return False
@@ -0,0 +1,43 @@
1
+ from pathlib import Path
2
+ from typing import TYPE_CHECKING, Sequence, Union
3
+ from patchright._impl._api_structures import FilePayload
4
+
5
+ if TYPE_CHECKING:
6
+ from patchright._impl._element_handle import ElementHandle
7
+ from patchright._impl._page import Page
8
+
9
+
10
+ class FileChooser:
11
+
12
+ def __init__(
13
+ self, page: "Page", element_handle: "ElementHandle", is_multiple: bool
14
+ ) -> None:
15
+ self._page = page
16
+ self._loop = page._loop
17
+ self._dispatcher_fiber = page._dispatcher_fiber
18
+ self._element_handle = element_handle
19
+ self._is_multiple = is_multiple
20
+
21
+ def __repr__(self) -> str:
22
+ return f"<FileChooser page={self._page} element={self._element_handle}>"
23
+
24
+ @property
25
+ def page(self) -> "Page":
26
+ return self._page
27
+
28
+ @property
29
+ def element(self) -> "ElementHandle":
30
+ return self._element_handle
31
+
32
+ def is_multiple(self) -> bool:
33
+ return self._is_multiple
34
+
35
+ async def set_files(
36
+ self,
37
+ files: Union[
38
+ str, Path, FilePayload, Sequence[Union[str, Path]], Sequence[FilePayload]
39
+ ],
40
+ timeout: float = None,
41
+ noWaitAfter: bool = None,
42
+ ) -> None:
43
+ await self._element_handle.set_input_files(files, timeout, noWaitAfter)