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