@willwade/aac-processors 0.0.6 → 0.0.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 (35) hide show
  1. package/README.md +2 -40
  2. package/dist/analytics/history.d.ts +57 -0
  3. package/dist/analytics/history.js +72 -0
  4. package/dist/core/analyze.d.ts +10 -0
  5. package/dist/core/analyze.js +10 -0
  6. package/dist/core/stringCasing.d.ts +11 -0
  7. package/dist/core/stringCasing.js +11 -0
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.js +5 -0
  10. package/dist/processors/dotProcessor.js +31 -12
  11. package/dist/processors/gridset/colorUtils.d.ts +69 -0
  12. package/dist/processors/gridset/colorUtils.js +331 -0
  13. package/dist/processors/gridset/helpers.d.ts +125 -0
  14. package/dist/processors/gridset/helpers.js +354 -0
  15. package/dist/processors/gridset/styleHelpers.d.ts +3 -4
  16. package/dist/processors/gridset/styleHelpers.js +10 -44
  17. package/dist/processors/index.d.ts +6 -4
  18. package/dist/processors/index.js +51 -3
  19. package/dist/processors/obfProcessor.js +10 -2
  20. package/dist/processors/snap/helpers.d.ts +85 -0
  21. package/dist/processors/snap/helpers.js +259 -2
  22. package/dist/processors/snapProcessor.js +27 -5
  23. package/dist/processors/touchchat/helpers.d.ts +12 -0
  24. package/dist/processors/touchchat/helpers.js +12 -2
  25. package/dist/utils/dotnetTicks.d.ts +13 -0
  26. package/dist/utils/dotnetTicks.js +21 -0
  27. package/package.json +8 -6
  28. package/docs/.keep +0 -1
  29. package/docs/ApplePanels.md +0 -309
  30. package/docs/Grid3-Styling-Guide.md +0 -287
  31. package/docs/Grid3-XML-Format.md +0 -1788
  32. package/docs/TobiiDynavox-Snap-Details.md +0 -394
  33. package/docs/asterics-Grid-fileformat-details.md +0 -443
  34. package/docs/obf_.obz Open Board File Formats.md +0 -432
  35. package/docs/touchchat.md +0 -520
