dexie-cloud-addon 4.0.0-beta.18 → 4.0.0-beta.19
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 +26 -20
- 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 +30 -21
- 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 +571 -564
- 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 +1 -0
- package/dist/types/DexieCloudEntity.d.ts +8 -0
- package/dist/types/DexieCloudOptions.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/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 +571 -564
- 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 +30 -21
- 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 +23 -17
- package/dist/umd-modern/dexie-cloud-addon.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* ==========================================================================
|
|
10
10
|
*
|
|
11
|
-
* Version 4.0.0-beta.
|
|
11
|
+
* Version 4.0.0-beta.19, Fri May 20 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
|
}
|
|
@@ -5847,7 +5850,7 @@ function dexieCloud(dexie) {
|
|
|
5847
5850
|
currentUserEmitter.next(UNAUTHORIZED_USER);
|
|
5848
5851
|
});
|
|
5849
5852
|
dexie.cloud = {
|
|
5850
|
-
version: '4.0.0-beta.
|
|
5853
|
+
version: '4.0.0-beta.19',
|
|
5851
5854
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
5852
5855
|
schema: null,
|
|
5853
5856
|
serverState: null,
|
|
@@ -5939,15 +5942,17 @@ function dexieCloud(dexie) {
|
|
|
5939
5942
|
dexie.use(createImplicitPropSetterMiddleware(DexieCloudDB(dexie)));
|
|
5940
5943
|
dexie.use(createIdGenerationMiddleware(DexieCloudDB(dexie)));
|
|
5941
5944
|
function onDbReady(dexie) {
|
|
5942
|
-
var _a, _b, _c, _d, _e, _f;
|
|
5945
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
5943
5946
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
5944
5947
|
closed = false; // As Dexie calls us, we are not closed anymore. Maybe reopened? Remember db.ready event is registered with sticky flag!
|
|
5945
5948
|
const db = DexieCloudDB(dexie);
|
|
5946
5949
|
// Setup default GUI:
|
|
5947
|
-
if (
|
|
5950
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
5948
5951
|
if (!((_a = db.cloud.options) === null || _a === void 0 ? void 0 : _a.customLoginGui)) {
|
|
5949
5952
|
subscriptions.push(setupDefaultGUI(dexie));
|
|
5950
5953
|
}
|
|
5954
|
+
}
|
|
5955
|
+
if (!db.cloud.isServiceWorkerDB) {
|
|
5951
5956
|
subscriptions.push(computeSyncState(db).subscribe(dexie.cloud.syncState));
|
|
5952
5957
|
}
|
|
5953
5958
|
//verifyConfig(db.cloud.options); Not needed (yet at least!)
|
|
@@ -5959,7 +5964,7 @@ function dexieCloud(dexie) {
|
|
|
5959
5964
|
? yield navigator.serviceWorker.getRegistrations()
|
|
5960
5965
|
: [];
|
|
5961
5966
|
const initiallySynced = yield db.transaction('rw', db.$syncState, () => __awaiter$1(this, void 0, void 0, function* () {
|
|
5962
|
-
var
|
|
5967
|
+
var _h, _j;
|
|
5963
5968
|
const { options, schema } = db.cloud;
|
|
5964
5969
|
const [persistedOptions, persistedSchema, persistedSyncState] = yield Promise.all([
|
|
5965
5970
|
db.getOptions(),
|
|
@@ -5978,7 +5983,7 @@ function dexieCloud(dexie) {
|
|
|
5978
5983
|
throw new Error(`Internal error`); // options cannot be null if configuredProgramatically is set.
|
|
5979
5984
|
yield db.$syncState.put(options, 'options');
|
|
5980
5985
|
}
|
|
5981
|
-
if (((
|
|
5986
|
+
if (((_h = db.cloud.options) === null || _h === void 0 ? void 0 : _h.tryUseServiceWorker) &&
|
|
5982
5987
|
'serviceWorker' in navigator &&
|
|
5983
5988
|
swRegistrations.length > 0 &&
|
|
5984
5989
|
!DISABLE_SERVICEWORKER_STRATEGY) {
|
|
@@ -5992,7 +5997,8 @@ function dexieCloud(dexie) {
|
|
|
5992
5997
|
// Not configured for using service worker or no service worker
|
|
5993
5998
|
// registration exists. Don't rely on service worker to do any job.
|
|
5994
5999
|
// Use LocalSyncWorker instead.
|
|
5995
|
-
if (((
|
|
6000
|
+
if (((_j = db.cloud.options) === null || _j === void 0 ? void 0 : _j.tryUseServiceWorker) &&
|
|
6001
|
+
!db.cloud.isServiceWorkerDB) {
|
|
5996
6002
|
console.debug('dexie-cloud-addon: Not using service worker.', swRegistrations.length === 0
|
|
5997
6003
|
? 'No SW registrations found.'
|
|
5998
6004
|
: 'serviceWorker' in navigator && DISABLE_SERVICEWORKER_STRATEGY
|
|
@@ -6040,7 +6046,7 @@ function dexieCloud(dexie) {
|
|
|
6040
6046
|
}
|
|
6041
6047
|
// Manage CurrentUser observable:
|
|
6042
6048
|
throwIfClosed();
|
|
6043
|
-
if (!
|
|
6049
|
+
if (!db.cloud.isServiceWorkerDB) {
|
|
6044
6050
|
subscriptions.push(liveQuery(() => db.getCurrentUser()).subscribe(currentUserEmitter));
|
|
6045
6051
|
// Manage PersistendSyncState observable:
|
|
6046
6052
|
subscriptions.push(liveQuery(() => db.getPersistedSyncState()).subscribe(db.cloud.persistedSyncState));
|
|
@@ -6067,7 +6073,7 @@ function dexieCloud(dexie) {
|
|
|
6067
6073
|
}
|
|
6068
6074
|
else if (((_e = db.cloud.options) === null || _e === void 0 ? void 0 : _e.databaseUrl) &&
|
|
6069
6075
|
db.cloud.schema &&
|
|
6070
|
-
!
|
|
6076
|
+
!db.cloud.isServiceWorkerDB) {
|
|
6071
6077
|
// There's no SW. Start SyncWorker instead.
|
|
6072
6078
|
localSyncWorker = LocalSyncWorker(db, db.cloud.options, db.cloud.schema);
|
|
6073
6079
|
localSyncWorker.start();
|
|
@@ -6075,7 +6081,7 @@ function dexieCloud(dexie) {
|
|
|
6075
6081
|
}
|
|
6076
6082
|
// Listen to online event and do sync.
|
|
6077
6083
|
throwIfClosed();
|
|
6078
|
-
if (!
|
|
6084
|
+
if (!db.cloud.isServiceWorkerDB) {
|
|
6079
6085
|
subscriptions.push(fromEvent(self, 'online').subscribe(() => {
|
|
6080
6086
|
console.debug('online!');
|
|
6081
6087
|
db.syncStateChangedEvent.next({
|
|
@@ -6089,16 +6095,16 @@ function dexieCloud(dexie) {
|
|
|
6089
6095
|
});
|
|
6090
6096
|
}));
|
|
6091
6097
|
}
|
|
6092
|
-
// Connect WebSocket
|
|
6093
|
-
if (
|
|
6094
|
-
!
|
|
6095
|
-
|
|
6098
|
+
// Connect WebSocket unless we
|
|
6099
|
+
if (((_f = db.cloud.options) === null || _f === void 0 ? void 0 : _f.databaseUrl) &&
|
|
6100
|
+
!((_g = db.cloud.options) === null || _g === void 0 ? void 0 : _g.disableWebSocket) &&
|
|
6101
|
+
!IS_SERVICE_WORKER) {
|
|
6096
6102
|
subscriptions.push(connectWebSocket(db));
|
|
6097
6103
|
}
|
|
6098
6104
|
});
|
|
6099
6105
|
}
|
|
6100
6106
|
}
|
|
6101
|
-
dexieCloud.version = '4.0.0-beta.
|
|
6107
|
+
dexieCloud.version = '4.0.0-beta.19';
|
|
6102
6108
|
Dexie.Cloud = dexieCloud;
|
|
6103
6109
|
|
|
6104
6110
|
export { dexieCloud as default, dexieCloud, getTiedObjectId, getTiedRealmId };
|