@matter/node 0.16.0-alpha.0-20251031-0f308af69 → 0.16.0-alpha.0-20251101-70c8d51d7

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.
Files changed (123) hide show
  1. package/dist/cjs/behavior/state/managed/Datasource.js +13 -13
  2. package/dist/cjs/behavior/state/managed/Datasource.js.map +2 -2
  3. package/dist/cjs/behavior/state/managed/values/ListManager.js +2 -2
  4. package/dist/cjs/behavior/state/managed/values/ListManager.js.map +1 -1
  5. package/dist/cjs/behavior/state/managed/values/ValuePatcher.js +10 -3
  6. package/dist/cjs/behavior/state/managed/values/ValuePatcher.js.map +1 -1
  7. package/dist/cjs/behavior/supervision/ValueSupervisor.d.ts +4 -0
  8. package/dist/cjs/behavior/supervision/ValueSupervisor.d.ts.map +1 -1
  9. package/dist/cjs/behavior/system/commissioning/CommissioningClient.d.ts +3 -3
  10. package/dist/cjs/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
  11. package/dist/cjs/behavior/system/network/ClientNetworkRuntime.d.ts +0 -1
  12. package/dist/cjs/behavior/system/network/ClientNetworkRuntime.d.ts.map +1 -1
  13. package/dist/cjs/behavior/system/network/ClientNetworkRuntime.js +3 -4
  14. package/dist/cjs/behavior/system/network/ClientNetworkRuntime.js.map +1 -1
  15. package/dist/cjs/behavior/system/network/NetworkClient.d.ts +8 -13
  16. package/dist/cjs/behavior/system/network/NetworkClient.d.ts.map +1 -1
  17. package/dist/cjs/behavior/system/network/NetworkClient.js +20 -35
  18. package/dist/cjs/behavior/system/network/NetworkClient.js.map +1 -1
  19. package/dist/cjs/behavior/system/network/NetworkRuntime.d.ts +1 -1
  20. package/dist/cjs/behavior/system/network/NetworkRuntime.d.ts.map +1 -1
  21. package/dist/cjs/behavior/system/network/NetworkRuntime.js +5 -1
  22. package/dist/cjs/behavior/system/network/NetworkRuntime.js.map +1 -1
  23. package/dist/cjs/behavior/system/network/ServerNetworkRuntime.d.ts +0 -1
  24. package/dist/cjs/behavior/system/network/ServerNetworkRuntime.d.ts.map +1 -1
  25. package/dist/cjs/behavior/system/network/ServerNetworkRuntime.js +4 -4
  26. package/dist/cjs/behavior/system/network/ServerNetworkRuntime.js.map +1 -1
  27. package/dist/cjs/behavior/system/remote/RemoteInterface.d.ts.map +1 -1
  28. package/dist/cjs/behavior/system/remote/RemoteInterface.js +3 -3
  29. package/dist/cjs/behavior/system/remote/RemoteInterface.js.map +1 -1
  30. package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.js +1 -1
  31. package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.js.map +1 -1
  32. package/dist/cjs/behaviors/color-control/ColorConversionUtils.js +2 -2
  33. package/dist/cjs/behaviors/color-control/ColorConversionUtils.js.map +1 -1
  34. package/dist/cjs/behaviors/thermostat/AtomicWriteHandler.js +1 -1
  35. package/dist/cjs/behaviors/thermostat/AtomicWriteHandler.js.map +1 -1
  36. package/dist/cjs/behaviors/thermostat/ThermostatServer.js +1 -1
  37. package/dist/cjs/behaviors/thermostat/ThermostatServer.js.map +1 -1
  38. package/dist/cjs/node/client/ClientEventEmitter.d.ts.map +1 -1
  39. package/dist/cjs/node/client/ClientEventEmitter.js +11 -10
  40. package/dist/cjs/node/client/ClientEventEmitter.js.map +2 -2
  41. package/dist/cjs/node/client/ClientNodeInteraction.d.ts +8 -5
  42. package/dist/cjs/node/client/ClientNodeInteraction.d.ts.map +1 -1
  43. package/dist/cjs/node/client/ClientNodeInteraction.js +9 -13
  44. package/dist/cjs/node/client/ClientNodeInteraction.js.map +1 -1
  45. package/dist/cjs/node/integration/ChangeNotificationService.js +1 -1
  46. package/dist/cjs/node/integration/ChangeNotificationService.js.map +1 -1
  47. package/dist/cjs/node/server/InteractionServer.js +1 -1
  48. package/dist/cjs/node/server/OnlineServerInteraction.d.ts +0 -1
  49. package/dist/cjs/node/server/OnlineServerInteraction.d.ts.map +1 -1
  50. package/dist/cjs/node/server/OnlineServerInteraction.js +0 -3
  51. package/dist/cjs/node/server/OnlineServerInteraction.js.map +1 -1
  52. package/dist/esm/behavior/state/managed/Datasource.js +13 -13
  53. package/dist/esm/behavior/state/managed/Datasource.js.map +2 -2
  54. package/dist/esm/behavior/state/managed/values/ListManager.js +2 -2
  55. package/dist/esm/behavior/state/managed/values/ListManager.js.map +1 -1
  56. package/dist/esm/behavior/state/managed/values/ValuePatcher.js +10 -3
  57. package/dist/esm/behavior/state/managed/values/ValuePatcher.js.map +1 -1
  58. package/dist/esm/behavior/supervision/ValueSupervisor.d.ts +4 -0
  59. package/dist/esm/behavior/supervision/ValueSupervisor.d.ts.map +1 -1
  60. package/dist/esm/behavior/system/commissioning/CommissioningClient.d.ts +3 -3
  61. package/dist/esm/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
  62. package/dist/esm/behavior/system/network/ClientNetworkRuntime.d.ts +0 -1
  63. package/dist/esm/behavior/system/network/ClientNetworkRuntime.d.ts.map +1 -1
  64. package/dist/esm/behavior/system/network/ClientNetworkRuntime.js +3 -4
  65. package/dist/esm/behavior/system/network/ClientNetworkRuntime.js.map +1 -1
  66. package/dist/esm/behavior/system/network/NetworkClient.d.ts +8 -13
  67. package/dist/esm/behavior/system/network/NetworkClient.d.ts.map +1 -1
  68. package/dist/esm/behavior/system/network/NetworkClient.js +21 -36
  69. package/dist/esm/behavior/system/network/NetworkClient.js.map +1 -1
  70. package/dist/esm/behavior/system/network/NetworkRuntime.d.ts +1 -1
  71. package/dist/esm/behavior/system/network/NetworkRuntime.d.ts.map +1 -1
  72. package/dist/esm/behavior/system/network/NetworkRuntime.js +6 -2
  73. package/dist/esm/behavior/system/network/NetworkRuntime.js.map +1 -1
  74. package/dist/esm/behavior/system/network/ServerNetworkRuntime.d.ts +0 -1
  75. package/dist/esm/behavior/system/network/ServerNetworkRuntime.d.ts.map +1 -1
  76. package/dist/esm/behavior/system/network/ServerNetworkRuntime.js +4 -4
  77. package/dist/esm/behavior/system/network/ServerNetworkRuntime.js.map +1 -1
  78. package/dist/esm/behavior/system/remote/RemoteInterface.d.ts.map +1 -1
  79. package/dist/esm/behavior/system/remote/RemoteInterface.js +4 -4
  80. package/dist/esm/behavior/system/remote/RemoteInterface.js.map +1 -1
  81. package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.js +1 -1
  82. package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.js.map +1 -1
  83. package/dist/esm/behaviors/color-control/ColorConversionUtils.js +2 -2
  84. package/dist/esm/behaviors/color-control/ColorConversionUtils.js.map +1 -1
  85. package/dist/esm/behaviors/thermostat/AtomicWriteHandler.js +1 -1
  86. package/dist/esm/behaviors/thermostat/AtomicWriteHandler.js.map +1 -1
  87. package/dist/esm/behaviors/thermostat/ThermostatServer.js +1 -1
  88. package/dist/esm/behaviors/thermostat/ThermostatServer.js.map +1 -1
  89. package/dist/esm/node/client/ClientEventEmitter.d.ts.map +1 -1
  90. package/dist/esm/node/client/ClientEventEmitter.js +12 -11
  91. package/dist/esm/node/client/ClientEventEmitter.js.map +2 -2
  92. package/dist/esm/node/client/ClientNodeInteraction.d.ts +8 -5
  93. package/dist/esm/node/client/ClientNodeInteraction.d.ts.map +1 -1
  94. package/dist/esm/node/client/ClientNodeInteraction.js +9 -13
  95. package/dist/esm/node/client/ClientNodeInteraction.js.map +1 -1
  96. package/dist/esm/node/integration/ChangeNotificationService.js +1 -1
  97. package/dist/esm/node/integration/ChangeNotificationService.js.map +1 -1
  98. package/dist/esm/node/server/InteractionServer.js +1 -1
  99. package/dist/esm/node/server/OnlineServerInteraction.d.ts +0 -1
  100. package/dist/esm/node/server/OnlineServerInteraction.d.ts.map +1 -1
  101. package/dist/esm/node/server/OnlineServerInteraction.js +0 -3
  102. package/dist/esm/node/server/OnlineServerInteraction.js.map +1 -1
  103. package/package.json +7 -7
  104. package/src/behavior/Transitions.ts +1 -1
  105. package/src/behavior/state/managed/Datasource.ts +17 -14
  106. package/src/behavior/state/managed/values/ListManager.ts +2 -2
  107. package/src/behavior/state/managed/values/ValuePatcher.ts +15 -6
  108. package/src/behavior/supervision/ValueSupervisor.ts +5 -0
  109. package/src/behavior/system/commissioning/CommissioningClient.ts +3 -3
  110. package/src/behavior/system/network/ClientNetworkRuntime.ts +5 -5
  111. package/src/behavior/system/network/NetworkClient.ts +25 -43
  112. package/src/behavior/system/network/NetworkRuntime.ts +7 -4
  113. package/src/behavior/system/network/ServerNetworkRuntime.ts +5 -6
  114. package/src/behavior/system/remote/RemoteInterface.ts +4 -4
  115. package/src/behavior/system/subscriptions/SubscriptionsServer.ts +1 -1
  116. package/src/behaviors/color-control/ColorConversionUtils.ts +2 -2
  117. package/src/behaviors/thermostat/AtomicWriteHandler.ts +1 -1
  118. package/src/behaviors/thermostat/ThermostatServer.ts +1 -1
  119. package/src/node/client/ClientEventEmitter.ts +12 -11
  120. package/src/node/client/ClientNodeInteraction.ts +13 -17
  121. package/src/node/integration/ChangeNotificationService.ts +1 -1
  122. package/src/node/server/InteractionServer.ts +1 -1
  123. package/src/node/server/OnlineServerInteraction.ts +0 -4
