nitro-nightly 3.0.1-20251109-134450-553d8f46 → 3.0.1-20251109-184848-3a5337c9
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/_build/common2.mjs
CHANGED
|
@@ -600,19 +600,28 @@ export default async function(error, event) {
|
|
|
600
600
|
//#region src/build/plugins/renderer-template.ts
|
|
601
601
|
function rendererTemplate(nitro) {
|
|
602
602
|
return virtual({ "#nitro-internal-virtual/renderer-template": async () => {
|
|
603
|
-
|
|
604
|
-
if (
|
|
603
|
+
const template = nitro.options.renderer?.template;
|
|
604
|
+
if (typeof template !== "string") return `
|
|
605
|
+
export const rendererTemplate = () => '<!-- renderer.template is not set -->';
|
|
606
|
+
export const rendererTemplateFile = undefined;
|
|
607
|
+
export const isStaticTemplate = true;`;
|
|
608
|
+
if (nitro.options.dev) return `
|
|
609
|
+
import { readFile } from 'node:fs/promises';
|
|
610
|
+
export const rendererTemplate = () => readFile(${JSON.stringify(template)}, "utf8");
|
|
611
|
+
export const rendererTemplateFile = ${JSON.stringify(template)};
|
|
612
|
+
export const isStaticTemplate = ${JSON.stringify(nitro.options.renderer?.static)};
|
|
613
|
+
`;
|
|
605
614
|
else {
|
|
606
|
-
const html = await readFile(
|
|
607
|
-
if (hasTemplateSyntax(html)) return `
|
|
615
|
+
const html = await readFile(template, "utf8");
|
|
616
|
+
if (nitro.options.renderer?.static ?? !hasTemplateSyntax(html)) return `
|
|
617
|
+
import { HTTPResponse } from "h3";
|
|
618
|
+
export const rendererTemplate = () => new HTTPResponse(${JSON.stringify(html)}, { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
619
|
+
`;
|
|
620
|
+
else return `
|
|
608
621
|
import { renderToResponse } from 'rendu'
|
|
609
622
|
import { serverFetch } from 'nitro/app'
|
|
610
623
|
const template = ${compileTemplateToString(html, { contextKeys: [...RENDER_CONTEXT_KEYS] })};
|
|
611
624
|
export const rendererTemplate = (request) => renderToResponse(template, { request, context: { serverFetch } })
|
|
612
|
-
`;
|
|
613
|
-
else return `
|
|
614
|
-
import { HTTPResponse } from "h3";
|
|
615
|
-
export const rendererTemplate = () => new HTTPResponse(${JSON.stringify(html)}, { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
616
625
|
`;
|
|
617
626
|
}
|
|
618
627
|
} }, nitro.vfs);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { serverFetch } from "../app.mjs";
|
|
2
|
-
import { rendererTemplate, rendererTemplateFile } from "#nitro-internal-virtual/renderer-template";
|
|
2
|
+
import { rendererTemplate, rendererTemplateFile, isStaticTemplate } from "#nitro-internal-virtual/renderer-template";
|
|
3
3
|
import { HTTPResponse } from "h3";
|
|
4
4
|
import { hasTemplateSyntax, renderToResponse, compileTemplate } from "rendu";
|
|
5
5
|
export default async function renderIndexHTML(event) {
|
|
@@ -7,7 +7,8 @@ export default async function renderIndexHTML(event) {
|
|
|
7
7
|
if (globalThis.__transform_html__) {
|
|
8
8
|
html = await globalThis.__transform_html__(html);
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
const isStatic = isStaticTemplate ?? !hasTemplateSyntax(html);
|
|
11
|
+
if (isStatic) {
|
|
11
12
|
return new HTTPResponse(html, { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
12
13
|
}
|
|
13
14
|
const template = compileTemplate(html, { filename: rendererTemplateFile });
|
package/dist/types/index.d.mts
CHANGED
package/package.json
CHANGED