@checkly/playwright-core 1.42.12 → 1.42.13
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/checkly/sWatcher.js +150 -0
- package/lib/cli/cli.js +62 -0
- package/lib/client/channelOwner.js +1 -1
- package/lib/client/fetch.js +9 -5
- package/lib/common/debugLogger.js +91 -0
- package/lib/generated/consoleApiSource.js +2 -1
- package/lib/generated/injectedScriptSource.js +2 -1
- package/lib/generated/recorderSource.js +2 -1
- package/lib/generated/utilityScriptSource.js +2 -1
- package/lib/vite/recorder/assets/codeMirrorModule-XkYKvQWL.js +15585 -0
- package/lib/vite/recorder/assets/codeMirrorModule-svF_VrcJ.css +344 -0
- package/lib/vite/recorder/assets/index-Sgxgm22s.css +2455 -0
- package/lib/vite/recorder/assets/index-g7JXfYxX.js +10429 -0
- package/lib/vite/recorder/index.html +2 -2
- package/lib/vite/traceViewer/assets/{codeMirrorModule-Vg1kIqMp.js → codeMirrorModule-0bpaqixv.js} +10 -10
- package/lib/vite/traceViewer/assets/codeMirrorModule-5nkjDDU_.js +15578 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-75b0ca4f.js +24 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-RVP_AMUu.js +15585 -0
- package/lib/vite/{recorder/assets/codeMirrorModule-I9ks4y7D.js → traceViewer/assets/codeMirrorModule-c1454a2e.js} +10 -10
- package/lib/vite/traceViewer/assets/codeMirrorModule-cc2329e4.js +15593 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-d725feea.js +15586 -0
- package/lib/vite/traceViewer/assets/{codeMirrorModule-wLpsbIhd.js → codeMirrorModule-e5a15eec.js} +13 -13
- package/lib/vite/traceViewer/assets/codeMirrorModule-kT-uS7F4.js +15592 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-rcsC5no8.js +15592 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-yboVpgC0.js +15592 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-ytMY1awF.js +15585 -0
- package/lib/vite/traceViewer/assets/wsPort-1-6TL4lc.js +18540 -0
- package/lib/vite/traceViewer/assets/wsPort-54626118.js +18361 -0
- package/lib/vite/traceViewer/assets/wsPort-98e00a94.js +64 -0
- package/lib/vite/traceViewer/assets/wsPort-CAXygIGt.js +18540 -0
- package/lib/vite/traceViewer/assets/wsPort-KEbz4l8i.js +18540 -0
- package/lib/vite/traceViewer/assets/{wsPort-RIoVGhlT.js → wsPort-_JBDEilC.js} +2 -2
- package/lib/vite/traceViewer/assets/wsPort-a88a6a12.js +18361 -0
- package/lib/vite/traceViewer/assets/wsPort-cb764cde.js +64 -0
- package/lib/vite/traceViewer/assets/wsPort-ee2830d7.js +64 -0
- package/lib/vite/traceViewer/assets/wsPort-lTlmZhJd.js +18564 -0
- package/lib/vite/traceViewer/assets/wsPort-xpIMLVfx.js +18540 -0
- package/lib/vite/traceViewer/assets/wsPort-yM58htfg.js +18360 -0
- 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/index.1a1fe659.css +1 -0
- package/lib/vite/traceViewer/index.4a8ee36e.js +2 -0
- package/lib/vite/traceViewer/index.55e65778.js +181 -0
- package/lib/vite/traceViewer/index.5nqVcfiC.js +180 -0
- package/lib/vite/traceViewer/index.742fd3e5.js +181 -0
- package/lib/vite/traceViewer/index.76e9f312.css +124 -0
- package/lib/vite/traceViewer/index.UNF4A0jZ.js +180 -0
- package/lib/vite/traceViewer/index.ZUjC4zt1.js +180 -0
- package/lib/vite/traceViewer/index.a265fbdb.js +2 -0
- package/lib/vite/traceViewer/index.decad628.js +2 -0
- package/lib/vite/traceViewer/index.html +4 -4
- package/lib/vite/traceViewer/index.ici1bqta.js +180 -0
- package/lib/vite/traceViewer/index.mxOcKqpu.js +180 -0
- package/lib/vite/traceViewer/{index.-_8-eHEE.js → index.u51inEcm.js} +1 -1
- package/lib/vite/traceViewer/index.zXVxM5ps.js +180 -0
- package/lib/vite/traceViewer/sw.bundle.js +7403 -4
- 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.2c31018f.css +1324 -0
- package/lib/vite/traceViewer/uiMode.468b0309.js +4 -0
- package/lib/vite/traceViewer/uiMode.67C8Ij-c.js +1490 -0
- package/lib/vite/traceViewer/uiMode.8b41a49d.css +1 -0
- package/lib/vite/traceViewer/uiMode.F_k6a2aC.js +1488 -0
- package/lib/vite/traceViewer/{uiMode.9CwNsWc6.js → uiMode.Fb0bNA4H.js} +1 -1
- package/lib/vite/traceViewer/uiMode.NjZAwD_B.js +1485 -0
- package/lib/vite/traceViewer/uiMode.YQRCZjm8.js +1485 -0
- package/lib/vite/traceViewer/uiMode.b2068d00.js +1484 -0
- package/lib/vite/traceViewer/uiMode.e-PLonGl.js +1490 -0
- package/lib/vite/traceViewer/uiMode.fEEgOxJh.js +1490 -0
- package/lib/vite/traceViewer/uiMode.html +4 -4
- package/lib/vite/traceViewer/uiMode.kvEeWpo2.js +1490 -0
- package/lib/vite/traceViewer/uiMode.ljHA9Ynz.js +1490 -0
- package/lib/vite/traceViewer/uiMode.ybQP_6Xr.js +10 -0
- package/lib/vite/traceViewer/wsPort.997c92cf.css +3513 -0
- package/lib/vite/traceViewer/wsPort.9c9a6767.css +1 -0
- package/lib/vite/traceViewer/wsPort.Oa05jfrO.css +3513 -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-Hs9-1ZG4.css +0 -1
- package/lib/vite/recorder/assets/index-ljsTwXtJ.css +0 -1
- package/lib/vite/recorder/assets/index-yg8ypzl6.js +0 -47
- package/lib/vite/traceViewer/assets/wsPort-f2dAQL4I.js +0 -69
- package/lib/vite/traceViewer/index.qOFdH9Ja.js +0 -2
- package/lib/vite/traceViewer/uiMode.iNIhieBM.js +0 -10
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _promises = _interopRequireDefault(require("fs/promises"));
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
class SWatcher {
|
|
11
|
+
constructor() {
|
|
12
|
+
this._outsideRequestsData = [];
|
|
13
|
+
// Test steps (api calls, assertions) data.
|
|
14
|
+
this._stepsData = new Map();
|
|
15
|
+
// Tracking test.step calls.
|
|
16
|
+
this._testStepIds = [];
|
|
17
|
+
// Tracking internal step to the matching test.step.
|
|
18
|
+
this._testStepRawStepData = {};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* This is to track when a `test.step` statement starts and ends.
|
|
23
|
+
*/
|
|
24
|
+
appendCurrentTestStepId() {
|
|
25
|
+
this._testStepIds = [...this._testStepIds, this.getRandomStepId()];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* This is to add the "test.step" internal Playwright *step* data.
|
|
30
|
+
*
|
|
31
|
+
* @param {Object} rawStep
|
|
32
|
+
*/
|
|
33
|
+
setCurrentTestStepRawStepData(rawStep) {
|
|
34
|
+
this._testStepRawStepData = {
|
|
35
|
+
[this.getCurrentTestStepId()]: rawStep
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* This is to get the parent test.step internal step data when we have nested test.step.
|
|
41
|
+
* It's useful to tell Playwright that it belongs to a particular test.step otherwise by default PW just adds this
|
|
42
|
+
* test.step to the root.
|
|
43
|
+
*
|
|
44
|
+
* @returns {Object|undefined}
|
|
45
|
+
*/
|
|
46
|
+
getParentTestStepRawStepData() {
|
|
47
|
+
return this._testStepRawStepData[this.getParentTestStepId()];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @returns {*}
|
|
53
|
+
*/
|
|
54
|
+
getCurrentTestStepRawStepData() {
|
|
55
|
+
return this._testStepRawStepData[this.getCurrentTestStepId()];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* When a test.step is done, we remove the ID from the tracking array.
|
|
60
|
+
*/
|
|
61
|
+
removeCurrentTestStepId() {
|
|
62
|
+
// Current step is always at the end of this._testStepIds
|
|
63
|
+
this._testStepIds = this._testStepIds.filter(testStepId => testStepId !== this.getCurrentTestStepId());
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Get n-1 test.step ID.
|
|
68
|
+
*
|
|
69
|
+
* @returns {string|null}
|
|
70
|
+
*/
|
|
71
|
+
getParentTestStepId() {
|
|
72
|
+
if (this._testStepIds.length <= 1) return null;
|
|
73
|
+
const [parentTestStepId] = this._testStepIds.slice(-2);
|
|
74
|
+
return parentTestStepId;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Get current test.step ID.
|
|
79
|
+
*
|
|
80
|
+
* @returns {string|undefined}
|
|
81
|
+
*/
|
|
82
|
+
getCurrentTestStepId() {
|
|
83
|
+
const [currentTestStepId] = this._testStepIds.slice(-1);
|
|
84
|
+
return currentTestStepId;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* This is to track when a step (api call, assertion) starts/ends.
|
|
89
|
+
*
|
|
90
|
+
* @param {string} stepId
|
|
91
|
+
*/
|
|
92
|
+
setCurrentStepId(stepId) {
|
|
93
|
+
this._stepsData.set(stepId, []);
|
|
94
|
+
this._stepId = stepId;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Get a step data (api call with request, body etc.; assertion with expected data etc.).
|
|
99
|
+
*
|
|
100
|
+
* @param {string} stepId
|
|
101
|
+
* @returns {Object}
|
|
102
|
+
*/
|
|
103
|
+
getStepData(stepId) {
|
|
104
|
+
return this._stepsData.get(stepId);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* For some reason, when we have two tests with both api calls and the first test is failing, the stepId counter
|
|
109
|
+
* is wrong because it set the same stepId for two different api call. This might be a race condition issue with
|
|
110
|
+
* Playwright.
|
|
111
|
+
*
|
|
112
|
+
* To fix this, we use a random string instead of a simple counter.
|
|
113
|
+
*
|
|
114
|
+
* @returns {string}
|
|
115
|
+
*/
|
|
116
|
+
getRandomStepId() {
|
|
117
|
+
return (Math.random() + 1).toString(36).substring(7);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* This adds the extra data to the current step (api call, assertion).
|
|
122
|
+
*
|
|
123
|
+
* @param {Object} data
|
|
124
|
+
*/
|
|
125
|
+
appendCurrentStepData(data) {
|
|
126
|
+
// StepId is defined which means we are inside a step.
|
|
127
|
+
if (this._stepId) {
|
|
128
|
+
this._stepsData.set(this._stepId, [...(this._stepsData.get(this._stepId) || []), data]);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// If stepId is null then it's probably a request without steps
|
|
133
|
+
// In this case, we push data to a different array in order to track the amount of API call made
|
|
134
|
+
// to bill it properly.
|
|
135
|
+
this._outsideRequestsData.push(data);
|
|
136
|
+
}
|
|
137
|
+
async dispose() {
|
|
138
|
+
// @todo rename getRandomStepId to getRandomId
|
|
139
|
+
await _promises.default.writeFile(_path.default.join(process.env.TEMP_DIR, `apiCalls-${this.getRandomStepId()}.json`), JSON.stringify({
|
|
140
|
+
outsideRequestsData: this._outsideRequestsData.filter(({
|
|
141
|
+
checklyStepCategory
|
|
142
|
+
}) => checklyStepCategory === 'api-call'),
|
|
143
|
+
stepsData: Array.from(this._stepsData).filter(([, [{
|
|
144
|
+
checklyStepCategory
|
|
145
|
+
} = {}]]) => checklyStepCategory === 'api-call')
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
var _default = exports.default = new SWatcher();
|
|
150
|
+
//# sourceMappingURL=sWatcher.js.map
|
package/lib/cli/cli.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
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);
|
|
62
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -185,7 +185,7 @@ class ChannelOwner extends _events.EventEmitter {
|
|
|
185
185
|
const result = await _zones.zones.run('apiZone', apiZone, async () => {
|
|
186
186
|
return await func(apiZone);
|
|
187
187
|
});
|
|
188
|
-
csi === null || csi === void 0 || csi.onApiCallEnd(callCookie);
|
|
188
|
+
csi === null || csi === void 0 || csi.onApiCallEnd(callCookie, null, result);
|
|
189
189
|
logApiCall(logger, `<= ${apiName} succeeded`, isInternal);
|
|
190
190
|
return result;
|
|
191
191
|
} catch (e) {
|
package/lib/client/fetch.js
CHANGED
|
@@ -56,9 +56,6 @@ class APIRequest {
|
|
|
56
56
|
storageState,
|
|
57
57
|
tracesDir
|
|
58
58
|
})).request);
|
|
59
|
-
// Checkly related code.
|
|
60
|
-
//@ts-ignore
|
|
61
|
-
context.__sWatcher__ = options.sWatcher;
|
|
62
59
|
this._contexts.add(context);
|
|
63
60
|
context._request = this;
|
|
64
61
|
context._tracing._tracesDir = tracesDir;
|
|
@@ -132,7 +129,13 @@ class APIRequestContext extends _channelOwner.ChannelOwner {
|
|
|
132
129
|
...options
|
|
133
130
|
});
|
|
134
131
|
}
|
|
132
|
+
async writeApiCallToDisk(options) {
|
|
133
|
+
try {
|
|
134
|
+
await _fs.default.promises.writeFile(_path.default.join(process.env.TEMP_DIR, 'apiCall-' + (Math.random() + 1).toString(36).substring(7) + '.txt'), options.url !== undefined ? options.url : options.request.url());
|
|
135
|
+
} catch {}
|
|
136
|
+
}
|
|
135
137
|
async _innerFetch(options = {}) {
|
|
138
|
+
this.writeApiCallToDisk(options);
|
|
136
139
|
return await this._wrapApiCall(async () => {
|
|
137
140
|
var _options$request, _options$request2, _options$request3;
|
|
138
141
|
(0, _utils.assert)(options.request || typeof options.url === 'string', 'First argument must be either URL string or Request');
|
|
@@ -206,8 +209,6 @@ class APIRequestContext extends _channelOwner.ChannelOwner {
|
|
|
206
209
|
...fixtures,
|
|
207
210
|
...(0, _fetch.getClientCertificates)(options)
|
|
208
211
|
});
|
|
209
|
-
//@ts-ignore
|
|
210
|
-
(0, _fetch.setSWatcherCurrentStepData)(this.__sWatcher__, result);
|
|
211
212
|
return new APIResponse(this, result.response);
|
|
212
213
|
});
|
|
213
214
|
}
|
|
@@ -297,6 +298,9 @@ class APIResponse {
|
|
|
297
298
|
}) => ` ${name}: ${value}`);
|
|
298
299
|
return `APIResponse: ${this.status()} ${this.statusText()}\n${headers.join('\n')}`;
|
|
299
300
|
}
|
|
301
|
+
initializer() {
|
|
302
|
+
return this._initializer;
|
|
303
|
+
}
|
|
300
304
|
_fetchUid() {
|
|
301
305
|
return this._initializer.fetchUid;
|
|
302
306
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
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;
|
|
91
|
+
//# sourceMappingURL=debugLogger.js.map
|