@powersync/web 1.18.0 → 1.19.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 +79 -64
- package/dist/index.umd.js.map +1 -1
- package/dist/worker/SharedSyncImplementation.umd.js +148 -424
- package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
- package/dist/worker/WASQLiteDB.umd.js +101 -378
- package/dist/worker/WASQLiteDB.umd.js.map +1 -1
- package/lib/package.json +3 -4
- package/lib/src/db/adapters/AbstractWebSQLOpenFactory.d.ts +1 -2
- package/lib/src/db/adapters/AbstractWebSQLOpenFactory.js +4 -4
- package/lib/src/db/adapters/LockedAsyncDatabaseAdapter.d.ts +1 -2
- package/lib/src/db/adapters/LockedAsyncDatabaseAdapter.js +2 -3
- package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.d.ts +4 -1
- package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.js +2 -1
- package/lib/src/db/adapters/web-sql-flags.d.ts +1 -2
- package/lib/src/db/sync/SharedWebStreamingSyncImplementation.js +1 -0
- package/lib/src/db/sync/WebRemote.d.ts +1 -2
- package/lib/src/db/sync/WebStreamingSyncImplementation.js +3 -1
- package/lib/src/worker/db/WASQLiteDB.worker.js +9 -5
- package/lib/src/worker/sync/BroadcastLogger.d.ts +11 -1
- package/lib/src/worker/sync/BroadcastLogger.js +37 -13
- package/lib/src/worker/sync/SharedSyncImplementation.d.ts +2 -2
- package/lib/src/worker/sync/SharedSyncImplementation.js +8 -5
- package/lib/src/worker/sync/SharedSyncImplementation.worker.js +3 -3
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
package/dist/index.umd.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
2
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
-
module.exports = factory(require("@powersync/common"), require("async-mutex"), require("comlink"), require("@journeyapps/wa-sqlite"), require("
|
|
3
|
+
module.exports = factory(require("@powersync/common"), require("async-mutex"), require("comlink"), require("@journeyapps/wa-sqlite"), require("@journeyapps/wa-sqlite/src/examples/OPFSCoopSyncVFS.js"), require("@journeyapps/wa-sqlite/src/examples/AccessHandlePoolVFS.js"), require("@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js"));
|
|
4
4
|
else if(typeof define === 'function' && define.amd)
|
|
5
|
-
define(["@powersync/common", "async-mutex", "comlink", "@journeyapps/wa-sqlite", "
|
|
5
|
+
define(["@powersync/common", "async-mutex", "comlink", "@journeyapps/wa-sqlite", "@journeyapps/wa-sqlite/src/examples/OPFSCoopSyncVFS.js", "@journeyapps/wa-sqlite/src/examples/AccessHandlePoolVFS.js", "@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js"], factory);
|
|
6
6
|
else if(typeof exports === 'object')
|
|
7
|
-
exports["sdk_web"] = factory(require("@powersync/common"), require("async-mutex"), require("comlink"), require("@journeyapps/wa-sqlite"), require("
|
|
7
|
+
exports["sdk_web"] = factory(require("@powersync/common"), require("async-mutex"), require("comlink"), require("@journeyapps/wa-sqlite"), require("@journeyapps/wa-sqlite/src/examples/OPFSCoopSyncVFS.js"), require("@journeyapps/wa-sqlite/src/examples/AccessHandlePoolVFS.js"), require("@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js"));
|
|
8
8
|
else
|
|
9
|
-
root["sdk_web"] = factory(root["@powersync/common"], root["async-mutex"], root["comlink"], root["@journeyapps/wa-sqlite"], root["
|
|
10
|
-
})(self, (__WEBPACK_EXTERNAL_MODULE__powersync_common__, __WEBPACK_EXTERNAL_MODULE_async_mutex__, __WEBPACK_EXTERNAL_MODULE_comlink__, __WEBPACK_EXTERNAL_MODULE__journeyapps_wa_sqlite__,
|
|
9
|
+
root["sdk_web"] = factory(root["@powersync/common"], root["async-mutex"], root["comlink"], root["@journeyapps/wa-sqlite"], root["@journeyapps/wa-sqlite/src/examples/OPFSCoopSyncVFS.js"], root["@journeyapps/wa-sqlite/src/examples/AccessHandlePoolVFS.js"], root["@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js"]);
|
|
10
|
+
})(self, (__WEBPACK_EXTERNAL_MODULE__powersync_common__, __WEBPACK_EXTERNAL_MODULE_async_mutex__, __WEBPACK_EXTERNAL_MODULE_comlink__, __WEBPACK_EXTERNAL_MODULE__journeyapps_wa_sqlite__, __WEBPACK_EXTERNAL_MODULE__journeyapps_wa_sqlite_src_examples_OPFSCoopSyncVFS_js__, __WEBPACK_EXTERNAL_MODULE__journeyapps_wa_sqlite_src_examples_AccessHandlePoolVFS_js__, __WEBPACK_EXTERNAL_MODULE__journeyapps_wa_sqlite_src_examples_IDBBatchAtomicVFS_js__) => {
|
|
11
11
|
return /******/ (() => { // webpackBootstrap
|
|
12
12
|
/******/ var __webpack_modules__ = ({
|
|
13
13
|
|
|
@@ -33680,8 +33680,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
33680
33680
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
33681
33681
|
/* harmony export */ AbstractWebSQLOpenFactory: () => (/* binding */ AbstractWebSQLOpenFactory)
|
|
33682
33682
|
/* harmony export */ });
|
|
33683
|
-
/* harmony import */ var
|
|
33684
|
-
/* harmony import */ var
|
|
33683
|
+
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @powersync/common */ "@powersync/common");
|
|
33684
|
+
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_powersync_common__WEBPACK_IMPORTED_MODULE_0__);
|
|
33685
33685
|
/* harmony import */ var _SSRDBAdapter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SSRDBAdapter */ "./lib/src/db/adapters/SSRDBAdapter.js");
|
|
33686
33686
|
/* harmony import */ var _web_sql_flags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./web-sql-flags */ "./lib/src/db/adapters/web-sql-flags.js");
|
|
33687
33687
|
|
|
@@ -33694,7 +33694,7 @@ class AbstractWebSQLOpenFactory {
|
|
|
33694
33694
|
constructor(options) {
|
|
33695
33695
|
this.options = options;
|
|
33696
33696
|
this.resolvedFlags = (0,_web_sql_flags__WEBPACK_IMPORTED_MODULE_2__.resolveWebSQLFlags)(options.flags);
|
|
33697
|
-
this.logger = options.logger ??
|
|
33697
|
+
this.logger = options.logger ?? (0,_powersync_common__WEBPACK_IMPORTED_MODULE_0__.createLogger)(`AbstractWebSQLOpenFactory - ${this.options.dbFilename}`);
|
|
33698
33698
|
}
|
|
33699
33699
|
/**
|
|
33700
33700
|
* Opens a {@link DBAdapter} using resolved flags.
|
|
@@ -33703,13 +33703,13 @@ class AbstractWebSQLOpenFactory {
|
|
|
33703
33703
|
openDB() {
|
|
33704
33704
|
const { resolvedFlags: { disableSSRWarning, enableMultiTabs, ssrMode = (0,_web_sql_flags__WEBPACK_IMPORTED_MODULE_2__.isServerSide)() } } = this;
|
|
33705
33705
|
if (ssrMode && !disableSSRWarning) {
|
|
33706
|
-
|
|
33706
|
+
this.logger.warn(`
|
|
33707
33707
|
Running PowerSync in SSR mode.
|
|
33708
33708
|
Only empty query results will be returned.
|
|
33709
33709
|
Disable this warning by setting 'disableSSRWarning: true' in options.`);
|
|
33710
33710
|
}
|
|
33711
33711
|
if (!enableMultiTabs) {
|
|
33712
|
-
|
|
33712
|
+
this.logger.warn('Multiple tab support is not enabled. Using this site across multiple tabs may not function correctly.');
|
|
33713
33713
|
}
|
|
33714
33714
|
if (ssrMode) {
|
|
33715
33715
|
return new _SSRDBAdapter__WEBPACK_IMPORTED_MODULE_1__.SSRDBAdapter();
|
|
@@ -33734,11 +33734,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
33734
33734
|
/* harmony export */ });
|
|
33735
33735
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @powersync/common */ "@powersync/common");
|
|
33736
33736
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_powersync_common__WEBPACK_IMPORTED_MODULE_0__);
|
|
33737
|
-
/* harmony import */ var
|
|
33738
|
-
/* harmony import */ var
|
|
33739
|
-
/* harmony import */ var _shared_navigator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../..//shared/navigator */ "./lib/src/shared/navigator.js");
|
|
33740
|
-
/* harmony import */ var _WorkerWrappedAsyncDatabaseConnection__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./WorkerWrappedAsyncDatabaseConnection */ "./lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js");
|
|
33741
|
-
|
|
33737
|
+
/* harmony import */ var _shared_navigator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../..//shared/navigator */ "./lib/src/shared/navigator.js");
|
|
33738
|
+
/* harmony import */ var _WorkerWrappedAsyncDatabaseConnection__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./WorkerWrappedAsyncDatabaseConnection */ "./lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js");
|
|
33742
33739
|
|
|
33743
33740
|
|
|
33744
33741
|
|
|
@@ -33761,7 +33758,7 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
33761
33758
|
super();
|
|
33762
33759
|
this.options = options;
|
|
33763
33760
|
this._dbIdentifier = options.name;
|
|
33764
|
-
this.logger = options.logger ??
|
|
33761
|
+
this.logger = options.logger ?? (0,_powersync_common__WEBPACK_IMPORTED_MODULE_0__.createLogger)(`LockedAsyncDatabaseAdapter - ${this._dbIdentifier}`);
|
|
33765
33762
|
// Set the name if provided. We can query for the name if not available yet
|
|
33766
33763
|
this.debugMode = options.debugMode ?? false;
|
|
33767
33764
|
if (this.debugMode) {
|
|
@@ -33818,7 +33815,7 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
33818
33815
|
await this.initPromise;
|
|
33819
33816
|
}
|
|
33820
33817
|
async shareConnection() {
|
|
33821
|
-
if (false == this._db instanceof
|
|
33818
|
+
if (false == this._db instanceof _WorkerWrappedAsyncDatabaseConnection__WEBPACK_IMPORTED_MODULE_2__.WorkerWrappedAsyncDatabaseConnection) {
|
|
33822
33819
|
throw new Error(`Only worker connections can be shared`);
|
|
33823
33820
|
}
|
|
33824
33821
|
return this._db.shareConnection();
|
|
@@ -33875,7 +33872,7 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
33875
33872
|
return this.acquireLock(async () => fn(this.generateDBHelpers({ execute: this._execute, executeRaw: this._executeRaw })));
|
|
33876
33873
|
}
|
|
33877
33874
|
acquireLock(callback) {
|
|
33878
|
-
return (0,
|
|
33875
|
+
return (0,_shared_navigator__WEBPACK_IMPORTED_MODULE_1__.getNavigatorLocks)().request(`db-lock-${this._dbIdentifier}`, callback);
|
|
33879
33876
|
}
|
|
33880
33877
|
async readTransaction(fn, options) {
|
|
33881
33878
|
return this.readLock(this.wrapTransaction(fn));
|
|
@@ -34711,7 +34708,8 @@ class WASQLiteOpenFactory extends _AbstractWebSQLOpenFactory__WEBPACK_IMPORTED_M
|
|
|
34711
34708
|
temporaryStorage,
|
|
34712
34709
|
cacheSizeKb,
|
|
34713
34710
|
flags: this.resolvedFlags,
|
|
34714
|
-
encryptionKey: encryptionKey
|
|
34711
|
+
encryptionKey: encryptionKey,
|
|
34712
|
+
logLevel: this.logger.getLevel()
|
|
34715
34713
|
}),
|
|
34716
34714
|
identifier: this.options.dbFilename,
|
|
34717
34715
|
onClose: () => {
|
|
@@ -35060,6 +35058,7 @@ class SharedWebStreamingSyncImplementation extends _WebStreamingSyncImplementati
|
|
|
35060
35058
|
}).port;
|
|
35061
35059
|
}
|
|
35062
35060
|
this.syncManager = comlink__WEBPACK_IMPORTED_MODULE_0__.wrap(this.messagePort);
|
|
35061
|
+
this.syncManager.setLogLevel(this.logger.getLevel());
|
|
35063
35062
|
this.triggerCrudUpload = this.syncManager.triggerCrudUpload;
|
|
35064
35063
|
/**
|
|
35065
35064
|
* Opens MessagePort to the existing shared DB worker.
|
|
@@ -35228,7 +35227,9 @@ class WebStreamingSyncImplementation extends _powersync_common__WEBPACK_IMPORTED
|
|
|
35228
35227
|
}
|
|
35229
35228
|
obtainLock(lockOptions) {
|
|
35230
35229
|
const identifier = `streaming-sync-${lockOptions.type}-${this.webOptions.identifier}`;
|
|
35231
|
-
lockOptions.type == _powersync_common__WEBPACK_IMPORTED_MODULE_0__.LockType.SYNC
|
|
35230
|
+
if (lockOptions.type == _powersync_common__WEBPACK_IMPORTED_MODULE_0__.LockType.SYNC) {
|
|
35231
|
+
this.logger.debug('requesting lock for ', identifier);
|
|
35232
|
+
}
|
|
35232
35233
|
return (0,_shared_navigator__WEBPACK_IMPORTED_MODULE_1__.getNavigatorLocks)().request(identifier, { signal: lockOptions.signal }, lockOptions.callback);
|
|
35233
35234
|
}
|
|
35234
35235
|
}
|
|
@@ -35440,8 +35441,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
35440
35441
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
35441
35442
|
/* harmony export */ BroadcastLogger: () => (/* binding */ BroadcastLogger)
|
|
35442
35443
|
/* harmony export */ });
|
|
35443
|
-
/* harmony import */ var
|
|
35444
|
-
/* harmony import */ var
|
|
35444
|
+
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @powersync/common */ "@powersync/common");
|
|
35445
|
+
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_powersync_common__WEBPACK_IMPORTED_MODULE_0__);
|
|
35445
35446
|
|
|
35446
35447
|
/**
|
|
35447
35448
|
* Broadcasts logs to all clients
|
|
@@ -35455,64 +35456,88 @@ class BroadcastLogger {
|
|
|
35455
35456
|
WARN;
|
|
35456
35457
|
ERROR;
|
|
35457
35458
|
OFF;
|
|
35459
|
+
currentLevel = _powersync_common__WEBPACK_IMPORTED_MODULE_0__.LogLevel.INFO;
|
|
35458
35460
|
constructor(clients) {
|
|
35459
35461
|
this.clients = clients;
|
|
35460
|
-
this.TRACE =
|
|
35461
|
-
this.DEBUG =
|
|
35462
|
-
this.INFO =
|
|
35463
|
-
this.TIME =
|
|
35464
|
-
this.WARN =
|
|
35465
|
-
this.ERROR =
|
|
35466
|
-
this.OFF =
|
|
35462
|
+
this.TRACE = _powersync_common__WEBPACK_IMPORTED_MODULE_0__.LogLevel.TRACE;
|
|
35463
|
+
this.DEBUG = _powersync_common__WEBPACK_IMPORTED_MODULE_0__.LogLevel.DEBUG;
|
|
35464
|
+
this.INFO = _powersync_common__WEBPACK_IMPORTED_MODULE_0__.LogLevel.INFO;
|
|
35465
|
+
this.TIME = _powersync_common__WEBPACK_IMPORTED_MODULE_0__.LogLevel.TIME;
|
|
35466
|
+
this.WARN = _powersync_common__WEBPACK_IMPORTED_MODULE_0__.LogLevel.WARN;
|
|
35467
|
+
this.ERROR = _powersync_common__WEBPACK_IMPORTED_MODULE_0__.LogLevel.ERROR;
|
|
35468
|
+
this.OFF = _powersync_common__WEBPACK_IMPORTED_MODULE_0__.LogLevel.OFF;
|
|
35467
35469
|
}
|
|
35468
35470
|
trace(...x) {
|
|
35471
|
+
if (!this.enabledFor(this.TRACE))
|
|
35472
|
+
return;
|
|
35469
35473
|
console.trace(...x);
|
|
35470
35474
|
const sanitized = this.sanitizeArgs(x);
|
|
35471
35475
|
this.iterateClients((client) => client.clientProvider.trace(...sanitized));
|
|
35472
35476
|
}
|
|
35473
35477
|
debug(...x) {
|
|
35478
|
+
if (!this.enabledFor(this.DEBUG))
|
|
35479
|
+
return;
|
|
35474
35480
|
console.debug(...x);
|
|
35475
35481
|
const sanitized = this.sanitizeArgs(x);
|
|
35476
35482
|
this.iterateClients((client) => client.clientProvider.debug(...sanitized));
|
|
35477
35483
|
}
|
|
35478
35484
|
info(...x) {
|
|
35485
|
+
if (!this.enabledFor(this.INFO))
|
|
35486
|
+
return;
|
|
35479
35487
|
console.info(...x);
|
|
35480
35488
|
const sanitized = this.sanitizeArgs(x);
|
|
35481
35489
|
this.iterateClients((client) => client.clientProvider.info(...sanitized));
|
|
35482
35490
|
}
|
|
35483
35491
|
log(...x) {
|
|
35492
|
+
if (!this.enabledFor(this.INFO))
|
|
35493
|
+
return;
|
|
35484
35494
|
console.log(...x);
|
|
35485
35495
|
const sanitized = this.sanitizeArgs(x);
|
|
35486
35496
|
this.iterateClients((client) => client.clientProvider.log(...sanitized));
|
|
35487
35497
|
}
|
|
35488
35498
|
warn(...x) {
|
|
35499
|
+
if (!this.enabledFor(this.WARN))
|
|
35500
|
+
return;
|
|
35489
35501
|
console.warn(...x);
|
|
35490
35502
|
const sanitized = this.sanitizeArgs(x);
|
|
35491
35503
|
this.iterateClients((client) => client.clientProvider.warn(...sanitized));
|
|
35492
35504
|
}
|
|
35493
35505
|
error(...x) {
|
|
35506
|
+
if (!this.enabledFor(this.ERROR))
|
|
35507
|
+
return;
|
|
35494
35508
|
console.error(...x);
|
|
35495
35509
|
const sanitized = this.sanitizeArgs(x);
|
|
35496
35510
|
this.iterateClients((client) => client.clientProvider.error(...sanitized));
|
|
35497
35511
|
}
|
|
35498
35512
|
time(label) {
|
|
35513
|
+
if (!this.enabledFor(this.TIME))
|
|
35514
|
+
return;
|
|
35499
35515
|
console.time(label);
|
|
35500
35516
|
this.iterateClients((client) => client.clientProvider.time(label));
|
|
35501
35517
|
}
|
|
35502
35518
|
timeEnd(label) {
|
|
35519
|
+
if (!this.enabledFor(this.TIME))
|
|
35520
|
+
return;
|
|
35503
35521
|
console.timeEnd(label);
|
|
35504
35522
|
this.iterateClients((client) => client.clientProvider.timeEnd(label));
|
|
35505
35523
|
}
|
|
35524
|
+
/**
|
|
35525
|
+
* Set the global log level.
|
|
35526
|
+
*/
|
|
35506
35527
|
setLevel(level) {
|
|
35507
|
-
|
|
35528
|
+
this.currentLevel = level;
|
|
35508
35529
|
}
|
|
35530
|
+
/**
|
|
35531
|
+
* Get the current log level.
|
|
35532
|
+
*/
|
|
35509
35533
|
getLevel() {
|
|
35510
|
-
|
|
35511
|
-
return (js_logger__WEBPACK_IMPORTED_MODULE_0___default().INFO);
|
|
35534
|
+
return this.currentLevel;
|
|
35512
35535
|
}
|
|
35536
|
+
/**
|
|
35537
|
+
* Returns true if the given level is enabled.
|
|
35538
|
+
*/
|
|
35513
35539
|
enabledFor(level) {
|
|
35514
|
-
|
|
35515
|
-
return true;
|
|
35540
|
+
return level.value >= this.currentLevel.value;
|
|
35516
35541
|
}
|
|
35517
35542
|
/**
|
|
35518
35543
|
* Iterates all clients, catches individual client exceptions
|
|
@@ -35568,15 +35593,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
35568
35593
|
/* harmony import */ var async_mutex__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(async_mutex__WEBPACK_IMPORTED_MODULE_1__);
|
|
35569
35594
|
/* harmony import */ var comlink__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! comlink */ "comlink");
|
|
35570
35595
|
/* harmony import */ var comlink__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(comlink__WEBPACK_IMPORTED_MODULE_2__);
|
|
35571
|
-
/* harmony import */ var
|
|
35572
|
-
/* harmony import */ var
|
|
35573
|
-
/* harmony import */ var
|
|
35574
|
-
/* harmony import */ var
|
|
35575
|
-
/* harmony import */ var
|
|
35576
|
-
/* harmony import */ var
|
|
35577
|
-
/* harmony import */ var _shared_navigator__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../shared/navigator */ "./lib/src/shared/navigator.js");
|
|
35578
|
-
/* harmony import */ var _BroadcastLogger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./BroadcastLogger */ "./lib/src/worker/sync/BroadcastLogger.js");
|
|
35579
|
-
|
|
35596
|
+
/* harmony import */ var _db_sync_WebRemote__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../db/sync/WebRemote */ "./lib/src/db/sync/WebRemote.js");
|
|
35597
|
+
/* harmony import */ var _db_sync_WebStreamingSyncImplementation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../db/sync/WebStreamingSyncImplementation */ "./lib/src/db/sync/WebStreamingSyncImplementation.js");
|
|
35598
|
+
/* harmony import */ var _db_adapters_LockedAsyncDatabaseAdapter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../db/adapters/LockedAsyncDatabaseAdapter */ "./lib/src/db/adapters/LockedAsyncDatabaseAdapter.js");
|
|
35599
|
+
/* harmony import */ var _db_adapters_WorkerWrappedAsyncDatabaseConnection__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../db/adapters/WorkerWrappedAsyncDatabaseConnection */ "./lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js");
|
|
35600
|
+
/* harmony import */ var _shared_navigator__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../shared/navigator */ "./lib/src/shared/navigator.js");
|
|
35601
|
+
/* harmony import */ var _BroadcastLogger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./BroadcastLogger */ "./lib/src/worker/sync/BroadcastLogger.js");
|
|
35580
35602
|
|
|
35581
35603
|
|
|
35582
35604
|
|
|
@@ -35620,7 +35642,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
35620
35642
|
this.dbAdapter = null;
|
|
35621
35643
|
this.syncParams = null;
|
|
35622
35644
|
this.syncStreamClient = null;
|
|
35623
|
-
this.logger =
|
|
35645
|
+
this.logger = (0,_powersync_common__WEBPACK_IMPORTED_MODULE_0__.createLogger)('shared-sync');
|
|
35624
35646
|
this.lastConnectOptions = undefined;
|
|
35625
35647
|
this.isInitialized = new Promise((resolve) => {
|
|
35626
35648
|
const callback = this.registerListener({
|
|
@@ -35631,7 +35653,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
35631
35653
|
});
|
|
35632
35654
|
});
|
|
35633
35655
|
this.syncStatus = new _powersync_common__WEBPACK_IMPORTED_MODULE_0__.SyncStatus({});
|
|
35634
|
-
this.broadCastLogger = new
|
|
35656
|
+
this.broadCastLogger = new _BroadcastLogger__WEBPACK_IMPORTED_MODULE_8__.BroadcastLogger(this.ports);
|
|
35635
35657
|
}
|
|
35636
35658
|
async waitForStatus(status) {
|
|
35637
35659
|
await this.waitForReady();
|
|
@@ -35650,6 +35672,10 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
35650
35672
|
async waitForReady() {
|
|
35651
35673
|
return this.isInitialized;
|
|
35652
35674
|
}
|
|
35675
|
+
setLogLevel(level) {
|
|
35676
|
+
this.logger.setLevel(level);
|
|
35677
|
+
this.broadCastLogger.setLevel(level);
|
|
35678
|
+
}
|
|
35653
35679
|
/**
|
|
35654
35680
|
* Configures the DBAdapter connection and a streaming sync client.
|
|
35655
35681
|
*/
|
|
@@ -35683,7 +35709,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
35683
35709
|
async connect(options) {
|
|
35684
35710
|
await this.waitForReady();
|
|
35685
35711
|
// This effectively queues connect and disconnect calls. Ensuring multiple tabs' requests are synchronized
|
|
35686
|
-
return (0,
|
|
35712
|
+
return (0,_shared_navigator__WEBPACK_IMPORTED_MODULE_7__.getNavigatorLocks)().request('shared-sync-connect', async () => {
|
|
35687
35713
|
if (!this.dbAdapter) {
|
|
35688
35714
|
await this.openInternalDB();
|
|
35689
35715
|
}
|
|
@@ -35700,7 +35726,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
35700
35726
|
async disconnect() {
|
|
35701
35727
|
await this.waitForReady();
|
|
35702
35728
|
// This effectively queues connect and disconnect calls. Ensuring multiple tabs' requests are synchronized
|
|
35703
|
-
return (0,
|
|
35729
|
+
return (0,_shared_navigator__WEBPACK_IMPORTED_MODULE_7__.getNavigatorLocks)().request('shared-sync-connect', async () => {
|
|
35704
35730
|
await this.syncStreamClient?.disconnect();
|
|
35705
35731
|
await this.syncStreamClient?.dispose();
|
|
35706
35732
|
this.syncStreamClient = null;
|
|
@@ -35728,7 +35754,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
35728
35754
|
async removePort(port) {
|
|
35729
35755
|
const index = this.ports.findIndex((p) => p.port == port);
|
|
35730
35756
|
if (index < 0) {
|
|
35731
|
-
|
|
35757
|
+
this.logger.warn(`Could not remove port ${port} since it is not present in active ports.`);
|
|
35732
35758
|
return;
|
|
35733
35759
|
}
|
|
35734
35760
|
const trackedPort = this.ports[index];
|
|
@@ -35779,9 +35805,9 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
35779
35805
|
// This should only be called after initialization has completed
|
|
35780
35806
|
const syncParams = this.syncParams;
|
|
35781
35807
|
// Create a new StreamingSyncImplementation for each connect call. This is usually done is all SDKs.
|
|
35782
|
-
return new
|
|
35808
|
+
return new _db_sync_WebStreamingSyncImplementation__WEBPACK_IMPORTED_MODULE_4__.WebStreamingSyncImplementation({
|
|
35783
35809
|
adapter: new _powersync_common__WEBPACK_IMPORTED_MODULE_0__.SqliteBucketStorage(this.dbAdapter, new async_mutex__WEBPACK_IMPORTED_MODULE_1__.Mutex(), this.logger),
|
|
35784
|
-
remote: new
|
|
35810
|
+
remote: new _db_sync_WebRemote__WEBPACK_IMPORTED_MODULE_3__.WebRemote({
|
|
35785
35811
|
fetchCredentials: async () => {
|
|
35786
35812
|
const lastPort = this.ports[this.ports.length - 1];
|
|
35787
35813
|
return new Promise(async (resolve, reject) => {
|
|
@@ -35792,7 +35818,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
35792
35818
|
};
|
|
35793
35819
|
abortController.signal.onabort = reject;
|
|
35794
35820
|
try {
|
|
35795
|
-
|
|
35821
|
+
this.logger.log('calling the last port client provider for credentials');
|
|
35796
35822
|
resolve(await lastPort.clientProvider.fetchCredentials());
|
|
35797
35823
|
}
|
|
35798
35824
|
catch (ex) {
|
|
@@ -35840,10 +35866,10 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
35840
35866
|
const remote = comlink__WEBPACK_IMPORTED_MODULE_2__.wrap(workerPort);
|
|
35841
35867
|
const identifier = this.syncParams.dbParams.dbFilename;
|
|
35842
35868
|
const db = await remote(this.syncParams.dbParams);
|
|
35843
|
-
const locked = new
|
|
35869
|
+
const locked = new _db_adapters_LockedAsyncDatabaseAdapter__WEBPACK_IMPORTED_MODULE_5__.LockedAsyncDatabaseAdapter({
|
|
35844
35870
|
name: identifier,
|
|
35845
35871
|
openConnection: async () => {
|
|
35846
|
-
return new
|
|
35872
|
+
return new _db_adapters_WorkerWrappedAsyncDatabaseConnection__WEBPACK_IMPORTED_MODULE_6__.WorkerWrappedAsyncDatabaseConnection({
|
|
35847
35873
|
remote,
|
|
35848
35874
|
baseConnection: db,
|
|
35849
35875
|
identifier
|
|
@@ -36001,17 +36027,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_comlink__;
|
|
|
36001
36027
|
|
|
36002
36028
|
/***/ }),
|
|
36003
36029
|
|
|
36004
|
-
/***/ "js-logger":
|
|
36005
|
-
/*!****************************!*\
|
|
36006
|
-
!*** external "js-logger" ***!
|
|
36007
|
-
\****************************/
|
|
36008
|
-
/***/ ((module) => {
|
|
36009
|
-
|
|
36010
|
-
"use strict";
|
|
36011
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_js_logger__;
|
|
36012
|
-
|
|
36013
|
-
/***/ }),
|
|
36014
|
-
|
|
36015
36030
|
/***/ "?2e65":
|
|
36016
36031
|
/*!************************!*\
|
|
36017
36032
|
!*** buffer (ignored) ***!
|