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