matterbridge 1.6.5 → 1.6.6-dev.2

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 (95) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cli.js +0 -26
  3. package/dist/cluster/export.js +0 -2
  4. package/dist/defaultConfigSchema.js +0 -23
  5. package/dist/deviceManager.js +1 -26
  6. package/dist/index.js +0 -30
  7. package/dist/logger/export.js +0 -1
  8. package/dist/matter/export.js +0 -1
  9. package/dist/matterbridge.js +62 -702
  10. package/dist/matterbridgeAccessoryPlatform.js +0 -33
  11. package/dist/matterbridgeBehaviors.js +1 -29
  12. package/dist/matterbridgeDevice.js +39 -933
  13. package/dist/matterbridgeDeviceTypes.js +21 -41
  14. package/dist/matterbridgeDynamicPlatform.js +0 -33
  15. package/dist/matterbridgeEdge.js +0 -525
  16. package/dist/matterbridgeEndpoint.js +61 -1027
  17. package/dist/matterbridgePlatform.js +3 -74
  18. package/dist/matterbridgeTypes.js +0 -24
  19. package/dist/matterbridgeWebsocket.js +0 -45
  20. package/dist/pluginManager.js +3 -237
  21. package/dist/storage/export.js +0 -1
  22. package/dist/utils/colorUtils.js +2 -78
  23. package/dist/utils/export.js +0 -1
  24. package/dist/utils/utils.js +7 -252
  25. package/npm-shrinkwrap.json +12 -15
  26. package/package.json +2 -2
  27. package/dist/cli.d.ts +0 -25
  28. package/dist/cli.d.ts.map +0 -1
  29. package/dist/cli.js.map +0 -1
  30. package/dist/cluster/export.d.ts +0 -2
  31. package/dist/cluster/export.d.ts.map +0 -1
  32. package/dist/cluster/export.js.map +0 -1
  33. package/dist/defaultConfigSchema.d.ts +0 -27
  34. package/dist/defaultConfigSchema.d.ts.map +0 -1
  35. package/dist/defaultConfigSchema.js.map +0 -1
  36. package/dist/deviceManager.d.ts +0 -46
  37. package/dist/deviceManager.d.ts.map +0 -1
  38. package/dist/deviceManager.js.map +0 -1
  39. package/dist/index.d.ts +0 -40
  40. package/dist/index.d.ts.map +0 -1
  41. package/dist/index.js.map +0 -1
  42. package/dist/logger/export.d.ts +0 -2
  43. package/dist/logger/export.d.ts.map +0 -1
  44. package/dist/logger/export.js.map +0 -1
  45. package/dist/matter/export.d.ts +0 -5
  46. package/dist/matter/export.d.ts.map +0 -1
  47. package/dist/matter/export.js.map +0 -1
  48. package/dist/matterbridge.d.ts +0 -466
  49. package/dist/matterbridge.d.ts.map +0 -1
  50. package/dist/matterbridge.js.map +0 -1
  51. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -39
  52. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  53. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  54. package/dist/matterbridgeBehaviors.d.ts +0 -934
  55. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  56. package/dist/matterbridgeBehaviors.js.map +0 -1
  57. package/dist/matterbridgeDevice.d.ts +0 -6504
  58. package/dist/matterbridgeDevice.d.ts.map +0 -1
  59. package/dist/matterbridgeDevice.js.map +0 -1
  60. package/dist/matterbridgeDeviceTypes.d.ts +0 -65
  61. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  62. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  63. package/dist/matterbridgeDynamicPlatform.d.ts +0 -39
  64. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  65. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  66. package/dist/matterbridgeEdge.d.ts +0 -89
  67. package/dist/matterbridgeEdge.d.ts.map +0 -1
  68. package/dist/matterbridgeEdge.js.map +0 -1
  69. package/dist/matterbridgeEndpoint.d.ts +0 -8529
  70. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  71. package/dist/matterbridgeEndpoint.js.map +0 -1
  72. package/dist/matterbridgePlatform.d.ts +0 -96
  73. package/dist/matterbridgePlatform.d.ts.map +0 -1
  74. package/dist/matterbridgePlatform.js.map +0 -1
  75. package/dist/matterbridgeTypes.d.ts +0 -147
  76. package/dist/matterbridgeTypes.d.ts.map +0 -1
  77. package/dist/matterbridgeTypes.js.map +0 -1
  78. package/dist/matterbridgeWebsocket.d.ts +0 -49
  79. package/dist/matterbridgeWebsocket.d.ts.map +0 -1
  80. package/dist/matterbridgeWebsocket.js.map +0 -1
  81. package/dist/pluginManager.d.ts +0 -238
  82. package/dist/pluginManager.d.ts.map +0 -1
  83. package/dist/pluginManager.js.map +0 -1
  84. package/dist/storage/export.d.ts +0 -2
  85. package/dist/storage/export.d.ts.map +0 -1
  86. package/dist/storage/export.js.map +0 -1
  87. package/dist/utils/colorUtils.d.ts +0 -61
  88. package/dist/utils/colorUtils.d.ts.map +0 -1
  89. package/dist/utils/colorUtils.js.map +0 -1
  90. package/dist/utils/export.d.ts +0 -3
  91. package/dist/utils/export.d.ts.map +0 -1
  92. package/dist/utils/export.js.map +0 -1
  93. package/dist/utils/utils.d.ts +0 -221
  94. package/dist/utils/utils.d.ts.map +0 -1
  95. package/dist/utils/utils.js.map +0 -1
