memorio 4.5.3 → 4.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -1,198 +1,409 @@
1
- var e = Object.getOwnPropertyNames, o = (o, t) => function() {
2
- return o && (t = (0, o[e(o)[0]])(o = 0)), t;
3
- }, t = {}, r = o({
1
+ Object.defineProperty(exports, "__esModule", {
2
+ value: !0
3
+ });
4
+
5
+ var e, t, r, o = Object.getOwnPropertyNames, s = (e, t) => function() {
6
+ return e && (t = (0, e[o(e)[0]])(e = 0)), t;
7
+ };
8
+
9
+ exports.propertyName = void 0, exports.internal = void 0;
10
+
11
+ var n, i = s({
12
+ "core/internal.ts"() {
13
+ e = {
14
+ debug: !1,
15
+ tracking: !1,
16
+ trackedPaths: new Set,
17
+ locked: !1,
18
+ lastAccessedPath: "",
19
+ stateVersion: 0,
20
+ currentContext: null
21
+ }, t = {
22
+ get debug() {
23
+ return e.debug;
24
+ },
25
+ set debug(t) {
26
+ e.debug = t;
27
+ },
28
+ get tracking() {
29
+ return e.tracking;
30
+ },
31
+ set tracking(t) {
32
+ e.tracking = t;
33
+ },
34
+ get trackedPaths() {
35
+ return e.trackedPaths;
36
+ },
37
+ clearTrackedPaths() {
38
+ e.trackedPaths.clear();
39
+ },
40
+ get locked() {
41
+ return e.locked;
42
+ },
43
+ set locked(t) {
44
+ e.locked = t;
45
+ },
46
+ get lastAccessedPath() {
47
+ return e.lastAccessedPath;
48
+ },
49
+ set lastAccessedPath(t) {
50
+ e.lastAccessedPath = t;
51
+ },
52
+ get stateVersion() {
53
+ return e.stateVersion;
54
+ },
55
+ bumpStateVersion: () => (e.stateVersion = (e.stateVersion || 0) + 1, e.stateVersion),
56
+ get currentContext() {
57
+ return e.currentContext;
58
+ },
59
+ set currentContext(t) {
60
+ e.currentContext = t;
61
+ }
62
+ }, r = [ "list", "state", "store", "idb", "observer", "useObserver", "remove", "removeAll", "_platform", "_capabilities", "_sessionId" ],
63
+ exports.propertyName = (e, t) => String(void 0 !== t ? t : e).replace("() => ", ""),
64
+ exports.internal = t;
65
+ }
66
+ });
67
+
68
+ exports.message = void 0;
69
+
70
+ var a, l, c = s({
71
+ "functions/message/index.ts"() {
72
+ i(), exports.message = (...e) => {
73
+ !0 === exports.internal.debug && console.debug(...e);
74
+ }, n = exports.message;
75
+ }
76
+ });
77
+
78
+ function u() {
79
+ const e = globalThis;
80
+ if (void 0 !== e.crypto && e.crypto.randomUUID) return e.crypto.randomUUID();
81
+ if (void 0 !== e.crypto && e.crypto.getRandomValues) {
82
+ const t = new Uint8Array(16);
83
+ return e.crypto.getRandomValues(t), Array.from(t, e => e.toString(16).padStart(2, "0")).join("");
84
+ }
85
+ return `session_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
86
+ }
87
+
88
+ function d() {
89
+ const e = globalThis;
90
+ 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";
91
+ }
92
+
93
+ function b() {
94
+ return "browser" === d();
95
+ }
96
+
97
+ function f() {
98
+ return "node" === d();
99
+ }
100
+
101
+ function p() {
102
+ return "deno" === d();
103
+ }
104
+
105
+ function g() {
106
+ return "edge" === d();
107
+ }
108
+
109
+ function m() {
110
+ try {
111
+ if ("undefined" != typeof sessionStorage) {
112
+ const e = "__memorio_test__";
113
+ return sessionStorage.setItem(e, "1"), sessionStorage.removeItem(e), sessionStorage;
114
+ }
115
+ } catch (e) {}
116
+ return null;
117
+ }
118
+
119
+ function h() {
120
+ try {
121
+ if ("undefined" != typeof localStorage) {
122
+ const e = "__memorio_test__";
123
+ return localStorage.setItem(e, "1"), localStorage.removeItem(e), localStorage;
124
+ }
125
+ } catch (e) {}
126
+ return null;
127
+ }
128
+
129
+ function v() {
130
+ return "undefined" != typeof indexedDB;
131
+ }
132
+
133
+ function y() {
134
+ const e = d(), t = void 0 !== globalThis.isSecureContext ? globalThis.isSecureContext : "browser" === e;
135
+ return {
136
+ platform: e,
137
+ hasSessionStorage: null !== m(),
138
+ hasLocalStorage: null !== h(),
139
+ hasIndexedDB: v(),
140
+ hasDispatchEvent: "function" == typeof globalThis.dispatchEvent,
141
+ hasNavigator: "undefined" != typeof navigator,
142
+ hasProcess: "undefined" != typeof process,
143
+ isSecureContext: t,
144
+ sessionId: u()
145
+ };
146
+ }
147
+
148
+ function x(e) {
149
+ const t = e || `context_${u()}`;
150
+ w(t);
151
+ const r = {
152
+ state: {},
153
+ store: new Map,
154
+ session: new Map,
155
+ cache: new Map
156
+ };
157
+ return l.set(t, r), {
158
+ id: t,
159
+ state: r.state,
160
+ store: {
161
+ get: e => {
162
+ const t = r.store.get(e);
163
+ return t ? JSON.parse(t) : null;
164
+ },
165
+ set: (e, t) => {
166
+ r.store.set(e, JSON.stringify(t));
167
+ },
168
+ remove: e => r.store.delete(e),
169
+ removeAll: () => r.store.clear(),
170
+ clearAll: () => r.store.clear(),
171
+ size: () => r.store.size,
172
+ isPersistent: !1
173
+ },
174
+ session: {
175
+ get: e => {
176
+ const t = r.session.get(e);
177
+ return t ? JSON.parse(t) : null;
178
+ },
179
+ set: (e, t) => {
180
+ r.session.set(e, JSON.stringify(t));
181
+ },
182
+ remove: e => r.session.delete(e),
183
+ removeAll: () => r.session.clear(),
184
+ clearAll: () => r.session.clear(),
185
+ size: () => r.session.size,
186
+ isPersistent: !1
187
+ },
188
+ cache: {
189
+ get: e => r.cache.get(e),
190
+ set: (e, t) => r.cache.set(e, t),
191
+ remove: e => r.cache.delete(e),
192
+ removeAll: () => r.cache.clear(),
193
+ clear: () => r.cache.clear()
194
+ }
195
+ };
196
+ }
197
+
198
+ function T() {
199
+ return Array.from(l.keys());
200
+ }
201
+
202
+ function O(e) {
203
+ return l.delete(e);
204
+ }
205
+
206
+ function w(e) {
207
+ exports.internal.currentContext = e;
208
+ }
209
+
210
+ var P, j = s({
211
+ "core/platform.ts"() {
212
+ i(), a = new Map, l = new Map;
213
+ }
214
+ }), S = {}, E = s({
4
215
  "functions/idb/tools/db.create.ts"() {
5
- idb.db.create = (e, o = 1) => new Promise((t, r) => {
6
- if (!idb.db.support()) return r(new Error("IndexedDB not supported"));
7
- const s = globalThis.indexedDB.open(e, o);
216
+ Q(), c(), exports.idb.db.create = (e, t = 1) => new Promise((r, o) => {
217
+ if (!exports.idb.db.support()) return o(new Error("IndexedDB not supported"));
218
+ const s = globalThis.indexedDB.open(e, t);
8
219
  s.onerror = () => {
9
- memorio.message(`IndexedDB error: ${s.error?.message}`), r(s.error);
220
+ n(`IndexedDB error: ${s.error?.message}`), o(s.error);
10
221
  }, s.onsuccess = () => {
11
- memorio.message(`Database ${e} connected successfully`), t(s.result);
222
+ n(`Database ${e} connected successfully`), r(s.result);
12
223
  }, s.onupgradeneeded = () => {
13
- memorio.message(`Database ${e} upgrade/creation initiated`);
224
+ n(`Database ${e} upgrade/creation initiated`);
14
225
  };
15
226
  });
16
227
  }
17
- }), s = {}, n = o({
228
+ }), $ = {}, k = s({
18
229
  "functions/idb/tools/db.list.ts"() {
19
- idb.db.list = async () => {
230
+ Q(), exports.idb.db.list = async () => {
20
231
  if (!("indexedDB" in globalThis) || !indexedDB.databases) return [];
21
232
  try {
22
233
  const e = await indexedDB.databases();
23
- return globalThis.idbases = e || [], await idb.db.size(), globalThis.idbases;
234
+ return globalThis.idbases = e || [], await exports.idb.db.size(), globalThis.idbases;
24
235
  } catch (e) {
25
236
  return console.error("Error listing databases:", e), [];
26
237
  }
27
238
  };
28
239
  }
29
- }), i = {}, a = o({
240
+ }), D = {}, C = s({
30
241
  "functions/idb/tools/db.exist.ts"() {
31
- idb.db.exist = e => idbases?.some(o => o.name === e);
242
+ Q(), exports.idb.db.exist = e => idbases?.some(t => t.name === e);
32
243
  }
33
- }), l = {}, c = o({
244
+ }), A = {}, _ = s({
34
245
  "functions/idb/tools/db.quota.ts"() {
35
- idb.db.quota = () => navigator.storage.estimate();
246
+ Q(), exports.idb.db.quota = () => navigator.storage.estimate();
36
247
  }
37
- }), m = {}, u = o({
248
+ }), I = {}, N = s({
38
249
  "functions/idb/tools/db.delete.ts"() {
39
- idb.db.delete = e => new Promise((o, t) => {
40
- memorio.message(`Removing database ${e}...`);
250
+ Q(), c(), exports.idb.db.delete = e => new Promise((t, r) => {
251
+ n(`Removing database ${e}...`);
41
252
  (() => {
42
- const r = indexedDB.deleteDatabase(e);
43
- r.onsuccess = () => {
44
- memorio.message(`${e} database removed successfully`), idb.db.list(), o();
45
- }, r.onerror = () => {
46
- console.error(`Error removing ${e}:`, r.error), t(r.error);
47
- }, r.onblocked = () => {
253
+ const o = indexedDB.deleteDatabase(e);
254
+ o.onsuccess = () => {
255
+ n(`${e} database removed successfully`), exports.idb.db.list(), t();
256
+ }, o.onerror = () => {
257
+ console.error(`Error removing ${e}:`, o.error), r(o.error);
258
+ }, o.onblocked = () => {
48
259
  console.warn(`Deletion of ${e} is blocked. Please close other tabs.`);
49
260
  };
50
261
  })();
51
262
  });
52
263
  }
53
- }), b = {}, d = o({
264
+ }), z = {}, B = s({
54
265
  "functions/idb/tools/db.size.ts"() {
55
- idb.db.size = async () => {
266
+ Q(), c(), exports.idb.db.size = async () => {
56
267
  if (idbases && 0 !== idbases.length) for (let e = 0; e < idbases.length; e++) {
57
- const o = idbases[e];
268
+ const t = idbases[e];
58
269
  try {
59
- const e = await idb.db.create(o.name, o.version), t = Array.from(e.objectStoreNames);
60
- let r = 0;
61
- for (const o of t) {
62
- r += await idb.table.size(e, o);
270
+ const e = await exports.idb.db.create(t.name, t.version), r = Array.from(e.objectStoreNames);
271
+ let o = 0;
272
+ for (const t of r) {
273
+ o += await exports.idb.table.size(e, t);
63
274
  }
64
- o.size = r, e.close();
275
+ t.size = o, e.close();
65
276
  } catch (e) {
66
- memorio.message(`Could not calculate size for ${o.name}:${e}`);
277
+ n(`Could not calculate size for ${t.name}:${e}`);
67
278
  }
68
279
  }
69
280
  };
70
281
  }
71
- }), g = {}, f = o({
282
+ }), M = {}, J = s({
72
283
  "functions/idb/tools/db.version.ts"() {
73
- idb.db.version = e => {
74
- let o = 0;
75
- for (const t of idbases) {
76
- t.name === e && (o = t.version);
284
+ Q(), exports.idb.db.version = e => {
285
+ let t = 0;
286
+ for (const r of idbases) {
287
+ r.name === e && (t = r.version);
77
288
  break;
78
289
  }
79
- return o;
290
+ return t;
80
291
  };
81
292
  }
82
- }), h = {}, p = o({
293
+ }), W = {}, R = s({
83
294
  "functions/idb/tools/db.support.ts"() {
84
- idb.db.support = () => {
295
+ Q(), c(), exports.idb.db.support = () => {
85
296
  const e = "indexedDB" in globalThis;
86
- return e || memorio.message("Your environment doesn't support IndexedDB"), e;
297
+ return e || n("Your environment doesn't support IndexedDB"), e;
87
298
  };
88
299
  }
89
- }), v = {}, y = o({
300
+ }), V = {}, U = s({
90
301
  "functions/idb/tools/table.create.ts"() {
91
- idb.table.create = (e, o) => new Promise((t, r) => {
302
+ Q(), c(), exports.idb.table.create = (e, t) => new Promise((r, o) => {
92
303
  try {
93
- const s = (Number(idb.db.version(e)) || 0) + 1, n = indexedDB.open(e, s);
94
- n.onupgradeneeded = t => {
95
- const r = t.target.result;
96
- if (!r.objectStoreNames.contains(o)) {
97
- const t = r.createObjectStore(o, {
304
+ const s = (Number(exports.idb.db.version(e)) || 0) + 1, i = indexedDB.open(e, s);
305
+ i.onupgradeneeded = r => {
306
+ const o = r.target.result;
307
+ if (!o.objectStoreNames.contains(t)) {
308
+ const r = o.createObjectStore(t, {
98
309
  keyPath: "id",
99
310
  autoIncrement: !0
100
311
  });
101
- t.createIndex("id", "id", {
312
+ r.createIndex("id", "id", {
102
313
  unique: !0
103
- }), t.createIndex("data", "data", {
314
+ }), r.createIndex("data", "data", {
104
315
  unique: !1
105
- }), memorio.message(`Table ${o} created in ${e}`);
316
+ }), n(`Table ${t} created in ${e}`);
106
317
  }
107
- }, n.onsuccess = () => {
108
- n.result.close(), idb.db.list(), t();
109
- }, n.onerror = () => {
110
- console.error(`Error creating table ${o}:`, n.error), r(n.error);
318
+ }, i.onsuccess = () => {
319
+ i.result.close(), exports.idb.db.list(), r();
320
+ }, i.onerror = () => {
321
+ console.error(`Error creating table ${t}:`, i.error), o(i.error);
111
322
  };
112
323
  } catch (e) {
113
- console.error("Critical error in table.create:", e), r(e);
324
+ console.error("Critical error in table.create:", e), o(e);
114
325
  }
115
326
  });
116
327
  }
117
- }), T = {}, O = o({
328
+ }), K = {}, q = s({
118
329
  "functions/idb/tools/table.size.ts"() {
119
- idb.table.size = (e, o) => new Promise((t, r) => {
120
- if (!e) return r(new Error("Database instance is required"));
121
- if (!e.objectStoreNames.contains(o)) return t(0);
122
- let s = 0, n = 0;
123
- const i = e.transaction([ o ], "readonly").objectStore(o).openCursor();
124
- i.onsuccess = async e => {
125
- const o = e.target.result;
126
- if (o) {
330
+ Q(), c(), exports.idb.table.size = (e, t) => new Promise((r, o) => {
331
+ if (!e) return o(new Error("Database instance is required"));
332
+ if (!e.objectStoreNames.contains(t)) return r(0);
333
+ let s = 0, i = 0;
334
+ const a = e.transaction([ t ], "readonly").objectStore(t).openCursor();
335
+ a.onsuccess = async e => {
336
+ const t = e.target.result;
337
+ if (t) {
127
338
  try {
128
- const e = o.value;
339
+ const e = t.value;
129
340
  s += JSON.stringify(e).length;
130
341
  } catch (e) {
131
- memorio.message(`Error stringifying IDB value tracking size:${e}`);
342
+ n(`Error stringifying IDB value tracking size:${e}`);
132
343
  }
133
- n++, n % 200 == 0 && await new Promise(e => setTimeout(e, 0)), o.continue();
134
- } else t(s);
135
- }, i.onerror = () => {
136
- r(i.error);
344
+ i++, i % 200 == 0 && await new Promise(e => setTimeout(e, 0)), t.continue();
345
+ } else r(s);
346
+ }, a.onerror = () => {
347
+ o(a.error);
137
348
  };
138
349
  });
139
350
  }
140
- }), w = {}, j = o({
351
+ }), F = {}, L = s({
141
352
  "functions/idb/crud/data.delete.ts"() {
142
- idb.data.delete = (e, o, t) => new Promise((r, s) => {
143
- const n = indexedDB.open(e);
144
- n.onsuccess = () => {
145
- const e = n.result;
146
- if (!e.objectStoreNames.contains(o)) return e.close(), s(new Error(`Table ${o} not found`));
147
- const i = e.transaction(o, "readwrite").objectStore(o).delete(t);
148
- i.onsuccess = () => {
149
- e.close(), memorio.message(`Record ${t} deleted from ${o}`), r();
150
- }, i.onerror = () => {
151
- e.close(), s(i.error);
353
+ Q(), c(), exports.idb.data.delete = (e, t, r) => new Promise((o, s) => {
354
+ const i = indexedDB.open(e);
355
+ i.onsuccess = () => {
356
+ const e = i.result;
357
+ if (!e.objectStoreNames.contains(t)) return e.close(), s(new Error(`Table ${t} not found`));
358
+ const a = e.transaction(t, "readwrite").objectStore(t).delete(r);
359
+ a.onsuccess = () => {
360
+ e.close(), n(`Record ${r} deleted from ${t}`), o();
361
+ }, a.onerror = () => {
362
+ e.close(), s(a.error);
152
363
  };
153
- }, n.onerror = () => s(n.error);
154
- }), idb.data.delete.all = (e, o) => new Promise((t, r) => {
364
+ }, i.onerror = () => s(i.error);
365
+ }), exports.idb.data.delete.all = (e, t) => new Promise((r, o) => {
155
366
  const s = indexedDB.open(e);
156
367
  s.onsuccess = e => {
157
368
  const s = e.target.result;
158
- if (!s.objectStoreNames.contains(o)) return s.close(), r(new Error(`Table ${o} not found`));
159
- const n = s.transaction(o, "readwrite").objectStore(o).clear();
160
- n.onsuccess = () => {
161
- s.close(), memorio.message(`All data cleared from ${o}`), t();
162
- }, n.onerror = () => {
163
- s.close(), r(n.error);
369
+ if (!s.objectStoreNames.contains(t)) return s.close(), o(new Error(`Table ${t} not found`));
370
+ const i = s.transaction(t, "readwrite").objectStore(t).clear();
371
+ i.onsuccess = () => {
372
+ s.close(), n(`All data cleared from ${t}`), r();
373
+ }, i.onerror = () => {
374
+ s.close(), o(i.error);
164
375
  };
165
- }, s.onerror = () => r(s.error);
376
+ }, s.onerror = () => o(s.error);
166
377
  });
167
378
  }
168
- }), S = {}, P = o({
379
+ }), H = {}, Y = s({
169
380
  "functions/idb/crud/data.set.ts"() {
170
- idb.data.set = (e, o, t) => new Promise((r, s) => {
171
- const n = indexedDB.open(e);
172
- n.onsuccess = () => {
173
- const i = n.result;
174
- if (!i.objectStoreNames.contains(o)) return i.close(), s(new Error(`Table ${o} does not exist in ${e}`));
175
- const a = i.transaction(o, "readwrite").objectStore(o).put(t);
176
- a.onsuccess = () => {
177
- i.close(), memorio.message(`Data saved in ${e}.${o}`), r(a.result);
178
- }, a.onerror = e => {
179
- i.close(), memorio.message(`Database insert error: ${a.error?.message}`), s(a.error);
381
+ Q(), c(), exports.idb.data.set = (e, t, r) => new Promise((o, s) => {
382
+ const i = indexedDB.open(e);
383
+ i.onsuccess = () => {
384
+ const a = i.result;
385
+ if (!a.objectStoreNames.contains(t)) return a.close(), s(new Error(`Table ${t} does not exist in ${e}`));
386
+ const l = a.transaction(t, "readwrite").objectStore(t).put(r);
387
+ l.onsuccess = () => {
388
+ a.close(), n(`Data saved in ${e}.${t}`), o(l.result);
389
+ }, l.onerror = e => {
390
+ a.close(), n(`Database insert error: ${l.error?.message}`), s(l.error);
180
391
  };
181
- }, n.onerror = () => {
182
- s(n.error);
392
+ }, i.onerror = () => {
393
+ s(i.error);
183
394
  };
184
395
  });
185
396
  }
186
- }), _ = {}, E = o({
397
+ }), Z = {}, G = s({
187
398
  "functions/idb/crud/data.get.ts"() {
188
- idb.data.get = (e, o, t) => new Promise((r, s) => {
399
+ Q(), exports.idb.data.get = (e, t, r) => new Promise((o, s) => {
189
400
  const n = indexedDB.open(e);
190
401
  n.onsuccess = n => {
191
402
  const i = n.target.result;
192
- if (!i.objectStoreNames.contains(o)) return i.close(), s(new Error(`Table ${o} not found in ${e}`));
193
- const a = i.transaction(o, "readonly").objectStore(o).get(t);
403
+ if (!i.objectStoreNames.contains(t)) return i.close(), s(new Error(`Table ${t} not found in ${e}`));
404
+ const a = i.transaction(t, "readonly").objectStore(t).get(r);
194
405
  a.onsuccess = () => {
195
- i.close(), r(a.result);
406
+ i.close(), o(a.result);
196
407
  }, a.onerror = () => {
197
408
  i.close(), s(a.error);
198
409
  };
@@ -203,575 +414,287 @@ var e = Object.getOwnPropertyNames, o = (o, t) => function() {
203
414
  }
204
415
  });
205
416
 
206
- function $() {
207
- const e = globalThis;
208
- if (void 0 !== e.crypto && e.crypto.randomUUID) return e.crypto.randomUUID();
209
- if (void 0 !== e.crypto && e.crypto.getRandomValues) {
210
- const o = new Uint8Array(16);
211
- return e.crypto.getRandomValues(o), Array.from(o, e => e.toString(16).padStart(2, "0")).join("");
212
- }
213
- return `session_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
214
- }
417
+ exports.idb = void 0;
215
418
 
216
- function k() {
217
- const e = globalThis;
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
- }
220
-
221
- function x() {
222
- try {
223
- if ("undefined" != typeof sessionStorage) {
224
- const e = "__memorio_test__";
225
- return sessionStorage.setItem(e, "1"), sessionStorage.removeItem(e), sessionStorage;
226
- }
227
- } catch (e) {}
228
- return null;
229
- }
230
-
231
- function D() {
232
- try {
233
- if ("undefined" != typeof localStorage) {
234
- const e = "__memorio_test__";
235
- return localStorage.setItem(e, "1"), localStorage.removeItem(e), localStorage;
236
- }
237
- } catch (e) {}
238
- return null;
239
- }
240
-
241
- function A() {
242
- return "undefined" != typeof indexedDB;
243
- }
244
-
245
- function I() {
246
- const e = k(), o = void 0 !== globalThis.isSecureContext ? globalThis.isSecureContext : "browser" === e;
247
- return {
248
- platform: e,
249
- hasSessionStorage: null !== x(),
250
- hasLocalStorage: null !== D(),
251
- hasIndexedDB: A(),
252
- hasDispatchEvent: "function" == typeof globalThis.dispatchEvent,
253
- hasNavigator: "undefined" != typeof navigator,
254
- hasProcess: "undefined" != typeof process,
255
- isSecureContext: o,
256
- sessionId: $()
257
- };
258
- }
259
-
260
- var N = new Map;
261
-
262
- var C = new Map;
263
-
264
- function J(e) {
265
- const o = e || `context_${$()}`;
266
- !function(e) {
267
- const o = globalThis;
268
- o.memorio || (o.memorio = {});
269
- o.memorio._currentContext = e;
270
- }(o);
271
- const t = {
272
- state: {},
273
- store: new Map,
274
- session: new Map,
275
- cache: new Map
276
- };
277
- return C.set(o, t), {
278
- id: o,
279
- state: t.state,
280
- store: {
281
- get: e => {
282
- const o = t.store.get(e);
283
- return o ? JSON.parse(o) : null;
284
- },
285
- set: (e, o) => {
286
- t.store.set(e, JSON.stringify(o));
287
- },
288
- remove: e => t.store.delete(e),
289
- removeAll: () => t.store.clear(),
290
- clearAll: () => t.store.clear(),
291
- size: () => t.store.size,
292
- isPersistent: !1
293
- },
294
- session: {
295
- get: e => {
296
- const o = t.session.get(e);
297
- return o ? JSON.parse(o) : null;
298
- },
299
- set: (e, o) => {
300
- t.session.set(e, JSON.stringify(o));
301
- },
302
- remove: e => t.session.delete(e),
303
- removeAll: () => t.session.clear(),
304
- clearAll: () => t.session.clear(),
305
- size: () => t.session.size,
306
- isPersistent: !1
307
- },
308
- cache: {
309
- get: e => t.cache.get(e),
310
- set: (e, o) => t.cache.set(e, o),
311
- remove: e => t.cache.delete(e),
312
- removeAll: () => t.cache.clear(),
313
- clear: () => t.cache.clear()
314
- }
315
- };
316
- }
317
-
318
- var z = "4.5.3";
319
-
320
- Object.defineProperty(globalThis, "memorio", {
321
- value: {
322
- setProps: () => {},
323
- obj: {},
324
- array: [],
325
- dispatch: {
326
- set: () => {},
327
- listen: () => {},
328
- remove: () => {}
329
- },
330
- setDescription: () => {}
331
- },
332
- writable: !1,
333
- configurable: !0,
334
- enumerable: !1
335
- }), Object.defineProperty(globalThis, "events", {
336
- value: {},
337
- writable: !0,
338
- enumerable: !1
339
- }), Object.defineProperty(memorio, "version", {
340
- writable: !1,
341
- enumerable: !1,
342
- value: z
343
- }), Object.defineProperty(memorio, "debug", {
344
- writable: !0,
345
- enumerable: !1,
346
- value: !1
419
+ var Q = s({
420
+ "functions/idb/index.ts"() {
421
+ j(), P = v(), exports.idb = {
422
+ db: {},
423
+ table: {},
424
+ data: {}
425
+ }, P ? (async () => {
426
+ Object.defineProperty(exports.idb, "db", {
427
+ value: {},
428
+ writable: !0,
429
+ configurable: !0
430
+ }), Object.defineProperty(exports.idb, "table", {
431
+ value: {},
432
+ writable: !0,
433
+ configurable: !0
434
+ }), Object.defineProperty(exports.idb, "data", {
435
+ value: {},
436
+ writable: !0,
437
+ configurable: !0
438
+ }), Object.defineProperty(globalThis, "idbases", {
439
+ value: [],
440
+ writable: !0,
441
+ configurable: !0,
442
+ enumerable: !1
443
+ }), await Promise.all([ Promise.resolve().then(() => (E(), S)), Promise.resolve().then(() => (k(),
444
+ $)), Promise.resolve().then(() => (C(), D)), Promise.resolve().then(() => (_(),
445
+ A)), Promise.resolve().then(() => (N(), I)), Promise.resolve().then(() => (B(),
446
+ z)), Promise.resolve().then(() => (J(), M)), Promise.resolve().then(() => (R(),
447
+ W)), Promise.resolve().then(() => (U(), V)), Promise.resolve().then(() => (q(),
448
+ K)), Promise.resolve().then(() => (L(), F)), Promise.resolve().then(() => (Y(),
449
+ H)), Promise.resolve().then(() => (G(), Z)) ]), Object.preventExtensions(exports.idb),
450
+ Object.seal(exports.idb), Object.freeze(exports.idb);
451
+ })() : (exports.idb._disabled = !0, exports.idb._warning = "IndexedDB is not available in this environment (Node.js/Deno). Use store or session for persistence.",
452
+ console.warn("Memorio IDB: IndexedDB is not available in this environment. Use store or session for data persistence."));
453
+ }
347
454
  });
348
455
 
349
- var B = [ "list", "state", "store", "idb", "observer", "useObserver", "remove", "removeAll", "_platform", "_capabilities", "_sessionId" ];
456
+ i(), c();
350
457
 
351
- !function() {
352
- const e = I(), o = globalThis;
353
- void 0 !== o.memorio && (o.memorio._platform = e.platform, o.memorio._capabilities = e),
354
- e.hasDispatchEvent || (o.dispatchEvent = function(e) {
355
- return !0;
356
- }, "undefined" == typeof CustomEvent && (o.CustomEvent = class {
357
- type;
358
- detail;
359
- constructor(e, o = {}) {
360
- this.type = e, this.detail = o;
361
- }
362
- })), "function" != typeof o.addEventListener && (o.addEventListener = function(e, o) {
363
- N.has(e) || N.set(e, []), N.get(e).push(o);
364
- }, o.removeEventListener = function(e, o) {
365
- const t = N.get(e);
366
- if (t) {
367
- const e = t.indexOf(o);
368
- e > -1 && t.splice(e, 1);
369
- }
370
- }, o.dispatchEvent = function(e) {
371
- const o = N.get(e.type);
372
- return o && o.forEach(o => {
373
- try {
374
- o(e);
375
- } catch (e) {
376
- console.error("Event listener error:", e);
377
- }
378
- }), !0;
379
- });
380
- }();
381
-
382
- var M = I();
383
-
384
- Object.defineProperty(memorio, "_sessionId", {
385
- writable: !1,
386
- enumerable: !1,
387
- value: M.sessionId
388
- }), memorio.createContext = J, memorio.listContexts = function() {
389
- return Array.from(C.keys());
390
- }, memorio.deleteContext = function(e) {
391
- return C.delete(e);
392
- }, memorio.isBrowser = function() {
393
- return "browser" === k();
394
- }, memorio.isNode = function() {
395
- return "node" === k();
396
- }, memorio.isDeno = function() {
397
- return "deno" === k();
398
- }, memorio.isEdge = function() {
399
- return "edge" === k();
400
- }, memorio.getCapabilities = I, memorio.isolate = function(e) {
401
- return J(e);
402
- }, memorio.help = function() {
403
- console.debug(`\n🧠 Memorio ${z} - Help\n\nCore Modules:\n state - Reactive state management\n store - Persistent storage (localStorage/Map)\n session - Session storage (sessionStorage/Map)\n cache - In-memory cache\n idb - IndexedDB (browser only)\n\nContext Management:\n memorio.isolate(name) - Create isolated context\n memorio.listContexts() - List all contexts\n memorio.deleteContext(id) - Delete a context\n\nPlatform Detection:\n memorio.isBrowser() - Browser environment\n memorio.isNode() - Node.js environment\n memorio.isDeno() - Deno environment\n memorio.isEdge() - Edge/Worker environment\n memorio.getCapabilities() - Full capabilities object\n\nDevTools:\n memorio.devtools.inspect() - Inspect all modules\n memorio.devtools.stats() - Show statistics\n memorio.devtools.watch() - Watch a path\n memorio.devtools.exportData() - Export as JSON\n memorio.devtools.importData() - Import from JSON\n memorio.devtools.clear() - Clear specific module\n memorio.devtools.clearAll() - Clear all modules\n\nShortcuts:\n state, store, session, cache, idb - direct access to modules\n`);
404
- }, Object.defineProperty(memorio, "dispatch", {
405
- writable: !1,
406
- enumerable: !1,
407
- value: {
408
- set: (e, o = {}) => {
409
- globalThis.dispatchEvent(new CustomEvent(String(e), o));
410
- },
411
- listen: (e, o = null) => {
412
- const t = globalThis.observer?.list?.[e];
413
- t && t.length > 0 && globalThis.observer?.remove?.(e);
414
- const r = o ? e => {
415
- const t = e;
416
- return globalThis.queueMicrotask ? globalThis.queueMicrotask(() => o(t)) : Promise.resolve().then(() => o(t));
417
- } : void 0;
418
- r && globalThis.addEventListener(e, r), r && (globalThis.events[e] = r);
419
- },
420
- remove: e => {
421
- const o = globalThis.events?.[e];
422
- o && (globalThis.removeEventListener(e, o), delete globalThis.events[e]);
423
- }
424
- }
425
- }), memorio.propertyName = (e, o) => String(o).replace("() => ", ""), memorio.message = (...e) => {
426
- !0 === memorio.debug && console.debug(...e);
427
- }, Object.defineProperty(memorio, "objPath", {
428
- writable: !1,
429
- enumerable: !1,
430
- value: (e, o, t = ".") => {
431
- const r = o.concat(e).join(t);
432
- return globalThis.memorio._tracking && globalThis.memorio._trackedPaths?.add("state." + r),
433
- r;
458
+ var X = {
459
+ set: (e, t = {}) => {
460
+ globalThis.dispatchEvent(new CustomEvent(String(e), t));
461
+ },
462
+ listen: (e, t = null, r) => {
463
+ if (globalThis.events?.[e]) return;
464
+ const o = t ? e => {
465
+ const r = e;
466
+ return globalThis.queueMicrotask ? globalThis.queueMicrotask(() => t(r)) : Promise.resolve().then(() => t(r));
467
+ } : void 0;
468
+ o && globalThis.addEventListener(e, o), o && (globalThis.events[e] = o);
469
+ },
470
+ remove: e => {
471
+ const t = globalThis.events?.[e];
472
+ t && (globalThis.removeEventListener(e, t), delete globalThis.events[e]);
434
473
  }
435
- }), globalThis.memorio._tracking = !1, globalThis.memorio._trackedPaths = new Set,
436
- globalThis.memorio._locked = !1, globalThis.memorio._lastAccessedPath = "", globalThis.memorio._stateVersion = 0,
437
- globalThis.memorio._propertyAccessLog = [];
438
-
439
- var L = (e, o, t = []) => new Proxy(e, {
474
+ }, ee = (e, t, r = ".") => t.concat(e).join(r), te = (e, t, o = []) => new Proxy(e, {
440
475
  get(e, r) {
441
- if ("__path" === r) return t.length > 0 ? "state." + t.join(".") : "state";
442
- if ("list" === r) return memorio.message('Some state could be hidden when you use "state.list". Use "state" to see the complete list '),
443
- JSON.parse(JSON.stringify(globalThis.state));
476
+ if ("__path" === r) return o.length > 0 ? "state." + o.join(".") : "state";
477
+ if ("list" === r) return n('Some state could be hidden when you use "state.list". Use "state" to see the complete list '),
478
+ JSON.parse(JSON.stringify(e));
444
479
  if ("string" == typeof r) {
445
- const e = t.length > 0 ? "state." + t.concat(r).join(".") : "state." + r;
446
- globalThis.memorio._lastAccessedPath = e, globalThis.memorio._tracking && globalThis.memorio._trackedPaths?.add(e);
480
+ const e = o.length > 0 ? "state." + o.concat(r).join(".") : "state." + r;
481
+ exports.internal.lastAccessedPath = e, exports.internal.tracking && exports.internal.trackedPaths.add(e);
447
482
  }
448
- if ("_lastPath" === r) return globalThis.memorio._lastAccessedPath;
449
- if ("remove" === r) return o => (delete e[o], !0);
483
+ if ("_lastPath" === r) return exports.internal.lastAccessedPath;
484
+ if ("remove" === r) return t => (delete e[t], !0);
450
485
  if ("removeAll" === r) return () => {
451
486
  try {
452
- for (const o in e) "function" == typeof e[o] || [ "list", "remove", "removeAll", "lock", "unlock" ].includes(o) || delete e[o];
487
+ for (const t in e) "function" == typeof e[t] || [ "list", "remove", "removeAll", "lock", "unlock" ].includes(t) || delete e[t];
453
488
  } catch (e) {
454
489
  console.error(e);
455
490
  }
456
491
  };
457
492
  if (Object.isFrozen(e[r])) return e[r];
458
493
  if ("lock" === r || "unlock" === r) {
459
- const o = Reflect.get(e, r);
460
- if (o) return o;
494
+ const t = Reflect.get(e, r);
495
+ if (t) return t;
461
496
  }
462
497
  try {
463
498
  const s = Reflect.get(e, r);
464
- if (s && "object" == typeof s && [ "Array", "Object" ].includes(s.constructor.name)) return L(s, o, t.concat(r));
465
- if ("string" == typeof r) {
466
- const e = t.length > 0 ? "state." + t.concat(r).join(".") : "state." + r;
467
- globalThis.memorio._lastAccessedPath = e, globalThis.memorio._tracking || globalThis.memorio._propertyAccessLog.push(e);
468
- }
469
- return s;
499
+ return s && "object" == typeof s && [ "Array", "Object" ].includes(s.constructor.name) ? te(s, t, o.concat(r)) : s;
470
500
  } catch (e) {
471
501
  return void console.error("Error: ", e);
472
502
  }
473
503
  },
474
- set(e, r, s) {
475
- if (globalThis.memorio._locked) return console.error("Error: state is locked. Use state.unlock() to enable modifications."),
504
+ set(e, s, i) {
505
+ if (exports.internal.locked) return console.error("Error: state is locked. Use state.unlock() to enable modifications."),
476
506
  !1;
477
- if (B.includes(r)) return console.error("key " + r + " is protected"), !1;
478
- if (e[r] && "object" == typeof e[r] && Object.isFrozen(e[r])) return console.error(`Error: state '${r}' is locked`),
507
+ if (r.includes(s)) return console.error("key " + s + " is protected"), !1;
508
+ if (e[s] && "object" == typeof e[s] && Object.isFrozen(e[s])) return console.error(`Error: state '${s}' is locked`),
479
509
  !1;
480
- 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.`),
510
+ if (e[s] && "object" == typeof e[s] && e[s].__locked) return console.error(`Error: state '${s}' is locked. Use state.${s}.unlock() to enable modifications.`),
481
511
  !1;
482
512
  try {
483
- const n = globalThis.memorio.objPath?.(r, t) ?? r;
484
- if (o({
513
+ const r = ee(s, o);
514
+ if (t({
485
515
  action: "set",
486
- path: n,
516
+ path: r,
487
517
  target: e,
488
- newValue: s,
489
- previousValue: Reflect.get(e, r)
518
+ newValue: i,
519
+ previousValue: Reflect.get(e, s)
490
520
  }), (e => {
491
521
  try {
492
- globalThis.memorio?.dispatch?.set?.(e, {
522
+ X.set(e, {
493
523
  detail: {
494
524
  name: e
495
525
  }
496
526
  });
497
527
  } catch (e) {}
498
- })("state." + n), Reflect.set(e, r, s), globalThis.memorio._stateVersion = (globalThis.memorio._stateVersion || 0) + 1,
499
- e[r] && "object" == typeof e[r]) {
500
- const o = e[r];
501
- if (o && "object" == typeof o) try {
502
- Object.defineProperty(o, "__locked", {
528
+ })("state." + r), Reflect.set(e, s, i), exports.internal.bumpStateVersion(), e[s] && "object" == typeof e[s]) {
529
+ const t = e[s];
530
+ if (t && "object" == typeof t) try {
531
+ Object.defineProperty(t, "__locked", {
503
532
  writable: !0,
504
533
  enumerable: !1,
505
534
  configurable: !1,
506
535
  value: !1
507
- }), Object.defineProperty(o, "lock", {
536
+ }), Object.defineProperty(t, "lock", {
508
537
  writable: !1,
509
538
  enumerable: !1,
510
539
  configurable: !1,
511
540
  value: () => {
512
- Object.defineProperty(o, "__locked", {
541
+ Object.defineProperty(t, "__locked", {
513
542
  writable: !0,
514
543
  enumerable: !1,
515
544
  configurable: !1,
516
545
  value: !0
517
- }), memorio.message(`State '${r}' is now locked.`);
546
+ }), n(`State '${s}' is now locked.`);
518
547
  }
519
- }), Object.defineProperty(o, "unlock", {
548
+ }), Object.defineProperty(t, "unlock", {
520
549
  writable: !1,
521
550
  enumerable: !1,
522
551
  configurable: !1,
523
552
  value: () => {
524
- Object.defineProperty(o, "__locked", {
553
+ Object.defineProperty(t, "__locked", {
525
554
  writable: !0,
526
555
  enumerable: !1,
527
556
  configurable: !1,
528
557
  value: !1
529
- }), memorio.message(`State '${r}' is now unlocked.`);
530
- }
531
- });
532
- } catch (e) {}
533
- }
534
- return !0;
535
- } catch (e) {
536
- return console.error("Error in set trap:", e), !1;
537
- }
538
- },
539
- deleteProperty(e, r) {
540
- try {
541
- const s = globalThis.memorio.objPath?.(r, t);
542
- return o({
543
- action: "delete",
544
- path: s,
545
- target: e
546
- }), Reflect.deleteProperty(e, r);
547
- } catch (e) {
548
- return console.error("Error in deleteProperty trap:", e), !1;
549
- }
550
- },
551
- ownKeys: e => Reflect.ownKeys(e),
552
- getOwnPropertyDescriptor: (e, o) => Reflect.getOwnPropertyDescriptor(e, o)
553
- });
554
-
555
- globalThis?.state || (globalThis.state = L({}, () => {})), globalThis.state.lock = () => {
556
- globalThis.memorio._locked = !0, memorio.message("State is now locked. All modifications are blocked.");
557
- }, globalThis.state.unlock = () => {
558
- globalThis.memorio._locked = !1, memorio.message("State is now unlocked. Modifications are allowed.");
559
- }, Object.defineProperty(globalThis, "state", {
560
- enumerable: !1,
561
- configurable: !0
562
- }), globalThis.observer || (globalThis.observer = null), Object.defineProperty(globalThis, "observer", {
563
- enumerable: !1,
564
- configurable: !0
565
- });
566
-
567
- var W = !1;
568
-
569
- globalThis.observer = (e, o = null, t = !0) => {
570
- W || (console.warn('DEPRECATED: "observer" is deprecated and will be removed in future versions. Please use "useObserver" instead.'),
571
- W = !0);
572
- const r = e => {
573
- if ("string" == typeof e) return e;
574
- if (e && "object" == typeof e && e.__path) return e.__path;
575
- if ("object" == typeof e && globalThis._propertyAccessLog && globalThis._propertyAccessLog.length > 0) {
576
- return globalThis._propertyAccessLog[globalThis._propertyAccessLog.length - 1].path || null;
577
- }
578
- return null;
579
- }, s = r(e);
580
- if (e || o) if (e || !o) {
581
- if (s) {
582
- const e = s.split(".");
583
- 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!`);
584
- }
585
- if (e && !o) {
586
- const o = r(e);
587
- if (!o) return;
588
- const t = {
589
- detail: {
590
- name: String(o)
591
- }
592
- }, s = globalThis.observer;
593
- return s?.list?.[o] && globalThis.memorio.dispatch.remove(t), void memorio.message(`called: ${o}`);
594
- }
595
- if (e && o) {
596
- const s = r(e);
597
- if (!s) return;
598
- 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");
599
- const n = Array.isArray(o) ? o : [ o ], i = globalThis.observer;
600
- return i?.list?.[s] && globalThis.memorio.dispatch.remove(s), void n.forEach(e => {
601
- "function" == typeof e && globalThis.memorio.dispatch.listen(s, e, t);
602
- });
603
- }
604
- } 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!");
605
- }, Object.defineProperties(globalThis.observer, {
606
- list: {
607
- get: () => globalThis.events
608
- },
609
- remove: {
610
- value: e => {
611
- e && (globalThis.memorio.dispatch.remove(e), delete globalThis.events[e]);
612
- }
613
- },
614
- removeAll: {
615
- get: () => {
616
- const e = globalThis.observer, o = e?.list;
617
- return o && Object.keys(o).forEach(o => {
618
- e?.remove?.(o);
619
- }), !0;
620
- }
621
- },
622
- has: {
623
- value: e => {
624
- const o = globalThis.observer;
625
- return !!o?.list?.[e];
626
- }
627
- }
628
- }), globalThis.useObserver || (globalThis.useObserver = null), Object.defineProperty(globalThis, "useObserver", {
629
- value: null,
630
- writable: !0,
631
- enumerable: !1,
632
- configurable: !0
633
- }), globalThis.useObserver = (e, o) => {
634
- if (!o || "function" != typeof e) return () => {};
635
- const t = [], r = Array.isArray(o) && !o.__path ? o : [ o ];
636
- try {
637
- return r.forEach(o => {
638
- let r = "";
639
- if ("function" == typeof o) {
640
- const e = globalThis.memorio.propertyName;
641
- if ("function" == typeof e) {
642
- const t = e(globalThis.state, o);
643
- t && (r = t);
644
- }
645
- } else "object" == typeof o && null !== o && (r = o.__path || ("function" == typeof o.toString && "[object Object]" !== o.toString() ? o.toString() : ""));
646
- if (r) {
647
- r = r.replace(/^(\(\)\s*=>\s*)/, "").replace(/^globalThis\./, "").replace(/^state\./, "");
648
- const o = r.startsWith("store.") || r.startsWith("state.") ? r : "state." + r;
649
- globalThis.memorio.dispatch.listen(o, () => e()), t.push(o);
650
- } else {
651
- globalThis.memorio._trackedPaths?.clear(), globalThis.memorio._tracking = !0;
652
- try {
653
- e();
558
+ }), n(`State '${s}' is now unlocked.`);
559
+ }
560
+ });
654
561
  } catch (e) {}
655
- globalThis.memorio._tracking = !1, globalThis.memorio._trackedPaths?.forEach(o => {
656
- t.includes(o) || (memorio.message(`useObserver: [Auto-Discovery] -> "${o}"`), globalThis.memorio.dispatch.listen(o, () => e()),
657
- t.push(o));
658
- });
659
562
  }
660
- }), t.length > 0 ? memorio.message(`useObserver: Monitoring ${t.length} paths.`) : console.warn("useObserver: No paths resolved for monitoring. Check your dependencies!"),
661
- () => {
662
- t.forEach(e => {
663
- globalThis.memorio.dispatch && "function" == typeof globalThis.memorio.dispatch.remove && (globalThis.memorio.dispatch.remove(e),
664
- memorio.message(`useObserver: Stopped monitoring "${e}"`));
665
- });
666
- };
667
- } catch (e) {
668
- return memorio.message(`useObserver Error: ${e}`), () => {};
669
- }
670
- }, Object.freeze(globalThis.useObserver);
563
+ return !0;
564
+ } catch (e) {
565
+ return console.error("Error in set trap:", e), !1;
566
+ }
567
+ },
568
+ deleteProperty(e, r) {
569
+ try {
570
+ const s = ee(r, o);
571
+ return t({
572
+ action: "delete",
573
+ path: s,
574
+ target: e
575
+ }), Reflect.deleteProperty(e, r);
576
+ } catch (e) {
577
+ return console.error("Error in deleteProperty trap:", e), !1;
578
+ }
579
+ },
580
+ ownKeys: e => Reflect.ownKeys(e),
581
+ getOwnPropertyDescriptor: (e, t) => Reflect.getOwnPropertyDescriptor(e, t)
582
+ }), re = te({}, () => {});
671
583
 
