mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-11 06:30:03 +00:00
fix(product-launch): consolidate media brand and audio contracts (#2408)
* fix(product-launch): preserve hoisted media offsets * fix(product-launch): preserve brand font and accent roles * fix(product-launch): honor TTS provider selection * fix(product-launch): preserve approved video geometry * fix(skills): enforce media geometry and font classification * fix(skills): align secondary brand accents
This commit is contained in:
@@ -48,6 +48,13 @@ export const UA_DEFAULT_COLORS = new Set(
|
||||
["#0000EE", "#0000FF", "#0000CC", "#1A0DAB", "#551A8B", "#EE0000"].map((c) => c.toUpperCase()),
|
||||
);
|
||||
|
||||
export const ICON_FONT_PATTERN =
|
||||
/(?:^|[\s_-])icons?(?:[\s_-]|$)|icomoon|font\s*-?awesome|glyphicons?|material\s*icons|feather\s*icons|(?:icon|glyph).*font|font.*(?:icon|glyph)|^vidaxlfont$/i;
|
||||
|
||||
export function isIconFont(name) {
|
||||
return ICON_FONT_PATTERN.test(String(name));
|
||||
}
|
||||
|
||||
// Semantic STATUS roles (green "positive", red "negative"/"error", amber "warning" …). Their HUE
|
||||
// carries the meaning, so they are never a brand ACCENT — a status red is frequently the most
|
||||
// chromatic color in a palette (e.g. #dc2626 chroma 182 beats a deep-blue accent #1E40AF chroma
|
||||
@@ -127,15 +134,7 @@ export function brandRolesFromStats(stats, colorsInOrder) {
|
||||
.find((s) => Math.abs((lum(s.hex) ?? 0) - cl) > 64)?.hex ??
|
||||
(cl > 128 ? "#000000" : "#FFFFFF");
|
||||
const accent2 =
|
||||
v
|
||||
.filter(
|
||||
(s) =>
|
||||
![canvas, ink, accent].includes(s.hex) &&
|
||||
(s.interactiveBg || 0) > 0 &&
|
||||
chroma(s.hex) > 40 &&
|
||||
!UA_DEFAULT_COLORS.has(s.hex.toUpperCase()),
|
||||
)
|
||||
.sort((a, b) => (b.interactiveBg || 0) - (a.interactiveBg || 0))[0]?.hex ?? accent;
|
||||
pickAccent(v, colorsInOrder ?? v.map((s) => s.hex), [canvas, ink, accent]) ?? accent;
|
||||
return { ink, canvas, accent, accent2 };
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import test from "node:test";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { brandRolesFromStats, ICON_FONT_PATTERN, isIconFont } from "./tokens.mjs";
|
||||
import { brandRolesFromStats as facelessBrandRolesFromStats } from "../../../faceless-explainer/scripts/lib/tokens.mjs";
|
||||
import { brandRolesFromStats as prBrandRolesFromStats } from "../../../pr-to-video/scripts/lib/tokens.mjs";
|
||||
|
||||
const scriptsDir = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "..");
|
||||
|
||||
test("recognizes brand-specific icon font names", () => {
|
||||
assert.equal(isIconFont("vidaXLfont"), true);
|
||||
assert.equal(isIconFont("BrandGlyphFont"), true);
|
||||
assert.equal(isIconFont("Poppins"), false);
|
||||
assert.equal(isIconFont("HelveticaFont"), false);
|
||||
assert.equal(isIconFont("Airbnb Cereal Font"), false);
|
||||
assert.equal(isIconFont("SF Pro Text Font"), false);
|
||||
assert.equal(isIconFont("Uber Move Font"), false);
|
||||
assert.equal(isIconFont("Circular Std font"), false);
|
||||
assert.equal(isIconFont("brand-font"), false);
|
||||
});
|
||||
|
||||
test("keeps sibling skill icon-font classifiers aligned", () => {
|
||||
for (const skill of ["faceless-explainer", "pr-to-video"]) {
|
||||
const source = readFileSync(join(scriptsDir, skill, "scripts", "build-frame.mjs"), "utf8");
|
||||
assert.match(
|
||||
source,
|
||||
new RegExp(String.raw`ICON_FONT_PATTERN\s*=\s*${escapeRegExp(ICON_FONT_PATTERN)}`),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
function escapeRegExp(value) {
|
||||
return String(value).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
}
|
||||
|
||||
test("preserves a prominent second accent used outside interactive backgrounds", () => {
|
||||
const colors = ["#FFFFFF", "#2D1238", "#F3E62B", "#111111"];
|
||||
const stats = [
|
||||
{ hex: "#FFFFFF", areaBg: 1000, maxArea: 1000 },
|
||||
{ hex: "#2D1238", textCount: 4, interactiveBg: 3 },
|
||||
{ hex: "#F3E62B", textCount: 3, interactiveBg: 0 },
|
||||
{ hex: "#111111", textCount: 20 },
|
||||
];
|
||||
|
||||
assert.deepEqual(brandRolesFromStats(stats, colors), {
|
||||
canvas: "#FFFFFF",
|
||||
ink: "#111111",
|
||||
accent: "#F3E62B",
|
||||
accent2: "#2D1238",
|
||||
});
|
||||
|
||||
for (const sibling of [facelessBrandRolesFromStats, prBrandRolesFromStats]) {
|
||||
assert.deepEqual(sibling(stats, colors), brandRolesFromStats(stats, colors));
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user