matterbridge 3.1.7 → 3.1.8-dev-20250725-d6e57e3

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 (247) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cli.js +2 -91
  3. package/dist/cliEmitter.js +0 -30
  4. package/dist/clusters/export.js +0 -2
  5. package/dist/defaultConfigSchema.js +0 -24
  6. package/dist/deviceManager.js +1 -94
  7. package/dist/devices/batteryStorage.js +1 -48
  8. package/dist/devices/dishwasher.js +3 -78
  9. package/dist/devices/evse.js +10 -74
  10. package/dist/devices/export.js +0 -2
  11. package/dist/devices/extractorHood.js +0 -42
  12. package/dist/devices/heatPump.js +2 -50
  13. package/dist/devices/laundryDryer.js +6 -83
  14. package/dist/devices/laundryWasher.js +7 -91
  15. package/dist/devices/roboticVacuumCleaner.js +7 -93
  16. package/dist/devices/solarPower.js +0 -38
  17. package/dist/devices/waterHeater.js +2 -82
  18. package/dist/dgram/coap.js +13 -126
  19. package/dist/dgram/dgram.js +2 -113
  20. package/dist/dgram/mb_coap.js +3 -41
  21. package/dist/dgram/mb_mdns.js +13 -51
  22. package/dist/dgram/mdns.js +137 -298
  23. package/dist/dgram/multicast.js +1 -60
  24. package/dist/dgram/unicast.js +0 -54
  25. package/dist/frontend.js +21 -435
  26. package/dist/globalMatterbridge.js +0 -47
  27. package/dist/helpers.js +0 -53
  28. package/dist/index.js +1 -30
  29. package/dist/logger/export.js +0 -1
  30. package/dist/matter/behaviors.js +0 -2
  31. package/dist/matter/clusters.js +0 -2
  32. package/dist/matter/devices.js +0 -2
  33. package/dist/matter/endpoints.js +0 -2
  34. package/dist/matter/export.js +0 -3
  35. package/dist/matter/types.js +0 -3
  36. package/dist/matterbridge.js +55 -811
  37. package/dist/matterbridgeAccessoryPlatform.js +0 -36
  38. package/dist/matterbridgeBehaviors.js +5 -65
  39. package/dist/matterbridgeDeviceTypes.js +15 -579
  40. package/dist/matterbridgeDynamicPlatform.js +0 -36
  41. package/dist/matterbridgeEndpoint.js +54 -1214
  42. package/dist/matterbridgeEndpointHelpers.js +12 -344
  43. package/dist/matterbridgePlatform.js +0 -233
  44. package/dist/matterbridgeTypes.js +0 -25
  45. package/dist/pluginManager.js +3 -249
  46. package/dist/shelly.js +7 -168
  47. package/dist/storage/export.js +0 -1
  48. package/dist/update.js +0 -54
  49. package/dist/utils/colorUtils.js +2 -263
  50. package/dist/utils/commandLine.js +0 -54
  51. package/dist/utils/copyDirectory.js +1 -38
  52. package/dist/utils/createDirectory.js +0 -33
  53. package/dist/utils/createZip.js +2 -47
  54. package/dist/utils/deepCopy.js +0 -39
  55. package/dist/utils/deepEqual.js +1 -72
  56. package/dist/utils/error.js +0 -41
  57. package/dist/utils/export.js +0 -1
  58. package/dist/utils/hex.js +0 -58
  59. package/dist/utils/isvalid.js +0 -101
  60. package/dist/utils/network.js +5 -81
  61. package/dist/utils/spawn.js +0 -40
  62. package/dist/utils/wait.js +9 -62
  63. package/npm-shrinkwrap.json +2 -2
  64. package/package.json +1 -2
  65. package/dist/cli.d.ts +0 -26
  66. package/dist/cli.d.ts.map +0 -1
  67. package/dist/cli.js.map +0 -1
  68. package/dist/cliEmitter.d.ts +0 -34
  69. package/dist/cliEmitter.d.ts.map +0 -1
  70. package/dist/cliEmitter.js.map +0 -1
  71. package/dist/clusters/export.d.ts +0 -2
  72. package/dist/clusters/export.d.ts.map +0 -1
  73. package/dist/clusters/export.js.map +0 -1
  74. package/dist/defaultConfigSchema.d.ts +0 -28
  75. package/dist/defaultConfigSchema.d.ts.map +0 -1
  76. package/dist/defaultConfigSchema.js.map +0 -1
  77. package/dist/deviceManager.d.ts +0 -112
  78. package/dist/deviceManager.d.ts.map +0 -1
  79. package/dist/deviceManager.js.map +0 -1
  80. package/dist/devices/batteryStorage.d.ts +0 -48
  81. package/dist/devices/batteryStorage.d.ts.map +0 -1
  82. package/dist/devices/batteryStorage.js.map +0 -1
  83. package/dist/devices/dishwasher.d.ts +0 -91
  84. package/dist/devices/dishwasher.d.ts.map +0 -1
  85. package/dist/devices/dishwasher.js.map +0 -1
  86. package/dist/devices/evse.d.ts +0 -75
  87. package/dist/devices/evse.d.ts.map +0 -1
  88. package/dist/devices/evse.js.map +0 -1
  89. package/dist/devices/export.d.ts +0 -11
  90. package/dist/devices/export.d.ts.map +0 -1
  91. package/dist/devices/export.js.map +0 -1
  92. package/dist/devices/extractorHood.d.ts +0 -46
  93. package/dist/devices/extractorHood.d.ts.map +0 -1
  94. package/dist/devices/extractorHood.js.map +0 -1
  95. package/dist/devices/heatPump.d.ts +0 -47
  96. package/dist/devices/heatPump.d.ts.map +0 -1
  97. package/dist/devices/heatPump.js.map +0 -1
  98. package/dist/devices/laundryDryer.d.ts +0 -87
  99. package/dist/devices/laundryDryer.d.ts.map +0 -1
  100. package/dist/devices/laundryDryer.js.map +0 -1
  101. package/dist/devices/laundryWasher.d.ts +0 -242
  102. package/dist/devices/laundryWasher.d.ts.map +0 -1
  103. package/dist/devices/laundryWasher.js.map +0 -1
  104. package/dist/devices/roboticVacuumCleaner.d.ts +0 -112
  105. package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
  106. package/dist/devices/roboticVacuumCleaner.js.map +0 -1
  107. package/dist/devices/solarPower.d.ts +0 -40
  108. package/dist/devices/solarPower.d.ts.map +0 -1
  109. package/dist/devices/solarPower.js.map +0 -1
  110. package/dist/devices/waterHeater.d.ts +0 -111
  111. package/dist/devices/waterHeater.d.ts.map +0 -1
  112. package/dist/devices/waterHeater.js.map +0 -1
  113. package/dist/dgram/coap.d.ts +0 -205
  114. package/dist/dgram/coap.d.ts.map +0 -1
  115. package/dist/dgram/coap.js.map +0 -1
  116. package/dist/dgram/dgram.d.ts +0 -140
  117. package/dist/dgram/dgram.d.ts.map +0 -1
  118. package/dist/dgram/dgram.js.map +0 -1
  119. package/dist/dgram/mb_coap.d.ts +0 -24
  120. package/dist/dgram/mb_coap.d.ts.map +0 -1
  121. package/dist/dgram/mb_coap.js.map +0 -1
  122. package/dist/dgram/mb_mdns.d.ts +0 -24
  123. package/dist/dgram/mb_mdns.d.ts.map +0 -1
  124. package/dist/dgram/mb_mdns.js.map +0 -1
  125. package/dist/dgram/mdns.d.ts +0 -288
  126. package/dist/dgram/mdns.d.ts.map +0 -1
  127. package/dist/dgram/mdns.js.map +0 -1
  128. package/dist/dgram/multicast.d.ts +0 -65
  129. package/dist/dgram/multicast.d.ts.map +0 -1
  130. package/dist/dgram/multicast.js.map +0 -1
  131. package/dist/dgram/unicast.d.ts +0 -56
  132. package/dist/dgram/unicast.d.ts.map +0 -1
  133. package/dist/dgram/unicast.js.map +0 -1
  134. package/dist/frontend.d.ts +0 -304
  135. package/dist/frontend.d.ts.map +0 -1
  136. package/dist/frontend.js.map +0 -1
  137. package/dist/globalMatterbridge.d.ts +0 -59
  138. package/dist/globalMatterbridge.d.ts.map +0 -1
  139. package/dist/globalMatterbridge.js.map +0 -1
  140. package/dist/helpers.d.ts +0 -48
  141. package/dist/helpers.d.ts.map +0 -1
  142. package/dist/helpers.js.map +0 -1
  143. package/dist/index.d.ts +0 -33
  144. package/dist/index.d.ts.map +0 -1
  145. package/dist/index.js.map +0 -1
  146. package/dist/logger/export.d.ts +0 -2
  147. package/dist/logger/export.d.ts.map +0 -1
  148. package/dist/logger/export.js.map +0 -1
  149. package/dist/matter/behaviors.d.ts +0 -2
  150. package/dist/matter/behaviors.d.ts.map +0 -1
  151. package/dist/matter/behaviors.js.map +0 -1
  152. package/dist/matter/clusters.d.ts +0 -2
  153. package/dist/matter/clusters.d.ts.map +0 -1
  154. package/dist/matter/clusters.js.map +0 -1
  155. package/dist/matter/devices.d.ts +0 -2
  156. package/dist/matter/devices.d.ts.map +0 -1
  157. package/dist/matter/devices.js.map +0 -1
  158. package/dist/matter/endpoints.d.ts +0 -2
  159. package/dist/matter/endpoints.d.ts.map +0 -1
  160. package/dist/matter/endpoints.js.map +0 -1
  161. package/dist/matter/export.d.ts +0 -5
  162. package/dist/matter/export.d.ts.map +0 -1
  163. package/dist/matter/export.js.map +0 -1
  164. package/dist/matter/types.d.ts +0 -3
  165. package/dist/matter/types.d.ts.map +0 -1
  166. package/dist/matter/types.js.map +0 -1
  167. package/dist/matterbridge.d.ts +0 -463
  168. package/dist/matterbridge.d.ts.map +0 -1
  169. package/dist/matterbridge.js.map +0 -1
  170. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
  171. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  172. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  173. package/dist/matterbridgeBehaviors.d.ts +0 -1351
  174. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  175. package/dist/matterbridgeBehaviors.js.map +0 -1
  176. package/dist/matterbridgeDeviceTypes.d.ts +0 -709
  177. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  178. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  179. package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
  180. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  181. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  182. package/dist/matterbridgeEndpoint.d.ts +0 -1348
  183. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  184. package/dist/matterbridgeEndpoint.js.map +0 -1
  185. package/dist/matterbridgeEndpointHelpers.d.ts +0 -406
  186. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  187. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  188. package/dist/matterbridgePlatform.d.ts +0 -310
  189. package/dist/matterbridgePlatform.d.ts.map +0 -1
  190. package/dist/matterbridgePlatform.js.map +0 -1
  191. package/dist/matterbridgeTypes.d.ts +0 -195
  192. package/dist/matterbridgeTypes.d.ts.map +0 -1
  193. package/dist/matterbridgeTypes.js.map +0 -1
  194. package/dist/pluginManager.d.ts +0 -270
  195. package/dist/pluginManager.d.ts.map +0 -1
  196. package/dist/pluginManager.js.map +0 -1
  197. package/dist/shelly.d.ts +0 -174
  198. package/dist/shelly.d.ts.map +0 -1
  199. package/dist/shelly.js.map +0 -1
  200. package/dist/storage/export.d.ts +0 -2
  201. package/dist/storage/export.d.ts.map +0 -1
  202. package/dist/storage/export.js.map +0 -1
  203. package/dist/update.d.ts +0 -59
  204. package/dist/update.d.ts.map +0 -1
  205. package/dist/update.js.map +0 -1
  206. package/dist/utils/colorUtils.d.ts +0 -117
  207. package/dist/utils/colorUtils.d.ts.map +0 -1
  208. package/dist/utils/colorUtils.js.map +0 -1
  209. package/dist/utils/commandLine.d.ts +0 -59
  210. package/dist/utils/commandLine.d.ts.map +0 -1
  211. package/dist/utils/commandLine.js.map +0 -1
  212. package/dist/utils/copyDirectory.d.ts +0 -33
  213. package/dist/utils/copyDirectory.d.ts.map +0 -1
  214. package/dist/utils/copyDirectory.js.map +0 -1
  215. package/dist/utils/createDirectory.d.ts +0 -34
  216. package/dist/utils/createDirectory.d.ts.map +0 -1
  217. package/dist/utils/createDirectory.js.map +0 -1
  218. package/dist/utils/createZip.d.ts +0 -39
  219. package/dist/utils/createZip.d.ts.map +0 -1
  220. package/dist/utils/createZip.js.map +0 -1
  221. package/dist/utils/deepCopy.d.ts +0 -32
  222. package/dist/utils/deepCopy.d.ts.map +0 -1
  223. package/dist/utils/deepCopy.js.map +0 -1
  224. package/dist/utils/deepEqual.d.ts +0 -54
  225. package/dist/utils/deepEqual.d.ts.map +0 -1
  226. package/dist/utils/deepEqual.js.map +0 -1
  227. package/dist/utils/error.d.ts +0 -44
  228. package/dist/utils/error.d.ts.map +0 -1
  229. package/dist/utils/error.js.map +0 -1
  230. package/dist/utils/export.d.ts +0 -12
  231. package/dist/utils/export.d.ts.map +0 -1
  232. package/dist/utils/export.js.map +0 -1
  233. package/dist/utils/hex.d.ts +0 -49
  234. package/dist/utils/hex.d.ts.map +0 -1
  235. package/dist/utils/hex.js.map +0 -1
  236. package/dist/utils/isvalid.d.ts +0 -103
  237. package/dist/utils/isvalid.d.ts.map +0 -1
  238. package/dist/utils/isvalid.js.map +0 -1
  239. package/dist/utils/network.d.ts +0 -74
  240. package/dist/utils/network.d.ts.map +0 -1
  241. package/dist/utils/network.js.map +0 -1
  242. package/dist/utils/spawn.d.ts +0 -33
  243. package/dist/utils/spawn.d.ts.map +0 -1
  244. package/dist/utils/spawn.js.map +0 -1
  245. package/dist/utils/wait.d.ts +0 -56
  246. package/dist/utils/wait.d.ts.map +0 -1
  247. package/dist/utils/wait.js.map +0 -1
