matterbridge 3.3.4 → 3.3.5-dev-20251028-d89f93f

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 (305) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/broadcastServer.js +1 -92
  3. package/dist/broadcastServerTypes.js +0 -24
  4. package/dist/cli.js +1 -97
  5. package/dist/cliEmitter.js +0 -37
  6. package/dist/cliHistory.js +0 -38
  7. package/dist/clusters/export.js +0 -2
  8. package/dist/defaultConfigSchema.js +0 -24
  9. package/dist/deviceManager.js +8 -124
  10. package/dist/devices/airConditioner.js +0 -57
  11. package/dist/devices/batteryStorage.js +1 -48
  12. package/dist/devices/cooktop.js +0 -55
  13. package/dist/devices/dishwasher.js +0 -57
  14. package/dist/devices/evse.js +10 -74
  15. package/dist/devices/export.js +0 -5
  16. package/dist/devices/extractorHood.js +0 -42
  17. package/dist/devices/heatPump.js +2 -50
  18. package/dist/devices/laundryDryer.js +3 -62
  19. package/dist/devices/laundryWasher.js +4 -70
  20. package/dist/devices/microwaveOven.js +5 -88
  21. package/dist/devices/oven.js +0 -85
  22. package/dist/devices/refrigerator.js +0 -102
  23. package/dist/devices/roboticVacuumCleaner.js +9 -100
  24. package/dist/devices/solarPower.js +0 -38
  25. package/dist/devices/speaker.js +0 -84
  26. package/dist/devices/temperatureControl.js +3 -24
  27. package/dist/devices/waterHeater.js +2 -82
  28. package/dist/dgram/coap.js +13 -126
  29. package/dist/dgram/dgram.js +2 -114
  30. package/dist/dgram/mb_coap.js +3 -41
  31. package/dist/dgram/mb_mdns.js +15 -80
  32. package/dist/dgram/mdns.js +137 -299
  33. package/dist/dgram/multicast.js +1 -62
  34. package/dist/dgram/unicast.js +0 -54
  35. package/dist/frontend.js +165 -493
  36. package/dist/frontendTypes.js +0 -45
  37. package/dist/helpers.js +0 -53
  38. package/dist/index.js +0 -25
  39. package/dist/logger/export.js +0 -1
  40. package/dist/matter/behaviors.js +0 -2
  41. package/dist/matter/clusters.js +0 -2
  42. package/dist/matter/devices.js +0 -2
  43. package/dist/matter/endpoints.js +0 -2
  44. package/dist/matter/export.js +0 -3
  45. package/dist/matter/types.js +0 -3
  46. package/dist/matterbridge.js +53 -828
  47. package/dist/matterbridgeAccessoryPlatform.js +0 -37
  48. package/dist/matterbridgeBehaviors.js +5 -68
  49. package/dist/matterbridgeDeviceTypes.js +17 -638
  50. package/dist/matterbridgeDynamicPlatform.js +0 -37
  51. package/dist/matterbridgeEndpoint.js +52 -1402
  52. package/dist/matterbridgeEndpointHelpers.js +19 -464
  53. package/dist/matterbridgePlatform.js +1 -341
  54. package/dist/matterbridgeTypes.js +0 -26
  55. package/dist/pluginManager.js +11 -319
  56. package/dist/shelly.js +7 -168
  57. package/dist/storage/export.js +0 -1
  58. package/dist/update.js +0 -69
  59. package/dist/utils/colorUtils.js +2 -97
  60. package/dist/utils/commandLine.js +0 -60
  61. package/dist/utils/copyDirectory.js +1 -38
  62. package/dist/utils/createDirectory.js +0 -33
  63. package/dist/utils/createZip.js +2 -47
  64. package/dist/utils/deepCopy.js +0 -39
  65. package/dist/utils/deepEqual.js +1 -72
  66. package/dist/utils/error.js +0 -41
  67. package/dist/utils/export.js +0 -1
  68. package/dist/utils/format.js +0 -49
  69. package/dist/utils/hex.js +0 -124
  70. package/dist/utils/inspector.js +1 -69
  71. package/dist/utils/isvalid.js +0 -101
  72. package/dist/utils/jestHelpers.js +3 -153
  73. package/dist/utils/network.js +5 -96
  74. package/dist/utils/spawn.js +0 -71
  75. package/dist/utils/tracker.js +1 -64
  76. package/dist/utils/wait.js +8 -60
  77. package/frontend/build/assets/index.js +4 -4
  78. package/frontend/package.json +1 -1
  79. package/npm-shrinkwrap.json +2 -2
  80. package/package.json +1 -2
  81. package/dist/broadcastServer.d.ts +0 -112
  82. package/dist/broadcastServer.d.ts.map +0 -1
  83. package/dist/broadcastServer.js.map +0 -1
  84. package/dist/broadcastServerTypes.d.ts +0 -793
  85. package/dist/broadcastServerTypes.d.ts.map +0 -1
  86. package/dist/broadcastServerTypes.js.map +0 -1
  87. package/dist/cli.d.ts +0 -30
  88. package/dist/cli.d.ts.map +0 -1
  89. package/dist/cli.js.map +0 -1
  90. package/dist/cliEmitter.d.ts +0 -50
  91. package/dist/cliEmitter.d.ts.map +0 -1
  92. package/dist/cliEmitter.js.map +0 -1
  93. package/dist/cliHistory.d.ts +0 -48
  94. package/dist/cliHistory.d.ts.map +0 -1
  95. package/dist/cliHistory.js.map +0 -1
  96. package/dist/clusters/export.d.ts +0 -2
  97. package/dist/clusters/export.d.ts.map +0 -1
  98. package/dist/clusters/export.js.map +0 -1
  99. package/dist/defaultConfigSchema.d.ts +0 -28
  100. package/dist/defaultConfigSchema.d.ts.map +0 -1
  101. package/dist/defaultConfigSchema.js.map +0 -1
  102. package/dist/deviceManager.d.ts +0 -117
  103. package/dist/deviceManager.d.ts.map +0 -1
  104. package/dist/deviceManager.js.map +0 -1
  105. package/dist/devices/airConditioner.d.ts +0 -98
  106. package/dist/devices/airConditioner.d.ts.map +0 -1
  107. package/dist/devices/airConditioner.js.map +0 -1
  108. package/dist/devices/batteryStorage.d.ts +0 -48
  109. package/dist/devices/batteryStorage.d.ts.map +0 -1
  110. package/dist/devices/batteryStorage.js.map +0 -1
  111. package/dist/devices/cooktop.d.ts +0 -60
  112. package/dist/devices/cooktop.d.ts.map +0 -1
  113. package/dist/devices/cooktop.js.map +0 -1
  114. package/dist/devices/dishwasher.d.ts +0 -71
  115. package/dist/devices/dishwasher.d.ts.map +0 -1
  116. package/dist/devices/dishwasher.js.map +0 -1
  117. package/dist/devices/evse.d.ts +0 -76
  118. package/dist/devices/evse.d.ts.map +0 -1
  119. package/dist/devices/evse.js.map +0 -1
  120. package/dist/devices/export.d.ts +0 -17
  121. package/dist/devices/export.d.ts.map +0 -1
  122. package/dist/devices/export.js.map +0 -1
  123. package/dist/devices/extractorHood.d.ts +0 -46
  124. package/dist/devices/extractorHood.d.ts.map +0 -1
  125. package/dist/devices/extractorHood.js.map +0 -1
  126. package/dist/devices/heatPump.d.ts +0 -47
  127. package/dist/devices/heatPump.d.ts.map +0 -1
  128. package/dist/devices/heatPump.js.map +0 -1
  129. package/dist/devices/laundryDryer.d.ts +0 -67
  130. package/dist/devices/laundryDryer.d.ts.map +0 -1
  131. package/dist/devices/laundryDryer.js.map +0 -1
  132. package/dist/devices/laundryWasher.d.ts +0 -81
  133. package/dist/devices/laundryWasher.d.ts.map +0 -1
  134. package/dist/devices/laundryWasher.js.map +0 -1
  135. package/dist/devices/microwaveOven.d.ts +0 -168
  136. package/dist/devices/microwaveOven.d.ts.map +0 -1
  137. package/dist/devices/microwaveOven.js.map +0 -1
  138. package/dist/devices/oven.d.ts +0 -105
  139. package/dist/devices/oven.d.ts.map +0 -1
  140. package/dist/devices/oven.js.map +0 -1
  141. package/dist/devices/refrigerator.d.ts +0 -118
  142. package/dist/devices/refrigerator.d.ts.map +0 -1
  143. package/dist/devices/refrigerator.js.map +0 -1
  144. package/dist/devices/roboticVacuumCleaner.d.ts +0 -112
  145. package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
  146. package/dist/devices/roboticVacuumCleaner.js.map +0 -1
  147. package/dist/devices/solarPower.d.ts +0 -40
  148. package/dist/devices/solarPower.d.ts.map +0 -1
  149. package/dist/devices/solarPower.js.map +0 -1
  150. package/dist/devices/speaker.d.ts +0 -87
  151. package/dist/devices/speaker.d.ts.map +0 -1
  152. package/dist/devices/speaker.js.map +0 -1
  153. package/dist/devices/temperatureControl.d.ts +0 -166
  154. package/dist/devices/temperatureControl.d.ts.map +0 -1
  155. package/dist/devices/temperatureControl.js.map +0 -1
  156. package/dist/devices/waterHeater.d.ts +0 -111
  157. package/dist/devices/waterHeater.d.ts.map +0 -1
  158. package/dist/devices/waterHeater.js.map +0 -1
  159. package/dist/dgram/coap.d.ts +0 -205
  160. package/dist/dgram/coap.d.ts.map +0 -1
  161. package/dist/dgram/coap.js.map +0 -1
  162. package/dist/dgram/dgram.d.ts +0 -141
  163. package/dist/dgram/dgram.d.ts.map +0 -1
  164. package/dist/dgram/dgram.js.map +0 -1
  165. package/dist/dgram/mb_coap.d.ts +0 -24
  166. package/dist/dgram/mb_coap.d.ts.map +0 -1
  167. package/dist/dgram/mb_coap.js.map +0 -1
  168. package/dist/dgram/mb_mdns.d.ts +0 -24
  169. package/dist/dgram/mb_mdns.d.ts.map +0 -1
  170. package/dist/dgram/mb_mdns.js.map +0 -1
  171. package/dist/dgram/mdns.d.ts +0 -290
  172. package/dist/dgram/mdns.d.ts.map +0 -1
  173. package/dist/dgram/mdns.js.map +0 -1
  174. package/dist/dgram/multicast.d.ts +0 -67
  175. package/dist/dgram/multicast.d.ts.map +0 -1
  176. package/dist/dgram/multicast.js.map +0 -1
  177. package/dist/dgram/unicast.d.ts +0 -56
  178. package/dist/dgram/unicast.d.ts.map +0 -1
  179. package/dist/dgram/unicast.js.map +0 -1
  180. package/dist/frontend.d.ts +0 -235
  181. package/dist/frontend.d.ts.map +0 -1
  182. package/dist/frontend.js.map +0 -1
  183. package/dist/frontendTypes.d.ts +0 -529
  184. package/dist/frontendTypes.d.ts.map +0 -1
  185. package/dist/frontendTypes.js.map +0 -1
  186. package/dist/helpers.d.ts +0 -48
  187. package/dist/helpers.d.ts.map +0 -1
  188. package/dist/helpers.js.map +0 -1
  189. package/dist/index.d.ts +0 -33
  190. package/dist/index.d.ts.map +0 -1
  191. package/dist/index.js.map +0 -1
  192. package/dist/logger/export.d.ts +0 -2
  193. package/dist/logger/export.d.ts.map +0 -1
  194. package/dist/logger/export.js.map +0 -1
  195. package/dist/matter/behaviors.d.ts +0 -2
  196. package/dist/matter/behaviors.d.ts.map +0 -1
  197. package/dist/matter/behaviors.js.map +0 -1
  198. package/dist/matter/clusters.d.ts +0 -2
  199. package/dist/matter/clusters.d.ts.map +0 -1
  200. package/dist/matter/clusters.js.map +0 -1
  201. package/dist/matter/devices.d.ts +0 -2
  202. package/dist/matter/devices.d.ts.map +0 -1
  203. package/dist/matter/devices.js.map +0 -1
  204. package/dist/matter/endpoints.d.ts +0 -2
  205. package/dist/matter/endpoints.d.ts.map +0 -1
  206. package/dist/matter/endpoints.js.map +0 -1
  207. package/dist/matter/export.d.ts +0 -5
  208. package/dist/matter/export.d.ts.map +0 -1
  209. package/dist/matter/export.js.map +0 -1
  210. package/dist/matter/types.d.ts +0 -3
  211. package/dist/matter/types.d.ts.map +0 -1
  212. package/dist/matter/types.js.map +0 -1
  213. package/dist/matterbridge.d.ts +0 -475
  214. package/dist/matterbridge.d.ts.map +0 -1
  215. package/dist/matterbridge.js.map +0 -1
  216. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
  217. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  218. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  219. package/dist/matterbridgeBehaviors.d.ts +0 -2404
  220. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  221. package/dist/matterbridgeBehaviors.js.map +0 -1
  222. package/dist/matterbridgeDeviceTypes.d.ts +0 -770
  223. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  224. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  225. package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
  226. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  227. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  228. package/dist/matterbridgeEndpoint.d.ts +0 -1550
  229. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  230. package/dist/matterbridgeEndpoint.js.map +0 -1
  231. package/dist/matterbridgeEndpointHelpers.d.ts +0 -758
  232. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  233. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  234. package/dist/matterbridgePlatform.d.ts +0 -402
  235. package/dist/matterbridgePlatform.d.ts.map +0 -1
  236. package/dist/matterbridgePlatform.js.map +0 -1
  237. package/dist/matterbridgeTypes.d.ts +0 -226
  238. package/dist/matterbridgeTypes.d.ts.map +0 -1
  239. package/dist/matterbridgeTypes.js.map +0 -1
  240. package/dist/pluginManager.d.ts +0 -347
  241. package/dist/pluginManager.d.ts.map +0 -1
  242. package/dist/pluginManager.js.map +0 -1
  243. package/dist/shelly.d.ts +0 -174
  244. package/dist/shelly.d.ts.map +0 -1
  245. package/dist/shelly.js.map +0 -1
  246. package/dist/storage/export.d.ts +0 -2
  247. package/dist/storage/export.d.ts.map +0 -1
  248. package/dist/storage/export.js.map +0 -1
  249. package/dist/update.d.ts +0 -75
  250. package/dist/update.d.ts.map +0 -1
  251. package/dist/update.js.map +0 -1
  252. package/dist/utils/colorUtils.d.ts +0 -99
  253. package/dist/utils/colorUtils.d.ts.map +0 -1
  254. package/dist/utils/colorUtils.js.map +0 -1
  255. package/dist/utils/commandLine.d.ts +0 -66
  256. package/dist/utils/commandLine.d.ts.map +0 -1
  257. package/dist/utils/commandLine.js.map +0 -1
  258. package/dist/utils/copyDirectory.d.ts +0 -33
  259. package/dist/utils/copyDirectory.d.ts.map +0 -1
  260. package/dist/utils/copyDirectory.js.map +0 -1
  261. package/dist/utils/createDirectory.d.ts +0 -34
  262. package/dist/utils/createDirectory.d.ts.map +0 -1
  263. package/dist/utils/createDirectory.js.map +0 -1
  264. package/dist/utils/createZip.d.ts +0 -39
  265. package/dist/utils/createZip.d.ts.map +0 -1
  266. package/dist/utils/createZip.js.map +0 -1
  267. package/dist/utils/deepCopy.d.ts +0 -32
  268. package/dist/utils/deepCopy.d.ts.map +0 -1
  269. package/dist/utils/deepCopy.js.map +0 -1
  270. package/dist/utils/deepEqual.d.ts +0 -54
  271. package/dist/utils/deepEqual.d.ts.map +0 -1
  272. package/dist/utils/deepEqual.js.map +0 -1
  273. package/dist/utils/error.d.ts +0 -44
  274. package/dist/utils/error.d.ts.map +0 -1
  275. package/dist/utils/error.js.map +0 -1
  276. package/dist/utils/export.d.ts +0 -13
  277. package/dist/utils/export.d.ts.map +0 -1
  278. package/dist/utils/export.js.map +0 -1
  279. package/dist/utils/format.d.ts +0 -53
  280. package/dist/utils/format.d.ts.map +0 -1
  281. package/dist/utils/format.js.map +0 -1
  282. package/dist/utils/hex.d.ts +0 -89
  283. package/dist/utils/hex.d.ts.map +0 -1
  284. package/dist/utils/hex.js.map +0 -1
  285. package/dist/utils/inspector.d.ts +0 -87
  286. package/dist/utils/inspector.d.ts.map +0 -1
  287. package/dist/utils/inspector.js.map +0 -1
  288. package/dist/utils/isvalid.d.ts +0 -103
  289. package/dist/utils/isvalid.d.ts.map +0 -1
  290. package/dist/utils/isvalid.js.map +0 -1
  291. package/dist/utils/jestHelpers.d.ts +0 -139
  292. package/dist/utils/jestHelpers.d.ts.map +0 -1
  293. package/dist/utils/jestHelpers.js.map +0 -1
  294. package/dist/utils/network.d.ts +0 -101
  295. package/dist/utils/network.d.ts.map +0 -1
  296. package/dist/utils/network.js.map +0 -1
  297. package/dist/utils/spawn.d.ts +0 -35
  298. package/dist/utils/spawn.d.ts.map +0 -1
  299. package/dist/utils/spawn.js.map +0 -1
  300. package/dist/utils/tracker.d.ts +0 -108
  301. package/dist/utils/tracker.d.ts.map +0 -1
  302. package/dist/utils/tracker.js.map +0 -1
  303. package/dist/utils/wait.d.ts +0 -54
  304. package/dist/utils/wait.d.ts.map +0 -1
  305. package/dist/utils/wait.js.map +0 -1
