@op-engineering/op-sqlite 0.0.0-resolution-test
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.
- package/LICENSE +7 -0
- package/README.md +31 -0
- package/android/.project +17 -0
- package/android/.settings/org.eclipse.buildship.core.prefs +13 -0
- package/android/CMakeLists.txt +141 -0
- package/android/build.gradle +266 -0
- package/android/c_sources/tokenizers.cpp +88 -0
- package/android/c_sources/tokenizers.h +15 -0
- package/android/cpp-adapter.cpp +46 -0
- package/android/gradle.properties +1 -0
- package/android/jniLibs/arm64-v8a/libsql_experimental.a +0 -0
- package/android/jniLibs/armeabi-v7a/libsql_experimental.a +0 -0
- package/android/jniLibs/x86/libsql_experimental.a +0 -0
- package/android/jniLibs/x86_64/libsql_experimental.a +0 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/op/sqlite/OPSQLiteBridge.kt +37 -0
- package/android/src/main/java/com/op/sqlite/OPSQLiteModule.kt +119 -0
- package/android/src/main/java/com/op/sqlite/OPSQLitePackage.kt +18 -0
- package/android/src/main/jniLibs/arm64-v8a/libcrsqlite.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libsqlite_vec.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libcrsqlite.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libsqlite_vec.so +0 -0
- package/android/src/main/jniLibs/x86/libcrsqlite.so +0 -0
- package/android/src/main/jniLibs/x86/libsqlite_vec.so +0 -0
- package/android/src/main/jniLibs/x86_64/libcrsqlite.so +0 -0
- package/android/src/main/jniLibs/x86_64/libsqlite_vec.so +0 -0
- package/android/src/paper/java/com/op/sqlite/NativeOPSQLiteSpec.java +77 -0
- package/cpp/DBHostObject.cpp +852 -0
- package/cpp/DBHostObject.h +99 -0
- package/cpp/DumbHostObject.cpp +72 -0
- package/cpp/DumbHostObject.h +36 -0
- package/cpp/OPThreadPool.cpp +120 -0
- package/cpp/OPThreadPool.h +44 -0
- package/cpp/PreparedStatementHostObject.cpp +151 -0
- package/cpp/PreparedStatementHostObject.h +59 -0
- package/cpp/SmartHostObject.cpp +34 -0
- package/cpp/SmartHostObject.h +24 -0
- package/cpp/bindings.cpp +182 -0
- package/cpp/bindings.h +19 -0
- package/cpp/bridge.cpp +873 -0
- package/cpp/bridge.h +80 -0
- package/cpp/libsql/bridge.cpp +738 -0
- package/cpp/libsql/bridge.h +85 -0
- package/cpp/libsql/libsql.h +172 -0
- package/cpp/logs.h +40 -0
- package/cpp/macros.h +15 -0
- package/cpp/sqlcipher/sqlite3.c +262970 -0
- package/cpp/sqlcipher/sqlite3.h +13485 -0
- package/cpp/sqlite3.c +261454 -0
- package/cpp/sqlite3.h +13715 -0
- package/cpp/types.h +33 -0
- package/cpp/utils.cpp +327 -0
- package/cpp/utils.h +47 -0
- package/generate_tokenizers_header_file.rb +29 -0
- package/ios/OPSQLite.h +7 -0
- package/ios/OPSQLite.mm +157 -0
- package/ios/OPSQLite.xcodeproj/project.pbxproj +275 -0
- package/ios/crsqlite.xcframework/Info.plist +46 -0
- package/ios/crsqlite.xcframework/ios-arm64/crsqlite.framework/Info.plist +24 -0
- package/ios/crsqlite.xcframework/ios-arm64/crsqlite.framework/crsqlite +0 -0
- package/ios/crsqlite.xcframework/ios-arm64_x86_64-simulator/crsqlite.framework/Info.plist +24 -0
- package/ios/crsqlite.xcframework/ios-arm64_x86_64-simulator/crsqlite.framework/crsqlite +0 -0
- package/ios/libsql.xcframework/Info.plist +48 -0
- package/ios/libsql.xcframework/ios-arm64/Headers/libsql.h +172 -0
- package/ios/libsql.xcframework/ios-arm64/libsql_experimental.a +0 -0
- package/ios/libsql.xcframework/ios-arm64_x86_64-simulator/Headers/libsql.h +172 -0
- package/ios/libsql.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.a +0 -0
- package/ios/sqlitevec.xcframework/Info.plist +71 -0
- package/ios/sqlitevec.xcframework/ios-arm64/sqlitevec.framework/Info.plist +24 -0
- package/ios/sqlitevec.xcframework/ios-arm64/sqlitevec.framework/sqlitevec +0 -0
- package/ios/sqlitevec.xcframework/ios-arm64_x86_64-simulator/sqlitevec.framework/Info.plist +24 -0
- package/ios/sqlitevec.xcframework/ios-arm64_x86_64-simulator/sqlitevec.framework/sqlitevec +0 -0
- package/ios/sqlitevec.xcframework/tvos-arm64/sqlitevec.framework/Info.plist +24 -0
- package/ios/sqlitevec.xcframework/tvos-arm64/sqlitevec.framework/sqlitevec +0 -0
- package/ios/sqlitevec.xcframework/tvos-arm64_x86_64-simulator/sqlitevec.framework/Info.plist +24 -0
- package/ios/sqlitevec.xcframework/tvos-arm64_x86_64-simulator/sqlitevec.framework/sqlitevec +0 -0
- package/lib/commonjs/NativeOPSQLite.js +9 -0
- package/lib/commonjs/NativeOPSQLite.js.map +1 -0
- package/lib/commonjs/Storage.js +60 -0
- package/lib/commonjs/Storage.js.map +1 -0
- package/lib/commonjs/index.js +365 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/NativeOPSQLite.js +3 -0
- package/lib/module/NativeOPSQLite.js.map +1 -0
- package/lib/module/Storage.js +53 -0
- package/lib/module/Storage.js.map +1 -0
- package/lib/module/index.js +340 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/src/NativeOPSQLite.d.ts +15 -0
- package/lib/typescript/src/NativeOPSQLite.d.ts.map +1 -0
- package/lib/typescript/src/Storage.d.ts +23 -0
- package/lib/typescript/src/Storage.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +319 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/op-sqlite.podspec +212 -0
- package/package.json +85 -0
- package/src/NativeOPSQLite.ts +17 -0
- package/src/Storage.ts +85 -0
- package/src/index.ts +722 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
package com.op.sqlite
|
|
2
|
+
|
|
3
|
+
import android.util.Log
|
|
4
|
+
import com.facebook.react.bridge.Promise
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.bridge.ReactMethod
|
|
7
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
8
|
+
import com.facebook.react.bridge.ReadableMap
|
|
9
|
+
import java.io.File
|
|
10
|
+
import java.io.FileOutputStream
|
|
11
|
+
import java.io.InputStream
|
|
12
|
+
import java.io.OutputStream
|
|
13
|
+
import com.facebook.react.util.RNLog;
|
|
14
|
+
|
|
15
|
+
//@ReactModule(name = OPSQLiteModule.NAME)
|
|
16
|
+
internal class OPSQLiteModule(context: ReactApplicationContext?) : ReactContextBaseJavaModule(context) {
|
|
17
|
+
override fun getName(): String {
|
|
18
|
+
return NAME
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
fun getTypedExportedConstants(): MutableMap<String, Any> {
|
|
22
|
+
val constants: MutableMap<String, Any> = HashMap()
|
|
23
|
+
val context = reactApplicationContext
|
|
24
|
+
val dbPath =
|
|
25
|
+
context.getDatabasePath("defaultDatabase")
|
|
26
|
+
.absolutePath
|
|
27
|
+
.replace("defaultDatabase", "")
|
|
28
|
+
constants["ANDROID_DATABASE_PATH"] = dbPath
|
|
29
|
+
val filesPath = context.filesDir.absolutePath
|
|
30
|
+
constants["ANDROID_FILES_PATH"] = filesPath
|
|
31
|
+
val externalFilesDir = context.getExternalFilesDir(null)!!.absolutePath
|
|
32
|
+
constants["ANDROID_EXTERNAL_FILES_PATH"] = externalFilesDir
|
|
33
|
+
constants["IOS_DOCUMENT_PATH"] = ""
|
|
34
|
+
constants["IOS_LIBRARY_PATH"] = ""
|
|
35
|
+
return constants
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
override fun getConstants(): MutableMap<String, Any>? {
|
|
39
|
+
return getTypedExportedConstants()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
43
|
+
fun install(): Boolean {
|
|
44
|
+
return try {
|
|
45
|
+
OPSQLiteBridge.instance.install(reactApplicationContext)
|
|
46
|
+
true
|
|
47
|
+
} catch (exception: Exception) {
|
|
48
|
+
Log.e(NAME, "Install exception: $exception")
|
|
49
|
+
false
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
54
|
+
fun getDylibPath(bundleId: String, name: String) {
|
|
55
|
+
throw Exception("Do not call getDylibPath on Android")
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@ReactMethod
|
|
59
|
+
fun moveAssetsDatabase(args: ReadableMap, promise: Promise) {
|
|
60
|
+
val filename = args.getString("filename")!!
|
|
61
|
+
val path = args.getString("path") ?: "custom"
|
|
62
|
+
val overwrite = if(args.hasKey("overwrite")) { args.getBoolean("overwrite") } else false
|
|
63
|
+
val context = reactApplicationContext
|
|
64
|
+
val assetsManager = context.assets
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
|
|
68
|
+
val databasesFolder =
|
|
69
|
+
context.getDatabasePath("defaultDatabase")
|
|
70
|
+
.absolutePath
|
|
71
|
+
.replace("defaultDatabase", "")
|
|
72
|
+
|
|
73
|
+
val outputFile = File(databasesFolder, filename)
|
|
74
|
+
|
|
75
|
+
if (outputFile.exists()) {
|
|
76
|
+
if(overwrite) {
|
|
77
|
+
outputFile.delete()
|
|
78
|
+
} else {
|
|
79
|
+
promise.resolve(true)
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
val inputStream: InputStream = assetsManager.open("$path/$filename")
|
|
85
|
+
|
|
86
|
+
// Open the output stream for the output file
|
|
87
|
+
val outputStream: OutputStream = FileOutputStream(outputFile)
|
|
88
|
+
|
|
89
|
+
// Copy the contents from the input stream to the output stream
|
|
90
|
+
val buffer = ByteArray(1024)
|
|
91
|
+
var length: Int
|
|
92
|
+
while (inputStream.read(buffer).also { length = it } > 0) {
|
|
93
|
+
outputStream.write(buffer, 0, length)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Close the streams
|
|
97
|
+
inputStream.close()
|
|
98
|
+
outputStream.close()
|
|
99
|
+
|
|
100
|
+
promise.resolve(true)
|
|
101
|
+
} catch (exception: Exception) {
|
|
102
|
+
RNLog.e(this.reactApplicationContext, "Exception: $exception")
|
|
103
|
+
promise.resolve(false)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
override fun invalidate() {
|
|
108
|
+
super.invalidate()
|
|
109
|
+
OPSQLiteBridge.instance.invalidate()
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
companion object {
|
|
113
|
+
init {
|
|
114
|
+
System.loadLibrary("op-sqlite")
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const val NAME = "OPSQLite"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package com.op.sqlite
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
class OPSQLitePackage : ReactPackage {
|
|
9
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
10
|
+
return listOf<NativeModule>(OPSQLiteModule(reactContext))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override fun createViewManagers(
|
|
14
|
+
reactContext: ReactApplicationContext
|
|
15
|
+
): List<ViewManager<*, *>> {
|
|
16
|
+
return emptyList()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJavaSpec.js
|
|
9
|
+
*
|
|
10
|
+
* @nolint
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
package com.op.sqlite;
|
|
14
|
+
|
|
15
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
16
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
17
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
18
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
19
|
+
import com.facebook.react.common.build.ReactBuildConfig;
|
|
20
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
|
21
|
+
import java.util.Arrays;
|
|
22
|
+
import java.util.HashSet;
|
|
23
|
+
import java.util.Map;
|
|
24
|
+
import java.util.Set;
|
|
25
|
+
import javax.annotation.Nonnull;
|
|
26
|
+
import javax.annotation.Nullable;
|
|
27
|
+
|
|
28
|
+
public abstract class NativeOPSQLiteSpec extends ReactContextBaseJavaModule implements TurboModule {
|
|
29
|
+
public static final String NAME = "OPSQLite";
|
|
30
|
+
|
|
31
|
+
public NativeOPSQLiteSpec(ReactApplicationContext reactContext) {
|
|
32
|
+
super(reactContext);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@Override
|
|
36
|
+
public @Nonnull String getName() {
|
|
37
|
+
return NAME;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
protected abstract Map<String, Object> getTypedExportedConstants();
|
|
41
|
+
|
|
42
|
+
@Override
|
|
43
|
+
@DoNotStrip
|
|
44
|
+
public final @Nullable Map<String, Object> getConstants() {
|
|
45
|
+
Map<String, Object> constants = getTypedExportedConstants();
|
|
46
|
+
if (ReactBuildConfig.DEBUG || ReactBuildConfig.IS_INTERNAL_BUILD) {
|
|
47
|
+
Set<String> obligatoryFlowConstants = new HashSet<>(Arrays.asList(
|
|
48
|
+
"ANDROID_DATABASE_PATH",
|
|
49
|
+
"ANDROID_EXTERNAL_FILES_PATH",
|
|
50
|
+
"ANDROID_FILES_PATH",
|
|
51
|
+
"IOS_DOCUMENT_PATH",
|
|
52
|
+
"IOS_LIBRARY_PATH"
|
|
53
|
+
));
|
|
54
|
+
Set<String> optionalFlowConstants = new HashSet<>();
|
|
55
|
+
Set<String> undeclaredConstants = new HashSet<>(constants.keySet());
|
|
56
|
+
undeclaredConstants.removeAll(obligatoryFlowConstants);
|
|
57
|
+
undeclaredConstants.removeAll(optionalFlowConstants);
|
|
58
|
+
if (!undeclaredConstants.isEmpty()) {
|
|
59
|
+
throw new IllegalStateException(String.format("Native Module Flow doesn't declare constants: %s", undeclaredConstants));
|
|
60
|
+
}
|
|
61
|
+
undeclaredConstants = obligatoryFlowConstants;
|
|
62
|
+
undeclaredConstants.removeAll(constants.keySet());
|
|
63
|
+
if (!undeclaredConstants.isEmpty()) {
|
|
64
|
+
throw new IllegalStateException(String.format("Native Module doesn't fill in constants: %s", undeclaredConstants));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return constants;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
71
|
+
@DoNotStrip
|
|
72
|
+
public abstract boolean install();
|
|
73
|
+
|
|
74
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
75
|
+
@DoNotStrip
|
|
76
|
+
public abstract boolean moveAssetsDatabase(String name, String extension);
|
|
77
|
+
}
|