matterbridge 3.0.6 → 3.0.7-dev-20250614-0d145a8

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 (183) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cli.js +2 -62
  3. package/dist/cluster/export.js +0 -2
  4. package/dist/defaultConfigSchema.js +0 -23
  5. package/dist/deviceManager.js +1 -94
  6. package/dist/evse.js +9 -65
  7. package/dist/frontend.js +16 -374
  8. package/dist/globalMatterbridge.js +0 -20
  9. package/dist/helpers.js +0 -51
  10. package/dist/index.js +1 -28
  11. package/dist/laundryWasher.js +7 -92
  12. package/dist/logger/export.js +0 -1
  13. package/dist/matter/behaviors.js +0 -2
  14. package/dist/matter/clusters.js +0 -2
  15. package/dist/matter/devices.js +0 -2
  16. package/dist/matter/endpoints.js +0 -2
  17. package/dist/matter/export.js +0 -2
  18. package/dist/matter/types.js +0 -2
  19. package/dist/matterbridge.js +46 -748
  20. package/dist/matterbridgeAccessoryPlatform.js +0 -34
  21. package/dist/matterbridgeBehaviors.js +1 -54
  22. package/dist/matterbridgeDeviceTypes.js +15 -578
  23. package/dist/matterbridgeDynamicPlatform.js +0 -34
  24. package/dist/matterbridgeEndpoint.js +43 -997
  25. package/dist/matterbridgeEndpointHelpers.js +10 -204
  26. package/dist/matterbridgePlatform.js +7 -225
  27. package/dist/matterbridgeTypes.js +0 -24
  28. package/dist/pluginManager.js +3 -269
  29. package/dist/roboticVacuumCleaner.js +6 -81
  30. package/dist/shelly.js +7 -155
  31. package/dist/storage/export.js +0 -1
  32. package/dist/update.js +0 -53
  33. package/dist/utils/colorUtils.js +2 -205
  34. package/dist/utils/commandLine.js +0 -53
  35. package/dist/utils/copyDirectory.js +1 -37
  36. package/dist/utils/createDirectory.js +0 -31
  37. package/dist/utils/createZip.js +2 -42
  38. package/dist/utils/deepCopy.js +0 -38
  39. package/dist/utils/deepEqual.js +1 -71
  40. package/dist/utils/export.js +0 -1
  41. package/dist/utils/hex.js +0 -57
  42. package/dist/utils/isvalid.js +0 -100
  43. package/dist/utils/network.js +5 -76
  44. package/dist/utils/spawn.js +0 -16
  45. package/dist/utils/wait.js +9 -58
  46. package/dist/waterHeater.js +2 -62
  47. package/npm-shrinkwrap.json +40 -28
  48. package/package.json +2 -3
  49. package/dist/cli.d.ts +0 -29
  50. package/dist/cli.d.ts.map +0 -1
  51. package/dist/cli.js.map +0 -1
  52. package/dist/cluster/export.d.ts +0 -2
  53. package/dist/cluster/export.d.ts.map +0 -1
  54. package/dist/cluster/export.js.map +0 -1
  55. package/dist/defaultConfigSchema.d.ts +0 -27
  56. package/dist/defaultConfigSchema.d.ts.map +0 -1
  57. package/dist/defaultConfigSchema.js.map +0 -1
  58. package/dist/deviceManager.d.ts +0 -114
  59. package/dist/deviceManager.d.ts.map +0 -1
  60. package/dist/deviceManager.js.map +0 -1
  61. package/dist/evse.d.ts +0 -67
  62. package/dist/evse.d.ts.map +0 -1
  63. package/dist/evse.js.map +0 -1
  64. package/dist/frontend.d.ts +0 -256
  65. package/dist/frontend.d.ts.map +0 -1
  66. package/dist/frontend.js.map +0 -1
  67. package/dist/globalMatterbridge.d.ts +0 -32
  68. package/dist/globalMatterbridge.d.ts.map +0 -1
  69. package/dist/globalMatterbridge.js.map +0 -1
  70. package/dist/helpers.d.ts +0 -47
  71. package/dist/helpers.d.ts.map +0 -1
  72. package/dist/helpers.js.map +0 -1
  73. package/dist/index.d.ts +0 -37
  74. package/dist/index.d.ts.map +0 -1
  75. package/dist/index.js.map +0 -1
  76. package/dist/laundryWasher.d.ts +0 -243
  77. package/dist/laundryWasher.d.ts.map +0 -1
  78. package/dist/laundryWasher.js.map +0 -1
  79. package/dist/logger/export.d.ts +0 -2
  80. package/dist/logger/export.d.ts.map +0 -1
  81. package/dist/logger/export.js.map +0 -1
  82. package/dist/matter/behaviors.d.ts +0 -2
  83. package/dist/matter/behaviors.d.ts.map +0 -1
  84. package/dist/matter/behaviors.js.map +0 -1
  85. package/dist/matter/clusters.d.ts +0 -2
  86. package/dist/matter/clusters.d.ts.map +0 -1
  87. package/dist/matter/clusters.js.map +0 -1
  88. package/dist/matter/devices.d.ts +0 -2
  89. package/dist/matter/devices.d.ts.map +0 -1
  90. package/dist/matter/devices.js.map +0 -1
  91. package/dist/matter/endpoints.d.ts +0 -2
  92. package/dist/matter/endpoints.d.ts.map +0 -1
  93. package/dist/matter/endpoints.js.map +0 -1
  94. package/dist/matter/export.d.ts +0 -5
  95. package/dist/matter/export.d.ts.map +0 -1
  96. package/dist/matter/export.js.map +0 -1
  97. package/dist/matter/types.d.ts +0 -3
  98. package/dist/matter/types.d.ts.map +0 -1
  99. package/dist/matter/types.js.map +0 -1
  100. package/dist/matterbridge.d.ts +0 -445
  101. package/dist/matterbridge.d.ts.map +0 -1
  102. package/dist/matterbridge.js.map +0 -1
  103. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -40
  104. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  105. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  106. package/dist/matterbridgeBehaviors.d.ts +0 -1333
  107. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  108. package/dist/matterbridgeBehaviors.js.map +0 -1
  109. package/dist/matterbridgeDeviceTypes.d.ts +0 -644
  110. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  111. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  112. package/dist/matterbridgeDynamicPlatform.d.ts +0 -40
  113. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  114. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  115. package/dist/matterbridgeEndpoint.d.ts +0 -1144
  116. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  117. package/dist/matterbridgeEndpoint.js.map +0 -1
  118. package/dist/matterbridgeEndpointHelpers.d.ts +0 -3083
  119. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  120. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  121. package/dist/matterbridgePlatform.d.ts +0 -294
  122. package/dist/matterbridgePlatform.d.ts.map +0 -1
  123. package/dist/matterbridgePlatform.js.map +0 -1
  124. package/dist/matterbridgeTypes.d.ts +0 -196
  125. package/dist/matterbridgeTypes.d.ts.map +0 -1
  126. package/dist/matterbridgeTypes.js.map +0 -1
  127. package/dist/pluginManager.d.ts +0 -273
  128. package/dist/pluginManager.d.ts.map +0 -1
  129. package/dist/pluginManager.js.map +0 -1
  130. package/dist/roboticVacuumCleaner.d.ts +0 -102
  131. package/dist/roboticVacuumCleaner.d.ts.map +0 -1
  132. package/dist/roboticVacuumCleaner.js.map +0 -1
  133. package/dist/shelly.d.ts +0 -161
  134. package/dist/shelly.d.ts.map +0 -1
  135. package/dist/shelly.js.map +0 -1
  136. package/dist/storage/export.d.ts +0 -2
  137. package/dist/storage/export.d.ts.map +0 -1
  138. package/dist/storage/export.js.map +0 -1
  139. package/dist/update.d.ts +0 -58
  140. package/dist/update.d.ts.map +0 -1
  141. package/dist/update.js.map +0 -1
  142. package/dist/utils/colorUtils.d.ts +0 -61
  143. package/dist/utils/colorUtils.d.ts.map +0 -1
  144. package/dist/utils/colorUtils.js.map +0 -1
  145. package/dist/utils/commandLine.d.ts +0 -58
  146. package/dist/utils/commandLine.d.ts.map +0 -1
  147. package/dist/utils/commandLine.js.map +0 -1
  148. package/dist/utils/copyDirectory.d.ts +0 -32
  149. package/dist/utils/copyDirectory.d.ts.map +0 -1
  150. package/dist/utils/copyDirectory.js.map +0 -1
  151. package/dist/utils/createDirectory.d.ts +0 -32
  152. package/dist/utils/createDirectory.d.ts.map +0 -1
  153. package/dist/utils/createDirectory.js.map +0 -1
  154. package/dist/utils/createZip.d.ts +0 -38
  155. package/dist/utils/createZip.d.ts.map +0 -1
  156. package/dist/utils/createZip.js.map +0 -1
  157. package/dist/utils/deepCopy.d.ts +0 -31
  158. package/dist/utils/deepCopy.d.ts.map +0 -1
  159. package/dist/utils/deepCopy.js.map +0 -1
  160. package/dist/utils/deepEqual.d.ts +0 -53
  161. package/dist/utils/deepEqual.d.ts.map +0 -1
  162. package/dist/utils/deepEqual.js.map +0 -1
  163. package/dist/utils/export.d.ts +0 -12
  164. package/dist/utils/export.d.ts.map +0 -1
  165. package/dist/utils/export.js.map +0 -1
  166. package/dist/utils/hex.d.ts +0 -48
  167. package/dist/utils/hex.d.ts.map +0 -1
  168. package/dist/utils/hex.js.map +0 -1
  169. package/dist/utils/isvalid.d.ts +0 -102
  170. package/dist/utils/isvalid.d.ts.map +0 -1
  171. package/dist/utils/isvalid.js.map +0 -1
  172. package/dist/utils/network.d.ts +0 -69
  173. package/dist/utils/network.d.ts.map +0 -1
  174. package/dist/utils/network.js.map +0 -1
  175. package/dist/utils/spawn.d.ts +0 -12
  176. package/dist/utils/spawn.d.ts.map +0 -1
  177. package/dist/utils/spawn.js.map +0 -1
  178. package/dist/utils/wait.d.ts +0 -52
  179. package/dist/utils/wait.d.ts.map +0 -1
  180. package/dist/utils/wait.js.map +0 -1
  181. package/dist/waterHeater.d.ts +0 -90
  182. package/dist/waterHeater.d.ts.map +0 -1
  183. package/dist/waterHeater.js.map +0 -1
