Something went wrong. Try again.
Local-first knowledge base made for Typst and the Atmosphere. typbase.at
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475import type { TypstRequest } from "@typbase/engine";import type { InstalledPackage, ThemePaletteTokens } from "@typbase/typing";
/** Types crossing the host <-> plugin-worker boundary. */
export interface PluginSurfaceSource { /** Virtual path under `/typbase/plugin/<slug>/` or the UI library path. */ path: string; text: string;}
export interface PluginSurfaceFile { path: string; bytes: Uint8Array;}
/** A package the request loop fetched for this surface. */export interface PluginSurfacePackage { spec: InstalledPackage; bytes: Uint8Array;}
export interface PluginSurfaceStyle { font: string; mathFont: string | null; codeFont: string | null; textSize: number; palette: ThemePaletteTokens;}
export interface PluginSurfaceInput { spaceId: string; slug: string; entry: string; fn: string; sources: PluginSurfaceSource[]; /** Plugin stylesheets, injected into the shadow root after the host sheet. */ styles?: string[]; /** Binary files the request loop resolved (query JSON, images, ...). */ files?: PluginSurfaceFile[]; /** Packages the request loop fetched. Installed before the compile. */ packages?: PluginSurfacePackage[]; ctx: unknown; style: PluginSurfaceStyle;}
export interface PluginSurfaceResult { html: string; diagnostics: unknown[]; requests: TypstRequest[]; /** Which engine compiled this surface. Local is the worker fallback. */ engine?: "worker" | "local"; /** Why the worker was abandoned, when it was. */ fallbackReason?: string;}
export interface PluginCompileRequest extends PluginSurfaceInput { type: "compile"; id: number; /** Vite asset URL for the engine binary, from the main thread. */ wasmUrl: string;}
export type PluginCompileResponse = | { type: "result"; id: number; ok: true; html: string; diagnostics: unknown[]; requests: TypstRequest[]; } | { type: "result"; id: number; ok: false; error: string } | { type: "crash"; message: string; stack?: string };