/** * Grid 3 Symbol Library Resolution * * Grid 3 uses symbol libraries stored as .pix files in the installation directory. * Symbol references in Grid files use the format: [library]/path/to/symbol.png * * Examples: * - [widgit]/food/apple.png * - [tawasl]/above bw.png * - [ssnaps]963.jpg * - [grid3x]/folder/document.png * * This module provides symbol resolution and metadata extraction. */ import { FileAdapter, ProcessorInput } from '../../utils/io'; import { ZipAdapter } from '../../utils/zip'; /** * Known symbol libraries in Grid 3 */ export declare const SYMBOL_LIBRARIES: { readonly WIDGIT: "widgit"; readonly TAWASL: "tawasl"; readonly SSNAPS: "ssnaps"; readonly GRID3X: "grid3x"; readonly GRID2X: "grid2x"; readonly BLISSX: "blissx"; readonly EYEGAZ: "eyegaz"; readonly INTERL: "interl"; readonly METACM: "metacm"; readonly MJPCS: "mjpcs#"; readonly PCSHC: "pcshc#"; readonly PCSTL: "pcstl#"; readonly SESENS: "sesens"; readonly SSTIX: "sstix#"; readonly SYMOJI: "symoji"; }; export type SymbolLibraryName = (typeof SYMBOL_LIBRARIES)[keyof typeof SYMBOL_LIBRARIES]; /** * Symbol reference parsed from Grid 3 format */ export interface SymbolReference { library: string; path: string; fullReference: string; isValid: boolean; } /** * Symbol library information */ export interface SymbolLibraryInfo { name: string; pixFile: string; exists: boolean; size: number; locale: string; } /** * Symbol resolution options */ export interface SymbolResolutionOptions { grid3Path?: string; symbolDir?: string; locale?: string; fallbackToEmbed?: boolean; } /** * Symbol resolution result */ export interface SymbolResolutionResult { reference: SymbolReference; found: boolean; path?: string; data?: Buffer; libraryInfo?: SymbolLibraryInfo; error?: string; } /** * Default locale to use */ export declare const DEFAULT_LOCALE = "en-GB"; /** * Parse a symbol reference string * @param reference - Symbol reference like "[widgit]/food/apple.png" * @returns Parsed symbol reference */ export declare function parseSymbolReference(reference: string): SymbolReference; /** * Check if a string is a symbol library reference * @param reference - String to check * @returns True if it's a symbol reference like [widgit]/... */ export declare function isSymbolReference(reference: string): boolean; /** * Get the default Grid 3 installation path for the current platform * @returns Default Grid 3 path or empty string if not found */ export declare function getDefaultGrid3Path(fileAdapter?: FileAdapter): Promise; /** * Get the Symbol Libraries directory path * Contains .symbols ZIP archives with actual image files * @param grid3Path - Grid 3 installation path * @returns Path to Symbol Libraries directory (e.g., "C:\...\Grid 3\Resources\Symbols") */ export declare function getSymbolLibrariesDir(grid3Path: string, fileAdapter?: FileAdapter): string; /** * Get the symbol search indexes directory path for a given locale * Contains .pix index files for searching symbols * @param grid3Path - Grid 3 installation path * @param locale - Locale code (e.g., 'en-GB') * @returns Path to symbol search indexes directory (e.g., "C:\...\Grid 3\Locale\en-GB\symbolsearch") */ export declare function getSymbolSearchIndexesDir(grid3Path: string, locale?: string, fileAdapter?: FileAdapter): string; /** * Get all available symbol libraries in the Grid 3 installation * @param options - Resolution options * @returns Array of symbol library information */ export declare function getAvailableSymbolLibraries(options?: SymbolResolutionOptions, fileAdapter?: FileAdapter): Promise; /** * Check if a symbol library exists * @param libraryName - Name of the library (e.g., 'widgit', 'tawasl') * @param options - Resolution options * @returns Symbol library info or undefined if not found */ export declare function getSymbolLibraryInfo(libraryName: string, options?: SymbolResolutionOptions, fileAdapter?: FileAdapter): Promise; /** * Resolve a symbol reference to extract the actual image data * @param reference - Symbol reference like "[tawasl]/above bw.png" * @param options - Resolution options * @returns Resolution result with image data if found */ export declare function resolveSymbolReference(reference: string, options?: SymbolResolutionOptions, fileAdapter?: FileAdapter, zipAdapter?: (input: ProcessorInput) => Promise): Promise; /** * Get all symbol references from a gridset * This scans button images for symbol references * @param tree - AAC tree from loaded gridset * @returns Array of unique symbol references */ export declare function extractSymbolReferences(tree: any): string[]; /** * Create a symbol reference from library and path * @param library - Library name * @param symbolPath - Path within the library * @returns Formatted symbol reference */ export declare function createSymbolReference(library: string, symbolPath: string): string; /** * Get the library name from a symbol reference * @param reference - Symbol reference * @returns Library name or empty string */ export declare function getSymbolLibraryName(reference: string): string; /** * Get the symbol path from a symbol reference * @param reference - Symbol reference * @returns Symbol path or empty string */ export declare function getSymbolPath(reference: string): string; /** * Check if a symbol library is one of the known Grid 3 libraries * @param libraryName - Library name to check * @returns True if it's a known library */ export declare function isKnownSymbolLibrary(libraryName: string): boolean; /** * Get display name for a symbol library * @param libraryName - Library name * @returns Human-readable display name */ export declare function getSymbolLibraryDisplayName(libraryName: string): string; /** * Analyze symbol usage in a gridset * @param tree - AAC tree from loaded gridset * @returns Symbol usage statistics */ export interface SymbolUsageStats { totalSymbols: number; byLibrary: Record; uniqueReferences: string[]; librariesUsed: string[]; } export declare function analyzeSymbolUsage(tree: any): SymbolUsageStats; /** * Convert symbol reference to filename for embedded images * Grid 3 sometimes embeds symbols with special naming * @param reference - Symbol reference * @param cellX - Cell X coordinate * @param cellY - Cell Y coordinate * @returns Generated filename */ export declare function symbolReferenceToFilename(reference: string, cellX: number, cellY: number): string; /** * @deprecated Use getSymbolLibrariesDir() instead - more descriptive name * Get the Symbols directory path (where .symbols ZIP archives are) */ export declare function getSymbolsDir(grid3Path: string): string; /** * @deprecated Use getSymbolSearchIndexesDir() instead - more descriptive name * Get the symbol search directory for a given locale (where .pix index files are) */ export declare function getSymbolSearchDir(grid3Path: string, locale?: string): string;