memorio 4.0.0 → 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.
Files changed (4) hide show
  1. package/index.cjs +123 -119
  2. package/index.js +121 -119
  3. package/package.json +12 -3
  4. package/types/memorio.d.ts +1 -0
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,15 +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
- console.debug(`IndexedDB error: ${s.error?.message}`), r(s.error);
11
+ memorio.message(`IndexedDB error: ${s.error?.message}`), r(s.error);
10
12
  }, s.onsuccess = () => {
11
- console.debug(`Database ${e} connected successfully`), idb.db.list(), o(s.result);
13
+ memorio.message(`Database ${e} connected successfully`), o(s.result);
12
14
  }, s.onupgradeneeded = () => {
13
- console.debug(`Database ${e} upgrade/creation initiated`);
15
+ memorio.message(`Database ${e} upgrade/creation initiated`);
14
16
  };
15
17
  });
16
18
  }
17
- }), s = {}, n = t({
19
+ }), s = {}, i = t({
18
20
  "functions/idb/tools/db.list.ts"() {
19
21
  idb.db.list = async () => {
20
22
  if (!("indexedDB" in globalThis) || !indexedDB.databases) return [];
@@ -24,24 +26,24 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
24
26
  } catch (e) {
25
27
  return console.error("Error listing databases:", e), [];
26
28
  }
27
- }, idb.db.list();
29
+ };
28
30
  }
29
- }), i = {}, l = t({
31
+ }), n = {}, a = t({
30
32
  "functions/idb/tools/db.exist.ts"() {
31
33
  idb.db.exist = e => idbases?.some(t => t.name === e);
32
34
  }
33
- }), a = {}, c = t({
35
+ }), l = {}, c = t({
34
36
  "functions/idb/tools/db.quota.ts"() {
35
37
  idb.db.quota = () => navigator.storage.estimate();
36
38
  }
37
- }), b = {}, u = t({
39
+ }), m = {}, b = t({
38
40
  "functions/idb/tools/db.delete.ts"() {
39
41
  idb.db.delete = e => new Promise((t, o) => {
40
- console.debug(`Removing database ${e}...`);
42
+ memorio.message(`Removing database ${e}...`);
41
43
  (() => {
42
44
  const r = indexedDB.deleteDatabase(e);
43
45
  r.onsuccess = () => {
44
- console.debug(`${e} database removed successfully`), idb.db.list(), t();
46
+ memorio.message(`${e} database removed successfully`), idb.db.list(), t();
45
47
  }, r.onerror = () => {
46
48
  console.error(`Error removing ${e}:`, r.error), o(r.error);
47
49
  }, r.onblocked = () => {
@@ -50,7 +52,7 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
50
52
  })();
51
53
  });
52
54
  }
53
- }), d = {}, f = t({
55
+ }), u = {}, d = t({
54
56
  "functions/idb/tools/db.size.ts"() {
55
57
  idb.db.size = async () => {
56
58
  if (idbases && 0 !== idbases.length) for (let e = 0; e < idbases.length; e++) {
@@ -63,12 +65,12 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
63
65
  }
64
66
  t.size = r, e.close();
65
67
  } catch (e) {
66
- console.debug(`Could not calculate size for ${t.name}:`, e);
68
+ memorio.message(`Could not calculate size for ${t.name}:${e}`);
67
69
  }
68
70
  }
69
71
  };
70
72
  }
71
- }), g = {}, h = t({
73
+ }), g = {}, f = t({
72
74
  "functions/idb/tools/db.version.ts"() {
73
75
  idb.db.version = e => {
74
76
  let t = 0;
@@ -79,19 +81,19 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
79
81
  return t;
80
82
  };
81
83
  }
82
- }), m = {}, p = t({
84
+ }), h = {}, p = t({
83
85
  "functions/idb/tools/db.support.ts"() {
84
86
  idb.db.support = () => {
85
87
  const e = "indexedDB" in globalThis;
86
- return e || console.debug("Your environment doesn't support IndexedDB"), e;
88
+ return e || memorio.message("Your environment doesn't support IndexedDB"), e;
87
89
  };
88
90
  }
89
91
  }), v = {}, y = t({
90
92
  "functions/idb/tools/table.create.ts"() {
91
93
  idb.table.create = (e, t) => new Promise(async (o, r) => {
92
94
  try {
93
- const s = (Number(idb.db.version(e)) || 0) + 1, n = indexedDB.open(e, s);
94
- n.onupgradeneeded = o => {
95
+ const s = (Number(idb.db.version(e)) || 0) + 1, i = indexedDB.open(e, s);
96
+ i.onupgradeneeded = o => {
95
97
  const r = o.target.result;
96
98
  if (!r.objectStoreNames.contains(t)) {
97
99
  const o = r.createObjectStore(t, {
@@ -102,12 +104,12 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
102
104
  unique: !0
103
105
  }), o.createIndex("data", "data", {
104
106
  unique: !1
105
- }), console.debug(`Table ${t} created in ${e}`);
107
+ }), memorio.message(`Table ${t} created in ${e}`);
106
108
  }
107
- }, n.onsuccess = () => {
108
- n.result.close(), idb.db.list(), o();
109
- }, n.onerror = () => {
110
- console.error(`Error creating table ${t}:`, n.error), 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);
111
113
  };
112
114
  } catch (e) {
113
115
  console.error("Critical error in table.create:", e), r(e);
@@ -119,48 +121,48 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
119
121
  idb.table.size = (e, t) => new Promise((o, r) => {
120
122
  if (!e) return r(new Error("Database instance is required"));
121
123
  if (!e.objectStoreNames.contains(t)) return o(0);
122
- let s = 0, n = 0;
123
- const i = e.transaction([ t ], "readonly").objectStore(t).openCursor();
124
- 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 => {
125
127
  const t = e.target.result;
126
128
  if (t) {
127
129
  try {
128
130
  const e = t.value;
129
131
  s += JSON.stringify(e).length;
130
132
  } catch (e) {
131
- console.debug("Error stringifying IDB value tracking size:", e);
133
+ memorio.message(`Error stringifying IDB value tracking size:${e}`);
132
134
  }
133
- n++, n % 200 == 0 && await new Promise(e => setTimeout(e, 0)), t.continue();
135
+ i++, i % 200 == 0 && await new Promise(e => setTimeout(e, 0)), t.continue();
134
136
  } else o(s);
135
- }, i.onerror = () => {
136
- r(i.error);
137
+ }, n.onerror = () => {
138
+ r(n.error);
137
139
  };
138
140
  });
139
141
  }
140
142
  }), j = {}, w = t({
141
143
  "functions/idb/crud/data.delete.ts"() {
142
144
  idb.data.delete = (e, t, o) => new Promise((r, s) => {
143
- const n = indexedDB.open(e);
144
- n.onsuccess = () => {
145
- const e = n.result;
145
+ const i = indexedDB.open(e);
146
+ i.onsuccess = () => {
147
+ const e = i.result;
146
148
  if (!e.objectStoreNames.contains(t)) return e.close(), s(new Error(`Table ${t} not found`));
147
- const i = e.transaction(t, "readwrite").objectStore(t).delete(o);
148
- i.onsuccess = () => {
149
- e.close(), console.debug(`Record ${o} deleted from ${t}`), r();
150
- }, i.onerror = () => {
151
- 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);
152
154
  };
153
- }, n.onerror = () => s(n.error);
155
+ }, i.onerror = () => s(i.error);
154
156
  }), idb.data.delete.all = (e, t) => new Promise((o, r) => {
155
157
  const s = indexedDB.open(e);
156
158
  s.onsuccess = e => {
157
159
  const s = e.target.result;
158
160
  if (!s.objectStoreNames.contains(t)) return s.close(), r(new Error(`Table ${t} not found`));
159
- const n = s.transaction(t, "readwrite").objectStore(t).clear();
160
- n.onsuccess = () => {
161
- s.close(), console.debug(`All data cleared from ${t}`), o();
162
- }, n.onerror = () => {
163
- 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);
164
166
  };
165
167
  }, s.onerror = () => r(s.error);
166
168
  });
@@ -168,42 +170,42 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
168
170
  }), S = {}, P = t({
169
171
  "functions/idb/crud/data.set.ts"() {
170
172
  idb.data.set = (e, t, o) => new Promise((r, s) => {
171
- const n = indexedDB.open(e);
172
- n.onsuccess = () => {
173
- const i = n.result;
174
- if (!i.objectStoreNames.contains(t)) return i.close(), s(new Error(`Table ${t} does not exist in ${e}`));
175
- const l = i.transaction(t, "readwrite").objectStore(t).put(o);
176
- l.onsuccess = () => {
177
- i.close(), console.debug(`Data saved in ${e}.${t}`), r(l.result);
178
- }, l.onerror = e => {
179
- i.close(), console.debug(`Database insert error: ${l.error?.message}`), 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);
180
182
  };
181
- }, n.onerror = () => {
182
- s(n.error);
183
+ }, i.onerror = () => {
184
+ s(i.error);
183
185
  };
184
186
  });
185
187
  }
186
- }), E = {}, k = t({
188
+ }), E = {}, $ = t({
187
189
  "functions/idb/crud/data.get.ts"() {
188
190
  idb.data.get = (e, t, o) => new Promise((r, s) => {
189
- const n = indexedDB.open(e);
190
- n.onsuccess = n => {
191
- const i = n.target.result;
192
- if (!i.objectStoreNames.contains(t)) return i.close(), s(new Error(`Table ${t} not found in ${e}`));
193
- const l = i.transaction(t, "readonly").objectStore(t).get(o);
194
- l.onsuccess = () => {
195
- i.close(), r(l.result);
196
- }, l.onerror = () => {
197
- 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);
198
200
  };
199
- }, n.onerror = () => {
200
- s(n.error);
201
+ }, i.onerror = () => {
202
+ s(i.error);
201
203
  };
202
204
  });
203
205
  }
204
206
  });
205
207
 
206
- function _() {
208
+ function k() {
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 _() {
213
215
  return `session_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
214
216
  }
215
217
 
216
- function $() {
218
+ function _() {
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
  }
@@ -243,7 +245,7 @@ function I() {
243
245
  }
244
246
 
245
247
  function N() {
246
- const e = $(), t = void 0 !== globalThis.isSecureContext ? globalThis.isSecureContext : "browser" === e;
248
+ const e = _(), t = void 0 !== globalThis.isSecureContext ? globalThis.isSecureContext : "browser" === e;
247
249
  return {
248
250
  platform: e,
249
251
  hasSessionStorage: null !== D(),
@@ -253,7 +255,7 @@ function N() {
253
255
  hasNavigator: "undefined" != typeof navigator,
254
256
  hasProcess: "undefined" != typeof process,
255
257
  isSecureContext: t,
256
- sessionId: _()
258
+ sessionId: k()
257
259
  };
258
260
  }
259
261
 
@@ -262,7 +264,7 @@ var A = new Map;
262
264
  var z = new Map;
263
265
 
264
266
  function J(e) {
265
- const t = e || `context_${_()}`, o = {
267
+ const t = e || `context_${k()}`, o = {
266
268
  state: {},
267
269
  store: new Map,
268
270
  session: new Map,
@@ -321,7 +323,7 @@ Object.defineProperty(globalThis, "memorio", {
321
323
  }), Object.defineProperty(memorio, "version", {
322
324
  writable: !1,
323
325
  enumerable: !1,
324
- value: "4.0.0"
326
+ value: "4.1.0"
325
327
  }), Object.defineProperty(memorio, "debug", {
326
328
  writable: !0,
327
329
  enumerable: !1,
@@ -372,13 +374,13 @@ Object.defineProperty(memorio, "_sessionId", {
372
374
  }, memorio.deleteContext = function(e) {
373
375
  return z.delete(e);
374
376
  }, memorio.isBrowser = function() {
375
- return "browser" === $();
377
+ return "browser" === _();
376
378
  }, memorio.isNode = function() {
377
- return "node" === $();
379
+ return "node" === _();
378
380
  }, memorio.isDeno = function() {
379
- return "deno" === $();
381
+ return "deno" === _();
380
382
  }, memorio.isEdge = function() {
381
- return "edge" === $();
383
+ return "edge" === _();
382
384
  }, memorio.getCapabilities = N, memorio.isolate = function(e) {
383
385
  return J(e);
384
386
  }, Object.defineProperty(memorio, "dispatch", {
@@ -398,7 +400,9 @@ Object.defineProperty(memorio, "_sessionId", {
398
400
  t && (globalThis.removeEventListener(e, t), delete globalThis.events[e]);
399
401
  }
400
402
  }
401
- }), 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", {
402
406
  writable: !1,
403
407
  enumerable: !1,
404
408
  value: (e, t, o = ".") => {
@@ -412,7 +416,7 @@ globalThis.memorio._locked = !1;
412
416
  var M = (e, t, o = []) => new Proxy(e, {
413
417
  get(e, r) {
414
418
  if ("__path" === r) return o.length > 0 ? "state." + o.join(".") : "state";
415
- if ("list" === r) return console.debug('Some state could be hidden when you use "state.list". Use "state" to see the complete list '),
419
+ if ("list" === r) return memorio.message('Some state could be hidden when you use "state.list". Use "state" to see the complete list '),
416
420
  JSON.parse(JSON.stringify(globalThis.state));
417
421
  if (globalThis.memorio._tracking && "string" == typeof r) {
418
422
  const e = o.length > 0 ? "state." + o.concat(r).join(".") : "state." + r;
@@ -447,10 +451,10 @@ var M = (e, t, o = []) => new Proxy(e, {
447
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.`),
448
452
  !1;
449
453
  try {
450
- const n = globalThis.memorio.objPath?.(r, o) ?? r;
454
+ const i = globalThis.memorio.objPath?.(r, o) ?? r;
451
455
  if (t({
452
456
  action: "set",
453
- path: n,
457
+ path: i,
454
458
  target: e,
455
459
  newValue: s,
456
460
  previousValue: Reflect.get(e, r)
@@ -462,7 +466,7 @@ var M = (e, t, o = []) => new Proxy(e, {
462
466
  }
463
467
  });
464
468
  } catch (e) {}
465
- })("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]) {
466
470
  const t = e[r];
467
471
  if (t && "object" == typeof t) try {
468
472
  Object.defineProperty(t, "__locked", {
@@ -480,7 +484,7 @@ var M = (e, t, o = []) => new Proxy(e, {
480
484
  enumerable: !1,
481
485
  configurable: !1,
482
486
  value: !0
483
- }), console.info(`State '${r}' is now locked.`);
487
+ }), memorio.message(`State '${r}' is now locked.`);
484
488
  }
485
489
  }), Object.defineProperty(t, "unlock", {
486
490
  writable: !1,
@@ -492,7 +496,7 @@ var M = (e, t, o = []) => new Proxy(e, {
492
496
  enumerable: !1,
493
497
  configurable: !1,
494
498
  value: !1
495
- }), console.info(`State '${r}' is now unlocked.`);
499
+ }), memorio.message(`State '${r}' is now unlocked.`);
496
500
  }
497
501
  });
498
502
  } catch (e) {}
@@ -519,9 +523,9 @@ var M = (e, t, o = []) => new Proxy(e, {
519
523
  });
