import type { Plugin } from "vite"; import { locales, isLang, resolveLang } from "../src/client/locales/index.ts"; import { LANG_STORAGE_KEY, readStoredCopy } from "../src/client/ui/copy.ts"; /** The React startup boundary cannot render before its entry module loads. */ export function startupFallback(): Plugin { const copy = Object.fromEntries(Object.entries(locales).map(([lang, { copy: catalog }]) => [lang, [catalog["startup.failed"], catalog["startup.retry"], catalog["common.refresh"]]])); return { name: "startup-fallback", transformIndexHtml: { order: "post", handler(html) { if (!html.includes('
')) return; html = html.replace(/