@powersync/web 0.0.0-dev-20251203144301 → 0.0.0-dev-20260112083235
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 +1 -1
- package/dist/0b19af1befc07ce338dd.wasm +0 -0
- package/dist/2632c3bda9473da74fd5.wasm +0 -0
- package/dist/64f5351ba3784bfe2f3e.wasm +0 -0
- package/dist/9318ca94aac4d0fe0135.wasm +0 -0
- package/dist/_journeyapps_wa-sqlite-_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapp-89f0ba.index.umd.js +1875 -0
- package/dist/_journeyapps_wa-sqlite-_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapp-89f0ba.index.umd.js.map +1 -0
- package/dist/_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapps_wa-sqlite_src_example-685f6c0.index.umd.js +567 -0
- package/dist/_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapps_wa-sqlite_src_example-685f6c0.index.umd.js.map +1 -0
- package/dist/_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapps_wa-sqlite_src_example-685f6c1.index.umd.js +567 -0
- package/dist/_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapps_wa-sqlite_src_example-685f6c1.index.umd.js.map +1 -0
- package/dist/index.umd.js +7107 -4249
- package/dist/index.umd.js.map +1 -1
- package/dist/worker/SharedSyncImplementation.umd.js +337 -2101
- package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
- package/dist/worker/WASQLiteDB.umd.js +182 -1931
- package/dist/worker/WASQLiteDB.umd.js.map +1 -1
- package/dist/worker/node_modules_bson_lib_bson_mjs.umd.js +3 -3
- package/dist/worker/node_modules_bson_lib_bson_mjs.umd.js.map +1 -1
- package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_mc-wa-sqlite-async_mjs.umd.js +22 -9
- package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_mc-wa-sqlite-async_mjs.umd.js.map +1 -1
- package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_mc-wa-sqlite_mjs.umd.js +22 -9
- package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_mc-wa-sqlite_mjs.umd.js.map +1 -1
- package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite-async_mjs.umd.js +22 -9
- package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite-async_mjs.umd.js.map +1 -1
- package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js +22 -9
- package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js.map +1 -1
- package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js.umd.js +1206 -3
- package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js.umd.js.map +1 -1
- package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_IDBBatchAtomicVFS_js.umd.js +1209 -6
- package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_IDBBatchAtomicVFS_js.umd.js.map +1 -1
- package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_OPFSCoopSyncVFS_js.umd.js +1820 -0
- package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_OPFSCoopSyncVFS_js.umd.js.map +1 -0
- package/lib/package.json +20 -15
- package/lib/src/db/PowerSyncDatabase.d.ts +3 -1
- package/lib/src/db/PowerSyncDatabase.js +19 -7
- package/lib/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.d.ts +1 -1
- package/lib/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.js +1 -1
- package/lib/src/db/adapters/AbstractWebSQLOpenFactory.d.ts +2 -2
- package/lib/src/db/adapters/AbstractWebSQLOpenFactory.js +2 -2
- package/lib/src/db/adapters/AsyncDatabaseConnection.d.ts +1 -9
- package/lib/src/db/adapters/AsyncDatabaseConnection.js +1 -11
- package/lib/src/db/adapters/LockedAsyncDatabaseAdapter.d.ts +3 -3
- package/lib/src/db/adapters/LockedAsyncDatabaseAdapter.js +25 -12
- package/lib/src/db/adapters/WebDBAdapter.d.ts +1 -1
- package/lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.d.ts +2 -2
- package/lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js +1 -2
- package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.d.ts +2 -2
- package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js +12 -3
- package/lib/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.d.ts +3 -3
- package/lib/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.js +5 -5
- package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.d.ts +4 -4
- package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.js +6 -6
- package/lib/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.d.ts +1 -1
- package/lib/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.js +3 -3
- package/lib/src/db/sync/SharedWebStreamingSyncImplementation.d.ts +4 -4
- package/lib/src/db/sync/SharedWebStreamingSyncImplementation.js +5 -5
- package/lib/src/db/sync/WebRemote.js +1 -1
- package/lib/src/db/sync/WebStreamingSyncImplementation.d.ts +1 -1
- package/lib/src/db/sync/WebStreamingSyncImplementation.js +1 -1
- package/lib/src/index.d.ts +12 -12
- package/lib/src/index.js +12 -12
- package/lib/src/worker/db/SharedWASQLiteConnection.d.ts +2 -2
- package/lib/src/worker/db/WASQLiteDB.worker.js +4 -3
- package/lib/src/worker/db/WorkerWASQLiteConnection.d.ts +2 -2
- package/lib/src/worker/db/WorkerWASQLiteConnection.js +1 -1
- package/lib/src/worker/db/open-worker-database.d.ts +2 -2
- package/lib/src/worker/db/open-worker-database.js +1 -1
- package/lib/src/worker/sync/BroadcastLogger.d.ts +1 -1
- package/lib/src/worker/sync/SharedSyncImplementation.d.ts +4 -4
- package/lib/src/worker/sync/SharedSyncImplementation.js +84 -83
- package/lib/src/worker/sync/SharedSyncImplementation.worker.js +2 -2
- package/lib/src/worker/sync/WorkerClient.d.ts +1 -1
- package/lib/src/worker/sync/WorkerClient.js +2 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -16
- package/src/db/PowerSyncDatabase.ts +23 -8
- package/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.ts +1 -1
- package/src/db/adapters/AbstractWebSQLOpenFactory.ts +3 -3
- package/src/db/adapters/AsyncDatabaseConnection.ts +1 -13
- package/src/db/adapters/LockedAsyncDatabaseAdapter.ts +30 -14
- package/src/db/adapters/WebDBAdapter.ts +1 -1
- package/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.ts +3 -4
- package/src/db/adapters/wa-sqlite/WASQLiteConnection.ts +14 -5
- package/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.ts +7 -7
- package/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.ts +7 -7
- package/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.ts +3 -3
- package/src/db/sync/SharedWebStreamingSyncImplementation.ts +7 -7
- package/src/db/sync/WebRemote.ts +1 -1
- package/src/db/sync/WebStreamingSyncImplementation.ts +2 -2
- package/src/index.ts +12 -12
- package/src/worker/db/SharedWASQLiteConnection.ts +2 -2
- package/src/worker/db/WASQLiteDB.worker.ts +6 -5
- package/src/worker/db/WorkerWASQLiteConnection.ts +2 -2
- package/src/worker/db/open-worker-database.ts +2 -2
- package/src/worker/sync/BroadcastLogger.ts +1 -1
- package/src/worker/sync/SharedSyncImplementation.ts +92 -89
- package/src/worker/sync/SharedSyncImplementation.worker.ts +2 -2
- package/src/worker/sync/WorkerClient.ts +2 -2
- package/dist/1807036ae51c10ee4d23.wasm +0 -0
- package/dist/307d8ce2280e3bae09d5.wasm +0 -0
- package/dist/cd8b9e8f4c87bf81c169.wasm +0 -0
- package/dist/e797080f5ed0b5324166.wasm +0 -0
- package/lib/src/worker/db/opfs.d.ts +0 -96
- package/lib/src/worker/db/opfs.js +0 -582
- package/src/worker/db/opfs.ts +0 -623
- /package/bin/{powersync.js → powersync.cjs} +0 -0
|
@@ -15,22 +15,23 @@ import {
|
|
|
15
15
|
type RequiredAdditionalConnectionOptions
|
|
16
16
|
} from '@powersync/common';
|
|
17
17
|
import { Mutex } from 'async-mutex';
|
|
18
|
-
import { getNavigatorLocks } from '../shared/navigator';
|
|
19
|
-
import { WebDBAdapter } from './adapters/WebDBAdapter';
|
|
20
|
-
import { WASQLiteOpenFactory } from './adapters/wa-sqlite/WASQLiteOpenFactory';
|
|
18
|
+
import { getNavigatorLocks } from '../shared/navigator.js';
|
|
19
|
+
import { WebDBAdapter } from './adapters/WebDBAdapter.js';
|
|
20
|
+
import { WASQLiteOpenFactory } from './adapters/wa-sqlite/WASQLiteOpenFactory.js';
|
|
21
21
|
import {
|
|
22
22
|
DEFAULT_WEB_SQL_FLAGS,
|
|
23
23
|
ResolvedWebSQLOpenOptions,
|
|
24
24
|
WebSQLFlags,
|
|
25
|
+
isServerSide,
|
|
25
26
|
resolveWebSQLFlags
|
|
26
|
-
} from './adapters/web-sql-flags';
|
|
27
|
-
import { SSRStreamingSyncImplementation } from './sync/SSRWebStreamingSyncImplementation';
|
|
28
|
-
import { SharedWebStreamingSyncImplementation } from './sync/SharedWebStreamingSyncImplementation';
|
|
29
|
-
import { WebRemote } from './sync/WebRemote';
|
|
27
|
+
} from './adapters/web-sql-flags.js';
|
|
28
|
+
import { SSRStreamingSyncImplementation } from './sync/SSRWebStreamingSyncImplementation.js';
|
|
29
|
+
import { SharedWebStreamingSyncImplementation } from './sync/SharedWebStreamingSyncImplementation.js';
|
|
30
|
+
import { WebRemote } from './sync/WebRemote.js';
|
|
30
31
|
import {
|
|
31
32
|
WebStreamingSyncImplementation,
|
|
32
33
|
WebStreamingSyncImplementationOptions
|
|
33
|
-
} from './sync/WebStreamingSyncImplementation';
|
|
34
|
+
} from './sync/WebStreamingSyncImplementation.js';
|
|
34
35
|
|
|
35
36
|
export interface WebPowerSyncFlags extends WebSQLFlags {
|
|
36
37
|
/**
|
|
@@ -169,6 +170,20 @@ export class PowerSyncDatabase extends AbstractPowerSyncDatabase {
|
|
|
169
170
|
});
|
|
170
171
|
}
|
|
171
172
|
|
|
173
|
+
protected async loadVersion(): Promise<void> {
|
|
174
|
+
if (isServerSide()) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
return super.loadVersion();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
protected async resolveOfflineSyncStatus() {
|
|
181
|
+
if (isServerSide()) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
return super.resolveOfflineSyncStatus();
|
|
185
|
+
}
|
|
186
|
+
|
|
172
187
|
protected generateBucketStorageAdapter(): BucketStorageAdapter {
|
|
173
188
|
return new SqliteBucketStorage(this.database);
|
|
174
189
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type ILogger,
|
|
2
|
-
import { SSRDBAdapter } from './SSRDBAdapter';
|
|
3
|
-
import { ResolvedWebSQLFlags, WebSQLOpenFactoryOptions, isServerSide, resolveWebSQLFlags } from './web-sql-flags';
|
|
1
|
+
import { DBAdapter, type ILogger, SQLOpenFactory, createLogger } from '@powersync/common';
|
|
2
|
+
import { SSRDBAdapter } from './SSRDBAdapter.js';
|
|
3
|
+
import { ResolvedWebSQLFlags, WebSQLOpenFactoryOptions, isServerSide, resolveWebSQLFlags } from './web-sql-flags.js';
|
|
4
4
|
|
|
5
5
|
export abstract class AbstractWebSQLOpenFactory implements SQLOpenFactory {
|
|
6
6
|
protected resolvedFlags: ResolvedWebSQLFlags;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BatchedUpdateNotification, QueryResult } from '@powersync/common';
|
|
2
|
-
import { ResolvedWebSQLOpenOptions } from './web-sql-flags';
|
|
2
|
+
import { ResolvedWebSQLOpenOptions } from './web-sql-flags.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
@@ -17,18 +17,6 @@ export type ProxiedQueryResult = Omit<QueryResult, 'rows'> & {
|
|
|
17
17
|
*/
|
|
18
18
|
export type OnTableChangeCallback = (event: BatchedUpdateNotification) => void;
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* Thrown when an underlying database connection is closed.
|
|
22
|
-
* This is particularly relevant when worker connections are marked as closed while
|
|
23
|
-
* operations are still in progress.
|
|
24
|
-
*/
|
|
25
|
-
export class ConnectionClosedError extends Error {
|
|
26
|
-
constructor(message: string) {
|
|
27
|
-
super(message);
|
|
28
|
-
this.name = 'ConnectionClosedError';
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
20
|
/**
|
|
33
21
|
* @internal
|
|
34
22
|
* An async Database connection which provides basic async SQL methods.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseObserver,
|
|
3
|
+
ConnectionClosedError,
|
|
3
4
|
DBAdapter,
|
|
4
5
|
DBAdapterListener,
|
|
5
6
|
DBGetUtils,
|
|
@@ -10,13 +11,13 @@ import {
|
|
|
10
11
|
createLogger,
|
|
11
12
|
type ILogger
|
|
12
13
|
} from '@powersync/common';
|
|
13
|
-
import { getNavigatorLocks } from '../../shared/navigator';
|
|
14
|
-
import { AsyncDatabaseConnection
|
|
15
|
-
import { SharedConnectionWorker, WebDBAdapter } from './WebDBAdapter';
|
|
16
|
-
import { WorkerWrappedAsyncDatabaseConnection } from './WorkerWrappedAsyncDatabaseConnection';
|
|
17
|
-
import { WASQLiteVFS } from './wa-sqlite/WASQLiteConnection';
|
|
18
|
-
import { ResolvedWASQLiteOpenFactoryOptions } from './wa-sqlite/WASQLiteOpenFactory';
|
|
19
|
-
import { ResolvedWebSQLOpenOptions } from './web-sql-flags';
|
|
14
|
+
import { getNavigatorLocks } from '../../shared/navigator.js';
|
|
15
|
+
import { AsyncDatabaseConnection } from './AsyncDatabaseConnection.js';
|
|
16
|
+
import { SharedConnectionWorker, WebDBAdapter } from './WebDBAdapter.js';
|
|
17
|
+
import { WorkerWrappedAsyncDatabaseConnection } from './WorkerWrappedAsyncDatabaseConnection.js';
|
|
18
|
+
import { WASQLiteVFS } from './wa-sqlite/WASQLiteConnection.js';
|
|
19
|
+
import { ResolvedWASQLiteOpenFactoryOptions } from './wa-sqlite/WASQLiteOpenFactory.js';
|
|
20
|
+
import { ResolvedWebSQLOpenOptions } from './web-sql-flags.js';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* @internal
|
|
@@ -233,7 +234,14 @@ export class LockedAsyncDatabaseAdapter
|
|
|
233
234
|
*/
|
|
234
235
|
async close() {
|
|
235
236
|
this.closing = true;
|
|
236
|
-
|
|
237
|
+
/**
|
|
238
|
+
* Note that we obtain a reference to the callback to avoid calling the callback with `this` as the context.
|
|
239
|
+
* This is to avoid Comlink attempting to clone `this` when calling the method.
|
|
240
|
+
*/
|
|
241
|
+
const dispose = this._disposeTableChangeListener;
|
|
242
|
+
if (dispose) {
|
|
243
|
+
dispose();
|
|
244
|
+
}
|
|
237
245
|
this.pendingAbortControllers.forEach((controller) => controller.abort('Closed'));
|
|
238
246
|
await this.baseDB?.close?.();
|
|
239
247
|
this.closed = true;
|
|
@@ -305,23 +313,31 @@ export class LockedAsyncDatabaseAdapter
|
|
|
305
313
|
protected async acquireLock(callback: () => Promise<any>, options?: { timeoutMs?: number }): Promise<any> {
|
|
306
314
|
await this.waitForInitialized();
|
|
307
315
|
|
|
316
|
+
// The database is being opened in the background. Wait for it here.
|
|
317
|
+
if (this.databaseOpenPromise) {
|
|
318
|
+
await this.databaseOpenPromise;
|
|
319
|
+
}
|
|
320
|
+
|
|
308
321
|
return this._acquireLock(async () => {
|
|
309
322
|
let holdId: string | null = null;
|
|
310
323
|
try {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
324
|
+
/**
|
|
325
|
+
* We can't await this since it uses the same lock as we're in now.
|
|
326
|
+
* If there is a pending open, this call will throw.
|
|
327
|
+
* If there is no pending open, but there is also no database - the open
|
|
328
|
+
* might have failed. We need to re-open the database.
|
|
329
|
+
*/
|
|
330
|
+
if (this.databaseOpenPromise || !this._db) {
|
|
316
331
|
throw new ConnectionClosedError('Connection is busy re-opening');
|
|
317
332
|
}
|
|
318
333
|
|
|
319
334
|
holdId = this.requiresHolds ? await this.baseDB.markHold() : null;
|
|
320
335
|
return await callback();
|
|
321
336
|
} catch (ex) {
|
|
322
|
-
if (
|
|
337
|
+
if (ConnectionClosedError.MATCHES(ex)) {
|
|
323
338
|
if (this.options.reOpenOnConnectionClosed && !this.databaseOpenPromise && !this.closing) {
|
|
324
339
|
// Immediately re-open the database. We need to miss as little table updates as possible.
|
|
340
|
+
// Note, don't await this since it uses the same lock as we're in now.
|
|
325
341
|
this.reOpenInternalDB();
|
|
326
342
|
}
|
|
327
343
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { BaseObserver } from '@powersync/common';
|
|
1
|
+
import { BaseObserver, ConnectionClosedError } from '@powersync/common';
|
|
2
2
|
import * as Comlink from 'comlink';
|
|
3
3
|
import {
|
|
4
4
|
AsyncDatabaseConnection,
|
|
5
|
-
ConnectionClosedError,
|
|
6
5
|
OnTableChangeCallback,
|
|
7
6
|
OpenAsyncDatabaseConnection,
|
|
8
7
|
ProxiedQueryResult
|
|
9
|
-
} from './AsyncDatabaseConnection';
|
|
10
|
-
import { ResolvedWebSQLOpenOptions } from './web-sql-flags';
|
|
8
|
+
} from './AsyncDatabaseConnection.js';
|
|
9
|
+
import { ResolvedWebSQLOpenOptions } from './web-sql-flags.js';
|
|
11
10
|
|
|
12
11
|
export type SharedConnectionWorker = {
|
|
13
12
|
identifier: string;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as SQLite from '@journeyapps/wa-sqlite';
|
|
2
2
|
import { BaseObserver, BatchedUpdateNotification } from '@powersync/common';
|
|
3
3
|
import { Mutex } from 'async-mutex';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { ResolvedWASQLiteOpenFactoryOptions } from './WASQLiteOpenFactory';
|
|
4
|
+
import { AsyncDatabaseConnection, OnTableChangeCallback, ProxiedQueryResult } from '../AsyncDatabaseConnection.js';
|
|
5
|
+
import { ResolvedWASQLiteOpenFactoryOptions } from './WASQLiteOpenFactory.js';
|
|
7
6
|
/**
|
|
8
7
|
* List of currently tested virtual filesystems
|
|
9
8
|
*/
|
|
@@ -124,10 +123,12 @@ export const DEFAULT_MODULE_FACTORIES = {
|
|
|
124
123
|
} else {
|
|
125
124
|
module = await SyncWASQLiteModuleFactory();
|
|
126
125
|
}
|
|
126
|
+
// @ts-expect-error The types for this static method are missing upstream
|
|
127
|
+
const { OPFSCoopSyncVFS } = await import('@journeyapps/wa-sqlite/src/examples/OPFSCoopSyncVFS.js');
|
|
127
128
|
const vfs = await OPFSCoopSyncVFS.create(options.dbFileName, module);
|
|
128
129
|
return {
|
|
129
130
|
module,
|
|
130
|
-
vfs
|
|
131
|
+
vfs
|
|
131
132
|
};
|
|
132
133
|
}
|
|
133
134
|
};
|
|
@@ -386,7 +387,15 @@ export class WASqliteConnection
|
|
|
386
387
|
|
|
387
388
|
async close() {
|
|
388
389
|
this.broadcastChannel?.close();
|
|
389
|
-
await this.
|
|
390
|
+
await this.acquireExecuteLock(async () => {
|
|
391
|
+
/**
|
|
392
|
+
* Running the close operation inside the same execute mutex prevents errors like:
|
|
393
|
+
* ```
|
|
394
|
+
* unable to close due to unfinalized statements or unfinished backups
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
await this.sqliteAPI.close(this.dbP);
|
|
398
|
+
});
|
|
390
399
|
}
|
|
391
400
|
|
|
392
401
|
async registerOnTableChange(callback: OnTableChangeCallback) {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { type PowerSyncOpenFactoryOptions } from '@powersync/common';
|
|
2
2
|
import * as Comlink from 'comlink';
|
|
3
|
-
import { resolveWebPowerSyncFlags } from '../../PowerSyncDatabase';
|
|
4
|
-
import { OpenAsyncDatabaseConnection } from '../AsyncDatabaseConnection';
|
|
5
|
-
import { LockedAsyncDatabaseAdapter } from '../LockedAsyncDatabaseAdapter';
|
|
3
|
+
import { resolveWebPowerSyncFlags } from '../../PowerSyncDatabase.js';
|
|
4
|
+
import { OpenAsyncDatabaseConnection } from '../AsyncDatabaseConnection.js';
|
|
5
|
+
import { LockedAsyncDatabaseAdapter } from '../LockedAsyncDatabaseAdapter.js';
|
|
6
6
|
import {
|
|
7
7
|
DEFAULT_CACHE_SIZE_KB,
|
|
8
8
|
ResolvedWebSQLOpenOptions,
|
|
9
9
|
TemporaryStorageOption,
|
|
10
10
|
WebSQLFlags
|
|
11
|
-
} from '../web-sql-flags';
|
|
12
|
-
import { WorkerWrappedAsyncDatabaseConnection } from '../WorkerWrappedAsyncDatabaseConnection';
|
|
13
|
-
import { WASQLiteVFS } from './WASQLiteConnection';
|
|
14
|
-
import { WASQLiteOpenFactory } from './WASQLiteOpenFactory';
|
|
11
|
+
} from '../web-sql-flags.js';
|
|
12
|
+
import { WorkerWrappedAsyncDatabaseConnection } from '../WorkerWrappedAsyncDatabaseConnection.js';
|
|
13
|
+
import { WASQLiteVFS } from './WASQLiteConnection.js';
|
|
14
|
+
import { WASQLiteOpenFactory } from './WASQLiteOpenFactory.js';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* These flags are the same as {@link WebSQLFlags}.
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { DBAdapter, type ILogLevel } from '@powersync/common';
|
|
2
2
|
import * as Comlink from 'comlink';
|
|
3
|
-
import { openWorkerDatabasePort, resolveWorkerDatabasePortFactory } from '../../../worker/db/open-worker-database';
|
|
4
|
-
import { AbstractWebSQLOpenFactory } from '../AbstractWebSQLOpenFactory';
|
|
5
|
-
import { AsyncDatabaseConnection, OpenAsyncDatabaseConnection } from '../AsyncDatabaseConnection';
|
|
6
|
-
import { LockedAsyncDatabaseAdapter } from '../LockedAsyncDatabaseAdapter';
|
|
7
|
-
import { WorkerWrappedAsyncDatabaseConnection } from '../WorkerWrappedAsyncDatabaseConnection';
|
|
3
|
+
import { openWorkerDatabasePort, resolveWorkerDatabasePortFactory } from '../../../worker/db/open-worker-database.js';
|
|
4
|
+
import { AbstractWebSQLOpenFactory } from '../AbstractWebSQLOpenFactory.js';
|
|
5
|
+
import { AsyncDatabaseConnection, OpenAsyncDatabaseConnection } from '../AsyncDatabaseConnection.js';
|
|
6
|
+
import { LockedAsyncDatabaseAdapter } from '../LockedAsyncDatabaseAdapter.js';
|
|
7
|
+
import { WorkerWrappedAsyncDatabaseConnection } from '../WorkerWrappedAsyncDatabaseConnection.js';
|
|
8
8
|
import {
|
|
9
9
|
DEFAULT_CACHE_SIZE_KB,
|
|
10
10
|
ResolvedWebSQLOpenOptions,
|
|
11
11
|
TemporaryStorageOption,
|
|
12
12
|
WebSQLOpenFactoryOptions
|
|
13
|
-
} from '../web-sql-flags';
|
|
14
|
-
import { WASQLiteVFS, WASqliteConnection } from './WASQLiteConnection';
|
|
13
|
+
} from '../web-sql-flags.js';
|
|
14
|
+
import { WASQLiteVFS, WASqliteConnection } from './WASQLiteConnection.js';
|
|
15
15
|
|
|
16
16
|
export interface WASQLiteOpenFactoryOptions extends WebSQLOpenFactoryOptions {
|
|
17
17
|
vfs?: WASQLiteVFS;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbstractPowerSyncDatabase, DBAdapter, PowerSyncDatabaseOptions } from '@powersync/common';
|
|
2
|
-
import { PowerSyncDatabase } from '../../../db/PowerSyncDatabase';
|
|
3
|
-
import { AbstractWebPowerSyncDatabaseOpenFactory } from '../AbstractWebPowerSyncDatabaseOpenFactory';
|
|
4
|
-
import { WASQLiteOpenFactory } from './WASQLiteOpenFactory';
|
|
2
|
+
import { PowerSyncDatabase } from '../../../db/PowerSyncDatabase.js';
|
|
3
|
+
import { AbstractWebPowerSyncDatabaseOpenFactory } from '../AbstractWebPowerSyncDatabaseOpenFactory.js';
|
|
4
|
+
import { WASQLiteOpenFactory } from './WASQLiteOpenFactory.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @deprecated {@link PowerSyncDatabase} can now be constructed directly
|
|
@@ -5,16 +5,16 @@ import {
|
|
|
5
5
|
SyncStatusOptions
|
|
6
6
|
} from '@powersync/common';
|
|
7
7
|
import * as Comlink from 'comlink';
|
|
8
|
-
import { getNavigatorLocks } from '../../shared/navigator';
|
|
9
|
-
import { AbstractSharedSyncClientProvider } from '../../worker/sync/AbstractSharedSyncClientProvider';
|
|
10
|
-
import { ManualSharedSyncPayload, SharedSyncClientEvent } from '../../worker/sync/SharedSyncImplementation';
|
|
11
|
-
import { WorkerClient } from '../../worker/sync/WorkerClient';
|
|
12
|
-
import { WebDBAdapter } from '../adapters/WebDBAdapter';
|
|
13
|
-
import { DEFAULT_CACHE_SIZE_KB, TemporaryStorageOption, resolveWebSQLFlags } from '../adapters/web-sql-flags';
|
|
8
|
+
import { getNavigatorLocks } from '../../shared/navigator.js';
|
|
9
|
+
import { AbstractSharedSyncClientProvider } from '../../worker/sync/AbstractSharedSyncClientProvider.js';
|
|
10
|
+
import { ManualSharedSyncPayload, SharedSyncClientEvent } from '../../worker/sync/SharedSyncImplementation.js';
|
|
11
|
+
import { WorkerClient } from '../../worker/sync/WorkerClient.js';
|
|
12
|
+
import { WebDBAdapter } from '../adapters/WebDBAdapter.js';
|
|
13
|
+
import { DEFAULT_CACHE_SIZE_KB, TemporaryStorageOption, resolveWebSQLFlags } from '../adapters/web-sql-flags.js';
|
|
14
14
|
import {
|
|
15
15
|
WebStreamingSyncImplementation,
|
|
16
16
|
WebStreamingSyncImplementationOptions
|
|
17
|
-
} from './WebStreamingSyncImplementation';
|
|
17
|
+
} from './WebStreamingSyncImplementation.js';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* The shared worker will trigger methods on this side of the message port
|
package/src/db/sync/WebRemote.ts
CHANGED
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
LockOptions,
|
|
5
5
|
LockType
|
|
6
6
|
} from '@powersync/common';
|
|
7
|
-
import { getNavigatorLocks } from '../../shared/navigator';
|
|
8
|
-
import { ResolvedWebSQLOpenOptions, WebSQLFlags } from '../adapters/web-sql-flags';
|
|
7
|
+
import { getNavigatorLocks } from '../../shared/navigator.js';
|
|
8
|
+
import { ResolvedWebSQLOpenOptions, WebSQLFlags } from '../adapters/web-sql-flags.js';
|
|
9
9
|
|
|
10
10
|
export interface WebStreamingSyncImplementationOptions extends AbstractStreamingSyncImplementationOptions {
|
|
11
11
|
flags?: WebSQLFlags;
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export * from '@powersync/common';
|
|
2
|
-
export * from './db/adapters/
|
|
3
|
-
export * from './db/adapters/
|
|
4
|
-
export * from './db/adapters/
|
|
5
|
-
export * from './db/adapters/wa-sqlite/WASQLiteConnection';
|
|
6
|
-
export * from './db/adapters/wa-sqlite/WASQLiteDBAdapter';
|
|
7
|
-
export * from './db/adapters/wa-sqlite/WASQLiteOpenFactory';
|
|
8
|
-
export * from './db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory';
|
|
9
|
-
export * from './db/adapters/web-sql-flags';
|
|
10
|
-
export * from './db/PowerSyncDatabase';
|
|
11
|
-
export * from './db/sync/SharedWebStreamingSyncImplementation';
|
|
12
|
-
export * from './db/sync/WebRemote';
|
|
13
|
-
export * from './db/sync/WebStreamingSyncImplementation';
|
|
2
|
+
export * from './db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.js';
|
|
3
|
+
export * from './db/adapters/AbstractWebSQLOpenFactory.js';
|
|
4
|
+
export * from './db/adapters/AsyncDatabaseConnection.js';
|
|
5
|
+
export * from './db/adapters/wa-sqlite/WASQLiteConnection.js';
|
|
6
|
+
export * from './db/adapters/wa-sqlite/WASQLiteDBAdapter.js';
|
|
7
|
+
export * from './db/adapters/wa-sqlite/WASQLiteOpenFactory.js';
|
|
8
|
+
export * from './db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.js';
|
|
9
|
+
export * from './db/adapters/web-sql-flags.js';
|
|
10
|
+
export * from './db/PowerSyncDatabase.js';
|
|
11
|
+
export * from './db/sync/SharedWebStreamingSyncImplementation.js';
|
|
12
|
+
export * from './db/sync/WebRemote.js';
|
|
13
|
+
export * from './db/sync/WebStreamingSyncImplementation.js';
|
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
AsyncDatabaseConnection,
|
|
4
4
|
OnTableChangeCallback,
|
|
5
5
|
ProxiedQueryResult
|
|
6
|
-
} from '../../db/adapters/AsyncDatabaseConnection';
|
|
7
|
-
import { ResolvedWebSQLOpenOptions } from '../../db/adapters/web-sql-flags';
|
|
6
|
+
} from '../../db/adapters/AsyncDatabaseConnection.js';
|
|
7
|
+
import { ResolvedWebSQLOpenOptions } from '../../db/adapters/web-sql-flags.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Keeps track of open DB connections and the clients which
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
import '@journeyapps/wa-sqlite';
|
|
6
6
|
import { createBaseLogger, createLogger } from '@powersync/common';
|
|
7
7
|
import * as Comlink from 'comlink';
|
|
8
|
-
import { AsyncDatabaseConnection } from '../../db/adapters/AsyncDatabaseConnection';
|
|
9
|
-
import { WorkerDBOpenerOptions } from '../../db/adapters/wa-sqlite/WASQLiteOpenFactory';
|
|
10
|
-
import { getNavigatorLocks } from '../../shared/navigator';
|
|
11
|
-
import { SharedDBWorkerConnection, SharedWASQLiteConnection } from './SharedWASQLiteConnection';
|
|
12
|
-
import { WorkerWASQLiteConnection } from './WorkerWASQLiteConnection';
|
|
8
|
+
import { AsyncDatabaseConnection } from '../../db/adapters/AsyncDatabaseConnection.js';
|
|
9
|
+
import { WorkerDBOpenerOptions } from '../../db/adapters/wa-sqlite/WASQLiteOpenFactory.js';
|
|
10
|
+
import { getNavigatorLocks } from '../../shared/navigator.js';
|
|
11
|
+
import { SharedDBWorkerConnection, SharedWASQLiteConnection } from './SharedWASQLiteConnection.js';
|
|
12
|
+
import { WorkerWASQLiteConnection } from './WorkerWASQLiteConnection.js';
|
|
13
13
|
|
|
14
14
|
const baseLogger = createBaseLogger();
|
|
15
15
|
baseLogger.useDefaults();
|
|
@@ -20,6 +20,7 @@ const OPEN_DB_LOCK = 'open-wasqlite-db';
|
|
|
20
20
|
let nextClientId = 1;
|
|
21
21
|
|
|
22
22
|
const openDBShared = async (options: WorkerDBOpenerOptions): Promise<AsyncDatabaseConnection> => {
|
|
23
|
+
// Prevent multiple simultaneous opens from causing race conditions
|
|
23
24
|
return getNavigatorLocks().request(OPEN_DB_LOCK, async () => {
|
|
24
25
|
const clientId = nextClientId++;
|
|
25
26
|
const { dbFilename, logLevel } = options;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Comlink from 'comlink';
|
|
2
|
-
import { OnTableChangeCallback } from '../../db/adapters/AsyncDatabaseConnection';
|
|
3
|
-
import { WASqliteConnection } from '../../db/adapters/wa-sqlite/WASQLiteConnection';
|
|
2
|
+
import { OnTableChangeCallback } from '../../db/adapters/AsyncDatabaseConnection.js';
|
|
3
|
+
import { WASqliteConnection } from '../../db/adapters/wa-sqlite/WASQLiteConnection.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* A Small proxy wrapper around the WASqliteConnection.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Comlink from 'comlink';
|
|
2
|
-
import { OpenAsyncDatabaseConnection } from '
|
|
3
|
-
import { WASQLiteVFS } from '../../db/adapters/wa-sqlite/WASQLiteConnection';
|
|
2
|
+
import { OpenAsyncDatabaseConnection } from '../../db/adapters/AsyncDatabaseConnection.js';
|
|
3
|
+
import { WASQLiteVFS } from '../../db/adapters/wa-sqlite/WASQLiteConnection.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Opens a shared or dedicated worker which exposes opening of database connections
|