Files
assistant-ui--assistant-ui/packages/react-devtools/scripts/build-styles.mjs
T
wehub-resource-sync e30e75b5d4
Changesets / Create Version PR (push) Has been cancelled
Deploy Shadcn Registry / Deploy Production (push) Has been cancelled
Template Metrics / LOC + Bundle Size (push) Has been cancelled
Code Quality / Oxlint + Oxfmt (push) Has been cancelled
Code Quality / Template Sync (push) Has been cancelled
Code Quality / Build Changed Packages (push) Has been cancelled
Code Quality / Test Changed Packages (push) Has been cancelled
Deploy Expo Example / Deploy Production (push) Has been cancelled
Deploy Ink Example / Deploy Production (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.12) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.12) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:40:13 +08:00

47 lines
1.6 KiB
JavaScript

import { execFileSync } from "node:child_process";
import { readFileSync, rmSync, writeFileSync } from "node:fs";
import { createRequire } from "node:module";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const input = resolve(root, "src/styles/panel.css");
const tmp = resolve(root, "src/styles/.panel.out.css");
const output = resolve(root, "src/styles/panel.generated.ts");
const require = createRequire(import.meta.url);
const cliPackagePath = require.resolve("@tailwindcss/cli/package.json");
const cliPackage = JSON.parse(readFileSync(cliPackagePath, "utf8"));
const cliBin =
typeof cliPackage.bin === "string"
? cliPackage.bin
: cliPackage.bin.tailwindcss;
const tailwindCli = join(dirname(cliPackagePath), cliBin);
execFileSync(
process.execPath,
[tailwindCli, "-i", input, "-o", tmp, "--minify"],
{
cwd: root,
stdio: "inherit",
},
);
let css = readFileSync(tmp, "utf8");
rmSync(tmp, { force: true });
// The compiled sheet is injected into a shadow root, where `:root` never
// matches. Move Tailwind's theme/preflight layers onto `:host` so the custom
// properties and base styles reach the panel. Our own token blocks already
// target `:host`/`.dark`.
css = css.replaceAll(":root", ":host");
const banner =
"// Generated by scripts/build-styles.mjs. Do not edit by hand.\n";
writeFileSync(
output,
`${banner}export const panelCss = ${JSON.stringify(css)};\n`,
);
console.log(`wrote ${output} (${css.length} bytes of css)`);