memorio 4.1.6 ā 4.2.0
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/README.md +16 -57
- package/docs/README.md +16 -57
- package/docs/markdown/PLATFORM.md +10 -9
- package/docs/markdown/SECURITY.md +15 -10
- package/index.cjs +436 -385
- package/index.js +436 -385
- package/package.json +1 -1
- package/types/memorio.d.ts +1 -0
package/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var e = Object.getOwnPropertyNames,
|
|
2
|
-
return
|
|
3
|
-
},
|
|
1
|
+
var e = Object.getOwnPropertyNames, o = (o, t) => function() {
|
|
2
|
+
return o && (t = (0, o[e(o)[0]])(o = 0)), t;
|
|
3
|
+
}, t = {}, r = o({
|
|
4
4
|
"functions/idb/tools/db.create.ts"() {
|
|
5
|
-
idb.db.create = (e,
|
|
5
|
+
idb.db.create = (e, o = 1) => new Promise((t, r) => {
|
|
6
6
|
if (!idb.db.support()) return r(new Error("IndexedDB not supported"));
|
|
7
|
-
const s = globalThis.indexedDB.open(e,
|
|
7
|
+
const s = globalThis.indexedDB.open(e, o);
|
|
8
8
|
s.onerror = () => {
|
|
9
9
|
memorio.message(`IndexedDB error: ${s.error?.message}`), r(s.error);
|
|
10
10
|
}, s.onsuccess = () => {
|
|
11
|
-
memorio.message(`Database ${e} connected successfully`),
|
|
11
|
+
memorio.message(`Database ${e} connected successfully`), t(s.result);
|
|
12
12
|
}, s.onupgradeneeded = () => {
|
|
13
13
|
memorio.message(`Database ${e} upgrade/creation initiated`);
|
|
14
14
|
};
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
}), s = {},
|
|
17
|
+
}), s = {}, n = o({
|
|
18
18
|
"functions/idb/tools/db.list.ts"() {
|
|
19
19
|
idb.db.list = async () => {
|
|
20
20
|
if (!("indexedDB" in globalThis) || !indexedDB.databases) return [];
|
|
@@ -26,178 +26,178 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
}),
|
|
29
|
+
}), i = {}, a = o({
|
|
30
30
|
"functions/idb/tools/db.exist.ts"() {
|
|
31
|
-
idb.db.exist = e => idbases?.some(
|
|
31
|
+
idb.db.exist = e => idbases?.some(o => o.name === e);
|
|
32
32
|
}
|
|
33
|
-
}), l = {}, c =
|
|
33
|
+
}), l = {}, c = o({
|
|
34
34
|
"functions/idb/tools/db.quota.ts"() {
|
|
35
35
|
idb.db.quota = () => navigator.storage.estimate();
|
|
36
36
|
}
|
|
37
|
-
}), m = {},
|
|
37
|
+
}), m = {}, u = o({
|
|
38
38
|
"functions/idb/tools/db.delete.ts"() {
|
|
39
|
-
idb.db.delete = e => new Promise((
|
|
39
|
+
idb.db.delete = e => new Promise((o, t) => {
|
|
40
40
|
memorio.message(`Removing database ${e}...`);
|
|
41
41
|
(() => {
|
|
42
42
|
const r = indexedDB.deleteDatabase(e);
|
|
43
43
|
r.onsuccess = () => {
|
|
44
|
-
memorio.message(`${e} database removed successfully`), idb.db.list(),
|
|
44
|
+
memorio.message(`${e} database removed successfully`), idb.db.list(), o();
|
|
45
45
|
}, r.onerror = () => {
|
|
46
|
-
console.error(`Error removing ${e}:`, r.error),
|
|
46
|
+
console.error(`Error removing ${e}:`, r.error), t(r.error);
|
|
47
47
|
}, r.onblocked = () => {
|
|
48
48
|
console.warn(`Deletion of ${e} is blocked. Please close other tabs.`);
|
|
49
49
|
};
|
|
50
50
|
})();
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
}),
|
|
53
|
+
}), b = {}, d = o({
|
|
54
54
|
"functions/idb/tools/db.size.ts"() {
|
|
55
55
|
idb.db.size = async () => {
|
|
56
56
|
if (idbases && 0 !== idbases.length) for (let e = 0; e < idbases.length; e++) {
|
|
57
|
-
const
|
|
57
|
+
const o = idbases[e];
|
|
58
58
|
try {
|
|
59
|
-
const e = await idb.db.create(
|
|
59
|
+
const e = await idb.db.create(o.name, o.version), t = Array.from(e.objectStoreNames);
|
|
60
60
|
let r = 0;
|
|
61
|
-
for (const
|
|
62
|
-
r += await idb.table.size(e,
|
|
61
|
+
for (const o of t) {
|
|
62
|
+
r += await idb.table.size(e, o);
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
o.size = r, e.close();
|
|
65
65
|
} catch (e) {
|
|
66
|
-
memorio.message(`Could not calculate size for ${
|
|
66
|
+
memorio.message(`Could not calculate size for ${o.name}:${e}`);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
}), g = {}, f =
|
|
71
|
+
}), g = {}, f = o({
|
|
72
72
|
"functions/idb/tools/db.version.ts"() {
|
|
73
73
|
idb.db.version = e => {
|
|
74
|
-
let
|
|
75
|
-
for (const
|
|
76
|
-
|
|
74
|
+
let o = 0;
|
|
75
|
+
for (const t of idbases) {
|
|
76
|
+
t.name === e && (o = t.version);
|
|
77
77
|
break;
|
|
78
78
|
}
|
|
79
|
-
return
|
|
79
|
+
return o;
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
}), h = {}, p =
|
|
82
|
+
}), h = {}, p = o({
|
|
83
83
|
"functions/idb/tools/db.support.ts"() {
|
|
84
84
|
idb.db.support = () => {
|
|
85
85
|
const e = "indexedDB" in globalThis;
|
|
86
86
|
return e || memorio.message("Your environment doesn't support IndexedDB"), e;
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
}), v = {}, y =
|
|
89
|
+
}), v = {}, y = o({
|
|
90
90
|
"functions/idb/tools/table.create.ts"() {
|
|
91
|
-
idb.table.create = (e,
|
|
91
|
+
idb.table.create = (e, o) => new Promise(async (t, r) => {
|
|
92
92
|
try {
|
|
93
|
-
const s = (Number(idb.db.version(e)) || 0) + 1,
|
|
94
|
-
|
|
95
|
-
const r =
|
|
96
|
-
if (!r.objectStoreNames.contains(
|
|
97
|
-
const
|
|
93
|
+
const s = (Number(idb.db.version(e)) || 0) + 1, n = indexedDB.open(e, s);
|
|
94
|
+
n.onupgradeneeded = t => {
|
|
95
|
+
const r = t.target.result;
|
|
96
|
+
if (!r.objectStoreNames.contains(o)) {
|
|
97
|
+
const t = r.createObjectStore(o, {
|
|
98
98
|
keyPath: "id",
|
|
99
99
|
autoIncrement: !0
|
|
100
100
|
});
|
|
101
|
-
|
|
101
|
+
t.createIndex("id", "id", {
|
|
102
102
|
unique: !0
|
|
103
|
-
}),
|
|
103
|
+
}), t.createIndex("data", "data", {
|
|
104
104
|
unique: !1
|
|
105
|
-
}), memorio.message(`Table ${
|
|
105
|
+
}), memorio.message(`Table ${o} created in ${e}`);
|
|
106
106
|
}
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
},
|
|
110
|
-
console.error(`Error creating table ${
|
|
107
|
+
}, n.onsuccess = () => {
|
|
108
|
+
n.result.close(), idb.db.list(), t();
|
|
109
|
+
}, n.onerror = () => {
|
|
110
|
+
console.error(`Error creating table ${o}:`, n.error), r(n.error);
|
|
111
111
|
};
|
|
112
112
|
} catch (e) {
|
|
113
113
|
console.error("Critical error in table.create:", e), r(e);
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
|
-
}), T = {}, O =
|
|
117
|
+
}), T = {}, O = o({
|
|
118
118
|
"functions/idb/tools/table.size.ts"() {
|
|
119
|
-
idb.table.size = (e,
|
|
119
|
+
idb.table.size = (e, o) => new Promise((t, r) => {
|
|
120
120
|
if (!e) return r(new Error("Database instance is required"));
|
|
121
|
-
if (!e.objectStoreNames.contains(
|
|
122
|
-
let s = 0,
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
121
|
+
if (!e.objectStoreNames.contains(o)) return t(0);
|
|
122
|
+
let s = 0, n = 0;
|
|
123
|
+
const i = e.transaction([ o ], "readonly").objectStore(o).openCursor();
|
|
124
|
+
i.onsuccess = async e => {
|
|
125
|
+
const o = e.target.result;
|
|
126
|
+
if (o) {
|
|
127
127
|
try {
|
|
128
|
-
const e =
|
|
128
|
+
const e = o.value;
|
|
129
129
|
s += JSON.stringify(e).length;
|
|
130
130
|
} catch (e) {
|
|
131
131
|
memorio.message(`Error stringifying IDB value tracking size:${e}`);
|
|
132
132
|
}
|
|
133
|
-
|
|
134
|
-
} else
|
|
135
|
-
},
|
|
136
|
-
r(
|
|
133
|
+
n++, n % 200 == 0 && await new Promise(e => setTimeout(e, 0)), o.continue();
|
|
134
|
+
} else t(s);
|
|
135
|
+
}, i.onerror = () => {
|
|
136
|
+
r(i.error);
|
|
137
137
|
};
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
|
-
}),
|
|
140
|
+
}), w = {}, S = o({
|
|
141
141
|
"functions/idb/crud/data.delete.ts"() {
|
|
142
|
-
idb.data.delete = (e,
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
const e =
|
|
146
|
-
if (!e.objectStoreNames.contains(
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
e.close(), memorio.message(`Record ${
|
|
150
|
-
},
|
|
151
|
-
e.close(), s(
|
|
142
|
+
idb.data.delete = (e, o, t) => new Promise((r, s) => {
|
|
143
|
+
const n = indexedDB.open(e);
|
|
144
|
+
n.onsuccess = () => {
|
|
145
|
+
const e = n.result;
|
|
146
|
+
if (!e.objectStoreNames.contains(o)) return e.close(), s(new Error(`Table ${o} not found`));
|
|
147
|
+
const i = e.transaction(o, "readwrite").objectStore(o).delete(t);
|
|
148
|
+
i.onsuccess = () => {
|
|
149
|
+
e.close(), memorio.message(`Record ${t} deleted from ${o}`), r();
|
|
150
|
+
}, i.onerror = () => {
|
|
151
|
+
e.close(), s(i.error);
|
|
152
152
|
};
|
|
153
|
-
},
|
|
154
|
-
}), idb.data.delete.all = (e,
|
|
153
|
+
}, n.onerror = () => s(n.error);
|
|
154
|
+
}), idb.data.delete.all = (e, o) => new Promise((t, r) => {
|
|
155
155
|
const s = indexedDB.open(e);
|
|
156
156
|
s.onsuccess = e => {
|
|
157
157
|
const s = e.target.result;
|
|
158
|
-
if (!s.objectStoreNames.contains(
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
s.close(), memorio.message(`All data cleared from ${
|
|
162
|
-
},
|
|
163
|
-
s.close(), r(
|
|
158
|
+
if (!s.objectStoreNames.contains(o)) return s.close(), r(new Error(`Table ${o} not found`));
|
|
159
|
+
const n = s.transaction(o, "readwrite").objectStore(o).clear();
|
|
160
|
+
n.onsuccess = () => {
|
|
161
|
+
s.close(), memorio.message(`All data cleared from ${o}`), t();
|
|
162
|
+
}, n.onerror = () => {
|
|
163
|
+
s.close(), r(n.error);
|
|
164
164
|
};
|
|
165
165
|
}, s.onerror = () => r(s.error);
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
|
-
}),
|
|
168
|
+
}), j = {}, P = o({
|
|
169
169
|
"functions/idb/crud/data.set.ts"() {
|
|
170
|
-
idb.data.set = (e,
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
const
|
|
174
|
-
if (!
|
|
175
|
-
const a =
|
|
170
|
+
idb.data.set = (e, o, t) => new Promise((r, s) => {
|
|
171
|
+
const n = indexedDB.open(e);
|
|
172
|
+
n.onsuccess = () => {
|
|
173
|
+
const i = n.result;
|
|
174
|
+
if (!i.objectStoreNames.contains(o)) return i.close(), s(new Error(`Table ${o} does not exist in ${e}`));
|
|
175
|
+
const a = i.transaction(o, "readwrite").objectStore(o).put(t);
|
|
176
176
|
a.onsuccess = () => {
|
|
177
|
-
|
|
177
|
+
i.close(), memorio.message(`Data saved in ${e}.${o}`), r(a.result);
|
|
178
178
|
}, a.onerror = e => {
|
|
179
|
-
|
|
179
|
+
i.close(), memorio.message(`Database insert error: ${a.error?.message}`), s(a.error);
|
|
180
180
|
};
|
|
181
|
-
},
|
|
182
|
-
s(
|
|
181
|
+
}, n.onerror = () => {
|
|
182
|
+
s(n.error);
|
|
183
183
|
};
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
|
-
}),
|
|
186
|
+
}), $ = {}, E = o({
|
|
187
187
|
"functions/idb/crud/data.get.ts"() {
|
|
188
|
-
idb.data.get = (e,
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
if (!
|
|
193
|
-
const a =
|
|
188
|
+
idb.data.get = (e, o, t) => new Promise((r, s) => {
|
|
189
|
+
const n = indexedDB.open(e);
|
|
190
|
+
n.onsuccess = n => {
|
|
191
|
+
const i = n.target.result;
|
|
192
|
+
if (!i.objectStoreNames.contains(o)) return i.close(), s(new Error(`Table ${o} not found in ${e}`));
|
|
193
|
+
const a = i.transaction(o, "readonly").objectStore(o).get(t);
|
|
194
194
|
a.onsuccess = () => {
|
|
195
|
-
|
|
195
|
+
i.close(), r(a.result);
|
|
196
196
|
}, a.onerror = () => {
|
|
197
|
-
|
|
197
|
+
i.close(), s(a.error);
|
|
198
198
|
};
|
|
199
|
-
},
|
|
200
|
-
s(
|
|
199
|
+
}, n.onerror = () => {
|
|
200
|
+
s(n.error);
|
|
201
201
|
};
|
|
202
202
|
});
|
|
203
203
|
}
|
|
@@ -207,8 +207,8 @@ function k() {
|
|
|
207
207
|
const e = globalThis;
|
|
208
208
|
if (void 0 !== e.crypto && e.crypto.randomUUID) return e.crypto.randomUUID();
|
|
209
209
|
if (void 0 !== e.crypto && e.crypto.getRandomValues) {
|
|
210
|
-
const
|
|
211
|
-
return e.crypto.getRandomValues(
|
|
210
|
+
const o = new Uint8Array(16);
|
|
211
|
+
return e.crypto.getRandomValues(o), Array.from(o, e => e.toString(16).padStart(2, "0")).join("");
|
|
212
212
|
}
|
|
213
213
|
return `session_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
|
|
214
214
|
}
|
|
@@ -218,7 +218,7 @@ function _() {
|
|
|
218
218
|
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";
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
function
|
|
221
|
+
function x() {
|
|
222
222
|
try {
|
|
223
223
|
if ("undefined" != typeof sessionStorage) {
|
|
224
224
|
const e = "__memorio_test__";
|
|
@@ -228,7 +228,7 @@ function D() {
|
|
|
228
228
|
return null;
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
function
|
|
231
|
+
function D() {
|
|
232
232
|
try {
|
|
233
233
|
if ("undefined" != typeof localStorage) {
|
|
234
234
|
const e = "__memorio_test__";
|
|
@@ -243,72 +243,80 @@ function I() {
|
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
function N() {
|
|
246
|
-
const e = _(),
|
|
246
|
+
const e = _(), o = void 0 !== globalThis.isSecureContext ? globalThis.isSecureContext : "browser" === e;
|
|
247
247
|
return {
|
|
248
248
|
platform: e,
|
|
249
|
-
hasSessionStorage: null !==
|
|
250
|
-
hasLocalStorage: null !==
|
|
249
|
+
hasSessionStorage: null !== x(),
|
|
250
|
+
hasLocalStorage: null !== D(),
|
|
251
251
|
hasIndexedDB: I(),
|
|
252
252
|
hasDispatchEvent: "function" == typeof globalThis.dispatchEvent,
|
|
253
253
|
hasNavigator: "undefined" != typeof navigator,
|
|
254
254
|
hasProcess: "undefined" != typeof process,
|
|
255
|
-
isSecureContext:
|
|
255
|
+
isSecureContext: o,
|
|
256
256
|
sessionId: k()
|
|
257
257
|
};
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
var A = new Map;
|
|
261
261
|
|
|
262
|
-
var
|
|
262
|
+
var C = new Map;
|
|
263
263
|
|
|
264
264
|
function J(e) {
|
|
265
|
-
const
|
|
265
|
+
const o = e || `context_${k()}`;
|
|
266
|
+
!function(e) {
|
|
267
|
+
const o = globalThis;
|
|
268
|
+
o.memorio || (o.memorio = {});
|
|
269
|
+
o.memorio._currentContext = e;
|
|
270
|
+
}(o);
|
|
271
|
+
const t = {
|
|
266
272
|
state: {},
|
|
267
273
|
store: new Map,
|
|
268
274
|
session: new Map,
|
|
269
275
|
cache: new Map
|
|
270
276
|
};
|
|
271
|
-
return
|
|
272
|
-
id:
|
|
273
|
-
state:
|
|
277
|
+
return C.set(o, t), {
|
|
278
|
+
id: o,
|
|
279
|
+
state: t.state,
|
|
274
280
|
store: {
|
|
275
281
|
get: e => {
|
|
276
|
-
const
|
|
277
|
-
return
|
|
282
|
+
const o = t.store.get(e);
|
|
283
|
+
return o ? JSON.parse(o) : null;
|
|
278
284
|
},
|
|
279
|
-
set: (e,
|
|
280
|
-
|
|
285
|
+
set: (e, o) => {
|
|
286
|
+
t.store.set(e, JSON.stringify(o));
|
|
281
287
|
},
|
|
282
|
-
remove: e =>
|
|
283
|
-
removeAll: () =>
|
|
284
|
-
clearAll: () =>
|
|
285
|
-
size: () =>
|
|
288
|
+
remove: e => t.store.delete(e),
|
|
289
|
+
removeAll: () => t.store.clear(),
|
|
290
|
+
clearAll: () => t.store.clear(),
|
|
291
|
+
size: () => t.store.size,
|
|
286
292
|
isPersistent: !1
|
|
287
293
|
},
|
|
288
294
|
session: {
|
|
289
295
|
get: e => {
|
|
290
|
-
const
|
|
291
|
-
return
|
|
296
|
+
const o = t.session.get(e);
|
|
297
|
+
return o ? JSON.parse(o) : null;
|
|
292
298
|
},
|
|
293
|
-
set: (e,
|
|
294
|
-
|
|
299
|
+
set: (e, o) => {
|
|
300
|
+
t.session.set(e, JSON.stringify(o));
|
|
295
301
|
},
|
|
296
|
-
remove: e =>
|
|
297
|
-
removeAll: () =>
|
|
298
|
-
clearAll: () =>
|
|
299
|
-
size: () =>
|
|
302
|
+
remove: e => t.session.delete(e),
|
|
303
|
+
removeAll: () => t.session.clear(),
|
|
304
|
+
clearAll: () => t.session.clear(),
|
|
305
|
+
size: () => t.session.size,
|
|
300
306
|
isPersistent: !1
|
|
301
307
|
},
|
|
302
308
|
cache: {
|
|
303
|
-
get: e =>
|
|
304
|
-
set: (e,
|
|
305
|
-
remove: e =>
|
|
306
|
-
removeAll: () =>
|
|
307
|
-
clear: () =>
|
|
309
|
+
get: e => t.cache.get(e),
|
|
310
|
+
set: (e, o) => t.cache.set(e, o),
|
|
311
|
+
remove: e => t.cache.delete(e),
|
|
312
|
+
removeAll: () => t.cache.clear(),
|
|
313
|
+
clear: () => t.cache.clear()
|
|
308
314
|
}
|
|
309
315
|
};
|
|
310
316
|
}
|
|
311
317
|
|
|
318
|
+
var z = "4.2.0";
|
|
319
|
+
|
|
312
320
|
Object.defineProperty(globalThis, "memorio", {
|
|
313
321
|
value: {},
|
|
314
322
|
writable: !1,
|
|
@@ -321,7 +329,7 @@ Object.defineProperty(globalThis, "memorio", {
|
|
|
321
329
|
}), Object.defineProperty(memorio, "version", {
|
|
322
330
|
writable: !1,
|
|
323
331
|
enumerable: !1,
|
|
324
|
-
value:
|
|
332
|
+
value: z
|
|
325
333
|
}), Object.defineProperty(memorio, "debug", {
|
|
326
334
|
writable: !0,
|
|
327
335
|
enumerable: !1,
|
|
@@ -331,29 +339,29 @@ Object.defineProperty(globalThis, "memorio", {
|
|
|
331
339
|
var B = [ "list", "state", "store", "idb", "observer", "useObserver", "remove", "removeAll", "_platform", "_capabilities", "_sessionId" ];
|
|
332
340
|
|
|
333
341
|
!function() {
|
|
334
|
-
const e = N(),
|
|
335
|
-
void 0 !==
|
|
336
|
-
e.hasDispatchEvent || (
|
|
342
|
+
const e = N(), o = globalThis;
|
|
343
|
+
void 0 !== o.memorio && (o.memorio._platform = e.platform, o.memorio._capabilities = e),
|
|
344
|
+
e.hasDispatchEvent || (o.dispatchEvent = function(e) {
|
|
337
345
|
return !0;
|
|
338
|
-
}, "undefined" == typeof CustomEvent && (
|
|
346
|
+
}, "undefined" == typeof CustomEvent && (o.CustomEvent = class {
|
|
339
347
|
type;
|
|
340
348
|
detail;
|
|
341
|
-
constructor(e,
|
|
342
|
-
this.type = e, this.detail =
|
|
349
|
+
constructor(e, o = {}) {
|
|
350
|
+
this.type = e, this.detail = o;
|
|
343
351
|
}
|
|
344
|
-
})), "function" != typeof
|
|
345
|
-
A.has(e) || A.set(e, []), A.get(e).push(
|
|
346
|
-
},
|
|
347
|
-
const
|
|
348
|
-
if (
|
|
349
|
-
const e =
|
|
350
|
-
e > -1 &&
|
|
352
|
+
})), "function" != typeof o.addEventListener && (o.addEventListener = function(e, o) {
|
|
353
|
+
A.has(e) || A.set(e, []), A.get(e).push(o);
|
|
354
|
+
}, o.removeEventListener = function(e, o) {
|
|
355
|
+
const t = A.get(e);
|
|
356
|
+
if (t) {
|
|
357
|
+
const e = t.indexOf(o);
|
|
358
|
+
e > -1 && t.splice(e, 1);
|
|
351
359
|
}
|
|
352
|
-
},
|
|
353
|
-
const
|
|
354
|
-
return
|
|
360
|
+
}, o.dispatchEvent = function(e) {
|
|
361
|
+
const o = A.get(e.type);
|
|
362
|
+
return o && o.forEach(o => {
|
|
355
363
|
try {
|
|
356
|
-
|
|
364
|
+
o(e);
|
|
357
365
|
} catch (e) {
|
|
358
366
|
console.error("Event listener error:", e);
|
|
359
367
|
}
|
|
@@ -361,16 +369,16 @@ var B = [ "list", "state", "store", "idb", "observer", "useObserver", "remove",
|
|
|
361
369
|
});
|
|
362
370
|
}();
|
|
363
371
|
|
|
364
|
-
var
|
|
372
|
+
var M = N();
|
|
365
373
|
|
|
366
374
|
Object.defineProperty(memorio, "_sessionId", {
|
|
367
375
|
writable: !1,
|
|
368
376
|
enumerable: !1,
|
|
369
|
-
value:
|
|
377
|
+
value: M.sessionId
|
|
370
378
|
}), memorio.createContext = J, memorio.listContexts = function() {
|
|
371
|
-
return Array.from(
|
|
379
|
+
return Array.from(C.keys());
|
|
372
380
|
}, memorio.deleteContext = function(e) {
|
|
373
|
-
return
|
|
381
|
+
return C.delete(e);
|
|
374
382
|
}, memorio.isBrowser = function() {
|
|
375
383
|
return "browser" === _();
|
|
376
384
|
}, memorio.isNode = function() {
|
|
@@ -381,64 +389,66 @@ Object.defineProperty(memorio, "_sessionId", {
|
|
|
381
389
|
return "edge" === _();
|
|
382
390
|
}, memorio.getCapabilities = N, memorio.isolate = function(e) {
|
|
383
391
|
return J(e);
|
|
392
|
+
}, memorio.help = function() {
|
|
393
|
+
console.log(`\nš§ Memorio ${z} - 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`);
|
|
384
394
|
}, Object.defineProperty(memorio, "dispatch", {
|
|
385
395
|
writable: !1,
|
|
386
396
|
enumerable: !1,
|
|
387
397
|
value: {
|
|
388
|
-
set: (e,
|
|
389
|
-
globalThis.dispatchEvent(new CustomEvent(String(e),
|
|
398
|
+
set: (e, o = {}) => {
|
|
399
|
+
globalThis.dispatchEvent(new CustomEvent(String(e), o));
|
|
390
400
|
},
|
|
391
|
-
listen: (e,
|
|
401
|
+
listen: (e, o = null, t = !1) => {
|
|
392
402
|
globalThis.observer?.list?.[e]?.length > 0 && globalThis.observer?.remove?.(e);
|
|
393
|
-
const r =
|
|
394
|
-
const
|
|
395
|
-
return globalThis.queueMicrotask ? globalThis.queueMicrotask(() => t
|
|
403
|
+
const r = o ? e => {
|
|
404
|
+
const t = e;
|
|
405
|
+
return globalThis.queueMicrotask ? globalThis.queueMicrotask(() => o(t)) : Promise.resolve().then(() => o(t));
|
|
396
406
|
} : void 0;
|
|
397
407
|
r && globalThis.addEventListener(e, r), r && (globalThis.events[e] = r);
|
|
398
408
|
},
|
|
399
409
|
remove: e => {
|
|
400
|
-
const
|
|
401
|
-
|
|
410
|
+
const o = globalThis.events?.[e];
|
|
411
|
+
o && (globalThis.removeEventListener(e, o), delete globalThis.events[e]);
|
|
402
412
|
}
|
|
403
413
|
}
|
|
404
|
-
}), memorio.propertyName = (e,
|
|
414
|
+
}), memorio.propertyName = (e, o) => String(o).replace("() => ", ""), memorio.message = (...e) => {
|
|
405
415
|
!0 === memorio.debug && console.debug(...e);
|
|
406
416
|
}, Object.defineProperty(memorio, "objPath", {
|
|
407
417
|
writable: !1,
|
|
408
418
|
enumerable: !1,
|
|
409
|
-
value: (e,
|
|
410
|
-
const r =
|
|
419
|
+
value: (e, o, t = ".") => {
|
|
420
|
+
const r = o.concat(e).join(t);
|
|
411
421
|
return globalThis.memorio._tracking && globalThis.memorio._trackedPaths?.add("state." + r),
|
|
412
422
|
r;
|
|
413
423
|
}
|
|
414
424
|
}), globalThis.memorio._tracking = !1, globalThis.memorio._trackedPaths = new Set,
|
|
415
425
|
globalThis.memorio._locked = !1;
|
|
416
426
|
|
|
417
|
-
var
|
|
427
|
+
var W = (e, o, t = []) => new Proxy(e, {
|
|
418
428
|
get(e, r) {
|
|
419
|
-
if ("__path" === r) return
|
|
429
|
+
if ("__path" === r) return t.length > 0 ? "state." + t.join(".") : "state";
|
|
420
430
|
if ("list" === r) return memorio.message('Some state could be hidden when you use "state.list". Use "state" to see the complete list '),
|
|
421
431
|
JSON.parse(JSON.stringify(globalThis.state));
|
|
422
432
|
if (globalThis.memorio._tracking && "string" == typeof r) {
|
|
423
|
-
const e =
|
|
433
|
+
const e = t.length > 0 ? "state." + t.concat(r).join(".") : "state." + r;
|
|
424
434
|
globalThis.memorio._trackedPaths?.add(e);
|
|
425
435
|
}
|
|
426
|
-
if ("remove" === r) return
|
|
436
|
+
if ("remove" === r) return o => (delete e[o], !0);
|
|
427
437
|
if ("removeAll" === r) return () => {
|
|
428
438
|
try {
|
|
429
|
-
for (const
|
|
439
|
+
for (const o in e) "function" == typeof e[o] || [ "list", "remove", "removeAll", "lock", "unlock" ].includes(o) || delete e[o];
|
|
430
440
|
} catch (e) {
|
|
431
441
|
console.error(e);
|
|
432
442
|
}
|
|
433
443
|
};
|
|
434
444
|
if (Object.isFrozen(e[r])) return e[r];
|
|
435
445
|
if ("lock" === r || "unlock" === r) {
|
|
436
|
-
const
|
|
437
|
-
if (
|
|
446
|
+
const o = Reflect.get(e, r);
|
|
447
|
+
if (o) return o;
|
|
438
448
|
}
|
|
439
449
|
try {
|
|
440
450
|
const s = Reflect.get(e, r);
|
|
441
|
-
return s && "object" == typeof s && [ "Array", "Object" ].includes(s.constructor.name) ?
|
|
451
|
+
return s && "object" == typeof s && [ "Array", "Object" ].includes(s.constructor.name) ? W(s, o, t.concat(r)) : s;
|
|
442
452
|
} catch (e) {
|
|
443
453
|
return void console.error("Error: ", e);
|
|
444
454
|
}
|
|
@@ -452,10 +462,10 @@ var M = (e, t, o = []) => new Proxy(e, {
|
|
|
452
462
|
if (e[r] && "object" == typeof e[r] && e[r].__locked) return console.error(`Error: state '${r}' is locked. Use state.${r}.unlock() to enable modifications.`),
|
|
453
463
|
!1;
|
|
454
464
|
try {
|
|
455
|
-
const
|
|
456
|
-
if (
|
|
465
|
+
const n = globalThis.memorio.objPath?.(r, t) ?? r;
|
|
466
|
+
if (o({
|
|
457
467
|
action: "set",
|
|
458
|
-
path:
|
|
468
|
+
path: n,
|
|
459
469
|
target: e,
|
|
460
470
|
newValue: s,
|
|
461
471
|
previousValue: Reflect.get(e, r)
|
|
@@ -467,32 +477,32 @@ var M = (e, t, o = []) => new Proxy(e, {
|
|
|
467
477
|
}
|
|
468
478
|
});
|
|
469
479
|
} catch (e) {}
|
|
470
|
-
})("state." +
|
|
471
|
-
const
|
|
472
|
-
if (
|
|
473
|
-
Object.defineProperty(
|
|
480
|
+
})("state." + n), Reflect.set(e, r, s), e[r] && "object" == typeof e[r]) {
|
|
481
|
+
const o = e[r];
|
|
482
|
+
if (o && "object" == typeof o) try {
|
|
483
|
+
Object.defineProperty(o, "__locked", {
|
|
474
484
|
writable: !0,
|
|
475
485
|
enumerable: !1,
|
|
476
486
|
configurable: !1,
|
|
477
487
|
value: !1
|
|
478
|
-
}), Object.defineProperty(
|
|
488
|
+
}), Object.defineProperty(o, "lock", {
|
|
479
489
|
writable: !1,
|
|
480
490
|
enumerable: !1,
|
|
481
491
|
configurable: !1,
|
|
482
492
|
value: () => {
|
|
483
|
-
Object.defineProperty(
|
|
493
|
+
Object.defineProperty(o, "__locked", {
|
|
484
494
|
writable: !0,
|
|
485
495
|
enumerable: !1,
|
|
486
496
|
configurable: !1,
|
|
487
497
|
value: !0
|
|
488
498
|
}), memorio.message(`State '${r}' is now locked.`);
|
|
489
499
|
}
|
|
490
|
-
}), Object.defineProperty(
|
|
500
|
+
}), Object.defineProperty(o, "unlock", {
|
|
491
501
|
writable: !1,
|
|
492
502
|
enumerable: !1,
|
|
493
503
|
configurable: !1,
|
|
494
504
|
value: () => {
|
|
495
|
-
Object.defineProperty(
|
|
505
|
+
Object.defineProperty(o, "__locked", {
|
|
496
506
|
writable: !0,
|
|
497
507
|
enumerable: !1,
|
|
498
508
|
configurable: !1,
|
|
@@ -509,8 +519,8 @@ var M = (e, t, o = []) => new Proxy(e, {
|
|
|
509
519
|
},
|
|
510
520
|
deleteProperty(e, r) {
|
|
511
521
|
try {
|
|
512
|
-
const s = globalThis.memorio.objPath?.(r,
|
|
513
|
-
return
|
|
522
|
+
const s = globalThis.memorio.objPath?.(r, t);
|
|
523
|
+
return o({
|
|
514
524
|
action: "delete",
|
|
515
525
|
path: s,
|
|
516
526
|
target: e
|
|
@@ -520,10 +530,10 @@ var M = (e, t, o = []) => new Proxy(e, {
|
|
|
520
530
|
}
|
|
521
531
|
},
|
|
522
532
|
ownKeys: e => Reflect.ownKeys(e),
|
|
523
|
-
getOwnPropertyDescriptor: (e,
|
|
533
|
+
getOwnPropertyDescriptor: (e, o) => Reflect.getOwnPropertyDescriptor(e, o)
|
|
524
534
|
});
|
|
525
535
|
|
|
526
|
-
globalThis?.state || (globalThis.state =
|
|
536
|
+
globalThis?.state || (globalThis.state = W({}, () => {})), globalThis.state.lock = () => {
|
|
527
537
|
globalThis.memorio._locked = !0, memorio.message("State is now locked. All modifications are blocked.");
|
|
528
538
|
}, globalThis.state.unlock = () => {
|
|
529
539
|
globalThis.memorio._locked = !1, memorio.message("State is now unlocked. Modifications are allowed.");
|
|
@@ -535,7 +545,7 @@ globalThis?.state || (globalThis.state = M({}, () => {})), globalThis.state.lock
|
|
|
535
545
|
configurable: !0
|
|
536
546
|
});
|
|
537
547
|
|
|
538
|
-
globalThis.observer = (e,
|
|
548
|
+
globalThis.observer = (e, o = null, t = !0) => {
|
|
539
549
|
console.warn('DEPRECATED: "observer" is deprecated and will be removed in future versions. Please use "useObserver" instead.');
|
|
540
550
|
try {
|
|
541
551
|
if (!(e => "state" === e.split(".")[0] || (console.error(`Observer Error: You need to declare 'state.' or 'store.'. The '${e}' string is incorrect!`),
|
|
@@ -543,20 +553,20 @@ globalThis.observer = (e, t = null, o = !0) => {
|
|
|
543
553
|
} catch (e) {
|
|
544
554
|
return void console.error(e);
|
|
545
555
|
}
|
|
546
|
-
if (e ||
|
|
547
|
-
if (e && !
|
|
548
|
-
const
|
|
556
|
+
if (e || o) if (e || !o) {
|
|
557
|
+
if (e && !o) {
|
|
558
|
+
const o = {
|
|
549
559
|
detail: {
|
|
550
560
|
name: String(e)
|
|
551
561
|
}
|
|
552
|
-
},
|
|
553
|
-
return
|
|
562
|
+
}, t = globalThis.observer;
|
|
563
|
+
return t?.list?.[e] && globalThis.memorio.dispatch.remove(o), t?.list?.[e] || globalThis.memorio.dispatch.listen(o),
|
|
554
564
|
void memorio.message(`called: ${e}`);
|
|
555
565
|
}
|
|
556
|
-
if (e &&
|
|
557
|
-
if ("string" != typeof e || "function" != typeof
|
|
566
|
+
if (e && o) {
|
|
567
|
+
if ("string" != typeof e || "function" != typeof o) return void console.error("Observer Error: name of state need to be a 'string' like 'state.test' and the callback need to be a 'function'");
|
|
558
568
|
const r = globalThis.observer;
|
|
559
|
-
return r?.list?.[e] && globalThis.memorio.dispatch.remove(e,
|
|
569
|
+
return r?.list?.[e] && globalThis.memorio.dispatch.remove(e, o, t), void (r?.list?.[e] || globalThis.memorio.dispatch.listen(e, o, t));
|
|
560
570
|
}
|
|
561
571
|
} 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!");
|
|
562
572
|
}, Object.defineProperties(globalThis.observer, {
|
|
@@ -570,9 +580,9 @@ globalThis.observer = (e, t = null, o = !0) => {
|
|
|
570
580
|
},
|
|
571
581
|
removeAll: {
|
|
572
582
|
get: () => {
|
|
573
|
-
const e = globalThis.observer,
|
|
574
|
-
return
|
|
575
|
-
e?.remove?.(
|
|
583
|
+
const e = globalThis.observer, o = e?.list;
|
|
584
|
+
return o && Object.keys(o).forEach(o => {
|
|
585
|
+
e?.remove?.(o);
|
|
576
586
|
}), !0;
|
|
577
587
|
}
|
|
578
588
|
}
|
|
@@ -581,36 +591,36 @@ globalThis.observer = (e, t = null, o = !0) => {
|
|
|
581
591
|
writable: !0,
|
|
582
592
|
enumerable: !1,
|
|
583
593
|
configurable: !0
|
|
584
|
-
}), globalThis.useObserver = (e,
|
|
585
|
-
if (!
|
|
586
|
-
const
|
|
594
|
+
}), globalThis.useObserver = (e, o) => {
|
|
595
|
+
if (!o || "function" != typeof e) return () => {};
|
|
596
|
+
const t = [], r = Array.isArray(o) && !o.__path ? o : [ o ];
|
|
587
597
|
try {
|
|
588
|
-
return r.forEach(
|
|
598
|
+
return r.forEach(o => {
|
|
589
599
|
let r = "";
|
|
590
|
-
if ("function" == typeof
|
|
600
|
+
if ("function" == typeof o) {
|
|
591
601
|
const e = globalThis.memorio.propertyName;
|
|
592
602
|
if ("function" == typeof e) {
|
|
593
|
-
const
|
|
594
|
-
|
|
603
|
+
const t = e(globalThis.state, o);
|
|
604
|
+
t && (r = t);
|
|
595
605
|
}
|
|
596
|
-
} else "object" == typeof
|
|
606
|
+
} else "object" == typeof o && null !== o ? r = o.__path || ("function" == typeof o.toString && "[object Object]" !== o.toString() ? o.toString() : "") : "string" == typeof o && (o.startsWith("state.") || o.startsWith("store.")) && (r = o);
|
|
597
607
|
if (r) {
|
|
598
608
|
r = r.replace(/^(\(\)\s*=>\s*)/, "").replace(/^globalThis\./, "").replace(/^state\./, "");
|
|
599
|
-
const
|
|
600
|
-
globalThis.memorio.dispatch.listen(
|
|
609
|
+
const o = r.startsWith("store.") || r.startsWith("state.") ? r : "state." + r;
|
|
610
|
+
globalThis.memorio.dispatch.listen(o, () => e()), t.push(o);
|
|
601
611
|
} else {
|
|
602
612
|
globalThis.memorio._trackedPaths?.clear(), globalThis.memorio._tracking = !0;
|
|
603
613
|
try {
|
|
604
614
|
e();
|
|
605
615
|
} catch (e) {}
|
|
606
|
-
globalThis.memorio._tracking = !1, globalThis.memorio._trackedPaths?.forEach(
|
|
607
|
-
|
|
608
|
-
|
|
616
|
+
globalThis.memorio._tracking = !1, globalThis.memorio._trackedPaths?.forEach(o => {
|
|
617
|
+
t.includes(o) || (memorio.message(`useObserver: [Auto-Discovery] -> "${o}"`), globalThis.memorio.dispatch.listen(o, () => e()),
|
|
618
|
+
t.push(o));
|
|
609
619
|
});
|
|
610
620
|
}
|
|
611
|
-
}),
|
|
621
|
+
}), t.length > 0 ? memorio.message(`useObserver: Monitoring ${t.length} paths.`) : console.warn("useObserver: No paths resolved for monitoring. Check your dependencies!"),
|
|
612
622
|
() => {
|
|
613
|
-
|
|
623
|
+
t.forEach(e => {
|
|
614
624
|
globalThis.memorio.dispatch && "function" == typeof globalThis.memorio.dispatch.remove && (globalThis.memorio.dispatch.remove(e),
|
|
615
625
|
memorio.message(`useObserver: Stopped monitoring "${e}"`));
|
|
616
626
|
});
|
|
@@ -620,11 +630,23 @@ globalThis.observer = (e, t = null, o = !0) => {
|
|
|
620
630
|
}
|
|
621
631
|
}, Object.freeze(globalThis.useObserver);
|
|
622
632
|
|
|
623
|
-
var
|
|
633
|
+
var R = D(), U = new Map;
|
|
634
|
+
|
|
635
|
+
function K() {
|
|
636
|
+
const e = memorio._currentContext || "" || "default";
|
|
637
|
+
return U.has(e) || U.set(e, new Map), U.get(e);
|
|
638
|
+
}
|
|
624
639
|
|
|
625
|
-
|
|
640
|
+
var q = null !== R;
|
|
641
|
+
|
|
642
|
+
function F() {
|
|
643
|
+
const e = memorio._currentContext || "";
|
|
644
|
+
return e ? `${e}-` : "memorio_store_";
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
function L(e) {
|
|
626
648
|
return e && "string" == typeof e ? e.length > 512 ? (memorio.message("Key too long (max 512 characters)"),
|
|
627
|
-
"") : /^[a-zA-Z0-9_.-]+$/.test(e) ?
|
|
649
|
+
"") : /^[a-zA-Z0-9_.-]+$/.test(e) ? F() + e : (memorio.message("Key contains invalid characters (only a-z, A-Z, 0-9, _, ., - allowed)"),
|
|
628
650
|
"") : "";
|
|
629
651
|
}
|
|
630
652
|
|
|
@@ -636,42 +658,45 @@ Object.defineProperty(globalThis, "store", {
|
|
|
636
658
|
get: {
|
|
637
659
|
value: e => {
|
|
638
660
|
if (!e) return;
|
|
639
|
-
const
|
|
661
|
+
const o = L(e);
|
|
640
662
|
try {
|
|
641
|
-
if (
|
|
642
|
-
const e =
|
|
663
|
+
if (q) {
|
|
664
|
+
const e = R.getItem(o);
|
|
643
665
|
return e ? JSON.parse(e) : e;
|
|
644
666
|
}
|
|
645
667
|
{
|
|
646
|
-
const e =
|
|
668
|
+
const e = K().get(o);
|
|
647
669
|
return e ? JSON.parse(e) : e;
|
|
648
670
|
}
|
|
649
|
-
} catch (
|
|
650
|
-
memorio.message(`Error parsing store item '${e}': ${
|
|
671
|
+
} catch (o) {
|
|
672
|
+
memorio.message(`Error parsing store item '${e}': ${o}`);
|
|
651
673
|
}
|
|
652
674
|
return null;
|
|
653
675
|
}
|
|
654
676
|
},
|
|
655
677
|
getMultiple: {
|
|
656
678
|
value: e => {
|
|
657
|
-
const
|
|
658
|
-
for (const
|
|
659
|
-
const e = store.get(
|
|
660
|
-
e && (t
|
|
679
|
+
const o = {};
|
|
680
|
+
for (const t of e) try {
|
|
681
|
+
const e = store.get(t);
|
|
682
|
+
e && (o[t] = e);
|
|
661
683
|
} catch {}
|
|
662
|
-
return
|
|
684
|
+
return o;
|
|
663
685
|
}
|
|
664
686
|
},
|
|
665
687
|
set: {
|
|
666
|
-
value: (e,
|
|
688
|
+
value: (e, o) => {
|
|
667
689
|
if (!e) return;
|
|
668
|
-
const
|
|
690
|
+
const t = L(e);
|
|
669
691
|
try {
|
|
670
|
-
if (
|
|
671
|
-
if (null ==
|
|
672
|
-
} else
|
|
673
|
-
|
|
674
|
-
|
|
692
|
+
if (q) {
|
|
693
|
+
if (null == o) R.setItem(t, JSON.stringify(null)); else if ("object" == typeof o || "number" == typeof o || "boolean" == typeof o || "string" == typeof o) R.setItem(t, JSON.stringify(o)); else if ("function" == typeof o) return void memorio.message("Storing functions is not secure and is blocked for safety.");
|
|
694
|
+
} else {
|
|
695
|
+
const e = K();
|
|
696
|
+
if (null == o) e.set(t, JSON.stringify(null)); else if ("object" == typeof o || "number" == typeof o || "boolean" == typeof o || "string" == typeof o) e.set(t, JSON.stringify(o)); else if ("function" == typeof o) return void memorio.message("Storing functions is not secure and is blocked for safety.");
|
|
697
|
+
}
|
|
698
|
+
} catch (o) {
|
|
699
|
+
memorio.message(`Error setting store item '${e}': ${o}`);
|
|
675
700
|
}
|
|
676
701
|
return null;
|
|
677
702
|
}
|
|
@@ -679,13 +704,13 @@ Object.defineProperty(globalThis, "store", {
|
|
|
679
704
|
remove: {
|
|
680
705
|
value: e => {
|
|
681
706
|
if (!e) return;
|
|
682
|
-
const
|
|
707
|
+
const o = L(e);
|
|
683
708
|
try {
|
|
684
|
-
if (
|
|
685
|
-
if (
|
|
686
|
-
} else if (
|
|
687
|
-
} catch (
|
|
688
|
-
memorio.message(`Error removing store item '${e}': ${
|
|
709
|
+
if (q) {
|
|
710
|
+
if (R.getItem(o)) return R.removeItem(o), !0;
|
|
711
|
+
} else if (K().has(o)) return K().delete(o), !0;
|
|
712
|
+
} catch (o) {
|
|
713
|
+
memorio.message(`Error removing store item '${e}': ${o}`);
|
|
689
714
|
}
|
|
690
715
|
return !1;
|
|
691
716
|
}
|
|
@@ -695,14 +720,14 @@ Object.defineProperty(globalThis, "store", {
|
|
|
695
720
|
},
|
|
696
721
|
removeAll: {
|
|
697
722
|
value: () => {
|
|
698
|
-
if (
|
|
723
|
+
if (q) {
|
|
699
724
|
const e = [];
|
|
700
|
-
for (let
|
|
701
|
-
const
|
|
702
|
-
|
|
725
|
+
for (let o = 0; o < R.length; o++) {
|
|
726
|
+
const t = R.key(o);
|
|
727
|
+
t?.startsWith(F()) && e.push(t);
|
|
703
728
|
}
|
|
704
|
-
e.forEach(e =>
|
|
705
|
-
} else
|
|
729
|
+
e.forEach(e => R.removeItem(e));
|
|
730
|
+
} else K().clear();
|
|
706
731
|
return !0;
|
|
707
732
|
}
|
|
708
733
|
},
|
|
@@ -715,40 +740,40 @@ Object.defineProperty(globalThis, "store", {
|
|
|
715
740
|
size: {
|
|
716
741
|
value: () => {
|
|
717
742
|
let e = 0;
|
|
718
|
-
return
|
|
719
|
-
if (
|
|
720
|
-
const
|
|
721
|
-
|
|
743
|
+
return q ? Object.keys(R).forEach(o => {
|
|
744
|
+
if (o.startsWith(F())) {
|
|
745
|
+
const t = R.getItem(o);
|
|
746
|
+
t && (e += t.length);
|
|
722
747
|
}
|
|
723
|
-
}) :
|
|
724
|
-
e +=
|
|
748
|
+
}) : K().forEach(o => {
|
|
749
|
+
e += o.length;
|
|
725
750
|
}), e;
|
|
726
751
|
}
|
|
727
752
|
},
|
|
728
753
|
isPersistent: {
|
|
729
|
-
get: () =>
|
|
754
|
+
get: () => q
|
|
730
755
|
},
|
|
731
756
|
list: {
|
|
732
757
|
value: () => {
|
|
733
758
|
const e = {};
|
|
734
759
|
try {
|
|
735
|
-
if (
|
|
736
|
-
const
|
|
737
|
-
if (
|
|
738
|
-
const
|
|
760
|
+
if (q) for (let o = 0; o < R.length; o++) {
|
|
761
|
+
const t = R.key(o);
|
|
762
|
+
if (t?.startsWith(F())) {
|
|
763
|
+
const o = t.replace(F(), ""), r = R.getItem(t);
|
|
739
764
|
if (null !== r) try {
|
|
740
|
-
e[
|
|
765
|
+
e[o] = JSON.parse(r);
|
|
741
766
|
} catch {
|
|
742
|
-
e[
|
|
767
|
+
e[o] = r;
|
|
743
768
|
}
|
|
744
769
|
}
|
|
745
|
-
} else
|
|
746
|
-
if (
|
|
747
|
-
const r =
|
|
770
|
+
} else K().forEach((o, t) => {
|
|
771
|
+
if (t.startsWith(F())) {
|
|
772
|
+
const r = t.replace(F(), "");
|
|
748
773
|
try {
|
|
749
|
-
e[r] = JSON.parse(
|
|
774
|
+
e[r] = JSON.parse(o);
|
|
750
775
|
} catch {
|
|
751
|
-
e[r] =
|
|
776
|
+
e[r] = o;
|
|
752
777
|
}
|
|
753
778
|
}
|
|
754
779
|
});
|
|
@@ -760,11 +785,23 @@ Object.defineProperty(globalThis, "store", {
|
|
|
760
785
|
}
|
|
761
786
|
}), Object.freeze(store);
|
|
762
787
|
|
|
763
|
-
var
|
|
788
|
+
var H = x(), V = new Map;
|
|
764
789
|
|
|
765
|
-
function Y(
|
|
790
|
+
function Y() {
|
|
791
|
+
const e = memorio._currentContext || "" || "default";
|
|
792
|
+
return V.has(e) || V.set(e, new Map), V.get(e);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
var Z = null !== H;
|
|
796
|
+
|
|
797
|
+
function G() {
|
|
798
|
+
const e = memorio._currentContext || "";
|
|
799
|
+
return e ? `${e}-` : "memorio_session_";
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
function Q(e) {
|
|
766
803
|
return e && "string" == typeof e ? e.length > 512 ? (memorio.message("Key too long (max 512 characters)"),
|
|
767
|
-
"") : /^[a-zA-Z0-9_.-]+$/.test(e) ?
|
|
804
|
+
"") : /^[a-zA-Z0-9_.-]+$/.test(e) ? G() + e : (memorio.message("Key contains invalid characters (only a-z, A-Z, 0-9, _, ., - allowed)"),
|
|
768
805
|
"") : "";
|
|
769
806
|
}
|
|
770
807
|
|
|
@@ -776,42 +813,45 @@ Object.defineProperty(globalThis, "session", {
|
|
|
776
813
|
get: {
|
|
777
814
|
value: e => {
|
|
778
815
|
if (!e) return;
|
|
779
|
-
const
|
|
816
|
+
const o = Q(e);
|
|
780
817
|
try {
|
|
781
|
-
if (
|
|
782
|
-
const e =
|
|
818
|
+
if (Z) {
|
|
819
|
+
const e = H.getItem(o);
|
|
783
820
|
return e ? JSON.parse(e) : e;
|
|
784
821
|
}
|
|
785
822
|
{
|
|
786
|
-
const e =
|
|
823
|
+
const e = Y().get(o);
|
|
787
824
|
return e ? JSON.parse(e) : e;
|
|
788
825
|
}
|
|
789
|
-
} catch (
|
|
790
|
-
memorio.message(`Error parsing session item '${e}':${
|
|
826
|
+
} catch (o) {
|
|
827
|
+
memorio.message(`Error parsing session item '${e}':${o}`);
|
|
791
828
|
}
|
|
792
829
|
}
|
|
793
830
|
},
|
|
794
831
|
set: {
|
|
795
|
-
value: (e,
|
|
832
|
+
value: (e, o) => {
|
|
796
833
|
if (!e) return;
|
|
797
|
-
const
|
|
834
|
+
const t = Q(e);
|
|
798
835
|
try {
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
836
|
+
if (Z) null == o ? H.setItem(t, JSON.stringify(null)) : "object" == typeof o || "number" == typeof o || "boolean" == typeof o || "string" == typeof o ? H.setItem(t, JSON.stringify(o)) : "function" == typeof o && memorio.message("It's not secure to session functions."); else {
|
|
837
|
+
const e = Y();
|
|
838
|
+
null == o ? e.set(t, JSON.stringify(null)) : "object" == typeof o || "number" == typeof o || "boolean" == typeof o || "string" == typeof o ? e.set(t, JSON.stringify(o)) : "function" == typeof o && memorio.message("It's not secure to session functions.");
|
|
839
|
+
}
|
|
840
|
+
} catch (o) {
|
|
841
|
+
memorio.message(`Error setting session item '${e}': ${o}`);
|
|
802
842
|
}
|
|
803
843
|
}
|
|
804
844
|
},
|
|
805
845
|
remove: {
|
|
806
846
|
value: e => {
|
|
807
847
|
if (!e) return;
|
|
808
|
-
const
|
|
848
|
+
const o = Q(e);
|
|
809
849
|
try {
|
|
810
|
-
if (
|
|
811
|
-
if (
|
|
812
|
-
} else if (
|
|
813
|
-
} catch (
|
|
814
|
-
memorio.message(`Error removing session item '${e}': ${
|
|
850
|
+
if (Z) {
|
|
851
|
+
if (H.getItem(o)) return H.removeItem(o), !0;
|
|
852
|
+
} else if (Y().has(o)) return Y().delete(o), !0;
|
|
853
|
+
} catch (o) {
|
|
854
|
+
memorio.message(`Error removing session item '${e}': ${o}`);
|
|
815
855
|
}
|
|
816
856
|
}
|
|
817
857
|
},
|
|
@@ -820,14 +860,14 @@ Object.defineProperty(globalThis, "session", {
|
|
|
820
860
|
},
|
|
821
861
|
removeAll: {
|
|
822
862
|
value: () => {
|
|
823
|
-
if (
|
|
863
|
+
if (Z) {
|
|
824
864
|
const e = [];
|
|
825
|
-
for (let
|
|
826
|
-
const
|
|
827
|
-
|
|
865
|
+
for (let o = 0; o < H.length; o++) {
|
|
866
|
+
const t = H.key(o);
|
|
867
|
+
t?.startsWith(G()) && e.push(t);
|
|
828
868
|
}
|
|
829
|
-
e.forEach(e =>
|
|
830
|
-
} else
|
|
869
|
+
e.forEach(e => H.removeItem(e));
|
|
870
|
+
} else Y().clear();
|
|
831
871
|
return !0;
|
|
832
872
|
}
|
|
833
873
|
},
|
|
@@ -840,40 +880,40 @@ Object.defineProperty(globalThis, "session", {
|
|
|
840
880
|
size: {
|
|
841
881
|
value: () => {
|
|
842
882
|
let e = 0;
|
|
843
|
-
return
|
|
844
|
-
if (
|
|
845
|
-
const
|
|
846
|
-
|
|
883
|
+
return Z ? Object.keys(H).forEach(o => {
|
|
884
|
+
if (o.startsWith(G())) {
|
|
885
|
+
const t = H.getItem(o);
|
|
886
|
+
t && (e += t.length);
|
|
847
887
|
}
|
|
848
|
-
}) :
|
|
849
|
-
e +=
|
|
888
|
+
}) : Y().forEach(o => {
|
|
889
|
+
e += o.length;
|
|
850
890
|
}), e;
|
|
851
891
|
}
|
|
852
892
|
},
|
|
853
893
|
isPersistent: {
|
|
854
|
-
get: () =>
|
|
894
|
+
get: () => Z
|
|
855
895
|
},
|
|
856
896
|
list: {
|
|
857
897
|
value: () => {
|
|
858
898
|
const e = {};
|
|
859
899
|
try {
|
|
860
|
-
if (
|
|
861
|
-
const
|
|
862
|
-
if (
|
|
863
|
-
const
|
|
900
|
+
if (Z) for (let o = 0; o < H.length; o++) {
|
|
901
|
+
const t = H.key(o);
|
|
902
|
+
if (t?.startsWith(G())) {
|
|
903
|
+
const o = t.replace(G(), ""), r = H.getItem(t);
|
|
864
904
|
if (null !== r) try {
|
|
865
|
-
e[
|
|
905
|
+
e[o] = JSON.parse(r);
|
|
866
906
|
} catch {
|
|
867
|
-
e[
|
|
907
|
+
e[o] = r;
|
|
868
908
|
}
|
|
869
909
|
}
|
|
870
|
-
} else
|
|
871
|
-
if (
|
|
872
|
-
const r =
|
|
910
|
+
} else Y().forEach((o, t) => {
|
|
911
|
+
if (t.startsWith(G())) {
|
|
912
|
+
const r = t.replace(G(), "");
|
|
873
913
|
try {
|
|
874
|
-
e[r] = JSON.parse(
|
|
914
|
+
e[r] = JSON.parse(o);
|
|
875
915
|
} catch {
|
|
876
|
-
e[r] =
|
|
916
|
+
e[r] = o;
|
|
877
917
|
}
|
|
878
918
|
}
|
|
879
919
|
});
|
|
@@ -885,18 +925,18 @@ Object.defineProperty(globalThis, "session", {
|
|
|
885
925
|
}
|
|
886
926
|
}), Object.freeze(session);
|
|
887
927
|
|
|
888
|
-
var
|
|
928
|
+
var X = {};
|
|
889
929
|
|
|
890
930
|
Object.defineProperty(globalThis, "cache", {
|
|
891
931
|
value: new Proxy({}, {
|
|
892
|
-
get: (e,
|
|
893
|
-
|
|
894
|
-
} : "remove" ===
|
|
895
|
-
!0) : "list" ===
|
|
896
|
-
...
|
|
897
|
-
}) :
|
|
898
|
-
set: (e,
|
|
899
|
-
deleteProperty: (e,
|
|
932
|
+
get: (e, o) => "get" === o ? e => X[e] : "set" === o ? (e, o) => {
|
|
933
|
+
X[e] = o;
|
|
934
|
+
} : "remove" === o ? e => (delete X[e], !0) : "removeAll" === o || "clear" === o ? () => (Object.keys(X).forEach(e => delete X[e]),
|
|
935
|
+
!0) : "list" === o ? () => ({
|
|
936
|
+
...X
|
|
937
|
+
}) : X[o],
|
|
938
|
+
set: (e, o, t) => (X[o] = t, !0),
|
|
939
|
+
deleteProperty: (e, o) => (delete X[o], !0)
|
|
900
940
|
}),
|
|
901
941
|
enumerable: !1,
|
|
902
942
|
configurable: !0
|
|
@@ -915,13 +955,13 @@ Object.defineProperty(globalThis, "cache", {
|
|
|
915
955
|
writable: !0,
|
|
916
956
|
configurable: !0,
|
|
917
957
|
enumerable: !1
|
|
918
|
-
}), await Promise.all([ Promise.resolve().then(() => (r(),
|
|
919
|
-
s)), Promise.resolve().then(() => (a(),
|
|
920
|
-
l)), Promise.resolve().then(() => (
|
|
921
|
-
|
|
958
|
+
}), await Promise.all([ Promise.resolve().then(() => (r(), t)), Promise.resolve().then(() => (n(),
|
|
959
|
+
s)), Promise.resolve().then(() => (a(), i)), Promise.resolve().then(() => (c(),
|
|
960
|
+
l)), Promise.resolve().then(() => (u(), m)), Promise.resolve().then(() => (d(),
|
|
961
|
+
b)), Promise.resolve().then(() => (f(), g)), Promise.resolve().then(() => (p(),
|
|
922
962
|
h)), Promise.resolve().then(() => (y(), v)), Promise.resolve().then(() => (O(),
|
|
923
|
-
T)), Promise.resolve().then(() => (
|
|
924
|
-
|
|
963
|
+
T)), Promise.resolve().then(() => (S(), w)), Promise.resolve().then(() => (P(),
|
|
964
|
+
j)), Promise.resolve().then(() => (E(), $)) ]), Object.preventExtensions(idb), Object.seal(idb),
|
|
925
965
|
Object.freeze(idb);
|
|
926
966
|
})() : (Object.defineProperty(globalThis, "idb", {
|
|
927
967
|
value: {
|
|
@@ -941,35 +981,35 @@ Object.defineProperty(globalThis, "cache", {
|
|
|
941
981
|
enumerable: !1
|
|
942
982
|
}), console.warn("Memorio IDB: IndexedDB is not available in this environment. Use store or session for data persistence."));
|
|
943
983
|
|
|
944
|
-
var
|
|
984
|
+
var ee = (globalThis.memorio || {}).globals;
|
|
945
985
|
|
|
946
|
-
function
|
|
986
|
+
function oe() {
|
|
947
987
|
if (!globalThis.store) return {};
|
|
948
|
-
const e = {},
|
|
949
|
-
if ("function" == typeof
|
|
950
|
-
return
|
|
988
|
+
const e = {}, o = globalThis.store;
|
|
989
|
+
if ("function" == typeof o.list) try {
|
|
990
|
+
return o.list();
|
|
951
991
|
} catch {}
|
|
952
|
-
if ("function" == typeof
|
|
953
|
-
const r =
|
|
954
|
-
null != r && (e[
|
|
992
|
+
if ("function" == typeof o.get) for (const t of Object.keys(o)) if (![ "get", "set", "remove", "delete", "removeAll", "clearAll", "size", "isPersistent", "list" ].includes(t)) try {
|
|
993
|
+
const r = o.get(t);
|
|
994
|
+
null != r && (e[t] = r);
|
|
955
995
|
} catch {}
|
|
956
996
|
return e;
|
|
957
997
|
}
|
|
958
998
|
|
|
959
|
-
function
|
|
999
|
+
function te() {
|
|
960
1000
|
if (!globalThis.session) return {};
|
|
961
|
-
const e = {},
|
|
962
|
-
if ("function" == typeof
|
|
963
|
-
return
|
|
1001
|
+
const e = {}, o = globalThis.session;
|
|
1002
|
+
if ("function" == typeof o.list) try {
|
|
1003
|
+
return o.list();
|
|
964
1004
|
} catch {}
|
|
965
|
-
if ("function" == typeof
|
|
966
|
-
const r =
|
|
967
|
-
null != r && (e[
|
|
1005
|
+
if ("function" == typeof o.get) for (const t of Object.keys(o)) if (![ "get", "set", "remove", "delete", "removeAll", "clearAll", "size", "isPersistent", "list" ].includes(t)) try {
|
|
1006
|
+
const r = o.get(t);
|
|
1007
|
+
null != r && (e[t] = r);
|
|
968
1008
|
} catch {}
|
|
969
1009
|
return e;
|
|
970
1010
|
}
|
|
971
1011
|
|
|
972
|
-
var
|
|
1012
|
+
var re, se = e => {
|
|
973
1013
|
globalThis[e] && "function" == typeof globalThis[e].clear ? globalThis[e].clear() : console.error(`Module ${e} not found or does not support clear()`);
|
|
974
1014
|
};
|
|
975
1015
|
|
|
@@ -981,16 +1021,16 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "devt
|
|
|
981
1021
|
if (!0 === globalThis.memorio?.debug) {
|
|
982
1022
|
if (globalThis.state) {
|
|
983
1023
|
const e = globalThis.state.list;
|
|
984
|
-
let
|
|
985
|
-
|
|
986
|
-
console.table(
|
|
1024
|
+
let o;
|
|
1025
|
+
o = "function" == typeof e ? e() : "object" == typeof e && null !== e ? e : globalThis.state,
|
|
1026
|
+
console.table(o);
|
|
987
1027
|
}
|
|
988
|
-
if (globalThis.store && console.table(
|
|
1028
|
+
if (globalThis.store && console.table(oe()), globalThis.session && console.table(te()),
|
|
989
1029
|
globalThis.cache) {
|
|
990
1030
|
const e = globalThis.cache.list;
|
|
991
|
-
let
|
|
992
|
-
|
|
993
|
-
console.table(
|
|
1031
|
+
let o;
|
|
1032
|
+
o = "function" == typeof e ? e() : "object" == typeof e && null !== e ? e : globalThis.cache,
|
|
1033
|
+
console.table(o);
|
|
994
1034
|
}
|
|
995
1035
|
}
|
|
996
1036
|
},
|
|
@@ -998,8 +1038,8 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "devt
|
|
|
998
1038
|
const e = e => {
|
|
999
1039
|
if (!e) return 0;
|
|
1000
1040
|
if ("function" == typeof e.list) try {
|
|
1001
|
-
const
|
|
1002
|
-
return Object.keys(
|
|
1041
|
+
const o = e.list();
|
|
1042
|
+
return Object.keys(o).length;
|
|
1003
1043
|
} catch {}
|
|
1004
1044
|
return Object.keys(e).length;
|
|
1005
1045
|
};
|
|
@@ -1012,9 +1052,9 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "devt
|
|
|
1012
1052
|
lastUpdate: (new Date).toISOString()
|
|
1013
1053
|
};
|
|
1014
1054
|
},
|
|
1015
|
-
clear:
|
|
1055
|
+
clear: se,
|
|
1016
1056
|
clearAll: () => {
|
|
1017
|
-
|
|
1057
|
+
se("state"), se("store"), se("session"), se("cache");
|
|
1018
1058
|
},
|
|
1019
1059
|
exportData: () => {
|
|
1020
1060
|
const e = {
|
|
@@ -1025,8 +1065,8 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "devt
|
|
|
1025
1065
|
return;
|
|
1026
1066
|
}
|
|
1027
1067
|
})(),
|
|
1028
|
-
store:
|
|
1029
|
-
session:
|
|
1068
|
+
store: oe(),
|
|
1069
|
+
session: te(),
|
|
1030
1070
|
cache: (() => {
|
|
1031
1071
|
if (globalThis.cache) try {
|
|
1032
1072
|
return "function" == typeof globalThis.cache.list ? globalThis.cache.list() : globalThis.cache;
|
|
@@ -1040,25 +1080,36 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "devt
|
|
|
1040
1080
|
},
|
|
1041
1081
|
importData: e => {
|
|
1042
1082
|
try {
|
|
1043
|
-
const
|
|
1044
|
-
|
|
1045
|
-
globalThis.state && "list" !== e && "remove" !== e && "removeAll" !== e && (globalThis.state[e] =
|
|
1046
|
-
}),
|
|
1047
|
-
globalThis.store.set(e,
|
|
1048
|
-
}),
|
|
1049
|
-
globalThis.session.set(e,
|
|
1050
|
-
}),
|
|
1051
|
-
globalThis.cache && "get" !== e && "set" !== e && "remove" !== e && "clear" !== e && (globalThis.cache[e] =
|
|
1083
|
+
const o = JSON.parse(e);
|
|
1084
|
+
o.state && Object.entries(o.state).forEach(([e, o]) => {
|
|
1085
|
+
globalThis.state && "list" !== e && "remove" !== e && "removeAll" !== e && (globalThis.state[e] = o);
|
|
1086
|
+
}), o.store && globalThis.store && "function" == typeof globalThis.store.set && Object.entries(o.store).forEach(([e, o]) => {
|
|
1087
|
+
globalThis.store.set(e, o);
|
|
1088
|
+
}), o.session && globalThis.session && "function" == typeof globalThis.session.set && Object.entries(o.session).forEach(([e, o]) => {
|
|
1089
|
+
globalThis.session.set(e, o);
|
|
1090
|
+
}), o.cache && globalThis.cache && Object.entries(o.cache).forEach(([e, o]) => {
|
|
1091
|
+
globalThis.cache && "get" !== e && "set" !== e && "remove" !== e && "clear" !== e && (globalThis.cache[e] = o);
|
|
1052
1092
|
});
|
|
1053
1093
|
} catch (e) {
|
|
1054
1094
|
console.error("%cā Import failed:", "color: #F44336", e);
|
|
1055
1095
|
}
|
|
1056
1096
|
},
|
|
1097
|
+
watch: (e, o) => {
|
|
1098
|
+
if (!globalThis[e]) return void console.error(`Module ${e} not found`);
|
|
1099
|
+
const t = globalThis[e], r = t[o];
|
|
1100
|
+
if (console.log(`š Watching ${e}.${o} (initial: ${JSON.stringify(r)})`), "state" === e && globalThis.memorio?.dispatch) {
|
|
1101
|
+
const r = t => {
|
|
1102
|
+
const r = t.detail;
|
|
1103
|
+
r?.name?.includes(o) && console.log(`š Change: ${e}.${o} =`, t.detail.value);
|
|
1104
|
+
};
|
|
1105
|
+
t.addEventListener?.("memorio-change", r);
|
|
1106
|
+
}
|
|
1107
|
+
},
|
|
1057
1108
|
help: () => {
|
|
1058
|
-
console.log("\nš§ Memorio DevTools Help\n\nAvailable commands:\n memorio.devtools.inspect() - Inspect all state modules\n memorio.devtools.stats() - Show statistics\n memorio.devtools.clear('module') - Clear specific module\n memorio.devtools.clearAll() - Clear all modules\n memorio.devtools.exportData() - Export all data as JSON\n memorio.devtools.importData(json) - Import data from JSON\n memorio.devtools.help() - Show this help\n\nShortcuts:\n state - globalThis.state\n store - globalThis.store\n session - globalThis.session\n cache - globalThis.cache\n");
|
|
1109
|
+
console.log("\nš§ Memorio DevTools Help\n\nAvailable commands:\n memorio.devtools.inspect() - Inspect all state modules\n memorio.devtools.stats() - Show statistics\n memorio.devtools.clear('module') - Clear specific module\n memorio.devtools.clearAll() - Clear all modules\n memorio.devtools.exportData() - Export all data as JSON\n memorio.devtools.importData(json) - Import data from JSON\n memorio.devtools.watch(module, path) - Watch a path for changes\n memorio.devtools.help() - Show this help\n\nShortcuts:\n state - globalThis.state\n store - globalThis.store\n session - globalThis.session\n cache - globalThis.cache\n");
|
|
1059
1110
|
}
|
|
1060
1111
|
}
|
|
1061
|
-
}),
|
|
1112
|
+
}), re = "devtools", !1 === ee || ee && "object" == typeof ee && !1 === ee[re] || (Object.defineProperty(globalThis, "$state", {
|
|
1062
1113
|
get: () => globalThis.state,
|
|
1063
1114
|
configurable: !0
|
|
1064
1115
|
}), Object.defineProperty(globalThis, "$store", {
|
|
@@ -1072,12 +1123,12 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "devt
|
|
|
1072
1123
|
configurable: !0
|
|
1073
1124
|
}));
|
|
1074
1125
|
|
|
1075
|
-
var
|
|
1126
|
+
var ne = {
|
|
1076
1127
|
enabled: !0,
|
|
1077
1128
|
logToConsole: !0,
|
|
1078
1129
|
modules: [ "state", "store", "session", "cache", "idb" ],
|
|
1079
1130
|
maxEntries: 1e3
|
|
1080
|
-
},
|
|
1131
|
+
}, ie = [], ae = e => ne.enabled && ne.modules.includes(e), le = e => ({
|
|
1081
1132
|
state: "#4CAF50",
|
|
1082
1133
|
store: "#2196F3",
|
|
1083
1134
|
session: "#FF9800",
|
|
@@ -1090,42 +1141,42 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "logg
|
|
|
1090
1141
|
configurable: !0,
|
|
1091
1142
|
value: {
|
|
1092
1143
|
configure: e => {
|
|
1093
|
-
|
|
1094
|
-
...
|
|
1144
|
+
ne = {
|
|
1145
|
+
...ne,
|
|
1095
1146
|
...e
|
|
1096
1147
|
};
|
|
1097
1148
|
},
|
|
1098
1149
|
enable: () => {
|
|
1099
|
-
|
|
1150
|
+
ne.enabled = !0;
|
|
1100
1151
|
},
|
|
1101
1152
|
disable: () => {
|
|
1102
|
-
|
|
1153
|
+
ne.enabled = !1;
|
|
1103
1154
|
},
|
|
1104
|
-
isEnabled:
|
|
1105
|
-
log: (e,
|
|
1106
|
-
if (!
|
|
1107
|
-
const
|
|
1155
|
+
isEnabled: ae,
|
|
1156
|
+
log: (e, o, t, r, s) => {
|
|
1157
|
+
if (!ae(e)) return;
|
|
1158
|
+
const n = {
|
|
1108
1159
|
timestamp: (new Date).toISOString(),
|
|
1109
1160
|
module: e,
|
|
1110
|
-
action:
|
|
1111
|
-
path:
|
|
1161
|
+
action: o,
|
|
1162
|
+
path: t,
|
|
1112
1163
|
value: r,
|
|
1113
1164
|
previousValue: s
|
|
1114
1165
|
};
|
|
1115
|
-
if (
|
|
1116
|
-
const
|
|
1117
|
-
memorio.message(`%c${
|
|
1166
|
+
if (ie.push(n), ie.length > ne.maxEntries && ie.shift(), ne.logToConsole && !0 === globalThis.memorio?.debug) {
|
|
1167
|
+
const n = `[Memorio:${e.toUpperCase()}]`, i = le(e);
|
|
1168
|
+
memorio.message(`%c${n}%c ${o} ${t},\n color: ${i}; font-weight: bold,\n color: inherit`),
|
|
1118
1169
|
void 0 !== r && memorio.message(` ā value:${r}`), void 0 !== s && memorio.message(` ā previous:${s}`);
|
|
1119
1170
|
}
|
|
1120
|
-
|
|
1171
|
+
ne.customHandler && ne.customHandler(n);
|
|
1121
1172
|
},
|
|
1122
|
-
getHistory: () => [ ...
|
|
1173
|
+
getHistory: () => [ ...ie ],
|
|
1123
1174
|
clearHistory: () => {
|
|
1124
|
-
|
|
1175
|
+
ie.length = 0;
|
|
1125
1176
|
},
|
|
1126
1177
|
getStats: () => {
|
|
1127
1178
|
const e = {
|
|
1128
|
-
total:
|
|
1179
|
+
total: ie.length,
|
|
1129
1180
|
state: 0,
|
|
1130
1181
|
store: 0,
|
|
1131
1182
|
session: 0,
|
|
@@ -1136,12 +1187,12 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "logg
|
|
|
1136
1187
|
delete: 0,
|
|
1137
1188
|
clear: 0
|
|
1138
1189
|
};
|
|
1139
|
-
for (const
|
|
1140
|
-
const
|
|
1141
|
-
|
|
1190
|
+
for (const o of ie) if (o) {
|
|
1191
|
+
const t = o.module, r = o.action;
|
|
1192
|
+
t && "number" == typeof e[t] && e[t]++, r && "number" == typeof e[r] && e[r]++;
|
|
1142
1193
|
}
|
|
1143
1194
|
return e;
|
|
1144
1195
|
},
|
|
1145
|
-
exportLogs: () => JSON.stringify(
|
|
1196
|
+
exportLogs: () => JSON.stringify(ie, null, 2)
|
|
1146
1197
|
}
|
|
1147
1198
|
});
|