matterbridge 3.5.2 → 3.5.3-dev-20260202-e19e9b6

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 (280) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/README-DOCKER.md +2 -2
  3. package/README.md +14 -9
  4. package/dist/broadcastServer.d.ts +0 -115
  5. package/dist/broadcastServer.js +0 -117
  6. package/dist/broadcastServerTypes.d.ts +0 -43
  7. package/dist/broadcastServerTypes.js +0 -24
  8. package/dist/checkUpdates.d.ts +0 -75
  9. package/dist/checkUpdates.js +1 -91
  10. package/dist/cli.d.ts +0 -24
  11. package/dist/cli.js +1 -97
  12. package/dist/cliEmitter.d.ts +0 -36
  13. package/dist/cliEmitter.js +0 -37
  14. package/dist/cliHistory.d.ts +0 -42
  15. package/dist/cliHistory.js +0 -38
  16. package/dist/clusters/export.d.ts +0 -1
  17. package/dist/clusters/export.js +0 -2
  18. package/dist/deviceManager.d.ts +0 -108
  19. package/dist/deviceManager.js +1 -114
  20. package/dist/devices/airConditioner.d.ts +0 -75
  21. package/dist/devices/airConditioner.js +0 -57
  22. package/dist/devices/basicVideoPlayer.d.ts +0 -58
  23. package/dist/devices/basicVideoPlayer.js +1 -56
  24. package/dist/devices/batteryStorage.d.ts +0 -43
  25. package/dist/devices/batteryStorage.js +1 -48
  26. package/dist/devices/castingVideoPlayer.d.ts +0 -63
  27. package/dist/devices/castingVideoPlayer.js +2 -65
  28. package/dist/devices/cooktop.d.ts +0 -55
  29. package/dist/devices/cooktop.js +0 -56
  30. package/dist/devices/dishwasher.d.ts +0 -55
  31. package/dist/devices/dishwasher.js +0 -57
  32. package/dist/devices/evse.d.ts +0 -57
  33. package/dist/devices/evse.js +10 -74
  34. package/dist/devices/export.d.ts +0 -1
  35. package/dist/devices/export.js +0 -5
  36. package/dist/devices/extractorHood.d.ts +0 -41
  37. package/dist/devices/extractorHood.js +0 -43
  38. package/dist/devices/heatPump.d.ts +0 -43
  39. package/dist/devices/heatPump.js +2 -50
  40. package/dist/devices/laundryDryer.d.ts +0 -58
  41. package/dist/devices/laundryDryer.js +3 -62
  42. package/dist/devices/laundryWasher.d.ts +0 -64
  43. package/dist/devices/laundryWasher.js +4 -70
  44. package/dist/devices/microwaveOven.d.ts +1 -77
  45. package/dist/devices/microwaveOven.js +5 -88
  46. package/dist/devices/oven.d.ts +0 -82
  47. package/dist/devices/oven.js +0 -85
  48. package/dist/devices/refrigerator.d.ts +0 -100
  49. package/dist/devices/refrigerator.js +0 -102
  50. package/dist/devices/roboticVacuumCleaner.d.ts +0 -83
  51. package/dist/devices/roboticVacuumCleaner.js +9 -100
  52. package/dist/devices/solarPower.d.ts +0 -36
  53. package/dist/devices/solarPower.js +0 -38
  54. package/dist/devices/speaker.d.ts +0 -79
  55. package/dist/devices/speaker.js +0 -84
  56. package/dist/devices/temperatureControl.d.ts +0 -21
  57. package/dist/devices/temperatureControl.js +3 -24
  58. package/dist/devices/waterHeater.d.ts +0 -74
  59. package/dist/devices/waterHeater.js +2 -82
  60. package/dist/dgram/export.d.ts +0 -1
  61. package/dist/dgram/export.js +0 -1
  62. package/dist/frontend.d.ts +0 -187
  63. package/dist/frontend.js +37 -498
  64. package/dist/frontendTypes.d.ts +0 -57
  65. package/dist/frontendTypes.js +0 -45
  66. package/dist/helpers.d.ts +0 -43
  67. package/dist/helpers.js +0 -54
  68. package/dist/index.d.ts +0 -23
  69. package/dist/index.js +0 -25
  70. package/dist/jestutils/export.d.ts +0 -1
  71. package/dist/jestutils/export.js +0 -1
  72. package/dist/jestutils/jestHelpers.d.ts +0 -255
  73. package/dist/jestutils/jestHelpers.js +15 -371
  74. package/dist/logger/export.d.ts +0 -1
  75. package/dist/logger/export.js +0 -1
  76. package/dist/matter/behaviors.d.ts +0 -1
  77. package/dist/matter/behaviors.js +0 -2
  78. package/dist/matter/clusters.d.ts +0 -1
  79. package/dist/matter/clusters.js +0 -2
  80. package/dist/matter/devices.d.ts +0 -1
  81. package/dist/matter/devices.js +0 -2
  82. package/dist/matter/endpoints.d.ts +0 -1
  83. package/dist/matter/endpoints.js +0 -2
  84. package/dist/matter/export.d.ts +0 -1
  85. package/dist/matter/export.js +0 -2
  86. package/dist/matter/types.d.ts +0 -1
  87. package/dist/matter/types.js +0 -2
  88. package/dist/matterNode.d.ts +0 -258
  89. package/dist/matterNode.js +8 -359
  90. package/dist/matterbridge.d.ts +0 -373
  91. package/dist/matterbridge.js +46 -854
  92. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
  93. package/dist/matterbridgeAccessoryPlatform.js +0 -50
  94. package/dist/matterbridgeBehaviors.d.ts +0 -24
  95. package/dist/matterbridgeBehaviors.js +5 -65
  96. package/dist/matterbridgeDeviceTypes.d.ts +0 -649
  97. package/dist/matterbridgeDeviceTypes.js +6 -673
  98. package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
  99. package/dist/matterbridgeDynamicPlatform.js +0 -50
  100. package/dist/matterbridgeEndpoint.d.ts +0 -1369
  101. package/dist/matterbridgeEndpoint.js +54 -1507
  102. package/dist/matterbridgeEndpointHelpers.d.ts +0 -425
  103. package/dist/matterbridgeEndpointHelpers.js +20 -482
  104. package/dist/matterbridgeEndpointTypes.d.ts +0 -70
  105. package/dist/matterbridgeEndpointTypes.js +0 -25
  106. package/dist/matterbridgePlatform.d.ts +0 -434
  107. package/dist/matterbridgePlatform.js +1 -472
  108. package/dist/matterbridgePlatformTypes.d.ts +0 -29
  109. package/dist/matterbridgePlatformTypes.js +0 -24
  110. package/dist/matterbridgeTypes.d.ts +0 -46
  111. package/dist/matterbridgeTypes.js +0 -26
  112. package/dist/mb_coap.d.ts +0 -23
  113. package/dist/mb_coap.js +3 -41
  114. package/dist/mb_health.d.ts +0 -67
  115. package/dist/mb_health.js +0 -70
  116. package/dist/mb_mdns.d.ts +0 -23
  117. package/dist/mb_mdns.js +36 -94
  118. package/dist/pluginManager.d.ts +0 -305
  119. package/dist/pluginManager.js +5 -342
  120. package/dist/shelly.d.ts +0 -157
  121. package/dist/shelly.js +7 -178
  122. package/dist/spawn.d.ts +0 -32
  123. package/dist/spawn.js +1 -71
  124. package/dist/storage/export.d.ts +0 -1
  125. package/dist/storage/export.js +0 -1
  126. package/dist/utils/export.d.ts +0 -1
  127. package/dist/utils/export.js +0 -1
  128. package/dist/worker.d.ts +0 -61
  129. package/dist/worker.js +4 -65
  130. package/dist/workerCheckUpdates.d.ts +0 -24
  131. package/dist/workerCheckUpdates.js +5 -36
  132. package/dist/workerGlobalPrefix.d.ts +0 -24
  133. package/dist/workerGlobalPrefix.js +5 -36
  134. package/dist/workerTypes.d.ts +0 -25
  135. package/dist/workerTypes.js +0 -24
  136. package/frontend/build/assets/index.js +4 -4
  137. package/frontend/build/assets/vendor_emotion.js +1 -1
  138. package/frontend/build/assets/vendor_lodash.js +1 -1
  139. package/frontend/build/assets/vendor_mdi.js +1 -1
  140. package/frontend/build/assets/vendor_mui.js +22 -22
  141. package/frontend/build/assets/vendor_node_modules.js +20 -20
  142. package/frontend/build/assets/vendor_notistack.js +2 -2
  143. package/frontend/build/assets/vendor_qrcode.js +1 -1
  144. package/frontend/build/assets/vendor_rjsf.js +8 -8
  145. package/frontend/build/index.html +1 -1
  146. package/frontend/package.json +48 -47
  147. package/npm-shrinkwrap.json +77 -47
  148. package/package.json +7 -7
  149. package/dist/broadcastServer.d.ts.map +0 -1
  150. package/dist/broadcastServer.js.map +0 -1
  151. package/dist/broadcastServerTypes.d.ts.map +0 -1
  152. package/dist/broadcastServerTypes.js.map +0 -1
  153. package/dist/checkUpdates.d.ts.map +0 -1
  154. package/dist/checkUpdates.js.map +0 -1
  155. package/dist/cli.d.ts.map +0 -1
  156. package/dist/cli.js.map +0 -1
  157. package/dist/cliEmitter.d.ts.map +0 -1
  158. package/dist/cliEmitter.js.map +0 -1
  159. package/dist/cliHistory.d.ts.map +0 -1
  160. package/dist/cliHistory.js.map +0 -1
  161. package/dist/clusters/export.d.ts.map +0 -1
  162. package/dist/clusters/export.js.map +0 -1
  163. package/dist/deviceManager.d.ts.map +0 -1
  164. package/dist/deviceManager.js.map +0 -1
  165. package/dist/devices/airConditioner.d.ts.map +0 -1
  166. package/dist/devices/airConditioner.js.map +0 -1
  167. package/dist/devices/basicVideoPlayer.d.ts.map +0 -1
  168. package/dist/devices/basicVideoPlayer.js.map +0 -1
  169. package/dist/devices/batteryStorage.d.ts.map +0 -1
  170. package/dist/devices/batteryStorage.js.map +0 -1
  171. package/dist/devices/castingVideoPlayer.d.ts.map +0 -1
  172. package/dist/devices/castingVideoPlayer.js.map +0 -1
  173. package/dist/devices/cooktop.d.ts.map +0 -1
  174. package/dist/devices/cooktop.js.map +0 -1
  175. package/dist/devices/dishwasher.d.ts.map +0 -1
  176. package/dist/devices/dishwasher.js.map +0 -1
  177. package/dist/devices/evse.d.ts.map +0 -1
  178. package/dist/devices/evse.js.map +0 -1
  179. package/dist/devices/export.d.ts.map +0 -1
  180. package/dist/devices/export.js.map +0 -1
  181. package/dist/devices/extractorHood.d.ts.map +0 -1
  182. package/dist/devices/extractorHood.js.map +0 -1
  183. package/dist/devices/heatPump.d.ts.map +0 -1
  184. package/dist/devices/heatPump.js.map +0 -1
  185. package/dist/devices/laundryDryer.d.ts.map +0 -1
  186. package/dist/devices/laundryDryer.js.map +0 -1
  187. package/dist/devices/laundryWasher.d.ts.map +0 -1
  188. package/dist/devices/laundryWasher.js.map +0 -1
  189. package/dist/devices/microwaveOven.d.ts.map +0 -1
  190. package/dist/devices/microwaveOven.js.map +0 -1
  191. package/dist/devices/oven.d.ts.map +0 -1
  192. package/dist/devices/oven.js.map +0 -1
  193. package/dist/devices/refrigerator.d.ts.map +0 -1
  194. package/dist/devices/refrigerator.js.map +0 -1
  195. package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
  196. package/dist/devices/roboticVacuumCleaner.js.map +0 -1
  197. package/dist/devices/solarPower.d.ts.map +0 -1
  198. package/dist/devices/solarPower.js.map +0 -1
  199. package/dist/devices/speaker.d.ts.map +0 -1
  200. package/dist/devices/speaker.js.map +0 -1
  201. package/dist/devices/temperatureControl.d.ts.map +0 -1
  202. package/dist/devices/temperatureControl.js.map +0 -1
  203. package/dist/devices/waterHeater.d.ts.map +0 -1
  204. package/dist/devices/waterHeater.js.map +0 -1
  205. package/dist/dgram/export.d.ts.map +0 -1
  206. package/dist/dgram/export.js.map +0 -1
  207. package/dist/frontend.d.ts.map +0 -1
  208. package/dist/frontend.js.map +0 -1
  209. package/dist/frontendTypes.d.ts.map +0 -1
  210. package/dist/frontendTypes.js.map +0 -1
  211. package/dist/helpers.d.ts.map +0 -1
  212. package/dist/helpers.js.map +0 -1
  213. package/dist/index.d.ts.map +0 -1
  214. package/dist/index.js.map +0 -1
  215. package/dist/jestutils/export.d.ts.map +0 -1
  216. package/dist/jestutils/export.js.map +0 -1
  217. package/dist/jestutils/jestHelpers.d.ts.map +0 -1
  218. package/dist/jestutils/jestHelpers.js.map +0 -1
  219. package/dist/logger/export.d.ts.map +0 -1
  220. package/dist/logger/export.js.map +0 -1
  221. package/dist/matter/behaviors.d.ts.map +0 -1
  222. package/dist/matter/behaviors.js.map +0 -1
  223. package/dist/matter/clusters.d.ts.map +0 -1
  224. package/dist/matter/clusters.js.map +0 -1
  225. package/dist/matter/devices.d.ts.map +0 -1
  226. package/dist/matter/devices.js.map +0 -1
  227. package/dist/matter/endpoints.d.ts.map +0 -1
  228. package/dist/matter/endpoints.js.map +0 -1
  229. package/dist/matter/export.d.ts.map +0 -1
  230. package/dist/matter/export.js.map +0 -1
  231. package/dist/matter/types.d.ts.map +0 -1
  232. package/dist/matter/types.js.map +0 -1
  233. package/dist/matterNode.d.ts.map +0 -1
  234. package/dist/matterNode.js.map +0 -1
  235. package/dist/matterbridge.d.ts.map +0 -1
  236. package/dist/matterbridge.js.map +0 -1
  237. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  238. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  239. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  240. package/dist/matterbridgeBehaviors.js.map +0 -1
  241. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  242. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  243. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  244. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  245. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  246. package/dist/matterbridgeEndpoint.js.map +0 -1
  247. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  248. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  249. package/dist/matterbridgeEndpointTypes.d.ts.map +0 -1
  250. package/dist/matterbridgeEndpointTypes.js.map +0 -1
  251. package/dist/matterbridgePlatform.d.ts.map +0 -1
  252. package/dist/matterbridgePlatform.js.map +0 -1
  253. package/dist/matterbridgePlatformTypes.d.ts.map +0 -1
  254. package/dist/matterbridgePlatformTypes.js.map +0 -1
  255. package/dist/matterbridgeTypes.d.ts.map +0 -1
  256. package/dist/matterbridgeTypes.js.map +0 -1
  257. package/dist/mb_coap.d.ts.map +0 -1
  258. package/dist/mb_coap.js.map +0 -1
  259. package/dist/mb_health.d.ts.map +0 -1
  260. package/dist/mb_health.js.map +0 -1
  261. package/dist/mb_mdns.d.ts.map +0 -1
  262. package/dist/mb_mdns.js.map +0 -1
  263. package/dist/pluginManager.d.ts.map +0 -1
  264. package/dist/pluginManager.js.map +0 -1
  265. package/dist/shelly.d.ts.map +0 -1
  266. package/dist/shelly.js.map +0 -1
  267. package/dist/spawn.d.ts.map +0 -1
  268. package/dist/spawn.js.map +0 -1
  269. package/dist/storage/export.d.ts.map +0 -1
  270. package/dist/storage/export.js.map +0 -1
  271. package/dist/utils/export.d.ts.map +0 -1
  272. package/dist/utils/export.js.map +0 -1
  273. package/dist/worker.d.ts.map +0 -1
  274. package/dist/worker.js.map +0 -1
  275. package/dist/workerCheckUpdates.d.ts.map +0 -1
  276. package/dist/workerCheckUpdates.js.map +0 -1
  277. package/dist/workerGlobalPrefix.d.ts.map +0 -1
  278. package/dist/workerGlobalPrefix.js.map +0 -1
  279. package/dist/workerTypes.d.ts.map +0 -1
  280. package/dist/workerTypes.js.map +0 -1
