@willwade/aac-processors 0.0.23 → 0.0.24
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.
|
@@ -561,7 +561,9 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
561
561
|
for (let r = 0; r < maxRows; r++) {
|
|
562
562
|
gridLayout[r] = new Array(maxCols).fill(null);
|
|
563
563
|
}
|
|
564
|
-
|
|
564
|
+
// Track grid-level prediction wordlists so we can attach them to AutoContent
|
|
565
|
+
const gridPredictionWords = [];
|
|
566
|
+
let predictionCellCounter = 0;
|
|
565
567
|
// Extract words from grid-level AutoContentCommands (e.g., Prediction Bar)
|
|
566
568
|
if (grid.AutoContentCommands) {
|
|
567
569
|
const collections = grid.AutoContentCommands.AutoContentCommandCollection;
|
|
@@ -581,7 +583,7 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
581
583
|
const wordListParam = paramArr.find((p) => (p['@_Key'] || p.Key || p.key) === 'wordlist');
|
|
582
584
|
if (wordListParam) {
|
|
583
585
|
const words = this._extractWordsFromWordList(wordListParam);
|
|
584
|
-
|
|
586
|
+
gridPredictionWords.push(...words);
|
|
585
587
|
}
|
|
586
588
|
}
|
|
587
589
|
});
|
|
@@ -657,6 +659,14 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
657
659
|
const message = label; // Use caption as message
|
|
658
660
|
// Detect plugin cell type (Workspace, LiveCell, AutoContent)
|
|
659
661
|
const pluginMetadata = (0, pluginTypes_1.detectPluginCellType)(content);
|
|
662
|
+
// Default labels for prediction cells so they don't render blank
|
|
663
|
+
if (pluginMetadata.cellType === pluginTypes_1.Grid3CellType.AutoContent &&
|
|
664
|
+
pluginMetadata.autoContentType === 'Prediction') {
|
|
665
|
+
predictionCellCounter += 1;
|
|
666
|
+
if (!label) {
|
|
667
|
+
label = `Prediction ${predictionCellCounter}`;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
660
670
|
// Parse all command types from Grid3 and create semantic actions
|
|
661
671
|
let semanticAction;
|
|
662
672
|
let legacyAction = null;
|
|
@@ -664,6 +674,7 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
664
674
|
let navigationTarget;
|
|
665
675
|
let detectedCommands = []; // Store detected command metadata
|
|
666
676
|
const commands = content.Commands?.Command || content.commands?.command;
|
|
677
|
+
let predictionWords;
|
|
667
678
|
// Resolve image for this cell using FileMap and coordinate heuristics
|
|
668
679
|
const imageCandidate = captionAndImage?.Image ||
|
|
669
680
|
captionAndImage?.image ||
|
|
@@ -705,7 +716,9 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
705
716
|
}
|
|
706
717
|
if (wlP) {
|
|
707
718
|
const words = this._extractWordsFromWordList(wlP);
|
|
708
|
-
words.
|
|
719
|
+
if (words.length > 0) {
|
|
720
|
+
predictionWords = words;
|
|
721
|
+
}
|
|
709
722
|
}
|
|
710
723
|
}
|
|
711
724
|
});
|
|
@@ -746,20 +759,21 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
746
759
|
// Skip PredictThis in primary action loop as it was handled in pre-pass
|
|
747
760
|
// unless we need a primary action and nothing else exists
|
|
748
761
|
if (commandId === 'Prediction.PredictThis') {
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
}
|
|
762
|
-
|
|
762
|
+
const wlParam = getRawParam('wordlist');
|
|
763
|
+
const words = wlParam ? this._extractWordsFromWordList(wlParam) : [];
|
|
764
|
+
if (words.length > 0) {
|
|
765
|
+
predictionWords = words;
|
|
766
|
+
}
|
|
767
|
+
if (!semanticAction && words.length > 0) {
|
|
768
|
+
semanticAction = {
|
|
769
|
+
category: treeStructure_1.AACSemanticCategory.COMMUNICATION,
|
|
770
|
+
intent: treeStructure_1.AACSemanticIntent.PLATFORM_SPECIFIC,
|
|
771
|
+
text: words.slice(0, 3).join(', '),
|
|
772
|
+
platformData: {
|
|
773
|
+
grid3: { commandId, parameters: { wordlist: words } },
|
|
774
|
+
},
|
|
775
|
+
fallback: { type: 'ACTION', message: 'Predict words' },
|
|
776
|
+
};
|
|
763
777
|
}
|
|
764
778
|
continue;
|
|
765
779
|
}
|
|
@@ -881,13 +895,9 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
881
895
|
}
|
|
882
896
|
case 'Prediction.PredictThis': {
|
|
883
897
|
const wlParam = getRawParam('wordlist');
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
words.forEach((w) => pagePredictedWords.add(w));
|
|
888
|
-
// Store words in a way that analyzer can find them
|
|
889
|
-
// For now, we'll attach to semanticAction so it can be used later
|
|
890
|
-
// We only set this as the primary action if we don't have one yet
|
|
898
|
+
const words = wlParam ? this._extractWordsFromWordList(wlParam) : [];
|
|
899
|
+
if (words.length > 0) {
|
|
900
|
+
predictionWords = words;
|
|
891
901
|
if (!semanticAction) {
|
|
892
902
|
semanticAction = {
|
|
893
903
|
category: treeStructure_1.AACSemanticCategory.COMMUNICATION,
|
|
@@ -1214,6 +1224,15 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
1214
1224
|
symbolLibraryRef: symbolLibraryRef, // Store full symbol reference
|
|
1215
1225
|
grammar: isSmartGrammarCell ? grammar : undefined,
|
|
1216
1226
|
isSmartGrammarCell: isSmartGrammarCell,
|
|
1227
|
+
predictions: predictionWords?.length
|
|
1228
|
+
? [...predictionWords]
|
|
1229
|
+
: gridPredictionWords.length > 0
|
|
1230
|
+
? [...gridPredictionWords]
|
|
1231
|
+
: undefined,
|
|
1232
|
+
predictionSlot: pluginMetadata.cellType === pluginTypes_1.Grid3CellType.AutoContent &&
|
|
1233
|
+
pluginMetadata.autoContentType === 'Prediction'
|
|
1234
|
+
? predictionCellCounter
|
|
1235
|
+
: undefined,
|
|
1217
1236
|
},
|
|
1218
1237
|
});
|
|
1219
1238
|
// Add button to page
|
|
@@ -1227,59 +1246,6 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
1227
1246
|
}
|
|
1228
1247
|
}
|
|
1229
1248
|
});
|
|
1230
|
-
// Process predicted words: Populate AutoContent slots first, then add virtual buttons at bottom
|
|
1231
|
-
if (pagePredictedWords.size > 0) {
|
|
1232
|
-
const extraWords = Array.from(pagePredictedWords).filter((w) => w.trim().length > 0);
|
|
1233
|
-
if (extraWords.length > 0) {
|
|
1234
|
-
let wordIdx = 0;
|
|
1235
|
-
// Step 1: Fill dedicated AutoContent prediction slots (e.g. at the top)
|
|
1236
|
-
page.buttons.forEach((btn) => {
|
|
1237
|
-
if (btn.contentType === 'AutoContent' &&
|
|
1238
|
-
btn.contentSubType === 'Prediction' &&
|
|
1239
|
-
wordIdx < extraWords.length) {
|
|
1240
|
-
const word = extraWords[wordIdx++];
|
|
1241
|
-
btn.label = word;
|
|
1242
|
-
btn.message = word;
|
|
1243
|
-
btn.semanticAction = {
|
|
1244
|
-
category: treeStructure_1.AACSemanticCategory.COMMUNICATION,
|
|
1245
|
-
intent: treeStructure_1.AACSemanticIntent.INSERT_TEXT,
|
|
1246
|
-
text: word,
|
|
1247
|
-
fallback: { type: 'SPEAK', message: word },
|
|
1248
|
-
};
|
|
1249
|
-
}
|
|
1250
|
-
});
|
|
1251
|
-
// Step 2: Add remaining words as virtual buttons at the bottom
|
|
1252
|
-
if (wordIdx < extraWords.length) {
|
|
1253
|
-
const remainingWords = extraWords.slice(wordIdx);
|
|
1254
|
-
const extraRowsCount = Math.ceil(remainingWords.length / maxCols);
|
|
1255
|
-
for (let r = 0; r < extraRowsCount; r++) {
|
|
1256
|
-
const row = new Array(maxCols).fill(null);
|
|
1257
|
-
for (let c = 0; c < maxCols; c++) {
|
|
1258
|
-
const idx = r * maxCols + c;
|
|
1259
|
-
if (idx < remainingWords.length) {
|
|
1260
|
-
const word = remainingWords[idx];
|
|
1261
|
-
const vBtn = new treeStructure_1.AACButton({
|
|
1262
|
-
id: `${gridId}_vpredict_${wordIdx + idx}`,
|
|
1263
|
-
label: word,
|
|
1264
|
-
message: word,
|
|
1265
|
-
x: c,
|
|
1266
|
-
y: maxRows + r,
|
|
1267
|
-
semanticAction: {
|
|
1268
|
-
category: treeStructure_1.AACSemanticCategory.COMMUNICATION,
|
|
1269
|
-
intent: treeStructure_1.AACSemanticIntent.INSERT_TEXT,
|
|
1270
|
-
text: word,
|
|
1271
|
-
fallback: { type: 'SPEAK', message: word },
|
|
1272
|
-
},
|
|
1273
|
-
});
|
|
1274
|
-
row[c] = vBtn;
|
|
1275
|
-
page.addButton(vBtn);
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
gridLayout.push(row);
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
1249
|
// Set the page's grid layout
|
|
1284
1250
|
page.grid = gridLayout;
|
|
1285
1251
|
// Generate clone_id for each button in the grid
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willwade/aac-processors",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
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",
|