440 lines
16 KiB
JavaScript
440 lines
16 KiB
JavaScript
|
|
import { createRenderer, getRequestDependencies, getPreloadLinks, getPrefetchLinks } from 'file://D:/doc/workspace/web3/node_modules/vue-bundle-renderer/dist/runtime.mjs';
|
|||
|
|
import { getResponseStatusText, getResponseStatus, getQuery, createError, appendResponseHeader } from 'file://D:/doc/workspace/web3/node_modules/h3/dist/index.mjs';
|
|||
|
|
import { joinRelativeURL, joinURL, withoutTrailingSlash } from 'file://D:/doc/workspace/web3/node_modules/ufo/dist/index.mjs';
|
|||
|
|
import { createHead as createHead$1, propsToString, renderSSRHead } from 'file://D:/doc/workspace/web3/node_modules/unhead/dist/server.mjs';
|
|||
|
|
import { walkResolver } from 'file://D:/doc/workspace/web3/node_modules/unhead/dist/utils.mjs';
|
|||
|
|
import { toValue, isRef, hasInjectionContext, inject, ref, watchEffect, getCurrentInstance, onBeforeUnmount, onDeactivated, onActivated } from 'file://D:/doc/workspace/web3/node_modules/vue/index.mjs';
|
|||
|
|
import { renderToString } from 'file://D:/doc/workspace/web3/node_modules/vue/server-renderer/index.mjs';
|
|||
|
|
import { a as useRuntimeConfig, b as useStorage, d as defineRenderHandler, g as getRouteRules, u as useNitroApp } from './nitro.mjs';
|
|||
|
|
import { stringify, uneval } from 'file://D:/doc/workspace/web3/node_modules/devalue/index.js';
|
|||
|
|
import { DeprecationsPlugin, PromisesPlugin, TemplateParamsPlugin, AliasSortingPlugin } from 'file://D:/doc/workspace/web3/node_modules/unhead/dist/plugins.mjs';
|
|||
|
|
|
|||
|
|
const VueResolver = (_, value) => {
|
|||
|
|
return isRef(value) ? toValue(value) : value;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
const headSymbol = "usehead";
|
|||
|
|
function vueInstall(head) {
|
|||
|
|
const plugin = {
|
|||
|
|
install(app) {
|
|||
|
|
app.config.globalProperties.$unhead = head;
|
|||
|
|
app.config.globalProperties.$head = head;
|
|||
|
|
app.provide(headSymbol, head);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
return plugin.install;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function injectHead() {
|
|||
|
|
if (hasInjectionContext()) {
|
|||
|
|
const instance = inject(headSymbol);
|
|||
|
|
if (!instance) {
|
|||
|
|
throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
|
|||
|
|
}
|
|||
|
|
return instance;
|
|||
|
|
}
|
|||
|
|
throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
|
|||
|
|
}
|
|||
|
|
function useHead(input, options = {}) {
|
|||
|
|
const head = options.head || injectHead();
|
|||
|
|
return head.ssr ? head.push(input || {}, options) : clientUseHead(head, input, options);
|
|||
|
|
}
|
|||
|
|
function clientUseHead(head, input, options = {}) {
|
|||
|
|
const deactivated = ref(false);
|
|||
|
|
let entry;
|
|||
|
|
watchEffect(() => {
|
|||
|
|
const i = deactivated.value ? {} : walkResolver(input, VueResolver);
|
|||
|
|
if (entry) {
|
|||
|
|
entry.patch(i);
|
|||
|
|
} else {
|
|||
|
|
entry = head.push(i, options);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
const vm = getCurrentInstance();
|
|||
|
|
if (vm) {
|
|||
|
|
onBeforeUnmount(() => {
|
|||
|
|
entry.dispose();
|
|||
|
|
});
|
|||
|
|
onDeactivated(() => {
|
|||
|
|
deactivated.value = true;
|
|||
|
|
});
|
|||
|
|
onActivated(() => {
|
|||
|
|
deactivated.value = false;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
return entry;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function createHead(options = {}) {
|
|||
|
|
const head = createHead$1({
|
|||
|
|
...options,
|
|||
|
|
propResolvers: [VueResolver]
|
|||
|
|
});
|
|||
|
|
head.install = vueInstall(head);
|
|||
|
|
return head;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const appHead = {"meta":[{"name":"viewport","content":"width=device-width, initial-scale=1"},{"charset":"utf-8"},{"name":"description","content":"为您的企业提供专业的AWS云服务解决方案,助力数字化转型"}],"link":[{"rel":"stylesheet","href":"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"},{"rel":"preconnect","href":"https://fonts.googleapis.com"},{"rel":"preconnect","href":"https://fonts.gstatic.com","crossorigin":""},{"rel":"stylesheet","href":"https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;600;700&display=swap"}],"style":[],"script":[],"noscript":[],"charset":"utf-8","viewport":"width=device-width, initial-scale=1","title":"AWS云服务专家"};
|
|||
|
|
|
|||
|
|
const appRootTag = "div";
|
|||
|
|
|
|||
|
|
const appRootAttrs = {"id":"__nuxt"};
|
|||
|
|
|
|||
|
|
const appTeleportTag = "div";
|
|||
|
|
|
|||
|
|
const appTeleportAttrs = {"id":"teleports"};
|
|||
|
|
|
|||
|
|
const componentIslands = false;
|
|||
|
|
|
|||
|
|
const appId = "nuxt-app";
|
|||
|
|
|
|||
|
|
function buildAssetsDir() {
|
|||
|
|
return useRuntimeConfig().app.buildAssetsDir;
|
|||
|
|
}
|
|||
|
|
function buildAssetsURL(...path) {
|
|||
|
|
return joinRelativeURL(publicAssetsURL(), buildAssetsDir(), ...path);
|
|||
|
|
}
|
|||
|
|
function publicAssetsURL(...path) {
|
|||
|
|
const app = useRuntimeConfig().app;
|
|||
|
|
const publicBase = app.cdnURL || app.baseURL;
|
|||
|
|
return path.length ? joinRelativeURL(publicBase, ...path) : publicBase;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const APP_ROOT_OPEN_TAG = `<${appRootTag}${propsToString(appRootAttrs)}>`;
|
|||
|
|
const APP_ROOT_CLOSE_TAG = `</${appRootTag}>`;
|
|||
|
|
const getClientManifest = () => import('../build/client.manifest.mjs').then((r) => r.default || r).then((r) => typeof r === "function" ? r() : r);
|
|||
|
|
const getEntryIds = () => getClientManifest().then((r) => Object.values(r).filter(
|
|||
|
|
(r2) => (
|
|||
|
|
// @ts-expect-error internal key set by CSS inlining configuration
|
|||
|
|
r2._globalCSS
|
|||
|
|
)
|
|||
|
|
).map((r2) => r2.src));
|
|||
|
|
const getServerEntry = () => import('../build/server.mjs').then(function (n) { return n.s; }).then((r) => r.default || r);
|
|||
|
|
const getSSRStyles = lazyCachedFunction(() => import('../build/styles.mjs').then((r) => r.default || r));
|
|||
|
|
const getSSRRenderer = lazyCachedFunction(async () => {
|
|||
|
|
const manifest = await getClientManifest();
|
|||
|
|
if (!manifest) {
|
|||
|
|
throw new Error("client.manifest is not available");
|
|||
|
|
}
|
|||
|
|
const createSSRApp = await getServerEntry();
|
|||
|
|
if (!createSSRApp) {
|
|||
|
|
throw new Error("Server bundle is not available");
|
|||
|
|
}
|
|||
|
|
const options = {
|
|||
|
|
manifest,
|
|||
|
|
renderToString: renderToString$1,
|
|||
|
|
buildAssetsURL
|
|||
|
|
};
|
|||
|
|
const renderer = createRenderer(createSSRApp, options);
|
|||
|
|
async function renderToString$1(input, context) {
|
|||
|
|
const html = await renderToString(input, context);
|
|||
|
|
return APP_ROOT_OPEN_TAG + html + APP_ROOT_CLOSE_TAG;
|
|||
|
|
}
|
|||
|
|
return renderer;
|
|||
|
|
});
|
|||
|
|
const getSPARenderer = lazyCachedFunction(async () => {
|
|||
|
|
const manifest = await getClientManifest();
|
|||
|
|
const spaTemplate = await import('../virtual/_virtual_spa-template.mjs').then((r) => r.template).catch(() => "").then((r) => {
|
|||
|
|
{
|
|||
|
|
return APP_ROOT_OPEN_TAG + r + APP_ROOT_CLOSE_TAG;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
const options = {
|
|||
|
|
manifest,
|
|||
|
|
renderToString: () => spaTemplate,
|
|||
|
|
buildAssetsURL
|
|||
|
|
};
|
|||
|
|
const renderer = createRenderer(() => () => {
|
|||
|
|
}, options);
|
|||
|
|
const result = await renderer.renderToString({});
|
|||
|
|
const renderToString = (ssrContext) => {
|
|||
|
|
const config = useRuntimeConfig(ssrContext.event);
|
|||
|
|
ssrContext.modules ||= /* @__PURE__ */ new Set();
|
|||
|
|
ssrContext.payload.serverRendered = false;
|
|||
|
|
ssrContext.config = {
|
|||
|
|
public: config.public,
|
|||
|
|
app: config.app
|
|||
|
|
};
|
|||
|
|
return Promise.resolve(result);
|
|||
|
|
};
|
|||
|
|
return {
|
|||
|
|
rendererContext: renderer.rendererContext,
|
|||
|
|
renderToString
|
|||
|
|
};
|
|||
|
|
});
|
|||
|
|
function lazyCachedFunction(fn) {
|
|||
|
|
let res = null;
|
|||
|
|
return () => {
|
|||
|
|
if (res === null) {
|
|||
|
|
res = fn().catch((err) => {
|
|||
|
|
res = null;
|
|||
|
|
throw err;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
return res;
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const payloadCache = useStorage("internal:nuxt:prerender:payload") ;
|
|||
|
|
useStorage("internal:nuxt:prerender:island") ;
|
|||
|
|
useStorage("internal:nuxt:prerender:island-props") ;
|
|||
|
|
|
|||
|
|
function renderPayloadResponse(ssrContext) {
|
|||
|
|
return {
|
|||
|
|
body: stringify(splitPayload(ssrContext).payload, ssrContext._payloadReducers) ,
|
|||
|
|
statusCode: getResponseStatus(ssrContext.event),
|
|||
|
|
statusMessage: getResponseStatusText(ssrContext.event),
|
|||
|
|
headers: {
|
|||
|
|
"content-type": "application/json;charset=utf-8" ,
|
|||
|
|
"x-powered-by": "Nuxt"
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
function renderPayloadJsonScript(opts) {
|
|||
|
|
const contents = opts.data ? stringify(opts.data, opts.ssrContext._payloadReducers) : "";
|
|||
|
|
const payload = {
|
|||
|
|
"type": "application/json",
|
|||
|
|
"innerHTML": contents,
|
|||
|
|
"data-nuxt-data": appId,
|
|||
|
|
"data-ssr": !(opts.ssrContext.noSSR)
|
|||
|
|
};
|
|||
|
|
{
|
|||
|
|
payload.id = "__NUXT_DATA__";
|
|||
|
|
}
|
|||
|
|
if (opts.src) {
|
|||
|
|
payload["data-src"] = opts.src;
|
|||
|
|
}
|
|||
|
|
const config = uneval(opts.ssrContext.config);
|
|||
|
|
return [
|
|||
|
|
payload,
|
|||
|
|
{
|
|||
|
|
innerHTML: `window.__NUXT__={};window.__NUXT__.config=${config}`
|
|||
|
|
}
|
|||
|
|
];
|
|||
|
|
}
|
|||
|
|
function splitPayload(ssrContext) {
|
|||
|
|
const { data, prerenderedAt, ...initial } = ssrContext.payload;
|
|||
|
|
return {
|
|||
|
|
initial: { ...initial, prerenderedAt },
|
|||
|
|
payload: { data, prerenderedAt }
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const unheadOptions = {
|
|||
|
|
disableDefaults: true,
|
|||
|
|
disableCapoSorting: false,
|
|||
|
|
plugins: [DeprecationsPlugin, PromisesPlugin, TemplateParamsPlugin, AliasSortingPlugin],
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
const renderSSRHeadOptions = {"omitLineBreaks":false};
|
|||
|
|
|
|||
|
|
globalThis.__buildAssetsURL = buildAssetsURL;
|
|||
|
|
globalThis.__publicAssetsURL = publicAssetsURL;
|
|||
|
|
const HAS_APP_TELEPORTS = !!(appTeleportAttrs.id);
|
|||
|
|
const APP_TELEPORT_OPEN_TAG = HAS_APP_TELEPORTS ? `<${appTeleportTag}${propsToString(appTeleportAttrs)}>` : "";
|
|||
|
|
const APP_TELEPORT_CLOSE_TAG = HAS_APP_TELEPORTS ? `</${appTeleportTag}>` : "";
|
|||
|
|
const PAYLOAD_URL_RE = /^[^?]*\/_payload.json(?:\?.*)?$/ ;
|
|||
|
|
const PAYLOAD_FILENAME = "_payload.json" ;
|
|||
|
|
const PRERENDER_NO_SSR_ROUTES = /* @__PURE__ */ new Set(["/index.html", "/200.html", "/404.html"]);
|
|||
|
|
const renderer = defineRenderHandler(async (event) => {
|
|||
|
|
const nitroApp = useNitroApp();
|
|||
|
|
const ssrError = event.path.startsWith("/__nuxt_error") ? getQuery(event) : null;
|
|||
|
|
if (ssrError && ssrError.statusCode) {
|
|||
|
|
ssrError.statusCode = Number.parseInt(ssrError.statusCode);
|
|||
|
|
}
|
|||
|
|
if (ssrError && !("__unenv__" in event.node.req)) {
|
|||
|
|
throw createError({
|
|||
|
|
statusCode: 404,
|
|||
|
|
statusMessage: "Page Not Found: /__nuxt_error"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
const isRenderingIsland = componentIslands;
|
|||
|
|
const islandContext = void 0;
|
|||
|
|
let url = ssrError?.url || islandContext?.url || event.path;
|
|||
|
|
const isRenderingPayload = PAYLOAD_URL_RE.test(url);
|
|||
|
|
if (isRenderingPayload) {
|
|||
|
|
url = url.substring(0, url.lastIndexOf("/")) || "/";
|
|||
|
|
event._path = url;
|
|||
|
|
event.node.req.url = url;
|
|||
|
|
if (await payloadCache.hasItem(url)) {
|
|||
|
|
return payloadCache.getItem(url);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
const routeOptions = getRouteRules(event);
|
|||
|
|
const head = createHead(unheadOptions);
|
|||
|
|
const headEntryOptions = { mode: "server" };
|
|||
|
|
{
|
|||
|
|
head.push(appHead, headEntryOptions);
|
|||
|
|
}
|
|||
|
|
const ssrContext = {
|
|||
|
|
url,
|
|||
|
|
event,
|
|||
|
|
runtimeConfig: useRuntimeConfig(event),
|
|||
|
|
noSSR: event.context.nuxt?.noSSR || routeOptions.ssr === false && true || (PRERENDER_NO_SSR_ROUTES.has(url) ),
|
|||
|
|
head,
|
|||
|
|
error: !!ssrError,
|
|||
|
|
nuxt: void 0,
|
|||
|
|
/* NuxtApp */
|
|||
|
|
payload: ssrError ? { error: ssrError } : {},
|
|||
|
|
_payloadReducers: /* @__PURE__ */ Object.create(null),
|
|||
|
|
modules: /* @__PURE__ */ new Set(),
|
|||
|
|
islandContext
|
|||
|
|
};
|
|||
|
|
const _PAYLOAD_EXTRACTION = !ssrContext.noSSR && true;
|
|||
|
|
const payloadURL = _PAYLOAD_EXTRACTION ? joinURL(ssrContext.runtimeConfig.app.cdnURL || ssrContext.runtimeConfig.app.baseURL, url.replace(/\?.*$/, ""), PAYLOAD_FILENAME) + "?" + ssrContext.runtimeConfig.app.buildId : void 0;
|
|||
|
|
{
|
|||
|
|
ssrContext.payload.prerenderedAt = Date.now();
|
|||
|
|
}
|
|||
|
|
const renderer = ssrContext.noSSR ? await getSPARenderer() : await getSSRRenderer();
|
|||
|
|
{
|
|||
|
|
for (const id of await getEntryIds()) {
|
|||
|
|
ssrContext.modules.add(id);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
const _rendered = await renderer.renderToString(ssrContext).catch(async (error) => {
|
|||
|
|
if (ssrContext._renderResponse && error.message === "skipping render") {
|
|||
|
|
return {};
|
|||
|
|
}
|
|||
|
|
const _err = !ssrError && ssrContext.payload?.error || error;
|
|||
|
|
await ssrContext.nuxt?.hooks.callHook("app:error", _err);
|
|||
|
|
throw _err;
|
|||
|
|
});
|
|||
|
|
await ssrContext.nuxt?.hooks.callHook("app:rendered", { ssrContext, renderResult: _rendered });
|
|||
|
|
if (ssrContext._renderResponse) {
|
|||
|
|
return ssrContext._renderResponse;
|
|||
|
|
}
|
|||
|
|
if (ssrContext.payload?.error && !ssrError) {
|
|||
|
|
throw ssrContext.payload.error;
|
|||
|
|
}
|
|||
|
|
if (isRenderingPayload) {
|
|||
|
|
const response2 = renderPayloadResponse(ssrContext);
|
|||
|
|
{
|
|||
|
|
await payloadCache.setItem(url, response2);
|
|||
|
|
}
|
|||
|
|
return response2;
|
|||
|
|
}
|
|||
|
|
if (_PAYLOAD_EXTRACTION) {
|
|||
|
|
appendResponseHeader(event, "x-nitro-prerender", joinURL(url.replace(/\?.*$/, ""), PAYLOAD_FILENAME));
|
|||
|
|
await payloadCache.setItem(withoutTrailingSlash(url), renderPayloadResponse(ssrContext));
|
|||
|
|
}
|
|||
|
|
const inlinedStyles = await renderInlineStyles(ssrContext.modules ?? []) ;
|
|||
|
|
const NO_SCRIPTS = routeOptions.noScripts;
|
|||
|
|
const { styles, scripts } = getRequestDependencies(ssrContext, renderer.rendererContext);
|
|||
|
|
if (_PAYLOAD_EXTRACTION && !NO_SCRIPTS && true) {
|
|||
|
|
head.push({
|
|||
|
|
link: [
|
|||
|
|
{ rel: "preload", as: "fetch", crossorigin: "anonymous", href: payloadURL }
|
|||
|
|
]
|
|||
|
|
}, headEntryOptions);
|
|||
|
|
}
|
|||
|
|
if (ssrContext._preloadManifest) {
|
|||
|
|
head.push({
|
|||
|
|
link: [
|
|||
|
|
{ rel: "preload", as: "fetch", fetchpriority: "low", crossorigin: "anonymous", href: buildAssetsURL(`builds/meta/${ssrContext.runtimeConfig.app.buildId}.json`) }
|
|||
|
|
]
|
|||
|
|
}, { ...headEntryOptions, tagPriority: "low" });
|
|||
|
|
}
|
|||
|
|
if (inlinedStyles.length) {
|
|||
|
|
head.push({ style: inlinedStyles });
|
|||
|
|
}
|
|||
|
|
{
|
|||
|
|
const link = [];
|
|||
|
|
for (const resource of Object.values(styles)) {
|
|||
|
|
{
|
|||
|
|
link.push({ rel: "stylesheet", href: renderer.rendererContext.buildAssetsURL(resource.file), crossorigin: "" });
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (link.length) {
|
|||
|
|
head.push({ link }, headEntryOptions);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (!NO_SCRIPTS) {
|
|||
|
|
head.push({
|
|||
|
|
link: getPreloadLinks(ssrContext, renderer.rendererContext)
|
|||
|
|
}, headEntryOptions);
|
|||
|
|
head.push({
|
|||
|
|
link: getPrefetchLinks(ssrContext, renderer.rendererContext)
|
|||
|
|
}, headEntryOptions);
|
|||
|
|
head.push({
|
|||
|
|
script: _PAYLOAD_EXTRACTION ? renderPayloadJsonScript({ ssrContext, data: splitPayload(ssrContext).initial, src: payloadURL }) : renderPayloadJsonScript({ ssrContext, data: ssrContext.payload })
|
|||
|
|
}, {
|
|||
|
|
...headEntryOptions,
|
|||
|
|
// this should come before another end of body scripts
|
|||
|
|
tagPosition: "bodyClose",
|
|||
|
|
tagPriority: "high"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
if (!routeOptions.noScripts) {
|
|||
|
|
head.push({
|
|||
|
|
script: Object.values(scripts).map((resource) => ({
|
|||
|
|
type: resource.module ? "module" : null,
|
|||
|
|
src: renderer.rendererContext.buildAssetsURL(resource.file),
|
|||
|
|
defer: resource.module ? null : true,
|
|||
|
|
// if we are rendering script tag payloads that import an async payload
|
|||
|
|
// we need to ensure this resolves before executing the Nuxt entry
|
|||
|
|
tagPosition: "head",
|
|||
|
|
crossorigin: ""
|
|||
|
|
}))
|
|||
|
|
}, headEntryOptions);
|
|||
|
|
}
|
|||
|
|
const { headTags, bodyTags, bodyTagsOpen, htmlAttrs, bodyAttrs } = await renderSSRHead(head, renderSSRHeadOptions);
|
|||
|
|
const htmlContext = {
|
|||
|
|
island: isRenderingIsland,
|
|||
|
|
htmlAttrs: htmlAttrs ? [htmlAttrs] : [],
|
|||
|
|
head: normalizeChunks([headTags]),
|
|||
|
|
bodyAttrs: bodyAttrs ? [bodyAttrs] : [],
|
|||
|
|
bodyPrepend: normalizeChunks([bodyTagsOpen, ssrContext.teleports?.body]),
|
|||
|
|
body: [
|
|||
|
|
_rendered.html,
|
|||
|
|
APP_TELEPORT_OPEN_TAG + (HAS_APP_TELEPORTS ? joinTags([ssrContext.teleports?.[`#${appTeleportAttrs.id}`]]) : "") + APP_TELEPORT_CLOSE_TAG
|
|||
|
|
],
|
|||
|
|
bodyAppend: [bodyTags]
|
|||
|
|
};
|
|||
|
|
await nitroApp.hooks.callHook("render:html", htmlContext, { event });
|
|||
|
|
const response = {
|
|||
|
|
body: renderHTMLDocument(htmlContext),
|
|||
|
|
statusCode: getResponseStatus(event),
|
|||
|
|
statusMessage: getResponseStatusText(event),
|
|||
|
|
headers: {
|
|||
|
|
"content-type": "text/html;charset=utf-8",
|
|||
|
|
"x-powered-by": "Nuxt"
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
return response;
|
|||
|
|
});
|
|||
|
|
function normalizeChunks(chunks) {
|
|||
|
|
return chunks.filter(Boolean).map((i) => i.trim());
|
|||
|
|
}
|
|||
|
|
function joinTags(tags) {
|
|||
|
|
return tags.join("");
|
|||
|
|
}
|
|||
|
|
function joinAttrs(chunks) {
|
|||
|
|
if (chunks.length === 0) {
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
return " " + chunks.join(" ");
|
|||
|
|
}
|
|||
|
|
function renderHTMLDocument(html) {
|
|||
|
|
return `<!DOCTYPE html><html${joinAttrs(html.htmlAttrs)}><head>${joinTags(html.head)}</head><body${joinAttrs(html.bodyAttrs)}>${joinTags(html.bodyPrepend)}${joinTags(html.body)}${joinTags(html.bodyAppend)}</body></html>`;
|
|||
|
|
}
|
|||
|
|
async function renderInlineStyles(usedModules) {
|
|||
|
|
const styleMap = await getSSRStyles();
|
|||
|
|
const inlinedStyles = /* @__PURE__ */ new Set();
|
|||
|
|
for (const mod of usedModules) {
|
|||
|
|
if (mod in styleMap && styleMap[mod]) {
|
|||
|
|
for (const style of await styleMap[mod]()) {
|
|||
|
|
inlinedStyles.add(style);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return Array.from(inlinedStyles).map((style) => ({ innerHTML: style }));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const renderer$1 = /*#__PURE__*/Object.freeze({
|
|||
|
|
__proto__: null,
|
|||
|
|
default: renderer
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
export { headSymbol as h, renderer$1 as r, useHead as u };
|
|||
|
|
//# sourceMappingURL=renderer.mjs.map
|