package/dist/spawn.js CHANGED
@@ -1,69 +1,28 @@
1
- /**
2
- * @description This file contains the spawn functions.
3
- * @file spawn.ts
4
- * @author Luca Liguori
5
- * @created 2025-02-16
6
- * @version 1.2.0
7
- * @license Apache-2.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
1
  import { AnsiLogger } from 'node-ansi-logger';
24
2
  import { hasParameter } from '@matterbridge/utils';
25
3
  import { BroadcastServer } from './broadcastServer.js';
26
- /**
27
- * Spawns a child process with the given command and arguments.
28
- *
29
- * @param {string} command - The command to execute.
30
- * @param {string[]} args - The arguments to pass to the command (default: []).
31
- * @param {'install' | 'uninstall'} packageCommand - The optional package command being executed (e.g., 'install', 'uninstall').
32
- * @param {string} [packageName] - The optional name of the package being installed.
33
- * @returns {Promise<boolean>} A promise that resolves to true if the command executed successfully, false otherwise.
34
- */
35
4
  export async function spawnCommand(command, args, packageCommand, packageName) {
36
5
  const { spawn } = await import('node:child_process');
37
- /** Broadcast server */
38
6
  const debug = hasParameter('debug') || hasParameter('verbose');
39
7
  const verbose = hasParameter('verbose');
40
- const log = new AnsiLogger({ logName: 'Spawn', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: debug ? "debug" /* LogLevel.DEBUG */ : "info" /* LogLevel.INFO */ });
8
+ const log = new AnsiLogger({ logName: 'Spawn', logTimestampFormat: 4, logLevel: debug ? "debug" : "info" });
41
9
  const server = new BroadcastServer('spawn', log);
42
10
  const sendLog = (name, message) => {
43
11
  try {
44
12
  server.request({ type: 'frontend_logmessage', src: 'spawn', dst: 'frontend', params: { level: 'spawn', time: log.now(), name, message } });
45
13
  }
46
14
  catch (err) {
47
- // istanbul ignore next cause it's a precaution
48
15
  log.debug(`Failed to send log message to frontend: ${err instanceof Error ? err.message : String(err)}`);
49
16
  }
50
17
  };
51
18
  if (verbose)
52
19
  log.debug(`Spawning command: ${command} with ${args.join(' ')} ${packageCommand} ${packageName}`);
53
- /*
54
- * npm > npm.cmd on windows
55
- * cmd.exe ['dir'] on windows
56
- */
57
20
  const cmdLine = command + ' ' + args.join(' ');
58
21
  if (process.platform === 'win32' && command === 'npm') {
59
- // Must be spawn('cmd.exe', ['/c', 'npm -g install <package>']);
60
22
  const argstring = 'npm ' + args.join(' ');
61
23
  args.splice(0, args.length, '/c', argstring);
62
24
  command = 'cmd.exe';
63
25
  }
64
- // Decide when using sudo on linux and macOS
65
- // When you need sudo: Spawn stderr: npm error Error: EACCES: permission denied
66
- // When you don't need sudo: Failed to start child process "npm install -g matterbridge-eve-door": spawn sudo ENOENT
67
26
  if (hasParameter('sudo') || (process.platform !== 'win32' && command === 'npm' && !hasParameter('docker') && !hasParameter('nosudo'))) {
68
27
  args.unshift(command);
69
28
  command = 'sudo';
@@ -119,20 +78,6 @@ export async function spawnCommand(command, args, packageCommand, packageName) {
119
78
  sendLog('Matterbridge:spawn', line);
120
79
  }
121
80
  });
