strata-storage 2.4.1 → 2.4.2
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/README.md +295 -0
- package/dist/README.md +295 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +14 -2
package/README.md
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
# Strata Storage
|
|
2
|
+
|
|
3
|
+
> Zero-dependency universal storage plugin providing a unified API for all storage operations across web, Android, and iOS platforms.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/strata-storage)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://www.typescriptlang.org/)
|
|
8
|
+
[](https://github.com/aoneahsan/strata-storage)
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **🚀 Zero Dependencies** - No external runtime dependencies, pure TypeScript implementation
|
|
13
|
+
- **🌐 Universal API** - Single consistent API across web, iOS, and Android
|
|
14
|
+
- **🔒 Built-in Encryption** - Secure data storage using native crypto APIs
|
|
15
|
+
- **📦 Compression** - Automatic data compression for large objects
|
|
16
|
+
- **⏱️ TTL Support** - Automatic expiration with time-to-live
|
|
17
|
+
- **🔄 Cross-Tab Sync** - Real-time synchronization across browser tabs
|
|
18
|
+
- **🎯 Advanced Queries** - Tag-based querying and filtering
|
|
19
|
+
- **📱 Mobile Ready** - Native iOS and Android storage with Capacitor
|
|
20
|
+
- **💾 Multiple Adapters** - localStorage, IndexedDB, SQLite, Keychain, and more
|
|
21
|
+
- **🎨 Framework Integrations** - React hooks, Vue composables, Angular services
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install strata-storage
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or using yarn:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
yarn add strata-storage
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Or using pnpm:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pnpm add strata-storage
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Quick Start
|
|
42
|
+
|
|
43
|
+
### Basic Usage
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { Strata } from 'strata-storage';
|
|
47
|
+
|
|
48
|
+
// Create and initialize storage
|
|
49
|
+
const storage = new Strata();
|
|
50
|
+
await storage.initialize();
|
|
51
|
+
|
|
52
|
+
// Store data
|
|
53
|
+
await storage.set('username', 'john_doe');
|
|
54
|
+
await storage.set('user', {
|
|
55
|
+
id: 123,
|
|
56
|
+
name: 'John Doe',
|
|
57
|
+
email: 'john@example.com'
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Retrieve data
|
|
61
|
+
const username = await storage.get('username');
|
|
62
|
+
const user = await storage.get('user');
|
|
63
|
+
|
|
64
|
+
// Remove data
|
|
65
|
+
await storage.remove('username');
|
|
66
|
+
|
|
67
|
+
// Clear all data
|
|
68
|
+
await storage.clear();
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Advanced Features
|
|
72
|
+
|
|
73
|
+
#### Encryption
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
const storage = new Strata({
|
|
77
|
+
encryption: {
|
|
78
|
+
enabled: true,
|
|
79
|
+
password: 'your-secure-password'
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
await storage.initialize();
|
|
84
|
+
await storage.set('sensitiveData', { token: 'secret' });
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### Time-To-Live (TTL)
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
// Data expires in 1 hour
|
|
91
|
+
await storage.set('sessionData', data, {
|
|
92
|
+
ttl: 60 * 60 * 1000
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### Compression
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
const storage = new Strata({
|
|
100
|
+
compression: {
|
|
101
|
+
enabled: true,
|
|
102
|
+
threshold: 1024 // Compress data larger than 1KB
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
await storage.initialize();
|
|
107
|
+
await storage.set('largeData', bigObject);
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Cross-Tab Sync
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
const storage = new Strata({
|
|
114
|
+
sync: { enabled: true }
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
await storage.initialize();
|
|
118
|
+
|
|
119
|
+
// Subscribe to changes from other tabs
|
|
120
|
+
storage.subscribe((change) => {
|
|
121
|
+
console.log(`Key ${change.key} changed to:`, change.newValue);
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Platform Support
|
|
126
|
+
|
|
127
|
+
### Web Browsers
|
|
128
|
+
- **localStorage** - Simple key-value storage
|
|
129
|
+
- **sessionStorage** - Session-scoped storage
|
|
130
|
+
- **IndexedDB** - Large structured data
|
|
131
|
+
- **Cookies** - Cookie-based storage
|
|
132
|
+
- **Cache API** - HTTP cache storage
|
|
133
|
+
- **Memory** - In-memory storage
|
|
134
|
+
|
|
135
|
+
### iOS (via Capacitor)
|
|
136
|
+
- **UserDefaults** - User preferences
|
|
137
|
+
- **Keychain** - Secure credential storage
|
|
138
|
+
- **SQLite** - Database storage
|
|
139
|
+
- **FileManager** - File-based storage
|
|
140
|
+
|
|
141
|
+
### Android (via Capacitor)
|
|
142
|
+
- **SharedPreferences** - Simple key-value storage
|
|
143
|
+
- **EncryptedSharedPreferences** - Secure storage
|
|
144
|
+
- **SQLite** - Database storage
|
|
145
|
+
- **File Storage** - File-based storage
|
|
146
|
+
|
|
147
|
+
## Framework Integrations
|
|
148
|
+
|
|
149
|
+
### React
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
import { useStrata } from 'strata-storage/react';
|
|
153
|
+
|
|
154
|
+
function MyComponent() {
|
|
155
|
+
const { data, loading, set, remove } = useStrata('myKey');
|
|
156
|
+
|
|
157
|
+
return (
|
|
158
|
+
<div>
|
|
159
|
+
<p>{data}</p>
|
|
160
|
+
<button onClick={() => set('newValue')}>Update</button>
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Vue
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
import { useStrata } from 'strata-storage/vue';
|
|
170
|
+
|
|
171
|
+
export default {
|
|
172
|
+
setup() {
|
|
173
|
+
const { data, loading, set, remove } = useStrata('myKey');
|
|
174
|
+
|
|
175
|
+
return { data, loading, set, remove };
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Angular
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { StrataService } from 'strata-storage/angular';
|
|
184
|
+
|
|
185
|
+
@Component({ /* ... */ })
|
|
186
|
+
export class MyComponent {
|
|
187
|
+
constructor(private storage: StrataService) {}
|
|
188
|
+
|
|
189
|
+
async saveData() {
|
|
190
|
+
await this.storage.set('key', 'value');
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Documentation
|
|
196
|
+
|
|
197
|
+
- **[Getting Started](docs/getting-started/installation.md)** - Installation and setup guide
|
|
198
|
+
- **[Quick Start](docs/getting-started/quick-start.md)** - Get up and running in minutes
|
|
199
|
+
- **[API Reference](docs/api/README.md)** - Complete API documentation
|
|
200
|
+
- **[Platform Guides](docs/guides/platforms/web.md)** - Platform-specific information
|
|
201
|
+
- **[Examples](docs/examples/README.md)** - Real-world usage examples
|
|
202
|
+
- **[Migration Guide](docs/MIGRATION.md)** - Migrating from other storage solutions
|
|
203
|
+
|
|
204
|
+
## Storage Adapters
|
|
205
|
+
|
|
206
|
+
| Adapter | Platform | Use Case |
|
|
207
|
+
|---------|----------|----------|
|
|
208
|
+
| `localStorage` | Web | Simple key-value, persistent |
|
|
209
|
+
| `sessionStorage` | Web | Session-scoped data |
|
|
210
|
+
| `indexedDB` | Web | Large structured data |
|
|
211
|
+
| `cookies` | Web | Cookie-based storage |
|
|
212
|
+
| `cache` | Web | HTTP cache |
|
|
213
|
+
| `memory` | All | Temporary in-memory |
|
|
214
|
+
| `preferences` | Mobile | User preferences (UserDefaults/SharedPreferences) |
|
|
215
|
+
| `secure` | Mobile | Encrypted storage (Keychain/EncryptedSharedPreferences) |
|
|
216
|
+
| `sqlite` | Mobile | Database storage |
|
|
217
|
+
| `filesystem` | Mobile | File-based storage |
|
|
218
|
+
|
|
219
|
+
## Requirements
|
|
220
|
+
|
|
221
|
+
- **Node.js**: 18.0.0 or higher
|
|
222
|
+
- **TypeScript**: 5.0+ (optional, but recommended)
|
|
223
|
+
- **Capacitor**: 5.x or 6.x (for mobile platforms)
|
|
224
|
+
|
|
225
|
+
## Browser Support
|
|
226
|
+
|
|
227
|
+
- Chrome/Edge: Latest 2 versions
|
|
228
|
+
- Firefox: Latest 2 versions
|
|
229
|
+
- Safari: Latest 2 versions
|
|
230
|
+
- iOS Safari: iOS 13+
|
|
231
|
+
- Android WebView: Android 8+
|
|
232
|
+
|
|
233
|
+
## Why Strata Storage?
|
|
234
|
+
|
|
235
|
+
### Zero Dependencies
|
|
236
|
+
Unlike other storage solutions that depend on multiple packages, Strata Storage has **zero runtime dependencies**. Everything is built from scratch, ensuring:
|
|
237
|
+
- Smaller bundle size
|
|
238
|
+
- No dependency conflicts
|
|
239
|
+
- Better security
|
|
240
|
+
- Full control over implementation
|
|
241
|
+
|
|
242
|
+
### Universal API
|
|
243
|
+
One API works everywhere. No need to learn different APIs for web and mobile, or switch between libraries:
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
// Same code works on web, iOS, and Android
|
|
247
|
+
await storage.set('key', 'value');
|
|
248
|
+
const value = await storage.get('key');
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Built-in Features
|
|
252
|
+
Advanced features included out of the box:
|
|
253
|
+
- Encryption (Web Crypto API / Native Crypto)
|
|
254
|
+
- Compression (LZ-string algorithm)
|
|
255
|
+
- TTL/Expiration
|
|
256
|
+
- Cross-tab sync
|
|
257
|
+
- Advanced queries
|
|
258
|
+
- Data migrations
|
|
259
|
+
|
|
260
|
+
## Contributing
|
|
261
|
+
|
|
262
|
+
Contributions are welcome! Please read the [Contributing Guide](CONTRIBUTING.md) for details.
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
|
|
267
|
+
|
|
268
|
+
## Author
|
|
269
|
+
|
|
270
|
+
**Ahsan Mahmood**
|
|
271
|
+
- Email: aoneahsan@gmail.com
|
|
272
|
+
- LinkedIn: [linkedin.com/in/aoneahsan](https://linkedin.com/in/aoneahsan)
|
|
273
|
+
- Portfolio: [aoneahsan.com](https://aoneahsan.com)
|
|
274
|
+
- GitHub: [@aoneahsan](https://github.com/aoneahsan)
|
|
275
|
+
- NPM: [npmjs.com/~aoneahsan](https://www.npmjs.com/~aoneahsan)
|
|
276
|
+
- Phone/WhatsApp: +923046619706
|
|
277
|
+
|
|
278
|
+
## Links
|
|
279
|
+
|
|
280
|
+
- **NPM Package**: [npmjs.com/package/strata-storage](https://www.npmjs.com/package/strata-storage)
|
|
281
|
+
- **GitHub Repository**: [github.com/aoneahsan/strata-storage](https://github.com/aoneahsan/strata-storage)
|
|
282
|
+
- **Issue Tracker**: [github.com/aoneahsan/strata-storage/issues](https://github.com/aoneahsan/strata-storage/issues)
|
|
283
|
+
- **Documentation**: [github.com/aoneahsan/strata-storage/tree/main/docs](https://github.com/aoneahsan/strata-storage/tree/main/docs)
|
|
284
|
+
|
|
285
|
+
## Support
|
|
286
|
+
|
|
287
|
+
If you encounter any issues or have questions:
|
|
288
|
+
|
|
289
|
+
1. Check the [FAQ](docs/reference/faq.md)
|
|
290
|
+
2. Search [existing issues](https://github.com/aoneahsan/strata-storage/issues)
|
|
291
|
+
3. Create a [new issue](https://github.com/aoneahsan/strata-storage/issues/new)
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
Made with ❤️ by [Ahsan Mahmood](https://aoneahsan.com)
|
package/dist/README.md
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
# Strata Storage
|
|
2
|
+
|
|
3
|
+
> Zero-dependency universal storage plugin providing a unified API for all storage operations across web, Android, and iOS platforms.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/strata-storage)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://www.typescriptlang.org/)
|
|
8
|
+
[](https://github.com/aoneahsan/strata-storage)
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **🚀 Zero Dependencies** - No external runtime dependencies, pure TypeScript implementation
|
|
13
|
+
- **🌐 Universal API** - Single consistent API across web, iOS, and Android
|
|
14
|
+
- **🔒 Built-in Encryption** - Secure data storage using native crypto APIs
|
|
15
|
+
- **📦 Compression** - Automatic data compression for large objects
|
|
16
|
+
- **⏱️ TTL Support** - Automatic expiration with time-to-live
|
|
17
|
+
- **🔄 Cross-Tab Sync** - Real-time synchronization across browser tabs
|
|
18
|
+
- **🎯 Advanced Queries** - Tag-based querying and filtering
|
|
19
|
+
- **📱 Mobile Ready** - Native iOS and Android storage with Capacitor
|
|
20
|
+
- **💾 Multiple Adapters** - localStorage, IndexedDB, SQLite, Keychain, and more
|
|
21
|
+
- **🎨 Framework Integrations** - React hooks, Vue composables, Angular services
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install strata-storage
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or using yarn:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
yarn add strata-storage
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Or using pnpm:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pnpm add strata-storage
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Quick Start
|
|
42
|
+
|
|
43
|
+
### Basic Usage
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { Strata } from 'strata-storage';
|
|
47
|
+
|
|
48
|
+
// Create and initialize storage
|
|
49
|
+
const storage = new Strata();
|
|
50
|
+
await storage.initialize();
|
|
51
|
+
|
|
52
|
+
// Store data
|
|
53
|
+
await storage.set('username', 'john_doe');
|
|
54
|
+
await storage.set('user', {
|
|
55
|
+
id: 123,
|
|
56
|
+
name: 'John Doe',
|
|
57
|
+
email: 'john@example.com'
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Retrieve data
|
|
61
|
+
const username = await storage.get('username');
|
|
62
|
+
const user = await storage.get('user');
|
|
63
|
+
|
|
64
|
+
// Remove data
|
|
65
|
+
await storage.remove('username');
|
|
66
|
+
|
|
67
|
+
// Clear all data
|
|
68
|
+
await storage.clear();
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Advanced Features
|
|
72
|
+
|
|
73
|
+
#### Encryption
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
const storage = new Strata({
|
|
77
|
+
encryption: {
|
|
78
|
+
enabled: true,
|
|
79
|
+
password: 'your-secure-password'
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
await storage.initialize();
|
|
84
|
+
await storage.set('sensitiveData', { token: 'secret' });
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### Time-To-Live (TTL)
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
// Data expires in 1 hour
|
|
91
|
+
await storage.set('sessionData', data, {
|
|
92
|
+
ttl: 60 * 60 * 1000
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### Compression
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
const storage = new Strata({
|
|
100
|
+
compression: {
|
|
101
|
+
enabled: true,
|
|
102
|
+
threshold: 1024 // Compress data larger than 1KB
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
await storage.initialize();
|
|
107
|
+
await storage.set('largeData', bigObject);
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Cross-Tab Sync
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
const storage = new Strata({
|
|
114
|
+
sync: { enabled: true }
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
await storage.initialize();
|
|
118
|
+
|
|
119
|
+
// Subscribe to changes from other tabs
|
|
120
|
+
storage.subscribe((change) => {
|
|
121
|
+
console.log(`Key ${change.key} changed to:`, change.newValue);
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Platform Support
|
|
126
|
+
|
|
127
|
+
### Web Browsers
|
|
128
|
+
- **localStorage** - Simple key-value storage
|
|
129
|
+
- **sessionStorage** - Session-scoped storage
|
|
130
|
+
- **IndexedDB** - Large structured data
|
|
131
|
+
- **Cookies** - Cookie-based storage
|
|
132
|
+
- **Cache API** - HTTP cache storage
|
|
133
|
+
- **Memory** - In-memory storage
|
|
134
|
+
|
|
135
|
+
### iOS (via Capacitor)
|
|
136
|
+
- **UserDefaults** - User preferences
|
|
137
|
+
- **Keychain** - Secure credential storage
|
|
138
|
+
- **SQLite** - Database storage
|
|
139
|
+
- **FileManager** - File-based storage
|
|
140
|
+
|
|
141
|
+
### Android (via Capacitor)
|
|
142
|
+
- **SharedPreferences** - Simple key-value storage
|
|
143
|
+
- **EncryptedSharedPreferences** - Secure storage
|
|
144
|
+
- **SQLite** - Database storage
|
|
145
|
+
- **File Storage** - File-based storage
|
|
146
|
+
|
|
147
|
+
## Framework Integrations
|
|
148
|
+
|
|
149
|
+
### React
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
import { useStrata } from 'strata-storage/react';
|
|
153
|
+
|
|
154
|
+
function MyComponent() {
|
|
155
|
+
const { data, loading, set, remove } = useStrata('myKey');
|
|
156
|
+
|
|
157
|
+
return (
|
|
158
|
+
<div>
|
|
159
|
+
<p>{data}</p>
|
|
160
|
+
<button onClick={() => set('newValue')}>Update</button>
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Vue
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
import { useStrata } from 'strata-storage/vue';
|
|
170
|
+
|
|
171
|
+
export default {
|
|
172
|
+
setup() {
|
|
173
|
+
const { data, loading, set, remove } = useStrata('myKey');
|
|
174
|
+
|
|
175
|
+
return { data, loading, set, remove };
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Angular
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { StrataService } from 'strata-storage/angular';
|
|
184
|
+
|
|
185
|
+
@Component({ /* ... */ })
|
|
186
|
+
export class MyComponent {
|
|
187
|
+
constructor(private storage: StrataService) {}
|
|
188
|
+
|
|
189
|
+
async saveData() {
|
|
190
|
+
await this.storage.set('key', 'value');
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Documentation
|
|
196
|
+
|
|
197
|
+
- **[Getting Started](docs/getting-started/installation.md)** - Installation and setup guide
|
|
198
|
+
- **[Quick Start](docs/getting-started/quick-start.md)** - Get up and running in minutes
|
|
199
|
+
- **[API Reference](docs/api/README.md)** - Complete API documentation
|
|
200
|
+
- **[Platform Guides](docs/guides/platforms/web.md)** - Platform-specific information
|
|
201
|
+
- **[Examples](docs/examples/README.md)** - Real-world usage examples
|
|
202
|
+
- **[Migration Guide](docs/MIGRATION.md)** - Migrating from other storage solutions
|
|
203
|
+
|
|
204
|
+
## Storage Adapters
|
|
205
|
+
|
|
206
|
+
| Adapter | Platform | Use Case |
|
|
207
|
+
|---------|----------|----------|
|
|
208
|
+
| `localStorage` | Web | Simple key-value, persistent |
|
|
209
|
+
| `sessionStorage` | Web | Session-scoped data |
|
|
210
|
+
| `indexedDB` | Web | Large structured data |
|
|
211
|
+
| `cookies` | Web | Cookie-based storage |
|
|
212
|
+
| `cache` | Web | HTTP cache |
|
|
213
|
+
| `memory` | All | Temporary in-memory |
|
|
214
|
+
| `preferences` | Mobile | User preferences (UserDefaults/SharedPreferences) |
|
|
215
|
+
| `secure` | Mobile | Encrypted storage (Keychain/EncryptedSharedPreferences) |
|
|
216
|
+
| `sqlite` | Mobile | Database storage |
|
|
217
|
+
| `filesystem` | Mobile | File-based storage |
|
|
218
|
+
|
|
219
|
+
## Requirements
|
|
220
|
+
|
|
221
|
+
- **Node.js**: 18.0.0 or higher
|
|
222
|
+
- **TypeScript**: 5.0+ (optional, but recommended)
|
|
223
|
+
- **Capacitor**: 5.x or 6.x (for mobile platforms)
|
|
224
|
+
|
|
225
|
+
## Browser Support
|
|
226
|
+
|
|
227
|
+
- Chrome/Edge: Latest 2 versions
|
|
228
|
+
- Firefox: Latest 2 versions
|
|
229
|
+
- Safari: Latest 2 versions
|
|
230
|
+
- iOS Safari: iOS 13+
|
|
231
|
+
- Android WebView: Android 8+
|
|
232
|
+
|
|
233
|
+
## Why Strata Storage?
|
|
234
|
+
|
|
235
|
+
### Zero Dependencies
|
|
236
|
+
Unlike other storage solutions that depend on multiple packages, Strata Storage has **zero runtime dependencies**. Everything is built from scratch, ensuring:
|
|
237
|
+
- Smaller bundle size
|
|
238
|
+
- No dependency conflicts
|
|
239
|
+
- Better security
|
|
240
|
+
- Full control over implementation
|
|
241
|
+
|
|
242
|
+
### Universal API
|
|
243
|
+
One API works everywhere. No need to learn different APIs for web and mobile, or switch between libraries:
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
// Same code works on web, iOS, and Android
|
|
247
|
+
await storage.set('key', 'value');
|
|
248
|
+
const value = await storage.get('key');
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Built-in Features
|
|
252
|
+
Advanced features included out of the box:
|
|
253
|
+
- Encryption (Web Crypto API / Native Crypto)
|
|
254
|
+
- Compression (LZ-string algorithm)
|
|
255
|
+
- TTL/Expiration
|
|
256
|
+
- Cross-tab sync
|
|
257
|
+
- Advanced queries
|
|
258
|
+
- Data migrations
|
|
259
|
+
|
|
260
|
+
## Contributing
|
|
261
|
+
|
|
262
|
+
Contributions are welcome! Please read the [Contributing Guide](CONTRIBUTING.md) for details.
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
|
|
267
|
+
|
|
268
|
+
## Author
|
|
269
|
+
|
|
270
|
+
**Ahsan Mahmood**
|
|
271
|
+
- Email: aoneahsan@gmail.com
|
|
272
|
+
- LinkedIn: [linkedin.com/in/aoneahsan](https://linkedin.com/in/aoneahsan)
|
|
273
|
+
- Portfolio: [aoneahsan.com](https://aoneahsan.com)
|
|
274
|
+
- GitHub: [@aoneahsan](https://github.com/aoneahsan)
|
|
275
|
+
- NPM: [npmjs.com/~aoneahsan](https://www.npmjs.com/~aoneahsan)
|
|
276
|
+
- Phone/WhatsApp: +923046619706
|
|
277
|
+
|
|
278
|
+
## Links
|
|
279
|
+
|
|
280
|
+
- **NPM Package**: [npmjs.com/package/strata-storage](https://www.npmjs.com/package/strata-storage)
|
|
281
|
+
- **GitHub Repository**: [github.com/aoneahsan/strata-storage](https://github.com/aoneahsan/strata-storage)
|
|
282
|
+
- **Issue Tracker**: [github.com/aoneahsan/strata-storage/issues](https://github.com/aoneahsan/strata-storage/issues)
|
|
283
|
+
- **Documentation**: [github.com/aoneahsan/strata-storage/tree/main/docs](https://github.com/aoneahsan/strata-storage/tree/main/docs)
|
|
284
|
+
|
|
285
|
+
## Support
|
|
286
|
+
|
|
287
|
+
If you encounter any issues or have questions:
|
|
288
|
+
|
|
289
|
+
1. Check the [FAQ](docs/reference/faq.md)
|
|
290
|
+
2. Search [existing issues](https://github.com/aoneahsan/strata-storage/issues)
|
|
291
|
+
3. Create a [new issue](https://github.com/aoneahsan/strata-storage/issues/new)
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
Made with ❤️ by [Ahsan Mahmood](https://aoneahsan.com)
|
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;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,YAAY,EACV,WAAW,EACX,cAAc,EACd,YAAY,EACZ,cAAc,EACd,aAAa,EACb,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,SAAS,
|
|
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;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,YAAY,EACV,WAAW,EACX,cAAc,EACd,YAAY,EACZ,cAAc,EACd,aAAa,EACb,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,SAAS,EACT,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,UAAU,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AASvC,QAAA,MAAM,OAAO,QAGX,CAAC;AAoBH,QAAA,MAAM,iBAAiB,qBAQtB,CAAC;AAMF,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAGtC,eAAe,OAAO,CAAC"}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strata-storage",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
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.
|
|
3
|
+
"version": "2.4.2",
|
|
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",
|
|
@@ -27,6 +27,18 @@
|
|
|
27
27
|
"./firebase": {
|
|
28
28
|
"types": "./dist/firebase.d.ts",
|
|
29
29
|
"default": "./dist/firebase.js"
|
|
30
|
+
},
|
|
31
|
+
"./react": {
|
|
32
|
+
"types": "./dist/integrations/react/index.d.ts",
|
|
33
|
+
"default": "./dist/integrations/react/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./vue": {
|
|
36
|
+
"types": "./dist/integrations/vue/index.d.ts",
|
|
37
|
+
"default": "./dist/integrations/vue/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./angular": {
|
|
40
|
+
"types": "./dist/integrations/angular/index.d.ts",
|
|
41
|
+
"default": "./dist/integrations/angular/index.js"
|
|
30
42
|
}
|
|
31
43
|
},
|
|
32
44
|
"scripts": {
|
|
@@ -103,7 +115,7 @@
|
|
|
103
115
|
"vitest": "^4.0.16"
|
|
104
116
|
},
|
|
105
117
|
"engines": {
|
|
106
|
-
"node": ">=
|
|
118
|
+
"node": ">=18.0.0"
|
|
107
119
|
},
|
|
108
120
|
"capacitor": {
|
|
109
121
|
"ios": {
|