matterbridge 3.0.1-dev-20250506-c77ed36 → 3.0.1
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.
- package/CHANGELOG.md +4 -4
- package/dist/cli.d.ts +29 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +37 -2
- package/dist/cli.js.map +1 -0
- package/dist/cluster/export.d.ts +2 -0
- package/dist/cluster/export.d.ts.map +1 -0
- package/dist/cluster/export.js +2 -0
- package/dist/cluster/export.js.map +1 -0
- package/dist/defaultConfigSchema.d.ts +27 -0
- package/dist/defaultConfigSchema.d.ts.map +1 -0
- package/dist/defaultConfigSchema.js +23 -0
- package/dist/defaultConfigSchema.js.map +1 -0
- package/dist/deviceManager.d.ts +114 -0
- package/dist/deviceManager.d.ts.map +1 -0
- package/dist/deviceManager.js +94 -1
- package/dist/deviceManager.js.map +1 -0
- package/dist/frontend.d.ts +240 -0
- package/dist/frontend.d.ts.map +1 -0
- package/dist/frontend.js +328 -15
- package/dist/frontend.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -1
- package/dist/index.js.map +1 -0
- package/dist/logger/export.d.ts +2 -0
- package/dist/logger/export.d.ts.map +1 -0
- package/dist/logger/export.js +1 -0
- package/dist/logger/export.js.map +1 -0
- package/dist/matter/behaviors.d.ts +2 -0
- package/dist/matter/behaviors.d.ts.map +1 -0
- package/dist/matter/behaviors.js +2 -0
- package/dist/matter/behaviors.js.map +1 -0
- package/dist/matter/clusters.d.ts +2 -0
- package/dist/matter/clusters.d.ts.map +1 -0
- package/dist/matter/clusters.js +2 -0
- package/dist/matter/clusters.js.map +1 -0
- package/dist/matter/devices.d.ts +2 -0
- package/dist/matter/devices.d.ts.map +1 -0
- package/dist/matter/devices.js +2 -0
- package/dist/matter/devices.js.map +1 -0
- package/dist/matter/endpoints.d.ts +2 -0
- package/dist/matter/endpoints.d.ts.map +1 -0
- package/dist/matter/endpoints.js +2 -0
- package/dist/matter/endpoints.js.map +1 -0
- package/dist/matter/export.d.ts +5 -0
- package/dist/matter/export.d.ts.map +1 -0
- package/dist/matter/export.js +2 -0
- package/dist/matter/export.js.map +1 -0
- package/dist/matter/types.d.ts +3 -0
- package/dist/matter/types.d.ts.map +1 -0
- package/dist/matter/types.js +2 -0
- package/dist/matter/types.js.map +1 -0
- package/dist/matterbridge.d.ts +433 -0
- package/dist/matterbridge.d.ts.map +1 -0
- package/dist/matterbridge.js +747 -46
- package/dist/matterbridge.js.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts +40 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.js +34 -0
- package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
- package/dist/matterbridgeBehaviors.d.ts +1166 -0
- package/dist/matterbridgeBehaviors.d.ts.map +1 -0
- package/dist/matterbridgeBehaviors.js +48 -1
- package/dist/matterbridgeBehaviors.js.map +1 -0
- package/dist/matterbridgeDeviceTypes.d.ts +494 -0
- package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
- package/dist/matterbridgeDeviceTypes.js +431 -12
- package/dist/matterbridgeDeviceTypes.js.map +1 -0
- package/dist/matterbridgeDynamicPlatform.d.ts +40 -0
- package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
- package/dist/matterbridgeDynamicPlatform.js +34 -0
- package/dist/matterbridgeDynamicPlatform.js.map +1 -0
- package/dist/matterbridgeEndpoint.d.ts +956 -0
- package/dist/matterbridgeEndpoint.d.ts.map +1 -0
- package/dist/matterbridgeEndpoint.js +801 -11
- package/dist/matterbridgeEndpoint.js.map +1 -0
- package/dist/matterbridgeEndpointHelpers.d.ts +2706 -0
- package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
- package/dist/matterbridgeEndpointHelpers.js +142 -9
- package/dist/matterbridgeEndpointHelpers.js.map +1 -0
- package/dist/matterbridgePlatform.d.ts +294 -0
- package/dist/matterbridgePlatform.d.ts.map +1 -0
- package/dist/matterbridgePlatform.js +225 -7
- package/dist/matterbridgePlatform.js.map +1 -0
- package/dist/matterbridgeTypes.d.ts +187 -0
- package/dist/matterbridgeTypes.d.ts.map +1 -0
- package/dist/matterbridgeTypes.js +24 -0
- package/dist/matterbridgeTypes.js.map +1 -0
- package/dist/pluginManager.d.ts +273 -0
- package/dist/pluginManager.d.ts.map +1 -0
- package/dist/pluginManager.js +264 -3
- package/dist/pluginManager.js.map +1 -0
- package/dist/shelly.d.ts +92 -0
- package/dist/shelly.d.ts.map +1 -0
- package/dist/shelly.js +146 -6
- package/dist/shelly.js.map +1 -0
- package/dist/storage/export.d.ts +2 -0
- package/dist/storage/export.d.ts.map +1 -0
- package/dist/storage/export.js +1 -0
- package/dist/storage/export.js.map +1 -0
- package/dist/update.d.ts +32 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +52 -0
- package/dist/update.js.map +1 -0
- package/dist/utils/colorUtils.d.ts +61 -0
- package/dist/utils/colorUtils.d.ts.map +1 -0
- package/dist/utils/colorUtils.js +205 -2
- package/dist/utils/colorUtils.js.map +1 -0
- package/dist/utils/copyDirectory.d.ts +32 -0
- package/dist/utils/copyDirectory.d.ts.map +1 -0
- package/dist/utils/copyDirectory.js +37 -1
- package/dist/utils/copyDirectory.js.map +1 -0
- package/dist/utils/createZip.d.ts +38 -0
- package/dist/utils/createZip.d.ts.map +1 -0
- package/dist/utils/createZip.js +42 -2
- package/dist/utils/createZip.js.map +1 -0
- package/dist/utils/deepCopy.d.ts +31 -0
- package/dist/utils/deepCopy.d.ts.map +1 -0
- package/dist/utils/deepCopy.js +40 -0
- package/dist/utils/deepCopy.js.map +1 -0
- package/dist/utils/deepEqual.d.ts +53 -0
- package/dist/utils/deepEqual.d.ts.map +1 -0
- package/dist/utils/deepEqual.js +65 -1
- package/dist/utils/deepEqual.js.map +1 -0
- package/dist/utils/export.d.ts +10 -0
- package/dist/utils/export.d.ts.map +1 -0
- package/dist/utils/export.js +1 -0
- package/dist/utils/export.js.map +1 -0
- package/dist/utils/isvalid.d.ts +95 -0
- package/dist/utils/isvalid.d.ts.map +1 -0
- package/dist/utils/isvalid.js +93 -0
- package/dist/utils/isvalid.js.map +1 -0
- package/dist/utils/network.d.ts +69 -0
- package/dist/utils/network.d.ts.map +1 -0
- package/dist/utils/network.js +76 -5
- package/dist/utils/network.js.map +1 -0
- package/dist/utils/parameter.d.ts +58 -0
- package/dist/utils/parameter.d.ts.map +1 -0
- package/dist/utils/parameter.js +53 -0
- package/dist/utils/parameter.js.map +1 -0
- package/dist/utils/wait.d.ts +43 -0
- package/dist/utils/wait.d.ts.map +1 -0
- package/dist/utils/wait.js +48 -5
- package/dist/utils/wait.js.map +1 -0
- package/frontend/build/asset-manifest.json +3 -3
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/js/{main.f221e2c1.js → main.15906009.js} +3 -3
- package/frontend/build/static/js/{main.f221e2c1.js.map → main.15906009.js.map} +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
- /package/frontend/build/static/js/{main.f221e2c1.js.LICENSE.txt → main.15906009.js.LICENSE.txt} +0 -0
package/dist/utils/network.js
CHANGED
|
@@ -1,8 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the network function.
|
|
3
|
+
*
|
|
4
|
+
* @file network.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2024-02-17
|
|
7
|
+
* @version 1.0.0
|
|
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
|
|
1
24
|
import os from 'node:os';
|
|
25
|
+
// AnsiLogger module
|
|
2
26
|
import { AnsiLogger, idn, rs } from '../logger/export.js';
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves the IPv4 address of the first non-internal network interface.
|
|
29
|
+
* @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
|
|
30
|
+
*/
|
|
3
31
|
export function getIpv4InterfaceAddress() {
|
|
4
32
|
let ipv4Address;
|
|
5
33
|
const networkInterfaces = os.networkInterfaces();
|
|
34
|
+
// console.log('Available Network Interfaces:', networkInterfaces);
|
|
6
35
|
for (const interfaceDetails of Object.values(networkInterfaces)) {
|
|
7
36
|
if (!interfaceDetails) {
|
|
8
37
|
break;
|
|
@@ -16,11 +45,17 @@ export function getIpv4InterfaceAddress() {
|
|
|
16
45
|
break;
|
|
17
46
|
}
|
|
18
47
|
}
|
|
48
|
+
// console.log('Selected Network Interfaces:', ipv4Address);
|
|
19
49
|
return ipv4Address;
|
|
20
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves the IPv6 address of the first non-internal network interface.
|
|
53
|
+
* @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
|
|
54
|
+
*/
|
|
21
55
|
export function getIpv6InterfaceAddress() {
|
|
22
56
|
let ipv6Address;
|
|
23
57
|
const networkInterfaces = os.networkInterfaces();
|
|
58
|
+
// console.log('Available Network Interfaces:', networkInterfaces);
|
|
24
59
|
for (const interfaceDetails of Object.values(networkInterfaces)) {
|
|
25
60
|
if (!interfaceDetails) {
|
|
26
61
|
break;
|
|
@@ -34,11 +69,17 @@ export function getIpv6InterfaceAddress() {
|
|
|
34
69
|
break;
|
|
35
70
|
}
|
|
36
71
|
}
|
|
72
|
+
// console.log('Selected Network Interfaces:', ipv6Address);
|
|
37
73
|
return ipv6Address;
|
|
38
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Retrieves the mac address of the first non-internal network interface.
|
|
77
|
+
* @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
|
|
78
|
+
*/
|
|
39
79
|
export function getMacAddress() {
|
|
40
80
|
let macAddress;
|
|
41
81
|
const networkInterfaces = os.networkInterfaces();
|
|
82
|
+
// console.log('Available Network Interfaces:', networkInterfaces);
|
|
42
83
|
for (const interfaceDetails of Object.values(networkInterfaces)) {
|
|
43
84
|
if (!interfaceDetails) {
|
|
44
85
|
break;
|
|
@@ -54,9 +95,13 @@ export function getMacAddress() {
|
|
|
54
95
|
}
|
|
55
96
|
return macAddress;
|
|
56
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Logs the available network interfaces and their details.
|
|
100
|
+
* @param {boolean} log - Whether to enable logging of network interface details.
|
|
101
|
+
*/
|
|
57
102
|
export function logInterfaces(debug = true) {
|
|
58
|
-
const log = new AnsiLogger({ logName: 'MatterbridgeUtils', logTimestampFormat: 4
|
|
59
|
-
log.logLevel = "info"
|
|
103
|
+
const log = new AnsiLogger({ logName: 'MatterbridgeUtils', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: "info" /* LogLevel.INFO */ });
|
|
104
|
+
log.logLevel = "info" /* LogLevel.INFO */;
|
|
60
105
|
log.logName = 'LogInterfaces';
|
|
61
106
|
const networkInterfaces = os.networkInterfaces();
|
|
62
107
|
if (debug)
|
|
@@ -72,16 +117,36 @@ export function logInterfaces(debug = true) {
|
|
|
72
117
|
}
|
|
73
118
|
}
|
|
74
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Resolves the given hostname to an IP address.
|
|
122
|
+
*
|
|
123
|
+
* @param {string} hostname - The hostname to resolve.
|
|
124
|
+
* @param {0 | 4 | 6} [family=4] - The address family to use (0 for any, 4 for IPv4, 6 for IPv6). Default is 4.
|
|
125
|
+
* @returns {Promise<string | null>} - A promise that resolves to the IP address or null if not found.
|
|
126
|
+
*
|
|
127
|
+
* @remarks
|
|
128
|
+
* This function uses DNS lookup to resolve the hostname, which can take some time to complete.
|
|
129
|
+
*/
|
|
75
130
|
export async function resolveHostname(hostname, family = 4) {
|
|
76
131
|
const dns = await import('node:dns');
|
|
77
132
|
try {
|
|
78
|
-
const addresses = await dns.promises.lookup(hostname.toLowerCase()
|
|
133
|
+
const addresses = await dns.promises.lookup(hostname.toLowerCase() /* + '.local'*/, { family });
|
|
79
134
|
return addresses.address;
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
80
136
|
}
|
|
81
137
|
catch (error) {
|
|
82
138
|
return null;
|
|
83
139
|
}
|
|
84
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Retrieves the version of an npm package from the npm registry.
|
|
143
|
+
*
|
|
144
|
+
* @param {string} packageName - The name of the npm package.
|
|
145
|
+
* @param {string} [tag='latest'] - The tag of the package version to retrieve (default is 'latest').
|
|
146
|
+
* @param {number} [timeout=5000] - The timeout duration in milliseconds (default is 5000ms).
|
|
147
|
+
* @returns {Promise<string>} A promise that resolves to the version string of the package.
|
|
148
|
+
* @throws {Error} If the request fails or the tag is not found.
|
|
149
|
+
*/
|
|
85
150
|
export async function getNpmPackageVersion(packageName, tag = 'latest', timeout = 10000) {
|
|
86
151
|
const https = await import('https');
|
|
87
152
|
return new Promise((resolve, reject) => {
|
|
@@ -95,8 +160,8 @@ export async function getNpmPackageVersion(packageName, tag = 'latest', timeout
|
|
|
95
160
|
let data = '';
|
|
96
161
|
if (res.statusCode !== 200) {
|
|
97
162
|
clearTimeout(timeoutId);
|
|
98
|
-
res.resume();
|
|
99
|
-
req.destroy();
|
|
163
|
+
res.resume(); // Discard response data to close the socket properly
|
|
164
|
+
req.destroy(); // Forcefully close the request
|
|
100
165
|
reject(new Error(`Failed to fetch data. Status code: ${res.statusCode}`));
|
|
101
166
|
return;
|
|
102
167
|
}
|
|
@@ -107,6 +172,7 @@ export async function getNpmPackageVersion(packageName, tag = 'latest', timeout
|
|
|
107
172
|
clearTimeout(timeoutId);
|
|
108
173
|
try {
|
|
109
174
|
const jsonData = JSON.parse(data);
|
|
175
|
+
// console.log(`Package ${packageName} tag ${tag}`, jsonData);
|
|
110
176
|
const version = jsonData['dist-tags']?.[tag];
|
|
111
177
|
if (version) {
|
|
112
178
|
resolve(version);
|
|
@@ -126,6 +192,10 @@ export async function getNpmPackageVersion(packageName, tag = 'latest', timeout
|
|
|
126
192
|
});
|
|
127
193
|
});
|
|
128
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Retrieves the path to the global Node.js modules directory.
|
|
197
|
+
* @returns A promise that resolves to the path of the global Node.js modules directory.
|
|
198
|
+
*/
|
|
129
199
|
export async function getGlobalNodeModules() {
|
|
130
200
|
const { exec } = await import('node:child_process');
|
|
131
201
|
return new Promise((resolve, reject) => {
|
|
@@ -139,3 +209,4 @@ export async function getGlobalNodeModules() {
|
|
|
139
209
|
});
|
|
140
210
|
});
|
|
141
211
|
}
|
|
212
|
+
//# sourceMappingURL=network.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/utils/network.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,kBAAkB;AAClB,OAAO,EAAE,MAAM,SAAS,CAAC;AAKzB,oBAAoB;AACpB,OAAO,EAAE,UAAU,EAAE,GAAG,EAAY,EAAE,EAAmB,MAAM,qBAAqB,CAAC;AAErF;;;GAGG;AACH,MAAM,UAAU,uBAAuB;IACrC,IAAI,WAA+B,CAAC;IACpC,MAAM,iBAAiB,GAAG,EAAE,CAAC,iBAAiB,EAAE,CAAC;IACjD,mEAAmE;IACnE,KAAK,MAAM,gBAAgB,IAAI,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAChE,IAAI,CAAC,gBAAgB,EAAE,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AAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACzF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;IACpD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,CAAC,aAAa,EAAE,CAAC,KAA2B,EAAE,MAAc,EAAE,EAAE;YAClE,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,CAAC,KAAK,CAAC,CAAC;YAChB,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;YACzB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the deepEqual function.
|
|
3
|
+
*
|
|
4
|
+
* @file parameter.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2025-02-16
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License. *
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Checks if a command-line parameter is present.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} name - The name of the parameter to check.
|
|
27
|
+
* @returns {boolean} True if the parameter is present, otherwise false.
|
|
28
|
+
*/
|
|
29
|
+
export declare function hasParameter(name: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Retrieves the value of a command-line parameter.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} name - The name of the parameter to retrieve.
|
|
34
|
+
* @returns {string | undefined} The value of the parameter, or undefined if not found.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getParameter(name: string): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves the value of a command-line parameter as an integer.
|
|
39
|
+
*
|
|
40
|
+
* @param {string} name - The name of the parameter to retrieve.
|
|
41
|
+
* @returns {number | undefined} The integer value of the parameter, or undefined if not found or invalid.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getIntParameter(name: string): number | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves the value of a command-line parameter as a number array.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} name - The name of the parameter to retrieve.
|
|
48
|
+
* @returns {number[] | undefined} An array of string values for the parameter, or undefined if not found.
|
|
49
|
+
*/
|
|
50
|
+
export declare function getIntArrayParameter(name: string): number[] | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves the value of a command-line parameter as a string array.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} name - The name of the parameter to retrieve.
|
|
55
|
+
* @returns {string[] | undefined} An array of string values for the parameter, or undefined if not found.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getStringArrayParameter(name: string): string[] | undefined;
|
|
58
|
+
//# sourceMappingURL=parameter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameter.d.ts","sourceRoot":"","sources":["../../src/utils/parameter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKlD;AAID;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM7D;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMhE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAYvE;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAW1E"}
|
package/dist/utils/parameter.js
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the deepEqual function.
|
|
3
|
+
*
|
|
4
|
+
* @file parameter.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2025-02-16
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License. *
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Checks if a command-line parameter is present.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} name - The name of the parameter to check.
|
|
27
|
+
* @returns {boolean} True if the parameter is present, otherwise false.
|
|
28
|
+
*/
|
|
1
29
|
export function hasParameter(name) {
|
|
2
30
|
const commandArguments = process.argv.slice(2);
|
|
3
31
|
let markerIncluded = commandArguments.includes(`-${name}`);
|
|
@@ -6,6 +34,12 @@ export function hasParameter(name) {
|
|
|
6
34
|
return markerIncluded;
|
|
7
35
|
}
|
|
8
36
|
import { isValidNumber } from './export.js';
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves the value of a command-line parameter.
|
|
39
|
+
*
|
|
40
|
+
* @param {string} name - The name of the parameter to retrieve.
|
|
41
|
+
* @returns {string | undefined} The value of the parameter, or undefined if not found.
|
|
42
|
+
*/
|
|
9
43
|
export function getParameter(name) {
|
|
10
44
|
const commandArguments = process.argv.slice(2);
|
|
11
45
|
let markerIndex = commandArguments.indexOf(`-${name}`);
|
|
@@ -15,6 +49,12 @@ export function getParameter(name) {
|
|
|
15
49
|
return undefined;
|
|
16
50
|
return commandArguments[markerIndex + 1];
|
|
17
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Retrieves the value of a command-line parameter as an integer.
|
|
54
|
+
*
|
|
55
|
+
* @param {string} name - The name of the parameter to retrieve.
|
|
56
|
+
* @returns {number | undefined} The integer value of the parameter, or undefined if not found or invalid.
|
|
57
|
+
*/
|
|
18
58
|
export function getIntParameter(name) {
|
|
19
59
|
const value = getParameter(name);
|
|
20
60
|
if (value === undefined)
|
|
@@ -24,6 +64,12 @@ export function getIntParameter(name) {
|
|
|
24
64
|
return undefined;
|
|
25
65
|
return intValue;
|
|
26
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Retrieves the value of a command-line parameter as a number array.
|
|
69
|
+
*
|
|
70
|
+
* @param {string} name - The name of the parameter to retrieve.
|
|
71
|
+
* @returns {number[] | undefined} An array of string values for the parameter, or undefined if not found.
|
|
72
|
+
*/
|
|
27
73
|
export function getIntArrayParameter(name) {
|
|
28
74
|
const commandArguments = process.argv.slice(2);
|
|
29
75
|
let markerIndex = commandArguments.indexOf(`--${name}`);
|
|
@@ -41,6 +87,12 @@ export function getIntArrayParameter(name) {
|
|
|
41
87
|
return undefined;
|
|
42
88
|
return intValues;
|
|
43
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Retrieves the value of a command-line parameter as a string array.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} name - The name of the parameter to retrieve.
|
|
94
|
+
* @returns {string[] | undefined} An array of string values for the parameter, or undefined if not found.
|
|
95
|
+
*/
|
|
44
96
|
export function getStringArrayParameter(name) {
|
|
45
97
|
const commandArguments = process.argv.slice(2);
|
|
46
98
|
let markerIndex = commandArguments.indexOf(`--${name}`);
|
|
@@ -56,3 +108,4 @@ export function getStringArrayParameter(name) {
|
|
|
56
108
|
return undefined;
|
|
57
109
|
return values;
|
|
58
110
|
}
|
|
111
|
+
//# sourceMappingURL=parameter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameter.js","sourceRoot":"","sources":["../../src/utils/parameter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/C,IAAI,cAAc,GAAG,gBAAgB,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAC3D,IAAI,CAAC,cAAc;QAAE,cAAc,GAAG,gBAAgB,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC7E,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,C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
|
|
3
|
+
*
|
|
4
|
+
* @file wait.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2025-02-16
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License. *
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Asynchronous waiter function that resolves when the provided condition is met or rejects on timeout.
|
|
25
|
+
* @param {string} name - The name of the waiter.
|
|
26
|
+
* @param {() => boolean} check - A function that checks the condition. Should return a boolean.
|
|
27
|
+
* @param {boolean} [exitWithReject=false] - Optional. If true, the promise will be rejected on timeout. Default is false.
|
|
28
|
+
* @param {number} [resolveTimeout=5000] - Optional. The timeout duration in milliseconds. Default is 5000ms.
|
|
29
|
+
* @param {number} [resolveInterval=500] - Optional. The interval duration in milliseconds between condition checks. Default is 500ms.
|
|
30
|
+
* @param {boolean} [debug=false] - Optional. If true, debug messages will be logged to the console. Default is false.
|
|
31
|
+
* @returns {Promise<boolean>} A promise that resolves to true when the condition is met, or false if the timeout occurs.
|
|
32
|
+
*/
|
|
33
|
+
export declare function waiter(name: string, check: () => boolean, exitWithReject?: boolean, resolveTimeout?: number, resolveInterval?: number, debug?: boolean): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Asynchronously waits for a specified amount of time.
|
|
36
|
+
* @param {number} timeout - The duration to wait in milliseconds. Default is 1000ms.
|
|
37
|
+
* @param {string} name - The name of the wait operation. Default is undefined.
|
|
38
|
+
* @param {boolean} debug - Whether to enable debug logging. Default is false.
|
|
39
|
+
* @returns {Promise<void>} A Promise that resolves after the specified timeout.
|
|
40
|
+
*/
|
|
41
|
+
export declare function wait(timeout?: number, name?: string, debug?: boolean): Promise<void>;
|
|
42
|
+
export declare function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T>;
|
|
43
|
+
//# sourceMappingURL=wait.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait.d.ts","sourceRoot":"","sources":["../../src/utils/wait.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH;;;;;;;;;GASG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,OAAO,EAAE,cAAc,UAAQ,EAAE,cAAc,SAAO,EAAE,eAAe,SAAM,EAAE,KAAK,UAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAuBtK;AAED;;;;;;GAMG;AACH,wBAAsB,IAAI,CAAC,OAAO,SAAO,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAYtF;AAGD,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAa1E"}
|
package/dist/utils/wait.js
CHANGED
|
@@ -1,9 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the wait, waiter and withTimeout functions.
|
|
3
|
+
*
|
|
4
|
+
* @file wait.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2025-02-16
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License. *
|
|
22
|
+
*/
|
|
23
|
+
// AnsiLogger module
|
|
1
24
|
import { AnsiLogger } from '../logger/export.js';
|
|
2
|
-
const log = new AnsiLogger({ logName: 'MatterbridgeUtils', logTimestampFormat: 4
|
|
25
|
+
const log = new AnsiLogger({ logName: 'MatterbridgeUtils', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: "info" /* LogLevel.INFO */ });
|
|
26
|
+
/**
|
|
27
|
+
* Asynchronous waiter function that resolves when the provided condition is met or rejects on timeout.
|
|
28
|
+
* @param {string} name - The name of the waiter.
|
|
29
|
+
* @param {() => boolean} check - A function that checks the condition. Should return a boolean.
|
|
30
|
+
* @param {boolean} [exitWithReject=false] - Optional. If true, the promise will be rejected on timeout. Default is false.
|
|
31
|
+
* @param {number} [resolveTimeout=5000] - Optional. The timeout duration in milliseconds. Default is 5000ms.
|
|
32
|
+
* @param {number} [resolveInterval=500] - Optional. The interval duration in milliseconds between condition checks. Default is 500ms.
|
|
33
|
+
* @param {boolean} [debug=false] - Optional. If true, debug messages will be logged to the console. Default is false.
|
|
34
|
+
* @returns {Promise<boolean>} A promise that resolves to true when the condition is met, or false if the timeout occurs.
|
|
35
|
+
*/
|
|
3
36
|
export async function waiter(name, check, exitWithReject = false, resolveTimeout = 5000, resolveInterval = 500, debug = false) {
|
|
4
37
|
if (check())
|
|
5
38
|
return true;
|
|
6
|
-
log.logLevel = "debug"
|
|
39
|
+
log.logLevel = "debug" /* LogLevel.DEBUG */;
|
|
7
40
|
log.logName = 'Waiter';
|
|
8
41
|
if (debug)
|
|
9
42
|
log.debug(`Waiter "${name}" started...`);
|
|
@@ -29,11 +62,19 @@ export async function waiter(name, check, exitWithReject = false, resolveTimeout
|
|
|
29
62
|
}, resolveInterval);
|
|
30
63
|
});
|
|
31
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Asynchronously waits for a specified amount of time.
|
|
67
|
+
* @param {number} timeout - The duration to wait in milliseconds. Default is 1000ms.
|
|
68
|
+
* @param {string} name - The name of the wait operation. Default is undefined.
|
|
69
|
+
* @param {boolean} debug - Whether to enable debug logging. Default is false.
|
|
70
|
+
* @returns {Promise<void>} A Promise that resolves after the specified timeout.
|
|
71
|
+
*/
|
|
32
72
|
export async function wait(timeout = 1000, name, debug = false) {
|
|
33
|
-
log.logLevel = "debug"
|
|
73
|
+
log.logLevel = "debug" /* LogLevel.DEBUG */;
|
|
34
74
|
log.logName = 'Wait';
|
|
35
75
|
if (debug)
|
|
36
76
|
log.debug(`Wait "${name}" started...`);
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
78
|
return new Promise((resolve, reject) => {
|
|
38
79
|
const timeoutId = setTimeout(() => {
|
|
39
80
|
if (debug)
|
|
@@ -43,17 +84,19 @@ export async function wait(timeout = 1000, name, debug = false) {
|
|
|
43
84
|
}, timeout);
|
|
44
85
|
});
|
|
45
86
|
}
|
|
87
|
+
// Helper function to add a timeout to a promise
|
|
46
88
|
export function withTimeout(promise, ms) {
|
|
47
89
|
return new Promise((resolve, reject) => {
|
|
48
90
|
const timer = setTimeout(() => reject(new Error('Operation timed out')), ms);
|
|
49
91
|
promise
|
|
50
92
|
.then((result) => {
|
|
51
|
-
clearTimeout(timer);
|
|
93
|
+
clearTimeout(timer); // Prevent memory leak
|
|
52
94
|
resolve(result);
|
|
53
95
|
})
|
|
54
96
|
.catch((error) => {
|
|
55
|
-
clearTimeout(timer);
|
|
97
|
+
clearTimeout(timer); // Ensure timeout does not fire if promise rejects first
|
|
56
98
|
reject(error);
|
|
57
99
|
});
|
|
58
100
|
});
|
|
59
101
|
}
|
|
102
|
+
//# sourceMappingURL=wait.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait.js","sourceRoot":"","sources":["../../src/utils/wait.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,oBAAoB;AACpB,OAAO,EAAE,UAAU,EAA6B,MAAM,qBAAqB,CAAC;AAE5E,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,EAAE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,qCAA6B,EAAE,QAAQ,4BAAe,EAAE,CAAC,CAAC;AAEvI;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAY,EAAE,KAAoB,EAAE,cAAc,GAAG,KAAK,EAAE,cAAc,GAAG,IAAI,EAAE,eAAe,GAAG,GAAG,EAAE,KAAK,GAAG,KAAK;IAClJ,IAAI,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IACzB,GAAG,CAAC,QAAQ,+BAAiB,CAAC;IAC9B,GAAG,CAAC,OAAO,GAAG,QAAQ,CAAC;IACvB,IAAI,KAAK;QAAE,GAAG,CAAC,KAAK,CAAC,WAAW,IAAI,cAAc,CAAC,CAAC;IACpD,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9C,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;YAChC,IAAI,KAAK;gBAAE,GAAG,CAAC,KAAK,CAAC,WAAW,IAAI,2BAA2B,CAAC,CAAC;YACjE,YAAY,CAAC,SAAS,CAAC,CAAC;YACxB,aAAa,CAAC,UAAU,CAAC,CAAC;YAC1B,IAAI,cAAc;gBAAE,MAAM,CAAC,IAAI,KAAK,CAAC,WAAW,IAAI,2BA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AU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC7E,OAAO;aACJ,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YACf,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,sBAAsB;YAC3C,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,wDAAwD;YAC7E,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
3
|
"main.css": "./static/css/main.944b63c3.css",
|
|
4
|
-
"main.js": "./static/js/main.
|
|
4
|
+
"main.js": "./static/js/main.15906009.js",
|
|
5
5
|
"static/js/453.d855a71b.chunk.js": "./static/js/453.d855a71b.chunk.js",
|
|
6
6
|
"static/media/roboto-latin-700-normal.woff2": "./static/media/roboto-latin-700-normal.c4d6cab43bec89049809.woff2",
|
|
7
7
|
"static/media/roboto-latin-500-normal.woff2": "./static/media/roboto-latin-500-normal.599f66a60bdf974e578e.woff2",
|
|
@@ -77,11 +77,11 @@
|
|
|
77
77
|
"static/media/roboto-greek-ext-300-normal.woff": "./static/media/roboto-greek-ext-300-normal.60729cafbded24073dfb.woff",
|
|
78
78
|
"index.html": "./index.html",
|
|
79
79
|
"main.944b63c3.css.map": "./static/css/main.944b63c3.css.map",
|
|
80
|
-
"main.
|
|
80
|
+
"main.15906009.js.map": "./static/js/main.15906009.js.map",
|
|
81
81
|
"453.d855a71b.chunk.js.map": "./static/js/453.d855a71b.chunk.js.map"
|
|
82
82
|
},
|
|
83
83
|
"entrypoints": [
|
|
84
84
|
"static/css/main.944b63c3.css",
|
|
85
|
-
"static/js/main.
|
|
85
|
+
"static/js/main.15906009.js"
|
|
86
86
|
]
|
|
87
87
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><base href="./"><link rel="icon" href="./matterbridge 32x32.png"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>Matterbridge</title><link rel="manifest" href="./manifest.json"/><script defer="defer" src="./static/js/main.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><base href="./"><link rel="icon" href="./matterbridge 32x32.png"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>Matterbridge</title><link rel="manifest" href="./manifest.json"/><script defer="defer" src="./static/js/main.15906009.js"></script><link href="./static/css/main.944b63c3.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|