@willwade/aac-processors 0.0.13 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +45 -7
  2. package/dist/applePanels.d.ts +6 -0
  3. package/dist/applePanels.js +13 -0
  4. package/dist/astericsGrid.d.ts +6 -0
  5. package/dist/astericsGrid.js +13 -0
  6. package/dist/core/baseProcessor.d.ts +41 -0
  7. package/dist/core/baseProcessor.js +41 -0
  8. package/dist/dot.d.ts +6 -0
  9. package/dist/dot.js +13 -0
  10. package/dist/excel.d.ts +6 -0
  11. package/dist/excel.js +13 -0
  12. package/dist/gridset.d.ts +17 -0
  13. package/dist/gridset.js +130 -0
  14. package/dist/index.d.ts +24 -3
  15. package/dist/index.js +37 -8
  16. package/dist/obf.d.ts +7 -0
  17. package/dist/obf.js +15 -0
  18. package/dist/obfset.d.ts +6 -0
  19. package/dist/obfset.js +13 -0
  20. package/dist/opml.d.ts +6 -0
  21. package/dist/opml.js +13 -0
  22. package/dist/processors/gridset/symbolAlignment.d.ts +125 -0
  23. package/dist/processors/gridset/symbolAlignment.js +283 -0
  24. package/dist/processors/gridsetProcessor.d.ts +26 -0
  25. package/dist/processors/gridsetProcessor.js +121 -5
  26. package/dist/processors/index.d.ts +8 -18
  27. package/dist/processors/index.js +9 -175
  28. package/dist/processors/obfProcessor.d.ts +26 -0
  29. package/dist/processors/obfProcessor.js +82 -1
  30. package/dist/processors/snapProcessor.js +1 -1
  31. package/dist/processors/touchchatProcessor.d.ts +26 -0
  32. package/dist/processors/touchchatProcessor.js +82 -1
  33. package/dist/snap.d.ts +7 -0
  34. package/dist/snap.js +24 -0
  35. package/dist/touchchat.d.ts +7 -0
  36. package/dist/touchchat.js +16 -0
  37. package/dist/translation.d.ts +13 -0
  38. package/dist/translation.js +21 -0
  39. package/dist/utilities/translation/translationProcessor.d.ts +119 -0
  40. package/dist/utilities/translation/translationProcessor.js +204 -0
  41. package/dist/validation.d.ts +13 -0
  42. package/dist/validation.js +28 -0
  43. package/package.json +58 -4
  44. package/dist/utilities/screenshotConverter.d.ts +0 -69
  45. package/dist/utilities/screenshotConverter.js +0 -453
  46. /package/dist/{optional → utilities}/analytics/history.d.ts +0 -0
  47. /package/dist/{optional → utilities}/analytics/history.js +0 -0
  48. /package/dist/{optional → utilities}/analytics/index.d.ts +0 -0
  49. /package/dist/{optional → utilities}/analytics/index.js +0 -0
  50. /package/dist/{optional → utilities}/analytics/metrics/comparison.d.ts +0 -0
  51. /package/dist/{optional → utilities}/analytics/metrics/comparison.js +0 -0
  52. /package/dist/{optional → utilities}/analytics/metrics/core.d.ts +0 -0
  53. /package/dist/{optional → utilities}/analytics/metrics/core.js +0 -0
  54. /package/dist/{optional → utilities}/analytics/metrics/effort.d.ts +0 -0
  55. /package/dist/{optional → utilities}/analytics/metrics/effort.js +0 -0
  56. /package/dist/{optional → utilities}/analytics/metrics/index.d.ts +0 -0
  57. /package/dist/{optional → utilities}/analytics/metrics/index.js +0 -0
  58. /package/dist/{optional → utilities}/analytics/metrics/obl-types.d.ts +0 -0
  59. /package/dist/{optional → utilities}/analytics/metrics/obl-types.js +0 -0
  60. /package/dist/{optional → utilities}/analytics/metrics/obl.d.ts +0 -0
  61. /package/dist/{optional → utilities}/analytics/metrics/obl.js +0 -0
  62. /package/dist/{optional → utilities}/analytics/metrics/sentence.d.ts +0 -0
  63. /package/dist/{optional → utilities}/analytics/metrics/sentence.js +0 -0
  64. /package/dist/{optional → utilities}/analytics/metrics/types.d.ts +0 -0
  65. /package/dist/{optional → utilities}/analytics/metrics/types.js +0 -0
  66. /package/dist/{optional → utilities}/analytics/metrics/vocabulary.d.ts +0 -0
  67. /package/dist/{optional → utilities}/analytics/metrics/vocabulary.js +0 -0
  68. /package/dist/{optional → utilities}/analytics/reference/index.d.ts +0 -0
  69. /package/dist/{optional → utilities}/analytics/reference/index.js +0 -0
  70. /package/dist/{optional → utilities}/analytics/utils/idGenerator.d.ts +0 -0
  71. /package/dist/{optional → utilities}/analytics/utils/idGenerator.js +0 -0
  72. /package/dist/{optional → utilities}/symbolTools.d.ts +0 -0
  73. /package/dist/{optional → utilities}/symbolTools.js +0 -0