@@ -1,50 +1,18 @@
1
- /**
2
- * This file contains the Plugins class.
3
- *
4
- * @file plugins.ts
5
- * @author Luca Liguori
6
- * @created 2024-07-14
7
- * @version 1.2.0
8
- * @license Apache-2.0
9
- *
10
- * Copyright 2024, 2025, 2026 Luca Liguori.
11
- *
12
- * Licensed under the Apache License, Version 2.0 (the "License");
13
- * you may not use this file except in compliance with the License.
14
- * You may obtain a copy of the License at
15
- *
16
- * http://www.apache.org/licenses/LICENSE-2.0
17
- *
18
- * Unless required by applicable law or agreed to in writing, software
19
- * distributed under the License is distributed on an "AS IS" BASIS,
20
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
- * See the License for the specific language governing permissions and
22
- * limitations under the License.
23
- */
24
- // Node.js import
25
1
  import EventEmitter from 'node:events';
26
- // AnsiLogger module
27
2
  import { AnsiLogger, UNDERLINE, UNDERLINEOFF, BLUE, db, er, nf, nt, rs, wr, debugStringify, CYAN } from 'node-ansi-logger';
28
3
  import { plg, typ } from './matterbridgeTypes.js';
29
4
  import { inspectError, logError } from './utils/error.js';
