@op-engineering/op-sqlite 2.0.1 → 2.0.2

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/cpp/types.h CHANGED
@@ -1,14 +1,15 @@
1
1
  #ifndef types_h
2
2
  #define types_h
3
3
 
4
+ #include <memory>
4
5
  #include <variant>
5
6
 
6
7
  struct ArrayBuffer {
7
- std::shared_ptr<uint8_t> data;
8
- size_t size;
8
+ std::shared_ptr<uint8_t> data;
9
+ size_t size;
9
10
  };
10
11
 
11
-
12
- using JSVariant = std::variant<nullptr_t, bool, int, double, long, long long, std::string, ArrayBuffer>;
12
+ using JSVariant = std::variant<nullptr_t, bool, int, double, long, long long,
13
+ std::string, ArrayBuffer>;
13
14
 
14
15
  #endif /* types_h */
package/cpp/utils.cpp CHANGED
@@ -1,213 +1,181 @@
1
1
  #include "utils.h"
2
- #include "DynamicHostObject.h"
3
- #include <iostream>
4
- #include <fstream>
2
+ #include "SmartHostObject.h"
5
3
  #include "bridge.h"
4
+ #include <fstream>
5
+ #include <iostream>
6
6
 
7
7
  namespace opsqlite {
8
8
 
9
9
  namespace jsi = facebook::jsi;
10
10
 
11
11
  jsi::Value toJSI(jsi::Runtime &rt, JSVariant value) {
12
-
13
- if (std::holds_alternative<bool>(value))
14
- {
15
- return std::get<bool>(value);
16
- }
17
- else if (std::holds_alternative<int>(value))
18
- {
19
- return jsi::Value(std::get<int>(value));
20
- }
21
- else if (std::holds_alternative<long long>(value))
22
- {
23
- return jsi::Value(static_cast<double>(std::get<long long>(value)));
24
- }
25
- else if (std::holds_alternative<double>(value))
26
- {
27
- return jsi::Value(std::get<double>(value));
28
- }
29
- else if (std::holds_alternative<std::string>(value))
30
- {
31
- return jsi::String::createFromUtf8(rt, std::get<std::string>(value));
32
- }
33
- else if (std::holds_alternative<ArrayBuffer>(value))
34
- {
35
- auto jsBuffer = std::get<ArrayBuffer>(value);
36
- jsi::Function array_buffer_ctor = rt.global().getPropertyAsFunction(rt, "ArrayBuffer");
37
- jsi::Object o = array_buffer_ctor.callAsConstructor(rt, (int)jsBuffer.size).getObject(rt);
38
- jsi::ArrayBuffer buf = o.getArrayBuffer(rt);
12
+
13
+ if (std::holds_alternative<bool>(value)) {
14
+ return std::get<bool>(value);
15
+ } else if (std::holds_alternative<int>(value)) {
16
+ return jsi::Value(std::get<int>(value));
17
+ } else if (std::holds_alternative<long long>(value)) {
18
+ return jsi::Value(static_cast<double>(std::get<long long>(value)));
19
+ } else if (std::holds_alternative<double>(value)) {
20
+ return jsi::Value(std::get<double>(value));
21
+ } else if (std::holds_alternative<std::string>(value)) {
22
+ return jsi::String::createFromUtf8(rt, std::get<std::string>(value));
23
+ } else if (std::holds_alternative<ArrayBuffer>(value)) {
24
+ auto jsBuffer = std::get<ArrayBuffer>(value);
25
+ jsi::Function array_buffer_ctor =
26
+ rt.global().getPropertyAsFunction(rt, "ArrayBuffer");
27
+ jsi::Object o = array_buffer_ctor.callAsConstructor(rt, (int)jsBuffer.size)
28
+ .getObject(rt);
29
+ jsi::ArrayBuffer buf = o.getArrayBuffer(rt);
30
+ // You cannot share raw memory between native and JS
31
+ // always copy the data
32
+ // see https://github.com/facebook/hermes/pull/419 and
33
+ // https://github.com/facebook/hermes/issues/564.
34
+ memcpy(buf.data(rt), jsBuffer.data.get(), jsBuffer.size);
35
+ return o;
36
+ }
37
+
38
+ return jsi::Value::null();
39
+ }
40
+
41
+ std::vector<JSVariant> toVariantVec(jsi::Runtime &rt,
42
+ jsi::Value const &params) {
43
+ std::vector<JSVariant> res;
44
+
45
+ if (params.isNull() || params.isUndefined()) {
46
+ return res;
47
+ }
48
+
49
+ jsi::Array values = params.asObject(rt).asArray(rt);
50
+
51
+ for (int ii = 0; ii < values.length(rt); ii++) {
52
+ jsi::Value value = values.getValueAtIndex(rt, ii);
53
+
54
+ if (value.isNull() || value.isUndefined()) {
55
+ res.push_back(JSVariant(nullptr));
56
+ } else if (value.isBool()) {
57
+ res.push_back(JSVariant(value.getBool()));
58
+ } else if (value.isNumber()) {
59
+ double doubleVal = value.asNumber();
60
+ int intVal = (int)doubleVal;
61
+ long long longVal = (long)doubleVal;
62
+ if (intVal == doubleVal) {
63
+ res.push_back(JSVariant(intVal));
64
+ } else if (longVal == doubleVal) {
65
+ res.push_back(JSVariant(longVal));
66
+ } else {
67
+ res.push_back(JSVariant(doubleVal));
68
+ }
69
+ } else if (value.isString()) {
70
+ std::string strVal = value.asString(rt).utf8(rt);
71
+ res.push_back(JSVariant(strVal));
72
+ } else if (value.isObject()) {
73
+ auto obj = value.asObject(rt);
74
+ if (obj.isArrayBuffer(rt)) {
75
+ auto buffer = obj.getArrayBuffer(rt);
76
+
77
+ uint8_t *data = new uint8_t[buffer.size(rt)];
39
78
  // You cannot share raw memory between native and JS
40
79
  // always copy the data
41
- // see https://github.com/facebook/hermes/pull/419 and https://github.com/facebook/hermes/issues/564.
42
- memcpy(buf.data(rt), jsBuffer.data.get(), jsBuffer.size);
43
- return o;
44
- }
45
-
46
- return jsi::Value::null();
47
- }
80
+ // see https://github.com/facebook/hermes/pull/419 and
81
+ // https://github.com/facebook/hermes/issues/564.
82
+ memcpy(data, buffer.data(rt), buffer.size(rt));
48
83
 
49
- std::vector<JSVariant> toVariantVec(jsi::Runtime &rt, jsi::Value const &params)
50
- {
51
- std::vector<JSVariant> res;
52
-
53
- if (params.isNull() || params.isUndefined())
54
- {
55
- return res;
56
- }
57
-
58
- jsi::Array values = params.asObject(rt).asArray(rt);
59
-
60
- for (int ii = 0; ii < values.length(rt); ii++)
61
- {
62
- jsi::Value value = values.getValueAtIndex(rt, ii);
63
-
64
- if (value.isNull() || value.isUndefined())
65
- {
66
- res.push_back(JSVariant(nullptr));
67
- }
68
- else if (value.isBool())
69
- {
70
- res.push_back(JSVariant(value.getBool()));
71
- }
72
- else if (value.isNumber())
73
- {
74
- double doubleVal = value.asNumber();
75
- int intVal = (int)doubleVal;
76
- long long longVal = (long)doubleVal;
77
- if (intVal == doubleVal)
78
- {
79
- res.push_back(JSVariant(intVal));
80
- }
81
- else if (longVal == doubleVal)
82
- {
83
- res.push_back(JSVariant(longVal));
84
- }
85
- else
86
- {
87
- res.push_back(JSVariant(doubleVal));
88
- }
89
- }
90
- else if (value.isString())
91
- {
92
- std::string strVal = value.asString(rt).utf8(rt);
93
- res.push_back(JSVariant(strVal));
94
- }
95
- else if (value.isObject())
96
- {
97
- auto obj = value.asObject(rt);
98
- if (obj.isArrayBuffer(rt)) {
99
- auto buffer = obj.getArrayBuffer(rt);
100
-
101
- uint8_t *data = new uint8_t[buffer.size(rt)];
102
- // You cannot share raw memory between native and JS
103
- // always copy the data
104
- // see https://github.com/facebook/hermes/pull/419 and https://github.com/facebook/hermes/issues/564.
105
- memcpy(data, buffer.data(rt), buffer.size(rt));
106
-
107
- res.push_back(JSVariant(ArrayBuffer {
108
- .data = std::shared_ptr<uint8_t>{data},
109
- .size = buffer.size(rt)
110
- }));
111
- } else {
112
- throw std::invalid_argument("Unknown JSI ArrayBuffer to variant value conversion, received object instead of ArrayBuffer");
113
- }
114
- } else {
115
- throw std::invalid_argument("Unknown JSI to variant value conversion");
116
- }
84
+ res.push_back(JSVariant(ArrayBuffer{
85
+ .data = std::shared_ptr<uint8_t>{data}, .size = buffer.size(rt)}));
86
+ } else {
87
+ throw std::invalid_argument(
88
+ "Unknown JSI ArrayBuffer to variant value conversion, received "
89
+ "object instead of ArrayBuffer");
90
+ }
91
+ } else {
92
+ throw std::invalid_argument("Unknown JSI to variant value conversion");
117
93
  }
118
-
119
- return res;
94
+ }
95
+
96
+ return res;
120
97
  }
121
98
 
122
- jsi::Value createResult(jsi::Runtime &rt,
123
- BridgeResult status,
124
- std::vector<DumbHostObject> *results,
125
- std::shared_ptr<std::vector<DynamicHostObject>> metadata)
126
- {
127
- if(status.type == SQLiteError) {
128
- throw std::invalid_argument(status.message);
129
- }
130
-
131
- jsi::Object res = jsi::Object(rt);
132
-
133
- res.setProperty(rt, "rowsAffected", status.affectedRows);
134
- if (status.affectedRows > 0 && status.insertId != 0)
135
- {
136
- res.setProperty(rt, "insertId", jsi::Value(status.insertId));
137
- }
138
-
139
- size_t rowCount = results->size();
140
- jsi::Object rows = jsi::Object(rt);
141
- rows.setProperty(rt, "length", jsi::Value((int)rowCount));
142
-
143
- if (rowCount > 0)
144
- {
145
- auto array = jsi::Array(rt, rowCount);
146
- for (int i = 0; i < rowCount; i++)
147
- {
148
- auto obj = results->at(i);
149
- array.setValueAtIndex(rt, i, jsi::Object::createFromHostObject(rt, std::make_shared<DumbHostObject>(obj)));
150
- }
151
- rows.setProperty(rt, "_array", std::move(array));
152
- res.setProperty(rt, "rows", std::move(rows));
153
- }
154
-
155
- size_t column_count = metadata->size();
156
- auto column_array = jsi::Array(rt, column_count);
157
- for (int i = 0; i < column_count; i++) {
158
- auto column = metadata->at(i);
159
- column_array.setValueAtIndex(rt, i, jsi::Object::createFromHostObject(rt, std::make_shared<DynamicHostObject>(column)));
99
+ jsi::Value
100
+ createResult(jsi::Runtime &rt, BridgeResult status,
101
+ std::vector<DumbHostObject> *results,
102
+ std::shared_ptr<std::vector<SmartHostObject>> metadata) {
103
+ if (status.type == SQLiteError) {
104
+ throw std::invalid_argument(status.message);
105
+ }
106
+
107
+ jsi::Object res = jsi::Object(rt);
108
+
109
+ res.setProperty(rt, "rowsAffected", status.affectedRows);
110
+ if (status.affectedRows > 0 && status.insertId != 0) {
111
+ res.setProperty(rt, "insertId", jsi::Value(status.insertId));
112
+ }
113
+
114
+ size_t rowCount = results->size();
115
+ jsi::Object rows = jsi::Object(rt);
116
+ rows.setProperty(rt, "length", jsi::Value((int)rowCount));
117
+
118
+ if (rowCount > 0) {
119
+ auto array = jsi::Array(rt, rowCount);
120
+ for (int i = 0; i < rowCount; i++) {
121
+ auto obj = results->at(i);
122
+ array.setValueAtIndex(rt, i,
123
+ jsi::Object::createFromHostObject(
124
+ rt, std::make_shared<DumbHostObject>(obj)));
160
125
  }
161
- res.setProperty(rt, "metadata", std::move(column_array));
162
-
163
- return std::move(res);
126
+ rows.setProperty(rt, "_array", std::move(array));
127
+ res.setProperty(rt, "rows", std::move(rows));
128
+ }
129
+
130
+ size_t column_count = metadata->size();
131
+ auto column_array = jsi::Array(rt, column_count);
132
+ for (int i = 0; i < column_count; i++) {
133
+ auto column = metadata->at(i);
134
+ column_array.setValueAtIndex(
135
+ rt, i,
136
+ jsi::Object::createFromHostObject(
137
+ rt, std::make_shared<SmartHostObject>(column)));
138
+ }
139
+ res.setProperty(rt, "metadata", std::move(column_array));
140
+
141
+ return std::move(res);
164
142
  }
165
143
 
166
- BatchResult importSQLFile(std::string dbName, std::string fileLocation)
167
- {
168
- std::string line;
169
- std::ifstream sqFile(fileLocation);
170
- if (sqFile.is_open())
171
- {
172
- try
173
- {
174
- int affectedRows = 0;
175
- int commands = 0;
176
- sqliteExecuteLiteral(dbName, "BEGIN EXCLUSIVE TRANSACTION");
177
- while (std::getline(sqFile, line, '\n'))
178
- {
179
- if (!line.empty())
180
- {
181
- BridgeResult result = sqliteExecuteLiteral(dbName, line);
182
- if (result.type == SQLiteError)
183
- {
184
- sqliteExecuteLiteral(dbName, "ROLLBACK");
185
- sqFile.close();
186
- return {SQLiteError, result.message, 0, commands};
187
- }
188
- else
189
- {
190
- affectedRows += result.affectedRows;
191
- commands++;
192
- }
193
- }
194
- }
195
- sqFile.close();
196
- sqliteExecuteLiteral(dbName, "COMMIT");
197
- return {SQLiteOk, "", affectedRows, commands};
198
- }
199
- catch (...)
200
- {
201
- sqFile.close();
144
+ BatchResult importSQLFile(std::string dbName, std::string fileLocation) {
145
+ std::string line;
146
+ std::ifstream sqFile(fileLocation);
147
+ if (sqFile.is_open()) {
148
+ try {
149
+ int affectedRows = 0;
150
+ int commands = 0;
151
+ sqliteExecuteLiteral(dbName, "BEGIN EXCLUSIVE TRANSACTION");
152
+ while (std::getline(sqFile, line, '\n')) {
153
+ if (!line.empty()) {
154
+ BridgeResult result = sqliteExecuteLiteral(dbName, line);
155
+ if (result.type == SQLiteError) {
202
156
  sqliteExecuteLiteral(dbName, "ROLLBACK");
203
- return {SQLiteError, "[op-sqlite][loadSQLFile] Unexpected error, transaction was rolledback", 0, 0};
157
+ sqFile.close();
158
+ return {SQLiteError, result.message, 0, commands};
159
+ } else {
160
+ affectedRows += result.affectedRows;
161
+ commands++;
162
+ }
204
163
  }
164
+ }
165
+ sqFile.close();
166
+ sqliteExecuteLiteral(dbName, "COMMIT");
167
+ return {SQLiteOk, "", affectedRows, commands};
168
+ } catch (...) {
169
+ sqFile.close();
170
+ sqliteExecuteLiteral(dbName, "ROLLBACK");
171
+ return {SQLiteError,
172
+ "[op-sqlite][loadSQLFile] Unexpected error, transaction was "
173
+ "rolledback",
174
+ 0, 0};
205
175
  }
206
- else
207
- {
208
- return {SQLiteError, "[op-sqlite][loadSQLFile] Could not open file", 0, 0};
209
- }
176
+ } else {
177
+ return {SQLiteError, "[op-sqlite][loadSQLFile] Could not open file", 0, 0};
178
+ }
210
179
  }
211
180
 
212
-
213
- }
181
+ } // namespace opsqlite
package/cpp/utils.h CHANGED
@@ -1,53 +1,46 @@
1
1
  #ifndef utils_h
2
2
  #define utils_h
3
3
 
4
- #include <stdio.h>
5
- #include <jsi/jsilib.h>
4
+ #include "DumbHostObject.h"
5
+ #include "SmartHostObject.h"
6
+ #include "types.h"
7
+ #include <any>
6
8
  #include <jsi/jsi.h>
7
- #include <vector>
9
+ #include <jsi/jsilib.h>
8
10
  #include <map>
9
- #include <any>
10
- #include "types.h"
11
- #include "DynamicHostObject.h"
12
- #include "DumbHostObject.h"
11
+ #include <stdio.h>
12
+ #include <vector>
13
13
 
14
14
  namespace opsqlite {
15
15
 
16
- namespace jsi = facebook::jsi;
16
+ namespace jsi = facebook::jsi;
17
17
 
18
- enum ResultType
19
- {
20
- SQLiteOk,
21
- SQLiteError
22
- };
18
+ enum ResultType { SQLiteOk, SQLiteError };
23
19
 
24
- struct BridgeResult
25
- {
26
- ResultType type;
27
- std::string message;
28
- int affectedRows;
29
- double insertId;
30
- };
20
+ struct BridgeResult {
21
+ ResultType type;
22
+ std::string message;
23
+ int affectedRows;
24
+ double insertId;
25
+ };
31
26
 
32
- struct BatchResult
33
- {
34
- ResultType type;
35
- std::string message;
36
- int affectedRows;
37
- int commands;
38
- };
27
+ struct BatchResult {
28
+ ResultType type;
29
+ std::string message;
30
+ int affectedRows;
31
+ int commands;
32
+ };
39
33
 
40
- jsi::Value toJSI(jsi::Runtime &rt, JSVariant value);
34
+ jsi::Value toJSI(jsi::Runtime &rt, JSVariant value);
41
35
 
42
- std::vector<JSVariant> toVariantVec(jsi::Runtime &rt, jsi::Value const &args);
36
+ std::vector<JSVariant> toVariantVec(jsi::Runtime &rt, jsi::Value const &args);
43
37
 
44
- jsi::Value createResult(jsi::Runtime &rt,
45
- BridgeResult status,
46
- std::vector<DumbHostObject> *results,
47
- std::shared_ptr<std::vector<DynamicHostObject>> metadata);
38
+ jsi::Value createResult(jsi::Runtime &rt, BridgeResult status,
39
+ std::vector<DumbHostObject> *results,
40
+ std::shared_ptr<std::vector<SmartHostObject>> metadata);
48
41
 
49
- BatchResult importSQLFile(std::string dbName, std::string fileLocation);
42
+ BatchResult importSQLFile(std::string dbName, std::string fileLocation);
50
43
 
51
- }
44
+ } // namespace opsqlite
52
45
 
53
46
  #endif /* utils_h */
@@ -219,7 +219,8 @@ const open = options => {
219
219
  loadFile: location => OPSQLite.loadFile(options.name, location),
220
220
  updateHook: callback => OPSQLite.updateHook(options.name, callback),
221
221
  commitHook: callback => OPSQLite.commitHook(options.name, callback),
222
- rollbackHook: callback => OPSQLite.rollbackHook(options.name, callback)
222
+ rollbackHook: callback => OPSQLite.rollbackHook(options.name, callback),
223
+ prepareStatement: query => OPSQLite.prepareStatement(options.name, query)
223
224
  };
224
225
  };
225
226
  exports.open = open;
@@ -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"],"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\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}\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};\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 };\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,eAAe,IAAI,IAAI,EAAE;IAClC,MAAM,IAAII,KAAK,CACb,yIAAyI,CAC1I;EACH;AACF;AAEA,MAAMI,KAAK,GAAGT,MAAM,CAACC,eAAe;AAC7B,MAAMG,QAAQ,GAAGK,KAAgB;AAAC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AACC,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;EAC1E,CAAC;AACH,CAAC;AAAC"}
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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xB,WAAW,EAAGC,EAAsC,IAClDxC,QAAQ,CAACuC,WAAW,CAACmB,OAAO,CAACC,IAAI,EAAEnB,EAAE,CAAC;IACxCb,OAAO,EAAE,CAACC,KAAa,EAAEC,MAA0B,KACjD7B,QAAQ,CAAC2B,OAAO,CAAC+B,OAAO,CAACC,IAAI,EAAE/B,KAAK,EAAEC,MAAM,CAAC;IAC/CQ,YAAY,EAAE,CACZT,KAAa,EACbC,MAA0B,KAE1B7B,QAAQ,CAACqC,YAAY,CAACqB,OAAO,CAACC,IAAI,EAAE/B,KAAK,EAAEC,MAAM,CAAC;IACpDoC,YAAY,EAAGC,QAAyB,IACtClE,QAAQ,CAACiE,YAAY,CAACP,OAAO,CAACC,IAAI,EAAEO,QAAQ,CAAC;IAC/CC,iBAAiB,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"}
@@ -208,7 +208,8 @@ export const open = options => {
208
208
  loadFile: location => OPSQLite.loadFile(options.name, location),
209
209
  updateHook: callback => OPSQLite.updateHook(options.name, callback),
210
210
  commitHook: callback => OPSQLite.commitHook(options.name, callback),
211
- rollbackHook: callback => OPSQLite.rollbackHook(options.name, callback)
211
+ rollbackHook: callback => OPSQLite.rollbackHook(options.name, callback),
212
+ prepareStatement: query => OPSQLite.prepareStatement(options.name, query)
212
213
  };
213
214
  };
214
215
  //# sourceMappingURL=index.js.map