matterbridge 2.1.1 → 2.1.2-dev.3

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 (111) hide show
  1. package/CHANGELOG.md +17 -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 +3 -29
  6. package/dist/frontend.js +51 -245
  7. package/dist/index.js +0 -28
  8. package/dist/logger/export.js +0 -1
  9. package/dist/matter/behaviors.js +0 -2
  10. package/dist/matter/clusters.js +0 -2
  11. package/dist/matter/devices.js +0 -2
  12. package/dist/matter/endpoints.js +0 -2
  13. package/dist/matter/export.js +1 -2
  14. package/dist/matter/types.js +0 -2
  15. package/dist/matterbridge.js +38 -752
  16. package/dist/matterbridgeAccessoryPlatform.js +0 -33
  17. package/dist/matterbridgeBehaviors.js +1 -32
  18. package/dist/matterbridgeDeviceTypes.js +11 -112
  19. package/dist/matterbridgeDynamicPlatform.js +0 -33
  20. package/dist/matterbridgeEndpoint.js +6 -690
  21. package/dist/matterbridgeEndpointHelpers.js +0 -96
  22. package/dist/matterbridgePlatform.js +9 -129
  23. package/dist/matterbridgeTypes.js +0 -24
  24. package/dist/pluginManager.js +5 -243
  25. package/dist/storage/export.js +0 -1
  26. package/dist/utils/colorUtils.js +2 -205
  27. package/dist/utils/export.js +0 -1
  28. package/dist/utils/utils.js +7 -251
  29. package/npm-shrinkwrap.json +2 -2
  30. package/package.json +1 -2
  31. package/dist/cli.d.ts +0 -25
  32. package/dist/cli.d.ts.map +0 -1
  33. package/dist/cli.js.map +0 -1
  34. package/dist/cluster/export.d.ts +0 -2
  35. package/dist/cluster/export.d.ts.map +0 -1
  36. package/dist/cluster/export.js.map +0 -1
  37. package/dist/defaultConfigSchema.d.ts +0 -27
  38. package/dist/defaultConfigSchema.d.ts.map +0 -1
  39. package/dist/defaultConfigSchema.js.map +0 -1
  40. package/dist/deviceManager.d.ts +0 -46
  41. package/dist/deviceManager.d.ts.map +0 -1
  42. package/dist/deviceManager.js.map +0 -1
  43. package/dist/frontend.d.ts +0 -109
  44. package/dist/frontend.d.ts.map +0 -1
  45. package/dist/frontend.js.map +0 -1
  46. package/dist/index.d.ts +0 -35
  47. package/dist/index.d.ts.map +0 -1
  48. package/dist/index.js.map +0 -1
  49. package/dist/logger/export.d.ts +0 -2
  50. package/dist/logger/export.d.ts.map +0 -1
  51. package/dist/logger/export.js.map +0 -1
  52. package/dist/matter/behaviors.d.ts +0 -2
  53. package/dist/matter/behaviors.d.ts.map +0 -1
  54. package/dist/matter/behaviors.js.map +0 -1
  55. package/dist/matter/clusters.d.ts +0 -2
  56. package/dist/matter/clusters.d.ts.map +0 -1
  57. package/dist/matter/clusters.js.map +0 -1
  58. package/dist/matter/devices.d.ts +0 -2
  59. package/dist/matter/devices.d.ts.map +0 -1
  60. package/dist/matter/devices.js.map +0 -1
  61. package/dist/matter/endpoints.d.ts +0 -2
  62. package/dist/matter/endpoints.d.ts.map +0 -1
  63. package/dist/matter/endpoints.js.map +0 -1
  64. package/dist/matter/export.d.ts +0 -4
  65. package/dist/matter/export.d.ts.map +0 -1
  66. package/dist/matter/export.js.map +0 -1
  67. package/dist/matter/types.d.ts +0 -3
  68. package/dist/matter/types.d.ts.map +0 -1
  69. package/dist/matter/types.js.map +0 -1
  70. package/dist/matterbridge.d.ts +0 -409
  71. package/dist/matterbridge.d.ts.map +0 -1
  72. package/dist/matterbridge.js.map +0 -1
  73. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -39
  74. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  75. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  76. package/dist/matterbridgeBehaviors.d.ts +0 -1056
  77. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  78. package/dist/matterbridgeBehaviors.js.map +0 -1
  79. package/dist/matterbridgeDeviceTypes.d.ts +0 -177
  80. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  81. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  82. package/dist/matterbridgeDynamicPlatform.d.ts +0 -39
  83. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  84. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  85. package/dist/matterbridgeEndpoint.d.ts +0 -834
  86. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  87. package/dist/matterbridgeEndpoint.js.map +0 -1
  88. package/dist/matterbridgeEndpointHelpers.d.ts +0 -2262
  89. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  90. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  91. package/dist/matterbridgePlatform.d.ts +0 -164
  92. package/dist/matterbridgePlatform.d.ts.map +0 -1
  93. package/dist/matterbridgePlatform.js.map +0 -1
  94. package/dist/matterbridgeTypes.d.ts +0 -165
  95. package/dist/matterbridgeTypes.d.ts.map +0 -1
  96. package/dist/matterbridgeTypes.js.map +0 -1
  97. package/dist/pluginManager.d.ts +0 -238
  98. package/dist/pluginManager.d.ts.map +0 -1
  99. package/dist/pluginManager.js.map +0 -1
  100. package/dist/storage/export.d.ts +0 -2
  101. package/dist/storage/export.d.ts.map +0 -1
  102. package/dist/storage/export.js.map +0 -1
  103. package/dist/utils/colorUtils.d.ts +0 -61
  104. package/dist/utils/colorUtils.d.ts.map +0 -1
  105. package/dist/utils/colorUtils.js.map +0 -1
  106. package/dist/utils/export.d.ts +0 -3
  107. package/dist/utils/export.d.ts.map +0 -1
  108. package/dist/utils/export.js.map +0 -1
  109. package/dist/utils/utils.d.ts +0 -221
  110. package/dist/utils/utils.d.ts.map +0 -1
  111. package/dist/utils/utils.js.map +0 -1
