Skip to content

Commit 780f1f5

Browse files
committed
More async patches, docs updating , JSDoc updating
1 parent d933c00 commit 780f1f5

10 files changed

Lines changed: 31 additions & 31 deletions

File tree

src/cli/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ program
559559
let care = undefined;
560560
if (options.care) {
561561
const comparison = new ComparisonAnalyzer();
562-
care = comparison.compare(metrics, metrics, {
562+
care = await comparison.compare(metrics, metrics, {
563563
includeSentences: true,
564564
usePrediction: !!options.usePrediction,
565565
scanningConfig,

src/processors/excelProcessor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class ExcelProcessor extends BaseProcessor {
2020
/**
2121
* Extract all text content from an Excel file
2222
* @param filePathOrBuffer - Path to Excel file or Buffer containing Excel data
23-
* @returns Array of all text content found in the Excel file
23+
* @returns Promise resolving to all text content found in the Excel file
2424
*/
2525
async extractTexts(_filePathOrBuffer: ProcessorInput): Promise<string[]> {
2626
console.warn('ExcelProcessor.extractTexts is not implemented yet.');
@@ -30,7 +30,7 @@ export class ExcelProcessor extends BaseProcessor {
3030
/**
3131
* Load Excel file into AACTree structure
3232
* @param filePathOrBuffer - Path to Excel file or Buffer containing Excel data
33-
* @returns AACTree representation of the Excel file
33+
* @returns Promise resolving to an AACTree representation of the Excel file
3434
*/
3535
async loadIntoTree(_filePathOrBuffer: ProcessorInput): Promise<AACTree> {
3636
console.warn('ExcelProcessor.loadIntoTree is not implemented yet.');
@@ -44,7 +44,7 @@ export class ExcelProcessor extends BaseProcessor {
4444
* @param filePathOrBuffer - Path to Excel file or Buffer containing Excel data
4545
* @param translations - Map of original text to translated text
4646
* @param outputPath - Path where translated Excel file should be saved
47-
* @returns Buffer containing the translated Excel file
47+
* @returns Promise resolving to a buffer containing the translated Excel file
4848
*/
4949
async processTexts(
5050
_filePathOrBuffer: ProcessorInput,

src/processors/gridsetProcessor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,7 +1964,7 @@ class GridsetProcessor extends BaseProcessor {
19641964
* This method uses shared translation utilities that work across all AAC formats.
19651965
*
19661966
* @param filePathOrBuffer - Path to gridset file or buffer
1967-
* @returns Array of symbol information for LLM processing
1967+
* @returns Promise resolving to symbol information for LLM processing
19681968
*/
19691969
async extractSymbolsForLLM(filePathOrBuffer: string | Buffer): Promise<ButtonForTranslation[]> {
19701970
const tree = await this.loadIntoTree(filePathOrBuffer);
@@ -1997,7 +1997,7 @@ class GridsetProcessor extends BaseProcessor {
19971997
* @param llmTranslations - Array of LLM translations with symbol info
19981998
* @param outputPath - Where to save the translated gridset
19991999
* @param options - Translation options (e.g., allowPartial for testing)
2000-
* @returns Buffer of the translated gridset
2000+
* @returns Promise resolving to a buffer of the translated gridset
20012001
*/
20022002
async processLLMTranslations(
20032003
filePathOrBuffer: string | Buffer,

src/processors/obfProcessor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ class ObfProcessor extends BaseProcessor {
778778
* This method uses shared translation utilities that work across all AAC formats.
779779
*
780780
* @param filePathOrBuffer - Path to OBF/OBZ file or buffer
781-
* @returns Array of symbol information for LLM processing
781+
* @returns Promise resolving to symbol information for LLM processing
782782
*/
783783
async extractSymbolsForLLM(filePathOrBuffer: ProcessorInput): Promise<ButtonForTranslation[]> {
784784
const tree = await this.loadIntoTree(filePathOrBuffer);
@@ -811,7 +811,7 @@ class ObfProcessor extends BaseProcessor {
811811
* @param llmTranslations - Array of LLM translations with symbol info
812812
* @param outputPath - Where to save the translated OBF/OBZ file
813813
* @param options - Translation options (e.g., allowPartial for testing)
814-
* @returns Buffer of the translated OBF/OBZ file
814+
* @returns Promise resolving to a buffer of the translated OBF/OBZ file
815815
*/
816816
async processLLMTranslations(
817817
filePathOrBuffer: ProcessorInput,

src/processors/snapProcessor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,7 @@ class SnapProcessor extends BaseProcessor {
14421442
* Get available PageLayouts for a Snap file
14431443
* Useful for UI components that want to let users select layout size
14441444
* @param filePath - Path to the Snap file
1445-
* @returns Array of available PageLayouts with their dimensions
1445+
* @returns Promise resolving to available PageLayouts with their dimensions
14461446
*/
14471447
async getAvailablePageLayouts(filePath: string): Promise<PageLayoutInfo[]> {
14481448
const { writeBinaryToPath, removePath, pathExists, join } = this.options.fileAdapter;

src/processors/touchchatProcessor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ class TouchChatProcessor extends BaseProcessor {
13561356
* This method uses shared translation utilities that work across all AAC formats.
13571357
*
13581358
* @param filePathOrBuffer - Path to TouchChat .ce file or buffer
1359-
* @returns Array of symbol information for LLM processing
1359+
* @returns Promise resolving to symbol information for LLM processing
13601360
*/
13611361
async extractSymbolsForLLM(filePathOrBuffer: string | Buffer): Promise<ButtonForTranslation[]> {
13621362
const tree = await this.loadIntoTree(filePathOrBuffer);
@@ -1389,7 +1389,7 @@ class TouchChatProcessor extends BaseProcessor {
13891389
* @param llmTranslations - Array of LLM translations with symbol info
13901390
* @param outputPath - Where to save the translated TouchChat file
13911391
* @param options - Translation options (e.g., allowPartial for testing)
1392-
* @returns Buffer of the translated TouchChat file
1392+
* @returns Promise resolving to a buffer of the translated TouchChat file
13931393
*/
13941394
async processLLMTranslations(
13951395
filePathOrBuffer: string | Uint8Array,

src/utilities/analytics/docs/AAC_METRICS_GUIDE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The `MetricsCalculator` is format-agnostic. You can use any processor to load a
4545
import { ObfsetProcessor, Analytics } from '@willwade/aac-processors';
4646

4747
const processor = new ObfsetProcessor();
48-
const tree = processor.loadIntoTree('set.obfset');
48+
const tree = await processor.loadIntoTree('set.obfset');
4949
const result = new Analytics.MetricsCalculator().analyze(tree);
5050
```
5151

@@ -54,7 +54,7 @@ const result = new Analytics.MetricsCalculator().analyze(tree);
5454
import { GridsetProcessor, Analytics } from '@willwade/aac-processors';
5555

5656
const processor = new GridsetProcessor();
57-
const tree = processor.loadIntoTree('my_file.gridset');
57+
const tree = await processor.loadIntoTree('my_file.gridset');
5858
const result = new Analytics.MetricsCalculator().analyze(tree);
5959
```
6060

@@ -63,7 +63,7 @@ const result = new Analytics.MetricsCalculator().analyze(tree);
6363
import { SnapProcessor, Analytics } from '@willwade/aac-processors';
6464

6565
const processor = new SnapProcessor();
66-
const tree = processor.loadIntoTree('SnapBackup.pageSet');
66+
const tree = await processor.loadIntoTree('SnapBackup.pageSet');
6767
const result = new Analytics.MetricsCalculator().analyze(tree);
6868
```
6969

@@ -72,7 +72,7 @@ const result = new Analytics.MetricsCalculator().analyze(tree);
7272
import { TouchChatProcessor, Analytics } from '@willwade/aac-processors';
7373

7474
const processor = new TouchChatProcessor();
75-
const tree = processor.loadIntoTree('TouchChatBackup.zip');
75+
const tree = await processor.loadIntoTree('TouchChatBackup.zip');
7676
const result = new Analytics.MetricsCalculator().analyze(tree);
7777
```
7878

src/utilities/analytics/docs/SCANNING_METRICS_GUIDE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Grid 3 stores scan block information directly on each button in the XML:
100100
import { GridsetProcessor, Analytics } from '@willwade/aac-processors';
101101

102102
const processor = new GridsetProcessor();
103-
const tree = processor.loadIntoTree('my_file.gridset');
103+
const tree = await processor.loadIntoTree('my_file.gridset');
104104

105105
// Scan blocks are automatically extracted from @ScanBlock attribute
106106
const result = new Analytics.MetricsCalculator().analyze(tree);
@@ -157,7 +157,7 @@ import { SnapProcessor, Analytics } from '@willwade/aac-processors';
157157

158158
// Option 1: Default - prefer largest layout with scanning enabled
159159
const processor = new SnapProcessor();
160-
const tree = processor.loadIntoTree('Core First Scanning.sps');
160+
const tree = await processor.loadIntoTree('Core First Scanning.sps');
161161

162162
// Option 2: Specify layout preference
163163
const processor = new SnapProcessor(null, {
@@ -233,7 +233,7 @@ console.log('Core Words scan blocks:', scanBlockCounts);
233233
import { TouchChatProcessor, Analytics } from '@willwade/aac-processors';
234234

235235
const processor = new TouchChatProcessor();
236-
const tree = processor.loadIntoTree('TouchChatBackup.zip');
236+
const tree = await processor.loadIntoTree('TouchChatBackup.zip');
237237

238238
// All buttons have scanBlock = 1 (linear scanning)
239239
// Or scanBlock = undefined (no grouping)
@@ -298,7 +298,7 @@ import { SnapProcessor, Analytics } from '@willwade/aac-processors';
298298
const processor = new SnapProcessor(null, {
299299
pageLayoutPreference: 'scanning' // Use scanning layout
300300
});
301-
const tree = processor.loadIntoTree('Core First Scanning.sps');
301+
const tree = await processor.loadIntoTree('Core First Scanning.sps');
302302

303303
// Set root page for multi-vocab pagesets
304304
tree.rootId = '0219f681-1069-4296-be42-790ee828a7b4'; // Core Words

src/utilities/analytics/docs/VOCABULARY_ANALYSIS_GUIDE.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ import { ObfsetProcessor, Analytics } from '@willwade/aac-processors';
2424

2525
// Load board set
2626
const processor = new ObfsetProcessor();
27-
const tree = processor.loadIntoTree('path/to/boardset.obfset');
27+
const tree = await processor.loadIntoTree('path/to/boardset.obfset');
2828

2929
// Calculate metrics
3030
const metrics = new Analytics.MetricsCalculator().analyze(tree);
3131

3232
// Analyze vocabulary coverage
3333
const vocabAnalyzer = new Analytics.VocabularyAnalyzer();
34-
const analysis = vocabAnalyzer.analyze(metrics);
34+
const analysis = await vocabAnalyzer.analyze(metrics);
3535

3636
console.log("Core Coverage:", analysis.core_coverage);
3737
console.log("High Effort Words:", analysis.high_effort_words);
@@ -132,7 +132,7 @@ const compareResult = calculator.analyze(compareTree);
132132

133133
// Compare
134134
const comparisonAnalyzer = new Analytics.ComparisonAnalyzer();
135-
const comparison = comparisonAnalyzer.compare(targetResult, compareResult, {
135+
const comparison = await comparisonAnalyzer.compare(targetResult, compareResult, {
136136
includeSentences: true,
137137
});
138138

@@ -230,12 +230,12 @@ All processors can now use these analysis features:
230230
import { ObfProcessor, Analytics } from '@willwade/aac-processors';
231231

232232
const processor = new ObfProcessor();
233-
const tree = processor.loadIntoTree('my-board.obf');
233+
const tree = await processor.loadIntoTree('my-board.obf');
234234

235235
const metrics = new Analytics.MetricsCalculator().analyze(tree);
236236

237237
const vocabAnalyzer = new Analytics.VocabularyAnalyzer();
238-
const coverage = vocabAnalyzer.analyze(metrics);
238+
const coverage = await vocabAnalyzer.analyze(metrics);
239239

240240
// Identify gaps in core vocabulary
241241
Object.entries(coverage.core_coverage).forEach(([id, data]) => {

src/utilities/translation/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ interface LLMLTranslationResult {
7676
import { extractAllButtonsForTranslation } from './translation/translationProcessor';
7777

7878
// For gridset format
79-
extractSymbolsForLLM(filePath): ButtonForTranslation[] {
80-
const tree = this.loadIntoTree(filePath);
79+
async extractSymbolsForLLM(filePath): Promise<ButtonForTranslation[]> {
80+
const tree = await this.loadIntoTree(filePath);
8181

8282
const allButtons: any[] = [];
8383
Object.values(tree.pages).forEach((page) => {
@@ -132,8 +132,8 @@ processLLMTranslations(
132132
filePath: string | Buffer,
133133
llmTranslations: LLMLTranslationResult[],
134134
outputPath: string
135-
): Buffer {
136-
const tree = this.loadIntoTree(filePath);
135+
): Promise<Buffer> {
136+
const tree = await this.loadIntoTree(filePath);
137137

138138
// Validate using shared utility
139139
const buttonIds = Object.values(tree.pages).flatMap((page) =>
@@ -176,7 +176,7 @@ processLLMTranslations(
176176
});
177177

178178
// Save and return
179-
this.saveFromTree(tree, outputPath);
179+
await this.saveFromTree(tree, outputPath);
180180
return fs.readFileSync(outputPath);
181181
}
182182
```
@@ -202,8 +202,8 @@ extractSymbolsForLLM(filePath: string | Buffer): ButtonForTranslation[] {
202202

203203
```typescript
204204
// snapProcessor.ts
205-
extractSymbolsForLLM(filePath: string | Buffer): ButtonForTranslation[] {
206-
const tree = this.loadIntoTree(filePath);
205+
async extractSymbolsForLLM(filePath: string | Buffer): Promise<ButtonForTranslation[]> {
206+
const tree = await this.loadIntoTree(filePath);
207207
const allButtons: any[] = [];
208208

209209
Object.values(tree.pages).forEach((page) => {

0 commit comments

Comments
 (0)