memorio 2.6.6 → 2.7.1
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 +57 -0
- package/examples/basic.ts +41 -1
- package/examples/browser-vanilla.html +358 -0
- package/examples/node-server.ts +308 -0
- package/examples/platform.ts +115 -0
- package/examples/react-app.tsx +357 -0
- package/examples/session-advanced.ts +13 -0
- package/examples/store-advanced.ts +13 -0
- package/index.cjs +333 -119
- package/index.js +331 -119
- package/package.json +17 -12
- package/types/memorio.d.ts +22 -0
- package/types/session.d.ts +7 -6
- package/types/state.d.ts +1 -6
- package/types/store.d.ts +6 -7
package/index.cjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
1
3
|
var e = Object.getOwnPropertyNames, t = (t, o) => function() {
|
|
2
4
|
return t && (o = (0, t[e(t)[0]])(t = 0)), o;
|
|
3
5
|
}, o = {}, r = t({
|
|
@@ -12,7 +14,7 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
|
|
|
12
14
|
}, s.onupgradeneeded = () => {};
|
|
13
15
|
});
|
|
14
16
|
}
|
|
15
|
-
}), s = {},
|
|
17
|
+
}), s = {}, n = t({
|
|
16
18
|
"functions/idb/tools/db.list.ts"() {
|
|
17
19
|
idb.db.list = async () => {
|
|
18
20
|
if (!("indexedDB" in globalThis) || !indexedDB.databases) return [];
|
|
@@ -24,11 +26,11 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
|
|
|
24
26
|
}
|
|
25
27
|
}, idb.db.list();
|
|
26
28
|
}
|
|
27
|
-
}),
|
|
29
|
+
}), i = {}, a = t({
|
|
28
30
|
"functions/idb/tools/db.exist.ts"() {
|
|
29
31
|
idb.db.exist = e => idbases?.some(t => t.name === e);
|
|
30
32
|
}
|
|
31
|
-
}),
|
|
33
|
+
}), l = {}, c = t({
|
|
32
34
|
"functions/idb/tools/db.quota.ts"() {
|
|
33
35
|
idb.db.quota = () => navigator.storage.estimate();
|
|
34
36
|
}
|
|
@@ -45,7 +47,7 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
|
|
|
45
47
|
})() : t();
|
|
46
48
|
});
|
|
47
49
|
}
|
|
48
|
-
}), d = {},
|
|
50
|
+
}), d = {}, f = t({
|
|
49
51
|
"functions/idb/tools/db.size.ts"() {
|
|
50
52
|
idb.db.size = async () => {
|
|
51
53
|
if (idbases && 0 !== idbases.length) for (let e = 0; e < idbases.length; e++) {
|
|
@@ -61,7 +63,7 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
|
|
|
61
63
|
}
|
|
62
64
|
};
|
|
63
65
|
}
|
|
64
|
-
}),
|
|
66
|
+
}), m = {}, g = t({
|
|
65
67
|
"functions/idb/tools/db.version.ts"() {
|
|
66
68
|
idb.db.version = e => {
|
|
67
69
|
let t = 0;
|
|
@@ -72,19 +74,19 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
|
|
|
72
74
|
return t;
|
|
73
75
|
};
|
|
74
76
|
}
|
|
75
|
-
}),
|
|
77
|
+
}), h = {}, p = t({
|
|
76
78
|
"functions/idb/tools/db.support.ts"() {
|
|
77
79
|
idb.db.support = () => {
|
|
78
80
|
const e = "indexedDB" in globalThis;
|
|
79
81
|
return e;
|
|
80
82
|
};
|
|
81
83
|
}
|
|
82
|
-
}),
|
|
84
|
+
}), v = {}, y = t({
|
|
83
85
|
"functions/idb/tools/table.create.ts"() {
|
|
84
86
|
idb.table.create = (e, t) => new Promise(async (o, r) => {
|
|
85
87
|
try {
|
|
86
|
-
const s = (Number(idb.db.version(e)) || 0) + 1,
|
|
87
|
-
|
|
88
|
+
const s = (Number(idb.db.version(e)) || 0) + 1, n = indexedDB.open(e, s);
|
|
89
|
+
n.onupgradeneeded = e => {
|
|
88
90
|
const o = e.target.result;
|
|
89
91
|
if (!o.objectStoreNames.contains(t)) {
|
|
90
92
|
const e = o.createObjectStore(t, {
|
|
@@ -97,103 +99,207 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
|
|
|
97
99
|
unique: !1
|
|
98
100
|
});
|
|
99
101
|
}
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
},
|
|
103
|
-
r(
|
|
102
|
+
}, n.onsuccess = () => {
|
|
103
|
+
n.result.close(), idb.db.list(), o();
|
|
104
|
+
}, n.onerror = () => {
|
|
105
|
+
r(n.error);
|
|
104
106
|
};
|
|
105
107
|
} catch (e) {
|
|
106
108
|
r(e);
|
|
107
109
|
}
|
|
108
110
|
});
|
|
109
111
|
}
|
|
110
|
-
}),
|
|
112
|
+
}), T = {}, j = t({
|
|
111
113
|
"functions/idb/tools/table.size.ts"() {
|
|
112
114
|
idb.table.size = (e, t) => new Promise((o, r) => {
|
|
113
115
|
if (!e) return r(new Error("Database instance is required"));
|
|
114
116
|
if (!e.objectStoreNames.contains(t)) return o(0);
|
|
115
|
-
let s = 0,
|
|
116
|
-
const
|
|
117
|
-
|
|
117
|
+
let s = 0, n = 0;
|
|
118
|
+
const i = e.transaction([ t ], "readonly").objectStore(t).openCursor();
|
|
119
|
+
i.onsuccess = async e => {
|
|
118
120
|
const t = e.target.result;
|
|
119
121
|
if (t) {
|
|
120
122
|
try {
|
|
121
123
|
const e = t.value;
|
|
122
124
|
s += JSON.stringify(e).length;
|
|
123
125
|
} catch (e) {}
|
|
124
|
-
|
|
126
|
+
n++, n % 200 == 0 && await new Promise(e => setTimeout(e, 0)), t.continue();
|
|
125
127
|
} else o(s);
|
|
126
|
-
},
|
|
127
|
-
r(
|
|
128
|
+
}, i.onerror = () => {
|
|
129
|
+
r(i.error);
|
|
128
130
|
};
|
|
129
131
|
});
|
|
130
132
|
}
|
|
131
|
-
}),
|
|
133
|
+
}), O = {}, P = t({
|
|
132
134
|
"functions/idb/crud/data.delete.ts"() {
|
|
133
135
|
idb.data.delete = (e, t, o) => new Promise((r, s) => {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
const e =
|
|
136
|
+
const n = indexedDB.open(e);
|
|
137
|
+
n.onsuccess = () => {
|
|
138
|
+
const e = n.result;
|
|
137
139
|
if (!e.objectStoreNames.contains(t)) return e.close(), s(new Error(`Table ${t} not found`));
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
+
const i = e.transaction(t, "readwrite").objectStore(t).delete(o);
|
|
141
|
+
i.onsuccess = () => {
|
|
140
142
|
e.close(), r();
|
|
141
|
-
},
|
|
142
|
-
e.close(), s(
|
|
143
|
+
}, i.onerror = () => {
|
|
144
|
+
e.close(), s(i.error);
|
|
143
145
|
};
|
|
144
|
-
},
|
|
146
|
+
}, n.onerror = () => s(n.error);
|
|
145
147
|
}), idb.data.delete.all = (e, t) => new Promise((o, r) => {
|
|
146
148
|
const s = indexedDB.open(e);
|
|
147
149
|
s.onsuccess = e => {
|
|
148
150
|
const s = e.target.result;
|
|
149
151
|
if (!s.objectStoreNames.contains(t)) return s.close(), r(new Error(`Table ${t} not found`));
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
+
const n = s.transaction(t, "readwrite").objectStore(t).clear();
|
|
153
|
+
n.onsuccess = () => {
|
|
152
154
|
s.close(), o();
|
|
153
|
-
},
|
|
154
|
-
s.close(), r(
|
|
155
|
+
}, n.onerror = () => {
|
|
156
|
+
s.close(), r(n.error);
|
|
155
157
|
};
|
|
156
158
|
}, s.onerror = () => r(s.error);
|
|
157
159
|
});
|
|
158
160
|
}
|
|
159
|
-
}), w = {},
|
|
161
|
+
}), w = {}, _ = t({
|
|
160
162
|
"functions/idb/crud/data.set.ts"() {
|
|
161
163
|
idb.data.set = (e, t, o) => new Promise((r, s) => {
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
if (!
|
|
166
|
-
const a =
|
|
164
|
+
const n = indexedDB.open(e);
|
|
165
|
+
n.onsuccess = () => {
|
|
166
|
+
const i = n.result;
|
|
167
|
+
if (!i.objectStoreNames.contains(t)) return i.close(), s(new Error(`Table ${t} does not exist in ${e}`));
|
|
168
|
+
const a = i.transaction(t, "readwrite").objectStore(t).put(o);
|
|
167
169
|
a.onsuccess = () => {
|
|
168
|
-
|
|
170
|
+
i.close(), r(a.result);
|
|
169
171
|
}, a.onerror = e => {
|
|
170
|
-
|
|
172
|
+
i.close(), s(a.error);
|
|
171
173
|
};
|
|
172
|
-
},
|
|
173
|
-
s(
|
|
174
|
+
}, n.onerror = () => {
|
|
175
|
+
s(n.error);
|
|
174
176
|
};
|
|
175
177
|
});
|
|
176
178
|
}
|
|
177
|
-
}),
|
|
179
|
+
}), S = {}, k = t({
|
|
178
180
|
"functions/idb/crud/data.get.ts"() {
|
|
179
181
|
idb.data.get = (e, t, o) => new Promise((r, s) => {
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
if (!
|
|
184
|
-
const a =
|
|
182
|
+
const n = indexedDB.open(e);
|
|
183
|
+
n.onsuccess = n => {
|
|
184
|
+
const i = n.target.result;
|
|
185
|
+
if (!i.objectStoreNames.contains(t)) return i.close(), s(new Error(`Table ${t} not found in ${e}`));
|
|
186
|
+
const a = i.transaction(t, "readonly").objectStore(t).get(o);
|
|
185
187
|
a.onsuccess = () => {
|
|
186
|
-
|
|
188
|
+
i.close(), r(a.result);
|
|
187
189
|
}, a.onerror = () => {
|
|
188
|
-
|
|
190
|
+
i.close(), s(a.error);
|
|
189
191
|
};
|
|
190
|
-
},
|
|
191
|
-
s(
|
|
192
|
+
}, n.onerror = () => {
|
|
193
|
+
s(n.error);
|
|
192
194
|
};
|
|
193
195
|
});
|
|
194
196
|
}
|
|
195
197
|
});
|
|
196
198
|
|
|
199
|
+
function x() {
|
|
200
|
+
const e = globalThis;
|
|
201
|
+
if (void 0 !== e.crypto && e.crypto.randomUUID) return e.crypto.randomUUID();
|
|
202
|
+
if (void 0 !== e.crypto && e.crypto.getRandomValues) {
|
|
203
|
+
const t = new Uint8Array(16);
|
|
204
|
+
return e.crypto.getRandomValues(t), Array.from(t, e => e.toString(16).padStart(2, "0")).join("");
|
|
205
|
+
}
|
|
206
|
+
return `session_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function N() {
|
|
210
|
+
try {
|
|
211
|
+
if ("undefined" != typeof sessionStorage) {
|
|
212
|
+
const e = "__memorio_test__";
|
|
213
|
+
return sessionStorage.setItem(e, "1"), sessionStorage.removeItem(e), sessionStorage;
|
|
214
|
+
}
|
|
215
|
+
} catch (e) {}
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function E() {
|
|
220
|
+
try {
|
|
221
|
+
if ("undefined" != typeof localStorage) {
|
|
222
|
+
const e = "__memorio_test__";
|
|
223
|
+
return localStorage.setItem(e, "1"), localStorage.removeItem(e), localStorage;
|
|
224
|
+
}
|
|
225
|
+
} catch (e) {}
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function I() {
|
|
230
|
+
return "undefined" != typeof indexedDB;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function D() {
|
|
234
|
+
const e = function() {
|
|
235
|
+
const e = globalThis;
|
|
236
|
+
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";
|
|
237
|
+
}(), t = void 0 !== globalThis.isSecureContext ? globalThis.isSecureContext : "browser" === e;
|
|
238
|
+
return {
|
|
239
|
+
platform: e,
|
|
240
|
+
hasSessionStorage: null !== N(),
|
|
241
|
+
hasLocalStorage: null !== E(),
|
|
242
|
+
hasIndexedDB: I(),
|
|
243
|
+
hasDispatchEvent: "function" == typeof globalThis.dispatchEvent,
|
|
244
|
+
hasNavigator: "undefined" != typeof navigator,
|
|
245
|
+
hasProcess: "undefined" != typeof process,
|
|
246
|
+
isSecureContext: t,
|
|
247
|
+
sessionId: x()
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
var A = new Map;
|
|
252
|
+
|
|
253
|
+
var z = new Map;
|
|
254
|
+
|
|
255
|
+
function J(e) {
|
|
256
|
+
const t = e || `context_${x()}`, o = {
|
|
257
|
+
state: {},
|
|
258
|
+
store: new Map,
|
|
259
|
+
session: new Map,
|
|
260
|
+
cache: new Map
|
|
261
|
+
};
|
|
262
|
+
return z.set(t, o), {
|
|
263
|
+
id: t,
|
|
264
|
+
state: o.state,
|
|
265
|
+
store: {
|
|
266
|
+
get: e => {
|
|
267
|
+
const t = o.store.get(e);
|
|
268
|
+
return t ? JSON.parse(t) : null;
|
|
269
|
+
},
|
|
270
|
+
set: (e, t) => {
|
|
271
|
+
o.store.set(e, JSON.stringify(t));
|
|
272
|
+
},
|
|
273
|
+
remove: e => o.store.delete(e),
|
|
274
|
+
removeAll: () => o.store.clear(),
|
|
275
|
+
clearAll: () => o.store.clear(),
|
|
276
|
+
size: () => o.store.size,
|
|
277
|
+
isPersistent: !1
|
|
278
|
+
},
|
|
279
|
+
session: {
|
|
280
|
+
get: e => {
|
|
281
|
+
const t = o.session.get(e);
|
|
282
|
+
return t ? JSON.parse(t) : null;
|
|
283
|
+
},
|
|
284
|
+
set: (e, t) => {
|
|
285
|
+
o.session.set(e, JSON.stringify(t));
|
|
286
|
+
},
|
|
287
|
+
remove: e => o.session.delete(e),
|
|
288
|
+
removeAll: () => o.session.clear(),
|
|
289
|
+
clearAll: () => o.session.clear(),
|
|
290
|
+
size: () => o.session.size,
|
|
291
|
+
isPersistent: !1
|
|
292
|
+
},
|
|
293
|
+
cache: {
|
|
294
|
+
get: e => o.cache.get(e),
|
|
295
|
+
set: (e, t) => o.cache.set(e, t),
|
|
296
|
+
remove: e => o.cache.delete(e),
|
|
297
|
+
removeAll: () => o.cache.clear(),
|
|
298
|
+
clear: () => o.cache.clear()
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
197
303
|
Object.defineProperty(globalThis, "memorio", {
|
|
198
304
|
value: {},
|
|
199
305
|
writable: !1,
|
|
@@ -206,12 +312,53 @@ Object.defineProperty(globalThis, "memorio", {
|
|
|
206
312
|
}), Object.defineProperty(memorio, "version", {
|
|
207
313
|
writable: !1,
|
|
208
314
|
enumerable: !1,
|
|
209
|
-
value: "2.
|
|
315
|
+
value: "2.7.1"
|
|
210
316
|
});
|
|
211
317
|
|
|
212
|
-
var
|
|
318
|
+
var B = [ "list", "state", "store", "idb", "observer", "useObserver", "remove", "removeAll", "_platform", "_capabilities", "_sessionId" ];
|
|
319
|
+
|
|
320
|
+
!function() {
|
|
321
|
+
const e = D(), t = globalThis;
|
|
322
|
+
void 0 !== t.memorio && (t.memorio._platform = e.platform, t.memorio._capabilities = e),
|
|
323
|
+
e.hasDispatchEvent || (t.dispatchEvent = function(e) {
|
|
324
|
+
return !0;
|
|
325
|
+
}, "undefined" == typeof CustomEvent && (t.CustomEvent = class {
|
|
326
|
+
type;
|
|
327
|
+
detail;
|
|
328
|
+
constructor(e, t = {}) {
|
|
329
|
+
this.type = e, this.detail = t;
|
|
330
|
+
}
|
|
331
|
+
})), "function" != typeof t.addEventListener && (t.addEventListener = function(e, t) {
|
|
332
|
+
A.has(e) || A.set(e, []), A.get(e).push(t);
|
|
333
|
+
}, t.removeEventListener = function(e, t) {
|
|
334
|
+
const o = A.get(e);
|
|
335
|
+
if (o) {
|
|
336
|
+
const e = o.indexOf(t);
|
|
337
|
+
e > -1 && o.splice(e, 1);
|
|
338
|
+
}
|
|
339
|
+
}, t.dispatchEvent = function(e) {
|
|
340
|
+
const t = A.get(e.type);
|
|
341
|
+
return t && t.forEach(t => {
|
|
342
|
+
try {
|
|
343
|
+
t(e);
|
|
344
|
+
} catch (e) {}
|
|
345
|
+
}), !0;
|
|
346
|
+
});
|
|
347
|
+
}();
|
|
348
|
+
|
|
349
|
+
var $ = D();
|
|
213
350
|
|
|
214
|
-
Object.defineProperty(memorio, "
|
|
351
|
+
Object.defineProperty(memorio, "_sessionId", {
|
|
352
|
+
writable: !1,
|
|
353
|
+
enumerable: !1,
|
|
354
|
+
value: $.sessionId
|
|
355
|
+
}), memorio.createContext = J, memorio.listContexts = function() {
|
|
356
|
+
return Array.from(z.keys());
|
|
357
|
+
}, memorio.deleteContext = function(e) {
|
|
358
|
+
return z.delete(e);
|
|
359
|
+
}, memorio.isolate = function(e) {
|
|
360
|
+
return J(e);
|
|
361
|
+
}, Object.defineProperty(memorio, "dispatch", {
|
|
215
362
|
writable: !1,
|
|
216
363
|
enumerable: !1,
|
|
217
364
|
value: {
|
|
@@ -239,7 +386,7 @@ Object.defineProperty(memorio, "dispatch", {
|
|
|
239
386
|
}), globalThis.memorio._tracking = !1, globalThis.memorio._trackedPaths = new Set,
|
|
240
387
|
globalThis.memorio._locked = !1;
|
|
241
388
|
|
|
242
|
-
var
|
|
389
|
+
var C = (e, t, o = []) => new Proxy(e, {
|
|
243
390
|
get(e, r) {
|
|
244
391
|
if ("__path" === r) return o.length > 0 ? "state." + o.join(".") : "state";
|
|
245
392
|
if ("list" === r) return JSON.parse(JSON.stringify(globalThis.state));
|
|
@@ -261,21 +408,21 @@ var N = (e, t, o = []) => new Proxy(e, {
|
|
|
261
408
|
}
|
|
262
409
|
try {
|
|
263
410
|
const s = Reflect.get(e, r);
|
|
264
|
-
return s && "object" == typeof s && [ "Array", "Object" ].includes(s.constructor.name) ?
|
|
411
|
+
return s && "object" == typeof s && [ "Array", "Object" ].includes(s.constructor.name) ? C(s, t, o.concat(r)) : s;
|
|
265
412
|
} catch (e) {
|
|
266
413
|
return;
|
|
267
414
|
}
|
|
268
415
|
},
|
|
269
416
|
set(e, r, s) {
|
|
270
417
|
if (globalThis.memorio._locked) return !1;
|
|
271
|
-
if (
|
|
418
|
+
if (B.includes(r)) return !1;
|
|
272
419
|
if (e[r] && "object" == typeof e[r] && Object.isFrozen(e[r])) return !1;
|
|
273
420
|
if (e[r] && "object" == typeof e[r] && e[r].__locked) return !1;
|
|
274
421
|
try {
|
|
275
|
-
const
|
|
422
|
+
const n = globalThis.memorio.objPath?.(r, o) ?? r;
|
|
276
423
|
if (t({
|
|
277
424
|
action: "set",
|
|
278
|
-
path:
|
|
425
|
+
path: n,
|
|
279
426
|
target: e,
|
|
280
427
|
newValue: s,
|
|
281
428
|
previousValue: Reflect.get(e, r)
|
|
@@ -287,7 +434,7 @@ var N = (e, t, o = []) => new Proxy(e, {
|
|
|
287
434
|
}
|
|
288
435
|
});
|
|
289
436
|
} catch (e) {}
|
|
290
|
-
})("state." +
|
|
437
|
+
})("state." + n), Reflect.set(e, r, s), e[r] && "object" == typeof e[r]) {
|
|
291
438
|
const t = e[r];
|
|
292
439
|
if (t && "object" == typeof t) try {
|
|
293
440
|
Object.defineProperty(t, "__locked", {
|
|
@@ -343,7 +490,7 @@ var N = (e, t, o = []) => new Proxy(e, {
|
|
|
343
490
|
getOwnPropertyDescriptor: (e, t) => Reflect.getOwnPropertyDescriptor(e, t)
|
|
344
491
|
});
|
|
345
492
|
|
|
346
|
-
globalThis?.state ? globalThis.state = state : globalThis.state =
|
|
493
|
+
globalThis?.state ? globalThis.state = state : globalThis.state = C({}, () => {}),
|
|
347
494
|
globalThis.state.lock = () => {
|
|
348
495
|
globalThis.memorio._locked = !0;
|
|
349
496
|
}, globalThis.state.unlock = () => {
|
|
@@ -434,128 +581,179 @@ Object.defineProperty(globalThis, "useObserver", {
|
|
|
434
581
|
} catch (e) {
|
|
435
582
|
return () => {};
|
|
436
583
|
}
|
|
437
|
-
}, Object.freeze(globalThis.useObserver)
|
|
584
|
+
}, Object.freeze(globalThis.useObserver);
|
|
585
|
+
|
|
586
|
+
var R = E(), M = new Map, q = null !== R, W = `memorio_store_${globalThis.memorio?._sessionId || "default"}_`;
|
|
587
|
+
|
|
588
|
+
function L(e) {
|
|
589
|
+
return e && "string" == typeof e ? e.length > 512 ? "" : /^[a-zA-Z0-9_.-]+$/.test(e) ? W + e : "" : "";
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
Object.defineProperty(globalThis, "store", {
|
|
438
593
|
value: new Proxy({}, {}),
|
|
439
594
|
enumerable: !1,
|
|
440
595
|
configurable: !0
|
|
441
596
|
}), Object.defineProperties(store, {
|
|
442
597
|
get: {
|
|
443
598
|
value: e => {
|
|
444
|
-
if (e)
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
599
|
+
if (!e) return;
|
|
600
|
+
const t = L(e);
|
|
601
|
+
try {
|
|
602
|
+
if (q) {
|
|
603
|
+
const e = R.getItem(t);
|
|
604
|
+
return e ? JSON.parse(e) : e;
|
|
605
|
+
}
|
|
606
|
+
{
|
|
607
|
+
const e = M.get(t);
|
|
608
|
+
return e ? JSON.parse(e) : e;
|
|
609
|
+
}
|
|
610
|
+
} catch (e) {}
|
|
611
|
+
return null;
|
|
451
612
|
}
|
|
452
613
|
},
|
|
453
614
|
set: {
|
|
454
615
|
value: (e, t) => {
|
|
455
|
-
if (e)
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
616
|
+
if (!e) return;
|
|
617
|
+
const o = L(e);
|
|
618
|
+
try {
|
|
619
|
+
q ? null == t ? R.setItem(o, JSON.stringify(null)) : "object" != typeof t && "number" != typeof t && "boolean" != typeof t && "string" != typeof t || R.setItem(o, JSON.stringify(t)) : null == t ? M.set(o, JSON.stringify(null)) : "object" != typeof t && "number" != typeof t && "boolean" != typeof t && "string" != typeof t || M.set(o, JSON.stringify(t));
|
|
620
|
+
} catch (e) {}
|
|
621
|
+
return null;
|
|
461
622
|
}
|
|
462
623
|
},
|
|
463
624
|
remove: {
|
|
464
625
|
value: e => {
|
|
465
|
-
if (e) return
|
|
466
|
-
|
|
626
|
+
if (!e) return;
|
|
627
|
+
const t = L(e);
|
|
628
|
+
try {
|
|
629
|
+
if (q) {
|
|
630
|
+
if (R.getItem(t)) return R.removeItem(t), !0;
|
|
631
|
+
} else if (M.has(t)) return M.delete(t), !0;
|
|
632
|
+
} catch (e) {}
|
|
633
|
+
return !1;
|
|
467
634
|
}
|
|
468
635
|
},
|
|
469
636
|
delete: {
|
|
470
637
|
value: e => (store.remove(e), !0)
|
|
471
638
|
},
|
|
472
639
|
removeAll: {
|
|
473
|
-
value: () => (
|
|
640
|
+
value: () => (q ? R.clear() : M.clear(), !0)
|
|
474
641
|
},
|
|
475
642
|
clearAll: {
|
|
476
643
|
value: () => (store.removeAll(), !0)
|
|
477
644
|
},
|
|
478
645
|
quota: {
|
|
479
|
-
value: async () =>
|
|
480
|
-
const o = e ?? 0, r = t ?? 0;
|
|
481
|
-
return [ o / 1024, r / 1024 ];
|
|
482
|
-
}).catch(e => [ 0, 0 ]) : [ 0, 0 ]
|
|
646
|
+
value: async () => [ 0, 0 ]
|
|
483
647
|
},
|
|
484
648
|
size: {
|
|
485
649
|
value: () => {
|
|
486
650
|
let e = 0;
|
|
487
|
-
return Object.keys(
|
|
488
|
-
|
|
489
|
-
|
|
651
|
+
return q ? Object.keys(R).forEach(t => {
|
|
652
|
+
if (t.startsWith(W)) {
|
|
653
|
+
const o = R.getItem(t);
|
|
654
|
+
o && (e += o.length);
|
|
655
|
+
}
|
|
656
|
+
}) : M.forEach(t => {
|
|
657
|
+
e += t.length;
|
|
490
658
|
}), e;
|
|
491
659
|
}
|
|
660
|
+
},
|
|
661
|
+
isPersistent: {
|
|
662
|
+
get: () => q
|
|
492
663
|
}
|
|
493
|
-
}), Object.freeze(store)
|
|
664
|
+
}), Object.freeze(store);
|
|
665
|
+
|
|
666
|
+
var U = N(), V = new Map, F = null !== U, K = `memorio_session_${globalThis.memorio?._sessionId || "default"}_`;
|
|
667
|
+
|
|
668
|
+
function Z(e) {
|
|
669
|
+
return e && "string" == typeof e ? e.length > 512 ? "" : /^[a-zA-Z0-9_.-]+$/.test(e) ? K + e : "" : "";
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
Object.defineProperty(globalThis, "session", {
|
|
494
673
|
value: new Proxy({}, {}),
|
|
495
674
|
enumerable: !1,
|
|
496
675
|
configurable: !0
|
|
497
676
|
}), Object.defineProperties(session, {
|
|
498
677
|
get: {
|
|
499
678
|
value: e => {
|
|
500
|
-
if (e)
|
|
501
|
-
|
|
502
|
-
|
|
679
|
+
if (!e) return;
|
|
680
|
+
const t = Z(e);
|
|
681
|
+
try {
|
|
682
|
+
if (F) {
|
|
683
|
+
const e = U.getItem(t);
|
|
684
|
+
return e ? JSON.parse(e) : e;
|
|
685
|
+
}
|
|
686
|
+
{
|
|
687
|
+
const e = V.get(t);
|
|
688
|
+
return e ? JSON.parse(e) : e;
|
|
689
|
+
}
|
|
503
690
|
} catch (e) {}
|
|
504
691
|
}
|
|
505
692
|
},
|
|
506
693
|
set: {
|
|
507
694
|
value: (e, t) => {
|
|
508
|
-
if (e)
|
|
509
|
-
|
|
695
|
+
if (!e) return;
|
|
696
|
+
const o = Z(e);
|
|
697
|
+
try {
|
|
698
|
+
F ? null == t ? U.setItem(o, JSON.stringify(null)) : "object" != typeof t && "number" != typeof t && "boolean" != typeof t && "string" != typeof t || U.setItem(o, JSON.stringify(t)) : null == t ? V.set(o, JSON.stringify(null)) : "object" != typeof t && "number" != typeof t && "boolean" != typeof t && "string" != typeof t || V.set(o, JSON.stringify(t));
|
|
510
699
|
} catch (e) {}
|
|
511
700
|
}
|
|
512
701
|
},
|
|
513
702
|
remove: {
|
|
514
703
|
value: e => {
|
|
515
|
-
if (e) return
|
|
516
|
-
|
|
704
|
+
if (!e) return;
|
|
705
|
+
const t = Z(e);
|
|
706
|
+
try {
|
|
707
|
+
if (F) {
|
|
708
|
+
if (U.getItem(t)) return U.removeItem(t), !0;
|
|
709
|
+
} else if (V.has(t)) return V.delete(t), !0;
|
|
710
|
+
} catch (e) {}
|
|
517
711
|
}
|
|
518
712
|
},
|
|
519
713
|
delete: {
|
|
520
714
|
value: e => (session.remove(e), !0)
|
|
521
715
|
},
|
|
522
716
|
removeAll: {
|
|
523
|
-
value: () => (
|
|
717
|
+
value: () => (F ? U.clear() : V.clear(), !0)
|
|
524
718
|
},
|
|
525
719
|
clearAll: {
|
|
526
720
|
value: () => (session.removeAll(), !0)
|
|
527
721
|
},
|
|
528
722
|
quota: {
|
|
529
|
-
value: async () =>
|
|
530
|
-
const o = e ?? 0, r = t ?? 0;
|
|
531
|
-
return [ o / 1024, r / 1024 ];
|
|
532
|
-
}).catch(e => [ 0, 0 ]) : [ 0, 0 ]
|
|
723
|
+
value: async () => [ 0, 0 ]
|
|
533
724
|
},
|
|
534
725
|
size: {
|
|
535
726
|
value: () => {
|
|
536
727
|
let e = 0;
|
|
537
|
-
return Object.keys(
|
|
538
|
-
|
|
539
|
-
|
|
728
|
+
return F ? Object.keys(U).forEach(t => {
|
|
729
|
+
if (t.startsWith(K)) {
|
|
730
|
+
const o = U.getItem(t);
|
|
731
|
+
o && (e += o.length);
|
|
732
|
+
}
|
|
733
|
+
}) : V.forEach(t => {
|
|
734
|
+
e += t.length;
|
|
540
735
|
}), e;
|
|
541
736
|
}
|
|
737
|
+
},
|
|
738
|
+
isPersistent: {
|
|
739
|
+
get: () => F
|
|
542
740
|
}
|
|
543
741
|
}), Object.freeze(session);
|
|
544
742
|
|
|
545
|
-
var
|
|
743
|
+
var G = {};
|
|
546
744
|
|
|
547
745
|
Object.defineProperty(globalThis, "cache", {
|
|
548
746
|
value: new Proxy({}, {
|
|
549
|
-
get: (e, t) => "get" === t ? e =>
|
|
550
|
-
|
|
551
|
-
} : "remove" === t ? e => (delete
|
|
552
|
-
!0) :
|
|
553
|
-
set: (e, t, o) => (
|
|
554
|
-
deleteProperty: (e, t) => (delete
|
|
747
|
+
get: (e, t) => "get" === t ? e => G[e] : "set" === t ? (e, t) => {
|
|
748
|
+
G[e] = t;
|
|
749
|
+
} : "remove" === t ? e => (delete G[e], !0) : "removeAll" === t || "clear" === t ? () => (Object.keys(G).forEach(e => delete G[e]),
|
|
750
|
+
!0) : G[t],
|
|
751
|
+
set: (e, t, o) => (G[t] = o, !0),
|
|
752
|
+
deleteProperty: (e, t) => (delete G[t], !0)
|
|
555
753
|
}),
|
|
556
754
|
enumerable: !1,
|
|
557
755
|
configurable: !0
|
|
558
|
-
}), Object.freeze(cache), (async () => {
|
|
756
|
+
}), Object.freeze(cache), I() ? (async () => {
|
|
559
757
|
Object.defineProperty(globalThis, "idb", {
|
|
560
758
|
value: {
|
|
561
759
|
db: {},
|
|
@@ -570,12 +768,28 @@ Object.defineProperty(globalThis, "cache", {
|
|
|
570
768
|
writable: !0,
|
|
571
769
|
configurable: !0,
|
|
572
770
|
enumerable: !1
|
|
573
|
-
}), await Promise.all([ Promise.resolve().then(() => (r(), o)), Promise.resolve().then(() => (
|
|
574
|
-
s)), Promise.resolve().then(() => (a(),
|
|
575
|
-
|
|
576
|
-
d)), Promise.resolve().then(() => (
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
w)), Promise.resolve().then(() => (
|
|
771
|
+
}), await Promise.all([ Promise.resolve().then(() => (r(), o)), Promise.resolve().then(() => (n(),
|
|
772
|
+
s)), Promise.resolve().then(() => (a(), i)), Promise.resolve().then(() => (c(),
|
|
773
|
+
l)), Promise.resolve().then(() => (u(), b)), Promise.resolve().then(() => (f(),
|
|
774
|
+
d)), Promise.resolve().then(() => (g(), m)), Promise.resolve().then(() => (p(),
|
|
775
|
+
h)), Promise.resolve().then(() => (y(), v)), Promise.resolve().then(() => (j(),
|
|
776
|
+
T)), Promise.resolve().then(() => (P(), O)), Promise.resolve().then(() => (_(),
|
|
777
|
+
w)), Promise.resolve().then(() => (k(), S)) ]), Object.preventExtensions(idb), Object.seal(idb),
|
|
580
778
|
Object.freeze(idb);
|
|
581
|
-
})()
|
|
779
|
+
})() : (Object.defineProperty(globalThis, "idb", {
|
|
780
|
+
value: {
|
|
781
|
+
db: {},
|
|
782
|
+
table: {},
|
|
783
|
+
data: {},
|
|
784
|
+
_disabled: !0,
|
|
785
|
+
_warning: "IndexedDB is not available in this environment (Node.js/Deno). Use store or session for persistence."
|
|
786
|
+
},
|
|
787
|
+
writable: !0,
|
|
788
|
+
configurable: !0,
|
|
789
|
+
enumerable: !1
|
|
790
|
+
}), Object.defineProperty(globalThis, "idbases", {
|
|
791
|
+
value: [],
|
|
792
|
+
writable: !0,
|
|
793
|
+
configurable: !0,
|
|
794
|
+
enumerable: !1
|
|
795
|
+
}));
|