@willwade/aac-processors 0.1.7 → 0.1.8

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 (32) hide show
  1. package/dist/analytics.d.ts +7 -0
  2. package/dist/analytics.js +23 -0
  3. package/dist/browser/index.browser.js +5 -0
  4. package/dist/browser/metrics.js +17 -0
  5. package/dist/browser/processors/gridset/helpers.js +390 -0
  6. package/dist/browser/processors/snap/helpers.js +252 -0
  7. package/dist/browser/utilities/analytics/history.js +116 -0
  8. package/dist/browser/utilities/analytics/metrics/comparison.js +477 -0
  9. package/dist/browser/utilities/analytics/metrics/core.js +775 -0
  10. package/dist/browser/utilities/analytics/metrics/effort.js +221 -0
  11. package/dist/browser/utilities/analytics/metrics/obl-types.js +6 -0
  12. package/dist/browser/utilities/analytics/metrics/obl.js +282 -0
  13. package/dist/browser/utilities/analytics/metrics/sentence.js +121 -0
  14. package/dist/browser/utilities/analytics/metrics/types.js +6 -0
  15. package/dist/browser/utilities/analytics/metrics/vocabulary.js +138 -0
  16. package/dist/browser/utilities/analytics/reference/browser.js +67 -0
  17. package/dist/browser/utilities/analytics/reference/index.js +129 -0
  18. package/dist/browser/utils/dotnetTicks.js +17 -0
  19. package/dist/index.browser.d.ts +1 -0
  20. package/dist/index.browser.js +18 -1
  21. package/dist/index.node.d.ts +2 -2
  22. package/dist/index.node.js +5 -5
  23. package/dist/metrics.d.ts +17 -0
  24. package/dist/metrics.js +44 -0
  25. package/dist/utilities/analytics/metrics/comparison.d.ts +2 -1
  26. package/dist/utilities/analytics/metrics/comparison.js +3 -3
  27. package/dist/utilities/analytics/metrics/vocabulary.d.ts +2 -2
  28. package/dist/utilities/analytics/reference/browser.d.ts +31 -0
  29. package/dist/utilities/analytics/reference/browser.js +73 -0
  30. package/dist/utilities/analytics/reference/index.d.ts +21 -0
  31. package/dist/utilities/analytics/reference/index.js +22 -46
  32. package/package.json +9 -1
@@ -5,6 +5,27 @@
5
5
  * for AAC metrics analysis.
6
6
  */
7
7
  import { CoreList, CommonWordsData, SynonymsData } from '../metrics/types';
8
+ export interface ReferenceDataProvider {
9
+ loadCoreLists(): CoreList[];
10
+ loadCommonWords(): CommonWordsData;
11
+ loadSynonyms(): SynonymsData;
12
+ loadSentences(): string[][];
13
+ loadFringe(): string[];
14
+ loadBaseWords(): {
15
+ [word: string]: boolean;
16
+ };
17
+ loadCommonFringe(): string[];
18
+ loadAll(): {
19
+ coreLists: CoreList[];
20
+ commonWords: CommonWordsData;
21
+ synonyms: SynonymsData;
22
+ sentences: string[][];
23
+ fringe: string[];
24
+ baseWords: {
25
+ [word: string]: boolean;
26
+ };
27
+ };
28
+ }
8
29
  export declare class ReferenceLoader {
9
30
  private dataDir;
10
31
  private locale;
@@ -5,35 +5,11 @@
5
5
  * Loads reference vocabulary lists, core lists, and sentences
6
6
  * for AAC metrics analysis.
7
7
  */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
- Object.defineProperty(o, "default", { enumerable: true, value: v });
21
- }) : function(o, v) {
22
- o["default"] = v;
23
- });
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
31
8
  Object.defineProperty(exports, "__esModule", { value: true });
32
9
  exports.ReferenceLoader = void 0;
33
10
  exports.getReferenceDataPath = getReferenceDataPath;
34
11
  exports.hasReferenceData = hasReferenceData;