672
- var R = D(), U = new Map;
584
+ re.lock = () => {
585
+ exports.internal.locked = !0, n("State is now locked. All modifications are blocked.");
586
+ }, re.unlock = () => {
587
+ exports.internal.locked = !1, n("State is now unlocked. Modifications are allowed.");
588
+ }, j(), i(), c();
673
589
 
674
- function K() {
675
- const e = memorio._currentContext || "" || "default";
676
- return U.has(e) || U.set(e, new Map), U.get(e);
590
+ var oe = h(), se = new Map;
591
+
592
+ function ne() {
593
+ const e = exports.internal.currentContext || "" || "default";
594
+ return se.has(e) || se.set(e, new Map), se.get(e);
677
595
  }
678
596
 
679
- var q = null !== R;
597
+ var ie = null !== oe;
680
598
 
681
- function F() {
682
- const e = memorio._currentContext || "";
599
+ function ae() {
600
+ const e = exports.internal.currentContext || "";
683
601
  return e ? `${e}-` : "memorio_store_";
684
602
  }
685
603
 
686
- function V(e) {
687
- return e && "string" == typeof e ? e.length > 512 ? (memorio.message("Key too long (max 512 characters)"),
688
- "") : /^[a-zA-Z0-9_.-]+$/.test(e) ? F() + e : (memorio.message("Key contains invalid characters (only a-z, A-Z, 0-9, _, ., - allowed)"),
604
+ function le(e) {
605
+ return e && "string" == typeof e ? e.length > 512 ? (exports.message("Key too long (max 512 characters)"),
606
+ "") : /^[a-zA-Z0-9_.-]+$/.test(e) ? ae() + e : (exports.message("Key contains invalid characters (only a-z, A-Z, 0-9, _, ., - allowed)"),
689
607
  "") : "";
690
608
  }
691
609
 
610
+ var ce = new Proxy({}, {});
611
+
692
612
  Object.defineProperty(globalThis, "store", {
693
- value: new Proxy({}, {}),
613
+ value: ce,
694
614
  enumerable: !1,
695
615
  configurable: !0
696
- }), Object.defineProperties(store, {
616
+ }), Object.defineProperties(ce, {
697
617
  get: {
698
618
  value: e => {
699
- if (!e) return;
700
- const o = V(e);
701
- try {
702
- if (q) {
703
- const e = R.getItem(o);
704
- return e ? JSON.parse(e) : e;
705
- }
706
- {
707
- const e = K().get(o);
708
- return e ? JSON.parse(e) : e;
619
+ if (e) {
620
+ try {
621
+ return function(e) {
622
+ const t = ie ? oe.getItem(e) : ne().get(e);
623
+ return t ? JSON.parse(t) : t;
624
+ }(le(e));
625
+ } catch (t) {
626
+ exports.message(`Error parsing store item '${e}': ${t}`);
709
627
  }
710
- } catch (o) {
711
- memorio.message(`Error parsing store item '${e}': ${o}`);
628
+ return null;
712
629
  }
713
- return null;
714
630
  }
715
631
  },
716
632
  getMultiple: {
717
633
  value: e => {
718
- const o = {};
719
- for (const t of e) try {
720
- const e = store.get(t);
721
- e && (o[t] = e);
634
+ const t = {};
635
+ for (const r of e) try {
636
+ const e = ce.get(r);
637
+ e && (t[r] = e);
722
638
  } catch {}
723
- return o;
639
+ return t;
724
640
  }
725
641
  },
726
642
  set: {
727
- value: (e, o) => {
643
+ value: (e, t) => {
728
644
  if (!e) return;
729
- const t = V(e);
730
- try {
731
- if (q) {
732
- 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.");
733
- } else {
734
- const e = K();
735
- if (null == o) e.set(t, JSON.stringify(null)); else if ("object" == typeof o || "number" == typeof o || "boolean" == typeof o || "string" == typeof o) e.set(t, JSON.stringify(o)); else if ("function" == typeof o) return void memorio.message("Storing functions is not secure and is blocked for safety.");
645
+ const r = le(e);
646
+ if (r) {
647
+ if ("function" != typeof t) {
648
+ try {
649
+ !function(e, t) {
650
+ const r = JSON.stringify(t);
651
+ ie ? oe.setItem(e, r) : ne().set(e, r);
652
+ }(r, t);
653
+ } catch (t) {
654
+ exports.message(`Error setting store item '${e}': ${t}`);
655
+ }
656
+ return null;
736
657
  }
737
- } catch (o) {
738
- memorio.message(`Error setting store item '${e}': ${o}`);
658
+ exports.message("Storing functions is not secure and is blocked for safety.");
739
659
  }
740
- return null;
741
660
  }
742
661
  },
743
662
  remove: {
744
663
  value: e => {
745
664
  if (!e) return;
746
- const o = V(e);
665
+ const t = le(e);
666
+ if (!t) return !1;
747
667
  try {
748
- if (q) {
749
- if (R.getItem(o)) return R.removeItem(o), !0;
750
- } else if (K().has(o)) return K().delete(o), !0;
751
- } catch (o) {
752
- memorio.message(`Error removing store item '${e}': ${o}`);
668
+ return function(e) {
669
+ if (ie) {
670
+ if (oe.getItem(e)) return oe.removeItem(e), !0;
671
+ } else if (ne().has(e)) return ne().delete(e), !0;
672
+ return !1;
673
+ }(t);
674
+ } catch (t) {
675
+ exports.message(`Error removing store item '${e}': ${t}`);
753
676
  }
754
677
  return !1;
755
678
  }
756
679
  },
757
680
  delete: {
758
- value: e => (store.remove(e), !0)
681
+ value: e => (ce.remove(e), !0)
759
682
  },
760
683
  removeAll: {
761
684
  value: () => {
762
- if (q) {
685
+ if (ie) {
763
686
  const e = [];
764
- for (let o = 0; o < R.length; o++) {
765
- const t = R.key(o);
766
- t?.startsWith(F()) && e.push(t);
687
+ for (let t = 0; t < oe.length; t++) {
688
+ const r = oe.key(t);
689
+ r?.startsWith(ae()) && e.push(r);
767
690
  }
768
- e.forEach(e => R.removeItem(e));
769
- } else K().clear();
691
+ e.forEach(e => oe.removeItem(e));
692
+ } else ne().clear();
770
693
  return !0;
771
694
  }
772
695
  },
773
696
  clearAll: {
774
- value: () => (store.removeAll(), !0)
697
+ value: () => (ce.removeAll(), !0)
775
698
  },
776
699
  quota: {
777
700
  value: async () => [ 0, 0 ]
@@ -779,139 +702,138 @@ Object.defineProperty(globalThis, "store", {
779
702
  size: {
780
703
  value: () => {
781
704
  let e = 0;
782
- return q ? Object.keys(R).forEach(o => {
783
- if (o.startsWith(F())) {
784
- const t = R.getItem(o);
785
- t && (e += t.length);
705
+ return ie ? Object.keys(oe).forEach(t => {
706
+ if (t.startsWith(ae())) {
707
+ const r = oe.getItem(t);
708
+ r && (e += r.length);
786
709
  }
787
- }) : K().forEach(o => {
788
- e += o.length;
710
+ }) : ne().forEach(t => {
711
+ e += t.length;
789
712
  }), e;
790
713
  }
791
714
  },
792
715
  isPersistent: {
793
- get: () => q
716
+ get: () => ie
794
717
  },
795
718
  list: {
796
719
  value: () => {
797
720
  const e = {};
798
721
  try {
799
- if (q) for (let o = 0; o < R.length; o++) {
800
- const t = R.key(o);
801
- if (t?.startsWith(F())) {
802
- const o = t.replace(F(), ""), r = R.getItem(t);
803
- if (null !== r) try {
804
- e[o] = JSON.parse(r);
722
+ if (ie) for (let t = 0; t < oe.length; t++) {
723
+ const r = oe.key(t);
724
+ if (r?.startsWith(ae())) {
725
+ const t = r.replace(ae(), ""), o = oe.getItem(r);
726
+ if (null !== o) try {
727
+ e[t] = JSON.parse(o);
805
728
  } catch {
806
- e[o] = r;
729
+ e[t] = o;
807
730
  }
808
731
  }
809
- } else K().forEach((o, t) => {
810
- if (t.startsWith(F())) {
811
- const r = t.replace(F(), "");
732
+ } else ne().forEach((t, r) => {
733
+ if (r.startsWith(ae())) {
734
+ const o = r.replace(ae(), "");
812
735
  try {
813
- e[r] = JSON.parse(o);
736
+ e[o] = JSON.parse(t);
814
737
  } catch {
815
- e[r] = o;
738
+ e[o] = t;
816
739
  }
817
740
  }
818
741
  });
819
742
  } catch (e) {
820
- memorio.message(`Error listing store items: ${e}`);
743
+ exports.message(`Error listing store items: ${e}`);
821
744
  }
822
745
  return e;
823
746
  }
824
747
  }
825
- }), Object.freeze(store);
748
+ }), Object.freeze(ce), j(), i(), c();
826
749
 
827
- var H = x(), Y = new Map;
750
+ var ue = m(), de = new Map;
828
751
 
829
- function Z() {
830
- const e = memorio._currentContext || "" || "default";
831
- return Y.has(e) || Y.set(e, new Map), Y.get(e);
752
+ function be() {
753
+ const e = exports.internal.currentContext || "" || "default";
754
+ return de.has(e) || de.set(e, new Map), de.get(e);
832
755
  }
833
756
 
834
- var G = null !== H;
757
+ var fe = null !== ue;
835
758
 
836
- function Q() {
837
- const e = memorio._currentContext || "";
759
+ function pe() {
760
+ const e = exports.internal.currentContext || "";
838
761
  return e ? `${e}-` : "memorio_session_";
839
762
  }
840
763
 
841
- function X(e) {
842
- return e && "string" == typeof e ? e.length > 512 ? (memorio.message("Key too long (max 512 characters)"),
843
- "") : /^[a-zA-Z0-9_.-]+$/.test(e) ? Q() + e : (memorio.message("Key contains invalid characters (only a-z, A-Z, 0-9, _, ., - allowed)"),
764
+ function ge(e) {
765
+ return e && "string" == typeof e ? e.length > 512 ? (exports.message("Key too long (max 512 characters)"),
766
+ "") : /^[a-zA-Z0-9_.-]+$/.test(e) ? pe() + e : (exports.message("Key contains invalid characters (only a-z, A-Z, 0-9, _, ., - allowed)"),
844
767
  "") : "";
845
768
  }
846
769
 
770
+ var me = new Proxy({}, {});
771
+
847
772
  Object.defineProperty(globalThis, "session", {
848
- value: new Proxy({}, {}),
773
+ value: me,
849
774
  enumerable: !1,
850
775
  configurable: !0
851
- }), Object.defineProperties(session, {
776
+ }), Object.defineProperties(me, {
852
777
  get: {
853
778
  value: e => {
854
- if (!e) return;
855
- const o = X(e);
856
- try {
857
- if (G) {
858
- const e = H.getItem(o);
859
- return e ? JSON.parse(e) : e;
860
- }
861
- {
862
- const e = Z().get(o);
863
- return e ? JSON.parse(e) : e;
864
- }
865
- } catch (o) {
866
- memorio.message(`Error parsing session item '${e}':${o}`);
779
+ if (e) try {
780
+ return function(e) {
781
+ const t = fe ? ue.getItem(e) : be().get(e);
782
+ return t ? JSON.parse(t) : t;
783
+ }(ge(e));
784
+ } catch (t) {
785
+ exports.message(`Error parsing session item '${e}':${t}`);
867
786
  }
868
787
  }
869
788
  },
870
789
  set: {
871
- value: (e, o) => {
790
+ value: (e, t) => {
872
791
  if (!e) return;
873
- const t = X(e);
874
- try {
875
- 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 {
876
- const e = Z();
877
- 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.");
878
- }
879
- } catch (o) {
880
- memorio.message(`Error setting session item '${e}': ${o}`);
881
- }
792
+ const r = ge(e);
793
+ if (r) if ("function" != typeof t) try {
794
+ !function(e, t) {
795
+ const r = JSON.stringify(t);
796
+ fe ? ue.setItem(e, r) : be().set(e, r);
797
+ }(r, t);
798
+ } catch (t) {
799
+ exports.message(`Error setting session item '${e}': ${t}`);
800
+ } else exports.message("It's not secure to session functions.");
882
801
  }
883
802
  },
884
803
  remove: {
885
804
  value: e => {
886
805
  if (!e) return;
887
- const o = X(e);
888
- try {
889
- if (G) {
890
- if (H.getItem(o)) return H.removeItem(o), !0;
891
- } else if (Z().has(o)) return Z().delete(o), !0;
892
- } catch (o) {
893
- memorio.message(`Error removing session item '${e}': ${o}`);
806
+ const t = ge(e);
807
+ if (t) try {
808
+ return function(e) {
809
+ if (fe) {
810
+ if (ue.getItem(e)) return ue.removeItem(e), !0;
811
+ } else if (be().has(e)) return be().delete(e), !0;
812
+ return !1;
813
+ }(t);
814
+ } catch (t) {
815
+ exports.message(`Error removing session item '${e}': ${t}`);
894
816
  }
895
817
  }
896
818
  },
897
819
  delete: {
898
- value: e => (session.remove(e), !0)
820
+ value: e => (me.remove(e), !0)
899
821
  },
900
822
  removeAll: {
901
823
  value: () => {
902
- if (G) {
824
+ if (fe) {
903
825
  const e = [];
904
- for (let o = 0; o < H.length; o++) {
905
- const t = H.key(o);
906
- t?.startsWith(Q()) && e.push(t);
826
+ for (let t = 0; t < ue.length; t++) {
827
+ const r = ue.key(t);
828
+ r?.startsWith(pe()) && e.push(r);
907
829
  }
908
- e.forEach(e => H.removeItem(e));
909
- } else Z().clear();
830
+ e.forEach(e => ue.removeItem(e));
831
+ } else be().clear();
910
832
  return !0;
911
833
  }
912
834
  },
913
835
  clearAll: {
914
- value: () => (session.removeAll(), !0)
836
+ value: () => (me.removeAll(), !0)
915
837
  },
916
838
  quota: {
917
839
  value: async () => [ 0, 0 ]
@@ -919,231 +841,477 @@ Object.defineProperty(globalThis, "session", {
919
841
  size: {
920
842
  value: () => {
921
843
  let e = 0;
922
- return G ? Object.keys(H).forEach(o => {
923
- if (o.startsWith(Q())) {
924
- const t = H.getItem(o);
925
- t && (e += t.length);
844
+ return fe ? Object.keys(ue).forEach(t => {
845
+ if (t.startsWith(pe())) {
846
+ const r = ue.getItem(t);
847
+ r && (e += r.length);
926
848
  }
927
- }) : Z().forEach(o => {
928
- e += o.length;
849
+ }) : be().forEach(t => {
850
+ e += t.length;
929
851
  }), e;
930
852
  }
931
853
  },
932
854
  isPersistent: {
933
- get: () => G
855
+ get: () => fe
934
856
  },
935
857
  list: {
936
858
  value: () => {
937
859
  const e = {};
938
860
  try {
939
- if (G) for (let o = 0; o < H.length; o++) {
940
- const t = H.key(o);
941
- if (t?.startsWith(Q())) {
942
- const o = t.replace(Q(), ""), r = H.getItem(t);
943
- if (null !== r) try {
944
- e[o] = JSON.parse(r);
861
+ if (fe) for (let t = 0; t < ue.length; t++) {
862
+ const r = ue.key(t);
863
+ if (r?.startsWith(pe())) {
864
+ const t = r.replace(pe(), ""), o = ue.getItem(r);
865
+ if (null !== o) try {
866
+ e[t] = JSON.parse(o);
945
867
  } catch {
946
- e[o] = r;
868
+ e[t] = o;
947
869
  }
948
870
  }
949
- } else Z().forEach((o, t) => {
950
- if (t.startsWith(Q())) {
951
- const r = t.replace(Q(), "");
871
+ } else be().forEach((t, r) => {
872
+ if (r.startsWith(pe())) {
873
+ const o = r.replace(pe(), "");
952
874
  try {
953
- e[r] = JSON.parse(o);
875
+ e[o] = JSON.parse(t);
954
876
  } catch {
955
- e[r] = o;
877
+ e[o] = t;
956
878
  }
957
879
  }
958
880
  });
959
881
  } catch (e) {
960
- memorio.message(`Error listing session items: ${e}`);
882
+ exports.message(`Error listing session items: ${e}`);
961
883
  }
962
884
  return e;
963
885
  }
964
886
  }
965
- }), Object.freeze(session);
887
+ }), Object.freeze(me);
966
888
 
967
- var ee = {};
889
+ var he = {}, ve = new Proxy({}, {
890
+ get: (e, t) => "get" === t ? e => he[e] : "set" === t ? (e, t) => {
891
+ he[e] = t;
892
+ } : "remove" === t ? e => (delete he[e], !0) : "removeAll" === t || "clear" === t ? () => (Object.keys(he).forEach(e => delete he[e]),
893
+ !0) : "list" === t ? () => ({
894
+ ...he
895
+ }) : he[t],
896
+ set: (e, t, r) => (he[t] = r, !0),
897
+ deleteProperty: (e, t) => (delete he[t], !0)
898
+ });
968
899
 
969
- Object.defineProperty(globalThis, "cache", {
970
- value: new Proxy({}, {
971
- get: (e, o) => "get" === o ? e => ee[e] : "set" === o ? (e, o) => {
972
- ee[e] = o;
973
- } : "remove" === o ? e => (delete ee[e], !0) : "removeAll" === o || "clear" === o ? () => (Object.keys(ee).forEach(e => delete ee[e]),
974
- !0) : "list" === o ? () => ({
975
- ...ee
976
- }) : ee[o],
977
- set: (e, o, t) => (ee[o] = t, !0),
978
- deleteProperty: (e, o) => (delete ee[o], !0)
979
- }),
980
- enumerable: !1,
981
- configurable: !0
982
- }), Object.freeze(cache), A() ? (async () => {
983
- Object.defineProperty(globalThis, "idb", {
984
- value: {
985
- db: {},
986
- table: {},
987
- data: {}
988
- },
989
- writable: !0,
990
- configurable: !0,
991
- enumerable: !1
992
- }), Object.defineProperty(globalThis, "idbases", {
993
- value: [],
994
- writable: !0,
995
- configurable: !0,
996
- enumerable: !1
997
- }), await Promise.all([ Promise.resolve().then(() => (r(), t)), Promise.resolve().then(() => (n(),
998
- s)), Promise.resolve().then(() => (a(), i)), Promise.resolve().then(() => (c(),
999
- l)), Promise.resolve().then(() => (u(), m)), Promise.resolve().then(() => (d(),
1000
- b)), Promise.resolve().then(() => (f(), g)), Promise.resolve().then(() => (p(),
1001
- h)), Promise.resolve().then(() => (y(), v)), Promise.resolve().then(() => (O(),
1002
- T)), Promise.resolve().then(() => (j(), w)), Promise.resolve().then(() => (P(),
1003
- S)), Promise.resolve().then(() => (E(), _)) ]), Object.preventExtensions(idb), Object.seal(idb),
1004
- Object.freeze(idb);
1005
- })() : (Object.defineProperty(globalThis, "idb", {
1006
- value: {
1007
- db: {},
1008
- table: {},
1009
- data: {},
1010
- _disabled: !0,
1011
- _warning: "IndexedDB is not available in this environment (Node.js/Deno). Use store or session for persistence."
900
+ Object.freeze(ve), Q(), c();
901
+
902
+ var ye = !1, xe = (e, t = null, r = !0) => {
903
+ ye || (console.warn('DEPRECATED: "observer" is deprecated and will be removed in future versions. Please use "useObserver" instead.'),
904
+ ye = !0);
905
+ const o = e => "string" == typeof e ? e : e && "object" == typeof e && e.__path ? e.__path : null, s = o(e);
906
+ if (e || t) if (e || !t) {
907
+ if (s) {
908
+ const e = s.split(".");
909
+ 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!`);
910
+ }
911
+ if (e && !t) {
912
+ const t = o(e);
913
+ if (!t) return;
914
+ const r = globalThis.observer;
915
+ return r?.list?.[t] && X.remove(t), void n(`called: ${t}`);
916
+ }
917
+ if (e && t) {
918
+ const s = o(e);
919
+ if (!s) return;
920
+ 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");
921
+ const n = Array.isArray(t) ? t : [ t ], i = globalThis.observer;
922
+ return i?.list?.[s] && X.remove(s), void n.forEach(e => {
923
+ "function" == typeof e && X.listen(s, e, r);
924
+ });
925
+ }
926
+ } 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!");
927
+ };
928
+
929
+ Object.defineProperties(xe, {
930
+ list: {
931
+ get: () => globalThis.events
932
+ },
933
+ remove: {
934
+ value: e => {
935
+ e && (X.remove(e), delete globalThis.events[e]);
936
+ }
937
+ },
938
+ removeAll: {
939
+ get: () => {
940
+ const e = globalThis.observer, t = e?.list;
941
+ return t && Object.keys(t).forEach(t => {
942
+ e?.remove?.(t);
943
+ }), !0;
944
+ }
1012
945
  },
946
+ has: {
947
+ value: e => {
948
+ const t = globalThis.observer;
949
+ return !!t?.list?.[e];
950
+ }
951
+ }
952
+ }), c(), i(), globalThis.useObserver || (globalThis.useObserver = null), Object.defineProperty(globalThis, "useObserver", {
953
+ value: null,
1013
954
  writable: !0,
1014
- configurable: !0,
1015
- enumerable: !1
1016
- }), console.warn("Memorio IDB: IndexedDB is not available in this environment. Use store or session for data persistence."));
955
+ enumerable: !1,
956
+ configurable: !0
957
+ });
1017
958
 
1018
- var oe = (globalThis.memorio || {}).globals;
959
+ var Te = (e, t = []) => {
960
+ if (!t || "function" != typeof e) return () => {};
961
+ const r = [], o = Array.isArray(t) && !t.__path ? t : [ t ];
962
+ try {
963
+ return o.forEach(t => {
964
+ let o = "";
965
+ if ("function" == typeof t) {
966
+ const e = exports.propertyName(t);
967
+ e && (o = e);
968
+ } else "object" == typeof t && null !== t && (o = t.__path || ("function" == typeof t.toString && "[object Object]" !== t.toString() ? t.toString() : ""));
969
+ if (o) {
970
+ o = o.replace(/^(\(\)\s*=>\s*)/, "").replace(/^globalThis\./, "").replace(/^state\./, "");
971
+ const t = o.startsWith("store.") || o.startsWith("state.") ? o : "state." + o;
972
+ X.listen(t, () => e()), r.push(t);
973
+ } else {
974
+ exports.internal.clearTrackedPaths(), exports.internal.tracking = !0;
975
+ try {
976
+ e();
977
+ } catch (e) {}
978
+ exports.internal.tracking = !1, exports.internal.trackedPaths.forEach(t => {
979
+ r.includes(t) || (n(`useObserver: [Auto-Discovery] -> "${t}"`), X.listen(t, () => e()),
980
+ r.push(t));
981
+ });
982
+ }
983
+ }), r.length > 0 ? n(`useObserver: Monitoring ${r.length} paths.`) : console.warn("useObserver: No paths resolved for monitoring. Check your dependencies!"),
984
+ () => {
985
+ r.forEach(e => {
986
+ "function" == typeof X.remove && (X.remove(e), n(`useObserver: Stopped monitoring "${e}"`));
987
+ });
988
+ };
989
+ } catch (e) {
990
+ return n(`useObserver Error: ${e}`), () => {};
991
+ }
992
+ };
1019
993
 
1020
- function te() {
994
+ function Oe() {
1021
995
  if (!globalThis.store) return {};
1022
- const e = {}, o = globalThis.store;
1023
- if ("function" == typeof o.list) try {
1024
- return o.list();
996
+ const e = {}, t = globalThis.store;
997
+ if ("function" == typeof t.list) try {
998
+ return t.list();
1025
999
  } catch {}
1026
- if ("function" == typeof o.get) for (const t of Object.keys(o)) if (![ "get", "set", "remove", "delete", "removeAll", "clearAll", "size", "isPersistent", "list" ].includes(t)) try {
1027
- const r = o.get(t);
1028
- null != r && (e[t] = r);
1000
+ if ("function" == typeof t.get) for (const r of Object.keys(t)) if (![ "get", "set", "remove", "delete", "removeAll", "clearAll", "size", "isPersistent", "list" ].includes(r)) try {
1001
+ const o = t.get(r);
1002
+ null != o && (e[r] = o);
1029
1003
  } catch {}
1030
1004
  return e;
1031
1005
  }
1032
1006
 
1033
- function re() {
1007
+ function we() {
1034
1008
  if (!globalThis.session) return {};
1035
- const e = {}, o = globalThis.session;
1036
- if ("function" == typeof o.list) try {
1037
- return o.list();
1009
+ const e = {}, t = globalThis.session;
1010
+ if ("function" == typeof t.list) try {
1011
+ return t.list();
1038
1012
  } catch {}
1039
- if ("function" == typeof o.get) for (const t of Object.keys(o)) if (![ "get", "set", "remove", "delete", "removeAll", "clearAll", "size", "isPersistent", "list" ].includes(t)) try {
1040
- const r = o.get(t);
1041
- null != r && (e[t] = r);
1013
+ if ("function" == typeof t.get) for (const r of Object.keys(t)) if (![ "get", "set", "remove", "delete", "removeAll", "clearAll", "size", "isPersistent", "list" ].includes(r)) try {
1014
+ const o = t.get(r);
1015
+ null != o && (e[r] = o);
1042
1016
  } catch {}
1043
1017
  return e;
1044
1018
  }
1045
1019
 
1046
- var se, ne = e => {
1047
- globalThis[e] && "function" == typeof globalThis[e].clear ? globalThis[e].clear() : console.error(`Module ${e} not found or does not support clear()`);
1048
- };
1020
+ globalThis.useObserver = Te, Object.freeze(globalThis.useObserver), c(), i();
1049
1021
 
1050
- void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "devtools", {
1051
- enumerable: !1,
1052
- configurable: !0,
1053
- value: {
1054
- inspect: () => {
1055
- if (!0 === globalThis.memorio?.debug) {
1056
- if (globalThis.state) {
1057
- const e = globalThis.state.list;
1058
- let o;
1059
- o = "function" == typeof e ? e() : "object" == typeof e && null !== e ? e : globalThis.state,
1060
- console.table(o);
1022
+ var Pe = e => {
1023
+ globalThis[e] && "function" == typeof globalThis[e].clear ? globalThis[e].clear() : console.error(`Module ${e} not found or does not support clear()`);
1024
+ }, je = {
1025
+ inspect: () => {
1026
+ if (!0 === exports.internal.debug) {
1027
+ if (globalThis.state) {
1028
+ const e = globalThis.state.list;
1029
+ let t;
1030
+ t = "function" == typeof e ? e() : "object" == typeof e && null !== e ? e : globalThis.state,
1031
+ console.table(t);
1032
+ }
1033
+ if (globalThis.store && console.table(Oe()), globalThis.session && console.table(we()),
1034
+ globalThis.cache) {
1035
+ const e = globalThis.cache.list;
1036
+ let t;
1037
+ t = "function" == typeof e ? e() : "object" == typeof e && null !== e ? e : globalThis.cache,
1038
+ console.table(t);
1039
+ }
1040
+ }
1041
+ },
1042
+ stats: () => {
1043
+ const e = e => {
1044
+ if (!e) return 0;
1045
+ if ("function" == typeof e.list) try {
1046
+ const t = e.list();
1047
+ return Object.keys(t).length;
1048
+ } catch {}
1049
+ return Object.keys(e).length;
1050
+ };
1051
+ return {
1052
+ stateKeys: e(globalThis.state),
1053
+ storeKeys: e(globalThis.store),
1054
+ sessionKeys: e(globalThis.session),
1055
+ cacheKeys: e(globalThis.cache),
1056
+ idbDatabases: 0,
1057
+ lastUpdate: (new Date).toISOString()
1058
+ };
1059
+ },
1060
+ clear: Pe,
1061
+ clearAll: () => {
1062
+ Pe("state"), Pe("store"), Pe("session"), Pe("cache");
1063
+ },
1064
+ exportData: () => {
1065
+ const e = {
1066
+ state: (() => {
1067
+ if (globalThis.state) try {
1068
+ return "function" == typeof globalThis.state.list ? globalThis.state.list() : globalThis.state;
1069
+ } catch {
1070
+ return;
1061
1071
  }
1062
- if (globalThis.store && console.table(te()), globalThis.session && console.table(re()),
1063
- globalThis.cache) {
1064
- const e = globalThis.cache.list;
1065
- let o;
1066
- o = "function" == typeof e ? e() : "object" == typeof e && null !== e ? e : globalThis.cache,
1067
- console.table(o);
1072
+ })(),
1073
+ store: Oe(),
1074
+ session: we(),
1075
+ cache: (() => {
1076
+ if (globalThis.cache) try {
1077
+ return "function" == typeof globalThis.cache.list ? globalThis.cache.list() : globalThis.cache;
1078
+ } catch {
1079
+ return;
1068
1080
  }
1069
- }
1070
- },
1071
- stats: () => {
1072
- const e = e => {
1073
- if (!e) return 0;
1074
- if ("function" == typeof e.list) try {
1075
- const o = e.list();
1076
- return Object.keys(o).length;
1077
- } catch {}
1078
- return Object.keys(e).length;
1079
- };
1080
- return {
1081
- stateKeys: e(globalThis.state),
1082
- storeKeys: e(globalThis.store),
1083
- sessionKeys: e(globalThis.session),
1084
- cacheKeys: e(globalThis.cache),
1085
- idbDatabases: 0,
1086
- lastUpdate: (new Date).toISOString()
1087
- };
1088
- },
1089
- clear: ne,
1090
- clearAll: () => {
1091
- ne("state"), ne("store"), ne("session"), ne("cache");
1092
- },
1093
- exportData: () => {
1094
- const e = {
1095
- state: (() => {
1096
- if (globalThis.state) try {
1097
- return "function" == typeof globalThis.state.list ? globalThis.state.list() : globalThis.state;
1098
- } catch {
1099
- return;
1100
- }
1101
- })(),
1102
- store: te(),
1103
- session: re(),
1104
- cache: (() => {
1105
- if (globalThis.cache) try {
1106
- return "function" == typeof globalThis.cache.list ? globalThis.cache.list() : globalThis.cache;
1107
- } catch {
1108
- return;
1109
- }
1110
- })(),
1111
- exportedAt: (new Date).toISOString()
1081
+ })(),
1082
+ exportedAt: (new Date).toISOString()
1083
+ };
1084
+ return JSON.stringify(e, null, 2);
1085
+ },
1086
+ importData: e => {
1087
+ try {
1088
+ const t = JSON.parse(e);
1089
+ t.state && Object.entries(t.state).forEach(([e, t]) => {
1090
+ globalThis.state && "list" !== e && "remove" !== e && "removeAll" !== e && (globalThis.state[e] = t);
1091
+ }), t.store && globalThis.store && "function" == typeof globalThis.store.set && Object.entries(t.store).forEach(([e, t]) => {
1092
+ globalThis.store.set(e, t);
1093
+ }), t.session && globalThis.session && "function" == typeof globalThis.session.set && Object.entries(t.session).forEach(([e, t]) => {
1094
+ globalThis.session.set(e, t);
1095
+ }), t.cache && globalThis.cache && Object.entries(t.cache).forEach(([e, t]) => {
1096
+ globalThis.cache && "get" !== e && "set" !== e && "remove" !== e && "clear" !== e && (globalThis.cache[e] = t);
1097
+ });
1098
+ } catch (e) {
1099
+ console.error("%cāœ— Import failed:", "color: #F44336", e);
1100
+ }
1101
+ },
1102
+ watch: (e, t) => {
1103
+ if (!globalThis[e]) return void console.error(`Module ${e} not found`);
1104
+ const r = globalThis[e], o = r[t];
1105
+ if (console.debug(`šŸ‘ Watching ${e}.${t} (initial: ${JSON.stringify(o)})`), "state" === e && globalThis.memorio?.dispatch) {
1106
+ const o = r => {
1107
+ const o = r.detail;
1108
+ o?.name?.includes(t) && console.debug(`šŸ‘ Change: ${e}.${t} =`, r.detail.value);
1112
1109
  };
1113
- return JSON.stringify(e, null, 2);
1114
- },
1115
- importData: e => {
1110
+ r.addEventListener?.("memorio-change", o);
1111
+ }
1112
+ },
1113
+ help: () => {
1114
+ console.debug("\n🧠 Memorio DevTools Help\n\nAvailable commands:\n memorio.devtools.inspect() - Inspect all state modules\n memorio.devtools.stats() - Show statistics\n memorio.devtools.clear('module') - Clear specific module\n memorio.devtools.clearAll() - Clear all modules\n memorio.devtools.exportData() - Export all data as JSON\n memorio.devtools.importData(json) - Import data from JSON\n memorio.devtools.watch(module, path) - Watch a path for changes\n memorio.devtools.help() - Show this help\n\nShortcuts:\n state - globalThis.state\n store - globalThis.store\n session - globalThis.session\n cache - globalThis.cache\n");
1115
+ }
1116
+ };
1117
+
1118
+ i(), c();
1119
+
1120
+ var Se = {
1121
+ enabled: !0,
1122
+ logToConsole: !0,
1123
+ modules: [ "state", "store", "session", "cache", "idb" ],
1124
+ maxEntries: 1e3
1125
+ }, Ee = [], $e = e => Se.enabled && Se.modules.includes(e), ke = e => ({
1126
+ state: "#4CAF50",
1127
+ store: "#2196F3",
1128
+ session: "#FF9800",
1129
+ cache: "#9C27B0",
1130
+ idb: "#F44336"
1131
+ }[e] || "#888888"), De = {
1132
+ configure: e => {
1133
+ Se = {
1134
+ ...Se,
1135
+ ...e
1136
+ };
1137
+ },
1138
+ enable: () => {
1139
+ Se.enabled = !0;
1140
+ },
1141
+ disable: () => {
1142
+ Se.enabled = !1;
1143
+ },
1144
+ isEnabled: $e,
1145
+ log: (e, t, r, o, s) => {
1146
+ if (!$e(e)) return;
1147
+ const i = {
1148
+ timestamp: (new Date).toISOString(),
1149
+ module: e,
1150
+ action: t,
1151
+ path: r,
1152
+ value: o,
1153
+ previousValue: s
1154
+ };
1155
+ if (Ee.push(i), Ee.length > Se.maxEntries && Ee.shift(), Se.logToConsole && !0 === exports.internal.debug) {
1156
+ const i = `[Memorio:${e.toUpperCase()}]`, a = ke(e);
1157
+ n(`%c${i}%c ${t} ${r},\n color: ${a}; font-weight: bold,\n color: inherit`),
1158
+ void 0 !== o && n(` → value:${o}`), void 0 !== s && n(` ← previous:${s}`);
1159
+ }
1160
+ Se.customHandler && Se.customHandler(i);
1161
+ },
1162
+ getHistory: () => [ ...Ee ],
1163
+ clearHistory: () => {
1164
+ Ee.length = 0;
1165
+ },
1166
+ getStats: () => {
1167
+ const e = {
1168
+ total: Ee.length,
1169
+ state: 0,
1170
+ store: 0,
1171
+ session: 0,
1172
+ cache: 0,
1173
+ idb: 0,
1174
+ set: 0,
1175
+ get: 0,
1176
+ delete: 0,
1177
+ clear: 0
1178
+ };
1179
+ for (const t of Ee) if (t) {
1180
+ const r = t.module, o = t.action;
1181
+ r && "number" == typeof e[r] && e[r]++, o && "number" == typeof e[o] && e[o]++;
1182
+ }
1183
+ return e;
1184
+ },
1185
+ exportLogs: () => JSON.stringify(Ee, null, 2)
1186
+ };
1187
+
1188
+ i(), j(), j(), i();
1189
+
1190
+ var Ce = "4.6.4";
1191
+
1192
+ Q(), c(), Object.defineProperty(globalThis, "memorio", {
1193
+ value: {
1194
+ setProps: () => {},
1195
+ obj: {},
1196
+ array: [],
1197
+ dispatch: X,
1198
+ message: exports.message,
1199
+ devtools: je,
1200
+ logger: De,
1201
+ setDescription: () => {}
1202
+ },
1203
+ writable: !1,
1204
+ configurable: !0,
1205
+ enumerable: !1
1206
+ }), Object.defineProperty(globalThis, "events", {
1207
+ value: {},
1208
+ writable: !0,
1209
+ enumerable: !1
1210
+ }), Object.defineProperty(memorio, "version", {
1211
+ writable: !1,
1212
+ enumerable: !1,
1213
+ value: Ce
1214
+ }), Object.defineProperty(memorio, "debug", {
1215
+ get: () => exports.internal.debug,
1216
+ set: e => {
1217
+ exports.internal.debug = e;
1218
+ },
1219
+ enumerable: !1
1220
+ });
1221
+
1222
+ var Ae = y();
1223
+
1224
+ Object.defineProperty(memorio, "_platform", {
1225
+ writable: !1,
1226
+ enumerable: !1,
1227
+ value: Ae.platform
1228
+ }), Object.defineProperty(memorio, "_capabilities", {
1229
+ writable: !1,
1230
+ enumerable: !1,
1231
+ value: Ae
1232
+ }), Object.defineProperty(memorio, "_sessionId", {
1233
+ writable: !1,
1234
+ enumerable: !1,
1235
+ value: u()
1236
+ }), function() {
1237
+ const e = y(), t = globalThis;
1238
+ e.hasDispatchEvent || (t.dispatchEvent = function(e) {
1239
+ return !0;
1240
+ }, "undefined" == typeof CustomEvent && (t.CustomEvent = class {
1241
+ type;
1242
+ detail;
1243
+ constructor(e, t = {}) {
1244
+ this.type = e, this.detail = t;
1245
+ }
1246
+ })), "function" != typeof t.addEventListener && (t.addEventListener = function(e, t) {
1247
+ a.has(e) || a.set(e, []), a.get(e).push(t);
1248
+ }, t.removeEventListener = function(e, t) {
1249
+ const r = a.get(e);
1250
+ if (r) {
1251
+ const e = r.indexOf(t);
1252
+ e > -1 && r.splice(e, 1);
1253
+ }
1254
+ }, t.dispatchEvent = function(e) {
1255
+ const t = a.get(e.type);
1256
+ return t && t.forEach(t => {
1116
1257
  try {
1117
- const o = JSON.parse(e);
1118
- o.state && Object.entries(o.state).forEach(([e, o]) => {
1119
- globalThis.state && "list" !== e && "remove" !== e && "removeAll" !== e && (globalThis.state[e] = o);
1120
- }), o.store && globalThis.store && "function" == typeof globalThis.store.set && Object.entries(o.store).forEach(([e, o]) => {
1121
- globalThis.store.set(e, o);
1122
- }), o.session && globalThis.session && "function" == typeof globalThis.session.set && Object.entries(o.session).forEach(([e, o]) => {
1123
- globalThis.session.set(e, o);
1124
- }), o.cache && globalThis.cache && Object.entries(o.cache).forEach(([e, o]) => {
1125
- globalThis.cache && "get" !== e && "set" !== e && "remove" !== e && "clear" !== e && (globalThis.cache[e] = o);
1126
- });
1258
+ t(e);
1127
1259
  } catch (e) {
1128
- console.error("%cāœ— Import failed:", "color: #F44336", e);
1129
- }
1130
- },
1131
- watch: (e, o) => {
1132
- if (!globalThis[e]) return void console.error(`Module ${e} not found`);
1133
- const t = globalThis[e], r = t[o];
1134
- if (console.debug(`šŸ‘ Watching ${e}.${o} (initial: ${JSON.stringify(r)})`), "state" === e && globalThis.memorio?.dispatch) {
1135
- const r = t => {
1136
- const r = t.detail;
1137
- r?.name?.includes(o) && console.debug(`šŸ‘ Change: ${e}.${o} =`, t.detail.value);
1138
- };
1139
- t.addEventListener?.("memorio-change", r);
1260
+ console.error("Event listener error:", e);
1140
1261
  }
1141
- },
1142
- help: () => {
1143
- 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");
1144
- }
1145
- }
1146
- }), se = "devtools", !1 === oe || oe && "object" == typeof oe && !1 === oe[se] || (Object.defineProperty(globalThis, "$state", {
1262
+ }), !0;
1263
+ });
1264
+ }(), memorio.isBrowser = b, memorio.isNode = f, memorio.isDeno = p, memorio.isEdge = g,
1265
+ memorio.getCapabilities = y, memorio.createContext = x, memorio.listContexts = T,
1266
+ memorio.deleteContext = O, memorio.isolate = e => x(e), Object.defineProperty(globalThis, "state", {
1267
+ value: re,
1268
+ writable: !0,
1269
+ enumerable: !1,
1270
+ configurable: !0
1271
+ }), Object.defineProperty(globalThis, "store", {
1272
+ value: ce,
1273
+ writable: !0,
1274
+ enumerable: !1,
1275
+ configurable: !0
1276
+ }), Object.defineProperty(globalThis, "session", {
1277
+ value: me,
1278
+ writable: !0,
1279
+ enumerable: !1,
1280
+ configurable: !0
1281
+ }), Object.defineProperty(globalThis, "cache", {
1282
+ value: ve,
1283
+ writable: !0,
1284
+ enumerable: !1,
1285
+ configurable: !0
1286
+ }), Object.defineProperty(globalThis, "idb", {
1287
+ value: exports.idb,
1288
+ writable: !0,
1289
+ enumerable: !1,
1290
+ configurable: !0
1291
+ }), Object.defineProperty(globalThis, "observer", {
1292
+ value: xe,
1293
+ writable: !0,
1294
+ enumerable: !1,
1295
+ configurable: !0
1296
+ }), Object.defineProperty(globalThis, "useObserver", {
1297
+ value: Te,
1298
+ writable: !0,
1299
+ enumerable: !1,
1300
+ configurable: !0
1301
+ }), Object.defineProperty(memorio, "dispatch", {
1302
+ value: X,
1303
+ writable: !0,
1304
+ enumerable: !1,
1305
+ configurable: !0
1306
+ }), Object.defineProperty(memorio, "setContext", {
1307
+ writable: !1,
1308
+ enumerable: !1,
1309
+ value: e => w(e)
1310
+ }), Object.defineProperty(memorio, "getContext", {
1311
+ writable: !1,
1312
+ enumerable: !1,
1313
+ value: () => exports.internal.currentContext
1314
+ }), Object.defineProperty(globalThis, "$state", {
1147
1315
  get: () => globalThis.state,
1148
1316
  configurable: !0
1149
1317
  }), Object.defineProperty(globalThis, "$store", {
@@ -1155,78 +1323,16 @@ void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "devt
1155
1323
  }), Object.defineProperty(globalThis, "$cache", {
1156
1324
  get: () => globalThis.cache,
1157
1325
  configurable: !0
1158
- }));
1326
+ }), memorio.help = function() {
1327
+ console.debug(`\n🧠 Memorio ${Ce} - 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`);
1328
+ };
1159
1329
 
1160
- var ie = {
1161
- enabled: !0,
1162
- logToConsole: !0,
1163
- modules: [ "state", "store", "session", "cache", "idb" ],
1164
- maxEntries: 1e3
1165
- }, ae = [], le = e => ie.enabled && ie.modules.includes(e), ce = e => ({
1166
- state: "#4CAF50",
1167
- store: "#2196F3",
1168
- session: "#FF9800",
1169
- cache: "#9C27B0",
1170
- idb: "#F44336"
1171
- }[e] || "#888888");
1330
+ var _e = globalThis.memorio, Ie = globalThis.events, Ne = globalThis.memorio?.help, ze = _e;
1172
1331
 
1173
- void 0 !== globalThis.memorio && Object.defineProperty(globalThis.memorio, "logger", {
1174
- enumerable: !1,
1175
- configurable: !0,
1176
- value: {
1177
- configure: e => {
1178
- ie = {
1179
- ...ie,
1180
- ...e
1181
- };
1182
- },
1183
- enable: () => {
1184
- ie.enabled = !0;
1185
- },
1186
- disable: () => {
1187
- ie.enabled = !1;
1188
- },
1189
- isEnabled: le,
1190
- log: (e, o, t, r, s) => {
1191
- if (!le(e)) return;
1192
- const n = {
1193
- timestamp: (new Date).toISOString(),
1194
- module: e,
1195
- action: o,
1196
- path: t,
1197
- value: r,
1198
- previousValue: s
1199
- };
1200
- if (ae.push(n), ae.length > ie.maxEntries && ae.shift(), ie.logToConsole && !0 === globalThis.memorio?.debug) {
1201
- const n = `[Memorio:${e.toUpperCase()}]`, i = ce(e);
1202
- memorio.message(`%c${n}%c ${o} ${t},\n color: ${i}; font-weight: bold,\n color: inherit`),
1203
- void 0 !== r && memorio.message(` → value:${r}`), void 0 !== s && memorio.message(` ← previous:${s}`);
1204
- }
1205
- ie.customHandler && ie.customHandler(n);
1206
- },
1207
- getHistory: () => [ ...ae ],
1208
- clearHistory: () => {
1209
- ae.length = 0;
1210
- },
1211
- getStats: () => {
1212
- const e = {
1213
- total: ae.length,
1214
- state: 0,
1215
- store: 0,
1216
- session: 0,
1217
- cache: 0,
1218
- idb: 0,
1219
- set: 0,
1220
- get: 0,
1221
- delete: 0,
1222
- clear: 0
1223
- };
1224
- for (const o of ae) if (o) {
1225
- const t = o.module, r = o.action;
1226
- t && "number" == typeof e[t] && e[t]++, r && "number" == typeof e[r] && e[r]++;
1227
- }
1228
- return e;
1229
- },
1230
- exportLogs: () => JSON.stringify(ae, null, 2)
1231
- }
1232
- });
1332
+ exports.cache = ve, exports.createContext = x, exports.default = ze, exports.deleteContext = O,
1333
+ exports.devtools = je, exports.dispatch = X, exports.events = Ie, exports.getCapabilities = y,
1334
+ exports.getContext = () => exports.internal.currentContext, exports.help = Ne, exports.isBrowser = b,
1335
+ exports.isDeno = p, exports.isEdge = g, exports.isNode = f, exports.isolate = e => x(e),
1336
+ exports.listContexts = T, exports.logger = De, exports.memorio = _e, exports.observer = xe,
1337
+ exports.session = me, exports.setContext = e => exports.internal.currentContext = e,
1338
+ exports.state = re, exports.store = ce, exports.useObserver = Te;