Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion packages/engine/src/services/frameCapture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,21 @@ export async function initializeSession(session: CaptureSession): Promise<void>
page.on("console", (msg: ConsoleMessage) => {
const type = msg.type();
const text = msg.text();

// Suppress font-loading 404s only. These are expected when deterministic
// font injection replaces Google Fonts @import URLs with embedded base64.
// Narrowed to font CDN domains and font file extensions to avoid hiding
// real asset failures (images, scripts, videos).
const isFontLoadError =
type === "error" &&
text.startsWith("Failed to load resource") &&
/fonts\.googleapis|fonts\.gstatic|\.woff2?(\b|$)/i.test(text);

const prefix =
type === "error" ? "[Browser:ERROR]" : type === "warn" ? "[Browser:WARN]" : "[Browser]";
console.log(`${prefix} ${text}`);
if (!isFontLoadError) {
console.log(`${prefix} ${text}`);
}

session.browserConsoleBuffer.push(`${prefix} ${text}`);
if (session.browserConsoleBuffer.length > BROWSER_CONSOLE_BUFFER_SIZE) {
Expand Down
7 changes: 7 additions & 0 deletions packages/producer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@
"puppeteer-core": "^24.39.1"
},
"devDependencies": {
"@fontsource/lato": "^5.2.7",
"@fontsource/noto-sans-jp": "^5.2.9",
"@fontsource/open-sans": "^5.2.7",
"@fontsource/playfair-display": "^5.2.8",
"@fontsource/poppins": "^5.2.7",
"@fontsource/roboto": "^5.2.10",
"@fontsource/source-code-pro": "^5.2.7",
"@types/node": "^22.10.1",
"esbuild": "^0.27.2",
"tsx": "^4.7.0",
Expand Down
28 changes: 28 additions & 0 deletions packages/producer/scripts/generate-font-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,34 @@ const CANONICAL_FONTS: Record<string, CanonicalFontSpec> = {
packageName: "@fontsource/eb-garamond",
faces: [{ weight: "400" }, { weight: "700" }],
},
"playfair-display": {
packageName: "@fontsource/playfair-display",
faces: [{ weight: "400" }, { weight: "700" }, { weight: "900" }],
},
"source-code-pro": {
packageName: "@fontsource/source-code-pro",
faces: [{ weight: "400" }, { weight: "700" }],
},
"noto-sans-jp": {
packageName: "@fontsource/noto-sans-jp",
faces: [{ weight: "400" }, { weight: "700" }],
},
roboto: {
packageName: "@fontsource/roboto",
faces: [{ weight: "400" }, { weight: "700" }, { weight: "900" }],
},
"open-sans": {
packageName: "@fontsource/open-sans",
faces: [{ weight: "400" }, { weight: "700" }],
},
lato: {
packageName: "@fontsource/lato",
faces: [{ weight: "400" }, { weight: "700" }, { weight: "900" }],
},
poppins: {
packageName: "@fontsource/poppins",
faces: [{ weight: "400" }, { weight: "700" }, { weight: "900" }],
},
};

function packageRoot(packageName: string): string {
Expand Down
37 changes: 37 additions & 0 deletions packages/producer/src/services/deterministicFonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,34 @@ const CANONICAL_FONTS: Record<string, CanonicalFontSpec> = {
packageName: "@fontsource/eb-garamond",
faces: [{ weight: "400" }, { weight: "700" }],
},
"playfair-display": {
packageName: "@fontsource/playfair-display",
faces: [{ weight: "400" }, { weight: "700" }, { weight: "900" }],
},
"source-code-pro": {
packageName: "@fontsource/source-code-pro",
faces: [{ weight: "400" }, { weight: "700" }],
},
"noto-sans-jp": {
packageName: "@fontsource/noto-sans-jp",
faces: [{ weight: "400" }, { weight: "700" }],
},
roboto: {
packageName: "@fontsource/roboto",
faces: [{ weight: "400" }, { weight: "700" }, { weight: "900" }],
},
"open-sans": {
packageName: "@fontsource/open-sans",
faces: [{ weight: "400" }, { weight: "700" }],
},
lato: {
packageName: "@fontsource/lato",
faces: [{ weight: "400" }, { weight: "700" }, { weight: "900" }],
},
poppins: {
packageName: "@fontsource/poppins",
faces: [{ weight: "400" }, { weight: "700" }, { weight: "900" }],
},
};
Comment on lines +76 to 104

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we may need a better way to handle this long term

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, I think users should download always their fonts to avoid hardcoding fonts like this


const FONT_ALIASES: Record<string, keyof typeof CANONICAL_FONTS> = {
Expand All @@ -98,6 +126,15 @@ const FONT_ALIASES: Record<string, keyof typeof CANONICAL_FONTS> = {
courier: "jetbrains-mono",
"eb garamond": "eb-garamond",
garamond: "eb-garamond",
"playfair display": "playfair-display",
"source code pro": "source-code-pro",
"noto sans jp": "noto-sans-jp",
"noto sans japanese": "noto-sans-jp",
roboto: "roboto",
"open sans": "open-sans",
lato: "lato",
poppins: "poppins",
"segoe ui": "roboto",
};

function normalizeFamilyName(family: string): string {
Expand Down
50 changes: 50 additions & 0 deletions packages/producer/src/services/fontData.generated.ts

Large diffs are not rendered by default.

Loading