matterbridge 3.4.1 → 3.4.2-dev-20251202-c41a119

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 (326) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/broadcastServer.js +0 -112
  3. package/dist/broadcastServerTypes.js +0 -24
  4. package/dist/cli.js +1 -97
  5. package/dist/cliEmitter.js +0 -37
  6. package/dist/cliHistory.js +0 -38
  7. package/dist/clusters/export.js +0 -2
  8. package/dist/deviceManager.js +1 -113
  9. package/dist/devices/airConditioner.js +0 -57
  10. package/dist/devices/batteryStorage.js +1 -48
  11. package/dist/devices/cooktop.js +0 -56
  12. package/dist/devices/dishwasher.js +0 -57
  13. package/dist/devices/evse.js +10 -74
  14. package/dist/devices/export.js +0 -5
  15. package/dist/devices/extractorHood.js +0 -43
  16. package/dist/devices/heatPump.js +2 -50
  17. package/dist/devices/laundryDryer.js +3 -62
  18. package/dist/devices/laundryWasher.js +4 -70
  19. package/dist/devices/microwaveOven.js +5 -88
  20. package/dist/devices/oven.js +0 -85
  21. package/dist/devices/refrigerator.js +0 -102
  22. package/dist/devices/roboticVacuumCleaner.js +9 -100
  23. package/dist/devices/solarPower.js +0 -38
  24. package/dist/devices/speaker.js +0 -84
  25. package/dist/devices/temperatureControl.js +3 -24
  26. package/dist/devices/waterHeater.js +2 -82
  27. package/dist/dgram/coap.js +13 -126
  28. package/dist/dgram/dgram.js +2 -114
  29. package/dist/dgram/mb_coap.js +3 -41
  30. package/dist/dgram/mb_mdns.js +15 -80
  31. package/dist/dgram/mdns.js +137 -299
  32. package/dist/dgram/multicast.js +1 -62
  33. package/dist/dgram/unicast.js +0 -54
  34. package/dist/frontend.js +35 -455
  35. package/dist/frontendTypes.js +0 -45
  36. package/dist/helpers.js +0 -53
  37. package/dist/index.js +0 -25
  38. package/dist/jestutils/export.js +0 -1
  39. package/dist/jestutils/jestHelpers.js +13 -368
  40. package/dist/logger/export.js +0 -1
  41. package/dist/matter/behaviors.js +0 -2
  42. package/dist/matter/clusters.js +0 -2
  43. package/dist/matter/devices.js +0 -2
  44. package/dist/matter/endpoints.js +0 -2
  45. package/dist/matter/export.js +0 -3
  46. package/dist/matter/types.js +0 -3
  47. package/dist/matterNode.js +8 -369
  48. package/dist/matterbridge.js +46 -807
  49. package/dist/matterbridgeAccessoryPlatform.js +0 -38
  50. package/dist/matterbridgeBehaviors.js +5 -68
  51. package/dist/matterbridgeDeviceTypes.js +14 -635
  52. package/dist/matterbridgeDynamicPlatform.js +0 -38
  53. package/dist/matterbridgeEndpoint.js +53 -1444
  54. package/dist/matterbridgeEndpointHelpers.js +20 -483
  55. package/dist/matterbridgeEndpointTypes.js +0 -25
  56. package/dist/matterbridgePlatform.js +1 -450
  57. package/dist/matterbridgeTypes.js +0 -26
  58. package/dist/pluginManager.js +5 -341
  59. package/dist/shelly.js +7 -178
  60. package/dist/storage/export.js +0 -1
  61. package/dist/update.js +1 -93
  62. package/dist/utils/colorUtils.js +2 -97
  63. package/dist/utils/commandLine.js +0 -60
  64. package/dist/utils/copyDirectory.js +0 -37
  65. package/dist/utils/createDirectory.js +0 -33
  66. package/dist/utils/createZip.js +2 -47
  67. package/dist/utils/deepCopy.js +0 -39
  68. package/dist/utils/deepEqual.js +1 -72
  69. package/dist/utils/error.js +0 -42
  70. package/dist/utils/export.js +0 -1
  71. package/dist/utils/format.js +0 -49
  72. package/dist/utils/hex.js +0 -124
  73. package/dist/utils/inspector.js +1 -69
  74. package/dist/utils/isvalid.js +0 -101
  75. package/dist/utils/network.js +5 -96
  76. package/dist/utils/spawn.js +1 -71
  77. package/dist/utils/tracker.js +1 -64
  78. package/dist/utils/wait.js +8 -60
  79. package/dist/workerGlobalPrefix.js +5 -37
  80. package/dist/workerTypes.js +0 -24
  81. package/dist/workers.js +4 -68
  82. package/frontend/build/assets/index.js +4 -4
  83. package/frontend/build/assets/vendor_mui.js +1 -1
  84. package/frontend/package.json +1 -1
  85. package/npm-shrinkwrap.json +14 -10
  86. package/package.json +1 -2
  87. package/dist/broadcastServer.d.ts +0 -136
  88. package/dist/broadcastServer.d.ts.map +0 -1
  89. package/dist/broadcastServer.js.map +0 -1
  90. package/dist/broadcastServerTypes.d.ts +0 -841
  91. package/dist/broadcastServerTypes.d.ts.map +0 -1
  92. package/dist/broadcastServerTypes.js.map +0 -1
  93. package/dist/cli.d.ts +0 -30
  94. package/dist/cli.d.ts.map +0 -1
  95. package/dist/cli.js.map +0 -1
  96. package/dist/cliEmitter.d.ts +0 -50
  97. package/dist/cliEmitter.d.ts.map +0 -1
  98. package/dist/cliEmitter.js.map +0 -1
  99. package/dist/cliHistory.d.ts +0 -48
  100. package/dist/cliHistory.d.ts.map +0 -1
  101. package/dist/cliHistory.js.map +0 -1
  102. package/dist/clusters/export.d.ts +0 -2
  103. package/dist/clusters/export.d.ts.map +0 -1
  104. package/dist/clusters/export.js.map +0 -1
  105. package/dist/deviceManager.d.ts +0 -135
  106. package/dist/deviceManager.d.ts.map +0 -1
  107. package/dist/deviceManager.js.map +0 -1
  108. package/dist/devices/airConditioner.d.ts +0 -98
  109. package/dist/devices/airConditioner.d.ts.map +0 -1
  110. package/dist/devices/airConditioner.js.map +0 -1
  111. package/dist/devices/batteryStorage.d.ts +0 -48
  112. package/dist/devices/batteryStorage.d.ts.map +0 -1
  113. package/dist/devices/batteryStorage.js.map +0 -1
  114. package/dist/devices/cooktop.d.ts +0 -61
  115. package/dist/devices/cooktop.d.ts.map +0 -1
  116. package/dist/devices/cooktop.js.map +0 -1
  117. package/dist/devices/dishwasher.d.ts +0 -71
  118. package/dist/devices/dishwasher.d.ts.map +0 -1
  119. package/dist/devices/dishwasher.js.map +0 -1
  120. package/dist/devices/evse.d.ts +0 -76
  121. package/dist/devices/evse.d.ts.map +0 -1
  122. package/dist/devices/evse.js.map +0 -1
  123. package/dist/devices/export.d.ts +0 -17
  124. package/dist/devices/export.d.ts.map +0 -1
  125. package/dist/devices/export.js.map +0 -1
  126. package/dist/devices/extractorHood.d.ts +0 -46
  127. package/dist/devices/extractorHood.d.ts.map +0 -1
  128. package/dist/devices/extractorHood.js.map +0 -1
  129. package/dist/devices/heatPump.d.ts +0 -47
  130. package/dist/devices/heatPump.d.ts.map +0 -1
  131. package/dist/devices/heatPump.js.map +0 -1
  132. package/dist/devices/laundryDryer.d.ts +0 -67
  133. package/dist/devices/laundryDryer.d.ts.map +0 -1
  134. package/dist/devices/laundryDryer.js.map +0 -1
  135. package/dist/devices/laundryWasher.d.ts +0 -81
  136. package/dist/devices/laundryWasher.d.ts.map +0 -1
  137. package/dist/devices/laundryWasher.js.map +0 -1
  138. package/dist/devices/microwaveOven.d.ts +0 -168
  139. package/dist/devices/microwaveOven.d.ts.map +0 -1
  140. package/dist/devices/microwaveOven.js.map +0 -1
  141. package/dist/devices/oven.d.ts +0 -105
  142. package/dist/devices/oven.d.ts.map +0 -1
  143. package/dist/devices/oven.js.map +0 -1
  144. package/dist/devices/refrigerator.d.ts +0 -118
  145. package/dist/devices/refrigerator.d.ts.map +0 -1
  146. package/dist/devices/refrigerator.js.map +0 -1
  147. package/dist/devices/roboticVacuumCleaner.d.ts +0 -112
  148. package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
  149. package/dist/devices/roboticVacuumCleaner.js.map +0 -1
  150. package/dist/devices/solarPower.d.ts +0 -40
  151. package/dist/devices/solarPower.d.ts.map +0 -1
  152. package/dist/devices/solarPower.js.map +0 -1
  153. package/dist/devices/speaker.d.ts +0 -87
  154. package/dist/devices/speaker.d.ts.map +0 -1
  155. package/dist/devices/speaker.js.map +0 -1
  156. package/dist/devices/temperatureControl.d.ts +0 -166
  157. package/dist/devices/temperatureControl.d.ts.map +0 -1
  158. package/dist/devices/temperatureControl.js.map +0 -1
  159. package/dist/devices/waterHeater.d.ts +0 -111
  160. package/dist/devices/waterHeater.d.ts.map +0 -1
  161. package/dist/devices/waterHeater.js.map +0 -1
  162. package/dist/dgram/coap.d.ts +0 -205
  163. package/dist/dgram/coap.d.ts.map +0 -1
  164. package/dist/dgram/coap.js.map +0 -1
  165. package/dist/dgram/dgram.d.ts +0 -141
  166. package/dist/dgram/dgram.d.ts.map +0 -1
  167. package/dist/dgram/dgram.js.map +0 -1
  168. package/dist/dgram/mb_coap.d.ts +0 -24
  169. package/dist/dgram/mb_coap.d.ts.map +0 -1
  170. package/dist/dgram/mb_coap.js.map +0 -1
  171. package/dist/dgram/mb_mdns.d.ts +0 -24
  172. package/dist/dgram/mb_mdns.d.ts.map +0 -1
  173. package/dist/dgram/mb_mdns.js.map +0 -1
  174. package/dist/dgram/mdns.d.ts +0 -290
  175. package/dist/dgram/mdns.d.ts.map +0 -1
  176. package/dist/dgram/mdns.js.map +0 -1
  177. package/dist/dgram/multicast.d.ts +0 -67
  178. package/dist/dgram/multicast.d.ts.map +0 -1
  179. package/dist/dgram/multicast.js.map +0 -1
  180. package/dist/dgram/unicast.d.ts +0 -56
  181. package/dist/dgram/unicast.d.ts.map +0 -1
  182. package/dist/dgram/unicast.js.map +0 -1
  183. package/dist/frontend.d.ts +0 -238
  184. package/dist/frontend.d.ts.map +0 -1
  185. package/dist/frontend.js.map +0 -1
  186. package/dist/frontendTypes.d.ts +0 -529
  187. package/dist/frontendTypes.d.ts.map +0 -1
  188. package/dist/frontendTypes.js.map +0 -1
  189. package/dist/helpers.d.ts +0 -48
  190. package/dist/helpers.d.ts.map +0 -1
  191. package/dist/helpers.js.map +0 -1
  192. package/dist/index.d.ts +0 -34
  193. package/dist/index.d.ts.map +0 -1
  194. package/dist/index.js.map +0 -1
  195. package/dist/jestutils/export.d.ts +0 -2
  196. package/dist/jestutils/export.d.ts.map +0 -1
  197. package/dist/jestutils/export.js.map +0 -1
  198. package/dist/jestutils/jestHelpers.d.ts +0 -340
  199. package/dist/jestutils/jestHelpers.d.ts.map +0 -1
  200. package/dist/jestutils/jestHelpers.js.map +0 -1
  201. package/dist/logger/export.d.ts +0 -2
  202. package/dist/logger/export.d.ts.map +0 -1
  203. package/dist/logger/export.js.map +0 -1
  204. package/dist/matter/behaviors.d.ts +0 -2
  205. package/dist/matter/behaviors.d.ts.map +0 -1
  206. package/dist/matter/behaviors.js.map +0 -1
  207. package/dist/matter/clusters.d.ts +0 -2
  208. package/dist/matter/clusters.d.ts.map +0 -1
  209. package/dist/matter/clusters.js.map +0 -1
  210. package/dist/matter/devices.d.ts +0 -2
  211. package/dist/matter/devices.d.ts.map +0 -1
  212. package/dist/matter/devices.js.map +0 -1
  213. package/dist/matter/endpoints.d.ts +0 -2
  214. package/dist/matter/endpoints.d.ts.map +0 -1
  215. package/dist/matter/endpoints.js.map +0 -1
  216. package/dist/matter/export.d.ts +0 -5
  217. package/dist/matter/export.d.ts.map +0 -1
  218. package/dist/matter/export.js.map +0 -1
  219. package/dist/matter/types.d.ts +0 -3
  220. package/dist/matter/types.d.ts.map +0 -1
  221. package/dist/matter/types.js.map +0 -1
  222. package/dist/matterNode.d.ts +0 -342
  223. package/dist/matterNode.d.ts.map +0 -1
  224. package/dist/matterNode.js.map +0 -1
  225. package/dist/matterbridge.d.ts +0 -493
  226. package/dist/matterbridge.d.ts.map +0 -1
  227. package/dist/matterbridge.js.map +0 -1
  228. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -41
  229. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  230. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  231. package/dist/matterbridgeBehaviors.d.ts +0 -2404
  232. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  233. package/dist/matterbridgeBehaviors.js.map +0 -1
  234. package/dist/matterbridgeDeviceTypes.d.ts +0 -698
  235. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  236. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  237. package/dist/matterbridgeDynamicPlatform.d.ts +0 -41
  238. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  239. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  240. package/dist/matterbridgeEndpoint.d.ts +0 -1507
  241. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  242. package/dist/matterbridgeEndpoint.js.map +0 -1
  243. package/dist/matterbridgeEndpointHelpers.d.ts +0 -787
  244. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  245. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  246. package/dist/matterbridgeEndpointTypes.d.ts +0 -166
  247. package/dist/matterbridgeEndpointTypes.d.ts.map +0 -1
  248. package/dist/matterbridgeEndpointTypes.js.map +0 -1
  249. package/dist/matterbridgePlatform.d.ts +0 -537
  250. package/dist/matterbridgePlatform.d.ts.map +0 -1
  251. package/dist/matterbridgePlatform.js.map +0 -1
  252. package/dist/matterbridgeTypes.d.ts +0 -251
  253. package/dist/matterbridgeTypes.d.ts.map +0 -1
  254. package/dist/matterbridgeTypes.js.map +0 -1
  255. package/dist/pluginManager.d.ts +0 -372
  256. package/dist/pluginManager.d.ts.map +0 -1
  257. package/dist/pluginManager.js.map +0 -1
  258. package/dist/shelly.d.ts +0 -181
  259. package/dist/shelly.d.ts.map +0 -1
  260. package/dist/shelly.js.map +0 -1
  261. package/dist/storage/export.d.ts +0 -2
  262. package/dist/storage/export.d.ts.map +0 -1
  263. package/dist/storage/export.js.map +0 -1
  264. package/dist/update.d.ts +0 -84
  265. package/dist/update.d.ts.map +0 -1
  266. package/dist/update.js.map +0 -1
  267. package/dist/utils/colorUtils.d.ts +0 -101
  268. package/dist/utils/colorUtils.d.ts.map +0 -1
  269. package/dist/utils/colorUtils.js.map +0 -1
  270. package/dist/utils/commandLine.d.ts +0 -66
  271. package/dist/utils/commandLine.d.ts.map +0 -1
  272. package/dist/utils/commandLine.js.map +0 -1
  273. package/dist/utils/copyDirectory.d.ts +0 -35
  274. package/dist/utils/copyDirectory.d.ts.map +0 -1
  275. package/dist/utils/copyDirectory.js.map +0 -1
  276. package/dist/utils/createDirectory.d.ts +0 -34
  277. package/dist/utils/createDirectory.d.ts.map +0 -1
  278. package/dist/utils/createDirectory.js.map +0 -1
  279. package/dist/utils/createZip.d.ts +0 -39
  280. package/dist/utils/createZip.d.ts.map +0 -1
  281. package/dist/utils/createZip.js.map +0 -1
  282. package/dist/utils/deepCopy.d.ts +0 -32
  283. package/dist/utils/deepCopy.d.ts.map +0 -1
  284. package/dist/utils/deepCopy.js.map +0 -1
  285. package/dist/utils/deepEqual.d.ts +0 -54
  286. package/dist/utils/deepEqual.d.ts.map +0 -1
  287. package/dist/utils/deepEqual.js.map +0 -1
  288. package/dist/utils/error.d.ts +0 -45
  289. package/dist/utils/error.d.ts.map +0 -1
  290. package/dist/utils/error.js.map +0 -1
  291. package/dist/utils/export.d.ts +0 -13
  292. package/dist/utils/export.d.ts.map +0 -1
  293. package/dist/utils/export.js.map +0 -1
  294. package/dist/utils/format.d.ts +0 -53
  295. package/dist/utils/format.d.ts.map +0 -1
  296. package/dist/utils/format.js.map +0 -1
  297. package/dist/utils/hex.d.ts +0 -89
  298. package/dist/utils/hex.d.ts.map +0 -1
  299. package/dist/utils/hex.js.map +0 -1
  300. package/dist/utils/inspector.d.ts +0 -87
  301. package/dist/utils/inspector.d.ts.map +0 -1
  302. package/dist/utils/inspector.js.map +0 -1
  303. package/dist/utils/isvalid.d.ts +0 -103
  304. package/dist/utils/isvalid.d.ts.map +0 -1
  305. package/dist/utils/isvalid.js.map +0 -1
  306. package/dist/utils/network.d.ts +0 -111
  307. package/dist/utils/network.d.ts.map +0 -1
  308. package/dist/utils/network.js.map +0 -1
  309. package/dist/utils/spawn.d.ts +0 -33
  310. package/dist/utils/spawn.d.ts.map +0 -1
  311. package/dist/utils/spawn.js.map +0 -1
  312. package/dist/utils/tracker.d.ts +0 -108
  313. package/dist/utils/tracker.d.ts.map +0 -1
  314. package/dist/utils/tracker.js.map +0 -1
  315. package/dist/utils/wait.d.ts +0 -54
  316. package/dist/utils/wait.d.ts.map +0 -1
  317. package/dist/utils/wait.js.map +0 -1
  318. package/dist/workerGlobalPrefix.d.ts +0 -25
  319. package/dist/workerGlobalPrefix.d.ts.map +0 -1
  320. package/dist/workerGlobalPrefix.js.map +0 -1
  321. package/dist/workerTypes.d.ts +0 -52
  322. package/dist/workerTypes.d.ts.map +0 -1
  323. package/dist/workerTypes.js.map +0 -1
  324. package/dist/workers.d.ts +0 -69
  325. package/dist/workers.d.ts.map +0 -1
  326. package/dist/workers.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,40 +85,27 @@ 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
