@checkly/playwright-core 1.48.21 → 1.48.22-beta.1
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/lib/cli/cli.js +61 -0
- package/lib/common/debugLogger.js +90 -0
- package/lib/generated/clockSource.js +2 -1
- package/lib/generated/consoleApiSource.js +2 -1
- package/lib/generated/injectedScriptSource.js +2 -1
- package/lib/generated/pollingRecorderSource.js +2 -1
- package/lib/generated/recorderSource.js +1 -1
- package/lib/generated/utilityScriptSource.js +2 -1
- package/lib/generated/webSocketMockSource.js +2 -1
- package/lib/server/recorder/java.js +4 -36
- package/lib/server/trace/recorder/tracing.js +22 -17
- package/lib/vite/{traceViewer/assets/codeMirrorModule-U6XMqGkV.js → recorder/assets/codeMirrorModule--bQcPrZ2.js} +2 -2
- package/lib/vite/recorder/assets/codeMirrorModule-Cy8X9Wtw.css +344 -0
- package/lib/vite/recorder/assets/index-BMeslH8X.js +9946 -0
- package/lib/vite/recorder/assets/index-BjXmTggo.css +2515 -0
- package/lib/vite/recorder/index.html +2 -2
- package/lib/vite/traceViewer/assets/codeMirrorModule-75b0ca4f.js +24 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-CBokkFJ2.js +16431 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-CNHvVrFd.js +16437 -0
- package/lib/vite/traceViewer/assets/{codeMirrorModule-BdBhzV6t.js → codeMirrorModule-CpGx_S8D.js} +2 -2
- package/lib/vite/traceViewer/assets/codeMirrorModule-SomGa-Da.js +16443 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-c1454a2e.js +24 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-c9bb9834.js +24 -0
- package/lib/vite/traceViewer/assets/{codeMirrorModule-Dx6AXgMV.js → codeMirrorModule-cc2329e4.js} +11 -1256
- package/lib/vite/traceViewer/assets/codeMirrorModule-d2cc7db0.js +15579 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-da915a35.js +15586 -0
- package/lib/vite/traceViewer/assets/{codeMirrorModule-CcviAl53.js → codeMirrorModule-f03b1a3e.js} +1118 -2370
- package/lib/vite/traceViewer/assets/codeMirrorModule-f333a775.js +24 -0
- package/lib/vite/traceViewer/assets/{codeMirrorModule-V7N6ppkd.js → codeMirrorModule-uWDlVSQz.js} +2 -2
- package/lib/vite/{recorder/assets/codeMirrorModule-d0KhC1qL.js → traceViewer/assets/codeMirrorModule-xvopPhZ4.js} +1 -1
- package/lib/vite/traceViewer/assets/{codeMirrorModule-BqcXH1AO.js → codeMirrorModule-yboVpgC0.js} +2 -1248
- package/lib/vite/traceViewer/assets/{inspectorTab-DpvLVMq5.js → inspectorTab-B4ynvyY9.js} +18 -8
- package/lib/vite/traceViewer/assets/{inspectorTab-BPzVEZSf.js → inspectorTab-BqBvUFio.js} +18 -8
- package/lib/vite/traceViewer/assets/{workbench-Bjkiwcr1.js → inspectorTab-Dw0Gnh1T.js} +1847 -3605
- package/lib/vite/traceViewer/assets/{inspectorTab-BABZNwlH.js → inspectorTab-Ywa000c9.js} +16 -6
- package/lib/vite/traceViewer/assets/{inspectorTab-BHcfR9dD.js → inspectorTab-wfvwpMHs.js} +2 -2
- package/lib/vite/traceViewer/assets/{workbench-BcgGQnKb.js → workbench-CROk6Fcc.js} +2 -2
- package/lib/vite/traceViewer/assets/{workbench-ByyWxoT8.js → workbench-CfXOj3eT.js} +2 -2
- package/lib/vite/traceViewer/assets/{workbench-DhqI6jeL.js → workbench-D9CTkv-4.js} +2 -2
- package/lib/vite/traceViewer/assets/{workbench-I4s6sWjN.js → workbench-DNolpp3y.js} +1 -1
- package/lib/vite/traceViewer/assets/workbench-DUc2iD0P.js +1473 -0
- package/lib/vite/traceViewer/assets/{workbench-B13nfocr.js → workbench-LKskf2Iy.js} +1 -1
- package/lib/vite/traceViewer/assets/workbench-dnZM5a7x.js +1473 -0
- package/lib/vite/traceViewer/assets/wsPort-54626118.js +18361 -0
- package/lib/vite/traceViewer/assets/{workbench-Crj6jzdv.js → wsPort-57f274c6.js} +4308 -5066
- package/lib/vite/traceViewer/assets/wsPort-762c6840.js +64 -0
- package/lib/vite/traceViewer/assets/wsPort-85286e61.js +18361 -0
- package/lib/vite/traceViewer/assets/wsPort-98e00a94.js +64 -0
- package/lib/vite/traceViewer/assets/{wsPort-EUvw-dwH.js → wsPort-CAXygIGt.js} +3 -3
- package/lib/vite/traceViewer/assets/{workbench-C5OQh9VX.js → wsPort-cc0077b5.js} +4046 -4623
- package/lib/vite/traceViewer/assets/wsPort-edfeeb7d.js +64 -0
- package/lib/vite/traceViewer/assets/wsPort-ee2830d7.js +64 -0
- package/lib/vite/traceViewer/assets/{workbench-BwodYCgl.js → wsPort-peeLnQhT.js} +985 -1540
- package/lib/vite/traceViewer/assets/xtermModule-443332e6.js +9 -0
- package/lib/vite/traceViewer/assets/xtermModule-60687b6b.js +6410 -0
- package/lib/vite/traceViewer/codeMirrorModule.5d0f417c.css +1 -0
- package/lib/vite/traceViewer/codeMirrorModule.eb494ea9.css +344 -0
- package/lib/vite/traceViewer/codicon.79f233d0.ttf +0 -0
- package/lib/vite/traceViewer/{embedded.27BGR_eD.js → embedded.6N1v7bZ1.js} +4 -3
- package/lib/vite/traceViewer/{embedded.DTjd2aiy.js → embedded.BOw0jX78.js} +4 -3
- package/lib/vite/traceViewer/{embedded.Dxe2heQk.js → embedded.BXYl5zRv.js} +1 -1
- package/lib/vite/traceViewer/{embedded.SsjKHrxC.js → embedded.BaqdbLsy.js} +4 -3
- package/lib/vite/traceViewer/embedded.CwwTDBzP.js +106 -0
- package/lib/vite/traceViewer/{embedded.Zu332ZC1.js → embedded.DeCrOtlO.js} +2 -2
- package/lib/vite/traceViewer/embedded.html +6 -6
- package/lib/vite/traceViewer/embedded.i_k4ceMJ.js +106 -0
- package/lib/vite/traceViewer/index.1a1fe659.css +1 -0
- package/lib/vite/traceViewer/index.1b525c1c.js +181 -0
- package/lib/vite/traceViewer/index.55e65778.js +181 -0
- package/lib/vite/traceViewer/{index.6KJ-JQ0L.js → index.5nqVcfiC.js} +2 -2
- package/lib/vite/traceViewer/{index.C0EgJ4oW.js → index.5ooko4n7.js} +21 -36
- package/lib/vite/traceViewer/index.76e9f312.css +124 -0
- package/lib/vite/traceViewer/{index.Dz3icWJV.js → index.Bugo2TbS.js} +4 -3
- package/lib/vite/traceViewer/{index.PqcsvBxQ.js → index.BzvnAP7t.js} +4 -3
- package/lib/vite/traceViewer/{index.CLxsp2W_.js → index.CM_h9lHr.js} +2 -2
- package/lib/vite/traceViewer/{index.yxAwzeWG.js → index.CY13pBr8.js} +4 -3
- package/lib/vite/traceViewer/index.DW2ZzZfL.js +197 -0
- package/lib/vite/traceViewer/{index.CB297BuW.js → index.DZkJsFod.js} +1 -1
- package/lib/vite/traceViewer/index.DblJtEW_.js +197 -0
- package/lib/vite/traceViewer/index.a265fbdb.js +2 -0
- package/lib/vite/traceViewer/index.c9f6fa8f.js +2 -0
- package/lib/vite/traceViewer/index.d86e70ca.js +181 -0
- package/lib/vite/traceViewer/index.decad628.js +2 -0
- package/lib/vite/traceViewer/index.e8730524.js +181 -0
- package/lib/vite/traceViewer/index.ed9a3c58.js +2 -0
- package/lib/vite/traceViewer/index.html +7 -7
- package/lib/vite/traceViewer/{recorder.BufKu9Hp.js → recorder.3Xfrl_zV.js} +3 -2
- package/lib/vite/traceViewer/{recorder.am-MV-DQ.js → recorder.B76AH9PE.js} +3 -2
- package/lib/vite/traceViewer/{recorder.C88JDknq.js → recorder.BVExlUUk.js} +1 -1
- package/lib/vite/traceViewer/{recorder.7Wl6HrQl.js → recorder.Db1aK_DY.js} +3 -2
- package/lib/vite/traceViewer/recorder.html +4 -4
- package/lib/vite/traceViewer/recorder.uj3cfoMf.js +551 -0
- package/lib/vite/traceViewer/uiMode.08ab2d90.js +4 -0
- package/lib/vite/traceViewer/uiMode.0d0d667b.js +4 -0
- package/lib/vite/traceViewer/uiMode.216233d5.js +1484 -0
- package/lib/vite/traceViewer/{uiMode.DVWUEIHq.css → uiMode.2c31018f.css} +88 -188
- package/lib/vite/traceViewer/uiMode.3ff70f7d.js +4 -0
- package/lib/vite/traceViewer/uiMode.4d0a45af.js +1484 -0
- package/lib/vite/traceViewer/uiMode.66eb0ce2.js +1484 -0
- package/lib/vite/traceViewer/uiMode.8b41a49d.css +1 -0
- package/lib/vite/traceViewer/uiMode.8d080c01.js +1486 -0
- package/lib/vite/traceViewer/uiMode.BKrDfnAk.js +1725 -0
- package/lib/vite/traceViewer/uiMode.BMYUvsRh.js +1725 -0
- package/lib/vite/traceViewer/{uiMode.BZoFj6zV.js → uiMode.BVpTBGoe.js} +4 -3
- package/lib/vite/traceViewer/uiMode.BWhJCEE9.js +1725 -0
- package/lib/vite/traceViewer/uiMode.Bg9fACTB.js +1725 -0
- package/lib/vite/traceViewer/{uiMode.CpC2B27N.js → uiMode.CYBsUhm_.js} +2 -2
- package/lib/vite/traceViewer/{uiMode.Dlo9s_YX.js → uiMode.DCSdxlAq.js} +4 -3
- package/lib/vite/traceViewer/{uiMode.2tr9k625.js → uiMode.DjTS7tqC.js} +1 -1
- package/lib/vite/traceViewer/{uiMode.wsGnVMQK.js → uiMode.DtleKuGI.js} +4 -3
- package/lib/vite/traceViewer/uiMode.UamAvOMX.js +1725 -0
- package/lib/vite/traceViewer/uiMode.bBcXYWNF.js +1725 -0
- package/lib/vite/traceViewer/uiMode.ca6ec898.js +4 -0
- package/lib/vite/traceViewer/{uiMode.iq7CyYy7.js → uiMode.e-PLonGl.js} +2 -2
- package/lib/vite/traceViewer/uiMode.e_-GuqEi.js +1725 -0
- package/lib/vite/traceViewer/uiMode.f1YADWIl.js +1724 -0
- package/lib/vite/traceViewer/uiMode.html +7 -7
- package/lib/vite/traceViewer/uiMode.kHsXCfV8.js +1490 -0
- package/lib/vite/traceViewer/uiMode.myF_lyEH.js +1724 -0
- package/lib/vite/traceViewer/{workbench.B3X2QtYa.css → wsPort.162042f9.css} +63 -315
- package/lib/vite/traceViewer/{workbench.wuxQoE2z.css → wsPort.997c92cf.css} +145 -335
- package/lib/vite/traceViewer/wsPort.9c9a6767.css +1 -0
- package/lib/vite/traceViewer/xtermModule.125f4259.css +191 -0
- package/lib/vite/traceViewer/xtermModule.6428296b.css +32 -0
- package/package.json +1 -1
- package/lib/vite/recorder/assets/codeMirrorModule-ez37Vkbh.css +0 -1
- package/lib/vite/recorder/assets/index-BW-aOBcL.css +0 -1
- package/lib/vite/recorder/assets/index-Bxxcmxlu.js +0 -42
- package/lib/vite/traceViewer/assets/codeMirrorModule-5yiV-3wl.js +0 -16831
- package/lib/vite/traceViewer/assets/codeMirrorModule-B7Z3vq11.js +0 -24
- package/lib/vite/traceViewer/assets/codeMirrorModule-C6p3E9Zg.js +0 -24
- package/lib/vite/traceViewer/assets/codeMirrorModule-Ca-1BNel.js +0 -24
- package/lib/vite/traceViewer/assets/codeMirrorModule-CqYUz5ms.js +0 -24
- package/lib/vite/traceViewer/assets/codeMirrorModule-DS3v0XrQ.js +0 -24
- package/lib/vite/traceViewer/assets/codeMirrorModule-DZoSgqUd.js +0 -24
- package/lib/vite/traceViewer/assets/codeMirrorModule-EhKN7Okm.js +0 -16449
- package/lib/vite/traceViewer/assets/codeMirrorModule-MzSmL4X2.js +0 -24
- package/lib/vite/traceViewer/assets/codeMirrorModule-T_sdMrbM.js +0 -24
- package/lib/vite/traceViewer/assets/inspectorTab-Bbgq0hgt.js +0 -64
- package/lib/vite/traceViewer/assets/inspectorTab-DhBbZz8I.js +0 -64
- package/lib/vite/traceViewer/assets/workbench-C43LWZEX.js +0 -72
- package/lib/vite/traceViewer/assets/workbench-DZqNXdoV.js +0 -9
- package/lib/vite/traceViewer/assets/workbench-DrQjKdyE.js +0 -72
- package/lib/vite/traceViewer/assets/workbench-Pa1v1Ojh.js +0 -72
- package/lib/vite/traceViewer/assets/workbench-caTaZnzx.js +0 -72
- package/lib/vite/traceViewer/assets/workbench-gtYcQBNA.js +0 -9
- package/lib/vite/traceViewer/assets/workbench-u2lRPMOT.js +0 -72
- package/lib/vite/traceViewer/assets/xtermModule-CZ7sDYXB.js +0 -6529
- package/lib/vite/traceViewer/embedded.BBZ9gQEw.js +0 -104
- package/lib/vite/traceViewer/embedded.BQq6Psnz.js +0 -104
- package/lib/vite/traceViewer/embedded.BVDVQOzc.js +0 -2
- package/lib/vite/traceViewer/embedded.Bn8Ptzv6.js +0 -2
- package/lib/vite/traceViewer/embedded.CorI3dFX.js +0 -104
- package/lib/vite/traceViewer/embedded.CvhnUgIi.js +0 -2
- package/lib/vite/traceViewer/embedded.D27cnKiB.js +0 -104
- package/lib/vite/traceViewer/embedded.D4lqGydT.js +0 -2
- package/lib/vite/traceViewer/embedded.DPqrDeET.js +0 -2
- package/lib/vite/traceViewer/embedded.DbzY7Q8w.js +0 -2
- package/lib/vite/traceViewer/embedded.f-PLGsBT.js +0 -2
- package/lib/vite/traceViewer/index.B7aiTMfZ.js +0 -2
- package/lib/vite/traceViewer/index.B8dgQwuN.js +0 -2
- package/lib/vite/traceViewer/index.BGj8jY3H.js +0 -2
- package/lib/vite/traceViewer/index.BSak5QT9.js +0 -2
- package/lib/vite/traceViewer/index.BrT2kfuc.js +0 -2
- package/lib/vite/traceViewer/index.CUpI-BFe.js +0 -195
- package/lib/vite/traceViewer/index.DkRbtWVo.js +0 -195
- package/lib/vite/traceViewer/index.DsjmhbB6.js +0 -195
- package/lib/vite/traceViewer/index._cX8k4co.js +0 -2
- package/lib/vite/traceViewer/index.pMAN88y-.js +0 -2
- package/lib/vite/traceViewer/recorder.Ch-WHviK.js +0 -2
- package/lib/vite/traceViewer/recorder.POd-toIn.js +0 -2
- package/lib/vite/traceViewer/uiMode.BEZVCe5O.js +0 -5
- package/lib/vite/traceViewer/uiMode.C4nbcio6.js +0 -1730
- package/lib/vite/traceViewer/uiMode.D-tg1Oci.js +0 -1730
- package/lib/vite/traceViewer/uiMode.D3cNFP6u.css +0 -1
- package/lib/vite/traceViewer/uiMode.DKjMBMlc.js +0 -1730
- package/lib/vite/traceViewer/uiMode.DVrL7a1K.js +0 -10
- package/lib/vite/traceViewer/uiMode.DdtUZZVS.js +0 -5
- package/lib/vite/traceViewer/uiMode.Dg9oJCQU.js +0 -10
- package/lib/vite/traceViewer/uiMode.DwZAzstF.js +0 -10
- package/lib/vite/traceViewer/uiMode.O07awP3T.js +0 -10
- package/lib/vite/traceViewer/uiMode.gGHHTsyL.js +0 -1730
- package/lib/vite/traceViewer/uiMode.jY2s-9ps.js +0 -10
- package/lib/vite/traceViewer/workbench.DjbIuxix.css +0 -1
- package/lib/vite/traceViewer/workbench.DyTpxWVb.css +0 -1
package/lib/cli/cli.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) Microsoft Corporation.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/* eslint-disable no-console */
|
|
20
|
+
"use strict";
|
|
21
|
+
|
|
22
|
+
var _utils = require("../utils");
|
|
23
|
+
var _program = _interopRequireDefault(require("./program"));
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
function printPlaywrightTestError(command) {
|
|
26
|
+
const packages = [];
|
|
27
|
+
for (const pkg of ['playwright', 'playwright-chromium', 'playwright-firefox', 'playwright-webkit']) {
|
|
28
|
+
try {
|
|
29
|
+
require.resolve(pkg);
|
|
30
|
+
packages.push(pkg);
|
|
31
|
+
} catch (e) {}
|
|
32
|
+
}
|
|
33
|
+
if (!packages.length) packages.push('playwright');
|
|
34
|
+
const packageManager = (0, _utils.getPackageManager)();
|
|
35
|
+
if (packageManager === 'yarn') {
|
|
36
|
+
console.error(`Please install @playwright/test package before running "yarn playwright ${command}"`);
|
|
37
|
+
console.error(` yarn remove ${packages.join(' ')}`);
|
|
38
|
+
console.error(' yarn add -D @playwright/test');
|
|
39
|
+
} else if (packageManager === 'pnpm') {
|
|
40
|
+
console.error(`Please install @playwright/test package before running "pnpm exec playwright ${command}"`);
|
|
41
|
+
console.error(` pnpm remove ${packages.join(' ')}`);
|
|
42
|
+
console.error(' pnpm add -D @playwright/test');
|
|
43
|
+
} else {
|
|
44
|
+
console.error(`Please install @playwright/test package before running "npx playwright ${command}"`);
|
|
45
|
+
console.error(` npm uninstall ${packages.join(' ')}`);
|
|
46
|
+
console.error(' npm install -D @playwright/test');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const kExternalPlaywrightTestCommands = [['test', 'Run tests with Playwright Test.'], ['show-report', 'Show Playwright Test HTML report.'], ['merge-reports', 'Merge Playwright Test Blob reports']];
|
|
50
|
+
function addExternalPlaywrightTestCommands() {
|
|
51
|
+
for (const [command, description] of kExternalPlaywrightTestCommands) {
|
|
52
|
+
const playwrightTest = _program.default.command(command).allowUnknownOption(true);
|
|
53
|
+
playwrightTest.description(`${description} Available in @playwright/test package.`);
|
|
54
|
+
playwrightTest.action(async () => {
|
|
55
|
+
printPlaywrightTestError(command);
|
|
56
|
+
(0, _utils.gracefullyProcessExitDoNotHang)(1);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (!process.env.PW_LANG_NAME) addExternalPlaywrightTestCommands();
|
|
61
|
+
_program.default.parse(process.argv);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.debugLogger = exports.RecentLogsCollector = void 0;
|
|
7
|
+
var _utilsBundle = require("../utilsBundle");
|
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
/**
|
|
11
|
+
* Copyright (c) Microsoft Corporation.
|
|
12
|
+
*
|
|
13
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
* you may not use this file except in compliance with the License.
|
|
15
|
+
* You may obtain a copy of the License at
|
|
16
|
+
*
|
|
17
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const debugLoggerColorMap = {
|
|
27
|
+
'api': 45,
|
|
28
|
+
// cyan
|
|
29
|
+
'protocol': 34,
|
|
30
|
+
// green
|
|
31
|
+
'install': 34,
|
|
32
|
+
// green
|
|
33
|
+
'download': 34,
|
|
34
|
+
// green
|
|
35
|
+
'browser': 0,
|
|
36
|
+
// reset
|
|
37
|
+
'socks': 92,
|
|
38
|
+
// purple
|
|
39
|
+
'error': 160,
|
|
40
|
+
// red,
|
|
41
|
+
'channel': 33,
|
|
42
|
+
// blue
|
|
43
|
+
'server': 45,
|
|
44
|
+
// cyan
|
|
45
|
+
'server:channel': 34,
|
|
46
|
+
// green
|
|
47
|
+
'server:metadata': 33 // blue
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
class DebugLogger {
|
|
51
|
+
constructor() {
|
|
52
|
+
this._debuggers = new Map();
|
|
53
|
+
if (process.env.DEBUG_FILE) {
|
|
54
|
+
const ansiRegex = new RegExp(['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|'), 'g');
|
|
55
|
+
const stream = _fs.default.createWriteStream(process.env.DEBUG_FILE);
|
|
56
|
+
_utilsBundle.debug.log = data => {
|
|
57
|
+
stream.write(data.replace(ansiRegex, ''));
|
|
58
|
+
stream.write('\n');
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
log(name, message) {
|
|
63
|
+
let cachedDebugger = this._debuggers.get(name);
|
|
64
|
+
if (!cachedDebugger) {
|
|
65
|
+
cachedDebugger = (0, _utilsBundle.debug)(`pw:${name}`);
|
|
66
|
+
this._debuggers.set(name, cachedDebugger);
|
|
67
|
+
cachedDebugger.color = debugLoggerColorMap[name] || 0;
|
|
68
|
+
}
|
|
69
|
+
cachedDebugger(message);
|
|
70
|
+
}
|
|
71
|
+
isEnabled(name) {
|
|
72
|
+
return _utilsBundle.debug.enabled(`pw:${name}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const debugLogger = exports.debugLogger = new DebugLogger();
|
|
76
|
+
const kLogCount = 150;
|
|
77
|
+
class RecentLogsCollector {
|
|
78
|
+
constructor() {
|
|
79
|
+
this._logs = [];
|
|
80
|
+
}
|
|
81
|
+
log(message) {
|
|
82
|
+
this._logs.push(message);
|
|
83
|
+
if (this._logs.length === kLogCount * 2) this._logs.splice(0, kLogCount);
|
|
84
|
+
}
|
|
85
|
+
recentLogs() {
|
|
86
|
+
if (this._logs.length > kLogCount) return this._logs.slice(-kLogCount);
|
|
87
|
+
return this._logs;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.RecentLogsCollector = RecentLogsCollector;
|
|
@@ -4,4 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.source = void 0;
|
|
7
|
-
const source = exports.source = "\nvar __commonJS = obj => {\n let required = false;\n let result;\n return function __require() {\n if (!required) {\n required = true;\n let fn;\n for (const name in obj) { fn = obj[name]; break; }\n const module = { exports: {} };\n fn(module.exports, module);\n result = module.exports;\n }\n return result;\n }\n};\nvar __export = (target, all) => {for (var name in all) target[name] = all[name];};\nvar __toESM = mod => ({ ...mod, 'default': mod });\nvar __toCommonJS = mod => ({ ...mod, __esModule: true });\n\n\n// packages/playwright-core/src/server/injected/clock.ts\nvar clock_exports = {};\n__export(clock_exports, {\n ClockController: () => ClockController,\n createClock: () => createClock,\n inject: () => inject,\n install: () => install\n});\nmodule.exports = __toCommonJS(clock_exports);\nvar ClockController = class {\n constructor(embedder) {\n this._duringTick = false;\n this._timers = /* @__PURE__ */ new Map();\n this._uniqueTimerId = idCounterStart;\n this.disposables = [];\n this._log = [];\n this._now = { time: asWallTime(0), isFixedTime: false, ticks: 0, origin: asWallTime(-1) };\n this._embedder = embedder;\n }\n uninstall() {\n this.disposables.forEach((dispose) => dispose());\n this.disposables.length = 0;\n }\n now() {\n this._replayLogOnce();\n return this._now.time;\n }\n install(time) {\n this._replayLogOnce();\n this._innerSetTime(asWallTime(time));\n }\n setSystemTime(time) {\n this._replayLogOnce();\n this._innerSetTime(asWallTime(time));\n }\n setFixedTime(time) {\n this._replayLogOnce();\n this._innerSetFixedTime(asWallTime(time));\n }\n performanceNow() {\n this._replayLogOnce();\n return this._now.ticks;\n }\n _innerSetTime(time) {\n this._now.time = time;\n this._now.isFixedTime = false;\n if (this._now.origin < 0)\n this._now.origin = this._now.time;\n }\n _innerSetFixedTime(time) {\n this._innerSetTime(time);\n this._now.isFixedTime = true;\n }\n _advanceNow(to) {\n if (!this._now.isFixedTime)\n this._now.time = asWallTime(this._now.time + to - this._now.ticks);\n this._now.ticks = to;\n }\n async log(type, time, param) {\n this._log.push({ type, time, param });\n }\n async runFor(ticks) {\n this._replayLogOnce();\n if (ticks < 0)\n throw new TypeError(\"Negative ticks are not supported\");\n await this._runTo(shiftTicks(this._now.ticks, ticks));\n }\n async _runTo(to) {\n to = Math.ceil(to);\n if (this._now.ticks > to)\n return;\n let firstException;\n while (true) {\n const result = await this._callFirstTimer(to);\n if (!result.timerFound)\n break;\n firstException = firstException || result.error;\n }\n this._advanceNow(to);\n if (firstException)\n throw firstException;\n }\n async pauseAt(time) {\n this._replayLogOnce();\n this._innerPause();\n const toConsume = time - this._now.time;\n await this._innerFastForwardTo(shiftTicks(this._now.ticks, toConsume));\n return toConsume;\n }\n _innerPause() {\n this._realTime = void 0;\n this._updateRealTimeTimer();\n }\n resume() {\n this._replayLogOnce();\n this._innerResume();\n }\n _innerResume() {\n const now = this._embedder.performanceNow();\n this._realTime = { startTicks: now, lastSyncTicks: now };\n this._updateRealTimeTimer();\n }\n _updateRealTimeTimer() {\n var _a;\n if (!this._realTime) {\n (_a = this._currentRealTimeTimer) == null ? void 0 : _a.dispose();\n this._currentRealTimeTimer = void 0;\n return;\n }\n const firstTimer = this._firstTimer();\n const callAt = Math.min(firstTimer ? firstTimer.callAt : this._now.ticks + maxTimeout, this._now.ticks + 100);\n if (this._currentRealTimeTimer && this._currentRealTimeTimer.callAt < callAt)\n return;\n if (this._currentRealTimeTimer) {\n this._currentRealTimeTimer.dispose();\n this._currentRealTimeTimer = void 0;\n }\n this._currentRealTimeTimer = {\n callAt,\n dispose: this._embedder.setTimeout(() => {\n const now = this._embedder.performanceNow();\n this._currentRealTimeTimer = void 0;\n const sinceLastSync = now - this._realTime.lastSyncTicks;\n this._realTime.lastSyncTicks = now;\n void this._runTo(shiftTicks(this._now.ticks, sinceLastSync)).catch((e) => console.error(e)).then(() => this._updateRealTimeTimer());\n }, callAt - this._now.ticks)\n };\n }\n async fastForward(ticks) {\n this._replayLogOnce();\n await this._innerFastForwardTo(shiftTicks(this._now.ticks, ticks | 0));\n }\n async _innerFastForwardTo(to) {\n if (to < this._now.ticks)\n throw new Error(\"Cannot fast-forward to the past\");\n for (const timer of this._timers.values()) {\n if (to > timer.callAt)\n timer.callAt = to;\n }\n await this._runTo(to);\n }\n addTimer(options) {\n this._replayLogOnce();\n if (options.type === \"AnimationFrame\" /* AnimationFrame */ && !options.func)\n throw new Error(\"Callback must be provided to requestAnimationFrame calls\");\n if (options.type === \"IdleCallback\" /* IdleCallback */ && !options.func)\n throw new Error(\"Callback must be provided to requestIdleCallback calls\");\n if ([\"Timeout\" /* Timeout */, \"Interval\" /* Interval */].includes(options.type) && !options.func && options.delay === void 0)\n throw new Error(\"Callback must be provided to timer calls\");\n let delay = options.delay ? +options.delay : 0;\n if (!Number.isFinite(delay))\n delay = 0;\n delay = delay > maxTimeout ? 1 : delay;\n delay = Math.max(0, delay);\n const timer = {\n type: options.type,\n func: options.func,\n args: options.args || [],\n delay,\n callAt: shiftTicks(this._now.ticks, delay || (this._duringTick ? 1 : 0)),\n createdAt: this._now.ticks,\n id: this._uniqueTimerId++,\n error: new Error()\n };\n this._timers.set(timer.id, timer);\n if (this._realTime)\n this._updateRealTimeTimer();\n return timer.id;\n }\n countTimers() {\n return this._timers.size;\n }\n _firstTimer(beforeTick) {\n let firstTimer = null;\n for (const timer of this._timers.values()) {\n const isInRange = beforeTick === void 0 || timer.callAt <= beforeTick;\n if (isInRange && (!firstTimer || compareTimers(firstTimer, timer) === 1))\n firstTimer = timer;\n }\n return firstTimer;\n }\n _takeFirstTimer(beforeTick) {\n const timer = this._firstTimer(beforeTick);\n if (!timer)\n return null;\n this._advanceNow(timer.callAt);\n if (timer.type === \"Interval\" /* Interval */)\n timer.callAt = shiftTicks(timer.callAt, timer.delay);\n else\n this._timers.delete(timer.id);\n return timer;\n }\n async _callFirstTimer(beforeTick) {\n const timer = this._takeFirstTimer(beforeTick);\n if (!timer)\n return { timerFound: false };\n this._duringTick = true;\n try {\n if (typeof timer.func !== \"function\") {\n let error2;\n try {\n (() => {\n globalThis.eval(timer.func);\n })();\n } catch (e) {\n error2 = e;\n }\n await new Promise((f) => this._embedder.setTimeout(f));\n return { timerFound: true, error: error2 };\n }\n let args = timer.args;\n if (timer.type === \"AnimationFrame\" /* AnimationFrame */)\n args = [this._now.ticks];\n else if (timer.type === \"IdleCallback\" /* IdleCallback */)\n args = [{ didTimeout: false, timeRemaining: () => 0 }];\n let error;\n try {\n timer.func.apply(null, args);\n } catch (e) {\n error = e;\n }\n await new Promise((f) => this._embedder.setTimeout(f));\n return { timerFound: true, error };\n } finally {\n this._duringTick = false;\n }\n }\n getTimeToNextFrame() {\n return 16 - this._now.ticks % 16;\n }\n clearTimer(timerId, type) {\n this._replayLogOnce();\n if (!timerId) {\n return;\n }\n const id = Number(timerId);\n if (Number.isNaN(id) || id < idCounterStart) {\n const handlerName = getClearHandler(type);\n new Error(`Clock: ${handlerName} was invoked to clear a native timer instead of one created by the clock library.`);\n }\n const timer = this._timers.get(id);\n if (timer) {\n if (timer.type === type || timer.type === \"Timeout\" && type === \"Interval\" || timer.type === \"Interval\" && type === \"Timeout\") {\n this._timers.delete(id);\n } else {\n const clear = getClearHandler(type);\n const schedule = getScheduleHandler(timer.type);\n throw new Error(\n `Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()`\n );\n }\n }\n }\n _replayLogOnce() {\n if (!this._log.length)\n return;\n let lastLogTime = -1;\n let isPaused = false;\n for (const { type, time, param } of this._log) {\n if (!isPaused && lastLogTime !== -1)\n this._advanceNow(shiftTicks(this._now.ticks, time - lastLogTime));\n lastLogTime = time;\n if (type === \"install\") {\n this._innerSetTime(asWallTime(param));\n } else if (type === \"fastForward\" || type === \"runFor\") {\n this._advanceNow(shiftTicks(this._now.ticks, param));\n } else if (type === \"pauseAt\") {\n isPaused = true;\n this._innerPause();\n this._innerSetTime(asWallTime(param));\n } else if (type === \"resume\") {\n this._innerResume();\n isPaused = false;\n } else if (type === \"setFixedTime\") {\n this._innerSetFixedTime(asWallTime(param));\n } else if (type === \"setSystemTime\") {\n this._innerSetTime(asWallTime(param));\n }\n }\n if (!isPaused && lastLogTime > 0)\n this._advanceNow(shiftTicks(this._now.ticks, this._embedder.dateNow() - lastLogTime));\n this._log.length = 0;\n }\n};\nfunction mirrorDateProperties(target, source) {\n for (const prop in source) {\n if (source.hasOwnProperty(prop))\n target[prop] = source[prop];\n }\n target.toString = () => source.toString();\n target.prototype = source.prototype;\n target.parse = source.parse;\n target.UTC = source.UTC;\n target.prototype.toUTCString = source.prototype.toUTCString;\n target.isFake = true;\n return target;\n}\nfunction createDate(clock, NativeDate) {\n function ClockDate(year, month, date, hour, minute, second, ms) {\n if (!(this instanceof ClockDate))\n return new NativeDate(clock.now()).toString();\n switch (arguments.length) {\n case 0:\n return new NativeDate(clock.now());\n case 1:\n return new NativeDate(year);\n case 2:\n return new NativeDate(year, month);\n case 3:\n return new NativeDate(year, month, date);\n case 4:\n return new NativeDate(year, month, date, hour);\n case 5:\n return new NativeDate(year, month, date, hour, minute);\n case 6:\n return new NativeDate(\n year,\n month,\n date,\n hour,\n minute,\n second\n );\n default:\n return new NativeDate(\n year,\n month,\n date,\n hour,\n minute,\n second,\n ms\n );\n }\n }\n ClockDate.now = () => clock.now();\n return mirrorDateProperties(ClockDate, NativeDate);\n}\nfunction createIntl(clock, NativeIntl) {\n const ClockIntl = {};\n for (const key of Object.getOwnPropertyNames(NativeIntl))\n ClockIntl[key] = NativeIntl[key];\n ClockIntl.DateTimeFormat = function(...args) {\n const realFormatter = new NativeIntl.DateTimeFormat(...args);\n const formatter = {\n formatRange: realFormatter.formatRange.bind(realFormatter),\n formatRangeToParts: realFormatter.formatRangeToParts.bind(realFormatter),\n resolvedOptions: realFormatter.resolvedOptions.bind(realFormatter),\n format: (date) => realFormatter.format(date || clock.now()),\n formatToParts: (date) => realFormatter.formatToParts(date || clock.now())\n };\n return formatter;\n };\n ClockIntl.DateTimeFormat.prototype = Object.create(\n NativeIntl.DateTimeFormat.prototype\n );\n ClockIntl.DateTimeFormat.supportedLocalesOf = NativeIntl.DateTimeFormat.supportedLocalesOf;\n return ClockIntl;\n}\nfunction compareTimers(a, b) {\n if (a.callAt < b.callAt)\n return -1;\n if (a.callAt > b.callAt)\n return 1;\n if (a.type === \"Immediate\" /* Immediate */ && b.type !== \"Immediate\" /* Immediate */)\n return -1;\n if (a.type !== \"Immediate\" /* Immediate */ && b.type === \"Immediate\" /* Immediate */)\n return 1;\n if (a.createdAt < b.createdAt)\n return -1;\n if (a.createdAt > b.createdAt)\n return 1;\n if (a.id < b.id)\n return -1;\n if (a.id > b.id)\n return 1;\n}\nvar maxTimeout = Math.pow(2, 31) - 1;\nvar idCounterStart = 1e12;\nfunction platformOriginals(globalObject) {\n const raw = {\n setTimeout: globalObject.setTimeout,\n clearTimeout: globalObject.clearTimeout,\n setInterval: globalObject.setInterval,\n clearInterval: globalObject.clearInterval,\n requestAnimationFrame: globalObject.requestAnimationFrame ? globalObject.requestAnimationFrame : void 0,\n cancelAnimationFrame: globalObject.cancelAnimationFrame ? globalObject.cancelAnimationFrame : void 0,\n requestIdleCallback: globalObject.requestIdleCallback ? globalObject.requestIdleCallback : void 0,\n cancelIdleCallback: globalObject.cancelIdleCallback ? globalObject.cancelIdleCallback : void 0,\n Date: globalObject.Date,\n performance: globalObject.performance,\n Intl: globalObject.Intl\n };\n const bound = { ...raw };\n for (const key of Object.keys(bound)) {\n if (key !== \"Date\" && typeof bound[key] === \"function\")\n bound[key] = bound[key].bind(globalObject);\n }\n return { raw, bound };\n}\nfunction getScheduleHandler(type) {\n if (type === \"IdleCallback\" || type === \"AnimationFrame\")\n return `request${type}`;\n return `set${type}`;\n}\nfunction createApi(clock, originals) {\n return {\n setTimeout: (func, timeout, ...args) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: \"Timeout\" /* Timeout */,\n func,\n args,\n delay\n });\n },\n clearTimeout: (timerId) => {\n if (timerId)\n clock.clearTimer(timerId, \"Timeout\" /* Timeout */);\n },\n setInterval: (func, timeout, ...args) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: \"Interval\" /* Interval */,\n func,\n args,\n delay\n });\n },\n clearInterval: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, \"Interval\" /* Interval */);\n },\n requestAnimationFrame: (callback) => {\n return clock.addTimer({\n type: \"AnimationFrame\" /* AnimationFrame */,\n func: callback,\n delay: clock.getTimeToNextFrame()\n });\n },\n cancelAnimationFrame: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, \"AnimationFrame\" /* AnimationFrame */);\n },\n requestIdleCallback: (callback, options) => {\n let timeToNextIdlePeriod = 0;\n if (clock.countTimers() > 0)\n timeToNextIdlePeriod = 50;\n return clock.addTimer({\n type: \"IdleCallback\" /* IdleCallback */,\n func: callback,\n delay: (options == null ? void 0 : options.timeout) ? Math.min(options == null ? void 0 : options.timeout, timeToNextIdlePeriod) : timeToNextIdlePeriod\n });\n },\n cancelIdleCallback: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, \"IdleCallback\" /* IdleCallback */);\n },\n Intl: originals.Intl ? createIntl(clock, originals.Intl) : void 0,\n Date: createDate(clock, originals.Date),\n performance: originals.performance ? fakePerformance(clock, originals.performance) : void 0\n };\n}\nfunction getClearHandler(type) {\n if (type === \"IdleCallback\" || type === \"AnimationFrame\")\n return `cancel${type}`;\n return `clear${type}`;\n}\nfunction fakePerformance(clock, performance) {\n const result = {\n now: () => clock.performanceNow()\n };\n result.__defineGetter__(\"timeOrigin\", () => clock._now.origin || 0);\n for (const key of Object.keys(performance.__proto__)) {\n if (key === \"now\" || key === \"timeOrigin\")\n continue;\n if (key === \"getEntries\" || key === \"getEntriesByName\" || key === \"getEntriesByType\")\n result[key] = () => [];\n else\n result[key] = () => {\n };\n }\n return result;\n}\nfunction createClock(globalObject) {\n const originals = platformOriginals(globalObject);\n const embedder = {\n dateNow: () => originals.raw.Date.now(),\n performanceNow: () => Math.ceil(originals.raw.performance.now()),\n setTimeout: (task, timeout) => {\n const timerId = originals.bound.setTimeout(task, timeout);\n return () => originals.bound.clearTimeout(timerId);\n },\n setInterval: (task, delay) => {\n const intervalId = originals.bound.setInterval(task, delay);\n return () => originals.bound.clearInterval(intervalId);\n }\n };\n const clock = new ClockController(embedder);\n const api = createApi(clock, originals.bound);\n return { clock, api, originals: originals.raw };\n}\nfunction install(globalObject, config = {}) {\n var _a, _b;\n if ((_a = globalObject.Date) == null ? void 0 : _a.isFake) {\n throw new TypeError(`Can't install fake timers twice on the same global object.`);\n }\n const { clock, api, originals } = createClock(globalObject);\n const toFake = ((_b = config.toFake) == null ? void 0 : _b.length) ? config.toFake : Object.keys(originals);\n for (const method of toFake) {\n if (method === \"Date\") {\n globalObject.Date = mirrorDateProperties(api.Date, globalObject.Date);\n } else if (method === \"Intl\") {\n globalObject.Intl = api[method];\n } else if (method === \"performance\") {\n globalObject.performance = api[method];\n const kEventTimeStamp = Symbol(\"playwrightEventTimeStamp\");\n Object.defineProperty(Event.prototype, \"timeStamp\", {\n get() {\n var _a2;\n if (!this[kEventTimeStamp])\n this[kEventTimeStamp] = (_a2 = api.performance) == null ? void 0 : _a2.now();\n return this[kEventTimeStamp];\n }\n });\n } else {\n globalObject[method] = (...args) => {\n return api[method].apply(api, args);\n };\n }\n clock.disposables.push(() => {\n globalObject[method] = originals[method];\n });\n }\n return { clock, api, originals };\n}\nfunction inject(globalObject) {\n const builtin = platformOriginals(globalObject).bound;\n const { clock: controller } = install(globalObject);\n controller.resume();\n return {\n controller,\n builtin\n };\n}\nfunction asWallTime(n) {\n return n;\n}\nfunction shiftTicks(ticks, ms) {\n return ticks + ms;\n}\n";
|
|
7
|
+
const source = exports.source = "\nvar __commonJS = obj => {\n let required = false;\n let result;\n return function __require() {\n if (!required) {\n required = true;\n let fn;\n for (const name in obj) { fn = obj[name]; break; }\n const module = { exports: {} };\n fn(module.exports, module);\n result = module.exports;\n }\n return result;\n }\n};\nvar __export = (target, all) => {for (var name in all) target[name] = all[name];};\nvar __toESM = mod => ({ ...mod, 'default': mod });\nvar __toCommonJS = mod => ({ ...mod, __esModule: true });\n\n\n// packages/playwright-core/src/server/injected/clock.ts\nvar clock_exports = {};\n__export(clock_exports, {\n ClockController: () => ClockController,\n createClock: () => createClock,\n inject: () => inject,\n install: () => install\n});\nmodule.exports = __toCommonJS(clock_exports);\nvar ClockController = class {\n constructor(embedder) {\n this._duringTick = false;\n this._timers = /* @__PURE__ */ new Map();\n this._uniqueTimerId = idCounterStart;\n this.disposables = [];\n this._log = [];\n this._now = { time: asWallTime(0), isFixedTime: false, ticks: 0, origin: asWallTime(-1) };\n this._embedder = embedder;\n }\n uninstall() {\n this.disposables.forEach((dispose) => dispose());\n this.disposables.length = 0;\n }\n now() {\n this._replayLogOnce();\n return this._now.time;\n }\n install(time) {\n this._replayLogOnce();\n this._innerSetTime(asWallTime(time));\n }\n setSystemTime(time) {\n this._replayLogOnce();\n this._innerSetTime(asWallTime(time));\n }\n setFixedTime(time) {\n this._replayLogOnce();\n this._innerSetFixedTime(asWallTime(time));\n }\n performanceNow() {\n this._replayLogOnce();\n return this._now.ticks;\n }\n _innerSetTime(time) {\n this._now.time = time;\n this._now.isFixedTime = false;\n if (this._now.origin < 0)\n this._now.origin = this._now.time;\n }\n _innerSetFixedTime(time) {\n this._innerSetTime(time);\n this._now.isFixedTime = true;\n }\n _advanceNow(to) {\n if (!this._now.isFixedTime)\n this._now.time = asWallTime(this._now.time + to - this._now.ticks);\n this._now.ticks = to;\n }\n async log(type, time, param) {\n this._log.push({ type, time, param });\n }\n async runFor(ticks) {\n this._replayLogOnce();\n if (ticks < 0)\n throw new TypeError(\"Negative ticks are not supported\");\n await this._runTo(shiftTicks(this._now.ticks, ticks));\n }\n async _runTo(to) {\n to = Math.ceil(to);\n if (this._now.ticks > to)\n return;\n let firstException;\n while (true) {\n const result = await this._callFirstTimer(to);\n if (!result.timerFound)\n break;\n firstException = firstException || result.error;\n }\n this._advanceNow(to);\n if (firstException)\n throw firstException;\n }\n async pauseAt(time) {\n this._replayLogOnce();\n this._innerPause();\n const toConsume = time - this._now.time;\n await this._innerFastForwardTo(shiftTicks(this._now.ticks, toConsume));\n return toConsume;\n }\n _innerPause() {\n this._realTime = void 0;\n this._updateRealTimeTimer();\n }\n resume() {\n this._replayLogOnce();\n this._innerResume();\n }\n _innerResume() {\n const now = this._embedder.performanceNow();\n this._realTime = { startTicks: now, lastSyncTicks: now };\n this._updateRealTimeTimer();\n }\n _updateRealTimeTimer() {\n var _a;\n if (!this._realTime) {\n (_a = this._currentRealTimeTimer) == null ? void 0 : _a.dispose();\n this._currentRealTimeTimer = void 0;\n return;\n }\n const firstTimer = this._firstTimer();\n const callAt = Math.min(firstTimer ? firstTimer.callAt : this._now.ticks + maxTimeout, this._now.ticks + 100);\n if (this._currentRealTimeTimer && this._currentRealTimeTimer.callAt < callAt)\n return;\n if (this._currentRealTimeTimer) {\n this._currentRealTimeTimer.dispose();\n this._currentRealTimeTimer = void 0;\n }\n this._currentRealTimeTimer = {\n callAt,\n dispose: this._embedder.setTimeout(() => {\n const now = this._embedder.performanceNow();\n this._currentRealTimeTimer = void 0;\n const sinceLastSync = now - this._realTime.lastSyncTicks;\n this._realTime.lastSyncTicks = now;\n void this._runTo(shiftTicks(this._now.ticks, sinceLastSync)).catch((e) => console.error(e)).then(() => this._updateRealTimeTimer());\n }, callAt - this._now.ticks)\n };\n }\n async fastForward(ticks) {\n this._replayLogOnce();\n await this._innerFastForwardTo(shiftTicks(this._now.ticks, ticks | 0));\n }\n async _innerFastForwardTo(to) {\n if (to < this._now.ticks)\n throw new Error(\"Cannot fast-forward to the past\");\n for (const timer of this._timers.values()) {\n if (to > timer.callAt)\n timer.callAt = to;\n }\n await this._runTo(to);\n }\n addTimer(options) {\n this._replayLogOnce();\n if (options.type === \"AnimationFrame\" /* AnimationFrame */ && !options.func)\n throw new Error(\"Callback must be provided to requestAnimationFrame calls\");\n if (options.type === \"IdleCallback\" /* IdleCallback */ && !options.func)\n throw new Error(\"Callback must be provided to requestIdleCallback calls\");\n if ([\"Timeout\" /* Timeout */, \"Interval\" /* Interval */].includes(options.type) && !options.func && options.delay === void 0)\n throw new Error(\"Callback must be provided to timer calls\");\n let delay = options.delay ? +options.delay : 0;\n if (!Number.isFinite(delay))\n delay = 0;\n delay = delay > maxTimeout ? 1 : delay;\n delay = Math.max(0, delay);\n const timer = {\n type: options.type,\n func: options.func,\n args: options.args || [],\n delay,\n callAt: shiftTicks(this._now.ticks, delay || (this._duringTick ? 1 : 0)),\n createdAt: this._now.ticks,\n id: this._uniqueTimerId++,\n error: new Error()\n };\n this._timers.set(timer.id, timer);\n if (this._realTime)\n this._updateRealTimeTimer();\n return timer.id;\n }\n countTimers() {\n return this._timers.size;\n }\n _firstTimer(beforeTick) {\n let firstTimer = null;\n for (const timer of this._timers.values()) {\n const isInRange = beforeTick === void 0 || timer.callAt <= beforeTick;\n if (isInRange && (!firstTimer || compareTimers(firstTimer, timer) === 1))\n firstTimer = timer;\n }\n return firstTimer;\n }\n _takeFirstTimer(beforeTick) {\n const timer = this._firstTimer(beforeTick);\n if (!timer)\n return null;\n this._advanceNow(timer.callAt);\n if (timer.type === \"Interval\" /* Interval */)\n timer.callAt = shiftTicks(timer.callAt, timer.delay);\n else\n this._timers.delete(timer.id);\n return timer;\n }\n async _callFirstTimer(beforeTick) {\n const timer = this._takeFirstTimer(beforeTick);\n if (!timer)\n return { timerFound: false };\n this._duringTick = true;\n try {\n if (typeof timer.func !== \"function\") {\n let error2;\n try {\n (() => {\n globalThis.eval(timer.func);\n })();\n } catch (e) {\n error2 = e;\n }\n await new Promise((f) => this._embedder.setTimeout(f));\n return { timerFound: true, error: error2 };\n }\n let args = timer.args;\n if (timer.type === \"AnimationFrame\" /* AnimationFrame */)\n args = [this._now.ticks];\n else if (timer.type === \"IdleCallback\" /* IdleCallback */)\n args = [{ didTimeout: false, timeRemaining: () => 0 }];\n let error;\n try {\n timer.func.apply(null, args);\n } catch (e) {\n error = e;\n }\n await new Promise((f) => this._embedder.setTimeout(f));\n return { timerFound: true, error };\n } finally {\n this._duringTick = false;\n }\n }\n getTimeToNextFrame() {\n return 16 - this._now.ticks % 16;\n }\n clearTimer(timerId, type) {\n this._replayLogOnce();\n if (!timerId) {\n return;\n }\n const id = Number(timerId);\n if (Number.isNaN(id) || id < idCounterStart) {\n const handlerName = getClearHandler(type);\n new Error(`Clock: ${handlerName} was invoked to clear a native timer instead of one created by the clock library.`);\n }\n const timer = this._timers.get(id);\n if (timer) {\n if (timer.type === type || timer.type === \"Timeout\" && type === \"Interval\" || timer.type === \"Interval\" && type === \"Timeout\") {\n this._timers.delete(id);\n } else {\n const clear = getClearHandler(type);\n const schedule = getScheduleHandler(timer.type);\n throw new Error(\n `Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()`\n );\n }\n }\n }\n _replayLogOnce() {\n if (!this._log.length)\n return;\n let lastLogTime = -1;\n let isPaused = false;\n for (const { type, time, param } of this._log) {\n if (!isPaused && lastLogTime !== -1)\n this._advanceNow(shiftTicks(this._now.ticks, time - lastLogTime));\n lastLogTime = time;\n if (type === \"install\") {\n this._innerSetTime(asWallTime(param));\n } else if (type === \"fastForward\" || type === \"runFor\") {\n this._advanceNow(shiftTicks(this._now.ticks, param));\n } else if (type === \"pauseAt\") {\n isPaused = true;\n this._innerPause();\n this._innerSetTime(asWallTime(param));\n } else if (type === \"resume\") {\n this._innerResume();\n isPaused = false;\n } else if (type === \"setFixedTime\") {\n this._innerSetFixedTime(asWallTime(param));\n } else if (type === \"setSystemTime\") {\n this._innerSetTime(asWallTime(param));\n }\n }\n if (!isPaused && lastLogTime > 0)\n this._advanceNow(shiftTicks(this._now.ticks, this._embedder.dateNow() - lastLogTime));\n this._log.length = 0;\n }\n};\nfunction mirrorDateProperties(target, source) {\n for (const prop in source) {\n if (source.hasOwnProperty(prop))\n target[prop] = source[prop];\n }\n target.toString = () => source.toString();\n target.prototype = source.prototype;\n target.parse = source.parse;\n target.UTC = source.UTC;\n target.prototype.toUTCString = source.prototype.toUTCString;\n target.isFake = true;\n return target;\n}\nfunction createDate(clock, NativeDate) {\n function ClockDate(year, month, date, hour, minute, second, ms) {\n if (!(this instanceof ClockDate))\n return new NativeDate(clock.now()).toString();\n switch (arguments.length) {\n case 0:\n return new NativeDate(clock.now());\n case 1:\n return new NativeDate(year);\n case 2:\n return new NativeDate(year, month);\n case 3:\n return new NativeDate(year, month, date);\n case 4:\n return new NativeDate(year, month, date, hour);\n case 5:\n return new NativeDate(year, month, date, hour, minute);\n case 6:\n return new NativeDate(\n year,\n month,\n date,\n hour,\n minute,\n second\n );\n default:\n return new NativeDate(\n year,\n month,\n date,\n hour,\n minute,\n second,\n ms\n );\n }\n }\n ClockDate.now = () => clock.now();\n return mirrorDateProperties(ClockDate, NativeDate);\n}\nfunction createIntl(clock, NativeIntl) {\n const ClockIntl = {};\n for (const key of Object.getOwnPropertyNames(NativeIntl))\n ClockIntl[key] = NativeIntl[key];\n ClockIntl.DateTimeFormat = function(...args) {\n const realFormatter = new NativeIntl.DateTimeFormat(...args);\n const formatter = {\n formatRange: realFormatter.formatRange.bind(realFormatter),\n formatRangeToParts: realFormatter.formatRangeToParts.bind(realFormatter),\n resolvedOptions: realFormatter.resolvedOptions.bind(realFormatter),\n format: (date) => realFormatter.format(date || clock.now()),\n formatToParts: (date) => realFormatter.formatToParts(date || clock.now())\n };\n return formatter;\n };\n ClockIntl.DateTimeFormat.prototype = Object.create(\n NativeIntl.DateTimeFormat.prototype\n );\n ClockIntl.DateTimeFormat.supportedLocalesOf = NativeIntl.DateTimeFormat.supportedLocalesOf;\n return ClockIntl;\n}\nfunction compareTimers(a, b) {\n if (a.callAt < b.callAt)\n return -1;\n if (a.callAt > b.callAt)\n return 1;\n if (a.type === \"Immediate\" /* Immediate */ && b.type !== \"Immediate\" /* Immediate */)\n return -1;\n if (a.type !== \"Immediate\" /* Immediate */ && b.type === \"Immediate\" /* Immediate */)\n return 1;\n if (a.createdAt < b.createdAt)\n return -1;\n if (a.createdAt > b.createdAt)\n return 1;\n if (a.id < b.id)\n return -1;\n if (a.id > b.id)\n return 1;\n}\nvar maxTimeout = Math.pow(2, 31) - 1;\nvar idCounterStart = 1e12;\nfunction platformOriginals(globalObject) {\n const raw = {\n setTimeout: globalObject.setTimeout,\n clearTimeout: globalObject.clearTimeout,\n setInterval: globalObject.setInterval,\n clearInterval: globalObject.clearInterval,\n requestAnimationFrame: globalObject.requestAnimationFrame ? globalObject.requestAnimationFrame : void 0,\n cancelAnimationFrame: globalObject.cancelAnimationFrame ? globalObject.cancelAnimationFrame : void 0,\n requestIdleCallback: globalObject.requestIdleCallback ? globalObject.requestIdleCallback : void 0,\n cancelIdleCallback: globalObject.cancelIdleCallback ? globalObject.cancelIdleCallback : void 0,\n Date: globalObject.Date,\n performance: globalObject.performance,\n Intl: globalObject.Intl\n };\n const bound = { ...raw };\n for (const key of Object.keys(bound)) {\n if (key !== \"Date\" && typeof bound[key] === \"function\")\n bound[key] = bound[key].bind(globalObject);\n }\n return { raw, bound };\n}\nfunction getScheduleHandler(type) {\n if (type === \"IdleCallback\" || type === \"AnimationFrame\")\n return `request${type}`;\n return `set${type}`;\n}\nfunction createApi(clock, originals) {\n return {\n setTimeout: (func, timeout, ...args) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: \"Timeout\" /* Timeout */,\n func,\n args,\n delay\n });\n },\n clearTimeout: (timerId) => {\n if (timerId)\n clock.clearTimer(timerId, \"Timeout\" /* Timeout */);\n },\n setInterval: (func, timeout, ...args) => {\n const delay = timeout ? +timeout : timeout;\n return clock.addTimer({\n type: \"Interval\" /* Interval */,\n func,\n args,\n delay\n });\n },\n clearInterval: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, \"Interval\" /* Interval */);\n },\n requestAnimationFrame: (callback) => {\n return clock.addTimer({\n type: \"AnimationFrame\" /* AnimationFrame */,\n func: callback,\n delay: clock.getTimeToNextFrame()\n });\n },\n cancelAnimationFrame: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, \"AnimationFrame\" /* AnimationFrame */);\n },\n requestIdleCallback: (callback, options) => {\n let timeToNextIdlePeriod = 0;\n if (clock.countTimers() > 0)\n timeToNextIdlePeriod = 50;\n return clock.addTimer({\n type: \"IdleCallback\" /* IdleCallback */,\n func: callback,\n delay: (options == null ? void 0 : options.timeout) ? Math.min(options == null ? void 0 : options.timeout, timeToNextIdlePeriod) : timeToNextIdlePeriod\n });\n },\n cancelIdleCallback: (timerId) => {\n if (timerId)\n return clock.clearTimer(timerId, \"IdleCallback\" /* IdleCallback */);\n },\n Intl: originals.Intl ? createIntl(clock, originals.Intl) : void 0,\n Date: createDate(clock, originals.Date),\n performance: originals.performance ? fakePerformance(clock, originals.performance) : void 0\n };\n}\nfunction getClearHandler(type) {\n if (type === \"IdleCallback\" || type === \"AnimationFrame\")\n return `cancel${type}`;\n return `clear${type}`;\n}\nfunction fakePerformance(clock, performance) {\n const result = {\n now: () => clock.performanceNow()\n };\n result.__defineGetter__(\"timeOrigin\", () => clock._now.origin || 0);\n for (const key of Object.keys(performance.__proto__)) {\n if (key === \"now\" || key === \"timeOrigin\")\n continue;\n if (key === \"getEntries\" || key === \"getEntriesByName\" || key === \"getEntriesByType\")\n result[key] = () => [];\n else\n result[key] = () => {\n };\n }\n return result;\n}\nfunction createClock(globalObject) {\n const originals = platformOriginals(globalObject);\n const embedder = {\n dateNow: () => originals.raw.Date.now(),\n performanceNow: () => Math.ceil(originals.raw.performance.now()),\n setTimeout: (task, timeout) => {\n const timerId = originals.bound.setTimeout(task, timeout);\n return () => originals.bound.clearTimeout(timerId);\n },\n setInterval: (task, delay) => {\n const intervalId = originals.bound.setInterval(task, delay);\n return () => originals.bound.clearInterval(intervalId);\n }\n };\n const clock = new ClockController(embedder);\n const api = createApi(clock, originals.bound);\n return { clock, api, originals: originals.raw };\n}\nfunction install(globalObject, config = {}) {\n var _a, _b;\n if ((_a = globalObject.Date) == null ? void 0 : _a.isFake) {\n throw new TypeError(`Can't install fake timers twice on the same global object.`);\n }\n const { clock, api, originals } = createClock(globalObject);\n const toFake = ((_b = config.toFake) == null ? void 0 : _b.length) ? config.toFake : Object.keys(originals);\n for (const method of toFake) {\n if (method === \"Date\") {\n globalObject.Date = mirrorDateProperties(api.Date, globalObject.Date);\n } else if (method === \"Intl\") {\n globalObject.Intl = api[method];\n } else if (method === \"performance\") {\n globalObject.performance = api[method];\n const kEventTimeStamp = Symbol(\"playwrightEventTimeStamp\");\n Object.defineProperty(Event.prototype, \"timeStamp\", {\n get() {\n var _a2;\n if (!this[kEventTimeStamp])\n this[kEventTimeStamp] = (_a2 = api.performance) == null ? void 0 : _a2.now();\n return this[kEventTimeStamp];\n }\n });\n } else {\n globalObject[method] = (...args) => {\n return api[method].apply(api, args);\n };\n }\n clock.disposables.push(() => {\n globalObject[method] = originals[method];\n });\n }\n return { clock, api, originals };\n}\nfunction inject(globalObject) {\n const builtin = platformOriginals(globalObject).bound;\n const { clock: controller } = install(globalObject);\n controller.resume();\n return {\n controller,\n builtin\n };\n}\nfunction asWallTime(n) {\n return n;\n}\nfunction shiftTicks(ticks, ms) {\n return ticks + ms;\n}\n";
|
|
8
|
+
//# sourceMappingURL=clockSource.js.map
|