import { ComponentType, ModuleEntry, PuptElement, ResolvedModuleEntry } from '../types'; import { PromptSource } from '../types/prompt-source'; /** A compiled prompt from a discovered .prompt file */ export interface CompiledPrompt { element: PuptElement; id: string; name: string; title?: string; description: string; tags: string[]; version?: string; } /** * Represents a loaded library with its components and prompts */ export interface LoadedLibrary { name: string; components: Record; prompts: Record; dependencies: string[]; } /** * Parsed package source information */ export interface ParsedPackageSource { name: string; version?: string; } /** * ModuleLoader handles loading modules from various sources (npm, URL, GitHub, local). * It manages deduplication and version conflict detection. */ export declare class ModuleLoader { private loaded; private loading; private versions; /** * Parse a package source string into name and version. * Handles scoped packages (@scope/name@version) and regular packages (name@version). */ parsePackageSource(source: string): ParsedPackageSource; /** * Load a module entry (ResolvedModuleEntry, PromptSource, or package reference). * Dispatches to the appropriate loading strategy based on entry type. */ loadEntry(entry: ModuleEntry): Promise; /** * Load a module from a ResolvedModuleEntry. * Uses the explicit `type` field for routing and passes `promptDirs` through * to the appropriate prompt source. */ loadResolvedEntry(entry: ResolvedModuleEntry): Promise; /** * Load prompts from a PromptSource instance. */ loadPromptSource(source: PromptSource, name?: string): Promise; /** * Load prompts from a dynamic package reference. * Imports the source module, instantiates its default export with the config, * and calls getPrompts() on it. */ loadPackageReference(ref: { source: string; config: Record; }): Promise; /** * Detect Component classes in module exports */ detectComponents(exports: Record): Record; /** * Detect Prompt elements in module exports */ detectPrompts(exports: Record): Record; /** * Normalize a source string for consistent deduplication. * Resolves relative paths to absolute, normalizes package names to lowercase. */ normalizeSource(source: string, type: ResolvedModuleEntry["type"]): string; /** * Discover and compile .prompt files from a PromptSource. * Each file is compiled through createPromptFromSource() and metadata extracted. */ discoverAndCompilePrompts(source: PromptSource): Promise>; /** * Clear all loaded modules (useful for testing) */ clear(): void; /** * Convert detected PuptElement prompts from JS exports into CompiledPrompt records. */ private convertDetectedPrompts; /** * Check if a value is a PuptElement with a name prop (indicates a Prompt) */ private isPromptElement; /** * Compile an array of discovered prompt files into CompiledPrompt records. */ private compilePromptFiles; /** * Internal load dispatch using explicit type and passing promptDirs to prompt sources. */ private doLoad; /** * Load a local module */ private loadLocal; /** * Load an npm package. * Tries to import as a JS module and additionally discovers .prompt files. */ private loadNpm; /** * Check if a URL looks like an npm tarball or CDN package URL. */ private isTarballOrCdnUrl; /** * Load a module from a URL. * Routes tarball/CDN URLs to NpmRegistryPromptSource for prompt discovery. * Other URLs are loaded as JS modules via dynamic import. */ private loadUrl; /** * Load prompts from a tarball or CDN URL via NpmRegistryPromptSource. */ private loadUrlAsPromptSource; /** * Load a module from a Git source (GitHub URL). * Extracts owner/repo from the URL, tries JS import and .prompt file discovery. */ private loadGit; /** * Extract a module name from a file path */ private extractNameFromPath; /** * Extract a module name from a URL */ private extractNameFromUrl; } //# sourceMappingURL=module-loader.d.ts.map