Skip to content
D
Documentation

Export — interfaces

reference
8 min readUpdated

Interfaces

Import these from @grafloria/renderer.

Interfaces

BatchJob

ts
interface BatchJob

Properties

NameTypeDefaultDescription
idstringEchoed back on the result, so a caller can correlate without relying on order.
documentBatchDocument
format?ExportFormatDefault 'svg' — the only format that needs no rasterizer at all.
options?ExportOptionsMerged over the batch-wide options.

BatchOptions

ts
interface BatchOptions

Properties

NameTypeDefaultDescription
options?ExportOptionsApplied to every job; a job's own options win.
theme?ThemeTheme for every job.
rendererConfig?SVGRendererConfigRenderer config for every job.
concurrency?numberHow many jobs run at once. Default 4.
onProgress?(done: number, total: number, result: BatchResult) => voidCalled as each job settles — for a progress bar or a log line.

BatchResult

ts
interface BatchResult

Properties

NameTypeDefaultDescription
idstring
formatExportFormat
output?stringThe artifact: an SVG string, or a data: URL for a raster. Absent when error is set.
warningsstring[]Fidelity caveats (foreignObject, unresolved theme vars, a clamped size).
error?ErrorSet when THIS job failed. The rest of the batch still ran.

BoundsOptions

ts
interface BoundsOptions

Properties

NameTypeDefaultDescription
includeIds?Set<string>Only union elements whose subtree is one of these diagram ids (node ids / link ids). This is what makes a SELECTION export tight around the selection.

CaptureHostOptions

ts
interface CaptureHostOptions

Properties

NameTypeDefaultDescription
scale?numberThe camera zoom the html layer is transformed by. Client rects are SCREEN space, so they are divided by this to get the host-local layout coordinates the export needs. Defaults to being inferred from the host itself, which is more reliable than trusting a caller to remember.
maxElements?numberSafety valve for a pathologically deep host. Default 4000 elements.

ClampResult

ts
interface ClampResult

Properties

NameTypeDefaultDescription
scalenumberThe scale that actually gets used (≤ the requested one).
widthnumber
heightnumber
warning?stringSet when the requested scale had to be reduced.

CustomNodeCapture

What the DOM boundary hands the pure layer for one custom node.

ts
interface CustomNodeCapture

Properties

