@powersync/op-sqlite 0.0.0-dev-20241107150304 → 0.0.0-dev-20250121114305
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/README.md +36 -0
- package/lib/{typescript/commonjs/src → src}/db/OPSQLiteConnection.d.ts +11 -2
- package/lib/src/db/OPSQLiteConnection.js +118 -0
- package/lib/{typescript/commonjs/src → src}/db/OPSqliteAdapter.d.ts +3 -2
- package/lib/src/db/OPSqliteAdapter.js +267 -0
- package/lib/{typescript/commonjs/src → src}/db/OPSqliteDBOpenFactory.d.ts +0 -1
- package/lib/src/db/OPSqliteDBOpenFactory.js +15 -0
- package/lib/{typescript/module/src → src}/db/SqliteOptions.d.ts +9 -2
- package/lib/src/db/SqliteOptions.js +29 -0
- package/lib/{typescript/commonjs/src → src}/index.d.ts +0 -2
- package/lib/src/index.js +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/package.json +11 -80
- package/android/build.gradle +0 -124
- package/android/gradle.properties +0 -5
- package/android/src/main/AndroidManifest.xml +0 -3
- package/android/src/main/AndroidManifestNew.xml +0 -2
- package/android/src/main/java/com/powersync/opsqlite/PowerSyncOpSqliteModule.kt +0 -25
- package/android/src/main/java/com/powersync/opsqlite/PowerSyncOpSqlitePackage.kt +0 -35
- package/android/src/newarch/PowerSyncOpSqliteSpec.kt +0 -7
- package/android/src/oldarch/PowerSyncOpSqliteSpec.kt +0 -11
- package/ios/PowerSyncOpSqlite.h +0 -5
- package/ios/PowerSyncOpSqlite.mm +0 -11
- package/lib/commonjs/NativePowerSyncOpSqlite.js +0 -9
- package/lib/commonjs/NativePowerSyncOpSqlite.js.map +0 -1
- package/lib/commonjs/db/OPSQLiteConnection.js +0 -77
- package/lib/commonjs/db/OPSQLiteConnection.js.map +0 -1
- package/lib/commonjs/db/OPSqliteAdapter.js +0 -234
- package/lib/commonjs/db/OPSqliteAdapter.js.map +0 -1
- package/lib/commonjs/db/OPSqliteDBOpenFactory.js +0 -26
- package/lib/commonjs/db/OPSqliteDBOpenFactory.js.map +0 -1
- package/lib/commonjs/db/SqliteOptions.js +0 -32
- package/lib/commonjs/db/SqliteOptions.js.map +0 -1
- package/lib/commonjs/index.js +0 -35
- package/lib/commonjs/index.js.map +0 -1
- package/lib/module/NativePowerSyncOpSqlite.js +0 -5
- package/lib/module/NativePowerSyncOpSqlite.js.map +0 -1
- package/lib/module/db/OPSQLiteConnection.js +0 -72
- package/lib/module/db/OPSQLiteConnection.js.map +0 -1
- package/lib/module/db/OPSqliteAdapter.js +0 -229
- package/lib/module/db/OPSqliteAdapter.js.map +0 -1
- package/lib/module/db/OPSqliteDBOpenFactory.js +0 -21
- package/lib/module/db/OPSqliteDBOpenFactory.js.map +0 -1
- package/lib/module/db/SqliteOptions.js +0 -28
- package/lib/module/db/SqliteOptions.js.map +0 -1
- package/lib/module/index.js +0 -19
- package/lib/module/index.js.map +0 -1
- package/lib/typescript/commonjs/package.json +0 -1
- package/lib/typescript/commonjs/src/NativePowerSyncOpSqlite.d.ts +0 -7
- package/lib/typescript/commonjs/src/NativePowerSyncOpSqlite.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/db/OPSQLiteConnection.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/db/OPSqliteAdapter.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/db/OPSqliteDBOpenFactory.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/db/SqliteOptions.d.ts +0 -44
- package/lib/typescript/commonjs/src/db/SqliteOptions.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
- package/lib/typescript/commonjs/tsconfig.build.tsbuildinfo +0 -1
- package/lib/typescript/module/package.json +0 -1
- package/lib/typescript/module/src/NativePowerSyncOpSqlite.d.ts +0 -7
- package/lib/typescript/module/src/NativePowerSyncOpSqlite.d.ts.map +0 -1
- package/lib/typescript/module/src/db/OPSQLiteConnection.d.ts +0 -17
- package/lib/typescript/module/src/db/OPSQLiteConnection.d.ts.map +0 -1
- package/lib/typescript/module/src/db/OPSqliteAdapter.d.ts +0 -43
- package/lib/typescript/module/src/db/OPSqliteAdapter.d.ts.map +0 -1
- package/lib/typescript/module/src/db/OPSqliteDBOpenFactory.d.ts +0 -12
- package/lib/typescript/module/src/db/OPSqliteDBOpenFactory.d.ts.map +0 -1
- package/lib/typescript/module/src/db/SqliteOptions.d.ts.map +0 -1
- package/lib/typescript/module/src/index.d.ts +0 -3
- package/lib/typescript/module/src/index.d.ts.map +0 -1
- package/lib/typescript/module/tsconfig.build.tsbuildinfo +0 -1
- package/powersync-op-sqlite.podspec +0 -26
- package/src/NativePowerSyncOpSqlite.ts +0 -8
- package/src/db/OPSQLiteConnection.ts +0 -82
- package/src/db/OPSqliteAdapter.ts +0 -274
- package/src/db/OPSqliteDBOpenFactory.ts +0 -25
- package/src/db/SqliteOptions.ts +0 -61
- package/src/index.ts +0 -30
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseObserver,
|
|
3
|
-
DBAdapter,
|
|
4
|
-
DBAdapterListener,
|
|
5
|
-
DBLockOptions,
|
|
6
|
-
QueryResult,
|
|
7
|
-
SQLOpenOptions,
|
|
8
|
-
Transaction
|
|
9
|
-
} from '@powersync/common';
|
|
10
|
-
import { ANDROID_DATABASE_PATH, IOS_LIBRARY_PATH, open, type DB } from '@op-engineering/op-sqlite';
|
|
11
|
-
import Lock from 'async-lock';
|
|
12
|
-
import { OPSQLiteConnection } from './OPSQLiteConnection';
|
|
13
|
-
import { NativeModules, Platform } from 'react-native';
|
|
14
|
-
import { SqliteOptions } from './SqliteOptions';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Adapter for React Native Quick SQLite
|
|
18
|
-
*/
|
|
19
|
-
export type OPSQLiteAdapterOptions = {
|
|
20
|
-
name: string;
|
|
21
|
-
dbLocation?: string;
|
|
22
|
-
sqliteOptions?: SqliteOptions;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
enum LockType {
|
|
26
|
-
READ = 'read',
|
|
27
|
-
WRITE = 'write'
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const READ_CONNECTIONS = 5;
|
|
31
|
-
|
|
32
|
-
export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implements DBAdapter {
|
|
33
|
-
name: string;
|
|
34
|
-
protected locks: Lock;
|
|
35
|
-
|
|
36
|
-
protected initialized: Promise<void>;
|
|
37
|
-
|
|
38
|
-
protected readConnections: Array<{ busy: boolean; connection: OPSQLiteConnection }> | null;
|
|
39
|
-
|
|
40
|
-
protected writeConnection: OPSQLiteConnection | null;
|
|
41
|
-
|
|
42
|
-
private readQueue: Array<() => void> = [];
|
|
43
|
-
|
|
44
|
-
constructor(protected options: OPSQLiteAdapterOptions) {
|
|
45
|
-
super();
|
|
46
|
-
this.name = this.options.name;
|
|
47
|
-
|
|
48
|
-
this.locks = new Lock();
|
|
49
|
-
this.readConnections = null;
|
|
50
|
-
this.writeConnection = null;
|
|
51
|
-
this.initialized = this.init();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
protected async init() {
|
|
55
|
-
const { lockTimeoutMs, journalMode, journalSizeLimit, synchronous, encryptionKey } = this.options.sqliteOptions;
|
|
56
|
-
const dbFilename = this.options.name;
|
|
57
|
-
|
|
58
|
-
this.writeConnection = await this.openConnection(dbFilename);
|
|
59
|
-
|
|
60
|
-
const statements: string[] = [
|
|
61
|
-
`PRAGMA busy_timeout = ${lockTimeoutMs}`,
|
|
62
|
-
`PRAGMA journal_mode = ${journalMode}`,
|
|
63
|
-
`PRAGMA journal_size_limit = ${journalSizeLimit}`,
|
|
64
|
-
`PRAGMA synchronous = ${synchronous}`
|
|
65
|
-
];
|
|
66
|
-
|
|
67
|
-
for (const statement of statements) {
|
|
68
|
-
for (let tries = 0; tries < 30; tries++) {
|
|
69
|
-
try {
|
|
70
|
-
await this.writeConnection!.execute(statement);
|
|
71
|
-
break;
|
|
72
|
-
} catch (e: any) {
|
|
73
|
-
if (e instanceof Error && e.message.includes('database is locked') && tries < 29) {
|
|
74
|
-
continue;
|
|
75
|
-
} else {
|
|
76
|
-
throw e;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Changes should only occur in the write connection
|
|
83
|
-
this.writeConnection!.registerListener({
|
|
84
|
-
tablesUpdated: (notification) => this.iterateListeners((cb) => cb.tablesUpdated?.(notification))
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
this.readConnections = [];
|
|
88
|
-
for (let i = 0; i < READ_CONNECTIONS; i++) {
|
|
89
|
-
// Workaround to create read-only connections
|
|
90
|
-
let dbName = './'.repeat(i + 1) + dbFilename;
|
|
91
|
-
const conn = await this.openConnection(dbName);
|
|
92
|
-
await conn.execute('PRAGMA query_only = true');
|
|
93
|
-
this.readConnections.push({ busy: false, connection: conn });
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
protected async openConnection(filenameOverride?: string): Promise<OPSQLiteConnection> {
|
|
98
|
-
const dbFilename = filenameOverride ?? this.options.name;
|
|
99
|
-
const DB: DB = this.openDatabase(dbFilename, this.options.sqliteOptions.encryptionKey);
|
|
100
|
-
|
|
101
|
-
//Load extension for all connections
|
|
102
|
-
this.loadExtension(DB);
|
|
103
|
-
|
|
104
|
-
await DB.execute('SELECT powersync_init()');
|
|
105
|
-
|
|
106
|
-
return new OPSQLiteConnection({
|
|
107
|
-
baseDB: DB
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
private getDbLocation(dbLocation?: string): string {
|
|
112
|
-
if (Platform.OS === 'ios') {
|
|
113
|
-
return dbLocation ?? IOS_LIBRARY_PATH;
|
|
114
|
-
} else {
|
|
115
|
-
return dbLocation ?? ANDROID_DATABASE_PATH;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
private openDatabase(dbFilename: string, encryptionKey?: string): DB {
|
|
120
|
-
//This is needed because an undefined/null dbLocation will cause the open function to fail
|
|
121
|
-
const location = this.getDbLocation(this.options.dbLocation);
|
|
122
|
-
//Simarlily if the encryption key is undefined/null when using SQLCipher it will cause the open function to fail
|
|
123
|
-
if (encryptionKey) {
|
|
124
|
-
return open({
|
|
125
|
-
name: dbFilename,
|
|
126
|
-
location: location,
|
|
127
|
-
encryptionKey: encryptionKey
|
|
128
|
-
});
|
|
129
|
-
} else {
|
|
130
|
-
return open({
|
|
131
|
-
name: dbFilename,
|
|
132
|
-
location: location
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
private loadExtension(DB: DB) {
|
|
138
|
-
if (Platform.OS === 'ios') {
|
|
139
|
-
const bundlePath: string = NativeModules.PowerSyncOpSqlite.getBundlePath();
|
|
140
|
-
const libPath = `${bundlePath}/Frameworks/powersync-sqlite-core.framework/powersync-sqlite-core`;
|
|
141
|
-
DB.loadExtension(libPath, 'sqlite3_powersync_init');
|
|
142
|
-
} else {
|
|
143
|
-
DB.loadExtension('libpowersync', 'sqlite3_powersync_init');
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
close() {
|
|
148
|
-
this.initialized.then(() => {
|
|
149
|
-
this.writeConnection!.close();
|
|
150
|
-
this.readConnections!.forEach((c) => c.connection.close());
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
async readLock<T>(fn: (tx: OPSQLiteConnection) => Promise<T>, options?: DBLockOptions): Promise<T> {
|
|
155
|
-
await this.initialized;
|
|
156
|
-
return new Promise(async (resolve, reject) => {
|
|
157
|
-
const execute = async () => {
|
|
158
|
-
// Find an available connection that is not busy
|
|
159
|
-
const availableConnection = this.readConnections!.find((conn) => !conn.busy);
|
|
160
|
-
|
|
161
|
-
// If we have an available connection, use it
|
|
162
|
-
if (availableConnection) {
|
|
163
|
-
availableConnection.busy = true;
|
|
164
|
-
try {
|
|
165
|
-
resolve(await fn(availableConnection.connection));
|
|
166
|
-
} catch (error) {
|
|
167
|
-
reject(error);
|
|
168
|
-
} finally {
|
|
169
|
-
availableConnection.busy = false;
|
|
170
|
-
// After query execution, process any queued tasks
|
|
171
|
-
this.processQueue();
|
|
172
|
-
}
|
|
173
|
-
} else {
|
|
174
|
-
// If no available connections, add to the queue
|
|
175
|
-
this.readQueue.push(execute);
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
execute();
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
private async processQueue(): Promise<void> {
|
|
184
|
-
if (this.readQueue.length > 0) {
|
|
185
|
-
const next = this.readQueue.shift();
|
|
186
|
-
if (next) {
|
|
187
|
-
next();
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
async writeLock<T>(fn: (tx: OPSQLiteConnection) => Promise<T>, options?: DBLockOptions): Promise<T> {
|
|
193
|
-
await this.initialized;
|
|
194
|
-
|
|
195
|
-
return new Promise(async (resolve, reject) => {
|
|
196
|
-
try {
|
|
197
|
-
await this.locks.acquire(
|
|
198
|
-
LockType.WRITE,
|
|
199
|
-
async () => {
|
|
200
|
-
resolve(await fn(this.writeConnection!));
|
|
201
|
-
},
|
|
202
|
-
{ timeout: options?.timeoutMs }
|
|
203
|
-
);
|
|
204
|
-
} catch (ex) {
|
|
205
|
-
reject(ex);
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
readTransaction<T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions): Promise<T> {
|
|
211
|
-
return this.readLock((ctx) => this.internalTransaction(ctx, fn));
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
writeTransaction<T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions): Promise<T> {
|
|
215
|
-
return this.writeLock((ctx) => this.internalTransaction(ctx, fn));
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
getAll<T>(sql: string, parameters?: any[]): Promise<T[]> {
|
|
219
|
-
return this.readLock((ctx) => ctx.getAll(sql, parameters));
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
getOptional<T>(sql: string, parameters?: any[]): Promise<T | null> {
|
|
223
|
-
return this.readLock((ctx) => ctx.getOptional(sql, parameters));
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
get<T>(sql: string, parameters?: any[]): Promise<T> {
|
|
227
|
-
return this.readLock((ctx) => ctx.get(sql, parameters));
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
execute(query: string, params?: any[]) {
|
|
231
|
-
return this.writeLock((ctx) => ctx.execute(query, params));
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
async executeBatch(query: string, params: any[][] = []): Promise<QueryResult> {
|
|
235
|
-
return this.writeLock((ctx) => ctx.executeBatch(query, params));
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
protected async internalTransaction<T>(
|
|
239
|
-
connection: OPSQLiteConnection,
|
|
240
|
-
fn: (tx: Transaction) => Promise<T>
|
|
241
|
-
): Promise<T> {
|
|
242
|
-
let finalized = false;
|
|
243
|
-
const commit = async (): Promise<QueryResult> => {
|
|
244
|
-
if (finalized) {
|
|
245
|
-
return { rowsAffected: 0 };
|
|
246
|
-
}
|
|
247
|
-
finalized = true;
|
|
248
|
-
return connection.execute('COMMIT');
|
|
249
|
-
};
|
|
250
|
-
const rollback = async (): Promise<QueryResult> => {
|
|
251
|
-
if (finalized) {
|
|
252
|
-
return { rowsAffected: 0 };
|
|
253
|
-
}
|
|
254
|
-
finalized = true;
|
|
255
|
-
return connection.execute('ROLLBACK');
|
|
256
|
-
};
|
|
257
|
-
try {
|
|
258
|
-
await connection.execute('BEGIN');
|
|
259
|
-
const result = await fn({
|
|
260
|
-
execute: (query, params) => connection.execute(query, params),
|
|
261
|
-
get: (query, params) => connection.get(query, params),
|
|
262
|
-
getAll: (query, params) => connection.getAll(query, params),
|
|
263
|
-
getOptional: (query, params) => connection.getOptional(query, params),
|
|
264
|
-
commit,
|
|
265
|
-
rollback
|
|
266
|
-
});
|
|
267
|
-
await commit();
|
|
268
|
-
return result;
|
|
269
|
-
} catch (ex) {
|
|
270
|
-
await rollback();
|
|
271
|
-
throw ex;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { DBAdapter, SQLOpenFactory, SQLOpenOptions } from '@powersync/common';
|
|
2
|
-
import { OPSQLiteDBAdapter } from './OPSqliteAdapter';
|
|
3
|
-
import { DEFAULT_SQLITE_OPTIONS, SqliteOptions } from './SqliteOptions';
|
|
4
|
-
|
|
5
|
-
export interface OPSQLiteOpenFactoryOptions extends SQLOpenOptions {
|
|
6
|
-
sqliteOptions?: SqliteOptions;
|
|
7
|
-
}
|
|
8
|
-
export class OPSqliteOpenFactory implements SQLOpenFactory {
|
|
9
|
-
private sqliteOptions: Required<SqliteOptions>;
|
|
10
|
-
|
|
11
|
-
constructor(protected options: OPSQLiteOpenFactoryOptions) {
|
|
12
|
-
this.sqliteOptions = {
|
|
13
|
-
...DEFAULT_SQLITE_OPTIONS,
|
|
14
|
-
...this.options.sqliteOptions
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
openDB(): DBAdapter {
|
|
19
|
-
return new OPSQLiteDBAdapter({
|
|
20
|
-
name: this.options.dbFilename,
|
|
21
|
-
dbLocation: this.options.dbLocation,
|
|
22
|
-
sqliteOptions: this.sqliteOptions
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
package/src/db/SqliteOptions.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export interface SqliteOptions {
|
|
2
|
-
/**
|
|
3
|
-
* SQLite journal mode. Defaults to [SqliteJournalMode.wal].
|
|
4
|
-
*/
|
|
5
|
-
journalMode?: SqliteJournalMode;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* SQLite synchronous flag. Defaults to [SqliteSynchronous.normal], which
|
|
9
|
-
* is safe for WAL mode.
|
|
10
|
-
*/
|
|
11
|
-
synchronous?: SqliteSynchronous;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Journal/WAL size limit. Defaults to 6MB.
|
|
15
|
-
* The WAL may grow larger than this limit during writes, but SQLite will
|
|
16
|
-
* attempt to truncate the file afterwards.
|
|
17
|
-
*/
|
|
18
|
-
journalSizeLimit?: number;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Timeout in milliseconds waiting for locks to be released by other connections.
|
|
22
|
-
* Defaults to 30 seconds.
|
|
23
|
-
* Set to null or zero to fail immediately when the database is locked.
|
|
24
|
-
*/
|
|
25
|
-
lockTimeoutMs?: number;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Encryption key for the database.
|
|
29
|
-
* If set, the database will be encrypted using SQLCipher.
|
|
30
|
-
*/
|
|
31
|
-
encryptionKey?: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// SQLite journal mode. Set on the primary connection.
|
|
35
|
-
// This library is written with WAL mode in mind - other modes may cause
|
|
36
|
-
// unexpected locking behavior.
|
|
37
|
-
enum SqliteJournalMode {
|
|
38
|
-
// Use a write-ahead log instead of a rollback journal.
|
|
39
|
-
// This provides good performance and concurrency.
|
|
40
|
-
wal = 'WAL',
|
|
41
|
-
delete = 'DELETE',
|
|
42
|
-
truncate = 'TRUNCATE',
|
|
43
|
-
persist = 'PERSIST',
|
|
44
|
-
memory = 'MEMORY',
|
|
45
|
-
off = 'OFF'
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// SQLite file commit mode.
|
|
49
|
-
enum SqliteSynchronous {
|
|
50
|
-
normal = 'NORMAL',
|
|
51
|
-
full = 'FULL',
|
|
52
|
-
off = 'OFF'
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const DEFAULT_SQLITE_OPTIONS: Required<SqliteOptions> = {
|
|
56
|
-
journalMode: SqliteJournalMode.wal,
|
|
57
|
-
synchronous: SqliteSynchronous.normal,
|
|
58
|
-
journalSizeLimit: 6 * 1024 * 1024,
|
|
59
|
-
lockTimeoutMs: 30000,
|
|
60
|
-
encryptionKey: null
|
|
61
|
-
};
|
package/src/index.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { NativeModules, Platform } from 'react-native';
|
|
2
|
-
|
|
3
|
-
const LINKING_ERROR =
|
|
4
|
-
`The package '@powersync/op-sqlite' doesn't seem to be linked. Make sure: \n\n` +
|
|
5
|
-
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
6
|
-
'- You rebuilt the app after installing the package\n' +
|
|
7
|
-
'- You are not using Expo Go\n';
|
|
8
|
-
|
|
9
|
-
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
10
|
-
|
|
11
|
-
const PowerSyncOpSqliteModule = isTurboModuleEnabled
|
|
12
|
-
? require('./NativePowerSyncOpSqlite').default
|
|
13
|
-
: NativeModules.PowerSyncOpSqlite;
|
|
14
|
-
|
|
15
|
-
const PowerSyncOpSqlite = PowerSyncOpSqliteModule
|
|
16
|
-
? PowerSyncOpSqliteModule
|
|
17
|
-
: new Proxy(
|
|
18
|
-
{},
|
|
19
|
-
{
|
|
20
|
-
get() {
|
|
21
|
-
throw new Error(LINKING_ERROR);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
export function getBundlePath(): string {
|
|
27
|
-
return PowerSyncOpSqlite.getBundlePath();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { OPSqliteOpenFactory, OPSQLiteOpenFactoryOptions } from './db/OPSqliteDBOpenFactory';
|