export { BoardViewer } from './board-viewer.js'; import { AACTree } from '@willwade/aac-processors'; export { AACButton, AACPage, AACSemanticAction, AACSemanticCategory, AACSemanticIntent, AACTree } from '@willwade/aac-processors'; import { M as MetricsOptions, B as ButtonMetric, L as LoadAACFileResult } from './index-D7ySIX_K.js'; export { a as BoardViewerProps } from './index-D7ySIX_K.js'; import 'react'; /** * React hooks for AAC Board Viewer */ /** * Hook to load an AAC file from a URL * * @param url - URL to the AAC file * @param options - Processor options (e.g., pageLayoutPreference for SNAP) * @returns Object with tree, loading state, and error * * @example * ```tsx * function MyViewer() { * const { tree, loading, error, reload } = useAACFile('/files/board.sps'); * * if (loading) return
Loading...
; * if (error) return
Error: {error.message}
; * * return ; * } * ``` */ declare function useAACFile(url: string, options?: { processorOptions?: Record; enabled?: boolean; }): { tree: AACTree | null; loading: boolean; error: Error | null; reload: () => Promise; }; /** * Hook to load an AAC file from a File object (Browser only) * * @param file - File object from file input * @param options - Processor options * @returns Object with tree, loading state, and error * * @example * ```tsx * function MyUploader() { * const [file, setFile] = useState(null); * const { tree, loading, error } = useAACFileFromFile(file); * * return ( *
* setFile(e.target.files?.[0])} /> * {loading &&
Loading...
} * {tree && } *
* ); * } * ``` */ declare function useAACFileFromFile(file: File | Blob | null, options?: { processorOptions?: Record; enabled?: boolean; }): { tree: AACTree | null; loading: boolean; error: Error | null; reload: () => Promise; }; /** * Hook to load an AAC file and calculate metrics * * @param url - URL to the AAC file * @param metricsOptions - Metrics calculation options * @returns Object with tree, metrics, loading state, and error * * @example * ```tsx * function MyViewer() { * const { tree, metrics, loading, error } = useAACFileWithMetrics( * '/files/board.sps', * { accessMethod: 'direct' } * ); * * if (loading) return
Loading...
; * if (error) return
Error: {error.message}
; * * return ; * } * ``` */ declare function useAACFileWithMetrics(url: string, metricsOptions?: MetricsOptions, fileOptions?: { processorOptions?: Record; enabled?: boolean; }): { tree: AACTree | null; metrics: ButtonMetric[] | null; loading: boolean; error: Error | null; reload: () => Promise; }; /** * Hook to load an AAC file from a File object and calculate metrics * * @param file - File object from file input * @param metricsOptions - Metrics calculation options * @returns Object with tree, metrics, loading state, and error * * @example * ```tsx * function MyUploader() { * const [file, setFile] = useState(null); * const { tree, metrics, loading, error } = useAACFileFromFileWithMetrics( * file, * { accessMethod: 'direct' } * ); * * return ( *
* setFile(e.target.files?.[0])} /> * {loading &&
Loading...
} * {tree && } *
* ); * } * ``` */ declare function useAACFileFromFileWithMetrics(file: File | Blob | null, metricsOptions?: MetricsOptions, fileOptions?: { processorOptions?: Record; enabled?: boolean; }): { tree: AACTree | null; metrics: ButtonMetric[] | null; loading: boolean; error: Error | null; reload: () => Promise; }; /** * Hook to calculate metrics for a tree * * @param tree - The AAC tree * @param options - Metrics calculation options * @returns Object with metrics, loading state, and error * * @example * ```tsx * function MyViewer({ tree }) { * const { metrics, loading } = useMetrics(tree, { * accessMethod: 'scanning', * scanningConfig: { pattern: 'row-column' } * }); * * return ; * } * ``` */ declare function useMetrics(tree: AACTree | null, options?: MetricsOptions): { metrics: ButtonMetric[] | null; loading: boolean; error: Error | null; recalculate: () => Promise; }; /** * Hook for sentence building state * * @returns Object with message state and handlers * * @example * ```tsx * function MyComponent() { * const { message, wordCount, effort, addWord, clear } = useSentenceBuilder(); * * return ( *
*

{message || 'Start building...'}

*

{wordCount} words, {effort.toFixed(2)} effort

* *
* ); * } * ``` */ declare function useSentenceBuilder(): { message: string; wordCount: number; effort: number; addWord: (word: string, wordEffort?: number) => void; clear: () => void; }; /** * AAC File Loading Utilities * * Provides utilities for loading AAC files from various sources * (File/Blob objects, file paths, URLs) in both browser and server contexts. * * Browser: Supports all formats. SQLite-backed formats (.sps, .spb, .ce) require SQL.js configuration. * Node.js: Supports all formats including filesystem access and SQLite-backed formats. */ type ProcessorOptions = Record | undefined; type SqlJsConfig = { locateFile: (file: string) => string; [key: string]: unknown; }; /** * Configure SQL.js for browser-only SQLite-backed formats (.sps/.spb/.ce). */ declare function configureBrowserSqlJs(config: SqlJsConfig): Promise; /** * Load an AAC file from a file path (Node.js only) * * @param filepath - Path to the AAC file * @param options - Processor options (e.g., pageLayoutPreference for SNAP) * @returns Promise resolving to AACTree * * @example * ```ts * const tree = await loadAACFile('/path/to/file.sps'); * ``` */ declare function loadAACFile(filepath: string, options?: ProcessorOptions): Promise; /** * Load an AAC file from a File or Blob object (Browser only) * * @param file - File or Blob object * @param options - Processor options * @returns Promise resolving to AACTree * * @example * ```ts * const input = document.querySelector('input[type="file"]'); * const file = input.files[0]; * const tree = await loadAACFile(file); * ``` */ declare function loadAACFile(file: File | Blob, options?: ProcessorOptions): Promise; /** * Load an AAC file from an ArrayBuffer (Browser only) * * @param buffer - ArrayBuffer containing file data * @param filename - Filename with extension to detect processor * @param options - Processor options * @returns Promise resolving to AACTree * * @example * ```ts * const arrayBuffer = await file.arrayBuffer(); * const tree = await loadAACFile(arrayBuffer, 'board.obf'); * ``` */ declare function loadAACFile(buffer: ArrayBuffer, filename: string, options?: ProcessorOptions): Promise; /** * Load an AAC file from a URL (Browser only) * * Note: This requires the server to provide the file with appropriate CORS headers. * For better performance, consider using loadAACFileFromFile() with direct file upload instead. * * @param url - URL to the AAC file * @param options - Processor options * @returns Promise resolving to AACTree * * @example * ```ts * const tree = await loadAACFileFromURL('https://example.com/file.obf'); * ``` */ declare function loadAACFileFromURL(url: string, options?: ProcessorOptions): Promise; /** * Load an AAC file and return extended result with format info * * @param input - File path (Node.js), File/Blob (Browser), or URL string * @param options - Processor options * @returns Promise resolving to LoadAACFileResult */ declare function loadAACFileWithMetadata(input: string | File | Blob, options?: ProcessorOptions): Promise; /** * Calculate cognitive effort metrics for an AAC tree * * @param tree - The AAC tree * @param options - Metrics calculation options * @returns Promise resolving to array of ButtonMetrics * * @example * ```ts * import { calculateMetrics } from 'aac-board-viewer'; * * const metrics = await calculateMetrics(tree, { * accessMethod: 'direct', * }); * ``` */ declare function calculateMetrics(tree: AACTree, options?: MetricsOptions): Promise<{ id: string; label: string; effort: number; count: number; is_word: boolean; level: number | undefined; semantic_id: string | undefined; clone_id: string | undefined; pos: string | undefined; is_word_form: boolean | undefined; parent_button_id: string | undefined; parent_button_label: string | undefined; }[]>; /** * Get a list of supported file formats * * @returns Array of format information */ declare function getSupportedFormats(): Array<{ name: string; extensions: string[]; description: string; browserCompatible: boolean; }>; /** * Check if a file format is compatible with browser processing * * @param extension - File extension (e.g., '.obf', 'obf') * @returns true if browser-compatible, false if server-only */ declare function isBrowserCompatible(extension: string): boolean; /** * Get list of browser-compatible file extensions */ declare function getBrowserExtensions(): string[]; /** * Get list of Node-only file extensions */ declare function getNodeOnlyExtensions(): string[]; export { ButtonMetric, LoadAACFileResult, MetricsOptions, calculateMetrics, configureBrowserSqlJs, getBrowserExtensions, getNodeOnlyExtensions, getSupportedFormats, isBrowserCompatible, loadAACFile, loadAACFileFromURL, loadAACFileWithMetadata, useAACFile, useAACFileFromFile, useAACFileFromFileWithMetrics, useAACFileWithMetrics, useMetrics, useSentenceBuilder };