Skip to content

Commit 93ccd56

Browse files
committed
fix obf correct format
Added locale/description/image/sound metadata to AACPage so boards can carry OBF-required fields through the tree abstraction (src/core/treeStructure.ts Reworked ObfProcessor to fully honor the OBF 0.1 schema: introduced the open-board-0.1 constant, richer ObfBoard/ObfGrid typings, parsing that can rebuild grids from the grid.order matrix, plus helpers that emit format/locale/description/grid/images/sounds (and derived box_ids) whenever a tree is saved Added a regression test that asserts saved boards include the new metadata and grid layout so invalid exports are caught quickly lint fixed after that
1 parent 1909321 commit 93ccd56

10 files changed

Lines changed: 561 additions & 268 deletions

src/cli/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22
import { program } from 'commander';
33
import { prettyPrintTree } from './prettyPrint';
4-
import { analyze, getProcessor } from '../core/analyze';
4+
import { getProcessor } from '../core/analyze';
55
import { ProcessorOptions } from '../core/baseProcessor';
66
import path from 'path';
77
import fs from 'fs';
@@ -192,7 +192,7 @@ program
192192
.option('--no-exclude-system', "Don't exclude system buttons (Delete, Clear, etc.)")
193193
.option('--exclude-buttons <list>', 'Comma-separated list of button labels/terms to exclude')
194194
.action(
195-
(
195+
async (
196196
input: string,
197197
output: string,
198198
options: {
@@ -221,7 +221,7 @@ program
221221

222222
// Save using output format with same filtering options
223223
const outputProcessor = getProcessor(options.format, filteringOptions);
224-
outputProcessor.saveFromTree(tree, output);
224+
await outputProcessor.saveFromTree(tree, output);
225225

226226
// Show filtering summary
227227
let filteringSummary = '';

src/core/analyze.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { ExcelProcessor } from '../processors/excelProcessor';
99
import { ApplePanelsProcessor } from '../processors/applePanelsProcessor';
1010
import { AACTree } from './treeStructure';
1111
import { BaseProcessor, ProcessorOptions } from './baseProcessor';
12-
import fs from 'fs';
1312

1413
export function getProcessor(format: string, options?: ProcessorOptions): BaseProcessor {
1514
const normalizedFormat = (format || '').toLowerCase();
@@ -44,7 +43,7 @@ export function getProcessor(format: string, options?: ProcessorOptions): BasePr
4443
}
4544
}
4645

47-
export function analyze(file: string, format: string) {
46+
export function analyze(file: string, format: string): { tree: AACTree } {
4847
const processor = getProcessor(format);
4948
const tree = processor.loadIntoTree(file);
5049
return { tree };

src/core/baseProcessor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AACTree, AACButton, AACSemanticCategory, AACSemanticIntent } from './treeStructure';
1+
import { AACTree, AACButton, AACSemanticCategory } from './treeStructure';
22
import { StringCasing, detectCasing, isNumericOrEmpty } from './stringCasing';
33

44
// Configuration options for processors

src/core/treeStructure.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ export class AACPage implements IAACPage {
309309
buttons: AACButton[];
310310
parentId: string | null;
311311
style?: AACStyle;
312+
locale?: string;
313+
descriptionHtml?: string;
314+
images?: any[];
315+
sounds?: any[];
312316

313317
constructor({
314318
id,
@@ -317,13 +321,21 @@ export class AACPage implements IAACPage {
317321
buttons = [],
318322
parentId = null,
319323
style,
324+
locale,
325+
descriptionHtml,
326+
images,
327+
sounds,
320328
}: {
321329
id: string;
322330
name?: string;
323331
grid?: Array<Array<AACButton | null>> | { columns: number; rows: number };
324332
buttons?: AACButton[];
325333
parentId?: string | null;
326334
style?: AACStyle;
335+
locale?: string;
336+
descriptionHtml?: string;
337+
images?: any[];
338+
sounds?: any[];
327339
}) {
328340
this.id = id;
329341
this.name = name;
@@ -339,6 +351,10 @@ export class AACPage implements IAACPage {
339351
this.buttons = buttons;
340352
this.parentId = parentId;
341353
this.style = style;
354+
this.locale = locale;
355+
this.descriptionHtml = descriptionHtml;
356+
this.images = images;
357+
this.sounds = sounds;
342358
}
343359

344360
addButton(button: AACButton): void {

0 commit comments

Comments
 (0)