5
+ import { hasParameter } from './utils/commandLine.js';
30
6
  import { BroadcastServer } from './broadcastServer.js';
31
- /**
32
- * Manages Matterbridge plugins.
33
- */
34
7
  export class PluginManager extends EventEmitter {
35
8
  _plugins = new Map();
36
9
  matterbridge;
37
10
  log;
38
11
  server;
39
- /**
40
- * Creates an instance of PluginManager.
41
- *
42
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
43
- */
44
12
  constructor(matterbridge) {
45
13
  super();
46
14
  this.matterbridge = matterbridge;
47
- this.log = new AnsiLogger({ logName: 'PluginManager', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: matterbridge.log.logLevel });
15
+ this.log = new AnsiLogger({ logName: 'PluginManager', logTimestampFormat: 4, logLevel: hasParameter('debug') ? "debug" : "info" });
48
16
  this.log.debug('Matterbridge plugin manager starting...');
49
17
  this.server = new BroadcastServer('plugins', this.log);
50
18
  this.server.on('broadcast_message', this.msgHandler.bind(this));
@@ -57,6 +25,13 @@ export class PluginManager extends EventEmitter {
57
25
  if (this.server.isWorkerRequest(msg, msg.type) && (msg.dst === 'all' || msg.dst === 'plugins')) {
58
26
  this.log.debug(`**Received request message ${CYAN}${msg.type}${db} from ${CYAN}${msg.src}${db}: ${debugStringify(msg)}${db}`);
59
27
  switch (msg.type) {
28
+ case 'get_log_level':
29
+ this.server.respond({ ...msg, response: { success: true, logLevel: this.log.logLevel } });
30
+ break;
31
+ case 'set_log_level':
32
+ this.log.logLevel = msg.params.logLevel;
33
+ this.server.respond({ ...msg, response: { success: true, logLevel: this.log.logLevel } });
34
+ break;
60
35
  case 'plugins_length':
61
36
  this.server.respond({ ...msg, response: { length: this.length } });
62
37
  break;
@@ -86,69 +61,28 @@ export class PluginManager extends EventEmitter {
86
61
  }
87
62
  }
88
63
  }
89
- /**
90
- * Gets the number of plugins.
91
- *
92
- * @returns {number} The number of plugins.
93
- */
94
64
  get length() {
95
65
  return this._plugins.size;
96
66
  }
97
- /**
98
- * Gets the number of plugins.
99
- *
100
- * @returns {number} The number of plugins.
101
- */
102
67
  get size() {
103
68
  return this._plugins.size;
104
69
  }
105
- /**
106
- * Checks if a plugin with the specified name exists.
107
- *
108
- * @param {string} name - The name of the plugin.
109
- * @returns {boolean} True if the plugin exists, false otherwise.
110
- */
111
70
  has(name) {
112
71
  return this._plugins.has(name);
113
72
  }
114
- /**
115
- * Gets a plugin by its name.
116
- *
117
- * @param {string} name - The name of the plugin.
118
- * @returns {Plugin | undefined} The plugin, or undefined if not found.
119
- */
120
73
  get(name) {
121
74
  return this._plugins.get(name);
122
75
  }
123
- /**
124
- * Adds a plugin to the manager.
125
- *
126
- * @param {Plugin} plugin - The plugin to add.
127
- * @returns {Plugin} The added plugin.
128
- */
129
76
  set(plugin) {
130
77
  this._plugins.set(plugin.name, plugin);
131
78
  return plugin;
132
79
  }
133
- /**
134
- * Clears all plugins from the manager.
135
- */
136
80
  clear() {
137
81
  this._plugins.clear();
138
82
  }
139
- /**
140
- * Gets an array of all plugins.
141
- *
142
- * @returns {Plugin[]} An array of all plugins.
143
- */
144
83
  array() {
145
84
  return Array.from(this._plugins.values());
146
85
  }
147
- /**
148
- * Gets an array of all plugins suitable for serialization.
149
- *
150
- * @returns {ApiPlugin[]} An array of all plugins.
151
- */
152
86
  baseArray() {
153
87
  const basePlugins = [];
154
88
  for (const plugin of this._plugins.values()) {
@@ -182,20 +116,9 @@ export class PluginManager extends EventEmitter {
182
116
  }
183
117
  return basePlugins;
184
118
  }
185
- /**
186
- * Gets an iterator for the plugins.
187
- *
188
- * @returns {IterableIterator<Plugin>} An iterator for the plugins.
189
- */
190
119
  [Symbol.iterator]() {
191
120
  return this._plugins.values();
192
121
  }
193
- /**
194
- * Executes a provided function once for each plugin.
195
- *
196
- * @param {Function} callback - The function to execute for each plugin.
197
- * @returns {Promise<void>}
198
- */
199
122
  async forEach(callback) {
200
123
  if (this.size === 0)
201
124
  return;
@@ -209,39 +132,22 @@ export class PluginManager extends EventEmitter {
209
132
  });
210
133
  await Promise.all(tasks);
211
134
  }
212
- /**
213
- * Sets the log level for the plugin manager.
214
- *
215
- * @param {LogLevel} logLevel - The log level to set.
216
- */
217
135
  set logLevel(logLevel) {
218
136
  this.log.logLevel = logLevel;
219
137
  }
220
- /**
221
- * Loads registered plugins from storage.
222
- *
223
- * @returns {Promise<StoragePlugin[]>} A promise that resolves to an array of registered plugins.
224
- */
225
138
  async loadFromStorage() {
226
139
  if (!this.matterbridge.nodeContext) {
227
140
  throw new Error('loadFromStorage: node context is not available.');
228
141
  }
229
- // Load the array from storage and convert it to a map
230
142
  const pluginsArray = await this.matterbridge.nodeContext.get('plugins', []);
231
143
  for (const plugin of pluginsArray)
232
144
  this._plugins.set(plugin.name, plugin);
233
145
  return pluginsArray;
234
146
  }
235
- /**
236
- * Saves registered plugins to storage.
237
- *
238
- * @returns {Promise<number>} A promise that resolves to the number of registered plugins.
239
- */
240
147
  async saveToStorage() {
241
148
  if (!this.matterbridge.nodeContext) {
242
149
  throw new Error('loadFromStorage: node context is not available.');
243
150
  }
244
- // Convert the map to an array
245
151
  const plugins = [];
246
152
  for (const plugin of this.array()) {
247
153
  plugins.push({
@@ -258,21 +164,13 @@ export class PluginManager extends EventEmitter {
258
164
  this.log.debug(`Saved ${BLUE}${plugins.length}${db} plugins to storage`);
259
165
  return plugins.length;
260
166
  }
261
- /**
262
- * Resolves the name of a plugin by loading and parsing its package.json file.
263
- *
264
- * @param {string} pluginPath - The path to the plugin or the path to the plugin's package.json file.
265
- * @returns {Promise<string | null>} A promise that resolves to the path of the plugin's package.json file or null if it could not be resolved.
266
- */
267
167
  async resolve(pluginPath) {
268
168
  const { default: path } = await import('node:path');
269
169
  const { promises } = await import('node:fs');
270
170
  if (!pluginPath.endsWith('package.json'))
271
171
  pluginPath = path.join(pluginPath, 'package.json');
272
- // Resolve the package.json of the plugin
273
172
  let packageJsonPath = path.resolve(pluginPath);
274
173
  this.log.debug(`Resolving plugin path ${plg}${packageJsonPath}${db}`);
275
- // Check if the package.json file exists
276
174
  try {
277
175
  await promises.access(packageJsonPath);
278
176
  }
@@ -282,9 +180,7 @@ export class PluginManager extends EventEmitter {
282
180
  this.log.debug(`Trying at ${plg}${packageJsonPath}${db}`);
283
181
  }
284
182
  try {
285
- // Load the package.json of the plugin
286
183
  const packageJson = JSON.parse(await promises.readFile(packageJsonPath, 'utf8'));
287
- // Check for main issues
288
184
  if (!packageJson.name) {
289
185
  this.log.error(`Package.json name not found at ${packageJsonPath}`);
290
186
  return null;
@@ -297,7 +193,6 @@ export class PluginManager extends EventEmitter {
297
193
  this.log.error(`Plugin at ${packageJsonPath} has no main entrypoint in package.json`);
298
194
  return null;
299
195
  }
300
- // Check for @project-chip and @matter packages in dependencies and devDependencies
301
196
  const checkForProjectChipPackages = (dependencies) => {
302
197
  return Object.keys(dependencies).filter((pkg) => pkg.startsWith('@project-chip') || pkg.startsWith('@matter'));
303
198
  };
@@ -319,7 +214,6 @@ export class PluginManager extends EventEmitter {
319
214
  this.log.error(`Please open an issue on the plugin repository to remove them.`);
320
215
  return null;
321
216
  }
322
- // Check for matterbridge package in dependencies and devDependencies
323
217
  const checkForMatterbridgePackage = (dependencies) => {
324
218
  return Object.keys(dependencies).filter((pkg) => pkg === 'matterbridge');
325
219
  };
@@ -349,12 +243,6 @@ export class PluginManager extends EventEmitter {
349
243
  return null;
350
244
  }
351
245
  }
352
- /**
353
- * Installs a package globally using npm.
354
- *
355
- * @param {string} packageName - The name of the package to install.
356
- * @returns {Promise<boolean>} A promise that resolves to true if the installation was successful, false otherwise.
357
- */
358
246
  async install(packageName) {
359
247
  const { spawnCommand } = await import('./utils/spawn.js');
360
248
  try {
@@ -381,12 +269,6 @@ export class PluginManager extends EventEmitter {
381
269
  return false;
382
270
  }
383
271
  }
384
- /**
385
- * Uninstalls a package globally using npm.
386
- *
387
- * @param {string} packageName - The name of the package to uninstall.
388
- * @returns {Promise<boolean>} A promise that resolves to true if the uninstallation was successful, false otherwise.
389
- */
390
272
  async uninstall(packageName) {
391
273
  const { spawnCommand } = await import('./utils/spawn.js');
392
274
  packageName = packageName.replace(/@.*$/, '');
@@ -407,12 +289,6 @@ export class PluginManager extends EventEmitter {
407
289
  return false;
408
290
  }
409
291
  }
410
- /**
411
- * Get the author of a plugin from its package.json.
412
- *
413
- * @param {Record<string, string | number | Record<string, string | number | object>>} packageJson - The package.json object of the plugin.
414
- * @returns {string} The author of the plugin, or 'Unknown author' if not found.
415
- */
416
292
  getAuthor(packageJson) {
417
293
  if (packageJson.author && typeof packageJson.author === 'string')
418
294
  return packageJson.author;
@@ -420,12 +296,6 @@ export class PluginManager extends EventEmitter {
420
296
  return packageJson.author.name;
421
297
  return 'Unknown author';
422
298
  }
423
- /**
424
- * Get the homepage of a plugin from its package.json.
425
- *
426
- * @param {Record<string, string | number | Record<string, string | number | object>>} packageJson - The package.json object of the plugin.
427
- * @returns {string | undefined} The homepage of the plugin, or undefined if not found.
428
- */
429
299
  getHomepage(packageJson) {
430
300
  if (packageJson.homepage && typeof packageJson.homepage === 'string' && packageJson.homepage.includes('http')) {
431
301
  return packageJson.homepage.replace('git+', '').replace('.git', '');
@@ -434,14 +304,7 @@ export class PluginManager extends EventEmitter {
434
304
  return packageJson.repository.url.replace('git+', '').replace('.git', '');
435
305
  }
436
306
  }
437
- /**
438
- * Get the help URL of a plugin from its package.json.
439
- *
440
- * @param {Record<string, string | number | Record<string, string | number | object>>} packageJson - The package.json object of the plugin.
441
- * @returns {string | undefined} The URL to the help page or to the README file, or undefined if not found.
442
- */
443
307
  getHelp(packageJson) {
444
- // If there's a help field that looks like a URL, return it.
445
308
  if (packageJson.help && typeof packageJson.help === 'string' && packageJson.help.startsWith('http')) {
446
309
  return packageJson.help;
447
310
  }
@@ -452,14 +315,7 @@ export class PluginManager extends EventEmitter {
452
315
  return packageJson.homepage.replace('git+', '').replace('.git', '');
453
316
  }
454
317
  }
455
- /**
456
- * Get the changelog URL of a plugin from its package.json.
457
- *
458
- * @param {Record<string, string | number | Record<string, string | number | object>>} packageJson - The package.json object of the plugin.
459
- * @returns {string | undefined} The URL to the CHANGELOG file, or undefined if not found.
460
- */
461
318
  getChangelog(packageJson) {
462
- // If there's a changelog field that looks like a URL, return it.
463
319
  if (packageJson.changelog && typeof packageJson.changelog === 'string' && packageJson.changelog.startsWith('http')) {
464
320
  return packageJson.changelog;
465
321
  }
@@ -470,13 +326,6 @@ export class PluginManager extends EventEmitter {
470
326
  return packageJson.homepage.replace('git+', '').replace('.git', '');
471
327
  }
472
328
  }
473
- /**
474
- * Get the first funding URL(s) of a plugin from its package.json.
475
- *
476
- * @param {Record<string, any>} packageJson - The package.json object of the plugin.
477
- * @returns {string | undefined} The first funding URLs, or undefined if not found.
478
- */
479
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
480
329
  getFunding(packageJson) {
481
330
  const funding = packageJson.funding;
482
331
  if (!funding)
@@ -485,25 +334,16 @@ export class PluginManager extends EventEmitter {
485
334
  return;
486
335
  if (typeof funding === 'string' && funding.startsWith('http'))
487
336
  return funding;
488
- // Normalize funding into an array.
489
337
  const fundingEntries = Array.isArray(funding) ? funding : [funding];
490
338
  for (const entry of fundingEntries) {
491
339
  if (entry && typeof entry === 'string' && entry.startsWith('http')) {
492
- // If the funding entry is a string, assume it is a URL.
493
340
  return entry;
494
341
  }
495
342
  else if (entry && typeof entry === 'object' && typeof entry.url === 'string' && entry.url.startsWith('http')) {
496
- // If it's an object with a 'url' property, use that.
497
343
  return entry.url;
498
344
  }
499
345
  }
500
346
  }
501
- /**
502
- * Loads and parses the plugin package.json and returns it.
503
- *
504
- * @param {Plugin} plugin - The plugin to load the package from.
505
- * @returns {Promise<Record<string, string | number | object> | null>} A promise that resolves to the parsed package.json object or null if it could not be parsed.
506
- */
507
347
  async parse(plugin) {
508
348
  const { promises } = await import('node:fs');
509
349
  try {
@@ -533,7 +373,6 @@ export class PluginManager extends EventEmitter {
533
373
  plugin.funding = this.getFunding(packageJson);
534
374
  if (!plugin.type)
535
375
  this.log.warn(`Plugin ${plg}${plugin.name}${wr} has no type`);
536
- // Check for @project-chip and @matter packages in dependencies and devDependencies
537
376
  const checkForProjectChipPackages = (dependencies) => {
538
377
  return Object.keys(dependencies).filter((pkg) => pkg.startsWith('@project-chip') || pkg.startsWith('@matter'));
539
378
  };
@@ -555,7 +394,6 @@ export class PluginManager extends EventEmitter {
555
394
  this.log.error(`Please open an issue on the plugin repository to remove them.`);
556
395
  return null;
557
396
  }
558
- // Check for matterbridge package in dependencies and devDependencies
559
397
  const checkForMatterbridgePackage = (dependencies) => {
560
398
  return Object.keys(dependencies).filter((pkg) => pkg === 'matterbridge');
561
399
  };
@@ -585,16 +423,6 @@ export class PluginManager extends EventEmitter {
585
423
  return null;
586
424
  }
587
425
  }
588
- /**
589
- * Enables a plugin by its name or path.
590
- *
591
- * This method enables a plugin by setting its `enabled` property to `true` and saving the updated
592
- * plugin information to storage. It first checks if the plugin is already registered in the `_plugins` map.
593
- * If not, it attempts to resolve the plugin's `package.json` file to retrieve its name and enable it.
594
- *
595
- * @param {string} nameOrPath - The name or path of the plugin to enable.
596
- * @returns {Promise<Plugin | null>} A promise that resolves to the enabled plugin object, or null if the plugin could not be enabled.
597
- */
598
426
  async enable(nameOrPath) {
599
427
  const { promises } = await import('node:fs');
600
428
  if (!nameOrPath)
@@ -630,16 +458,6 @@ export class PluginManager extends EventEmitter {
630
458
  return null;
631
459
  }
632
460
  }
633
- /**
634
- * Enables a plugin by its name or path.
635
- *
636
- * This method enables a plugin by setting its `enabled` property to `true` and saving the updated
637
- * plugin information to storage. It first checks if the plugin is already registered in the `_plugins` map.
638
- * If not, it attempts to resolve the plugin's `package.json` file to retrieve its name and enable it.
639
- *
640
- * @param {string} nameOrPath - The name or path of the plugin to enable.
641
- * @returns {Promise<Plugin | null>} A promise that resolves to the enabled plugin object, or null if the plugin could not be enabled.
642
- */
643
461
  async disable(nameOrPath) {
644
462
  const { promises } = await import('node:fs');
645
463
  if (!nameOrPath)
@@ -675,16 +493,6 @@ export class PluginManager extends EventEmitter {
675
493
  return null;
676
494
  }
677
495
  }
678
- /**
679
- * Removes a plugin by its name or path.
680
- *
681
- * This method removes a plugin from the `_plugins` map and saves the updated plugin information to storage.
682
- * It first checks if the plugin is already registered in the `_plugins` map. If not, it attempts to resolve
683
- * the plugin's `package.json` file to retrieve its name and remove it.
684
- *
685
- * @param {string} nameOrPath - The name or path of the plugin to remove.
686
- * @returns {Promise<Plugin | null>} A promise that resolves to the removed plugin object, or null if the plugin could not be removed.
687
- */
688
496
  async remove(nameOrPath) {
689
497
  const { promises } = await import('node:fs');
690
498
  if (!nameOrPath)
@@ -720,17 +528,6 @@ export class PluginManager extends EventEmitter {
720
528
  return null;
721
529
  }
722
530
  }
723
- /**
724
- * Adds a plugin by its name or path.
725
- *
726
- * This method adds a plugin to the plugins map and saves the updated plugin information to storage.
727
- * It first resolves the plugin's `package.json` file to retrieve its details. If the plugin is already
728
- * registered, it logs an info message and returns null. Otherwise, it registers the plugin, enables it,
729
- * and saves the updated plugin information to storage.
730
- *
731
- * @param {string} nameOrPath - The name or path of the plugin to add.
732
- * @returns {Promise<Plugin | null>} A promise that resolves to the added plugin object, or null if the plugin could not be added.
733
- */
734
531
  async add(nameOrPath) {
735
532
  const { promises } = await import('node:fs');
736
533
  if (!nameOrPath)
@@ -770,15 +567,6 @@ export class PluginManager extends EventEmitter {
770
567
  return null;
771
568
  }
772
569
  }
773
- /**
774
- * Loads a plugin and returns the corresponding MatterbridgePlatform instance.
775
- *
776
- * @param {Plugin} plugin - The plugin to load.
777
- * @param {boolean} start - Optional flag indicating whether to start the plugin after loading. Default is false.
778
- * @param {string} message - Optional message to pass to the plugin when starting.
779
- * @param {boolean} configure - Optional flag indicating whether to configure the plugin after loading. Default is false.
780
- * @returns {Promise<MatterbridgePlatform | undefined>} A Promise that resolves to the loaded MatterbridgePlatform instance or undefined.
781
- */
782
570
  async load(plugin, start = false, message = '', configure = false) {
783
571
  const { promises } = await import('node:fs');
784
572
  const { default: path } = await import('node:path');
@@ -792,20 +580,15 @@ export class PluginManager extends EventEmitter {
792
580
  }
793
581
  this.log.info(`Loading plugin ${plg}${plugin.name}${nf} type ${typ}${plugin.type}${nf}`);
794
582
  try {
795
- // Load the package.json of the plugin
796
583
  const packageJson = JSON.parse(await promises.readFile(plugin.path, 'utf8'));
797
- // Resolve the main module path relative to package.json
798
584
  const pluginEntry = path.resolve(path.dirname(plugin.path), packageJson.main);
799
- // Dynamically import the plugin
800
585
  const { pathToFileURL } = await import('node:url');
801
586
  const pluginUrl = pathToFileURL(pluginEntry);
802
587
  this.log.debug(`Importing plugin ${plg}${plugin.name}${db} from ${pluginUrl.href}`);
803
588
  const pluginInstance = await import(pluginUrl.href);
804
589
  this.log.debug(`Imported plugin ${plg}${plugin.name}${db} from ${pluginUrl.href}`);
805
- // Call the default export function of the plugin, passing this MatterBridge instance, the log and the config
806
590
  if (pluginInstance.default) {
807
591
  const config = await this.loadConfig(plugin);
808
- // 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.
809
592
  plugin.name = packageJson.name;
810
593
  plugin.description = packageJson.description ?? 'No description';
811
594
  plugin.version = packageJson.version;
@@ -814,7 +597,7 @@ export class PluginManager extends EventEmitter {
814
597
  plugin.schemaJson = await this.loadSchema(plugin);
815
598
  config.name = plugin.name;
816
599
  config.version = packageJson.version;
817
- const log = new AnsiLogger({ logName: plugin.description, logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: config.debug ? "debug" /* LogLevel.DEBUG */ : this.matterbridge.log.logLevel });
600
+ const log = new AnsiLogger({ logName: plugin.description, logTimestampFormat: 4, logLevel: config.debug ? "debug" : this.matterbridge.log.logLevel });
818
601
  const platform = pluginInstance.default(this.matterbridge, log, config);
819
602
  config.type = platform.type;
820
603
  platform.name = packageJson.name;
@@ -832,7 +615,7 @@ export class PluginManager extends EventEmitter {
832
615
  plugin.platform = platform;
833
616
  plugin.loaded = true;
834
617
  plugin.registeredDevices = 0;
835
- await this.saveToStorage(); // Save the plugin to storage
618
+ await this.saveToStorage();
836
619
  this.log.notice(`Loaded plugin ${plg}${plugin.name}${nt} type ${typ}${platform.type}${nt} (entrypoint ${UNDERLINE}${pluginEntry}${UNDERLINEOFF})`);
837
620
  this.emit('loaded', plugin.name);
838
621
  if (start)
@@ -852,14 +635,6 @@ export class PluginManager extends EventEmitter {
852
635
  }
853
636
  return undefined;
854
637
  }
855
- /**
856
- * Starts a plugin.
857
- *
858
- * @param {Plugin} plugin - The plugin to start.
859
- * @param {string} [message] - Optional message to pass to the plugin's onStart method.
860
- * @param {boolean} [configure] - Indicates whether to configure the plugin after starting (default false).
861
- * @returns {Promise<Plugin | undefined>} A promise that resolves when the plugin is started successfully, or rejects with an error if starting the plugin fails.
862
- */
863
638
  async start(plugin, message, configure = false) {
864
639
  if (!plugin.loaded) {
865
640
  this.log.error(`Plugin ${plg}${plugin.name}${er} not loaded`);
@@ -890,12 +665,6 @@ export class PluginManager extends EventEmitter {
890
665
  }
891
666
  return undefined;
892
667
  }
893
- /**
894
- * Configures a plugin.
895
- *
896
- * @param {Plugin} plugin - The plugin to configure.
897
- * @returns {Promise<Plugin | undefined>} A promise that resolves when the plugin is configured successfully, or rejects with an error if configuration fails.
898
- */
899
668
  async configure(plugin) {
900
669
  if (!plugin.loaded) {
901
670
  this.log.error(`Plugin ${plg}${plugin.name}${er} not loaded`);
@@ -927,18 +696,6 @@ export class PluginManager extends EventEmitter {
927
696
  }
928
697
  return undefined;
929
698
  }
930
- /**
931
- * Shuts down a plugin.
932
- *
933
- * This method shuts down a plugin by calling its `onShutdown` method and resetting its state.
934
- * It logs the shutdown process and optionally removes all devices associated with the plugin.
935
- *
936
- * @param {Plugin} plugin - The plugin to shut down.
937
- * @param {string} [reason] - The reason for shutting down the plugin.
938
- * @param {boolean} [removeAllDevices] - Whether to remove all devices associated with the plugin.
939
- * @param {boolean} [force] - Whether to force the shutdown even if the plugin is not loaded or started.
940
- * @returns {Promise<Plugin | undefined>} A promise that resolves to the shut down plugin object, or undefined if the shutdown failed.
941
- */
942
699
  async shutdown(plugin, reason, removeAllDevices = false, force = false) {
943
700
  this.log.debug(`Shutting down plugin ${plg}${plugin.name}${db}`);
944
701
  if (!plugin.loaded) {
@@ -981,15 +738,6 @@ export class PluginManager extends EventEmitter {
981
738
  }
982
739
  return undefined;
983
740
  }
984
- /**
985
- * Loads the configuration for a plugin.
986
- * If the configuration file exists, it reads the file and returns the parsed JSON data.
987
- * If the configuration file does not exist, it creates a new file with default configuration and returns it.
988
- * If any error occurs during file access or creation, it logs an error and return un empty config.
989
- *
990
- * @param {Plugin} plugin - The plugin for which to load the configuration.
991
- * @returns {Promise<PlatformConfig>} A promise that resolves to the loaded or created configuration.
992
- */
993
741
  async loadConfig(plugin) {
994
742
  const { default: path } = await import('node:path');
995
743
  const { promises } = await import('node:fs');
@@ -1001,8 +749,6 @@ export class PluginManager extends EventEmitter {
1001
749
  const data = await promises.readFile(configFile, 'utf8');
1002
750
  const config = JSON.parse(data);
1003
751
  this.log.debug(`Loaded config file ${configFile} for plugin ${plg}${plugin.name}${db}.`);
1004
- // this.log.debug(`Loaded config file ${configFile} for plugin ${plg}${plugin.name}${db}.\nConfig:${rs}\n`, config);
1005
- // The first time a plugin is added to the system, the config file is created with the plugin name and type "AnyPlatform".
1006
752
  config.name = plugin.name;
1007
753
  config.type = plugin.type;
1008
754
  if (config.debug === undefined)
@@ -1024,8 +770,6 @@ export class PluginManager extends EventEmitter {
1024
770
  }
1025
771
  catch (_err) {
1026
772
  this.log.debug(`Default config file ${defaultConfigFile} for plugin ${plg}${plugin.name}${db} does not exist, creating new config file...`);
1027
- // TODO: Remove this when all these plugins have their own default config file
1028
- // istanbul ignore next if
1029
773
  if (plugin.name === 'matterbridge-zigbee2mqtt')
1030
774
  config = zigbee2mqtt_config;
1031
775
  else if (plugin.name === 'matterbridge-somfy-tahoma')
@@ -1038,7 +782,6 @@ export class PluginManager extends EventEmitter {
1038
782
  try {
1039
783
  await promises.writeFile(configFile, JSON.stringify(config, null, 2), 'utf8');
1040
784
  this.log.debug(`Created config file ${configFile} for plugin ${plg}${plugin.name}${db}.`);
1041
- // this.log.debug(`Created config file ${configFile} for plugin ${plg}${plugin.name}${db}.\nConfig:${rs}\n`, config);
1042
785
  return config;
1043
786
  }
1044
787
  catch (err) {
@@ -1052,19 +795,6 @@ export class PluginManager extends EventEmitter {
1052
795
  }
1053
796
  }
1054
797
  }
1055
- /**
1056
- * Saves the configuration of a plugin to a file.
1057
- *
1058
- * This method saves the configuration of the specified plugin to a JSON file in the matterbridge directory.
1059
- * If the plugin's configuration is not found, it logs an error and rejects the promise. If the configuration
1060
- * is successfully saved, it logs a debug message. If an error occurs during the file write operation, it logs
1061
- * the error and rejects the promise.
1062
- *
1063
- * @param {Plugin} plugin - The plugin whose configuration is to be saved.
1064
- * @param {boolean} [restartRequired] - Indicates whether a restart is required after saving the configuration.
1065
- * @returns {Promise<void>} A promise that resolves when the configuration is successfully saved, or rejects if an error occurs.
1066
- * @throws {Error} If the plugin's configuration is not found.
1067
- */
1068
798
  async saveConfigFromPlugin(plugin, restartRequired = false) {
1069
799
  const { default: path } = await import('node:path');
1070
800
  const { promises } = await import('node:fs');
@@ -1079,7 +809,6 @@ export class PluginManager extends EventEmitter {
1079
809
  if (restartRequired)
1080
810
  plugin.restartRequired = true;
1081
811
  this.log.debug(`Saved config file ${configFile} for plugin ${plg}${plugin.name}${db}`);
1082
- // this.log.debug(`Saved config file ${configFile} for plugin ${plg}${plugin.name}${db}.\nConfig:${rs}\n`, plugin.platform.config);
1083
812
  return Promise.resolve();
1084
813
  }
1085
814
  catch (err) {
@@ -1087,20 +816,6 @@ export class PluginManager extends EventEmitter {
1087
816
  return Promise.reject(err);
1088
817
  }
1089
818
  }
1090
- /**
1091
- * Saves the configuration of a plugin from a JSON object to a file.
1092
- *
1093
- * This method saves the provided configuration of the specified plugin to a JSON file in the matterbridge directory.
1094
- * It first checks if the configuration data is valid by ensuring it contains the correct name and type, and matches
1095
- * the plugin's name. If the configuration data is invalid, it logs an error and returns. If the configuration is
1096
- * successfully saved, it updates the plugin's `configJson` property and logs a debug message. If an error occurs
1097
- * during the file write operation, it logs the error and returns.
1098
- *
1099
- * @param {Plugin} plugin - The plugin whose configuration is to be saved.
1100
- * @param {PlatformConfig} config - The configuration data to be saved.
1101
- * @param {boolean} [restartRequired] - Indicates whether a restart is required after saving the configuration.
1102
- * @returns {Promise<void>} A promise that resolves when the configuration is successfully saved, or returns if an error occurs.
1103
- */
1104
819
  async saveConfigFromJson(plugin, config, restartRequired = false) {
1105
820
  const { default: path } = await import('node:path');
1106
821
  const { promises } = await import('node:fs');
@@ -1119,23 +834,12 @@ export class PluginManager extends EventEmitter {
1119
834
  plugin.platform.onConfigChanged(config).catch((err) => this.log.error(`Error calling onConfigChanged for plugin ${plg}${plugin.name}${er}: ${err}`));
1120
835
  }
1121
836
  this.log.debug(`Saved config file ${configFile} for plugin ${plg}${plugin.name}${db}`);
1122
- // this.log.debug(`Saved config file ${configFile} for plugin ${plg}${plugin.name}${db}.\nConfig:${rs}\n`, config);
1123
837
  }
1124
838
  catch (err) {
1125
839
  logError(this.log, `Error saving config file ${configFile} for plugin ${plg}${plugin.name}${er}`, err);
1126
840
  return;
1127
841
  }
1128
842
  }
1129
- /**
1130
- * Loads the schema for a plugin.
1131
- *
1132
- * This method attempts to load the schema file for the specified plugin. If the schema file is found,
1133
- * it reads and parses the file, updates the schema's title and description, and logs the process.
1134
- * If the schema file is not found, it logs the event and loads a default schema for the plugin.
1135
- *
1136
- * @param {Plugin} plugin - The plugin whose schema is to be loaded.
1137
- * @returns {Promise<PlatformSchema>} A promise that resolves to the loaded schema object, or the default schema if the schema file is not found.
1138
- */
1139
843
  async loadSchema(plugin) {
1140
844
  const { promises } = await import('node:fs');
1141
845
  const schemaFile = plugin.path.replace('package.json', `${plugin.name}.schema.json`);
@@ -1146,7 +850,6 @@ export class PluginManager extends EventEmitter {
1146
850
  schema.title = plugin.description;
1147
851
  schema.description = plugin.name + ' v. ' + plugin.version + ' by ' + plugin.author;
1148
852
  this.log.debug(`Loaded schema file ${schemaFile} for plugin ${plg}${plugin.name}${db}.`);
1149
- // this.log.debug(`Loaded schema file ${schemaFile} for plugin ${plg}${plugin.name}${db}.\nSchema:${rs}\n`, schema);
1150
853
  return schema;
1151
854
  }
1152
855
  catch (_err) {
@@ -1154,16 +857,6 @@ export class PluginManager extends EventEmitter {
1154
857
  return this.getDefaultSchema(plugin);
1155
858
  }
1156
859
  }
1157
- /**
1158
- * Returns the default schema for a plugin.
1159
- *
1160
- * This method generates a default schema object for the specified plugin. The schema includes
1161
- * metadata such as the plugin's title, description, version, and author. It also defines the
1162
- * properties of the schema, including the plugin's name, type, debug flag, and unregisterOnShutdown flag.
1163
- *
1164
- * @param {Plugin} plugin - The plugin for which the default schema is to be generated.
1165
- * @returns {PlatformSchema} The default schema object for the plugin.
1166
- */
1167
860
  getDefaultSchema(plugin) {
1168
861
  return {
1169
862
  title: plugin.description,
@@ -1194,4 +887,3 @@ export class PluginManager extends EventEmitter {
1194
887
  };
1195
888
  }
1196
889
  }
1197
- //# sourceMappingURL=pluginManager.js.map