memorio 3.0.0 → 3.0.1
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/CODE_OF_CONDUCT.md +1 -1
- package/README.md +202 -332
- package/SECURITY.md +48 -3
- package/docs/README.md +202 -332
- package/examples/basic.ts +22 -22
- package/examples/browser-vanilla.html +2 -2
- package/examples/cache.ts +9 -9
- package/examples/idb.ts +8 -8
- package/examples/node-server.ts +39 -39
- package/examples/observer.ts +5 -5
- package/examples/platform.ts +37 -37
- package/examples/react-app.tsx +3 -3
- package/examples/session-advanced.ts +8 -8
- package/examples/state-advanced.ts +10 -10
- package/examples/store-advanced.ts +9 -9
- package/examples/useObserver.tsx +1 -1
- package/index.cjs +27 -26
- package/index.js +25 -26
- package/package.json +3 -3
- package/types/cache.d.ts +1 -1
- package/types/idb.d.ts +1 -1
- package/types/observer.d.ts +1 -1
- package/types/store.d.ts +10 -10
- package/types/useObserver.d.ts +1 -1
|
@@ -13,13 +13,13 @@ import 'memorio'
|
|
|
13
13
|
// CHECK PERSISTENCE
|
|
14
14
|
// ============================================
|
|
15
15
|
|
|
16
|
-
console.
|
|
17
|
-
console.
|
|
16
|
+
console.debug('=== Session Persistence Check ===')
|
|
17
|
+
console.debug('Is persistent (survives tab close):', session.isPersistent)
|
|
18
18
|
// In browser: true (sessionStorage)
|
|
19
19
|
// In Node.js/Deno: false (memory fallback)
|
|
20
20
|
|
|
21
21
|
if (!session.isPersistent) {
|
|
22
|
-
console.
|
|
22
|
+
console.debug('⚠️ Warning: Using in-memory storage. Data will be lost on process restart!')
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// ============================================
|
|
@@ -33,7 +33,7 @@ session.set('userId', 12345)
|
|
|
33
33
|
// Check if user is logged in
|
|
34
34
|
const token = session.get('authToken')
|
|
35
35
|
if (token) {
|
|
36
|
-
console.
|
|
36
|
+
console.debug('User is logged in, token:', token.substring(0, 20) + '...')
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// ============================================
|
|
@@ -50,7 +50,7 @@ session.set('formDraft', {
|
|
|
50
50
|
// Restore on page refresh
|
|
51
51
|
const draft = session.get('formDraft')
|
|
52
52
|
if (draft) {
|
|
53
|
-
console.
|
|
53
|
+
console.debug('Restored draft:', draft)
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// ============================================
|
|
@@ -66,14 +66,14 @@ session.set('cart', [
|
|
|
66
66
|
// Calculate total
|
|
67
67
|
const cart = session.get('cart') || []
|
|
68
68
|
const total = cart.reduce((sum, item) => sum + (item.price * item.qty), 0)
|
|
69
|
-
console.
|
|
69
|
+
console.debug('Cart total:', total)
|
|
70
70
|
|
|
71
71
|
// ============================================
|
|
72
72
|
// SESSION SIZE
|
|
73
73
|
// ============================================
|
|
74
74
|
|
|
75
75
|
// Get session storage size
|
|
76
|
-
console.
|
|
76
|
+
console.debug('Session size:', session.size(), 'bytes')
|
|
77
77
|
|
|
78
78
|
// ============================================
|
|
79
79
|
// CLEANUP
|
|
@@ -88,4 +88,4 @@ session.remove('formDraft')
|
|
|
88
88
|
// Or use alias
|
|
89
89
|
// session.clearAll()
|
|
90
90
|
|
|
91
|
-
console.
|
|
91
|
+
console.debug('Session advanced example complete!')
|
|
@@ -25,9 +25,9 @@ state.user = {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// Access nested values
|
|
28
|
-
console.
|
|
29
|
-
console.
|
|
30
|
-
console.
|
|
28
|
+
console.debug('User name:', state.user.name)
|
|
29
|
+
console.debug('Email:', state.user.profile.email)
|
|
30
|
+
console.debug('Theme:', state.user.profile.settings.theme)
|
|
31
31
|
|
|
32
32
|
// ============================================
|
|
33
33
|
// ARRAYS
|
|
@@ -36,14 +36,14 @@ console.log('Theme:', state.user.profile.settings.theme)
|
|
|
36
36
|
// State arrays work like regular arrays
|
|
37
37
|
state.items = [1, 2, 3]
|
|
38
38
|
state.items.push(4)
|
|
39
|
-
console.
|
|
39
|
+
console.debug('Items:', state.items) // [1, 2, 3, 4]
|
|
40
40
|
|
|
41
41
|
state.users = [
|
|
42
42
|
{ name: 'Mario', id: 1 },
|
|
43
43
|
{ name: 'Luigi', id: 2 }
|
|
44
44
|
]
|
|
45
45
|
state.users.push({ name: 'Peach', id: 3 })
|
|
46
|
-
console.
|
|
46
|
+
console.debug('Users:', state.users)
|
|
47
47
|
|
|
48
48
|
// ============================================
|
|
49
49
|
// LOCKING STATE
|
|
@@ -56,25 +56,25 @@ state.config.lock()
|
|
|
56
56
|
// This will fail:
|
|
57
57
|
// state.config.maxUsers = 200 // Error: state 'config' is locked
|
|
58
58
|
|
|
59
|
-
console.
|
|
59
|
+
console.debug('Config locked:', state.config)
|
|
60
60
|
|
|
61
61
|
// ============================================
|
|
62
62
|
// PATH TRACKING
|
|
63
63
|
// ============================================
|
|
64
64
|
|
|
65
65
|
// Get path information
|
|
66
|
-
console.
|
|
66
|
+
console.debug('Path:', state.user.__path) // "state.user"
|
|
67
67
|
|
|
68
68
|
// Use path tracker for debugging
|
|
69
69
|
const path = state.user.profile
|
|
70
|
-
console.
|
|
70
|
+
console.debug('Profile path:', path.email.toString()) // "state.user.profile.email"
|
|
71
71
|
|
|
72
72
|
// ============================================
|
|
73
73
|
// LIST ALL STATES
|
|
74
74
|
// ============================================
|
|
75
75
|
|
|
76
76
|
// Get all current state keys
|
|
77
|
-
console.
|
|
77
|
+
console.debug('All states:', state.list)
|
|
78
78
|
|
|
79
79
|
// ============================================
|
|
80
80
|
// REMOVE STATE
|
|
@@ -86,4 +86,4 @@ state.remove('items')
|
|
|
86
86
|
// Remove all states
|
|
87
87
|
// state.removeAll()
|
|
88
88
|
|
|
89
|
-
console.
|
|
89
|
+
console.debug('State advanced example complete!')
|
|
@@ -12,13 +12,13 @@ import 'memorio'
|
|
|
12
12
|
// CHECK PERSISTENCE
|
|
13
13
|
// ============================================
|
|
14
14
|
|
|
15
|
-
console.
|
|
16
|
-
console.
|
|
15
|
+
console.debug('=== Store Persistence Check ===')
|
|
16
|
+
console.debug('Is persistent (survives restart):', store.isPersistent)
|
|
17
17
|
// In browser: true (localStorage)
|
|
18
18
|
// In Node.js/Deno: false (memory fallback)
|
|
19
19
|
|
|
20
20
|
if (!store.isPersistent) {
|
|
21
|
-
console.
|
|
21
|
+
console.debug('⚠️ Warning: Using in-memory storage. Data will be lost on restart!')
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
// ============================================
|
|
@@ -39,9 +39,9 @@ store.set('preferences', {
|
|
|
39
39
|
|
|
40
40
|
const savedPrefs = store.get('preferences')
|
|
41
41
|
if (savedPrefs) {
|
|
42
|
-
console.
|
|
42
|
+
console.debug('Loaded preferences:', savedPrefs)
|
|
43
43
|
} else {
|
|
44
|
-
console.
|
|
44
|
+
console.debug('No preferences found, using defaults')
|
|
45
45
|
store.set('preferences', { theme: 'light', language: 'en' })
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -51,7 +51,7 @@ if (savedPrefs) {
|
|
|
51
51
|
|
|
52
52
|
// Get storage size
|
|
53
53
|
const currentSize = store.size()
|
|
54
|
-
console.
|
|
54
|
+
console.debug('Current storage size:', currentSize, 'bytes')
|
|
55
55
|
|
|
56
56
|
// ============================================
|
|
57
57
|
// ALIAS METHODS
|
|
@@ -75,7 +75,7 @@ try {
|
|
|
75
75
|
items: Array(1000).fill(null).map((_, i) => ({ id: i, data: 'x'.repeat(100) }))
|
|
76
76
|
}
|
|
77
77
|
store.set('largeData', largeData)
|
|
78
|
-
console.
|
|
78
|
+
console.debug('Large data stored successfully')
|
|
79
79
|
} catch (error) {
|
|
80
80
|
console.error('Storage full:', error)
|
|
81
81
|
}
|
|
@@ -111,7 +111,7 @@ store.set('appState', appState)
|
|
|
111
111
|
// Load on next visit
|
|
112
112
|
const restored = store.get('appState')
|
|
113
113
|
if (restored) {
|
|
114
|
-
console.
|
|
114
|
+
console.debug('Restored app state:', restored.lastPage)
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
console.
|
|
117
|
+
console.debug('Store advanced example complete!')
|
package/examples/useObserver.tsx
CHANGED
package/index.cjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
1
3
|
var e = Object.getOwnPropertyNames, t = (t, o) => function() {
|
|
2
4
|
return t && (o = (0, t[e(t)[0]])(t = 0)), o;
|
|
3
5
|
}, o = {}, r = t({
|
|
@@ -24,25 +26,25 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
|
|
|
24
26
|
}
|
|
25
27
|
}, idb.db.list();
|
|
26
28
|
}
|
|
27
|
-
}), i = {},
|
|
29
|
+
}), i = {}, l = t({
|
|
28
30
|
"functions/idb/tools/db.exist.ts"() {
|
|
29
31
|
idb.db.exist = e => idbases?.some(t => t.name === e);
|
|
30
32
|
}
|
|
31
|
-
}),
|
|
33
|
+
}), a = {}, c = t({
|
|
32
34
|
"functions/idb/tools/db.quota.ts"() {
|
|
33
35
|
idb.db.quota = () => navigator.storage.estimate();
|
|
34
36
|
}
|
|
35
37
|
}), b = {}, u = t({
|
|
36
38
|
"functions/idb/tools/db.delete.ts"() {
|
|
37
39
|
idb.db.delete = e => new Promise((t, o) => {
|
|
38
|
-
|
|
40
|
+
(() => {
|
|
39
41
|
const r = indexedDB.deleteDatabase(e);
|
|
40
42
|
r.onsuccess = () => {
|
|
41
43
|
idb.db.list(), t();
|
|
42
44
|
}, r.onerror = () => {
|
|
43
45
|
o(r.error);
|
|
44
46
|
}, r.onblocked = () => {};
|
|
45
|
-
})()
|
|
47
|
+
})();
|
|
46
48
|
});
|
|
47
49
|
}
|
|
48
50
|
}), d = {}, f = t({
|
|
@@ -128,7 +130,7 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
|
|
|
128
130
|
};
|
|
129
131
|
});
|
|
130
132
|
}
|
|
131
|
-
}),
|
|
133
|
+
}), P = {}, O = t({
|
|
132
134
|
"functions/idb/crud/data.delete.ts"() {
|
|
133
135
|
idb.data.delete = (e, t, o) => new Promise((r, s) => {
|
|
134
136
|
const n = indexedDB.open(e);
|
|
@@ -163,11 +165,11 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
|
|
|
163
165
|
n.onsuccess = () => {
|
|
164
166
|
const i = n.result;
|
|
165
167
|
if (!i.objectStoreNames.contains(t)) return i.close(), s(new Error(`Table ${t} does not exist in ${e}`));
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
i.close(), r(
|
|
169
|
-
},
|
|
170
|
-
i.close(), s(
|
|
168
|
+
const l = i.transaction(t, "readwrite").objectStore(t).put(o);
|
|
169
|
+
l.onsuccess = () => {
|
|
170
|
+
i.close(), r(l.result);
|
|
171
|
+
}, l.onerror = e => {
|
|
172
|
+
i.close(), s(l.error);
|
|
171
173
|
};
|
|
172
174
|
}, n.onerror = () => {
|
|
173
175
|
s(n.error);
|
|
@@ -181,11 +183,11 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
|
|
|
181
183
|
n.onsuccess = n => {
|
|
182
184
|
const i = n.target.result;
|
|
183
185
|
if (!i.objectStoreNames.contains(t)) return i.close(), s(new Error(`Table ${t} not found in ${e}`));
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
i.close(), r(
|
|
187
|
-
},
|
|
188
|
-
i.close(), s(
|
|
186
|
+
const l = i.transaction(t, "readonly").objectStore(t).get(o);
|
|
187
|
+
l.onsuccess = () => {
|
|
188
|
+
i.close(), r(l.result);
|
|
189
|
+
}, l.onerror = () => {
|
|
190
|
+
i.close(), s(l.error);
|
|
189
191
|
};
|
|
190
192
|
}, n.onerror = () => {
|
|
191
193
|
s(n.error);
|
|
@@ -310,7 +312,7 @@ Object.defineProperty(globalThis, "memorio", {
|
|
|
310
312
|
}), Object.defineProperty(memorio, "version", {
|
|
311
313
|
writable: !1,
|
|
312
314
|
enumerable: !1,
|
|
313
|
-
value: "3.0.
|
|
315
|
+
value: "3.0.1"
|
|
314
316
|
});
|
|
315
317
|
|
|
316
318
|
var B = [ "list", "state", "store", "idb", "observer", "useObserver", "remove", "removeAll", "_platform", "_capabilities", "_sessionId" ];
|
|
@@ -395,8 +397,7 @@ var C = (e, t, o = []) => new Proxy(e, {
|
|
|
395
397
|
if ("remove" === r) return t => (delete e[t], !0);
|
|
396
398
|
if ("removeAll" === r) return () => {
|
|
397
399
|
try {
|
|
398
|
-
for (const t in e) "function" == typeof e[t] || [ "list", "remove", "removeAll" ].includes(t) ||
|
|
399
|
-
delete e[t]);
|
|
400
|
+
for (const t in e) "function" == typeof e[t] || [ "list", "remove", "removeAll", "lock", "unlock" ].includes(t) || delete e[t];
|
|
400
401
|
} catch (e) {}
|
|
401
402
|
};
|
|
402
403
|
if (Object.isFrozen(e[r])) return e[r];
|
|
@@ -488,8 +489,7 @@ var C = (e, t, o = []) => new Proxy(e, {
|
|
|
488
489
|
getOwnPropertyDescriptor: (e, t) => Reflect.getOwnPropertyDescriptor(e, t)
|
|
489
490
|
});
|
|
490
491
|
|
|
491
|
-
globalThis?.state
|
|
492
|
-
globalThis.state.lock = () => {
|
|
492
|
+
globalThis?.state || (globalThis.state = C({}, () => {})), globalThis.state.lock = () => {
|
|
493
493
|
globalThis.memorio._locked = !0;
|
|
494
494
|
}, globalThis.state.unlock = () => {
|
|
495
495
|
globalThis.memorio._locked = !1;
|
|
@@ -539,8 +539,7 @@ globalThis.observer = (e, t = null, o = !0) => {
|
|
|
539
539
|
}), !0;
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
|
-
}),
|
|
543
|
-
Object.defineProperty(globalThis, "useObserver", {
|
|
542
|
+
}), globalThis.useObserver || (globalThis.useObserver = null), Object.defineProperty(globalThis, "useObserver", {
|
|
544
543
|
value: null,
|
|
545
544
|
writable: !0,
|
|
546
545
|
enumerable: !1,
|
|
@@ -614,7 +613,9 @@ Object.defineProperty(globalThis, "store", {
|
|
|
614
613
|
if (!e) return;
|
|
615
614
|
const o = L(e);
|
|
616
615
|
try {
|
|
617
|
-
|
|
616
|
+
if (M) {
|
|
617
|
+
if (null == t) R.setItem(o, JSON.stringify(null)); else if ("object" == typeof t || "number" == typeof t || "boolean" == typeof t || "string" == typeof t) R.setItem(o, JSON.stringify(t)); else if ("function" == typeof t) return;
|
|
618
|
+
} else if (null == t) W.set(o, JSON.stringify(null)); else if ("object" == typeof t || "number" == typeof t || "boolean" == typeof t || "string" == typeof t) W.set(o, JSON.stringify(t)); else if ("function" == typeof t) return;
|
|
618
619
|
} catch (e) {}
|
|
619
620
|
return null;
|
|
620
621
|
}
|
|
@@ -787,11 +788,11 @@ Object.defineProperty(globalThis, "cache", {
|
|
|
787
788
|
configurable: !0,
|
|
788
789
|
enumerable: !1
|
|
789
790
|
}), await Promise.all([ Promise.resolve().then(() => (r(), o)), Promise.resolve().then(() => (n(),
|
|
790
|
-
s)), Promise.resolve().then(() => (
|
|
791
|
-
|
|
791
|
+
s)), Promise.resolve().then(() => (l(), i)), Promise.resolve().then(() => (c(),
|
|
792
|
+
a)), Promise.resolve().then(() => (u(), b)), Promise.resolve().then(() => (f(),
|
|
792
793
|
d)), Promise.resolve().then(() => (h(), m)), Promise.resolve().then(() => (p(),
|
|
793
794
|
g)), Promise.resolve().then(() => (y(), v)), Promise.resolve().then(() => (j(),
|
|
794
|
-
T)), Promise.resolve().then(() => (
|
|
795
|
+
T)), Promise.resolve().then(() => (O(), P)), Promise.resolve().then(() => (S(),
|
|
795
796
|
w)), Promise.resolve().then(() => (k(), _)) ]), Object.preventExtensions(idb), Object.seal(idb),
|
|
796
797
|
Object.freeze(idb);
|
|
797
798
|
})() : (Object.defineProperty(globalThis, "idb", {
|
package/index.js
CHANGED
|
@@ -24,25 +24,25 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
|
|
|
24
24
|
}
|
|
25
25
|
}, idb.db.list();
|
|
26
26
|
}
|
|
27
|
-
}), i = {},
|
|
27
|
+
}), i = {}, l = t({
|
|
28
28
|
"functions/idb/tools/db.exist.ts"() {
|
|
29
29
|
idb.db.exist = e => idbases?.some(t => t.name === e);
|
|
30
30
|
}
|
|
31
|
-
}),
|
|
31
|
+
}), a = {}, c = t({
|
|
32
32
|
"functions/idb/tools/db.quota.ts"() {
|
|
33
33
|
idb.db.quota = () => navigator.storage.estimate();
|
|
34
34
|
}
|
|
35
35
|
}), b = {}, u = t({
|
|
36
36
|
"functions/idb/tools/db.delete.ts"() {
|
|
37
37
|
idb.db.delete = e => new Promise((t, o) => {
|
|
38
|
-
|
|
38
|
+
(() => {
|
|
39
39
|
const r = indexedDB.deleteDatabase(e);
|
|
40
40
|
r.onsuccess = () => {
|
|
41
41
|
idb.db.list(), t();
|
|
42
42
|
}, r.onerror = () => {
|
|
43
43
|
o(r.error);
|
|
44
44
|
}, r.onblocked = () => {};
|
|
45
|
-
})()
|
|
45
|
+
})();
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
}), d = {}, f = t({
|
|
@@ -128,7 +128,7 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
|
|
|
128
128
|
};
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
}),
|
|
131
|
+
}), P = {}, O = t({
|
|
132
132
|
"functions/idb/crud/data.delete.ts"() {
|
|
133
133
|
idb.data.delete = (e, t, o) => new Promise((r, s) => {
|
|
134
134
|
const n = indexedDB.open(e);
|
|
@@ -163,11 +163,11 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
|
|
|
163
163
|
n.onsuccess = () => {
|
|
164
164
|
const i = n.result;
|
|
165
165
|
if (!i.objectStoreNames.contains(t)) return i.close(), s(new Error(`Table ${t} does not exist in ${e}`));
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
i.close(), r(
|
|
169
|
-
},
|
|
170
|
-
i.close(), s(
|
|
166
|
+
const l = i.transaction(t, "readwrite").objectStore(t).put(o);
|
|
167
|
+
l.onsuccess = () => {
|
|
168
|
+
i.close(), r(l.result);
|
|
169
|
+
}, l.onerror = e => {
|
|
170
|
+
i.close(), s(l.error);
|
|
171
171
|
};
|
|
172
172
|
}, n.onerror = () => {
|
|
173
173
|
s(n.error);
|
|
@@ -181,11 +181,11 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
|
|
|
181
181
|
n.onsuccess = n => {
|
|
182
182
|
const i = n.target.result;
|
|
183
183
|
if (!i.objectStoreNames.contains(t)) return i.close(), s(new Error(`Table ${t} not found in ${e}`));
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
i.close(), r(
|
|
187
|
-
},
|
|
188
|
-
i.close(), s(
|
|
184
|
+
const l = i.transaction(t, "readonly").objectStore(t).get(o);
|
|
185
|
+
l.onsuccess = () => {
|
|
186
|
+
i.close(), r(l.result);
|
|
187
|
+
}, l.onerror = () => {
|
|
188
|
+
i.close(), s(l.error);
|
|
189
189
|
};
|
|
190
190
|
}, n.onerror = () => {
|
|
191
191
|
s(n.error);
|
|
@@ -310,7 +310,7 @@ Object.defineProperty(globalThis, "memorio", {
|
|
|
310
310
|
}), Object.defineProperty(memorio, "version", {
|
|
311
311
|
writable: !1,
|
|
312
312
|
enumerable: !1,
|
|
313
|
-
value: "3.0.
|
|
313
|
+
value: "3.0.1"
|
|
314
314
|
});
|
|
315
315
|
|
|
316
316
|
var B = [ "list", "state", "store", "idb", "observer", "useObserver", "remove", "removeAll", "_platform", "_capabilities", "_sessionId" ];
|
|
@@ -395,8 +395,7 @@ var C = (e, t, o = []) => new Proxy(e, {
|
|
|
395
395
|
if ("remove" === r) return t => (delete e[t], !0);
|
|
396
396
|
if ("removeAll" === r) return () => {
|
|
397
397
|
try {
|
|
398
|
-
for (const t in e) "function" == typeof e[t] || [ "list", "remove", "removeAll" ].includes(t) ||
|
|
399
|
-
delete e[t]);
|
|
398
|
+
for (const t in e) "function" == typeof e[t] || [ "list", "remove", "removeAll", "lock", "unlock" ].includes(t) || delete e[t];
|
|
400
399
|
} catch (e) {}
|
|
401
400
|
};
|
|
402
401
|
if (Object.isFrozen(e[r])) return e[r];
|
|
@@ -488,8 +487,7 @@ var C = (e, t, o = []) => new Proxy(e, {
|
|
|
488
487
|
getOwnPropertyDescriptor: (e, t) => Reflect.getOwnPropertyDescriptor(e, t)
|
|
489
488
|
});
|
|
490
489
|
|
|
491
|
-
globalThis?.state
|
|
492
|
-
globalThis.state.lock = () => {
|
|
490
|
+
globalThis?.state || (globalThis.state = C({}, () => {})), globalThis.state.lock = () => {
|
|
493
491
|
globalThis.memorio._locked = !0;
|
|
494
492
|
}, globalThis.state.unlock = () => {
|
|
495
493
|
globalThis.memorio._locked = !1;
|
|
@@ -539,8 +537,7 @@ globalThis.observer = (e, t = null, o = !0) => {
|
|
|
539
537
|
}), !0;
|
|
540
538
|
}
|
|
541
539
|
}
|
|
542
|
-
}),
|
|
543
|
-
Object.defineProperty(globalThis, "useObserver", {
|
|
540
|
+
}), globalThis.useObserver || (globalThis.useObserver = null), Object.defineProperty(globalThis, "useObserver", {
|
|
544
541
|
value: null,
|
|
545
542
|
writable: !0,
|
|
546
543
|
enumerable: !1,
|
|
@@ -614,7 +611,9 @@ Object.defineProperty(globalThis, "store", {
|
|
|
614
611
|
if (!e) return;
|
|
615
612
|
const o = L(e);
|
|
616
613
|
try {
|
|
617
|
-
|
|
614
|
+
if (M) {
|
|
615
|
+
if (null == t) R.setItem(o, JSON.stringify(null)); else if ("object" == typeof t || "number" == typeof t || "boolean" == typeof t || "string" == typeof t) R.setItem(o, JSON.stringify(t)); else if ("function" == typeof t) return;
|
|
616
|
+
} else if (null == t) W.set(o, JSON.stringify(null)); else if ("object" == typeof t || "number" == typeof t || "boolean" == typeof t || "string" == typeof t) W.set(o, JSON.stringify(t)); else if ("function" == typeof t) return;
|
|
618
617
|
} catch (e) {}
|
|
619
618
|
return null;
|
|
620
619
|
}
|
|
@@ -787,11 +786,11 @@ Object.defineProperty(globalThis, "cache", {
|
|
|
787
786
|
configurable: !0,
|
|
788
787
|
enumerable: !1
|
|
789
788
|
}), await Promise.all([ Promise.resolve().then(() => (r(), o)), Promise.resolve().then(() => (n(),
|
|
790
|
-
s)), Promise.resolve().then(() => (
|
|
791
|
-
|
|
789
|
+
s)), Promise.resolve().then(() => (l(), i)), Promise.resolve().then(() => (c(),
|
|
790
|
+
a)), Promise.resolve().then(() => (u(), b)), Promise.resolve().then(() => (f(),
|
|
792
791
|
d)), Promise.resolve().then(() => (h(), m)), Promise.resolve().then(() => (p(),
|
|
793
792
|
g)), Promise.resolve().then(() => (y(), v)), Promise.resolve().then(() => (j(),
|
|
794
|
-
T)), Promise.resolve().then(() => (
|
|
793
|
+
T)), Promise.resolve().then(() => (O(), P)), Promise.resolve().then(() => (S(),
|
|
795
794
|
w)), Promise.resolve().then(() => (k(), _)) ]), Object.preventExtensions(idb), Object.seal(idb),
|
|
796
795
|
Object.freeze(idb);
|
|
797
796
|
})() : (Object.defineProperty(globalThis, "idb", {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "memorio",
|
|
3
3
|
"code": "memorio",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.1",
|
|
5
5
|
"description": "Memorio, State + Observer, Store and iDB for an easy life - Cross-platform compatible",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
7
|
"browser": "./index.cjs",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"types": "./index.d.ts",
|
|
10
10
|
"typing": "./types/*",
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"copyright": "Dario Passariello",
|
|
13
|
-
"author": "Dario Passariello",
|
|
12
|
+
"copyright": "Dario Passariello - BigLogic Inc",
|
|
13
|
+
"author": "Dario Passariello - BigLogic Inc <info@biglogic.ca> (https://biglogic.ca)",
|
|
14
14
|
"contributors": [
|
|
15
15
|
{
|
|
16
16
|
"name": "Dario Passariello",
|
package/types/cache.d.ts
CHANGED
package/types/idb.d.ts
CHANGED
package/types/observer.d.ts
CHANGED
package/types/store.d.ts
CHANGED
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
interface _store {
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
* Create a new store
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* store.set("test","example") // Array, Object, Number, Boolean, String or null
|
|
11
|
+
*
|
|
12
|
+
* @since memorio 0.0.1
|
|
13
|
+
* @param name The String as name to define the store.
|
|
14
|
+
* @param value The information you want to store. Functions are blocked for security.
|
|
15
|
+
* @return void
|
|
16
|
+
*/
|
|
17
17
|
set: (name: string, value: any) => void
|
|
18
18
|
|
|
19
19
|
/**
|