dexie-cloud-addon 4.0.1-beta.31 → 4.0.1-beta.33

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.
@@ -2539,7 +2539,8 @@
2539
2539
  catch (_a) { }
2540
2540
 
2541
2541
  const swHolder = {};
2542
- const swContainer = typeof self !== undefined && self.document && navigator.serviceWorker; // self.document is to verify we're not the SW ourself
2542
+ const swContainer = typeof self !== 'undefined' && self.document && // self.document is to verify we're not the SW ourself
2543
+ typeof navigator !== 'undefined' && navigator.serviceWorker;
2543
2544
  if (swContainer)
2544
2545
  swContainer.ready.then((registration) => (swHolder.registration = registration));
2545
2546
  if (typeof self !== 'undefined' && 'clients' in self && !self.document) {
@@ -2551,6 +2552,12 @@
2551
2552
  }
2552
2553
  });
2553
2554
  }
2555
+ /** This class is a fallback for browsers that lacks BroadcastChannel but have
2556
+ * service workers (which is Safari versions 11.1 through 15.3).
2557
+ * Safari 15.4 with BroadcastChannel was released on 2022-03-14.
2558
+ * We might be able to remove this class in a near future as Safari < 15.4 is
2559
+ * already very low in market share as of 2023-03-10.
2560
+ */
2554
2561
  class SWBroadcastChannel {
2555
2562
  constructor(name) {
2556
2563
  this.name = name;
@@ -2715,8 +2722,22 @@
2715
2722
 
2716
2723
  function randomString(bytes) {
2717
2724
  const buf = new Uint8Array(bytes);
2718
- crypto.getRandomValues(buf);
2719
- return btoa(String.fromCharCode.apply(null, buf));
2725
+ if (typeof crypto !== 'undefined') {
2726
+ crypto.getRandomValues(buf);
2727
+ }
2728
+ else {
2729
+ for (let i = 0; i < bytes; i++)
2730
+ buf[i] = Math.floor(Math.random() * 256);
2731
+ }
2732
+ if (typeof Buffer !== 'undefined' && Buffer.from) {
2733
+ return Buffer.from(buf).toString('base64');
2734
+ }
2735
+ else if (typeof btoa !== 'undefined') {
2736
+ return btoa(String.fromCharCode.apply(null, buf));
2737
+ }
2738
+ else {
2739
+ throw new Error('No btoa or Buffer available');
2740
+ }
2720
2741
  }
2721
2742
 
2722
2743
  function listSyncifiedChanges(tablesToSyncify, currentUser, schema, alreadySyncedRealms) {
@@ -3461,9 +3482,12 @@
3461
3482
  This function relies initially on navigator.onLine but then uses online and offline events
3462
3483
  which seem to be more reliable.
3463
3484
  */
3464
- let isOnline = navigator.onLine;
3465
- self.addEventListener('online', () => isOnline = true);
3466
- self.addEventListener('offline', () => isOnline = false);
3485
+ let isOnline = false;
3486
+ if (typeof self !== 'undefined' && typeof navigator !== 'undefined') {
3487
+ isOnline = navigator.onLine;
3488
+ self.addEventListener('online', () => isOnline = true);
3489
+ self.addEventListener('offline', () => isOnline = false);
3490
+ }
3467
3491
 
3468
3492
  function updateBaseRevs(db, schema, latestRevisions, serverRev) {
3469
3493
  return __awaiter(this, void 0, void 0, function* () {