@uniweb/core 1.3.2 → 1.4.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/package.json +6 -3
- package/src/block.js +45 -10
- package/src/data-script.js +82 -0
- package/src/page-shell.js +128 -0
- package/src/page.js +30 -15
- package/src/section-type.js +31 -0
- package/src/website.js +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Core classes for the Uniweb platform - Uniweb, Website, Page, Block",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -8,18 +8,21 @@
|
|
|
8
8
|
"./base-path": "./src/base-path.js",
|
|
9
9
|
"./records-service": "./src/records-service.js",
|
|
10
10
|
"./data-paths": "./src/data-paths.js",
|
|
11
|
+
"./data-script": "./src/data-script.js",
|
|
11
12
|
"./data-keys": "./src/data-keys.js",
|
|
12
13
|
"./datastore": "./src/datastore.js",
|
|
13
14
|
"./detail-url": "./src/detail-url.js",
|
|
14
15
|
"./fetch-config": "./src/fetch-config.js",
|
|
15
16
|
"./layout-name": "./src/layout-name.js",
|
|
16
17
|
"./page-data": "./src/page-data.js",
|
|
18
|
+
"./page-shell": "./src/page-shell.js",
|
|
17
19
|
"./icon-corpus": "./src/icon-corpus.js",
|
|
18
20
|
"./insets": "./src/insets.js",
|
|
19
21
|
"./locale-config": "./src/locale-config.js",
|
|
20
22
|
"./route-match": "./src/route-match.js",
|
|
21
23
|
"./resolve-route": "./src/resolve-route.js",
|
|
22
24
|
"./section-id": "./src/section-id.js",
|
|
25
|
+
"./section-type": "./src/section-type.js",
|
|
23
26
|
"./services": "./src/services.js",
|
|
24
27
|
"./sort": "./src/sort.js",
|
|
25
28
|
"./tracker": "./src/tracker.js",
|
|
@@ -49,8 +52,8 @@
|
|
|
49
52
|
"vitest": "^4.1.7"
|
|
50
53
|
},
|
|
51
54
|
"dependencies": {
|
|
52
|
-
"@uniweb/
|
|
53
|
-
"@uniweb/
|
|
55
|
+
"@uniweb/semantic-parser": "~1.12.2",
|
|
56
|
+
"@uniweb/theming": "~1.2.1"
|
|
54
57
|
},
|
|
55
58
|
"scripts": {
|
|
56
59
|
"test": "vitest run"
|
package/src/block.js
CHANGED
|
@@ -74,22 +74,34 @@ export default class Block {
|
|
|
74
74
|
const blockConfig = blockData.params || blockData.config || {}
|
|
75
75
|
|
|
76
76
|
// ⭐ THE SECTION'S OWN SETTINGS — the names framework reserves in its params
|
|
77
|
-
// (`@uniweb/schemas/section`): `theme`, `background`, `grid`, `vars`, `fetch`.
|
|
78
|
-
// each — the runtime paints the background and the color context around
|
|
79
|
-
// the
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
// 2026-09-28]. It reads them from the
|
|
83
|
-
// also received `theme` (the mode),
|
|
84
|
-
// them there. ⛔ An editor's older
|
|
85
|
-
// — is no longer read
|
|
86
|
-
//
|
|
77
|
+
// (`@uniweb/schemas/section`): `theme`, `background`, `grid`, `vars`, `fetch`, `sticky`.
|
|
78
|
+
// Framework applies each — the runtime paints the background and the color context around
|
|
79
|
+
// the component and makes sticky the box that can stick, the page stylesheet applies the
|
|
80
|
+
// section's theme and its component's variables, kit's `ChildGrid` lays out the child
|
|
81
|
+
// sections — so each is lifted onto the block, normalized once for every renderer, and a
|
|
82
|
+
// component NEVER receives one as a param [Diego, 2026-09-28]. It reads them from the
|
|
83
|
+
// block, or through kit. ⛔ Until then a component also received `theme` (the mode),
|
|
84
|
+
// `background` and `vars` as params, and nothing read them there. ⛔ An editor's older
|
|
85
|
+
// envelope — `params.standardOptions` and `params.properties` — is no longer read
|
|
86
|
+
// (2026-09-28): an editor's preview sends a section's params as stored, and no store
|
|
87
|
+
// publishes the envelope. Either name is an ordinary param now.
|
|
87
88
|
const {
|
|
88
89
|
theme: rawTheme, background: rawBg, grid: gridParam, vars: varsParam, fetch: fetchParam,
|
|
90
|
+
sticky: stickyParam,
|
|
89
91
|
...componentParams
|
|
90
92
|
} = blockConfig
|
|
91
93
|
this.properties = componentParams
|
|
92
94
|
|
|
95
|
+
// Whether the section stays in view as the page scrolls — what the author wrote (`true` or
|
|
96
|
+
// `false`; anything else is no answer), else its type's default from `meta.js`, which
|
|
97
|
+
// `initComponent` reads, else not. The runtime applies it to the box that can stick: a
|
|
98
|
+
// component's own markup sits in boxes as tall as itself, where `sticky` cannot move
|
|
99
|
+
// (2026-10-19).
|
|
100
|
+
this.stickySetting = typeof stickyParam === 'boolean' ? stickyParam : null
|
|
101
|
+
this.sticky = this.stickySetting ?? false
|
|
102
|
+
// How far below the top it stays — its type's `top`, a CSS length; null is the very top.
|
|
103
|
+
this.stickyTop = null
|
|
104
|
+
|
|
93
105
|
// The section's theme: `theme.yml`'s own keys scoped to the section — `colors`,
|
|
94
106
|
// `contexts`, `vars` — plus `mode`, the color context it pins. `theme: dark` is the
|
|
95
107
|
// shorthand for `{ mode: dark }`, and a token written beside `mode` applies to the section
|
|
@@ -506,9 +518,32 @@ export default class Block {
|
|
|
506
518
|
this.componentVars = Block.mergeComponentVars(meta.vars, this.sectionVars)
|
|
507
519
|
}
|
|
508
520
|
|
|
521
|
+
// The type's `sticky`: `true`, or `{ default, top }` — the author's value wins.
|
|
522
|
+
const sticky = Block.normalizeStickyDeclaration(meta.sticky)
|
|
523
|
+
this.sticky = this.stickySetting ?? sticky.default
|
|
524
|
+
this.stickyTop = sticky.top
|
|
525
|
+
|
|
509
526
|
return this.Component
|
|
510
527
|
}
|
|
511
528
|
|
|
529
|
+
/**
|
|
530
|
+
* A section type's `sticky` declaration, as `meta.js` may write it: `true` or `false`, or
|
|
531
|
+
* `{ default, top }` — `top` a CSS length, for a type that sits below another sticking
|
|
532
|
+
* element.
|
|
533
|
+
*
|
|
534
|
+
* @param {*} declared
|
|
535
|
+
* @returns {{ default: boolean, top: string|null }}
|
|
536
|
+
*/
|
|
537
|
+
static normalizeStickyDeclaration(declared) {
|
|
538
|
+
if (declared && typeof declared === 'object') {
|
|
539
|
+
return {
|
|
540
|
+
default: declared.default === true,
|
|
541
|
+
top: typeof declared.top === 'string' && declared.top.trim() ? declared.top.trim() : null,
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return { default: declared === true, top: null }
|
|
545
|
+
}
|
|
546
|
+
|
|
512
547
|
/**
|
|
513
548
|
* Get block properties
|
|
514
549
|
*/
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The data a page's shell carries — the ONE rule for writing it, for every lane that writes a
|
|
3
|
+
* shell: a static build (`__SITE_CONTENT__`) and a host that assembles one per request
|
|
4
|
+
* (`__DATA__`, `{ foundation, content }`, which the runtime reads in `decodeData`).
|
|
5
|
+
*
|
|
6
|
+
* Two jobs, both easy to get subtly wrong in a copy:
|
|
7
|
+
*
|
|
8
|
+
* 1. ⭐ JSON INSIDE A `<script>` ESCAPES EVERY `<` AS `<`. A `<script>` element's text ends at
|
|
9
|
+
* `</script` and changes state at `<!--`, so either inside a string value would break the page;
|
|
10
|
+
* `<` is a JSON escape, so the text still parses as the same value. ⛔ A JavaScript-string
|
|
11
|
+
* escape is not a JSON one: `<\!--` keeps the HTML parser calm and makes the whole payload
|
|
12
|
+
* invalid JSON. Measured 2026-10-23 on a hosted site, whose every page then stayed its server
|
|
13
|
+
* render with no client app.
|
|
14
|
+
*
|
|
15
|
+
* 2. ⭐ SPLIT CONTENT CARRIES ONE PAGE'S SECTIONS. When a site's content is split, a page's data
|
|
16
|
+
* keeps every page's entry but only its own sections and every dynamic template's, which a
|
|
17
|
+
* route's record page is built from. Every other page's sections are fetched when the page is
|
|
18
|
+
* visited (`Page.loadContent`), from the address `config.pageHashes[locale][route]` names on a
|
|
19
|
+
* host, or `_pages/<route>.json` in a static build. A page whose sections leave says
|
|
20
|
+
* `hasContent`, so it is not taken for an empty folder.
|
|
21
|
+
*
|
|
22
|
+
* Zero-dependency leaf: the build imports it, and a host reaches it through `@uniweb/runtime/ssr`.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A value as JSON text that can sit inside a `<script>` element: every `<` as `<`.
|
|
27
|
+
*
|
|
28
|
+
* @param {*} value
|
|
29
|
+
* @returns {string}
|
|
30
|
+
*/
|
|
31
|
+
export function jsonForScript(value) {
|
|
32
|
+
return JSON.stringify(value).replace(/</g, '\\u003c')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The pages a split page's data carries: every entry, with sections only for the page being served
|
|
37
|
+
* and for every dynamic template. A page whose sections leave says `hasContent`.
|
|
38
|
+
*
|
|
39
|
+
* @param {Array<Object>} pages - the site content's `pages`
|
|
40
|
+
* @param {string|null} route - the route of the page being served
|
|
41
|
+
* @param {Object} [options]
|
|
42
|
+
* @param {(page: Object) => boolean} [options.fetchable] - whether a page's sections can be fetched
|
|
43
|
+
* when it is visited; a page whose cannot keeps them inline
|
|
44
|
+
* @returns {Array<Object>}
|
|
45
|
+
*/
|
|
46
|
+
export function splitPageSections(pages, route, { fetchable = () => true } = {}) {
|
|
47
|
+
return pages.map((page) => {
|
|
48
|
+
if (page.route === route || page.isDynamic || !Array.isArray(page.sections) || !fetchable(page)) {
|
|
49
|
+
return page
|
|
50
|
+
}
|
|
51
|
+
const { sections, ...entry } = page
|
|
52
|
+
return { ...entry, hasContent: entry.hasContent ?? sections.length > 0 }
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The `<script id="__DATA__">` element a host writes into a page's shell — the boot payload
|
|
58
|
+
* `{ foundation, content }`, as JSON a `<script>` cannot end or misparse (`jsonForScript`).
|
|
59
|
+
*
|
|
60
|
+
* When the content names where each page's sections are served — `content.config.pageHashes`,
|
|
61
|
+
* per locale — it carries only the served page's sections and every dynamic template's
|
|
62
|
+
* (`splitPageSections`); a page with no address keeps its sections inline. Without that map it
|
|
63
|
+
* carries the content as it is.
|
|
64
|
+
*
|
|
65
|
+
* @param {{ foundation: Object, content: Object }} data
|
|
66
|
+
* @param {Object} [options]
|
|
67
|
+
* @param {string} [options.route] - the route of the page being served, as the content names it (a
|
|
68
|
+
* dynamic page's own template route for one of its records)
|
|
69
|
+
* @param {string} [options.locale] - the locale the content is for; by default its `activeLocale`
|
|
70
|
+
* @returns {string}
|
|
71
|
+
*/
|
|
72
|
+
export function dataScript({ foundation, content }, { route = null, locale } = {}) {
|
|
73
|
+
const addresses = content?.config?.pageHashes?.[locale ?? content?.config?.activeLocale]
|
|
74
|
+
const carried =
|
|
75
|
+
addresses && Array.isArray(content.pages)
|
|
76
|
+
? {
|
|
77
|
+
...content,
|
|
78
|
+
pages: splitPageSections(content.pages, route, { fetchable: (page) => Boolean(addresses[page.route]) }),
|
|
79
|
+
}
|
|
80
|
+
: content
|
|
81
|
+
return `<script id="__DATA__" type="application/json">${jsonForScript({ foundation, content: carried })}</script>`
|
|
82
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A page's shell — the ONE writer of the HTML a page starts as, for a host that assembles pages:
|
|
3
|
+
* the head (charset, viewport, title, icon, the foundation's stylesheet, the runtime's import map,
|
|
4
|
+
* entry and preloads), an empty `#root`, and `__DATA__`. A host calls it through its own link for a
|
|
5
|
+
* page it serves without rendering it, and inside an isolate (`@uniweb/runtime/ssr` re-exports it,
|
|
6
|
+
* versioned with the runtime) as the shell `createPageRenderer` renders into.
|
|
7
|
+
*
|
|
8
|
+
* ⭐ Page assembly is framework's [Diego, 2026-10-23: a host is "supposed to do hosting right,
|
|
9
|
+
* not rendering or page assembling. That's our job."]. A host hands in what only it knows — the
|
|
10
|
+
* addresses it resolved and the content it read — and serves what comes back. ⛔ Until then each
|
|
11
|
+
* host wrote its own shell, and one escaped `__DATA__` its own way, as invalid JSON, so no page
|
|
12
|
+
* of the site it served could start.
|
|
13
|
+
*
|
|
14
|
+
* Its output is a function of its inputs only — no request, no clock — because a host caches it
|
|
15
|
+
* under a key of publish-time facts, one entry serving a site's every hostname.
|
|
16
|
+
*
|
|
17
|
+
* Zero-dependency leaf, like `data-script.js`, which writes its `__DATA__`.
|
|
18
|
+
*/
|
|
19
|
+
import { dataScript, jsonForScript } from './data-script.js'
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Escape a string for HTML text or a double-quoted attribute value.
|
|
23
|
+
*
|
|
24
|
+
* @param {*} str
|
|
25
|
+
* @returns {string}
|
|
26
|
+
*/
|
|
27
|
+
export function escapeHtml(str) {
|
|
28
|
+
if (!str) return ''
|
|
29
|
+
return String(str)
|
|
30
|
+
.replace(/&/g, '&')
|
|
31
|
+
.replace(/</g, '<')
|
|
32
|
+
.replace(/>/g, '>')
|
|
33
|
+
.replace(/"/g, '"')
|
|
34
|
+
.replace(/'/g, ''')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The MIME type of a favicon, by its file's extension — or null when unknown, and the `type`
|
|
39
|
+
* attribute is then left out.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} href
|
|
42
|
+
* @returns {string|null}
|
|
43
|
+
*/
|
|
44
|
+
export function faviconType(href) {
|
|
45
|
+
const ext = String(href || '').split('?')[0].split('.').pop()?.toLowerCase()
|
|
46
|
+
if (ext === 'svg') return 'image/svg+xml'
|
|
47
|
+
if (ext === 'ico') return 'image/x-icon'
|
|
48
|
+
if (ext === 'png') return 'image/png'
|
|
49
|
+
return null
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A foundation's stylesheet, by the convention every foundation build follows: `…/entry.js` →
|
|
54
|
+
* `…/assets/style.css`. The runtime's loader derives an extension's the same way.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} url - the foundation's (or an extension's) entry
|
|
57
|
+
* @returns {string|null}
|
|
58
|
+
*/
|
|
59
|
+
export function foundationCssUrl(url) {
|
|
60
|
+
return typeof url === 'string' && url ? url.replace(/[^/]+\.js$/, 'assets/style.css') : null
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** A runtime file's address: its path in the manifest, on the runtime's base. */
|
|
64
|
+
function onBase(base, path) {
|
|
65
|
+
return `${base.endsWith('/') ? base : `${base}/`}${String(path).replace(/^\/+/, '')}`
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const extensionUrl = (entry) => (typeof entry === 'string' ? entry : entry?.url) || null
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The HTML a page starts as.
|
|
72
|
+
*
|
|
73
|
+
* @param {Object} input
|
|
74
|
+
* @param {Object} input.content - one locale's content as the host stamped it: `config` (`name`,
|
|
75
|
+
* `favicon`, `activeLocale`, `extensions` — each extension's entry URL, in declared order), the
|
|
76
|
+
* pages, and any `fetchedData`
|
|
77
|
+
* @param {string} [input.route] - the served page's route as the content names it, so a split
|
|
78
|
+
* site's `__DATA__` carries that page's sections (`dataScript`)
|
|
79
|
+
* @param {{ url: string, cssUrl?: string }} input.foundation - the foundation's entry; its
|
|
80
|
+
* stylesheet is `foundationCssUrl(url)` unless given
|
|
81
|
+
* @param {{ base: string, manifest: { entry: string, preloads?: string[], importMap?: Object } }}
|
|
82
|
+
* input.runtime - the runtime's base address, absolute, and its `manifest.json`
|
|
83
|
+
* @returns {string}
|
|
84
|
+
*/
|
|
85
|
+
export function pageShell({ content, route = null, foundation, runtime }) {
|
|
86
|
+
const config = content?.config || {}
|
|
87
|
+
const manifest = runtime?.manifest || {}
|
|
88
|
+
const base = runtime?.base || ''
|
|
89
|
+
const cssUrl = foundation?.cssUrl || foundationCssUrl(foundation?.url)
|
|
90
|
+
const extensions = (Array.isArray(config.extensions) ? config.extensions : []).map(extensionUrl).filter(Boolean)
|
|
91
|
+
const importMap = Object.fromEntries(
|
|
92
|
+
Object.entries(manifest.importMap || {}).map(([specifier, path]) => [specifier, onBase(base, path)])
|
|
93
|
+
)
|
|
94
|
+
const preloads = [
|
|
95
|
+
...(Array.isArray(manifest.preloads) ? manifest.preloads : []).map((path) => onBase(base, path)),
|
|
96
|
+
foundation?.url,
|
|
97
|
+
...extensions,
|
|
98
|
+
].filter(Boolean)
|
|
99
|
+
const lang = config.activeLocale
|
|
100
|
+
|
|
101
|
+
const head = [
|
|
102
|
+
'<meta charset="UTF-8">',
|
|
103
|
+
'<meta name="viewport" content="width=device-width, initial-scale=1.0">',
|
|
104
|
+
config.name ? `<title>${escapeHtml(config.name)}</title>` : null,
|
|
105
|
+
config.favicon
|
|
106
|
+
? `<link rel="icon"${faviconType(config.favicon) ? ` type="${faviconType(config.favicon)}"` : ''} href="${escapeHtml(config.favicon)}">`
|
|
107
|
+
: null,
|
|
108
|
+
cssUrl ? `<link rel="stylesheet" href="${escapeHtml(cssUrl)}">` : null,
|
|
109
|
+
// Before the module script and every preload: a browser reads an import map only ahead of them.
|
|
110
|
+
`<script type="importmap">${jsonForScript({ imports: importMap })}</script>`,
|
|
111
|
+
manifest.entry ? `<script type="module" crossorigin src="${escapeHtml(onBase(base, manifest.entry))}"></script>` : null,
|
|
112
|
+
...preloads.map((href) => `<link rel="modulepreload" crossorigin href="${escapeHtml(href)}">`),
|
|
113
|
+
].filter(Boolean)
|
|
114
|
+
|
|
115
|
+
return [
|
|
116
|
+
'<!DOCTYPE html>',
|
|
117
|
+
lang ? `<html lang="${escapeHtml(lang)}">` : '<html>',
|
|
118
|
+
'<head>',
|
|
119
|
+
...head,
|
|
120
|
+
'</head>',
|
|
121
|
+
'<body>',
|
|
122
|
+
'<div id="root"></div>',
|
|
123
|
+
dataScript({ foundation: { url: foundation?.url, cssUrl }, content }, { route, locale: lang }),
|
|
124
|
+
'</body>',
|
|
125
|
+
'</html>',
|
|
126
|
+
'',
|
|
127
|
+
].join('\n')
|
|
128
|
+
}
|
package/src/page.js
CHANGED
|
@@ -376,6 +376,20 @@ export default class Page {
|
|
|
376
376
|
return result
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
+
/**
|
|
380
|
+
* Whether a layout area stays in view as the page scrolls: any of its sections is sticky
|
|
381
|
+
* (`sticky:`, a setting of the section). The runtime makes sticky the box it gives the area;
|
|
382
|
+
* a layout that wraps the area in an element of its own makes THAT element sticky when this
|
|
383
|
+
* is true, since a box sticks only within its parent, and the area's sits in the layout's.
|
|
384
|
+
*
|
|
385
|
+
* @param {string} areaName
|
|
386
|
+
* @returns {boolean}
|
|
387
|
+
*/
|
|
388
|
+
isSticky(areaName) {
|
|
389
|
+
const blocks = this.getLayoutAreas()[areaName]
|
|
390
|
+
return Array.isArray(blocks) && blocks.some((block) => block.sticky)
|
|
391
|
+
}
|
|
392
|
+
|
|
379
393
|
/**
|
|
380
394
|
* Get layout params for this page (merged with defaults at render time)
|
|
381
395
|
* @returns {Object}
|
|
@@ -524,10 +538,11 @@ export default class Page {
|
|
|
524
538
|
const lang = this.website.activeLocale
|
|
525
539
|
const defaultLang = this.website.defaultLocale
|
|
526
540
|
|
|
527
|
-
//
|
|
528
|
-
//
|
|
529
|
-
//
|
|
530
|
-
//
|
|
541
|
+
// A host that splits a site's content names each page's address in
|
|
542
|
+
// `config.pageHashes`, and that address wins. Without one, the static
|
|
543
|
+
// build's own layout: `/{lang}/_pages/{route}.json` beside the site
|
|
544
|
+
// (`build/src/prerender.js`). ⛔ This called that layout "legacy", for
|
|
545
|
+
// sites that had not republished, until 2026-10-24.
|
|
531
546
|
const hashes = this.website.config?.pageHashes
|
|
532
547
|
const hashedUrl = hashes?.[lang]?.[this.route]
|
|
533
548
|
|
|
@@ -542,10 +557,10 @@ export default class Page {
|
|
|
542
557
|
|
|
543
558
|
const res = await fetch(url)
|
|
544
559
|
if (res.status === 404 && _shouldReloadOnHashed404(hashedUrl)) {
|
|
545
|
-
// Stale tab: this tab's __DATA__
|
|
546
|
-
// no longer
|
|
560
|
+
// Stale tab: this tab's `__DATA__` names the addresses of a publish
|
|
561
|
+
// the host no longer serves. One reload usually picks up the fresh
|
|
547
562
|
// HTML (and a fresh map). Capped at 2 attempts to defend against
|
|
548
|
-
// a
|
|
563
|
+
// a publish whose new HTML and new addresses also disagree.
|
|
549
564
|
window.location.reload()
|
|
550
565
|
return
|
|
551
566
|
}
|
|
@@ -744,14 +759,14 @@ export default class Page {
|
|
|
744
759
|
/**
|
|
745
760
|
* Helper for the stale-tab 404→reload guard in Page.loadContent.
|
|
746
761
|
*
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
*
|
|
751
|
-
*
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
762
|
+
* A host's split content is content-addressed (`config.pageHashes`), and a
|
|
763
|
+
* publish replaces the addresses. A browser tab loaded against a previous
|
|
764
|
+
* publish carries a stale map; on SPA navigation it requests an address that
|
|
765
|
+
* is no longer served. Reloading the tab pulls fresh HTML (and a fresh map).
|
|
766
|
+
* The session-scoped counter caps reloads at 2 so a publish whose new HTML and
|
|
767
|
+
* new addresses disagree doesn't trigger an infinite loop. After 2 failed
|
|
768
|
+
* reloads the page is marked empty with a warning, as any other failed fetch
|
|
769
|
+
* is. ⛔ This said it rendered "the synthetic 404 path" until 2026-10-24.
|
|
755
770
|
*
|
|
756
771
|
* Only fires when the request was a hashed URL: legacy non-hashed 404s
|
|
757
772
|
* keep the prior "mark empty, log warning" behavior (they're not symptomatic
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Section types — the ONE rule for what renders a section that names none.
|
|
3
|
+
*
|
|
4
|
+
* A section names the section type that renders it (`type: Hero` in its file's
|
|
5
|
+
* frontmatter). One that names none renders with the foundation's `defaultSection`,
|
|
6
|
+
* else `Section`. The site's object graph asks this when it builds a Block
|
|
7
|
+
* (`Website.getDefaultBlockType`), and a push asks it for the type a store requires
|
|
8
|
+
* of every section — so a host rendering what the store holds renders what the
|
|
9
|
+
* site's files render. ⛔ Until 2026-10-23 a push sent `Content` for such a section,
|
|
10
|
+
* which no starter template's foundation has, and a hosted page showed
|
|
11
|
+
* "Component not found: Content" where the files rendered `Section`.
|
|
12
|
+
*
|
|
13
|
+
* Zero-dependency leaf, like `layout-name.js`: the build imports it, and should not
|
|
14
|
+
* pull more of core to agree on a type.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** What renders a section when neither it nor its foundation names a type. */
|
|
18
|
+
export const DEFAULT_SECTION_TYPE = 'Section'
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The type a section that names none renders with: the foundation's
|
|
22
|
+
* `defaultSection`, else `Section`.
|
|
23
|
+
*
|
|
24
|
+
* @param {Object|null|undefined} foundation - the foundation's declarations: its
|
|
25
|
+
* `main.js` default export, its schema's `_self`, or the runtime's foundation config
|
|
26
|
+
* @returns {string}
|
|
27
|
+
*/
|
|
28
|
+
export function defaultSectionType(foundation) {
|
|
29
|
+
const declared = foundation?.defaultSection
|
|
30
|
+
return typeof declared === 'string' && declared ? declared : DEFAULT_SECTION_TYPE
|
|
31
|
+
}
|
package/src/website.js
CHANGED
|
@@ -16,6 +16,7 @@ import { resolveFetchConfigs, pageRouteQuery, recordPages } from './fetch-config
|
|
|
16
16
|
import { declaredKeys } from './data-keys.js'
|
|
17
17
|
import { pageRecordConfig, planFor, runPlanSync } from './page-data.js'
|
|
18
18
|
import { findLayoutEntry } from './layout-name.js'
|
|
19
|
+
import { defaultSectionType } from './section-type.js'
|
|
19
20
|
import { resolveService } from './services.js'
|
|
20
21
|
import {
|
|
21
22
|
routeIndex,
|
|
@@ -709,10 +710,11 @@ export default class Website {
|
|
|
709
710
|
}
|
|
710
711
|
|
|
711
712
|
/**
|
|
712
|
-
*
|
|
713
|
+
* The type a section that names none renders with — the foundation's
|
|
714
|
+
* `defaultSection`, else `Section` (`section-type.js`, the rule a push fills by too).
|
|
713
715
|
*/
|
|
714
716
|
getDefaultBlockType() {
|
|
715
|
-
return globalThis.uniweb?.foundationConfig
|
|
717
|
+
return defaultSectionType(globalThis.uniweb?.foundationConfig)
|
|
716
718
|
}
|
|
717
719
|
|
|
718
720
|
// ─────────────────────────────────────────────────────────────────
|