import type { BlobInput } from './BlobInput.js'; import { CompilationMode } from './CompilationMode.js'; import { CompiledDocument } from './CompiledDocument.js'; import type { Diagnostic } from './Diagnostic.js'; import { type ExportFormat } from './ExportFormat.js'; import type { ExportOnceResult } from './ExportOnceResult.js'; import type { PageRange } from './PageRange.js'; import type { TemplateManifest } from './TemplateManifest.js'; import type { ZipLimits } from './ZipLimits.js'; /** * A template * * The zip file is loaded during the instance creation and cached afterward. */ export declare class Template implements Disposable { private readonly template; private lastWarnings; /** * Register a template with the given template file * @param template - the packed Oicana template file */ constructor(template: Uint8Array); /** * Register a template with the given template file and inputs * @param template - the packed Oicana template file * @param jsonInputs for the initial compilation to warm up the cache * @param blobInputs for the initial compilation to warm up the cache */ constructor(template: Uint8Array, jsonInputs: Map, blobInputs: Map); /** * Register a template with the given template file and inputs * @param template - the packed Oicana template file * @param jsonInputs for the initial compilation to warm up the cache (defaults to empty map) * @param blobInputs for the initial compilation to warm up the cache (defaults to empty map) * @param mode for the initial compilation to warm up the cache (defaults to Development) * @param limits for reading the template zip (defaults apply when omitted) */ constructor(template: Uint8Array, jsonInputs?: Map, blobInputs?: Map, mode?: CompilationMode, limits?: ZipLimits); /** * Compile and export a template in a single WASM call, without caching. * * Nothing is registered and no warm-up compilation runs, so this is the * fastest way to render a template exactly once. For repeated exports of the * same template, create a {@link Template} instance instead. * @param template - the packed Oicana template file * @param jsonInputs - JSON inputs for the template (defaults to empty map) * @param blobInputs - Blob inputs for the template (defaults to empty map) * @param exportFormat - Export format specification (defaults to PDF) * @param mode - Compilation mode (defaults to Production) * @param pages - 0-based, inclusive page range (defaults to the whole document) * @param limits - limits for reading the template zip (defaults apply when omitted) */ static exportOnce(template: Uint8Array, jsonInputs?: Map, blobInputs?: Map, exportFormat?: ExportFormat, mode?: CompilationMode, pages?: PageRange, limits?: ZipLimits): ExportOnceResult; /** * Compile the template and export it to a PDF file, without inputs, in * production mode. */ export(): Uint8Array; /** * Compile the template with the given inputs and export it to a PDF file in * production mode. * @param jsonInputs * @param blobInputs */ export(jsonInputs: Map, blobInputs: Map): Uint8Array; /** * Compile the template with the given inputs and export it in the given format. * @param jsonInputs * @param blobInputs * @param exportFormat */ export(jsonInputs: Map, blobInputs: Map, exportFormat: ExportFormat): Uint8Array; /** * Compile the template with the given inputs and export it in the given format. * @param jsonInputs * @param blobInputs * @param exportFormat * @param mode */ export(jsonInputs: Map, blobInputs: Map, exportFormat: ExportFormat, mode: CompilationMode): Uint8Array; /** * Compile the template with the given inputs and export a range of pages * @param jsonInputs * @param blobInputs * @param exportFormat * @param mode * @param pages */ export(jsonInputs: Map, blobInputs: Map, exportFormat: ExportFormat, mode: CompilationMode, pages: PageRange): Uint8Array; /** * Compile the template and export it to PDF in a single call, then free the * document. * Tagging will be automatically turned off when exporting a subset of pages. * @param jsonInputs - JSON inputs for the template (defaults to empty map) * @param blobInputs - Blob inputs for the template (defaults to empty map) * @param mode - Compilation mode (defaults to Production) * @param pages - 0-based, inclusive page range (defaults to the whole document) */ exportPdf(jsonInputs?: Map, blobInputs?: Map, mode?: CompilationMode, pages?: PageRange): Uint8Array; /** * Compile the template and export it to PNG in a single call, then free the * document. * Multiple pages are merged into a single, vertically stacked image. * @param jsonInputs - JSON inputs for the template (defaults to empty map) * @param blobInputs - Blob inputs for the template (defaults to empty map) * @param mode - Compilation mode (defaults to Production) * @param pixelsPerPt - resolution in pixels per point (defaults to 1.0) * @param pages - 0-based, inclusive page range (defaults to the whole document) */ exportPng(jsonInputs?: Map, blobInputs?: Map, mode?: CompilationMode, pixelsPerPt?: number, pages?: PageRange): Uint8Array; /** * Compile the template and export it to SVG in a single call, then free the * document. * @param jsonInputs - JSON inputs for the template (defaults to empty map) * @param blobInputs - Blob inputs for the template (defaults to empty map) * @param mode - Compilation mode (defaults to Production) * @param pages - 0-based, inclusive page range (defaults to the whole document) */ exportSvg(jsonInputs?: Map, blobInputs?: Map, mode?: CompilationMode, pages?: PageRange): Uint8Array; private exportWith; /** * Compile the template. * * The document is kept in memory so it can be exported one or more times * (whole document, a page range, or individual pages) without re-compiling. * Call `dispose()` on the returned document (or use `using`) to free it. * For a single one-shot export, prefer {@link export}. * @param jsonInputs - JSON inputs for the template (defaults to empty map) * @param blobInputs - Blob inputs for the template (defaults to empty map) * @param mode - Compilation mode (defaults to Production) */ compile(jsonInputs?: Map, blobInputs?: Map, mode?: CompilationMode): CompiledDocument; private compileToDocumentId; /** * Warnings produced by the most recent compilation (constructor warm-up, or a * `compile()` / `export()` call). Empty if there were none. */ warnings(): Diagnostic[]; /** * The template's manifest. * * The Typst package section and Oicana * configuration with the input definitions. */ manifest(): TemplateManifest; /** * Get the string content of a file from the template */ source(path: string): string; /** * Get the raw file from the template */ file(path: string): Uint8Array; /** * Enable or disable JSON schema validation for this template. * * When enabled (the default), JSON inputs are validated against their schemas * before compilation. * @param validate - whether to validate inputs against their JSON schemas */ setValidateInputs(validate: boolean): void; /** * Release resources associated with this template. * After calling dispose(), this template instance should not be used. */ dispose(): void; /** * Enables use with the `using` keyword for automatic resource cleanup. */ [Symbol.dispose](): void; }