matterbridge 3.3.1-dev-20251008-e61b8db → 3.3.1-dev-20251009-008da25
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/CHANGELOG.md +8 -1
- package/dist/broadcastServer.js +2 -0
- package/dist/cli.js +52 -17
- package/dist/cliEmitter.js +6 -0
- package/dist/cliHistory.js +659 -0
- package/dist/frontend.js +30 -11
- package/dist/matterbridge.js +1 -0
- package/dist/matterbridgeTypes.js +2 -0
- package/frontend/build/assets/index.js +4 -4
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/frontend.js
CHANGED
|
@@ -12,11 +12,12 @@ import { BridgedDeviceBasicInformation } from '@matter/main/clusters/bridged-dev
|
|
|
12
12
|
import { PowerSource } from '@matter/main/clusters/power-source';
|
|
13
13
|
import { DeviceAdvertiser, DeviceCommissioner, FabricManager } from '@matter/main/protocol';
|
|
14
14
|
import { CommissioningOptions } from '@matter/main/types';
|
|
15
|
-
import { MATTER_LOGGER_FILE, MATTER_STORAGE_NAME, MATTERBRIDGE_LOGGER_FILE, NODE_STORAGE_DIR, plg } from './matterbridgeTypes.js';
|
|
15
|
+
import { MATTER_LOGGER_FILE, MATTER_STORAGE_NAME, MATTERBRIDGE_DIAGNOSTIC_FILE, MATTERBRIDGE_HISTORY_FILE, MATTERBRIDGE_LOGGER_FILE, NODE_STORAGE_DIR, plg } from './matterbridgeTypes.js';
|
|
16
16
|
import { createZip, isValidArray, isValidNumber, isValidObject, isValidString, isValidBoolean, withTimeout, hasParameter, wait, inspectError } from './utils/export.js';
|
|
17
17
|
import { formatMemoryUsage, formatOsUpTime } from './utils/network.js';
|
|
18
18
|
import { capitalizeFirstLetter, getAttribute } from './matterbridgeEndpointHelpers.js';
|
|
19
|
-
import { cliEmitter, lastCpuUsage } from './cliEmitter.js';
|
|
19
|
+
import { cliEmitter, lastCpuUsage, lastProcessCpuUsage } from './cliEmitter.js';
|
|
20
|
+
import { generateHistoryPage } from './cliHistory.js';
|
|
20
21
|
import { BroadcastServer } from './broadcastServer.js';
|
|
21
22
|
export class Frontend extends EventEmitter {
|
|
22
23
|
matterbridge;
|
|
@@ -294,8 +295,8 @@ export class Frontend extends EventEmitter {
|
|
|
294
295
|
cliEmitter.on('memory', (totalMememory, freeMemory, rss, heapTotal, heapUsed, external, arrayBuffers) => {
|
|
295
296
|
this.wssSendMemoryUpdate(totalMememory, freeMemory, rss, heapTotal, heapUsed, external, arrayBuffers);
|
|
296
297
|
});
|
|
297
|
-
cliEmitter.on('cpu', (cpuUsage) => {
|
|
298
|
-
this.wssSendCpuUpdate(cpuUsage);
|
|
298
|
+
cliEmitter.on('cpu', (cpuUsage, processCpuUsage) => {
|
|
299
|
+
this.wssSendCpuUpdate(cpuUsage, processCpuUsage);
|
|
299
300
|
});
|
|
300
301
|
this.expressApp.post('/api/login', express.json(), async (req, res) => {
|
|
301
302
|
const { password } = req.body;
|
|
@@ -418,11 +419,11 @@ export class Frontend extends EventEmitter {
|
|
|
418
419
|
serverNodes.push(device.serverNode);
|
|
419
420
|
}
|
|
420
421
|
const fs = await import('node:fs');
|
|
421
|
-
if (fs.existsSync(path.join(this.matterbridge.matterbridgeDirectory,
|
|
422
|
-
fs.unlinkSync(path.join(this.matterbridge.matterbridgeDirectory,
|
|
422
|
+
if (fs.existsSync(path.join(this.matterbridge.matterbridgeDirectory, MATTERBRIDGE_DIAGNOSTIC_FILE)))
|
|
423
|
+
fs.unlinkSync(path.join(this.matterbridge.matterbridgeDirectory, MATTERBRIDGE_DIAGNOSTIC_FILE));
|
|
423
424
|
const diagnosticDestination = LogDestination({ name: 'diagnostic', level: MatterLogLevel.INFO, format: MatterLogFormat.formats.plain });
|
|
424
425
|
diagnosticDestination.write = async (text, _message) => {
|
|
425
|
-
await fs.promises.appendFile(path.join(this.matterbridge.matterbridgeDirectory,
|
|
426
|
+
await fs.promises.appendFile(path.join(this.matterbridge.matterbridgeDirectory, MATTERBRIDGE_DIAGNOSTIC_FILE), text + '\n', { encoding: 'utf8' });
|
|
426
427
|
};
|
|
427
428
|
Logger.destinations.diagnostic = diagnosticDestination;
|
|
428
429
|
if (!diagnosticDestination.context) {
|
|
@@ -439,15 +440,28 @@ export class Frontend extends EventEmitter {
|
|
|
439
440
|
await wait(500);
|
|
440
441
|
try {
|
|
441
442
|
const fs = await import('node:fs');
|
|
442
|
-
const data = await fs.promises.readFile(path.join(this.matterbridge.matterbridgeDirectory,
|
|
443
|
+
const data = await fs.promises.readFile(path.join(this.matterbridge.matterbridgeDirectory, MATTERBRIDGE_DIAGNOSTIC_FILE), 'utf8');
|
|
443
444
|
res.type('text/plain');
|
|
444
445
|
res.send(data.slice(29));
|
|
445
446
|
}
|
|
446
447
|
catch (error) {
|
|
447
|
-
this.log.error(`Error reading diagnostic log file ${
|
|
448
|
+
this.log.error(`Error reading diagnostic log file ${MATTERBRIDGE_DIAGNOSTIC_FILE}: ${error instanceof Error ? error.message : error}`);
|
|
448
449
|
res.status(500).send('Error reading diagnostic log file.');
|
|
449
450
|
}
|
|
450
451
|
});
|
|
452
|
+
this.expressApp.get('/api/viewhistory', async (req, res) => {
|
|
453
|
+
this.log.debug('The frontend sent /api/viewhistory');
|
|
454
|
+
try {
|
|
455
|
+
const fs = await import('node:fs');
|
|
456
|
+
const data = await fs.promises.readFile(path.join(this.matterbridge.matterbridgeDirectory, MATTERBRIDGE_HISTORY_FILE), 'utf8');
|
|
457
|
+
res.type('text/html');
|
|
458
|
+
res.send(data);
|
|
459
|
+
}
|
|
460
|
+
catch (error) {
|
|
461
|
+
this.log.error(`Error reading history log file ${MATTERBRIDGE_HISTORY_FILE}: ${error instanceof Error ? error.message : error}`);
|
|
462
|
+
res.status(500).send('Error reading history log file. Please create the history log before loading it.');
|
|
463
|
+
}
|
|
464
|
+
});
|
|
451
465
|
this.expressApp.get('/api/shellyviewsystemlog', async (req, res) => {
|
|
452
466
|
this.log.debug('The frontend sent /api/shellyviewsystemlog');
|
|
453
467
|
try {
|
|
@@ -666,6 +680,7 @@ export class Frontend extends EventEmitter {
|
|
|
666
680
|
this.matterbridge.systemInformation.systemUptime = formatOsUpTime(os.uptime());
|
|
667
681
|
this.matterbridge.systemInformation.processUptime = formatOsUpTime(Math.floor(process.uptime()));
|
|
668
682
|
this.matterbridge.systemInformation.cpuUsage = lastCpuUsage.toFixed(2) + ' %';
|
|
683
|
+
this.matterbridge.systemInformation.processCpuUsage = lastProcessCpuUsage.toFixed(2) + ' %';
|
|
669
684
|
this.matterbridge.systemInformation.rss = formatMemoryUsage(process.memoryUsage().rss);
|
|
670
685
|
this.matterbridge.systemInformation.heapTotal = formatMemoryUsage(process.memoryUsage().heapTotal);
|
|
671
686
|
this.matterbridge.systemInformation.heapUsed = formatMemoryUsage(process.memoryUsage().heapUsed);
|
|
@@ -1268,6 +1283,10 @@ export class Frontend extends EventEmitter {
|
|
|
1268
1283
|
await this.matterbridge.shutdownProcessAndFactoryReset();
|
|
1269
1284
|
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, success: true });
|
|
1270
1285
|
}
|
|
1286
|
+
else if (data.method === '/api/generatehistorypage') {
|
|
1287
|
+
generateHistoryPage({ outputPath: path.join(this.matterbridge.matterbridgeDirectory, MATTERBRIDGE_HISTORY_FILE), pageTitle: `Matterbridge on ${this.matterbridge.systemInformation.hostname} Cpu & Memory History` });
|
|
1288
|
+
sendResponse({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, success: true });
|
|
1289
|
+
}
|
|
1271
1290
|
else if (data.method === '/api/matter') {
|
|
1272
1291
|
const localData = data;
|
|
1273
1292
|
if (!isValidString(data.params.id)) {
|
|
@@ -1749,10 +1768,10 @@ export class Frontend extends EventEmitter {
|
|
|
1749
1768
|
this.matterbridge.updateRequired = true;
|
|
1750
1769
|
this.wssBroadcastMessage({ id: 0, src: 'Matterbridge', dst: 'Frontend', method: 'update_required', success: true, response: { devVersion } });
|
|
1751
1770
|
}
|
|
1752
|
-
wssSendCpuUpdate(cpuUsage) {
|
|
1771
|
+
wssSendCpuUpdate(cpuUsage, processCpuUsage) {
|
|
1753
1772
|
if (hasParameter('debug'))
|
|
1754
1773
|
this.log.debug('Sending a cpu update message to all connected clients');
|
|
1755
|
-
this.wssBroadcastMessage({ id: 0, src: 'Matterbridge', dst: 'Frontend', method: 'cpu_update', success: true, response: { cpuUsage: Math.round(cpuUsage * 100) / 100 } });
|
|
1774
|
+
this.wssBroadcastMessage({ id: 0, src: 'Matterbridge', dst: 'Frontend', method: 'cpu_update', success: true, response: { cpuUsage: Math.round(cpuUsage * 100) / 100, processCpuUsage: Math.round(processCpuUsage * 100) / 100 } });
|
|
1756
1775
|
}
|
|
1757
1776
|
wssSendMemoryUpdate(totalMemory, freeMemory, rss, heapTotal, heapUsed, external, arrayBuffers) {
|
|
1758
1777
|
if (hasParameter('debug'))
|
package/dist/matterbridge.js
CHANGED
|
@@ -5,3 +5,5 @@ export const MATTERBRIDGE_LOGGER_FILE = 'matterbridge.log';
|
|
|
5
5
|
export const MATTER_LOGGER_FILE = 'matter.log';
|
|
6
6
|
export const NODE_STORAGE_DIR = 'storage';
|
|
7
7
|
export const MATTER_STORAGE_NAME = 'matterstorage';
|
|
8
|
+
export const MATTERBRIDGE_DIAGNOSTIC_FILE = 'diagnostic.log';
|
|
9
|
+
export const MATTERBRIDGE_HISTORY_FILE = 'history.html';
|