@powersync/web 1.24.0 → 1.25.0
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 +87 -40
- package/dist/index.umd.js.map +1 -1
- package/dist/worker/SharedSyncImplementation.umd.js +119 -77
- package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
- package/dist/worker/WASQLiteDB.umd.js +82 -71
- package/dist/worker/WASQLiteDB.umd.js.map +1 -1
- package/lib/package.json +2 -2
- package/lib/src/db/adapters/AsyncDatabaseConnection.d.ts +7 -0
- package/lib/src/db/adapters/LockedAsyncDatabaseAdapter.d.ts +6 -1
- package/lib/src/db/adapters/LockedAsyncDatabaseAdapter.js +36 -4
- package/lib/src/db/sync/SharedWebStreamingSyncImplementation.js +1 -0
- package/lib/src/index.d.ts +1 -0
- package/lib/src/index.js +1 -0
- package/lib/src/worker/sync/SharedSyncImplementation.js +1 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/index.umd.js
CHANGED
|
@@ -38521,6 +38521,19 @@ class AbstractWebSQLOpenFactory {
|
|
|
38521
38521
|
}
|
|
38522
38522
|
|
|
38523
38523
|
|
|
38524
|
+
/***/ }),
|
|
38525
|
+
|
|
38526
|
+
/***/ "./lib/src/db/adapters/AsyncDatabaseConnection.js":
|
|
38527
|
+
/*!********************************************************!*\
|
|
38528
|
+
!*** ./lib/src/db/adapters/AsyncDatabaseConnection.js ***!
|
|
38529
|
+
\********************************************************/
|
|
38530
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
38531
|
+
|
|
38532
|
+
"use strict";
|
|
38533
|
+
__webpack_require__.r(__webpack_exports__);
|
|
38534
|
+
|
|
38535
|
+
|
|
38536
|
+
|
|
38524
38537
|
/***/ }),
|
|
38525
38538
|
|
|
38526
38539
|
/***/ "./lib/src/db/adapters/LockedAsyncDatabaseAdapter.js":
|
|
@@ -38556,11 +38569,17 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
38556
38569
|
_db = null;
|
|
38557
38570
|
_disposeTableChangeListener = null;
|
|
38558
38571
|
_config = null;
|
|
38572
|
+
pendingAbortControllers;
|
|
38573
|
+
closing;
|
|
38574
|
+
closed;
|
|
38559
38575
|
constructor(options) {
|
|
38560
38576
|
super();
|
|
38561
38577
|
this.options = options;
|
|
38562
38578
|
this._dbIdentifier = options.name;
|
|
38563
38579
|
this.logger = options.logger ?? (0,_powersync_common__WEBPACK_IMPORTED_MODULE_0__.createLogger)(`LockedAsyncDatabaseAdapter - ${this._dbIdentifier}`);
|
|
38580
|
+
this.pendingAbortControllers = new Set();
|
|
38581
|
+
this.closed = false;
|
|
38582
|
+
this.closing = false;
|
|
38564
38583
|
// Set the name if provided. We can query for the name if not available yet
|
|
38565
38584
|
this.debugMode = options.debugMode ?? false;
|
|
38566
38585
|
if (this.debugMode) {
|
|
@@ -38650,8 +38669,11 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
38650
38669
|
* tabs are still using it.
|
|
38651
38670
|
*/
|
|
38652
38671
|
async close() {
|
|
38672
|
+
this.closing = true;
|
|
38653
38673
|
this._disposeTableChangeListener?.();
|
|
38674
|
+
this.pendingAbortControllers.forEach((controller) => controller.abort('Closed'));
|
|
38654
38675
|
await this.baseDB?.close?.();
|
|
38676
|
+
this.closed = true;
|
|
38655
38677
|
}
|
|
38656
38678
|
async getAll(sql, parameters) {
|
|
38657
38679
|
await this.waitForInitialized();
|
|
@@ -38667,14 +38689,37 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
38667
38689
|
}
|
|
38668
38690
|
async readLock(fn, options) {
|
|
38669
38691
|
await this.waitForInitialized();
|
|
38670
|
-
return this.acquireLock(async () => fn(this.generateDBHelpers({ execute: this._execute, executeRaw: this._executeRaw }))
|
|
38692
|
+
return this.acquireLock(async () => fn(this.generateDBHelpers({ execute: this._execute, executeRaw: this._executeRaw })), {
|
|
38693
|
+
timeoutMs: options?.timeoutMs
|
|
38694
|
+
});
|
|
38671
38695
|
}
|
|
38672
38696
|
async writeLock(fn, options) {
|
|
38673
38697
|
await this.waitForInitialized();
|
|
38674
|
-
return this.acquireLock(async () => fn(this.generateDBHelpers({ execute: this._execute, executeRaw: this._executeRaw }))
|
|
38698
|
+
return this.acquireLock(async () => fn(this.generateDBHelpers({ execute: this._execute, executeRaw: this._executeRaw })), {
|
|
38699
|
+
timeoutMs: options?.timeoutMs
|
|
38700
|
+
});
|
|
38675
38701
|
}
|
|
38676
|
-
acquireLock(callback) {
|
|
38677
|
-
|
|
38702
|
+
async acquireLock(callback, options) {
|
|
38703
|
+
await this.waitForInitialized();
|
|
38704
|
+
if (this.closing) {
|
|
38705
|
+
throw new Error(`Cannot acquire lock, the database is closing`);
|
|
38706
|
+
}
|
|
38707
|
+
const abortController = new AbortController();
|
|
38708
|
+
this.pendingAbortControllers.add(abortController);
|
|
38709
|
+
const { timeoutMs } = options ?? {};
|
|
38710
|
+
const timoutId = timeoutMs
|
|
38711
|
+
? setTimeout(() => {
|
|
38712
|
+
abortController.abort(`Timeout after ${timeoutMs}ms`);
|
|
38713
|
+
this.pendingAbortControllers.delete(abortController);
|
|
38714
|
+
}, timeoutMs)
|
|
38715
|
+
: null;
|
|
38716
|
+
return (0,_shared_navigator__WEBPACK_IMPORTED_MODULE_1__.getNavigatorLocks)().request(`db-lock-${this._dbIdentifier}`, { signal: abortController.signal }, () => {
|
|
38717
|
+
this.pendingAbortControllers.delete(abortController);
|
|
38718
|
+
if (timoutId) {
|
|
38719
|
+
clearTimeout(timoutId);
|
|
38720
|
+
}
|
|
38721
|
+
return callback();
|
|
38722
|
+
});
|
|
38678
38723
|
}
|
|
38679
38724
|
async readTransaction(fn, options) {
|
|
38680
38725
|
return this.readLock(this.wrapTransaction(fn));
|
|
@@ -39916,6 +39961,7 @@ class SharedWebStreamingSyncImplementation extends _WebStreamingSyncImplementati
|
|
|
39916
39961
|
}
|
|
39917
39962
|
async dispose() {
|
|
39918
39963
|
await this.waitForReady();
|
|
39964
|
+
await super.dispose();
|
|
39919
39965
|
await new Promise((resolve) => {
|
|
39920
39966
|
// Listen for the close acknowledgment from the worker
|
|
39921
39967
|
this.messagePort.addEventListener('message', (event) => {
|
|
@@ -40765,8 +40811,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
40765
40811
|
*/
|
|
40766
40812
|
async _testUpdateAllStatuses(status) {
|
|
40767
40813
|
if (!this.connectionManager.syncStreamImplementation) {
|
|
40768
|
-
|
|
40769
|
-
this.connectionManager.syncStreamImplementation = this.generateStreamingImplementation();
|
|
40814
|
+
throw new Error('Cannot update status without a sync stream implementation');
|
|
40770
40815
|
}
|
|
40771
40816
|
// Only assigning, don't call listeners for this test
|
|
40772
40817
|
this.connectionManager.syncStreamImplementation.syncStatus = new _powersync_common__WEBPACK_IMPORTED_MODULE_0__.SyncStatus(status);
|
|
@@ -41286,46 +41331,48 @@ var __webpack_exports__ = {};
|
|
|
41286
41331
|
\**************************/
|
|
41287
41332
|
__webpack_require__.r(__webpack_exports__);
|
|
41288
41333
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
41289
|
-
/* harmony export */ AbstractWebPowerSyncDatabaseOpenFactory: () => (/* reexport safe */
|
|
41290
|
-
/* harmony export */ AbstractWebSQLOpenFactory: () => (/* reexport safe */
|
|
41291
|
-
/* harmony export */ AsyncWASQLiteModuleFactory: () => (/* reexport safe */
|
|
41292
|
-
/* harmony export */ DEFAULT_CACHE_SIZE_KB: () => (/* reexport safe */
|
|
41293
|
-
/* harmony export */ DEFAULT_MODULE_FACTORIES: () => (/* reexport safe */
|
|
41294
|
-
/* harmony export */ DEFAULT_POWERSYNC_FLAGS: () => (/* reexport safe */
|
|
41295
|
-
/* harmony export */ DEFAULT_WEB_SQL_FLAGS: () => (/* reexport safe */
|
|
41296
|
-
/* harmony export */ MultiCipherAsyncWASQLiteModuleFactory: () => (/* reexport safe */
|
|
41297
|
-
/* harmony export */ MultiCipherSyncWASQLiteModuleFactory: () => (/* reexport safe */
|
|
41298
|
-
/* harmony export */ PowerSyncDatabase: () => (/* reexport safe */
|
|
41299
|
-
/* harmony export */ SharedWebStreamingSyncImplementation: () => (/* reexport safe */
|
|
41300
|
-
/* harmony export */ SyncWASQLiteModuleFactory: () => (/* reexport safe */
|
|
41301
|
-
/* harmony export */ TemporaryStorageOption: () => (/* reexport safe */
|
|
41302
|
-
/* harmony export */ WASQLiteDBAdapter: () => (/* reexport safe */
|
|
41303
|
-
/* harmony export */ WASQLiteOpenFactory: () => (/* reexport safe */
|
|
41304
|
-
/* harmony export */ WASQLitePowerSyncDatabaseOpenFactory: () => (/* reexport safe */
|
|
41305
|
-
/* harmony export */ WASQLiteVFS: () => (/* reexport safe */
|
|
41306
|
-
/* harmony export */ WASqliteConnection: () => (/* reexport safe */
|
|
41307
|
-
/* harmony export */ WebRemote: () => (/* reexport safe */
|
|
41308
|
-
/* harmony export */ WebStreamingSyncImplementation: () => (/* reexport safe */
|
|
41309
|
-
/* harmony export */ isServerSide: () => (/* reexport safe */
|
|
41310
|
-
/* harmony export */ resolveWebPowerSyncFlags: () => (/* reexport safe */
|
|
41311
|
-
/* harmony export */ resolveWebSQLFlags: () => (/* reexport safe */
|
|
41334
|
+
/* harmony export */ AbstractWebPowerSyncDatabaseOpenFactory: () => (/* reexport safe */ _db_adapters_AbstractWebPowerSyncDatabaseOpenFactory__WEBPACK_IMPORTED_MODULE_2__.AbstractWebPowerSyncDatabaseOpenFactory),
|
|
41335
|
+
/* harmony export */ AbstractWebSQLOpenFactory: () => (/* reexport safe */ _db_adapters_AbstractWebSQLOpenFactory__WEBPACK_IMPORTED_MODULE_3__.AbstractWebSQLOpenFactory),
|
|
41336
|
+
/* harmony export */ AsyncWASQLiteModuleFactory: () => (/* reexport safe */ _db_adapters_wa_sqlite_WASQLiteConnection__WEBPACK_IMPORTED_MODULE_4__.AsyncWASQLiteModuleFactory),
|
|
41337
|
+
/* harmony export */ DEFAULT_CACHE_SIZE_KB: () => (/* reexport safe */ _db_adapters_web_sql_flags__WEBPACK_IMPORTED_MODULE_8__.DEFAULT_CACHE_SIZE_KB),
|
|
41338
|
+
/* harmony export */ DEFAULT_MODULE_FACTORIES: () => (/* reexport safe */ _db_adapters_wa_sqlite_WASQLiteConnection__WEBPACK_IMPORTED_MODULE_4__.DEFAULT_MODULE_FACTORIES),
|
|
41339
|
+
/* harmony export */ DEFAULT_POWERSYNC_FLAGS: () => (/* reexport safe */ _db_PowerSyncDatabase__WEBPACK_IMPORTED_MODULE_9__.DEFAULT_POWERSYNC_FLAGS),
|
|
41340
|
+
/* harmony export */ DEFAULT_WEB_SQL_FLAGS: () => (/* reexport safe */ _db_adapters_web_sql_flags__WEBPACK_IMPORTED_MODULE_8__.DEFAULT_WEB_SQL_FLAGS),
|
|
41341
|
+
/* harmony export */ MultiCipherAsyncWASQLiteModuleFactory: () => (/* reexport safe */ _db_adapters_wa_sqlite_WASQLiteConnection__WEBPACK_IMPORTED_MODULE_4__.MultiCipherAsyncWASQLiteModuleFactory),
|
|
41342
|
+
/* harmony export */ MultiCipherSyncWASQLiteModuleFactory: () => (/* reexport safe */ _db_adapters_wa_sqlite_WASQLiteConnection__WEBPACK_IMPORTED_MODULE_4__.MultiCipherSyncWASQLiteModuleFactory),
|
|
41343
|
+
/* harmony export */ PowerSyncDatabase: () => (/* reexport safe */ _db_PowerSyncDatabase__WEBPACK_IMPORTED_MODULE_9__.PowerSyncDatabase),
|
|
41344
|
+
/* harmony export */ SharedWebStreamingSyncImplementation: () => (/* reexport safe */ _db_sync_SharedWebStreamingSyncImplementation__WEBPACK_IMPORTED_MODULE_10__.SharedWebStreamingSyncImplementation),
|
|
41345
|
+
/* harmony export */ SyncWASQLiteModuleFactory: () => (/* reexport safe */ _db_adapters_wa_sqlite_WASQLiteConnection__WEBPACK_IMPORTED_MODULE_4__.SyncWASQLiteModuleFactory),
|
|
41346
|
+
/* harmony export */ TemporaryStorageOption: () => (/* reexport safe */ _db_adapters_web_sql_flags__WEBPACK_IMPORTED_MODULE_8__.TemporaryStorageOption),
|
|
41347
|
+
/* harmony export */ WASQLiteDBAdapter: () => (/* reexport safe */ _db_adapters_wa_sqlite_WASQLiteDBAdapter__WEBPACK_IMPORTED_MODULE_5__.WASQLiteDBAdapter),
|
|
41348
|
+
/* harmony export */ WASQLiteOpenFactory: () => (/* reexport safe */ _db_adapters_wa_sqlite_WASQLiteOpenFactory__WEBPACK_IMPORTED_MODULE_6__.WASQLiteOpenFactory),
|
|
41349
|
+
/* harmony export */ WASQLitePowerSyncDatabaseOpenFactory: () => (/* reexport safe */ _db_adapters_wa_sqlite_WASQLitePowerSyncDatabaseOpenFactory__WEBPACK_IMPORTED_MODULE_7__.WASQLitePowerSyncDatabaseOpenFactory),
|
|
41350
|
+
/* harmony export */ WASQLiteVFS: () => (/* reexport safe */ _db_adapters_wa_sqlite_WASQLiteConnection__WEBPACK_IMPORTED_MODULE_4__.WASQLiteVFS),
|
|
41351
|
+
/* harmony export */ WASqliteConnection: () => (/* reexport safe */ _db_adapters_wa_sqlite_WASQLiteConnection__WEBPACK_IMPORTED_MODULE_4__.WASqliteConnection),
|
|
41352
|
+
/* harmony export */ WebRemote: () => (/* reexport safe */ _db_sync_WebRemote__WEBPACK_IMPORTED_MODULE_11__.WebRemote),
|
|
41353
|
+
/* harmony export */ WebStreamingSyncImplementation: () => (/* reexport safe */ _db_sync_WebStreamingSyncImplementation__WEBPACK_IMPORTED_MODULE_12__.WebStreamingSyncImplementation),
|
|
41354
|
+
/* harmony export */ isServerSide: () => (/* reexport safe */ _db_adapters_web_sql_flags__WEBPACK_IMPORTED_MODULE_8__.isServerSide),
|
|
41355
|
+
/* harmony export */ resolveWebPowerSyncFlags: () => (/* reexport safe */ _db_PowerSyncDatabase__WEBPACK_IMPORTED_MODULE_9__.resolveWebPowerSyncFlags),
|
|
41356
|
+
/* harmony export */ resolveWebSQLFlags: () => (/* reexport safe */ _db_adapters_web_sql_flags__WEBPACK_IMPORTED_MODULE_8__.resolveWebSQLFlags)
|
|
41312
41357
|
/* harmony export */ });
|
|
41313
41358
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @powersync/common */ "@powersync/common");
|
|
41314
41359
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_powersync_common__WEBPACK_IMPORTED_MODULE_0__);
|
|
41315
41360
|
/* harmony reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
41316
41361
|
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in _powersync_common__WEBPACK_IMPORTED_MODULE_0__) if(__WEBPACK_IMPORT_KEY__ !== "default") __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = () => _powersync_common__WEBPACK_IMPORTED_MODULE_0__[__WEBPACK_IMPORT_KEY__]
|
|
41317
41362
|
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
41318
|
-
/* harmony import */ var
|
|
41319
|
-
/* harmony import */ var
|
|
41320
|
-
/* harmony import */ var
|
|
41321
|
-
/* harmony import */ var
|
|
41322
|
-
/* harmony import */ var
|
|
41323
|
-
/* harmony import */ var
|
|
41324
|
-
/* harmony import */ var
|
|
41325
|
-
/* harmony import */ var
|
|
41326
|
-
/* harmony import */ var
|
|
41327
|
-
/* harmony import */ var
|
|
41328
|
-
/* harmony import */ var
|
|
41363
|
+
/* harmony import */ var _db_adapters_AsyncDatabaseConnection__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./db/adapters/AsyncDatabaseConnection */ "./lib/src/db/adapters/AsyncDatabaseConnection.js");
|
|
41364
|
+
/* harmony import */ var _db_adapters_AbstractWebPowerSyncDatabaseOpenFactory__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./db/adapters/AbstractWebPowerSyncDatabaseOpenFactory */ "./lib/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.js");
|
|
41365
|
+
/* harmony import */ var _db_adapters_AbstractWebSQLOpenFactory__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./db/adapters/AbstractWebSQLOpenFactory */ "./lib/src/db/adapters/AbstractWebSQLOpenFactory.js");
|
|
41366
|
+
/* harmony import */ var _db_adapters_wa_sqlite_WASQLiteConnection__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./db/adapters/wa-sqlite/WASQLiteConnection */ "./lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js");
|
|
41367
|
+
/* harmony import */ var _db_adapters_wa_sqlite_WASQLiteDBAdapter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./db/adapters/wa-sqlite/WASQLiteDBAdapter */ "./lib/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.js");
|
|
41368
|
+
/* harmony import */ var _db_adapters_wa_sqlite_WASQLiteOpenFactory__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./db/adapters/wa-sqlite/WASQLiteOpenFactory */ "./lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.js");
|
|
41369
|
+
/* harmony import */ var _db_adapters_wa_sqlite_WASQLitePowerSyncDatabaseOpenFactory__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory */ "./lib/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.js");
|
|
41370
|
+
/* harmony import */ var _db_adapters_web_sql_flags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./db/adapters/web-sql-flags */ "./lib/src/db/adapters/web-sql-flags.js");
|
|
41371
|
+
/* harmony import */ var _db_PowerSyncDatabase__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./db/PowerSyncDatabase */ "./lib/src/db/PowerSyncDatabase.js");
|
|
41372
|
+
/* harmony import */ var _db_sync_SharedWebStreamingSyncImplementation__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./db/sync/SharedWebStreamingSyncImplementation */ "./lib/src/db/sync/SharedWebStreamingSyncImplementation.js");
|
|
41373
|
+
/* harmony import */ var _db_sync_WebRemote__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./db/sync/WebRemote */ "./lib/src/db/sync/WebRemote.js");
|
|
41374
|
+
/* harmony import */ var _db_sync_WebStreamingSyncImplementation__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./db/sync/WebStreamingSyncImplementation */ "./lib/src/db/sync/WebStreamingSyncImplementation.js");
|
|
41375
|
+
|
|
41329
41376
|
|
|
41330
41377
|
|
|
41331
41378
|
|