dexie-cloud-addon 4.0.0-beta.18 → 4.0.0-beta.21
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 +41 -25
- 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 +45 -26
- 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 +598 -568
- 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 +17 -3
- package/dist/types/DexieCloudEntity.d.ts +8 -0
- package/dist/types/DexieCloudOptions.d.ts +2 -1
- package/dist/types/Invite.d.ts +2 -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/db/entities/UserLogin.d.ts +0 -2
- package/dist/types/default-ui/Dialog.d.ts +2 -1
- package/dist/types/getInvitesObservable.d.ts +1 -23
- 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 +598 -568
- 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 +45 -26
- 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 +38 -22
- package/dist/umd-modern/dexie-cloud-addon.js.map +1 -1
- package/package.json +3 -3
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* ==========================================================================
|
|
10
10
|
*
|
|
11
|
-
* Version 4.0.0-beta.
|
|
11
|
+
* Version 4.0.0-beta.21, Tue Jun 07 2022
|
|
12
12
|
*
|
|
13
13
|
* https://dexie.org
|
|
14
14
|
*
|
|
@@ -5197,16 +5197,19 @@ function syncIfPossible(db, cloudOptions, cloudSchema, options) {
|
|
|
5197
5197
|
function _syncIfPossible() {
|
|
5198
5198
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
5199
5199
|
try {
|
|
5200
|
-
if (db.cloud.
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
}
|
|
5200
|
+
if (db.cloud.isServiceWorkerDB) {
|
|
5201
|
+
// We are the dedicated sync SW:
|
|
5202
|
+
yield sync(db, cloudOptions, cloudSchema, options);
|
|
5204
5203
|
}
|
|
5205
|
-
else {
|
|
5204
|
+
else if (!db.cloud.usingServiceWorker) {
|
|
5206
5205
|
// We use a flow that is better suited for the case when multiple workers want to
|
|
5207
5206
|
// do the same thing.
|
|
5208
5207
|
yield performGuardedJob(db, CURRENT_SYNC_WORKER, '$jobs', () => sync(db, cloudOptions, cloudSchema, options));
|
|
5209
5208
|
}
|
|
5209
|
+
else {
|
|
5210
|
+
assert(false);
|
|
5211
|
+
throw new Error('Internal _syncIfPossible() - invalid precondition - should not have been called.');
|
|
5212
|
+
}
|
|
5210
5213
|
ongoingSyncs.delete(db);
|
|
5211
5214
|
console.debug('Done sync');
|
|
5212
5215
|
}
|
|
@@ -5368,8 +5371,8 @@ const Styles = {
|
|
|
5368
5371
|
}
|
|
5369
5372
|
};
|
|
5370
5373
|
|
|
5371
|
-
function Dialog({ children }) {
|
|
5372
|
-
return (a$1("div",
|
|
5374
|
+
function Dialog({ children, className }) {
|
|
5375
|
+
return (a$1("div", { className: className },
|
|
5373
5376
|
a$1("div", { style: Styles.Darken }),
|
|
5374
5377
|
a$1("div", { style: Styles.DialogOuter },
|
|
5375
5378
|
a$1("div", { style: Styles.DialogInner }, children))));
|
|
@@ -5385,7 +5388,7 @@ function LoginDialog({ title, alerts, fields, onCancel, onSubmit, }) {
|
|
|
5385
5388
|
const [params, setParams] = l({});
|
|
5386
5389
|
const firstFieldRef = s();
|
|
5387
5390
|
h(() => { var _a; return (_a = firstFieldRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }, []);
|
|
5388
|
-
return (a$1(Dialog,
|
|
5391
|
+
return (a$1(Dialog, { className: "dxc-login-dlg" },
|
|
5389
5392
|
a$1(y, null,
|
|
5390
5393
|
a$1("h3", { style: Styles.WindowHeader }, title),
|
|
5391
5394
|
alerts.map((alert) => (a$1("p", { style: Styles.Alert[alert.type] }, resolveText(alert)))),
|
|
@@ -5799,7 +5802,18 @@ const getInvitesObservable = associate((db) => {
|
|
|
5799
5802
|
const reducer = (result, m) => (Object.assign(Object.assign({}, result), { [m.id]: Object.assign(Object.assign({}, m), { realm: realmLookup[m.realmId] }) }));
|
|
5800
5803
|
const emailMembersById = membersByEmail.reduce(reducer, {});
|
|
5801
5804
|
const membersById = accessControl.selfMembers.reduce(reducer, emailMembersById);
|
|
5802
|
-
return Object.values(membersById)
|
|
5805
|
+
return Object.values(membersById)
|
|
5806
|
+
.filter((invite) => !invite.accepted && !invite.rejected)
|
|
5807
|
+
.map((invite) => (Object.assign(Object.assign({}, invite), { accept() {
|
|
5808
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
5809
|
+
yield db.members.update(invite.id, { accepted: new Date() });
|
|
5810
|
+
});
|
|
5811
|
+
},
|
|
5812
|
+
reject() {
|
|
5813
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
5814
|
+
yield db.members.update(invite.id, { rejected: new Date() });
|
|
5815
|
+
});
|
|
5816
|
+
} })));
|
|
5803
5817
|
})), []);
|
|
5804
5818
|
});
|
|
5805
5819
|
|
|
@@ -5847,10 +5861,9 @@ function dexieCloud(dexie) {
|
|
|
5847
5861
|
currentUserEmitter.next(UNAUTHORIZED_USER);
|
|
5848
5862
|
});
|
|
5849
5863
|
dexie.cloud = {
|
|
5850
|
-
version: '4.0.0-beta.
|
|
5864
|
+
version: '4.0.0-beta.21',
|
|
5851
5865
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
5852
5866
|
schema: null,
|
|
5853
|
-
serverState: null,
|
|
5854
5867
|
get currentUserId() {
|
|
5855
5868
|
return currentUserEmitter.value.userId || UNAUTHORIZED_USER.userId;
|
|
5856
5869
|
},
|
|
@@ -5939,15 +5952,17 @@ function dexieCloud(dexie) {
|
|
|
5939
5952
|
dexie.use(createImplicitPropSetterMiddleware(DexieCloudDB(dexie)));
|
|
5940
5953
|
dexie.use(createIdGenerationMiddleware(DexieCloudDB(dexie)));
|
|
5941
5954
|
function onDbReady(dexie) {
|
|
5942
|
-
var _a, _b, _c, _d, _e, _f;
|
|
5955
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
5943
5956
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
5944
5957
|
closed = false; // As Dexie calls us, we are not closed anymore. Maybe reopened? Remember db.ready event is registered with sticky flag!
|
|
5945
5958
|
const db = DexieCloudDB(dexie);
|
|
5946
5959
|
// Setup default GUI:
|
|
5947
|
-
if (
|
|
5960
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
5948
5961
|
if (!((_a = db.cloud.options) === null || _a === void 0 ? void 0 : _a.customLoginGui)) {
|
|
5949
5962
|
subscriptions.push(setupDefaultGUI(dexie));
|
|
5950
5963
|
}
|
|
5964
|
+
}
|
|
5965
|
+
if (!db.cloud.isServiceWorkerDB) {
|
|
5951
5966
|
subscriptions.push(computeSyncState(db).subscribe(dexie.cloud.syncState));
|
|
5952
5967
|
}
|
|
5953
5968
|
//verifyConfig(db.cloud.options); Not needed (yet at least!)
|
|
@@ -5959,7 +5974,7 @@ function dexieCloud(dexie) {
|
|
|
5959
5974
|
? yield navigator.serviceWorker.getRegistrations()
|
|
5960
5975
|
: [];
|
|
5961
5976
|
const initiallySynced = yield db.transaction('rw', db.$syncState, () => __awaiter$1(this, void 0, void 0, function* () {
|
|
5962
|
-
var
|
|
5977
|
+
var _h, _j;
|
|
5963
5978
|
const { options, schema } = db.cloud;
|
|
5964
5979
|
const [persistedOptions, persistedSchema, persistedSyncState] = yield Promise.all([
|
|
5965
5980
|
db.getOptions(),
|
|
@@ -5978,7 +5993,7 @@ function dexieCloud(dexie) {
|
|
|
5978
5993
|
throw new Error(`Internal error`); // options cannot be null if configuredProgramatically is set.
|
|
5979
5994
|
yield db.$syncState.put(options, 'options');
|
|
5980
5995
|
}
|
|
5981
|
-
if (((
|
|
5996
|
+
if (((_h = db.cloud.options) === null || _h === void 0 ? void 0 : _h.tryUseServiceWorker) &&
|
|
5982
5997
|
'serviceWorker' in navigator &&
|
|
5983
5998
|
swRegistrations.length > 0 &&
|
|
5984
5999
|
!DISABLE_SERVICEWORKER_STRATEGY) {
|
|
@@ -5992,7 +6007,8 @@ function dexieCloud(dexie) {
|
|
|
5992
6007
|
// Not configured for using service worker or no service worker
|
|
5993
6008
|
// registration exists. Don't rely on service worker to do any job.
|
|
5994
6009
|
// Use LocalSyncWorker instead.
|
|
5995
|
-
if (((
|
|
6010
|
+
if (((_j = db.cloud.options) === null || _j === void 0 ? void 0 : _j.tryUseServiceWorker) &&
|
|
6011
|
+
!db.cloud.isServiceWorkerDB) {
|
|
5996
6012
|
console.debug('dexie-cloud-addon: Not using service worker.', swRegistrations.length === 0
|
|
5997
6013
|
? 'No SW registrations found.'
|
|
5998
6014
|
: 'serviceWorker' in navigator && DISABLE_SERVICEWORKER_STRATEGY
|
|
@@ -6040,7 +6056,7 @@ function dexieCloud(dexie) {
|
|
|
6040
6056
|
}
|
|
6041
6057
|
// Manage CurrentUser observable:
|
|
6042
6058
|
throwIfClosed();
|
|
6043
|
-
if (!
|
|
6059
|
+
if (!db.cloud.isServiceWorkerDB) {
|
|
6044
6060
|
subscriptions.push(liveQuery(() => db.getCurrentUser()).subscribe(currentUserEmitter));
|
|
6045
6061
|
// Manage PersistendSyncState observable:
|
|
6046
6062
|
subscriptions.push(liveQuery(() => db.getPersistedSyncState()).subscribe(db.cloud.persistedSyncState));
|
|
@@ -6067,7 +6083,7 @@ function dexieCloud(dexie) {
|
|
|
6067
6083
|
}
|
|
6068
6084
|
else if (((_e = db.cloud.options) === null || _e === void 0 ? void 0 : _e.databaseUrl) &&
|
|
6069
6085
|
db.cloud.schema &&
|
|
6070
|
-
!
|
|
6086
|
+
!db.cloud.isServiceWorkerDB) {
|
|
6071
6087
|
// There's no SW. Start SyncWorker instead.
|
|
6072
6088
|
localSyncWorker = LocalSyncWorker(db, db.cloud.options, db.cloud.schema);
|
|
6073
6089
|
localSyncWorker.start();
|
|
@@ -6075,7 +6091,7 @@ function dexieCloud(dexie) {
|
|
|
6075
6091
|
}
|
|
6076
6092
|
// Listen to online event and do sync.
|
|
6077
6093
|
throwIfClosed();
|
|
6078
|
-
if (!
|
|
6094
|
+
if (!db.cloud.isServiceWorkerDB) {
|
|
6079
6095
|
subscriptions.push(fromEvent(self, 'online').subscribe(() => {
|
|
6080
6096
|
console.debug('online!');
|
|
6081
6097
|
db.syncStateChangedEvent.next({
|
|
@@ -6089,16 +6105,16 @@ function dexieCloud(dexie) {
|
|
|
6089
6105
|
});
|
|
6090
6106
|
}));
|
|
6091
6107
|
}
|
|
6092
|
-
// Connect WebSocket
|
|
6093
|
-
if (
|
|
6094
|
-
!
|
|
6095
|
-
|
|
6108
|
+
// Connect WebSocket unless we
|
|
6109
|
+
if (((_f = db.cloud.options) === null || _f === void 0 ? void 0 : _f.databaseUrl) &&
|
|
6110
|
+
!((_g = db.cloud.options) === null || _g === void 0 ? void 0 : _g.disableWebSocket) &&
|
|
6111
|
+
!IS_SERVICE_WORKER) {
|
|
6096
6112
|
subscriptions.push(connectWebSocket(db));
|
|
6097
6113
|
}
|
|
6098
6114
|
});
|
|
6099
6115
|
}
|
|
6100
6116
|
}
|
|
6101
|
-
dexieCloud.version = '4.0.0-beta.
|
|
6117
|
+
dexieCloud.version = '4.0.0-beta.21';
|
|
6102
6118
|
Dexie.Cloud = dexieCloud;
|
|
6103
6119
|
|
|
6104
6120
|
export { dexieCloud as default, dexieCloud, getTiedObjectId, getTiedRealmId };
|