122
- /*
123
- childProcess.stdout.on('close', () => {
124
- log.debug(`Spawn output (stdout): closed`);
125
- resolve(true);
126
- });
127
- childProcess.stdout.on('end', () => {
128
- log.debug(`Spawn output (stdout): ended`);
129
- resolve(true);
130
- });
131
- childProcess.stdout.on('error', () => {
132
- log.debug(`Spawn output (stdout): error`);
133
- resolve(true);
134
- });
135
- */
136
81
  }
137
82
  if (childProcess.stderr) {
138
83
  childProcess.stderr.on('data', (data) => {
@@ -143,23 +88,8 @@ export async function spawnCommand(command, args, packageCommand, packageName) {
143
88
  sendLog('Matterbridge:spawn', line);
144
89
  }
145
90
  });
146
- /*
147
- childProcess.stderr.on('close', () => {
148
- log.debug(`Spawn verbose (stderr): closed`);
149
- resolve(true);
150
- });
151
- childProcess.stderr.on('end', () => {
152
- log.debug(`Spawn verbose (stderr): ended`);
153
- resolve(true);
154
- });
155
- childProcess.stderr.on('error', () => {
156
- log.debug(`Spawn verbose (stderr): error`);
157
- resolve(true);
158
- });
159
- */
160
91
  }