@@ -5,7 +5,6 @@ export declare class OnlineServerInteraction implements Interactable<RemoteActor
5
5
  constructor(node: NodeProtocol);
6
6
  read(request: Read, context: RemoteActorContext.Options): ReadResult;
7
7
  subscribe(_request: Subscribe, _context: RemoteActorContext.Options): SubscribeResult;
8
- cancelSubscription(_id: number): void;
9
8
  write<T extends Write>(request: T, context: RemoteActorContext.Options): WriteResult<T>;
10
9
  invoke(request: Invoke, context: RemoteActorContext.Options): AsyncGenerator<import("#protocol").InvokeResult.Chunk, undefined, unknown>;
11
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"OnlineServerInteraction.d.ts","sourceRoot":"","sources":["../../../../src/node/server/OnlineServerInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAEpF,OAAO,EACH,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,UAAU,EAEV,SAAS,EACT,eAAe,EACf,KAAK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,GAAG,WAAW,CAAC,CAAC,CAAC;IAItF,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,CAAC,OAAO;CAWrE"}
@@ -21,9 +21,6 @@ class OnlineServerInteraction {
21
21
  subscribe(_request, _context) {
22
22
  throw new NotImplementedError("subscribe not implemented");
23
23
  }
24
- cancelSubscription(_id) {
25
- throw new NotImplementedError("cancelSubscription not implemented");
26
- }
27
24
  async write(request, context) {
28
25
  return RemoteActorContext(context).act((session) => this.#interaction.write(request, session));
29
26
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/node/server/OnlineServerInteraction.ts"],
4
- "mappings": "AAAA,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AACpC;AAAA,EAMI;AAAA,OAKG;AAEA,MAAM,wBAA4E;AAAA,EAC5E;AAAA,EAET,YAAY,MAAoB;AAC5B,SAAK,eAAe,IAAI,kBAAkB,IAAI;AAAA,EAClD;AAAA,EAEA,OAAO,KAAK,SAAe,SAAiD;AACxE,UAAM,UAAU,mBAAmB,OAAO,EAAE,cAAc;AAC1D,QAAI;AACA,uBAAiB,UAAU,KAAK,aAAa,KAAK,SAAS,OAAO,GAAG;AACjE,cAAM;AAAA,MACV;AAAA,IACJ,UAAE;AACE,cAAQ,OAAO,OAAO,EAAE;AAAA,IAC5B;AAAA,EACJ;AAAA,EAEA,UAAU,UAAqB,UAAuD;AAClF,UAAM,IAAI,oBAAoB,2BAA2B;AAAA,EAC7D;AAAA,EAEA,mBAAmB,KAAmB;AAClC,UAAM,IAAI,oBAAoB,oCAAoC;AAAA,EACtE;AAAA,EAEA,MAAM,MAAuB,SAAY,SAAqD;AAC1F,WAAO,mBAAmB,OAAO,EAAE,IAAI,aAAW,KAAK,aAAa,MAAM,SAAS,OAAO,CAAC;AAAA,EAC/F;AAAA,EAEA,OAAO,OAAO,SAAiB,SAAqC;AAChE,UAAM,UAAU,mBAAmB,EAAE,GAAG,SAA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6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matter/node",
3
- "version": "0.16.0-alpha.0-20251031-0f308af69",
3
+ "version": "0.16.0-alpha.0-20251101-70c8d51d7",
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-20251031-0f308af69",
46
- "@matter/model": "0.16.0-alpha.0-20251031-0f308af69",
47
- "@matter/types": "0.16.0-alpha.0-20251031-0f308af69",
48
- "@matter/protocol": "0.16.0-alpha.0-20251031-0f308af69"
45
+ "@matter/general": "0.16.0-alpha.0-20251101-70c8d51d7",
46
+ "@matter/model": "0.16.0-alpha.0-20251101-70c8d51d7",
47
+ "@matter/types": "0.16.0-alpha.0-20251101-70c8d51d7",
48
+ "@matter/protocol": "0.16.0-alpha.0-20251101-70c8d51d7"
49
49
  },
50
50
  "devDependencies": {
51
- "@matter/tools": "0.16.0-alpha.0-20251031-0f308af69",
52
- "@matter/testing": "0.16.0-alpha.0-20251031-0f308af69"
51
+ "@matter/tools": "0.16.0-alpha.0-20251101-70c8d51d7",
52
+ "@matter/testing": "0.16.0-alpha.0-20251101-70c8d51d7"
53
53
  },
54
54
  "files": [
55
55
  "dist/**/*",
@@ -220,7 +220,7 @@ export class Transitions<B extends Behavior> {
220
220
  return;
221
221
  }
222
222
 
223
- // Only report if it changes, with a delta larger than 10, caused by the invoke of a command
223
+ // Only report if it changes, with a delta larger than 10, caused by an invoke of a command
224
224
  if (fromCommand && Math.abs(this.#prevPublishedRemainingTime - newRemainingTime) <= 10) {
225
225
  return;
226
226
  }
@@ -285,7 +285,7 @@ interface CommitChanges {
285
285
  * Initialize the internal version of the datasource.
286
286
  */
287
287
  function configure(options: Datasource.Options): Internals {
288
- const values = new options.type() as Val.Struct;
288
+ let values = new options.type() as Val.Struct;
289
289
 
290
290
  let storedValues = options.store?.initialValues;
291
291
 
@@ -328,11 +328,26 @@ function configure(options: Datasource.Options): Internals {
328
328
  primaryKey: options.primaryKey === "id" ? "id" : "name",
329
329
  events,
330
330
  version: options.entropy.randomUint32,
331
- values,
332
331
  featuresKey,
333
332
  manageVersion: true,
334
333
  persistentFields,
335
334
 
335
+ get values() {
336
+ return values;
337
+ },
338
+
339
+ set values(newValues: Val.Struct) {
340
+ const oldValues = this.values;
341
+
342
+ values = newValues;
343
+
344
+ if (this.sessions) {
345
+ for (const context of this.sessions.values()) {
346
+ context.onChange(oldValues);
347
+ }
348
+ }
349
+ },
350
+
336
351
  interactionObserver(session?: ValueSupervisor.Session) {
337
352
  function handleObserverError(error: any) {
338
353
  logger.error(`Error in ${options.location.path} observer:`, error);
@@ -425,12 +440,6 @@ function configureExternalChanges(internals: Internals) {
425
440
  ...changes,
426
441
  };
427
442
 
428
- if (internals.sessions) {
429
- for (const context of internals.sessions.values()) {
430
- context.onChange(oldValues!);
431
- }
432
- }
433
-
434
443
  const changedProps = Object.keys(changes);
435
444
 
436
445
  const onChangePromise = internals.onChange?.(Array.from(changedProps));
@@ -825,13 +834,7 @@ function createReference(resource: Transaction.Resource, internals: Internals, s
825
834
  return;
826
835
  }
827
836
 
828
- const oldValues = internals.values;
829
837
  internals.values = values;
830
- if (internals.sessions) {
831
- for (const context of internals.sessions.values()) {
832
- context.onChange(oldValues);
833
- }
834
- }
835
838
  }
836
839
 
837
840
  /**
@@ -65,8 +65,8 @@ function createConfig(owner: RootSupervisor, schema: Schema): ListConfig {
65
65
 
66
66
  return {
67
67
  schema,
68
- fabricScoped: schema.effectiveAccess.fabric == Access.Fabric.Scoped,
69
- fabricSensitive: schema.effectiveAccess.fabric == Access.Fabric.Sensitive,
68
+ fabricScoped: schema.effectiveAccess.fabric === Access.Fabric.Scoped,
69
+ fabricSensitive: schema.effectiveAccess.fabric === Access.Fabric.Sensitive,
70
70
  manageEntries: entryManager.manage !== PrimitiveManager,
71
71
  manageEntry: entryManager.manage,
72
72
  validateEntry: entryManager.validate,
@@ -70,9 +70,12 @@ function StructPatcher(schema: ValueModel, supervisor: RootSupervisor): ValueSup
70
70
  // An object mapping name to default value (if any) for sub-structs
71
71
  const memberDefaults = {} as Record<string, Val.Struct>;
72
72
 
73
- // An object mapping name to true iff member is an array
73
+ // An object mapping name to true if member is an array
74
74
  const memberArrays = {} as Record<string, boolean>;
75
75
 
76
+ // An object mapping alt keys (numeric IDs) to member names, if numeric IDs are defined
77
+ const memberAltKeys = {} as Record<string, string>;
78
+
76
79
  for (const member of supervisor.membersOf(schema)) {
77
80
  const metatype = member.effectiveMetatype;
78
81
 
@@ -82,6 +85,9 @@ function StructPatcher(schema: ValueModel, supervisor: RootSupervisor): ValueSup
82
85
  }
83
86
 
84
87
  const key = camelize(member.name);
88
+ if (member.id !== undefined) {
89
+ memberAltKeys[member.id.toString()] = key;
90
+ }
85
91
 
86
92
  memberPatchers[key] = handler;
87
93
 
@@ -105,14 +111,17 @@ function StructPatcher(schema: ValueModel, supervisor: RootSupervisor): ValueSup
105
111
  throw new WriteError(path, `cannot patch ${target} because it is not an object`);
106
112
  }
107
113
 
108
- for (const key in changes as Val.Struct) {
114
+ for (let key in changes as Val.Struct) {
115
+ let newValue = (changes as Val.Struct)[key];
116
+
109
117
  // Validate the key
110
118
  if (!(key in memberPatchers)) {
111
- throw new WriteError(path, `${key} is not a property of ${schema.name}`);
119
+ if (!(key in memberAltKeys)) {
120
+ throw new WriteError(path, `${key} is not a property of ${schema.name}`);
121
+ }
122
+ key = memberAltKeys[key];
112
123
  }
113
124
 
114
- let newValue = (changes as Val.Struct)[key];
115
-
116
125
  // If this is not a subcollection or the new value is not an object, just do direct set
117
126
  const subpatch = memberPatchers[key];
118
127
  if (!subpatch || newValue === null || typeof newValue !== "object") {
@@ -137,7 +146,7 @@ function StructPatcher(schema: ValueModel, supervisor: RootSupervisor): ValueSup
137
146
  continue;
138
147
  }
139
148
 
140
- // Patch existing container. Casts to collection here may be incorrect but we the subpatcher will validate
149
+ // Patch existing container. Casts to collection here may be incorrect but the subpatcher will validate
141
150
  // input and throw for non-collections
142
151
  subpatch(newValue as Val.Collection, target[key] as Val.Collection, path.at(key));
143
152
  }
@@ -74,6 +74,11 @@ export namespace ValueSupervisor {
74
74
  */
75
75
  transaction: Transaction;
76
76
 
77
+ /**
78
+ * Signal for terminating asynchronous processes.
79
+ */
80
+ abort?: AbortSignal;
81
+
77
82
  /**
78
83
  * If this is true, data validation is disabled. This should only be used in contexts where data validation is
79
84
  * deferred.
@@ -521,15 +521,15 @@ export namespace CommissioningClient {
521
521
  * ```
522
522
  *
523
523
  * Note that certain clusters like Descriptor and Basic Information contain critical operational data. If your
524
- * read omits them then the node will only be partially functional once initialized or relevant clusters and
525
- * endpoints need to be enabled manually.
524
+ * read omits them then the node will only be partially functional once initialized.
526
525
  */
527
526
  defaultSubscription?: Subscribe;
528
527
 
529
528
  /**
530
529
  * By default, nodes we commission are automatically subscribed to using the {@link defaultSubscription} (or a
531
530
  * full wildcard subscription if that is undefined).
532
- * When set to false, the node will not be automatically subscribed.
531
+ *
532
+ * Matter.js will not subscribe automatically if set to false.
533
533
  */
534
534
  autoSubscribe?: boolean;
535
535
 
@@ -61,10 +61,12 @@ export class ClientNetworkRuntime extends NetworkRuntime {
61
61
  });
62
62
  env.set(ExchangeProvider, exchangeProvider);
63
63
 
64
+ this.#client = new ClientInteraction({ environment: env, abort: this.abortSignal });
65
+ env.set(ClientInteraction, this.#client);
66
+
64
67
  // Monitor sessions to maintain online state. We consider the node "online" if there is an active session. If
65
68
  // not, we consider the node offline. This is the only real way we have of determining whether the node is
66
69
  // healthy without actively polling
67
- this.#client = env.get(ClientInteraction);
68
70
  const { sessions } = env.get(SessionManager);
69
71
 
70
72
  if (sessions.find(session => session.peerIs(address))) {
@@ -105,6 +107,8 @@ export class ClientNetworkRuntime extends NetworkRuntime {
105
107
  protected async stop() {
106
108
  await this.construction;
107
109
 
110
+ this.owner.env.delete(ClientInteraction, this.#client);
111
+
108
112
  try {
109
113
  await this.#client?.close();
110
114
  } catch (e) {
@@ -113,8 +117,4 @@ export class ClientNetworkRuntime extends NetworkRuntime {
113
117
 
114
118
  this.#observers.close();
115
119
  }
116
-
117
- blockNewActivity() {
118
- this.owner.env.delete(ClientInteraction, this.#client);
119
- }
120
120
  }
@@ -5,11 +5,11 @@
5
5
  */
6
6
 
7
7
  import { RemoteDescriptor } from "#behavior/system/commissioning/RemoteDescriptor.js";
8
- import { ImplementationError, Observable, ServerAddress, ServerAddressUdp } from "#general";
8
+ import { Observable, ServerAddress, ServerAddressUdp } from "#general";
9
9
  import { DatatypeModel, FieldElement } from "#model";
10
10
  import type { ClientNode } from "#node/ClientNode.js";
11
11
  import { Node } from "#node/Node.js";
12
- import { ClientInteraction, DEFAULT_MIN_INTERVAL_FLOOR, PeerSet, Subscribe } from "#protocol";
12
+ import { ActiveSubscription, DEFAULT_MIN_INTERVAL_FLOOR, PeerSet, Subscribe } from "#protocol";
13
13
  import { CaseAuthenticatedTag } from "#types";
14
14
  import { ClientNetworkRuntime } from "./ClientNetworkRuntime.js";
15
15
  import { NetworkBehavior } from "./NetworkBehavior.js";
@@ -25,8 +25,8 @@ export class NetworkClient extends NetworkBehavior {
25
25
  this.state.autoSubscribe = false;
26
26
  this.state.defaultSubscription = undefined;
27
27
  } else {
28
- this.reactTo(this.events.autoSubscribe$Changed, this.#handleSubscription, { offline: true });
29
- this.reactTo(this.events.defaultSubscription$Changed, this.#handleChangedDefaultSubscription);
28
+ this.reactTo(this.events.autoSubscribe$Changed, this.#handleAutoSubscribeChanged, { offline: true });
29
+ this.reactTo(this.events.defaultSubscription$Changed, this.#handleDefaultSubscriptionChange);
30
30
  }
31
31
  }
32
32
 
@@ -48,36 +48,23 @@ export class NetworkClient extends NetworkBehavior {
48
48
  }
49
49
  }
50
50
 
51
- await this.#handleSubscription();
51
+ await this.#handleAutoSubscribeChanged();
52
52
  }
53
53
 
54
- /**
55
- * Manually activate the subscription for the node, if not already active. This will fail if the node is disabled.
56
- *
57
- * If you want to disable subscription, set the isDisabled state to true or set autoSubscribe to false.
58
- */
59
- subscribe() {
60
- if (this.state.isDisabled) {
61
- throw new ImplementationError("Cannot subscribe when node is disabled");
62
- }
63
- return this.#handleSubscription(true);
64
- }
54
+ async #handleDefaultSubscriptionChange() {
55
+ // Terminate any existing subscription
56
+ await this.#handleAutoSubscribeChanged(false);
65
57
 
66
- async #handleChangedDefaultSubscription() {
67
- if (!this.internal.subscriptionActivated) {
68
- return;
58
+ if (this.state.autoSubscribe && !this.state.isDisabled) {
59
+ await this.#handleAutoSubscribeChanged(true);
69
60
  }
70
-
71
- // Restart the subscription with the new parameters
72
- await this.#handleSubscription(false);
73
- await this.#handleSubscription(true);
74
61
  }
75
62
 
76
- async #handleSubscription(desiredState = this.state.autoSubscribe) {
63
+ async #handleAutoSubscribeChanged(desiredState = this.state.autoSubscribe) {
77
64
  const { isDisabled } = this.state;
78
65
  const subscriptionDesired = desiredState && !isDisabled;
79
66
 
80
- if (subscriptionDesired === this.internal.subscriptionActivated) {
67
+ if (subscriptionDesired === !!this.internal.activeSubscription) {
81
68
  return;
82
69
  }
83
70
 
@@ -93,22 +80,17 @@ export class NetworkClient extends NetworkBehavior {
93
80
  ...this.state.defaultSubscription,
94
81
  });
95
82
 
96
- // First, read. This allows us to retrieve attributes that do not support subscription
83
+ // First, read. This allows us to retrieve attributes that do not support subscription and gives us
84
+ // physical device information required to optimize subscription parameters
97
85
  for await (const _chunk of this.#node.interaction.read(subscribe));
98
86
 
99
87
  // Now subscribe for subsequent updates
100
- const { subscriptionId } = await this.#node.interaction.subscribe(subscribe);
88
+ const subscription = await this.#node.interaction.subscribe(subscribe);
101
89
 
102
- this.internal.subscriptionActivated = true;
103
- this.internal.defaultSubscriptionId = subscriptionId;
90
+ this.internal.activeSubscription = subscription;
104
91
  } else {
105
- if (this.internal.defaultSubscriptionId !== undefined) {
106
- (this.#node.interaction as ClientInteraction).subscriptions
107
- .get(this.internal.defaultSubscriptionId)
108
- ?.close();
109
- this.internal.defaultSubscriptionId = undefined;
110
- }
111
- this.internal.subscriptionActivated = false;
92
+ this.internal.activeSubscription?.close();
93
+ this.internal.activeSubscription = undefined;
112
94
  }
113
95
  }
114
96
 
@@ -167,13 +149,9 @@ export namespace NetworkClient {
167
149
  declare runtime?: ClientNetworkRuntime;
168
150
 
169
151
  /**
170
- * Contains the subscription target state. It will also be true if a subscription is in the process of being
171
- * established, or we wait for the node to be rediscovered.
152
+ * The active default subscription.
172
153
  */
173
- subscriptionActivated = false;
174
-
175
- /** The ID of the current active default subscription, if any */
176
- defaultSubscriptionId?: number;
154
+ activeSubscription?: ActiveSubscription;
177
155
  }
178
156
 
179
157
  export class State extends NetworkBehavior.State {
@@ -184,7 +162,7 @@ export namespace NetworkClient {
184
162
  * The default subscription is a wildcard for all attributes of the node. You can set to undefined or filter
185
163
  * the fields and values but only values selected by this subscription will update automatically.
186
164
  *
187
- * Set to null to disable automatic subscription.
165
+ * The default subscription updates automatically if you change this property.
188
166
  */
189
167
  defaultSubscription?: Subscribe;
190
168
 
@@ -199,6 +177,10 @@ export namespace NetworkClient {
199
177
  /**
200
178
  * If true, automatically subscribe to the provided default subscription (or all attributes and events) when
201
179
  * the node is started. If false, do not automatically subscribe.
180
+ *
181
+ * The subscription will activate or deactivate automatically if you change this property.
182
+ *
183
+ * Newly commissioned nodes default to true.
202
184
  */
203
185
  autoSubscribe = false;
204
186
 
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import { Construction, ImplementationError } from "#general";
7
+ import { Abort, Construction, ImplementationError } from "#general";
8
8
  import type { Node } from "#node/Node.js";
9
9
  import { NodeActivity } from "../../context/NodeActivity.js";
10
10
  import { NetworkBehavior } from "./NetworkBehavior.js";
@@ -15,6 +15,11 @@ import { NetworkBehavior } from "./NetworkBehavior.js";
15
15
  export abstract class NetworkRuntime {
16
16
  #construction: Construction<NetworkRuntime>;
17
17
  #owner: Node;
18
+ #abort = new Abort();
19
+
20
+ get abortSignal() {
21
+ return this.#abort.signal;
22
+ }
18
23
 
19
24
  get construction() {
20
25
  return this.#construction;
@@ -37,7 +42,7 @@ export abstract class NetworkRuntime {
37
42
  }
38
43
 
39
44
  async [Construction.destruct]() {
40
- this.blockNewActivity();
45
+ this.#abort();
41
46
  const activity = this.#owner.env.get(NodeActivity);
42
47
  if (activity.isActive) {
43
48
  await activity.inactive;
@@ -59,8 +64,6 @@ export abstract class NetworkRuntime {
59
64
 
60
65
  protected abstract stop(): Promise<void>;
61
66
 
62
- protected abstract blockNewActivity(): void;
63
-
64
67
  protected get owner() {
65
68
  return this.#owner;
66
69
  }
@@ -294,12 +294,15 @@ export class ServerNetworkRuntime extends NetworkRuntime {
294
294
 
295
295
  await env.load(PeerSet);
296
296
 
297
+ // Prevent new connections when aborted
298
+ this.abortSignal.addEventListener("abort", () =>
299
+ this.owner.env.maybeGet(InteractionServer)?.blockNewActivity(),
300
+ );
301
+
297
302
  await this.owner.act(agent => this.owner.lifecycle.online.emit(agent.context));
298
303
  }
299
304
 
300
305
  protected override async stop() {
301
- this.blockNewActivity();
302
-
303
306
  this.#observers.close();
304
307
 
305
308
  const { env } = this.owner;
@@ -327,10 +330,6 @@ export class ServerNetworkRuntime extends NetworkRuntime {
327
330
  await env.close(PeerSet);
328
331
  }
329
332
 
330
- protected override blockNewActivity() {
331
- this.owner.env.maybeGet(InteractionServer)?.blockNewActivity();
332
- }
333
-
334
333
  async #initializeGroupNetworking() {
335
334
  if (this.#groupNetworking) {
336
335
  logger.warn("Group networking already initialized, skipping.");
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import { AppAddress, BasicMultiplex, ImplementationError, Logger } from "#general";
7
+ import { Abort, AppAddress, BasicMultiplex, ImplementationError, Logger } from "#general";
8
8
  import type { ServerNode } from "#node/ServerNode.js";
9
9
  import { ApiPath } from "./api/ApiPath.js";
10
10
 
@@ -16,7 +16,7 @@ const logger = Logger.get("RemoteAdapter");
16
16
  export abstract class RemoteInterface {
17
17
  #node: ServerNode;
18
18
  #address: AppAddress;
19
- #abort = new AbortController();
19
+ #abort = new Abort();
20
20
  #root: ApiPath;
21
21
  #workers = new BasicMultiplex();
22
22
 
@@ -48,7 +48,7 @@ export abstract class RemoteInterface {
48
48
  }
49
49
 
50
50
  get isAborted() {
51
- return this.#abort.signal.aborted;
51
+ return this.#abort.aborted;
52
52
  }
53
53
 
54
54
  get abort() {
@@ -75,7 +75,7 @@ export abstract class RemoteInterface {
75
75
  return;
76
76
  }
77
77
 
78
- this.#abort.abort();
78
+ this.#abort();
79
79
 
80
80
  try {
81
81
  await this.stop();
@@ -206,7 +206,7 @@ export class SubscriptionsBehavior extends Behavior {
206
206
  const { formerSubscriptions } = this.internal;
207
207
 
208
208
  if (!formerSubscriptions.length) {
209
- logger.info("No former subscriptions to re-establish");
209
+ logger.debug("No former subscriptions to re-establish");
210
210
  return;
211
211
  } else {
212
212
  this.internal.formerSubscriptions = [];
@@ -172,8 +172,8 @@ export function rgbToXy(r: number, g: number, b: number): [number, number] {
172
172
  const Z = r * 0.000088 + g * 0.07231 + b * 0.986039;
173
173
  const sum = X + Y + Z;
174
174
 
175
- const retX = sum == 0 ? 0 : X / sum;
176
- const retY = sum == 0 ? 0 : Y / sum;
175
+ const retX = sum === 0 ? 0 : X / sum;
176
+ const retY = sum === 0 ? 0 : Y / sum;
177
177
 
178
178
  return [retX, retY];
179
179
  }
@@ -325,7 +325,7 @@ export class AtomicWriteHandler {
325
325
  */
326
326
  #pendingWriteStateForAttribute(endpoint: Endpoint, cluster: Behavior.Type, attribute: AttributeId) {
327
327
  const writeStates = this.#pendingWrites.filter(
328
- s => s.endpoint.number == endpoint.number && s.clusterId === (cluster as ClusterBehavior.Type).cluster.id,
328
+ s => s.endpoint.number === endpoint.number && s.clusterId === (cluster as ClusterBehavior.Type).cluster.id,
329
329
  );
330
330
  if (writeStates.length === 0) {
331
331
  return undefined;
@@ -999,7 +999,7 @@ export class ThermostatBaseServer extends ThermostatBehaviorLogicBase {
999
999
  * true.
1000
1000
  */
1001
1001
  #handleTemperatureChangeForMode(temperature: number | null) {
1002
- if (temperature == null) {
1002
+ if (temperature === null) {
1003
1003
  return;
1004
1004
  }
1005
1005
  const consideration = this.temperatureConsideration;
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import type { ElementEvent, Events } from "#behavior/Events.js";
8
- import { camelize, Logger } from "#general";
8
+ import { camelize, Diagnostic, Logger } from "#general";
9
9
  import { ClusterModel, EventModel, MatterModel } from "#model";
10
10
  import type { ClientNode } from "#node/ClientNode.js";
11
11
  import type { ReadResult } from "#protocol";
@@ -46,7 +46,7 @@ export function ClientEventEmitter(node: ClientNode, structure: ClientStructure)
46
46
  return;
47
47
  }
48
48
 
49
- const event = getEvent(occurrence.path.endpointId, names.cluster, names.event);
49
+ const event = getEvent(node, occurrence.path.endpointId, names.cluster, names.event);
50
50
  if (event) {
51
51
  node.act(agent => {
52
52
  // Current ActionContext is not writable, could skip act() but meh, see TODO above
@@ -56,26 +56,27 @@ export function ClientEventEmitter(node: ClientNode, structure: ClientStructure)
56
56
  }
57
57
  }
58
58
 
59
- function getEvent(endpointId: EndpointNumber, clusterName: string, eventName: string) {
59
+ function getEvent(node: ClientNode, endpointId: EndpointNumber, clusterName: string, eventName: string) {
60
60
  const endpoint = structure.endpointFor(endpointId);
61
61
  if (endpoint === undefined) {
62
- logger.error(`Received event for unsupported endpoint #${endpointId}`);
62
+ logger.warn(`Received event for unsupported endpoint #${endpointId} on ${node}`);
63
63
  return;
64
64
  }
65
65
 
66
66
  const events = (endpoint.events as Events.Generic<ElementEvent>)[clusterName];
67
67
  if (events === undefined) {
68
- logger.error(`Received event ${eventName} for unsupported cluster ${clusterName} on ${endpoint}`);
68
+ logger.warn(`Received event ${eventName} for unsupported cluster ${clusterName} on ${endpoint}`);
69
69
  return;
70
70
  }
71
71
 
72
- const event = events[eventName];
73
- if (event === undefined) {
74
- logger.error(`Received unsupported event ${eventName} for cluster ${clusterName} on ${endpoint}`);
75
- return;
76
- }
72
+ logger.info(
73
+ "Received event",
74
+ Diagnostic.strong(`${clusterName}.${eventName}`),
75
+ " on ",
76
+ Diagnostic.strong(endpoint.toString()),
77
+ );
77
78
 
78
- return event;
79
+ return events[eventName];
79
80
  }
80
81
  }
81
82