import { readFile, writeFile, copyFile } from 'fs/promises';
import { join } from 'path';
import { tryExecute } from '@/utils/node/logging';
import { pathExists } from '@/utils/node/fs';
import { getAssetPath } from '@/utils/node/path';
const KLITE_CSS_OVERRIDE = `
`;
export const patchKliteEmbd = (unpackedDir: string) =>
tryExecute(async () => {
const possiblePaths = [
join(unpackedDir, '_internal', 'embd_res', 'klite.embd'),
join(unpackedDir, 'embd_res', 'klite.embd'),
];
let kliteEmbdPath: string | null = null;
for (const path of possiblePaths) {
if (await pathExists(path)) {
kliteEmbdPath = path;
break;
}
}
if (!kliteEmbdPath) {
return;
}
const content = await readFile(kliteEmbdPath, 'utf8');
if (content.includes('')) {
let patchedContent = content;
if (content.includes('gerbil-css-override')) {
patchedContent = patchedContent.replace(
/