'use strict'; const assert = require('assert'); const { getSerializableSpans } = require('../tracing/tracing-middleware'); const renderHydrogenToString = require('../hydrogen-render/render-hydrogen-to-string'); const sanitizeHtml = require('../lib/sanitize-html'); const safeJson = require('../lib/safe-json'); async function renderHydrogenVmRenderScriptToPageHtml( vmRenderScriptFilePath, vmRenderContext, pageOptions ) { assert(vmRenderScriptFilePath); assert(vmRenderContext); assert(pageOptions); assert(pageOptions.title); assert(pageOptions.styles); assert(pageOptions.scripts); assert(pageOptions.cspNonce); const hydrogenHtmlOutput = await renderHydrogenToString({ vmRenderScriptFilePath, vmRenderContext, pageOptions, }); const serializableSpans = getSerializableSpans(); const serializedSpans = JSON.stringify(serializableSpans); // We shouldn't let some pages be indexed by search engines let maybeNoIndexHtml = ''; if (!pageOptions.shouldIndex) { maybeNoIndexHtml = ``; } const pageHtml = `
${maybeNoIndexHtml} ${sanitizeHtml(`