@agentman/chat-widget
Version:
Agentman Chat Widget for easy integration with web applications
65 lines (64 loc) • 1.78 kB
TypeScript
/**
* Configuration options for markdown loading
*/
export interface MarkdownConfig {
cdnUrls?: string[];
timeout?: number;
markedOptions?: {
gfm?: boolean;
breaks?: boolean;
headerIds?: boolean;
mangle?: boolean;
pedantic?: boolean;
smartLists?: boolean;
smartypants?: boolean;
};
}
/**
* Utility for dynamically loading the marked.js library
* This keeps the bundle size small while providing full markdown support
*/
export declare class MarkdownLoader {
private static loadPromise;
private static isLoaded;
private static config;
private static readonly DEFAULT_CDN_URLS;
private static readonly DEFAULT_TIMEOUT_MS;
/**
* Configure the markdown loader
*/
static configure(config: MarkdownConfig): void;
/**
* Dynamically load marked.js from CDN
* Returns a promise that resolves to true if loaded successfully, false otherwise
*/
static loadMarked(config?: MarkdownConfig): Promise<boolean>;
/**
* Check if marked.js is available (either loaded dynamically or already present)
*/
static isAvailable(): boolean;
/**
* Get the marked instance if available with proper typing
*/
static getMarked(): typeof window.marked | null;
/**
* Perform the actual loading of marked.js
*/
private static performLoad;
/**
* Try to load marked.js from a specific URL
*/
private static tryLoadFromUrl;
/**
* Reset the loader state (useful for testing)
*/
static reset(): void;
/**
* Clean up loaded scripts from the DOM
*/
static cleanup(): void;
/**
* Get current configuration
*/
static getConfig(): Readonly<MarkdownConfig>;
}