@powersync/web 1.10.0 → 1.10.1

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 CHANGED
@@ -33481,6 +33481,8 @@ __webpack_require__.r(__webpack_exports__);
33481
33481
  /* harmony import */ var _sync_SSRWebStreamingSyncImplementation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sync/SSRWebStreamingSyncImplementation */ "./lib/src/db/sync/SSRWebStreamingSyncImplementation.js");
33482
33482
  /* harmony import */ var _sync_WebRemote__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./sync/WebRemote */ "./lib/src/db/sync/WebRemote.js");
33483
33483
  /* harmony import */ var _sync_WebStreamingSyncImplementation__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sync/WebStreamingSyncImplementation */ "./lib/src/db/sync/WebStreamingSyncImplementation.js");
33484
+ /* harmony import */ var _shared_navigator__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../shared/navigator */ "./lib/src/shared/navigator.js");
33485
+
33484
33486
 
33485
33487
 
33486
33488
 
@@ -33568,7 +33570,7 @@ class PowerSyncDatabase extends _powersync_common__WEBPACK_IMPORTED_MODULE_0__.A
33568
33570
  if (this.resolvedFlags.ssrMode) {
33569
33571
  return PowerSyncDatabase.SHARED_MUTEX.runExclusive(cb);
33570
33572
  }
33571
- return navigator.locks.request(`lock-${this.database.name}`, cb);
33573
+ return (0,_shared_navigator__WEBPACK_IMPORTED_MODULE_8__.getNavigatorLocks)().request(`lock-${this.database.name}`, cb);
33572
33574
  }
33573
33575
  generateSyncStreamImplementation(connector) {
33574
33576
  const remote = new _sync_WebRemote__WEBPACK_IMPORTED_MODULE_6__.WebRemote(connector);
@@ -33801,6 +33803,8 @@ __webpack_require__.r(__webpack_exports__);
33801
33803
  /* harmony import */ var _shared_open_db__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../shared/open-db */ "./lib/src/shared/open-db.js");
33802
33804
  /* harmony import */ var _worker_db_open_worker_database__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../worker/db/open-worker-database */ "./lib/src/worker/db/open-worker-database.js");
33803
33805
  /* harmony import */ var _web_sql_flags__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../web-sql-flags */ "./lib/src/db/adapters/web-sql-flags.js");
33806
+ /* harmony import */ var _shared_navigator__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../shared/navigator */ "./lib/src/shared/navigator.js");
33807
+
33804
33808
 
33805
33809
 
33806
33810
 
@@ -33937,7 +33941,7 @@ class WASQLiteDBAdapter extends _powersync_common__WEBPACK_IMPORTED_MODULE_0__.B
33937
33941
  return this.acquireLock(async () => fn(this.generateDBHelpers({ execute: this._execute })));
33938
33942
  }
33939
33943
  acquireLock(callback) {
33940
- return navigator.locks.request(`db-lock-${this.options.dbFilename}`, callback);
33944
+ return (0,_shared_navigator__WEBPACK_IMPORTED_MODULE_6__.getNavigatorLocks)().request(`db-lock-${this.options.dbFilename}`, callback);
33941
33945
  }
33942
33946
  async readTransaction(fn, options) {
33943
33947
  return this.readLock(this.wrapTransaction(fn));
@@ -34495,6 +34499,8 @@ __webpack_require__.r(__webpack_exports__);
34495
34499
  /* harmony export */ });
34496
34500
  /* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @powersync/common */ "@powersync/common");
34497
34501
  /* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_powersync_common__WEBPACK_IMPORTED_MODULE_0__);
34502
+ /* harmony import */ var _shared_navigator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../shared/navigator */ "./lib/src/shared/navigator.js");
34503
+
34498
34504
 
