strata-storage 2.0.1 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/Readme.md +17 -0
  3. package/android/src/main/java/com/strata/storage/EncryptedStorage.java +44 -3
  4. package/android/src/main/java/com/strata/storage/SQLiteStorage.java +35 -5
  5. package/android/src/main/java/com/strata/storage/SharedPreferencesStorage.java +43 -3
  6. package/android/src/main/java/com/stratastorage/StrataStoragePlugin.java +12 -3
  7. package/dist/LICENSE +21 -0
  8. package/dist/adapters/web/CacheAdapter.d.ts.map +1 -1
  9. package/dist/adapters/web/CacheAdapter.js +1 -3
  10. package/dist/adapters/web/IndexedDBAdapter.d.ts.map +1 -1
  11. package/dist/adapters/web/IndexedDBAdapter.js +1 -3
  12. package/dist/adapters/web/LocalStorageAdapter.d.ts.map +1 -1
  13. package/dist/adapters/web/LocalStorageAdapter.js +1 -3
  14. package/dist/adapters/web/MemoryAdapter.d.ts.map +1 -1
  15. package/dist/adapters/web/MemoryAdapter.js +1 -3
  16. package/dist/android/src/main/java/com/strata/storage/EncryptedStorage.java +44 -3
  17. package/dist/android/src/main/java/com/strata/storage/SQLiteStorage.java +35 -5
  18. package/dist/android/src/main/java/com/strata/storage/SharedPreferencesStorage.java +43 -3
  19. package/dist/android/src/main/java/com/stratastorage/StrataStoragePlugin.java +12 -3
  20. package/dist/capacitor.d.ts.map +1 -1
  21. package/dist/capacitor.js +4 -3
  22. package/dist/core/AdapterRegistry.d.ts +1 -1
  23. package/dist/core/AdapterRegistry.d.ts.map +1 -1
  24. package/dist/core/AdapterRegistry.js +10 -3
  25. package/dist/core/BaseAdapter.d.ts +2 -2
  26. package/dist/core/BaseAdapter.d.ts.map +1 -1
  27. package/dist/core/Strata.d.ts +133 -2
  28. package/dist/core/Strata.d.ts.map +1 -1
  29. package/dist/core/Strata.js +153 -14
  30. package/dist/firebase.d.ts.map +1 -1
  31. package/dist/firebase.js +21 -1
  32. package/dist/index.d.ts +2 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +26 -16
  35. package/dist/ios/Plugin/KeychainStorage.swift +31 -9
  36. package/dist/ios/Plugin/SQLiteStorage.swift +29 -6
  37. package/dist/ios/Plugin/UserDefaultsStorage.swift +25 -7
  38. package/dist/package.json +5 -5
  39. package/dist/plugin/web.d.ts +10 -6
  40. package/dist/plugin/web.d.ts.map +1 -1
  41. package/dist/plugin/web.js +42 -13
  42. package/dist/types/index.d.ts +2 -2
  43. package/dist/types/index.d.ts.map +1 -1
  44. package/dist/utils/index.d.ts +0 -3
  45. package/dist/utils/index.d.ts.map +1 -1
  46. package/dist/utils/index.js +0 -3
  47. package/ios/Plugin/KeychainStorage.swift +31 -9
  48. package/ios/Plugin/SQLiteStorage.swift +29 -6
  49. package/ios/Plugin/UserDefaultsStorage.swift +25 -7
  50. package/package.json +15 -15
  51. package/dist/README.md +0 -162
