strata-storage 2.6.1 → 2.7.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.
- package/AI-INTEGRATION-GUIDE.md +129 -11
- package/README.md +42 -64
- package/android/AGENTS.md +18 -3
- package/android/CLAUDE.md +36 -3
- package/android/build.gradle +5 -1
- package/android/src/main/java/com/strata/storage/EncryptedStorage.java +31 -18
- package/android/src/main/java/com/strata/storage/FilesystemStorage.java +62 -10
- package/android/src/main/java/com/strata/storage/SQLiteStorage.java +65 -13
- package/android/src/main/java/com/strata/storage/SharedPreferencesStorage.java +63 -51
- package/android/src/main/java/com/stratastorage/StrataStoragePlugin.java +80 -11
- package/dist/README.md +42 -64
- package/dist/adapters/capacitor/FilesystemAdapter.d.ts +2 -2
- package/dist/adapters/capacitor/FilesystemAdapter.d.ts.map +1 -1
- package/dist/adapters/capacitor/FilesystemAdapter.js +6 -2
- package/dist/adapters/capacitor/PreferencesAdapter.d.ts +2 -2
- package/dist/adapters/capacitor/PreferencesAdapter.d.ts.map +1 -1
- package/dist/adapters/capacitor/PreferencesAdapter.js +6 -2
- package/dist/adapters/capacitor/SecureAdapter.d.ts +3 -3
- package/dist/adapters/capacitor/SecureAdapter.d.ts.map +1 -1
- package/dist/adapters/capacitor/SecureAdapter.js +6 -2
- package/dist/adapters/capacitor/SqliteAdapter.d.ts +24 -3
- package/dist/adapters/capacitor/SqliteAdapter.d.ts.map +1 -1
- package/dist/adapters/capacitor/SqliteAdapter.js +105 -23
- package/dist/adapters/capacitor/index.d.ts +4 -4
- package/dist/adapters/web/CacheAdapter.d.ts +2 -2
- package/dist/adapters/web/CacheAdapter.d.ts.map +1 -1
- package/dist/adapters/web/CacheAdapter.js +20 -5
- package/dist/adapters/web/CookieAdapter.d.ts +2 -2
- package/dist/adapters/web/CookieAdapter.d.ts.map +1 -1
- package/dist/adapters/web/CookieAdapter.js +27 -3
- package/dist/adapters/web/IndexedDBAdapter.d.ts +10 -3
- package/dist/adapters/web/IndexedDBAdapter.d.ts.map +1 -1
- package/dist/adapters/web/IndexedDBAdapter.js +19 -4
- package/dist/adapters/web/LocalStorageAdapter.d.ts +2 -2
- package/dist/adapters/web/LocalStorageAdapter.d.ts.map +1 -1
- package/dist/adapters/web/LocalStorageAdapter.js +15 -1
- package/dist/adapters/web/MemoryAdapter.d.ts +9 -2
- package/dist/adapters/web/MemoryAdapter.d.ts.map +1 -1
- package/dist/adapters/web/MemoryAdapter.js +22 -5
- package/dist/adapters/web/SessionStorageAdapter.d.ts +10 -10
- package/dist/adapters/web/SessionStorageAdapter.d.ts.map +1 -1
- package/dist/adapters/web/SessionStorageAdapter.js +17 -3
- package/dist/adapters/web/URLAdapter.d.ts +2 -2
- package/dist/adapters/web/index.d.ts +7 -7
- package/dist/capacitor.d.ts +6 -6
- package/dist/capacitor.d.ts.map +1 -1
- package/dist/capacitor.js +5 -4
- package/dist/core/AdapterRegistry.d.ts +1 -1
- package/dist/core/BaseAdapter.d.ts +21 -5
- package/dist/core/BaseAdapter.d.ts.map +1 -1
- package/dist/core/BaseAdapter.js +29 -1
- package/dist/core/Strata.d.ts +53 -7
- package/dist/core/Strata.d.ts.map +1 -1
- package/dist/core/Strata.js +581 -125
- package/dist/features/compression/index.d.ts +1 -1
- package/dist/features/compression.d.ts +28 -9
- package/dist/features/compression.d.ts.map +1 -1
- package/dist/features/compression.js +164 -77
- package/dist/features/encryption/index.d.ts +1 -1
- package/dist/features/encryption.d.ts +55 -2
- package/dist/features/encryption.d.ts.map +1 -1
- package/dist/features/encryption.js +139 -26
- package/dist/features/migration.d.ts +1 -1
- package/dist/features/migration.d.ts.map +1 -1
- package/dist/features/migration.js +7 -2
- package/dist/features/observer/index.d.ts +1 -1
- package/dist/features/observer.d.ts +1 -1
- package/dist/features/query/index.d.ts +1 -1
- package/dist/features/query.d.ts +2 -1
- package/dist/features/query.d.ts.map +1 -1
- package/dist/features/query.js +32 -7
- package/dist/features/sync/index.d.ts +1 -1
- package/dist/features/sync.d.ts +19 -3
- package/dist/features/sync.d.ts.map +1 -1
- package/dist/features/sync.js +75 -12
- package/dist/features/ttl/index.d.ts +1 -1
- package/dist/features/ttl.d.ts +2 -2
- package/dist/features/ttl.d.ts.map +1 -1
- package/dist/features/ttl.js +4 -2
- package/dist/firebase.d.ts +1 -1
- package/dist/firebase.d.ts.map +1 -1
- package/dist/firebase.js +72 -10
- package/dist/index.d.ts +24 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/integrations/angular/index.d.ts +2 -2
- package/dist/integrations/angular/index.d.ts.map +1 -1
- package/dist/integrations/angular/index.js +7 -8
- package/dist/integrations/react/index.d.ts +3 -3
- package/dist/integrations/react/index.d.ts.map +1 -1
- package/dist/integrations/react/index.js +16 -4
- package/dist/integrations/vue/index.d.ts +2 -2
- package/dist/integrations/vue/index.d.ts.map +1 -1
- package/dist/integrations/vue/index.js +5 -2
- package/dist/package.json +11 -2
- package/dist/plugin/definitions.d.ts +29 -3
- package/dist/plugin/definitions.d.ts.map +1 -1
- package/dist/plugin/index.d.ts +2 -2
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +3 -0
- package/dist/plugin/web.d.ts +11 -2
- package/dist/plugin/web.d.ts.map +1 -1
- package/dist/plugin/web.js +23 -4
- package/dist/types/index.d.ts +50 -20
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -10
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +7 -0
- package/ios/AGENTS.md +14 -3
- package/ios/CLAUDE.md +25 -3
- package/ios/Plugin/FilesystemStorage.swift +19 -0
- package/ios/Plugin/SQLiteStorage.swift +59 -9
- package/ios/Plugin/StrataStoragePlugin.m +1 -0
- package/ios/Plugin/StrataStoragePlugin.swift +87 -34
- package/ios/Plugin/UserDefaultsStorage.swift +47 -46
- package/package.json +27 -24
- package/scripts/build.js +46 -27
- package/scripts/cli.js +1 -1
- package/scripts/configure.js +2 -2
- package/scripts/postinstall.js +3 -2
- package/dist/android/AGENTS.md +0 -51
- package/dist/android/CLAUDE.md +0 -89
- package/dist/android/build.gradle +0 -58
- package/dist/android/proguard-rules.pro +0 -11
- package/dist/android/settings.gradle +0 -2
- package/dist/android/src/main/AndroidManifest.xml +0 -2
- package/dist/android/src/main/java/com/strata/storage/EncryptedStorage.java +0 -218
- package/dist/android/src/main/java/com/strata/storage/FilesystemStorage.java +0 -287
- package/dist/android/src/main/java/com/strata/storage/SQLiteStorage.java +0 -371
- package/dist/android/src/main/java/com/strata/storage/SharedPreferencesStorage.java +0 -209
- package/dist/android/src/main/java/com/stratastorage/StrataStoragePlugin.java +0 -616
- package/dist/core/StorageStrategy.d.ts +0 -55
- package/dist/core/StorageStrategy.d.ts.map +0 -1
- package/dist/core/StorageStrategy.js +0 -200
- package/dist/ios/AGENTS.md +0 -48
- package/dist/ios/CLAUDE.md +0 -84
- package/dist/ios/Plugin/FilesystemStorage.swift +0 -218
- package/dist/ios/Plugin/KeychainStorage.swift +0 -233
- package/dist/ios/Plugin/SQLiteStorage.swift +0 -426
- package/dist/ios/Plugin/StrataStoragePlugin.m +0 -23
- package/dist/ios/Plugin/StrataStoragePlugin.swift +0 -411
- package/dist/ios/Plugin/UserDefaultsStorage.swift +0 -87
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseAdapter.d.ts","sourceRoot":"","sources":["../../src/core/BaseAdapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,WAAW,EACX,mBAAmB,EAEnB,YAAY,EACZ,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACf,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,YAAY,EAA4B,MAAM,SAAS,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;GAEG;AACH,8BAAsB,WAAY,YAAW,cAA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,OAAO,CAAC,IAAI,CAAC;IAM5B,QAAQ,CAAC,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IACxC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IACpD,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACvE,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAC7E,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAC3C,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAC5D"}
|
package/dist/core/BaseAdapter.js
CHANGED
|
@@ -38,17 +38,27 @@ export class BaseAdapter {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* Clean up expired items
|
|
41
|
+
* Clean up expired items, returning how many were removed.
|
|
42
|
+
*
|
|
43
|
+
* Default implementation is a per-key sweep (enumerate keys, drop the expired
|
|
44
|
+
* ones). Backends that can filter expired rows in the storage engine itself
|
|
45
|
+
* (e.g. SQLite) override this with a single bulk delete — and because such a
|
|
46
|
+
* backend's `keys()` no longer surfaces expired entries, this per-key sweep
|
|
47
|
+
* would not see them anyway. Called by the automatic TTL tick and by
|
|
48
|
+
* `Strata.cleanupExpired()`.
|
|
42
49
|
*/
|
|
43
50
|
async cleanupExpired() {
|
|
44
51
|
const now = Date.now();
|
|
45
52
|
const keys = await this.keys();
|
|
53
|
+
let removed = 0;
|
|
46
54
|
for (const key of keys) {
|
|
47
55
|
const item = await this.get(key);
|
|
48
56
|
if (item?.expires && item.expires <= now) {
|
|
49
57
|
await this.remove(key);
|
|
58
|
+
removed++;
|
|
50
59
|
}
|
|
51
60
|
}
|
|
61
|
+
return removed;
|
|
52
62
|
}
|
|
53
63
|
/**
|
|
54
64
|
* Check if value is expired
|
|
@@ -135,6 +145,13 @@ export class BaseAdapter {
|
|
|
135
145
|
shouldDelete = false;
|
|
136
146
|
}
|
|
137
147
|
}
|
|
148
|
+
if (shouldDelete && options?.olderThan !== undefined) {
|
|
149
|
+
const value = await this.get(key);
|
|
150
|
+
const olderThan = options.olderThan instanceof Date ? options.olderThan.getTime() : options.olderThan;
|
|
151
|
+
if (!value || value.created >= olderThan) {
|
|
152
|
+
shouldDelete = false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
138
155
|
if (shouldDelete) {
|
|
139
156
|
await this.remove(key);
|
|
140
157
|
}
|
|
@@ -194,6 +211,17 @@ export class BaseAdapter {
|
|
|
194
211
|
this.eventEmitter.off('change', handler);
|
|
195
212
|
};
|
|
196
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Whether any subscriber is currently attached to this adapter's change
|
|
216
|
+
* stream. Adapters that talk to a slow backend (native bridge, network) use
|
|
217
|
+
* this to avoid a wasted read-before-write: fetching the previous value just
|
|
218
|
+
* to populate a change event is pointless when nobody is listening. When a
|
|
219
|
+
* subscriber IS attached, callers must still capture the old value so the
|
|
220
|
+
* emitted change is complete. See `SqliteAdapter.set`/`remove`.
|
|
221
|
+
*/
|
|
222
|
+
hasChangeListeners() {
|
|
223
|
+
return this.eventEmitter.listenerCount('change') > 0;
|
|
224
|
+
}
|
|
197
225
|
/**
|
|
198
226
|
* Emit change event
|
|
199
227
|
*/
|
package/dist/core/Strata.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Strata Storage - Main entry point
|
|
3
3
|
* Zero-dependency universal storage solution
|
|
4
4
|
*/
|
|
5
|
-
import type { StrataConfig, StorageAdapter, StorageOptions, StorageType, Platform, SizeInfo, ClearOptions, ExportOptions, ImportOptions, SubscriptionCallback, UnsubscribeFunction, QueryCondition, StorageCapabilities } from
|
|
6
|
-
import { AdapterRegistry } from
|
|
5
|
+
import type { StrataConfig, StorageAdapter, StorageOptions, StorageType, Platform, SizeInfo, ClearOptions, ExportOptions, ImportOptions, SubscriptionCallback, UnsubscribeFunction, QueryCondition, QueryOptions, StorageCapabilities } from "../types/index.js";
|
|
6
|
+
import { AdapterRegistry } from "./AdapterRegistry.js";
|
|
7
7
|
/**
|
|
8
8
|
* Main Strata class - unified storage interface
|
|
9
9
|
*/
|
|
@@ -17,9 +17,11 @@ export declare class Strata {
|
|
|
17
17
|
private compressionManager?;
|
|
18
18
|
private syncManager?;
|
|
19
19
|
private ttlManager?;
|
|
20
|
+
private readonly queryEngine;
|
|
20
21
|
private _initialized;
|
|
21
22
|
private _readyPromise?;
|
|
22
23
|
private _autoBackupTimer?;
|
|
24
|
+
private _ttlCleanupTimer?;
|
|
23
25
|
constructor(config?: StrataConfig);
|
|
24
26
|
/**
|
|
25
27
|
* Check if Strata has been initialized
|
|
@@ -49,7 +51,7 @@ export declare class Strata {
|
|
|
49
51
|
* @param options - Storage options
|
|
50
52
|
* @param options.storage - Specific storage type to use (e.g., 'localStorage', 'indexedDB')
|
|
51
53
|
* @param options.decrypt - Whether to decrypt the value (default: auto-detect)
|
|
52
|
-
* @param options.
|
|
54
|
+
* @param options.encryptionPassword - Password for decryption (uses config password if not provided)
|
|
53
55
|
* @returns The stored value or null if not found
|
|
54
56
|
* @throws {StorageError} If the storage adapter is not available
|
|
55
57
|
* @throws {EncryptionError} If decryption fails
|
|
@@ -64,11 +66,18 @@ export declare class Strata {
|
|
|
64
66
|
*
|
|
65
67
|
* // Get encrypted value
|
|
66
68
|
* const value = await storage.get('secure-key', {
|
|
67
|
-
*
|
|
69
|
+
* encryptionPassword: 'myPassword'
|
|
68
70
|
* });
|
|
69
71
|
* ```
|
|
70
72
|
*/
|
|
71
73
|
get<T = unknown>(key: string, options?: StorageOptions): Promise<T | null>;
|
|
74
|
+
/**
|
|
75
|
+
* Reverse the write-time transform pipeline on a stored wrapper: decrypt (if
|
|
76
|
+
* encrypted) and then decompress (if compressed). Shared by get() and query()
|
|
77
|
+
* so query results are decoded identically to direct reads. Returns the raw
|
|
78
|
+
* encrypted payload when `skipDecryption` is set.
|
|
79
|
+
*/
|
|
80
|
+
private decodeStoredValue;
|
|
72
81
|
/**
|
|
73
82
|
* Set a value in storage
|
|
74
83
|
*
|
|
@@ -172,6 +181,8 @@ export declare class Strata {
|
|
|
172
181
|
* ```
|
|
173
182
|
*/
|
|
174
183
|
clear(options?: ClearOptions & StorageOptions): Promise<void>;
|
|
184
|
+
/** Expiry check that works before the TTL manager exists (e.g. pre-init). */
|
|
185
|
+
private isItemExpired;
|
|
175
186
|
/**
|
|
176
187
|
* Get all keys from storage
|
|
177
188
|
*
|
|
@@ -216,7 +227,7 @@ export declare class Strata {
|
|
|
216
227
|
/**
|
|
217
228
|
* Get storage size information
|
|
218
229
|
*/
|
|
219
|
-
size(detailed?: boolean): Promise<SizeInfo>;
|
|
230
|
+
size(detailed?: boolean, options?: StorageOptions): Promise<SizeInfo>;
|
|
220
231
|
/**
|
|
221
232
|
* Subscribe to storage changes
|
|
222
233
|
*/
|
|
@@ -224,14 +235,18 @@ export declare class Strata {
|
|
|
224
235
|
/**
|
|
225
236
|
* Query storage (if supported)
|
|
226
237
|
*/
|
|
227
|
-
query<T = unknown>(condition: QueryCondition, options?: StorageOptions): Promise<Array<{
|
|
238
|
+
query<T = unknown>(condition: QueryCondition, options?: StorageOptions & QueryOptions): Promise<Array<{
|
|
228
239
|
key: string;
|
|
229
240
|
value: T;
|
|
230
241
|
}>>;
|
|
242
|
+
/** Apply QueryOptions (sort → skip → limit → select) to decoded query results. */
|
|
243
|
+
private applyQueryOptions;
|
|
231
244
|
/**
|
|
232
245
|
* Export storage data
|
|
233
246
|
*/
|
|
234
247
|
export(options?: ExportOptions): Promise<string>;
|
|
248
|
+
/** Detect a full StorageValue wrapper (e.g. from export({ includeMetadata })). */
|
|
249
|
+
private isStorageValueWrapper;
|
|
235
250
|
/**
|
|
236
251
|
* Import storage data
|
|
237
252
|
*/
|
|
@@ -294,11 +309,19 @@ export declare class Strata {
|
|
|
294
309
|
*
|
|
295
310
|
* @example
|
|
296
311
|
* ```typescript
|
|
297
|
-
* import { MyCustomAdapter } from
|
|
312
|
+
* import { MyCustomAdapter } from "./my-adapter.js";
|
|
298
313
|
* storage.registerAdapter(new MyCustomAdapter());
|
|
299
314
|
* ```
|
|
300
315
|
*/
|
|
301
316
|
registerAdapter(adapter: StorageAdapter): void;
|
|
317
|
+
/**
|
|
318
|
+
* Initialize and attach any registered adapters that are not yet active, then
|
|
319
|
+
* re-pick the default adapter. Call this after `registerAdapter()` on an
|
|
320
|
+
* already-initialized instance (e.g. `registerCapacitorAdapters()`), so the
|
|
321
|
+
* newly registered adapters become available to multi-adapter operations
|
|
322
|
+
* (keys/clear/size/subscribe) — not just to explicit `{ storage }` calls.
|
|
323
|
+
*/
|
|
324
|
+
refreshAdapters(): Promise<void>;
|
|
302
325
|
/**
|
|
303
326
|
* Get the adapter registry (for advanced use cases)
|
|
304
327
|
* @internal
|
|
@@ -310,6 +333,28 @@ export declare class Strata {
|
|
|
310
333
|
close(): Promise<void>;
|
|
311
334
|
private normalizeConfig;
|
|
312
335
|
private detectPlatform;
|
|
336
|
+
/** Effective namespace for an operation: a per-call value wins over the
|
|
337
|
+
* instance default (`config.namespace`). Empty strings are treated as none. */
|
|
338
|
+
private effectiveNamespace;
|
|
339
|
+
/**
|
|
340
|
+
* Encode a namespace into an unambiguous physical-key prefix component.
|
|
341
|
+
* `:` is a legal character in user keys, so a bare `${ns}:${key}` join lets
|
|
342
|
+
* namespace `a` + key `b:c` collide with namespace `a:b` + key `c` (both
|
|
343
|
+
* `a:b:c`), leaking keys across namespaces. Percent-encoding `:` (and the `%`
|
|
344
|
+
* escape itself) in the namespace component removes the ambiguity while
|
|
345
|
+
* leaving the user key — including any `:` — untouched. Namespaces without a
|
|
346
|
+
* `:` are unchanged, so existing namespaced data keeps the same physical key.
|
|
347
|
+
*/
|
|
348
|
+
private encodeNamespace;
|
|
349
|
+
/** The physical-key prefix (with trailing `:`) for a namespace. */
|
|
350
|
+
private namespacePrefix;
|
|
351
|
+
/** Map a logical key to the physical key actually stored (namespace-prefixed). */
|
|
352
|
+
private resolveKey;
|
|
353
|
+
/** Reduce physical keys to the logical keys owned by `ns`, then apply pattern. */
|
|
354
|
+
private scopeAndStripKeys;
|
|
355
|
+
/** Pattern matcher mirroring BaseAdapter.filterKeys (prefix / glob / RegExp). */
|
|
356
|
+
private filterKeysByPattern;
|
|
357
|
+
private static normalizeTimestamp;
|
|
313
358
|
private getDefaultStorages;
|
|
314
359
|
private initializeAdapters;
|
|
315
360
|
private selectDefaultAdapter;
|
|
@@ -320,6 +365,7 @@ export declare class Strata {
|
|
|
320
365
|
* natively via the `storage` event and sessionStorage is per-tab, so both are
|
|
321
366
|
* skipped here to avoid redundant re-writes.
|
|
322
367
|
*/
|
|
368
|
+
private cleanupAllAdapters;
|
|
323
369
|
private applyRemoteChange;
|
|
324
370
|
private mirrorAdapters;
|
|
325
371
|
private mirrorWrite;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Strata.d.ts","sourceRoot":"","sources":["../../src/core/Strata.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,cAAc,EACd,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EAGpB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Strata.d.ts","sourceRoot":"","sources":["../../src/core/Strata.ts"],"names":[],"mappings":"AAAA;;;GAGG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