import { type MainModule } from "./WasmModule"; /** * Preload configuration for DsPdfJS. * * This object can be assigned to `globalThis.DSPDF_CONFIG` * **before** the library is imported. * * It allows configuring Wasm loading, validation, licensing, * and module initialization without importing {@link DsPdfConfig}. */ export interface DsPdfPreloadConfig { /** * The URL used to load the DsPdf WebAssembly binary. */ wasmUrl?: string; /** * Custom factory that overrides the default Wasm initialization logic. * * Must return a Promise resolving to an initialized `MainModule`. */ wasmFactory?: () => Promise; /** * The license key. * * Set to remove usage limitations. The required key depends on the runtime environment. */ licenseKey?: string; /** * Enables verbose logging during Wasm discovery and initialization. * * @default false */ verbose?: boolean; } declare global { /** * Optional global preload configuration for DsPdfJS. * * Must be defined **before** the library is loaded. */ var DSPDF_CONFIG: DsPdfPreloadConfig | undefined; } /** * Global configuration for DsPdfJS WebAssembly initialization. * * DsPdfJS supports two configuration mechanisms: * * 1. **Preload configuration** via the global `DSPDF_CONFIG` object. * This is useful when configuration must be applied before the * library is imported. * * 2. **Runtime configuration** via static properties of `DsPdfConfig` * after the library has been loaded. * * The preload configuration is read lazily on first access and * is not re-evaluated afterwards. * * Example: * ```js * // Pre-load configuration * globalThis.DSPDF_CONFIG = { * wasmUrl: "/assets/DsPdf.wasm", * licenseKey: "YOUR_LICENSE_KEY" * }; * * // Post-load configuration * import { DsPdfConfig } from "@mescius/ds-pdf"; * DsPdfConfig.verbose = true; * ``` */ export declare class DsPdfConfig { static readonly MIN_WASM_SIZE = 5000000; private constructor(); private static get _instance(); private _wasmFactory?; private _wasmUrl?; private _preloadedLicenseKey?; private _licenseInfo?; private _verbose; /** * Sets or validates the license key. The required key depends on the runtime environment. * * Behavior: * - If `key` is provided, validates and applies it. Any preloaded key (from `DSPDF_CONFIG`) is cleared. * - If `key` is omitted, validates the preloaded key. * - If `undefined` is passed, removes any previously set license key and ignores the preloaded one. * * You can optionally preconfigure the license key before the library loads: * * ```ts * // Pre-load configuration (before initializing DsPdf) * globalThis.DSPDF_CONFIG = { * wasmUrl: "/assets/DsPdf.wasm", * licenseKey: "YOUR_LICENSE_KEY" * }; * ``` * * Examples: * ```ts * await setLicenseKey(key); // validates and applies the provided license key * await setLicenseKey(undefined); // removes any previously set license key * await setLicenseKey(); // validates the preloaded license key * ``` * * @param key License key to validate and apply. * @throws Error if license validation fails. */ static setLicenseKey(key?: string): Promise; /** * Custom factory for creating and initializing the DsPdf WASM module. * * If defined, this function overrides the default initialization process. * Must return a `Promise` resolving to a fully initialized `MainModule`. * * Useful for: * - CDN or remote WASM hosting * - Custom build or environment setup * - Mocking during unit tests * * Example: * ```js * DsPdfConfig.wasmFactory = async () => { * const wasmBinary = await (await fetch("https://cdn.example.com/DsPdf.wasm")).arrayBuffer(); * return createDsPdfModule({ wasmBinary }); * }; * ``` */ static get wasmFactory(): any; /** * Custom factory for creating and initializing the DsPdf WASM module. * * If defined, this function overrides the default initialization process. * Must return a `Promise` resolving to a fully initialized `MainModule`. * * Useful for: * - CDN or remote WASM hosting * - Custom build or environment setup * - Mocking during unit tests * * Example: * ```js * DsPdfConfig.wasmFactory = async () => { * const wasmBinary = await (await fetch("https://cdn.example.com/DsPdf.wasm")).arrayBuffer(); * return createDsPdfModule({ wasmBinary }); * }; * ``` */ static set wasmFactory(v: any); /** * The URL specifying where to load the DsPdf WebAssembly binary from. * * Example: * ```js * DsPdfConfig.wasmUrl = "https://cdn.example.com/v2.0/DsPdf.wasm"; * ``` */ static get wasmUrl(): string | undefined; /** * The URL specifying where to load the DsPdf WebAssembly binary from. * * Example: * ```js * DsPdfConfig.wasmUrl = "https://cdn.example.com/v2.0/DsPdf.wasm"; * ``` */ static set wasmUrl(v: string | undefined); /** * Enables detailed console logging during WASM discovery and initialization. * Use this to debug loading issues or verify fallback behavior. * * Default: `false` * * Example: * ```js * DsPdfConfig.verbose = true; * ``` */ static get verbose(): boolean; /** * Enables detailed console logging during WASM discovery and initialization. * Use this to debug loading issues or verify fallback behavior. * * Default: `false` * * Example: * ```js * DsPdfConfig.verbose = true; * ``` */ static set verbose(v: boolean); /** * * @ignore exclude from docs */ static get shouldValidateLicenseOnStartup(): boolean; }