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