// Post-export step: inject PWA manifest link, theme color, and apple-touch meta
// into the SPA index.html. Expo's `single` web output does not use +html.tsx,
// so we patch the generated file directly. Idempotent.
import { readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
const dist = process.argv[2] || "dist";
const file = join(dist, "index.html");
const HEAD = `
`;
let html = readFileSync(file, "utf8");
if (!html.includes('rel="manifest"')) {
html = html.replace("", `${HEAD}\n `);
}
// Allow full-screen camera: disable user zoom, cover the notch.
html = html.replace(
/]*\/>/,
'',
);
writeFileSync(file, html);
console.log("inject-pwa: patched", file);