matterbridge 1.6.5-dev.3 → 1.6.5
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 +1 -1
- package/dist/cli.d.ts +25 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +26 -0
- 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 +46 -0
- package/dist/deviceManager.d.ts.map +1 -0
- package/dist/deviceManager.js +26 -1
- package/dist/deviceManager.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- 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/export.d.ts +5 -0
- package/dist/matter/export.d.ts.map +1 -0
- package/dist/matter/export.js +1 -0
- package/dist/matter/export.js.map +1 -0
- package/dist/matterbridge.d.ts +466 -0
- package/dist/matterbridge.d.ts.map +1 -0
- package/dist/matterbridge.js +702 -62
- package/dist/matterbridge.js.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts +39 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.js +33 -0
- package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
- package/dist/matterbridgeBehaviors.d.ts +934 -0
- package/dist/matterbridgeBehaviors.d.ts.map +1 -0
- package/dist/matterbridgeBehaviors.js +29 -1
- package/dist/matterbridgeBehaviors.js.map +1 -0
- package/dist/matterbridgeDevice.d.ts +6504 -0
- package/dist/matterbridgeDevice.d.ts.map +1 -0
- package/dist/matterbridgeDevice.js +919 -9
- package/dist/matterbridgeDevice.js.map +1 -0
- package/dist/matterbridgeDeviceTypes.d.ts +65 -0
- package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
- package/dist/matterbridgeDeviceTypes.js +40 -12
- package/dist/matterbridgeDeviceTypes.js.map +1 -0
- package/dist/matterbridgeDynamicPlatform.d.ts +39 -0
- package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
- package/dist/matterbridgeDynamicPlatform.js +33 -0
- package/dist/matterbridgeDynamicPlatform.js.map +1 -0
- package/dist/matterbridgeEdge.d.ts +89 -0
- package/dist/matterbridgeEdge.d.ts.map +1 -0
- package/dist/matterbridgeEdge.js +525 -0
- package/dist/matterbridgeEdge.js.map +1 -0
- package/dist/matterbridgeEndpoint.d.ts +8529 -0
- package/dist/matterbridgeEndpoint.d.ts.map +1 -0
- package/dist/matterbridgeEndpoint.js +997 -16
- package/dist/matterbridgeEndpoint.js.map +1 -0
- package/dist/matterbridgePlatform.d.ts +96 -0
- package/dist/matterbridgePlatform.d.ts.map +1 -0
- package/dist/matterbridgePlatform.js +74 -3
- package/dist/matterbridgePlatform.js.map +1 -0
- package/dist/matterbridgeTypes.d.ts +147 -0
- package/dist/matterbridgeTypes.d.ts.map +1 -0
- package/dist/matterbridgeTypes.js +24 -0
- package/dist/matterbridgeTypes.js.map +1 -0
- package/dist/matterbridgeWebsocket.d.ts +49 -0
- package/dist/matterbridgeWebsocket.d.ts.map +1 -0
- package/dist/matterbridgeWebsocket.js +45 -0
- package/dist/matterbridgeWebsocket.js.map +1 -0
- package/dist/pluginManager.d.ts +238 -0
- package/dist/pluginManager.d.ts.map +1 -0
- package/dist/pluginManager.js +231 -3
- package/dist/pluginManager.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/utils/colorUtils.d.ts +61 -0
- package/dist/utils/colorUtils.d.ts.map +1 -0
- package/dist/utils/colorUtils.js +78 -2
- package/dist/utils/colorUtils.js.map +1 -0
- package/dist/utils/export.d.ts +3 -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/utils.d.ts +221 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +252 -7
- package/dist/utils/utils.js.map +1 -0
- package/npm-shrinkwrap.json +8 -5
- package/package.json +1 -1
- package/tsconfig.production.json +3 -9
package/dist/pluginManager.js
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the Plugins class.
|
|
3
|
+
*
|
|
4
|
+
* @file plugins.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2024-07-14
|
|
7
|
+
* @version 1.1.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
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
24
|
+
// NodeStorage and AnsiLogger modules
|
|
1
25
|
import { AnsiLogger, BLUE, db, er, nf, nt, rs, UNDERLINE, UNDERLINEOFF, wr } from 'node-ansi-logger';
|
|
26
|
+
// Node.js modules
|
|
2
27
|
import path from 'path';
|
|
3
28
|
import { promises as fs } from 'fs';
|
|
4
29
|
import { pathToFileURL } from 'url';
|
|
@@ -12,8 +37,9 @@ export class PluginManager {
|
|
|
12
37
|
log;
|
|
13
38
|
constructor(matterbridge) {
|
|
14
39
|
this.matterbridge = matterbridge;
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
41
|
this.nodeContext = matterbridge.nodeContext;
|
|
16
|
-
this.log = new AnsiLogger({ logName: 'PluginManager', logTimestampFormat: 4
|
|
42
|
+
this.log = new AnsiLogger({ logName: 'PluginManager', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: matterbridge.log.logLevel });
|
|
17
43
|
this.log.debug('Matterbridge plugin manager starting...');
|
|
18
44
|
}
|
|
19
45
|
get length() {
|
|
@@ -48,6 +74,7 @@ export class PluginManager {
|
|
|
48
74
|
}
|
|
49
75
|
catch (error) {
|
|
50
76
|
this.log.error(`Error processing forEach plugin ${plg}${plugin.name}${er}:`, error);
|
|
77
|
+
// throw error;
|
|
51
78
|
}
|
|
52
79
|
});
|
|
53
80
|
await Promise.all(tasks);
|
|
@@ -58,13 +85,31 @@ export class PluginManager {
|
|
|
58
85
|
set logLevel(logLevel) {
|
|
59
86
|
this.log.logLevel = logLevel;
|
|
60
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Loads registered plugins from storage.
|
|
90
|
+
*
|
|
91
|
+
* This method retrieves an array of registered plugins from the storage and converts it
|
|
92
|
+
* into a map where the plugin names are the keys and the plugin objects are the values.
|
|
93
|
+
*
|
|
94
|
+
* @returns {Promise<RegisteredPlugin[]>} A promise that resolves to an array of registered plugins.
|
|
95
|
+
*/
|
|
61
96
|
async loadFromStorage() {
|
|
97
|
+
// Load the array from storage and convert it to a map
|
|
62
98
|
const pluginsArray = await this.nodeContext.get('plugins', []);
|
|
63
99
|
for (const plugin of pluginsArray)
|
|
64
100
|
this._plugins.set(plugin.name, plugin);
|
|
65
101
|
return pluginsArray;
|
|
66
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Loads registered plugins from storage.
|
|
105
|
+
*
|
|
106
|
+
* This method retrieves an array of registered plugins from the storage and converts it
|
|
107
|
+
* into a map where the plugin names are the keys and the plugin objects are the values.
|
|
108
|
+
*
|
|
109
|
+
* @returns {Promise<RegisteredPlugin[]>} A promise that resolves to an array of registered plugins.
|
|
110
|
+
*/
|
|
67
111
|
async saveToStorage() {
|
|
112
|
+
// Convert the map to an array
|
|
68
113
|
const plugins = [];
|
|
69
114
|
const pluginArrayFromMap = Array.from(this._plugins.values());
|
|
70
115
|
for (const plugin of pluginArrayFromMap) {
|
|
@@ -84,11 +129,18 @@ export class PluginManager {
|
|
|
84
129
|
this.log.debug(`Saved ${BLUE}${plugins.length}${db} plugins to storage`);
|
|
85
130
|
return plugins.length;
|
|
86
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Resolves the name of a plugin by loading and parsing its package.json file.
|
|
134
|
+
* @param pluginPath - The path to the plugin or the path to the plugin's package.json file.
|
|
135
|
+
* @returns The path to the resolved package.json file, or null if the package.json file is not found or does not contain a name.
|
|
136
|
+
*/
|
|
87
137
|
async resolve(pluginPath) {
|
|
88
138
|
if (!pluginPath.endsWith('package.json'))
|
|
89
139
|
pluginPath = path.join(pluginPath, 'package.json');
|
|
140
|
+
// Resolve the package.json of the plugin
|
|
90
141
|
let packageJsonPath = path.resolve(pluginPath);
|
|
91
142
|
this.log.debug(`Resolving plugin path ${plg}${packageJsonPath}${db}`);
|
|
143
|
+
// Check if the package.json file exists
|
|
92
144
|
try {
|
|
93
145
|
await fs.access(packageJsonPath);
|
|
94
146
|
}
|
|
@@ -98,11 +150,13 @@ export class PluginManager {
|
|
|
98
150
|
this.log.debug(`Trying at ${plg}${packageJsonPath}${db}`);
|
|
99
151
|
}
|
|
100
152
|
try {
|
|
153
|
+
// Load the package.json of the plugin
|
|
101
154
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
|
|
102
155
|
if (!packageJson.name) {
|
|
103
156
|
this.log.error(`Package.json name not found at ${packageJsonPath}`);
|
|
104
157
|
return null;
|
|
105
158
|
}
|
|
159
|
+
// Check for main issues
|
|
106
160
|
if (!packageJson.type || packageJson.type !== 'module') {
|
|
107
161
|
this.log.error(`Plugin at ${packageJsonPath} is not a module`);
|
|
108
162
|
return null;
|
|
@@ -115,6 +169,7 @@ export class PluginManager {
|
|
|
115
169
|
this.log.error(`Plugin at ${packageJsonPath} has no types in package.json`);
|
|
116
170
|
return null;
|
|
117
171
|
}
|
|
172
|
+
// Check for @project-chip packages in dependencies and devDependencies
|
|
118
173
|
const checkForProjectChipPackages = (dependencies) => {
|
|
119
174
|
return Object.keys(dependencies).filter((pkg) => pkg.startsWith('@project-chip') || pkg.startsWith('@matter'));
|
|
120
175
|
};
|
|
@@ -136,6 +191,7 @@ export class PluginManager {
|
|
|
136
191
|
this.log.error(`Please open an issue on the plugin repository to remove them.`);
|
|
137
192
|
return null;
|
|
138
193
|
}
|
|
194
|
+
// Check for matterbridge package in dependencies and devDependencies
|
|
139
195
|
const checkForMatterbridgePackage = (dependencies) => {
|
|
140
196
|
return Object.keys(dependencies).filter((pkg) => pkg === 'matterbridge');
|
|
141
197
|
};
|
|
@@ -165,6 +221,11 @@ export class PluginManager {
|
|
|
165
221
|
return null;
|
|
166
222
|
}
|
|
167
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Loads and parse the plugin package.json and returns it.
|
|
226
|
+
* @param plugin - The plugin to load the package from.
|
|
227
|
+
* @returns A Promise that resolves to the package.json object or undefined if the package.json could not be loaded.
|
|
228
|
+
*/
|
|
168
229
|
async parse(plugin) {
|
|
169
230
|
this.log.debug(`Parsing package.json of plugin ${plg}${plugin.name}${db}`);
|
|
170
231
|
try {
|
|
@@ -191,6 +252,7 @@ export class PluginManager {
|
|
|
191
252
|
this.log.warn(`Plugin ${plg}${plugin.name}${wr} has no path`);
|
|
192
253
|
if (!plugin.type)
|
|
193
254
|
this.log.warn(`Plugin ${plg}${plugin.name}${wr} has no type`);
|
|
255
|
+
// Check for @project-chip packages in dependencies and devDependencies
|
|
194
256
|
const checkForProjectChipPackages = (dependencies) => {
|
|
195
257
|
return Object.keys(dependencies).filter((pkg) => pkg.startsWith('@project-chip') || pkg.startsWith('@matter'));
|
|
196
258
|
};
|
|
@@ -212,6 +274,7 @@ export class PluginManager {
|
|
|
212
274
|
this.log.error(`Please open an issue on the plugin repository to remove them.`);
|
|
213
275
|
return null;
|
|
214
276
|
}
|
|
277
|
+
// Check for matterbridge package in dependencies and devDependencies
|
|
215
278
|
const checkForMatterbridgePackage = (dependencies) => {
|
|
216
279
|
return Object.keys(dependencies).filter((pkg) => pkg === 'matterbridge');
|
|
217
280
|
};
|
|
@@ -233,6 +296,7 @@ export class PluginManager {
|
|
|
233
296
|
this.log.error(`Please open an issue on the plugin repository to remove them.`);
|
|
234
297
|
return null;
|
|
235
298
|
}
|
|
299
|
+
// await this.saveToStorage(); // No need to save the plugin to storage
|
|
236
300
|
return packageJson;
|
|
237
301
|
}
|
|
238
302
|
catch (err) {
|
|
@@ -241,6 +305,16 @@ export class PluginManager {
|
|
|
241
305
|
return null;
|
|
242
306
|
}
|
|
243
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Enables a plugin by its name or path.
|
|
310
|
+
*
|
|
311
|
+
* This method enables a plugin by setting its `enabled` property to `true` and saving the updated
|
|
312
|
+
* plugin information to storage. It first checks if the plugin is already registered in the `_plugins` map.
|
|
313
|
+
* If not, it attempts to resolve the plugin's `package.json` file to retrieve its name and enable it.
|
|
314
|
+
*
|
|
315
|
+
* @param {string} nameOrPath - The name or path of the plugin to enable.
|
|
316
|
+
* @returns {Promise<RegisteredPlugin | null>} A promise that resolves to the enabled plugin object, or null if the plugin could not be enabled.
|
|
317
|
+
*/
|
|
244
318
|
async enable(nameOrPath) {
|
|
245
319
|
if (!nameOrPath || nameOrPath === '')
|
|
246
320
|
return null;
|
|
@@ -273,6 +347,16 @@ export class PluginManager {
|
|
|
273
347
|
return null;
|
|
274
348
|
}
|
|
275
349
|
}
|
|
350
|
+
/**
|
|
351
|
+
* Enables a plugin by its name or path.
|
|
352
|
+
*
|
|
353
|
+
* This method enables a plugin by setting its `enabled` property to `true` and saving the updated
|
|
354
|
+
* plugin information to storage. It first checks if the plugin is already registered in the `_plugins` map.
|
|
355
|
+
* If not, it attempts to resolve the plugin's `package.json` file to retrieve its name and enable it.
|
|
356
|
+
*
|
|
357
|
+
* @param {string} nameOrPath - The name or path of the plugin to enable.
|
|
358
|
+
* @returns {Promise<RegisteredPlugin | null>} A promise that resolves to the enabled plugin object, or null if the plugin could not be enabled.
|
|
359
|
+
*/
|
|
276
360
|
async disable(nameOrPath) {
|
|
277
361
|
if (!nameOrPath || nameOrPath === '')
|
|
278
362
|
return null;
|
|
@@ -305,6 +389,16 @@ export class PluginManager {
|
|
|
305
389
|
return null;
|
|
306
390
|
}
|
|
307
391
|
}
|
|
392
|
+
/**
|
|
393
|
+
* Removes a plugin by its name or path.
|
|
394
|
+
*
|
|
395
|
+
* This method removes a plugin from the `_plugins` map and saves the updated plugin information to storage.
|
|
396
|
+
* It first checks if the plugin is already registered in the `_plugins` map. If not, it attempts to resolve
|
|
397
|
+
* the plugin's `package.json` file to retrieve its name and remove it.
|
|
398
|
+
*
|
|
399
|
+
* @param {string} nameOrPath - The name or path of the plugin to remove.
|
|
400
|
+
* @returns {Promise<RegisteredPlugin | null>} A promise that resolves to the removed plugin object, or null if the plugin could not be removed.
|
|
401
|
+
*/
|
|
308
402
|
async remove(nameOrPath) {
|
|
309
403
|
if (!nameOrPath || nameOrPath === '')
|
|
310
404
|
return null;
|
|
@@ -337,6 +431,17 @@ export class PluginManager {
|
|
|
337
431
|
return null;
|
|
338
432
|
}
|
|
339
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* Adds a plugin by its name or path.
|
|
436
|
+
*
|
|
437
|
+
* This method adds a plugin to the `_plugins` map and saves the updated plugin information to storage.
|
|
438
|
+
* It first resolves the plugin's `package.json` file to retrieve its details. If the plugin is already
|
|
439
|
+
* registered, it logs an info message and returns null. Otherwise, it registers the plugin, enables it,
|
|
440
|
+
* and saves the updated plugin information to storage.
|
|
441
|
+
*
|
|
442
|
+
* @param {string} nameOrPath - The name or path of the plugin to add.
|
|
443
|
+
* @returns {Promise<RegisteredPlugin | null>} A promise that resolves to the added plugin object, or null if the plugin could not be added.
|
|
444
|
+
*/
|
|
340
445
|
async add(nameOrPath) {
|
|
341
446
|
if (!nameOrPath || nameOrPath === '')
|
|
342
447
|
return null;
|
|
@@ -362,6 +467,15 @@ export class PluginManager {
|
|
|
362
467
|
return null;
|
|
363
468
|
}
|
|
364
469
|
}
|
|
470
|
+
/**
|
|
471
|
+
* Installs a plugin by its name.
|
|
472
|
+
*
|
|
473
|
+
* This method first uninstalls any existing version of the plugin, then installs the plugin globally using npm.
|
|
474
|
+
* It logs the installation process and retrieves the installed version of the plugin.
|
|
475
|
+
*
|
|
476
|
+
* @param {string} name - The name of the plugin to install.
|
|
477
|
+
* @returns {Promise<string | undefined>} A promise that resolves to the installed version of the plugin, or undefined if the installation failed.
|
|
478
|
+
*/
|
|
365
479
|
async install(name) {
|
|
366
480
|
await this.uninstall(name);
|
|
367
481
|
this.log.info(`Installing plugin ${plg}${name}${nf}`);
|
|
@@ -375,11 +489,13 @@ export class PluginManager {
|
|
|
375
489
|
else {
|
|
376
490
|
this.log.info(`Installed plugin ${plg}${name}${nf}`);
|
|
377
491
|
this.log.debug(`Installed plugin ${plg}${name}${db}: ${stdout}`);
|
|
492
|
+
// Get the installed version
|
|
378
493
|
exec(`npm list -g ${name} --depth=0`, (listError, listStdout, listStderr) => {
|
|
379
494
|
if (listError) {
|
|
380
495
|
this.log.error(`List error: ${listError}`);
|
|
381
496
|
resolve(undefined);
|
|
382
497
|
}
|
|
498
|
+
// Clean the output to get only the package name and version
|
|
383
499
|
const lines = listStdout.split('\n');
|
|
384
500
|
const versionLine = lines.find((line) => line.includes(`${name}@`));
|
|
385
501
|
if (versionLine) {
|
|
@@ -395,6 +511,15 @@ export class PluginManager {
|
|
|
395
511
|
});
|
|
396
512
|
});
|
|
397
513
|
}
|
|
514
|
+
/**
|
|
515
|
+
* Uninstalls a plugin by its name.
|
|
516
|
+
*
|
|
517
|
+
* This method uninstalls a globally installed plugin using npm. It logs the uninstallation process
|
|
518
|
+
* and returns the name of the uninstalled plugin if successful, or undefined if the uninstallation failed.
|
|
519
|
+
*
|
|
520
|
+
* @param {string} name - The name of the plugin to uninstall.
|
|
521
|
+
* @returns {Promise<string | undefined>} A promise that resolves to the name of the uninstalled plugin, or undefined if the uninstallation failed.
|
|
522
|
+
*/
|
|
398
523
|
async uninstall(name) {
|
|
399
524
|
this.log.info(`Uninstalling plugin ${plg}${name}${nf}`);
|
|
400
525
|
return new Promise((resolve, reject) => {
|
|
@@ -412,6 +537,14 @@ export class PluginManager {
|
|
|
412
537
|
});
|
|
413
538
|
});
|
|
414
539
|
}
|
|
540
|
+
/**
|
|
541
|
+
* Loads a plugin and returns the corresponding MatterbridgePlatform instance.
|
|
542
|
+
* @param plugin - The plugin to load.
|
|
543
|
+
* @param start - Optional flag indicating whether to start the plugin after loading. Default is false.
|
|
544
|
+
* @param message - Optional message to pass to the plugin when starting.
|
|
545
|
+
* @returns A Promise that resolves to the loaded MatterbridgePlatform instance.
|
|
546
|
+
* @throws An error if the plugin is not enabled, already loaded, or fails to load.
|
|
547
|
+
*/
|
|
415
548
|
async load(plugin, start = false, message = '', configure = false) {
|
|
416
549
|
if (!plugin.enabled) {
|
|
417
550
|
this.log.error(`Plugin ${plg}${plugin.name}${er} not enabled`);
|
|
@@ -423,14 +556,19 @@ export class PluginManager {
|
|
|
423
556
|
}
|
|
424
557
|
this.log.info(`Loading plugin ${plg}${plugin.name}${nf} type ${typ}${plugin.type}${nf}`);
|
|
425
558
|
try {
|
|
559
|
+
// Load the package.json of the plugin
|
|
426
560
|
const packageJson = JSON.parse(await fs.readFile(plugin.path, 'utf8'));
|
|
561
|
+
// Resolve the main module path relative to package.json
|
|
427
562
|
const pluginEntry = path.resolve(path.dirname(plugin.path), packageJson.main);
|
|
563
|
+
// Dynamically import the plugin
|
|
428
564
|
const pluginUrl = pathToFileURL(pluginEntry);
|
|
429
565
|
this.log.debug(`Importing plugin ${plg}${plugin.name}${db} from ${pluginUrl.href}`);
|
|
430
566
|
const pluginInstance = await import(pluginUrl.href);
|
|
431
567
|
this.log.debug(`Imported plugin ${plg}${plugin.name}${db} from ${pluginUrl.href}`);
|
|
568
|
+
// Call the default export function of the plugin, passing this MatterBridge instance, the log and the config
|
|
432
569
|
if (pluginInstance.default) {
|
|
433
570
|
const config = await this.loadConfig(plugin);
|
|
571
|
+
// Preset the plugin properties here in case the plugin throws an error during loading. In this case the user can change the config and restart the plugin.
|
|
434
572
|
plugin.name = packageJson.name;
|
|
435
573
|
plugin.description = packageJson.description ?? 'No description';
|
|
436
574
|
plugin.version = packageJson.version;
|
|
@@ -439,7 +577,7 @@ export class PluginManager {
|
|
|
439
577
|
plugin.schemaJson = await this.loadSchema(plugin);
|
|
440
578
|
config.name = plugin.name;
|
|
441
579
|
config.version = packageJson.version;
|
|
442
|
-
const log = new AnsiLogger({ logName: plugin.description ?? 'No description', logTimestampFormat: 4
|
|
580
|
+
const log = new AnsiLogger({ logName: plugin.description ?? 'No description', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: config.debug ? "debug" /* LogLevel.DEBUG */ : this.matterbridge.log.logLevel });
|
|
443
581
|
const platform = pluginInstance.default(this.matterbridge, log, config);
|
|
444
582
|
config.type = platform.type;
|
|
445
583
|
platform.name = packageJson.name;
|
|
@@ -456,7 +594,7 @@ export class PluginManager {
|
|
|
456
594
|
plugin.addedDevices = 0;
|
|
457
595
|
plugin.configJson = config;
|
|
458
596
|
plugin.schemaJson = await this.loadSchema(plugin);
|
|
459
|
-
await this.saveToStorage();
|
|
597
|
+
await this.saveToStorage(); // Save the plugin to storage
|
|
460
598
|
this.log.notice(`Loaded plugin ${plg}${plugin.name}${nf} type ${typ}${platform.type}${db} (entrypoint ${UNDERLINE}${pluginEntry}${UNDERLINEOFF})`);
|
|
461
599
|
if (start)
|
|
462
600
|
await this.start(plugin, message, false);
|
|
@@ -475,6 +613,14 @@ export class PluginManager {
|
|
|
475
613
|
}
|
|
476
614
|
return undefined;
|
|
477
615
|
}
|
|
616
|
+
/**
|
|
617
|
+
* Starts a plugin.
|
|
618
|
+
*
|
|
619
|
+
* @param {RegisteredPlugin} plugin - The plugin to start.
|
|
620
|
+
* @param {string} [message] - Optional message to pass to the plugin's onStart method.
|
|
621
|
+
* @param {boolean} [configure] - Indicates whether to configure the plugin after starting (default false).
|
|
622
|
+
* @returns {Promise<RegisteredPlugin | undefined>} A promise that resolves when the plugin is started successfully, or rejects with an error if starting the plugin fails.
|
|
623
|
+
*/
|
|
478
624
|
async start(plugin, message, configure = false) {
|
|
479
625
|
if (!plugin.loaded) {
|
|
480
626
|
this.log.error(`Plugin ${plg}${plugin.name}${er} not loaded`);
|
|
@@ -504,6 +650,12 @@ export class PluginManager {
|
|
|
504
650
|
}
|
|
505
651
|
return undefined;
|
|
506
652
|
}
|
|
653
|
+
/**
|
|
654
|
+
* Configures a plugin.
|
|
655
|
+
*
|
|
656
|
+
* @param {RegisteredPlugin} plugin - The plugin to configure.
|
|
657
|
+
* @returns {Promise<void>} A promise that resolves when the plugin is configured successfully, or rejects with an error if configuration fails.
|
|
658
|
+
*/
|
|
507
659
|
async configure(plugin) {
|
|
508
660
|
if (!plugin.loaded) {
|
|
509
661
|
this.log.error(`Plugin ${plg}${plugin.name}${er} not loaded`);
|
|
@@ -526,6 +678,7 @@ export class PluginManager {
|
|
|
526
678
|
await plugin.platform.onConfigure();
|
|
527
679
|
this.log.notice(`Configured plugin ${plg}${plugin.name}${nt} type ${typ}${plugin.type}${nt}`);
|
|
528
680
|
plugin.configured = true;
|
|
681
|
+
// await this.saveConfigFromPlugin(plugin);
|
|
529
682
|
return plugin;
|
|
530
683
|
}
|
|
531
684
|
catch (err) {
|
|
@@ -534,6 +687,18 @@ export class PluginManager {
|
|
|
534
687
|
}
|
|
535
688
|
return undefined;
|
|
536
689
|
}
|
|
690
|
+
/**
|
|
691
|
+
* Shuts down a plugin.
|
|
692
|
+
*
|
|
693
|
+
* This method shuts down a plugin by calling its `onShutdown` method and resetting its state.
|
|
694
|
+
* It logs the shutdown process and optionally removes all devices associated with the plugin.
|
|
695
|
+
*
|
|
696
|
+
* @param {RegisteredPlugin} plugin - The plugin to shut down.
|
|
697
|
+
* @param {string} [reason] - The reason for shutting down the plugin.
|
|
698
|
+
* @param {boolean} [removeAllDevices=false] - Whether to remove all devices associated with the plugin.
|
|
699
|
+
* @param {boolean} [force=false] - Whether to force the shutdown even if the plugin is not loaded or started.
|
|
700
|
+
* @returns {Promise<RegisteredPlugin | undefined>} A promise that resolves to the shut down plugin object, or undefined if the shutdown failed.
|
|
701
|
+
*/
|
|
537
702
|
async shutdown(plugin, reason, removeAllDevices = false, force = false) {
|
|
538
703
|
this.log.debug(`Shutting down plugin ${plg}${plugin.name}${db}`);
|
|
539
704
|
if (!plugin.loaded) {
|
|
@@ -577,6 +742,15 @@ export class PluginManager {
|
|
|
577
742
|
}
|
|
578
743
|
return undefined;
|
|
579
744
|
}
|
|
745
|
+
/**
|
|
746
|
+
* Loads the configuration for a plugin.
|
|
747
|
+
* If the configuration file exists, it reads the file and returns the parsed JSON data.
|
|
748
|
+
* If the configuration file does not exist, it creates a new file with default configuration and returns it.
|
|
749
|
+
* If any error occurs during file access or creation, it logs an error and return un empty config.
|
|
750
|
+
*
|
|
751
|
+
* @param plugin - The plugin for which to load the configuration.
|
|
752
|
+
* @returns A promise that resolves to the loaded or created configuration.
|
|
753
|
+
*/
|
|
580
754
|
async loadConfig(plugin) {
|
|
581
755
|
const configFile = path.join(this.matterbridge.matterbridgeDirectory, `${plugin.name}.config.json`);
|
|
582
756
|
try {
|
|
@@ -584,6 +758,8 @@ export class PluginManager {
|
|
|
584
758
|
const data = await fs.readFile(configFile, 'utf8');
|
|
585
759
|
const config = JSON.parse(data);
|
|
586
760
|
this.log.debug(`Loaded config file ${configFile} for plugin ${plg}${plugin.name}${db}.`);
|
|
761
|
+
// this.log.debug(`Loaded config file ${configFile} for plugin ${plg}${plugin.name}${db}.\nConfig:${rs}\n`, config);
|
|
762
|
+
// The first time a plugin is added to the system, the config file is created with the plugin name and type "AnyPlatform".
|
|
587
763
|
config.name = plugin.name;
|
|
588
764
|
config.type = plugin.type;
|
|
589
765
|
if (config.debug === undefined)
|
|
@@ -608,6 +784,7 @@ export class PluginManager {
|
|
|
608
784
|
try {
|
|
609
785
|
await fs.writeFile(configFile, JSON.stringify(config, null, 2), 'utf8');
|
|
610
786
|
this.log.debug(`Created config file ${configFile} for plugin ${plg}${plugin.name}${db}.`);
|
|
787
|
+
// this.log.debug(`Created config file ${configFile} for plugin ${plg}${plugin.name}${db}.\nConfig:${rs}\n`, config);
|
|
611
788
|
return config;
|
|
612
789
|
}
|
|
613
790
|
catch (err) {
|
|
@@ -624,6 +801,18 @@ export class PluginManager {
|
|
|
624
801
|
return { name: plugin.name, type: plugin.type, debug: false, unregisterOnShutdown: false };
|
|
625
802
|
}
|
|
626
803
|
}
|
|
804
|
+
/**
|
|
805
|
+
* Saves the configuration of a plugin to a file.
|
|
806
|
+
*
|
|
807
|
+
* This method saves the configuration of the specified plugin to a JSON file in the matterbridge directory.
|
|
808
|
+
* If the plugin's configuration is not found, it logs an error and rejects the promise. If the configuration
|
|
809
|
+
* is successfully saved, it logs a debug message. If an error occurs during the file write operation, it logs
|
|
810
|
+
* the error and rejects the promise.
|
|
811
|
+
*
|
|
812
|
+
* @param {RegisteredPlugin} plugin - The plugin whose configuration is to be saved.
|
|
813
|
+
* @returns {Promise<void>} A promise that resolves when the configuration is successfully saved, or rejects if an error occurs.
|
|
814
|
+
* @throws {Error} If the plugin's configuration is not found.
|
|
815
|
+
*/
|
|
627
816
|
async saveConfigFromPlugin(plugin) {
|
|
628
817
|
if (!plugin.platform?.config) {
|
|
629
818
|
this.log.error(`Error saving config file for plugin ${plg}${plugin.name}${er}: config not found`);
|
|
@@ -633,6 +822,7 @@ export class PluginManager {
|
|
|
633
822
|
try {
|
|
634
823
|
await fs.writeFile(configFile, JSON.stringify(plugin.platform.config, null, 2), 'utf8');
|
|
635
824
|
this.log.debug(`Saved config file ${configFile} for plugin ${plg}${plugin.name}${db}`);
|
|
825
|
+
// this.log.debug(`Saved config file ${configFile} for plugin ${plg}${plugin.name}${db}.\nConfig:${rs}\n`, plugin.platform.config);
|
|
636
826
|
return Promise.resolve();
|
|
637
827
|
}
|
|
638
828
|
catch (err) {
|
|
@@ -640,6 +830,19 @@ export class PluginManager {
|
|
|
640
830
|
return Promise.reject(err);
|
|
641
831
|
}
|
|
642
832
|
}
|
|
833
|
+
/**
|
|
834
|
+
* Saves the configuration of a plugin from a JSON object to a file.
|
|
835
|
+
*
|
|
836
|
+
* This method saves the provided configuration of the specified plugin to a JSON file in the matterbridge directory.
|
|
837
|
+
* It first checks if the configuration data is valid by ensuring it contains the correct name and type, and matches
|
|
838
|
+
* the plugin's name. If the configuration data is invalid, it logs an error and returns. If the configuration is
|
|
839
|
+
* successfully saved, it updates the plugin's `configJson` property and logs a debug message. If an error occurs
|
|
840
|
+
* during the file write operation, it logs the error and returns.
|
|
841
|
+
*
|
|
842
|
+
* @param {RegisteredPlugin} plugin - The plugin whose configuration is to be saved.
|
|
843
|
+
* @param {PlatformConfig} config - The configuration data to be saved.
|
|
844
|
+
* @returns {Promise<void>} A promise that resolves when the configuration is successfully saved, or returns if an error occurs.
|
|
845
|
+
*/
|
|
643
846
|
async saveConfigFromJson(plugin, config) {
|
|
644
847
|
if (!config.name || !config.type || config.name !== plugin.name) {
|
|
645
848
|
this.log.error(`Error saving config file for plugin ${plg}${plugin.name}${er}. Wrong config data content:${rs}\n`, config);
|
|
@@ -650,12 +853,24 @@ export class PluginManager {
|
|
|
650
853
|
await fs.writeFile(configFile, JSON.stringify(config, null, 2), 'utf8');
|
|
651
854
|
plugin.configJson = config;
|
|
652
855
|
this.log.debug(`Saved config file ${configFile} for plugin ${plg}${plugin.name}${db}`);
|
|
856
|
+
// this.log.debug(`Saved config file ${configFile} for plugin ${plg}${plugin.name}${db}.\nConfig:${rs}\n`, config);
|
|
653
857
|
}
|
|
654
858
|
catch (err) {
|
|
655
859
|
this.log.error(`Error saving config file ${configFile} for plugin ${plg}${plugin.name}${er}: ${err}`);
|
|
656
860
|
return;
|
|
657
861
|
}
|
|
658
862
|
}
|
|
863
|
+
/**
|
|
864
|
+
* Loads the schema for a plugin.
|
|
865
|
+
*
|
|
866
|
+
* This method attempts to load the schema file for the specified plugin. If the schema file is found,
|
|
867
|
+
* it reads and parses the file, updates the schema's title and description, and logs the process.
|
|
868
|
+
* It also attempts to delete any old schema file from the matterbridge directory. If the schema file
|
|
869
|
+
* is not found, it logs the event and loads a default schema for the plugin.
|
|
870
|
+
*
|
|
871
|
+
* @param {RegisteredPlugin} plugin - The plugin whose schema is to be loaded.
|
|
872
|
+
* @returns {Promise<PlatformSchema>} A promise that resolves to the loaded schema object, or the default schema if the schema file is not found.
|
|
873
|
+
*/
|
|
659
874
|
async loadSchema(plugin) {
|
|
660
875
|
let schemaFile = plugin.path.replace('package.json', `${plugin.name}.schema.json`);
|
|
661
876
|
try {
|
|
@@ -665,6 +880,8 @@ export class PluginManager {
|
|
|
665
880
|
schema.title = plugin.description;
|
|
666
881
|
schema.description = plugin.name + ' v. ' + plugin.version + ' by ' + plugin.author;
|
|
667
882
|
this.log.debug(`Loaded schema file ${schemaFile} for plugin ${plg}${plugin.name}${db}.`);
|
|
883
|
+
// this.log.debug(`Loaded schema file ${schemaFile} for plugin ${plg}${plugin.name}${db}.\nSchema:${rs}\n`, schema);
|
|
884
|
+
// Delete the schema file from old position
|
|
668
885
|
schemaFile = path.join(this.matterbridge.matterbridgeDirectory, `${plugin.name}.schema.json`);
|
|
669
886
|
try {
|
|
670
887
|
await fs.unlink(schemaFile);
|
|
@@ -680,6 +897,16 @@ export class PluginManager {
|
|
|
680
897
|
return this.getDefaultSchema(plugin);
|
|
681
898
|
}
|
|
682
899
|
}
|
|
900
|
+
/**
|
|
901
|
+
* Returns the default schema for a plugin.
|
|
902
|
+
*
|
|
903
|
+
* This method generates a default schema object for the specified plugin. The schema includes
|
|
904
|
+
* metadata such as the plugin's title, description, version, and author. It also defines the
|
|
905
|
+
* properties of the schema, including the plugin's name, type, debug flag, and unregisterOnShutdown flag.
|
|
906
|
+
*
|
|
907
|
+
* @param {RegisteredPlugin} plugin - The plugin for which the default schema is to be generated.
|
|
908
|
+
* @returns {PlatformSchema} The default schema object for the plugin.
|
|
909
|
+
*/
|
|
683
910
|
getDefaultSchema(plugin) {
|
|
684
911
|
return {
|
|
685
912
|
title: plugin.description,
|
|
@@ -710,3 +937,4 @@ export class PluginManager {
|
|
|
710
937
|
};
|
|
711
938
|
}
|
|
712
939
|
}
|
|
940
|
+
//# sourceMappingURL=pluginManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginManager.js","sourceRoot":"","sources":["../src/pluginManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,sDAAsD;AAEtD,qCAAqC;AACrC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAY,EAAE,EAAE,EAAE,EAAE,EAAE,EAAmB,SAAS,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAGhI,kBAAkB;AAClB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,IAAI,EAAiB,MAAM,eAAe,CAAC;AAIpD,OAAO,EAAE,GAAG,EAAoB,GAAG,EAAE,MAAM,wBAAwB,CAAC;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OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,eAAe,UAAU,uBAAuB,CAAC,CAAC;YACnE,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,eAAe,UAAU,eAAe,GAAG,GAAG,MAAM,CAAC,IAAI,GAAG,EAAE,qCAAqC,CAAC,CAAC;YACpH,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED;;;;;;;;;OASG;IACH,gBAAgB,CAAC,MAAwB;QACvC,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,WAAW;YACzB,WAAW,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM;YAC3E,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,WAAW,EAAE,aAAa;oBAC1B,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,IAAI;iBACf;gBACD,IAAI,EAAE;oBACJ,WAAW,EAAE,aAAa;oBAC1B,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,IAAI;iBACf;gBACD,KAAK,EAAE;oBACL,WAAW,EAAE,oDAAoD;oBACjE,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE,KAAK;iBACf;gBACD,oBAAoB,EAAE;oBACpB,WAAW,EAAE,uDAAuD;oBACpE,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE,KAAK;iBACf;aACF;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/storage/export.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
package/dist/storage/export.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/storage/export.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the color utilities.
|
|
3
|
+
*
|
|
4
|
+
* @file colorUtils.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2023-10-05
|
|
7
|
+
* @version 1.2.6
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2023, 2024, 2025 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
|
+
export interface RGB {
|
|
24
|
+
r: number;
|
|
25
|
+
g: number;
|
|
26
|
+
b: number;
|
|
27
|
+
}
|
|
28
|
+
export interface XY {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
}
|
|
32
|
+
export interface HSL {
|
|
33
|
+
h: number;
|
|
34
|
+
s: number;
|
|
35
|
+
l: number;
|
|
36
|
+
}
|
|
37
|
+
export declare function hslColorToRgbColor(hue: number, saturation: number, luminance: number): RGB;
|
|
38
|
+
export declare function rgbColorToXYColor(rgb: RGB): XY;
|
|
39
|
+
export declare function xyColorToRgbColor(x: number, y: number, brightness?: number): RGB;
|
|
40
|
+
export declare function rgbColorToHslColor(rgb: RGB): HSL;
|
|
41
|
+
export declare function xyToHsl(x: number, y: number): HSL;
|
|
42
|
+
export declare function testColors(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Converts CIE color space to RGB color space
|
|
45
|
+
* @param {Number} x
|
|
46
|
+
* @param {Number} y
|
|
47
|
+
* @param {Number} brightness - Ranges from 1 to 254
|
|
48
|
+
* @return {Array} Array that contains the color values for red, green and blue
|
|
49
|
+
* From: https://github.com/usolved/cie-rgb-converter/blob/master/cie_rgb_converter.js
|
|
50
|
+
*/
|
|
51
|
+
export declare function cie_to_rgb(x: number, y: number, brightness?: number): RGB;
|
|
52
|
+
/**
|
|
53
|
+
* Converts RGB color space to CIE color space
|
|
54
|
+
* @param {Number} red
|
|
55
|
+
* @param {Number} green
|
|
56
|
+
* @param {Number} blue
|
|
57
|
+
* @return {Array} Array that contains the CIE color values for x and y
|
|
58
|
+
* From: https://github.com/usolved/cie-rgb-converter/blob/master/cie_rgb_converter.js
|
|
59
|
+
*/
|
|
60
|
+
export declare function rgb_to_cie(red: number, green: number, blue: number): XY;
|
|
61
|
+
//# sourceMappingURL=colorUtils.d.ts.map
|