34499
34505
  class WebStreamingSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODULE_0__.AbstractStreamingSyncImplementation {
34500
34506
  constructor(options) {
@@ -34507,7 +34513,7 @@ class WebStreamingSyncImplementation extends _powersync_common__WEBPACK_IMPORTED
34507
34513
  obtainLock(lockOptions) {
34508
34514
  const identifier = `streaming-sync-${lockOptions.type}-${this.webOptions.identifier}`;
34509
34515
  lockOptions.type == _powersync_common__WEBPACK_IMPORTED_MODULE_0__.LockType.SYNC && console.debug('requesting lock for ', identifier);
34510
- return navigator.locks.request(identifier, { signal: lockOptions.signal }, lockOptions.callback);
34516
+ return (0,_shared_navigator__WEBPACK_IMPORTED_MODULE_1__.getNavigatorLocks)().request(identifier, { signal: lockOptions.signal }, lockOptions.callback);
34511
34517
  }
34512
34518
  }
34513
34519
 
@@ -34591,6 +34597,27 @@ function getOsInfo(nav) {
34591
34597
  }
34592
34598
 
34593
34599
 
34600
+ /***/ }),
34601
+
34602
+ /***/ "./lib/src/shared/navigator.js":
34603
+ /*!*************************************!*\
34604
+ !*** ./lib/src/shared/navigator.js ***!
34605
+ \*************************************/
34606
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
34607
+
34608
+ "use strict";
34609
+ __webpack_require__.r(__webpack_exports__);
34610
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
34611
+ /* harmony export */ getNavigatorLocks: () => (/* binding */ getNavigatorLocks)
34612
+ /* harmony export */ });
34613
+ const getNavigatorLocks = () => {
34614
+ if ('locks' in navigator && navigator.locks) {
34615
+ return navigator.locks;
34616
+ }
34617
+ throw new Error('Navigator locks are not available in an insecure context. Use a secure context such as HTTPS or http://localhost.');
34618
+ };
34619
+
34620
+
34594
34621
  /***/ }),
34595
34622
 
34596
34623
  /***/ "./lib/src/shared/open-db.js":
@@ -35041,6 +35068,8 @@ __webpack_require__.r(__webpack_exports__);
35041
35068
  /* harmony import */ var _db_sync_WebStreamingSyncImplementation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../db/sync/WebStreamingSyncImplementation */ "./lib/src/db/sync/WebStreamingSyncImplementation.js");
35042
35069
  /* harmony import */ var _db_adapters_wa_sqlite_WASQLiteDBAdapter__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../db/adapters/wa-sqlite/WASQLiteDBAdapter */ "./lib/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.js");
35043
35070
  /* harmony import */ var _BroadcastLogger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./BroadcastLogger */ "./lib/src/worker/sync/BroadcastLogger.js");
35071
+ /* harmony import */ var _shared_navigator__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../shared/navigator */ "./lib/src/shared/navigator.js");
35072
+
35044
35073
 
35045
35074
 
35046
35075
 
@@ -35144,7 +35173,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
35144
35173
  async connect(options) {
35145
35174
  await this.waitForReady();
35146
35175
  // This effectively queues connect and disconnect calls. Ensuring multiple tabs' requests are synchronized
35147
- return navigator.locks.request('shared-sync-connect', async () => {
35176
+ return (0,_shared_navigator__WEBPACK_IMPORTED_MODULE_8__.getNavigatorLocks)().request('shared-sync-connect', async () => {
35148
35177
  this.syncStreamClient = this.generateStreamingImplementation();
35149
35178
  this.syncStreamClient.registerListener({
35150
35179
  statusChanged: (status) => {
@@ -35157,7 +35186,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
35157
35186
  async disconnect() {
35158
35187
  await this.waitForReady();
35159
35188
  // This effectively queues connect and disconnect calls. Ensuring multiple tabs' requests are synchronized
35160
- return navigator.locks.request('shared-sync-connect', async () => {
35189
+ return (0,_shared_navigator__WEBPACK_IMPORTED_MODULE_8__.getNavigatorLocks)().request('shared-sync-connect', async () => {
35161
35190
  await this.syncStreamClient?.disconnect();
35162
35191
  await this.syncStreamClient?.dispose();
35163
35192
  this.syncStreamClient = null;