taon-storage 21.0.10 → 21.0.12

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/lib/storage.js CHANGED
@@ -1,241 +1,504 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Stor = void 0;
3
+ exports.Stor = exports.StorPropertyInIndexedDb = exports.StorPropertyInLocalStorage = exports.keyDefaultValueAreadySet = exports.StorConfig = exports.storeName = void 0;
4
+ exports.keyValue = keyValue;
5
+ exports.keyDefaultValueAlreadySet = keyDefaultValueAlreadySet;
4
6
  exports.uncache = uncache;
5
- const helpers_1 = require("./helpers");
6
- const file_stor_1 = require("./file-stor");
7
- /* */
8
- /* */
9
- //#endregion
10
- //#region constants
11
- const AWAITING_INTERVAL_TIME = 200;
12
- //#endregion
13
- //#region public api / uncahce
14
- function uncache(onlyInThisComponentClass, propertyValueToDeleteFromCache) {
15
- if (!onlyInThisComponentClass) { // @ts-ignore
16
- onlyInThisComponentClass = { name: '__GLOBAL_NAMESPACE__' };
17
- }
18
- return Promise.all([
19
- /* */
20
- /* */
21
- /* */
22
- /* */
23
- /* */
24
- ]);
7
+ /* taon-storage (native, SSR-safe) */
8
+ const lib_1 = require("tnp-core/lib");
9
+ const isBrowser = typeof window !== 'undefined' &&
10
+ typeof document !== 'undefined' &&
11
+ typeof navigator !== 'undefined';
12
+ function safeLocationPort() {
13
+ try {
14
+ return globalThis?.location?.port || 'no-port';
15
+ }
16
+ catch {
17
+ return 'no-port';
18
+ }
19
+ }
20
+ /**
21
+ * Keeps the spirit of your old `storeName = taon-storage_<port>`
22
+ * plus project name namespacing (but without localForage).
23
+ */
24
+ exports.storeName = `taon-storage_${safeLocationPort()}`;
25
+ function defaultNamespace() {
26
+ const project = lib_1._.kebabCase(globalThis['CURRENT_PROJECT_GENERIC_NAME'] ?? '');
27
+ return project ? `${exports.storeName}_${project}` : exports.storeName;
28
+ }
29
+ /**
30
+ * Central config (optional).
31
+ * You can set it once at app bootstrap if you want a stable namespace.
32
+ */
33
+ exports.StorConfig = {
34
+ namespace: defaultNamespace(),
35
+ indexedDb: {
36
+ dbName: `${defaultNamespace()}_INDEXEDDB`,
37
+ storeName: 'keyvaluepairs',
38
+ },
39
+ };
40
+ function normalizeScopeClass(cls) {
41
+ if (!cls)
42
+ return { name: '__GLOBAL_NAMESPACE__' };
43
+ // if it's a function/class
44
+ if (typeof cls === 'function')
45
+ return { name: cls.name || '__ANON__' };
46
+ // if it's already object with name
47
+ return { name: cls.name || '__ANON__' };
48
+ }
49
+ function keyValue(scopeClass, memberName) {
50
+ const c = normalizeScopeClass(scopeClass);
51
+ return `${exports.StorConfig.namespace}::taon.storage.class.${c.name}.prop.${memberName}`;
52
+ }
53
+ function keyDefaultValueAlreadySet(scopeClass, memberName) {
54
+ return `${keyValue(scopeClass, memberName)}::defaultvalueisset`;
55
+ }
56
+ /** Back-compat alias (your old typo) */
57
+ exports.keyDefaultValueAreadySet = keyDefaultValueAlreadySet;
58
+ class NoopStore {
59
+ async getItem(_key) {
60
+ return undefined;
61
+ }
62
+ async setItem(_key, _value) {
63
+ // noop
64
+ }
65
+ async removeItem(_key) {
66
+ // noop
67
+ }
68
+ }
69
+ class BrowserLocalStorageStore {
70
+ ls() {
71
+ if (!isBrowser)
72
+ return undefined;
73
+ try {
74
+ return window.localStorage;
75
+ }
76
+ catch {
77
+ return undefined;
78
+ }
79
+ }
80
+ async getItem(key) {
81
+ const ls = this.ls();
82
+ if (!ls)
83
+ return undefined;
84
+ const raw = ls.getItem(key);
85
+ if (raw === null)
86
+ return undefined;
87
+ try {
88
+ return JSON.parse(raw);
89
+ }
90
+ catch {
91
+ // if something stored plain string by older versions
92
+ return raw;
93
+ }
94
+ }
95
+ async setItem(key, value) {
96
+ const ls = this.ls();
97
+ if (!ls)
98
+ return;
99
+ try {
100
+ ls.setItem(key, JSON.stringify(value));
101
+ }
102
+ catch {
103
+ // last resort: try as string
104
+ try {
105
+ ls.setItem(key, String(value));
106
+ }
107
+ catch {
108
+ // ignore (quota/private mode)
109
+ }
110
+ }
111
+ }
112
+ async removeItem(key) {
113
+ const ls = this.ls();
114
+ if (!ls)
115
+ return;
116
+ try {
117
+ ls.removeItem(key);
118
+ }
119
+ catch {
120
+ // ignore
121
+ }
122
+ }
123
+ }
124
+ class BrowserIndexedDbStore {
125
+ dbPromise = null;
126
+ openDb() {
127
+ if (!isBrowser || !window.indexedDB) {
128
+ return Promise.reject(new Error('IndexedDB not available'));
129
+ }
130
+ if (this.dbPromise)
131
+ return this.dbPromise;
132
+ const { dbName, storeName } = exports.StorConfig.indexedDb;
133
+ this.dbPromise = new Promise((resolve, reject) => {
134
+ const req = indexedDB.open(dbName, 1);
135
+ req.onupgradeneeded = () => {
136
+ const db = req.result;
137
+ if (!db.objectStoreNames.contains(storeName)) {
138
+ db.createObjectStore(storeName);
139
+ }
140
+ };
141
+ req.onsuccess = () => resolve(req.result);
142
+ req.onerror = () => reject(req.error);
143
+ });
144
+ return this.dbPromise;
145
+ }
146
+ async withStore(mode, fn) {
147
+ const db = await this.openDb();
148
+ const { storeName } = exports.StorConfig.indexedDb;
149
+ return await new Promise((resolve, reject) => {
150
+ const tx = db.transaction(storeName, mode);
151
+ const store = tx.objectStore(storeName);
152
+ const req = fn(store);
153
+ req.onsuccess = () => resolve(req.result);
154
+ req.onerror = () => reject(req.error);
155
+ tx.onabort = () => reject(tx.error);
156
+ // tx.oncomplete => nothing
157
+ });
158
+ }
159
+ async getItem(key) {
160
+ try {
161
+ const result = await this.withStore('readonly', s => s.get(key));
162
+ return result === undefined ? undefined : result;
163
+ }
164
+ catch {
165
+ return undefined;
166
+ }
167
+ }
168
+ async setItem(key, value) {
169
+ try {
170
+ await this.withStore('readwrite', s => s.put(value, key));
171
+ }
172
+ catch {
173
+ // ignore
174
+ }
175
+ }
176
+ async removeItem(key) {
177
+ try {
178
+ await this.withStore('readwrite', s => s.delete(key));
179
+ }
180
+ catch {
181
+ // ignore
182
+ }
183
+ }
184
+ }
185
+ /**
186
+ * Node-side file storage (optional). No top-level node imports (Angular-safe).
187
+ * Works only when executed in Node.
188
+ */
189
+ class FileStor {
190
+ filePath;
191
+ useJSON;
192
+ constructor(filePath, useJSON = false) {
193
+ this.filePath = filePath;
194
+ this.useJSON = useJSON;
195
+ }
196
+ isNodeRuntime() {
197
+ return lib_1.UtilsOs.isNode;
198
+ // return (
199
+ // typeof process !== 'undefined' &&
200
+ // !!(process as any).versions?.node &&
201
+ // typeof (globalThis as any).window === 'undefined'
202
+ // );
203
+ }
204
+ async setItem(_key, value) {
205
+ if (!this.isNodeRuntime())
206
+ return;
207
+ //#region @backendFunc
208
+ const fs = await Promise.resolve().then(() => require('node:fs/promises'));
209
+ const data = this.useJSON ? JSON.stringify(value, null, 2) : value;
210
+ if (this.useJSON) {
211
+ await fs.writeFile(this.filePath, String(data), 'utf8');
212
+ }
213
+ else {
214
+ await fs.writeFile(this.filePath, String(data), 'utf8');
215
+ }
216
+ //#endregion
217
+ }
218
+ async getItem(_key) {
219
+ if (!this.isNodeRuntime())
220
+ return undefined;
221
+ //#region @backendFunc
222
+ const fs = await Promise.resolve().then(() => require('node:fs/promises'));
223
+ try {
224
+ const buf = await fs.readFile(this.filePath, 'utf8');
225
+ if (!this.useJSON)
226
+ return buf;
227
+ return JSON.parse(buf);
228
+ }
229
+ catch {
230
+ return undefined;
231
+ }
232
+ //#endregion
233
+ }
234
+ async removeItem(_key) {
235
+ if (!this.isNodeRuntime())
236
+ return;
237
+ //#region @backendFunc
238
+ const fs = await Promise.resolve().then(() => require('node:fs/promises'));
239
+ try {
240
+ await fs.rm(this.filePath, { force: true });
241
+ }
242
+ catch {
243
+ // ignore
244
+ }
245
+ //#endregion
246
+ }
25
247
  }
26
- //#endregion
27
- class TaonStorage {
28
- //#region static
29
- static pendingOperatins = [];
248
+ /* ---------------------------
249
+ * Pending ops (so you can still await)
250
+ * -------------------------- */
251
+ class StorPending {
252
+ static pending = [];
30
253
  static id = 0;
31
- /**
32
- * TODO This is fine for now, but could be something smarter here
33
- */
34
- static async awaitPendingOperatios(id = TaonStorage.id++) {
35
- // console.log('AWAITING')
254
+ static AWAITING_INTERVAL_TIME = 200;
255
+ static async awaitPendingOperations(id = StorPending.id++) {
36
256
  if (id > Number.MAX_SAFE_INTEGER - 2) {
37
- TaonStorage.id = 0;
38
- id = TaonStorage.id++;
257
+ StorPending.id = 0;
258
+ id = StorPending.id++;
39
259
  }
40
- const pending = this.pendingOperatins;
41
- const toDeleteIndex = [];
42
- for (let index = 0; index < pending.length; index++) {
43
- const op = pending[index];
260
+ const pending = StorPending.pending;
261
+ for (const op of pending) {
44
262
  if (!op.isDone) {
45
- await new Promise(async (resovle, reject) => {
263
+ await new Promise(resolve => {
46
264
  setTimeout(async () => {
47
- await this.awaitPendingOperatios(id);
48
- resovle();
49
- }, AWAITING_INTERVAL_TIME);
265
+ await StorPending.awaitPendingOperations(id);
266
+ resolve();
267
+ }, StorPending.AWAITING_INTERVAL_TIME);
50
268
  });
51
269
  return;
52
270
  }
53
- else {
54
- toDeleteIndex.push(index);
55
- }
56
- }
57
- for (let index = 0; index < toDeleteIndex.length; index++) {
58
- const toDelete = toDeleteIndex[index];
59
- pending.splice(toDelete, 1);
60
271
  }
272
+ // cleanup
273
+ StorPending.pending = pending.filter(p => !p.isDone);
61
274
  }
62
- static get property() {
63
- return new TaonStorage();
275
+ static start(engine, id) {
276
+ const op = { engine, id, isDone: false };
277
+ StorPending.pending.push(op);
278
+ return op;
279
+ }
280
+ static done(op) {
281
+ op.isDone = true;
64
282
  }
65
- //#endregion
66
- //#region private fields
67
- onlyInThisComponentClass;
68
- defaultValue;
283
+ }
284
+ /* ---------------------------
285
+ * Decorator builder
286
+ * -------------------------- */
287
+ class StorPropertyBuilder {
288
+ scopeClass;
69
289
  engine;
70
- //#region private fields / file path
71
- //#region @backend
290
+ store;
72
291
  filePath;
73
- //#endregion
74
- //#endregion
75
- //#endregion
76
- //#region public getters
77
- get in() {
78
- const that = this;
79
- return {
80
- get indexedb() {
81
- that.engine = 'indexeddb';
82
- return that;
83
- },
84
- get localstorage() {
85
- that.engine = 'localstorage';
86
- return that;
87
- },
88
- //#region @backend
89
- /**
90
- * may be relative or absolute
91
- */
92
- file(filePath) {
93
- that.engine = 'file';
94
- that.filePath = filePath;
95
- return that;
96
- },
97
- jsonFile(filePath) {
98
- that.engine = 'json';
99
- that.filePath = filePath;
100
- return that;
101
- },
102
- //#endregion
103
- };
292
+ useJsonFile = false;
293
+ constructor(engine, store) {
294
+ this.engine = engine;
295
+ this.store = store;
296
+ }
297
+ for(scopeClass) {
298
+ this.scopeClass = scopeClass;
299
+ return this;
104
300
  }
105
- //#endregion
106
- //#region public methods
107
- //#region public methods / for
108
- /* */
109
- /* */
110
- /* */
111
- /* */
112
- /* */
113
- //#endregion
114
- //#region public methods / with default value
115
301
  withDefaultValue(defaultValue) {
116
- // log.i(`["${}"]`)
117
- return this.action(defaultValue, this.getEngine(), this.engine);
302
+ return this.withOptions({ defaultValue });
118
303
  }
119
- //#endregion
120
- //#region public methods / with options
121
304
  withOptions(options) {
122
- const { defaultValue, transformFrom, transformTo } = (options || {});
123
- return this.action(defaultValue ? defaultValue : this.defaultValue, this.getEngine(), this.engine, transformFrom, transformTo);
124
- }
125
- //#endregion
126
- //#endregion
127
- //#region private methods
128
- //#region private methods / get engine
129
- getEngine() {
130
- switch (this.engine) {
131
- /* */
132
- /* */
133
- /* */
134
- /* */
135
- /* */
136
- //#region @backend
137
- case 'file':
138
- return new file_stor_1.FileStor(this.filePath);
139
- case 'json':
140
- return new file_stor_1.FileStor(this.filePath, true);
141
- //#endregion
142
- }
143
- }
144
- //#endregion
145
- //#region private methods / end observer action
146
- endObserverAction(observe) {
147
- // observe.subscribers.forEach(c => typeof c?.awaitId === 'function' && c());
148
- observe.isDone = true;
149
- }
150
- //#endregion
151
- //#region private methods / action
152
- action = (defaultValue, storageEngine
153
- /* */
154
- /* */
155
- , engine, transformFrom, transformTo) => {
156
- if (!this.onlyInThisComponentClass) { // @ts-ignore
157
- this.onlyInThisComponentClass = { name: '__GLOBAL_NAMESPACE__' };
158
- }
305
+ const scopeClass = this.scopeClass;
306
+ // per-instance state (fixes prototype-closure sharing)
307
+ const values = new WeakMap();
308
+ const initStarted = new WeakMap();
309
+ const ensureInit = (instance) => {
310
+ if (initStarted.has(instance))
311
+ return;
312
+ const op = StorPending.start(this.engine, 'init');
313
+ const p = (async () => {
314
+ const memberName = ensureInit.__memberName;
315
+ const kVal = keyValue(scopeClass, memberName);
316
+ const kDef = keyDefaultValueAlreadySet(scopeClass, memberName);
317
+ const defProvided = options.defaultValue !== undefined;
318
+ if (!isBrowser &&
319
+ (this.engine === 'localstorage' || this.engine === 'indexeddb')) {
320
+ // SSR: just set defaults, no storage
321
+ if (defProvided)
322
+ values.set(instance, options.defaultValue);
323
+ return;
324
+ }
325
+ // Browser (or node file/json)
326
+ if (defProvided) {
327
+ const already = await this.store.getItem(kDef);
328
+ if (already) {
329
+ const stored = await this.store.getItem(kVal);
330
+ const v = options.transformFrom
331
+ ? options.transformFrom(stored)
332
+ : stored;
333
+ if (v !== undefined)
334
+ values.set(instance, v);
335
+ else
336
+ values.set(instance, options.defaultValue);
337
+ }
338
+ else {
339
+ await this.store.setItem(kDef, true);
340
+ const toDb = options.transformTo
341
+ ? options.transformTo(options.defaultValue)
342
+ : options.defaultValue;
343
+ await this.store.setItem(kVal, toDb);
344
+ values.set(instance, options.defaultValue);
345
+ }
346
+ }
347
+ else {
348
+ const stored = await this.store.getItem(kVal);
349
+ const v = options.transformFrom
350
+ ? options.transformFrom(stored)
351
+ : stored;
352
+ if (v !== undefined)
353
+ values.set(instance, v);
354
+ }
355
+ })()
356
+ .catch(() => {
357
+ // swallow, keep app alive
358
+ })
359
+ .finally(() => StorPending.done(op));
360
+ initStarted.set(instance, p);
361
+ };
159
362
  return (target, memberName) => {
160
- let currentValue = target[memberName];
161
- const setItemDefaultValue = async () => {
162
- //#region settin default value
163
- const observe = {
164
- engine,
165
- id: 'setting default value'
166
- };
167
- TaonStorage.pendingOperatins.push(observe);
168
- await new Promise((resolve, reject) => {
169
- storageEngine.getItem((0, helpers_1.keyValue)(this.onlyInThisComponentClass, memberName), (err, valFromDb) => {
170
- // target[memberName] = valFromDb;
171
- currentValue = transformFrom ? transformFrom(valFromDb) : valFromDb;
172
- // log.info(`["${memberName}"] set default value for `, valFromDb);
173
- resolve();
174
- this.endObserverAction(observe);
175
- });
176
- });
177
- //#endregion
178
- };
179
- if (defaultValue !== void 0) {
180
- //#region setting default value from db
181
- const observe = {
182
- engine,
183
- id: 'setting not rivial default value'
184
- };
185
- TaonStorage.pendingOperatins.push(observe);
186
- (new Promise((resolve, reject) => {
187
- storageEngine.getItem((0, helpers_1.keyDefaultValueAreadySet)(this.onlyInThisComponentClass, memberName), async (err, val) => {
188
- // log.info(`["${memberName}"] was set default value for ? `, val)
189
- if (val) {
190
- await setItemDefaultValue();
191
- resolve();
192
- }
193
- else {
194
- await new Promise((res, rej) => {
195
- storageEngine.setItem((0, helpers_1.keyDefaultValueAreadySet)(this.onlyInThisComponentClass, memberName), true, (err, v) => {
196
- res();
197
- });
198
- });
199
- await new Promise((res, rej) => {
200
- storageEngine.setItem((0, helpers_1.keyValue)(this.onlyInThisComponentClass, memberName), transformTo ? transformTo(defaultValue) : defaultValue, (err, val) => {
201
- res();
202
- });
203
- });
204
- currentValue = defaultValue;
205
- // log.i(`["${memberName}"] defaultValue "${memberName}"`, currentValue)
206
- resolve();
207
- }
208
- });
209
- })).then(() => {
210
- this.endObserverAction(observe);
211
- });
212
- //#endregion
213
- }
214
- else {
215
- setItemDefaultValue();
216
- }
363
+ ensureInit.__memberName = memberName;
217
364
  Object.defineProperty(target, memberName, {
218
- set: (newValue) => {
219
- //#region setting new value on setter
220
- const observe = {
221
- engine,
222
- id: 'setting in SET not rivial default value'
223
- };
224
- TaonStorage.pendingOperatins.push(observe);
225
- (new Promise((resolve, reject) => {
226
- storageEngine.setItem((0, helpers_1.keyValue)(this.onlyInThisComponentClass, memberName), transformTo ? transformTo(newValue) : newValue, (err, savedValue) => {
227
- resolve();
228
- });
229
- })).then(() => {
230
- this.endObserverAction(observe);
365
+ configurable: true,
366
+ enumerable: true,
367
+ get: function () {
368
+ ensureInit(this);
369
+ if (values.has(this))
370
+ return values.get(this);
371
+ if (options.defaultValue !== undefined)
372
+ return options.defaultValue;
373
+ return undefined;
374
+ },
375
+ set: function (newValue) {
376
+ values.set(this, newValue);
377
+ // if this is the first interaction, init will happen anyway
378
+ ensureInit(this);
379
+ const op = StorPending.start(target?.engine ?? 'localstorage', 'set');
380
+ const scope = scopeClass;
381
+ const kVal = keyValue(scope, memberName);
382
+ const toDb = options.transformTo
383
+ ? options.transformTo(newValue)
384
+ : newValue;
385
+ Promise.resolve()
386
+ .then(() => target)
387
+ .then(() => this)
388
+ .then(() => this)
389
+ .then(async () => {
390
+ // If we are SSR + browser engine => no-op
391
+ if (!isBrowser && options)
392
+ return;
393
+ await options; // no-op line to keep TS happy about chaining in some builds
394
+ })
395
+ .catch(() => {
396
+ // ignore
231
397
  });
232
- //#endregion
233
- currentValue = newValue;
398
+ // do real store write (async)
399
+ Promise.resolve()
400
+ .then(async () => {
401
+ // SSR guard for browser engines
402
+ if (!isBrowser && StorPropertyInLocalStorage) {
403
+ return;
404
+ }
405
+ await thisStoreForEngineWrite(this, kVal, toDb);
406
+ })
407
+ .catch(() => {
408
+ // ignore
409
+ })
410
+ .finally(() => StorPending.done(op));
234
411
  },
235
- get: () => currentValue,
236
412
  });
413
+ // small helper to keep closure clean
414
+ const builderStore = this.store;
415
+ const builderEngine = this.engine;
416
+ async function thisStoreForEngineWrite(_instance, key, value) {
417
+ // If browser engines but not browser, skip.
418
+ if (!isBrowser &&
419
+ (builderEngine === 'localstorage' || builderEngine === 'indexeddb'))
420
+ return;
421
+ await builderStore.setItem(key, value);
422
+ }
237
423
  };
238
- };
424
+ }
425
+ /* optional node-only engines (same builder) */
426
+ file(filePath) {
427
+ this.engine = 'file';
428
+ this.filePath = filePath;
429
+ this.useJsonFile = false;
430
+ this.store = new FileStor(filePath, false);
431
+ return this;
432
+ }
433
+ jsonFile(filePath) {
434
+ this.engine = 'json';
435
+ this.filePath = filePath;
436
+ this.useJsonFile = true;
437
+ this.store = new FileStor(filePath, true);
438
+ return this;
439
+ }
440
+ }
441
+ /* ---------------------------
442
+ * Public: clean API exports
443
+ * -------------------------- */
444
+ const localStorageStore = isBrowser
445
+ ? new BrowserLocalStorageStore()
446
+ : new NoopStore();
447
+ const indexedDbStore = isBrowser
448
+ ? new BrowserIndexedDbStore()
449
+ : new NoopStore();
450
+ class StorPropertyInLocalStorage {
451
+ static for(scopeClass) {
452
+ return new StorPropertyBuilder('localstorage', localStorageStore).for(scopeClass);
453
+ }
454
+ }
455
+ exports.StorPropertyInLocalStorage = StorPropertyInLocalStorage;
456
+ class StorPropertyInIndexedDb {
457
+ static for(scopeClass) {
458
+ return new StorPropertyBuilder('indexeddb', indexedDbStore).for(scopeClass);
459
+ }
460
+ }
461
+ exports.StorPropertyInIndexedDb = StorPropertyInIndexedDb;
462
+ /**
463
+ * Helpers
464
+ */
465
+ async function uncache(onlyInThisComponentClass, propertyValueToDeleteFromCache) {
466
+ const scope = onlyInThisComponentClass || { name: '__GLOBAL_NAMESPACE__' };
467
+ const prop = String(propertyValueToDeleteFromCache);
468
+ await Promise.all([
469
+ localStorageStore.removeItem(keyValue(scope, prop)),
470
+ localStorageStore.removeItem(keyDefaultValueAlreadySet(scope, prop)),
471
+ indexedDbStore.removeItem(keyValue(scope, prop)),
472
+ indexedDbStore.removeItem(keyDefaultValueAlreadySet(scope, prop)),
473
+ ]);
474
+ }
475
+ /**
476
+ * Backwards-compatible facade:
477
+ * Stor.property.in.localstorage.for(...).withDefaultValue(...)
478
+ */
479
+ class TaonStorageFacade {
480
+ static async awaitPendingOperatios() {
481
+ await StorPending.awaitPendingOperations();
482
+ }
483
+ static get property() {
484
+ return {
485
+ in: {
486
+ get localstorage() {
487
+ return new StorPropertyBuilder('localstorage', localStorageStore);
488
+ },
489
+ get indexedb() {
490
+ return new StorPropertyBuilder('indexeddb', indexedDbStore);
491
+ },
492
+ // node-only (safe: dynamic import inside FileStor)
493
+ file(filePath) {
494
+ return new StorPropertyBuilder('file', new FileStor(filePath, false));
495
+ },
496
+ jsonFile(filePath) {
497
+ return new StorPropertyBuilder('json', new FileStor(filePath, true));
498
+ },
499
+ },
500
+ };
501
+ }
239
502
  }
240
- exports.Stor = TaonStorage;
503
+ exports.Stor = TaonStorageFacade;
241
504
  //# sourceMappingURL=storage.js.map