161
92
  });
162
93
  server.close();
163
94
  return success;
164
95
  }
165
- //# sourceMappingURL=spawn.js.map
@@ -1,2 +1 @@
1
1
  export * from 'node-persist-manager';
2
- //# sourceMappingURL=export.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from 'node-persist-manager';
2
- //# sourceMappingURL=export.js.map
@@ -1,2 +1 @@
1
1
  export * from '@matterbridge/utils';
2
- //# sourceMappingURL=export.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from '@matterbridge/utils';
2
- //# sourceMappingURL=export.js.map
package/dist/worker.d.ts CHANGED
@@ -1,68 +1,7 @@
1
- /**
2
- * This file contains the worker functions.
3
- *
4
- * @file workers.ts
5
- * @author Luca Liguori
6
- * @created 2025-11-25
7
- * @version 1.1.0
8
- * @license Apache-2.0
9
- *
10
- * Copyright 2025, 2026, 2027 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
1
  import { Worker } from 'node:worker_threads';
25
2
  import { AnsiLogger, LogLevel } from 'node-ansi-logger';
26
3
  import type { ParentPortMessage } from './workerTypes.js';
27
- /**
28
- * Sends a control message to the parent through parentPort
29
- *
30
- * @param {ControlMessage} message - The control message to send.
31
- */
32
4
  export declare function parentPost(message: ParentPortMessage): void;
