@capgo/capacitor-fast-sql 8.0.25 → 8.0.30
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/CapgoCapacitorFastSql.podspec +13 -4
- package/README.md +15 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/app/capgo/capacitor/fastsql/CapgoCapacitorFastSqlPlugin.java +1 -1
- package/android/src/main/java/app/capgo/capacitor/fastsql/SQLHTTPServer.java +40 -16
- package/ios/Sources/CapgoCapacitorFastSqlPlugin/CapgoCapacitorFastSqlPlugin.swift +1 -1
- package/ios/Sources/CapgoCapacitorFastSqlPlugin/SQLDatabase.swift +1 -1
- package/package.json +1 -1
|
@@ -10,10 +10,19 @@ Pod::Spec.new do |s|
|
|
|
10
10
|
s.homepage = package['repository']['url']
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
-
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
13
|
s.ios.deployment_target = '15.0'
|
|
15
|
-
s.dependency 'Capacitor'
|
|
16
|
-
s.dependency 'Telegraph', '~> 0.30'
|
|
17
|
-
s.dependency 'SQLCipher', '~> 4.10'
|
|
18
14
|
s.swift_version = '5.1'
|
|
15
|
+
s.default_subspecs = 'Core'
|
|
16
|
+
|
|
17
|
+
s.subspec 'Core' do |ss|
|
|
18
|
+
ss.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
19
|
+
ss.dependency 'Capacitor'
|
|
20
|
+
ss.dependency 'Telegraph', '~> 0.30'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Optional encryption support. Include this subspec to enable SQLCipher.
|
|
24
|
+
s.subspec 'SQLCipher' do |ss|
|
|
25
|
+
ss.dependency 'CapgoCapacitorFastSql/Core'
|
|
26
|
+
ss.dependency 'SQLCipher', '~> 4.10'
|
|
27
|
+
end
|
|
19
28
|
end
|
package/README.md
CHANGED
|
@@ -103,7 +103,9 @@ Then reference it in your `AndroidManifest.xml`:
|
|
|
103
103
|
</application>
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
## Encryption
|
|
106
|
+
## Encryption
|
|
107
|
+
|
|
108
|
+
### Android
|
|
107
109
|
|
|
108
110
|
Encryption uses [SQLCipher](https://www.zetetic.net/sqlcipher/) and is opt-in. Add the SQLCipher dependency to your **app-level** `build.gradle`:
|
|
109
111
|
|
|
@@ -125,6 +127,18 @@ const db = await FastSQL.connect({
|
|
|
125
127
|
|
|
126
128
|
If SQLCipher is not installed and `encrypted: true` is passed, the plugin returns a clear error message instead of crashing.
|
|
127
129
|
|
|
130
|
+
### iOS
|
|
131
|
+
|
|
132
|
+
SQLCipher is optional on iOS. The plugin builds without it; encryption calls will return `Encryption is not available in this build` unless SQLCipher is installed.
|
|
133
|
+
|
|
134
|
+
To enable encryption via CocoaPods, update your `ios/App/Podfile` after `capacitor install`/`cap sync` to use the SQLCipher subspec:
|
|
135
|
+
|
|
136
|
+
```ruby
|
|
137
|
+
pod 'CapgoCapacitorFastSql/SQLCipher', :path => '../../node_modules/@capgo/capacitor-fast-sql'
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Then run `pod install` in the `ios/App` directory. If you skip this subspec, keep `encrypted: false`.
|
|
141
|
+
|
|
128
142
|
## Web Platform
|
|
129
143
|
|
|
130
144
|
On the web, this plugin uses [sql.js](https://sql.js.org/) (SQLite compiled to WebAssembly) with IndexedDB for persistence.
|
package/android/build.gradle
CHANGED
|
@@ -54,7 +54,7 @@ dependencies {
|
|
|
54
54
|
implementation 'androidx.sqlite:sqlite:2.6.2'
|
|
55
55
|
implementation 'com.google.code.gson:gson:2.13.2'
|
|
56
56
|
implementation 'org.nanohttpd:nanohttpd:2.3.1'
|
|
57
|
-
compileOnly 'net.zetetic:sqlcipher-android:4.14.
|
|
57
|
+
compileOnly 'net.zetetic:sqlcipher-android:4.14.1'
|
|
58
58
|
testImplementation "junit:junit:$junitVersion"
|
|
59
59
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
60
60
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
@@ -19,7 +19,7 @@ import java.util.Map;
|
|
|
19
19
|
@CapacitorPlugin(name = "CapgoCapacitorFastSql")
|
|
20
20
|
public class CapgoCapacitorFastSqlPlugin extends Plugin {
|
|
21
21
|
|
|
22
|
-
private final String pluginVersion = "8.0.
|
|
22
|
+
private final String pluginVersion = "8.0.30";
|
|
23
23
|
|
|
24
24
|
private Map<String, DatabaseConnection> databases = new HashMap<>();
|
|
25
25
|
private SQLHTTPServer server;
|
|
@@ -11,6 +11,9 @@ import fi.iki.elonen.NanoHTTPD; // Note: org.nanohttpd:nanohttpd:2.3.1 still use
|
|
|
11
11
|
import java.io.IOException;
|
|
12
12
|
import java.security.SecureRandom;
|
|
13
13
|
import java.util.Map;
|
|
14
|
+
import java.util.concurrent.ExecutionException;
|
|
15
|
+
import java.util.concurrent.ExecutorService;
|
|
16
|
+
import java.util.concurrent.Executors;
|
|
14
17
|
import org.json.JSONArray;
|
|
15
18
|
import org.json.JSONObject;
|
|
16
19
|
|
|
@@ -25,6 +28,12 @@ public class SQLHTTPServer extends NanoHTTPD {
|
|
|
25
28
|
private final String token;
|
|
26
29
|
private final Map<String, DatabaseConnection> databases;
|
|
27
30
|
private final Gson gson = new Gson();
|
|
31
|
+
private final ExecutorService requestExecutor = Executors.newSingleThreadExecutor((runnable) -> {
|
|
32
|
+
Thread thread = new Thread(runnable);
|
|
33
|
+
thread.setName("FastSQL-DB");
|
|
34
|
+
thread.setDaemon(true);
|
|
35
|
+
return thread;
|
|
36
|
+
});
|
|
28
37
|
|
|
29
38
|
public SQLHTTPServer(Map<String, DatabaseConnection> databases) throws IOException {
|
|
30
39
|
super(findAvailablePort());
|
|
@@ -48,6 +57,12 @@ public class SQLHTTPServer extends NanoHTTPD {
|
|
|
48
57
|
return response;
|
|
49
58
|
}
|
|
50
59
|
|
|
60
|
+
@Override
|
|
61
|
+
public void stop() {
|
|
62
|
+
super.stop();
|
|
63
|
+
requestExecutor.shutdownNow();
|
|
64
|
+
}
|
|
65
|
+
|
|
51
66
|
@Override
|
|
52
67
|
public Response serve(IHTTPSession session) {
|
|
53
68
|
if (Method.OPTIONS.equals(session.getMethod())) {
|
|
@@ -69,25 +84,34 @@ public class SQLHTTPServer extends NanoHTTPD {
|
|
|
69
84
|
return addCorsHeaders(newFixedLengthResponse(Response.Status.NOT_FOUND, "text/plain", "Database not found"));
|
|
70
85
|
}
|
|
71
86
|
|
|
87
|
+
try {
|
|
88
|
+
return requestExecutor.submit(() -> routeRequest(session, db)).get();
|
|
89
|
+
} catch (ExecutionException e) {
|
|
90
|
+
Throwable cause = e.getCause();
|
|
91
|
+
String message = cause != null ? cause.getMessage() : e.getMessage();
|
|
92
|
+
return addCorsHeaders(newFixedLengthResponse(Response.Status.INTERNAL_ERROR, "text/plain", "Error: " + message));
|
|
93
|
+
} catch (InterruptedException e) {
|
|
94
|
+
Thread.currentThread().interrupt();
|
|
95
|
+
return addCorsHeaders(newFixedLengthResponse(Response.Status.INTERNAL_ERROR, "text/plain", "Request interrupted"));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private Response routeRequest(IHTTPSession session, DatabaseConnection db) throws Exception {
|
|
72
100
|
String uri = session.getUri();
|
|
73
101
|
Method method = session.getMethod();
|
|
74
102
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return addCorsHeaders(newFixedLengthResponse(Response.Status.NOT_FOUND, "text/plain", "Endpoint not found"));
|
|
88
|
-
}
|
|
89
|
-
} catch (Exception e) {
|
|
90
|
-
return addCorsHeaders(newFixedLengthResponse(Response.Status.INTERNAL_ERROR, "text/plain", "Error: " + e.getMessage()));
|
|
103
|
+
if (method == Method.POST && uri.equals("/execute")) {
|
|
104
|
+
return addCorsHeaders(handleExecute(session, db));
|
|
105
|
+
} else if (method == Method.POST && uri.equals("/batch")) {
|
|
106
|
+
return addCorsHeaders(handleBatch(session, db));
|
|
107
|
+
} else if (method == Method.POST && uri.equals("/transaction/begin")) {
|
|
108
|
+
return addCorsHeaders(handleBeginTransaction(db));
|
|
109
|
+
} else if (method == Method.POST && uri.equals("/transaction/commit")) {
|
|
110
|
+
return addCorsHeaders(handleCommitTransaction(db));
|
|
111
|
+
} else if (method == Method.POST && uri.equals("/transaction/rollback")) {
|
|
112
|
+
return addCorsHeaders(handleRollbackTransaction(db));
|
|
113
|
+
} else {
|
|
114
|
+
return addCorsHeaders(newFixedLengthResponse(Response.Status.NOT_FOUND, "text/plain", "Endpoint not found"));
|
|
91
115
|
}
|
|
92
116
|
}
|
|
93
117
|
|
|
@@ -10,7 +10,7 @@ import SQLite3
|
|
|
10
10
|
*/
|
|
11
11
|
@objc(CapgoCapacitorFastSqlPlugin)
|
|
12
12
|
public class CapgoCapacitorFastSqlPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
13
|
-
private let pluginVersion: String = "8.0.
|
|
13
|
+
private let pluginVersion: String = "8.0.30"
|
|
14
14
|
public let identifier = "CapgoCapacitorFastSqlPlugin"
|
|
15
15
|
public let jsName = "CapgoCapacitorFastSql"
|
|
16
16
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -270,7 +270,7 @@ extension SQLError: LocalizedError {
|
|
|
270
270
|
case .encryptionKeyMissing:
|
|
271
271
|
return "Encryption key is required when encryption is enabled"
|
|
272
272
|
case .encryptionUnavailable:
|
|
273
|
-
return "Encryption is not available in this build"
|
|
273
|
+
return "Encryption is not available in this build. Add SQLCipher to enable encryption."
|
|
274
274
|
case .encryptionFailed(let message):
|
|
275
275
|
return "Failed to set encryption key: \(message)"
|
|
276
276
|
case .transactionAlreadyActive:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-fast-sql",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.30",
|
|
4
4
|
"description": "High-performance native SQLite plugin with custom protocol for efficient sync operations and IndexedDB replacement",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|