strata-storage 1.4.0 โ 1.6.0
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/StrataStorage.podspec +17 -0
- package/dist/README.md +116 -0
- package/dist/adapters/capacitor/FilesystemAdapter.js +4 -4
- package/dist/adapters/capacitor/PreferencesAdapter.js +4 -4
- package/dist/adapters/capacitor/SecureAdapter.js +4 -4
- package/dist/adapters/capacitor/SqliteAdapter.js +4 -4
- package/dist/adapters/capacitor/index.js +4 -4
- package/dist/adapters/web/CacheAdapter.js +3 -3
- package/dist/adapters/web/CookieAdapter.js +2 -2
- package/dist/adapters/web/IndexedDBAdapter.js +3 -3
- package/dist/adapters/web/LocalStorageAdapter.js +3 -3
- package/dist/adapters/web/MemoryAdapter.js +2 -2
- package/dist/adapters/web/SessionStorageAdapter.js +1 -1
- package/dist/adapters/web/index.js +6 -6
- package/dist/android/src/main/java/com/strata/storage/EncryptedStorage.java +65 -0
- package/dist/android/src/main/java/com/strata/storage/SQLiteStorage.java +147 -0
- package/dist/android/src/main/java/com/strata/storage/SharedPreferencesStorage.java +74 -0
- package/dist/android/src/main/java/com/stratastorage/StrataStoragePlugin.java +256 -0
- package/dist/core/AdapterRegistry.js +1 -1
- package/dist/core/BaseAdapter.js +3 -3
- package/dist/core/StorageStrategy.js +1 -0
- package/dist/core/Strata.js +17 -17
- package/dist/features/compression.js +1 -1
- package/dist/features/encryption.d.ts.map +1 -1
- package/dist/features/encryption.js +6 -5
- package/dist/features/sync.js +1 -1
- package/dist/features/ttl.js +1 -1
- package/dist/index.js +24 -24
- package/dist/ios/Plugin/KeychainStorage.swift +87 -0
- package/dist/ios/Plugin/SQLiteStorage.swift +167 -0
- package/dist/ios/Plugin/StrataStoragePlugin.swift +204 -0
- package/dist/ios/Plugin/UserDefaultsStorage.swift +44 -0
- package/dist/package.json +14 -4
- package/dist/plugin/index.js +2 -2
- package/package.json +10 -27
- package/scripts/build.js +119 -14
- package/scripts/cli.js +6 -2
- package/scripts/configure.js +7 -3
- package/scripts/postinstall.js +6 -2
package/scripts/build.js
CHANGED
|
@@ -1,39 +1,140 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { execSync } from 'child_process';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
6
10
|
|
|
7
11
|
const rootDir = path.join(__dirname, '..');
|
|
8
12
|
const srcDir = path.join(rootDir, 'src');
|
|
9
13
|
const distDir = path.join(rootDir, 'dist');
|
|
10
14
|
|
|
11
|
-
console.log('๐จ Building Strata Storage...');
|
|
15
|
+
console.log('๐จ Building Strata Storage (ESM)...');
|
|
12
16
|
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
// Clean dist directory
|
|
18
|
+
console.log('๐งน Cleaning dist directory...');
|
|
19
|
+
if (fs.existsSync(distDir)) {
|
|
20
|
+
fs.rmSync(distDir, { recursive: true, force: true });
|
|
16
21
|
}
|
|
17
22
|
|
|
18
|
-
//
|
|
19
|
-
|
|
23
|
+
// Ensure dist directory exists
|
|
24
|
+
fs.mkdirSync(distDir, { recursive: true });
|
|
25
|
+
|
|
26
|
+
// Compile TypeScript to ESM
|
|
27
|
+
console.log('๐ฆ Building ES Modules...');
|
|
20
28
|
try {
|
|
21
29
|
execSync('npx tsc', { stdio: 'inherit', cwd: rootDir });
|
|
22
30
|
} catch (error) {
|
|
23
|
-
console.error('โ
|
|
31
|
+
console.error('โ Build failed');
|
|
24
32
|
process.exit(1);
|
|
25
33
|
}
|
|
26
34
|
|
|
27
|
-
//
|
|
35
|
+
// Fix path aliases in all built files
|
|
36
|
+
console.log('๐ง Fixing path aliases...');
|
|
37
|
+
const fixPathAliases = (dir) => {
|
|
38
|
+
const files = fs.readdirSync(dir);
|
|
39
|
+
|
|
40
|
+
files.forEach(file => {
|
|
41
|
+
const filePath = path.join(dir, file);
|
|
42
|
+
const stat = fs.statSync(filePath);
|
|
43
|
+
|
|
44
|
+
if (stat.isDirectory()) {
|
|
45
|
+
fixPathAliases(filePath);
|
|
46
|
+
} else if (file.endsWith('.js')) {
|
|
47
|
+
let content = fs.readFileSync(filePath, 'utf8');
|
|
48
|
+
|
|
49
|
+
// Calculate depth from dist root
|
|
50
|
+
const relativeFromDist = path.relative(distDir, path.dirname(filePath));
|
|
51
|
+
const depth = relativeFromDist ? relativeFromDist.split(path.sep).length : 0;
|
|
52
|
+
const pathToRoot = depth > 0 ? '../'.repeat(depth) : './';
|
|
53
|
+
|
|
54
|
+
// Fix all @/ imports with proper aliasing
|
|
55
|
+
content = content
|
|
56
|
+
.replace(/from\s+["']@\/core\//g, `from "${pathToRoot}core/`)
|
|
57
|
+
.replace(/from\s+["']@\/adapters\//g, `from "${pathToRoot}adapters/`)
|
|
58
|
+
.replace(/from\s+["']@\/features\//g, `from "${pathToRoot}features/`)
|
|
59
|
+
.replace(/from\s+["']@\/utils\//g, `from "${pathToRoot}utils/`)
|
|
60
|
+
.replace(/from\s+["']@\/plugin\//g, `from "${pathToRoot}plugin/`)
|
|
61
|
+
.replace(/from\s+["']@\/types\//g, `from "${pathToRoot}types/`)
|
|
62
|
+
.replace(/from\s+["']@\/utils["']/g, `from "${pathToRoot}utils/index.js"`)
|
|
63
|
+
.replace(/from\s+["']@\/plugin["']/g, `from "${pathToRoot}plugin/index.js"`)
|
|
64
|
+
.replace(/import\(["']@\/core\//g, `import("${pathToRoot}core/`)
|
|
65
|
+
.replace(/import\(["']@\/adapters\//g, `import("${pathToRoot}adapters/`)
|
|
66
|
+
.replace(/import\(["']@\/features\//g, `import("${pathToRoot}features/`)
|
|
67
|
+
.replace(/import\(["']@\/utils\//g, `import("${pathToRoot}utils/`)
|
|
68
|
+
.replace(/import\(["']@\/plugin\//g, `import("${pathToRoot}plugin/`)
|
|
69
|
+
.replace(/import\(["']@\/types\//g, `import("${pathToRoot}types/`)
|
|
70
|
+
.replace(/import\(["']@\/utils["']\)/g, `import("${pathToRoot}utils/index.js")`)
|
|
71
|
+
.replace(/import\(["']@\/plugin["']\)/g, `import("${pathToRoot}plugin/index.js")`);
|
|
72
|
+
|
|
73
|
+
// Also fix any remaining short imports that should point to index.js
|
|
74
|
+
content = content
|
|
75
|
+
.replace(/from\s+["']\.\/utils["']/g, `from "./utils/index.js"`)
|
|
76
|
+
.replace(/from\s+["']\.\/plugin["']/g, `from "./plugin/index.js"`);
|
|
77
|
+
|
|
78
|
+
// Add .js extension to relative imports
|
|
79
|
+
content = content
|
|
80
|
+
.replace(/from\s+["'](\.[^"']+)["']/g, (match, path) => {
|
|
81
|
+
if (!path.endsWith('.js') && !path.endsWith('.json')) {
|
|
82
|
+
return `from "${path}.js"`;
|
|
83
|
+
}
|
|
84
|
+
return match;
|
|
85
|
+
})
|
|
86
|
+
.replace(/import\(["'](\.[^"']+)["']\)/g, (match, path) => {
|
|
87
|
+
if (!path.endsWith('.js') && !path.endsWith('.json')) {
|
|
88
|
+
return `import("${path}.js")`;
|
|
89
|
+
}
|
|
90
|
+
return match;
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
fs.writeFileSync(filePath, content);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
fixPathAliases(distDir);
|
|
99
|
+
|
|
100
|
+
// Copy native directories if they exist
|
|
101
|
+
console.log('๐ฑ Copying native code...');
|
|
102
|
+
const nativeDirs = ['android', 'ios'];
|
|
103
|
+
nativeDirs.forEach(dir => {
|
|
104
|
+
const srcPath = path.join(rootDir, dir);
|
|
105
|
+
const destPath = path.join(distDir, dir);
|
|
106
|
+
if (fs.existsSync(srcPath)) {
|
|
107
|
+
fs.cpSync(srcPath, destPath, { recursive: true });
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Copy other files
|
|
112
|
+
console.log('๐ Copying additional files...');
|
|
113
|
+
const filesToCopy = ['README.md', 'LICENSE'];
|
|
114
|
+
filesToCopy.forEach(file => {
|
|
115
|
+
const srcPath = path.join(rootDir, file);
|
|
116
|
+
const destPath = path.join(distDir, file);
|
|
117
|
+
if (fs.existsSync(srcPath)) {
|
|
118
|
+
fs.copyFileSync(srcPath, destPath);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Create package.json for distribution
|
|
28
123
|
console.log('๐ Preparing package metadata...');
|
|
29
124
|
const packageJson = JSON.parse(fs.readFileSync(path.join(rootDir, 'package.json'), 'utf8'));
|
|
30
125
|
const distPackageJson = {
|
|
31
126
|
name: packageJson.name,
|
|
32
127
|
version: packageJson.version,
|
|
33
128
|
description: packageJson.description,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
types: 'index.d.ts',
|
|
129
|
+
type: 'module',
|
|
130
|
+
main: './index.js',
|
|
131
|
+
types: './index.d.ts',
|
|
132
|
+
exports: {
|
|
133
|
+
'.': {
|
|
134
|
+
types: './index.d.ts',
|
|
135
|
+
default: './index.js'
|
|
136
|
+
}
|
|
137
|
+
},
|
|
37
138
|
author: packageJson.author,
|
|
38
139
|
license: packageJson.license,
|
|
39
140
|
repository: packageJson.repository,
|
|
@@ -41,6 +142,10 @@ const distPackageJson = {
|
|
|
41
142
|
peerDependencies: packageJson.peerDependencies,
|
|
42
143
|
peerDependenciesMeta: packageJson.peerDependenciesMeta,
|
|
43
144
|
capacitor: packageJson.capacitor,
|
|
145
|
+
sideEffects: false,
|
|
146
|
+
engines: {
|
|
147
|
+
node: '>=18.0.0'
|
|
148
|
+
}
|
|
44
149
|
};
|
|
45
150
|
|
|
46
151
|
fs.writeFileSync(
|
package/scripts/cli.js
CHANGED
|
@@ -5,8 +5,12 @@
|
|
|
5
5
|
* Main entry point for npx commands
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { spawn } from 'child_process';
|
|
10
|
+
import { fileURLToPath } from 'url';
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = path.dirname(__filename);
|
|
10
14
|
|
|
11
15
|
// Get command from arguments
|
|
12
16
|
const command = process.argv[2];
|
package/scripts/configure.js
CHANGED
|
@@ -5,9 +5,13 @@
|
|
|
5
5
|
* Usage: npx strata-storage configure
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
import { execSync } from 'child_process';
|
|
11
|
+
import { fileURLToPath } from 'url';
|
|
12
|
+
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = path.dirname(__filename);
|
|
11
15
|
|
|
12
16
|
// Colors for terminal output
|
|
13
17
|
const colors = {
|
package/scripts/postinstall.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
5
9
|
|
|
6
10
|
console.log('\n๐ Strata Storage - Zero Dependencies, Infinite Possibilities!\n');
|
|
7
11
|
|