dexie-cloud-addon 4.0.0-beta.13 → 4.0.0-beta.16
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/modern/dexie-cloud-addon.js +154 -49
- package/dist/modern/dexie-cloud-addon.js.map +1 -1
- package/dist/modern/dexie-cloud-addon.min.js +1 -1
- package/dist/modern/dexie-cloud-addon.min.js.map +1 -1
- package/dist/modern/service-worker.js +152 -46
- package/dist/modern/service-worker.js.map +1 -1
- package/dist/modern/service-worker.min.js +1 -1
- package/dist/modern/service-worker.min.js.map +1 -1
- package/dist/module-es5/dexie-cloud-addon.js +109 -45
- package/dist/module-es5/dexie-cloud-addon.js.map +1 -1
- package/dist/module-es5/dexie-cloud-addon.min.js +1 -1
- package/dist/module-es5/dexie-cloud-addon.min.js.map +1 -1
- package/dist/types/DexieCloudAPI.d.ts +4 -1
- package/dist/types/DexieCloudEntity.d.ts +8 -0
- package/dist/types/Invite.d.ts +1 -1
- package/dist/types/WSObservable.d.ts +1 -0
- package/dist/types/WebSocketStatus.d.ts +1 -0
- package/dist/types/createMyMembersObservable.d.ts +14 -0
- package/dist/types/currentUserObservable.d.ts +3 -0
- package/dist/types/dexie-cloud-client.d.ts +1 -0
- package/dist/types/getGlobalRolesObservable.d.ts +5 -0
- package/dist/types/getInvitesObservable.d.ts +1 -1
- package/dist/types/helpers/BroadcastedLocalEvent.d.ts +8 -0
- package/dist/types/helpers/visibleState.d.ts +1 -0
- package/dist/types/permissionsLookup.d.ts +9 -0
- package/dist/types/permissionsLookupObservable.d.ts +14 -0
- package/dist/types/sync/globalizePrivateIds.d.ts +4 -0
- package/dist/types/sync/syncServerToClientOnly.d.ts +3 -0
- package/dist/types/types/CloudConnectionStatus.d.ts +0 -0
- package/dist/types/types/ConnectionStatus.d.ts +0 -0
- package/dist/types/types/LoginState.d.ts +41 -0
- package/dist/types/types/SyncConnectionStatus.d.ts +1 -0
- package/dist/types/types/SyncFlowStatus.d.ts +6 -0
- package/dist/types/types/SyncStatus.d.ts +6 -0
- package/dist/umd/dexie-cloud-addon.js +129 -64
- package/dist/umd/dexie-cloud-addon.js.map +1 -1
- package/dist/umd/dexie-cloud-addon.min.js +1 -1
- package/dist/umd/dexie-cloud-addon.min.js.map +1 -1
- package/dist/umd/service-worker.js +175 -69
- package/dist/umd/service-worker.js.map +1 -1
- package/dist/umd/service-worker.min.js +1 -1
- package/dist/umd/service-worker.min.js.map +1 -1
- package/dist/umd-modern/dexie-cloud-addon.js +172 -66
- package/dist/umd-modern/dexie-cloud-addon.js.map +1 -1
- package/package.json +5 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Dexie, { liveQuery, cmp } from 'dexie';
|
|
2
|
-
import { BehaviorSubject, fromEvent, of, merge, from as from$1, Observable as Observable$1,
|
|
2
|
+
import { BehaviorSubject, fromEvent, of, merge, from as from$1, Observable as Observable$1, Subscription as Subscription$1, Subject, switchMap as switchMap$1, combineLatest, map as map$1, throwError, share, timer as timer$1 } from 'rxjs';
|
|
3
3
|
|
|
4
4
|
/*! *****************************************************************************
|
|
5
5
|
Copyright (c) Microsoft Corporation.
|
|
@@ -101,7 +101,7 @@ function __spreadArray$1(to, from, pack) {
|
|
|
101
101
|
*
|
|
102
102
|
* ==========================================================================
|
|
103
103
|
*
|
|
104
|
-
* Version 4.0.0-beta.
|
|
104
|
+
* Version 4.0.0-beta.16, Fri Apr 01 2022
|
|
105
105
|
*
|
|
106
106
|
* https://dexie.org
|
|
107
107
|
*
|
|
@@ -811,7 +811,8 @@ var timeoutProvider = {
|
|
|
811
811
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
812
812
|
args[_i] = arguments[_i];
|
|
813
813
|
}
|
|
814
|
-
|
|
814
|
+
var delegate = timeoutProvider.delegate;
|
|
815
|
+
return ((delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) || setTimeout).apply(void 0, __spreadArray([], __read(args)));
|
|
815
816
|
},
|
|
816
817
|
clearTimeout: function (handle) {
|
|
817
818
|
return (clearTimeout)(handle);
|
|
@@ -851,23 +852,20 @@ var Subscriber = (function (_super) {
|
|
|
851
852
|
return new SafeSubscriber(next, error, complete);
|
|
852
853
|
};
|
|
853
854
|
Subscriber.prototype.next = function (value) {
|
|
854
|
-
if (this.isStopped)
|
|
855
|
-
;
|
|
855
|
+
if (this.isStopped) ;
|
|
856
856
|
else {
|
|
857
857
|
this._next(value);
|
|
858
858
|
}
|
|
859
859
|
};
|
|
860
860
|
Subscriber.prototype.error = function (err) {
|
|
861
|
-
if (this.isStopped)
|
|
862
|
-
;
|
|
861
|
+
if (this.isStopped) ;
|
|
863
862
|
else {
|
|
864
863
|
this.isStopped = true;
|
|
865
864
|
this._error(err);
|
|
866
865
|
}
|
|
867
866
|
};
|
|
868
867
|
Subscriber.prototype.complete = function () {
|
|
869
|
-
if (this.isStopped)
|
|
870
|
-
;
|
|
868
|
+
if (this.isStopped) ;
|
|
871
869
|
else {
|
|
872
870
|
this.isStopped = true;
|
|
873
871
|
this._complete();
|
|
@@ -1322,7 +1320,8 @@ var intervalProvider = {
|
|
|
1322
1320
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1323
1321
|
args[_i] = arguments[_i];
|
|
1324
1322
|
}
|
|
1325
|
-
|
|
1323
|
+
var delegate = intervalProvider.delegate;
|
|
1324
|
+
return ((delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) || setInterval).apply(void 0, __spreadArray([], __read(args)));
|
|
1326
1325
|
},
|
|
1327
1326
|
clearInterval: function (handle) {
|
|
1328
1327
|
return (clearInterval)(handle);
|
|
@@ -5456,7 +5455,7 @@ function performInitialSync(db, cloudOptions, cloudSchema) {
|
|
|
5456
5455
|
});
|
|
5457
5456
|
});
|
|
5458
5457
|
}
|
|
5459
|
-
var USER_INACTIVITY_TIMEOUT =
|
|
5458
|
+
var USER_INACTIVITY_TIMEOUT = 180000; // 3 minutes
|
|
5460
5459
|
var INACTIVE_WAIT_TIME = 20000;
|
|
5461
5460
|
// This observable will be emitted to later down....
|
|
5462
5461
|
var userIsActive = new BehaviorSubject(true);
|
|
@@ -5470,9 +5469,12 @@ var userIsActive = new BehaviorSubject(true);
|
|
|
5470
5469
|
// for just a short time.
|
|
5471
5470
|
var userIsReallyActive = new BehaviorSubject(true);
|
|
5472
5471
|
userIsActive
|
|
5473
|
-
.pipe(switchMap(function (isActive) {
|
|
5474
|
-
|
|
5475
|
-
|
|
5472
|
+
.pipe(switchMap(function (isActive) {
|
|
5473
|
+
//console.debug('SyncStatus: DUBB: isActive changed to', isActive);
|
|
5474
|
+
return isActive
|
|
5475
|
+
? of(true)
|
|
5476
|
+
: of(false).pipe(delay(INACTIVE_WAIT_TIME));
|
|
5477
|
+
}), distinctUntilChanged())
|
|
5476
5478
|
.subscribe(userIsReallyActive);
|
|
5477
5479
|
//
|
|
5478
5480
|
// First create some corner-stone observables to build the flow on
|
|
@@ -5487,7 +5489,7 @@ var documentBecomesHidden = visibilityStateIsChanged.pipe(filter(function () { r
|
|
|
5487
5489
|
var documentBecomesVisible = visibilityStateIsChanged.pipe(filter(function () { return document.visibilityState === 'visible'; }));
|
|
5488
5490
|
// Any of various user-activity-related events happen:
|
|
5489
5491
|
var userDoesSomething = typeof window !== 'undefined'
|
|
5490
|
-
? merge(documentBecomesVisible, fromEvent(window, 'mousemove'), fromEvent(window, 'keydown'), fromEvent(window, 'wheel'), fromEvent(window, 'touchmove'))
|
|
5492
|
+
? merge(documentBecomesVisible, fromEvent(window, 'mousedown'), fromEvent(window, 'mousemove'), fromEvent(window, 'keydown'), fromEvent(window, 'wheel'), fromEvent(window, 'touchmove'))
|
|
5491
5493
|
: of({});
|
|
5492
5494
|
if (typeof document !== 'undefined') {
|
|
5493
5495
|
//
|
|
@@ -5542,6 +5544,7 @@ var WSConnection = /** @class */ (function (_super_1) {
|
|
|
5542
5544
|
function WSConnection(databaseUrl, rev, realmSetHash, clientIdentity, token, tokenExpiration, subscriber, messageProducer, webSocketStatus) {
|
|
5543
5545
|
var _this_1 = _super_1.call(this, function () { return _this_1.teardown(); }) || this;
|
|
5544
5546
|
_this_1.id = ++counter;
|
|
5547
|
+
_this_1.reconnecting = false;
|
|
5545
5548
|
console.debug('New WebSocket Connection', _this_1.id, token ? 'authorized' : 'unauthorized');
|
|
5546
5549
|
_this_1.databaseUrl = databaseUrl;
|
|
5547
5550
|
_this_1.rev = rev;
|
|
@@ -5562,7 +5565,7 @@ var WSConnection = /** @class */ (function (_super_1) {
|
|
|
5562
5565
|
this.disconnect();
|
|
5563
5566
|
};
|
|
5564
5567
|
WSConnection.prototype.disconnect = function () {
|
|
5565
|
-
this.webSocketStatus.next(
|
|
5568
|
+
this.webSocketStatus.next('disconnected');
|
|
5566
5569
|
if (this.pinger) {
|
|
5567
5570
|
clearInterval(this.pinger);
|
|
5568
5571
|
this.pinger = null;
|
|
@@ -5580,17 +5583,25 @@ var WSConnection = /** @class */ (function (_super_1) {
|
|
|
5580
5583
|
}
|
|
5581
5584
|
};
|
|
5582
5585
|
WSConnection.prototype.reconnect = function () {
|
|
5583
|
-
this
|
|
5584
|
-
this.
|
|
5586
|
+
var _this_1 = this;
|
|
5587
|
+
if (this.reconnecting)
|
|
5588
|
+
return;
|
|
5589
|
+
this.reconnecting = true;
|
|
5590
|
+
try {
|
|
5591
|
+
this.disconnect();
|
|
5592
|
+
}
|
|
5593
|
+
catch (_e) { }
|
|
5594
|
+
this.connect()
|
|
5595
|
+
.catch(function () { })
|
|
5596
|
+
.then(function () { return (_this_1.reconnecting = false); }); // finally()
|
|
5585
5597
|
};
|
|
5586
5598
|
WSConnection.prototype.connect = function () {
|
|
5587
5599
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
5588
|
-
var wsUrl, searchParams, ws;
|
|
5600
|
+
var wsUrl, searchParams, ws, everConnected_1;
|
|
5589
5601
|
var _this_1 = this;
|
|
5590
5602
|
return __generator$1(this, function (_e) {
|
|
5591
5603
|
switch (_e.label) {
|
|
5592
5604
|
case 0:
|
|
5593
|
-
this.webSocketStatus.next("connecting");
|
|
5594
5605
|
this.lastServerActivity = new Date();
|
|
5595
5606
|
if (this.pauseUntil && this.pauseUntil > new Date()) {
|
|
5596
5607
|
console.debug('WS not reconnecting just yet', {
|
|
@@ -5605,12 +5616,14 @@ var WSConnection = /** @class */ (function (_super_1) {
|
|
|
5605
5616
|
if (!this.databaseUrl)
|
|
5606
5617
|
throw new Error("Cannot connect without a database URL");
|
|
5607
5618
|
if (this.closed) {
|
|
5619
|
+
//console.debug('SyncStatus: DUBB: Ooops it was closed!');
|
|
5608
5620
|
return [2 /*return*/];
|
|
5609
5621
|
}
|
|
5610
5622
|
if (this.tokenExpiration && this.tokenExpiration < new Date()) {
|
|
5611
5623
|
this.subscriber.error(new TokenExpiredError()); // Will be handled in connectWebSocket.ts.
|
|
5612
5624
|
return [2 /*return*/];
|
|
5613
5625
|
}
|
|
5626
|
+
this.webSocketStatus.next('connecting');
|
|
5614
5627
|
this.pinger = setInterval(function () { return __awaiter$1(_this_1, void 0, void 0, function () {
|
|
5615
5628
|
var _this_1 = this;
|
|
5616
5629
|
return __generator$1(this, function (_e) {
|
|
@@ -5660,7 +5673,7 @@ var WSConnection = /** @class */ (function (_super_1) {
|
|
|
5660
5673
|
searchParams = new URLSearchParams();
|
|
5661
5674
|
if (this.subscriber.closed)
|
|
5662
5675
|
return [2 /*return*/];
|
|
5663
|
-
searchParams.set('v',
|
|
5676
|
+
searchParams.set('v', '2');
|
|
5664
5677
|
searchParams.set('rev', this.rev);
|
|
5665
5678
|
searchParams.set('realmsHash', this.realmSetHash);
|
|
5666
5679
|
searchParams.set('clientId', this.clientIdentity);
|
|
@@ -5701,17 +5714,23 @@ var WSConnection = /** @class */ (function (_super_1) {
|
|
|
5701
5714
|
_e.label = 1;
|
|
5702
5715
|
case 1:
|
|
5703
5716
|
_e.trys.push([1, 3, , 4]);
|
|
5717
|
+
everConnected_1 = false;
|
|
5704
5718
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
5705
5719
|
ws.onopen = function (event) {
|
|
5706
5720
|
console.debug('dexie-cloud WebSocket onopen');
|
|
5721
|
+
everConnected_1 = true;
|
|
5707
5722
|
resolve(null);
|
|
5708
5723
|
};
|
|
5709
5724
|
ws.onerror = function (event) {
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5725
|
+
if (!everConnected_1) {
|
|
5726
|
+
var error = event.error || new Error('WebSocket Error');
|
|
5727
|
+
_this_1.subscriber.error(error);
|
|
5728
|
+
_this_1.webSocketStatus.next('error');
|
|
5729
|
+
reject(error);
|
|
5730
|
+
}
|
|
5731
|
+
else {
|
|
5732
|
+
_this_1.reconnect();
|
|
5733
|
+
}
|
|
5715
5734
|
};
|
|
5716
5735
|
})];
|
|
5717
5736
|
case 2:
|
|
@@ -5719,8 +5738,9 @@ var WSConnection = /** @class */ (function (_super_1) {
|
|
|
5719
5738
|
this.messageProducerSubscription = this.messageProducer.subscribe(function (msg) {
|
|
5720
5739
|
var _e;
|
|
5721
5740
|
if (!_this_1.closed) {
|
|
5722
|
-
if (msg.type === 'ready' &&
|
|
5723
|
-
_this_1.webSocketStatus.
|
|
5741
|
+
if (msg.type === 'ready' &&
|
|
5742
|
+
_this_1.webSocketStatus.value !== 'connected') {
|
|
5743
|
+
_this_1.webSocketStatus.next('connected');
|
|
5724
5744
|
}
|
|
5725
5745
|
(_e = _this_1.ws) === null || _e === void 0 ? void 0 : _e.send(TSON.stringify(msg));
|
|
5726
5746
|
}
|
|
@@ -5829,7 +5849,10 @@ function connectWebSocket(db) {
|
|
|
5829
5849
|
else {
|
|
5830
5850
|
return throwError(error);
|
|
5831
5851
|
}
|
|
5832
|
-
}), catchError(function (error) {
|
|
5852
|
+
}), catchError(function (error) {
|
|
5853
|
+
db.cloud.webSocketStatus.next("error");
|
|
5854
|
+
return from$1(waitAndReconnectWhenUserDoesSomething(error)).pipe(switchMap(function () { return createObservable(); }));
|
|
5855
|
+
}));
|
|
5833
5856
|
}
|
|
5834
5857
|
return createObservable().subscribe(function (msg) {
|
|
5835
5858
|
if (msg) {
|
|
@@ -6198,7 +6221,7 @@ n = { __e: function (n, l) { for (var u, i, t; l = l.__;)
|
|
|
6198
6221
|
}
|
|
6199
6222
|
catch (l) {
|
|
6200
6223
|
n = l;
|
|
6201
|
-
} throw n; }, __v: 0 }, p$1.prototype.setState = function (n, l) { var u; u = null != this.__s && this.__s !== this.state ? this.__s : this.__s = c$1({}, this.state), "function" == typeof n && (n = n(c$1({}, u), this.props)), n && c$1(u, n), null != n && this.__v && (l && this.__h.push(l), k$1(this)); }, p$1.prototype.forceUpdate = function (n) { this.__v && (this.__e = !0, n && this.__h.push(n), k$1(this)); }, p$1.prototype.render = y, u$1 = [], i$1 = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, b$1.__r = 0
|
|
6224
|
+
} throw n; }, __v: 0 }, p$1.prototype.setState = function (n, l) { var u; u = null != this.__s && this.__s !== this.state ? this.__s : this.__s = c$1({}, this.state), "function" == typeof n && (n = n(c$1({}, u), this.props)), n && c$1(u, n), null != n && this.__v && (l && this.__h.push(l), k$1(this)); }, p$1.prototype.forceUpdate = function (n) { this.__v && (this.__e = !0, n && this.__h.push(n), k$1(this)); }, p$1.prototype.render = y, u$1 = [], i$1 = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, b$1.__r = 0;
|
|
6202
6225
|
var Styles = {
|
|
6203
6226
|
Error: {
|
|
6204
6227
|
color: "red",
|
|
@@ -6470,6 +6493,21 @@ function createSharedValueObservable(o, defaultValue) {
|
|
|
6470
6493
|
rv.getValue = function () { return currentValue; };
|
|
6471
6494
|
return rv;
|
|
6472
6495
|
}
|
|
6496
|
+
var getGlobalRolesObservable = associate(function (db) {
|
|
6497
|
+
return createSharedValueObservable(liveQuery(function () { return db.roles
|
|
6498
|
+
.where({ realmId: 'rlm-public' })
|
|
6499
|
+
.toArray()
|
|
6500
|
+
.then(function (roles) {
|
|
6501
|
+
var rv = {};
|
|
6502
|
+
for (var _e = 0, _f = roles
|
|
6503
|
+
.slice()
|
|
6504
|
+
.sort(function (a, b) { return (a.sortOrder || 0) - (b.sortOrder || 0); }); _e < _f.length; _e++) {
|
|
6505
|
+
var role = _f[_e];
|
|
6506
|
+
rv[role.name] = role;
|
|
6507
|
+
}
|
|
6508
|
+
return rv;
|
|
6509
|
+
}); }), {});
|
|
6510
|
+
});
|
|
6473
6511
|
var getCurrentUserEmitter = associate(function (db) { return new BehaviorSubject(UNAUTHORIZED_USER); });
|
|
6474
6512
|
var getInternalAccessControlObservable = associate(function (db) {
|
|
6475
6513
|
return createSharedValueObservable(getCurrentUserEmitter(db._novip).pipe(switchMap(function (currentUser) { return liveQuery(function () { return db.transaction('r', 'realms', 'members', function () { return Promise.all([
|
|
@@ -6572,17 +6610,40 @@ function mergePermissions() {
|
|
|
6572
6610
|
return reduced;
|
|
6573
6611
|
}
|
|
6574
6612
|
var getPermissionsLookupObservable = associate(function (db) {
|
|
6575
|
-
var o =
|
|
6613
|
+
var o = createSharedValueObservable(combineLatest([
|
|
6614
|
+
getInternalAccessControlObservable(db._novip),
|
|
6615
|
+
getGlobalRolesObservable(db._novip),
|
|
6616
|
+
]).pipe(map(function (_e) {
|
|
6617
|
+
var _f = _e[0], selfMembers = _f.selfMembers, realms = _f.realms, userId = _f.userId, globalRoles = _e[1];
|
|
6618
|
+
return ({
|
|
6619
|
+
selfMembers: selfMembers,
|
|
6620
|
+
realms: realms,
|
|
6621
|
+
userId: userId,
|
|
6622
|
+
globalRoles: globalRoles,
|
|
6623
|
+
});
|
|
6624
|
+
})), {
|
|
6625
|
+
selfMembers: [],
|
|
6626
|
+
realms: [],
|
|
6627
|
+
userId: UNAUTHORIZED_USER.userId,
|
|
6628
|
+
globalRoles: {},
|
|
6629
|
+
});
|
|
6576
6630
|
return mapValueObservable(o, function (_e) {
|
|
6577
6631
|
var _f;
|
|
6578
|
-
var selfMembers = _e.selfMembers, realms = _e.realms, userId = _e.userId;
|
|
6632
|
+
var selfMembers = _e.selfMembers, realms = _e.realms, userId = _e.userId, globalRoles = _e.globalRoles;
|
|
6579
6633
|
var rv = realms
|
|
6580
|
-
.map(function (realm) {
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6634
|
+
.map(function (realm) {
|
|
6635
|
+
var selfRealmMembers = selfMembers.filter(function (m) { return m.realmId === realm.realmId; });
|
|
6636
|
+
var directPermissionSets = selfRealmMembers
|
|
6637
|
+
.map(function (m) { return m.permissions; })
|
|
6638
|
+
.filter(function (p) { return p; });
|
|
6639
|
+
var rolePermissionSets = flatten(selfRealmMembers.map(function (m) { return m.roles; }).filter(function (roleName) { return roleName; }))
|
|
6640
|
+
.map(function (role) { return globalRoles[role]; })
|
|
6641
|
+
.filter(function (role) { return role; })
|
|
6642
|
+
.map(function (role) { return role.permissions; });
|
|
6643
|
+
return __assign(__assign({}, realm), { permissions: realm.owner === userId
|
|
6644
|
+
? { manage: '*' }
|
|
6645
|
+
: mergePermissions.apply(void 0, __spreadArray$1(__spreadArray$1([], directPermissionSets, false), rolePermissionSets, false)) });
|
|
6646
|
+
})
|
|
6586
6647
|
.reduce(function (p, c) {
|
|
6587
6648
|
var _e;
|
|
6588
6649
|
return (__assign(__assign({}, p), (_e = {}, _e[c.realmId] = c, _e)));
|
|
@@ -6680,7 +6741,7 @@ function permissions(dexie, obj, tableName) {
|
|
|
6680
6741
|
var realm = permissionsLookup[realmId || dexie.cloud.currentUserId];
|
|
6681
6742
|
if (!realm)
|
|
6682
6743
|
return new PermissionChecker({}, tableName, !owner || owner === dexie.cloud.currentUserId);
|
|
6683
|
-
return new PermissionChecker(realm.permissions, tableName,
|
|
6744
|
+
return new PermissionChecker(realm.permissions, tableName, realmId === dexie.cloud.currentUserId || owner === dexie.cloud.currentUserId);
|
|
6684
6745
|
};
|
|
6685
6746
|
var o = source.pipe(map(mapper));
|
|
6686
6747
|
o.getValue = function () { return mapper(source.getValue()); };
|
|
@@ -6718,6 +6779,7 @@ function dexieCloud(dexie) {
|
|
|
6718
6779
|
//
|
|
6719
6780
|
var currentUserEmitter = getCurrentUserEmitter(dexie);
|
|
6720
6781
|
var subscriptions = [];
|
|
6782
|
+
var configuredProgramatically = false;
|
|
6721
6783
|
// local sync worker - used when there's no service worker.
|
|
6722
6784
|
var localSyncWorker = null;
|
|
6723
6785
|
dexie.on('ready', function (dexie) { return __awaiter$1(_this_1, void 0, void 0, function () {
|
|
@@ -6753,7 +6815,7 @@ function dexieCloud(dexie) {
|
|
|
6753
6815
|
currentUserEmitter.next(UNAUTHORIZED_USER);
|
|
6754
6816
|
});
|
|
6755
6817
|
dexie.cloud = {
|
|
6756
|
-
version: '4.0.0-beta.
|
|
6818
|
+
version: '4.0.0-beta.16',
|
|
6757
6819
|
options: __assign({}, DEFAULT_OPTIONS),
|
|
6758
6820
|
schema: null,
|
|
6759
6821
|
serverState: null,
|
|
@@ -6787,8 +6849,10 @@ function dexieCloud(dexie) {
|
|
|
6787
6849
|
});
|
|
6788
6850
|
},
|
|
6789
6851
|
invites: getInvitesObservable(dexie),
|
|
6852
|
+
roles: getGlobalRolesObservable(dexie),
|
|
6790
6853
|
configure: function (options) {
|
|
6791
6854
|
options = dexie.cloud.options = __assign(__assign({}, dexie.cloud.options), options);
|
|
6855
|
+
configuredProgramatically = true;
|
|
6792
6856
|
if (options.databaseUrl && options.nameSuffix) {
|
|
6793
6857
|
// @ts-ignore
|
|
6794
6858
|
dexie.name = "".concat(origIdbName, "-").concat(getDbNameFromDbUrl(options.databaseUrl));
|
|
@@ -6923,7 +6987,7 @@ function dexieCloud(dexie) {
|
|
|
6923
6987
|
])];
|
|
6924
6988
|
case 1:
|
|
6925
6989
|
_f = _m.sent(), persistedOptions = _f[0], persistedSchema = _f[1], persistedSyncState = _f[2];
|
|
6926
|
-
if (!!
|
|
6990
|
+
if (!!configuredProgramatically) return [3 /*break*/, 2];
|
|
6927
6991
|
// Options not specified programatically (use case for SW!)
|
|
6928
6992
|
// Take persisted options:
|
|
6929
6993
|
db.cloud.options = persistedOptions || null;
|
|
@@ -6932,9 +6996,10 @@ function dexieCloud(dexie) {
|
|
|
6932
6996
|
if (!(!persistedOptions ||
|
|
6933
6997
|
JSON.stringify(persistedOptions) !== JSON.stringify(options))) return [3 /*break*/, 4];
|
|
6934
6998
|
// Update persisted options:
|
|
6999
|
+
if (!options)
|
|
7000
|
+
throw new Error("Internal error"); // options cannot be null if configuredProgramatically is set.
|
|
6935
7001
|
return [4 /*yield*/, db.$syncState.put(options, 'options')];
|
|
6936
7002
|
case 3:
|
|
6937
|
-
// Update persisted options:
|
|
6938
7003
|
_m.sent();
|
|
6939
7004
|
_m.label = 4;
|
|
6940
7005
|
case 4:
|
|
@@ -7080,9 +7145,8 @@ function dexieCloud(dexie) {
|
|
|
7080
7145
|
});
|
|
7081
7146
|
}
|
|
7082
7147
|
}
|
|
7083
|
-
dexieCloud.version = '4.0.0-beta.
|
|
7148
|
+
dexieCloud.version = '4.0.0-beta.16';
|
|
7084
7149
|
Dexie.Cloud = dexieCloud;
|
|
7085
7150
|
|
|
7086
|
-
export default dexieCloud;
|
|
7087
|
-
export { dexieCloud, getTiedObjectId, getTiedRealmId };
|
|
7151
|
+
export { dexieCloud as default, dexieCloud, getTiedObjectId, getTiedRealmId };
|
|
7088
7152
|
//# sourceMappingURL=dexie-cloud-addon.js.map
|