@schukai/monster 4.73.1 → 4.73.2
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/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.73.
|
|
1
|
+
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.73.2"}
|
|
@@ -66,6 +66,7 @@ const readRequestIdSymbol = Symbol("readRequestId");
|
|
|
66
66
|
const writeRequestIdSymbol = Symbol("writeRequestId");
|
|
67
67
|
const lookupCacheSymbol = Symbol("lookupCache");
|
|
68
68
|
const lookupPendingSymbol = Symbol("lookupPending");
|
|
69
|
+
const lookupPendingFetchSymbol = Symbol("lookupPendingFetch");
|
|
69
70
|
|
|
70
71
|
/**
|
|
71
72
|
* A rest api datasource
|
|
@@ -823,6 +824,7 @@ async function resolveRemoteLookup(requestId, name, cfg) {
|
|
|
823
824
|
|
|
824
825
|
const cache = getLookupCache.call(this, name);
|
|
825
826
|
const pending = getLookupPending.call(this, name);
|
|
827
|
+
const pendingFetches = getLookupPendingFetches.call(this, name);
|
|
826
828
|
|
|
827
829
|
const ids = collectLookupIds.call(
|
|
828
830
|
this,
|
|
@@ -832,6 +834,21 @@ async function resolveRemoteLookup(requestId, name, cfg) {
|
|
|
832
834
|
const missingIds = ids.filter((id) => !cache.has(id) && !pending.has(id));
|
|
833
835
|
|
|
834
836
|
if (missingIds.length === 0) {
|
|
837
|
+
if (pending.size > 0) {
|
|
838
|
+
updateLookupRows.call(this, requestId, (rows) => {
|
|
839
|
+
if (!isString(cfg.loadingKey)) return;
|
|
840
|
+
for (const row of rows) {
|
|
841
|
+
if (pending.has(String(row[key]))) {
|
|
842
|
+
row[cfg.loadingKey] = true;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
});
|
|
846
|
+
|
|
847
|
+
if (pendingFetches.size > 0) {
|
|
848
|
+
const fetches = Array.from(pendingFetches);
|
|
849
|
+
await Promise.all(fetches.map((promise) => promise.catch(() => null)));
|
|
850
|
+
}
|
|
851
|
+
}
|
|
835
852
|
applyLookupCache.call(this, requestId, cfg, cache);
|
|
836
853
|
return;
|
|
837
854
|
}
|
|
@@ -839,7 +856,7 @@ async function resolveRemoteLookup(requestId, name, cfg) {
|
|
|
839
856
|
updateLookupRows.call(this, requestId, (rows) => {
|
|
840
857
|
if (!isString(cfg.loadingKey)) return;
|
|
841
858
|
for (const row of rows) {
|
|
842
|
-
if (missingIds.includes(String(row[key]))) {
|
|
859
|
+
if (missingIds.includes(String(row[key])) || pending.has(String(row[key]))) {
|
|
843
860
|
row[cfg.loadingKey] = true;
|
|
844
861
|
}
|
|
845
862
|
}
|
|
@@ -847,7 +864,14 @@ async function resolveRemoteLookup(requestId, name, cfg) {
|
|
|
847
864
|
|
|
848
865
|
missingIds.forEach((id) => pending.add(id));
|
|
849
866
|
|
|
850
|
-
const
|
|
867
|
+
const fetchPromise = fetchLookupEntries.call(this, cfg, missingIds);
|
|
868
|
+
pendingFetches.add(fetchPromise);
|
|
869
|
+
let response;
|
|
870
|
+
try {
|
|
871
|
+
response = await fetchPromise;
|
|
872
|
+
} finally {
|
|
873
|
+
pendingFetches.delete(fetchPromise);
|
|
874
|
+
}
|
|
851
875
|
response.forEach((entry, id) => cache.set(id, entry));
|
|
852
876
|
missingIds.forEach((id) => pending.delete(id));
|
|
853
877
|
|
|
@@ -1137,6 +1161,21 @@ function getLookupPending(name) {
|
|
|
1137
1161
|
return this[lookupPendingSymbol].get(name);
|
|
1138
1162
|
}
|
|
1139
1163
|
|
|
1164
|
+
/**
|
|
1165
|
+
* @private
|
|
1166
|
+
* @param {string} name
|
|
1167
|
+
* @return {Set<Promise<Map<string, object>>>}
|
|
1168
|
+
*/
|
|
1169
|
+
function getLookupPendingFetches(name) {
|
|
1170
|
+
if (!this[lookupPendingFetchSymbol]) {
|
|
1171
|
+
this[lookupPendingFetchSymbol] = new Map();
|
|
1172
|
+
}
|
|
1173
|
+
if (!this[lookupPendingFetchSymbol].has(name)) {
|
|
1174
|
+
this[lookupPendingFetchSymbol].set(name, new Set());
|
|
1175
|
+
}
|
|
1176
|
+
return this[lookupPendingFetchSymbol].get(name);
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1140
1179
|
/**
|
|
1141
1180
|
* @private
|
|
1142
1181
|
* @return {string}
|