Skip to content
D
Documentation

Export — constants

reference
1 min readUpdated

Constants

Import these from @grafloria/renderer.

Constants

AVG_CHAR_WIDTH_EM

The average glyph advance, as a fraction of font-size.

THE SAME CONSTANT LabelRenderer.estimateTextWidth uses. It is a rough mean for proportional Latin text — and it being rough is fine, because the renderer sizes label backgrounds with it too. What matters is that the two AGREE: a bbox derived from a different estimate than the one that placed the text would crop labels the renderer thought it had left room for.

ts
const AVG_CHAR_WIDTH_EM: 0.6

DEFAULT_MAX_OUTPUT_SIZE

The default cap on an exported raster's pixel size, per side.

ts
const DEFAULT_MAX_OUTPUT_SIZE: 4000

GRAFLORIA_MODEL_KEY

The PNG text-chunk keyword, and the SVG element name.

NOT grafloria-diagram: that is already the CSS class on the exported root (class="grafloria-diagram"), so "does this file carry a model?" would answer YES for every export we have ever produced.

ts
const GRAFLORIA_MODEL_KEY: "grafloria-model"

GRAFLORIA_NS

The XML namespace the embedded model lives in.

ts
const GRAFLORIA_NS: "https://grafloria.dev/ns/diagram"

IMAGE_NOT_INLINED_WARNING

Companion caveat from resolveImageHref — same lifecycle as {@link IMAGE_PDF_WARNING}.

ts
const IMAGE_NOT_INLINED_WARNING: string

IMAGE_PDF_WARNING

The capture-time verdict on an external image, EXPORTED because the async export path revises it: await export(…) fetches external URLs (environment fetch, then ExportOptions.assetFetcher) and STRIPS this warning from any capture whose images it embedded — see stripResolvedImageWarnings. The synchronous entry points cannot fetch, so for them this text is the whole truth, and it names the way out.

ts
const IMAGE_PDF_WARNING: string

PAGE_SIZES

Page sizes in POINTS (1/72"), which is PDF's only unit.

ts
const PAGE_SIZES: { readonly a4: { readonly width: 595.28; readonly height: 841.89; }; readonly letter: { readonly width: 612; readonly height: 792; }; readonly legal: { readonly width: 612; readonly height: 1008; }; readonly a3: { readonly width: 841.89; readonly height: 1190.55; }; readonly tabloid: { readonly width: 792; readonly height: 1224; }; }

SVG_XMLNS

ts
const SVG_XMLNS: "http://www.w3.org/2000/svg"

utf8

UTF-8, implemented rather than borrowed.

TextEncoder/TextDecoder are NOT reliably global: they are absent in jsdom (which is what the renderer's own tests run in) and were late to Node. Sniffing for them and falling back would give two code paths that can disagree about a surrogate pair — in a module whose entire job is lossless bytes. So: one path, always, everywhere.

ts
const utf8: { encode(text: string): Uint8Array<ArrayBufferLike>; decode(bytes: Uint8Array<ArrayBufferLike>): string; }

XML_DECLARATION

The XML prolog. Required by strict XML parsers and by most SVG→PDF toolchains.

ts
const XML_DECLARATION: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>"

Was this page helpful?

Export — constants — Grafloria