@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,468 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Grid 3 Symbol Library Resolution
|
|
4
|
+
*
|
|
5
|
+
* Grid 3 uses symbol libraries stored as .pix files in the installation directory.
|
|
6
|
+
* Symbol references in Grid files use the format: [library]/path/to/symbol.png
|
|
7
|
+
*
|
|
8
|
+
* Examples:
|
|
9
|
+
* - [widgit]/food/apple.png
|
|
10
|
+
* - [tawasl]/above bw.png
|
|
11
|
+
* - [ssnaps]963.jpg
|
|
12
|
+
* - [grid3x]/folder/document.png
|
|
13
|
+
*
|
|
14
|
+
* This module provides symbol resolution and metadata extraction.
|
|
15
|
+
*/
|
|
16
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
19
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
20
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
21
|
+
}
|
|
22
|
+
Object.defineProperty(o, k2, desc);
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
28
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
29
|
+
}) : function(o, v) {
|
|
30
|
+
o["default"] = v;
|
|
31
|
+
});
|
|
32
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.DEFAULT_LOCALE = exports.SYMBOL_LIBRARIES = void 0;
|
|
44
|
+
exports.parseSymbolReference = parseSymbolReference;
|
|
45
|
+
exports.isSymbolReference = isSymbolReference;
|
|
46
|
+
exports.getDefaultGrid3Path = getDefaultGrid3Path;
|
|
47
|
+
exports.getSymbolLibrariesDir = getSymbolLibrariesDir;
|
|
48
|
+
exports.getSymbolSearchIndexesDir = getSymbolSearchIndexesDir;
|
|
49
|
+
exports.getAvailableSymbolLibraries = getAvailableSymbolLibraries;
|
|
50
|
+
exports.getSymbolLibraryInfo = getSymbolLibraryInfo;
|
|
51
|
+
exports.resolveSymbolReference = resolveSymbolReference;
|
|
52
|
+
exports.extractSymbolReferences = extractSymbolReferences;
|
|
53
|
+
exports.createSymbolReference = createSymbolReference;
|
|
54
|
+
exports.getSymbolLibraryName = getSymbolLibraryName;
|
|
55
|
+
exports.getSymbolPath = getSymbolPath;
|
|
56
|
+
exports.isKnownSymbolLibrary = isKnownSymbolLibrary;
|
|
57
|
+
exports.getSymbolLibraryDisplayName = getSymbolLibraryDisplayName;
|
|
58
|
+
exports.analyzeSymbolUsage = analyzeSymbolUsage;
|
|
59
|
+
exports.symbolReferenceToFilename = symbolReferenceToFilename;
|
|
60
|
+
exports.getSymbolsDir = getSymbolsDir;
|
|
61
|
+
exports.getSymbolSearchDir = getSymbolSearchDir;
|
|
62
|
+
const fs = __importStar(require("fs"));
|
|
63
|
+
const path = __importStar(require("path"));
|
|
64
|
+
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
65
|
+
/**
|
|
66
|
+
* Default Grid 3 installation paths by platform
|
|
67
|
+
*/
|
|
68
|
+
const DEFAULT_GRID3_PATHS = {
|
|
69
|
+
win32: 'C:\\Program Files (x86)\\Smartbox\\Grid 3',
|
|
70
|
+
darwin: '/Applications/Grid 3.app/Contents/Resources',
|
|
71
|
+
linux: '/opt/smartbox/grid3',
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Path to Symbols directory within Grid 3 installation
|
|
75
|
+
* Contains .symbols ZIP archives with actual images
|
|
76
|
+
*/
|
|
77
|
+
const SYMBOLS_SUBDIR = 'Resources\\Symbols';
|
|
78
|
+
/**
|
|
79
|
+
* Path to symbol search indexes within Grid 3 installation
|
|
80
|
+
* Contains .pix index files for searching
|
|
81
|
+
*/
|
|
82
|
+
const SYMBOLSEARCH_SUBDIR = 'Locale';
|
|
83
|
+
/**
|
|
84
|
+
* Known symbol libraries in Grid 3
|
|
85
|
+
*/
|
|
86
|
+
exports.SYMBOL_LIBRARIES = {
|
|
87
|
+
WIDGIT: 'widgit',
|
|
88
|
+
TAWASL: 'tawasl',
|
|
89
|
+
SSNAPS: 'ssnaps',
|
|
90
|
+
GRID3X: 'grid3x',
|
|
91
|
+
GRID2X: 'grid2x',
|
|
92
|
+
BLISSX: 'blissx',
|
|
93
|
+
EYEGAZ: 'eyegaz',
|
|
94
|
+
INTERL: 'interl',
|
|
95
|
+
METACM: 'metacm',
|
|
96
|
+
MJPCS: 'mjpcs#',
|
|
97
|
+
PCSHC: 'pcshc#',
|
|
98
|
+
PCSTL: 'pcstl#',
|
|
99
|
+
SESENS: 'sesens',
|
|
100
|
+
SSTIX: 'sstix#',
|
|
101
|
+
SYMOJI: 'symoji',
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Default locale to use
|
|
105
|
+
*/
|
|
106
|
+
exports.DEFAULT_LOCALE = 'en-GB';
|
|
107
|
+
/**
|
|
108
|
+
* Parse a symbol reference string
|
|
109
|
+
* @param reference - Symbol reference like "[widgit]/food/apple.png"
|
|
110
|
+
* @returns Parsed symbol reference
|
|
111
|
+
*/
|
|
112
|
+
function parseSymbolReference(reference) {
|
|
113
|
+
const trimmed = reference.trim();
|
|
114
|
+
// Match pattern: [library]/path or [library]path
|
|
115
|
+
const match = trimmed.match(/^\[([^\]]+)\](.+)$/);
|
|
116
|
+
if (!match) {
|
|
117
|
+
return {
|
|
118
|
+
library: '',
|
|
119
|
+
path: trimmed,
|
|
120
|
+
fullReference: trimmed,
|
|
121
|
+
isValid: false,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const [, library, symbolPath] = match;
|
|
125
|
+
return {
|
|
126
|
+
library: library.toLowerCase(),
|
|
127
|
+
path: symbolPath.replace(/^\\+/, '').trim(), // Remove leading slashes
|
|
128
|
+
fullReference: trimmed,
|
|
129
|
+
isValid: true,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Check if a string is a symbol library reference
|
|
134
|
+
* @param reference - String to check
|
|
135
|
+
* @returns True if it's a symbol reference like [widgit]/...
|
|
136
|
+
*/
|
|
137
|
+
function isSymbolReference(reference) {
|
|
138
|
+
return reference.trim().startsWith('[');
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Get the default Grid 3 installation path for the current platform
|
|
142
|
+
* @returns Default Grid 3 path or empty string if not found
|
|
143
|
+
*/
|
|
144
|
+
function getDefaultGrid3Path() {
|
|
145
|
+
const platform = process.platform;
|
|
146
|
+
const defaultPath = DEFAULT_GRID3_PATHS[platform] || '';
|
|
147
|
+
if (defaultPath && fs.existsSync(defaultPath)) {
|
|
148
|
+
return defaultPath;
|
|
149
|
+
}
|
|
150
|
+
// Try to find Grid 3 in common locations
|
|
151
|
+
const commonPaths = [
|
|
152
|
+
'C:\\Program Files (x86)\\Smartbox\\Grid 3',
|
|
153
|
+
'C:\\Program Files\\Smartbox\\Grid 3',
|
|
154
|
+
'C:\\Program Files\\Smartbox\\Grid 3',
|
|
155
|
+
'/Applications/Grid 3.app',
|
|
156
|
+
'/opt/smartbox/grid3',
|
|
157
|
+
];
|
|
158
|
+
for (const testPath of commonPaths) {
|
|
159
|
+
if (fs.existsSync(testPath)) {
|
|
160
|
+
return testPath;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return '';
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Get the Symbol Libraries directory path
|
|
167
|
+
* Contains .symbols ZIP archives with actual image files
|
|
168
|
+
* @param grid3Path - Grid 3 installation path
|
|
169
|
+
* @returns Path to Symbol Libraries directory (e.g., "C:\...\Grid 3\Resources\Symbols")
|
|
170
|
+
*/
|
|
171
|
+
function getSymbolLibrariesDir(grid3Path) {
|
|
172
|
+
return path.join(grid3Path, SYMBOLS_SUBDIR);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get the symbol search indexes directory path for a given locale
|
|
176
|
+
* Contains .pix index files for searching symbols
|
|
177
|
+
* @param grid3Path - Grid 3 installation path
|
|
178
|
+
* @param locale - Locale code (e.g., 'en-GB')
|
|
179
|
+
* @returns Path to symbol search indexes directory (e.g., "C:\...\Grid 3\Locale\en-GB\symbolsearch")
|
|
180
|
+
*/
|
|
181
|
+
function getSymbolSearchIndexesDir(grid3Path, locale = exports.DEFAULT_LOCALE) {
|
|
182
|
+
return path.join(grid3Path, SYMBOLSEARCH_SUBDIR, locale, 'symbolsearch');
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Get all available symbol libraries in the Grid 3 installation
|
|
186
|
+
* @param options - Resolution options
|
|
187
|
+
* @returns Array of symbol library information
|
|
188
|
+
*/
|
|
189
|
+
function getAvailableSymbolLibraries(options = {}) {
|
|
190
|
+
const grid3Path = options.grid3Path || options.symbolDir || getDefaultGrid3Path();
|
|
191
|
+
if (!grid3Path) {
|
|
192
|
+
return [];
|
|
193
|
+
}
|
|
194
|
+
const symbolsDir = getSymbolLibrariesDir(grid3Path);
|
|
195
|
+
if (!fs.existsSync(symbolsDir)) {
|
|
196
|
+
return [];
|
|
197
|
+
}
|
|
198
|
+
const libraries = [];
|
|
199
|
+
const files = fs.readdirSync(symbolsDir);
|
|
200
|
+
for (const file of files) {
|
|
201
|
+
if (file.endsWith('.symbols')) {
|
|
202
|
+
const fullPath = path.join(symbolsDir, file);
|
|
203
|
+
const stats = fs.statSync(fullPath);
|
|
204
|
+
const libraryName = path.basename(file, '.symbols');
|
|
205
|
+
libraries.push({
|
|
206
|
+
name: libraryName,
|
|
207
|
+
pixFile: fullPath, // Reuse this field for the .symbols file path
|
|
208
|
+
exists: true,
|
|
209
|
+
size: stats.size,
|
|
210
|
+
locale: 'global', // .symbols files are not locale-specific
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return libraries.sort((a, b) => a.name.localeCompare(b.name));
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Check if a symbol library exists
|
|
218
|
+
* @param libraryName - Name of the library (e.g., 'widgit', 'tawasl')
|
|
219
|
+
* @param options - Resolution options
|
|
220
|
+
* @returns Symbol library info or undefined if not found
|
|
221
|
+
*/
|
|
222
|
+
function getSymbolLibraryInfo(libraryName, options = {}) {
|
|
223
|
+
const grid3Path = options.grid3Path || options.symbolDir || getDefaultGrid3Path();
|
|
224
|
+
if (!grid3Path) {
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
const symbolsDir = getSymbolLibrariesDir(grid3Path);
|
|
228
|
+
const normalizedLibName = libraryName.toLowerCase();
|
|
229
|
+
// Try different case variations
|
|
230
|
+
const variations = [
|
|
231
|
+
normalizedLibName + '.symbols',
|
|
232
|
+
normalizedLibName.toUpperCase() + '.symbols',
|
|
233
|
+
libraryName + '.symbols',
|
|
234
|
+
];
|
|
235
|
+
for (const file of variations) {
|
|
236
|
+
const fullPath = path.join(symbolsDir, file);
|
|
237
|
+
if (fs.existsSync(fullPath)) {
|
|
238
|
+
const stats = fs.statSync(fullPath);
|
|
239
|
+
return {
|
|
240
|
+
name: libraryName,
|
|
241
|
+
pixFile: fullPath,
|
|
242
|
+
exists: true,
|
|
243
|
+
size: stats.size,
|
|
244
|
+
locale: 'global',
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return undefined;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Resolve a symbol reference to extract the actual image data
|
|
252
|
+
* @param reference - Symbol reference like "[tawasl]/above bw.png"
|
|
253
|
+
* @param options - Resolution options
|
|
254
|
+
* @returns Resolution result with image data if found
|
|
255
|
+
*/
|
|
256
|
+
function resolveSymbolReference(reference, options = {}) {
|
|
257
|
+
const parsed = parseSymbolReference(reference);
|
|
258
|
+
if (!parsed.isValid) {
|
|
259
|
+
return {
|
|
260
|
+
reference: parsed,
|
|
261
|
+
found: false,
|
|
262
|
+
error: 'Invalid symbol reference format',
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
const grid3Path = options.grid3Path || getDefaultGrid3Path();
|
|
266
|
+
if (!grid3Path) {
|
|
267
|
+
return {
|
|
268
|
+
reference: parsed,
|
|
269
|
+
found: false,
|
|
270
|
+
error: 'Grid 3 installation not found. Please specify grid3Path.',
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
const libraryInfo = getSymbolLibraryInfo(parsed.library, { grid3Path });
|
|
274
|
+
if (!libraryInfo || !libraryInfo.exists) {
|
|
275
|
+
return {
|
|
276
|
+
reference: parsed,
|
|
277
|
+
found: false,
|
|
278
|
+
error: `Symbol library '${parsed.library}' not found at ${libraryInfo?.pixFile || 'unknown'}`,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
try {
|
|
282
|
+
// .symbols files are ZIP archives
|
|
283
|
+
const zip = new adm_zip_1.default(libraryInfo.pixFile);
|
|
284
|
+
// The path in the symbol reference becomes the path within the symbols/ folder
|
|
285
|
+
// e.g., [tawasl]/above bw.png becomes symbols/above bw.png
|
|
286
|
+
const symbolPath = `symbols/${parsed.path}`;
|
|
287
|
+
const entry = zip.getEntry(symbolPath);
|
|
288
|
+
if (!entry) {
|
|
289
|
+
// Try without the symbols/ prefix (in case reference already includes it)
|
|
290
|
+
const altPath = parsed.path.startsWith('symbols/') ? parsed.path : `symbols/${parsed.path}`;
|
|
291
|
+
const altEntry = zip.getEntry(altPath);
|
|
292
|
+
if (!altEntry) {
|
|
293
|
+
return {
|
|
294
|
+
reference: parsed,
|
|
295
|
+
found: false,
|
|
296
|
+
error: `Symbol '${parsed.path}' not found in library '${parsed.library}'`,
|
|
297
|
+
path: libraryInfo.pixFile,
|
|
298
|
+
libraryInfo,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
// Found with alternate path
|
|
302
|
+
const data = altEntry.getData();
|
|
303
|
+
return {
|
|
304
|
+
reference: parsed,
|
|
305
|
+
found: true,
|
|
306
|
+
path: libraryInfo.pixFile,
|
|
307
|
+
data,
|
|
308
|
+
libraryInfo,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
// Found the symbol!
|
|
312
|
+
const data = entry.getData();
|
|
313
|
+
return {
|
|
314
|
+
reference: parsed,
|
|
315
|
+
found: true,
|
|
316
|
+
path: libraryInfo.pixFile,
|
|
317
|
+
data,
|
|
318
|
+
libraryInfo,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
catch (error) {
|
|
322
|
+
return {
|
|
323
|
+
reference: parsed,
|
|
324
|
+
found: false,
|
|
325
|
+
error: `Failed to extract symbol: ${error.message}`,
|
|
326
|
+
path: libraryInfo.pixFile,
|
|
327
|
+
libraryInfo,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Get all symbol references from a gridset
|
|
333
|
+
* This scans button images for symbol references
|
|
334
|
+
* @param tree - AAC tree from loaded gridset
|
|
335
|
+
* @returns Array of unique symbol references
|
|
336
|
+
*/
|
|
337
|
+
function extractSymbolReferences(tree) {
|
|
338
|
+
const references = new Set();
|
|
339
|
+
for (const pageId in tree.pages) {
|
|
340
|
+
const page = tree.pages[pageId];
|
|
341
|
+
if (page.buttons) {
|
|
342
|
+
for (const button of page.buttons) {
|
|
343
|
+
if (button.image && isSymbolReference(String(button.image))) {
|
|
344
|
+
references.add(String(button.image));
|
|
345
|
+
}
|
|
346
|
+
// Check for symbol library metadata
|
|
347
|
+
if (button.symbolLibrary) {
|
|
348
|
+
const ref = `[${button.symbolLibrary}]${button.symbolPath || ''}`;
|
|
349
|
+
references.add(ref);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return Array.from(references).sort();
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Create a symbol reference from library and path
|
|
358
|
+
* @param library - Library name
|
|
359
|
+
* @param symbolPath - Path within the library
|
|
360
|
+
* @returns Formatted symbol reference
|
|
361
|
+
*/
|
|
362
|
+
function createSymbolReference(library, symbolPath) {
|
|
363
|
+
const normalizedLib = library.toLowerCase().replace(/\[|\]/g, '');
|
|
364
|
+
const normalizedPath = symbolPath.replace(/^\\+/, '');
|
|
365
|
+
return `[${normalizedLib}]${normalizedPath}`;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Get the library name from a symbol reference
|
|
369
|
+
* @param reference - Symbol reference
|
|
370
|
+
* @returns Library name or empty string
|
|
371
|
+
*/
|
|
372
|
+
function getSymbolLibraryName(reference) {
|
|
373
|
+
const parsed = parseSymbolReference(reference);
|
|
374
|
+
return parsed.library;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Get the symbol path from a symbol reference
|
|
378
|
+
* @param reference - Symbol reference
|
|
379
|
+
* @returns Symbol path or empty string
|
|
380
|
+
*/
|
|
381
|
+
function getSymbolPath(reference) {
|
|
382
|
+
const parsed = parseSymbolReference(reference);
|
|
383
|
+
return parsed.path;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Check if a symbol library is one of the known Grid 3 libraries
|
|
387
|
+
* @param libraryName - Library name to check
|
|
388
|
+
* @returns True if it's a known library
|
|
389
|
+
*/
|
|
390
|
+
function isKnownSymbolLibrary(libraryName) {
|
|
391
|
+
const normalized = libraryName.toLowerCase().replace(/\[|\]/g, '');
|
|
392
|
+
return Object.values(exports.SYMBOL_LIBRARIES).includes(normalized);
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Get display name for a symbol library
|
|
396
|
+
* @param libraryName - Library name
|
|
397
|
+
* @returns Human-readable display name
|
|
398
|
+
*/
|
|
399
|
+
function getSymbolLibraryDisplayName(libraryName) {
|
|
400
|
+
const normalized = libraryName.toLowerCase().replace(/\[|\]/g, '');
|
|
401
|
+
const displayNames = {
|
|
402
|
+
widgit: 'Widgit Symbols',
|
|
403
|
+
tawasl: 'Tawasol (Arabic)',
|
|
404
|
+
ssnaps: 'Smartbox Symbol Snapshots',
|
|
405
|
+
grid3x: 'Grid 3 Extended',
|
|
406
|
+
grid2x: 'Grid 2 Extended',
|
|
407
|
+
blissx: 'Blissymbols',
|
|
408
|
+
eyegaz: 'Eye Gaze Symbols',
|
|
409
|
+
interl: 'International Symbols',
|
|
410
|
+
metacm: 'MetaComm',
|
|
411
|
+
mjpcs: 'Mayer-Johnson PCS',
|
|
412
|
+
pcshc: 'PCS High Contrast',
|
|
413
|
+
pcstl: 'PCS Thin Line',
|
|
414
|
+
sesens: 'Sensory Software',
|
|
415
|
+
sstix: 'Smartbox TIX',
|
|
416
|
+
symoji: 'Symbol Emoji',
|
|
417
|
+
};
|
|
418
|
+
return displayNames[normalized] || normalized.charAt(0).toUpperCase() + normalized.slice(1);
|
|
419
|
+
}
|
|
420
|
+
function analyzeSymbolUsage(tree) {
|
|
421
|
+
const references = extractSymbolReferences(tree);
|
|
422
|
+
const byLibrary = {};
|
|
423
|
+
const libraries = new Set();
|
|
424
|
+
for (const ref of references) {
|
|
425
|
+
const lib = getSymbolLibraryName(ref);
|
|
426
|
+
byLibrary[lib] = (byLibrary[lib] || 0) + 1;
|
|
427
|
+
if (lib) {
|
|
428
|
+
libraries.add(lib);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return {
|
|
432
|
+
totalSymbols: references.length,
|
|
433
|
+
byLibrary,
|
|
434
|
+
uniqueReferences: references,
|
|
435
|
+
librariesUsed: Array.from(libraries).sort(),
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Convert symbol reference to filename for embedded images
|
|
440
|
+
* Grid 3 sometimes embeds symbols with special naming
|
|
441
|
+
* @param reference - Symbol reference
|
|
442
|
+
* @param cellX - Cell X coordinate
|
|
443
|
+
* @param cellY - Cell Y coordinate
|
|
444
|
+
* @returns Generated filename
|
|
445
|
+
*/
|
|
446
|
+
function symbolReferenceToFilename(reference, cellX, cellY) {
|
|
447
|
+
const parsed = parseSymbolReference(reference);
|
|
448
|
+
const ext = path.extname(parsed.path) || '.png';
|
|
449
|
+
// Grid 3 format: {x}-{y}-0-text-0.{ext}
|
|
450
|
+
return `${cellX}-${cellY}-0-text-0${ext}`;
|
|
451
|
+
}
|
|
452
|
+
// ============================================================================
|
|
453
|
+
// BACKWARD COMPATIBILITY ALIASES
|
|
454
|
+
// ============================================================================
|
|
455
|
+
/**
|
|
456
|
+
* @deprecated Use getSymbolLibrariesDir() instead - more descriptive name
|
|
457
|
+
* Get the Symbols directory path (where .symbols ZIP archives are)
|
|
458
|
+
*/
|
|
459
|
+
function getSymbolsDir(grid3Path) {
|
|
460
|
+
return getSymbolLibrariesDir(grid3Path);
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* @deprecated Use getSymbolSearchIndexesDir() instead - more descriptive name
|
|
464
|
+
* Get the symbol search directory for a given locale (where .pix index files are)
|
|
465
|
+
*/
|
|
466
|
+
function getSymbolSearchDir(grid3Path, locale = exports.DEFAULT_LOCALE) {
|
|
467
|
+
return getSymbolSearchIndexesDir(grid3Path, locale);
|
|
468
|
+
}
|
|
@@ -14,6 +14,12 @@ const password_1 = require("./gridset/password");
|
|
|
14
14
|
const crypto_1 = __importDefault(require("crypto"));
|
|
15
15
|
const zlib_1 = __importDefault(require("zlib"));
|
|
16
16
|
const gridsetValidator_1 = require("../validation/gridsetValidator");
|
|
17
|
+
// New imports for enhanced Grid 3 support
|
|
18
|
+
const pluginTypes_1 = require("./gridset/pluginTypes");
|
|
19
|
+
const commands_1 = require("./gridset/commands");
|
|
20
|
+
const symbols_1 = require("./gridset/symbols");
|
|
21
|
+
const resolver_2 = require("./gridset/resolver");
|
|
22
|
+
const idGenerator_1 = require("../optional/analytics/utils/idGenerator");
|
|
17
23
|
class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
18
24
|
constructor(options) {
|
|
19
25
|
super(options);
|
|
@@ -254,6 +260,9 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
254
260
|
fontColor: grid3Style.FontColour,
|
|
255
261
|
fontFamily: grid3Style.FontName,
|
|
256
262
|
fontSize: grid3Style.FontSize ? parseInt(String(grid3Style.FontSize)) : undefined,
|
|
263
|
+
backgroundShape: grid3Style.BackgroundShape !== undefined
|
|
264
|
+
? parseInt(String(grid3Style.BackgroundShape))
|
|
265
|
+
: undefined,
|
|
257
266
|
};
|
|
258
267
|
}
|
|
259
268
|
// Helper function to get style by ID or return default
|
|
@@ -496,11 +505,14 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
496
505
|
}
|
|
497
506
|
}
|
|
498
507
|
const message = label; // Use caption as message
|
|
508
|
+
// Detect plugin cell type (Workspace, LiveCell, AutoContent)
|
|
509
|
+
const pluginMetadata = (0, pluginTypes_1.detectPluginCellType)(content);
|
|
499
510
|
// Parse all command types from Grid3 and create semantic actions
|
|
500
511
|
let semanticAction;
|
|
501
512
|
let legacyAction = null;
|
|
502
513
|
// infer action type implicitly from commands; no explicit enum needed
|
|
503
514
|
let navigationTarget;
|
|
515
|
+
let detectedCommands = []; // Store detected command metadata
|
|
504
516
|
const commands = content.Commands?.Command || content.commands?.command;
|
|
505
517
|
// Resolve image for this cell using FileMap and coordinate heuristics
|
|
506
518
|
const imageCandidate = captionAndImage?.Image ||
|
|
@@ -520,8 +532,14 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
520
532
|
y: cellY + 1,
|
|
521
533
|
dynamicFiles,
|
|
522
534
|
}, entries) || undefined;
|
|
535
|
+
// Check if image is a symbol library reference
|
|
536
|
+
let symbolLibraryRef = null;
|
|
537
|
+
if (declaredImageName && (0, resolver_2.isSymbolLibraryReference)(declaredImageName)) {
|
|
538
|
+
symbolLibraryRef = (0, symbols_1.parseSymbolReference)(declaredImageName);
|
|
539
|
+
}
|
|
523
540
|
if (commands) {
|
|
524
541
|
const commandArr = Array.isArray(commands) ? commands : [commands];
|
|
542
|
+
detectedCommands = commandArr.map((cmd) => (0, commands_1.detectCommand)(cmd));
|
|
525
543
|
for (const command of commandArr) {
|
|
526
544
|
const commandId = command['@_ID'] || command.ID || command.id;
|
|
527
545
|
const parameters = command.Parameter || command.parameter;
|
|
@@ -905,16 +923,34 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
905
923
|
message: String(message),
|
|
906
924
|
targetPageId: navigationTarget ? String(navigationTarget) : undefined,
|
|
907
925
|
semanticAction: semanticAction,
|
|
926
|
+
semantic_id: cell.semantic_id || cell.SemanticId || undefined, // Extract semantic_id if present
|
|
908
927
|
image: declaredImageName,
|
|
909
928
|
resolvedImageEntry: resolvedImageEntry,
|
|
910
929
|
x: cellX,
|
|
911
930
|
y: cellY,
|
|
912
931
|
columnSpan: colSpan,
|
|
913
932
|
rowSpan: rowSpan,
|
|
933
|
+
contentType: pluginMetadata.cellType === pluginTypes_1.Grid3CellType.Regular
|
|
934
|
+
? 'Normal'
|
|
935
|
+
: pluginMetadata.cellType === pluginTypes_1.Grid3CellType.Workspace
|
|
936
|
+
? 'Workspace'
|
|
937
|
+
: pluginMetadata.cellType === pluginTypes_1.Grid3CellType.LiveCell
|
|
938
|
+
? 'LiveCell'
|
|
939
|
+
: 'AutoContent',
|
|
940
|
+
contentSubType: pluginMetadata.subType ||
|
|
941
|
+
pluginMetadata.liveCellType ||
|
|
942
|
+
pluginMetadata.autoContentType,
|
|
943
|
+
symbolLibrary: symbolLibraryRef?.library || undefined,
|
|
944
|
+
symbolPath: symbolLibraryRef?.path || undefined,
|
|
914
945
|
style: {
|
|
915
946
|
...cellStyle,
|
|
916
947
|
...inlineStyle, // Inline styles override referenced styles
|
|
917
948
|
},
|
|
949
|
+
parameters: {
|
|
950
|
+
pluginMetadata: pluginMetadata, // Store full plugin metadata for future use
|
|
951
|
+
grid3Commands: detectedCommands, // Store detected command metadata
|
|
952
|
+
symbolLibraryRef: symbolLibraryRef, // Store full symbol reference
|
|
953
|
+
},
|
|
918
954
|
});
|
|
919
955
|
// Add button to page
|
|
920
956
|
page.addButton(button);
|
|
@@ -929,6 +965,29 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
929
965
|
});
|
|
930
966
|
// Set the page's grid layout
|
|
931
967
|
page.grid = gridLayout;
|
|
968
|
+
// Generate clone_id for each button in the grid
|
|
969
|
+
const semanticIds = [];
|
|
970
|
+
const cloneIds = [];
|
|
971
|
+
gridLayout.forEach((row, rowIndex) => {
|
|
972
|
+
row.forEach((btn, colIndex) => {
|
|
973
|
+
if (btn) {
|
|
974
|
+
// Generate clone_id based on position and label
|
|
975
|
+
btn.clone_id = (0, idGenerator_1.generateCloneId)(maxRows, maxCols, rowIndex, colIndex, btn.label);
|
|
976
|
+
cloneIds.push(btn.clone_id);
|
|
977
|
+
// Track semantic_id if present
|
|
978
|
+
if (btn.semantic_id) {
|
|
979
|
+
semanticIds.push(btn.semantic_id);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
});
|
|
983
|
+
});
|
|
984
|
+
// Track IDs on the page
|
|
985
|
+
if (semanticIds.length > 0) {
|
|
986
|
+
page.semantic_ids = semanticIds;
|
|
987
|
+
}
|
|
988
|
+
if (cloneIds.length > 0) {
|
|
989
|
+
page.clone_ids = cloneIds;
|
|
990
|
+
}
|
|
932
991
|
}
|
|
933
992
|
tree.addPage(page);
|
|
934
993
|
}
|
|
@@ -7,13 +7,22 @@ export { OpmlProcessor } from './opmlProcessor';
|
|
|
7
7
|
export { SnapProcessor } from './snapProcessor';
|
|
8
8
|
export { TouchChatProcessor } from './touchchatProcessor';
|
|
9
9
|
export { AstericsGridProcessor } from './astericsGridProcessor';
|
|
10
|
+
export { ObfsetProcessor } from './obfsetProcessor';
|
|
10
11
|
export { getPageTokenImageMap, getAllowedImageEntries, openImage, generateGrid3Guid, createSettingsXml, createFileMapXml, getCommonDocumentsPath, findGrid3UserPaths, findGrid3HistoryDatabases, findGrid3Users, findGrid3Vocabularies, findGrid3UserHistory, isGrid3Installed, readGrid3History, readGrid3HistoryForUser, readAllGrid3History, type Grid3UserPath, type Grid3VocabularyPath, type Grid3HistoryEntry, } from './gridset/helpers';
|
|
11
12
|
export { getPageTokenImageMap as getGridsetPageTokenImageMap, getAllowedImageEntries as getGridsetAllowedImageEntries, openImage as openGridsetImage, generateGrid3Guid as generateGridsetGuid, createSettingsXml as createGridsetSettingsXml, createFileMapXml as createGridsetFileMapXml, getCommonDocumentsPath as getGridsetCommonDocumentsPath, findGrid3UserPaths as findGridsetUserPaths, findGrid3HistoryDatabases as findGridsetHistoryDatabases, findGrid3Users as findGridsetUsers, findGrid3Vocabularies as findGridsetVocabularies, findGrid3UserHistory as findGridsetUserHistory, isGrid3Installed as isGridsetInstalled, readGrid3History as readGridsetHistory, readGrid3HistoryForUser as readGridsetHistoryForUser, readAllGrid3History as readAllGridsetHistory, } from './gridset/helpers';
|
|
12
13
|
export { resolveGrid3CellImage } from './gridset/resolver';
|
|
13
14
|
export { createWordlist, extractWordlists, updateWordlist, wordlistToXml, type WordList, type WordListItem, } from './gridset/wordlistHelpers';
|
|
14
15
|
export { resolveGridsetPassword, resolveGridsetPasswordFromEnv } from './gridset/password';
|
|
15
16
|
export { getNamedColor, rgbaToHex, channelToHex, clampColorChannel, clampAlpha, toHexColor, darkenColor, normalizeColor, ensureAlphaChannel, } from './gridset/colorUtils';
|
|
16
|
-
export { DEFAULT_GRID3_STYLES, CATEGORY_STYLES, createDefaultStylesXml, createCategoryStyle, } from './gridset/styleHelpers';
|
|
17
|
+
export { DEFAULT_GRID3_STYLES, CATEGORY_STYLES, createDefaultStylesXml, createCategoryStyle, CellBackgroundShape, SHAPE_NAMES, } from './gridset/styleHelpers';
|
|
17
18
|
export { ensureAlphaChannel as ensureAlphaChannelFromStyles } from './gridset/styleHelpers';
|
|
19
|
+
export { detectPluginCellType, type Grid3PluginMetadata, Grid3CellType, WORKSPACE_TYPES, LIVECELL_TYPES, AUTOCONTENT_TYPES, getCellTypeDisplayName, isWorkspaceCell, isLiveCell, isAutoContentCell, isRegularCell, } from './gridset/pluginTypes';
|
|
20
|
+
export { detectCommand, getCommandDefinition, getCommandsByPlugin, getCommandsByCategory, getAllCommandIds, getAllPluginIds, extractCommandParameters, GRID3_COMMANDS, type Grid3CommandDefinition, type CommandParameter, type ExtractedParameters, Grid3CommandCategory, } from './gridset/commands';
|
|
21
|
+
export * from './gridset/index';
|
|
22
|
+
export { parseSymbolReference, isSymbolReference, resolveSymbolReference, getAvailableSymbolLibraries, getSymbolLibraryInfo, extractSymbolReferences, analyzeSymbolUsage, createSymbolReference, getSymbolLibraryName, getSymbolPath, isKnownSymbolLibrary, getSymbolLibraryDisplayName, getDefaultGrid3Path, getSymbolLibrariesDir, getSymbolSearchIndexesDir, symbolReferenceToFilename, SYMBOL_LIBRARIES, } from './gridset/symbols';
|
|
23
|
+
export { isSymbolLibraryReference, parseImageSymbolReference } from './gridset/resolver';
|
|
24
|
+
export { getSymbolsDir, getSymbolSearchDir } from './gridset/symbols';
|
|
25
|
+
export { extractButtonImage, extractSymbolLibraryImage, convertToAstericsImage, analyzeSymbolExtraction, suggestExtractionStrategy, exportSymbolReferencesToCsv, createSymbolManifest, } from './gridset/symbolExtractor';
|
|
26
|
+
export { parsePixFile, loadSearchIndexes, searchSymbols, searchSymbolsWithReferences, getSymbolFilename, getSymbolDisplayName, getAllSearchTerms, getSearchSuggestions, countLibrarySymbols, getSymbolSearchStats, } from './gridset/symbolSearch';
|
|
18
27
|
export { getPageTokenImageMap as getSnapPageTokenImageMap, getAllowedImageEntries as getSnapAllowedImageEntries, openImage as openSnapImage, findSnapPackages, findSnapPackagePath, findSnapUsers, findSnapUserVocabularies, findSnapUserHistory, isSnapInstalled, readSnapUsage, readSnapUsageForUser, type SnapPackagePath, type SnapUserInfo, type SnapUsageEntry, } from './snap/helpers';
|
|
19
28
|
export { getPageTokenImageMap as getTouchChatPageTokenImageMap, getAllowedImageEntries as getTouchChatAllowedImageEntries, openImage as openTouchChatImage, } from './touchchat/helpers';
|