Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
76 lines
2.6 KiB
JavaScript
76 lines
2.6 KiB
JavaScript
/**
|
|
* Build `@reelforge/ui-kit`'s framework-free `tokens.json` into the desktop
|
|
* Rust theme (`apps/desktop/crates/rf-theme/src/palette.rs`), so the native
|
|
* Rust/GPUI app shares the SAME palette as web/mobile/electron (packages.md §16).
|
|
*
|
|
* Run: `node scripts/gen_rf_theme.mjs` (from the repo root). `--check` fails if
|
|
* the committed palette.rs is stale (drift guard for CI).
|
|
*/
|
|
|
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import { dirname, join } from "node:path";
|
|
|
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
const root = join(here, "..");
|
|
const tokensPath = join(root, "packages", "ui-kit", "src", "tokens", "tokens.json");
|
|
const outPath = join(root, "apps", "desktop", "crates", "rf-theme", "src", "palette.rs");
|
|
|
|
const t = JSON.parse(readFileSync(tokensPath, "utf8"));
|
|
|
|
function screaming(name) {
|
|
return name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[- ]/g, "_").toUpperCase();
|
|
}
|
|
function hexToRgb(hex) {
|
|
const h = hex.replace(/^#/, "");
|
|
return [parseInt(h.slice(0, 2), 16), parseInt(h.slice(2, 4), 16), parseInt(h.slice(4, 6), 16)];
|
|
}
|
|
|
|
const lines = [];
|
|
lines.push("// @generated by scripts/gen_rf_theme.mjs from packages/ui-kit/src/tokens/tokens.json");
|
|
lines.push("// Do not edit by hand — re-run the generator after changing the ui-kit tokens.");
|
|
lines.push("");
|
|
lines.push("use super::Rgb;");
|
|
lines.push("");
|
|
lines.push("// --- Colors ---");
|
|
for (const [name, hex] of Object.entries(t.colors)) {
|
|
const [r, g, b] = hexToRgb(hex);
|
|
lines.push(`pub const ${screaming(name)}: Rgb = Rgb(${r}, ${g}, ${b});`);
|
|
}
|
|
lines.push("");
|
|
lines.push("// --- Platform brand colors ---");
|
|
for (const [name, hex] of Object.entries(t.platformColors)) {
|
|
const [r, g, b] = hexToRgb(hex);
|
|
lines.push(`pub const PLATFORM_${screaming(name)}: Rgb = Rgb(${r}, ${g}, ${b});`);
|
|
}
|
|
lines.push("");
|
|
lines.push("// --- Spacing (px) ---");
|
|
for (const [name, v] of Object.entries(t.spacing)) {
|
|
lines.push(`pub const SPACING_${screaming(name)}: u32 = ${v};`);
|
|
}
|
|
lines.push("");
|
|
lines.push("// --- Radii (px) ---");
|
|
for (const [name, v] of Object.entries(t.radii)) {
|
|
lines.push(`pub const RADIUS_${screaming(name)}: u32 = ${v};`);
|
|
}
|
|
lines.push("");
|
|
|
|
const out = lines.join("\n");
|
|
|
|
if (process.argv.includes("--check")) {
|
|
let current = "";
|
|
try {
|
|
current = readFileSync(outPath, "utf8");
|
|
} catch {
|
|
/* missing */
|
|
}
|
|
if (current !== out) {
|
|
console.error(`STALE: ${outPath} — re-run scripts/gen_rf_theme.mjs`);
|
|
process.exit(1);
|
|
}
|
|
console.log("rf-theme palette is current.");
|
|
} else {
|
|
writeFileSync(outPath, out);
|
|
console.log(`wrote ${outPath} (${Object.keys(t.colors).length} colors)`);
|
|
}
|