@willwade/aac-processors 0.1.8 → 0.1.10

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.
@@ -69,6 +69,7 @@ export const AUTOCONTENT_TYPES = {
69
69
  PREDICTION: 'Prediction',
70
70
  GRAMMAR: 'Grammar',
71
71
  CONTEXTUAL: 'Contextual',
72
+ WORDLIST: 'WordList',
72
73
  };
73
74
  /**
74
75
  * Human-readable names for cell types
@@ -67,6 +67,14 @@ export function resolveGrid3CellImage(zip, args, zipEntries) {
67
67
  }
68
68
  // Direct declared file
69
69
  if (imageName) {
70
+ // Check for partial image names that start with '-' (common in Grid3)
71
+ // These are coordinate-based suffixes like "-0-text-0.png" that need
72
+ // to be prefixed with the cell coordinates
73
+ if (imageName.startsWith('-') && x != null && y != null) {
74
+ const coordPrefixed = joinBaseDir(baseDir, `${x}-${y}${imageName}`);
75
+ if (has(coordPrefixed))
76
+ return coordPrefixed;
77
+ }
70
78
  const p1 = joinBaseDir(baseDir, imageName);
71
79
  if (has(p1))
72
80
  return p1;
@@ -625,6 +625,27 @@ class GridsetProcessor extends BaseProcessor {
625
625
  });
626
626
  });
627
627
  }
628
+ const pageWordListItems = [];
629
+ if (grid.WordList && grid.WordList.Items) {
630
+ const items = grid.WordList.Items.WordListItem || grid.WordList.Items.wordlistitem || [];
631
+ const itemArr = Array.isArray(items) ? items : items ? [items] : [];
632
+ for (const item of itemArr) {
633
+ const text = item.Text || item.text;
634
+ if (text) {
635
+ const val = this.textOf(text);
636
+ if (val) {
637
+ pageWordListItems.push({
638
+ text: val,
639
+ image: item.Image || item.image || undefined,
640
+ partOfSpeech: item.PartOfSpeech || item.partOfSpeech || undefined,
641
+ });
642
+ }
643
+ }
644
+ }
645
+ }
646
+ // Track WordList AutoContent cells and their positions for "more" button placement
647
+ const wordListAutoContentCells = [];
648
+ let wordListCellIndex = 0;
628
649
  cellArr.forEach((cell, idx) => {
629
650
  if (!cell || !cell.Content)
630
651
  return;
@@ -692,7 +713,7 @@ class GridsetProcessor extends BaseProcessor {
692
713
  return; // Skip cells without labels AND without images/symbols
693
714
  }
694
715
  }
695
- const message = label; // Use caption as message
716
+ let message = label; // Use caption as message
696
717
  // Detect plugin cell type (Workspace, LiveCell, AutoContent)
697
718
  const pluginMetadata = detectPluginCellType(content);
698
719
  // Friendly labels for workspace/prediction cells when captions are missing
@@ -711,6 +732,45 @@ class GridsetProcessor extends BaseProcessor {
711
732
  // Always surface a friendly label for predictions even if a placeholder exists
712
733
  label = `Prediction ${predictionCellCounter}`;
713
734
  }
735
+ // Handle WordList AutoContent cells - populate from page-level WordList
736
+ let isMoreButton = false;
737
+ if (pluginMetadata.cellType === Grid3CellType.AutoContent &&
738
+ pluginMetadata.autoContentType === 'WordList' &&
739
+ pageWordListItems.length > 0) {
740
+ // Track this cell for potential "more" button
741
+ wordListAutoContentCells.push({
742
+ cell,
743
+ idx,
744
+ x: cellX,
745
+ y: cellY,
746
+ });
747
+ // Check if we have more WordList items than available cells
748
+ // The "more" button replaces the last WordList cell
749
+ const cellsNeededForWordList = pageWordListItems.length;
750
+ const availableWordListCells = wordListAutoContentCells.length;
751
+ const isLastWordListCell = availableWordListCells === cellsNeededForWordList + 1; // +1 for "more" button
752
+ if (isLastWordListCell) {
753
+ // This cell becomes the "more" button
754
+ label = 'more...';
755
+ message = 'more...';
756
+ isMoreButton = true;
757
+ }
758
+ else if (wordListCellIndex < pageWordListItems.length) {
759
+ // Populate this cell with the next WordList item
760
+ const wordListItem = pageWordListItems[wordListCellIndex];
761
+ label = wordListItem.text;
762
+ message = wordListItem.text;
763
+ // Use the WordList item's image if available
764
+ if (wordListItem.image && !label) {
765
+ label = wordListItem.image; // Fallback to image path if no text
766
+ }
767
+ wordListCellIndex++;
768
+ }
769
+ else {
770
+ // No more WordList items - skip this cell
771
+ return;
772
+ }
773
+ }
714
774
  // Parse all command types from Grid3 and create semantic actions
715
775
  let semanticAction;
716
776
  let legacyAction = null;
@@ -1285,6 +1345,13 @@ class GridsetProcessor extends BaseProcessor {
1285
1345
  : undefined,
1286
1346
  // Store page name for Grid3 image lookup
1287
1347
  gridPageName: gridName,
1348
+ // Store WordList "more" button flag
1349
+ isMoreButton: isMoreButton || undefined,
1350
+ wordListItemIndex: pluginMetadata.cellType === Grid3CellType.AutoContent &&
1351
+ pluginMetadata.autoContentType === 'WordList' &&
1352
+ !isMoreButton
1353
+ ? wordListCellIndex - 1
1354
+ : undefined,
1288
1355
  },
1289
1356
  });
1290
1357
  // Add button to page
@@ -491,19 +491,27 @@ class ObfProcessor extends BaseProcessor {
491
491
  columns,
492
492
  order,
493
493
  },
494
- buttons: page.buttons.map((button) => ({
495
- id: button.id,
496
- label: button.label,
497
- vocalization: button.message || button.label,
498
- load_board: button.semanticAction?.intent === AACSemanticIntent.NAVIGATE_TO && button.targetPageId
499
- ? {
500
- path: button.targetPageId,
501
- }
502
- : undefined,
503
- background_color: button.style?.backgroundColor,
504
- border_color: button.style?.borderColor,
505
- box_id: buttonPositions.get(String(button.id ?? '')),
506
- })),
494
+ buttons: page.buttons.map((button) => {
495
+ const extraButtonInfo = button;
496
+ const imageId = button.parameters?.image_id ||
497
+ button.parameters?.imageId ||
498
+ extraButtonInfo.image_id ||
499
+ extraButtonInfo.imageId;
500
+ return {
501
+ id: button.id,
502
+ label: button.label,
503
+ vocalization: button.message || button.label,
504
+ load_board: button.semanticAction?.intent === AACSemanticIntent.NAVIGATE_TO && button.targetPageId
505
+ ? {
506
+ path: button.targetPageId,
507
+ }
508
+ : undefined,
509
+ background_color: button.style?.backgroundColor,
510
+ border_color: button.style?.borderColor,
511
+ box_id: buttonPositions.get(String(button.id ?? '')),
512
+ image_id: imageId,
513
+ };
514
+ }),
507
515
  images: Array.isArray(page.images) ? page.images : [],
508
516
  sounds: Array.isArray(page.sounds) ? page.sounds : [],
509
517
  };
package/dist/gridset.d.ts CHANGED
@@ -15,3 +15,4 @@ export { parseSymbolReference, isSymbolReference, resolveSymbolReference, getAva
15
15
  export { extractButtonImage, extractSymbolLibraryImage, convertToAstericsImage, analyzeSymbolExtraction, suggestExtractionStrategy, exportSymbolReferencesToCsv, createSymbolManifest, } from './processors/gridset/symbolExtractor';
16
16
  export { parsePixFile, loadSearchIndexes, searchSymbols, searchSymbolsWithReferences, getSymbolFilename, getSymbolDisplayName, getAllSearchTerms, getSearchSuggestions, countLibrarySymbols, getSymbolSearchStats, } from './processors/gridset/symbolSearch';
17
17
  export { resolveGridsetPassword, resolveGridsetPasswordFromEnv, } from './processors/gridset/password';
18
+ export { auditGridsetImages, formatImageAuditSummary, type ImageAuditResult, type ImageIssue, } from './processors/gridset/imageDebug';
package/dist/gridset.js CHANGED
@@ -7,7 +7,7 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getCommandsByPlugin = exports.getCommandDefinition = exports.detectCommand = exports.AUTOCONTENT_TYPES = exports.LIVECELL_TYPES = exports.WORKSPACE_TYPES = exports.Grid3CellType = exports.isRegularCell = exports.isAutoContentCell = exports.isLiveCell = exports.isWorkspaceCell = exports.getCellTypeDisplayName = exports.detectPluginCellType = exports.ensureAlphaChannelFromStyles = exports.SHAPE_NAMES = exports.CellBackgroundShape = exports.createCategoryStyle = exports.createDefaultStylesXml = exports.CATEGORY_STYLES = exports.DEFAULT_GRID3_STYLES = exports.ensureAlphaChannel = exports.normalizeColor = exports.darkenColor = exports.toHexColor = exports.clampAlpha = exports.clampColorChannel = exports.channelToHex = exports.rgbaToHex = exports.getNamedColor = exports.wordlistToXml = exports.updateWordlist = exports.extractWordlists = exports.createWordlist = exports.createFileMapXml = exports.createSettingsXml = exports.generateGrid3Guid = exports.readAllGrid3History = exports.readGrid3HistoryForUser = exports.readGrid3History = exports.isGrid3Installed = exports.findGrid3UserHistory = exports.findGrid3Vocabularies = exports.findGrid3Users = exports.findGrid3HistoryDatabases = exports.findGrid3UserPaths = exports.getCommonDocumentsPath = exports.openImage = exports.getAllowedImageEntries = exports.getPageTokenImageMap = exports.GridsetProcessor = void 0;
10
- exports.resolveGridsetPasswordFromEnv = exports.resolveGridsetPassword = exports.getSymbolSearchStats = exports.countLibrarySymbols = exports.getSearchSuggestions = exports.getAllSearchTerms = exports.getSymbolDisplayName = exports.getSymbolFilename = exports.searchSymbolsWithReferences = exports.searchSymbols = exports.loadSearchIndexes = exports.parsePixFile = exports.createSymbolManifest = exports.exportSymbolReferencesToCsv = exports.suggestExtractionStrategy = exports.analyzeSymbolExtraction = exports.convertToAstericsImage = exports.extractSymbolLibraryImage = exports.extractButtonImage = exports.getSymbolSearchDir = exports.getSymbolsDir = exports.resolveGrid3CellImage = exports.parseImageSymbolReference = exports.isSymbolLibraryReference = exports.SYMBOL_LIBRARIES = exports.symbolReferenceToFilename = exports.getSymbolSearchIndexesDir = exports.getSymbolLibrariesDir = exports.getDefaultGrid3Path = exports.getSymbolLibraryDisplayName = exports.isKnownSymbolLibrary = exports.getSymbolPath = exports.getSymbolLibraryName = exports.createSymbolReference = exports.analyzeSymbolUsage = exports.extractSymbolReferences = exports.getSymbolLibraryInfo = exports.getAvailableSymbolLibraries = exports.resolveSymbolReference = exports.isSymbolReference = exports.parseSymbolReference = exports.Grid3CommandCategory = exports.GRID3_COMMANDS = exports.extractCommandParameters = exports.getAllPluginIds = exports.getAllCommandIds = exports.getCommandsByCategory = void 0;
10
+ exports.formatImageAuditSummary = exports.auditGridsetImages = exports.resolveGridsetPasswordFromEnv = exports.resolveGridsetPassword = exports.getSymbolSearchStats = exports.countLibrarySymbols = exports.getSearchSuggestions = exports.getAllSearchTerms = exports.getSymbolDisplayName = exports.getSymbolFilename = exports.searchSymbolsWithReferences = exports.searchSymbols = exports.loadSearchIndexes = exports.parsePixFile = exports.createSymbolManifest = exports.exportSymbolReferencesToCsv = exports.suggestExtractionStrategy = exports.analyzeSymbolExtraction = exports.convertToAstericsImage = exports.extractSymbolLibraryImage = exports.extractButtonImage = exports.getSymbolSearchDir = exports.getSymbolsDir = exports.resolveGrid3CellImage = exports.parseImageSymbolReference = exports.isSymbolLibraryReference = exports.SYMBOL_LIBRARIES = exports.symbolReferenceToFilename = exports.getSymbolSearchIndexesDir = exports.getSymbolLibrariesDir = exports.getDefaultGrid3Path = exports.getSymbolLibraryDisplayName = exports.isKnownSymbolLibrary = exports.getSymbolPath = exports.getSymbolLibraryName = exports.createSymbolReference = exports.analyzeSymbolUsage = exports.extractSymbolReferences = exports.getSymbolLibraryInfo = exports.getAvailableSymbolLibraries = exports.resolveSymbolReference = exports.isSymbolReference = exports.parseSymbolReference = exports.Grid3CommandCategory = exports.GRID3_COMMANDS = exports.extractCommandParameters = exports.getAllPluginIds = exports.getAllCommandIds = exports.getCommandsByCategory = void 0;
11
11
  // Processor class
12
12
  var gridsetProcessor_1 = require("./processors/gridsetProcessor");
13
13
  Object.defineProperty(exports, "GridsetProcessor", { enumerable: true, get: function () { return gridsetProcessor_1.GridsetProcessor; } });
@@ -128,3 +128,7 @@ Object.defineProperty(exports, "getSymbolSearchStats", { enumerable: true, get:
128
128
  var password_1 = require("./processors/gridset/password");
129
129
  Object.defineProperty(exports, "resolveGridsetPassword", { enumerable: true, get: function () { return password_1.resolveGridsetPassword; } });
130
130
  Object.defineProperty(exports, "resolveGridsetPasswordFromEnv", { enumerable: true, get: function () { return password_1.resolveGridsetPasswordFromEnv; } });
131
+ // === Image Debugging ===
132
+ var imageDebug_1 = require("./processors/gridset/imageDebug");
133
+ Object.defineProperty(exports, "auditGridsetImages", { enumerable: true, get: function () { return imageDebug_1.auditGridsetImages; } });
134
+ Object.defineProperty(exports, "formatImageAuditSummary", { enumerable: true, get: function () { return imageDebug_1.formatImageAuditSummary; } });
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Image Debugging Utilities for Grid3 Files
3
+ *
4
+ * These utilities help developers understand why images might not be resolving
5
+ * correctly in Grid3 gridsets.
6
+ */
7
+ export interface ImageIssue {
8
+ gridName: string;
9
+ cellX: number;
10
+ cellY: number;
11
+ declaredImage: string | undefined;
12
+ expectedPaths: string[];
13
+ issue: 'not_found' | 'symbol_library' | 'external_reference';
14
+ suggestion: string;
15
+ }
16
+ export interface ImageAuditResult {
17
+ totalCells: number;
18
+ cellsWithImages: number;
19
+ resolvedImages: number;
20
+ unresolvedImages: number;
21
+ issues: ImageIssue[];
22
+ availableImages: string[];
23
+ }
24
+ /**
25
+ * Audit a gridset file to find image resolution issues
26
+ *
27
+ * @param gridsetBuffer - The gridset file as a Buffer
28
+ * @returns Detailed audit report of image issues
29
+ *
30
+ * @example
31
+ * const audit = await auditGridsetImages(gridsetBuffer);
32
+ * console.log(`Found ${audit.unresolvedImages} unresolved images`);
33
+ * audit.issues.forEach(issue => {
34
+ * console.log(`Cell (${issue.cellX}, ${issue.cellY}): ${issue.suggestion}`);
35
+ * });
36
+ */
37
+ export declare function auditGridsetImages(gridsetBuffer: Uint8Array, password?: string | undefined): Promise<ImageAuditResult>;
38
+ /**
39
+ * Get a human-readable summary of image audit results
40
+ */
41
+ export declare function formatImageAuditSummary(audit: ImageAuditResult): string;
@@ -0,0 +1,222 @@
1
+ "use strict";
2
+ /**
3
+ * Image Debugging Utilities for Grid3 Files
4
+ *
5
+ * These utilities help developers understand why images might not be resolving
6
+ * correctly in Grid3 gridsets.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.auditGridsetImages = auditGridsetImages;
10
+ exports.formatImageAuditSummary = formatImageAuditSummary;
11
+ const zip_1 = require("../../utils/zip");
12
+ const password_1 = require("./password");
13
+ const password_2 = require("./password");
14
+ const fast_xml_parser_1 = require("fast-xml-parser");
15
+ const io_1 = require("../../utils/io");
16
+ /**
17
+ * Audit a gridset file to find image resolution issues
18
+ *
19
+ * @param gridsetBuffer - The gridset file as a Buffer
20
+ * @returns Detailed audit report of image issues
21
+ *
22
+ * @example
23
+ * const audit = await auditGridsetImages(gridsetBuffer);
24
+ * console.log(`Found ${audit.unresolvedImages} unresolved images`);
25
+ * audit.issues.forEach(issue => {
26
+ * console.log(`Cell (${issue.cellX}, ${issue.cellY}): ${issue.suggestion}`);
27
+ * });
28
+ */
29
+ async function auditGridsetImages(gridsetBuffer, password = (0, password_2.resolveGridsetPasswordFromEnv)()) {
30
+ const issues = [];
31
+ const availableImages = new Set();
32
+ let totalCells = 0;
33
+ let cellsWithImages = 0;
34
+ let resolvedImages = 0;
35
+ let unresolvedImages = 0;
36
+ try {
37
+ const { zip } = await (0, zip_1.openZipFromInput)(gridsetBuffer);
38
+ const entries = (0, password_1.getZipEntriesFromAdapter)(zip, password);
39
+ const parser = new fast_xml_parser_1.XMLParser();
40
+ // Collect all image files in the gridset
41
+ const imageExtensions = ['.png', '.jpg', '.jpeg', '.bmp', '.gif', '.emf', '.wmf'];
42
+ for (const entry of entries) {
43
+ const name = entry.entryName.toLowerCase();
44
+ if (imageExtensions.some((ext) => name.endsWith(ext))) {
45
+ availableImages.add(entry.entryName);
46
+ }
47
+ }
48
+ // Process each grid file
49
+ for (const entry of entries) {
50
+ if (!entry.entryName.startsWith('Grids/') || !entry.entryName.endsWith('grid.xml')) {
51
+ continue;
52
+ }
53
+ try {
54
+ const xmlContent = (0, io_1.decodeText)(await entry.getData());
55
+ const data = parser.parse(xmlContent);
56
+ const grid = data.Grid || data.grid;
57
+ if (!grid)
58
+ continue;
59
+ const gridNameMatch = entry.entryName.match(/^Grids\/([^/]+)\//);
60
+ const gridName = gridNameMatch ? gridNameMatch[1] : entry.entryName;
61
+ const gridEntryPath = entry.entryName.replace(/\\/g, '/');
62
+ const baseDir = gridEntryPath.replace(/\/grid\.xml$/, '/');
63
+ // Check for FileMap.xml
64
+ const fileMapEntry = entries.find((e) => e.entryName === baseDir + 'FileMap.xml');
65
+ const dynamicFilesMap = new Map();
66
+ if (fileMapEntry) {
67
+ try {
68
+ const fmXml = (0, io_1.decodeText)(await fileMapEntry.getData());
69
+ const fmData = parser.parse(fmXml);
70
+ const fileEntries = fmData?.FileMap?.Entries?.Entry || fmData?.fileMap?.entries?.entry;
71
+ if (fileEntries) {
72
+ const arr = Array.isArray(fileEntries) ? fileEntries : [fileEntries];
73
+ for (const ent of arr) {
74
+ const rawStaticFile = ent['@_StaticFile'] || ent.StaticFile || ent.staticFile;
75
+ const staticFile = typeof rawStaticFile === 'string' ? rawStaticFile.replace(/\\/g, '/') : '';
76
+ if (!staticFile)
77
+ continue;
78
+ const df = ent.DynamicFiles || ent.dynamicFiles;
79
+ const candidates = df?.File || df?.file || df?.Files || df?.files;
80
+ const list = Array.isArray(candidates)
81
+ ? candidates
82
+ : candidates
83
+ ? [candidates]
84
+ : [];
85
+ dynamicFilesMap.set(staticFile, list);
86
+ }
87
+ }
88
+ }
89
+ catch (e) {
90
+ // FileMap parsing failed, continue without it
91
+ }
92
+ }
93
+ // Process cells
94
+ const cells = grid.Cells?.Cell || grid.cells?.cell;
95
+ if (!cells)
96
+ continue;
97
+ const cellArr = Array.isArray(cells) ? cells : [cells];
98
+ for (const cell of cellArr) {
99
+ totalCells++;
100
+ const content = cell.Content;
101
+ if (!content)
102
+ continue;
103
+ const captionAndImage = content.CaptionAndImage || content.captionAndImage;
104
+ const imageCandidate = captionAndImage?.Image ||
105
+ captionAndImage?.image ||
106
+ captionAndImage?.ImageName ||
107
+ captionAndImage?.imageName;
108
+ if (!imageCandidate)
109
+ continue;
110
+ cellsWithImages++;
111
+ const cellX = Math.max(0, parseInt(String(cell['@_X'] || '1'), 10) - 1);
112
+ const cellY = Math.max(0, parseInt(String(cell['@_Y'] || '1'), 10) - 1);
113
+ // Try to resolve the image
114
+ const imageName = String(imageCandidate).trim();
115
+ const imageFound = availableImages.has(`${baseDir}${imageName}`) ||
116
+ availableImages.has(`${baseDir}Images/${imageName}`);
117
+ if (imageFound) {
118
+ resolvedImages++;
119
+ }
120
+ else {
121
+ unresolvedImages++;
122
+ // Determine the issue
123
+ const expectedPaths = [
124
+ `${baseDir}${imageName}`,
125
+ `${baseDir}Images/${imageName}`,
126
+ `${baseDir}${cellX + 1}-${cellY + 1}-0-text-0.png`,
127
+ `${baseDir}${cellX + 1}-${cellY + 1}.png`,
128
+ ];
129
+ let issue;
130
+ let suggestion;
131
+ if (imageName.startsWith('[')) {
132
+ // Check if it's a symbol library reference
133
+ if (imageName.includes('widgit') || imageName.includes('Widgit')) {
134
+ issue = 'symbol_library';
135
+ suggestion =
136
+ 'This is a Widgit symbol library reference. These symbols are not stored in the gridset - they require the Widgit Symbols to be installed on the system.';
137
+ }
138
+ else if (imageName.includes('grid3x') || imageName.includes('Grid3')) {
139
+ issue = 'external_reference';
140
+ suggestion =
141
+ 'This is a built-in Grid3 resource reference. These images are not included in the gridset file.';
142
+ }
143
+ else {
144
+ issue = 'symbol_library';
145
+ suggestion = `External symbol library reference: ${imageName}. Symbol libraries are not embedded in gridset files.`;
146
+ }
147
+ }
148
+ else {
149
+ issue = 'not_found';
150
+ const similarImages = Array.from(availableImages).filter((img) => img.toLowerCase().includes(imageName.toLowerCase().substring(0, 10)));
151
+ if (similarImages.length > 0) {
152
+ suggestion = `Image not found. Did you mean one of these?\n ${similarImages.slice(0, 3).join('\n ')}`;
153
+ }
154
+ else {
155
+ suggestion = `Image file not found in gridset. The file may have been excluded or the path is incorrect.`;
156
+ }
157
+ }
158
+ issues.push({
159
+ gridName,
160
+ cellX: cellX + 1,
161
+ cellY: cellY + 1,
162
+ declaredImage: imageName,
163
+ expectedPaths,
164
+ issue,
165
+ suggestion,
166
+ });
167
+ }
168
+ }
169
+ }
170
+ catch (e) {
171
+ // Skip grids that can't be processed
172
+ continue;
173
+ }
174
+ }
175
+ return {
176
+ totalCells,
177
+ cellsWithImages,
178
+ resolvedImages,
179
+ unresolvedImages,
180
+ issues,
181
+ availableImages: Array.from(availableImages).sort(),
182
+ };
183
+ }
184
+ catch (error) {
185
+ throw new Error(`Failed to audit gridset images: ${error.message}`);
186
+ }
187
+ }
188
+ /**
189
+ * Get a human-readable summary of image audit results
190
+ */
191
+ function formatImageAuditSummary(audit) {
192
+ const lines = [];
193
+ lines.push('=== Grid3 Image Audit Summary ===');
194
+ lines.push(`Total cells: ${audit.totalCells}`);
195
+ lines.push(`Cells with images: ${audit.cellsWithImages}`);
196
+ lines.push(`Resolved images: ${audit.resolvedImages}`);
197
+ lines.push(`Unresolved images: ${audit.unresolvedImages}`);
198
+ lines.push(`Available image files: ${audit.availableImages.length}`);
199
+ lines.push('');
200
+ if (audit.issues.length > 0) {
201
+ lines.push('=== Image Issues ===');
202
+ // Group by issue type
203
+ const byType = new Map();
204
+ for (const issue of audit.issues) {
205
+ const list = byType.get(issue.issue) || [];
206
+ list.push(issue);
207
+ byType.set(issue.issue, list);
208
+ }
209
+ for (const [type, issues] of byType) {
210
+ lines.push(`\n${type.toUpperCase()} (${issues.length} occurrences):`);
211
+ for (const issue of issues.slice(0, 5)) {
212
+ // Show first 5 of each type
213
+ lines.push(` [${issue.gridName}] Cell (${issue.cellX}, ${issue.cellY}): ${issue.declaredImage}`);
214
+ lines.push(` → ${issue.suggestion}`);
215
+ }
216
+ if (issues.length > 5) {
217
+ lines.push(` ... and ${issues.length - 5} more`);
218
+ }
219
+ }
220
+ }
221
+ return lines.join('\n');
222
+ }
@@ -79,6 +79,7 @@ export declare const AUTOCONTENT_TYPES: {
79
79
  readonly PREDICTION: "Prediction";
80
80
  readonly GRAMMAR: "Grammar";
81
81
  readonly CONTEXTUAL: "Contextual";
82
+ readonly WORDLIST: "WordList";
82
83
  };
83
84
  /**
84
85
  * Human-readable names for cell types
@@ -78,6 +78,7 @@ exports.AUTOCONTENT_TYPES = {
78
78
  PREDICTION: 'Prediction',
79
79
  GRAMMAR: 'Grammar',
80
80
  CONTEXTUAL: 'Contextual',
81
+ WORDLIST: 'WordList',
81
82
  };
82
83
  /**
83
84
  * Human-readable names for cell types
@@ -72,6 +72,14 @@ function resolveGrid3CellImage(zip, args, zipEntries) {
72
72
  }
73
73
  // Direct declared file
74
74
  if (imageName) {
75
+ // Check for partial image names that start with '-' (common in Grid3)
76
+ // These are coordinate-based suffixes like "-0-text-0.png" that need
77
+ // to be prefixed with the cell coordinates
78
+ if (imageName.startsWith('-') && x != null && y != null) {
79
+ const coordPrefixed = joinBaseDir(baseDir, `${x}-${y}${imageName}`);
80
+ if (has(coordPrefixed))
81
+ return coordPrefixed;
82
+ }
75
83
  const p1 = joinBaseDir(baseDir, imageName);
76
84
  if (has(p1))
77
85
  return p1;
@@ -651,6 +651,27 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
651
651
  });
652
652
  });
653
653
  }
654
+ const pageWordListItems = [];
655
+ if (grid.WordList && grid.WordList.Items) {
656
+ const items = grid.WordList.Items.WordListItem || grid.WordList.Items.wordlistitem || [];
657
+ const itemArr = Array.isArray(items) ? items : items ? [items] : [];
658
+ for (const item of itemArr) {
659
+ const text = item.Text || item.text;
660
+ if (text) {
661
+ const val = this.textOf(text);
662
+ if (val) {
663
+ pageWordListItems.push({
664
+ text: val,
665
+ image: item.Image || item.image || undefined,
666
+ partOfSpeech: item.PartOfSpeech || item.partOfSpeech || undefined,
667
+ });
668
+ }
669
+ }
670
+ }
671
+ }
672
+ // Track WordList AutoContent cells and their positions for "more" button placement
673
+ const wordListAutoContentCells = [];
674
+ let wordListCellIndex = 0;
654
675
  cellArr.forEach((cell, idx) => {
655
676
  if (!cell || !cell.Content)
656
677
  return;
@@ -718,7 +739,7 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
718
739
  return; // Skip cells without labels AND without images/symbols
719
740
  }
720
741
  }
721
- const message = label; // Use caption as message
742
+ let message = label; // Use caption as message
722
743
  // Detect plugin cell type (Workspace, LiveCell, AutoContent)
723
744
  const pluginMetadata = (0, pluginTypes_1.detectPluginCellType)(content);
724
745
  // Friendly labels for workspace/prediction cells when captions are missing
@@ -737,6 +758,45 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
737
758
  // Always surface a friendly label for predictions even if a placeholder exists
738
759
  label = `Prediction ${predictionCellCounter}`;
739
760
  }
761
+ // Handle WordList AutoContent cells - populate from page-level WordList
762
+ let isMoreButton = false;
763
+ if (pluginMetadata.cellType === pluginTypes_1.Grid3CellType.AutoContent &&
764
+ pluginMetadata.autoContentType === 'WordList' &&
765
+ pageWordListItems.length > 0) {
766
+ // Track this cell for potential "more" button
767
+ wordListAutoContentCells.push({
768
+ cell,
769
+ idx,
770
+ x: cellX,
771
+ y: cellY,
772
+ });
773
+ // Check if we have more WordList items than available cells
774
+ // The "more" button replaces the last WordList cell
775
+ const cellsNeededForWordList = pageWordListItems.length;
776
+ const availableWordListCells = wordListAutoContentCells.length;
777
+ const isLastWordListCell = availableWordListCells === cellsNeededForWordList + 1; // +1 for "more" button
778
+ if (isLastWordListCell) {
779
+ // This cell becomes the "more" button
780
+ label = 'more...';
781
+ message = 'more...';
782
+ isMoreButton = true;
783
+ }
784
+ else if (wordListCellIndex < pageWordListItems.length) {
785
+ // Populate this cell with the next WordList item
786
+ const wordListItem = pageWordListItems[wordListCellIndex];
787
+ label = wordListItem.text;
788
+ message = wordListItem.text;
789
+ // Use the WordList item's image if available
790
+ if (wordListItem.image && !label) {
791
+ label = wordListItem.image; // Fallback to image path if no text
792
+ }
793
+ wordListCellIndex++;
794
+ }
795
+ else {
796
+ // No more WordList items - skip this cell
797
+ return;
798
+ }
799
+ }
740
800
  // Parse all command types from Grid3 and create semantic actions
741
801
  let semanticAction;
742
802
  let legacyAction = null;
@@ -1311,6 +1371,13 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
1311
1371
  : undefined,
1312
1372
  // Store page name for Grid3 image lookup
1313
1373
  gridPageName: gridName,
1374
+ // Store WordList "more" button flag
1375
+ isMoreButton: isMoreButton || undefined,
1376
+ wordListItemIndex: pluginMetadata.cellType === pluginTypes_1.Grid3CellType.AutoContent &&
1377
+ pluginMetadata.autoContentType === 'WordList' &&
1378
+ !isMoreButton
1379
+ ? wordListCellIndex - 1
1380
+ : undefined,
1314
1381
  },
1315
1382
  });
1316
1383
  // Add button to page
@@ -517,19 +517,27 @@ class ObfProcessor extends baseProcessor_1.BaseProcessor {
517
517
  columns,
518
518
  order,
519
519
  },
520
- buttons: page.buttons.map((button) => ({
521
- id: button.id,
522
- label: button.label,
523
- vocalization: button.message || button.label,
524
- load_board: button.semanticAction?.intent === treeStructure_1.AACSemanticIntent.NAVIGATE_TO && button.targetPageId
525
- ? {
526
- path: button.targetPageId,
527
- }
528
- : undefined,
529
- background_color: button.style?.backgroundColor,
530
- border_color: button.style?.borderColor,
531
- box_id: buttonPositions.get(String(button.id ?? '')),
532
- })),
520
+ buttons: page.buttons.map((button) => {
521
+ const extraButtonInfo = button;
522
+ const imageId = button.parameters?.image_id ||
523
+ button.parameters?.imageId ||
524
+ extraButtonInfo.image_id ||
525
+ extraButtonInfo.imageId;
526
+ return {
527
+ id: button.id,
528
+ label: button.label,
529
+ vocalization: button.message || button.label,
530
+ load_board: button.semanticAction?.intent === treeStructure_1.AACSemanticIntent.NAVIGATE_TO && button.targetPageId
531
+ ? {
532
+ path: button.targetPageId,
533
+ }
534
+ : undefined,
535
+ background_color: button.style?.backgroundColor,
536
+ border_color: button.style?.borderColor,
537
+ box_id: buttonPositions.get(String(button.id ?? '')),
538
+ image_id: imageId,
539
+ };
540
+ }),
533
541
  images: Array.isArray(page.images) ? page.images : [],
534
542
  sounds: Array.isArray(page.sounds) ? page.sounds : [],
535
543
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willwade/aac-processors",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
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
  "browser": "dist/browser/index.browser.js",