@op-engineering/op-sqlite 2.0.6 → 2.0.7-rc2

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.
@@ -2,15 +2,16 @@ import java.nio.file.Paths
2
2
 
3
3
  buildscript {
4
4
  repositories {
5
- maven {
6
- url "https://plugins.gradle.org/m2/"
7
- }
8
- mavenCentral()
9
5
  google()
6
+ gradlePluginPortal()
10
7
  }
11
8
 
9
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["OPSQLite_kotlinVersion"]
10
+
12
11
  dependencies {
13
- classpath("com.android.tools.build:gradle:7.2.2")
12
+ classpath("com.android.tools.build:gradle:7.3.1")
13
+ // noinspection DifferentKotlinGradleVersion
14
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
15
  }
15
16
  }
16
17
 
@@ -22,13 +23,17 @@ def resolveBuildType() {
22
23
  }
23
24
 
24
25
  def isNewArchitectureEnabled() {
25
- // - Set `newArchEnabled` to true inside the `gradle.properties` file
26
26
  return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
27
27
  }
28
28
 
29
29
  def SQLITE_FLAGS = rootProject.properties['OPSQLiteFlags']
30
30
 
31
+ if (isNewArchitectureEnabled()) {
32
+ apply plugin: "com.facebook.react"
33
+ }
34
+
31
35
  apply plugin: 'com.android.library'
36
+ apply plugin: "kotlin-android"
32
37
 
33
38
  def safeExtGet(prop, fallback) {
34
39
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
@@ -39,15 +44,16 @@ def reactNativeArchitectures() {
39
44
  return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
40
45
  }
41
46
 
42
- def USE_HERMES = rootProject.ext.hermesEnabled
43
-
44
- repositories {
45
- mavenCentral()
47
+ def getExtOrDefault(name) {
48
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["OPSQLite" + name]
46
49
  }
47
50
 
51
+ def USE_HERMES = rootProject.ext.hermesEnabled
52
+
48
53
  android {
49
54
 
50
- compileSdkVersion safeExtGet("compileSdkVersion", 28)
55
+ compileSdkVersion safeExtGet("compileSdkVersion", 33)
56
+ namespace "com.op.sqlite"
51
57
 
52
58
  // Used to override the NDK path/version on internal CI or by allowing
53
59
  // users to customize the NDK path/version from their root project (e.g. for M1 support)
@@ -64,7 +70,7 @@ android {
64
70
 
65
71
  defaultConfig {
66
72
  minSdkVersion 21
67
- targetSdkVersion safeExtGet('targetSdkVersion', 28)
73
+ targetSdkVersion safeExtGet('targetSdkVersion', 34)
68
74
  versionCode 1
69
75
  versionName "1.0"
70
76
 
@@ -104,11 +110,26 @@ android {
104
110
  path "CMakeLists.txt"
105
111
  }
106
112
  }
113
+
114
+ sourceSets.main {
115
+ java {
116
+ if (!isNewArchitectureEnabled()) {
117
+ srcDirs += 'src/paper/java'
118
+ }
119
+ }
120
+ }
107
121
  }
108
122
 
123
+ repositories {
124
+ mavenCentral()
125
+ google()
126
+ }
127
+
128
+ def kotlin_version = getExtOrDefault("kotlinVersion")
129
+
109
130
  dependencies {
110
- //noinspection GradleDynamicVersion
111
- implementation 'com.facebook.react:react-android:+'
131
+ implementation 'com.facebook.react:react-native'
132
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
112
133
  }
113
134
 
114
135
  // Resolves "LOCAL_SRC_FILES points to a missing file, Check that libfb.so exists or that its path is correct".
@@ -0,0 +1 @@
1
+ OPSQLite_kotlinVersion=1.8.0
@@ -0,0 +1,35 @@
1
+ package com.op.sqlite
2
+
3
+ import com.facebook.react.bridge.ReactContext
4
+ import com.facebook.react.turbomodule.core.CallInvokerHolderImpl
5
+
6
+ class OPSQLiteBridge {
7
+ private external fun installNativeJsi(
8
+ jsContextNativePointer: Long,
9
+ jsCallInvokerHolder: CallInvokerHolderImpl,
10
+ docPath: String
11
+ )
12
+
13
+ private external fun clearStateNativeJsi()
14
+ fun install(context: ReactContext) {
15
+ val jsContextPointer = context.javaScriptContextHolder!!.get()
16
+ val jsCallInvokerHolder =
17
+ context.catalystInstance.jsCallInvokerHolder as CallInvokerHolderImpl
18
+ // Trick to get the base database path
19
+ val dbPath =
20
+ context.getDatabasePath("defaultDatabase").absolutePath.replace("defaultDatabase", "")
21
+ installNativeJsi(
22
+ jsContextPointer,
23
+ jsCallInvokerHolder,
24
+ dbPath
25
+ )
26
+ }
27
+
28
+ fun clearState() {
29
+ clearStateNativeJsi()
30
+ }
31
+
32
+ companion object {
33
+ val instance = OPSQLiteBridge()
34
+ }
35
+ }
@@ -0,0 +1,53 @@
1
+ package com.op.sqlite
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
5
+ import com.facebook.react.bridge.ReactMethod
6
+ import com.facebook.react.module.annotations.ReactModule;
7
+
8
+ @ReactModule(name = OPSQLiteModule.NAME)
9
+ internal class OPSQLiteModule(context: ReactApplicationContext?) :
10
+ NativeOPSQLiteSpec(context) {
11
+ override fun getName(): String {
12
+ return NAME
13
+ }
14
+
15
+ override fun getTypedExportedConstants(): MutableMap<String, Any> {
16
+ val constants: MutableMap<String, Any> = HashMap()
17
+ val context = reactApplicationContext
18
+ val dbPath = context
19
+ .getDatabasePath("defaultDatabase")
20
+ .absolutePath
21
+ .replace("defaultDatabase", "")
22
+ constants["ANDROID_DATABASE_PATH"] = dbPath
23
+ val filesPath = context.filesDir.absolutePath
24
+ constants["ANDROID_FILES_PATH"] = filesPath
25
+ val externalFilesDir = context.getExternalFilesDir(null)!!.absolutePath
26
+ constants["ANDROID_EXTERNAL_FILES_PATH"] = externalFilesDir
27
+ constants["IOS_DOCUMENT_PATH"] = ""
28
+ constants["IOS_LIBRARY_PATH"] = ""
29
+ return constants
30
+ }
31
+
32
+ @ReactMethod(isBlockingSynchronousMethod = true)
33
+ override fun install(): Boolean {
34
+ return try {
35
+ OPSQLiteBridge.instance.install(reactApplicationContext)
36
+ true
37
+ } catch (exception: Exception) {
38
+ false
39
+ }
40
+ }
41
+
42
+ override fun onCatalystInstanceDestroy() {
43
+ OPSQLiteBridge.instance.clearState()
44
+ }
45
+
46
+ companion object {
47
+ init {
48
+ System.loadLibrary("op-sqlite")
49
+ }
50
+
51
+ const val NAME = "OPSQLite"
52
+ }
53
+ }
@@ -0,0 +1,38 @@
1
+ package com.op.sqlite
2
+
3
+
4
+ import com.facebook.react.TurboReactPackage
5
+ import com.facebook.react.bridge.NativeModule
6
+ import com.facebook.react.bridge.ReactApplicationContext
7
+ import com.facebook.react.module.model.ReactModuleInfoProvider
8
+ import com.facebook.react.module.annotations.ReactModuleList;
9
+ import com.facebook.react.module.model.ReactModuleInfo
10
+
11
+ //@ReactModuleList(
12
+ // nativeModules = {
13
+ // OPSQLiteModule.class,
14
+ // }
15
+ //)
16
+ class OPSQLitePackage : TurboReactPackage() {
17
+ override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
18
+ if(name == OPSQLiteModule.NAME) {
19
+ return OPSQLiteModule(reactContext)
20
+ } else {
21
+ return null
22
+ }
23
+ }
24
+
25
+ override fun getReactModuleInfoProvider() = ReactModuleInfoProvider {
26
+ mapOf(
27
+ OPSQLiteModule.NAME to ReactModuleInfo(
28
+ OPSQLiteModule.NAME,
29
+ OPSQLiteModule.NAME,
30
+ false, // canOverrideExistingModule
31
+ false, // needsEagerInit
32
+ true, // hasConstants
33
+ false, // isCxxModule
34
+ true // isTurboModule
35
+ )
36
+ )
37
+ }
38
+ }
@@ -0,0 +1,73 @@
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
+ }
package/ios/OPSQLite.h CHANGED
@@ -1,7 +1,15 @@
1
- #import <React/RCTBridgeModule.h>
2
- #import <React/RCTInvalidating.h>
1
+ #ifdef RCT_NEW_ARCH_ENABLED
2
+ #import <OPSQLiteSpec/OPSQLiteSpec.h>
3
+ #else
4
+ #import <React/RCTBridge.h>
5
+ #endif
3
6
 
4
- @interface OPSQLite : NSObject <RCTBridgeModule, RCTInvalidating>
7
+ @interface OPSQLite : NSObject
8
+ #ifdef RCT_NEW_ARCH_ENABLED
9
+ <NativeOPSQLiteSpec>
10
+ #else
11
+ <RCTBridgeModule>
12
+ #endif
5
13
 
6
14
  @property(nonatomic, assign) BOOL setBridgeOnMainQueue;
7
15
 
package/ios/OPSQLite.mm CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  @synthesize bridge=_bridge;
11
11
 
12
- RCT_EXPORT_MODULE(OPSQLite)
12
+ RCT_EXPORT_MODULE()
13
13
 
14
14
  - (void)setBridge:(RCTBridge *)bridge {
15
15
  _bridge = bridge;
@@ -32,6 +32,10 @@ RCT_EXPORT_MODULE(OPSQLite)
32
32
  };
33
33
  }
