matterbridge 3.3.4-dev-20251020-4d2dd49 → 3.3.4-dev-20251020-df40d12

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,10 +2,14 @@ import { rmSync } from 'node:fs';
2
2
  import { inspect } from 'node:util';
3
3
  import path from 'node:path';
4
4
  import { jest } from '@jest/globals';
5
- import { DeviceTypeId, Endpoint, Environment, ServerNode, ServerNodeStore, VendorId, LogFormat as MatterLogFormat, LogLevel as MatterLogLevel, Lifecycle } from '@matter/main';
6
- import { AggregatorEndpoint, RootEndpoint } from '@matter/main/endpoints';
7
- import { MdnsService } from '@matter/main/protocol';
8
5
  import { AnsiLogger } from 'node-ansi-logger';
6
+ import '@matter/nodejs';
7
+ import { LogFormat as MatterLogFormat, LogLevel as MatterLogLevel, Environment, Lifecycle } from '@matter/general';
8
+ import { DeviceTypeId, VendorId } from '@matter/types';
9
+ import { MdnsService } from '@matter/protocol';
10
+ import { ServerNode, Endpoint, ServerNodeStore } from '@matter/node';
11
+ import { AggregatorEndpoint } from '@matter/node/endpoints/aggregator';
12
+ import { RootEndpoint } from '@matter/node/endpoints/root';
9
13
  export let loggerLogSpy;
10
14
  export let consoleLogSpy;
11
15
  export let consoleDebugSpy;
@@ -180,29 +180,3 @@ export async function getGlobalNodeModules() {
180
180
  });
181
181
  });
182
182
  }
183
- export function formatMemoryUsage(bytes) {
184
- if (bytes >= 1024 ** 3) {
185
- return `${(bytes / 1024 ** 3).toFixed(2)} GB`;
186
- }
187
- else if (bytes >= 1024 ** 2) {
188
- return `${(bytes / 1024 ** 2).toFixed(2)} MB`;
189
- }
190
- else {
191
- return `${(bytes / 1024).toFixed(2)} KB`;
192
- }
193
- }
194
- export function formatOsUpTime(seconds) {
195
- if (seconds >= 86400) {
196
- const days = Math.floor(seconds / 86400);
197
- return `${days} day${days !== 1 ? 's' : ''}`;
198
- }
199
- if (seconds >= 3600) {
200
- const hours = Math.floor(seconds / 3600);
201
- return `${hours} hour${hours !== 1 ? 's' : ''}`;
202
- }
203
- if (seconds >= 60) {
204
- const minutes = Math.floor(seconds / 60);
205
- return `${minutes} minute${minutes !== 1 ? 's' : ''}`;
206
- }
207
- return `${seconds} second${seconds !== 1 ? 's' : ''}`;
208
- }
@@ -3,6 +3,7 @@ if (process.argv.includes('--loader') || process.argv.includes('-loader'))
3
3
  import os from 'node:os';
4
4
  import EventEmitter from 'node:events';
5
5
  import { AnsiLogger, BRIGHT, CYAN, RESET, YELLOW, db, RED } from 'node-ansi-logger';
6
+ import { formatPercent, formatBytes, formatTimeStamp } from './format.js';
6
7
  export class Tracker extends EventEmitter {
7
8
  name;
8
9
  debug;
@@ -65,35 +66,6 @@ export class Tracker extends EventEmitter {
65
66
  this.runGarbageCollector();
66
67
  });
67
68
  }
