@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,621 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var fetch_exports = {};
|
30
|
+
__export(fetch_exports, {
|
31
|
+
APIRequestContext: () => APIRequestContext,
|
32
|
+
BrowserContextAPIRequestContext: () => BrowserContextAPIRequestContext,
|
33
|
+
GlobalAPIRequestContext: () => GlobalAPIRequestContext
|
34
|
+
});
|
35
|
+
module.exports = __toCommonJS(fetch_exports);
|
36
|
+
var import_http = __toESM(require("http"));
|
37
|
+
var import_https = __toESM(require("https"));
|
38
|
+
var import_stream = require("stream");
|
39
|
+
var import_tls = require("tls");
|
40
|
+
var zlib = __toESM(require("zlib"));
|
41
|
+
var import_utils = require("../utils");
|
42
|
+
var import_crypto = require("./utils/crypto");
|
43
|
+
var import_userAgent = require("./utils/userAgent");
|
44
|
+
var import_browserContext = require("./browserContext");
|
45
|
+
var import_cookieStore = require("./cookieStore");
|
46
|
+
var import_formData = require("./formData");
|
47
|
+
var import_instrumentation = require("./instrumentation");
|
48
|
+
var import_progress = require("./progress");
|
49
|
+
var import_socksClientCertificatesInterceptor = require("./socksClientCertificatesInterceptor");
|
50
|
+
var import_happyEyeballs = require("./utils/happyEyeballs");
|
51
|
+
var import_tracing = require("./trace/recorder/tracing");
|
52
|
+
class APIRequestContext extends import_instrumentation.SdkObject {
|
53
|
+
constructor(parent) {
|
54
|
+
super(parent, "request-context");
|
55
|
+
this.fetchResponses = /* @__PURE__ */ new Map();
|
56
|
+
this.fetchLog = /* @__PURE__ */ new Map();
|
57
|
+
APIRequestContext.allInstances.add(this);
|
58
|
+
}
|
59
|
+
static {
|
60
|
+
this.Events = {
|
61
|
+
Dispose: "dispose",
|
62
|
+
Request: "request",
|
63
|
+
RequestFinished: "requestfinished"
|
64
|
+
};
|
65
|
+
}
|
66
|
+
static {
|
67
|
+
this.allInstances = /* @__PURE__ */ new Set();
|
68
|
+
}
|
69
|
+
static findResponseBody(guid) {
|
70
|
+
for (const request of APIRequestContext.allInstances) {
|
71
|
+
const body = request.fetchResponses.get(guid);
|
72
|
+
if (body)
|
73
|
+
return body;
|
74
|
+
}
|
75
|
+
return void 0;
|
76
|
+
}
|
77
|
+
_disposeImpl() {
|
78
|
+
APIRequestContext.allInstances.delete(this);
|
79
|
+
this.fetchResponses.clear();
|
80
|
+
this.fetchLog.clear();
|
81
|
+
this.emit(APIRequestContext.Events.Dispose);
|
82
|
+
}
|
83
|
+
disposeResponse(fetchUid) {
|
84
|
+
this.fetchResponses.delete(fetchUid);
|
85
|
+
this.fetchLog.delete(fetchUid);
|
86
|
+
}
|
87
|
+
_storeResponseBody(body) {
|
88
|
+
const uid = (0, import_crypto.createGuid)();
|
89
|
+
this.fetchResponses.set(uid, body);
|
90
|
+
return uid;
|
91
|
+
}
|
92
|
+
async fetch(progress, params) {
|
93
|
+
const defaults = this._defaultOptions();
|
94
|
+
const headers = {
|
95
|
+
"user-agent": defaults.userAgent,
|
96
|
+
"accept": "*/*",
|
97
|
+
"accept-encoding": "gzip,deflate,br"
|
98
|
+
};
|
99
|
+
if (defaults.extraHTTPHeaders) {
|
100
|
+
for (const { name, value } of defaults.extraHTTPHeaders)
|
101
|
+
setHeader(headers, name, value);
|
102
|
+
}
|
103
|
+
if (params.headers) {
|
104
|
+
for (const { name, value } of params.headers)
|
105
|
+
setHeader(headers, name, value);
|
106
|
+
}
|
107
|
+
const requestUrl = new URL((0, import_utils.constructURLBasedOnBaseURL)(defaults.baseURL, params.url));
|
108
|
+
if (params.encodedParams) {
|
109
|
+
requestUrl.search = params.encodedParams;
|
110
|
+
} else if (params.params) {
|
111
|
+
for (const { name, value } of params.params)
|
112
|
+
requestUrl.searchParams.append(name, value);
|
113
|
+
}
|
114
|
+
const credentials = this._getHttpCredentials(requestUrl);
|
115
|
+
if (credentials?.send === "always")
|
116
|
+
setBasicAuthorizationHeader(headers, credentials);
|
117
|
+
const method = params.method?.toUpperCase() || "GET";
|
118
|
+
const proxy = defaults.proxy;
|
119
|
+
let agent;
|
120
|
+
if (proxy?.server !== "per-context")
|
121
|
+
agent = (0, import_utils.createProxyAgent)(proxy, requestUrl);
|
122
|
+
let maxRedirects = params.maxRedirects ?? (defaults.maxRedirects ?? 20);
|
123
|
+
maxRedirects = maxRedirects === 0 ? -1 : maxRedirects;
|
124
|
+
const options = {
|
125
|
+
method,
|
126
|
+
headers,
|
127
|
+
agent,
|
128
|
+
maxRedirects,
|
129
|
+
...(0, import_socksClientCertificatesInterceptor.getMatchingTLSOptionsForOrigin)(this._defaultOptions().clientCertificates, requestUrl.origin),
|
130
|
+
__testHookLookup: params.__testHookLookup
|
131
|
+
};
|
132
|
+
if (params.ignoreHTTPSErrors || defaults.ignoreHTTPSErrors)
|
133
|
+
options.rejectUnauthorized = false;
|
134
|
+
const postData = serializePostData(params, headers);
|
135
|
+
if (postData)
|
136
|
+
setHeader(headers, "content-length", String(postData.byteLength));
|
137
|
+
const fetchResponse = await this._sendRequestWithRetries(progress, requestUrl, options, postData, params.maxRetries);
|
138
|
+
const fetchUid = this._storeResponseBody(fetchResponse.body);
|
139
|
+
this.fetchLog.set(fetchUid, progress.metadata.log);
|
140
|
+
const failOnStatusCode = params.failOnStatusCode !== void 0 ? params.failOnStatusCode : !!defaults.failOnStatusCode;
|
141
|
+
if (failOnStatusCode && (fetchResponse.status < 200 || fetchResponse.status >= 400)) {
|
142
|
+
let responseText = "";
|
143
|
+
if (fetchResponse.body.byteLength) {
|
144
|
+
let text = fetchResponse.body.toString("utf8");
|
145
|
+
if (text.length > 1e3)
|
146
|
+
text = text.substring(0, 997) + "...";
|
147
|
+
responseText = `
|
148
|
+
Response text:
|
149
|
+
${text}`;
|
150
|
+
}
|
151
|
+
throw new Error(`${fetchResponse.status} ${fetchResponse.statusText}${responseText}`);
|
152
|
+
}
|
153
|
+
return { ...fetchResponse, fetchUid };
|
154
|
+
}
|
155
|
+
_parseSetCookieHeader(responseUrl, setCookie) {
|
156
|
+
if (!setCookie)
|
157
|
+
return [];
|
158
|
+
const url = new URL(responseUrl);
|
159
|
+
const defaultPath = "/" + url.pathname.substr(1).split("/").slice(0, -1).join("/");
|
160
|
+
const cookies = [];
|
161
|
+
for (const header of setCookie) {
|
162
|
+
const cookie = parseCookie(header);
|
163
|
+
if (!cookie)
|
164
|
+
continue;
|
165
|
+
if (!cookie.domain)
|
166
|
+
cookie.domain = url.hostname;
|
167
|
+
else
|
168
|
+
(0, import_utils.assert)(cookie.domain.startsWith(".") || !cookie.domain.includes("."));
|
169
|
+
if (!(0, import_cookieStore.domainMatches)(url.hostname, cookie.domain))
|
170
|
+
continue;
|
171
|
+
if (!cookie.path || !cookie.path.startsWith("/"))
|
172
|
+
cookie.path = defaultPath;
|
173
|
+
cookies.push(cookie);
|
174
|
+
}
|
175
|
+
return cookies;
|
176
|
+
}
|
177
|
+
async _updateRequestCookieHeader(progress, url, headers) {
|
178
|
+
if (getHeader(headers, "cookie") !== void 0)
|
179
|
+
return;
|
180
|
+
const contextCookies = await progress.race(this._cookies(url));
|
181
|
+
const cookies = contextCookies.filter((c) => new import_cookieStore.Cookie(c).matches(url));
|
182
|
+
if (cookies.length) {
|
183
|
+
const valueArray = cookies.map((c) => `${c.name}=${c.value}`);
|
184
|
+
setHeader(headers, "cookie", valueArray.join("; "));
|
185
|
+
}
|
186
|
+
}
|
187
|
+
async _sendRequestWithRetries(progress, url, options, postData, maxRetries) {
|
188
|
+
maxRetries ??= 0;
|
189
|
+
let backoff = 250;
|
190
|
+
for (let i = 0; i <= maxRetries; i++) {
|
191
|
+
try {
|
192
|
+
return await this._sendRequest(progress, url, options, postData);
|
193
|
+
} catch (e) {
|
194
|
+
if ((0, import_progress.isAbortError)(e))
|
195
|
+
throw e;
|
196
|
+
e = (0, import_socksClientCertificatesInterceptor.rewriteOpenSSLErrorIfNeeded)(e);
|
197
|
+
if (maxRetries === 0)
|
198
|
+
throw e;
|
199
|
+
if (i === maxRetries)
|
200
|
+
throw new Error(`Failed after ${i + 1} attempt(s): ${e}`);
|
201
|
+
if (e.code !== "ECONNRESET")
|
202
|
+
throw e;
|
203
|
+
progress.log(` Received ECONNRESET, will retry after ${backoff}ms.`);
|
204
|
+
await progress.wait(backoff);
|
205
|
+
backoff *= 2;
|
206
|
+
}
|
207
|
+
}
|
208
|
+
throw new Error("Unreachable");
|
209
|
+
}
|
210
|
+
async _sendRequest(progress, url, options, postData) {
|
211
|
+
await this._updateRequestCookieHeader(progress, url, options.headers);
|
212
|
+
const requestCookies = getHeader(options.headers, "cookie")?.split(";").map((p) => {
|
213
|
+
const [name, value] = p.split("=").map((v) => v.trim());
|
214
|
+
return { name, value };
|
215
|
+
}) || [];
|
216
|
+
const requestEvent = {
|
217
|
+
url,
|
218
|
+
method: options.method,
|
219
|
+
headers: options.headers,
|
220
|
+
cookies: requestCookies,
|
221
|
+
postData
|
222
|
+
};
|
223
|
+
this.emit(APIRequestContext.Events.Request, requestEvent);
|
224
|
+
let destroyRequest;
|
225
|
+
const resultPromise = new Promise((fulfill, reject) => {
|
226
|
+
const requestConstructor = (url.protocol === "https:" ? import_https.default : import_http.default).request;
|
227
|
+
const agent = options.agent || (url.protocol === "https:" ? import_happyEyeballs.httpsHappyEyeballsAgent : import_happyEyeballs.httpHappyEyeballsAgent);
|
228
|
+
const requestOptions = { ...options, agent };
|
229
|
+
const startAt = (0, import_utils.monotonicTime)();
|
230
|
+
let reusedSocketAt;
|
231
|
+
let dnsLookupAt;
|
232
|
+
let tcpConnectionAt;
|
233
|
+
let tlsHandshakeAt;
|
234
|
+
let requestFinishAt;
|
235
|
+
let serverIPAddress;
|
236
|
+
let serverPort;
|
237
|
+
let securityDetails;
|
238
|
+
const listeners = [];
|
239
|
+
const request = requestConstructor(url, requestOptions, async (response) => {
|
240
|
+
const responseAt = (0, import_utils.monotonicTime)();
|
241
|
+
const notifyRequestFinished = (body2) => {
|
242
|
+
const endAt = (0, import_utils.monotonicTime)();
|
243
|
+
const connectEnd = tlsHandshakeAt ?? tcpConnectionAt;
|
244
|
+
const timings = {
|
245
|
+
send: requestFinishAt - startAt,
|
246
|
+
wait: responseAt - requestFinishAt,
|
247
|
+
receive: endAt - responseAt,
|
248
|
+
dns: dnsLookupAt ? dnsLookupAt - startAt : -1,
|
249
|
+
connect: connectEnd ? connectEnd - startAt : -1,
|
250
|
+
// "If [ssl] is defined then the time is also included in the connect field "
|
251
|
+
ssl: tlsHandshakeAt ? tlsHandshakeAt - tcpConnectionAt : -1,
|
252
|
+
blocked: reusedSocketAt ? reusedSocketAt - startAt : -1
|
253
|
+
};
|
254
|
+
const requestFinishedEvent = {
|
255
|
+
requestEvent,
|
256
|
+
httpVersion: response.httpVersion,
|
257
|
+
statusCode: response.statusCode || 0,
|
258
|
+
statusMessage: response.statusMessage || "",
|
259
|
+
headers: response.headers,
|
260
|
+
rawHeaders: response.rawHeaders,
|
261
|
+
cookies,
|
262
|
+
body: body2,
|
263
|
+
timings,
|
264
|
+
serverIPAddress,
|
265
|
+
serverPort,
|
266
|
+
securityDetails
|
267
|
+
};
|
268
|
+
this.emit(APIRequestContext.Events.RequestFinished, requestFinishedEvent);
|
269
|
+
};
|
270
|
+
progress.log(`\u2190 ${response.statusCode} ${response.statusMessage}`);
|
271
|
+
for (const [name, value] of Object.entries(response.headers))
|
272
|
+
progress.log(` ${name}: ${value}`);
|
273
|
+
const cookies = this._parseSetCookieHeader(response.url || url.toString(), response.headers["set-cookie"]);
|
274
|
+
if (cookies.length) {
|
275
|
+
try {
|
276
|
+
await this._addCookies(cookies);
|
277
|
+
} catch (e) {
|
278
|
+
await Promise.all(cookies.map((c) => this._addCookies([c]).catch(() => {
|
279
|
+
})));
|
280
|
+
}
|
281
|
+
}
|
282
|
+
if (redirectStatus.includes(response.statusCode) && options.maxRedirects >= 0) {
|
283
|
+
if (options.maxRedirects === 0) {
|
284
|
+
reject(new Error("Max redirect count exceeded"));
|
285
|
+
request.destroy();
|
286
|
+
return;
|
287
|
+
}
|
288
|
+
const headers = { ...options.headers };
|
289
|
+
removeHeader(headers, `cookie`);
|
290
|
+
const status = response.statusCode;
|
291
|
+
let method = options.method;
|
292
|
+
if ((status === 301 || status === 302) && method === "POST" || status === 303 && !["GET", "HEAD"].includes(method)) {
|
293
|
+
method = "GET";
|
294
|
+
postData = void 0;
|
295
|
+
removeHeader(headers, `content-encoding`);
|
296
|
+
removeHeader(headers, `content-language`);
|
297
|
+
removeHeader(headers, `content-length`);
|
298
|
+
removeHeader(headers, `content-location`);
|
299
|
+
removeHeader(headers, `content-type`);
|
300
|
+
}
|
301
|
+
const redirectOptions = {
|
302
|
+
method,
|
303
|
+
headers,
|
304
|
+
agent: options.agent,
|
305
|
+
maxRedirects: options.maxRedirects - 1,
|
306
|
+
...(0, import_socksClientCertificatesInterceptor.getMatchingTLSOptionsForOrigin)(this._defaultOptions().clientCertificates, url.origin),
|
307
|
+
__testHookLookup: options.__testHookLookup
|
308
|
+
};
|
309
|
+
if (options.rejectUnauthorized === false)
|
310
|
+
redirectOptions.rejectUnauthorized = false;
|
311
|
+
const locationHeaderValue = Buffer.from(response.headers.location ?? "", "latin1").toString("utf8");
|
312
|
+
if (locationHeaderValue) {
|
313
|
+
let locationURL;
|
314
|
+
try {
|
315
|
+
locationURL = new URL(locationHeaderValue, url);
|
316
|
+
} catch (error) {
|
317
|
+
reject(new Error(`uri requested responds with an invalid redirect URL: ${locationHeaderValue}`));
|
318
|
+
request.destroy();
|
319
|
+
return;
|
320
|
+
}
|
321
|
+
if (headers["host"])
|
322
|
+
headers["host"] = locationURL.host;
|
323
|
+
notifyRequestFinished();
|
324
|
+
fulfill(this._sendRequest(progress, locationURL, redirectOptions, postData));
|
325
|
+
request.destroy();
|
326
|
+
return;
|
327
|
+
}
|
328
|
+
}
|
329
|
+
if (response.statusCode === 401 && !getHeader(options.headers, "authorization")) {
|
330
|
+
const auth = response.headers["www-authenticate"];
|
331
|
+
const credentials = this._getHttpCredentials(url);
|
332
|
+
if (auth?.trim().startsWith("Basic") && credentials) {
|
333
|
+
setBasicAuthorizationHeader(options.headers, credentials);
|
334
|
+
notifyRequestFinished();
|
335
|
+
fulfill(this._sendRequest(progress, url, options, postData));
|
336
|
+
request.destroy();
|
337
|
+
return;
|
338
|
+
}
|
339
|
+
}
|
340
|
+
response.on("aborted", () => reject(new Error("aborted")));
|
341
|
+
const chunks = [];
|
342
|
+
const notifyBodyFinished = () => {
|
343
|
+
const body2 = Buffer.concat(chunks);
|
344
|
+
notifyRequestFinished(body2);
|
345
|
+
fulfill({
|
346
|
+
url: response.url || url.toString(),
|
347
|
+
status: response.statusCode || 0,
|
348
|
+
statusText: response.statusMessage || "",
|
349
|
+
headers: toHeadersArray(response.rawHeaders),
|
350
|
+
body: body2
|
351
|
+
});
|
352
|
+
};
|
353
|
+
let body = response;
|
354
|
+
let transform;
|
355
|
+
const encoding = response.headers["content-encoding"];
|
356
|
+
if (encoding === "gzip" || encoding === "x-gzip") {
|
357
|
+
transform = zlib.createGunzip({
|
358
|
+
flush: zlib.constants.Z_SYNC_FLUSH,
|
359
|
+
finishFlush: zlib.constants.Z_SYNC_FLUSH
|
360
|
+
});
|
361
|
+
} else if (encoding === "br") {
|
362
|
+
transform = zlib.createBrotliDecompress({
|
363
|
+
flush: zlib.constants.BROTLI_OPERATION_FLUSH,
|
364
|
+
finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH
|
365
|
+
});
|
366
|
+
} else if (encoding === "deflate") {
|
367
|
+
transform = zlib.createInflate();
|
368
|
+
}
|
369
|
+
if (transform) {
|
370
|
+
const emptyStreamTransform = new SafeEmptyStreamTransform(notifyBodyFinished);
|
371
|
+
body = (0, import_stream.pipeline)(response, emptyStreamTransform, transform, (e) => {
|
372
|
+
if (e)
|
373
|
+
reject(new Error(`failed to decompress '${encoding}' encoding: ${e.message}`));
|
374
|
+
});
|
375
|
+
body.on("error", (e) => reject(new Error(`failed to decompress '${encoding}' encoding: ${e}`)));
|
376
|
+
} else {
|
377
|
+
body.on("error", reject);
|
378
|
+
}
|
379
|
+
body.on("data", (chunk) => chunks.push(chunk));
|
380
|
+
body.on("end", notifyBodyFinished);
|
381
|
+
});
|
382
|
+
request.on("error", reject);
|
383
|
+
destroyRequest = () => request.destroy();
|
384
|
+
listeners.push(
|
385
|
+
import_utils.eventsHelper.addEventListener(this, APIRequestContext.Events.Dispose, () => {
|
386
|
+
reject(new Error("Request context disposed."));
|
387
|
+
request.destroy();
|
388
|
+
})
|
389
|
+
);
|
390
|
+
request.on("close", () => import_utils.eventsHelper.removeEventListeners(listeners));
|
391
|
+
request.on("socket", (socket) => {
|
392
|
+
if (request.reusedSocket) {
|
393
|
+
reusedSocketAt = (0, import_utils.monotonicTime)();
|
394
|
+
return;
|
395
|
+
}
|
396
|
+
const happyEyeBallsTimings = (0, import_happyEyeballs.timingForSocket)(socket);
|
397
|
+
dnsLookupAt = happyEyeBallsTimings.dnsLookupAt;
|
398
|
+
tcpConnectionAt = happyEyeBallsTimings.tcpConnectionAt;
|
399
|
+
listeners.push(
|
400
|
+
import_utils.eventsHelper.addEventListener(socket, "lookup", () => {
|
401
|
+
dnsLookupAt = (0, import_utils.monotonicTime)();
|
402
|
+
}),
|
403
|
+
import_utils.eventsHelper.addEventListener(socket, "connect", () => {
|
404
|
+
tcpConnectionAt = (0, import_utils.monotonicTime)();
|
405
|
+
}),
|
406
|
+
import_utils.eventsHelper.addEventListener(socket, "secureConnect", () => {
|
407
|
+
tlsHandshakeAt = (0, import_utils.monotonicTime)();
|
408
|
+
if (socket instanceof import_tls.TLSSocket) {
|
409
|
+
const peerCertificate = socket.getPeerCertificate();
|
410
|
+
securityDetails = {
|
411
|
+
protocol: socket.getProtocol() ?? void 0,
|
412
|
+
subjectName: peerCertificate.subject.CN,
|
413
|
+
validFrom: new Date(peerCertificate.valid_from).getTime() / 1e3,
|
414
|
+
validTo: new Date(peerCertificate.valid_to).getTime() / 1e3,
|
415
|
+
issuer: peerCertificate.issuer.CN
|
416
|
+
};
|
417
|
+
}
|
418
|
+
})
|
419
|
+
);
|
420
|
+
serverIPAddress = socket.remoteAddress;
|
421
|
+
serverPort = socket.remotePort;
|
422
|
+
});
|
423
|
+
request.on("finish", () => {
|
424
|
+
requestFinishAt = (0, import_utils.monotonicTime)();
|
425
|
+
});
|
426
|
+
progress.log(`\u2192 ${options.method} ${url.toString()}`);
|
427
|
+
if (options.headers) {
|
428
|
+
for (const [name, value] of Object.entries(options.headers))
|
429
|
+
progress.log(` ${name}: ${value}`);
|
430
|
+
}
|
431
|
+
if (postData)
|
432
|
+
request.write(postData);
|
433
|
+
request.end();
|
434
|
+
});
|
435
|
+
return progress.race(resultPromise).catch((error) => {
|
436
|
+
destroyRequest?.();
|
437
|
+
throw error;
|
438
|
+
});
|
439
|
+
}
|
440
|
+
_getHttpCredentials(url) {
|
441
|
+
if (!this._defaultOptions().httpCredentials?.origin || url.origin.toLowerCase() === this._defaultOptions().httpCredentials?.origin?.toLowerCase())
|
442
|
+
return this._defaultOptions().httpCredentials;
|
443
|
+
return void 0;
|
444
|
+
}
|
445
|
+
}
|
446
|
+
class SafeEmptyStreamTransform extends import_stream.Transform {
|
447
|
+
constructor(onEmptyStreamCallback) {
|
448
|
+
super();
|
449
|
+
this._receivedSomeData = false;
|
450
|
+
this._onEmptyStreamCallback = onEmptyStreamCallback;
|
451
|
+
}
|
452
|
+
_transform(chunk, encoding, callback) {
|
453
|
+
this._receivedSomeData = true;
|
454
|
+
callback(null, chunk);
|
455
|
+
}
|
456
|
+
_flush(callback) {
|
457
|
+
if (this._receivedSomeData)
|
458
|
+
callback(null);
|
459
|
+
else
|
460
|
+
this._onEmptyStreamCallback();
|
461
|
+
}
|
462
|
+
}
|
463
|
+
class BrowserContextAPIRequestContext extends APIRequestContext {
|
464
|
+
constructor(context) {
|
465
|
+
super(context);
|
466
|
+
this._context = context;
|
467
|
+
context.once(import_browserContext.BrowserContext.Events.Close, () => this._disposeImpl());
|
468
|
+
}
|
469
|
+
tracing() {
|
470
|
+
return this._context.tracing;
|
471
|
+
}
|
472
|
+
async dispose(options) {
|
473
|
+
this._closeReason = options.reason;
|
474
|
+
this.fetchResponses.clear();
|
475
|
+
}
|
476
|
+
_defaultOptions() {
|
477
|
+
return {
|
478
|
+
userAgent: this._context._options.userAgent || this._context._browser.userAgent(),
|
479
|
+
extraHTTPHeaders: this._context._options.extraHTTPHeaders,
|
480
|
+
failOnStatusCode: void 0,
|
481
|
+
httpCredentials: this._context._options.httpCredentials,
|
482
|
+
proxy: this._context._options.proxy || this._context._browser.options.proxy,
|
483
|
+
ignoreHTTPSErrors: this._context._options.ignoreHTTPSErrors,
|
484
|
+
baseURL: this._context._options.baseURL,
|
485
|
+
clientCertificates: this._context._options.clientCertificates
|
486
|
+
};
|
487
|
+
}
|
488
|
+
async _addCookies(cookies) {
|
489
|
+
await this._context.addCookies(cookies);
|
490
|
+
}
|
491
|
+
async _cookies(url) {
|
492
|
+
return await this._context.cookies(url.toString());
|
493
|
+
}
|
494
|
+
async storageState(progress, indexedDB) {
|
495
|
+
return this._context.storageState(progress, indexedDB);
|
496
|
+
}
|
497
|
+
}
|
498
|
+
class GlobalAPIRequestContext extends APIRequestContext {
|
499
|
+
constructor(playwright, options) {
|
500
|
+
super(playwright);
|
501
|
+
this._cookieStore = new import_cookieStore.CookieStore();
|
502
|
+
this.attribution.context = this;
|
503
|
+
if (options.storageState) {
|
504
|
+
this._origins = options.storageState.origins?.map((origin) => ({ indexedDB: [], ...origin }));
|
505
|
+
this._cookieStore.addCookies(options.storageState.cookies || []);
|
506
|
+
}
|
507
|
+
(0, import_browserContext.verifyClientCertificates)(options.clientCertificates);
|
508
|
+
this._options = {
|
509
|
+
baseURL: options.baseURL,
|
510
|
+
userAgent: options.userAgent || (0, import_userAgent.getUserAgent)(),
|
511
|
+
extraHTTPHeaders: options.extraHTTPHeaders,
|
512
|
+
failOnStatusCode: !!options.failOnStatusCode,
|
513
|
+
ignoreHTTPSErrors: !!options.ignoreHTTPSErrors,
|
514
|
+
maxRedirects: options.maxRedirects,
|
515
|
+
httpCredentials: options.httpCredentials,
|
516
|
+
clientCertificates: options.clientCertificates,
|
517
|
+
proxy: options.proxy
|
518
|
+
};
|
519
|
+
this._tracing = new import_tracing.Tracing(this, options.tracesDir);
|
520
|
+
}
|
521
|
+
tracing() {
|
522
|
+
return this._tracing;
|
523
|
+
}
|
524
|
+
async dispose(options) {
|
525
|
+
this._closeReason = options.reason;
|
526
|
+
await this._tracing.flush();
|
527
|
+
await this._tracing.deleteTmpTracesDir();
|
528
|
+
this._disposeImpl();
|
529
|
+
}
|
530
|
+
_defaultOptions() {
|
531
|
+
return this._options;
|
532
|
+
}
|
533
|
+
async _addCookies(cookies) {
|
534
|
+
this._cookieStore.addCookies(cookies);
|
535
|
+
}
|
536
|
+
async _cookies(url) {
|
537
|
+
return this._cookieStore.cookies(url);
|
538
|
+
}
|
539
|
+
async storageState(progress, indexedDB = false) {
|
540
|
+
return {
|
541
|
+
cookies: this._cookieStore.allCookies(),
|
542
|
+
origins: (this._origins || []).map((origin) => ({ ...origin, indexedDB: indexedDB ? origin.indexedDB : [] }))
|
543
|
+
};
|
544
|
+
}
|
545
|
+
}
|
546
|
+
function toHeadersArray(rawHeaders) {
|
547
|
+
const result = [];
|
548
|
+
for (let i = 0; i < rawHeaders.length; i += 2)
|
549
|
+
result.push({ name: rawHeaders[i], value: rawHeaders[i + 1] });
|
550
|
+
return result;
|
551
|
+
}
|
552
|
+
const redirectStatus = [301, 302, 303, 307, 308];
|
553
|
+
function parseCookie(header) {
|
554
|
+
const raw = (0, import_cookieStore.parseRawCookie)(header);
|
555
|
+
if (!raw)
|
556
|
+
return null;
|
557
|
+
const cookie = {
|
558
|
+
domain: "",
|
559
|
+
path: "",
|
560
|
+
expires: -1,
|
561
|
+
httpOnly: false,
|
562
|
+
secure: false,
|
563
|
+
// From https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
|
564
|
+
// The cookie-sending behavior if SameSite is not specified is SameSite=Lax.
|
565
|
+
sameSite: "Lax",
|
566
|
+
...raw
|
567
|
+
};
|
568
|
+
return cookie;
|
569
|
+
}
|
570
|
+
function serializePostData(params, headers) {
|
571
|
+
(0, import_utils.assert)((params.postData ? 1 : 0) + (params.jsonData ? 1 : 0) + (params.formData ? 1 : 0) + (params.multipartData ? 1 : 0) <= 1, `Only one of 'data', 'form' or 'multipart' can be specified`);
|
572
|
+
if (params.jsonData !== void 0) {
|
573
|
+
setHeader(headers, "content-type", "application/json", true);
|
574
|
+
return Buffer.from(params.jsonData, "utf8");
|
575
|
+
} else if (params.formData) {
|
576
|
+
const searchParams = new URLSearchParams();
|
577
|
+
for (const { name, value } of params.formData)
|
578
|
+
searchParams.append(name, value);
|
579
|
+
setHeader(headers, "content-type", "application/x-www-form-urlencoded", true);
|
580
|
+
return Buffer.from(searchParams.toString(), "utf8");
|
581
|
+
} else if (params.multipartData) {
|
582
|
+
const formData = new import_formData.MultipartFormData();
|
583
|
+
for (const field of params.multipartData) {
|
584
|
+
if (field.file)
|
585
|
+
formData.addFileField(field.name, field.file);
|
586
|
+
else if (field.value)
|
587
|
+
formData.addField(field.name, field.value);
|
588
|
+
}
|
589
|
+
setHeader(headers, "content-type", formData.contentTypeHeader(), true);
|
590
|
+
return formData.finish();
|
591
|
+
} else if (params.postData !== void 0) {
|
592
|
+
setHeader(headers, "content-type", "application/octet-stream", true);
|
593
|
+
return params.postData;
|
594
|
+
}
|
595
|
+
return void 0;
|
596
|
+
}
|
597
|
+
function setHeader(headers, name, value, keepExisting = false) {
|
598
|
+
const existing = Object.entries(headers).find((pair) => pair[0].toLowerCase() === name.toLowerCase());
|
599
|
+
if (!existing)
|
600
|
+
headers[name] = value;
|
601
|
+
else if (!keepExisting)
|
602
|
+
headers[existing[0]] = value;
|
603
|
+
}
|
604
|
+
function getHeader(headers, name) {
|
605
|
+
const existing = Object.entries(headers).find((pair) => pair[0].toLowerCase() === name.toLowerCase());
|
606
|
+
return existing ? existing[1] : void 0;
|
607
|
+
}
|
608
|
+
function removeHeader(headers, name) {
|
609
|
+
delete headers[name];
|
610
|
+
}
|
611
|
+
function setBasicAuthorizationHeader(headers, credentials) {
|
612
|
+
const { username, password } = credentials;
|
613
|
+
const encoded = Buffer.from(`${username || ""}:${password || ""}`).toString("base64");
|
614
|
+
setHeader(headers, "authorization", `Basic ${encoded}`);
|
615
|
+
}
|
616
|
+
// Annotate the CommonJS export names for ESM import in node:
|
617
|
+
0 && (module.exports = {
|
618
|
+
APIRequestContext,
|
619
|
+
BrowserContextAPIRequestContext,
|
620
|
+
GlobalAPIRequestContext
|
621
|
+
});
|
@@ -0,0 +1,43 @@
|
|
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 fileChooser_exports = {};
|
20
|
+
__export(fileChooser_exports, {
|
21
|
+
FileChooser: () => FileChooser
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(fileChooser_exports);
|
24
|
+
class FileChooser {
|
25
|
+
constructor(page, elementHandle, isMultiple) {
|
26
|
+
this._page = page;
|
27
|
+
this._elementHandle = elementHandle;
|
28
|
+
this._isMultiple = isMultiple;
|
29
|
+
}
|
30
|
+
element() {
|
31
|
+
return this._elementHandle;
|
32
|
+
}
|
33
|
+
isMultiple() {
|
34
|
+
return this._isMultiple;
|
35
|
+
}
|
36
|
+
page() {
|
37
|
+
return this._page;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
41
|
+
0 && (module.exports = {
|
42
|
+
FileChooser
|
43
|
+
});
|