dexie-cloud-addon 4.0.1-beta.34 → 4.0.1-beta.36

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.
@@ -20,6 +20,9 @@ export interface DexieCloudAPI {
20
20
  webSocketStatus: Rx.BehaviorSubject<DXCWebSocketStatus>;
21
21
  syncState: Rx.BehaviorSubject<SyncState>;
22
22
  persistedSyncState: Rx.BehaviorSubject<PersistedSyncState | undefined>;
23
+ events: {
24
+ syncComplete: Rx.Observable<void>;
25
+ };
23
26
  userInteraction: Rx.BehaviorSubject<DXCUserInteraction | undefined>;
24
27
  invites: Rx.Observable<Invite[]>;
25
28
  roles: Rx.Observable<{
@@ -3,4 +3,4 @@ export declare function login(db: DexieCloudDB, hints?: {
3
3
  email?: string;
4
4
  userId?: string;
5
5
  grant_type?: string;
6
- }): Promise<void>;
6
+ }): Promise<boolean>;
@@ -3,7 +3,7 @@ import { GuardedJob } from './entities/GuardedJob';
3
3
  import { UserLogin } from './entities/UserLogin';
4
4
  import { PersistedSyncState } from './entities/PersistedSyncState';
5
5
  import { DexieCloudOptions } from '../DexieCloudOptions';
6
- import { BehaviorSubject } from 'rxjs';
6
+ import { Subject } from 'rxjs';
7
7
  import { BaseRevisionMapEntry } from './entities/BaseRevisionMapEntry';
8
8
  import { DBRealm, DBRealmMember, DBRealmRole, DexieCloudSchema } from 'dexie-cloud-common';
9
9
  import { BroadcastedAndLocalEvent } from '../helpers/BroadcastedAndLocalEvent';
