@willwade/aac-processors 0.0.5 → 0.0.7

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.
@@ -2,3 +2,33 @@ import { AACTree } from '../../core/treeStructure';
2
2
  export declare function getPageTokenImageMap(tree: AACTree, pageId: string): Map<string, string>;
3
3
  export declare function getAllowedImageEntries(tree: AACTree): Set<string>;
4
4
  export declare function openImage(gridsetBuffer: Buffer, entryPath: string): Buffer | null;
5
+ /**
6
+ * Generate a random GUID for Grid3 elements
7
+ * Grid3 uses GUIDs for grid identification
8
+ * @returns A UUID v4-like string in the format xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
9
+ */
10
+ export declare function generateGrid3Guid(): string;
11
+ /**
12
+ * Create Grid3 settings XML with start grid and common settings
13
+ * @param startGrid - Name of the grid to start on
14
+ * @param options - Optional settings (scan, hover, language, etc.)
15
+ * @returns XML string for Settings.xml
16
+ */
17
+ export declare function createSettingsXml(startGrid: string, options?: {
18
+ scanEnabled?: boolean;
19
+ scanTimeoutMs?: number;
20
+ hoverEnabled?: boolean;
21
+ hoverTimeoutMs?: number;
22
+ mouseclickEnabled?: boolean;
23
+ language?: string;
24
+ }): string;
25
+ /**
26
+ * Create Grid3 FileMap.xml content
27
+ * @param grids - Array of grid configurations with name and path
28
+ * @returns XML string for FileMap.xml
29
+ */
30
+ export declare function createFileMapXml(grids: Array<{
31
+ name: string;
32
+ path: string;
33
+ dynamicFiles?: string[];
34
+ }>): string;
@@ -6,7 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getPageTokenImageMap = getPageTokenImageMap;
7
7
  exports.getAllowedImageEntries = getAllowedImageEntries;
8
8
  exports.openImage = openImage;
9
+ exports.generateGrid3Guid = generateGrid3Guid;
10
+ exports.createSettingsXml = createSettingsXml;
11
+ exports.createFileMapXml = createFileMapXml;
9
12
  const adm_zip_1 = __importDefault(require("adm-zip"));
13
+ const fast_xml_parser_1 = require("fast-xml-parser");
10
14
  function normalizeZipPath(p) {
11
15
  const unified = p.replace(/\\/g, '/');
12
16
  try {
@@ -46,3 +50,68 @@ function openImage(gridsetBuffer, entryPath) {
46
50
  return null;
47
51
  return entry.getData();
48
52
  }
53
+ /**
54
+ * Generate a random GUID for Grid3 elements
55
+ * Grid3 uses GUIDs for grid identification
56
+ * @returns A UUID v4-like string in the format xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
57
+ */
58
+ function generateGrid3Guid() {
59
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
60
+ const r = (Math.random() * 16) | 0;
61
+ const v = c === 'x' ? r : (r & 0x3) | 0x8;
62
+ return v.toString(16);
63
+ });
64
+ }
65
+ /**
66
+ * Create Grid3 settings XML with start grid and common settings
67
+ * @param startGrid - Name of the grid to start on
68
+ * @param options - Optional settings (scan, hover, language, etc.)
69
+ * @returns XML string for Settings.xml
70
+ */
71
+ function createSettingsXml(startGrid, options) {
72
+ const builder = new fast_xml_parser_1.XMLBuilder({
73
+ ignoreAttributes: false,
74
+ format: true,
75
+ indentBy: ' ',
76
+ });
77
+ const settingsData = {
78
+ GridSetSettings: {
79
+ '@_xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
80
+ StartGrid: startGrid,
81
+ ScanEnabled: options?.scanEnabled?.toString() ?? 'false',
82
+ ScanTimeoutMs: options?.scanTimeoutMs?.toString() ?? '2000',
83
+ HoverEnabled: options?.hoverEnabled?.toString() ?? 'false',
84
+ HoverTimeoutMs: options?.hoverTimeoutMs?.toString() ?? '1000',
85
+ MouseclickEnabled: options?.mouseclickEnabled?.toString() ?? 'true',
86
+ Language: options?.language ?? 'en-US',
87
+ },
88
+ };
89
+ return builder.build(settingsData);
90
+ }
91
+ /**
92
+ * Create Grid3 FileMap.xml content
93
+ * @param grids - Array of grid configurations with name and path
94
+ * @returns XML string for FileMap.xml
95
+ */
96
+ function createFileMapXml(grids) {
97
+ const builder = new fast_xml_parser_1.XMLBuilder({
98
+ ignoreAttributes: false,
99
+ format: true,
100
+ indentBy: ' ',
101
+ });
102
+ const entries = grids.map((grid) => ({
103
+ '@_StaticFile': grid.path,
104
+ ...(grid.dynamicFiles && grid.dynamicFiles.length > 0
105
+ ? { DynamicFiles: { File: grid.dynamicFiles } }
106
+ : {}),
107
+ }));
108
+ const fileMapData = {
109
+ FileMap: {
110
+ '@_xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
111
+ Entries: {
112
+ Entry: entries,
113
+ },
114
+ },
115
+ };
116
+ return builder.build(fileMapData);
117
+ }
@@ -25,11 +25,10 @@ export declare const DEFAULT_GRID3_STYLES: Record<string, Grid3Style>;
25
25
  */
26
26
  export declare const CATEGORY_STYLES: Record<string, Grid3Style>;
27
27
  /**
28
- * Ensure a color has an alpha channel (Grid3 format requires 8-digit ARGB)
29
- * @param color - Color string (hex format)
30
- * @returns Color with alpha channel in format #AARRGGBBFF
28
+ * Re-export ensureAlphaChannel from colorUtils for backward compatibility
29
+ * @deprecated Use ensureAlphaChannel from colorUtils instead
31
30
  */
32
- export declare function ensureAlphaChannel(color: string | undefined): string;
31
+ export { ensureAlphaChannel } from './colorUtils';
33
32
  /**
34
33
  * Create a Grid3 style XML string with default and category styles
35
34
  * @param includeCategories - Whether to include category-specific styles (default: true)
@@ -6,11 +6,11 @@
6
6
  * style XML generation, and style conversion utilities.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.CATEGORY_STYLES = exports.DEFAULT_GRID3_STYLES = void 0;
10
- exports.ensureAlphaChannel = ensureAlphaChannel;
9
+ exports.ensureAlphaChannel = exports.CATEGORY_STYLES = exports.DEFAULT_GRID3_STYLES = void 0;
11
10
  exports.createDefaultStylesXml = createDefaultStylesXml;
12
11
  exports.createCategoryStyle = createCategoryStyle;
13
12
  const fast_xml_parser_1 = require("fast-xml-parser");
13
+ const colorUtils_1 = require("./colorUtils");
14
14
  /**
15
15
  * Default Grid3 styles for common use cases
16
16
  * Colors are in 8-digit ARGB hex format (#AARRGGBBFF)
@@ -119,29 +119,11 @@ exports.CATEGORY_STYLES = {
119
119
  },
120
120
  };
121
121
  /**
122
- * Ensure a color has an alpha channel (Grid3 format requires 8-digit ARGB)
123
- * @param color - Color string (hex format)
124
- * @returns Color with alpha channel in format #AARRGGBBFF
122
+ * Re-export ensureAlphaChannel from colorUtils for backward compatibility
123
+ * @deprecated Use ensureAlphaChannel from colorUtils instead
125
124
  */
126
- function ensureAlphaChannel(color) {
127
- if (!color)
128
- return '#FFFFFFFF';
129
- // If already 8 digits (with alpha), return as is
130
- if (color.match(/^#[0-9A-Fa-f]{8}$/))
131
- return color;
132
- // If 6 digits (no alpha), add FF for fully opaque
133
- if (color.match(/^#[0-9A-Fa-f]{6}$/))
134
- return color + 'FF';
135
- // If 3 digits (shorthand), expand to 8
136
- if (color.match(/^#[0-9A-Fa-f]{3}$/)) {
137
- const r = color[1];
138
- const g = color[2];
139
- const b = color[3];
140
- return `#${r}${r}${g}${g}${b}${b}FF`;
141
- }
142
- // Invalid or unknown format, return white
143
- return '#FFFFFFFF';
144
- }
125
+ var colorUtils_2 = require("./colorUtils");
126
+ Object.defineProperty(exports, "ensureAlphaChannel", { enumerable: true, get: function () { return colorUtils_2.ensureAlphaChannel; } });
145
127
  /**
146
128
  * Create a Grid3 style XML string with default and category styles
147
129
  * @param includeCategories - Whether to include category-specific styles (default: true)
@@ -185,27 +167,11 @@ function createDefaultStylesXml(includeCategories = true) {
185
167
  */
186
168
  function createCategoryStyle(categoryName, backgroundColor, fontColor = '#FFFFFFFF') {
187
169
  return {
188
- BackColour: ensureAlphaChannel(backgroundColor),
189
- TileColour: ensureAlphaChannel(backgroundColor),
190
- BorderColour: ensureAlphaChannel(darkenColor(backgroundColor, 30)),
191
- FontColour: ensureAlphaChannel(fontColor),
170
+ BackColour: (0, colorUtils_1.ensureAlphaChannel)(backgroundColor),
171
+ TileColour: (0, colorUtils_1.ensureAlphaChannel)(backgroundColor),
172
+ BorderColour: (0, colorUtils_1.ensureAlphaChannel)((0, colorUtils_1.darkenColor)(backgroundColor, 30)),
173
+ FontColour: (0, colorUtils_1.ensureAlphaChannel)(fontColor),
192
174
  FontName: 'Arial',
193
175
  FontSize: '16',
194
176
  };
195
177
  }
196
- /**
197
- * Darken a hex color by a given amount
198
- * @param hexColor - Hex color string
199
- * @param amount - Amount to darken (0-255)
200
- * @returns Darkened hex color
201
- */
202
- function darkenColor(hexColor, amount) {
203
- const normalized = ensureAlphaChannel(hexColor);
204
- const hex = normalized.slice(1, 7); // Extract RGB part (skip # and alpha)
205
- const num = parseInt(hex, 16);
206
- const clamp = (value) => Math.max(0, Math.min(255, value));
207
- const r = clamp(((num >> 16) & 0xff) - amount);
208
- const g = clamp(((num >> 8) & 0xff) - amount);
209
- const b = clamp((num & 0xff) - amount);
210
- return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`;
211
- }
@@ -49,7 +49,7 @@ function createWordlist(input) {
49
49
  }
50
50
  else if (typeof input === 'object') {
51
51
  // Handle dictionary/object input
52
- items = Object.entries(input).map(([key, value]) => {
52
+ items = Object.entries(input).map(([, value]) => {
53
53
  if (typeof value === 'string') {
54
54
  return { text: value };
55
55
  }
@@ -222,7 +222,8 @@ function updateWordlist(gridsetBuffer, gridName, wordlist) {
222
222
  found = true;
223
223
  }
224
224
  catch (error) {
225
- throw new Error(`Failed to update wordlist in grid "${gridName}": ${error}`);
225
+ const message = error instanceof Error ? error.message : String(error);
226
+ throw new Error(`Failed to update wordlist in grid "${gridName}": ${message}`);
226
227
  }
227
228
  }
228
229
  }
@@ -56,7 +56,7 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
56
56
  r: text,
57
57
  },
58
58
  {
59
- r: { '__cdata': ' ' },
59
+ r: { __cdata: ' ' },
60
60
  },
61
61
  ],
62
62
  },
@@ -131,92 +131,85 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
131
131
  },
132
132
  };
133
133
  case 'SPEAK_TEXT':
134
- case 'SPEAK_IMMEDIATE':
135
- // For communication buttons, insert text into message bar (sentence building)
136
- // Grid3 requires explicit trailing space for automatic word spacing
137
- // Use two <s> elements: one for the word, one for the space (CDATA preserves whitespace)
138
- // Users can speak the complete sentence with a dedicated Speak button
139
- {
140
- let text = semanticAction.text || button.message || button.label || '';
141
- // Remove trailing space from message if present (we'll add it as separate segment)
142
- if (text.endsWith(' ')) {
143
- text = text.slice(0, -1);
144
- }
145
- return {
146
- Command: {
147
- '@_ID': 'Action.InsertText',
148
- Parameter: {
149
- '@_Key': 'text',
150
- p: {
151
- s: [
152
- {
153
- r: text,
154
- },
155
- {
156
- r: { '__cdata': ' ' },
157
- },
158
- ],
159
- },
134
+ case 'SPEAK_IMMEDIATE': {
135
+ // Users can speak the complete sentence with a dedicated Speak button // Use two <s> elements: one for the word, one for the space (CDATA preserves whitespace) // Grid3 requires explicit trailing space for automatic word spacing // For communication buttons, insert text into message bar (sentence building)
136
+ let text = semanticAction.text || button.message || button.label || '';
137
+ // Remove trailing space from message if present (we'll add it as separate segment)
138
+ if (text.endsWith(' ')) {
139
+ text = text.slice(0, -1);
140
+ }
141
+ return {
142
+ Command: {
143
+ '@_ID': 'Action.InsertText',
144
+ Parameter: {
145
+ '@_Key': 'text',
146
+ p: {
147
+ s: [
148
+ {
149
+ r: text,
150
+ },
151
+ {
152
+ r: { __cdata: ' ' },
153
+ },
154
+ ],
160
155
  },
161
156
  },
162
- };
157
+ },
158
+ };
159
+ }
160
+ case 'INSERT_TEXT': {
161
+ // Use two <s> elements: one for the word, one for the space (CDATA preserves whitespace) // Add trailing space for word buttons to enable sentence building
162
+ let text = semanticAction.text || button.message || button.label || '';
163
+ // Remove trailing space from message if present (we'll add it as separate segment)
164
+ if (text.endsWith(' ')) {
165
+ text = text.slice(0, -1);
163
166
  }
164
- case 'INSERT_TEXT':
165
- // Add trailing space for word buttons to enable sentence building
166
- // Use two <s> elements: one for the word, one for the space (CDATA preserves whitespace)
167
- {
168
- let text = semanticAction.text || button.message || button.label || '';
169
- // Remove trailing space from message if present (we'll add it as separate segment)
170
- if (text.endsWith(' ')) {
171
- text = text.slice(0, -1);
172
- }
173
- return {
174
- Command: {
175
- '@_ID': 'Action.InsertText',
176
- Parameter: {
177
- '@_Key': 'text',
178
- p: {
179
- s: [
180
- {
181
- r: text,
182
- },
183
- {
184
- r: { '__cdata': ' ' },
185
- },
186
- ],
187
- },
167
+ return {
168
+ Command: {
169
+ '@_ID': 'Action.InsertText',
170
+ Parameter: {
171
+ '@_Key': 'text',
172
+ p: {
173
+ s: [
174
+ {
175
+ r: text,
176
+ },
177
+ {
178
+ r: { __cdata: ' ' },
179
+ },
180
+ ],
188
181
  },
189
182
  },
190
- };
191
- }
192
- default:
193
- // Fallback to insert text with structured XML format
183
+ },
184
+ };
185
+ }
186
+ default: {
194
187
  // Use two <s> elements: one for the word, one for the space (CDATA preserves whitespace)
195
- {
196
- let text = semanticAction.text || button.message || button.label || '';
197
- // Remove trailing space from message if present (we'll add it as separate segment)
198
- if (text.endsWith(' ')) {
199
- text = text.slice(0, -1);
200
- }
201
- return {
202
- Command: {
203
- '@_ID': 'Action.InsertText',
204
- Parameter: {
205
- '@_Key': 'text',
206
- p: {
207
- s: [
208
- {
209
- r: text,
210
- },
211
- {
212
- r: { '__cdata': ' ' },
213
- },
214
- ],
215
- },
188
+ // Fallback to insert text with structured XML format
189
+ let text = semanticAction.text || button.message || button.label || '';
190
+ // Remove trailing space from message if present (we'll add it as separate segment)
191
+ if (text.endsWith(' ')) {
192
+ text = text.slice(0, -1);
193
+ }
194
+ return {
195
+ Command: {
196
+ '@_ID': 'Action.InsertText',
197
+ Parameter: {
198
+ '@_Key': 'text',
199
+ p: {
200
+ s: [
201
+ {
202
+ r: text,
203
+ },
204
+ {
205
+ r: { __cdata: ' ' },
206
+ },
207
+ ],
216
208
  },
217
209
  },
218
- };
219
- }
210
+ },
211
+ };
212
+ }
220
213
  }
221
214
  }
222
215
  // Helper function to convert Grid 3 style to AACStyle
@@ -288,10 +281,8 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
288
281
  if (entries) {
289
282
  const arr = Array.isArray(entries) ? entries : [entries];
290
283
  for (const ent of arr) {
291
- const staticFile = (ent['@_StaticFile'] ||
292
- ent.StaticFile ||
293
- ent.staticFile ||
294
- '').replace(/\\/g, '/');
284
+ const rawStaticFile = ent['@_StaticFile'] || ent.StaticFile || ent.staticFile;
285
+ const staticFile = typeof rawStaticFile === 'string' ? rawStaticFile.replace(/\\/g, '/') : '';
295
286
  if (!staticFile)
296
287
  continue;
297
288
  const df = ent.DynamicFiles || ent.dynamicFiles;
@@ -987,26 +978,22 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
987
978
  const buttonImages = new Map();
988
979
  // Helper function to add style and return its ID
989
980
  const addStyle = (style) => {
990
- if (!style || typeof style !== 'object')
991
- return '';
992
- const obj = style;
993
- if (Object.keys(obj).length === 0)
981
+ if (!style)
994
982
  return '';
995
- const styleKey = JSON.stringify(obj);
983
+ const normalizedStyle = { ...style };
984
+ const styleKey = JSON.stringify(normalizedStyle);
996
985
  const existing = uniqueStyles.get(styleKey);
997
986
  if (existing)
998
987
  return existing.id;
999
988
  const styleId = `Style${styleIdCounter++}`;
1000
- uniqueStyles.set(styleKey, { id: styleId, style: obj });
989
+ uniqueStyles.set(styleKey, { id: styleId, style: normalizedStyle });
1001
990
  return styleId;
1002
991
  };
1003
992
  // Collect styles from all pages and buttons
1004
993
  Object.values(tree.pages).forEach((page) => {
1005
- if (page.style)
1006
- addStyle(page.style);
994
+ addStyle(page.style);
1007
995
  page.buttons.forEach((button) => {
1008
- if (button.style)
1009
- addStyle(button.style);
996
+ addStyle(button.style);
1010
997
  });
1011
998
  });
1012
999
  // Get the home/start grid from tree.rootId, fallback to first page
@@ -1053,8 +1040,8 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
1053
1040
  // When TileColour is present, BackColour is the surround (outer area)
1054
1041
  // For "None" surround, just use BackColour for the fill (no TileColour)
1055
1042
  BackColour: this.ensureAlphaChannel(style.backgroundColor),
1056
- BorderColour: this.ensureAlphaChannel(style.borderColor) || '#000000FF',
1057
- FontColour: this.ensureAlphaChannel(style.fontColor) || '#000000FF',
1043
+ BorderColour: this.ensureAlphaChannel(style.borderColor),
1044
+ FontColour: this.ensureAlphaChannel(style.fontColor),
1058
1045
  FontName: style.fontFamily || 'Arial',
1059
1046
  FontSize: style.fontSize?.toString() || '16',
1060
1047
  };
@@ -1081,7 +1068,7 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
1081
1068
  // Collect grid file paths for FileMap.xml
1082
1069
  const gridFilePaths = [];
1083
1070
  // Create a grid for each page
1084
- Object.values(tree.pages).forEach((page, index) => {
1071
+ Object.values(tree.pages).forEach((page) => {
1085
1072
  const gridData = {
1086
1073
  Grid: {
1087
1074
  '@_xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
@@ -1121,8 +1108,9 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
1121
1108
  if (button.image) {
1122
1109
  // Try to determine file extension from image name or default to PNG
1123
1110
  let imageExt = 'png';
1124
- if (button.image.match(/\.(png|jpg|jpeg|gif|svg)$/i)) {
1125
- imageExt = button.image.match(/\.(png|jpg|jpeg|gif|svg)$/i)[1].toLowerCase();
1111
+ const imageMatch = button.image.match(/\.(png|jpg|jpeg|gif|svg)$/i);
1112
+ if (imageMatch) {
1113
+ imageExt = imageMatch[1].toLowerCase();
1126
1114
  }
1127
1115
  // Grid3 dynamically constructs image filenames by prepending cell coordinates
1128
1116
  // The XML should only contain the suffix: -0-text-0.{ext}
@@ -1131,7 +1119,9 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
1131
1119
  // Extract image data from button parameters if available
1132
1120
  // (AstericsGridProcessor stores it there during loadIntoTree)
1133
1121
  let imageData = Buffer.alloc(0);
1134
- if (button.parameters && button.parameters.imageData && Buffer.isBuffer(button.parameters.imageData)) {
1122
+ if (button.parameters &&
1123
+ button.parameters.imageData &&
1124
+ Buffer.isBuffer(button.parameters.imageData)) {
1135
1125
  imageData = button.parameters.imageData;
1136
1126
  }
1137
1127
  // Store image data for later writing to ZIP
@@ -1182,7 +1172,7 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
1182
1172
  }
1183
1173
  return cellData;
1184
1174
  }),
1185
- ]
1175
+ ],
1186
1176
  }
1187
1177
  : { Cell: [] },
1188
1178
  },
@@ -1202,7 +1192,7 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
1202
1192
  zip.addFile(gridPath, Buffer.from(xmlContent, 'utf8'));
1203
1193
  });
1204
1194
  // Write image files to ZIP
1205
- buttonImages.forEach((imgData, buttonId) => {
1195
+ buttonImages.forEach((imgData) => {
1206
1196
  if (imgData.imageData && imgData.imageData.length > 0) {
1207
1197
  // Create image path in the grid's directory
1208
1198
  const imagePath = `Grids\\${imgData.pageName}\\${imgData.x}-${imgData.y}-0-text-0.${imgData.ext}`;
@@ -1221,7 +1211,7 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
1221
1211
  const imageFiles = [];
1222
1212
  // Collect image filenames for buttons on this page
1223
1213
  // IMPORTANT: FileMap.xml requires full paths like "Grids\PageName\1-5-0-text-0.png"
1224
- buttonImages.forEach((imgData, buttonId) => {
1214
+ buttonImages.forEach((imgData) => {
1225
1215
  if (imgData.pageName === gridName && imgData.imageData.length > 0) {
1226
1216
  const imagePath = `Grids\\${gridName}\\${imgData.x}-${imgData.y}-0-text-0.${imgData.ext}`;
1227
1217
  imageFiles.push(imagePath);
@@ -1229,9 +1219,11 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
1229
1219
  });
1230
1220
  return {
1231
1221
  '@_StaticFile': gridPath,
1232
- DynamicFiles: imageFiles.length > 0 ? {
1233
- File: imageFiles
1234
- } : {},
1222
+ DynamicFiles: imageFiles.length > 0
1223
+ ? {
1224
+ File: imageFiles,
1225
+ }
1226
+ : {},
1235
1227
  };
1236
1228
  }),
1237
1229
  },
@@ -7,10 +7,12 @@ export { OpmlProcessor } from './opmlProcessor';
7
7
  export { SnapProcessor } from './snapProcessor';
8
8
  export { TouchChatProcessor } from './touchchatProcessor';
9
9
  export { AstericsGridProcessor } from './astericsGridProcessor';
10
- export { getPageTokenImageMap, getAllowedImageEntries, openImage } from './gridset/helpers';
11
- export { getPageTokenImageMap as getGridsetPageTokenImageMap, getAllowedImageEntries as getGridsetAllowedImageEntries, openImage as openGridsetImage, } from './gridset/helpers';
10
+ export { getPageTokenImageMap, getAllowedImageEntries, openImage, generateGrid3Guid, createSettingsXml, createFileMapXml, } from './gridset/helpers';
11
+ export { getPageTokenImageMap as getGridsetPageTokenImageMap, getAllowedImageEntries as getGridsetAllowedImageEntries, openImage as openGridsetImage, generateGrid3Guid as generateGridsetGuid, createSettingsXml as createGridsetSettingsXml, createFileMapXml as createGridsetFileMapXml, } from './gridset/helpers';
12
12
  export { resolveGrid3CellImage } from './gridset/resolver';
13
13
  export { createWordlist, extractWordlists, updateWordlist, wordlistToXml, type WordList, type WordListItem, } from './gridset/wordlistHelpers';
14
- export { DEFAULT_GRID3_STYLES, CATEGORY_STYLES, ensureAlphaChannel, createDefaultStylesXml, createCategoryStyle, type Grid3Style, } from './gridset/styleHelpers';
14
+ export { getNamedColor, rgbaToHex, channelToHex, clampColorChannel, clampAlpha, toHexColor, darkenColor, normalizeColor, ensureAlphaChannel, } from './gridset/colorUtils';
15
+ export { DEFAULT_GRID3_STYLES, CATEGORY_STYLES, createDefaultStylesXml, createCategoryStyle, } from './gridset/styleHelpers';
16
+ export { ensureAlphaChannel as ensureAlphaChannelFromStyles } from './gridset/styleHelpers';
15
17
  export { getPageTokenImageMap as getSnapPageTokenImageMap, getAllowedImageEntries as getSnapAllowedImageEntries, openImage as openSnapImage, } from './snap/helpers';
16
18
  export { getPageTokenImageMap as getTouchChatPageTokenImageMap, getAllowedImageEntries as getTouchChatAllowedImageEntries, openImage as openTouchChatImage, } from './touchchat/helpers';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.openTouchChatImage = exports.getTouchChatAllowedImageEntries = exports.getTouchChatPageTokenImageMap = exports.openSnapImage = exports.getSnapAllowedImageEntries = exports.getSnapPageTokenImageMap = exports.createCategoryStyle = exports.createDefaultStylesXml = exports.ensureAlphaChannel = exports.CATEGORY_STYLES = exports.DEFAULT_GRID3_STYLES = exports.wordlistToXml = exports.updateWordlist = exports.extractWordlists = exports.createWordlist = exports.resolveGrid3CellImage = exports.openGridsetImage = exports.getGridsetAllowedImageEntries = exports.getGridsetPageTokenImageMap = exports.openImage = exports.getAllowedImageEntries = exports.getPageTokenImageMap = exports.AstericsGridProcessor = exports.TouchChatProcessor = exports.SnapProcessor = exports.OpmlProcessor = exports.ObfProcessor = exports.GridsetProcessor = exports.ExcelProcessor = exports.DotProcessor = exports.ApplePanelsProcessor = void 0;
3
+ exports.openTouchChatImage = exports.getTouchChatAllowedImageEntries = exports.getTouchChatPageTokenImageMap = exports.openSnapImage = exports.getSnapAllowedImageEntries = exports.getSnapPageTokenImageMap = exports.ensureAlphaChannelFromStyles = exports.createCategoryStyle = exports.createDefaultStylesXml = exports.CATEGORY_STYLES = exports.DEFAULT_GRID3_STYLES = exports.ensureAlphaChannel = exports.normalizeColor = exports.darkenColor = exports.toHexColor = exports.clampAlpha = exports.clampColorChannel = exports.channelToHex = exports.rgbaToHex = exports.getNamedColor = exports.wordlistToXml = exports.updateWordlist = exports.extractWordlists = exports.createWordlist = exports.resolveGrid3CellImage = exports.createGridsetFileMapXml = exports.createGridsetSettingsXml = exports.generateGridsetGuid = exports.openGridsetImage = exports.getGridsetAllowedImageEntries = exports.getGridsetPageTokenImageMap = exports.createFileMapXml = exports.createSettingsXml = exports.generateGrid3Guid = exports.openImage = exports.getAllowedImageEntries = exports.getPageTokenImageMap = exports.AstericsGridProcessor = exports.TouchChatProcessor = exports.SnapProcessor = exports.OpmlProcessor = exports.ObfProcessor = exports.GridsetProcessor = exports.ExcelProcessor = exports.DotProcessor = exports.ApplePanelsProcessor = void 0;
4
4
  var applePanelsProcessor_1 = require("./applePanelsProcessor");
5
5
  Object.defineProperty(exports, "ApplePanelsProcessor", { enumerable: true, get: function () { return applePanelsProcessor_1.ApplePanelsProcessor; } });
6
6
  var dotProcessor_1 = require("./dotProcessor");
@@ -24,10 +24,16 @@ var helpers_1 = require("./gridset/helpers");
24
24
  Object.defineProperty(exports, "getPageTokenImageMap", { enumerable: true, get: function () { return helpers_1.getPageTokenImageMap; } });
25
25
  Object.defineProperty(exports, "getAllowedImageEntries", { enumerable: true, get: function () { return helpers_1.getAllowedImageEntries; } });
26
26
  Object.defineProperty(exports, "openImage", { enumerable: true, get: function () { return helpers_1.openImage; } });
27
+ Object.defineProperty(exports, "generateGrid3Guid", { enumerable: true, get: function () { return helpers_1.generateGrid3Guid; } });
28
+ Object.defineProperty(exports, "createSettingsXml", { enumerable: true, get: function () { return helpers_1.createSettingsXml; } });
29
+ Object.defineProperty(exports, "createFileMapXml", { enumerable: true, get: function () { return helpers_1.createFileMapXml; } });
27
30
  var helpers_2 = require("./gridset/helpers");
28
31
  Object.defineProperty(exports, "getGridsetPageTokenImageMap", { enumerable: true, get: function () { return helpers_2.getPageTokenImageMap; } });
29
32
  Object.defineProperty(exports, "getGridsetAllowedImageEntries", { enumerable: true, get: function () { return helpers_2.getAllowedImageEntries; } });
30
33
  Object.defineProperty(exports, "openGridsetImage", { enumerable: true, get: function () { return helpers_2.openImage; } });
34
+ Object.defineProperty(exports, "generateGridsetGuid", { enumerable: true, get: function () { return helpers_2.generateGrid3Guid; } });
35
+ Object.defineProperty(exports, "createGridsetSettingsXml", { enumerable: true, get: function () { return helpers_2.createSettingsXml; } });
36
+ Object.defineProperty(exports, "createGridsetFileMapXml", { enumerable: true, get: function () { return helpers_2.createFileMapXml; } });
31
37
  var resolver_1 = require("./gridset/resolver");
32
38
  Object.defineProperty(exports, "resolveGrid3CellImage", { enumerable: true, get: function () { return resolver_1.resolveGrid3CellImage; } });
33
39
  // Gridset (Grid 3) wordlist helpers
@@ -36,13 +42,26 @@ Object.defineProperty(exports, "createWordlist", { enumerable: true, get: functi
36
42
  Object.defineProperty(exports, "extractWordlists", { enumerable: true, get: function () { return wordlistHelpers_1.extractWordlists; } });
37
43
  Object.defineProperty(exports, "updateWordlist", { enumerable: true, get: function () { return wordlistHelpers_1.updateWordlist; } });
38
44
  Object.defineProperty(exports, "wordlistToXml", { enumerable: true, get: function () { return wordlistHelpers_1.wordlistToXml; } });
45
+ // Gridset (Grid 3) color utilities
46
+ var colorUtils_1 = require("./gridset/colorUtils");
47
+ Object.defineProperty(exports, "getNamedColor", { enumerable: true, get: function () { return colorUtils_1.getNamedColor; } });
48
+ Object.defineProperty(exports, "rgbaToHex", { enumerable: true, get: function () { return colorUtils_1.rgbaToHex; } });
49
+ Object.defineProperty(exports, "channelToHex", { enumerable: true, get: function () { return colorUtils_1.channelToHex; } });
50
+ Object.defineProperty(exports, "clampColorChannel", { enumerable: true, get: function () { return colorUtils_1.clampColorChannel; } });
51
+ Object.defineProperty(exports, "clampAlpha", { enumerable: true, get: function () { return colorUtils_1.clampAlpha; } });
52
+ Object.defineProperty(exports, "toHexColor", { enumerable: true, get: function () { return colorUtils_1.toHexColor; } });
53
+ Object.defineProperty(exports, "darkenColor", { enumerable: true, get: function () { return colorUtils_1.darkenColor; } });
54
+ Object.defineProperty(exports, "normalizeColor", { enumerable: true, get: function () { return colorUtils_1.normalizeColor; } });
55
+ Object.defineProperty(exports, "ensureAlphaChannel", { enumerable: true, get: function () { return colorUtils_1.ensureAlphaChannel; } });
39
56
  // Gridset (Grid 3) style helpers
40
57
  var styleHelpers_1 = require("./gridset/styleHelpers");
41
58
  Object.defineProperty(exports, "DEFAULT_GRID3_STYLES", { enumerable: true, get: function () { return styleHelpers_1.DEFAULT_GRID3_STYLES; } });
42
59
  Object.defineProperty(exports, "CATEGORY_STYLES", { enumerable: true, get: function () { return styleHelpers_1.CATEGORY_STYLES; } });
43
- Object.defineProperty(exports, "ensureAlphaChannel", { enumerable: true, get: function () { return styleHelpers_1.ensureAlphaChannel; } });
44
60
  Object.defineProperty(exports, "createDefaultStylesXml", { enumerable: true, get: function () { return styleHelpers_1.createDefaultStylesXml; } });
45
61
  Object.defineProperty(exports, "createCategoryStyle", { enumerable: true, get: function () { return styleHelpers_1.createCategoryStyle; } });
62
+ // Re-export ensureAlphaChannel from styleHelpers for backward compatibility
63
+ var styleHelpers_2 = require("./gridset/styleHelpers");
64
+ Object.defineProperty(exports, "ensureAlphaChannelFromStyles", { enumerable: true, get: function () { return styleHelpers_2.ensureAlphaChannel; } });
46
65
  // Snap helpers (stubs)
47
66
  var helpers_3 = require("./snap/helpers");
48
67
  Object.defineProperty(exports, "getSnapPageTokenImageMap", { enumerable: true, get: function () { return helpers_3.getPageTokenImageMap; } });
@@ -5,6 +5,8 @@ declare class ObfProcessor extends BaseProcessor {
5
5
  private processBoard;
6
6
  extractTexts(filePathOrBuffer: string | Buffer): string[];
7
7
  loadIntoTree(filePathOrBuffer: string | Buffer): AACTree;
8
+ private buildGridMetadata;
9
+ private createObfBoardFromPage;
8
10
  processTexts(filePathOrBuffer: string | Buffer, translations: Map<string, string>, outputPath: string): Buffer;
9
11
  saveFromTree(tree: AACTree, outputPath: string): void;
10
12
  /**