dexie-cloud-addon 4.0.1-beta.31 → 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.
@@ -148,7 +148,8 @@ try {
148
148
  catch (_a) { }
149
149
 
150
150
  const swHolder = {};
151
- const swContainer = typeof self !== undefined && self.document && navigator.serviceWorker; // self.document is to verify we're not the SW ourself
151
+ const swContainer = typeof self !== 'undefined' && self.document && // self.document is to verify we're not the SW ourself
152
+ typeof navigator !== 'undefined' && navigator.serviceWorker;
152
153
  if (swContainer)
153
154
  swContainer.ready.then((registration) => (swHolder.registration = registration));
154
155
  if (typeof self !== 'undefined' && 'clients' in self && !self.document) {
@@ -160,6 +161,12 @@ if (typeof self !== 'undefined' && 'clients' in self && !self.document) {
160
161
  }
161
162
  });
162
163
  }
164
+ /** This class is a fallback for browsers that lacks BroadcastChannel but have
165
+ * service workers (which is Safari versions 11.1 through 15.3).
166
+ * Safari 15.4 with BroadcastChannel was released on 2022-03-14.
167
+ * We might be able to remove this class in a near future as Safari < 15.4 is
168
+ * already very low in market share as of 2023-03-10.
169
+ */
163
170
  class SWBroadcastChannel {
164
171
  constructor(name) {
165
172
  this.name = name;
@@ -1929,8 +1936,22 @@ function listClientChanges(mutationTables, db, { since = {}, limit = Infinity }
1929
1936
 
1930
1937
  function randomString$1(bytes) {
1931
1938
  const buf = new Uint8Array(bytes);
1932
- crypto.getRandomValues(buf);
1933
- return btoa(String.fromCharCode.apply(null, buf));
1939
+ if (typeof crypto !== 'undefined') {
1940
+ crypto.getRandomValues(buf);
1941
+ }
1942
+ else {
1943
+ for (let i = 0; i < bytes; i++)
1944
+ buf[i] = Math.floor(Math.random() * 256);
1945
+ }
1946
+ if (typeof Buffer !== 'undefined' && Buffer.from) {
1947
+ return Buffer.from(buf).toString('base64');
1948
+ }
1949
+ else if (typeof btoa !== 'undefined') {
1950
+ return btoa(String.fromCharCode.apply(null, buf));
1951
+ }
1952
+ else {
1953
+ throw new Error('No btoa or Buffer available');
1954
+ }
1934
1955
  }
1935
1956
 
1936
1957
  function assert(b) {
@@ -3221,9 +3242,12 @@ function throwIfCancelled(cancelToken) {
3221
3242
  This function relies initially on navigator.onLine but then uses online and offline events
3222
3243
  which seem to be more reliable.
3223
3244
  */
3224
- let isOnline = navigator.onLine;
3225
- self.addEventListener('online', () => isOnline = true);
3226
- self.addEventListener('offline', () => isOnline = false);
3245
+ let isOnline = false;
3246
+ if (typeof self !== 'undefined' && typeof navigator !== 'undefined') {
3247
+ isOnline = navigator.onLine;
3248
+ self.addEventListener('online', () => isOnline = true);
3249
+ self.addEventListener('offline', () => isOnline = false);
3250
+ }
3227
3251
 
3228
3252
  function updateBaseRevs(db, schema, latestRevisions, serverRev) {
3229
3253
  return __awaiter(this, void 0, void 0, function* () {
@@ -5913,7 +5937,7 @@ function dexieCloud(dexie) {
5913
5937
  currentUserEmitter.next(UNAUTHORIZED_USER);
5914
5938
  });
5915
5939
  dexie.cloud = {
5916
- version: '4.0.1-beta.31',
5940
+ version: '4.0.1-beta.32',
5917
5941
  options: Object.assign({}, DEFAULT_OPTIONS),
5918
5942
  schema: null,
5919
5943
  get currentUserId() {
@@ -6168,7 +6192,7 @@ function dexieCloud(dexie) {
6168
6192
  });
6169
6193
  }
6170
6194
  }
6171
- dexieCloud.version = '4.0.1-beta.31';
6195
+ dexieCloud.version = '4.0.1-beta.32';
6172
6196
  Dexie.Cloud = dexieCloud;
6173
6197
 
6174
6198
  // In case the SW lives for a while, let it reuse already opened connections: