memorio 5.0.0 → 5.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 (60) hide show
  1. package/README.md +80 -449
  2. package/SECURITY.md +152 -42
  3. package/SUMMARY.md +1 -1
  4. package/adr/001-state-proxy-model.md +95 -96
  5. package/adr/002-observer-semantics.md +179 -180
  6. package/adr/003-deep-mutation-semantics.md +7 -8
  7. package/adr/004-array-mutation-semantics.md +127 -128
  8. package/adr/005-scheduler-contract.md +148 -149
  9. package/adr/006-context-isolation.md +91 -92
  10. package/adr/007-mutation-records.md +5 -6
  11. package/adr/008-transactions.md +6 -7
  12. package/adr/009-history-model.md +6 -7
  13. package/adr/README.md +46 -46
  14. package/adr/template.md +48 -49
  15. package/bin/cli.js +68 -0
  16. package/global.cjs +1462 -323
  17. package/global.js +1459 -324
  18. package/index.cjs +1462 -323
  19. package/index.d.ts +1 -0
  20. package/index.js +1459 -324
  21. package/llms.txt +42 -5
  22. package/markdown/AUDIT-REPORT.md +7 -8
  23. package/markdown/CACHE.md +190 -99
  24. package/markdown/DEVTOOLS.md +0 -1
  25. package/markdown/DISPATCH.md +0 -1
  26. package/markdown/HISTORY.md +0 -1
  27. package/markdown/IDB.md +0 -1
  28. package/markdown/IMPORT.md +0 -1
  29. package/markdown/INSPECT.md +0 -1
  30. package/markdown/LOGGER.md +0 -1
  31. package/markdown/MEMORY-ATTACHMENT.md +0 -1
  32. package/markdown/MEMORY.md +0 -1
  33. package/markdown/OBSERVER.md +0 -1
  34. package/markdown/PLATFORM.md +277 -271
  35. package/markdown/REDUX.md +54 -0
  36. package/markdown/SCHEMA.md +0 -1
  37. package/markdown/SESSION.md +0 -1
  38. package/markdown/SQLITE.md +0 -1
  39. package/markdown/STATE.md +0 -1
  40. package/markdown/STORE.md +0 -1
  41. package/markdown/SYNC.md +0 -1
  42. package/markdown/TYPED.md +0 -1
  43. package/markdown/USEOBSERVER.md +0 -1
  44. package/modules/redux.cjs +381 -10
  45. package/modules/redux.cjs.map +1 -1
  46. package/modules/redux.js +381 -10
  47. package/modules/redux.js.map +1 -1
  48. package/package.json +14 -2
  49. package/types/broadcast.d.ts +61 -0
  50. package/types/computed.d.ts +96 -0
  51. package/types/encryption.d.ts +129 -0
  52. package/types/exports.d.ts +9 -0
  53. package/types/memorio.d.ts +19 -12
  54. package/types/security.d.ts +67 -0
  55. package/types/session.d.ts +23 -5
  56. package/types/store.d.ts +19 -3
  57. package/vsix/memorio.vsix +0 -0
  58. package/markdown/CHANGELOG.md +0 -243
  59. package/markdown/PROJECT.md +0 -311
  60. package/markdown/SECURITY.md +0 -330
package/index.js CHANGED
@@ -7,6 +7,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7
7
  var __esm = (fn, res) => function __init() {
8
8
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
9
  };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
10
14
  var init_esm_shims = __esm({
11
15
  "node_modules/tsup/assets/esm_shims.js"() {
12
16
  }
@@ -205,6 +209,241 @@ var init_message = __esm({
205
209
  }
206
210
  });
207
211
 
212
+ // functions/encryption/index.ts
213
+ function _hasWebCrypto() {
214
+ const g3 = globalThis;
215
+ return typeof g3.crypto !== "undefined" && typeof g3.crypto.subtle !== "undefined" && typeof g3.crypto.subtle.encrypt === "function";
216
+ }
217
+ function _b64encode(buf) {
218
+ const bytes = buf instanceof Uint8Array ? buf : new Uint8Array(buf);
219
+ if (typeof btoa === "function") {
220
+ let binary = "";
221
+ for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
222
+ return btoa(binary);
223
+ }
224
+ if (typeof Buffer !== "undefined") {
225
+ return Buffer.from(bytes).toString("base64");
226
+ }
227
+ return "";
228
+ }
229
+ function _b64decode(b64) {
230
+ if (typeof Buffer !== "undefined") {
231
+ return new Uint8Array(Buffer.from(b64, "base64"));
232
+ }
233
+ if (typeof atob === "function") {
234
+ const binary = atob(b64);
235
+ const out = new Uint8Array(binary.length);
236
+ for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i);
237
+ return out;
238
+ }
239
+ throw new Error("memorio encryption: no base64 decoder available");
240
+ }
241
+ function _isEncrypted(value) {
242
+ return typeof value === "object" && value !== null && value.__memorio_encrypted === true && typeof value.alg === "string";
243
+ }
244
+ var AES_GCM, PBKDF2_ITERATIONS, encryption;
245
+ var init_encryption = __esm({
246
+ "functions/encryption/index.ts"() {
247
+ init_esm_shims();
248
+ init_env();
249
+ init_message();
250
+ __name(_hasWebCrypto, "_hasWebCrypto");
251
+ __name(_b64encode, "_b64encode");
252
+ __name(_b64decode, "_b64decode");
253
+ __name(_isEncrypted, "_isEncrypted");
254
+ AES_GCM = { name: "AES-GCM", length: 256 };
255
+ PBKDF2_ITERATIONS = 6e5;
256
+ encryption = {
257
+ ///
258
+ // Capability detection
259
+ ///
260
+ isAvailable() {
261
+ return _hasWebCrypto();
262
+ },
263
+ ///
264
+ // Derive a CryptoKey from a password using PBKDF2.
265
+ //
266
+ // @param password The password string.
267
+ // @param salt Salt (string or Uint8Array). Defaults to a static value.
268
+ // @param alg 'AES-GCM' (default) or 'AES-CBC'.
269
+ // @returns A Promise<CryptoKey>.
270
+ ///
271
+ async deriveKey(password, salt, alg = "AES-GCM", iterations = PBKDF2_ITERATIONS) {
272
+ if (!_hasWebCrypto()) {
273
+ throw new Error("memorio encryption: Web Crypto API is not available in this environment");
274
+ }
275
+ const enc = new TextEncoder();
276
+ const saltBytes = typeof salt === "string" ? enc.encode(salt) : salt ?? enc.encode("memorio:salt");
277
+ const keyMaterial = await globalThis.crypto.subtle.importKey(
278
+ "raw",
279
+ enc.encode(password),
280
+ { name: "PBKDF2" },
281
+ false,
282
+ ["deriveKey"]
283
+ );
284
+ return globalThis.crypto.subtle.deriveKey(
285
+ { name: "PBKDF2", salt: saltBytes, iterations, hash: "SHA-256" },
286
+ keyMaterial,
287
+ { name: alg, length: 256 },
288
+ false,
289
+ ["encrypt", "decrypt"]
290
+ );
291
+ },
292
+ ///
293
+ // Generate a fresh random CryptoKey (AES-GCM, 256-bit).
294
+ ///
295
+ async generateKey(alg = "AES-GCM") {
296
+ if (!_hasWebCrypto()) {
297
+ throw new Error("memorio encryption: Web Crypto API is not available in this environment");
298
+ }
299
+ return globalThis.crypto.subtle.generateKey(
300
+ { name: alg, length: 256 },
301
+ true,
302
+ ["encrypt", "decrypt"]
303
+ );
304
+ },
305
+ ///
306
+ // Generate a random salt for PBKDF2 key derivation.
307
+ ///
308
+ generateSalt(bytes = 16) {
309
+ const arr = new Uint8Array(bytes);
310
+ globalThis.crypto?.getRandomValues?.(arr);
311
+ return _b64encode(arr);
312
+ },
313
+ ///
314
+ // Export a CryptoKey to portable base64 strings so it can be stored
315
+ // (e.g. in an httpOnly cookie) and re-imported later with importKey().
316
+ //
317
+ // @param cryptoKey A raw CryptoKey (not a password string).
318
+ // @returns { key: string, iv: string } base64-encoded.
319
+ ///
320
+ async exportKey(cryptoKey) {
321
+ if (!_hasWebCrypto()) {
322
+ throw new Error("memorio encryption: Web Crypto API is not available in this environment");
323
+ }
324
+ const exported = await globalThis.crypto.subtle.exportKey("raw", cryptoKey);
325
+ return {
326
+ key: _b64encode(exported),
327
+ iv: ""
328
+ };
329
+ },
330
+ ///
331
+ // Import a CryptoKey from base64 strings produced by exportKey().
332
+ //
333
+ // @param keyData Base64-encoded raw key bytes.
334
+ // @param _ivData Ignored (kept for API compatibility with exportKey return).
335
+ // @returns A Promise<CryptoKey>.
336
+ ///
337
+ async importKey(keyData, _ivData) {
338
+ if (!_hasWebCrypto()) {
339
+ throw new Error("memorio encryption: Web Crypto API is not available in this environment");
340
+ }
341
+ const keyBytes = _b64decode(keyData);
342
+ if (keyBytes.length !== 32) {
343
+ throw new Error(`memorio encryption: AES-256 key must be exactly 32 bytes, got ${keyBytes.length}`);
344
+ }
345
+ return globalThis.crypto.subtle.importKey(
346
+ "raw",
347
+ keyBytes,
348
+ AES_GCM,
349
+ true,
350
+ ["encrypt", "decrypt"]
351
+ );
352
+ },
353
+ ///
354
+ // Encrypt a JavaScript value.
355
+ //
356
+ // @param value The value to encrypt (any JSON-serializable object).
357
+ // @param key A CryptoKey or a password string (password is derived via PBKDF2).
358
+ // @param keyId Optional label, stored in the envelope for key rotation.
359
+ // @returns An EncryptedEnvelope object.
360
+ ///
361
+ async encrypt(value, key, keyId) {
362
+ const cryptoKey = typeof key === "string" ? await this.deriveKey(key, void 0, "AES-GCM") : key;
363
+ const data = new TextEncoder().encode(JSON.stringify(value));
364
+ const iv = new Uint8Array(12);
365
+ globalThis.crypto.getRandomValues(iv);
366
+ const ciphertext = await globalThis.crypto.subtle.encrypt(
367
+ { name: "AES-GCM", iv },
368
+ cryptoKey,
369
+ data
370
+ );
371
+ const envelope = {
372
+ __memorio_encrypted: true,
373
+ v: 1,
374
+ alg: "AES-GCM",
375
+ iv: _b64encode(iv),
376
+ data: _b64encode(ciphertext)
377
+ };
378
+ if (keyId) envelope.keyId = keyId;
379
+ if (DEV) message_default(`encryption: encrypted value (alg=${envelope.alg})`);
380
+ return envelope;
381
+ },
382
+ ///
383
+ // Decrypt an EncryptedEnvelope.
384
+ //
385
+ // @param envelope The envelope object returned by encrypt().
386
+ // @param key A CryptoKey or a password string.
387
+ // @returns The original value (parsed from JSON).
388
+ ///
389
+ async decrypt(envelope, key) {
390
+ if (!_isEncrypted(envelope)) {
391
+ throw new Error("memorio encryption: value is not a valid encrypted envelope");
392
+ }
393
+ const cryptoKey = typeof key === "string" ? await this.deriveKey(key, void 0, "AES-GCM") : key;
394
+ const iv = _b64decode(envelope.iv);
395
+ const data = _b64decode(envelope.data);
396
+ const decrypted = await globalThis.crypto.subtle.decrypt(
397
+ { name: "AES-GCM", iv },
398
+ cryptoKey,
399
+ data
400
+ );
401
+ return JSON.parse(new TextDecoder().decode(new Uint8Array(decrypted)));
402
+ },
403
+ ///
404
+ // Convenience: encrypt with a password (derives the key internally).
405
+ // Returns a JSON string you can store anywhere.
406
+ ///
407
+ async encryptWithPassword(value, password, salt, keyId) {
408
+ const env = await this.encrypt(value, password, keyId);
409
+ return JSON.stringify(env);
410
+ },
411
+ ///
412
+ // Convenience: decrypt a JSON envelope string with a password.
413
+ ///
414
+ async decryptWithPassword(envelopeJson, password, _salt) {
415
+ const envelope = JSON.parse(envelopeJson);
416
+ return this.decrypt(envelope, password);
417
+ },
418
+ ///
419
+ // Type guard: check whether a value is an encrypted envelope.
420
+ ///
421
+ isEncrypted(value) {
422
+ return _isEncrypted(value);
423
+ },
424
+ ///
425
+ // Configure a default encryption key for auto-encrypt mode.
426
+ // When set on `store` or `session`, all writes are encrypted and all
427
+ // reads attempt decryption automatically.
428
+ ///
429
+ config(opts) {
430
+ if (opts.key !== void 0) this._defaultKey = opts.key;
431
+ if (opts.keyId !== void 0) this._defaultKeyId = opts.keyId;
432
+ return this;
433
+ },
434
+ ///
435
+ // Internal: resolve the configured default key.
436
+ ///
437
+ get _key() {
438
+ return this._defaultKey ?? null;
439
+ },
440
+ get _keyId() {
441
+ return this._defaultKeyId;
442
+ }
443
+ };
444
+ }
445
+ });
446
+
208
447
  // core/platform.ts
