@kitn.ai/ui
Version:
Framework-agnostic, Shadow-DOM web components for building AI chat interfaces — works in React, Vue, Angular, Svelte, or plain HTML. Authored in SolidJS.
51 lines (50 loc) • 1.72 kB
TypeScript
/** Minimal shape of the pdf.js module + objects we rely on. */
export interface PdfViewportLike {
width: number;
height: number;
}
export interface PdfPageLike {
getViewport(opts: {
scale: number;
}): PdfViewportLike;
render(opts: {
canvasContext: CanvasRenderingContext2D | null;
viewport: PdfViewportLike;
}): {
promise: Promise<void>;
};
}
export interface PdfDocumentLike {
numPages: number;
getPage(n: number): Promise<PdfPageLike>;
}
export interface PdfjsLike {
getDocument(src: {
url: string;
}): {
promise: Promise<PdfDocumentLike>;
};
GlobalWorkerOptions: {
workerSrc: string;
};
}
export interface PdfPreviewOptions {
/** Turn inline PDF rendering on/off globally. When false, always show the card. */
enabled?: boolean;
/** Override the pdf.js module loader (self-host / CSP / version pin). */
load?: () => Promise<PdfjsLike>;
/** Worker URL. Default = the matching jsDelivr worker for the pinned version. */
workerSrc?: string;
}
export declare function configurePdfPreview(options: PdfPreviewOptions): void;
export declare function isPdfPreviewEnabled(): boolean;
export declare function __resetPdfPreviewForTests(): void;
/**
* Render EVERY page of the PDF at `url` into `container` as stacked <canvas>
* elements fit to `pxWidth` CSS pixels (rendered at devicePixelRatio for
* crispness). Clears `container` first. Resolves `{ pages }`. THROWS on
* load / CORS / parse failure — the caller catches and shows the fallback card.
*/
export declare function renderPdfInto(url: string, container: HTMLElement, pxWidth: number): Promise<{
pages: number;
}>;