@converse/skeletor 3.1.5 → 3.1.6
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/CHANGES.md +12 -0
- package/dist/skeletor.d.ts +14 -1
- package/dist/skeletor.esm.js +13 -1
- package/dist/skeletor.esm.js.map +1 -1
- package/dist/skeletor.js +13 -1
- package/dist/skeletor.js.map +1 -1
- package/dist/skeletor.min.js +1 -1
- package/dist/skeletor.node.d.ts +956 -0
- package/dist/skeletor.node.js +14 -1
- package/dist/skeletor.node.mjs +14 -1
- package/package.json +6 -4
- package/src/drivers/nodeSQLiteStorage.ts +1 -0
- package/src/index.ts +1 -0
- package/src/storage.ts +22 -2
package/dist/skeletor.node.js
CHANGED
|
@@ -8024,7 +8024,7 @@ class PersistentStorage {
|
|
|
8024
8024
|
throw new Error("Skeletor.storage: the 'node' storage type is only available in Node.js builds. " +
|
|
8025
8025
|
"Import from '@converse/skeletor/node' instead of '@converse/skeletor'.");
|
|
8026
8026
|
}
|
|
8027
|
-
this.store = new NodeSQLiteStorage(this.name);
|
|
8027
|
+
this.store = new NodeSQLiteStorage(this.name, PersistentStorage.nodeStorageDir ?? undefined);
|
|
8028
8028
|
if (batchedWrites) {
|
|
8029
8029
|
this.store.debouncedSetItems = mergebounce((items) => this.store.setItems(items), 50, {
|
|
8030
8030
|
'promise': true,
|
|
@@ -8228,6 +8228,18 @@ class PersistentStorage {
|
|
|
8228
8228
|
// node-only driver (and its `node:sqlite` import) never enters the browser
|
|
8229
8229
|
// bundle; the `@converse/skeletor/node` entry sets it.
|
|
8230
8230
|
PersistentStorage.nodeStorage = null;
|
|
8231
|
+
/**
|
|
8232
|
+
* Directory the `'node'` store type writes its database files to. The driver's
|
|
8233
|
+
* own default is relative, so it resolves against `process.cwd()` and a process
|
|
8234
|
+
* started from two directories ends up with two separate sets of state. Set an
|
|
8235
|
+
* absolute path (`$XDG_STATE_HOME/<app>`, say) to pin it. Left `null`, the
|
|
8236
|
+
* driver's default applies.
|
|
8237
|
+
*
|
|
8238
|
+
* Only the `'node'` string store type reads this; passing a driver instance to
|
|
8239
|
+
* the constructor means you've already chosen a directory yourself.
|
|
8240
|
+
* @public
|
|
8241
|
+
*/
|
|
8242
|
+
PersistentStorage.nodeStorageDir = null;
|
|
8231
8243
|
PersistentStorage.sessionStorageInitialized = localForage.defineDriver(sessionStorageWrapper);
|
|
8232
8244
|
PersistentStorage.localForage = localForage;
|
|
8233
8245
|
|
|
@@ -8235,6 +8247,7 @@ const DEFAULT_BASE_DIR = '.skeletor-storage';
|
|
|
8235
8247
|
/**
|
|
8236
8248
|
* SQLite-backed implementation of StorageDriver.
|
|
8237
8249
|
* Uses a single table with key/value columns, storing values as JSON strings.
|
|
8250
|
+
* @public
|
|
8238
8251
|
*/
|
|
8239
8252
|
class NodeSQLiteStorage {
|
|
8240
8253
|
ready() {
|
package/dist/skeletor.node.mjs
CHANGED
|
@@ -8020,7 +8020,7 @@ class PersistentStorage {
|
|
|
8020
8020
|
throw new Error("Skeletor.storage: the 'node' storage type is only available in Node.js builds. " +
|
|
8021
8021
|
"Import from '@converse/skeletor/node' instead of '@converse/skeletor'.");
|
|
8022
8022
|
}
|
|
8023
|
-
this.store = new NodeSQLiteStorage(this.name);
|
|
8023
|
+
this.store = new NodeSQLiteStorage(this.name, PersistentStorage.nodeStorageDir ?? undefined);
|
|
8024
8024
|
if (batchedWrites) {
|
|
8025
8025
|
this.store.debouncedSetItems = mergebounce((items) => this.store.setItems(items), 50, {
|
|
8026
8026
|
'promise': true,
|
|
@@ -8224,6 +8224,18 @@ class PersistentStorage {
|
|
|
8224
8224
|
// node-only driver (and its `node:sqlite` import) never enters the browser
|
|
8225
8225
|
// bundle; the `@converse/skeletor/node` entry sets it.
|
|
8226
8226
|
PersistentStorage.nodeStorage = null;
|
|
8227
|
+
/**
|
|
8228
|
+
* Directory the `'node'` store type writes its database files to. The driver's
|
|
8229
|
+
* own default is relative, so it resolves against `process.cwd()` and a process
|
|
8230
|
+
* started from two directories ends up with two separate sets of state. Set an
|
|
8231
|
+
* absolute path (`$XDG_STATE_HOME/<app>`, say) to pin it. Left `null`, the
|
|
8232
|
+
* driver's default applies.
|
|
8233
|
+
*
|
|
8234
|
+
* Only the `'node'` string store type reads this; passing a driver instance to
|
|
8235
|
+
* the constructor means you've already chosen a directory yourself.
|
|
8236
|
+
* @public
|
|
8237
|
+
*/
|
|
8238
|
+
PersistentStorage.nodeStorageDir = null;
|
|
8227
8239
|
PersistentStorage.sessionStorageInitialized = localForage.defineDriver(sessionStorageWrapper);
|
|
8228
8240
|
PersistentStorage.localForage = localForage;
|
|
8229
8241
|
|
|
@@ -8231,6 +8243,7 @@ const DEFAULT_BASE_DIR = '.skeletor-storage';
|
|
|
8231
8243
|
/**
|
|
8232
8244
|
* SQLite-backed implementation of StorageDriver.
|
|
8233
8245
|
* Uses a single table with key/value columns, storing values as JSON strings.
|
|
8246
|
+
* @public
|
|
8234
8247
|
*/
|
|
8235
8248
|
class NodeSQLiteStorage {
|
|
8236
8249
|
ready() {
|
package/package.json
CHANGED
|
@@ -9,18 +9,19 @@
|
|
|
9
9
|
"browser": "dist/skeletor.js",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"types": "./dist/skeletor.d.ts",
|
|
13
12
|
"node": {
|
|
13
|
+
"types": "./dist/skeletor.node.d.ts",
|
|
14
14
|
"require": "./dist/skeletor.node.js",
|
|
15
15
|
"import": "./dist/skeletor.node.mjs"
|
|
16
16
|
},
|
|
17
17
|
"default": {
|
|
18
|
+
"types": "./dist/skeletor.d.ts",
|
|
18
19
|
"import": "./dist/skeletor.esm.js",
|
|
19
20
|
"require": "./dist/skeletor.js"
|
|
20
21
|
}
|
|
21
22
|
},
|
|
22
23
|
"./node": {
|
|
23
|
-
"types": "./dist/skeletor.d.ts",
|
|
24
|
+
"types": "./dist/skeletor.node.d.ts",
|
|
24
25
|
"require": "./dist/skeletor.node.js",
|
|
25
26
|
"import": "./dist/skeletor.node.mjs"
|
|
26
27
|
}
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
"contributors": [
|
|
39
40
|
"JC Brand"
|
|
40
41
|
],
|
|
41
|
-
"version": "3.1.
|
|
42
|
+
"version": "3.1.6",
|
|
42
43
|
"engines": {
|
|
43
44
|
"node": ">=22.0.0"
|
|
44
45
|
},
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
},
|
|
50
51
|
"scripts": {
|
|
51
52
|
"build": "npm run prebuild && npm run build:declarations && rollup -c",
|
|
52
|
-
"build:declarations": "npm run build:types && api-extractor run --local && rm -rf dist/defs",
|
|
53
|
+
"build:declarations": "npm run build:types && api-extractor run --local && api-extractor run --local -c api-extractor.node.json && rm -rf dist/defs",
|
|
53
54
|
"build:types": "tsc -p tsconfig.declarations.json",
|
|
54
55
|
"check": "npm run check:types && npm run test && npm run test:node && npm run lint",
|
|
55
56
|
"check:types": "tsc --noEmit",
|
|
@@ -74,6 +75,7 @@
|
|
|
74
75
|
"dist/skeletor.node.mjs",
|
|
75
76
|
"dist/skeletor.d.ts",
|
|
76
77
|
"dist/skeletor.d.ts.map",
|
|
78
|
+
"dist/skeletor.node.d.ts",
|
|
77
79
|
"src/**/*.ts"
|
|
78
80
|
],
|
|
79
81
|
"dependencies": {
|
|
@@ -9,6 +9,7 @@ const DEFAULT_BASE_DIR = '.skeletor-storage';
|
|
|
9
9
|
/**
|
|
10
10
|
* SQLite-backed implementation of StorageDriver.
|
|
11
11
|
* Uses a single table with key/value columns, storing values as JSON strings.
|
|
12
|
+
* @public
|
|
12
13
|
*/
|
|
13
14
|
export class NodeSQLiteStorage implements StorageDriver {
|
|
14
15
|
private db: DatabaseSync;
|
package/src/index.ts
CHANGED
|
@@ -63,6 +63,7 @@ export { noConflict, Collection, EventEmitter, Model, PersistentStorage, Browser
|
|
|
63
63
|
export { getStorage } from './helpers';
|
|
64
64
|
|
|
65
65
|
export type { StorageDriver, StoreType } from './drivers/types';
|
|
66
|
+
export type { NodeStorageConstructor } from './storage';
|
|
66
67
|
export type {
|
|
67
68
|
ClassConstructor,
|
|
68
69
|
CollectionOptions,
|
package/src/storage.ts
CHANGED
|
@@ -36,8 +36,13 @@ const registered = new WeakSet<PersistentStorage>();
|
|
|
36
36
|
/**
|
|
37
37
|
* Constructor for a Node.js-only storage driver. Registered by the
|
|
38
38
|
* `@converse/skeletor/node` entry point via {@link PersistentStorage.nodeStorage}.
|
|
39
|
+
* @public
|
|
39
40
|
*/
|
|
40
|
-
type NodeStorageConstructor = new (
|
|
41
|
+
export type NodeStorageConstructor = new (
|
|
42
|
+
name: string,
|
|
43
|
+
storageDir?: string,
|
|
44
|
+
inMemory?: boolean,
|
|
45
|
+
) => StorageDriver;
|
|
41
46
|
|
|
42
47
|
/**
|
|
43
48
|
* @public
|
|
@@ -60,6 +65,19 @@ class PersistentStorage {
|
|
|
60
65
|
// bundle; the `@converse/skeletor/node` entry sets it.
|
|
61
66
|
static nodeStorage: NodeStorageConstructor | null = null;
|
|
62
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Directory the `'node'` store type writes its database files to. The driver's
|
|
70
|
+
* own default is relative, so it resolves against `process.cwd()` and a process
|
|
71
|
+
* started from two directories ends up with two separate sets of state. Set an
|
|
72
|
+
* absolute path (`$XDG_STATE_HOME/<app>`, say) to pin it. Left `null`, the
|
|
73
|
+
* driver's default applies.
|
|
74
|
+
*
|
|
75
|
+
* Only the `'node'` string store type reads this; passing a driver instance to
|
|
76
|
+
* the constructor means you've already chosen a directory yourself.
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
static nodeStorageDir: string | null = null;
|
|
80
|
+
|
|
63
81
|
/** Register a storage instance with a weak reference. @public */
|
|
64
82
|
static register(instance: PersistentStorage): void {
|
|
65
83
|
if (registered.has(instance)) return;
|
|
@@ -128,7 +146,7 @@ class PersistentStorage {
|
|
|
128
146
|
"Import from '@converse/skeletor/node' instead of '@converse/skeletor'.",
|
|
129
147
|
);
|
|
130
148
|
}
|
|
131
|
-
this.store = new NodeSQLiteStorage(this.name);
|
|
149
|
+
this.store = new NodeSQLiteStorage(this.name, PersistentStorage.nodeStorageDir ?? undefined);
|
|
132
150
|
if (batchedWrites) {
|
|
133
151
|
this.store.debouncedSetItems = mergebounce((items: Record<string, any>) => this.store.setItems!(items), 50, {
|
|
134
152
|
'promise': true,
|
|
@@ -155,9 +173,11 @@ class PersistentStorage {
|
|
|
155
173
|
async clear(): Promise<void> {
|
|
156
174
|
await this.storeInitialized;
|
|
157
175
|
await this.store.removeItem(this.name).catch((e) => console.error(e));
|
|
176
|
+
|
|
158
177
|
const re = new RegExp(`^${this.name}-`);
|
|
159
178
|
const keys = await this.store.keys();
|
|
160
179
|
const removed_keys = keys.filter((k) => re.test(k));
|
|
180
|
+
|
|
161
181
|
await Promise.all(removed_keys.map((k) => this.store.removeItem(k).catch((e) => console.error(e))));
|
|
162
182
|
}
|
|
163
183
|
|