209
448
  function generateSessionId() {
210
449
  const anyGlobal = globalThis;
@@ -219,6 +458,9 @@ function generateSessionId() {
219
458
  return `session_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
220
459
  }
221
460
  function detectPlatform() {
461
+ if (_isBun()) {
462
+ return "bun";
463
+ }
222
464
  const globalAny = globalThis;
223
465
  if (globalAny.Deno && globalAny.Deno.version) {
224
466
  return "deno";
@@ -234,6 +476,13 @@ function detectPlatform() {
234
476
  }
235
477
  return "unknown";
236
478
  }
479
+ function _isBun() {
480
+ const globalAny = globalThis;
481
+ return typeof globalAny.Bun !== "undefined" && typeof globalAny.Bun.version === "string";
482
+ }
483
+ function isBun() {
484
+ return _isBun();
485
+ }
237
486
  function isBrowser() {
238
487
  const platform = detectPlatform();
239
488
  return platform === "browser";
@@ -287,6 +536,9 @@ function hasSqlJs() {
287
536
  }
288
537
  return typeof anyGlobal.window !== "undefined";
289
538
  }
539
+ function hasBunSqlite() {
540
+ return _isBun();
541
+ }
290
542
  function hasDispatchEvent() {
291
543
  return typeof globalThis.dispatchEvent === "function";
292
544
  }
@@ -299,6 +551,7 @@ function getCapabilities() {
299
551
  hasLocalStorage: getLocalStorage() !== null,
300
552
  hasIndexedDB: hasIndexedDB(),
301
553
  hasSqlJs: hasSqlJs(),
554
+ hasBunSqlite: hasBunSqlite(),
302
555
  hasDispatchEvent: hasDispatchEvent(),
303
556
  hasNavigator: typeof navigator !== "undefined",
304
557
  hasProcess: typeof process !== "undefined",
@@ -358,8 +611,9 @@ function initializePlatform() {
358
611
  };
359
612
  }
360
613
  }
361
- function createContext(name) {
614
+ function createContext(name, opts) {
362
615
  const contextId = name || `context_${generateSessionId()}`;
616
+ const encKey = opts?.encryptionKey;
363
617
  setCurrentContext(contextId);
364
618
  const contextStorage = {
365
619
  state: {},
@@ -368,10 +622,31 @@ function createContext(name) {
368
622
  cache: /* @__PURE__ */ new Map()
369
623
  };
370
624
  _contexts.set(contextId, contextStorage);
625
+ function _isEncrypted2(value) {
626
+ return encryption.isEncrypted(value);
627
+ }
628
+ __name(_isEncrypted2, "_isEncrypted");
371
629
  return {
372
630
  id: contextId,
373
631
  state: contextStorage.state,
374
- store: {
632
+ store: encKey ? {
633
+ get: /* @__PURE__ */ __name(async (key) => {
634
+ const data = contextStorage.store.get(key);
635
+ if (!data) return null;
636
+ const parsed = JSON.parse(data);
637
+ if (_isEncrypted2(parsed)) return encryption.decrypt(parsed, encKey);
638
+ return parsed;
639
+ }, "get"),
640
+ set: /* @__PURE__ */ __name(async (key, value) => {
641
+ const env = await encryption.encrypt(value, encKey);
642
+ contextStorage.store.set(key, JSON.stringify(env));
643
+ }, "set"),
644
+ remove: /* @__PURE__ */ __name((key) => contextStorage.store.delete(key), "remove"),
645
+ removeAll: /* @__PURE__ */ __name(() => contextStorage.store.clear(), "removeAll"),
646
+ clearAll: /* @__PURE__ */ __name(() => contextStorage.store.clear(), "clearAll"),
647
+ size: /* @__PURE__ */ __name(() => contextStorage.store.size, "size"),
648
+ isPersistent: false
649
+ } : {
375
650
  get: /* @__PURE__ */ __name((key) => {
376
651
  const data = contextStorage.store.get(key);
377
652
  return data ? JSON.parse(data) : null;
@@ -385,7 +660,24 @@ function createContext(name) {
385
660
  size: /* @__PURE__ */ __name(() => contextStorage.store.size, "size"),
386
661
  isPersistent: false
387
662
  },
388
- session: {
663
+ session: encKey ? {
664
+ get: /* @__PURE__ */ __name(async (key) => {
665
+ const data = contextStorage.session.get(key);
666
+ if (!data) return null;
667
+ const parsed = JSON.parse(data);
668
+ if (_isEncrypted2(parsed)) return encryption.decrypt(parsed, encKey);
669
+ return parsed;
670
+ }, "get"),
671
+ set: /* @__PURE__ */ __name(async (key, value) => {
672
+ const env = await encryption.encrypt(value, encKey);
673
+ contextStorage.session.set(key, JSON.stringify(env));
674
+ }, "set"),
675
+ remove: /* @__PURE__ */ __name((key) => contextStorage.session.delete(key), "remove"),
676
+ removeAll: /* @__PURE__ */ __name(() => contextStorage.session.clear(), "removeAll"),
677
+ clearAll: /* @__PURE__ */ __name(() => contextStorage.session.clear(), "clearAll"),
678
+ size: /* @__PURE__ */ __name(() => contextStorage.session.size, "size"),
679
+ isPersistent: false
680
+ } : {
389
681
  get: /* @__PURE__ */ __name((key) => {
390
682
  const data = contextStorage.session.get(key);
391
683
  return data ? JSON.parse(data) : null;
@@ -405,7 +697,8 @@ function createContext(name) {
405
697
  remove: /* @__PURE__ */ __name((key) => contextStorage.cache.delete(key), "remove"),
406
698
  removeAll: /* @__PURE__ */ __name(() => contextStorage.cache.clear(), "removeAll"),
407
699
  clear: /* @__PURE__ */ __name(() => contextStorage.cache.clear(), "clear")
408
- }
700
+ },
701
+ encryptionKey: encKey
409
702
  };
410
703
  }
411
704
  function listContexts() {
@@ -422,8 +715,11 @@ var init_platform = __esm({
422
715
  "core/platform.ts"() {
423
716
  init_esm_shims();
424
717
  init_internal();
718
+ init_encryption();
425
719
  __name(generateSessionId, "generateSessionId");
426
720
  __name(detectPlatform, "detectPlatform");
721
+ __name(_isBun, "_isBun");
722
+ __name(isBun, "isBun");
427
723
  __name(isBrowser, "isBrowser");
428
724
  __name(isNode, "isNode");
429
725
  __name(isDeno, "isDeno");
@@ -432,6 +728,7 @@ var init_platform = __esm({
432
728
  __name(getLocalStorage, "getLocalStorage");
433
729
  __name(hasIndexedDB, "hasIndexedDB");
434
730
  __name(hasSqlJs, "hasSqlJs");
731
+ __name(hasBunSqlite, "hasBunSqlite");
435
732
  __name(hasDispatchEvent, "hasDispatchEvent");
436
733
  __name(getCapabilities, "getCapabilities");
437
734
  _eventListenerStorage = /* @__PURE__ */ new Map();
@@ -457,6 +754,9 @@ function _getFallbackStorage() {
457
754
  }
458
755
  return _fallbackStorageByContext.get(key);
459
756
  }
757
+ function _isEncryptedEnvelope(value) {
758
+ return encryption.isEncrypted(value);
759
+ }
460
760
  function _getPrefix() {
461
761
  const contextName = internal_default.currentContext || "";
462
762
  return contextName ? `${contextName}-` : `memorio_store_`;
@@ -493,17 +793,23 @@ function _remove(prefixedName) {
493
793
  }
494
794
  return false;
495
795
  }
496
- var _localStorage, _fallbackStorageByContext, _hasStorage, STORE_INSTANCE_KEY, store;
796
+ var _localStorage, _fallbackStorageByContext, _hasStorage, _encryptionKey, _onError, _maxObjectSize, _maxTotalSize, STORE_INSTANCE_KEY, store;
497
797
  var init_store = __esm({
498
798
  "functions/store/index.ts"() {
499
799
  init_esm_shims();
500
800
  init_platform();
501
801
  init_internal();
502
802
  init_message();
803
+ init_encryption();
503
804
  _localStorage = getLocalStorage();
504
805
  _fallbackStorageByContext = /* @__PURE__ */ new Map();
505
806
  __name(_getFallbackStorage, "_getFallbackStorage");
506
807
  _hasStorage = _localStorage !== null;
808
+ _encryptionKey = null;
809
+ _onError = null;
810
+ _maxObjectSize = 0;
811
+ _maxTotalSize = 0;
812
+ __name(_isEncryptedEnvelope, "_isEncryptedEnvelope");
507
813
  __name(_getPrefix, "_getPrefix");
508
814
  __name(_prefixKey, "_prefixKey");
509
815
  __name(_read, "_read");
@@ -520,16 +826,24 @@ var init_store = __esm({
520
826
  /**
521
827
  * Gets a value from storage.
522
828
  * @param name The key to retrieve.
523
- * @returns The parsed value or null if not found.
829
+ * @param opts Optional { decrypt: key } to decrypt an encrypted envelope.
830
+ * When no key is passed, encrypted envelopes are returned as-is.
831
+ * If a default key was configured via store.config(), it is used automatically.
832
+ * @returns The parsed value, a Promise<parsed value> when decrypting, or null if not found.
524
833
  */
525
834
  get: {
526
- value: /* @__PURE__ */ __name((name) => {
835
+ value: /* @__PURE__ */ __name((name, opts) => {
527
836
  if (!name) {
528
837
  console.warn("[memorio store] store.get() called with empty or null key - returning null");
529
838
  return null;
530
839
  }
531
840
  try {
532
- return _read(_prefixKey(name));
841
+ const raw = _read(_prefixKey(name));
842
+ const key = opts?.decrypt ?? _encryptionKey;
843
+ if (key && _isEncryptedEnvelope(raw)) {
844
+ return encryption.decrypt(raw, key);
845
+ }
846
+ return raw;
533
847
  } catch (err) {
534
848
  message(`Error parsing store item '${name}': ${err}`);
535
849
  }
@@ -554,10 +868,13 @@ var init_store = __esm({
554
868
  * Sets a value in storage.
555
869
  * @param name The key to set.
556
870
  * @param value The value to store (objects, arrays, primitives).
557
- * @returns true if written, false if the key was rejected.
871
+ * @param opts Optional { encrypt: key } to encrypt the value before storage.
872
+ * If a default key was configured via store.config(), it is used automatically.
873
+ * When encryption is used, returns a Promise<boolean>.
874
+ * @returns true if written, false if rejected or error.
558
875
  */
559
876
  set: {
560
- value: /* @__PURE__ */ __name((name, value) => {
877
+ value: /* @__PURE__ */ __name((name, value, opts) => {
561
878
  if (!name) {
562
879
  console.warn("[memorio store] store.set() called with empty or null key - write aborted");
563
880
  return false;
@@ -569,15 +886,66 @@ var init_store = __esm({
569
886
  message("Storing functions is not secure and is blocked for safety.");
570
887
  return false;
571
888
  }
889
+ if (_maxObjectSize > 0 || _maxTotalSize > 0) {
890
+ let serializedSize = 0;
891
+ try {
892
+ serializedSize = new TextEncoder().encode(JSON.stringify(value)).length;
893
+ } catch {
894
+ serializedSize = 0;
895
+ }
896
+ if (_maxObjectSize > 0 && serializedSize > _maxObjectSize) {
897
+ const err = new Error(`Object size (${serializedSize} bytes) exceeds maxObjectSize (${_maxObjectSize} bytes)`);
898
+ _onError?.(err, { operation: "set" });
899
+ return false;
900
+ }
901
+ if (_maxTotalSize > 0) {
902
+ const currentTotal = store.size() * 1024;
903
+ const existingItemSize = _hasStorage ? _localStorage.getItem(prefixedName)?.length ?? 0 : _getFallbackStorage().get(prefixedName)?.length ?? 0;
904
+ const projected = currentTotal * 1024 - existingItemSize + serializedSize;
905
+ if (projected > _maxTotalSize) {
906
+ const err = new Error(`Total store size (${projected} bytes) exceeds maxTotalSize (${_maxTotalSize} bytes)`);
907
+ _onError?.(err, { operation: "set" });
908
+ return false;
909
+ }
910
+ }
911
+ }
912
+ const key = opts?.encrypt ?? _encryptionKey;
913
+ if (key) {
914
+ return encryption.encrypt(value, key).then((env) => {
915
+ _write(prefixedName, env);
916
+ return true;
917
+ }).catch((err) => {
918
+ message(`Error encrypting store item '${name}': ${err}`);
919
+ _onError?.(err, { operation: "set" });
920
+ return false;
921
+ });
922
+ }
572
923
  try {
573
924
  _write(prefixedName, value);
574
925
  } catch (err) {
575
926
  message(`Error setting store item '${name}': ${err}`);
927
+ _onError?.(err, { operation: "set" });
576
928
  return false;
577
929
  }
578
930
  return true;
579
931
  }, "value")
580
932
  },
933
+ /**
934
+ * Configure store-wide behavior.
935
+ * @param opts Optional { encryptionKey } to enable automatic encryption
936
+ * for all set/get operations. When set, values are encrypted
937
+ * on write and decrypted on read (if the value is an envelope).
938
+ * @returns The store instance for chaining.
939
+ */
940
+ config: {
941
+ value: /* @__PURE__ */ __name((opts) => {
942
+ if (opts.encryptionKey !== void 0) _encryptionKey = opts.encryptionKey;
943
+ if (opts.onError !== void 0) _onError = opts.onError;
944
+ if (opts.maxObjectSize !== void 0) _maxObjectSize = opts.maxObjectSize;
945
+ if (opts.maxTotalSize !== void 0) _maxTotalSize = opts.maxTotalSize;
946
+ return store;
947
+ }, "value")
948
+ },
581
949
  /**
582
950
  * Removes a value from storage.
583
951
  * @param name The key to remove.
@@ -1163,6 +1531,91 @@ var init_idb = __esm({
1163
1531
  }
1164
1532
  });
1165
1533
 
1534
+ // functions/sqlite/tools/bun-sqlite-adapter.ts
1535
+ var bun_sqlite_adapter_exports = {};
1536
+ __export(bun_sqlite_adapter_exports, {
1537
+ BunSqlJsDatabase: () => BunSqlJsDatabase,
1538
+ createBunSqlJs: () => createBunSqlJs
1539
+ });
1540
+ async function _loadDatabase() {
1541
+ if (!_DatabaseClass) {
1542
+ const mod = await import('bun:sqlite');
1543
+ _DatabaseClass = mod.Database;
1544
+ }
1545
+ return _DatabaseClass;
1546
+ }
1547
+ async function createBunSqlJs() {
1548
+ await _loadDatabase();
1549
+ return {
1550
+ Database: BunSqlJsDatabase,
1551
+ version: "bun:sqlite"
1552
+ };
1553
+ }
1554
+ var _DatabaseClass, BunSqlJsDatabase;
1555
+ var init_bun_sqlite_adapter = __esm({
1556
+ "functions/sqlite/tools/bun-sqlite-adapter.ts"() {
1557
+ init_esm_shims();
1558
+ _DatabaseClass = null;
1559
+ __name(_loadDatabase, "_loadDatabase");
1560
+ BunSqlJsDatabase = class {
1561
+ static {
1562
+ __name(this, "BunSqlJsDatabase");
1563
+ }
1564
+ _db;
1565
+ _lastRunChanges = 0;
1566
+ constructor(data) {
1567
+ this._lastRunChanges = 0;
1568
+ if (typeof data === "string") {
1569
+ this._db = new _DatabaseClass(data);
1570
+ } else {
1571
+ this._db = new _DatabaseClass(":memory:");
1572
+ }
1573
+ }
1574
+ run(sql, params = []) {
1575
+ const info = this._db.run(sql, ...params);
1576
+ this._lastRunChanges = info?.changes ?? 0;
1577
+ return info;
1578
+ }
1579
+ getRowsModified() {
1580
+ return this._lastRunChanges;
1581
+ }
1582
+ prepare(sql, params = []) {
1583
+ const rows = params.length > 0 ? this._db.query(sql).all(...params) : this._db.query(sql).all();
1584
+ return {
1585
+ _rows: rows,
1586
+ _idx: -1,
1587
+ step() {
1588
+ this._idx++;
1589
+ return this._idx < this._rows.length;
1590
+ },
1591
+ getAsObject() {
1592
+ return this._rows[this._idx] || {};
1593
+ },
1594
+ get() {
1595
+ return this._rows[this._idx] ? Object.values(this._rows[this._idx]) : [];
1596
+ },
1597
+ free() {
1598
+ this._rows = null;
1599
+ }
1600
+ };
1601
+ }
1602
+ export() {
1603
+ throw new Error("Bun:sqlite does not support in-memory export - use store/session for persistence, or use the sql.js backend for export/import operations");
1604
+ }
1605
+ close() {
1606
+ try {
1607
+ this._db.close();
1608
+ } catch {
1609
+ }
1610
+ }
1611
+ get version() {
1612
+ return "bun:sqlite";
1613
+ }
1614
+ };
1615
+ __name(createBunSqlJs, "createBunSqlJs");
1616
+ }
1617
+ });
1618
+
1166
1619
  // functions/sqlite/tools/db.support.ts
1167
1620
  var db_support_exports2 = {};
1168
1621
  function _inDocument() {
@@ -1223,11 +1676,18 @@ var init_db_support2 = __esm({
1223
1676
  return g3.initSqlJs || g3;
1224
1677
  }, "_loadSqlJsFromCdn");
1225
1678
  sqlite.db.support = () => {
1226
- return hasSqlJs();
1679
+ return hasSqlJs() || hasBunSqlite();
1227
1680
  };
1228
1681
  sqlite.db.getSQL = async () => {
1229
1682
  if (_SQL) return _SQL;
1230
1683
  if (_loading) return _loading;
1684
+ if (hasBunSqlite()) {
1685
+ const { createBunSqlJs: createBunSqlJs2 } = await Promise.resolve().then(() => (init_bun_sqlite_adapter(), bun_sqlite_adapter_exports));
1686
+ _SQL = await createBunSqlJs2();
1687
+ globalThis.sqliteVersion = _SQL.version;
1688
+ message_default("Memorio SQLite: bun:sqlite engine loaded");
1689
+ return _SQL;
1690
+ }
1231
1691
  const g3 = globalThis;
1232
1692
  const cfg = g3.sqliteConfig || {};
1233
1693
  const p = (async () => {
@@ -1254,7 +1714,7 @@ var init_db_support2 = __esm({
1254
1714
  } catch (_) {
1255
1715
  }
1256
1716
  try {
1257
- sqlite._warning = "Memorio SQLite: sql.js could not be loaded. Install sql.js (npm i sql.js) and pass a loader via sqlite.config({ loader: () => <your sql.js import>() }).";
1717
+ sqlite._warning = "Memorio SQLite: sql.js could not be loaded. Install sql.js (npm i sql.js) and pass a loader via sqlite.config({ loader: () => import(<your sql.js import>()) }).";
1258
1718
  } catch (_) {
1259
1719
  }
1260
1720
  console.warn("Memorio SQLite: failed to load sql.js", err);
@@ -1277,7 +1737,7 @@ function _ns() {
1277
1737
  function _key(name) {
1278
1738
  return `memorio:sqlite:db:${_ns()}:${name}`;
1279
1739
  }
1280
- function _b64encode(buf) {
1740
+ function _b64encode2(buf) {
1281
1741
  const bytes = buf instanceof Uint8Array ? buf : new Uint8Array(buf);
1282
1742
  let binary = "";
1283
1743
  const len = bytes.byteLength;
@@ -1285,7 +1745,7 @@ function _b64encode(buf) {
1285
1745
  if (typeof btoa === "function") return btoa(binary);
1286
1746
  return typeof Buffer !== "undefined" ? Buffer.from(bytes).toString("base64") : "";
1287
1747
  }
1288
- function _b64decode(b64) {
1748
+ function _b64decode2(b64) {
1289
1749
  if (typeof Buffer !== "undefined") {
1290
1750
  return new Uint8Array(Buffer.from(b64, "base64"));
1291
1751
  }
@@ -1307,7 +1767,7 @@ function saveSnapshot(name) {
1307
1767
  }
1308
1768
  try {
1309
1769
  const blob = db.export();
1310
- store.set(_key(name), _b64encode(blob));
1770
+ store.set(_key(name), _b64encode2(blob));
1311
1771
  message_default(`Memorio SQLite: persisted '${name}' to store`);
1312
1772
  resolve(true);
1313
1773
  } catch (err) {
@@ -1320,7 +1780,7 @@ function loadSnapshot(name) {
1320
1780
  const b64 = store.get(_key(name));
1321
1781
  if (!b64) return null;
1322
1782
  try {
1323
- return _b64decode(b64);
1783
+ return _b64decode2(b64);
1324
1784
  } catch {
1325
1785
  return null;
1326
1786
  }
@@ -1355,8 +1815,8 @@ var init_persist = __esm({
1355
1815
  _exportTimers = {};
1356
1816
  __name(_ns, "_ns");
1357
1817
  __name(_key, "_key");
1358
- __name(_b64encode, "_b64encode");
1359
- __name(_b64decode, "_b64decode");
1818
+ __name(_b64encode2, "_b64encode");
1819
+ __name(_b64decode2, "_b64decode");
1360
1820
  __name(saveSnapshot, "saveSnapshot");
1361
1821
  __name(loadSnapshot, "loadSnapshot");
1362
1822
  __name(removeSnapshot, "removeSnapshot");
@@ -1561,7 +2021,14 @@ var init_db_export = __esm({
1561
2021
  init_sqlite();
1562
2022
  sqlite.db.export = async (name = "memorio") => {
1563
2023
  const db = sqlite.db.get(name);
1564
- return db.export();
2024
+ try {
2025
+ return db.export();
2026
+ } catch (err) {
2027
+ if (db && db.version === "bun:sqlite") {
2028
+ throw new Error(`memorio sqlite: export is not supported under Bun's native sqlite. Use \`store\` or \`session\` for persistence instead. If you need a binary dump, run this code under the browser/sql.js backend.`);
2029
+ }
2030
+ throw err;
2031
+ }
1565
2032
  };
