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.
@@ -5733,6 +5733,7 @@
5733
5733
  //
5734
5734
  const currentUserEmitter = getCurrentUserEmitter(dexie);
5735
5735
  const subscriptions = [];
5736
+ let configuredProgramatically = false;
5736
5737
  // local sync worker - used when there's no service worker.
5737
5738
  let localSyncWorker = null;
5738
5739
  dexie.on('ready', async (dexie) => {
@@ -5782,6 +5783,7 @@
5782
5783
  invites: getInvitesObservable(dexie),
5783
5784
  configure(options) {
5784
5785
  options = dexie.cloud.options = { ...dexie.cloud.options, ...options };
5786
+ configuredProgramatically = true;
5785
5787
  if (options.databaseUrl && options.nameSuffix) {
5786
5788
  // @ts-ignore
5787
5789
  dexie.name = `${origIdbName}-${getDbNameFromDbUrl(options.databaseUrl)}`;
@@ -5868,7 +5870,7 @@
5868
5870
  db.getSchema(),
5869
5871
  db.getPersistedSyncState(),
5870
5872
  ]);
5871
- if (!options) {
5873
+ if (!configuredProgramatically) {
5872
5874
  // Options not specified programatically (use case for SW!)
5873
5875
  // Take persisted options:
5874
5876
  db.cloud.options = persistedOptions || null;
@@ -5876,6 +5878,8 @@
5876
5878
  else if (!persistedOptions ||
5877
5879
  JSON.stringify(persistedOptions) !== JSON.stringify(options)) {
5878
5880
  // Update persisted options:
5881
+ if (!options)
5882
+ throw new Error(`Internal error`); // options cannot be null if configuredProgramatically is set.
5879
5883
  await db.$syncState.put(options, 'options');
5880
5884
  }
5881
5885
  if (db.cloud.options?.tryUseServiceWorker &&