@project-chip/matter.js 0.15.1 → 0.15.2-alpha.0-20250703-2e16aba2b
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/CommissioningController.d.ts +2 -2
- package/dist/cjs/CommissioningController.d.ts.map +1 -1
- package/dist/cjs/CommissioningController.js +6 -6
- package/dist/cjs/CommissioningController.js.map +1 -1
- package/dist/cjs/ControllerStore.d.ts +38 -0
- package/dist/cjs/ControllerStore.d.ts.map +1 -0
- package/dist/cjs/ControllerStore.js +113 -0
- package/dist/cjs/ControllerStore.js.map +6 -0
- package/dist/cjs/LegacyControllerStore.d.ts +1 -1
- package/dist/cjs/LegacyControllerStore.d.ts.map +1 -1
- package/dist/cjs/MatterController.d.ts +1 -1
- package/dist/cjs/MatterController.d.ts.map +1 -1
- package/dist/cjs/MatterController.js.map +1 -1
- package/dist/cjs/device/ClientEndpointStore.d.ts +3 -3
- package/dist/cjs/device/ClientEndpointStore.d.ts.map +1 -1
- package/dist/cjs/device/ClientEndpointStore.js +3 -3
- package/dist/cjs/device/ClientEndpointStore.js.map +1 -1
- package/dist/cjs/device/Endpoint.d.ts +0 -1
- package/dist/cjs/device/Endpoint.d.ts.map +1 -1
- package/dist/cjs/device/Endpoint.js +0 -12
- package/dist/cjs/device/Endpoint.js.map +1 -1
- package/dist/cjs/export.d.ts +1 -0
- package/dist/cjs/export.d.ts.map +1 -1
- package/dist/cjs/export.js +1 -0
- package/dist/cjs/export.js.map +1 -1
- package/dist/esm/CommissioningController.d.ts +2 -2
- package/dist/esm/CommissioningController.d.ts.map +1 -1
- package/dist/esm/CommissioningController.js +1 -1
- package/dist/esm/CommissioningController.js.map +1 -1
- package/dist/esm/ControllerStore.d.ts +38 -0
- package/dist/esm/ControllerStore.d.ts.map +1 -0
- package/dist/esm/ControllerStore.js +101 -0
- package/dist/esm/ControllerStore.js.map +6 -0
- package/dist/esm/LegacyControllerStore.d.ts +1 -1
- package/dist/esm/LegacyControllerStore.d.ts.map +1 -1
- package/dist/esm/MatterController.d.ts +1 -1
- package/dist/esm/MatterController.d.ts.map +1 -1
- package/dist/esm/MatterController.js.map +1 -1
- package/dist/esm/device/ClientEndpointStore.d.ts +3 -3
- package/dist/esm/device/ClientEndpointStore.d.ts.map +1 -1
- package/dist/esm/device/ClientEndpointStore.js +4 -4
- package/dist/esm/device/ClientEndpointStore.js.map +1 -1
- package/dist/esm/device/Endpoint.d.ts +0 -1
- package/dist/esm/device/Endpoint.d.ts.map +1 -1
- package/dist/esm/device/Endpoint.js +0 -13
- package/dist/esm/device/Endpoint.js.map +1 -1
- package/dist/esm/export.d.ts +1 -0
- package/dist/esm/export.d.ts.map +1 -1
- package/dist/esm/export.js +1 -0
- package/dist/esm/export.js.map +1 -1
- package/package.json +8 -8
- package/src/CommissioningController.ts +1 -1
- package/src/ControllerStore.ts +128 -0
- package/src/LegacyControllerStore.ts +1 -1
- package/src/MatterController.ts +1 -1
- package/src/device/ClientEndpointStore.ts +7 -6
- package/src/device/Endpoint.ts +0 -17
- package/src/export.ts +1 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
Construction,
|
|
9
|
+
Destructable,
|
|
10
|
+
Diagnostic,
|
|
11
|
+
Environment,
|
|
12
|
+
ImplementationError,
|
|
13
|
+
Logger,
|
|
14
|
+
MaybePromise,
|
|
15
|
+
StorageContext,
|
|
16
|
+
StorageManager,
|
|
17
|
+
StorageService,
|
|
18
|
+
asyncNew,
|
|
19
|
+
} from "#general";
|
|
20
|
+
|
|
21
|
+
const logger = Logger.get("ControllerStore");
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Non-volatile state management for a {@link ControllerNode}.
|
|
25
|
+
*/
|
|
26
|
+
export class ControllerStore implements Destructable, ControllerStoreInterface {
|
|
27
|
+
#location: string;
|
|
28
|
+
#nodeId: string;
|
|
29
|
+
#storageManager?: StorageManager;
|
|
30
|
+
#sessionStorage?: StorageContext;
|
|
31
|
+
#caStorage?: StorageContext; // Root certificate and Fabric
|
|
32
|
+
#nodesStorage?: StorageContext; // Holds list of nodes in root level and then sub levels with data per client node?
|
|
33
|
+
#construction: Construction<ControllerStore>;
|
|
34
|
+
|
|
35
|
+
get construction() {
|
|
36
|
+
return this.#construction;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Create a new store.
|
|
41
|
+
*
|
|
42
|
+
* TODO - implement conversion from 0.7 format so people can change API seamlessly
|
|
43
|
+
*/
|
|
44
|
+
constructor(nodeId: string, environment: Environment) {
|
|
45
|
+
if (nodeId === undefined) {
|
|
46
|
+
throw new ImplementationError("ServerStore must be created with a nodeId");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const storage = environment.get(StorageService);
|
|
50
|
+
this.#location = storage.location ?? "(unknown location)";
|
|
51
|
+
this.#nodeId = nodeId;
|
|
52
|
+
|
|
53
|
+
const initializeStorage = async () => {
|
|
54
|
+
this.#storageManager = await storage.open(nodeId);
|
|
55
|
+
|
|
56
|
+
this.#logChange("Opened");
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
this.#construction = Construction(this, initializeStorage);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static async create(nodeId: string, environment = Environment.default) {
|
|
63
|
+
return await asyncNew(this, nodeId, environment);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async erase() {
|
|
67
|
+
await this.#sessionStorage?.clearAll();
|
|
68
|
+
await this.#caStorage?.clearAll();
|
|
69
|
+
await this.#nodesStorage?.clearAll();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async close() {
|
|
73
|
+
await this.#construction.close(async () => {
|
|
74
|
+
await this.#storageManager?.close();
|
|
75
|
+
this.#logChange("Closed");
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get sessionStorage() {
|
|
80
|
+
if (!this.#sessionStorage) {
|
|
81
|
+
this.#sessionStorage = this.storage.createContext("sessions");
|
|
82
|
+
}
|
|
83
|
+
return this.#sessionStorage;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
get caStorage() {
|
|
87
|
+
if (!this.#caStorage) {
|
|
88
|
+
this.#caStorage = this.storage.createContext("credentials");
|
|
89
|
+
}
|
|
90
|
+
return this.#caStorage;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
get nodesStorage() {
|
|
94
|
+
if (this.#nodesStorage === undefined) {
|
|
95
|
+
this.#nodesStorage = this.storage.createContext("nodes");
|
|
96
|
+
}
|
|
97
|
+
return this.#nodesStorage;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
get fabricStorage() {
|
|
101
|
+
return this.caStorage;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
get storage() {
|
|
105
|
+
if (this.#storageManager === undefined) {
|
|
106
|
+
throw new ImplementationError("Node storage accessed prior to initialization");
|
|
107
|
+
}
|
|
108
|
+
return this.#storageManager;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async clientNodeStore(nodeId: string) {
|
|
112
|
+
return this.storage.createContext(`node-${nodeId}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
#logChange(what: "Opened" | "Closed") {
|
|
116
|
+
logger.info(what, Diagnostic.strong(this.#nodeId ?? "node"), "storage at", `${this.#location}/${this.#nodeId}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export abstract class ControllerStoreInterface {
|
|
121
|
+
abstract erase(): Promise<void>;
|
|
122
|
+
abstract close(): Promise<void>;
|
|
123
|
+
abstract get sessionStorage(): StorageContext;
|
|
124
|
+
abstract get caStorage(): StorageContext;
|
|
125
|
+
abstract get nodesStorage(): StorageContext;
|
|
126
|
+
abstract get fabricStorage(): StorageContext;
|
|
127
|
+
abstract clientNodeStore(nodeId: string): MaybePromise<StorageContext>;
|
|
128
|
+
}
|
package/src/MatterController.ts
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import { GeneralCommissioning } from "#clusters";
|
|
14
14
|
import { NodeCommissioningOptions } from "#CommissioningController.js";
|
|
15
|
+
import { ControllerStoreInterface } from "#ControllerStore.js";
|
|
15
16
|
import { CachedClientNodeStore } from "#device/CachedClientNodeStore.js";
|
|
16
17
|
import { DeviceInformationData } from "#device/DeviceInformation.js";
|
|
17
18
|
import {
|
|
@@ -74,7 +75,6 @@ import {
|
|
|
74
75
|
VendorId,
|
|
75
76
|
} from "#types";
|
|
76
77
|
import { ClassExtends } from "@matter/general";
|
|
77
|
-
import { ControllerStoreInterface } from "@matter/node";
|
|
78
78
|
import { ControllerCommissioningFlow, MessageChannel } from "@matter/protocol";
|
|
79
79
|
|
|
80
80
|
export type CommissionedNodeDetails = {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Construction, isDeepEqual, StorageContext } from "#general";
|
|
8
|
-
import {
|
|
8
|
+
import { ServerEndpointStore } from "#node";
|
|
9
9
|
import { Val } from "@matter/protocol";
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -13,16 +13,17 @@ import { Val } from "@matter/protocol";
|
|
|
13
13
|
* Most methods from EndpointStore are not meant to be used in this class. Please just use "get" and "set".
|
|
14
14
|
* This class is supposed to be used in legacy code paths for Controller usage.
|
|
15
15
|
*/
|
|
16
|
-
export class ClientEndpointStore extends
|
|
17
|
-
readonly #construction: Construction<
|
|
16
|
+
export class ClientEndpointStore extends ServerEndpointStore {
|
|
17
|
+
readonly #construction: Construction<ServerEndpointStore>;
|
|
18
18
|
#values: Record<string, Val.Struct> = {};
|
|
19
19
|
|
|
20
20
|
constructor(storage: StorageContext, load = true) {
|
|
21
|
-
super(storage
|
|
21
|
+
super(storage);
|
|
22
22
|
|
|
23
23
|
this.#construction = Construction(this, async () => {
|
|
24
|
-
await super.construction;
|
|
25
24
|
if (load) {
|
|
25
|
+
await this.load();
|
|
26
|
+
|
|
26
27
|
// Copy over initial values from the superclass
|
|
27
28
|
this.#values = this.initialValues;
|
|
28
29
|
this.initialValues = {};
|
|
@@ -30,7 +31,7 @@ export class ClientEndpointStore extends EndpointStore {
|
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
get construction() {
|
|
34
35
|
return this.#construction;
|
|
35
36
|
}
|
|
36
37
|
|
package/src/device/Endpoint.ts
CHANGED
|
@@ -313,23 +313,6 @@ export class Endpoint {
|
|
|
313
313
|
return Array.from(this.clusterClients.values());
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
-
updatePartsList() {
|
|
317
|
-
const newPartsList = new Array<EndpointNumber>();
|
|
318
|
-
|
|
319
|
-
for (const child of this.childEndpoints) {
|
|
320
|
-
const childPartsList = child.updatePartsList();
|
|
321
|
-
|
|
322
|
-
if (child.number === undefined) {
|
|
323
|
-
throw new InternalError(`Child endpoint has no id, cannot add to parts list`);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
newPartsList.push(EndpointNumber(child.number));
|
|
327
|
-
newPartsList.push(...childPartsList);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
return newPartsList;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
316
|
/**
|
|
334
317
|
* Hierarchical diagnostics of endpoint and children.
|
|
335
318
|
*/
|