@@ -1,93 +1,30 @@
1
- /**
2
- * This file contains the deepEqual function.
3
- *
4
- * @file utils.ts
5
- * @author Luca Liguori
6
- * @date 2024-02-17
7
- * @version 1.2.9
8
- *
9
- * Copyright 2024, 2025, 2026 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License. *
22
- */
23
- // Node.js modules
24
1
  import os from 'os';
25
2
  import { createWriteStream, statSync } from 'fs';
26
3
  import path from 'path';
27
4
  import * as dns from 'dns';
28
5
  import { promises as fs } from 'fs';
29
- // Package modules
30
6
  import archiver from 'archiver';
31
7
  import { glob } from 'glob';
32
- // AnsiLogger module
33
8
  import { AnsiLogger, idn, rs } from 'node-ansi-logger';
34
- const log = new AnsiLogger({ logName: 'MatterbridgeUtils', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: "info" /* LogLevel.INFO */ });
35
- /**
36
- * Performs a deep comparison between two values to determine if they are equivalent.
37
- * This comparison includes primitive types, arrays, and objects, allowing for optional
38
- * exclusion of specific properties from the comparison in objects.
39
- *
40
- * @param {any} a The first value to compare.
41
- * @param {any} b The second value to compare.
42
- * @param {string[]} [excludeProperties=[]] An array of property names to exclude from the comparison in objects.
43
- * @returns {boolean} True if the values are deeply equal, excluding any specified properties; otherwise, false.
44
- *
45
- * Note: This function utilizes recursion for deep comparison of nested structures and includes a debugging
46
- * mechanism that can be toggled on or off for detailed comparison logging. It is important to ensure that
47
- * objects do not contain circular references when enabling debug logging to avoid infinite loops.
48
- *
49
- * Example usage:
50
- * ```
51
- * const obj1 = { a: 1, b: { c: 2 } };
52
- * const obj2 = { a: 1, b: { c: 2 } };
53
- * console.log(deepEqual(obj1, obj2)); // true
54
- *
55
- * const arr1 = [1, 2, [3, 4]];
56
- * const arr2 = [1, 2, [3, 4]];
57
- * console.log(deepEqual(arr1, arr2)); // true
58
- *
59
- * const obj3 = { a: 1, b: { c: 2, d: 3 } };
60
- * const obj4 = { a: 1, b: { c: 2 } };
61
- * console.log(deepEqual(obj3, obj4, ['d'])); // true, excluding property 'd' from comparison
62
- * ```
63
- */
64
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ const log = new AnsiLogger({ logName: 'MatterbridgeUtils', logTimestampFormat: 4, logLevel: "info" });
65
10
  export function deepEqual(a, b, excludeProperties = []) {
66
- // Toggle debugging on or off easily
67
11
  const debug = false;
68
- // Helper function for conditional logging
69
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
12
  const debugLog = (...messages) => {
71
13
  if (debug) {
72
- // eslint-disable-next-line no-console
73
14
  console.log(...messages);
74
15
  }
75
16
  };
76
- // If both are the same instance, return true (handles primitives and same object references)
77
17
  if (a === b) {
78
18
  return true;
79
19
  }
80
- // If types are different, return false
81
20
  if (typeof a !== typeof b) {
82
21
  debugLog(`deepEqual false for typeof a: ${typeof a} typeof b: ${typeof b}`);
83
22
  return false;
84
23
  }
85
- // If one of them is null (and we know they are not equal from the first check), return false
86
24
  if (a == null || b == null) {
87
25
  debugLog('deepEqual false for == null');
88
26
  return false;
89
27
  }
90
- // Handle Arrays
91
28
  if (Array.isArray(a) && Array.isArray(b)) {
92
29
  if (a.length !== b.length) {
93
30
  debugLog(`deepEqual false for array a.length(${a.length}) !== b.length(${b.length})`);
@@ -103,75 +40,54 @@ export function deepEqual(a, b, excludeProperties = []) {
103
40
  }
104
41
  return true;
105
42
  }
106
- // Handle Objects (and exclude null, functions, and arrays)
107
43
  if (typeof a === 'object' && typeof b === 'object') {
108
44
  const aProps = Object.getOwnPropertyNames(a).filter((prop) => !excludeProperties.includes(prop));
109
45
  const bProps = Object.getOwnPropertyNames(b).filter((prop) => !excludeProperties.includes(prop));
110
- // If their property lengths are different, they're different objects
111
46
  if (aProps.length !== bProps.length) {
112
47
  debugLog(`deepEqual false for aProps.length(${aProps.length}) !== bProps.length(${bProps.length})`);
113
48
  debugLog(`- aProps.length(${aProps.length}):`, aProps);
114
49
  debugLog(`- bProps.length(${bProps.length}):`, bProps);
115
50
  return false;
116
51
  }
117
- // Check each property in 'a' to see if it's in 'b' and if it's equal (deep check)
118
52
  for (const prop of aProps) {
119
53
  if (!Object.prototype.hasOwnProperty.call(b, prop)) {
120
54
  debugLog(`deepEqual false for !b.hasOwnProperty(${prop})`);
121
55
  return false;
122
56
  }
123
57
  if (!deepEqual(a[prop], b[prop], excludeProperties)) {
124
- debugLog(`deepEqual false for !deepEqual(a[${prop}], b[${prop}])` /* , a[prop], b[prop]*/);
58
+ debugLog(`deepEqual false for !deepEqual(a[${prop}], b[${prop}])`);
125
59
  return false;
126
60
  }
127
61
  }
128
62
  return true;
129
63
  }
130
- // If none of the above, the objects are not equal
131
64
  return false;
132
65
  }
133
- /**
134
- * Creates a deep copy of the given value.
135
- *
136
- * @template T - The type of the value being copied.
137
- * @param {T} value - The value to be copied.
138
- * @returns {T} - The deep copy of the value.
139
- */
140
66
  export function deepCopy(value) {
141
67
  if (typeof value !== 'object' || value === null) {
142
- // Primitive value (string, number, boolean, bigint, undefined, symbol) or null
143
68
  return value;
144
69
  }
145
70
  else if (Array.isArray(value)) {
146
- // Array: Recursively copy each element
147
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
148
71
  return value.map((item) => deepCopy(item));
149
72
  }
150
73
  else if (value instanceof Date) {
151
- // Date objects
152
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
153
74
  return new Date(value.getTime());
154
75
  }
155
76
  else if (value instanceof Map) {
156
- // Maps
157
77
  const mapCopy = new Map();
158
78
  value.forEach((val, key) => {
159
79
  mapCopy.set(key, deepCopy(val));
160
80
  });
161
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
162
81
  return mapCopy;
163
82
  }
164
83
  else if (value instanceof Set) {
165
- // Sets
166
84
  const setCopy = new Set();
167
85
  value.forEach((item) => {
168
86
  setCopy.add(deepCopy(item));
169
87
  });
170
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
171
88
  return setCopy;
172
89
  }
173
90
  else {
174
- // Objects: Create a copy with the same prototype as the original
175
91
  const proto = Object.getPrototypeOf(value);
176
92
  const copy = Object.create(proto);
177
93
  for (const key in value) {
@@ -182,14 +98,9 @@ export function deepCopy(value) {
182
98
  return copy;
183
99
  }
184
100
  }
185
- /**
186
- * Retrieves the IPv4 address of the first non-internal network interface.
187
- * @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
188
- */
189
101
  export function getIpv4InterfaceAddress() {
190
102
  let ipv4Address;
191
103
  const networkInterfaces = os.networkInterfaces();
192
- // console.log('Available Network Interfaces:', networkInterfaces);
193
104
  for (const interfaceDetails of Object.values(networkInterfaces)) {
194
105
  if (!interfaceDetails) {
195
106
  break;
@@ -203,17 +114,11 @@ export function getIpv4InterfaceAddress() {
203
114
  break;
204
115
  }
205
116
  }
206
- // console.log('Selected Network Interfaces:', ipv4Address);
207
117
  return ipv4Address;
208
118
  }
209
- /**
210
- * Retrieves the IPv6 address of the first non-internal network interface.
211
- * @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
212
- */
213
119
  export function getIpv6InterfaceAddress() {
214
120
  let ipv6Address;
215
121
  const networkInterfaces = os.networkInterfaces();
216
- // console.log('Available Network Interfaces:', networkInterfaces);
217
122
  for (const interfaceDetails of Object.values(networkInterfaces)) {
218
123
  if (!interfaceDetails) {
219
124
  break;
@@ -227,17 +132,11 @@ export function getIpv6InterfaceAddress() {
227
132
  break;
228
133
  }
229
134
  }
230
- // console.log('Selected Network Interfaces:', ipv6Address);
231
135
  return ipv6Address;
232
136
  }
233
- /**
234
- * Retrieves the mac address of the first non-internal network interface.
235
- * @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
236
- */
237
137
  export function getMacAddress() {
238
138
  let macAddress;
239
139
  const networkInterfaces = os.networkInterfaces();
240
- // console.log('Available Network Interfaces:', networkInterfaces);
241
140
  for (const interfaceDetails of Object.values(networkInterfaces)) {
242
141
  if (!interfaceDetails) {
243
142
  break;
@@ -253,25 +152,10 @@ export function getMacAddress() {
253
152
  }
254
153
  return macAddress;
255
154
  }
256
- /**
257
- * Checks if a given string is a valid IPv4 address.
258
- *
259
- * @param {string} ipv4Address - The string to be checked.
260
- * @returns {boolean} - Returns true if the string is a valid IPv4 address, otherwise returns false.
261
- */
262
155
  export function isValidIpv4Address(ipv4Address) {
263
156
  const ipv4Regex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
264
157
  return ipv4Regex.test(ipv4Address);
265
158
  }
266
- /**
267
- * Checks if a value is a valid number within the specified range.
268
- *
269
- * @param {any} value - The value to be checked.
270
- * @param {number} min - The minimum value allowed (optional).
271
- * @param {number} max - The maximum value allowed (optional).
272
- * @returns {boolean} Returns true if the value is a valid number within the specified range, otherwise false.
273
- */
274
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
275
159
  export function isValidNumber(value, min, max) {
276
160
  if (value === undefined || value === null || typeof value !== 'number' || Number.isNaN(value))
277
161
  return false;
@@ -281,25 +165,9 @@ export function isValidNumber(value, min, max) {
281
165
  return false;
282
166
  return true;
283
167
  }
284
- /**
285
- * Checks if a value is a valid boolean.
286
- *
287
- * @param {any} value - The value to be checked.
288
- * @returns {boolean} `true` if the value is a valid boolean, `false` otherwise.
289
- */
290
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
291
168
  export function isValidBoolean(value) {
292
169
  return value !== undefined && value !== null && typeof value === 'boolean';
293
170
  }
294
- /**
295
- * Checks if a value is a valid string.
296
- *
297
- * @param {any} value - The value to be checked.
298
- * @param {number} minLength - The min string length (optional).
299
- * @param {number} maxLength - The max string length (optional).
300
- * @returns {boolean} A boolean indicating whether the value is a valid string.
301
- */
302
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
303
171
  export function isValidString(value, minLength, maxLength) {
304
172
  if (value === undefined || value === null || typeof value !== 'string')
305
173
  return false;
@@ -309,15 +177,6 @@ export function isValidString(value, minLength, maxLength) {
309
177
  return false;
310
178
  return true;
311
179
  }
312
- /**
313
- * Checks if a value is a valid object.
314
- *
315
- * @param {any} value - The value to be checked.
316
- * @param {number} minLength - The min number of keys (optional).
317
- * @param {number} maxLength - The max number of keys (optional).
318
- * @returns {boolean} A boolean indicating whether the value is a valid object.
319
- */
320
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
321
180
  export function isValidObject(value, minLength, maxLength) {
322
181
  if (value === undefined || value === null || typeof value !== 'object' || Array.isArray(value))
323
182
  return false;
@@ -328,15 +187,6 @@ export function isValidObject(value, minLength, maxLength) {
328
187
  return false;
329
188
  return true;
330
189
  }
331
- /**
332
- * Checks if a value is a valid array.
333
- *
334
- * @param {any} value - The value to be checked.
335
- * @param {number} minLength - The min number of elements (optional).
336
- * @param {number} maxLength - The max number of elements (optional).
337
- * @returns {boolean} A boolean indicating whether the value is a valid array.
338
- */
339
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
340
190
  export function isValidArray(value, minLength, maxLength) {
341
191
  if (value === undefined || value === null || !Array.isArray(value))
342
192
  return false;
@@ -346,33 +196,14 @@ export function isValidArray(value, minLength, maxLength) {
346
196
  return false;
347
197
  return true;
348
198
  }
349
- /**
350
- * Checks if the given value is null.
351
- *
352
- * @param {any} value - The value to check.
353
- * @returns {boolean} `true` if the value is null, `false` otherwise.
354
- */
355
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
356
199
  export function isValidNull(value) {
357
200
  return value === null;
358
201
  }
359
- /**
360
- * Checks if a value is undefined.
361
- *
362
- * @param {any} value - The value to check.
363
- * @returns {boolean} `true` if the value is undefined, `false` otherwise.
364
- */
365
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
366
202
  export function isValidUndefined(value) {
367
203
  return value === undefined;
368
204
  }
369
- /**
370
- * Logs the available network interfaces and their details.
371
- * @param {boolean} log - Whether to enable logging of network interface details.
372
- * @returns {string | undefined} The IPv6 address of the network interface, if available.
373
- */
374
205
  export function logInterfaces(debug = true) {
375
- log.logLevel = "info" /* LogLevel.INFO */;
206
+ log.logLevel = "info";
376
207
  log.logName = 'LogInterfaces';
377
208
  let ipv6Address;
378
209
  const networkInterfaces = os.networkInterfaces();
@@ -390,18 +221,8 @@ export function logInterfaces(debug = true) {
390
221
  }
391
222
  return ipv6Address;
392
223
  }
393
- /**
394
- * Asynchronous waiter function that resolves when the provided condition is met or rejects on timeout.
395
- * @param {string} name - The name of the waiter.
396
- * @param {() => boolean} check - A function that checks the condition. Should return a boolean.
397
- * @param {boolean} [exitWithReject=false] - Optional. If true, the promise will be rejected on timeout. Default is false.
398
- * @param {number} [resolveTimeout=5000] - Optional. The timeout duration in milliseconds. Default is 5000ms.
399
- * @param {number} [resolveInterval=500] - Optional. The interval duration in milliseconds between condition checks. Default is 500ms.
400
- * @param {boolean} [debug=false] - Optional. If true, debug messages will be logged to the console. Default is false.
401
- * @returns {Promise<boolean>} A promise that resolves to true when the condition is met, or false if the timeout occurs.
402
- */
403
224
  export async function waiter(name, check, exitWithReject = false, resolveTimeout = 5000, resolveInterval = 500, debug = false) {
404
- log.logLevel = "debug" /* LogLevel.DEBUG */;
225
+ log.logLevel = "debug";
405
226
  log.logName = 'Waiter';
406
227
  if (debug)
407
228
  log.debug(`Waiter "${name}" started...`);
@@ -427,19 +248,11 @@ export async function waiter(name, check, exitWithReject = false, resolveTimeout
427
248
  }, resolveInterval);
428
249
  });
429
250
  }
430
- /**
431
- * Asynchronously waits for a specified amount of time.
432
- * @param {number} timeout - The duration to wait in milliseconds. Default is 1000ms.
433
- * @param {string} name - The name of the wait operation. Default is undefined.
434
- * @param {boolean} debug - Whether to enable debug logging. Default is false.
435
- * @returns {Promise<void>} A Promise that resolves after the specified timeout.
436
- */
437
251
  export async function wait(timeout = 1000, name, debug = false) {
438
- log.logLevel = "debug" /* LogLevel.DEBUG */;
252
+ log.logLevel = "debug";
439
253
  log.logName = 'Wait';
440
254
  if (debug)
441
255
  log.debug(`Wait "${name}" started...`);
442
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
443
256
  return new Promise((resolve, reject) => {
444
257
  const timeoutId = setTimeout(() => {
445
258
  if (debug)
@@ -449,28 +262,14 @@ export async function wait(timeout = 1000, name, debug = false) {
449
262
  }, timeout);
450
263
  });
451
264
  }
452
- /**
453
- * Creates a ZIP archive from the specified source pattern or directory and writes it to the specified output path.
454
- *
455
- * @param {string} outputPath - The path where the output ZIP file will be written.
456
- * @param {string[]} sourcePaths - The source pattern or directory to be zipped (use path.join for sourcePath).
457
- * @returns {Promise<number>} - A promise that resolves to the total number of bytes written to the ZIP file.
458
- *
459
- * @remarks
460
- * This function uses the `archiver` library to create a ZIP archive. It sets the compression level to 9 (maximum compression).
461
- * The function ensures that the output file is properly closed after the archiving process is complete.
462
- * It logs the progress and the total number of bytes written to the console.
463
- *
464
- * This function uses the `glob` library to match files based on the source pattern (internally converted in posix).
465
- */
466
265
  export async function createZip(outputPath, ...sourcePaths) {
467
- log.logLevel = "info" /* LogLevel.INFO */;
266
+ log.logLevel = "info";
468
267
  log.logName = 'Archive';
469
268
  log.debug(`creating archive ${outputPath} from ${sourcePaths.join(', ')} ...`);
470
269
  return new Promise((resolve, reject) => {
471
270
  const output = createWriteStream(outputPath);
472
271
  const archive = archiver('zip', {
473
- zlib: { level: 9 }, // Set compression level
272
+ zlib: { level: 9 },
474
273
  });
475
274
  output.on('close', () => {
476
275
  log.debug(`archive ${outputPath} closed with ${archive.pointer()} total bytes`);
@@ -497,7 +296,6 @@ export async function createZip(outputPath, ...sourcePaths) {
497
296
  });
498
297
  archive.pipe(output);
499
298
  for (const sourcePath of sourcePaths) {
500
- // Check if the sourcePath is a file or directory
501
299
  let stats;
502
300
  try {
503
301
  stats = statSync(sourcePath);
@@ -525,35 +323,22 @@ export async function createZip(outputPath, ...sourcePaths) {
525
323
  archive.directory(sourcePath, path.basename(sourcePath));
526
324
  }
527
325
  }
528
- // Finalize the archive (i.e., we are done appending files but streams have to finish yet)
529
326
  log.debug(`finalizing archive ${outputPath}...`);
530
327
  archive.finalize().catch(reject);
531
328
  });
532
329
  }
533
- /**
534
- * Copies a directory and all its subdirectories and files to a new location.
535
- *
536
- * @param {string} srcDir - The path to the source directory.
537
- * @param {string} destDir - The path to the destination directory.
538
- * @returns {Promise<boolean>} - A promise that resolves when the copy operation is complete or fails for error.
539
- * @throws {Error} - Throws an error if the copy operation fails.
540
- */
541
330
  export async function copyDirectory(srcDir, destDir) {
542
331
  log.debug(`copyDirectory: copying directory from ${srcDir} to ${destDir}`);
543
332
  try {
544
- // Create destination directory if it doesn't exist
545
333
  await fs.mkdir(destDir, { recursive: true });
546
- // Read contents of the source directory
547
334
  const entries = await fs.readdir(srcDir, { withFileTypes: true });
548
335
  for (const entry of entries) {
549
336
  const srcPath = path.join(srcDir, entry.name);
550
337
  const destPath = path.join(destDir, entry.name);
551
338
  if (entry.isDirectory()) {
552
- // Recursive call if entry is a directory
553
339
  await copyDirectory(srcPath, destPath);
554
340
  }
555
341
  else if (entry.isFile()) {
556
- // Copy file if entry is a file
557
342
  await fs.copyFile(srcPath, destPath);
558
343
  }
559
344
  }
@@ -564,32 +349,15 @@ export async function copyDirectory(srcDir, destDir) {
564
349
  return false;
565
350
  }
566
351
  }
567
- /**
568
- * Resolves the given hostname to an IP address.
569
- *
570
- * @param {string} hostname - The hostname to resolve.
571
- * @param {0 | 4 | 6} [family=4] - The address family to use (0 for any, 4 for IPv4, 6 for IPv6). Default is 4.
572
- * @returns {Promise<string | null>} - A promise that resolves to the IP address or null if not found.
573
- *
574
- * @remarks
575
- * This function uses DNS lookup to resolve the hostname, which can take some time to complete.
576
- */
577
352
  export async function resolveHostname(hostname, family = 4) {
578
353
  try {
579
354
  const addresses = await dns.promises.lookup(hostname.toLowerCase() + '.local', { family });
580
355
  return addresses.address;
581
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
582
356
  }
583
357
  catch (error) {
584
358
  return null;
585
359
  }
586
360
  }
587
- /**
588
- * Retrieves the value of a command-line parameter.
589
- *
590
- * @param {string} name - The name of the parameter to retrieve.
591
- * @returns {string | undefined} The value of the parameter, or undefined if not found.
592
- */
593
361
  export function getParameter(name) {
594
362
  const commandArguments = process.argv.slice(2);
595
363
  let markerIndex = commandArguments.indexOf(`-${name}`);
@@ -599,12 +367,6 @@ export function getParameter(name) {
599
367
  return undefined;
600
368
  return commandArguments[markerIndex + 1];
601
369
  }
602
- /**
603
- * Checks if a command-line parameter is present.
604
- *
605
- * @param {string} name - The name of the parameter to check.
606
- * @returns {boolean} True if the parameter is present, otherwise false.
607
- */
608
370
  export function hasParameter(name) {
609
371
  const commandArguments = process.argv.slice(2);
610
372
  let markerIncluded = commandArguments.includes(`-${name}`);
@@ -612,12 +374,6 @@ export function hasParameter(name) {
612
374
  markerIncluded = commandArguments.includes(`--${name}`);
613
375
  return markerIncluded;
614
376
  }
615
- /**
616
- * Retrieves the value of a command-line parameter as an integer.
617
- *
618
- * @param {string} name - The name of the parameter to retrieve.
619
- * @returns {number | undefined} The integer value of the parameter, or undefined if not found or invalid.
620
- */
621
377
  export function getIntParameter(name) {
622
378
  const value = getParameter(name);
623
379
  if (value === undefined)
@@ -627,4 +383,3 @@ export function getIntParameter(name) {
627
383
  return undefined;
628
384
  return intValue;
629
385
  }
630
- //# sourceMappingURL=utils.js.map
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "matterbridge",
3
- "version": "1.6.5",
3
+ "version": "1.6.6-dev.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "matterbridge",
9
- "version": "1.6.5",
9
+ "version": "1.6.6-dev.2",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@matter/main": "0.11.8",
@@ -24,7 +24,7 @@
24
24
  "matterbridge": "dist/cli.js"
25
25
  },
26
26
  "engines": {
27
- "node": ">=18.0.0"
27
+ "node": ">=18.0.0 <19.0.0 || >=20.0.0 <21.0.0 || >=22.0.0 <23.0.0"
28
28
  },
29
29
  "funding": {
30
30
  "type": "buymeacoffee",
@@ -945,13 +945,10 @@
945
945
  }
946
946
  },
947
947
  "node_modules/gopd": {
948
- "version": "1.1.0",
949
- "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.1.0.tgz",
950
- "integrity": "sha512-FQoVQnqcdk4hVM4JN1eromaun4iuS34oStkdlLENLdpULsuQcTyXj8w7ayhuUfPwEYZ1ZOooOTT6fdA9Vmx/RA==",
948
+ "version": "1.2.0",
949
+ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
950
+ "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
951
951
  "license": "MIT",
952
- "dependencies": {
953
- "get-intrinsic": "^1.2.4"
954
- },
955
952
  "engines": {
956
953
  "node": ">= 0.4"
957
954
  },
@@ -993,9 +990,9 @@
993
990
  }
994
991
  },
995
992
  "node_modules/has-symbols": {
996
- "version": "1.0.3",
997
- "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
998
- "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
993
+ "version": "1.1.0",
994
+ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
995
+ "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
999
996
  "license": "MIT",
1000
997
  "engines": {
1001
998
  "node": ">= 0.4"
@@ -1717,9 +1714,9 @@
1717
1714
  }
1718
1715
  },
1719
1716
  "node_modules/streamx": {
1720
- "version": "2.20.2",
1721
- "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.20.2.tgz",
1722
- "integrity": "sha512-aDGDLU+j9tJcUdPGOaHmVF1u/hhI+CsGkT02V3OKlHDV7IukOI+nTWAGkiZEKCO35rWN1wIr4tS7YFr1f4qSvA==",
1717
+ "version": "2.21.0",
1718
+ "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.21.0.tgz",
1719
+ "integrity": "sha512-Qz6MsDZXJ6ur9u+b+4xCG18TluU7PGlRfXVAAjNiGsFrBUt/ioyLkxbFaKJygoPs+/kW4VyBj0bSj89Qu0IGyg==",
1723
1720
  "license": "MIT",
1724
1721
  "dependencies": {
1725
1722
  "fast-fifo": "^1.3.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matterbridge",
3
- "version": "1.6.5",
3
+ "version": "1.6.6-dev.2",
4
4
  "description": "Matterbridge plugin manager for Matter",
5
5
  "author": "https://github.com/Luligu",
6
6
  "license": "Apache-2.0",
@@ -46,7 +46,7 @@
46
46
  "matterbridge": "dist/cli.js"
47
47
  },
48
48
  "engines": {
49
- "node": ">=18.0.0"
49
+ "node": ">=18.0.0 <19.0.0 || >=20.0.0 <21.0.0 || >=22.0.0 <23.0.0"
50
50
  },
51
51
  "exports": {
52
52
  ".": {
package/dist/cli.d.ts DELETED
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * This file contains the CLI entry point of Matterbridge.
4
- *
5
- * @file cli.ts
6
- * @author Luca Liguori
7
- * @date 2023-12-29
8
- * @version 1.0.11
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
- export {};
25
- //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;GAqBG"}
package/dist/cli.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,+BAA+B;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,O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AK,CAAC,EAAE,GAAG,uDAAuD,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;AAC1F,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=export.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/cluster/export.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/cluster/export.ts"],"names":[],"mappings":";AAAA,8BAA8B"}
@@ -1,27 +0,0 @@
1
- /**
2
- * This file contains the default config for the plugins.
3
- *
4
- * @file defaultConfigSchema.ts
5
- * @author Luca Liguori
6
- * @date 2024-05-07
7
- * @version 1.0.1
8
- *
9
- * Copyright 2024, 2025, 2026 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 { PlatformConfig } from './matterbridgePlatform.js';
24
- export declare const zigbee2mqtt_config: PlatformConfig;
25
- export declare const somfytahoma_config: PlatformConfig;
26
- export declare const shelly_config: PlatformConfig;
27
- //# sourceMappingURL=defaultConfigSchema.d.ts.map