dexie 4.0.5 → 4.0.8
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 +14 -10
- package/dist/dexie.js +37 -31
- 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 +37 -31
- 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 +37 -31
- package/dist/modern/dexie.mjs.map +1 -1
- package/package.json +2 -2
package/dist/modern/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.8, Wed Jul 10 2024
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -1094,7 +1094,7 @@ function tempTransaction(db, mode, storeNames, fn) {
|
|
|
1094
1094
|
}
|
|
1095
1095
|
}
|
|
1096
1096
|
|
|
1097
|
-
const DEXIE_VERSION = '4.0.
|
|
1097
|
+
const DEXIE_VERSION = '4.0.8';
|
|
1098
1098
|
const maxString = String.fromCharCode(65535);
|
|
1099
1099
|
const minKey = -Infinity;
|
|
1100
1100
|
const INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
|
|
@@ -2054,6 +2054,12 @@ class Collection {
|
|
|
2054
2054
|
}
|
|
2055
2055
|
};
|
|
2056
2056
|
return this.clone().primaryKeys().then(keys => {
|
|
2057
|
+
const criteria = isPlainKeyRange(ctx) &&
|
|
2058
|
+
ctx.limit === Infinity &&
|
|
2059
|
+
(typeof changes !== 'function' || changes === deleteCallback) && {
|
|
2060
|
+
index: ctx.index,
|
|
2061
|
+
range: ctx.range
|
|
2062
|
+
};
|
|
2057
2063
|
const nextChunk = (offset) => {
|
|
2058
2064
|
const count = Math.min(limit, keys.length - offset);
|
|
2059
2065
|
return coreTable.getMany({
|
|
@@ -2086,12 +2092,6 @@ class Collection {
|
|
|
2086
2092
|
}
|
|
2087
2093
|
}
|
|
2088
2094
|
}
|
|
2089
|
-
const criteria = isPlainKeyRange(ctx) &&
|
|
2090
|
-
ctx.limit === Infinity &&
|
|
2091
|
-
(typeof changes !== 'function' || changes === deleteCallback) && {
|
|
2092
|
-
index: ctx.index,
|
|
2093
|
-
range: ctx.range
|
|
2094
|
-
};
|
|
2095
2095
|
return Promise.resolve(addValues.length > 0 &&
|
|
2096
2096
|
coreTable.mutate({ trans, type: 'add', values: addValues })
|
|
2097
2097
|
.then(res => {
|
|
@@ -2107,13 +2107,15 @@ class Collection {
|
|
|
2107
2107
|
values: putValues,
|
|
2108
2108
|
criteria,
|
|
2109
2109
|
changeSpec: typeof changes !== 'function'
|
|
2110
|
-
&& changes
|
|
2110
|
+
&& changes,
|
|
2111
|
+
isAdditionalChunk: offset > 0
|
|
2111
2112
|
}).then(res => applyMutateResult(putValues.length, res))).then(() => (deleteKeys.length > 0 || (criteria && changes === deleteCallback)) &&
|
|
2112
2113
|
coreTable.mutate({
|
|
2113
2114
|
trans,
|
|
2114
2115
|
type: 'delete',
|
|
2115
2116
|
keys: deleteKeys,
|
|
2116
|
-
criteria
|
|
2117
|
+
criteria,
|
|
2118
|
+
isAdditionalChunk: offset > 0
|
|
2117
2119
|
}).then(res => applyMutateResult(deleteKeys.length, res))).then(() => {
|
|
2118
2120
|
return keys.length > offset + count && nextChunk(offset + limit);
|
|
2119
2121
|
});
|
|
@@ -3651,6 +3653,10 @@ props(RangeSet.prototype, {
|
|
|
3651
3653
|
keys.forEach(key => addRange(this, key, key));
|
|
3652
3654
|
return this;
|
|
3653
3655
|
},
|
|
3656
|
+
hasKey(key) {
|
|
3657
|
+
const node = getRangeSetIterator(this).next(key).value;
|
|
3658
|
+
return node && cmp(node.from, key) <= 0 && cmp(node.to, key) >= 0;
|
|
3659
|
+
},
|
|
3654
3660
|
[iteratorSymbol]() {
|
|
3655
3661
|
return getRangeSetIterator(this);
|
|
3656
3662
|
}
|
|
@@ -4742,19 +4748,23 @@ function applyOptimisticOps(result, req, ops, table, cacheEntry, immutable) {
|
|
|
4742
4748
|
const extractLowLevelIndex = (index.lowLevelIndex || index).extractKey;
|
|
4743
4749
|
let finalResult = ops.reduce((result, op) => {
|
|
4744
4750
|
let modifedResult = result;
|
|
4745
|
-
const includedValues =
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4751
|
+
const includedValues = [];
|
|
4752
|
+
if (op.type === 'add' || op.type === 'put') {
|
|
4753
|
+
const includedPKs = new RangeSet();
|
|
4754
|
+
for (let i = op.values.length - 1; i >= 0; --i) {
|
|
4755
|
+
const value = op.values[i];
|
|
4756
|
+
const pk = extractPrimKey(value);
|
|
4757
|
+
if (includedPKs.hasKey(pk))
|
|
4758
|
+
continue;
|
|
4759
|
+
const key = extractIndex(value);
|
|
4760
|
+
if (multiEntry && isArray(key)
|
|
4749
4761
|
? key.some((k) => isWithinRange(k, queryRange))
|
|
4750
|
-
: isWithinRange(key, queryRange)
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
})
|
|
4757
|
-
: [];
|
|
4762
|
+
: isWithinRange(key, queryRange)) {
|
|
4763
|
+
includedPKs.addKey(pk);
|
|
4764
|
+
includedValues.push(value);
|
|
4765
|
+
}
|
|
4766
|
+
}
|
|
4767
|
+
}
|
|
4758
4768
|
switch (op.type) {
|
|
4759
4769
|
case 'add':
|
|
4760
4770
|
modifedResult = result.concat(req.values
|
|
@@ -4764,20 +4774,16 @@ function applyOptimisticOps(result, req, ops, table, cacheEntry, immutable) {
|
|
|
4764
4774
|
case 'put':
|
|
4765
4775
|
const keySet = new RangeSet().addKeys(op.values.map((v) => extractPrimKey(v)));
|
|
4766
4776
|
modifedResult = result
|
|
4767
|
-
.filter(
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
.concat(req.values
|
|
4777
|
+
.filter(
|
|
4778
|
+
(item) => !keySet.hasKey(req.values ? extractPrimKey(item) : item))
|
|
4779
|
+
.concat(
|
|
4780
|
+
req.values
|
|
4772
4781
|
? includedValues
|
|
4773
4782
|
: includedValues.map((v) => extractPrimKey(v)));
|
|
4774
4783
|
break;
|
|
4775
4784
|
case 'delete':
|
|
4776
4785
|
const keysToDelete = new RangeSet().addKeys(op.keys);
|
|
4777
|
-
modifedResult = result.filter((item) =>
|
|
4778
|
-
const key = req.values ? extractPrimKey(item) : item;
|
|
4779
|
-
return !rangesOverlap(new RangeSet(key), keysToDelete);
|
|
4780
|
-
});
|
|
4786
|
+
modifedResult = result.filter((item) => !keysToDelete.hasKey(req.values ? extractPrimKey(item) : item));
|
|
4781
4787
|
break;
|
|
4782
4788
|
case 'deleteRange':
|
|
4783
4789
|
const range = op.range;
|