@op-engineering/op-sqlite 15.0.7 → 15.1.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.
Files changed (45) hide show
  1. package/android/CMakeLists.txt +1 -1
  2. package/android/build.gradle +1 -1
  3. package/android/cpp-adapter.cpp +1 -1
  4. package/android/src/main/java/com/op/sqlite/OPSQLiteModule.kt +7 -9
  5. package/cpp/DBHostObject.cpp +469 -677
  6. package/cpp/DBHostObject.h +56 -58
  7. package/cpp/DumbHostObject.cpp +1 -1
  8. package/cpp/DumbHostObject.h +12 -13
  9. package/cpp/OPSqlite.cpp +207 -0
  10. package/cpp/OPThreadPool.cpp +79 -79
  11. package/cpp/OPThreadPool.h +28 -28
  12. package/cpp/PreparedStatementHostObject.cpp +87 -136
  13. package/cpp/PreparedStatementHostObject.h +16 -28
  14. package/cpp/SmartHostObject.cpp +1 -1
  15. package/cpp/SmartHostObject.h +6 -7
  16. package/cpp/bridge.cpp +639 -633
  17. package/cpp/bridge.h +2 -2
  18. package/cpp/libsql/LICENSE.txt +9 -0
  19. package/cpp/libsql/bridge.cpp +2 -2
  20. package/cpp/libsql/{bridge.h → bridge.hpp} +4 -4
  21. package/cpp/macros.hpp +21 -0
  22. package/cpp/sqlcipher/LICENSE.txt +24 -0
  23. package/cpp/types.hpp +42 -0
  24. package/cpp/utils.cpp +320 -255
  25. package/cpp/{utils.h → utils.hpp} +9 -1
  26. package/ios/OPSQLite.mm +104 -106
  27. package/lib/module/functions.js +52 -44
  28. package/lib/module/functions.js.map +1 -1
  29. package/lib/module/index.js +1 -1
  30. package/lib/module/index.js.map +1 -1
  31. package/lib/typescript/src/functions.d.ts +5 -1
  32. package/lib/typescript/src/functions.d.ts.map +1 -1
  33. package/lib/typescript/src/index.d.ts +1 -1
  34. package/lib/typescript/src/index.d.ts.map +1 -1
  35. package/lib/typescript/src/types.d.ts +12 -1
  36. package/lib/typescript/src/types.d.ts.map +1 -1
  37. package/op-sqlite.podspec +1 -1
  38. package/package.json +10 -8
  39. package/src/functions.ts +64 -54
  40. package/src/index.ts +1 -12
  41. package/src/types.ts +9 -1
  42. package/cpp/bindings.cpp +0 -202
  43. package/cpp/macros.h +0 -15
  44. package/cpp/types.h +0 -33
  45. /package/cpp/{bindings.h → OPSqlite.hpp} +0 -0
package/cpp/bridge.h CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  #include "DumbHostObject.h"
4
4
  #include "SmartHostObject.h"
5
- #include "types.h"
6
- #include "utils.h"
5
+ #include "types.hpp"
6
+ #include "utils.hpp"
7
7
  #ifdef __ANDROID__
8
8
  #include "sqlite3.h"
9
9
  #else
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright 2023 the sqld authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,9 +1,9 @@
1
- #include "bridge.h"
1
+ #include "bridge.hpp"
2
2
  #include "DumbHostObject.h"
3
3
  #include "SmartHostObject.h"
4
4
  #include "libsql.h"
5
5
  #include "logs.h"
6
- #include "utils.h"
6
+ #include "utils.hpp"
7
7
  #include <filesystem>
8
8
  #include <iostream>
9
9
  #include <unordered_map>
@@ -3,8 +3,8 @@
3
3
  #include "DumbHostObject.h"
4
4
  #include "SmartHostObject.h"
5
5
  #include "libsql.h"
6
- #include "types.h"
7
- #include "utils.h"
6
+ #include "types.hpp"
7
+ #include "utils.hpp"
8
8
  #include <vector>
