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

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.
@@ -108,7 +108,7 @@
108
108
  *
109
109
  * ==========================================================================
110
110
  *
111
- * Version 4.0.1-beta.28, Mon Mar 06 2023
111
+ * Version 4.0.1-beta.31, Thu Mar 09 2023
112
112
  *
113
113
  * https://dexie.org
114
114
  *
@@ -312,8 +312,6 @@
312
312
  function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
313
313
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
314
314
  }
315
- //@ts-check
316
- var randomFillSync = crypto.getRandomValues.bind(crypto);
317
315
  function assert(b) {
318
316
  if (!b)
319
317
  throw new Error('Assertion Failed');
@@ -374,17 +372,24 @@
374
372
  }
375
373
  }
376
374
  }
377
- var randomString$1 = typeof self !== 'undefined' && typeof crypto !== 'undefined' ? function (bytes) {
375
+ var randomString$1 = typeof self !== 'undefined' && typeof crypto !== 'undefined' ? function (bytes, randomFill) {
376
+ if (randomFill === void 0) { randomFill = crypto.getRandomValues.bind(crypto); }
378
377
  // Web
379
378
  var buf = new Uint8Array(bytes);
380
- crypto.getRandomValues(buf);
381
- return btoa(String.fromCharCode.apply(null, buf));
382
- } : typeof Buffer !== 'undefined' ? function (bytes) {
379
+ randomFill(buf);
380
+ return self.btoa(String.fromCharCode.apply(null, buf));
381
+ } : typeof Buffer !== 'undefined' ? function (bytes, randomFill) {
382
+ if (randomFill === void 0) { randomFill = simpleRandomFill; }
383
383
  // Node
384
384
  var buf = Buffer.alloc(bytes);
385
- randomFillSync(buf);
385
+ randomFill(buf);
386
386
  return buf.toString("base64");
387
387
  } : function () { throw new Error("No implementation of randomString was found"); };
388
+ function simpleRandomFill(buf) {
389
+ for (var i_1 = 0; i_1 < buf.length; ++i_1) {
390
+ buf[i_1] = Math.floor(Math.random() * 256);
391
+ }
392
+ }
388
393
  /** Verifies that given primary key is valid.
389
394
  * The reason we narrow validity for valid keys are twofold:
390
395
  * 1: Make sure to only support types that can be used as an object index in DBKeyMutationSet.
@@ -550,9 +555,11 @@
550
555
  * @param inSet
551
556
  * @returns DBOperationsSet representing inSet
552
557
  */
553
- function toDBOperationSet(inSet) {
558
+ function toDBOperationSet(inSet, txid) {
559
+ if (txid === void 0) { txid = ""; }
554
560
  // Fictive transaction:
555
- var txid = randomString$1(16);
561
+ if (!txid)
562
+ txid = randomString$1(16);
556
563
  // Convert data into a temporary map to collect mutations of same table and type
557
564
  var map = {};
558
565
  for (var _k = 0, _l = Object.entries(inSet); _k < _l.length; _k++) {
@@ -2768,7 +2775,7 @@
2768
2775
  }
2769
2776
  catch (_a) { }
2770
2777
  var swHolder = {};
2771
- 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 && navigator.serviceWorker; // self.document is to verify we're not the SW ourself
2772
2779
  if (swContainer)
2773
2780
  swContainer.ready.then(function (registration) { return (swHolder.registration = registration); });
2774
2781
  if (typeof self !== 'undefined' && 'clients' in self && !self.document) {
@@ -2804,7 +2811,7 @@
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 @@
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
  };
@@ -3057,10 +3064,10 @@
3057
3064
  function escapeDollarProps(value) {
3058
3065
  var keys = Object.keys(value);
3059
3066
  var dollarKeys = null;
3060
- for (var i_1 = 0, l_1 = keys.length; i_1 < l_1; ++i_1) {
3061
- if (keys[i_1][0] === "$") {
3067
+ for (var i_2 = 0, l_1 = keys.length; i_2 < l_1; ++i_2) {
3068
+ if (keys[i_2][0] === "$") {
3062
3069
  dollarKeys = dollarKeys || [];
3063
- dollarKeys.push(keys[i_1]);
3070
+ dollarKeys.push(keys[i_2]);
3064
3071
  }
3065
3072
  }
3066
3073
  if (!dollarKeys)
@@ -3448,8 +3455,8 @@
3448
3455
  }
3449
3456
  function string2ArrayBuffer(str) {
3450
3457
  var array = new Uint8Array(str.length);
3451
- for (var i_2 = 0; i_2 < str.length; ++i_2) {
3452
- array[i_2] = str.charCodeAt(i_2); // & 0xff;
3458
+ for (var i_3 = 0; i_3 < str.length; ++i_3) {
3459
+ array[i_3] = str.charCodeAt(i_3); // & 0xff;
3453
3460
  }
3454
3461
  return array.buffer;
3455
3462
  }
@@ -4875,9 +4882,9 @@
4875
4882
  }
4876
4883
  function generateTablePrefix(tableName, allPrefixes) {
4877
4884
  var rv = tableName[0].toLocaleLowerCase(); // "users" = "usr", "friends" = "frn", "realms" = "rlm", etc.
4878
- for (var i_3 = 1, l_2 = tableName.length; i_3 < l_2 && rv.length < 3; ++i_3) {
4879
- if (consonants.test(tableName[i_3]) || isUpperCase(tableName[i_3]))
4880
- rv += tableName[i_3].toLowerCase();
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();
4881
4888
  }
4882
4889
  while (allPrefixes.has(rv)) {
4883
4890
  if (/\d/g.test(rv)) {
@@ -6936,7 +6943,7 @@
6936
6943
  currentUserEmitter.next(UNAUTHORIZED_USER);
6937
6944
  });
6938
6945
  dexie.cloud = {
6939
- version: '4.0.1-beta.28',
6946
+ version: '4.0.1-beta.31',
6940
6947
  options: Object.assign({}, DEFAULT_OPTIONS),
6941
6948
  schema: null,
6942
6949
  get currentUserId() {
@@ -7269,7 +7276,7 @@
7269
7276
  });
7270
7277
  }
7271
7278
  }
7272
- dexieCloud.version = '4.0.1-beta.28';
7279
+ dexieCloud.version = '4.0.1-beta.31';
7273
7280
  Dexie__default["default"].Cloud = dexieCloud;
7274
7281
 
7275
7282
  exports["default"] = dexieCloud;