35
- const fs = __importStar(require("fs"));
36
- const path = __importStar(require("path"));
12
+ const io_1 = require("../../../utils/io");
37
13
  class ReferenceLoader {
38
14
  constructor(dataDir, locale = 'en') {
39
15
  this.locale = locale;
@@ -43,48 +19,48 @@ class ReferenceLoader {
43
19
  else {
44
20
  // Resolve the data directory relative to this file's location
45
21
  // Use __dirname which works correctly after compilation
46
- this.dataDir = path.join(__dirname, 'data');
22
+ this.dataDir = (0, io_1.getPath)().join(__dirname, 'data');
47
23
  }
48
24
  }
49
25
  /**
50
26
  * Load core vocabulary lists
51
27
  */
52
28
  loadCoreLists() {
53
- const filePath = path.join(this.dataDir, `core_lists.${this.locale}.json`);
54
- const content = fs.readFileSync(filePath, 'utf-8');
55
- return JSON.parse(content);
29
+ const filePath = (0, io_1.getPath)().join(this.dataDir, `core_lists.${this.locale}.json`);
30
+ const content = (0, io_1.getFs)().readFileSync(filePath, 'utf-8');
31
+ return JSON.parse(String(content));
56
32
  }
57
33
  /**
58
34
  * Load common words with baseline effort scores
59
35
  */
60
36
  loadCommonWords() {
61
- const filePath = path.join(this.dataDir, `common_words.${this.locale}.json`);
62
- const content = fs.readFileSync(filePath, 'utf-8');
63
- return JSON.parse(content);
37
+ const filePath = (0, io_1.getPath)().join(this.dataDir, `common_words.${this.locale}.json`);
38
+ const content = (0, io_1.getFs)().readFileSync(filePath, 'utf-8');
39
+ return JSON.parse(String(content));
64
40
  }
65
41
  /**
66
42
  * Load synonym mappings
67
43
  */
68
44
  loadSynonyms() {
69
- const filePath = path.join(this.dataDir, `synonyms.${this.locale}.json`);
70
- const content = fs.readFileSync(filePath, 'utf-8');
71
- return JSON.parse(content);
45
+ const filePath = (0, io_1.getPath)().join(this.dataDir, `synonyms.${this.locale}.json`);
46
+ const content = (0, io_1.getFs)().readFileSync(filePath, 'utf-8');
47
+ return JSON.parse(String(content));
72
48
  }
73
49
  /**
74
50
  * Load test sentences
75
51
  */
76
52
  loadSentences() {
77
- const filePath = path.join(this.dataDir, `sentences.${this.locale}.json`);
78
- const content = fs.readFileSync(filePath, 'utf-8');
79
- return JSON.parse(content);
53
+ const filePath = (0, io_1.getPath)().join(this.dataDir, `sentences.${this.locale}.json`);
54
+ const content = (0, io_1.getFs)().readFileSync(filePath, 'utf-8');
55
+ return JSON.parse(String(content));
80
56
  }
81
57
  /**
82
58
  * Load fringe vocabulary
83
59
  */
84
60
  loadFringe() {
85
- const filePath = path.join(this.dataDir, `fringe.${this.locale}.json`);
86
- const content = fs.readFileSync(filePath, 'utf-8');
87
- const data = JSON.parse(content);
61
+ const filePath = (0, io_1.getPath)().join(this.dataDir, `fringe.${this.locale}.json`);
62
+ const content = (0, io_1.getFs)().readFileSync(filePath, 'utf-8');
63
+ const data = JSON.parse(String(content));
88
64
  // Flatten nested category words if needed
89
65
  if (Array.isArray(data) && data.length > 0 && data[0].categories) {
90
66
  const flattened = [];
@@ -101,9 +77,9 @@ class ReferenceLoader {
101
77
  * Load base words hash map
102
78
  */
103
79
  loadBaseWords() {
104
- const filePath = path.join(this.dataDir, `base_words.${this.locale}.json`);
105
- const content = fs.readFileSync(filePath, 'utf-8');
106
- return JSON.parse(content);
80
+ const filePath = (0, io_1.getPath)().join(this.dataDir, `base_words.${this.locale}.json`);
81
+ const content = (0, io_1.getFs)().readFileSync(filePath, 'utf-8');
82
+ return JSON.parse(String(content));
107
83
  }
108
84
  /**
109
85
  * Load common fringe vocabulary
@@ -141,7 +117,7 @@ exports.ReferenceLoader = ReferenceLoader;
141
117
  * Get the default reference data path
142
118
  */
143
119
  function getReferenceDataPath() {
144
- return path.join(__dirname, 'data');
120
+ return String((0, io_1.getPath)().join(__dirname, 'data'));
145
121
  }
146
122
  /**
147
123
  * Check if reference data files exist
@@ -155,5 +131,5 @@ function hasReferenceData() {
155
131
  'synonyms.en.json',
156
132
  'fringe.en.json',
157
133
  ];
158
- return requiredFiles.every((file) => fs.existsSync(path.join(dataPath, file)));
134
+ return requiredFiles.every((file) => (0, io_1.getFs)().existsSync((0, io_1.getPath)().join(dataPath, file)));
159
135
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willwade/aac-processors",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
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",
@@ -67,6 +67,14 @@
67
67
  "./validation": {
68
68
  "types": "./dist/validation.d.ts",
69
69
  "default": "./dist/validation.js"
70
+ },
71
+ "./metrics": {
72
+ "types": "./dist/metrics.d.ts",
73
+ "default": "./dist/metrics.js"
74
+ },
75
+ "./analytics": {
76
+ "types": "./dist/analytics.d.ts",
77
+ "default": "./dist/analytics.js"
70
78
  }
71
79
  },
72
80
  "files": [