dexie 3.0.3-rc.3 → 3.0.4

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.
package/dist/dexie.mjs CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 3.0.3-rc.3, Tue Oct 20 2020
7
+ * Version 3.0.4, Fri Apr 29 2022
8
8
  *
9
9
  * http://dexie.org
10
10
  *
@@ -172,7 +172,7 @@ function setByKeyPath(obj, keyPath, value) {
172
172
  obj[currentKeyPath] = value;
173
173
  else {
174
174
  var innerObj = obj[currentKeyPath];
175
- if (!innerObj)
175
+ if (!innerObj || !hasOwn(obj, currentKeyPath))
176
176
  innerObj = (obj[currentKeyPath] = {});
177
177
  setByKeyPath(innerObj, remainingKeyPath, value);
178
178
  }
@@ -683,10 +683,9 @@ var thenProp = {
683
683
  function then(onFulfilled, onRejected) {
684
684
  var _this = this;
685
685
  var possibleAwait = !psd.global && (psd !== PSD || microTaskId !== totalEchoes);
686
- if (possibleAwait)
687
- decrementExpectedAwaits();
686
+ var cleanup = possibleAwait && !decrementExpectedAwaits();
688
687
  var rv = new DexiePromise(function (resolve, reject) {
689
- propagateToListener(_this, new Listener(nativeAwaitCompatibleWrap(onFulfilled, psd, possibleAwait), nativeAwaitCompatibleWrap(onRejected, psd, possibleAwait), resolve, reject, psd));
688
+ propagateToListener(_this, new Listener(nativeAwaitCompatibleWrap(onFulfilled, psd, possibleAwait, cleanup), nativeAwaitCompatibleWrap(onRejected, psd, possibleAwait, cleanup), resolve, reject, psd));
690
689
  });
691
690
  debug && linkToPreviousPromise(rv, this);
692
691
  return rv;
@@ -803,6 +802,7 @@ props(DexiePromise, {
803
802
  get: function () { return PSD; },
804
803
  set: function (value) { return PSD = value; }
805
804
  },
805
+ totalEchoes: { get: function () { return totalEchoes; } },
806
806
  newPSD: newScope,
807
807
  usePSD: usePSD,
808
808
  scheduler: {
@@ -1125,12 +1125,13 @@ function incrementExpectedAwaits() {
1125
1125
  task.echoes += ZONE_ECHO_LIMIT;
1126
1126
  return task.id;
1127
1127
  }
1128
- function decrementExpectedAwaits(sourceTaskId) {
1129
- if (!task.awaits || (sourceTaskId && sourceTaskId !== task.id))
1130
- return;
1128
+ function decrementExpectedAwaits() {
1129
+ if (!task.awaits)
1130
+ return false;
1131
1131
  if (--task.awaits === 0)
1132
1132
  task.id = 0;
1133
1133
  task.echoes = task.awaits * ZONE_ECHO_LIMIT;
1134
+ return true;
1134
1135
  }
1135
1136
  if (('' + nativePromiseThen).indexOf('[native code]') === -1) {
1136
1137
  incrementExpectedAwaits = decrementExpectedAwaits = nop;
@@ -1217,7 +1218,7 @@ function usePSD(psd, fn, a1, a2, a3) {
1217
1218
  function enqueueNativeMicroTask(job) {
1218
1219
  nativePromiseThen.call(resolvedNativePromise, job);
1219
1220
  }
1220
- function nativeAwaitCompatibleWrap(fn, zone, possibleAwait) {
1221
+ function nativeAwaitCompatibleWrap(fn, zone, possibleAwait, cleanup) {
1221
1222
  return typeof fn !== 'function' ? fn : function () {
1222
1223
  var outerZone = PSD;
1223
1224
  if (possibleAwait)
@@ -1228,12 +1229,14 @@ function nativeAwaitCompatibleWrap(fn, zone, possibleAwait) {
1228
1229
  }
1229
1230
  finally {
1230
1231
  switchToZone(outerZone, false);
1232
+ if (cleanup)
1233
+ enqueueNativeMicroTask(decrementExpectedAwaits);
1231
1234
  }
1232
1235
  };
1233
1236
  }
1234
1237
  function getPatchedPromiseThen(origThen, zone) {
1235
1238
  return function (onResolved, onRejected) {
1236
- return origThen.call(this, nativeAwaitCompatibleWrap(onResolved, zone, false), nativeAwaitCompatibleWrap(onRejected, zone, false));
1239
+ return origThen.call(this, nativeAwaitCompatibleWrap(onResolved, zone), nativeAwaitCompatibleWrap(onRejected, zone));
1237
1240
  };
1238
1241
  }
1239
1242
  var UNHANDLEDREJECTION = "unhandledrejection";
@@ -1299,7 +1302,7 @@ function tempTransaction(db, mode, storeNames, fn) {
1299
1302
  }
1300
1303
  }
1301
1304
 
1302
- var DEXIE_VERSION = '3.0.3-rc.3';
1305
+ var DEXIE_VERSION = '3.0.4';
1303
1306
  var maxString = String.fromCharCode(65535);
1304
1307
  var minKey = -Infinity;
1305
1308
  var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
@@ -2340,6 +2343,8 @@ var WhereClause = (function () {
2340
2343
  }
2341
2344
  };
2342
2345
  WhereClause.prototype.equals = function (value) {
2346
+ if (value == null)
2347
+ return fail(this, INVALID_KEY_ARGUMENT);
2343
2348
  return new this.Collection(this, function () { return rangeEqual(value); });
2344
2349
  };
2345
2350
  WhereClause.prototype.above = function (value) {