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.
@@ -1,3 +1,9 @@
1
+ /** This class is a fallback for browsers that lacks BroadcastChannel but have
2
+ * service workers (which is Safari versions 11.1 through 15.3).
3
+ * Safari 15.4 with BroadcastChannel was released on 2022-03-14.
4
+ * We might be able to remove this class in a near future as Safari < 15.4 is
5
+ * already very low in market share as of 2023-03-10.
6
+ */
1
7
  export declare class SWBroadcastChannel {
2
8
  name: string;
3
9
  constructor(name: string);
@@ -108,7 +108,7 @@
108
108
  *
109
109
  * ==========================================================================
110
110
  *
111
- * Version 4.0.1-beta.30, Thu Mar 09 2023
111
+ * Version 4.0.1-beta.32, Fri Mar 10 2023
112
112
  *
113
113
  * https://dexie.org
114
114
  *
@@ -2775,7 +2775,8 @@
2775
2775
  }
2776
2776
  catch (_a) { }
2777
2777
  var swHolder = {};
2778
- var swContainer = self.document && navigator.serviceWorker; // self.document is to verify we're not the SW ourself
2778
+ var swContainer = typeof self !== 'undefined' && self.document && // self.document is to verify we're not the SW ourself
2779
+ typeof navigator !== 'undefined' && navigator.serviceWorker;
2779
2780
  if (swContainer)
2780
2781
  swContainer.ready.then(function (registration) { return (swHolder.registration = registration); });
2781
2782
  if (typeof self !== 'undefined' && 'clients' in self && !self.document) {
@@ -2787,6 +2788,12 @@
2787
2788
  }
2788
2789
  });
2789
2790
  }
2791
+ /** This class is a fallback for browsers that lacks BroadcastChannel but have
2792
+ * service workers (which is Safari versions 11.1 through 15.3).
2793
+ * Safari 15.4 with BroadcastChannel was released on 2022-03-14.
2794
+ * We might be able to remove this class in a near future as Safari < 15.4 is
2795
+ * already very low in market share as of 2023-03-10.
2796
+ */
2790
2797
  var SWBroadcastChannel = /** @class */ (function () {
2791
2798
  function SWBroadcastChannel(name) {
2792
2799
  this.name = name;
@@ -2811,7 +2818,7 @@
2811
2818
  // We're a service worker. Propagate to our browser clients.
2812
2819
  __spreadArray$1([], self['clients'].matchAll({ includeUncontrolled: true }), true).forEach(function (client) { return client.postMessage({
2813
2820
  type: "sw-broadcast-".concat(_this_1.name),
2814
- message: message
2821
+ message: message,
2815
2822
  }); });
2816
2823
  }
2817
2824
  else if (swHolder.registration) {
@@ -2819,7 +2826,7 @@
2819
2826
  // Post to SW so it can repost to all its clients and to itself
2820
2827
  (_a = swHolder.registration.active) === null || _a === void 0 ? void 0 : _a.postMessage({
2821
2828
  type: "sw-broadcast-".concat(this.name),
2822
- message: message
2829
+ message: message,
2823
2830
  });
2824
2831
  }
2825
2832
  };
@@ -2982,8 +2989,22 @@
2982
2989
  }
2983
2990
  function randomString(bytes) {
2984
2991
  var buf = new Uint8Array(bytes);
2985
- crypto.getRandomValues(buf);
2986
- return btoa(String.fromCharCode.apply(null, buf));
2992
+ if (typeof crypto !== 'undefined') {
2993
+ crypto.getRandomValues(buf);
2994
+ }
2995
+ else {
2996
+ for (var i_2 = 0; i_2 < bytes; i_2++)
2997
+ buf[i_2] = Math.floor(Math.random() * 256);
2998
+ }
2999
+ if (typeof Buffer !== 'undefined' && Buffer.from) {
3000
+ return Buffer.from(buf).toString('base64');
3001
+ }
3002
+ else if (typeof btoa !== 'undefined') {
3003
+ return btoa(String.fromCharCode.apply(null, buf));
3004
+ }
3005
+ else {
3006
+ throw new Error('No btoa or Buffer available');
3007
+ }
2987
3008
  }
