466 lines
16 KiB
JavaScript
466 lines
16 KiB
JavaScript
import { createRenderer, getRequestDependencies, getPreloadLinks, getPrefetchLinks } from 'vue-bundle-renderer/runtime';
|
|
import { j as joinRelativeURL, u as useRuntimeConfig, i as getResponseStatusText, k as getResponseStatus, l as defineRenderHandler, h as getQuery, c as createError, m as destr, n as getRouteRules, o as relative, p as joinURL, q as useNitroApp } from '../nitro/nitro.mjs';
|
|
import { renderToString } from 'vue/server-renderer';
|
|
import { createHead as createHead$1, propsToString, renderSSRHead } from 'unhead/server';
|
|
import { stringify, uneval } from 'devalue';
|
|
import { walkResolver } from 'unhead/utils';
|
|
import { toValue, isRef, hasInjectionContext, inject, ref, watchEffect, getCurrentInstance, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
|
|
|
|
const VueResolver = (_, value) => {
|
|
return isRef(value) ? toValue(value) : value;
|
|
};
|
|
|
|
const headSymbol = "usehead";
|
|
// @__NO_SIDE_EFFECTS__
|
|
function vueInstall(head) {
|
|
const plugin = {
|
|
install(app) {
|
|
app.config.globalProperties.$unhead = head;
|
|
app.config.globalProperties.$head = head;
|
|
app.provide(headSymbol, head);
|
|
}
|
|
};
|
|
return plugin.install;
|
|
}
|
|
|
|
// @__NO_SIDE_EFFECTS__
|
|
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 || /* @__PURE__ */ 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;
|
|
}
|
|
|
|
// @__NO_SIDE_EFFECTS__
|
|
function createHead(options = {}) {
|
|
const head = createHead$1({
|
|
...options,
|
|
propResolvers: [VueResolver]
|
|
});
|
|
head.install = vueInstall(head);
|
|
return head;
|
|
}
|
|
|
|
const appHead = {"meta":[{"charset":"utf-8"},{"name":"viewport","content":"width=device-width, initial-scale=1"},{"name":"description","content":"Willkommen beim Harheimer Tischtennis Club - Ihr Tischtennisverein in Frankfurt-Harheim. Mitglied werden, Training buchen, Turniere und mehr."},{"name":"keywords","content":"Tischtennis, Tischtennisclub, Frankfurt, Harheim, Sport, Verein, Mitgliedschaft, Pingpong"}],"link":[{"rel":"preconnect","href":"https://fonts.googleapis.com"},{"rel":"preconnect","href":"https://fonts.gstatic.com","crossorigin":""},{"rel":"stylesheet","href":"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Montserrat:wght@700;800;900&display=swap"}],"style":[],"script":[],"noscript":[],"title":"Harheimer TC - Tischtennis in Frankfurt-Harheim"};
|
|
|
|
const appRootTag = "div";
|
|
|
|
const appRootAttrs = {"id":"__nuxt"};
|
|
|
|
const appTeleportTag = "div";
|
|
|
|
const appTeleportAttrs = {"id":"teleports"};
|
|
|
|
const appSpaLoaderTag = "div";
|
|
|
|
const appSpaLoaderAttrs = {"id":"__nuxt-loader"};
|
|
|
|
const appId = "nuxt-app";
|
|
|
|
function baseURL() {
|
|
return useRuntimeConfig().app.baseURL;
|
|
}
|
|
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 getServerEntry = () => import('../build/server.mjs').then((r) => r.default || r);
|
|
const getClientManifest = () => import('../build/client.manifest.mjs').then((r) => r.default || r).then((r) => typeof r === "function" ? r() : 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) => {
|
|
{
|
|
const APP_SPA_LOADER_OPEN_TAG = `<${appSpaLoaderTag}${propsToString(appSpaLoaderAttrs)}>`;
|
|
const APP_SPA_LOADER_CLOSE_TAG = `</${appSpaLoaderTag}>`;
|
|
const appTemplate = APP_ROOT_OPEN_TAG + APP_ROOT_CLOSE_TAG;
|
|
const loaderTemplate = r ? APP_SPA_LOADER_OPEN_TAG + r + APP_SPA_LOADER_CLOSE_TAG : "";
|
|
return appTemplate + loaderTemplate;
|
|
}
|
|
});
|
|
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;
|
|
};
|
|
}
|
|
function getRenderer(ssrContext) {
|
|
return ssrContext.noSSR ? getSPARenderer() : getSSRRenderer();
|
|
}
|
|
const getSSRStyles = lazyCachedFunction(() => import('../build/styles.mjs').then((r) => r.default || r));
|
|
const getEntryIds = () => getClientManifest().then((r) => {
|
|
const entryIds = [];
|
|
for (const entry of Object.values(r)) {
|
|
if (entry._globalCSS) {
|
|
entryIds.push(entry.src);
|
|
}
|
|
}
|
|
return entryIds;
|
|
});
|
|
|
|
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,
|
|
};
|
|
|
|
function createSSRContext(event) {
|
|
const ssrContext = {
|
|
url: event.path,
|
|
event,
|
|
runtimeConfig: useRuntimeConfig(event),
|
|
noSSR: event.context.nuxt?.noSSR || (false),
|
|
head: createHead(unheadOptions),
|
|
error: false,
|
|
nuxt: void 0,
|
|
/* NuxtApp */
|
|
payload: {},
|
|
_payloadReducers: /* @__PURE__ */ Object.create(null),
|
|
modules: /* @__PURE__ */ new Set()
|
|
};
|
|
return ssrContext;
|
|
}
|
|
function setSSRError(ssrContext, error) {
|
|
ssrContext.error = true;
|
|
ssrContext.payload = { error };
|
|
ssrContext.url = error.url;
|
|
}
|
|
|
|
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 renderSSRHeadOptions = {"omitLineBreaks":true};
|
|
|
|
const entryFileName = "oL_Xi1h-.js";
|
|
|
|
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(?:\?.*)?$/ ;
|
|
let entryPath;
|
|
const renderer = defineRenderHandler(async (event) => {
|
|
const nitroApp = useNitroApp();
|
|
const ssrError = event.path.startsWith("/__nuxt_error") ? getQuery(event) : null;
|
|
if (ssrError && !("__unenv__" in event.node.req)) {
|
|
throw createError({
|
|
statusCode: 404,
|
|
statusMessage: "Page Not Found: /__nuxt_error"
|
|
});
|
|
}
|
|
const ssrContext = createSSRContext(event);
|
|
const headEntryOptions = { mode: "server" };
|
|
ssrContext.head.push(appHead, headEntryOptions);
|
|
if (ssrError) {
|
|
ssrError.statusCode &&= Number.parseInt(ssrError.statusCode);
|
|
if (typeof ssrError.data === "string") {
|
|
try {
|
|
ssrError.data = destr(ssrError.data);
|
|
} catch {
|
|
}
|
|
}
|
|
setSSRError(ssrContext, ssrError);
|
|
}
|
|
const isRenderingPayload = PAYLOAD_URL_RE.test(ssrContext.url);
|
|
if (isRenderingPayload) {
|
|
const url = ssrContext.url.substring(0, ssrContext.url.lastIndexOf("/")) || "/";
|
|
ssrContext.url = url;
|
|
event._path = event.node.req.url = url;
|
|
}
|
|
const routeOptions = getRouteRules(event);
|
|
if (routeOptions.ssr === false) {
|
|
ssrContext.noSSR = true;
|
|
}
|
|
const renderer = await getRenderer(ssrContext);
|
|
{
|
|
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;
|
|
});
|
|
const inlinedStyles = !ssrContext._renderResponse && !isRenderingPayload ? await renderInlineStyles(ssrContext.modules ?? []) : [];
|
|
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 response = renderPayloadResponse(ssrContext);
|
|
return response;
|
|
}
|
|
const NO_SCRIPTS = routeOptions.noScripts;
|
|
const { styles, scripts } = getRequestDependencies(ssrContext, renderer.rendererContext);
|
|
if (!NO_SCRIPTS) {
|
|
let path = entryPath;
|
|
if (!path) {
|
|
path = buildAssetsURL(entryFileName);
|
|
if (ssrContext.runtimeConfig.app.cdnURL || /^(?:\/|\.+\/)/.test(path)) {
|
|
entryPath = path;
|
|
} else {
|
|
path = relative(event.path.replace(/\/[^/]+$/, "/"), joinURL("/", path));
|
|
if (!/^(?:\/|\.+\/)/.test(path)) {
|
|
path = `./${path}`;
|
|
}
|
|
}
|
|
}
|
|
ssrContext.head.push({
|
|
script: [{
|
|
tagPosition: "head",
|
|
tagPriority: -2,
|
|
type: "importmap",
|
|
innerHTML: JSON.stringify({ imports: { "#entry": path } })
|
|
}]
|
|
}, headEntryOptions);
|
|
}
|
|
if (ssrContext._preloadManifest && !NO_SCRIPTS) {
|
|
ssrContext.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) {
|
|
ssrContext.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) {
|
|
ssrContext.head.push({ link }, headEntryOptions);
|
|
}
|
|
if (!NO_SCRIPTS) {
|
|
ssrContext.head.push({
|
|
link: getPreloadLinks(ssrContext, renderer.rendererContext)
|
|
}, headEntryOptions);
|
|
ssrContext.head.push({
|
|
link: getPrefetchLinks(ssrContext, renderer.rendererContext)
|
|
}, headEntryOptions);
|
|
ssrContext.head.push({
|
|
script: renderPayloadJsonScript({ ssrContext, data: ssrContext.payload })
|
|
}, {
|
|
...headEntryOptions,
|
|
// this should come before another end of body scripts
|
|
tagPosition: "bodyClose",
|
|
tagPriority: "high"
|
|
});
|
|
}
|
|
if (!routeOptions.noScripts) {
|
|
const tagPosition = "head";
|
|
ssrContext.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,
|
|
crossorigin: ""
|
|
}))
|
|
}, headEntryOptions);
|
|
}
|
|
const { headTags, bodyTags, bodyTagsOpen, htmlAttrs, bodyAttrs } = await renderSSRHead(ssrContext.head, renderSSRHeadOptions);
|
|
const htmlContext = {
|
|
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 });
|
|
return {
|
|
body: renderHTMLDocument(htmlContext),
|
|
statusCode: getResponseStatus(event),
|
|
statusMessage: getResponseStatusText(event),
|
|
headers: {
|
|
"content-type": "text/html;charset=utf-8",
|
|
"x-powered-by": "Nuxt"
|
|
}
|
|
};
|
|
});
|
|
function normalizeChunks(chunks) {
|
|
const result = [];
|
|
for (const _chunk of chunks) {
|
|
const chunk = _chunk?.trim();
|
|
if (chunk) {
|
|
result.push(chunk);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
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>`;
|
|
}
|
|
|
|
const renderer$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
__proto__: null,
|
|
default: renderer
|
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
|
|
export { baseURL as b, headSymbol as h, renderer$1 as r, useHead as u };
|
|
//# sourceMappingURL=renderer.mjs.map
|