9
9
 
10
10
  #define LIBSQL_INT 1
@@ -25,8 +25,8 @@ typedef std::function<void(std::string dbName)> CommitCallback;
25
25
  typedef std::function<void(std::string dbName)> RollbackCallback;
26
26
 
27
27
  struct DB {
28
- libsql_database_t db;
29
- libsql_connection_t c;
28
+ libsql_database_t db;
29
+ libsql_connection_t c;
30
30
  };
31
31
 
32
32
  std::string opsqlite_get_db_path(std::string const &name,
package/cpp/macros.hpp ADDED
@@ -0,0 +1,21 @@
1
+ #pragma once
2
+
3
+ #define HOSTFN(name) \
4
+ jsi::Function::createFromHostFunction( \
5
+ rt, \
6
+ jsi::PropNameID::forAscii(rt, name), \
7
+ 0, \
8
+ [=, this](jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) -> jsi::Value
9
+
10
+ #define HOST_STATIC_FN(name) \
11
+ jsi::Function::createFromHostFunction( \
12
+ rt, \
13
+ jsi::PropNameID::forAscii(rt, name), \
14
+ 0, \
15
+ [=](jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) -> jsi::Value
16
+
17
+ // Do not unroll into multi lines to avoid Xcode reporting the wrong lines
18
+ #define HFN0 jsi::Function::createFromHostFunction(rt, jsi::PropNameID::forAscii(rt, ""), 0, [](jsi::Runtime &rt, const jsi::Value &that, const jsi::Value *args, size_t count) -> jsi::Value
19
+ #define HFN(c1) jsi::Function::createFromHostFunction(rt, jsi::PropNameID::forAscii(rt, ""), 0, [c1](jsi::Runtime &rt, const jsi::Value &that, const jsi::Value *args, size_t count) -> jsi::Value
20
+ #define HFN2(c1, c2) jsi::Function::createFromHostFunction(rt, jsi::PropNameID::forAscii(rt, ""), 0, [c1, c2](jsi::Runtime &rt, const jsi::Value &that, const jsi::Value *args, size_t count) -> jsi::Value
21
+ #define HFN3(c1, c2, c3) jsi::Function::createFromHostFunction(rt, jsi::PropNameID::forAscii(rt, ""), 0, [c1, c2, c3](jsi::Runtime &rt, const jsi::Value &that, const jsi::Value *args, size_t count) -> jsi::Value
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2025, ZETETIC LLC
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+ * Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ * Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+ * Neither the name of the ZETETIC LLC nor the
12
+ names of its contributors may be used to endorse or promote products
13
+ derived from this software without specific prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY
16
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/cpp/types.hpp ADDED
@@ -0,0 +1,42 @@
1
+ #pragma once
2
+
3
+ #include <ReactCommon/CallInvoker.h>
4
+ #include <memory>
5
+ #include <sqlite3.h>
6
+ #include <string>
7
+ #include <variant>
8
+ #include <vector>
9
+
10
+ namespace opsqlite {
11
+
12
+ extern std::shared_ptr<facebook::react::CallInvoker> invoker;
13
+ extern bool invalidated;
14
+
15
+ struct ArrayBuffer {
16
+ std::shared_ptr<uint8_t> data;
17
+ size_t size;
18
+ };
19
+
20
+ using JSVariant = std::variant<nullptr_t, bool, int, double, long, long long,
21
+ std::string, ArrayBuffer>;
22
+
23
+ struct BridgeResult {
24
+ std::string message;
25
+ int affectedRows;
26
+ double insertId;
27
+ std::vector<std::vector<JSVariant>> rows;
28
+ std::vector<std::string> column_names;
29
+ };
30
+
31
+ struct BatchResult {
32
+ std::string message;
33
+ int affectedRows;
34
+ int commands;
35
+ };
36
+
37
+ struct BatchArguments {
38
+ std::string sql;
39
+ std::vector<JSVariant> params;
40
+ };
41
+
42
+ } // namespace opsqlite