@powersync/op-sqlite 0.0.0-dev-20251106124255 → 0.0.0-dev-20251111122755
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/lib/commonjs/db/OPSQLiteConnection.js +0 -24
- package/lib/commonjs/db/OPSQLiteConnection.js.map +1 -1
- package/lib/commonjs/db/OPSqliteAdapter.js +5 -7
- package/lib/commonjs/db/OPSqliteAdapter.js.map +1 -1
- package/lib/commonjs/db/OPSqliteDBOpenFactory.js +1 -2
- package/lib/commonjs/db/OPSqliteDBOpenFactory.js.map +1 -1
- package/lib/module/db/OPSQLiteConnection.js +0 -24
- package/lib/module/db/OPSQLiteConnection.js.map +1 -1
- package/lib/module/db/OPSqliteAdapter.js +5 -7
- package/lib/module/db/OPSqliteAdapter.js.map +1 -1
- package/lib/module/db/OPSqliteDBOpenFactory.js +1 -2
- package/lib/module/db/OPSqliteDBOpenFactory.js.map +1 -1
- package/lib/typescript/commonjs/src/db/OPSQLiteConnection.d.ts +0 -2
- package/lib/typescript/commonjs/src/db/OPSQLiteConnection.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/db/OPSqliteAdapter.d.ts +1 -2
- package/lib/typescript/commonjs/src/db/OPSqliteAdapter.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/db/OPSqliteDBOpenFactory.d.ts.map +1 -1
- package/lib/typescript/commonjs/tsconfig.build.tsbuildinfo +1 -1
- package/lib/typescript/module/src/db/OPSQLiteConnection.d.ts +0 -2
- package/lib/typescript/module/src/db/OPSQLiteConnection.d.ts.map +1 -1
- package/lib/typescript/module/src/db/OPSqliteAdapter.d.ts +1 -2
- package/lib/typescript/module/src/db/OPSqliteAdapter.d.ts.map +1 -1
- package/lib/typescript/module/src/db/OPSqliteDBOpenFactory.d.ts.map +1 -1
- package/lib/typescript/module/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/db/OPSQLiteConnection.ts +0 -28
- package/src/db/OPSqliteAdapter.ts +5 -8
- package/src/db/OPSqliteDBOpenFactory.ts +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powersync/op-sqlite",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20251111122755",
|
|
4
4
|
"description": "PowerSync - sync Postgres or MongoDB with SQLite in your React Native app for offline-first and real-time data",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@op-engineering/op-sqlite": "^13.0.0 || ^14.0.0",
|
|
62
|
-
"@powersync/common": "0.0.0-dev-
|
|
62
|
+
"@powersync/common": "0.0.0-dev-20251111122755",
|
|
63
63
|
"react": "*",
|
|
64
64
|
"react-native": "*"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"async-lock": "^1.4.0",
|
|
68
|
-
"@powersync/common": "0.0.0-dev-
|
|
68
|
+
"@powersync/common": "0.0.0-dev-20251111122755"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@op-engineering/op-sqlite": "^14.0.2",
|
|
@@ -10,8 +10,6 @@ import {
|
|
|
10
10
|
|
|
11
11
|
export type OPSQLiteConnectionOptions = {
|
|
12
12
|
baseDB: DB;
|
|
13
|
-
debugMode: boolean;
|
|
14
|
-
connectionName: string;
|
|
15
13
|
};
|
|
16
14
|
|
|
17
15
|
export type OPSQLiteUpdateNotification = {
|
|
@@ -37,16 +35,6 @@ export class OPSQLiteConnection extends BaseObserver<DBAdapterListener> {
|
|
|
37
35
|
this.DB.updateHook((update) => {
|
|
38
36
|
this.addTableUpdate(update);
|
|
39
37
|
});
|
|
40
|
-
|
|
41
|
-
if (options.debugMode) {
|
|
42
|
-
const c = this.options.connectionName;
|
|
43
|
-
this.execute = withDebug(this.execute.bind(this), `[SQL execute ${c}]`);
|
|
44
|
-
this.executeRaw = withDebug(this.executeRaw.bind(this), `[SQL executeRaw ${c}]`);
|
|
45
|
-
this.executeBatch = withDebug(this.executeBatch.bind(this), `[SQL executeBatch ${c}]`);
|
|
46
|
-
this.get = withDebug(this.get.bind(this), `[SQL get ${c}]`);
|
|
47
|
-
this.getAll = withDebug(this.getAll.bind(this), `[SQL getAll ${c}]`);
|
|
48
|
-
this.getOptional = withDebug(this.getOptional.bind(this), `[SQL getOptional ${c}]`);
|
|
49
|
-
}
|
|
50
38
|
}
|
|
51
39
|
|
|
52
40
|
addTableUpdate(update: OPSQLiteUpdateNotification) {
|
|
@@ -145,19 +133,3 @@ export class OPSQLiteConnection extends BaseObserver<DBAdapterListener> {
|
|
|
145
133
|
await this.get("PRAGMA table_info('sqlite_master')");
|
|
146
134
|
}
|
|
147
135
|
}
|
|
148
|
-
|
|
149
|
-
function withDebug<T extends (sql: string, ...args: any[]) => Promise<any>>(fn: T, name: string): T {
|
|
150
|
-
return (async (sql: string, ...args: any[]): Promise<any> => {
|
|
151
|
-
const start = performance.now();
|
|
152
|
-
try {
|
|
153
|
-
const r = await fn(sql, ...args);
|
|
154
|
-
const duration = performance.now() - start;
|
|
155
|
-
console.log(name, `[${duration.toFixed(1)}ms]`, sql);
|
|
156
|
-
return r;
|
|
157
|
-
} catch (e: any) {
|
|
158
|
-
const duration = performance.now() - start;
|
|
159
|
-
console.error(name, `[ERROR: ${e.message}]`, `[${duration.toFixed(1)}ms]`, sql);
|
|
160
|
-
throw e;
|
|
161
|
-
}
|
|
162
|
-
}) as T;
|
|
163
|
-
}
|
|
@@ -12,7 +12,6 @@ export type OPSQLiteAdapterOptions = {
|
|
|
12
12
|
name: string;
|
|
13
13
|
dbLocation?: string;
|
|
14
14
|
sqliteOptions?: SqliteOptions;
|
|
15
|
-
debugMode?: boolean;
|
|
16
15
|
};
|
|
17
16
|
|
|
18
17
|
enum LockType {
|
|
@@ -51,7 +50,7 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
|
|
|
51
50
|
this.options.sqliteOptions!;
|
|
52
51
|
const dbFilename = this.options.name;
|
|
53
52
|
|
|
54
|
-
this.writeConnection = await this.openConnection(
|
|
53
|
+
this.writeConnection = await this.openConnection(dbFilename);
|
|
55
54
|
|
|
56
55
|
const baseStatements = [
|
|
57
56
|
`PRAGMA busy_timeout = ${lockTimeoutMs}`,
|
|
@@ -90,7 +89,7 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
|
|
|
90
89
|
|
|
91
90
|
this.readConnections = [];
|
|
92
91
|
for (let i = 0; i < READ_CONNECTIONS; i++) {
|
|
93
|
-
const conn = await this.openConnection(
|
|
92
|
+
const conn = await this.openConnection(dbFilename);
|
|
94
93
|
for (let statement of readConnectionStatements) {
|
|
95
94
|
await conn.execute(statement);
|
|
96
95
|
}
|
|
@@ -98,8 +97,8 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
|
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
99
|
|
|
101
|
-
protected async openConnection(
|
|
102
|
-
const dbFilename = this.options.name;
|
|
100
|
+
protected async openConnection(filenameOverride?: string): Promise<OPSQLiteConnection> {
|
|
101
|
+
const dbFilename = filenameOverride ?? this.options.name;
|
|
103
102
|
const DB: DB = this.openDatabase(dbFilename, this.options.sqliteOptions?.encryptionKey ?? undefined);
|
|
104
103
|
|
|
105
104
|
//Load extensions for all connections
|
|
@@ -109,9 +108,7 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
|
|
|
109
108
|
await DB.execute('SELECT powersync_init()');
|
|
110
109
|
|
|
111
110
|
return new OPSQLiteConnection({
|
|
112
|
-
baseDB: DB
|
|
113
|
-
debugMode: this.options.debugMode ?? false,
|
|
114
|
-
connectionName
|
|
111
|
+
baseDB: DB
|
|
115
112
|
});
|
|
116
113
|
}
|
|
117
114
|
|
|
@@ -19,8 +19,7 @@ export class OPSqliteOpenFactory implements SQLOpenFactory {
|
|
|
19
19
|
return new OPSQLiteDBAdapter({
|
|
20
20
|
name: this.options.dbFilename,
|
|
21
21
|
dbLocation: this.options.dbLocation,
|
|
22
|
-
sqliteOptions: this.sqliteOptions
|
|
23
|
-
debugMode: this.options.debugMode
|
|
22
|
+
sqliteOptions: this.sqliteOptions
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
25
|
}
|