import fs from "node:fs"; const file = "/app/index.html"; let html = fs.readFileSync(file, "utf8"); const pkg = JSON.parse(fs.readFileSync("/app/package.json", "utf8")); const logo = fs.readFileSync('/app/assets/logo.jpg').toString('base64'); const og = fs.readFileSync('/app/assets/og.jpg').toString('base64'); // Keep structured metadata aligned with the release deployed from GitHub. html = html.replace(/"softwareVersion"\s*:\s*"[^"]+"/g, `"softwareVersion":"${pkg.version}"`); // Embed the approved production images directly in the visible UI so they do // not depend on Hugging Face proxy/base-path routing. Metadata continues to // use the public /assets URLs for social crawlers and previews. html = html.replace( /src=(['"])\/assets\/logo\.jpg(?:\?[^'\"]*)?\1/g, `src="data:image/jpeg;base64,${logo}"` ); html = html.replace( /src=(['"])\/assets\/og\.jpg(?:\?[^'\"]*)?\1/g, `src="data:image/jpeg;base64,${og}"` ); if (!html.includes("url-agent-ui-enhancement-v3")) { const css = fs.readFileSync("/app/ui-v2.css", "utf8"); const js = fs.readFileSync("/app/ui-v2.js", "utf8"); html = html.replace( "", `\n` ); html = html.replace( "", `\n` ); } fs.writeFileSync(file, html); console.log(`Approved branding embedded into visible Hugging Face UI; softwareVersion=${pkg.version}`);