@uniweb/runtime 1.2.2 → 1.2.3

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 CHANGED
@@ -697,10 +697,12 @@ async function prefetchIcons(siteContent, uniweb, onProgress = () => {
697
697
  const url = iconUrl(family, name, cdnBase);
698
698
  const response = await fetch(url);
699
699
  if (!response.ok) throw new Error(`HTTP ${response.status}`);
700
- const svg = await response.text();
701
- uniweb.iconCache.set(`${family}:${name}`, svg);
700
+ return [`${family}:${name}`, await response.text()];
702
701
  })
703
702
  );
703
+ for (const result of results) {
704
+ if (result.status === "fulfilled") uniweb.iconCache.set(...result.value);
705
+ }
704
706
  const succeeded = results.filter((r) => r.status === "fulfilled").length;
705
707
  const failedRefs = icons.filter((_, i) => results[i].status === "rejected");
706
708
  if (failedRefs.length > 0) {
@@ -1188,6 +1190,7 @@ async function loadPageData({ website, route, fetch: fetch2, dev = false, locale
1188
1190
  `loadPageData: this Website renders ${JSON.stringify(active)} and the caller asked for ${JSON.stringify(locale)}. A Website is locale-sliced — build one per locale (\`initPrerenderForLocale\`) rather than asking this step for another language.`
1189
1191
  );
1190
1192
  }
1193
+ website.makeCurrent();
1191
1194
  const resolved = typeof route === "string" ? resolvePage(website, route) : route;
1192
1195
  if (!resolved) return [];
1193
1196
  const page = typeof resolved.getRenderableSelf === "function" ? resolved.getRenderableSelf() : resolved;
@@ -1232,7 +1235,15 @@ async function loadPageData({ website, route, fetch: fetch2, dev = false, locale
1232
1235
  function createPageRenderer({ website, shell }) {
1233
1236
  if (!website) throw new Error("createPageRenderer: `website` is required");
1234
1237
  if (typeof shell !== "string") throw new Error("createPageRenderer: `shell` must be an HTML string");
1235
- function render(target, { inject = {} } = {}) {
1238
+ function render(target, { inject = {}, fetchedData } = {}) {
1239
+ if (fetchedData !== void 0 && !Array.isArray(fetchedData)) {
1240
+ throw new Error("createPageRenderer: `fetchedData` must be the array of entries the page carries");
1241
+ }
1242
+ website.makeCurrent();
1243
+ if (fetchedData !== void 0) {
1244
+ website.forgetData();
1245
+ hydrateDataStore(website, fetchedData);
1246
+ }
1236
1247
  const resolved = typeof target === "string" ? resolvePage(website, target) : target;
1237
1248
  if (!resolved) return { outcome: "notFound", html: null, page: null, error: null };
1238
1249
  const page = typeof resolved.getRenderableSelf === "function" ? resolved.getRenderableSelf() : resolved;