From 5c6058af93453628f31bd4c4da53936dcf16ee9f Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Fri, 28 Nov 2025 16:05:22 +0100 Subject: [PATCH 1/4] Fixes invalidated module not resolving promises --- cpp/OPSqlite.cpp | 1 + example/babel.config.js | 1 - example/globals.d.ts | 1 - example/ios/OPSQLiteExample/Info.plist | 4 +- example/ios/Podfile.lock | 2 +- example/package.json | 1 - example/src/App.tsx | 12 +- example/src/globals.d.ts | 1 - example/src/tests/dbsetup.ts | 24 +++- package.json | 5 +- yarn.lock | 170 ++----------------------- 11 files changed, 38 insertions(+), 184 deletions(-) delete mode 100644 example/globals.d.ts delete mode 100644 example/src/globals.d.ts diff --git a/cpp/OPSqlite.cpp b/cpp/OPSqlite.cpp index 33a86978..e9455c18 100644 --- a/cpp/OPSqlite.cpp +++ b/cpp/OPSqlite.cpp @@ -51,6 +51,7 @@ void install(jsi::Runtime &rt, _crsqlite_path = std::string(crsqlite_path); _sqlite_vec_path = std::string(sqlite_vec_path); opsqlite::invoker = invoker; + opsqlite::invalidated = false; auto open = HFN0 { jsi::Object options = args[0].asObject(rt); diff --git a/example/babel.config.js b/example/babel.config.js index ae100ac4..2529f96d 100644 --- a/example/babel.config.js +++ b/example/babel.config.js @@ -7,7 +7,6 @@ const root = path.resolve(__dirname, '..'); module.exports = getConfig( { presets: ['module:@react-native/babel-preset'], - plugins: ['nativewind/babel'], }, {root, pkg}, ); diff --git a/example/globals.d.ts b/example/globals.d.ts deleted file mode 100644 index a13e3136..00000000 --- a/example/globals.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/example/ios/OPSQLiteExample/Info.plist b/example/ios/OPSQLiteExample/Info.plist index bce5a746..ac8aad13 100644 --- a/example/ios/OPSQLiteExample/Info.plist +++ b/example/ios/OPSQLiteExample/Info.plist @@ -2,7 +2,7 @@ - CADisableMinimumFrameDurationOnPhone + CADisableMinimumFrameDurationOnPhone CFBundleDevelopmentRegion en @@ -34,7 +34,7 @@ NSLocationWhenInUseUsageDescription - + Location is needed RCTNewArchEnabled UILaunchStoryboardName diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index a8e92492..1f4bc5b1 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -2027,7 +2027,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: FBLazyVector: 2e5b5553df729e080483373db6f045201ff4e6db hermes-engine: 273e30e7fb618279934b0b95ffab60ecedb7acf5 - op-sqlite: 7e1d781318b8f936bd7afe0773cf0d2e0b81780b + op-sqlite: dab20bf7d412623996a2247014d04a8cbb1ccb0a OpServer: 63fc523290a5c7c6f98dc7ba5e76cc720d798259 RCTDeprecation: c6b36da89aa26090c8684d29c2868dcca2cd4554 RCTRequired: 1413a0844770d00fa1f1bb2da4680adfa8698065 diff --git a/example/package.json b/example/package.json index a1b89765..cf3d0fde 100644 --- a/example/package.json +++ b/example/package.json @@ -20,7 +20,6 @@ "chance": "^1.1.9", "clsx": "^2.0.0", "events": "^3.3.0", - "nativewind": "^2.0.11", "react": "19.1.1", "react-native": "0.82.1", "react-native-safe-area-context": "^5.6.2" diff --git a/example/src/App.tsx b/example/src/App.tsx index b4cc550b..5a0ca003 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -10,7 +10,7 @@ import { allTestsPassed, } from '@op-engineering/op-test'; import './tests'; // import all tests to register them -import {SafeAreaView} from 'react-native-safe-area-context'; +import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context'; import {StyleSheet} from 'react-native'; export default function App() { @@ -54,15 +54,17 @@ export default function App() { // }; return ( - - {displayResults(results)} - + + + {displayResults(results)} + + ); } const STYLES = StyleSheet.create({ container: { - height: '100%', + flex: 1, backgroundColor: '#333', }, }); diff --git a/example/src/globals.d.ts b/example/src/globals.d.ts deleted file mode 100644 index a13e3136..00000000 --- a/example/src/globals.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/example/src/tests/dbsetup.ts b/example/src/tests/dbsetup.ts index 91f69c70..f12088e6 100644 --- a/example/src/tests/dbsetup.ts +++ b/example/src/tests/dbsetup.ts @@ -270,12 +270,12 @@ it('Can get db path', () => { db.close(); }); -if(isLibsql()) { - it("Libsql can set reserved bytes", async () => { - const db = open({ name: "test.db" }); - db.setReservedBytes(28); - expect(db.getReservedBytes()).toEqual(28); - db.delete() +if (isLibsql()) { + it('Libsql can set reserved bytes', async () => { + const db = open({name: 'test.db'}); + db.setReservedBytes(28); + expect(db.getReservedBytes()).toEqual(28); + db.delete(); }); } @@ -288,3 +288,15 @@ if (isSQLCipher()) { db.close(); }); } + +// This test wasn't really failing, but the module was not being properly +// invalidated/re-created on a hot reload +// Check opsqlite::invalidated +// itOnly('Can execute async pragma', async () => { +// const db = open({ +// name: 'pragma.sqlite', +// }); + +// const result = await db.execute('select sqlite_version() as version'); +// expect(result).toBe('1.52'); +// }); diff --git a/package.json b/package.json index 19d39962..88ed753c 100644 --- a/package.json +++ b/package.json @@ -109,8 +109,5 @@ "type": "turbo-module", "version": "0.52.1" }, - "packageManager": "yarn@4.11.0", - "dependencies": { - "react-native-safe-area-context": "^5.6.2" - } + "packageManager": "yarn@4.11.0" } diff --git a/yarn.lock b/yarn.lock index 3b7f3e82..b34aa71c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -69,7 +69,7 @@ __metadata: languageName: node linkType: hard -"@babel/generator@npm:^7.18.7, @babel/generator@npm:^7.25.0, @babel/generator@npm:^7.28.5": +"@babel/generator@npm:^7.25.0, @babel/generator@npm:^7.28.5": version: 7.28.5 resolution: "@babel/generator@npm:7.28.5" dependencies: @@ -166,15 +166,6 @@ __metadata: languageName: node linkType: hard -"@babel/helper-module-imports@npm:7.18.6": - version: 7.18.6 - resolution: "@babel/helper-module-imports@npm:7.18.6" - dependencies: - "@babel/types": "npm:^7.18.6" - checksum: 10c0/a92e28fc4b5dbb0d0afd4a313efc0cf5b26ce1adc0c01fc22724c997789ac7d7f4f30bc9143d94a6ba8b0a035933cf63a727a365ce1c57dbca0935f48de96244 - languageName: node - linkType: hard - "@babel/helper-module-imports@npm:^7.27.1": version: 7.27.1 resolution: "@babel/helper-module-imports@npm:7.27.1" @@ -250,14 +241,14 @@ __metadata: languageName: node linkType: hard -"@babel/helper-string-parser@npm:^7.18.10, @babel/helper-string-parser@npm:^7.27.1": +"@babel/helper-string-parser@npm:^7.27.1": version: 7.27.1 resolution: "@babel/helper-string-parser@npm:7.27.1" checksum: 10c0/8bda3448e07b5583727c103560bcf9c4c24b3c1051a4c516d4050ef69df37bb9a4734a585fe12725b8c2763de0a265aa1e909b485a4e3270b7cfd3e4dbe4b602 languageName: node linkType: hard -"@babel/helper-validator-identifier@npm:^7.18.6, @babel/helper-validator-identifier@npm:^7.27.1, @babel/helper-validator-identifier@npm:^7.28.5": +"@babel/helper-validator-identifier@npm:^7.27.1, @babel/helper-validator-identifier@npm:^7.28.5": version: 7.28.5 resolution: "@babel/helper-validator-identifier@npm:7.28.5" checksum: 10c0/42aaebed91f739a41f3d80b72752d1f95fd7c72394e8e4bd7cdd88817e0774d80a432451bcba17c2c642c257c483bf1d409dd4548883429ea9493a3bc4ab0847 @@ -1508,18 +1499,7 @@ __metadata: languageName: node linkType: hard -"@babel/types@npm:7.19.0": - version: 7.19.0 - resolution: "@babel/types@npm:7.19.0" - dependencies: - "@babel/helper-string-parser": "npm:^7.18.10" - "@babel/helper-validator-identifier": "npm:^7.18.6" - to-fast-properties: "npm:^2.0.0" - checksum: 10c0/36b9360aa2d29fe515963b7c7014de3d66eb8c17315d00c65d82ab46b44482d5ba898aa3b5bc84887e6304b5456f2dbfe46e21851ca514f98106d8d47fbc3a0f - languageName: node - linkType: hard - -"@babel/types@npm:^7.0.0, @babel/types@npm:^7.18.6, @babel/types@npm:^7.20.7, @babel/types@npm:^7.25.2, @babel/types@npm:^7.27.1, @babel/types@npm:^7.27.3, @babel/types@npm:^7.28.2, @babel/types@npm:^7.28.4, @babel/types@npm:^7.28.5, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4": +"@babel/types@npm:^7.0.0, @babel/types@npm:^7.20.7, @babel/types@npm:^7.25.2, @babel/types@npm:^7.27.1, @babel/types@npm:^7.27.3, @babel/types@npm:^7.28.2, @babel/types@npm:^7.28.4, @babel/types@npm:^7.28.5, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4": version: 7.28.5 resolution: "@babel/types@npm:7.28.5" dependencies: @@ -1812,7 +1792,6 @@ __metadata: react: "npm:19.1.1" react-native: "npm:0.82.1" react-native-builder-bob: "npm:^0.40.15" - react-native-safe-area-context: "npm:^5.6.2" typescript: "npm:5.0.4" peerDependencies: react: "*" @@ -3065,13 +3044,6 @@ __metadata: languageName: node linkType: hard -"camelize@npm:^1.0.0": - version: 1.0.1 - resolution: "camelize@npm:1.0.1" - checksum: 10c0/4c9ac55efd356d37ac483bad3093758236ab686192751d1c9daa43188cc5a07b09bd431eb7458a4efd9ca22424bba23253e7b353feb35d7c749ba040de2385fb - languageName: node - linkType: hard - "caniuse-lite@npm:^1.0.30001754": version: 1.0.30001756 resolution: "caniuse-lite@npm:1.0.30001756" @@ -3406,31 +3378,6 @@ __metadata: languageName: node linkType: hard -"css-color-keywords@npm:^1.0.0": - version: 1.0.0 - resolution: "css-color-keywords@npm:1.0.0" - checksum: 10c0/af205a86c68e0051846ed91eb3e30b4517e1904aac040013ff1d742019b3f9369ba5658ba40901dbbc121186fc4bf0e75a814321cc3e3182fbb2feb81c6d9cb7 - languageName: node - linkType: hard - -"css-mediaquery@npm:^0.1.2": - version: 0.1.2 - resolution: "css-mediaquery@npm:0.1.2" - checksum: 10c0/b7825a78f52ce8a8198e004fcad0d7be1d3c9a0463ecd05ba31a0f2c94fb81468ad6f4d7bf715a6ca775696e7a17500c2a339b5216a6d0f789cbf78f9454d048 - languageName: node - linkType: hard - -"css-to-react-native@npm:^3.0.0": - version: 3.2.0 - resolution: "css-to-react-native@npm:3.2.0" - dependencies: - camelize: "npm:^1.0.0" - css-color-keywords: "npm:^1.0.0" - postcss-value-parser: "npm:^4.0.2" - checksum: 10c0/fde850a511d5d3d7c55a1e9b8ed26b69a8ad4868b3487e36ebfbfc0b96fc34bc977d9cd1d61a289d0c74d3f9a662d8cee297da53d4433bf2e27d6acdff8e1003 - languageName: node - linkType: hard - "cssesc@npm:^3.0.0": version: 3.0.0 resolution: "cssesc@npm:3.0.0" @@ -3710,13 +3657,6 @@ __metadata: languageName: node linkType: hard -"escape-string-regexp@npm:^1.0.3": - version: 1.0.5 - resolution: "escape-string-regexp@npm:1.0.5" - checksum: 10c0/a968ad453dd0c2724e14a4f20e177aaf32bb384ab41b674a8454afe9a41c5e6fe8903323e0a1052f56289d04bd600f81278edf140b0fcc02f5cac98d0f5b5371 - languageName: node - linkType: hard - "escape-string-regexp@npm:^2.0.0": version: 2.0.0 resolution: "escape-string-regexp@npm:2.0.0" @@ -3817,13 +3757,6 @@ __metadata: languageName: node linkType: hard -"extend@npm:^3.0.1": - version: 3.0.2 - resolution: "extend@npm:3.0.2" - checksum: 10c0/73bf6e27406e80aa3e85b0d1c4fd987261e628064e170ca781125c0b635a3dabad5e05adbf07595ea0cf1e6c5396cacb214af933da7cbaf24fe75ff14818e8f9 - languageName: node - linkType: hard - "fast-glob@npm:^3.2.12, fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.2, fast-glob@npm:^3.3.3": version: 3.3.3 resolution: "fast-glob@npm:3.3.3" @@ -5473,29 +5406,6 @@ __metadata: languageName: node linkType: hard -"nativewind@npm:^2.0.11": - version: 2.0.11 - resolution: "nativewind@npm:2.0.11" - dependencies: - "@babel/generator": "npm:^7.18.7" - "@babel/helper-module-imports": "npm:7.18.6" - "@babel/types": "npm:7.19.0" - css-mediaquery: "npm:^0.1.2" - css-to-react-native: "npm:^3.0.0" - micromatch: "npm:^4.0.5" - postcss: "npm:^8.4.12" - postcss-calc: "npm:^8.2.4" - postcss-color-functional-notation: "npm:^4.2.2" - postcss-css-variables: "npm:^0.18.0" - postcss-nested: "npm:^5.0.6" - react-is: "npm:^18.1.0" - use-sync-external-store: "npm:^1.1.0" - peerDependencies: - tailwindcss: ~3 - checksum: 10c0/8db00c208b88e61ae954df8ce466bc1f1e22ccf16380c9fe0e1f29f84aa177261ab466e52e047770680e3664620f1c7c0b170ad1c262eaf1c30f6ee1234bc584 - languageName: node - linkType: hard - "negotiator@npm:0.6.3": version: 0.6.3 resolution: "negotiator@npm:0.6.3" @@ -5692,7 +5602,6 @@ __metadata: chance: "npm:^1.1.9" clsx: "npm:^2.0.0" events: "npm:^3.3.0" - nativewind: "npm:^2.0.11" react: "npm:19.1.1" react-native: "npm:0.82.1" react-native-builder-bob: "npm:^0.40.13" @@ -5906,42 +5815,6 @@ __metadata: languageName: node linkType: hard -"postcss-calc@npm:^8.2.4": - version: 8.2.4 - resolution: "postcss-calc@npm:8.2.4" - dependencies: - postcss-selector-parser: "npm:^6.0.9" - postcss-value-parser: "npm:^4.2.0" - peerDependencies: - postcss: ^8.2.2 - checksum: 10c0/8518a429488c3283ff1560c83a511f6f772329bc61d88875eb7c83e13a8683b7ccbdccaa9946024cf1553da3eacd2f40fcbcebf1095f7fdeb432bf86bc6ba6ba - languageName: node - linkType: hard - -"postcss-color-functional-notation@npm:^4.2.2": - version: 4.2.4 - resolution: "postcss-color-functional-notation@npm:4.2.4" - dependencies: - postcss-value-parser: "npm:^4.2.0" - peerDependencies: - postcss: ^8.2 - checksum: 10c0/e80785d10d252512f290c9d5e9436d8ea9e986a4a3f7ccb57ca9a5c2cd7fbff2498287d907c0e887dc6f69de66f6321ba40ebb8dbb7f47dace2050786b04c55e - languageName: node - linkType: hard - -"postcss-css-variables@npm:^0.18.0": - version: 0.18.0 - resolution: "postcss-css-variables@npm:0.18.0" - dependencies: - balanced-match: "npm:^1.0.0" - escape-string-regexp: "npm:^1.0.3" - extend: "npm:^3.0.1" - peerDependencies: - postcss: ^8.2.6 - checksum: 10c0/be3e6a752b852c20fdf7e76beb46b943da79b3c647a08df2b58e946ec1e52e229ac58646611e6cc746028dc949ca02ecb0772f5755743af5dfb5917c59cf7380 - languageName: node - linkType: hard - "postcss-import@npm:^15.1.0": version: 15.1.0 resolution: "postcss-import@npm:15.1.0" @@ -5984,17 +5857,6 @@ __metadata: languageName: node linkType: hard -"postcss-nested@npm:^5.0.6": - version: 5.0.6 - resolution: "postcss-nested@npm:5.0.6" - dependencies: - postcss-selector-parser: "npm:^6.0.6" - peerDependencies: - postcss: ^8.2.14 - checksum: 10c0/cff4f05b06ec752a90a36b329b4c1b620352458b3d8e02e2fc7efdfb5073945242573ec42c0dd2b7c4beccba21233e5f089903c3e5e8aea2bbceca09c406fb8f - languageName: node - linkType: hard - "postcss-nested@npm:^6.0.1": version: 6.2.0 resolution: "postcss-nested@npm:6.2.0" @@ -6006,7 +5868,7 @@ __metadata: languageName: node linkType: hard -"postcss-selector-parser@npm:^6.0.11, postcss-selector-parser@npm:^6.0.6, postcss-selector-parser@npm:^6.0.9, postcss-selector-parser@npm:^6.1.1": +"postcss-selector-parser@npm:^6.0.11, postcss-selector-parser@npm:^6.1.1": version: 6.1.2 resolution: "postcss-selector-parser@npm:6.1.2" dependencies: @@ -6016,14 +5878,14 @@ __metadata: languageName: node linkType: hard -"postcss-value-parser@npm:^4.0.0, postcss-value-parser@npm:^4.0.2, postcss-value-parser@npm:^4.2.0": +"postcss-value-parser@npm:^4.0.0, postcss-value-parser@npm:^4.2.0": version: 4.2.0 resolution: "postcss-value-parser@npm:4.2.0" checksum: 10c0/f4142a4f56565f77c1831168e04e3effd9ffcc5aebaf0f538eee4b2d465adfd4b85a44257bb48418202a63806a7da7fe9f56c330aebb3cac898e46b4cbf49161 languageName: node linkType: hard -"postcss@npm:^8.4.12, postcss@npm:^8.4.23": +"postcss@npm:^8.4.23": version: 8.5.6 resolution: "postcss@npm:8.5.6" dependencies: @@ -6164,7 +6026,7 @@ __metadata: languageName: node linkType: hard -"react-is@npm:^18.0.0, react-is@npm:^18.1.0": +"react-is@npm:^18.0.0": version: 18.3.1 resolution: "react-is@npm:18.3.1" checksum: 10c0/f2f1e60010c683479e74c63f96b09fb41603527cd131a9959e2aee1e5a8b0caf270b365e5ca77d4a6b18aae659b60a86150bb3979073528877029b35aecd2072 @@ -6999,13 +6861,6 @@ __metadata: languageName: node linkType: hard -"to-fast-properties@npm:^2.0.0": - version: 2.0.0 - resolution: "to-fast-properties@npm:2.0.0" - checksum: 10c0/b214d21dbfb4bce3452b6244b336806ffea9c05297148d32ebb428d5c43ce7545bdfc65a1ceb58c9ef4376a65c0cb2854d645f33961658b3e3b4f84910ddcdd7 - languageName: node - linkType: hard - "to-regex-range@npm:^5.0.1": version: 5.0.1 resolution: "to-regex-range@npm:5.0.1" @@ -7171,15 +7026,6 @@ __metadata: languageName: node linkType: hard -"use-sync-external-store@npm:^1.1.0": - version: 1.6.0 - resolution: "use-sync-external-store@npm:1.6.0" - peerDependencies: - react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 - checksum: 10c0/35e1179f872a53227bdf8a827f7911da4c37c0f4091c29b76b1e32473d1670ebe7bcd880b808b7549ba9a5605c233350f800ffab963ee4a4ee346ee983b6019b - languageName: node - linkType: hard - "util-deprecate@npm:^1.0.1, util-deprecate@npm:^1.0.2": version: 1.0.2 resolution: "util-deprecate@npm:1.0.2" From c8ada9e63f8258af59ec531cc75ec4fcc22fd0b5 Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Fri, 28 Nov 2025 16:14:12 +0100 Subject: [PATCH 2/4] Allow empty encryption key --- cpp/DBHostObject.cpp | 21 ++++++++------------- cpp/DBHostObject.h | 20 ++++++++------------ cpp/OPSqlite.cpp | 15 ++++----------- cpp/bridge.cpp | 2 +- 4 files changed, 21 insertions(+), 37 deletions(-) diff --git a/cpp/DBHostObject.cpp b/cpp/DBHostObject.cpp index a8b0fd2c..64e2e392 100644 --- a/cpp/DBHostObject.cpp +++ b/cpp/DBHostObject.cpp @@ -142,9 +142,8 @@ void DBHostObject::auto_register_update_hook() { #ifdef OP_SQLITE_USE_LIBSQL // Remote connection constructor DBHostObject::DBHostObject(jsi::Runtime &rt, std::string &url, - std::string &auth_token, - std::shared_ptr invoker) - : db_name(url), invoker(std::move(invoker)), rt(rt) { + std::string &auth_token, ) + : db_name(url), rt(rt) { _thread_pool = std::make_shared(); db = opsqlite_libsql_open_remote(url, auth_token); @@ -152,14 +151,12 @@ DBHostObject::DBHostObject(jsi::Runtime &rt, std::string &url, } // Sync connection constructor -DBHostObject::DBHostObject(jsi::Runtime &rt, - std::shared_ptr invoker, - std::string &db_name, std::string &path, - std::string &url, std::string &auth_token, - int sync_interval, bool offline, - std::string &encryption_key, +DBHostObject::DBHostObject(jsi::Runtime &rt, std::string &db_name, + std::string &path, std::string &url, + std::string &auth_token, int sync_interval, + bool offline, std::string &encryption_key, std::string &remote_encryption_key) - : db_name(db_name), invoker(std::move(invoker)), rt(rt) { + : db_name(db_name), rt(rt) { _thread_pool = std::make_shared(); @@ -173,13 +170,11 @@ DBHostObject::DBHostObject(jsi::Runtime &rt, #endif DBHostObject::DBHostObject(jsi::Runtime &rt, std::string &base_path, - std::shared_ptr invoker, std::string &db_name, std::string &path, std::string &crsqlite_path, std::string &sqlite_vec_path, std::string &encryption_key) - : base_path(base_path), invoker(std::move(invoker)), db_name(db_name), - rt(rt) { + : base_path(base_path), db_name(db_name), rt(rt) { _thread_pool = std::make_shared(); #ifdef OP_SQLITE_USE_SQLCIPHER diff --git a/cpp/DBHostObject.h b/cpp/DBHostObject.h index 0e4da2bf..901cfa1d 100644 --- a/cpp/DBHostObject.h +++ b/cpp/DBHostObject.h @@ -44,22 +44,19 @@ struct ReactiveQuery { class JSI_EXPORT DBHostObject : public jsi::HostObject { public: // Normal constructor shared between all backends - DBHostObject(jsi::Runtime &rt, std::string &base_path, - std::shared_ptr invoker, - std::string &db_name, std::string &path, - std::string &crsqlite_path, std::string &sqlite_vec_path, - std::string &encryption_key); + DBHostObject(jsi::Runtime &rt, std::string &base_path, std::string &db_name, + std::string &path, std::string &crsqlite_path, + std::string &sqlite_vec_path, std::string &encryption_key); #ifdef OP_SQLITE_USE_LIBSQL // Constructor for remoteOpen, purely for remote databases - DBHostObject(jsi::Runtime &rt, std::string &url, std::string &auth_token, - std::shared_ptr invoker); + DBHostObject(jsi::Runtime &rt, std::string &url, std::string &auth_token); // Constructor for a local database with remote sync - DBHostObject(jsi::Runtime &rt, std::shared_ptr invoker, - std::string &db_name, std::string &path, std::string &url, - std::string &auth_token, int sync_interval, bool offline, - std::string &encryption_key, std::string &remote_encryption_key); + DBHostObject(jsi::Runtime &rt, std::string &db_name, std::string &path, + std::string &url, std::string &auth_token, int sync_interval, + bool offline, std::string &encryption_key, + std::string &remote_encryption_key); #endif std::vector getPropertyNames(jsi::Runtime &rt) override; @@ -82,7 +79,6 @@ class JSI_EXPORT DBHostObject : public jsi::HostObject { std::unordered_map function_map; std::string base_path; - std::shared_ptr invoker; std::shared_ptr _thread_pool; std::string db_name; std::shared_ptr update_hook_callback; diff --git a/cpp/OPSqlite.cpp b/cpp/OPSqlite.cpp index e9455c18..eac3bb0e 100644 --- a/cpp/OPSqlite.cpp +++ b/cpp/OPSqlite.cpp @@ -69,12 +69,6 @@ void install(jsi::Runtime &rt, options.getProperty(rt, "encryptionKey").asString(rt).utf8(rt); } -#ifdef OP_SQLITE_USE_SQLCIPHER - if (encryption_key.empty()) { - log_to_console(rt, "Encryption key is missing for SQLCipher"); - } -#endif - if (!location.empty()) { if (location == ":memory:") { path = ":memory:"; @@ -86,8 +80,7 @@ void install(jsi::Runtime &rt, } std::shared_ptr db = std::make_shared( - rt, path, opsqlite::invoker, name, path, _crsqlite_path, - _sqlite_vec_path, encryption_key); + rt, path, name, path, _crsqlite_path, _sqlite_vec_path, encryption_key); dbs.emplace_back(db); return jsi::Object::createFromHostObject(rt, db); }); @@ -126,7 +119,7 @@ void install(jsi::Runtime &rt, options.getProperty(rt, "authToken").asString(rt).utf8(rt); std::shared_ptr db = - std::make_shared(rt, url, auth_token, invoker); + std::make_shared(rt, url, auth_token); return jsi::Object::createFromHostObject(rt, db); }); @@ -177,8 +170,8 @@ void install(jsi::Runtime &rt, } std::shared_ptr db = std::make_shared( - rt, invoker, name, path, url, auth_token, sync_interval, offline, - encryption_key, remote_encryption_key); + rt, name, path, url, auth_token, sync_interval, offline, encryption_key, + remote_encryption_key); return jsi::Object::createFromHostObject(rt, db); }); #endif diff --git a/cpp/bridge.cpp b/cpp/bridge.cpp index f298505f..0bd34294 100644 --- a/cpp/bridge.cpp +++ b/cpp/bridge.cpp @@ -102,7 +102,7 @@ sqlite3 *opsqlite_open(std::string const &name, std::string const &path, } #ifdef OP_SQLITE_USE_SQLCIPHER - if (!encryption_key.empty()) { + if (encryption_key != nullptr && !encryption_key.empty()) { opsqlite_execute(db, "PRAGMA key = '" + encryption_key + "'", nullptr); } #endif From 1c62a9994fd9c041d66694ce823210bf030f43ae Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Fri, 28 Nov 2025 16:47:55 +0100 Subject: [PATCH 3/4] Fix encryption key --- example/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/package.json b/example/package.json index cf3d0fde..d7c2f5c2 100644 --- a/example/package.json +++ b/example/package.json @@ -46,7 +46,7 @@ }, "op-sqlite": { "libsql": false, - "sqlcipher": false, + "sqlcipher": true, "iosSqlite": false, "fts5": true, "rtree": true, From c7481564392e43baed1e426c04d7ac580e516000 Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Fri, 28 Nov 2025 17:05:39 +0100 Subject: [PATCH 4/4] Fix Cpp --- cpp/DBHostObject.cpp | 9 ++++----- cpp/bridge.cpp | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cpp/DBHostObject.cpp b/cpp/DBHostObject.cpp index 64e2e392..94a8eb13 100644 --- a/cpp/DBHostObject.cpp +++ b/cpp/DBHostObject.cpp @@ -142,7 +142,7 @@ void DBHostObject::auto_register_update_hook() { #ifdef OP_SQLITE_USE_LIBSQL // Remote connection constructor DBHostObject::DBHostObject(jsi::Runtime &rt, std::string &url, - std::string &auth_token, ) + std::string &auth_token) : db_name(url), rt(rt) { _thread_pool = std::make_shared(); db = opsqlite_libsql_open_remote(url, auth_token); @@ -612,13 +612,12 @@ void DBHostObject::create_jsi_functions() { return jsi::String::createFromUtf8(rt, result); }); - function_map["flushPendingReactiveQueries"] = - HOSTFN("flushPendingReactiveQueries") { + function_map["flushPendingReactiveQueries"] = HFN(this) { auto promiseCtr = rt.global().getPropertyAsFunction(rt, "Promise"); - auto promise = promiseCtr.callAsConstructor(rt, HOSTFN("executor") { + auto promise = promiseCtr.callAsConstructor(rt, HFN(this) { auto resolve = std::make_shared(rt, args[0]); - auto task = [&rt, this, resolve]() { + auto task = [this, resolve]() { flush_pending_reactive_queries(resolve); }; diff --git a/cpp/bridge.cpp b/cpp/bridge.cpp index 0bd34294..f298505f 100644 --- a/cpp/bridge.cpp +++ b/cpp/bridge.cpp @@ -102,7 +102,7 @@ sqlite3 *opsqlite_open(std::string const &name, std::string const &path, } #ifdef OP_SQLITE_USE_SQLCIPHER - if (encryption_key != nullptr && !encryption_key.empty()) { + if (!encryption_key.empty()) { opsqlite_execute(db, "PRAGMA key = '" + encryption_key + "'", nullptr); } #endif