@checkly/playwright-core 1.48.24-beta.1 → 1.48.24-maxi

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 (112) hide show
  1. package/lib/client/clientStackTrace.js +66 -0
  2. package/lib/client/fileUtils.js +33 -0
  3. package/lib/client/platform.js +72 -0
  4. package/lib/client/timeoutSettings.js +66 -0
  5. package/lib/client/webSocket.js +107 -0
  6. package/lib/generated/recorderSource.js +7 -0
  7. package/lib/server/callLog.js +80 -0
  8. package/lib/server/harBackend.js +158 -0
  9. package/lib/server/localUtils.js +204 -0
  10. package/lib/server/recorder/chat.js +178 -0
  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/storageScript.js +161 -0
  21. package/lib/server/timeoutSettings.js +75 -0
  22. package/lib/server/utils/ascii.js +32 -0
  23. package/lib/server/utils/comparators.js +160 -0
  24. package/lib/server/utils/crypto.js +172 -0
  25. package/lib/server/utils/debug.js +39 -0
  26. package/lib/server/utils/debugLogger.js +94 -0
  27. package/lib/server/utils/env.js +54 -0
  28. package/lib/server/utils/eventsHelper.js +39 -0
  29. package/lib/server/utils/expectUtils.js +34 -0
  30. package/lib/server/utils/fileUtils.js +205 -0
  31. package/lib/server/utils/happyEyeballs.js +210 -0
  32. package/lib/server/utils/hostPlatform.js +146 -0
  33. package/lib/server/utils/httpServer.js +234 -0
  34. package/lib/server/utils/image_tools/colorUtils.js +99 -0
  35. package/lib/server/utils/image_tools/compare.js +109 -0
  36. package/lib/server/utils/image_tools/imageChannel.js +71 -0
  37. package/lib/server/utils/image_tools/stats.js +103 -0
  38. package/lib/server/utils/linuxUtils.js +59 -0
  39. package/lib/server/utils/network.js +161 -0
  40. package/lib/server/utils/nodePlatform.js +141 -0
  41. package/lib/server/utils/pipeTransport.js +83 -0
  42. package/lib/server/utils/processLauncher.js +249 -0
  43. package/lib/server/utils/profiler.js +53 -0
  44. package/lib/server/utils/socksProxy.js +571 -0
  45. package/lib/server/utils/spawnAsync.js +46 -0
  46. package/lib/server/utils/task.js +59 -0
  47. package/lib/server/utils/userAgent.js +92 -0
  48. package/lib/server/utils/wsServer.js +129 -0
  49. package/lib/server/utils/zipFile.js +76 -0
  50. package/lib/server/utils/zones.js +55 -0
  51. package/lib/utils/glob.js +84 -0
  52. package/lib/utils/isomorphic/ariaSnapshot.js +393 -0
  53. package/lib/utils/isomorphic/assert.js +26 -0
  54. package/lib/utils/isomorphic/colors.js +66 -0
  55. package/lib/utils/isomorphic/headers.js +53 -0
  56. package/lib/utils/isomorphic/manualPromise.js +108 -0
  57. package/lib/utils/isomorphic/multimap.js +74 -0
  58. package/lib/utils/isomorphic/rtti.js +42 -0
  59. package/lib/utils/isomorphic/semaphore.js +52 -0
  60. package/lib/utils/isomorphic/stackTrace.js +170 -0
  61. package/lib/utils/isomorphic/time.js +26 -0
  62. package/lib/utils/isomorphic/timeoutRunner.js +67 -0
  63. package/lib/utils/isomorphic/types.js +6 -0
  64. package/lib/utils/mimeType.js +30 -0
  65. package/lib/utils.js +448 -0
  66. package/lib/vite/{traceViewer/assets/codeMirrorModule-lDjkI8Ax.js → recorder/assets/codeMirrorModule-CR6kB851.js} +1 -1
  67. package/lib/vite/recorder/assets/{index-Bxxcmxlu.js → index-BcaUAUCW.js} +2 -2
  68. package/lib/vite/recorder/index.html +1 -1
  69. package/lib/vite/traceViewer/assets/codeMirrorModule-CB-2okZ8.js +16684 -0
  70. package/lib/vite/traceViewer/assets/{codeMirrorModule-Bh1rfd2w.js → codeMirrorModule-tzBrK1V4.js} +10 -10
  71. package/lib/vite/traceViewer/assets/defaultSettingsView-CBiB4avC.js +217 -0
  72. package/lib/vite/traceViewer/assets/{inspectorTab-7GHnKvSD.js → inspectorTab-BuJ3wAX_.js} +2 -2
  73. package/lib/vite/traceViewer/assets/inspectorTab-CwgfffWb.js +25143 -0
  74. package/lib/vite/traceViewer/assets/workbench-CWZselvp.js +2470 -0
  75. package/lib/vite/traceViewer/assets/{workbench-C6nMfKVy.js → workbench-DdmJ9AJV.js} +1 -1
  76. package/lib/vite/traceViewer/assets/xtermModule-Es_gt_u7.js +5994 -0
  77. package/lib/vite/traceViewer/codeMirrorModule.DuST8d_k.css +344 -0
  78. package/lib/vite/traceViewer/defaultSettingsView.Dp3b_92q.css +41 -0
  79. package/lib/vite/traceViewer/embedded.BeldSa2G.css +68 -0
  80. package/lib/vite/traceViewer/{embedded.BIubxTi3.js → embedded.DInvAijy.js} +1 -1
  81. package/lib/vite/traceViewer/embedded.gzudoghF.js +106 -0
  82. package/lib/vite/traceViewer/embedded.html +3 -3
  83. package/lib/vite/traceViewer/{index.DPD22sZn.js → index.Dha3cgqs.js} +1 -1
  84. package/lib/vite/traceViewer/index.DilotR1h.js +314 -0
  85. package/lib/vite/traceViewer/index.QewjJ85u.css +131 -0
  86. package/lib/vite/traceViewer/index.html +3 -3
  87. package/lib/vite/traceViewer/inspectorTab.DnGm18kV.css +3178 -0
  88. package/lib/vite/traceViewer/recorder.DLgqV9db.css +15 -0
  89. package/lib/vite/traceViewer/{recorder.BaRuS6Pc.js → recorder.DNMfnSiu.js} +1 -1
  90. package/lib/vite/traceViewer/recorder.DVrkq3Um.js +551 -0
  91. package/lib/vite/traceViewer/recorder.html +2 -2
  92. package/lib/vite/traceViewer/uiMode.C9_OcpPU.js +1756 -0
  93. package/lib/vite/traceViewer/{uiMode.DXa41vt9.js → uiMode.Cr1tvTWS.js} +1 -1
  94. package/lib/vite/traceViewer/uiMode.c5ORgcrX.css +1424 -0
  95. package/lib/vite/traceViewer/uiMode.html +3 -3
  96. package/lib/vite/traceViewer/workbench.xUZSA8PY.css +787 -0
  97. package/lib/vite/traceViewer/xtermModule.EsaqrrTX.css +209 -0
  98. package/package.json +1 -1
  99. package/lib/vite/recorder/assets/codeMirrorModule-d0KhC1qL.js +0 -24
  100. package/lib/vite/traceViewer/assets/codeMirrorModule-xvopPhZ4.js +0 -24
  101. package/lib/vite/traceViewer/assets/inspectorTab-BPzhNk9r.js +0 -64
  102. package/lib/vite/traceViewer/assets/inspectorTab-wfvwpMHs.js +0 -64
  103. package/lib/vite/traceViewer/assets/workbench-DLv_q9ji.js +0 -9
  104. package/lib/vite/traceViewer/assets/workbench-LKskf2Iy.js +0 -9
  105. package/lib/vite/traceViewer/embedded.BXYl5zRv.js +0 -2
  106. package/lib/vite/traceViewer/embedded.CShPz96b.js +0 -2
  107. package/lib/vite/traceViewer/index.BZ9CE8t3.js +0 -2
  108. package/lib/vite/traceViewer/index.DZkJsFod.js +0 -2
  109. package/lib/vite/traceViewer/recorder.BVExlUUk.js +0 -2
  110. package/lib/vite/traceViewer/recorder.C4zxcvd2.js +0 -2
  111. package/lib/vite/traceViewer/uiMode.B11wexdJ.js +0 -5
  112. package/lib/vite/traceViewer/uiMode.DjTS7tqC.js +0 -5
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.FastStats = void 0;
7
+ exports.ssim = ssim;
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
+ // Image channel has a 8-bit depth.
25
+ const DYNAMIC_RANGE = 2 ** 8 - 1;
26
+ function ssim(stats, x1, y1, x2, y2) {
27
+ const mean1 = stats.meanC1(x1, y1, x2, y2);
28
+ const mean2 = stats.meanC2(x1, y1, x2, y2);
29
+ const var1 = stats.varianceC1(x1, y1, x2, y2);
30
+ const var2 = stats.varianceC2(x1, y1, x2, y2);
31
+ const cov = stats.covariance(x1, y1, x2, y2);
32
+ const c1 = (0.01 * DYNAMIC_RANGE) ** 2;
33
+ const c2 = (0.03 * DYNAMIC_RANGE) ** 2;
34
+ return (2 * mean1 * mean2 + c1) * (2 * cov + c2) / (mean1 ** 2 + mean2 ** 2 + c1) / (var1 + var2 + c2);
35
+ }
36
+ class FastStats {
37
+ constructor(c1, c2) {
38
+ this.c1 = void 0;
39
+ this.c2 = void 0;
40
+ this._partialSumC1 = void 0;
41
+ this._partialSumC2 = void 0;
42
+ this._partialSumMult = void 0;
43
+ this._partialSumSq1 = void 0;
44
+ this._partialSumSq2 = void 0;
45
+ this.c1 = c1;
46
+ this.c2 = c2;
47
+ const {
48
+ width,
49
+ height
50
+ } = c1;
51
+ this._partialSumC1 = new Array(width * height);
52
+ this._partialSumC2 = new Array(width * height);
53
+ this._partialSumSq1 = new Array(width * height);
54
+ this._partialSumSq2 = new Array(width * height);
55
+ this._partialSumMult = new Array(width * height);
56
+ const recalc = (mx, idx, initial, x, y) => {
57
+ mx[idx] = initial;
58
+ if (y > 0) mx[idx] += mx[(y - 1) * width + x];
59
+ if (x > 0) mx[idx] += mx[y * width + x - 1];
60
+ if (x > 0 && y > 0) mx[idx] -= mx[(y - 1) * width + x - 1];
61
+ };
62
+ for (let y = 0; y < height; ++y) {
63
+ for (let x = 0; x < width; ++x) {
64
+ const idx = y * width + x;
65
+ recalc(this._partialSumC1, idx, this.c1.data[idx], x, y);
66
+ recalc(this._partialSumC2, idx, this.c2.data[idx], x, y);
67
+ recalc(this._partialSumSq1, idx, this.c1.data[idx] * this.c1.data[idx], x, y);
68
+ recalc(this._partialSumSq2, idx, this.c2.data[idx] * this.c2.data[idx], x, y);
69
+ recalc(this._partialSumMult, idx, this.c1.data[idx] * this.c2.data[idx], x, y);
70
+ }
71
+ }
72
+ }
73
+ _sum(partialSum, x1, y1, x2, y2) {
74
+ const width = this.c1.width;
75
+ let result = partialSum[y2 * width + x2];
76
+ if (y1 > 0) result -= partialSum[(y1 - 1) * width + x2];
77
+ if (x1 > 0) result -= partialSum[y2 * width + x1 - 1];
78
+ if (x1 > 0 && y1 > 0) result += partialSum[(y1 - 1) * width + x1 - 1];
79
+ return result;
80
+ }
81
+ meanC1(x1, y1, x2, y2) {
82
+ const N = (y2 - y1 + 1) * (x2 - x1 + 1);
83
+ return this._sum(this._partialSumC1, x1, y1, x2, y2) / N;
84
+ }
85
+ meanC2(x1, y1, x2, y2) {
86
+ const N = (y2 - y1 + 1) * (x2 - x1 + 1);
87
+ return this._sum(this._partialSumC2, x1, y1, x2, y2) / N;
88
+ }
89
+ varianceC1(x1, y1, x2, y2) {
90
+ const N = (y2 - y1 + 1) * (x2 - x1 + 1);
91
+ return (this._sum(this._partialSumSq1, x1, y1, x2, y2) - this._sum(this._partialSumC1, x1, y1, x2, y2) ** 2 / N) / N;
92
+ }
93
+ varianceC2(x1, y1, x2, y2) {
94
+ const N = (y2 - y1 + 1) * (x2 - x1 + 1);
95
+ return (this._sum(this._partialSumSq2, x1, y1, x2, y2) - this._sum(this._partialSumC2, x1, y1, x2, y2) ** 2 / N) / N;
96
+ }
97
+ covariance(x1, y1, x2, y2) {
98
+ const N = (y2 - y1 + 1) * (x2 - x1 + 1);
99
+ return (this._sum(this._partialSumMult, x1, y1, x2, y2) - this._sum(this._partialSumC1, x1, y1, x2, y2) * this._sum(this._partialSumC2, x1, y1, x2, y2) / N) / N;
100
+ }
101
+ }
102
+ exports.FastStats = FastStats;
103
+ //# sourceMappingURL=stats.js.map
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getLinuxDistributionInfoSync = getLinuxDistributionInfoSync;
7
+ var _fs = _interopRequireDefault(require("fs"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ /**
10
+ * Copyright 2017 Google Inc. All rights reserved.
11
+ * Modifications 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 didFailToReadOSRelease = false;
27
+ let osRelease;
28
+ function getLinuxDistributionInfoSync() {
29
+ if (process.platform !== 'linux') return undefined;
30
+ if (!osRelease && !didFailToReadOSRelease) {
31
+ try {
32
+ var _fields$get, _fields$get2;
33
+ // List of /etc/os-release values for different distributions could be
34
+ // found here: https://gist.github.com/aslushnikov/8ceddb8288e4cf9db3039c02e0f4fb75
35
+ const osReleaseText = _fs.default.readFileSync('/etc/os-release', 'utf8');
36
+ const fields = parseOSReleaseText(osReleaseText);
37
+ osRelease = {
38
+ id: (_fields$get = fields.get('id')) !== null && _fields$get !== void 0 ? _fields$get : '',
39
+ version: (_fields$get2 = fields.get('version_id')) !== null && _fields$get2 !== void 0 ? _fields$get2 : ''
40
+ };
41
+ } catch (e) {
42
+ didFailToReadOSRelease = true;
43
+ }
44
+ }
45
+ return osRelease;
46
+ }
47
+ function parseOSReleaseText(osReleaseText) {
48
+ const fields = new Map();
49
+ for (const line of osReleaseText.split('\n')) {
50
+ const tokens = line.split('=');
51
+ const name = tokens.shift();
52
+ let value = tokens.join('=').trim();
53
+ if (value.startsWith('"') && value.endsWith('"')) value = value.substring(1, value.length - 1);
54
+ if (!name) continue;
55
+ fields.set(name.toLowerCase(), value);
56
+ }
57
+ return fields;
58
+ }
59
+ //# sourceMappingURL=linuxUtils.js.map
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NET_DEFAULT_TIMEOUT = void 0;
7
+ exports.createHttp2Server = createHttp2Server;
8
+ exports.createHttpServer = createHttpServer;
9
+ exports.createHttpsServer = createHttpsServer;
10
+ exports.fetchData = fetchData;
11
+ exports.httpRequest = httpRequest;
12
+ exports.isURLAvailable = isURLAvailable;
13
+ var _http = _interopRequireDefault(require("http"));
14
+ var _http2 = _interopRequireDefault(require("http2"));
15
+ var _https = _interopRequireDefault(require("https"));
16
+ var _url = _interopRequireDefault(require("url"));
17
+ var _utilsBundle = require("../../utilsBundle");
18
+ var _happyEyeballs = require("./happyEyeballs");
19
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
+ /**
21
+ * Copyright (c) Microsoft Corporation.
22
+ *
23
+ * Licensed under the Apache License, Version 2.0 (the "License");
24
+ * you may not use this file except in compliance with the License.
25
+ * You may obtain a copy of the License at
26
+ *
27
+ * http://www.apache.org/licenses/LICENSE-2.0
28
+ *
29
+ * Unless required by applicable law or agreed to in writing, software
30
+ * distributed under the License is distributed on an "AS IS" BASIS,
31
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32
+ * See the License for the specific language governing permissions and
33
+ * limitations under the License.
34
+ */
35
+
36
+ const NET_DEFAULT_TIMEOUT = exports.NET_DEFAULT_TIMEOUT = 30_000;
37
+ function httpRequest(params, onResponse, onError) {
38
+ var _params$timeout;
39
+ const parsedUrl = _url.default.parse(params.url);
40
+ let options = {
41
+ ...parsedUrl,
42
+ agent: parsedUrl.protocol === 'https:' ? _happyEyeballs.httpsHappyEyeballsAgent : _happyEyeballs.httpHappyEyeballsAgent,
43
+ method: params.method || 'GET',
44
+ headers: params.headers
45
+ };
46
+ if (params.rejectUnauthorized !== undefined) options.rejectUnauthorized = params.rejectUnauthorized;
47
+ const timeout = (_params$timeout = params.timeout) !== null && _params$timeout !== void 0 ? _params$timeout : NET_DEFAULT_TIMEOUT;
48
+ const proxyURL = (0, _utilsBundle.getProxyForUrl)(params.url);
49
+ if (proxyURL) {
50
+ const parsedProxyURL = _url.default.parse(proxyURL);
51
+ if (params.url.startsWith('http:')) {
52
+ options = {
53
+ path: parsedUrl.href,
54
+ host: parsedProxyURL.hostname,
55
+ port: parsedProxyURL.port,
56
+ headers: options.headers,
57
+ method: options.method
58
+ };
59
+ } else {
60
+ parsedProxyURL.secureProxy = parsedProxyURL.protocol === 'https:';
61
+ options.agent = new _utilsBundle.HttpsProxyAgent(parsedProxyURL);
62
+ options.rejectUnauthorized = false;
63
+ }
64
+ }
65
+ const requestCallback = res => {
66
+ const statusCode = res.statusCode || 0;
67
+ if (statusCode >= 300 && statusCode < 400 && res.headers.location) httpRequest({
68
+ ...params,
69
+ url: new URL(res.headers.location, params.url).toString()
70
+ }, onResponse, onError);else onResponse(res);
71
+ };
72
+ const request = options.protocol === 'https:' ? _https.default.request(options, requestCallback) : _http.default.request(options, requestCallback);
73
+ request.on('error', onError);
74
+ if (timeout !== undefined) {
75
+ const rejectOnTimeout = () => {
76
+ onError(new Error(`Request to ${params.url} timed out after ${timeout}ms`));
77
+ request.abort();
78
+ };
79
+ if (timeout <= 0) {
80
+ rejectOnTimeout();
81
+ return;
82
+ }
83
+ request.setTimeout(timeout, rejectOnTimeout);
84
+ }
85
+ request.end(params.data);
86
+ }
87
+ function fetchData(params, onError) {
88
+ return new Promise((resolve, reject) => {
89
+ httpRequest(params, async response => {
90
+ if (response.statusCode !== 200) {
91
+ const error = onError ? await onError(params, response) : new Error(`fetch failed: server returned code ${response.statusCode}. URL: ${params.url}`);
92
+ reject(error);
93
+ return;
94
+ }
95
+ let body = '';
96
+ response.on('data', chunk => body += chunk);
97
+ response.on('error', error => reject(error));
98
+ response.on('end', () => resolve(body));
99
+ }, reject);
100
+ });
101
+ }
102
+ function createHttpServer(...args) {
103
+ const server = _http.default.createServer(...args);
104
+ decorateServer(server);
105
+ return server;
106
+ }
107
+ function createHttpsServer(...args) {
108
+ const server = _https.default.createServer(...args);
109
+ decorateServer(server);
110
+ return server;
111
+ }
112
+ function createHttp2Server(...args) {
113
+ const server = _http2.default.createSecureServer(...args);
114
+ decorateServer(server);
115
+ return server;
116
+ }
117
+ async function isURLAvailable(url, ignoreHTTPSErrors, onLog, onStdErr) {
118
+ let statusCode = await httpStatusCode(url, ignoreHTTPSErrors, onLog, onStdErr);
119
+ if (statusCode === 404 && url.pathname === '/') {
120
+ const indexUrl = new URL(url);
121
+ indexUrl.pathname = '/index.html';
122
+ statusCode = await httpStatusCode(indexUrl, ignoreHTTPSErrors, onLog, onStdErr);
123
+ }
124
+ return statusCode >= 200 && statusCode < 404;
125
+ }
126
+ async function httpStatusCode(url, ignoreHTTPSErrors, onLog, onStdErr) {
127
+ return new Promise(resolve => {
128
+ onLog === null || onLog === void 0 || onLog(`HTTP GET: ${url}`);
129
+ httpRequest({
130
+ url: url.toString(),
131
+ headers: {
132
+ Accept: '*/*'
133
+ },
134
+ rejectUnauthorized: !ignoreHTTPSErrors
135
+ }, res => {
136
+ var _res$statusCode;
137
+ res.resume();
138
+ const statusCode = (_res$statusCode = res.statusCode) !== null && _res$statusCode !== void 0 ? _res$statusCode : 0;
139
+ onLog === null || onLog === void 0 || onLog(`HTTP Status: ${statusCode}`);
140
+ resolve(statusCode);
141
+ }, error => {
142
+ if (error.code === 'DEPTH_ZERO_SELF_SIGNED_CERT') onStdErr === null || onStdErr === void 0 || onStdErr(`[WebServer] Self-signed certificate detected. Try adding ignoreHTTPSErrors: true to config.webServer.`);
143
+ onLog === null || onLog === void 0 || onLog(`Error while checking if ${url} is available: ${error.message}`);
144
+ resolve(0);
145
+ });
146
+ });
147
+ }
148
+ function decorateServer(server) {
149
+ const sockets = new Set();
150
+ server.on('connection', socket => {
151
+ sockets.add(socket);
152
+ socket.once('close', () => sockets.delete(socket));
153
+ });
154
+ const close = server.close;
155
+ server.close = callback => {
156
+ for (const socket of sockets) socket.destroy();
157
+ sockets.clear();
158
+ return close.call(server, callback);
159
+ };
160
+ }
161
+ //# sourceMappingURL=network.js.map
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.nodePlatform = void 0;
7
+ exports.setBoxedStackPrefixes = setBoxedStackPrefixes;
8
+ var _crypto = _interopRequireDefault(require("crypto"));
9
+ var _fs = _interopRequireDefault(require("fs"));
10
+ var _path = _interopRequireDefault(require("path"));
11
+ var util = _interopRequireWildcard(require("util"));
12
+ var _stream = require("stream");
13
+ var _events = require("events");
14
+ var _utilsBundle = require("../../utilsBundle");
15
+ var _debugLogger = require("./debugLogger");
16
+ var _zones = require("./zones");
17
+ var _debug = require("./debug");
18
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
19
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
20
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
21
+ /**
22
+ * Copyright (c) Microsoft Corporation.
23
+ *
24
+ * Licensed under the Apache License, Version 2.0 (the "License");
25
+ * you may not use this file except in compliance with the License.
26
+ * You may obtain a copy of the License at
27
+ *
28
+ * http://www.apache.org/licenses/LICENSE-2.0
29
+ *
30
+ * Unless required by applicable law or agreed to in writing, software
31
+ * distributed under the License is distributed on an "AS IS" BASIS,
32
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33
+ * See the License for the specific language governing permissions and
34
+ * limitations under the License.
35
+ */
36
+
37
+ const pipelineAsync = util.promisify(_stream.pipeline);
38
+ class NodeZone {
39
+ constructor(zone) {
40
+ this._zone = void 0;
41
+ this._zone = zone;
42
+ }
43
+ push(data) {
44
+ return new NodeZone(this._zone.with('apiZone', data));
45
+ }
46
+ pop() {
47
+ return new NodeZone(this._zone.without('apiZone'));
48
+ }
49
+ run(func) {
50
+ return this._zone.run(func);
51
+ }
52
+ data() {
53
+ return this._zone.data('apiZone');
54
+ }
55
+ }
56
+ let boxedStackPrefixes = [];
57
+ function setBoxedStackPrefixes(prefixes) {
58
+ boxedStackPrefixes = prefixes;
59
+ }
60
+ const coreDir = _path.default.dirname(require.resolve('../../../package.json'));
61
+ const nodePlatform = exports.nodePlatform = {
62
+ name: 'node',
63
+ boxedStackPrefixes: () => {
64
+ if (process.env.PWDEBUGIMPL) return [];
65
+ return [coreDir, ...boxedStackPrefixes];
66
+ },
67
+ calculateSha1: text => {
68
+ const sha1 = _crypto.default.createHash('sha1');
69
+ sha1.update(text);
70
+ return Promise.resolve(sha1.digest('hex'));
71
+ },
72
+ colors: _utilsBundle.colors,
73
+ coreDir,
74
+ createGuid: () => _crypto.default.randomBytes(16).toString('hex'),
75
+ defaultMaxListeners: () => _events.EventEmitter.defaultMaxListeners,
76
+ fs: () => _fs.default,
77
+ env: process.env,
78
+ inspectCustom: util.inspect.custom,
79
+ isDebugMode: () => !!(0, _debug.debugMode)(),
80
+ isJSDebuggerAttached: () => !!require('inspector').url(),
81
+ isLogEnabled(name) {
82
+ return _debugLogger.debugLogger.isEnabled(name);
83
+ },
84
+ isUnderTest: () => (0, _debug.isUnderTest)(),
85
+ log(name, message) {
86
+ _debugLogger.debugLogger.log(name, message);
87
+ },
88
+ path: () => _path.default,
89
+ pathSeparator: _path.default.sep,
90
+ showInternalStackFrames: () => !!process.env.PWDEBUGIMPL,
91
+ async streamFile(path, stream) {
92
+ await pipelineAsync(_fs.default.createReadStream(path), stream);
93
+ },
94
+ streamReadable: channel => {
95
+ return new ReadableStreamImpl(channel);
96
+ },
97
+ streamWritable: channel => {
98
+ return new WritableStreamImpl(channel);
99
+ },
100
+ zones: {
101
+ current: () => new NodeZone((0, _zones.currentZone)()),
102
+ empty: new NodeZone(_zones.emptyZone)
103
+ }
104
+ };
105
+ class ReadableStreamImpl extends _stream.Readable {
106
+ constructor(channel) {
107
+ super();
108
+ this._channel = void 0;
109
+ this._channel = channel;
110
+ }
111
+ async _read() {
112
+ const result = await this._channel.read({
113
+ size: 1024 * 1024
114
+ });
115
+ if (result.binary.byteLength) this.push(result.binary);else this.push(null);
116
+ }
117
+ _destroy(error, callback) {
118
+ // Stream might be destroyed after the connection was closed.
119
+ this._channel.close().catch(e => null);
120
+ super._destroy(error, callback);
121
+ }
122
+ }
123
+ class WritableStreamImpl extends _stream.Writable {
124
+ constructor(channel) {
125
+ super();
126
+ this._channel = void 0;
127
+ this._channel = channel;
128
+ }
129
+ async _write(chunk, encoding, callback) {
130
+ const error = await this._channel.write({
131
+ binary: typeof chunk === 'string' ? Buffer.from(chunk) : chunk
132
+ }).catch(e => e);
133
+ callback(error || null);
134
+ }
135
+ async _final(callback) {
136
+ // Stream might be destroyed after the connection was closed.
137
+ const error = await this._channel.close().catch(e => e);
138
+ callback(error || null);
139
+ }
140
+ }
141
+ //# sourceMappingURL=nodePlatform.js.map
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PipeTransport = void 0;
7
+ var _task = require("./task");
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 PipeTransport {
25
+ constructor(pipeWrite, pipeRead, closeable, endian = 'le') {
26
+ this._pipeWrite = void 0;
27
+ this._data = Buffer.from([]);
28
+ this._waitForNextTask = (0, _task.makeWaitForNextTask)();
29
+ this._closed = false;
30
+ this._bytesLeft = 0;
31
+ this.onmessage = void 0;
32
+ this.onclose = void 0;
33
+ this._endian = void 0;
34
+ this._closeableStream = void 0;
35
+ this._pipeWrite = pipeWrite;
36
+ this._endian = endian;
37
+ this._closeableStream = closeable;
38
+ pipeRead.on('data', buffer => this._dispatch(buffer));
39
+ pipeRead.on('close', () => {
40
+ this._closed = true;
41
+ if (this.onclose) this.onclose();
42
+ });
43
+ this.onmessage = undefined;
44
+ this.onclose = undefined;
45
+ }
46
+ send(message) {
47
+ if (this._closed) throw new Error('Pipe has been closed');
48
+ const data = Buffer.from(message, 'utf-8');
49
+ const dataLength = Buffer.alloc(4);
50
+ if (this._endian === 'be') dataLength.writeUInt32BE(data.length, 0);else dataLength.writeUInt32LE(data.length, 0);
51
+ this._pipeWrite.write(dataLength);
52
+ this._pipeWrite.write(data);
53
+ }
54
+ close() {
55
+ // Let it throw.
56
+ this._closeableStream.close();
57
+ }
58
+ _dispatch(buffer) {
59
+ this._data = Buffer.concat([this._data, buffer]);
60
+ while (true) {
61
+ if (!this._bytesLeft && this._data.length < 4) {
62
+ // Need more data.
63
+ break;
64
+ }
65
+ if (!this._bytesLeft) {
66
+ this._bytesLeft = this._endian === 'be' ? this._data.readUInt32BE(0) : this._data.readUInt32LE(0);
67
+ this._data = this._data.slice(4);
68
+ }
69
+ if (!this._bytesLeft || this._data.length < this._bytesLeft) {
70
+ // Need more data.
71
+ break;
72
+ }
73
+ const message = this._data.slice(0, this._bytesLeft);
74
+ this._data = this._data.slice(this._bytesLeft);
75
+ this._bytesLeft = 0;
76
+ this._waitForNextTask(() => {
77
+ if (this.onmessage) this.onmessage(message.toString('utf-8'));
78
+ });
79
+ }
80
+ }
81
+ }
82
+ exports.PipeTransport = PipeTransport;
83
+ //# sourceMappingURL=pipeTransport.js.map