import ejs from "ejs"; import type { Response } from "express"; import fs from "fs/promises"; import { buildAssetUrl } from "../core/AssetUrls"; import { setNoStoreHeaders } from "./NoStoreHeaders"; import { getRuntimeAssetManifest } from "./RuntimeAssetManifest"; const APP_SHELL_CACHE_CONTROL = "public, max-age=0, s-maxage=300, stale-while-revalidate=86400"; const appShellContentCache = new Map>(); export async function renderHtmlContent(htmlPath: string): Promise { const htmlContent = await fs.readFile(htmlPath, "utf-8"); const assetManifest = await getRuntimeAssetManifest(); const cdnBase = process.env.CDN_BASE ?? ""; return ejs.render(htmlContent, { gitCommit: JSON.stringify(process.env.GIT_COMMIT ?? "undefined"), assetManifest: JSON.stringify(assetManifest), cdnBase: JSON.stringify(cdnBase), // Raw (unquoted) value for use as a URL prefix in the index.html template, // e.g.