@hmlr/govuk-react-components-library
Version:
These are common component use for React applications based on GDS and govuk-frontend
28 lines (27 loc) • 1.02 kB
TypeScript
import { SourceDeterminer } from "./PDFViewer.types";
/**
* Convert a base64 string to an ArrayBuffer
*/
export declare const _base64ToArrayBuffer: (base64: string) => ArrayBuffer;
/**
* Very small heuristic to detect a plain base64 string
*/
export declare const isBase64: (value: string) => boolean;
/**
* ResolvePDFSource
*
* Accepts a source that may be:
* - a plain base64 string (PDF binary encoded as base64)
* - a data: URL containing base64 (data:application/pdf;base64,...)
* - an existing blob: URL (blob:...)
* - a Blob/File object
* - a regular URL string (http(s) or same-origin path)
*
* Returns a SourceDeterminer:
* - { isBase64Source: true, source: string } when an object URL was created
* - { isBase64Source: false, source: string } when source can be used directly
*
* If an object URL is created, callers should revoke it when no longer needed:
* `URL.revokeObjectURL(source)`
*/
export declare const ResolvePDFSource: (source?: string | Blob | null) => SourceDeterminer;