@@ -29,10 +29,11 @@ export interface DexieCloudDBBase {
29
29
  readonly realms: Table<DBRealm, string>;
30
30
  readonly members: Table<DBRealmMember, string>;
31
31
  readonly roles: Table<DBRealmRole, [string, string]>;
32
- readonly localSyncEvent: BehaviorSubject<{
32
+ readonly localSyncEvent: Subject<{
33
33
  purpose?: 'pull' | 'push';
34
34
  }>;
35
35
  readonly syncStateChangedEvent: BroadcastedAndLocalEvent<SyncStateChangedEventData>;
36
+ readonly syncCompleteEvent: BroadcastedAndLocalEvent<void>;
36
37
  readonly dx: Dexie;
37
38
  readonly initiallySynced: boolean;
38
39
  }
@@ -1,3 +1,3 @@
1
1
  import { DexieCloudDB } from "../db/DexieCloudDB";
2
2
  import { PersistedSyncState } from "../db/entities/PersistedSyncState";
3
- export declare function getTablesToSyncify(db: DexieCloudDB, syncState: PersistedSyncState | undefined): import("dexie").Table<import("../db/entities/EntityCommon").EntityCommon, import("dexie").IndexableType, import("../db/entities/EntityCommon").EntityCommon>[];
3
+ export declare function getTablesToSyncify(db: DexieCloudDB, syncState: PersistedSyncState | undefined): import("dexie").Table<import("../db/entities/EntityCommon").EntityCommon, any, import("../db/entities/EntityCommon").EntityCommon>[];
@@ -8,7 +8,7 @@
8
8
 
9
9
  var Dexie__default = /*#__PURE__*/_interopDefaultLegacy(Dexie);
10
10
 
11
- /*! *****************************************************************************
11
+ /******************************************************************************
12
12
  Copyright (c) Microsoft Corporation.
13
13
 
14
14
  Permission to use, copy, modify, and/or distribute this software for any
@@ -95,7 +95,7 @@
95
95
  ar[i] = from[i];
96
96
  }
97
97
  }
98
- return to.concat(ar || from);
98
+ return to.concat(ar || Array.prototype.slice.call(from));
99
99
  }
100
100
 
101
101
  /* ==========================================================================
@@ -108,14 +108,14 @@
108
108
  *
109
109
  * ==========================================================================
110
110
  *
111
- * Version 4.0.1-beta.34, Mon Mar 27 2023
111
+ * Version 4.0.1-beta.36, Mon Apr 17 2023
112
112
  *
113
113
  * https://dexie.org
114
114
  *
115
115
  * Apache License Version 2.0, January 2004, http://www.apache.org/licenses/
116
116
  *
117
117
  */
118
- /*! *****************************************************************************
118
+ /******************************************************************************
119
119
  Copyright (c) Microsoft Corporation.
120
120
 
121
121
  Permission to use, copy, modify, and/or distribute this software for any
@@ -280,7 +280,7 @@
280
280
  ar[i] = from[i];
281
281
  }
282
282
  }
283
- return to.concat(ar || from);
283
+ return to.concat(ar || Array.prototype.slice.call(from));
284
284
  }
285
285
  function __await(v) {
286
286
  return this instanceof __await ? (this.v = v, this) : new __await(v);
@@ -1407,7 +1407,6 @@
1407
1407
  return _this;
1408
1408
  }
1409
1409
  AsyncAction.prototype.schedule = function (state, delay) {
1410
- var _a;
1411
1410
  if (delay === void 0) {
1412
1411
  delay = 0;
1413
1412
  }
@@ -1422,7 +1421,7 @@
1422
1421
  }
1423
1422
  this.pending = true;
1424
1423
  this.delay = delay;
1425
- this.id = (_a = this.id) !== null && _a !== void 0 ? _a : this.requestAsyncId(scheduler, this.id, delay);
1424
+ this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
1426
1425
  return this;
1427
1426
  };
1428
1427
  AsyncAction.prototype.requestAsyncId = function (scheduler, _id, delay) {
@@ -1438,9 +1437,7 @@
1438
1437
  if (delay != null && this.delay === delay && this.pending === false) {
1439
1438
  return id;
1440
1439
  }
1441
- if (id != null) {
1442
- intervalProvider.clearInterval(id);
1443
- }
1440
+ intervalProvider.clearInterval(id);
1444
1441
  return undefined;
1445
1442
  };
1446
1443
  AsyncAction.prototype.execute = function (state, delay) {
@@ -1519,6 +1516,7 @@
1519
1516
  var _this = _super.call(this, SchedulerAction, now) || this;
1520
1517
  _this.actions = [];
1521
1518
  _this._active = false;
1519
+ _this._scheduled = undefined;
1522
1520
  return _this;
1523
1521
  }
1524
1522
  AsyncScheduler.prototype.flush = function (action) {
@@ -1917,7 +1915,7 @@
1917
1915
  return concat$1(subscriptionDelay.pipe(take(1), ignoreElements()), source.pipe(delayWhen(delayDurationSelector)));
1918
1916
  };
1919
1917
  }
1920
- return mergeMap(function (value, index) { return innerFrom(delayDurationSelector(value, index)).pipe(take(1), mapTo(value)); });
1918
+ return mergeMap(function (value, index) { return delayDurationSelector(value, index).pipe(take(1), mapTo(value)); });
1921
1919
  }
1922
1920
  function delay(due, scheduler) {
1923
1921
  if (scheduler === void 0) {
@@ -2403,13 +2401,22 @@
2403
2401
  var _k, privateKey, publicKey, publicKeySPKI, publicKeyPEM, response2, error_1;
2404
2402
  return __generator$1(this, function (_l) {
2405
2403
  switch (_l.label) {
2406
- case 0: return [4 /*yield*/, crypto.subtle.generateKey({
2407
- name: 'RSASSA-PKCS1-v1_5',
2408
- modulusLength: 2048,
2409
- publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
2410
- hash: { name: 'SHA-256' },
2411
- }, false, // Non-exportable...
2412
- ['sign', 'verify'])];
2404
+ case 0:
2405
+ if (!crypto.subtle) {
2406
+ if (typeof location !== 'undefined' && location.protocol === 'http:') {
2407
+ throw new Error("Dexie Cloud Addon needs to use WebCrypto, but your browser has disabled it due to being served from an insecure location. Please serve it from https or http://localhost:<port> (See https://stackoverflow.com/questions/46670556/how-to-enable-crypto-subtle-for-unsecure-origins-in-chrome/46671627#46671627)");
2408
+ }
2409
+ else {
2410
+ throw new Error("This browser does not support WebCrypto.");
2411
+ }
2412
+ }
2413
+ return [4 /*yield*/, crypto.subtle.generateKey({
2414
+ name: 'RSASSA-PKCS1-v1_5',
2415
+ modulusLength: 2048,
2416
+ publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
2417
+ hash: { name: 'SHA-256' },
2418
+ }, false, // Non-exportable...
2419
+ ['sign', 'verify'])];
2413
2420
  case 1:
