dexie-cloud-addon 4.0.1-beta.27 → 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.
@@ -1933,9 +1933,6 @@ function randomString$1(bytes) {
1933
1933
  return btoa(String.fromCharCode.apply(null, buf));
1934
1934
  }
1935
1935
 
1936
- //@ts-check
1937
- const randomFillSync = crypto.getRandomValues.bind(crypto);
1938
-
1939
1936
  function assert(b) {
1940
1937
  if (!b)
1941
1938
  throw new Error('Assertion Failed');
@@ -1996,17 +1993,22 @@ function setByKeyPath(obj, keyPath, value) {
1996
1993
  }
1997
1994
  }
1998
1995
  }
1999
- const randomString = typeof self !== 'undefined' && typeof crypto !== 'undefined' ? (bytes) => {
1996
+ const randomString = typeof self !== 'undefined' && typeof crypto !== 'undefined' ? (bytes, randomFill = crypto.getRandomValues.bind(crypto)) => {
2000
1997
  // Web
2001
1998
  const buf = new Uint8Array(bytes);
2002
- crypto.getRandomValues(buf);
2003
- return btoa(String.fromCharCode.apply(null, buf));
2004
- } : typeof Buffer !== 'undefined' ? (bytes) => {
1999
+ randomFill(buf);
2000
+ return self.btoa(String.fromCharCode.apply(null, buf));
2001
+ } : typeof Buffer !== 'undefined' ? (bytes, randomFill = simpleRandomFill) => {
2005
2002
  // Node
2006
2003
  const buf = Buffer.alloc(bytes);
2007
- randomFillSync(buf);
2004
+ randomFill(buf);
2008
2005
  return buf.toString("base64");
2009
2006
  } : () => { throw new Error("No implementation of randomString was found"); };
2007
+ function simpleRandomFill(buf) {
2008
+ for (let i = 0; i < buf.length; ++i) {
2009
+ buf[i] = Math.floor(Math.random() * 256);
2010
+ }
2011
+ }
2010
2012
 
2011
2013
  /** Verifies that given primary key is valid.
2012
2014
  * The reason we narrow validity for valid keys are twofold:
@@ -2170,9 +2172,10 @@ changesToSubtract // additional mutations on client during syncWithServer()
2170
2172
  * @param inSet
2171
2173
  * @returns DBOperationsSet representing inSet
2172
2174
  */
2173
- function toDBOperationSet(inSet) {
2175
+ function toDBOperationSet(inSet, txid = "") {
2174
2176
  // Fictive transaction:
2175
- const txid = randomString(16);
2177
+ if (!txid)
2178
+ txid = randomString(16);
2176
2179
  // Convert data into a temporary map to collect mutations of same table and type
2177
2180
  const map = {};
2178
2181
  for (const [table, ops] of Object.entries(inSet)) {
@@ -2937,7 +2940,7 @@ const builtin = {
2937
2940
  ...MapDef,
2938
2941
  ...TypedArraysDefs,
2939
2942
  ...ArrayBufferDef,
2940
- ...BlobDef,
2943
+ ...BlobDef, // Should be moved to another preset for DOM types (or universal? since it supports node as well with FakeBlob)
2941
2944
  };
2942
2945
 
2943
2946
  function Bison(...typeDefsInputs) {
@@ -5910,7 +5913,7 @@ function dexieCloud(dexie) {
5910
5913
  currentUserEmitter.next(UNAUTHORIZED_USER);
5911
5914
  });
5912
5915
  dexie.cloud = {
5913
- version: '4.0.1-beta.27',
5916
+ version: '4.0.1-beta.30',
5914
5917
  options: Object.assign({}, DEFAULT_OPTIONS),
5915
5918
  schema: null,
5916
5919
  get currentUserId() {
@@ -6165,7 +6168,7 @@ function dexieCloud(dexie) {
6165
6168
  });
6166
6169
  }
6167
6170
  }
6168
- dexieCloud.version = '4.0.1-beta.27';
6171
+ dexieCloud.version = '4.0.1-beta.30';
6169
6172
  Dexie.Cloud = dexieCloud;
6170
6173
 
6171
6174
  // In case the SW lives for a while, let it reuse already opened connections: