@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.
- package/lib/client/clientStackTrace.js +66 -0
- package/lib/client/fileUtils.js +33 -0
- package/lib/client/platform.js +72 -0
- package/lib/client/timeoutSettings.js +66 -0
- package/lib/client/webSocket.js +107 -0
- package/lib/generated/recorderSource.js +7 -0
- package/lib/server/callLog.js +80 -0
- package/lib/server/harBackend.js +158 -0
- package/lib/server/localUtils.js +204 -0
- package/lib/server/recorder/chat.js +178 -0
- package/lib/server/recorder/codeGenerator.js +154 -0
- package/lib/server/recorder/csharp.js +311 -0
- package/lib/server/recorder/java.js +249 -0
- package/lib/server/recorder/javascript.js +230 -0
- package/lib/server/recorder/jsonl.js +48 -0
- package/lib/server/recorder/language.js +45 -0
- package/lib/server/recorder/python.js +276 -0
- package/lib/server/recorder/recorderActions.js +6 -0
- package/lib/server/recorder/utils.js +46 -0
- package/lib/server/storageScript.js +161 -0
- package/lib/server/timeoutSettings.js +75 -0
- package/lib/server/utils/ascii.js +32 -0
- package/lib/server/utils/comparators.js +160 -0
- package/lib/server/utils/crypto.js +172 -0
- package/lib/server/utils/debug.js +39 -0
- package/lib/server/utils/debugLogger.js +94 -0
- package/lib/server/utils/env.js +54 -0
- package/lib/server/utils/eventsHelper.js +39 -0
- package/lib/server/utils/expectUtils.js +34 -0
- package/lib/server/utils/fileUtils.js +205 -0
- package/lib/server/utils/happyEyeballs.js +210 -0
- package/lib/server/utils/hostPlatform.js +146 -0
- package/lib/server/utils/httpServer.js +234 -0
- package/lib/server/utils/image_tools/colorUtils.js +99 -0
- package/lib/server/utils/image_tools/compare.js +109 -0
- package/lib/server/utils/image_tools/imageChannel.js +71 -0
- package/lib/server/utils/image_tools/stats.js +103 -0
- package/lib/server/utils/linuxUtils.js +59 -0
- package/lib/server/utils/network.js +161 -0
- package/lib/server/utils/nodePlatform.js +141 -0
- package/lib/server/utils/pipeTransport.js +83 -0
- package/lib/server/utils/processLauncher.js +249 -0
- package/lib/server/utils/profiler.js +53 -0
- package/lib/server/utils/socksProxy.js +571 -0
- package/lib/server/utils/spawnAsync.js +46 -0
- package/lib/server/utils/task.js +59 -0
- package/lib/server/utils/userAgent.js +92 -0
- package/lib/server/utils/wsServer.js +129 -0
- package/lib/server/utils/zipFile.js +76 -0
- package/lib/server/utils/zones.js +55 -0
- package/lib/utils/glob.js +84 -0
- package/lib/utils/isomorphic/ariaSnapshot.js +393 -0
- package/lib/utils/isomorphic/assert.js +26 -0
- package/lib/utils/isomorphic/colors.js +66 -0
- package/lib/utils/isomorphic/headers.js +53 -0
- package/lib/utils/isomorphic/manualPromise.js +108 -0
- package/lib/utils/isomorphic/multimap.js +74 -0
- package/lib/utils/isomorphic/rtti.js +42 -0
- package/lib/utils/isomorphic/semaphore.js +52 -0
- package/lib/utils/isomorphic/stackTrace.js +170 -0
- package/lib/utils/isomorphic/time.js +26 -0
- package/lib/utils/isomorphic/timeoutRunner.js +67 -0
- package/lib/utils/isomorphic/types.js +6 -0
- package/lib/utils/mimeType.js +30 -0
- package/lib/utils.js +448 -0
- package/lib/vite/{traceViewer/assets/codeMirrorModule-lDjkI8Ax.js → recorder/assets/codeMirrorModule-CR6kB851.js} +1 -1
- package/lib/vite/recorder/assets/{index-Bxxcmxlu.js → index-BcaUAUCW.js} +2 -2
- package/lib/vite/recorder/index.html +1 -1
- package/lib/vite/traceViewer/assets/codeMirrorModule-CB-2okZ8.js +16684 -0
- package/lib/vite/traceViewer/assets/{codeMirrorModule-Bh1rfd2w.js → codeMirrorModule-tzBrK1V4.js} +10 -10
- package/lib/vite/traceViewer/assets/defaultSettingsView-CBiB4avC.js +217 -0
- package/lib/vite/traceViewer/assets/{inspectorTab-7GHnKvSD.js → inspectorTab-BuJ3wAX_.js} +2 -2
- package/lib/vite/traceViewer/assets/inspectorTab-CwgfffWb.js +25143 -0
- package/lib/vite/traceViewer/assets/workbench-CWZselvp.js +2470 -0
- package/lib/vite/traceViewer/assets/{workbench-C6nMfKVy.js → workbench-DdmJ9AJV.js} +1 -1
- package/lib/vite/traceViewer/assets/xtermModule-Es_gt_u7.js +5994 -0
- package/lib/vite/traceViewer/codeMirrorModule.DuST8d_k.css +344 -0
- package/lib/vite/traceViewer/defaultSettingsView.Dp3b_92q.css +41 -0
- package/lib/vite/traceViewer/embedded.BeldSa2G.css +68 -0
- package/lib/vite/traceViewer/{embedded.BIubxTi3.js → embedded.DInvAijy.js} +1 -1
- package/lib/vite/traceViewer/embedded.gzudoghF.js +106 -0
- package/lib/vite/traceViewer/embedded.html +3 -3
- package/lib/vite/traceViewer/{index.DPD22sZn.js → index.Dha3cgqs.js} +1 -1
- package/lib/vite/traceViewer/index.DilotR1h.js +314 -0
- package/lib/vite/traceViewer/index.QewjJ85u.css +131 -0
- package/lib/vite/traceViewer/index.html +3 -3
- package/lib/vite/traceViewer/inspectorTab.DnGm18kV.css +3178 -0
- package/lib/vite/traceViewer/recorder.DLgqV9db.css +15 -0
- package/lib/vite/traceViewer/{recorder.BaRuS6Pc.js → recorder.DNMfnSiu.js} +1 -1
- package/lib/vite/traceViewer/recorder.DVrkq3Um.js +551 -0
- package/lib/vite/traceViewer/recorder.html +2 -2
- package/lib/vite/traceViewer/uiMode.C9_OcpPU.js +1756 -0
- package/lib/vite/traceViewer/{uiMode.DXa41vt9.js → uiMode.Cr1tvTWS.js} +1 -1
- package/lib/vite/traceViewer/uiMode.c5ORgcrX.css +1424 -0
- package/lib/vite/traceViewer/uiMode.html +3 -3
- package/lib/vite/traceViewer/workbench.xUZSA8PY.css +787 -0
- package/lib/vite/traceViewer/xtermModule.EsaqrrTX.css +209 -0
- package/package.json +1 -1
- package/lib/vite/recorder/assets/codeMirrorModule-d0KhC1qL.js +0 -24
- package/lib/vite/traceViewer/assets/codeMirrorModule-xvopPhZ4.js +0 -24
- package/lib/vite/traceViewer/assets/inspectorTab-BPzhNk9r.js +0 -64
- package/lib/vite/traceViewer/assets/inspectorTab-wfvwpMHs.js +0 -64
- package/lib/vite/traceViewer/assets/workbench-DLv_q9ji.js +0 -9
- package/lib/vite/traceViewer/assets/workbench-LKskf2Iy.js +0 -9
- package/lib/vite/traceViewer/embedded.BXYl5zRv.js +0 -2
- package/lib/vite/traceViewer/embedded.CShPz96b.js +0 -2
- package/lib/vite/traceViewer/index.BZ9CE8t3.js +0 -2
- package/lib/vite/traceViewer/index.DZkJsFod.js +0 -2
- package/lib/vite/traceViewer/recorder.BVExlUUk.js +0 -2
- package/lib/vite/traceViewer/recorder.C4zxcvd2.js +0 -2
- package/lib/vite/traceViewer/uiMode.B11wexdJ.js +0 -5
- package/lib/vite/traceViewer/uiMode.DjTS7tqC.js +0 -5
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isOfficiallySupportedPlatform = exports.hostPlatform = void 0;
|
|
7
|
+
var _os = _interopRequireDefault(require("os"));
|
|
8
|
+
var _linuxUtils = require("./linuxUtils");
|
|
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
|
+
function calculatePlatform() {
|
|
27
|
+
if (process.env.PLAYWRIGHT_HOST_PLATFORM_OVERRIDE) {
|
|
28
|
+
return {
|
|
29
|
+
hostPlatform: process.env.PLAYWRIGHT_HOST_PLATFORM_OVERRIDE,
|
|
30
|
+
isOfficiallySupportedPlatform: false
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const platform = _os.default.platform();
|
|
34
|
+
if (platform === 'darwin') {
|
|
35
|
+
const ver = _os.default.release().split('.').map(a => parseInt(a, 10));
|
|
36
|
+
let macVersion = '';
|
|
37
|
+
if (ver[0] < 18) {
|
|
38
|
+
// Everything before 10.14 is considered 10.13.
|
|
39
|
+
macVersion = 'mac10.13';
|
|
40
|
+
} else if (ver[0] === 18) {
|
|
41
|
+
macVersion = 'mac10.14';
|
|
42
|
+
} else if (ver[0] === 19) {
|
|
43
|
+
macVersion = 'mac10.15';
|
|
44
|
+
} else {
|
|
45
|
+
// ver[0] >= 20
|
|
46
|
+
const LAST_STABLE_MACOS_MAJOR_VERSION = 15;
|
|
47
|
+
// Best-effort support for MacOS beta versions.
|
|
48
|
+
macVersion = 'mac' + Math.min(ver[0] - 9, LAST_STABLE_MACOS_MAJOR_VERSION);
|
|
49
|
+
// BigSur is the first version that might run on Apple Silicon.
|
|
50
|
+
if (_os.default.cpus().some(cpu => cpu.model.includes('Apple'))) macVersion += '-arm64';
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
hostPlatform: macVersion,
|
|
54
|
+
isOfficiallySupportedPlatform: true
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (platform === 'linux') {
|
|
58
|
+
if (!['x64', 'arm64'].includes(_os.default.arch())) return {
|
|
59
|
+
hostPlatform: '<unknown>',
|
|
60
|
+
isOfficiallySupportedPlatform: false
|
|
61
|
+
};
|
|
62
|
+
const archSuffix = '-' + _os.default.arch();
|
|
63
|
+
const distroInfo = (0, _linuxUtils.getLinuxDistributionInfoSync)();
|
|
64
|
+
|
|
65
|
+
// Pop!_OS is ubuntu-based and has the same versions.
|
|
66
|
+
// KDE Neon is ubuntu-based and has the same versions.
|
|
67
|
+
// TUXEDO OS is ubuntu-based and has the same versions.
|
|
68
|
+
if ((distroInfo === null || distroInfo === void 0 ? void 0 : distroInfo.id) === 'ubuntu' || (distroInfo === null || distroInfo === void 0 ? void 0 : distroInfo.id) === 'pop' || (distroInfo === null || distroInfo === void 0 ? void 0 : distroInfo.id) === 'neon' || (distroInfo === null || distroInfo === void 0 ? void 0 : distroInfo.id) === 'tuxedo') {
|
|
69
|
+
const isUbuntu = (distroInfo === null || distroInfo === void 0 ? void 0 : distroInfo.id) === 'ubuntu';
|
|
70
|
+
const version = distroInfo === null || distroInfo === void 0 ? void 0 : distroInfo.version;
|
|
71
|
+
const major = parseInt(distroInfo.version, 10);
|
|
72
|
+
if (major < 20) return {
|
|
73
|
+
hostPlatform: 'ubuntu18.04' + archSuffix,
|
|
74
|
+
isOfficiallySupportedPlatform: false
|
|
75
|
+
};
|
|
76
|
+
if (major < 22) return {
|
|
77
|
+
hostPlatform: 'ubuntu20.04' + archSuffix,
|
|
78
|
+
isOfficiallySupportedPlatform: isUbuntu && version === '20.04'
|
|
79
|
+
};
|
|
80
|
+
if (major < 24) return {
|
|
81
|
+
hostPlatform: 'ubuntu22.04' + archSuffix,
|
|
82
|
+
isOfficiallySupportedPlatform: isUbuntu && version === '22.04'
|
|
83
|
+
};
|
|
84
|
+
if (major < 26) return {
|
|
85
|
+
hostPlatform: 'ubuntu24.04' + archSuffix,
|
|
86
|
+
isOfficiallySupportedPlatform: isUbuntu && version === '24.04'
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
hostPlatform: 'ubuntu' + distroInfo.version + archSuffix,
|
|
90
|
+
isOfficiallySupportedPlatform: false
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// Linux Mint is ubuntu-based but does not have the same versions
|
|
94
|
+
if ((distroInfo === null || distroInfo === void 0 ? void 0 : distroInfo.id) === 'linuxmint') {
|
|
95
|
+
const mintMajor = parseInt(distroInfo.version, 10);
|
|
96
|
+
if (mintMajor <= 20) return {
|
|
97
|
+
hostPlatform: 'ubuntu20.04' + archSuffix,
|
|
98
|
+
isOfficiallySupportedPlatform: false
|
|
99
|
+
};
|
|
100
|
+
if (mintMajor === 21) return {
|
|
101
|
+
hostPlatform: 'ubuntu22.04' + archSuffix,
|
|
102
|
+
isOfficiallySupportedPlatform: false
|
|
103
|
+
};
|
|
104
|
+
return {
|
|
105
|
+
hostPlatform: 'ubuntu24.04' + archSuffix,
|
|
106
|
+
isOfficiallySupportedPlatform: false
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if ((distroInfo === null || distroInfo === void 0 ? void 0 : distroInfo.id) === 'debian' || (distroInfo === null || distroInfo === void 0 ? void 0 : distroInfo.id) === 'raspbian') {
|
|
110
|
+
const isOfficiallySupportedPlatform = (distroInfo === null || distroInfo === void 0 ? void 0 : distroInfo.id) === 'debian';
|
|
111
|
+
if ((distroInfo === null || distroInfo === void 0 ? void 0 : distroInfo.version) === '11') return {
|
|
112
|
+
hostPlatform: 'debian11' + archSuffix,
|
|
113
|
+
isOfficiallySupportedPlatform
|
|
114
|
+
};
|
|
115
|
+
if ((distroInfo === null || distroInfo === void 0 ? void 0 : distroInfo.version) === '12') return {
|
|
116
|
+
hostPlatform: 'debian12' + archSuffix,
|
|
117
|
+
isOfficiallySupportedPlatform
|
|
118
|
+
};
|
|
119
|
+
// use most recent supported release for 'debian testing' and 'unstable'.
|
|
120
|
+
// they never include a numeric version entry in /etc/os-release.
|
|
121
|
+
if ((distroInfo === null || distroInfo === void 0 ? void 0 : distroInfo.version) === '') return {
|
|
122
|
+
hostPlatform: 'debian12' + archSuffix,
|
|
123
|
+
isOfficiallySupportedPlatform
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
hostPlatform: 'ubuntu20.04' + archSuffix,
|
|
128
|
+
isOfficiallySupportedPlatform: false
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
if (platform === 'win32') return {
|
|
132
|
+
hostPlatform: 'win64',
|
|
133
|
+
isOfficiallySupportedPlatform: true
|
|
134
|
+
};
|
|
135
|
+
return {
|
|
136
|
+
hostPlatform: '<unknown>',
|
|
137
|
+
isOfficiallySupportedPlatform: false
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const {
|
|
141
|
+
hostPlatform,
|
|
142
|
+
isOfficiallySupportedPlatform
|
|
143
|
+
} = calculatePlatform();
|
|
144
|
+
exports.isOfficiallySupportedPlatform = isOfficiallySupportedPlatform;
|
|
145
|
+
exports.hostPlatform = hostPlatform;
|
|
146
|
+
//# sourceMappingURL=hostPlatform.js.map
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.HttpServer = void 0;
|
|
7
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _utilsBundle = require("../../utilsBundle");
|
|
10
|
+
var _crypto = require("./crypto");
|
|
11
|
+
var _assert = require("../../utils/isomorphic/assert");
|
|
12
|
+
var _manualPromise = require("../../utils/isomorphic/manualPromise");
|
|
13
|
+
var _network = require("./network");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
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
|
+
class HttpServer {
|
|
32
|
+
constructor() {
|
|
33
|
+
this._server = void 0;
|
|
34
|
+
this._urlPrefixPrecise = '';
|
|
35
|
+
this._urlPrefixHumanReadable = '';
|
|
36
|
+
this._port = 0;
|
|
37
|
+
this._started = false;
|
|
38
|
+
this._routes = [];
|
|
39
|
+
this._wsGuid = void 0;
|
|
40
|
+
this._server = (0, _network.createHttpServer)(this._onRequest.bind(this));
|
|
41
|
+
}
|
|
42
|
+
server() {
|
|
43
|
+
return this._server;
|
|
44
|
+
}
|
|
45
|
+
routePrefix(prefix, handler) {
|
|
46
|
+
this._routes.push({
|
|
47
|
+
prefix,
|
|
48
|
+
handler
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
routePath(path, handler) {
|
|
52
|
+
this._routes.push({
|
|
53
|
+
exact: path,
|
|
54
|
+
handler
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
port() {
|
|
58
|
+
return this._port;
|
|
59
|
+
}
|
|
60
|
+
async _tryStart(port, host) {
|
|
61
|
+
const errorPromise = new _manualPromise.ManualPromise();
|
|
62
|
+
const errorListener = error => errorPromise.reject(error);
|
|
63
|
+
this._server.on('error', errorListener);
|
|
64
|
+
try {
|
|
65
|
+
this._server.listen(port, host);
|
|
66
|
+
await Promise.race([new Promise(cb => this._server.once('listening', cb)), errorPromise]);
|
|
67
|
+
} finally {
|
|
68
|
+
this._server.removeListener('error', errorListener);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
createWebSocket(transport, guid) {
|
|
72
|
+
(0, _assert.assert)(!this._wsGuid, 'can only create one main websocket transport per server');
|
|
73
|
+
this._wsGuid = guid || (0, _crypto.createGuid)();
|
|
74
|
+
const wss = new _utilsBundle.wsServer({
|
|
75
|
+
server: this._server,
|
|
76
|
+
path: '/' + this._wsGuid
|
|
77
|
+
});
|
|
78
|
+
wss.on('connection', ws => {
|
|
79
|
+
transport.onconnect();
|
|
80
|
+
transport.sendEvent = (method, params) => ws.send(JSON.stringify({
|
|
81
|
+
method,
|
|
82
|
+
params
|
|
83
|
+
}));
|
|
84
|
+
transport.close = () => ws.close();
|
|
85
|
+
ws.on('message', async message => {
|
|
86
|
+
const {
|
|
87
|
+
id,
|
|
88
|
+
method,
|
|
89
|
+
params
|
|
90
|
+
} = JSON.parse(String(message));
|
|
91
|
+
try {
|
|
92
|
+
const result = await transport.dispatch(method, params);
|
|
93
|
+
ws.send(JSON.stringify({
|
|
94
|
+
id,
|
|
95
|
+
result
|
|
96
|
+
}));
|
|
97
|
+
} catch (e) {
|
|
98
|
+
ws.send(JSON.stringify({
|
|
99
|
+
id,
|
|
100
|
+
error: String(e)
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
ws.on('close', () => transport.onclose());
|
|
105
|
+
ws.on('error', () => transport.onclose());
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
wsGuid() {
|
|
109
|
+
return this._wsGuid;
|
|
110
|
+
}
|
|
111
|
+
async start(options = {}) {
|
|
112
|
+
(0, _assert.assert)(!this._started, 'server already started');
|
|
113
|
+
this._started = true;
|
|
114
|
+
const host = options.host || 'localhost';
|
|
115
|
+
if (options.preferredPort) {
|
|
116
|
+
try {
|
|
117
|
+
await this._tryStart(options.preferredPort, host);
|
|
118
|
+
} catch (e) {
|
|
119
|
+
if (!e || !e.message || !e.message.includes('EADDRINUSE')) throw e;
|
|
120
|
+
await this._tryStart(undefined, host);
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
await this._tryStart(options.port, host);
|
|
124
|
+
}
|
|
125
|
+
const address = this._server.address();
|
|
126
|
+
(0, _assert.assert)(address, 'Could not bind server socket');
|
|
127
|
+
if (typeof address === 'string') {
|
|
128
|
+
this._urlPrefixPrecise = address;
|
|
129
|
+
this._urlPrefixHumanReadable = address;
|
|
130
|
+
} else {
|
|
131
|
+
this._port = address.port;
|
|
132
|
+
const resolvedHost = address.family === 'IPv4' ? address.address : `[${address.address}]`;
|
|
133
|
+
this._urlPrefixPrecise = `http://${resolvedHost}:${address.port}`;
|
|
134
|
+
this._urlPrefixHumanReadable = `http://${host}:${address.port}`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async stop() {
|
|
138
|
+
await new Promise(cb => this._server.close(cb));
|
|
139
|
+
}
|
|
140
|
+
urlPrefix(purpose) {
|
|
141
|
+
return purpose === 'human-readable' ? this._urlPrefixHumanReadable : this._urlPrefixPrecise;
|
|
142
|
+
}
|
|
143
|
+
serveFile(request, response, absoluteFilePath, headers) {
|
|
144
|
+
try {
|
|
145
|
+
for (const [name, value] of Object.entries(headers || {})) response.setHeader(name, value);
|
|
146
|
+
if (request.headers.range) this._serveRangeFile(request, response, absoluteFilePath);else this._serveFile(response, absoluteFilePath);
|
|
147
|
+
return true;
|
|
148
|
+
} catch (e) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
_serveFile(response, absoluteFilePath) {
|
|
153
|
+
const content = _fs.default.readFileSync(absoluteFilePath);
|
|
154
|
+
response.statusCode = 200;
|
|
155
|
+
const contentType = _utilsBundle.mime.getType(_path.default.extname(absoluteFilePath)) || 'application/octet-stream';
|
|
156
|
+
response.setHeader('Content-Type', contentType);
|
|
157
|
+
response.setHeader('Content-Length', content.byteLength);
|
|
158
|
+
response.end(content);
|
|
159
|
+
}
|
|
160
|
+
_serveRangeFile(request, response, absoluteFilePath) {
|
|
161
|
+
const range = request.headers.range;
|
|
162
|
+
if (!range || !range.startsWith('bytes=') || range.includes(', ') || [...range].filter(char => char === '-').length !== 1) {
|
|
163
|
+
response.statusCode = 400;
|
|
164
|
+
return response.end('Bad request');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Parse the range header: https://datatracker.ietf.org/doc/html/rfc7233#section-2.1
|
|
168
|
+
const [startStr, endStr] = range.replace(/bytes=/, '').split('-');
|
|
169
|
+
|
|
170
|
+
// Both start and end (when passing to fs.createReadStream) and the range header are inclusive and start counting at 0.
|
|
171
|
+
let start;
|
|
172
|
+
let end;
|
|
173
|
+
const size = _fs.default.statSync(absoluteFilePath).size;
|
|
174
|
+
if (startStr !== '' && endStr === '') {
|
|
175
|
+
// No end specified: use the whole file
|
|
176
|
+
start = +startStr;
|
|
177
|
+
end = size - 1;
|
|
178
|
+
} else if (startStr === '' && endStr !== '') {
|
|
179
|
+
// No start specified: calculate start manually
|
|
180
|
+
start = size - +endStr;
|
|
181
|
+
end = size - 1;
|
|
182
|
+
} else {
|
|
183
|
+
start = +startStr;
|
|
184
|
+
end = +endStr;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Handle unavailable range request
|
|
188
|
+
if (Number.isNaN(start) || Number.isNaN(end) || start >= size || end >= size || start > end) {
|
|
189
|
+
// Return the 416 Range Not Satisfiable: https://datatracker.ietf.org/doc/html/rfc7233#section-4.4
|
|
190
|
+
response.writeHead(416, {
|
|
191
|
+
'Content-Range': `bytes */${size}`
|
|
192
|
+
});
|
|
193
|
+
return response.end();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Sending Partial Content: https://datatracker.ietf.org/doc/html/rfc7233#section-4.1
|
|
197
|
+
response.writeHead(206, {
|
|
198
|
+
'Content-Range': `bytes ${start}-${end}/${size}`,
|
|
199
|
+
'Accept-Ranges': 'bytes',
|
|
200
|
+
'Content-Length': end - start + 1,
|
|
201
|
+
'Content-Type': _utilsBundle.mime.getType(_path.default.extname(absoluteFilePath))
|
|
202
|
+
});
|
|
203
|
+
const readable = _fs.default.createReadStream(absoluteFilePath, {
|
|
204
|
+
start,
|
|
205
|
+
end
|
|
206
|
+
});
|
|
207
|
+
readable.pipe(response);
|
|
208
|
+
}
|
|
209
|
+
_onRequest(request, response) {
|
|
210
|
+
if (request.method === 'OPTIONS') {
|
|
211
|
+
response.writeHead(200);
|
|
212
|
+
response.end();
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
request.on('error', () => response.end());
|
|
216
|
+
try {
|
|
217
|
+
if (!request.url) {
|
|
218
|
+
response.end();
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const url = new URL('http://localhost' + request.url);
|
|
222
|
+
for (const route of this._routes) {
|
|
223
|
+
if (route.exact && url.pathname === route.exact && route.handler(request, response)) return;
|
|
224
|
+
if (route.prefix && url.pathname.startsWith(route.prefix) && route.handler(request, response)) return;
|
|
225
|
+
}
|
|
226
|
+
response.statusCode = 404;
|
|
227
|
+
response.end();
|
|
228
|
+
} catch (e) {
|
|
229
|
+
response.end();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
exports.HttpServer = HttpServer;
|
|
234
|
+
//# sourceMappingURL=httpServer.js.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.blendWithWhite = blendWithWhite;
|
|
7
|
+
exports.colorDeltaE94 = colorDeltaE94;
|
|
8
|
+
exports.rgb2gray = rgb2gray;
|
|
9
|
+
exports.srgb2xyz = srgb2xyz;
|
|
10
|
+
exports.xyz2lab = xyz2lab;
|
|
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 blendWithWhite(c, a) {
|
|
28
|
+
return 255 + (c - 255) * a;
|
|
29
|
+
}
|
|
30
|
+
function rgb2gray(r, g, b) {
|
|
31
|
+
// NOTE: this is the exact integer formula from SSIM.js.
|
|
32
|
+
// See https://github.com/obartra/ssim/blob/ca8e3c6a6ff5f4f2e232239e0c3d91806f3c97d5/src/matlab/rgb2gray.ts#L56
|
|
33
|
+
return 77 * r + 150 * g + 29 * b + 128 >> 8;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Perceived color difference defined by CIE94.
|
|
37
|
+
// See https://en.wikipedia.org/wiki/Color_difference#CIE94
|
|
38
|
+
//
|
|
39
|
+
// The result of 1.0 is a "just-noticeable difference".
|
|
40
|
+
//
|
|
41
|
+
// Other results interpretation (taken from http://zschuessler.github.io/DeltaE/learn/):
|
|
42
|
+
// < 1.0 Not perceptible by human eyes.
|
|
43
|
+
// 1-2 Perceptible through close observation.
|
|
44
|
+
// 2-10 Perceptible at a glance.
|
|
45
|
+
// 11-49 Colors are more similar than opposite
|
|
46
|
+
// 100 Colors are exact opposite
|
|
47
|
+
function colorDeltaE94(rgb1, rgb2) {
|
|
48
|
+
const [l1, a1, b1] = xyz2lab(srgb2xyz(rgb1));
|
|
49
|
+
const [l2, a2, b2] = xyz2lab(srgb2xyz(rgb2));
|
|
50
|
+
const deltaL = l1 - l2;
|
|
51
|
+
const deltaA = a1 - a2;
|
|
52
|
+
const deltaB = b1 - b2;
|
|
53
|
+
const c1 = Math.sqrt(a1 ** 2 + b1 ** 2);
|
|
54
|
+
const c2 = Math.sqrt(a2 ** 2 + b2 ** 2);
|
|
55
|
+
const deltaC = c1 - c2;
|
|
56
|
+
let deltaH = deltaA ** 2 + deltaB ** 2 - deltaC ** 2;
|
|
57
|
+
deltaH = deltaH < 0 ? 0 : Math.sqrt(deltaH);
|
|
58
|
+
// The k1, k2, kL, kC, kH values for "graphic arts" applications.
|
|
59
|
+
// See https://en.wikipedia.org/wiki/Color_difference#CIE94
|
|
60
|
+
const k1 = 0.045;
|
|
61
|
+
const k2 = 0.015;
|
|
62
|
+
const kL = 1;
|
|
63
|
+
const kC = 1;
|
|
64
|
+
const kH = 1;
|
|
65
|
+
const sC = 1.0 + k1 * c1;
|
|
66
|
+
const sH = 1.0 + k2 * c1;
|
|
67
|
+
const sL = 1;
|
|
68
|
+
return Math.sqrt((deltaL / sL / kL) ** 2 + (deltaC / sC / kC) ** 2 + (deltaH / sH / kH) ** 2);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// sRGB -> 1-normalized XYZ (i.e. Y ∈ [0, 1]) with D65 illuminant
|
|
72
|
+
// See https://en.wikipedia.org/wiki/SRGB#From_sRGB_to_CIE_XYZ
|
|
73
|
+
function srgb2xyz(rgb) {
|
|
74
|
+
let r = rgb[0] / 255;
|
|
75
|
+
let g = rgb[1] / 255;
|
|
76
|
+
let b = rgb[2] / 255;
|
|
77
|
+
r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
|
|
78
|
+
g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
|
|
79
|
+
b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
|
|
80
|
+
return [r * 0.4124 + g * 0.3576 + b * 0.1805, r * 0.2126 + g * 0.7152 + b * 0.0722, r * 0.0193 + g * 0.1192 + b * 0.9505];
|
|
81
|
+
}
|
|
82
|
+
const sigma_pow2 = 6 * 6 / 29 / 29;
|
|
83
|
+
const sigma_pow3 = 6 * 6 * 6 / 29 / 29 / 29;
|
|
84
|
+
|
|
85
|
+
// 1-normalized CIE XYZ with D65 to L*a*b*
|
|
86
|
+
// See https://en.wikipedia.org/wiki/CIELAB_color_space#From_CIEXYZ_to_CIELAB
|
|
87
|
+
function xyz2lab(xyz) {
|
|
88
|
+
const x = xyz[0] / 0.950489;
|
|
89
|
+
const y = xyz[1];
|
|
90
|
+
const z = xyz[2] / 1.088840;
|
|
91
|
+
const fx = x > sigma_pow3 ? x ** (1 / 3) : x / 3 / sigma_pow2 + 4 / 29;
|
|
92
|
+
const fy = y > sigma_pow3 ? y ** (1 / 3) : y / 3 / sigma_pow2 + 4 / 29;
|
|
93
|
+
const fz = z > sigma_pow3 ? z ** (1 / 3) : z / 3 / sigma_pow2 + 4 / 29;
|
|
94
|
+
const l = 116 * fy - 16;
|
|
95
|
+
const a = 500 * (fx - fy);
|
|
96
|
+
const b = 200 * (fy - fz);
|
|
97
|
+
return [l, a, b];
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=colorUtils.js.map
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
}
|
|
109
|
+
//# sourceMappingURL=compare.js.map
|
|
@@ -0,0 +1,71 @@
|
|
|
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;
|
|
71
|
+
//# sourceMappingURL=imageChannel.js.map
|