2988
3009
  function listSyncifiedChanges(tablesToSyncify, currentUser, schema, alreadySyncedRealms) {
2989
3010
  return __awaiter(this, void 0, void 0, function () {
@@ -3064,10 +3085,10 @@
3064
3085
  function escapeDollarProps(value) {
3065
3086
  var keys = Object.keys(value);
3066
3087
  var dollarKeys = null;
3067
- for (var i_2 = 0, l_1 = keys.length; i_2 < l_1; ++i_2) {
3068
- if (keys[i_2][0] === "$") {
3088
+ for (var i_3 = 0, l_1 = keys.length; i_3 < l_1; ++i_3) {
3089
+ if (keys[i_3][0] === "$") {
3069
3090
  dollarKeys = dollarKeys || [];
3070
- dollarKeys.push(keys[i_2]);
3091
+ dollarKeys.push(keys[i_3]);
3071
3092
  }
3072
3093
  }
3073
3094
  if (!dollarKeys)
@@ -3455,8 +3476,8 @@
3455
3476
  }
3456
3477
  function string2ArrayBuffer(str) {
3457
3478
  var array = new Uint8Array(str.length);
3458
- for (var i_3 = 0; i_3 < str.length; ++i_3) {
3459
- array[i_3] = str.charCodeAt(i_3); // & 0xff;
3479
+ for (var i_4 = 0; i_4 < str.length; ++i_4) {
3480
+ array[i_4] = str.charCodeAt(i_4); // & 0xff;
3460
3481
  }
3461
3482
  return array.buffer;
3462
3483
  }
@@ -3814,9 +3835,12 @@
3814
3835
  This function relies initially on navigator.onLine but then uses online and offline events
3815
3836
  which seem to be more reliable.
3816
3837
  */
3817
- var isOnline = navigator.onLine;
3818
- self.addEventListener('online', function () { return isOnline = true; });
3819
- self.addEventListener('offline', function () { return isOnline = false; });
3838
+ var isOnline = false;
3839
+ if (typeof self !== 'undefined' && typeof navigator !== 'undefined') {
3840
+ isOnline = navigator.onLine;
3841
+ self.addEventListener('online', function () { return isOnline = true; });
3842
+ self.addEventListener('offline', function () { return isOnline = false; });
3843
+ }
3820
3844
  function updateBaseRevs(db, schema, latestRevisions, serverRev) {
3821
3845
  return __awaiter(this, void 0, void 0, function () {
3822
3846
  return __generator$1(this, function (_k) {
@@ -4882,9 +4906,9 @@
4882
4906
  }
4883
4907
  function generateTablePrefix(tableName, allPrefixes) {
4884
4908
  var rv = tableName[0].toLocaleLowerCase(); // "users" = "usr", "friends" = "frn", "realms" = "rlm", etc.
4885
- for (var i_4 = 1, l_2 = tableName.length; i_4 < l_2 && rv.length < 3; ++i_4) {
4886
- if (consonants.test(tableName[i_4]) || isUpperCase(tableName[i_4]))
4887
- rv += tableName[i_4].toLowerCase();
4909
+ for (var i_5 = 1, l_2 = tableName.length; i_5 < l_2 && rv.length < 3; ++i_5) {
4910
+ if (consonants.test(tableName[i_5]) || isUpperCase(tableName[i_5]))
4911
+ rv += tableName[i_5].toLowerCase();
4888
4912
  }
4889
4913
  while (allPrefixes.has(rv)) {
4890
4914
  if (/\d/g.test(rv)) {
@@ -6943,7 +6967,7 @@
6943
6967
  currentUserEmitter.next(UNAUTHORIZED_USER);
6944
6968
  });
6945
6969
  dexie.cloud = {
6946
- version: '4.0.1-beta.30',
6970
+ version: '4.0.1-beta.32',
6947
6971
  options: Object.assign({}, DEFAULT_OPTIONS),
6948
6972
  schema: null,
6949
6973
  get currentUserId() {
@@ -7276,7 +7300,7 @@
7276
7300
  });
7277
7301
  }
7278
7302
  }
7279
- dexieCloud.version = '4.0.1-beta.30';
7303
+ dexieCloud.version = '4.0.1-beta.32';
7280
7304
  Dexie__default["default"].Cloud = dexieCloud;
7281
7305
 
7282
7306
  exports["default"] = dexieCloud;