@checkly/playwright-core 1.48.23 → 1.48.24-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/generated/clockSource.js +1 -2
- package/lib/generated/consoleApiSource.js +1 -2
- package/lib/generated/injectedScriptSource.js +1 -2
- package/lib/generated/pollingRecorderSource.js +1 -2
- package/lib/generated/utilityScriptSource.js +1 -2
- package/lib/generated/webSocketMockSource.js +1 -2
- package/lib/vite/traceViewer/assets/codeMirrorModule-lDjkI8Ax.js +24 -0
- package/lib/vite/traceViewer/assets/inspectorTab-BPzhNk9r.js +64 -0
- package/lib/vite/traceViewer/assets/workbench-DLv_q9ji.js +9 -0
- package/lib/vite/traceViewer/embedded.BIubxTi3.js +2 -0
- package/lib/vite/traceViewer/embedded.html +3 -3
- package/lib/vite/traceViewer/index.DPD22sZn.js +2 -0
- package/lib/vite/traceViewer/index.html +3 -3
- package/lib/vite/traceViewer/recorder.BaRuS6Pc.js +2 -0
- package/lib/vite/traceViewer/recorder.html +2 -2
- package/lib/vite/traceViewer/uiMode.B11wexdJ.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +3 -3
- package/package.json +1 -1
- package/lib/client/clientStackTrace.js +0 -65
- package/lib/client/fileUtils.js +0 -31
- package/lib/client/platform.js +0 -71
- package/lib/client/timeoutSettings.js +0 -65
- package/lib/client/webSocket.js +0 -106
- package/lib/server/callLog.js +0 -79
- package/lib/server/harBackend.js +0 -157
- package/lib/server/localUtils.js +0 -203
- package/lib/server/recorder/chat.js +0 -177
- package/lib/server/storageScript.js +0 -160
- package/lib/server/timeoutSettings.js +0 -74
- package/lib/server/utils/ascii.js +0 -31
- package/lib/server/utils/comparators.js +0 -159
- package/lib/server/utils/crypto.js +0 -171
- package/lib/server/utils/debug.js +0 -38
- package/lib/server/utils/debugLogger.js +0 -93
- package/lib/server/utils/env.js +0 -53
- package/lib/server/utils/eventsHelper.js +0 -38
- package/lib/server/utils/expectUtils.js +0 -33
- package/lib/server/utils/fileUtils.js +0 -204
- package/lib/server/utils/happyEyeballs.js +0 -209
- package/lib/server/utils/hostPlatform.js +0 -145
- package/lib/server/utils/httpServer.js +0 -233
- package/lib/server/utils/image_tools/colorUtils.js +0 -98
- package/lib/server/utils/image_tools/compare.js +0 -108
- package/lib/server/utils/image_tools/imageChannel.js +0 -70
- package/lib/server/utils/image_tools/stats.js +0 -102
- package/lib/server/utils/linuxUtils.js +0 -58
- package/lib/server/utils/network.js +0 -160
- package/lib/server/utils/nodePlatform.js +0 -140
- package/lib/server/utils/pipeTransport.js +0 -82
- package/lib/server/utils/processLauncher.js +0 -248
- package/lib/server/utils/profiler.js +0 -52
- package/lib/server/utils/socksProxy.js +0 -570
- package/lib/server/utils/spawnAsync.js +0 -45
- package/lib/server/utils/task.js +0 -58
- package/lib/server/utils/userAgent.js +0 -91
- package/lib/server/utils/wsServer.js +0 -128
- package/lib/server/utils/zipFile.js +0 -75
- package/lib/server/utils/zones.js +0 -54
- package/lib/utils/isomorphic/ariaSnapshot.js +0 -392
- package/lib/utils/isomorphic/assert.js +0 -25
- package/lib/utils/isomorphic/colors.js +0 -65
- package/lib/utils/isomorphic/headers.js +0 -52
- package/lib/utils/isomorphic/manualPromise.js +0 -107
- package/lib/utils/isomorphic/multimap.js +0 -73
- package/lib/utils/isomorphic/rtti.js +0 -41
- package/lib/utils/isomorphic/semaphore.js +0 -51
- package/lib/utils/isomorphic/stackTrace.js +0 -169
- package/lib/utils/isomorphic/time.js +0 -25
- package/lib/utils/isomorphic/timeoutRunner.js +0 -66
- package/lib/utils/isomorphic/types.js +0 -5
- package/lib/utils.js +0 -447
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.calculateSha1 = calculateSha1;
|
|
7
|
-
exports.createGuid = createGuid;
|
|
8
|
-
exports.generateSelfSignedCertificate = generateSelfSignedCertificate;
|
|
9
|
-
var _crypto = _interopRequireDefault(require("crypto"));
|
|
10
|
-
var _assert = require("../../utils/isomorphic/assert");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
/**
|
|
13
|
-
* Copyright (c) Microsoft Corporation.
|
|
14
|
-
*
|
|
15
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
16
|
-
* you may not use this file except in compliance with the License.
|
|
17
|
-
* You may obtain a copy of the License at
|
|
18
|
-
*
|
|
19
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
-
*
|
|
21
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
22
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
23
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
24
|
-
* See the License for the specific language governing permissions and
|
|
25
|
-
* limitations under the License.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
function createGuid() {
|
|
29
|
-
return _crypto.default.randomBytes(16).toString('hex');
|
|
30
|
-
}
|
|
31
|
-
function calculateSha1(buffer) {
|
|
32
|
-
const hash = _crypto.default.createHash('sha1');
|
|
33
|
-
hash.update(buffer);
|
|
34
|
-
return hash.digest('hex');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Variable-length quantity encoding aka. base-128 encoding
|
|
38
|
-
function encodeBase128(value) {
|
|
39
|
-
const bytes = [];
|
|
40
|
-
do {
|
|
41
|
-
let byte = value & 0x7f;
|
|
42
|
-
value >>>= 7;
|
|
43
|
-
if (bytes.length > 0) byte |= 0x80;
|
|
44
|
-
bytes.push(byte);
|
|
45
|
-
} while (value > 0);
|
|
46
|
-
return Buffer.from(bytes.reverse());
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// ASN1/DER Speficiation: https://www.itu.int/rec/T-REC-X.680-X.693-202102-I/en
|
|
50
|
-
class DER {
|
|
51
|
-
static encodeSequence(data) {
|
|
52
|
-
return this._encode(0x30, Buffer.concat(data));
|
|
53
|
-
}
|
|
54
|
-
static encodeInteger(data) {
|
|
55
|
-
(0, _assert.assert)(data >= -128 && data <= 127);
|
|
56
|
-
return this._encode(0x02, Buffer.from([data]));
|
|
57
|
-
}
|
|
58
|
-
static encodeObjectIdentifier(oid) {
|
|
59
|
-
const parts = oid.split('.').map(v => Number(v));
|
|
60
|
-
// Encode the second part, which could be large, using base-128 encoding if necessary
|
|
61
|
-
const output = [encodeBase128(40 * parts[0] + parts[1])];
|
|
62
|
-
for (let i = 2; i < parts.length; i++) output.push(encodeBase128(parts[i]));
|
|
63
|
-
return this._encode(0x06, Buffer.concat(output));
|
|
64
|
-
}
|
|
65
|
-
static encodeNull() {
|
|
66
|
-
return Buffer.from([0x05, 0x00]);
|
|
67
|
-
}
|
|
68
|
-
static encodeSet(data) {
|
|
69
|
-
(0, _assert.assert)(data.length === 1, 'Only one item in the set is supported. We\'d need to sort the data to support more.');
|
|
70
|
-
// We expect the data to be already sorted.
|
|
71
|
-
return this._encode(0x31, Buffer.concat(data));
|
|
72
|
-
}
|
|
73
|
-
static encodeExplicitContextDependent(tag, data) {
|
|
74
|
-
return this._encode(0xa0 + tag, data);
|
|
75
|
-
}
|
|
76
|
-
static encodePrintableString(data) {
|
|
77
|
-
return this._encode(0x13, Buffer.from(data));
|
|
78
|
-
}
|
|
79
|
-
static encodeBitString(data) {
|
|
80
|
-
// The first byte of the content is the number of unused bits at the end
|
|
81
|
-
const unusedBits = 0; // Assuming all bits are used
|
|
82
|
-
const content = Buffer.concat([Buffer.from([unusedBits]), data]);
|
|
83
|
-
return this._encode(0x03, content);
|
|
84
|
-
}
|
|
85
|
-
static encodeDate(date) {
|
|
86
|
-
const year = date.getUTCFullYear();
|
|
87
|
-
const isGeneralizedTime = year >= 2050;
|
|
88
|
-
const parts = [isGeneralizedTime ? year.toString() : year.toString().slice(-2), (date.getUTCMonth() + 1).toString().padStart(2, '0'), date.getUTCDate().toString().padStart(2, '0'), date.getUTCHours().toString().padStart(2, '0'), date.getUTCMinutes().toString().padStart(2, '0'), date.getUTCSeconds().toString().padStart(2, '0')];
|
|
89
|
-
const encodedDate = parts.join('') + 'Z';
|
|
90
|
-
const tag = isGeneralizedTime ? 0x18 : 0x17; // 0x18 for GeneralizedTime, 0x17 for UTCTime
|
|
91
|
-
return this._encode(tag, Buffer.from(encodedDate));
|
|
92
|
-
}
|
|
93
|
-
static _encode(tag, data) {
|
|
94
|
-
const lengthBytes = this._encodeLength(data.length);
|
|
95
|
-
return Buffer.concat([Buffer.from([tag]), lengthBytes, data]);
|
|
96
|
-
}
|
|
97
|
-
static _encodeLength(length) {
|
|
98
|
-
if (length < 128) {
|
|
99
|
-
return Buffer.from([length]);
|
|
100
|
-
} else {
|
|
101
|
-
const lengthBytes = [];
|
|
102
|
-
while (length > 0) {
|
|
103
|
-
lengthBytes.unshift(length & 0xFF);
|
|
104
|
-
length >>= 8;
|
|
105
|
-
}
|
|
106
|
-
return Buffer.from([0x80 | lengthBytes.length, ...lengthBytes]);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// X.509 Specification: https://datatracker.ietf.org/doc/html/rfc2459#section-4.1
|
|
112
|
-
function generateSelfSignedCertificate() {
|
|
113
|
-
const {
|
|
114
|
-
privateKey,
|
|
115
|
-
publicKey
|
|
116
|
-
} = _crypto.default.generateKeyPairSync('rsa', {
|
|
117
|
-
modulusLength: 2048
|
|
118
|
-
});
|
|
119
|
-
const publicKeyDer = publicKey.export({
|
|
120
|
-
type: 'pkcs1',
|
|
121
|
-
format: 'der'
|
|
122
|
-
});
|
|
123
|
-
const oneYearInMilliseconds = 365 * 24 * 60 * 60 * 1_000;
|
|
124
|
-
const notBefore = new Date(new Date().getTime() - oneYearInMilliseconds);
|
|
125
|
-
const notAfter = new Date(new Date().getTime() + oneYearInMilliseconds);
|
|
126
|
-
|
|
127
|
-
// List of fields / structure: https://datatracker.ietf.org/doc/html/rfc2459#section-4.1
|
|
128
|
-
const tbsCertificate = DER.encodeSequence([DER.encodeExplicitContextDependent(0, DER.encodeInteger(1)),
|
|
129
|
-
// version
|
|
130
|
-
DER.encodeInteger(1),
|
|
131
|
-
// serialNumber
|
|
132
|
-
DER.encodeSequence([DER.encodeObjectIdentifier('1.2.840.113549.1.1.11'),
|
|
133
|
-
// sha256WithRSAEncryption PKCS #1
|
|
134
|
-
DER.encodeNull()]),
|
|
135
|
-
// signature
|
|
136
|
-
DER.encodeSequence([DER.encodeSet([DER.encodeSequence([DER.encodeObjectIdentifier('2.5.4.3'),
|
|
137
|
-
// commonName X.520 DN component
|
|
138
|
-
DER.encodePrintableString('localhost')])]), DER.encodeSet([DER.encodeSequence([DER.encodeObjectIdentifier('2.5.4.10'),
|
|
139
|
-
// organizationName X.520 DN component
|
|
140
|
-
DER.encodePrintableString('Playwright Client Certificate Support')])])]),
|
|
141
|
-
// issuer
|
|
142
|
-
DER.encodeSequence([DER.encodeDate(notBefore),
|
|
143
|
-
// notBefore
|
|
144
|
-
DER.encodeDate(notAfter) // notAfter
|
|
145
|
-
]),
|
|
146
|
-
// validity
|
|
147
|
-
DER.encodeSequence([DER.encodeSet([DER.encodeSequence([DER.encodeObjectIdentifier('2.5.4.3'),
|
|
148
|
-
// commonName X.520 DN component
|
|
149
|
-
DER.encodePrintableString('localhost')])]), DER.encodeSet([DER.encodeSequence([DER.encodeObjectIdentifier('2.5.4.10'),
|
|
150
|
-
// organizationName X.520 DN component
|
|
151
|
-
DER.encodePrintableString('Playwright Client Certificate Support')])])]),
|
|
152
|
-
// subject
|
|
153
|
-
DER.encodeSequence([DER.encodeSequence([DER.encodeObjectIdentifier('1.2.840.113549.1.1.1'),
|
|
154
|
-
// rsaEncryption PKCS #1
|
|
155
|
-
DER.encodeNull()]), DER.encodeBitString(publicKeyDer)]) // SubjectPublicKeyInfo
|
|
156
|
-
]);
|
|
157
|
-
const signature = _crypto.default.sign('sha256', tbsCertificate, privateKey);
|
|
158
|
-
const certificate = DER.encodeSequence([tbsCertificate, DER.encodeSequence([DER.encodeObjectIdentifier('1.2.840.113549.1.1.11'),
|
|
159
|
-
// sha256WithRSAEncryption PKCS #1
|
|
160
|
-
DER.encodeNull()]), DER.encodeBitString(signature)]);
|
|
161
|
-
const certPem = ['-----BEGIN CERTIFICATE-----',
|
|
162
|
-
// Split the base64 string into lines of 64 characters
|
|
163
|
-
certificate.toString('base64').match(/.{1,64}/g).join('\n'), '-----END CERTIFICATE-----'].join('\n');
|
|
164
|
-
return {
|
|
165
|
-
cert: certPem,
|
|
166
|
-
key: privateKey.export({
|
|
167
|
-
type: 'pkcs1',
|
|
168
|
-
format: 'pem'
|
|
169
|
-
})
|
|
170
|
-
};
|
|
171
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.debugMode = debugMode;
|
|
7
|
-
exports.isUnderTest = isUnderTest;
|
|
8
|
-
exports.setUnderTest = setUnderTest;
|
|
9
|
-
var _env = require("./env");
|
|
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 _debugMode = (0, _env.getFromENV)('PWDEBUG') || '';
|
|
27
|
-
function debugMode() {
|
|
28
|
-
if (_debugMode === 'console') return 'console';
|
|
29
|
-
if (_debugMode === '0' || _debugMode === 'false') return '';
|
|
30
|
-
return _debugMode ? 'inspector' : '';
|
|
31
|
-
}
|
|
32
|
-
let _isUnderTest = !!process.env.PWTEST_UNDER_TEST;
|
|
33
|
-
function setUnderTest() {
|
|
34
|
-
_isUnderTest = true;
|
|
35
|
-
}
|
|
36
|
-
function isUnderTest() {
|
|
37
|
-
return _isUnderTest;
|
|
38
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.debugLogger = exports.RecentLogsCollector = void 0;
|
|
7
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
8
|
-
var _utilsBundle = require("../../utilsBundle");
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
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
|
-
'client-certificates': 92,
|
|
40
|
-
// purple
|
|
41
|
-
'error': 160,
|
|
42
|
-
// red,
|
|
43
|
-
'channel': 33,
|
|
44
|
-
// blue
|
|
45
|
-
'server': 45,
|
|
46
|
-
// cyan
|
|
47
|
-
'server:channel': 34,
|
|
48
|
-
// green
|
|
49
|
-
'server:metadata': 33,
|
|
50
|
-
// blue,
|
|
51
|
-
'recorder': 45 // cyan
|
|
52
|
-
};
|
|
53
|
-
class DebugLogger {
|
|
54
|
-
constructor() {
|
|
55
|
-
this._debuggers = new Map();
|
|
56
|
-
if (process.env.DEBUG_FILE) {
|
|
57
|
-
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');
|
|
58
|
-
const stream = _fs.default.createWriteStream(process.env.DEBUG_FILE);
|
|
59
|
-
_utilsBundle.debug.log = data => {
|
|
60
|
-
stream.write(data.replace(ansiRegex, ''));
|
|
61
|
-
stream.write('\n');
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
log(name, message) {
|
|
66
|
-
let cachedDebugger = this._debuggers.get(name);
|
|
67
|
-
if (!cachedDebugger) {
|
|
68
|
-
cachedDebugger = (0, _utilsBundle.debug)(`pw:${name}`);
|
|
69
|
-
this._debuggers.set(name, cachedDebugger);
|
|
70
|
-
cachedDebugger.color = debugLoggerColorMap[name] || 0;
|
|
71
|
-
}
|
|
72
|
-
cachedDebugger(message);
|
|
73
|
-
}
|
|
74
|
-
isEnabled(name) {
|
|
75
|
-
return _utilsBundle.debug.enabled(`pw:${name}`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
const debugLogger = exports.debugLogger = new DebugLogger();
|
|
79
|
-
const kLogCount = 150;
|
|
80
|
-
class RecentLogsCollector {
|
|
81
|
-
constructor() {
|
|
82
|
-
this._logs = [];
|
|
83
|
-
}
|
|
84
|
-
log(message) {
|
|
85
|
-
this._logs.push(message);
|
|
86
|
-
if (this._logs.length === kLogCount * 2) this._logs.splice(0, kLogCount);
|
|
87
|
-
}
|
|
88
|
-
recentLogs() {
|
|
89
|
-
if (this._logs.length > kLogCount) return this._logs.slice(-kLogCount);
|
|
90
|
-
return this._logs;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
exports.RecentLogsCollector = RecentLogsCollector;
|
package/lib/server/utils/env.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getAsBooleanFromENV = getAsBooleanFromENV;
|
|
7
|
-
exports.getFromENV = getFromENV;
|
|
8
|
-
exports.getPackageManager = getPackageManager;
|
|
9
|
-
exports.getPackageManagerExecCommand = getPackageManagerExecCommand;
|
|
10
|
-
exports.isLikelyNpxGlobal = isLikelyNpxGlobal;
|
|
11
|
-
/**
|
|
12
|
-
* Copyright (c) Microsoft Corporation.
|
|
13
|
-
*
|
|
14
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15
|
-
* you may not use this file except in compliance with the License.
|
|
16
|
-
* You may obtain a copy of the License at
|
|
17
|
-
*
|
|
18
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
-
*
|
|
20
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
21
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
22
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
23
|
-
* See the License for the specific language governing permissions and
|
|
24
|
-
* limitations under the License.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
function getFromENV(name) {
|
|
28
|
-
let value = process.env[name];
|
|
29
|
-
value = value === undefined ? process.env[`npm_config_${name.toLowerCase()}`] : value;
|
|
30
|
-
value = value === undefined ? process.env[`npm_package_config_${name.toLowerCase()}`] : value;
|
|
31
|
-
return value;
|
|
32
|
-
}
|
|
33
|
-
function getAsBooleanFromENV(name, defaultValue) {
|
|
34
|
-
const value = getFromENV(name);
|
|
35
|
-
if (value === 'false' || value === '0') return false;
|
|
36
|
-
if (value) return true;
|
|
37
|
-
return !!defaultValue;
|
|
38
|
-
}
|
|
39
|
-
function getPackageManager() {
|
|
40
|
-
const env = process.env.npm_config_user_agent || '';
|
|
41
|
-
if (env.includes('yarn')) return 'yarn';
|
|
42
|
-
if (env.includes('pnpm')) return 'pnpm';
|
|
43
|
-
return 'npm';
|
|
44
|
-
}
|
|
45
|
-
function getPackageManagerExecCommand() {
|
|
46
|
-
const packageManager = getPackageManager();
|
|
47
|
-
if (packageManager === 'yarn') return 'yarn';
|
|
48
|
-
if (packageManager === 'pnpm') return 'pnpm exec';
|
|
49
|
-
return 'npx';
|
|
50
|
-
}
|
|
51
|
-
function isLikelyNpxGlobal() {
|
|
52
|
-
return process.argv.length >= 2 && process.argv[1].includes('_npx');
|
|
53
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.eventsHelper = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Copyright 2017 Google Inc. All rights reserved.
|
|
9
|
-
* Modifications copyright (c) Microsoft Corporation.
|
|
10
|
-
*
|
|
11
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
-
* you may not use this file except in compliance with the License.
|
|
13
|
-
* You may obtain a copy of the License at
|
|
14
|
-
*
|
|
15
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
-
*
|
|
17
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
-
* See the License for the specific language governing permissions and
|
|
21
|
-
* limitations under the License.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
class EventsHelper {
|
|
25
|
-
static addEventListener(emitter, eventName, handler) {
|
|
26
|
-
emitter.on(eventName, handler);
|
|
27
|
-
return {
|
|
28
|
-
emitter,
|
|
29
|
-
eventName,
|
|
30
|
-
handler
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
static removeEventListeners(listeners) {
|
|
34
|
-
for (const listener of listeners) listener.emitter.removeListener(listener.eventName, listener.handler);
|
|
35
|
-
listeners.splice(0, listeners.length);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const eventsHelper = exports.eventsHelper = EventsHelper;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.serializeExpectedTextValues = serializeExpectedTextValues;
|
|
7
|
-
var _rtti = require("../../utils/isomorphic/rtti");
|
|
8
|
-
/**
|
|
9
|
-
* Copyright (c) Microsoft Corporation.
|
|
10
|
-
*
|
|
11
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
-
* you may not use this file except in compliance with the License.
|
|
13
|
-
* You may obtain a copy of the License at
|
|
14
|
-
*
|
|
15
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
-
*
|
|
17
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
-
* See the License for the specific language governing permissions and
|
|
21
|
-
* limitations under the License.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
function serializeExpectedTextValues(items, options = {}) {
|
|
25
|
-
return items.map(i => ({
|
|
26
|
-
string: (0, _rtti.isString)(i) ? i : undefined,
|
|
27
|
-
regexSource: (0, _rtti.isRegExp)(i) ? i.source : undefined,
|
|
28
|
-
regexFlags: (0, _rtti.isRegExp)(i) ? i.flags : undefined,
|
|
29
|
-
matchSubstring: options.matchSubstring,
|
|
30
|
-
ignoreCase: options.ignoreCase,
|
|
31
|
-
normalizeWhiteSpace: options.normalizeWhiteSpace
|
|
32
|
-
}));
|
|
33
|
-
}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SerializedFS = void 0;
|
|
7
|
-
exports.canAccessFile = canAccessFile;
|
|
8
|
-
exports.copyFileAndMakeWritable = copyFileAndMakeWritable;
|
|
9
|
-
exports.existsAsync = void 0;
|
|
10
|
-
exports.mkdirIfNeeded = mkdirIfNeeded;
|
|
11
|
-
exports.removeFolders = removeFolders;
|
|
12
|
-
exports.sanitizeForFilePath = sanitizeForFilePath;
|
|
13
|
-
exports.toPosixPath = toPosixPath;
|
|
14
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
15
|
-
var _path = _interopRequireDefault(require("path"));
|
|
16
|
-
var _manualPromise = require("../../utils/isomorphic/manualPromise");
|
|
17
|
-
var _zipBundle = require("../../zipBundle");
|
|
18
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
-
/**
|
|
20
|
-
* Copyright (c) Microsoft Corporation.
|
|
21
|
-
*
|
|
22
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
23
|
-
* you may not use this file except in compliance with the License.
|
|
24
|
-
* You may obtain a copy of the License at
|
|
25
|
-
*
|
|
26
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
27
|
-
*
|
|
28
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
29
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
30
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
31
|
-
* See the License for the specific language governing permissions and
|
|
32
|
-
* limitations under the License.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
const existsAsync = path => new Promise(resolve => _fs.default.stat(path, err => resolve(!err)));
|
|
36
|
-
exports.existsAsync = existsAsync;
|
|
37
|
-
async function mkdirIfNeeded(filePath) {
|
|
38
|
-
// This will harmlessly throw on windows if the dirname is the root directory.
|
|
39
|
-
await _fs.default.promises.mkdir(_path.default.dirname(filePath), {
|
|
40
|
-
recursive: true
|
|
41
|
-
}).catch(() => {});
|
|
42
|
-
}
|
|
43
|
-
async function removeFolders(dirs) {
|
|
44
|
-
return await Promise.all(dirs.map(dir => _fs.default.promises.rm(dir, {
|
|
45
|
-
recursive: true,
|
|
46
|
-
force: true,
|
|
47
|
-
maxRetries: 10
|
|
48
|
-
}).catch(e => e)));
|
|
49
|
-
}
|
|
50
|
-
function canAccessFile(file) {
|
|
51
|
-
if (!file) return false;
|
|
52
|
-
try {
|
|
53
|
-
_fs.default.accessSync(file);
|
|
54
|
-
return true;
|
|
55
|
-
} catch (e) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
async function copyFileAndMakeWritable(from, to) {
|
|
60
|
-
await _fs.default.promises.copyFile(from, to);
|
|
61
|
-
await _fs.default.promises.chmod(to, 0o664);
|
|
62
|
-
}
|
|
63
|
-
function sanitizeForFilePath(s) {
|
|
64
|
-
return s.replace(/[\x00-\x2C\x2E-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, '-');
|
|
65
|
-
}
|
|
66
|
-
function toPosixPath(aPath) {
|
|
67
|
-
return aPath.split(_path.default.sep).join(_path.default.posix.sep);
|
|
68
|
-
}
|
|
69
|
-
class SerializedFS {
|
|
70
|
-
constructor() {
|
|
71
|
-
this._buffers = new Map();
|
|
72
|
-
// Should never be accessed from within appendOperation.
|
|
73
|
-
this._error = void 0;
|
|
74
|
-
this._operations = [];
|
|
75
|
-
this._operationsDone = void 0;
|
|
76
|
-
this._operationsDone = new _manualPromise.ManualPromise();
|
|
77
|
-
this._operationsDone.resolve(); // No operations scheduled yet.
|
|
78
|
-
}
|
|
79
|
-
mkdir(dir) {
|
|
80
|
-
this._appendOperation({
|
|
81
|
-
op: 'mkdir',
|
|
82
|
-
dir
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
writeFile(file, content, skipIfExists) {
|
|
86
|
-
this._buffers.delete(file); // No need to flush the buffer since we'll overwrite anyway.
|
|
87
|
-
this._appendOperation({
|
|
88
|
-
op: 'writeFile',
|
|
89
|
-
file,
|
|
90
|
-
content,
|
|
91
|
-
skipIfExists
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
appendFile(file, text, flush) {
|
|
95
|
-
if (!this._buffers.has(file)) this._buffers.set(file, []);
|
|
96
|
-
this._buffers.get(file).push(text);
|
|
97
|
-
if (flush) this._flushFile(file);
|
|
98
|
-
}
|
|
99
|
-
_flushFile(file) {
|
|
100
|
-
const buffer = this._buffers.get(file);
|
|
101
|
-
if (buffer === undefined) return;
|
|
102
|
-
const content = buffer.join('');
|
|
103
|
-
this._buffers.delete(file);
|
|
104
|
-
this._appendOperation({
|
|
105
|
-
op: 'appendFile',
|
|
106
|
-
file,
|
|
107
|
-
content
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
copyFile(from, to) {
|
|
111
|
-
this._flushFile(from);
|
|
112
|
-
this._buffers.delete(to); // No need to flush the buffer since we'll overwrite anyway.
|
|
113
|
-
this._appendOperation({
|
|
114
|
-
op: 'copyFile',
|
|
115
|
-
from,
|
|
116
|
-
to
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
async syncAndGetError() {
|
|
120
|
-
for (const file of this._buffers.keys()) this._flushFile(file);
|
|
121
|
-
await this._operationsDone;
|
|
122
|
-
return this._error;
|
|
123
|
-
}
|
|
124
|
-
zip(entries, zipFileName) {
|
|
125
|
-
for (const file of this._buffers.keys()) this._flushFile(file);
|
|
126
|
-
|
|
127
|
-
// Chain the export operation against write operations,
|
|
128
|
-
// so that files do not change during the export.
|
|
129
|
-
this._appendOperation({
|
|
130
|
-
op: 'zip',
|
|
131
|
-
entries,
|
|
132
|
-
zipFileName
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// This method serializes all writes to the trace.
|
|
137
|
-
_appendOperation(op) {
|
|
138
|
-
const last = this._operations[this._operations.length - 1];
|
|
139
|
-
if ((last === null || last === void 0 ? void 0 : last.op) === 'appendFile' && op.op === 'appendFile' && last.file === op.file) {
|
|
140
|
-
// Merge pending appendFile operations for performance.
|
|
141
|
-
last.content += op.content;
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
this._operations.push(op);
|
|
145
|
-
if (this._operationsDone.isDone()) this._performOperations();
|
|
146
|
-
}
|
|
147
|
-
async _performOperations() {
|
|
148
|
-
this._operationsDone = new _manualPromise.ManualPromise();
|
|
149
|
-
while (this._operations.length) {
|
|
150
|
-
const op = this._operations.shift();
|
|
151
|
-
// Ignore all operations after the first error.
|
|
152
|
-
if (this._error) continue;
|
|
153
|
-
try {
|
|
154
|
-
await this._performOperation(op);
|
|
155
|
-
} catch (e) {
|
|
156
|
-
this._error = e;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
this._operationsDone.resolve();
|
|
160
|
-
}
|
|
161
|
-
async _performOperation(op) {
|
|
162
|
-
switch (op.op) {
|
|
163
|
-
case 'mkdir':
|
|
164
|
-
{
|
|
165
|
-
await _fs.default.promises.mkdir(op.dir, {
|
|
166
|
-
recursive: true
|
|
167
|
-
});
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
case 'writeFile':
|
|
171
|
-
{
|
|
172
|
-
// Note: 'wx' flag only writes when the file does not exist.
|
|
173
|
-
// See https://nodejs.org/api/fs.html#file-system-flags.
|
|
174
|
-
// This way tracing never have to write the same resource twice.
|
|
175
|
-
if (op.skipIfExists) await _fs.default.promises.writeFile(op.file, op.content, {
|
|
176
|
-
flag: 'wx'
|
|
177
|
-
}).catch(() => {});else await _fs.default.promises.writeFile(op.file, op.content);
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
case 'copyFile':
|
|
181
|
-
{
|
|
182
|
-
await _fs.default.promises.copyFile(op.from, op.to);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
case 'appendFile':
|
|
186
|
-
{
|
|
187
|
-
await _fs.default.promises.appendFile(op.file, op.content);
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
case 'zip':
|
|
191
|
-
{
|
|
192
|
-
const zipFile = new _zipBundle.yazl.ZipFile();
|
|
193
|
-
const result = new _manualPromise.ManualPromise();
|
|
194
|
-
zipFile.on('error', error => result.reject(error));
|
|
195
|
-
for (const entry of op.entries) zipFile.addFile(entry.value, entry.name);
|
|
196
|
-
zipFile.end();
|
|
197
|
-
zipFile.outputStream.pipe(_fs.default.createWriteStream(op.zipFileName)).on('close', () => result.resolve()).on('error', error => result.reject(error));
|
|
198
|
-
await result;
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
exports.SerializedFS = SerializedFS;
|