@willwade/aac-processors 0.2.4 → 0.2.6

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.
@@ -939,7 +939,7 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
939
939
  }
940
940
  // Parse all command types from Grid3 and create semantic actions
941
941
  let semanticAction;
942
- let legacyAction = null;
942
+ let _legacyAction = null;
943
943
  // infer action type implicitly from commands; no explicit enum needed
944
944
  let navigationTarget;
945
945
  let detectedCommands = []; // Store detected command metadata
@@ -1065,114 +1065,125 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
1065
1065
  if (gridTarget) {
1066
1066
  // Resolve grid name to grid ID for navigation
1067
1067
  const targetGridId = gridNameToIdMap.get(gridTarget) || gridTarget;
1068
+ // Always set navigationTarget even if another command already
1069
+ // set semanticAction (e.g. Jump.SetBookmark + Jump.To).
1068
1070
  navigationTarget = targetGridId;
1069
- // navigate action
1071
+ // Only set semanticAction if not already set by a prior command
1072
+ if (!semanticAction) {
1073
+ semanticAction = {
1074
+ category: treeStructure_1.AACSemanticCategory.NAVIGATION,
1075
+ intent: treeStructure_1.AACSemanticIntent.NAVIGATE_TO,
1076
+ targetId: targetGridId,
1077
+ platformData: {
1078
+ grid3: {
1079
+ commandId,
1080
+ parameters: { grid: gridTarget },
1081
+ },
1082
+ },
1083
+ fallback: {
1084
+ type: 'NAVIGATE',
1085
+ targetPageId: targetGridId,
1086
+ },
1087
+ };
1088
+ _legacyAction = {
1089
+ type: 'NAVIGATE',
1090
+ targetPageId: targetGridId,
1091
+ };
1092
+ }
1093
+ }
1094
+ break;
1095
+ }
1096
+ case 'Jump.Back':
1097
+ if (!semanticAction) {
1070
1098
  semanticAction = {
1071
1099
  category: treeStructure_1.AACSemanticCategory.NAVIGATION,
1072
- intent: treeStructure_1.AACSemanticIntent.NAVIGATE_TO,
1073
- targetId: targetGridId,
1100
+ intent: treeStructure_1.AACSemanticIntent.GO_BACK,
1074
1101
  platformData: {
1075
1102
  grid3: {
1076
1103
  commandId,
1077
- parameters: { grid: gridTarget },
1104
+ parameters: {},
1078
1105
  },
1079
1106
  },
1080
1107
  fallback: {
1081
- type: 'NAVIGATE',
1082
- targetPageId: targetGridId,
1108
+ type: 'ACTION',
1109
+ message: 'Go back',
1083
1110
  },
1084
1111
  };
1085
- legacyAction = {
1086
- type: 'NAVIGATE',
1087
- targetPageId: targetGridId,
1112
+ _legacyAction = {
1113
+ type: 'GO_BACK',
1088
1114
  };
1089
1115
  }
1090
1116
  break;
1091
- }
1092
- case 'Jump.Back':
1093
- // action
1094
- semanticAction = {
1095
- category: treeStructure_1.AACSemanticCategory.NAVIGATION,
1096
- intent: treeStructure_1.AACSemanticIntent.GO_BACK,
1097
- platformData: {
1098
- grid3: {
1099
- commandId,
1100
- parameters: {},
1101
- },
1102
- },
1103
- fallback: {
1104
- type: 'ACTION',
1105
- message: 'Go back',
1106
- },
1107
- };
1108
- legacyAction = {
1109
- type: 'GO_BACK',
1110
- };
1111
- break;
1112
1117
  case 'Jump.Home':
1113
1118
  case 'Jump.SetHome':
