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