dexie-cloud-addon 4.0.0-beta.14 → 4.0.0-beta.15

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.
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * ==========================================================================
10
10
  *
11
- * Version 4.0.0-beta.14, Mon Dec 20 2021
11
+ * Version 4.0.0-beta.15, Mon Dec 20 2021
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -5726,6 +5726,7 @@ function dexieCloud(dexie) {
5726
5726
  //
5727
5727
  const currentUserEmitter = getCurrentUserEmitter(dexie);
5728
5728
  const subscriptions = [];
5729
+ let configuredProgramatically = false;
5729
5730
  // local sync worker - used when there's no service worker.
5730
5731
  let localSyncWorker = null;
5731
5732
  dexie.on('ready', async (dexie) => {
@@ -5752,7 +5753,7 @@ function dexieCloud(dexie) {
5752
5753
  currentUserEmitter.next(UNAUTHORIZED_USER);
5753
5754
  });
5754
5755
  dexie.cloud = {
5755
- version: '4.0.0-beta.14',
5756
+ version: '4.0.0-beta.15',
5756
5757
  options: { ...DEFAULT_OPTIONS },
5757
5758
  schema: null,
5758
5759
  serverState: null,
@@ -5775,6 +5776,7 @@ function dexieCloud(dexie) {
5775
5776
  invites: getInvitesObservable(dexie),
5776
5777
  configure(options) {
5777
5778
  options = dexie.cloud.options = { ...dexie.cloud.options, ...options };
5779
+ configuredProgramatically = true;
5778
5780
  if (options.databaseUrl && options.nameSuffix) {
5779
5781
  // @ts-ignore
5780
5782
  dexie.name = `${origIdbName}-${getDbNameFromDbUrl(options.databaseUrl)}`;
@@ -5861,7 +5863,7 @@ function dexieCloud(dexie) {
5861
5863
  db.getSchema(),
5862
5864
  db.getPersistedSyncState(),
5863
5865
  ]);
5864
- if (!options) {
5866
+ if (!configuredProgramatically) {
5865
5867
  // Options not specified programatically (use case for SW!)
5866
5868
  // Take persisted options:
5867
5869
  db.cloud.options = persistedOptions || null;
@@ -5869,6 +5871,8 @@ function dexieCloud(dexie) {
5869
5871
  else if (!persistedOptions ||
5870
5872
  JSON.stringify(persistedOptions) !== JSON.stringify(options)) {
5871
5873
  // Update persisted options:
5874
+ if (!options)
5875
+ throw new Error(`Internal error`); // options cannot be null if configuredProgramatically is set.
5872
5876
  await db.$syncState.put(options, 'options');
5873
5877
  }
5874
5878
  if (db.cloud.options?.tryUseServiceWorker &&
@@ -5990,7 +5994,7 @@ function dexieCloud(dexie) {
5990
5994
  }
5991
5995
  }
5992
5996
  }
5993
- dexieCloud.version = '4.0.0-beta.14';
5997
+ dexieCloud.version = '4.0.0-beta.15';
5994
5998
  Dexie.Cloud = dexieCloud;
5995
5999
 
5996
6000
  export { dexieCloud as default, dexieCloud, getTiedObjectId, getTiedRealmId };