- // Fix negative zero issue by ensuring we return positive zero
162
103
  return {
163
104
  r: red === 0 ? 0 : red,
164
105
  g: green === 0 ? 0 : green,
165
106
  b: blue === 0 ? 0 : blue,
166
107
  };
167
108
  }
168
- /**
169
- * Converts RGB color space to HSL color space
170
- *
171
- * @param {RGB} rgb - The RGB color object.
172
- * @returns {HSL} An object containing the HSL values.
173
- */
174
109
  export function rgbColorToHslColor(rgb) {
175
110
  const r = rgb.r / 255;
176
111
  const g = rgb.g / 255;
@@ -180,7 +115,7 @@ export function rgbColorToHslColor(rgb) {
180
115
  let h = 0, s = 0;
181
116
  const l = (max + min) / 2;
182
117
  if (max === min) {
183
- h = s = 0; // achromatic
118
+ h = s = 0;
184
119
  }
185
120
  else {
186
121
  const d = max - min;
@@ -204,48 +139,21 @@ export function rgbColorToHslColor(rgb) {
204
139
  l: Math.round(l * 100),
205
140
  };
206
141
  }
207
- /**
208
- * Converts CIE 1931 XY color space to HSL color space
209
- *
210
- * @param {number} x - The x value in CIE 1931 XY color space.
211
- * @param {number} y - The y value in CIE 1931 XY color space.
212
- * @returns {HSL} An object containing the HSL values.
213
- */
214
142
  export function xyToHsl(x, y) {
215
143
  const rgb = xyColorToRgbColor(x, y);
216
144
  return rgbColorToHslColor(rgb);
217
145
  }
218
- /**
219
- * Converts mireds to kelvin.
220
- *
221
- * @param {number} mired - The mired value to convert.
222
- * @returns {number} The converted kelvin value.
223
- */
224
146
  export function miredToKelvin(mired) {
225
147
  return Math.round(1000000 / mired);
226
148
  }
227
149
  export const miredsToKelvin = miredToKelvin;
228
- /**
229
- * Converts kelvin to mireds.
230
- *
231
- * @param {number} kelvin - The kelvin value to convert.
232
- * @returns {number} The converted mired value.
233
- */
234
150
  export function kelvinToMired(kelvin) {
235
151
  return Math.round(1000000 / kelvin);
236
152
  }
237
153
  export const kelvinToMireds = kelvinToMired;
238
- /**
239
- * Converts kelvin to RGB color space.
240
- *
241
- * @param {number} kelvin - The kelvin value to convert (1000K to 40000K).
242
- * @returns {RGB} An object containing the RGB values.
243
- */
244
154
  export function kelvinToRGB(kelvin) {
245
- // Clamp the temperature to the range 1000K to 40000K
246
155
  kelvin = Math.max(1000, Math.min(40000, kelvin)) / 100;
247
156
  let r, g, b;
248
- // Calculate red
249
157
  if (kelvin <= 66) {
250
158
  r = 255;
251
159
  }
@@ -254,7 +162,6 @@ export function kelvinToRGB(kelvin) {
254
162
  r = 329.698727446 * Math.pow(r, -0.1332047592);
255
163
  r = Math.max(0, Math.min(255, r));
256
164
  }
257
- // Calculate green
258
165
  if (kelvin <= 66) {
259
166
  g = kelvin;
260
167
  g = 99.4708025861 * Math.log(g) - 161.1195681661;
@@ -265,7 +172,6 @@ export function kelvinToRGB(kelvin) {
265
172
  g = 288.1221695283 * Math.pow(g, -0.0755148492);
266
173
  g = Math.max(0, Math.min(255, g));
267
174
  }
268
- // Calculate blue
269
175
  if (kelvin >= 66) {
270
176
  b = 255;
271
177
  }
@@ -279,4 +185,3 @@ export function kelvinToRGB(kelvin) {
279
185
  }
280
186
  return { r: Math.round(r), g: Math.round(g), b: Math.round(b) };
281
187
  }
282
- //# 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 './isvalid.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,23 +6,11 @@ export function hasParameter(name) {
35
6
  markerIncluded = commandArguments.includes(`--${name}`);
36
7
  return markerIncluded;
37
8
  }
38
- /**
39
- * Checks if any of the provided command-line parameters are present.
40
- *
41
- * @param {string[]} params - The names of the parameters to check.
42
- * @returns {boolean} True if any of the parameters are present, otherwise false.
43
- */
44
9
  export function hasAnyParameter(...params) {
45
10
  return params.some((param) => {
46
11
  return hasParameter(param);
47
12
  });
48
13
  }
49
- /**
50
- * Retrieves the value of a command-line parameter as a string.
51
- *
52
- * @param {string} name - The name of the parameter to retrieve.
53
- * @returns {string | undefined} The value of the parameter, or undefined if not found.
54
- */
55
14
  export function getParameter(name) {
56
15
  const commandArguments = process.argv.slice(2);
57
16
  let markerIndex = commandArguments.indexOf(`-${name}`);
@@ -61,12 +20,6 @@ export function getParameter(name) {
61
20
  return undefined;
62
21
  return commandArguments[markerIndex + 1];
63
22
  }
64
- /**
65
- * Retrieves the value of a command-line parameter as an integer.
66
- *
67
- * @param {string} name - The name of the parameter to retrieve.
68
- * @returns {number | undefined} The integer value of the parameter, or undefined if not found or invalid.
69
- */
70
23
  export function getIntParameter(name) {
71
24
  const value = getParameter(name);
72
25
  if (value === undefined)
@@ -76,12 +29,6 @@ export function getIntParameter(name) {
76
29
  return undefined;
77
30
  return intValue;
78
31
  }
79
- /**
80
- * Retrieves the value of a command-line parameter as a number array.
81
- *
82
- * @param {string} name - The name of the parameter to retrieve.
83
- * @returns {number[] | undefined} An array of string values for the parameter, or undefined if not found.
84
- */
85
32
  export function getIntArrayParameter(name) {
86
33
  const commandArguments = process.argv.slice(2);
87
34
  let markerIndex = commandArguments.indexOf(`--${name}`);
@@ -99,12 +46,6 @@ export function getIntArrayParameter(name) {
99
46
  return undefined;
100
47
  return intValues;
101
48
  }
102
- /**
103
- * Retrieves the value of a command-line parameter as a string array.
104
- *
105
- * @param {string} name - The name of the parameter to retrieve.
106
- * @returns {string[] | undefined} An array of string values for the parameter, or undefined if not found.
107
- */
108
49
  export function getStringArrayParameter(name) {
109
50
  const commandArguments = process.argv.slice(2);
110
51
  let markerIndex = commandArguments.indexOf(`--${name}`);
@@ -120,4 +61,3 @@ export function getStringArrayParameter(name) {
120
61
  return undefined;
121
62
  return values;
122
63
  }
123
- //# sourceMappingURL=commandLine.js.map
@@ -1,35 +1,3 @@
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.2
8
- * @license Apache-2.0
9
- *
10
- * Copyright 2025, 2026, 2027 Luca Liguori.
11
- *
12
- * Licensed under the Apache License, Version 2.0 (the "License");
13
- * you may not use this file except in compliance with the License.
14
- * You may obtain a copy of the License at
15
- *
16
- * http://www.apache.org/licenses/LICENSE-2.0
17
- *
18
- * Unless required by applicable law or agreed to in writing, software
19
- * distributed under the License is distributed on an "AS IS" BASIS,
20
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
- * See the License for the specific language governing permissions and
22
- * limitations under the License.
23
- */
24
- /**
25
- * Copies a directory and all its subdirectories and files to a new location.
26
- *
27
- * @param {string} srcDir - The path to the source directory.
28
- * @param {string} destDir - The path to the destination directory.
29
- * @param {AnsiLogger} [log] - Optional AnsiLogger instance for logging.
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
1
  export async function copyDirectory(srcDir, destDir, log) {
34
2
  if (srcDir === '') {
35
3
  throw new Error('Source directory must be specified.');
@@ -50,19 +18,15 @@ export async function copyDirectory(srcDir, destDir, log) {
50
18
  const path = await import('node:path');
51
19
  log?.debug(`copyDirectory: copying directory from ${srcDir} to ${destDir}`);
52
20
  try {
53
- // Create destination directory if it doesn't exist
54
21
  await fs.mkdir(destDir, { recursive: true });
55
- // Read contents of the source directory
56
22
  const entries = await fs.readdir(srcDir, { withFileTypes: true });
57
23
  for (const entry of entries) {
58
24
  const srcPath = path.join(srcDir, entry.name);
59
25
  const destPath = path.join(destDir, entry.name);
60
26
  if (entry.isDirectory()) {
61
- // Recursive call if entry is a directory
62
27
  await copyDirectory(srcPath, destPath);
63
28
  }
64
29
  else if (entry.isFile()) {
65
- // Copy file if entry is a file
66
30
  await fs.copyFile(srcPath, destPath);
67
31
  }
68
32
  }
@@ -73,4 +37,3 @@ export async function copyDirectory(srcDir, destDir, log) {
73
37
  return false;
74
38
  }
75
39
  }
76
- //# 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
@@ -1,53 +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
- * @created 2025-02-16
8
- * @version 1.0.0
9
- * @license Apache-2.0
10
- *
11
- * Copyright 2025, 2026, 2027 Luca Liguori.
12
- *
13
- * Licensed under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License.
15
- * You may obtain a copy of the License at
16
- *
17
- * http://www.apache.org/licenses/LICENSE-2.0
18
- *
19
- * Unless required by applicable law or agreed to in writing, software
20
- * distributed under the License is distributed on an "AS IS" BASIS,
21
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
- * See the License for the specific language governing permissions and
23
- * limitations under the License.
24
- */
25
- /**
26
- * Creates a deep copy of the given value.
27
- *
28
- * @template T - The type of the value being copied.
29
- * @param {T} value - The value to be copied.
30
- * @returns {T} - The deep copy of the value.
31
- */
32
1
  export function deepCopy(value) {
33
2
  if (typeof value !== 'object' || value === null) {
34
- // Primitive value (string, number, boolean, bigint, undefined, symbol) or null
35
3
  return value;
36
4
  }
37
5
  else if (Array.isArray(value)) {
38
- // Array: Recursively copy each element
39
6
  return value.map((item) => deepCopy(item));
40
7
  }
41
8
  else if (value instanceof Date) {
42
- // Date objects
43
9
  return new Date(value.getTime());
44
10
  }
45
11
  else if (value instanceof RegExp) {
46
- // RegExp objects
47
12
  return new RegExp(value.source, value.flags);
48
13
  }
49
14
  else if (value instanceof Map) {
50
- // Maps
51
15
  const mapCopy = new Map();
52
16
  for (const [origKey, origVal] of value.entries()) {
53
17
  const clonedKey = deepCopy(origKey);
@@ -57,7 +21,6 @@ export function deepCopy(value) {
57
21
  return mapCopy;
58
22
  }
59
23
  else if (value instanceof Set) {
60
- // Sets
61
24
  const setCopy = new Set();
62
25
  value.forEach((item) => {
63
26
  setCopy.add(deepCopy(item));
@@ -65,7 +28,6 @@ export function deepCopy(value) {
65
28
  return setCopy;
66
29
  }
67
30
  else {
68
- // Objects: Create a copy with the same prototype as the original
69
31
  const proto = Object.getPrototypeOf(value);
70
32
  const copy = Object.create(proto);
71
33
  for (const key in value) {
@@ -76,4 +38,3 @@ export function deepCopy(value) {
76
38
  return copy;
77
39
  }
78
40
  }
79
- //# sourceMappingURL=deepCopy.js.map