@willwade/aac-processors 0.2.3 → 0.2.5

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.
Files changed (47) hide show
  1. package/dist/browser/core/treeStructure.js +3 -1
  2. package/dist/browser/metrics.js +2 -0
  3. package/dist/browser/processors/astericsGridProcessor.js +21 -12
  4. package/dist/browser/processors/gridset/helpers.js +3 -3
  5. package/dist/browser/processors/gridsetProcessor.js +269 -239
  6. package/dist/browser/processors/obfProcessor.js +4 -4
  7. package/dist/browser/processors/snap/helpers.js +3 -3
  8. package/dist/browser/processors/snapProcessor.js +2 -2
  9. package/dist/browser/processors/touchchatProcessor.js +6 -6
  10. package/dist/browser/utilities/analytics/metrics/core.js +213 -8
  11. package/dist/browser/utilities/analytics/metrics/vocabulary.js +13 -1
  12. package/dist/browser/utilities/analytics/morphology/engine.js +910 -0
  13. package/dist/browser/utilities/analytics/morphology/grid3VerbsParser.js +455 -0
  14. package/dist/browser/utilities/analytics/morphology/index.js +3 -0
  15. package/dist/browser/utilities/analytics/morphology/types.js +1 -0
  16. package/dist/browser/utilities/analytics/morphology/wordFormGenerator.js +74 -0
  17. package/dist/core/treeStructure.d.ts +17 -1
  18. package/dist/core/treeStructure.js +3 -1
  19. package/dist/index.node.d.ts +2 -0
  20. package/dist/index.node.js +6 -1
  21. package/dist/metrics.d.ts +3 -0
  22. package/dist/metrics.js +5 -1
  23. package/dist/processors/astericsGridProcessor.js +21 -12
  24. package/dist/processors/excelProcessor.js +5 -1
  25. package/dist/processors/gridset/helpers.js +3 -3
  26. package/dist/processors/gridset/imageDebug.js +2 -2
  27. package/dist/processors/gridsetProcessor.js +269 -239
  28. package/dist/processors/obfProcessor.js +4 -4
  29. package/dist/processors/snap/helpers.js +3 -3
  30. package/dist/processors/snapProcessor.js +2 -2
  31. package/dist/processors/touchchatProcessor.js +6 -6
  32. package/dist/utilities/analytics/metrics/core.d.ts +14 -0
  33. package/dist/utilities/analytics/metrics/core.js +213 -8
  34. package/dist/utilities/analytics/metrics/types.d.ts +18 -3
  35. package/dist/utilities/analytics/metrics/vocabulary.d.ts +3 -0
  36. package/dist/utilities/analytics/metrics/vocabulary.js +13 -1
  37. package/dist/utilities/analytics/morphology/engine.d.ts +30 -0
  38. package/dist/utilities/analytics/morphology/engine.js +914 -0
  39. package/dist/utilities/analytics/morphology/grid3VerbsParser.d.ts +36 -0
  40. package/dist/utilities/analytics/morphology/grid3VerbsParser.js +485 -0
  41. package/dist/utilities/analytics/morphology/index.d.ts +5 -0
  42. package/dist/utilities/analytics/morphology/index.js +9 -0
  43. package/dist/utilities/analytics/morphology/types.d.ts +40 -0
  44. package/dist/utilities/analytics/morphology/types.js +2 -0
  45. package/dist/utilities/analytics/morphology/wordFormGenerator.d.ts +10 -0
  46. package/dist/utilities/analytics/morphology/wordFormGenerator.js +78 -0
  47. package/package.json +12 -11
@@ -51,7 +51,7 @@ export var AACScanType;
51
51
  AACScanType["BLOCK_COLUMN_ROW"] = "block-column-row";
52
52
  })(AACScanType || (AACScanType = {}));
