@op-engineering/op-sqlite 7.4.3 → 8.0.1

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.
@@ -1,5 +1,6 @@
1
1
  #pragma once
2
2
 
3
+ #include <ReactCommon/CallInvoker.h>
3
4
  #include <jsi/jsi.h>
4
5
  #include <memory>
5
6
  #ifdef OP_SQLITE_USE_LIBSQL
@@ -7,19 +8,29 @@
7
8
  #else
8
9
  #include <sqlite3.h>
9
10
  #endif
11
+ #include "ThreadPool.h"
10
12
  #include <string>
11
13
 
12
14
  namespace opsqlite {
13
15
  namespace jsi = facebook::jsi;
16
+ namespace react = facebook::react;
14
17
 
15
18
  class PreparedStatementHostObject : public jsi::HostObject {
16
19
  public:
17
20
  #ifdef OP_SQLITE_USE_LIBSQL
18
- PreparedStatementHostObject(std::string name, libsql_stmt_t stmt)
19
- : _name(name), _stmt(stmt){};
21
+ PreparedStatementHostObject(
22
+ std::string name, libsql_stmt_t stmt,
23
+ std::shared_ptr<react::CallInvoker> js_call_invoker,
24
+ std::shared_ptr<ThreadPool> thread_pool)
25
+ : _name(name), _stmt(stmt), _js_call_invoker(js_call_invoker),
26
+ _thread_pool(thread_pool){};
20
27
  #else
21
- PreparedStatementHostObject(std::string name, sqlite3_stmt *stmt)
22
- : _name(name), _stmt(stmt){};
28
+ PreparedStatementHostObject(
29
+ std::string name, sqlite3_stmt *stmt,
30
+ std::shared_ptr<react::CallInvoker> js_call_invoker,
31
+ std::shared_ptr<ThreadPool> thread_pool)
32
+ : _name(name), _stmt(stmt), _js_call_invoker(js_call_invoker),
33
+ _thread_pool(thread_pool){};
23
34
  #endif
24
35
  virtual ~PreparedStatementHostObject();
25
36
 
@@ -28,6 +39,8 @@ public:
28
39
  jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propNameID);
29
40
 
30
41
  private:
42
+ std::shared_ptr<react::CallInvoker> _js_call_invoker;
43
+ std::shared_ptr<ThreadPool> _thread_pool;
31
44
  std::string _name;
32
45
  #ifdef OP_SQLITE_USE_LIBSQL
33
46
  libsql_stmt_t _stmt;
package/cpp/bindings.cpp CHANGED
@@ -52,7 +52,7 @@ void install(jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> invoker,
52
52
  _sqlite_vec_path = std::string(sqlite_vec_path);
53
53
  _invoker = invoker;
54
54
 
55
- auto open = HOSTFN("open", 1) {
55
+ auto open = HOSTFN("open") {
56
56
  jsi::Object options = args[0].asObject(rt);
57
57
  std::string name = options.getProperty(rt, "name").asString(rt).utf8(rt);
58
58
  std::string path = std::string(_base_path);
@@ -91,7 +91,7 @@ void install(jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> invoker,
91
91
  return jsi::Object::createFromHostObject(rt, db);
92
92
  });
93
93
 
94
- auto is_sqlcipher = HOSTFN("isSQLCipher", 0) {
94
+ auto is_sqlcipher = HOSTFN("isSQLCipher") {
95
95
  #ifdef OP_SQLITE_USE_SQLCIPHER
96
96
  return true;
97
97
  #else
@@ -99,7 +99,7 @@ void install(jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> invoker,
99
99
  #endif
100
100
  });
101
101
 
102
- auto is_libsql = HOSTFN("isLibsql", 0) {
102
+ auto is_libsql = HOSTFN("isLibsql") {
103
103
  #ifdef OP_SQLITE_USE_LIBSQL
104
104
  return true;
105
105
  #else
@@ -108,7 +108,7 @@ void install(jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> invoker,
108
108
  });
109
109
 
110
110
  #ifdef OP_SQLITE_USE_LIBSQL
111
- auto open_remote = HOSTFN("openRemote", 1) {
111
+ auto open_remote = HOSTFN("openRemote") {
112
112
  jsi::Object options = args[0].asObject(rt);
113
113
  std::string url = options.getProperty(rt, "url").asString(rt).utf8(rt);
114
114
  std::string auth_token =
@@ -119,7 +119,7 @@ void install(jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> invoker,
119
119
  return jsi::Object::createFromHostObject(rt, db);
120
120
  });
121
121
 
122
- auto open_sync = HOSTFN("openSync", 1) {
122
+ auto open_sync = HOSTFN("openSync") {
123
123
  jsi::Object options = args[0].asObject(rt);
124
124
  std::string name = options.getProperty(rt, "name").asString(rt).utf8(rt);
125
125
  std::string path = std::string(_base_path);