UNPKG

@xec-sh/cli

Version:

Xec: The Universal Shell for TypeScript

45 lines (44 loc) 1.57 kB
export interface ModuleLoaderOptions { cacheDir?: string; preferredCDN?: 'esm.sh' | 'jsr.io' | 'unpkg' | 'skypack' | 'jsdelivr'; verbose?: boolean; cache?: boolean; cdnOnly?: boolean; } export declare class ModuleLoader { private options; private cacheDir; private memoryCache; private pendingLoads; private isInitialized; constructor(options?: ModuleLoaderOptions); init(): Promise<void>; importModule(specifier: string): Promise<any>; private _importModule; private importFromCDN; private _importFromCDN; private isLocalModule; private getCDNUrl; private fetchFromCDN; private detectModuleType; private executeModule; private loadFromCache; private saveToCache; private getCacheKey; private transformESMContent; private executeESMModule; private executeCJSModule; private executeUMDModule; transformTypeScript(code: string, filename: string): Promise<string>; loadScript(scriptPath: string, args?: string[]): Promise<any>; clearCache(): Promise<void>; getCacheStats(): Promise<{ memoryEntries: number; fileEntries: number; totalSize: number; }>; } export declare function getModuleLoader(options?: ModuleLoaderOptions): ModuleLoader; export declare function initializeGlobalModuleContext(options?: ModuleLoaderOptions): Promise<void>; export declare function importModule(specifier: string): Promise<any>; export declare function createCDNOnlyLoader(options?: Omit<ModuleLoaderOptions, 'cdnOnly'>): ModuleLoader;