@@ -1,90 +1,28 @@
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
- // AnsiLogger module
30
6
  import { AnsiLogger, idn, rs } from 'node-ansi-logger';
31
- const log = new AnsiLogger({ logName: 'MatterbridgeUtils', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: "info" /* LogLevel.INFO */ });
32
- /**
33
- * Performs a deep comparison between two values to determine if they are equivalent.
34
- * This comparison includes primitive types, arrays, and objects, allowing for optional
35
- * exclusion of specific properties from the comparison in objects.
36
- *
37
- * @param {any} a The first value to compare.
38
- * @param {any} b The second value to compare.
39
- * @param {string[]} [excludeProperties=[]] An array of property names to exclude from the comparison in objects.
40
- * @returns {boolean} True if the values are deeply equal, excluding any specified properties; otherwise, false.
41
- *
42
- * Note: This function utilizes recursion for deep comparison of nested structures and includes a debugging
43
- * mechanism that can be toggled on or off for detailed comparison logging. It is important to ensure that
44
- * objects do not contain circular references when enabling debug logging to avoid infinite loops.
45
- *
46
- * Example usage:
47
- * ```
48
- * const obj1 = { a: 1, b: { c: 2 } };
49
- * const obj2 = { a: 1, b: { c: 2 } };
50
- * console.log(deepEqual(obj1, obj2)); // true
51
- *
52
- * const arr1 = [1, 2, [3, 4]];
53
- * const arr2 = [1, 2, [3, 4]];
54
- * console.log(deepEqual(arr1, arr2)); // true
55
- *
56
- * const obj3 = { a: 1, b: { c: 2, d: 3 } };
57
- * const obj4 = { a: 1, b: { c: 2 } };
58
- * console.log(deepEqual(obj3, obj4, ['d'])); // true, excluding property 'd' from comparison
59
- * ```
60
- */
61
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+ const log = new AnsiLogger({ logName: 'MatterbridgeUtils', logTimestampFormat: 4, logLevel: "info" });
62
8
  export function deepEqual(a, b, excludeProperties = []) {
63
- // Toggle debugging on or off easily
64
9
  const debug = false;
65
- // Helper function for conditional logging
66
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
10
  const debugLog = (...messages) => {
68
11
  if (debug) {
69
- // eslint-disable-next-line no-console
70
12
  console.log(...messages);
71
13
  }
72
14
  };
73
- // If both are the same instance, return true (handles primitives and same object references)
74
15
  if (a === b) {
75
16
  return true;
76
17
  }
77
- // If types are different, return false
78
18
  if (typeof a !== typeof b) {
79
19
  debugLog(`deepEqual false for typeof a: ${typeof a} typeof b: ${typeof b}`);
80
20
  return false;
81
21
  }
82
- // If one of them is null (and we know they are not equal from the first check), return false
83
22
  if (a == null || b == null) {
84
23
  debugLog('deepEqual false for == null');
85
24
  return false;
86
25
  }
87
- // Handle Arrays
88
26
  if (Array.isArray(a) && Array.isArray(b)) {
89
27
  if (a.length !== b.length) {
90
28
  debugLog(`deepEqual false for array a.length(${a.length}) !== b.length(${b.length})`);
@@ -100,75 +38,54 @@ export function deepEqual(a, b, excludeProperties = []) {
100
38
  }
101
39
  return true;
102
40
  }
103
- // Handle Objects (and exclude null, functions, and arrays)
104
41
  if (typeof a === 'object' && typeof b === 'object') {
105
42
  const aProps = Object.getOwnPropertyNames(a).filter((prop) => !excludeProperties.includes(prop));
106
43
  const bProps = Object.getOwnPropertyNames(b).filter((prop) => !excludeProperties.includes(prop));
107
- // If their property lengths are different, they're different objects
108
44
  if (aProps.length !== bProps.length) {
109
45
  debugLog(`deepEqual false for aProps.length(${aProps.length}) !== bProps.length(${bProps.length})`);
110
46
  debugLog(`- aProps.length(${aProps.length}):`, aProps);
111
47
  debugLog(`- bProps.length(${bProps.length}):`, bProps);
112
48
  return false;
113
49
  }
114
- // Check each property in 'a' to see if it's in 'b' and if it's equal (deep check)
115
50
  for (const prop of aProps) {
116
51
  if (!Object.prototype.hasOwnProperty.call(b, prop)) {
117
52
  debugLog(`deepEqual false for !b.hasOwnProperty(${prop})`);
118
53
  return false;
119
54
  }
120
55
  if (!deepEqual(a[prop], b[prop], excludeProperties)) {
121
- debugLog(`deepEqual false for !deepEqual(a[${prop}], b[${prop}])` /* , a[prop], b[prop]*/);
56
+ debugLog(`deepEqual false for !deepEqual(a[${prop}], b[${prop}])`);
122
57
  return false;
123
58
  }
124
59
  }
125
60
  return true;
126
61
  }
127
- // If none of the above, the objects are not equal
128
62
  return false;
129
63
  }
130
- /**
131
- * Creates a deep copy of the given value.
132
- *
133
- * @template T - The type of the value being copied.
134
- * @param {T} value - The value to be copied.
135
- * @returns {T} - The deep copy of the value.
136
- */
137
64
  export function deepCopy(value) {
138
65
  if (typeof value !== 'object' || value === null) {
139
- // Primitive value (string, number, boolean, bigint, undefined, symbol) or null
140
66
  return value;
141
67
  }
142
68
  else if (Array.isArray(value)) {
143
- // Array: Recursively copy each element
144
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
145
69
  return value.map((item) => deepCopy(item));
146
70
  }
147
71
  else if (value instanceof Date) {
148
- // Date objects
149
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
150
72
  return new Date(value.getTime());
151
73
  }
152
74
  else if (value instanceof Map) {
153
- // Maps
154
75
  const mapCopy = new Map();
155
76
  value.forEach((val, key) => {
156
77
  mapCopy.set(key, deepCopy(val));
157
78
  });
158
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
159
79
  return mapCopy;
160
80
  }
161
81
  else if (value instanceof Set) {
162
- // Sets
163
82
  const setCopy = new Set();
164
83
  value.forEach((item) => {
165
84
  setCopy.add(deepCopy(item));
166
85
  });
167
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
168
86
  return setCopy;
169
87
  }
170
88
  else {
171
- // Objects: Create a copy with the same prototype as the original
172
89
  const proto = Object.getPrototypeOf(value);
173
90
  const copy = Object.create(proto);
174
91
  for (const key in value) {
@@ -179,14 +96,9 @@ export function deepCopy(value) {
179
96
  return copy;
180
97
  }
181
98
  }
182
- /**
183
- * Retrieves the IPv4 address of the first non-internal network interface.
184
- * @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
185
- */
186
99
  export function getIpv4InterfaceAddress() {
187
100
  let ipv4Address;
188
101
  const networkInterfaces = os.networkInterfaces();
189
- // console.log('Available Network Interfaces:', networkInterfaces);
190
102
  for (const interfaceDetails of Object.values(networkInterfaces)) {
191
103
  if (!interfaceDetails) {
192
104
  break;
@@ -200,17 +112,11 @@ export function getIpv4InterfaceAddress() {
200
112
  break;
201
113
  }
202
114
  }
203
- // console.log('Selected Network Interfaces:', ipv4Address);
204
115
  return ipv4Address;
205
116
  }
206
- /**
207
- * Retrieves the IPv6 address of the first non-internal network interface.
208
- * @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
209
- */
210
117
  export function getIpv6InterfaceAddress() {
211
118
  let ipv6Address;
212
119
  const networkInterfaces = os.networkInterfaces();
213
- // console.log('Available Network Interfaces:', networkInterfaces);
214
120
  for (const interfaceDetails of Object.values(networkInterfaces)) {
215
121
  if (!interfaceDetails) {
216
122
  break;
@@ -224,17 +130,11 @@ export function getIpv6InterfaceAddress() {
224
130
  break;
225
131
  }
226
132
  }
227
- // console.log('Selected Network Interfaces:', ipv6Address);
228
133
  return ipv6Address;
229
134
  }
230
- /**
231
- * Retrieves the mac address of the first non-internal network interface.
232
- * @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
233
- */
234
135
  export function getMacAddress() {
235
136
  let macAddress;
236
137
  const networkInterfaces = os.networkInterfaces();
237
- // console.log('Available Network Interfaces:', networkInterfaces);
238
138
  for (const interfaceDetails of Object.values(networkInterfaces)) {
239
139
  if (!interfaceDetails) {
240
140
  break;
@@ -250,25 +150,10 @@ export function getMacAddress() {
250
150
  }
251
151
  return macAddress;
252
152
  }
253
- /**
254
- * Checks if a given string is a valid IPv4 address.
255
- *
256
- * @param {string} ipv4Address - The string to be checked.
257
- * @returns {boolean} - Returns true if the string is a valid IPv4 address, otherwise returns false.
258
- */
259
153
  export function isValidIpv4Address(ipv4Address) {
260
154
  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]?)$/;
261
155
  return ipv4Regex.test(ipv4Address);
262
156
  }
263
- /**
264
- * Checks if a value is a valid number within the specified range.
265
- *
266
- * @param {any} value - The value to be checked.
267
- * @param {number} min - The minimum value allowed (optional).
268
- * @param {number} max - The maximum value allowed (optional).
269
- * @returns {boolean} Returns true if the value is a valid number within the specified range, otherwise false.
270
- */
271
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
272
157
  export function isValidNumber(value, min, max) {
273
158
  if (value === undefined || value === null || typeof value !== 'number' || Number.isNaN(value))
274
159
  return false;
@@ -278,25 +163,9 @@ export function isValidNumber(value, min, max) {
278
163
  return false;
279
164
  return true;
280
165
  }
281
- /**
282
- * Checks if a value is a valid boolean.
283
- *
284
- * @param {any} value - The value to be checked.
285
- * @returns {boolean} `true` if the value is a valid boolean, `false` otherwise.
286
- */
287
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
288
166
  export function isValidBoolean(value) {
289
167
  return value !== undefined && value !== null && typeof value === 'boolean';
290
168
  }
291
- /**
292
- * Checks if a value is a valid string.
293
- *
294
- * @param {any} value - The value to be checked.
295
- * @param {number} minLength - The min string length (optional).
296
- * @param {number} maxLength - The max string length (optional).
297
- * @returns {boolean} A boolean indicating whether the value is a valid string.
298
- */
299
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
300
169
  export function isValidString(value, minLength, maxLength) {
301
170
  if (value === undefined || value === null || typeof value !== 'string')
302
171
  return false;
@@ -306,15 +175,6 @@ export function isValidString(value, minLength, maxLength) {
306
175
  return false;
307
176
  return true;
308
177
  }
309
- /**
310
- * Checks if a value is a valid object.
311
- *
312
- * @param {any} value - The value to be checked.
313
- * @param {number} minLength - The min number of keys (optional).
314
- * @param {number} maxLength - The max number of keys (optional).
315
- * @returns {boolean} A boolean indicating whether the value is a valid object.
316
- */
317
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
318
178
  export function isValidObject(value, minLength, maxLength) {
319
179
  if (value === undefined || value === null || typeof value !== 'object' || Array.isArray(value))
320
180
  return false;
@@ -325,15 +185,6 @@ export function isValidObject(value, minLength, maxLength) {
325
185
  return false;
326
186
  return true;
327
187
  }
328
- /**
329
- * Checks if a value is a valid array.
330
- *
331
- * @param {any} value - The value to be checked.
332
- * @param {number} minLength - The min number of elements (optional).
333
- * @param {number} maxLength - The max number of elements (optional).
334
- * @returns {boolean} A boolean indicating whether the value is a valid array.
335
- */
336
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
337
188
  export function isValidArray(value, minLength, maxLength) {
338
189
  if (value === undefined || value === null || !Array.isArray(value))
339
190
  return false;
@@ -343,33 +194,14 @@ export function isValidArray(value, minLength, maxLength) {
343
194
  return false;
344
195
  return true;
345
196
  }
346
- /**
347
- * Checks if the given value is null.
348
- *
349
- * @param {any} value - The value to check.
350
- * @returns {boolean} `true` if the value is null, `false` otherwise.
351
- */
352
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
353
197
  export function isValidNull(value) {
354
198
  return value === null;
355
199
  }
356
- /**
357
- * Checks if a value is undefined.
358
- *
359
- * @param {any} value - The value to check.
360
- * @returns {boolean} `true` if the value is undefined, `false` otherwise.
361
- */
362
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
363
200
  export function isValidUndefined(value) {
364
201
  return value === undefined;
365
202
  }
366
- /**
367
- * Logs the available network interfaces and their details.
368
- * @param {boolean} log - Whether to enable logging of network interface details.
369
- * @returns {string | undefined} The IPv6 address of the network interface, if available.
370
- */
371
203
  export function logInterfaces(debug = true) {
372
- log.logLevel = "info" /* LogLevel.INFO */;
204
+ log.logLevel = "info";
373
205
  log.logName = 'LogInterfaces';
374
206
  let ipv6Address;
375
207
  const networkInterfaces = os.networkInterfaces();
@@ -387,18 +219,8 @@ export function logInterfaces(debug = true) {
387
219
  }
388
220
  return ipv6Address;
389
221
  }
390
- /**
391
- * Asynchronous waiter function that resolves when the provided condition is met or rejects on timeout.
392
- * @param {string} name - The name of the waiter.
393
- * @param {() => boolean} check - A function that checks the condition. Should return a boolean.
394
- * @param {boolean} [exitWithReject=false] - Optional. If true, the promise will be rejected on timeout. Default is false.
395
- * @param {number} [resolveTimeout=5000] - Optional. The timeout duration in milliseconds. Default is 5000ms.
396
- * @param {number} [resolveInterval=500] - Optional. The interval duration in milliseconds between condition checks. Default is 500ms.
397
- * @param {boolean} [debug=false] - Optional. If true, debug messages will be logged to the console. Default is false.
398
- * @returns {Promise<boolean>} A promise that resolves to true when the condition is met, or false if the timeout occurs.
399
- */
400
222
  export async function waiter(name, check, exitWithReject = false, resolveTimeout = 5000, resolveInterval = 500, debug = false) {
401
- log.logLevel = "debug" /* LogLevel.DEBUG */;
223
+ log.logLevel = "debug";
402
224
  log.logName = 'Waiter';
403
225
  if (debug)
404
226
  log.debug(`Waiter "${name}" started...`);
@@ -424,19 +246,11 @@ export async function waiter(name, check, exitWithReject = false, resolveTimeout
424
246
  }, resolveInterval);
425
247
  });
426
248
  }
427
- /**
428
- * Asynchronously waits for a specified amount of time.
429
- * @param {number} timeout - The duration to wait in milliseconds. Default is 1000ms.
430
- * @param {string} name - The name of the wait operation. Default is undefined.
431
- * @param {boolean} debug - Whether to enable debug logging. Default is false.
432
- * @returns {Promise<void>} A Promise that resolves after the specified timeout.
433
- */
434
249
  export async function wait(timeout = 1000, name, debug = false) {
435
- log.logLevel = "debug" /* LogLevel.DEBUG */;
250
+ log.logLevel = "debug";
436
251
  log.logName = 'Wait';
437
252
  if (debug)
438
253
  log.debug(`Wait "${name}" started...`);
439
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
440
254
  return new Promise((resolve, reject) => {
441
255
  const timeoutId = setTimeout(() => {
442
256
  if (debug)
@@ -446,30 +260,16 @@ export async function wait(timeout = 1000, name, debug = false) {
446
260
  }, timeout);
447
261
  });
448
262
  }
449
- /**
450
- * Creates a ZIP archive from the specified source pattern or directory and writes it to the specified output path.
451
- *
452
- * @param {string} outputPath - The path where the output ZIP file will be written.
453
- * @param {string[]} sourcePaths - The source pattern or directory to be zipped (use path.join for sourcePath).
454
- * @returns {Promise<number>} - A promise that resolves to the total number of bytes written to the ZIP file.
455
- *
456
- * @remarks
457
- * This function uses the `archiver` library to create a ZIP archive. It sets the compression level to 9 (maximum compression).
458
- * The function ensures that the output file is properly closed after the archiving process is complete.
459
- * It logs the progress and the total number of bytes written to the console.
460
- *
461
- * This function uses the `glob` library to match files based on the source pattern (internally converted in posix).
462
- */
463
263
  export async function createZip(outputPath, ...sourcePaths) {
464
264
  const { default: archiver } = await import('archiver');
465
265
  const { glob } = await import('glob');
466
- log.logLevel = "info" /* LogLevel.INFO */;
266
+ log.logLevel = "info";
467
267
  log.logName = 'Archive';
468
268
  log.debug(`creating archive ${outputPath} from ${sourcePaths.join(', ')} ...`);
469
269
  return new Promise((resolve, reject) => {
470
270
  const output = createWriteStream(outputPath);
471
271
  const archive = archiver('zip', {
472
- zlib: { level: 9 }, // Set compression level
272
+ zlib: { level: 9 },
473
273
  });
474
274
  output.on('close', () => {
475
275
  log.debug(`archive ${outputPath} closed with ${archive.pointer()} total bytes`);
@@ -496,7 +296,6 @@ export async function createZip(outputPath, ...sourcePaths) {
496
296
  });
497
297
  archive.pipe(output);
498
298
  for (const sourcePath of sourcePaths) {
499
- // Check if the sourcePath is a file or directory
500
299
  let stats;
501
300
  try {
502
301
  stats = statSync(sourcePath);
@@ -524,35 +323,22 @@ export async function createZip(outputPath, ...sourcePaths) {
524
323
  archive.directory(sourcePath, path.basename(sourcePath));
525
324
  }
526
325
  }
527
- // Finalize the archive (i.e., we are done appending files but streams have to finish yet)
528
326
  log.debug(`finalizing archive ${outputPath}...`);
529
327
  archive.finalize().catch(reject);
530
328
  });
531
329
  }
532
- /**
533
- * Copies a directory and all its subdirectories and files to a new location.
534
- *
535
- * @param {string} srcDir - The path to the source directory.
536
- * @param {string} destDir - The path to the destination directory.
537
- * @returns {Promise<boolean>} - A promise that resolves when the copy operation is complete or fails for error.
538
- * @throws {Error} - Throws an error if the copy operation fails.
539
- */
540
330
  export async function copyDirectory(srcDir, destDir) {
541
331
  log.debug(`copyDirectory: copying directory from ${srcDir} to ${destDir}`);
542
332
  try {
543
- // Create destination directory if it doesn't exist
544
333
  await fs.mkdir(destDir, { recursive: true });
545
- // Read contents of the source directory
546
334
  const entries = await fs.readdir(srcDir, { withFileTypes: true });
547
335
  for (const entry of entries) {
548
336
  const srcPath = path.join(srcDir, entry.name);
549
337
  const destPath = path.join(destDir, entry.name);
550
338
  if (entry.isDirectory()) {
551
- // Recursive call if entry is a directory
552
339
  await copyDirectory(srcPath, destPath);
553
340
  }
554
341
  else if (entry.isFile()) {
555
- // Copy file if entry is a file
556
342
  await fs.copyFile(srcPath, destPath);
557
343
  }
558
344
  }
@@ -563,32 +349,15 @@ export async function copyDirectory(srcDir, destDir) {
563
349
  return false;
564
350
  }
565
351
  }
566
- /**
567
- * Resolves the given hostname to an IP address.
568
- *
569
- * @param {string} hostname - The hostname to resolve.
570
- * @param {0 | 4 | 6} [family=4] - The address family to use (0 for any, 4 for IPv4, 6 for IPv6). Default is 4.
571
- * @returns {Promise<string | null>} - A promise that resolves to the IP address or null if not found.
572
- *
573
- * @remarks
574
- * This function uses DNS lookup to resolve the hostname, which can take some time to complete.
575
- */
576
352
  export async function resolveHostname(hostname, family = 4) {
577
353
  try {
578
354
  const addresses = await dns.promises.lookup(hostname.toLowerCase() + '.local', { family });
579
355
  return addresses.address;
580
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
581
356
  }
582
357
  catch (error) {
583
358
  return null;
584
359
  }
585
360
  }
586
- /**
587
- * Retrieves the value of a command-line parameter.
588
- *
589
- * @param {string} name - The name of the parameter to retrieve.
590
- * @returns {string | undefined} The value of the parameter, or undefined if not found.
591
- */
592
361
  export function getParameter(name) {
593
362
  const commandArguments = process.argv.slice(2);
594
363
  let markerIndex = commandArguments.indexOf(`-${name}`);
@@ -598,12 +367,6 @@ export function getParameter(name) {
598
367
  return undefined;
599
368
  return commandArguments[markerIndex + 1];
600
369
  }
601
- /**
602
- * Checks if a command-line parameter is present.
603
- *
604
- * @param {string} name - The name of the parameter to check.
605
- * @returns {boolean} True if the parameter is present, otherwise false.
606
- */
607
370
  export function hasParameter(name) {
608
371
  const commandArguments = process.argv.slice(2);
609
372
  let markerIncluded = commandArguments.includes(`-${name}`);
@@ -611,12 +374,6 @@ export function hasParameter(name) {
611
374
  markerIncluded = commandArguments.includes(`--${name}`);
612
375
  return markerIncluded;
613
376
  }
614
- /**
615
- * Retrieves the value of a command-line parameter as an integer.
616
- *
617
- * @param {string} name - The name of the parameter to retrieve.
618
- * @returns {number | undefined} The integer value of the parameter, or undefined if not found or invalid.
619
- */
620
377
  export function getIntParameter(name) {
621
378
  const value = getParameter(name);
622
379
  if (value === undefined)
@@ -626,4 +383,3 @@ export function getIntParameter(name) {
626
383
  return undefined;
627
384
  return intValue;
628
385
  }
629
- //# sourceMappingURL=utils.js.map
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "matterbridge",
3
- "version": "2.1.1",
3
+ "version": "2.1.2-dev.3",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "matterbridge",
9
- "version": "2.1.1",
9
+ "version": "2.1.2-dev.3",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@matter/main": "0.12.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matterbridge",
3
- "version": "2.1.1",
3
+ "version": "2.1.2-dev.3",
4
4
  "description": "Matterbridge plugin manager for Matter",
5
5
  "author": "https://github.com/Luligu",
6
6
  "license": "Apache-2.0",
@@ -41,7 +41,6 @@
41
41
  ],
42
42
  "type": "module",
43
43
  "main": "dist/index.js",
44
- "types": "dist/index.d.ts",
45
44
  "bin": {
46
45
  "matterbridge": "dist/cli.js"
47
46
  },
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;AAEjD,IAAI,QAAkC,CAAC;AACvC,MAAM,GAAG,GAAG,YAAY,CAAC;AACzB,MAAM,EAAE,GAAG,gBAAgB,CAAC;AAC5B,MAAM,EAAE,GAAG,cAAc,CAAC;AAE1B,KAAK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,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,yCAAyC,GAAG,EAAE,CAAC,CAAC;IACvG,QAAQ,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACjD,gBAAgB,EAAE,CAAC;AACrB,CAAC;AAED,KAAK,UAAU,MAAM;IACnB,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,yCAAyC,GAAG,EAAE,CAAC,CAAC;IACvG,uDAAuD;IACvD,QAAQ,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACjD,gBAAgB,EAAE,CAAC;AACrB,CAAC;AAED,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC;AAE/B,wBAAwB;AACxB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,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
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultConfigSchema.d.ts","sourceRoot":"","sources":["../src/defaultConfigSchema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,eAAO,MAAM,kBAAkB,EAAE,cAiBhC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,cAWhC,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,cAkC3B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultConfigSchema.js","sourceRoot":"","sources":["../src/defaultConfigSchema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,MAAM,CAAC,MAAM,kBAAkB,GAAmB;IAChD,IAAI,EAAE,0BAA0B;IAChC,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,aAAa;IACpB,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,EAAE;IACb,UAAU,EAAE,EAAE;IACd,SAAS,EAAE,EAAE;IACb,UAAU,EAAE,EAAE;IACd,gBAAgB,EAAE,EAAE;IACpB,sBAAsB,EAAE,EAAE;IAC1B,KAAK,EAAE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}
@@ -1,46 +0,0 @@
1
- /**
2
- * This file contains the DeviceManager class.
3
- *
4
- * @file devices.ts
5
- * @author Luca Liguori
6
- * @date 2024-07-26
7
- * @version 1.0.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
- import { LogLevel } from './logger/export.js';
24
- import { NodeStorage } from './storage/export.js';
25
- import { Matterbridge } from './matterbridge.js';
26
- import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
27
- export declare class DeviceManager {
28
- private readonly _devices;
29
- private readonly matterbridge;
30
- private readonly nodeContext;
31
- private readonly log;
32
- constructor(matterbridge: Matterbridge, nodeContext: NodeStorage);
33
- get length(): number;
34
- get size(): number;
35
- has(uniqueId: string): boolean;
36
- get(uniqueId: string): MatterbridgeEndpoint | undefined;
37
- set(device: MatterbridgeEndpoint): MatterbridgeEndpoint;
38
- remove(device: MatterbridgeEndpoint): boolean;
39
- clear(): void;
40
- array(): MatterbridgeEndpoint[];
41
- [Symbol.iterator](): MapIterator<MatterbridgeEndpoint>;
42
- forEach(callback: (device: MatterbridgeEndpoint) => Promise<void>): Promise<void>;
43
- get logLevel(): LogLevel;
44
- set logLevel(logLevel: LogLevel);
45
- }
46
- //# sourceMappingURL=deviceManager.d.ts.map