strata-storage 1.6.0 → 2.0.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/Readme.md +66 -20
- package/android/build.gradle +58 -0
- package/android/proguard-rules.pro +11 -0
- package/android/settings.gradle +2 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/dist/README.md +66 -20
- package/dist/adapters/web/MemoryAdapter.js +1 -1
- package/dist/android/build.gradle +58 -0
- package/dist/android/proguard-rules.pro +11 -0
- package/dist/android/settings.gradle +2 -0
- package/dist/android/src/main/AndroidManifest.xml +2 -0
- package/dist/capacitor.d.ts +20 -0
- package/dist/capacitor.d.ts.map +1 -0
- package/dist/capacitor.js +48 -0
- package/dist/core/Strata.d.ts +28 -3
- package/dist/core/Strata.d.ts.map +1 -1
- package/dist/core/Strata.js +51 -52
- package/dist/features/compression/index.d.ts +2 -0
- package/dist/features/compression/index.d.ts.map +1 -0
- package/dist/features/compression/index.js +1 -0
- package/dist/features/encryption/index.d.ts +2 -0
- package/dist/features/encryption/index.d.ts.map +1 -0
- package/dist/features/encryption/index.js +1 -0
- package/dist/features/observer/index.d.ts +2 -0
- package/dist/features/observer/index.d.ts.map +1 -0
- package/dist/features/observer/index.js +1 -0
- package/dist/features/observer.d.ts +20 -0
- package/dist/features/observer.d.ts.map +1 -0
- package/dist/features/observer.js +32 -0
- package/dist/features/query/index.d.ts +2 -0
- package/dist/features/query/index.d.ts.map +1 -0
- package/dist/features/query/index.js +1 -0
- package/dist/features/query.d.ts.map +1 -1
- package/dist/features/query.js +8 -1
- package/dist/features/sync/index.d.ts +2 -0
- package/dist/features/sync/index.d.ts.map +1 -0
- package/dist/features/sync/index.js +1 -0
- package/dist/features/ttl/index.d.ts +2 -0
- package/dist/features/ttl/index.d.ts.map +1 -0
- package/dist/features/ttl/index.js +1 -0
- package/dist/firebase.d.ts +26 -0
- package/dist/firebase.d.ts.map +1 -0
- package/dist/firebase.js +147 -0
- package/dist/index.d.ts +13 -47
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -50
- package/dist/package.json +11 -2
- package/dist/plugin/definitions.d.ts +2 -2
- package/dist/plugin/definitions.d.ts.map +1 -1
- package/dist/plugin/index.d.ts +2 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +76 -10
- package/dist/types/index.d.ts +190 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +13 -0
- package/dist/utils/index.d.ts +20 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +34 -0
- package/package.json +12 -2
- package/scripts/build.js +8 -0
- package/scripts/postinstall.js +15 -8
package/Readme.md
CHANGED
|
@@ -23,21 +23,56 @@ Zero-dependency universal storage plugin providing a unified API for all storage
|
|
|
23
23
|
npm install strata-storage
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
### Provider-less Usage (Zero Setup)
|
|
26
27
|
```typescript
|
|
27
|
-
import {
|
|
28
|
+
import { storage } from 'strata-storage';
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
await storage.initialize();
|
|
31
|
-
|
|
32
|
-
// Works everywhere - web, iOS, Android
|
|
30
|
+
// Works immediately - no setup, no providers, no initialization!
|
|
33
31
|
await storage.set('user', { name: 'John', age: 30 });
|
|
34
32
|
const user = await storage.get('user');
|
|
35
33
|
```
|
|
36
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
|
+
|
|
37
67
|
## ✨ Features
|
|
38
68
|
|
|
39
69
|
### Core Features
|
|
40
|
-
- ✅ **Zero Dependencies** - No
|
|
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
|
|
41
76
|
- ✅ **Universal API** - Single interface for all storage types
|
|
42
77
|
- ✅ **Cross-Platform** - Web, iOS, Android support
|
|
43
78
|
- ✅ **TypeScript** - Full type safety and IntelliSense
|
|
@@ -67,22 +102,23 @@ const user = await storage.get('user');
|
|
|
67
102
|
## 📖 Basic Usage
|
|
68
103
|
|
|
69
104
|
```typescript
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
encryption: { enabled: true },
|
|
74
|
-
compression: { enabled: true },
|
|
75
|
-
ttl: { defaultTTL: 3600000 } // 1 hour
|
|
76
|
-
});
|
|
105
|
+
import { storage } from 'strata-storage';
|
|
106
|
+
|
|
107
|
+
// No initialization needed - works immediately!
|
|
77
108
|
|
|
78
|
-
|
|
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();
|
|
79
114
|
|
|
80
|
-
//
|
|
115
|
+
// Advanced options
|
|
81
116
|
await storage.set('key', value, {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
|
86
122
|
});
|
|
87
123
|
|
|
88
124
|
// Query data
|
|
@@ -97,13 +133,23 @@ storage.subscribe((change) => {
|
|
|
97
133
|
});
|
|
98
134
|
```
|
|
99
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
|
+
|
|
100
145
|
## 🏗 Project Status
|
|
101
146
|
|
|
102
147
|
Currently in active development. Phase 1-5 completed:
|
|
103
148
|
- ✅ Project setup and core architecture
|
|
104
149
|
- ✅ Memory and web storage adapters
|
|
105
|
-
- ✅ Capacitor plugin structure
|
|
150
|
+
- ✅ Capacitor plugin structure (now optional)
|
|
106
151
|
- ✅ Advanced features (encryption, compression, sync, query, TTL)
|
|
152
|
+
- ✅ Provider-less architecture
|
|
107
153
|
- 🚧 Native implementations (iOS/Android)
|
|
108
154
|
- 🚧 Testing and documentation
|
|
109
155
|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.2.1'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace "com.stratastorage"
|
|
22
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lintOptions {
|
|
37
|
+
abortOnError false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
google()
|
|
47
|
+
mavenCentral()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
dependencies {
|
|
51
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
52
|
+
implementation project(':capacitor-android')
|
|
53
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
54
|
+
implementation 'androidx.security:security-crypto:1.1.0-alpha06'
|
|
55
|
+
testImplementation "junit:junit:$junitVersion"
|
|
56
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
57
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
58
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Add project specific ProGuard rules here.
|
|
2
|
+
|
|
3
|
+
# Keep StrataStorage plugin classes
|
|
4
|
+
-keep class com.stratastorage.** { *; }
|
|
5
|
+
-keep class com.strata.storage.** { *; }
|
|
6
|
+
|
|
7
|
+
# Keep Capacitor classes
|
|
8
|
+
-keep class com.getcapacitor.** { *; }
|
|
9
|
+
|
|
10
|
+
# Keep security crypto classes for encrypted storage
|
|
11
|
+
-keep class androidx.security.crypto.** { *; }
|
package/dist/README.md
CHANGED
|
@@ -23,21 +23,56 @@ Zero-dependency universal storage plugin providing a unified API for all storage
|
|
|
23
23
|
npm install strata-storage
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
### Provider-less Usage (Zero Setup)
|
|
26
27
|
```typescript
|
|
27
|
-
import {
|
|
28
|
+
import { storage } from 'strata-storage';
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
await storage.initialize();
|
|
31
|
-
|
|
32
|
-
// Works everywhere - web, iOS, Android
|
|
30
|
+
// Works immediately - no setup, no providers, no initialization!
|
|
33
31
|
await storage.set('user', { name: 'John', age: 30 });
|
|
34
32
|
const user = await storage.get('user');
|
|
35
33
|
```
|
|
36
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
|
+
|
|
37
67
|
## ✨ Features
|
|
38
68
|
|
|
39
69
|
### Core Features
|
|
40
|
-
- ✅ **Zero Dependencies** - No
|
|
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
|
|
41
76
|
- ✅ **Universal API** - Single interface for all storage types
|
|
42
77
|
- ✅ **Cross-Platform** - Web, iOS, Android support
|
|
43
78
|
- ✅ **TypeScript** - Full type safety and IntelliSense
|
|
@@ -67,22 +102,23 @@ const user = await storage.get('user');
|
|
|
67
102
|
## 📖 Basic Usage
|
|
68
103
|
|
|
69
104
|
```typescript
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
encryption: { enabled: true },
|
|
74
|
-
compression: { enabled: true },
|
|
75
|
-
ttl: { defaultTTL: 3600000 } // 1 hour
|
|
76
|
-
});
|
|
105
|
+
import { storage } from 'strata-storage';
|
|
106
|
+
|
|
107
|
+
// No initialization needed - works immediately!
|
|
77
108
|
|
|
78
|
-
|
|
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();
|
|
79
114
|
|
|
80
|
-
//
|
|
115
|
+
// Advanced options
|
|
81
116
|
await storage.set('key', value, {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
|
86
122
|
});
|
|
87
123
|
|
|
88
124
|
// Query data
|
|
@@ -97,13 +133,23 @@ storage.subscribe((change) => {
|
|
|
97
133
|
});
|
|
98
134
|
```
|
|
99
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
|
+
|
|
100
145
|
## 🏗 Project Status
|
|
101
146
|
|
|
102
147
|
Currently in active development. Phase 1-5 completed:
|
|
103
148
|
- ✅ Project setup and core architecture
|
|
104
149
|
- ✅ Memory and web storage adapters
|
|
105
|
-
- ✅ Capacitor plugin structure
|
|
150
|
+
- ✅ Capacitor plugin structure (now optional)
|
|
106
151
|
- ✅ Advanced features (encryption, compression, sync, query, TTL)
|
|
152
|
+
- ✅ Provider-less architecture
|
|
107
153
|
- 🚧 Native implementations (iOS/Android)
|
|
108
154
|
- 🚧 Testing and documentation
|
|
109
155
|
|
|
@@ -134,7 +134,7 @@ export class MemoryAdapter extends BaseAdapter {
|
|
|
134
134
|
async query(condition) {
|
|
135
135
|
const results = [];
|
|
136
136
|
for (const [key, item] of this.storage.entries()) {
|
|
137
|
-
if (!this.isExpired(item) && this.queryEngine.matches(item
|
|
137
|
+
if (!this.isExpired(item) && this.queryEngine.matches(item, condition)) {
|
|
138
138
|
results.push({
|
|
139
139
|
key,
|
|
140
140
|
value: deepClone(item.value),
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.2.1'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace "com.stratastorage"
|
|
22
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lintOptions {
|
|
37
|
+
abortOnError false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
google()
|
|
47
|
+
mavenCentral()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
dependencies {
|
|
51
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
52
|
+
implementation project(':capacitor-android')
|
|
53
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
54
|
+
implementation 'androidx.security:security-crypto:1.1.0-alpha06'
|
|
55
|
+
testImplementation "junit:junit:$junitVersion"
|
|
56
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
57
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
58
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Add project specific ProGuard rules here.
|
|
2
|
+
|
|
3
|
+
# Keep StrataStorage plugin classes
|
|
4
|
+
-keep class com.stratastorage.** { *; }
|
|
5
|
+
-keep class com.strata.storage.** { *; }
|
|
6
|
+
|
|
7
|
+
# Keep Capacitor classes
|
|
8
|
+
-keep class com.getcapacitor.** { *; }
|
|
9
|
+
|
|
10
|
+
# Keep security crypto classes for encrypted storage
|
|
11
|
+
-keep class androidx.security.crypto.** { *; }
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Strata } from './core/Strata';
|
|
2
|
+
export { PreferencesAdapter } from './adapters/capacitor/PreferencesAdapter';
|
|
3
|
+
export { SqliteAdapter } from './adapters/capacitor/SqliteAdapter';
|
|
4
|
+
export { SecureAdapter } from './adapters/capacitor/SecureAdapter';
|
|
5
|
+
export { FilesystemAdapter } from './adapters/capacitor/FilesystemAdapter';
|
|
6
|
+
export { StrataStorage } from './plugin';
|
|
7
|
+
/**
|
|
8
|
+
* Register Capacitor adapters with a Strata instance
|
|
9
|
+
* This is completely optional and only needed for Capacitor apps
|
|
10
|
+
*/
|
|
11
|
+
export declare function registerCapacitorAdapters(storage: Strata): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Helper to check if running in Capacitor environment
|
|
14
|
+
*/
|
|
15
|
+
export declare function isCapacitorEnvironment(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Get Capacitor-specific storage types
|
|
18
|
+
*/
|
|
19
|
+
export declare function getCapacitorStorageTypes(): string[];
|
|
20
|
+
//# sourceMappingURL=capacitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capacitor.d.ts","sourceRoot":"","sources":["../src/capacitor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAO5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;GAGG;AACH,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB9E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAMhD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,EAAE,CAEnD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { PreferencesAdapter } from "./adapters/capacitor/PreferencesAdapter.js";
|
|
2
|
+
import { SqliteAdapter } from "./adapters/capacitor/SqliteAdapter.js";
|
|
3
|
+
import { SecureAdapter } from "./adapters/capacitor/SecureAdapter.js";
|
|
4
|
+
import { FilesystemAdapter } from "./adapters/capacitor/FilesystemAdapter.js";
|
|
5
|
+
// Export Capacitor adapters
|
|
6
|
+
export { PreferencesAdapter } from "./adapters/capacitor/PreferencesAdapter.js";
|
|
7
|
+
export { SqliteAdapter } from "./adapters/capacitor/SqliteAdapter.js";
|
|
8
|
+
export { SecureAdapter } from "./adapters/capacitor/SecureAdapter.js";
|
|
9
|
+
export { FilesystemAdapter } from "./adapters/capacitor/FilesystemAdapter.js";
|
|
10
|
+
// Export the plugin for direct access if needed
|
|
11
|
+
export { StrataStorage } from "./plugin/index.js";
|
|
12
|
+
/**
|
|
13
|
+
* Register Capacitor adapters with a Strata instance
|
|
14
|
+
* This is completely optional and only needed for Capacitor apps
|
|
15
|
+
*/
|
|
16
|
+
export async function registerCapacitorAdapters(storage) {
|
|
17
|
+
// Check if Capacitor is available
|
|
18
|
+
const hasCapacitor = typeof window !== 'undefined' &&
|
|
19
|
+
window.Capacitor &&
|
|
20
|
+
window.Capacitor.isNativePlatform();
|
|
21
|
+
if (!hasCapacitor) {
|
|
22
|
+
console.warn('Capacitor not detected. Capacitor adapters will not be registered.');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
// Register Capacitor adapters
|
|
26
|
+
storage.registerAdapter(new PreferencesAdapter());
|
|
27
|
+
storage.registerAdapter(new SqliteAdapter());
|
|
28
|
+
storage.registerAdapter(new SecureAdapter());
|
|
29
|
+
storage.registerAdapter(new FilesystemAdapter());
|
|
30
|
+
// Re-initialize to make new adapters available
|
|
31
|
+
if (storage.isInitialized) {
|
|
32
|
+
await storage.initialize();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Helper to check if running in Capacitor environment
|
|
37
|
+
*/
|
|
38
|
+
export function isCapacitorEnvironment() {
|
|
39
|
+
return (typeof window !== 'undefined' &&
|
|
40
|
+
window.Capacitor &&
|
|
41
|
+
window.Capacitor.isNativePlatform());
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get Capacitor-specific storage types
|
|
45
|
+
*/
|
|
46
|
+
export function getCapacitorStorageTypes() {
|
|
47
|
+
return ['preferences', 'sqlite', 'secure', 'filesystem'];
|
|
48
|
+
}
|
package/dist/core/Strata.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Strata Storage - Main entry point
|
|
3
3
|
* Zero-dependency universal storage solution
|
|
4
4
|
*/
|
|
5
|
-
import type { StrataConfig, StorageOptions, StorageType, SizeInfo, ClearOptions, ExportOptions, ImportOptions, SubscriptionCallback, UnsubscribeFunction, QueryCondition, StorageCapabilities } from '@/types';
|
|
5
|
+
import type { StrataConfig, StorageAdapter, StorageOptions, StorageType, Platform, SizeInfo, ClearOptions, ExportOptions, ImportOptions, SubscriptionCallback, UnsubscribeFunction, QueryCondition, StorageCapabilities } from '@/types';
|
|
6
|
+
import { AdapterRegistry } from './AdapterRegistry';
|
|
6
7
|
/**
|
|
7
8
|
* Main Strata class - unified storage interface
|
|
8
9
|
*/
|
|
@@ -11,12 +12,21 @@ export declare class Strata {
|
|
|
11
12
|
private registry;
|
|
12
13
|
private defaultAdapter?;
|
|
13
14
|
private adapters;
|
|
14
|
-
private
|
|
15
|
+
private readonly _platform;
|
|
15
16
|
private encryptionManager?;
|
|
16
17
|
private compressionManager?;
|
|
17
18
|
private syncManager?;
|
|
18
19
|
private ttlManager?;
|
|
20
|
+
private _initialized;
|
|
19
21
|
constructor(config?: StrataConfig);
|
|
22
|
+
/**
|
|
23
|
+
* Check if Strata has been initialized
|
|
24
|
+
*/
|
|
25
|
+
get isInitialized(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Get the detected platform
|
|
28
|
+
*/
|
|
29
|
+
get platform(): Platform;
|
|
20
30
|
/**
|
|
21
31
|
* Initialize Strata with available adapters
|
|
22
32
|
*/
|
|
@@ -107,6 +117,22 @@ export declare class Strata {
|
|
|
107
117
|
* Manually trigger TTL cleanup
|
|
108
118
|
*/
|
|
109
119
|
cleanupExpired(options?: StorageOptions): Promise<number>;
|
|
120
|
+
/**
|
|
121
|
+
* Register a custom storage adapter
|
|
122
|
+
* This allows external adapters to be registered after initialization
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* import { MyCustomAdapter } from './my-adapter';
|
|
127
|
+
* storage.registerAdapter(new MyCustomAdapter());
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
registerAdapter(adapter: StorageAdapter): void;
|
|
131
|
+
/**
|
|
132
|
+
* Get the adapter registry (for advanced use cases)
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
getRegistry(): AdapterRegistry;
|
|
110
136
|
/**
|
|
111
137
|
* Close all adapters
|
|
112
138
|
*/
|
|
@@ -114,7 +140,6 @@ export declare class Strata {
|
|
|
114
140
|
private normalizeConfig;
|
|
115
141
|
private detectPlatform;
|
|
116
142
|
private getDefaultStorages;
|
|
117
|
-
private registerAdapters;
|
|
118
143
|
private selectDefaultAdapter;
|
|
119
144
|
private initializeAdapters;
|
|
120
145
|
private selectAdapter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Strata.d.ts","sourceRoot":"","sources":["../../src/core/Strata.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,YAAY,
|
|
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,EACpB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAQpD;;GAEG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,cAAc,CAAC,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAA+C;IAC/D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IACrC,OAAO,CAAC,iBAAiB,CAAC,CAAoB;IAC9C,OAAO,CAAC,kBAAkB,CAAC,CAAqB;IAChD,OAAO,CAAC,WAAW,CAAC,CAAc;IAClC,OAAO,CAAC,UAAU,CAAC,CAAa;IAChC,OAAO,CAAC,YAAY,CAAkB;gBAE1B,MAAM,GAAE,YAAiB;IAMrC;;OAEG;IACH,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,QAAQ,CAEvB;IAED;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAmDjC;;OAEG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,E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