matterbridge 3.0.7-dev-20250618-fb768ee → 3.0.7

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 (188) hide show
  1. package/CHANGELOG.md +3 -2
  2. package/README-DEV.md +4 -4
  3. package/dist/cli.d.ts +29 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +62 -2
  6. package/dist/cli.js.map +1 -0
  7. package/dist/clusters/export.d.ts +2 -0
  8. package/dist/clusters/export.d.ts.map +1 -0
  9. package/dist/clusters/export.js +2 -0
  10. package/dist/clusters/export.js.map +1 -0
  11. package/dist/defaultConfigSchema.d.ts +27 -0
  12. package/dist/defaultConfigSchema.d.ts.map +1 -0
  13. package/dist/defaultConfigSchema.js +23 -0
  14. package/dist/defaultConfigSchema.js.map +1 -0
  15. package/dist/deviceManager.d.ts +114 -0
  16. package/dist/deviceManager.d.ts.map +1 -0
  17. package/dist/deviceManager.js +94 -1
  18. package/dist/deviceManager.js.map +1 -0
  19. package/dist/devices/export.d.ts +5 -0
  20. package/dist/devices/export.d.ts.map +1 -0
  21. package/dist/devices/export.js +2 -0
  22. package/dist/devices/export.js.map +1 -0
  23. package/dist/evse.d.ts +67 -0
  24. package/dist/evse.d.ts.map +1 -0
  25. package/dist/evse.js +65 -9
  26. package/dist/evse.js.map +1 -0
  27. package/dist/frontend.d.ts +256 -0
  28. package/dist/frontend.d.ts.map +1 -0
  29. package/dist/frontend.js +374 -16
  30. package/dist/frontend.js.map +1 -0
  31. package/dist/globalMatterbridge.d.ts +32 -0
  32. package/dist/globalMatterbridge.d.ts.map +1 -0
  33. package/dist/globalMatterbridge.js +20 -0
  34. package/dist/globalMatterbridge.js.map +1 -0
  35. package/dist/helpers.d.ts +47 -0
  36. package/dist/helpers.d.ts.map +1 -0
  37. package/dist/helpers.js +51 -0
  38. package/dist/helpers.js.map +1 -0
  39. package/dist/index.d.ts +37 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +28 -1
  42. package/dist/index.js.map +1 -0
  43. package/dist/laundryWasher.d.ts +243 -0
  44. package/dist/laundryWasher.d.ts.map +1 -0
  45. package/dist/laundryWasher.js +92 -7
  46. package/dist/laundryWasher.js.map +1 -0
  47. package/dist/logger/export.d.ts +2 -0
  48. package/dist/logger/export.d.ts.map +1 -0
  49. package/dist/logger/export.js +1 -0
  50. package/dist/logger/export.js.map +1 -0
  51. package/dist/matter/behaviors.d.ts +2 -0
  52. package/dist/matter/behaviors.d.ts.map +1 -0
  53. package/dist/matter/behaviors.js +2 -0
  54. package/dist/matter/behaviors.js.map +1 -0
  55. package/dist/matter/clusters.d.ts +2 -0
  56. package/dist/matter/clusters.d.ts.map +1 -0
  57. package/dist/matter/clusters.js +2 -0
  58. package/dist/matter/clusters.js.map +1 -0
  59. package/dist/matter/devices.d.ts +2 -0
  60. package/dist/matter/devices.d.ts.map +1 -0
  61. package/dist/matter/devices.js +2 -0
  62. package/dist/matter/devices.js.map +1 -0
  63. package/dist/matter/endpoints.d.ts +2 -0
  64. package/dist/matter/endpoints.d.ts.map +1 -0
  65. package/dist/matter/endpoints.js +2 -0
  66. package/dist/matter/endpoints.js.map +1 -0
  67. package/dist/matter/export.d.ts +5 -0
  68. package/dist/matter/export.d.ts.map +1 -0
  69. package/dist/matter/export.js +2 -0
  70. package/dist/matter/export.js.map +1 -0
  71. package/dist/matter/types.d.ts +3 -0
  72. package/dist/matter/types.d.ts.map +1 -0
  73. package/dist/matter/types.js +2 -0
  74. package/dist/matter/types.js.map +1 -0
  75. package/dist/matterbridge.d.ts +445 -0
  76. package/dist/matterbridge.d.ts.map +1 -0
  77. package/dist/matterbridge.js +748 -46
  78. package/dist/matterbridge.js.map +1 -0
  79. package/dist/matterbridgeAccessoryPlatform.d.ts +40 -0
  80. package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
  81. package/dist/matterbridgeAccessoryPlatform.js +34 -0
  82. package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
  83. package/dist/matterbridgeBehaviors.d.ts +1333 -0
  84. package/dist/matterbridgeBehaviors.d.ts.map +1 -0
  85. package/dist/matterbridgeBehaviors.js +54 -1
  86. package/dist/matterbridgeBehaviors.js.map +1 -0
  87. package/dist/matterbridgeDeviceTypes.d.ts +644 -0
  88. package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
  89. package/dist/matterbridgeDeviceTypes.js +578 -15
  90. package/dist/matterbridgeDeviceTypes.js.map +1 -0
  91. package/dist/matterbridgeDynamicPlatform.d.ts +40 -0
  92. package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
  93. package/dist/matterbridgeDynamicPlatform.js +34 -0
  94. package/dist/matterbridgeDynamicPlatform.js.map +1 -0
  95. package/dist/matterbridgeEndpoint.d.ts +1145 -0
  96. package/dist/matterbridgeEndpoint.d.ts.map +1 -0
  97. package/dist/matterbridgeEndpoint.js +995 -40
  98. package/dist/matterbridgeEndpoint.js.map +1 -0
  99. package/dist/matterbridgeEndpointHelpers.d.ts +3083 -0
  100. package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
  101. package/dist/matterbridgeEndpointHelpers.js +204 -10
  102. package/dist/matterbridgeEndpointHelpers.js.map +1 -0
  103. package/dist/matterbridgePlatform.d.ts +290 -0
  104. package/dist/matterbridgePlatform.d.ts.map +1 -0
  105. package/dist/matterbridgePlatform.js +221 -6
  106. package/dist/matterbridgePlatform.js.map +1 -0
  107. package/dist/matterbridgeTypes.d.ts +196 -0
  108. package/dist/matterbridgeTypes.d.ts.map +1 -0
  109. package/dist/matterbridgeTypes.js +24 -0
  110. package/dist/matterbridgeTypes.js.map +1 -0
  111. package/dist/pluginManager.d.ts +273 -0
  112. package/dist/pluginManager.d.ts.map +1 -0
  113. package/dist/pluginManager.js +269 -3
  114. package/dist/pluginManager.js.map +1 -0
  115. package/dist/roboticVacuumCleaner.d.ts +102 -0
  116. package/dist/roboticVacuumCleaner.d.ts.map +1 -0
  117. package/dist/roboticVacuumCleaner.js +81 -6
  118. package/dist/roboticVacuumCleaner.js.map +1 -0
  119. package/dist/shelly.d.ts +161 -0
  120. package/dist/shelly.d.ts.map +1 -0
  121. package/dist/shelly.js +155 -7
  122. package/dist/shelly.js.map +1 -0
  123. package/dist/storage/export.d.ts +2 -0
  124. package/dist/storage/export.d.ts.map +1 -0
  125. package/dist/storage/export.js +1 -0
  126. package/dist/storage/export.js.map +1 -0
  127. package/dist/update.d.ts +58 -0
  128. package/dist/update.d.ts.map +1 -0
  129. package/dist/update.js +53 -0
  130. package/dist/update.js.map +1 -0
  131. package/dist/utils/colorUtils.d.ts +61 -0
  132. package/dist/utils/colorUtils.d.ts.map +1 -0
  133. package/dist/utils/colorUtils.js +205 -2
  134. package/dist/utils/colorUtils.js.map +1 -0
  135. package/dist/utils/commandLine.d.ts +58 -0
  136. package/dist/utils/commandLine.d.ts.map +1 -0
  137. package/dist/utils/commandLine.js +53 -0
  138. package/dist/utils/commandLine.js.map +1 -0
  139. package/dist/utils/copyDirectory.d.ts +32 -0
  140. package/dist/utils/copyDirectory.d.ts.map +1 -0
  141. package/dist/utils/copyDirectory.js +37 -1
  142. package/dist/utils/copyDirectory.js.map +1 -0
  143. package/dist/utils/createDirectory.d.ts +32 -0
  144. package/dist/utils/createDirectory.d.ts.map +1 -0
  145. package/dist/utils/createDirectory.js +31 -0
  146. package/dist/utils/createDirectory.js.map +1 -0
  147. package/dist/utils/createZip.d.ts +38 -0
  148. package/dist/utils/createZip.d.ts.map +1 -0
  149. package/dist/utils/createZip.js +42 -2
  150. package/dist/utils/createZip.js.map +1 -0
  151. package/dist/utils/deepCopy.d.ts +31 -0
  152. package/dist/utils/deepCopy.d.ts.map +1 -0
  153. package/dist/utils/deepCopy.js +38 -0
  154. package/dist/utils/deepCopy.js.map +1 -0
  155. package/dist/utils/deepEqual.d.ts +53 -0
  156. package/dist/utils/deepEqual.d.ts.map +1 -0
  157. package/dist/utils/deepEqual.js +71 -1
  158. package/dist/utils/deepEqual.js.map +1 -0
  159. package/dist/utils/export.d.ts +12 -0
  160. package/dist/utils/export.d.ts.map +1 -0
  161. package/dist/utils/export.js +1 -0
  162. package/dist/utils/export.js.map +1 -0
  163. package/dist/utils/hex.d.ts +48 -0
  164. package/dist/utils/hex.d.ts.map +1 -0
  165. package/dist/utils/hex.js +57 -0
  166. package/dist/utils/hex.js.map +1 -0
  167. package/dist/utils/isvalid.d.ts +102 -0
  168. package/dist/utils/isvalid.d.ts.map +1 -0
  169. package/dist/utils/isvalid.js +100 -0
  170. package/dist/utils/isvalid.js.map +1 -0
  171. package/dist/utils/network.d.ts +69 -0
  172. package/dist/utils/network.d.ts.map +1 -0
  173. package/dist/utils/network.js +76 -5
  174. package/dist/utils/network.js.map +1 -0
  175. package/dist/utils/spawn.d.ts +12 -0
  176. package/dist/utils/spawn.d.ts.map +1 -0
  177. package/dist/utils/spawn.js +16 -0
  178. package/dist/utils/spawn.js.map +1 -0
  179. package/dist/utils/wait.d.ts +52 -0
  180. package/dist/utils/wait.d.ts.map +1 -0
  181. package/dist/utils/wait.js +58 -9
  182. package/dist/utils/wait.js.map +1 -0
  183. package/dist/waterHeater.d.ts +90 -0
  184. package/dist/waterHeater.d.ts.map +1 -0
  185. package/dist/waterHeater.js +62 -2
  186. package/dist/waterHeater.js.map +1 -0
  187. package/npm-shrinkwrap.json +2 -2
  188. package/package.json +2 -1
