Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions cpp/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <fstream>
#include <sys/stat.h>
#include <utility>
#include "macros.hpp"

namespace opsqlite {

Expand Down Expand Up @@ -322,21 +323,14 @@ void log_to_console(jsi::Runtime &runtime, const std::string &message) {
log.call(runtime, jsi::String::createFromUtf8(runtime, message));
}

inline jsi::Function host_fn(jsi::Runtime &rt, jsi::HostFunctionType lambda) {
return jsi::Function::createFromHostFunction(
rt, jsi::PropNameID::forAscii(rt, ""), 0, std::move(lambda));
};

jsi::Value
promisify(jsi::Runtime &rt, std::function<std::any()> lambda,
std::function<jsi::Value(jsi::Runtime &rt, std::any result)>
resolve_callback) {
auto promise_constructor = rt.global().getPropertyAsFunction(rt, "Promise");

auto executor = host_fn(rt, [lambda = std::move(lambda),
resolve_callback = std::move(resolve_callback)](
jsi::Runtime &rt, const jsi::Value &thiz,
const jsi::Value *args, size_t count) {
auto executor = HFN2(lambda = std::move(lambda),
resolve_callback = std::move(resolve_callback)) {
auto resolve = std::make_shared<jsi::Value>(rt, args[0]);
auto reject = std::make_shared<jsi::Value>(rt, args[1]);

Expand Down
1 change: 0 additions & 1 deletion cpp/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ bool file_exists(const std::string &path);

void log_to_console(jsi::Runtime &rt, const std::string &message);

jsi::Function host_fn(jsi::Runtime &rt, jsi::HostFunctionType lambda);
jsi::Value
promisify(jsi::Runtime &rt, std::function<std::any()> lambda,
std::function<jsi::Value(jsi::Runtime &rt, std::any result)>
Expand Down
75 changes: 67 additions & 8 deletions example/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ GEM
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
addressable (2.8.8)
public_suffix (>= 2.0.2, < 8.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
base64 (0.3.0)
benchmark (0.5.0)
bigdecimal (3.3.1)
bigdecimal (4.0.1)
claide (1.1.0)
cocoapods (1.15.2)
addressable (~> 2.8)
Expand Down Expand Up @@ -63,7 +63,7 @@ GEM
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.3.3)
connection_pool (2.5.4)
connection_pool (3.0.2)
drb (2.2.3)
escape (0.0.4)
ethon (0.15.0)
Expand All @@ -86,14 +86,16 @@ GEM
mutex_m
i18n (1.14.7)
concurrent-ruby (~> 1.0)
json (2.16.0)
json (2.18.0)
logger (1.7.0)
minitest (5.26.2)
minitest (6.0.0)
prism (~> 1.5)
molinillo (0.8.0)
mutex_m (0.3.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
prism (1.6.0)
public_suffix (4.0.7)
rexml (3.4.4)
ruby-macho (2.5.1)
Expand Down Expand Up @@ -133,8 +135,65 @@ DEPENDENCIES
mutex_m
xcodeproj (< 1.26.0)

CHECKSUMS
CFPropertyList (3.0.8) sha256=2c99d0d980536d3d7ab252f7bd59ac8be50fbdd1ff487c98c949bb66bb114261
activesupport (7.2.3) sha256=5675c9770dac93e371412684249f9dc3c8cec104efd0624362a520ae685c7b10
addressable (2.8.8) sha256=7c13b8f9536cf6364c03b9d417c19986019e28f7c00ac8132da4eb0fe393b057
algoliasearch (1.27.5) sha256=26c1cddf3c2ec4bd60c148389e42702c98fdac862881dc6b07a4c0b89ffec853
atomos (0.1.3) sha256=7d43b22f2454a36bace5532d30785b06de3711399cb1c6bf932573eda536789f
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
benchmark (0.5.0) sha256=465df122341aedcb81a2a24b4d3bd19b6c67c1530713fd533f3ff034e419236c
bigdecimal (4.0.1) sha256=8b07d3d065a9f921c80ceaea7c9d4ae596697295b584c296fe599dd0ad01c4a7
claide (1.1.0) sha256=6d3c5c089dde904d96aa30e73306d0d4bd444b1accb9b3125ce14a3c0183f82e
cocoapods (1.15.2) sha256=f0f5153de8d028d133b96f423e04f37fb97a1da0d11dda581a9f46c0cba4090a
cocoapods-core (1.15.2) sha256=322650d97fe1ad4c0831a09669764b888bd91c6d79d0f6bb07281a17667a2136
cocoapods-deintegrate (1.0.5) sha256=517c2a448ef563afe99b6e7668704c27f5de9e02715a88ee9de6974dc1b3f6a2
cocoapods-downloader (2.1) sha256=bb6ebe1b3966dc4055de54f7a28b773485ac724fdf575d9bee2212d235e7b6d1
cocoapods-plugins (1.0.0) sha256=725d17ce90b52f862e73476623fd91441b4430b742d8a071000831efb440ca9a
cocoapods-search (1.0.1) sha256=1b133b0e6719ed439bd840e84a1828cca46425ab73a11eff5e096c3b2df05589
cocoapods-trunk (1.6.0) sha256=5f5bda8c172afead48fa2d43a718cf534b1313c367ba1194cebdeb9bfee9ed31
cocoapods-try (1.2.0) sha256=145b946c6e7747ed0301d975165157951153d27469e6b2763c83e25c84b9defe
colored2 (3.1.2) sha256=b13c2bd7eeae2cf7356a62501d398e72fde78780bd26aec6a979578293c28b4a
concurrent-ruby (1.3.3) sha256=4f9cd28965c4dcf83ffd3ea7304f9323277be8525819cb18a3b61edcb56a7c6a
connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
escape (0.0.4) sha256=e49f44ae2b4f47c6a3abd544ae77fe4157802794e32f19b8e773cbc4dcec4169
ethon (0.15.0) sha256=0809805a035bc10f54162ca99f15ded49e428e0488bcfe1c08c821e18261a74d
ffi (1.17.2) sha256=297235842e5947cc3036ebe64077584bff583cd7a4e94e9a02fdec399ef46da6
ffi (1.17.2-aarch64-linux-gnu) sha256=c910bd3cae70b76690418cce4572b7f6c208d271f323d692a067d59116211a1a
ffi (1.17.2-aarch64-linux-musl) sha256=69e6556b091d45df83e6c3b19d3c54177c206910965155a6ec98de5e893c7b7c
ffi (1.17.2-arm-linux-gnu) sha256=d4a438f2b40224ae42ec72f293b3ebe0ba2159f7d1bd47f8417e6af2f68dbaa5
ffi (1.17.2-arm-linux-musl) sha256=977dfb7f3a6381206dbda9bc441d9e1f9366bf189a634559c3b7c182c497aaa3
ffi (1.17.2-arm64-darwin) sha256=54dd9789be1d30157782b8de42d8f887a3c3c345293b57ffb6b45b4d1165f813
ffi (1.17.2-x86-linux-gnu) sha256=95d8f9ebea23c39888e2ab85a02c98f54acb2f4e79b829250d7267ce741dc7b0
ffi (1.17.2-x86-linux-musl) sha256=41741449bab2b9530f42a47baa5c26263925306fad0ac2d60887f51af2e3b24c
ffi (1.17.2-x86_64-darwin) sha256=981f2d4e32ea03712beb26e55e972797c2c5a7b0257955d8667ba58f2da6440e
ffi (1.17.2-x86_64-linux-gnu) sha256=05d2026fc9dbb7cfd21a5934559f16293815b7ce0314846fee2ac8efbdb823ea
ffi (1.17.2-x86_64-linux-musl) sha256=97c0eb3981414309285a64dc4d466bd149e981c279a56371ef811395d68cb95c
fourflusher (2.3.1) sha256=1b3de61c7c791b6a4e64f31e3719eb25203d151746bb519a0292bff1065ccaa9
fuzzy_match (2.0.4) sha256=b5de4f95816589c5b5c3ad13770c0af539b75131c158135b3f3bbba75d0cfca5
gh_inspector (1.1.3) sha256=04cca7171b87164e053aa43147971d3b7f500fcb58177698886b48a9fc4a1939
httpclient (2.9.0) sha256=4b645958e494b2f86c2f8a2f304c959baa273a310e77a2931ddb986d83e498c8
i18n (1.14.7) sha256=ceba573f8138ff2c0915427f1fc5bdf4aa3ab8ae88c8ce255eb3ecf0a11a5d0f
json (2.18.0) sha256=b10506aee4183f5cf49e0efc48073d7b75843ce3782c68dbeb763351c08fd505
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
minitest (6.0.0) sha256=4ca597fc1d735ea18d2b4b98c5fb1d5a6da4a6f35ddf32bd5fa3eded33a453be
molinillo (0.8.0) sha256=efbff2716324e2a30bccd3eba1ff3a735f4d5d53ffddbc6a2f32c0ca9433045d
mutex_m (0.3.0) sha256=cfcb04ac16b69c4813777022fdceda24e9f798e48092a2b817eb4c0a782b0751
nanaimo (0.3.0) sha256=aaaedc60497070b864a7e220f7c4b4cad3a0daddda2c30055ba8dae306342376
nap (1.1.0) sha256=949691660f9d041d75be611bb2a8d2fd559c467537deac241f4097d9b5eea576
netrc (0.11.0) sha256=de1ce33da8c99ab1d97871726cba75151113f117146becbe45aa85cb3dabee3f
prism (1.6.0) sha256=bfc0281a81718c4872346bc858dc84abd3a60cae78336c65ad35c8fbff641c6b
public_suffix (4.0.7) sha256=8be161e2421f8d45b0098c042c06486789731ea93dc3a896d30554ee38b573b8
rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142
ruby-macho (2.5.1) sha256=9075e52e0f9270b552a90b24fcc6219ad149b0d15eae1bc364ecd0ac8984f5c9
securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
typhoeus (1.5.0) sha256=120b67ed1ef515e6c0e938176db880f15b0916f038e78ce2a66290f3f1de3e3b
tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
xcodeproj (1.25.1) sha256=9a2310dccf6d717076e86f602b17c640046b6f1dfe64480044596f6f2f13dc84

RUBY VERSION
ruby 3.3.0p0
ruby 3.3.0

BUNDLED WITH
2.7.2
4.0.1
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2027,7 +2027,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
FBLazyVector: 2e5b5553df729e080483373db6f045201ff4e6db
hermes-engine: 273e30e7fb618279934b0b95ffab60ecedb7acf5
op-sqlite: e771018121ddfa4373d51bb1e1751835cfa659b0
op-sqlite: 44765a0bf429dbb8cc5e301b81114faa080df893
OpServer: 9b3ebdeeb095950e760e3c39853cd06849421b35
RCTDeprecation: c6b36da89aa26090c8684d29c2868dcca2cd4554
RCTRequired: 1413a0844770d00fa1f1bb2da4680adfa8698065
Expand Down
2 changes: 1 addition & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function App() {
useEffect(() => {
const work = async () => {
let start = performance.now();
let dummyDB = open({
open({
name: 'dummyDb.sqlite',
});
setOpenTime(performance.now() - start);
Expand Down
1 change: 1 addition & 0 deletions example/src/tests/tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('Tokenizer tests', () => {
});

if (!isLibsql()) {
await db.execute('DROP TABLE IF EXISTS tokenizer_table;');
await db.execute(
`CREATE VIRTUAL TABLE tokenizer_table USING fts5(content, tokenize = 'wordtokenizer');`,
);
Expand Down
17 changes: 12 additions & 5 deletions ios/OPSQLite.mm
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,22 @@ - (NSDictionary *)getConstants {
}

#ifdef OP_SQLITE_USE_CRSQLITE
NSBundle *crsqlite_bundle =
[NSBundle bundleWithIdentifier:@"io.vlcn.crsqlite"];
NSString *crsqlite_bundle_path =
[[[NSBundle mainBundle] privateFrameworksPath]
stringByAppendingPathComponent:@"crsqlite.framework"];
NSBundle *crsqlite_bundle = [NSBundle bundleWithPath:crsqlite_bundle_path];
NSString *crsqlite_path = [crsqlite_bundle pathForResource:@"crsqlite"
ofType:@""];
#else
NSString *crsqlite_path = @"";
#endif


#ifdef OP_SQLITE_USE_SQLITE_VEC
NSString *sqlitevec_bundle_path =
[[[NSBundle mainBundle] privateFrameworksPath]
stringByAppendingPathComponent:@"sqlitevec.framework"];
NSBundle *libsqlitevec_bundle =
[NSBundle bundleWithIdentifier:@"com.ospfranco.sqlitevec"];
[NSBundle bundleWithPath:sqlitevec_bundle_path];
NSString *sqlite_vec_path = [libsqlitevec_bundle pathForResource:@"sqlitevec"
ofType:@""];
#else
Expand All @@ -98,7 +102,10 @@ - (NSDictionary *)getConstants {

RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getDylibPath : (
NSString *)bundleId andResource : (NSString *)resourceName) {
NSBundle *bundle = [NSBundle bundleWithIdentifier:bundleId];
NSString *bundle_path = [[[NSBundle mainBundle] privateFrameworksPath]
stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.framework",
resourceName]];
NSBundle *bundle = [NSBundle bundleWithPath:bundle_path];
NSString *path = [bundle pathForResource:resourceName ofType:@""];
return path;
}
Expand Down
Loading