53
53
  export class AACButton {
54
- constructor({ id, label = '', message = '', targetPageId, semanticAction, audioRecording, style, contentType, contentSubType, image, resolvedImageEntry, symbolLibrary, symbolPath, x, y, columnSpan, rowSpan, scanBlocks, scanBlock, visibility, directActivate, parameters, predictions, semantic_id, clone_id,
54
+ constructor({ id, label = '', message = '', targetPageId, semanticAction, audioRecording, style, contentType, contentSubType, image, resolvedImageEntry, symbolLibrary, symbolPath, x, y, columnSpan, rowSpan, scanBlocks, scanBlock, visibility, directActivate, parameters, predictions, pos, wordForms, semantic_id, clone_id,
55
55
  // Legacy input support
56
56
  type, action, }) {
57
57
  this.id = id;
@@ -77,6 +77,8 @@ export class AACButton {
77
77
  this.directActivate = directActivate;
78
78
  this.parameters = parameters;
79
79
  this.predictions = predictions;
80
+ this.pos = pos;
81
+ this.wordForms = wordForms;
80
82
  this.semantic_id = semantic_id;
81
83
  this.clone_id = clone_id;
82
84
  // Legacy mapping: if no semanticAction provided, derive from legacy `action` first
@@ -12,6 +12,8 @@ export { MetricsCalculator } from './utilities/analytics/metrics/core';
12
12
  export { VocabularyAnalyzer } from './utilities/analytics/metrics/vocabulary';
13
13
  export { SentenceAnalyzer } from './utilities/analytics/metrics/sentence';
14
14
  export { ComparisonAnalyzer } from './utilities/analytics/metrics/comparison';
15
+ export { MorphologyEngine } from './utilities/analytics/morphology';
16
+ export { WordFormGenerator } from './utilities/analytics/morphology';
15
17
  export { ReferenceLoader } from './utilities/analytics/reference';
16
18
  export { InMemoryReferenceLoader, createBrowserReferenceLoader, loadReferenceDataFromUrl, } from './utilities/analytics/reference/browser';
17
19
  export * from './utilities/analytics/utils/idGenerator';
@@ -605,7 +605,7 @@ class AstericsGridProcessor extends BaseProcessor {
605
605
  });
606
606
  });
607
607
  }
608
- catch (error) {
608
+ catch (_error) {
609
609
  // If JSON parsing fails, return empty array
610
610
  }
611
611
  return texts;
@@ -1021,7 +1021,7 @@ class AstericsGridProcessor extends BaseProcessor {
1021
1021
  // Use detected format for filename
1022
1022
  imageName = element.image.id || `image.${imageFormat}`;
1023
1023
  }
1024
- catch (e) {
1024
+ catch (_e) {
1025
1025
  // Invalid base64 data, skip image
1026
1026
  }
1027
1027
  }
@@ -1034,19 +1034,23 @@ class AstericsGridProcessor extends BaseProcessor {
1034
1034
  audioRecording: audioRecording,
1035
1035
  visibility: mapAstericsVisibility(element.hidden),
1036
1036
  image: imageName, // Store image filename/reference
1037
- parameters: imageData
1038
- ? {
1039
- ...{ imageData: imageData }, // Store actual image data in parameters for conversion
1040
- }
1041
- : undefined,
1042
1037
  style: {
1043
1038
  backgroundColor: finalBackgroundColor,
1044
1039
  borderColor: colorStyles.borderColor || colorConfig?.elementBorderColor || '#CCCCCC',
1045
1040
  borderWidth: colorConfig?.borderWidth || 1,
1046
1041
  fontFamily: colorConfig?.fontFamily || 'Arial',
1047
- fontSize: colorConfig?.fontSizePct ? colorConfig.fontSizePct * 16 : 16, // Default to 16px
1042
+ fontSize: colorConfig?.fontSizePct ? colorConfig.fontSizePct * 16 : 16,
1048
1043
  fontColor: fontColor,
1049
1044
  },
1045
+ wordForms: element.wordForms && element.wordForms.length > 0 ? element.wordForms : undefined,
1046
+ parameters: {
1047
+ ...(imageData ? { imageData: imageData } : {}),
1048
+ ...(element.actions?.some((a) => a.modelName === 'GridActionWordForm')
1049
+ ? {
1050
+ wordFormActions: element.actions.filter((a) => a.modelName === 'GridActionWordForm'),
1051
+ }
1052
+ : {}),
1053
+ },
1050
1054
  });
1051
1055
  }
1052
1056
  async processTexts(filePathOrBuffer, translations, outputPath) {
@@ -1313,6 +1317,11 @@ class AstericsGridProcessor extends BaseProcessor {
1313
1317
  });
1314
1318
  }
1315
1319
  const locale = tree.metadata?.locale || 'en';
1320
+ if (button.parameters?.wordFormActions &&
1321
+ Array.isArray(button.parameters.wordFormActions)) {
1322
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
1323
+ actions.push(...button.parameters.wordFormActions);
1324
+ }
1316
1325
  return {
1317
1326
  id: button.id,
1318
1327
  modelName: 'GridElement',
@@ -1322,7 +1331,7 @@ class AstericsGridProcessor extends BaseProcessor {
1322
1331
  x: calculatedX,
1323
1332
  y: calculatedY,
1324
1333
  label: { [locale]: button.label },
1325
- wordForms: [],
1334
+ wordForms: button.wordForms || [],
1326
1335
  image: {
1327
1336
  data: null,
1328
1337
  author: undefined,
@@ -1414,7 +1423,7 @@ class AstericsGridProcessor extends BaseProcessor {
1414
1423
  audioAction.durationMs = parsedMetadata.durationMs || audioAction.durationMs;
1415
1424
  audioAction.filename = parsedMetadata.filename || audioAction.filename;
1416
1425
  }
1417
- catch (e) {
1426
+ catch (_e) {
1418
1427
  // Use defaults if metadata parsing fails
1419
1428
  }
1420
1429
  }
@@ -1466,7 +1475,7 @@ class AstericsGridProcessor extends BaseProcessor {
1466
1475
  });
1467
1476
  });
1468
1477
  }
1469
- catch (error) {
1478
+ catch (_error) {
1470
1479
  // If JSON parsing fails, return empty array
1471
1480
  }
1472
1481
  return elementIds;
@@ -1491,7 +1500,7 @@ class AstericsGridProcessor extends BaseProcessor {
1491
1500
  }
1492
1501
  }
1493
1502
  }
1494
- catch (error) {
1503
+ catch (_error) {
1495
1504
  // If JSON parsing fails, return false
1496
1505
  }
1497
1506
  return false;
@@ -66,7 +66,7 @@ export async function openImage(gridsetBuffer, entryPath, password = resolveGrid
66
66
  }
67
67
  return data;
68
68
  }
69
- catch (error) {
69
+ catch (_error) {
70
70
  return null;
71
71
  }
72
72
  }
@@ -156,7 +156,7 @@ export function getCommonDocumentsPath() {
156
156
  return match[1].trim();
157
157
  }
158
158
  }
159
- catch (error) {
159
+ catch (_error) {
160
160
  // Registry access failed, fall back to default
161
161
  }
162
162
  // Default fallback path
@@ -212,7 +212,7 @@ export async function findGrid3UserPaths(fileAdapter = defaultFileAdapter) {
212
212
  }
213
213
  }
214
214
  }
215
- catch (error) {
215
+ catch (_error) {
216
216
  // Silently fail if directory access fails
217
217
  }
218
218
  return results;