@matter/node 0.11.9 → 0.12.0-alpha.0-20241211-6d80d8b5c
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/internal/BehaviorBacking.d.ts +6 -1
- package/dist/cjs/behavior/internal/BehaviorBacking.d.ts.map +1 -1
- package/dist/cjs/behavior/internal/BehaviorBacking.js +2 -1
- package/dist/cjs/behavior/internal/BehaviorBacking.js.map +1 -1
- package/dist/cjs/behavior/internal/ClientBehaviorBacking.d.ts +2 -1
- package/dist/cjs/behavior/internal/ClientBehaviorBacking.d.ts.map +1 -1
- package/dist/cjs/behavior/internal/ClientBehaviorBacking.js +4 -0
- package/dist/cjs/behavior/internal/ClientBehaviorBacking.js.map +1 -1
- package/dist/cjs/behavior/internal/ServerBehaviorBacking.d.ts +2 -0
- package/dist/cjs/behavior/internal/ServerBehaviorBacking.d.ts.map +1 -1
- package/dist/cjs/behavior/internal/ServerBehaviorBacking.js +37 -0
- package/dist/cjs/behavior/internal/ServerBehaviorBacking.js.map +1 -1
- package/dist/cjs/behavior/state/transaction/Transaction.d.ts +18 -18
- package/dist/cjs/behavior/system/events/EventsBehavior.d.ts +26 -0
- package/dist/cjs/behavior/system/events/EventsBehavior.d.ts.map +1 -0
- package/dist/cjs/behavior/system/events/EventsBehavior.js +74 -0
- package/dist/cjs/behavior/system/events/EventsBehavior.js.map +6 -0
- package/dist/cjs/behavior/system/events/index.d.ts +7 -0
- package/dist/cjs/behavior/system/events/index.d.ts.map +1 -0
- package/dist/cjs/behavior/system/events/index.js +24 -0
- package/dist/cjs/behavior/system/events/index.js.map +6 -0
- package/dist/cjs/behavior/system/network/ServerNetworkRuntime.d.ts.map +1 -1
- package/dist/cjs/behavior/system/network/ServerNetworkRuntime.js +3 -0
- package/dist/cjs/behavior/system/network/ServerNetworkRuntime.js.map +1 -1
- package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.d.ts +8 -0
- package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.js +12 -4
- package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.js.map +1 -1
- package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts +2 -4
- package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts.map +1 -1
- package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.js +6 -8
- package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.js.map +1 -1
- package/dist/cjs/endpoint/Agent.d.ts +1 -1
- package/dist/cjs/endpoint/Agent.js +1 -1
- package/dist/cjs/endpoint/index.d.ts +1 -1
- package/dist/cjs/endpoint/index.d.ts.map +1 -1
- package/dist/cjs/endpoint/index.js +1 -1
- package/dist/cjs/endpoint/index.js.map +1 -1
- package/dist/cjs/endpoint/properties/Behaviors.d.ts +13 -0
- package/dist/cjs/endpoint/properties/Behaviors.d.ts.map +1 -1
- package/dist/cjs/endpoint/properties/Behaviors.js +37 -24
- package/dist/cjs/endpoint/properties/Behaviors.js.map +2 -2
- package/dist/cjs/endpoint/properties/EndpointInitializer.d.ts +8 -3
- package/dist/cjs/endpoint/properties/EndpointInitializer.d.ts.map +1 -1
- package/dist/cjs/endpoint/properties/EndpointInitializer.js +5 -0
- package/dist/cjs/endpoint/properties/EndpointInitializer.js.map +1 -1
- package/dist/cjs/endpoint/server/BehaviorServer.d.ts +21 -0
- package/dist/cjs/endpoint/server/BehaviorServer.d.ts.map +1 -0
- package/dist/cjs/endpoint/server/BehaviorServer.js +272 -0
- package/dist/cjs/endpoint/server/BehaviorServer.js.map +6 -0
- package/dist/{esm/endpoint → cjs/endpoint/server}/EndpointServer.d.ts +5 -6
- package/dist/cjs/endpoint/server/EndpointServer.d.ts.map +1 -0
- package/dist/cjs/endpoint/{EndpointServer.js → server/EndpointServer.js} +38 -14
- package/dist/cjs/endpoint/server/EndpointServer.js.map +6 -0
- package/dist/cjs/{node → endpoint}/server/ServerEndpointInitializer.d.ts +4 -4
- package/dist/cjs/endpoint/server/ServerEndpointInitializer.d.ts.map +1 -0
- package/dist/cjs/{node → endpoint}/server/ServerEndpointInitializer.js +7 -7
- package/dist/cjs/endpoint/server/ServerEndpointInitializer.js.map +6 -0
- package/dist/cjs/endpoint/server/index.d.ts +8 -0
- package/dist/cjs/endpoint/server/index.d.ts.map +1 -0
- package/dist/cjs/endpoint/server/index.js +25 -0
- package/dist/cjs/endpoint/server/index.js.map +6 -0
- package/dist/cjs/endpoint/type/MutableEndpoint.d.ts.map +1 -1
- package/dist/cjs/endpoint/type/MutableEndpoint.js +3 -0
- package/dist/cjs/endpoint/type/MutableEndpoint.js.map +1 -1
- package/dist/cjs/node/Node.d.ts +5 -0
- package/dist/cjs/node/Node.d.ts.map +1 -1
- package/dist/cjs/node/Node.js +17 -2
- package/dist/cjs/node/Node.js.map +1 -1
- package/dist/cjs/node/NodeLifecycle.d.ts +11 -1
- package/dist/cjs/node/NodeLifecycle.d.ts.map +1 -1
- package/dist/cjs/node/NodeLifecycle.js +14 -0
- package/dist/cjs/node/NodeLifecycle.js.map +1 -1
- package/dist/cjs/node/ServerNode.d.ts +3 -2
- package/dist/cjs/node/ServerNode.d.ts.map +1 -1
- package/dist/cjs/node/ServerNode.js +9 -9
- package/dist/cjs/node/ServerNode.js.map +1 -1
- package/dist/cjs/node/server/ServerEnvironment.js +1 -1
- package/dist/cjs/node/server/ServerEnvironment.js.map +1 -1
- package/dist/cjs/node/server/TransactionalInteractionServer.d.ts +2 -2
- package/dist/cjs/node/server/TransactionalInteractionServer.d.ts.map +1 -1
- package/dist/cjs/node/server/TransactionalInteractionServer.js +9 -4
- package/dist/cjs/node/server/TransactionalInteractionServer.js.map +2 -2
- package/dist/cjs/node/server/index.d.ts +0 -1
- package/dist/cjs/node/server/index.d.ts.map +1 -1
- package/dist/cjs/node/server/index.js +0 -1
- package/dist/cjs/node/server/index.js.map +1 -1
- package/dist/esm/behavior/internal/BehaviorBacking.d.ts +6 -1
- package/dist/esm/behavior/internal/BehaviorBacking.d.ts.map +1 -1
- package/dist/esm/behavior/internal/BehaviorBacking.js +2 -1
- package/dist/esm/behavior/internal/BehaviorBacking.js.map +1 -1
- package/dist/esm/behavior/internal/ClientBehaviorBacking.d.ts +2 -1
- package/dist/esm/behavior/internal/ClientBehaviorBacking.d.ts.map +1 -1
- package/dist/esm/behavior/internal/ClientBehaviorBacking.js +4 -0
- package/dist/esm/behavior/internal/ClientBehaviorBacking.js.map +1 -1
- package/dist/esm/behavior/internal/ServerBehaviorBacking.d.ts +2 -0
- package/dist/esm/behavior/internal/ServerBehaviorBacking.d.ts.map +1 -1
- package/dist/esm/behavior/internal/ServerBehaviorBacking.js +37 -0
- package/dist/esm/behavior/internal/ServerBehaviorBacking.js.map +1 -1
- package/dist/esm/behavior/state/transaction/Transaction.d.ts +18 -18
- package/dist/esm/behavior/system/events/EventsBehavior.d.ts +26 -0
- package/dist/esm/behavior/system/events/EventsBehavior.d.ts.map +1 -0
- package/dist/esm/behavior/system/events/EventsBehavior.js +54 -0
- package/dist/esm/behavior/system/events/EventsBehavior.js.map +6 -0
- package/dist/esm/behavior/system/events/index.d.ts +7 -0
- package/dist/esm/behavior/system/events/index.d.ts.map +1 -0
- package/dist/esm/behavior/system/events/index.js +7 -0
- package/dist/esm/behavior/system/events/index.js.map +6 -0
- package/dist/esm/behavior/system/network/ServerNetworkRuntime.d.ts.map +1 -1
- package/dist/esm/behavior/system/network/ServerNetworkRuntime.js +3 -0
- package/dist/esm/behavior/system/network/ServerNetworkRuntime.js.map +1 -1
- package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.d.ts +8 -0
- package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.d.ts.map +1 -1
- package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.js +12 -4
- package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.js.map +1 -1
- package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts +2 -4
- package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts.map +1 -1
- package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.js +6 -8
- package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.js.map +1 -1
- package/dist/esm/endpoint/Agent.d.ts +1 -1
- package/dist/esm/endpoint/Agent.js +1 -1
- package/dist/esm/endpoint/index.d.ts +1 -1
- package/dist/esm/endpoint/index.d.ts.map +1 -1
- package/dist/esm/endpoint/index.js +1 -1
- package/dist/esm/endpoint/properties/Behaviors.d.ts +13 -0
- package/dist/esm/endpoint/properties/Behaviors.d.ts.map +1 -1
- package/dist/esm/endpoint/properties/Behaviors.js +38 -27
- package/dist/esm/endpoint/properties/Behaviors.js.map +2 -2
- package/dist/esm/endpoint/properties/EndpointInitializer.d.ts +8 -3
- package/dist/esm/endpoint/properties/EndpointInitializer.d.ts.map +1 -1
- package/dist/esm/endpoint/properties/EndpointInitializer.js +5 -0
- package/dist/esm/endpoint/properties/EndpointInitializer.js.map +1 -1
- package/dist/esm/endpoint/server/BehaviorServer.d.ts +21 -0
- package/dist/esm/endpoint/server/BehaviorServer.d.ts.map +1 -0
- package/dist/esm/endpoint/server/BehaviorServer.js +269 -0
- package/dist/esm/endpoint/server/BehaviorServer.js.map +6 -0
- package/dist/{cjs/endpoint → esm/endpoint/server}/EndpointServer.d.ts +5 -6
- package/dist/esm/endpoint/server/EndpointServer.d.ts.map +1 -0
- package/dist/esm/endpoint/{EndpointServer.js → server/EndpointServer.js} +38 -14
- package/dist/esm/endpoint/server/EndpointServer.js.map +6 -0
- package/dist/esm/{node → endpoint}/server/ServerEndpointInitializer.d.ts +4 -4
- package/dist/esm/endpoint/server/ServerEndpointInitializer.d.ts.map +1 -0
- package/dist/esm/{node → endpoint}/server/ServerEndpointInitializer.js +7 -7
- package/dist/esm/endpoint/server/ServerEndpointInitializer.js.map +6 -0
- package/dist/esm/endpoint/server/index.d.ts +8 -0
- package/dist/esm/endpoint/server/index.d.ts.map +1 -0
- package/dist/esm/endpoint/server/index.js +8 -0
- package/dist/esm/endpoint/server/index.js.map +6 -0
- package/dist/esm/endpoint/type/MutableEndpoint.d.ts.map +1 -1
- package/dist/esm/endpoint/type/MutableEndpoint.js +3 -0
- package/dist/esm/endpoint/type/MutableEndpoint.js.map +1 -1
- package/dist/esm/node/Node.d.ts +5 -0
- package/dist/esm/node/Node.d.ts.map +1 -1
- package/dist/esm/node/Node.js +17 -2
- package/dist/esm/node/Node.js.map +1 -1
- package/dist/esm/node/NodeLifecycle.d.ts +11 -1
- package/dist/esm/node/NodeLifecycle.d.ts.map +1 -1
- package/dist/esm/node/NodeLifecycle.js +15 -1
- package/dist/esm/node/NodeLifecycle.js.map +1 -1
- package/dist/esm/node/ServerNode.d.ts +3 -2
- package/dist/esm/node/ServerNode.d.ts.map +1 -1
- package/dist/esm/node/ServerNode.js +10 -10
- package/dist/esm/node/ServerNode.js.map +1 -1
- package/dist/esm/node/server/ServerEnvironment.js +1 -1
- package/dist/esm/node/server/ServerEnvironment.js.map +1 -1
- package/dist/esm/node/server/TransactionalInteractionServer.d.ts +2 -2
- package/dist/esm/node/server/TransactionalInteractionServer.d.ts.map +1 -1
- package/dist/esm/node/server/TransactionalInteractionServer.js +9 -4
- package/dist/esm/node/server/TransactionalInteractionServer.js.map +2 -2
- package/dist/esm/node/server/index.d.ts +0 -1
- package/dist/esm/node/server/index.d.ts.map +1 -1
- package/dist/esm/node/server/index.js +0 -1
- package/dist/esm/node/server/index.js.map +1 -1
- package/package.json +7 -7
- package/src/behavior/internal/BehaviorBacking.ts +9 -1
- package/src/behavior/internal/ClientBehaviorBacking.ts +6 -1
- package/src/behavior/internal/ServerBehaviorBacking.ts +51 -0
- package/src/behavior/system/events/EventsBehavior.ts +60 -0
- package/src/behavior/system/events/index.ts +7 -0
- package/src/behavior/system/network/ServerNetworkRuntime.ts +6 -0
- package/src/behaviors/administrator-commissioning/AdministratorCommissioningServer.ts +14 -4
- package/src/behaviors/general-diagnostics/GeneralDiagnosticsServer.ts +16 -9
- package/src/endpoint/Agent.ts +1 -1
- package/src/endpoint/index.ts +1 -1
- package/src/endpoint/properties/Behaviors.ts +56 -28
- package/src/endpoint/properties/EndpointInitializer.ts +9 -3
- package/src/endpoint/server/BehaviorServer.ts +387 -0
- package/src/endpoint/{EndpointServer.ts → server/EndpointServer.ts} +50 -20
- package/src/{node → endpoint}/server/ServerEndpointInitializer.ts +7 -7
- package/src/endpoint/server/index.ts +8 -0
- package/src/endpoint/type/MutableEndpoint.ts +4 -0
- package/src/node/Node.ts +22 -4
- package/src/node/NodeLifecycle.ts +17 -1
- package/src/node/ServerNode.ts +11 -13
- package/src/node/server/ServerEnvironment.ts +1 -1
- package/src/node/server/TransactionalInteractionServer.ts +13 -7
- package/src/node/server/index.ts +0 -1
- package/dist/cjs/behavior/internal/ClusterServerBacking.d.ts +0 -36
- package/dist/cjs/behavior/internal/ClusterServerBacking.d.ts.map +0 -1
- package/dist/cjs/behavior/internal/ClusterServerBacking.js +0 -342
- package/dist/cjs/behavior/internal/ClusterServerBacking.js.map +0 -6
- package/dist/cjs/endpoint/EndpointServer.d.ts.map +0 -1
- package/dist/cjs/endpoint/EndpointServer.js.map +0 -6
- package/dist/cjs/node/server/ServerEndpointInitializer.d.ts.map +0 -1
- package/dist/cjs/node/server/ServerEndpointInitializer.js.map +0 -6
- package/dist/esm/behavior/internal/ClusterServerBacking.d.ts +0 -36
- package/dist/esm/behavior/internal/ClusterServerBacking.d.ts.map +0 -1
- package/dist/esm/behavior/internal/ClusterServerBacking.js +0 -330
- package/dist/esm/behavior/internal/ClusterServerBacking.js.map +0 -6
- package/dist/esm/endpoint/EndpointServer.d.ts.map +0 -1
- package/dist/esm/endpoint/EndpointServer.js.map +0 -6
- package/dist/esm/node/server/ServerEndpointInitializer.d.ts.map +0 -1
- package/dist/esm/node/server/ServerEndpointInitializer.js.map +0 -6
- package/src/behavior/internal/ClusterServerBacking.ts +0 -446
|
@@ -53,8 +53,8 @@ import { NodeActivity } from "#behavior/context/NodeActivity.js";
|
|
|
53
53
|
import { OfflineContext } from "#behavior/context/server/OfflineContext.js";
|
|
54
54
|
import { OnlineContext } from "#behavior/context/server/OnlineContext.js";
|
|
55
55
|
import { AccessControlCluster } from "#clusters/access-control";
|
|
56
|
-
import { EndpointServer } from "#endpoint/EndpointServer.js";
|
|
57
56
|
import { EndpointLifecycle } from "#endpoint/properties/EndpointLifecycle.js";
|
|
57
|
+
import { EndpointServer } from "#endpoint/server/EndpointServer.js";
|
|
58
58
|
import { Diagnostic, InternalError, Logger, MaybePromise } from "#general";
|
|
59
59
|
import {
|
|
60
60
|
AccessDeniedError,
|
|
@@ -93,11 +93,14 @@ class TransactionalInteractionServer extends InteractionServer {
|
|
|
93
93
|
this.#endpoint = endpoint;
|
|
94
94
|
this.#endpointStructure = structure;
|
|
95
95
|
this.#updateStructure();
|
|
96
|
-
this.#changeListener = (type) => {
|
|
96
|
+
this.#changeListener = (type, endpoint2) => {
|
|
97
97
|
switch (type) {
|
|
98
|
+
case EndpointLifecycle.Change.ServersChanged:
|
|
99
|
+
EndpointServer.forEndpoint(endpoint2).updateServers();
|
|
100
|
+
this.#updateStructure();
|
|
101
|
+
break;
|
|
98
102
|
case EndpointLifecycle.Change.PartsReady:
|
|
99
103
|
case EndpointLifecycle.Change.ClientsChanged:
|
|
100
|
-
case EndpointLifecycle.Change.ServersChanged:
|
|
101
104
|
case EndpointLifecycle.Change.Destroyed:
|
|
102
105
|
this.#updateStructure();
|
|
103
106
|
break;
|
|
@@ -109,6 +112,7 @@ class TransactionalInteractionServer extends InteractionServer {
|
|
|
109
112
|
this.#endpoint.lifecycle.changed.off(this.#changeListener);
|
|
110
113
|
await this.close();
|
|
111
114
|
this.#endpointStructure.close();
|
|
115
|
+
await EndpointServer.forEndpoint(this.#endpoint)[Symbol.asyncDispose]();
|
|
112
116
|
}
|
|
113
117
|
blockNewActivity() {
|
|
114
118
|
this.#newActivityBlocked = true;
|
|
@@ -254,7 +258,8 @@ class TransactionalInteractionServer extends InteractionServer {
|
|
|
254
258
|
}
|
|
255
259
|
#updateStructure() {
|
|
256
260
|
if (this.#endpoint.lifecycle.isPartsReady) {
|
|
257
|
-
|
|
261
|
+
const server = EndpointServer.forEndpoint(this.#endpoint);
|
|
262
|
+
this.#endpointStructure.initializeFromEndpoint(server);
|
|
258
263
|
}
|
|
259
264
|
}
|
|
260
265
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/node/server/TransactionalInteractionServer.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AAErC,SAAS,sBAAsB;AAC/B,SAAS,
|
|
5
|
-
"names": []
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AAErC,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAC/B,SAAS,YAAY,eAAe,QAAQ,oBAAoB;AAChE;AAAA,EACI;AAAA,EASA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OAOG;AAEP,SAAS,2BAA2B;AAGpC,MAAM,SAAS,OAAO,IAAI,gCAAgC;AAE1D,MAAM,cAAc,OAAO,UAAU;AAMrC,MAAM,eAAe,qBAAqB;AAC1C,MAAM,iBAAiB,qBAAqB,W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A,MACpC;AAAA,MACA,MAAM,KAAK;AAAA,IACf,CAAC,EAAE,IAAI,aAAa;AAAA,EACxB;AAAA,EAEA,IAAI,UAAU;AACV,QAAI,KAAK,UAAU,IAAI,IAAI,YAAY,GAAG;AACtC,aAAO,KAAK,UAAU,IAAI,IAAI,YAAY;AAAA,IAC9C;AAAA,EACJ;AAAA,EAEA,mBAAmB;AACf,QAAI,KAAK,UAAU,UAAU,cAAc;AACvC,YAAM,SAAS,eAAe,YAAY,KAAK,SAAS;AACxD,WAAK,mBAAmB,uBAAuB,MAAM;AAAA,IACzD;AAAA,EACJ;AACJ;",
|
|
5
|
+
"names": ["endpoint"]
|
|
6
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/node/server/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/node/server/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,qCAAqC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matter/node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0-alpha.0-20241211-6d80d8b5c",
|
|
4
4
|
"description": "API for building Matter nodes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"iot",
|
|
@@ -43,14 +43,14 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@noble/curves": "^1.7.0",
|
|
46
|
-
"@matter/general": "0.
|
|
47
|
-
"@matter/model": "0.
|
|
48
|
-
"@matter/types": "0.
|
|
49
|
-
"@matter/protocol": "0.
|
|
46
|
+
"@matter/general": "0.12.0-alpha.0-20241211-6d80d8b5c",
|
|
47
|
+
"@matter/model": "0.12.0-alpha.0-20241211-6d80d8b5c",
|
|
48
|
+
"@matter/types": "0.12.0-alpha.0-20241211-6d80d8b5c",
|
|
49
|
+
"@matter/protocol": "0.12.0-alpha.0-20241211-6d80d8b5c"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@matter/tools": "0.
|
|
53
|
-
"@matter/testing": "0.
|
|
52
|
+
"@matter/tools": "0.12.0-alpha.0-20241211-6d80d8b5c",
|
|
53
|
+
"@matter/testing": "0.12.0-alpha.0-20241211-6d80d8b5c"
|
|
54
54
|
},
|
|
55
55
|
"files": [
|
|
56
56
|
"dist/**/*",
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import type { Agent } from "#endpoint/Agent.js";
|
|
8
8
|
import type { Endpoint } from "#endpoint/Endpoint.js";
|
|
9
9
|
import { BehaviorInitializationError } from "#endpoint/errors.js";
|
|
10
|
+
import type { SupportedElements } from "#endpoint/properties/Behaviors.js";
|
|
10
11
|
import { Construction, EventEmitter, ImplementationError, Lifecycle, Logger, MaybePromise, Observable } from "#general";
|
|
12
|
+
import type { ClusterId } from "@matter/types";
|
|
11
13
|
import type { Behavior } from "../Behavior.js";
|
|
12
14
|
import { Reactor } from "../Reactor.js";
|
|
13
15
|
import { Datasource } from "../state/managed/Datasource.js";
|
|
@@ -166,6 +168,7 @@ export abstract class BehaviorBacking {
|
|
|
166
168
|
defaults: this.#endpoint.behaviors.defaultsFor(this.type),
|
|
167
169
|
store: this.store,
|
|
168
170
|
owner: this.#endpoint,
|
|
171
|
+
cluster: this.type.schema?.tag === "cluster" ? (this.type.schema.id as ClusterId) : undefined,
|
|
169
172
|
};
|
|
170
173
|
}
|
|
171
174
|
|
|
@@ -209,6 +212,11 @@ export abstract class BehaviorBacking {
|
|
|
209
212
|
return this.#datasource?.view ?? {};
|
|
210
213
|
}
|
|
211
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Supported elements.
|
|
217
|
+
*/
|
|
218
|
+
abstract readonly elements: SupportedElements | undefined;
|
|
219
|
+
|
|
212
220
|
/**
|
|
213
221
|
* Install a reactor.
|
|
214
222
|
*/
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
import { Behavior } from "#behavior/Behavior.js";
|
|
8
8
|
import { Datasource } from "#behavior/state/managed/Datasource.js";
|
|
9
9
|
import { Endpoint } from "#endpoint/Endpoint.js";
|
|
10
|
-
import { EndpointStore } from "#endpoint/index.js";
|
|
10
|
+
import { EndpointStore, SupportedElements } from "#endpoint/index.js";
|
|
11
|
+
import { NotImplementedError } from "@matter/general";
|
|
11
12
|
import { BehaviorBacking } from "./BehaviorBacking.js";
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -21,4 +22,8 @@ export class ClientBehaviorBacking extends BehaviorBacking {
|
|
|
21
22
|
|
|
22
23
|
this.store = endpointStore.storeForBehavior(behavior.id);
|
|
23
24
|
}
|
|
25
|
+
|
|
26
|
+
get elements(): SupportedElements | undefined {
|
|
27
|
+
throw new NotImplementedError();
|
|
28
|
+
}
|
|
24
29
|
}
|
|
@@ -4,19 +4,27 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { ClusterBehavior } from "#behavior/cluster/ClusterBehavior.js";
|
|
8
|
+
import { GlobalAttributeState } from "#behavior/cluster/ClusterState.js";
|
|
9
|
+
import { ValidatedElements } from "#behavior/cluster/ValidatedElements.js";
|
|
10
|
+
import type { SupportedElements } from "#endpoint/index.js";
|
|
7
11
|
import { camelize } from "#general";
|
|
8
12
|
import { FieldValue } from "#model";
|
|
9
13
|
import { ServerNodeStore } from "#node/storage/ServerNodeStore.js";
|
|
14
|
+
import { ClusterType, TlvNoResponse } from "#types";
|
|
10
15
|
import { Behavior } from "../Behavior.js";
|
|
11
16
|
import { Val } from "../state/Val.js";
|
|
12
17
|
import { Datasource } from "../state/managed/Datasource.js";
|
|
13
18
|
import { BehaviorBacking } from "./BehaviorBacking.js";
|
|
14
19
|
|
|
20
|
+
const NoElements = new Set<string>();
|
|
21
|
+
|
|
15
22
|
/**
|
|
16
23
|
* This class backs the server implementation of a behavior.
|
|
17
24
|
*/
|
|
18
25
|
export class ServerBehaviorBacking extends BehaviorBacking {
|
|
19
26
|
#store?: Datasource.Store;
|
|
27
|
+
#elements?: SupportedElements;
|
|
20
28
|
|
|
21
29
|
override get store() {
|
|
22
30
|
if (!this.#store) {
|
|
@@ -27,10 +35,24 @@ export class ServerBehaviorBacking extends BehaviorBacking {
|
|
|
27
35
|
return this.#store;
|
|
28
36
|
}
|
|
29
37
|
|
|
38
|
+
get elements() {
|
|
39
|
+
return this.#elements;
|
|
40
|
+
}
|
|
41
|
+
|
|
30
42
|
protected override invokeInitializer(behavior: Behavior, options?: Behavior.Options) {
|
|
31
43
|
const finalizeState = () => {
|
|
32
44
|
this.#applyTransitiveDefaults(behavior.state);
|
|
33
45
|
|
|
46
|
+
if (behavior instanceof ClusterBehavior) {
|
|
47
|
+
this.#configureElements(behavior);
|
|
48
|
+
} else {
|
|
49
|
+
this.#elements = {
|
|
50
|
+
attributes: NoElements,
|
|
51
|
+
commands: NoElements,
|
|
52
|
+
events: NoElements,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
34
56
|
// State must now conform to the schema. Validate the behavior's state rather than internal state
|
|
35
57
|
// because the behavior likely has uncommitted changes
|
|
36
58
|
const context = behavior.context;
|
|
@@ -72,4 +94,33 @@ export class ServerBehaviorBacking extends BehaviorBacking {
|
|
|
72
94
|
}
|
|
73
95
|
}
|
|
74
96
|
}
|
|
97
|
+
|
|
98
|
+
#configureElements(behavior: ClusterBehavior) {
|
|
99
|
+
// Validate
|
|
100
|
+
const validation = new ValidatedElements(behavior.constructor as ClusterBehavior.Type, behavior);
|
|
101
|
+
validation.report();
|
|
102
|
+
|
|
103
|
+
const globals = behavior.state as GlobalAttributeState;
|
|
104
|
+
|
|
105
|
+
// Update attribute list
|
|
106
|
+
const attributeDefs = behavior.cluster.attributes as ClusterType.ElementSet<ClusterType.Attribute>;
|
|
107
|
+
globals.attributeList = [...validation.attributes].map(name => attributeDefs[name].id);
|
|
108
|
+
|
|
109
|
+
// Update accepted & generated command lists
|
|
110
|
+
const commandDefs = behavior.cluster.commands as ClusterType.ElementSet<ClusterType.Command>;
|
|
111
|
+
const commands = [...validation.commands].map(name => commandDefs[name]);
|
|
112
|
+
globals.acceptedCommandList = commands.map(command => command.requestId);
|
|
113
|
+
globals.generatedCommandList = [
|
|
114
|
+
...new Set(
|
|
115
|
+
commands.filter(command => command.responseSchema !== TlvNoResponse).map(command => command.responseId),
|
|
116
|
+
),
|
|
117
|
+
];
|
|
118
|
+
|
|
119
|
+
// Load public API
|
|
120
|
+
this.#elements = {
|
|
121
|
+
attributes: validation.attributes,
|
|
122
|
+
commands: validation.commands,
|
|
123
|
+
events: validation.events,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
75
126
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2024 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { deepCopy, StorageManager } from "#general";
|
|
8
|
+
import { DatatypeModel, FieldElement } from "#model";
|
|
9
|
+
import { NonvolatileEventStore, OccurrenceManager, VolatileEventStore } from "#protocol";
|
|
10
|
+
import { Behavior } from "../../Behavior.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Event handling configuration.
|
|
14
|
+
*/
|
|
15
|
+
export class EventsBehavior extends Behavior {
|
|
16
|
+
static override readonly id = "events";
|
|
17
|
+
static override early = true;
|
|
18
|
+
|
|
19
|
+
declare state: EventsBehavior.State;
|
|
20
|
+
|
|
21
|
+
override initialize() {
|
|
22
|
+
const storage = this.env.get(StorageManager).createContext("events");
|
|
23
|
+
let store;
|
|
24
|
+
if (this.state.nonvolatile) {
|
|
25
|
+
store = new NonvolatileEventStore(storage);
|
|
26
|
+
} else {
|
|
27
|
+
store = new VolatileEventStore(storage, this.state.numberBlockSize);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
this.env.set(OccurrenceManager, new OccurrenceManager({ store, bufferConfig: this.state.buffers }));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static override schema = new DatatypeModel(
|
|
34
|
+
{
|
|
35
|
+
name: "EventsState",
|
|
36
|
+
type: "struct",
|
|
37
|
+
},
|
|
38
|
+
FieldElement({ name: "nonvolatile", type: "bool" }),
|
|
39
|
+
FieldElement({ name: "numberBlockSize", type: "uint16" }),
|
|
40
|
+
FieldElement(
|
|
41
|
+
{ name: "buffer", type: "struct" },
|
|
42
|
+
FieldElement({ name: "minEventAllowance", type: "uint32" }),
|
|
43
|
+
FieldElement({ name: "maxEventAllowance", type: "uint32" }),
|
|
44
|
+
FieldElement(
|
|
45
|
+
{ name: "minPriorityEventAllowance", type: "struct" },
|
|
46
|
+
FieldElement({ name: "critical", type: "uint32" }),
|
|
47
|
+
FieldElement({ name: "info", type: "uint32" }),
|
|
48
|
+
FieldElement({ name: "debug", type: "uint32" }),
|
|
49
|
+
),
|
|
50
|
+
),
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export namespace EventsBehavior {
|
|
55
|
+
export class State {
|
|
56
|
+
nonvolatile = false;
|
|
57
|
+
numberBlockSize = 1_000;
|
|
58
|
+
buffers = deepCopy(OccurrenceManager.DefaultBufferConfig);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -310,6 +310,8 @@ export class ServerNetworkRuntime extends NetworkRuntime {
|
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
protected override async stop() {
|
|
313
|
+
this.blockNewActivity();
|
|
314
|
+
|
|
313
315
|
this.#observers.close();
|
|
314
316
|
|
|
315
317
|
await this.owner.env.close(DeviceCommissioner);
|
|
@@ -320,6 +322,10 @@ export class ServerNetworkRuntime extends NetworkRuntime {
|
|
|
320
322
|
|
|
321
323
|
await this.#interactionServer?.[Symbol.asyncDispose]();
|
|
322
324
|
this.#interactionServer = undefined;
|
|
325
|
+
|
|
326
|
+
// DeviceAdvertiser does this but we do so here just in case DeviceAdvertiser did not initialize for some reason
|
|
327
|
+
await this.#mdnsBroadcaster?.close();
|
|
328
|
+
this.#mdnsBroadcaster = undefined;
|
|
323
329
|
}
|
|
324
330
|
|
|
325
331
|
protected override blockNewActivity() {
|
|
@@ -201,16 +201,16 @@ export class AdministratorCommissioningServer extends AdministratorCommissioning
|
|
|
201
201
|
);
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
if (commissioningTimeout >
|
|
204
|
+
if (commissioningTimeout > this.internal.maximumCommissioningTimeoutS) {
|
|
205
205
|
throw new StatusResponseError(
|
|
206
|
-
`Commissioning timeout must not exceed ${
|
|
206
|
+
`Commissioning timeout must not exceed ${this.internal.maximumCommissioningTimeoutS} seconds.`,
|
|
207
207
|
StatusCode.InvalidCommand,
|
|
208
208
|
);
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
if (commissioningTimeout <
|
|
211
|
+
if (commissioningTimeout < this.internal.minimumCommissioningTimeoutS) {
|
|
212
212
|
throw new StatusResponseError(
|
|
213
|
-
`Commissioning timeout must not be lower then ${
|
|
213
|
+
`Commissioning timeout must not be lower then ${this.internal.minimumCommissioningTimeoutS} seconds.`,
|
|
214
214
|
StatusCode.InvalidCommand,
|
|
215
215
|
);
|
|
216
216
|
}
|
|
@@ -279,6 +279,16 @@ export namespace AdministratorCommissioningServer {
|
|
|
279
279
|
export class Internal {
|
|
280
280
|
commissioningWindowTimeout?: Timer;
|
|
281
281
|
stopMonitoringFabricForRemoval?: () => void;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Mandated by spec; should only be modified in testing.
|
|
285
|
+
*/
|
|
286
|
+
minimumCommissioningTimeoutS = MINIMUM_COMMISSIONING_TIMEOUT_S;
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Mandated by spec; should only be modified in testing.
|
|
290
|
+
*/
|
|
291
|
+
maximumCommissioningTimeoutS = MAXIMUM_COMMISSIONING_TIMEOUT_S;
|
|
282
292
|
}
|
|
283
293
|
|
|
284
294
|
export class State extends AdministratorCommissioningBehavior.State {
|
|
@@ -8,6 +8,7 @@ import { Val } from "#behavior/state/Val.js";
|
|
|
8
8
|
import { ValueSupervisor } from "#behavior/supervision/ValueSupervisor.js";
|
|
9
9
|
import { NetworkServer } from "#behavior/system/network/NetworkServer.js";
|
|
10
10
|
import { NetworkCommissioningServer } from "#behaviors/network-commissioning";
|
|
11
|
+
import { TimeSynchronizationBehavior } from "#behaviors/time-synchronization";
|
|
11
12
|
import { GeneralDiagnostics } from "#clusters/general-diagnostics";
|
|
12
13
|
import { Endpoint } from "#endpoint/Endpoint.js";
|
|
13
14
|
import { Bytes, ImplementationError, ipv4ToBytes, Logger, Time, Timer } from "#general";
|
|
@@ -102,9 +103,20 @@ export class GeneralDiagnosticsServer extends Base {
|
|
|
102
103
|
|
|
103
104
|
override timeSnapshot() {
|
|
104
105
|
const time = Time.nowMs();
|
|
106
|
+
|
|
107
|
+
// TC_DGGEN_2_4.py fails us if we set this without TimeSynchronizationCluster support. Spec is worded poorly
|
|
108
|
+
// but my read of "SHALL only if" is "may not unless" and not "SHALL if and only if". But conforming to tests
|
|
109
|
+
// for now
|
|
110
|
+
const posixTimeMs =
|
|
111
|
+
this.agent.has(TimeSynchronizationBehavior) &&
|
|
112
|
+
this.agent.get(TimeSynchronizationBehavior).state.utcTime !== null
|
|
113
|
+
? time
|
|
114
|
+
: null;
|
|
115
|
+
|
|
105
116
|
return {
|
|
106
|
-
systemTimeMs: time -
|
|
107
|
-
|
|
117
|
+
systemTimeMs: time - Time.startup.systemMs,
|
|
118
|
+
|
|
119
|
+
posixTimeMs,
|
|
108
120
|
};
|
|
109
121
|
}
|
|
110
122
|
|
|
@@ -280,7 +292,6 @@ export class GeneralDiagnosticsServer extends Base {
|
|
|
280
292
|
);
|
|
281
293
|
|
|
282
294
|
// Update the timestamps now that node is really online.
|
|
283
|
-
this.internal.bootUpTime = Time.nowMs();
|
|
284
295
|
this.internal.lastTotalOperationalHoursCounterUpdateTime = Time.nowMs();
|
|
285
296
|
|
|
286
297
|
this.internal.lastTotalOperationalHoursTimer = Time.getPeriodicTimer(
|
|
@@ -368,9 +379,6 @@ export class GeneralDiagnosticsServer extends Base {
|
|
|
368
379
|
|
|
369
380
|
export namespace GeneralDiagnosticsServer {
|
|
370
381
|
export class Internal {
|
|
371
|
-
/** Remember the bootUp time for the device. */
|
|
372
|
-
bootUpTime: number = Time.nowMs();
|
|
373
|
-
|
|
374
382
|
/** Last time the total operational hours counter was updated. */
|
|
375
383
|
lastTotalOperationalHoursCounterUpdateTime: number = Time.nowMs();
|
|
376
384
|
|
|
@@ -388,12 +396,11 @@ export namespace GeneralDiagnosticsServer {
|
|
|
388
396
|
[Val.properties](endpoint: Endpoint, _session: ValueSupervisor.Session) {
|
|
389
397
|
return {
|
|
390
398
|
/**
|
|
391
|
-
* Dynamically calculate the upTime. This is ok because the attribute is not
|
|
399
|
+
* Dynamically calculate the upTime. This is ok because the attribute is not sent via subscriptions
|
|
392
400
|
* anyway.
|
|
393
401
|
*/
|
|
394
402
|
get upTime() {
|
|
395
|
-
|
|
396
|
-
return Math.round((Time.nowMs() - bootUpTime) / 1000);
|
|
403
|
+
return Math.round((Time.nowMs() - Time.startup.systemMs) / 1000);
|
|
397
404
|
},
|
|
398
405
|
|
|
399
406
|
/**
|
package/src/endpoint/Agent.ts
CHANGED
|
@@ -101,7 +101,7 @@ export class Agent {
|
|
|
101
101
|
/**
|
|
102
102
|
* Trigger initialization of a supported {@link Behavior.Type}.
|
|
103
103
|
*
|
|
104
|
-
* Functionally identical to {@link load} but has no return value and errors are logged
|
|
104
|
+
* Functionally identical to {@link load} but has no return value and errors are logged rather than thrown.
|
|
105
105
|
*/
|
|
106
106
|
activate(type: Behavior.Type) {
|
|
107
107
|
this.#endpoint.behaviors.activate(type, this);
|
package/src/endpoint/index.ts
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
import { Behavior } from "#behavior/Behavior.js";
|
|
8
8
|
import type { ClusterBehavior } from "#behavior/cluster/ClusterBehavior.js";
|
|
9
|
-
import { ValidatedElements } from "#behavior/cluster/ValidatedElements.js";
|
|
10
9
|
import { ActionContext } from "#behavior/context/ActionContext.js";
|
|
11
10
|
import { ActionTracer } from "#behavior/context/ActionTracer.js";
|
|
12
11
|
import { NodeActivity } from "#behavior/context/NodeActivity.js";
|
|
@@ -21,12 +20,10 @@ import {
|
|
|
21
20
|
Diagnostic,
|
|
22
21
|
EventEmitter,
|
|
23
22
|
ImplementationError,
|
|
24
|
-
InternalError,
|
|
25
23
|
Lifecycle,
|
|
26
24
|
Logger,
|
|
27
25
|
MaybePromise,
|
|
28
26
|
ReadOnlyError,
|
|
29
|
-
UninitializedDependencyError,
|
|
30
27
|
} from "#general";
|
|
31
28
|
import { FeatureSet } from "#model";
|
|
32
29
|
import { ClusterType } from "#types";
|
|
@@ -41,6 +38,12 @@ import type { SupportedBehaviors } from "./SupportedBehaviors.js";
|
|
|
41
38
|
|
|
42
39
|
const logger = Logger.get("Behaviors");
|
|
43
40
|
|
|
41
|
+
export interface SupportedElements {
|
|
42
|
+
attributes: Set<string>;
|
|
43
|
+
commands: Set<string>;
|
|
44
|
+
events: Set<string>;
|
|
45
|
+
}
|
|
46
|
+
|
|
44
47
|
/**
|
|
45
48
|
* This class manages {@link Behavior} instances owned by a {@link Endpoint}.
|
|
46
49
|
*/
|
|
@@ -80,10 +83,9 @@ export class Behaviors {
|
|
|
80
83
|
return result;
|
|
81
84
|
}
|
|
82
85
|
|
|
86
|
+
const elements = this.elementsOf(type);
|
|
83
87
|
const elementDiagnostic = Array<unknown>();
|
|
84
88
|
|
|
85
|
-
const elements = new ValidatedElements(type as ClusterBehavior.Type);
|
|
86
|
-
|
|
87
89
|
const features = new FeatureSet(cluster.supportedFeatures);
|
|
88
90
|
if (features.size) {
|
|
89
91
|
elementDiagnostic.push([Diagnostic.strong("features"), features]);
|
|
@@ -148,7 +150,7 @@ export class Behaviors {
|
|
|
148
150
|
}
|
|
149
151
|
|
|
150
152
|
// Initialization action. We initialize all behaviors in the same transaction
|
|
151
|
-
const initializeBehaviors = (context: ActionContext) => {
|
|
153
|
+
const initializeBehaviors = (context: ActionContext): MaybePromise => {
|
|
152
154
|
const agent = context.agentFor(this.#endpoint);
|
|
153
155
|
|
|
154
156
|
// Activate behaviors
|
|
@@ -161,7 +163,7 @@ export class Behaviors {
|
|
|
161
163
|
}
|
|
162
164
|
|
|
163
165
|
// Wait for all behaviors to initialize
|
|
164
|
-
|
|
166
|
+
let promise = Construction.all(
|
|
165
167
|
{
|
|
166
168
|
[Symbol.iterator]: () => {
|
|
167
169
|
return Object.values(this.#backings)[Symbol.iterator]();
|
|
@@ -170,6 +172,16 @@ export class Behaviors {
|
|
|
170
172
|
|
|
171
173
|
causes => new EndpointBehaviorsError(causes),
|
|
172
174
|
);
|
|
175
|
+
|
|
176
|
+
// Notify other components that participate in initialization
|
|
177
|
+
const endpointInitializer = this.#endpoint.env.get(EndpointInitializer);
|
|
178
|
+
if (promise) {
|
|
179
|
+
promise = promise.then(() => endpointInitializer.behaviorsInitialized(agent));
|
|
180
|
+
} else {
|
|
181
|
+
promise = endpointInitializer.behaviorsInitialized(agent);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return promise;
|
|
173
185
|
};
|
|
174
186
|
|
|
175
187
|
// Initialize instrumentation
|
|
@@ -463,17 +475,36 @@ export class Behaviors {
|
|
|
463
475
|
* does access to {@link Behavior.State} and {@link Behavior.Events}.
|
|
464
476
|
*/
|
|
465
477
|
internalsOf<T extends Behavior.Type>(type: T) {
|
|
466
|
-
|
|
467
|
-
if (!backing) {
|
|
468
|
-
this.#activateLate(type);
|
|
469
|
-
backing = this.#backings[type.id];
|
|
470
|
-
if (backing === undefined) {
|
|
471
|
-
throw new InternalError(`Behavior ${this.#endpoint}.${type.id} late activation did not create backing`);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
478
|
+
const backing = this.#backingFor(type);
|
|
474
479
|
return backing.getInternal() as InstanceType<T["Internal"]>;
|
|
475
480
|
}
|
|
476
481
|
|
|
482
|
+
/**
|
|
483
|
+
* Obtain current data version of behavior.
|
|
484
|
+
*/
|
|
485
|
+
versionOf(type: Behavior.Type) {
|
|
486
|
+
const backing = this.#backingFor(type);
|
|
487
|
+
return backing.datasource.version;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Access elements supported by a behavior.
|
|
492
|
+
*/
|
|
493
|
+
elementsOf(type: Behavior.Type): SupportedElements {
|
|
494
|
+
if (!this.has(type)) {
|
|
495
|
+
throw new ImplementationError(`Endpoint ${this.#endpoint} does not support behavior ${type.id}`);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
const elements = this.#backingFor(type).elements;
|
|
499
|
+
if (elements === undefined) {
|
|
500
|
+
throw new ImplementationError(
|
|
501
|
+
`Endpoint ${this.#endpoint} behavior ${type.id} elements accessed before initialization`,
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
return elements;
|
|
506
|
+
}
|
|
507
|
+
|
|
477
508
|
#activateLate(type: Behavior.Type) {
|
|
478
509
|
const result = OfflineContext.act("behavior-late-activation", this.#endpoint.env.get(NodeActivity), context =>
|
|
479
510
|
this.activate(type, context.agentFor(this.#endpoint)),
|
|
@@ -495,29 +526,26 @@ export class Behaviors {
|
|
|
495
526
|
}
|
|
496
527
|
|
|
497
528
|
/**
|
|
498
|
-
* Obtain a backing for
|
|
529
|
+
* Obtain a backing for a behavior.
|
|
499
530
|
*/
|
|
500
|
-
#backingFor(
|
|
531
|
+
#backingFor(type: Behavior.Type) {
|
|
532
|
+
// Crash if endpoint is not initialized
|
|
501
533
|
if (this.#endpoint.construction.status !== Lifecycle.Status.Initializing) {
|
|
502
534
|
this.#endpoint.construction.assert(this.#endpoint.toString(), `behavior ${type.id}`);
|
|
503
535
|
}
|
|
504
536
|
|
|
537
|
+
// Obtain backing
|
|
505
538
|
let backing = this.#backings[type.id];
|
|
539
|
+
|
|
540
|
+
// If backing is not already initialized, attempt late initialization
|
|
506
541
|
if (!backing) {
|
|
507
|
-
|
|
508
|
-
this.#activateLate(type);
|
|
509
|
-
} catch (e) {
|
|
510
|
-
logger.warn(`Cannot initialize ${container}.${type.id} until node is initialized: ${e}`);
|
|
511
|
-
throw new UninitializedDependencyError(
|
|
512
|
-
`${container}.${type.id}`,
|
|
513
|
-
"is not available until node is initialized, you may await node.construction to avoid this error",
|
|
514
|
-
);
|
|
515
|
-
}
|
|
542
|
+
this.#activateLate(type);
|
|
516
543
|
backing = this.#backings[type.id];
|
|
517
544
|
if (backing === undefined) {
|
|
518
|
-
throw new
|
|
545
|
+
throw new BehaviorInitializationError(`${this.#endpoint}.${type.id}`, "initialization failed");
|
|
519
546
|
}
|
|
520
547
|
}
|
|
548
|
+
|
|
521
549
|
return backing;
|
|
522
550
|
}
|
|
523
551
|
|
|
@@ -556,7 +584,7 @@ export class Behaviors {
|
|
|
556
584
|
#augmentEndpoint(type: Behavior.Type) {
|
|
557
585
|
Object.defineProperty(this.#endpoint.state, type.id, {
|
|
558
586
|
get: () => {
|
|
559
|
-
return this.#backingFor(
|
|
587
|
+
return this.#backingFor(type).stateView;
|
|
560
588
|
},
|
|
561
589
|
|
|
562
590
|
set() {
|