@matter-server/dashboard 1.5.3 → 1.5.4
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/web/js/main.js +39 -18
- package/package.json +3 -3
package/dist/web/js/main.js
CHANGED
|
@@ -101,6 +101,21 @@ function parseBigIntAwareJson(json) {
|
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* @license
|
|
106
|
+
* Copyright 2025-2026 Open Home Foundation
|
|
107
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
108
|
+
*/
|
|
109
|
+
function toConsole(write) {
|
|
110
|
+
return (message, detail) => detail === void 0 ? write(message) : write(message, detail());
|
|
111
|
+
}
|
|
112
|
+
const consoleLogger = {
|
|
113
|
+
debug: toConsole((...values) => console.debug(...values)),
|
|
114
|
+
info: toConsole((...values) => console.info(...values)),
|
|
115
|
+
warn: toConsole((...values) => console.warn(...values)),
|
|
116
|
+
error: toConsole((...values) => console.error(...values))
|
|
117
|
+
};
|
|
118
|
+
|
|
104
119
|
/**
|
|
105
120
|
* @license
|
|
106
121
|
* Copyright 2025-2026 Open Home Foundation
|
|
@@ -201,16 +216,23 @@ class Connection {
|
|
|
201
216
|
/**
|
|
202
217
|
* Create a new connection.
|
|
203
218
|
* @param ws_server_url WebSocket server URL
|
|
204
|
-
* @param
|
|
205
|
-
* If not provided, uses the global WebSocket constructor.
|
|
219
|
+
* @param options The {@link ConnectionOptions}, or only a {@link WebSocketFactory}.
|
|
206
220
|
*/
|
|
207
|
-
constructor(ws_server_url,
|
|
221
|
+
constructor(ws_server_url, options) {
|
|
208
222
|
this.ws_server_url = ws_server_url;
|
|
223
|
+
const {
|
|
224
|
+
wsFactory,
|
|
225
|
+
logger = consoleLogger
|
|
226
|
+
} = typeof options === "function" ? {
|
|
227
|
+
wsFactory: options
|
|
228
|
+
} : options ?? {};
|
|
209
229
|
this.ws_server_url = ws_server_url;
|
|
210
230
|
this.wsFactory = wsFactory ?? (url => new WebSocket(url));
|
|
231
|
+
this.logger = logger;
|
|
211
232
|
}
|
|
212
233
|
ws_server_url;
|
|
213
234
|
serverInfo = void 0;
|
|
235
|
+
logger;
|
|
214
236
|
socket;
|
|
215
237
|
wsFactory;
|
|
216
238
|
get connected() {
|
|
@@ -220,26 +242,26 @@ class Connection {
|
|
|
220
242
|
if (this.socket) {
|
|
221
243
|
throw new Error("Already connected");
|
|
222
244
|
}
|
|
223
|
-
|
|
245
|
+
this.logger.debug("Trying to connect");
|
|
224
246
|
return new Promise((resolve, reject) => {
|
|
225
247
|
this.socket = this.wsFactory(this.ws_server_url);
|
|
226
248
|
this.socket.onopen = () => {
|
|
227
|
-
|
|
249
|
+
this.logger.info("WebSocket Connected");
|
|
228
250
|
};
|
|
229
251
|
this.socket.onclose = () => {
|
|
230
|
-
|
|
252
|
+
this.logger.info("WebSocket Closed");
|
|
231
253
|
this.socket = void 0;
|
|
232
254
|
this.serverInfo = void 0;
|
|
233
255
|
onConnectionLost();
|
|
234
256
|
};
|
|
235
257
|
this.socket.onerror = error => {
|
|
236
|
-
|
|
258
|
+
this.logger.error("WebSocket Error:", () => error);
|
|
237
259
|
reject(new Error("WebSocket Error"));
|
|
238
260
|
};
|
|
239
261
|
this.socket.onmessage = event => {
|
|
240
262
|
const dataStr = typeof event.data === "string" ? event.data : String(event.data);
|
|
241
263
|
const data = parseBigIntAwareJson(dataStr);
|
|
242
|
-
|
|
264
|
+
this.logger.debug("WebSocket OnMessage", () => redactIncomingMessage(data));
|
|
243
265
|
if (!this.serverInfo) {
|
|
244
266
|
this.serverInfo = data;
|
|
245
267
|
resolve();
|
|
@@ -260,7 +282,7 @@ class Connection {
|
|
|
260
282
|
if (!this.socket) {
|
|
261
283
|
throw new Error("Not connected");
|
|
262
284
|
}
|
|
263
|
-
|
|
285
|
+
this.logger.debug("WebSocket send message", () => redactSensitiveCommandFields(message));
|
|
264
286
|
this.socket.send(toBigIntAwareJson(message));
|
|
265
287
|
}
|
|
266
288
|
}
|
|
@@ -519,14 +541,14 @@ class MatterClient {
|
|
|
519
541
|
/**
|
|
520
542
|
* Create a new MatterClient.
|
|
521
543
|
* @param url WebSocket URL to connect to
|
|
522
|
-
* @param
|
|
523
|
-
*
|
|
524
|
-
*
|
|
544
|
+
* @param options The {@link ConnectionOptions}, or only a {@link WebSocketFactory}.
|
|
545
|
+
* For Node.js, pass a factory: (url) => new WebSocket(url) from the 'ws' package.
|
|
546
|
+
* For browser, leave the factory undefined to use native WebSocket.
|
|
525
547
|
*/
|
|
526
|
-
constructor(url,
|
|
548
|
+
constructor(url, options) {
|
|
527
549
|
this.url = url;
|
|
528
550
|
this.url = url;
|
|
529
|
-
this.connection = new Connection(this.url,
|
|
551
|
+
this.connection = new Connection(this.url, options);
|
|
530
552
|
this.serverBaseAddress = this.url.split("://")[1].split(":")[0] ?? "";
|
|
531
553
|
}
|
|
532
554
|
url;
|
|
@@ -787,7 +809,7 @@ class MatterClient {
|
|
|
787
809
|
subscription_id
|
|
788
810
|
}) => {
|
|
789
811
|
if (timedOut) {
|
|
790
|
-
this.unsubscribe(args.node_id, subscription_id).catch(error =>
|
|
812
|
+
this.unsubscribe(args.node_id, subscription_id).catch(error => this.connection.logger.warn(`Could not end subscription ${subscription_id} after its subscribe timed out`, () => error));
|
|
791
813
|
return;
|
|
792
814
|
}
|
|
793
815
|
this.subscriptionListeners.set(subscriptionKey(args.node_id, subscription_id), listener);
|
|
@@ -1081,7 +1103,7 @@ class MatterClient {
|
|
|
1081
1103
|
try {
|
|
1082
1104
|
listener.ended?.();
|
|
1083
1105
|
} catch (error) {
|
|
1084
|
-
|
|
1106
|
+
this.connection.logger.error("Subscription listener failed on end", () => error);
|
|
1085
1107
|
}
|
|
1086
1108
|
}
|
|
1087
1109
|
}
|
|
@@ -1145,10 +1167,9 @@ class MatterClient {
|
|
|
1145
1167
|
this._resolvePendingCommand(msg.message_id, msg.result);
|
|
1146
1168
|
return;
|
|
1147
1169
|
}
|
|
1148
|
-
|
|
1170
|
+
this.connection.logger.warn("Received message with unknown format", () => redactIncomingMessage(msg));
|
|
1149
1171
|
}
|
|
1150
1172
|
_handleEventMessage(event) {
|
|
1151
|
-
console.debug("Incoming event", redactIncomingMessage(event));
|
|
1152
1173
|
this.onRawEvent(event);
|
|
1153
1174
|
if (event.event === "node_added") {
|
|
1154
1175
|
const node = new MatterNode(event.data);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matter-server/dashboard",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.4",
|
|
4
4
|
"description": "Dashboard for OHF Matter Server",
|
|
5
5
|
"homepage": "https://github.com/matter-js/matterjs-server",
|
|
6
6
|
"bugs": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@lit/context": "^1.1.6",
|
|
36
36
|
"@material/web": "^2.5.0",
|
|
37
|
-
"@matter-server/custom-clusters": "1.5.
|
|
38
|
-
"@matter-server/ws-client": "1.5.
|
|
37
|
+
"@matter-server/custom-clusters": "1.5.4",
|
|
38
|
+
"@matter-server/ws-client": "1.5.4",
|
|
39
39
|
"@mdi/js": "^7.4.47",
|
|
40
40
|
"lit": "^3.3.3",
|
|
41
41
|
"qrcode-generator": "^2.0.4",
|