34
34
 
35
+ - (NSDictionary *)getConstants {
36
+ return [self constantsToExport];
37
+ }
38
+
35
39
  RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
36
40
  RCTCxxBridge *cxxBridge = (RCTCxxBridge *)_bridge;
37
41
  if (cxxBridge == nil) {
@@ -71,6 +75,15 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
71
75
  return @true;
72
76
  }
73
77
 
78
+
79
+ #if RCT_NEW_ARCH_ENABLED
80
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
81
+ (const facebook::react::ObjCTurboModule::InitParams &)params
82
+ {
83
+ return std::make_shared<facebook::react::NativeOPSQLiteSpecJSI>(params);
84
+ }
85
+ #endif
86
+
74
87
  - (void)invalidate {
75
88
  opsqlite::clearState();
76
89
  }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _default = _reactNative.TurboModuleRegistry.getEnforcing('OPSQLite');
9
+ exports.default = _default;
10
+ //# sourceMappingURL=NativeOPSQLite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeOPSQLite.ts"],"mappings":";;;;;;AAAA;AAAgE,eAcjDA,gCAAmB,CAACC,YAAY,CAAO,UAAU,CAAC;AAAA"}
@@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.open = exports.OPSQLite = exports.IOS_LIBRARY_PATH = exports.IOS_DOCUMENT_PATH = exports.ANDROID_FILES_PATH = exports.ANDROID_EXTERNAL_FILES_PATH = exports.ANDROID_DATABASE_PATH = void 0;
7
- var _reactNative = require("react-native");
7
+ var _NativeOPSQLite = _interopRequireDefault(require("./NativeOPSQLite"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
9
  if (global.__OPSQLiteProxy == null) {
9
- const OPSQLiteModule = _reactNative.NativeModules.OPSQLite;
10
+ const OPSQLiteModule = _NativeOPSQLite.default;
10
11
  if (OPSQLiteModule == null) {
11
12
  throw new Error('Base module not found. Maybe try rebuilding the app.');
12
13
  }
@@ -31,12 +32,17 @@ const proxy = global.__OPSQLiteProxy;
31
32
  const OPSQLite = proxy;
32
33
  exports.OPSQLite = OPSQLite;
33
34
  const {
35
+ // @ts-expect-error
34
36
  IOS_DOCUMENT_PATH,
37
+ // @ts-expect-error
35
38
  IOS_LIBRARY_PATH,
39
+ // @ts-expect-error
36
40
  ANDROID_DATABASE_PATH,
41
+ // @ts-expect-error
37
42
  ANDROID_FILES_PATH,
43
+ // @ts-expect-error
38
44
  ANDROID_EXTERNAL_FILES_PATH
39
- } = _reactNative.NativeModules.OPSQLite;
45
+ } = !!_NativeOPSQLite.default.getConstants ? _NativeOPSQLite.default.getConstants() : _NativeOPSQLite.default;
40
46
 
41
47
  /**
42
48
  * Object returned by SQL Query executions {
@@ -64,16 +70,10 @@ function enhanceQueryResult(result) {
64
70
  result.rows = {
65
71
  _array: [],
66
72
  length: 0,
67
- item: idx => {
68
- var _result$rows;
69
- return (_result$rows = result.rows) === null || _result$rows === void 0 ? void 0 : _result$rows._array[idx];
70
- }
73
+ item: idx => result.rows?._array[idx]
71
74
  };
72
75
  } else {
73
- result.rows.item = idx => {
74
- var _result$rows2;
75
- return (_result$rows2 = result.rows) === null || _result$rows2 === void 0 ? void 0 : _result$rows2._array[idx];
76
- };
76
+ result.rows.item = idx => result.rows?._array[idx];
77
77
  }
78
78
  }
79
79
  const _open = OPSQLite.open;
@@ -91,7 +91,7 @@ OPSQLite.close = dbName => {
91
91
  };
92
92
  const _execute = OPSQLite.execute;
93
93
  OPSQLite.execute = (dbName, query, params) => {
94
- const sanitizedParams = params === null || params === void 0 ? void 0 : params.map(p => {
94
+ const sanitizedParams = params?.map(p => {
95
95
  if (ArrayBuffer.isView(p)) {
96
96
  return p.buffer;
97
97
  }
@@ -103,7 +103,7 @@ OPSQLite.execute = (dbName, query, params) => {
103
103
  };
104
104
  const _executeAsync = OPSQLite.executeAsync;
105
105
  OPSQLite.executeAsync = async (dbName, query, params) => {
106
- const sanitizedParams = params === null || params === void 0 ? void 0 : params.map(p => {
106
+ const sanitizedParams = params?.map(p => {
107
107
  if (ArrayBuffer.isView(p)) {
108
108
  return p.buffer;
109
109
  }
@@ -1 +1 @@
1
- {"version":3,"names":["global","__OPSQLiteProxy","OPSQLiteModule","NativeModules","OPSQLite","Error","nativeCallSyncHook","install","result","proxy","IOS_DOCUMENT_PATH","IOS_LIBRARY_PATH","ANDROID_DATABASE_PATH","ANDROID_FILES_PATH","ANDROID_EXTERNAL_FILES_PATH","locks","enhanceQueryResult","rows","_array","length","item","idx","_open","open","dbName","location","queue","inProgress","_close","close","_execute","execute","query","params","sanitizedParams","map","p","ArrayBuffer","isView","buffer","_executeAsync","executeAsync","res","transaction","fn","isFinalized","commit","rollback","run","executionError","rollbackError","startNextTransaction","Promise","resolve","reject","tx","start","then","catch","push","shift","setImmediate","options","name","delete","attach","dbNameToAttach","alias","detach","executeBatch","commands","executeBatchAsync","loadFile","updateHook","callback","commitHook","rollbackHook","prepareStatement"],"sources":["index.ts"],"sourcesContent":["import { NativeModules } from 'react-native';\n\ndeclare global {\n function nativeCallSyncHook(): unknown;\n var __OPSQLiteProxy: object | undefined;\n}\n\nif (global.__OPSQLiteProxy == null) {\n const OPSQLiteModule = NativeModules.OPSQLite;\n\n if (OPSQLiteModule == null) {\n throw new Error('Base module not found. Maybe try rebuilding the app.');\n }\n\n // Check if we are running on-device (JSI)\n if (global.nativeCallSyncHook == null || OPSQLiteModule.install == null) {\n throw new Error(\n 'Failed to install op-sqlite: React Native is not running on-device. OPSQLite can only be used when synchronous method invocations (JSI) are possible. If you are using a remote debugger (e.g. Chrome), switch to an on-device debugger (e.g. Flipper) instead.'\n );\n }\n\n // Call the synchronous blocking install() function\n const result = OPSQLiteModule.install();\n if (result !== true) {\n throw new Error(\n `Failed to install op-sqlite: The native OPSQLite Module could not be installed! Looks like something went wrong when installing JSI bindings: ${result}`\n );\n }\n\n // Check again if the constructor now exists. If not, throw an error.\n if (global.__OPSQLiteProxy == null) {\n throw new Error(\n 'Failed to install op-sqlite, the native initializer function does not exist. Are you trying to use OPSQLite from different JS Runtimes?'\n );\n }\n}\n\nconst proxy = global.__OPSQLiteProxy;\nexport const OPSQLite = proxy as ISQLite;\n\nexport const {\n IOS_DOCUMENT_PATH,\n IOS_LIBRARY_PATH,\n ANDROID_DATABASE_PATH,\n ANDROID_FILES_PATH,\n ANDROID_EXTERNAL_FILES_PATH,\n} = NativeModules.OPSQLite;\n\n/**\n * Object returned by SQL Query executions {\n * insertId: Represent the auto-generated row id if applicable\n * rowsAffected: Number of affected rows if result of a update query\n * message: if status === 1, here you will find error description\n * rows: if status is undefined or 0 this object will contain the query results\n * }\n *\n * @interface QueryResult\n */\nexport type QueryResult = {\n insertId?: number;\n rowsAffected: number;\n rows?: {\n /** Raw array with all dataset */\n _array: any[];\n /** The lengh of the dataset */\n length: number;\n /** A convenience function to acess the index based the row object\n * @param idx the row index\n * @returns the row structure identified by column names\n */\n item: (idx: number) => any;\n };\n /**\n * Query metadata, avaliable only for select query results\n */\n metadata?: ColumnMetadata[];\n};\n\n/**\n * Column metadata\n * Describes some information about columns fetched by the query\n */\nexport type ColumnMetadata = {\n /** The name used for this column for this resultset */\n name: string;\n /** The declared column type for this column, when fetched directly from a table or a View resulting from a table column. \"UNKNOWN\" for dynamic values, like function returned ones. */\n type: string;\n /**\n * The index for this column for this resultset*/\n index: number;\n};\n\n/**\n * Allows the execution of bulk of sql commands\n * inside a transaction\n * If a single query must be executed many times with different arguments, its preferred\n * to declare it a single time, and use an array of array parameters.\n */\nexport type SQLBatchTuple = [string] | [string, Array<any> | Array<Array<any>>];\n\nexport type UpdateHookOperation = 'INSERT' | 'DELETE' | 'UPDATE';\n\n/**\n * status: 0 or undefined for correct execution, 1 for error\n * message: if status === 1, here you will find error description\n * rowsAffected: Number of affected rows if status == 0\n */\nexport type BatchQueryResult = {\n rowsAffected?: number;\n};\n\n/**\n * Result of loading a file and executing every line as a SQL command\n * Similar to BatchQueryResult\n */\nexport interface FileLoadResult extends BatchQueryResult {\n commands?: number;\n}\n\nexport interface Transaction {\n commit: () => QueryResult;\n execute: (query: string, params?: any[]) => QueryResult;\n executeAsync: (\n query: string,\n params?: any[] | undefined\n ) => Promise<QueryResult>;\n rollback: () => QueryResult;\n}\n\nexport interface PendingTransaction {\n /*\n * The start function should not throw or return a promise because the\n * queue just calls it and does not monitor for failures or completions.\n *\n * It should catch any errors and call the resolve or reject of the wrapping\n * promise when complete.\n *\n * It should also automatically commit or rollback the transaction if needed\n */\n start: () => void;\n}\n\nexport type PreparedStatementObj = {\n bind: (params: any[]) => void;\n execute: () => QueryResult;\n};\n\ninterface ISQLite {\n open: (dbName: string, location?: string) => void;\n close: (dbName: string) => void;\n delete: (dbName: string, location?: string) => void;\n attach: (\n mainDbName: string,\n dbNameToAttach: string,\n alias: string,\n location?: string\n ) => void;\n detach: (mainDbName: string, alias: string) => void;\n transaction: (\n dbName: string,\n fn: (tx: Transaction) => Promise<void>\n ) => Promise<void>;\n execute: (dbName: string, query: string, params?: any[]) => QueryResult;\n executeAsync: (\n dbName: string,\n query: string,\n params?: any[]\n ) => Promise<QueryResult>;\n executeBatch: (dbName: string, commands: SQLBatchTuple[]) => BatchQueryResult;\n executeBatchAsync: (\n dbName: string,\n commands: SQLBatchTuple[]\n ) => Promise<BatchQueryResult>;\n loadFile: (dbName: string, location: string) => Promise<FileLoadResult>;\n updateHook: (\n dbName: string,\n callback?:\n | ((params: {\n table: string;\n operation: UpdateHookOperation;\n row?: any;\n rowId: number;\n }) => void)\n | null\n ) => void;\n commitHook: (dbName: string, callback?: (() => void) | null) => void;\n rollbackHook: (dbName: string, callback?: (() => void) | null) => void;\n prepareStatement: (dbName: string, query: string) => PreparedStatementObj;\n}\n\nconst locks: Record<\n string,\n { queue: PendingTransaction[]; inProgress: boolean }\n> = {};\n\n// Enhance some host functions\n\n// Add 'item' function to result object to allow the sqlite-storage typeorm driver to work\nfunction enhanceQueryResult(result: QueryResult): void {\n // Add 'item' function to result object to allow the sqlite-storage typeorm driver to work\n if (result.rows == null) {\n result.rows = {\n _array: [],\n length: 0,\n item: (idx: number) => result.rows?._array[idx],\n };\n } else {\n result.rows.item = (idx: number) => result.rows?._array[idx];\n }\n}\n\nconst _open = OPSQLite.open;\nOPSQLite.open = (dbName: string, location?: string) => {\n _open(dbName, location);\n\n locks[dbName] = {\n queue: [],\n inProgress: false,\n };\n};\n\nconst _close = OPSQLite.close;\nOPSQLite.close = (dbName: string) => {\n _close(dbName);\n delete locks[dbName];\n};\n\nconst _execute = OPSQLite.execute;\nOPSQLite.execute = (\n dbName: string,\n query: string,\n params?: any[] | undefined\n): QueryResult => {\n const sanitizedParams = params?.map((p) => {\n if (ArrayBuffer.isView(p)) {\n return p.buffer;\n }\n\n return p;\n });\n\n const result = _execute(dbName, query, sanitizedParams);\n enhanceQueryResult(result);\n return result;\n};\n\nconst _executeAsync = OPSQLite.executeAsync;\nOPSQLite.executeAsync = async (\n dbName: string,\n query: string,\n params?: any[] | undefined\n): Promise<QueryResult> => {\n const sanitizedParams = params?.map((p) => {\n if (ArrayBuffer.isView(p)) {\n return p.buffer;\n }\n\n return p;\n });\n\n const res = await _executeAsync(dbName, query, sanitizedParams);\n enhanceQueryResult(res);\n return res;\n};\n\nOPSQLite.transaction = async (\n dbName: string,\n fn: (tx: Transaction) => Promise<void>\n): Promise<void> => {\n if (!locks[dbName]) {\n throw Error(`SQLite Error: No lock found on db: ${dbName}`);\n }\n\n let isFinalized = false;\n\n // Local transaction context object implementation\n const execute = (query: string, params?: any[]): QueryResult => {\n if (isFinalized) {\n throw Error(\n `SQLite Error: Cannot execute query on finalized transaction: ${dbName}`\n );\n }\n return OPSQLite.execute(dbName, query, params);\n };\n\n const executeAsync = (query: string, params?: any[] | undefined) => {\n if (isFinalized) {\n throw Error(\n `SQLite Error: Cannot execute query on finalized transaction: ${dbName}`\n );\n }\n return OPSQLite.executeAsync(dbName, query, params);\n };\n\n const commit = () => {\n if (isFinalized) {\n throw Error(\n `SQLite Error: Cannot execute commit on finalized transaction: ${dbName}`\n );\n }\n const result = OPSQLite.execute(dbName, 'COMMIT');\n isFinalized = true;\n return result;\n };\n\n const rollback = () => {\n if (isFinalized) {\n throw Error(\n `SQLite Error: Cannot execute rollback on finalized transaction: ${dbName}`\n );\n }\n const result = OPSQLite.execute(dbName, 'ROLLBACK');\n isFinalized = true;\n return result;\n };\n\n async function run() {\n try {\n await OPSQLite.executeAsync(dbName, 'BEGIN TRANSACTION');\n\n await fn({\n commit,\n execute,\n executeAsync,\n rollback,\n });\n\n if (!isFinalized) {\n commit();\n }\n } catch (executionError) {\n if (!isFinalized) {\n try {\n rollback();\n } catch (rollbackError) {\n throw rollbackError;\n }\n }\n\n throw executionError;\n } finally {\n locks[dbName].inProgress = false;\n isFinalized = false;\n startNextTransaction(dbName);\n }\n }\n\n return await new Promise((resolve, reject) => {\n const tx: PendingTransaction = {\n start: () => {\n run().then(resolve).catch(reject);\n },\n };\n\n locks[dbName].queue.push(tx);\n startNextTransaction(dbName);\n });\n};\n\nconst startNextTransaction = (dbName: string) => {\n if (!locks[dbName]) {\n throw Error(`Lock not found for db: ${dbName}`);\n }\n\n if (locks[dbName].inProgress) {\n // Transaction is already in process bail out\n return;\n }\n\n if (locks[dbName].queue.length) {\n locks[dbName].inProgress = true;\n const tx = locks[dbName].queue.shift();\n\n if (!tx) {\n throw new Error('Could not get a operation on datebase');\n }\n\n setImmediate(() => {\n tx.start();\n });\n }\n};\n\nexport type OPSQLiteConnection = {\n close: () => void;\n delete: () => void;\n attach: (dbNameToAttach: string, alias: string, location?: string) => void;\n detach: (alias: string) => void;\n transaction: (fn: (tx: Transaction) => Promise<void>) => Promise<void>;\n execute: (query: string, params?: any[]) => QueryResult;\n executeAsync: (query: string, params?: any[]) => Promise<QueryResult>;\n executeBatch: (commands: SQLBatchTuple[]) => BatchQueryResult;\n executeBatchAsync: (commands: SQLBatchTuple[]) => Promise<BatchQueryResult>;\n loadFile: (location: string) => Promise<FileLoadResult>;\n updateHook: (\n callback:\n | ((params: {\n table: string;\n operation: UpdateHookOperation;\n row?: any;\n rowId: number;\n }) => void)\n | null\n ) => void;\n commitHook: (callback: (() => void) | null) => void;\n rollbackHook: (callback: (() => void) | null) => void;\n prepareStatement: (query: string) => PreparedStatementObj;\n};\n\nexport const open = (options: {\n name: string;\n location?: string;\n}): OPSQLiteConnection => {\n OPSQLite.open(options.name, options.location);\n\n return {\n close: () => OPSQLite.close(options.name),\n delete: () => OPSQLite.delete(options.name, options.location),\n attach: (dbNameToAttach: string, alias: string, location?: string) =>\n OPSQLite.attach(options.name, dbNameToAttach, alias, location),\n detach: (alias: string) => OPSQLite.detach(options.name, alias),\n transaction: (fn: (tx: Transaction) => Promise<void>) =>\n OPSQLite.transaction(options.name, fn),\n execute: (query: string, params?: any[] | undefined): QueryResult =>\n OPSQLite.execute(options.name, query, params),\n executeAsync: (\n query: string,\n params?: any[] | undefined\n ): Promise<QueryResult> =>\n OPSQLite.executeAsync(options.name, query, params),\n executeBatch: (commands: SQLBatchTuple[]) =>\n OPSQLite.executeBatch(options.name, commands),\n executeBatchAsync: (commands: SQLBatchTuple[]) =>\n OPSQLite.executeBatchAsync(options.name, commands),\n loadFile: (location: string) => OPSQLite.loadFile(options.name, location),\n updateHook: (callback) => OPSQLite.updateHook(options.name, callback),\n commitHook: (callback) => OPSQLite.commitHook(options.name, callback),\n rollbackHook: (callback) => OPSQLite.rollbackHook(options.name, callback),\n prepareStatement: (query) => OPSQLite.prepareStatement(options.name, query),\n };\n};\n"],"mappings":";;;;;;AAAA;AAOA,IAAIA,MAAM,CAACC,eAAe,IAAI,IAAI,EAAE;EAClC,MAAMC,cAAc,GAAGC,0BAAa,CAACC,QAAQ;EAE7C,IAAIF,cAAc,IAAI,IAAI,EAAE;IAC1B,MAAM,IAAIG,KAAK,CAAC,sDAAsD,CAAC;EACzE;;EAEA;EACA,IAAIL,MAAM,CAACM,kBAAkB,IAAI,IAAI,IAAIJ,cAAc,CAACK,OAAO,IAAI,IAAI,EAAE;IACvE,MAAM,IAAIF,KAAK,CACb,iQAAiQ,CAClQ;EACH;;EAEA;EACA,MAAMG,MAAM,GAAGN,cAAc,CAACK,OAAO,EAAE;EACvC,IAAIC,MAAM,KAAK,IAAI,EAAE;IACnB,MAAM,IAAIH,KAAK,CACZ,iJAAgJG,MAAO,EAAC,CAC1J;EACH;;EAEA;EACA,IAAIR,MAAM,CAACC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EAAGD,QAAyB,IAC3ClE,QAAQ,CAACmE,iBAAiB,CAACT,OAAO,CAACC,IAAI,EAAEO,QAAQ,CAAC;IACpDE,QAAQ,EAAG/C,QAAgB,IAAKrB,QAAQ,CAACoE,QAAQ,CAACV,OAAO,CAACC,IAAI,EAAEtC,QAAQ,CAAC;IACzEgD,UAAU,EAAGC,QAAQ,IAAKtE,QAAQ,CAACqE,UAAU,CAACX,OAAO,CAACC,IAAI,EAAEW,QAAQ,CAAC;IACrEC,UAAU,EAAGD,QAAQ,IAAKtE,QAAQ,CAACuE,UAAU,CAACb,OAAO,CAACC,IAAI,EAAEW,QAAQ,CAAC;IACrEE,YAAY,EAAGF,QAAQ,IAAKtE,QAAQ,CAACwE,YAAY,CAACd,OAAO,CAACC,IAAI,EAAEW,QAAQ,CAAC;IACzEG,gBAAgB,EAAG7C,KAAK,IAAK5B,QAAQ,CAACyE,gBAAgB,CAACf,OAAO,CAACC,IAAI,EAAE/B,KAAK;EAC5E,CAAC;AACH,CAAC;AAAC"}
1
+ {"version":3,"names":["global","__OPSQLiteProxy","OPSQLiteModule","NativeOPSQLite","Error","nativeCallSyncHook","install","result","proxy","OPSQLite","IOS_DOCUMENT_PATH","IOS_LIBRARY_PATH","ANDROID_DATABASE_PATH","ANDROID_FILES_PATH","ANDROID_EXTERNAL_FILES_PATH","getConstants","locks","enhanceQueryResult","rows","_array","length","item","idx","_open","open","dbName","location","queue","inProgress","_close","close","_execute","execute","query","params","sanitizedParams","map","p","ArrayBuffer","isView","buffer","_executeAsync","executeAsync","res","transaction","fn","isFinalized","commit","rollback","run","executionError","rollbackError","startNextTransaction","Promise","resolve","reject","tx","start","then","catch","push","shift","setImmediate","options","name","delete","attach","dbNameToAttach","alias","detach","executeBatch","commands","executeBatchAsync","loadFile","updateHook","callback","commitHook","rollbackHook","prepareStatement"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;AAAA;AAA8C;AAO9C,IAAIA,MAAM,CAACC,eAAe,IAAI,IAA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mB,OAAO,CAACC,IAAI,EAAEnB,EAAE,CAAC;IACxCb,OAAO,EAAE,CAACC,KAAa,EAAEC,MAA0B,KACjDzB,QAAQ,CAACuB,OAAO,CAAC+B,OAAO,CAACC,IAAI,EAAE/B,KAAK,EAAEC,MAAM,CAAC;IAC/CQ,YAAY,EAAE,CACZT,KAAa,EACbC,MAA0B,KAE1BzB,QAAQ,CAACiC,YAAY,CAACqB,OAAO,CAACC,IAAI,EAAE/B,KAAK,EAAEC,MAAM,CAAC;IACpDoC,YAAY,EAAGC,QAAyB,IACtC9D,QAAQ,CAAC6D,YAAY,CAACP,OAAO,CAACC,IAAI,EAAEO,QAAQ,CAAC;IAC/CC,iBAAiB,EAAGD,QAAyB,IAC3C9D,QAAQ,CAAC+D,iBAAiB,CAACT,OAAO,CAACC,IAAI,EAAEO,QAAQ,CAAC;IACpDE,QAAQ,EAAG/C,QAAgB,IAAKjB,QAAQ,CAACgE,QAAQ,CAACV,OAAO,CAACC,IAAI,EAAEtC,QAAQ,CAAC;IACzEgD,UAAU,EAAGC,QAAQ,IAAKlE,QAAQ,CAACiE,UAAU,CAACX,OAAO,CAACC,IAAI,EAAEW,QAAQ,CAAC;IACrEC,UAAU,EAAGD,QAAQ,IAAKlE,QAAQ,CAACmE,UAAU,CAACb,OAAO,CAACC,IAAI,EAAEW,QAAQ,CAAC;IACrEE,YAAY,EAAGF,QAAQ,IAAKlE,QAAQ,CAACoE,YAAY,CAACd,OAAO,CAACC,IAAI,EAAEW,QAAQ,CAAC;IACzEG,gBAAgB,EAAG7C,KAAK,IAAKxB,QAAQ,CAACqE,gBAAgB,CAACf,OAAO,CAACC,IAAI,EAAE/B,KAAK;EAC5E,CAAC;AACH,CAAC;AAAC"}
@@ -0,0 +1,3 @@
1
+ import { TurboModuleRegistry } from 'react-native';
2
+ export default TurboModuleRegistry.getEnforcing('OPSQLite');
3
+ //# sourceMappingURL=NativeOPSQLite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeOPSQLite.ts"],"mappings":"AAAA,SAASA,mBAAmB,QAAqB,cAAc;AAc/D,eAAeA,mBAAmB,CAACC,YAAY,CAAO,UAAU,CAAC"}
@@ -1,6 +1,6 @@
1
- import { NativeModules } from 'react-native';
1
+ import NativeOPSQLite from './NativeOPSQLite';
2
2
  if (global.__OPSQLiteProxy == null) {
3
- const OPSQLiteModule = NativeModules.OPSQLite;
3
+ const OPSQLiteModule = NativeOPSQLite;
4
4
  if (OPSQLiteModule == null) {
5
5
  throw new Error('Base module not found. Maybe try rebuilding the app.');
6
6
  }
@@ -24,12 +24,17 @@ if (global.__OPSQLiteProxy == null) {
24
24
  const proxy = global.__OPSQLiteProxy;
25
25
  export const OPSQLite = proxy;
26
26
  export const {
27
+ // @ts-expect-error
27
28
  IOS_DOCUMENT_PATH,
29
+ // @ts-expect-error
28
30
  IOS_LIBRARY_PATH,
31
+ // @ts-expect-error
29
32
  ANDROID_DATABASE_PATH,
33
+ // @ts-expect-error
30
34
  ANDROID_FILES_PATH,
35
+ // @ts-expect-error
31
36
  ANDROID_EXTERNAL_FILES_PATH
32
- } = NativeModules.OPSQLite;
37
+ } = !!NativeOPSQLite.getConstants ? NativeOPSQLite.getConstants() : NativeOPSQLite;
33
38
 
34
39
  /**
35
40
  * Object returned by SQL Query executions {
@@ -53,16 +58,10 @@ function enhanceQueryResult(result) {
53
58
  result.rows = {
54
59
  _array: [],
55
60
  length: 0,
56
- item: idx => {
57
- var _result$rows;
58
- return (_result$rows = result.rows) === null || _result$rows === void 0 ? void 0 : _result$rows._array[idx];
59
- }
61
+ item: idx => result.rows?._array[idx]
60
62
  };
61
63
  } else {
62
- result.rows.item = idx => {
63
- var _result$rows2;
64
- return (_result$rows2 = result.rows) === null || _result$rows2 === void 0 ? void 0 : _result$rows2._array[idx];
65
- };
64
+ result.rows.item = idx => result.rows?._array[idx];
66
65
  }
67
66
  }
68
67
  const _open = OPSQLite.open;
@@ -80,7 +79,7 @@ OPSQLite.close = dbName => {
80
79
  };
81
80
  const _execute = OPSQLite.execute;
82
81
  OPSQLite.execute = (dbName, query, params) => {
83
- const sanitizedParams = params === null || params === void 0 ? void 0 : params.map(p => {
82
+ const sanitizedParams = params?.map(p => {
84
83
  if (ArrayBuffer.isView(p)) {
85
84
  return p.buffer;
86
85
  }
@@ -92,7 +91,7 @@ OPSQLite.execute = (dbName, query, params) => {
92
91
  };
93
92
  const _executeAsync = OPSQLite.executeAsync;
94
93
  OPSQLite.executeAsync = async (dbName, query, params) => {
95
- const sanitizedParams = params === null || params === void 0 ? void 0 : params.map(p => {
94
+ const sanitizedParams = params?.map(p => {
96
95
  if (ArrayBuffer.isView(p)) {
97
96
  return p.buffer;
98
97
  }
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","global","__OPSQLiteProxy","OPSQLiteModule","OPSQLite","Error","nativeCallSyncHook","install","result","proxy","IOS_DOCUMENT_PATH","IOS_LIBRARY_PATH","ANDROID_DATABASE_PATH","ANDROID_FILES_PATH","ANDROID_EXTERNAL_FILES_PATH","locks","enhanceQueryResult","rows","_array","length","item","idx","_open","open","dbName","location","queue","inProgress","_close","close","_execute","execute","query","params","sanitizedParams","map","p","ArrayBuffer","isView","buffer","_executeAsync","executeAsync","res","transaction","fn","isFinalized","commit","rollback","run","executionError","rollbackError","startNextTransaction","Promise","resolve","reject","tx","start","then","catch","push","shift","setImmediate","options","name","delete","attach","dbNameToAttach","alias","detach","executeBatch","commands","executeBatchAsync","loadFile","updateHook","callback","commitHook","rollbackHook","prepareStatement"],"sources":["index.ts"],"sourcesContent":["import { NativeModules } from 'react-native';\n\ndeclare global {\n function nativeCallSyncHook(): unknown;\n var __OPSQLiteProxy: object | undefined;\n}\n\nif (global.__OPSQLiteProxy == null) {\n const OPSQLiteModule = NativeModules.OPSQLite;\n\n if (OPSQLiteModule == null) {\n throw new Error('Base module not found. Maybe try rebuilding the app.');\n }\n\n // Check if we are running on-device (JSI)\n if (global.nativeCallSyncHook == null || OPSQLiteModule.install == null) {\n throw new Error(\n 'Failed to install op-sqlite: React Native is not running on-device. OPSQLite can only be used when synchronous method invocations (JSI) are possible. If you are using a remote debugger (e.g. Chrome), switch to an on-device debugger (e.g. Flipper) instead.'\n );\n }\n\n // Call the synchronous blocking install() function\n const result = OPSQLiteModule.install();\n if (result !== true) {\n throw new Error(\n `Failed to install op-sqlite: The native OPSQLite Module could not be installed! Looks like something went wrong when installing JSI bindings: ${result}`\n );\n }\n\n // Check again if the constructor now exists. If not, throw an error.\n if (global.__OPSQLiteProxy == null) {\n throw new Error(\n 'Failed to install op-sqlite, the native initializer function does not exist. Are you trying to use OPSQLite from different JS Runtimes?'\n );\n }\n}\n\nconst proxy = global.__OPSQLiteProxy;\nexport const OPSQLite = proxy as ISQLite;\n\nexport const {\n IOS_DOCUMENT_PATH,\n IOS_LIBRARY_PATH,\n ANDROID_DATABASE_PATH,\n ANDROID_FILES_PATH,\n ANDROID_EXTERNAL_FILES_PATH,\n} = NativeModules.OPSQLite;\n\n/**\n * Object returned by SQL Query executions {\n * insertId: Represent the auto-generated row id if applicable\n * rowsAffected: Number of affected rows if result of a update query\n * message: if status === 1, here you will find error description\n * rows: if status is undefined or 0 this object will contain the query results\n * }\n *\n * @interface QueryResult\n */\nexport type QueryResult = {\n insertId?: number;\n rowsAffected: number;\n rows?: {\n /** Raw array with all dataset */\n _array: any[];\n /** The lengh of the dataset */\n length: number;\n /** A convenience function to acess the index based the row object\n * @param idx the row index\n * @returns the row structure identified by column names\n */\n item: (idx: number) => any;\n };\n /**\n * Query metadata, avaliable only for select query results\n */\n metadata?: ColumnMetadata[];\n};\n\n/**\n * Column metadata\n * Describes some information about columns fetched by the query\n */\nexport type ColumnMetadata = {\n /** The name used for this column for this resultset */\n name: string;\n /** The declared column type for this column, when fetched directly from a table or a View resulting from a table column. \"UNKNOWN\" for dynamic values, like function returned ones. */\n type: string;\n /**\n * The index for this column for this resultset*/\n index: number;\n};\n\n/**\n * Allows the execution of bulk of sql commands\n * inside a transaction\n * If a single query must be executed many times with different arguments, its preferred\n * to declare it a single time, and use an array of array parameters.\n */\nexport type SQLBatchTuple = [string] | [string, Array<any> | Array<Array<any>>];\n\nexport type UpdateHookOperation = 'INSERT' | 'DELETE' | 'UPDATE';\n\n/**\n * status: 0 or undefined for correct execution, 1 for error\n * message: if status === 1, here you will find error description\n * rowsAffected: Number of affected rows if status == 0\n */\nexport type BatchQueryResult = {\n rowsAffected?: number;\n};\n\n/**\n * Result of loading a file and executing every line as a SQL command\n * Similar to BatchQueryResult\n */\nexport interface FileLoadResult extends BatchQueryResult {\n commands?: number;\n}\n\nexport interface Transaction {\n commit: () => QueryResult;\n execute: (query: string, params?: any[]) => QueryResult;\n executeAsync: (\n query: string,\n params?: any[] | undefined\n ) => Promise<QueryResult>;\n rollback: () => QueryResult;\n}\n\nexport interface PendingTransaction {\n /*\n * The start function should not throw or return a promise because the\n * queue just calls it and does not monitor for failures or completions.\n *\n * It should catch any errors and call the resolve or reject of the wrapping\n * promise when complete.\n *\n * It should also automatically commit or rollback the transaction if needed\n */\n start: () => void;\n}\n\nexport type PreparedStatementObj = {\n bind: (params: any[]) => void;\n execute: () => QueryResult;\n};\n\ninterface ISQLite {\n open: (dbName: string, location?: string) => void;\n close: (dbName: string) => void;\n delete: (dbName: string, location?: string) => void;\n attach: (\n mainDbName: string,\n dbNameToAttach: string,\n alias: string,\n location?: string\n ) => void;\n detach: (mainDbName: string, alias: string) => void;\n transaction: (\n dbName: string,\n fn: (tx: Transaction) => Promise<void>\n ) => Promise<void>;\n execute: (dbName: string, query: string, params?: any[]) => QueryResult;\n executeAsync: (\n dbName: string,\n query: string,\n params?: any[]\n ) => Promise<QueryResult>;\n executeBatch: (dbName: string, commands: SQLBatchTuple[]) => BatchQueryResult;\n executeBatchAsync: (\n dbName: string,\n commands: SQLBatchTuple[]\n ) => Promise<BatchQueryResult>;\n loadFile: (dbName: string, location: string) => Promise<FileLoadResult>;\n updateHook: (\n dbName: string,\n callback?:\n | ((params: {\n table: string;\n operation: UpdateHookOperation;\n row?: any;\n rowId: number;\n }) => void)\n | null\n ) => void;\n commitHook: (dbName: string, callback?: (() => void) | null) => void;\n rollbackHook: (dbName: string, callback?: (() => void) | null) => void;\n prepareStatement: (dbName: string, query: string) => PreparedStatementObj;\n}\n\nconst locks: Record<\n string,\n { queue: PendingTransaction[]; inProgress: boolean }\n> = {};\n\n// Enhance some host functions\n\n// Add 'item' function to result object to allow the sqlite-storage typeorm driver to work\nfunction enhanceQueryResult(result: QueryResult): void {\n // Add 'item' function to result object to allow the sqlite-storage typeorm driver to work\n if (result.rows == null) {\n result.rows = {\n _array: [],\n length: 0,\n item: (idx: number) => result.rows?._array[idx],\n };\n } else {\n result.rows.item = (idx: number) => result.rows?._array[idx];\n }\n}\n\nconst _open = OPSQLite.open;\nOPSQLite.open = (dbName: string, location?: string) => {\n _open(dbName, location);\n\n locks[dbName] = {\n queue: [],\n inProgress: false,\n };\n};\n\nconst _close = OPSQLite.close;\nOPSQLite.close = (dbName: string) => {\n _close(dbName);\n delete locks[dbName];\n};\n\nconst _execute = OPSQLite.execute;\nOPSQLite.execute = (\n dbName: string,\n query: string,\n params?: any[] | undefined\n): QueryResult => {\n const sanitizedParams = params?.map((p) => {\n if (ArrayBuffer.isView(p)) {\n return p.buffer;\n }\n\n return p;\n });\n\n const result = _execute(dbName, query, sanitizedParams);\n enhanceQueryResult(result);\n return result;\n};\n\nconst _executeAsync = OPSQLite.executeAsync;\nOPSQLite.executeAsync = async (\n dbName: string,\n query: string,\n params?: any[] | undefined\n): Promise<QueryResult> => {\n const sanitizedParams = params?.map((p) => {\n if (ArrayBuffer.isView(p)) {\n return p.buffer;\n }\n\n return p;\n });\n\n const res = await _executeAsync(dbName, query, sanitizedParams);\n enhanceQueryResult(res);\n return res;\n};\n\nOPSQLite.transaction = async (\n dbName: string,\n fn: (tx: Transaction) => Promise<void>\n): Promise<void> => {\n if (!locks[dbName]) {\n throw Error(`SQLite Error: No lock found on db: ${dbName}`);\n }\n\n let isFinalized = false;\n\n // Local transaction context object implementation\n const execute = (query: string, params?: any[]): QueryResult => {\n if (isFinalized) {\n throw Error(\n `SQLite Error: Cannot execute query on finalized transaction: ${dbName}`\n );\n }\n return OPSQLite.execute(dbName, query, params);\n };\n\n const executeAsync = (query: string, params?: any[] | undefined) => {\n if (isFinalized) {\n throw Error(\n `SQLite Error: Cannot execute query on finalized transaction: ${dbName}`\n );\n }\n return OPSQLite.executeAsync(dbName, query, params);\n };\n\n const commit = () => {\n if (isFinalized) {\n throw Error(\n `SQLite Error: Cannot execute commit on finalized transaction: ${dbName}`\n );\n }\n const result = OPSQLite.execute(dbName, 'COMMIT');\n isFinalized = true;\n return result;\n };\n\n const rollback = () => {\n if (isFinalized) {\n throw Error(\n `SQLite Error: Cannot execute rollback on finalized transaction: ${dbName}`\n );\n }\n const result = OPSQLite.execute(dbName, 'ROLLBACK');\n isFinalized = true;\n return result;\n };\n\n async function run() {\n try {\n await OPSQLite.executeAsync(dbName, 'BEGIN TRANSACTION');\n\n await fn({\n commit,\n execute,\n executeAsync,\n rollback,\n });\n\n if (!isFinalized) {\n commit();\n }\n } catch (executionError) {\n if (!isFinalized) {\n try {\n rollback();\n } catch (rollbackError) {\n throw rollbackError;\n }\n }\n\n throw executionError;\n } finally {\n locks[dbName].inProgress = false;\n isFinalized = false;\n startNextTransaction(dbName);\n }\n }\n\n return await new Promise((resolve, reject) => {\n const tx: PendingTransaction = {\n start: () => {\n run().then(resolve).catch(reject);\n },\n };\n\n locks[dbName].queue.push(tx);\n startNextTransaction(dbName);\n });\n};\n\nconst startNextTransaction = (dbName: string) => {\n if (!locks[dbName]) {\n throw Error(`Lock not found for db: ${dbName}`);\n }\n\n if (locks[dbName].inProgress) {\n // Transaction is already in process bail out\n return;\n }\n\n if (locks[dbName].queue.length) {\n locks[dbName].inProgress = true;\n const tx = locks[dbName].queue.shift();\n\n if (!tx) {\n throw new Error('Could not get a operation on datebase');\n }\n\n setImmediate(() => {\n tx.start();\n });\n }\n};\n\nexport type OPSQLiteConnection = {\n close: () => void;\n delete: () => void;\n attach: (dbNameToAttach: string, alias: string, location?: string) => void;\n detach: (alias: string) => void;\n transaction: (fn: (tx: Transaction) => Promise<void>) => Promise<void>;\n execute: (query: string, params?: any[]) => QueryResult;\n executeAsync: (query: string, params?: any[]) => Promise<QueryResult>;\n executeBatch: (commands: SQLBatchTuple[]) => BatchQueryResult;\n executeBatchAsync: (commands: SQLBatchTuple[]) => Promise<BatchQueryResult>;\n loadFile: (location: string) => Promise<FileLoadResult>;\n updateHook: (\n callback:\n | ((params: {\n table: string;\n operation: UpdateHookOperation;\n row?: any;\n rowId: number;\n }) => void)\n | null\n ) => void;\n commitHook: (callback: (() => void) | null) => void;\n rollbackHook: (callback: (() => void) | null) => void;\n prepareStatement: (query: string) => PreparedStatementObj;\n};\n\nexport const open = (options: {\n name: string;\n location?: string;\n}): OPSQLiteConnection => {\n OPSQLite.open(options.name, options.location);\n\n return {\n close: () => OPSQLite.close(options.name),\n delete: () => OPSQLite.delete(options.name, options.location),\n attach: (dbNameToAttach: string, alias: string, location?: string) =>\n OPSQLite.attach(options.name, dbNameToAttach, alias, location),\n detach: (alias: string) => OPSQLite.detach(options.name, alias),\n transaction: (fn: (tx: Transaction) => Promise<void>) =>\n OPSQLite.transaction(options.name, fn),\n execute: (query: string, params?: any[] | undefined): QueryResult =>\n OPSQLite.execute(options.name, query, params),\n executeAsync: (\n query: string,\n params?: any[] | undefined\n ): Promise<QueryResult> =>\n OPSQLite.executeAsync(options.name, query, params),\n executeBatch: (commands: SQLBatchTuple[]) =>\n OPSQLite.executeBatch(options.name, commands),\n executeBatchAsync: (commands: SQLBatchTuple[]) =>\n OPSQLite.executeBatchAsync(options.name, commands),\n loadFile: (location: string) => OPSQLite.loadFile(options.name, location),\n updateHook: (callback) => OPSQLite.updateHook(options.name, callback),\n commitHook: (callback) => OPSQLite.commitHook(options.name, callback),\n rollbackHook: (callback) => OPSQLite.rollbackHook(options.name, callback),\n prepareStatement: (query) => OPSQLite.prepareStatement(options.name, query),\n };\n};\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAO5C,IAAIC,MAAM,CAACC,eAAe,IAAI,IAAI,EAAE;EAClC,MAAMC,cAAc,GAAGH,aAAa,CAACI,QAAQ;EAE7C,IAAID,cAAc,IAAI,IAAI,EAAE;IAC1B,MAAM,IAAIE,KAAK,CAAC,sDAAsD,CAAC;EACzE;;EAEA;EACA,IAAIJ,MAAM,CAACK,kBAAkB,IAAI,IAAI,IAAIH,cAAc,CAACI,OAAO,IAAI,IAAI,EAAE;IACvE,MAAM,IAAIF,KAAK,CACb,iQAAiQ,CAClQ;EACH;;EAEA;EACA,MAAMG,MAAM,GAAGL,cAAc,CAACI,OAAO,EAAE;EACvC,IAAIC,MAAM,KAAK,IAAI,EAAE;IACnB,MAAM,IAAIH,KAAK,CACZ,iJAAgJG,MAAO,EAAC,CAC1J;EACH;;EAEA;EACA,IAAIP,MAAM,CAACC,eAAe,IAAI,IAAI,EAAE;IAClC,MAAM,IAAIG,KAAK,CACb,yIAAyI,CAC1I;EACH;AACF;AAEA,MAAMI,KAAK,GAAGR,MAAM,CAACC,eAAe;AACpC,OAAO,MAAME,QAAQ,GAAGK,KAAgB;AAExC,OAAO,MAAM;EACXC,iBAAiB;EACjBC,gBAAgB;EAChBC,qBAAqB;EACrBC,kBAAkB;EAClBC;AACF,CAAC,GAAGd,aAAa,CAACI,QAAQ;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqIA,MAAMW,KAGL,GAAG,CAAC,CAAC;;AAEN;;AAEA;AACA,SAASC,kBAAkB,CAACR,MAAmB,EAAQ;EACrD;EACA,IAAIA,MAAM,CAACS,IAAI,IAAI,IAAI,EAAE;IACvBT,MAAM,CAACS,IAAI,GAAG;MACZC,MAAM,EAAE,EAAE;MACVC,MAAM,EAAE,CAAC;MACTC,IAAI,EAAGC,GAAW;QAAA;QAAA,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C"}
1
+ {"version":3,"names":["NativeOPSQLite","global","__OPSQLiteProxy","OPSQLiteModule","Error","nativeCallSyncHook","install","result","proxy","OPSQLite","IOS_DOCUMENT_PATH","IOS_LIBRARY_PATH","ANDROID_DATABASE_PATH","ANDROID_FILES_PATH","ANDROID_EXTERNAL_FILES_PATH","getConstants","locks","enhanceQueryResult","rows","_array","length","item","idx","_open","open","dbName","location","queue","inProgress","_close","close","_execute","execute","query","params","sanitizedParams","map","p","ArrayBuffer","isView","buffer","_executeAsync","executeAsync","res","transaction","fn","isFinalized","commit","rollback","run","executionError","rollbackError","startNextTransaction","Promise","resolve","reject","tx","start","then","catch","push","shift","setImmediate","options","name","delete","attach","dbNameToAttach","alias","detach","executeBatch","commands","executeBatchAsync","loadFile","updateHook","callback","commitHook","rollbackHook","prepareStatement"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,OAAOA,cAAc,MAAM,kBAAkB;AAO7C,IAAIC,MAAM,CAACC,eAAe,IAAI,IAAI,EAAE;EAClC,MAAMC,cAAc,GAAGH,cAAc;EAErC,IAAIG,cAAc,IAAI,IAAI,EAAE;IAC1B,MAAM,IAAIC,KAAK,CAAC,sDAAsD,CAAC;EACzE;;EAEA;EACA,IAAIH,MAAM,CAACI,kBAAkB,IAAI,IAAI,IAAIF,cAAc,CAACG,OAAO,IAAI,IAAI,EAAE;IACvE,MAAM,IAAIF,KAAK,CACb,iQAAiQ,CAClQ;EACH;;EAEA;EACA,MAAMG,MAAM,GAAGJ,cAAc,CAACG,OAAO,EAAE;EACvC,IAAIC,MAAM,KAAK,IAAI,EAAE;IACnB,MAAM,IAAIH,KAAK,CACZ,iJAAgJG,MAAO,EAAC,CAC1J;EACH;;EAEA;EACA,IAAIN,MAAM,CAACC,eAAe,IAAI,IAAI,EAAE;IAClC,MAAM,IAAIE,KAAK,CACb,yIAAyI,CAC1I;EACH;AACF;AAEA,MAAMI,KAAK,GAAGP,MAAM,CAACC,eAAe;AACpC,OAAO,MAAMO,QA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EgD,UAAU,EAAGC,QAAQ,IAAKlE,QAAQ,CAACiE,UAAU,CAACX,OAAO,CAACC,IAAI,EAAEW,QAAQ,CAAC;IACrEC,UAAU,EAAGD,QAAQ,IAAKlE,QAAQ,CAACmE,UAAU,CAACb,OAAO,CAACC,IAAI,EAAEW,QAAQ,CAAC;IACrEE,YAAY,EAAGF,QAAQ,IAAKlE,QAAQ,CAACoE,YAAY,CAACd,OAAO,CAACC,IAAI,EAAEW,QAAQ,CAAC;IACzEG,gBAAgB,EAAG7C,KAAK,IAAKxB,QAAQ,CAACqE,gBAAgB,CAACf,OAAO,CAACC,IAAI,EAAE/B,KAAK;EAC5E,CAAC;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { TurboModule } from 'react-native';
2
+ export interface Spec extends TurboModule {
3
+ getConstants: () => {
4
+ IOS_DOCUMENT_PATH: string;
5
+ IOS_LIBRARY_PATH: string;
6
+ ANDROID_DATABASE_PATH: string;
7
+ ANDROID_FILES_PATH: string;
8
+ ANDROID_EXTERNAL_FILES_PATH: string;
9
+ };
10
+ install(): boolean;
11
+ }
12
+ declare const _default: Spec;
13
+ export default _default;
14
+ //# sourceMappingURL=NativeOPSQLite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeOPSQLite.d.ts","sourceRoot":"","sources":["../../src/NativeOPSQLite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhE,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,YAAY,EAAE,MAAM;QAClB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,gBAAgB,EAAE,MAAM,CAAC;QACzB,qBAAqB,EAAE,MAAM,CAAC;QAC9B,kBAAkB,EAAE,MAAM,CAAC;QAC3B,2BAA2B,EAAE,MAAM,CAAC;KACrC,CAAC;IAEF,OAAO,IAAI,OAAO,CAAC;CACpB;;AAED,wBAAkE"}
@@ -130,3 +130,4 @@ export declare const open: (options: {
130
130
  location?: string;
131
131
  }) => OPSQLiteConnection;
132
132
  export {};
133
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,CAAC;IACb,SAAS,kBAAkB,IAAI,OAAO,CAAC;IACvC,IAAI,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AAiCD,eAAO,MAAM,QAAQ,SAAmB,CAAC;AAEzC,eAAO,MAEL,iBAAiB,OAEjB,gBAAgB,OAEhB,qBAAqB,OAErB,kBAAkB,OAElB,2BAA2B,KAGX,CAAC;AAEnB;;;;;;;;;GASG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE;QACL,iCAAiC;QACjC,MAAM,EAAE,GAAG,EAAE,CAAC;QACd,+BAA+B;QAC/B,MAAM,EAAE,MAAM,CAAC;QACf;;;WAGG;QACH,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAC;KAC5B,CAAC;IACF;;OAEG;IACH,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC7B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,uLAAuL;IACvL,IAAI,EAAE,MAAM,CAAC;IACb;qDACiD;IACjD,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAEhF,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAA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CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IACpD,YAAY,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IACtD,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,oBAAoB,CAAC;CAC3D,CAAC;AAEF,eAAO,MAAM,IAAI,YAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,KAAG,kBA4BH,CAAC"}
package/op-sqlite.podspec CHANGED
@@ -2,6 +2,7 @@ require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
4
  folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+ fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
5
6
 
6
7
  Pod::Spec.new do |s|
7
8
  s.name = "op-sqlite"
@@ -17,7 +18,8 @@ Pod::Spec.new do |s|
17
18
  s.pod_target_xcconfig = {
18
19
  :GCC_PREPROCESSOR_DEFINITIONS => "HAVE_FULLFSYNC=1",
19
20
  :WARNING_CFLAGS => "-Wno-shorten-64-to-32 -Wno-comma -Wno-unreachable-code -Wno-conditional-uninitialized -Wno-deprecated-declarations",
20
- :USE_HEADERMAP => "No"
21
+ :USE_HEADERMAP => "No",
22
+ :CLANG_CXX_LANGUAGE_STANDARD => "c++17"
21
23
  }
22
24
 
23
25
  s.header_mappings_dir = "cpp"
@@ -25,11 +27,11 @@ Pod::Spec.new do |s|
25
27
 
26
28
  s.dependency "React-callinvoker"
27
29
  s.dependency "React"
28
- s.dependency "React-Core"
29
-
30
- s.xcconfig = {
31
- 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
32
- }
30
+ if fabric_enabled then
31
+ install_modules_dependencies(s)
32
+ else
33
+ s.dependency "React-Core"
34
+ end
33
35
 
34
36
  if ENV['OP_SQLITE_USE_PHONE_VERSION'] == '1' then
35
37
  s.exclude_files = "cpp/sqlite3.c", "cpp/sqlite3.h"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@op-engineering/op-sqlite",
3
- "version": "2.0.6",
3
+ "version": "2.0.7-rc2",
4
4
  "description": "Next generation SQLite for React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -48,14 +48,22 @@
48
48
  "devDependencies": {
49
49
  "lefthook": "^1.5.5",
50
50
  "react": "18.2.0",
51
- "react-native": "0.72.6",
52
- "react-native-builder-bob": "^0.18.2",
53
- "typescript": "^4.8.4"
51
+ "react-native": "0.73.0",
52
+ "react-native-builder-bob": "^0.23.2",
53
+ "typescript": "5.0.4"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "react": "*",
57
57
  "react-native": "*"
58
58
  },
59
+ "codegenConfig": {
60
+ "name": "OPSQLiteSpec",
61
+ "type": "modules",
62
+ "jsSrcsDir": "src",
63
+ "android": {
64
+ "javaPackageName": "com.op.sqlite"
65
+ }
66
+ },
59
67
  "prettier": {
60
68
  "quoteProps": "consistent",
61
69
  "singleQuote": true,
@@ -0,0 +1,15 @@
1
+ import { TurboModuleRegistry, TurboModule } from 'react-native';
2
+
3
+ export interface Spec extends TurboModule {
4
+ getConstants: () => {
5
+ IOS_DOCUMENT_PATH: string;
6
+ IOS_LIBRARY_PATH: string;
7
+ ANDROID_DATABASE_PATH: string;
8
+ ANDROID_FILES_PATH: string;
9
+ ANDROID_EXTERNAL_FILES_PATH: string;
10
+ };
11
+
12
+ install(): boolean;
13
+ }
14
+
15
+ export default TurboModuleRegistry.getEnforcing<Spec>('OPSQLite');
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { NativeModules } from 'react-native';
1
+ import NativeOPSQLite from './NativeOPSQLite';
2
2
 
3
3
  declare global {
4
4
  function nativeCallSyncHook(): unknown;
@@ -6,7 +6,7 @@ declare global {
6
6
  }
7
7
 
8
8
  if (global.__OPSQLiteProxy == null) {
9
- const OPSQLiteModule = NativeModules.OPSQLite;
9
+ const OPSQLiteModule = NativeOPSQLite;
10
10
 
11
11
  if (OPSQLiteModule == null) {
12
12
  throw new Error('Base module not found. Maybe try rebuilding the app.');
@@ -39,12 +39,19 @@ const proxy = global.__OPSQLiteProxy;
39
39
  export const OPSQLite = proxy as ISQLite;
40
40
 
41
41
  export const {
42
+ // @ts-expect-error
42
43
  IOS_DOCUMENT_PATH,
44
+ // @ts-expect-error
43
45
  IOS_LIBRARY_PATH,
46
+ // @ts-expect-error
44
47
  ANDROID_DATABASE_PATH,
48
+ // @ts-expect-error
45
49
  ANDROID_FILES_PATH,
50
+ // @ts-expect-error
46
51
  ANDROID_EXTERNAL_FILES_PATH,
47
- } = NativeModules.OPSQLite;
52
+ } = !!NativeOPSQLite.getConstants
53
+ ? NativeOPSQLite.getConstants()
54
+ : NativeOPSQLite;
48
55
 
49
56
  /**
50
57
  * Object returned by SQL Query executions {
@@ -1,26 +0,0 @@
1
- package com.op.sqlite;
2
-
3
- import com.facebook.react.bridge.ReactContext;
4
- import com.facebook.react.turbomodule.core.CallInvokerHolderImpl;
5
-
6
- public class OPSQLiteBridge {
7
- private native void installNativeJsi(long jsContextNativePointer, CallInvokerHolderImpl jsCallInvokerHolder, String docPath);
8
- private native void clearStateNativeJsi();
9
- public static final OPSQLiteBridge instance = new OPSQLiteBridge();
10
-
11
- public void install(ReactContext context) {
12
- long jsContextPointer = context.getJavaScriptContextHolder().get();
13
- CallInvokerHolderImpl jsCallInvokerHolder = (CallInvokerHolderImpl)context.getCatalystInstance().getJSCallInvokerHolder();
14
- // Trick to get the base database path
15
- final String dbPath = context.getDatabasePath("defaultDatabase").getAbsolutePath().replace("defaultDatabase", "");
16
- installNativeJsi(
17
- jsContextPointer,
18
- jsCallInvokerHolder,
19
- dbPath
20
- );
21
- }
22
-
23
- public void clearState() {
24
- clearStateNativeJsi();
25
- }
26
- }
@@ -1,60 +0,0 @@
1
- package com.op.sqlite;
2
-
3
- import androidx.annotation.NonNull;
4
- import com.facebook.react.bridge.ReactApplicationContext;
5
- import com.facebook.react.bridge.ReactContextBaseJavaModule;
6
- import com.facebook.react.bridge.ReactMethod;
7
- import java.util.HashMap;
8
- import java.util.Map;
9
-
10
- class OPSQLiteModule extends ReactContextBaseJavaModule {
11
- static {
12
- System.loadLibrary("op-sqlite");
13
- }
14
-
15
- public static final String NAME = "OPSQLite";
16
-
17
- public OPSQLiteModule(ReactApplicationContext context) {
18
- super(context);
19
- }
20
-
21
- @NonNull
22
- @Override
23
- public String getName() {
24
- return NAME;
25
- }
26
-
27
- @Override
28
- public Map<String, Object> getConstants() {
29
- final Map<String, Object> constants = new HashMap<>();
30
- ReactApplicationContext context = getReactApplicationContext();
31
- final String dbPath = context
32
- .getDatabasePath("defaultDatabase")
33
- .getAbsolutePath()
34
- .replace("defaultDatabase", "");
35
- constants.put("ANDROID_DATABASE_PATH", dbPath);
36
-
37
- final String filesPath = context.getFilesDir().getAbsolutePath();
38
- constants.put("ANDROID_FILES_PATH", filesPath);
39
-
40
- final String externalFilesDir = context.getExternalFilesDir(null).getAbsolutePath();
41
- constants.put("ANDROID_EXTERNAL_FILES_PATH", externalFilesDir);
42
-
43
- return constants;
44
- }
45
-
46
- @ReactMethod(isBlockingSynchronousMethod = true)
47
- public boolean install() {
48
- try {
49
- OPSQLiteBridge.instance.install(getReactApplicationContext());
50
- return true;
51
- } catch (Exception exception) {
52
- return false;
53
- }
54
- }
55
-
56
- @Override
57
- public void onCatalystInstanceDestroy() {
58
- OPSQLiteBridge.instance.clearState();
59
- }
60
- }
@@ -1,26 +0,0 @@
1
- package com.op.sqlite;
2
-
3
- import androidx.annotation.NonNull;
4
-
5
- import com.facebook.react.ReactPackage;
6
- import com.facebook.react.bridge.NativeModule;
7
- import com.facebook.react.bridge.ReactApplicationContext;
8
- import com.facebook.react.uimanager.ViewManager;
9
-
10
- import java.util.Collections;
11
- import java.util.List;
12
-
13
-
14
- public class OPSQLitePackage implements ReactPackage {
15
- @NonNull
16
- @Override
17
- public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
18
- return Collections.singletonList(new OPSQLiteModule(reactContext));
19
- }
20
-
21
- @NonNull
22
- @Override
23
- public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
24
- return Collections.emptyList();
25
- }
26
- }