@dynlabs/react-native-immutable-file-cache 1.0.0-alpha.1

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 (113) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +415 -0
  3. package/lib/commonjs/adapters/memoryAdapter.js +266 -0
  4. package/lib/commonjs/adapters/memoryAdapter.js.map +1 -0
  5. package/lib/commonjs/adapters/rnfsAdapter.js +259 -0
  6. package/lib/commonjs/adapters/rnfsAdapter.js.map +1 -0
  7. package/lib/commonjs/adapters/webAdapter.js +432 -0
  8. package/lib/commonjs/adapters/webAdapter.js.map +1 -0
  9. package/lib/commonjs/core/adapter.js +2 -0
  10. package/lib/commonjs/core/adapter.js.map +1 -0
  11. package/lib/commonjs/core/cacheEngine.js +578 -0
  12. package/lib/commonjs/core/cacheEngine.js.map +1 -0
  13. package/lib/commonjs/core/errors.js +83 -0
  14. package/lib/commonjs/core/errors.js.map +1 -0
  15. package/lib/commonjs/core/hash.js +83 -0
  16. package/lib/commonjs/core/hash.js.map +1 -0
  17. package/lib/commonjs/core/indexStore.js +175 -0
  18. package/lib/commonjs/core/indexStore.js.map +1 -0
  19. package/lib/commonjs/core/mutex.js +143 -0
  20. package/lib/commonjs/core/mutex.js.map +1 -0
  21. package/lib/commonjs/core/prune.js +127 -0
  22. package/lib/commonjs/core/prune.js.map +1 -0
  23. package/lib/commonjs/core/types.js +6 -0
  24. package/lib/commonjs/core/types.js.map +1 -0
  25. package/lib/commonjs/factory.js +56 -0
  26. package/lib/commonjs/factory.js.map +1 -0
  27. package/lib/commonjs/index.js +110 -0
  28. package/lib/commonjs/index.js.map +1 -0
  29. package/lib/commonjs/index.native.js +74 -0
  30. package/lib/commonjs/index.native.js.map +1 -0
  31. package/lib/commonjs/index.web.js +75 -0
  32. package/lib/commonjs/index.web.js.map +1 -0
  33. package/lib/commonjs/types/react-native-fs.d.js +2 -0
  34. package/lib/commonjs/types/react-native-fs.d.js.map +1 -0
  35. package/lib/module/adapters/memoryAdapter.js +261 -0
  36. package/lib/module/adapters/memoryAdapter.js.map +1 -0
  37. package/lib/module/adapters/rnfsAdapter.js +251 -0
  38. package/lib/module/adapters/rnfsAdapter.js.map +1 -0
  39. package/lib/module/adapters/webAdapter.js +426 -0
  40. package/lib/module/adapters/webAdapter.js.map +1 -0
  41. package/lib/module/core/adapter.js +2 -0
  42. package/lib/module/core/adapter.js.map +1 -0
  43. package/lib/module/core/cacheEngine.js +571 -0
  44. package/lib/module/core/cacheEngine.js.map +1 -0
  45. package/lib/module/core/errors.js +71 -0
  46. package/lib/module/core/errors.js.map +1 -0
  47. package/lib/module/core/hash.js +76 -0
  48. package/lib/module/core/hash.js.map +1 -0
  49. package/lib/module/core/indexStore.js +168 -0
  50. package/lib/module/core/indexStore.js.map +1 -0
  51. package/lib/module/core/mutex.js +135 -0
  52. package/lib/module/core/mutex.js.map +1 -0
  53. package/lib/module/core/prune.js +116 -0
  54. package/lib/module/core/prune.js.map +1 -0
  55. package/lib/module/core/types.js +2 -0
  56. package/lib/module/core/types.js.map +1 -0
  57. package/lib/module/factory.js +49 -0
  58. package/lib/module/factory.js.map +1 -0
  59. package/lib/module/index.js +41 -0
  60. package/lib/module/index.js.map +1 -0
  61. package/lib/module/index.native.js +54 -0
  62. package/lib/module/index.native.js.map +1 -0
  63. package/lib/module/index.web.js +55 -0
  64. package/lib/module/index.web.js.map +1 -0
  65. package/lib/module/types/react-native-fs.d.js +2 -0
  66. package/lib/module/types/react-native-fs.d.js.map +1 -0
  67. package/lib/typescript/src/adapters/memoryAdapter.d.ts +23 -0
  68. package/lib/typescript/src/adapters/memoryAdapter.d.ts.map +1 -0
  69. package/lib/typescript/src/adapters/rnfsAdapter.d.ts +18 -0
  70. package/lib/typescript/src/adapters/rnfsAdapter.d.ts.map +1 -0
  71. package/lib/typescript/src/adapters/webAdapter.d.ts +30 -0
  72. package/lib/typescript/src/adapters/webAdapter.d.ts.map +1 -0
  73. package/lib/typescript/src/core/adapter.d.ts +105 -0
  74. package/lib/typescript/src/core/adapter.d.ts.map +1 -0
  75. package/lib/typescript/src/core/cacheEngine.d.ts +99 -0
  76. package/lib/typescript/src/core/cacheEngine.d.ts.map +1 -0
  77. package/lib/typescript/src/core/errors.d.ts +54 -0
  78. package/lib/typescript/src/core/errors.d.ts.map +1 -0
  79. package/lib/typescript/src/core/hash.d.ts +20 -0
  80. package/lib/typescript/src/core/hash.d.ts.map +1 -0
  81. package/lib/typescript/src/core/indexStore.d.ts +34 -0
  82. package/lib/typescript/src/core/indexStore.d.ts.map +1 -0
  83. package/lib/typescript/src/core/mutex.d.ts +49 -0
  84. package/lib/typescript/src/core/mutex.d.ts.map +1 -0
  85. package/lib/typescript/src/core/prune.d.ts +39 -0
  86. package/lib/typescript/src/core/prune.d.ts.map +1 -0
  87. package/lib/typescript/src/core/types.d.ts +109 -0
  88. package/lib/typescript/src/core/types.d.ts.map +1 -0
  89. package/lib/typescript/src/factory.d.ts +46 -0
  90. package/lib/typescript/src/factory.d.ts.map +1 -0
  91. package/lib/typescript/src/index.d.ts +20 -0
  92. package/lib/typescript/src/index.d.ts.map +1 -0
  93. package/lib/typescript/src/index.native.d.ts +37 -0
  94. package/lib/typescript/src/index.native.d.ts.map +1 -0
  95. package/lib/typescript/src/index.web.d.ts +38 -0
  96. package/lib/typescript/src/index.web.d.ts.map +1 -0
  97. package/package.json +125 -0
  98. package/src/adapters/memoryAdapter.ts +307 -0
  99. package/src/adapters/rnfsAdapter.ts +283 -0
  100. package/src/adapters/webAdapter.ts +480 -0
  101. package/src/core/adapter.ts +128 -0
  102. package/src/core/cacheEngine.ts +634 -0
  103. package/src/core/errors.ts +82 -0
  104. package/src/core/hash.ts +78 -0
  105. package/src/core/indexStore.ts +184 -0
  106. package/src/core/mutex.ts +134 -0
  107. package/src/core/prune.ts +145 -0
  108. package/src/core/types.ts +165 -0
  109. package/src/factory.ts +60 -0
  110. package/src/index.native.ts +58 -0
  111. package/src/index.ts +82 -0
  112. package/src/index.web.ts +59 -0
  113. package/src/types/react-native-fs.d.ts +75 -0
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @dynlabs/react-native-immutable-file-cache
3
+ *
4
+ * Cross-platform immutable file cache with pluggable storage adapters.
5
+ */
6
+
7
+ // ─────────────────────────────────────────────────────────────────
8
+ // Core Types
9
+ // ─────────────────────────────────────────────────────────────────
10
+
11
+ // ─────────────────────────────────────────────────────────────────
12
+ // Errors
13
+ // ─────────────────────────────────────────────────────────────────
14
+
15
+ export { CacheError, UnsupportedSourceError, AdapterIOError, CorruptIndexError, ImmutableConflictError, EntryNotFoundError } from "./core/errors";
16
+
17
+ // ─────────────────────────────────────────────────────────────────
18
+ // Core Engine
19
+ // ─────────────────────────────────────────────────────────────────
20
+
21
+ export { CacheEngine } from "./core/cacheEngine";
22
+
23
+ // ─────────────────────────────────────────────────────────────────
24
+ // Factory
25
+ // ─────────────────────────────────────────────────────────────────
26
+
27
+ export { createImmutableFileCache, createCacheEngineSync } from "./factory";
28
+ // ─────────────────────────────────────────────────────────────────
29
+ // Adapters
30
+ // ─────────────────────────────────────────────────────────────────
31
+
32
+ export { createRnfsAdapter } from "./adapters/rnfsAdapter";
33
+ export { createWebAdapter } from "./adapters/webAdapter";
34
+ export { createMemoryAdapter } from "./adapters/memoryAdapter";
35
+ // ─────────────────────────────────────────────────────────────────
36
+ // Utilities
37
+ // ─────────────────────────────────────────────────────────────────
38
+
39
+ export { hash, hashSync } from "./core/hash";
40
+ export { Mutex, KeyedMutex } from "./core/mutex";
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CacheError","UnsupportedSourceError","AdapterIOError","CorruptIndexError","ImmutableConflictError","EntryNotFoundError","CacheEngine","createImmutableFileCache","createCacheEngineSync","createRnfsAdapter","createWebAdapter","createMemoryAdapter","hash","hashSync","Mutex","KeyedMutex"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AA4BA;AACA;AACA;;AAEA,SACEA,UAAU,EACVC,sBAAsB,EACtBC,cAAc,EACdC,iBAAiB,EACjBC,sBAAsB,EACtBC,kBAAkB,QACb,eAAe;;AAEtB;AACA;AACA;;AAEA,SAASC,WAAW,QAAQ,oBAAoB;;AAEhD;AACA;AACA;;AAEA,SAASC,wBAAwB,EAAEC,qBAAqB,QAAQ,WAAW;AAI3E;AACA;AACA;;AAEA,SAASC,iBAAiB,QAAQ,wBAAwB;AAG1D,SAASC,gBAAgB,QAAQ,uBAAuB;AAGxD,SAASC,mBAAmB,QAAQ,0BAA0B;AAG9D;AACA;AACA;;AAEA,SAASC,IAAI,EAAEC,QAAQ,QAAQ,aAAa;AAC5C,SAASC,KAAK,EAAEC,UAAU,QAAQ,cAAc","ignoreList":[]}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @dynlabs/react-native-immutable-file-cache - Native entrypoint
3
+ * Auto-selects RNFS adapter for React Native (iOS/Android).
4
+ */
5
+
6
+ // Re-export everything from main index
7
+ export * from "./index";
8
+ import { createRnfsAdapter } from "./adapters/rnfsAdapter";
9
+ import { CacheEngine } from "./core/cacheEngine";
10
+
11
+ /**
12
+ * Creates an immutable file cache instance for React Native.
13
+ * Automatically uses the RNFS adapter.
14
+ *
15
+ * @param options - Cache configuration options
16
+ * @returns Initialized CacheEngine instance
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import { createImmutableFileCache } from "@dynlabs/react-native-immutable-file-cache";
21
+ *
22
+ * const cache = await createImmutableFileCache({
23
+ * namespace: "images",
24
+ * defaultTtlMs: 7 * 24 * 60 * 60 * 1000,
25
+ * });
26
+ *
27
+ * // Cache an image
28
+ * const result = await cache.putFromUrl("avatar", "https://example.com/avatar.jpg");
29
+ *
30
+ * // Get cached image URI
31
+ * const entry = await cache.get("avatar");
32
+ * if (entry) {
33
+ * console.log("Image URI:", entry.uri);
34
+ * }
35
+ * ```
36
+ */
37
+ export async function createImmutableFileCache(options) {
38
+ const {
39
+ autoInit = true,
40
+ adapter,
41
+ ...config
42
+ } = options ?? {};
43
+
44
+ // Use provided adapter or create RNFS adapter
45
+ const resolvedAdapter = adapter ?? createRnfsAdapter({
46
+ namespace: config.namespace
47
+ });
48
+ const engine = new CacheEngine(config, resolvedAdapter);
49
+ if (autoInit) {
50
+ await engine.init();
51
+ }
52
+ return engine;
53
+ }
54
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createRnfsAdapter","CacheEngine","createImmutableFileCache","options","autoInit","adapter","config","resolvedAdapter","namespace","engine","init"],"sourceRoot":"../../src","sources":["index.native.ts"],"mappings":"AAAA;AACA;AACA;AACA;;AAEA;AACA,cAAc,SAAS;AAEvB,SAASA,iBAAiB,QAAQ,wBAAwB;AAE1D,SAASC,WAAW,QAAQ,oBAAoB;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,wBAAwBA,CAC5CC,OAA6F,EACvE;EACtB,MAAM;IAAEC,QAAQ,GAAG,IAAI;IAAEC,OAAO;IAAE,GAAGC;EAAO,CAAC,GAAGH,OAAO,IAAI,CAAC,CAAC;;EAE7D;EACA,MAAMI,eAAe,GACnBF,OAAO,IACPL,iBAAiB,CAAC;IAChBQ,SAAS,EAAEF,MAAM,CAACE;EACpB,CAAC,CAAC;EAEJ,MAAMC,MAAM,GAAG,IAAIR,WAAW,CAACK,MAAM,EAAEC,eAAe,CAAC;EAEvD,IAAIH,QAAQ,EAAE;IACZ,MAAMK,MAAM,CAACC,IAAI,CAAC,CAAC;EACrB;EAEA,OAAOD,MAAM;AACf","ignoreList":[]}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @dynlabs/react-native-immutable-file-cache - Web entrypoint
3
+ * Auto-selects Web adapter for browser environments.
4
+ */
5
+
6
+ // Re-export everything from main index
7
+ export * from "./index";
8
+ import { createWebAdapter } from "./adapters/webAdapter";
9
+ import { CacheEngine } from "./core/cacheEngine";
10
+
11
+ /**
12
+ * Creates an immutable file cache instance for web browsers.
13
+ * Automatically uses the Web adapter (Cache Storage + IndexedDB).
14
+ *
15
+ * @param options - Cache configuration options
16
+ * @returns Initialized CacheEngine instance
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import { createImmutableFileCache } from "@dynlabs/react-native-immutable-file-cache/web";
21
+ *
22
+ * const cache = await createImmutableFileCache({
23
+ * namespace: "images",
24
+ * defaultTtlMs: 7 * 24 * 60 * 60 * 1000,
25
+ * });
26
+ *
27
+ * // Cache an image
28
+ * const result = await cache.putFromUrl("avatar", "https://example.com/avatar.jpg");
29
+ *
30
+ * // Get cached image URI (blob: URL)
31
+ * const entry = await cache.get("avatar");
32
+ * if (entry) {
33
+ * // Use entry.uri as image source
34
+ * // Remember to revoke blob URL when done to free memory
35
+ * }
36
+ * ```
37
+ */
38
+ export async function createImmutableFileCache(options) {
39
+ const {
40
+ autoInit = true,
41
+ adapter,
42
+ ...config
43
+ } = options ?? {};
44
+
45
+ // Use provided adapter or create Web adapter
46
+ const resolvedAdapter = adapter ?? createWebAdapter({
47
+ namespace: config.namespace
48
+ });
49
+ const engine = new CacheEngine(config, resolvedAdapter);
50
+ if (autoInit) {
51
+ await engine.init();
52
+ }
53
+ return engine;
54
+ }
55
+ //# sourceMappingURL=index.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createWebAdapter","CacheEngine","createImmutableFileCache","options","autoInit","adapter","config","resolvedAdapter","namespace","engine","init"],"sourceRoot":"../../src","sources":["index.web.ts"],"mappings":"AAAA;AACA;AACA;AACA;;AAEA;AACA,cAAc,SAAS;AAEvB,SAASA,gBAAgB,QAAQ,uBAAuB;AAExD,SAASC,WAAW,QAAQ,oBAAoB;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,wBAAwBA,CAC5CC,OAA6F,EACvE;EACtB,MAAM;IAAEC,QAAQ,GAAG,IAAI;IAAEC,OAAO;IAAE,GAAGC;EAAO,CAAC,GAAGH,OAAO,IAAI,CAAC,CAAC;;EAE7D;EACA,MAAMI,eAAe,GACnBF,OAAO,IACPL,gBAAgB,CAAC;IACfQ,SAAS,EAAEF,MAAM,CAACE;EACpB,CAAC,CAAC;EAEJ,MAAMC,MAAM,GAAG,IAAIR,WAAW,CAACK,MAAM,EAAEC,eAAe,CAAC;EAEvD,IAAIH,QAAQ,EAAE;IACZ,MAAMK,MAAM,CAACC,IAAI,CAAC,CAAC;EACrB;EAEA,OAAOD,MAAM;AACf","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=react-native-fs.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/react-native-fs.d.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * In-Memory Storage Adapter
3
+ *
4
+ * For testing purposes only.
5
+ * Implements IStorageAdapter using in-memory storage.
6
+ */
7
+ import type { IStorageAdapter } from "../core/adapter";
8
+ /**
9
+ * Extended interface for memory adapter with test utilities.
10
+ */
11
+ export interface IMemoryAdapter extends IStorageAdapter {
12
+ /** Resets all stored data. For testing. */
13
+ _reset(): void;
14
+ /** Gets raw content for assertions. For testing. */
15
+ _getContent(path: string): Uint8Array | undefined;
16
+ /** Gets all stored paths. For testing. */
17
+ _getAllPaths(): string[];
18
+ }
19
+ /**
20
+ * Creates an in-memory storage adapter for testing.
21
+ */
22
+ export declare function createMemoryAdapter(namespace?: string): IMemoryAdapter;
23
+ //# sourceMappingURL=memoryAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoryAdapter.d.ts","sourceRoot":"","sources":["../../../../src/adapters/memoryAdapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EACV,eAAe,EAMhB,MAAM,iBAAiB,CAAC;AASzB;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,eAAe;IACrD,2CAA2C;IAC3C,MAAM,IAAI,IAAI,CAAC;IACf,oDAAoD;IACpD,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IAClD,0CAA0C;IAC1C,YAAY,IAAI,MAAM,EAAE,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,cAAc,CA0QtE"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * React Native FS Adapter
3
+ *
4
+ * This is the ONLY file that imports react-native-fs.
5
+ * Implements IStorageAdapter using RNFS APIs.
6
+ */
7
+ import type { IStorageAdapter } from "../core/adapter";
8
+ export interface IRnfsAdapterOptions {
9
+ /** Base directory. @default RNFS.CachesDirectoryPath */
10
+ readonly baseDir?: string;
11
+ /** Namespace subdirectory. */
12
+ readonly namespace?: string;
13
+ }
14
+ /**
15
+ * Creates a storage adapter backed by react-native-fs.
16
+ */
17
+ export declare function createRnfsAdapter(options?: IRnfsAdapterOptions): IStorageAdapter;
18
+ //# sourceMappingURL=rnfsAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rnfsAdapter.d.ts","sourceRoot":"","sources":["../../../../src/adapters/rnfsAdapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,OAAO,KAAK,EACV,eAAe,EAMhB,MAAM,iBAAiB,CAAC;AAGzB,MAAM,WAAW,mBAAmB;IAClC,wDAAwD;IACxD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,8BAA8B;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,eAAe,CA2OhF"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Web Storage Adapter
3
+ *
4
+ * Implements IStorageAdapter using:
5
+ * - Cache Storage API for binary file storage
6
+ * - IndexedDB for metadata and index storage
7
+ */
8
+ import type { IStorageAdapter } from "../core/adapter";
9
+ export interface IWebAdapterOptions {
10
+ /** Cache name for Cache Storage. @default "immutable-file-cache" */
11
+ readonly cacheName?: string;
12
+ /** IDB database name. @default "immutable-file-cache-meta" */
13
+ readonly idbName?: string;
14
+ /** Namespace. */
15
+ readonly namespace?: string;
16
+ }
17
+ /**
18
+ * Creates a storage adapter for web platforms using Cache Storage and IndexedDB.
19
+ */
20
+ export declare function createWebAdapter(options?: IWebAdapterOptions): IStorageAdapter;
21
+ /**
22
+ * Extended interface for web adapter with cleanup methods.
23
+ */
24
+ export interface IWebAdapterWithCleanup extends IStorageAdapter {
25
+ /** Revokes a specific blob URL to free memory. */
26
+ revokeUri(uri: string): void;
27
+ /** Revokes all created blob URLs. */
28
+ revokeAllUris(): void;
29
+ }
30
+ //# sourceMappingURL=webAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webAdapter.d.ts","sourceRoot":"","sources":["../../../../src/adapters/webAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,eAAe,EAMhB,MAAM,iBAAiB,CAAC;AAGzB,MAAM,WAAW,kBAAkB;IACjC,oEAAoE;IACpE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB;IACjB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAUD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,eAAe,CA+a9E;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,eAAe;IAC7D,kDAAkD;IAClD,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,qCAAqC;IACrC,aAAa,IAAI,IAAI,CAAC;CACvB"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Adapter-relative path. Core never constructs absolute OS paths.
3
+ * All paths are relative to the adapter's root.
4
+ */
5
+ export type TAdapterPath = string;
6
+ /**
7
+ * Discriminated union for binary content sources.
8
+ * Adapters support the subset they can handle; throw UnsupportedSourceError otherwise.
9
+ */
10
+ export type TBinarySource = {
11
+ readonly type: "url";
12
+ readonly url: string;
13
+ readonly headers?: Readonly<Record<string, string>>;
14
+ } | {
15
+ readonly type: "file";
16
+ readonly filePath: string;
17
+ } | {
18
+ readonly type: "blob";
19
+ readonly blob: Blob;
20
+ } | {
21
+ readonly type: "bytes";
22
+ readonly bytes: Uint8Array;
23
+ };
24
+ /**
25
+ * Result of a binary write operation.
26
+ */
27
+ export interface IBinaryWriteResult {
28
+ readonly sizeBytes: number;
29
+ readonly contentType?: string;
30
+ }
31
+ /**
32
+ * File/entry stat information.
33
+ */
34
+ export interface IFileStat {
35
+ readonly sizeBytes: number;
36
+ readonly mtimeMs: number;
37
+ }
38
+ /**
39
+ * Progress callback for binary operations.
40
+ */
41
+ export type TProgressCallback = (percent: number) => void;
42
+ /**
43
+ * Options for binary write operations.
44
+ */
45
+ export interface IBinaryWriteOptions {
46
+ readonly onProgress?: TProgressCallback;
47
+ readonly headers?: Readonly<Record<string, string>>;
48
+ }
49
+ /**
50
+ * Storage adapter interface.
51
+ * Represents a key-addressed "filesystem-like" store with atomic write support.
52
+ * All paths are adapter-relative. Core never constructs absolute OS paths.
53
+ */
54
+ export interface IStorageAdapter {
55
+ /** Adapter kind identifier. */
56
+ readonly kind: string;
57
+ /** A stable root identifier (e.g., absolute cache root on native, cache name on web). */
58
+ readonly rootId: string;
59
+ /**
60
+ * Ensures a directory exists at the given path, creating it recursively if needed.
61
+ */
62
+ ensureDir(path: TAdapterPath): Promise<void>;
63
+ /**
64
+ * Checks if a file or directory exists at the given path.
65
+ */
66
+ exists(path: TAdapterPath): Promise<boolean>;
67
+ /**
68
+ * Removes a file at the given path. No-op if file doesn't exist.
69
+ */
70
+ remove(path: TAdapterPath): Promise<void>;
71
+ /**
72
+ * Removes a directory and all its contents recursively.
73
+ */
74
+ removeDir(path: TAdapterPath): Promise<void>;
75
+ /**
76
+ * Lists all entries (files/directories) in a directory.
77
+ * Returns relative paths from the listed directory.
78
+ */
79
+ listDir(path: TAdapterPath): Promise<ReadonlyArray<TAdapterPath>>;
80
+ /**
81
+ * Reads text content from a file.
82
+ */
83
+ readText(path: TAdapterPath, encoding: "utf8"): Promise<string>;
84
+ /**
85
+ * Writes text content atomically (write to temp, then rename).
86
+ */
87
+ writeTextAtomic(path: TAdapterPath, content: string, encoding: "utf8"): Promise<void>;
88
+ /**
89
+ * Gets file statistics.
90
+ */
91
+ stat(path: TAdapterPath): Promise<IFileStat>;
92
+ /**
93
+ * Writes binary content atomically.
94
+ * Source may be URL, blob, file path, or raw bytes depending on adapter.
95
+ * Adapter must throw UnsupportedSourceError for unsupported source types.
96
+ */
97
+ writeBinaryAtomic(path: TAdapterPath, source: TBinarySource, options?: IBinaryWriteOptions): Promise<IBinaryWriteResult>;
98
+ /**
99
+ * Returns a URI that the app can use to read/view the stored file.
100
+ * - Native: file:// URI
101
+ * - Web: blob: URL (caller responsible for revoking)
102
+ */
103
+ getPublicUri(path: TAdapterPath): Promise<string>;
104
+ }
105
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/core/adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC;;;GAGG;AACH,MAAM,MAAM,aAAa,GACrB;IACE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;I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IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE7C;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1C;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7C;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;IAMlE;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEhE;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtF;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAE7C;;;;OAIG;IACH,iBAAiB,CACf,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAE/B;;;;OAIG;IACH,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACnD"}
@@ -0,0 +1,99 @@
1
+ import type { IStorageAdapter } from "./adapter";
2
+ import type { ICacheConfig, ICacheEntry, IPutOptions, IPutResult, IGetResult, IListOptions, IPruneResult, ICacheStats } from "./types";
3
+ /**
4
+ * Main cache engine implementation.
5
+ * Coordinates all cache operations through the storage adapter.
6
+ */
7
+ export declare class CacheEngine {
8
+ private readonly _config;
9
+ private readonly _adapter;
10
+ private readonly _indexStore;
11
+ private readonly _indexMutex;
12
+ private readonly _keyMutex;
13
+ private readonly _hashFn;
14
+ private _index;
15
+ private _initialized;
16
+ constructor(config: ICacheConfig, adapter: IStorageAdapter);
17
+ /**
18
+ * Initialize cache (ensure directories, load index).
19
+ */
20
+ init(): Promise<void>;
21
+ /**
22
+ * Store content from URL.
23
+ * Returns {status: "exists"} if key already exists.
24
+ */
25
+ putFromUrl(key: string, url: string, options?: IPutOptions): Promise<IPutResult>;
26
+ /**
27
+ * Store content from local file path (native only).
28
+ */
29
+ putFromFile(key: string, filePath: string, options?: IPutOptions): Promise<IPutResult>;
30
+ /**
31
+ * Store content from Blob (web only).
32
+ */
33
+ putFromBlob(key: string, blob: Blob, options?: IPutOptions): Promise<IPutResult>;
34
+ /**
35
+ * Store content from raw bytes.
36
+ */
37
+ putFromBytes(key: string, bytes: Uint8Array, options?: IPutOptions): Promise<IPutResult>;
38
+ /**
39
+ * Internal put implementation.
40
+ */
41
+ private _put;
42
+ /**
43
+ * Get entry by key. Returns null if not found or expired.
44
+ * Updates lastAccessedAt.
45
+ */
46
+ get(key: string): Promise<IGetResult | null>;
47
+ /**
48
+ * Check if key exists and is not expired.
49
+ */
50
+ has(key: string): Promise<boolean>;
51
+ /**
52
+ * Get entry metadata without updating lastAccessedAt.
53
+ */
54
+ peek(key: string): Promise<ICacheEntry | null>;
55
+ /**
56
+ * List entries with sorting, filtering, pagination.
57
+ */
58
+ list(options?: IListOptions): Promise<ReadonlyArray<ICacheEntry>>;
59
+ /**
60
+ * Get cache statistics.
61
+ */
62
+ stats(): Promise<ICacheStats>;
63
+ /**
64
+ * Remove specific entry by key.
65
+ */
66
+ remove(key: string): Promise<boolean>;
67
+ /**
68
+ * Internal remove implementation (must be called within keyed mutex).
69
+ */
70
+ private _removeEntry;
71
+ /**
72
+ * Remove all expired entries.
73
+ */
74
+ removeExpired(): Promise<IPruneResult>;
75
+ /**
76
+ * Prune to fit within size limit using LRU.
77
+ */
78
+ pruneLru(maxSizeBytes: number): Promise<IPruneResult>;
79
+ /**
80
+ * Remove multiple entries.
81
+ */
82
+ private _removeEntries;
83
+ /**
84
+ * Clear all entries.
85
+ */
86
+ clear(): Promise<void>;
87
+ /**
88
+ * Validate index against filesystem and rebuild if needed.
89
+ */
90
+ validateAndRepair(): Promise<{
91
+ repaired: boolean;
92
+ issues: string[];
93
+ }>;
94
+ private _ensureInitialized;
95
+ private _entryWithPath;
96
+ private _extractExtension;
97
+ private _autoPrune;
98
+ }
99
+ //# sourceMappingURL=cacheEngine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cacheEngine.d.ts","sourceRoot":"","sources":["../../../../src/core/cacheEngine.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,WAAW,CAAC;AAChE,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EAEX,WAAW,EACX,UAAU,EACV,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,EAEZ,MAAM,SAAS,CAAC;AAgBjB;;;GAGG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CACT;IACf,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAa;IACzC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoB;IAC9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8C;IAEtE,OAAO,CAAC,MAAM,CAAmC;IACjD,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe;IAW1D;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAyB3B;;;OAGG;IACG,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAStF;;OAEG;IACG,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MA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AE,CAAC;IAiD3E,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,iBAAiB;YA6CX,UAAU;CASzB"}
@@ -0,0 +1,54 @@
1
+ import type { TBinarySource } from "./adapter";
2
+ /**
3
+ * Base error class for cache operations.
4
+ */
5
+ export declare abstract class CacheError extends Error {
6
+ abstract readonly code: string;
7
+ constructor(message: string);
8
+ }
9
+ /**
10
+ * Thrown when an adapter receives a TBinarySource type it cannot handle.
11
+ */
12
+ export declare class UnsupportedSourceError extends CacheError {
13
+ readonly sourceType: TBinarySource["type"];
14
+ readonly adapterKind: string;
15
+ readonly code: "UNSUPPORTED_SOURCE";
16
+ constructor(sourceType: TBinarySource["type"], adapterKind: string);
17
+ }
18
+ /**
19
+ * Thrown when an adapter I/O operation fails.
20
+ */
21
+ export declare class AdapterIOError extends CacheError {
22
+ readonly operation: string;
23
+ readonly path: string;
24
+ readonly cause?: Error | undefined;
25
+ readonly code: "ADAPTER_IO_ERROR";
26
+ constructor(operation: string, path: string, cause?: Error | undefined);
27
+ }
28
+ /**
29
+ * Thrown when the cache index is corrupt and cannot be parsed.
30
+ */
31
+ export declare class CorruptIndexError extends CacheError {
32
+ readonly reason: string;
33
+ readonly cause?: Error | undefined;
34
+ readonly code: "CORRUPT_INDEX";
35
+ constructor(reason: string, cause?: Error | undefined);
36
+ }
37
+ /**
38
+ * Internal error when attempting to overwrite an immutable entry.
39
+ * Public API converts this to {status: "exists"} response.
40
+ */
41
+ export declare class ImmutableConflictError extends CacheError {
42
+ readonly key: string;
43
+ readonly code: "IMMUTABLE_CONFLICT";
44
+ constructor(key: string);
45
+ }
46
+ /**
47
+ * Thrown when a required entry is not found.
48
+ */
49
+ export declare class EntryNotFoundError extends CacheError {
50
+ readonly key: string;
51
+ readonly code: "ENTRY_NOT_FOUND";
52
+ constructor(key: string);
53
+ }
54
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.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GAAG,EAAE,MAAM;CAGxC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Cross-platform SHA-256 hashing utility.
3
+ * Uses SubtleCrypto on web and native platforms that support it.
4
+ */
5
+ /**
6
+ * Computes SHA-256 hash of the input string.
7
+ * Returns lowercase hex string.
8
+ *
9
+ * Uses SubtleCrypto API which is available in:
10
+ * - Modern browsers
11
+ * - React Native (via Hermes or polyfill)
12
+ * - Node.js 15+
13
+ */
14
+ export declare function hash(input: string): Promise<string>;
15
+ /**
16
+ * Synchronous hash for cases where async is not possible.
17
+ * Uses fallback algorithm - prefer async hash() when possible.
18
+ */
19
+ export declare function hashSync(input: string): string;
20
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../../src/core/hash.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsBH;;;;;;;;GAQG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAYzD;AAyBD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9C"}
@@ -0,0 +1,34 @@
1
+ import type { IStorageAdapter, TAdapterPath } from "./adapter";
2
+ import type { ICacheIndex } from "./types";
3
+ /**
4
+ * Manages persistence of the cache index via the storage adapter.
5
+ */
6
+ export declare class IndexStore {
7
+ private readonly _adapter;
8
+ private readonly _indexPath;
9
+ constructor(adapter: IStorageAdapter, indexPath: TAdapterPath);
10
+ /**
11
+ * Load index from storage.
12
+ * Returns empty index if file doesn't exist.
13
+ * Throws CorruptIndexError if index is malformed.
14
+ */
15
+ load(): Promise<ICacheIndex>;
16
+ /**
17
+ * Save index atomically via the adapter.
18
+ */
19
+ save(index: ICacheIndex): Promise<void>;
20
+ /**
21
+ * Validate and rebuild index from filesystem if corrupt.
22
+ * Scans the entries directory and reconstructs metadata.
23
+ */
24
+ rebuild(entriesDir: TAdapterPath): Promise<ICacheIndex>;
25
+ /**
26
+ * Validates that the parsed object is a valid ICacheIndex.
27
+ */
28
+ private _validateIndex;
29
+ /**
30
+ * Validates that an entry has all required fields.
31
+ */
32
+ private _validateEntry;
33
+ }
34
+ //# sourceMappingURL=indexStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexStore.d.ts","sourceRoot":"","sources":["../../../../src/core/indexStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,SAAS,CAAC;AAM5D;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAe;gBAE9B,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY;IAK7D;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC;IA0BlC;;OAEG;IACG,IAAI,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7C;;;OAGG;IACG,OAAO,CAAC,UAAU,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAqD7D;;OAEG;IACH,OAAO,CAAC,cAAc;IAyCtB;;OAEG;IACH,OAAO,CAAC,cAAc;CAqBvB"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Async mutex for serializing critical sections.
3
+ * Ensures only one operation runs at a time within a critical section.
4
+ */
5
+ export declare class Mutex {
6
+ private readonly _queue;
7
+ private _locked;
8
+ /**
9
+ * Acquires the mutex lock.
10
+ * Returns a release function that must be called when done.
11
+ */
12
+ acquire(): Promise<() => void>;
13
+ /**
14
+ * Creates a release function for the current lock holder.
15
+ */
16
+ private _createRelease;
17
+ /**
18
+ * Returns whether the mutex is currently locked.
19
+ */
20
+ get isLocked(): boolean;
21
+ /**
22
+ * Executes a function with the mutex held.
23
+ * Automatically releases the mutex when done.
24
+ */
25
+ runExclusive<T>(fn: () => Promise<T> | T): Promise<T>;
26
+ }
27
+ /**
28
+ * Keyed mutex for per-key locking.
29
+ * Allows concurrent operations on different keys while serializing same-key operations.
30
+ */
31
+ export declare class KeyedMutex {
32
+ private readonly _mutexes;
33
+ private readonly _refCounts;
34
+ /**
35
+ * Acquires lock for a specific key.
36
+ * Returns a release function that must be called when done.
37
+ */
38
+ acquire(key: string): Promise<() => void>;
39
+ /**
40
+ * Executes a function with the keyed mutex held.
41
+ * Automatically releases the mutex when done.
42
+ */
43
+ runExclusive<T>(key: string, fn: () => Promise<T> | T): Promise<T>;
44
+ /**
45
+ * Returns the number of active keys with pending operations.
46
+ */
47
+ get activeKeyCount(): number;
48
+ }
49
+ //# sourceMappingURL=mutex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutex.d.ts","sourceRoot":"","sources":["../../../../src/core/mutex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,KAAK;IAChB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;IAChD,OAAO,CAAC,OAAO,CAAS;IAExB;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC;IAcpC;;OAEG;IACH,OAAO,CAAC,cAAc;IAetB;;OAEG;IACH,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED;;;OAGG;IACG,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAQ5D;AAED;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA4B;IACrD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA6B;IAExD;;;OAGG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC;IAqC/C;;;OAGG;IACG,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IASxE;;OAEG;IACH,IAAI,cAAc,IAAI,MAAM,CAE3B;CACF"}