@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.
Files changed (71) hide show
  1. package/lib/generated/clockSource.js +1 -2
  2. package/lib/generated/consoleApiSource.js +1 -2
  3. package/lib/generated/injectedScriptSource.js +1 -2
  4. package/lib/generated/pollingRecorderSource.js +1 -2
  5. package/lib/generated/utilityScriptSource.js +1 -2
  6. package/lib/generated/webSocketMockSource.js +1 -2
  7. package/lib/vite/traceViewer/assets/codeMirrorModule-lDjkI8Ax.js +24 -0
  8. package/lib/vite/traceViewer/assets/inspectorTab-BPzhNk9r.js +64 -0
  9. package/lib/vite/traceViewer/assets/workbench-DLv_q9ji.js +9 -0
  10. package/lib/vite/traceViewer/embedded.BIubxTi3.js +2 -0
  11. package/lib/vite/traceViewer/embedded.html +3 -3
  12. package/lib/vite/traceViewer/index.DPD22sZn.js +2 -0
  13. package/lib/vite/traceViewer/index.html +3 -3
  14. package/lib/vite/traceViewer/recorder.BaRuS6Pc.js +2 -0
  15. package/lib/vite/traceViewer/recorder.html +2 -2
  16. package/lib/vite/traceViewer/uiMode.B11wexdJ.js +5 -0
  17. package/lib/vite/traceViewer/uiMode.html +3 -3
  18. package/package.json +1 -1
  19. package/lib/client/clientStackTrace.js +0 -65
  20. package/lib/client/fileUtils.js +0 -31
  21. package/lib/client/platform.js +0 -71
  22. package/lib/client/timeoutSettings.js +0 -65
  23. package/lib/client/webSocket.js +0 -106
  24. package/lib/server/callLog.js +0 -79
  25. package/lib/server/harBackend.js +0 -157
  26. package/lib/server/localUtils.js +0 -203
  27. package/lib/server/recorder/chat.js +0 -177
  28. package/lib/server/storageScript.js +0 -160
  29. package/lib/server/timeoutSettings.js +0 -74
  30. package/lib/server/utils/ascii.js +0 -31
  31. package/lib/server/utils/comparators.js +0 -159
  32. package/lib/server/utils/crypto.js +0 -171
  33. package/lib/server/utils/debug.js +0 -38
  34. package/lib/server/utils/debugLogger.js +0 -93
  35. package/lib/server/utils/env.js +0 -53
  36. package/lib/server/utils/eventsHelper.js +0 -38
  37. package/lib/server/utils/expectUtils.js +0 -33
  38. package/lib/server/utils/fileUtils.js +0 -204
  39. package/lib/server/utils/happyEyeballs.js +0 -209
  40. package/lib/server/utils/hostPlatform.js +0 -145
  41. package/lib/server/utils/httpServer.js +0 -233
  42. package/lib/server/utils/image_tools/colorUtils.js +0 -98
  43. package/lib/server/utils/image_tools/compare.js +0 -108
  44. package/lib/server/utils/image_tools/imageChannel.js +0 -70
  45. package/lib/server/utils/image_tools/stats.js +0 -102
  46. package/lib/server/utils/linuxUtils.js +0 -58
  47. package/lib/server/utils/network.js +0 -160
  48. package/lib/server/utils/nodePlatform.js +0 -140
  49. package/lib/server/utils/pipeTransport.js +0 -82
  50. package/lib/server/utils/processLauncher.js +0 -248
  51. package/lib/server/utils/profiler.js +0 -52
  52. package/lib/server/utils/socksProxy.js +0 -570
  53. package/lib/server/utils/spawnAsync.js +0 -45
  54. package/lib/server/utils/task.js +0 -58
  55. package/lib/server/utils/userAgent.js +0 -91
  56. package/lib/server/utils/wsServer.js +0 -128
  57. package/lib/server/utils/zipFile.js +0 -75
  58. package/lib/server/utils/zones.js +0 -54
  59. package/lib/utils/isomorphic/ariaSnapshot.js +0 -392
  60. package/lib/utils/isomorphic/assert.js +0 -25
  61. package/lib/utils/isomorphic/colors.js +0 -65
  62. package/lib/utils/isomorphic/headers.js +0 -52
  63. package/lib/utils/isomorphic/manualPromise.js +0 -107
  64. package/lib/utils/isomorphic/multimap.js +0 -73
  65. package/lib/utils/isomorphic/rtti.js +0 -41
  66. package/lib/utils/isomorphic/semaphore.js +0 -51
  67. package/lib/utils/isomorphic/stackTrace.js +0 -169
  68. package/lib/utils/isomorphic/time.js +0 -25
  69. package/lib/utils/isomorphic/timeoutRunner.js +0 -66
  70. package/lib/utils/isomorphic/types.js +0 -5
  71. package/lib/utils.js +0 -447
