memorio 4.3.2 → 4.4.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, o = (o, t) => function() {
2
4
  return o && (t = (0, o[e(o)[0]])(o = 0)), t;
3
5
  }, t = {}, r = o({
@@ -88,7 +90,7 @@ var e = Object.getOwnPropertyNames, o = (o, t) => function() {
88
90
  }
89
91
  }), v = {}, y = o({
90
92
  "functions/idb/tools/table.create.ts"() {
91
- idb.table.create = (e, o) => new Promise(async (t, r) => {
93
+ idb.table.create = (e, o) => new Promise((t, r) => {
92
94
  try {
93
95
  const s = (Number(idb.db.version(e)) || 0) + 1, n = indexedDB.open(e, s);
94
96
  n.onupgradeneeded = t => {
@@ -137,7 +139,7 @@ var e = Object.getOwnPropertyNames, o = (o, t) => function() {
137
139
  };
138
140
  });
139
141
  }
140
- }), w = {}, S = o({
142
+ }), w = {}, j = o({
141
143
  "functions/idb/crud/data.delete.ts"() {
142
144
  idb.data.delete = (e, o, t) => new Promise((r, s) => {
143
145
  const n = indexedDB.open(e);
@@ -165,7 +167,7 @@ var e = Object.getOwnPropertyNames, o = (o, t) => function() {
165
167
  }, s.onerror = () => r(s.error);
166
168
  });
167
169
  }
168
- }), j = {}, P = o({
170
+ }), S = {}, P = o({
169
171
  "functions/idb/crud/data.set.ts"() {
170
172
  idb.data.set = (e, o, t) => new Promise((r, s) => {
171
173
  const n = indexedDB.open(e);
@@ -183,7 +185,7 @@ var e = Object.getOwnPropertyNames, o = (o, t) => function() {
183
185
  };
184
186
  });
185
187
  }
186
- }), $ = {}, E = o({
188
+ }), _ = {}, E = o({
187
189
  "functions/idb/crud/data.get.ts"() {
188
190
  idb.data.get = (e, o, t) => new Promise((r, s) => {
189
191
  const n = indexedDB.open(e);
@@ -203,7 +205,7 @@ var e = Object.getOwnPropertyNames, o = (o, t) => function() {
203
205
  }
204
206
  });
205
207
 
206
- function k() {
208
+ function $() {
207
209
  const e = globalThis;
208
210
  if (void 0 !== e.crypto && e.crypto.randomUUID) return e.crypto.randomUUID();
209
211
  if (void 0 !== e.crypto && e.crypto.getRandomValues) {
@@ -213,7 +215,7 @@ function k() {
213
215
  return `session_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
214
216
  }
215
217
 
216
- function _() {
218
+ function k() {
217
219
  const e = globalThis;
218
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";
219
221
  }
@@ -238,31 +240,31 @@ function D() {
238
240
  return null;
239
241
  }
240
242
 
241
- function I() {
243
+ function A() {
242
244
  return "undefined" != typeof indexedDB;
243
245
  }
244
246
 
245
- function N() {
246
- const e = _(), o = void 0 !== globalThis.isSecureContext ? globalThis.isSecureContext : "browser" === e;
247
+ function I() {
248
+ const e = k(), o = void 0 !== globalThis.isSecureContext ? globalThis.isSecureContext : "browser" === e;
247
249
  return {
248
250
  platform: e,
249
251
  hasSessionStorage: null !== x(),
250
252
  hasLocalStorage: null !== D(),
251
- hasIndexedDB: I(),
253
+ hasIndexedDB: A(),
252
254
  hasDispatchEvent: "function" == typeof globalThis.dispatchEvent,
253
255
  hasNavigator: "undefined" != typeof navigator,
254
256
  hasProcess: "undefined" != typeof process,
255
257
  isSecureContext: o,
256
- sessionId: k()
258
+ sessionId: $()
257
259
  };
258
260
  }
259
261
 
260
- var A = new Map;
262
+ var N = new Map;
261
263
 
262
264
  var C = new Map;
263
265
 
264
266
  function J(e) {
265
- const o = e || `context_${k()}`;
267
+ const o = e || `context_${$()}`;
266
268
  !function(e) {
267
269
  const o = globalThis;
268
270
  o.memorio || (o.memorio = {});
@@ -315,7 +317,7 @@ function J(e) {
315
317
  };
316
318
  }
317
319
 
318
- var z = "4.3.2";
320
+ var z = "4.4.0";
319
321
 
320
322
  Object.defineProperty(globalThis, "memorio", {
321
323
  value: {
@@ -349,7 +351,7 @@ Object.defineProperty(globalThis, "memorio", {
349
351
  var B = [ "list", "state", "store", "idb", "observer", "useObserver", "remove", "removeAll", "_platform", "_capabilities", "_sessionId" ];
350
352
 
351
353
  !function() {
352
- const e = N(), o = globalThis;
354
+ const e = I(), o = globalThis;
353
355
  void 0 !== o.memorio && (o.memorio._platform = e.platform, o.memorio._capabilities = e),
354
356
  e.hasDispatchEvent || (o.dispatchEvent = function(e) {
355
357
  return !0;
@@ -360,15 +362,15 @@ var B = [ "list", "state", "store", "idb", "observer", "useObserver", "remove",
360
362
  this.type = e, this.detail = o;
361
363
  }
362
364
  })), "function" != typeof o.addEventListener && (o.addEventListener = function(e, o) {
363
- A.has(e) || A.set(e, []), A.get(e).push(o);
365
+ N.has(e) || N.set(e, []), N.get(e).push(o);
364
366
  }, o.removeEventListener = function(e, o) {
365
- const t = A.get(e);
367
+ const t = N.get(e);
366
368
  if (t) {
367
369
  const e = t.indexOf(o);
368
370
  e > -1 && t.splice(e, 1);
369
371
  }
370
372
  }, o.dispatchEvent = function(e) {
371
- const o = A.get(e.type);
373
+ const o = N.get(e.type);
372
374
  return o && o.forEach(o => {
373
375
  try {
374
376
  o(e);
@@ -379,7 +381,7 @@ var B = [ "list", "state", "store", "idb", "observer", "useObserver", "remove",
379
381
  });
380
382
  }();
381
383
 
382
- var M = N();
384
+ var M = I();
383
385
 
384
386
  Object.defineProperty(memorio, "_sessionId", {
385
387
  writable: !1,
@@ -390,17 +392,17 @@ Object.defineProperty(memorio, "_sessionId", {
390
392
  }, memorio.deleteContext = function(e) {
391
393
  return C.delete(e);
392
394
  }, memorio.isBrowser = function() {
393
- return "browser" === _();
395
+ return "browser" === k();
394
396
  }, memorio.isNode = function() {
395
- return "node" === _();
397
+ return "node" === k();
396
398
  }, memorio.isDeno = function() {
397
- return "deno" === _();
399
+ return "deno" === k();
398
400
  }, memorio.isEdge = function() {
399
- return "edge" === _();
400
- }, memorio.getCapabilities = N, memorio.isolate = function(e) {
401
+ return "edge" === k();
402
+ }, memorio.getCapabilities = I, memorio.isolate = function(e) {
401
403
  return J(e);
402
404
  }, memorio.help = function() {
403
- console.log(`\n🧠 Memorio ${z} - Help\n\nCore Modules:\n state - Reactive state management\n store - Persistent storage (localStorage/Map)\n session - Session storage (sessionStorage/Map)\n cache - In-memory cache\n idb - IndexedDB (browser only)\n\nContext Management:\n memorio.isolate(name) - Create isolated context\n memorio.listContexts() - List all contexts\n memorio.deleteContext(id) - Delete a context\n\nPlatform Detection:\n memorio.isBrowser() - Browser environment\n memorio.isNode() - Node.js environment\n memorio.isDeno() - Deno environment\n memorio.isEdge() - Edge/Worker environment\n memorio.getCapabilities() - Full capabilities object\n\nDevTools:\n memorio.devtools.inspect() - Inspect all modules\n memorio.devtools.stats() - Show statistics\n memorio.devtools.watch() - Watch a path\n memorio.devtools.exportData() - Export as JSON\n memorio.devtools.importData() - Import from JSON\n memorio.devtools.clear() - Clear specific module\n memorio.devtools.clearAll() - Clear all modules\n\nShortcuts:\n state, store, session, cache, idb - direct access to modules\n`);
405
+ console.debug(`\n🧠 Memorio ${z} - Help\n\nCore Modules:\n state - Reactive state management\n store - Persistent storage (localStorage/Map)\n session - Session storage (sessionStorage/Map)\n cache - In-memory cache\n idb - IndexedDB (browser only)\n\nContext Management:\n memorio.isolate(name) - Create isolated context\n memorio.listContexts() - List all contexts\n memorio.deleteContext(id) - Delete a context\n\nPlatform Detection:\n memorio.isBrowser() - Browser environment\n memorio.isNode() - Node.js environment\n memorio.isDeno() - Deno environment\n memorio.isEdge() - Edge/Worker environment\n memorio.getCapabilities() - Full capabilities object\n\nDevTools:\n memorio.devtools.inspect() - Inspect all modules\n memorio.devtools.stats() - Show statistics\n memorio.devtools.watch() - Watch a path\n memorio.devtools.exportData() - Export as JSON\n memorio.devtools.importData() - Import from JSON\n memorio.devtools.clear() - Clear specific module\n memorio.devtools.clearAll() - Clear all modules\n\nShortcuts:\n state, store, session, cache, idb - direct access to modules\n`);
404
406
  }, Object.defineProperty(memorio, "dispatch", {
405
407
  writable: !1,
406
408
  enumerable: !1,
@@ -409,12 +411,13 @@ Object.defineProperty(memorio, "_sessionId", {
409
411
  globalThis.dispatchEvent(new CustomEvent(String(e), o));
410
412
  },
411
413
  listen: (e, o = null) => {
412
- globalThis.observer?.list?.[e]?.length > 0 && globalThis.observer?.remove?.(e);
413
- const t = o ? e => {
414
+ const t = globalThis.observer?.list?.[e];
415
+ t && t.length > 0 && globalThis.observer?.remove?.(e);
416
+ const r = o ? e => {
414
417
  const t = e;
415
418
  return globalThis.queueMicrotask ? globalThis.queueMicrotask(() => o(t)) : Promise.resolve().then(() => o(t));
416
419
  } : void 0;
417
- t && globalThis.addEventListener(e, t), t && (globalThis.events[e] = t);
420
+ r && globalThis.addEventListener(e, r), r && (globalThis.events[e] = r);
418
421
  },
419
422
  remove: e => {
420
423
  const o = globalThis.events?.[e];
@@ -432,17 +435,19 @@ Object.defineProperty(memorio, "_sessionId", {
432
435
  r;
433
436
  }
434
437
  }), globalThis.memorio._tracking = !1, globalThis.memorio._trackedPaths = new Set,
435
- globalThis.memorio._locked = !1;
438
+ globalThis.memorio._locked = !1, globalThis.memorio._lastAccessedPath = "", globalThis.memorio._stateVersion = 0,
439
+ globalThis.memorio._propertyAccessLog = [];
436
440
 
437
- var W = (e, o, t = []) => new Proxy(e, {
441
+ var L = (e, o, t = []) => new Proxy(e, {
438
442
  get(e, r) {
439
443
  if ("__path" === r) return t.length > 0 ? "state." + t.join(".") : "state";
440
444
  if ("list" === r) return memorio.message('Some state could be hidden when you use "state.list". Use "state" to see the complete list '),
441
445
  JSON.parse(JSON.stringify(globalThis.state));
442
- if (globalThis.memorio._tracking && "string" == typeof r) {
446
+ if ("string" == typeof r) {
443
447
  const e = t.length > 0 ? "state." + t.concat(r).join(".") : "state." + r;
444
- globalThis.memorio._trackedPaths?.add(e);
448
+ globalThis.memorio._lastAccessedPath = e, globalThis.memorio._tracking && globalThis.memorio._trackedPaths?.add(e);
445
449
  }
450
+ if ("_lastPath" === r) return globalThis.memorio._lastAccessedPath;
446
451
  if ("remove" === r) return o => (delete e[o], !0);
447
452
  if ("removeAll" === r) return () => {
448
453
  try {
@@ -458,7 +463,12 @@ var W = (e, o, t = []) => new Proxy(e, {
458
463
  }
459
464
  try {
460
465
  const s = Reflect.get(e, r);
461
- return s && "object" == typeof s && [ "Array", "Object" ].includes(s.constructor.name) ? W(s, o, t.concat(r)) : s;
466
+ if (s && "object" == typeof s && [ "Array", "Object" ].includes(s.constructor.name)) return L(s, o, t.concat(r));
467
+ if ("string" == typeof r) {
468
+ const e = t.length > 0 ? "state." + t.concat(r).join(".") : "state." + r;
469
+ globalThis.memorio._lastAccessedPath = e, globalThis.memorio._tracking || globalThis.memorio._propertyAccessLog.push(e);
470
+ }
471
+ return s;
462
472
  } catch (e) {
463
473
  return void console.error("Error: ", e);
464
474
  }
@@ -487,7 +497,8 @@ var W = (e, o, t = []) => new Proxy(e, {
487
497
  }
488
498
  });
489
499
  } catch (e) {}
490
- })("state." + n), Reflect.set(e, r, s), e[r] && "object" == typeof e[r]) {
500
+ })("state." + n), Reflect.set(e, r, s), globalThis.memorio._stateVersion = (globalThis.memorio._stateVersion || 0) + 1,
501
+ e[r] && "object" == typeof e[r]) {
491
502
  const o = e[r];
492
503
  if (o && "object" == typeof o) try {
493
504
  Object.defineProperty(o, "__locked", {
@@ -543,7 +554,7 @@ var W = (e, o, t = []) => new Proxy(e, {
543
554
  getOwnPropertyDescriptor: (e, o) => Reflect.getOwnPropertyDescriptor(e, o)
544
555
  });
545
556
 
546
- globalThis?.state || (globalThis.state = W({}, () => {})), globalThis.state.lock = () => {
557
+ globalThis?.state || (globalThis.state = L({}, () => {})), globalThis.state.lock = () => {
547
558
  globalThis.memorio._locked = !0, memorio.message("State is now locked. All modifications are blocked.");
548
559
  }, globalThis.state.unlock = () => {
549
560
  globalThis.memorio._locked = !1, memorio.message("State is now unlocked. Modifications are allowed.");
@@ -555,28 +566,42 @@ globalThis?.state || (globalThis.state = W({}, () => {})), globalThis.state.lock
555
566
  configurable: !0
556
567
  });
557
568
 
569
+ var W = !1;
570
+
558
571
  globalThis.observer = (e, o = null, t = !0) => {
559
- console.warn('DEPRECATED: "observer" is deprecated and will be removed in future versions. Please use "useObserver" instead.');
560
- try {
561
- if (!(e => "state" === e.split(".")[0] || (console.error(`Observer Error: You need to declare 'state.' or 'store.'. The '${e}' string is incorrect!`),
562
- !1))(e)) return;
563
- } catch (e) {
564
- return void console.error(e);
565
- }
572
+ W || (console.warn('DEPRECATED: "observer" is deprecated and will be removed in future versions. Please use "useObserver" instead.'),
573
+ W = !0);
574
+ const r = e => {
575
+ if ("string" == typeof e) return e;
576
+ if (e && "object" == typeof e && e.__path) return e.__path;
577
+ if ("object" == typeof e && globalThis._propertyAccessLog && globalThis._propertyAccessLog.length > 0) {
578
+ return globalThis._propertyAccessLog[globalThis._propertyAccessLog.length - 1].path || null;
579
+ }
580
+ return null;
581
+ }, s = r(e);
566
582
  if (e || o) if (e || !o) {
583
+ if (s) {
584
+ const e = s.split(".");
585
+ if ("state" !== e[0] && "store" !== e[0]) return void console.error(`Observer Error: You need to declare 'state.' or 'store.'. The '${s}' string is incorrect!`);
586
+ }
567
587
  if (e && !o) {
568
- const o = {
588
+ const o = r(e);
589
+ if (!o) return;
590
+ const t = {
569
591
  detail: {
570
- name: String(e)
592
+ name: String(o)
571
593
  }
572
- }, t = globalThis.observer;
573
- return t?.list?.[e] && globalThis.memorio.dispatch.remove(o), t?.list?.[e] || globalThis.memorio.dispatch.listen(o),
574
- void memorio.message(`called: ${e}`);
594
+ }, s = globalThis.observer;
595
+ return s?.list?.[o] && globalThis.memorio.dispatch.remove(t), void memorio.message(`called: ${o}`);
575
596
  }
576
597
  if (e && o) {
577
- if ("string" != typeof e || "function" != typeof o) return void console.error("Observer Error: name of state need to be a 'string' like 'state.test' and the callback need to be a 'function'");
578
- const r = globalThis.observer;
579
- return r?.list?.[e] && globalThis.memorio.dispatch.remove(e, o, t), void (r?.list?.[e] || globalThis.memorio.dispatch.listen(e, o, t));
598
+ const s = r(e);
599
+ if (!s) return;
600
+ if ("string" != typeof e && (!e || "object" != typeof e)) return void console.error("Observer Error: name of state need to be a 'string' like 'state.test' or a direct state value");
601
+ const n = Array.isArray(o) ? o : [ o ], i = globalThis.observer;
602
+ return i?.list?.[s] && globalThis.memorio.dispatch.remove(s), void n.forEach(e => {
603
+ "function" == typeof e && globalThis.memorio.dispatch.listen(s, e, t);
604
+ });
580
605
  }
581
606
  } 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!");
582
607
  }, Object.defineProperties(globalThis.observer, {
@@ -595,6 +620,12 @@ globalThis.observer = (e, o = null, t = !0) => {
595
620
  e?.remove?.(o);
596
621
  }), !0;
597
622
  }
623
+ },
624
+ has: {
625
+ value: e => {
626
+ const o = globalThis.observer;
627
+ return !!o?.list?.[e];
628
+ }
598
629
  }
599
630
  }), globalThis.useObserver || (globalThis.useObserver = null), Object.defineProperty(globalThis, "useObserver", {
600
631
  value: null,
@@ -613,7 +644,7 @@ globalThis.observer = (e, o = null, t = !0) => {
613
644
  const t = e(globalThis.state, o);
614
645
  t && (r = t);
615
646
  }
616
- } else "object" == typeof o && null !== o ? r = o.__path || ("function" == typeof o.toString && "[object Object]" !== o.toString() ? o.toString() : "") : "string" == typeof o && (o.startsWith("state.") || o.startsWith("store.")) && (r = o);
647
+ } else "object" == typeof o && null !== o && (r = o.__path || ("function" == typeof o.toString && "[object Object]" !== o.toString() ? o.toString() : ""));
617
648
  if (r) {
618
649
  r = r.replace(/^(\(\)\s*=>\s*)/, "").replace(/^globalThis\./, "").replace(/^state\./, "");
619
650
  const o = r.startsWith("store.") || r.startsWith("state.") ? r : "state." + r;
@@ -654,7 +685,7 @@ function F() {
654
685
  return e ? `${e}-` : "memorio_store_";
655
686
  }
656
687
 
657
- function L(e) {
688
+ function V(e) {
658
689
  return e && "string" == typeof e ? e.length > 512 ? (memorio.message("Key too long (max 512 characters)"),
659
690
  "") : /^[a-zA-Z0-9_.-]+$/.test(e) ? F() + e : (memorio.message("Key contains invalid characters (only a-z, A-Z, 0-9, _, ., - allowed)"),
660
691
  "") : "";
@@ -668,7 +699,7 @@ Object.defineProperty(globalThis, "store", {
668
699
  get: {
669
700
  value: e => {
670
701
  if (!e) return;
671
- const o = L(e);
702
+ const o = V(e);
672
703
  try {
673
704
  if (q) {
674
705
  const e = R.getItem(o);
@@ -697,7 +728,7 @@ Object.defineProperty(globalThis, "store", {
697
728
  set: {
698
729
  value: (e, o) => {
699
730
  if (!e) return;
700
- const t = L(e);
731
+ const t = V(e);
701
732
  try {
702
733
  if (q) {
703
734
  if (null == o) R.setItem(t, JSON.stringify(null)); else if ("object" == typeof o || "number" == typeof o || "boolean" == typeof o || "string" == typeof o) R.setItem(t, JSON.stringify(o)); else if ("function" == typeof o) return void memorio.message("Storing functions is not secure and is blocked for safety.");
@@ -714,7 +745,7 @@ Object.defineProperty(globalThis, "store", {
714
745
  remove: {
715
746
  value: e => {
716
747
  if (!e) return;
717
- const o = L(e);
748
+ const o = V(e);
718
749
  try {
719
750
  if (q) {
720
751
  if (R.getItem(o)) return R.removeItem(o), !0;
@@ -795,23 +826,23 @@ Object.defineProperty(globalThis, "store", {
795
826
  }
796
827
  }), Object.freeze(store);
797
828
 
798
- var H = x(), V = new Map;
829
+ var H = x(), Y = new Map;
799
830
 
800
- function Y() {
831
+ function Z() {
801
832
  const e = memorio._currentContext || "" || "default";
802
- return V.has(e) || V.set(e, new Map), V.get(e);
833
+ return Y.has(e) || Y.set(e, new Map), Y.get(e);
803
834
  }
804
835
 
805
- var Z = null !== H;
836
+ var G = null !== H;
806
837
 
807
- function G() {
838
+ function Q() {
808
839
  const e = memorio._currentContext || "";
809
840
  return e ? `${e}-` : "memorio_session_";
810
841
  }
811
842
 
812
- function Q(e) {
843
+ function X(e) {
813
844
  return e && "string" == typeof e ? e.length > 512 ? (memorio.message("Key too long (max 512 characters)"),
814
- "") : /^[a-zA-Z0-9_.-]+$/.test(e) ? G() + e : (memorio.message("Key contains invalid characters (only a-z, A-Z, 0-9, _, ., - allowed)"),
845
+ "") : /^[a-zA-Z0-9_.-]+$/.test(e) ? Q() + e : (memorio.message("Key contains invalid characters (only a-z, A-Z, 0-9, _, ., - allowed)"),
815
846
  "") : "";
816
847
  }
817
848
 
@@ -823,14 +854,14 @@ Object.defineProperty(globalThis, "session", {
823
854
  get: {
824
855
  value: e => {
825
856
  if (!e) return;
826
- const o = Q(e);
857
+ const o = X(e);
827
858
  try {
828
- if (Z) {
859
+ if (G) {
829
860
  const e = H.getItem(o);
830
861
  return e ? JSON.parse(e) : e;
831
862
  }
832
863
  {
833
- const e = Y().get(o);
864
+ const e = Z().get(o);
834
865
  return e ? JSON.parse(e) : e;
835
866
  }
836
867
  } catch (o) {
@@ -841,10 +872,10 @@ Object.defineProperty(globalThis, "session", {
841
872
  set: {
842
873
  value: (e, o) => {
843
874
  if (!e) return;
844
- const t = Q(e);
875
+ const t = X(e);
845
876
  try {
846
- if (Z) null == o ? H.setItem(t, JSON.stringify(null)) : "object" == typeof o || "number" == typeof o || "boolean" == typeof o || "string" == typeof o ? H.setItem(t, JSON.stringify(o)) : "function" == typeof o && memorio.message("It's not secure to session functions."); else {
847
- const e = Y();
877
+ if (G) null == o ? H.setItem(t, JSON.stringify(null)) : "object" == typeof o || "number" == typeof o || "boolean" == typeof o || "string" == typeof o ? H.setItem(t, JSON.stringify(o)) : "function" == typeof o && memorio.message("It's not secure to session functions."); else {
878
+ const e = Z();
848
879
  null == o ? e.set(t, JSON.stringify(null)) : "object" == typeof o || "number" == typeof o || "boolean" == typeof o || "string" == typeof o ? e.set(t, JSON.stringify(o)) : "function" == typeof o && memorio.message("It's not secure to session functions.");
849
880
  }
850
881
  } catch (o) {
@@ -855,11 +886,11 @@ Object.defineProperty(globalThis, "session", {
855
886
  remove: {
856
887
  value: e => {
857
888
  if (!e) return;
858
- const o = Q(e);
889
+ const o = X(e);
859
890
  try {
860
- if (Z) {
891
+ if (G) {
861
892
  if (H.getItem(o)) return H.removeItem(o), !0;
862
- } else if (Y().has(o)) return Y().delete(o), !0;
893
+ } else if (Z().has(o)) return Z().delete(o), !0;
863
894
  } catch (o) {
864
895
  memorio.message(`Error removing session item '${e}': ${o}`);
865
896
  }
@@ -870,14 +901,14 @@ Object.defineProperty(globalThis, "session", {
870
901
  },
871
902
  removeAll: {
872
903
  value: () => {
873
- if (Z) {
904
+ if (G) {
874
905
  const e = [];
875
906
  for (let o = 0; o < H.length; o++) {
876
907
  const t = H.key(o);
877
- t?.startsWith(G()) && e.push(t);
908
+ t?.startsWith(Q()) && e.push(t);
878
909
  }
879
910
  e.forEach(e => H.removeItem(e));
880
- } else Y().clear();
911
+ } else Z().clear();
881
912
  return !0;
882
913
  }
883
914
  },
@@ -890,36 +921,36 @@ Object.defineProperty(globalThis, "session", {
890
921
  size: {
891
922
  value: () => {
892
923
  let e = 0;
893
- return Z ? Object.keys(H).forEach(o => {
894
- if (o.startsWith(G())) {
924
+ return G ? Object.keys(H).forEach(o => {
925
+ if (o.startsWith(Q())) {
895
926
  const t = H.getItem(o);
896
927
  t && (e += t.length);
897
928
  }
898
- }) : Y().forEach(o => {
929
+ }) : Z().forEach(o => {
899
930
  e += o.length;
900
931
  }), e;
901
932
  }
902
933
  },
903
934
  isPersistent: {
904
- get: () => Z
935
+ get: () => G
905
936
  },
906
937
  list: {
907
938
  value: () => {
908
939
  const e = {};
909
940
  try {
910
- if (Z) for (let o = 0; o < H.length; o++) {
941
+ if (G) for (let o = 0; o < H.length; o++) {
911
942
  const t = H.key(o);
912
- if (t?.startsWith(G())) {
913
- const o = t.replace(G(), ""), r = H.getItem(t);
943
+ if (t?.startsWith(Q())) {
944
+ const o = t.replace(Q(), ""), r = H.getItem(t);
914
945
  if (null !== r) try {
915
946
  e[o] = JSON.parse(r);
916
947
  } catch {
917
948
  e[o] = r;
918
949
  }
919
950
  }
920
- } else Y().forEach((o, t) => {
921
- if (t.startsWith(G())) {
922
- const r = t.replace(G(), "");
951
+ } else Z().forEach((o, t) => {
952
+ if (t.startsWith(Q())) {
953
+ const r = t.replace(Q(), "");
923
954
  try {
924
955
  e[r] = JSON.parse(o);
925
956
  } catch {
@@ -935,22 +966,22 @@ Object.defineProperty(globalThis, "session", {
935
966
  }
936
967
  }), Object.freeze(session);
937
968
 
938
- var X = {};
969
+ var ee = {};
939
970
 
940
971
  Object.defineProperty(globalThis, "cache", {
941
972
  value: new Proxy({}, {
942
- get: (e, o) => "get" === o ? e => X[e] : "set" === o ? (e, o) => {
943
- X[e] = o;
944
- } : "remove" === o ? e => (delete X[e], !0) : "removeAll" === o || "clear" === o ? () => (Object.keys(X).forEach(e => delete X[e]),
973
+ get: (e, o) => "get" === o ? e => ee[e] : "set" === o ? (e, o) => {
974
+ ee[e] = o;
975
+ } : "remove" === o ? e => (delete ee[e], !0) : "removeAll" === o || "clear" === o ? () => (Object.keys(ee).forEach(e => delete ee[e]),
945
976
  !0) : "list" === o ? () => ({
946
- ...X
947
- }) : X[o],
948
- set: (e, o, t) => (X[o] = t, !0),
949
- deleteProperty: (e, o) => (delete X[o], !0)
977
+ ...ee
978
+ }) : ee[o],
979
+ set: (e, o, t) => (ee[o] = t, !0),
980
+ deleteProperty: (e, o) => (delete ee[o], !0)
950
981
  }),
951
982
  enumerable: !1,
952
983
  configurable: !0
953
- }), Object.freeze(cache), I() ? (async () => {
984
+ }), Object.freeze(cache), A() ? (async () => {
954
985
  Object.defineProperty(globalThis, "idb", {
955
986
  value: {
956
987
  db: {},
@@ -970,8 +1001,8 @@ Object.defineProperty(globalThis, "cache", {
970
1001
  l)), Promise.resolve().then(() => (u(), m)), Promise.resolve().then(() => (d(),
971
1002
  b)), Promise.resolve().then(() => (f(), g)), Promise.resolve().then(() => (p(),
972
1003
  h)), Promise.resolve().then(() => (y(), v)), Promise.resolve().then(() => (O(),
973
- T)), Promise.resolve().then(() => (S(), w)), Promise.resolve().then(() => (P(),
974
- j)), Promise.resolve().then(() => (E(), $)) ]), Object.preventExtensions(idb), Object.seal(idb),
1004
+ T)), Promise.resolve().then(() => (j(), w)), Promise.resolve().then(() => (P(),
1005
+ S)), Promise.resolve().then(() => (E(), _)) ]), Object.preventExtensions(idb), Object.seal(idb),
975
1006
  Object.freeze(idb);
976
1007
  })() : (Object.defineProperty(globalThis, "idb", {
977
1008
  value: {
@@ -986,9 +1017,9 @@ Object.defineProperty(globalThis, "cache", {
986
1017
  enumerable: !1
987
1018
  }), console.warn("Memorio IDB: IndexedDB is not available in this environment. Use store or session for data persistence."));
988
1019
 
989
- var ee = (globalThis.memorio || {}).globals;
1020
+ var oe = (globalThis.memorio || {}).globals;
990
1021
 
991
- function oe() {
1022
+ function te() {
992
1023
  if (!globalThis.store) return {};
993
1024
  const e = {}, o = globalThis.store;
994
1025
  if ("function" == typeof o.list) try {
@@ -1001,7 +1032,7 @@ function oe() {
1001
1032
  return e;
1002
1033
  }
1003
1034
 
1004
- function te() {
1035
+ function re() {
1005
1036
  if (!globalThis.session) return {};
1006
1037
  const e = {}, o = globalThis.session;
1007
1038
  if ("function" == typeof o.list) try {
@@ -1014,7 +1045,7 @@ function te() {
1014
1045
  return e;
1015
1046
  }
1016
1047
 
1017
- var re, se = e => {
1048
+ var se, ne = e => {
1018
1049
  globalThis[e] && "function" == typeof globalThis[e].clear ? globalThis[e].clear() : console.error(`Module ${e} not found or does not support clear()`);
1019
1050
  };
1020
1051
 
@@ -1030,7 +1061,7 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "devt
1030
1061
  o = "function" == typeof e ? e() : "object" == typeof e && null !== e ? e : globalThis.state,
1031
1062
  console.table(o);
1032
1063
  }
1033
- if (globalThis.store && console.table(oe()), globalThis.session && console.table(te()),
1064
+ if (globalThis.store && console.table(te()), globalThis.session && console.table(re()),
1034
1065
  globalThis.cache) {
1035
1066
  const e = globalThis.cache.list;
1036
1067
  let o;
@@ -1057,9 +1088,9 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "devt
1057
1088
  lastUpdate: (new Date).toISOString()
1058
1089
  };
1059
1090
  },
1060
- clear: se,
1091
+ clear: ne,
1061
1092
  clearAll: () => {
1062
- se("state"), se("store"), se("session"), se("cache");
1093
+ ne("state"), ne("store"), ne("session"), ne("cache");
1063
1094
  },
1064
1095
  exportData: () => {
1065
1096
  const e = {
@@ -1070,8 +1101,8 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "devt
1070
1101
  return;
1071
1102
  }
1072
1103
  })(),
1073
- store: oe(),
1074
- session: te(),
1104
+ store: te(),
1105
+ session: re(),
1075
1106
  cache: (() => {
1076
1107
  if (globalThis.cache) try {
1077
1108
  return "function" == typeof globalThis.cache.list ? globalThis.cache.list() : globalThis.cache;
@@ -1102,19 +1133,19 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "devt
1102
1133
  watch: (e, o) => {
1103
1134
  if (!globalThis[e]) return void console.error(`Module ${e} not found`);
1104
1135
  const t = globalThis[e], r = t[o];
1105
- if (console.log(`šŸ‘ Watching ${e}.${o} (initial: ${JSON.stringify(r)})`), "state" === e && globalThis.memorio?.dispatch) {
1136
+ if (console.debug(`šŸ‘ Watching ${e}.${o} (initial: ${JSON.stringify(r)})`), "state" === e && globalThis.memorio?.dispatch) {
1106
1137
  const r = t => {
1107
1138
  const r = t.detail;
1108
- r?.name?.includes(o) && console.log(`šŸ‘ Change: ${e}.${o} =`, t.detail.value);
1139
+ r?.name?.includes(o) && console.debug(`šŸ‘ Change: ${e}.${o} =`, t.detail.value);
1109
1140
  };
1110
1141
  t.addEventListener?.("memorio-change", r);
1111
1142
  }
1112
1143
  },
1113
1144
  help: () => {
1114
- console.log("\n🧠 Memorio DevTools Help\n\nAvailable commands:\n memorio.devtools.inspect() - Inspect all state modules\n memorio.devtools.stats() - Show statistics\n memorio.devtools.clear('module') - Clear specific module\n memorio.devtools.clearAll() - Clear all modules\n memorio.devtools.exportData() - Export all data as JSON\n memorio.devtools.importData(json) - Import data from JSON\n memorio.devtools.watch(module, path) - Watch a path for changes\n memorio.devtools.help() - Show this help\n\nShortcuts:\n state - globalThis.state\n store - globalThis.store\n session - globalThis.session\n cache - globalThis.cache\n");
1145
+ console.debug("\n🧠 Memorio DevTools Help\n\nAvailable commands:\n memorio.devtools.inspect() - Inspect all state modules\n memorio.devtools.stats() - Show statistics\n memorio.devtools.clear('module') - Clear specific module\n memorio.devtools.clearAll() - Clear all modules\n memorio.devtools.exportData() - Export all data as JSON\n memorio.devtools.importData(json) - Import data from JSON\n memorio.devtools.watch(module, path) - Watch a path for changes\n memorio.devtools.help() - Show this help\n\nShortcuts:\n state - globalThis.state\n store - globalThis.store\n session - globalThis.session\n cache - globalThis.cache\n");
1115
1146
  }
1116
1147
  }
1117
- }), re = "devtools", !1 === ee || ee && "object" == typeof ee && !1 === ee[re] || (Object.defineProperty(globalThis, "$state", {
1148
+ }), se = "devtools", !1 === oe || oe && "object" == typeof oe && !1 === oe[se] || (Object.defineProperty(globalThis, "$state", {
1118
1149
  get: () => globalThis.state,
1119
1150
  configurable: !0
1120
1151
  }), Object.defineProperty(globalThis, "$store", {
@@ -1128,12 +1159,12 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "devt
1128
1159
  configurable: !0
1129
1160
  }));
1130
1161
 
1131
- var ne = {
1162
+ var ie = {
1132
1163
  enabled: !0,
1133
1164
  logToConsole: !0,
1134
1165
  modules: [ "state", "store", "session", "cache", "idb" ],
1135
1166
  maxEntries: 1e3
1136
- }, ie = [], ae = e => ne.enabled && ne.modules.includes(e), le = e => ({
1167
+ }, ae = [], le = e => ie.enabled && ie.modules.includes(e), ce = e => ({
1137
1168
  state: "#4CAF50",
1138
1169
  store: "#2196F3",
1139
1170
  session: "#FF9800",
@@ -1146,20 +1177,20 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "logg
1146
1177
  configurable: !0,
1147
1178
  value: {
1148
1179
  configure: e => {
1149
- ne = {
1150
- ...ne,
1180
+ ie = {
1181
+ ...ie,
1151
1182
  ...e
1152
1183
  };
1153
1184
  },
1154
1185
  enable: () => {
1155
- ne.enabled = !0;
1186
+ ie.enabled = !0;
1156
1187
  },
1157
1188
  disable: () => {
1158
- ne.enabled = !1;
1189
+ ie.enabled = !1;
1159
1190
  },
1160
- isEnabled: ae,
1191
+ isEnabled: le,
1161
1192
  log: (e, o, t, r, s) => {
1162
- if (!ae(e)) return;
1193
+ if (!le(e)) return;
1163
1194
  const n = {
1164
1195
  timestamp: (new Date).toISOString(),
1165
1196
  module: e,
@@ -1168,20 +1199,20 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "logg
1168
1199
  value: r,
1169
1200
  previousValue: s
1170
1201
  };
1171
- if (ie.push(n), ie.length > ne.maxEntries && ie.shift(), ne.logToConsole && !0 === globalThis.memorio?.debug) {
1172
- const n = `[Memorio:${e.toUpperCase()}]`, i = le(e);
1202
+ if (ae.push(n), ae.length > ie.maxEntries && ae.shift(), ie.logToConsole && !0 === globalThis.memorio?.debug) {
1203
+ const n = `[Memorio:${e.toUpperCase()}]`, i = ce(e);
1173
1204
  memorio.message(`%c${n}%c ${o} ${t},\n color: ${i}; font-weight: bold,\n color: inherit`),
1174
1205
  void 0 !== r && memorio.message(` → value:${r}`), void 0 !== s && memorio.message(` ← previous:${s}`);
1175
1206
  }
1176
- ne.customHandler && ne.customHandler(n);
1207
+ ie.customHandler && ie.customHandler(n);
1177
1208
  },
1178
- getHistory: () => [ ...ie ],
1209
+ getHistory: () => [ ...ae ],
1179
1210
  clearHistory: () => {
1180
- ie.length = 0;
1211
+ ae.length = 0;
1181
1212
  },
1182
1213
  getStats: () => {
1183
1214
  const e = {
1184
- total: ie.length,
1215
+ total: ae.length,
1185
1216
  state: 0,
1186
1217
  store: 0,
1187
1218
  session: 0,
@@ -1192,12 +1223,12 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "logg
1192
1223
  delete: 0,
1193
1224
  clear: 0
1194
1225
  };
1195
- for (const o of ie) if (o) {
1226
+ for (const o of ae) if (o) {
1196
1227
  const t = o.module, r = o.action;
1197
1228
  t && "number" == typeof e[t] && e[t]++, r && "number" == typeof e[r] && e[r]++;
1198
1229
  }
1199
1230
  return e;
1200
1231
  },
1201
- exportLogs: () => JSON.stringify(ie, null, 2)
1232
+ exportLogs: () => JSON.stringify(ae, null, 2)
1202
1233
  }
1203
1234
  });