@@ -0,0 +1,331 @@
1
+ "use strict";
2
+ /**
3
+ * Grid3 Color Utilities
4
+ *
5
+ * Comprehensive color handling for Grid3 format, including:
6
+ * - CSS color name lookup (147 named colors)
7
+ * - Color format conversion (hex, RGB, RGBA, named colors)
8
+ * - Color manipulation (darkening, normalization)
9
+ * - Grid3-specific color formatting (8-digit ARGB hex)
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getNamedColor = getNamedColor;
13
+ exports.rgbaToHex = rgbaToHex;
14
+ exports.channelToHex = channelToHex;
15
+ exports.clampColorChannel = clampColorChannel;
16
+ exports.clampAlpha = clampAlpha;
17
+ exports.toHexColor = toHexColor;
18
+ exports.darkenColor = darkenColor;
19
+ exports.normalizeColor = normalizeColor;
20
+ exports.ensureAlphaChannel = ensureAlphaChannel;
21
+ /**
22
+ * CSS color names to RGB values
23
+ * Supports 147 standard CSS color names
24
+ */
25
+ const CSS_COLORS = {
26
+ aliceblue: [240, 248, 255],
27
+ antiquewhite: [250, 235, 215],
28
+ aqua: [0, 255, 255],
29
+ aquamarine: [127, 255, 212],
30
+ azure: [240, 255, 255],
31
+ beige: [245, 245, 220],
32
+ bisque: [255, 228, 196],
33
+ black: [0, 0, 0],
34
+ blanchedalmond: [255, 235, 205],
35
+ blue: [0, 0, 255],
36
+ blueviolet: [138, 43, 226],
37
+ brown: [165, 42, 42],
38
+ burlywood: [222, 184, 135],
39
+ cadetblue: [95, 158, 160],
40
+ chartreuse: [127, 255, 0],
41
+ chocolate: [210, 105, 30],
42
+ coral: [255, 127, 80],
43
+ cornflowerblue: [100, 149, 237],
44
+ cornsilk: [255, 248, 220],
45
+ crimson: [220, 20, 60],
46
+ cyan: [0, 255, 255],
47
+ darkblue: [0, 0, 139],
48
+ darkcyan: [0, 139, 139],
49
+ darkgoldenrod: [184, 134, 11],
50
+ darkgray: [169, 169, 169],
51
+ darkgreen: [0, 100, 0],
52
+ darkgrey: [169, 169, 169],
53
+ darkkhaki: [189, 183, 107],
54
+ darkmagenta: [139, 0, 139],
55
+ darkolivegreen: [85, 107, 47],
56
+ darkorange: [255, 140, 0],
57
+ darkorchid: [153, 50, 204],
58
+ darkred: [139, 0, 0],
59
+ darksalmon: [233, 150, 122],
60
+ darkseagreen: [143, 188, 143],
61
+ darkslateblue: [72, 61, 139],
62
+ darkslategray: [47, 79, 79],
63
+ darkslategrey: [47, 79, 79],
64
+ darkturquoise: [0, 206, 209],
65
+ darkviolet: [148, 0, 211],
66
+ deeppink: [255, 20, 147],
67
+ deepskyblue: [0, 191, 255],
68
+ dimgray: [105, 105, 105],
69
+ dimgrey: [105, 105, 105],
70
+ dodgerblue: [30, 144, 255],
71
+ firebrick: [178, 34, 34],
72
+ floralwhite: [255, 250, 240],
73
+ forestgreen: [34, 139, 34],
74
+ fuchsia: [255, 0, 255],
75
+ gainsboro: [220, 220, 220],
76
+ ghostwhite: [248, 248, 255],
77
+ gold: [255, 215, 0],
78
+ goldenrod: [218, 165, 32],
79
+ gray: [128, 128, 128],
80
+ grey: [128, 128, 128],
81
+ green: [0, 128, 0],
82
+ greenyellow: [173, 255, 47],
83
+ honeydew: [240, 255, 240],
84
+ hotpink: [255, 105, 180],
85
+ indianred: [205, 92, 92],
86
+ indigo: [75, 0, 130],
87
+ ivory: [255, 255, 240],
88
+ khaki: [240, 230, 140],
89
+ lavender: [230, 230, 250],
90
+ lavenderblush: [255, 240, 245],
91
+ lawngreen: [124, 252, 0],
92
+ lemonchiffon: [255, 250, 205],
93
+ lightblue: [173, 216, 230],
94
+ lightcoral: [240, 128, 128],
95
+ lightcyan: [224, 255, 255],
96
+ lightgoldenrodyellow: [250, 250, 210],
97
+ lightgray: [211, 211, 211],
98
+ lightgreen: [144, 238, 144],
99
+ lightgrey: [211, 211, 211],
100
+ lightpink: [255, 182, 193],
101
+ lightsalmon: [255, 160, 122],
102
+ lightseagreen: [32, 178, 170],
103
+ lightskyblue: [135, 206, 250],
104
+ lightslategray: [119, 136, 153],
105
+ lightslategrey: [119, 136, 153],
106
+ lightsteelblue: [176, 196, 222],
107
+ lightyellow: [255, 255, 224],
108
+ lime: [0, 255, 0],
109
+ limegreen: [50, 205, 50],
110
+ linen: [250, 240, 230],
111
+ magenta: [255, 0, 255],
112
+ maroon: [128, 0, 0],
113
+ mediumaquamarine: [102, 205, 170],
114
+ mediumblue: [0, 0, 205],
115
+ mediumorchid: [186, 85, 211],
116
+ mediumpurple: [147, 112, 219],
117
+ mediumseagreen: [60, 179, 113],
118
+ mediumslateblue: [123, 104, 238],
119
+ mediumspringgreen: [0, 250, 154],
120
+ mediumturquoise: [72, 209, 204],
121
+ mediumvioletred: [199, 21, 133],
122
+ midnightblue: [25, 25, 112],
123
+ mintcream: [245, 255, 250],
124
+ mistyrose: [255, 228, 225],
125
+ moccasin: [255, 228, 181],
126
+ navajowhite: [255, 222, 173],
127
+ navy: [0, 0, 128],
128
+ oldlace: [253, 245, 230],
129
+ olive: [128, 128, 0],
130
+ olivedrab: [107, 142, 35],
131
+ orange: [255, 165, 0],
132
+ orangered: [255, 69, 0],
133
+ orchid: [218, 112, 214],
134
+ palegoldenrod: [238, 232, 170],
135
+ palegreen: [152, 251, 152],
136
+ paleturquoise: [175, 238, 238],
137
+ palevioletred: [219, 112, 147],
138
+ papayawhip: [255, 239, 213],
139
+ peachpuff: [255, 218, 185],
140
+ peru: [205, 133, 63],
141
+ pink: [255, 192, 203],
142
+ plum: [221, 160, 221],
143
+ powderblue: [176, 224, 230],
144
+ purple: [128, 0, 128],
145
+ rebeccapurple: [102, 51, 153],
146
+ red: [255, 0, 0],
147
+ rosybrown: [188, 143, 143],
148
+ royalblue: [65, 105, 225],
149
+ saddlebrown: [139, 69, 19],
150
+ salmon: [250, 128, 114],
151
+ sandybrown: [244, 164, 96],
152
+ seagreen: [46, 139, 87],
153
+ seashell: [255, 245, 238],
154
+ sienna: [160, 82, 45],
155
+ silver: [192, 192, 192],
156
+ skyblue: [135, 206, 235],
157
+ slateblue: [106, 90, 205],
158
+ slategray: [112, 128, 144],
159
+ slategrey: [112, 128, 144],
160
+ snow: [255, 250, 250],
161
+ springgreen: [0, 255, 127],
162
+ steelblue: [70, 130, 180],
163
+ tan: [210, 180, 140],
164
+ teal: [0, 128, 128],
165
+ thistle: [216, 191, 216],
166
+ tomato: [255, 99, 71],
167
+ turquoise: [64, 224, 208],
168
+ violet: [238, 130, 238],
169
+ wheat: [245, 222, 179],
170
+ white: [255, 255, 255],
171
+ whitesmoke: [245, 245, 245],
172
+ yellow: [255, 255, 0],
173
+ yellowgreen: [154, 205, 50],
174
+ };
175
+ /**
176
+ * Get RGB values for a CSS color name
177
+ * @param name - CSS color name (case-insensitive)
178
+ * @returns RGB tuple [r, g, b] or undefined if not found
179
+ */
180
+ function getNamedColor(name) {
181
+ const color = CSS_COLORS[name.toLowerCase()];
182
+ return color;
183
+ }
184
+ /**
185
+ * Convert RGBA values to hex format
186
+ * @param r - Red channel (0-255)
187
+ * @param g - Green channel (0-255)
188
+ * @param b - Blue channel (0-255)
189
+ * @param a - Alpha channel (0-1)
190
+ * @returns Hex color string in format #RRGGBBAA
191
+ */
192
+ function rgbaToHex(r, g, b, a) {
193
+ const red = channelToHex(r);
194
+ const green = channelToHex(g);
195
+ const blue = channelToHex(b);
196
+ const alpha = channelToHex(Math.round(a * 255));
197
+ return `#${red}${green}${blue}${alpha}`;
198
+ }
199
+ /**
200
+ * Convert a single color channel value to hex
201
+ * @param value - Channel value (0-255)
202
+ * @returns Two-digit hex string
203
+ */
204
+ function channelToHex(value) {
205
+ const clamped = Math.max(0, Math.min(255, Math.round(value)));
206
+ return clamped.toString(16).padStart(2, '0').toUpperCase();
207
+ }
208
+ /**
209
+ * Clamp RGB channel value to valid range
210
+ * @param value - Channel value
211
+ * @returns Clamped value (0-255)
212
+ */
213
+ function clampColorChannel(value) {
214
+ if (Number.isNaN(value)) {
215
+ return 0;
216
+ }
217
+ return Math.max(0, Math.min(255, value));
218
+ }
219
+ /**
220
+ * Clamp alpha value to valid range
221
+ * @param value - Alpha value
222
+ * @returns Clamped value (0-1)
223
+ */
224
+ function clampAlpha(value) {
225
+ if (Number.isNaN(value)) {
226
+ return 1;
227
+ }
228
+ return Math.max(0, Math.min(1, value));
229
+ }
230
+ /**
231
+ * Convert any color format to hex
232
+ * Supports: hex (#RGB, #RRGGBB, #RRGGBBAA), RGB/RGBA, and CSS color names
233
+ * @param value - Color string in any supported format
234
+ * @returns Hex color string (#RRGGBBAA) or undefined if invalid
235
+ */
236
+ function toHexColor(value) {
237
+ // Try hex format
238
+ const hexMatch = value.match(/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i);
239
+ if (hexMatch) {
240
+ const hex = hexMatch[1];
241
+ if (hex.length === 3 || hex.length === 4) {
242
+ return `#${hex
243
+ .split('')
244
+ .map((char) => char + char)
245
+ .join('')}`;
246
+ }
247
+ return `#${hex}`;
248
+ }
249
+ // Try RGB/RGBA format
250
+ const rgbMatch = value.match(/^rgba?\((.+)\)$/i);
251
+ if (rgbMatch) {
252
+ const parts = rgbMatch[1]
253
+ .split(',')
254
+ .map((part) => part.trim())
255
+ .filter(Boolean);
256
+ if (parts.length === 3 || parts.length === 4) {
257
+ const [r, g, b, a] = parts;
258
+ const red = clampColorChannel(parseFloat(r));
259
+ const green = clampColorChannel(parseFloat(g));
260
+ const blue = clampColorChannel(parseFloat(b));
261
+ const alpha = parts.length === 4 ? clampAlpha(parseFloat(a)) : 1;
262
+ return rgbaToHex(red, green, blue, alpha);
263
+ }
264
+ }
265
+ // Try CSS color name
266
+ const rgb = getNamedColor(value);
267
+ if (rgb) {
268
+ return rgbaToHex(rgb[0], rgb[1], rgb[2], 1);
269
+ }
270
+ return undefined;
271
+ }
272
+ /**
273
+ * Darken a hex color by a specified amount
274
+ * @param hex - Hex color string
275
+ * @param amount - Amount to darken (0-255)
276
+ * @returns Darkened hex color
277
+ */
278
+ function darkenColor(hex, amount) {
279
+ const normalized = ensureAlphaChannel(hex).substring(1); // strip #
280
+ const rgb = normalized.substring(0, 6);
281
+ const alpha = normalized.substring(6) || 'FF';
282
+ const r = parseInt(rgb.substring(0, 2), 16);
283
+ const g = parseInt(rgb.substring(2, 4), 16);
284
+ const b = parseInt(rgb.substring(4, 6), 16);
285
+ const clamp = (val) => Math.max(0, Math.min(255, val));
286
+ const newR = clamp(r - amount);
287
+ const newG = clamp(g - amount);
288
+ const newB = clamp(b - amount);
289
+ return `#${channelToHex(newR)}${channelToHex(newG)}${channelToHex(newB)}${alpha.toUpperCase()}`;
290
+ }
291
+ /**
292
+ * Normalize any color format to Grid3's 8-digit hex format
293
+ * @param input - Color string in any supported format
294
+ * @param fallback - Fallback color if input is invalid (default: white)
295
+ * @returns Normalized color in format #AARRGGBBFF
296
+ */
297
+ function normalizeColor(input, fallback = '#FFFFFFFF') {
298
+ const trimmed = input.trim();
299
+ if (!trimmed) {
300
+ return fallback;
301
+ }
302
+ const hex = toHexColor(trimmed);
303
+ if (hex) {
304
+ return ensureAlphaChannel(hex).toUpperCase();
305
+ }
306
+ return fallback;
307
+ }
308
+ /**
309
+ * Ensure a color has an alpha channel (Grid3 format requires 8-digit ARGB)
310
+ * @param color - Color string (hex format)
311
+ * @returns Color with alpha channel in format #AARRGGBBFF
312
+ */
313
+ function ensureAlphaChannel(color) {
314
+ if (!color)
315
+ return '#FFFFFFFF';
316
+ // If already 8 digits (with alpha), return as is
317
+ if (color.match(/^#[0-9A-Fa-f]{8}$/))
318
+ return color;
319
+ // If 6 digits (no alpha), add FF for fully opaque
320
+ if (color.match(/^#[0-9A-Fa-f]{6}$/))
321
+ return color + 'FF';
322
+ // If 3 digits (shorthand), expand to 8
323
+ if (color.match(/^#[0-9A-Fa-f]{3}$/)) {
324
+ const r = color[1];
325
+ const g = color[2];
326
+ const b = color[3];
327
+ return `#${r}${r}${g}${g}${b}${b}FF`;
328
+ }
329
+ // Invalid or unknown format, return white
330
+ return '#FFFFFFFF';
331
+ }
@@ -1,4 +1,129 @@
1
1
  import { AACTree } from '../../core/treeStructure';
2
+ /**
3
+ * Build a map of button IDs to resolved image entry paths for a specific page.
4
+ * Helpful when rewriting zip entry names or validating images referenced in a grid.
5
+ */
2
6
  export declare function getPageTokenImageMap(tree: AACTree, pageId: string): Map<string, string>;
7
+ /**
8
+ * Collect all image entries referenced across every page in a tree.
9
+ * Returns normalized zip entry paths that should be preserved when pruning images.
10
+ */
3
11
  export declare function getAllowedImageEntries(tree: AACTree): Set<string>;
12
+ /**
13
+ * Read an image entry from a gridset zip by path.
14
+ * @param gridsetBuffer Gridset archive contents
15
+ * @param entryPath Entry name inside the zip
16
+ * @returns Image data buffer or null if not found
17
+ */
4
18
  export declare function openImage(gridsetBuffer: Buffer, entryPath: string): Buffer | null;
19
+ /**
20
+ * Generate a random GUID for Grid3 elements
21
+ * Grid3 uses GUIDs for grid identification
22
+ * @returns A UUID v4-like string in the format xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
23
+ */
24
+ export declare function generateGrid3Guid(): string;
25
+ /**
26
+ * Create Grid3 settings XML with start grid and common settings
27
+ * @param startGrid - Name of the grid to start on
28
+ * @param options - Optional settings (scan, hover, language, etc.)
29
+ * @returns XML string for Settings.xml
30
+ */
31
+ export declare function createSettingsXml(startGrid: string, options?: {
32
+ scanEnabled?: boolean;
33
+ scanTimeoutMs?: number;
34
+ hoverEnabled?: boolean;
35
+ hoverTimeoutMs?: number;
36
+ mouseclickEnabled?: boolean;
37
+ language?: string;
38
+ }): string;
39
+ /**
40
+ * Create Grid3 FileMap.xml content
41
+ * @param grids - Array of grid configurations with name and path
42
+ * @returns XML string for FileMap.xml
43
+ */
44
+ export declare function createFileMapXml(grids: Array<{
45
+ name: string;
46
+ path: string;
47
+ dynamicFiles?: string[];
48
+ }>): string;
49
+ /**
50
+ * Grid3 user data path information
51
+ */
52
+ export interface Grid3UserPath {
53
+ userName: string;
54
+ langCode: string;
55
+ basePath: string;
56
+ historyDbPath: string;
57
+ }
58
+ export interface Grid3VocabularyPath {
59
+ userName: string;
60
+ gridsetPath: string;
61
+ }
62
+ export interface Grid3HistoryEntry {
63
+ id: string;
64
+ content: string;
65
+ occurrences: Array<{
66
+ timestamp: Date;
67
+ latitude?: number | null;
68
+ longitude?: number | null;
69
+ }>;
70
+ rawXml?: string;
71
+ }
72
+ /**
73
+ * Get the Windows Common Documents folder path from registry
74
+ * Falls back to default path if registry access fails
75
+ * @returns Path to Common Documents folder
76
+ */
77
+ export declare function getCommonDocumentsPath(): string;
78
+ /**
79
+ * Find all Grid3 user data paths
80
+ * Searches for users and language codes in the Grid3 directory structure
81
+ * C:\Users\Public\Documents\Smartbox\Grid 3\Users\{UserName}\{langCode}\Phrases\history.sqlite
82
+ * @returns Array of Grid3 user path information
83
+ */
84
+ export declare function findGrid3UserPaths(): Grid3UserPath[];
85
+ /**
86
+ * Find all Grid3 history database paths
87
+ * Convenience method that returns just the database file paths
88
+ * @returns Array of paths to history.sqlite files
89
+ */
90
+ export declare function findGrid3HistoryDatabases(): string[];
91
+ /**
92
+ * Get Grid 3 users (alias of findGrid3UserPaths for clarity)
93
+ */
94
+ export declare function findGrid3Users(): Grid3UserPath[];
95
+ /**
96
+ * Find Grid 3 gridset/vocabulary files for each user
97
+ * @param userName Optional user filter; matches case-insensitively
98
+ * @returns Array of user/gridset path pairs
99
+ */
100
+ export declare function findGrid3Vocabularies(userName?: string): Grid3VocabularyPath[];
101
+ /**
102
+ * Find a specific user's Grid 3 history database
103
+ * @param userName User name to search for (case-insensitive)
104
+ * @param langCode Optional language code filter (case-insensitive)
105
+ * @returns Path to history.sqlite or null if not found
106
+ */
107
+ export declare function findGrid3UserHistory(userName: string, langCode?: string): string | null;
108
+ /**
109
+ * Check whether Grid 3 appears to be installed (Windows only)
110
+ */
111
+ export declare function isGrid3Installed(): boolean;
112
+ /**
113
+ * Read history events from a Grid 3 history.sqlite database.
114
+ * @param historyDbPath Absolute path to the history database
115
+ * @returns Parsed history entries grouped by phrase
116
+ */
117
+ export declare function readGrid3History(historyDbPath: string): Grid3HistoryEntry[];
118
+ /**
119
+ * Convenience wrapper to load history for a specific Grid 3 user/lang combination.
120
+ * @param userName Grid 3 user name (case-insensitive)
121
+ * @param langCode Optional language code to narrow selection (case-insensitive)
122
+ * @returns History entries for that user/language, or empty array if none
123
+ */
124
+ export declare function readGrid3HistoryForUser(userName: string, langCode?: string): Grid3HistoryEntry[];
125
+ /**
126
+ * Load all available Grid 3 histories on the machine.
127
+ * @returns Combined history entries from every discovered history.sqlite
128
+ */
129
+ export declare function readAllGrid3History(): Grid3HistoryEntry[];