@uniweb/runtime 1.1.14 → 1.1.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 +17 -5
- package/dist/ssr.js.map +1 -1
- package/package.json +3 -3
- package/src/components/BlockRenderer.jsx +4 -1
- package/src/foundation-loader.js +5 -3
- package/src/isolate-api.js +6 -0
- package/src/setup.js +7 -1
- package/src/ssr-renderer.js +8 -13
- package/src/ssr.js +17 -0
- package/src/sticky.js +28 -0
package/dist/ssr.js
CHANGED
|
@@ -9,10 +9,13 @@ import { DEFAULT_ICON_BASE, iconUrl } from "@uniweb/core/icon-corpus";
|
|
|
9
9
|
import { buildTheme, FONT_LINKS_MARKER, buildSectionOverrides } from "@uniweb/theming";
|
|
10
10
|
import "@uniweb/core/services";
|
|
11
11
|
import "@uniweb/core/tracker";
|
|
12
|
+
import { escapeHtml } from "@uniweb/core/page-shell";
|
|
13
|
+
import { escapeHtml as escapeHtml2, foundationCssUrl, pageShell } from "@uniweb/core/page-shell";
|
|
12
14
|
import DataStore, { deriveCacheKey as deriveCacheKey$1 } from "@uniweb/core/datastore";
|
|
13
15
|
import { RESOLUTION_STATUS, carryQuery, localeOfPath, localeUrl, resolveRoute, routeIndex } from "@uniweb/core/resolve-route";
|
|
14
16
|
import { resolveFetchConfigs } from "@uniweb/core/fetch-config";
|
|
15
17
|
import { resolveRecordsService } from "@uniweb/core/records-service";
|
|
18
|
+
import { dataScript, jsonForScript } from "@uniweb/core/data-script";
|
|
16
19
|
function guaranteeItemStructure(item) {
|
|
17
20
|
return {
|
|
18
21
|
title: item.title || "",
|
|
@@ -312,6 +315,13 @@ function zoneProps(stickiness, layer) {
|
|
|
312
315
|
function sectionStickyStyle(block) {
|
|
313
316
|
return block?.sticky ? { ...stickyStyle(block.stickyTop || STICKY_SECTION_TOP, 1), alignSelf: "start" } : null;
|
|
314
317
|
}
|
|
318
|
+
function hasStickyArea(page) {
|
|
319
|
+
const areas = page?.getLayoutAreas?.() || {};
|
|
320
|
+
return Object.values(areas).some((blocks) => areaStickiness(blocks) !== null);
|
|
321
|
+
}
|
|
322
|
+
function sectionScrollMargin(block, kind) {
|
|
323
|
+
return kind && hasStickyArea(block?.page) ? { scrollMarginTop: STICKY_SECTION_TOP } : null;
|
|
324
|
+
}
|
|
315
325
|
function sectionStickyProps(block, kind) {
|
|
316
326
|
const style = kind ? sectionStickyStyle(block) : null;
|
|
317
327
|
return style ? { style, "data-uw-sticky": kind === "child" ? "child" : "section" } : null;
|
|
@@ -569,6 +579,8 @@ function renderBlock(block, { as = "section", stickySelf = false } = {}) {
|
|
|
569
579
|
wrapperProps.style = { ...wrapperProps.style, ...sticky.style };
|
|
570
580
|
wrapperProps["data-uw-sticky"] = sticky["data-uw-sticky"];
|
|
571
581
|
}
|
|
582
|
+
const margin = sectionScrollMargin(block, stickySelf);
|
|
583
|
+
if (margin) wrapperProps.style = { ...wrapperProps.style, ...margin };
|
|
572
584
|
const componentClassName = Component.className;
|
|
573
585
|
if (componentClassName) {
|
|
574
586
|
wrapperProps.className = wrapperProps.className ? `${wrapperProps.className} ${componentClassName}` : componentClassName;
|
|
@@ -763,10 +775,6 @@ function renderPage(page, website) {
|
|
|
763
775
|
const sectionOverrideCSS = buildSectionOverrides(page.getAllBlocks(), appearance);
|
|
764
776
|
return { renderedContent, sectionOverrideCSS };
|
|
765
777
|
}
|
|
766
|
-
function escapeHtml(str) {
|
|
767
|
-
if (!str) return "";
|
|
768
|
-
return String(str).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
769
|
-
}
|
|
770
778
|
function injectPageContent(html, renderedContent, page, options = {}) {
|
|
771
779
|
let result = html;
|
|
772
780
|
if (!result.includes('id="uniweb-appearance"')) {
|
|
@@ -1297,8 +1305,10 @@ export {
|
|
|
1297
1305
|
classifyRenderError,
|
|
1298
1306
|
collectSiteRecords,
|
|
1299
1307
|
createPageRenderer,
|
|
1300
|
-
|
|
1308
|
+
dataScript,
|
|
1309
|
+
escapeHtml2 as escapeHtml,
|
|
1301
1310
|
findPageForRoute,
|
|
1311
|
+
foundationCssUrl,
|
|
1302
1312
|
generate404Html,
|
|
1303
1313
|
getComponentDefaults,
|
|
1304
1314
|
getComponentMeta,
|
|
@@ -1308,9 +1318,11 @@ export {
|
|
|
1308
1318
|
initPrerender,
|
|
1309
1319
|
initPrerenderForLocale,
|
|
1310
1320
|
injectPageContent,
|
|
1321
|
+
jsonForScript,
|
|
1311
1322
|
loadPageData,
|
|
1312
1323
|
localeOfPath,
|
|
1313
1324
|
localeUrl,
|
|
1325
|
+
pageShell,
|
|
1314
1326
|
prefetchAndHydrate,
|
|
1315
1327
|
prefetchIcons,
|
|
1316
1328
|
prepareProps,
|