@willwade/aac-processors 0.1.8 → 0.1.9

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
@@ -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
  };
@@ -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
@@ -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.9",
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",