patchright-bun-core 1.58.2 → 1.59.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/ThirdPartyNotices.txt +126 -650
- package/browsers.json +16 -14
- package/lib/bootstrap.js +77 -0
- package/lib/cli/browserActions.js +308 -0
- package/lib/cli/driver.js +3 -2
- package/lib/cli/installActions.js +171 -0
- package/lib/cli/program.js +47 -411
- package/lib/client/android.js +4 -4
- package/lib/client/api.js +3 -3
- package/lib/client/browser.js +8 -0
- package/lib/client/browserContext.js +18 -37
- package/lib/client/browserType.js +19 -51
- package/lib/client/cdpSession.js +6 -2
- package/lib/client/channelOwner.js +1 -1
- package/lib/client/{webSocket.js → connect.js} +57 -7
- package/lib/client/connection.js +8 -4
- package/lib/client/consoleMessage.js +3 -0
- package/lib/client/debugger.js +57 -0
- package/lib/client/dialog.js +8 -1
- package/lib/client/disposable.js +76 -0
- package/lib/client/electron.js +1 -0
- package/lib/client/elementHandle.js +1 -4
- package/lib/client/events.js +3 -3
- package/lib/client/fetch.js +0 -1
- package/lib/client/frame.js +0 -5
- package/lib/client/harRouter.js +13 -1
- package/lib/client/jsHandle.js +0 -4
- package/lib/client/locator.js +5 -7
- package/lib/client/network.js +14 -11
- package/lib/client/page.js +34 -48
- package/lib/client/platform.js +0 -3
- package/lib/client/screencast.js +88 -0
- package/lib/client/selectors.js +3 -1
- package/lib/client/tracing.js +11 -4
- package/lib/client/video.js +13 -20
- package/lib/generated/bindingsControllerSource.js +1 -1
- package/lib/generated/clockSource.js +1 -1
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/pollingRecorderSource.js +1 -1
- package/lib/generated/storageScriptSource.js +1 -1
- package/lib/generated/utilityScriptSource.js +1 -1
- package/lib/mcpBundle.js +0 -6
- package/lib/mcpBundleImpl.js +91 -0
- package/lib/protocol/validator.js +216 -118
- package/lib/protocol/validatorPrimitives.js +1 -1
- package/lib/remote/playwrightConnection.js +10 -8
- package/lib/remote/playwrightPipeServer.js +100 -0
- package/lib/remote/playwrightServer.js +13 -8
- package/lib/remote/playwrightWebSocketServer.js +73 -0
- package/lib/remote/serverTransport.js +96 -0
- package/lib/server/android/android.js +2 -2
- package/lib/server/bidi/bidiBrowser.js +30 -8
- package/lib/server/bidi/bidiChromium.js +18 -5
- package/lib/server/bidi/bidiNetworkManager.js +39 -11
- package/lib/server/bidi/bidiPage.js +31 -15
- package/lib/server/bidi/third_party/firefoxPrefs.js +3 -1
- package/lib/server/browser.js +84 -21
- package/lib/server/browserContext.js +97 -58
- package/lib/server/browserType.js +14 -12
- package/lib/server/chromium/chromium.js +15 -13
- package/lib/server/chromium/crBrowser.js +18 -10
- package/lib/server/chromium/crNetworkManager.js +4 -4
- package/lib/server/chromium/crPage.js +26 -64
- package/lib/server/chromium/crServiceWorker.js +5 -4
- package/lib/server/clock.js +33 -33
- package/lib/server/console.js +5 -1
- package/lib/server/debugController.js +12 -6
- package/lib/server/debugger.js +40 -47
- package/lib/server/deviceDescriptorsSource.json +137 -137
- package/lib/server/dispatchers/browserContextDispatcher.js +27 -30
- package/lib/server/dispatchers/browserDispatcher.js +11 -5
- package/lib/server/dispatchers/browserTypeDispatcher.js +7 -0
- package/lib/server/dispatchers/cdpSessionDispatcher.js +4 -1
- package/lib/server/dispatchers/debuggerDispatcher.js +84 -0
- package/lib/server/dispatchers/dispatcher.js +1 -1
- package/lib/server/dispatchers/disposableDispatcher.js +39 -0
- package/lib/server/dispatchers/electronDispatcher.js +2 -1
- package/lib/server/dispatchers/frameDispatcher.js +3 -3
- package/lib/server/dispatchers/localUtilsDispatcher.js +37 -1
- package/lib/server/dispatchers/networkDispatchers.js +6 -5
- package/lib/server/dispatchers/pageDispatcher.js +101 -38
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +4 -5
- package/lib/server/disposable.js +41 -0
- package/lib/server/dom.js +44 -26
- package/lib/server/download.js +3 -2
- package/lib/server/electron/electron.js +12 -7
- package/lib/server/firefox/ffBrowser.js +9 -19
- package/lib/server/firefox/ffInput.js +21 -5
- package/lib/server/firefox/ffNetworkManager.js +2 -2
- package/lib/server/firefox/ffPage.js +24 -27
- package/lib/server/frames.js +40 -11
- package/lib/server/har/harRecorder.js +2 -2
- package/lib/server/har/harTracer.js +5 -4
- package/lib/server/input.js +49 -4
- package/lib/server/instrumentation.js +5 -0
- package/lib/server/launchApp.js +0 -1
- package/lib/server/localUtils.js +6 -6
- package/lib/server/network.js +9 -8
- package/lib/server/overlay.js +138 -0
- package/lib/server/page.js +111 -51
- package/lib/server/progress.js +6 -0
- package/lib/server/recorder/recorderApp.js +9 -8
- package/lib/server/recorder.js +76 -40
- package/lib/server/registry/index.js +54 -81
- package/lib/server/registry/nativeDeps.js +1 -0
- package/lib/server/screencast.js +90 -143
- package/lib/server/trace/recorder/snapshotter.js +2 -2
- package/lib/server/trace/recorder/tracing.js +87 -36
- package/lib/server/trace/viewer/traceViewer.js +3 -4
- package/lib/server/usKeyboardLayout.js +7 -0
- package/lib/server/utils/comparators.js +1 -1
- package/lib/server/utils/disposable.js +32 -0
- package/lib/server/utils/eventsHelper.js +3 -1
- package/lib/server/utils/fileUtils.js +16 -2
- package/lib/server/utils/happyEyeballs.js +15 -12
- package/lib/server/utils/hostPlatform.js +0 -15
- package/lib/server/utils/httpServer.js +5 -3
- package/lib/server/utils/network.js +2 -1
- package/lib/server/utils/nodePlatform.js +0 -6
- package/lib/server/utils/processLauncher.js +8 -6
- package/lib/server/utils/zipFile.js +2 -2
- package/lib/server/videoRecorder.js +82 -12
- package/lib/server/webkit/wkBrowser.js +1 -6
- package/lib/server/webkit/wkPage.js +27 -25
- package/lib/server/webkit/wkWorkers.js +2 -1
- package/lib/serverRegistry.js +156 -0
- package/lib/tools/backend/browserBackend.js +79 -0
- package/lib/tools/backend/common.js +63 -0
- package/lib/tools/backend/config.js +41 -0
- package/lib/tools/backend/console.js +66 -0
- package/lib/tools/backend/context.js +296 -0
- package/lib/tools/backend/cookies.js +152 -0
- package/lib/tools/backend/devtools.js +69 -0
- package/lib/tools/backend/dialogs.js +59 -0
- package/lib/tools/backend/evaluate.js +64 -0
- package/lib/tools/backend/files.js +60 -0
- package/lib/tools/backend/form.js +64 -0
- package/lib/tools/backend/keyboard.js +155 -0
- package/lib/tools/backend/logFile.js +95 -0
- package/lib/tools/backend/mouse.js +168 -0
- package/lib/tools/backend/navigate.js +106 -0
- package/lib/tools/backend/network.js +135 -0
- package/lib/tools/backend/pdf.js +48 -0
- package/lib/tools/backend/response.js +305 -0
- package/lib/tools/backend/route.js +140 -0
- package/lib/tools/backend/runCode.js +77 -0
- package/lib/tools/backend/screenshot.js +88 -0
- package/lib/tools/backend/sessionLog.js +74 -0
- package/lib/tools/backend/snapshot.js +208 -0
- package/lib/tools/backend/storage.js +68 -0
- package/lib/tools/backend/tab.js +445 -0
- package/lib/tools/backend/tabs.js +67 -0
- package/lib/tools/backend/tool.js +47 -0
- package/lib/tools/backend/tools.js +102 -0
- package/lib/tools/backend/tracing.js +78 -0
- package/lib/tools/backend/utils.js +83 -0
- package/lib/tools/backend/verify.js +151 -0
- package/lib/tools/backend/video.js +98 -0
- package/lib/tools/backend/wait.js +63 -0
- package/lib/tools/backend/webstorage.js +223 -0
- package/lib/tools/cli-client/cli.js +6 -0
- package/lib/tools/cli-client/help.json +399 -0
- package/lib/tools/cli-client/minimist.js +128 -0
- package/lib/tools/cli-client/program.js +350 -0
- package/lib/tools/cli-client/registry.js +176 -0
- package/lib/tools/cli-client/session.js +289 -0
- package/lib/tools/cli-client/skill/SKILL.md +328 -0
- package/lib/tools/cli-client/skill/references/element-attributes.md +23 -0
- package/lib/tools/cli-client/skill/references/playwright-tests.md +39 -0
- package/lib/tools/cli-client/skill/references/request-mocking.md +87 -0
- package/lib/tools/cli-client/skill/references/running-code.md +231 -0
- package/lib/tools/cli-client/skill/references/session-management.md +169 -0
- package/lib/tools/cli-client/skill/references/storage-state.md +275 -0
- package/lib/tools/cli-client/skill/references/test-generation.md +88 -0
- package/lib/tools/cli-client/skill/references/tracing.md +139 -0
- package/lib/tools/cli-client/skill/references/video-recording.md +143 -0
- package/lib/tools/cli-daemon/command.js +73 -0
- package/lib/tools/cli-daemon/commands.js +956 -0
- package/lib/tools/cli-daemon/daemon.js +157 -0
- package/lib/tools/cli-daemon/helpGenerator.js +177 -0
- package/lib/tools/cli-daemon/program.js +129 -0
- package/lib/tools/dashboard/appIcon.png +0 -0
- package/lib/tools/dashboard/dashboardApp.js +284 -0
- package/lib/tools/dashboard/dashboardController.js +296 -0
- package/lib/tools/exports.js +60 -0
- package/lib/tools/mcp/browserFactory.js +233 -0
- package/lib/tools/mcp/cdpRelay.js +352 -0
- package/lib/tools/mcp/cli-stub.js +7 -0
- package/lib/tools/mcp/config.d.js +16 -0
- package/lib/tools/mcp/config.js +446 -0
- package/lib/tools/mcp/configIni.js +189 -0
- package/lib/tools/mcp/extensionContextFactory.js +55 -0
- package/lib/tools/mcp/index.js +62 -0
- package/lib/tools/mcp/log.js +35 -0
- package/lib/tools/mcp/program.js +107 -0
- package/lib/tools/mcp/protocol.js +28 -0
- package/lib/tools/mcp/watchdog.js +44 -0
- package/lib/tools/trace/SKILL.md +171 -0
- package/lib/{server/trace/viewer/traceParser.js → tools/trace/installSkill.js} +15 -39
- package/lib/tools/trace/traceActions.js +142 -0
- package/lib/tools/trace/traceAttachments.js +69 -0
- package/lib/tools/trace/traceCli.js +87 -0
- package/lib/tools/trace/traceConsole.js +97 -0
- package/lib/tools/trace/traceErrors.js +55 -0
- package/lib/tools/trace/traceOpen.js +69 -0
- package/lib/tools/trace/traceParser.js +96 -0
- package/lib/tools/trace/traceRequests.js +182 -0
- package/lib/tools/trace/traceScreenshot.js +68 -0
- package/lib/tools/trace/traceSnapshot.js +149 -0
- package/lib/tools/trace/traceUtils.js +153 -0
- package/lib/tools/utils/connect.js +32 -0
- package/lib/tools/utils/mcp/http.js +152 -0
- package/lib/tools/utils/mcp/server.js +230 -0
- package/lib/tools/utils/mcp/tool.js +47 -0
- package/lib/tools/utils/socketConnection.js +108 -0
- package/lib/utils/isomorphic/formatUtils.js +64 -0
- package/lib/utils/isomorphic/jsonSchema.js +89 -0
- package/lib/utils/isomorphic/mimeType.js +7 -2
- package/lib/utils/isomorphic/protocolFormatter.js +2 -2
- package/lib/utils/isomorphic/protocolMetainfo.js +127 -106
- package/lib/utils/isomorphic/stringUtils.js +3 -3
- package/lib/utils/isomorphic/timeoutRunner.js +3 -3
- package/lib/utils/isomorphic/trace/snapshotRenderer.js +35 -42
- package/lib/utils/isomorphic/trace/traceLoader.js +15 -14
- package/lib/utils/isomorphic/trace/traceModel.js +3 -2
- package/lib/utils/isomorphic/trace/traceModernizer.js +1 -0
- package/lib/utils/isomorphic/urlMatch.js +54 -1
- package/lib/utils/isomorphic/utilityScriptSerializers.js +11 -0
- package/lib/utils.js +6 -2
- package/lib/utilsBundle.js +3 -21
- package/lib/utilsBundleImpl/index.js +132 -133
- package/lib/vite/dashboard/assets/index-BAOybkp8.js +50 -0
- package/lib/vite/dashboard/assets/index-CZAYOG76.css +1 -0
- package/lib/vite/dashboard/index.html +28 -0
- package/lib/vite/htmlReport/index.html +2 -70
- package/lib/vite/htmlReport/report.css +1 -0
- package/lib/vite/htmlReport/report.js +72 -0
- package/lib/vite/recorder/assets/{codeMirrorModule-DadYNm1I.js → codeMirrorModule-C8KMvO9L.js} +20 -20
- package/lib/vite/recorder/assets/index-CqAYX1I3.js +193 -0
- package/lib/vite/recorder/index.html +1 -1
- package/lib/vite/traceViewer/assets/{codeMirrorModule-a5XoALAZ.js → codeMirrorModule-DS0FLvoc.js} +20 -20
- package/lib/vite/traceViewer/assets/defaultSettingsView-GTWI-W_B.js +262 -0
- package/lib/vite/traceViewer/defaultSettingsView.B4dS75f0.css +1 -0
- package/lib/vite/traceViewer/{index.BVu7tZDe.css → index.CzXZzn5A.css} +1 -1
- package/lib/vite/traceViewer/{index.BDwrLSGN.js → index.Dtstcb7U.js} +1 -1
- package/lib/vite/traceViewer/index.html +4 -4
- package/lib/vite/traceViewer/sw.bundle.js +4 -4
- package/lib/vite/traceViewer/uiMode.Vipi55dB.js +6 -0
- package/lib/vite/traceViewer/uiMode.html +3 -3
- package/lib/zipBundleImpl.js +2 -2
- package/lib/zodBundle.js +39 -0
- package/lib/zodBundleImpl.js +40 -0
- package/package.json +6 -1
- package/types/protocol.d.ts +947 -51
- package/types/types.d.ts +854 -74
- package/lib/client/pageAgent.js +0 -64
- package/lib/mcpBundleImpl/index.js +0 -147
- package/lib/server/agent/actionRunner.js +0 -335
- package/lib/server/agent/actions.js +0 -128
- package/lib/server/agent/codegen.js +0 -111
- package/lib/server/agent/context.js +0 -150
- package/lib/server/agent/expectTools.js +0 -156
- package/lib/server/agent/pageAgent.js +0 -204
- package/lib/server/agent/performTools.js +0 -262
- package/lib/server/agent/tool.js +0 -109
- package/lib/server/dispatchers/pageAgentDispatcher.js +0 -96
- package/lib/vite/recorder/assets/index-BhTWtUlo.js +0 -193
- package/lib/vite/traceViewer/assets/defaultSettingsView-CJSZINFr.js +0 -266
- package/lib/vite/traceViewer/defaultSettingsView.7ch9cixO.css +0 -1
- package/lib/vite/traceViewer/uiMode.CQJ9SCIQ.js +0 -5
- /package/lib/{server/utils → utils/isomorphic}/imageUtils.js +0 -0
- /package/lib/utils/isomorphic/{traceUtils.js → trace/traceUtils.js} +0 -0
package/browsers.json
CHANGED
|
@@ -3,57 +3,59 @@
|
|
|
3
3
|
"browsers": [
|
|
4
4
|
{
|
|
5
5
|
"name": "chromium",
|
|
6
|
-
"revision": "
|
|
6
|
+
"revision": "1217",
|
|
7
7
|
"installByDefault": true,
|
|
8
|
-
"browserVersion": "
|
|
8
|
+
"browserVersion": "147.0.7727.15",
|
|
9
9
|
"title": "Chrome for Testing"
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
"name": "chromium-headless-shell",
|
|
13
|
-
"revision": "
|
|
13
|
+
"revision": "1217",
|
|
14
14
|
"installByDefault": true,
|
|
15
|
-
"browserVersion": "
|
|
15
|
+
"browserVersion": "147.0.7727.15",
|
|
16
16
|
"title": "Chrome Headless Shell"
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"name": "chromium-tip-of-tree",
|
|
20
|
-
"revision": "
|
|
20
|
+
"revision": "1417",
|
|
21
21
|
"installByDefault": false,
|
|
22
|
-
"browserVersion": "
|
|
22
|
+
"browserVersion": "148.0.7755.0",
|
|
23
23
|
"title": "Chrome Canary for Testing"
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
"name": "chromium-tip-of-tree-headless-shell",
|
|
27
|
-
"revision": "
|
|
27
|
+
"revision": "1417",
|
|
28
28
|
"installByDefault": false,
|
|
29
|
-
"browserVersion": "
|
|
29
|
+
"browserVersion": "148.0.7755.0",
|
|
30
30
|
"title": "Chrome Canary Headless Shell"
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
"name": "firefox",
|
|
34
|
-
"revision": "
|
|
34
|
+
"revision": "1511",
|
|
35
35
|
"installByDefault": true,
|
|
36
|
-
"browserVersion": "
|
|
36
|
+
"browserVersion": "148.0.2",
|
|
37
37
|
"title": "Firefox"
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
"name": "firefox-beta",
|
|
41
|
-
"revision": "
|
|
41
|
+
"revision": "1505",
|
|
42
42
|
"installByDefault": false,
|
|
43
|
-
"browserVersion": "
|
|
43
|
+
"browserVersion": "148.0b9",
|
|
44
44
|
"title": "Firefox Beta"
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
"name": "webkit",
|
|
48
|
-
"revision": "
|
|
48
|
+
"revision": "2272",
|
|
49
49
|
"installByDefault": true,
|
|
50
50
|
"revisionOverrides": {
|
|
51
|
+
"mac14": "2251",
|
|
52
|
+
"mac14-arm64": "2251",
|
|
51
53
|
"debian11-x64": "2105",
|
|
52
54
|
"debian11-arm64": "2105",
|
|
53
55
|
"ubuntu20.04-x64": "2092",
|
|
54
56
|
"ubuntu20.04-arm64": "2092"
|
|
55
57
|
},
|
|
56
|
-
"browserVersion": "26.
|
|
58
|
+
"browserVersion": "26.4",
|
|
57
59
|
"title": "WebKit"
|
|
58
60
|
},
|
|
59
61
|
{
|
package/lib/bootstrap.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
if (process.env.PW_INSTRUMENT_MODULES) {
|
|
3
|
+
const Module = require("module");
|
|
4
|
+
const originalLoad = Module._load;
|
|
5
|
+
const root = { name: "<root>", selfMs: 0, totalMs: 0, childrenMs: 0, children: [] };
|
|
6
|
+
let current = root;
|
|
7
|
+
const stack = [];
|
|
8
|
+
Module._load = function(request, _parent, _isMain) {
|
|
9
|
+
const node = { name: request, selfMs: 0, totalMs: 0, childrenMs: 0, children: [] };
|
|
10
|
+
current.children.push(node);
|
|
11
|
+
stack.push(current);
|
|
12
|
+
current = node;
|
|
13
|
+
const start = performance.now();
|
|
14
|
+
let result;
|
|
15
|
+
try {
|
|
16
|
+
result = originalLoad.apply(this, arguments);
|
|
17
|
+
} catch (e) {
|
|
18
|
+
current = stack.pop();
|
|
19
|
+
current.children.pop();
|
|
20
|
+
throw e;
|
|
21
|
+
}
|
|
22
|
+
const duration = performance.now() - start;
|
|
23
|
+
node.totalMs = duration;
|
|
24
|
+
node.selfMs = Math.max(0, duration - node.childrenMs);
|
|
25
|
+
current = stack.pop();
|
|
26
|
+
current.childrenMs += duration;
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
process.on("exit", () => {
|
|
30
|
+
function printTree(node, prefix, isLast, lines2, depth) {
|
|
31
|
+
if (node.totalMs < 1 && depth > 0)
|
|
32
|
+
return;
|
|
33
|
+
const connector = depth === 0 ? "" : isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
34
|
+
const time = `${node.totalMs.toFixed(1).padStart(8)}ms`;
|
|
35
|
+
const self = node.children.length ? ` (self: ${node.selfMs.toFixed(1)}ms)` : "";
|
|
36
|
+
lines2.push(`${time} ${prefix}${connector}${node.name}${self}`);
|
|
37
|
+
const childPrefix = prefix + (depth === 0 ? "" : isLast ? " " : "\u2502 ");
|
|
38
|
+
const sorted2 = node.children.slice().sort((a, b) => b.totalMs - a.totalMs);
|
|
39
|
+
for (let i = 0; i < sorted2.length; i++)
|
|
40
|
+
printTree(sorted2[i], childPrefix, i === sorted2.length - 1, lines2, depth + 1);
|
|
41
|
+
}
|
|
42
|
+
let totalModules = 0;
|
|
43
|
+
function count(n) {
|
|
44
|
+
totalModules++;
|
|
45
|
+
n.children.forEach(count);
|
|
46
|
+
}
|
|
47
|
+
root.children.forEach(count);
|
|
48
|
+
const lines = [];
|
|
49
|
+
const sorted = root.children.slice().sort((a, b) => b.totalMs - a.totalMs);
|
|
50
|
+
for (let i = 0; i < sorted.length; i++)
|
|
51
|
+
printTree(sorted[i], "", i === sorted.length - 1, lines, 0);
|
|
52
|
+
const totalMs = root.children.reduce((s, c) => s + c.totalMs, 0);
|
|
53
|
+
process.stderr.write(`
|
|
54
|
+
--- Module load tree: ${totalModules} modules, ${totalMs.toFixed(0)}ms total ---
|
|
55
|
+
` + lines.join("\n") + "\n");
|
|
56
|
+
const flat = /* @__PURE__ */ new Map();
|
|
57
|
+
function gather(n) {
|
|
58
|
+
const existing = flat.get(n.name);
|
|
59
|
+
if (existing) {
|
|
60
|
+
existing.selfMs += n.selfMs;
|
|
61
|
+
existing.totalMs += n.totalMs;
|
|
62
|
+
existing.count++;
|
|
63
|
+
} else {
|
|
64
|
+
flat.set(n.name, { selfMs: n.selfMs, totalMs: n.totalMs, count: 1 });
|
|
65
|
+
}
|
|
66
|
+
n.children.forEach(gather);
|
|
67
|
+
}
|
|
68
|
+
root.children.forEach(gather);
|
|
69
|
+
const top50 = [...flat.entries()].sort((a, b) => b[1].selfMs - a[1].selfMs).slice(0, 50);
|
|
70
|
+
const flatLines = top50.map(
|
|
71
|
+
([mod, { selfMs, totalMs: totalMs2, count: count2 }]) => `${selfMs.toFixed(1).padStart(8)}ms self ${totalMs2.toFixed(1).padStart(8)}ms total (x${String(count2).padStart(3)}) ${mod}`
|
|
72
|
+
);
|
|
73
|
+
process.stderr.write(`
|
|
74
|
+
--- Top 50 modules by self time ---
|
|
75
|
+
` + flatLines.join("\n") + "\n");
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -0,0 +1,308 @@
|
|
|
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 browserActions_exports = {};
|
|
30
|
+
__export(browserActions_exports, {
|
|
31
|
+
codegen: () => codegen,
|
|
32
|
+
open: () => open,
|
|
33
|
+
pdf: () => pdf,
|
|
34
|
+
screenshot: () => screenshot
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(browserActions_exports);
|
|
37
|
+
var import_fs = __toESM(require("fs"));
|
|
38
|
+
var import_os = __toESM(require("os"));
|
|
39
|
+
var import_path = __toESM(require("path"));
|
|
40
|
+
var playwright = __toESM(require("../.."));
|
|
41
|
+
var import_utils = require("../utils");
|
|
42
|
+
var import_utilsBundle = require("../utilsBundle");
|
|
43
|
+
async function launchContext(options, extraOptions) {
|
|
44
|
+
validateOptions(options);
|
|
45
|
+
const browserType = lookupBrowserType(options);
|
|
46
|
+
const launchOptions = extraOptions;
|
|
47
|
+
if (options.channel)
|
|
48
|
+
launchOptions.channel = options.channel;
|
|
49
|
+
launchOptions.handleSIGINT = false;
|
|
50
|
+
const contextOptions = (
|
|
51
|
+
// Copy the device descriptor since we have to compare and modify the options.
|
|
52
|
+
options.device ? { ...playwright.devices[options.device] } : {}
|
|
53
|
+
);
|
|
54
|
+
if (!extraOptions.headless)
|
|
55
|
+
contextOptions.deviceScaleFactor = import_os.default.platform() === "darwin" ? 2 : 1;
|
|
56
|
+
if (browserType.name() === "webkit" && process.platform === "linux") {
|
|
57
|
+
delete contextOptions.hasTouch;
|
|
58
|
+
delete contextOptions.isMobile;
|
|
59
|
+
}
|
|
60
|
+
if (contextOptions.isMobile && browserType.name() === "firefox")
|
|
61
|
+
contextOptions.isMobile = void 0;
|
|
62
|
+
if (options.blockServiceWorkers)
|
|
63
|
+
contextOptions.serviceWorkers = "block";
|
|
64
|
+
if (options.proxyServer) {
|
|
65
|
+
launchOptions.proxy = {
|
|
66
|
+
server: options.proxyServer
|
|
67
|
+
};
|
|
68
|
+
if (options.proxyBypass)
|
|
69
|
+
launchOptions.proxy.bypass = options.proxyBypass;
|
|
70
|
+
}
|
|
71
|
+
if (options.viewportSize) {
|
|
72
|
+
try {
|
|
73
|
+
const [width, height] = options.viewportSize.split(",").map((n) => +n);
|
|
74
|
+
if (isNaN(width) || isNaN(height))
|
|
75
|
+
throw new Error("bad values");
|
|
76
|
+
contextOptions.viewport = { width, height };
|
|
77
|
+
} catch (e) {
|
|
78
|
+
throw new Error('Invalid viewport size format: use "width,height", for example --viewport-size="800,600"');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (options.geolocation) {
|
|
82
|
+
try {
|
|
83
|
+
const [latitude, longitude] = options.geolocation.split(",").map((n) => parseFloat(n.trim()));
|
|
84
|
+
contextOptions.geolocation = {
|
|
85
|
+
latitude,
|
|
86
|
+
longitude
|
|
87
|
+
};
|
|
88
|
+
} catch (e) {
|
|
89
|
+
throw new Error('Invalid geolocation format, should be "lat,long". For example --geolocation="37.819722,-122.478611"');
|
|
90
|
+
}
|
|
91
|
+
contextOptions.permissions = ["geolocation"];
|
|
92
|
+
}
|
|
93
|
+
if (options.userAgent)
|
|
94
|
+
contextOptions.userAgent = options.userAgent;
|
|
95
|
+
if (options.lang)
|
|
96
|
+
contextOptions.locale = options.lang;
|
|
97
|
+
if (options.colorScheme)
|
|
98
|
+
contextOptions.colorScheme = options.colorScheme;
|
|
99
|
+
if (options.timezone)
|
|
100
|
+
contextOptions.timezoneId = options.timezone;
|
|
101
|
+
if (options.loadStorage)
|
|
102
|
+
contextOptions.storageState = options.loadStorage;
|
|
103
|
+
if (options.ignoreHttpsErrors)
|
|
104
|
+
contextOptions.ignoreHTTPSErrors = true;
|
|
105
|
+
if (options.saveHar) {
|
|
106
|
+
contextOptions.recordHar = { path: import_path.default.resolve(process.cwd(), options.saveHar), mode: "minimal" };
|
|
107
|
+
if (options.saveHarGlob)
|
|
108
|
+
contextOptions.recordHar.urlFilter = options.saveHarGlob;
|
|
109
|
+
contextOptions.serviceWorkers = "block";
|
|
110
|
+
}
|
|
111
|
+
let browser;
|
|
112
|
+
let context;
|
|
113
|
+
if (options.userDataDir) {
|
|
114
|
+
context = await browserType.launchPersistentContext(options.userDataDir, { ...launchOptions, ...contextOptions });
|
|
115
|
+
browser = context.browser();
|
|
116
|
+
} else {
|
|
117
|
+
browser = await browserType.launch(launchOptions);
|
|
118
|
+
context = await browser.newContext(contextOptions);
|
|
119
|
+
}
|
|
120
|
+
let closingBrowser = false;
|
|
121
|
+
async function closeBrowser() {
|
|
122
|
+
if (closingBrowser)
|
|
123
|
+
return;
|
|
124
|
+
closingBrowser = true;
|
|
125
|
+
if (options.saveStorage)
|
|
126
|
+
await context.storageState({ path: options.saveStorage }).catch((e) => null);
|
|
127
|
+
if (options.saveHar)
|
|
128
|
+
await context.close();
|
|
129
|
+
await browser.close();
|
|
130
|
+
}
|
|
131
|
+
context.on("page", (page) => {
|
|
132
|
+
page.on("dialog", () => {
|
|
133
|
+
});
|
|
134
|
+
page.on("close", () => {
|
|
135
|
+
const hasPage = browser.contexts().some((context2) => context2.pages().length > 0);
|
|
136
|
+
if (hasPage)
|
|
137
|
+
return;
|
|
138
|
+
closeBrowser().catch(() => {
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
process.on("SIGINT", async () => {
|
|
143
|
+
await closeBrowser();
|
|
144
|
+
(0, import_utils.gracefullyProcessExitDoNotHang)(130);
|
|
145
|
+
});
|
|
146
|
+
const timeout = options.timeout ? parseInt(options.timeout, 10) : 0;
|
|
147
|
+
context.setDefaultTimeout(timeout);
|
|
148
|
+
context.setDefaultNavigationTimeout(timeout);
|
|
149
|
+
delete launchOptions.headless;
|
|
150
|
+
delete launchOptions.executablePath;
|
|
151
|
+
delete launchOptions.handleSIGINT;
|
|
152
|
+
delete contextOptions.deviceScaleFactor;
|
|
153
|
+
return { browser, browserName: browserType.name(), context, contextOptions, launchOptions, closeBrowser };
|
|
154
|
+
}
|
|
155
|
+
async function openPage(context, url) {
|
|
156
|
+
let page = context.pages()[0];
|
|
157
|
+
if (!page)
|
|
158
|
+
page = await context.newPage();
|
|
159
|
+
if (url) {
|
|
160
|
+
if (import_fs.default.existsSync(url))
|
|
161
|
+
url = "file://" + import_path.default.resolve(url);
|
|
162
|
+
else if (!url.startsWith("http") && !url.startsWith("file://") && !url.startsWith("about:") && !url.startsWith("data:"))
|
|
163
|
+
url = "http://" + url;
|
|
164
|
+
await page.goto(url);
|
|
165
|
+
}
|
|
166
|
+
return page;
|
|
167
|
+
}
|
|
168
|
+
async function open(options, url) {
|
|
169
|
+
const { context } = await launchContext(options, { headless: !!process.env.PWTEST_CLI_HEADLESS, executablePath: process.env.PWTEST_CLI_EXECUTABLE_PATH });
|
|
170
|
+
await context._exposeConsoleApi();
|
|
171
|
+
await openPage(context, url);
|
|
172
|
+
}
|
|
173
|
+
async function codegen(options, url) {
|
|
174
|
+
const { target: language, output: outputFile, testIdAttribute: testIdAttributeName } = options;
|
|
175
|
+
const tracesDir = import_path.default.join(import_os.default.tmpdir(), `playwright-recorder-trace-${Date.now()}`);
|
|
176
|
+
const { context, browser, launchOptions, contextOptions, closeBrowser } = await launchContext(options, {
|
|
177
|
+
headless: !!process.env.PWTEST_CLI_HEADLESS,
|
|
178
|
+
executablePath: process.env.PWTEST_CLI_EXECUTABLE_PATH,
|
|
179
|
+
tracesDir
|
|
180
|
+
});
|
|
181
|
+
const donePromise = new import_utils.ManualPromise();
|
|
182
|
+
maybeSetupTestHooks(browser, closeBrowser, donePromise);
|
|
183
|
+
import_utilsBundle.dotenv.config({ path: "playwright.env" });
|
|
184
|
+
await context._enableRecorder({
|
|
185
|
+
language,
|
|
186
|
+
launchOptions,
|
|
187
|
+
contextOptions,
|
|
188
|
+
device: options.device,
|
|
189
|
+
saveStorage: options.saveStorage,
|
|
190
|
+
mode: "recording",
|
|
191
|
+
testIdAttributeName,
|
|
192
|
+
outputFile: outputFile ? import_path.default.resolve(outputFile) : void 0,
|
|
193
|
+
handleSIGINT: false
|
|
194
|
+
});
|
|
195
|
+
await openPage(context, url);
|
|
196
|
+
donePromise.resolve();
|
|
197
|
+
}
|
|
198
|
+
async function maybeSetupTestHooks(browser, closeBrowser, donePromise) {
|
|
199
|
+
if (!process.env.PWTEST_CLI_IS_UNDER_TEST)
|
|
200
|
+
return;
|
|
201
|
+
const logs = [];
|
|
202
|
+
require("playwright-core/lib/utilsBundle").debug.log = (...args) => {
|
|
203
|
+
const line = require("util").format(...args) + "\n";
|
|
204
|
+
logs.push(line);
|
|
205
|
+
process.stderr.write(line);
|
|
206
|
+
};
|
|
207
|
+
browser.on("disconnected", () => {
|
|
208
|
+
const hasCrashLine = logs.some((line) => line.includes("process did exit:") && !line.includes("process did exit: exitCode=0, signal=null"));
|
|
209
|
+
if (hasCrashLine) {
|
|
210
|
+
process.stderr.write("Detected browser crash.\n");
|
|
211
|
+
(0, import_utils.gracefullyProcessExitDoNotHang)(1);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
const close = async () => {
|
|
215
|
+
await donePromise;
|
|
216
|
+
await closeBrowser();
|
|
217
|
+
};
|
|
218
|
+
if (process.env.PWTEST_CLI_EXIT_AFTER_TIMEOUT) {
|
|
219
|
+
setTimeout(close, +process.env.PWTEST_CLI_EXIT_AFTER_TIMEOUT);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
let stdin = "";
|
|
223
|
+
process.stdin.on("data", (data) => {
|
|
224
|
+
stdin += data.toString();
|
|
225
|
+
if (stdin.startsWith("exit")) {
|
|
226
|
+
process.stdin.destroy();
|
|
227
|
+
close();
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
async function waitForPage(page, captureOptions) {
|
|
232
|
+
if (captureOptions.waitForSelector) {
|
|
233
|
+
console.log(`Waiting for selector ${captureOptions.waitForSelector}...`);
|
|
234
|
+
await page.waitForSelector(captureOptions.waitForSelector);
|
|
235
|
+
}
|
|
236
|
+
if (captureOptions.waitForTimeout) {
|
|
237
|
+
console.log(`Waiting for timeout ${captureOptions.waitForTimeout}...`);
|
|
238
|
+
await page.waitForTimeout(parseInt(captureOptions.waitForTimeout, 10));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
async function screenshot(options, captureOptions, url, path2) {
|
|
242
|
+
const { context } = await launchContext(options, { headless: true });
|
|
243
|
+
console.log("Navigating to " + url);
|
|
244
|
+
const page = await openPage(context, url);
|
|
245
|
+
await waitForPage(page, captureOptions);
|
|
246
|
+
console.log("Capturing screenshot into " + path2);
|
|
247
|
+
await page.screenshot({ path: path2, fullPage: !!captureOptions.fullPage });
|
|
248
|
+
await page.close();
|
|
249
|
+
}
|
|
250
|
+
async function pdf(options, captureOptions, url, path2) {
|
|
251
|
+
if (options.browser !== "chromium")
|
|
252
|
+
throw new Error("PDF creation is only working with Chromium");
|
|
253
|
+
const { context } = await launchContext({ ...options, browser: "chromium" }, { headless: true });
|
|
254
|
+
console.log("Navigating to " + url);
|
|
255
|
+
const page = await openPage(context, url);
|
|
256
|
+
await waitForPage(page, captureOptions);
|
|
257
|
+
console.log("Saving as pdf into " + path2);
|
|
258
|
+
await page.pdf({ path: path2, format: captureOptions.paperFormat });
|
|
259
|
+
await page.close();
|
|
260
|
+
}
|
|
261
|
+
function lookupBrowserType(options) {
|
|
262
|
+
let name = options.browser;
|
|
263
|
+
if (options.device) {
|
|
264
|
+
const device = playwright.devices[options.device];
|
|
265
|
+
name = device.defaultBrowserType;
|
|
266
|
+
}
|
|
267
|
+
let browserType;
|
|
268
|
+
switch (name) {
|
|
269
|
+
case "chromium":
|
|
270
|
+
browserType = playwright.chromium;
|
|
271
|
+
break;
|
|
272
|
+
case "webkit":
|
|
273
|
+
browserType = playwright.webkit;
|
|
274
|
+
break;
|
|
275
|
+
case "firefox":
|
|
276
|
+
browserType = playwright.firefox;
|
|
277
|
+
break;
|
|
278
|
+
case "cr":
|
|
279
|
+
browserType = playwright.chromium;
|
|
280
|
+
break;
|
|
281
|
+
case "wk":
|
|
282
|
+
browserType = playwright.webkit;
|
|
283
|
+
break;
|
|
284
|
+
case "ff":
|
|
285
|
+
browserType = playwright.firefox;
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
if (browserType)
|
|
289
|
+
return browserType;
|
|
290
|
+
import_utilsBundle.program.help();
|
|
291
|
+
}
|
|
292
|
+
function validateOptions(options) {
|
|
293
|
+
if (options.device && !(options.device in playwright.devices)) {
|
|
294
|
+
const lines = [`Device descriptor not found: '${options.device}', available devices are:`];
|
|
295
|
+
for (const name in playwright.devices)
|
|
296
|
+
lines.push(` "${name}"`);
|
|
297
|
+
throw new Error(lines.join("\n"));
|
|
298
|
+
}
|
|
299
|
+
if (options.colorScheme && !["light", "dark"].includes(options.colorScheme))
|
|
300
|
+
throw new Error('Invalid color scheme, should be one of "light", "dark"');
|
|
301
|
+
}
|
|
302
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
303
|
+
0 && (module.exports = {
|
|
304
|
+
codegen,
|
|
305
|
+
open,
|
|
306
|
+
pdf,
|
|
307
|
+
screenshot
|
|
308
|
+
});
|
package/lib/cli/driver.js
CHANGED
|
@@ -72,9 +72,10 @@ async function runServer(options) {
|
|
|
72
72
|
host,
|
|
73
73
|
path = "/",
|
|
74
74
|
maxConnections = Infinity,
|
|
75
|
-
extension
|
|
75
|
+
extension,
|
|
76
|
+
artifactsDir
|
|
76
77
|
} = options;
|
|
77
|
-
const server = new import_playwrightServer.PlaywrightServer({ mode: extension ? "extension" : "default", path, maxConnections });
|
|
78
|
+
const server = new import_playwrightServer.PlaywrightServer({ mode: extension ? "extension" : "default", path, maxConnections, artifactsDir });
|
|
78
79
|
const wsEndpoint = await server.listen(port, host);
|
|
79
80
|
process.on("exit", () => server.close().catch(console.error));
|
|
80
81
|
console.log("Listening on " + wsEndpoint);
|
|
@@ -0,0 +1,171 @@
|
|
|
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 installActions_exports = {};
|
|
30
|
+
__export(installActions_exports, {
|
|
31
|
+
installBrowsers: () => installBrowsers,
|
|
32
|
+
installDeps: () => installDeps,
|
|
33
|
+
markDockerImage: () => markDockerImage,
|
|
34
|
+
registry: () => import_server.registry,
|
|
35
|
+
uninstallBrowsers: () => uninstallBrowsers
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(installActions_exports);
|
|
38
|
+
var import_path = __toESM(require("path"));
|
|
39
|
+
var import_server = require("../server");
|
|
40
|
+
var import_utils = require("../utils");
|
|
41
|
+
var import_utils2 = require("../utils");
|
|
42
|
+
var import_ascii = require("../server/utils/ascii");
|
|
43
|
+
function printInstalledBrowsers(browsers) {
|
|
44
|
+
const browserPaths = /* @__PURE__ */ new Set();
|
|
45
|
+
for (const browser of browsers)
|
|
46
|
+
browserPaths.add(browser.browserPath);
|
|
47
|
+
console.log(` Browsers:`);
|
|
48
|
+
for (const browserPath of [...browserPaths].sort())
|
|
49
|
+
console.log(` ${browserPath}`);
|
|
50
|
+
console.log(` References:`);
|
|
51
|
+
const references = /* @__PURE__ */ new Set();
|
|
52
|
+
for (const browser of browsers)
|
|
53
|
+
references.add(browser.referenceDir);
|
|
54
|
+
for (const reference of [...references].sort())
|
|
55
|
+
console.log(` ${reference}`);
|
|
56
|
+
}
|
|
57
|
+
function printGroupedByPlaywrightVersion(browsers) {
|
|
58
|
+
const dirToVersion = /* @__PURE__ */ new Map();
|
|
59
|
+
for (const browser of browsers) {
|
|
60
|
+
if (dirToVersion.has(browser.referenceDir))
|
|
61
|
+
continue;
|
|
62
|
+
const packageJSON = require(import_path.default.join(browser.referenceDir, "package.json"));
|
|
63
|
+
const version = packageJSON.version;
|
|
64
|
+
dirToVersion.set(browser.referenceDir, version);
|
|
65
|
+
}
|
|
66
|
+
const groupedByPlaywrightMinorVersion = /* @__PURE__ */ new Map();
|
|
67
|
+
for (const browser of browsers) {
|
|
68
|
+
const version = dirToVersion.get(browser.referenceDir);
|
|
69
|
+
let entries = groupedByPlaywrightMinorVersion.get(version);
|
|
70
|
+
if (!entries) {
|
|
71
|
+
entries = [];
|
|
72
|
+
groupedByPlaywrightMinorVersion.set(version, entries);
|
|
73
|
+
}
|
|
74
|
+
entries.push(browser);
|
|
75
|
+
}
|
|
76
|
+
const sortedVersions = [...groupedByPlaywrightMinorVersion.keys()].sort((a, b) => {
|
|
77
|
+
const aComponents = a.split(".");
|
|
78
|
+
const bComponents = b.split(".");
|
|
79
|
+
const aMajor = parseInt(aComponents[0], 10);
|
|
80
|
+
const bMajor = parseInt(bComponents[0], 10);
|
|
81
|
+
if (aMajor !== bMajor)
|
|
82
|
+
return aMajor - bMajor;
|
|
83
|
+
const aMinor = parseInt(aComponents[1], 10);
|
|
84
|
+
const bMinor = parseInt(bComponents[1], 10);
|
|
85
|
+
if (aMinor !== bMinor)
|
|
86
|
+
return aMinor - bMinor;
|
|
87
|
+
return aComponents.slice(2).join(".").localeCompare(bComponents.slice(2).join("."));
|
|
88
|
+
});
|
|
89
|
+
for (const version of sortedVersions) {
|
|
90
|
+
console.log(`
|
|
91
|
+
Playwright version: ${version}`);
|
|
92
|
+
printInstalledBrowsers(groupedByPlaywrightMinorVersion.get(version));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async function markDockerImage(dockerImageNameTemplate) {
|
|
96
|
+
(0, import_utils2.assert)(dockerImageNameTemplate, "dockerImageNameTemplate is required");
|
|
97
|
+
await (0, import_server.writeDockerVersion)(dockerImageNameTemplate);
|
|
98
|
+
}
|
|
99
|
+
async function installBrowsers(args, options) {
|
|
100
|
+
if ((0, import_utils.isLikelyNpxGlobal)()) {
|
|
101
|
+
console.error((0, import_ascii.wrapInASCIIBox)([
|
|
102
|
+
`WARNING: It looks like you are running 'npx playwright install' without first`,
|
|
103
|
+
`installing your project's dependencies.`,
|
|
104
|
+
``,
|
|
105
|
+
`To avoid unexpected behavior, please install your dependencies first, and`,
|
|
106
|
+
`then run Playwright's install command:`,
|
|
107
|
+
``,
|
|
108
|
+
` npm install`,
|
|
109
|
+
` npx playwright install`,
|
|
110
|
+
``,
|
|
111
|
+
`If your project does not yet depend on Playwright, first install the`,
|
|
112
|
+
`applicable npm package (most commonly @playwright/test), and`,
|
|
113
|
+
`then run Playwright's install command to download the browsers:`,
|
|
114
|
+
``,
|
|
115
|
+
` npm install @playwright/test`,
|
|
116
|
+
` npx playwright install`,
|
|
117
|
+
``
|
|
118
|
+
].join("\n"), 1));
|
|
119
|
+
}
|
|
120
|
+
if (options.shell === false && options.onlyShell)
|
|
121
|
+
throw new Error(`Only one of --no-shell and --only-shell can be specified`);
|
|
122
|
+
const shell = options.shell === false ? "no" : options.onlyShell ? "only" : void 0;
|
|
123
|
+
const executables = import_server.registry.resolveBrowsers(args, { shell });
|
|
124
|
+
if (options.withDeps)
|
|
125
|
+
await import_server.registry.installDeps(executables, !!options.dryRun);
|
|
126
|
+
if (options.dryRun && options.list)
|
|
127
|
+
throw new Error(`Only one of --dry-run and --list can be specified`);
|
|
128
|
+
if (options.dryRun) {
|
|
129
|
+
for (const executable of executables) {
|
|
130
|
+
console.log(import_server.registry.calculateDownloadTitle(executable));
|
|
131
|
+
console.log(` Install location: ${executable.directory ?? "<system>"}`);
|
|
132
|
+
if (executable.downloadURLs?.length) {
|
|
133
|
+
const [url, ...fallbacks] = executable.downloadURLs;
|
|
134
|
+
console.log(` Download url: ${url}`);
|
|
135
|
+
for (let i = 0; i < fallbacks.length; ++i)
|
|
136
|
+
console.log(` Download fallback ${i + 1}: ${fallbacks[i]}`);
|
|
137
|
+
}
|
|
138
|
+
console.log(``);
|
|
139
|
+
}
|
|
140
|
+
} else if (options.list) {
|
|
141
|
+
const browsers = await import_server.registry.listInstalledBrowsers();
|
|
142
|
+
printGroupedByPlaywrightVersion(browsers);
|
|
143
|
+
} else {
|
|
144
|
+
await import_server.registry.install(executables, { force: options.force });
|
|
145
|
+
await import_server.registry.validateHostRequirementsForExecutablesIfNeeded(executables, process.env.PW_LANG_NAME || "javascript").catch((e) => {
|
|
146
|
+
e.name = "Playwright Host validation warning";
|
|
147
|
+
console.error(e);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async function uninstallBrowsers(options) {
|
|
152
|
+
delete process.env.PLAYWRIGHT_SKIP_BROWSER_GC;
|
|
153
|
+
await import_server.registry.uninstall(!!options.all).then(({ numberOfBrowsersLeft }) => {
|
|
154
|
+
if (!options.all && numberOfBrowsersLeft > 0) {
|
|
155
|
+
console.log("Successfully uninstalled Playwright browsers for the current Playwright installation.");
|
|
156
|
+
console.log(`There are still ${numberOfBrowsersLeft} browsers left, used by other Playwright installations.
|
|
157
|
+
To uninstall Playwright browsers for all installations, re-run with --all flag.`);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
async function installDeps(args, options) {
|
|
162
|
+
await import_server.registry.installDeps(import_server.registry.resolveBrowsers(args, {}), !!options.dryRun);
|
|
163
|
+
}
|
|
164
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
165
|
+
0 && (module.exports = {
|
|
166
|
+
installBrowsers,
|
|
167
|
+
installDeps,
|
|
168
|
+
markDockerImage,
|
|
169
|
+
registry,
|
|
170
|
+
uninstallBrowsers
|
|
171
|
+
});
|