@matter-server/ws-controller 0.6.3-alpha.0-20260429-7b8104b → 0.6.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.
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import { NodeId } from "@matter/main";
8
+ import { EndpointNumber } from "@matter/main/types";
8
9
  import { NodeStates, PairedNode } from "@project-chip/matter.js/device";
9
10
  import { ServerError } from "../types/WebSocketMessageTypes.js";
10
11
  import { AttributeDataCache } from "./AttributeDataCache.js";
@@ -25,6 +26,13 @@ export class Nodes {
25
26
  #previousStates = new Map<NodeId, NodeStates>();
26
27
  /** Cached availability so serialization and event paths always agree */
27
28
  #lastAvailability = new Map<NodeId, boolean>();
29
+ /**
30
+ * Endpoint additions queued until the next nodeStructureChanged for that node.
31
+ * Preserves the wire contract used by python-matter-server: endpoint_added must
32
+ * arrive AFTER a node_updated that already carries the new endpoint, so consumers
33
+ * (e.g., Home Assistant) can resolve node.endpoints[endpoint_id] in their callback.
34
+ */
35
+ #pendingEndpointAdds = new Map<NodeId, EndpointNumber[]>();
28
36
 
29
37
  /**
30
38
  * Get the attribute cache instance.
@@ -74,6 +82,32 @@ export class Nodes {
74
82
  this.#attributeCache.delete(nodeId);
75
83
  this.#previousStates.delete(nodeId);
76
84
  this.#lastAvailability.delete(nodeId);
85
+ this.#pendingEndpointAdds.delete(nodeId);
86
+ }
87
+
88
+ /**
89
+ * Buffer an endpoint_added until the next nodeStructureChanged for that node.
90
+ */
91
+ queueEndpointAdded(nodeId: NodeId, endpointId: EndpointNumber): void {
92
+ let queue = this.#pendingEndpointAdds.get(nodeId);
93
+ if (queue === undefined) {
94
+ queue = [];
95
+ this.#pendingEndpointAdds.set(nodeId, queue);
96
+ }
97
+ queue.push(endpointId);
98
+ }
99
+
100
+ /**
101
+ * Take ownership of buffered endpoint additions for a node and clear the queue.
102
+ * Returned array is in insertion order; an empty array is returned if nothing is queued.
103
+ */
104
+ drainPendingEndpointAdds(nodeId: NodeId): EndpointNumber[] {
105
+ const queue = this.#pendingEndpointAdds.get(nodeId);
106
+ if (queue === undefined || queue.length === 0) {
107
+ return [];
108
+ }
109
+ this.#pendingEndpointAdds.delete(nodeId);
110
+ return queue;
77
111
  }
78
112
 
79
113
  /**
@@ -470,6 +470,9 @@ export class WebSocketControllerHandler implements WebServerHandler {
470
470
  case "set_thread_dataset":
471
471
  result = await this.#handleSetThreadDataset(args);
472
472
  break;
473
+ case "get_thread_border_routers":
474
+ result = this.#controller.borderRouters.list();
475
+ break;
473
476
  case "open_commissioning_window":
474
477
  result = await this.#handleOpenCommissioningWindow(args);
475
478
  break;