68
- formatTimeStamp(timestamp) {
69
- return `${new Date(timestamp).toLocaleString()}`;
70
- }
71
- formatOsUpTime(seconds) {
72
- if (seconds >= 86400) {
73
- const days = Math.floor(seconds / 86400);
74
- return `${days} day${days !== 1 ? 's' : ''}`;
75
- }
76
- if (seconds >= 3600) {
77
- const hours = Math.floor(seconds / 3600);
78
- return `${hours} hour${hours !== 1 ? 's' : ''}`;
79
- }
80
- if (seconds >= 60) {
81
- const minutes = Math.floor(seconds / 60);
82
- return `${minutes} minute${minutes !== 1 ? 's' : ''}`;
83
- }
84
- return `${seconds} second${seconds !== 1 ? 's' : ''}`;
85
- }
86
- formatPercent(percent) {
87
- return `${percent.toFixed(2)} %`;
88
- }
89
- formatBytes(bytes) {
90
- if (bytes === 0)
91
- return '0 B';
92
- const units = ['B', 'KB', 'MB', 'GB', 'TB'];
93
- const idx = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1);
94
- const value = bytes / Math.pow(1024, idx);
95
- return `${value.toFixed(2)} ${units[idx]}`;
96
- }
97
69
  start(sampleIntervalMs = 10000) {
98
70
  if (this.trackerInterval)
99
71
  return;
@@ -154,14 +126,14 @@ export class Tracker extends EventEmitter {
154
126
  this.emit('memory', entry.freeMemory, entry.totalMemory, entry.rss, entry.heapUsed, entry.heapTotal, entry.external, entry.arrayBuffers);
155
127
  this.emit('snapshot', entry);
156
128
  if (this.debug) {
157
- this.log.debug(`Time: ${this.formatTimeStamp(entry.timestamp)} ` +
158
- `os ${CYAN}${BRIGHT}${this.formatPercent(entry.osCpu)}${RESET}${db} (${entry.peakOsCpu > prevEntry.peakOsCpu ? RED : ''}${this.formatPercent(entry.peakOsCpu)}${db}) ` +
159
- `process ${CYAN}${BRIGHT}${this.formatPercent(entry.processCpu)}${RESET}${db} (${entry.peakProcessCpu > prevEntry.peakProcessCpu ? RED : ''}${this.formatPercent(entry.peakProcessCpu)}${db}) ` +
160
- `rss: ${CYAN}${BRIGHT}${this.formatBytes(entry.rss)}${RESET}${db} (${entry.peakRss > prevEntry.peakRss ? RED : ''}${this.formatBytes(entry.peakRss)}${db}) ` +
161
- `heapUsed: ${CYAN}${BRIGHT}${this.formatBytes(entry.heapUsed)}${RESET}${db} (${entry.peakHeapUsed > prevEntry.peakHeapUsed ? RED : ''}${this.formatBytes(entry.peakHeapUsed)}${db}) ` +
162
- `heapTotal: ${CYAN}${BRIGHT}${this.formatBytes(entry.heapTotal)}${RESET}${db} (${entry.peakHeapTotal > prevEntry.peakHeapTotal ? RED : ''}${this.formatBytes(entry.peakHeapTotal)}${db}) ` +
163
- `external: ${CYAN}${BRIGHT}${this.formatBytes(entry.external)}${RESET}${db} (${entry.peakExternal > prevEntry.peakExternal ? RED : ''}${this.formatBytes(entry.peakExternal)}${db}) ` +
164
- `arrayBuffers: ${CYAN}${BRIGHT}${this.formatBytes(entry.arrayBuffers)}${RESET}${db} (${entry.peakArrayBuffers > prevEntry.peakArrayBuffers ? RED : ''}${this.formatBytes(entry.peakArrayBuffers)}${db})`);
129
+ this.log.debug(`Time: ${formatTimeStamp(entry.timestamp)} ` +
130
+ `os ${CYAN}${BRIGHT}${formatPercent(entry.osCpu)}${RESET}${db} (${entry.peakOsCpu > prevEntry.peakOsCpu ? RED : ''}${formatPercent(entry.peakOsCpu)}${db}) ` +
131
+ `process ${CYAN}${BRIGHT}${formatPercent(entry.processCpu)}${RESET}${db} (${entry.peakProcessCpu > prevEntry.peakProcessCpu ? RED : ''}${formatPercent(entry.peakProcessCpu)}${db}) ` +
132
+ `rss: ${CYAN}${BRIGHT}${formatBytes(entry.rss)}${RESET}${db} (${entry.peakRss > prevEntry.peakRss ? RED : ''}${formatBytes(entry.peakRss)}${db}) ` +
133
+ `heapUsed: ${CYAN}${BRIGHT}${formatBytes(entry.heapUsed)}${RESET}${db} (${entry.peakHeapUsed > prevEntry.peakHeapUsed ? RED : ''}${formatBytes(entry.peakHeapUsed)}${db}) ` +
134
+ `heapTotal: ${CYAN}${BRIGHT}${formatBytes(entry.heapTotal)}${RESET}${db} (${entry.peakHeapTotal > prevEntry.peakHeapTotal ? RED : ''}${formatBytes(entry.peakHeapTotal)}${db}) ` +
135
+ `external: ${CYAN}${BRIGHT}${formatBytes(entry.external)}${RESET}${db} (${entry.peakExternal > prevEntry.peakExternal ? RED : ''}${formatBytes(entry.peakExternal)}${db}) ` +
136
+ `arrayBuffers: ${CYAN}${BRIGHT}${formatBytes(entry.arrayBuffers)}${RESET}${db} (${entry.peakArrayBuffers > prevEntry.peakArrayBuffers ? RED : ''}${formatBytes(entry.peakArrayBuffers)}${db})`);
165
137
  }
166
138
  Tracker.historyIndex = (Tracker.historyIndex + 1) % Tracker.historySize;
167
139
  }, sampleIntervalMs);
