dexie 4.0.8 → 4.0.9
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 +1 -1
- package/dist/dexie.js +40 -14
- package/dist/dexie.js.map +1 -1
- package/dist/dexie.min.js +1 -1
- package/dist/dexie.min.js.map +1 -1
- package/dist/dexie.mjs +40 -14
- package/dist/dexie.mjs.map +1 -1
- package/dist/modern/dexie.min.mjs +1 -1
- package/dist/modern/dexie.min.mjs.map +1 -1
- package/dist/modern/dexie.mjs +34 -11
- package/dist/modern/dexie.mjs.map +1 -1
- package/package.json +1 -1
package/dist/dexie.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* By David Fahlander, david.fahlander@gmail.com
|
|
6
6
|
*
|
|
7
|
-
* Version 4.0.
|
|
7
|
+
* Version 4.0.9, Mon Oct 21 2024
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -770,6 +770,8 @@ if (NativePromise) {
|
|
|
770
770
|
}); });
|
|
771
771
|
});
|
|
772
772
|
});
|
|
773
|
+
if (NativePromise.withResolvers)
|
|
774
|
+
DexiePromise.withResolvers = NativePromise.withResolvers;
|
|
773
775
|
}
|
|
774
776
|
function executePromiseTask(promise, fn) {
|
|
775
777
|
try {
|
|
@@ -1144,7 +1146,7 @@ function tempTransaction(db, mode, storeNames, fn) {
|
|
|
1144
1146
|
}
|
|
1145
1147
|
}
|
|
1146
1148
|
|
|
1147
|
-
var DEXIE_VERSION = '4.0.
|
|
1149
|
+
var DEXIE_VERSION = '4.0.9';
|
|
1148
1150
|
var maxString = String.fromCharCode(65535);
|
|
1149
1151
|
var minKey = -Infinity;
|
|
1150
1152
|
var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
|
|
@@ -1337,9 +1339,8 @@ var Table = (function () {
|
|
|
1337
1339
|
console.warn("The query ".concat(JSON.stringify(indexOrCrit), " on ").concat(this.name, " would benefit from a ") +
|
|
1338
1340
|
"compound index [".concat(keyPaths.join('+'), "]"));
|
|
1339
1341
|
var idxByName = this.schema.idxByName;
|
|
1340
|
-
var idb = this.db._deps.indexedDB;
|
|
1341
1342
|
function equals(a, b) {
|
|
1342
|
-
return
|
|
1343
|
+
return cmp(a, b) === 0;
|
|
1343
1344
|
}
|
|
1344
1345
|
var _a = keyPaths.reduce(function (_a, keyPath) {
|
|
1345
1346
|
var prevIndex = _a[0], prevFilterFn = _a[1];
|
|
@@ -1915,7 +1916,7 @@ var Collection = (function () {
|
|
|
1915
1916
|
var order = this._ctx.dir === "next" ? 1 : -1;
|
|
1916
1917
|
function sorter(a, b) {
|
|
1917
1918
|
var aVal = getval(a, lastIndex), bVal = getval(b, lastIndex);
|
|
1918
|
-
return aVal
|
|
1919
|
+
return cmp(aVal, bVal) * order;
|
|
1919
1920
|
}
|
|
1920
1921
|
return this.toArray(function (a) {
|
|
1921
1922
|
return a.sort(sorter);
|
|
@@ -4623,6 +4624,7 @@ var observabilityMiddleware = {
|
|
|
4623
4624
|
var extractKey = primaryKey.extractKey, outbound = primaryKey.outbound;
|
|
4624
4625
|
var indexesWithAutoIncPK = primaryKey.autoIncrement && indexes.filter(function (index) { return index.compound && index.keyPath.includes(primaryKey.keyPath); });
|
|
4625
4626
|
var tableClone = __assign(__assign({}, table), { mutate: function (req) {
|
|
4627
|
+
var _a, _b;
|
|
4626
4628
|
var trans = req.trans;
|
|
4627
4629
|
var mutatedParts = req.mutatedParts || (req.mutatedParts = {});
|
|
4628
4630
|
var getRangeSet = function (indexName) {
|
|
@@ -4633,13 +4635,13 @@ var observabilityMiddleware = {
|
|
|
4633
4635
|
var pkRangeSet = getRangeSet("");
|
|
4634
4636
|
var delsRangeSet = getRangeSet(":dels");
|
|
4635
4637
|
var type = req.type;
|
|
4636
|
-
var
|
|
4638
|
+
var _c = req.type === "deleteRange"
|
|
4637
4639
|
? [req.range]
|
|
4638
4640
|
: req.type === "delete"
|
|
4639
4641
|
? [req.keys]
|
|
4640
4642
|
: req.values.length < 50
|
|
4641
4643
|
? [getEffectiveKeys(primaryKey, req).filter(function (id) { return id; }), req.values]
|
|
4642
|
-
: [], keys =
|
|
4644
|
+
: [], keys = _c[0], newObjs = _c[1];
|
|
4643
4645
|
var oldCache = req.trans["_cache"];
|
|
4644
4646
|
if (isArray(keys)) {
|
|
4645
4647
|
pkRangeSet.addKeys(keys);
|
|
@@ -4652,7 +4654,10 @@ var observabilityMiddleware = {
|
|
|
4652
4654
|
}
|
|
4653
4655
|
}
|
|
4654
4656
|
else if (keys) {
|
|
4655
|
-
var range = {
|
|
4657
|
+
var range = {
|
|
4658
|
+
from: (_a = keys.lower) !== null && _a !== void 0 ? _a : core.MIN_KEY,
|
|
4659
|
+
to: (_b = keys.upper) !== null && _b !== void 0 ? _b : core.MAX_KEY
|
|
4660
|
+
};
|
|
4656
4661
|
delsRangeSet.add(range);
|
|
4657
4662
|
pkRangeSet.add(range);
|
|
4658
4663
|
}
|
|
@@ -4876,12 +4881,27 @@ function applyOptimisticOps(result, req, ops, table, cacheEntry, immutable) {
|
|
|
4876
4881
|
}
|
|
4877
4882
|
}
|
|
4878
4883
|
switch (op.type) {
|
|
4879
|
-
case 'add':
|
|
4884
|
+
case 'add': {
|
|
4885
|
+
var existingKeys_1 = new RangeSet().addKeys(req.values ? result.map(function (v) { return extractPrimKey(v); }) : result);
|
|
4880
4886
|
modifedResult = result.concat(req.values
|
|
4881
|
-
? includedValues
|
|
4882
|
-
|
|
4887
|
+
? includedValues.filter(function (v) {
|
|
4888
|
+
var key = extractPrimKey(v);
|
|
4889
|
+
if (existingKeys_1.hasKey(key))
|
|
4890
|
+
return false;
|
|
4891
|
+
existingKeys_1.addKey(key);
|
|
4892
|
+
return true;
|
|
4893
|
+
})
|
|
4894
|
+
: includedValues
|
|
4895
|
+
.map(function (v) { return extractPrimKey(v); })
|
|
4896
|
+
.filter(function (k) {
|
|
4897
|
+
if (existingKeys_1.hasKey(k))
|
|
4898
|
+
return false;
|
|
4899
|
+
existingKeys_1.addKey(k);
|
|
4900
|
+
return true;
|
|
4901
|
+
}));
|
|
4883
4902
|
break;
|
|
4884
|
-
|
|
4903
|
+
}
|
|
4904
|
+
case 'put': {
|
|
4885
4905
|
var keySet_1 = new RangeSet().addKeys(op.values.map(function (v) { return extractPrimKey(v); }));
|
|
4886
4906
|
modifedResult = result
|
|
4887
4907
|
.filter(
|
|
@@ -4891,9 +4911,12 @@ function applyOptimisticOps(result, req, ops, table, cacheEntry, immutable) {
|
|
|
4891
4911
|
? includedValues
|
|
4892
4912
|
: includedValues.map(function (v) { return extractPrimKey(v); }));
|
|
4893
4913
|
break;
|
|
4914
|
+
}
|
|
4894
4915
|
case 'delete':
|
|
4895
4916
|
var keysToDelete_1 = new RangeSet().addKeys(op.keys);
|
|
4896
|
-
modifedResult = result.filter(function (item) {
|
|
4917
|
+
modifedResult = result.filter(function (item) {
|
|
4918
|
+
return !keysToDelete_1.hasKey(req.values ? extractPrimKey(item) : item);
|
|
4919
|
+
});
|
|
4897
4920
|
break;
|
|
4898
4921
|
case 'deleteRange':
|
|
4899
4922
|
var range_1 = op.range;
|
|
@@ -5107,7 +5130,8 @@ var cacheMiddleware = {
|
|
|
5107
5130
|
var trans = PSD.trans;
|
|
5108
5131
|
if (primKey.outbound ||
|
|
5109
5132
|
trans.db._options.cache === 'disabled' ||
|
|
5110
|
-
trans.explicit
|
|
5133
|
+
trans.explicit ||
|
|
5134
|
+
trans.idbtrans.mode !== 'readwrite'
|
|
5111
5135
|
) {
|
|
5112
5136
|
return downTable.mutate(req);
|
|
5113
5137
|
}
|
|
@@ -5119,6 +5143,8 @@ var cacheMiddleware = {
|
|
|
5119
5143
|
promise.then(function (res) {
|
|
5120
5144
|
var reqWithResolvedKeys = __assign(__assign({}, req), { values: req.values.map(function (value, i) {
|
|
5121
5145
|
var _a;
|
|
5146
|
+
if (res.failures[i])
|
|
5147
|
+
return value;
|
|
5122
5148
|
var valueWithKey = ((_a = primKey.keyPath) === null || _a === void 0 ? void 0 : _a.includes('.'))
|
|
5123
5149
|
? deepClone(value)
|
|
5124
5150
|
: __assign({}, value);
|