(html: string)
| 54 | |
| 55 | /** Inject the runtime <script> into composition HTML before </body> (or at the end). */ |
| 56 | export function injectRuntime(html: string): string { |
| 57 | const runtimeTag = `<script src="/runtime.js"></script>`; |
| 58 | return html.includes("</body>") |
| 59 | ? html.replace("</body>", `${runtimeTag}\n</body>`) |
| 60 | : html + `\n${runtimeTag}`; |
| 61 | } |
| 62 | |
| 63 | const ASSET_CONTENT_TYPES: Record<string, string> = { |
| 64 | js: "application/javascript", |