/** * Browser support utilities for pupt-lib. * Provides import map generation and CDN URL resolution for browser environments. */ /** * Supported CDN providers */ export type CdnProvider = 'esm.sh' | 'unpkg' | 'jsdelivr' | 'skypack'; /** * Options for CDN resolution */ export interface CdnOptions { /** CDN provider to use */ cdn?: CdnProvider; /** Custom template URL with {name}, {version}, and optionally {path} placeholders */ cdnTemplate?: string; /** Optional path within the package (e.g., 'dist/index.js') */ path?: string; /** Optional scopes for import map */ scopes?: Record>; } /** * Represents a dependency for import map generation */ export interface Dependency { name: string; version: string; } /** * Standard import map structure * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap */ export interface ImportMap { imports: Record; scopes?: Record>; } /** * Resolve a CDN URL for a package. * * @param name - Package name (e.g., '@acme/pkg' or 'lodash') * @param version - Package version (e.g., '1.0.0') * @param options - CDN options * @returns The resolved CDN URL * * @example * ```typescript * resolveCdn('@acme/pkg', '1.0.0', { cdn: 'esm.sh' }); * // => 'https://esm.sh/@acme/pkg@1.0.0' * * resolveCdn('@acme/pkg', '1.0.0', { cdn: 'unpkg' }); * // => 'https://unpkg.com/@acme/pkg@1.0.0' * * resolveCdn('@acme/pkg', '1.0.0', { * cdnTemplate: 'https://cdn.example.com/{name}@{version}' * }); * // => 'https://cdn.example.com/@acme/pkg@1.0.0' * ``` */ export declare function resolveCdn(name: string, version: string, options: CdnOptions): string; /** * Generate an import map for a list of dependencies. * * @param dependencies - Array of dependencies with name and version * @param options - CDN options * @returns An ImportMap object ready to be serialized * * @example * ```typescript * const deps = [ * { name: '@pupt/lib', version: '1.0.0' }, * { name: '@acme/prompts', version: '2.0.0' }, * ]; * * const importMap = generateImportMap(deps, { cdn: 'esm.sh' }); * // => { * // imports: { * // '@pupt/lib': 'https://esm.sh/pupt-lib@1.0.0', * // '@acme/prompts': 'https://esm.sh/@acme/prompts@2.0.0' * // } * // } * ``` */ export declare function generateImportMap(dependencies: Dependency[], options: CdnOptions): ImportMap; /** * Serialize an import map to a JSON string for embedding in HTML. * * @param importMap - The import map to serialize * @returns JSON string * * @example * ```typescript * const json = serializeImportMap(importMap); * // Use in HTML: * ``` */ export declare function serializeImportMap(importMap: ImportMap): string; /** * Generate an HTML script tag with an import map. * * @param dependencies - Array of dependencies with name and version * @param options - CDN options * @returns HTML string for the import map script tag * * @example * ```typescript * const html = generateImportMapScript(deps, { cdn: 'esm.sh' }); * // => * ``` */ export declare function generateImportMapScript(dependencies: Dependency[], options: CdnOptions): string; /** * Options for generating pupt-lib import map */ export interface PuptLibImportMapOptions { /** CDN provider to use (default: 'esm.sh') */ cdn?: CdnProvider; /** Custom CDN template URL */ cdnTemplate?: string; /** pupt-lib version (default: current installed version) */ puptLibVersion?: string; /** Additional dependencies to include */ additionalDependencies?: Dependency[]; } /** * Generate an import map for browser usage of pupt-lib. * * This creates the minimal import map required to use `createPromptFromSource` * in browser environments. It includes: * - pupt-lib main entry * - pupt-lib/jsx-runtime subpath * * Note: zod, minisearch, and @babel/standalone are bundled into pupt-lib's dist * and do not need separate import map entries. * * @param options - Configuration options * @returns An ImportMap object ready to be serialized * * @example * ```typescript * // Using esm.sh (default) * const importMap = generatePuptLibImportMap({ puptLibVersion: '1.1.0' }); * * // Using unpkg * const importMap = generatePuptLibImportMap({ * puptLibVersion: '1.1.0', * cdn: 'unpkg' * }); * * // With additional dependencies * const importMap = generatePuptLibImportMap({ * puptLibVersion: '1.1.0', * additionalDependencies: [ * { name: 'my-component-lib', version: '2.0.0' } * ] * }); * ``` * * @example * ```html * * * ``` */ export declare function generatePuptLibImportMap(options?: PuptLibImportMapOptions): ImportMap; /** * Generate an HTML script tag with the pupt-lib import map. * * @param options - Configuration options * @returns HTML string for the import map script tag * * @example * ```typescript * const html = generatePuptLibImportMapScript({ puptLibVersion: '1.1.0' }); * // Use in HTML head: document.head.insertAdjacentHTML('afterbegin', html); * ``` */ export declare function generatePuptLibImportMapScript(options?: PuptLibImportMapOptions): string; //# sourceMappingURL=browser-support.d.ts.map