@op-engineering/op-sqlite 7.2.0 → 7.4.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.
@@ -55,6 +55,12 @@ if (USE_CRSQLITE)
55
55
  )
56
56
  endif()
57
57
 
58
+ if (USE_SQLITE_VEC)
59
+ add_definitions(
60
+ -DOP_SQLITE_USE_SQLITE_VEC=1
61
+ )
62
+ endif()
63
+
58
64
  set_target_properties(
59
65
  ${PACKAGE_NAME} PROPERTIES
60
66
  CXX_STANDARD 20
@@ -33,6 +33,7 @@ def useCRSQLite = false
33
33
  def performanceMode = "0"
34
34
  def sqliteFlags = ""
35
35
  def enableFTS5 = false
36
+ def useSqliteVec = false
36
37
 
37
38
  def packageJsonFile = new File("$rootDir/../package.json")
38
39
  def packageJson = new JsonSlurper().parseText(packageJsonFile.text)
@@ -41,6 +42,7 @@ def opsqliteConfig = packageJson["op-sqlite"]
41
42
  if(opsqliteConfig) {
42
43
  useSQLCipher = opsqliteConfig["sqlcipher"]
43
44
  useCRSQLite = opsqliteConfig["crsqlite"]
45
+ useSqliteVec = opsqliteConfig["sqliteVec"]
44
46
  performanceMode = opsqliteConfig["performanceMode"] ? opsqliteConfig["performanceMode"] : ""
45
47
  sqliteFlags = opsqliteConfig["sqliteFlags"] ? opsqliteConfig["sqliteFlags"] : ""
46
48
  enableFTS5 = opsqliteConfig["fts5"]
@@ -71,6 +73,10 @@ if(enableFTS5) {
71
73
  println "[OP-SQLITE] FTS5 enabled! 🔎"
72
74
  }
73
75
 
76
+ if(useSqliteVec) {
77
+ println "[OP-SQLITE] Sqlite Vec enabled! ↗️"
78
+ }
79
+
74
80
  if (isNewArchitectureEnabled()) {
75
81
  apply plugin: "com.facebook.react"
76
82
  }
@@ -138,6 +144,10 @@ android {
138
144
  if(enableFTS5) {
139
145
  cFlags += ["-DSQLITE_ENABLE_FTS4=1", "-DSQLITE_ENABLE_FTS3_PARENTHESIS=1", "-DSQLITE_ENABLE_FTS5=1"]
140
146
  }
147
+ if(useSqliteVec) {
148
+ cFlags += "-DOP_SQLITE_USE_SQLITE_VEC=1"
149
+ cppFlags += "-DOP_SQLITE_USE_SQLITE_VEC=1"
150
+ }
141
151
 
142
152
  cppFlags "-O2", "-fexceptions", "-frtti", "-std=c++1y", "-DONANDROID"
143
153
  abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
@@ -145,7 +155,8 @@ android {
145
155
  "-DSQLITE_FLAGS='$sqliteFlags'",
146
156
  "-DUSE_SQLCIPHER=${useSQLCipher ? 1 : 0}",
147
157
  "-DUSE_CRSQLITE=${useCRSQLite ? 1 : 0}",
148
- "-DUSE_LIBSQL=${useLibsql ? 1 : 0}"
158
+ "-DUSE_LIBSQL=${useLibsql ? 1 : 0}",
159
+ "-DUSE_SQLITE_VEC=${useSqliteVec ? 1 : 0}"
149
160
  abiFilters (*reactNativeArchitectures())
150
161
  }
151
162
  }
@@ -33,7 +33,7 @@ private:
33
33
  std::string dbPathStr = dbPath->toStdString();
34
34
 
35
35
  opsqlite::install(*jsiRuntime, jsCallInvoker, dbPathStr.c_str(),
36
- "libcrsqlite");
36
+ "libcrsqlite", "libsqlite_vec");
37
37
  }
38
38
 