33
- /**
34
- * Sends a control message to the parent through parentPort to log a message.
35
- *
36
- * @param {string | undefined} logName - The name of the logger.
37
- * @param {LogLevel} logLevel - The log level of the message.
38
- * @param {string} message - The log message to send.
39
- */
40
5
  export declare function parentLog(logName: string | undefined, logLevel: LogLevel, message: string): void;
41
- /**
42
- * Typed helper to create an ESM Worker.
43
- *
44
- * This function uses pathToFileURL to convert the relative path to a file URL,
45
- * which is necessary for ESM modules. It also sets the worker type to 'module'.
46
- *
47
- * @param {string} name - name of the worker
48
- * @param {string} relativePath - path to the worker file code: it must be an ESM module in javascript
49
- * @param {Record<string, boolean | number | string | object>} [workerData] - optional data to pass to the worker
50
- * @param {string[]} [argv] - optional command line arguments to pass to the worker. If not provided, inherits from the main thread.
51
- * @param {NodeJS.ProcessEnv} [env] - optional environment variables to pass to the worker. If not provided, inherits from the main thread.
52
- * @param {string[]} [execArgv] - optional execArgv to pass to the worker. If not provided no execArgv are passed.
53
- * @returns {Worker} - the created Worker instance
54
- *
55
- * @example
56
- * ```typescript
57
- * createESMWorker('NpmCommand', './dist/npmCommand.js', { command: 'npm list --global --depth=0' });
58
- * ```
59
- */
60
6
  export declare function createESMWorker(name: string, relativePath: string, workerData?: Record<string, boolean | number | string | object>, argv?: string[], env?: NodeJS.ProcessEnv, execArgv?: string[]): Worker;
