@powersync/web 0.0.0-dev-20251119150914 → 0.0.0-dev-20251126195153
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/dist/index.umd.js +36 -11
- package/dist/index.umd.js.map +1 -1
- package/dist/worker/SharedSyncImplementation.umd.js +14863 -10910
- package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
- package/dist/worker/WASQLiteDB.umd.js +12733 -10923
- package/dist/worker/WASQLiteDB.umd.js.map +1 -1
- package/lib/package.json +2 -2
- package/lib/src/db/adapters/AsyncDatabaseConnection.d.ts +5 -0
- package/lib/src/db/adapters/LockedAsyncDatabaseAdapter.d.ts +1 -0
- package/lib/src/db/adapters/LockedAsyncDatabaseAdapter.js +11 -2
- package/lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.d.ts +1 -0
- package/lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js +7 -2
- package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.d.ts +5 -0
- package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js +7 -0
- package/lib/src/worker/db/SharedWASQLiteConnection.d.ts +4 -3
- package/lib/src/worker/db/SharedWASQLiteConnection.js +15 -11
- package/lib/src/worker/db/WASQLiteDB.worker.js +2 -2
- package/lib/src/worker/db/WorkerWASQLiteConnection.d.ts +3 -3
- package/lib/src/worker/db/WorkerWASQLiteConnection.js +2 -14
- package/lib/src/worker/sync/SharedSyncImplementation.d.ts +2 -2
- package/lib/src/worker/sync/SharedSyncImplementation.js +7 -4
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/db/adapters/AsyncDatabaseConnection.ts +5 -0
- package/src/db/adapters/LockedAsyncDatabaseAdapter.ts +12 -2
- package/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.ts +8 -2
- package/src/db/adapters/wa-sqlite/WASQLiteConnection.ts +8 -0
- package/src/worker/db/SharedWASQLiteConnection.ts +19 -14
- package/src/worker/db/WASQLiteDB.worker.ts +2 -2
- package/src/worker/db/WorkerWASQLiteConnection.ts +3 -18
- package/src/worker/sync/SharedSyncImplementation.ts +15 -12
- package/dist/_journeyapps_wa-sqlite-_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapp-81d3460.index.umd.js +0 -355
- package/dist/_journeyapps_wa-sqlite-_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapp-81d3460.index.umd.js.map +0 -1
- package/dist/_journeyapps_wa-sqlite-_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapp-81d3461.index.umd.js +0 -355
- package/dist/_journeyapps_wa-sqlite-_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapp-81d3461.index.umd.js.map +0 -1
package/dist/index.umd.js
CHANGED
|
@@ -38700,6 +38700,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
38700
38700
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_powersync_common__WEBPACK_IMPORTED_MODULE_0__);
|
|
38701
38701
|
/* harmony import */ var _shared_navigator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../..//shared/navigator */ "./lib/src/shared/navigator.js");
|
|
38702
38702
|
/* harmony import */ var _WorkerWrappedAsyncDatabaseConnection__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./WorkerWrappedAsyncDatabaseConnection */ "./lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js");
|
|
38703
|
+
/* harmony import */ var _wa_sqlite_WASQLiteConnection__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./wa-sqlite/WASQLiteConnection */ "./lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js");
|
|
38704
|
+
|
|
38703
38705
|
|
|
38704
38706
|
|
|
38705
38707
|
|
|
@@ -38719,6 +38721,7 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
38719
38721
|
_disposeTableChangeListener = null;
|
|
38720
38722
|
_config = null;
|
|
38721
38723
|
pendingAbortControllers;
|
|
38724
|
+
requiresHolds;
|
|
38722
38725
|
closing;
|
|
38723
38726
|
closed;
|
|
38724
38727
|
constructor(options) {
|
|
@@ -38729,6 +38732,7 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
38729
38732
|
this.pendingAbortControllers = new Set();
|
|
38730
38733
|
this.closed = false;
|
|
38731
38734
|
this.closing = false;
|
|
38735
|
+
this.requiresHolds = null;
|
|
38732
38736
|
// Set the name if provided. We can query for the name if not available yet
|
|
38733
38737
|
this.debugMode = options.debugMode ?? false;
|
|
38734
38738
|
if (this.debugMode) {
|
|
@@ -38773,6 +38777,10 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
38773
38777
|
this._config = await this._db.getConfig();
|
|
38774
38778
|
await this.registerOnChangeListener(this._db);
|
|
38775
38779
|
this.iterateListeners((cb) => cb.initialized?.());
|
|
38780
|
+
/**
|
|
38781
|
+
* This is only required for the long-lived shared IndexedDB connections.
|
|
38782
|
+
*/
|
|
38783
|
+
this.requiresHolds = this._config.vfs == _wa_sqlite_WASQLiteConnection__WEBPACK_IMPORTED_MODULE_3__.WASQLiteVFS.IDBBatchAtomicVFS;
|
|
38776
38784
|
}
|
|
38777
38785
|
getConfiguration() {
|
|
38778
38786
|
if (!this._config) {
|
|
@@ -38867,12 +38875,14 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
38867
38875
|
if (timoutId) {
|
|
38868
38876
|
clearTimeout(timoutId);
|
|
38869
38877
|
}
|
|
38870
|
-
const holdId = await this.baseDB.markHold();
|
|
38878
|
+
const holdId = this.requiresHolds ? await this.baseDB.markHold() : null;
|
|
38871
38879
|
try {
|
|
38872
38880
|
return await callback();
|
|
38873
38881
|
}
|
|
38874
38882
|
finally {
|
|
38875
|
-
|
|
38883
|
+
if (holdId) {
|
|
38884
|
+
await this.baseDB.releaseHold(holdId);
|
|
38885
|
+
}
|
|
38876
38886
|
}
|
|
38877
38887
|
});
|
|
38878
38888
|
}
|
|
@@ -39126,10 +39136,13 @@ class WorkerWrappedAsyncDatabaseConnection {
|
|
|
39126
39136
|
this.notifyRemoteClosed.abort();
|
|
39127
39137
|
}
|
|
39128
39138
|
markHold() {
|
|
39129
|
-
return this.baseConnection.markHold();
|
|
39139
|
+
return this.withRemote(() => this.baseConnection.markHold());
|
|
39130
39140
|
}
|
|
39131
39141
|
releaseHold(holdId) {
|
|
39132
|
-
return this.baseConnection.releaseHold(holdId);
|
|
39142
|
+
return this.withRemote(() => this.baseConnection.releaseHold(holdId));
|
|
39143
|
+
}
|
|
39144
|
+
isAutoCommit() {
|
|
39145
|
+
return this.withRemote(() => this.baseConnection.isAutoCommit());
|
|
39133
39146
|
}
|
|
39134
39147
|
withRemote(workerPromise) {
|
|
39135
39148
|
const controller = this.notifyRemoteClosed;
|
|
@@ -39137,6 +39150,8 @@ class WorkerWrappedAsyncDatabaseConnection {
|
|
|
39137
39150
|
return new Promise((resolve, reject) => {
|
|
39138
39151
|
if (controller.signal.aborted) {
|
|
39139
39152
|
reject(new Error('Called operation on closed remote'));
|
|
39153
|
+
// Don't run the operation if we're going to reject
|
|
39154
|
+
return;
|
|
39140
39155
|
}
|
|
39141
39156
|
function handleAbort() {
|
|
39142
39157
|
reject(new Error('Remote peer closed with request in flight'));
|
|
@@ -39396,6 +39411,13 @@ class WASqliteConnection extends _powersync_common__WEBPACK_IMPORTED_MODULE_1__.
|
|
|
39396
39411
|
}
|
|
39397
39412
|
return this._dbP;
|
|
39398
39413
|
}
|
|
39414
|
+
/**
|
|
39415
|
+
* Checks if the database connection is in autocommit mode.
|
|
39416
|
+
* @returns true if in autocommit mode, false if in a transaction
|
|
39417
|
+
*/
|
|
39418
|
+
async isAutoCommit() {
|
|
39419
|
+
return this.sqliteAPI.get_autocommit(this.dbP) != 0;
|
|
39420
|
+
}
|
|
39399
39421
|
async markHold() {
|
|
39400
39422
|
const previousHoldId = this._holdId;
|
|
39401
39423
|
this._holdId = `${++this._holdCounter}`;
|
|
@@ -40144,7 +40166,7 @@ class SharedWebStreamingSyncImplementation extends _WebStreamingSyncImplementati
|
|
|
40144
40166
|
}
|
|
40145
40167
|
}
|
|
40146
40168
|
else {
|
|
40147
|
-
this.messagePort = new SharedWorker(new URL(/* worker import */ __webpack_require__.p + __webpack_require__.u("
|
|
40169
|
+
this.messagePort = new SharedWorker(new URL(/* worker import */ __webpack_require__.p + __webpack_require__.u("lib_src_worker_sync_SharedSyncImplementation_worker_js-_journeyapps_wa-sqlite-_journeyapps_wa-4748cf"), __webpack_require__.b), {
|
|
40148
40170
|
/* @vite-ignore */
|
|
40149
40171
|
name: `shared-sync-${this.webOptions.identifier}`,
|
|
40150
40172
|
type: undefined
|
|
@@ -40495,12 +40517,12 @@ function openWorkerDatabasePort(workerIdentifier, multipleTabs = true, worker =
|
|
|
40495
40517
|
* (in the case of Android)
|
|
40496
40518
|
*/
|
|
40497
40519
|
return !needsDedicated && multipleTabs
|
|
40498
|
-
? new SharedWorker(new URL(/* worker import */ __webpack_require__.p + __webpack_require__.u("
|
|
40520
|
+
? new SharedWorker(new URL(/* worker import */ __webpack_require__.p + __webpack_require__.u("lib_src_worker_db_WASQLiteDB_worker_js-_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVF-1dc7800"), __webpack_require__.b), {
|
|
40499
40521
|
/* @vite-ignore */
|
|
40500
40522
|
name: `shared-DB-worker-${workerIdentifier}`,
|
|
40501
40523
|
type: undefined
|
|
40502
40524
|
}).port
|
|
40503
|
-
: new Worker(new URL(/* worker import */ __webpack_require__.p + __webpack_require__.u("
|
|
40525
|
+
: new Worker(new URL(/* worker import */ __webpack_require__.p + __webpack_require__.u("lib_src_worker_db_WASQLiteDB_worker_js-_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVF-1dc7801"), __webpack_require__.b), {
|
|
40504
40526
|
/* @vite-ignore */
|
|
40505
40527
|
name: `DB-worker-${workerIdentifier}`,
|
|
40506
40528
|
type: undefined
|
|
@@ -40943,11 +40965,14 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
40943
40965
|
return () => { };
|
|
40944
40966
|
}
|
|
40945
40967
|
for (const closeListener of trackedPort.closeListeners) {
|
|
40946
|
-
closeListener();
|
|
40968
|
+
await closeListener();
|
|
40947
40969
|
}
|
|
40948
40970
|
if (this.dbAdapter && this.dbAdapter == trackedPort.db) {
|
|
40949
40971
|
// Unconditionally close the connection because the database it's writing to has just been closed.
|
|
40950
|
-
|
|
40972
|
+
// The connection has been closed previously, this might throw. We should be able to ignore it.
|
|
40973
|
+
await this.connectionManager
|
|
40974
|
+
.disconnect()
|
|
40975
|
+
.catch((ex) => this.logger.warn('Error while disconnecting. Will attempt to reconnect.', ex));
|
|
40951
40976
|
// Clearing the adapter will result in a new one being opened in connect
|
|
40952
40977
|
this.dbAdapter = null;
|
|
40953
40978
|
if (shouldReconnect) {
|
|
@@ -41076,9 +41101,9 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
41076
41101
|
// that and ensure pending requests are aborted when the tab is closed.
|
|
41077
41102
|
remoteCanCloseUnexpectedly: true
|
|
41078
41103
|
});
|
|
41079
|
-
lastClient.closeListeners.push(() => {
|
|
41104
|
+
lastClient.closeListeners.push(async () => {
|
|
41080
41105
|
this.logger.info('Aborting open connection because associated tab closed.');
|
|
41081
|
-
wrapped.close();
|
|
41106
|
+
wrapped.close().catch((ex) => this.logger.warn('error closing database connection', ex));
|
|
41082
41107
|
wrapped.markRemoteClosed();
|
|
41083
41108
|
});
|
|
41084
41109
|
return wrapped;
|