2414
2421
  _k = _l.sent(), privateKey = _k.privateKey, publicKey = _k.publicKey;
2415
2422
  if (!privateKey || !publicKey)
@@ -2458,7 +2465,7 @@
2458
2465
  type: 'error',
2459
2466
  messageCode: 'GENERIC_ERROR',
2460
2467
  message: "We're having a problem authenticating right now.",
2461
- messageParams: {}
2468
+ messageParams: {},
2462
2469
  }).catch(function () { })];
2463
2470
  case 8:
2464
2471
  _l.sent();
@@ -2724,7 +2731,7 @@
2724
2731
  }
2725
2732
  function login(db, hints) {
2726
2733
  return __awaiter(this, void 0, void 0, function () {
2727
- var currentUser, context;
2734
+ var currentUser, context, e_6;
2728
2735
  return __generator$1(this, function (_k) {
2729
2736
  switch (_k.label) {
2730
2737
  case 0: return [4 /*yield*/, db.getCurrentUser()];
@@ -2740,7 +2747,7 @@
2740
2747
  }
2741
2748
  }
2742
2749
  // Already authenticated according to given hints.
2743
- return [2 /*return*/];
2750
+ return [2 /*return*/, false];
2744
2751
  }
2745
2752
  context = new AuthPersistedContext(db, {
2746
2753
  claims: {},
@@ -2749,16 +2756,31 @@
2749
2756
  return [4 /*yield*/, authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints)];
2750
2757
  case 2:
2751
2758
  _k.sent();
2752
- return [4 /*yield*/, context.save()];
2759
+ _k.label = 3;
2753
2760
  case 3:
2754
- _k.sent();
2755
- return [4 /*yield*/, setCurrentUser(db, context)];
2761
+ _k.trys.push([3, 5, , 6]);
2762
+ return [4 /*yield*/, context.save()];
2756
2763
  case 4:
2764
+ _k.sent();
2765
+ return [3 /*break*/, 6];
2766
+ case 5:
2767
+ e_6 = _k.sent();
2768
+ try {
2769
+ if (e_6.name === 'DataCloneError') {
2770
+ console.debug("Login context property names:", Object.keys(context));
2771
+ console.debug("Login context:", context);
2772
+ console.debug("Login context JSON:", JSON.stringify(context));
2773
+ }
2774
+ }
2775
+ catch (_a) { }
2776
+ throw e_6;
2777
+ case 6: return [4 /*yield*/, setCurrentUser(db, context)];
2778
+ case 7:
2757
2779
  _k.sent();
2758
2780
  // Make sure to resync as the new login will be authorized
2759
2781
  // for new realms.
2760
2782
  triggerSync(db, "pull");
2761
- return [2 /*return*/];
2783
+ return [2 /*return*/, true];
2762
2784
  }
2763
2785
  });
2764
2786
  });
@@ -2834,6 +2856,36 @@
2834
2856
  };
2835
2857
  return SWBroadcastChannel;
2836
2858
  }());
