@matter/node 0.16.0-alpha.0-20251018-dd1ea6a8a → 0.16.0-alpha.0-20251021-cca02fb0e
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/cjs/behavior/Behavior.d.ts +1 -1
- package/dist/cjs/behavior/Behavior.d.ts.map +1 -1
- package/dist/cjs/behavior/Behavior.js +29 -3
- package/dist/cjs/behavior/Behavior.js.map +1 -1
- package/dist/cjs/behavior/cluster/ClusterBehavior.d.ts +1 -1
- package/dist/cjs/behavior/cluster/ClusterBehavior.d.ts.map +1 -1
- package/dist/cjs/behavior/cluster/ClusterBehaviorUtil.d.ts.map +1 -1
- package/dist/cjs/behavior/cluster/ClusterBehaviorUtil.js +2 -4
- package/dist/cjs/behavior/cluster/ClusterBehaviorUtil.js.map +1 -1
- package/dist/cjs/behavior/supervision/RootSupervisor.d.ts.map +1 -1
- package/dist/cjs/behavior/supervision/RootSupervisor.js +2 -1
- package/dist/cjs/behavior/supervision/RootSupervisor.js.map +1 -1
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.d.ts +35 -11
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.js +155 -140
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.js.map +2 -2
- package/dist/cjs/behavior/system/commissioning/CommissioningServer.d.ts +0 -7
- package/dist/cjs/behavior/system/commissioning/CommissioningServer.d.ts.map +1 -1
- package/dist/cjs/behavior/system/commissioning/CommissioningServer.js +23 -27
- package/dist/cjs/behavior/system/commissioning/CommissioningServer.js.map +1 -1
- package/dist/cjs/behavior/system/commissioning/RemoteDescriptor.js +4 -4
- package/dist/cjs/behavior/system/commissioning/RemoteDescriptor.js.map +1 -1
- package/dist/cjs/behavior/system/controller/ControllerBehavior.d.ts +13 -2
- package/dist/cjs/behavior/system/controller/ControllerBehavior.d.ts.map +1 -1
- package/dist/cjs/behavior/system/controller/ControllerBehavior.js +37 -23
- package/dist/cjs/behavior/system/controller/ControllerBehavior.js.map +1 -1
- package/dist/cjs/behavior/system/network/NetworkClient.d.ts.map +1 -1
- package/dist/cjs/behavior/system/network/NetworkClient.js +7 -2
- package/dist/cjs/behavior/system/network/NetworkClient.js.map +1 -1
- package/dist/cjs/behavior/system/network/NetworkServer.js +1 -1
- package/dist/cjs/behavior/system/network/NetworkServer.js.map +1 -1
- package/dist/cjs/behavior/system/network/ServerNetworkRuntime.d.ts.map +1 -1
- package/dist/cjs/behavior/system/network/ServerNetworkRuntime.js +1 -2
- package/dist/cjs/behavior/system/network/ServerNetworkRuntime.js.map +1 -1
- package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.js +3 -3
- package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.js.map +1 -1
- package/dist/cjs/behaviors/access-control/AccessControlServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/access-control/AccessControlServer.js +2 -9
- package/dist/cjs/behaviors/access-control/AccessControlServer.js.map +1 -1
- package/dist/cjs/behaviors/general-commissioning/GeneralCommissioningServer.js +1 -1
- package/dist/cjs/behaviors/general-commissioning/GeneralCommissioningServer.js.map +1 -1
- package/dist/cjs/endpoint/properties/Endpoints.d.ts +1 -1
- package/dist/cjs/endpoint/properties/Endpoints.d.ts.map +1 -1
- package/dist/cjs/node/ClientGroup.d.ts +18 -0
- package/dist/cjs/node/ClientGroup.d.ts.map +1 -0
- package/dist/cjs/node/ClientGroup.js +53 -0
- package/dist/cjs/node/ClientGroup.js.map +6 -0
- package/dist/cjs/node/ClientNode.d.ts +3 -0
- package/dist/cjs/node/ClientNode.d.ts.map +1 -1
- package/dist/cjs/node/ClientNode.js +8 -2
- package/dist/cjs/node/ClientNode.js.map +1 -1
- package/dist/cjs/node/client/ClientGroupInteraction.d.ts +22 -0
- package/dist/cjs/node/client/ClientGroupInteraction.d.ts.map +1 -0
- package/dist/cjs/node/client/ClientGroupInteraction.js +67 -0
- package/dist/cjs/node/client/ClientGroupInteraction.js.map +6 -0
- package/dist/cjs/node/client/ClientNodeFactory.d.ts +2 -1
- package/dist/cjs/node/client/ClientNodeFactory.d.ts.map +1 -1
- package/dist/cjs/node/client/ClientNodeFactory.js.map +1 -1
- package/dist/cjs/node/client/Peers.d.ts.map +1 -1
- package/dist/cjs/node/client/Peers.js +28 -18
- package/dist/cjs/node/client/Peers.js.map +2 -2
- package/dist/cjs/node/server/ServerEnvironment.d.ts.map +1 -1
- package/dist/cjs/node/server/ServerEnvironment.js +8 -2
- package/dist/cjs/node/server/ServerEnvironment.js.map +1 -1
- package/dist/cjs/storage/client/ClientNodeStores.d.ts +2 -0
- package/dist/cjs/storage/client/ClientNodeStores.d.ts.map +1 -1
- package/dist/cjs/storage/client/ClientNodeStores.js +19 -0
- package/dist/cjs/storage/client/ClientNodeStores.js.map +1 -1
- package/dist/esm/behavior/Behavior.d.ts +1 -1
- package/dist/esm/behavior/Behavior.d.ts.map +1 -1
- package/dist/esm/behavior/Behavior.js +29 -3
- package/dist/esm/behavior/Behavior.js.map +1 -1
- package/dist/esm/behavior/cluster/ClusterBehavior.d.ts +1 -1
- package/dist/esm/behavior/cluster/ClusterBehavior.d.ts.map +1 -1
- package/dist/esm/behavior/cluster/ClusterBehaviorUtil.d.ts.map +1 -1
- package/dist/esm/behavior/cluster/ClusterBehaviorUtil.js +3 -4
- package/dist/esm/behavior/cluster/ClusterBehaviorUtil.js.map +1 -1
- package/dist/esm/behavior/supervision/RootSupervisor.d.ts.map +1 -1
- package/dist/esm/behavior/supervision/RootSupervisor.js +3 -1
- package/dist/esm/behavior/supervision/RootSupervisor.js.map +1 -1
- package/dist/esm/behavior/system/commissioning/CommissioningClient.d.ts +35 -11
- package/dist/esm/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
- package/dist/esm/behavior/system/commissioning/CommissioningClient.js +175 -143
- package/dist/esm/behavior/system/commissioning/CommissioningClient.js.map +2 -2
- package/dist/esm/behavior/system/commissioning/CommissioningServer.d.ts +0 -7
- package/dist/esm/behavior/system/commissioning/CommissioningServer.d.ts.map +1 -1
- package/dist/esm/behavior/system/commissioning/CommissioningServer.js +23 -27
- package/dist/esm/behavior/system/commissioning/CommissioningServer.js.map +1 -1
- package/dist/esm/behavior/system/commissioning/RemoteDescriptor.js +4 -4
- package/dist/esm/behavior/system/commissioning/RemoteDescriptor.js.map +1 -1
- package/dist/esm/behavior/system/controller/ControllerBehavior.d.ts +13 -2
- package/dist/esm/behavior/system/controller/ControllerBehavior.d.ts.map +1 -1
- package/dist/esm/behavior/system/controller/ControllerBehavior.js +38 -25
- package/dist/esm/behavior/system/controller/ControllerBehavior.js.map +1 -1
- package/dist/esm/behavior/system/network/NetworkClient.d.ts.map +1 -1
- package/dist/esm/behavior/system/network/NetworkClient.js +7 -2
- package/dist/esm/behavior/system/network/NetworkClient.js.map +1 -1
- package/dist/esm/behavior/system/network/NetworkServer.js +1 -1
- package/dist/esm/behavior/system/network/NetworkServer.js.map +1 -1
- package/dist/esm/behavior/system/network/ServerNetworkRuntime.d.ts.map +1 -1
- package/dist/esm/behavior/system/network/ServerNetworkRuntime.js +1 -3
- package/dist/esm/behavior/system/network/ServerNetworkRuntime.js.map +1 -1
- package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.js +3 -3
- package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.js.map +1 -1
- package/dist/esm/behaviors/access-control/AccessControlServer.d.ts.map +1 -1
- package/dist/esm/behaviors/access-control/AccessControlServer.js +2 -9
- package/dist/esm/behaviors/access-control/AccessControlServer.js.map +1 -1
- package/dist/esm/behaviors/general-commissioning/GeneralCommissioningServer.js +1 -1
- package/dist/esm/behaviors/general-commissioning/GeneralCommissioningServer.js.map +1 -1
- package/dist/esm/endpoint/properties/Endpoints.d.ts +1 -1
- package/dist/esm/endpoint/properties/Endpoints.d.ts.map +1 -1
- package/dist/esm/node/ClientGroup.d.ts +18 -0
- package/dist/esm/node/ClientGroup.d.ts.map +1 -0
- package/dist/esm/node/ClientGroup.js +33 -0
- package/dist/esm/node/ClientGroup.js.map +6 -0
- package/dist/esm/node/ClientNode.d.ts +3 -0
- package/dist/esm/node/ClientNode.d.ts.map +1 -1
- package/dist/esm/node/ClientNode.js +8 -2
- package/dist/esm/node/ClientNode.js.map +1 -1
- package/dist/esm/node/client/ClientGroupInteraction.d.ts +22 -0
- package/dist/esm/node/client/ClientGroupInteraction.d.ts.map +1 -0
- package/dist/esm/node/client/ClientGroupInteraction.js +47 -0
- package/dist/esm/node/client/ClientGroupInteraction.js.map +6 -0
- package/dist/esm/node/client/ClientNodeFactory.d.ts +2 -1
- package/dist/esm/node/client/ClientNodeFactory.d.ts.map +1 -1
- package/dist/esm/node/client/ClientNodeFactory.js.map +1 -1
- package/dist/esm/node/client/Peers.d.ts.map +1 -1
- package/dist/esm/node/client/Peers.js +23 -13
- package/dist/esm/node/client/Peers.js.map +1 -1
- package/dist/esm/node/server/ServerEnvironment.d.ts.map +1 -1
- package/dist/esm/node/server/ServerEnvironment.js +9 -3
- package/dist/esm/node/server/ServerEnvironment.js.map +1 -1
- package/dist/esm/storage/client/ClientNodeStores.d.ts +2 -0
- package/dist/esm/storage/client/ClientNodeStores.d.ts.map +1 -1
- package/dist/esm/storage/client/ClientNodeStores.js +20 -1
- package/dist/esm/storage/client/ClientNodeStores.js.map +1 -1
- package/package.json +7 -7
- package/src/behavior/Behavior.ts +42 -4
- package/src/behavior/cluster/ClusterBehavior.ts +1 -1
- package/src/behavior/cluster/ClusterBehaviorUtil.ts +7 -7
- package/src/behavior/supervision/RootSupervisor.ts +4 -2
- package/src/behavior/system/commissioning/CommissioningClient.ts +121 -75
- package/src/behavior/system/commissioning/CommissioningServer.ts +25 -30
- package/src/behavior/system/commissioning/RemoteDescriptor.ts +4 -4
- package/src/behavior/system/controller/ControllerBehavior.ts +49 -32
- package/src/behavior/system/network/NetworkClient.ts +8 -2
- package/src/behavior/system/network/NetworkServer.ts +1 -1
- package/src/behavior/system/network/ServerNetworkRuntime.ts +1 -3
- package/src/behavior/system/subscriptions/SubscriptionsServer.ts +3 -3
- package/src/behaviors/access-control/AccessControlServer.ts +1 -8
- package/src/behaviors/general-commissioning/GeneralCommissioningServer.ts +1 -1
- package/src/endpoint/properties/Endpoints.ts +1 -1
- package/src/node/ClientGroup.ts +36 -0
- package/src/node/ClientNode.ts +10 -2
- package/src/node/client/ClientEndpointInitializer.ts +1 -1
- package/src/node/client/ClientGroupInteraction.ts +70 -0
- package/src/node/client/ClientNodeFactory.ts +2 -1
- package/src/node/client/Peers.ts +25 -14
- package/src/node/server/ServerEnvironment.ts +11 -3
- package/src/storage/client/ClientNodeStores.ts +25 -1
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { Construction, StorageContext } from "#general";
|
|
7
|
+
import type { ClientGroup } from "#node/ClientGroup.js";
|
|
7
8
|
import type { ClientNode } from "#node/ClientNode.js";
|
|
8
9
|
import { ClientNodeStore } from "./ClientNodeStore.js";
|
|
9
10
|
/**
|
|
@@ -27,6 +28,7 @@ export declare class ClientNodeStores {
|
|
|
27
28
|
* These stores are cached internally by ID.
|
|
28
29
|
*/
|
|
29
30
|
storeForNode(node: ClientNode): ClientNodeStore;
|
|
31
|
+
storeForGroup(node: ClientGroup): ClientNodeStore;
|
|
30
32
|
/**
|
|
31
33
|
* List all nodes present.
|
|
32
34
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientNodeStores.d.ts","sourceRoot":"","sources":["../../../../src/storage/client/ClientNodeStores.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"ClientNodeStores.d.ts","sourceRoot":"","sources":["../../../../src/storage/client/ClientNodeStores.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAA8C,cAAc,EAAkB,MAAM,UAAU,CAAC;AACpH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAQvD;;GAEG;AACH,qBAAa,gBAAgB;;IAMzB,IAAI,YAAY,mCAEf;gBAEW,OAAO,EAAE,cAAc;IAM7B,CAAC,YAAY,CAAC,SAAS,CAAC;IAwB9B;;;;;OAKG;IACH,UAAU;IAMV;;;;OAIG;IACH,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,eAAe;IAW/C,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,eAAe;IAWjD;;OAEG;IACH,IAAI,QAAQ,aAIX;IAEK,KAAK;CAsBd"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2022-2025 Matter.js Authors
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { Construction, MatterAggregateError } from "#general";
|
|
6
|
+
import { Construction, MatterAggregateError, StorageBackendMemory, StorageManager } from "#general";
|
|
7
7
|
import { ClientNodeStore } from "./ClientNodeStore.js";
|
|
8
8
|
const CLIENT_ID_PREFIX = "peer";
|
|
9
9
|
class ClientNodeStores {
|
|
@@ -61,6 +61,14 @@ class ClientNodeStores {
|
|
|
61
61
|
}
|
|
62
62
|
return this.#createNodeStore(node.id);
|
|
63
63
|
}
|
|
64
|
+
storeForGroup(node) {
|
|
65
|
+
this.#construction.assert();
|
|
66
|
+
const store = this.#stores[node.id];
|
|
67
|
+
if (store) {
|
|
68
|
+
return store;
|
|
69
|
+
}
|
|
70
|
+
return this.#createGroupStore(node.id);
|
|
71
|
+
}
|
|
64
72
|
/**
|
|
65
73
|
* List all nodes present.
|
|
66
74
|
*/
|
|
@@ -71,6 +79,17 @@ class ClientNodeStores {
|
|
|
71
79
|
async close() {
|
|
72
80
|
await this.construction;
|
|
73
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Group stores are always created with a memory backend as they are transient.
|
|
84
|
+
*/
|
|
85
|
+
#createGroupStore(id) {
|
|
86
|
+
const manager = new StorageManager(new StorageBackendMemory());
|
|
87
|
+
manager.initialize();
|
|
88
|
+
const store = new ClientNodeStore(id, manager.createContext(id));
|
|
89
|
+
store.construction.start();
|
|
90
|
+
this.#stores[id] = store;
|
|
91
|
+
return store;
|
|
92
|
+
}
|
|
74
93
|
#createNodeStore(id) {
|
|
75
94
|
const store = new ClientNodeStore(id, this.#storage.createContext(id));
|
|
76
95
|
store.construction.start();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/storage/client/ClientNodeStores.ts"],
|
|
4
|
-
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,SAAS,cAAc,
|
|
4
|
+
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,SAAS,cAAc,sBAAsB,sBAAsC,sBAAsB;AAIzG,SAAS,uBAAuB;AAMhC,MAAM,mBAAmB;AAKlB,MAAM,iBAAiB;AAAA,EAC1B;AAAA,EACA,UAAU,CAAC;AAAA,EACX;AAAA,EACA,mBAAmB;AAAA,EAEnB,IAAI,eAAe;AACf,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,YAAY,SAAyB;AACjC,SAAK,WAAW;AAChB,SAAK,gBAAgB,aAAa,IAAI;AACtC,SAAK,cAAc,MAAM;AAAA,EAC7B;AAAA,EAEA,OAAO,aAAa,SAAS,IAAI;AAC7B,UAAM,WAAW,MAAM,KAAK,SAAS,SAAS;AAE9C,eAAW,MAAM,UAAU;AACvB,UAAI,CAAC,GAAG,WAAW,gBAAgB,GAAG;AAClC;AAAA,MACJ;AAEA,YAAM,MAAM,OAAO,SAAS,GAAG,MAAM,iBAAiB,MAAM,CAAC;AAC7D,UAAI,OAAO,SAAS,GAAG,GAAG;AACtB,YAAI,KAAK,oBAAoB,KAAK;AAC9B,eAAK,mBAAmB,MAAM;AAAA,QAClC;AAAA,MACJ;AAEA,WAAK,iBAAiB,EAAE;AAAA,IAC5B;AAEA,UAAM,qBAAqB;AAAA,MACvB,OAAO,OAAO,KAAK,OAAO,EAAE,IAAI,WAAS,MAAM,aAAa,KAAK;AAAA,MACjE;AAAA,IACJ;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,aAAa;AACT,SAAK,cAAc,OAAO;AAE1B,WAAO,GAAG,gBAAgB,GAAG,KAAK,kBAAkB;AAAA,EACxD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,aAAa,MAAmC;AAC5C,SAAK,cAAc,OAAO;AAE1B,UAAM,QAAQ,KAAK,QAAQ,KAAK,EAAE;AAClC,QAAI,OAAO;AACP,aAAO;AAAA,IACX;AAEA,WAAO,KAAK,iBAAiB,KAAK,EAAE;AAAA,EACxC;AAAA,EAEA,cAAc,MAAoC;AAC9C,SAAK,cAAc,OAAO;AAE1B,UAAM,QAAQ,KAAK,QAAQ,KAAK,EAAE;AAClC,QAAI,OAAO;AACP,aAAO;AAAA,IACX;AAEA,WAAO,KAAK,kBAAkB,KAAK,EAAE;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,WAAW;AACX,SAAK,cAAc,OAAO;AAE1B,WAAO,OAAO,KAAK,KAAK,OAAO;AAAA,EACnC;AAAA,EAEA,MAAM,QAAQ;AACV,UAAM,KAAK;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EAKA,kBAAkB,IAAY;AAC1B,UAAM,UAAU,IAAI,eAAe,IAAI,qBAAqB,CAAC;AAC7D,YAAQ,WAAW;AACnB,UAAM,QAAQ,IAAI,gBAAgB,IAAI,QAAQ,cAAc,EAAE,CAAC;AAC/D,UAAM,aAAa,MAAM;AACzB,SAAK,QAAQ,EAAE,IAAI;AACnB,WAAO;AAAA,EACX;AAAA,EAEA,iBAAiB,IAAY;AACzB,UAAM,QAAQ,IAAI,gBAAgB,IAAI,KAAK,SAAS,cAAc,EAAE,CAAC;AACrE,UAAM,aAAa,MAAM;AACzB,SAAK,QAAQ,EAAE,IAAI;AACnB,WAAO;AAAA,EACX;AACJ;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matter/node",
|
|
3
|
-
"version": "0.16.0-alpha.0-
|
|
3
|
+
"version": "0.16.0-alpha.0-20251021-cca02fb0e",
|
|
4
4
|
"description": "API for building Matter nodes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"iot",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"#*": "./src/*"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@matter/general": "0.16.0-alpha.0-
|
|
46
|
-
"@matter/model": "0.16.0-alpha.0-
|
|
47
|
-
"@matter/types": "0.16.0-alpha.0-
|
|
48
|
-
"@matter/protocol": "0.16.0-alpha.0-
|
|
45
|
+
"@matter/general": "0.16.0-alpha.0-20251021-cca02fb0e",
|
|
46
|
+
"@matter/model": "0.16.0-alpha.0-20251021-cca02fb0e",
|
|
47
|
+
"@matter/types": "0.16.0-alpha.0-20251021-cca02fb0e",
|
|
48
|
+
"@matter/protocol": "0.16.0-alpha.0-20251021-cca02fb0e"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@matter/tools": "0.16.0-alpha.0-
|
|
52
|
-
"@matter/testing": "0.16.0-alpha.0-
|
|
51
|
+
"@matter/tools": "0.16.0-alpha.0-20251021-cca02fb0e",
|
|
52
|
+
"@matter/testing": "0.16.0-alpha.0-20251021-cca02fb0e"
|
|
53
53
|
},
|
|
54
54
|
"files": [
|
|
55
55
|
"dist/**/*",
|
package/src/behavior/Behavior.ts
CHANGED
|
@@ -14,12 +14,11 @@ import {
|
|
|
14
14
|
Observable,
|
|
15
15
|
Transaction,
|
|
16
16
|
} from "#general";
|
|
17
|
-
import { Schema } from "#model";
|
|
17
|
+
import { ClassSemantics, Schema, Semantics } from "#model";
|
|
18
18
|
import type { ClusterType } from "#types";
|
|
19
19
|
import { Reactor } from "./Reactor.js";
|
|
20
20
|
import type { BehaviorBacking } from "./internal/BehaviorBacking.js";
|
|
21
21
|
import { DerivedState, EmptyState } from "./state/StateType.js";
|
|
22
|
-
import { BehaviorSupervisor } from "./supervision/BehaviorSupervisor.js";
|
|
23
22
|
import { RootSupervisor } from "./supervision/RootSupervisor.js";
|
|
24
23
|
|
|
25
24
|
// Internal fields
|
|
@@ -68,7 +67,9 @@ export abstract class Behavior {
|
|
|
68
67
|
* Schema is inferred from the methods and properties of the behavior but you can specify explicitly for additional
|
|
69
68
|
* control.
|
|
70
69
|
*/
|
|
71
|
-
static
|
|
70
|
+
static get schema() {
|
|
71
|
+
return Schema(this);
|
|
72
|
+
}
|
|
72
73
|
|
|
73
74
|
/**
|
|
74
75
|
* By default behaviors load lazily as they are accessed. You can set this flag to true to force behaviors to load
|
|
@@ -139,7 +140,7 @@ export abstract class Behavior {
|
|
|
139
140
|
if (Object.hasOwn(this, SUPERVISOR)) {
|
|
140
141
|
return (this as StaticInternal)[SUPERVISOR] as RootSupervisor;
|
|
141
142
|
}
|
|
142
|
-
return ((this as StaticInternal)[SUPERVISOR] =
|
|
143
|
+
return ((this as StaticInternal)[SUPERVISOR] = RootSupervisor.for(Schema(this) ?? Schema.empty));
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
/**
|
|
@@ -310,6 +311,43 @@ Object.defineProperties(Behavior.prototype, {
|
|
|
310
311
|
},
|
|
311
312
|
});
|
|
312
313
|
|
|
314
|
+
/**
|
|
315
|
+
* Install {@link ClassSemantics} extension logic to integrate schema metadata.
|
|
316
|
+
*/
|
|
317
|
+
Object.defineProperties(Behavior, {
|
|
318
|
+
[ClassSemantics.extend]: {
|
|
319
|
+
value(this: Behavior.Type, decoration: ClassSemantics) {
|
|
320
|
+
const type = decoration.new as Behavior.Type;
|
|
321
|
+
|
|
322
|
+
// Support static override of schema
|
|
323
|
+
if (Object.hasOwn(type, "schema") && type.schema !== undefined) {
|
|
324
|
+
decoration.mutableModel = type.schema;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// Obtain state and base schema
|
|
328
|
+
const { State, Events, defaults } = type;
|
|
329
|
+
if (!State || !defaults) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// Merge state properties into my schema
|
|
334
|
+
if (ClassSemantics.hasOwnSemantics(State)) {
|
|
335
|
+
const stateSemantics = Semantics.classOf(State);
|
|
336
|
+
stateSemantics.mutableModel = decoration.mutableModel;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Merge events into my schema
|
|
340
|
+
if (ClassSemantics.hasOwnSemantics(Events)) {
|
|
341
|
+
const eventSemantics = Semantics.classOf(Events);
|
|
342
|
+
eventSemantics.mutableModel = decoration.mutableModel;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Augment with fields for untyped state members
|
|
346
|
+
decoration.defineUnknownMembers(defaults);
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
});
|
|
350
|
+
|
|
313
351
|
export namespace Behavior {
|
|
314
352
|
/**
|
|
315
353
|
* Static properties supported by all behaviors.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { Events } from "#behavior/Events.js";
|
|
8
8
|
import type { Agent } from "#endpoint/Agent.js";
|
|
9
9
|
import { ImplementationError, MaybePromise } from "#general";
|
|
10
|
-
import type
|
|
10
|
+
import { type Schema } from "#model";
|
|
11
11
|
import { ClusterComposer, ClusterType, ElementModifier, TypeFromBitSchema } from "#types";
|
|
12
12
|
import { Behavior } from "../Behavior.js";
|
|
13
13
|
import type { BehaviorBacking } from "../internal/BehaviorBacking.js";
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { Events, OfflineEvent, OnlineEvent, QuietEvent } from "#behavior/Events.js";
|
|
8
8
|
import { camelize, EventEmitter, GeneratedClass, ImplementationError, Observable } from "#general";
|
|
9
9
|
import {
|
|
10
|
+
ClassSemantics,
|
|
10
11
|
ClusterModel,
|
|
11
12
|
DefaultValue,
|
|
12
13
|
ElementTag,
|
|
@@ -81,9 +82,6 @@ export function createType<const C extends ClusterType>(
|
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
// Mutation of schema will almost certainly result in logic errors so ensure that can't happen
|
|
85
|
-
schema.freeze();
|
|
86
|
-
|
|
87
85
|
const newProps = {} as Record<string, ValueModel>;
|
|
88
86
|
const scope = Scope(schema);
|
|
89
87
|
|
|
@@ -110,15 +108,17 @@ export function createType<const C extends ClusterType>(
|
|
|
110
108
|
value: cluster,
|
|
111
109
|
enumerable: true,
|
|
112
110
|
},
|
|
113
|
-
|
|
114
|
-
schema: {
|
|
115
|
-
value: schema,
|
|
116
|
-
},
|
|
117
111
|
},
|
|
118
112
|
|
|
119
113
|
instanceDescriptors: createDefaultCommandDescriptors(cluster, base),
|
|
120
114
|
}) as ClusterBehavior.Type;
|
|
121
115
|
|
|
116
|
+
// Decorate the class
|
|
117
|
+
ClassSemantics.of(type).mutableModel = schema;
|
|
118
|
+
|
|
119
|
+
// Mutation of schema will almost certainly result in logic errors so ensure that can't happen
|
|
120
|
+
schema.finalize();
|
|
121
|
+
|
|
122
122
|
if (useCache) {
|
|
123
123
|
ClusterBehaviorCache.set(cluster, base, schema, type);
|
|
124
124
|
}
|
|
@@ -8,6 +8,7 @@ import { camelize, InternalError } from "#general";
|
|
|
8
8
|
import {
|
|
9
9
|
AttributeModel,
|
|
10
10
|
ClusterModel,
|
|
11
|
+
ElementTag,
|
|
11
12
|
FeatureMap,
|
|
12
13
|
FeatureSet,
|
|
13
14
|
Matter,
|
|
@@ -160,8 +161,9 @@ export class RootSupervisor implements ValueSupervisor {
|
|
|
160
161
|
// TODO: We should handle writable/fabric scoped being non-volatile already in the conformance interpreter
|
|
161
162
|
if (
|
|
162
163
|
member.effectiveQuality.nonvolatile ||
|
|
163
|
-
|
|
164
|
-
member.
|
|
164
|
+
// Persist all writable attributes in addition to those officially marked as nonvolatile
|
|
165
|
+
(member.tag === ElementTag.Attribute &&
|
|
166
|
+
(member.effectiveAccess.writable || member.effectiveAccess.fabricScoped))
|
|
165
167
|
) {
|
|
166
168
|
if (key === "id") {
|
|
167
169
|
const id = member.effectiveId;
|
|
@@ -19,7 +19,22 @@ import {
|
|
|
19
19
|
Time,
|
|
20
20
|
Timestamp,
|
|
21
21
|
} from "#general";
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
bool,
|
|
24
|
+
duration,
|
|
25
|
+
fabricIdx,
|
|
26
|
+
field,
|
|
27
|
+
listOf,
|
|
28
|
+
mandatory,
|
|
29
|
+
nodeId,
|
|
30
|
+
nonvolatile,
|
|
31
|
+
string,
|
|
32
|
+
systimeMs,
|
|
33
|
+
uint16,
|
|
34
|
+
uint32,
|
|
35
|
+
uint8,
|
|
36
|
+
vendorId,
|
|
37
|
+
} from "#model";
|
|
23
38
|
import type { ClientNode } from "#node/ClientNode.js";
|
|
24
39
|
import type { Node } from "#node/Node.js";
|
|
25
40
|
import { IdentityService } from "#node/server/IdentityService.js";
|
|
@@ -32,14 +47,15 @@ import {
|
|
|
32
47
|
FabricAuthority,
|
|
33
48
|
FabricManager,
|
|
34
49
|
LocatedNodeCommissioningOptions,
|
|
35
|
-
PeerAddress,
|
|
36
|
-
|
|
50
|
+
PeerAddress as ProtocolPeerAddress,
|
|
51
|
+
SessionIntervals as ProtocolSessionIntervals,
|
|
37
52
|
Subscribe,
|
|
38
53
|
} from "#protocol";
|
|
39
54
|
import {
|
|
40
55
|
CaseAuthenticatedTag,
|
|
41
56
|
DeviceTypeId,
|
|
42
57
|
DiscoveryCapabilitiesBitmap,
|
|
58
|
+
FabricIndex,
|
|
43
59
|
ManualPairingCodeCodec,
|
|
44
60
|
NodeId,
|
|
45
61
|
TypeFromPartialBitSchema,
|
|
@@ -109,11 +125,17 @@ export class CommissioningClient extends Behavior {
|
|
|
109
125
|
await node.owner?.act(agent => agent.load(ControllerBehavior));
|
|
110
126
|
|
|
111
127
|
// Obtain the fabric we will commission into
|
|
112
|
-
const fabricAuthority = opts.fabricAuthority
|
|
128
|
+
const fabricAuthority = opts.fabricAuthority ?? this.env.get(FabricAuthority);
|
|
113
129
|
let { fabric } = opts;
|
|
114
130
|
if (fabric === undefined) {
|
|
115
131
|
if (this.context.fabric === undefined) {
|
|
116
|
-
|
|
132
|
+
const config = await node.owner?.act(agent => agent.get(ControllerBehavior).fabricAuthorityConfig);
|
|
133
|
+
if (config === undefined) {
|
|
134
|
+
throw new ImplementationError(
|
|
135
|
+
`Cannot commission ${node} because no fabric was specified and the controller has no fabric configuration`,
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
fabric = await fabricAuthority.defaultFabric(config);
|
|
117
139
|
} else {
|
|
118
140
|
fabric = node.env.get(FabricManager).for(this.context.fabric);
|
|
119
141
|
}
|
|
@@ -194,7 +216,7 @@ export class CommissioningClient extends Behavior {
|
|
|
194
216
|
throw new ImplementationError("Cannot decommission node that is not commissioned");
|
|
195
217
|
}
|
|
196
218
|
|
|
197
|
-
const formerAddress =
|
|
219
|
+
const formerAddress = ProtocolPeerAddress(peerAddress).toString();
|
|
198
220
|
|
|
199
221
|
const opcreds = this.agent.get(OperationalCredentialsClient);
|
|
200
222
|
|
|
@@ -218,7 +240,7 @@ export class CommissioningClient extends Behavior {
|
|
|
218
240
|
* If you override, matter.js commissions to the point where commissioning over PASE is complete. You must then
|
|
219
241
|
* complete commissioning yourself by connecting to the device and invokeint the "CommissioningComplete" command.
|
|
220
242
|
*/
|
|
221
|
-
protected async finalizeCommissioning(_address:
|
|
243
|
+
protected async finalizeCommissioning(_address: ProtocolPeerAddress, _discoveryData?: DiscoveryData) {
|
|
222
244
|
throw new NotImplementedError();
|
|
223
245
|
}
|
|
224
246
|
|
|
@@ -235,7 +257,7 @@ export class CommissioningClient extends Behavior {
|
|
|
235
257
|
endpoint.lifecycle.initialized.emit(this.state.peerAddress !== undefined);
|
|
236
258
|
}
|
|
237
259
|
|
|
238
|
-
#peerAddressChanged(addr?:
|
|
260
|
+
#peerAddressChanged(addr?: ProtocolPeerAddress) {
|
|
239
261
|
const node = this.endpoint as ClientNode;
|
|
240
262
|
|
|
241
263
|
if (addr) {
|
|
@@ -258,174 +280,198 @@ export class CommissioningClient extends Behavior {
|
|
|
258
280
|
node.lifecycle.decommissioned.emit(this.context);
|
|
259
281
|
}
|
|
260
282
|
}
|
|
283
|
+
}
|
|
261
284
|
|
|
285
|
+
export namespace CommissioningClient {
|
|
262
286
|
/**
|
|
263
|
-
*
|
|
287
|
+
* Concrete version of {@link ProtocolPeerAddress}.
|
|
264
288
|
*/
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
289
|
+
export class PeerAddress implements ProtocolPeerAddress {
|
|
290
|
+
@field(fabricIdx, mandatory)
|
|
291
|
+
fabricIndex: FabricIndex;
|
|
292
|
+
|
|
293
|
+
@field(nodeId, mandatory)
|
|
294
|
+
nodeId: NodeId;
|
|
295
|
+
|
|
296
|
+
constructor(fabricIndex: FabricIndex, nodeId: NodeId) {
|
|
297
|
+
this.fabricIndex = fabricIndex;
|
|
298
|
+
this.nodeId = nodeId;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Concrete version of {@link SessionIntervals}.
|
|
304
|
+
*/
|
|
305
|
+
export class SessionIntervals implements ProtocolSessionIntervals {
|
|
306
|
+
@field(duration.extend({ constraint: "max 3600000" }), mandatory)
|
|
307
|
+
idleInterval: Duration;
|
|
308
|
+
|
|
309
|
+
@field(duration.extend({ constraint: "max 3600000" }), mandatory)
|
|
310
|
+
activeInterval: Duration;
|
|
311
|
+
|
|
312
|
+
@field(duration.extend({ constraint: "max 65535" }), mandatory)
|
|
313
|
+
activeThreshold: Duration;
|
|
314
|
+
|
|
315
|
+
constructor(intervals: SessionIntervals) {
|
|
316
|
+
this.idleInterval = intervals.idleInterval;
|
|
317
|
+
this.activeInterval = intervals.activeInterval;
|
|
318
|
+
this.activeThreshold = intervals.activeThreshold;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* The network address of a node.
|
|
324
|
+
*/
|
|
325
|
+
export class NetworkAddress implements ServerAddress.Definition {
|
|
326
|
+
@field(string, mandatory)
|
|
327
|
+
type: "udp" | "tcp" | "ble";
|
|
328
|
+
|
|
329
|
+
@field(string)
|
|
330
|
+
ip?: string;
|
|
331
|
+
|
|
332
|
+
@field(uint16)
|
|
333
|
+
port?: number;
|
|
334
|
+
|
|
335
|
+
@field(string)
|
|
336
|
+
peripheralAddress?: string;
|
|
337
|
+
|
|
338
|
+
@field(uint32)
|
|
339
|
+
ttl?: Duration | undefined;
|
|
340
|
+
|
|
341
|
+
@field(systimeMs)
|
|
342
|
+
discoveredAt?: Timestamp | undefined;
|
|
343
|
+
|
|
344
|
+
constructor(address: NetworkAddress) {
|
|
345
|
+
this.type = address.type;
|
|
346
|
+
this.ip = address.ip;
|
|
347
|
+
this.port = address.port;
|
|
348
|
+
this.peripheralAddress = address.peripheralAddress;
|
|
349
|
+
this.ttl = address.ttl;
|
|
350
|
+
this.discoveredAt = address.discoveredAt;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
327
353
|
|
|
328
|
-
export namespace CommissioningClient {
|
|
329
354
|
export class State {
|
|
330
355
|
/**
|
|
331
356
|
* Fabric index and node ID for paired peers. If this is undefined the node is uncommissioned.
|
|
332
357
|
*/
|
|
358
|
+
@field(PeerAddress, nonvolatile)
|
|
333
359
|
peerAddress?: PeerAddress;
|
|
334
360
|
|
|
335
361
|
/**
|
|
336
362
|
* Known network addresses for the device. If this is undefined the node has not been located on any network
|
|
337
363
|
* interface.
|
|
338
364
|
*/
|
|
365
|
+
@field(listOf(NetworkAddress), nonvolatile)
|
|
339
366
|
addresses?: ServerAddress.Definition[];
|
|
340
367
|
|
|
341
368
|
/**
|
|
342
369
|
* Time at which the device was discovered.
|
|
343
370
|
*/
|
|
371
|
+
@field(systimeMs, nonvolatile)
|
|
344
372
|
discoveredAt?: Timestamp;
|
|
345
373
|
|
|
346
374
|
/**
|
|
347
375
|
* Time at which we discovered the device's current operational addresses.
|
|
348
376
|
*/
|
|
377
|
+
@field(systimeMs)
|
|
349
378
|
onlineAt?: Timestamp;
|
|
350
379
|
|
|
351
380
|
/**
|
|
352
381
|
* Time at which we concluded the device's current operational address is unreachable.
|
|
353
382
|
*/
|
|
383
|
+
@field(systimeMs)
|
|
354
384
|
offlineAt?: Timestamp;
|
|
355
385
|
|
|
356
386
|
/**
|
|
357
387
|
* The TTL of the discovery record if applicable (in seconds).
|
|
358
388
|
*/
|
|
389
|
+
@field(duration, nonvolatile)
|
|
359
390
|
ttl?: Duration;
|
|
360
391
|
|
|
361
392
|
/**
|
|
362
393
|
* The canonical global ID of the device.
|
|
363
394
|
*/
|
|
395
|
+
@field(string, nonvolatile)
|
|
364
396
|
deviceIdentifier?: string;
|
|
365
397
|
|
|
366
398
|
/**
|
|
367
399
|
* The device's long discriminator.
|
|
368
400
|
*/
|
|
401
|
+
@field(uint16, nonvolatile)
|
|
369
402
|
discriminator?: number;
|
|
370
403
|
|
|
371
404
|
/**
|
|
372
405
|
* The last know commissioning mode of the device.
|
|
373
406
|
*/
|
|
407
|
+
@field(uint8, nonvolatile)
|
|
374
408
|
commissioningMode?: CommissioningMode;
|
|
375
409
|
|
|
376
410
|
/**
|
|
377
411
|
* Vendor.
|
|
378
412
|
*/
|
|
413
|
+
@field(vendorId, nonvolatile)
|
|
379
414
|
vendorId?: VendorId;
|
|
380
415
|
|
|
381
416
|
/**
|
|
382
417
|
* Product.
|
|
383
418
|
*/
|
|
419
|
+
@field(uint16, nonvolatile)
|
|
384
420
|
productId?: number;
|
|
385
421
|
|
|
386
422
|
/**
|
|
387
423
|
* Advertised device type.
|
|
388
424
|
*/
|
|
425
|
+
@field(uint16, nonvolatile)
|
|
389
426
|
deviceType?: DeviceTypeId;
|
|
390
427
|
|
|
391
428
|
/**
|
|
392
429
|
* The advertised device name specified by the user.
|
|
393
430
|
*/
|
|
431
|
+
@field(string, nonvolatile)
|
|
394
432
|
deviceName?: string;
|
|
395
433
|
|
|
396
434
|
/**
|
|
397
435
|
* An optional manufacturer-specific unique rotating ID for uniquely identifying the device.
|
|
398
436
|
*/
|
|
437
|
+
@field(string, nonvolatile)
|
|
399
438
|
rotatingIdentifier?: string;
|
|
400
439
|
|
|
401
440
|
/**
|
|
402
441
|
* A bitmap indicating how to transition the device to commissioning mode from its current state.
|
|
403
442
|
*/
|
|
443
|
+
@field(uint32, nonvolatile)
|
|
404
444
|
pairingHint?: number;
|
|
405
445
|
|
|
406
446
|
/**
|
|
407
447
|
* Textual pairing instructions associated with pairing hint.
|
|
408
448
|
*/
|
|
449
|
+
@field(string, nonvolatile)
|
|
409
450
|
pairingInstructions?: string;
|
|
410
451
|
|
|
411
452
|
/**
|
|
412
|
-
* The remote node's session
|
|
453
|
+
* The remote node's session intervals.
|
|
413
454
|
*/
|
|
414
|
-
|
|
455
|
+
@field(SessionIntervals, nonvolatile)
|
|
456
|
+
sessionIntervals?: Partial<ProtocolSessionIntervals>;
|
|
415
457
|
|
|
416
458
|
/**
|
|
417
459
|
* TCP support bitmap.
|
|
418
460
|
*/
|
|
461
|
+
@field(uint8, nonvolatile)
|
|
419
462
|
tcpSupport?: number;
|
|
420
463
|
|
|
421
464
|
/**
|
|
422
465
|
* Indicates whether node is ICD with a slow (15 s+) polling interval.
|
|
423
466
|
*/
|
|
467
|
+
@field(bool, nonvolatile)
|
|
424
468
|
longIdleTimeOperatingMode?: boolean;
|
|
425
469
|
}
|
|
426
470
|
|
|
427
471
|
export class Events extends BaseEvents {
|
|
428
|
-
peerAddress$Changed = new Observable<
|
|
472
|
+
peerAddress$Changed = new Observable<
|
|
473
|
+
[value: ProtocolPeerAddress | undefined, oldValue: ProtocolPeerAddress | undefined]
|
|
474
|
+
>();
|
|
429
475
|
}
|
|
430
476
|
|
|
431
477
|
/**
|