1114
- // action
1115
- navigationTarget = tree.rootId || undefined;
1116
- semanticAction = {
1117
- category: treeStructure_1.AACSemanticCategory.NAVIGATION,
1118
- intent: treeStructure_1.AACSemanticIntent.GO_HOME,
1119
- targetId: tree.rootId || undefined,
1120
- platformData: {
1121
- grid3: {
1122
- commandId,
1123
- parameters: {},
1119
+ if (!navigationTarget)
1120
+ navigationTarget = tree.rootId || undefined;
1121
+ if (!semanticAction) {
1122
+ semanticAction = {
1123
+ category: treeStructure_1.AACSemanticCategory.NAVIGATION,
1124
+ intent: treeStructure_1.AACSemanticIntent.GO_HOME,
1125
+ targetId: tree.rootId || undefined,
1126
+ platformData: {
1127
+ grid3: {
1128
+ commandId,
1129
+ parameters: {},
1130
+ },
1124
1131
  },
1125
- },
1126
- fallback: {
1127
- type: 'ACTION',
1128
- message: 'Go home',
1129
- },
1130
- };
1131
- legacyAction = {
1132
- type: 'GO_HOME',
1133
- };
1132
+ fallback: {
1133
+ type: 'ACTION',
1134
+ message: 'Go home',
1135
+ },
1136
+ };
1137
+ _legacyAction = {
1138
+ type: 'GO_HOME',
1139
+ };
1140
+ }
1134
1141
  break;
1135
1142
  case 'Jump.ToKeyboard': {
1136
1143
  // Navigate to the set keyboard if we found one in settings
1137
1144
  const keyboardGridName = tree.keyboardGridName;
1138
1145
  const keyboardPageId = gridNameToIdMap.get(keyboardGridName);
1139
- if (keyboardPageId) {
1146
+ if (keyboardPageId && !navigationTarget) {
1140
1147
  navigationTarget = keyboardPageId;
1141
1148
  }
1142
- semanticAction = {
1143
- category: treeStructure_1.AACSemanticCategory.NAVIGATION,
1144
- intent: treeStructure_1.AACSemanticIntent.GO_HOME, // Close enough to 'navigation to keyboard'
1145
- targetId: keyboardPageId,
1146
- platformData: {
1147
- grid3: {
1148
- commandId,
1149
- parameters: {},
1149
+ if (!semanticAction) {
1150
+ semanticAction = {
1151
+ category: treeStructure_1.AACSemanticCategory.NAVIGATION,
1152
+ intent: treeStructure_1.AACSemanticIntent.GO_HOME, // Close enough to 'navigation to keyboard'
1153
+ targetId: keyboardPageId,
1154
+ platformData: {
1155
+ grid3: {
1156
+ commandId,
1157
+ parameters: {},
1158
+ },
1150
1159
  },
1151
- },
1152
- fallback: {
1153
- type: 'NAVIGATE',
1154
- targetPageId: keyboardPageId,
1155
- },
1156
- };
1160
+ fallback: {
1161
+ type: 'NAVIGATE',
1162
+ targetPageId: keyboardPageId,
1163
+ },
1164
+ };
1165
+ }
1157
1166
  break;
1158
1167
  }
1159
1168
  case 'Action.InsertTextAndSpeak': {
1160
- const insertText = getParam('text');
1161
- semanticAction = {
1162
- category: treeStructure_1.AACSemanticCategory.COMMUNICATION,
1163
- intent: treeStructure_1.AACSemanticIntent.SPEAK_IMMEDIATE,
1164
- text: insertText,
1165
- platformData: {
1166
- grid3: {
1167
- commandId,
1168
- parameters: { text: insertText },
1169
+ if (!semanticAction) {
1170
+ const insertText = getParam('text');
1171
+ semanticAction = {
1172
+ category: treeStructure_1.AACSemanticCategory.COMMUNICATION,
1173
+ intent: treeStructure_1.AACSemanticIntent.SPEAK_IMMEDIATE,
1174
+ text: insertText,
1175
+ platformData: {
1176
+ grid3: {
1177
+ commandId,
1178
+ parameters: { text: insertText },
1179
+ },
1169
1180
  },
1170
- },
1171
- fallback: {
1172
- type: 'SPEAK',
1173
- message: insertText,
1174
- },
1175
- };
1181
+ fallback: {
1182
+ type: 'SPEAK',
1183
+ message: insertText,
1184
+ },
1185
+ };
1186
+ }
1176
1187
  break;
1177
1188
  }
1178
1189
  case 'Prediction.PredictThis': {
@@ -1205,193 +1216,207 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
1205
1216
  // speak
1206
1217
  const speakUnit = getParam('unit');
1207
1218
  const moveCaret = getParam('movecaret');
1208
- semanticAction = {
1209
- category: treeStructure_1.AACSemanticCategory.COMMUNICATION,
1210
- intent: treeStructure_1.AACSemanticIntent.SPEAK_TEXT,
1211
- platformData: {
1212
- grid3: {
1213
- commandId,
1214
- parameters: {
1215
- unit: speakUnit,
1216
- movecaret: moveCaret,
1219
+ if (!semanticAction) {
1220
+ semanticAction = {
1221
+ category: treeStructure_1.AACSemanticCategory.COMMUNICATION,
1222
+ intent: treeStructure_1.AACSemanticIntent.SPEAK_TEXT,
1223
+ platformData: {
1224
+ grid3: {
1225
+ commandId,
1226
+ parameters: {
1227
+ unit: speakUnit,
1228
+ movecaret: moveCaret,
1229
+ },
1217
1230
  },
1218
1231
  },
1219
- },
1220
- fallback: {
1232
+ fallback: {
1233
+ type: 'SPEAK',
1234
+ message: 'Speak text',
1235
+ },
1236
+ };
1237
+ _legacyAction = {
1221
1238
  type: 'SPEAK',
1222
- message: 'Speak text',
1223
- },
1224
- };
1225
- legacyAction = {
1226
- type: 'SPEAK',
1227
- unit: speakUnit,
1228
- moveCaret: moveCaret ? parseInt(String(moveCaret)) : undefined,
1229
- };
1239
+ unit: speakUnit,
1240
+ moveCaret: moveCaret ? parseInt(String(moveCaret)) : undefined,
1241
+ };
1242
+ }
1230
1243
  break;
1231
1244
  }
1232
1245
  case 'Action.InsertText': {
1233
1246
  const insertText = getParam('text');
1234
1247
  const posParam = getParam('pos');
1248
+ // Always extract POS even if semanticAction is already set
1235
1249
  if (posParam) {
1236
1250
  buttonPos = posParam;
1237
1251
  }
1238
- semanticAction = {
1239
- category: treeStructure_1.AACSemanticCategory.COMMUNICATION,
1240
- intent: treeStructure_1.AACSemanticIntent.INSERT_TEXT,
1241
- text: insertText,
1242
- platformData: {
1243
- grid3: {
1244
- commandId,
1245
- parameters: { text: insertText, pos: posParam },
1252
+ if (!semanticAction) {
1253
+ semanticAction = {
1254
+ category: treeStructure_1.AACSemanticCategory.COMMUNICATION,
1255
+ intent: treeStructure_1.AACSemanticIntent.INSERT_TEXT,
1256
+ text: insertText,
1257
+ platformData: {
1258
+ grid3: {
1259
+ commandId,
1260
+ parameters: { text: insertText, pos: posParam },
1261
+ },
1246
1262
  },
1247
- },
1248
- fallback: {
1249
- type: 'SPEAK',
1250
- message: insertText,
1251
- },
1252
- };
1253
- legacyAction = {
1254
- type: 'INSERT_TEXT',
1255
- text: insertText,
1256
- };
1263
+ fallback: {
1264
+ type: 'SPEAK',
1265
+ message: insertText,
1266
+ },
1267
+ };
1268
+ _legacyAction = {
1269
+ type: 'INSERT_TEXT',
1270
+ text: insertText,
1271
+ };
1272
+ }
1257
1273
  break;
1258
1274
  }
1259
1275
  case 'Action.DeleteWord':
1260
- // action
1261
- semanticAction = {
1262
- category: treeStructure_1.AACSemanticCategory.TEXT_EDITING,
1263
- intent: treeStructure_1.AACSemanticIntent.DELETE_WORD,
1264
- platformData: {
1265
- grid3: {
1266
- commandId,
1267
- parameters: {},
1276
+ if (!semanticAction) {
1277
+ semanticAction = {
1278
+ category: treeStructure_1.AACSemanticCategory.TEXT_EDITING,
1279
+ intent: treeStructure_1.AACSemanticIntent.DELETE_WORD,
1280
+ platformData: {
1281
+ grid3: {
1282
+ commandId,
1283
+ parameters: {},
1284
+ },
1268
1285
  },
1269
- },
1270
- fallback: {
1271
- type: 'ACTION',
1272
- message: 'Delete word',
1273
- },
1274
- };
1275
- legacyAction = {
1276
- type: 'DELETE_WORD',
1277
- };
1286
+ fallback: {
1287
+ type: 'ACTION',
1288
+ message: 'Delete word',
1289
+ },
1290
+ };
1291
+ _legacyAction = {
1292
+ type: 'DELETE_WORD',
1293
+ };
1294
+ }
1278
1295
  break;
1279
1296
  case 'Action.DeleteLetter':
1280
- // action
1281
- semanticAction = {
1282
- category: treeStructure_1.AACSemanticCategory.TEXT_EDITING,
1283
- intent: treeStructure_1.AACSemanticIntent.DELETE_CHARACTER,
1284
- platformData: {
1285
- grid3: {
1286
- commandId,
1287
- parameters: {},
1297
+ if (!semanticAction) {
1298
+ semanticAction = {
1299
+ category: treeStructure_1.AACSemanticCategory.TEXT_EDITING,
1300
+ intent: treeStructure_1.AACSemanticIntent.DELETE_CHARACTER,
1301
+ platformData: {
1302
+ grid3: {
1303
+ commandId,
1304
+ parameters: {},
1305
+ },
1288
1306
  },
1289
- },
1290
- fallback: {
1291
- type: 'ACTION',
1292
- message: 'Delete character',
1293
- },
1294
- };
1295
- legacyAction = {
1296
- type: 'DELETE_CHARACTER',
1297
- };
1307
+ fallback: {
1308
+ type: 'ACTION',
1309
+ message: 'Delete character',
1310
+ },
1311
+ };
1312
+ _legacyAction = {
1313
+ type: 'DELETE_CHARACTER',
1314
+ };
1315
+ }
1298
1316
  break;
1299
1317
  case 'Action.Clear':
1300
1318
  // action
1301
- semanticAction = {
1302
- category: treeStructure_1.AACSemanticCategory.TEXT_EDITING,
1303
- intent: treeStructure_1.AACSemanticIntent.CLEAR_TEXT,
1304
- platformData: {
1305
- grid3: {
1306
- commandId,
1307
- parameters: {},
1319
+ if (!semanticAction) {
1320
+ semanticAction = {
1321
+ category: treeStructure_1.AACSemanticCategory.TEXT_EDITING,
1322
+ intent: treeStructure_1.AACSemanticIntent.CLEAR_TEXT,
1323
+ platformData: {
1324
+ grid3: {
1325
+ commandId,
1326
+ parameters: {},
1327
+ },
1308
1328
  },
1309
- },
1310
- fallback: {
1311
- type: 'ACTION',
1312
- message: 'Clear text',
1313
- },
1314
- };
1315
- legacyAction = {
1316
- type: 'CLEAR_TEXT',
1317
- };
1329
+ fallback: {
1330
+ type: 'ACTION',
1331
+ message: 'Clear text',
1332
+ },
1333
+ };
1334
+ _legacyAction = {
1335
+ type: 'CLEAR_TEXT',
1336
+ };
1337
+ }
1318
1338
  break;
1319
1339
  case 'Action.Letter': {
1320
1340
  // action
1321
1341
  const letter = getParam('letter');
1322
- semanticAction = {
1323
- category: treeStructure_1.AACSemanticCategory.TEXT_EDITING,
1324
- intent: treeStructure_1.AACSemanticIntent.INSERT_TEXT,
1325
- text: letter,
1326
- platformData: {
1327
- grid3: {
1328
- commandId,
1329
- parameters: { letter },
1342
+ if (!semanticAction) {
1343
+ semanticAction = {
1344
+ category: treeStructure_1.AACSemanticCategory.TEXT_EDITING,
1345
+ intent: treeStructure_1.AACSemanticIntent.INSERT_TEXT,
1346
+ text: letter,
1347
+ platformData: {
1348
+ grid3: {
1349
+ commandId,
1350
+ parameters: { letter },
1351
+ },
1330
1352
  },
1331
- },
1332
- fallback: {
1333
- type: 'ACTION',
1334
- message: letter,
1335
- },
1336
- };
1337
- legacyAction = {
1338
- type: 'INSERT_LETTER',
1339
- letter,
1340
- };
1353
+ fallback: {
1354
+ type: 'ACTION',
1355
+ message: letter,
1356
+ },
1357
+ };
1358
+ _legacyAction = {
1359
+ type: 'INSERT_LETTER',
1360
+ letter,
1361
+ };
1362
+ }
1341
1363
  break;
1342
1364
  }
1343
1365
  case 'Settings.RestAll':
1344
1366
  // action
1345
- semanticAction = {
1346
- category: treeStructure_1.AACSemanticCategory.CUSTOM,
1347
- intent: treeStructure_1.AACSemanticIntent.PLATFORM_SPECIFIC,
1348
- platformData: {
1349
- grid3: {
1350
- commandId,
1351
- parameters: {
1352
- indicatorenabled: getParam('indicatorenabled'),
1353
- action: getParam('action'),
1367
+ if (!semanticAction) {
1368
+ semanticAction = {
1369
+ category: treeStructure_1.AACSemanticCategory.CUSTOM,
1370
+ intent: treeStructure_1.AACSemanticIntent.PLATFORM_SPECIFIC,
1371
+ platformData: {
1372
+ grid3: {
1373
+ commandId,
1374
+ parameters: {
1375
+ indicatorenabled: getParam('indicatorenabled'),
1376
+ action: getParam('action'),
1377
+ },
1354
1378
  },
1355
1379
  },
1356
- },
1357
- fallback: {
1358
- type: 'ACTION',
1359
- message: 'Settings action',
1360
- },
1361
- };
1362
- legacyAction = {
1363
- type: 'SETTINGS',
1364
- indicatorEnabled: getParam('indicatorenabled') === '1',
1365
- settingsAction: getParam('action'),
1366
- };
1380
+ fallback: {
1381
+ type: 'ACTION',
1382
+ message: 'Settings action',
1383
+ },
1384
+ };
1385
+ _legacyAction = {
1386
+ type: 'SETTINGS',
1387
+ indicatorEnabled: getParam('indicatorenabled') === '1',
1388
+ settingsAction: getParam('action'),
1389
+ };
1390
+ }
1367
1391
  break;
1368
1392
  case 'AutoContent.Activate':
1369
1393
  // action
1370
- semanticAction = {
1371
- category: treeStructure_1.AACSemanticCategory.CUSTOM,
1372
- intent: treeStructure_1.AACSemanticIntent.PLATFORM_SPECIFIC,
1373
- platformData: {
1374
- grid3: {
1375
- commandId,
1376
- parameters: {
1377
- autocontenttype: getParam('autocontenttype'),
1394
+ if (!semanticAction) {
1395
+ semanticAction = {
1396
+ category: treeStructure_1.AACSemanticCategory.CUSTOM,
1397
+ intent: treeStructure_1.AACSemanticIntent.PLATFORM_SPECIFIC,
1398
+ platformData: {
1399
+ grid3: {
1400
+ commandId,
1401
+ parameters: {
1402
+ autocontenttype: getParam('autocontenttype'),
1403
+ },
1378
1404
  },
1379
1405
  },
1380
- },
1381
- fallback: {
1382
- type: 'ACTION',
1383
- message: 'Auto content',
1384
- },
1385
- };
1386
- legacyAction = {
1387
- type: 'AUTO_CONTENT',
1388
- autoContentType: getParam('autocontenttype'),
1389
- };
1406
+ fallback: {
1407
+ type: 'ACTION',
1408
+ message: 'Auto content',
1409
+ },
1410
+ };
1411
+ _legacyAction = {
1412
+ type: 'AUTO_CONTENT',
1413
+ autoContentType: getParam('autocontenttype'),
1414
+ };
1415
+ }
1390
1416
  break;
1391
1417
  default:
1392
1418
  // Unknown command - preserve as generic action
1393
- if (commandId) {
1394
- // action
1419
+ if (commandId && !semanticAction) {
1395
1420
  const allParams = Object.fromEntries(paramArr.map((p) => [p.Key || p.key, p['#text']]));
1396
1421
  semanticAction = {
1397
1422
  category: treeStructure_1.AACSemanticCategory.CUSTOM,
@@ -1407,16 +1432,13 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
1407
1432
  message: 'Unknown command',
1408
1433
  },
1409
1434
  };
1410
- legacyAction = {
1411
- type: 'SPEAK',
1412
- parameters: { commandId, ...allParams },
1413
- };
1435
+ // legacy action not needed for unknown commands
1414
1436
  }
1415
1437
  break;
1416
1438
  }
1417
- // Use first recognized command
1418
- if (semanticAction || legacyAction)
1419
- break;
1439
+ // Continue processing remaining commands so that navigation
1440
+ // targets (Jump.To) are discovered even when a non-navigation
1441
+ // command (e.g. Jump.SetBookmark, Action.InsertText) appears first.
1420
1442
  }
1421
1443
  }
1422
1444
  // Create default semantic action if none was created from commands