@@ -0,0 +1,119 @@
1
+ /**
2
+ * LLM-Based Translation with Symbol Preservation
3
+ *
4
+ * This module provides utilities for translating AAC files while preserving
5
+ * symbol-to-word associations across different formats (gridset, OBF, Snap, etc.).
6
+ *
7
+ * The key insight: Different AAC formats have different internal structures,
8
+ * but they all share common concepts:
9
+ * - Buttons with labels and messages
10
+ * - Symbols attached to specific words
11
+ * - Need to preserve symbol positions during translation
12
+ *
13
+ * This module provides a format-agnostic way to:
14
+ * 1. Extract symbol information for LLM processing
15
+ * 2. Apply LLM translations with preserved symbols
16
+ *
17
+ * Usage:
18
+ * 1. Processor extracts buttons and calls extractSymbolsForLLM()
19
+ * 2. LLM translates and returns aligned symbols
20
+ * 3. Processor calls processLLMTranslations() to apply results
21
+ */
22
+ /**
23
+ * Represents a symbol attached to text in a format-agnostic way
24
+ */
25
+ export interface SymbolInfo {
26
+ text: string;
27
+ image?: string;
28
+ symbolLibrary?: string;
29
+ symbolPath?: string;
30
+ }
31
+ /**
32
+ * Button data extracted for translation (format-agnostic)
33
+ */
34
+ export interface ButtonForTranslation {
35
+ buttonId: string;
36
+ pageId?: string;
37
+ pageName?: string;
38
+ label: string;
39
+ message: string;
40
+ textToTranslate: string;
41
+ symbols: SymbolInfo[];
42
+ }
43
+ /**
44
+ * LLM translation result with symbol mappings
45
+ */
46
+ export interface LLMLTranslationResult {
47
+ buttonId: string;
48
+ translatedLabel?: string;
49
+ translatedMessage?: string;
50
+ symbols?: Array<{
51
+ text: string;
52
+ image?: string;
53
+ }>;
54
+ }
55
+ /**
56
+ * Extract symbols from a button for LLM-based translation.
57
+ *
58
+ * This is a format-agnostic helper that processors can use to normalize
59
+ * their button data into a common format for LLM processing.
60
+ *
61
+ * @param buttonId - Unique identifier for the button
62
+ * @param label - Button label text
63
+ * @param message - Button message/speak text
64
+ * @param symbols - Array of symbols from the button
65
+ * @param context - Optional page context
66
+ * @returns Normalized button data for translation
67
+ */
68
+ export declare function normalizeButtonForTranslation(buttonId: string, label: string, message: string, symbols: SymbolInfo[], context?: {
69
+ pageId?: string;
70
+ pageName?: string;
71
+ }): ButtonForTranslation;
72
+ /**
73
+ * Extract symbols from various button formats.
74
+ *
75
+ * This helper handles different ways symbols might be stored in button data:
76
+ * - semanticAction.richText.symbols (gridset format)
77
+ * - symbolLibrary + symbolPath fields
78
+ * - image field with [library]path format
79
+ *
80
+ * @param button - Button object from any AAC format
81
+ * @returns Array of symbol info, or undefined if no symbols
82
+ */
83
+ export declare function extractSymbolsFromButton(button: any): SymbolInfo[] | undefined;
84
+ /**
85
+ * Extract all buttons from a file for LLM translation.
86
+ *
87
+ * This is a convenience method that processors can use to extract all
88
+ * translatable buttons with their symbols in a format-agnostic way.
89
+ *
90
+ * @param buttons - Array of button objects from any AAC format
91
+ * @param contextFn - Optional function to provide page context for each button
92
+ * @returns Array of normalized button data ready for LLM translation
93
+ */
94
+ export declare function extractAllButtonsForTranslation(buttons: any[], contextFn?: (button: any) => {
95
+ pageId?: string;
96
+ pageName?: string;
97
+ }): ButtonForTranslation[];
98
+ /**
99
+ * Create a prompt for LLM translation with symbol preservation.
100
+ *
101
+ * This generates a structured prompt that instructs the LLM to translate
102
+ * while preserving symbol-to-word associations.
103
+ *
104
+ * @param buttons - Buttons to translate
105
+ * @param targetLanguage - Target language for translation
106
+ * @returns Prompt string for LLM
107
+ */
108
+ export declare function createTranslationPrompt(buttons: ButtonForTranslation[], targetLanguage: string): string;
109
+ /**
110
+ * Validate LLM translation results before applying.
111
+ *
112
+ * @param translations - LLM translation results
113
+ * @param originalButtonIds - Expected button IDs (optional, for validation)
114
+ * @param options - Validation options
115
+ * @throws Error if validation fails
116
+ */
117
+ export declare function validateTranslationResults(translations: LLMLTranslationResult[], originalButtonIds?: string[], options?: {
118
+ allowPartial?: boolean;
119
+ }): void;
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+ /**
3
+ * LLM-Based Translation with Symbol Preservation
4
+ *
5
+ * This module provides utilities for translating AAC files while preserving
6
+ * symbol-to-word associations across different formats (gridset, OBF, Snap, etc.).
7
+ *
8
+ * The key insight: Different AAC formats have different internal structures,
9
+ * but they all share common concepts:
10
+ * - Buttons with labels and messages
11
+ * - Symbols attached to specific words
12
+ * - Need to preserve symbol positions during translation
13
+ *
14
+ * This module provides a format-agnostic way to:
15
+ * 1. Extract symbol information for LLM processing
16
+ * 2. Apply LLM translations with preserved symbols
17
+ *
18
+ * Usage:
19
+ * 1. Processor extracts buttons and calls extractSymbolsForLLM()
20
+ * 2. LLM translates and returns aligned symbols
21
+ * 3. Processor calls processLLMTranslations() to apply results
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.normalizeButtonForTranslation = normalizeButtonForTranslation;
25
+ exports.extractSymbolsFromButton = extractSymbolsFromButton;
26
+ exports.extractAllButtonsForTranslation = extractAllButtonsForTranslation;
27
+ exports.createTranslationPrompt = createTranslationPrompt;
28
+ exports.validateTranslationResults = validateTranslationResults;
29
+ /**
30
+ * Extract symbols from a button for LLM-based translation.
31
+ *
32
+ * This is a format-agnostic helper that processors can use to normalize
33
+ * their button data into a common format for LLM processing.
34
+ *
35
+ * @param buttonId - Unique identifier for the button
36
+ * @param label - Button label text
37
+ * @param message - Button message/speak text
38
+ * @param symbols - Array of symbols from the button
39
+ * @param context - Optional page context
40
+ * @returns Normalized button data for translation
41
+ */
42
+ function normalizeButtonForTranslation(buttonId, label, message, symbols, context) {
43
+ return {
44
+ buttonId,
45
+ label,
46
+ message,
47
+ textToTranslate: message || label, // Translate message if present, otherwise label
48
+ symbols,
49
+ ...context,
50
+ };
51
+ }
52
+ /**
53
+ * Extract symbols from various button formats.
54
+ *
55
+ * This helper handles different ways symbols might be stored in button data:
56
+ * - semanticAction.richText.symbols (gridset format)
57
+ * - symbolLibrary + symbolPath fields
58
+ * - image field with [library]path format
59
+ *
60
+ * @param button - Button object from any AAC format
61
+ * @returns Array of symbol info, or undefined if no symbols
62
+ */
63
+ function extractSymbolsFromButton(button) {
64
+ const symbols = [];
65
+ // Method 1: Check for semanticAction.richText.symbols (gridset format)
66
+ if (button.semanticAction?.richText?.symbols) {
67
+ const richTextSymbols = button.semanticAction.richText.symbols;
68
+ if (Array.isArray(richTextSymbols) && richTextSymbols.length > 0) {
69
+ symbols.push(...richTextSymbols);
70
+ return symbols;
71
+ }
72
+ }
73
+ // Determine the text to attach symbol to
74
+ const text = button.label || button.message || '';
75
+ if (!text) {
76
+ return undefined;
77
+ }
78
+ // Method 2: Check for symbolLibrary + symbolPath fields
79
+ if (button.symbolLibrary && button.symbolPath) {
80
+ symbols.push({
81
+ text,
82
+ image: `[${button.symbolLibrary}]${button.symbolPath}`,
83
+ symbolLibrary: button.symbolLibrary,
84
+ symbolPath: button.symbolPath,
85
+ });
86
+ return symbols;
87
+ }
88
+ // Method 3: Check if image field contains a symbol reference
89
+ if (button.image && typeof button.image === 'string' && button.image.startsWith('[')) {
90
+ symbols.push({
91
+ text,
92
+ image: button.image,
93
+ });
94
+ return symbols;
95
+ }
96
+ // No symbols found
97
+ return undefined;
98
+ }
99
+ /**
100
+ * Extract all buttons from a file for LLM translation.
101
+ *
102
+ * This is a convenience method that processors can use to extract all
103
+ * translatable buttons with their symbols in a format-agnostic way.
104
+ *
105
+ * @param buttons - Array of button objects from any AAC format
106
+ * @param contextFn - Optional function to provide page context for each button
107
+ * @returns Array of normalized button data ready for LLM translation
108
+ */
109
+ function extractAllButtonsForTranslation(buttons, contextFn) {
110
+ const results = [];
111
+ for (const button of buttons) {
112
+ if (!button)
113
+ continue;
114
+ const buttonId = (button.id || button.buttonId || `button_${results.length}`);
115
+ const label = (button.label || '');
116
+ const message = (button.message || '');
117
+ const symbols = extractSymbolsFromButton(button);
118
+ // Only include buttons that have text to translate
119
+ if (!label && !message)
120
+ continue;
121
+ const context = contextFn ? contextFn(button) : undefined;
122
+ results.push(normalizeButtonForTranslation(buttonId, label, message, symbols || [], context));
123
+ }
124
+ return results;
125
+ }
126
+ /**
127
+ * Create a prompt for LLM translation with symbol preservation.
128
+ *
129
+ * This generates a structured prompt that instructs the LLM to translate
130
+ * while preserving symbol-to-word associations.
131
+ *
132
+ * @param buttons - Buttons to translate
133
+ * @param targetLanguage - Target language for translation
134
+ * @returns Prompt string for LLM
135
+ */
136
+ function createTranslationPrompt(buttons, targetLanguage) {
137
+ const buttonsData = JSON.stringify(buttons, null, 2);
138
+ return `You are a translation assistant for AAC (Augmentative and Alternative Communication) systems.
139
+
140
+ Your task is to translate the following buttons to ${targetLanguage} while preserving symbol associations.
141
+
142
+ Each button has:
143
+ - label: The text shown on the button
144
+ - message: The text spoken when the button is activated
145
+ - textToTranslate: The actual text to translate (usually the message)
146
+ - symbols: Visual symbols attached to specific words
147
+
148
+ IMPORTANT: After translation, you MUST reattach symbols to the correct translated words based on MEANING, not position.
149
+
150
+ Example:
151
+ - Original: "I want apple" with apple symbol on "apple"
152
+ - Spanish: "Yo quiero manzana" with apple symbol on "manzana" (NOT "Yo" or "quiero")
153
+ - French: "Je veux une pomme" with apple symbol on "pomme"
154
+
155
+ The symbols array should contain the translated word that each symbol should be attached to.
156
+
157
+ Buttons to translate:
158
+ ${buttonsData}
159
+
160
+ Return ONLY a JSON array with this exact structure:
161
+ [
162
+ {
163
+ "buttonId": "...",
164
+ "translatedLabel": "...",
165
+ "translatedMessage": "...",
166
+ "symbols": [
167
+ {"text": "translated_word", "image": "[library]path"}
168
+ ]
169
+ }
170
+ ]
171
+
172
+ Ensure all symbol image references are preserved exactly as provided.`;
173
+ }
174
+ /**
175
+ * Validate LLM translation results before applying.
176
+ *
177
+ * @param translations - LLM translation results
178
+ * @param originalButtonIds - Expected button IDs (optional, for validation)
179
+ * @param options - Validation options
180
+ * @throws Error if validation fails
181
+ */
182
+ function validateTranslationResults(translations, originalButtonIds, options) {
183
+ if (!Array.isArray(translations)) {
184
+ throw new Error('Translation results must be an array');
185
+ }
186
+ const translatedIds = new Set(translations.map((t) => t.buttonId));
187
+ // Check that all original buttons have translations (unless partial is allowed)
188
+ if (originalButtonIds && !options?.allowPartial) {
189
+ for (const id of originalButtonIds) {
190
+ if (!translatedIds.has(id)) {
191
+ throw new Error(`Missing translation for button: ${id}`);
192
+ }
193
+ }
194
+ }
195
+ // Check each translation has required fields
196
+ for (const trans of translations) {
197
+ if (!trans.buttonId) {
198
+ throw new Error('Translation missing buttonId');
199
+ }
200
+ if (!trans.translatedMessage && !trans.translatedLabel) {
201
+ throw new Error(`Translation for ${trans.buttonId} has no translated text`);
202
+ }
203
+ }
204
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Validation Namespace
3
+ *
4
+ * All validation functionality for AAC processors.
5
+ * Provides consistent validation across all supported formats.
6
+ */
7
+ export { ValidationError, ValidationCheck, ValidationResult, ValidationOptions, ValidationRule, } from './validation/validationTypes';
8
+ export { BaseValidator } from './validation/baseValidator';
9
+ export { ObfValidator } from './validation/obfValidator';
10
+ export { GridsetValidator } from './validation/gridsetValidator';
11
+ export { SnapValidator } from './validation/snapValidator';
12
+ export { TouchChatValidator } from './validation/touchChatValidator';
13
+ export { getValidatorForFormat, getValidatorForFile } from './validation/index';
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * Validation Namespace
4
+ *
5
+ * All validation functionality for AAC processors.
6
+ * Provides consistent validation across all supported formats.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.getValidatorForFile = exports.getValidatorForFormat = exports.TouchChatValidator = exports.SnapValidator = exports.GridsetValidator = exports.ObfValidator = exports.BaseValidator = exports.ValidationError = void 0;
10
+ // Validation types and interfaces
11
+ var validationTypes_1 = require("./validation/validationTypes");
12
+ Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return validationTypes_1.ValidationError; } });
13
+ // Base validator
14
+ var baseValidator_1 = require("./validation/baseValidator");
15
+ Object.defineProperty(exports, "BaseValidator", { enumerable: true, get: function () { return baseValidator_1.BaseValidator; } });
16
+ // Format-specific validators
17
+ var obfValidator_1 = require("./validation/obfValidator");
18
+ Object.defineProperty(exports, "ObfValidator", { enumerable: true, get: function () { return obfValidator_1.ObfValidator; } });
19
+ var gridsetValidator_1 = require("./validation/gridsetValidator");
20
+ Object.defineProperty(exports, "GridsetValidator", { enumerable: true, get: function () { return gridsetValidator_1.GridsetValidator; } });
21
+ var snapValidator_1 = require("./validation/snapValidator");
22
+ Object.defineProperty(exports, "SnapValidator", { enumerable: true, get: function () { return snapValidator_1.SnapValidator; } });
23
+ var touchChatValidator_1 = require("./validation/touchChatValidator");
24
+ Object.defineProperty(exports, "TouchChatValidator", { enumerable: true, get: function () { return touchChatValidator_1.TouchChatValidator; } });
25
+ // Validator factory functions
26
+ var index_1 = require("./validation/index");
27
+ Object.defineProperty(exports, "getValidatorForFormat", { enumerable: true, get: function () { return index_1.getValidatorForFormat; } });
28
+ Object.defineProperty(exports, "getValidatorForFile", { enumerable: true, get: function () { return index_1.getValidatorForFile; } });
package/package.json CHANGED
@@ -1,9 +1,63 @@
1
1
  {
2
2
  "name": "@willwade/aac-processors",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "A comprehensive TypeScript library for processing AAC (Augmentative and Alternative Communication) file formats with translation support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./gridset": {
13
+ "types": "./dist/gridset.d.ts",
14
+ "default": "./dist/gridset.js"
15
+ },
16
+ "./snap": {
17
+ "types": "./dist/snap.d.ts",
18
+ "default": "./dist/snap.js"
19
+ },
20
+ "./obf": {
21
+ "types": "./dist/obf.d.ts",
22
+ "default": "./dist/obf.js"
23
+ },
24
+ "./obfset": {
25
+ "types": "./dist/obfset.d.ts",
26
+ "default": "./dist/obfset.js"
27
+ },
28
+ "./touchchat": {
29
+ "types": "./dist/touchchat.d.ts",
30
+ "default": "./dist/touchchat.js"
31
+ },
32
+ "./dot": {
33
+ "types": "./dist/dot.d.ts",
34
+ "default": "./dist/dot.js"
35
+ },
36
+ "./excel": {
37
+ "types": "./dist/excel.d.ts",
38
+ "default": "./dist/excel.js"
39
+ },
40
+ "./opml": {
41
+ "types": "./dist/opml.d.ts",
42
+ "default": "./dist/opml.js"
43
+ },
44
+ "./applePanels": {
45
+ "types": "./dist/applePanels.d.ts",
46
+ "default": "./dist/applePanels.js"
47
+ },
48
+ "./astericsGrid": {
49
+ "types": "./dist/astericsGrid.d.ts",
50
+ "default": "./dist/astericsGrid.js"
51
+ },
52
+ "./translation": {
53
+ "types": "./dist/translation.d.ts",
54
+ "default": "./dist/translation.js"
55
+ },
56
+ "./validation": {
57
+ "types": "./dist/validation.d.ts",
58
+ "default": "./dist/validation.js"
59
+ }
60
+ },
7
61
  "files": [
8
62
  "dist/**/*",
9
63
  "docs/**/*",
@@ -69,8 +123,8 @@
69
123
  },
