@matterbridge/core 3.9.2-dev-20260625-1591faa → 3.9.2-dev-20260625-582ef8d

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.
@@ -2,6 +2,7 @@ import os from 'node:os';
2
2
  import path from 'node:path';
3
3
  import { BroadcastServer } from '@matterbridge/thread';
4
4
  import { MATTER_LOGGER_FILE, MATTER_STORAGE_DIR, MATTERBRIDGE_BACKUP_FILE, MATTERBRIDGE_DIAGNOSTIC_FILE, MATTERBRIDGE_HISTORY_FILE, MATTERBRIDGE_LOGGER_FILE, MATTERBRIDGE_PLUGIN_CONFIG_FILE, MATTERBRIDGE_PLUGIN_STORAGE_FILE, NODE_STORAGE_DIR, plg, } from '@matterbridge/types';
5
+ import { isBun } from '@matterbridge/utils/bun';
5
6
  import { hasParameter } from '@matterbridge/utils/cli';
6
7
  import { getErrorMessage } from '@matterbridge/utils/error';
7
8
  import { formatBytes } from '@matterbridge/utils/format';
@@ -411,8 +412,8 @@ export class BackendExpress {
411
412
  name: 'SpawnCommand',
412
413
  workerData: {
413
414
  threadName: 'SpawnCommand',
414
- command: 'npm',
415
- args: ['install', '-g', filePath, '--omit=dev', '--verbose'],
415
+ command: isBun() ? 'bun' : 'npm',
416
+ args: isBun() ? ['install', '-g', filePath, '--production'] : ['install', '-g', filePath, '--omit=dev', '--verbose'],
416
417
  packageCommand: 'install',
417
418
  packageName: filename,
418
419
  },
package/dist/frontend.js CHANGED
@@ -9,6 +9,7 @@ import { CommissioningOptions } from '@matter/types/commissioning';
9
9
  import { FabricIndex } from '@matter/types/datatype';
10
10
  import { BroadcastServer } from '@matterbridge/thread/server';
11
11
  import { MATTER_LOGGER_FILE, MATTER_STORAGE_DIR, MATTERBRIDGE_DIAGNOSTIC_FILE, MATTERBRIDGE_HISTORY_FILE, MATTERBRIDGE_LOGGER_FILE, NODE_STORAGE_DIR, plg, } from '@matterbridge/types';
12
+ import { isBun } from '@matterbridge/utils/bun';
12
13
  import { getParameter, hasParameter } from '@matterbridge/utils/cli';
13
14
  import { getErrorMessage, inspectError, logError } from '@matterbridge/utils/error';
14
15
  import { formatBytes, formatPercent, formatUptime } from '@matterbridge/utils/format';
@@ -798,8 +799,8 @@ export class Frontend extends EventEmitter {
798
799
  name: 'SpawnCommand',
799
800
  workerData: {
800
801
  threadName: 'SpawnCommand',
801
- command: 'npm',
802
- args: ['install', '-g', filePath, '--omit=dev', '--verbose'],
802
+ command: isBun() ? 'bun' : 'npm',
803
+ args: isBun() ? ['install', '-g', filePath, '--production'] : ['install', '-g', filePath, '--omit=dev', '--verbose'],
803
804
  packageCommand: 'install',
804
805
  packageName: filename,
805
806
  },
@@ -2236,8 +2237,8 @@ export class Frontend extends EventEmitter {
2236
2237
  name: 'SpawnCommand',
2237
2238
  workerData: {
2238
2239
  threadName: 'SpawnCommand',
2239
- command: 'npm',
2240
- args: [command, '-g', packageName, '--omit=dev', '--verbose'],
2240
+ command: isBun() ? 'bun' : 'npm',
2241
+ args: isBun() ? [command, '-g', packageName, '--production'] : [command, '-g', packageName, '--omit=dev', '--verbose'],
2241
2242
  packageCommand: command,
2242
2243
  packageName: packageName,
2243
2244
  },
@@ -14,6 +14,7 @@ import { DeviceTypeId, VendorId } from '@matter/types/datatype';
14
14
  import { ManualPairingCodeCodec } from '@matter/types/schema';
15
15
  import { BroadcastServer } from '@matterbridge/thread/server';
16
16
  import { dev, MATTER_LOGGER_FILE, MATTER_STORAGE_DIR, MATTERBRIDGE_LOGGER_FILE, NODE_STORAGE_DIR, plg, typ } from '@matterbridge/types';
17
+ import { isBun, getGlobalBunModules } from '@matterbridge/utils/bun';
17
18
  import { getIntParameter, getParameter, hasAnyParameter, hasParameter } from '@matterbridge/utils/cli';
18
19
  import { copyDirectory } from '@matterbridge/utils/copy-dir';
19
20
  import { createDirectory } from '@matterbridge/utils/create-dir';
@@ -384,14 +385,19 @@ export class Matterbridge extends EventEmitter {
384
385
  this.matterbridgeCertDirectory = this.profile ? path.join(this.homeDirectory, '.mattercert', 'profiles', this.profile) : path.join(this.homeDirectory, '.mattercert');
385
386
  await createDirectory(this.matterbridgeCertDirectory, 'Matterbridge Matter Certificate Directory', this.log);
386
387
  const currentFileDirectory = path.dirname(fileURLToPath(import.meta.url));
387
- if (currentFileDirectory.includes(path.join('packages', 'core'))) {
388
+ this.log.debug(`Determining root directory from currentFileDirectory = ${CYAN}${currentFileDirectory}${db}`);
389
+ if (currentFileDirectory.endsWith(path.join('matterbridge', 'packages', 'core', 'src')) ||
390
+ currentFileDirectory.endsWith(path.join('matterbridge', 'packages', 'core', 'dist'))) {
388
391
  this.rootDirectory = path.resolve(currentFileDirectory, '..', '..', '..');
392
+ this.log.debug(`Found packages core >>> root directory: ${CYAN}${this.rootDirectory}${db}`);
389
393
  }
390
- else if (path.basename(currentFileDirectory) === 'dist') {
394
+ else if (currentFileDirectory.endsWith(path.join('matterbridge', 'dist'))) {
391
395
  this.rootDirectory = path.resolve(currentFileDirectory, '..');
396
+ this.log.debug(`Found bundled core >>> root directory: ${CYAN}${this.rootDirectory}${db}`);
392
397
  }
393
398
  else {
394
399
  this.rootDirectory = path.resolve(currentFileDirectory, '..', '..', '..', '..');
400
+ this.log.debug(`Found production core >>> root directory: ${CYAN}${this.rootDirectory}${db}`);
395
401
  }
396
402
  this.environment.vars.set('log.level', MatterLogLevel.DEBUG);
397
403
  this.environment.vars.set('log.format', hasParameter('no-ansi') || process.env.NO_COLOR === '1' ? MatterLogFormat.PLAIN : MatterLogFormat.ANSI);
@@ -675,12 +681,37 @@ export class Matterbridge extends EventEmitter {
675
681
  this.virtualMode = (await this.nodeContext.get('virtualmode', 'outlet'));
676
682
  }
677
683
  this.log.debug(`Virtual mode ${this.virtualMode}.`);
684
+ if (isBun()) {
685
+ this.globalModulesDirectory = getGlobalBunModules();
686
+ this.log.debug(`Global node_modules Directory (Bun): ${this.globalModulesDirectory}`);
687
+ await this.nodeContext.set('globalModulesDirectory', this.globalModulesDirectory);
688
+ }
689
+ else {
690
+ this.globalModulesDirectory = await this.nodeContext.get('globalModulesDirectory', '');
691
+ }
692
+ if (this.globalModulesDirectory === '') {
693
+ this.log.debug(`Getting global node_modules directory...`);
694
+ try {
695
+ const { getGlobalNodeModules } = await import('@matterbridge/utils/npm-prefix');
696
+ this.globalModulesDirectory = await getGlobalNodeModules();
697
+ this.log.debug(`Global node_modules Directory: ${this.globalModulesDirectory}`);
698
+ await this.nodeContext.set('globalModulesDirectory', this.globalModulesDirectory);
699
+ }
700
+ catch (error) {
701
+ logError(this.log, `Error getting global node_modules directory`, error);
702
+ }
703
+ }
704
+ else {
705
+ if (!isBun()) {
706
+ this.log.debug(`Global node_modules Directory: ${this.globalModulesDirectory}`);
707
+ this.server.request({ type: 'manager_run', src: 'matterbridge', dst: 'manager', params: { name: 'GlobalPrefix' } });
708
+ }
709
+ }
678
710
  this.plugins.logLevel = this.log.logLevel;
679
711
  await this.plugins.loadFromStorage();
680
712
  this.devices.logLevel = this.log.logLevel;
681
713
  for (const plugin of this.plugins) {
682
- const globalModulesDirectory = await this.nodeContext.get('globalModulesDirectory', '');
683
- const isLocal = globalModulesDirectory.length > 0 && !plugin.path.startsWith(globalModulesDirectory);
714
+ const isLocal = fs.existsSync(plugin.path) && this.globalModulesDirectory.length > 0 && !plugin.path.startsWith(this.globalModulesDirectory);
684
715
  this.log.debug(`Parsing plugin ${plg}${plugin.name}${db} from path ${CYAN}${plugin.path}${db} ` +
685
716
  `with version ${CYAN}${plugin.version}${db} type ${CYAN}${plugin.type}${db} local ${CYAN}${isLocal}${db} ` +
686
717
  `private ${CYAN}${plugin.private}${db} tarball ${CYAN}${plugin.tarballPath}${db}.`);
@@ -691,7 +722,7 @@ export class Matterbridge extends EventEmitter {
691
722
  process.env.MATTERBRIDGE_LINK_LOCAL_PLUGINS === 'jest') {
692
723
  const { execSync } = await import('node:child_process');
693
724
  try {
694
- execSync('npm link matterbridge --no-fund --no-audit --silent', { cwd: path.dirname(plugin.path) });
725
+ execSync(isBun() ? 'bun link matterbridge --silent' : 'npm link matterbridge --no-fund --no-audit --silent', { cwd: path.dirname(plugin.path) });
695
726
  this.log.info(`Matterbridge linked to plugin ${plg}${plugin.name}${nf}.`);
696
727
  }
697
728
  catch (error) {
@@ -708,11 +739,11 @@ export class Matterbridge extends EventEmitter {
708
739
  try {
709
740
  if (plugin.private && plugin.tarballPath && fs.existsSync(path.join(this.matterbridgeDirectory, 'uploads', plugin.tarballPath))) {
710
741
  this.log.info(`Plugin ${plg}${plugin.name}${nf} not found. Trying to reinstall it from last tarball...`);
711
- execSync(`${sudo ? 'sudo ' : ''}npm install -g ${path.join(this.matterbridgeDirectory, 'uploads', plugin.tarballPath)} --no-fund --no-audit --silent --omit=dev`);
742
+ execSync(`${sudo ? 'sudo ' : ''}${isBun() ? 'bun' : 'npm'} install -g ${path.join(this.matterbridgeDirectory, 'uploads', plugin.tarballPath)} ${isBun() ? '--production --silent' : '--no-fund --no-audit --silent --omit=dev'}`);
712
743
  }
713
744
  else {
714
745
  this.log.info(`Plugin ${plg}${plugin.name}${nf} not found. Trying to reinstall it from npm${plugin.version.includes('-dev-') ? ' with tag @dev' : ''}...`);
715
- execSync(`${sudo ? 'sudo ' : ''}npm install -g ${plugin.name}${plugin.version.includes('-dev-') ? '@dev' : ''} --no-fund --no-audit --silent --omit=dev`);
746
+ execSync(`${sudo ? 'sudo ' : ''}${isBun() ? 'bun' : 'npm'} install -g ${plugin.name}${plugin.version.includes('-dev-') ? '@dev' : ''} ${isBun() ? '--production --silent' : '--no-fund --no-audit --silent --omit=dev'}`);
716
747
  }
717
748
  this.log.info(`Plugin ${plg}${plugin.name}${nf} reinstalled.`);
718
749
  }
@@ -1078,24 +1109,7 @@ export class Matterbridge extends EventEmitter {
1078
1109
  this.log.debug(`Matterbridge Directory: ${this.matterbridgeDirectory}`);
1079
1110
  this.log.debug(`Matterbridge Plugin Directory: ${this.matterbridgePluginDirectory}`);
1080
1111
  this.log.debug(`Matterbridge Matter Certificate Directory: ${this.matterbridgeCertDirectory}`);
1081
- if (this.nodeContext)
1082
- this.globalModulesDirectory = await this.nodeContext.get('globalModulesDirectory', '');
1083
- if (this.globalModulesDirectory === '') {
1084
- this.log.debug(`Getting global node_modules directory...`);
1085
- try {
1086
- const { getGlobalNodeModules } = await import('@matterbridge/utils/npm-prefix');
1087
- this.globalModulesDirectory = await getGlobalNodeModules();
1088
- this.log.debug(`Global node_modules Directory: ${this.globalModulesDirectory}`);
1089
- await this.nodeContext?.set('globalModulesDirectory', this.globalModulesDirectory);
1090
- }
1091
- catch (error) {
1092
- logError(this.log, `Error getting global node_modules directory`, error);
1093
- }
1094
- }
1095
- else {
1096
- this.log.debug(`Global node_modules Directory: ${this.globalModulesDirectory}`);
1097
- this.server.request({ type: 'manager_run', src: 'matterbridge', dst: 'manager', params: { name: 'GlobalPrefix' } });
1098
- }
1112
+ this.log.debug(`Global node_modules Directory: ${this.globalModulesDirectory}`);
1099
1113
  this.log.debug(`Reading matterbridge package.json...`);
1100
1114
  const packageJson = JSON.parse(await fs.promises.readFile(path.join(this.rootDirectory, 'package.json'), 'utf-8'));
1101
1115
  this.matterbridgeVersion = this.matterbridgeLatestVersion = this.matterbridgeDevVersion = packageJson.version;
@@ -1180,8 +1194,8 @@ export class Matterbridge extends EventEmitter {
1180
1194
  name: 'SpawnCommand',
1181
1195
  workerData: {
1182
1196
  threadName: 'SpawnCommand',
1183
- command: 'npm',
1184
- args: ['install', '-g', 'matterbridge', '--omit=dev', '--verbose'],
1197
+ command: isBun() ? 'bun' : 'npm',
1198
+ args: isBun() ? ['install', '-g', 'matterbridge', '--production'] : ['install', '-g', 'matterbridge', '--omit=dev', '--verbose'],
1185
1199
  packageCommand: 'install',
1186
1200
  packageName: 'matterbridge',
1187
1201
  },
@@ -2,6 +2,7 @@ import EventEmitter from 'node:events';
2
2
  import path from 'node:path';
3
3
  import { BroadcastServer } from '@matterbridge/thread/server';
4
4
  import { plg, typ } from '@matterbridge/types';
5
+ import { isBun } from '@matterbridge/utils/bun';
5
6
  import { hasParameter } from '@matterbridge/utils/cli';
6
7
  import { getErrorMessage, inspectError, logError } from '@matterbridge/utils/error';
7
8
  import { logModuleLoaded } from '@matterbridge/utils/loader';
@@ -522,8 +523,8 @@ export class PluginManager extends EventEmitter {
522
523
  name: 'SpawnCommand',
523
524
  workerData: {
524
525
  threadName: 'SpawnCommand',
525
- command: 'npm',
526
- args: ['install', '-g', packageName, '--omit=dev', '--verbose'],
526
+ command: isBun() ? 'bun' : 'npm',
527
+ args: isBun() ? ['install', '-g', packageName, '--production'] : ['install', '-g', packageName, '--omit=dev', '--verbose'],
527
528
  packageCommand: 'install',
528
529
  packageName: packageName,
529
530
  },
@@ -540,8 +541,8 @@ export class PluginManager extends EventEmitter {
540
541
  name: 'SpawnCommand',
541
542
  workerData: {
542
543
  threadName: 'SpawnCommand',
543
- command: 'npm',
544
- args: ['uninstall', '-g', packageName, '--omit=dev', '--verbose'],
544
+ command: isBun() ? 'bun' : 'npm',
545
+ args: isBun() ? ['uninstall', '-g', packageName] : ['uninstall', '-g', packageName, '--verbose'],
545
546
  packageCommand: 'uninstall',
546
547
  packageName: packageName,
547
548
  },
@@ -635,7 +636,16 @@ export class PluginManager extends EventEmitter {
635
636
  plugin = p;
636
637
  }
637
638
  try {
638
- this.log.debug(`Parsing package.json of plugin ${plg}${plugin.name}${db}`);
639
+ const { existsSync } = await import('node:fs');
640
+ this.log.debug(`Parsing package.json of plugin ${plg}${plugin.name}${db} at path ${CYAN}${plugin.path}${db}`);
641
+ if (!existsSync(plugin.path) && existsSync(path.join(this.matterbridge.globalModulesDirectory, plugin.name, 'package.json'))) {
642
+ plugin.path = path.join(this.matterbridge.globalModulesDirectory, plugin.name, 'package.json');
643
+ this.log.debug(`Found package.json of plugin ${plg}${plugin.name}${db} in global npm modules directory: ${CYAN}${plugin.path}${db}`);
644
+ }
645
+ if (!existsSync(plugin.path) && existsSync(path.join(this.matterbridge.matterbridgePluginDirectory, plugin.name, 'package.json'))) {
646
+ plugin.path = path.join(this.matterbridge.matterbridgePluginDirectory, plugin.name, 'package.json');
647
+ this.log.debug(`Found package.json of plugin ${plg}${plugin.name}${db} in matterbridge plugin directory: ${CYAN}${plugin.path}${db}`);
648
+ }
639
649
  const packageJson = JSON.parse(await promises.readFile(plugin.path, 'utf8'));
640
650
  if (!packageJson.name)
641
651
  this.log.warn(`Plugin ${plg}${plugin.name}${wr} has no name in package.json`);
@@ -662,7 +672,6 @@ export class PluginManager extends EventEmitter {
662
672
  if (!plugin.type)
663
673
  this.log.warn(`Plugin ${plg}${plugin.name}${wr} has no type`);
664
674
  const frontendPath = path.join(plugin.path.replace('package.json', ''), 'apps', 'frontend', 'build', 'index.html');
665
- const { existsSync } = await import('node:fs');
666
675
  if (existsSync(frontendPath))
667
676
  plugin.frontendPath = frontendPath;
668
677
  const invalidDependencies = this.findInvalidDependencies(packageJson);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matterbridge/core",
3
- "version": "3.9.2-dev-20260625-1591faa",
3
+ "version": "3.9.2-dev-20260625-582ef8d",
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.17.4-alpha.0-20260624-ef5aefa3b",
133
- "@matterbridge/dgram": "3.9.2-dev-20260625-1591faa",
134
- "@matterbridge/thread": "3.9.2-dev-20260625-1591faa",
135
- "@matterbridge/types": "3.9.2-dev-20260625-1591faa",
136
- "@matterbridge/utils": "3.9.2-dev-20260625-1591faa",
133
+ "@matterbridge/dgram": "3.9.2-dev-20260625-582ef8d",
134
+ "@matterbridge/thread": "3.9.2-dev-20260625-582ef8d",
135
+ "@matterbridge/types": "3.9.2-dev-20260625-582ef8d",
136
+ "@matterbridge/utils": "3.9.2-dev-20260625-582ef8d",
137
137
  "escape-html": "1.0.3",
138
138
  "express": "5.2.1",
139
139
  "express-rate-limit": "8.5.2",