import { t as WorkerHost } from "./host-DMz-7U8I.js"; //#region src/files/cache.d.ts /** Asynchronous cache for compressed Typst package archives (`.tar.gz`). */ interface PackageCache { match(request: RequestInfo | URL): Promise; put(request: RequestInfo | URL, response: Response): Promise; } //#endregion //#region src/engine/generated/jspi/interfaces/typst-engine-types.d.ts /** @module Interface typst:engine/types **/ /** * # Variants * * ## `"project"` * * ## `"package"` * * ## `"url"` */ type FileKind = 'project' | 'package' | 'url'; interface FetchRequest { path: string; kind: FileKind; } interface FetchedFile { data: Uint8Array; resolvedPath?: string; mediaType?: string; } /** * # Variants * * ## `"pdf"` * * ## `"png"` * * ## `"svg"` * * ## `"html"` * * ## `"bundle"` */ type CompileFormat = 'pdf' | 'png' | 'svg' | 'html' | 'bundle'; /** * # Variants * * ## `"v17"` * * ## `"a2b"` * * ## `"a3b"` */ type PdfStandard = 'v17' | 'a2b' | 'a3b'; /** * # Variants * * ## `"warning"` * * ## `"error"` */ type DiagnosticSeverity = 'warning' | 'error'; interface Diagnostic { message: string; severity: DiagnosticSeverity; file?: string; line?: number; column?: number; start?: number; end?: number; formatted: string; hints: Array; trace: Array; } interface LoadedFile { kind: FileKind; path: string; resolvedPath?: string; mediaType?: string; } //#endregion //#region src/engine/types.d.ts type CoreModuleName = "engine.core.wasm" | "engine.core2.wasm" | "engine.core3.wasm"; type CoreModules = Readonly>>; //#endregion //#region src/compiler/types.d.ts /** String values exposed to Typst through `sys.inputs`. */ type CompileInputs = Record; /** Options controlling one compilation. */ interface CompileOptions { /** Output format to produce. */ format: F; /** Optional entry-point file path. */ main?: string; /** String values available through Typst's `sys.inputs` dictionary. */ inputs?: CompileInputs; /** Page selector, such as `"1,3-5"`. */ pages?: string; /** PDF standards to target. */ pdfStandards?: PdfStandard[]; /** Pixels per inch for raster output. */ ppi?: number; } /** Document metadata extracted from a successful compilation. */ interface DocumentMetadata { title?: string; description?: string; author: string[]; keywords: string[]; /** Custom metadata values decoded from the engine's JSON representation. */ custom: Array<{ label?: string; value: unknown; }>; } interface CompileResultBase { diagnostics: Diagnostic[]; metadata?: DocumentMetadata; dependencies: LoadedFile[]; } /** PDF compilation result. */ interface PdfCompileResult extends CompileResultBase { format: "pdf"; output: Uint8Array; } /** PNG compilation result. */ interface PngCompileResult extends CompileResultBase { format: "png"; pages: Array<{ page: number; output: Uint8Array; }>; } /** SVG compilation result. */ interface SvgCompileResult extends CompileResultBase { format: "svg"; pages: Array<{ page: number; output: string; }>; } /** HTML compilation result. */ interface HtmlCompileResult extends CompileResultBase { format: "html"; output: string; } /** HTML bundle compilation result. */ interface BundleCompileResult extends CompileResultBase { format: "bundle"; files: Array<{ path: string; data: Uint8Array; mediaType?: string; }>; } /** All caller-facing successful compilation results. */ type AnyCompileResult = PdfCompileResult | PngCompileResult | SvgCompileResult | HtmlCompileResult | BundleCompileResult; /** Successful result corresponding to a requested output format. */ type CompileResult = Extract; /** Resolves files requested by Typst. */ type TypstFileLoader = (request: FetchRequest) => Promise; /** Receives diagnostic and debug messages emitted by the library. */ interface TypstLogger { /** Records a library message. */ log(level: TypstLogLevel, message: string, context?: unknown): void; } type TypstLogLevel = "error" | "debug"; /** Options used to create a {@link TypstCompiler}. */ interface TypstCompilerOptions { /** Controls library messages. */ logLevel?: TypstLogLevel; /** Receives library messages. */ logger?: TypstLogger; /** Backend to use; `auto` selects the best available backend. */ backend?: "auto" | "worker" | "jspi"; /** Core WebAssembly modules required by the Typst engine. */ coreModules: CoreModules; /** Creates the host used by the worker backend. */ worker?: () => WorkerHost; /** Custom loaders tried before the built-in package and URL loaders. */ fileLoaders?: TypstFileLoader[]; /** Fetch implementation used for URL and package resources. */ fetch?: typeof fetch; /** Base URL used to resolve Typst package downloads. */ packageBaseUrl?: string; /** Optional compressed `.tar.gz` archive cache, or `false` to disable archive caching. */ packageCache?: PackageCache | false; /** Maximum number of decoded package maps retained per compiler (default 32). `0` disables completed decoded caching. */ memoryPackageCacheCapacity?: number; } type FontInput = Uint8Array | Promise; /** Stateful promise-based Typst compiler. */ interface TypstCompiler { /** Registers fonts for subsequent compilations. */ addFonts(...fonts: FontInput[]): Promise; /** Adds binary data at a path in the virtual project. */ addFile(path: string, data: Uint8Array): Promise; /** Adds Typst source at a path in the virtual project. */ addSource(path: string, text: string): Promise; /** Removes a file from the virtual project. */ removeFile(path: string): Promise; /** Removes all files from the virtual project. */ clearFiles(): Promise; /** Lists paths currently in the virtual project. */ listFiles(): Promise; /** Tests whether a path exists in the virtual project. */ hasFile(path: string): Promise; /** Sets the default entry-point path. */ setMain(path: string): Promise; /** Compiles the project into the requested format. */ compile(options: CompileOptions): Promise>; /** Releases compiler and worker resources. */ dispose(): Promise; } //#endregion //#region src/compiler/index.d.ts declare const createTypstCompiler: (options: TypstCompilerOptions) => Promise; //#endregion //#region src/backends/capabilities.d.ts declare const supportsWorkerBackend: () => boolean; declare const supportsJspiBackend: () => boolean; //#endregion //#region src/backends/index.d.ts type BackendKind = "auto" | "worker" | "jspi"; type BackendSelection = Exclude | "none"; declare const selectAutomaticBackendKind: (options: TypstCompilerOptions) => BackendSelection; //#endregion //#region src/errors.d.ts /** Base class for errors raised by the Typst compiler API. */ declare class TypstError extends Error { constructor(message: string, options?: { cause?: unknown; }); } /** Indicates that compilation failed or produced error diagnostics. */ declare class CompileError extends TypstError { readonly diagnostics: Diagnostic[]; constructor(message: string, options?: { diagnostics?: Diagnostic[]; cause?: unknown; }); } /** Indicates that an operation was attempted before compiler initialization. */ declare class CompilerNotInitializedError extends TypstError {} /** Indicates that an operation was attempted after compiler disposal. */ declare class CompilerDisposedError extends TypstError {} /** Indicates that a requested file could not be fetched. */ declare class FetchError extends TypstError { readonly path: string; constructor(path: string, cause: unknown); } /** Indicates that a Typst package specification is invalid. */ declare class PackageParseError extends TypstError { readonly spec: string; constructor(spec: string, message: string); } /** Indicates that a Typst package could not be fetched. */ declare class PackageFetchError extends TypstError { readonly url: string; constructor(url: string, cause: unknown); } /** Indicates that a requested file does not exist. */ declare class FileNotFoundError extends TypstError { readonly filePath: string; constructor(filePath: string); } /** Indicates a failure communicating with a compiler worker. */ declare class WorkerError extends TypstError {} //#endregion export { type AnyCompileResult, type BackendKind, type BackendSelection, type BundleCompileResult, CompileError, type CompileFormat, type CompileInputs, type CompileOptions, type CompileResult, CompilerDisposedError, CompilerNotInitializedError, type CoreModuleName, type CoreModules, type Diagnostic, type DocumentMetadata, FetchError, type FetchRequest, type FetchedFile, type FileKind, FileNotFoundError, type FontInput, type HtmlCompileResult, type LoadedFile, type PackageCache, PackageFetchError, PackageParseError, type PdfCompileResult, type PdfStandard, type PngCompileResult, type SvgCompileResult, type TypstCompiler, type TypstCompilerOptions, TypstError, type TypstFileLoader, type TypstLogLevel, type TypstLogger, WorkerError, type WorkerHost, createTypstCompiler, selectAutomaticBackendKind, supportsJspiBackend, supportsWorkerBackend }; //# sourceMappingURL=index.d.ts.map