strata-storage 2.4.1 → 2.4.3

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.
@@ -0,0 +1,354 @@
1
+ # AI Integration Guide - strata-storage
2
+
3
+ Quick reference for AI development agents (Claude Code, Cursor, Copilot, etc.) to integrate strata-storage into web and mobile projects.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ yarn add strata-storage
9
+ # or
10
+ npm install strata-storage
11
+ ```
12
+
13
+ ## Core Concepts
14
+
15
+ strata-storage provides:
16
+ - **Zero Dependencies** - Pure TypeScript, no runtime deps
17
+ - **9 Storage Adapters** - Memory, LocalStorage, SessionStorage, IndexedDB, Cookies, Cache, Preferences, SQLite, Secure, Filesystem
18
+ - **Advanced Features** - Encryption, compression, TTL, queries, cross-tab sync
19
+
20
+ ## Quick Start
21
+
22
+ ### Basic Usage
23
+
24
+ ```typescript
25
+ import { Strata } from 'strata-storage';
26
+
27
+ const storage = new Strata();
28
+ await storage.initialize();
29
+
30
+ // Set data
31
+ await storage.set('username', 'john_doe');
32
+ await storage.set('user', { id: 1, name: 'John' });
33
+
34
+ // Get data
35
+ const username = await storage.get('username');
36
+ const user = await storage.get<{ id: number; name: string }>('user');
37
+
38
+ // Remove data
39
+ await storage.remove('username');
40
+
41
+ // Clear all
42
+ await storage.clear();
43
+ ```
44
+
45
+ ### With Encryption
46
+
47
+ ```typescript
48
+ const storage = new Strata({
49
+ encryption: {
50
+ enabled: true,
51
+ password: 'your-secure-password',
52
+ },
53
+ });
54
+ await storage.initialize();
55
+
56
+ // Data is automatically encrypted
57
+ await storage.set('secret', { token: 'abc123' });
58
+ ```
59
+
60
+ ### With TTL (Time-To-Live)
61
+
62
+ ```typescript
63
+ const storage = new Strata({
64
+ ttl: {
65
+ enabled: true,
66
+ defaultTTL: 3600000, // 1 hour in ms
67
+ },
68
+ });
69
+ await storage.initialize();
70
+
71
+ // Expires after 1 hour (default)
72
+ await storage.set('session', { token: '...' });
73
+
74
+ // Custom TTL: expires in 5 minutes
75
+ await storage.set('cache', data, { ttl: 300000 });
76
+ ```
77
+
78
+ ### With Compression
79
+
80
+ ```typescript
81
+ const storage = new Strata({
82
+ compression: {
83
+ enabled: true,
84
+ threshold: 1024, // Compress data > 1KB
85
+ },
86
+ });
87
+ ```
88
+
89
+ ## Storage Adapters
90
+
91
+ ### Web Adapters
92
+
93
+ ```typescript
94
+ import {
95
+ MemoryAdapter,
96
+ LocalStorageAdapter,
97
+ SessionStorageAdapter,
98
+ IndexedDBAdapter,
99
+ CookieAdapter,
100
+ CacheAdapter,
101
+ } from 'strata-storage';
102
+
103
+ const storage = new Strata();
104
+ storage.registerAdapter(new LocalStorageAdapter());
105
+ storage.registerAdapter(new IndexedDBAdapter());
106
+ await storage.initialize();
107
+ ```
108
+
109
+ ### Capacitor/Mobile Adapters
110
+
111
+ ```typescript
112
+ import { Strata } from 'strata-storage';
113
+ import {
114
+ PreferencesAdapter,
115
+ SQLiteAdapter,
116
+ SecureStorageAdapter,
117
+ FilesystemAdapter,
118
+ } from 'strata-storage/capacitor';
119
+
120
+ const storage = new Strata();
121
+ storage.registerAdapter(new PreferencesAdapter());
122
+ storage.registerAdapter(new SecureStorageAdapter()); // For sensitive data
123
+ await storage.initialize();
124
+ ```
125
+
126
+ ### Adapter Selection
127
+
128
+ ```typescript
129
+ // Use specific adapter
130
+ await storage.set('key', 'value', { adapter: 'localStorage' });
131
+ await storage.set('secure', 'secret', { adapter: 'secure' });
132
+
133
+ // Get from specific adapter
134
+ const value = await storage.get('key', { adapter: 'indexedDB' });
135
+ ```
136
+
137
+ ## Framework Integrations
138
+
139
+ ### React
140
+
141
+ ```typescript
142
+ import { useStorage } from 'strata-storage/react';
143
+
144
+ function MyComponent() {
145
+ const { value, setValue, remove, loading, error } = useStorage<string>('username');
146
+
147
+ if (loading) return <div>Loading...</div>;
148
+
149
+ return (
150
+ <div>
151
+ <p>Username: {value}</p>
152
+ <button onClick={() => setValue('new_user')}>Update</button>
153
+ <button onClick={remove}>Remove</button>
154
+ </div>
155
+ );
156
+ }
157
+ ```
158
+
159
+ ### Vue
160
+
161
+ ```typescript
162
+ import { useStorage } from 'strata-storage/vue';
163
+
164
+ const { value, setValue, remove, loading, error } = useStorage<string>('username');
165
+ ```
166
+
167
+ ### Angular
168
+
169
+ ```typescript
170
+ import { StorageService } from 'strata-storage/angular';
171
+
172
+ @Component({ ... })
173
+ export class MyComponent {
174
+ constructor(private storage: StorageService) {}
175
+
176
+ async ngOnInit() {
177
+ const value = await this.storage.get('key');
178
+ }
179
+ }
180
+ ```
181
+
182
+ ## API Reference
183
+
184
+ ### Strata Class
185
+
186
+ | Method | Description | Returns |
187
+ |--------|-------------|---------|
188
+ | `initialize()` | Initialize storage and adapters | `Promise<void>` |
189
+ | `set(key, value, options?)` | Store a value | `Promise<void>` |
190
+ | `get<T>(key, options?)` | Retrieve a value | `Promise<T \| null>` |
191
+ | `remove(key, options?)` | Remove a value | `Promise<void>` |
192
+ | `clear(options?)` | Clear all values | `Promise<void>` |
193
+ | `has(key, options?)` | Check if key exists | `Promise<boolean>` |
194
+ | `keys(options?)` | Get all keys | `Promise<string[]>` |
195
+ | `registerAdapter(adapter)` | Register storage adapter | `void` |
196
+ | `subscribe(callback)` | Subscribe to changes | `UnsubscribeFunction` |
197
+
198
+ ### Configuration Options
199
+
200
+ ```typescript
201
+ interface StrataConfig {
202
+ defaultStorages?: StorageType[]; // Preferred adapter order
203
+ autoInitialize?: boolean; // Auto-init on first operation
204
+ encryption?: {
205
+ enabled: boolean;
206
+ password: string;
207
+ algorithm?: 'AES-GCM';
208
+ };
209
+ compression?: {
210
+ enabled: boolean;
211
+ threshold?: number; // Min bytes to compress
212
+ };
213
+ ttl?: {
214
+ enabled: boolean;
215
+ defaultTTL?: number; // Default expiration in ms
216
+ cleanupInterval?: number;
217
+ };
218
+ sync?: {
219
+ enabled: boolean;
220
+ channel?: string; // BroadcastChannel name
221
+ };
222
+ }
223
+ ```
224
+
225
+ ### Storage Options
226
+
227
+ ```typescript
228
+ interface StorageOptions {
229
+ adapter?: string; // Specific adapter to use
230
+ ttl?: number; // Custom TTL for this operation
231
+ tags?: string[]; // Tags for querying
232
+ encrypt?: boolean; // Override encryption setting
233
+ compress?: boolean; // Override compression setting
234
+ }
235
+ ```
236
+
237
+ ## Advanced Features
238
+
239
+ ### Tag-Based Queries
240
+
241
+ ```typescript
242
+ // Store with tags
243
+ await storage.set('user:1', userData, { tags: ['users', 'active'] });
244
+ await storage.set('user:2', userData, { tags: ['users', 'inactive'] });
245
+
246
+ // Query by tag
247
+ const activeUsers = await storage.query({ tags: ['active'] });
248
+
249
+ // Query with operators
250
+ const results = await storage.query({
251
+ where: {
252
+ age: { $gte: 18 },
253
+ status: 'active',
254
+ },
255
+ });
256
+ ```
257
+
258
+ ### Cross-Tab Sync
259
+
260
+ ```typescript
261
+ const storage = new Strata({
262
+ sync: {
263
+ enabled: true,
264
+ channel: 'my-app-storage',
265
+ },
266
+ });
267
+
268
+ // Subscribe to changes (including from other tabs)
269
+ storage.subscribe((event) => {
270
+ console.log('Storage changed:', event.key, event.newValue);
271
+ });
272
+ ```
273
+
274
+ ### Observer Pattern
275
+
276
+ ```typescript
277
+ import { StorageObserver } from 'strata-storage';
278
+
279
+ const observer = new StorageObserver(storage);
280
+
281
+ // Watch specific key
282
+ observer.watch('user', (newValue, oldValue) => {
283
+ console.log('User changed:', newValue);
284
+ });
285
+
286
+ // Watch pattern
287
+ observer.watchPattern(/^cache:/, (key, newValue) => {
288
+ console.log(`Cache key ${key} changed:`, newValue);
289
+ });
290
+ ```
291
+
292
+ ## Common Patterns
293
+
294
+ ### Initialize Once in App Entry
295
+
296
+ ```typescript
297
+ // src/storage.ts
298
+ import { Strata } from 'strata-storage';
299
+
300
+ export const storage = new Strata({
301
+ encryption: { enabled: true, password: import.meta.env.VITE_STORAGE_KEY },
302
+ ttl: { enabled: true, defaultTTL: 86400000 }, // 24 hours
303
+ });
304
+
305
+ // Initialize early in app lifecycle
306
+ storage.initialize();
307
+
308
+ export default storage;
309
+ ```
310
+
311
+ ### Use in Components
312
+
313
+ ```typescript
314
+ import storage from '@/storage';
315
+
316
+ async function saveSettings(settings: Settings) {
317
+ await storage.set('settings', settings);
318
+ }
319
+
320
+ async function loadSettings(): Promise<Settings | null> {
321
+ return await storage.get<Settings>('settings');
322
+ }
323
+ ```
324
+
325
+ ### Capacitor Mobile Setup
326
+
327
+ ```typescript
328
+ // capacitor.config.ts - register plugin
329
+ import { registerPlugin } from '@capacitor/core';
330
+
331
+ // In your app initialization
332
+ import { Strata } from 'strata-storage';
333
+ import { PreferencesAdapter, SecureStorageAdapter } from 'strata-storage/capacitor';
334
+
335
+ const storage = new Strata();
336
+ storage.registerAdapter(new PreferencesAdapter());
337
+ storage.registerAdapter(new SecureStorageAdapter());
338
+ await storage.initialize();
339
+ ```
340
+
341
+ ## Troubleshooting
342
+
343
+ | Issue | Solution |
344
+ |-------|----------|
345
+ | Data not persisting | Ensure `initialize()` is called before operations |
346
+ | Encryption errors | Check password is consistent, use env vars |
347
+ | Mobile storage not working | Register Capacitor adapters explicitly |
348
+ | Cross-tab not syncing | Enable sync in config, use same channel name |
349
+
350
+ ## Links
351
+
352
+ - [Full Documentation](./README.md)
353
+ - [Changelog](./CHANGELOG.md)
354
+ - [GitHub](https://github.com/aoneahsan/strata-storage)
package/README.md ADDED
@@ -0,0 +1,297 @@
1
+ # Strata Storage
2
+
3
+ - **[AI Integration Guide](./AI-INTEGRATION-GUIDE.md)** - Quick reference for AI development agents (Claude, Cursor, Copilot)
4
+
5
+ > Zero-dependency universal storage plugin providing a unified API for all storage operations across web, Android, and iOS platforms.
6
+
7
+ [![npm version](https://img.shields.io/npm/v/strata-storage.svg)](https://www.npmjs.com/package/strata-storage)
8
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
9
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.9+-blue.svg)](https://www.typescriptlang.org/)
10
+ [![Platform](https://img.shields.io/badge/platform-Web%20%7C%20iOS%20%7C%20Android-lightgrey.svg)](https://github.com/aoneahsan/strata-storage)
11
+
12
+ ## Features
13
+
14
+ - **🚀 Zero Dependencies** - No external runtime dependencies, pure TypeScript implementation
15
+ - **🌐 Universal API** - Single consistent API across web, iOS, and Android
16
+ - **🔒 Built-in Encryption** - Secure data storage using native crypto APIs
17
+ - **📦 Compression** - Automatic data compression for large objects
18
+ - **⏱️ TTL Support** - Automatic expiration with time-to-live
19
+ - **🔄 Cross-Tab Sync** - Real-time synchronization across browser tabs
20
+ - **🎯 Advanced Queries** - Tag-based querying and filtering
21
+ - **📱 Mobile Ready** - Native iOS and Android storage with Capacitor
22
+ - **💾 Multiple Adapters** - localStorage, IndexedDB, SQLite, Keychain, and more
23
+ - **🎨 Framework Integrations** - React hooks, Vue composables, Angular services
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ npm install strata-storage
29
+ ```
30
+
31
+ Or using yarn:
32
+
33
+ ```bash
34
+ yarn add strata-storage
35
+ ```
36
+
37
+ Or using pnpm:
38
+
39
+ ```bash
40
+ pnpm add strata-storage
41
+ ```
42
+
43
+ ## Quick Start
44
+
45
+ ### Basic Usage
46
+
47
+ ```typescript
48
+ import { Strata } from 'strata-storage';
49
+
50
+ // Create and initialize storage
51
+ const storage = new Strata();
52
+ await storage.initialize();
53
+
54
+ // Store data
55
+ await storage.set('username', 'john_doe');
56
+ await storage.set('user', {
57
+ id: 123,
58
+ name: 'John Doe',
59
+ email: 'john@example.com'
60
+ });
61
+
62
+ // Retrieve data
63
+ const username = await storage.get('username');
64
+ const user = await storage.get('user');
65
+
66
+ // Remove data
67
+ await storage.remove('username');
68
+
69
+ // Clear all data
70
+ await storage.clear();
71
+ ```
72
+
73
+ ### Advanced Features
74
+
75
+ #### Encryption
76
+
77
+ ```typescript
78
+ const storage = new Strata({
79
+ encryption: {
80
+ enabled: true,
81
+ password: 'your-secure-password'
82
+ }
83
+ });
84
+
85
+ await storage.initialize();
86
+ await storage.set('sensitiveData', { token: 'secret' });
87
+ ```
88
+
89
+ #### Time-To-Live (TTL)
90
+
91
+ ```typescript
92
+ // Data expires in 1 hour
93
+ await storage.set('sessionData', data, {
94
+ ttl: 60 * 60 * 1000
95
+ });
96
+ ```
97
+
98
+ #### Compression
99
+
100
+ ```typescript
101
+ const storage = new Strata({
102
+ compression: {
103
+ enabled: true,
104
+ threshold: 1024 // Compress data larger than 1KB
105
+ }
106
+ });
107
+
108
+ await storage.initialize();
109
+ await storage.set('largeData', bigObject);
110
+ ```
111
+
112
+ #### Cross-Tab Sync
113
+
114
+ ```typescript
115
+ const storage = new Strata({
116
+ sync: { enabled: true }
117
+ });
118
+
119
+ await storage.initialize();
120
+
121
+ // Subscribe to changes from other tabs
122
+ storage.subscribe((change) => {
123
+ console.log(`Key ${change.key} changed to:`, change.newValue);
124
+ });
125
+ ```
126
+
127
+ ## Platform Support
128
+
129
+ ### Web Browsers
130
+ - **localStorage** - Simple key-value storage
131
+ - **sessionStorage** - Session-scoped storage
132
+ - **IndexedDB** - Large structured data
133
+ - **Cookies** - Cookie-based storage
134
+ - **Cache API** - HTTP cache storage
135
+ - **Memory** - In-memory storage
136
+
137
+ ### iOS (via Capacitor)
138
+ - **UserDefaults** - User preferences
139
+ - **Keychain** - Secure credential storage
140
+ - **SQLite** - Database storage
141
+ - **FileManager** - File-based storage
142
+
143
+ ### Android (via Capacitor)
144
+ - **SharedPreferences** - Simple key-value storage
145
+ - **EncryptedSharedPreferences** - Secure storage
146
+ - **SQLite** - Database storage
147
+ - **File Storage** - File-based storage
148
+
149
+ ## Framework Integrations
150
+
151
+ ### React
152
+
153
+ ```typescript
154
+ import { useStrata } from 'strata-storage/react';
155
+
156
+ function MyComponent() {
157
+ const { data, loading, set, remove } = useStrata('myKey');
158
+
159
+ return (
160
+ <div>
161
+ <p>{data}</p>
162
+ <button onClick={() => set('newValue')}>Update</button>
163
+ </div>
164
+ );
165
+ }
166
+ ```
167
+
168
+ ### Vue
169
+
170
+ ```typescript
171
+ import { useStrata } from 'strata-storage/vue';
172
+
173
+ export default {
174
+ setup() {
175
+ const { data, loading, set, remove } = useStrata('myKey');
176
+
177
+ return { data, loading, set, remove };
178
+ }
179
+ };
180
+ ```
181
+
182
+ ### Angular
183
+
184
+ ```typescript
185
+ import { StrataService } from 'strata-storage/angular';
186
+
187
+ @Component({ /* ... */ })
188
+ export class MyComponent {
189
+ constructor(private storage: StrataService) {}
190
+
191
+ async saveData() {
192
+ await this.storage.set('key', 'value');
193
+ }
194
+ }
195
+ ```
196
+
197
+ ## Documentation
198
+
199
+ - **[Getting Started](docs/getting-started/installation.md)** - Installation and setup guide
200
+ - **[Quick Start](docs/getting-started/quick-start.md)** - Get up and running in minutes
201
+ - **[API Reference](docs/api/README.md)** - Complete API documentation
202
+ - **[Platform Guides](docs/guides/platforms/web.md)** - Platform-specific information
203
+ - **[Examples](docs/examples/README.md)** - Real-world usage examples
204
+ - **[Migration Guide](docs/MIGRATION.md)** - Migrating from other storage solutions
205
+
206
+ ## Storage Adapters
207
+
208
+ | Adapter | Platform | Use Case |
209
+ |---------|----------|----------|
210
+ | `localStorage` | Web | Simple key-value, persistent |
211
+ | `sessionStorage` | Web | Session-scoped data |
212
+ | `indexedDB` | Web | Large structured data |
213
+ | `cookies` | Web | Cookie-based storage |
214
+ | `cache` | Web | HTTP cache |
215
+ | `memory` | All | Temporary in-memory |
216
+ | `preferences` | Mobile | User preferences (UserDefaults/SharedPreferences) |
217
+ | `secure` | Mobile | Encrypted storage (Keychain/EncryptedSharedPreferences) |
218
+ | `sqlite` | Mobile | Database storage |
219
+ | `filesystem` | Mobile | File-based storage |
220
+
221
+ ## Requirements
222
+
223
+ - **Node.js**: 18.0.0 or higher
224
+ - **TypeScript**: 5.0+ (optional, but recommended)
225
+ - **Capacitor**: 5.x or 6.x (for mobile platforms)
226
+
227
+ ## Browser Support
228
+
229
+ - Chrome/Edge: Latest 2 versions
230
+ - Firefox: Latest 2 versions
231
+ - Safari: Latest 2 versions
232
+ - iOS Safari: iOS 13+
233
+ - Android WebView: Android 8+
234
+
235
+ ## Why Strata Storage?
236
+
237
+ ### Zero Dependencies
238
+ Unlike other storage solutions that depend on multiple packages, Strata Storage has **zero runtime dependencies**. Everything is built from scratch, ensuring:
239
+ - Smaller bundle size
240
+ - No dependency conflicts
241
+ - Better security
242
+ - Full control over implementation
243
+
244
+ ### Universal API
245
+ One API works everywhere. No need to learn different APIs for web and mobile, or switch between libraries:
246
+
247
+ ```typescript
248
+ // Same code works on web, iOS, and Android
249
+ await storage.set('key', 'value');
250
+ const value = await storage.get('key');
251
+ ```
252
+
253
+ ### Built-in Features
254
+ Advanced features included out of the box:
255
+ - Encryption (Web Crypto API / Native Crypto)
256
+ - Compression (LZ-string algorithm)
257
+ - TTL/Expiration
258
+ - Cross-tab sync
259
+ - Advanced queries
260
+ - Data migrations
261
+
262
+ ## Contributing
263
+
264
+ Contributions are welcome! Please read the [Contributing Guide](CONTRIBUTING.md) for details.
265
+
266
+ ## License
267
+
268
+ Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
269
+
270
+ ## Author
271
+
272
+ **Ahsan Mahmood**
273
+ - Email: aoneahsan@gmail.com
274
+ - LinkedIn: [linkedin.com/in/aoneahsan](https://linkedin.com/in/aoneahsan)
275
+ - Portfolio: [aoneahsan.com](https://aoneahsan.com)
276
+ - GitHub: [@aoneahsan](https://github.com/aoneahsan)
277
+ - NPM: [npmjs.com/~aoneahsan](https://www.npmjs.com/~aoneahsan)
278
+ - Phone/WhatsApp: +923046619706
279
+
280
+ ## Links
281
+
282
+ - **NPM Package**: [npmjs.com/package/strata-storage](https://www.npmjs.com/package/strata-storage)
283
+ - **GitHub Repository**: [github.com/aoneahsan/strata-storage](https://github.com/aoneahsan/strata-storage)
284
+ - **Issue Tracker**: [github.com/aoneahsan/strata-storage/issues](https://github.com/aoneahsan/strata-storage/issues)
285
+ - **Documentation**: [github.com/aoneahsan/strata-storage/tree/main/docs](https://github.com/aoneahsan/strata-storage/tree/main/docs)
286
+
287
+ ## Support
288
+
289
+ If you encounter any issues or have questions:
290
+
291
+ 1. Check the [FAQ](docs/reference/faq.md)
292
+ 2. Search [existing issues](https://github.com/aoneahsan/strata-storage/issues)
293
+ 3. Create a [new issue](https://github.com/aoneahsan/strata-storage/issues/new)
294
+
295
+ ---
296
+
297
+ Made with ❤️ by [Ahsan Mahmood](https://aoneahsan.com)
package/dist/README.md ADDED
@@ -0,0 +1,297 @@
1
+ # Strata Storage
2
+
3
+ - **[AI Integration Guide](./AI-INTEGRATION-GUIDE.md)** - Quick reference for AI development agents (Claude, Cursor, Copilot)
4
+
5
+ > Zero-dependency universal storage plugin providing a unified API for all storage operations across web, Android, and iOS platforms.
6
+
7
+ [![npm version](https://img.shields.io/npm/v/strata-storage.svg)](https://www.npmjs.com/package/strata-storage)
8
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
9
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.9+-blue.svg)](https://www.typescriptlang.org/)
10
+ [![Platform](https://img.shields.io/badge/platform-Web%20%7C%20iOS%20%7C%20Android-lightgrey.svg)](https://github.com/aoneahsan/strata-storage)
11
+
12
+ ## Features
13
+
14
+ - **🚀 Zero Dependencies** - No external runtime dependencies, pure TypeScript implementation
15
+ - **🌐 Universal API** - Single consistent API across web, iOS, and Android
16
+ - **🔒 Built-in Encryption** - Secure data storage using native crypto APIs
17
+ - **📦 Compression** - Automatic data compression for large objects
18
+ - **⏱️ TTL Support** - Automatic expiration with time-to-live
19
+ - **🔄 Cross-Tab Sync** - Real-time synchronization across browser tabs
20
+ - **🎯 Advanced Queries** - Tag-based querying and filtering
21
+ - **📱 Mobile Ready** - Native iOS and Android storage with Capacitor
22
+ - **💾 Multiple Adapters** - localStorage, IndexedDB, SQLite, Keychain, and more
23
+ - **🎨 Framework Integrations** - React hooks, Vue composables, Angular services
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ npm install strata-storage
29
+ ```
30
+
31
+ Or using yarn:
32
+
33
+ ```bash
34
+ yarn add strata-storage
35
+ ```
36
+
37
+ Or using pnpm:
38
+
39
+ ```bash
40
+ pnpm add strata-storage
41
+ ```
42
+
43
+ ## Quick Start
44
+
45
+ ### Basic Usage
46
+
47
+ ```typescript
48
+ import { Strata } from 'strata-storage';
49
+
50
+ // Create and initialize storage
51
+ const storage = new Strata();
52
+ await storage.initialize();
53
+
54
+ // Store data
55
+ await storage.set('username', 'john_doe');
56
+ await storage.set('user', {
57
+ id: 123,
58
+ name: 'John Doe',
59
+ email: 'john@example.com'
60
+ });
61
+
62
+ // Retrieve data
63
+ const username = await storage.get('username');
64
+ const user = await storage.get('user');
65
+
66
+ // Remove data
67
+ await storage.remove('username');
68
+
69
+ // Clear all data
70
+ await storage.clear();
71
+ ```
72
+
73
+ ### Advanced Features
74
+
75
+ #### Encryption
76
+
77
+ ```typescript
78
+ const storage = new Strata({
79
+ encryption: {
80
+ enabled: true,
81
+ password: 'your-secure-password'
82
+ }
83
+ });
84
+
85
+ await storage.initialize();
86
+ await storage.set('sensitiveData', { token: 'secret' });
87
+ ```
88
+
89
+ #### Time-To-Live (TTL)
90
+
91
+ ```typescript
92
+ // Data expires in 1 hour
93
+ await storage.set('sessionData', data, {
94
+ ttl: 60 * 60 * 1000
95
+ });
96
+ ```
97
+
98
+ #### Compression
99
+
100
+ ```typescript
101
+ const storage = new Strata({
102
+ compression: {
103
+ enabled: true,
104
+ threshold: 1024 // Compress data larger than 1KB
105
+ }
106
+ });
107
+
108
+ await storage.initialize();
109
+ await storage.set('largeData', bigObject);
110
+ ```
111
+
112
+ #### Cross-Tab Sync
113
+
114
+ ```typescript
115
+ const storage = new Strata({
116
+ sync: { enabled: true }
117
+ });
118
+
119
+ await storage.initialize();
120
+
121
+ // Subscribe to changes from other tabs
122
+ storage.subscribe((change) => {
123
+ console.log(`Key ${change.key} changed to:`, change.newValue);
124
+ });
125
+ ```
126
+
127
+ ## Platform Support
128
+
129
+ ### Web Browsers
130
+ - **localStorage** - Simple key-value storage
131
+ - **sessionStorage** - Session-scoped storage
132
+ - **IndexedDB** - Large structured data
133
+ - **Cookies** - Cookie-based storage
134
+ - **Cache API** - HTTP cache storage
135
+ - **Memory** - In-memory storage
136
+
137
+ ### iOS (via Capacitor)
138
+ - **UserDefaults** - User preferences
139
+ - **Keychain** - Secure credential storage
140
+ - **SQLite** - Database storage
141
+ - **FileManager** - File-based storage
142
+
143
+ ### Android (via Capacitor)
144
+ - **SharedPreferences** - Simple key-value storage
145
+ - **EncryptedSharedPreferences** - Secure storage
146
+ - **SQLite** - Database storage
147
+ - **File Storage** - File-based storage
148
+
149
+ ## Framework Integrations
150
+
151
+ ### React
152
+
153
+ ```typescript
154
+ import { useStrata } from 'strata-storage/react';
155
+
156
+ function MyComponent() {
157
+ const { data, loading, set, remove } = useStrata('myKey');
158
+
159
+ return (
160
+ <div>
161
+ <p>{data}</p>
162
+ <button onClick={() => set('newValue')}>Update</button>
163
+ </div>
164
+ );
165
+ }
166
+ ```
167
+
168
+ ### Vue
169
+
170
+ ```typescript
171
+ import { useStrata } from 'strata-storage/vue';
172
+
173
+ export default {
174
+ setup() {
175
+ const { data, loading, set, remove } = useStrata('myKey');
176
+
177
+ return { data, loading, set, remove };
178
+ }
179
+ };
180
+ ```
181
+
182
+ ### Angular
183
+
184
+ ```typescript
185
+ import { StrataService } from 'strata-storage/angular';
186
+
187
+ @Component({ /* ... */ })
188
+ export class MyComponent {
189
+ constructor(private storage: StrataService) {}
190
+
191
+ async saveData() {
192
+ await this.storage.set('key', 'value');
193
+ }
194
+ }
195
+ ```
196
+
197
+ ## Documentation
198
+
199
+ - **[Getting Started](docs/getting-started/installation.md)** - Installation and setup guide
200
+ - **[Quick Start](docs/getting-started/quick-start.md)** - Get up and running in minutes
201
+ - **[API Reference](docs/api/README.md)** - Complete API documentation
202
+ - **[Platform Guides](docs/guides/platforms/web.md)** - Platform-specific information
203
+ - **[Examples](docs/examples/README.md)** - Real-world usage examples
204
+ - **[Migration Guide](docs/MIGRATION.md)** - Migrating from other storage solutions
205
+
206
+ ## Storage Adapters
207
+
208
+ | Adapter | Platform | Use Case |
209
+ |---------|----------|----------|
210
+ | `localStorage` | Web | Simple key-value, persistent |
211
+ | `sessionStorage` | Web | Session-scoped data |
212
+ | `indexedDB` | Web | Large structured data |
213
+ | `cookies` | Web | Cookie-based storage |
214
+ | `cache` | Web | HTTP cache |
215
+ | `memory` | All | Temporary in-memory |
216
+ | `preferences` | Mobile | User preferences (UserDefaults/SharedPreferences) |
217
+ | `secure` | Mobile | Encrypted storage (Keychain/EncryptedSharedPreferences) |
218
+ | `sqlite` | Mobile | Database storage |
219
+ | `filesystem` | Mobile | File-based storage |
220
+
221
+ ## Requirements
222
+
223
+ - **Node.js**: 18.0.0 or higher
224
+ - **TypeScript**: 5.0+ (optional, but recommended)
225
+ - **Capacitor**: 5.x or 6.x (for mobile platforms)
226
+
227
+ ## Browser Support
228
+
229
+ - Chrome/Edge: Latest 2 versions
230
+ - Firefox: Latest 2 versions
231
+ - Safari: Latest 2 versions
232
+ - iOS Safari: iOS 13+
233
+ - Android WebView: Android 8+
234
+
235
+ ## Why Strata Storage?
236
+
237
+ ### Zero Dependencies
238
+ Unlike other storage solutions that depend on multiple packages, Strata Storage has **zero runtime dependencies**. Everything is built from scratch, ensuring:
239
+ - Smaller bundle size
240
+ - No dependency conflicts
241
+ - Better security
242
+ - Full control over implementation
243
+
244
+ ### Universal API
245
+ One API works everywhere. No need to learn different APIs for web and mobile, or switch between libraries:
246
+
247
+ ```typescript
248
+ // Same code works on web, iOS, and Android
249
+ await storage.set('key', 'value');
250
+ const value = await storage.get('key');
251
+ ```
252
+
253
+ ### Built-in Features
254
+ Advanced features included out of the box:
255
+ - Encryption (Web Crypto API / Native Crypto)
256
+ - Compression (LZ-string algorithm)
257
+ - TTL/Expiration
258
+ - Cross-tab sync
259
+ - Advanced queries
260
+ - Data migrations
261
+
262
+ ## Contributing
263
+
264
+ Contributions are welcome! Please read the [Contributing Guide](CONTRIBUTING.md) for details.
265
+
266
+ ## License
267
+
268
+ Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
269
+
270
+ ## Author
271
+
272
+ **Ahsan Mahmood**
273
+ - Email: aoneahsan@gmail.com
274
+ - LinkedIn: [linkedin.com/in/aoneahsan](https://linkedin.com/in/aoneahsan)
275
+ - Portfolio: [aoneahsan.com](https://aoneahsan.com)
276
+ - GitHub: [@aoneahsan](https://github.com/aoneahsan)
277
+ - NPM: [npmjs.com/~aoneahsan](https://www.npmjs.com/~aoneahsan)
278
+ - Phone/WhatsApp: +923046619706
279
+
280
+ ## Links
281
+
282
+ - **NPM Package**: [npmjs.com/package/strata-storage](https://www.npmjs.com/package/strata-storage)
283
+ - **GitHub Repository**: [github.com/aoneahsan/strata-storage](https://github.com/aoneahsan/strata-storage)
284
+ - **Issue Tracker**: [github.com/aoneahsan/strata-storage/issues](https://github.com/aoneahsan/strata-storage/issues)
285
+ - **Documentation**: [github.com/aoneahsan/strata-storage/tree/main/docs](https://github.com/aoneahsan/strata-storage/tree/main/docs)
286
+
287
+ ## Support
288
+
289
+ If you encounter any issues or have questions:
290
+
291
+ 1. Check the [FAQ](docs/reference/faq.md)
292
+ 2. Search [existing issues](https://github.com/aoneahsan/strata-storage/issues)
293
+ 3. Create a [new issue](https://github.com/aoneahsan/strata-storage/issues/new)
294
+
295
+ ---
296
+
297
+ Made with ❤️ by [Ahsan Mahmood](https://aoneahsan.com)
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Support configuration for strata-storage package
3
+ * Help keep this package free and improving
4
+ */
5
+ export declare const SUPPORT_CONFIG: {
6
+ readonly url: "https://aoneahsan.com/payment?project-id=strata-storage&project-identifier=strata-storage";
7
+ readonly label: "Support the Project";
8
+ readonly description: "Help us keep strata-storage free and improving";
9
+ };
10
+ //# sourceMappingURL=support.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"support.d.ts","sourceRoot":"","sources":["../../src/config/support.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;CAIjB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Support configuration for strata-storage package
3
+ * Help keep this package free and improving
4
+ */
5
+ export const SUPPORT_CONFIG = {
6
+ url: 'https://aoneahsan.com/payment?project-id=strata-storage&project-identifier=strata-storage',
7
+ label: 'Support the Project',
8
+ description: 'Help us keep strata-storage free and improving',
9
+ };
package/dist/index.d.ts CHANGED
@@ -13,7 +13,7 @@ export { TTLManager } from './features/ttl';
13
13
  export { QueryEngine } from './features/query';
14
14
  export { SyncManager } from './features/sync';
15
15
  export { StorageObserver } from './features/observer';
16
- export type { StorageType, StorageOptions, StorageValue, StorageAdapter, AdapterConfig, QueryOptions, SyncConfig, EncryptionConfig, CompressionConfig, ObserverCallback, StorageEvent, StorageError, StorageCapabilities, StorageMetadata, TTLConfig, } from './types';
16
+ export type { StorageType, StorageOptions, StorageValue, StorageAdapter, AdapterConfig, QueryOptions, SyncConfig, EncryptionConfig, CompressionConfig, ObserverCallback, StorageEvent, StorageError, StorageCapabilities, StorageMetadata, TTLConfig, StrataConfig, StorageChange, SubscriptionCallback, UnsubscribeFunction, } from './types';
17
17
  export { isValidKey, isValidValue, serializeValue, deserializeValue, generateId, createError, retry, debounce, throttle, } from './utils';
18
18
  import { Strata } from './core/Strata';
19
19
  declare const storage: Strata;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC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C;AAGtC,eAAe,OAAO,CAAC"}
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strata-storage",
3
- "version": "2.4.1",
3
+ "version": "2.4.3",
4
4
  "description": "Zero-dependency universal storage plugin providing a unified API for all storage operations across web, Android, and iOS platforms",
5
5
  "type": "module",
6
6
  "main": "./index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strata-storage",
3
- "version": "2.4.1",
3
+ "version": "2.4.3",
4
4
  "description": "Zero-dependency universal storage plugin providing a unified API for all storage operations across web, Android, and iOS platforms",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -10,7 +10,8 @@
10
10
  "ios/",
11
11
  "android/",
12
12
  "scripts/",
13
- "StrataStorage.podspec"
13
+ "StrataStorage.podspec",
14
+ "AI-INTEGRATION-GUIDE.md"
14
15
  ],
15
16
  "bin": {
16
17
  "strata-storage": "./scripts/cli.js"
@@ -27,6 +28,18 @@
27
28
  "./firebase": {
28
29
  "types": "./dist/firebase.d.ts",
29
30
  "default": "./dist/firebase.js"
31
+ },
32
+ "./react": {
33
+ "types": "./dist/integrations/react/index.d.ts",
34
+ "default": "./dist/integrations/react/index.js"
35
+ },
36
+ "./vue": {
37
+ "types": "./dist/integrations/vue/index.d.ts",
38
+ "default": "./dist/integrations/vue/index.js"
39
+ },
40
+ "./angular": {
41
+ "types": "./dist/integrations/angular/index.d.ts",
42
+ "default": "./dist/integrations/angular/index.js"
30
43
  }
31
44
  },
32
45
  "scripts": {
@@ -36,7 +49,7 @@
36
49
  "typecheck": "tsc --noEmit",
37
50
  "test": "vitest",
38
51
  "test:coverage": "vitest --coverage",
39
- "prepublishOnly": "pnpm build && pnpm lint && pnpm typecheck",
52
+ "prepublishOnly": "yarn build && yarn lint && yarn typecheck",
40
53
  "postinstall": "node scripts/postinstall.js || true"
41
54
  },
42
55
  "keywords": [
@@ -88,22 +101,22 @@
88
101
  }
89
102
  },
90
103
  "devDependencies": {
91
- "@types/node": "^25.0.3",
92
- "@types/react": "^19.2.7",
93
- "@typescript-eslint/eslint-plugin": "^8.50.1",
94
- "@typescript-eslint/parser": "^8.50.1",
95
- "@vitest/coverage-v8": "^4.0.16",
104
+ "@types/node": "^25.0.9",
105
+ "@types/react": "^19.2.9",
106
+ "@typescript-eslint/eslint-plugin": "^8.53.1",
107
+ "@typescript-eslint/parser": "^8.53.1",
108
+ "@vitest/coverage-v8": "^4.0.17",
96
109
  "eslint": "^9.39.2",
97
110
  "eslint-config-prettier": "^10.1.8",
98
- "eslint-plugin-prettier": "^5.5.4",
111
+ "eslint-plugin-prettier": "^5.5.5",
99
112
  "jsdom": "^27.4.0",
100
- "prettier": "^3.7.4",
113
+ "prettier": "^3.8.0",
101
114
  "typescript": "^5.9.3",
102
- "typescript-eslint": "^8.50.1",
103
- "vitest": "^4.0.16"
115
+ "typescript-eslint": "^8.53.1",
116
+ "vitest": "^4.0.17"
104
117
  },
105
118
  "engines": {
106
- "node": ">=25.0.3"
119
+ "node": ">=18.0.0"
107
120
  },
108
121
  "capacitor": {
109
122
  "ios": {