@powersync/web 0.0.0-dev-20250528152729 → 0.0.0-dev-20250529141956
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 +53 -44
- package/dist/index.umd.js.map +1 -1
- package/dist/worker/SharedSyncImplementation.umd.js +106 -94
- package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
- package/dist/worker/WASQLiteDB.umd.js +53 -53
- package/dist/worker/WASQLiteDB.umd.js.map +1 -1
- package/lib/src/db/PowerSyncDatabase.d.ts +0 -1
- package/lib/src/db/PowerSyncDatabase.js +0 -3
- package/lib/src/worker/sync/SharedSyncImplementation.d.ts +5 -1
- package/lib/src/worker/sync/SharedSyncImplementation.js +53 -41
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/index.umd.js
CHANGED
|
@@ -38223,9 +38223,6 @@ class PowerSyncDatabase extends _powersync_common__WEBPACK_IMPORTED_MODULE_0__.A
|
|
|
38223
38223
|
disconnect: options.disconnect ?? !this.resolvedFlags.enableMultiTabs
|
|
38224
38224
|
});
|
|
38225
38225
|
}
|
|
38226
|
-
async connectExclusive(callback) {
|
|
38227
|
-
await this.runExclusive(callback);
|
|
38228
|
-
}
|
|
38229
38226
|
generateBucketStorageAdapter() {
|
|
38230
38227
|
return new _powersync_common__WEBPACK_IMPORTED_MODULE_0__.SqliteBucketStorage(this.database, _powersync_common__WEBPACK_IMPORTED_MODULE_0__.AbstractPowerSyncDatabase.transactionMutex);
|
|
38231
38228
|
}
|
|
@@ -40266,6 +40263,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
40266
40263
|
|
|
40267
40264
|
|
|
40268
40265
|
/**
|
|
40266
|
+
* @internal
|
|
40269
40267
|
* Manual message events for shared sync clients
|
|
40270
40268
|
*/
|
|
40271
40269
|
var SharedSyncClientEvent;
|
|
@@ -40320,21 +40318,23 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
40320
40318
|
this.syncStatus = new _powersync_common__WEBPACK_IMPORTED_MODULE_0__.SyncStatus({});
|
|
40321
40319
|
this.broadCastLogger = new _BroadcastLogger__WEBPACK_IMPORTED_MODULE_7__.BroadcastLogger(this.ports);
|
|
40322
40320
|
this.connectionManager = new _powersync_common__WEBPACK_IMPORTED_MODULE_0__.ConnectionManager({
|
|
40323
|
-
createSyncImplementation: async (
|
|
40324
|
-
|
|
40325
|
-
|
|
40326
|
-
|
|
40327
|
-
|
|
40328
|
-
const sync = this.generateStreamingImplementation();
|
|
40329
|
-
const onDispose = sync.registerListener({
|
|
40330
|
-
statusChanged: (status) => {
|
|
40331
|
-
this.updateAllStatuses(status.toJSON());
|
|
40321
|
+
createSyncImplementation: async () => {
|
|
40322
|
+
return this.portMutex.runExclusive(async () => {
|
|
40323
|
+
await this.waitForReady();
|
|
40324
|
+
if (!this.dbAdapter) {
|
|
40325
|
+
await this.openInternalDB();
|
|
40332
40326
|
}
|
|
40327
|
+
const sync = this.generateStreamingImplementation();
|
|
40328
|
+
const onDispose = sync.registerListener({
|
|
40329
|
+
statusChanged: (status) => {
|
|
40330
|
+
this.updateAllStatuses(status.toJSON());
|
|
40331
|
+
}
|
|
40332
|
+
});
|
|
40333
|
+
return {
|
|
40334
|
+
sync,
|
|
40335
|
+
onDispose
|
|
40336
|
+
};
|
|
40333
40337
|
});
|
|
40334
|
-
return {
|
|
40335
|
-
sync,
|
|
40336
|
-
onDispose
|
|
40337
|
-
};
|
|
40338
40338
|
},
|
|
40339
40339
|
logger: this.logger
|
|
40340
40340
|
});
|
|
@@ -40368,12 +40368,14 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
40368
40368
|
async setParams(params) {
|
|
40369
40369
|
await this.portMutex.runExclusive(async () => {
|
|
40370
40370
|
if (this.syncParams) {
|
|
40371
|
+
// Cannot modify already existing sync implementation params
|
|
40372
|
+
// But we can ask for a DB adapter, if required, at this point.
|
|
40371
40373
|
if (!this.dbAdapter) {
|
|
40372
40374
|
await this.openInternalDB();
|
|
40373
40375
|
}
|
|
40374
|
-
// Cannot modify already existing sync implementation
|
|
40375
40376
|
return;
|
|
40376
40377
|
}
|
|
40378
|
+
// First time setting params
|
|
40377
40379
|
this.syncParams = params;
|
|
40378
40380
|
if (params.streamOptions?.flags?.broadcastLogs) {
|
|
40379
40381
|
this.logger = this.broadCastLogger;
|
|
@@ -40400,16 +40402,11 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
40400
40402
|
* connects.
|
|
40401
40403
|
*/
|
|
40402
40404
|
async connect(options) {
|
|
40403
|
-
|
|
40404
|
-
|
|
40405
|
-
this.lastConnectOptions = options;
|
|
40406
|
-
return this.connectionManager.connect(CONNECTOR_PLACEHOLDER, options);
|
|
40407
|
-
});
|
|
40405
|
+
this.lastConnectOptions = options;
|
|
40406
|
+
return this.connectionManager.connect(CONNECTOR_PLACEHOLDER, options);
|
|
40408
40407
|
}
|
|
40409
40408
|
async disconnect() {
|
|
40410
|
-
|
|
40411
|
-
await this.connectionManager.disconnect();
|
|
40412
|
-
});
|
|
40409
|
+
return this.connectionManager.disconnect();
|
|
40413
40410
|
}
|
|
40414
40411
|
/**
|
|
40415
40412
|
* Adds a new client tab's message port to the list of connected ports
|
|
@@ -40433,11 +40430,14 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
40433
40430
|
* clients.
|
|
40434
40431
|
*/
|
|
40435
40432
|
async removePort(port) {
|
|
40436
|
-
|
|
40433
|
+
// Remove the port within a mutex context.
|
|
40434
|
+
// Warns if the port is not found. This should not happen in practice.
|
|
40435
|
+
// We return early if the port is not found.
|
|
40436
|
+
const { trackedPort, shouldReconnect } = await this.portMutex.runExclusive(async () => {
|
|
40437
40437
|
const index = this.ports.findIndex((p) => p.port == port);
|
|
40438
40438
|
if (index < 0) {
|
|
40439
40439
|
this.logger.warn(`Could not remove port ${port} since it is not present in active ports.`);
|
|
40440
|
-
return;
|
|
40440
|
+
return {};
|
|
40441
40441
|
}
|
|
40442
40442
|
const trackedPort = this.ports[index];
|
|
40443
40443
|
// Remove from the list of active ports
|
|
@@ -40452,26 +40452,35 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
40452
40452
|
}
|
|
40453
40453
|
});
|
|
40454
40454
|
const shouldReconnect = !!this.connectionManager.syncStreamImplementation && this.ports.length > 0;
|
|
40455
|
-
|
|
40456
|
-
|
|
40457
|
-
|
|
40458
|
-
|
|
40459
|
-
|
|
40460
|
-
|
|
40461
|
-
|
|
40462
|
-
|
|
40463
|
-
|
|
40455
|
+
return {
|
|
40456
|
+
shouldReconnect,
|
|
40457
|
+
trackedPort
|
|
40458
|
+
};
|
|
40459
|
+
});
|
|
40460
|
+
if (!trackedPort) {
|
|
40461
|
+
// We could not find the port to remove
|
|
40462
|
+
return () => { };
|
|
40463
|
+
}
|
|
40464
|
+
if (this.dbAdapter && this.dbAdapter == trackedPort.db) {
|
|
40465
|
+
if (shouldReconnect) {
|
|
40466
|
+
await this.connectionManager.disconnect();
|
|
40464
40467
|
}
|
|
40465
|
-
|
|
40466
|
-
|
|
40468
|
+
// Clearing the adapter will result in a new one being opened in connect
|
|
40469
|
+
this.dbAdapter = null;
|
|
40470
|
+
if (shouldReconnect) {
|
|
40471
|
+
await this.connectionManager.connect(CONNECTOR_PLACEHOLDER, this.lastConnectOptions);
|
|
40467
40472
|
}
|
|
40468
|
-
|
|
40469
|
-
|
|
40470
|
-
|
|
40471
|
-
}
|
|
40473
|
+
}
|
|
40474
|
+
if (trackedPort.db) {
|
|
40475
|
+
await trackedPort.db.close();
|
|
40476
|
+
}
|
|
40477
|
+
// Release proxy
|
|
40478
|
+
return () => trackedPort.clientProvider[comlink__WEBPACK_IMPORTED_MODULE_2__.releaseProxy]();
|
|
40472
40479
|
}
|
|
40473
40480
|
triggerCrudUpload() {
|
|
40474
|
-
this.
|
|
40481
|
+
this.withSyncImplementation(async (sync) => {
|
|
40482
|
+
sync.triggerCrudUpload();
|
|
40483
|
+
});
|
|
40475
40484
|
}
|
|
40476
40485
|
async hasCompletedSync() {
|
|
40477
40486
|
return this.withSyncImplementation(async (sync) => {
|
|
@@ -40599,7 +40608,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
40599
40608
|
* A function only used for unit tests which updates the internal
|
|
40600
40609
|
* sync stream client and all tab client's sync status
|
|
40601
40610
|
*/
|
|
40602
|
-
_testUpdateAllStatuses(status) {
|
|
40611
|
+
async _testUpdateAllStatuses(status) {
|
|
40603
40612
|
if (!this.connectionManager.syncStreamImplementation) {
|
|
40604
40613
|
// This is just for testing purposes
|
|
40605
40614
|
this.connectionManager.syncStreamImplementation = this.generateStreamingImplementation();
|