@@ -214,14 +186,14 @@ export class Tracker extends EventEmitter {
214
186
  const entry = Tracker.history[index];
215
187
  if (entry.timestamp === 0)
216
188
  continue;
217
- this.log.debug(`${this.formatTimeStamp(entry.timestamp)} ` +
218
- `${CYAN}${BRIGHT}${this.formatPercent(entry.osCpu).padStart(8)}${RESET} (${this.formatPercent(entry.peakOsCpu).padStart(8)}) ` +
219
- `${CYAN}${BRIGHT}${this.formatPercent(entry.processCpu).padStart(8)}${RESET} (${this.formatPercent(entry.peakProcessCpu).padStart(8)}) ` +
220
- `${CYAN}${BRIGHT}${this.formatBytes(entry.rss).padStart(9)}${RESET} (${this.formatBytes(entry.peakRss).padStart(9)}) ` +
221
- `${CYAN}${BRIGHT}${this.formatBytes(entry.heapUsed).padStart(9)}${RESET} (${this.formatBytes(entry.peakHeapUsed).padStart(9)}) ` +
222
- `${CYAN}${BRIGHT}${this.formatBytes(entry.heapTotal).padStart(9)}${RESET} (${this.formatBytes(entry.peakHeapTotal).padStart(9)}) ` +
223
- `${CYAN}${BRIGHT}${this.formatBytes(entry.external).padStart(9)}${RESET} (${this.formatBytes(entry.peakExternal).padStart(9)}) ` +
224
- `${CYAN}${BRIGHT}${this.formatBytes(entry.arrayBuffers).padStart(9)}${RESET} (${this.formatBytes(entry.peakArrayBuffers).padStart(9)})`);
189
+ this.log.debug(`${formatTimeStamp(entry.timestamp)} ` +
190
+ `${CYAN}${BRIGHT}${formatPercent(entry.osCpu).padStart(8)}${RESET} (${formatPercent(entry.peakOsCpu).padStart(8)}) ` +
191
+ `${CYAN}${BRIGHT}${formatPercent(entry.processCpu).padStart(8)}${RESET} (${formatPercent(entry.peakProcessCpu).padStart(8)}) ` +
192
+ `${CYAN}${BRIGHT}${formatBytes(entry.rss).padStart(9)}${RESET} (${formatBytes(entry.peakRss).padStart(9)}) ` +
193
+ `${CYAN}${BRIGHT}${formatBytes(entry.heapUsed).padStart(9)}${RESET} (${formatBytes(entry.peakHeapUsed).padStart(9)}) ` +
194
+ `${CYAN}${BRIGHT}${formatBytes(entry.heapTotal).padStart(9)}${RESET} (${formatBytes(entry.peakHeapTotal).padStart(9)}) ` +
195
+ `${CYAN}${BRIGHT}${formatBytes(entry.external).padStart(9)}${RESET} (${formatBytes(entry.peakExternal).padStart(9)}) ` +
196
+ `${CYAN}${BRIGHT}${formatBytes(entry.arrayBuffers).padStart(9)}${RESET} (${formatBytes(entry.peakArrayBuffers).padStart(9)})`);
225
197
  }
226
198
  }
227
199
  this.log.debug(`Tracker stopped`);
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "matterbridge",
3
- "version": "3.3.4-dev-20251020-4d2dd49",
3
+ "version": "3.3.4-dev-20251020-df40d12",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "matterbridge",
9
- "version": "3.3.4-dev-20251020-4d2dd49",
9
+ "version": "3.3.4-dev-20251020-df40d12",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@matter/main": "0.15.6",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matterbridge",
3
- "version": "3.3.4-dev-20251020-4d2dd49",
3
+ "version": "3.3.4-dev-20251020-df40d12",
4
4
  "description": "Matterbridge plugin manager for Matter",
5
5
  "author": "https://github.com/Luligu",
6
6
  "license": "Apache-2.0",