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

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.
@@ -1940,9 +1940,6 @@
1940
1940
  return btoa(String.fromCharCode.apply(null, buf));
1941
1941
  }
1942
1942
 
1943
- //@ts-check
1944
- const randomFillSync = crypto.getRandomValues.bind(crypto);
1945
-
1946
1943
  function assert(b) {
1947
1944
  if (!b)
1948
1945
  throw new Error('Assertion Failed');
@@ -2003,17 +2000,22 @@
2003
2000
  }
2004
2001
  }
2005
2002
  }
2006
- const randomString = typeof self !== 'undefined' && typeof crypto !== 'undefined' ? (bytes) => {
2003
+ const randomString = typeof self !== 'undefined' && typeof crypto !== 'undefined' ? (bytes, randomFill = crypto.getRandomValues.bind(crypto)) => {
2007
2004
  // Web
2008
2005
  const buf = new Uint8Array(bytes);
2009
- crypto.getRandomValues(buf);
2010
- return btoa(String.fromCharCode.apply(null, buf));
2011
- } : typeof Buffer !== 'undefined' ? (bytes) => {
2006
+ randomFill(buf);
2007
+ return self.btoa(String.fromCharCode.apply(null, buf));
2008
+ } : typeof Buffer !== 'undefined' ? (bytes, randomFill = simpleRandomFill) => {
2012
2009
  // Node
2013
2010
  const buf = Buffer.alloc(bytes);
2014
- randomFillSync(buf);
2011
+ randomFill(buf);
2015
2012
  return buf.toString("base64");
2016
2013
  } : () => { throw new Error("No implementation of randomString was found"); };
2014
+ function simpleRandomFill(buf) {
2015
+ for (let i = 0; i < buf.length; ++i) {
2016
+ buf[i] = Math.floor(Math.random() * 256);
2017
+ }
2018
+ }
2017
2019
 
2018
2020
  /** Verifies that given primary key is valid.
2019
2021
  * The reason we narrow validity for valid keys are twofold:
@@ -2177,9 +2179,10 @@
2177
2179
  * @param inSet
2178
2180
  * @returns DBOperationsSet representing inSet
2179
2181
  */
2180
- function toDBOperationSet(inSet) {
2182
+ function toDBOperationSet(inSet, txid = "") {
2181
2183
  // Fictive transaction:
2182
- const txid = randomString(16);
2184
+ if (!txid)
2185
+ txid = randomString(16);
2183
2186
  // Convert data into a temporary map to collect mutations of same table and type
2184
2187
  const map = {};
2185
2188
  for (const [table, ops] of Object.entries(inSet)) {
@@ -2944,7 +2947,7 @@
2944
2947
  ...MapDef,
2945
2948
  ...TypedArraysDefs,
2946
2949
  ...ArrayBufferDef,
2947
- ...BlobDef,
2950
+ ...BlobDef, // Should be moved to another preset for DOM types (or universal? since it supports node as well with FakeBlob)
2948
2951
  };
2949
2952
 
2950
2953
  function Bison(...typeDefsInputs) {
@@ -5917,7 +5920,7 @@
5917
5920
  currentUserEmitter.next(UNAUTHORIZED_USER);
5918
5921
  });
5919
5922
  dexie.cloud = {
5920
- version: '4.0.1-beta.28',
5923
+ version: '4.0.1-beta.30',
5921
5924
  options: Object.assign({}, DEFAULT_OPTIONS),
5922
5925
  schema: null,
5923
5926
  get currentUserId() {
@@ -6172,7 +6175,7 @@
6172
6175
  });
6173
6176
  }
6174
6177
  }
6175
- dexieCloud.version = '4.0.1-beta.28';
6178
+ dexieCloud.version = '4.0.1-beta.30';
6176
6179
  Dexie__default["default"].Cloud = dexieCloud;
6177
6180
 
6178
6181
  // In case the SW lives for a while, let it reuse already opened connections: