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.
@@ -5701,6 +5701,7 @@ function dexieCloud(dexie) {
5701
5701
  //
5702
5702
  const currentUserEmitter = getCurrentUserEmitter(dexie);
5703
5703
  const subscriptions = [];
5704
+ let configuredProgramatically = false;
5704
5705
  // local sync worker - used when there's no service worker.
5705
5706
  let localSyncWorker = null;
5706
5707
  dexie.on('ready', async (dexie) => {
@@ -5727,7 +5728,7 @@ function dexieCloud(dexie) {
5727
5728
  currentUserEmitter.next(UNAUTHORIZED_USER);
5728
5729
  });
5729
5730
  dexie.cloud = {
5730
- version: '4.0.0-beta.14',
5731
+ version: '4.0.0-beta.15',
5731
5732
  options: { ...DEFAULT_OPTIONS },
5732
5733
  schema: null,
5733
5734
  serverState: null,
@@ -5750,6 +5751,7 @@ function dexieCloud(dexie) {
5750
5751
  invites: getInvitesObservable(dexie),
5751
5752
  configure(options) {
5752
5753
  options = dexie.cloud.options = { ...dexie.cloud.options, ...options };
5754
+ configuredProgramatically = true;
5753
5755
  if (options.databaseUrl && options.nameSuffix) {
5754
5756
  // @ts-ignore
5755
5757
  dexie.name = `${origIdbName}-${getDbNameFromDbUrl(options.databaseUrl)}`;
@@ -5836,7 +5838,7 @@ function dexieCloud(dexie) {
5836
5838
  db.getSchema(),
5837
5839
  db.getPersistedSyncState(),
5838
5840
  ]);
5839
- if (!options) {
5841
+ if (!configuredProgramatically) {
5840
5842
  // Options not specified programatically (use case for SW!)
5841
5843
  // Take persisted options:
5842
5844
  db.cloud.options = persistedOptions || null;
@@ -5844,6 +5846,8 @@ function dexieCloud(dexie) {
5844
5846
  else if (!persistedOptions ||
5845
5847
  JSON.stringify(persistedOptions) !== JSON.stringify(options)) {
5846
5848
  // Update persisted options:
5849
+ if (!options)
5850
+ throw new Error(`Internal error`); // options cannot be null if configuredProgramatically is set.
5847
5851
  await db.$syncState.put(options, 'options');
5848
5852
  }
5849
5853
  if (db.cloud.options?.tryUseServiceWorker &&
@@ -5965,7 +5969,7 @@ function dexieCloud(dexie) {
5965
5969
  }
5966
5970
  }
5967
5971
  }
5968
- dexieCloud.version = '4.0.0-beta.14';
5972
+ dexieCloud.version = '4.0.0-beta.15';
5969
5973
  Dexie.Cloud = dexieCloud;
5970
5974
 
5971
5975
  // In case the SW lives for a while, let it reuse already opened connections: