@checkly/playwright-core 1.51.11 → 1.51.12

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.
Files changed (51) hide show
  1. package/lib/common/socksProxy.js +569 -0
  2. package/lib/common/timeoutSettings.js +73 -0
  3. package/lib/common/types.js +5 -0
  4. package/lib/generated/recorderSource.js +7 -0
  5. package/lib/image_tools/colorUtils.js +98 -0
  6. package/lib/image_tools/compare.js +108 -0
  7. package/lib/image_tools/imageChannel.js +70 -0
  8. package/lib/image_tools/stats.js +102 -0
  9. package/lib/protocol/transport.js +82 -0
  10. package/lib/server/fetch.js +4 -3
  11. package/lib/server/recorder/codeGenerator.js +154 -0
  12. package/lib/server/recorder/csharp.js +311 -0
  13. package/lib/server/recorder/java.js +249 -0
  14. package/lib/server/recorder/javascript.js +230 -0
  15. package/lib/server/recorder/jsonl.js +48 -0
  16. package/lib/server/recorder/language.js +45 -0
  17. package/lib/server/recorder/python.js +276 -0
  18. package/lib/server/recorder/recorderActions.js +6 -0
  19. package/lib/server/recorder/utils.js +46 -0
  20. package/lib/server/utils/happyEyeballs.js +9 -7
  21. package/lib/third_party/diff_match_patch.js +2222 -0
  22. package/lib/utils/ascii.js +31 -0
  23. package/lib/utils/comparators.js +171 -0
  24. package/lib/utils/crypto.js +174 -0
  25. package/lib/utils/debug.js +46 -0
  26. package/lib/utils/debugLogger.js +91 -0
  27. package/lib/utils/env.js +49 -0
  28. package/lib/utils/eventsHelper.js +38 -0
  29. package/lib/utils/glob.js +84 -0
  30. package/lib/utils/happy-eyeballs.js +210 -0
  31. package/lib/utils/headers.js +52 -0
  32. package/lib/utils/hostPlatform.js +133 -0
  33. package/lib/utils/httpServer.js +237 -0
  34. package/lib/utils/linuxUtils.js +78 -0
  35. package/lib/utils/manualPromise.js +109 -0
  36. package/lib/utils/mimeType.js +30 -0
  37. package/lib/utils/multimap.js +75 -0
  38. package/lib/utils/network.js +160 -0
  39. package/lib/utils/processLauncher.js +248 -0
  40. package/lib/utils/profiler.js +53 -0
  41. package/lib/utils/rtti.js +44 -0
  42. package/lib/utils/semaphore.js +51 -0
  43. package/lib/utils/spawnAsync.js +45 -0
  44. package/lib/utils/task.js +58 -0
  45. package/lib/utils/time.js +37 -0
  46. package/lib/utils/traceUtils.js +44 -0
  47. package/lib/utils/userAgent.js +105 -0
  48. package/lib/utils/wsServer.js +127 -0
  49. package/lib/utils/zipFile.js +75 -0
  50. package/lib/vite/traceViewer/sw.bundle.js +7888 -0
  51. package/package.json +1 -1
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getEmbedderName = getEmbedderName;
7
+ exports.getPlaywrightVersion = getPlaywrightVersion;
8
+ exports.getUserAgent = getUserAgent;
9
+ exports.userAgentVersionMatchesErrorMessage = userAgentVersionMatchesErrorMessage;
10
+ var _child_process = require("child_process");
11
+ var _os = _interopRequireDefault(require("os"));
12
+ var _linuxUtils = require("../utils/linuxUtils");
13
+ var _ascii = require("./ascii");
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ /**
16
+ * Copyright (c) Microsoft Corporation.
17
+ *
18
+ * Licensed under the Apache License, Version 2.0 (the "License");
19
+ * you may not use this file except in compliance with the License.
20
+ * You may obtain a copy of the License at
21
+ *
22
+ * http://www.apache.org/licenses/LICENSE-2.0
23
+ *
24
+ * Unless required by applicable law or agreed to in writing, software
25
+ * distributed under the License is distributed on an "AS IS" BASIS,
26
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27
+ * See the License for the specific language governing permissions and
28
+ * limitations under the License.
29
+ */
30
+
31
+ let cachedUserAgent;
32
+ function getUserAgent() {
33
+ if (cachedUserAgent) return cachedUserAgent;
34
+ try {
35
+ cachedUserAgent = determineUserAgent();
36
+ } catch (e) {
37
+ cachedUserAgent = 'Playwright/unknown';
38
+ }
39
+ return cachedUserAgent;
40
+ }
41
+ function determineUserAgent() {
42
+ let osIdentifier = 'unknown';
43
+ let osVersion = 'unknown';
44
+ if (process.platform === 'win32') {
45
+ const version = _os.default.release().split('.');
46
+ osIdentifier = 'windows';
47
+ osVersion = `${version[0]}.${version[1]}`;
48
+ } else if (process.platform === 'darwin') {
49
+ const version = (0, _child_process.execSync)('sw_vers -productVersion', {
50
+ stdio: ['ignore', 'pipe', 'ignore']
51
+ }).toString().trim().split('.');
52
+ osIdentifier = 'macOS';
53
+ osVersion = `${version[0]}.${version[1]}`;
54
+ } else if (process.platform === 'linux') {
55
+ const distroInfo = (0, _linuxUtils.getLinuxDistributionInfoSync)();
56
+ if (distroInfo) {
57
+ osIdentifier = distroInfo.id || 'linux';
58
+ osVersion = distroInfo.version || 'unknown';
59
+ } else {
60
+ // Linux distribution without /etc/os-release.
61
+ // Default to linux/unknown.
62
+ osIdentifier = 'linux';
63
+ }
64
+ }
65
+ const additionalTokens = [];
66
+ if (process.env.CI) additionalTokens.push('CI/1');
67
+ const serializedTokens = additionalTokens.length ? ' ' + additionalTokens.join(' ') : '';
68
+ const {
69
+ embedderName,
70
+ embedderVersion
71
+ } = getEmbedderName();
72
+ return `Playwright/${getPlaywrightVersion()} (${_os.default.arch()}; ${osIdentifier} ${osVersion}) ${embedderName}/${embedderVersion}${serializedTokens}`;
73
+ }
74
+ function getEmbedderName() {
75
+ let embedderName = 'unknown';
76
+ let embedderVersion = 'unknown';
77
+ if (!process.env.PW_LANG_NAME) {
78
+ embedderName = 'node';
79
+ embedderVersion = process.version.substring(1).split('.').slice(0, 2).join('.');
80
+ } else if (['node', 'python', 'java', 'csharp'].includes(process.env.PW_LANG_NAME)) {
81
+ var _process$env$PW_LANG_;
82
+ embedderName = process.env.PW_LANG_NAME;
83
+ embedderVersion = (_process$env$PW_LANG_ = process.env.PW_LANG_NAME_VERSION) !== null && _process$env$PW_LANG_ !== void 0 ? _process$env$PW_LANG_ : 'unknown';
84
+ }
85
+ return {
86
+ embedderName,
87
+ embedderVersion
88
+ };
89
+ }
90
+ function getPlaywrightVersion(majorMinorOnly = false) {
91
+ const version = process.env.PW_VERSION_OVERRIDE || require('./../../package.json').version;
92
+ return majorMinorOnly ? version.split('.').slice(0, 2).join('.') : version;
93
+ }
94
+ function userAgentVersionMatchesErrorMessage(userAgent) {
95
+ const match = userAgent.match(/^Playwright\/(\d+\.\d+\.\d+)/);
96
+ if (!match) {
97
+ // Cannot parse user agent - be lax.
98
+ return;
99
+ }
100
+ const received = match[1].split('.').slice(0, 2).join('.');
101
+ const expected = getPlaywrightVersion(true);
102
+ if (received !== expected) {
103
+ return (0, _ascii.wrapInASCIIBox)([`Playwright version mismatch:`, ` - server version: v${expected}`, ` - client version: v${received}`, ``, `If you are using VSCode extension, restart VSCode.`, ``, `If you are connecting to a remote service,`, `keep your local Playwright version in sync`, `with the remote service version.`, ``, `<3 Playwright Team`].join('\n'), 1);
104
+ }
105
+ }
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.perMessageDeflate = exports.WSServer = void 0;
7
+ var _utils = require("../utils");
8
+ var _utilsBundle = require("../utilsBundle");
9
+ var _debugLogger = require("./debugLogger");
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
+ let lastConnectionId = 0;
27
+ const kConnectionSymbol = Symbol('kConnection');
28
+ const perMessageDeflate = exports.perMessageDeflate = {
29
+ zlibDeflateOptions: {
30
+ level: 3
31
+ },
32
+ zlibInflateOptions: {
33
+ chunkSize: 10 * 1024
34
+ },
35
+ threshold: 10 * 1024
36
+ };
37
+ class WSServer {
38
+ constructor(delegate) {
39
+ this._wsServer = void 0;
40
+ this.server = void 0;
41
+ this._delegate = void 0;
42
+ this._delegate = delegate;
43
+ }
44
+ async listen(port = 0, hostname, path) {
45
+ _debugLogger.debugLogger.log('server', `Server started at ${new Date()}`);
46
+ const server = (0, _utils.createHttpServer)((request, response) => {
47
+ if (request.method === 'GET' && request.url === '/json') {
48
+ response.setHeader('Content-Type', 'application/json');
49
+ response.end(JSON.stringify({
50
+ wsEndpointPath: path
51
+ }));
52
+ return;
53
+ }
54
+ response.end('Running');
55
+ });
56
+ server.on('error', error => _debugLogger.debugLogger.log('server', String(error)));
57
+ this.server = server;
58
+ const wsEndpoint = await new Promise((resolve, reject) => {
59
+ server.listen(port, hostname, () => {
60
+ const address = server.address();
61
+ if (!address) {
62
+ reject(new Error('Could not bind server socket'));
63
+ return;
64
+ }
65
+ const wsEndpoint = typeof address === 'string' ? `${address}${path}` : `ws://${hostname || 'localhost'}:${address.port}${path}`;
66
+ resolve(wsEndpoint);
67
+ }).on('error', reject);
68
+ });
69
+ _debugLogger.debugLogger.log('server', 'Listening at ' + wsEndpoint);
70
+ this._wsServer = new _utilsBundle.wsServer({
71
+ noServer: true,
72
+ perMessageDeflate
73
+ });
74
+ if (this._delegate.onHeaders) this._wsServer.on('headers', headers => this._delegate.onHeaders(headers));
75
+ server.on('upgrade', (request, socket, head) => {
76
+ var _this$_delegate$onUpg, _this$_delegate, _this$_wsServer;
77
+ const pathname = new URL('http://localhost' + request.url).pathname;
78
+ if (pathname !== path) {
79
+ socket.write(`HTTP/${request.httpVersion} 400 Bad Request\r\n\r\n`);
80
+ socket.destroy();
81
+ return;
82
+ }
83
+ const upgradeResult = (_this$_delegate$onUpg = (_this$_delegate = this._delegate).onUpgrade) === null || _this$_delegate$onUpg === void 0 ? void 0 : _this$_delegate$onUpg.call(_this$_delegate, request, socket);
84
+ if (upgradeResult) {
85
+ socket.write(upgradeResult.error);
86
+ socket.destroy();
87
+ return;
88
+ }
89
+ (_this$_wsServer = this._wsServer) === null || _this$_wsServer === void 0 || _this$_wsServer.handleUpgrade(request, socket, head, ws => {
90
+ var _this$_wsServer2;
91
+ return (_this$_wsServer2 = this._wsServer) === null || _this$_wsServer2 === void 0 ? void 0 : _this$_wsServer2.emit('connection', ws, request);
92
+ });
93
+ });
94
+ this._wsServer.on('connection', (ws, request) => {
95
+ _debugLogger.debugLogger.log('server', 'Connected client ws.extension=' + ws.extensions);
96
+ const url = new URL('http://localhost' + (request.url || ''));
97
+ const id = String(++lastConnectionId);
98
+ _debugLogger.debugLogger.log('server', `[${id}] serving connection: ${request.url}`);
99
+ const connection = this._delegate.onConnection(request, url, ws, id);
100
+ ws[kConnectionSymbol] = connection;
101
+ });
102
+ return wsEndpoint;
103
+ }
104
+ async close() {
105
+ var _this$_delegate$onClo, _this$_delegate2;
106
+ const server = this._wsServer;
107
+ if (!server) return;
108
+ _debugLogger.debugLogger.log('server', 'closing websocket server');
109
+ const waitForClose = new Promise(f => server.close(f));
110
+ // First disconnect all remaining clients.
111
+ await Promise.all(Array.from(server.clients).map(async ws => {
112
+ const connection = ws[kConnectionSymbol];
113
+ if (connection) await connection.close();
114
+ try {
115
+ ws.terminate();
116
+ } catch (e) {}
117
+ }));
118
+ await waitForClose;
119
+ _debugLogger.debugLogger.log('server', 'closing http server');
120
+ if (this.server) await new Promise(f => this.server.close(f));
121
+ this._wsServer = undefined;
122
+ this.server = undefined;
123
+ _debugLogger.debugLogger.log('server', 'closed server');
124
+ await ((_this$_delegate$onClo = (_this$_delegate2 = this._delegate).onClose) === null || _this$_delegate$onClo === void 0 ? void 0 : _this$_delegate$onClo.call(_this$_delegate2));
125
+ }
126
+ }
127
+ exports.WSServer = WSServer;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ZipFile = void 0;
7
+ var _zipBundle = require("../zipBundle");
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
+ class ZipFile {
25
+ constructor(fileName) {
26
+ this._fileName = void 0;
27
+ this._zipFile = void 0;
28
+ this._entries = new Map();
29
+ this._openedPromise = void 0;
30
+ this._fileName = fileName;
31
+ this._openedPromise = this._open();
32
+ }
33
+ async _open() {
34
+ await new Promise((fulfill, reject) => {
35
+ _zipBundle.yauzl.open(this._fileName, {
36
+ autoClose: false
37
+ }, (e, z) => {
38
+ if (e) {
39
+ reject(e);
40
+ return;
41
+ }
42
+ this._zipFile = z;
43
+ this._zipFile.on('entry', entry => {
44
+ this._entries.set(entry.fileName, entry);
45
+ });
46
+ this._zipFile.on('end', fulfill);
47
+ });
48
+ });
49
+ }
50
+ async entries() {
51
+ await this._openedPromise;
52
+ return [...this._entries.keys()];
53
+ }
54
+ async read(entryPath) {
55
+ await this._openedPromise;
56
+ const entry = this._entries.get(entryPath);
57
+ if (!entry) throw new Error(`${entryPath} not found in file ${this._fileName}`);
58
+ return new Promise((resolve, reject) => {
59
+ this._zipFile.openReadStream(entry, (error, readStream) => {
60
+ if (error || !readStream) {
61
+ reject(error || 'Entry not found');
62
+ return;
63
+ }
64
+ const buffers = [];
65
+ readStream.on('data', data => buffers.push(data));
66
+ readStream.on('end', () => resolve(Buffer.concat(buffers)));
67
+ });
68
+ });
69
+ }
70
+ close() {
71
+ var _this$_zipFile;
72
+ (_this$_zipFile = this._zipFile) === null || _this$_zipFile === void 0 || _this$_zipFile.close();
73
+ }
74
+ }
75
+ exports.ZipFile = ZipFile;