@@ -1,108 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.compare = compare;
7
- var _colorUtils = require("./colorUtils");
8
- var _imageChannel = require("./imageChannel");
9
- var _stats = require("./stats");
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 SSIM_WINDOW_RADIUS = 15;
27
- const VARIANCE_WINDOW_RADIUS = 1;
28
- function drawPixel(width, data, x, y, r, g, b) {
29
- const idx = (y * width + x) * 4;
30
- data[idx + 0] = r;
31
- data[idx + 1] = g;
32
- data[idx + 2] = b;
33
- data[idx + 3] = 255;
34
- }
35
- function compare(actual, expected, diff, width, height, options = {}) {
36
- const {
37
- maxColorDeltaE94 = 1.0
38
- } = options;
39
- const paddingSize = Math.max(VARIANCE_WINDOW_RADIUS, SSIM_WINDOW_RADIUS);
40
- const paddingColorEven = [255, 0, 255];
41
- const paddingColorOdd = [0, 255, 0];
42
- const [r1, g1, b1] = _imageChannel.ImageChannel.intoRGB(width, height, expected, {
43
- paddingSize,
44
- paddingColorEven,
45
- paddingColorOdd
46
- });
47
- const [r2, g2, b2] = _imageChannel.ImageChannel.intoRGB(width, height, actual, {
48
- paddingSize,
49
- paddingColorEven,
50
- paddingColorOdd
51
- });
52
- const noop = (x, y) => {};
53
- const drawRedPixel = diff ? (x, y) => drawPixel(width, diff, x - paddingSize, y - paddingSize, 255, 0, 0) : noop;
54
- const drawYellowPixel = diff ? (x, y) => drawPixel(width, diff, x - paddingSize, y - paddingSize, 255, 255, 0) : noop;
55
- const drawGrayPixel = diff ? (x, y) => {
56
- const gray = (0, _colorUtils.rgb2gray)(r1.get(x, y), g1.get(x, y), b1.get(x, y));
57
- const value = (0, _colorUtils.blendWithWhite)(gray, 0.1);
58
- drawPixel(width, diff, x - paddingSize, y - paddingSize, value, value, value);
59
- } : noop;
60
- let fastR, fastG, fastB;
61
- let diffCount = 0;
62
- for (let y = paddingSize; y < r1.height - paddingSize; ++y) {
63
- for (let x = paddingSize; x < r1.width - paddingSize; ++x) {
64
- // Fast-path: equal pixels.
65
- if (r1.get(x, y) === r2.get(x, y) && g1.get(x, y) === g2.get(x, y) && b1.get(x, y) === b2.get(x, y)) {
66
- drawGrayPixel(x, y);
67
- continue;
68
- }
69
-
70
- // Compare pixel colors using the dE94 color difference formulae.
71
- // The dE94 is normalized so that the value of 1.0 is the "just-noticeable-difference".
72
- // Color difference below 1.0 is not noticeable to a human eye, so we can disregard it.
73
- // See https://en.wikipedia.org/wiki/Color_difference
74
- const delta = (0, _colorUtils.colorDeltaE94)([r1.get(x, y), g1.get(x, y), b1.get(x, y)], [r2.get(x, y), g2.get(x, y), b2.get(x, y)]);
75
- if (delta <= maxColorDeltaE94) {
76
- drawGrayPixel(x, y);
77
- continue;
78
- }
79
- if (!fastR || !fastG || !fastB) {
80
- fastR = new _stats.FastStats(r1, r2);
81
- fastG = new _stats.FastStats(g1, g2);
82
- fastB = new _stats.FastStats(b1, b2);
83
- }
84
- const [varX1, varY1] = r1.boundXY(x - VARIANCE_WINDOW_RADIUS, y - VARIANCE_WINDOW_RADIUS);
85
- const [varX2, varY2] = r1.boundXY(x + VARIANCE_WINDOW_RADIUS, y + VARIANCE_WINDOW_RADIUS);
86
- const var1 = fastR.varianceC1(varX1, varY1, varX2, varY2) + fastG.varianceC1(varX1, varY1, varX2, varY2) + fastB.varianceC1(varX1, varY1, varX2, varY2);
87
- const var2 = fastR.varianceC2(varX1, varY1, varX2, varY2) + fastG.varianceC2(varX1, varY1, varX2, varY2) + fastB.varianceC2(varX1, varY1, varX2, varY2);
88
- // if this pixel is a part of a flood fill of a 3x3 square of either of the images, then it cannot be
89
- // anti-aliasing pixel so it must be a pixel difference.
90
- if (var1 === 0 || var2 === 0) {
91
- drawRedPixel(x, y);
92
- ++diffCount;
93
- continue;
94
- }
95
- const [ssimX1, ssimY1] = r1.boundXY(x - SSIM_WINDOW_RADIUS, y - SSIM_WINDOW_RADIUS);
96
- const [ssimX2, ssimY2] = r1.boundXY(x + SSIM_WINDOW_RADIUS, y + SSIM_WINDOW_RADIUS);
97
- const ssimRGB = ((0, _stats.ssim)(fastR, ssimX1, ssimY1, ssimX2, ssimY2) + (0, _stats.ssim)(fastG, ssimX1, ssimY1, ssimX2, ssimY2) + (0, _stats.ssim)(fastB, ssimX1, ssimY1, ssimX2, ssimY2)) / 3.0;
98
- const isAntialiased = ssimRGB >= 0.99;
99
- if (isAntialiased) {
100
- drawYellowPixel(x, y);
101
- } else {
102
- drawRedPixel(x, y);
103
- ++diffCount;
104
- }
105
- }
106
- }
107
- return diffCount;
108
- }
@@ -1,70 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ImageChannel = void 0;
7
- var _colorUtils = require("./colorUtils");
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 ImageChannel {
25
- static intoRGB(width, height, data, options = {}) {
26
- const {
27
- paddingSize = 0,
28
- paddingColorOdd = [255, 0, 255],
29
- paddingColorEven = [0, 255, 0]
30
- } = options;
31
- const newWidth = width + 2 * paddingSize;
32
- const newHeight = height + 2 * paddingSize;
33
- const r = new Uint8Array(newWidth * newHeight);
34
- const g = new Uint8Array(newWidth * newHeight);
35
- const b = new Uint8Array(newWidth * newHeight);
36
- for (let y = 0; y < newHeight; ++y) {
37
- for (let x = 0; x < newWidth; ++x) {
38
- const index = y * newWidth + x;
39
- if (y >= paddingSize && y < newHeight - paddingSize && x >= paddingSize && x < newWidth - paddingSize) {
40
- const offset = ((y - paddingSize) * width + (x - paddingSize)) * 4;
41
- const alpha = data[offset + 3] === 255 ? 1 : data[offset + 3] / 255;
42
- r[index] = (0, _colorUtils.blendWithWhite)(data[offset], alpha);
43
- g[index] = (0, _colorUtils.blendWithWhite)(data[offset + 1], alpha);
44
- b[index] = (0, _colorUtils.blendWithWhite)(data[offset + 2], alpha);
45
- } else {
46
- const color = (y + x) % 2 === 0 ? paddingColorEven : paddingColorOdd;
47
- r[index] = color[0];
48
- g[index] = color[1];
49
- b[index] = color[2];
50
- }
51
- }
52
- }
53
- return [new ImageChannel(newWidth, newHeight, r), new ImageChannel(newWidth, newHeight, g), new ImageChannel(newWidth, newHeight, b)];
54
- }
55
- constructor(width, height, data) {
56
- this.data = void 0;
57
- this.width = void 0;
58
- this.height = void 0;
59
- this.data = data;
60
- this.width = width;
61
- this.height = height;
62
- }
63
- get(x, y) {
64
- return this.data[y * this.width + x];
65
- }
66
- boundXY(x, y) {
67
- return [Math.min(Math.max(x, 0), this.width - 1), Math.min(Math.max(y, 0), this.height - 1)];
68
- }
69
- }
70
- exports.ImageChannel = ImageChannel;
@@ -1,102 +0,0 @@
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;
@@ -1,58 +0,0 @@
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
- }
@@ -1,160 +0,0 @@
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
- }
@@ -1,140 +0,0 @@
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
- }