Skip to content
D
Documentation

interfaces

reference
8 min readUpdated

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.

CustomNodeCapturer

The two capture entry points a canvas exposes, bound to its host source.

ts
interface CustomNodeCapturer

Members

  • withCustomNodes(exportOptions?: ExportOptions): ExportOptions — Synchronous: add customNodes captured now. A caller's own customNodes wins.
  • withCustomNodesAsync(exportOptions?: ExportOptions): Promise<ExportOptions> — Async: wait for pending painters (bounded), then capture. A caller's own customNodes wins.

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.

ExportImageUrlSource

What image inlining needs from the renderer: the URLs its own tree references.

ts
interface ExportImageUrlSource

Members

  • collectExportImageUrls(options?: ExportOptions): string[]

ExportPipeline

A canvas's three export entry points, with its custom nodes in them.

ts
interface ExportPipeline

Members

  • export(format?: ExportFormat, options?: ExportOptions): Promise<string> — The full async pipeline: wait for async painters (bounded by customNodeTimeout), capture every in-scope custom node, fetch and embed external images, then export.
  • exportSvgString(options?: ExportOptions): SvgExportResult — Synchronous SVG: custom nodes captured as they stand now; no fetch (only resolvedAssets).
  • exportPdf(options?: ExportOptions): PdfExportResult — Synchronous vector PDF: custom nodes captured as they stand now; no fetch.

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.

PipelineRenderer

Also has every member of ExportImageUrlSource, listed on its own entry.

What the full pipeline needs from the renderer.

ts
interface PipelineRenderer extends ExportImageUrlSource

Members

  • export(format?: ExportFormat, options?: ExportOptions): Promise<string>
  • exportSvgString(options?: ExportOptions): SvgExportResult
  • exportPdf(options?: ExportOptions): PdfExportResult

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?

interfaces — Grafloria