import { BinaryData } from '@character-foundry/core'; import { CCv3Data } from '@character-foundry/schemas'; /** * Exporter Types * * Types for the universal card exporter API. */ /** * Target export format */ type ExportFormat = 'png' | 'charx' | 'voxta'; /** * Asset to include in export */ interface ExportAsset { /** Asset name/identifier */ name: string; /** Asset type */ type: 'icon' | 'emotion' | 'background' | 'sound' | 'data' | 'custom'; /** File extension */ ext: string; /** Binary data */ data: BinaryData; /** Whether this is the main/primary asset (used for PNG embedding) */ isMain?: boolean; /** Original path or source identifier (e.g., pngchunk:0) */ path?: string; /** Additional tags for categorization */ tags?: string[]; } /** * Loss report for export */ interface ExportLossReport { /** Fields that will be lost */ lostFields: string[]; /** Assets that cannot be exported */ lostAssets: string[]; /** Warnings about potential issues */ warnings: string[]; /** Target format */ targetFormat: ExportFormat; /** Whether export is lossless */ isLossless: boolean; } /** * Common export options */ interface ExportOptionsBase { /** Whether to check for loss before export (default: true) */ checkLoss?: boolean; /** Compression level for ZIP-based formats (0-9, default: 6) */ compressionLevel?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; } /** * PNG export options */ interface PngExportOptions extends ExportOptionsBase { /** Chunk key to use (default: 'chara' for v2 compat, 'ccv3' for v3) */ chunkKey?: 'chara' | 'ccv3' | 'chara_card_v3'; /** Whether to use zTXt (compressed) chunk (default: true for large cards) */ useCompression?: boolean; /** Export as v2 format for maximum compatibility (default: false) */ exportAsV2?: boolean; } /** * CharX export options */ interface CharxExportOptions extends ExportOptionsBase { /** Target spec: 'v3' = standard, 'risu' = include x_meta */ spec?: 'v3' | 'risu'; /** Include readme.txt (default: false) */ includeReadme?: boolean; /** Emit x_meta for image assets (default: false, auto-enabled for risu spec) */ emitXMeta?: boolean; /** Risu module.risum binary to include (opaque, preserved from read) */ moduleRisum?: BinaryData; } /** * Voxta export options */ interface VoxtaExportOptions extends ExportOptionsBase { /** Character ID to use (auto-generated if not provided) */ characterId?: string; /** Package ID to use (auto-generated if not provided) */ packageId?: string; /** Include package.json metadata (default: false) */ includePackageJson?: boolean; } /** * Export options union */ type ExportOptions = PngExportOptions | CharxExportOptions | VoxtaExportOptions; /** * Result of exporting a card */ interface ExportResult { /** The exported binary data */ buffer: BinaryData; /** Target format that was used */ format: ExportFormat; /** Suggested filename */ filename: string; /** MIME type for the export */ mimeType: string; /** Number of assets included */ assetCount: number; /** Total size in bytes */ totalSize: number; /** Loss report (if checkLoss was enabled) */ lossReport?: ExportLossReport; } /** * Pre-export check result */ interface PreExportCheck { /** Whether export can proceed */ canExport: boolean; /** Loss report */ lossReport: ExportLossReport; /** Suggested alternatives if current format has significant loss */ suggestedFormats?: ExportFormat[]; } /** * Universal Card Exporter * * Exports character cards to any supported format. */ /** * Options for exportCard function */ interface ExportCardOptions { /** Target format */ format: ExportFormat; /** Format-specific options */ png?: PngExportOptions; charx?: CharxExportOptions; voxta?: VoxtaExportOptions; } /** * Export a character card to any supported format * * @param card - CCv3 card data to export * @param assets - Assets to include in export * @param options - Export options including target format * @returns ExportResult with buffer and metadata */ declare function exportCard(card: CCv3Data, assets: ExportAsset[], options: ExportCardOptions): ExportResult; /** * Async version of exportCard */ declare function exportCardAsync(card: CCv3Data, assets: ExportAsset[], options: ExportCardOptions): Promise; /** * Get supported export formats */ declare function getSupportedFormats(): ExportFormat[]; /** * Get file extension for a format */ declare function getFormatExtension(format: ExportFormat): string; /** * Get MIME type for a format */ declare function getFormatMimeType(format: ExportFormat): string; /** * PNG Exporter * * Exports character cards to PNG format with embedded JSON. */ /** * Export card to PNG format */ declare function exportToPng(card: CCv3Data, assets: ExportAsset[], options?: PngExportOptions): ExportResult; /** * Async version of exportToPng */ declare function exportToPngAsync(card: CCv3Data, assets: ExportAsset[], options?: PngExportOptions): Promise; /** * CharX Exporter * * Exports character cards to CharX (ZIP) format. */ /** * Export card to CharX format */ declare function exportToCharx(card: CCv3Data, assets: ExportAsset[], options?: CharxExportOptions): ExportResult; /** * Async version of exportToCharx */ declare function exportToCharxAsync(card: CCv3Data, assets: ExportAsset[], options?: CharxExportOptions): Promise; /** * Voxta Exporter * * Exports character cards to Voxta (VoxPkg) format. */ /** * Export card to Voxta format */ declare function exportToVoxta(card: CCv3Data, assets: ExportAsset[], options?: VoxtaExportOptions): ExportResult; /** * Async version of exportToVoxta */ declare function exportToVoxtaAsync(card: CCv3Data, assets: ExportAsset[], options?: VoxtaExportOptions): Promise; /** * Export Loss Checker * * Analyzes what data would be lost when exporting to different formats. */ /** * Check what would be lost when exporting to a specific format */ declare function checkExportLoss(card: CCv3Data, assets: ExportAsset[], targetFormat: ExportFormat): ExportLossReport; /** * Perform pre-export check and suggest alternatives */ declare function preExportCheck(card: CCv3Data, assets: ExportAsset[], targetFormat: ExportFormat): PreExportCheck; /** * Format a loss report as human-readable string */ declare function formatLossReport(report: ExportLossReport): string; export { type CharxExportOptions, type ExportAsset, type ExportCardOptions, type ExportFormat, type ExportLossReport, type ExportOptions, type ExportOptionsBase, type ExportResult, type PngExportOptions, type PreExportCheck, type VoxtaExportOptions, checkExportLoss, exportCard, exportCardAsync, exportToCharx, exportToCharxAsync, exportToPng, exportToPngAsync, exportToVoxta, exportToVoxtaAsync, formatLossReport, getFormatExtension, getFormatMimeType, getSupportedFormats, preExportCheck };