@@ -1,25 +1,3 @@
1
- /**
2
- * This file contains the color utilities.
3
- *
4
- * @file colorUtils.ts
5
- * @author Luca Liguori
6
- * @date 2023-10-05
7
- * @version 1.3.0
8
- *
9
- * Copyright 2023, 2024, 2025 Luca Liguori.
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
1
  import { assert } from 'node:console';
24
2
  export function hslColorToRgbColor(hue, saturation, luminance) {
25
3
  if (hue === 360) {
@@ -32,7 +10,7 @@ export function hslColorToRgbColor(hue, saturation, luminance) {
32
10
  luminance /= 100;
33
11
  let r, g, b;
34
12
  if (saturation === 0) {
35
- r = g = b = luminance; // achromatic
13
+ r = g = b = luminance;
36
14
  }
37
15
  else {
38
16
  const hue2rgb = (p, q, t) => {
@@ -65,27 +43,21 @@ export function hslColorToRgbColor(hue, saturation, luminance) {
65
43
  b: Math.ceil(b * 255),
66
44
  };
67
45
  }
68
- // Converts from RGB to the XY color (CIE 1931 color space)
69
46
  export function rgbColorToXYColor(rgb) {
70
47
  let r = rgb.r / 255;
71
48
  let g = rgb.g / 255;
72
49
  let b = rgb.b / 255;
73
- // Apply gamma correction
74
50
  r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
75
51
  g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
76
52
  b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
77
- // Scale the values to the D65 illuminant
78
53
  r = r * 100;
79
54
  g = g * 100;
80
55
  b = b * 100;
81
- // Convert RGB to XYZ
82
56
  const X = r * 0.664511 + g * 0.154324 + b * 0.162028;
83
57
  const Y = r * 0.283881 + g * 0.668433 + b * 0.047685;
84
58
  const Z = r * 0.000088 + g * 0.07231 + b * 0.986039;
85
- // Normalization
86
59
  let x = X / (X + Y + Z);
87
60
  let y = Y / (X + Y + Z);
88
- // Round to 4 digits
89
61
  x = Math.round(x * 10000) / 10000;
90
62
  y = Math.round(y * 10000) / 10000;
91
63
  return { x, y };
@@ -95,11 +67,9 @@ export function xyColorToRgbColor(x, y, brightness = 254) {
95
67
  const Y = (brightness / 254).toFixed(2);
96
68
  const X = (Number(Y) / y) * x;
97
69
  const Z = (Number(Y) / y) * z;
98
- // Convert to RGB using Wide RGB D65 conversion
99
70
  let red = X * 1.656492 - Number(Y) * 0.354851 - Z * 0.255038;
100
71
  let green = -X * 0.707196 + Number(Y) * 1.655397 + Z * 0.036152;
101
72
  let blue = X * 0.051713 - Number(Y) * 0.121364 + Z * 1.01153;
102
- // If red, green or blue is larger than 1.0 set it back to the maximum of 1.0
103
73
  if (red > blue && red > green && red > 1.0) {
104
74
  green = green / red;
105
75
  blue = blue / red;
@@ -115,15 +85,12 @@ export function xyColorToRgbColor(x, y, brightness = 254) {
115
85
  green = green / blue;
116
86
  blue = 1.0;
117
87
  }
118
- // Reverse gamma correction
119
88
  red = red <= 0.0031308 ? 12.92 * red : (1.0 + 0.055) * Math.pow(red, 1.0 / 2.4) - 0.055;
120
89
  green = green <= 0.0031308 ? 12.92 * green : (1.0 + 0.055) * Math.pow(green, 1.0 / 2.4) - 0.055;
121
90
  blue = blue <= 0.0031308 ? 12.92 * blue : (1.0 + 0.055) * Math.pow(blue, 1.0 / 2.4) - 0.055;
122
- // Convert normalized decimal to decimal
123
91
  red = Math.round(red * 255);
124
92
  green = Math.round(green * 255);
125
93
  blue = Math.round(blue * 255);
126
- // Normalize
127
94
  if (isNaN(red) || red < 0) {
128
95
  red = 0;
129
96
  }
@@ -144,7 +111,7 @@ export function rgbColorToHslColor(rgb) {
144
111
  let h = 0, s = 0;
145
112
  const l = (max + min) / 2;
146
113
  if (max === min) {
147
- h = s = 0; // achromatic
114
+ h = s = 0;
148
115
  }
149
116
  else {
150
117
  const d = max - min;
@@ -179,10 +146,8 @@ export function kelvinToMired(kelvin) {
179
146
  return Math.round(1000000 / kelvin);
180
147
  }
181
148
  export function kelvinToRGB(kelvin) {
182
- // Clamp the temperature to the range 1000K to 40000K
183
149
  kelvin = Math.max(1000, Math.min(40000, kelvin)) / 100;
184
150
  let r, g, b;
185
- // Calculate red
186
151
  if (kelvin <= 66) {
187
152
  r = 255;
188
153
  }
@@ -191,7 +156,6 @@ export function kelvinToRGB(kelvin) {
191
156
  r = 329.698727446 * Math.pow(r, -0.1332047592);
192
157
  r = Math.max(0, Math.min(255, r));
193
158
  }
194
- // Calculate green
195
159
  if (kelvin <= 66) {
196
160
  g = kelvin;
197
161
  g = 99.4708025861 * Math.log(g) - 161.1195681661;
@@ -202,7 +166,6 @@ export function kelvinToRGB(kelvin) {
202
166
  g = 288.1221695283 * Math.pow(g, -0.0755148492);
203
167
  g = Math.max(0, Math.min(255, g));
204
168
  }
205
- // Calculate blue
206
169
  if (kelvin >= 66) {
207
170
  b = 255;
208
171
  }
@@ -216,169 +179,3 @@ export function kelvinToRGB(kelvin) {
216
179
  }
217
180
  return { r: Math.round(r), g: Math.round(g), b: Math.round(b) };
218
181
  }
219
- /*
220
- export function testColors(): void {
221
- // this table has been checked with different apps and sites and is correct 100%
222
- const colors = [
223
- { 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 } },
224
- { 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 } },
225
- { 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 } },
226
- { 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 } },
227
- { 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 } },
228
- { 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 } },
229
- { 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 } },
230
- { 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 } },
231
- { 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 } },
232
- { 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 } },
233
- { 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 } },
234
- { 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 } },
235
-
236
- { 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 } },
237
- { 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 } },
238
- { 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 } },
239
- { 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 } },
240
- { 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 } },
241
- { 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 } },
242
- { 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 } },
243
- { 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 } },
244
- { 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 } },
245
- { 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 } },
246
- { 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 } },
247
- { 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 } },
248
- ];
249
-
250
- colors.forEach((color) => {
251
- // eslint-disable-next-line no-console
252
- console.log(
253
- `\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} }`,
254
- );
255
-
256
- const rgb = hslColorToRgbColor(color.hsl.h, color.hsl.s, color.hsl.l);
257
- 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`);
258
-
259
- const hsl = rgbColorToHslColor({ r: color.rgb.r, g: color.rgb.g, b: color.rgb.b });
260
- assert(hsl.h === color.hsl.h && hsl.s === color.hsl.s && hsl.l === color.hsl.l, `Color: ${color.name} rgbColorToHslColor conversion error`);
261
-
262
- const xy = rgbColorToXYColor({ r: color.rgb.r, g: color.rgb.g, b: color.rgb.b });
263
- assert(xy.x === color.xy.x && xy.y === color.xy.y, `Color: ${color.name} rgbColorToXYColor conversion error got x ${xy.x} y ${xy.y}`);
264
-
265
- const rgb2 = xyColorToRgbColor(color.xy.x, color.xy.y);
266
- assert(
267
- rgb2.r === color.rgb.r && rgb2.g === color.rgb.g && rgb2.b === color.rgb.b,
268
- `\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}`,
269
- );
270
- });
271
- }
272
- */
273
- /**
274
- * Converts CIE color space to RGB color space
275
- * @param {Number} x
276
- * @param {Number} y
277
- * @param {Number} brightness - Ranges from 1 to 254
278
- * @return {Array} Array that contains the color values for red, green and blue
279
- * From: https://github.com/usolved/cie-rgb-converter/blob/master/cie_rgb_converter.js
280
- */
281
- /*
282
- export function cie_to_rgb(x: number, y: number, brightness = 254): RGB {
283
- // Set to maximum brightness if no custom value was given (Not the slick ECMAScript 6 way for compatibility reasons)
284
-
285
- const z = 1.0 - x - y;
286
- const Y = (brightness / 254).toFixed(2);
287
- const X = (Number(Y) / y) * x;
288
- const Z = (Number(Y) / y) * z;
289
-
290
- // Convert to RGB using Wide RGB D65 conversion
291
- let red = X * 1.656492 - Number(Y) * 0.354851 - Z * 0.255038;
292
- let green = -X * 0.707196 + Number(Y) * 1.655397 + Z * 0.036152;
293
- let blue = X * 0.051713 - Number(Y) * 0.121364 + Z * 1.01153;
294
-
295
- // If red, green or blue is larger than 1.0 set it back to the maximum of 1.0
296
- if (red > blue && red > green && red > 1.0) {
297
- green = green / red;
298
- blue = blue / red;
299
- red = 1.0;
300
- } else if (green > blue && green > red && green > 1.0) {
301
- red = red / green;
302
- blue = blue / green;
303
- green = 1.0;
304
- } else if (blue > red && blue > green && blue > 1.0) {
305
- red = red / blue;
306
- green = green / blue;
307
- blue = 1.0;
308
- }
309
-
310
- // Reverse gamma correction
311
- red = red <= 0.0031308 ? 12.92 * red : (1.0 + 0.055) * Math.pow(red, 1.0 / 2.4) - 0.055;
312
- green = green <= 0.0031308 ? 12.92 * green : (1.0 + 0.055) * Math.pow(green, 1.0 / 2.4) - 0.055;
313
- blue = blue <= 0.0031308 ? 12.92 * blue : (1.0 + 0.055) * Math.pow(blue, 1.0 / 2.4) - 0.055;
314
-
315
- // Convert normalized decimal to decimal
316
- red = Math.round(red * 255);
317
- green = Math.round(green * 255);
318
- blue = Math.round(blue * 255);
319
-
320
- // Normalize
321
- if (isNaN(red) || red < 0) {
322
- red = 0;
323
- }
324
- if (isNaN(green) || green < 0) {
325
- green = 0;
326
- }
327
- if (isNaN(blue) || blue < 0) {
328
- blue = 0;
329
- }
330
-
331
- return { r: red, g: green, b: blue };
332
- }
333
- */
334
- /**
335
- * Converts RGB color space to CIE color space
336
- * @param {Number} red
337
- * @param {Number} green
338
- * @param {Number} blue
339
- * @return {Array} Array that contains the CIE color values for x and y
340
- * From: https://github.com/usolved/cie-rgb-converter/blob/master/cie_rgb_converter.js
341
- */
342
- /*
343
- export function rgb_to_cie(red: number, green: number, blue: number): XY {
344
- // 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
345
- red = red > 0.04045 ? Math.pow((red + 0.055) / (1.0 + 0.055), 2.4) : red / 12.92;
346
- green = green > 0.04045 ? Math.pow((green + 0.055) / (1.0 + 0.055), 2.4) : green / 12.92;
347
- blue = blue > 0.04045 ? Math.pow((blue + 0.055) / (1.0 + 0.055), 2.4) : blue / 12.92;
348
-
349
- // RGB values to XYZ using the Wide RGB D65 conversion formula
350
- const X = red * 0.664511 + green * 0.154324 + blue * 0.162028;
351
- const Y = red * 0.283881 + green * 0.668433 + blue * 0.047685;
352
- const Z = red * 0.000088 + green * 0.07231 + blue * 0.986039;
353
-
354
- // Calculate the xy values from the XYZ values
355
- let x = (X / (X + Y + Z)).toFixed(4);
356
- let y = (Y / (X + Y + Z)).toFixed(4);
357
-
358
- if (isNaN(Number(x))) {
359
- x = '0';
360
- }
361
-
362
- if (isNaN(Number(y))) {
363
- y = '0';
364
- }
365
-
366
- return { x: Number(x), y: Number(y) };
367
- }
368
- */
369
- /*
370
- testColors();
371
- console.log('rgb_to_cie(0, 128, 255)', rgb_to_cie(0, 128, 255));
372
- console.log('cie_to_rgb(0.1401, 0.1284, 254)', cie_to_rgb(0.1401, 0.1284, 254));
373
- console.log('cie_to_rgb(0.1406, 0.1382, 254)', cie_to_rgb(0.1406, 0.1382, 254));
374
- for (let h = 0; h < 360; h++) {
375
- const rgb = hslColorToRgbColor(h, 100, 50);
376
- const xy = rgbColorToXYColor({ r: rgb.r, g: rgb.g, b: rgb.b });
377
- const rgb2 = cie_to_rgb(xy.x, xy.y, 254);
378
- const hsl = rgbColorToHslColor({ r: rgb2.r, g: rgb2.g, b: rgb2.b });
379
- assert(rgb.r === rgb2.r && rgb.g === rgb2.g && rgb.b === rgb2.b, 'Color rgb conversion error');
380
- assert(h === hsl.h, 'Color hsl conversion error');
381
- 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`);
382
- }
383
- */
384
- //# sourceMappingURL=colorUtils.js.map
@@ -1,32 +1,4 @@
1
- /**
2
- * This file contains the parameters functions.
3
- *
4
- * @file parameter.ts
5
- * @author Luca Liguori
6
- * @date 2025-02-16
7
- * @version 1.0.0
8
- *
9
- * Copyright 2025, 2026, 2027 Luca Liguori.
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
1
  import { isValidNumber } from './export.js';
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
2
  export function hasParameter(name) {
31
3
  const commandArguments = process.argv.slice(2);
32
4
  let markerIncluded = commandArguments.includes(`-${name}`);
@@ -34,12 +6,6 @@ export function hasParameter(name) {
34
6
  markerIncluded = commandArguments.includes(`--${name}`);
35
7
  return markerIncluded;
36
8
  }
37
- /**
38
- * Retrieves the value of a command-line parameter as a string.
39
- *
40
- * @param {string} name - The name of the parameter to retrieve.
41
- * @returns {string | undefined} The value of the parameter, or undefined if not found.
42
- */
43
9
  export function getParameter(name) {
44
10
  const commandArguments = process.argv.slice(2);
45
11
  let markerIndex = commandArguments.indexOf(`-${name}`);
@@ -49,12 +15,6 @@ export function getParameter(name) {
49
15
  return undefined;
50
16
  return commandArguments[markerIndex + 1];
51
17
  }
52
- /**
53
- * Retrieves the value of a command-line parameter as an integer.
54
- *
55
- * @param {string} name - The name of the parameter to retrieve.
56
- * @returns {number | undefined} The integer value of the parameter, or undefined if not found or invalid.
57
- */
58
18
  export function getIntParameter(name) {
59
19
  const value = getParameter(name);
60
20
  if (value === undefined)
@@ -64,12 +24,6 @@ export function getIntParameter(name) {
64
24
  return undefined;
65
25
  return intValue;
66
26
  }
67
- /**
68
- * Retrieves the value of a command-line parameter as a number array.
69
- *
70
- * @param {string} name - The name of the parameter to retrieve.
71
- * @returns {number[] | undefined} An array of string values for the parameter, or undefined if not found.
72
- */
73
27
  export function getIntArrayParameter(name) {
74
28
  const commandArguments = process.argv.slice(2);
75
29
  let markerIndex = commandArguments.indexOf(`--${name}`);
@@ -87,12 +41,6 @@ export function getIntArrayParameter(name) {
87
41
  return undefined;
88
42
  return intValues;
89
43
  }
90
- /**
91
- * Retrieves the value of a command-line parameter as a string array.
92
- *
93
- * @param {string} name - The name of the parameter to retrieve.
94
- * @returns {string[] | undefined} An array of string values for the parameter, or undefined if not found.
95
- */
96
44
  export function getStringArrayParameter(name) {
97
45
  const commandArguments = process.argv.slice(2);
98
46
  let markerIndex = commandArguments.indexOf(`--${name}`);
@@ -108,4 +56,3 @@ export function getStringArrayParameter(name) {
108
56
  return undefined;
109
57
  return values;
110
58
  }
111
- //# sourceMappingURL=commandLine.js.map
@@ -1,35 +1,4 @@
1
- /**
2
- * This file contains the copyDirectory function.
3
- *
4
- * @file copyDirectory.ts
5
- * @author Luca Liguori
6
- * @date 2025-02-16
7
- * @version 1.0.1
8
- *
9
- * Copyright 2025, 2026, 2027 Luca Liguori.
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
- // AnsiLogger module
24
1
  import { AnsiLogger } from '../logger/export.js';
25
- /**
26
- * Copies a directory and all its subdirectories and files to a new location.
27
- *
28
- * @param {string} srcDir - The path to the source directory.
29
- * @param {string} destDir - The path to the destination directory.
30
- * @returns {Promise<boolean>} - A promise that resolves when the copy operation is complete or fails for error.
31
- * @throws {Error} - Throws an error if the copy operation fails.
32
- */
33
2
  export async function copyDirectory(srcDir, destDir) {
34
3
  if (srcDir === '') {
35
4
  throw new Error('Source directory must be specified.');
@@ -46,24 +15,20 @@ export async function copyDirectory(srcDir, destDir) {
46
15
  if (srcDir === destDir) {
47
16
  throw new Error('Source and destination directories must be different.');
48
17
  }
49
- const log = new AnsiLogger({ logName: 'Archive', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: "info" /* LogLevel.INFO */ });
18
+ const log = new AnsiLogger({ logName: 'Archive', logTimestampFormat: 4, logLevel: "info" });
50
19
  const fs = await import('node:fs').then((mod) => mod.promises);
51
20
  const path = await import('node:path');
52
21
  log.debug(`copyDirectory: copying directory from ${srcDir} to ${destDir}`);
53
22
  try {
54
- // Create destination directory if it doesn't exist
55
23
  await fs.mkdir(destDir, { recursive: true });
56
- // Read contents of the source directory
57
24
  const entries = await fs.readdir(srcDir, { withFileTypes: true });
58
25
  for (const entry of entries) {
59
26
  const srcPath = path.join(srcDir, entry.name);
60
27
  const destPath = path.join(destDir, entry.name);
61
28
  if (entry.isDirectory()) {
62
- // Recursive call if entry is a directory
63
29
  await copyDirectory(srcPath, destPath);
64
30
  }
65
31
  else if (entry.isFile()) {
66
- // Copy file if entry is a file
67
32
  await fs.copyFile(srcPath, destPath);
68
33
  }
69
34
  }
@@ -74,4 +39,3 @@ export async function copyDirectory(srcDir, destDir) {
74
39
  return false;
75
40
  }
76
41
  }
77
- //# sourceMappingURL=copyDirectory.js.map
@@ -1,34 +1,4 @@
1
- /**
2
- * This file contains the createDirectory function.
3
- *
4
- * @file createDirectory.ts
5
- * @author Luca Liguori
6
- * @date 2025-06-08
7
- * @version 1.0.0
8
- *
9
- * Copyright 2025, 2026, 2027 Luca Liguori.
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
- // Node.js modules
24
1
  import { promises as fs } from 'node:fs';
25
- /**
26
- * Creates a directory at the specified path if it doesn't already exist.
27
- *
28
- * @param {string} path - The path to the directory to create.
29
- * @param {string} name - The name of the directory.
30
- * @returns {Promise<void>} A promise that resolves when the directory has been created or already exists.
31
- */
32
2
  export async function createDirectory(path, name, log) {
33
3
  try {
34
4
  await fs.access(path);
@@ -49,4 +19,3 @@ export async function createDirectory(path, name, log) {
49
19
  }
50
20
  }
51
21
  }
52
- //# sourceMappingURL=createDirectory.js.map
@@ -1,43 +1,6 @@
1
- /**
2
- * This file contains the createZip function.
3
- *
4
- * @file createZip.ts
5
- * @author Luca Liguori
6
- * @date 2025-02-16
7
- * @version 1.0.0
8
- *
9
- * Copyright 2025, 2026, 2027 Luca Liguori.
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
- // AnsiLogger module
24
1
  import { AnsiLogger } from '../logger/export.js';
25
- /**
26
- * Creates a ZIP archive from the specified source pattern or directory and writes it to the specified output path.
27
- *
28
- * @param {string} outputPath - The path where the output ZIP file will be written.
29
- * @param {string[]} sourcePaths - The source pattern or directory to be zipped (use path.join for sourcePath).
30
- * @returns {Promise<number>} - A promise that resolves to the total number of bytes written to the ZIP file.
31
- *
32
- * @remarks
33
- * This function uses the `archiver` library to create a ZIP archive. It sets the compression level to 9 (maximum compression).
34
- * The function ensures that the output file is properly closed after the archiving process is complete.
35
- * It logs the progress and the total number of bytes written to the console.
36
- *
37
- * This function uses the `glob` library to match files based on the source pattern (internally converted in posix).
38
- */
39
2
  export async function createZip(outputPath, ...sourcePaths) {
40
- const log = new AnsiLogger({ logName: 'Archive', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: "info" /* LogLevel.INFO */ });
3
+ const log = new AnsiLogger({ logName: 'Archive', logTimestampFormat: 4, logLevel: "info" });
41
4
  const { default: archiver } = await import('archiver');
42
5
  const { glob } = await import('glob');
43
6
  const { createWriteStream, statSync } = await import('node:fs');
@@ -46,7 +9,7 @@ export async function createZip(outputPath, ...sourcePaths) {
46
9
  return new Promise((resolve, reject) => {
47
10
  const output = createWriteStream(outputPath);
48
11
  const archive = archiver('zip', {
49
- zlib: { level: 9 }, // Set compression level
12
+ zlib: { level: 9 },
50
13
  });
51
14
  output.on('close', () => {
52
15
  log.debug(`archive ${outputPath} closed with ${archive.pointer()} total bytes`);
@@ -73,7 +36,6 @@ export async function createZip(outputPath, ...sourcePaths) {
73
36
  });
74
37
  archive.pipe(output);
75
38
  for (const sourcePath of sourcePaths) {
76
- // Check if the sourcePath is a file or directory
77
39
  let stats;
78
40
  try {
79
41
  stats = statSync(sourcePath);
@@ -101,9 +63,7 @@ export async function createZip(outputPath, ...sourcePaths) {
101
63
  archive.directory(sourcePath, path.basename(sourcePath));
102
64
  }
103
65
  }
104
- // Finalize the archive (i.e., we are done appending files but streams have to finish yet)
105
66
  log.debug(`finalizing archive ${outputPath}...`);
106
67
  archive.finalize().catch(reject);
107
68
  });
108
69
  }
109
- //# sourceMappingURL=createZip.js.map
@@ -1,52 +1,17 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- /**
3
- * This file contains the deepCopy function.
4
- *
5
- * @file deepCopy.ts
6
- * @author Luca Liguori
7
- * @date 2025-02-16
8
- * @version 1.0.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
- * Creates a deep copy of the given value.
26
- *
27
- * @template T - The type of the value being copied.
28
- * @param {T} value - The value to be copied.
29
- * @returns {T} - The deep copy of the value.
30
- */
31
1
  export function deepCopy(value) {
32
2
  if (typeof value !== 'object' || value === null) {
33
- // Primitive value (string, number, boolean, bigint, undefined, symbol) or null
34
3
  return value;
35
4
  }
36
5
  else if (Array.isArray(value)) {
37
- // Array: Recursively copy each element
38
6
  return value.map((item) => deepCopy(item));
39
7
  }
40
8
  else if (value instanceof Date) {
41
- // Date objects
42
9
  return new Date(value.getTime());
43
10
  }
44
11
  else if (value instanceof RegExp) {
45
- // RegExp objects
46
12
  return new RegExp(value.source, value.flags);
47
13
  }
48
14
  else if (value instanceof Map) {
49
- // Maps
50
15
  const mapCopy = new Map();
51
16
  for (const [origKey, origVal] of value.entries()) {
52
17
  const clonedKey = deepCopy(origKey);
@@ -56,7 +21,6 @@ export function deepCopy(value) {
56
21
  return mapCopy;
57
22
  }
58
23
  else if (value instanceof Set) {
59
- // Sets
60
24
  const setCopy = new Set();
61
25
  value.forEach((item) => {
62
26
  setCopy.add(deepCopy(item));
@@ -64,7 +28,6 @@ export function deepCopy(value) {
64
28
  return setCopy;
65
29
  }
66
30
  else {
67
- // Objects: Create a copy with the same prototype as the original
68
31
  const proto = Object.getPrototypeOf(value);
69
32
  const copy = Object.create(proto);
70
33
  for (const key in value) {
@@ -75,4 +38,3 @@ export function deepCopy(value) {
75
38
  return copy;
76
39
  }
77
40
  }
78
- //# sourceMappingURL=deepCopy.js.map