@uniweb/runtime 0.17.2 → 0.18.1
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/ssr.js +10 -10
- package/dist/ssr.js.map +1 -1
- package/package.json +3 -3
- package/src/appearance.js +1 -1
- package/src/collect-records.js +2 -2
- package/src/default-fetcher.js +19 -13
- package/src/document-tracking.js +1 -1
- package/src/foundation-loader.js +2 -2
- package/src/page-renderer.js +2 -2
- package/src/prefetch.js +5 -4
- package/src/shell/main.js +2 -1
- package/src/ssr-renderer.js +4 -4
- package/src/wire-foundation.js +8 -8
package/dist/ssr.js
CHANGED
|
@@ -940,8 +940,8 @@ function createDefaultFetcher({ basePath = "", dev = false, fetch: fetchImpl = n
|
|
|
940
940
|
data = getNestedValue(data, effectiveTransform);
|
|
941
941
|
}
|
|
942
942
|
data = applyOperators(data, request, { dev });
|
|
943
|
-
const
|
|
944
|
-
return
|
|
943
|
+
const whole = typeof request.whole === "boolean" ? request.whole : void 0;
|
|
944
|
+
return whole === void 0 ? { data: data ?? [] } : { data: data ?? [], meta: { whole } };
|
|
945
945
|
} catch (error) {
|
|
946
946
|
if (error?.name === "AbortError") {
|
|
947
947
|
return { data: [], error: "aborted" };
|
|
@@ -965,7 +965,7 @@ function toQuestion(request) {
|
|
|
965
965
|
const sort = sortToWire(request.sort);
|
|
966
966
|
if (sort) q.sort = sort;
|
|
967
967
|
if (typeof request.limit === "number" && request.limit > 0) q.limit = request.limit;
|
|
968
|
-
if (request.
|
|
968
|
+
if (request.whole === true) q.whole = true;
|
|
969
969
|
if (typeof request.cursor === "string" && request.cursor) q.cursor = request.cursor;
|
|
970
970
|
return q;
|
|
971
971
|
}
|
|
@@ -1020,7 +1020,7 @@ async function flushAsked(url, queue, doFetch) {
|
|
|
1020
1020
|
}
|
|
1021
1021
|
const data = parsed && typeof parsed.data === "object" && parsed.data ? parsed.data : {};
|
|
1022
1022
|
const errors = parsed && typeof parsed.errors === "object" && parsed.errors ? parsed.errors : {};
|
|
1023
|
-
const
|
|
1023
|
+
const wholes = parsed && typeof parsed.whole === "object" && parsed.whole ? parsed.whole : {};
|
|
1024
1024
|
const cursors = parsed && typeof parsed.cursors === "object" && parsed.cursors ? parsed.cursors : {};
|
|
1025
1025
|
const limits = parsed && typeof parsed.limits === "object" && parsed.limits ? parsed.limits : {};
|
|
1026
1026
|
queue.forEach((entry, i) => {
|
|
@@ -1038,7 +1038,7 @@ async function flushAsked(url, queue, doFetch) {
|
|
|
1038
1038
|
entry.resolve({ data: null, error: `the records service answered without the key "${key}"` });
|
|
1039
1039
|
return;
|
|
1040
1040
|
}
|
|
1041
|
-
const
|
|
1041
|
+
const whole = typeof wholes[key] === "boolean" ? wholes[key] : typeof entry.request.whole === "boolean" ? entry.request.whole : void 0;
|
|
1042
1042
|
const cursor = typeof cursors[key] === "string" && cursors[key] ? cursors[key] : null;
|
|
1043
1043
|
const bound = typeof limits[key] === "number" ? limits[key] : void 0;
|
|
1044
1044
|
const rows = Array.isArray(data[key]) ? data[key] : data[key];
|
|
@@ -1047,15 +1047,15 @@ async function flushAsked(url, queue, doFetch) {
|
|
|
1047
1047
|
const page = (entry.page || 1) + 1;
|
|
1048
1048
|
const cap = typeof entry.request.maxPages === "number" && entry.request.maxPages > 0 ? entry.request.maxPages : DEFAULT_MAX_PAGES;
|
|
1049
1049
|
if (page <= cap) {
|
|
1050
|
-
pending.set(entry, { cursor, collected: acc, page,
|
|
1050
|
+
pending.set(entry, { cursor, collected: acc, page, whole, bound });
|
|
1051
1051
|
return;
|
|
1052
1052
|
}
|
|
1053
|
-
entry.resolve({ data: acc, meta: withMeta({
|
|
1053
|
+
entry.resolve({ data: acc, meta: withMeta({ whole, bound, partial: true, pages: cap }) });
|
|
1054
1054
|
return;
|
|
1055
1055
|
}
|
|
1056
1056
|
const collected = entry.collected ? entry.collected.concat(Array.isArray(rows) ? rows : []) : rows;
|
|
1057
1057
|
const meta = withMeta({
|
|
1058
|
-
|
|
1058
|
+
whole,
|
|
1059
1059
|
bound,
|
|
1060
1060
|
// ⭐ ONE FLAG, MEANING **NOT THE WHOLE POPULATION** — asked for by name, so
|
|
1061
1061
|
// a caller has one boolean to branch on rather than three signals to
|
|
@@ -1254,7 +1254,7 @@ async function prefetchAndHydrate({ website, content, route, locale = null, fetc
|
|
|
1254
1254
|
hydrateDataStore(website, fetched);
|
|
1255
1255
|
return fetched;
|
|
1256
1256
|
}
|
|
1257
|
-
async function collectSiteRecords(content, { locale, fetch: fetch2, signal, only = null,
|
|
1257
|
+
async function collectSiteRecords(content, { locale, fetch: fetch2, signal, only = null, whole = false, maxPages } = {}) {
|
|
1258
1258
|
const config = content?.config;
|
|
1259
1259
|
const services = config?.services ?? null;
|
|
1260
1260
|
const queries = config?.queries ?? null;
|
|
@@ -1273,7 +1273,7 @@ async function collectSiteRecords(content, { locale, fetch: fetch2, signal, only
|
|
|
1273
1273
|
await Promise.all([...configs].map(async ([name, cfg]) => {
|
|
1274
1274
|
if (!cfg.ask) return;
|
|
1275
1275
|
const { limit, ...population } = cfg;
|
|
1276
|
-
const asked = { ...population,
|
|
1276
|
+
const asked = { ...population, whole, exhaustive: true };
|
|
1277
1277
|
if (typeof maxPages === "number" && maxPages > 0) asked.maxPages = maxPages;
|
|
1278
1278
|
const result = await fetcher.resolve(asked, { signal });
|
|
1279
1279
|
if (result?.error) errors[name] = result.error;
|