@willwade/aac-processors 0.0.3 → 0.0.4

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.
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Grid3 Wordlist Helpers
3
+ *
4
+ * This module provides utilities for creating and extracting wordlists
5
+ * from Grid3 gridsets. Wordlists are Grid3-specific data structures
6
+ * used for dynamic vocabulary content.
7
+ *
8
+ * Note: Wordlists are only supported in Grid3 format. Other AAC formats
9
+ * do not have equivalent wordlist functionality.
10
+ */
11
+ /**
12
+ * Represents a single item in a wordlist
13
+ */
14
+ export interface WordListItem {
15
+ /** The text/word/phrase */
16
+ text: string;
17
+ /** Optional image reference (e.g., "[WIDGIT]path/to/symbol.emf") */
18
+ image?: string;
19
+ /** Part of speech category (e.g., "Noun", "Verb", "Unknown") */
20
+ partOfSpeech?: string;
21
+ }
22
+ /**
23
+ * Represents a complete wordlist
24
+ */
25
+ export interface WordList {
26
+ /** Array of wordlist items */
27
+ items: WordListItem[];
28
+ }
29
+ /**
30
+ * Creates a WordList object from an array of words/phrases or a dictionary
31
+ *
32
+ * @param input - Either an array of strings or an object with text/image/partOfSpeech properties
33
+ * @returns A WordList object ready to be used in Grid3
34
+ *
35
+ * @example
36
+ * // From simple array
37
+ * const wordlist = createWordlist(['hello', 'goodbye', 'thank you']);
38
+ *
39
+ * @example
40
+ * // From array of objects
41
+ * const wordlist = createWordlist([
42
+ * { text: 'hello', image: '[WIDGIT]greetings/hello.emf', partOfSpeech: 'Interjection' },
43
+ * { text: 'goodbye', image: '[WIDGIT]greetings/goodbye.emf', partOfSpeech: 'Interjection' }
44
+ * ]);
45
+ */
46
+ export declare function createWordlist(input: string[] | WordListItem[] | Record<string, string | WordListItem>): WordList;
47
+ /**
48
+ * Converts a WordList object to Grid3 XML format
49
+ *
50
+ * @param wordlist - The wordlist to convert
51
+ * @returns XML string representation
52
+ * @internal
53
+ */
54
+ export declare function wordlistToXml(wordlist: WordList): string;
55
+ /**
56
+ * Extracts all wordlists from a gridset buffer
57
+ *
58
+ * @param gridsetBuffer - The gridset file as a Buffer
59
+ * @returns Map of grid names to their wordlists (if they have any)
60
+ *
61
+ * @example
62
+ * const wordlists = extractWordlists(gridsetBuffer);
63
+ * wordlists.forEach((wordlist, gridName) => {
64
+ * console.log(`Grid "${gridName}" has ${wordlist.items.length} items`);
65
+ * });
66
+ */
67
+ export declare function extractWordlists(gridsetBuffer: Buffer): Map<string, WordList>;
68
+ /**
69
+ * Updates or adds a wordlist to a specific grid in a gridset
70
+ *
71
+ * @param gridsetBuffer - The gridset file as a Buffer
72
+ * @param gridName - The name of the grid to update (e.g., "Greetings")
73
+ * @param wordlist - The wordlist to add/update
74
+ * @returns Updated gridset as a Buffer
75
+ *
76
+ * @example
77
+ * const gridsetBuffer = fs.readFileSync('my-gridset.gridset');
78
+ * const newWordlist = createWordlist(['hello', 'hi', 'hey']);
79
+ * const updatedGridset = updateWordlist(gridsetBuffer, 'Greetings', newWordlist);
80
+ * fs.writeFileSync('updated-gridset.gridset', updatedGridset);
81
+ */
82
+ export declare function updateWordlist(gridsetBuffer: Buffer, gridName: string, wordlist: WordList): Buffer;
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+ /**
3
+ * Grid3 Wordlist Helpers
4
+ *
5
+ * This module provides utilities for creating and extracting wordlists
6
+ * from Grid3 gridsets. Wordlists are Grid3-specific data structures
7
+ * used for dynamic vocabulary content.
8
+ *
9
+ * Note: Wordlists are only supported in Grid3 format. Other AAC formats
10
+ * do not have equivalent wordlist functionality.
11
+ */
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.createWordlist = createWordlist;
17
+ exports.wordlistToXml = wordlistToXml;
18
+ exports.extractWordlists = extractWordlists;
19
+ exports.updateWordlist = updateWordlist;
20
+ const adm_zip_1 = __importDefault(require("adm-zip"));
21
+ const fast_xml_parser_1 = require("fast-xml-parser");
22
+ /**
23
+ * Creates a WordList object from an array of words/phrases or a dictionary
24
+ *
25
+ * @param input - Either an array of strings or an object with text/image/partOfSpeech properties
26
+ * @returns A WordList object ready to be used in Grid3
27
+ *
28
+ * @example
29
+ * // From simple array
30
+ * const wordlist = createWordlist(['hello', 'goodbye', 'thank you']);
31
+ *
32
+ * @example
33
+ * // From array of objects
34
+ * const wordlist = createWordlist([
35
+ * { text: 'hello', image: '[WIDGIT]greetings/hello.emf', partOfSpeech: 'Interjection' },
36
+ * { text: 'goodbye', image: '[WIDGIT]greetings/goodbye.emf', partOfSpeech: 'Interjection' }
37
+ * ]);
38
+ */
39
+ function createWordlist(input) {
40
+ let items = [];
41
+ if (Array.isArray(input)) {
42
+ // Handle array input
43
+ items = input.map((item) => {
44
+ if (typeof item === 'string') {
45
+ return { text: item };
46
+ }
47
+ return item;
48
+ });
49
+ }
50
+ else if (typeof input === 'object') {
51
+ // Handle dictionary/object input
52
+ items = Object.entries(input).map(([key, value]) => {
53
+ if (typeof value === 'string') {
54
+ return { text: value };
55
+ }
56
+ return value;
57
+ });
58
+ }
59
+ return { items };
60
+ }
61
+ /**
62
+ * Converts a WordList object to Grid3 XML format
63
+ *
64
+ * @param wordlist - The wordlist to convert
65
+ * @returns XML string representation
66
+ * @internal
67
+ */
68
+ function wordlistToXml(wordlist) {
69
+ const items = wordlist.items.map((item) => ({
70
+ WordListItem: {
71
+ Text: {
72
+ s: {
73
+ '@_Image': item.image || '',
74
+ r: item.text,
75
+ },
76
+ },
77
+ Image: item.image || '',
78
+ PartOfSpeech: item.partOfSpeech || 'Unknown',
79
+ },
80
+ }));
81
+ const wordlistData = {
82
+ WordList: {
83
+ Items: {
84
+ WordListItem: items.length === 1 ? items[0].WordListItem : items.map((i) => i.WordListItem),
85
+ },
86
+ },
87
+ };
88
+ const builder = new fast_xml_parser_1.XMLBuilder({
89
+ ignoreAttributes: false,
90
+ format: false,
91
+ suppressEmptyNode: false,
92
+ });
93
+ return builder.build(wordlistData);
94
+ }
95
+ /**
96
+ * Extracts all wordlists from a gridset buffer
97
+ *
98
+ * @param gridsetBuffer - The gridset file as a Buffer
99
+ * @returns Map of grid names to their wordlists (if they have any)
100
+ *
101
+ * @example
102
+ * const wordlists = extractWordlists(gridsetBuffer);
103
+ * wordlists.forEach((wordlist, gridName) => {
104
+ * console.log(`Grid "${gridName}" has ${wordlist.items.length} items`);
105
+ * });
106
+ */
107
+ function extractWordlists(gridsetBuffer) {
108
+ const wordlists = new Map();
109
+ const parser = new fast_xml_parser_1.XMLParser();
110
+ let zip;
111
+ try {
112
+ zip = new adm_zip_1.default(gridsetBuffer);
113
+ }
114
+ catch (error) {
115
+ throw new Error(`Invalid gridset buffer: ${error.message}`);
116
+ }
117
+ // Process each grid file
118
+ zip.getEntries().forEach((entry) => {
119
+ if (entry.entryName.startsWith('Grids/') && entry.entryName.endsWith('grid.xml')) {
120
+ try {
121
+ const xmlContent = entry.getData().toString('utf8');
122
+ const data = parser.parse(xmlContent);
123
+ const grid = data.Grid || data.grid;
124
+ if (!grid || !grid.WordList) {
125
+ return;
126
+ }
127
+ // Extract grid name from path (e.g., "Grids/MyGrid/grid.xml" -> "MyGrid")
128
+ const match = entry.entryName.match(/^Grids\/([^/]+)\//);
129
+ const gridName = match ? match[1] : entry.entryName;
130
+ // Parse wordlist items
131
+ const wordlistData = grid.WordList;
132
+ const itemsContainer = wordlistData.Items || wordlistData.items;
133
+ if (!itemsContainer) {
134
+ return;
135
+ }
136
+ const itemArray = Array.isArray(itemsContainer.WordListItem)
137
+ ? itemsContainer.WordListItem
138
+ : itemsContainer.WordListItem
139
+ ? [itemsContainer.WordListItem]
140
+ : [];
141
+ const items = itemArray.map((item) => ({
142
+ text: item.Text?.s?.r || item.text?.s?.r || '',
143
+ image: item.Image || item.image || undefined,
144
+ partOfSpeech: item.PartOfSpeech || item.partOfSpeech || 'Unknown',
145
+ }));
146
+ if (items.length > 0) {
147
+ wordlists.set(gridName, { items });
148
+ }
149
+ }
150
+ catch (error) {
151
+ // Skip grids with parsing errors
152
+ console.warn(`Failed to extract wordlist from ${entry.entryName}:`, error);
153
+ }
154
+ }
155
+ });
156
+ return wordlists;
157
+ }
158
+ /**
159
+ * Updates or adds a wordlist to a specific grid in a gridset
160
+ *
161
+ * @param gridsetBuffer - The gridset file as a Buffer
162
+ * @param gridName - The name of the grid to update (e.g., "Greetings")
163
+ * @param wordlist - The wordlist to add/update
164
+ * @returns Updated gridset as a Buffer
165
+ *
166
+ * @example
167
+ * const gridsetBuffer = fs.readFileSync('my-gridset.gridset');
168
+ * const newWordlist = createWordlist(['hello', 'hi', 'hey']);
169
+ * const updatedGridset = updateWordlist(gridsetBuffer, 'Greetings', newWordlist);
170
+ * fs.writeFileSync('updated-gridset.gridset', updatedGridset);
171
+ */
172
+ function updateWordlist(gridsetBuffer, gridName, wordlist) {
173
+ const parser = new fast_xml_parser_1.XMLParser();
174
+ const builder = new fast_xml_parser_1.XMLBuilder({
175
+ ignoreAttributes: false,
176
+ format: true,
177
+ indentBy: ' ',
178
+ suppressEmptyNode: false,
179
+ });
180
+ let zip;
181
+ try {
182
+ zip = new adm_zip_1.default(gridsetBuffer);
183
+ }
184
+ catch (error) {
185
+ throw new Error(`Invalid gridset buffer: ${error.message}`);
186
+ }
187
+ let found = false;
188
+ // Find and update the grid
189
+ zip.getEntries().forEach((entry) => {
190
+ if (entry.entryName.startsWith('Grids/') && entry.entryName.endsWith('grid.xml')) {
191
+ const match = entry.entryName.match(/^Grids\/([^/]+)\//);
192
+ const currentGridName = match ? match[1] : null;
193
+ if (currentGridName === gridName) {
194
+ try {
195
+ const xmlContent = entry.getData().toString('utf8');
196
+ const data = parser.parse(xmlContent);
197
+ const grid = data.Grid || data.grid;
198
+ if (!grid) {
199
+ return;
200
+ }
201
+ // Build the new wordlist XML structure
202
+ const items = wordlist.items.map((item) => ({
203
+ WordListItem: {
204
+ Text: {
205
+ s: {
206
+ '@_Image': item.image || '',
207
+ r: item.text,
208
+ },
209
+ },
210
+ Image: item.image || '',
211
+ PartOfSpeech: item.partOfSpeech || 'Unknown',
212
+ },
213
+ }));
214
+ grid.WordList = {
215
+ Items: {
216
+ WordListItem: items.length === 1 ? items[0].WordListItem : items.map((i) => i.WordListItem),
217
+ },
218
+ };
219
+ // Rebuild the XML
220
+ const updatedXml = builder.build(data);
221
+ zip.updateFile(entry, Buffer.from(updatedXml, 'utf8'));
222
+ found = true;
223
+ }
224
+ catch (error) {
225
+ throw new Error(`Failed to update wordlist in grid "${gridName}": ${error}`);
226
+ }
227
+ }
228
+ }
229
+ });
230
+ if (!found) {
231
+ throw new Error(`Grid "${gridName}" not found in gridset`);
232
+ }
233
+ return zip.toBuffer();
234
+ }
@@ -10,5 +10,6 @@ export { AstericsGridProcessor } from './astericsGridProcessor';
10
10
  export { getPageTokenImageMap, getAllowedImageEntries, openImage } from './gridset/helpers';
11
11
  export { getPageTokenImageMap as getGridsetPageTokenImageMap, getAllowedImageEntries as getGridsetAllowedImageEntries, openImage as openGridsetImage, } from './gridset/helpers';
12
12
  export { resolveGrid3CellImage } from './gridset/resolver';
13
+ export { createWordlist, extractWordlists, updateWordlist, wordlistToXml, type WordList, type WordListItem, } from './gridset/wordlistHelpers';
13
14
  export { getPageTokenImageMap as getSnapPageTokenImageMap, getAllowedImageEntries as getSnapAllowedImageEntries, openImage as openSnapImage, } from './snap/helpers';
14
15
  export { getPageTokenImageMap as getTouchChatPageTokenImageMap, getAllowedImageEntries as getTouchChatAllowedImageEntries, openImage as openTouchChatImage, } from './touchchat/helpers';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.openTouchChatImage = exports.getTouchChatAllowedImageEntries = exports.getTouchChatPageTokenImageMap = exports.openSnapImage = exports.getSnapAllowedImageEntries = exports.getSnapPageTokenImageMap = exports.resolveGrid3CellImage = exports.openGridsetImage = exports.getGridsetAllowedImageEntries = exports.getGridsetPageTokenImageMap = exports.openImage = exports.getAllowedImageEntries = exports.getPageTokenImageMap = exports.AstericsGridProcessor = exports.TouchChatProcessor = exports.SnapProcessor = exports.OpmlProcessor = exports.ObfProcessor = exports.GridsetProcessor = exports.ExcelProcessor = exports.DotProcessor = exports.ApplePanelsProcessor = void 0;
3
+ exports.openTouchChatImage = exports.getTouchChatAllowedImageEntries = exports.getTouchChatPageTokenImageMap = exports.openSnapImage = exports.getSnapAllowedImageEntries = exports.getSnapPageTokenImageMap = exports.wordlistToXml = exports.updateWordlist = exports.extractWordlists = exports.createWordlist = exports.resolveGrid3CellImage = exports.openGridsetImage = exports.getGridsetAllowedImageEntries = exports.getGridsetPageTokenImageMap = exports.openImage = exports.getAllowedImageEntries = exports.getPageTokenImageMap = exports.AstericsGridProcessor = exports.TouchChatProcessor = exports.SnapProcessor = exports.OpmlProcessor = exports.ObfProcessor = exports.GridsetProcessor = exports.ExcelProcessor = exports.DotProcessor = exports.ApplePanelsProcessor = void 0;
4
4
  var applePanelsProcessor_1 = require("./applePanelsProcessor");
5
5
  Object.defineProperty(exports, "ApplePanelsProcessor", { enumerable: true, get: function () { return applePanelsProcessor_1.ApplePanelsProcessor; } });
6
6
  var dotProcessor_1 = require("./dotProcessor");
@@ -30,6 +30,12 @@ Object.defineProperty(exports, "getGridsetAllowedImageEntries", { enumerable: tr
30
30
  Object.defineProperty(exports, "openGridsetImage", { enumerable: true, get: function () { return helpers_2.openImage; } });
31
31
  var resolver_1 = require("./gridset/resolver");
32
32
  Object.defineProperty(exports, "resolveGrid3CellImage", { enumerable: true, get: function () { return resolver_1.resolveGrid3CellImage; } });
33
+ // Gridset (Grid 3) wordlist helpers
34
+ var wordlistHelpers_1 = require("./gridset/wordlistHelpers");
35
+ Object.defineProperty(exports, "createWordlist", { enumerable: true, get: function () { return wordlistHelpers_1.createWordlist; } });
36
+ Object.defineProperty(exports, "extractWordlists", { enumerable: true, get: function () { return wordlistHelpers_1.extractWordlists; } });
37
+ Object.defineProperty(exports, "updateWordlist", { enumerable: true, get: function () { return wordlistHelpers_1.updateWordlist; } });
38
+ Object.defineProperty(exports, "wordlistToXml", { enumerable: true, get: function () { return wordlistHelpers_1.wordlistToXml; } });
33
39
  // Snap helpers (stubs)
34
40
  var helpers_3 = require("./snap/helpers");
35
41
  Object.defineProperty(exports, "getSnapPageTokenImageMap", { enumerable: true, get: function () { return helpers_3.getPageTokenImageMap; } });
@@ -1,31 +1,43 @@
1
- # AAC Processors Examples
1
+ # AAC Processors Example Pagesets
2
2
 
3
- This directory contains example scripts demonstrating various uses of the AAC Processors library.
3
+ This directory contains example AAC pagesets in various formats used for testing and demonstration purposes.
4
4
 
5
- ## Translation Demo
5
+ ## Available Pagesets
6
6
 
7
- Demonstrates how to translate AAC files between languages using various translation services.
7
+ ### Grid3 Format (.gridset)
8
+ - **example.gridset** - Main example pageset with multiple grids and wordlists
9
+ - **example-images.gridset** - Example pageset with embedded images
8
10
 
9
- ### Setup
11
+ ### Snap Format (.spb, .sps)
12
+ - **example.spb** - Snap pageset (binary format)
13
+ - **example.sps** - Snap pageset (alternative format)
10
14
 
11
- ```bash
12
- # Install example-specific dependencies
13
- cd examples
14
- npm install
15
+ ### TouchChat Format (.ce)
16
+ - **example.ce** - TouchChat pageset
15
17
 
16
- # Set up environment variables
17
- export AZURE_TRANSLATOR_KEY="your-key"
18
- export GOOGLE_TRANSLATE_KEY="your-key"
19
- ```
18
+ ### OBF/OBZ Format (.obf, .obz)
19
+ - **example.obf** - OBF pageset (JSON-based)
20
+ - **example.obz** - OBZ pageset (compressed)
20
21
 
21
- ### Usage
22
+ ### Asterics Grid Format (.grd)
23
+ - **example.grd** - Asterics Grid pageset
24
+ - **example2.grd** - Alternative Asterics Grid pageset
22
25
 
23
- ```bash
24
- # Basic usage
25
- node translate_demo.js ../path/to/input.gridset --endlang fr
26
+ ### DOT Format (.dot)
27
+ - **example.dot** - Simple DOT format pageset
28
+ - **communikate.dot** - Communikate DOT format pageset
26
29
 
27
- # With confidence checking
28
- node translate_demo.js ../path/to/input.gridset --endlang fr --enable-confidence-check
29
- ```
30
+ ### OPML Format (.opml)
31
+ - **example.opml** - OPML pageset
30
32
 
31
- Note: These examples are for demonstration purposes only and have their own dependencies separate from the main package.
33
+ ### Styled Output
34
+ - **styled-output/** - Directory containing example pagesets with styling applied
35
+
36
+ ## Usage
37
+
38
+ These pagesets are used by:
39
+ - Unit tests in the main test suite
40
+ - Demo scripts in the `scripts/` directory
41
+ - Integration examples
42
+
43
+ To run demo scripts that use these pagesets, see the [scripts/README.md](../scripts/README.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willwade/aac-processors",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
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",
package/examples/demo.js DELETED
@@ -1,143 +0,0 @@
1
- // AACProcessors Demo: Showcase all engines and features
2
- const path = require('path');
3
-
4
- // Import processors
5
- const { DotProcessor, OpmlProcessor, SnapProcessor, GridsetProcessor, TouchChatProcessor, ApplePanelsProcessor, ObfProcessor } = require('../dist/processors');
6
-
7
- // Optional: pretty printer
8
- let prettyPrint;
9
- try {
10
- prettyPrint = require('../dist/viewer/prettyPrint');
11
- } catch {}
12
-
13
- // Optional: symbol tools
14
- let symbolTools;
15
- try {
16
- symbolTools = require('../dist/optional/symbolTools');
17
- } catch {}
18
-
19
- // --- DotProcessor ---
20
- console.log('\n=== DOT Example ===');
21
- try {
22
- const dotFile = path.join(__dirname, 'example.dot');
23
- const dotProcessor = new DotProcessor();
24
- const dotTree = dotProcessor.loadIntoTree(dotFile);
25
- console.log('DOT tree:', dotTree);
26
- console.log('DOT texts:', dotProcessor.extractTexts ? dotProcessor.extractTexts(dotFile) : '(no extractTexts)');
27
- if (prettyPrint) prettyPrint.printTree(dotTree, { showNavigation: true });
28
- } catch (e) {
29
- console.warn('DOT demo error:', e.message);
30
- }
31
-
32
- // --- OPMLProcessor ---
33
- console.log('\n=== OPML Example ===');
34
- try {
35
- const opmlFile = path.join(__dirname, 'example.opml');
36
- const opmlProcessor = new OpmlProcessor();
37
- const opmlTree = opmlProcessor.loadIntoTree(opmlFile);
38
- console.log('OPML tree:', opmlTree);
39
- console.log('OPML texts:', opmlProcessor.extractTexts ? opmlProcessor.extractTexts(opmlFile) : '(no extractTexts)');
40
- if (prettyPrint) prettyPrint.printTree(opmlTree, { showNavigation: true });
41
- } catch (e) {
42
- console.warn('OPML demo error:', e.message);
43
- }
44
-
45
-
46
-
47
- // --- SnapProcessor (SPB) ---
48
- console.log('\n=== Snap Example (.spb) ===');
49
- try {
50
- const spbFile = path.join(__dirname, 'example.spb');
51
- const snapProcessor = new SnapProcessor();
52
- const snapTree = snapProcessor.loadIntoTree(spbFile);
53
- console.log('Snap tree (.spb):', snapTree);
54
- console.log('Snap texts (.spb):', snapProcessor.extractTexts(spbFile));
55
- if (prettyPrint) prettyPrint.printTree(snapTree, { showNavigation: true });
56
- } catch (e) {
57
- console.warn('Snap demo error (.spb):', e.message);
58
- }
59
-
60
- // // --- SnapProcessor (SPS) ---
61
- // console.log('\n=== Snap Example (.sps) ===');
62
- // try {
63
- // const spsFile = path.join(__dirname, 'example.sps');
64
- // const snapProcessor = new SnapProcessor();
65
- // const snapTree = snapProcessor.loadIntoTree(spsFile);
66
- // console.log('Snap tree (.sps):', snapTree);
67
- // console.log('Snap texts (.sps):', snapProcessor.extractTexts(spsFile));
68
- // if (prettyPrint) prettyPrint.printTree(snapTree, { showNavigation: true });
69
- // } catch (e) {
70
- // console.warn('Snap demo error (.sps):', e.message);
71
- // }
72
-
73
- // --- GridsetProcessor ---
74
- console.log('\n=== Gridset Example ===');
75
- try {
76
- const gridsetFile = path.join(__dirname, 'example.gridset');
77
- const gridsetProcessor = new GridsetProcessor();
78
- const gridTree = gridsetProcessor.loadIntoTree(gridsetFile);
79
- console.log('Gridset tree:', gridTree);
80
- console.log('Gridset texts:', gridsetProcessor.extractTexts(gridsetFile));
81
- if (prettyPrint) prettyPrint.printTree(gridTree, { showNavigation: true });
82
- } catch (e) {
83
- console.warn('Gridset demo error:', e.message);
84
- }
85
-
86
- // --- TouchChatProcessor ---
87
- console.log('\n=== TouchChat Example ===');
88
- try {
89
- const touchchatFile = path.join(__dirname, 'example.ce');
90
- const touchchatProcessor = new TouchChatProcessor();
91
- const tcTree = touchchatProcessor.loadIntoTree(touchchatFile);
92
- console.log('TouchChat tree:', tcTree);
93
- console.log('TouchChat texts:', touchchatProcessor.extractTexts(touchchatFile));
94
- if (prettyPrint) prettyPrint.printTree(tcTree, { showNavigation: true });
95
- } catch (e) {
96
- console.warn('TouchChat demo error:', e.message);
97
- }
98
-
99
- // --- OBF/OBZ Processor ---
100
- console.log('\n=== OBF/OBZ Example ===');
101
- try {
102
- // Use ObfProcessor from dist, matching others
103
- const obfProcessor = new ObfProcessor();
104
- const obzFile = path.join(__dirname, 'example.obz');
105
- // If loadIntoTree is async, use then/catch. If not, call directly.
106
- let obTree;
107
- try {
108
- obTree = obfProcessor.loadIntoTree(obzFile);
109
- console.log('OBZ tree:', obTree);
110
- // Try extractTexts if available
111
- if (obfProcessor.extractTexts) {
112
- try {
113
- const texts = obfProcessor.extractTexts(obzFile);
114
- console.log('OBZ texts:', texts);
115
- } catch (e) {
116
- console.warn('OBZ extractTexts error:', e.message);
117
- }
118
- }
119
- if (prettyPrint) prettyPrint.printTree(obTree, { showNavigation: true });
120
- console.log('\nDemo complete.');
121
- } catch (e) {
122
- console.warn('OBZ demo error:', e.message);
123
- console.log('\nDemo complete.');
124
- }
125
- // Return here so the rest of the demo waits for async
126
- return;
127
- } catch (e) {
128
- console.warn('OBZ demo error:', e.message);
129
- }
130
-
131
- // --- ApplePanelsProcessor (if implemented) ---
132
- // console.log('\n=== Apple Panels Example ===');
133
- // try {
134
- // const applePanelsFile = path.join(__dirname, 'example.ascconfig');
135
- // const applePanelsProcessor = new ApplePanelsProcessor();
136
- // const apTree = applePanelsProcessor.loadIntoTree(applePanelsFile);
137
- // console.log('Apple Panels tree:', apTree);
138
- // if (prettyPrint) prettyPrint.printTree(apTree, { showNavigation: true });
139
- // } catch (e) {
140
- // console.warn('Apple Panels demo error:', e.message);
141
- // }
142
-
143
- console.log('\nDemo complete.');