Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
refactor: use documents build script as the single font-gen entry
Sidwebworks66c6163941a7
diff --git a/.claude/rules/pdf-generation-patterns.md b/.claude/rules/pdf-generation-patterns.mdindex 5af449686b..fa72c7c5d3 100644--- a/.claude/rules/pdf-generation-patterns.md+++ b/.claude/rules/pdf-generation-patterns.md@@ -108,12 +108,16 @@ Times-Roman / Courier are PDF built-ins (no registration).Also avoid OpenType **variable** fonts — react-pdf can't subset them (PDF 2.0).- `pdf/fonts.data.ts` — **generated, gitignored** `BUNDLED_FONTS` (base64 woff,~720 KiB). Produced by `scripts/generate-fonts.mjs` from the `@fontsource/*`- devDeps (static, numeric-weight instances — NOT the variable packages). Built- automatically by the **root `postinstall`** (`pnpm --filter @carbon/documents- generate:fonts`), so it exists after any `pnpm install` — before dev/build/typecheck- (which is why install, not a Turbo task, is the hook: `typecheck` has no `^build`- dep). Same pattern as the gitignored Lingui `.mjs`. Run `generate:fonts` manually to- refresh after changing the family list.+ devDeps (static, numeric-weight instances — NOT the variable packages). The+ `@carbon/documents` **`build`** script is the single entry point; it runs:+ - on the **root `postinstall`** (`pnpm --filter @carbon/documents build`) — so the+ file exists after any `pnpm install`, including for `typecheck` (which has no+ `^build` dep, so install is the hook there);+ - as the turbo **`@carbon/documents#build`** task (outputs the file, cache-restored+ on hits) — so app builds get it via `^build`.++ Same pattern as the gitignored Lingui `.mjs`. Run `pnpm --filter @carbon/documents+ build` manually to refresh after changing the family list.- `registerDocumentFonts()` — idempotent, synchronous; registers every bundledfamily from local woff. If Inter isn't bundled yet (pre-generation), it falls backto remote Inter TTF URLs so the default still renders.diff --git a/.gitignore b/.gitignoreindex 57cad5ec74..ac80dbeae3 100644--- a/.gitignore+++ b/.gitignore@@ -24,7 +24,7 @@ opencode.json# Lingui compiled catalogspackages/locale/locales/**/*.mjs-# Generated PDF font data (woff base64) — built on postinstall via generate:fonts+# Generated PDF font data (woff base64) — built on postinstall + turbo buildpackages/documents/src/pdf/fonts.data.tsscripts/migrations/datadiff --git a/package.json b/package.jsonindex d7eb51e486..a01e4ef3ea 100755--- a/package.json+++ b/package.json@@ -58,7 +58,7 @@"lingui:compile": "lingui compile --namespace es","lingui:extract": "lingui extract --clean","lingui:clean": "node ./scripts/strip-po-headers.mjs",- "postinstall": "pnpm --filter @carbon/documents generate:fonts",+ "postinstall": "pnpm --filter @carbon/documents build","prepare": "pnpm exec husky install","test": "turbo run test","tool:new": "tsx scripts/create-tool.ts",diff --git a/packages/documents/package.json b/packages/documents/package.jsonindex 5cb568e5f9..82f906e1eb 100644--- a/packages/documents/package.json+++ b/packages/documents/package.json@@ -48,7 +48,6 @@"scripts": {"build": "node ./scripts/generate-fonts.mjs","clean": "rimraf .turbo node_modules dist",- "generate:fonts": "node ./scripts/generate-fonts.mjs","lint": "biome lint --write ","test": "vitest run","typecheck": "tsgo --noEmit"diff --git a/packages/documents/scripts/generate-fonts.mjs b/packages/documents/scripts/generate-fonts.mjsindex 131e2e2528..790c46f667 100644--- a/packages/documents/scripts/generate-fonts.mjs+++ b/packages/documents/scripts/generate-fonts.mjs@@ -11,8 +11,9 @@// embed. woff (zlib/tiny-inflate) is stateless and decodes all families fine.// (Verified: all 8 families render with woff; woff2 crashes once all are registered.)//-// Runs automatically on the root `postinstall` (output is gitignored). Run-// manually to refresh: pnpm --filter @carbon/documents generate:fonts+// Runs automatically on the root `postinstall` and the turbo `build` task+// (output is gitignored). Run manually to refresh:+// pnpm --filter @carbon/documents buildimport { createRequire } from "node:module";import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";import { dirname, join } from "node:path";@@ -104,7 +105,7 @@ const body = entries.join("\n");const out = `// GENERATED by scripts/generate-fonts.mjs — DO NOT EDIT BY HAND.-// Run: pnpm --filter @carbon/documents generate:fonts+// Run: pnpm --filter @carbon/documents build// Document fonts embedded as base64 woff data URIs (decoded in-process by// react-pdf/fontkit; no network at render).diff --git a/packages/documents/src/pdf/fonts.ts b/packages/documents/src/pdf/fonts.tsindex 724e4ff311..544099e302 100644--- a/packages/documents/src/pdf/fonts.ts+++ b/packages/documents/src/pdf/fonts.ts@@ -4,7 +4,7 @@ import { BUNDLED_FONTS } from "./fonts.data";/*** Document fonts for PDFs. Every Google font offered in the template editor is* bundled into the package as base64 woff (`fonts.data.ts`, generated by- * `pnpm --filter @carbon/documents generate:fonts`) and registered in-process — there+ * `pnpm --filter @carbon/documents build`) and registered in-process — there* is NO network at render time. (The previous approach fetched Google's CSS at* render, which failed intermittently on Vercel and crashed with* "Font family not registered: <font>".)