dexie-cloud-addon 4.0.1-beta.30 → 4.0.1-beta.32

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.
@@ -101,7 +101,7 @@ function __spreadArray$1(to, from, pack) {
101
101
  *
102
102
  * ==========================================================================
103
103
  *
104
- * Version 4.0.1-beta.30, Thu Mar 09 2023
104
+ * Version 4.0.1-beta.32, Fri Mar 10 2023
105
105
  *
106
106
  * https://dexie.org
107
107
  *
@@ -2768,7 +2768,8 @@ try {
2768
2768
  }
2769
2769
  catch (_a) { }
2770
2770
  var swHolder = {};
2771
- var swContainer = self.document && navigator.serviceWorker; // self.document is to verify we're not the SW ourself
2771
+ var swContainer = typeof self !== 'undefined' && self.document && // self.document is to verify we're not the SW ourself
2772
+ typeof navigator !== 'undefined' && navigator.serviceWorker;
2772
2773
  if (swContainer)
2773
2774
  swContainer.ready.then(function (registration) { return (swHolder.registration = registration); });
2774
2775
  if (typeof self !== 'undefined' && 'clients' in self && !self.document) {
@@ -2780,6 +2781,12 @@ if (typeof self !== 'undefined' && 'clients' in self && !self.document) {
2780
2781
  }
2781
2782
  });
2782
2783
  }
