taon-storage 21.0.27 → 21.0.30
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/browser/fesm2022/taon-storage-browser.mjs +154 -334
- package/browser/fesm2022/taon-storage-browser.mjs.map +1 -1
- package/browser/package.json +1 -1
- package/browser/types/taon-storage-browser.d.ts +21 -77
- package/browser-prod/fesm2022/taon-storage-browser-prod.mjs +146 -333
- package/browser-prod/fesm2022/taon-storage-browser-prod.mjs.map +1 -1
- package/browser-prod/package.json +1 -1
- package/browser-prod/types/taon-storage-browser-prod.d.ts +20 -78
- package/browser-prod.split-namespaces.json +18 -2
- package/lib/build-info._auto-generated_.d.ts +1 -3
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/taon-stor.d.ts +51 -0
- package/lib/taon-stor.js +316 -0
- package/lib/taon-stor.js.map +1 -0
- package/lib/taon-stor.test.d.ts +1 -0
- package/lib/taon-stor.test.js +45 -0
- package/lib/taon-stor.test.js.map +1 -0
- package/lib-prod/build-info._auto-generated_.d.ts +1 -1
- package/lib-prod/build-info._auto-generated_.js +1 -3
- package/lib-prod/build-info._auto-generated_.js.map +1 -1
- package/lib-prod/index.d.ts +1 -1
- package/lib-prod/index.js +3 -3
- package/lib-prod/index.js.map +1 -1
- package/lib-prod/package.json +1 -1
- package/lib-prod/taon-stor.d.ts +49 -0
- package/lib-prod/taon-stor.js +306 -0
- package/lib-prod/taon-stor.js.map +1 -0
- package/lib-prod/taon-stor.test.d.ts +1 -0
- package/lib-prod/taon-stor.test.js +43 -0
- package/lib-prod/taon-stor.test.js.map +1 -0
- package/lib-prod.split-namespaces.json +18 -2
- package/package.json +1 -1
- package/websql/fesm2022/taon-storage-websql.mjs +154 -334
- package/websql/fesm2022/taon-storage-websql.mjs.map +1 -1
- package/websql/package.json +1 -1
- package/websql/types/taon-storage-websql.d.ts +21 -77
- package/websql-prod/fesm2022/taon-storage-websql-prod.mjs +146 -333
- package/websql-prod/fesm2022/taon-storage-websql-prod.mjs.map +1 -1
- package/websql-prod/package.json +1 -1
- package/websql-prod/types/taon-storage-websql-prod.d.ts +20 -78
- package/websql-prod.split-namespaces.json +18 -2
- package/lib/sample-log-cmp/sample-log-cmp.component.d.ts +0 -2
- package/lib/storage.d.ts +0 -79
- package/lib/storage.js +0 -504
- package/lib/storage.js.map +0 -1
- package/lib-prod/storage.d.ts +0 -79
- package/lib-prod/storage.js +0 -496
- package/lib-prod/storage.js.map +0 -1
- package/scss/lib/sample-log-cmp/sample-log-cmp.component.scss +0 -3
|
@@ -1,42 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { CommonModule } from '@angular/common';
|
|
4
|
-
import { _, UtilsOs } from 'tnp-core/browser';
|
|
1
|
+
import { signal } from '@angular/core';
|
|
2
|
+
import { UtilsOs, _ } from 'tnp-core/browser';
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: SampleLogCmpComponent, decorators: [{
|
|
11
|
-
type: Component,
|
|
12
|
-
args: [{ selector: 'sample-log-cmp', changeDetection: ChangeDetectionStrategy.OnPush, imports: [CommonModule], standalone: true, template: "<p>\n sample log component works!\n <img\n src=\"assets/assets-for/taon-storage/assets/shared/logo.png\"\n alt=\"logo\" height=\"200\" />\n</p>", styles: [":host{display:block}\n"] }]
|
|
13
|
-
}] });
|
|
14
|
-
|
|
15
|
-
/* taon-storage (native, SSR-safe) */
|
|
16
|
-
const isBrowser = typeof window !== 'undefined' &&
|
|
17
|
-
typeof document !== 'undefined' &&
|
|
18
|
-
typeof navigator !== 'undefined';
|
|
19
|
-
function safeLocationPort() {
|
|
4
|
+
const isBrowser = UtilsOs.isBrowser;
|
|
5
|
+
const isNode = UtilsOs.isNode;
|
|
6
|
+
const safeLocationPort = () => {
|
|
20
7
|
try {
|
|
21
8
|
return globalThis?.location?.port || 'no-port';
|
|
22
9
|
}
|
|
23
10
|
catch {
|
|
24
11
|
return 'no-port';
|
|
25
12
|
}
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Keeps the spirit of your old `storeName = taon-storage_<port>`
|
|
29
|
-
* plus project name namespacing (but without localForage).
|
|
30
|
-
*/
|
|
13
|
+
};
|
|
31
14
|
const storeName = `taon-storage_${safeLocationPort()}`;
|
|
32
|
-
|
|
15
|
+
const defaultNamespace = () => {
|
|
33
16
|
const project = _.kebabCase(globalThis['CURRENT_PROJECT_GENERIC_NAME'] ?? '');
|
|
34
17
|
return project ? `${storeName}_${project}` : storeName;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Central config (optional).
|
|
38
|
-
* You can set it once at app bootstrap if you want a stable namespace.
|
|
39
|
-
*/
|
|
18
|
+
};
|
|
40
19
|
const StorConfig = {
|
|
41
20
|
namespace: defaultNamespace(),
|
|
42
21
|
indexedDb: {
|
|
@@ -44,7 +23,7 @@ const StorConfig = {
|
|
|
44
23
|
storeName: 'keyvaluepairs',
|
|
45
24
|
},
|
|
46
25
|
};
|
|
47
|
-
|
|
26
|
+
const normalizeScopeClass = (cls) => {
|
|
48
27
|
if (!cls)
|
|
49
28
|
return { name: '__GLOBAL_NAMESPACE__' };
|
|
50
29
|
// if it's a function/class
|
|
@@ -52,83 +31,70 @@ function normalizeScopeClass(cls) {
|
|
|
52
31
|
return { name: cls.name || '__ANON__' };
|
|
53
32
|
// if it's already object with name
|
|
54
33
|
return { name: cls.name || '__ANON__' };
|
|
55
|
-
}
|
|
56
|
-
|
|
34
|
+
};
|
|
35
|
+
const keyValue = (scopeClass, memberName) => {
|
|
57
36
|
const c = normalizeScopeClass(scopeClass);
|
|
58
37
|
return `${StorConfig.namespace}::taon.storage.class.${c.name}.prop.${memberName}`;
|
|
59
|
-
}
|
|
60
|
-
|
|
38
|
+
};
|
|
39
|
+
const keyDefaultValueAlreadySet = (scopeClass, memberName) => {
|
|
61
40
|
return `${keyValue(scopeClass, memberName)}::defaultvalueisset`;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
async getItem(_key) {
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
async setItem(_key, _value) {
|
|
70
|
-
// noop
|
|
71
|
-
}
|
|
72
|
-
async removeItem(_key) {
|
|
73
|
-
// noop
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
class BrowserLocalStorageStore {
|
|
77
|
-
ls() {
|
|
41
|
+
};
|
|
42
|
+
//#region local storage
|
|
43
|
+
class LocalStorageStore {
|
|
44
|
+
async getItem(key) {
|
|
78
45
|
if (!isBrowser)
|
|
79
46
|
return undefined;
|
|
47
|
+
const raw = localStorage.getItem(key);
|
|
48
|
+
if (raw == null)
|
|
49
|
+
return undefined;
|
|
80
50
|
try {
|
|
81
|
-
return
|
|
51
|
+
return JSON.parse(raw);
|
|
82
52
|
}
|
|
83
53
|
catch {
|
|
84
|
-
return
|
|
54
|
+
return raw;
|
|
85
55
|
}
|
|
86
56
|
}
|
|
57
|
+
async setItem(key, value) {
|
|
58
|
+
if (!isBrowser)
|
|
59
|
+
return;
|
|
60
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
61
|
+
}
|
|
62
|
+
async removeItem(key) {
|
|
63
|
+
if (!isBrowser)
|
|
64
|
+
return;
|
|
65
|
+
localStorage.removeItem(key);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region session storage
|
|
70
|
+
class SessionStorageStore extends LocalStorageStore {
|
|
87
71
|
async getItem(key) {
|
|
88
|
-
|
|
89
|
-
if (!ls)
|
|
72
|
+
if (!isBrowser)
|
|
90
73
|
return undefined;
|
|
91
|
-
const raw =
|
|
92
|
-
if (raw
|
|
74
|
+
const raw = sessionStorage.getItem(key);
|
|
75
|
+
if (raw == null)
|
|
93
76
|
return undefined;
|
|
94
77
|
try {
|
|
95
78
|
return JSON.parse(raw);
|
|
96
79
|
}
|
|
97
80
|
catch {
|
|
98
|
-
// if something stored plain string by older versions
|
|
99
81
|
return raw;
|
|
100
82
|
}
|
|
101
83
|
}
|
|
102
84
|
async setItem(key, value) {
|
|
103
|
-
|
|
104
|
-
if (!ls)
|
|
85
|
+
if (!isBrowser)
|
|
105
86
|
return;
|
|
106
|
-
|
|
107
|
-
ls.setItem(key, JSON.stringify(value));
|
|
108
|
-
}
|
|
109
|
-
catch {
|
|
110
|
-
// last resort: try as string
|
|
111
|
-
try {
|
|
112
|
-
ls.setItem(key, String(value));
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
// ignore (quota/private mode)
|
|
116
|
-
}
|
|
117
|
-
}
|
|
87
|
+
sessionStorage.setItem(key, JSON.stringify(value));
|
|
118
88
|
}
|
|
119
89
|
async removeItem(key) {
|
|
120
|
-
|
|
121
|
-
if (!ls)
|
|
90
|
+
if (!isBrowser)
|
|
122
91
|
return;
|
|
123
|
-
|
|
124
|
-
ls.removeItem(key);
|
|
125
|
-
}
|
|
126
|
-
catch {
|
|
127
|
-
// ignore
|
|
128
|
-
}
|
|
92
|
+
sessionStorage.removeItem(key);
|
|
129
93
|
}
|
|
130
94
|
}
|
|
131
|
-
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region indexed db store
|
|
97
|
+
class IndexedDbStore {
|
|
132
98
|
constructor() {
|
|
133
99
|
this.dbPromise = null;
|
|
134
100
|
}
|
|
@@ -191,10 +157,8 @@ class BrowserIndexedDbStore {
|
|
|
191
157
|
}
|
|
192
158
|
}
|
|
193
159
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
* Works only when executed in Node.
|
|
197
|
-
*/
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region file stor
|
|
198
162
|
class FileStor {
|
|
199
163
|
constructor(filePath, useJSON = false) {
|
|
200
164
|
this.filePath = filePath;
|
|
@@ -202,11 +166,6 @@ class FileStor {
|
|
|
202
166
|
}
|
|
203
167
|
isNodeRuntime() {
|
|
204
168
|
return UtilsOs.isNode;
|
|
205
|
-
// return (
|
|
206
|
-
// typeof process !== 'undefined' &&
|
|
207
|
-
// !!(process as any).versions?.node &&
|
|
208
|
-
// typeof (globalThis as any).window === 'undefined'
|
|
209
|
-
// );
|
|
210
169
|
}
|
|
211
170
|
async setItem(_key, value) {
|
|
212
171
|
if (!this.isNodeRuntime())
|
|
@@ -250,262 +209,123 @@ class FileStor {
|
|
|
250
209
|
return (void 0);
|
|
251
210
|
}
|
|
252
211
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if (
|
|
262
|
-
|
|
263
|
-
id = StorPending.id++;
|
|
212
|
+
//#endregion
|
|
213
|
+
// --- global registry
|
|
214
|
+
const ALL_READY = [];
|
|
215
|
+
function createStorSignal(key, store, options) {
|
|
216
|
+
const hasDefault = options.defaultValue !== undefined;
|
|
217
|
+
const s = signal(options.defaultValue, ...(ngDevMode ? [{ debugName: "s" }] : []));
|
|
218
|
+
const readyPromise = (async () => {
|
|
219
|
+
// SSR: just use default
|
|
220
|
+
if (!isBrowser && !isNode) {
|
|
221
|
+
return;
|
|
264
222
|
}
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
setTimeout(async () => {
|
|
270
|
-
await StorPending.awaitPendingOperations(id);
|
|
271
|
-
resolve();
|
|
272
|
-
}, StorPending.AWAITING_INTERVAL_TIME);
|
|
273
|
-
});
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
223
|
+
const stored = await store.getItem(key);
|
|
224
|
+
if (stored !== undefined) {
|
|
225
|
+
const v = options.transformFrom ? options.transformFrom(stored) : stored;
|
|
226
|
+
s.set(v);
|
|
276
227
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
228
|
+
else if (hasDefault) {
|
|
229
|
+
const toDb = options.transformTo
|
|
230
|
+
? options.transformTo(options.defaultValue)
|
|
231
|
+
: options.defaultValue;
|
|
232
|
+
await store.setItem(key, toDb);
|
|
233
|
+
s.set(options.defaultValue);
|
|
234
|
+
}
|
|
235
|
+
})();
|
|
236
|
+
ALL_READY.push(readyPromise);
|
|
237
|
+
const fn = (() => s());
|
|
238
|
+
fn.signal = s;
|
|
239
|
+
fn.set = async (v) => {
|
|
240
|
+
s.set(v);
|
|
241
|
+
const toDb = options.transformTo ? options.transformTo(v) : v;
|
|
242
|
+
await store.setItem(key, toDb);
|
|
243
|
+
};
|
|
244
|
+
fn.ready = () => readyPromise;
|
|
245
|
+
return fn;
|
|
288
246
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (defProvided)
|
|
323
|
-
values.set(instance, options.defaultValue);
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
// Browser (or node file/json)
|
|
327
|
-
if (defProvided) {
|
|
328
|
-
const already = await this.store.getItem(kDef);
|
|
329
|
-
if (already) {
|
|
330
|
-
const stored = await this.store.getItem(kVal);
|
|
331
|
-
const v = options.transformFrom
|
|
332
|
-
? options.transformFrom(stored)
|
|
333
|
-
: stored;
|
|
334
|
-
if (v !== undefined)
|
|
335
|
-
values.set(instance, v);
|
|
336
|
-
else
|
|
337
|
-
values.set(instance, options.defaultValue);
|
|
338
|
-
}
|
|
339
|
-
else {
|
|
340
|
-
await this.store.setItem(kDef, true);
|
|
341
|
-
const toDb = options.transformTo
|
|
342
|
-
? options.transformTo(options.defaultValue)
|
|
343
|
-
: options.defaultValue;
|
|
344
|
-
await this.store.setItem(kVal, toDb);
|
|
345
|
-
values.set(instance, options.defaultValue);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
349
|
-
const stored = await this.store.getItem(kVal);
|
|
350
|
-
const v = options.transformFrom
|
|
351
|
-
? options.transformFrom(stored)
|
|
352
|
-
: stored;
|
|
353
|
-
if (v !== undefined)
|
|
354
|
-
values.set(instance, v);
|
|
355
|
-
}
|
|
356
|
-
})()
|
|
357
|
-
.catch(() => {
|
|
358
|
-
// swallow, keep app alive
|
|
359
|
-
})
|
|
360
|
-
.finally(() => StorPending.done(op));
|
|
361
|
-
initStarted.set(instance, p);
|
|
362
|
-
};
|
|
363
|
-
return (target, memberName) => {
|
|
364
|
-
ensureInit.__memberName = memberName;
|
|
365
|
-
Object.defineProperty(target, memberName, {
|
|
366
|
-
configurable: true,
|
|
367
|
-
enumerable: true,
|
|
368
|
-
get: function () {
|
|
369
|
-
ensureInit(this);
|
|
370
|
-
if (values.has(this))
|
|
371
|
-
return values.get(this);
|
|
372
|
-
if (options.defaultValue !== undefined)
|
|
373
|
-
return options.defaultValue;
|
|
374
|
-
return undefined;
|
|
375
|
-
},
|
|
376
|
-
set: function (newValue) {
|
|
377
|
-
values.set(this, newValue);
|
|
378
|
-
// if this is the first interaction, init will happen anyway
|
|
379
|
-
ensureInit(this);
|
|
380
|
-
const op = StorPending.start(target?.engine ?? 'localstorage', 'set');
|
|
381
|
-
const scope = scopeClass;
|
|
382
|
-
const kVal = keyValue(scope, memberName);
|
|
383
|
-
const toDb = options.transformTo
|
|
384
|
-
? options.transformTo(newValue)
|
|
385
|
-
: newValue;
|
|
386
|
-
Promise.resolve()
|
|
387
|
-
.then(() => target)
|
|
388
|
-
.then(() => this)
|
|
389
|
-
.then(() => this)
|
|
390
|
-
.then(async () => {
|
|
391
|
-
// If we are SSR + browser engine => no-op
|
|
392
|
-
if (!isBrowser && options)
|
|
393
|
-
return;
|
|
394
|
-
await options; // no-op line to keep TS happy about chaining in some builds
|
|
395
|
-
})
|
|
396
|
-
.catch(() => {
|
|
397
|
-
// ignore
|
|
398
|
-
});
|
|
399
|
-
// do real store write (async)
|
|
400
|
-
Promise.resolve()
|
|
401
|
-
.then(async () => {
|
|
402
|
-
// SSR guard for browser engines
|
|
403
|
-
if (!isBrowser && StorPropertyInLocalStorage) {
|
|
404
|
-
return;
|
|
405
|
-
}
|
|
406
|
-
await thisStoreForEngineWrite(this, kVal, toDb);
|
|
407
|
-
})
|
|
408
|
-
.catch(() => {
|
|
409
|
-
// ignore
|
|
410
|
-
})
|
|
411
|
-
.finally(() => StorPending.done(op));
|
|
412
|
-
},
|
|
413
|
-
});
|
|
414
|
-
// small helper to keep closure clean
|
|
415
|
-
const builderStore = this.store;
|
|
416
|
-
const builderEngine = this.engine;
|
|
417
|
-
async function thisStoreForEngineWrite(_instance, key, value) {
|
|
418
|
-
// If browser engines but not browser, skip.
|
|
419
|
-
if (!isBrowser &&
|
|
420
|
-
(builderEngine === 'localstorage' || builderEngine === 'indexeddb'))
|
|
421
|
-
return;
|
|
422
|
-
await builderStore.setItem(key, value);
|
|
423
|
-
}
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
/* optional node-only engines (same builder) */
|
|
427
|
-
file(filePath) {
|
|
428
|
-
this.engine = 'file';
|
|
429
|
-
this.filePath = filePath;
|
|
430
|
-
this.useJsonFile = false;
|
|
431
|
-
this.store = new FileStor(filePath, false);
|
|
432
|
-
return this;
|
|
433
|
-
}
|
|
434
|
-
jsonFile(filePath) {
|
|
435
|
-
this.engine = 'json';
|
|
436
|
-
this.filePath = filePath;
|
|
437
|
-
this.useJsonFile = true;
|
|
438
|
-
this.store = new FileStor(filePath, true);
|
|
439
|
-
return this;
|
|
247
|
+
//#endregion
|
|
248
|
+
const create = (engine, scopeClass, memberName, options) => {
|
|
249
|
+
const key = keyValue(scopeClass, memberName);
|
|
250
|
+
return createStorSignal(key, engine, options);
|
|
251
|
+
};
|
|
252
|
+
const local = new LocalStorageStore();
|
|
253
|
+
const session = new SessionStorageStore();
|
|
254
|
+
const indexedDBInstace = new IndexedDbStore();
|
|
255
|
+
//#region API
|
|
256
|
+
var TaonStor;
|
|
257
|
+
(function (TaonStor) {
|
|
258
|
+
function inLocalstorage(options, scopeClass) {
|
|
259
|
+
return create(local, scopeClass, options.keyOrPath ?? '__global__', options);
|
|
260
|
+
}
|
|
261
|
+
TaonStor.inLocalstorage = inLocalstorage;
|
|
262
|
+
function inSessionStorage(options, scopeClass) {
|
|
263
|
+
return create(session, scopeClass, options.keyOrPath ?? '__global__', options);
|
|
264
|
+
}
|
|
265
|
+
TaonStor.inSessionStorage = inSessionStorage;
|
|
266
|
+
function inIndexedDbStorage(options, scopeClass) {
|
|
267
|
+
return create(indexedDBInstace, scopeClass, options.keyOrPath ?? '__global__', options);
|
|
268
|
+
}
|
|
269
|
+
TaonStor.inIndexedDbStorage = inIndexedDbStorage;
|
|
270
|
+
function inFile(options, scopeClass) {
|
|
271
|
+
/* */
|
|
272
|
+
/* */
|
|
273
|
+
/* */
|
|
274
|
+
/* */
|
|
275
|
+
/* */
|
|
276
|
+
/* */
|
|
277
|
+
/* */
|
|
278
|
+
/* */
|
|
279
|
+
return (void 0);
|
|
440
280
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
static for(scopeClass) {
|
|
453
|
-
return new StorPropertyBuilder('localstorage', localStorageStore).for(scopeClass);
|
|
281
|
+
TaonStor.inFile = inFile;
|
|
282
|
+
function inJson(options, scopeClass) {
|
|
283
|
+
/* */
|
|
284
|
+
/* */
|
|
285
|
+
/* */
|
|
286
|
+
/* */
|
|
287
|
+
/* */
|
|
288
|
+
/* */
|
|
289
|
+
/* */
|
|
290
|
+
/* */
|
|
291
|
+
return (void 0);
|
|
454
292
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
return new StorPropertyBuilder('indexeddb', indexedDbStore).for(scopeClass);
|
|
293
|
+
TaonStor.inJson = inJson;
|
|
294
|
+
async function awaitAll() {
|
|
295
|
+
await Promise.all(ALL_READY);
|
|
459
296
|
}
|
|
460
|
-
|
|
297
|
+
TaonStor.awaitAll = awaitAll;
|
|
298
|
+
})(TaonStor || (TaonStor = {}));
|
|
299
|
+
//#endregion
|
|
461
300
|
/**
|
|
462
|
-
*
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
*
|
|
476
|
-
*
|
|
301
|
+
* exampel useage
|
|
302
|
+
*
|
|
303
|
+
* class SomeAngularComponentOrWhatever {
|
|
304
|
+
*
|
|
305
|
+
* positionX = TaonStor.inLocalstorage({
|
|
306
|
+
* defaultValue: 0
|
|
307
|
+
* });
|
|
308
|
+
*
|
|
309
|
+
* async ngOnInit() {
|
|
310
|
+
* console.log(this.positionX()) // I wonder if this can be angular signal
|
|
311
|
+
*
|
|
312
|
+
* this.positionX.set(12)
|
|
313
|
+
*
|
|
314
|
+
* await this.positionX.ready(); // but with addional this
|
|
315
|
+
* }
|
|
316
|
+
*
|
|
317
|
+
* }
|
|
318
|
+
*
|
|
319
|
+
|
|
320
|
+
*
|
|
477
321
|
*/
|
|
478
|
-
class TaonStorageFacade {
|
|
479
|
-
static async awaitPendingOperatios() {
|
|
480
|
-
await StorPending.awaitPendingOperations();
|
|
481
|
-
}
|
|
482
|
-
static get property() {
|
|
483
|
-
return {
|
|
484
|
-
in: {
|
|
485
|
-
get localstorage() {
|
|
486
|
-
return new StorPropertyBuilder('localstorage', localStorageStore);
|
|
487
|
-
},
|
|
488
|
-
get indexedb() {
|
|
489
|
-
return new StorPropertyBuilder('indexeddb', indexedDbStore);
|
|
490
|
-
},
|
|
491
|
-
// node-only (safe: dynamic import inside FileStor)
|
|
492
|
-
file(filePath) {
|
|
493
|
-
return new StorPropertyBuilder('file', new FileStor(filePath, false));
|
|
494
|
-
},
|
|
495
|
-
jsonFile(filePath) {
|
|
496
|
-
return new StorPropertyBuilder('json', new FileStor(filePath, true));
|
|
497
|
-
},
|
|
498
|
-
},
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
const Stor = TaonStorageFacade;
|
|
503
322
|
|
|
504
|
-
|
|
323
|
+
// export * from './storage';
|
|
324
|
+
// export * from './storage';
|
|
505
325
|
|
|
506
326
|
/**
|
|
507
327
|
* Generated bundle index. Do not edit.
|
|
508
328
|
*/
|
|
509
329
|
|
|
510
|
-
export {
|
|
511
|
-
//# sourceMappingURL=taon-storage-browser.mjs.map
|
|
330
|
+
export { TaonStor };
|
|
331
|
+
//# sourceMappingURL=taon-storage-browser.mjs.map
|