@powersync/op-sqlite 0.3.1 → 0.4.1
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 +4 -8
- package/android/build.gradle +1 -1
- package/lib/commonjs/db/OPSqliteAdapter.js +10 -4
- package/lib/commonjs/db/OPSqliteAdapter.js.map +1 -1
- package/lib/commonjs/db/SqliteOptions.js +8 -2
- package/lib/commonjs/db/SqliteOptions.js.map +1 -1
- package/lib/module/db/OPSqliteAdapter.js +10 -4
- package/lib/module/db/OPSqliteAdapter.js.map +1 -1
- package/lib/module/db/SqliteOptions.js +8 -0
- package/lib/module/db/SqliteOptions.js.map +1 -1
- package/lib/typescript/commonjs/src/db/OPSqliteAdapter.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/db/SqliteOptions.d.ts +17 -0
- package/lib/typescript/commonjs/src/db/SqliteOptions.d.ts.map +1 -1
- package/lib/typescript/commonjs/tsconfig.build.tsbuildinfo +1 -1
- package/lib/typescript/module/src/db/OPSqliteAdapter.d.ts.map +1 -1
- package/lib/typescript/module/src/db/SqliteOptions.d.ts +17 -0
- package/lib/typescript/module/src/db/SqliteOptions.d.ts.map +1 -1
- package/lib/typescript/module/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -5
- package/powersync-op-sqlite.podspec +1 -1
- package/src/db/OPSqliteAdapter.ts +15 -4
- package/src/db/SqliteOptions.ts +22 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powersync/op-sqlite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
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": "^11.2.13",
|
|
62
|
-
"@powersync/common": "^1.
|
|
62
|
+
"@powersync/common": "^1.25.0",
|
|
63
63
|
"react": "*",
|
|
64
64
|
"react-native": "*"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"async-lock": "^1.4.0",
|
|
68
|
-
"@powersync/common": "1.
|
|
68
|
+
"@powersync/common": "1.25.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@op-engineering/op-sqlite": "^11.2.13",
|
|
@@ -80,8 +80,7 @@
|
|
|
80
80
|
"react": "18.3.1",
|
|
81
81
|
"react-native": "0.75.3",
|
|
82
82
|
"react-native-builder-bob": "^0.30.2",
|
|
83
|
-
"turbo": "^1.10.7"
|
|
84
|
-
"typescript": "^5.2.2"
|
|
83
|
+
"turbo": "^1.10.7"
|
|
85
84
|
},
|
|
86
85
|
"eslintIgnore": [
|
|
87
86
|
"node_modules/",
|
|
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
|
|
|
17
17
|
|
|
18
18
|
s.dependency "React-callinvoker"
|
|
19
19
|
s.dependency "React"
|
|
20
|
-
s.dependency "powersync-sqlite-core", "~> 0.3.
|
|
20
|
+
s.dependency "powersync-sqlite-core", "~> 0.3.12"
|
|
21
21
|
if defined?(install_modules_dependencies())
|
|
22
22
|
install_modules_dependencies(s)
|
|
23
23
|
else
|
|
@@ -44,19 +44,28 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
protected async init() {
|
|
47
|
-
const { lockTimeoutMs, journalMode, journalSizeLimit, synchronous } =
|
|
47
|
+
const { lockTimeoutMs, journalMode, journalSizeLimit, synchronous, cacheSizeKb, temporaryStorage } =
|
|
48
|
+
this.options.sqliteOptions!;
|
|
48
49
|
const dbFilename = this.options.name;
|
|
49
50
|
|
|
50
51
|
this.writeConnection = await this.openConnection(dbFilename);
|
|
51
52
|
|
|
52
|
-
const
|
|
53
|
+
const baseStatements = [
|
|
53
54
|
`PRAGMA busy_timeout = ${lockTimeoutMs}`,
|
|
55
|
+
`PRAGMA cache_size = -${cacheSizeKb}`,
|
|
56
|
+
`PRAGMA temp_store = ${temporaryStorage}`
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
const writeConnectionStatements = [
|
|
60
|
+
...baseStatements,
|
|
54
61
|
`PRAGMA journal_mode = ${journalMode}`,
|
|
55
62
|
`PRAGMA journal_size_limit = ${journalSizeLimit}`,
|
|
56
63
|
`PRAGMA synchronous = ${synchronous}`
|
|
57
64
|
];
|
|
58
65
|
|
|
59
|
-
|
|
66
|
+
const readConnectionStatements = [...baseStatements, 'PRAGMA query_only = true'];
|
|
67
|
+
|
|
68
|
+
for (const statement of writeConnectionStatements) {
|
|
60
69
|
for (let tries = 0; tries < 30; tries++) {
|
|
61
70
|
try {
|
|
62
71
|
await this.writeConnection!.execute(statement);
|
|
@@ -79,7 +88,9 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
|
|
|
79
88
|
this.readConnections = [];
|
|
80
89
|
for (let i = 0; i < READ_CONNECTIONS; i++) {
|
|
81
90
|
const conn = await this.openConnection(dbFilename);
|
|
82
|
-
|
|
91
|
+
for (let statement of readConnectionStatements) {
|
|
92
|
+
await conn.execute(statement);
|
|
93
|
+
}
|
|
83
94
|
this.readConnections.push({ busy: false, connection: conn });
|
|
84
95
|
}
|
|
85
96
|
}
|
package/src/db/SqliteOptions.ts
CHANGED
|
@@ -30,6 +30,21 @@ export interface SqliteOptions {
|
|
|
30
30
|
*/
|
|
31
31
|
encryptionKey?: string | null;
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Where to store SQLite temporary files. Defaults to 'MEMORY'.
|
|
35
|
+
* Setting this to `FILESYSTEM` can cause issues with larger queries or datasets.
|
|
36
|
+
*
|
|
37
|
+
* For details, see: https://www.sqlite.org/pragma.html#pragma_temp_store
|
|
38
|
+
*/
|
|
39
|
+
temporaryStorage?: TemporaryStorageOption;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Maximum SQLite cache size. Defaults to 50MB.
|
|
43
|
+
*
|
|
44
|
+
* For details, see: https://www.sqlite.org/pragma.html#pragma_cache_size
|
|
45
|
+
*/
|
|
46
|
+
cacheSizeKb?: number;
|
|
47
|
+
|
|
33
48
|
/**
|
|
34
49
|
* Load extensions using the path and entryPoint.
|
|
35
50
|
* More info can be found here https://op-engineering.github.io/op-sqlite/docs/api#loading-extensions.
|
|
@@ -40,6 +55,11 @@ export interface SqliteOptions {
|
|
|
40
55
|
}>;
|
|
41
56
|
}
|
|
42
57
|
|
|
58
|
+
export enum TemporaryStorageOption {
|
|
59
|
+
MEMORY = 'memory',
|
|
60
|
+
FILESYSTEM = 'file'
|
|
61
|
+
}
|
|
62
|
+
|
|
43
63
|
// SQLite journal mode. Set on the primary connection.
|
|
44
64
|
// This library is written with WAL mode in mind - other modes may cause
|
|
45
65
|
// unexpected locking behavior.
|
|
@@ -65,6 +85,8 @@ export const DEFAULT_SQLITE_OPTIONS: Required<SqliteOptions> = {
|
|
|
65
85
|
journalMode: SqliteJournalMode.wal,
|
|
66
86
|
synchronous: SqliteSynchronous.normal,
|
|
67
87
|
journalSizeLimit: 6 * 1024 * 1024,
|
|
88
|
+
cacheSizeKb: 50 * 1024,
|
|
89
|
+
temporaryStorage: TemporaryStorageOption.MEMORY,
|
|
68
90
|
lockTimeoutMs: 30000,
|
|
69
91
|
encryptionKey: null,
|
|
70
92
|
extensions: []
|