@willwade/aac-processors 0.0.10 → 0.0.12
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.
- package/dist/cli/index.js +7 -0
- package/dist/core/analyze.js +1 -0
- package/dist/core/baseProcessor.d.ts +3 -0
- package/dist/core/treeStructure.d.ts +14 -2
- package/dist/core/treeStructure.js +8 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +20 -3
- package/dist/{analytics → optional/analytics}/history.d.ts +3 -3
- package/dist/{analytics → optional/analytics}/history.js +3 -3
- package/dist/optional/analytics/index.d.ts +28 -0
- package/dist/optional/analytics/index.js +73 -0
- package/dist/optional/analytics/metrics/comparison.d.ts +36 -0
- package/dist/optional/analytics/metrics/comparison.js +330 -0
- package/dist/optional/analytics/metrics/core.d.ts +36 -0
- package/dist/optional/analytics/metrics/core.js +422 -0
- package/dist/optional/analytics/metrics/effort.d.ts +137 -0
- package/dist/optional/analytics/metrics/effort.js +198 -0
- package/dist/optional/analytics/metrics/index.d.ts +15 -0
- package/dist/optional/analytics/metrics/index.js +36 -0
- package/dist/optional/analytics/metrics/sentence.d.ts +49 -0
- package/dist/optional/analytics/metrics/sentence.js +112 -0
- package/dist/optional/analytics/metrics/types.d.ts +157 -0
- package/dist/optional/analytics/metrics/types.js +7 -0
- package/dist/optional/analytics/metrics/vocabulary.d.ts +65 -0
- package/dist/optional/analytics/metrics/vocabulary.js +140 -0
- package/dist/optional/analytics/reference/index.d.ts +51 -0
- package/dist/optional/analytics/reference/index.js +102 -0
- package/dist/optional/analytics/utils/idGenerator.d.ts +59 -0
- package/dist/optional/analytics/utils/idGenerator.js +96 -0
- package/dist/processors/gridset/colorUtils.d.ts +18 -0
- package/dist/processors/gridset/colorUtils.js +36 -0
- package/dist/processors/gridset/commands.d.ts +103 -0
- package/dist/processors/gridset/commands.js +958 -0
- package/dist/processors/gridset/index.d.ts +45 -0
- package/dist/processors/gridset/index.js +153 -0
- package/dist/processors/gridset/pluginTypes.d.ts +109 -0
- package/dist/processors/gridset/pluginTypes.js +285 -0
- package/dist/processors/gridset/resolver.d.ts +13 -0
- package/dist/processors/gridset/resolver.js +39 -1
- package/dist/processors/gridset/styleHelpers.d.ts +22 -0
- package/dist/processors/gridset/styleHelpers.js +35 -1
- package/dist/processors/gridset/symbolExtractor.d.ts +121 -0
- package/dist/processors/gridset/symbolExtractor.js +362 -0
- package/dist/processors/gridset/symbolSearch.d.ts +117 -0
- package/dist/processors/gridset/symbolSearch.js +280 -0
- package/dist/processors/gridset/symbols.d.ts +199 -0
- package/dist/processors/gridset/symbols.js +468 -0
- package/dist/processors/gridsetProcessor.js +59 -0
- package/dist/processors/index.d.ts +10 -1
- package/dist/processors/index.js +93 -2
- package/dist/processors/obfProcessor.js +25 -2
- package/dist/processors/obfsetProcessor.d.ts +26 -0
- package/dist/processors/obfsetProcessor.js +179 -0
- package/dist/processors/snapProcessor.js +29 -1
- package/dist/processors/touchchatProcessor.js +27 -0
- package/dist/types/aac.d.ts +21 -0
- package/package.json +1 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Vocabulary Coverage Analysis
|
|
4
|
+
*
|
|
5
|
+
* Analyzes how well an AAC board set covers core vocabulary
|
|
6
|
+
* and identifies missing/extra words compared to reference lists.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.VocabularyAnalyzer = void 0;
|
|
10
|
+
const index_1 = require("../reference/index");
|
|
11
|
+
const effort_1 = require("./effort");
|
|
12
|
+
class VocabularyAnalyzer {
|
|
13
|
+
constructor(referenceLoader) {
|
|
14
|
+
this.referenceLoader = referenceLoader || new index_1.ReferenceLoader();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Analyze vocabulary coverage against core lists
|
|
18
|
+
*/
|
|
19
|
+
analyze(metrics, options) {
|
|
20
|
+
// const locale = options?.locale || metrics.locale || 'en';
|
|
21
|
+
const highEffortThreshold = options?.highEffortThreshold || 5.0;
|
|
22
|
+
const lowEffortThreshold = options?.lowEffortThreshold || 2.0;
|
|
23
|
+
// Load reference data
|
|
24
|
+
const coreLists = this.referenceLoader.loadCoreLists();
|
|
25
|
+
// Create word to effort map
|
|
26
|
+
const wordEffortMap = new Map();
|
|
27
|
+
metrics.buttons.forEach((btn) => {
|
|
28
|
+
const existing = wordEffortMap.get(btn.label);
|
|
29
|
+
if (!existing || btn.effort < existing) {
|
|
30
|
+
wordEffortMap.set(btn.label, btn.effort);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
// Analyze each core list
|
|
34
|
+
const core_coverage = {};
|
|
35
|
+
coreLists.forEach((list) => {
|
|
36
|
+
const analysis = this.analyzeCoreList(list, wordEffortMap);
|
|
37
|
+
core_coverage[list.id] = analysis;
|
|
38
|
+
});
|
|
39
|
+
// Find extra words (words not in any core list)
|
|
40
|
+
const allCoreWords = new Set();
|
|
41
|
+
coreLists.forEach((list) => {
|
|
42
|
+
list.words.forEach((word) => allCoreWords.add(word.toLowerCase()));
|
|
43
|
+
});
|
|
44
|
+
const extraWords = [];
|
|
45
|
+
wordEffortMap.forEach((effort, word) => {
|
|
46
|
+
if (!allCoreWords.has(word.toLowerCase())) {
|
|
47
|
+
extraWords.push(word);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
extraWords.sort((a, b) => a.localeCompare(b));
|
|
51
|
+
// Find high/low effort words
|
|
52
|
+
const highEffortWords = [];
|
|
53
|
+
const lowEffortWords = [];
|
|
54
|
+
wordEffortMap.forEach((effort, word) => {
|
|
55
|
+
if (effort > highEffortThreshold) {
|
|
56
|
+
highEffortWords.push({ word, effort });
|
|
57
|
+
}
|
|
58
|
+
else if (effort < lowEffortThreshold) {
|
|
59
|
+
lowEffortWords.push({ word, effort });
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
highEffortWords.sort((a, b) => b.effort - a.effort);
|
|
63
|
+
lowEffortWords.sort((a, b) => a.effort - b.effort);
|
|
64
|
+
return {
|
|
65
|
+
core_coverage,
|
|
66
|
+
total_unique_words: wordEffortMap.size,
|
|
67
|
+
words_with_effort: wordEffortMap.size,
|
|
68
|
+
words_requiring_spelling: 0, // Calculated during sentence analysis
|
|
69
|
+
extra_words: extraWords,
|
|
70
|
+
high_effort_words: highEffortWords.slice(0, 50), // Top 50
|
|
71
|
+
low_effort_words: lowEffortWords.slice(0, 50), // Bottom 50
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Analyze coverage for a single core list
|
|
76
|
+
*/
|
|
77
|
+
analyzeCoreList(list, wordEffortMap) {
|
|
78
|
+
const covered = [];
|
|
79
|
+
const missing = [];
|
|
80
|
+
let totalEffort = 0;
|
|
81
|
+
list.words.forEach((word) => {
|
|
82
|
+
const effort = wordEffortMap.get(word);
|
|
83
|
+
if (effort !== undefined) {
|
|
84
|
+
covered.push(word);
|
|
85
|
+
totalEffort += effort;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
missing.push(word);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const averageEffort = covered.length > 0 ? totalEffort / covered.length : 0;
|
|
92
|
+
return {
|
|
93
|
+
name: list.name,
|
|
94
|
+
total_words: list.words.length,
|
|
95
|
+
covered: covered.length,
|
|
96
|
+
missing: missing.length,
|
|
97
|
+
coverage_percent: (covered.length / list.words.length) * 100,
|
|
98
|
+
missing_words: missing,
|
|
99
|
+
average_effort: averageEffort,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Calculate coverage percentage for a specific word list
|
|
104
|
+
*/
|
|
105
|
+
calculateCoverage(wordList, metrics) {
|
|
106
|
+
const wordSet = new Set(metrics.buttons.map((btn) => btn.label.toLowerCase()));
|
|
107
|
+
const covered = [];
|
|
108
|
+
const missing = [];
|
|
109
|
+
wordList.forEach((word) => {
|
|
110
|
+
if (wordSet.has(word.toLowerCase())) {
|
|
111
|
+
covered.push(word);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
missing.push(word);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
return {
|
|
118
|
+
covered,
|
|
119
|
+
missing,
|
|
120
|
+
coverage_percent: (covered.length / wordList.length) * 100,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get effort for a word, or calculate spelling effort if missing
|
|
125
|
+
*/
|
|
126
|
+
getWordEffort(word, metrics) {
|
|
127
|
+
const btn = metrics.buttons.find((b) => b.label.toLowerCase() === word.toLowerCase());
|
|
128
|
+
if (btn) {
|
|
129
|
+
return btn.effort;
|
|
130
|
+
}
|
|
131
|
+
return (0, effort_1.spellingEffort)(word);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Check if a word is in the board set
|
|
135
|
+
*/
|
|
136
|
+
hasWord(word, metrics) {
|
|
137
|
+
return metrics.buttons.some((b) => b.label.toLowerCase() === word.toLowerCase());
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.VocabularyAnalyzer = VocabularyAnalyzer;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference Data Loader
|
|
3
|
+
*
|
|
4
|
+
* Loads reference vocabulary lists, core lists, and sentences
|
|
5
|
+
* for AAC metrics analysis.
|
|
6
|
+
*/
|
|
7
|
+
import { CoreList, CommonWordsData, SynonymsData } from '../metrics/types';
|
|
8
|
+
export declare class ReferenceLoader {
|
|
9
|
+
private dataDir;
|
|
10
|
+
private locale;
|
|
11
|
+
constructor(dataDir?: string, locale?: string);
|
|
12
|
+
/**
|
|
13
|
+
* Load core vocabulary lists
|
|
14
|
+
*/
|
|
15
|
+
loadCoreLists(): CoreList[];
|
|
16
|
+
/**
|
|
17
|
+
* Load common words with baseline effort scores
|
|
18
|
+
*/
|
|
19
|
+
loadCommonWords(): CommonWordsData;
|
|
20
|
+
/**
|
|
21
|
+
* Load synonym mappings
|
|
22
|
+
*/
|
|
23
|
+
loadSynonyms(): SynonymsData;
|
|
24
|
+
/**
|
|
25
|
+
* Load test sentences
|
|
26
|
+
*/
|
|
27
|
+
loadSentences(): string[][];
|
|
28
|
+
/**
|
|
29
|
+
* Load fringe vocabulary
|
|
30
|
+
*/
|
|
31
|
+
loadFringe(): string[];
|
|
32
|
+
/**
|
|
33
|
+
* Load base words hash map
|
|
34
|
+
*/
|
|
35
|
+
loadBaseWords(): {
|
|
36
|
+
[word: string]: boolean;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Get all reference data at once
|
|
40
|
+
*/
|
|
41
|
+
loadAll(): {
|
|
42
|
+
coreLists: CoreList[];
|
|
43
|
+
commonWords: CommonWordsData;
|
|
44
|
+
synonyms: SynonymsData;
|
|
45
|
+
sentences: string[][];
|
|
46
|
+
fringe: string[];
|
|
47
|
+
baseWords: {
|
|
48
|
+
[word: string]: boolean;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Reference Data Loader
|
|
4
|
+
*
|
|
5
|
+
* Loads reference vocabulary lists, core lists, and sentences
|
|
6
|
+
* for AAC metrics analysis.
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.ReferenceLoader = void 0;
|
|
33
|
+
const fs = __importStar(require("fs"));
|
|
34
|
+
const path = __importStar(require("path"));
|
|
35
|
+
class ReferenceLoader {
|
|
36
|
+
constructor(dataDir = path.join(__dirname, 'data'), locale = 'en') {
|
|
37
|
+
this.dataDir = dataDir;
|
|
38
|
+
this.locale = locale;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Load core vocabulary lists
|
|
42
|
+
*/
|
|
43
|
+
loadCoreLists() {
|
|
44
|
+
const filePath = path.join(this.dataDir, `core_lists.${this.locale}.json`);
|
|
45
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
46
|
+
return JSON.parse(content);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Load common words with baseline effort scores
|
|
50
|
+
*/
|
|
51
|
+
loadCommonWords() {
|
|
52
|
+
const filePath = path.join(this.dataDir, `common_words.${this.locale}.json`);
|
|
53
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
54
|
+
return JSON.parse(content);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Load synonym mappings
|
|
58
|
+
*/
|
|
59
|
+
loadSynonyms() {
|
|
60
|
+
const filePath = path.join(this.dataDir, `synonyms.${this.locale}.json`);
|
|
61
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
62
|
+
return JSON.parse(content);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Load test sentences
|
|
66
|
+
*/
|
|
67
|
+
loadSentences() {
|
|
68
|
+
const filePath = path.join(this.dataDir, `sentences.${this.locale}.json`);
|
|
69
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
70
|
+
return JSON.parse(content);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Load fringe vocabulary
|
|
74
|
+
*/
|
|
75
|
+
loadFringe() {
|
|
76
|
+
const filePath = path.join(this.dataDir, `fringe.${this.locale}.json`);
|
|
77
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
78
|
+
return JSON.parse(content);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Load base words hash map
|
|
82
|
+
*/
|
|
83
|
+
loadBaseWords() {
|
|
84
|
+
const filePath = path.join(this.dataDir, `base_words.${this.locale}.json`);
|
|
85
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
86
|
+
return JSON.parse(content);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get all reference data at once
|
|
90
|
+
*/
|
|
91
|
+
loadAll() {
|
|
92
|
+
return {
|
|
93
|
+
coreLists: this.loadCoreLists(),
|
|
94
|
+
commonWords: this.loadCommonWords(),
|
|
95
|
+
synonyms: this.loadSynonyms(),
|
|
96
|
+
sentences: this.loadSentences(),
|
|
97
|
+
fringe: this.loadFringe(),
|
|
98
|
+
baseWords: this.loadBaseWords(),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.ReferenceLoader = ReferenceLoader;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ID Generator Utility for AAC Metrics
|
|
3
|
+
*
|
|
4
|
+
* Generates clone_id values based on grid location and button label.
|
|
5
|
+
* Clone IDs help identify buttons that appear in the same location
|
|
6
|
+
* across different boards in an AAC system.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Normalize a label for use in clone_id generation
|
|
10
|
+
* Converts to lowercase, removes apostrophes, trims whitespace
|
|
11
|
+
*
|
|
12
|
+
* @param label - The button label to normalize
|
|
13
|
+
* @returns Normalized label string
|
|
14
|
+
*/
|
|
15
|
+
export declare function normalizeLabelForCloneId(label: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Generate a clone_id based on grid location and button label
|
|
18
|
+
*
|
|
19
|
+
* Clone ID format: "{rows}x{cols}-{row}.{col}-{label_normalized}"
|
|
20
|
+
* Example: "6x4-2.3-more" for button "more" at row 2, col 3 in a 6x4 grid
|
|
21
|
+
*
|
|
22
|
+
* @param rows - Total number of rows in the grid
|
|
23
|
+
* @param cols - Total number of columns in the grid
|
|
24
|
+
* @param row - Zero-based row index of the button
|
|
25
|
+
* @param col - Zero-based column index of the button
|
|
26
|
+
* @param label - The button label
|
|
27
|
+
* @returns A clone_id string
|
|
28
|
+
*/
|
|
29
|
+
export declare function generateCloneId(rows: number, cols: number, row: number, col: number, label: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Generate a semantic_id based on button content
|
|
32
|
+
*
|
|
33
|
+
* Semantic IDs identify buttons with the same semantic meaning across boards.
|
|
34
|
+
* This is a fallback for formats that don't have explicit semantic IDs.
|
|
35
|
+
* Based on hash of message + label
|
|
36
|
+
*
|
|
37
|
+
* @param message - The button message/vocalization
|
|
38
|
+
* @param label - The button label
|
|
39
|
+
* @returns A semantic_id string (hash-based)
|
|
40
|
+
*/
|
|
41
|
+
export declare function generateSemanticId(message: string, label: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* Extract all semantic_ids from a page's buttons
|
|
44
|
+
*
|
|
45
|
+
* @param buttons - Array of buttons to scan
|
|
46
|
+
* @returns Array of unique semantic_id strings
|
|
47
|
+
*/
|
|
48
|
+
export declare function extractSemanticIds(buttons: Array<{
|
|
49
|
+
semantic_id?: string;
|
|
50
|
+
}>): string[];
|
|
51
|
+
/**
|
|
52
|
+
* Extract all clone_ids from a page's buttons
|
|
53
|
+
*
|
|
54
|
+
* @param buttons - Array of buttons to scan
|
|
55
|
+
* @returns Array of unique clone_id strings
|
|
56
|
+
*/
|
|
57
|
+
export declare function extractCloneIds(buttons: Array<{
|
|
58
|
+
clone_id?: string;
|
|
59
|
+
}>): string[];
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ID Generator Utility for AAC Metrics
|
|
4
|
+
*
|
|
5
|
+
* Generates clone_id values based on grid location and button label.
|
|
6
|
+
* Clone IDs help identify buttons that appear in the same location
|
|
7
|
+
* across different boards in an AAC system.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.normalizeLabelForCloneId = normalizeLabelForCloneId;
|
|
11
|
+
exports.generateCloneId = generateCloneId;
|
|
12
|
+
exports.generateSemanticId = generateSemanticId;
|
|
13
|
+
exports.extractSemanticIds = extractSemanticIds;
|
|
14
|
+
exports.extractCloneIds = extractCloneIds;
|
|
15
|
+
/**
|
|
16
|
+
* Normalize a label for use in clone_id generation
|
|
17
|
+
* Converts to lowercase, removes apostrophes, trims whitespace
|
|
18
|
+
*
|
|
19
|
+
* @param label - The button label to normalize
|
|
20
|
+
* @returns Normalized label string
|
|
21
|
+
*/
|
|
22
|
+
function normalizeLabelForCloneId(label) {
|
|
23
|
+
return label
|
|
24
|
+
.toLowerCase()
|
|
25
|
+
.replace(/['']/g, '') // Remove apostrophes
|
|
26
|
+
.replace(/\s+/g, '_') // Replace spaces with underscores
|
|
27
|
+
.trim();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Generate a clone_id based on grid location and button label
|
|
31
|
+
*
|
|
32
|
+
* Clone ID format: "{rows}x{cols}-{row}.{col}-{label_normalized}"
|
|
33
|
+
* Example: "6x4-2.3-more" for button "more" at row 2, col 3 in a 6x4 grid
|
|
34
|
+
*
|
|
35
|
+
* @param rows - Total number of rows in the grid
|
|
36
|
+
* @param cols - Total number of columns in the grid
|
|
37
|
+
* @param row - Zero-based row index of the button
|
|
38
|
+
* @param col - Zero-based column index of the button
|
|
39
|
+
* @param label - The button label
|
|
40
|
+
* @returns A clone_id string
|
|
41
|
+
*/
|
|
42
|
+
function generateCloneId(rows, cols, row, col, label) {
|
|
43
|
+
const normalizedLabel = normalizeLabelForCloneId(label);
|
|
44
|
+
return `${rows}x${cols}-${row}.${col}-${normalizedLabel}`;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Generate a semantic_id based on button content
|
|
48
|
+
*
|
|
49
|
+
* Semantic IDs identify buttons with the same semantic meaning across boards.
|
|
50
|
+
* This is a fallback for formats that don't have explicit semantic IDs.
|
|
51
|
+
* Based on hash of message + label
|
|
52
|
+
*
|
|
53
|
+
* @param message - The button message/vocalization
|
|
54
|
+
* @param label - The button label
|
|
55
|
+
* @returns A semantic_id string (hash-based)
|
|
56
|
+
*/
|
|
57
|
+
function generateSemanticId(message, label) {
|
|
58
|
+
const content = `${message || ''}::${label || ''}`;
|
|
59
|
+
// Simple hash function (djb2 algorithm)
|
|
60
|
+
let hash = 5381;
|
|
61
|
+
for (let i = 0; i < content.length; i++) {
|
|
62
|
+
hash = (hash * 33) ^ content.charCodeAt(i);
|
|
63
|
+
}
|
|
64
|
+
// Convert to positive hex string
|
|
65
|
+
return `semantic_${(hash >>> 0).toString(16)}`;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Extract all semantic_ids from a page's buttons
|
|
69
|
+
*
|
|
70
|
+
* @param buttons - Array of buttons to scan
|
|
71
|
+
* @returns Array of unique semantic_id strings
|
|
72
|
+
*/
|
|
73
|
+
function extractSemanticIds(buttons) {
|
|
74
|
+
const ids = new Set();
|
|
75
|
+
for (const button of buttons) {
|
|
76
|
+
if (button.semantic_id) {
|
|
77
|
+
ids.add(button.semantic_id);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return Array.from(ids);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Extract all clone_ids from a page's buttons
|
|
84
|
+
*
|
|
85
|
+
* @param buttons - Array of buttons to scan
|
|
86
|
+
* @returns Array of unique clone_id strings
|
|
87
|
+
*/
|
|
88
|
+
function extractCloneIds(buttons) {
|
|
89
|
+
const ids = new Set();
|
|
90
|
+
for (const button of buttons) {
|
|
91
|
+
if (button.clone_id) {
|
|
92
|
+
ids.add(button.clone_id);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return Array.from(ids);
|
|
96
|
+
}
|
|
@@ -54,6 +54,24 @@ export declare function toHexColor(value: string): string | undefined;
|
|
|
54
54
|
* @returns Darkened hex color
|
|
55
55
|
*/
|
|
56
56
|
export declare function darkenColor(hex: string, amount: number): string;
|
|
57
|
+
/**
|
|
58
|
+
* Lighten a hex color by a specified amount
|
|
59
|
+
* @param hex - Hex color string
|
|
60
|
+
* @param amount - Amount to lighten (0-255)
|
|
61
|
+
* @returns Lightened hex color
|
|
62
|
+
*/
|
|
63
|
+
export declare function lightenColor(hex: string, amount: number): string;
|
|
64
|
+
/**
|
|
65
|
+
* Convert hex color to RGBA object
|
|
66
|
+
* @param hex - Hex color string (#RRGGBB or #RRGGBBAA)
|
|
67
|
+
* @returns RGBA object with r, g, b, a properties (0-1 for alpha)
|
|
68
|
+
*/
|
|
69
|
+
export declare function hexToRgba(hex: string): {
|
|
70
|
+
r: number;
|
|
71
|
+
g: number;
|
|
72
|
+
b: number;
|
|
73
|
+
a: number;
|
|
74
|
+
};
|
|
57
75
|
/**
|
|
58
76
|
* Normalize any color format to Grid3's 8-digit hex format
|
|
59
77
|
* @param input - Color string in any supported format
|
|
@@ -16,6 +16,8 @@ exports.clampColorChannel = clampColorChannel;
|
|
|
16
16
|
exports.clampAlpha = clampAlpha;
|
|
17
17
|
exports.toHexColor = toHexColor;
|
|
18
18
|
exports.darkenColor = darkenColor;
|
|
19
|
+
exports.lightenColor = lightenColor;
|
|
20
|
+
exports.hexToRgba = hexToRgba;
|
|
19
21
|
exports.normalizeColor = normalizeColor;
|
|
20
22
|
exports.ensureAlphaChannel = ensureAlphaChannel;
|
|
21
23
|
/**
|
|
@@ -288,6 +290,40 @@ function darkenColor(hex, amount) {
|
|
|
288
290
|
const newB = clamp(b - amount);
|
|
289
291
|
return `#${channelToHex(newR)}${channelToHex(newG)}${channelToHex(newB)}${alpha.toUpperCase()}`;
|
|
290
292
|
}
|
|
293
|
+
/**
|
|
294
|
+
* Lighten a hex color by a specified amount
|
|
295
|
+
* @param hex - Hex color string
|
|
296
|
+
* @param amount - Amount to lighten (0-255)
|
|
297
|
+
* @returns Lightened hex color
|
|
298
|
+
*/
|
|
299
|
+
function lightenColor(hex, amount) {
|
|
300
|
+
const normalized = ensureAlphaChannel(hex).substring(1); // strip #
|
|
301
|
+
const rgb = normalized.substring(0, 6);
|
|
302
|
+
const alpha = normalized.substring(6) || 'FF';
|
|
303
|
+
const r = parseInt(rgb.substring(0, 2), 16);
|
|
304
|
+
const g = parseInt(rgb.substring(2, 4), 16);
|
|
305
|
+
const b = parseInt(rgb.substring(4, 6), 16);
|
|
306
|
+
const clamp = (val) => Math.max(0, Math.min(255, val));
|
|
307
|
+
const newR = clamp(r + amount);
|
|
308
|
+
const newG = clamp(g + amount);
|
|
309
|
+
const newB = clamp(b + amount);
|
|
310
|
+
return `#${channelToHex(newR)}${channelToHex(newG)}${channelToHex(newB)}${alpha.toUpperCase()}`;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Convert hex color to RGBA object
|
|
314
|
+
* @param hex - Hex color string (#RRGGBB or #RRGGBBAA)
|
|
315
|
+
* @returns RGBA object with r, g, b, a properties (0-1 for alpha)
|
|
316
|
+
*/
|
|
317
|
+
function hexToRgba(hex) {
|
|
318
|
+
const normalized = ensureAlphaChannel(hex).substring(1); // strip #
|
|
319
|
+
const rgb = normalized.substring(0, 6);
|
|
320
|
+
const alphaHex = normalized.substring(6) || 'FF';
|
|
321
|
+
const r = parseInt(rgb.substring(0, 2), 16);
|
|
322
|
+
const g = parseInt(rgb.substring(2, 4), 16);
|
|
323
|
+
const b = parseInt(rgb.substring(4, 6), 16);
|
|
324
|
+
const a = parseInt(alphaHex, 16) / 255;
|
|
325
|
+
return { r, g, b, a };
|
|
326
|
+
}
|
|
291
327
|
/**
|
|
292
328
|
* Normalize any color format to Grid3's 8-digit hex format
|
|
293
329
|
* @param input - Color string in any supported format
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grid 3 Command Definitions and Detection System
|
|
3
|
+
*
|
|
4
|
+
* This module provides comprehensive metadata for all Grid 3 commands,
|
|
5
|
+
* organized by plugin/category. It enables:
|
|
6
|
+
* - Command detection and classification
|
|
7
|
+
* - Parameter extraction
|
|
8
|
+
* - Future extensibility for command execution
|
|
9
|
+
* - Semantic action mapping
|
|
10
|
+
*
|
|
11
|
+
* Grid 3 has 33+ plugins with 200+ commands. This catalog captures
|
|
12
|
+
* the most commonly used and important commands.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Command categories in Grid 3
|
|
16
|
+
*/
|
|
17
|
+
export declare enum Grid3CommandCategory {
|
|
18
|
+
NAVIGATION = "navigation",
|
|
19
|
+
COMMUNICATION = "communication",
|
|
20
|
+
TEXT_EDITING = "text_editing",
|
|
21
|
+
COMPUTER_CONTROL = "computer_control",
|
|
22
|
+
WEB_BROWSER = "web_browser",
|
|
23
|
+
EMAIL = "email",
|
|
24
|
+
PHONE = "phone",
|
|
25
|
+
SMS = "sms",
|
|
26
|
+
SYSTEM = "system",
|
|
27
|
+
SETTINGS = "settings",
|
|
28
|
+
SPEECH = "speech",
|
|
29
|
+
AUTO_CONTENT = "auto_content",
|
|
30
|
+
ENVIRONMENT_CONTROL = "environment_control",
|
|
31
|
+
MOUSE = "mouse",
|
|
32
|
+
WINDOW = "window",
|
|
33
|
+
MEDIA = "media",
|
|
34
|
+
CUSTOM = "custom"
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Parameter definition for commands
|
|
38
|
+
*/
|
|
39
|
+
export interface CommandParameter {
|
|
40
|
+
key: string;
|
|
41
|
+
type: 'string' | 'number' | 'boolean' | 'grid' | 'color' | 'font';
|
|
42
|
+
required: boolean;
|
|
43
|
+
description?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Command metadata definition
|
|
47
|
+
*/
|
|
48
|
+
export interface Grid3CommandDefinition {
|
|
49
|
+
id: string;
|
|
50
|
+
category: Grid3CommandCategory;
|
|
51
|
+
pluginId: string;
|
|
52
|
+
displayName: string;
|
|
53
|
+
description: string;
|
|
54
|
+
parameters?: CommandParameter[];
|
|
55
|
+
platforms?: ('desktop' | 'ios' | 'medicare' | 'medicareBionics')[];
|
|
56
|
+
deprecated?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Registry of all Grid 3 commands
|
|
60
|
+
* Key is command ID (e.g., 'Jump.To', 'Action.InsertText')
|
|
61
|
+
*/
|
|
62
|
+
export declare const GRID3_COMMANDS: Record<string, Grid3CommandDefinition>;
|
|
63
|
+
/**
|
|
64
|
+
* Get command definition by ID
|
|
65
|
+
*/
|
|
66
|
+
export declare function getCommandDefinition(commandId: string): Grid3CommandDefinition | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Check if a command ID is known
|
|
69
|
+
*/
|
|
70
|
+
export declare function isKnownCommand(commandId: string): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Get all commands for a specific plugin
|
|
73
|
+
*/
|
|
74
|
+
export declare function getCommandsByPlugin(pluginId: string): Grid3CommandDefinition[];
|
|
75
|
+
/**
|
|
76
|
+
* Get all commands in a category
|
|
77
|
+
*/
|
|
78
|
+
export declare function getCommandsByCategory(category: Grid3CommandCategory): Grid3CommandDefinition[];
|
|
79
|
+
/**
|
|
80
|
+
* Get all command IDs
|
|
81
|
+
*/
|
|
82
|
+
export declare function getAllCommandIds(): string[];
|
|
83
|
+
/**
|
|
84
|
+
* Get all plugin IDs that have commands
|
|
85
|
+
*/
|
|
86
|
+
export declare function getAllPluginIds(): string[];
|
|
87
|
+
/**
|
|
88
|
+
* Extract parameters from a Grid 3 command object
|
|
89
|
+
*/
|
|
90
|
+
export interface ExtractedParameters {
|
|
91
|
+
[key: string]: string | number | boolean;
|
|
92
|
+
}
|
|
93
|
+
export declare function extractCommandParameters(command: any): ExtractedParameters;
|
|
94
|
+
/**
|
|
95
|
+
* Detect and categorize a command from Grid 3
|
|
96
|
+
*/
|
|
97
|
+
export declare function detectCommand(commandObj: any): {
|
|
98
|
+
id: string;
|
|
99
|
+
definition?: Grid3CommandDefinition;
|
|
100
|
+
parameters: ExtractedParameters;
|
|
101
|
+
category: Grid3CommandCategory | 'unknown';
|
|
102
|
+
pluginId: string | 'unknown';
|
|
103
|
+
};
|