@uniweb/runtime 0.6.14 → 0.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/dist/ssr.js +42 -6
- package/dist/ssr.js.map +1 -1
- package/package.json +9 -5
- package/src/components/BlockRenderer.jsx +1 -0
- package/src/components/Layout.jsx +3 -3
- package/src/components/PageRenderer.jsx +32 -17
- package/src/default-404.js +60 -0
- package/src/foundation-loader.js +3 -0
- package/src/index.jsx +3 -4
- package/src/setup.js +3 -0
- package/src/shell/index.html +12 -0
- package/src/shell/main.js +16 -0
- package/src/ssr-renderer.js +84 -9
- package/src/ssr.js +3 -0
package/dist/ssr.js
CHANGED
|
@@ -126,6 +126,10 @@ function getComponentMeta(componentName) {
|
|
|
126
126
|
function getComponentDefaults(componentName) {
|
|
127
127
|
return globalThis.uniweb?.getComponentDefaults?.(componentName) || {};
|
|
128
128
|
}
|
|
129
|
+
function default404Html(basePath = "") {
|
|
130
|
+
const homeHref = basePath ? `${basePath}/` : "/";
|
|
131
|
+
return `<div class="page-not-found" style="min-height:80vh;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:2rem;text-align:center"><h1 style="font-size:3rem;font-weight:bold;color:#1f2937;margin-bottom:1rem">404</h1><p style="color:#64748b;margin-bottom:2rem">Page not found</p><a href="${homeHref}" style="color:#3b82f6;text-decoration:underline">Go to homepage</a></div>`;
|
|
132
|
+
}
|
|
129
133
|
const VALID_CONTEXTS = ["light", "medium", "dark"];
|
|
130
134
|
function getWrapperProps(block) {
|
|
131
135
|
const theme = block.themeName;
|
|
@@ -276,7 +280,7 @@ function renderBackground(background) {
|
|
|
276
280
|
"aria-hidden": "true"
|
|
277
281
|
}, ...children);
|
|
278
282
|
}
|
|
279
|
-
function renderBlock(block, { pure = false } = {}) {
|
|
283
|
+
function renderBlock(block, { pure = false, as = void 0 } = {}) {
|
|
280
284
|
const Component = block.initComponent();
|
|
281
285
|
if (!Component) {
|
|
282
286
|
return React.createElement("div", {
|
|
@@ -312,7 +316,7 @@ function renderBlock(block, { pure = false } = {}) {
|
|
|
312
316
|
}
|
|
313
317
|
const hasBackground = background?.mode && meta?.background !== "self";
|
|
314
318
|
block.hasBackground = hasBackground;
|
|
315
|
-
const wrapperTag = Component.as || "section";
|
|
319
|
+
const wrapperTag = as !== void 0 && as !== "section" ? as : Component.as || "section";
|
|
316
320
|
if (hasBackground) {
|
|
317
321
|
return React.createElement(
|
|
318
322
|
wrapperTag,
|
|
@@ -385,13 +389,13 @@ function initPrerender(content, foundation, options = {}) {
|
|
|
385
389
|
if (content.config?.base && uniweb.activeWebsite?.setBasePath) {
|
|
386
390
|
uniweb.activeWebsite.setBasePath(content.config.base);
|
|
387
391
|
}
|
|
388
|
-
uniweb.childBlockRenderer = function InlineChildBlocks({ blocks, from, pure = false }) {
|
|
392
|
+
uniweb.childBlockRenderer = function InlineChildBlocks({ blocks, from, pure = false, as = "div" }) {
|
|
389
393
|
const blockList = blocks || from?.childBlocks || [];
|
|
390
394
|
return blockList.map(
|
|
391
395
|
(childBlock, index) => React.createElement(
|
|
392
396
|
React.Fragment,
|
|
393
397
|
{ key: childBlock.id || index },
|
|
394
|
-
renderBlock(childBlock, { pure })
|
|
398
|
+
renderBlock(childBlock, { pure, as })
|
|
395
399
|
)
|
|
396
400
|
);
|
|
397
401
|
};
|
|
@@ -473,10 +477,11 @@ ${options.sectionOverrideCSS}
|
|
|
473
477
|
/<div id="root">[\s\S]*?<\/div>/,
|
|
474
478
|
`<div id="root">${renderedContent}</div>`
|
|
475
479
|
);
|
|
476
|
-
|
|
480
|
+
const pageTitle = page.getTitle?.() || page.title;
|
|
481
|
+
if (pageTitle) {
|
|
477
482
|
result = result.replace(
|
|
478
483
|
/<title>.*?<\/title>/,
|
|
479
|
-
`<title>${escapeHtml(
|
|
484
|
+
`<title>${escapeHtml(pageTitle)}</title>`
|
|
480
485
|
);
|
|
481
486
|
}
|
|
482
487
|
if (page.description) {
|
|
@@ -490,11 +495,42 @@ ${options.sectionOverrideCSS}
|
|
|
490
495
|
}
|
|
491
496
|
return result;
|
|
492
497
|
}
|
|
498
|
+
function generate404Html({ baseHtml, website, siteContent }) {
|
|
499
|
+
const dynamicTemplates = siteContent.pages?.filter((p) => p.isDynamic) || [];
|
|
500
|
+
const routePatterns = dynamicTemplates.map((p) => {
|
|
501
|
+
const escaped = p.route.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/:[^/]+/g, "[^\\/]+");
|
|
502
|
+
return `^${escaped}\\/?$`;
|
|
503
|
+
});
|
|
504
|
+
let html = baseHtml;
|
|
505
|
+
const notFoundPage = website.getNotFoundPage();
|
|
506
|
+
if (notFoundPage) {
|
|
507
|
+
const notFoundResult = renderPage(notFoundPage, website);
|
|
508
|
+
if (notFoundResult && !notFoundResult.error) {
|
|
509
|
+
html = injectPageContent(html, notFoundResult.renderedContent, notFoundPage, {
|
|
510
|
+
sectionOverrideCSS: notFoundResult.sectionOverrideCSS
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
} else {
|
|
514
|
+
const basePath = website.basePath || "";
|
|
515
|
+
html = html.replace(
|
|
516
|
+
/<div id="root">[\s\S]*?<\/div>/,
|
|
517
|
+
`<div id="root">${default404Html(basePath)}</div>`
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
if (routePatterns.length > 0) {
|
|
521
|
+
const patternList = routePatterns.map((p) => `/${p}/`).join(",");
|
|
522
|
+
const dynamicScript = `<script>(function(){var p=[${patternList}],r=window.location.pathname;if(p.some(function(x){return x.test(r)})){var el=document.getElementById('root');if(el)el.innerHTML='';}})()<\/script>`;
|
|
523
|
+
html = html.replace("</body>", `${dynamicScript}
|
|
524
|
+
</body>`);
|
|
525
|
+
}
|
|
526
|
+
return { html, hasNotFoundPage: !!notFoundPage };
|
|
527
|
+
}
|
|
493
528
|
export {
|
|
494
529
|
applyDefaults,
|
|
495
530
|
applySchemas,
|
|
496
531
|
classifyRenderError,
|
|
497
532
|
escapeHtml,
|
|
533
|
+
generate404Html,
|
|
498
534
|
getComponentDefaults,
|
|
499
535
|
getComponentMeta,
|
|
500
536
|
getWrapperProps,
|
package/dist/ssr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr.js","sources":["../src/prepare-props.js","../src/ssr-renderer.js"],"sourcesContent":["/**\n * Props Preparation for Runtime Guarantees\n *\n * Prepares props for foundation components with:\n * - Param defaults from runtime schema\n * - Guaranteed content structure (no null checks needed)\n *\n * This enables simpler component code by ensuring predictable prop shapes.\n */\n\n/**\n * Guarantee item has flat content structure\n *\n * @param {Object} item - Raw item from parser\n * @returns {Object} Item with guaranteed flat structure\n */\nfunction guaranteeItemStructure(item) {\n return {\n title: item.title || '',\n pretitle: item.pretitle || '',\n subtitle: item.subtitle || '',\n paragraphs: item.paragraphs || [],\n links: item.links || [],\n images: item.images || [],\n lists: item.lists || [],\n icons: item.icons || [],\n videos: item.videos || [],\n snippets: item.snippets || [],\n buttons: item.buttons || [],\n data: item.data || {},\n cards: item.cards || [],\n documents: item.documents || [],\n forms: item.forms || [],\n quotes: item.quotes || [],\n headings: item.headings || [],\n }\n}\n\n/**\n * Guarantee content structure exists\n * Returns a flat content object with all standard fields guaranteed to exist\n *\n * @param {Object} parsedContent - Raw parsed content from semantic parser (flat structure)\n * @returns {Object} Content with guaranteed flat structure\n */\nexport function guaranteeContentStructure(parsedContent) {\n const content = parsedContent || {}\n\n return {\n // Flat header fields\n title: content.title || '',\n pretitle: content.pretitle || '',\n subtitle: content.subtitle || '',\n alignment: content.alignment || null,\n\n // Flat body fields\n paragraphs: content.paragraphs || [],\n links: content.links || [],\n images: content.images || [],\n lists: content.lists || [],\n icons: content.icons || [],\n videos: content.videos || [],\n insets: content.insets || [],\n snippets: content.snippets || [],\n buttons: content.buttons || [],\n data: content.data || {},\n cards: content.cards || [],\n documents: content.documents || [],\n forms: content.forms || [],\n quotes: content.quotes || [],\n headings: content.headings || [],\n\n // Items with guaranteed structure\n items: (content.items || []).map(guaranteeItemStructure),\n\n // Sequence for ordered rendering\n sequence: content.sequence || [],\n\n // Preserve raw content if present\n raw: content.raw,\n }\n}\n\n/**\n * Apply a schema to a single object\n * Only processes fields defined in the schema, preserves unknown fields\n *\n * @param {Object} obj - The object to process\n * @param {Object} schema - Schema definition (fieldName -> fieldDef)\n * @returns {Object} Object with schema defaults applied\n */\nfunction applySchemaToObject(obj, schema) {\n if (!obj || typeof obj !== 'object' || Array.isArray(obj)) {\n return obj\n }\n\n const result = { ...obj }\n\n for (const [field, fieldDef] of Object.entries(schema)) {\n // Get the default value - handle both shorthand and full form\n const defaultValue = typeof fieldDef === 'object' ? fieldDef.default : undefined\n\n // Apply default if field is missing and default exists\n if (result[field] === undefined && defaultValue !== undefined) {\n result[field] = defaultValue\n }\n\n // For select fields with options, apply default if value is not among valid options\n if (typeof fieldDef === 'object' && fieldDef.options && Array.isArray(fieldDef.options)) {\n if (result[field] !== undefined && !fieldDef.options.includes(result[field])) {\n // Value exists but is not valid - apply default if available\n if (defaultValue !== undefined) {\n result[field] = defaultValue\n }\n }\n }\n\n // Handle nested object schema\n if (typeof fieldDef === 'object' && fieldDef.type === 'object' && fieldDef.schema && result[field]) {\n result[field] = applySchemaToObject(result[field], fieldDef.schema)\n }\n\n // Handle array with inline schema\n if (typeof fieldDef === 'object' && fieldDef.type === 'array' && fieldDef.of && result[field]) {\n if (typeof fieldDef.of === 'object') {\n result[field] = result[field].map(item => applySchemaToObject(item, fieldDef.of))\n }\n }\n }\n\n return result\n}\n\n/**\n * Apply a schema to a value (object or array of objects)\n *\n * @param {Object|Array} value - The value to process\n * @param {Object} schema - Schema definition\n * @returns {Object|Array} Value with schema defaults applied\n */\nfunction applySchemaToValue(value, schema) {\n if (Array.isArray(value)) {\n return value.map(item => applySchemaToObject(item, schema))\n }\n return applySchemaToObject(value, schema)\n}\n\n/**\n * Apply schemas to content.data\n * Only processes tags that have a matching schema, leaves others untouched\n *\n * @param {Object} data - The data object from content\n * @param {Object} schemas - Schema definitions from runtime meta\n * @returns {Object} Data with schemas applied\n */\nexport function applySchemas(data, schemas) {\n if (!schemas || !data || typeof data !== 'object') {\n return data || {}\n }\n\n const result = { ...data }\n\n for (const [tag, rawValue] of Object.entries(data)) {\n const schema = schemas[tag]\n if (!schema) continue // No schema for this tag - leave as-is\n\n result[tag] = applySchemaToValue(rawValue, schema)\n }\n\n return result\n}\n\n/**\n * Apply param defaults from runtime schema\n *\n * @param {Object} params - Params from frontmatter\n * @param {Object} defaults - Default values from runtime schema\n * @returns {Object} Merged params with defaults applied\n */\nexport function applyDefaults(params, defaults) {\n if (!defaults || Object.keys(defaults).length === 0) {\n return params || {}\n }\n\n return {\n ...defaults,\n ...(params || {}),\n }\n}\n\n/**\n * Prepare props for a component with runtime guarantees\n *\n * @param {Object} block - The block instance\n * @param {Object} meta - Runtime metadata for the component (from meta[componentName])\n * @returns {Object} Prepared props: { content, params }\n */\nexport function prepareProps(block, meta) {\n // Apply param defaults\n const defaults = meta?.defaults || {}\n const params = applyDefaults(block.properties, defaults)\n\n // Guarantee content structure\n const content = guaranteeContentStructure(block.parsedContent)\n\n // Apply schemas to content.data\n const schemas = meta?.schemas || null\n if (schemas && content.data) {\n content.data = applySchemas(content.data, schemas)\n }\n\n return { content, params }\n}\n\n/**\n * Get runtime metadata for a component from the global uniweb instance\n *\n * @param {string} componentName\n * @returns {Object|null}\n */\nexport function getComponentMeta(componentName) {\n return globalThis.uniweb?.getComponentMeta?.(componentName) || null\n}\n\n/**\n * Get default param values for a component\n *\n * @param {string} componentName\n * @returns {Object}\n */\nexport function getComponentDefaults(componentName) {\n return globalThis.uniweb?.getComponentDefaults?.(componentName) || {}\n}\n","/**\n * SSR Renderer\n *\n * Hook-free rendering pipeline for SSG (build) and cloud SSR (unicloud).\n * Mirrors BlockRenderer.jsx + Background.jsx using React.createElement\n * directly — no hooks, no JSX, no browser APIs.\n *\n * This is the single source of truth for how blocks render during prerender.\n * When modifying BlockRenderer.jsx or Background.jsx, update this file to match.\n *\n * Exports three layers:\n * 1. Rendering functions (renderBlock, renderBlocks, renderLayout, renderBackground)\n * 2. Initialization (initPrerender, prefetchIcons)\n * 3. Per-page rendering (renderPage, classifyRenderError, injectPageContent, escapeHtml)\n */\n\nimport React from 'react'\nimport { renderToString } from 'react-dom/server'\nimport { createUniweb } from '@uniweb/core'\nimport { buildSectionOverrides } from '@uniweb/theming'\nimport { prepareProps, getComponentMeta } from './prepare-props.js'\n\n// ============================================================================\n// Layer 1: Rendering functions\n// ============================================================================\n\n/**\n * Valid color contexts for section theming\n */\nconst VALID_CONTEXTS = ['light', 'medium', 'dark']\n\n/**\n * Build wrapper props from block configuration.\n * Mirrors getWrapperProps in BlockRenderer.jsx.\n */\nexport function getWrapperProps(block) {\n const theme = block.themeName\n const blockClassName = block.state?.className || ''\n\n // Empty themeName = Auto → no context class → inherits tokens from :root\n // Non-empty = Pinned → context class sets tokens directly on the element\n let contextClass = ''\n if (theme && VALID_CONTEXTS.includes(theme)) {\n contextClass = `context-${theme}`\n }\n\n let className = contextClass\n if (blockClassName) {\n className = className ? `${className} ${blockClassName}` : blockClassName\n }\n\n const { background = {} } = block.standardOptions\n const style = {}\n\n // If background has content, ensure relative positioning and a stacking context\n // so the background's z-index stays contained within this section.\n if (background.mode) {\n style.position = 'relative'\n style.isolation = 'isolate'\n }\n\n // Apply context overrides as inline CSS custom properties\n if (block.contextOverrides) {\n for (const [key, value] of Object.entries(block.contextOverrides)) {\n style[`--${key}`] = value\n }\n }\n\n // Use stableId for DOM ID if available (stable across reordering)\n const sectionId = block.stableId || block.id\n\n return { id: `section-${sectionId}`, style, className, background }\n}\n\n/**\n * Convert hex/rgb color to rgba with opacity.\n * Mirrors withOpacity() in Background.jsx.\n */\nfunction withOpacity(color, opacity) {\n if (color.startsWith('#')) {\n const r = parseInt(color.slice(1, 3), 16)\n const g = parseInt(color.slice(3, 5), 16)\n const b = parseInt(color.slice(5, 7), 16)\n return `rgba(${r}, ${g}, ${b}, ${opacity})`\n }\n if (color.startsWith('rgb')) {\n const match = color.match(/rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)/)\n if (match) {\n return `rgba(${match[1]}, ${match[2]}, ${match[3]}, ${opacity})`\n }\n }\n return color\n}\n\n/**\n * Resolve a URL against the site's base path.\n * Mirrors resolveUrl() in Background.jsx.\n */\nfunction resolveUrl(url) {\n if (!url || !url.startsWith('/')) return url\n const basePath = globalThis.uniweb?.activeWebsite?.basePath || ''\n if (!basePath) return url\n if (url.startsWith(basePath + '/') || url === basePath) return url\n return basePath + url\n}\n\n/**\n * Render a background element for SSR.\n * Mirrors Background.jsx (color, gradient, image — not video).\n * Video backgrounds require JS for autoplay and are skipped during SSR.\n */\nexport function renderBackground(background) {\n if (!background?.mode) return null\n\n const containerStyle = {\n position: 'absolute',\n inset: '0',\n overflow: 'hidden',\n zIndex: 0,\n }\n\n const children = []\n\n // Color background\n if (background.mode === 'color' && background.color) {\n children.push(\n React.createElement('div', {\n key: 'bg-color',\n className: 'background-color',\n style: { position: 'absolute', inset: '0', backgroundColor: background.color },\n 'aria-hidden': 'true',\n })\n )\n }\n\n // Gradient background (supports string or object with opacity)\n if (background.mode === 'gradient' && background.gradient) {\n const g = background.gradient\n\n let bgValue\n if (typeof g === 'string') {\n bgValue = g\n } else {\n const {\n start = 'transparent',\n end = 'transparent',\n angle = 0,\n startPosition = 0,\n endPosition = 100,\n startOpacity = 1,\n endOpacity = 1,\n } = g\n const startColor = startOpacity < 1 ? withOpacity(start, startOpacity) : start\n const endColor = endOpacity < 1 ? withOpacity(end, endOpacity) : end\n bgValue = `linear-gradient(${angle}deg, ${startColor} ${startPosition}%, ${endColor} ${endPosition}%)`\n }\n\n children.push(\n React.createElement('div', {\n key: 'bg-gradient',\n className: 'background-gradient',\n style: { position: 'absolute', inset: '0', background: bgValue },\n 'aria-hidden': 'true',\n })\n )\n }\n\n // Image background\n if (background.mode === 'image' && background.image?.src) {\n const img = background.image\n children.push(\n React.createElement('div', {\n key: 'bg-image',\n className: 'background-image',\n style: {\n position: 'absolute',\n inset: '0',\n backgroundImage: `url(${resolveUrl(img.src)})`,\n backgroundPosition: img.position || 'center',\n backgroundSize: img.size || 'cover',\n backgroundRepeat: 'no-repeat',\n },\n 'aria-hidden': 'true',\n })\n )\n }\n\n // Overlay (gradient or solid)\n if (background.overlay?.enabled) {\n const ov = background.overlay\n let overlayStyle\n\n if (ov.gradient) {\n const g = ov.gradient\n overlayStyle = {\n position: 'absolute', inset: '0', pointerEvents: 'none',\n background: `linear-gradient(${g.angle || 180}deg, ${g.start || 'rgba(0,0,0,0.7)'} ${g.startPosition || 0}%, ${g.end || 'rgba(0,0,0,0)'} ${g.endPosition || 100}%)`,\n opacity: ov.opacity ?? 0.5,\n }\n } else {\n const baseColor = ov.type === 'light' ? '255, 255, 255' : '0, 0, 0'\n overlayStyle = {\n position: 'absolute', inset: '0', pointerEvents: 'none',\n backgroundColor: `rgba(${baseColor}, ${ov.opacity ?? 0.5})`,\n }\n }\n\n children.push(\n React.createElement('div', {\n key: 'bg-overlay',\n className: ov.gradient ? 'background-overlay background-overlay--gradient' : 'background-overlay background-overlay--solid',\n style: overlayStyle,\n 'aria-hidden': 'true',\n })\n )\n }\n\n if (children.length === 0) return null\n\n return React.createElement('div', {\n className: `background background--${background.mode}`,\n style: containerStyle,\n 'aria-hidden': 'true',\n }, ...children)\n}\n\n/**\n * Render a single block for SSR.\n * Mirrors BlockRenderer.jsx but without hooks (no runtime data fetching).\n *\n * @param {Block} block - Block instance to render\n * @param {Object} [options]\n * @param {boolean} [options.pure=false] - Render component without section wrapper (used by ChildBlocks)\n * @returns {React.ReactElement}\n */\nexport function renderBlock(block, { pure = false } = {}) {\n const Component = block.initComponent()\n\n if (!Component) {\n return React.createElement('div', {\n className: 'block-error',\n style: { padding: '1rem', background: '#fef2f2', color: '#dc2626' },\n }, `Component not found: ${block.type}`)\n }\n\n // Build content and params with runtime guarantees\n const meta = getComponentMeta(block.type)\n const prepared = prepareProps(block, meta)\n const params = prepared.params\n const content = { ...prepared.content, ...block.properties }\n\n // Resolve inherited entity data (mirrors BlockRenderer.jsx)\n // EntityStore walks page/site hierarchy to find data matching meta.inheritData\n const entityStore = block.website?.entityStore\n if (entityStore) {\n const resolved = entityStore.resolve(block, meta)\n if (resolved.status === 'ready' && resolved.data) {\n const merged = { ...content.data }\n for (const key of Object.keys(resolved.data)) {\n if (merged[key] === undefined) {\n merged[key] = resolved.data[key]\n }\n }\n content.data = merged\n }\n }\n\n const componentProps = { content, params, block }\n\n // Pure mode: render component without section wrapper (used by ChildBlocks)\n if (pure) {\n return React.createElement(Component, componentProps)\n }\n\n // Background handling (mirrors BlockRenderer.jsx)\n const { background, ...wrapperProps } = getWrapperProps(block)\n\n // Merge Component.className (static classes declared on the component function)\n const componentClassName = Component.className\n if (componentClassName) {\n wrapperProps.className = wrapperProps.className\n ? `${wrapperProps.className} ${componentClassName}`\n : componentClassName\n }\n\n // Check if component handles its own background\n const hasBackground = background?.mode && meta?.background !== 'self'\n block.hasBackground = hasBackground\n\n // Use Component.as as the wrapper tag (default: 'section')\n const wrapperTag = Component.as || 'section'\n\n if (hasBackground) {\n return React.createElement(wrapperTag, wrapperProps,\n renderBackground(background),\n React.createElement('div', { style: { position: 'relative', zIndex: 10 } },\n React.createElement(Component, componentProps)\n )\n )\n }\n\n return React.createElement(wrapperTag, wrapperProps,\n React.createElement(Component, componentProps)\n )\n}\n\n/**\n * Render an array of blocks for SSR.\n */\nexport function renderBlocks(blocks) {\n if (!blocks || blocks.length === 0) return null\n return blocks.map((block, index) =>\n React.createElement(React.Fragment, { key: block.id || index },\n renderBlock(block)\n )\n )\n}\n\n/**\n * Render page layout for SSR.\n * Mirrors Layout.jsx but without hooks.\n */\nexport function renderLayout(page, website) {\n const layoutName = page.getLayoutName()\n const RemoteLayout = website.getRemoteLayout(layoutName)\n const layoutMeta = website.getLayoutMeta(layoutName)\n\n const bodyBlocks = page.getBodyBlocks()\n const areas = page.getLayoutAreas()\n\n const bodyElement = bodyBlocks ? renderBlocks(bodyBlocks) : null\n const areaElements = {}\n for (const [name, blocks] of Object.entries(areas)) {\n areaElements[name] = renderBlocks(blocks)\n }\n\n if (RemoteLayout) {\n const params = { ...(layoutMeta?.defaults || {}), ...(page.getLayoutParams() || {}) }\n return React.createElement(RemoteLayout, {\n page, website, params,\n body: bodyElement,\n ...areaElements,\n })\n }\n\n // Default layout\n return React.createElement(React.Fragment, null,\n areaElements.header && React.createElement('header', null, areaElements.header),\n bodyElement && React.createElement('main', null, bodyElement),\n areaElements.footer && React.createElement('footer', null, areaElements.footer)\n )\n}\n\n// ============================================================================\n// Layer 2: Initialization\n// ============================================================================\n\n/**\n * Create and configure the Uniweb runtime for prerendering.\n *\n * Handles the full initialization sequence in the correct order:\n * createUniweb → setFoundation → capabilities → layoutMeta → basePath → childBlockRenderer.\n *\n * Returns the configured uniweb instance. Consumers can add extras after:\n * - Build: pre-populate DataStore, load extensions\n * - Unicloud: (none needed — payload is complete)\n *\n * NOTE: Does NOT clone content. Cloning is the consumer's responsibility\n * (build modifies content before init; unicloud clones upfront).\n *\n * @param {Object} content - Site content JSON (pages, config, hierarchy)\n * @param {Object} foundation - Loaded foundation module\n * @param {Object} [options]\n * @param {function} [options.onProgress] - Progress callback\n * @returns {Object} Configured uniweb instance\n */\nexport function initPrerender(content, foundation, options = {}) {\n const { onProgress = () => {} } = options\n\n onProgress('Initializing runtime...')\n const uniweb = createUniweb(content)\n uniweb.setFoundation(foundation)\n\n // Set foundation capabilities (Layout, props, etc.)\n if (foundation.default?.capabilities) {\n uniweb.setFoundationConfig(foundation.default.capabilities)\n }\n\n // Attach layout metadata (areas, transitions, defaults)\n if (foundation.default?.layoutMeta && uniweb.foundationConfig) {\n uniweb.foundationConfig.layoutMeta = foundation.default.layoutMeta\n }\n\n // Set base path from site config for subdirectory deployments\n if (content.config?.base && uniweb.activeWebsite?.setBasePath) {\n uniweb.activeWebsite.setBasePath(content.config.base)\n }\n\n // Set childBlockRenderer so ChildBlocks/Visual/Render work during prerender\n uniweb.childBlockRenderer = function InlineChildBlocks({ blocks, from, pure = false }) {\n const blockList = blocks || from?.childBlocks || []\n return blockList.map((childBlock, index) =>\n React.createElement(React.Fragment, { key: childBlock.id || index },\n renderBlock(childBlock, { pure })\n )\n )\n }\n\n return uniweb\n}\n\n/**\n * Pre-fetch icons from CDN and populate the Uniweb icon cache.\n * Stores the cache on siteContent._iconCache for embedding in HTML.\n *\n * @param {Object} siteContent - Site content JSON (mutated: _iconCache added)\n * @param {Object} uniweb - Configured uniweb instance\n * @param {function} [onProgress] - Progress callback\n */\nexport async function prefetchIcons(siteContent, uniweb, onProgress = () => {}) {\n const icons = siteContent.icons?.used || []\n if (icons.length === 0) return\n\n const cdnBase = siteContent.config?.icons?.cdnUrl || 'https://uniweb.github.io/icons'\n\n onProgress(`Fetching ${icons.length} icons for SSR...`)\n\n const results = await Promise.allSettled(\n icons.map(async (iconRef) => {\n const [family, name] = iconRef.split(':')\n const url = `${cdnBase}/${family}/${family}-${name}.svg`\n const response = await fetch(url)\n if (!response.ok) throw new Error(`HTTP ${response.status}`)\n const svg = await response.text()\n uniweb.iconCache.set(`${family}:${name}`, svg)\n })\n )\n\n const succeeded = results.filter(r => r.status === 'fulfilled').length\n const failed = results.filter(r => r.status === 'rejected').length\n if (failed > 0) {\n const msg = `Fetched ${succeeded}/${icons.length} icons (${failed} failed)`\n console.warn(`[prerender] ${msg}`)\n onProgress(` ${msg}`)\n }\n\n // Store icon cache on siteContent for embedding in HTML\n if (uniweb.iconCache.size > 0) {\n siteContent._iconCache = Object.fromEntries(uniweb.iconCache)\n }\n}\n\n// ============================================================================\n// Layer 3: Per-page rendering\n// ============================================================================\n\n/**\n * Classify an SSR rendering error.\n *\n * @param {Error} err\n * @returns {{ type: 'hooks'|'null-component'|'unknown', message: string }}\n */\nexport function classifyRenderError(err) {\n const msg = err.message || ''\n\n if (msg.includes('Invalid hook call') || msg.includes('useState') || msg.includes('useEffect')) {\n return {\n type: 'hooks',\n message: 'contains components with React hooks (renders client-side)',\n }\n }\n\n if (msg.includes('Element type is invalid') && msg.includes('null')) {\n return {\n type: 'null-component',\n message: 'a component resolved to null (often hook-related, renders client-side)',\n }\n }\n\n return {\n type: 'unknown',\n message: msg,\n }\n}\n\n/**\n * Render a single page to HTML.\n *\n * Handles the full per-page pipeline:\n * setActivePage → renderLayout → renderToString → error handling → section override CSS.\n *\n * @param {Page} page - Page instance to render\n * @param {Website} website - Website instance\n * @returns {{ renderedContent: string, sectionOverrideCSS: string } | { error: { type: string, message: string } }}\n */\nexport function renderPage(page, website) {\n website.setActivePage(page.route)\n\n const element = renderLayout(page, website)\n\n let renderedContent\n try {\n renderedContent = renderToString(element)\n } catch (err) {\n return { error: classifyRenderError(err) }\n }\n\n // Build per-page section override CSS (theme pinning, component vars)\n const appearance = website.themeData?.appearance\n const sectionOverrideCSS = buildSectionOverrides(page.getPageBlocks(), appearance)\n\n return { renderedContent, sectionOverrideCSS }\n}\n\n// ============================================================================\n// HTML injection\n// ============================================================================\n\n/**\n * Escape HTML special characters.\n */\nexport function escapeHtml(str) {\n if (!str) return ''\n return String(str)\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n}\n\n/**\n * Inject prerendered content into an HTML shell.\n *\n * Common operations shared by both build and cloud:\n * - Replace #root div with rendered HTML\n * - Update page title\n * - Add/update meta description\n * - Inject section override CSS\n *\n * Build layers its additional injections on top of this return value:\n * __SITE_CONTENT__ JSON, icon cache, theme CSS (build-specific).\n *\n * @param {string} html - HTML shell\n * @param {string} renderedContent - React renderToString output\n * @param {Object} page - Page data { title, description, route }\n * @param {Object} [options]\n * @param {string} [options.sectionOverrideCSS] - Per-page section override CSS\n * @returns {string} HTML with injected content\n */\nexport function injectPageContent(html, renderedContent, page, options = {}) {\n let result = html\n\n // Inject per-page section override CSS before </head>\n if (options.sectionOverrideCSS) {\n const overrideStyle = `<style id=\"uniweb-page-overrides\">\\n${options.sectionOverrideCSS}\\n</style>`\n result = result.replace('</head>', `${overrideStyle}\\n</head>`)\n }\n\n // Replace the empty root div with pre-rendered content\n result = result.replace(\n /<div id=\"root\">[\\s\\S]*?<\\/div>/,\n `<div id=\"root\">${renderedContent}</div>`\n )\n\n // Update page title\n if (page.title) {\n result = result.replace(\n /<title>.*?<\\/title>/,\n `<title>${escapeHtml(page.title)}</title>`\n )\n }\n\n // Add/update meta description\n if (page.description) {\n const metaDesc = `<meta name=\"description\" content=\"${escapeHtml(page.description)}\">`\n if (result.includes('<meta name=\"description\"')) {\n result = result.replace(/<meta name=\"description\"[^>]*>/, metaDesc)\n } else {\n result = result.replace('</head>', `${metaDesc}\\n</head>`)\n }\n }\n\n return result\n}\n"],"names":[],"mappings":";;;;AAgBA,SAAS,uBAAuB,MAAM;AACpC,SAAO;AAAA,IACL,OAAO,KAAK,SAAS;AAAA,IACrB,UAAU,KAAK,YAAY;AAAA,IAC3B,UAAU,KAAK,YAAY;AAAA,IAC3B,YAAY,KAAK,cAAc,CAAA;AAAA,IAC/B,OAAO,KAAK,SAAS,CAAA;AAAA,IACrB,QAAQ,KAAK,UAAU,CAAA;AAAA,IACvB,OAAO,KAAK,SAAS,CAAA;AAAA,IACrB,OAAO,KAAK,SAAS,CAAA;AAAA,IACrB,QAAQ,KAAK,UAAU,CAAA;AAAA,IACvB,UAAU,KAAK,YAAY,CAAA;AAAA,IAC3B,SAAS,KAAK,WAAW,CAAA;AAAA,IACzB,MAAM,KAAK,QAAQ,CAAA;AAAA,IACnB,OAAO,KAAK,SAAS,CAAA;AAAA,IACrB,WAAW,KAAK,aAAa,CAAA;AAAA,IAC7B,OAAO,KAAK,SAAS,CAAA;AAAA,IACrB,QAAQ,KAAK,UAAU,CAAA;AAAA,IACvB,UAAU,KAAK,YAAY,CAAA;AAAA,EAC/B;AACA;AASO,SAAS,0BAA0B,eAAe;AACvD,QAAM,UAAU,iBAAiB,CAAA;AAEjC,SAAO;AAAA;AAAA,IAEL,OAA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QAAO;AACjB,SAAO,OAAO,GAAG,EACd,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,QAAQ,EACtB,QAAQ,MAAM,OAAO;AAC1B;AAqBO,SAAS,kBAAkB,MAAM,iBAAiB,MAAM,UAAU,CAAA,GAAI;AAC3E,MAAI,SAAS;AAGb,MAAI,QAAQ,oBAAoB;AAC9B,UAAM,gBAAgB;AAAA,EAAuC,QAAQ,kBAAkB;AAAA;AACvF,aAAS,OAAO,QAAQ,WAAW,GAAG,aAAa;AAAA,QAAW;AAAA,EAChE;AAGA,WAAS,OAAO;AAAA,IACd;AAAA,IACA,kBAAkB,eAAe;AAAA,EACrC;AAGE,MAAI,KAAK,OAAO;AACd,aAAS,OAAO;AAAA,MACd;AAAA,MACA,UAAU,WAAW,KAAK,KAAK,CAAC;AAAA,IACtC;AAAA,EACE;AAGA,MAAI,KAAK,aAAa;AACpB,UAAM,WAAW,qCAAqC,WAAW,KAAK,WAAW,CAAC;AAClF,QAAI,OAAO,SAAS,0BAA0B,GAAG;AAC/C,eAAS,OAAO,QAAQ,kCAAkC,QAAQ;AAAA,IACpE,OAAO;AACL,eAAS,OAAO,QAAQ,WAAW,GAAG,QAAQ;AAAA,QAAW;AAAA,IAC3D;AAAA,EACF;AAEA,SAAO;AACT;"}
|
|
1
|
+
{"version":3,"file":"ssr.js","sources":["../src/prepare-props.js","../src/default-404.js","../src/ssr-renderer.js"],"sourcesContent":["/**\n * Props Preparation for Runtime Guarantees\n *\n * Prepares props for foundation components with:\n * - Param defaults from runtime schema\n * - Guaranteed content structure (no null checks needed)\n *\n * This enables simpler component code by ensuring predictable prop shapes.\n */\n\n/**\n * Guarantee item has flat content structure\n *\n * @param {Object} item - Raw item from parser\n * @returns {Object} Item with guaranteed flat structure\n */\nfunction guaranteeItemStructure(item) {\n return {\n title: item.title || '',\n pretitle: item.pretitle || '',\n subtitle: item.subtitle || '',\n paragraphs: item.paragraphs || [],\n links: item.links || [],\n images: item.images || [],\n lists: item.lists || [],\n icons: item.icons || [],\n videos: item.videos || [],\n snippets: item.snippets || [],\n buttons: item.buttons || [],\n data: item.data || {},\n cards: item.cards || [],\n documents: item.documents || [],\n forms: item.forms || [],\n quotes: item.quotes || [],\n headings: item.headings || [],\n }\n}\n\n/**\n * Guarantee content structure exists\n * Returns a flat content object with all standard fields guaranteed to exist\n *\n * @param {Object} parsedContent - Raw parsed content from semantic parser (flat structure)\n * @returns {Object} Content with guaranteed flat structure\n */\nexport function guaranteeContentStructure(parsedContent) {\n const content = parsedContent || {}\n\n return {\n // Flat header fields\n title: content.title || '',\n pretitle: content.pretitle || '',\n subtitle: content.subtitle || '',\n alignment: content.alignment || null,\n\n // Flat body fields\n paragraphs: content.paragraphs || [],\n links: content.links || [],\n images: content.images || [],\n lists: content.lists || [],\n icons: content.icons || [],\n videos: content.videos || [],\n insets: content.insets || [],\n snippets: content.snippets || [],\n buttons: content.buttons || [],\n data: content.data || {},\n cards: content.cards || [],\n documents: content.documents || [],\n forms: content.forms || [],\n quotes: content.quotes || [],\n headings: content.headings || [],\n\n // Items with guaranteed structure\n items: (content.items || []).map(guaranteeItemStructure),\n\n // Sequence for ordered rendering\n sequence: content.sequence || [],\n\n // Preserve raw content if present\n raw: content.raw,\n }\n}\n\n/**\n * Apply a schema to a single object\n * Only processes fields defined in the schema, preserves unknown fields\n *\n * @param {Object} obj - The object to process\n * @param {Object} schema - Schema definition (fieldName -> fieldDef)\n * @returns {Object} Object with schema defaults applied\n */\nfunction applySchemaToObject(obj, schema) {\n if (!obj || typeof obj !== 'object' || Array.isArray(obj)) {\n return obj\n }\n\n const result = { ...obj }\n\n for (const [field, fieldDef] of Object.entries(schema)) {\n // Get the default value - handle both shorthand and full form\n const defaultValue = typeof fieldDef === 'object' ? fieldDef.default : undefined\n\n // Apply default if field is missing and default exists\n if (result[field] === undefined && defaultValue !== undefined) {\n result[field] = defaultValue\n }\n\n // For select fields with options, apply default if value is not among valid options\n if (typeof fieldDef === 'object' && fieldDef.options && Array.isArray(fieldDef.options)) {\n if (result[field] !== undefined && !fieldDef.options.includes(result[field])) {\n // Value exists but is not valid - apply default if available\n if (defaultValue !== undefined) {\n result[field] = defaultValue\n }\n }\n }\n\n // Handle nested object schema\n if (typeof fieldDef === 'object' && fieldDef.type === 'object' && fieldDef.schema && result[field]) {\n result[field] = applySchemaToObject(result[field], fieldDef.schema)\n }\n\n // Handle array with inline schema\n if (typeof fieldDef === 'object' && fieldDef.type === 'array' && fieldDef.of && result[field]) {\n if (typeof fieldDef.of === 'object') {\n result[field] = result[field].map(item => applySchemaToObject(item, fieldDef.of))\n }\n }\n }\n\n return result\n}\n\n/**\n * Apply a schema to a value (object or array of objects)\n *\n * @param {Object|Array} value - The value to process\n * @param {Object} schema - Schema definition\n * @returns {Object|Array} Value with schema defaults applied\n */\nfunction applySchemaToValue(value, schema) {\n if (Array.isArray(value)) {\n return value.map(item => applySchemaToObject(item, schema))\n }\n return applySchemaToObject(value, schema)\n}\n\n/**\n * Apply schemas to content.data\n * Only processes tags that have a matching schema, leaves others untouched\n *\n * @param {Object} data - The data object from content\n * @param {Object} schemas - Schema definitions from runtime meta\n * @returns {Object} Data with schemas applied\n */\nexport function applySchemas(data, schemas) {\n if (!schemas || !data || typeof data !== 'object') {\n return data || {}\n }\n\n const result = { ...data }\n\n for (const [tag, rawValue] of Object.entries(data)) {\n const schema = schemas[tag]\n if (!schema) continue // No schema for this tag - leave as-is\n\n result[tag] = applySchemaToValue(rawValue, schema)\n }\n\n return result\n}\n\n/**\n * Apply param defaults from runtime schema\n *\n * @param {Object} params - Params from frontmatter\n * @param {Object} defaults - Default values from runtime schema\n * @returns {Object} Merged params with defaults applied\n */\nexport function applyDefaults(params, defaults) {\n if (!defaults || Object.keys(defaults).length === 0) {\n return params || {}\n }\n\n return {\n ...defaults,\n ...(params || {}),\n }\n}\n\n/**\n * Prepare props for a component with runtime guarantees\n *\n * @param {Object} block - The block instance\n * @param {Object} meta - Runtime metadata for the component (from meta[componentName])\n * @returns {Object} Prepared props: { content, params }\n */\nexport function prepareProps(block, meta) {\n // Apply param defaults\n const defaults = meta?.defaults || {}\n const params = applyDefaults(block.properties, defaults)\n\n // Guarantee content structure\n const content = guaranteeContentStructure(block.parsedContent)\n\n // Apply schemas to content.data\n const schemas = meta?.schemas || null\n if (schemas && content.data) {\n content.data = applySchemas(content.data, schemas)\n }\n\n return { content, params }\n}\n\n/**\n * Get runtime metadata for a component from the global uniweb instance\n *\n * @param {string} componentName\n * @returns {Object|null}\n */\nexport function getComponentMeta(componentName) {\n return globalThis.uniweb?.getComponentMeta?.(componentName) || null\n}\n\n/**\n * Get default param values for a component\n *\n * @param {string} componentName\n * @returns {Object}\n */\nexport function getComponentDefaults(componentName) {\n return globalThis.uniweb?.getComponentDefaults?.(componentName) || {}\n}\n","/**\n * Default 404 Page Content\n *\n * Single source of truth for the fallback 404 page shown when a site\n * has no custom 404 page defined. Used by:\n * - PageRenderer.jsx (client-side, as React elements)\n * - ssr-renderer.js generate404Html (build-time, as HTML string)\n *\n * The wrapper uses min-height + flex centering so the 404 content\n * renders at the same position regardless of parent layout context.\n * This prevents a visible flash when React hydrates over the SSR content.\n */\n\nimport React from 'react'\n\nconst styles = {\n wrapper: {\n minHeight: '80vh',\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n padding: '2rem',\n textAlign: 'center',\n },\n heading: { fontSize: '3rem', fontWeight: 'bold', color: '#1f2937', marginBottom: '1rem' },\n message: { color: '#64748b', marginBottom: '2rem' },\n link: { color: '#3b82f6', textDecoration: 'underline' },\n}\n\n/**\n * React element for client-side rendering (PageRenderer).\n * Reads basePath from the runtime so the homepage link works\n * in subdirectory deployments (e.g., /sites/testproject).\n */\nexport function Default404() {\n const basePath = globalThis.uniweb?.activeWebsite?.basePath || ''\n const homeHref = basePath ? `${basePath}/` : '/'\n return React.createElement('div', { className: 'page-not-found', style: styles.wrapper },\n React.createElement('h1', { style: styles.heading }, '404'),\n React.createElement('p', { style: styles.message }, 'Page not found'),\n React.createElement('a', { href: homeHref, style: styles.link }, 'Go to homepage')\n )\n}\n\n/**\n * Static HTML string for SSR injection (generate404Html).\n *\n * @param {string} [basePath] - Base path prefix for the homepage link (e.g., '/sites/testproject')\n */\nexport function default404Html(basePath = '') {\n const homeHref = basePath ? `${basePath}/` : '/'\n return (\n `<div class=\"page-not-found\" style=\"min-height:80vh;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:2rem;text-align:center\">` +\n `<h1 style=\"font-size:3rem;font-weight:bold;color:#1f2937;margin-bottom:1rem\">404</h1>` +\n `<p style=\"color:#64748b;margin-bottom:2rem\">Page not found</p>` +\n `<a href=\"${homeHref}\" style=\"color:#3b82f6;text-decoration:underline\">Go to homepage</a>` +\n `</div>`\n )\n}\n","/**\n * SSR Renderer\n *\n * Hook-free rendering pipeline for SSG (build) and cloud SSR (unicloud).\n * Mirrors BlockRenderer.jsx + Background.jsx using React.createElement\n * directly — no hooks, no JSX, no browser APIs.\n *\n * This is the single source of truth for how blocks render during prerender.\n * When modifying BlockRenderer.jsx or Background.jsx, update this file to match.\n *\n * Exports three layers:\n * 1. Rendering functions (renderBlock, renderBlocks, renderLayout, renderBackground)\n * 2. Initialization (initPrerender, prefetchIcons)\n * 3. Per-page rendering (renderPage, classifyRenderError, injectPageContent, escapeHtml)\n */\n\nimport React from 'react'\nimport { renderToString } from 'react-dom/server'\nimport { createUniweb } from '@uniweb/core'\nimport { buildSectionOverrides } from '@uniweb/theming'\nimport { prepareProps, getComponentMeta } from './prepare-props.js'\nimport { default404Html } from './default-404.js'\n\n// ============================================================================\n// Layer 1: Rendering functions\n// ============================================================================\n\n/**\n * Valid color contexts for section theming\n */\nconst VALID_CONTEXTS = ['light', 'medium', 'dark']\n\n/**\n * Build wrapper props from block configuration.\n * Mirrors getWrapperProps in BlockRenderer.jsx.\n */\nexport function getWrapperProps(block) {\n const theme = block.themeName\n const blockClassName = block.state?.className || ''\n\n // Empty themeName = Auto → no context class → inherits tokens from :root\n // Non-empty = Pinned → context class sets tokens directly on the element\n let contextClass = ''\n if (theme && VALID_CONTEXTS.includes(theme)) {\n contextClass = `context-${theme}`\n }\n\n let className = contextClass\n if (blockClassName) {\n className = className ? `${className} ${blockClassName}` : blockClassName\n }\n\n const { background = {} } = block.standardOptions\n const style = {}\n\n // If background has content, ensure relative positioning and a stacking context\n // so the background's z-index stays contained within this section.\n if (background.mode) {\n style.position = 'relative'\n style.isolation = 'isolate'\n }\n\n // Apply context overrides as inline CSS custom properties\n if (block.contextOverrides) {\n for (const [key, value] of Object.entries(block.contextOverrides)) {\n style[`--${key}`] = value\n }\n }\n\n // Use stableId for DOM ID if available (stable across reordering)\n const sectionId = block.stableId || block.id\n\n return { id: `section-${sectionId}`, style, className, background }\n}\n\n/**\n * Convert hex/rgb color to rgba with opacity.\n * Mirrors withOpacity() in Background.jsx.\n */\nfunction withOpacity(color, opacity) {\n if (color.startsWith('#')) {\n const r = parseInt(color.slice(1, 3), 16)\n const g = parseInt(color.slice(3, 5), 16)\n const b = parseInt(color.slice(5, 7), 16)\n return `rgba(${r}, ${g}, ${b}, ${opacity})`\n }\n if (color.startsWith('rgb')) {\n const match = color.match(/rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)/)\n if (match) {\n return `rgba(${match[1]}, ${match[2]}, ${match[3]}, ${opacity})`\n }\n }\n return color\n}\n\n/**\n * Resolve a URL against the site's base path.\n * Mirrors resolveUrl() in Background.jsx.\n */\nfunction resolveUrl(url) {\n if (!url || !url.startsWith('/')) return url\n const basePath = globalThis.uniweb?.activeWebsite?.basePath || ''\n if (!basePath) return url\n if (url.startsWith(basePath + '/') || url === basePath) return url\n return basePath + url\n}\n\n/**\n * Render a background element for SSR.\n * Mirrors Background.jsx (color, gradient, image — not video).\n * Video backgrounds require JS for autoplay and are skipped during SSR.\n */\nexport function renderBackground(background) {\n if (!background?.mode) return null\n\n const containerStyle = {\n position: 'absolute',\n inset: '0',\n overflow: 'hidden',\n zIndex: 0,\n }\n\n const children = []\n\n // Color background\n if (background.mode === 'color' && background.color) {\n children.push(\n React.createElement('div', {\n key: 'bg-color',\n className: 'background-color',\n style: { position: 'absolute', inset: '0', backgroundColor: background.color },\n 'aria-hidden': 'true',\n })\n )\n }\n\n // Gradient background (supports string or object with opacity)\n if (background.mode === 'gradient' && background.gradient) {\n const g = background.gradient\n\n let bgValue\n if (typeof g === 'string') {\n bgValue = g\n } else {\n const {\n start = 'transparent',\n end = 'transparent',\n angle = 0,\n startPosition = 0,\n endPosition = 100,\n startOpacity = 1,\n endOpacity = 1,\n } = g\n const startColor = startOpacity < 1 ? withOpacity(start, startOpacity) : start\n const endColor = endOpacity < 1 ? withOpacity(end, endOpacity) : end\n bgValue = `linear-gradient(${angle}deg, ${startColor} ${startPosition}%, ${endColor} ${endPosition}%)`\n }\n\n children.push(\n React.createElement('div', {\n key: 'bg-gradient',\n className: 'background-gradient',\n style: { position: 'absolute', inset: '0', background: bgValue },\n 'aria-hidden': 'true',\n })\n )\n }\n\n // Image background\n if (background.mode === 'image' && background.image?.src) {\n const img = background.image\n children.push(\n React.createElement('div', {\n key: 'bg-image',\n className: 'background-image',\n style: {\n position: 'absolute',\n inset: '0',\n backgroundImage: `url(${resolveUrl(img.src)})`,\n backgroundPosition: img.position || 'center',\n backgroundSize: img.size || 'cover',\n backgroundRepeat: 'no-repeat',\n },\n 'aria-hidden': 'true',\n })\n )\n }\n\n // Overlay (gradient or solid)\n if (background.overlay?.enabled) {\n const ov = background.overlay\n let overlayStyle\n\n if (ov.gradient) {\n const g = ov.gradient\n overlayStyle = {\n position: 'absolute', inset: '0', pointerEvents: 'none',\n background: `linear-gradient(${g.angle || 180}deg, ${g.start || 'rgba(0,0,0,0.7)'} ${g.startPosition || 0}%, ${g.end || 'rgba(0,0,0,0)'} ${g.endPosition || 100}%)`,\n opacity: ov.opacity ?? 0.5,\n }\n } else {\n const baseColor = ov.type === 'light' ? '255, 255, 255' : '0, 0, 0'\n overlayStyle = {\n position: 'absolute', inset: '0', pointerEvents: 'none',\n backgroundColor: `rgba(${baseColor}, ${ov.opacity ?? 0.5})`,\n }\n }\n\n children.push(\n React.createElement('div', {\n key: 'bg-overlay',\n className: ov.gradient ? 'background-overlay background-overlay--gradient' : 'background-overlay background-overlay--solid',\n style: overlayStyle,\n 'aria-hidden': 'true',\n })\n )\n }\n\n if (children.length === 0) return null\n\n return React.createElement('div', {\n className: `background background--${background.mode}`,\n style: containerStyle,\n 'aria-hidden': 'true',\n }, ...children)\n}\n\n/**\n * Render a single block for SSR.\n * Mirrors BlockRenderer.jsx but without hooks (no runtime data fetching).\n *\n * @param {Block} block - Block instance to render\n * @param {Object} [options]\n * @param {boolean} [options.pure=false] - Render component without section wrapper (used by ChildBlocks)\n * @returns {React.ReactElement}\n */\nexport function renderBlock(block, { pure = false, as = undefined } = {}) {\n const Component = block.initComponent()\n\n if (!Component) {\n return React.createElement('div', {\n className: 'block-error',\n style: { padding: '1rem', background: '#fef2f2', color: '#dc2626' },\n }, `Component not found: ${block.type}`)\n }\n\n // Build content and params with runtime guarantees\n const meta = getComponentMeta(block.type)\n const prepared = prepareProps(block, meta)\n const params = prepared.params\n const content = { ...prepared.content, ...block.properties }\n\n // Resolve inherited entity data (mirrors BlockRenderer.jsx)\n // EntityStore walks page/site hierarchy to find data matching meta.inheritData\n const entityStore = block.website?.entityStore\n if (entityStore) {\n const resolved = entityStore.resolve(block, meta)\n if (resolved.status === 'ready' && resolved.data) {\n const merged = { ...content.data }\n for (const key of Object.keys(resolved.data)) {\n if (merged[key] === undefined) {\n merged[key] = resolved.data[key]\n }\n }\n content.data = merged\n }\n }\n\n const componentProps = { content, params, block }\n\n // Pure mode: render component without section wrapper (used by ChildBlocks)\n if (pure) {\n return React.createElement(Component, componentProps)\n }\n\n // Background handling (mirrors BlockRenderer.jsx)\n const { background, ...wrapperProps } = getWrapperProps(block)\n\n // Merge Component.className (static classes declared on the component function)\n const componentClassName = Component.className\n if (componentClassName) {\n wrapperProps.className = wrapperProps.className\n ? `${wrapperProps.className} ${componentClassName}`\n : componentClassName\n }\n\n // Check if component handles its own background\n const hasBackground = background?.mode && meta?.background !== 'self'\n block.hasBackground = hasBackground\n\n // Use Component.as as the wrapper tag (default: 'section').\n // An explicit `as` prop (e.g. 'div' from ChildBlocks) overrides Component.as,\n // mirroring the BlockRenderer.jsx Wrapper resolution logic.\n const wrapperTag = (as !== undefined && as !== 'section') ? as : (Component.as || 'section')\n\n if (hasBackground) {\n return React.createElement(wrapperTag, wrapperProps,\n renderBackground(background),\n React.createElement('div', { style: { position: 'relative', zIndex: 10 } },\n React.createElement(Component, componentProps)\n )\n )\n }\n\n return React.createElement(wrapperTag, wrapperProps,\n React.createElement(Component, componentProps)\n )\n}\n\n/**\n * Render an array of blocks for SSR.\n */\nexport function renderBlocks(blocks) {\n if (!blocks || blocks.length === 0) return null\n return blocks.map((block, index) =>\n React.createElement(React.Fragment, { key: block.id || index },\n renderBlock(block)\n )\n )\n}\n\n/**\n * Render page layout for SSR.\n * Mirrors Layout.jsx but without hooks.\n */\nexport function renderLayout(page, website) {\n const layoutName = page.getLayoutName()\n const RemoteLayout = website.getRemoteLayout(layoutName)\n const layoutMeta = website.getLayoutMeta(layoutName)\n\n const bodyBlocks = page.getBodyBlocks()\n const areas = page.getLayoutAreas()\n\n const bodyElement = bodyBlocks ? renderBlocks(bodyBlocks) : null\n const areaElements = {}\n for (const [name, blocks] of Object.entries(areas)) {\n areaElements[name] = renderBlocks(blocks)\n }\n\n if (RemoteLayout) {\n const params = { ...(layoutMeta?.defaults || {}), ...(page.getLayoutParams() || {}) }\n return React.createElement(RemoteLayout, {\n page, website, params,\n body: bodyElement,\n ...areaElements,\n })\n }\n\n // Default layout\n return React.createElement(React.Fragment, null,\n areaElements.header && React.createElement('header', null, areaElements.header),\n bodyElement && React.createElement('main', null, bodyElement),\n areaElements.footer && React.createElement('footer', null, areaElements.footer)\n )\n}\n\n// ============================================================================\n// Layer 2: Initialization\n// ============================================================================\n\n/**\n * Create and configure the Uniweb runtime for prerendering.\n *\n * Handles the full initialization sequence in the correct order:\n * createUniweb → setFoundation → capabilities → layoutMeta → basePath → childBlockRenderer.\n *\n * Returns the configured uniweb instance. Consumers can add extras after:\n * - Build: pre-populate DataStore, load extensions\n * - Unicloud: (none needed — payload is complete)\n *\n * NOTE: Does NOT clone content. Cloning is the consumer's responsibility\n * (build modifies content before init; unicloud clones upfront).\n *\n * @param {Object} content - Site content JSON (pages, config, hierarchy)\n * @param {Object} foundation - Loaded foundation module\n * @param {Object} [options]\n * @param {function} [options.onProgress] - Progress callback\n * @returns {Object} Configured uniweb instance\n */\nexport function initPrerender(content, foundation, options = {}) {\n const { onProgress = () => {} } = options\n\n onProgress('Initializing runtime...')\n const uniweb = createUniweb(content)\n uniweb.setFoundation(foundation)\n\n // Set foundation capabilities (Layout, props, etc.)\n if (foundation.default?.capabilities) {\n uniweb.setFoundationConfig(foundation.default.capabilities)\n }\n\n // Attach layout metadata (areas, transitions, defaults)\n if (foundation.default?.layoutMeta && uniweb.foundationConfig) {\n uniweb.foundationConfig.layoutMeta = foundation.default.layoutMeta\n }\n\n // Set base path from site config for subdirectory deployments\n if (content.config?.base && uniweb.activeWebsite?.setBasePath) {\n uniweb.activeWebsite.setBasePath(content.config.base)\n }\n\n // Set childBlockRenderer so ChildBlocks/Visual/Render work during prerender.\n // Mirrors the client's ChildBlocks component in PageRenderer.jsx:\n // - default as='div' so nested blocks use <div> wrapper (not <section>)\n // matching the client and avoiding React hydration mismatch (error #418)\n uniweb.childBlockRenderer = function InlineChildBlocks({ blocks, from, pure = false, as = 'div' }) {\n const blockList = blocks || from?.childBlocks || []\n return blockList.map((childBlock, index) =>\n React.createElement(React.Fragment, { key: childBlock.id || index },\n renderBlock(childBlock, { pure, as })\n )\n )\n }\n\n return uniweb\n}\n\n/**\n * Pre-fetch icons from CDN and populate the Uniweb icon cache.\n * Stores the cache on siteContent._iconCache for embedding in HTML.\n *\n * @param {Object} siteContent - Site content JSON (mutated: _iconCache added)\n * @param {Object} uniweb - Configured uniweb instance\n * @param {function} [onProgress] - Progress callback\n */\nexport async function prefetchIcons(siteContent, uniweb, onProgress = () => {}) {\n const icons = siteContent.icons?.used || []\n if (icons.length === 0) return\n\n const cdnBase = siteContent.config?.icons?.cdnUrl || 'https://uniweb.github.io/icons'\n\n onProgress(`Fetching ${icons.length} icons for SSR...`)\n\n const results = await Promise.allSettled(\n icons.map(async (iconRef) => {\n const [family, name] = iconRef.split(':')\n const url = `${cdnBase}/${family}/${family}-${name}.svg`\n const response = await fetch(url)\n if (!response.ok) throw new Error(`HTTP ${response.status}`)\n const svg = await response.text()\n uniweb.iconCache.set(`${family}:${name}`, svg)\n })\n )\n\n const succeeded = results.filter(r => r.status === 'fulfilled').length\n const failed = results.filter(r => r.status === 'rejected').length\n if (failed > 0) {\n const msg = `Fetched ${succeeded}/${icons.length} icons (${failed} failed)`\n console.warn(`[prerender] ${msg}`)\n onProgress(` ${msg}`)\n }\n\n // Store icon cache on siteContent for embedding in HTML\n if (uniweb.iconCache.size > 0) {\n siteContent._iconCache = Object.fromEntries(uniweb.iconCache)\n }\n}\n\n// ============================================================================\n// Layer 3: Per-page rendering\n// ============================================================================\n\n/**\n * Classify an SSR rendering error.\n *\n * @param {Error} err\n * @returns {{ type: 'hooks'|'null-component'|'unknown', message: string }}\n */\nexport function classifyRenderError(err) {\n const msg = err.message || ''\n\n if (msg.includes('Invalid hook call') || msg.includes('useState') || msg.includes('useEffect')) {\n return {\n type: 'hooks',\n message: 'contains components with React hooks (renders client-side)',\n }\n }\n\n if (msg.includes('Element type is invalid') && msg.includes('null')) {\n return {\n type: 'null-component',\n message: 'a component resolved to null (often hook-related, renders client-side)',\n }\n }\n\n return {\n type: 'unknown',\n message: msg,\n }\n}\n\n/**\n * Render a single page to HTML.\n *\n * Handles the full per-page pipeline:\n * setActivePage → renderLayout → renderToString → error handling → section override CSS.\n *\n * @param {Page} page - Page instance to render\n * @param {Website} website - Website instance\n * @returns {{ renderedContent: string, sectionOverrideCSS: string } | { error: { type: string, message: string } }}\n */\nexport function renderPage(page, website) {\n website.setActivePage(page.route)\n\n const element = renderLayout(page, website)\n\n let renderedContent\n try {\n renderedContent = renderToString(element)\n } catch (err) {\n return { error: classifyRenderError(err) }\n }\n\n // Build per-page section override CSS (theme pinning, component vars)\n const appearance = website.themeData?.appearance\n const sectionOverrideCSS = buildSectionOverrides(page.getPageBlocks(), appearance)\n\n return { renderedContent, sectionOverrideCSS }\n}\n\n// ============================================================================\n// HTML injection\n// ============================================================================\n\n/**\n * Escape HTML special characters.\n */\nexport function escapeHtml(str) {\n if (!str) return ''\n return String(str)\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n}\n\n/**\n * Inject prerendered content into an HTML shell.\n *\n * Common operations shared by both build and cloud:\n * - Replace #root div with rendered HTML\n * - Update page title\n * - Add/update meta description\n * - Inject section override CSS\n *\n * Build layers its additional injections on top of this return value:\n * __SITE_CONTENT__ JSON, icon cache, theme CSS (build-specific).\n *\n * @param {string} html - HTML shell\n * @param {string} renderedContent - React renderToString output\n * @param {Object} page - Page data { title, description, route }\n * @param {Object} [options]\n * @param {string} [options.sectionOverrideCSS] - Per-page section override CSS\n * @returns {string} HTML with injected content\n */\nexport function injectPageContent(html, renderedContent, page, options = {}) {\n let result = html\n\n // Inject per-page section override CSS before </head>\n if (options.sectionOverrideCSS) {\n const overrideStyle = `<style id=\"uniweb-page-overrides\">\\n${options.sectionOverrideCSS}\\n</style>`\n result = result.replace('</head>', `${overrideStyle}\\n</head>`)\n }\n\n // Replace the empty root div with pre-rendered content\n result = result.replace(\n /<div id=\"root\">[\\s\\S]*?<\\/div>/,\n `<div id=\"root\">${renderedContent}</div>`\n )\n\n // Update page title (use getTitle() so isIndex pages inherit parent title)\n const pageTitle = page.getTitle?.() || page.title\n if (pageTitle) {\n result = result.replace(\n /<title>.*?<\\/title>/,\n `<title>${escapeHtml(pageTitle)}</title>`\n )\n }\n\n // Add/update meta description\n if (page.description) {\n const metaDesc = `<meta name=\"description\" content=\"${escapeHtml(page.description)}\">`\n if (result.includes('<meta name=\"description\"')) {\n result = result.replace(/<meta name=\"description\"[^>]*>/, metaDesc)\n } else {\n result = result.replace('</head>', `${metaDesc}\\n</head>`)\n }\n }\n\n return result\n}\n\n// ============================================================================\n// 404 fallback generation\n// ============================================================================\n\n/**\n * Generate 404.html content for static hosting fallback.\n *\n * Serves two purposes on static hosts (GitHub Pages, Cloudflare Pages, etc.):\n * 1. Real 404: pre-rendered custom 404 page content (or blank #root if none defined)\n * 2. Valid dynamic route (e.g. /blog/2): inline script clears #root so SPA renders fresh\n *\n * Flow: static host serves 404.html → inline script runs before React mounts →\n * - dynamic route: clears #root, React renders the page normally\n * - real 404: leaves #root with pre-rendered content, React re-renders same 404 page\n *\n * @param {Object} options\n * @param {string} options.baseHtml - Assembled HTML shell (with site content already injected)\n * @param {Object} options.website - Initialized Website instance (from initPrerender)\n * @param {Object} options.siteContent - Site content object (to find dynamic templates)\n * @returns {{ html: string, hasNotFoundPage: boolean }}\n */\nexport function generate404Html({ baseHtml, website, siteContent }) {\n // Extract patterns for routes that remain as dynamic templates (prerender: false)\n const dynamicTemplates = siteContent.pages?.filter((p) => p.isDynamic) || []\n const routePatterns = dynamicTemplates.map((p) => {\n // '/blog/:id' → /^\\/blog\\/[^\\/]+\\/?$/\n const escaped = p.route\n .replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n .replace(/:[^/]+/g, '[^\\\\/]+')\n return `^${escaped}\\\\/?$`\n })\n\n let html = baseHtml\n\n // Pre-render the custom 404 page content into #root (if the site defines one),\n // otherwise inject a default 404 message so the page isn't blank before JS loads\n const notFoundPage = website.getNotFoundPage()\n if (notFoundPage) {\n const notFoundResult = renderPage(notFoundPage, website)\n if (notFoundResult && !notFoundResult.error) {\n html = injectPageContent(html, notFoundResult.renderedContent, notFoundPage, {\n sectionOverrideCSS: notFoundResult.sectionOverrideCSS,\n })\n }\n } else {\n const basePath = website.basePath || ''\n html = html.replace(\n /<div id=\"root\">[\\s\\S]*?<\\/div>/,\n `<div id=\"root\">${default404Html(basePath)}</div>`\n )\n }\n\n // Inject inline script: if path matches a dynamic route, clear #root before React mounts\n // so the SPA renders the correct page rather than the 404 content\n if (routePatterns.length > 0) {\n const patternList = routePatterns.map((p) => `/${p}/`).join(',')\n const dynamicScript =\n `<script>(function(){` +\n `var p=[${patternList}],r=window.location.pathname;` +\n `if(p.some(function(x){return x.test(r)})){` +\n `var el=document.getElementById('root');if(el)el.innerHTML='';` +\n `}})()</script>`\n html = html.replace('</body>', `${dynamicScript}\\n</body>`)\n }\n\n return { html, hasNotFoundPage: !!notFoundPage }\n}\n"],"names":[],"mappings":";;;;AAgBA,SAAS,uBAAuB,MAAM;AACpC,SAAO;AAAA,IACL,OAAO,KAAK,SAAS;AAAA,IACrB,UAAU,KAAK,YAAY;AAAA,IAC3B,UAAU,KAAK,YAAY;AAAA,IAC3B,YAAY,KAAK,cAAc,CAAA;AAAA,IAC/B,OAAO,KAAK,SAAS,CAAA;AAAA,IACrB,QAAQ,KAAK,UAAU,CAAA;AAAA,IACvB,OAAO,KAAK,SAAS,CAAA;AAAA,IACrB,OAAO,KAAK,SAAS,CAAA;AAAA,IACrB,QAAQ,KAAK,UAAU,CAAA;AAAA,IACvB,UAAU,KAAK,YAAY,CAAA;AAAA,IAC3B,SAAS,KAAK,WAAW,CAAA;AAAA,IACzB,MAAM,KAAK,QAAQ,CAAA;AAAA,IACnB,OAAO,KAAK,SAAS,CAAA;AAAA,IACrB,WAAW,KAAK,aAAa,CAAA;AAAA,IAC7B,OAAO,KAAK,SAAS,CAAA;AAAA,IACrB,QAAQ,KAAK,UAAU,CAAA;AAAA,IACvB,UAAU,KAAK,YAAY,CAAA;AAAA,EAC/B;AACA;AASO,SAAS,0BAA0B,eAAe;AACvD,QAAM,UAAU,iBAAiB,CAAA;AAE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AAI,CAAC,MAAM;AAEhD,UAAM,UAAU,EAAE,MACf,QAAQ,uBAAuB,MAAM,EACrC,QAAQ,WAAW,SAAS;AAC/B,WAAO,IAAI,OAAO;AAAA,EACpB,CAAC;AAED,MAAI,OAAO;AAIX,QAAM,eAAe,QAAQ,gBAAe;AAC5C,MAAI,cAAc;AAChB,UAAM,iBAAiB,WAAW,cAAc,OAAO;AACvD,QAAI,kBAAkB,CAAC,eAAe,OAAO;AAC3C,aAAO,kBAAkB,MAAM,eAAe,iBAAiB,cAAc;AAAA,QAC3E,oBAAoB,eAAe;AAAA,MAC3C,CAAO;AAAA,IACH;AAAA,EACF,OAAO;AACL,UAAM,WAAW,QAAQ,YAAY;AACrC,WAAO,KAAK;AAAA,MACV;AAAA,MACA,kBAAkB,eAAe,QAAQ,CAAC;AAAA,IAChD;AAAA,EACE;AAIA,MAAI,cAAc,SAAS,GAAG;AAC5B,UAAM,cAAc,cAAc,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,KAAK,GAAG;AAC/D,UAAM,gBACJ,8BACU,WAAW;AAIvB,WAAO,KAAK,QAAQ,WAAW,GAAG,aAAa;AAAA,QAAW;AAAA,EAC5D;AAEA,SAAO,EAAE,MAAM,iBAAiB,CAAC,CAAC,aAAY;AAChD;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/runtime",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.16",
|
|
4
4
|
"description": "Minimal runtime for loading Uniweb foundations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"./ssr": "./dist/ssr.js",
|
|
9
9
|
"./provider": "./src/RuntimeProvider.jsx",
|
|
10
10
|
"./setup": "./src/setup.js",
|
|
11
|
-
"./foundation-loader": "./src/foundation-loader.js"
|
|
11
|
+
"./foundation-loader": "./src/foundation-loader.js",
|
|
12
|
+
"./data-fetcher-client": "./src/data-fetcher-client.js"
|
|
12
13
|
},
|
|
13
14
|
"files": [
|
|
14
15
|
"src",
|
|
@@ -34,12 +35,13 @@
|
|
|
34
35
|
"node": ">=20.19"
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
37
|
-
"@uniweb/core": "0.5.
|
|
38
|
+
"@uniweb/core": "0.5.15",
|
|
38
39
|
"@uniweb/theming": "0.1.2"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@vitejs/plugin-react": "^4.5.2",
|
|
42
|
-
"vite": "^7.3.1"
|
|
43
|
+
"vite": "^7.3.1",
|
|
44
|
+
"@uniweb/build": "0.8.20"
|
|
43
45
|
},
|
|
44
46
|
"peerDependencies": {
|
|
45
47
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -47,6 +49,8 @@
|
|
|
47
49
|
"react-router-dom": "^6.0.0 || ^7.0.0"
|
|
48
50
|
},
|
|
49
51
|
"scripts": {
|
|
50
|
-
"build:ssr": "vite build --config vite.config.ssr.js"
|
|
52
|
+
"build:ssr": "vite build --config vite.config.ssr.js",
|
|
53
|
+
"build:app": "vite build --config vite.config.app.js",
|
|
54
|
+
"build": "npm run build:ssr && npm run build:app"
|
|
51
55
|
}
|
|
52
56
|
}
|
|
@@ -80,6 +80,7 @@ export default function BlockRenderer({ block, pure = false, as = 'section', ext
|
|
|
80
80
|
// Entity-aware data resolution via EntityStore
|
|
81
81
|
const entityStore = block.website.entityStore
|
|
82
82
|
const meta = getComponentMeta(block.type)
|
|
83
|
+
|
|
83
84
|
const resolved = entityStore.resolve(block, meta)
|
|
84
85
|
|
|
85
86
|
// Async data for when resolve returns 'pending' (runtime fetches)
|
|
@@ -39,11 +39,11 @@ import Blocks from './Blocks.jsx'
|
|
|
39
39
|
*/
|
|
40
40
|
function DefaultLayout({ header, body, footer }) {
|
|
41
41
|
return (
|
|
42
|
-
|
|
42
|
+
<div style={{ display: 'flex', flexDirection: 'column', minHeight: '100vh' }}>
|
|
43
43
|
{header && <header>{header}</header>}
|
|
44
|
-
{body && <main>{body}</main>}
|
|
44
|
+
{body && <main style={{ flex: 1 }}>{body}</main>}
|
|
45
45
|
{footer && <footer>{footer}</footer>}
|
|
46
|
-
|
|
46
|
+
</div>
|
|
47
47
|
)
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -6,12 +6,13 @@
|
|
|
6
6
|
* Manages head meta tags for SEO and social sharing.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import React, { useMemo, useEffect, useRef } from 'react'
|
|
9
|
+
import React, { useMemo, useEffect, useReducer, useRef } from 'react'
|
|
10
10
|
import { useLocation } from 'react-router-dom'
|
|
11
11
|
import BlockRenderer from './BlockRenderer.jsx'
|
|
12
12
|
import Layout from './Layout.jsx'
|
|
13
13
|
import { useHeadMeta } from '../hooks/useHeadMeta.js'
|
|
14
14
|
import { buildSectionOverrides } from '@uniweb/theming'
|
|
15
|
+
import { Default404 } from '../default-404.js'
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* ChildBlocks - renders child blocks of a block
|
|
@@ -66,16 +67,19 @@ function SectionOverrideStyles({ page, appearance }) {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
if (!styleRef.current) {
|
|
69
|
-
|
|
70
|
+
// Reuse the SSR-injected element if present to avoid duplicates
|
|
71
|
+
styleRef.current = document.getElementById('uniweb-page-overrides') || document.createElement('style')
|
|
70
72
|
styleRef.current.id = 'uniweb-page-overrides'
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
themeStyle
|
|
75
|
-
|
|
76
|
-
themeStyle
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
if (!styleRef.current.parentNode) {
|
|
74
|
+
// Not yet in the DOM — insert after uniweb-theme if it exists, otherwise append to head
|
|
75
|
+
const themeStyle = document.getElementById('uniweb-theme')
|
|
76
|
+
if (themeStyle && themeStyle.nextSibling) {
|
|
77
|
+
themeStyle.parentNode.insertBefore(styleRef.current, themeStyle.nextSibling)
|
|
78
|
+
} else if (themeStyle) {
|
|
79
|
+
themeStyle.parentNode.appendChild(styleRef.current)
|
|
80
|
+
} else {
|
|
81
|
+
document.head.appendChild(styleRef.current)
|
|
82
|
+
}
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
|
|
@@ -107,6 +111,9 @@ export default function PageRenderer() {
|
|
|
107
111
|
const website = uniweb?.activeWebsite
|
|
108
112
|
const siteName = website?.name || ''
|
|
109
113
|
|
|
114
|
+
// Force re-render counter — incremented by DataStore listener below
|
|
115
|
+
const [, forceUpdate] = useReducer((x) => x + 1, 0)
|
|
116
|
+
|
|
110
117
|
// Resolve page from current URL and sync website.activePage immediately.
|
|
111
118
|
// This must happen synchronously (not in an effect) so child components
|
|
112
119
|
// like Header see the correct activePage during the same render cycle.
|
|
@@ -128,17 +135,25 @@ export default function PageRenderer() {
|
|
|
128
135
|
// Manage head meta tags
|
|
129
136
|
useHeadMeta(headMeta, { siteName })
|
|
130
137
|
|
|
138
|
+
// For dynamic pages created before collection data was available (hard reload),
|
|
139
|
+
// the page title starts as the template name (e.g. '[id]'). Subscribe to
|
|
140
|
+
// DataStore updates so we re-render once the collection loads — _createDynamicPage
|
|
141
|
+
// then runs again with fresh data and sets the correct title/notFound state.
|
|
142
|
+
const isDynamicPending = !!(page?.dynamicContext && !website?._dynamicPageCache?.has(location.pathname))
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
if (!isDynamicPending || !website?.dataStore) return
|
|
145
|
+
return website.dataStore.onUpdate(forceUpdate)
|
|
146
|
+
}, [isDynamicPending, website])
|
|
147
|
+
|
|
131
148
|
if (!page) {
|
|
132
|
-
// No page and no 404 page defined - show
|
|
149
|
+
// No page and no 404 page defined - show shared fallback + dev debug info
|
|
133
150
|
const requestedPath = location.pathname
|
|
134
151
|
const isDev = import.meta.env?.DEV
|
|
135
152
|
return (
|
|
136
|
-
|
|
137
|
-
<
|
|
138
|
-
<p style={{ color: '#64748b', marginBottom: '2rem' }}>Page not found</p>
|
|
139
|
-
<a href="/" style={{ color: '#3b82f6', textDecoration: 'underline' }}>Go to homepage</a>
|
|
153
|
+
<>
|
|
154
|
+
<Default404 />
|
|
140
155
|
{isDev && (
|
|
141
|
-
<div style={{ marginTop: '
|
|
156
|
+
<div style={{ marginTop: '0', padding: '1rem', background: '#f1f5f9', borderRadius: '0.5rem', textAlign: 'left', maxWidth: '32rem', margin: '0 auto' }}>
|
|
142
157
|
<p style={{ fontWeight: '600', color: '#475569', marginBottom: '0.5rem' }}>Debug info</p>
|
|
143
158
|
<p style={{ fontSize: '0.875rem', color: '#64748b' }}>Path: {requestedPath}</p>
|
|
144
159
|
<p style={{ fontSize: '0.875rem', color: '#64748b' }}>Locale: {website?.getActiveLocale?.() || 'unknown'}</p>
|
|
@@ -146,7 +161,7 @@ export default function PageRenderer() {
|
|
|
146
161
|
<p style={{ fontSize: '0.75rem', color: '#94a3b8', marginTop: '0.5rem' }}>Tip: Create a pages/404/ folder with a page.yml and content to customize this page.</p>
|
|
147
162
|
</div>
|
|
148
163
|
)}
|
|
149
|
-
|
|
164
|
+
</>
|
|
150
165
|
)
|
|
151
166
|
}
|
|
152
167
|
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default 404 Page Content
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for the fallback 404 page shown when a site
|
|
5
|
+
* has no custom 404 page defined. Used by:
|
|
6
|
+
* - PageRenderer.jsx (client-side, as React elements)
|
|
7
|
+
* - ssr-renderer.js generate404Html (build-time, as HTML string)
|
|
8
|
+
*
|
|
9
|
+
* The wrapper uses min-height + flex centering so the 404 content
|
|
10
|
+
* renders at the same position regardless of parent layout context.
|
|
11
|
+
* This prevents a visible flash when React hydrates over the SSR content.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import React from 'react'
|
|
15
|
+
|
|
16
|
+
const styles = {
|
|
17
|
+
wrapper: {
|
|
18
|
+
minHeight: '80vh',
|
|
19
|
+
display: 'flex',
|
|
20
|
+
flexDirection: 'column',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
justifyContent: 'center',
|
|
23
|
+
padding: '2rem',
|
|
24
|
+
textAlign: 'center',
|
|
25
|
+
},
|
|
26
|
+
heading: { fontSize: '3rem', fontWeight: 'bold', color: '#1f2937', marginBottom: '1rem' },
|
|
27
|
+
message: { color: '#64748b', marginBottom: '2rem' },
|
|
28
|
+
link: { color: '#3b82f6', textDecoration: 'underline' },
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* React element for client-side rendering (PageRenderer).
|
|
33
|
+
* Reads basePath from the runtime so the homepage link works
|
|
34
|
+
* in subdirectory deployments (e.g., /sites/testproject).
|
|
35
|
+
*/
|
|
36
|
+
export function Default404() {
|
|
37
|
+
const basePath = globalThis.uniweb?.activeWebsite?.basePath || ''
|
|
38
|
+
const homeHref = basePath ? `${basePath}/` : '/'
|
|
39
|
+
return React.createElement('div', { className: 'page-not-found', style: styles.wrapper },
|
|
40
|
+
React.createElement('h1', { style: styles.heading }, '404'),
|
|
41
|
+
React.createElement('p', { style: styles.message }, 'Page not found'),
|
|
42
|
+
React.createElement('a', { href: homeHref, style: styles.link }, 'Go to homepage')
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Static HTML string for SSR injection (generate404Html).
|
|
48
|
+
*
|
|
49
|
+
* @param {string} [basePath] - Base path prefix for the homepage link (e.g., '/sites/testproject')
|
|
50
|
+
*/
|
|
51
|
+
export function default404Html(basePath = '') {
|
|
52
|
+
const homeHref = basePath ? `${basePath}/` : '/'
|
|
53
|
+
return (
|
|
54
|
+
`<div class="page-not-found" style="min-height:80vh;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:2rem;text-align:center">` +
|
|
55
|
+
`<h1 style="font-size:3rem;font-weight:bold;color:#1f2937;margin-bottom:1rem">404</h1>` +
|
|
56
|
+
`<p style="color:#64748b;margin-bottom:2rem">Page not found</p>` +
|
|
57
|
+
`<a href="${homeHref}" style="color:#3b82f6;text-decoration:underline">Go to homepage</a>` +
|
|
58
|
+
`</div>`
|
|
59
|
+
)
|
|
60
|
+
}
|
package/src/foundation-loader.js
CHANGED
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
async function loadFoundationCSS(url) {
|
|
13
13
|
if (!url) return
|
|
14
14
|
|
|
15
|
+
// Skip if already present (e.g., injected by SSR into the static HTML)
|
|
16
|
+
if (document.querySelector(`link[rel="stylesheet"][href="${url}"]`)) return
|
|
17
|
+
|
|
15
18
|
return new Promise((resolve) => {
|
|
16
19
|
const link = document.createElement('link')
|
|
17
20
|
link.rel = 'stylesheet'
|
package/src/index.jsx
CHANGED
|
@@ -108,10 +108,9 @@ async function initRuntime(foundationSource, options = {}) {
|
|
|
108
108
|
return
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
)
|
|
111
|
+
const app = <RuntimeProvider basename={routerBasename} development={development} />
|
|
112
|
+
|
|
113
|
+
createRoot(container).render(app)
|
|
115
114
|
|
|
116
115
|
// Log success
|
|
117
116
|
if (!development) {
|
package/src/setup.js
CHANGED
|
@@ -121,6 +121,8 @@ function createIconResolver(iconConfig = {}) {
|
|
|
121
121
|
*/
|
|
122
122
|
export function setupUniweb(configData) {
|
|
123
123
|
// Create singleton via @uniweb/core (also assigns to globalThis.uniweb)
|
|
124
|
+
// The serving layer is responsible for injecting locale-specific content
|
|
125
|
+
// into __DATA__ — the runtime treats whatever it receives as the active content.
|
|
124
126
|
const uniwebInstance = createUniweb(configData)
|
|
125
127
|
|
|
126
128
|
// Pre-populate DataStore from build-time fetched data
|
|
@@ -184,6 +186,7 @@ export function rebuildWebsite(configData) {
|
|
|
184
186
|
const uniweb = globalThis.uniweb
|
|
185
187
|
const newWebsite = new Website(configData)
|
|
186
188
|
newWebsite.dataStore.registerFetcher(executeFetchClient)
|
|
189
|
+
|
|
187
190
|
uniweb.activeWebsite = newWebsite
|
|
188
191
|
return newWebsite
|
|
189
192
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title></title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="./main.js"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime Shell Entry Point
|
|
3
|
+
*
|
|
4
|
+
* Standalone browser app that boots a Uniweb site from __DATA__ injected
|
|
5
|
+
* by a dynamic backend (unicloud, PHP, etc.).
|
|
6
|
+
*
|
|
7
|
+
* This calls the same start() function that all sites use. When no
|
|
8
|
+
* __FOUNDATION_CONFIG__ is embedded in the page, start() checks for
|
|
9
|
+
* __DATA__ (the dynamic backend protocol) and boots from that.
|
|
10
|
+
*
|
|
11
|
+
* See: kb/plans/runtime-shell-and-cdn.md
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { start } from '../index.jsx'
|
|
15
|
+
|
|
16
|
+
start({ config: null })
|
package/src/ssr-renderer.js
CHANGED
|
@@ -19,6 +19,7 @@ import { renderToString } from 'react-dom/server'
|
|
|
19
19
|
import { createUniweb } from '@uniweb/core'
|
|
20
20
|
import { buildSectionOverrides } from '@uniweb/theming'
|
|
21
21
|
import { prepareProps, getComponentMeta } from './prepare-props.js'
|
|
22
|
+
import { default404Html } from './default-404.js'
|
|
22
23
|
|
|
23
24
|
// ============================================================================
|
|
24
25
|
// Layer 1: Rendering functions
|
|
@@ -233,7 +234,7 @@ export function renderBackground(background) {
|
|
|
233
234
|
* @param {boolean} [options.pure=false] - Render component without section wrapper (used by ChildBlocks)
|
|
234
235
|
* @returns {React.ReactElement}
|
|
235
236
|
*/
|
|
236
|
-
export function renderBlock(block, { pure = false } = {}) {
|
|
237
|
+
export function renderBlock(block, { pure = false, as = undefined } = {}) {
|
|
237
238
|
const Component = block.initComponent()
|
|
238
239
|
|
|
239
240
|
if (!Component) {
|
|
@@ -287,8 +288,10 @@ export function renderBlock(block, { pure = false } = {}) {
|
|
|
287
288
|
const hasBackground = background?.mode && meta?.background !== 'self'
|
|
288
289
|
block.hasBackground = hasBackground
|
|
289
290
|
|
|
290
|
-
// Use Component.as as the wrapper tag (default: 'section')
|
|
291
|
-
|
|
291
|
+
// Use Component.as as the wrapper tag (default: 'section').
|
|
292
|
+
// An explicit `as` prop (e.g. 'div' from ChildBlocks) overrides Component.as,
|
|
293
|
+
// mirroring the BlockRenderer.jsx Wrapper resolution logic.
|
|
294
|
+
const wrapperTag = (as !== undefined && as !== 'section') ? as : (Component.as || 'section')
|
|
292
295
|
|
|
293
296
|
if (hasBackground) {
|
|
294
297
|
return React.createElement(wrapperTag, wrapperProps,
|
|
@@ -396,12 +399,15 @@ export function initPrerender(content, foundation, options = {}) {
|
|
|
396
399
|
uniweb.activeWebsite.setBasePath(content.config.base)
|
|
397
400
|
}
|
|
398
401
|
|
|
399
|
-
// Set childBlockRenderer so ChildBlocks/Visual/Render work during prerender
|
|
400
|
-
|
|
402
|
+
// Set childBlockRenderer so ChildBlocks/Visual/Render work during prerender.
|
|
403
|
+
// Mirrors the client's ChildBlocks component in PageRenderer.jsx:
|
|
404
|
+
// - default as='div' so nested blocks use <div> wrapper (not <section>)
|
|
405
|
+
// matching the client and avoiding React hydration mismatch (error #418)
|
|
406
|
+
uniweb.childBlockRenderer = function InlineChildBlocks({ blocks, from, pure = false, as = 'div' }) {
|
|
401
407
|
const blockList = blocks || from?.childBlocks || []
|
|
402
408
|
return blockList.map((childBlock, index) =>
|
|
403
409
|
React.createElement(React.Fragment, { key: childBlock.id || index },
|
|
404
|
-
renderBlock(childBlock, { pure })
|
|
410
|
+
renderBlock(childBlock, { pure, as })
|
|
405
411
|
)
|
|
406
412
|
)
|
|
407
413
|
}
|
|
@@ -563,11 +569,12 @@ export function injectPageContent(html, renderedContent, page, options = {}) {
|
|
|
563
569
|
`<div id="root">${renderedContent}</div>`
|
|
564
570
|
)
|
|
565
571
|
|
|
566
|
-
// Update page title
|
|
567
|
-
|
|
572
|
+
// Update page title (use getTitle() so isIndex pages inherit parent title)
|
|
573
|
+
const pageTitle = page.getTitle?.() || page.title
|
|
574
|
+
if (pageTitle) {
|
|
568
575
|
result = result.replace(
|
|
569
576
|
/<title>.*?<\/title>/,
|
|
570
|
-
`<title>${escapeHtml(
|
|
577
|
+
`<title>${escapeHtml(pageTitle)}</title>`
|
|
571
578
|
)
|
|
572
579
|
}
|
|
573
580
|
|
|
@@ -583,3 +590,71 @@ export function injectPageContent(html, renderedContent, page, options = {}) {
|
|
|
583
590
|
|
|
584
591
|
return result
|
|
585
592
|
}
|
|
593
|
+
|
|
594
|
+
// ============================================================================
|
|
595
|
+
// 404 fallback generation
|
|
596
|
+
// ============================================================================
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Generate 404.html content for static hosting fallback.
|
|
600
|
+
*
|
|
601
|
+
* Serves two purposes on static hosts (GitHub Pages, Cloudflare Pages, etc.):
|
|
602
|
+
* 1. Real 404: pre-rendered custom 404 page content (or blank #root if none defined)
|
|
603
|
+
* 2. Valid dynamic route (e.g. /blog/2): inline script clears #root so SPA renders fresh
|
|
604
|
+
*
|
|
605
|
+
* Flow: static host serves 404.html → inline script runs before React mounts →
|
|
606
|
+
* - dynamic route: clears #root, React renders the page normally
|
|
607
|
+
* - real 404: leaves #root with pre-rendered content, React re-renders same 404 page
|
|
608
|
+
*
|
|
609
|
+
* @param {Object} options
|
|
610
|
+
* @param {string} options.baseHtml - Assembled HTML shell (with site content already injected)
|
|
611
|
+
* @param {Object} options.website - Initialized Website instance (from initPrerender)
|
|
612
|
+
* @param {Object} options.siteContent - Site content object (to find dynamic templates)
|
|
613
|
+
* @returns {{ html: string, hasNotFoundPage: boolean }}
|
|
614
|
+
*/
|
|
615
|
+
export function generate404Html({ baseHtml, website, siteContent }) {
|
|
616
|
+
// Extract patterns for routes that remain as dynamic templates (prerender: false)
|
|
617
|
+
const dynamicTemplates = siteContent.pages?.filter((p) => p.isDynamic) || []
|
|
618
|
+
const routePatterns = dynamicTemplates.map((p) => {
|
|
619
|
+
// '/blog/:id' → /^\/blog\/[^\/]+\/?$/
|
|
620
|
+
const escaped = p.route
|
|
621
|
+
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
622
|
+
.replace(/:[^/]+/g, '[^\\/]+')
|
|
623
|
+
return `^${escaped}\\/?$`
|
|
624
|
+
})
|
|
625
|
+
|
|
626
|
+
let html = baseHtml
|
|
627
|
+
|
|
628
|
+
// Pre-render the custom 404 page content into #root (if the site defines one),
|
|
629
|
+
// otherwise inject a default 404 message so the page isn't blank before JS loads
|
|
630
|
+
const notFoundPage = website.getNotFoundPage()
|
|
631
|
+
if (notFoundPage) {
|
|
632
|
+
const notFoundResult = renderPage(notFoundPage, website)
|
|
633
|
+
if (notFoundResult && !notFoundResult.error) {
|
|
634
|
+
html = injectPageContent(html, notFoundResult.renderedContent, notFoundPage, {
|
|
635
|
+
sectionOverrideCSS: notFoundResult.sectionOverrideCSS,
|
|
636
|
+
})
|
|
637
|
+
}
|
|
638
|
+
} else {
|
|
639
|
+
const basePath = website.basePath || ''
|
|
640
|
+
html = html.replace(
|
|
641
|
+
/<div id="root">[\s\S]*?<\/div>/,
|
|
642
|
+
`<div id="root">${default404Html(basePath)}</div>`
|
|
643
|
+
)
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// Inject inline script: if path matches a dynamic route, clear #root before React mounts
|
|
647
|
+
// so the SPA renders the correct page rather than the 404 content
|
|
648
|
+
if (routePatterns.length > 0) {
|
|
649
|
+
const patternList = routePatterns.map((p) => `/${p}/`).join(',')
|
|
650
|
+
const dynamicScript =
|
|
651
|
+
`<script>(function(){` +
|
|
652
|
+
`var p=[${patternList}],r=window.location.pathname;` +
|
|
653
|
+
`if(p.some(function(x){return x.test(r)})){` +
|
|
654
|
+
`var el=document.getElementById('root');if(el)el.innerHTML='';` +
|
|
655
|
+
`}})()</script>`
|
|
656
|
+
html = html.replace('</body>', `${dynamicScript}\n</body>`)
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
return { html, hasNotFoundPage: !!notFoundPage }
|
|
660
|
+
}
|