@@ -1,3 +1,25 @@
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
+ */
1
23
  import { assert } from 'node:console';
2
24
  export function hslColorToRgbColor(hue, saturation, luminance) {
3
25
  if (hue === 360) {
@@ -10,7 +32,7 @@ export function hslColorToRgbColor(hue, saturation, luminance) {
10
32
  luminance /= 100;
11
33
  let r, g, b;
12
34
  if (saturation === 0) {
13
- r = g = b = luminance;
35
+ r = g = b = luminance; // achromatic
14
36
  }
15
37
  else {
16
38
  const hue2rgb = (p, q, t) => {
@@ -43,21 +65,27 @@ export function hslColorToRgbColor(hue, saturation, luminance) {
43
65
  b: Math.ceil(b * 255),
44
66
  };
45
67
  }
68
+ // Converts from RGB to the XY color (CIE 1931 color space)
46
69
  export function rgbColorToXYColor(rgb) {
47
70
  let r = rgb.r / 255;
48
71
  let g = rgb.g / 255;
49
72
  let b = rgb.b / 255;
73
+ // Apply gamma correction
50
74
  r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
51
75
  g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
52
76
  b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
77
+ // Scale the values to the D65 illuminant
53
78
  r = r * 100;
54
79
  g = g * 100;
55
80
  b = b * 100;
81
+ // Convert RGB to XYZ
56
82
  const X = r * 0.664511 + g * 0.154324 + b * 0.162028;
57
83
  const Y = r * 0.283881 + g * 0.668433 + b * 0.047685;
58
84
  const Z = r * 0.000088 + g * 0.07231 + b * 0.986039;
85
+ // Normalization
59
86
  let x = X / (X + Y + Z);
60
87
  let y = Y / (X + Y + Z);
88
+ // Round to 4 digits
61
89
  x = Math.round(x * 10000) / 10000;
62
90
  y = Math.round(y * 10000) / 10000;
63
91
  return { x, y };
@@ -67,9 +95,11 @@ export function xyColorToRgbColor(x, y, brightness = 254) {
67
95
  const Y = (brightness / 254).toFixed(2);
68
96
  const X = (Number(Y) / y) * x;
69
97
  const Z = (Number(Y) / y) * z;
98
+ // Convert to RGB using Wide RGB D65 conversion
70
99
  let red = X * 1.656492 - Number(Y) * 0.354851 - Z * 0.255038;
71
100
  let green = -X * 0.707196 + Number(Y) * 1.655397 + Z * 0.036152;
72
101
  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
73
103
  if (red > blue && red > green && red > 1.0) {
74
104
  green = green / red;
75
105
  blue = blue / red;
@@ -85,12 +115,15 @@ export function xyColorToRgbColor(x, y, brightness = 254) {
85
115
  green = green / blue;
86
116
  blue = 1.0;
87
117
  }
118
+ // Reverse gamma correction
88
119
  red = red <= 0.0031308 ? 12.92 * red : (1.0 + 0.055) * Math.pow(red, 1.0 / 2.4) - 0.055;
89
120
  green = green <= 0.0031308 ? 12.92 * green : (1.0 + 0.055) * Math.pow(green, 1.0 / 2.4) - 0.055;
90
121
  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
91
123
  red = Math.round(red * 255);
92
124
  green = Math.round(green * 255);
93
125
  blue = Math.round(blue * 255);
126
+ // Normalize
94
127
  if (isNaN(red) || red < 0) {
95
128
  red = 0;
96
129
  }
@@ -111,7 +144,7 @@ export function rgbColorToHslColor(rgb) {
111
144
  let h = 0, s = 0;
112
145
  const l = (max + min) / 2;
113
146
  if (max === min) {
114
- h = s = 0;
147
+ h = s = 0; // achromatic
115
148
  }
116
149
  else {
117
150
  const d = max - min;
@@ -146,8 +179,10 @@ export function kelvinToMired(kelvin) {
146
179
  return Math.round(1000000 / kelvin);
147
180
  }
148
181
  export function kelvinToRGB(kelvin) {
182
+ // Clamp the temperature to the range 1000K to 40000K
149
183
  kelvin = Math.max(1000, Math.min(40000, kelvin)) / 100;
150
184
  let r, g, b;
185
+ // Calculate red
151
186
  if (kelvin <= 66) {
152
187
  r = 255;
153
188
  }
@@ -156,6 +191,7 @@ export function kelvinToRGB(kelvin) {
156
191
  r = 329.698727446 * Math.pow(r, -0.1332047592);
157
192
  r = Math.max(0, Math.min(255, r));
158
193
  }
194
+ // Calculate green
159
195
  if (kelvin <= 66) {
160
196
  g = kelvin;
161
197
  g = 99.4708025861 * Math.log(g) - 161.1195681661;
@@ -166,6 +202,7 @@ export function kelvinToRGB(kelvin) {
166
202
  g = 288.1221695283 * Math.pow(g, -0.0755148492);
167
203
  g = Math.max(0, Math.min(255, g));
168
204
  }
205
+ // Calculate blue
169
206
  if (kelvin >= 66) {
170
207
  b = 255;
171
208
  }
@@ -179,3 +216,169 @@ export function kelvinToRGB(kelvin) {
179
216
  }
180
217
  return { r: Math.round(r), g: Math.round(g), b: Math.round(b) };
181
218
  }
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorUtils.js","sourceRoot":"","sources":["../../src/utils/colorUtils.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EAAE,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,iBAAiB;IACjB,IAAI,MAAM,IAAI,EAAE,EAAE,CAAC;QACjB,CAAC,GAAG,GAAG,CAAC;IACV,CAAC;SAAM,IAAI,MAAM,IAAI,EAAE,EAAE,CAAC;QACxB,CAAC,GAAG,CAAC,CAAC;IACR,CAAC;SAAM,CAAC;QACN,CAAC,GAAG,MAAM,GAAG,EAAE,CAAC;QAChB,CAAC,GAAG,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC;QAClD,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAClE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqDE;AACF;;;;;;;GAOG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoDE;AACF;;;;;;;GAOG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BE;AACF;;;;;;;;;;;;;;EAcE"}
@@ -0,0 +1,58 @@
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
+ /**
24
+ * Checks if a command-line parameter is present.
25
+ *
26
+ * @param {string} name - The name of the parameter to check.
27
+ * @returns {boolean} True if the parameter is present, otherwise false.
28
+ */
29
+ export declare function hasParameter(name: string): boolean;
30
+ /**
31
+ * Retrieves the value of a command-line parameter as a string.
32
+ *
33
+ * @param {string} name - The name of the parameter to retrieve.
34
+ * @returns {string | undefined} The value of the parameter, or undefined if not found.
35
+ */
36
+ export declare function getParameter(name: string): string | undefined;
37
+ /**
38
+ * Retrieves the value of a command-line parameter as an integer.
39
+ *
40
+ * @param {string} name - The name of the parameter to retrieve.
41
+ * @returns {number | undefined} The integer value of the parameter, or undefined if not found or invalid.
42
+ */
43
+ export declare function getIntParameter(name: string): number | undefined;
44
+ /**
45
+ * Retrieves the value of a command-line parameter as a number array.
46
+ *
47
+ * @param {string} name - The name of the parameter to retrieve.
48
+ * @returns {number[] | undefined} An array of string values for the parameter, or undefined if not found.
49
+ */
50
+ export declare function getIntArrayParameter(name: string): number[] | undefined;
51
+ /**
52
+ * Retrieves the value of a command-line parameter as a string array.
53
+ *
54
+ * @param {string} name - The name of the parameter to retrieve.
55
+ * @returns {string[] | undefined} An array of string values for the parameter, or undefined if not found.
56
+ */
57
+ export declare function getStringArrayParameter(name: string): string[] | undefined;
58
+ //# sourceMappingURL=commandLine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandLine.d.ts","sourceRoot":"","sources":["../../src/utils/commandLine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;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,32 @@
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
+ */
1
23
  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
+ */
2
30
  export function hasParameter(name) {
3
31
  const commandArguments = process.argv.slice(2);
4
32
  let markerIncluded = commandArguments.includes(`-${name}`);
@@ -6,6 +34,12 @@ export function hasParameter(name) {
6
34
  markerIncluded = commandArguments.includes(`--${name}`);
7
35
  return markerIncluded;
8
36
  }
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
+ */
9
43
  export function getParameter(name) {
10
44
  const commandArguments = process.argv.slice(2);
11
45
  let markerIndex = commandArguments.indexOf(`-${name}`);
@@ -15,6 +49,12 @@ export function getParameter(name) {
15
49
  return undefined;
16
50
  return commandArguments[markerIndex + 1];
17
51
  }
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
+ */
18
58
  export function getIntParameter(name) {
19
59
  const value = getParameter(name);
20
60
  if (value === undefined)
@@ -24,6 +64,12 @@ export function getIntParameter(name) {
24
64
  return undefined;
25
65
  return intValue;
26
66
  }
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
+ */
27
73
  export function getIntArrayParameter(name) {
28
74
  const commandArguments = process.argv.slice(2);
29
75
  let markerIndex = commandArguments.indexOf(`--${name}`);
@@ -41,6 +87,12 @@ export function getIntArrayParameter(name) {
41
87
  return undefined;
42
88
  return intValues;
43
89
  }
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
+ */
44
96
  export function getStringArrayParameter(name) {
45
97
  const commandArguments = process.argv.slice(2);
46
98
  let markerIndex = commandArguments.indexOf(`--${name}`);
@@ -56,3 +108,4 @@ export function getStringArrayParameter(name) {
56
108
  return undefined;
57
109
  return values;
58
110
  }
111
+ //# sourceMappingURL=commandLine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandLine.js","sourceRoot":"","sources":["../../src/utils/commandLine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa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;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,32 @@
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
+ /**
24
+ * Copies a directory and all its subdirectories and files to a new location.
25
+ *
26
+ * @param {string} srcDir - The path to the source directory.
27
+ * @param {string} destDir - The path to the destination directory.
28
+ * @returns {Promise<boolean>} - A promise that resolves when the copy operation is complete or fails for error.
29
+ * @throws {Error} - Throws an error if the copy operation fails.
30
+ */
31
+ export declare function copyDirectory(srcDir: string, destDir: string): Promise<boolean>;
32
+ //# sourceMappingURL=copyDirectory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyDirectory.d.ts","sourceRoot":"","sources":["../../src/utils/copyDirectory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA8CrF"}
@@ -1,4 +1,35 @@
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
1
24
  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
+ */
2
33
  export async function copyDirectory(srcDir, destDir) {
3
34
  if (srcDir === '') {
4
35
  throw new Error('Source directory must be specified.');
@@ -15,20 +46,24 @@ export async function copyDirectory(srcDir, destDir) {
15
46
  if (srcDir === destDir) {
16
47
  throw new Error('Source and destination directories must be different.');
17
48
  }
18
- const log = new AnsiLogger({ logName: 'Archive', logTimestampFormat: 4, logLevel: "info" });
49
+ const log = new AnsiLogger({ logName: 'Archive', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: "info" /* LogLevel.INFO */ });
19
50
  const fs = await import('node:fs').then((mod) => mod.promises);
20
51
  const path = await import('node:path');
21
52
  log.debug(`copyDirectory: copying directory from ${srcDir} to ${destDir}`);
22
53
  try {
54
+ // Create destination directory if it doesn't exist
23
55
  await fs.mkdir(destDir, { recursive: true });
56
+ // Read contents of the source directory
24
57
  const entries = await fs.readdir(srcDir, { withFileTypes: true });
25
58
  for (const entry of entries) {
26
59
  const srcPath = path.join(srcDir, entry.name);
27
60
  const destPath = path.join(destDir, entry.name);
28
61
  if (entry.isDirectory()) {
62
+ // Recursive call if entry is a directory
29
63
  await copyDirectory(srcPath, destPath);
30
64
  }
31
65
  else if (entry.isFile()) {
66
+ // Copy file if entry is a file
32
67
  await fs.copyFile(srcPath, destPath);
33
68
  }
34
69
  }
@@ -39,3 +74,4 @@ export async function copyDirectory(srcDir, destDir) {
39
74
  return false;
40
75
  }
41
76
  }
77
+ //# sourceMappingURL=copyDirectory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyDirectory.js","sourceRoot":"","sources":["../../src/utils/copyDirectory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;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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C/B,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,KAAK,CAAC,oCAAoC,MAAM,OAAO,OAAO,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;QACzH,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,32 @@
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
+ import { Logger } from '../logger/export.js';
24
+ /**
25
+ * Creates a directory at the specified path if it doesn't already exist.
26
+ *
27
+ * @param {string} path - The path to the directory to create.
28
+ * @param {string} name - The name of the directory.
29
+ * @returns {Promise<void>} A promise that resolves when the directory has been created or already exists.
30
+ */
31
+ export declare function createDirectory(path: string, name: string, log: Logger): Promise<void>;
32
+ //# sourceMappingURL=createDirectory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDirectory.d.ts","sourceRoot":"","sources":["../../src/utils/createDirectory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAK7C;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB5F"}
@@ -1,4 +1,34 @@
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
1
24
  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
+ */
2
32
  export async function createDirectory(path, name, log) {
3
33
  try {
4
34
  await fs.access(path);
@@ -19,3 +49,4 @@ export async function createDirectory(path, name, log) {
19
49
  }
20
50
  }
21
51
  }
52
+ //# sourceMappingURL=createDirectory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDirectory.js","sourceRoot":"","sources":["../../src/utils/createDirectory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,kBAAkB;AAClB,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAY,EAAE,IAAY,EAAE,GAAW;IAC3E,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtB,GAAG,CAAC,KAAK,CAAC,aAAa,IAAI,4BAA4B,IAAI,EAAE,CAAC,CAAC;IACjE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrD,IAAI,CAAC;gBACH,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC1C,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,KAAK,IAAI,EAAE,CAAC,CAAC;YACvC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,GAAG,CAAC,KAAK,CAAC,sBAAsB,IAAI,SAAS,IAAI,KAAK,GAAG,EAAE,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,KAAK,CAAC,uBAAuB,IAAI,SAAS,IAAI,KAAK,GAAG,EAAE,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;AACH,CAAC"}