@powersync/web 0.0.0-dev-20260504100448 → 0.0.0-dev-20260630144038
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/bin/powersync.cjs +1 -1
- package/dist/index.react_native_web.js +1879 -0
- package/dist/index.react_native_web.js.map +1 -0
- package/dist/worker/AccessHandlePoolVFS-BPUHfZME.js +2 -0
- package/dist/worker/AccessHandlePoolVFS-BPUHfZME.js.map +1 -0
- package/dist/worker/FacadeVFS-d1ZDvud7.js +2 -0
- package/dist/worker/FacadeVFS-d1ZDvud7.js.map +1 -0
- package/dist/worker/IDBBatchAtomicVFS-DbkDb777.js +2 -0
- package/dist/worker/IDBBatchAtomicVFS-DbkDb777.js.map +1 -0
- package/dist/worker/OPFSCoopSyncVFS-DRKedN0p.js +2 -0
- package/dist/worker/OPFSCoopSyncVFS-DRKedN0p.js.map +1 -0
- package/dist/worker/OPFSWriteAheadVFS-BzodSqNq.js +2 -0
- package/dist/worker/OPFSWriteAheadVFS-BzodSqNq.js.map +1 -0
- package/dist/worker/mc-wa-sqlite-DiBqIVE5.js +2 -0
- package/dist/worker/mc-wa-sqlite-DiBqIVE5.js.map +1 -0
- package/dist/worker/mc-wa-sqlite-async-DUEhO9ef.js +2 -0
- package/dist/worker/mc-wa-sqlite-async-DUEhO9ef.js.map +1 -0
- package/dist/worker/wa-sqlite-BlSx7-_P.js +2 -0
- package/dist/worker/wa-sqlite-BlSx7-_P.js.map +1 -0
- package/dist/worker/wa-sqlite-async-BdR24Ucf.js +2 -0
- package/dist/worker/wa-sqlite-async-BdR24Ucf.js.map +1 -0
- package/dist/worker/websockets-Q8W_lerF.js +9 -0
- package/dist/worker/websockets-Q8W_lerF.js.map +1 -0
- package/dist/worker/worker.js +7 -0
- package/dist/worker/worker.js.map +1 -0
- package/lib/{src/attachments → attachments}/IndexDBFileSystemAdapter.js +1 -0
- package/lib/attachments/IndexDBFileSystemAdapter.js.map +1 -0
- package/lib/{src/db → db}/NavigatorTriggerClaimManager.d.ts +1 -1
- package/lib/{src/db → db}/NavigatorTriggerClaimManager.js +1 -0
- package/lib/db/NavigatorTriggerClaimManager.js.map +1 -0
- package/lib/db/PowerSyncDatabase.d.ts +67 -0
- package/lib/{src/db → db}/PowerSyncDatabase.js +48 -61
- package/lib/db/PowerSyncDatabase.js.map +1 -0
- package/lib/db/adapters/AsyncWebAdapter.d.ts +32 -0
- package/lib/{src/db → db}/adapters/AsyncWebAdapter.js +15 -14
- package/lib/db/adapters/AsyncWebAdapter.js.map +1 -0
- package/lib/db/adapters/SSRDBAdapter.d.ts +17 -0
- package/lib/db/adapters/SSRDBAdapter.js +37 -0
- package/lib/db/adapters/SSRDBAdapter.js.map +1 -0
- package/lib/{src/db → db}/adapters/WebDBAdapter.d.ts +1 -1
- package/lib/db/adapters/WebDBAdapter.js +2 -0
- package/lib/db/adapters/WebDBAdapter.js.map +1 -0
- package/lib/db/adapters/options.d.ts +87 -0
- package/lib/db/adapters/options.js +6 -0
- package/lib/db/adapters/options.js.map +1 -0
- package/lib/db/adapters/resolveAndValidateOptions.d.ts +5 -0
- package/lib/db/adapters/resolveAndValidateOptions.js +33 -0
- package/lib/db/adapters/resolveAndValidateOptions.js.map +1 -0
- package/lib/{src/db → db}/adapters/wa-sqlite/ConcurrentConnection.d.ts +3 -4
- package/lib/{src/db → db}/adapters/wa-sqlite/ConcurrentConnection.js +3 -2
- package/lib/db/adapters/wa-sqlite/ConcurrentConnection.js.map +1 -0
- package/lib/{src/db → db}/adapters/wa-sqlite/DatabaseClient.d.ts +4 -4
- package/lib/{src/db → db}/adapters/wa-sqlite/DatabaseClient.js +12 -37
- package/lib/db/adapters/wa-sqlite/DatabaseClient.js.map +1 -0
- package/lib/{src/db → db}/adapters/wa-sqlite/DatabaseServer.d.ts +5 -5
- package/lib/{src/db → db}/adapters/wa-sqlite/DatabaseServer.js +12 -7
- package/lib/db/adapters/wa-sqlite/DatabaseServer.js.map +1 -0
- package/lib/{src/db → db}/adapters/wa-sqlite/RawSqliteConnection.d.ts +22 -12
- package/lib/{src/db → db}/adapters/wa-sqlite/RawSqliteConnection.js +12 -10
- package/lib/db/adapters/wa-sqlite/RawSqliteConnection.js.map +1 -0
- package/lib/db/adapters/wa-sqlite/WASQLiteOpenFactory.d.ts +18 -0
- package/lib/db/adapters/wa-sqlite/WASQLiteOpenFactory.js +131 -0
- package/lib/db/adapters/wa-sqlite/WASQLiteOpenFactory.js.map +1 -0
- package/lib/{src/db → db}/adapters/wa-sqlite/vfs.js +1 -0
- package/lib/db/adapters/wa-sqlite/vfs.js.map +1 -0
- package/lib/{src/db → db}/sync/SSRWebStreamingSyncImplementation.d.ts +4 -8
- package/lib/{src/db → db}/sync/SSRWebStreamingSyncImplementation.js +5 -11
- package/lib/db/sync/SSRWebStreamingSyncImplementation.js.map +1 -0
- package/lib/{src/db → db}/sync/SharedWebStreamingSyncImplementation.d.ts +13 -14
- package/lib/{src/db → db}/sync/SharedWebStreamingSyncImplementation.js +32 -66
- package/lib/db/sync/SharedWebStreamingSyncImplementation.js.map +1 -0
- package/lib/db/sync/WebRemote.d.ts +10 -0
- package/lib/db/sync/WebRemote.js +33 -0
- package/lib/db/sync/WebRemote.js.map +1 -0
- package/lib/{src/db → db}/sync/WebStreamingSyncImplementation.d.ts +2 -4
- package/lib/{src/db → db}/sync/WebStreamingSyncImplementation.js +4 -2
- package/lib/db/sync/WebStreamingSyncImplementation.js.map +1 -0
- package/lib/{src/db → db}/sync/userAgent.js +1 -0
- package/lib/db/sync/userAgent.js.map +1 -0
- package/lib/{src/index.d.ts → index.d.ts} +1 -3
- package/lib/{src/index.js → index.js} +2 -3
- package/lib/index.js.map +1 -0
- package/lib/{src/shared → shared}/navigator.js +1 -0
- package/lib/shared/navigator.js.map +1 -0
- package/lib/{src/shared → shared}/tab_close_signal.js +1 -0
- package/lib/shared/tab_close_signal.js.map +1 -0
- package/lib/worker/SharedWorkerConnectionRequest.d.ts +5 -0
- package/lib/worker/SharedWorkerConnectionRequest.js +2 -0
- package/lib/worker/SharedWorkerConnectionRequest.js.map +1 -0
- package/lib/worker/client.d.ts +15 -0
- package/lib/worker/client.js +77 -0
- package/lib/worker/client.js.map +1 -0
- package/lib/worker/db/MultiDatabaseServer.d.ts +22 -0
- package/lib/{src/worker → worker}/db/MultiDatabaseServer.js +26 -15
- package/lib/worker/db/MultiDatabaseServer.js.map +1 -0
- package/lib/worker/sync/AbstractSharedSyncClientProvider.d.ts +13 -0
- package/lib/{src/worker → worker}/sync/AbstractSharedSyncClientProvider.js +1 -0
- package/lib/worker/sync/AbstractSharedSyncClientProvider.js.map +1 -0
- package/lib/worker/sync/BroadcastLogger.d.ts +27 -0
- package/lib/worker/sync/BroadcastLogger.js +65 -0
- package/lib/worker/sync/BroadcastLogger.js.map +1 -0
- package/lib/{src/worker → worker}/sync/SharedSyncImplementation.d.ts +11 -15
- package/lib/{src/worker → worker}/sync/SharedSyncImplementation.js +43 -43
- package/lib/worker/sync/SharedSyncImplementation.js.map +1 -0
- package/lib/{src/worker → worker}/sync/WorkerClient.d.ts +3 -3
- package/lib/{src/worker → worker}/sync/WorkerClient.js +3 -2
- package/lib/worker/sync/WorkerClient.js.map +1 -0
- package/lib/worker/worker.js +34 -0
- package/lib/worker/worker.js.map +1 -0
- package/package.json +22 -29
- package/src/db/NavigatorTriggerClaimManager.ts +1 -1
- package/src/db/PowerSyncDatabase.ts +80 -122
- package/src/db/adapters/AsyncWebAdapter.ts +17 -26
- package/src/db/adapters/SSRDBAdapter.ts +14 -64
- package/src/db/adapters/WebDBAdapter.ts +1 -1
- package/src/db/adapters/options.ts +100 -0
- package/src/db/adapters/resolveAndValidateOptions.ts +40 -0
- package/src/db/adapters/wa-sqlite/ConcurrentConnection.ts +4 -5
- package/src/db/adapters/wa-sqlite/DatabaseClient.ts +20 -56
- package/src/db/adapters/wa-sqlite/DatabaseServer.ts +15 -12
- package/src/db/adapters/wa-sqlite/RawSqliteConnection.ts +35 -24
- package/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.ts +63 -126
- package/src/db/sync/SSRWebStreamingSyncImplementation.ts +4 -22
- package/src/db/sync/SharedWebStreamingSyncImplementation.ts +38 -77
- package/src/db/sync/WebRemote.ts +23 -26
- package/src/db/sync/WebStreamingSyncImplementation.ts +4 -5
- package/src/index.ts +1 -3
- package/src/worker/SharedWorkerConnectionRequest.ts +6 -0
- package/src/worker/client.ts +100 -0
- package/src/worker/db/MultiDatabaseServer.ts +40 -22
- package/src/worker/sync/AbstractSharedSyncClientProvider.ts +4 -10
- package/src/worker/sync/BroadcastLogger.ts +35 -103
- package/src/worker/sync/SharedSyncImplementation.ts +62 -63
- package/src/worker/sync/WorkerClient.ts +4 -4
- package/src/worker/worker.ts +38 -0
- package/dist/index.umd.js +0 -7613
- package/dist/index.umd.js.map +0 -1
- package/dist/worker/SharedSyncImplementation.umd.js +0 -15885
- package/dist/worker/SharedSyncImplementation.umd.js.map +0 -1
- package/dist/worker/WASQLiteDB.umd.js +0 -17164
- package/dist/worker/WASQLiteDB.umd.js.map +0 -1
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-9af0a7.umd.js +0 -31
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-9af0a7.umd.js.map +0 -1
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-bbf5a9.umd.js +0 -31
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-bbf5a9.umd.js.map +0 -1
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-c26e0f.umd.js +0 -31
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-c26e0f.umd.js.map +0 -1
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js +0 -31
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js.map +0 -1
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-2fb422.umd.js +0 -3562
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-2fb422.umd.js.map +0 -1
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-96fb23.umd.js +0 -2478
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-96fb23.umd.js.map +0 -1
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-c89911.umd.js +0 -1681
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-c89911.umd.js.map +0 -1
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-ec4eb1.umd.js +0 -1820
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-ec4eb1.umd.js.map +0 -1
- package/lib/package.json +0 -91
- package/lib/src/db/PowerSyncDatabase.d.ts +0 -78
- package/lib/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.d.ts +0 -23
- package/lib/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.js +0 -26
- package/lib/src/db/adapters/AsyncWebAdapter.d.ts +0 -50
- package/lib/src/db/adapters/SSRDBAdapter.d.ts +0 -30
- package/lib/src/db/adapters/SSRDBAdapter.js +0 -68
- package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.d.ts +0 -45
- package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.js +0 -145
- package/lib/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.d.ts +0 -15
- package/lib/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.js +0 -21
- package/lib/src/db/adapters/web-sql-flags.d.ts +0 -92
- package/lib/src/db/adapters/web-sql-flags.js +0 -36
- package/lib/src/db/sync/WebRemote.d.ts +0 -7
- package/lib/src/db/sync/WebRemote.js +0 -32
- package/lib/src/worker/db/MultiDatabaseServer.d.ts +0 -17
- package/lib/src/worker/db/WASQLiteDB.worker.d.ts +0 -4
- package/lib/src/worker/db/WASQLiteDB.worker.js +0 -30
- package/lib/src/worker/db/open-worker-database.d.ts +0 -14
- package/lib/src/worker/db/open-worker-database.js +0 -52
- package/lib/src/worker/sync/AbstractSharedSyncClientProvider.d.ts +0 -19
- package/lib/src/worker/sync/BroadcastLogger.d.ts +0 -47
- package/lib/src/worker/sync/BroadcastLogger.js +0 -128
- package/lib/src/worker/sync/SharedSyncImplementation.worker.d.ts +0 -1
- package/lib/src/worker/sync/SharedSyncImplementation.worker.js +0 -11
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.ts +0 -47
- package/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.ts +0 -24
- package/src/db/adapters/web-sql-flags.ts +0 -141
- package/src/worker/db/WASQLiteDB.worker.ts +0 -35
- package/src/worker/db/open-worker-database.ts +0 -62
- package/src/worker/sync/SharedSyncImplementation.worker.ts +0 -14
- /package/dist/{8e97452e297be23b5e50.wasm → worker/assets/mc-wa-sqlite-CnHbhWvs.wasm} +0 -0
- /package/dist/{2075a31bb151adbb9767.wasm → worker/assets/mc-wa-sqlite-async-D6idQS2r.wasm} +0 -0
- /package/dist/{3322bc84de986b63c2cd.wasm → worker/assets/wa-sqlite-XZW__iJk.wasm} +0 -0
- /package/dist/{fbc178b70d530e8ce02b.wasm → worker/assets/wa-sqlite-async-rHzzC98y.wasm} +0 -0
- /package/lib/{src/attachments → attachments}/IndexDBFileSystemAdapter.d.ts +0 -0
- /package/lib/{src/db → db}/adapters/wa-sqlite/vfs.d.ts +0 -0
- /package/lib/{src/db → db}/sync/userAgent.d.ts +0 -0
- /package/lib/{src/shared → shared}/navigator.d.ts +0 -0
- /package/lib/{src/shared → shared}/tab_close_signal.d.ts +0 -0
- /package/lib/{src/db/adapters/WebDBAdapter.js → worker/worker.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powersync/web",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20260630144038",
|
|
4
4
|
"description": "PowerSync Web SDK",
|
|
5
|
-
"main": "lib/
|
|
6
|
-
"module": "lib/
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"module": "lib/index.js",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"types": "lib/
|
|
8
|
+
"types": "lib/index.d.ts",
|
|
9
9
|
"bin": {
|
|
10
10
|
"powersync-web": "bin/powersync.cjs"
|
|
11
11
|
},
|
|
@@ -18,22 +18,14 @@
|
|
|
18
18
|
],
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
|
-
"types": "./lib/
|
|
22
|
-
"
|
|
21
|
+
"types": "./lib/index.d.ts",
|
|
22
|
+
"react-native-web": "./dist/index.react_native_web.js",
|
|
23
|
+
"react-native": "./dist/index.react_native_web.js",
|
|
24
|
+
"default": "./lib/index.js"
|
|
23
25
|
},
|
|
24
|
-
"./
|
|
25
|
-
"types": "./lib/
|
|
26
|
-
"default": "./dist/
|
|
27
|
-
},
|
|
28
|
-
"./umd/worker/db": {
|
|
29
|
-
"types": "./lib/src/index.d.ts",
|
|
30
|
-
"import": "./dist/worker/WASQLiteDB.umd.js",
|
|
31
|
-
"require": "./dist/worker/WASQLiteDB.umd.js"
|
|
32
|
-
},
|
|
33
|
-
"./umd/worker/sync": {
|
|
34
|
-
"types": "./lib/src/index.d.ts",
|
|
35
|
-
"import": "./dist/worker/SharedSyncImplementation.umd.js",
|
|
36
|
-
"require": "./dist/worker/SharedSyncImplementation.umd.js"
|
|
26
|
+
"./bundled_worker": {
|
|
27
|
+
"types": "./lib/worker/worker.d.ts",
|
|
28
|
+
"default": "./dist/worker/worker.js"
|
|
37
29
|
}
|
|
38
30
|
},
|
|
39
31
|
"repository": "https://github.com/powersync-ja/powersync-js",
|
|
@@ -56,12 +48,14 @@
|
|
|
56
48
|
"license": "Apache-2.0",
|
|
57
49
|
"peerDependencies": {
|
|
58
50
|
"@journeyapps/wa-sqlite": "^1.5.0",
|
|
59
|
-
"@powersync/common": "0.0.0-dev-
|
|
51
|
+
"@powersync/common": "0.0.0-dev-20260630144038",
|
|
52
|
+
"@powersync/shared-internals": "1.0.0"
|
|
60
53
|
},
|
|
61
54
|
"dependencies": {
|
|
62
55
|
"comlink": "^4.4.2",
|
|
63
56
|
"commander": "^12.1.0",
|
|
64
|
-
"@powersync/common": "0.0.0-dev-
|
|
57
|
+
"@powersync/common": "0.0.0-dev-20260630144038",
|
|
58
|
+
"@powersync/shared-internals": "1.0.0"
|
|
65
59
|
},
|
|
66
60
|
"devDependencies": {
|
|
67
61
|
"@journeyapps/wa-sqlite": "^1.7.0",
|
|
@@ -70,19 +64,18 @@
|
|
|
70
64
|
"glob": "^11.0.0",
|
|
71
65
|
"p-defer": "^4.0.1",
|
|
72
66
|
"source-map-loader": "^5.0.0",
|
|
73
|
-
"terser-webpack-plugin": "^5.3.9",
|
|
74
67
|
"uuid": "^11.1.0",
|
|
75
68
|
"vite": "^7.3.1",
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
69
|
+
"rollup": "^4.52.5",
|
|
70
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
71
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
72
|
+
"estree-walker": "^3.0.3",
|
|
73
|
+
"magic-string": "^0.30.21"
|
|
79
74
|
},
|
|
80
75
|
"scripts": {
|
|
81
76
|
"build:tsc": "tsc --build",
|
|
82
|
-
"build:
|
|
83
|
-
"build:
|
|
84
|
-
"build": "pnpm run build:tsc && pnpm run build:webpack-main && pnpm run build:webpack-workers",
|
|
85
|
-
"build:prod": "pnpm run build:tsc --sourceMap false && pnpm run build:webpack-main && pnpm run build:webpack-workers",
|
|
77
|
+
"build": "pnpm run build:tsc && rollup --config",
|
|
78
|
+
"build:prod": "pnpm run build",
|
|
86
79
|
"clean": "rm -rf lib dist tsconfig.tsbuildinfo",
|
|
87
80
|
"watch": "tsc --build -w",
|
|
88
81
|
"test": "pnpm build && vitest",
|
|
@@ -1,32 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
type PowerSyncBackendConnector,
|
|
3
|
+
type PowerSyncCloseOptions,
|
|
4
|
+
LogLevels,
|
|
5
|
+
BasePowerSyncDatabaseOptions,
|
|
6
|
+
DatabaseSource,
|
|
3
7
|
DBAdapter,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
PowerSyncDatabaseConstructor,
|
|
9
|
+
CommonPowerSyncDatabase
|
|
10
|
+
} from '@powersync/common';
|
|
11
|
+
import {
|
|
12
|
+
BasePowerSyncDatabase,
|
|
13
|
+
BucketStorageAdapter,
|
|
14
|
+
CreateSyncImplementationOptions,
|
|
15
|
+
Mutex,
|
|
8
16
|
SqliteBucketStorage,
|
|
9
17
|
StreamingSyncImplementation,
|
|
10
18
|
TriggerManagerConfig,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Mutex,
|
|
14
|
-
type BucketStorageAdapter,
|
|
15
|
-
type PowerSyncBackendConnector,
|
|
16
|
-
type PowerSyncCloseOptions,
|
|
17
|
-
type RequiredAdditionalConnectionOptions
|
|
18
|
-
} from '@powersync/common';
|
|
19
|
+
openDatabase
|
|
20
|
+
} from '@powersync/shared-internals';
|
|
19
21
|
import { getNavigatorLocks } from '../shared/navigator.js';
|
|
20
22
|
import { NAVIGATOR_TRIGGER_CLAIM_MANAGER } from './NavigatorTriggerClaimManager.js';
|
|
21
23
|
import { WebDBAdapter } from './adapters/WebDBAdapter.js';
|
|
22
24
|
import { WASQLiteOpenFactory } from './adapters/wa-sqlite/WASQLiteOpenFactory.js';
|
|
23
|
-
import {
|
|
24
|
-
DEFAULT_WEB_SQL_FLAGS,
|
|
25
|
-
ResolvedWebSQLOpenOptions,
|
|
26
|
-
WebSQLFlags,
|
|
27
|
-
isServerSide,
|
|
28
|
-
resolveWebSQLFlags
|
|
29
|
-
} from './adapters/web-sql-flags.js';
|
|
25
|
+
import { WebSpecificOpenOptions, WebSQLOpenOptions } from './adapters/options.js';
|
|
30
26
|
import { SSRStreamingSyncImplementation } from './sync/SSRWebStreamingSyncImplementation.js';
|
|
31
27
|
import { SharedWebStreamingSyncImplementation } from './sync/SharedWebStreamingSyncImplementation.js';
|
|
32
28
|
import { WebRemote } from './sync/WebRemote.js';
|
|
@@ -35,19 +31,22 @@ import {
|
|
|
35
31
|
WebStreamingSyncImplementationOptions
|
|
36
32
|
} from './sync/WebStreamingSyncImplementation.js';
|
|
37
33
|
import { AsyncDbAdapter } from './adapters/AsyncWebAdapter.js';
|
|
34
|
+
import { resolveAndValidateOptions } from './adapters/resolveAndValidateOptions.js';
|
|
35
|
+
|
|
36
|
+
export type WebPowerSyncDatabaseOptions = BasePowerSyncDatabaseOptions &
|
|
37
|
+
DatabaseSource<WebSQLOpenOptions> &
|
|
38
|
+
WebSpecificOptions;
|
|
39
|
+
|
|
40
|
+
export interface WebSpecificOptions {
|
|
41
|
+
sync?: WebSyncOptions;
|
|
38
42
|
|
|
39
|
-
export interface WebPowerSyncFlags extends WebSQLFlags {
|
|
40
43
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* Setting this to `true` requires calling `close` on all open PowerSyncDatabase
|
|
44
|
-
* instances before the window unloads
|
|
44
|
+
* Broadcast logs from shared workers, such as the shared sync worker,
|
|
45
|
+
* to individual tabs. This defaults to true.
|
|
45
46
|
*/
|
|
46
|
-
|
|
47
|
+
broadcastLogs?: boolean;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
type WithWebFlags<Base> = Base & { flags?: WebPowerSyncFlags };
|
|
50
|
-
|
|
51
50
|
export interface WebSyncOptions {
|
|
52
51
|
/**
|
|
53
52
|
* Allows you to override the default sync worker.
|
|
@@ -55,91 +54,31 @@ export interface WebSyncOptions {
|
|
|
55
54
|
* You can either provide a path to the worker script
|
|
56
55
|
* or a factory method that returns a worker.
|
|
57
56
|
*/
|
|
58
|
-
worker?: string | URL | ((
|
|
59
|
-
}
|
|
57
|
+
worker?: string | URL | (() => SharedWorker);
|
|
60
58
|
|
|
61
|
-
type WithWebSyncOptions<Base> = Base & {
|
|
62
|
-
sync?: WebSyncOptions;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export interface WebEncryptionOptions {
|
|
66
59
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
60
|
+
* The log level for logs from the sync worker.
|
|
61
|
+
*
|
|
62
|
+
* Defaults to {@link LogLevels.info}.
|
|
69
63
|
*/
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
type WithWebEncryptionOptions<Base> = Base & WebEncryptionOptions;
|
|
74
|
-
|
|
75
|
-
export type WebPowerSyncDatabaseOptionsWithAdapter = WithWebSyncOptions<
|
|
76
|
-
WithWebFlags<PowerSyncDatabaseOptionsWithDBAdapter>
|
|
77
|
-
>;
|
|
78
|
-
export type WebPowerSyncDatabaseOptionsWithOpenFactory = WithWebSyncOptions<
|
|
79
|
-
WithWebFlags<PowerSyncDatabaseOptionsWithOpenFactory>
|
|
80
|
-
>;
|
|
81
|
-
export type WebPowerSyncDatabaseOptionsWithSettings = WithWebSyncOptions<
|
|
82
|
-
WithWebFlags<WithWebEncryptionOptions<PowerSyncDatabaseOptionsWithSettings>>
|
|
83
|
-
>;
|
|
84
|
-
|
|
85
|
-
export type WebPowerSyncDatabaseOptions = WithWebSyncOptions<WithWebFlags<PowerSyncDatabaseOptions>>;
|
|
86
|
-
|
|
87
|
-
export const DEFAULT_POWERSYNC_FLAGS: Required<WebPowerSyncFlags> = {
|
|
88
|
-
...DEFAULT_WEB_SQL_FLAGS,
|
|
89
|
-
externallyUnload: false
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export const resolveWebPowerSyncFlags = (flags?: WebPowerSyncFlags): Required<WebPowerSyncFlags> => {
|
|
93
|
-
return {
|
|
94
|
-
...DEFAULT_POWERSYNC_FLAGS,
|
|
95
|
-
...flags,
|
|
96
|
-
...resolveWebSQLFlags(flags)
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Asserts that the database options are valid for custom database constructors.
|
|
102
|
-
*/
|
|
103
|
-
function assertValidDatabaseOptions(options: WebPowerSyncDatabaseOptions): void {
|
|
104
|
-
if ('database' in options && 'encryptionKey' in options) {
|
|
105
|
-
const { database } = options;
|
|
106
|
-
if (isSQLOpenFactory(database) || isDBAdapter(database)) {
|
|
107
|
-
throw new Error(
|
|
108
|
-
`Invalid configuration: 'encryptionKey' should only be included inside the database object when using a custom ${isSQLOpenFactory(database) ? 'WASQLiteOpenFactory' : 'WASQLiteDBAdapter'} constructor.`
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
64
|
+
logLevel?: number;
|
|
112
65
|
}
|
|
113
66
|
|
|
114
67
|
/**
|
|
115
|
-
*
|
|
116
|
-
* which is automatically synced.
|
|
117
|
-
*
|
|
118
|
-
* @example
|
|
119
|
-
* ```typescript
|
|
120
|
-
* export const db = new PowerSyncDatabase({
|
|
121
|
-
* schema: AppSchema,
|
|
122
|
-
* database: {
|
|
123
|
-
* dbFilename: 'example.db'
|
|
124
|
-
* }
|
|
125
|
-
* });
|
|
126
|
-
* ```
|
|
68
|
+
* @internal Use {@link PowerSyncDatabase} instead, this class is only used by other SDKs also needing web support.
|
|
127
69
|
*/
|
|
128
|
-
export class
|
|
70
|
+
export class WebPowerSyncDatabase extends BasePowerSyncDatabase<WebPowerSyncDatabaseOptions> {
|
|
129
71
|
static SHARED_MUTEX = new Mutex();
|
|
130
72
|
|
|
131
|
-
protected
|
|
73
|
+
protected resolvedOpenOptions: WebSpecificOpenOptions;
|
|
74
|
+
protected enableBroadcastLogs: boolean;
|
|
132
75
|
|
|
133
|
-
constructor(options:
|
|
134
|
-
|
|
135
|
-
constructor(options: WebPowerSyncDatabaseOptionsWithSettings);
|
|
136
|
-
constructor(options: WebPowerSyncDatabaseOptions);
|
|
137
|
-
constructor(protected options: WebPowerSyncDatabaseOptions) {
|
|
138
|
-
super(options);
|
|
139
|
-
|
|
140
|
-
assertValidDatabaseOptions(options);
|
|
76
|
+
constructor(options: WebPowerSyncDatabaseOptions) {
|
|
77
|
+
const resolvedOpenOptions = resolveAndValidateOptions('database' in options ? options.database : {});
|
|
141
78
|
|
|
142
|
-
|
|
79
|
+
super(options);
|
|
80
|
+
this.resolvedOpenOptions = resolvedOpenOptions;
|
|
81
|
+
this.enableBroadcastLogs = options.broadcastLogs ?? true;
|
|
143
82
|
}
|
|
144
83
|
|
|
145
84
|
async _initialize(): Promise<void> {
|
|
@@ -170,13 +109,14 @@ export class PowerSyncDatabase extends AbstractPowerSyncDatabase {
|
|
|
170
109
|
};
|
|
171
110
|
}
|
|
172
111
|
|
|
173
|
-
protected openDBAdapter(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
112
|
+
protected override openDBAdapter(): DBAdapter {
|
|
113
|
+
return openDatabase(this.options, (options) => {
|
|
114
|
+
const defaultFactory = new WASQLiteOpenFactory({
|
|
115
|
+
logger: this.logger,
|
|
116
|
+
open: options
|
|
117
|
+
});
|
|
118
|
+
return defaultFactory.openDB();
|
|
178
119
|
});
|
|
179
|
-
return defaultFactory.openDB();
|
|
180
120
|
}
|
|
181
121
|
|
|
182
122
|
/**
|
|
@@ -187,44 +127,43 @@ export class PowerSyncDatabase extends AbstractPowerSyncDatabase {
|
|
|
187
127
|
close(options?: PowerSyncCloseOptions): Promise<void> {
|
|
188
128
|
return super.close({
|
|
189
129
|
// Don't disconnect by default if multiple tabs are enabled
|
|
190
|
-
disconnect: options?.disconnect ?? !this.
|
|
130
|
+
disconnect: options?.disconnect ?? !this.resolvedOpenOptions.enableMultiTabs
|
|
191
131
|
});
|
|
192
132
|
}
|
|
193
133
|
|
|
194
134
|
protected async loadVersion(): Promise<void> {
|
|
195
|
-
if (
|
|
135
|
+
if (this.resolvedOpenOptions.ssrMode) {
|
|
196
136
|
return;
|
|
197
137
|
}
|
|
198
138
|
return super.loadVersion();
|
|
199
139
|
}
|
|
200
140
|
|
|
201
141
|
protected async resolveOfflineSyncStatus() {
|
|
202
|
-
if (
|
|
142
|
+
if (this.resolvedOpenOptions.ssrMode) {
|
|
203
143
|
return;
|
|
204
144
|
}
|
|
205
145
|
return super.resolveOfflineSyncStatus();
|
|
206
146
|
}
|
|
207
147
|
|
|
208
148
|
protected generateBucketStorageAdapter(): BucketStorageAdapter {
|
|
209
|
-
return new SqliteBucketStorage(this.database);
|
|
149
|
+
return new SqliteBucketStorage(this.database, this.logger);
|
|
210
150
|
}
|
|
211
151
|
|
|
212
152
|
protected async runExclusive<T>(cb: () => Promise<T>) {
|
|
213
|
-
if (this.
|
|
214
|
-
return
|
|
153
|
+
if (this.resolvedOpenOptions.ssrMode) {
|
|
154
|
+
return WebPowerSyncDatabase.SHARED_MUTEX.runExclusive(cb);
|
|
215
155
|
}
|
|
216
156
|
return getNavigatorLocks().request(`lock-${this.database.name}`, cb);
|
|
217
157
|
}
|
|
218
158
|
|
|
219
159
|
protected generateSyncStreamImplementation(
|
|
220
160
|
connector: PowerSyncBackendConnector,
|
|
221
|
-
options:
|
|
161
|
+
options: CreateSyncImplementationOptions
|
|
222
162
|
): StreamingSyncImplementation {
|
|
223
163
|
const remote = new WebRemote(connector, this.logger);
|
|
224
164
|
const syncOptions: WebStreamingSyncImplementationOptions = {
|
|
225
165
|
...(this.options as {}),
|
|
226
166
|
...options,
|
|
227
|
-
flags: this.resolvedFlags,
|
|
228
167
|
adapter: this.bucketStorageAdapter,
|
|
229
168
|
remote,
|
|
230
169
|
uploadCrud: async () => {
|
|
@@ -236,23 +175,42 @@ export class PowerSyncDatabase extends AbstractPowerSyncDatabase {
|
|
|
236
175
|
};
|
|
237
176
|
|
|
238
177
|
switch (true) {
|
|
239
|
-
case this.
|
|
240
|
-
return new SSRStreamingSyncImplementation(
|
|
241
|
-
case this.
|
|
242
|
-
if (!this.
|
|
178
|
+
case this.resolvedOpenOptions.ssrMode:
|
|
179
|
+
return new SSRStreamingSyncImplementation();
|
|
180
|
+
case this.resolvedOpenOptions.enableMultiTabs:
|
|
181
|
+
if (!this.enableBroadcastLogs) {
|
|
243
182
|
const warning = `
|
|
244
183
|
Multiple tabs are enabled, but broadcasting of logs is disabled.
|
|
245
184
|
Logs for shared sync worker will only be available in the shared worker context
|
|
246
185
|
`;
|
|
247
186
|
const logger = this.options.logger;
|
|
248
|
-
logger ? logger.warn
|
|
187
|
+
logger ? logger.log({ level: LogLevels.warn, message: warning }) : console.warn(warning);
|
|
249
188
|
}
|
|
250
189
|
return new SharedWebStreamingSyncImplementation({
|
|
251
190
|
...syncOptions,
|
|
252
|
-
db: this.database as WebDBAdapter // This should always be the case
|
|
191
|
+
db: this.database as WebDBAdapter, // This should always be the case
|
|
192
|
+
logLevel: this.options.sync?.logLevel ?? LogLevels.info,
|
|
193
|
+
enableBroadcastLogs: this.enableBroadcastLogs
|
|
253
194
|
});
|
|
254
195
|
default:
|
|
255
196
|
return new WebStreamingSyncImplementation(syncOptions);
|
|
256
197
|
}
|
|
257
198
|
}
|
|
258
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* A PowerSync database which provides SQLite functionality
|
|
202
|
+
* which is automatically synced.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* export const db = new PowerSyncDatabase({
|
|
207
|
+
* schema: AppSchema,
|
|
208
|
+
* database: {
|
|
209
|
+
* dbFilename: 'example.db'
|
|
210
|
+
* }
|
|
211
|
+
* });
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
// Typed constructor to avoid leaking AbstractPowerSyncDatabase into the public interface
|
|
215
|
+
export const PowerSyncDatabase: PowerSyncDatabaseConstructor<WebPowerSyncDatabaseOptions> = WebPowerSyncDatabase;
|
|
216
|
+
export interface PowerSyncDatabase extends CommonPowerSyncDatabase {}
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
DBAdapterDefaultMixin,
|
|
4
|
-
DBAdapterListener,
|
|
5
|
-
DBLockOptions,
|
|
6
|
-
LockContext,
|
|
7
|
-
Mutex,
|
|
8
|
-
Semaphore,
|
|
9
|
-
UnlockFn
|
|
10
|
-
} from '@powersync/common';
|
|
1
|
+
import { DBAdapter, DBAdapterListener, DBLockOptions, LockContext } from '@powersync/common';
|
|
2
|
+
import { Mutex, Semaphore, UnlockFn } from '@powersync/shared-internals';
|
|
11
3
|
import { SharedConnectionWorker, WebDBAdapter, WebDBAdapterConfiguration } from './WebDBAdapter.js';
|
|
12
4
|
import { DatabaseClient } from './wa-sqlite/DatabaseClient.js';
|
|
13
5
|
|
|
@@ -16,7 +8,7 @@ type PendingListener = { listener: Partial<DBAdapterListener>; closeAfterRegiste
|
|
|
16
8
|
/**
|
|
17
9
|
* A connection pool implementation delegating to another pool opened asynchronnously.
|
|
18
10
|
*/
|
|
19
|
-
class
|
|
11
|
+
export class AsyncDbAdapter extends DBAdapter {
|
|
20
12
|
protected readonly state: Promise<PoolState>;
|
|
21
13
|
protected resolvedWriter?: DatabaseClient;
|
|
22
14
|
|
|
@@ -26,6 +18,7 @@ class AsyncConnectionPool implements ConnectionPool {
|
|
|
26
18
|
inner: Promise<PoolConnection>,
|
|
27
19
|
readonly name: string
|
|
28
20
|
) {
|
|
21
|
+
super();
|
|
29
22
|
this.state = inner.then((client) => {
|
|
30
23
|
for (const pending of this.pendingListeners) {
|
|
31
24
|
pending.closeAfterRegisteredOnResolvedPool = client.writer.registerListener(pending.listener);
|
|
@@ -81,6 +74,19 @@ class AsyncConnectionPool implements ConnectionPool {
|
|
|
81
74
|
};
|
|
82
75
|
}
|
|
83
76
|
}
|
|
77
|
+
|
|
78
|
+
async shareConnection(): Promise<SharedConnectionWorker> {
|
|
79
|
+
const state = await this.state;
|
|
80
|
+
return state.writer.shareConnection();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getConfiguration(): WebDBAdapterConfiguration {
|
|
84
|
+
if (this.resolvedWriter) {
|
|
85
|
+
return this.resolvedWriter.getConfiguration();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
throw new Error('AsyncDbAdapter.getConfiguration() can only be called after initializing it.');
|
|
89
|
+
}
|
|
84
90
|
}
|
|
85
91
|
|
|
86
92
|
export interface PoolConnection {
|
|
@@ -190,18 +196,3 @@ function readWritePoolState(writer: DatabaseClient, readers: DatabaseClient[]):
|
|
|
190
196
|
}
|
|
191
197
|
};
|
|
192
198
|
}
|
|
193
|
-
|
|
194
|
-
export class AsyncDbAdapter extends DBAdapterDefaultMixin(AsyncConnectionPool) implements WebDBAdapter {
|
|
195
|
-
async shareConnection(): Promise<SharedConnectionWorker> {
|
|
196
|
-
const state = await this.state;
|
|
197
|
-
return state.writer.shareConnection();
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
getConfiguration(): WebDBAdapterConfiguration {
|
|
201
|
-
if (this.resolvedWriter) {
|
|
202
|
-
return this.resolvedWriter.getConfiguration();
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
throw new Error('AsyncDbAdapter.getConfiguration() can only be called after initializing it.');
|
|
206
|
-
}
|
|
207
|
-
}
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
DBAdapterListener,
|
|
4
|
-
DBAdapter,
|
|
5
|
-
DBLockOptions,
|
|
6
|
-
LockContext,
|
|
7
|
-
QueryResult,
|
|
8
|
-
Transaction,
|
|
9
|
-
Mutex,
|
|
10
|
-
timeoutSignal
|
|
11
|
-
} from '@powersync/common';
|
|
1
|
+
import { DBAdapter, DBLockOptions, LockContext, RawQueryResult } from '@powersync/common';
|
|
2
|
+
import { Mutex } from '@powersync/shared-internals';
|
|
12
3
|
|
|
13
|
-
const MOCK_QUERY_RESPONSE:
|
|
14
|
-
rowsAffected: 0
|
|
4
|
+
const MOCK_QUERY_RESPONSE: RawQueryResult = {
|
|
5
|
+
rowsAffected: 0,
|
|
6
|
+
columnNames: [],
|
|
7
|
+
rawRows: []
|
|
15
8
|
};
|
|
16
9
|
|
|
17
10
|
/**
|
|
@@ -19,7 +12,7 @@ const MOCK_QUERY_RESPONSE: QueryResult = {
|
|
|
19
12
|
* This adapter will return empty results for queries, which will allow
|
|
20
13
|
* server rendered views to initially generate scaffolding components
|
|
21
14
|
*/
|
|
22
|
-
export class SSRDBAdapter extends
|
|
15
|
+
export class SSRDBAdapter extends DBAdapter {
|
|
23
16
|
name: string;
|
|
24
17
|
readMutex: Mutex;
|
|
25
18
|
writeMutex: Mutex;
|
|
@@ -34,61 +27,18 @@ export class SSRDBAdapter extends BaseObserver<DBAdapterListener> implements DBA
|
|
|
34
27
|
close() {}
|
|
35
28
|
|
|
36
29
|
async readLock<T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions) {
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async readTransaction<T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions) {
|
|
41
|
-
return this.readLock(() => fn(this.generateMockTransactionContext()), options);
|
|
30
|
+
return fn(new StubLockContext());
|
|
42
31
|
}
|
|
43
32
|
|
|
44
33
|
async writeLock<T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions) {
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async writeTransaction<T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions) {
|
|
49
|
-
return this.writeLock(() => fn(this.generateMockTransactionContext()), options);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async execute(query: string, params?: any[]): Promise<QueryResult> {
|
|
53
|
-
return this.writeMutex.runExclusive(async () => MOCK_QUERY_RESPONSE);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async executeRaw(query: string, params?: any[]): Promise<any[][]> {
|
|
57
|
-
return this.writeMutex.runExclusive(async () => []);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async executeBatch(query: string, params?: any[][]): Promise<QueryResult> {
|
|
61
|
-
return this.writeMutex.runExclusive(async () => MOCK_QUERY_RESPONSE);
|
|
34
|
+
return fn(new StubLockContext());
|
|
62
35
|
}
|
|
63
36
|
|
|
64
|
-
async
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async getOptional<T>(sql: string, parameters?: any[] | undefined): Promise<T | null> {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async get<T>(sql: string, parameters?: any[] | undefined): Promise<T> {
|
|
73
|
-
throw new Error(`No values are returned in SSR mode`);
|
|
74
|
-
}
|
|
37
|
+
async refreshSchema(): Promise<void> {}
|
|
38
|
+
}
|
|
75
39
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
* are added here
|
|
80
|
-
*/
|
|
81
|
-
private generateMockTransactionContext(): Transaction {
|
|
82
|
-
return {
|
|
83
|
-
...this,
|
|
84
|
-
commit: async () => {
|
|
85
|
-
return MOCK_QUERY_RESPONSE;
|
|
86
|
-
},
|
|
87
|
-
rollback: async () => {
|
|
88
|
-
return MOCK_QUERY_RESPONSE;
|
|
89
|
-
}
|
|
90
|
-
};
|
|
40
|
+
class StubLockContext extends LockContext {
|
|
41
|
+
async executeRaw(): Promise<RawQueryResult> {
|
|
42
|
+
return MOCK_QUERY_RESPONSE;
|
|
91
43
|
}
|
|
92
|
-
|
|
93
|
-
async refreshSchema(): Promise<void> {}
|
|
94
44
|
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { LogLevels, SQLOpenOptions } from '@powersync/common';
|
|
2
|
+
import { WASQLiteVFS } from './wa-sqlite/vfs.js';
|
|
3
|
+
|
|
4
|
+
export interface WebSpecificOpenOptions {
|
|
5
|
+
/**
|
|
6
|
+
* SQLite operations are currently not supported in SSR mode.
|
|
7
|
+
* A warning will be logged if attempting to use SQLite in SSR.
|
|
8
|
+
* Setting this to `true` will disabled the warning above.
|
|
9
|
+
*/
|
|
10
|
+
disableSSRWarning: boolean;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Enables multi tab support.
|
|
14
|
+
*
|
|
15
|
+
* Enabling multi-tab support will transparently make PowerSync manage the sync process in a shared worker collecting
|
|
16
|
+
* Sync Streams across tabs. Additionally, it enables a shared worker for IndexedDB databases.
|
|
17
|
+
*
|
|
18
|
+
* It is still valid to open multiple tabs when this option is disabled, but the experience may be degrated as only
|
|
19
|
+
* one tab can sync at the time.
|
|
20
|
+
*
|
|
21
|
+
* This is enabled by default on Desktop browsers if shared workers are enabled, except for Safari.
|
|
22
|
+
*/
|
|
23
|
+
enableMultiTabs: boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The SQLite connection is often executed through a web worker in order to offload computation and because some file
|
|
27
|
+
* system implementations (notably those based on web filesystem APIs like OPFS) are only available in workers.
|
|
28
|
+
*
|
|
29
|
+
* Manually disabling the use of web workers is not recommended, but can be useful for testing or for environments
|
|
30
|
+
* or toolchains where web workers are not supported.
|
|
31
|
+
*/
|
|
32
|
+
useWebWorker: boolean;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Open in SSR placeholder mode. DB operations and Sync operations will be a No-op
|
|
36
|
+
*/
|
|
37
|
+
ssrMode: boolean;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The log level for database workers.
|
|
41
|
+
*
|
|
42
|
+
* Defaults to {@link LogLevels.info}.
|
|
43
|
+
*/
|
|
44
|
+
databaseWorkerLogLevel: number;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Where to store SQLite temporary files. Defaults to 'MEMORY'.
|
|
48
|
+
* Setting this to `FILESYSTEM` can cause issues with larger queries or datasets.
|
|
49
|
+
*/
|
|
50
|
+
temporaryStorage: TemporaryStorageOption;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Maximum SQLite cache size. Defaults to 50MB.
|
|
54
|
+
*
|
|
55
|
+
* For details, see: https://www.sqlite.org/pragma.html#pragma_cache_size
|
|
56
|
+
*/
|
|
57
|
+
cacheSizeKb: number;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Encryption key for the database.
|
|
61
|
+
* If set, the database will be encrypted using ChaCha20.
|
|
62
|
+
*/
|
|
63
|
+
encryptionKey: string | undefined;
|
|
64
|
+
|
|
65
|
+
vfs: WASQLiteVFS;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* If the {@link vfs} supports it, an additional amount of read-only connections to open. Using additional read
|
|
69
|
+
* connections can speed up queries by dispatching them to multiple workers running them concurrently.
|
|
70
|
+
*
|
|
71
|
+
* {@link WASQLiteVFS.OPFSWriteAheadVFS} is the only VFS with support for multiple connections, so this option is
|
|
72
|
+
* ignored for other VFS implementations.
|
|
73
|
+
*
|
|
74
|
+
* Defaults to 1.
|
|
75
|
+
*/
|
|
76
|
+
additionalReaders: number;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Allows you to override the default wasqlite db worker.
|
|
80
|
+
*
|
|
81
|
+
* You can either provide a path to the worker script
|
|
82
|
+
* or a factory method that returns a worker.
|
|
83
|
+
*/
|
|
84
|
+
worker?: string | URL | ((options: ResolvedWebSQLOpenOptions) => Worker | SharedWorker);
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Use an existing port to an initialized worker.
|
|
88
|
+
* A worker will be initialized if none is provided
|
|
89
|
+
*/
|
|
90
|
+
workerPort?: MessagePort | undefined;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface ResolvedWebSQLOpenOptions extends SQLOpenOptions, WebSpecificOpenOptions {}
|
|
94
|
+
|
|
95
|
+
export interface WebSQLOpenOptions extends SQLOpenOptions, Partial<WebSpecificOpenOptions> {}
|
|
96
|
+
|
|
97
|
+
export enum TemporaryStorageOption {
|
|
98
|
+
MEMORY = 'memory',
|
|
99
|
+
FILESYSTEM = 'file'
|
|
100
|
+
}
|