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.d.ts 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
  *
package/dist/dexie.js 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
  *
@@ -178,7 +178,7 @@ function setByKeyPath(obj, keyPath, value) {
178
178
  obj[currentKeyPath] = value;
179
179
  else {
180
180
  var innerObj = obj[currentKeyPath];
181
- if (!innerObj)
181
+ if (!innerObj || !hasOwn(obj, currentKeyPath))
182
182
  innerObj = (obj[currentKeyPath] = {});
183
183
  setByKeyPath(innerObj, remainingKeyPath, value);
184
184
  }
@@ -689,10 +689,9 @@ var thenProp = {
689
689
  function then(onFulfilled, onRejected) {
690
690
  var _this = this;
691
691
  var possibleAwait = !psd.global && (psd !== PSD || microTaskId !== totalEchoes);
692
- if (possibleAwait)
693
- decrementExpectedAwaits();
692
+ var cleanup = possibleAwait && !decrementExpectedAwaits();
694
693
  var rv = new DexiePromise(function (resolve, reject) {
695
- propagateToListener(_this, new Listener(nativeAwaitCompatibleWrap(onFulfilled, psd, possibleAwait), nativeAwaitCompatibleWrap(onRejected, psd, possibleAwait), resolve, reject, psd));
694
+ propagateToListener(_this, new Listener(nativeAwaitCompatibleWrap(onFulfilled, psd, possibleAwait, cleanup), nativeAwaitCompatibleWrap(onRejected, psd, possibleAwait, cleanup), resolve, reject, psd));
696
695
  });
697
696
  debug && linkToPreviousPromise(rv, this);
698
697
  return rv;
@@ -809,6 +808,7 @@ props(DexiePromise, {
809
808
  get: function () { return PSD; },
810
809
  set: function (value) { return PSD = value; }
811
810
  },
811
+ totalEchoes: { get: function () { return totalEchoes; } },
812
812
  newPSD: newScope,
813
813
  usePSD: usePSD,
814
814
  scheduler: {
@@ -1131,12 +1131,13 @@ function incrementExpectedAwaits() {
1131
1131
  task.echoes += ZONE_ECHO_LIMIT;
1132
1132
  return task.id;
1133
1133
  }
1134
- function decrementExpectedAwaits(sourceTaskId) {
1135
- if (!task.awaits || (sourceTaskId && sourceTaskId !== task.id))
1136
- return;
1134
+ function decrementExpectedAwaits() {
1135
+ if (!task.awaits)
1136
+ return false;
1137
1137
  if (--task.awaits === 0)
1138
1138
  task.id = 0;
1139
1139
  task.echoes = task.awaits * ZONE_ECHO_LIMIT;
1140
+ return true;
1140
1141
  }
1141
1142
  if (('' + nativePromiseThen).indexOf('[native code]') === -1) {
1142
1143
  incrementExpectedAwaits = decrementExpectedAwaits = nop;
@@ -1223,7 +1224,7 @@ function usePSD(psd, fn, a1, a2, a3) {
1223
1224
  function enqueueNativeMicroTask(job) {
1224
1225
  nativePromiseThen.call(resolvedNativePromise, job);
1225
1226
  }
1226
- function nativeAwaitCompatibleWrap(fn, zone, possibleAwait) {
1227
+ function nativeAwaitCompatibleWrap(fn, zone, possibleAwait, cleanup) {
1227
1228
  return typeof fn !== 'function' ? fn : function () {
1228
1229
  var outerZone = PSD;
1229
1230
  if (possibleAwait)
@@ -1234,12 +1235,14 @@ function nativeAwaitCompatibleWrap(fn, zone, possibleAwait) {
1234
1235
  }
1235
1236
  finally {
1236
1237
  switchToZone(outerZone, false);
1238
+ if (cleanup)
1239
+ enqueueNativeMicroTask(decrementExpectedAwaits);
1237
1240
  }
1238
1241
  };
1239
1242
  }
1240
1243
  function getPatchedPromiseThen(origThen, zone) {
1241
1244
  return function (onResolved, onRejected) {
1242
- return origThen.call(this, nativeAwaitCompatibleWrap(onResolved, zone, false), nativeAwaitCompatibleWrap(onRejected, zone, false));
1245
+ return origThen.call(this, nativeAwaitCompatibleWrap(onResolved, zone), nativeAwaitCompatibleWrap(onRejected, zone));
1243
1246
  };
1244
1247
  }
1245
1248
  var UNHANDLEDREJECTION = "unhandledrejection";
@@ -1305,7 +1308,7 @@ function tempTransaction(db, mode, storeNames, fn) {
1305
1308
  }
1306
1309
  }
1307
1310
 
1308
- var DEXIE_VERSION = '3.0.3-rc.3';
1311
+ var DEXIE_VERSION = '3.0.4';
1309
1312
  var maxString = String.fromCharCode(65535);
1310
1313
  var minKey = -Infinity;
1311
1314
  var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
@@ -2346,6 +2349,8 @@ var WhereClause = (function () {
2346
2349
  }
2347
2350
  };
2348
2351
  WhereClause.prototype.equals = function (value) {
2352
+ if (value == null)
2353
+ return fail(this, INVALID_KEY_ARGUMENT);
2349
2354
  return new this.Collection(this, function () { return rangeEqual(value); });
2350
2355
  };
2351
2356
  WhereClause.prototype.above = function (value) {