2859
+ var events = globalThis['lbc-events'] || (globalThis['lbc-events'] = new Map());
2860
+ function addListener(name, listener) {
2861
+ if (events.has(name)) {
2862
+ events.get(name).push(listener);
2863
+ }
2864
+ else {
2865
+ events.set(name, [listener]);
2866
+ }
2867
+ }
2868
+ function removeListener(name, listener) {
2869
+ var listeners = events.get(name);
2870
+ if (listeners) {
2871
+ var idx = listeners.indexOf(listener);
2872
+ if (idx !== -1) {
2873
+ listeners.splice(idx, 1);
2874
+ }
2875
+ }
2876
+ }
2877
+ function dispatch(ev) {
2878
+ var listeners = events.get(ev.type);
2879
+ if (listeners) {
2880
+ listeners.forEach(function (listener) {
2881
+ try {
2882
+ listener(ev);
2883
+ }
2884
+ catch (_a) {
2885
+ }
2886
+ });
2887
+ }
2888
+ }
2837
2889
  var BroadcastedAndLocalEvent = /** @class */ (function (_super_1) {
2838
2890
  __extends$1(BroadcastedAndLocalEvent, _super_1);
2839
2891
  function BroadcastedAndLocalEvent(name) {
@@ -2849,16 +2901,24 @@
2849
2901
  subscriber.next(ev.data);
2850
2902
  }
2851
2903
  var unsubscribe;
2852
- self.addEventListener("lbc-".concat(name), onCustomEvent);
2853
- if (bc instanceof SWBroadcastChannel) {
2854
- unsubscribe = bc.subscribe(function (message) { return subscriber.next(message); });
2904
+ //self.addEventListener(`lbc-${name}`, onCustomEvent); // Fails in service workers
2905
+ addListener("lbc-".concat(name), onCustomEvent); // Works better in service worker
2906
+ try {
2907
+ if (bc instanceof SWBroadcastChannel) {
2908
+ unsubscribe = bc.subscribe(function (message) { return subscriber.next(message); });
2909
+ }
2910
+ else {
2911
+ console.debug("BroadcastedAndLocalEvent: bc.addEventListener()", name, "bc is a", bc);
2912
+ bc.addEventListener("message", onMessageEvent);
2913
+ }
2855
2914
  }
2856
- else {
2857
- console.debug("BroadcastedAndLocalEvent: bc.addEventListener()", name, "bc is a", bc);
2858
- bc.addEventListener("message", onMessageEvent);
2915
+ catch (err) {
2916
+ // Service workers might fail to subscribe outside its initial script.
2917
+ console.warn('Failed to subscribe to broadcast channel', err);
2859
2918
  }
2860
2919
  return function () {
2861
- self.removeEventListener("lbc-".concat(name), onCustomEvent);
2920
+ //self.removeEventListener(`lbc-${name}`, onCustomEvent);
2921
+ removeListener("lbc-".concat(name), onCustomEvent);
2862
2922
  if (bc instanceof SWBroadcastChannel) {
2863
2923
  unsubscribe();
2864
2924
  }
@@ -2875,7 +2935,8 @@
2875
2935
  console.debug("BroadcastedAndLocalEvent: bc.postMessage()", Object.assign({}, message), "bc is a", this.bc);
2876
2936
  this.bc.postMessage(message);
2877
2937
  var ev = new CustomEvent("lbc-".concat(this.name), { detail: message });
2878
- self.dispatchEvent(ev);
2938
+ //self.dispatchEvent(ev);
2939
+ dispatch(ev);
2879
2940
  };
2880
2941
  return BroadcastedAndLocalEvent;
2881
2942
  }(rxjs.Observable));
@@ -4057,7 +4118,7 @@
4057
4118
  return _sync
4058
4119
  .apply(this, arguments)
4059
4120
  .then(function () {
4060
- if (!(syncOptions === null || syncOptions === void 0 ? void 0 : syncOptions.justCheckIfNeeded)) {
4121
+ if (!(syncOptions === null || syncOptions === void 0 ? void 0 : syncOptions.justCheckIfNeeded)) { // && syncOptions?.purpose !== 'push') {
4061
4122
  db.syncStateChangedEvent.next({
4062
4123
  phase: 'in-sync',
4063
4124
  });
@@ -4115,7 +4176,7 @@
4115
4176
  } : _k, isInitialSync = _l.isInitialSync, cancelToken = _l.cancelToken, justCheckIfNeeded = _l.justCheckIfNeeded, purpose = _l.purpose;
4116
4177
  var _a;
4117
4178
  return __awaiter(this, void 0, void 0, function () {
4118
- var databaseUrl, currentUser, tablesToSync, mutationTables, persistedSyncState, readyForSyncification, tablesToSyncify, doSyncify, _k, clientChangeSet, syncState, baseRevs, syncIsNeeded, latestRevisions, clientIdentity, res, done;
4179
+ var databaseUrl, currentUser, tablesToSync, mutationTables, persistedSyncState, readyForSyncification, tablesToSyncify, doSyncify, _k, clientChangeSet, syncState, baseRevs, pushSyncIsNeeded, latestRevisions, clientIdentity, res, done;
4119
4180
  var _this_1 = this;
4120
4181
  return __generator$1(this, function (_l) {
4121
4182
  switch (_l.label) {
@@ -4192,12 +4253,12 @@
4192
4253
  }); })];
4193
4254
  case 5:
4194
4255
  _k = _l.sent(), clientChangeSet = _k[0], syncState = _k[1], baseRevs = _k[2];
4195
- syncIsNeeded = clientChangeSet.some(function (set) { return set.muts.some(function (mut) { return mut.keys.length > 0; }); });
4256
+ pushSyncIsNeeded = clientChangeSet.some(function (set) { return set.muts.some(function (mut) { return mut.keys.length > 0; }); });
4196
4257
  if (justCheckIfNeeded) {
4197
- console.debug('Sync is needed:', syncIsNeeded);
4198
- return [2 /*return*/, syncIsNeeded];
4258
+ console.debug('Sync is needed:', pushSyncIsNeeded);
4259
+ return [2 /*return*/, pushSyncIsNeeded];
4199
4260
  }
4200
- if (purpose === 'push' && !syncIsNeeded) {
4261
+ if (purpose === 'push' && !pushSyncIsNeeded) {
4201
4262
  // The purpose of this request was to push changes
4202
4263
  return [2 /*return*/, false];
4203
4264
  }
@@ -4372,6 +4433,7 @@
4372
4433
  case 8: return [2 /*return*/, _l.sent()];
4373
4434
  case 9:
4374
4435
  console.debug('SYNC DONE', { isInitialSync: isInitialSync });
4436
+ db.syncCompleteEvent.next();
4375
4437
  return [2 /*return*/, false]; // Not needed anymore
4376
4438
  }
4377
4439
  });
@@ -4765,6 +4827,7 @@
4765
4827
  if (!db) {
4766
4828
  var localSyncEvent = new rxjs.Subject();
4767
4829
  var syncStateChangedEvent_1 = new BroadcastedAndLocalEvent("syncstatechanged-".concat(dx.name));
4830
+ var syncCompleteEvent_1 = new BroadcastedAndLocalEvent("synccomplete-".concat(dx.name));
4768
4831
  localSyncEvent['id'] = ++static_counter;
4769
4832
  var initiallySynced_1 = false;
4770
4833
  db = {
@@ -4808,6 +4871,9 @@
4808
4871
  get syncStateChangedEvent() {
4809
4872
  return syncStateChangedEvent_1;
4810
4873
  },
4874
+ get syncCompleteEvent() {
4875
+ return syncCompleteEvent_1;
4876
+ },
4811
4877
  dx: dx,
4812
4878
  };
4813
4879
  var helperMethods = {
@@ -4840,6 +4906,7 @@
4840
4906
  },
4841
4907
  reconfigure: function () {
4842
4908
  syncStateChangedEvent_1 = new BroadcastedAndLocalEvent("syncstatechanged-".concat(dx.name));
4909
+ syncCompleteEvent_1 = new BroadcastedAndLocalEvent("synccomplete-".concat(dx.name));
4843
4910
  },
4844
4911
  };
4845
4912
  Object.assign(db, helperMethods);
@@ -5773,6 +5840,15 @@
5773
5840
  switchMap(function (syncState) { return db.cloud.currentUser.pipe(map(function (userLogin) { return [userLogin, syncState]; })); }), switchMap(function (_k) {
5774
5841
  var userLogin = _k[0], syncState = _k[1];
5775
5842
  return userIsReallyActive.pipe(map(function (isActive) { return [isActive ? userLogin : null, syncState]; }));
5843
+ }), switchMap(function (_k) {
5844
+ var userLogin = _k[0], syncState = _k[1];
5845
+ if ((userLogin === null || userLogin === void 0 ? void 0 : userLogin.isLoggedIn) && !(syncState === null || syncState === void 0 ? void 0 : syncState.realms.includes(userLogin.userId))) {
5846
+ // We're in an in-between state when user is logged in but the user's realms are not yet synced.
5847
+ // Don't make this change reconnect the websocket just yet. Wait till syncState is updated
5848
+ // to iclude the user's realm.
5849
+ return db.cloud.persistedSyncState.pipe(filter(function (syncState) { return (syncState === null || syncState === void 0 ? void 0 : syncState.realms.includes(userLogin.userId)) || false; }), take(1), map(function (syncState) { return [userLogin, syncState]; }));
5850
+ }
5851
+ return new rxjs.BehaviorSubject([userLogin, syncState]);
5776
5852
  }), switchMap(function (_k) {
5777
5853
  var userLogin = _k[0], syncState = _k[1];
5778
5854
  return __awaiter(_this_1, void 0, void 0, function () { var _k; return __generator$1(this, function (_l) {
@@ -6968,8 +7044,9 @@
6968
7044
  localSyncWorker = null;
6969
7045
  currentUserEmitter.next(UNAUTHORIZED_USER);
6970
7046
  });
7047
+ var syncComplete = new rxjs.Subject();
6971
7048
  dexie.cloud = {
6972
- version: '4.0.1-beta.34',
7049
+ version: '4.0.1-beta.36',
6973
7050
  options: Object.assign({}, DEFAULT_OPTIONS),
6974
7051
  schema: null,
6975
7052
  get currentUserId() {
@@ -6980,6 +7057,9 @@
6980
7057
  phase: 'initial',
6981
7058
  status: 'not-started',
6982
7059
  }),
7060
+ events: {
7061
+ syncComplete: syncComplete,
7062
+ },
6983
7063
  persistedSyncState: new rxjs.BehaviorSubject(undefined),
6984
7064
  userInteraction: new rxjs.BehaviorSubject(undefined),
6985
7065
  webSocketStatus: new rxjs.BehaviorSubject('not-started'),
@@ -7097,7 +7177,7 @@
7097
7177
  function onDbReady(dexie) {
7098
7178
  var _a, _b, _c, _d, _e, _f, _g;
7099
7179
  return __awaiter(this, void 0, void 0, function () {
7100
- var db, swRegistrations, _k, initiallySynced;
7180
+ var db, swRegistrations, _k, initiallySynced, changedUser;
7101
7181
  var _this_1 = this;
7102
7182
  return __generator$1(this, function (_l) {
7103
7183
  switch (_l.label) {
@@ -7113,6 +7193,8 @@
7113
7193
  if (!db.cloud.isServiceWorkerDB) {
7114
7194
  subscriptions.push(computeSyncState(db).subscribe(dexie.cloud.syncState));
7115
7195
  }
7196
+ // Forward db.syncCompleteEvent to be publicly consumable via db.cloud.events.syncComplete:
7197
+ subscriptions.push(db.syncCompleteEvent.subscribe(syncComplete));
7116
7198
  //verifyConfig(db.cloud.options); Not needed (yet at least!)
7117
7199
  // Verify the user has allowed version increment.
7118
7200
  if (!db.tables.every(function (table) { return table.core; })) {
@@ -7252,10 +7334,11 @@
7252
7334
  _l.sent();
7253
7335
  _l.label = 8;
7254
7336
  case 8:
7337
+ changedUser = false;
7255
7338
  if (!((_c = db.cloud.options) === null || _c === void 0 ? void 0 : _c.requireAuth)) return [3 /*break*/, 10];
7256
7339
  return [4 /*yield*/, login(db)];
7257
7340
  case 9:
7258
- _l.sent();
7341
+ changedUser = _l.sent();
7259
7342
  _l.label = 10;
7260
7343
  case 10:
7261
7344
  if (localSyncWorker)
@@ -7263,7 +7346,7 @@
7263
7346
  localSyncWorker = null;
7264
7347
  throwIfClosed();
7265
7348
  if (db.cloud.usingServiceWorker && ((_d = db.cloud.options) === null || _d === void 0 ? void 0 : _d.databaseUrl)) {
7266
- registerSyncEvent(db, 'push').catch(function () { });
7349
+ registerSyncEvent(db, changedUser ? 'pull' : 'push').catch(function () { });
7267
7350
  registerPeriodicSyncEvent(db).catch(function () { });
7268
7351
  }
7269
7352
  else if (((_e = db.cloud.options) === null || _e === void 0 ? void 0 : _e.databaseUrl) &&
@@ -7272,7 +7355,7 @@
7272
7355
  // There's no SW. Start SyncWorker instead.
7273
7356
  localSyncWorker = LocalSyncWorker(db, db.cloud.options, db.cloud.schema);
7274
7357
  localSyncWorker.start();
7275
- triggerSync(db, 'push');
7358
+ triggerSync(db, changedUser ? 'pull' : 'push');
7276
7359
  }
7277
7360
  // Listen to online event and do sync.
7278
7361
  throwIfClosed();
@@ -7302,7 +7385,7 @@
7302
7385
  });
7303
7386
  }
7304
7387
  }
7305
- dexieCloud.version = '4.0.1-beta.34';
7388
+ dexieCloud.version = '4.0.1-beta.36';
7306
7389
  Dexie__default["default"].Cloud = dexieCloud;
7307
7390
 
7308
7391
  exports["default"] = dexieCloud;