61
- /**
62
- * Log worker information.
63
- *
64
- * @param {AnsiLogger} log - The logger instance to use for logging.
65
- * @param {boolean} [logEnv] - Whether to log environment variables. Defaults to false.
66
- */
67
7
  export declare function logWorkerInfo(log: AnsiLogger, logEnv?: boolean): void;
68
- //# sourceMappingURL=worker.d.ts.map
package/dist/worker.js CHANGED
@@ -1,90 +1,30 @@
1
- /**
2
- * This file contains the worker functions.
3
- *
4
- * @file workers.ts
5
- * @author Luca Liguori
6
- * @created 2025-11-25
7
- * @version 1.1.0
8
- * @license Apache-2.0
9
- *
10
- * Copyright 2025, 2026, 2027 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
1
  import { isMainThread, parentPort, threadId, Worker, workerData } from 'node:worker_threads';
25
2
  import { pathToFileURL } from 'node:url';
26
3
  import { resolve } from 'node:path';
27
4
  import { inspect } from 'node:util';
28
- /**
29
- * Sends a control message to the parent through parentPort
30
- *
31
- * @param {ControlMessage} message - The control message to send.
32
- */
33
5
  export function parentPost(message) {
34
6
  if (!parentPort)
35
7
  throw new Error(`WorkerServer ${workerData.threadName}: parentPort is not available.`);
36
8
  parentPort.postMessage(message);
37
9
  }
38
- /**
39
- * Sends a control message to the parent through parentPort to log a message.
40
- *
41
- * @param {string | undefined} logName - The name of the logger.
42
- * @param {LogLevel} logLevel - The log level of the message.
43
- * @param {string} message - The log message to send.
44
- */
45
10
  export function parentLog(logName, logLevel, message) {
46
11
  if (!parentPort)
47
12
  throw new Error(`WorkerServer ${workerData.threadName}: parentPort is not available.`);
48
13
  const logMessage = { type: 'log', threadId, threadName: workerData.threadName, logName, logLevel, message };
49
14
  parentPort.postMessage(logMessage);
50
15
  }
51
- /**
52
- * Typed helper to create an ESM Worker.
53
- *
54
- * This function uses pathToFileURL to convert the relative path to a file URL,
55
- * which is necessary for ESM modules. It also sets the worker type to 'module'.
56
- *
57
- * @param {string} name - name of the worker
58
- * @param {string} relativePath - path to the worker file code: it must be an ESM module in javascript
59
- * @param {Record<string, boolean | number | string | object>} [workerData] - optional data to pass to the worker
60
- * @param {string[]} [argv] - optional command line arguments to pass to the worker. If not provided, inherits from the main thread.
61
- * @param {NodeJS.ProcessEnv} [env] - optional environment variables to pass to the worker. If not provided, inherits from the main thread.
62
- * @param {string[]} [execArgv] - optional execArgv to pass to the worker. If not provided no execArgv are passed.
63
- * @returns {Worker} - the created Worker instance
64
- *
65
- * @example
66
- * ```typescript
67
- * createESMWorker('NpmCommand', './dist/npmCommand.js', { command: 'npm list --global --depth=0' });
68
- * ```
69
- */
70
16
  export function createESMWorker(name, relativePath, workerData, argv, env, execArgv) {
71
17
  const fileURL = pathToFileURL(resolve(relativePath));
72
18
  const options = {
73
- workerData: { ...workerData, threadName: name }, // Pass threadName in workerData cause worker_threads don't have it natively in node 20
19
+ workerData: { ...workerData, threadName: name },
74
20
  type: 'module',
75
21
  name,
76
- argv: argv ?? process.argv.slice(2), // Pass command line arguments to worker
77
- env: env ?? process.env, // Inherit environment variables
78
- execArgv, // execArgv for node like --inspect
22
+ argv: argv ?? process.argv.slice(2),
23
+ env: env ?? process.env,
24
+ execArgv,
79
25
  };
80
26
  return new Worker(fileURL, options);
81
27
  }
