/** * Grid 3 Symbol Extraction Strategy * * For converting Grid 3 gridsets to other formats (like Asterics), * we need to handle symbol library references properly. * * Strategy: * 1. Check if image is embedded in gridset (extract directly) * 2. If symbol library reference: * a. Check if we can extract from .pix file (limited support) * b. Provide reference/URL for manual resolution * c. For Tawasol: provide alternative sources */ import { type SymbolReference } from './symbols'; import { FileAdapter, ProcessorInput } from '../../utils/io'; import { ZipAdapter } from '../../utils/zip'; /** * Image extraction result */ export interface ExtractedImage { found: boolean; data?: Buffer; format?: 'png' | 'jpg' | 'jpeg' | 'gif' | 'svg' | 'unknown'; source: 'embedded' | 'symbol-library' | 'external-file' | 'not-found'; reference?: string; error?: string; metadata?: { library?: string; symbolPath?: string; attribution?: string; license?: string; }; } /** * Symbol extraction options */ export interface SymbolExtractionOptions { grid3Path?: string; locale?: string; preferEmbedded?: boolean; includeAttribution?: boolean; /** For Tawasol: try to find alternative sources */ tryAlternativeSources?: boolean; /** Callback for when symbol needs manual extraction */ onMissingSymbol?: (ref: SymbolReference) => void; } /** * Extract image data for a button * @param gridsetBuffer - Gridset ZIP buffer * @param resolvedImageEntry - Path to embedded image in gridset * @param symbolReference - Symbol library reference * @param options - Extraction options * @returns Extracted image data */ export declare function extractButtonImage(gridsetBuffer: Buffer, resolvedImageEntry: string | undefined, symbolReference: string | undefined, options?: SymbolExtractionOptions, fileAdapter?: FileAdapter, zipAdapter?: (input: ProcessorInput) => Promise): Promise; /** * Extract image from symbol library * @param reference - Symbol reference like "[tawasl]/food/apple.png" * @param options - Extraction options * @returns Extracted image or reference info */ export declare function extractSymbolLibraryImage(reference: string, options?: SymbolExtractionOptions): Promise; /** * Convert extracted image to Asterics Grid format * @param extracted - Extracted image * @returns GridImage object for Asterics */ export declare function convertToAstericsImage(extracted: ExtractedImage): any; /** * Generate a symbol extraction report * Useful for identifying which symbols need manual extraction */ export interface SymbolReport { total: number; embedded: number; symbolLibraries: number; notFound: number; byLibrary: Record; missingSymbols: Array<{ reference: string; library: string; path: string; attribution?: string; license?: string; }>; } /** * Analyze symbol usage for a gridset * @param tree - AAC tree * @returns Symbol usage report */ export declare function analyzeSymbolExtraction(tree: any): SymbolReport; /** * Suggest extraction strategy based on report */ export declare function suggestExtractionStrategy(report: SymbolReport): string; /** * Export symbol references to CSV for manual extraction */ export declare function exportSymbolReferencesToCsv(report: SymbolReport, outputPath: string, fileAdapter?: FileAdapter): Promise; /** * Create a manifest file for missing symbols */ export interface SymbolManifest { generatedAt: string; gridset: string; totalSymbols: number; embedded: number; fromLibraries: number; libraries: Record; symbols: Array<{ pageId: string; buttonId: string; reference: string; label?: string; }>; } export declare function createSymbolManifest(tree: any, gridsetName: string): SymbolManifest;