package/dist/README.md DELETED
@@ -1,162 +0,0 @@
1
- # Strata Storage
2
-
3
- ## 📚 Documentation
4
-
5
- - **[Getting Started](./docs/getting-started/installation.md)** - Installation and setup
6
- - **[Quick Start Guide](./docs/getting-started/quick-start.md)** - Get running in minutes
7
- - **[API Reference](./docs/api/README.md)** - Complete API documentation
8
- - **[Configuration](./docs/getting-started/configuration.md)** - Configuration options
9
- - **[Platform Guides](./docs/guides/platforms/web.md)** - Platform-specific guides
10
- - **[Examples](./docs/examples/README.md)** - Code examples and recipes
11
- - **[GitHub](https://github.com/aoneahsan/strata-storage)** - Source code
12
- - **[NPM](https://www.npmjs.com/package/strata-storage)** - Package registry
13
-
14
- ---
15
-
16
- **One API. Every Storage. Everywhere.**
17
-
18
- Zero-dependency universal storage plugin providing a unified API for all storage operations across web, Android, and iOS platforms.
19
-
20
- ## 🚀 Quick Start
21
-
22
- ```bash
23
- npm install strata-storage
24
- ```
25
-
26
- ### Provider-less Usage (Zero Setup)
27
- ```typescript
28
- import { storage } from 'strata-storage';
29
-
30
- // Works immediately - no setup, no providers, no initialization!
31
- await storage.set('user', { name: 'John', age: 30 });
32
- const user = await storage.get('user');
33
- ```
34
-
35
- ### With Capacitor (Optional)
36
- ```typescript
37
- import { storage } from 'strata-storage';
38
- import { registerCapacitorAdapters } from 'strata-storage/capacitor';
39
-
40
- // Only if you need native features
41
- if (window.Capacitor) {
42
- await registerCapacitorAdapters(storage);
43
- }
44
-
45
- // Use native storage when available
46
- await storage.set('secure-data', 'secret', { storage: 'secure' });
47
- ```
48
-
49
- ### With Firebase (Optional)
50
- ```typescript
51
- import { storage } from 'strata-storage';
52
- import { enableFirebaseSync } from 'strata-storage/firebase';
53
-
54
- // Only if you need cloud sync
55
- if (needCloudSync) {
56
- await enableFirebaseSync(storage, {
57
- apiKey: 'your-api-key',
58
- projectId: 'your-project-id',
59
- firestore: true
60
- });
61
- }
62
-
63
- // Works offline-first, syncs when online
64
- await storage.set('data', value, { storage: 'firestore' });
65
- ```
66
-
67
- ## ✨ Features
68
-
69
- ### Core Features
70
- - ✅ **Zero Dependencies** - No runtime dependencies, pure implementation
71
- - ✅ **Provider-less Architecture** - No providers, contexts, or wrappers needed (like zustand)
72
- - ✅ **Works Everywhere** - React, Vue, Angular, Vanilla JS, Node.js - same API
73
- - ✅ **Zero Configuration** - Import and use immediately, no setup required
74
- - ✅ **Opt-in Complexity** - Start simple, add features only when needed
75
- - ✅ **Dynamic Provider Loading** - Providers load only when used, keeping bundle small
76
- - ✅ **Universal API** - Single interface for all storage types
77
- - ✅ **Cross-Platform** - Web, iOS, Android support
78
- - ✅ **TypeScript** - Full type safety and IntelliSense
79
- - ✅ **Auto Fallback** - Intelligent storage selection
80
-
81
- ### Storage Adapters
82
- - ✅ **Memory** - Fast in-memory storage
83
- - ✅ **LocalStorage** - Persistent browser storage
84
- - ✅ **SessionStorage** - Session-based browser storage
85
- - ✅ **IndexedDB** - Large-scale browser database
86
- - ✅ **Cookies** - HTTP cookie storage
87
- - ✅ **Cache API** - Service worker cache storage
88
- - ✅ **Capacitor Preferences** - Native mobile preferences
89
- - ✅ **SQLite** - Mobile SQL database
90
- - ✅ **Secure Storage** - Keychain (iOS) / Encrypted SharedPreferences (Android)
91
- - ✅ **Filesystem** - File-based storage
92
-
93
- ### Advanced Features
94
- - ✅ **Encryption** - AES-GCM encryption with Web Crypto API
95
- - ✅ **Compression** - LZ-string compression algorithm
96
- - ✅ **Cross-Tab Sync** - Real-time synchronization across tabs
97
- - ✅ **Query Engine** - MongoDB-like queries for filtering data
98
- - ✅ **TTL Support** - Automatic expiration with sliding TTL
99
- - ✅ **Migration System** - Version-based data migrations
100
- - 🚧 **Framework Integrations** - React, Vue, Angular (coming soon)
101
-
102
- ## 📖 Basic Usage
103
-
104
- ```typescript
105
- import { storage } from 'strata-storage';
106
-
107
- // No initialization needed - works immediately!
108
-
109
- // Simple usage
110
- await storage.set('key', 'value');
111
- const value = await storage.get('key');
112
- await storage.remove('key');
113
- await storage.clear();
114
-
115
- // Advanced options
116
- await storage.set('key', value, {
117
- storage: 'indexedDB', // Choose specific storage
118
- ttl: 3600000, // Expire in 1 hour
119
- encrypt: true, // Encrypt this value
120
- compress: true, // Compress if beneficial
121
- tags: ['user-data'] // Tag for grouping
122
- });
123
-
124
- // Query data
125
- const results = await storage.query({
126
- tags: { $in: ['user-data'] },
127
- 'value.age': { $gte: 18 }
128
- });
129
-
130
- // Subscribe to changes
131
- storage.subscribe((change) => {
132
- console.log(`${change.key} changed from ${change.oldValue} to ${change.newValue}`);
133
- });
134
- ```
135
-
136
- ## 🎯 Provider-less Architecture
137
-
138
- Strata Storage follows a provider-less architecture similar to Zustand. The core library works everywhere with zero dependencies, and platform-specific features (like Capacitor) are completely optional.
139
-
140
- - **Minimal by default** - Only includes web storage adapters
141
- - **Opt-in native features** - Explicitly add Capacitor support when needed
142
- - **Better tree-shaking** - Unused adapters are eliminated by bundlers
143
- - **Smaller bundle size** - Web-only projects don't include native code
144
-
145
- ## 🏗 Project Status
146
-
147
- Currently in active development. Phase 1-5 completed:
148
- - ✅ Project setup and core architecture
149
- - ✅ Memory and web storage adapters
150
- - ✅ Capacitor plugin structure (now optional)
151
- - ✅ Advanced features (encryption, compression, sync, query, TTL)
152
- - ✅ Provider-less architecture
153
- - 🚧 Native implementations (iOS/Android)
154
- - 🚧 Testing and documentation
155
-
156
- ## 📄 License
157
-
158
- MIT
159
-
160
- ---
161
-
162
- Created by Ahsan Mahmood