520
524
 
521
525
  globalThis?.state || (globalThis.state = M({}, () => {})), globalThis.state.lock = () => {
522
- globalThis.memorio._locked = !0, console.info("State is now locked. All modifications are blocked.");
526
+ globalThis.memorio._locked = !0, memorio.message("State is now locked. All modifications are blocked.");
523
527
  }, globalThis.state.unlock = () => {
524
- globalThis.memorio._locked = !1, console.info("State is now unlocked. Modifications are allowed.");
528
+ globalThis.memorio._locked = !1, memorio.message("State is now unlocked. Modifications are allowed.");
525
529
  }, Object.defineProperty(globalThis, "state", {
526
530
  enumerable: !1,
527
531
  configurable: !0
@@ -546,7 +550,7 @@ globalThis.observer = (e, t = null, o = !0) => {
546
550
  }
547
551
  }, o = globalThis.observer;
548
552
  return o?.list?.[e] && globalThis.memorio.dispatch.remove(t), o?.list?.[e] || globalThis.memorio.dispatch.listen(t),
549
- void console.debug("called: ", e);
553
+ void memorio.message(`called: ${e}`);
550
554
  }
551
555
  if (e && t) {
552
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'");
@@ -599,27 +603,27 @@ globalThis.observer = (e, t = null, o = !0) => {
599
603
  e();
600
604
  } catch (e) {}
601
605
  globalThis.memorio._tracking = !1, globalThis.memorio._trackedPaths?.forEach(t => {
602
- o.includes(t) || (console.info(`useObserver: [Auto-Discovery] -> "${t}"`), globalThis.memorio.dispatch.listen(t, () => e()),
606
+ o.includes(t) || (memorio.message(`useObserver: [Auto-Discovery] -> "${t}"`), globalThis.memorio.dispatch.listen(t, () => e()),
603
607
  o.push(t));
604
608
  });
605
609
  }
606
- }), o.length > 0 ? console.info(`useObserver: Monitoring ${o.length} paths.`) : console.warn("useObserver: No paths resolved for monitoring. Check your dependencies!"),
610
+ }), o.length > 0 ? memorio.message(`useObserver: Monitoring ${o.length} paths.`) : console.warn("useObserver: No paths resolved for monitoring. Check your dependencies!"),
607
611
  () => {
608
612
  o.forEach(e => {
609
613
  globalThis.memorio.dispatch && "function" == typeof globalThis.memorio.dispatch.remove && (globalThis.memorio.dispatch.remove(e),
610
- console.debug(`useObserver: Stopped monitoring "${e}"`));
614
+ memorio.message(`useObserver: Stopped monitoring "${e}"`));
611
615
  });
612
616
  };
613
617
  } catch (e) {
614
- return console.debug("useObserver Error:", e), () => {};
618
+ return memorio.message(`useObserver Error: ${e}`), () => {};
615
619
  }
616
620
  }, Object.freeze(globalThis.useObserver);
617
621
 
618
622
  var W = x(), R = new Map, U = null !== W, K = "memorio_store_";
619
623
 
620
624
  function F(e) {
621
- return e && "string" == typeof e ? e.length > 512 ? (console.debug("Key too long (max 512 characters)"),
622
- "") : /^[a-zA-Z0-9_.-]+$/.test(e) ? K + e : (console.debug("Key contains invalid characters (only a-z, A-Z, 0-9, _, ., - allowed)"),
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)"),
623
627
  "") : "";
624
628
  }
625
629
 
@@ -642,7 +646,7 @@ Object.defineProperty(globalThis, "store", {
642
646
  return e ? JSON.parse(e) : e;
643
647
  }
644
648
  } catch (t) {
645
- console.debug(`Error parsing store item '${e}':`, t);
649
+ memorio.message(`Error parsing store item '${e}': ${t}`);
646
650
  }
647
651
  return null;
648
652
  }
@@ -653,10 +657,10 @@ Object.defineProperty(globalThis, "store", {
653
657
  const o = F(e);
654
658
  try {
655
659
  if (U) {
656
- 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 console.debug("Storing functions is not secure and is blocked for safety.");
657
- } 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 console.debug("Storing functions is not secure and is blocked for safety.");
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.");
658
662
  } catch (t) {
659
- console.debug(`Error setting store item '${e}':`, t);
663
+ memorio.message(`Error setting store item '${e}': ${t}`);
660
664
  }
661
665
  return null;
662
666
  }
@@ -670,7 +674,7 @@ Object.defineProperty(globalThis, "store", {
670
674
  if (W.getItem(t)) return W.removeItem(t), !0;
671
675
  } else if (R.has(t)) return R.delete(t), !0;
672
676
  } catch (t) {
673
- console.debug(`Error removing store item '${e}':`, t);
677
+ memorio.message(`Error removing store item '${e}': ${t}`);
674
678
  }
675
679
  return !1;
676
680
  }
@@ -738,7 +742,7 @@ Object.defineProperty(globalThis, "store", {
738
742
  }
739
743
  });
740
744
  } catch (e) {
741
- console.debug("Error listing store items:", e);
745
+ memorio.message(`Error listing store items: ${e}`);
742
746
  }
743
747
  return e;
744
748
  }
@@ -748,8 +752,8 @@ Object.defineProperty(globalThis, "store", {
748
752
  var q = D(), L = new Map, H = null !== q, V = "memorio_session_";
749
753
 
750
754
  function Y(e) {
751
- return e && "string" == typeof e ? e.length > 512 ? (console.debug("Key too long (max 512 characters)"),
752
- "") : /^[a-zA-Z0-9_.-]+$/.test(e) ? V + e : (console.debug("Key contains invalid characters (only a-z, A-Z, 0-9, _, ., - allowed)"),
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)"),
753
757
  "") : "";
754
758
  }
755
759
 
@@ -772,7 +776,7 @@ Object.defineProperty(globalThis, "session", {
772
776
  return e ? JSON.parse(e) : e;
773
777
  }
774
778
  } catch (t) {
775
- console.debug(`Error parsing session item '${e}':`, t);
779
+ memorio.message(`Error parsing session item '${e}':${t}`);
776
780
  }
777
781
  }
778
782
  },
@@ -781,9 +785,9 @@ Object.defineProperty(globalThis, "session", {
781
785
  if (!e) return;
782
786
  const o = Y(e);
783
787
  try {
784
- 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 && console.debug("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 && console.debug("It's not secure to session functions.");
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.");
785
789
  } catch (t) {
786
- console.debug(`Error setting session item '${e}':`, t);
790
+ memorio.message(`Error setting session item '${e}': ${t}`);
787
791
  }
788
792
  }
789
793
  },
@@ -796,7 +800,7 @@ Object.defineProperty(globalThis, "session", {
796
800
  if (q.getItem(t)) return q.removeItem(t), !0;
797
801
  } else if (L.has(t)) return L.delete(t), !0;
798
802
  } catch (t) {
799
- console.debug(`Error removing session item '${e}':`, t);
803
+ memorio.message(`Error removing session item '${e}': ${t}`);
800
804
  }
801
805
  }
802
806
  },
@@ -863,7 +867,7 @@ Object.defineProperty(globalThis, "session", {
863
867
  }
864
868
  });
865
869
  } catch (e) {
866
- console.debug("Error listing session items:", e);
870
+ memorio.message(`Error listing session items: ${e}`);
867
871
  }
868
872
  return e;
869
873
  }
