/** * Grid3 Wordlist Helpers * * This module provides utilities for creating and extracting wordlists * from Grid3 gridsets. Wordlists are Grid3-specific data structures * used for dynamic vocabulary content. * * Note: Wordlists are only supported in Grid3 format. Other AAC formats * do not have equivalent wordlist functionality. */ import { FileAdapter, type ProcessorInput } from '../../utils/io'; import { ZipAdapter } from '../../utils/zip'; /** * Represents a single item in a wordlist */ export interface WordListItem { /** The text/word/phrase */ text: string; /** Optional image reference (e.g., "[WIDGIT]path/to/symbol.emf") */ image?: string; /** Part of speech category (e.g., "Noun", "Verb", "Unknown") */ partOfSpeech?: string; } /** * Represents a complete wordlist */ export interface WordList { /** Array of wordlist items */ items: WordListItem[]; } /** * Creates a WordList object from an array of words/phrases or a dictionary * * @param input - Either an array of strings or an object with text/image/partOfSpeech properties * @returns A WordList object ready to be used in Grid3 * * @example * // From simple array * const wordlist = createWordlist(['hello', 'goodbye', 'thank you']); * * @example * // From array of objects * const wordlist = createWordlist([ * { text: 'hello', image: '[WIDGIT]greetings/hello.emf', partOfSpeech: 'Interjection' }, * { text: 'goodbye', image: '[WIDGIT]greetings/goodbye.emf', partOfSpeech: 'Interjection' } * ]); */ export declare function createWordlist(input: string[] | WordListItem[] | Record): WordList; /** * Converts a WordList object to Grid3 XML format * * @param wordlist - The wordlist to convert * @returns XML string representation * @internal */ export declare function wordlistToXml(wordlist: WordList): string; /** * Extracts all wordlists from a gridset buffer * * @param gridsetBuffer - The gridset file as a Buffer * @returns Map of grid names to their wordlists (if they have any) * * @example * const wordlists = await extractWordlists(gridsetBuffer); * wordlists.forEach((wordlist, gridName) => { * console.log(`Grid "${gridName}" has ${wordlist.items.length} items`); * }); */ export declare function extractWordlists(gridsetBuffer: Uint8Array, password?: string | undefined, fileAdapter?: FileAdapter, zipAdapter?: (input: ProcessorInput) => Promise): Promise>; /** * Updates or adds a wordlist to a specific grid in a gridset * * @param gridsetBuffer - The gridset file as a Buffer * @param gridName - The name of the grid to update (e.g., "Greetings") * @param wordlist - The wordlist to add/update * @returns Updated gridset as a Buffer * * @example * const gridsetBuffer = fs.readFileSync('my-gridset.gridset'); * const newWordlist = createWordlist(['hello', 'hi', 'hey']); * const updatedGridset = updateWordlist(gridsetBuffer, 'Greetings', newWordlist); * fs.writeFileSync('updated-gridset.gridset', updatedGridset); */ export declare function updateWordlist(gridsetBuffer: Uint8Array, gridName: string, wordlist: WordList, password?: string | undefined, fileAdapter?: FileAdapter, zipAdapter?: (input: ProcessorInput) => Promise): Promise;