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