NameTypeDefaultDescription
idstringThe node id — carried onto the group, and what includeIds scoping matches.
rectRectangleThe node's WORLD rect (position + size), i.e. where to place the content.
fidelityCustomNodeFidelity
content?VNode[]The transcribed display list, in HOST-RELATIVE coordinates (0,0 = the host's top-left). Placed by translating to rect. Only for fidelity: 'vector'.
html?stringRaw XHTML for the foreignObject attempt. Only for fidelity: 'html'.
warning?stringA caveat the DOM boundary knows and this layer cannot see.

CustomNodeOptions

ts
interface CustomNodeOptions

Properties

NameTypeDefaultDescription
htmlFallback?HtmlFallbackModeHow to export a fidelity: 'html' capture. Default 'foreignObject' — the honest best effort: browsers render it, so an SVG opened in a browser or placed in a web page is correct. It is still reported as a fidelity risk, because a PDF and most standalone rasterizers will drop it.

FontSource

ts
interface FontSource

Properties

NameTypeDefaultDescription
familystringThe family name the diagram's font-family refers to, e.g. Inter.
dataUint8ArrayThe font program's bytes.
format?FontFormat
weight?string | numbere.g. 400, 700, 'bold'. Default 'normal'.
style?string'normal' | 'italic'. Default 'normal'.
unicodeRange?stringOptional unicode-range descriptor.

Page

ts
interface Page

Properties

NameTypeDefaultDescription
indexnumber0-based, reading order (left→right, top→bottom).
rownumber
columnnumber
rectRectangleThe world window mapped onto the paper. Always the full page size — see the header.
clipRectangleThe sub-rectangle actually painted. Equals rect unless a break was snapped in.

PaginationOptions

ts
interface PaginationOptions

Properties

NameTypeDefaultDescription
pageWidthnumberOne page's width in WORLD units.
pageHeightnumberOne page's height in WORLD units.
overlap?numberWorld units each page repeats from its neighbour — a bleed, so a printed poster can be trimmed and taped without losing a strip. Default 0.
snapToNodes?booleanPull a page break back so it does not slice through a node. Default true — a break through the middle of a box is the thing that makes tiled printouts unusable.
snapTolerance?numberHow far a break may be pulled back, as a fraction of the page. Default 0.25.
content?RectangleThe region to paginate. Default: the tree's content bounds.
padding?numberPadding around the content bounds, in world units. Default 20.

PaginationResult

ts
interface PaginationResult

Properties

NameTypeDefaultDescription
pagesPage[]
columnsnumber
rowsnumber
columnBreaksnumber[]The x break positions (page origins).
rowBreaksnumber[]The y break positions.
warningsstring[]Nodes we could NOT spare — a break had to cut them.

PdfExportOptions

ts
interface PdfExportOptions

Properties

NameTypeDefaultDescription
theme?ThemeThe theme the tree was rendered with. REQUIRED for fidelity in CSS mode: a node's fill and a link's stroke live in the stylesheet, not on the element, so without the theme to resolve them the PDF comes out nearly blank. Defaults to LIGHT_THEME.
pageSize?PageSize | { width: number; height: number }
orientation?Orientation
margin?number | { top: number; right: number; bottom: number; left: number }Points (1/72"). Default 36 (half an inch) on every side.
viewBox?RectangleThe world rectangle to draw. Default: the tree's content bounds.
padding?numberPadding around the content bounds, in world units. Default 20.
metadata?PdfMetadata
backgroundColor?stringPaint a page background. Default: none (white paper shows through).
pages?Array<Rectangle | { rect: Rectangle; clip?: Rectangle }>Pages to lay the diagram across. Supplied by the paginator.
pageNumbers?booleanDraw "n / total" at the foot of each page. Default false; the paginator turns it on.

PdfExportResult

ts
interface PdfExportResult

Properties

NameTypeDefaultDescription
pdfUint8Array
pageCountnumber
warningsstring[]

PdfMetadata

ts
interface PdfMetadata

Properties

NameTypeDefaultDescription
title?string
author?string
subject?string
keywords?string
creationDate?stringISO-8601. Omit for a deterministic file — a wall-clock stamp makes bytes differ.

PdfRgb

PDF paints in 0–1 channels, not 0–255. Named PdfRgb so it cannot be confused with the theme's Rgb (which is 0–255).

ts
interface PdfRgb

Properties

NameTypeDefaultDescription
rnumber
gnumber
bnumber

PrintOptions

ts
interface PrintOptions

Properties

NameTypeDefaultDescription
title?stringShown in the browser's print dialog and as the default filename.
pageSize?stringCSS page size, e.g. 'A4 landscape'. Default 'auto'.
margin?stringCSS margin for

RasterBackend

Pluggable rasterizer. Returns a data: URL.

ts
interface RasterBackend

Members

  • rasterize(request: RasterizeRequest): Promise<string>

RasterizeRequest

What a rasterizer is asked to produce.

ts
interface RasterizeRequest

Properties

NameTypeDefaultDescription
svgstringA standalone SVG document (styles inlined, no external references).
widthnumberTarget pixel width (already scaled).
heightnumberTarget pixel height (already scaled).
mimeTypestringimage/png | image/jpeg | image/webp.
quality?number0–1, for the lossy formats.

ResolveAssetsOptions

ts
interface ResolveAssetsOptions

Properties

NameTypeDefaultDescription
fetcher?AssetFetcherHow to get the bytes. Defaults to fetch when the environment has one.
maxBytes?numberCap on one asset's size, in bytes. Default 5MB — a data: URI is ~33% bigger than the file.

ResolveAssetsResult

ts
interface ResolveAssetsResult

Properties

NameTypeDefaultDescription
treeVNode
inlinednumberHow many external references were replaced.
warningsstring[]

ResvgModule

The slice of @resvg/resvg-js we use.

ts
interface ResvgModule

Properties

NameTypeDefaultDescription
Resvgnew ( svg: string | Uint8Array, options?: { fitTo?: { mode: 'width' | 'height'; value: number } } ) => { render(): { asPng(): Uint8Array } }

SvgExportResult

ts
interface SvgExportResult

Properties

NameTypeDefaultDescription
svgstringThe standalone SVG document.
widthnumberIntrinsic width in px (viewBox width × the CLAMPED scale).
heightnumberIntrinsic height in px.
viewBoxViewBoxThe world rectangle the document actually covers — what pagination and PDF page off.
warningsstring[]Fidelity caveats hit during this export (foreignObject, unresolved vars, size clamp, …).

TieredFetchOptions

ts
interface TieredFetchOptions

Properties

NameTypeDefaultDescription
fetcher?AssetFetcherTier 2: consulted only when the environment's own fetch fails.
maxBytes?numberCap on one asset's size, in bytes. Default 5MB. TERMINAL — no tier retries it.
timeoutMs?numberBound on fetching ONE URL, per tier, in milliseconds. Default 5000.

TieredFetchResult

ts
interface TieredFetchResult

Properties

NameTypeDefaultDescription
byUrlMap<string, string>URL → data: URI, for every asset some tier could produce.
failuresMap<string, string>URL → why EVERY tier failed — ready to surface as a warning.

Was this page helpful?

Export — interfaces — Grafloria