export type ScriptStatus = 'idle' | 'loading' | 'ready' | 'error'; export type ScriptEvents = Exclude; export type ScriptAttributes = { [key in keyof HTMLScriptElement | string]: string; }; /** Configuration options for the script loading behavior. */ export type ScriptConfig = { /** Whether the script should be loaded as an ES6 module. */ module?: boolean; /** Flag to bypass the cache by appending a timestamp to the script URL. */ cache?: boolean; /** Additional HTML attributes to set on the script element. */ attrs?: ScriptAttributes; }; export type EventCallback = (data?: any) => void; /** * Class responsible for dynamically injecting a script element into the DOM, * managing its loading state, and providing event hooks for script status changes. * This class handles the script's creation, its addition to the document, and * monitors the script's loading progress. Users can subscribe to 'loading', 'ready', * and 'error' events to execute custom callbacks based on the script's status. */ export declare class ScriptInjector { private src; private module; private attrs; private events; private script; private cache; /** * Creates an instance of ScriptInjector. * @param {string} src - The source URL of the script. * @param {ScriptConfig} [config={}] - Optional configuration options. */ constructor(src: string, config?: ScriptConfig); /** * Subscribe to script events. * @param {ScriptEvents} event - The event to subscribe to ('loading', 'ready', 'error'). * @param {EventCallback} callback - The callback function to execute when the event occurs. */ on(event: ScriptEvents, callback: EventCallback): void; /** * Execute the script injection process. */ execute(): void; /** * Get an existing script element if it exists in the DOM. * @returns {HTMLScriptElement | null} - The existing script element or null if not found. */ private getScript; /** * Handle an existing script element. */ private handleScript; /** * Create and load a new script element. */ private loadScript; /** * Load ESM module using dynamic import with blob URL to bypass Speedy */ private loadModuleViaBlobUrl; /** * Traditional script loading with src attribute */ private loadTraditionalScript; /** * Add event listeners to the script element. */ private addEventListeners; /** * Update the status of the script element. * @param {ScriptStatus} status - The new status of the script. */ private updateStatus; /** * Trigger the callbacks for a given event. * @param {ScriptStatus} status - The event status to trigger. */ private triggerEvent; } //# sourceMappingURL=script-injector.d.ts.map