@uniweb/build 1.15.3 → 1.15.4
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 +7 -7
- package/src/prerender.js +26 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/build",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.4",
|
|
4
4
|
"description": "Build tooling for the Uniweb Component Web Platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -56,15 +56,15 @@
|
|
|
56
56
|
"js-yaml": "^4.3.2",
|
|
57
57
|
"sharp": "^0.35.5",
|
|
58
58
|
"yaml": "^2.5.0",
|
|
59
|
-
"@uniweb/
|
|
60
|
-
"@uniweb/semantic-parser": "~1.13.2",
|
|
61
|
-
"@uniweb/content-writer": "~1.3.1",
|
|
59
|
+
"@uniweb/schemas": "~1.6.7",
|
|
62
60
|
"@uniweb/content-reader": "~1.5.8",
|
|
63
61
|
"@uniweb/theming": "~1.2.1",
|
|
64
|
-
"@uniweb/
|
|
62
|
+
"@uniweb/content-writer": "~1.3.1",
|
|
63
|
+
"@uniweb/semantic-parser": "~1.13.2",
|
|
64
|
+
"@uniweb/projections": "~1.2.11"
|
|
65
65
|
},
|
|
66
66
|
"optionalDependencies": {
|
|
67
|
-
"@uniweb/runtime": "~1.4.
|
|
67
|
+
"@uniweb/runtime": "~1.4.5"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@tailwindcss/vite": "^4.0.0",
|
|
74
74
|
"@vitejs/plugin-react": "^4.0.0 || ^5.0.0",
|
|
75
75
|
"vite-plugin-svgr": "^4.0.0",
|
|
76
|
-
"@uniweb/runtime": "~1.4.
|
|
76
|
+
"@uniweb/runtime": "~1.4.5",
|
|
77
77
|
"@uniweb/core": "~1.6.4"
|
|
78
78
|
},
|
|
79
79
|
"peerDependenciesMeta": {
|
package/src/prerender.js
CHANGED
|
@@ -685,6 +685,17 @@ function dedupeByAddress(entries) {
|
|
|
685
685
|
return out
|
|
686
686
|
}
|
|
687
687
|
|
|
688
|
+
/** The icons a page's HTML already carries in `__ICON_CACHE__`, by key; none when it carries none. */
|
|
689
|
+
function embeddedIcons(html) {
|
|
690
|
+
const script = html.match(/<script[^>]*id="__ICON_CACHE__"[^>]*>([\s\S]*?)<\/script>/)
|
|
691
|
+
if (!script) return {}
|
|
692
|
+
try {
|
|
693
|
+
return JSON.parse(script[1])
|
|
694
|
+
} catch {
|
|
695
|
+
return {}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
688
699
|
/**
|
|
689
700
|
* Inject build-specific data into HTML (theme CSS, __SITE_CONTENT__, icon cache).
|
|
690
701
|
* Called after the shared injectPageContent for build-specific additions.
|
|
@@ -760,9 +771,16 @@ export function injectBuildData(html, siteContent, { splitContent = false, curre
|
|
|
760
771
|
)
|
|
761
772
|
}
|
|
762
773
|
|
|
763
|
-
//
|
|
774
|
+
// ⭐ THE PAGE'S ICONS, so the browser draws them without fetching: the site's content icons,
|
|
775
|
+
// which every page embeds so the next page a visit opens has them too, and whatever else this
|
|
776
|
+
// page drew, which its render wrote here (`injectPageContent`): a link's icon, a param's, a
|
|
777
|
+
// record's. Those follow in key order, so a build writes the same page every time. Replacing the
|
|
778
|
+
// render's copy instead would blank them in the browser's first render.
|
|
764
779
|
if (siteContent._iconCache) {
|
|
765
|
-
const
|
|
780
|
+
const icons = { ...siteContent._iconCache }
|
|
781
|
+
const drawn = embeddedIcons(result)
|
|
782
|
+
for (const key of Object.keys(drawn).sort()) if (!(key in icons)) icons[key] = drawn[key]
|
|
783
|
+
const iconScript = `<script id="__ICON_CACHE__" type="application/json">${jsonForScript(icons)}</script>`
|
|
766
784
|
if (result.includes('__ICON_CACHE__')) {
|
|
767
785
|
result = result.replace(
|
|
768
786
|
/<script[^>]*id="__ICON_CACHE__"[^>]*>[\s\S]*?<\/script>/,
|
|
@@ -1110,8 +1128,12 @@ export async function prerenderSite(siteDir, options = {}) {
|
|
|
1110
1128
|
fetch: fileTransport,
|
|
1111
1129
|
prerender: 'author',
|
|
1112
1130
|
cache: buildDataCache,
|
|
1113
|
-
//
|
|
1114
|
-
icons:
|
|
1131
|
+
// ⭐ The icons the site names for this page beyond the ones `prefetchIcons` already holds,
|
|
1132
|
+
// the image icons of the whole site's content: a link's icon, a param's, a tagged data
|
|
1133
|
+
// block's, a record's. One the graph holds is not asked again, so a build fetches each
|
|
1134
|
+
// icon once. ⛔ Until 2026-11-04 this said `false`, and every such icon was a blank box in
|
|
1135
|
+
// the built page until the browser fetched it.
|
|
1136
|
+
icons: true,
|
|
1115
1137
|
})
|
|
1116
1138
|
// Filed under this page, the way a route-bound view always has been: `scopeFetchedData`
|
|
1117
1139
|
// embeds it in this page's HTML and nowhere else, and one address embedded twice collapses.
|