import { readdir, readFile } from "node:fs/promises"; import { stdout } from "node:process"; import { fileURLToPath, URL } from "node:url"; import path from "node:path"; const assetsDirectory = fileURLToPath(new URL("../dist/assets/", import.meta.url)); const assetNames = await readdir(assetsDirectory); const stylesheetName = assetNames.find((name) => /^index-.*\.css$/.test(name)); if (!stylesheetName) { throw new Error("Production CSS verification failed: index stylesheet was not emitted."); } const stylesheet = await readFile(path.join(assetsDirectory, stylesheetName), "utf8"); const selector = ".agent-panel-shell.acrylic-panel"; const selectorOffset = stylesheet.indexOf(selector); const ruleStart = stylesheet.indexOf("{", selectorOffset); const ruleEnd = stylesheet.indexOf("}", ruleStart); if (selectorOffset < 0 || ruleStart < 0 || ruleEnd < 0) { throw new Error(`Production CSS verification failed: ${selector} rule is missing.`); } const declarations = stylesheet .slice(ruleStart + 1, ruleEnd) .split(";") .map((declaration) => declaration.trim()); if (!declarations.some((declaration) => declaration.startsWith("backdrop-filter:"))) { throw new Error( "Production CSS verification failed: the standard backdrop-filter declaration was removed." ); } stdout.write(`Verified standard backdrop-filter in ${stylesheetName}.\n`);