@matter/nodejs 0.16.6-alpha.0-20260121-bc6d62766 → 0.16.6-alpha.0-20260122-b5154bcb4
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/config.d.ts +6 -0
- package/dist/cjs/config.d.ts.map +1 -1
- package/dist/cjs/config.js +14 -1
- package/dist/cjs/config.js.map +1 -1
- package/dist/cjs/environment/NodeJsEnvironment.d.ts +2 -1
- package/dist/cjs/environment/NodeJsEnvironment.d.ts.map +1 -1
- package/dist/cjs/environment/NodeJsEnvironment.js +28 -10
- package/dist/cjs/environment/NodeJsEnvironment.js.map +1 -1
- package/dist/cjs/storage/StorageFactory.d.ts +52 -0
- package/dist/cjs/storage/StorageFactory.d.ts.map +1 -0
- package/dist/cjs/storage/StorageFactory.js +215 -0
- package/dist/cjs/storage/StorageFactory.js.map +6 -0
- package/dist/cjs/storage/fs/StorageBackendDisk.d.ts.map +1 -0
- package/dist/cjs/storage/{StorageBackendDisk.js.map → fs/StorageBackendDisk.js.map} +1 -1
- package/dist/cjs/storage/fs/StorageBackendJsonFile.d.ts.map +1 -0
- package/dist/cjs/storage/{StorageBackendJsonFile.js.map → fs/StorageBackendJsonFile.js.map} +1 -1
- package/dist/cjs/storage/fs/index.d.ts +8 -0
- package/dist/cjs/storage/fs/index.d.ts.map +1 -0
- package/dist/cjs/storage/fs/index.js +25 -0
- package/dist/cjs/storage/fs/index.js.map +6 -0
- package/dist/cjs/storage/index.d.ts +3 -2
- package/dist/cjs/storage/index.d.ts.map +1 -1
- package/dist/cjs/storage/index.js +3 -2
- package/dist/cjs/storage/index.js.map +1 -1
- package/dist/cjs/storage/sqlite/SqliteStorage.d.ts +105 -0
- package/dist/cjs/storage/sqlite/SqliteStorage.d.ts.map +1 -0
- package/dist/cjs/storage/sqlite/SqliteStorage.js +439 -0
- package/dist/cjs/storage/sqlite/SqliteStorage.js.map +6 -0
- package/dist/cjs/storage/sqlite/SqliteStorageError.d.ts +19 -0
- package/dist/cjs/storage/sqlite/SqliteStorageError.d.ts.map +1 -0
- package/dist/cjs/storage/sqlite/SqliteStorageError.js +38 -0
- package/dist/cjs/storage/sqlite/SqliteStorageError.js.map +6 -0
- package/dist/cjs/storage/sqlite/SqliteTypes.d.ts +67 -0
- package/dist/cjs/storage/sqlite/SqliteTypes.d.ts.map +1 -0
- package/dist/cjs/storage/sqlite/SqliteTypes.js +35 -0
- package/dist/cjs/storage/sqlite/SqliteTypes.js.map +6 -0
- package/dist/cjs/storage/sqlite/SqliteUtil.d.ts +33 -0
- package/dist/cjs/storage/sqlite/SqliteUtil.d.ts.map +1 -0
- package/dist/cjs/storage/sqlite/SqliteUtil.js +64 -0
- package/dist/cjs/storage/sqlite/SqliteUtil.js.map +6 -0
- package/dist/cjs/storage/sqlite/index.d.ts +10 -0
- package/dist/cjs/storage/sqlite/index.d.ts.map +1 -0
- package/dist/cjs/storage/sqlite/index.js +34 -0
- package/dist/cjs/storage/sqlite/index.js.map +6 -0
- package/dist/cjs/storage/sqlite/platform/BunSqlite.d.ts +17 -0
- package/dist/cjs/storage/sqlite/platform/BunSqlite.d.ts.map +1 -0
- package/dist/cjs/storage/sqlite/platform/BunSqlite.js +62 -0
- package/dist/cjs/storage/sqlite/platform/BunSqlite.js.map +6 -0
- package/dist/cjs/storage/sqlite/platform/NodeJsSqlite.d.ts +12 -0
- package/dist/cjs/storage/sqlite/platform/NodeJsSqlite.d.ts.map +1 -0
- package/dist/cjs/storage/sqlite/platform/NodeJsSqlite.js +49 -0
- package/dist/cjs/storage/sqlite/platform/NodeJsSqlite.js.map +6 -0
- package/dist/cjs/storage/sqlite/platform/PlatformSqlite.d.ts +8 -0
- package/dist/cjs/storage/sqlite/platform/PlatformSqlite.d.ts.map +1 -0
- package/dist/cjs/storage/sqlite/platform/PlatformSqlite.js +54 -0
- package/dist/cjs/storage/sqlite/platform/PlatformSqlite.js.map +6 -0
- package/dist/cjs/util/runtimeChecks.d.ts +14 -0
- package/dist/cjs/util/runtimeChecks.d.ts.map +1 -0
- package/dist/cjs/util/runtimeChecks.js +45 -0
- package/dist/cjs/util/runtimeChecks.js.map +6 -0
- package/dist/esm/config.d.ts +6 -0
- package/dist/esm/config.d.ts.map +1 -1
- package/dist/esm/config.js +14 -1
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/environment/NodeJsEnvironment.d.ts +2 -1
- package/dist/esm/environment/NodeJsEnvironment.d.ts.map +1 -1
- package/dist/esm/environment/NodeJsEnvironment.js +29 -10
- package/dist/esm/environment/NodeJsEnvironment.js.map +1 -1
- package/dist/esm/storage/StorageFactory.d.ts +52 -0
- package/dist/esm/storage/StorageFactory.d.ts.map +1 -0
- package/dist/esm/storage/StorageFactory.js +195 -0
- package/dist/esm/storage/StorageFactory.js.map +6 -0
- package/dist/esm/storage/fs/StorageBackendDisk.d.ts.map +1 -0
- package/dist/esm/storage/{StorageBackendDisk.js.map → fs/StorageBackendDisk.js.map} +1 -1
- package/dist/esm/storage/fs/StorageBackendJsonFile.d.ts.map +1 -0
- package/dist/esm/storage/{StorageBackendJsonFile.js.map → fs/StorageBackendJsonFile.js.map} +1 -1
- package/dist/esm/storage/fs/index.d.ts +8 -0
- package/dist/esm/storage/fs/index.d.ts.map +1 -0
- package/dist/esm/storage/fs/index.js +8 -0
- package/dist/esm/storage/fs/index.js.map +6 -0
- package/dist/esm/storage/index.d.ts +3 -2
- package/dist/esm/storage/index.d.ts.map +1 -1
- package/dist/esm/storage/index.js +3 -2
- package/dist/esm/storage/index.js.map +1 -1
- package/dist/esm/storage/sqlite/SqliteStorage.d.ts +105 -0
- package/dist/esm/storage/sqlite/SqliteStorage.d.ts.map +1 -0
- package/dist/esm/storage/sqlite/SqliteStorage.js +423 -0
- package/dist/esm/storage/sqlite/SqliteStorage.js.map +6 -0
- package/dist/esm/storage/sqlite/SqliteStorageError.d.ts +19 -0
- package/dist/esm/storage/sqlite/SqliteStorageError.d.ts.map +1 -0
- package/dist/esm/storage/sqlite/SqliteStorageError.js +18 -0
- package/dist/esm/storage/sqlite/SqliteStorageError.js.map +6 -0
- package/dist/esm/storage/sqlite/SqliteTypes.d.ts +67 -0
- package/dist/esm/storage/sqlite/SqliteTypes.d.ts.map +1 -0
- package/dist/esm/storage/sqlite/SqliteTypes.js +15 -0
- package/dist/esm/storage/sqlite/SqliteTypes.js.map +6 -0
- package/dist/esm/storage/sqlite/SqliteUtil.d.ts +33 -0
- package/dist/esm/storage/sqlite/SqliteUtil.d.ts.map +1 -0
- package/dist/esm/storage/sqlite/SqliteUtil.js +44 -0
- package/dist/esm/storage/sqlite/SqliteUtil.js.map +6 -0
- package/dist/esm/storage/sqlite/index.d.ts +10 -0
- package/dist/esm/storage/sqlite/index.d.ts.map +1 -0
- package/dist/esm/storage/sqlite/index.js +14 -0
- package/dist/esm/storage/sqlite/index.js.map +6 -0
- package/dist/esm/storage/sqlite/platform/BunSqlite.d.ts +17 -0
- package/dist/esm/storage/sqlite/platform/BunSqlite.d.ts.map +1 -0
- package/dist/esm/storage/sqlite/platform/BunSqlite.js +32 -0
- package/dist/esm/storage/sqlite/platform/BunSqlite.js.map +6 -0
- package/dist/esm/storage/sqlite/platform/NodeJsSqlite.d.ts +12 -0
- package/dist/esm/storage/sqlite/platform/NodeJsSqlite.d.ts.map +1 -0
- package/dist/esm/storage/sqlite/platform/NodeJsSqlite.js +29 -0
- package/dist/esm/storage/sqlite/platform/NodeJsSqlite.js.map +6 -0
- package/dist/esm/storage/sqlite/platform/PlatformSqlite.d.ts +8 -0
- package/dist/esm/storage/sqlite/platform/PlatformSqlite.d.ts.map +1 -0
- package/dist/esm/storage/sqlite/platform/PlatformSqlite.js +24 -0
- package/dist/esm/storage/sqlite/platform/PlatformSqlite.js.map +6 -0
- package/dist/esm/util/runtimeChecks.d.ts +14 -0
- package/dist/esm/util/runtimeChecks.d.ts.map +1 -0
- package/dist/esm/util/runtimeChecks.js +25 -0
- package/dist/esm/util/runtimeChecks.js.map +6 -0
- package/package.json +10 -10
- package/src/config.ts +18 -4
- package/src/environment/NodeJsEnvironment.ts +41 -12
- package/src/net/NodeJsHttpEndpoint.ts +1 -1
- package/src/storage/StorageFactory.ts +310 -0
- package/src/storage/fs/index.ts +8 -0
- package/src/storage/index.ts +3 -2
- package/src/storage/sqlite/SqliteStorage.ts +572 -0
- package/src/storage/sqlite/SqliteStorageError.ts +23 -0
- package/src/storage/sqlite/SqliteTypes.ts +75 -0
- package/src/storage/sqlite/SqliteUtil.ts +61 -0
- package/src/storage/sqlite/index.ts +10 -0
- package/src/storage/sqlite/platform/BunSqlite.ts +40 -0
- package/src/storage/sqlite/platform/NodeJsSqlite.ts +35 -0
- package/src/storage/sqlite/platform/PlatformSqlite.ts +52 -0
- package/src/util/runtimeChecks.ts +31 -0
- package/dist/cjs/storage/StorageBackendDisk.d.ts.map +0 -1
- package/dist/cjs/storage/StorageBackendJsonFile.d.ts.map +0 -1
- package/dist/esm/storage/StorageBackendDisk.d.ts.map +0 -1
- package/dist/esm/storage/StorageBackendJsonFile.d.ts.map +0 -1
- /package/dist/cjs/storage/{StorageBackendDisk.d.ts → fs/StorageBackendDisk.d.ts} +0 -0
- /package/dist/cjs/storage/{StorageBackendDisk.js → fs/StorageBackendDisk.js} +0 -0
- /package/dist/cjs/storage/{StorageBackendJsonFile.d.ts → fs/StorageBackendJsonFile.d.ts} +0 -0
- /package/dist/cjs/storage/{StorageBackendJsonFile.js → fs/StorageBackendJsonFile.js} +0 -0
- /package/dist/esm/storage/{StorageBackendDisk.d.ts → fs/StorageBackendDisk.d.ts} +0 -0
- /package/dist/esm/storage/{StorageBackendDisk.js → fs/StorageBackendDisk.js} +0 -0
- /package/dist/esm/storage/{StorageBackendJsonFile.d.ts → fs/StorageBackendJsonFile.d.ts} +0 -0
- /package/dist/esm/storage/{StorageBackendJsonFile.js → fs/StorageBackendJsonFile.js} +0 -0
- /package/src/storage/{StorageBackendDisk.ts → fs/StorageBackendDisk.ts} +0 -0
- /package/src/storage/{StorageBackendJsonFile.ts → fs/StorageBackendJsonFile.ts} +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2026 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export { PlatformSqlite } from "./platform/PlatformSqlite.js";
|
|
7
|
+
export { SqliteStorage } from "./SqliteStorage.js";
|
|
8
|
+
export { SqliteStorageError } from "./SqliteStorageError.js";
|
|
9
|
+
export type { DatabaseCreator, DatabaseLike } from "./SqliteTypes.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/sqlite/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2026 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { PlatformSqlite } from "./platform/PlatformSqlite.js";
|
|
7
|
+
import { SqliteStorage } from "./SqliteStorage.js";
|
|
8
|
+
import { SqliteStorageError } from "./SqliteStorageError.js";
|
|
9
|
+
export {
|
|
10
|
+
PlatformSqlite,
|
|
11
|
+
SqliteStorage,
|
|
12
|
+
SqliteStorageError
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2026 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { SqliteStorage } from "../SqliteStorage.js";
|
|
7
|
+
/**
|
|
8
|
+
* `StorageSqliteDisk` for Bun
|
|
9
|
+
*
|
|
10
|
+
* DO NOT IMPORT DIRECTLY
|
|
11
|
+
* (should import `PlatformSqlite.js`)
|
|
12
|
+
*/
|
|
13
|
+
export declare class BunSqlite extends SqliteStorage {
|
|
14
|
+
constructor(path: string | null, clear?: boolean);
|
|
15
|
+
clear(completely?: boolean): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=BunSqlite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BunSqlite.d.ts","sourceRoot":"","sources":["../../../../../src/storage/sqlite/platform/BunSqlite.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAMpD;;;;;GAKG;AACH,qBAAa,SAAU,SAAQ,aAAa;gBAC5B,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,UAAQ;IAY/B,KAAK,CAAC,UAAU,CAAC,EAAE,OAAO;CAQ5C"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2026 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { SqliteStorage } from "../SqliteStorage.js";
|
|
7
|
+
import { Database } from "bun:sqlite";
|
|
8
|
+
import Bun from "bun";
|
|
9
|
+
class BunSqlite extends SqliteStorage {
|
|
10
|
+
constructor(path, clear = false) {
|
|
11
|
+
super({
|
|
12
|
+
databaseCreator: (path2) => new Database(path2, {
|
|
13
|
+
strict: true,
|
|
14
|
+
create: true
|
|
15
|
+
}),
|
|
16
|
+
path,
|
|
17
|
+
clear
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async clear(completely) {
|
|
21
|
+
await super.clear();
|
|
22
|
+
if (completely ?? false) {
|
|
23
|
+
this.close();
|
|
24
|
+
await Bun.file(this.dbPath).delete();
|
|
25
|
+
this.isInitialized = false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
BunSqlite
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=BunSqlite.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/storage/sqlite/platform/BunSqlite.ts"],
|
|
4
|
+
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,SAAS,qBAAqB;AAE9B,SAAS,gBAAgB;AAEzB,OAAO,SAAS;AAQT,MAAM,kBAAkB,cAAc;AAAA,EACzC,YAAY,MAAqB,QAAQ,OAAO;AAC5C,UAAM;AAAA,MACF,iBAAiB,CAAAA,UACb,IAAI,SAASA,OAAM;AAAA,QACf,QAAQ;AAAA,QACR,QAAQ;AAAA,MACZ,CAAC;AAAA,MACL;AAAA,MACA;AAAA,IACJ,CAAC;AAAA,EACL;AAAA,EAEA,MAAe,MAAM,YAAsB;AACvC,UAAM,MAAM,MAAM;AAClB,QAAI,cAAc,OAAO;AACrB,WAAK,MAAM;AACX,YAAM,IAAI,KAAK,KAAK,MAAM,EAAE,OAAO;AACnC,WAAK,gBAAgB;AAAA,IACzB;AAAA,EACJ;AACJ;",
|
|
5
|
+
"names": ["path"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SqliteStorage } from "../SqliteStorage.js";
|
|
2
|
+
/**
|
|
3
|
+
* `StorageSqliteDisk` for Node.js
|
|
4
|
+
*
|
|
5
|
+
* DO NOT IMPORT DIRECTLY
|
|
6
|
+
* (should import `PlatformSqlite.js`)
|
|
7
|
+
*/
|
|
8
|
+
export declare class NodeJsSqlite extends SqliteStorage {
|
|
9
|
+
constructor(path: string | null, clear?: boolean);
|
|
10
|
+
clear(completely?: boolean): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=NodeJsSqlite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeJsSqlite.d.ts","sourceRoot":"","sources":["../../../../../src/storage/sqlite/platform/NodeJsSqlite.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD;;;;;GAKG;AACH,qBAAa,YAAa,SAAQ,aAAa;gBAC/B,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,UAAQ;IAQ/B,KAAK,CAAC,UAAU,CAAC,EAAE,OAAO;CAQ5C"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2026 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { rm } from "node:fs/promises";
|
|
7
|
+
import { DatabaseSync } from "node:sqlite";
|
|
8
|
+
import { SqliteStorage } from "../SqliteStorage.js";
|
|
9
|
+
class NodeJsSqlite extends SqliteStorage {
|
|
10
|
+
constructor(path, clear = false) {
|
|
11
|
+
super({
|
|
12
|
+
databaseCreator: (path2) => new DatabaseSync(path2),
|
|
13
|
+
path,
|
|
14
|
+
clear
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
async clear(completely) {
|
|
18
|
+
await super.clear();
|
|
19
|
+
if (completely ?? false) {
|
|
20
|
+
this.close();
|
|
21
|
+
await rm(this.dbPath, { force: true });
|
|
22
|
+
this.isInitialized = false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
NodeJsSqlite
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=NodeJsSqlite.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/storage/sqlite/platform/NodeJsSqlite.ts"],
|
|
4
|
+
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAE7B,SAAS,qBAAqB;AASvB,MAAM,qBAAqB,cAAc;AAAA,EAC5C,YAAY,MAAqB,QAAQ,OAAO;AAC5C,UAAM;AAAA,MACF,iBAAiB,CAAAA,UAAQ,IAAI,aAAaA,KAAI;AAAA,MAC9C;AAAA,MACA;AAAA,IACJ,CAAC;AAAA,EACL;AAAA,EAEA,MAAe,MAAM,YAAsB;AACvC,UAAM,MAAM,MAAM;AAClB,QAAI,cAAc,OAAO;AACrB,WAAK,MAAM;AACX,YAAM,GAAG,KAAK,QAAQ,EAAE,OAAO,KAAK,CAAC;AACrC,WAAK,gBAAgB;AAAA,IACzB;AAAA,EACJ;AACJ;",
|
|
5
|
+
"names": ["path"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SqliteStorage } from "../SqliteStorage.js";
|
|
2
|
+
/**
|
|
3
|
+
* Create platform-specific SQLite storage
|
|
4
|
+
*
|
|
5
|
+
* Automatically detects runtime (Bun or Node.js) and returns appropriate implementation.
|
|
6
|
+
*/
|
|
7
|
+
export declare function PlatformSqlite(path: string | null, clear?: boolean): Promise<SqliteStorage>;
|
|
8
|
+
//# sourceMappingURL=PlatformSqlite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformSqlite.d.ts","sourceRoot":"","sources":["../../../../../src/storage/sqlite/platform/PlatformSqlite.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,UAAQ,GAAG,OAAO,CAAC,aAAa,CAAC,CAc/F"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2026 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { isBunjs } from "#util/runtimeChecks.js";
|
|
7
|
+
async function PlatformSqlite(path, clear = false) {
|
|
8
|
+
const isBun = isBunjs();
|
|
9
|
+
if (!isBun) {
|
|
10
|
+
const module2 = await import("./NodeJsSqlite.js");
|
|
11
|
+
const NodeJsSqlite = findDefaultExport(module2, "NodeJsSqlite");
|
|
12
|
+
return new NodeJsSqlite(path, clear);
|
|
13
|
+
}
|
|
14
|
+
const module = await import("./BunSqlite.js");
|
|
15
|
+
const BunSqlite = findDefaultExport(module, "BunSqlite");
|
|
16
|
+
return new BunSqlite(path, clear);
|
|
17
|
+
}
|
|
18
|
+
function findDefaultExport(moduleLike, name) {
|
|
19
|
+
return moduleLike[name] || moduleLike.default?.[name] || moduleLike.default;
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
PlatformSqlite
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=PlatformSqlite.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/storage/sqlite/platform/PlatformSqlite.ts"],
|
|
4
|
+
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,SAAS,eAAe;AAQxB,eAAsB,eAAe,MAAqB,QAAQ,OAA+B;AAC7F,QAAM,QAAQ,QAAQ;AAGtB,MAAI,CAAC,OAAO;AACR,UAAMA,UAAS,MAAM,OAAO,mBAAmB;AAC/C,UAAM,eAAe,kBAAkBA,SAAQ,cAAc;AAC7D,WAAO,IAAI,aAAa,MAAM,KAAK;AAAA,EACvC;AAGA,QAAM,SAAS,MAAM,OAAO,gBAAgB;AAC5C,QAAM,YAAY,kBAAkB,QAAQ,WAAW;AACvD,SAAO,IAAI,UAAU,MAAM,KAAK;AACpC;AAsBA,SAAS,kBAAwC,YAAe,MAAe;AAC3E,SAAO,WAAW,IAAI,KAAM,WAAmB,UAAU,IAAI,KAAM,WAAmB;AAC1F;",
|
|
5
|
+
"names": ["module"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2026 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Check runtime is bun.js
|
|
8
|
+
*/
|
|
9
|
+
export declare function isBunjs(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Check Node.js's runtime supports sqlite.
|
|
12
|
+
*/
|
|
13
|
+
export declare function supportsSqlite(): boolean;
|
|
14
|
+
//# sourceMappingURL=runtimeChecks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeChecks.d.ts","sourceRoot":"","sources":["../../../src/util/runtimeChecks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH;;GAEG;AACH,wBAAgB,OAAO,YAEtB;AAED;;GAEG;AACH,wBAAgB,cAAc,YAa7B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2026 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
function isBunjs() {
|
|
7
|
+
return process.versions.bun != null;
|
|
8
|
+
}
|
|
9
|
+
function supportsSqlite() {
|
|
10
|
+
const nodeVersion = process.versions.node;
|
|
11
|
+
if (!nodeVersion.includes(".")) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const prefixPart = nodeVersion.substring(0, nodeVersion.indexOf("."));
|
|
15
|
+
const majorNum = Number(prefixPart);
|
|
16
|
+
if (Number.isNaN(majorNum)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return majorNum >= 22;
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
isBunjs,
|
|
23
|
+
supportsSqlite
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=runtimeChecks.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/util/runtimeChecks.ts"],
|
|
4
|
+
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,SAAS,UAAU;AACtB,SAAO,QAAQ,SAAS,OAAO;AACnC;AAKO,SAAS,iBAAiB;AAC7B,QAAM,cAAc,QAAQ,SAAS;AACrC,MAAI,CAAC,YAAY,SAAS,GAAG,GAAG;AAC5B,WAAO;AAAA,EACX;AACA,QAAM,aAAa,YAAY,UAAU,GAAG,YAAY,QAAQ,GAAG,CAAC;AAEpE,QAAM,WAAW,OAAO,UAAU;AAClC,MAAI,OAAO,MAAM,QAAQ,GAAG;AACxB,WAAO;AAAA,EACX;AAEA,SAAO,YAAY;AACvB;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matter/nodejs",
|
|
3
|
-
"version": "0.16.6-alpha.0-
|
|
3
|
+
"version": "0.16.6-alpha.0-20260122-b5154bcb4",
|
|
4
4
|
"description": "Node.js platform support for matter.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"iot",
|
|
@@ -44,17 +44,17 @@
|
|
|
44
44
|
"#*": "./src/*"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@matter/general": "0.16.6-alpha.0-
|
|
48
|
-
"@matter/node": "0.16.6-alpha.0-
|
|
49
|
-
"@matter/protocol": "0.16.6-alpha.0-
|
|
50
|
-
"@matter/types": "0.16.6-alpha.0-
|
|
47
|
+
"@matter/general": "0.16.6-alpha.0-20260122-b5154bcb4",
|
|
48
|
+
"@matter/node": "0.16.6-alpha.0-20260122-b5154bcb4",
|
|
49
|
+
"@matter/protocol": "0.16.6-alpha.0-20260122-b5154bcb4",
|
|
50
|
+
"@matter/types": "0.16.6-alpha.0-20260122-b5154bcb4"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@matter/model": "0.16.6-alpha.0-
|
|
54
|
-
"@matter/protocol": "0.16.6-alpha.0-
|
|
55
|
-
"@matter/testing": "0.16.6-alpha.0-
|
|
56
|
-
"@matter/tools": "0.16.6-alpha.0-
|
|
57
|
-
"@project-chip/matter.js": "0.16.6-alpha.0-
|
|
53
|
+
"@matter/model": "0.16.6-alpha.0-20260122-b5154bcb4",
|
|
54
|
+
"@matter/protocol": "0.16.6-alpha.0-20260122-b5154bcb4",
|
|
55
|
+
"@matter/testing": "0.16.6-alpha.0-20260122-b5154bcb4",
|
|
56
|
+
"@matter/tools": "0.16.6-alpha.0-20260122-b5154bcb4",
|
|
57
|
+
"@project-chip/matter.js": "0.16.6-alpha.0-20260122-b5154bcb4",
|
|
58
58
|
"@types/bytebuffer": "^5.0.49"
|
|
59
59
|
},
|
|
60
60
|
"files": [
|
package/src/config.ts
CHANGED
|
@@ -16,10 +16,10 @@ let trapProcessSignals = true;
|
|
|
16
16
|
let trapUnhandledErrors = true;
|
|
17
17
|
let setProcessExitCodeOnError = true;
|
|
18
18
|
let installNetwork = true;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
//
|
|
22
|
-
let
|
|
19
|
+
// Automatic replace to `StandardCrypto` in bun.js
|
|
20
|
+
let installCrypto = true;
|
|
21
|
+
// Storage driver
|
|
22
|
+
let storageDriver = "file";
|
|
23
23
|
|
|
24
24
|
export class NodeJsAlreadyInitializedError extends Error {}
|
|
25
25
|
|
|
@@ -163,6 +163,20 @@ export const config = {
|
|
|
163
163
|
initializeStorage = value;
|
|
164
164
|
},
|
|
165
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Set storage driver to use (default: 'file').
|
|
168
|
+
*
|
|
169
|
+
* Currently, 'file' and 'sqlite' (Node.js v22+) is supported.
|
|
170
|
+
*/
|
|
171
|
+
get storageDriver() {
|
|
172
|
+
return storageDriver as "file" | "sqlite";
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
set storageDriver(value: "file" | "sqlite") {
|
|
176
|
+
assertUninitialized("initializeStorage");
|
|
177
|
+
storageDriver = value;
|
|
178
|
+
},
|
|
179
|
+
|
|
166
180
|
/**
|
|
167
181
|
* Enables handling of SIGINT, SIGTERM, SIGUSR2 and SIGABRT (depending on platform; default: true).
|
|
168
182
|
*/
|
|
@@ -18,15 +18,20 @@ import {
|
|
|
18
18
|
Logger,
|
|
19
19
|
Network,
|
|
20
20
|
ServiceBundle,
|
|
21
|
+
StandardCrypto,
|
|
21
22
|
StorageService,
|
|
22
23
|
VariableService,
|
|
23
24
|
} from "#general";
|
|
24
25
|
import { NodeJsHttpEndpoint } from "#net/NodeJsHttpEndpoint.js";
|
|
26
|
+
import { StorageFactory } from "#storage/index.js";
|
|
27
|
+
|
|
28
|
+
import { isBunjs } from "#util/runtimeChecks.js";
|
|
29
|
+
|
|
25
30
|
import { existsSync, readFileSync } from "node:fs";
|
|
26
31
|
import { writeFile } from "node:fs/promises";
|
|
27
32
|
import { resolve } from "node:path";
|
|
33
|
+
|
|
28
34
|
import { NodeJsNetwork } from "../net/NodeJsNetwork.js";
|
|
29
|
-
import { StorageBackendDisk } from "../storage/StorageBackendDisk.js";
|
|
30
35
|
import { ProcessManager } from "./ProcessManager.js";
|
|
31
36
|
|
|
32
37
|
/**
|
|
@@ -62,9 +67,10 @@ import { ProcessManager } from "./ProcessManager.js";
|
|
|
62
67
|
* * `trace.enable` - Enable writing a trace file
|
|
63
68
|
* * `storage.path` - Where to store storage files, Default: "path.root"
|
|
64
69
|
* * `storage.clear` - Clear storage on start? Default: false
|
|
70
|
+
* * `storage.driver` - Storage driver to use: "file" (default) or "sqlite" (requires Node.js v22+). Automatically migrates data when switching drivers.
|
|
65
71
|
* * `nodejs.crypto` - Enables crypto implementation in this package. Default: true
|
|
66
72
|
* * `nodejs.network` - Enables network implementation in this package. Default: true
|
|
67
|
-
* * `nodejs.storage` - Enables
|
|
73
|
+
* * `nodejs.storage` - Enables storage implementation in this package. Default: true
|
|
68
74
|
* * `runtime.signals` - By default register SIGINT and SIGUSR2 (diag) handlers, set to false if not wanted
|
|
69
75
|
* * `runtime.exitcode` - By default we set the process.exitcode to 0 (ok) or 1 (crash); set to false to disable
|
|
70
76
|
* * `runtime.unhandlederrors` - By default we log unhandled errors to matter.js log; set to false to disable
|
|
@@ -140,16 +146,24 @@ function rootDirOf(env: Environment) {
|
|
|
140
146
|
function configureCrypto(env: Environment) {
|
|
141
147
|
Boot.init(() => {
|
|
142
148
|
if (config.installCrypto || (env.vars.boolean("nodejs.crypto") ?? true)) {
|
|
143
|
-
|
|
149
|
+
let crypto: Crypto;
|
|
150
|
+
if (!isBunjs()) {
|
|
151
|
+
// Platform implemented crypto
|
|
152
|
+
crypto = new NodeJsCrypto();
|
|
153
|
+
} else {
|
|
154
|
+
// Unsupported environment fallback
|
|
155
|
+
crypto = new StandardCrypto(global.crypto);
|
|
156
|
+
}
|
|
144
157
|
env.set(Entropy, crypto);
|
|
145
158
|
env.set(Crypto, crypto);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
// Extends default crypto
|
|
162
|
+
if (Environment.default.has(Entropy)) {
|
|
163
|
+
env.set(Entropy, Environment.default.get(Entropy));
|
|
164
|
+
}
|
|
165
|
+
if (Environment.default.has(Crypto)) {
|
|
166
|
+
env.set(Crypto, Environment.default.get(Crypto));
|
|
153
167
|
}
|
|
154
168
|
});
|
|
155
169
|
}
|
|
@@ -191,8 +205,23 @@ function configureStorage(env: Environment) {
|
|
|
191
205
|
service.location = env.vars.get("storage.path", rootDirOf(env));
|
|
192
206
|
});
|
|
193
207
|
|
|
194
|
-
|
|
195
|
-
|
|
208
|
+
const shouldClear = env.vars.get("storage.clear", false);
|
|
209
|
+
let storageDriver = config.storageDriver ?? env.vars.string("storage.driver") ?? "file";
|
|
210
|
+
|
|
211
|
+
// fallback 'file' when storageDriver is blank
|
|
212
|
+
if (storageDriver.length === 0) {
|
|
213
|
+
storageDriver = "file";
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// code is moved to StorageFactory
|
|
217
|
+
service.factory = async namespace => {
|
|
218
|
+
return await StorageFactory.create({
|
|
219
|
+
driver: storageDriver,
|
|
220
|
+
rootDir: service.location ?? ".",
|
|
221
|
+
namespace,
|
|
222
|
+
clear: shouldClear,
|
|
223
|
+
});
|
|
224
|
+
};
|
|
196
225
|
|
|
197
226
|
service.resolve = (...paths) => resolve(rootDirOf(env), ...paths);
|
|
198
227
|
}
|
|
@@ -310,7 +310,7 @@ class NodeJsHttpRequest extends Request {
|
|
|
310
310
|
} as RequestInit;
|
|
311
311
|
|
|
312
312
|
if (method !== "GET" && method !== "HEAD") {
|
|
313
|
-
init.body = IncomingMessage.toWeb(message) as ReadableStream;
|
|
313
|
+
init.body = IncomingMessage.toWeb(message) as unknown as ReadableStream;
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
super(url, init);
|