70
124
  "homepage": "https://github.com/willwade/AACProcessors-nodejs#readme",
71
125
  "engines": {
72
- "node": ">=16.0.0",
73
- "npm": ">=8.0.0"
126
+ "node": ">=20.0.0",
127
+ "npm": ">=9.0.0"
74
128
  },
75
129
  "devDependencies": {
76
130
  "@types/adm-zip": "^0.5.7",
@@ -96,7 +150,7 @@
96
150
  "@types/xml2js": "^0.4.14",
97
151
  "adm-zip": "^0.5.16",
98
152
  "axios": "^1.11.0",
99
- "better-sqlite3": "^11.9.1",
153
+ "better-sqlite3": "^12.5.0",
100
154
  "commander": "^13.1.0",
101
155
  "exceljs": "^4.4.0",
102
156
  "fast-xml-parser": "^5.2.0",
@@ -1,69 +0,0 @@
1
- import { AACPage, AACTree } from '../core/treeStructure';
2
- export interface ScreenshotCell {
3
- text: string;
4
- row: number;
5
- col: number;
6
- isCategory?: boolean;
7
- isNavigation?: boolean;
8
- isEmpty?: boolean;
9
- imageUrl?: string;
10
- }
11
- export interface ScreenshotGrid {
12
- rows: number;
13
- cols: number;
14
- cells: ScreenshotCell[];
15
- categories: string[];
16
- metadata?: {
17
- timestamp?: string;
18
- battery?: string;
19
- date?: string;
20
- };
21
- }
22
- export interface ScreenshotPage {
23
- filename: string;
24
- grid: ScreenshotGrid;
25
- extractedAt: Date;
26
- pageName?: string;
27
- parentPath?: string;
28
- pageTitle?: string;
29
- }
30
- export interface PageHierarchy {
31
- [pageId: string]: {
32
- page: ScreenshotPage;
33
- children: string[];
34
- parent?: string;
35
- };
36
- }
37
- export interface ScreenshotConversionOptions {
38
- includeEmptyCells: boolean;
39
- generateIds: boolean;
40
- targetPlatform?: 'grid3' | 'asterics' | 'snap' | 'touchchat';
41
- language: string;
42
- fallbackCategory: string;
43
- filenameDelimiter?: string;
44
- }
45
- export declare class ScreenshotConverter {
46
- private static defaultOptions;
47
- /**
48
- * Parse filename to extract page hierarchy and names
49
- * Examples:
50
- * - "Home.png" → pageName: "Home", parentPath: ""
51
- * - "Home->Fragen.png" → pageName: "Fragen", parentPath: "Home"
52
- * - "Home->Settings->Profile.jpg" → pageName: "Profile", parentPath: "Home->Settings"
53
- */
54
- static parseFilename(filename: string, delimiter?: string): {
55
- pageName: string;
56
- parentPath: string;
57
- };
58
- /**
59
- * Build page hierarchy from an array of screenshots
60
- */
61
- static buildPageHierarchy(screenshots: ScreenshotPage[]): PageHierarchy;
62
- static parseOCRText(ocrResult: string): ScreenshotGrid;
63
- private static isCategoryToken;
64
- private static isNavigationToken;
65
- static convertToAACPage(screenshotPage: ScreenshotPage, pageHierarchy?: PageHierarchy, options?: Partial<ScreenshotConversionOptions>): AACPage;
66
- private static createSemanticAction;
67
- static convertToAACTree(screenshotPages: ScreenshotPage[], options?: Partial<ScreenshotConversionOptions>): AACTree;
68
- private static sanitizePageId;
69
- }