@@ -1,35 +1,4 @@
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
- */
24
1
  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
- */
33
2
  export function hslColorToRgbColor(hue, saturation, luminance) {
34
3
  if (hue === 360) {
35
4
  hue = 0;
@@ -41,7 +10,7 @@ export function hslColorToRgbColor(hue, saturation, luminance) {
41
10
  luminance /= 100;
42
11
  let r, g, b;
43
12
  if (saturation === 0) {
44
- r = g = b = luminance; // achromatic
13
+ r = g = b = luminance;
45
14
  }
46
15
  else {
47
16
  const hue2rgb = (p, q, t) => {
@@ -74,54 +43,33 @@ export function hslColorToRgbColor(hue, saturation, luminance) {
74
43
  b: Math.ceil(b * 255),
75
44
  };
76
45
  }
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
- */
83
46
  export function rgbColorToXYColor(rgb) {
84
47
  let r = rgb.r / 255;
85
48
  let g = rgb.g / 255;
86
49
  let b = rgb.b / 255;
87
- // Apply gamma correction
88
50
  r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
89
51
  g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
90
52
  b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
91
- // Scale the values to the D65 illuminant
92
53
  r = r * 100;
93
54
  g = g * 100;
94
55
  b = b * 100;
95
- // Convert RGB to XYZ
96
56
  const X = r * 0.664511 + g * 0.154324 + b * 0.162028;
97
57
  const Y = r * 0.283881 + g * 0.668433 + b * 0.047685;
98
58
  const Z = r * 0.000088 + g * 0.07231 + b * 0.986039;
99
- // Normalization
100
59
  let x = X / (X + Y + Z);
101
60
  let y = Y / (X + Y + Z);
102
- // Round to 4 digits
103
61
  x = Math.round(x * 10000) / 10000;
104
62
  y = Math.round(y * 10000) / 10000;
105
63
  return { x, y };
106
64
  }
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
- */
115
65
  export function xyColorToRgbColor(x, y, brightness = 254) {
116
66
  const z = 1.0 - x - y;
117
67
  const Y = (brightness / 254).toFixed(2);
118
68
  const X = (Number(Y) / y) * x;
119
69
  const Z = (Number(Y) / y) * z;
120
- // Convert to RGB using Wide RGB D65 conversion
121
70
  let red = X * 1.656492 - Number(Y) * 0.354851 - Z * 0.255038;
122
71
  let green = -X * 0.707196 + Number(Y) * 1.655397 + Z * 0.036152;
123
72
  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
125
73
  if (red > blue && red > green && red > 1.0) {
126
74
  green = green / red;
127
75
  blue = blue / red;
@@ -137,35 +85,23 @@ export function xyColorToRgbColor(x, y, brightness = 254) {
137
85
  green = green / blue;
138
86
  blue = 1.0;
139
87
  }
140
- // Reverse gamma correction
141
88
  red = red <= 0.0031308 ? 12.92 * red : (1.0 + 0.055) * Math.pow(red, 1.0 / 2.4) - 0.055;
142
89
  green = green <= 0.0031308 ? 12.92 * green : (1.0 + 0.055) * Math.pow(green, 1.0 / 2.4) - 0.055;
143
90
  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
145
91
  red = Math.round(red * 255);
146
92
  green = Math.round(green * 255);
147
93
  blue = Math.round(blue * 255);
148
- // Normalize even if this code should never be reached...
149
94
  if (isNaN(red) || red < 0) {
150
- /* istanbul ignore next */
151
95
  red = 0;
152
96
  }
153
97
  if (isNaN(green) || green < 0) {
154
- /* istanbul ignore next */
155
98
  green = 0;
156
99
  }
157
100
  if (isNaN(blue) || blue < 0) {
158
- /* istanbul ignore next */
159
101
  blue = 0;
160
102
  }
161
103
  return { r: Math.round(red), g: Math.round(green), b: Math.round(blue) };
162
104
  }
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
- */
169
105
  export function rgbColorToHslColor(rgb) {
170
106
  const r = rgb.r / 255;
171
107
  const g = rgb.g / 255;
@@ -175,7 +111,7 @@ export function rgbColorToHslColor(rgb) {
175
111
  let h = 0, s = 0;
176
112
  const l = (max + min) / 2;
177
113
  if (max === min) {
178
- h = s = 0; // achromatic
114
+ h = s = 0;
179
115
  }
180
116
  else {
181
117
  const d = max - min;
@@ -199,46 +135,19 @@ export function rgbColorToHslColor(rgb) {
199
135
  l: Math.round(l * 100),
200
136
  };
201
137
  }
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
- */
209
138
  export function xyToHsl(x, y) {
210
139
  const rgb = xyColorToRgbColor(x, y);
211
140
  return rgbColorToHslColor(rgb);
212
141
  }
213
- /**
214
- * Converts mireds to kelvin.
215
- *
216
- * @param {number} mired - The mired value to convert.
217
- * @returns {number} The converted kelvin value.
218
- */
219
142
  export function miredToKelvin(mired) {
220
143
  return Math.round(1000000 / mired);
221
144
  }
222
- /**
223
- * Converts kelvin to mireds.
224
- *
225
- * @param {number} kelvin - The kelvin value to convert.
226
- * @returns {number} The converted mired value.
227
- */
228
145
  export function kelvinToMired(kelvin) {
229
146
  return Math.round(1000000 / kelvin);
230
147
  }
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
- */
237
148
  export function kelvinToRGB(kelvin) {
238
- // Clamp the temperature to the range 1000K to 40000K
239
149
  kelvin = Math.max(1000, Math.min(40000, kelvin)) / 100;
240
150
  let r, g, b;
241
- // Calculate red
242
151
  if (kelvin <= 66) {
243
152
  r = 255;
244
153
  }
@@ -247,7 +156,6 @@ export function kelvinToRGB(kelvin) {
247
156
  r = 329.698727446 * Math.pow(r, -0.1332047592);
248
157
  r = Math.max(0, Math.min(255, r));
249
158
  }
250
- // Calculate green
251
159
  if (kelvin <= 66) {
252
160
  g = kelvin;
253
161
  g = 99.4708025861 * Math.log(g) - 161.1195681661;
@@ -258,7 +166,6 @@ export function kelvinToRGB(kelvin) {
258
166
  g = 288.1221695283 * Math.pow(g, -0.0755148492);
259
167
  g = Math.max(0, Math.min(255, g));
260
168
  }
261
- // Calculate blue
262
169
  if (kelvin >= 66) {
263
170
  b = 255;
264
171
  }
@@ -272,171 +179,3 @@ export function kelvinToRGB(kelvin) {
272
179
  }
273
180
  return { r: Math.round(r), g: Math.round(g), b: Math.round(b) };
274
181
  }
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
- //# sourceMappingURL=colorUtils.js.map
@@ -1,33 +1,4 @@
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
1
  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
- */
31
2
  export function hasParameter(name) {
32
3
  const commandArguments = process.argv.slice(2);
33
4
  let markerIncluded = commandArguments.includes(`-${name}`);
@@ -35,12 +6,6 @@ export function hasParameter(name) {
35
6
  markerIncluded = commandArguments.includes(`--${name}`);
36
7
  return markerIncluded;
37
8
  }
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
- */
44
9
  export function getParameter(name) {
45
10
  const commandArguments = process.argv.slice(2);
46
11
  let markerIndex = commandArguments.indexOf(`-${name}`);
@@ -50,12 +15,6 @@ export function getParameter(name) {
50
15
  return undefined;
51
16
  return commandArguments[markerIndex + 1];
52
17
  }
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
- */
59
18
  export function getIntParameter(name) {
60
19
  const value = getParameter(name);
61
20
  if (value === undefined)
@@ -65,12 +24,6 @@ export function getIntParameter(name) {
65
24
  return undefined;
66
25
  return intValue;
67
26
  }
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
- */
74
27
  export function getIntArrayParameter(name) {
75
28
  const commandArguments = process.argv.slice(2);
76
29
  let markerIndex = commandArguments.indexOf(`--${name}`);
@@ -88,12 +41,6 @@ export function getIntArrayParameter(name) {
88
41
  return undefined;
89
42
  return intValues;
90
43
  }
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
- */
97
44
  export function getStringArrayParameter(name) {
98
45
  const commandArguments = process.argv.slice(2);
99
46
  let markerIndex = commandArguments.indexOf(`--${name}`);
@@ -109,4 +56,3 @@ export function getStringArrayParameter(name) {
109
56
  return undefined;
110
57
  return values;
111
58
  }
112
- //# sourceMappingURL=commandLine.js.map
@@ -1,36 +1,4 @@
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
25
1
  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
- */
34
2
  export async function copyDirectory(srcDir, destDir) {
35
3
  if (srcDir === '') {
36
4
  throw new Error('Source directory must be specified.');
@@ -47,24 +15,20 @@ export async function copyDirectory(srcDir, destDir) {
47
15
  if (srcDir === destDir) {
48
16
  throw new Error('Source and destination directories must be different.');
49
17
  }
50
- 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" });
51
19
  const fs = await import('node:fs').then((mod) => mod.promises);
52
20
  const path = await import('node:path');
53
21
  log.debug(`copyDirectory: copying directory from ${srcDir} to ${destDir}`);
54
22
  try {
55
- // Create destination directory if it doesn't exist
56
23
  await fs.mkdir(destDir, { recursive: true });
57
- // Read contents of the source directory
58
24
  const entries = await fs.readdir(srcDir, { withFileTypes: true });
59
25
  for (const entry of entries) {
60
26
  const srcPath = path.join(srcDir, entry.name);
61
27
  const destPath = path.join(destDir, entry.name);
62
28
  if (entry.isDirectory()) {
63
- // Recursive call if entry is a directory
64
29
  await copyDirectory(srcPath, destPath);
65
30
  }
66
31
  else if (entry.isFile()) {
67
- // Copy file if entry is a file
68
32
  await fs.copyFile(srcPath, destPath);
69
33
  }
70
34
  }
@@ -75,4 +39,3 @@ export async function copyDirectory(srcDir, destDir) {
75
39
  return false;
76
40
  }
77
41
  }
78
- //# sourceMappingURL=copyDirectory.js.map
@@ -1,36 +1,4 @@
1
- /**
2
- * This file contains the createDirectory function.
3
- *
4
- * @file createDirectory.ts
5
- * @author Luca Liguori
6
- * @created 2025-06-08
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
- // Node.js modules
25
1
  import { promises as fs } from 'node:fs';
26
- /**
27
- * Creates a directory at the specified path if it doesn't already exist.
28
- *
29
- * @param {string} path - The path to the directory to create.
30
- * @param {string} name - The name of the directory.
31
- * @param {Logger} log - The logger instance to use for logging messages.
32
- * @returns {Promise<void>} A promise that resolves when the directory has been created or already exists.
33
- */
34
2
  export async function createDirectory(path, name, log) {
35
3
  try {
36
4
  await fs.access(path);
@@ -51,4 +19,3 @@ export async function createDirectory(path, name, log) {
51
19
  }
52
20
  }
53
21
  }
54
- //# sourceMappingURL=createDirectory.js.map
@@ -1,44 +1,6 @@
1
- /**
2
- * This file contains the createZip function.
3
- *
4
- * @file createZip.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
- // AnsiLogger module
25
1
  import { AnsiLogger } from '../logger/export.js';
26
- /**
27
- * Creates a ZIP archive from the specified source pattern or directory and writes it to the specified output path.
28
- *
29
- * @param {string} outputPath - The path where the output ZIP file will be written.
30
- * @param {string[]} sourcePaths - The source pattern or directory to be zipped (use path.join for sourcePath).
31
- * @returns {Promise<number>} - A promise that resolves to the total number of bytes written to the ZIP file.
32
- *
33
- * @remarks
34
- * This function uses the `archiver` library to create a ZIP archive. It sets the compression level to 9 (maximum compression).
35
- * The function ensures that the output file is properly closed after the archiving process is complete.
36
- * It logs the progress and the total number of bytes written to the console.
37
- *
38
- * This function uses the `glob` library to match files based on the source pattern (internally converted in posix).
39
- */
40
2
  export async function createZip(outputPath, ...sourcePaths) {
41
- 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" });
42
4
  const { default: archiver } = await import('archiver');
43
5
  const { glob } = await import('glob');
44
6
  const { createWriteStream, statSync } = await import('node:fs');
@@ -47,22 +9,19 @@ export async function createZip(outputPath, ...sourcePaths) {
47
9
  return new Promise((resolve, reject) => {
48
10
  const output = createWriteStream(outputPath);
49
11
  const archive = archiver('zip', {
50
- zlib: { level: 9 }, // Set compression level
12
+ zlib: { level: 9 },
51
13
  });
52
14
  output.on('close', () => {
53
15
  log.debug(`archive ${outputPath} closed with ${archive.pointer()} total bytes`);
54
16
  resolve(archive.pointer());
55
17
  });
56
- /* istanbul ignore next */
57
18
  output.on('end', () => {
58
19
  log.debug(`archive ${outputPath} data has been drained ${archive.pointer()} total bytes`);
59
20
  });
60
- /* istanbul ignore next */
61
21
  archive.on('error', (error) => {
62
22
  log.error(`archive error: ${error.message}`);
63
23
  reject(error);
64
24
  });
65
- /* istanbul ignore next */
66
25
  archive.on('warning', (error) => {
67
26
  if (error.code === 'ENOENT') {
68
27
  log.warn(`archive warning: ${error.message}`);
@@ -77,7 +36,6 @@ export async function createZip(outputPath, ...sourcePaths) {
77
36
  });
78
37
  archive.pipe(output);
79
38
  for (const sourcePath of sourcePaths) {
80
- // Check if the sourcePath is a file or directory
81
39
  let stats;
82
40
  try {
83
41
  stats = statSync(sourcePath);
@@ -92,7 +50,6 @@ export async function createZip(outputPath, ...sourcePaths) {
92
50
  }
93
51
  }
94
52
  else {
95
- /* istanbul ignore next */
96
53
  log.error(`no files or directory found for pattern ${sourcePath}: ${error}`);
97
54
  }
98
55
  continue;
@@ -106,9 +63,7 @@ export async function createZip(outputPath, ...sourcePaths) {
106
63
  archive.directory(sourcePath, path.basename(sourcePath));
107
64
  }
108
65
  }
109
- // Finalize the archive (i.e., we are done appending files but streams have to finish yet)
110
66
  log.debug(`finalizing archive ${outputPath}...`);
111
67
  archive.finalize().catch(reject);
112
68
  });
113
69
  }
114
- //# sourceMappingURL=createZip.js.map