react-native-nitro-sqlite 9.6.0 → 9.8.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/RNNitroSQLite.podspec +56 -20
- package/android/CMakeLists.txt +15 -0
- package/android/build.gradle +14 -0
- package/cpp/NitroSQLiteException.hpp +5 -0
- package/cpp/databaseMigration.cpp +123 -0
- package/cpp/databaseMigration.hpp +13 -0
- package/cpp/hybridObjects/HybridNitroSQLite.cpp +65 -16
- package/cpp/hybridObjects/HybridNitroSQLite.hpp +5 -0
- package/cpp/hybridObjects/HybridNitroSQLiteQueryResult.cpp +5 -4
- package/cpp/hybridObjects/HybridNitroSQLiteQueryResult.hpp +1 -1
- package/cpp/importSqlFile.cpp +10 -5
- package/cpp/importSqlFile.hpp +5 -1
- package/cpp/operations.cpp +232 -168
- package/cpp/operations.hpp +31 -1
- package/cpp/sqliteExecuteBatch.cpp +17 -16
- package/cpp/sqliteExecuteBatch.hpp +4 -0
- package/ios/OnLoad.mm +26 -3
- package/lib/commonjs/DatabaseQueue.js +4 -17
- package/lib/commonjs/DatabaseQueue.js.map +1 -1
- package/lib/commonjs/operations/execute.js +28 -11
- package/lib/commonjs/operations/execute.js.map +1 -1
- package/lib/commonjs/operations/session.js +34 -9
- package/lib/commonjs/operations/session.js.map +1 -1
- package/lib/commonjs/operations/transaction.js +5 -5
- package/lib/commonjs/operations/transaction.js.map +1 -1
- package/lib/module/DatabaseQueue.js +4 -15
- package/lib/module/DatabaseQueue.js.map +1 -1
- package/lib/module/operations/execute.js +24 -12
- package/lib/module/operations/execute.js.map +1 -1
- package/lib/module/operations/session.js +36 -11
- package/lib/module/operations/session.js.map +1 -1
- package/lib/module/operations/transaction.js +6 -6
- package/lib/module/operations/transaction.js.map +1 -1
- package/lib/typescript/commonjs/DatabaseQueue.d.ts +1 -3
- package/lib/typescript/commonjs/DatabaseQueue.d.ts.map +1 -1
- package/lib/typescript/commonjs/operations/execute.d.ts +6 -0
- package/lib/typescript/commonjs/operations/execute.d.ts.map +1 -1
- package/lib/typescript/commonjs/operations/session.d.ts.map +1 -1
- package/lib/typescript/commonjs/specs/NitroSQLite.nitro.d.ts.map +1 -1
- package/lib/typescript/commonjs/specs/NitroSQLiteQueryResult.nitro.d.ts.map +1 -1
- package/lib/typescript/module/DatabaseQueue.d.ts +1 -3
- package/lib/typescript/module/DatabaseQueue.d.ts.map +1 -1
- package/lib/typescript/module/operations/execute.d.ts +6 -0
- package/lib/typescript/module/operations/execute.d.ts.map +1 -1
- package/lib/typescript/module/operations/session.d.ts.map +1 -1
- package/lib/typescript/module/specs/NitroSQLite.nitro.d.ts.map +1 -1
- package/lib/typescript/module/specs/NitroSQLiteQueryResult.nitro.d.ts.map +1 -1
- package/nitrogen/generated/android/RNNitroSQLiteOnLoad.cpp +2 -2
- package/nitrogen/generated/android/c++/JHybridNitroSQLiteOnLoadSpec.hpp +2 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnnitrosqlite/HybridNitroSQLiteOnLoadSpec.kt +2 -0
- package/nitrogen/generated/ios/RNNitroSQLite+autolinking.rb +2 -0
- package/package.json +9 -7
- package/src/DatabaseQueue.ts +9 -19
- package/src/operations/execute.ts +52 -12
- package/src/operations/session.ts +57 -11
- package/src/operations/transaction.ts +6 -6
- package/src/specs/NitroSQLite.nitro.ts +4 -1
- package/src/specs/NitroSQLiteQueryResult.nitro.ts +4 -1
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.9/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { QueryResult, QueryResultRow, SQLiteQueryParams } from '../types';
|
|
2
|
+
import type { NitroSQLiteQueryResult } from '../specs/NitroSQLiteQueryResult.nitro';
|
|
2
3
|
export declare function execute<Row extends QueryResultRow = never>(dbName: string, query: string, params?: SQLiteQueryParams): QueryResult<Row>;
|
|
4
|
+
export declare function executeManaged<Row extends QueryResultRow = never>(dbName: string, query: string, params?: SQLiteQueryParams): QueryResult<Row>;
|
|
5
|
+
export declare function executeNative<Row extends QueryResultRow = never>(dbName: string, query: string, params?: SQLiteQueryParams): QueryResult<Row>;
|
|
3
6
|
export declare function executeAsync<Row extends QueryResultRow = never>(dbName: string, query: string, params?: SQLiteQueryParams): Promise<QueryResult<Row>>;
|
|
7
|
+
export declare function executeAsyncManaged<Row extends QueryResultRow = never>(dbName: string, query: string, params?: SQLiteQueryParams): Promise<QueryResult<Row>>;
|
|
8
|
+
export declare function executeAsyncNative<Row extends QueryResultRow = never>(dbName: string, query: string, params?: SQLiteQueryParams): Promise<QueryResult<Row>>;
|
|
9
|
+
export declare function buildJSQueryResult<Row extends QueryResultRow = never>(result: NitroSQLiteQueryResult): QueryResult<Row>;
|
|
4
10
|
//# sourceMappingURL=execute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../../src/operations/execute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../../src/operations/execute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAE9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AAOnF,wBA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|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/operations/session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,qBAAqB,EACrB,4BAA4B,EAK7B,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/operations/session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,qBAAqB,EACrB,4BAA4B,EAK7B,MAAM,UAAU,CAAA;AAYjB,wBAAgB,IAAI,CAClB,OAAO,EAAE,4BAA4B,GACpC,qBAAqB,CAwEvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NitroSQLite.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/NitroSQLite.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EAClB,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAE5E,MAAM,WAAW,WACf,SAAQ,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"NitroSQLite.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/NitroSQLite.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EAClB,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAE5E,MAAM,WAAW,WACf,SAAQ,YAAY,CAAC;IACnB,GAAG,EAAE,KAAK,CAAA;IACV,OAAO,EAAE,KAAK,CAAA;CACf,CAAC;IACF,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAA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E,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEvD;;;;;;;;;GASG;AACH,MAAM,WAAW,sBACf,SAAQ,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"NitroSQLiteQueryResult.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/NitroSQLiteQueryResult.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEvD;;;;;;;;;GASG;AACH,MAAM,WAAW,sBACf,SAAQ,YAAY,CAAC;IACnB,GAAG,EAAE,KAAK,CAAA;IACV,OAAO,EAAE,KAAK,CAAA;CACf,CAAC;IACF,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAE1B,oBAAoB;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,CAAA;IAE/C,qBAAqB;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAA;CACnE;AASD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAA;IAEZ,uLAAuL;IACvL,IAAI,EAAE,UAAU,CAAA;IAEhB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAA;CACd,CAAA"}
|
|
@@ -13,8 +13,6 @@ export declare function closeDatabaseQueue(dbName: string): void;
|
|
|
13
13
|
export declare function isDatabaseOpen(dbName: string): boolean;
|
|
14
14
|
export declare function throwIfDatabaseIsNotOpen(dbName: string): void;
|
|
15
15
|
export declare function getDatabaseQueue(dbName: string): DatabaseQueue;
|
|
16
|
-
export declare function openDatabase(dbName: string): void;
|
|
17
|
-
export declare function closeDatabase(dbName: string): void;
|
|
18
16
|
export declare function queueOperationAsync<Result>(dbName: string, callback: () => Promise<Result>): Promise<Result>;
|
|
19
|
-
export declare function startOperationSync<
|
|
17
|
+
export declare function startOperationSync<Result>(dbName: string, callback: () => Result): Result;
|
|
20
18
|
//# sourceMappingURL=DatabaseQueue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseQueue.d.ts","sourceRoot":"","sources":["../../../src/DatabaseQueue.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAA;CAClB;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,eAAe,EAAE,CAAA;IACxB,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AAID,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,QAQ/C;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,QAUhD;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,WAE5C;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,QAKtD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,iBAK9C;AAED,wBAAgB,
|
|
1
|
+
{"version":3,"file":"DatabaseQueue.d.ts","sourceRoot":"","sources":["../../../src/DatabaseQueue.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAA;CAClB;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,eAAe,EAAE,CAAA;IACxB,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AAID,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,QAQ/C;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,QAUhD;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,WAE5C;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,QAKtD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,iBAK9C;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EACxC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,mBAwBhC;AAgBD,wBAAgB,kBAAkB,CAAC,MAAM,EACvC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,MAAM,GACrB,MAAM,CAiBR"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { QueryResult, QueryResultRow, SQLiteQueryParams } from '../types';
|
|
2
|
+
import type { NitroSQLiteQueryResult } from '../specs/NitroSQLiteQueryResult.nitro';
|
|
2
3
|
export declare function execute<Row extends QueryResultRow = never>(dbName: string, query: string, params?: SQLiteQueryParams): QueryResult<Row>;
|
|
4
|
+
export declare function executeManaged<Row extends QueryResultRow = never>(dbName: string, query: string, params?: SQLiteQueryParams): QueryResult<Row>;
|
|
5
|
+
export declare function executeNative<Row extends QueryResultRow = never>(dbName: string, query: string, params?: SQLiteQueryParams): QueryResult<Row>;
|
|
3
6
|
export declare function executeAsync<Row extends QueryResultRow = never>(dbName: string, query: string, params?: SQLiteQueryParams): Promise<QueryResult<Row>>;
|
|
7
|
+
export declare function executeAsyncManaged<Row extends QueryResultRow = never>(dbName: string, query: string, params?: SQLiteQueryParams): Promise<QueryResult<Row>>;
|
|
8
|
+
export declare function executeAsyncNative<Row extends QueryResultRow = never>(dbName: string, query: string, params?: SQLiteQueryParams): Promise<QueryResult<Row>>;
|
|
9
|
+
export declare function buildJSQueryResult<Row extends QueryResultRow = never>(result: NitroSQLiteQueryResult): QueryResult<Row>;
|
|
4
10
|
//# sourceMappingURL=execute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../../src/operations/execute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,E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,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAW3B;AAED,wBAAgB,kBAAkB,CAAC,GAAG,SAAS,cAAc,GAAG,KAAK,EACnE,MAAM,EAAE,sBAAsB,GAC7B,WAAW,CAAC,GAAG,CAAC,CAWlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/operations/session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,qBAAqB,EACrB,4BAA4B,EAK7B,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/operations/session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,qBAAqB,EACrB,4BAA4B,EAK7B,MAAM,UAAU,CAAA;AAYjB,wBAAgB,IAAI,CAClB,OAAO,EAAE,4BAA4B,GACpC,qBAAqB,CAwEvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NitroSQLite.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/NitroSQLite.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EAClB,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAE5E,MAAM,WAAW,WACf,SAAQ,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"NitroSQLite.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/NitroSQLite.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EA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,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;CACzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NitroSQLiteQueryResult.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/NitroSQLiteQueryResult.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEvD;;;;;;;;;GASG;AACH,MAAM,WAAW,sBACf,SAAQ,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"NitroSQLiteQueryResult.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/NitroSQLiteQueryResult.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEvD;;;;;;;;;GASG;AACH,MAAM,WAAW,sBACf,SAAQ,YAAY,CAAC;IACnB,GAAG,EAAE,KAAK,CAAA;IACV,OAAO,EAAE,KAAK,CAAA;CACf,CAAC;IACF,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAE1B,oBAAoB;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,CAAA;IAE/C,qBAAqB;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAA;CACnE;AASD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAA;IAEZ,uLAAuL;IACvL,IAAI,EAAE,UAAU,CAAA;IAEhB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAA;CACd,CAAA"}
|
|
@@ -28,9 +28,9 @@ int initialize(JavaVM* vm) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
struct JHybridNitroSQLiteOnLoadSpecImpl: public jni::JavaClass<JHybridNitroSQLiteOnLoadSpecImpl, JHybridNitroSQLiteOnLoadSpec::JavaPart> {
|
|
31
|
-
static auto
|
|
31
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/rnnitrosqlite/HybridNitroSQLiteOnLoad;";
|
|
32
32
|
static std::shared_ptr<JHybridNitroSQLiteOnLoadSpec> create() {
|
|
33
|
-
static auto constructorFn = javaClassStatic()->getConstructor<JHybridNitroSQLiteOnLoadSpecImpl::javaobject()>();
|
|
33
|
+
static const auto constructorFn = javaClassStatic()->getConstructor<JHybridNitroSQLiteOnLoadSpecImpl::javaobject()>();
|
|
34
34
|
jni::local_ref<JHybridNitroSQLiteOnLoadSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
|
|
35
35
|
return javaPart->getJHybridNitroSQLiteOnLoadSpec();
|
|
36
36
|
}
|
|
@@ -21,11 +21,11 @@ namespace margelo::nitro::rnnitrosqlite {
|
|
|
21
21
|
class JHybridNitroSQLiteOnLoadSpec: public virtual HybridNitroSQLiteOnLoadSpec, public virtual JHybridObject {
|
|
22
22
|
public:
|
|
23
23
|
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
-
static auto
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/rnnitrosqlite/HybridNitroSQLiteOnLoadSpec;";
|
|
25
25
|
std::shared_ptr<JHybridNitroSQLiteOnLoadSpec> getJHybridNitroSQLiteOnLoadSpec();
|
|
26
26
|
};
|
|
27
27
|
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
-
static auto
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/rnnitrosqlite/HybridNitroSQLiteOnLoadSpec$CxxPart;";
|
|
29
29
|
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
30
30
|
static void registerNatives();
|
|
31
31
|
using HybridBase::HybridBase;
|
|
@@ -10,6 +10,7 @@ package com.margelo.nitro.rnnitrosqlite
|
|
|
10
10
|
import androidx.annotation.Keep
|
|
11
11
|
import com.facebook.jni.HybridData
|
|
12
12
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import dalvik.annotation.optimization.FastNative
|
|
13
14
|
import com.margelo.nitro.core.HybridObject
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -42,6 +43,7 @@ abstract class HybridNitroSQLiteOnLoadSpec: HybridObject() {
|
|
|
42
43
|
@Keep
|
|
43
44
|
protected open class CxxPart(javaPart: HybridNitroSQLiteOnLoadSpec): HybridObject.CxxPart(javaPart) {
|
|
44
45
|
// C++ JHybridNitroSQLiteOnLoadSpec::CxxPart::initHybrid(...)
|
|
46
|
+
@FastNative
|
|
45
47
|
external override fun initHybrid(): HybridData
|
|
46
48
|
}
|
|
47
49
|
override fun createCxxPart(): CxxPart {
|
|
@@ -56,5 +56,7 @@ def add_nitrogen_files(spec)
|
|
|
56
56
|
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
|
|
57
57
|
# Enables stricter modular headers
|
|
58
58
|
"DEFINES_MODULE" => "YES",
|
|
59
|
+
# Disable auto-generated ObjC header for Swift (Static linkage on Xcode 26.4 breaks here)
|
|
60
|
+
"SWIFT_INSTALL_OBJC_HEADER" => "NO",
|
|
59
61
|
})
|
|
60
62
|
end
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-sqlite",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.8.0",
|
|
4
4
|
"description": "Fast SQLite library for React Native built using Nitro Modules",
|
|
5
5
|
"main": "./lib/module/index",
|
|
6
6
|
"module": "./lib/module/index",
|
|
@@ -69,23 +69,24 @@
|
|
|
69
69
|
"typeorm": "0.3.27"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
+
"@react-native/jest-preset": "0.87.1",
|
|
72
73
|
"jest": "^30.2.0",
|
|
73
|
-
"nitrogen": "0.
|
|
74
|
+
"nitrogen": "0.37.1",
|
|
74
75
|
"react": "19.2.3",
|
|
75
|
-
"react-native": "0.
|
|
76
|
+
"react-native": "0.87.1",
|
|
76
77
|
"react-native-builder-bob": "^0.31.0",
|
|
77
|
-
"react-native-nitro-modules": "0.
|
|
78
|
+
"react-native-nitro-modules": "0.37.1"
|
|
78
79
|
},
|
|
79
80
|
"peerDependencies": {
|
|
80
81
|
"react": ">=17.0.0",
|
|
81
82
|
"react-native": ">=0.75.0",
|
|
82
|
-
"react-native-nitro-modules": ">=0.
|
|
83
|
+
"react-native-nitro-modules": ">=0.37.1"
|
|
83
84
|
},
|
|
84
85
|
"resolutions": {
|
|
85
86
|
"@types/react": "^18.2.44"
|
|
86
87
|
},
|
|
87
88
|
"jest": {
|
|
88
|
-
"preset": "react-native",
|
|
89
|
+
"preset": "@react-native/jest-preset",
|
|
89
90
|
"modulePathIgnorePatterns": [
|
|
90
91
|
"<rootDir>/example/node_modules",
|
|
91
92
|
"<rootDir>/lib/"
|
|
@@ -94,6 +95,7 @@
|
|
|
94
95
|
"release-it": {
|
|
95
96
|
"npm": {
|
|
96
97
|
"publish": true,
|
|
98
|
+
"skipChecks": true,
|
|
97
99
|
"versionArgs": [
|
|
98
100
|
"--allow-same-version"
|
|
99
101
|
]
|
|
@@ -126,7 +128,7 @@
|
|
|
126
128
|
[
|
|
127
129
|
"typescript",
|
|
128
130
|
{
|
|
129
|
-
"tsc": "
|
|
131
|
+
"tsc": "../../node_modules/.bin/tsc",
|
|
130
132
|
"project": "tsconfig.build.json",
|
|
131
133
|
"esm": true
|
|
132
134
|
}
|
package/src/DatabaseQueue.ts
CHANGED
|
@@ -28,8 +28,8 @@ export function closeDatabaseQueue(dbName: string) {
|
|
|
28
28
|
const databaseQueue = getDatabaseQueue(dbName)
|
|
29
29
|
|
|
30
30
|
if (databaseQueue.inProgress || databaseQueue.queue.length > 0) {
|
|
31
|
-
|
|
32
|
-
`
|
|
31
|
+
throw new NitroSQLiteError(
|
|
32
|
+
`Cannot close database ${dbName}. The database is busy with another operation.`,
|
|
33
33
|
)
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -54,14 +54,6 @@ export function getDatabaseQueue(dbName: string) {
|
|
|
54
54
|
return queue
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
export function openDatabase(dbName: string) {
|
|
58
|
-
databaseQueues.set(dbName, { queue: [], inProgress: false })
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function closeDatabase(dbName: string) {
|
|
62
|
-
databaseQueues.delete(dbName)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
57
|
export function queueOperationAsync<Result>(
|
|
66
58
|
dbName: string,
|
|
67
59
|
callback: () => Promise<Result>,
|
|
@@ -77,7 +69,7 @@ export function queueOperationAsync<Result>(
|
|
|
77
69
|
reject(error)
|
|
78
70
|
} finally {
|
|
79
71
|
databaseQueue.inProgress = false
|
|
80
|
-
startOperationAsync(
|
|
72
|
+
startOperationAsync(databaseQueue)
|
|
81
73
|
}
|
|
82
74
|
}
|
|
83
75
|
|
|
@@ -86,13 +78,11 @@ export function queueOperationAsync<Result>(
|
|
|
86
78
|
}
|
|
87
79
|
|
|
88
80
|
databaseQueue.queue.push(operation)
|
|
89
|
-
startOperationAsync(
|
|
81
|
+
startOperationAsync(databaseQueue)
|
|
90
82
|
})
|
|
91
83
|
}
|
|
92
84
|
|
|
93
|
-
function startOperationAsync(
|
|
94
|
-
const queue = getDatabaseQueue(dbName)
|
|
95
|
-
|
|
85
|
+
function startOperationAsync(queue: DatabaseQueue) {
|
|
96
86
|
// Queue is empty or in progress. Bail out.
|
|
97
87
|
if (queue.inProgress || queue.queue.length === 0) {
|
|
98
88
|
return
|
|
@@ -106,10 +96,10 @@ function startOperationAsync(dbName: string) {
|
|
|
106
96
|
})
|
|
107
97
|
}
|
|
108
98
|
|
|
109
|
-
export function startOperationSync<
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
99
|
+
export function startOperationSync<Result>(
|
|
100
|
+
dbName: string,
|
|
101
|
+
callback: () => Result,
|
|
102
|
+
): Result {
|
|
113
103
|
const databaseQueue = getDatabaseQueue(dbName)
|
|
114
104
|
|
|
115
105
|
// Database is busy - cannot execute synchronously
|
|
@@ -2,11 +2,36 @@ import { HybridNitroSQLite } from '../nitro'
|
|
|
2
2
|
import type { QueryResult, QueryResultRow, SQLiteQueryParams } from '../types'
|
|
3
3
|
import NitroSQLiteError from '../NitroSQLiteError'
|
|
4
4
|
import type { NitroSQLiteQueryResult } from '../specs/NitroSQLiteQueryResult.nitro'
|
|
5
|
+
import {
|
|
6
|
+
isDatabaseOpen,
|
|
7
|
+
queueOperationAsync,
|
|
8
|
+
startOperationSync,
|
|
9
|
+
} from '../DatabaseQueue'
|
|
5
10
|
|
|
6
11
|
export function execute<Row extends QueryResultRow = never>(
|
|
7
12
|
dbName: string,
|
|
8
13
|
query: string,
|
|
9
14
|
params?: SQLiteQueryParams,
|
|
15
|
+
): QueryResult<Row> {
|
|
16
|
+
if (!isDatabaseOpen(dbName)) {
|
|
17
|
+
return executeNative(dbName, query, params)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return executeManaged(dbName, query, params)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function executeManaged<Row extends QueryResultRow = never>(
|
|
24
|
+
dbName: string,
|
|
25
|
+
query: string,
|
|
26
|
+
params?: SQLiteQueryParams,
|
|
27
|
+
): QueryResult<Row> {
|
|
28
|
+
return startOperationSync(dbName, () => executeNative(dbName, query, params))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function executeNative<Row extends QueryResultRow = never>(
|
|
32
|
+
dbName: string,
|
|
33
|
+
query: string,
|
|
34
|
+
params?: SQLiteQueryParams,
|
|
10
35
|
): QueryResult<Row> {
|
|
11
36
|
try {
|
|
12
37
|
const nativeResult = HybridNitroSQLite.execute(dbName, query, params)
|
|
@@ -20,6 +45,28 @@ export async function executeAsync<Row extends QueryResultRow = never>(
|
|
|
20
45
|
dbName: string,
|
|
21
46
|
query: string,
|
|
22
47
|
params?: SQLiteQueryParams,
|
|
48
|
+
): Promise<QueryResult<Row>> {
|
|
49
|
+
if (!isDatabaseOpen(dbName)) {
|
|
50
|
+
return executeAsyncNative(dbName, query, params)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return executeAsyncManaged(dbName, query, params)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function executeAsyncManaged<Row extends QueryResultRow = never>(
|
|
57
|
+
dbName: string,
|
|
58
|
+
query: string,
|
|
59
|
+
params?: SQLiteQueryParams,
|
|
60
|
+
): Promise<QueryResult<Row>> {
|
|
61
|
+
return queueOperationAsync(dbName, () =>
|
|
62
|
+
executeAsyncNative(dbName, query, params),
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export async function executeAsyncNative<Row extends QueryResultRow = never>(
|
|
67
|
+
dbName: string,
|
|
68
|
+
query: string,
|
|
69
|
+
params?: SQLiteQueryParams,
|
|
23
70
|
): Promise<QueryResult<Row>> {
|
|
24
71
|
try {
|
|
25
72
|
const nativeResult = await HybridNitroSQLite.executeAsync(
|
|
@@ -33,24 +80,17 @@ export async function executeAsync<Row extends QueryResultRow = never>(
|
|
|
33
80
|
}
|
|
34
81
|
}
|
|
35
82
|
|
|
36
|
-
function buildJSQueryResult<Row extends QueryResultRow = never>(
|
|
83
|
+
export function buildJSQueryResult<Row extends QueryResultRow = never>(
|
|
37
84
|
result: NitroSQLiteQueryResult,
|
|
38
85
|
): QueryResult<Row> {
|
|
39
86
|
const resultWithRows = result as QueryResult<Row>
|
|
87
|
+
const results = result.results as Row[]
|
|
40
88
|
|
|
41
89
|
resultWithRows.rows = {
|
|
42
|
-
_array:
|
|
43
|
-
length:
|
|
44
|
-
item: (idx: number) =>
|
|
90
|
+
_array: results,
|
|
91
|
+
length: results.length,
|
|
92
|
+
item: (idx: number) => results[idx],
|
|
45
93
|
}
|
|
46
94
|
|
|
47
95
|
return resultWithRows
|
|
48
|
-
|
|
49
|
-
// return Object.assign(result, {
|
|
50
|
-
// rows: {
|
|
51
|
-
// _array: result.results,
|
|
52
|
-
// length: result.results.length,
|
|
53
|
-
// item: (idx: number) => result.results[idx],
|
|
54
|
-
// },
|
|
55
|
-
// })
|
|
56
96
|
}
|
|
@@ -9,51 +9,97 @@ import type {
|
|
|
9
9
|
QueryResultRow,
|
|
10
10
|
QueryResult,
|
|
11
11
|
} from '../types'
|
|
12
|
-
import {
|
|
12
|
+
import { executeAsyncManaged, executeManaged } from './execute'
|
|
13
13
|
import { executeBatch, executeBatchAsync } from './executeBatch'
|
|
14
14
|
import NitroSQLiteError from '../NitroSQLiteError'
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
closeDatabaseQueue,
|
|
17
|
+
isDatabaseOpen,
|
|
18
|
+
openDatabaseQueue,
|
|
19
|
+
queueOperationAsync,
|
|
20
|
+
startOperationSync,
|
|
21
|
+
} from '../DatabaseQueue'
|
|
16
22
|
|
|
17
23
|
export function open(
|
|
18
24
|
options: NitroSQLiteConnectionOptions,
|
|
19
25
|
): NitroSQLiteConnection {
|
|
26
|
+
openDatabaseQueue(options.name)
|
|
27
|
+
|
|
20
28
|
try {
|
|
21
29
|
HybridNitroSQLite.open(options.name, options.location)
|
|
22
|
-
openDatabaseQueue(options.name)
|
|
23
30
|
} catch (error) {
|
|
31
|
+
closeDatabaseQueue(options.name)
|
|
24
32
|
throw NitroSQLiteError.fromError(error)
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
return {
|
|
28
36
|
close: () => {
|
|
29
37
|
try {
|
|
30
|
-
|
|
38
|
+
startOperationSync(options.name, () =>
|
|
39
|
+
HybridNitroSQLite.close(options.name),
|
|
40
|
+
)
|
|
41
|
+
closeDatabaseQueue(options.name)
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw NitroSQLiteError.fromError(error)
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
delete: () => {
|
|
47
|
+
try {
|
|
48
|
+
if (!isDatabaseOpen(options.name)) {
|
|
49
|
+
HybridNitroSQLite.drop(options.name, options.location)
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
startOperationSync(options.name, () =>
|
|
54
|
+
HybridNitroSQLite.drop(options.name, options.location),
|
|
55
|
+
)
|
|
31
56
|
closeDatabaseQueue(options.name)
|
|
32
57
|
} catch (error) {
|
|
33
58
|
throw NitroSQLiteError.fromError(error)
|
|
34
59
|
}
|
|
35
60
|
},
|
|
36
|
-
delete: () => HybridNitroSQLite.drop(options.name, options.location),
|
|
37
61
|
attach: (dbNameToAttach: string, alias: string, location?: string) =>
|
|
38
|
-
|
|
39
|
-
|
|
62
|
+
runSyncOperation(options.name, () =>
|
|
63
|
+
HybridNitroSQLite.attach(options.name, dbNameToAttach, alias, location),
|
|
64
|
+
),
|
|
65
|
+
detach: (alias: string) =>
|
|
66
|
+
runSyncOperation(options.name, () =>
|
|
67
|
+
HybridNitroSQLite.detach(options.name, alias),
|
|
68
|
+
),
|
|
40
69
|
transaction: <Result = void>(fn: (tx: Transaction) => Promise<Result>) =>
|
|
41
70
|
transaction(options.name, fn),
|
|
42
71
|
execute: <Row extends QueryResultRow = never>(
|
|
43
72
|
query: string,
|
|
44
73
|
params?: SQLiteQueryParams,
|
|
45
|
-
): QueryResult<Row> =>
|
|
74
|
+
): QueryResult<Row> => executeManaged(options.name, query, params),
|
|
46
75
|
executeAsync: <Row extends QueryResultRow = never>(
|
|
47
76
|
query: string,
|
|
48
77
|
params?: SQLiteQueryParams,
|
|
49
|
-
): Promise<QueryResult<Row>> =>
|
|
78
|
+
): Promise<QueryResult<Row>> =>
|
|
79
|
+
executeAsyncManaged(options.name, query, params),
|
|
50
80
|
executeBatch: (commands: BatchQueryCommand[]) =>
|
|
51
81
|
executeBatch(options.name, commands),
|
|
52
82
|
executeBatchAsync: (commands: BatchQueryCommand[]) =>
|
|
53
83
|
executeBatchAsync(options.name, commands),
|
|
54
84
|
loadFile: (location: string) =>
|
|
55
|
-
|
|
85
|
+
runSyncOperation(options.name, () =>
|
|
86
|
+
HybridNitroSQLite.loadFile(options.name, location),
|
|
87
|
+
),
|
|
56
88
|
loadFileAsync: (location: string) =>
|
|
57
|
-
|
|
89
|
+
queueOperationAsync(options.name, async () => {
|
|
90
|
+
try {
|
|
91
|
+
return await HybridNitroSQLite.loadFileAsync(options.name, location)
|
|
92
|
+
} catch (error) {
|
|
93
|
+
throw NitroSQLiteError.fromError(error)
|
|
94
|
+
}
|
|
95
|
+
}),
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function runSyncOperation<Result>(dbName: string, callback: () => Result) {
|
|
100
|
+
try {
|
|
101
|
+
return startOperationSync(dbName, callback)
|
|
102
|
+
} catch (error) {
|
|
103
|
+
throw NitroSQLiteError.fromError(error)
|
|
58
104
|
}
|
|
59
105
|
}
|
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
QueryResult,
|
|
6
6
|
QueryResultRow,
|
|
7
7
|
} from '../types'
|
|
8
|
-
import {
|
|
8
|
+
import { executeAsyncNative, executeNative } from './execute'
|
|
9
9
|
import NitroSQLiteError from '../NitroSQLiteError'
|
|
10
10
|
|
|
11
11
|
export const transaction = async <Result = void>(
|
|
@@ -26,7 +26,7 @@ export const transaction = async <Result = void>(
|
|
|
26
26
|
`Cannot execute query on finalized transaction: ${dbName}`,
|
|
27
27
|
)
|
|
28
28
|
}
|
|
29
|
-
return
|
|
29
|
+
return executeNative(dbName, query, params)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
const executeAsyncOnTransaction = <Row extends QueryResultRow = never>(
|
|
@@ -38,7 +38,7 @@ export const transaction = async <Result = void>(
|
|
|
38
38
|
`Cannot execute query on finalized transaction: ${dbName}`,
|
|
39
39
|
)
|
|
40
40
|
}
|
|
41
|
-
return
|
|
41
|
+
return executeAsyncNative(dbName, query, params)
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const commit = () => {
|
|
@@ -48,7 +48,7 @@ export const transaction = async <Result = void>(
|
|
|
48
48
|
)
|
|
49
49
|
}
|
|
50
50
|
isFinished = true
|
|
51
|
-
return
|
|
51
|
+
return executeNative(dbName, 'COMMIT')
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
const rollback = () => {
|
|
@@ -58,12 +58,12 @@ export const transaction = async <Result = void>(
|
|
|
58
58
|
)
|
|
59
59
|
}
|
|
60
60
|
isFinished = true
|
|
61
|
-
return
|
|
61
|
+
return executeNative(dbName, 'ROLLBACK')
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
return await queueOperationAsync(dbName, async () => {
|
|
65
65
|
try {
|
|
66
|
-
await
|
|
66
|
+
await executeAsyncNative(
|
|
67
67
|
dbName,
|
|
68
68
|
isExclusive ? 'BEGIN EXCLUSIVE TRANSACTION' : 'BEGIN TRANSACTION',
|
|
69
69
|
)
|
|
@@ -8,7 +8,10 @@ import type {
|
|
|
8
8
|
import type { NitroSQLiteQueryResult } from './NitroSQLiteQueryResult.nitro'
|
|
9
9
|
|
|
10
10
|
export interface NitroSQLite
|
|
11
|
-
extends HybridObject<{
|
|
11
|
+
extends HybridObject<{
|
|
12
|
+
ios: 'c++'
|
|
13
|
+
android: 'c++'
|
|
14
|
+
}> {
|
|
12
15
|
open(dbName: string, location?: string): void
|
|
13
16
|
close(dbName: string): void
|
|
14
17
|
drop(dbName: string, location?: string): void
|
|
@@ -12,7 +12,10 @@ import type { ColumnType, SQLiteValue } from '../types'
|
|
|
12
12
|
* @interface QueryResult
|
|
13
13
|
*/
|
|
14
14
|
export interface NitroSQLiteQueryResult
|
|
15
|
-
extends HybridObject<{
|
|
15
|
+
extends HybridObject<{
|
|
16
|
+
ios: 'c++'
|
|
17
|
+
android: 'c++'
|
|
18
|
+
}> {
|
|
16
19
|
readonly rowsAffected: number
|
|
17
20
|
readonly insertId?: number
|
|
18
21
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|