82
- /**
83
- * Log worker information.
84
- *
85
- * @param {AnsiLogger} log - The logger instance to use for logging.
86
- * @param {boolean} [logEnv] - Whether to log environment variables. Defaults to false.
87
- */
88
28
  export function logWorkerInfo(log, logEnv = false) {
89
29
  log.debug(`${isMainThread ? 'Main thread' : 'Worker thread'}: ${workerData?.threadName}:${threadId} Pid: ${process.pid}`);
90
30
  log.debug(`ParentPort: ${parentPort ? 'active' : 'not active'}`);
@@ -93,4 +33,3 @@ export function logWorkerInfo(log, logEnv = false) {
93
33
  log.debug(`Argv: ${argv.length ? argv.join(' ') : 'none'}`);
94
34
  log.debug(`Env: ${logEnv ? inspect(process.env, true, 10, true) : 'not logged'}`);
95
35
  }
96
- //# sourceMappingURL=worker.js.map
@@ -1,25 +1 @@
1
- /**
2
- * This file contains the workerCheckUpdates functions.
3
- *
4
- * @file workerCheckUpdates.ts
5
- * @author Luca Liguori
6
- * @created 2025-11-25
7
- * @version 1.1.0
8
- * @license Apache-2.0
9
- *
10
- * Copyright 2025, 2026, 2027 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
1
  export {};
25
- //# sourceMappingURL=workerCheckUpdates.d.ts.map
@@ -1,26 +1,3 @@
1
- /**
2
- * This file contains the workerCheckUpdates functions.
3
- *
4
- * @file workerCheckUpdates.ts
5
- * @author Luca Liguori
6
- * @created 2025-11-25
7
- * @version 1.1.0
8
- * @license Apache-2.0
9
- *
10
- * Copyright 2025, 2026, 2027 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
1
  import { threadId, isMainThread, parentPort, workerData } from 'node:worker_threads';
25
2
  import { AnsiLogger } from 'node-ansi-logger';
26
3
  import { hasParameter, inspectError } from '@matterbridge/utils';
@@ -29,16 +6,13 @@ import { logWorkerInfo, parentLog, parentPost } from './worker.js';
29
6
  import { checkUpdates } from './checkUpdates.js';
30
7
  const debug = hasParameter('debug') || hasParameter('verbose');
31
8
  const verbose = hasParameter('verbose');
32
- // Send init message
33
9
  if (!isMainThread && parentPort) {
34
10
  parentPost({ type: 'init', threadId, threadName: workerData.threadName, success: true });
35
11
  if (debug)
36
- parentLog('MatterbridgeCheckUpdates', "info" /* LogLevel.INFO */, `Worker ${workerData.threadName}:${threadId} initialized.`);
12
+ parentLog('MatterbridgeCheckUpdates', "info", `Worker ${workerData.threadName}:${threadId} initialized.`);
37
13
  }
38
- // Broadcast server
39
- const log = new AnsiLogger({ logName: 'MatterbridgeCheckUpdates', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: debug ? "debug" /* LogLevel.DEBUG */ : "info" /* LogLevel.INFO */ });
14
+ const log = new AnsiLogger({ logName: 'MatterbridgeCheckUpdates', logTimestampFormat: 4, logLevel: debug ? "debug" : "info" });
40
15
  const server = new BroadcastServer('matterbridge', log);
41
- // Log worker info
42
16
  if (verbose)
43
17
  logWorkerInfo(log, verbose);
44
18
  let success = false;
@@ -48,21 +22,16 @@ try {
48
22
  success = true;
49
23
  log.debug(`Check updates succeeded`);
50
24
  if (!isMainThread && parentPort)
51
- parentLog('MatterbridgeCheckUpdates', "debug" /* LogLevel.DEBUG */, `Check updates succeeded`);
25
+ parentLog('MatterbridgeCheckUpdates', "debug", `Check updates succeeded`);
52
26
  }
53
27
  catch (error) {
54
- // istanbul ignore next cause it's just an error log
55
28
  const errorMessage = inspectError(log, `Failed to check updates`, error);
56
- // istanbul ignore next cause it's just an error log
57
29
  if (!isMainThread && parentPort)
58
- parentLog('MatterbridgeCheckUpdates', "error" /* LogLevel.ERROR */, errorMessage);
30
+ parentLog('MatterbridgeCheckUpdates', "error", errorMessage);
59
31
  }
60
- // Close the broadcast server
61
32
  server.close();
62
- // Send exit message
63
33
  if (!isMainThread && parentPort) {
64
34
  parentPost({ type: 'exit', threadId, threadName: workerData.threadName, success });
65
35
  if (debug)
66
- parentLog('MatterbridgeCheckUpdates', "info" /* LogLevel.INFO */, `Worker ${workerData.threadName}:${threadId} exiting with success: ${success}.`);
36
+ parentLog('MatterbridgeCheckUpdates', "info", `Worker ${workerData.threadName}:${threadId} exiting with success: ${success}.`);
67
37
  }
