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