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.
@@ -5708,6 +5708,7 @@
5708
5708
  //
5709
5709
  const currentUserEmitter = getCurrentUserEmitter(dexie);
5710
5710
  const subscriptions = [];
5711
+ let configuredProgramatically = false;
5711
5712
  // local sync worker - used when there's no service worker.
5712
5713
  let localSyncWorker = null;
5713
5714
  dexie.on('ready', async (dexie) => {
@@ -5734,7 +5735,7 @@
5734
5735
  currentUserEmitter.next(UNAUTHORIZED_USER);
5735
5736
  });
5736
5737
  dexie.cloud = {
5737
- version: '4.0.0-beta.14',
5738
+ version: '4.0.0-beta.15',
5738
5739
  options: { ...DEFAULT_OPTIONS },
5739
5740
  schema: null,
5740
5741
  serverState: null,
@@ -5757,6 +5758,7 @@
5757
5758
  invites: getInvitesObservable(dexie),
5758
5759
  configure(options) {
5759
5760
  options = dexie.cloud.options = { ...dexie.cloud.options, ...options };
5761
+ configuredProgramatically = true;
5760
5762
  if (options.databaseUrl && options.nameSuffix) {
5761
5763
  // @ts-ignore
5762
5764
  dexie.name = `${origIdbName}-${getDbNameFromDbUrl(options.databaseUrl)}`;
@@ -5843,7 +5845,7 @@
5843
5845
  db.getSchema(),
5844
5846
  db.getPersistedSyncState(),
5845
5847
  ]);
5846
- if (!options) {
5848
+ if (!configuredProgramatically) {
5847
5849
  // Options not specified programatically (use case for SW!)
5848
5850
  // Take persisted options:
5849
5851
  db.cloud.options = persistedOptions || null;
@@ -5851,6 +5853,8 @@
5851
5853
  else if (!persistedOptions ||
5852
5854
  JSON.stringify(persistedOptions) !== JSON.stringify(options)) {
5853
5855
  // Update persisted options:
5856
+ if (!options)
5857
+ throw new Error(`Internal error`); // options cannot be null if configuredProgramatically is set.
5854
5858
  await db.$syncState.put(options, 'options');
5855
5859
  }
5856
5860
  if (db.cloud.options?.tryUseServiceWorker &&
@@ -5972,7 +5976,7 @@
5972
5976
  }
5973
5977
  }
5974
5978
  }
5975
- dexieCloud.version = '4.0.0-beta.14';
5979
+ dexieCloud.version = '4.0.0-beta.15';
5976
5980
  Dexie__default["default"].Cloud = dexieCloud;
5977
5981
 
5978
5982
  // In case the SW lives for a while, let it reuse already opened connections: