@matterbridge/core 3.7.10-dev-20260518-d8df401 → 3.7.10-dev-20260519-b4a9def

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/dist/frontend.js CHANGED
@@ -130,11 +130,7 @@ export class Frontend extends EventEmitter {
130
130
  this.fixedRestartRequired = true;
131
131
  this.wssSendRestartRequired(true, true);
132
132
  this.wssSendSnackbarMessage(`Installed package ${msg.result.packageName}`, 5, 'success');
133
- const packageName = msg.result.packageName.replace(/-\d.*$/, '');
134
- if (msg.result.packageName.startsWith('matterbridge-') && msg.result.packageName.endsWith('.tgz')) {
135
- fireAndForget(this.server.fetch({ type: 'plugins_add', src: this.server.name, dst: 'plugins', params: { nameOrPath: packageName } }, this.serverFetchTimeout), this.log, `Error adding plugin ${packageName} after uploading package ${msg.result.packageName}`);
136
- setImmediate(() => this.wssSendRefreshRequired('plugins')).unref();
137
- }
133
+ setTimeout(() => this.wssSendRefreshRequired('plugins'), 2000).unref();
138
134
  }
139
135
  else {
140
136
  this.wssSendSnackbarMessage(`Package ${msg.result.packageName} not installed`, 10, 'error');
@@ -147,6 +143,7 @@ export class Frontend extends EventEmitter {
147
143
  this.fixedRestartRequired = true;
148
144
  this.wssSendRestartRequired(true, true);
149
145
  this.wssSendSnackbarMessage(`Uninstalled package ${msg.result.packageName}`, 5, 'success');
146
+ setTimeout(() => this.wssSendRefreshRequired('plugins'), 2000).unref();
150
147
  }
151
148
  else {
152
149
  this.wssSendSnackbarMessage(`Package ${msg.result.packageName} not uninstalled`, 10, 'error');
@@ -1096,6 +1093,7 @@ export class Frontend extends EventEmitter {
1096
1093
  type: plugin.type,
1097
1094
  name: plugin.name,
1098
1095
  version: plugin.version,
1096
+ private: plugin.private,
1099
1097
  description: plugin.description,
1100
1098
  author: plugin.author,
1101
1099
  homepage: plugin.homepage,
@@ -620,9 +620,11 @@ export class Matterbridge extends EventEmitter {
620
620
  await this.plugins.loadFromStorage();
621
621
  this.devices.logLevel = this.log.logLevel;
622
622
  for (const plugin of this.plugins) {
623
- this.log.debug(`Parsing plugin ${plg}${plugin.name}${db} from path ${CYAN}${plugin.path}${db} with version ${CYAN}${plugin.version}${db} and type ${CYAN}${plugin.type}${db}.`);
624
623
  const globalModulesDirectory = await this.nodeContext.get('globalModulesDirectory', '');
625
- const isLocal = globalModulesDirectory && !plugin.path.includes(globalModulesDirectory);
624
+ const isLocal = globalModulesDirectory && !plugin.path.startsWith(globalModulesDirectory);
625
+ this.log.debug(`Parsing plugin ${plg}${plugin.name}${db} from path ${CYAN}${plugin.path}${db} ` +
626
+ `with version ${CYAN}${plugin.version}${db} type ${CYAN}${plugin.type}${db} local ${CYAN}${isLocal}${db} ` +
627
+ `private ${CYAN}${plugin.private}${db} tarball ${CYAN}${plugin.tarballPath}${db}.`);
626
628
  if ((isLocal &&
627
629
  fs.existsSync(plugin.path) &&
628
630
  !fs.existsSync(path.join(path.dirname(plugin.path), 'node_modules', 'matterbridge')) &&
@@ -642,11 +644,17 @@ export class Matterbridge extends EventEmitter {
642
644
  }
643
645
  if ((!isLocal && !fs.existsSync(plugin.path) && !hasAnyParameter('add', 'remove', 'enable', 'disable', 'reset', 'factoryreset', 'systemcheck')) ||
644
646
  process.env.MATTERBRIDGE_REINSTALL_PLUGINS === 'jest') {
645
- this.log.info(`Error parsing plugin ${plg}${plugin.name}${nf}. Trying to reinstall it from npm...`);
646
647
  const { execSync } = await import('node:child_process');
647
648
  const sudo = hasParameter('sudo') || (process.platform !== 'win32' && !hasParameter('docker') && !hasParameter('nosudo') && !process.env.PATH?.includes('/.nvm/versions/node/'));
648
649
  try {
649
- execSync(`${sudo ? 'sudo ' : ''}npm install -g ${plugin.name}${plugin.version.includes('-dev-') ? '@dev' : ''} --no-fund --no-audit --silent --omit=dev`);
650
+ if (plugin.private && plugin.tarballPath && fs.existsSync(path.join(this.matterbridgeDirectory, 'uploads', plugin.tarballPath))) {
651
+ this.log.info(`Plugin ${plg}${plugin.name}${nf} not found. Trying to reinstall it from last tarball...`);
652
+ execSync(`${sudo ? 'sudo ' : ''}npm install -g ${path.join(this.matterbridgeDirectory, 'uploads', plugin.tarballPath)} --no-fund --no-audit --silent --omit=dev`);
653
+ }
654
+ else {
655
+ this.log.info(`Plugin ${plg}${plugin.name}${nf} not found. Trying to reinstall it from npm...`);
656
+ execSync(`${sudo ? 'sudo ' : ''}npm install -g ${plugin.name}${plugin.version.includes('-dev-') ? '@dev' : ''} --no-fund --no-audit --silent --omit=dev`);
657
+ }
650
658
  this.log.info(`Plugin ${plg}${plugin.name}${nf} reinstalled.`);
651
659
  }
652
660
  catch (error) {
@@ -276,23 +276,37 @@ export class PluginManager extends EventEmitter {
276
276
  switch (msg.type) {
277
277
  case 'manager_spawn_response':
278
278
  if (msg.result && msg.result.packageCommand === 'install') {
279
- if (msg.result.packageName.endsWith('.tgz'))
279
+ if (!msg.result.success) {
280
+ this.log.error(`Failed to install package ${plg}${msg.result.packageName}${er}`);
280
281
  return;
281
- if (msg.result.success) {
282
- const packageName = msg.result.packageName.replace(/@.*$/, '');
283
- if (packageName !== 'matterbridge') {
282
+ }
283
+ if (msg.result.packageName.endsWith('.tgz')) {
284
+ const packageName = msg.result.packageName.replace(/-\d.*$/, '');
285
+ this.log.info(`Installed package ${plg}${packageName}${nf} from ${CYAN}${msg.result.packageName}${nf} successfully`);
286
+ if (msg.result.packageName.startsWith('matterbridge-') && msg.result.packageName.endsWith('.tgz')) {
284
287
  if (!this.has(packageName))
285
288
  await this.add(packageName);
286
289
  const plugin = this.get(packageName);
287
- if (plugin && !plugin.loaded) {
290
+ if (plugin)
291
+ plugin.tarballPath = msg.result.packageName;
292
+ await this.saveToStorage();
293
+ if (plugin && !plugin.loaded)
288
294
  await this.load(plugin);
289
- this.server.request({ type: 'frontend_refreshrequired', src: 'plugins', dst: 'frontend', params: { changed: 'plugins' } });
290
- }
291
295
  }
292
- this.log.info(`Installed plugin ${plg}${packageName}${db} successfully`);
293
296
  }
294
297
  else {
295
- this.log.error(`Failed to install plugin ${plg}${msg.result.packageName}${er}`);
298
+ const packageName = msg.result.packageName.replace(/@.*$/, '');
299
+ this.log.info(`Installed plugin ${plg}${packageName}${db} successfully`);
300
+ if (packageName !== 'matterbridge') {
301
+ if (!this.has(packageName))
302
+ await this.add(packageName);
303
+ const plugin = this.get(packageName);
304
+ if (plugin)
305
+ plugin.tarballPath = undefined;
306
+ await this.saveToStorage();
307
+ if (plugin && !plugin.loaded)
308
+ await this.load(plugin);
309
+ }
296
310
  }
297
311
  }
298
312
  if (msg.result && msg.result.packageCommand === 'uninstall') {
@@ -302,7 +316,6 @@ export class PluginManager extends EventEmitter {
302
316
  if (plugin && plugin.loaded)
303
317
  await this.shutdown(plugin, 'Matterbridge is uninstalling the plugin');
304
318
  await this.remove(msg.result.packageName);
305
- this.server.request({ type: 'frontend_refreshrequired', src: 'plugins', dst: 'frontend', params: { changed: 'plugins' } });
306
319
  }
307
320
  this.log.info(`Uninstalled plugin ${plg}${msg.result.packageName}${db} successfully`);
308
321
  }
@@ -342,6 +355,7 @@ export class PluginManager extends EventEmitter {
342
355
  description: plugin.description,
343
356
  author: plugin.author,
344
357
  enabled: plugin.enabled,
358
+ private: plugin.private,
345
359
  };
346
360
  }
347
361
  toApiPlugin(plugin) {
@@ -352,6 +366,7 @@ export class PluginManager extends EventEmitter {
352
366
  author: plugin.author,
353
367
  path: plugin.path,
354
368
  type: plugin.type,
369
+ private: plugin.private,
355
370
  latestVersion: plugin.latestVersion,
356
371
  devVersion: plugin.devVersion,
357
372
  homepage: plugin.homepage,
@@ -415,7 +430,7 @@ export class PluginManager extends EventEmitter {
415
430
  }
416
431
  const pluginsArray = await this.matterbridge.nodeContext.get('plugins', []);
417
432
  for (const plugin of pluginsArray)
418
- this._plugins.set(plugin.name, plugin);
433
+ this._plugins.set(plugin.name, { ...plugin, private: plugin.private ?? false });
419
434
  this.log.debug(`Loaded ${BLUE}${pluginsArray.length}${db} plugins from storage`);
420
435
  return pluginsArray;
421
436
  }
@@ -433,6 +448,8 @@ export class PluginManager extends EventEmitter {
433
448
  description: plugin.description,
434
449
  author: plugin.author,
435
450
  enabled: plugin.enabled,
451
+ private: plugin.private,
452
+ tarballPath: plugin.tarballPath,
436
453
  });
437
454
  }
438
455
  await this.matterbridge.nodeContext.set('plugins', plugins);
@@ -785,6 +802,7 @@ export class PluginManager extends EventEmitter {
785
802
  path: packageJsonPath,
786
803
  type: 'AnyPlatform',
787
804
  version: packageJson.version,
805
+ private: packageJson.private || false,
788
806
  description: packageJson.description,
789
807
  author: this.getAuthor(packageJson),
790
808
  homepage: this.getHomepage(packageJson),
@@ -861,6 +879,7 @@ export class PluginManager extends EventEmitter {
861
879
  plugin.name = packageJson.name;
862
880
  plugin.description = this.getDescription(packageJson);
863
881
  plugin.version = packageJson.version;
882
+ plugin.private = packageJson.private || false;
864
883
  plugin.author = this.getAuthor(packageJson);
865
884
  plugin.homepage = this.getHomepage(packageJson);
866
885
  plugin.help = this.getHelp(packageJson);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matterbridge/core",
3
- "version": "3.7.10-dev-20260518-d8df401",
3
+ "version": "3.7.10-dev-20260519-b4a9def",
4
4
  "description": "Matterbridge core library",
5
5
  "author": "https://github.com/Luligu",
6
6
  "homepage": "https://matterbridge.io/",
@@ -130,10 +130,10 @@
130
130
  ],
131
131
  "dependencies": {
132
132
  "@matter/main": "0.16.11",
133
- "@matterbridge/dgram": "3.7.10-dev-20260518-d8df401",
134
- "@matterbridge/thread": "3.7.10-dev-20260518-d8df401",
135
- "@matterbridge/types": "3.7.10-dev-20260518-d8df401",
136
- "@matterbridge/utils": "3.7.10-dev-20260518-d8df401",
133
+ "@matterbridge/dgram": "3.7.10-dev-20260519-b4a9def",
134
+ "@matterbridge/thread": "3.7.10-dev-20260519-b4a9def",
135
+ "@matterbridge/types": "3.7.10-dev-20260519-b4a9def",
136
+ "@matterbridge/utils": "3.7.10-dev-20260519-b4a9def",
137
137
  "escape-html": "1.0.3",
138
138
  "express": "5.2.1",
139
139
  "express-rate-limit": "8.5.2",