@@ -900,13 +904,13 @@ Object.defineProperty(globalThis, "cache", {
900
904
  writable: !0,
901
905
  configurable: !0,
902
906
  enumerable: !1
903
- }), await Promise.all([ Promise.resolve().then(() => (r(), o)), Promise.resolve().then(() => (n(),
904
- s)), Promise.resolve().then(() => (l(), i)), Promise.resolve().then(() => (c(),
905
- a)), Promise.resolve().then(() => (u(), b)), Promise.resolve().then(() => (f(),
906
- d)), Promise.resolve().then(() => (h(), g)), Promise.resolve().then(() => (p(),
907
- m)), Promise.resolve().then(() => (y(), v)), Promise.resolve().then(() => (O(),
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(),
908
912
  T)), Promise.resolve().then(() => (w(), j)), Promise.resolve().then(() => (P(),
909
- S)), Promise.resolve().then(() => (k(), E)) ]), Object.preventExtensions(idb), Object.seal(idb),
913
+ S)), Promise.resolve().then(() => ($(), E)) ]), Object.preventExtensions(idb), Object.seal(idb),
910
914
  Object.freeze(idb);
911
915
  })() : (Object.defineProperty(globalThis, "idb", {
912
916
  value: {
@@ -1040,7 +1044,7 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "devt
1040
1044
  }
1041
1045
  },
1042
1046
  help: () => {
1043
- 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");
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");
1044
1048
  }
1045
1049
  }
1046
1050
  }), ee = "devtools", !1 === G || G && "object" == typeof G && !1 === G[ee] || (Object.defineProperty(globalThis, "$state", {
@@ -1062,7 +1066,7 @@ var oe = {
1062
1066
  logToConsole: !0,
1063
1067
  modules: [ "state", "store", "session", "cache", "idb" ],
1064
1068
  maxEntries: 1e3
1065
- }, re = [], se = e => oe.enabled && oe.modules.includes(e), ne = e => ({
1069
+ }, re = [], se = e => oe.enabled && oe.modules.includes(e), ie = e => ({
1066
1070
  state: "#4CAF50",
1067
1071
  store: "#2196F3",
1068
1072
  session: "#FF9800",
@@ -1089,7 +1093,7 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "logg
1089
1093
  isEnabled: se,
1090
1094
  log: (e, t, o, r, s) => {
1091
1095
  if (!se(e)) return;
1092
- const n = {
1096
+ const i = {
1093
1097
  timestamp: (new Date).toISOString(),
1094
1098
  module: e,
1095
1099
  action: t,
@@ -1097,12 +1101,12 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "logg
1097
1101
  value: r,
1098
1102
  previousValue: s
1099
1103
  };
1100
- if (re.push(n), re.length > oe.maxEntries && re.shift(), oe.logToConsole && !0 === globalThis.memorio?.debug) {
1101
- const n = `[Memorio:${e.toUpperCase()}]`, i = ne(e);
1102
- console.debug(`%c${n}%c ${t} ${o}`, `color: ${i}; font-weight: bold`, "color: inherit"),
1103
- void 0 !== r && console.debug(" → value:", r), void 0 !== s && console.debug(" ← previous:", s);
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}`);
1104
1108
  }
1105
- oe.customHandler && oe.customHandler(n);
1109
+ oe.customHandler && oe.customHandler(i);
1106
1110
  },
1107
1111
  getHistory: () => [ ...re ],
1108
1112
  clearHistory: () => {
package/index.js CHANGED
@@ -6,15 +6,15 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
6
6
  if (!idb.db.support()) return r(new Error("IndexedDB not supported"));
7
7
  const s = globalThis.indexedDB.open(e, t);
8
8
  s.onerror = () => {
9
- console.debug(`IndexedDB error: ${s.error?.message}`), r(s.error);
9
+ memorio.message(`IndexedDB error: ${s.error?.message}`), r(s.error);
10
10
  }, s.onsuccess = () => {
11
- console.debug(`Database ${e} connected successfully`), idb.db.list(), o(s.result);
11
+ memorio.message(`Database ${e} connected successfully`), o(s.result);
12
12
  }, s.onupgradeneeded = () => {
13
- console.debug(`Database ${e} upgrade/creation initiated`);
13
+ memorio.message(`Database ${e} upgrade/creation initiated`);
14
14
  };
15
15
  });
16
16
  }
17
- }), s = {}, n = t({
17
+ }), s = {}, i = t({
18
18
  "functions/idb/tools/db.list.ts"() {
19
19
  idb.db.list = async () => {
20
20
  if (!("indexedDB" in globalThis) || !indexedDB.databases) return [];
@@ -24,24 +24,24 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
24
24
  } catch (e) {
25
25
  return console.error("Error listing databases:", e), [];
26
26
  }
27
- }, idb.db.list();
27
+ };
28
28
  }
29
- }), i = {}, l = t({
29
+ }), n = {}, a = t({
30
30
  "functions/idb/tools/db.exist.ts"() {
31
31
  idb.db.exist = e => idbases?.some(t => t.name === e);
32
32
  }
33
- }), a = {}, c = t({
33
+ }), l = {}, c = t({
34
34
  "functions/idb/tools/db.quota.ts"() {
35
35
  idb.db.quota = () => navigator.storage.estimate();
36
36
  }
37
- }), b = {}, u = t({
37
+ }), m = {}, b = t({
38
38
  "functions/idb/tools/db.delete.ts"() {
39
39
  idb.db.delete = e => new Promise((t, o) => {
40
- console.debug(`Removing database ${e}...`);
40
+ memorio.message(`Removing database ${e}...`);
41
41
  (() => {
42
42
  const r = indexedDB.deleteDatabase(e);
43
43
  r.onsuccess = () => {
44
- console.debug(`${e} database removed successfully`), idb.db.list(), t();
44
+ memorio.message(`${e} database removed successfully`), idb.db.list(), t();
45
45
  }, r.onerror = () => {
46
46
  console.error(`Error removing ${e}:`, r.error), o(r.error);
47
47
  }, r.onblocked = () => {
@@ -50,7 +50,7 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
50
50
  })();
51
51
  });
52
52
  }
53
- }), d = {}, f = t({
53
+ }), u = {}, d = t({
54
54
  "functions/idb/tools/db.size.ts"() {
55
55
  idb.db.size = async () => {
56
56
  if (idbases && 0 !== idbases.length) for (let e = 0; e < idbases.length; e++) {
@@ -63,12 +63,12 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
63
63
  }
64
64
  t.size = r, e.close();
65
65
  } catch (e) {
66
- console.debug(`Could not calculate size for ${t.name}:`, e);
66
+ memorio.message(`Could not calculate size for ${t.name}:${e}`);
67
67
  }
68
68
  }
69
69
  };
70
70
  }
71
- }), g = {}, h = t({
71
+ }), g = {}, f = t({
72
72
  "functions/idb/tools/db.version.ts"() {
73
73
  idb.db.version = e => {
74
74
  let t = 0;
@@ -79,19 +79,19 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
79
79
  return t;
80
80
  };
81
81
  }
82
- }), m = {}, p = t({
82
+ }), h = {}, p = t({
83
83
  "functions/idb/tools/db.support.ts"() {
84
84
  idb.db.support = () => {
85
85
  const e = "indexedDB" in globalThis;
86
- return e || console.debug("Your environment doesn't support IndexedDB"), e;
86
+ return e || memorio.message("Your environment doesn't support IndexedDB"), e;
87
87
  };
88
88
  }
89
89
  }), v = {}, y = t({
90
90
  "functions/idb/tools/table.create.ts"() {
91
91
  idb.table.create = (e, t) => new Promise(async (o, r) => {
92
92
  try {
93
- const s = (Number(idb.db.version(e)) || 0) + 1, n = indexedDB.open(e, s);
94
- n.onupgradeneeded = o => {
93
+ const s = (Number(idb.db.version(e)) || 0) + 1, i = indexedDB.open(e, s);
94
+ i.onupgradeneeded = o => {
95
95
  const r = o.target.result;
96
96
  if (!r.objectStoreNames.contains(t)) {
97
97
  const o = r.createObjectStore(t, {
@@ -102,12 +102,12 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
102
102
  unique: !0
103
103
  }), o.createIndex("data", "data", {
104
104
  unique: !1
105
- }), console.debug(`Table ${t} created in ${e}`);
105
+ }), memorio.message(`Table ${t} created in ${e}`);
106
106
  }
107
- }, n.onsuccess = () => {
108
- n.result.close(), idb.db.list(), o();
109
- }, n.onerror = () => {
110
- console.error(`Error creating table ${t}:`, n.error), r(n.error);
107
+ }, i.onsuccess = () => {
108
+ i.result.close(), idb.db.list(), o();
109
+ }, i.onerror = () => {
110
+ console.error(`Error creating table ${t}:`, i.error), r(i.error);
111
111
  };
112
112
  } catch (e) {
113
113
  console.error("Critical error in table.create:", e), r(e);
@@ -119,48 +119,48 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
119
119
  idb.table.size = (e, t) => new Promise((o, r) => {
120
120
  if (!e) return r(new Error("Database instance is required"));
121
121
  if (!e.objectStoreNames.contains(t)) return o(0);
122
- let s = 0, n = 0;
123
- const i = e.transaction([ t ], "readonly").objectStore(t).openCursor();
124
- i.onsuccess = async e => {
122
+ let s = 0, i = 0;
123
+ const n = e.transaction([ t ], "readonly").objectStore(t).openCursor();
124
+ n.onsuccess = async e => {
125
125
  const t = e.target.result;
126
126
  if (t) {
127
127
  try {
128
128
  const e = t.value;
129
129
  s += JSON.stringify(e).length;
130
130
  } catch (e) {
131
- console.debug("Error stringifying IDB value tracking size:", e);
131
+ memorio.message(`Error stringifying IDB value tracking size:${e}`);
132
132
  }
133
- n++, n % 200 == 0 && await new Promise(e => setTimeout(e, 0)), t.continue();
133
+ i++, i % 200 == 0 && await new Promise(e => setTimeout(e, 0)), t.continue();
134
134
  } else o(s);
135
- }, i.onerror = () => {
136
- r(i.error);
135
+ }, n.onerror = () => {
136
+ r(n.error);
137
137
  };
138
138
  });
139
139
  }
140
140
  }), j = {}, w = t({
141
141
  "functions/idb/crud/data.delete.ts"() {
142
142
  idb.data.delete = (e, t, o) => new Promise((r, s) => {
143
- const n = indexedDB.open(e);
144
- n.onsuccess = () => {
145
- const e = n.result;
143
+ const i = indexedDB.open(e);
144
+ i.onsuccess = () => {
145
+ const e = i.result;
146
146
  if (!e.objectStoreNames.contains(t)) return e.close(), s(new Error(`Table ${t} not found`));
147
- const i = e.transaction(t, "readwrite").objectStore(t).delete(o);
148
- i.onsuccess = () => {
149
- e.close(), console.debug(`Record ${o} deleted from ${t}`), r();
150
- }, i.onerror = () => {
151
- e.close(), s(i.error);
147
+ const n = e.transaction(t, "readwrite").objectStore(t).delete(o);
148
+ n.onsuccess = () => {
149
+ e.close(), memorio.message(`Record ${o} deleted from ${t}`), r();
150
+ }, n.onerror = () => {
151
+ e.close(), s(n.error);
152
152
  };
153
- }, n.onerror = () => s(n.error);
153
+ }, i.onerror = () => s(i.error);
154
154
  }), idb.data.delete.all = (e, t) => new Promise((o, r) => {
155
155
  const s = indexedDB.open(e);
156
156
  s.onsuccess = e => {
157
157
  const s = e.target.result;
158
158
  if (!s.objectStoreNames.contains(t)) return s.close(), r(new Error(`Table ${t} not found`));
159
- const n = s.transaction(t, "readwrite").objectStore(t).clear();
160
- n.onsuccess = () => {
161
- s.close(), console.debug(`All data cleared from ${t}`), o();
162
- }, n.onerror = () => {
163
- s.close(), r(n.error);
159
+ const i = s.transaction(t, "readwrite").objectStore(t).clear();
160
+ i.onsuccess = () => {
161
+ s.close(), memorio.message(`All data cleared from ${t}`), o();
162
+ }, i.onerror = () => {
163
+ s.close(), r(i.error);
164
164
  };
165
165
  }, s.onerror = () => r(s.error);
166
166
  });
@@ -168,42 +168,42 @@ var e = Object.getOwnPropertyNames, t = (t, o) => function() {
168
168
  }), S = {}, P = t({
169
169
  "functions/idb/crud/data.set.ts"() {
170
170
  idb.data.set = (e, t, o) => new Promise((r, s) => {
171
- const n = indexedDB.open(e);
172
- n.onsuccess = () => {
173
- const i = n.result;
174
- if (!i.objectStoreNames.contains(t)) return i.close(), s(new Error(`Table ${t} does not exist in ${e}`));
175
- const l = i.transaction(t, "readwrite").objectStore(t).put(o);
176
- l.onsuccess = () => {
177
- i.close(), console.debug(`Data saved in ${e}.${t}`), r(l.result);
178
- }, l.onerror = e => {
179
- i.close(), console.debug(`Database insert error: ${l.error?.message}`), s(l.error);
171
+ const i = indexedDB.open(e);
172
+ i.onsuccess = () => {
173
+ const n = i.result;
174
+ if (!n.objectStoreNames.contains(t)) return n.close(), s(new Error(`Table ${t} does not exist in ${e}`));
175
+ const a = n.transaction(t, "readwrite").objectStore(t).put(o);
176
+ a.onsuccess = () => {
177
+ n.close(), memorio.message(`Data saved in ${e}.${t}`), r(a.result);
178
+ }, a.onerror = e => {
179
+ n.close(), memorio.message(`Database insert error: ${a.error?.message}`), s(a.error);
180
180
  };
181
- }, n.onerror = () => {
182
- s(n.error);
181
+ }, i.onerror = () => {
182
+ s(i.error);
183
183
  };
184
184
  });
185
185
  }
186
- }), E = {}, k = t({
186
+ }), E = {}, $ = t({
187
187
  "functions/idb/crud/data.get.ts"() {
188
188
  idb.data.get = (e, t, o) => new Promise((r, s) => {
189
- const n = indexedDB.open(e);
190
- n.onsuccess = n => {
191
- const i = n.target.result;
192
- if (!i.objectStoreNames.contains(t)) return i.close(), s(new Error(`Table ${t} not found in ${e}`));
193
- const l = i.transaction(t, "readonly").objectStore(t).get(o);
194
- l.onsuccess = () => {
195
- i.close(), r(l.result);
196
- }, l.onerror = () => {
197
- i.close(), s(l.error);
189
+ const i = indexedDB.open(e);
190
+ i.onsuccess = i => {
191
+ const n = i.target.result;
192
+ if (!n.objectStoreNames.contains(t)) return n.close(), s(new Error(`Table ${t} not found in ${e}`));
193
+ const a = n.transaction(t, "readonly").objectStore(t).get(o);
194
+ a.onsuccess = () => {
195
+ n.close(), r(a.result);
196
+ }, a.onerror = () => {
197
+ n.close(), s(a.error);
198
198
  };
199
- }, n.onerror = () => {
200
- s(n.error);
199
+ }, i.onerror = () => {
200
+ s(i.error);
201
201
  };
202
202
  });
203
203
  }
204
204
  });
205
205
 
206
- function _() {
206
+ function k() {
207
207
  const e = globalThis;
208
208
  if (void 0 !== e.crypto && e.crypto.randomUUID) return e.crypto.randomUUID();
209
209
  if (void 0 !== e.crypto && e.crypto.getRandomValues) {
@@ -213,7 +213,7 @@ function _() {
213
213
  return `session_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
214
214
  }
215
215
 
216
- function $() {
216
+ function _() {
217
217
  const e = globalThis;
218
218
  return e.Deno && e.Deno.version ? "deno" : "undefined" != typeof process && process.versions && process.versions.node ? "node" : "undefined" != typeof globalThis && void 0 !== globalThis.ServiceWorkerGlobalScope ? "edge" : "undefined" != typeof window && "undefined" != typeof document ? "browser" : "unknown";
219
219
  }
@@ -243,7 +243,7 @@ function I() {
243
243
  }
244
244
 
245
245
  function N() {
246
- const e = $(), t = void 0 !== globalThis.isSecureContext ? globalThis.isSecureContext : "browser" === e;
246
+ const e = _(), t = void 0 !== globalThis.isSecureContext ? globalThis.isSecureContext : "browser" === e;
247
247
  return {
248
248
  platform: e,
249
249
  hasSessionStorage: null !== D(),
@@ -253,7 +253,7 @@ function N() {
253
253
  hasNavigator: "undefined" != typeof navigator,
254
254
  hasProcess: "undefined" != typeof process,
255
255
  isSecureContext: t,
256
- sessionId: _()
256
+ sessionId: k()
257
257
  };
258
258
  }
259
259
 
@@ -262,7 +262,7 @@ var A = new Map;
262
262
  var z = new Map;
263
263
 
264
264
  function J(e) {
265
- const t = e || `context_${_()}`, o = {
265
+ const t = e || `context_${k()}`, o = {
266
266
  state: {},
267
267
  store: new Map,
268
268
  session: new Map,
@@ -321,7 +321,7 @@ Object.defineProperty(globalThis, "memorio", {
321
321
  }), Object.defineProperty(memorio, "version", {
322
322
  writable: !1,
323
323
  enumerable: !1,
324
- value: "4.0.0"
324
+ value: "4.1.0"
325
325
  }), Object.defineProperty(memorio, "debug", {
326
326
  writable: !0,
327
327
  enumerable: !1,
@@ -372,13 +372,13 @@ Object.defineProperty(memorio, "_sessionId", {
372
372
  }, memorio.deleteContext = function(e) {
373
373
  return z.delete(e);
374
374
  }, memorio.isBrowser = function() {
375
- return "browser" === $();
375
+ return "browser" === _();
376
376
  }, memorio.isNode = function() {
377
- return "node" === $();
377
+ return "node" === _();
378
378
  }, memorio.isDeno = function() {
379
- return "deno" === $();
379
+ return "deno" === _();
380
380
  }, memorio.isEdge = function() {
381
- return "edge" === $();
381
+ return "edge" === _();
382
382
  }, memorio.getCapabilities = N, memorio.isolate = function(e) {
383
383
  return J(e);
384
384
  }, Object.defineProperty(memorio, "dispatch", {
@@ -398,7 +398,9 @@ Object.defineProperty(memorio, "_sessionId", {
398
398
  t && (globalThis.removeEventListener(e, t), delete globalThis.events[e]);
399
399
  }
400
400
  }
401
- }), memorio.propertyName = (e, t) => String(t).replace("() => ", ""), Object.defineProperty(memorio, "objPath", {
401
+ }), memorio.propertyName = (e, t) => String(t).replace("() => ", ""), memorio.message = (...e) => {
402
+ !0 === memorio.debug && console.debug(...e);
403
+ }, Object.defineProperty(memorio, "objPath", {
402
404
  writable: !1,
403
405
  enumerable: !1,
404
406
  value: (e, t, o = ".") => {
@@ -412,7 +414,7 @@ globalThis.memorio._locked = !1;
412
414
  var M = (e, t, o = []) => new Proxy(e, {
413
415
  get(e, r) {
414
416
  if ("__path" === r) return o.length > 0 ? "state." + o.join(".") : "state";
415
- if ("list" === r) return console.debug('Some state could be hidden when you use "state.list". Use "state" to see the complete list '),
417
+ if ("list" === r) return memorio.message('Some state could be hidden when you use "state.list". Use "state" to see the complete list '),
416
418
  JSON.parse(JSON.stringify(globalThis.state));
417
419
  if (globalThis.memorio._tracking && "string" == typeof r) {
418
420
  const e = o.length > 0 ? "state." + o.concat(r).join(".") : "state." + r;
@@ -447,10 +449,10 @@ var M = (e, t, o = []) => new Proxy(e, {
447
449
  if (e[r] && "object" == typeof e[r] && e[r].__locked) return console.error(`Error: state '${r}' is locked. Use state.${r}.unlock() to enable modifications.`),
448
450
  !1;
449
451
  try {
450
- const n = globalThis.memorio.objPath?.(r, o) ?? r;
452
+ const i = globalThis.memorio.objPath?.(r, o) ?? r;
451
453
  if (t({
452
454
  action: "set",
453
- path: n,
455
+ path: i,
454
456
  target: e,
455
457
  newValue: s,
456
458
  previousValue: Reflect.get(e, r)
@@ -462,7 +464,7 @@ var M = (e, t, o = []) => new Proxy(e, {
462
464
  }
463
465
  });
464
466
  } catch (e) {}
465
- })("state." + n), Reflect.set(e, r, s), e[r] && "object" == typeof e[r]) {
467
+ })("state." + i), Reflect.set(e, r, s), e[r] && "object" == typeof e[r]) {
466
468
  const t = e[r];
467
469
  if (t && "object" == typeof t) try {
468
470
  Object.defineProperty(t, "__locked", {
@@ -480,7 +482,7 @@ var M = (e, t, o = []) => new Proxy(e, {
480
482
  enumerable: !1,
481
483
  configurable: !1,
482
484
  value: !0
483
- }), console.info(`State '${r}' is now locked.`);
485
+ }), memorio.message(`State '${r}' is now locked.`);
484
486
  }
485
487
  }), Object.defineProperty(t, "unlock", {
486
488
  writable: !1,
@@ -492,7 +494,7 @@ var M = (e, t, o = []) => new Proxy(e, {
492
494
  enumerable: !1,
493
495
  configurable: !1,
494
496
  value: !1
495
- }), console.info(`State '${r}' is now unlocked.`);
497
+ }), memorio.message(`State '${r}' is now unlocked.`);
496
498
  }
497
499
  });
498
500
  } catch (e) {}
@@ -519,9 +521,9 @@ var M = (e, t, o = []) => new Proxy(e, {
519
521
  });
520
522
 
521
523
  globalThis?.state || (globalThis.state = M({}, () => {})), globalThis.state.lock = () => {
522
- globalThis.memorio._locked = !0, console.info("State is now locked. All modifications are blocked.");
524
+ globalThis.memorio._locked = !0, memorio.message("State is now locked. All modifications are blocked.");
523
525
  }, globalThis.state.unlock = () => {
524
- globalThis.memorio._locked = !1, console.info("State is now unlocked. Modifications are allowed.");
526
+ globalThis.memorio._locked = !1, memorio.message("State is now unlocked. Modifications are allowed.");
525
527
  }, Object.defineProperty(globalThis, "state", {
526
528
  enumerable: !1,
527
529
  configurable: !0
@@ -546,7 +548,7 @@ globalThis.observer = (e, t = null, o = !0) => {
546
548
  }
547
549
  }, o = globalThis.observer;
548
550
  return o?.list?.[e] && globalThis.memorio.dispatch.remove(t), o?.list?.[e] || globalThis.memorio.dispatch.listen(t),
549
- void console.debug("called: ", e);
551
+ void memorio.message(`called: ${e}`);
550
552
  }
551
553
  if (e && t) {
552
554
  if ("string" != typeof e || "function" != typeof t) return void console.error("Observer Error: name of state need to be a 'string' like 'state.test' and the callback need to be a 'function'");
@@ -599,27 +601,27 @@ globalThis.observer = (e, t = null, o = !0) => {
599
601
  e();
600
602
  } catch (e) {}
601
603
  globalThis.memorio._tracking = !1, globalThis.memorio._trackedPaths?.forEach(t => {
602
- o.includes(t) || (console.info(`useObserver: [Auto-Discovery] -> "${t}"`), globalThis.memorio.dispatch.listen(t, () => e()),
604
+ o.includes(t) || (memorio.message(`useObserver: [Auto-Discovery] -> "${t}"`), globalThis.memorio.dispatch.listen(t, () => e()),
603
605
  o.push(t));
604
606
  });
605
607
  }
606
- }), o.length > 0 ? console.info(`useObserver: Monitoring ${o.length} paths.`) : console.warn("useObserver: No paths resolved for monitoring. Check your dependencies!"),
608
+ }), o.length > 0 ? memorio.message(`useObserver: Monitoring ${o.length} paths.`) : console.warn("useObserver: No paths resolved for monitoring. Check your dependencies!"),
607
609
  () => {
608
610
  o.forEach(e => {
609
611
  globalThis.memorio.dispatch && "function" == typeof globalThis.memorio.dispatch.remove && (globalThis.memorio.dispatch.remove(e),
610
- console.debug(`useObserver: Stopped monitoring "${e}"`));
612
+ memorio.message(`useObserver: Stopped monitoring "${e}"`));
611
613
  });
612
614
  };
613
615
  } catch (e) {
614
- return console.debug("useObserver Error:", e), () => {};
616
+ return memorio.message(`useObserver Error: ${e}`), () => {};
615
617
  }
616
618
  }, Object.freeze(globalThis.useObserver);
617
619
 
618
620
  var W = x(), R = new Map, U = null !== W, K = "memorio_store_";
619
621
 
620
622
  function F(e) {
621
- return e && "string" == typeof e ? e.length > 512 ? (console.debug("Key too long (max 512 characters)"),
622
- "") : /^[a-zA-Z0-9_.-]+$/.test(e) ? K + e : (console.debug("Key contains invalid characters (only a-z, A-Z, 0-9, _, ., - allowed)"),
623
+ return e && "string" == typeof e ? e.length > 512 ? (memorio.message("Key too long (max 512 characters)"),
624
+ "") : /^[a-zA-Z0-9_.-]+$/.test(e) ? K + e : (memorio.message("Key contains invalid characters (only a-z, A-Z, 0-9, _, ., - allowed)"),
623
625
  "") : "";
624
626
  }
625
627
 
@@ -642,7 +644,7 @@ Object.defineProperty(globalThis, "store", {
642
644
  return e ? JSON.parse(e) : e;
643
645
  }
644
646
  } catch (t) {
645
- console.debug(`Error parsing store item '${e}':`, t);
647
+ memorio.message(`Error parsing store item '${e}': ${t}`);
646
648
  }
647
649
  return null;
648
650
  }
@@ -653,10 +655,10 @@ Object.defineProperty(globalThis, "store", {
653
655
  const o = F(e);
654
656
  try {
655
657
  if (U) {
656
- 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 console.debug("Storing functions is not secure and is blocked for safety.");
657
- } 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 console.debug("Storing functions is not secure and is blocked for safety.");
658
+ if (null == t) W.setItem(o, JSON.stringify(null)); else if ("object" == typeof t || "number" == typeof t || "boolean" == typeof t || "string" == typeof t) W.setItem(o, JSON.stringify(t)); else if ("function" == typeof t) return void memorio.message("Storing functions is not secure and is blocked for safety.");
659
+ } else if (null == t) R.set(o, JSON.stringify(null)); else if ("object" == typeof t || "number" == typeof t || "boolean" == typeof t || "string" == typeof t) R.set(o, JSON.stringify(t)); else if ("function" == typeof t) return void memorio.message("Storing functions is not secure and is blocked for safety.");
658
660
  } catch (t) {
659
- console.debug(`Error setting store item '${e}':`, t);
661
+ memorio.message(`Error setting store item '${e}': ${t}`);
660
662
  }
661
663
  return null;
662
664
  }
@@ -670,7 +672,7 @@ Object.defineProperty(globalThis, "store", {
670
672
  if (W.getItem(t)) return W.removeItem(t), !0;
671
673
  } else if (R.has(t)) return R.delete(t), !0;
672
674
  } catch (t) {
673
- console.debug(`Error removing store item '${e}':`, t);
675
+ memorio.message(`Error removing store item '${e}': ${t}`);
674
676
  }
675
677
  return !1;
676
678
  }
@@ -738,7 +740,7 @@ Object.defineProperty(globalThis, "store", {
738
740
  }
739
741
  });
740
742
  } catch (e) {
741
- console.debug("Error listing store items:", e);
743
+ memorio.message(`Error listing store items: ${e}`);
742
744
  }
743
745
  return e;
744
746
  }
@@ -748,8 +750,8 @@ Object.defineProperty(globalThis, "store", {
748
750
  var q = D(), L = new Map, H = null !== q, V = "memorio_session_";
749
751
 
750
752
  function Y(e) {
751
- return e && "string" == typeof e ? e.length > 512 ? (console.debug("Key too long (max 512 characters)"),
752
- "") : /^[a-zA-Z0-9_.-]+$/.test(e) ? V + e : (console.debug("Key contains invalid characters (only a-z, A-Z, 0-9, _, ., - allowed)"),
753
+ return e && "string" == typeof e ? e.length > 512 ? (memorio.message("Key too long (max 512 characters)"),
754
+ "") : /^[a-zA-Z0-9_.-]+$/.test(e) ? V + e : (memorio.message("Key contains invalid characters (only a-z, A-Z, 0-9, _, ., - allowed)"),
753
755
  "") : "";
754
756
  }
755
757
 
@@ -772,7 +774,7 @@ Object.defineProperty(globalThis, "session", {
772
774
  return e ? JSON.parse(e) : e;
773
775
  }
774
776
  } catch (t) {
775
- console.debug(`Error parsing session item '${e}':`, t);
777
+ memorio.message(`Error parsing session item '${e}':${t}`);
776
778
  }
777
779
  }
778
780
  },
@@ -781,9 +783,9 @@ Object.defineProperty(globalThis, "session", {
781
783
  if (!e) return;
782
784
  const o = Y(e);
783
785
  try {
784
- 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 && console.debug("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 && console.debug("It's not secure to session functions.");
786
+ H ? null == t ? q.setItem(o, JSON.stringify(null)) : "object" == typeof t || "number" == typeof t || "boolean" == typeof t || "string" == typeof t ? q.setItem(o, JSON.stringify(t)) : "function" == typeof t && memorio.message("It's not secure to session functions.") : null == t ? L.set(o, JSON.stringify(null)) : "object" == typeof t || "number" == typeof t || "boolean" == typeof t || "string" == typeof t ? L.set(o, JSON.stringify(t)) : "function" == typeof t && memorio.message("It's not secure to session functions.");
785
787
  } catch (t) {
786
- console.debug(`Error setting session item '${e}':`, t);
788
+ memorio.message(`Error setting session item '${e}': ${t}`);
787
789
  }
788
790
  }
789
791
  },
@@ -796,7 +798,7 @@ Object.defineProperty(globalThis, "session", {
796
798
  if (q.getItem(t)) return q.removeItem(t), !0;
797
799
  } else if (L.has(t)) return L.delete(t), !0;
798
800
  } catch (t) {
799
- console.debug(`Error removing session item '${e}':`, t);
801
+ memorio.message(`Error removing session item '${e}': ${t}`);
800
802
  }
801
803
  }
802
804
  },
@@ -863,7 +865,7 @@ Object.defineProperty(globalThis, "session", {
863
865
  }
864
866
  });
865
867
  } catch (e) {
866
- console.debug("Error listing session items:", e);
868
+ memorio.message(`Error listing session items: ${e}`);
867
869
  }
868
870
  return e;
869
871
  }
@@ -900,13 +902,13 @@ Object.defineProperty(globalThis, "cache", {
900
902
  writable: !0,
901
903
  configurable: !0,
902
904
  enumerable: !1
903
- }), await Promise.all([ Promise.resolve().then(() => (r(), o)), Promise.resolve().then(() => (n(),
904
- s)), Promise.resolve().then(() => (l(), i)), Promise.resolve().then(() => (c(),
905
- a)), Promise.resolve().then(() => (u(), b)), Promise.resolve().then(() => (f(),
906
- d)), Promise.resolve().then(() => (h(), g)), Promise.resolve().then(() => (p(),
907
- m)), Promise.resolve().then(() => (y(), v)), Promise.resolve().then(() => (O(),
905
+ }), await Promise.all([ Promise.resolve().then(() => (r(), o)), Promise.resolve().then(() => (i(),
906
+ s)), Promise.resolve().then(() => (a(), n)), Promise.resolve().then(() => (c(),
907
+ l)), Promise.resolve().then(() => (b(), m)), Promise.resolve().then(() => (d(),
908
+ u)), Promise.resolve().then(() => (f(), g)), Promise.resolve().then(() => (p(),
909
+ h)), Promise.resolve().then(() => (y(), v)), Promise.resolve().then(() => (O(),
908
910
  T)), Promise.resolve().then(() => (w(), j)), Promise.resolve().then(() => (P(),
909
- S)), Promise.resolve().then(() => (k(), E)) ]), Object.preventExtensions(idb), Object.seal(idb),
911
+ S)), Promise.resolve().then(() => ($(), E)) ]), Object.preventExtensions(idb), Object.seal(idb),
910
912
  Object.freeze(idb);
911
913
  })() : (Object.defineProperty(globalThis, "idb", {
912
914
  value: {
@@ -1040,7 +1042,7 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "devt
1040
1042
  }
1041
1043
  },
1042
1044
  help: () => {
1043
- 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");
1045
+ console.log("\n🧠 Memorio DevTools Help\n\nAvailable commands:\n memorio.devtools.inspect() - Inspect all state modules\n memorio.devtools.stats() - Show statistics\n memorio.devtools.clear('module') - Clear specific module\n memorio.devtools.clearAll() - Clear all modules\n memorio.devtools.exportData() - Export all data as JSON\n memorio.devtools.importData(json) - Import data from JSON\n memorio.devtools.help() - Show this help\n\nShortcuts:\n state - globalThis.state\n store - globalThis.store\n session - globalThis.session\n cache - globalThis.cache\n");
1044
1046
  }
1045
1047
  }
1046
1048
  }), ee = "devtools", !1 === G || G && "object" == typeof G && !1 === G[ee] || (Object.defineProperty(globalThis, "$state", {
@@ -1062,7 +1064,7 @@ var oe = {
1062
1064
  logToConsole: !0,
1063
1065
  modules: [ "state", "store", "session", "cache", "idb" ],
1064
1066
  maxEntries: 1e3
1065
- }, re = [], se = e => oe.enabled && oe.modules.includes(e), ne = e => ({
1067
+ }, re = [], se = e => oe.enabled && oe.modules.includes(e), ie = e => ({
1066
1068
  state: "#4CAF50",
1067
1069
  store: "#2196F3",
1068
1070
  session: "#FF9800",
@@ -1089,7 +1091,7 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "logg
1089
1091
  isEnabled: se,
1090
1092
  log: (e, t, o, r, s) => {
1091
1093
  if (!se(e)) return;
1092
- const n = {
1094
+ const i = {
1093
1095
  timestamp: (new Date).toISOString(),
1094
1096
  module: e,
1095
1097
  action: t,
@@ -1097,12 +1099,12 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "logg
1097
1099
  value: r,
1098
1100
  previousValue: s
1099
1101
  };
1100
- if (re.push(n), re.length > oe.maxEntries && re.shift(), oe.logToConsole && !0 === globalThis.memorio?.debug) {
1101
- const n = `[Memorio:${e.toUpperCase()}]`, i = ne(e);
1102
- console.debug(`%c${n}%c ${t} ${o}`, `color: ${i}; font-weight: bold`, "color: inherit"),
1103
- void 0 !== r && console.debug(" → value:", r), void 0 !== s && console.debug(" ← previous:", s);
1102
+ if (re.push(i), re.length > oe.maxEntries && re.shift(), oe.logToConsole && !0 === globalThis.memorio?.debug) {
1103
+ const i = `[Memorio:${e.toUpperCase()}]`, n = ie(e);
1104
+ memorio.message(`%c${i}%c ${t} ${o},\n color: ${n}; font-weight: bold,\n color: inherit`),
1105
+ void 0 !== r && memorio.message(` → value:${r}`), void 0 !== s && memorio.message(` ← previous:${s}`);
1104
1106
  }
1105
- oe.customHandler && oe.customHandler(n);
1107
+ oe.customHandler && oe.customHandler(i);
1106
1108
  },
1107
1109
  getHistory: () => [ ...re ],
1108
1110
  clearHistory: () => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "memorio",
3
- "code": "memorio",
4
- "version": "4.0.0",
3
+ "codeName": "memorio",
4
+ "version": "4.1.0",
5
5
  "description": "Memorio, State + Observer, Store and iDB for an easy life - Cross-platform compatible",
6
6
  "main": "./index.cjs",
7
7
  "browser": "./index.cjs",
@@ -67,9 +67,18 @@
67
67
  }
68
68
  },
69
69
  "overrides": {
70
+ "es-define-property": "npm:@socketregistry/es-define-property@^1",
71
+ "es-set-tostringtag": "npm:@socketregistry/es-set-tostringtag@^1",
72
+ "function-bind": "npm:@socketregistry/function-bind@^1",
73
+ "gopd": "npm:@socketregistry/gopd@^1",
74
+ "has-symbols": "npm:@socketregistry/has-symbols@^1",
75
+ "has-tostringtag": "npm:@socketregistry/has-tostringtag@^1",
76
+ "hasown": "npm:@socketregistry/hasown@^1",
70
77
  "indent-string": "npm:@socketregistry/indent-string@^1",
71
78
  "object-assign": "npm:@socketregistry/object-assign@^1",
72
- "safer-buffer": "npm:@socketregistry/safer-buffer@^1"
79
+ "safe-buffer": "npm:@socketregistry/safe-buffer@^1",
80
+ "safer-buffer": "npm:@socketregistry/safer-buffer@^1",
81
+ "side-channel": "npm:@socketregistry/side-channel@^1"
73
82
  },
74
83
  "exports": {
75
84
  ".": {
@@ -6,6 +6,7 @@ interface _dispatch {
6
6
  }
7
7
 
8
8
  interface _memorio {
9
+ message: (props: string) => void
9
10
  setProps: (props: Record<string, unknown>) => void
10
11
  obj: Record<string, unknown>
11
12
  array: unknown[]