39
39
  static void clearStateNativeJsi(jni::alias_ref<jni::JObject> thiz) {
@@ -171,17 +171,19 @@ DBHostObject::DBHostObject(jsi::Runtime &rt, std::string &base_path,
171
171
  std::shared_ptr<ThreadPool> thread_pool,
172
172
  std::string &db_name, std::string &path,
173
173
  std::string &crsqlite_path,
174
+ std::string &sqlite_vec_path,
174
175
  std::string &encryption_key)
175
176
  : base_path(base_path), jsCallInvoker(jsCallInvoker),
176
177
  thread_pool(thread_pool), db_name(db_name), rt(rt) {
177
178
 
178
179
  #ifdef OP_SQLITE_USE_SQLCIPHER
179
180
  BridgeResult result =
180
- opsqlite_open(db_name, path, crsqlite_path, encryption_key);
181
+ opsqlite_open(db_name, path, crsqlite_path, sqlite_vec_path, encryption_key);
181
182
  #elif OP_SQLITE_USE_LIBSQL
182
183
  BridgeResult result = opsqlite_libsql_open(db_name, path, crsqlite_path);
183
184
  #else
184
- BridgeResult result = opsqlite_open(db_name, path, crsqlite_path);
185
+ BridgeResult result =
186
+ opsqlite_open(db_name, path, crsqlite_path, sqlite_vec_path);
185
187
  #endif
186
188
 
187
189
  if (result.type == SQLiteError) {
@@ -32,7 +32,7 @@ public:
32
32
  std::shared_ptr<react::CallInvoker> js_call_invoker,
33
33
  std::shared_ptr<ThreadPool> thread_pool, std::string &db_name,
34
34
  std::string &path, std::string &crsqlite_path,
35
- std::string &encryption_key);
35
+ std::string &sqlite_vec_path, std::string &encryption_key);
36
36
 
37
37
  #ifdef OP_SQLITE_USE_LIBSQL
38
38
  // Constructor for remoteOpen, purely for remote databases
package/cpp/bindings.cpp CHANGED
@@ -21,6 +21,7 @@ namespace jsi = facebook::jsi;
21
21
 
22
22
  std::string _base_path;
23
23
  std::string _crsqlite_path;
24
+ std::string _sqlite_vec_path;
24
25
  std::shared_ptr<react::CallInvoker> _invoker;
25
26
  std::shared_ptr<ThreadPool> thread_pool = std::make_shared<ThreadPool>();
26
27
 
@@ -43,10 +44,12 @@ void clearState() {
43
44
  }
44
45
 
45
46
  void install(jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> invoker,
46
- const char *base_path, const char *crsqlite_path) {
47
+ const char *base_path, const char *crsqlite_path,
48
+ const char *sqlite_vec_path) {
47
49
  invalidated = false;
48
50
  _base_path = std::string(base_path);
49
51
  _crsqlite_path = std::string(crsqlite_path);
52
+ _sqlite_vec_path = std::string(sqlite_vec_path);
50
53
  _invoker = invoker;
51
54
 
52
55
  auto open = HOSTFN("open", 1) {
@@ -82,9 +85,9 @@ void install(jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> invoker,
82
85
  }
83
86
  }
84
87
 
85
- std::shared_ptr<DBHostObject> db =
86
- std::make_shared<DBHostObject>(rt, path, invoker, thread_pool, name,
87
- path, _crsqlite_path, encryptionKey);
88
+ std::shared_ptr<DBHostObject> db = std::make_shared<DBHostObject>(
89
+ rt, path, invoker, thread_pool, name, path, _crsqlite_path,
90
+ _sqlite_vec_path, encryptionKey);
88
91
  return jsi::Object::createFromHostObject(rt, db);
89
92
  });
90
93
 
package/cpp/bindings.h CHANGED
@@ -10,7 +10,8 @@ namespace jsi = facebook::jsi;
10
10
  namespace react = facebook::react;
11
11
 
