patchright-core 1.48.2
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/README.md +3 -0
- package/ThirdPartyNotices.txt +1548 -0
- package/bin/PrintDeps.exe +0 -0
- package/bin/README.md +2 -0
- package/bin/install_media_pack.ps1 +5 -0
- package/bin/reinstall_chrome_beta_linux.sh +40 -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 +40 -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 +40 -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 +40 -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 +40 -0
- package/bin/reinstall_msedge_stable_mac.sh +11 -0
- package/bin/reinstall_msedge_stable_win.ps1 +24 -0
- package/browsers.json +57 -0
- package/cli.js +18 -0
- package/index.d.ts +17 -0
- package/index.js +33 -0
- package/index.mjs +28 -0
- package/lib/androidServerImpl.js +69 -0
- package/lib/browserServerImpl.js +92 -0
- package/lib/cli/driver.js +95 -0
- package/lib/cli/program.js +589 -0
- package/lib/cli/programWithTestStub.js +67 -0
- package/lib/client/accessibility.js +50 -0
- package/lib/client/android.js +473 -0
- package/lib/client/api.js +285 -0
- package/lib/client/artifact.js +79 -0
- package/lib/client/browser.js +145 -0
- package/lib/client/browserContext.js +583 -0
- package/lib/client/browserType.js +241 -0
- package/lib/client/cdpSession.js +53 -0
- package/lib/client/channelOwner.js +235 -0
- package/lib/client/clientHelper.js +57 -0
- package/lib/client/clientInstrumentation.js +50 -0
- package/lib/client/clock.js +69 -0
- package/lib/client/connection.js +333 -0
- package/lib/client/consoleMessage.js +55 -0
- package/lib/client/coverage.js +41 -0
- package/lib/client/dialog.js +57 -0
- package/lib/client/download.js +62 -0
- package/lib/client/electron.js +135 -0
- package/lib/client/elementHandle.js +321 -0
- package/lib/client/errors.js +77 -0
- package/lib/client/eventEmitter.js +314 -0
- package/lib/client/events.js +94 -0
- package/lib/client/fetch.js +391 -0
- package/lib/client/fileChooser.js +45 -0
- package/lib/client/frame.js +504 -0
- package/lib/client/harRouter.js +99 -0
- package/lib/client/input.js +111 -0
- package/lib/client/jsHandle.js +121 -0
- package/lib/client/jsonPipe.js +35 -0
- package/lib/client/localUtils.js +36 -0
- package/lib/client/locator.js +441 -0
- package/lib/client/network.js +762 -0
- package/lib/client/page.js +770 -0
- package/lib/client/playwright.js +80 -0
- package/lib/client/selectors.js +67 -0
- package/lib/client/stream.js +54 -0
- package/lib/client/tracing.js +134 -0
- package/lib/client/types.js +24 -0
- package/lib/client/video.js +51 -0
- package/lib/client/waiter.js +158 -0
- package/lib/client/webError.js +37 -0
- package/lib/client/worker.js +71 -0
- package/lib/client/writableStream.js +54 -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/clockSource.js +7 -0
- package/lib/generated/consoleApiSource.js +7 -0
- package/lib/generated/injectedScriptSource.js +7 -0
- package/lib/generated/pollingRecorderSource.js +7 -0
- package/lib/generated/utilityScriptSource.js +7 -0
- package/lib/generated/webSocketMockSource.js +7 -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 +54 -0
- package/lib/inprocess.js +20 -0
- package/lib/outofprocess.js +67 -0
- package/lib/protocol/debug.js +27 -0
- package/lib/protocol/serializers.js +173 -0
- package/lib/protocol/transport.js +82 -0
- package/lib/protocol/validator.js +2760 -0
- package/lib/protocol/validatorPrimitives.js +139 -0
- package/lib/remote/playwrightConnection.js +274 -0
- package/lib/remote/playwrightServer.js +110 -0
- package/lib/server/accessibility.js +62 -0
- package/lib/server/android/android.js +441 -0
- package/lib/server/android/backendAdb.js +172 -0
- package/lib/server/artifact.js +104 -0
- package/lib/server/bidi/bidiBrowser.js +311 -0
- package/lib/server/bidi/bidiChromium.js +124 -0
- package/lib/server/bidi/bidiConnection.js +206 -0
- package/lib/server/bidi/bidiExecutionContext.js +159 -0
- package/lib/server/bidi/bidiFirefox.js +104 -0
- package/lib/server/bidi/bidiInput.js +158 -0
- package/lib/server/bidi/bidiNetworkManager.js +338 -0
- package/lib/server/bidi/bidiOverCdp.js +103 -0
- package/lib/server/bidi/bidiPage.js +529 -0
- package/lib/server/bidi/bidiPdf.js +140 -0
- package/lib/server/bidi/third_party/bidiDeserializer.js +93 -0
- package/lib/server/bidi/third_party/bidiKeyboard.js +238 -0
- package/lib/server/bidi/third_party/bidiProtocol.js +139 -0
- package/lib/server/bidi/third_party/bidiSerializer.js +144 -0
- package/lib/server/bidi/third_party/firefoxPrefs.js +221 -0
- package/lib/server/browser.js +148 -0
- package/lib/server/browserContext.js +666 -0
- package/lib/server/browserType.js +335 -0
- package/lib/server/chromium/appIcon.png +0 -0
- package/lib/server/chromium/chromium.js +350 -0
- package/lib/server/chromium/chromiumSwitches.js +36 -0
- package/lib/server/chromium/crAccessibility.js +237 -0
- package/lib/server/chromium/crBrowser.js +522 -0
- package/lib/server/chromium/crConnection.js +228 -0
- package/lib/server/chromium/crCoverage.js +246 -0
- package/lib/server/chromium/crDevTools.js +104 -0
- package/lib/server/chromium/crDragDrop.js +143 -0
- package/lib/server/chromium/crExecutionContext.js +149 -0
- package/lib/server/chromium/crInput.js +171 -0
- package/lib/server/chromium/crNetworkManager.js +809 -0
- package/lib/server/chromium/crPage.js +1235 -0
- package/lib/server/chromium/crPdf.js +153 -0
- package/lib/server/chromium/crProtocolHelper.js +133 -0
- package/lib/server/chromium/crServiceWorker.js +111 -0
- package/lib/server/chromium/defaultFontFamilies.js +145 -0
- package/lib/server/chromium/videoRecorder.js +155 -0
- package/lib/server/clock.js +133 -0
- package/lib/server/codegen/csharp.js +299 -0
- package/lib/server/codegen/java.js +235 -0
- package/lib/server/codegen/javascript.js +223 -0
- package/lib/server/codegen/jsonl.js +47 -0
- package/lib/server/codegen/language.js +88 -0
- package/lib/server/codegen/languages.js +30 -0
- package/lib/server/codegen/python.js +265 -0
- package/lib/server/codegen/types.js +5 -0
- package/lib/server/console.js +57 -0
- package/lib/server/cookieStore.js +185 -0
- package/lib/server/debugController.js +234 -0
- package/lib/server/debugger.js +132 -0
- package/lib/server/deviceDescriptors.js +26 -0
- package/lib/server/deviceDescriptorsSource.json +1669 -0
- package/lib/server/dialog.js +71 -0
- package/lib/server/dispatchers/androidDispatcher.js +193 -0
- package/lib/server/dispatchers/artifactDispatcher.js +118 -0
- package/lib/server/dispatchers/browserContextDispatcher.js +368 -0
- package/lib/server/dispatchers/browserDispatcher.js +170 -0
- package/lib/server/dispatchers/browserTypeDispatcher.js +55 -0
- package/lib/server/dispatchers/cdpSessionDispatcher.js +48 -0
- package/lib/server/dispatchers/debugControllerDispatcher.js +103 -0
- package/lib/server/dispatchers/dialogDispatcher.js +44 -0
- package/lib/server/dispatchers/dispatcher.js +395 -0
- package/lib/server/dispatchers/electronDispatcher.js +93 -0
- package/lib/server/dispatchers/elementHandlerDispatcher.js +228 -0
- package/lib/server/dispatchers/frameDispatcher.js +286 -0
- package/lib/server/dispatchers/jsHandleDispatcher.js +97 -0
- package/lib/server/dispatchers/jsonPipeDispatcher.js +59 -0
- package/lib/server/dispatchers/localUtilsDispatcher.js +413 -0
- package/lib/server/dispatchers/networkDispatchers.js +221 -0
- package/lib/server/dispatchers/pageDispatcher.js +367 -0
- package/lib/server/dispatchers/playwrightDispatcher.js +107 -0
- package/lib/server/dispatchers/selectorsDispatcher.js +36 -0
- package/lib/server/dispatchers/streamDispatcher.js +62 -0
- package/lib/server/dispatchers/tracingDispatcher.js +54 -0
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +189 -0
- package/lib/server/dispatchers/writableStreamDispatcher.js +58 -0
- package/lib/server/dom.js +845 -0
- package/lib/server/download.js +60 -0
- package/lib/server/electron/electron.js +296 -0
- package/lib/server/electron/loader.js +57 -0
- package/lib/server/errors.js +68 -0
- package/lib/server/fetch.js +656 -0
- package/lib/server/fileChooser.js +42 -0
- package/lib/server/fileUploadUtils.js +75 -0
- package/lib/server/firefox/ffAccessibility.js +216 -0
- package/lib/server/firefox/ffBrowser.js +460 -0
- package/lib/server/firefox/ffConnection.js +168 -0
- package/lib/server/firefox/ffExecutionContext.js +135 -0
- package/lib/server/firefox/ffInput.js +150 -0
- package/lib/server/firefox/ffNetworkManager.js +233 -0
- package/lib/server/firefox/ffPage.js +559 -0
- package/lib/server/firefox/firefox.js +99 -0
- package/lib/server/formData.js +75 -0
- package/lib/server/frameSelectors.js +171 -0
- package/lib/server/frames.js +1808 -0
- package/lib/server/har/harRecorder.js +139 -0
- package/lib/server/har/harTracer.js +542 -0
- package/lib/server/helper.js +103 -0
- package/lib/server/index.js +114 -0
- package/lib/server/input.js +310 -0
- package/lib/server/instrumentation.js +70 -0
- package/lib/server/isomorphic/utilityScriptSerializers.js +226 -0
- package/lib/server/javascript.js +299 -0
- package/lib/server/launchApp.js +91 -0
- package/lib/server/macEditingCommands.js +139 -0
- package/lib/server/network.js +617 -0
- package/lib/server/page.js +819 -0
- package/lib/server/pipeTransport.js +85 -0
- package/lib/server/playwright.js +88 -0
- package/lib/server/progress.js +102 -0
- package/lib/server/protocolError.js +49 -0
- package/lib/server/recorder/contextRecorder.js +299 -0
- package/lib/server/recorder/recorderApp.js +196 -0
- package/lib/server/recorder/recorderCollection.js +116 -0
- package/lib/server/recorder/recorderFrontend.js +5 -0
- package/lib/server/recorder/recorderInTraceViewer.js +144 -0
- package/lib/server/recorder/recorderRunner.js +155 -0
- package/lib/server/recorder/recorderUtils.js +112 -0
- package/lib/server/recorder/throttledFile.js +46 -0
- package/lib/server/recorder.js +329 -0
- package/lib/server/registry/browserFetcher.js +168 -0
- package/lib/server/registry/dependencies.js +322 -0
- package/lib/server/registry/index.js +1005 -0
- package/lib/server/registry/nativeDeps.js +490 -0
- package/lib/server/registry/oopDownloadBrowserMain.js +138 -0
- package/lib/server/screenshotter.js +348 -0
- package/lib/server/selectors.js +73 -0
- package/lib/server/socksClientCertificatesInterceptor.js +340 -0
- package/lib/server/socksInterceptor.js +100 -0
- package/lib/server/trace/recorder/snapshotter.js +172 -0
- package/lib/server/trace/recorder/snapshotterInjected.js +493 -0
- package/lib/server/trace/recorder/tracing.js +542 -0
- package/lib/server/trace/test/inMemorySnapshotter.js +93 -0
- package/lib/server/trace/viewer/traceViewer.js +213 -0
- package/lib/server/transport.js +191 -0
- package/lib/server/types.js +24 -0
- package/lib/server/usKeyboardLayout.js +555 -0
- package/lib/server/webkit/webkit.js +87 -0
- package/lib/server/webkit/wkAccessibility.js +194 -0
- package/lib/server/webkit/wkBrowser.js +329 -0
- package/lib/server/webkit/wkConnection.js +173 -0
- package/lib/server/webkit/wkExecutionContext.js +143 -0
- package/lib/server/webkit/wkInput.js +169 -0
- package/lib/server/webkit/wkInterceptableRequest.js +162 -0
- package/lib/server/webkit/wkPage.js +1219 -0
- package/lib/server/webkit/wkProvisionalPage.js +94 -0
- package/lib/server/webkit/wkWorkers.js +104 -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 +174 -0
- package/lib/utils/debug.js +46 -0
- package/lib/utils/debugLogger.js +91 -0
- package/lib/utils/env.js +49 -0
- package/lib/utils/eventsHelper.js +38 -0
- package/lib/utils/expectUtils.js +33 -0
- package/lib/utils/fileUtils.js +205 -0
- package/lib/utils/happy-eyeballs.js +194 -0
- package/lib/utils/headers.js +52 -0
- package/lib/utils/hostPlatform.js +133 -0
- package/lib/utils/httpServer.js +237 -0
- package/lib/utils/index.js +368 -0
- package/lib/utils/isomorphic/cssParser.js +250 -0
- package/lib/utils/isomorphic/cssTokenizer.js +979 -0
- package/lib/utils/isomorphic/locatorGenerators.js +642 -0
- package/lib/utils/isomorphic/locatorParser.js +179 -0
- package/lib/utils/isomorphic/locatorUtils.js +62 -0
- package/lib/utils/isomorphic/mimeType.js +29 -0
- package/lib/utils/isomorphic/recorderUtils.js +195 -0
- package/lib/utils/isomorphic/selectorParser.js +397 -0
- package/lib/utils/isomorphic/stringUtils.js +139 -0
- package/lib/utils/isomorphic/traceUtils.js +39 -0
- package/lib/utils/isomorphic/urlMatch.js +120 -0
- package/lib/utils/linuxUtils.js +78 -0
- package/lib/utils/manualPromise.js +109 -0
- package/lib/utils/multimap.js +75 -0
- package/lib/utils/network.js +160 -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/utilsBundle.js +82 -0
- package/lib/utilsBundleImpl/index.js +53 -0
- package/lib/utilsBundleImpl/xdg-open +1066 -0
- package/lib/vite/htmlReport/index.html +66 -0
- package/lib/vite/recorder/assets/codeMirrorModule-baozm8ur.js +24 -0
- package/lib/vite/recorder/assets/codeMirrorModule-ez37Vkbh.css +1 -0
- package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- package/lib/vite/recorder/assets/index-2ElAIWFB.js +42 -0
- package/lib/vite/recorder/assets/index-BW-aOBcL.css +1 -0
- package/lib/vite/recorder/index.html +29 -0
- package/lib/vite/recorder/playwright-logo.svg +9 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-Bh1rfd2w.js +24 -0
- package/lib/vite/traceViewer/assets/inspectorTab-7GHnKvSD.js +64 -0
- package/lib/vite/traceViewer/assets/testServerConnection-DeE2kSzz.js +1 -0
- package/lib/vite/traceViewer/assets/workbench-DPQnTHYP.js +9 -0
- package/lib/vite/traceViewer/assets/xtermModule-BeNbaIVa.js +9 -0
- package/lib/vite/traceViewer/codeMirrorModule.ez37Vkbh.css +1 -0
- package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/lib/vite/traceViewer/embedded.BlHoW5LY.js +2 -0
- package/lib/vite/traceViewer/embedded.html +18 -0
- package/lib/vite/traceViewer/embedded.w7WN2u1R.css +1 -0
- package/lib/vite/traceViewer/index.CrbWWHbf.css +1 -0
- package/lib/vite/traceViewer/index.DaWVfou1.js +2 -0
- package/lib/vite/traceViewer/index.html +29 -0
- package/lib/vite/traceViewer/inspectorTab.DLjBDrQR.css +1 -0
- package/lib/vite/traceViewer/playwright-logo.svg +9 -0
- package/lib/vite/traceViewer/recorder.B_SY1GJM.css +0 -0
- package/lib/vite/traceViewer/recorder.C4zxcvd2.js +2 -0
- package/lib/vite/traceViewer/recorder.html +17 -0
- package/lib/vite/traceViewer/snapshot.html +21 -0
- package/lib/vite/traceViewer/sw.bundle.js +3 -0
- package/lib/vite/traceViewer/uiMode.CAYqod-m.css +1 -0
- package/lib/vite/traceViewer/uiMode.html +20 -0
- package/lib/vite/traceViewer/uiMode.mTXWniJb.js +5 -0
- package/lib/vite/traceViewer/workbench.D3JVcA9K.css +1 -0
- package/lib/vite/traceViewer/xtermModule.DSXBckUd.css +32 -0
- package/lib/zipBundle.js +25 -0
- package/lib/zipBundleImpl.js +5 -0
- package/package.json +44 -0
- package/types/protocol.d.ts +21571 -0
- package/types/structs.d.ts +45 -0
- package/types/types.d.ts +22519 -0
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dockerVersion = dockerVersion;
|
|
7
|
+
exports.installDependenciesLinux = installDependenciesLinux;
|
|
8
|
+
exports.installDependenciesWindows = installDependenciesWindows;
|
|
9
|
+
exports.readDockerVersionSync = readDockerVersionSync;
|
|
10
|
+
exports.transformCommandsForRoot = transformCommandsForRoot;
|
|
11
|
+
exports.validateDependenciesLinux = validateDependenciesLinux;
|
|
12
|
+
exports.validateDependenciesWindows = validateDependenciesWindows;
|
|
13
|
+
exports.writeDockerVersion = writeDockerVersion;
|
|
14
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
15
|
+
var _path = _interopRequireDefault(require("path"));
|
|
16
|
+
var os = _interopRequireWildcard(require("os"));
|
|
17
|
+
var _child_process = _interopRequireDefault(require("child_process"));
|
|
18
|
+
var utils = _interopRequireWildcard(require("../../utils"));
|
|
19
|
+
var _spawnAsync = require("../../utils/spawnAsync");
|
|
20
|
+
var _hostPlatform = require("../../utils/hostPlatform");
|
|
21
|
+
var _ = require(".");
|
|
22
|
+
var _nativeDeps = require("./nativeDeps");
|
|
23
|
+
var _userAgent = require("../../utils/userAgent");
|
|
24
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
25
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
/**
|
|
28
|
+
* Copyright (c) Microsoft Corporation.
|
|
29
|
+
*
|
|
30
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
31
|
+
* you may not use this file except in compliance with the License.
|
|
32
|
+
* You may obtain a copy of the License at
|
|
33
|
+
*
|
|
34
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
35
|
+
*
|
|
36
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
37
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
38
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
39
|
+
* See the License for the specific language governing permissions and
|
|
40
|
+
* limitations under the License.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
const BIN_DIRECTORY = _path.default.join(__dirname, '..', '..', '..', 'bin');
|
|
44
|
+
const languageBindingVersion = process.env.PW_CLI_DISPLAY_VERSION || require('../../../package.json').version;
|
|
45
|
+
const dockerVersionFilePath = '/ms-playwright/.docker-info';
|
|
46
|
+
async function writeDockerVersion(dockerImageNameTemplate) {
|
|
47
|
+
await _fs.default.promises.mkdir(_path.default.dirname(dockerVersionFilePath), {
|
|
48
|
+
recursive: true
|
|
49
|
+
});
|
|
50
|
+
await _fs.default.promises.writeFile(dockerVersionFilePath, JSON.stringify(dockerVersion(dockerImageNameTemplate), null, 2), 'utf8');
|
|
51
|
+
// Make sure version file is globally accessible.
|
|
52
|
+
await _fs.default.promises.chmod(dockerVersionFilePath, 0o777);
|
|
53
|
+
}
|
|
54
|
+
function dockerVersion(dockerImageNameTemplate) {
|
|
55
|
+
return {
|
|
56
|
+
driverVersion: languageBindingVersion,
|
|
57
|
+
dockerImageName: dockerImageNameTemplate.replace('%version%', languageBindingVersion)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function readDockerVersionSync() {
|
|
61
|
+
try {
|
|
62
|
+
const data = JSON.parse(_fs.default.readFileSync(dockerVersionFilePath, 'utf8'));
|
|
63
|
+
return {
|
|
64
|
+
...data,
|
|
65
|
+
dockerImageNameTemplate: data.dockerImageName.replace(data.driverVersion, '%version%')
|
|
66
|
+
};
|
|
67
|
+
} catch (e) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const checkExecutable = filePath => {
|
|
72
|
+
if (process.platform === 'win32') return filePath.endsWith('.exe');
|
|
73
|
+
return _fs.default.promises.access(filePath, _fs.default.constants.X_OK).then(() => true).catch(() => false);
|
|
74
|
+
};
|
|
75
|
+
function isSupportedWindowsVersion() {
|
|
76
|
+
if (os.platform() !== 'win32' || os.arch() !== 'x64') return false;
|
|
77
|
+
const [major, minor] = os.release().split('.').map(token => parseInt(token, 10));
|
|
78
|
+
// This is based on: https://stackoverflow.com/questions/42524606/how-to-get-windows-version-using-node-js/44916050#44916050
|
|
79
|
+
// The table with versions is taken from: https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoexw#remarks
|
|
80
|
+
// Windows 7 is not supported and is encoded as `6.1`.
|
|
81
|
+
return major > 6 || major === 6 && minor > 1;
|
|
82
|
+
}
|
|
83
|
+
async function installDependenciesWindows(targets, dryRun) {
|
|
84
|
+
if (targets.has('chromium')) {
|
|
85
|
+
const command = 'powershell.exe';
|
|
86
|
+
const args = ['-ExecutionPolicy', 'Bypass', '-File', _path.default.join(BIN_DIRECTORY, 'install_media_pack.ps1')];
|
|
87
|
+
if (dryRun) {
|
|
88
|
+
console.log(`${command} ${quoteProcessArgs(args).join(' ')}`); // eslint-disable-line no-console
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const {
|
|
92
|
+
code
|
|
93
|
+
} = await (0, _spawnAsync.spawnAsync)(command, args, {
|
|
94
|
+
cwd: BIN_DIRECTORY,
|
|
95
|
+
stdio: 'inherit'
|
|
96
|
+
});
|
|
97
|
+
if (code !== 0) throw new Error('Failed to install windows dependencies!');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function installDependenciesLinux(targets, dryRun) {
|
|
101
|
+
const libraries = [];
|
|
102
|
+
const platform = _hostPlatform.hostPlatform;
|
|
103
|
+
if (!_hostPlatform.isOfficiallySupportedPlatform) console.warn(`BEWARE: your OS is not officially supported by Playwright; installing dependencies for ${platform} as a fallback.`); // eslint-disable-line no-console
|
|
104
|
+
for (const target of targets) {
|
|
105
|
+
const info = _nativeDeps.deps[platform];
|
|
106
|
+
if (!info) {
|
|
107
|
+
console.warn(`Cannot install dependencies for ${platform}!`); // eslint-disable-line no-console
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
libraries.push(...info[target]);
|
|
111
|
+
}
|
|
112
|
+
const uniqueLibraries = Array.from(new Set(libraries));
|
|
113
|
+
if (!dryRun) console.log(`Installing dependencies...`); // eslint-disable-line no-console
|
|
114
|
+
const commands = [];
|
|
115
|
+
commands.push('apt-get update');
|
|
116
|
+
commands.push(['apt-get', 'install', '-y', '--no-install-recommends', ...uniqueLibraries].join(' '));
|
|
117
|
+
const {
|
|
118
|
+
command,
|
|
119
|
+
args,
|
|
120
|
+
elevatedPermissions
|
|
121
|
+
} = await transformCommandsForRoot(commands);
|
|
122
|
+
if (dryRun) {
|
|
123
|
+
console.log(`${command} ${quoteProcessArgs(args).join(' ')}`); // eslint-disable-line no-console
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (elevatedPermissions) console.log('Switching to root user to install dependencies...'); // eslint-disable-line no-console
|
|
127
|
+
const child = _child_process.default.spawn(command, args, {
|
|
128
|
+
stdio: 'inherit'
|
|
129
|
+
});
|
|
130
|
+
await new Promise((resolve, reject) => {
|
|
131
|
+
child.on('exit', code => code === 0 ? resolve() : reject(new Error(`Installation process exited with code: ${code}`)));
|
|
132
|
+
child.on('error', reject);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
async function validateDependenciesWindows(windowsExeAndDllDirectories) {
|
|
136
|
+
const directoryPaths = windowsExeAndDllDirectories;
|
|
137
|
+
const lddPaths = [];
|
|
138
|
+
for (const directoryPath of directoryPaths) lddPaths.push(...(await executablesOrSharedLibraries(directoryPath)));
|
|
139
|
+
const allMissingDeps = await Promise.all(lddPaths.map(lddPath => missingFileDependenciesWindows(lddPath)));
|
|
140
|
+
const missingDeps = new Set();
|
|
141
|
+
for (const deps of allMissingDeps) {
|
|
142
|
+
for (const dep of deps) missingDeps.add(dep);
|
|
143
|
+
}
|
|
144
|
+
if (!missingDeps.size) return;
|
|
145
|
+
let isCrtMissing = false;
|
|
146
|
+
let isMediaFoundationMissing = false;
|
|
147
|
+
for (const dep of missingDeps) {
|
|
148
|
+
if (dep.startsWith('api-ms-win-crt') || dep === 'vcruntime140.dll' || dep === 'vcruntime140_1.dll' || dep === 'msvcp140.dll') isCrtMissing = true;else if (dep === 'mf.dll' || dep === 'mfplat.dll' || dep === 'msmpeg2vdec.dll' || dep === 'evr.dll' || dep === 'avrt.dll') isMediaFoundationMissing = true;
|
|
149
|
+
}
|
|
150
|
+
const details = [];
|
|
151
|
+
if (isCrtMissing) {
|
|
152
|
+
details.push(`Some of the Universal C Runtime files cannot be found on the system. You can fix`, `that by installing Microsoft Visual C++ Redistributable for Visual Studio from:`, `https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads`, ``);
|
|
153
|
+
}
|
|
154
|
+
if (isMediaFoundationMissing) {
|
|
155
|
+
details.push(`Some of the Media Foundation files cannot be found on the system. If you are`, `on Windows Server try fixing this by running the following command in PowerShell`, `as Administrator:`, ``, ` Install-WindowsFeature Server-Media-Foundation`, ``, `For Windows N editions visit:`, `https://support.microsoft.com/en-us/help/3145500/media-feature-pack-list-for-windows-n-editions`, ``);
|
|
156
|
+
}
|
|
157
|
+
details.push(`Full list of missing libraries:`, ` ${[...missingDeps].join('\n ')}`, ``);
|
|
158
|
+
const message = `Host system is missing dependencies!\n\n${details.join('\n')}`;
|
|
159
|
+
if (isSupportedWindowsVersion()) {
|
|
160
|
+
throw new Error(message);
|
|
161
|
+
} else {
|
|
162
|
+
// eslint-disable-next-line no-console
|
|
163
|
+
console.warn(`WARNING: running on unsupported windows version!`);
|
|
164
|
+
// eslint-disable-next-line no-console
|
|
165
|
+
console.warn(message);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async function validateDependenciesLinux(sdkLanguage, linuxLddDirectories, dlOpenLibraries) {
|
|
169
|
+
var _deps$hostPlatform, _process$getuid, _process;
|
|
170
|
+
const directoryPaths = linuxLddDirectories;
|
|
171
|
+
const lddPaths = [];
|
|
172
|
+
for (const directoryPath of directoryPaths) lddPaths.push(...(await executablesOrSharedLibraries(directoryPath)));
|
|
173
|
+
const missingDepsPerFile = await Promise.all(lddPaths.map(lddPath => missingFileDependencies(lddPath, directoryPaths)));
|
|
174
|
+
const missingDeps = new Set();
|
|
175
|
+
for (const deps of missingDepsPerFile) {
|
|
176
|
+
for (const dep of deps) missingDeps.add(dep);
|
|
177
|
+
}
|
|
178
|
+
for (const dep of await missingDLOPENLibraries(dlOpenLibraries)) missingDeps.add(dep);
|
|
179
|
+
if (!missingDeps.size) return;
|
|
180
|
+
const allMissingDeps = new Set(missingDeps);
|
|
181
|
+
// Check Ubuntu version.
|
|
182
|
+
const missingPackages = new Set();
|
|
183
|
+
const libraryToPackageNameMapping = _nativeDeps.deps[_hostPlatform.hostPlatform] ? {
|
|
184
|
+
...(((_deps$hostPlatform = _nativeDeps.deps[_hostPlatform.hostPlatform]) === null || _deps$hostPlatform === void 0 ? void 0 : _deps$hostPlatform.lib2package) || {}),
|
|
185
|
+
...MANUAL_LIBRARY_TO_PACKAGE_NAME_UBUNTU
|
|
186
|
+
} : {};
|
|
187
|
+
// Translate missing dependencies to package names to install with apt.
|
|
188
|
+
for (const missingDep of missingDeps) {
|
|
189
|
+
const packageName = libraryToPackageNameMapping[missingDep];
|
|
190
|
+
if (packageName) {
|
|
191
|
+
missingPackages.add(packageName);
|
|
192
|
+
missingDeps.delete(missingDep);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const maybeSudo = (_process$getuid = (_process = process).getuid) !== null && _process$getuid !== void 0 && _process$getuid.call(_process) && os.platform() !== 'win32' ? 'sudo ' : '';
|
|
196
|
+
const dockerInfo = readDockerVersionSync();
|
|
197
|
+
const errorLines = [`Host system is missing dependencies to run browsers.`];
|
|
198
|
+
// Ignore patch versions when comparing docker container version and Playwright version:
|
|
199
|
+
// we **NEVER** roll browsers in patch releases, so native dependencies do not change.
|
|
200
|
+
if (dockerInfo && !dockerInfo.driverVersion.startsWith((0, _userAgent.getPlaywrightVersion)(true /* majorMinorOnly */) + '.')) {
|
|
201
|
+
// We are running in a docker container with unmatching version.
|
|
202
|
+
// In this case, we know how to install dependencies in it.
|
|
203
|
+
const pwVersion = (0, _userAgent.getPlaywrightVersion)();
|
|
204
|
+
const requiredDockerImage = dockerInfo.dockerImageName.replace(dockerInfo.driverVersion, pwVersion);
|
|
205
|
+
errorLines.push(...[`This is most likely due to Docker image version not matching Playwright version:`, `- Playwright : ${pwVersion}`, `- Docker image: ${dockerInfo.driverVersion}`, ``, `Either:`, `- (recommended) use Docker image "${requiredDockerImage}"`, `- (alternative 1) run the following command inside Docker to install missing dependencies:`, ``, ` ${maybeSudo}${(0, _.buildPlaywrightCLICommand)(sdkLanguage, 'install-deps')}`, ``, `- (alternative 2) use apt inside Docker:`, ``, ` ${maybeSudo}apt-get install ${[...missingPackages].join('\\\n ')}`, ``, `<3 Playwright Team`]);
|
|
206
|
+
} else if (missingPackages.size && !missingDeps.size) {
|
|
207
|
+
// Only known dependencies are missing for browsers.
|
|
208
|
+
// Suggest installation with a Playwright CLI.
|
|
209
|
+
errorLines.push(...[`Please install them with the following command:`, ``, ` ${maybeSudo}${(0, _.buildPlaywrightCLICommand)(sdkLanguage, 'install-deps')}`, ``, `Alternatively, use apt:`, ` ${maybeSudo}apt-get install ${[...missingPackages].join('\\\n ')}`, ``, `<3 Playwright Team`]);
|
|
210
|
+
} else {
|
|
211
|
+
// Unhappy path: we either run on unknown distribution, or we failed to resolve all missing
|
|
212
|
+
// libraries to package names.
|
|
213
|
+
// Print missing libraries only:
|
|
214
|
+
errorLines.push(...[`Missing libraries:`, ...[...allMissingDeps].map(dep => ' ' + dep)]);
|
|
215
|
+
}
|
|
216
|
+
throw new Error('\n' + utils.wrapInASCIIBox(errorLines.join('\n'), 1));
|
|
217
|
+
}
|
|
218
|
+
function isSharedLib(basename) {
|
|
219
|
+
switch (os.platform()) {
|
|
220
|
+
case 'linux':
|
|
221
|
+
return basename.endsWith('.so') || basename.includes('.so.');
|
|
222
|
+
case 'win32':
|
|
223
|
+
return basename.endsWith('.dll');
|
|
224
|
+
default:
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
async function executablesOrSharedLibraries(directoryPath) {
|
|
229
|
+
if (!_fs.default.existsSync(directoryPath)) return [];
|
|
230
|
+
const allPaths = (await _fs.default.promises.readdir(directoryPath)).map(file => _path.default.resolve(directoryPath, file));
|
|
231
|
+
const allStats = await Promise.all(allPaths.map(aPath => _fs.default.promises.stat(aPath)));
|
|
232
|
+
const filePaths = allPaths.filter((aPath, index) => allStats[index].isFile());
|
|
233
|
+
const executablersOrLibraries = (await Promise.all(filePaths.map(async filePath => {
|
|
234
|
+
const basename = _path.default.basename(filePath).toLowerCase();
|
|
235
|
+
if (isSharedLib(basename)) return filePath;
|
|
236
|
+
if (await checkExecutable(filePath)) return filePath;
|
|
237
|
+
return false;
|
|
238
|
+
}))).filter(Boolean);
|
|
239
|
+
return executablersOrLibraries;
|
|
240
|
+
}
|
|
241
|
+
async function missingFileDependenciesWindows(filePath) {
|
|
242
|
+
const executable = _path.default.join(__dirname, '..', '..', '..', 'bin', 'PrintDeps.exe');
|
|
243
|
+
const dirname = _path.default.dirname(filePath);
|
|
244
|
+
const {
|
|
245
|
+
stdout,
|
|
246
|
+
code
|
|
247
|
+
} = await (0, _spawnAsync.spawnAsync)(executable, [filePath], {
|
|
248
|
+
cwd: dirname,
|
|
249
|
+
env: {
|
|
250
|
+
...process.env,
|
|
251
|
+
LD_LIBRARY_PATH: process.env.LD_LIBRARY_PATH ? `${process.env.LD_LIBRARY_PATH}:${dirname}` : dirname
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
if (code !== 0) return [];
|
|
255
|
+
const missingDeps = stdout.split('\n').map(line => line.trim()).filter(line => line.endsWith('not found') && line.includes('=>')).map(line => line.split('=>')[0].trim().toLowerCase());
|
|
256
|
+
return missingDeps;
|
|
257
|
+
}
|
|
258
|
+
async function missingFileDependencies(filePath, extraLDPaths) {
|
|
259
|
+
const dirname = _path.default.dirname(filePath);
|
|
260
|
+
let LD_LIBRARY_PATH = extraLDPaths.join(':');
|
|
261
|
+
if (process.env.LD_LIBRARY_PATH) LD_LIBRARY_PATH = `${process.env.LD_LIBRARY_PATH}:${LD_LIBRARY_PATH}`;
|
|
262
|
+
const {
|
|
263
|
+
stdout,
|
|
264
|
+
code
|
|
265
|
+
} = await (0, _spawnAsync.spawnAsync)('ldd', [filePath], {
|
|
266
|
+
cwd: dirname,
|
|
267
|
+
env: {
|
|
268
|
+
...process.env,
|
|
269
|
+
LD_LIBRARY_PATH
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
if (code !== 0) return [];
|
|
273
|
+
const missingDeps = stdout.split('\n').map(line => line.trim()).filter(line => line.endsWith('not found') && line.includes('=>')).map(line => line.split('=>')[0].trim());
|
|
274
|
+
return missingDeps;
|
|
275
|
+
}
|
|
276
|
+
async function missingDLOPENLibraries(libraries) {
|
|
277
|
+
if (!libraries.length) return [];
|
|
278
|
+
// NOTE: Using full-qualified path to `ldconfig` since `/sbin` is not part of the
|
|
279
|
+
// default PATH in CRON.
|
|
280
|
+
// @see https://github.com/microsoft/playwright/issues/3397
|
|
281
|
+
const {
|
|
282
|
+
stdout,
|
|
283
|
+
code,
|
|
284
|
+
error
|
|
285
|
+
} = await (0, _spawnAsync.spawnAsync)('/sbin/ldconfig', ['-p'], {});
|
|
286
|
+
if (code !== 0 || error) return [];
|
|
287
|
+
const isLibraryAvailable = library => stdout.toLowerCase().includes(library.toLowerCase());
|
|
288
|
+
return libraries.filter(library => !isLibraryAvailable(library));
|
|
289
|
+
}
|
|
290
|
+
const MANUAL_LIBRARY_TO_PACKAGE_NAME_UBUNTU = {
|
|
291
|
+
// libgstlibav.so (the only actual library provided by gstreamer1.0-libav) is not
|
|
292
|
+
// in the ldconfig cache, so we detect the actual library required for playing h.264
|
|
293
|
+
// and if it's missing recommend installing missing gstreamer lib.
|
|
294
|
+
// gstreamer1.0-libav -> libavcodec57 -> libx264-152
|
|
295
|
+
'libx264.so': 'gstreamer1.0-libav'
|
|
296
|
+
};
|
|
297
|
+
function quoteProcessArgs(args) {
|
|
298
|
+
return args.map(arg => {
|
|
299
|
+
if (arg.includes(' ')) return `"${arg}"`;
|
|
300
|
+
return arg;
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
async function transformCommandsForRoot(commands) {
|
|
304
|
+
var _process$getuid2, _process2;
|
|
305
|
+
const isRoot = ((_process$getuid2 = (_process2 = process).getuid) === null || _process$getuid2 === void 0 ? void 0 : _process$getuid2.call(_process2)) === 0;
|
|
306
|
+
if (isRoot) return {
|
|
307
|
+
command: 'sh',
|
|
308
|
+
args: ['-c', `${commands.join('&& ')}`],
|
|
309
|
+
elevatedPermissions: false
|
|
310
|
+
};
|
|
311
|
+
const sudoExists = await (0, _spawnAsync.spawnAsync)('which', ['sudo']);
|
|
312
|
+
if (sudoExists.code === 0) return {
|
|
313
|
+
command: 'sudo',
|
|
314
|
+
args: ['--', 'sh', '-c', `${commands.join('&& ')}`],
|
|
315
|
+
elevatedPermissions: true
|
|
316
|
+
};
|
|
317
|
+
return {
|
|
318
|
+
command: 'su',
|
|
319
|
+
args: ['root', '-c', `${commands.join('&& ')}`],
|
|
320
|
+
elevatedPermissions: true
|
|
321
|
+
};
|
|
322
|
+
}
|