@frank/ad-template-renderer (0.1.1)

Published 2026-09-26 17:44:13 +10:00 by steve

Installation

@frank:registry=
npm install @frank/ad-template-renderer@0.1.1
"@frank/ad-template-renderer": "0.1.1"

About this package

@frank/ad-template-renderer

The canonical deterministic renderer for final ad templates, ported unchanged from packages/ad-template-renderer in the Blockwise repo. It renders an AdTemplate from @frank/ad-template into feed (1080x1350) and story (1080x1920) PNGs, fails closed when authored text cannot fit its box, and produces a render audit receipt (pixel gates, perceptual duplicate-image checks, text diagnostics) for the tool-run quality gate.

Public API (src/index.ts)

  • renderPlacement(input, placement), renderBoth(input) - render one or both placements. RenderInput carries template, imageValues, textValues, colourMap, optional fontValues (font file -> bytes).
  • TextPreflightError / TEXT_PREFLIGHT_ERROR_CODE - thrown when text cannot fit at the readability floor.
  • auditTemplateArtifact(input) - full audit; AuditArtifactInput carries artifactBytes, assetsDir, optional sourceBytes, runId, iteration.
  • Subpath @frank/ad-template-renderer/text-layout: segmentGraphemes, measureTrackedTextWidth, wrapText, prepareTextLayout.
  • Subpath @frank/ad-template-renderer/layer-geometry (browser-safe, no canvas): resolveGeometry, effectiveTextFontSize, imageMaskRadius and the Fabric helpers. The renderer uses the same functions, so an editor that imports them places layers exactly where the server renders them.
  • Bins: ad-template-render (CLI render), ad-template-audit (CLI audit).

Config

No environment reads. Fonts the template declares by bare file name resolve to fonts/adbuilder/ inside this package; callers override by passing fontValues bytes. Asset files resolve against the caller-provided assetsDir.

Usage

import { renderBoth } from "@frank/ad-template-renderer";
const [feed, story] = await renderBoth({ template, imageValues, textValues, colourMap });

Dependencies

Dependencies

ID Version
@frank/ad-template 0.1.0
@napi-rs/canvas ^1.0.3

Development dependencies

ID Version
@types/node ^22.0.0
fabric ^7.4.0
Details
npm
2026-09-26 17:44:13 +10:00
1
2.2 MiB
Assets (1)
Versions (3) View all
0.2.0 2026-10-04
0.1.1 2026-09-26
0.1.0 2026-09-26