taon-storage 21.0.12 → 21.0.14
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 +3 -3
- package/browser/package.json +1 -1
- package/browser-prod/README.md +24 -0
- package/browser-prod/fesm2022/taon-storage-browser.mjs +511 -0
- package/browser-prod/fesm2022/taon-storage-browser.mjs.map +1 -0
- package/browser-prod/types/taon-storage-browser.d.ts +89 -0
- package/lib/build-info._auto-generated_.d.ts +5 -1
- package/lib/build-info._auto-generated_.js +6 -2
- package/lib/build-info._auto-generated_.js.map +1 -1
- package/lib/env/env.angular-node-app.d.ts +30 -29
- package/lib/env/env.angular-node-app.js +32 -31
- package/lib/env/env.angular-node-app.js.map +1 -1
- package/lib/env/env.docs-webapp.d.ts +30 -29
- package/lib/env/env.docs-webapp.js +32 -31
- package/lib/env/env.docs-webapp.js.map +1 -1
- package/lib/env/env.electron-app.d.ts +30 -29
- package/lib/env/env.electron-app.js +32 -31
- package/lib/env/env.electron-app.js.map +1 -1
- package/lib/env/env.mobile-app.d.ts +30 -29
- package/lib/env/env.mobile-app.js +32 -31
- package/lib/env/env.mobile-app.js.map +1 -1
- package/lib/env/env.npm-lib-and-cli-tool.d.ts +30 -29
- package/lib/env/env.npm-lib-and-cli-tool.js +32 -31
- package/lib/env/env.npm-lib-and-cli-tool.js.map +1 -1
- package/lib/env/env.vscode-plugin.d.ts +30 -29
- package/lib/env/env.vscode-plugin.js +32 -31
- package/lib/env/env.vscode-plugin.js.map +1 -1
- package/lib/index._auto-generated_.js +1 -1
- package/lib/index._auto-generated_.js.map +1 -1
- package/lib-prod/build-info._auto-generated_.d.ts +24 -0
- package/lib-prod/build-info._auto-generated_.js +30 -0
- package/lib-prod/build-info._auto-generated_.js.map +1 -0
- package/lib-prod/env/env.angular-node-app.d.ts +64 -0
- package/lib-prod/env/env.angular-node-app.js +71 -0
- package/lib-prod/env/env.angular-node-app.js.map +1 -0
- package/lib-prod/env/env.docs-webapp.d.ts +64 -0
- package/lib-prod/env/env.docs-webapp.js +71 -0
- package/lib-prod/env/env.docs-webapp.js.map +1 -0
- package/lib-prod/env/env.electron-app.d.ts +64 -0
- package/lib-prod/env/env.electron-app.js +71 -0
- package/lib-prod/env/env.electron-app.js.map +1 -0
- package/lib-prod/env/env.mobile-app.d.ts +64 -0
- package/lib-prod/env/env.mobile-app.js +71 -0
- package/lib-prod/env/env.mobile-app.js.map +1 -0
- package/lib-prod/env/env.npm-lib-and-cli-tool.d.ts +64 -0
- package/lib-prod/env/env.npm-lib-and-cli-tool.js +71 -0
- package/lib-prod/env/env.npm-lib-and-cli-tool.js.map +1 -0
- package/lib-prod/env/env.vscode-plugin.d.ts +64 -0
- package/lib-prod/env/env.vscode-plugin.js +71 -0
- package/lib-prod/env/env.vscode-plugin.js.map +1 -0
- package/lib-prod/env/index.d.ts +6 -0
- package/lib-prod/env/index.js +23 -0
- package/lib-prod/env/index.js.map +1 -0
- package/lib-prod/index._auto-generated_.d.ts +0 -0
- package/lib-prod/index._auto-generated_.js +6 -0
- package/lib-prod/index._auto-generated_.js.map +1 -0
- package/lib-prod/index.d.ts +1 -0
- package/lib-prod/index.js +20 -0
- package/lib-prod/index.js.map +1 -0
- package/lib-prod/storage.d.ts +79 -0
- package/lib-prod/storage.js +504 -0
- package/lib-prod/storage.js.map +1 -0
- package/package.json +1 -1
- package/websql/fesm2022/taon-storage-websql.mjs +3 -3
- package/websql/package.json +1 -1
- package/websql-prod/README.md +24 -0
- package/websql-prod/fesm2022/taon-storage-websql.mjs +511 -0
- package/websql-prod/fesm2022/taon-storage-websql.mjs.map +1 -0
- package/websql-prod/types/taon-storage-websql.d.ts +89 -0
- package/lib/constants.d.ts +0 -3
- package/lib/constants.js +0 -40
- package/lib/constants.js.map +0 -1
- package/lib/file-stor.d.ts +0 -9
- package/lib/file-stor.js +0 -64
- package/lib/file-stor.js.map +0 -1
- package/lib/helpers.d.ts +0 -2
- package/lib/helpers.js +0 -15
- package/lib/helpers.js.map +0 -1
- package/lib/models.d.ts +0 -10
- package/lib/models.js +0 -5
- package/lib/models.js.map +0 -1
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { CommonModule } from '@angular/common';
|
|
4
|
+
import { _, UtilsOs } from 'tnp-core/websql-prod';
|
|
5
|
+
|
|
6
|
+
class SampleLogCmpComponent {
|
|
7
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: SampleLogCmpComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
8
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.0.9", type: SampleLogCmpComponent, isStandalone: true, selector: "sample-log-cmp", ngImport: i0, 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"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
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() {
|
|
20
|
+
try {
|
|
21
|
+
return globalThis?.location?.port || 'no-port';
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return 'no-port';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Keeps the spirit of your old `storeName = taon-storage_<port>`
|
|
29
|
+
* plus project name namespacing (but without localForage).
|
|
30
|
+
*/
|
|
31
|
+
const storeName = `taon-storage_${safeLocationPort()}`;
|
|
32
|
+
function defaultNamespace() {
|
|
33
|
+
const project = _.kebabCase(globalThis['CURRENT_PROJECT_GENERIC_NAME'] ?? '');
|
|
34
|
+
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
|
+
*/
|
|
40
|
+
const StorConfig = {
|
|
41
|
+
namespace: defaultNamespace(),
|
|
42
|
+
indexedDb: {
|
|
43
|
+
dbName: `${defaultNamespace()}_INDEXEDDB`,
|
|
44
|
+
storeName: 'keyvaluepairs',
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
function normalizeScopeClass(cls) {
|
|
48
|
+
if (!cls)
|
|
49
|
+
return { name: '__GLOBAL_NAMESPACE__' };
|
|
50
|
+
// if it's a function/class
|
|
51
|
+
if (typeof cls === 'function')
|
|
52
|
+
return { name: cls.name || '__ANON__' };
|
|
53
|
+
// if it's already object with name
|
|
54
|
+
return { name: cls.name || '__ANON__' };
|
|
55
|
+
}
|
|
56
|
+
function keyValue(scopeClass, memberName) {
|
|
57
|
+
const c = normalizeScopeClass(scopeClass);
|
|
58
|
+
return `${StorConfig.namespace}::taon.storage.class.${c.name}.prop.${memberName}`;
|
|
59
|
+
}
|
|
60
|
+
function keyDefaultValueAlreadySet(scopeClass, memberName) {
|
|
61
|
+
return `${keyValue(scopeClass, memberName)}::defaultvalueisset`;
|
|
62
|
+
}
|
|
63
|
+
/** Back-compat alias (your old typo) */
|
|
64
|
+
const keyDefaultValueAreadySet = keyDefaultValueAlreadySet;
|
|
65
|
+
class NoopStore {
|
|
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() {
|
|
78
|
+
if (!isBrowser)
|
|
79
|
+
return undefined;
|
|
80
|
+
try {
|
|
81
|
+
return window.localStorage;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async getItem(key) {
|
|
88
|
+
const ls = this.ls();
|
|
89
|
+
if (!ls)
|
|
90
|
+
return undefined;
|
|
91
|
+
const raw = ls.getItem(key);
|
|
92
|
+
if (raw === null)
|
|
93
|
+
return undefined;
|
|
94
|
+
try {
|
|
95
|
+
return JSON.parse(raw);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// if something stored plain string by older versions
|
|
99
|
+
return raw;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async setItem(key, value) {
|
|
103
|
+
const ls = this.ls();
|
|
104
|
+
if (!ls)
|
|
105
|
+
return;
|
|
106
|
+
try {
|
|
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
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async removeItem(key) {
|
|
120
|
+
const ls = this.ls();
|
|
121
|
+
if (!ls)
|
|
122
|
+
return;
|
|
123
|
+
try {
|
|
124
|
+
ls.removeItem(key);
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
// ignore
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
class BrowserIndexedDbStore {
|
|
132
|
+
constructor() {
|
|
133
|
+
this.dbPromise = null;
|
|
134
|
+
}
|
|
135
|
+
openDb() {
|
|
136
|
+
if (!isBrowser || !window.indexedDB) {
|
|
137
|
+
return Promise.reject(new Error('IndexedDB not available'));
|
|
138
|
+
}
|
|
139
|
+
if (this.dbPromise)
|
|
140
|
+
return this.dbPromise;
|
|
141
|
+
const { dbName, storeName } = StorConfig.indexedDb;
|
|
142
|
+
this.dbPromise = new Promise((resolve, reject) => {
|
|
143
|
+
const req = indexedDB.open(dbName, 1);
|
|
144
|
+
req.onupgradeneeded = () => {
|
|
145
|
+
const db = req.result;
|
|
146
|
+
if (!db.objectStoreNames.contains(storeName)) {
|
|
147
|
+
db.createObjectStore(storeName);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
req.onsuccess = () => resolve(req.result);
|
|
151
|
+
req.onerror = () => reject(req.error);
|
|
152
|
+
});
|
|
153
|
+
return this.dbPromise;
|
|
154
|
+
}
|
|
155
|
+
async withStore(mode, fn) {
|
|
156
|
+
const db = await this.openDb();
|
|
157
|
+
const { storeName } = StorConfig.indexedDb;
|
|
158
|
+
return await new Promise((resolve, reject) => {
|
|
159
|
+
const tx = db.transaction(storeName, mode);
|
|
160
|
+
const store = tx.objectStore(storeName);
|
|
161
|
+
const req = fn(store);
|
|
162
|
+
req.onsuccess = () => resolve(req.result);
|
|
163
|
+
req.onerror = () => reject(req.error);
|
|
164
|
+
tx.onabort = () => reject(tx.error);
|
|
165
|
+
// tx.oncomplete => nothing
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
async getItem(key) {
|
|
169
|
+
try {
|
|
170
|
+
const result = await this.withStore('readonly', s => s.get(key));
|
|
171
|
+
return result === undefined ? undefined : result;
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
async setItem(key, value) {
|
|
178
|
+
try {
|
|
179
|
+
await this.withStore('readwrite', s => s.put(value, key));
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
// ignore
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
async removeItem(key) {
|
|
186
|
+
try {
|
|
187
|
+
await this.withStore('readwrite', s => s.delete(key));
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
// ignore
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Node-side file storage (optional). No top-level node imports (Angular-safe).
|
|
196
|
+
* Works only when executed in Node.
|
|
197
|
+
*/
|
|
198
|
+
class FileStor {
|
|
199
|
+
constructor(filePath, useJSON = false) {
|
|
200
|
+
this.filePath = filePath;
|
|
201
|
+
this.useJSON = useJSON;
|
|
202
|
+
}
|
|
203
|
+
isNodeRuntime() {
|
|
204
|
+
return UtilsOs.isNode;
|
|
205
|
+
// return (
|
|
206
|
+
// typeof process !== 'undefined' &&
|
|
207
|
+
// !!(process as any).versions?.node &&
|
|
208
|
+
// typeof (globalThis as any).window === 'undefined'
|
|
209
|
+
// );
|
|
210
|
+
}
|
|
211
|
+
async setItem(_key, value) {
|
|
212
|
+
if (!this.isNodeRuntime())
|
|
213
|
+
return;
|
|
214
|
+
/* */
|
|
215
|
+
/* */
|
|
216
|
+
/* */
|
|
217
|
+
/* */
|
|
218
|
+
/* */
|
|
219
|
+
/* */
|
|
220
|
+
/* */
|
|
221
|
+
/* */
|
|
222
|
+
/* */
|
|
223
|
+
return (void 0);
|
|
224
|
+
}
|
|
225
|
+
async getItem(_key) {
|
|
226
|
+
if (!this.isNodeRuntime())
|
|
227
|
+
return undefined;
|
|
228
|
+
/* */
|
|
229
|
+
/* */
|
|
230
|
+
/* */
|
|
231
|
+
/* */
|
|
232
|
+
/* */
|
|
233
|
+
/* */
|
|
234
|
+
/* */
|
|
235
|
+
/* */
|
|
236
|
+
/* */
|
|
237
|
+
/* */
|
|
238
|
+
return (void 0);
|
|
239
|
+
}
|
|
240
|
+
async removeItem(_key) {
|
|
241
|
+
if (!this.isNodeRuntime())
|
|
242
|
+
return;
|
|
243
|
+
/* */
|
|
244
|
+
/* */
|
|
245
|
+
/* */
|
|
246
|
+
/* */
|
|
247
|
+
/* */
|
|
248
|
+
/* */
|
|
249
|
+
/* */
|
|
250
|
+
return (void 0);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/* ---------------------------
|
|
254
|
+
* Pending ops (so you can still await)
|
|
255
|
+
* -------------------------- */
|
|
256
|
+
class StorPending {
|
|
257
|
+
static { this.pending = []; }
|
|
258
|
+
static { this.id = 0; }
|
|
259
|
+
static { this.AWAITING_INTERVAL_TIME = 200; }
|
|
260
|
+
static async awaitPendingOperations(id = StorPending.id++) {
|
|
261
|
+
if (id > Number.MAX_SAFE_INTEGER - 2) {
|
|
262
|
+
StorPending.id = 0;
|
|
263
|
+
id = StorPending.id++;
|
|
264
|
+
}
|
|
265
|
+
const pending = StorPending.pending;
|
|
266
|
+
for (const op of pending) {
|
|
267
|
+
if (!op.isDone) {
|
|
268
|
+
await new Promise(resolve => {
|
|
269
|
+
setTimeout(async () => {
|
|
270
|
+
await StorPending.awaitPendingOperations(id);
|
|
271
|
+
resolve();
|
|
272
|
+
}, StorPending.AWAITING_INTERVAL_TIME);
|
|
273
|
+
});
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// cleanup
|
|
278
|
+
StorPending.pending = pending.filter(p => !p.isDone);
|
|
279
|
+
}
|
|
280
|
+
static start(engine, id) {
|
|
281
|
+
const op = { engine, id, isDone: false };
|
|
282
|
+
StorPending.pending.push(op);
|
|
283
|
+
return op;
|
|
284
|
+
}
|
|
285
|
+
static done(op) {
|
|
286
|
+
op.isDone = true;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
/* ---------------------------
|
|
290
|
+
* Decorator builder
|
|
291
|
+
* -------------------------- */
|
|
292
|
+
class StorPropertyBuilder {
|
|
293
|
+
constructor(engine, store) {
|
|
294
|
+
this.useJsonFile = false;
|
|
295
|
+
this.engine = engine;
|
|
296
|
+
this.store = store;
|
|
297
|
+
}
|
|
298
|
+
for(scopeClass) {
|
|
299
|
+
this.scopeClass = scopeClass;
|
|
300
|
+
return this;
|
|
301
|
+
}
|
|
302
|
+
withDefaultValue(defaultValue) {
|
|
303
|
+
return this.withOptions({ defaultValue });
|
|
304
|
+
}
|
|
305
|
+
withOptions(options) {
|
|
306
|
+
const scopeClass = this.scopeClass;
|
|
307
|
+
// per-instance state (fixes prototype-closure sharing)
|
|
308
|
+
const values = new WeakMap();
|
|
309
|
+
const initStarted = new WeakMap();
|
|
310
|
+
const ensureInit = (instance) => {
|
|
311
|
+
if (initStarted.has(instance))
|
|
312
|
+
return;
|
|
313
|
+
const op = StorPending.start(this.engine, 'init');
|
|
314
|
+
const p = (async () => {
|
|
315
|
+
const memberName = ensureInit.__memberName;
|
|
316
|
+
const kVal = keyValue(scopeClass, memberName);
|
|
317
|
+
const kDef = keyDefaultValueAlreadySet(scopeClass, memberName);
|
|
318
|
+
const defProvided = options.defaultValue !== undefined;
|
|
319
|
+
if (!isBrowser &&
|
|
320
|
+
(this.engine === 'localstorage' || this.engine === 'indexeddb')) {
|
|
321
|
+
// SSR: just set defaults, no storage
|
|
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;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
/* ---------------------------
|
|
443
|
+
* Public: clean API exports
|
|
444
|
+
* -------------------------- */
|
|
445
|
+
const localStorageStore = isBrowser
|
|
446
|
+
? new BrowserLocalStorageStore()
|
|
447
|
+
: new NoopStore();
|
|
448
|
+
const indexedDbStore = isBrowser
|
|
449
|
+
? new BrowserIndexedDbStore()
|
|
450
|
+
: new NoopStore();
|
|
451
|
+
class StorPropertyInLocalStorage {
|
|
452
|
+
static for(scopeClass) {
|
|
453
|
+
return new StorPropertyBuilder('localstorage', localStorageStore).for(scopeClass);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
class StorPropertyInIndexedDb {
|
|
457
|
+
static for(scopeClass) {
|
|
458
|
+
return new StorPropertyBuilder('indexeddb', indexedDbStore).for(scopeClass);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Helpers
|
|
463
|
+
*/
|
|
464
|
+
async function uncache(onlyInThisComponentClass, propertyValueToDeleteFromCache) {
|
|
465
|
+
const scope = onlyInThisComponentClass || { name: '__GLOBAL_NAMESPACE__' };
|
|
466
|
+
const prop = String(propertyValueToDeleteFromCache);
|
|
467
|
+
await Promise.all([
|
|
468
|
+
localStorageStore.removeItem(keyValue(scope, prop)),
|
|
469
|
+
localStorageStore.removeItem(keyDefaultValueAlreadySet(scope, prop)),
|
|
470
|
+
indexedDbStore.removeItem(keyValue(scope, prop)),
|
|
471
|
+
indexedDbStore.removeItem(keyDefaultValueAlreadySet(scope, prop)),
|
|
472
|
+
]);
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Backwards-compatible facade:
|
|
476
|
+
* Stor.property.in.localstorage.for(...).withDefaultValue(...)
|
|
477
|
+
*/
|
|
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
|
+
|
|
504
|
+
//#region @browser
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Generated bundle index. Do not edit.
|
|
508
|
+
*/
|
|
509
|
+
|
|
510
|
+
export { SampleLogCmpComponent, Stor, StorConfig, StorPropertyInIndexedDb, StorPropertyInLocalStorage, keyDefaultValueAlreadySet, keyDefaultValueAreadySet, keyValue, storeName, uncache };
|
|
511
|
+
//# sourceMappingURL=taon-storage-websql.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taon-storage-websql.mjs","sources":["../../../tmp-libs-for-dist-websql-prod/taon-storage/projects/taon-storage/src/lib/sample-log-cmp/sample-log-cmp.component.ts","../../../tmp-libs-for-dist-websql-prod/taon-storage/projects/taon-storage/src/lib/sample-log-cmp/sample-log-cmp.component.html","../../../tmp-libs-for-dist-websql-prod/taon-storage/projects/taon-storage/src/lib/storage.ts","../../../tmp-libs-for-dist-websql-prod/taon-storage/projects/taon-storage/src/lib/index.ts","../../../tmp-libs-for-dist-websql-prod/taon-storage/projects/taon-storage/src/taon-storage-websql.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n EventEmitter,\n HostBinding,\n Input,\n OnInit,\n Output,\n} from '@angular/core';\nimport { Subscription } from 'rxjs';\nimport { CommonModule } from '@angular/common';\n\n@Component({\n selector: 'sample-log-cmp',\n templateUrl: './sample-log-cmp.component.html',\n styleUrls: ['./sample-log-cmp.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [CommonModule],\n standalone: true,\n})\nexport class SampleLogCmpComponent {}","<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>","/* taon-storage (native, SSR-safe) */\nimport { UtilsOs, _ } from 'tnp-core/websql-prod';\nexport type StorageEngine = 'localstorage' | 'indexeddb' | 'file' | 'json';\n\nexport interface StorOptions<T = any> {\n defaultValue?: T;\n transformFrom?: (valueFromDb: any) => T;\n transformTo?: (valueToDb: T) => any;\n}\n\nexport interface PendingOperation {\n engine: StorageEngine;\n id: string;\n isDone: boolean;\n}\n\ntype ClassLike = Function | { name: string } | undefined;\n\nconst isBrowser =\n typeof window !== 'undefined' &&\n typeof document !== 'undefined' &&\n typeof navigator !== 'undefined';\n\nfunction safeLocationPort(): string {\n try {\n return (globalThis as any)?.location?.port || 'no-port';\n } catch {\n return 'no-port';\n }\n}\n\n/**\n * Keeps the spirit of your old `storeName = taon-storage_<port>`\n * plus project name namespacing (but without localForage).\n */\nexport const storeName = `taon-storage_${safeLocationPort()}`;\n\nfunction defaultNamespace(): string {\n const project = _.kebabCase(globalThis['CURRENT_PROJECT_GENERIC_NAME'] ?? '');\n return project ? `${storeName}_${project}` : storeName;\n}\n\n/**\n * Central config (optional).\n * You can set it once at app bootstrap if you want a stable namespace.\n */\nexport const StorConfig = {\n namespace: defaultNamespace(),\n indexedDb: {\n dbName: `${defaultNamespace()}_INDEXEDDB`,\n storeName: 'keyvaluepairs',\n },\n};\n\nfunction normalizeScopeClass(cls: ClassLike): { name: string } {\n if (!cls) return { name: '__GLOBAL_NAMESPACE__' };\n // if it's a function/class\n if (typeof cls === 'function')\n return { name: (cls as any).name || '__ANON__' };\n // if it's already object with name\n return { name: (cls as any).name || '__ANON__' };\n}\n\nexport function keyValue(scopeClass: ClassLike, memberName: string) {\n const c = normalizeScopeClass(scopeClass);\n return `${StorConfig.namespace}::taon.storage.class.${c.name}.prop.${memberName}`;\n}\n\nexport function keyDefaultValueAlreadySet(\n scopeClass: ClassLike,\n memberName: string,\n) {\n return `${keyValue(scopeClass, memberName)}::defaultvalueisset`;\n}\n\n/** Back-compat alias (your old typo) */\nexport const keyDefaultValueAreadySet = keyDefaultValueAlreadySet;\n\n/* ---------------------------\n * Stores\n * -------------------------- */\n\ninterface AsyncKVStore {\n getItem<T = any>(key: string): Promise<T | undefined>;\n setItem<T = any>(key: string, value: T): Promise<void>;\n removeItem(key: string): Promise<void>;\n}\n\nclass NoopStore implements AsyncKVStore {\n async getItem<T>(_key: string): Promise<T | undefined> {\n return undefined;\n }\n async setItem<T>(_key: string, _value: T): Promise<void> {\n // noop\n }\n async removeItem(_key: string): Promise<void> {\n // noop\n }\n}\n\nclass BrowserLocalStorageStore implements AsyncKVStore {\n private ls(): Storage | undefined {\n if (!isBrowser) return undefined;\n try {\n return window.localStorage;\n } catch {\n return undefined;\n }\n }\n\n async getItem<T>(key: string): Promise<T | undefined> {\n const ls = this.ls();\n if (!ls) return undefined;\n\n const raw = ls.getItem(key);\n if (raw === null) return undefined;\n\n try {\n return JSON.parse(raw) as T;\n } catch {\n // if something stored plain string by older versions\n return raw as unknown as T;\n }\n }\n\n async setItem<T>(key: string, value: T): Promise<void> {\n const ls = this.ls();\n if (!ls) return;\n\n try {\n ls.setItem(key, JSON.stringify(value));\n } catch {\n // last resort: try as string\n try {\n ls.setItem(key, String(value));\n } catch {\n // ignore (quota/private mode)\n }\n }\n }\n\n async removeItem(key: string): Promise<void> {\n const ls = this.ls();\n if (!ls) return;\n try {\n ls.removeItem(key);\n } catch {\n // ignore\n }\n }\n}\n\nclass BrowserIndexedDbStore implements AsyncKVStore {\n private dbPromise: Promise<IDBDatabase> | null = null;\n\n private openDb(): Promise<IDBDatabase> {\n if (!isBrowser || !(window as any).indexedDB) {\n return Promise.reject(new Error('IndexedDB not available'));\n }\n if (this.dbPromise) return this.dbPromise;\n\n const { dbName, storeName } = StorConfig.indexedDb;\n\n this.dbPromise = new Promise<IDBDatabase>((resolve, reject) => {\n const req = indexedDB.open(dbName, 1);\n\n req.onupgradeneeded = () => {\n const db = req.result;\n if (!db.objectStoreNames.contains(storeName)) {\n db.createObjectStore(storeName);\n }\n };\n\n req.onsuccess = () => resolve(req.result);\n req.onerror = () => reject(req.error);\n });\n\n return this.dbPromise;\n }\n\n private async withStore<T>(\n mode: IDBTransactionMode,\n fn: (store: IDBObjectStore) => IDBRequest<T>,\n ): Promise<T> {\n const db = await this.openDb();\n const { storeName } = StorConfig.indexedDb;\n\n return await new Promise<T>((resolve, reject) => {\n const tx = db.transaction(storeName, mode);\n const store = tx.objectStore(storeName);\n const req = fn(store);\n\n req.onsuccess = () => resolve(req.result);\n req.onerror = () => reject(req.error);\n\n tx.onabort = () => reject(tx.error);\n // tx.oncomplete => nothing\n });\n }\n\n async getItem<T>(key: string): Promise<T | undefined> {\n try {\n const result = await this.withStore('readonly', s => s.get(key));\n return (result as any) === undefined ? undefined : (result as any);\n } catch {\n return undefined;\n }\n }\n\n async setItem<T>(key: string, value: T): Promise<void> {\n try {\n await this.withStore('readwrite', s => s.put(value as any, key));\n } catch {\n // ignore\n }\n }\n\n async removeItem(key: string): Promise<void> {\n try {\n await this.withStore('readwrite', s => s.delete(key) as any);\n } catch {\n // ignore\n }\n }\n}\n\n/**\n * Node-side file storage (optional). No top-level node imports (Angular-safe).\n * Works only when executed in Node.\n */\nclass FileStor implements AsyncKVStore {\n constructor(\n private filePath: string,\n private useJSON = false,\n ) {}\n\n private isNodeRuntime() {\n return UtilsOs.isNode;\n // return (\n // typeof process !== 'undefined' &&\n // !!(process as any).versions?.node &&\n // typeof (globalThis as any).window === 'undefined'\n // );\n }\n\n async setItem<T>(_key: string, value: T): Promise<void> {\n if (!this.isNodeRuntime()) return;\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n return (void 0);\n }\n\n async getItem<T>(_key: string): Promise<T | undefined> {\n if (!this.isNodeRuntime()) return undefined;\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n return (void 0);\n }\n\n async removeItem(_key: string): Promise<void> {\n if (!this.isNodeRuntime()) return;\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n return (void 0);\n }\n}\n\n/* ---------------------------\n * Pending ops (so you can still await)\n * -------------------------- */\n\nclass StorPending {\n static pending: PendingOperation[] = [];\n static id = 0;\n static AWAITING_INTERVAL_TIME = 200;\n\n static async awaitPendingOperations(id = StorPending.id++): Promise<void> {\n if (id > Number.MAX_SAFE_INTEGER - 2) {\n StorPending.id = 0;\n id = StorPending.id++;\n }\n\n const pending = StorPending.pending;\n\n for (const op of pending) {\n if (!op.isDone) {\n await new Promise<void>(resolve => {\n setTimeout(async () => {\n await StorPending.awaitPendingOperations(id);\n resolve();\n }, StorPending.AWAITING_INTERVAL_TIME);\n });\n return;\n }\n }\n\n // cleanup\n StorPending.pending = pending.filter(p => !p.isDone);\n }\n\n static start(engine: StorageEngine, id: string): PendingOperation {\n const op: PendingOperation = { engine, id, isDone: false };\n StorPending.pending.push(op);\n return op;\n }\n\n static done(op: PendingOperation) {\n op.isDone = true;\n }\n}\n\n/* ---------------------------\n * Decorator builder\n * -------------------------- */\n\nclass StorPropertyBuilder {\n private scopeClass?: ClassLike;\n private engine: StorageEngine;\n private store: AsyncKVStore;\n private filePath?: string;\n private useJsonFile = false;\n\n constructor(engine: StorageEngine, store: AsyncKVStore) {\n this.engine = engine;\n this.store = store;\n }\n\n for(scopeClass?: ClassLike) {\n this.scopeClass = scopeClass;\n return this;\n }\n\n withDefaultValue<T = any>(defaultValue: T) {\n return this.withOptions<T>({ defaultValue });\n }\n\n withOptions<T = any>(options: StorOptions<T>) {\n const scopeClass = this.scopeClass;\n\n // per-instance state (fixes prototype-closure sharing)\n const values = new WeakMap<object, T>();\n const initStarted = new WeakMap<object, Promise<void>>();\n\n const ensureInit = (instance: object) => {\n if (initStarted.has(instance)) return;\n\n const op = StorPending.start(this.engine, 'init');\n const p = (async () => {\n const memberName = (ensureInit as any).__memberName as string;\n\n const kVal = keyValue(scopeClass, memberName);\n const kDef = keyDefaultValueAlreadySet(scopeClass, memberName);\n\n const defProvided = options.defaultValue !== undefined;\n\n if (\n !isBrowser &&\n (this.engine === 'localstorage' || this.engine === 'indexeddb')\n ) {\n // SSR: just set defaults, no storage\n if (defProvided) values.set(instance, options.defaultValue as T);\n return;\n }\n\n // Browser (or node file/json)\n if (defProvided) {\n const already = await this.store.getItem<boolean>(kDef);\n if (already) {\n const stored = await this.store.getItem<any>(kVal);\n const v = options.transformFrom\n ? options.transformFrom(stored)\n : stored;\n if (v !== undefined) values.set(instance, v as T);\n else values.set(instance, options.defaultValue as T);\n } else {\n await this.store.setItem(kDef, true);\n const toDb = options.transformTo\n ? options.transformTo(options.defaultValue as T)\n : (options.defaultValue as any);\n await this.store.setItem(kVal, toDb);\n values.set(instance, options.defaultValue as T);\n }\n } else {\n const stored = await this.store.getItem<any>(kVal);\n const v = options.transformFrom\n ? options.transformFrom(stored)\n : stored;\n if (v !== undefined) values.set(instance, v as T);\n }\n })()\n .catch(() => {\n // swallow, keep app alive\n })\n .finally(() => StorPending.done(op));\n\n initStarted.set(instance, p);\n };\n\n return (target: any, memberName: string) => {\n (ensureInit as any).__memberName = memberName;\n\n Object.defineProperty(target, memberName, {\n configurable: true,\n enumerable: true,\n get: function () {\n ensureInit(this);\n\n if (values.has(this)) return values.get(this);\n if (options.defaultValue !== undefined) return options.defaultValue;\n return undefined;\n },\n set: function (newValue: T) {\n values.set(this, newValue);\n\n // if this is the first interaction, init will happen anyway\n ensureInit(this);\n\n const op = StorPending.start(\n (target as any)?.engine ?? 'localstorage',\n 'set',\n );\n\n const scope = scopeClass;\n const kVal = keyValue(scope, memberName);\n\n const toDb = options.transformTo\n ? options.transformTo(newValue)\n : (newValue as any);\n\n Promise.resolve()\n .then(() => target as any)\n .then(() => this as any)\n .then(() => this as any)\n .then(async () => {\n // If we are SSR + browser engine => no-op\n if (!isBrowser && (options as any)) return;\n await (options as any); // no-op line to keep TS happy about chaining in some builds\n })\n .catch(() => {\n // ignore\n });\n\n // do real store write (async)\n Promise.resolve()\n .then(async () => {\n // SSR guard for browser engines\n if (!isBrowser && (StorPropertyInLocalStorage as any)) {\n return;\n }\n await thisStoreForEngineWrite(this, kVal, toDb);\n })\n .catch(() => {\n // ignore\n })\n .finally(() => StorPending.done(op));\n },\n });\n\n // small helper to keep closure clean\n const builderStore = this.store;\n const builderEngine = this.engine;\n\n async function thisStoreForEngineWrite(\n _instance: any,\n key: string,\n value: any,\n ) {\n // If browser engines but not browser, skip.\n if (\n !isBrowser &&\n (builderEngine === 'localstorage' || builderEngine === 'indexeddb')\n )\n return;\n await builderStore.setItem(key, value);\n }\n };\n }\n\n /* optional node-only engines (same builder) */\n file(filePath: string) {\n this.engine = 'file';\n this.filePath = filePath;\n this.useJsonFile = false;\n this.store = new FileStor(filePath, false);\n return this;\n }\n\n jsonFile(filePath: string) {\n this.engine = 'json';\n this.filePath = filePath;\n this.useJsonFile = true;\n this.store = new FileStor(filePath, true);\n return this;\n }\n}\n\n/* ---------------------------\n * Public: clean API exports\n * -------------------------- */\n\nconst localStorageStore: AsyncKVStore = isBrowser\n ? new BrowserLocalStorageStore()\n : new NoopStore();\nconst indexedDbStore: AsyncKVStore = isBrowser\n ? new BrowserIndexedDbStore()\n : new NoopStore();\n\nexport class StorPropertyInLocalStorage {\n static for(scopeClass?: ClassLike) {\n return new StorPropertyBuilder('localstorage', localStorageStore).for(\n scopeClass,\n );\n }\n}\n\nexport class StorPropertyInIndexedDb {\n static for(scopeClass?: ClassLike) {\n return new StorPropertyBuilder('indexeddb', indexedDbStore).for(scopeClass);\n }\n}\n\n/**\n * Helpers\n */\nexport async function uncache<CLASS_FUNCTION = any>(\n onlyInThisComponentClass: CLASS_FUNCTION,\n propertyValueToDeleteFromCache: keyof CLASS_FUNCTION,\n) {\n const scope =\n onlyInThisComponentClass || ({ name: '__GLOBAL_NAMESPACE__' } as any);\n const prop = String(propertyValueToDeleteFromCache);\n\n await Promise.all([\n localStorageStore.removeItem(keyValue(scope as any, prop)),\n localStorageStore.removeItem(keyDefaultValueAlreadySet(scope as any, prop)),\n indexedDbStore.removeItem(keyValue(scope as any, prop)),\n indexedDbStore.removeItem(keyDefaultValueAlreadySet(scope as any, prop)),\n ]);\n}\n\n/**\n * Backwards-compatible facade:\n * Stor.property.in.localstorage.for(...).withDefaultValue(...)\n */\nclass TaonStorageFacade {\n static async awaitPendingOperatios() {\n await StorPending.awaitPendingOperations();\n }\n\n static get property() {\n return {\n in: {\n get localstorage() {\n return new StorPropertyBuilder('localstorage', localStorageStore);\n },\n get indexedb() {\n return new StorPropertyBuilder('indexeddb', indexedDbStore);\n },\n // node-only (safe: dynamic import inside FileStor)\n file(filePath: string) {\n return new StorPropertyBuilder('file', new FileStor(filePath, false));\n },\n jsonFile(filePath: string) {\n return new StorPropertyBuilder('json', new FileStor(filePath, true));\n },\n },\n };\n }\n}\n\nexport const Stor = TaonStorageFacade;","//#region @browser\nexport * from './sample-log-cmp/sample-log-cmp.component';\n//#endregion\nexport * from './storage';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAoBa,qBAAqB,CAAA;8GAArB,qBAAqB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;kGAArB,qBAAqB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,gBAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,ECp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ent {
|
|
5
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SampleLogCmpComponent, never>;
|
|
6
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SampleLogCmpComponent, "sample-log-cmp", never, {}, {}, never, never, true, never>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type StorageEngine = 'localstorage' | 'indexeddb' | 'file' | 'json';
|
|
10
|
+
interface StorOptions<T = any> {
|
|
11
|
+
defaultValue?: T;
|
|
12
|
+
transformFrom?: (valueFromDb: any) => T;
|
|
13
|
+
transformTo?: (valueToDb: T) => any;
|
|
14
|
+
}
|
|
15
|
+
interface PendingOperation {
|
|
16
|
+
engine: StorageEngine;
|
|
17
|
+
id: string;
|
|
18
|
+
isDone: boolean;
|
|
19
|
+
}
|
|
20
|
+
type ClassLike = Function | {
|
|
21
|
+
name: string;
|
|
22
|
+
} | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Keeps the spirit of your old `storeName = taon-storage_<port>`
|
|
25
|
+
* plus project name namespacing (but without localForage).
|
|
26
|
+
*/
|
|
27
|
+
declare const storeName: string;
|
|
28
|
+
/**
|
|
29
|
+
* Central config (optional).
|
|
30
|
+
* You can set it once at app bootstrap if you want a stable namespace.
|
|
31
|
+
*/
|
|
32
|
+
declare const StorConfig: {
|
|
33
|
+
namespace: string;
|
|
34
|
+
indexedDb: {
|
|
35
|
+
dbName: string;
|
|
36
|
+
storeName: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
declare function keyValue(scopeClass: ClassLike, memberName: string): string;
|
|
40
|
+
declare function keyDefaultValueAlreadySet(scopeClass: ClassLike, memberName: string): string;
|
|
41
|
+
/** Back-compat alias (your old typo) */
|
|
42
|
+
declare const keyDefaultValueAreadySet: typeof keyDefaultValueAlreadySet;
|
|
43
|
+
interface AsyncKVStore {
|
|
44
|
+
getItem<T = any>(key: string): Promise<T | undefined>;
|
|
45
|
+
setItem<T = any>(key: string, value: T): Promise<void>;
|
|
46
|
+
removeItem(key: string): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
declare class StorPropertyBuilder {
|
|
49
|
+
private scopeClass?;
|
|
50
|
+
private engine;
|
|
51
|
+
private store;
|
|
52
|
+
private filePath?;
|
|
53
|
+
private useJsonFile;
|
|
54
|
+
constructor(engine: StorageEngine, store: AsyncKVStore);
|
|
55
|
+
for(scopeClass?: ClassLike): this;
|
|
56
|
+
withDefaultValue<T = any>(defaultValue: T): (target: any, memberName: string) => void;
|
|
57
|
+
withOptions<T = any>(options: StorOptions<T>): (target: any, memberName: string) => void;
|
|
58
|
+
file(filePath: string): this;
|
|
59
|
+
jsonFile(filePath: string): this;
|
|
60
|
+
}
|
|
61
|
+
declare class StorPropertyInLocalStorage {
|
|
62
|
+
static for(scopeClass?: ClassLike): StorPropertyBuilder;
|
|
63
|
+
}
|
|
64
|
+
declare class StorPropertyInIndexedDb {
|
|
65
|
+
static for(scopeClass?: ClassLike): StorPropertyBuilder;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Helpers
|
|
69
|
+
*/
|
|
70
|
+
declare function uncache<CLASS_FUNCTION = any>(onlyInThisComponentClass: CLASS_FUNCTION, propertyValueToDeleteFromCache: keyof CLASS_FUNCTION): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Backwards-compatible facade:
|
|
73
|
+
* Stor.property.in.localstorage.for(...).withDefaultValue(...)
|
|
74
|
+
*/
|
|
75
|
+
declare class TaonStorageFacade {
|
|
76
|
+
static awaitPendingOperatios(): Promise<void>;
|
|
77
|
+
static get property(): {
|
|
78
|
+
in: {
|
|
79
|
+
readonly localstorage: StorPropertyBuilder;
|
|
80
|
+
readonly indexedb: StorPropertyBuilder;
|
|
81
|
+
file(filePath: string): StorPropertyBuilder;
|
|
82
|
+
jsonFile(filePath: string): StorPropertyBuilder;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
declare const Stor: typeof TaonStorageFacade;
|
|
87
|
+
|
|
88
|
+
export { SampleLogCmpComponent, Stor, StorConfig, StorPropertyInIndexedDb, StorPropertyInLocalStorage, keyDefaultValueAlreadySet, keyDefaultValueAreadySet, keyValue, storeName, uncache };
|
|
89
|
+
export type { PendingOperation, StorOptions, StorageEngine };
|
package/lib/constants.d.ts
DELETED