@uniweb/core 1.6.15 → 1.6.16
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/package.json +3 -3
- package/src/page-data.js +36 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/core",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.16",
|
|
4
4
|
"description": "Core classes for the Uniweb platform - Uniweb, Website, Page, Block",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"vitest": "^4.1.7"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@uniweb/
|
|
57
|
-
"@uniweb/
|
|
56
|
+
"@uniweb/semantic-parser": "~1.13.6",
|
|
57
|
+
"@uniweb/theming": "~1.3.3"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"test": "vitest run"
|
package/src/page-data.js
CHANGED
|
@@ -92,9 +92,13 @@ export function blockFills({ declared, levels, holds = {}, queries = null, optio
|
|
|
92
92
|
const out = new Map()
|
|
93
93
|
if (!declared || declared.length === 0) return out
|
|
94
94
|
|
|
95
|
+
// A key the block holds is filled from what it holds (`@uniweb/runtime`'s prepare-props), except a key
|
|
96
|
+
// that expects whole records and holds only briefs — a static build's prerendered list — which is
|
|
97
|
+
// planned, so its records are completed whole (`keyProgram`).
|
|
98
|
+
const wholeKeys = new Set(declared.filter(([, , whole]) => whole === true).map(([key]) => key))
|
|
95
99
|
const fills = fillDeclaredKeys(declared, levels, {
|
|
96
100
|
queries,
|
|
97
|
-
held: declared.map(([key]) => key).filter((key) => holds[key] !== undefined),
|
|
101
|
+
held: declared.map(([key]) => key).filter((key) => holds[key] !== undefined && !(wholeKeys.has(key) && isBriefList(holds[key]))),
|
|
98
102
|
})
|
|
99
103
|
// where the first fetch of each key reaching the block sits — the one a held answer belongs to
|
|
100
104
|
const firstOfKey = new Map()
|
|
@@ -390,8 +394,6 @@ export function* keyProgram(cfg, { dynamicContext = null, route = null, held = u
|
|
|
390
394
|
const maybe = (request) => (opportunistic ? { request, optional: true } : request)
|
|
391
395
|
/** A step answered from what is held, on both drivers: never dispatched, `{ missing: true }` when not held. */
|
|
392
396
|
const fromHeld = (request) => ({ request, held: true })
|
|
393
|
-
// The block holds this fetch's answer already — a static build prerendered it.
|
|
394
|
-
if (held !== undefined) return { value: held }
|
|
395
397
|
|
|
396
398
|
// ⭐ WHOLE OR BRIEF IS A QUESTION ABOUT RECORDS OF A DATA SCHEMA — the records service's, or a
|
|
397
399
|
// compiled query's. An external query's records have none, so they have no brief: a list is what
|
|
@@ -409,6 +411,18 @@ export function* keyProgram(cfg, { dynamicContext = null, route = null, held = u
|
|
|
409
411
|
const listed = single ? firstOnly(cfg) : cfg
|
|
410
412
|
const cut = (data) => (single && Array.isArray(data) ? data.slice(0, 1) : data)
|
|
411
413
|
|
|
414
|
+
// The block holds this fetch's answer already — a static build prerendered it, as its compiled list
|
|
415
|
+
// holds it: briefs. ⭐ A key that expects whole records takes those briefs as the set to complete,
|
|
416
|
+
// each record asked for whole by its own request, as an answer fetched here is completed below; a
|
|
417
|
+
// held answer that is not a list of briefs (records already whole, or anything without a handle) is
|
|
418
|
+
// the answer as it is. ⛔ Until 2026-11-23 the held list was the answer whatever the key expected, so
|
|
419
|
+
// a section showing one record whole by its own fetch got the record's card and no body, on a
|
|
420
|
+
// static build only.
|
|
421
|
+
if (held !== undefined) {
|
|
422
|
+
if (whole && isBriefList(held)) return yield* wholeRecordsOf(cfg, cut(held))
|
|
423
|
+
return { value: held }
|
|
424
|
+
}
|
|
425
|
+
|
|
412
426
|
if (current === 'exclude') {
|
|
413
427
|
// The query's records without this page's, its `limit` counting the others.
|
|
414
428
|
const view = othersView(listed)
|
|
@@ -560,6 +574,25 @@ function* ownRecord(cfg, dynamicContext, match, peekRecord, maybe) {
|
|
|
560
574
|
* @param {*} records - the list's answer
|
|
561
575
|
* @returns {Generator<Object[], { value?: *, error?: string, errorConfig?: Object }>}
|
|
562
576
|
*/
|
|
577
|
+
/** A record as a list holds it: its card, with its handle, not yet asked for whole (`{ brief, body }`). */
|
|
578
|
+
function isBrief(record) {
|
|
579
|
+
return !!record && typeof record === 'object' && !Array.isArray(record) &&
|
|
580
|
+
record.$name !== undefined && record.$name !== null && record.$name !== '' &&
|
|
581
|
+
record.brief === undefined && record.body === undefined
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Whether a held value is a list of briefs: what a static build prerenders for a fetch, which a key
|
|
586
|
+
* expecting whole records completes rather than takes. Records already whole, a tagged data block, or
|
|
587
|
+
* anything without a handle is not.
|
|
588
|
+
*
|
|
589
|
+
* @param {*} value
|
|
590
|
+
* @returns {boolean}
|
|
591
|
+
*/
|
|
592
|
+
export function isBriefList(value) {
|
|
593
|
+
return Array.isArray(value) && value.length > 0 && value.every(isBrief)
|
|
594
|
+
}
|
|
595
|
+
|
|
563
596
|
function* wholeRecordsOf(cfg, records) {
|
|
564
597
|
if (!Array.isArray(records)) return { value: null }
|
|
565
598
|
if (records.length === 0) return { value: [] }
|