1566
2033
  }
1567
2034
  });
@@ -1645,13 +2112,14 @@ var init_data_get2 = __esm({
1645
2112
  });
1646
2113
 
1647
2114
  // functions/sqlite/index.ts
1648
- var _hasSqlJs, sqlite;
2115
+ var _hasSqlJs, _hasBunSqlite, sqlite;
1649
2116
  var init_sqlite = __esm({
1650
2117
  "functions/sqlite/index.ts"() {
1651
2118
  init_esm_shims();
1652
2119
  init_platform();
1653
2120
  init_env();
1654
2121
  _hasSqlJs = hasSqlJs();
2122
+ _hasBunSqlite = hasBunSqlite();
1655
2123
  sqlite = {
1656
2124
  db: {},
1657
2125
  query: {},
@@ -1678,7 +2146,7 @@ var init_sqlite = __esm({
1678
2146
  return g3.sqliteReady;
1679
2147
  }, "get")
1680
2148
  });
1681
- if (_hasSqlJs) {
2149
+ if (_hasSqlJs || _hasBunSqlite) {
1682
2150
  (async () => {
1683
2151
  Object.defineProperty(sqlite, "db", { value: {}, writable: false, configurable: true, enumerable: true });
1684
2152
  Object.defineProperty(sqlite, "query", { value: {}, writable: false, configurable: true, enumerable: true });
@@ -1706,11 +2174,11 @@ var init_sqlite = __esm({
1706
2174
  })();
1707
2175
  } else {
1708
2176
  sqlite._disabled = true;
1709
- sqlite._warning = 'SQLite (sql.js) is not available in this environment. It requires a browser with WebAssembly support. Install the optional "sql.js" package to enable it.';
2177
+ sqlite._warning = 'SQLite is not available in this environment. It requires a browser with WebAssembly (sql.js) or the Bun runtime (bun:sqlite). Install the optional "sql.js" package to enable it in browsers.';
1710
2178
  if (DEV) {
1711
2179
  globalThis.sqliteDisabled = true;
1712
2180
  globalThis.sqliteWarning = sqlite._warning;
1713
- console.warn("Memorio SQLite: sql.js is not available in this environment (requires browser + WebAssembly). Use store or session for persistence.");
2181
+ console.warn("Memorio SQLite: no engine available in this environment (requires browser + WebAssembly, or Bun runtime with bun:sqlite). Use store or session for persistence.");
1714
2182
  }
1715
2183
  }
1716
2184
  }
@@ -2722,6 +3190,7 @@ init_esm_shims();
2722
3190
  init_platform();
2723
3191
  init_internal();
2724
3192
  init_message();
3193
+ init_encryption();
2725
3194
  var _sessionStorage = getSessionStorage();
2726
3195
  var _fallbackStorageByContext2 = /* @__PURE__ */ new Map();
2727
3196
  function _getFallbackStorage2() {
@@ -2734,6 +3203,14 @@ function _getFallbackStorage2() {
2734
3203
  }
2735
3204
  __name(_getFallbackStorage2, "_getFallbackStorage");
2736
3205
  var _hasStorage2 = _sessionStorage !== null;
3206
+ var _encryptionKey2 = null;
3207
+ var _onError2 = null;
3208
+ var _maxObjectSize2 = 0;
3209
+ var _maxTotalSize2 = 0;
3210
+ function _isEncryptedEnvelope2(value) {
3211
+ return encryption.isEncrypted(value);
3212
+ }
3213
+ __name(_isEncryptedEnvelope2, "_isEncryptedEnvelope");
2737
3214
  function _getPrefix2() {
2738
3215
  const contextName = internal_default.currentContext || "";
2739
3216
  return contextName ? `${contextName}-` : `memorio_session_`;
@@ -2787,16 +3264,22 @@ if (globalThis[SESSION_INSTANCE_KEY]) {
2787
3264
  /**
2788
3265
  * Gets a value from storage.
2789
3266
  * @param name The key to retrieve.
2790
- * @returns The parsed value or null if not found.
3267
+ * @param opts Optional { decrypt: key } to decrypt an encrypted envelope.
3268
+ * @returns The parsed value, a Promise when decrypting, or null if not found.
2791
3269
  */
2792
3270
  get: {
2793
- value: /* @__PURE__ */ __name((name) => {
3271
+ value: /* @__PURE__ */ __name((name, opts) => {
2794
3272
  if (!name) {
2795
3273
  console.warn("[memorio session] session.get() called with empty or null key - returning null");
2796
3274
  return null;
2797
3275
  }
2798
3276
  try {
2799
- return _read2(_prefixKey2(name));
3277
+ const raw = _read2(_prefixKey2(name));
3278
+ const key = opts?.decrypt ?? _encryptionKey2;
3279
+ if (key && _isEncryptedEnvelope2(raw)) {
3280
+ return encryption.decrypt(raw, key);
3281
+ }
3282
+ return raw;
2800
3283
  } catch (err) {
2801
3284
  message(`Error parsing session item '${name}':${err}`);
2802
3285
  }
@@ -2807,10 +3290,11 @@ if (globalThis[SESSION_INSTANCE_KEY]) {
2807
3290
  * Sets a value in storage.
2808
3291
  * @param name The key to set.
2809
3292
  * @param value The value to store.
2810
- * @returns true if written, false if the key was rejected.
3293
+ * @param opts Optional { encrypt: key } to encrypt before storage.
3294
+ * @returns true if written, false if rejected. Returns a Promise when encrypting.
2811
3295
  */
2812
3296
  set: {
2813
- value: /* @__PURE__ */ __name((name, value) => {
3297
+ value: /* @__PURE__ */ __name((name, value, opts) => {
2814
3298
  if (!name) {
2815
3299
  console.warn("[memorio session] session.set() called with empty or null key - write aborted");
2816
3300
  return false;
@@ -2822,15 +3306,63 @@ if (globalThis[SESSION_INSTANCE_KEY]) {
2822
3306
  message("It's not secure to session functions.");
2823
3307
  return false;
2824
3308
  }
3309
+ if (_maxObjectSize2 > 0 || _maxTotalSize2 > 0) {
3310
+ let serializedSize = 0;
3311
+ try {
3312
+ serializedSize = new TextEncoder().encode(JSON.stringify(value)).length;
3313
+ } catch {
3314
+ serializedSize = 0;
3315
+ }
3316
+ if (_maxObjectSize2 > 0 && serializedSize > _maxObjectSize2) {
3317
+ const err = new Error(`Object size (${serializedSize} bytes) exceeds maxObjectSize (${_maxObjectSize2} bytes)`);
3318
+ _onError2?.(err, { operation: "set" });
3319
+ return false;
3320
+ }
3321
+ if (_maxTotalSize2 > 0) {
3322
+ const currentTotal = session.size() * 1024;
3323
+ const existingItemSize = _sessionStorage ? _sessionStorage.getItem(prefixedName)?.length ?? 0 : _getFallbackStorage2().get(prefixedName)?.length ?? 0;
3324
+ const projected = currentTotal - existingItemSize + serializedSize;
3325
+ if (projected > _maxTotalSize2) {
3326
+ const err = new Error(`Total session size (${projected} bytes) exceeds maxTotalSize (${_maxTotalSize2} bytes)`);
3327
+ _onError2?.(err, { operation: "set" });
3328
+ return false;
3329
+ }
3330
+ }
3331
+ }
3332
+ const key = opts?.encrypt ?? _encryptionKey2;
3333
+ if (key) {
3334
+ return encryption.encrypt(value, key).then((env) => {
3335
+ _write2(prefixedName, env);
3336
+ return true;
3337
+ }).catch((err) => {
3338
+ message(`Error encrypting session item '${name}': ${err}`);
3339
+ _onError2?.(err, { operation: "set" });
3340
+ return false;
3341
+ });
3342
+ }
2825
3343
  try {
2826
3344
  _write2(prefixedName, value);
2827
3345
  } catch (err) {
2828
3346
  message(`Error setting session item '${name}': ${err}`);
3347
+ _onError2?.(err, { operation: "set" });
2829
3348
  return false;
2830
3349
  }
2831
3350
  return true;
2832
3351
  }, "value")
2833
3352
  },
3353
+ /**
3354
+ * Configure session-wide behavior.
3355
+ * @param opts { encryptionKey, onError, maxObjectSize, maxTotalSize }
3356
+ */
3357
+ config: {
3358
+ value: /* @__PURE__ */ __name((opts) => {
3359
+ if (opts.encryptionKey !== void 0) _encryptionKey2 = opts.encryptionKey;
3360
+ if (opts.onError !== void 0) _onError2 = opts.onError;
3361
+ if (opts.maxObjectSize !== void 0) _maxObjectSize2 = opts.maxObjectSize;
3362
+ if (opts.maxTotalSize !== void 0) _maxTotalSize2 = opts.maxTotalSize;
3363
+ return session;
3364
+ }, "value")
3365
+ },
2834
3366
  /**
2835
3367
  * Removes a value from storage.
2836
3368
  * @param name The key to remove.
@@ -3197,92 +3729,685 @@ var useObserver = /* @__PURE__ */ __name(((func, deps = []) => {
3197
3729
  }), "useObserver");
3198
3730
 
3199
3731
  // index.ts
3200
- init_message();
3732
+ init_encryption();
3201
3733
 
3202
- // functions/logger/index.ts
3734
+ // functions/computed/index.ts
3203
3735
  init_esm_shims();
3204
- init_internal();
3205
- init_message();
3206
3736
  init_env();
3207
- var defaultConfig = {
3208
- enabled: true,
3209
- logToConsole: true,
3210
- modules: ["state", "store", "session", "cache", "idb"],
3211
- maxEntries: 1e3
3212
- };
3213
- function isDebugEnabled() {
3214
- return DEV && internal_default.debug === true;
3737
+ init_message();
3738
+ var DEFAULT_EQUALITY = /* @__PURE__ */ __name((prev, next) => {
3739
+ if (prev === next) return true;
3740
+ if (prev == null || next == null) return false;
3741
+ if (typeof prev !== typeof next) return false;
3742
+ if (typeof prev !== "object") return false;
3743
+ try {
3744
+ return JSON.stringify(prev) === JSON.stringify(next);
3745
+ } catch {
3746
+ return false;
3747
+ }
3748
+ }, "DEFAULT_EQUALITY");
3749
+ var computedMap = /* @__PURE__ */ new Map();
3750
+ function _normalizeKey(key) {
3751
+ if (!key || typeof key !== "string") return "";
3752
+ const normalized = key.startsWith("state.") ? key : `state.${key}`;
3753
+ return normalized;
3754
+ }
3755
+ __name(_normalizeKey, "_normalizeKey");
3756
+ function _invalidate(key) {
3757
+ const entry = computedMap.get(key);
3758
+ if (!entry) return;
3759
+ const newValue = _recompute(entry);
3760
+ if (entry.equality(entry.lastValue, newValue)) {
3761
+ return;
3762
+ }
3763
+ entry.lastValue = newValue;
3764
+ for (const sub of entry.subscribers) {
3765
+ try {
3766
+ sub(newValue);
3767
+ } catch (err) {
3768
+ if (DEV) console.error("[memorio computed] subscriber error:", err);
3769
+ }
3770
+ }
3771
+ dispatch.set("memorio:computed:" + key, { detail: { key, value: newValue } });
3215
3772
  }
3216
- __name(isDebugEnabled, "isDebugEnabled");
3217
- var config = { ...defaultConfig };
3218
- var logHistory = [];
3219
- var configure = /* @__PURE__ */ __name((options) => {
3220
- config = { ...config, ...options };
3221
- }, "configure");
3222
- var enable = /* @__PURE__ */ __name(() => {
3223
- config.enabled = true;
3224
- }, "enable");
3225
- var disable = /* @__PURE__ */ __name(() => {
3226
- config.enabled = false;
3227
- }, "disable");
3228
- var isEnabled = /* @__PURE__ */ __name((module) => {
3229
- return config.enabled && config.modules.includes(module);
3230
- }, "isEnabled");
3231
- var log = /* @__PURE__ */ __name((module, action, path2, value, previousValue) => {
3232
- if (!isEnabled(module)) return;
3233
- const entry = {
3234
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3235
- module,
3236
- action,
3237
- path: path2,
3238
- value,
3239
- previousValue
3240
- };
3241
- logHistory.push(entry);
3242
- if (logHistory.length > config.maxEntries) {
3243
- logHistory.shift();
3773
+ __name(_invalidate, "_invalidate");
3774
+ function _readStatePath(path2) {
3775
+ const entry = computedMap.get(path2);
3776
+ if (entry) {
3777
+ return entry.lastValue;
3244
3778
  }
3245
- if (config.logToConsole && isDebugEnabled()) {
3246
- const prefix = `[Memorio:${module.toUpperCase()}]`;
3247
- const color = getModuleColor(module);
3248
- message_default(
3249
- `%c${prefix}%c ${action} ${path2},
3250
- color: ${color}; font-weight: bold,
3251
- color: inherit`
3252
- );
3253
- if (value !== void 0) {
3254
- message_default(` \u2192 value:${value}`);
3779
+ const normalized = path2.startsWith("state.") ? path2 : `state.${path2}`;
3780
+ const segments = normalized.replace(/^state\./, "").split(".");
3781
+ let current = globalThis.state;
3782
+ if (current) {
3783
+ for (const seg of segments) {
3784
+ if (current === null || current === void 0) break;
3785
+ try {
3786
+ current = current[seg];
3787
+ } catch {
3788
+ return void 0;
3789
+ }
3255
3790
  }
3256
- if (previousValue !== void 0) {
3257
- message_default(` \u2190 previous:${previousValue}`);
3791
+ }
3792
+ return current === void 0 ? null : current;
3793
+ }
3794
+ __name(_readStatePath, "_readStatePath");
3795
+ function _recompute(entry) {
3796
+ const newDeps = /* @__PURE__ */ new Set();
3797
+ const trackerGet = /* @__PURE__ */ __name((path2) => {
3798
+ if (!path2 || typeof path2 !== "string") return void 0;
3799
+ newDeps.add(path2);
3800
+ return _readStatePath(path2);
3801
+ }, "trackerGet");
3802
+ try {
3803
+ return entry.selector(trackerGet);
3804
+ } catch (err) {
3805
+ if (DEV) console.error("[memorio computed] selector error:", err);
3806
+ message_default(`[memorio computed] selector error: ${err}`);
3807
+ return entry.lastValue;
3808
+ }
3809
+ }
3810
+ __name(_recompute, "_recompute");
3811
+ function _setupDeps(key, entry, deps) {
3812
+ for (const off of entry._dispatchUnsubscribers) off();
3813
+ entry._dispatchUnsubscribers = [];
3814
+ for (const dep of deps) {
3815
+ if (computedMap.has(dep)) {
3816
+ const computedEvent = "memorio:computed:" + dep;
3817
+ const off = dispatch.listen(computedEvent, () => _invalidate(key));
3818
+ if (off) entry._dispatchUnsubscribers.push(off);
3819
+ } else {
3820
+ const off = dispatch.listen(dep, () => _invalidate(key));
3821
+ if (off) entry._dispatchUnsubscribers.push(off);
3258
3822
  }
3259
3823
  }
3260
- if (config.customHandler) {
3261
- config.customHandler(entry);
3824
+ entry.deps = deps;
3825
+ }
3826
+ __name(_setupDeps, "_setupDeps");
3827
+ function _compute(key, selector, opts) {
3828
+ const normalizedKey = _normalizeKey(key);
3829
+ const cacheKey = opts?.equalityKey ? `${opts.equalityKey}:${normalizedKey}` : normalizedKey;
3830
+ if (computedMap.has(cacheKey)) {
3831
+ const entry2 = computedMap.get(cacheKey);
3832
+ entry2.selector = selector;
3833
+ entry2.equality = opts?.equality || DEFAULT_EQUALITY;
3834
+ const newDeps2 = /* @__PURE__ */ new Set();
3835
+ const wrappedGet = /* @__PURE__ */ __name((path2) => {
3836
+ newDeps2.add(path2);
3837
+ return _readStatePath(path2);
3838
+ }, "wrappedGet");
3839
+ let newValue;
3840
+ try {
3841
+ newValue = selector(wrappedGet);
3842
+ } catch (err) {
3843
+ if (DEV) console.error("[memorio computed] selector error:", err);
3844
+ return entry2.lastValue;
3845
+ }
3846
+ if (entry2.equality(entry2.lastValue, newValue)) {
3847
+ return entry2.lastValue;
3848
+ }
3849
+ entry2.lastValue = newValue;
3850
+ _setupDeps(cacheKey, entry2, newDeps2);
3851
+ for (const sub of entry2.subscribers) {
3852
+ try {
3853
+ sub(newValue);
3854
+ } catch (err) {
3855
+ if (DEV) console.error("[memorio computed] subscriber error:", err);
3856
+ }
3857
+ }
3858
+ return newValue;
3859
+ }
3860
+ const newDeps = /* @__PURE__ */ new Set();
3861
+ const get = /* @__PURE__ */ __name((path2) => {
3862
+ newDeps.add(path2);
3863
+ return _readStatePath(path2);
3864
+ }, "get");
3865
+ let lastValue;
3866
+ try {
3867
+ lastValue = selector(get);
3868
+ } catch (err) {
3869
+ if (DEV) console.error("[memorio computed] selector error:", err);
3870
+ message_default(`[memorio computed] selector error: ${err}`);
3871
+ lastValue = null;
3262
3872
  }
3263
- }, "log");
3264
- var getModuleColor = /* @__PURE__ */ __name((module) => {
3265
- const colors = {
3266
- state: "#4CAF50",
3267
- store: "#2196F3",
3268
- session: "#FF9800",
3269
- cache: "#9C27B0",
3270
- idb: "#F44336"
3873
+ const entry = {
3874
+ selector,
3875
+ lastValue,
3876
+ deps: newDeps,
3877
+ equality: opts?.equality || DEFAULT_EQUALITY,
3878
+ subscribers: /* @__PURE__ */ new Set(),
3879
+ _dispatchUnsubscribers: []
3271
3880
  };
3272
- return colors[module] || "#888888";
3273
- }, "getModuleColor");
3274
- var getHistory = /* @__PURE__ */ __name(() => {
3275
- return [...logHistory];
3276
- }, "getHistory");
3277
- var clearHistory = /* @__PURE__ */ __name(() => {
3278
- logHistory.length = 0;
3279
- }, "clearHistory");
3280
- var getStats = /* @__PURE__ */ __name(() => {
3281
- const stats = {
3282
- total: logHistory.length,
3283
- state: 0,
3284
- store: 0,
3285
- session: 0,
3881
+ computedMap.set(cacheKey, entry);
3882
+ _setupDeps(cacheKey, entry, newDeps);
3883
+ return lastValue;
3884
+ }
3885
+ __name(_compute, "_compute");
3886
+ function _getValue(key) {
3887
+ const normalizedKey = _normalizeKey(key);
3888
+ const entry = computedMap.get(normalizedKey);
3889
+ if (!entry) return null;
3890
+ return entry.lastValue;
3891
+ }
3892
+ __name(_getValue, "_getValue");
3893
+ function _subscribe(key, cb) {
3894
+ const normalizedKey = _normalizeKey(key);
3895
+ const entry = computedMap.get(normalizedKey);
3896
+ if (!entry) {
3897
+ if (DEV) console.warn(`[memorio computed] subscribe: no computed value registered for key '${key}'`);
3898
+ return () => {
3899
+ };
3900
+ }
3901
+ entry.subscribers.add(cb);
3902
+ return () => {
3903
+ entry.subscribers.delete(cb);
3904
+ };
3905
+ }
3906
+ __name(_subscribe, "_subscribe");
3907
+ function _remove3(key) {
3908
+ const normalizedKey = _normalizeKey(key);
3909
+ if (!computedMap.has(normalizedKey)) return false;
3910
+ const entry = computedMap.get(normalizedKey);
3911
+ for (const off of entry._dispatchUnsubscribers) off();
3912
+ computedMap.delete(normalizedKey);
3913
+ return true;
3914
+ }
3915
+ __name(_remove3, "_remove");
3916
+ function _list() {
3917
+ return Array.from(computedMap.keys());
3918
+ }
3919
+ __name(_list, "_list");
3920
+ function _clear() {
3921
+ for (const [, entry] of computedMap) {
3922
+ for (const off of entry._dispatchUnsubscribers) off();
3923
+ }
3924
+ computedMap.clear();
3925
+ }
3926
+ __name(_clear, "_clear");
3927
+ var computed = {
3928
+ compute: _compute,
3929
+ getValue: _getValue,
3930
+ subscribe: _subscribe,
3931
+ remove: _remove3,
3932
+ list: _list,
3933
+ clear: _clear
3934
+ };
3935
+
3936
+ // functions/broadcast/index.ts
3937
+ init_esm_shims();
3938
+ init_env();
3939
+ init_message();
3940
+ var _channel = null;
3941
+ var _storageListener = null;
3942
+ var _originalDispatchSet = null;
3943
+ var _installed = false;
3944
+ var _targets = "all";
3945
+ var _isLocalChange = false;
3946
+ function _hasBroadcastChannel() {
3947
+ return typeof BroadcastChannel !== "undefined";
3948
+ }
3949
+ __name(_hasBroadcastChannel, "_hasBroadcastChannel");
3950
+ function _hasStorageEvents() {
3951
+ return typeof window !== "undefined" && "addEventListener" in window;
3952
+ }
3953
+ __name(_hasStorageEvents, "_hasStorageEvents");
3954
+ function _shouldSync(target) {
3955
+ if (_targets === "all") return true;
3956
+ return _targets === target;
3957
+ }
3958
+ __name(_shouldSync, "_shouldSync");
3959
+ function _onBroadcastMessage(event) {
3960
+ let msg;
3961
+ try {
3962
+ msg = event.data;
3963
+ } catch {
3964
+ return;
3965
+ }
3966
+ if (!msg || !msg.__memorio_sync) return;
3967
+ if (!_shouldSync(msg.target)) return;
3968
+ if (_isLocalChange) return;
3969
+ try {
3970
+ if (msg.target === "state" || msg.target === "all") {
3971
+ const s = globalThis.state;
3972
+ if (s) {
3973
+ _isLocalChange = true;
3974
+ try {
3975
+ const segments = msg.path.replace(/^state\./, "").split(".");
3976
+ let current = s;
3977
+ for (let i = 0; i < segments.length - 1; i++) {
3978
+ const seg = segments[i];
3979
+ if (current[seg] === void 0 || current[seg] === null) {
3980
+ current[seg] = {};
3981
+ }
3982
+ current = current[seg];
3983
+ }
3984
+ const lastSeg = segments[segments.length - 1];
3985
+ if (msg.action === "set") {
3986
+ current[lastSeg] = msg.value;
3987
+ } else if (msg.action === "delete") {
3988
+ delete current[lastSeg];
3989
+ }
3990
+ } finally {
3991
+ queueMicrotask(() => {
3992
+ _isLocalChange = false;
3993
+ });
3994
+ }
3995
+ }
3996
+ }
3997
+ } catch (err) {
3998
+ if (DEV) console.error("[memorio broadcast] apply state error:", err);
3999
+ }
4000
+ }
4001
+ __name(_onBroadcastMessage, "_onBroadcastMessage");
4002
+ function _onStorageEvent(e) {
4003
+ if (!e.key) return;
4004
+ const prefixes = [
4005
+ ["memorio_store_", "store"],
4006
+ ["memorio_session_", "session"]
4007
+ ];
4008
+ for (const [prefix, target] of prefixes) {
4009
+ if (e.key.startsWith(prefix)) {
4010
+ if (!_shouldSync(target)) continue;
4011
+ const cleanKey = e.key.slice(prefix.length);
4012
+ dispatch.set(`memorio:broadcast:${target}:${cleanKey}`, {
4013
+ detail: { key: cleanKey, oldValue: e.oldValue, newValue: e.newValue }
4014
+ });
4015
+ break;
4016
+ }
4017
+ }
4018
+ }
4019
+ __name(_onStorageEvent, "_onStorageEvent");
4020
+ function _wrapDispatchSet() {
4021
+ if (_originalDispatchSet !== null) return;
4022
+ _originalDispatchSet = dispatch.set;
4023
+ const original = dispatch.set;
4024
+ dispatch.set = (name, value) => {
4025
+ original(name, value);
4026
+ if (name.startsWith("state.") && _shouldSync("state") && _channel) {
4027
+ _isLocalChange = true;
4028
+ try {
4029
+ _channel.postMessage({
4030
+ __memorio_sync: true,
4031
+ target: "state",
4032
+ action: "set",
4033
+ path: name,
4034
+ value: _extractStateValue(name),
4035
+ timestamp: Date.now()
4036
+ });
4037
+ } finally {
4038
+ queueMicrotask(() => {
4039
+ _isLocalChange = false;
4040
+ });
4041
+ }
4042
+ }
4043
+ };
4044
+ }
4045
+ __name(_wrapDispatchSet, "_wrapDispatchSet");
4046
+ function _restoreDispatchSet() {
4047
+ if (_originalDispatchSet !== null) {
4048
+ dispatch.set = _originalDispatchSet;
4049
+ _originalDispatchSet = null;
4050
+ }
4051
+ }
4052
+ __name(_restoreDispatchSet, "_restoreDispatchSet");
4053
+ function _extractStateValue(path2) {
4054
+ const s = globalThis.state;
4055
+ if (!s) return void 0;
4056
+ try {
4057
+ const segments = path2.replace(/^state\./, "").split(".");
4058
+ let current = s;
4059
+ for (const seg of segments) {
4060
+ if (current === null || current === void 0) break;
4061
+ current = current[seg];
4062
+ }
4063
+ return current === void 0 ? null : current;
4064
+ } catch {
4065
+ return null;
4066
+ }
4067
+ }
4068
+ __name(_extractStateValue, "_extractStateValue");
4069
+ var broadcast = {
4070
+ install: /* @__PURE__ */ __name((channelName, opts) => {
4071
+ if (_installed) return;
4072
+ const name = channelName || opts?.channelName || "memorio_sync";
4073
+ _targets = opts?.targets || "all";
4074
+ if (_hasBroadcastChannel()) {
4075
+ _channel = new BroadcastChannel(name);
4076
+ _channel.addEventListener("message", _onBroadcastMessage);
4077
+ _installed = true;
4078
+ _wrapDispatchSet();
4079
+ if (DEV) message_default(`memorio broadcast: installed (channel="${name}", targets="${_targets}")`);
4080
+ }
4081
+ if (_hasStorageEvents()) {
4082
+ _storageListener = _onStorageEvent;
4083
+ window.addEventListener("storage", _storageListener);
4084
+ _installed = true;
4085
+ if (!_hasBroadcastChannel() && DEV) {
4086
+ message_default(`memorio broadcast: using storage event fallback (targets="${_targets}")`);
4087
+ }
4088
+ }
4089
+ if (!_installed) {
4090
+ console.warn("[memorio broadcast] Neither BroadcastChannel nor storage events are available in this environment.");
4091
+ }
4092
+ }, "install"),
4093
+ uninstall: /* @__PURE__ */ __name(() => {
4094
+ if (_channel) {
4095
+ _channel.removeEventListener("message", _onBroadcastMessage);
4096
+ _channel.close();
4097
+ _channel = null;
4098
+ }
4099
+ if (_storageListener && typeof window !== "undefined") {
4100
+ window.removeEventListener("storage", _storageListener);
4101
+ _storageListener = null;
4102
+ }
4103
+ _restoreDispatchSet();
4104
+ _installed = false;
4105
+ }, "uninstall"),
4106
+ isInstalled: /* @__PURE__ */ __name(() => _installed, "isInstalled"),
4107
+ broadcast: /* @__PURE__ */ __name((msg) => {
4108
+ if (!_channel) return;
4109
+ _channel.postMessage({ ...msg, timestamp: Date.now() });
4110
+ }, "broadcast")
4111
+ };
4112
+
4113
+ // functions/security/index.ts
4114
+ init_esm_shims();
4115
+ init_env();
4116
+ function _safeRandomUUID() {
4117
+ const g3 = globalThis;
4118
+ if (typeof g3.crypto !== "undefined" && typeof g3.crypto.randomUUID === "function") {
4119
+ try {
4120
+ return g3.crypto.randomUUID();
4121
+ } catch {
4122
+ }
4123
+ }
4124
+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
4125
+ }
4126
+ __name(_safeRandomUUID, "_safeRandomUUID");
4127
+ var REGEX_TIMEOUT_MS = 100;
4128
+ function _safeRegexTest(pattern, key) {
4129
+ if (/\(.*[+*?].*.*\)[+*?]/.test(pattern)) {
4130
+ if (DEV) console.warn(`[memorio security] Potentially dangerous regex blocked: ${pattern}`);
4131
+ return false;
4132
+ }
4133
+ if (pattern.length > 500) {
4134
+ if (DEV) console.warn("[memorio security] Regex pattern exceeds max length (500)");
4135
+ return false;
4136
+ }
4137
+ const startTime = Date.now();
4138
+ try {
4139
+ const regex = new RegExp(pattern);
4140
+ const result = regex.test(key);
4141
+ const elapsed = Date.now() - startTime;
4142
+ if (elapsed > REGEX_TIMEOUT_MS) {
4143
+ if (DEV) console.warn(`[memorio security] Slow regex detected (${elapsed}ms): ${pattern}`);
4144
+ }
4145
+ return result;
4146
+ } catch {
4147
+ return false;
4148
+ }
4149
+ }
4150
+ __name(_safeRegexTest, "_safeRegexTest");
4151
+ function addAccessRule(rules, pattern, perms) {
4152
+ const key = pattern instanceof RegExp ? pattern.source : pattern;
4153
+ rules.set(key, perms);
4154
+ return rules;
4155
+ }
4156
+ __name(addAccessRule, "addAccessRule");
4157
+ function hasPermission(rules, key, action, userId) {
4158
+ if (rules.size === 0) return true;
4159
+ for (const [pattern, perms] of rules) {
4160
+ let matches;
4161
+ if (typeof pattern === "function") {
4162
+ try {
4163
+ matches = pattern(key, userId);
4164
+ } catch {
4165
+ matches = false;
4166
+ }
4167
+ } else {
4168
+ matches = _safeRegexTest(pattern, key);
4169
+ }
4170
+ if (matches) {
4171
+ const allowed = perms.includes(action) || perms.includes("admin");
4172
+ if (!allowed) {
4173
+ logAudit({
4174
+ action,
4175
+ key,
4176
+ userId,
4177
+ success: false,
4178
+ error: "RBAC Denied: insufficient permissions"
4179
+ });
4180
+ }
4181
+ return allowed;
4182
+ }
4183
+ }
4184
+ logAudit({
4185
+ action: "permission_check",
4186
+ key,
4187
+ userId,
4188
+ success: false,
4189
+ error: "RBAC Denied: no matching rule"
4190
+ });
4191
+ return false;
4192
+ }
4193
+ __name(hasPermission, "hasPermission");
4194
+ var _auditLogger = null;
4195
+ function isAuditActive() {
4196
+ return _auditLogger !== null;
4197
+ }
4198
+ __name(isAuditActive, "isAuditActive");
4199
+ function setAuditLogger(logger3) {
4200
+ _auditLogger = logger3;
4201
+ }
4202
+ __name(setAuditLogger, "setAuditLogger");
4203
+ function logAudit(entry) {
4204
+ if (!_auditLogger) return;
4205
+ _auditLogger({
4206
+ timestamp: Date.now(),
4207
+ success: true,
4208
+ ...entry
4209
+ });
4210
+ }
4211
+ __name(logAudit, "logAudit");
4212
+ function sanitizeValue(value) {
4213
+ if (typeof value === "string") {
4214
+ let decoded = value.replace(/&#[xX]?[0-9a-fA-F]+;?/g, (match) => {
4215
+ const hexMatch = match.match(/&#x([0-9a-fA-F]+);?/i);
4216
+ if (hexMatch && hexMatch[1]) {
4217
+ return String.fromCharCode(parseInt(hexMatch[1], 16));
4218
+ }
4219
+ const decMatch = match.match(/&#([0-9]+);?/);
4220
+ if (decMatch && decMatch[1]) {
4221
+ return String.fromCharCode(parseInt(decMatch[1], 10));
4222
+ }
4223
+ return match;
4224
+ });
4225
+ try {
4226
+ decoded = decodeURIComponent(decoded);
4227
+ } catch {
4228
+ }
4229
+ decoded = decoded.replace(/(javascript|vbscript|data:text\/html|about:blank|chrome:)/gi, "[SEC-REMOVED]");
4230
+ return decoded.replace(/<script\b[^>]*>[\s\S]*?<\s*\/\s*script\b[^>]*>/gi, "[SEC-REMOVED]").replace(/on\w+\s*=/gi, "[SEC-REMOVED]=").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi, "[SEC-REMOVED]").replace(/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi, "[SEC-REMOVED]").replace(/<embed\b[^>]*>/gi, "[SEC-REMOVED]").replace(/<svg\b[^<]*(?:(?!<\/svg>)<[^<]*)*<\/svg>/gi, "[SEC-REMOVED]").replace(/<form\b[^<]*(?:(?!<\/form>)<[^<]*)*<\/form>/gi, "[SEC-REMOVED]").replace(/<base\b[^<]*(?:(?!<\/base>)<[^<]*)*<\/base>/gi, "[SEC-REMOVED]").replace(/<link\b[^<]*(?:(?!<\/link>)<[^<]*)*<\/link>/gi, "[SEC-REMOVED]").replace(/<meta\b[^<]*(?:(?!<\/meta>)<[^<]*)*<\/meta>/gi, "[SEC-REMOVED]").replace(/<style\b[^<]*(?:(?!<\/style>)<[^<]*)*<\/style>/gi, "[SEC-REMOVED]");
4231
+ }
4232
+ if (value && typeof value === "object" && !Array.isArray(value)) {
4233
+ const ctor = value.constructor?.name;
4234
+ if (ctor === "Object" || ctor === void 0) {
4235
+ const sanitized = {};
4236
+ for (const [k, v] of Object.entries(value)) {
4237
+ if (k === "__proto__" || k === "constructor" || k === "prototype") continue;
4238
+ sanitized[k] = sanitizeValue(v);
4239
+ }
4240
+ return sanitized;
4241
+ }
4242
+ return value;
4243
+ }
4244
+ if (Array.isArray(value)) {
4245
+ return value.map((v) => sanitizeValue(v));
4246
+ }
4247
+ return value;
4248
+ }
4249
+ __name(sanitizeValue, "sanitizeValue");
4250
+ function validateKey(key) {
4251
+ return /^[a-zA-Z0-9_.-]+$/.test(key) && key.length <= 256 && key.length > 0;
4252
+ }
4253
+ __name(validateKey, "validateKey");
4254
+ function recordConsent(consents, userId, purpose, granted) {
4255
+ const record = {
4256
+ id: _safeRandomUUID(),
4257
+ purpose,
4258
+ granted,
4259
+ timestamp: Date.now()
4260
+ };
4261
+ const user = consents.get(userId) || [];
4262
+ user.push(record);
4263
+ consents.set(userId, user);
4264
+ return record;
4265
+ }
4266
+ __name(recordConsent, "recordConsent");
4267
+ function hasConsent(consents, userId, purpose) {
4268
+ const userConsents = consents.get(userId);
4269
+ if (!userConsents) return false;
4270
+ for (let i = userConsents.length - 1; i >= 0; i--) {
4271
+ const record = userConsents[i];
4272
+ if (record && record.purpose === purpose) {
4273
+ return record.granted;
4274
+ }
4275
+ }
4276
+ return false;
4277
+ }
4278
+ __name(hasConsent, "hasConsent");
4279
+ function revokeConsent(consents, userId, purpose) {
4280
+ return recordConsent(consents, userId, purpose, false);
4281
+ }
4282
+ __name(revokeConsent, "revokeConsent");
4283
+ function getConsents(consents, userId) {
4284
+ return consents.get(userId) || [];
4285
+ }
4286
+ __name(getConsents, "getConsents");
4287
+ function exportUserData(consents, userId) {
4288
+ return {
4289
+ userId,
4290
+ exportedAt: Date.now(),
4291
+ consents: consents.get(userId) || []
4292
+ };
4293
+ }
4294
+ __name(exportUserData, "exportUserData");
4295
+ function deleteUserData(consents, userId) {
4296
+ const count = consents.get(userId)?.length || 0;
4297
+ consents.delete(userId);
4298
+ return { success: true, deletedConsents: count };
4299
+ }
4300
+ __name(deleteUserData, "deleteUserData");
4301
+ var security = {
4302
+ // Re-exports for convenience
4303
+ safeRandomUUID: _safeRandomUUID,
4304
+ safeRegexTest: _safeRegexTest,
4305
+ // RBAC
4306
+ addAccessRule,
4307
+ hasPermission,
4308
+ // Audit logging
4309
+ isAuditActive,
4310
+ setAuditLogger,
4311
+ logAudit,
4312
+ // Input sanitization
4313
+ sanitizeValue,
4314
+ validateKey,
4315
+ // Consent management
4316
+ recordConsent,
4317
+ hasConsent,
4318
+ revokeConsent,
4319
+ getConsents,
4320
+ exportUserData,
4321
+ deleteUserData
4322
+ };
4323
+
4324
+ // index.ts
4325
+ init_message();
4326
+
4327
+ // functions/logger/index.ts
4328
+ init_esm_shims();
4329
+ init_internal();
4330
+ init_message();
4331
+ init_env();
4332
+ var defaultConfig = {
4333
+ enabled: true,
4334
+ logToConsole: true,
4335
+ modules: ["state", "store", "session", "cache", "idb"],
4336
+ maxEntries: 1e3
4337
+ };
4338
+ function isDebugEnabled() {
4339
+ return DEV && internal_default.debug === true;
4340
+ }
4341
+ __name(isDebugEnabled, "isDebugEnabled");
4342
+ var config = { ...defaultConfig };
4343
+ var logHistory = [];
4344
+ var configure = /* @__PURE__ */ __name((options) => {
4345
+ config = { ...config, ...options };
4346
+ }, "configure");
4347
+ var enable = /* @__PURE__ */ __name(() => {
4348
+ config.enabled = true;
4349
+ }, "enable");
4350
+ var disable = /* @__PURE__ */ __name(() => {
4351
+ config.enabled = false;
4352
+ }, "disable");
4353
+ var isEnabled = /* @__PURE__ */ __name((module) => {
4354
+ return config.enabled && config.modules.includes(module);
4355
+ }, "isEnabled");
4356
+ var log = /* @__PURE__ */ __name((module, action, path2, value, previousValue) => {
4357
+ if (!isEnabled(module)) return;
4358
+ const entry = {
4359
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
4360
+ module,
4361
+ action,
4362
+ path: path2,
4363
+ value,
4364
+ previousValue
4365
+ };
4366
+ logHistory.push(entry);
4367
+ if (logHistory.length > config.maxEntries) {
4368
+ logHistory.shift();
4369
+ }
4370
+ if (config.logToConsole && isDebugEnabled()) {
4371
+ const prefix = `[Memorio:${module.toUpperCase()}]`;
4372
+ const color = getModuleColor(module);
4373
+ message_default(
4374
+ `%c${prefix}%c ${action} ${path2},
4375
+ color: ${color}; font-weight: bold,
4376
+ color: inherit`
4377
+ );
4378
+ if (value !== void 0) {
4379
+ message_default(` \u2192 value:${value}`);
4380
+ }
4381
+ if (previousValue !== void 0) {
4382
+ message_default(` \u2190 previous:${previousValue}`);
4383
+ }
4384
+ }
4385
+ if (config.customHandler) {
4386
+ config.customHandler(entry);
4387
+ }
4388
+ }, "log");
4389
+ var getModuleColor = /* @__PURE__ */ __name((module) => {
4390
+ const colors = {
4391
+ state: "#4CAF50",
4392
+ store: "#2196F3",
4393
+ session: "#FF9800",
4394
+ cache: "#9C27B0",
4395
+ idb: "#F44336"
4396
+ };
4397
+ return colors[module] || "#888888";
4398
+ }, "getModuleColor");
4399
+ var getHistory = /* @__PURE__ */ __name(() => {
4400
+ return [...logHistory];
4401
+ }, "getHistory");
4402
+ var clearHistory = /* @__PURE__ */ __name(() => {
4403
+ logHistory.length = 0;
4404
+ }, "clearHistory");
4405
+ var getStats = /* @__PURE__ */ __name(() => {
4406
+ const stats = {
4407
+ total: logHistory.length,
4408
+ state: 0,
4409
+ store: 0,
4410
+ session: 0,
3286
4411
  cache: 0,
3287
4412
  idb: 0,
3288
4413
  set: 0,
@@ -3462,228 +4587,67 @@ function reorder(items, fromIndex, toIndex) {
3462
4587
  if (fromIndex === toIndex) return items.map((i) => i.key);
3463
4588
  const reordered = [...items];
3464
4589
  const [removed] = reordered.splice(fromIndex, 1);
3465
- reordered.splice(toIndex, 0, removed);
3466
- return reordered.map((i) => i.key);
3467
- }
3468
- __name(reorder, "reorder");
3469
- function reindex(items) {
3470
- if (items.length === 0) return items;
3471
- const result = [];
3472
- let prev = null;
3473
- for (let i = 0; i < items.length; i++) {
3474
- const next = i < items.length - 1 ? items[i + 1].key : null;
3475
- const newItem = { ...items[i] };
3476
- if (prev === null) {
3477
- newItem.key = before(items[0].key);
3478
- } else if (next === null) {
3479
- newItem.key = after(prev);
3480
- } else {
3481
- newItem.key = between(prev, next);
3482
- }
3483
- result.push(newItem);
3484
- prev = newItem.key;
3485
- }
3486
- return result;
3487
- }
3488
- __name(reindex, "reindex");
3489
- var fractional = {
3490
- generateBetween,
3491
- firstKey,
3492
- after,
3493
- before,
3494
- between,
3495
- reorder,
3496
- reindex
3497
- };
3498
-
3499
- // index.ts
3500
- init_internal();
3501
- init_platform();
3502
-
3503
- // core/global.ts
3504
- init_esm_shims();
3505
- init_platform();
3506
- init_internal();
3507
-
3508
- // package.json
3509
- var package_default = {
3510
- version: "5.0.0"};
3511
-
3512
- // core/global.ts
3513
- init_env();
3514
- init_store();
3515
- init_idb();
3516
- init_sqlite();
3517
- init_message();
3518
-
3519
- // functions/typed/index.ts
3520
- init_esm_shims();
3521
- function typed() {
3522
- return state2;
3523
- }
3524
- __name(typed, "typed");
3525
-
3526
- // functions/history/index.ts
3527
- init_esm_shims();
3528
- init_internal();
3529
- init_env();
3530
- init_message();
3531
- function _clone(value) {
3532
- if (value === null || typeof value !== "object") return value;
3533
- try {
3534
- return deepRaw(value, /* @__PURE__ */ new WeakSet());
3535
- } catch (err) {
3536
- if (DEV) console.warn("[memorio history] deep clone failed:", err);
3537
- return value;
3538
- }
3539
- }
3540
- __name(_clone, "_clone");
3541
- var snapshot = /* @__PURE__ */ __name(() => {
3542
- return deepRaw(state2, /* @__PURE__ */ new WeakSet());
3543
- }, "snapshot");
3544
- var diff = /* @__PURE__ */ __name((snap) => {
3545
- const changes = [];
3546
- const _walk = /* @__PURE__ */ __name((oldObj, newObj, prefix) => {
3547
- const oldKeys = oldObj ? Object.keys(oldObj) : [];
3548
- const newKeys = newObj ? Object.keys(newObj) : [];
3549
- for (const key of newKeys) {
3550
- const newPath = prefix ? `${prefix}.${key}` : key;
3551
- const oldVal = oldObj ? oldObj[key] : void 0;
3552
- const newVal = newObj[key];
3553
- if (oldVal !== newVal) {
3554
- const oldType = typeof oldVal;
3555
- const newType = typeof newVal;
3556
- if (oldType !== newType || oldVal === void 0) {
3557
- changes.push({ path: newPath, oldValue: oldVal, newValue: newVal });
3558
- } else if (oldVal && typeof oldVal === "object") {
3559
- _walk(oldVal, newVal, newPath);
3560
- } else if (oldVal !== newVal) {
3561
- changes.push({ path: newPath, oldValue: oldVal, newValue: newVal });
3562
- }
3563
- }
3564
- }
3565
- for (const key of oldKeys) {
3566
- if (!(key in (newObj || {}))) {
3567
- const newPath = prefix ? `${prefix}.${key}` : key;
3568
- changes.push({ path: newPath, oldValue: oldObj[key], newValue: void 0 });
3569
- }
3570
- }
3571
- }, "_walk");
3572
- _walk(snap, deepRaw(state2), "");
3573
- return changes;
3574
- }, "diff");
3575
- var enableHistory = /* @__PURE__ */ __name((enabled = true) => {
3576
- internal_default.historyEnabled = enabled;
3577
- message_default(`[memorio history] Tracking ${enabled ? "enabled" : "disabled"}`);
3578
- }, "enableHistory");
3579
- var trace = /* @__PURE__ */ __name(() => {
3580
- return [...internal_default.mutations];
3581
- }, "trace");
3582
- var canUndo = /* @__PURE__ */ __name(() => {
3583
- return internal_default.canUndo();
3584
- }, "canUndo");
3585
- var canRedo = /* @__PURE__ */ __name(() => {
3586
- return internal_default.canRedo();
3587
- }, "canRedo");
3588
- var undo = /* @__PURE__ */ __name(() => {
3589
- if (!internal_default.historyEnabled) {
3590
- message_default("[memorio history] History is not enabled");
3591
- return void 0;
3592
- }
3593
- const record = internal_default.popUndo();
3594
- if (!record) return void 0;
3595
- _applyInverse2(record);
3596
- message_default(`[memorio history] Undid: ${record.action} ${record.path}`);
3597
- return record;
3598
- }, "undo");
3599
- var redo = /* @__PURE__ */ __name(() => {
3600
- if (!internal_default.historyEnabled) {
3601
- message_default("[memorio history] History is not enabled");
3602
- return void 0;
3603
- }
3604
- const record = internal_default.popRedo();
3605
- if (!record) return void 0;
3606
- _applyForward(record);
3607
- message_default(`[memorio history] Redid: ${record.action} ${record.path}`);
3608
- return record;
3609
- }, "redo");
3610
- function _applyInverse2(record) {
3611
- const wasEnabled = internal_default.historyEnabled;
3612
- internal_default.historyEnabled = false;
3613
- try {
3614
- if (record.action === "set") {
3615
- if (record.previousValue === void 0) {
3616
- _deletePath2(record.path);
3617
- } else {
3618
- _setPath2(record.path, record.previousValue);
3619
- }
3620
- } else if (record.action === "delete") {
3621
- if (record.previousValue !== void 0) {
3622
- _setPath2(record.path, record.previousValue);
3623
- }
3624
- }
3625
- } finally {
3626
- internal_default.historyEnabled = wasEnabled;
3627
- }
3628
- }
3629
- __name(_applyInverse2, "_applyInverse");
3630
- function _applyForward(record) {
3631
- const wasEnabled = internal_default.historyEnabled;
3632
- internal_default.historyEnabled = false;
3633
- try {
3634
- if (record.action === "set") {
3635
- _setPath2(record.path, record.newValue);
3636
- } else if (record.action === "delete") {
3637
- _deletePath2(record.path);
3638
- }
3639
- } finally {
3640
- internal_default.historyEnabled = wasEnabled;
3641
- }
4590
+ reordered.splice(toIndex, 0, removed);
4591
+ return reordered.map((i) => i.key);
3642
4592
  }
3643
- __name(_applyForward, "_applyForward");
3644
- function _setPath2(path2, value) {
3645
- const parts = path2.split(".");
3646
- let current = state2;
3647
- for (let i = 0; i < parts.length - 1; i++) {
3648
- const part = parts[i];
3649
- if (current[part] === void 0) {
3650
- current[part] = {};
4593
+ __name(reorder, "reorder");
4594
+ function reindex(items) {
4595
+ if (items.length === 0) return items;
4596
+ const result = [];
4597
+ let prev = null;
4598
+ for (let i = 0; i < items.length; i++) {
4599
+ const next = i < items.length - 1 ? items[i + 1].key : null;
4600
+ const newItem = { ...items[i] };
4601
+ if (prev === null) {
4602
+ newItem.key = before(items[0].key);
4603
+ } else if (next === null) {
4604
+ newItem.key = after(prev);
4605
+ } else {
4606
+ newItem.key = between(prev, next);
3651
4607
  }
3652
- current = current[part];
4608
+ result.push(newItem);
4609
+ prev = newItem.key;
3653
4610
  }
3654
- current[parts[parts.length - 1]] = value;
4611
+ return result;
3655
4612
  }
3656
- __name(_setPath2, "_setPath");
3657
- function _deletePath2(path2) {
3658
- const parts = path2.split(".");
3659
- if (parts.length === 1) {
3660
- state2.remove(parts[0]);
3661
- return;
3662
- }
3663
- let current = state2;
3664
- for (let i = 0; i < parts.length - 1; i++) {
3665
- const part = parts[i];
3666
- if (current[part] === void 0) return;
3667
- current = current[part];
3668
- }
3669
- delete current[parts[parts.length - 1]];
4613
+ __name(reindex, "reindex");
4614
+ var fractional = {
4615
+ generateBetween,
4616
+ firstKey,
4617
+ after,
4618
+ before,
4619
+ between,
4620
+ reorder,
4621
+ reindex
4622
+ };
4623
+
4624
+ // index.ts
4625
+ init_internal();
4626
+ init_platform();
4627
+
4628
+ // core/global.ts
4629
+ init_esm_shims();
4630
+ init_platform();
4631
+ init_internal();
4632
+
4633
+ // package.json
4634
+ var package_default = {
4635
+ version: "5.1.0"};
4636
+
4637
+ // core/global.ts
4638
+ init_env();
4639
+ init_store();
4640
+ init_idb();
4641
+ init_sqlite();
4642
+ init_encryption();
4643
+ init_message();
4644
+
4645
+ // functions/typed/index.ts
4646
+ init_esm_shims();
4647
+ function typed() {
4648
+ return state2;
3670
4649
  }
3671
- __name(_deletePath2, "_deletePath");
3672
- var rollback = /* @__PURE__ */ __name((snap) => {
3673
- state2.removeAll();
3674
- for (const key of Object.keys(snap)) {
3675
- state2[key] = _clone(snap[key]);
3676
- }
3677
- internal_default.clearHistory();
3678
- message_default("[memorio history] State rolled back to snapshot");
3679
- }, "rollback");
3680
- var clearHistory2 = /* @__PURE__ */ __name(() => {
3681
- internal_default.clearHistory();
3682
- message_default("[memorio history] History cleared");
3683
- }, "clearHistory");
3684
- var clearRedo = /* @__PURE__ */ __name(() => {
3685
- internal_default.clearRedo();
3686
- }, "clearRedo");
4650
+ __name(typed, "typed");
3687
4651
 
3688
4652
  // functions/memory/index.ts
3689
4653
  init_esm_shims();
@@ -4376,6 +5340,168 @@ var memory = {
4376
5340
  }
4377
5341
  };
4378
5342
 
5343
+ // functions/history/index.ts
5344
+ init_esm_shims();
5345
+ init_internal();
5346
+ init_env();
5347
+ init_message();
5348
+ function _clone(value) {
5349
+ if (value === null || typeof value !== "object") return value;
5350
+ try {
5351
+ return deepRaw(value, /* @__PURE__ */ new WeakSet());
5352
+ } catch (err) {
5353
+ if (DEV) console.warn("[memorio history] deep clone failed:", err);
5354
+ return value;
5355
+ }
5356
+ }
5357
+ __name(_clone, "_clone");
5358
+ var snapshot = /* @__PURE__ */ __name(() => {
5359
+ return deepRaw(state2, /* @__PURE__ */ new WeakSet());
5360
+ }, "snapshot");
5361
+ var diff = /* @__PURE__ */ __name((snap) => {
5362
+ const changes = [];
5363
+ const _walk = /* @__PURE__ */ __name((oldObj, newObj, prefix) => {
5364
+ const oldKeys = oldObj ? Object.keys(oldObj) : [];
5365
+ const newKeys = newObj ? Object.keys(newObj) : [];
5366
+ for (const key of newKeys) {
5367
+ const newPath = prefix ? `${prefix}.${key}` : key;
5368
+ const oldVal = oldObj ? oldObj[key] : void 0;
5369
+ const newVal = newObj[key];
5370
+ if (oldVal !== newVal) {
5371
+ const oldType = typeof oldVal;
5372
+ const newType = typeof newVal;
5373
+ if (oldType !== newType || oldVal === void 0) {
5374
+ changes.push({ path: newPath, oldValue: oldVal, newValue: newVal });
5375
+ } else if (oldVal && typeof oldVal === "object") {
5376
+ _walk(oldVal, newVal, newPath);
5377
+ } else if (oldVal !== newVal) {
5378
+ changes.push({ path: newPath, oldValue: oldVal, newValue: newVal });
5379
+ }
5380
+ }
5381
+ }
5382
+ for (const key of oldKeys) {
5383
+ if (!(key in (newObj || {}))) {
5384
+ const newPath = prefix ? `${prefix}.${key}` : key;
5385
+ changes.push({ path: newPath, oldValue: oldObj[key], newValue: void 0 });
5386
+ }
5387
+ }
5388
+ }, "_walk");
5389
+ _walk(snap, deepRaw(state2), "");
5390
+ return changes;
5391
+ }, "diff");
5392
+ var enableHistory = /* @__PURE__ */ __name((enabled = true) => {
5393
+ internal_default.historyEnabled = enabled;
5394
+ message_default(`[memorio history] Tracking ${enabled ? "enabled" : "disabled"}`);
5395
+ }, "enableHistory");
5396
+ var trace = /* @__PURE__ */ __name(() => {
5397
+ return [...internal_default.mutations];
5398
+ }, "trace");
5399
+ var canUndo = /* @__PURE__ */ __name(() => {
5400
+ return internal_default.canUndo();
5401
+ }, "canUndo");
5402
+ var canRedo = /* @__PURE__ */ __name(() => {
5403
+ return internal_default.canRedo();
5404
+ }, "canRedo");
5405
+ var undo = /* @__PURE__ */ __name(() => {
5406
+ if (!internal_default.historyEnabled) {
5407
+ message_default("[memorio history] History is not enabled");
5408
+ return void 0;
5409
+ }
5410
+ const record = internal_default.popUndo();
5411
+ if (!record) return void 0;
5412
+ _applyInverse2(record);
5413
+ message_default(`[memorio history] Undid: ${record.action} ${record.path}`);
5414
+ return record;
5415
+ }, "undo");
5416
+ var redo = /* @__PURE__ */ __name(() => {
5417
+ if (!internal_default.historyEnabled) {
5418
+ message_default("[memorio history] History is not enabled");
5419
+ return void 0;
5420
+ }
5421
+ const record = internal_default.popRedo();
5422
+ if (!record) return void 0;
5423
+ _applyForward(record);
5424
+ message_default(`[memorio history] Redid: ${record.action} ${record.path}`);
5425
+ return record;
5426
+ }, "redo");
5427
+ function _applyInverse2(record) {
5428
+ const wasEnabled = internal_default.historyEnabled;
5429
+ internal_default.historyEnabled = false;
5430
+ try {
5431
+ if (record.action === "set") {
5432
+ if (record.previousValue === void 0) {
5433
+ _deletePath2(record.path);
5434
+ } else {
5435
+ _setPath2(record.path, record.previousValue);
5436
+ }
5437
+ } else if (record.action === "delete") {
5438
+ if (record.previousValue !== void 0) {
5439
+ _setPath2(record.path, record.previousValue);
5440
+ }
5441
+ }
5442
+ } finally {
5443
+ internal_default.historyEnabled = wasEnabled;
5444
+ }
5445
+ }
5446
+ __name(_applyInverse2, "_applyInverse");
5447
+ function _applyForward(record) {
5448
+ const wasEnabled = internal_default.historyEnabled;
5449
+ internal_default.historyEnabled = false;
5450
+ try {
5451
+ if (record.action === "set") {
5452
+ _setPath2(record.path, record.newValue);
5453
+ } else if (record.action === "delete") {
5454
+ _deletePath2(record.path);
5455
+ }
5456
+ } finally {
5457
+ internal_default.historyEnabled = wasEnabled;
5458
+ }
5459
+ }
5460
+ __name(_applyForward, "_applyForward");
5461
+ function _setPath2(path2, value) {
5462
+ const parts = path2.split(".");
5463
+ let current = state2;
5464
+ for (let i = 0; i < parts.length - 1; i++) {
5465
+ const part = parts[i];
5466
+ if (current[part] === void 0) {
5467
+ current[part] = {};
5468
+ }
5469
+ current = current[part];
5470
+ }
5471
+ current[parts[parts.length - 1]] = value;
5472
+ }
5473
+ __name(_setPath2, "_setPath");
5474
+ function _deletePath2(path2) {
5475
+ const parts = path2.split(".");
5476
+ if (parts.length === 1) {
5477
+ state2.remove(parts[0]);
5478
+ return;
5479
+ }
5480
+ let current = state2;
5481
+ for (let i = 0; i < parts.length - 1; i++) {
5482
+ const part = parts[i];
5483
+ if (current[part] === void 0) return;
5484
+ current = current[part];
5485
+ }
5486
+ delete current[parts[parts.length - 1]];
5487
+ }
5488
+ __name(_deletePath2, "_deletePath");
5489
+ var rollback = /* @__PURE__ */ __name((snap) => {
5490
+ state2.removeAll();
5491
+ for (const key of Object.keys(snap)) {
5492
+ state2[key] = _clone(snap[key]);
5493
+ }
5494
+ internal_default.clearHistory();
5495
+ message_default("[memorio history] State rolled back to snapshot");
5496
+ }, "rollback");
5497
+ var clearHistory2 = /* @__PURE__ */ __name(() => {
5498
+ internal_default.clearHistory();
5499
+ message_default("[memorio history] History cleared");
5500
+ }, "clearHistory");
5501
+ var clearRedo = /* @__PURE__ */ __name(() => {
5502
+ internal_default.clearRedo();
5503
+ }, "clearRedo");
5504
+
4379
5505
  // core/global.ts
4380
5506
  if (!("memorio" in globalThis)) {
4381
5507
  Object.defineProperty(
@@ -4442,16 +5568,18 @@ if (!("memorio" in globalThis)) {
4442
5568
  }
4443
5569
  );
4444
5570
  memorio.memory = memory;
5571
+ memorio.encryption = encryption;
4445
5572
  initializePlatform();
4446
5573
  memorio.isBrowser = isBrowser;
4447
5574
  memorio.isNode = isNode;
4448
5575
  memorio.isDeno = isDeno;
5576
+ memorio.isBun = isBun;
4449
5577
  memorio.isEdge = isEdge;
4450
5578
  memorio.getCapabilities = getCapabilities;
4451
5579
  memorio.createContext = createContext;
4452
5580
  memorio.listContexts = listContexts;
4453
5581
  memorio.deleteContext = deleteContext;
4454
- memorio.isolate = (name) => createContext(name);
5582
+ memorio.isolate = (name, opts) => createContext(name, opts);
4455
5583
  Object.defineProperty(memorio, "setContext", { writable: false, enumerable: false, value: /* @__PURE__ */ __name((id) => setCurrentContext(id), "value") });
4456
5584
  Object.defineProperty(memorio, "getContext", { writable: false, enumerable: false, value: /* @__PURE__ */ __name(() => internal_default.currentContext, "value") });
4457
5585
  memorio.registerSchema = schema.register;
@@ -4459,6 +5587,9 @@ if (!("memorio" in globalThis)) {
4459
5587
  memorio.unregisterSchema = schema.unregister;
4460
5588
  memorio.listSchemas = schema.list;
4461
5589
  memorio.typed = typed;
5590
+ memorio.computed = computed;
5591
+ memorio.broadcast = broadcast;
5592
+ memorio.security = security;
4462
5593
  memorio.snapshot = snapshot;
4463
5594
  memorio.diff = diff;
4464
5595
  memorio.undo = undo;
@@ -4492,7 +5623,11 @@ if (!("memorio" in globalThis)) {
4492
5623
  idb,
4493
5624
  sqlite,
4494
5625
  observer,
4495
- useObserver
5626
+ useObserver,
5627
+ encryption,
5628
+ computed,
5629
+ broadcast,
5630
+ security
4496
5631
  };
4497
5632
  for (const key of Object.keys(globalDefinitions)) {
4498
5633
  if (!(key in globalThis)) {
@@ -4521,6 +5656,6 @@ var setContext = /* @__PURE__ */ __name((id) => internal_default.currentContext
4521
5656
  var getContext = /* @__PURE__ */ __name(() => internal_default.currentContext, "getContext");
4522
5657
  var index_default = memorio2;
4523
5658
 
4524
- export { DEV, PROD, abortTransaction, activeTransactionId, beginTransaction, cache, canMerge, canRedo, canUndo, clearHistory2 as clearHistory, clearRedo, commitTransaction, createContext, createMutation, currentTimestamp, currentTransaction, index_default as default, deleteContext, devtools, diff, diffToPatch, dispatch, enableHistory, events, fractional, generateCommitId, generateMutationId, generateTransactionId, getCapabilities, getContext, help, hlc, idb, internal_default as internal, isBrowser, isDeno, isEdge, isNode, isolate, listContexts, listSchemas, listTransactions, logger, memorio2 as memorio, memory, mergePatches, message, mutate, mutationToPatch, observer, propertyName, recordMutation, redo, registerSchema, rollback, schema, session, setContext, snapshot, sqlite, state2 as state, store, toPatch, trace, transaction, typed, undo, unregisterSchema, useObserver, validate };
5659
+ export { DEV, PROD, abortTransaction, activeTransactionId, beginTransaction, broadcast, cache, canMerge, canRedo, canUndo, clearHistory2 as clearHistory, clearRedo, commitTransaction, computed, createContext, createMutation, currentTimestamp, currentTransaction, index_default as default, deleteContext, devtools, diff, diffToPatch, dispatch, enableHistory, encryption, events, fractional, generateCommitId, generateMutationId, generateTransactionId, getCapabilities, getContext, help, hlc, idb, internal_default as internal, isBrowser, isBun, isDeno, isEdge, isNode, isolate, listContexts, listSchemas, listTransactions, logger, memorio2 as memorio, memory, mergePatches, message, mutate, mutationToPatch, observer, propertyName, recordMutation, redo, registerSchema, rollback, schema, security, session, setContext, snapshot, sqlite, state2 as state, store, toPatch, trace, transaction, typed, undo, unregisterSchema, useObserver, validate };
4525
5660
  //# sourceMappingURL=index.js.map
4526
5661
  //# sourceMappingURL=index.js.map