2784
+ /** This class is a fallback for browsers that lacks BroadcastChannel but have
2785
+ * service workers (which is Safari versions 11.1 through 15.3).
2786
+ * Safari 15.4 with BroadcastChannel was released on 2022-03-14.
2787
+ * We might be able to remove this class in a near future as Safari < 15.4 is
2788
+ * already very low in market share as of 2023-03-10.
2789
+ */
2783
2790
  var SWBroadcastChannel = /** @class */ (function () {
2784
2791
  function SWBroadcastChannel(name) {
2785
2792
  this.name = name;
@@ -2804,7 +2811,7 @@ var SWBroadcastChannel = /** @class */ (function () {
2804
2811
  // We're a service worker. Propagate to our browser clients.
2805
2812
  __spreadArray$1([], self['clients'].matchAll({ includeUncontrolled: true }), true).forEach(function (client) { return client.postMessage({
2806
2813
  type: "sw-broadcast-".concat(_this_1.name),
2807
- message: message
2814
+ message: message,
2808
2815
  }); });
2809
2816
  }
2810
2817
  else if (swHolder.registration) {
@@ -2812,7 +2819,7 @@ var SWBroadcastChannel = /** @class */ (function () {
2812
2819
  // Post to SW so it can repost to all its clients and to itself
2813
2820
  (_a = swHolder.registration.active) === null || _a === void 0 ? void 0 : _a.postMessage({
2814
2821
  type: "sw-broadcast-".concat(this.name),
2815
- message: message
2822
+ message: message,
2816
2823
  });
2817
2824
  }
2818
2825
  };
@@ -2975,8 +2982,22 @@ function listClientChanges(mutationTables, db, _k) {
2975
2982
  }
2976
2983
  function randomString(bytes) {
2977
2984
  var buf = new Uint8Array(bytes);
2978
- crypto.getRandomValues(buf);
2979
- return btoa(String.fromCharCode.apply(null, buf));
2985
+ if (typeof crypto !== 'undefined') {
2986
+ crypto.getRandomValues(buf);
2987
+ }
2988
+ else {
2989
+ for (var i_2 = 0; i_2 < bytes; i_2++)
2990
+ buf[i_2] = Math.floor(Math.random() * 256);
2991
+ }
2992
+ if (typeof Buffer !== 'undefined' && Buffer.from) {
2993
+ return Buffer.from(buf).toString('base64');
2994
+ }
2995
+ else if (typeof btoa !== 'undefined') {
2996
+ return btoa(String.fromCharCode.apply(null, buf));
2997
+ }
2998
+ else {
2999
+ throw new Error('No btoa or Buffer available');
3000
+ }
2980
3001
  }
2981
3002
  function listSyncifiedChanges(tablesToSyncify, currentUser, schema, alreadySyncedRealms) {
2982
3003
  return __awaiter(this, void 0, void 0, function () {
@@ -3057,10 +3078,10 @@ function getToStringTag(val) {
3057
3078
  function escapeDollarProps(value) {
3058
3079
  var keys = Object.keys(value);
3059
3080
  var dollarKeys = null;
3060
- for (var i_2 = 0, l_1 = keys.length; i_2 < l_1; ++i_2) {
3061
- if (keys[i_2][0] === "$") {
3081
+ for (var i_3 = 0, l_1 = keys.length; i_3 < l_1; ++i_3) {
3082
+ if (keys[i_3][0] === "$") {
3062
3083
  dollarKeys = dollarKeys || [];
3063
- dollarKeys.push(keys[i_2]);
3084
+ dollarKeys.push(keys[i_3]);
3064
3085
  }
3065
3086
  }
3066
3087
  if (!dollarKeys)
@@ -3448,8 +3469,8 @@ function readBlobSync(b) {
3448
3469
  }
3449
3470
  function string2ArrayBuffer(str) {
3450
3471
  var array = new Uint8Array(str.length);
3451
- for (var i_3 = 0; i_3 < str.length; ++i_3) {
3452
- array[i_3] = str.charCodeAt(i_3); // & 0xff;
3472
+ for (var i_4 = 0; i_4 < str.length; ++i_4) {
3473
+ array[i_4] = str.charCodeAt(i_4); // & 0xff;
3453
3474
  }
3454
3475
  return array.buffer;
3455
3476
  }
@@ -3807,9 +3828,12 @@ function throwIfCancelled(cancelToken) {
3807
3828
  This function relies initially on navigator.onLine but then uses online and offline events
3808
3829
  which seem to be more reliable.
3809
3830
  */
3810
- var isOnline = navigator.onLine;
3811
- self.addEventListener('online', function () { return isOnline = true; });
3812
- self.addEventListener('offline', function () { return isOnline = false; });
3831
+ var isOnline = false;
3832
+ if (typeof self !== 'undefined' && typeof navigator !== 'undefined') {
3833
+ isOnline = navigator.onLine;
3834
+ self.addEventListener('online', function () { return isOnline = true; });
3835
+ self.addEventListener('offline', function () { return isOnline = false; });
3836
+ }
3813
3837
  function updateBaseRevs(db, schema, latestRevisions, serverRev) {
3814
3838
  return __awaiter(this, void 0, void 0, function () {
3815
3839
  return __generator$1(this, function (_k) {
@@ -4875,9 +4899,9 @@ function isUpperCase(ch) {
4875
4899
  }
4876
4900
  function generateTablePrefix(tableName, allPrefixes) {
4877
4901
  var rv = tableName[0].toLocaleLowerCase(); // "users" = "usr", "friends" = "frn", "realms" = "rlm", etc.
4878
- for (var i_4 = 1, l_2 = tableName.length; i_4 < l_2 && rv.length < 3; ++i_4) {
4879
- if (consonants.test(tableName[i_4]) || isUpperCase(tableName[i_4]))
4880
- rv += tableName[i_4].toLowerCase();
4902
+ for (var i_5 = 1, l_2 = tableName.length; i_5 < l_2 && rv.length < 3; ++i_5) {
4903
+ if (consonants.test(tableName[i_5]) || isUpperCase(tableName[i_5]))
4904
+ rv += tableName[i_5].toLowerCase();
4881
4905
  }
4882
4906
  while (allPrefixes.has(rv)) {
4883
4907
  if (/\d/g.test(rv)) {
@@ -6936,7 +6960,7 @@ function dexieCloud(dexie) {
6936
6960
  currentUserEmitter.next(UNAUTHORIZED_USER);
6937
6961
  });
6938
6962
  dexie.cloud = {
6939
- version: '4.0.1-beta.30',
6963
+ version: '4.0.1-beta.32',
6940
6964
  options: Object.assign({}, DEFAULT_OPTIONS),
6941
6965
  schema: null,
6942
6966
  get currentUserId() {
@@ -7269,7 +7293,7 @@ function dexieCloud(dexie) {
7269
7293
  });
7270
7294
  }
7271
7295
  }
7272
- dexieCloud.version = '4.0.1-beta.30';
7296
+ dexieCloud.version = '4.0.1-beta.32';
7273
7297
  Dexie.Cloud = dexieCloud;
7274
7298
 
7275
7299
  export { dexieCloud as default, dexieCloud, getTiedObjectId, getTiedRealmId };