12
12
  void install(jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> invoker,
13
- const char *base_path, const char *crsqlite_path);
13
+ const char *base_path, const char *crsqlite_path,
14
+ const char *sqlite_vec_path);
14
15
  void clearState();
15
16
 
16
17
  } // namespace opsqlite
package/cpp/bridge.cpp CHANGED
@@ -51,12 +51,14 @@ std::string opsqlite_get_db_path(std::string const &db_name,
51
51
  #ifdef OP_SQLITE_USE_SQLCIPHER
52
52
  BridgeResult opsqlite_open(std::string const &dbName,
53
53
  std::string const &last_path,
54
- std::string const &crsqlitePath,
54
+ std::string const &crsqlite_path,
55
+ std::string const &sqlite_vec_path,
55
56
  std::string const &encryptionKey) {
56
57
  #else
57
58
  BridgeResult opsqlite_open(std::string const &dbName,
58
59
  std::string const &last_path,
59
- std::string const &crsqlitePath) {
60
+ std::string const &crsqlite_path,
61
+ std::string const &sqlite_vec_path) {
60
62
  #endif
61
63
  std::string dbPath = opsqlite_get_db_path(dbName, last_path);
62
64
 
@@ -78,13 +80,15 @@ BridgeResult opsqlite_open(std::string const &dbName,
78
80
  nullptr, nullptr);
79
81
  #endif
80
82
 
81
- #ifdef OP_SQLITE_USE_CRSQLITE
83
+ sqlite3_enable_load_extension(db, 1);
84
+
82
85
  char *errMsg;
83
- const char *crsqliteEntryPoint = "sqlite3_crsqlite_init";
84
86
 
85
- sqlite3_enable_load_extension(db, 1);
87
+ #ifdef OP_SQLITE_USE_CRSQLITE
88
+ const char *crsqliteEntryPoint = "sqlite3_crsqlite_init";
86
89
 
87
- sqlite3_load_extension(db, crsqlitePath.c_str(), crsqliteEntryPoint, &errMsg);
90
+ sqlite3_load_extension(db, crsqlite_path.c_str(), crsqliteEntryPoint,
91
+ &errMsg);
88
92
 
89
93
  if (errMsg != nullptr) {
90
94
  return {.type = SQLiteError, .message = errMsg};
@@ -93,6 +97,19 @@ BridgeResult opsqlite_open(std::string const &dbName,
93
97
  }
94
98
  #endif
95
99
 
100
+ #ifdef OP_SQLITE_USE_SQLITE_VEC
101
+ const char *vec_entry_point = "sqlite3_vec_init";
102
+
103
+ sqlite3_load_extension(db, sqlite_vec_path.c_str(), vec_entry_point, &errMsg);
104
+
105
+ if (errMsg != nullptr) {
106
+ return {.type = SQLiteError, .message = errMsg};
107
+ } else {
108
+ LOGI("Loaded sqlite-vec successfully");
109
+ }
110
+
111
+ #endif
112
+
96
113
  return {.type = SQLiteOk, .affectedRows = 0};
97
114
  }
98
115
 
package/cpp/bridge.h CHANGED
@@ -24,11 +24,13 @@ std::string opsqlite_get_db_path(std::string const &db_name,
24
24
 
25
25
  #ifdef OP_SQLITE_USE_SQLCIPHER
26
26
  BridgeResult opsqlite_open(std::string const &dbName, std::string const &dbPath,
27
- std::string const &crsqlitePath,
27
+ std::string const &crsqlite_path,
28
+ std::string const &sqlite_vec_path,
28
29
  std::string const &encryptionKey);
29
30
  #else
30
31
  BridgeResult opsqlite_open(std::string const &dbName, std::string const &dbPath,
31
- std::string const &crsqlitePath);
32
+ std::string const &crsqlite_path,
33
+ std::string const &sqlite_vec_path);
32
34
  #endif
33
35
 
34
36
  BridgeResult opsqlite_close(std::string const &dbName);
package/ios/OPSQLite.mm CHANGED
@@ -75,15 +75,25 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
75
75
  documentPath = [paths objectAtIndex:0];
76
76
  }
77
77
 
78
- NSBundle *bundle = [NSBundle bundleWithIdentifier:@"io.vlcn.crsqlite"];
79
- NSString *crsqlitePath = [bundle pathForResource:@"crsqlite" ofType:@""];
78
+ NSBundle *crsqlite_bundle =
79
+ [NSBundle bundleWithIdentifier:@"io.vlcn.crsqlite"];
80
+ NSString *crsqlite_path = [crsqlite_bundle pathForResource:@"crsqlite"
81
+ ofType:@""];
82
+ NSBundle *libsqlitevec_bundle =
83
+ [NSBundle bundleWithIdentifier:@"com.ospfranco.sqlitevec"];
84
+ NSString *sqlite_vec_path = [libsqlitevec_bundle pathForResource:@"sqlitevec"
85
+ ofType:@""];
86
+
87
+ if (crsqlite_path == nil) {
88
+ crsqlite_path = @"";
89
+ }
80
90
 
81
- if (crsqlitePath == nil) {
82
- crsqlitePath = @"";
91
+ if (sqlite_vec_path == nil) {
92
+ sqlite_vec_path = @"";
83
93
  }
84
94
 
85
95
  opsqlite::install(runtime, callInvoker, [documentPath UTF8String],
86
- [crsqlitePath UTF8String]);
96
+ [crsqlite_path UTF8String], [sqlite_vec_path UTF8String]);
87
97
  return @true;
88
98
  }
89
99
 
@@ -0,0 +1,46 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>AvailableLibraries</key>
6
+ <array>
7
+ <dict>
8
+ <key>LibraryIdentifier</key>
9
+ <string>ios-arm64</string>
10
+ <key>LibraryPath</key>
11
+ <string>sqlitevec.framework</string>
12
+ <key>SupportedArchitectures</key>
13
+ <array>
14
+ <string>arm64</string>
15
+ </array>
16
+ <key>SupportedPlatform</key>
17
+ <string>ios</string>
18
+ </dict>
19
+ <dict>
20
+ <key>LibraryIdentifier</key>
21
+ <string>ios-arm64_x86_64-simulator</string>
22
+ <key>LibraryPath</key>
23
+ <string>sqlitevec.framework</string>
24
+ <key>SupportedArchitectures</key>
25
+ <array>
26
+ <string>arm64</string>
27
+ <string>x86_64</string>
28
+ </array>
29
+ <key>SupportedPlatform</key>
30
+ <string>ios</string>
31
+ <key>SupportedPlatformVariant</key>
32
+ <string>simulator</string>
33
+ </dict>
34
+ </array>
35
+ <key>CFBundlePackageType</key>
36
+ <string>XFWK</string>
37
+ <key>XCFrameworkFormatVersion</key>
38
+ <string>1.0</string>
39
+ <key>CFBundleVersion</key>
40
+ <string>1.0.0</string>
41
+ <key>CFBundleShortVersionString</key>
42
+ <string>1.0.0</string>
43
+ <key>MinimumOSVersion</key>
44
+ <string>8.0</string>
45
+ </dict>
46
+ </plist>
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>en</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>sqlitevec</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>com.ospfranco.sqlitevec</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundlePackageType</key>
14
+ <string>FMWK</string>
15
+ <key>CFBundleSignature</key>
16
+ <string>????</string>
17
+ <key>CFBundleVersion</key>
18
+ <string>1.0.0</string>
19
+ <key>CFBundleShortVersionString</key>
20
+ <string>1.0.0</string>
21
+ <key>MinimumOSVersion</key>
22
+ <string>8.0</string>
23
+ </dict>
24
+ </plist>
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>en</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>sqlitevec</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>com.ospfranco.sqlitevec</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundlePackageType</key>
14
+ <string>FMWK</string>
15
+ <key>CFBundleSignature</key>
16
+ <string>????</string>
17
+ <key>CFBundleVersion</key>
18
+ <string>1.0.0</string>
19
+ <key>CFBundleShortVersionString</key>
20
+ <string>1.0.0</string>
21
+ <key>MinimumOSVersion</key>
22
+ <string>8.0</string>
23
+ </dict>
24
+ </plist>
package/op-sqlite.podspec CHANGED
@@ -26,6 +26,7 @@ performance_mode = "0"
26
26
  phone_version = false
27
27
  sqlite_flags = ""
28
28
  fts5 = false
29
+ use_sqlite_vec = false
29
30
 
30
31
  if(op_sqlite_config != nil)
31
32
  use_sqlcipher = op_sqlite_config["sqlcipher"] == true
@@ -35,6 +36,7 @@ if(op_sqlite_config != nil)
35
36
  phone_version = op_sqlite_config["iosSqlite"] == true
36
37
  sqlite_flags = op_sqlite_config["sqliteFlags"] || ""
37
38
  fts5 = op_sqlite_config["fts5"] == true
39
+ use_sqlite_vec = op_sqlite_config["sqliteVec"] == true
38
40
  end
39
41
 
40
42
  if phone_version && use_sqlcipher
@@ -86,8 +88,8 @@ Pod::Spec.new do |s|
86
88
  end
87
89
 
88
90
  other_cflags = '-DSQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION=1'
89
-
90
91
  optimizedCflags = other_cflags + '$(inherited) -DSQLITE_DQS=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_OMIT_DEPRECATED=1 -DSQLITE_OMIT_PROGRESS_CALLBACK=1 -DSQLITE_OMIT_SHARED_CACHE=1 -DSQLITE_USE_ALLOCA=1'
92
+ frameworks = []
91
93
 
92
94
  if fts5 && !phone_version then
93
95
  log_message.call("[OP-SQLITE] FTS5 enabled 🔎")
@@ -126,7 +128,13 @@ Pod::Spec.new do |s|
126
128
  if use_crsqlite then
127
129
  log_message.call("[OP-SQLITE] using CRQSQLite 🤖")
128
130
  xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_CRSQLITE=1"
129
- s.vendored_frameworks = "ios/crsqlite.xcframework"
131
+ frameworks.push("ios/crsqlite.xcframework")
132
+ end
133
+
134
+ if use_sqlite_vec then
135
+ log_message.call("[OP-SQLITE] using Sqlite Vec ↗️")
136
+ xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_SQLITE_VEC=1"
137
+ frameworks.push("ios/sqlitevec.xcframework")
130
138
  end
131
139
 
132
140
  if use_libsql then
@@ -135,9 +143,9 @@ Pod::Spec.new do |s|
135
143
  end
136
144
  xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_LIBSQL=1"
137
145
  if use_crsqlite then
138
- s.vendored_frameworks = "ios/libsql.xcframework", "ios/crsqlite.xcframework"
146
+ frameworks = ["ios/libsql.xcframework", "ios/crsqlite.xcframework"]
139
147
  else
140
- s.vendored_frameworks = "ios/libsql.xcframework"
148
+ frameworks = ["ios/libsql.xcframework"]
141
149
  end
142
150
  end
143
151
 
@@ -147,4 +155,5 @@ Pod::Spec.new do |s|
147
155
  end
148
156
 
149
157
  s.pod_target_xcconfig = xcconfig
158
+ s.vendored_frameworks = frameworks
150
159
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@op-engineering/op-sqlite",
3
- "version": "7.2.0",
3
+ "version": "7.4.0",
4
4
  "description": "Next generation SQLite for React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -14,7 +14,7 @@
14
14
  "ios",
15
15
  "cpp",
16
16
  "op-sqlite.podspec",
17
- "crsqlite.xcframework",
17
+ "ios/**.xcframework",
18
18
  "!lib/typescript/example",
19
19
  "!android/build",
20
20
  "!android/.cxx",