dexie 4.0.1-alpha.12 → 4.0.1-alpha.13
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 +53 -13
- 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 +53 -13
- 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 +50 -13
- package/dist/modern/dexie.mjs.map +1 -1
- package/package.json +1 -1
package/dist/dexie.d.ts
CHANGED
package/dist/dexie.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* By David Fahlander, david.fahlander@gmail.com
|
|
6
6
|
*
|
|
7
|
-
* Version 4.0.1-alpha.
|
|
7
|
+
* Version 4.0.1-alpha.13, Wed May 31 2023
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -1270,7 +1270,7 @@
|
|
|
1270
1270
|
}
|
|
1271
1271
|
}
|
|
1272
1272
|
|
|
1273
|
-
var DEXIE_VERSION = '4.0.1-alpha.
|
|
1273
|
+
var DEXIE_VERSION = '4.0.1-alpha.13';
|
|
1274
1274
|
var maxString = String.fromCharCode(65535);
|
|
1275
1275
|
var minKey = -Infinity;
|
|
1276
1276
|
var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
|
|
@@ -4766,7 +4766,45 @@
|
|
|
4766
4766
|
return immutable ? Object.freeze(finalResult) : finalResult;
|
|
4767
4767
|
}
|
|
4768
4768
|
|
|
4769
|
+
function obsSetsOverlap(os1, os2) {
|
|
4770
|
+
return Object.keys(os1).some(function (key) { return os2[key] && rangesOverlap(os2[key], os1[key]); });
|
|
4771
|
+
}
|
|
4772
|
+
|
|
4769
4773
|
var cache = {};
|
|
4774
|
+
function invalidateCachedQueries(updateParts) {
|
|
4775
|
+
var queriesToSignal = new Set();
|
|
4776
|
+
for (var key in updateParts) {
|
|
4777
|
+
var parts = /^idb\:\/\/(.*)\/(.*)\//.exec(key);
|
|
4778
|
+
if (parts) {
|
|
4779
|
+
var dbName = parts[1], tableName = parts[2];
|
|
4780
|
+
var tblCache = cache["idb://".concat(dbName, "/").concat(tableName)];
|
|
4781
|
+
if (tblCache)
|
|
4782
|
+
invalidateTableQueries(tblCache, updateParts, queriesToSignal);
|
|
4783
|
+
}
|
|
4784
|
+
}
|
|
4785
|
+
queriesToSignal.forEach(function (requery) { return requery(); });
|
|
4786
|
+
}
|
|
4787
|
+
function invalidateTableQueries(tblCache, mutatedParts, queriesToSignal) {
|
|
4788
|
+
var updatedEntryLists = [];
|
|
4789
|
+
for (var _i = 0, _a = Object.entries(tblCache.queries.query); _i < _a.length; _i++) {
|
|
4790
|
+
var _b = _a[_i], indexName = _b[0], entries = _b[1];
|
|
4791
|
+
var filteredEntries = [];
|
|
4792
|
+
for (var _c = 0, entries_1 = entries; _c < entries_1.length; _c++) {
|
|
4793
|
+
var entry = entries_1[_c];
|
|
4794
|
+
if (entry.obsSet && obsSetsOverlap(mutatedParts, entry.obsSet)) {
|
|
4795
|
+
entry.subscribers.forEach(function (requery) { return queriesToSignal.add(requery); });
|
|
4796
|
+
}
|
|
4797
|
+
else {
|
|
4798
|
+
filteredEntries.push(entry);
|
|
4799
|
+
}
|
|
4800
|
+
}
|
|
4801
|
+
updatedEntryLists.push([indexName, filteredEntries]);
|
|
4802
|
+
}
|
|
4803
|
+
for (var _d = 0, updatedEntryLists_1 = updatedEntryLists; _d < updatedEntryLists_1.length; _d++) {
|
|
4804
|
+
var _e = updatedEntryLists_1[_d], indexName = _e[0], newEntries = _e[1];
|
|
4805
|
+
tblCache.queries.query[indexName] = newEntries;
|
|
4806
|
+
}
|
|
4807
|
+
}
|
|
4770
4808
|
|
|
4771
4809
|
function areRangesEqual(r1, r2) {
|
|
4772
4810
|
return (cmp(r1.lower, r2.lower) === 0 &&
|
|
@@ -4852,10 +4890,6 @@
|
|
|
4852
4890
|
}
|
|
4853
4891
|
}
|
|
4854
4892
|
|
|
4855
|
-
function obsSetsOverlap(os1, os2) {
|
|
4856
|
-
return Object.keys(os1).some(function (key) { return os2[key] && rangesOverlap(os2[key], os1[key]); });
|
|
4857
|
-
}
|
|
4858
|
-
|
|
4859
4893
|
function signalSubscribers(tblCache, mutatedParts) {
|
|
4860
4894
|
extendObservabilitySet(tblCache.unsignaledParts, mutatedParts);
|
|
4861
4895
|
if (!tblCache.signalTimer) {
|
|
@@ -4916,6 +4950,7 @@
|
|
|
4916
4950
|
delArrayItem(txs, idbtrans);
|
|
4917
4951
|
ac_1.abort();
|
|
4918
4952
|
if (mode === 'readwrite') {
|
|
4953
|
+
var affectedSubscribers_1 = new Set();
|
|
4919
4954
|
for (var _i = 0, stores_1 = stores; _i < stores_1.length; _i++) {
|
|
4920
4955
|
var storeName = stores_1[_i];
|
|
4921
4956
|
var tblCache = cache["idb://".concat(dbName, "/").concat(storeName)];
|
|
@@ -4936,7 +4971,7 @@
|
|
|
4936
4971
|
var modRes = applyOptimisticOps(entry.res, entry.req, ops, table, entry, freezeResults);
|
|
4937
4972
|
if (entry.dirty) {
|
|
4938
4973
|
delArrayItem(entries, entry);
|
|
4939
|
-
entry.subscribers.forEach(function (requery) { return requery
|
|
4974
|
+
entry.subscribers.forEach(function (requery) { return affectedSubscribers_1.add(requery); });
|
|
4940
4975
|
}
|
|
4941
4976
|
else if (modRes !== entry.res) {
|
|
4942
4977
|
entry.res = modRes;
|
|
@@ -4947,7 +4982,7 @@
|
|
|
4947
4982
|
if (entry.dirty) {
|
|
4948
4983
|
delArrayItem(entries, entry);
|
|
4949
4984
|
}
|
|
4950
|
-
entry.subscribers.forEach(function (requery) { return requery
|
|
4985
|
+
entry.subscribers.forEach(function (requery) { return affectedSubscribers_1.add(requery); });
|
|
4951
4986
|
}
|
|
4952
4987
|
}
|
|
4953
4988
|
}
|
|
@@ -4955,6 +4990,7 @@
|
|
|
4955
4990
|
}
|
|
4956
4991
|
}
|
|
4957
4992
|
}
|
|
4993
|
+
affectedSubscribers_1.forEach(function (requery) { return requery(); });
|
|
4958
4994
|
}
|
|
4959
4995
|
}; };
|
|
4960
4996
|
idbtrans.addEventListener('abort', endTransaction(false), {
|
|
@@ -5435,10 +5471,13 @@
|
|
|
5435
5471
|
return closed;
|
|
5436
5472
|
},
|
|
5437
5473
|
unsubscribe: function () {
|
|
5474
|
+
if (closed)
|
|
5475
|
+
return;
|
|
5438
5476
|
closed = true;
|
|
5439
5477
|
if (abortController)
|
|
5440
5478
|
abortController.abort();
|
|
5441
|
-
|
|
5479
|
+
if (startedListening)
|
|
5480
|
+
globalEvents.storagemutated.unsubscribe(mutationListener);
|
|
5442
5481
|
txs.forEach(function (idbtrans) {
|
|
5443
5482
|
idbtrans.aborted = true;
|
|
5444
5483
|
try {
|
|
@@ -5488,10 +5527,6 @@
|
|
|
5488
5527
|
trans: null
|
|
5489
5528
|
};
|
|
5490
5529
|
var ret = execute(ctx);
|
|
5491
|
-
if (!startedListening) {
|
|
5492
|
-
globalEvents(DEXIE_STORAGE_MUTATED_EVENT_NAME, mutationListener);
|
|
5493
|
-
startedListening = true;
|
|
5494
|
-
}
|
|
5495
5530
|
Promise.resolve(ret).then(function (result) {
|
|
5496
5531
|
hasValue = true;
|
|
5497
5532
|
currentValue = result;
|
|
@@ -5500,6 +5535,10 @@
|
|
|
5500
5535
|
}
|
|
5501
5536
|
accumMuts = {};
|
|
5502
5537
|
currentObs = subscr;
|
|
5538
|
+
if (keys(currentObs).length > 0 && !startedListening) {
|
|
5539
|
+
globalEvents(DEXIE_STORAGE_MUTATED_EVENT_NAME, mutationListener);
|
|
5540
|
+
startedListening = true;
|
|
5541
|
+
}
|
|
5503
5542
|
observer.next && observer.next(result);
|
|
5504
5543
|
}, function (err) {
|
|
5505
5544
|
hasValue = false;
|
|
@@ -5631,6 +5670,7 @@
|
|
|
5631
5670
|
try {
|
|
5632
5671
|
propagatingLocally = true;
|
|
5633
5672
|
globalEvents.storagemutated.fire(updateParts);
|
|
5673
|
+
invalidateCachedQueries(updateParts);
|
|
5634
5674
|
}
|
|
5635
5675
|
finally {
|
|
5636
5676
|
propagatingLocally = wasMe;
|