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