68
- //# sourceMappingURL=workerCheckUpdates.js.map
@@ -1,25 +1 @@
1
- /**
2
- * This file contains the workerGlobalPrefix functions.
3
- *
4
- * @file workerGlobalPrefix.ts
5
- * @author Luca Liguori
6
- * @created 2025-11-25
7
- * @version 1.1.0
8
- * @license Apache-2.0
9
- *
10
- * Copyright 2025, 2026, 2027 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
1
  export {};
25
- //# sourceMappingURL=workerGlobalPrefix.d.ts.map
@@ -1,26 +1,3 @@
1
- /**
2
- * This file contains the workerGlobalPrefix functions.
3
- *
4
- * @file workerGlobalPrefix.ts
5
- * @author Luca Liguori
6
- * @created 2025-11-25
7
- * @version 1.1.0
8
- * @license Apache-2.0
9
- *
10
- * Copyright 2025, 2026, 2027 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
1
  import { threadId, isMainThread, parentPort, workerData } from 'node:worker_threads';
25
2
  import { AnsiLogger } from 'node-ansi-logger';
26
3
  import { getGlobalNodeModules, hasParameter, inspectError } from '@matterbridge/utils';
@@ -28,16 +5,13 @@ import { BroadcastServer } from './broadcastServer.js';
28
5
  import { logWorkerInfo, parentLog, parentPost } from './worker.js';
29
6
  const debug = hasParameter('debug') || hasParameter('verbose');
30
7
  const verbose = hasParameter('verbose');
31
- // Send init message
32
8
  if (!isMainThread && parentPort) {
33
9
  parentPost({ type: 'init', threadId, threadName: workerData.threadName, success: true });
34
10
  if (debug)
35
- parentLog('MatterbridgePrefix', "info" /* LogLevel.INFO */, `Worker ${workerData.threadName}:${threadId} initialized.`);
11
+ parentLog('MatterbridgePrefix', "info", `Worker ${workerData.threadName}:${threadId} initialized.`);
36
12
  }
37
- // Broadcast server
38
- const log = new AnsiLogger({ logName: 'MatterbridgePrefix', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: debug ? "debug" /* LogLevel.DEBUG */ : "info" /* LogLevel.INFO */ });
13
+ const log = new AnsiLogger({ logName: 'MatterbridgePrefix', logTimestampFormat: 4, logLevel: debug ? "debug" : "info" });
39
14
  const server = new BroadcastServer('matterbridge', log);
40
- // Log worker info
41
15
  if (verbose)
42
16
  logWorkerInfo(log, verbose);
43
17
  let prefix;
@@ -48,21 +22,16 @@ try {
48
22
  server.request({ type: 'matterbridge_global_prefix', src: `matterbridge`, dst: 'matterbridge', params: { prefix } });
49
23
  success = true;
50
24
  if (!isMainThread && parentPort)
51
- parentLog('MatterbridgePrefix', "debug" /* LogLevel.DEBUG */, `Global node_modules Directory: ${prefix}`);
25
+ parentLog('MatterbridgePrefix', "debug", `Global node_modules Directory: ${prefix}`);
52
26
  }
53
27
  catch (error) {
54
- // istanbul ignore next cause it's just an error log
55
28
  const errorMessage = inspectError(log, `Failed to get global node modules`, error);
56
- // istanbul ignore next cause it's just an error log
57
29
  if (!isMainThread && parentPort)
58
- parentLog('MatterbridgePrefix', "error" /* LogLevel.ERROR */, errorMessage);
30
+ parentLog('MatterbridgePrefix', "error", errorMessage);
59
31
  }
60
- // Close the broadcast server
61
32
  server.close();
62
- // Send exit message
63
33
  if (!isMainThread && parentPort) {
64
34
  parentPost({ type: 'exit', threadId, threadName: workerData.threadName, success });
65
35
  if (debug)
66
- parentLog('MatterbridgePrefix', "info" /* LogLevel.INFO */, `Worker ${workerData.threadName}:${threadId} exiting with success: ${success}.`);
36
+ parentLog('MatterbridgePrefix', "info", `Worker ${workerData.threadName}:${threadId} exiting with success: ${success}.`);
67
37
  }
68
- //# sourceMappingURL=workerGlobalPrefix.js.map
@@ -1,28 +1,4 @@
1
- /**
2
- * This file contains the worker types.
3
- *
4
- * @file workerTypes.ts
5
- * @author Luca Liguori
6
- * @created 2025-11-25
7
- * @version 1.1.0
8
- * @license Apache-2.0
9
- *
10
- * Copyright 2025, 2026, 2027 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
1
  import type { LogLevel } from 'node-ansi-logger';
25
- /** Control messages sent through parentPort manager <-> workers */
26
2
  export type ParentPortMessage = {
27
3
  type: 'init';
28
4
  threadName: string | null;
@@ -49,4 +25,3 @@ export type ParentPortMessage = {
49
25
  threadId: number;
50
26
  success: boolean;
51
27
  };
52
- //# sourceMappingURL=workerTypes.d.ts.map
@@ -1,25 +1 @@
1
- /**
2
- * This file contains the worker types.
3
- *
4
- * @file workerTypes.ts
5
- * @author Luca Liguori
6
- * @created 2025-11-25
7
- * @version 1.1.0
8
- * @license Apache-2.0
9
- *
10
- * Copyright 2025, 2026, 2027 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
1
  export {};
25
- //# sourceMappingURL=workerTypes.js.map