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