matterbridge 3.1.0-dev-20250627-94e7f6e → 3.1.0
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/CHANGELOG.md +4 -8
- package/dist/cli.d.ts +29 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +91 -2
- package/dist/cli.js.map +1 -0
- package/dist/clusters/export.d.ts +2 -0
- package/dist/clusters/export.d.ts.map +1 -0
- package/dist/clusters/export.js +2 -0
- package/dist/clusters/export.js.map +1 -0
- package/dist/defaultConfigSchema.d.ts +28 -0
- package/dist/defaultConfigSchema.d.ts.map +1 -0
- package/dist/defaultConfigSchema.js +24 -0
- package/dist/defaultConfigSchema.js.map +1 -0
- package/dist/deviceManager.d.ts +112 -0
- package/dist/deviceManager.d.ts.map +1 -0
- package/dist/deviceManager.js +94 -1
- package/dist/deviceManager.js.map +1 -0
- package/dist/devices/export.d.ts +5 -0
- package/dist/devices/export.d.ts.map +1 -0
- package/dist/devices/export.js +2 -0
- package/dist/devices/export.js.map +1 -0
- package/dist/evse.d.ts +72 -0
- package/dist/evse.d.ts.map +1 -0
- package/dist/evse.js +70 -9
- package/dist/evse.js.map +1 -0
- package/dist/frontend.d.ts +285 -0
- package/dist/frontend.d.ts.map +1 -0
- package/dist/frontend.js +413 -16
- package/dist/frontend.js.map +1 -0
- package/dist/globalMatterbridge.d.ts +59 -0
- package/dist/globalMatterbridge.d.ts.map +1 -0
- package/dist/globalMatterbridge.js +47 -0
- package/dist/globalMatterbridge.js.map +1 -0
- package/dist/helpers.d.ts +48 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +53 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -1
- package/dist/index.js.map +1 -0
- package/dist/laundryWasher.d.ts +243 -0
- package/dist/laundryWasher.d.ts.map +1 -0
- package/dist/laundryWasher.js +92 -7
- package/dist/laundryWasher.js.map +1 -0
- package/dist/logger/export.d.ts +2 -0
- package/dist/logger/export.d.ts.map +1 -0
- package/dist/logger/export.js +1 -0
- package/dist/logger/export.js.map +1 -0
- package/dist/matter/behaviors.d.ts +2 -0
- package/dist/matter/behaviors.d.ts.map +1 -0
- package/dist/matter/behaviors.js +2 -0
- package/dist/matter/behaviors.js.map +1 -0
- package/dist/matter/clusters.d.ts +2 -0
- package/dist/matter/clusters.d.ts.map +1 -0
- package/dist/matter/clusters.js +2 -0
- package/dist/matter/clusters.js.map +1 -0
- package/dist/matter/devices.d.ts +2 -0
- package/dist/matter/devices.d.ts.map +1 -0
- package/dist/matter/devices.js +2 -0
- package/dist/matter/devices.js.map +1 -0
- package/dist/matter/endpoints.d.ts +2 -0
- package/dist/matter/endpoints.d.ts.map +1 -0
- package/dist/matter/endpoints.js +2 -0
- package/dist/matter/endpoints.js.map +1 -0
- package/dist/matter/export.d.ts +5 -0
- package/dist/matter/export.d.ts.map +1 -0
- package/dist/matter/export.js +3 -0
- package/dist/matter/export.js.map +1 -0
- package/dist/matter/types.d.ts +3 -0
- package/dist/matter/types.d.ts.map +1 -0
- package/dist/matter/types.js +3 -0
- package/dist/matter/types.js.map +1 -0
- package/dist/matterbridge.d.ts +450 -0
- package/dist/matterbridge.d.ts.map +1 -0
- package/dist/matterbridge.js +809 -55
- package/dist/matterbridge.js.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts +42 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.js +36 -0
- package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
- package/dist/matterbridgeBehaviors.d.ts +1334 -0
- package/dist/matterbridgeBehaviors.d.ts.map +1 -0
- package/dist/matterbridgeBehaviors.js +55 -1
- package/dist/matterbridgeBehaviors.js.map +1 -0
- package/dist/matterbridgeDeviceTypes.d.ts +709 -0
- package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
- package/dist/matterbridgeDeviceTypes.js +579 -15
- package/dist/matterbridgeDeviceTypes.js.map +1 -0
- package/dist/matterbridgeDynamicPlatform.d.ts +42 -0
- package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
- package/dist/matterbridgeDynamicPlatform.js +36 -0
- package/dist/matterbridgeDynamicPlatform.js.map +1 -0
- package/dist/matterbridgeEndpoint.d.ts +1173 -0
- package/dist/matterbridgeEndpoint.d.ts.map +1 -0
- package/dist/matterbridgeEndpoint.js +1023 -41
- package/dist/matterbridgeEndpoint.js.map +1 -0
- package/dist/matterbridgeEndpointHelpers.d.ts +3198 -0
- package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
- package/dist/matterbridgeEndpointHelpers.js +322 -12
- package/dist/matterbridgeEndpointHelpers.js.map +1 -0
- package/dist/matterbridgePlatform.d.ts +310 -0
- package/dist/matterbridgePlatform.d.ts.map +1 -0
- package/dist/matterbridgePlatform.js +233 -0
- package/dist/matterbridgePlatform.js.map +1 -0
- package/dist/matterbridgeTypes.d.ts +184 -0
- package/dist/matterbridgeTypes.d.ts.map +1 -0
- package/dist/matterbridgeTypes.js +25 -0
- package/dist/matterbridgeTypes.js.map +1 -0
- package/dist/pluginManager.d.ts +291 -0
- package/dist/pluginManager.d.ts.map +1 -0
- package/dist/pluginManager.js +269 -3
- package/dist/pluginManager.js.map +1 -0
- package/dist/roboticVacuumCleaner.d.ts +104 -0
- package/dist/roboticVacuumCleaner.d.ts.map +1 -0
- package/dist/roboticVacuumCleaner.js +83 -6
- package/dist/roboticVacuumCleaner.js.map +1 -0
- package/dist/shelly.d.ts +174 -0
- package/dist/shelly.d.ts.map +1 -0
- package/dist/shelly.js +168 -7
- package/dist/shelly.js.map +1 -0
- package/dist/storage/export.d.ts +2 -0
- package/dist/storage/export.d.ts.map +1 -0
- package/dist/storage/export.js +1 -0
- package/dist/storage/export.js.map +1 -0
- package/dist/update.d.ts +59 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +54 -0
- package/dist/update.js.map +1 -0
- package/dist/utils/colorUtils.d.ts +117 -0
- package/dist/utils/colorUtils.d.ts.map +1 -0
- package/dist/utils/colorUtils.js +263 -2
- package/dist/utils/colorUtils.js.map +1 -0
- package/dist/utils/commandLine.d.ts +59 -0
- package/dist/utils/commandLine.d.ts.map +1 -0
- package/dist/utils/commandLine.js +54 -0
- package/dist/utils/commandLine.js.map +1 -0
- package/dist/utils/copyDirectory.d.ts +33 -0
- package/dist/utils/copyDirectory.d.ts.map +1 -0
- package/dist/utils/copyDirectory.js +38 -1
- package/dist/utils/copyDirectory.js.map +1 -0
- package/dist/utils/createDirectory.d.ts +34 -0
- package/dist/utils/createDirectory.d.ts.map +1 -0
- package/dist/utils/createDirectory.js +33 -0
- package/dist/utils/createDirectory.js.map +1 -0
- package/dist/utils/createZip.d.ts +39 -0
- package/dist/utils/createZip.d.ts.map +1 -0
- package/dist/utils/createZip.js +47 -2
- package/dist/utils/createZip.js.map +1 -0
- package/dist/utils/deepCopy.d.ts +32 -0
- package/dist/utils/deepCopy.d.ts.map +1 -0
- package/dist/utils/deepCopy.js +39 -0
- package/dist/utils/deepCopy.js.map +1 -0
- package/dist/utils/deepEqual.d.ts +54 -0
- package/dist/utils/deepEqual.d.ts.map +1 -0
- package/dist/utils/deepEqual.js +72 -1
- package/dist/utils/deepEqual.js.map +1 -0
- package/dist/utils/export.d.ts +12 -0
- package/dist/utils/export.d.ts.map +1 -0
- package/dist/utils/export.js +1 -0
- package/dist/utils/export.js.map +1 -0
- package/dist/utils/hex.d.ts +49 -0
- package/dist/utils/hex.d.ts.map +1 -0
- package/dist/utils/hex.js +58 -0
- package/dist/utils/hex.js.map +1 -0
- package/dist/utils/isvalid.d.ts +103 -0
- package/dist/utils/isvalid.d.ts.map +1 -0
- package/dist/utils/isvalid.js +101 -0
- package/dist/utils/isvalid.js.map +1 -0
- package/dist/utils/network.d.ts +76 -0
- package/dist/utils/network.d.ts.map +1 -0
- package/dist/utils/network.js +83 -5
- package/dist/utils/network.js.map +1 -0
- package/dist/utils/spawn.d.ts +14 -0
- package/dist/utils/spawn.d.ts.map +1 -0
- package/dist/utils/spawn.js +18 -0
- package/dist/utils/spawn.js.map +1 -0
- package/dist/utils/wait.d.ts +56 -0
- package/dist/utils/wait.d.ts.map +1 -0
- package/dist/utils/wait.js +62 -9
- package/dist/utils/wait.js.map +1 -0
- package/dist/waterHeater.d.ts +106 -0
- package/dist/waterHeater.d.ts.map +1 -0
- package/dist/waterHeater.js +77 -2
- package/dist/waterHeater.js.map +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
package/dist/utils/colorUtils.js
CHANGED
|
@@ -1,4 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the color utilities.
|
|
3
|
+
*
|
|
4
|
+
* @file colorUtils.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @created 2023-10-05
|
|
7
|
+
* @version 1.3.0
|
|
8
|
+
* @license Apache-2.0
|
|
9
|
+
*
|
|
10
|
+
* Copyright 2023, 2024, 2025 Luca Liguori.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
1
24
|
import { assert } from 'node:console';
|
|
25
|
+
/**
|
|
26
|
+
* Converts from HSL to RGB color space
|
|
27
|
+
*
|
|
28
|
+
* @param {number} hue - The hue value (0-360).
|
|
29
|
+
* @param {number} saturation - The saturation value (0-100).
|
|
30
|
+
* @param {number} luminance - The luminance value (0-100).
|
|
31
|
+
* @returns {RGB} An object containing the RGB values.
|
|
32
|
+
*/
|
|
2
33
|
export function hslColorToRgbColor(hue, saturation, luminance) {
|
|
3
34
|
if (hue === 360) {
|
|
4
35
|
hue = 0;
|
|
@@ -10,7 +41,7 @@ export function hslColorToRgbColor(hue, saturation, luminance) {
|
|
|
10
41
|
luminance /= 100;
|
|
11
42
|
let r, g, b;
|
|
12
43
|
if (saturation === 0) {
|
|
13
|
-
r = g = b = luminance;
|
|
44
|
+
r = g = b = luminance; // achromatic
|
|
14
45
|
}
|
|
15
46
|
else {
|
|
16
47
|
const hue2rgb = (p, q, t) => {
|
|
@@ -43,33 +74,54 @@ export function hslColorToRgbColor(hue, saturation, luminance) {
|
|
|
43
74
|
b: Math.ceil(b * 255),
|
|
44
75
|
};
|
|
45
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Converts RGB color space to CIE 1931 XY color space
|
|
79
|
+
*
|
|
80
|
+
* @param {RGB} rgb - The RGB color object.
|
|
81
|
+
* @returns {XY} An object containing the x and y values in CIE 1931 XY color space.
|
|
82
|
+
*/
|
|
46
83
|
export function rgbColorToXYColor(rgb) {
|
|
47
84
|
let r = rgb.r / 255;
|
|
48
85
|
let g = rgb.g / 255;
|
|
49
86
|
let b = rgb.b / 255;
|
|
87
|
+
// Apply gamma correction
|
|
50
88
|
r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
|
|
51
89
|
g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
|
|
52
90
|
b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
|
|
91
|
+
// Scale the values to the D65 illuminant
|
|
53
92
|
r = r * 100;
|
|
54
93
|
g = g * 100;
|
|
55
94
|
b = b * 100;
|
|
95
|
+
// Convert RGB to XYZ
|
|
56
96
|
const X = r * 0.664511 + g * 0.154324 + b * 0.162028;
|
|
57
97
|
const Y = r * 0.283881 + g * 0.668433 + b * 0.047685;
|
|
58
98
|
const Z = r * 0.000088 + g * 0.07231 + b * 0.986039;
|
|
99
|
+
// Normalization
|
|
59
100
|
let x = X / (X + Y + Z);
|
|
60
101
|
let y = Y / (X + Y + Z);
|
|
102
|
+
// Round to 4 digits
|
|
61
103
|
x = Math.round(x * 10000) / 10000;
|
|
62
104
|
y = Math.round(y * 10000) / 10000;
|
|
63
105
|
return { x, y };
|
|
64
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Converts CIE 1931 XY color space to RGB color space
|
|
109
|
+
*
|
|
110
|
+
* @param {number} x - The x value in CIE 1931 XY color space.
|
|
111
|
+
* @param {number} y - The y value in CIE 1931 XY color space.
|
|
112
|
+
* @param {number} [brightness] - The brightness value (1-254). Defaults to 254.
|
|
113
|
+
* @returns {RGB} An object containing the RGB values.
|
|
114
|
+
*/
|
|
65
115
|
export function xyColorToRgbColor(x, y, brightness = 254) {
|
|
66
116
|
const z = 1.0 - x - y;
|
|
67
117
|
const Y = (brightness / 254).toFixed(2);
|
|
68
118
|
const X = (Number(Y) / y) * x;
|
|
69
119
|
const Z = (Number(Y) / y) * z;
|
|
120
|
+
// Convert to RGB using Wide RGB D65 conversion
|
|
70
121
|
let red = X * 1.656492 - Number(Y) * 0.354851 - Z * 0.255038;
|
|
71
122
|
let green = -X * 0.707196 + Number(Y) * 1.655397 + Z * 0.036152;
|
|
72
123
|
let blue = X * 0.051713 - Number(Y) * 0.121364 + Z * 1.01153;
|
|
124
|
+
// If red, green or blue is larger than 1.0 set it back to the maximum of 1.0
|
|
73
125
|
if (red > blue && red > green && red > 1.0) {
|
|
74
126
|
green = green / red;
|
|
75
127
|
blue = blue / red;
|
|
@@ -85,23 +137,35 @@ export function xyColorToRgbColor(x, y, brightness = 254) {
|
|
|
85
137
|
green = green / blue;
|
|
86
138
|
blue = 1.0;
|
|
87
139
|
}
|
|
140
|
+
// Reverse gamma correction
|
|
88
141
|
red = red <= 0.0031308 ? 12.92 * red : (1.0 + 0.055) * Math.pow(red, 1.0 / 2.4) - 0.055;
|
|
89
142
|
green = green <= 0.0031308 ? 12.92 * green : (1.0 + 0.055) * Math.pow(green, 1.0 / 2.4) - 0.055;
|
|
90
143
|
blue = blue <= 0.0031308 ? 12.92 * blue : (1.0 + 0.055) * Math.pow(blue, 1.0 / 2.4) - 0.055;
|
|
144
|
+
// Convert normalized decimal to decimal
|
|
91
145
|
red = Math.round(red * 255);
|
|
92
146
|
green = Math.round(green * 255);
|
|
93
147
|
blue = Math.round(blue * 255);
|
|
148
|
+
// Normalize even if this code should never be reached...
|
|
94
149
|
if (isNaN(red) || red < 0) {
|
|
150
|
+
/* istanbul ignore next */
|
|
95
151
|
red = 0;
|
|
96
152
|
}
|
|
97
153
|
if (isNaN(green) || green < 0) {
|
|
154
|
+
/* istanbul ignore next */
|
|
98
155
|
green = 0;
|
|
99
156
|
}
|
|
100
157
|
if (isNaN(blue) || blue < 0) {
|
|
158
|
+
/* istanbul ignore next */
|
|
101
159
|
blue = 0;
|
|
102
160
|
}
|
|
103
161
|
return { r: Math.round(red), g: Math.round(green), b: Math.round(blue) };
|
|
104
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Converts RGB color space to HSL color space
|
|
165
|
+
*
|
|
166
|
+
* @param {RGB} rgb - The RGB color object.
|
|
167
|
+
* @returns {HSL} An object containing the HSL values.
|
|
168
|
+
*/
|
|
105
169
|
export function rgbColorToHslColor(rgb) {
|
|
106
170
|
const r = rgb.r / 255;
|
|
107
171
|
const g = rgb.g / 255;
|
|
@@ -111,7 +175,7 @@ export function rgbColorToHslColor(rgb) {
|
|
|
111
175
|
let h = 0, s = 0;
|
|
112
176
|
const l = (max + min) / 2;
|
|
113
177
|
if (max === min) {
|
|
114
|
-
h = s = 0;
|
|
178
|
+
h = s = 0; // achromatic
|
|
115
179
|
}
|
|
116
180
|
else {
|
|
117
181
|
const d = max - min;
|
|
@@ -135,19 +199,46 @@ export function rgbColorToHslColor(rgb) {
|
|
|
135
199
|
l: Math.round(l * 100),
|
|
136
200
|
};
|
|
137
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Converts CIE 1931 XY color space to HSL color space
|
|
204
|
+
*
|
|
205
|
+
* @param {number} x - The x value in CIE 1931 XY color space.
|
|
206
|
+
* @param {number} y - The y value in CIE 1931 XY color space.
|
|
207
|
+
* @returns {HSL} An object containing the HSL values.
|
|
208
|
+
*/
|
|
138
209
|
export function xyToHsl(x, y) {
|
|
139
210
|
const rgb = xyColorToRgbColor(x, y);
|
|
140
211
|
return rgbColorToHslColor(rgb);
|
|
141
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Converts mireds to kelvin.
|
|
215
|
+
*
|
|
216
|
+
* @param {number} mired - The mired value to convert.
|
|
217
|
+
* @returns {number} The converted kelvin value.
|
|
218
|
+
*/
|
|
142
219
|
export function miredToKelvin(mired) {
|
|
143
220
|
return Math.round(1000000 / mired);
|
|
144
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Converts kelvin to mireds.
|
|
224
|
+
*
|
|
225
|
+
* @param {number} kelvin - The kelvin value to convert.
|
|
226
|
+
* @returns {number} The converted mired value.
|
|
227
|
+
*/
|
|
145
228
|
export function kelvinToMired(kelvin) {
|
|
146
229
|
return Math.round(1000000 / kelvin);
|
|
147
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Converts kelvin to RGB color space.
|
|
233
|
+
*
|
|
234
|
+
* @param {number} kelvin - The kelvin value to convert (1000K to 40000K).
|
|
235
|
+
* @returns {RGB} An object containing the RGB values.
|
|
236
|
+
*/
|
|
148
237
|
export function kelvinToRGB(kelvin) {
|
|
238
|
+
// Clamp the temperature to the range 1000K to 40000K
|
|
149
239
|
kelvin = Math.max(1000, Math.min(40000, kelvin)) / 100;
|
|
150
240
|
let r, g, b;
|
|
241
|
+
// Calculate red
|
|
151
242
|
if (kelvin <= 66) {
|
|
152
243
|
r = 255;
|
|
153
244
|
}
|
|
@@ -156,6 +247,7 @@ export function kelvinToRGB(kelvin) {
|
|
|
156
247
|
r = 329.698727446 * Math.pow(r, -0.1332047592);
|
|
157
248
|
r = Math.max(0, Math.min(255, r));
|
|
158
249
|
}
|
|
250
|
+
// Calculate green
|
|
159
251
|
if (kelvin <= 66) {
|
|
160
252
|
g = kelvin;
|
|
161
253
|
g = 99.4708025861 * Math.log(g) - 161.1195681661;
|
|
@@ -166,6 +258,7 @@ export function kelvinToRGB(kelvin) {
|
|
|
166
258
|
g = 288.1221695283 * Math.pow(g, -0.0755148492);
|
|
167
259
|
g = Math.max(0, Math.min(255, g));
|
|
168
260
|
}
|
|
261
|
+
// Calculate blue
|
|
169
262
|
if (kelvin >= 66) {
|
|
170
263
|
b = 255;
|
|
171
264
|
}
|
|
@@ -179,3 +272,171 @@ export function kelvinToRGB(kelvin) {
|
|
|
179
272
|
}
|
|
180
273
|
return { r: Math.round(r), g: Math.round(g), b: Math.round(b) };
|
|
181
274
|
}
|
|
275
|
+
/*
|
|
276
|
+
export function testColors(): void {
|
|
277
|
+
// this table has been checked with different apps and sites and is correct 100%
|
|
278
|
+
const colors = [
|
|
279
|
+
{ name: 'Pure Red 0', hsl: { h: 0, s: 100, l: 50 }, rgb: { r: 255, g: 0, b: 0 }, xy: { x: 0.7006, y: 0.2993 } },
|
|
280
|
+
{ name: 'Bright Orange 30', hsl: { h: 30, s: 100, l: 50 }, rgb: { r: 255, g: 128, b: 0 }, xy: { x: 0.6112, y: 0.375 } },
|
|
281
|
+
{ name: 'Pure Yellow 60', hsl: { h: 60, s: 100, l: 50 }, rgb: { r: 255, g: 255, b: 0 }, xy: { x: 0.4442, y: 0.5166 } },
|
|
282
|
+
{ name: 'Lime Green 90', hsl: { h: 90, s: 100, l: 50 }, rgb: { r: 128, g: 255, b: 0 }, xy: { x: 0.2707, y: 0.6635 } },
|
|
283
|
+
{ name: 'Pure Green 120', hsl: { h: 120, s: 100, l: 50 }, rgb: { r: 0, g: 255, b: 0 }, xy: { x: 0.1724, y: 0.7468 } },
|
|
284
|
+
{ name: 'Light Sea Green 150', hsl: { h: 150, s: 100, l: 50 }, rgb: { r: 0, g: 255, b: 128 }, xy: { x: 0.1642, y: 0.5886 } },
|
|
285
|
+
{ name: 'Pure Cyan 180', hsl: { h: 180, s: 100, l: 50 }, rgb: { r: 0, g: 255, b: 255 }, xy: { x: 0.1513, y: 0.3425 } },
|
|
286
|
+
{ name: 'Deep Sky Blue 210', hsl: { h: 210, s: 100, l: 50 }, rgb: { r: 0, g: 128, b: 255 }, xy: { x: 0.1406, y: 0.1382 } },
|
|
287
|
+
{ name: 'Pure Blue 240', hsl: { h: 240, s: 100, l: 50 }, rgb: { r: 0, g: 0, b: 255 }, xy: { x: 0.1355, y: 0.0399 } },
|
|
288
|
+
{ name: 'Blue Violet 270', hsl: { h: 270, s: 100, l: 50 }, rgb: { r: 128, g: 0, b: 255 }, xy: { x: 0.2181, y: 0.0778 } },
|
|
289
|
+
{ name: 'Pure Magenta 300', hsl: { h: 300, s: 100, l: 50 }, rgb: { r: 255, g: 0, b: 255 }, xy: { x: 0.3855, y: 0.1546 } },
|
|
290
|
+
{ name: 'Deep Pink 330', hsl: { h: 330, s: 100, l: 50 }, rgb: { r: 255, g: 0, b: 128 }, xy: { x: 0.5797, y: 0.2438 } },
|
|
291
|
+
|
|
292
|
+
{ name: 'Pure Red 50% 0', hsl: { h: 0, s: 50, l: 50 }, rgb: { r: 192, g: 64, b: 64 }, xy: { x: 0.6036, y: 0.3069 } },
|
|
293
|
+
{ name: 'Bright Orange 50% 30', hsl: { h: 30, s: 50, l: 50 }, rgb: { r: 192, g: 128, b: 64 }, xy: { x: 0.5194, y: 0.3928 } },
|
|
294
|
+
{ name: 'Pure Yellow 50% 60', hsl: { h: 60, s: 50, l: 50 }, rgb: { r: 192, g: 192, b: 64 }, xy: { x: 0.4258, y: 0.4883 } },
|
|
295
|
+
{ name: 'Lime Green 50% 90', hsl: { h: 90, s: 50, l: 50 }, rgb: { r: 128, g: 192, b: 64 }, xy: { x: 0.3159, y: 0.5639 } },
|
|
296
|
+
{ name: 'Pure Green 50% 120', hsl: { h: 120, s: 50, l: 50 }, rgb: { r: 64, g: 192, b: 64 }, xy: { x: 0.2127, y: 0.6349 } },
|
|
297
|
+
{ name: 'Light Sea Green 50% 150', hsl: { h: 150, s: 50, l: 50 }, rgb: { r: 64, g: 192, b: 128 }, xy: { x: 0.1932, y: 0.4845 } },
|
|
298
|
+
{ name: 'Pure Cyan 50% 180', hsl: { h: 180, s: 50, l: 50 }, rgb: { r: 64, g: 192, b: 192 }, xy: { x: 0.1745, y: 0.3407 } },
|
|
299
|
+
{ name: 'Deep Sky Blue 50% 210', hsl: { h: 210, s: 50, l: 50 }, rgb: { r: 64, g: 128, b: 192 }, xy: { x: 0.1752, y: 0.211 } },
|
|
300
|
+
{ name: 'Pure Blue 50% 240', hsl: { h: 240, s: 50, l: 50 }, rgb: { r: 64, g: 64, b: 192 }, xy: { x: 0.1758, y: 0.102 } },
|
|
301
|
+
{ name: 'Blue Violet 50% 270', hsl: { h: 270, s: 50, l: 50 }, rgb: { r: 128, g: 64, b: 192 }, xy: { x: 0.2688, y: 0.137 } },
|
|
302
|
+
{ name: 'Pure Magenta 50% 300', hsl: { h: 300, s: 50, l: 50 }, rgb: { r: 192, g: 64, b: 192 }, xy: { x: 0.3772, y: 0.1777 } },
|
|
303
|
+
{ name: 'Deep Pink 50% 330', hsl: { h: 330, s: 50, l: 50 }, rgb: { r: 192, g: 64, b: 128 }, xy: { x: 0.489, y: 0.2416 } },
|
|
304
|
+
];
|
|
305
|
+
|
|
306
|
+
colors.forEach((color) => {
|
|
307
|
+
// eslint-disable-next-line no-console
|
|
308
|
+
console.log(
|
|
309
|
+
`\x1b[48;2;${color.rgb.r};${color.rgb.g};${color.rgb.b}mColor: ${color.name}\x1b[0m, hsl: { h: ${color.hsl.h}, s: ${color.hsl.s}, l: ${color.hsl.l} }, rgb: { r: ${color.rgb.r}, g: ${color.rgb.g}, b: ${color.rgb.b} }, xy: { x: ${color.xy.x}, y: ${color.xy.y} }`,
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
const rgb = hslColorToRgbColor(color.hsl.h, color.hsl.s, color.hsl.l);
|
|
313
|
+
assert(rgb.r === color.rgb.r && rgb.g === color.rgb.g && rgb.b === color.rgb.b, `\x1b[48;2;${rgb.r};${rgb.g};${rgb.b}mColor: ${color.name}\x1b[0m hslColorToRgbColor { r: ${rgb.r}, g: ${rgb.g}, b: ${rgb.b} } conversion error`);
|
|
314
|
+
|
|
315
|
+
const hsl = rgbColorToHslColor({ r: color.rgb.r, g: color.rgb.g, b: color.rgb.b });
|
|
316
|
+
assert(hsl.h === color.hsl.h && hsl.s === color.hsl.s && hsl.l === color.hsl.l, `Color: ${color.name} rgbColorToHslColor conversion error`);
|
|
317
|
+
|
|
318
|
+
const xy = rgbColorToXYColor({ r: color.rgb.r, g: color.rgb.g, b: color.rgb.b });
|
|
319
|
+
assert(xy.x === color.xy.x && xy.y === color.xy.y, `Color: ${color.name} rgbColorToXYColor conversion error got x ${xy.x} y ${xy.y}`);
|
|
320
|
+
|
|
321
|
+
const rgb2 = xyColorToRgbColor(color.xy.x, color.xy.y);
|
|
322
|
+
assert(
|
|
323
|
+
rgb2.r === color.rgb.r && rgb2.g === color.rgb.g && rgb2.b === color.rgb.b,
|
|
324
|
+
`\x1b[48;2;${rgb2.r};${rgb2.g};${rgb2.b}mColor: ${color.name}\x1b[0m xyColorToRgbColor(${color.xy.x}, ${color.xy.y}) conversion error -> r: ${rgb2.r} g: ${rgb2.g} b: ${rgb2.g}`,
|
|
325
|
+
);
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
*/
|
|
329
|
+
/**
|
|
330
|
+
* Converts CIE color space to RGB color space
|
|
331
|
+
*
|
|
332
|
+
* @param {number} x
|
|
333
|
+
* @param {number} y
|
|
334
|
+
* @param {number} brightness - Ranges from 1 to 254
|
|
335
|
+
* @returns {Array} Array that contains the color values for red, green and blue
|
|
336
|
+
* From: https://github.com/usolved/cie-rgb-converter/blob/master/cie_rgb_converter.js
|
|
337
|
+
*/
|
|
338
|
+
/*
|
|
339
|
+
export function cie_to_rgb(x: number, y: number, brightness = 254): RGB {
|
|
340
|
+
// Set to maximum brightness if no custom value was given (Not the slick ECMAScript 6 way for compatibility reasons)
|
|
341
|
+
|
|
342
|
+
const z = 1.0 - x - y;
|
|
343
|
+
const Y = (brightness / 254).toFixed(2);
|
|
344
|
+
const X = (Number(Y) / y) * x;
|
|
345
|
+
const Z = (Number(Y) / y) * z;
|
|
346
|
+
|
|
347
|
+
// Convert to RGB using Wide RGB D65 conversion
|
|
348
|
+
let red = X * 1.656492 - Number(Y) * 0.354851 - Z * 0.255038;
|
|
349
|
+
let green = -X * 0.707196 + Number(Y) * 1.655397 + Z * 0.036152;
|
|
350
|
+
let blue = X * 0.051713 - Number(Y) * 0.121364 + Z * 1.01153;
|
|
351
|
+
|
|
352
|
+
// If red, green or blue is larger than 1.0 set it back to the maximum of 1.0
|
|
353
|
+
if (red > blue && red > green && red > 1.0) {
|
|
354
|
+
green = green / red;
|
|
355
|
+
blue = blue / red;
|
|
356
|
+
red = 1.0;
|
|
357
|
+
} else if (green > blue && green > red && green > 1.0) {
|
|
358
|
+
red = red / green;
|
|
359
|
+
blue = blue / green;
|
|
360
|
+
green = 1.0;
|
|
361
|
+
} else if (blue > red && blue > green && blue > 1.0) {
|
|
362
|
+
red = red / blue;
|
|
363
|
+
green = green / blue;
|
|
364
|
+
blue = 1.0;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// Reverse gamma correction
|
|
368
|
+
red = red <= 0.0031308 ? 12.92 * red : (1.0 + 0.055) * Math.pow(red, 1.0 / 2.4) - 0.055;
|
|
369
|
+
green = green <= 0.0031308 ? 12.92 * green : (1.0 + 0.055) * Math.pow(green, 1.0 / 2.4) - 0.055;
|
|
370
|
+
blue = blue <= 0.0031308 ? 12.92 * blue : (1.0 + 0.055) * Math.pow(blue, 1.0 / 2.4) - 0.055;
|
|
371
|
+
|
|
372
|
+
// Convert normalized decimal to decimal
|
|
373
|
+
red = Math.round(red * 255);
|
|
374
|
+
green = Math.round(green * 255);
|
|
375
|
+
blue = Math.round(blue * 255);
|
|
376
|
+
|
|
377
|
+
// Normalize
|
|
378
|
+
if (isNaN(red) || red < 0) {
|
|
379
|
+
red = 0;
|
|
380
|
+
}
|
|
381
|
+
if (isNaN(green) || green < 0) {
|
|
382
|
+
green = 0;
|
|
383
|
+
}
|
|
384
|
+
if (isNaN(blue) || blue < 0) {
|
|
385
|
+
blue = 0;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return { r: red, g: green, b: blue };
|
|
389
|
+
}
|
|
390
|
+
*/
|
|
391
|
+
/**
|
|
392
|
+
* Converts RGB color space to CIE color space
|
|
393
|
+
*
|
|
394
|
+
* @param {number} red
|
|
395
|
+
* @param {number} green
|
|
396
|
+
* @param {number} blue
|
|
397
|
+
* @returns {Array} Array that contains the CIE color values for x and y
|
|
398
|
+
* From: https://github.com/usolved/cie-rgb-converter/blob/master/cie_rgb_converter.js
|
|
399
|
+
*/
|
|
400
|
+
/*
|
|
401
|
+
export function rgb_to_cie(red: number, green: number, blue: number): XY {
|
|
402
|
+
// Apply a gamma correction to the RGB values, which makes the color more vivid and more the like the color displayed on the screen of your device
|
|
403
|
+
red = red > 0.04045 ? Math.pow((red + 0.055) / (1.0 + 0.055), 2.4) : red / 12.92;
|
|
404
|
+
green = green > 0.04045 ? Math.pow((green + 0.055) / (1.0 + 0.055), 2.4) : green / 12.92;
|
|
405
|
+
blue = blue > 0.04045 ? Math.pow((blue + 0.055) / (1.0 + 0.055), 2.4) : blue / 12.92;
|
|
406
|
+
|
|
407
|
+
// RGB values to XYZ using the Wide RGB D65 conversion formula
|
|
408
|
+
const X = red * 0.664511 + green * 0.154324 + blue * 0.162028;
|
|
409
|
+
const Y = red * 0.283881 + green * 0.668433 + blue * 0.047685;
|
|
410
|
+
const Z = red * 0.000088 + green * 0.07231 + blue * 0.986039;
|
|
411
|
+
|
|
412
|
+
// Calculate the xy values from the XYZ values
|
|
413
|
+
let x = (X / (X + Y + Z)).toFixed(4);
|
|
414
|
+
let y = (Y / (X + Y + Z)).toFixed(4);
|
|
415
|
+
|
|
416
|
+
if (isNaN(Number(x))) {
|
|
417
|
+
x = '0';
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
if (isNaN(Number(y))) {
|
|
421
|
+
y = '0';
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
return { x: Number(x), y: Number(y) };
|
|
425
|
+
}
|
|
426
|
+
*/
|
|
427
|
+
/*
|
|
428
|
+
testColors();
|
|
429
|
+
console.log('rgb_to_cie(0, 128, 255)', rgb_to_cie(0, 128, 255));
|
|
430
|
+
console.log('cie_to_rgb(0.1401, 0.1284, 254)', cie_to_rgb(0.1401, 0.1284, 254));
|
|
431
|
+
console.log('cie_to_rgb(0.1406, 0.1382, 254)', cie_to_rgb(0.1406, 0.1382, 254));
|
|
432
|
+
for (let h = 0; h < 360; h++) {
|
|
433
|
+
const rgb = hslColorToRgbColor(h, 100, 50);
|
|
434
|
+
const xy = rgbColorToXYColor({ r: rgb.r, g: rgb.g, b: rgb.b });
|
|
435
|
+
const rgb2 = cie_to_rgb(xy.x, xy.y, 254);
|
|
436
|
+
const hsl = rgbColorToHslColor({ r: rgb2.r, g: rgb2.g, b: rgb2.b });
|
|
437
|
+
assert(rgb.r === rgb2.r && rgb.g === rgb2.g && rgb.b === rgb2.b, 'Color rgb conversion error');
|
|
438
|
+
assert(h === hsl.h, 'Color hsl conversion error');
|
|
439
|
+
console.log(`\x1b[48;2;${rgb.r};${rgb.g};${rgb.b}mColor: r:${rgb.r} g:${rgb.g} b:${rgb.b}\x1b[0m => x:${xy.x} y:${xy.y} => \x1b[48;2;${rgb2.r};${rgb2.g};${rgb2.b}mColor: r:${rgb2.r} g:${rgb2.g} b:${rgb2.b} h:${hsl.h} s:${hsl.s}\x1b[0m\x1b[K`);
|
|
440
|
+
}
|
|
441
|
+
*/
|
|
442
|
+
//# source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,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the parameters functions.
|
|
3
|
+
*
|
|
4
|
+
* @file parameter.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @created 2025-02-16
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
* @license Apache-2.0
|
|
9
|
+
*
|
|
10
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Checks if a command-line parameter is present.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} name - The name of the parameter to check.
|
|
28
|
+
* @returns {boolean} True if the parameter is present, otherwise false.
|
|
29
|
+
*/
|
|
30
|
+
export declare function hasParameter(name: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Retrieves the value of a command-line parameter as a string.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} name - The name of the parameter to retrieve.
|
|
35
|
+
* @returns {string | undefined} The value of the parameter, or undefined if not found.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getParameter(name: string): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Retrieves the value of a command-line parameter as an integer.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} name - The name of the parameter to retrieve.
|
|
42
|
+
* @returns {number | undefined} The integer value of the parameter, or undefined if not found or invalid.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getIntParameter(name: string): number | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves the value of a command-line parameter as a number array.
|
|
47
|
+
*
|
|
48
|
+
* @param {string} name - The name of the parameter to retrieve.
|
|
49
|
+
* @returns {number[] | undefined} An array of string values for the parameter, or undefined if not found.
|
|
50
|
+
*/
|
|
51
|
+
export declare function getIntArrayParameter(name: string): number[] | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Retrieves the value of a command-line parameter as a string array.
|
|
54
|
+
*
|
|
55
|
+
* @param {string} name - The name of the parameter to retrieve.
|
|
56
|
+
* @returns {string[] | undefined} An array of string values for the parameter, or undefined if not found.
|
|
57
|
+
*/
|
|
58
|
+
export declare function getStringArrayParameter(name: string): string[] | undefined;
|
|
59
|
+
//# sourceMappingURL=commandLine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandLine.d.ts","sourceRoot":"","sources":["../../src/utils/commandLine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKlD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM7D;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMhE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAYvE;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAW1E"}
|
|
@@ -1,4 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the parameters functions.
|
|
3
|
+
*
|
|
4
|
+
* @file parameter.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @created 2025-02-16
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
* @license Apache-2.0
|
|
9
|
+
*
|
|
10
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
1
24
|
import { isValidNumber } from './export.js';
|
|
25
|
+
/**
|
|
26
|
+
* Checks if a command-line parameter is present.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} name - The name of the parameter to check.
|
|
29
|
+
* @returns {boolean} True if the parameter is present, otherwise false.
|
|
30
|
+
*/
|
|
2
31
|
export function hasParameter(name) {
|
|
3
32
|
const commandArguments = process.argv.slice(2);
|
|
4
33
|
let markerIncluded = commandArguments.includes(`-${name}`);
|
|
@@ -6,6 +35,12 @@ export function hasParameter(name) {
|
|
|
6
35
|
markerIncluded = commandArguments.includes(`--${name}`);
|
|
7
36
|
return markerIncluded;
|
|
8
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Retrieves the value of a command-line parameter as a string.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} name - The name of the parameter to retrieve.
|
|
42
|
+
* @returns {string | undefined} The value of the parameter, or undefined if not found.
|
|
43
|
+
*/
|
|
9
44
|
export function getParameter(name) {
|
|
10
45
|
const commandArguments = process.argv.slice(2);
|
|
11
46
|
let markerIndex = commandArguments.indexOf(`-${name}`);
|
|
@@ -15,6 +50,12 @@ export function getParameter(name) {
|
|
|
15
50
|
return undefined;
|
|
16
51
|
return commandArguments[markerIndex + 1];
|
|
17
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves the value of a command-line parameter as an integer.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} name - The name of the parameter to retrieve.
|
|
57
|
+
* @returns {number | undefined} The integer value of the parameter, or undefined if not found or invalid.
|
|
58
|
+
*/
|
|
18
59
|
export function getIntParameter(name) {
|
|
19
60
|
const value = getParameter(name);
|
|
20
61
|
if (value === undefined)
|
|
@@ -24,6 +65,12 @@ export function getIntParameter(name) {
|
|
|
24
65
|
return undefined;
|
|
25
66
|
return intValue;
|
|
26
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Retrieves the value of a command-line parameter as a number array.
|
|
70
|
+
*
|
|
71
|
+
* @param {string} name - The name of the parameter to retrieve.
|
|
72
|
+
* @returns {number[] | undefined} An array of string values for the parameter, or undefined if not found.
|
|
73
|
+
*/
|
|
27
74
|
export function getIntArrayParameter(name) {
|
|
28
75
|
const commandArguments = process.argv.slice(2);
|
|
29
76
|
let markerIndex = commandArguments.indexOf(`--${name}`);
|
|
@@ -41,6 +88,12 @@ export function getIntArrayParameter(name) {
|
|
|
41
88
|
return undefined;
|
|
42
89
|
return intValues;
|
|
43
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Retrieves the value of a command-line parameter as a string array.
|
|
93
|
+
*
|
|
94
|
+
* @param {string} name - The name of the parameter to retrieve.
|
|
95
|
+
* @returns {string[] | undefined} An array of string values for the parameter, or undefined if not found.
|
|
96
|
+
*/
|
|
44
97
|
export function getStringArrayParameter(name) {
|
|
45
98
|
const commandArguments = process.argv.slice(2);
|
|
46
99
|
let markerIndex = commandArguments.indexOf(`--${name}`);
|
|
@@ -56,3 +109,4 @@ export function getStringArrayParameter(name) {
|
|
|
56
109
|
return undefined;
|
|
57
110
|
return values;
|
|
58
111
|
}
|
|
112
|
+
//# sourceMappingURL=commandLine.js.map
|
|
@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I,EAAE,CAAC,CAAC;IACxD,IAAI,WAAW,GAAG,CAAC;QAAE,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACxE,IAAI,WAAW,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IACtC,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,WAAW,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,CAAC,MAAM,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACvG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC1C,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the copyDirectory function.
|
|
3
|
+
*
|
|
4
|
+
* @file copyDirectory.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @created 2025-02-16
|
|
7
|
+
* @version 1.0.1
|
|
8
|
+
* @license Apache-2.0
|
|
9
|
+
*
|
|
10
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Copies a directory and all its subdirectories and files to a new location.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} srcDir - The path to the source directory.
|
|
28
|
+
* @param {string} destDir - The path to the destination directory.
|
|
29
|
+
* @returns {Promise<boolean>} - A promise that resolves when the copy operation is complete or fails for error.
|
|
30
|
+
* @throws {Error} - Throws an error if the copy operation fails.
|
|
31
|
+
*/
|
|
32
|
+
export declare function copyDirectory(srcDir: string, destDir: string): Promise<boolean>;
|
|
33
|
+
//# sourceMappingURL=copyDirectory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copyDirectory.d.ts","sourceRoot":"","sources":["../../src/utils/copyDirectory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA8CrF"}
|
|
@@ -1,4 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the copyDirectory function.
|
|
3
|
+
*
|
|
4
|
+
* @file copyDirectory.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @created 2025-02-16
|
|
7
|
+
* @version 1.0.1
|
|
8
|
+
* @license Apache-2.0
|
|
9
|
+
*
|
|
10
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
// AnsiLogger module
|
|
1
25
|
import { AnsiLogger } from '../logger/export.js';
|
|
26
|
+
/**
|
|
27
|
+
* Copies a directory and all its subdirectories and files to a new location.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} srcDir - The path to the source directory.
|
|
30
|
+
* @param {string} destDir - The path to the destination directory.
|
|
31
|
+
* @returns {Promise<boolean>} - A promise that resolves when the copy operation is complete or fails for error.
|
|
32
|
+
* @throws {Error} - Throws an error if the copy operation fails.
|
|
33
|
+
*/
|
|
2
34
|
export async function copyDirectory(srcDir, destDir) {
|
|
3
35
|
if (srcDir === '') {
|
|
4
36
|
throw new Error('Source directory must be specified.');
|
|
@@ -15,20 +47,24 @@ export async function copyDirectory(srcDir, destDir) {
|
|
|
15
47
|
if (srcDir === destDir) {
|
|
16
48
|
throw new Error('Source and destination directories must be different.');
|
|
17
49
|
}
|
|
18
|
-
const log = new AnsiLogger({ logName: 'Archive', logTimestampFormat: 4
|
|
50
|
+
const log = new AnsiLogger({ logName: 'Archive', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: "info" /* LogLevel.INFO */ });
|
|
19
51
|
const fs = await import('node:fs').then((mod) => mod.promises);
|
|
20
52
|
const path = await import('node:path');
|
|
21
53
|
log.debug(`copyDirectory: copying directory from ${srcDir} to ${destDir}`);
|
|
22
54
|
try {
|
|
55
|
+
// Create destination directory if it doesn't exist
|
|
23
56
|
await fs.mkdir(destDir, { recursive: true });
|
|
57
|
+
// Read contents of the source directory
|
|
24
58
|
const entries = await fs.readdir(srcDir, { withFileTypes: true });
|
|
25
59
|
for (const entry of entries) {
|
|
26
60
|
const srcPath = path.join(srcDir, entry.name);
|
|
27
61
|
const destPath = path.join(destDir, entry.name);
|
|
28
62
|
if (entry.isDirectory()) {
|
|
63
|
+
// Recursive call if entry is a directory
|
|
29
64
|
await copyDirectory(srcPath, destPath);
|
|
30
65
|
}
|
|
31
66
|
else if (entry.isFile()) {
|
|
67
|
+
// Copy file if entry is a file
|
|
32
68
|
await fs.copyFile(srcPath, destPath);
|
|
33
69
|
}
|
|
34
70
|
}
|
|
@@ -39,3 +75,4 @@ export async function copyDirectory(srcDir, destDir) {
|
|
|
39
75
|
return false;
|
|
40
76
|
}
|
|
41
77
|
}
|
|
78
|
+
//# sourceMappingURL=copyDirectory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copyDirectory.js","sourceRoot":"","sources":["../../src/utils/copyDirectory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,oBAAoB;AACpB,OAAO,EAAE,UAAU,EAA6B,MAAM,qBAAqB,CAAC;AAE5E;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAc,EAAE,OAAe;IACjE,IAAI,MAAM,KAAK,EAAE,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IACD,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IACD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,qCAA6B,EAAE,QAAQ,4BAAe,EAAE,CAAC,CAAC;IAE7H,MAAM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