memorio 4.6.4 → 4.6.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/COPYRIGHT.md +6 -0
- package/LICENSE.md +21 -0
- package/SECURITY.md +48 -0
- package/index.cjs +269 -236
- package/index.js +314 -283
- package/llms.txt +405 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var e, t, o, r, s, n,
|
|
1
|
+
var e, t, o, r, s, n, i, a, l = Object.getOwnPropertyNames, c = (e, t) => function() {
|
|
2
2
|
return e && (t = (0, e[l(e)[0]])(e = 0)), t;
|
|
3
3
|
}, u = c({
|
|
4
4
|
"core/internal.ts"() {
|
|
@@ -77,11 +77,11 @@ function f() {
|
|
|
77
77
|
return e.Deno && e.Deno.version ? "deno" : "undefined" != typeof process && process.versions && process.versions.node ? "node" : "undefined" != typeof globalThis && void 0 !== globalThis.ServiceWorkerGlobalScope ? "edge" : "undefined" != typeof window && "undefined" != typeof document ? "browser" : "unknown";
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
function
|
|
80
|
+
function m() {
|
|
81
81
|
return "browser" === f();
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
function
|
|
84
|
+
function g() {
|
|
85
85
|
return "node" === f();
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -113,17 +113,17 @@ function y() {
|
|
|
113
113
|
return null;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
function
|
|
116
|
+
function w() {
|
|
117
117
|
return "undefined" != typeof indexedDB;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
function
|
|
120
|
+
function T() {
|
|
121
121
|
const e = f(), t = void 0 !== globalThis.isSecureContext ? globalThis.isSecureContext : "browser" === e;
|
|
122
122
|
return {
|
|
123
123
|
platform: e,
|
|
124
124
|
hasSessionStorage: null !== v(),
|
|
125
125
|
hasLocalStorage: null !== y(),
|
|
126
|
-
hasIndexedDB:
|
|
126
|
+
hasIndexedDB: w(),
|
|
127
127
|
hasDispatchEvent: "function" == typeof globalThis.dispatchEvent,
|
|
128
128
|
hasNavigator: "undefined" != typeof navigator,
|
|
129
129
|
hasProcess: "undefined" != typeof process,
|
|
@@ -134,14 +134,14 @@ function w() {
|
|
|
134
134
|
|
|
135
135
|
function O(e) {
|
|
136
136
|
const t = e || `context_${b()}`;
|
|
137
|
-
|
|
137
|
+
k(t);
|
|
138
138
|
const o = {
|
|
139
139
|
state: {},
|
|
140
140
|
store: new Map,
|
|
141
141
|
session: new Map,
|
|
142
142
|
cache: new Map
|
|
143
143
|
};
|
|
144
|
-
return
|
|
144
|
+
return a.set(t, o), {
|
|
145
145
|
id: t,
|
|
146
146
|
state: o.state,
|
|
147
147
|
store: {
|
|
@@ -183,20 +183,20 @@ function O(e) {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
function P() {
|
|
186
|
-
return Array.from(
|
|
186
|
+
return Array.from(a.keys());
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
function j(e) {
|
|
190
|
-
return
|
|
190
|
+
return a.delete(e);
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
function
|
|
193
|
+
function k(e) {
|
|
194
194
|
r.currentContext = e;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
var
|
|
197
|
+
var S, $, E = c({
|
|
198
198
|
"core/platform.ts"() {
|
|
199
|
-
u(),
|
|
199
|
+
u(), i = new Map, a = new Map;
|
|
200
200
|
}
|
|
201
201
|
}), x = {}, D = c({
|
|
202
202
|
"functions/idb/tools/db.create.ts"() {
|
|
@@ -212,7 +212,7 @@ var E, $, k = c({
|
|
|
212
212
|
};
|
|
213
213
|
});
|
|
214
214
|
}
|
|
215
|
-
}), A = {},
|
|
215
|
+
}), A = {}, C = c({
|
|
216
216
|
"functions/idb/tools/db.list.ts"() {
|
|
217
217
|
te(), $.db.list = async () => {
|
|
218
218
|
if (!("indexedDB" in globalThis) || !indexedDB.databases) return [];
|
|
@@ -224,15 +224,15 @@ var E, $, k = c({
|
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
|
-
}),
|
|
227
|
+
}), I = {}, _ = c({
|
|
228
228
|
"functions/idb/tools/db.exist.ts"() {
|
|
229
229
|
te(), $.db.exist = e => idbases?.some(t => t.name === e);
|
|
230
230
|
}
|
|
231
|
-
}), N = {},
|
|
231
|
+
}), N = {}, M = c({
|
|
232
232
|
"functions/idb/tools/db.quota.ts"() {
|
|
233
233
|
te(), $.db.quota = () => navigator.storage.estimate();
|
|
234
234
|
}
|
|
235
|
-
}), B = {},
|
|
235
|
+
}), B = {}, z = c({
|
|
236
236
|
"functions/idb/tools/db.delete.ts"() {
|
|
237
237
|
te(), d(), $.db.delete = e => new Promise((t, o) => {
|
|
238
238
|
n(`Removing database ${e}...`);
|
|
@@ -277,19 +277,19 @@ var E, $, k = c({
|
|
|
277
277
|
return t;
|
|
278
278
|
};
|
|
279
279
|
}
|
|
280
|
-
}), U = {},
|
|
280
|
+
}), U = {}, q = c({
|
|
281
281
|
"functions/idb/tools/db.support.ts"() {
|
|
282
282
|
te(), d(), $.db.support = () => {
|
|
283
283
|
const e = "indexedDB" in globalThis;
|
|
284
284
|
return e || n("Your environment doesn't support IndexedDB"), e;
|
|
285
285
|
};
|
|
286
286
|
}
|
|
287
|
-
}),
|
|
287
|
+
}), F = {}, L = c({
|
|
288
288
|
"functions/idb/tools/table.create.ts"() {
|
|
289
289
|
te(), d(), $.table.create = (e, t) => new Promise((o, r) => {
|
|
290
290
|
try {
|
|
291
|
-
const s = (Number($.db.version(e)) || 0) + 1,
|
|
292
|
-
|
|
291
|
+
const s = (Number($.db.version(e)) || 0) + 1, i = indexedDB.open(e, s);
|
|
292
|
+
i.onupgradeneeded = o => {
|
|
293
293
|
const r = o.target.result;
|
|
294
294
|
if (!r.objectStoreNames.contains(t)) {
|
|
295
295
|
const o = r.createObjectStore(t, {
|
|
@@ -302,24 +302,24 @@ var E, $, k = c({
|
|
|
302
302
|
unique: !1
|
|
303
303
|
}), n(`Table ${t} created in ${e}`);
|
|
304
304
|
}
|
|
305
|
-
},
|
|
306
|
-
|
|
307
|
-
},
|
|
308
|
-
console.error(`Error creating table ${t}:`,
|
|
305
|
+
}, i.onsuccess = () => {
|
|
306
|
+
i.result.close(), $.db.list(), o();
|
|
307
|
+
}, i.onerror = () => {
|
|
308
|
+
console.error(`Error creating table ${t}:`, i.error), r(i.error);
|
|
309
309
|
};
|
|
310
310
|
} catch (e) {
|
|
311
311
|
console.error("Critical error in table.create:", e), r(e);
|
|
312
312
|
}
|
|
313
313
|
});
|
|
314
314
|
}
|
|
315
|
-
}),
|
|
315
|
+
}), K = {}, H = c({
|
|
316
316
|
"functions/idb/tools/table.size.ts"() {
|
|
317
317
|
te(), d(), $.table.size = (e, t) => new Promise((o, r) => {
|
|
318
318
|
if (!e) return r(new Error("Database instance is required"));
|
|
319
319
|
if (!e.objectStoreNames.contains(t)) return o(0);
|
|
320
|
-
let s = 0,
|
|
321
|
-
const
|
|
322
|
-
|
|
320
|
+
let s = 0, i = 0;
|
|
321
|
+
const a = e.transaction([ t ], "readonly").objectStore(t).openCursor();
|
|
322
|
+
a.onsuccess = async e => {
|
|
323
323
|
const t = e.target.result;
|
|
324
324
|
if (t) {
|
|
325
325
|
try {
|
|
@@ -328,71 +328,71 @@ var E, $, k = c({
|
|
|
328
328
|
} catch (e) {
|
|
329
329
|
n(`Error stringifying IDB value tracking size:${e}`);
|
|
330
330
|
}
|
|
331
|
-
|
|
331
|
+
i++, i % 200 == 0 && await new Promise(e => setTimeout(e, 0)), t.continue();
|
|
332
332
|
} else o(s);
|
|
333
|
-
},
|
|
334
|
-
r(
|
|
333
|
+
}, a.onerror = () => {
|
|
334
|
+
r(a.error);
|
|
335
335
|
};
|
|
336
336
|
});
|
|
337
337
|
}
|
|
338
|
-
}), Y = {},
|
|
338
|
+
}), Y = {}, G = c({
|
|
339
339
|
"functions/idb/crud/data.delete.ts"() {
|
|
340
340
|
te(), d(), $.data.delete = (e, t, o) => new Promise((r, s) => {
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
const e =
|
|
341
|
+
const i = indexedDB.open(e);
|
|
342
|
+
i.onsuccess = () => {
|
|
343
|
+
const e = i.result;
|
|
344
344
|
if (!e.objectStoreNames.contains(t)) return e.close(), s(new Error(`Table ${t} not found`));
|
|
345
|
-
const
|
|
346
|
-
|
|
345
|
+
const a = e.transaction(t, "readwrite").objectStore(t).delete(o);
|
|
346
|
+
a.onsuccess = () => {
|
|
347
347
|
e.close(), n(`Record ${o} deleted from ${t}`), r();
|
|
348
|
-
},
|
|
349
|
-
e.close(), s(
|
|
348
|
+
}, a.onerror = () => {
|
|
349
|
+
e.close(), s(a.error);
|
|
350
350
|
};
|
|
351
|
-
},
|
|
351
|
+
}, i.onerror = () => s(i.error);
|
|
352
352
|
}), $.data.delete.all = (e, t) => new Promise((o, r) => {
|
|
353
353
|
const s = indexedDB.open(e);
|
|
354
354
|
s.onsuccess = e => {
|
|
355
355
|
const s = e.target.result;
|
|
356
356
|
if (!s.objectStoreNames.contains(t)) return s.close(), r(new Error(`Table ${t} not found`));
|
|
357
|
-
const
|
|
358
|
-
|
|
357
|
+
const i = s.transaction(t, "readwrite").objectStore(t).clear();
|
|
358
|
+
i.onsuccess = () => {
|
|
359
359
|
s.close(), n(`All data cleared from ${t}`), o();
|
|
360
|
-
},
|
|
361
|
-
s.close(), r(
|
|
360
|
+
}, i.onerror = () => {
|
|
361
|
+
s.close(), r(i.error);
|
|
362
362
|
};
|
|
363
363
|
}, s.onerror = () => r(s.error);
|
|
364
364
|
});
|
|
365
365
|
}
|
|
366
|
-
}),
|
|
366
|
+
}), Q = {}, X = c({
|
|
367
367
|
"functions/idb/crud/data.set.ts"() {
|
|
368
368
|
te(), d(), $.data.set = (e, t, o) => new Promise((r, s) => {
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
const
|
|
372
|
-
if (!
|
|
373
|
-
const l =
|
|
369
|
+
const i = indexedDB.open(e);
|
|
370
|
+
i.onsuccess = () => {
|
|
371
|
+
const a = i.result;
|
|
372
|
+
if (!a.objectStoreNames.contains(t)) return a.close(), s(new Error(`Table ${t} does not exist in ${e}`));
|
|
373
|
+
const l = a.transaction(t, "readwrite").objectStore(t).put(o);
|
|
374
374
|
l.onsuccess = () => {
|
|
375
|
-
|
|
375
|
+
a.close(), n(`Data saved in ${e}.${t}`), r(l.result);
|
|
376
376
|
}, l.onerror = e => {
|
|
377
|
-
|
|
377
|
+
a.close(), n(`Database insert error: ${l.error?.message}`), s(l.error);
|
|
378
378
|
};
|
|
379
|
-
},
|
|
380
|
-
s(
|
|
379
|
+
}, i.onerror = () => {
|
|
380
|
+
s(i.error);
|
|
381
381
|
};
|
|
382
382
|
});
|
|
383
383
|
}
|
|
384
|
-
}),
|
|
384
|
+
}), Z = {}, ee = c({
|
|
385
385
|
"functions/idb/crud/data.get.ts"() {
|
|
386
386
|
te(), $.data.get = (e, t, o) => new Promise((r, s) => {
|
|
387
387
|
const n = indexedDB.open(e);
|
|
388
388
|
n.onsuccess = n => {
|
|
389
|
-
const
|
|
390
|
-
if (!
|
|
391
|
-
const
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
},
|
|
395
|
-
|
|
389
|
+
const i = n.target.result;
|
|
390
|
+
if (!i.objectStoreNames.contains(t)) return i.close(), s(new Error(`Table ${t} not found in ${e}`));
|
|
391
|
+
const a = i.transaction(t, "readonly").objectStore(t).get(o);
|
|
392
|
+
a.onsuccess = () => {
|
|
393
|
+
i.close(), r(a.result);
|
|
394
|
+
}, a.onerror = () => {
|
|
395
|
+
i.close(), s(a.error);
|
|
396
396
|
};
|
|
397
397
|
}, n.onerror = () => {
|
|
398
398
|
s(n.error);
|
|
@@ -401,11 +401,11 @@ var E, $, k = c({
|
|
|
401
401
|
}
|
|
402
402
|
}), te = c({
|
|
403
403
|
"functions/idb/index.ts"() {
|
|
404
|
-
|
|
404
|
+
E(), S = w(), $ = {
|
|
405
405
|
db: {},
|
|
406
406
|
table: {},
|
|
407
407
|
data: {}
|
|
408
|
-
},
|
|
408
|
+
}, S ? (async () => {
|
|
409
409
|
Object.defineProperty($, "db", {
|
|
410
410
|
value: {},
|
|
411
411
|
writable: !0,
|
|
@@ -423,13 +423,13 @@ var E, $, k = c({
|
|
|
423
423
|
writable: !0,
|
|
424
424
|
configurable: !0,
|
|
425
425
|
enumerable: !1
|
|
426
|
-
}), await Promise.all([ Promise.resolve().then(() => (D(), x)), Promise.resolve().then(() => (
|
|
427
|
-
A)), Promise.resolve().then(() => (
|
|
428
|
-
N)), Promise.resolve().then(() => (
|
|
429
|
-
J)), Promise.resolve().then(() => (V(), R)), Promise.resolve().then(() => (
|
|
430
|
-
U)), Promise.resolve().then(() => (
|
|
431
|
-
|
|
432
|
-
|
|
426
|
+
}), await Promise.all([ Promise.resolve().then(() => (D(), x)), Promise.resolve().then(() => (C(),
|
|
427
|
+
A)), Promise.resolve().then(() => (_(), I)), Promise.resolve().then(() => (M(),
|
|
428
|
+
N)), Promise.resolve().then(() => (z(), B)), Promise.resolve().then(() => (W(),
|
|
429
|
+
J)), Promise.resolve().then(() => (V(), R)), Promise.resolve().then(() => (q(),
|
|
430
|
+
U)), Promise.resolve().then(() => (L(), F)), Promise.resolve().then(() => (H(),
|
|
431
|
+
K)), Promise.resolve().then(() => (G(), Y)), Promise.resolve().then(() => (X(),
|
|
432
|
+
Q)), Promise.resolve().then(() => (ee(), Z)) ]), Object.preventExtensions($), Object.seal($),
|
|
433
433
|
Object.freeze($);
|
|
434
434
|
})() : ($._disabled = !0, $._warning = "IndexedDB is not available in this environment (Node.js/Deno). Use store or session for persistence.",
|
|
435
435
|
console.warn("Memorio IDB: IndexedDB is not available in this environment. Use store or session for data persistence."));
|
|
@@ -454,9 +454,23 @@ var oe = {
|
|
|
454
454
|
const t = globalThis.events?.[e];
|
|
455
455
|
t && (globalThis.removeEventListener(e, t), delete globalThis.events[e]);
|
|
456
456
|
}
|
|
457
|
-
}, re = (
|
|
457
|
+
}, re = Symbol("memorio.target"), se = new WeakMap, ne = (e, t = null) => {
|
|
458
|
+
if (null === e || "object" != typeof e) return e;
|
|
459
|
+
if (void 0 !== e[re]) return ne(e[re], t);
|
|
460
|
+
if (t) {
|
|
461
|
+
if (t.has(e)) return e;
|
|
462
|
+
t.add(e);
|
|
463
|
+
}
|
|
464
|
+
const o = e.constructor?.name;
|
|
465
|
+
if ("Object" !== o && "Array" !== o) return e;
|
|
466
|
+
const r = Array.isArray(e) ? [] : {};
|
|
467
|
+
for (const o of Reflect.ownKeys(e)) r[o] = ne(e[o], t);
|
|
468
|
+
return r;
|
|
469
|
+
}, ie = (e, t, o = ".") => t.concat(e).join(o), ae = (e, o, s = []) => new Proxy(e, {
|
|
458
470
|
get(e, t) {
|
|
459
471
|
if ("__path" === t) return s.length > 0 ? "state." + s.join(".") : "state";
|
|
472
|
+
if (t === re) return e;
|
|
473
|
+
if (void 0 !== e[re]) return e;
|
|
460
474
|
if ("list" === t) return n('Some state could be hidden when you use "state.list". Use "state" to see the complete list '),
|
|
461
475
|
JSON.parse(JSON.stringify(e));
|
|
462
476
|
if ("string" == typeof t) {
|
|
@@ -479,27 +493,31 @@ var oe = {
|
|
|
479
493
|
}
|
|
480
494
|
try {
|
|
481
495
|
const r = Reflect.get(e, t);
|
|
482
|
-
|
|
496
|
+
if (r && "object" == typeof r && [ "Array", "Object" ].includes(r.constructor.name)) {
|
|
497
|
+
let e = se.get(r);
|
|
498
|
+
return e || (e = ae(r, o, s.concat(t)), se.set(r, e)), e;
|
|
499
|
+
}
|
|
500
|
+
return r;
|
|
483
501
|
} catch (e) {
|
|
484
502
|
return void console.error("Error: ", e);
|
|
485
503
|
}
|
|
486
504
|
},
|
|
487
|
-
set(e,
|
|
505
|
+
set(e, i, a) {
|
|
488
506
|
if (r.locked) return console.error("Error: state is locked. Use state.unlock() to enable modifications."),
|
|
489
507
|
!1;
|
|
490
|
-
if (t.includes(
|
|
491
|
-
if (e[
|
|
508
|
+
if (t.includes(i)) return console.error("key " + i + " is protected"), !1;
|
|
509
|
+
if (e[i] && "object" == typeof e[i] && Object.isFrozen(e[i])) return console.error(`Error: state '${i}' is locked`),
|
|
492
510
|
!1;
|
|
493
|
-
if (e[
|
|
511
|
+
if (e[i] && "object" == typeof e[i] && e[i].__locked) return console.error(`Error: state '${i}' is locked. Use state.${i}.unlock() to enable modifications.`),
|
|
494
512
|
!1;
|
|
495
513
|
try {
|
|
496
|
-
const t =
|
|
514
|
+
const t = ie(i, s), l = ne(a);
|
|
497
515
|
if (o({
|
|
498
516
|
action: "set",
|
|
499
517
|
path: t,
|
|
500
518
|
target: e,
|
|
501
|
-
newValue:
|
|
502
|
-
previousValue: Reflect.get(e,
|
|
519
|
+
newValue: l,
|
|
520
|
+
previousValue: Reflect.get(e, i)
|
|
503
521
|
}), (e => {
|
|
504
522
|
try {
|
|
505
523
|
oe.set(e, {
|
|
@@ -508,8 +526,8 @@ var oe = {
|
|
|
508
526
|
}
|
|
509
527
|
});
|
|
510
528
|
} catch (e) {}
|
|
511
|
-
})("state." + t), Reflect.set(e,
|
|
512
|
-
const t = e[
|
|
529
|
+
})("state." + t), Reflect.set(e, i, l), r.bumpStateVersion(), e[i] && "object" == typeof e[i]) {
|
|
530
|
+
const t = e[i];
|
|
513
531
|
if (t && "object" == typeof t) try {
|
|
514
532
|
Object.defineProperty(t, "__locked", {
|
|
515
533
|
writable: !0,
|
|
@@ -526,7 +544,7 @@ var oe = {
|
|
|
526
544
|
enumerable: !1,
|
|
527
545
|
configurable: !1,
|
|
528
546
|
value: !0
|
|
529
|
-
}), n(`State '${
|
|
547
|
+
}), n(`State '${i}' is now locked.`);
|
|
530
548
|
}
|
|
531
549
|
}), Object.defineProperty(t, "unlock", {
|
|
532
550
|
writable: !1,
|
|
@@ -538,7 +556,7 @@ var oe = {
|
|
|
538
556
|
enumerable: !1,
|
|
539
557
|
configurable: !1,
|
|
540
558
|
value: !1
|
|
541
|
-
}), n(`State '${
|
|
559
|
+
}), n(`State '${i}' is now unlocked.`);
|
|
542
560
|
}
|
|
543
561
|
});
|
|
544
562
|
} catch (e) {}
|
|
@@ -550,7 +568,7 @@ var oe = {
|
|
|
550
568
|
},
|
|
551
569
|
deleteProperty(e, t) {
|
|
552
570
|
try {
|
|
553
|
-
const r =
|
|
571
|
+
const r = ie(t, s);
|
|
554
572
|
return o({
|
|
555
573
|
action: "delete",
|
|
556
574
|
path: r,
|
|
@@ -562,96 +580,98 @@ var oe = {
|
|
|
562
580
|
},
|
|
563
581
|
ownKeys: e => Reflect.ownKeys(e),
|
|
564
582
|
getOwnPropertyDescriptor: (e, t) => Reflect.getOwnPropertyDescriptor(e, t)
|
|
565
|
-
}),
|
|
583
|
+
}), le = ae({}, () => {});
|
|
566
584
|
|
|
567
|
-
|
|
585
|
+
le.lock = () => {
|
|
568
586
|
r.locked = !0, n("State is now locked. All modifications are blocked.");
|
|
569
|
-
},
|
|
587
|
+
}, le.unlock = () => {
|
|
570
588
|
r.locked = !1, n("State is now unlocked. Modifications are allowed.");
|
|
571
|
-
},
|
|
589
|
+
}, E(), u(), d();
|
|
572
590
|
|
|
573
|
-
var
|
|
591
|
+
var ce = y(), ue = new Map;
|
|
574
592
|
|
|
575
|
-
function
|
|
593
|
+
function de() {
|
|
576
594
|
const e = r.currentContext || "" || "default";
|
|
577
|
-
return
|
|
595
|
+
return ue.has(e) || ue.set(e, new Map), ue.get(e);
|
|
578
596
|
}
|
|
579
597
|
|
|
580
|
-
var
|
|
598
|
+
var be = null !== ce;
|
|
581
599
|
|
|
582
|
-
function
|
|
600
|
+
function fe() {
|
|
583
601
|
const e = r.currentContext || "";
|
|
584
602
|
return e ? `${e}-` : "memorio_store_";
|
|
585
603
|
}
|
|
586
604
|
|
|
587
|
-
function
|
|
588
|
-
return e && "string" == typeof e ? e.length > 512 ? (
|
|
589
|
-
"") :
|
|
590
|
-
"")
|
|
605
|
+
function me(e) {
|
|
606
|
+
return e && "string" == typeof e ? e.length > 512 ? (console.warn(`[memorio store] key "${e}" exceeds 512 chars — operation aborted`),
|
|
607
|
+
"") : fe() + e : (console.warn("[memorio store] key is empty or not a string — operation aborted"),
|
|
608
|
+
"");
|
|
591
609
|
}
|
|
592
610
|
|
|
593
|
-
var
|
|
611
|
+
var ge = new Proxy({}, {});
|
|
594
612
|
|
|
595
613
|
Object.defineProperty(globalThis, "store", {
|
|
596
|
-
value:
|
|
614
|
+
value: ge,
|
|
597
615
|
enumerable: !1,
|
|
598
616
|
configurable: !0
|
|
599
|
-
}), Object.defineProperties(
|
|
617
|
+
}), Object.defineProperties(ge, {
|
|
600
618
|
get: {
|
|
601
619
|
value: e => {
|
|
602
|
-
if (e)
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
}
|
|
611
|
-
return null;
|
|
620
|
+
if (!e) return console.warn("[memorio store] store.get() called with empty or null key — returning null"),
|
|
621
|
+
null;
|
|
622
|
+
try {
|
|
623
|
+
return function(e) {
|
|
624
|
+
const t = be ? ce.getItem(e) : de().get(e);
|
|
625
|
+
return t ? JSON.parse(t) : t;
|
|
626
|
+
}(me(e));
|
|
627
|
+
} catch (t) {
|
|
628
|
+
s(`Error parsing store item '${e}': ${t}`);
|
|
612
629
|
}
|
|
630
|
+
return null;
|
|
613
631
|
}
|
|
614
632
|
},
|
|
615
633
|
getMultiple: {
|
|
616
634
|
value: e => {
|
|
617
635
|
const t = {};
|
|
618
636
|
for (const o of e) try {
|
|
619
|
-
const e =
|
|
637
|
+
const e = ge.get(o);
|
|
620
638
|
e && (t[o] = e);
|
|
621
|
-
} catch {
|
|
639
|
+
} catch (e) {
|
|
640
|
+
console.debug(`[memorio store] getMultiple error for key "${o}":`, e);
|
|
641
|
+
}
|
|
622
642
|
return t;
|
|
623
643
|
}
|
|
624
644
|
},
|
|
625
645
|
set: {
|
|
626
646
|
value: (e, t) => {
|
|
627
|
-
if (!e) return
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
}
|
|
641
|
-
s("Storing functions is not secure and is blocked for safety.");
|
|
647
|
+
if (!e) return console.warn("[memorio store] store.set() called with empty or null key — write aborted"),
|
|
648
|
+
!1;
|
|
649
|
+
const o = me(e);
|
|
650
|
+
if (!o) return !1;
|
|
651
|
+
if ("function" == typeof t) return console.warn("[memorio store] functions are not storable — write aborted for key: " + e),
|
|
652
|
+
s("Storing functions is not secure and is blocked for safety."), !1;
|
|
653
|
+
try {
|
|
654
|
+
!function(e, t) {
|
|
655
|
+
const o = JSON.stringify(t);
|
|
656
|
+
be ? ce.setItem(e, o) : de().set(e, o);
|
|
657
|
+
}(o, t);
|
|
658
|
+
} catch (t) {
|
|
659
|
+
return s(`Error setting store item '${e}': ${t}`), !1;
|
|
642
660
|
}
|
|
661
|
+
return !0;
|
|
643
662
|
}
|
|
644
663
|
},
|
|
645
664
|
remove: {
|
|
646
665
|
value: e => {
|
|
647
|
-
if (!e) return
|
|
648
|
-
|
|
666
|
+
if (!e) return console.debug("[memorio store] store.remove() called with empty or null key — returning false"),
|
|
667
|
+
!1;
|
|
668
|
+
const t = me(e);
|
|
649
669
|
if (!t) return !1;
|
|
650
670
|
try {
|
|
651
671
|
return function(e) {
|
|
652
|
-
if (
|
|
653
|
-
if (
|
|
654
|
-
} else if (
|
|
672
|
+
if (be) {
|
|
673
|
+
if (ce.getItem(e)) return ce.removeItem(e), !0;
|
|
674
|
+
} else if (de().has(e)) return de().delete(e), !0;
|
|
655
675
|
return !1;
|
|
656
676
|
}(t);
|
|
657
677
|
} catch (t) {
|
|
@@ -661,23 +681,23 @@ Object.defineProperty(globalThis, "store", {
|
|
|
661
681
|
}
|
|
662
682
|
},
|
|
663
683
|
delete: {
|
|
664
|
-
value: e =>
|
|
684
|
+
value: e => ge.remove(e)
|
|
665
685
|
},
|
|
666
686
|
removeAll: {
|
|
667
687
|
value: () => {
|
|
668
|
-
if (
|
|
688
|
+
if (be) {
|
|
669
689
|
const e = [];
|
|
670
|
-
for (let t = 0; t <
|
|
671
|
-
const o =
|
|
672
|
-
o?.startsWith(
|
|
690
|
+
for (let t = 0; t < ce.length; t++) {
|
|
691
|
+
const o = ce.key(t);
|
|
692
|
+
o?.startsWith(fe()) && e.push(o);
|
|
673
693
|
}
|
|
674
|
-
e.forEach(e =>
|
|
675
|
-
} else
|
|
694
|
+
e.forEach(e => ce.removeItem(e));
|
|
695
|
+
} else de().clear();
|
|
676
696
|
return !0;
|
|
677
697
|
}
|
|
678
698
|
},
|
|
679
699
|
clearAll: {
|
|
680
|
-
value: () => (
|
|
700
|
+
value: () => (ge.removeAll(), !0)
|
|
681
701
|
},
|
|
682
702
|
quota: {
|
|
683
703
|
value: async () => [ 0, 0 ]
|
|
@@ -685,36 +705,36 @@ Object.defineProperty(globalThis, "store", {
|
|
|
685
705
|
size: {
|
|
686
706
|
value: () => {
|
|
687
707
|
let e = 0;
|
|
688
|
-
return
|
|
689
|
-
if (t.startsWith(
|
|
690
|
-
const o =
|
|
708
|
+
return be ? Object.keys(ce).forEach(t => {
|
|
709
|
+
if (t.startsWith(fe())) {
|
|
710
|
+
const o = ce.getItem(t);
|
|
691
711
|
o && (e += o.length);
|
|
692
712
|
}
|
|
693
|
-
}) :
|
|
713
|
+
}) : de().forEach(t => {
|
|
694
714
|
e += t.length;
|
|
695
715
|
}), e;
|
|
696
716
|
}
|
|
697
717
|
},
|
|
698
718
|
isPersistent: {
|
|
699
|
-
get: () =>
|
|
719
|
+
get: () => be
|
|
700
720
|
},
|
|
701
721
|
list: {
|
|
702
722
|
value: () => {
|
|
703
723
|
const e = {};
|
|
704
724
|
try {
|
|
705
|
-
if (
|
|
706
|
-
const o =
|
|
707
|
-
if (o?.startsWith(
|
|
708
|
-
const t = o.replace(
|
|
725
|
+
if (be) for (let t = 0; t < ce.length; t++) {
|
|
726
|
+
const o = ce.key(t);
|
|
727
|
+
if (o?.startsWith(fe())) {
|
|
728
|
+
const t = o.replace(fe(), ""), r = ce.getItem(o);
|
|
709
729
|
if (null !== r) try {
|
|
710
730
|
e[t] = JSON.parse(r);
|
|
711
731
|
} catch {
|
|
712
732
|
e[t] = r;
|
|
713
733
|
}
|
|
714
734
|
}
|
|
715
|
-
} else
|
|
716
|
-
if (o.startsWith(
|
|
717
|
-
const r = o.replace(
|
|
735
|
+
} else de().forEach((t, o) => {
|
|
736
|
+
if (o.startsWith(fe())) {
|
|
737
|
+
const r = o.replace(fe(), "");
|
|
718
738
|
try {
|
|
719
739
|
e[r] = JSON.parse(t);
|
|
720
740
|
} catch {
|
|
@@ -728,95 +748,106 @@ Object.defineProperty(globalThis, "store", {
|
|
|
728
748
|
return e;
|
|
729
749
|
}
|
|
730
750
|
}
|
|
731
|
-
}), Object.freeze(
|
|
751
|
+
}), Object.freeze(ge), E(), u(), d();
|
|
732
752
|
|
|
733
|
-
var
|
|
753
|
+
var he = v(), pe = new Map;
|
|
734
754
|
|
|
735
|
-
function
|
|
755
|
+
function ve() {
|
|
736
756
|
const e = r.currentContext || "" || "default";
|
|
737
|
-
return
|
|
757
|
+
return pe.has(e) || pe.set(e, new Map), pe.get(e);
|
|
738
758
|
}
|
|
739
759
|
|
|
740
|
-
var
|
|
760
|
+
var ye = null !== he;
|
|
741
761
|
|
|
742
|
-
function
|
|
762
|
+
function we() {
|
|
743
763
|
const e = r.currentContext || "";
|
|
744
764
|
return e ? `${e}-` : "memorio_session_";
|
|
745
765
|
}
|
|
746
766
|
|
|
747
|
-
function
|
|
748
|
-
return e && "string" == typeof e ? e.length > 512 ? (
|
|
749
|
-
"") :
|
|
750
|
-
"")
|
|
767
|
+
function Te(e) {
|
|
768
|
+
return e && "string" == typeof e ? e.length > 512 ? (console.warn(`[memorio session] key "${e}" exceeds 512 chars — operation aborted`),
|
|
769
|
+
"") : we() + e : (console.warn("[memorio session] key is empty or not a string — operation aborted"),
|
|
770
|
+
"");
|
|
751
771
|
}
|
|
752
772
|
|
|
753
|
-
var
|
|
773
|
+
var Oe = new Proxy({}, {});
|
|
754
774
|
|
|
755
775
|
Object.defineProperty(globalThis, "session", {
|
|
756
|
-
value:
|
|
776
|
+
value: Oe,
|
|
757
777
|
enumerable: !1,
|
|
758
778
|
configurable: !0
|
|
759
|
-
}), Object.defineProperties(
|
|
779
|
+
}), Object.defineProperties(Oe, {
|
|
760
780
|
get: {
|
|
761
781
|
value: e => {
|
|
762
|
-
if (e)
|
|
782
|
+
if (!e) return console.warn("[memorio session] session.get() called with empty or null key — returning null"),
|
|
783
|
+
null;
|
|
784
|
+
try {
|
|
763
785
|
return function(e) {
|
|
764
|
-
const t =
|
|
786
|
+
const t = ye ? he.getItem(e) : ve().get(e);
|
|
765
787
|
return t ? JSON.parse(t) : t;
|
|
766
|
-
}(
|
|
788
|
+
}(Te(e));
|
|
767
789
|
} catch (t) {
|
|
768
790
|
s(`Error parsing session item '${e}':${t}`);
|
|
769
791
|
}
|
|
792
|
+
return null;
|
|
770
793
|
}
|
|
771
794
|
},
|
|
772
795
|
set: {
|
|
773
796
|
value: (e, t) => {
|
|
774
|
-
if (!e) return
|
|
775
|
-
|
|
776
|
-
|
|
797
|
+
if (!e) return console.warn("[memorio session] session.set() called with empty or null key — write aborted"),
|
|
798
|
+
!1;
|
|
799
|
+
const o = Te(e);
|
|
800
|
+
if (!o) return !1;
|
|
801
|
+
if ("function" == typeof t) return console.warn("[memorio session] functions are not storable — write aborted for key: " + e),
|
|
802
|
+
s("It's not secure to session functions."), !1;
|
|
803
|
+
try {
|
|
777
804
|
!function(e, t) {
|
|
778
805
|
const o = JSON.stringify(t);
|
|
779
|
-
|
|
806
|
+
ye ? he.setItem(e, o) : ve().set(e, o);
|
|
780
807
|
}(o, t);
|
|
781
808
|
} catch (t) {
|
|
782
|
-
s(`Error setting session item '${e}': ${t}`);
|
|
783
|
-
}
|
|
809
|
+
return s(`Error setting session item '${e}': ${t}`), !1;
|
|
810
|
+
}
|
|
811
|
+
return !0;
|
|
784
812
|
}
|
|
785
813
|
},
|
|
786
814
|
remove: {
|
|
787
815
|
value: e => {
|
|
788
|
-
if (!e) return
|
|
789
|
-
|
|
790
|
-
|
|
816
|
+
if (!e) return console.warn("[memorio session] session.remove() called with empty or null key — returning false"),
|
|
817
|
+
!1;
|
|
818
|
+
const t = Te(e);
|
|
819
|
+
if (!t) return !1;
|
|
820
|
+
try {
|
|
791
821
|
return function(e) {
|
|
792
|
-
if (
|
|
793
|
-
if (
|
|
794
|
-
} else if (
|
|
822
|
+
if (ye) {
|
|
823
|
+
if (he.getItem(e)) return he.removeItem(e), !0;
|
|
824
|
+
} else if (ve().has(e)) return ve().delete(e), !0;
|
|
795
825
|
return !1;
|
|
796
826
|
}(t);
|
|
797
827
|
} catch (t) {
|
|
798
828
|
s(`Error removing session item '${e}': ${t}`);
|
|
799
829
|
}
|
|
830
|
+
return !1;
|
|
800
831
|
}
|
|
801
832
|
},
|
|
802
833
|
delete: {
|
|
803
|
-
value: e =>
|
|
834
|
+
value: e => Oe.remove(e)
|
|
804
835
|
},
|
|
805
836
|
removeAll: {
|
|
806
837
|
value: () => {
|
|
807
|
-
if (
|
|
838
|
+
if (ye) {
|
|
808
839
|
const e = [];
|
|
809
|
-
for (let t = 0; t <
|
|
810
|
-
const o =
|
|
811
|
-
o?.startsWith(
|
|
840
|
+
for (let t = 0; t < he.length; t++) {
|
|
841
|
+
const o = he.key(t);
|
|
842
|
+
o?.startsWith(we()) && e.push(o);
|
|
812
843
|
}
|
|
813
|
-
e.forEach(e =>
|
|
814
|
-
} else
|
|
844
|
+
e.forEach(e => he.removeItem(e));
|
|
845
|
+
} else ve().clear();
|
|
815
846
|
return !0;
|
|
816
847
|
}
|
|
817
848
|
},
|
|
818
849
|
clearAll: {
|
|
819
|
-
value: () => (
|
|
850
|
+
value: () => (Oe.removeAll(), !0)
|
|
820
851
|
},
|
|
821
852
|
quota: {
|
|
822
853
|
value: async () => [ 0, 0 ]
|
|
@@ -824,36 +855,36 @@ Object.defineProperty(globalThis, "session", {
|
|
|
824
855
|
size: {
|
|
825
856
|
value: () => {
|
|
826
857
|
let e = 0;
|
|
827
|
-
return
|
|
828
|
-
if (t.startsWith(
|
|
829
|
-
const o =
|
|
858
|
+
return ye ? Object.keys(he).forEach(t => {
|
|
859
|
+
if (t.startsWith(we())) {
|
|
860
|
+
const o = he.getItem(t);
|
|
830
861
|
o && (e += o.length);
|
|
831
862
|
}
|
|
832
|
-
}) :
|
|
863
|
+
}) : ve().forEach(t => {
|
|
833
864
|
e += t.length;
|
|
834
865
|
}), e;
|
|
835
866
|
}
|
|
836
867
|
},
|
|
837
868
|
isPersistent: {
|
|
838
|
-
get: () =>
|
|
869
|
+
get: () => ye
|
|
839
870
|
},
|
|
840
871
|
list: {
|
|
841
872
|
value: () => {
|
|
842
873
|
const e = {};
|
|
843
874
|
try {
|
|
844
|
-
if (
|
|
845
|
-
const o =
|
|
846
|
-
if (o?.startsWith(
|
|
847
|
-
const t = o.replace(
|
|
875
|
+
if (ye) for (let t = 0; t < he.length; t++) {
|
|
876
|
+
const o = he.key(t);
|
|
877
|
+
if (o?.startsWith(we())) {
|
|
878
|
+
const t = o.replace(we(), ""), r = he.getItem(o);
|
|
848
879
|
if (null !== r) try {
|
|
849
880
|
e[t] = JSON.parse(r);
|
|
850
881
|
} catch {
|
|
851
882
|
e[t] = r;
|
|
852
883
|
}
|
|
853
884
|
}
|
|
854
|
-
} else
|
|
855
|
-
if (o.startsWith(
|
|
856
|
-
const r = o.replace(
|
|
885
|
+
} else ve().forEach((t, o) => {
|
|
886
|
+
if (o.startsWith(we())) {
|
|
887
|
+
const r = o.replace(we(), "");
|
|
857
888
|
try {
|
|
858
889
|
e[r] = JSON.parse(t);
|
|
859
890
|
} catch {
|
|
@@ -867,24 +898,24 @@ Object.defineProperty(globalThis, "session", {
|
|
|
867
898
|
return e;
|
|
868
899
|
}
|
|
869
900
|
}
|
|
870
|
-
}), Object.freeze(
|
|
901
|
+
}), Object.freeze(Oe);
|
|
871
902
|
|
|
872
|
-
var
|
|
873
|
-
get: (e, t) => "get" === t ? e =>
|
|
874
|
-
|
|
875
|
-
} : "remove" === t ? e => (delete
|
|
903
|
+
var Pe = {}, je = new Proxy({}, {
|
|
904
|
+
get: (e, t) => "get" === t ? e => Pe[e] : "set" === t ? (e, t) => {
|
|
905
|
+
Pe[e] = t;
|
|
906
|
+
} : "remove" === t ? e => (delete Pe[e], !0) : "removeAll" === t || "clear" === t ? () => (Object.keys(Pe).forEach(e => delete Pe[e]),
|
|
876
907
|
!0) : "list" === t ? () => ({
|
|
877
|
-
...
|
|
878
|
-
}) :
|
|
879
|
-
set: (e, t, o) => (
|
|
880
|
-
deleteProperty: (e, t) => (delete
|
|
908
|
+
...Pe
|
|
909
|
+
}) : Pe[t],
|
|
910
|
+
set: (e, t, o) => (Pe[t] = o, !0),
|
|
911
|
+
deleteProperty: (e, t) => (delete Pe[t], !0)
|
|
881
912
|
});
|
|
882
913
|
|
|
883
|
-
Object.freeze(
|
|
914
|
+
Object.freeze(je), te(), d();
|
|
884
915
|
|
|
885
|
-
var
|
|
886
|
-
|
|
887
|
-
|
|
916
|
+
var ke = !1, Se = (e, t = null, o = !0) => {
|
|
917
|
+
ke || (console.warn('DEPRECATED: "observer" is deprecated and will be removed in future versions. Please use "useObserver" instead.'),
|
|
918
|
+
ke = !0);
|
|
888
919
|
const r = e => "string" == typeof e ? e : e && "object" == typeof e && e.__path ? e.__path : null, s = r(e);
|
|
889
920
|
if (e || t) if (e || !t) {
|
|
890
921
|
if (s) {
|
|
@@ -901,15 +932,15 @@ var Oe = !1, Pe = (e, t = null, o = !0) => {
|
|
|
901
932
|
const s = r(e);
|
|
902
933
|
if (!s) return;
|
|
903
934
|
if ("string" != typeof e && (!e || "object" != typeof e)) return void console.error("Observer Error: name of state need to be a 'string' like 'state.test' or a direct state value");
|
|
904
|
-
const n = Array.isArray(t) ? t : [ t ],
|
|
905
|
-
return
|
|
935
|
+
const n = Array.isArray(t) ? t : [ t ], i = globalThis.observer;
|
|
936
|
+
return i?.list?.[s] && oe.remove(s), void n.forEach(e => {
|
|
906
937
|
"function" == typeof e && oe.listen(s, e, o);
|
|
907
938
|
});
|
|
908
939
|
}
|
|
909
940
|
} else console.error("Observer Error: You need to declare what state need to be monitored as string like 'state.test'."); else console.error("Observer Error: You need to setup observer correctly, Some parameters are missed!");
|
|
910
941
|
};
|
|
911
942
|
|
|
912
|
-
Object.defineProperties(
|
|
943
|
+
Object.defineProperties(Se, {
|
|
913
944
|
list: {
|
|
914
945
|
get: () => globalThis.events
|
|
915
946
|
},
|
|
@@ -939,19 +970,19 @@ Object.defineProperties(Pe, {
|
|
|
939
970
|
configurable: !0
|
|
940
971
|
});
|
|
941
972
|
|
|
942
|
-
var
|
|
973
|
+
var $e = (e, t = []) => {
|
|
943
974
|
if (!t || "function" != typeof e) return () => {};
|
|
944
|
-
const s = [],
|
|
975
|
+
const s = [], i = Array.isArray(t) && !t.__path ? t : [ t ];
|
|
945
976
|
try {
|
|
946
|
-
return
|
|
947
|
-
let
|
|
977
|
+
return i.forEach(t => {
|
|
978
|
+
let i = "";
|
|
948
979
|
if ("function" == typeof t) {
|
|
949
980
|
const e = o(t);
|
|
950
|
-
e && (
|
|
951
|
-
} else "object" == typeof t && null !== t && (
|
|
952
|
-
if (
|
|
953
|
-
|
|
954
|
-
const t =
|
|
981
|
+
e && (i = e);
|
|
982
|
+
} else "object" == typeof t && null !== t && (i = t.__path || ("function" == typeof t.toString && "[object Object]" !== t.toString() ? t.toString() : ""));
|
|
983
|
+
if (i) {
|
|
984
|
+
i = i.replace(/^(\(\)\s*=>\s*)/, "").replace(/^globalThis\./, "").replace(/^state\./, "");
|
|
985
|
+
const t = i.startsWith("store.") || i.startsWith("state.") ? i : "state." + i;
|
|
955
986
|
oe.listen(t, () => e()), s.push(t);
|
|
956
987
|
} else {
|
|
957
988
|
r.clearTrackedPaths(), r.tracking = !0;
|
|
@@ -974,7 +1005,7 @@ var je = (e, t = []) => {
|
|
|
974
1005
|
}
|
|
975
1006
|
};
|
|
976
1007
|
|
|
977
|
-
function
|
|
1008
|
+
function Ee() {
|
|
978
1009
|
if (!globalThis.store) return {};
|
|
979
1010
|
const e = {}, t = globalThis.store;
|
|
980
1011
|
if ("function" == typeof t.list) try {
|
|
@@ -987,7 +1018,7 @@ function Se() {
|
|
|
987
1018
|
return e;
|
|
988
1019
|
}
|
|
989
1020
|
|
|
990
|
-
function
|
|
1021
|
+
function xe() {
|
|
991
1022
|
if (!globalThis.session) return {};
|
|
992
1023
|
const e = {}, t = globalThis.session;
|
|
993
1024
|
if ("function" == typeof t.list) try {
|
|
@@ -1000,11 +1031,11 @@ function Ee() {
|
|
|
1000
1031
|
return e;
|
|
1001
1032
|
}
|
|
1002
1033
|
|
|
1003
|
-
globalThis.useObserver =
|
|
1034
|
+
globalThis.useObserver = $e, Object.freeze(globalThis.useObserver), d(), u();
|
|
1004
1035
|
|
|
1005
|
-
var
|
|
1036
|
+
var De = e => {
|
|
1006
1037
|
globalThis[e] && "function" == typeof globalThis[e].clear ? globalThis[e].clear() : console.error(`Module ${e} not found or does not support clear()`);
|
|
1007
|
-
},
|
|
1038
|
+
}, Ae = {
|
|
1008
1039
|
inspect: () => {
|
|
1009
1040
|
if (!0 === r.debug) {
|
|
1010
1041
|
if (globalThis.state) {
|
|
@@ -1013,7 +1044,7 @@ var $e = e => {
|
|
|
1013
1044
|
t = "function" == typeof e ? e() : "object" == typeof e && null !== e ? e : globalThis.state,
|
|
1014
1045
|
console.table(t);
|
|
1015
1046
|
}
|
|
1016
|
-
if (globalThis.store && console.table(
|
|
1047
|
+
if (globalThis.store && console.table(Ee()), globalThis.session && console.table(xe()),
|
|
1017
1048
|
globalThis.cache) {
|
|
1018
1049
|
const e = globalThis.cache.list;
|
|
1019
1050
|
let t;
|
|
@@ -1040,9 +1071,9 @@ var $e = e => {
|
|
|
1040
1071
|
lastUpdate: (new Date).toISOString()
|
|
1041
1072
|
};
|
|
1042
1073
|
},
|
|
1043
|
-
clear:
|
|
1074
|
+
clear: De,
|
|
1044
1075
|
clearAll: () => {
|
|
1045
|
-
|
|
1076
|
+
De("state"), De("store"), De("session"), De("cache");
|
|
1046
1077
|
},
|
|
1047
1078
|
exportData: () => {
|
|
1048
1079
|
const e = {
|
|
@@ -1053,8 +1084,8 @@ var $e = e => {
|
|
|
1053
1084
|
return;
|
|
1054
1085
|
}
|
|
1055
1086
|
})(),
|
|
1056
|
-
store:
|
|
1057
|
-
session:
|
|
1087
|
+
store: Ee(),
|
|
1088
|
+
session: xe(),
|
|
1058
1089
|
cache: (() => {
|
|
1059
1090
|
if (globalThis.cache) try {
|
|
1060
1091
|
return "function" == typeof globalThis.cache.list ? globalThis.cache.list() : globalThis.cache;
|
|
@@ -1100,55 +1131,55 @@ var $e = e => {
|
|
|
1100
1131
|
|
|
1101
1132
|
u(), d();
|
|
1102
1133
|
|
|
1103
|
-
var
|
|
1134
|
+
var Ce = {
|
|
1104
1135
|
enabled: !0,
|
|
1105
1136
|
logToConsole: !0,
|
|
1106
1137
|
modules: [ "state", "store", "session", "cache", "idb" ],
|
|
1107
1138
|
maxEntries: 1e3
|
|
1108
|
-
},
|
|
1139
|
+
}, Ie = [], _e = e => Ce.enabled && Ce.modules.includes(e), Ne = e => ({
|
|
1109
1140
|
state: "#4CAF50",
|
|
1110
1141
|
store: "#2196F3",
|
|
1111
1142
|
session: "#FF9800",
|
|
1112
1143
|
cache: "#9C27B0",
|
|
1113
1144
|
idb: "#F44336"
|
|
1114
|
-
}[e] || "#888888"),
|
|
1145
|
+
}[e] || "#888888"), Me = {
|
|
1115
1146
|
configure: e => {
|
|
1116
|
-
|
|
1117
|
-
...
|
|
1147
|
+
Ce = {
|
|
1148
|
+
...Ce,
|
|
1118
1149
|
...e
|
|
1119
1150
|
};
|
|
1120
1151
|
},
|
|
1121
1152
|
enable: () => {
|
|
1122
|
-
|
|
1153
|
+
Ce.enabled = !0;
|
|
1123
1154
|
},
|
|
1124
1155
|
disable: () => {
|
|
1125
|
-
|
|
1156
|
+
Ce.enabled = !1;
|
|
1126
1157
|
},
|
|
1127
|
-
isEnabled:
|
|
1128
|
-
log: (e, t, o, s,
|
|
1129
|
-
if (!
|
|
1130
|
-
const
|
|
1158
|
+
isEnabled: _e,
|
|
1159
|
+
log: (e, t, o, s, i) => {
|
|
1160
|
+
if (!_e(e)) return;
|
|
1161
|
+
const a = {
|
|
1131
1162
|
timestamp: (new Date).toISOString(),
|
|
1132
1163
|
module: e,
|
|
1133
1164
|
action: t,
|
|
1134
1165
|
path: o,
|
|
1135
1166
|
value: s,
|
|
1136
|
-
previousValue:
|
|
1167
|
+
previousValue: i
|
|
1137
1168
|
};
|
|
1138
|
-
if (
|
|
1139
|
-
const r = `[Memorio:${e.toUpperCase()}]`,
|
|
1140
|
-
n(`%c${r}%c ${t} ${o},\n color: ${
|
|
1141
|
-
void 0 !== s && n(` → value:${s}`), void 0 !==
|
|
1169
|
+
if (Ie.push(a), Ie.length > Ce.maxEntries && Ie.shift(), Ce.logToConsole && !0 === r.debug) {
|
|
1170
|
+
const r = `[Memorio:${e.toUpperCase()}]`, a = Ne(e);
|
|
1171
|
+
n(`%c${r}%c ${t} ${o},\n color: ${a}; font-weight: bold,\n color: inherit`),
|
|
1172
|
+
void 0 !== s && n(` → value:${s}`), void 0 !== i && n(` ← previous:${i}`);
|
|
1142
1173
|
}
|
|
1143
|
-
|
|
1174
|
+
Ce.customHandler && Ce.customHandler(a);
|
|
1144
1175
|
},
|
|
1145
|
-
getHistory: () => [ ...
|
|
1176
|
+
getHistory: () => [ ...Ie ],
|
|
1146
1177
|
clearHistory: () => {
|
|
1147
|
-
|
|
1178
|
+
Ie.length = 0;
|
|
1148
1179
|
},
|
|
1149
1180
|
getStats: () => {
|
|
1150
1181
|
const e = {
|
|
1151
|
-
total:
|
|
1182
|
+
total: Ie.length,
|
|
1152
1183
|
state: 0,
|
|
1153
1184
|
store: 0,
|
|
1154
1185
|
session: 0,
|
|
@@ -1159,18 +1190,18 @@ var xe = {
|
|
|
1159
1190
|
delete: 0,
|
|
1160
1191
|
clear: 0
|
|
1161
1192
|
};
|
|
1162
|
-
for (const t of
|
|
1193
|
+
for (const t of Ie) if (t) {
|
|
1163
1194
|
const o = t.module, r = t.action;
|
|
1164
1195
|
o && "number" == typeof e[o] && e[o]++, r && "number" == typeof e[r] && e[r]++;
|
|
1165
1196
|
}
|
|
1166
1197
|
return e;
|
|
1167
1198
|
},
|
|
1168
|
-
exportLogs: () => JSON.stringify(
|
|
1199
|
+
exportLogs: () => JSON.stringify(Ie, null, 2)
|
|
1169
1200
|
};
|
|
1170
1201
|
|
|
1171
|
-
u(),
|
|
1202
|
+
u(), E(), E(), u();
|
|
1172
1203
|
|
|
1173
|
-
var
|
|
1204
|
+
var Be = "4.6.6";
|
|
1174
1205
|
|
|
1175
1206
|
te(), d(), Object.defineProperty(globalThis, "memorio", {
|
|
1176
1207
|
value: {
|
|
@@ -1179,8 +1210,8 @@ te(), d(), Object.defineProperty(globalThis, "memorio", {
|
|
|
1179
1210
|
array: [],
|
|
1180
1211
|
dispatch: oe,
|
|
1181
1212
|
message: s,
|
|
1182
|
-
devtools:
|
|
1183
|
-
logger:
|
|
1213
|
+
devtools: Ae,
|
|
1214
|
+
logger: Me,
|
|
1184
1215
|
setDescription: () => {}
|
|
1185
1216
|
},
|
|
1186
1217
|
writable: !1,
|
|
@@ -1193,7 +1224,7 @@ te(), d(), Object.defineProperty(globalThis, "memorio", {
|
|
|
1193
1224
|
}), Object.defineProperty(memorio, "version", {
|
|
1194
1225
|
writable: !1,
|
|
1195
1226
|
enumerable: !1,
|
|
1196
|
-
value:
|
|
1227
|
+
value: Be
|
|
1197
1228
|
}), Object.defineProperty(memorio, "debug", {
|
|
1198
1229
|
get: () => r.debug,
|
|
1199
1230
|
set: e => {
|
|
@@ -1202,22 +1233,22 @@ te(), d(), Object.defineProperty(globalThis, "memorio", {
|
|
|
1202
1233
|
enumerable: !1
|
|
1203
1234
|
});
|
|
1204
1235
|
|
|
1205
|
-
var
|
|
1236
|
+
var ze = T();
|
|
1206
1237
|
|
|
1207
1238
|
Object.defineProperty(memorio, "_platform", {
|
|
1208
1239
|
writable: !1,
|
|
1209
1240
|
enumerable: !1,
|
|
1210
|
-
value:
|
|
1241
|
+
value: ze.platform
|
|
1211
1242
|
}), Object.defineProperty(memorio, "_capabilities", {
|
|
1212
1243
|
writable: !1,
|
|
1213
1244
|
enumerable: !1,
|
|
1214
|
-
value:
|
|
1245
|
+
value: ze
|
|
1215
1246
|
}), Object.defineProperty(memorio, "_sessionId", {
|
|
1216
1247
|
writable: !1,
|
|
1217
1248
|
enumerable: !1,
|
|
1218
1249
|
value: b()
|
|
1219
1250
|
}), function() {
|
|
1220
|
-
const e =
|
|
1251
|
+
const e = T(), t = globalThis;
|
|
1221
1252
|
e.hasDispatchEvent || (t.dispatchEvent = function(e) {
|
|
1222
1253
|
return !0;
|
|
1223
1254
|
}, "undefined" == typeof CustomEvent && (t.CustomEvent = class {
|
|
@@ -1227,15 +1258,15 @@ Object.defineProperty(memorio, "_platform", {
|
|
|
1227
1258
|
this.type = e, this.detail = t;
|
|
1228
1259
|
}
|
|
1229
1260
|
})), "function" != typeof t.addEventListener && (t.addEventListener = function(e, t) {
|
|
1230
|
-
|
|
1261
|
+
i.has(e) || i.set(e, []), i.get(e).push(t);
|
|
1231
1262
|
}, t.removeEventListener = function(e, t) {
|
|
1232
|
-
const o =
|
|
1263
|
+
const o = i.get(e);
|
|
1233
1264
|
if (o) {
|
|
1234
1265
|
const e = o.indexOf(t);
|
|
1235
1266
|
e > -1 && o.splice(e, 1);
|
|
1236
1267
|
}
|
|
1237
1268
|
}, t.dispatchEvent = function(e) {
|
|
1238
|
-
const t =
|
|
1269
|
+
const t = i.get(e.type);
|
|
1239
1270
|
return t && t.forEach(t => {
|
|
1240
1271
|
try {
|
|
1241
1272
|
t(e);
|
|
@@ -1244,25 +1275,25 @@ Object.defineProperty(memorio, "_platform", {
|
|
|
1244
1275
|
}
|
|
1245
1276
|
}), !0;
|
|
1246
1277
|
});
|
|
1247
|
-
}(), memorio.isBrowser =
|
|
1248
|
-
memorio.getCapabilities =
|
|
1278
|
+
}(), memorio.isBrowser = m, memorio.isNode = g, memorio.isDeno = h, memorio.isEdge = p,
|
|
1279
|
+
memorio.getCapabilities = T, memorio.createContext = O, memorio.listContexts = P,
|
|
1249
1280
|
memorio.deleteContext = j, memorio.isolate = e => O(e), Object.defineProperty(globalThis, "state", {
|
|
1250
|
-
value:
|
|
1281
|
+
value: le,
|
|
1251
1282
|
writable: !0,
|
|
1252
1283
|
enumerable: !1,
|
|
1253
1284
|
configurable: !0
|
|
1254
1285
|
}), Object.defineProperty(globalThis, "store", {
|
|
1255
|
-
value:
|
|
1286
|
+
value: ge,
|
|
1256
1287
|
writable: !0,
|
|
1257
1288
|
enumerable: !1,
|
|
1258
1289
|
configurable: !0
|
|
1259
1290
|
}), Object.defineProperty(globalThis, "session", {
|
|
1260
|
-
value:
|
|
1291
|
+
value: Oe,
|
|
1261
1292
|
writable: !0,
|
|
1262
1293
|
enumerable: !1,
|
|
1263
1294
|
configurable: !0
|
|
1264
1295
|
}), Object.defineProperty(globalThis, "cache", {
|
|
1265
|
-
value:
|
|
1296
|
+
value: je,
|
|
1266
1297
|
writable: !0,
|
|
1267
1298
|
enumerable: !1,
|
|
1268
1299
|
configurable: !0
|
|
@@ -1272,12 +1303,12 @@ memorio.deleteContext = j, memorio.isolate = e => O(e), Object.defineProperty(gl
|
|
|
1272
1303
|
enumerable: !1,
|
|
1273
1304
|
configurable: !0
|
|
1274
1305
|
}), Object.defineProperty(globalThis, "observer", {
|
|
1275
|
-
value:
|
|
1306
|
+
value: Se,
|
|
1276
1307
|
writable: !0,
|
|
1277
1308
|
enumerable: !1,
|
|
1278
1309
|
configurable: !0
|
|
1279
1310
|
}), Object.defineProperty(globalThis, "useObserver", {
|
|
1280
|
-
value:
|
|
1311
|
+
value: $e,
|
|
1281
1312
|
writable: !0,
|
|
1282
1313
|
enumerable: !1,
|
|
1283
1314
|
configurable: !0
|
|
@@ -1289,7 +1320,7 @@ memorio.deleteContext = j, memorio.isolate = e => O(e), Object.defineProperty(gl
|
|
|
1289
1320
|
}), Object.defineProperty(memorio, "setContext", {
|
|
1290
1321
|
writable: !1,
|
|
1291
1322
|
enumerable: !1,
|
|
1292
|
-
value: e =>
|
|
1323
|
+
value: e => k(e)
|
|
1293
1324
|
}), Object.defineProperty(memorio, "getContext", {
|
|
1294
1325
|
writable: !1,
|
|
1295
1326
|
enumerable: !1,
|
|
@@ -1307,9 +1338,9 @@ memorio.deleteContext = j, memorio.isolate = e => O(e), Object.defineProperty(gl
|
|
|
1307
1338
|
get: () => globalThis.cache,
|
|
1308
1339
|
configurable: !0
|
|
1309
1340
|
}), memorio.help = function() {
|
|
1310
|
-
console.debug(`\n🧠 Memorio ${
|
|
1341
|
+
console.debug(`\n🧠 Memorio ${Be} - Help\n\nCore Modules:\n state - Reactive state management\n store - Persistent storage (localStorage/Map)\n session - Session storage (sessionStorage/Map)\n cache - In-memory cache\n idb - IndexedDB (browser only)\n\nContext Management:\n memorio.isolate(name) - Create isolated context\n memorio.listContexts() - List all contexts\n memorio.deleteContext(id) - Delete a context\n\nPlatform Detection:\n memorio.isBrowser() - Browser environment\n memorio.isNode() - Node.js environment\n memorio.isDeno() - Deno environment\n memorio.isEdge() - Edge/Worker environment\n memorio.getCapabilities() - Full capabilities object\n\nDevTools:\n memorio.devtools.inspect() - Inspect all modules\n memorio.devtools.stats() - Show statistics\n memorio.devtools.watch() - Watch a path\n memorio.devtools.exportData() - Export as JSON\n memorio.devtools.importData() - Import from JSON\n memorio.devtools.clear() - Clear specific module\n memorio.devtools.clearAll() - Clear all modules\n\nShortcuts:\n state, store, session, cache, idb - direct access to modules\n`);
|
|
1311
1342
|
};
|
|
1312
1343
|
|
|
1313
|
-
var
|
|
1344
|
+
var Je = globalThis.memorio, We = globalThis.events, Re = e => O(e), Ve = globalThis.memorio?.help, Ue = e => r.currentContext = e, qe = () => r.currentContext, Fe = Je;
|
|
1314
1345
|
|
|
1315
|
-
export {
|
|
1346
|
+
export { je as cache, O as createContext, Fe as default, j as deleteContext, Ae as devtools, oe as dispatch, We as events, T as getCapabilities, qe as getContext, Ve as help, $ as idb, r as internal, m as isBrowser, h as isDeno, p as isEdge, g as isNode, Re as isolate, P as listContexts, Me as logger, Je as memorio, s as message, Se as observer, o as propertyName, Oe as session, Ue as setContext, le as state, ge as store, $e as useObserver };
|