import { Logger } from '@elliemae/pui-diagnostics'; export declare const APP_SCRIPT_ID_PREFIX = "ice-script-"; type LoadOptions = { name: string; hostUrl: string; documentEle: Document; isESMModule?: boolean; }; /** * Class to load and unload script resources dynamically */ /** * A utility class for dynamically loading, managing, and removing script elements in the DOM. * @remarks * This class provides methods to: * - Add script elements dynamically to the document * - Remove script elements by ID * - Clean up dynamically imported scripts by host URL * - Remove prefetch link elements by host URL * @example * ```typescript * const logger = new Logger(); * const scriptLoader = new ScriptLoader(logger); * * // Add a script * await scriptLoader.add({ * name: 'myApp', * hostUrl: 'https://example.com', * documentEle: document, * fileName: 'bundle.js', * index: 0 * }); * * // Remove a script * await scriptLoader.remove('app-script-myapp-0', document); * ``` */ export declare class ScriptLoader { #private; constructor(logger: Logger); /** * Loads multiple script assets in manifest order, like HTML module script tags. * @param assets - Array of script URLs (either full HTTP/HTTPS URLs or relative paths) * @param options - Configuration options for loading the scripts * @param options.name - The name of the application (used for generating script IDs) * @param options.hostUrl - The base URL for resolving relative script paths * @param options.documentEle - The document object where scripts should be added * @param options.isESMModule - Whether scripts should be loaded as ES modules (default: true) * @returns A promise that resolves with an array of script element IDs when all scripts are loaded * @remarks * This method: * - Stages external (CDN) scripts before local guest-host scripts * - Preserves manifest order within each origin group * - Creates modulepreload links for all assets for performance optimization * - Inserts script tags synchronously per stage so the browser can fetch in parallel * - Syncs webpack public path from hostUrl (or guest _ASSET_PATH) before local scripts run * @example * ```typescript * const scriptIds = await scriptLoader.load( * ['https://cdn.example.com/lib.js', 'global.js', 'runtime~app.js'], * { * name: 'myApp', * hostUrl: 'https://example.com/my-app/', * documentEle: document, * isESMModule: true * } * ); * ``` */ load: (assets: string[], options: LoadOptions) => Promise; /** * Removes a script element from the document by its ID. * @param elementId - The ID of the script element to remove (default: '') * @param documentEle - The document object from which to remove the script (default: document) * @returns A promise that resolves when the script element has been removed * @remarks * If the element with the specified ID is not found, a warning is logged but the promise still resolves. * @example * ```typescript * await scriptLoader.remove('ice-script-myapp-0', document); * ``` */ remove: (elementId?: string, documentEle?: Document) => Promise; /** * Removes all script elements from the document that match a specific host URL pattern. * @param hostUrl - The host URL pattern to match against script sources * @param documentEle - The document object from which to remove scripts * @remarks * This method iterates through all script elements in reverse order and removes any script * whose `src` attribute matches the provided host URL pattern (case-insensitive). * This is useful for cleaning up dynamically imported scripts from a specific host. * @example * ```typescript * scriptLoader.removeDynamicImportedScripts('https://cdn.example.com', document); * ``` */ removeDynamicImportedScripts: (hostUrl: string, documentEle: Document) => void; /** * Removes all prefetch link elements from the document that match a specific host URL pattern. * @param hostUrl - The host URL pattern to match against link hrefs * @param documentEle - The document object from which to remove prefetch links * @remarks * This method queries all elements with `rel="prefetch"` and removes any link whose `href` * attribute matches the provided host URL pattern (case-insensitive). This is useful for * cleaning up resource hints that are no longer needed. * @example * ```typescript * scriptLoader.removePrefetchLinks('https://cdn.example.com', document); * ``` */ removePrefetchLinks: (hostUrl: string, documentEle: Document) => void; } export {};