@willwade/aac-processors 0.0.9 → 0.0.11
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/README.md +85 -11
- package/dist/cli/index.js +87 -0
- package/dist/core/analyze.js +1 -0
- package/dist/core/baseProcessor.d.ts +6 -0
- package/dist/core/fileProcessor.js +1 -0
- package/dist/core/treeStructure.d.ts +3 -1
- package/dist/core/treeStructure.js +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/optional/symbolTools.js +4 -2
- 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/helpers.d.ts +1 -1
- package/dist/processors/gridset/helpers.js +5 -3
- package/dist/processors/gridset/index.d.ts +45 -0
- package/dist/processors/gridset/index.js +153 -0
- package/dist/processors/gridset/password.d.ts +11 -0
- package/dist/processors/gridset/password.js +37 -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 +14 -1
- package/dist/processors/gridset/resolver.js +47 -5
- 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/gridset/wordlistHelpers.d.ts +2 -2
- package/dist/processors/gridset/wordlistHelpers.js +7 -4
- package/dist/processors/gridsetProcessor.d.ts +15 -1
- package/dist/processors/gridsetProcessor.js +98 -22
- package/dist/processors/index.d.ts +10 -1
- package/dist/processors/index.js +94 -2
- package/dist/processors/obfProcessor.d.ts +7 -0
- package/dist/processors/obfProcessor.js +9 -0
- package/dist/processors/snapProcessor.d.ts +7 -0
- package/dist/processors/snapProcessor.js +9 -0
- package/dist/processors/touchchatProcessor.d.ts +7 -0
- package/dist/processors/touchchatProcessor.js +9 -0
- package/dist/types/aac.d.ts +17 -0
- package/dist/utilities/screenshotConverter.d.ts +69 -0
- package/dist/utilities/screenshotConverter.js +453 -0
- package/dist/validation/baseValidator.d.ts +80 -0
- package/dist/validation/baseValidator.js +160 -0
- package/dist/validation/gridsetValidator.d.ts +36 -0
- package/dist/validation/gridsetValidator.js +288 -0
- package/dist/validation/index.d.ts +13 -0
- package/dist/validation/index.js +69 -0
- package/dist/validation/obfValidator.d.ts +44 -0
- package/dist/validation/obfValidator.js +530 -0
- package/dist/validation/snapValidator.d.ts +33 -0
- package/dist/validation/snapValidator.js +237 -0
- package/dist/validation/touchChatValidator.d.ts +33 -0
- package/dist/validation/touchChatValidator.js +229 -0
- package/dist/validation/validationTypes.d.ts +64 -0
- package/dist/validation/validationTypes.js +15 -0
- package/examples/README.md +7 -0
- package/examples/demo.js +143 -0
- package/examples/obf/aboutme.json +376 -0
- package/examples/obf/array.json +6 -0
- package/examples/obf/hash.json +4 -0
- package/examples/obf/links.obz +0 -0
- package/examples/obf/simple.obf +53 -0
- package/examples/package-lock.json +1326 -0
- package/examples/package.json +10 -0
- package/examples/styling-example.ts +316 -0
- package/examples/translate.js +39 -0
- package/examples/translate_demo.js +254 -0
- package/examples/typescript-demo.ts +251 -0
- package/package.json +3 -1
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Grid 3 Plugin Cell Type Detection
|
|
4
|
+
*
|
|
5
|
+
* Grid 3 uses three special cell types for different plugin functionalities:
|
|
6
|
+
* - Workspace: Full editing workspaces (Email, Chat, WordProcessor, etc.)
|
|
7
|
+
* - LiveCell: Dynamic content displays (Clock, Volume indicators, etc.)
|
|
8
|
+
* - AutoContent: Dynamic word/content suggestions
|
|
9
|
+
*
|
|
10
|
+
* This module provides detection and metadata extraction for these cell types.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.AUTOCONTENT_TYPES = exports.LIVECELL_TYPES = exports.WORKSPACE_TYPES = exports.Grid3CellType = void 0;
|
|
14
|
+
exports.getCellTypeDisplayName = getCellTypeDisplayName;
|
|
15
|
+
exports.detectPluginCellType = detectPluginCellType;
|
|
16
|
+
exports.isWorkspaceCell = isWorkspaceCell;
|
|
17
|
+
exports.isLiveCell = isLiveCell;
|
|
18
|
+
exports.isAutoContentCell = isAutoContentCell;
|
|
19
|
+
exports.isRegularCell = isRegularCell;
|
|
20
|
+
/**
|
|
21
|
+
* Cell types in Grid 3
|
|
22
|
+
*/
|
|
23
|
+
var Grid3CellType;
|
|
24
|
+
(function (Grid3CellType) {
|
|
25
|
+
Grid3CellType["Regular"] = "regular";
|
|
26
|
+
Grid3CellType["Workspace"] = "workspace";
|
|
27
|
+
Grid3CellType["LiveCell"] = "livecell";
|
|
28
|
+
Grid3CellType["AutoContent"] = "autocontent";
|
|
29
|
+
})(Grid3CellType || (exports.Grid3CellType = Grid3CellType = {}));
|
|
30
|
+
/**
|
|
31
|
+
* Known workspace types in Grid 3
|
|
32
|
+
*/
|
|
33
|
+
exports.WORKSPACE_TYPES = {
|
|
34
|
+
CHAT: 'Chat',
|
|
35
|
+
EMAIL: 'Email',
|
|
36
|
+
WORD_PROCESSOR: 'WordProcessor',
|
|
37
|
+
PHONE: 'Phone',
|
|
38
|
+
SMS: 'Sms',
|
|
39
|
+
WEB_BROWSER: 'WebBrowser',
|
|
40
|
+
COMPUTER_CONTROL: 'ComputerControl',
|
|
41
|
+
CALCULATOR: 'Calculator',
|
|
42
|
+
TIMER: 'Timer',
|
|
43
|
+
MUSIC_VIDEO: 'MusicVideo',
|
|
44
|
+
PHOTOS: 'Photos',
|
|
45
|
+
CONTACTS: 'Contacts',
|
|
46
|
+
INTERACTIVE_LEARNING: 'InteractiveLearning',
|
|
47
|
+
MESSAGE_BANKING: 'MessageBanking',
|
|
48
|
+
ENVIRONMENT_CONTROL: 'EnvironmentControl',
|
|
49
|
+
SETTINGS: 'Settings',
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Known live cell types in Grid 3
|
|
53
|
+
*/
|
|
54
|
+
exports.LIVECELL_TYPES = {
|
|
55
|
+
DIGITAL_CLOCK: 'DigitalClock',
|
|
56
|
+
ANALOG_CLOCK: 'AnalogClock',
|
|
57
|
+
DATE_DISPLAY: 'DateDisplay',
|
|
58
|
+
PUBLIC_VOLUME: 'PublicVolume',
|
|
59
|
+
PUBLIC_SPEED: 'PublicSpeed',
|
|
60
|
+
PUBLIC_VOICE: 'PublicVoice',
|
|
61
|
+
MESSAGES: 'Messages',
|
|
62
|
+
BATTERY: 'Battery',
|
|
63
|
+
WIFI_STRENGTH: 'WifiStrength',
|
|
64
|
+
BLUETOOTH_STATUS: 'BluetoothStatus',
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Known auto content types in Grid 3
|
|
68
|
+
*/
|
|
69
|
+
exports.AUTOCONTENT_TYPES = {
|
|
70
|
+
CHANGE_PUBLIC_VOICE: 'ChangePublicVoice',
|
|
71
|
+
CHANGE_PUBLIC_SPEED: 'ChangePublicSpeed',
|
|
72
|
+
EMAIL_CONTACTS: 'EmailContacts',
|
|
73
|
+
EMAIL_RECIPIENTS: 'EmailRecipients',
|
|
74
|
+
PHONE_CONTACTS: 'PhoneContacts',
|
|
75
|
+
SMS_CONTACTS: 'SmsContacts',
|
|
76
|
+
WEB_FAVORITES: 'WebFavorites',
|
|
77
|
+
WEB_HISTORY: 'WebHistory',
|
|
78
|
+
PREDICTION: 'Prediction',
|
|
79
|
+
GRAMMAR: 'Grammar',
|
|
80
|
+
CONTEXTUAL: 'Contextual',
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Human-readable names for cell types
|
|
84
|
+
*/
|
|
85
|
+
function getCellTypeDisplayName(cellType) {
|
|
86
|
+
switch (cellType) {
|
|
87
|
+
case Grid3CellType.Workspace:
|
|
88
|
+
return 'Workspace';
|
|
89
|
+
case Grid3CellType.LiveCell:
|
|
90
|
+
return 'Live Cell';
|
|
91
|
+
case Grid3CellType.AutoContent:
|
|
92
|
+
return 'Auto Content';
|
|
93
|
+
case Grid3CellType.Regular:
|
|
94
|
+
return 'Regular';
|
|
95
|
+
default:
|
|
96
|
+
return 'Unknown';
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Detect plugin cell type from Grid 3 cell content
|
|
101
|
+
*
|
|
102
|
+
* @param content - Grid 3 cell content object
|
|
103
|
+
* @returns Plugin metadata with detected type
|
|
104
|
+
*/
|
|
105
|
+
function detectPluginCellType(content) {
|
|
106
|
+
if (!content) {
|
|
107
|
+
return { cellType: Grid3CellType.Regular };
|
|
108
|
+
}
|
|
109
|
+
const contentType = content.ContentType || content.contenttype || content.ContentType;
|
|
110
|
+
const contentSubType = content.ContentSubType || content.contentsubtype || content.ContentSubType;
|
|
111
|
+
// Workspace cells - full editing workspaces
|
|
112
|
+
if (contentType === 'Workspace') {
|
|
113
|
+
return {
|
|
114
|
+
cellType: Grid3CellType.Workspace,
|
|
115
|
+
subType: contentSubType || undefined,
|
|
116
|
+
pluginId: inferWorkspacePlugin(String(contentSubType || '')),
|
|
117
|
+
displayName: contentSubType ? `${contentSubType} Workspace` : 'Workspace',
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
// LiveCell detection - dynamic content displays
|
|
121
|
+
if (contentType === 'LiveCell') {
|
|
122
|
+
return {
|
|
123
|
+
cellType: Grid3CellType.LiveCell,
|
|
124
|
+
liveCellType: contentSubType || undefined,
|
|
125
|
+
pluginId: inferLiveCellPlugin(String(contentSubType || '')),
|
|
126
|
+
displayName: contentSubType || 'Live Cell',
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
// AutoContent detection - dynamic word/content suggestions
|
|
130
|
+
if (contentType === 'AutoContent') {
|
|
131
|
+
const autoContentType = extractAutoContentType(content);
|
|
132
|
+
return {
|
|
133
|
+
cellType: Grid3CellType.AutoContent,
|
|
134
|
+
autoContentType: autoContentType || undefined,
|
|
135
|
+
pluginId: inferAutoContentPlugin(autoContentType),
|
|
136
|
+
displayName: autoContentType || 'Auto Content',
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
// Regular cell
|
|
140
|
+
return {
|
|
141
|
+
cellType: Grid3CellType.Regular,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Extract auto content type from AutoContent.Activate command
|
|
146
|
+
*/
|
|
147
|
+
function extractAutoContentType(content) {
|
|
148
|
+
const commands = content.Commands?.Command || content.commands?.command;
|
|
149
|
+
if (!commands)
|
|
150
|
+
return undefined;
|
|
151
|
+
const commandArr = Array.isArray(commands) ? commands : [commands];
|
|
152
|
+
for (const command of commandArr) {
|
|
153
|
+
const commandId = command['@_ID'] || command.ID || command.id;
|
|
154
|
+
if (commandId === 'AutoContent.Activate') {
|
|
155
|
+
const parameters = command.Parameter || command.parameter;
|
|
156
|
+
const paramArr = Array.isArray(parameters) ? parameters : parameters ? [parameters] : [];
|
|
157
|
+
for (const param of paramArr) {
|
|
158
|
+
const key = param['@_Key'] || param.Key || param.key;
|
|
159
|
+
if (key === 'autocontenttype') {
|
|
160
|
+
return String(param['#text'] || param.text || param.value || '');
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Infer plugin ID from workspace subtype
|
|
169
|
+
*/
|
|
170
|
+
function inferWorkspacePlugin(subType) {
|
|
171
|
+
if (!subType)
|
|
172
|
+
return undefined;
|
|
173
|
+
const normalized = subType.toLowerCase();
|
|
174
|
+
if (normalized.includes('chat'))
|
|
175
|
+
return 'chat';
|
|
176
|
+
if (normalized.includes('email') || normalized.includes('mail'))
|
|
177
|
+
return 'email';
|
|
178
|
+
if (normalized.includes('word') || normalized.includes('processor'))
|
|
179
|
+
return 'wordprocessor';
|
|
180
|
+
if (normalized.includes('phone'))
|
|
181
|
+
return 'phone';
|
|
182
|
+
if (normalized.includes('sms') || normalized.includes('text'))
|
|
183
|
+
return 'sms';
|
|
184
|
+
if (normalized.includes('web') || normalized.includes('browser'))
|
|
185
|
+
return 'webbrowser';
|
|
186
|
+
if (normalized.includes('computer') || normalized.includes('control'))
|
|
187
|
+
return 'computercontrol';
|
|
188
|
+
if (normalized.includes('calculator') || normalized.includes('calc'))
|
|
189
|
+
return 'calculator';
|
|
190
|
+
if (normalized.includes('timer') || normalized.includes('stopwatch'))
|
|
191
|
+
return 'timer';
|
|
192
|
+
if (normalized.includes('music') || normalized.includes('video'))
|
|
193
|
+
return 'musicvideo';
|
|
194
|
+
if (normalized.includes('photo') || normalized.includes('image'))
|
|
195
|
+
return 'photos';
|
|
196
|
+
if (normalized.includes('contact'))
|
|
197
|
+
return 'contacts';
|
|
198
|
+
if (normalized.includes('learning'))
|
|
199
|
+
return 'interactivelearning';
|
|
200
|
+
if (normalized.includes('message') && normalized.includes('bank'))
|
|
201
|
+
return 'messagebanking';
|
|
202
|
+
if (normalized.includes('env') || normalized.includes('ir'))
|
|
203
|
+
return 'environmentcontrol';
|
|
204
|
+
if (normalized.includes('setting'))
|
|
205
|
+
return 'settings';
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Infer plugin ID from live cell type
|
|
210
|
+
*/
|
|
211
|
+
function inferLiveCellPlugin(liveCellType) {
|
|
212
|
+
if (!liveCellType)
|
|
213
|
+
return undefined;
|
|
214
|
+
const normalized = liveCellType.toLowerCase();
|
|
215
|
+
if (normalized.includes('clock') || normalized.includes('time') || normalized.includes('date')) {
|
|
216
|
+
return 'clock';
|
|
217
|
+
}
|
|
218
|
+
if (normalized.includes('volume'))
|
|
219
|
+
return 'speech';
|
|
220
|
+
if (normalized.includes('speed'))
|
|
221
|
+
return 'speech';
|
|
222
|
+
if (normalized.includes('voice'))
|
|
223
|
+
return 'speech';
|
|
224
|
+
if (normalized.includes('message'))
|
|
225
|
+
return 'chat';
|
|
226
|
+
if (normalized.includes('battery'))
|
|
227
|
+
return 'settings';
|
|
228
|
+
if (normalized.includes('wifi') || normalized.includes('network'))
|
|
229
|
+
return 'settings';
|
|
230
|
+
if (normalized.includes('bluetooth'))
|
|
231
|
+
return 'settings';
|
|
232
|
+
return undefined;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Infer plugin ID from auto content type
|
|
236
|
+
*/
|
|
237
|
+
function inferAutoContentPlugin(autoContentType) {
|
|
238
|
+
if (!autoContentType)
|
|
239
|
+
return undefined;
|
|
240
|
+
const normalized = autoContentType.toLowerCase();
|
|
241
|
+
if (normalized.includes('voice') || normalized.includes('speed'))
|
|
242
|
+
return 'speech';
|
|
243
|
+
if (normalized.includes('email') || normalized.includes('mail'))
|
|
244
|
+
return 'email';
|
|
245
|
+
if (normalized.includes('phone'))
|
|
246
|
+
return 'phone';
|
|
247
|
+
if (normalized.includes('sms') || normalized.includes('text'))
|
|
248
|
+
return 'sms';
|
|
249
|
+
if (normalized.includes('web') ||
|
|
250
|
+
normalized.includes('favorite') ||
|
|
251
|
+
normalized.includes('history')) {
|
|
252
|
+
return 'webbrowser';
|
|
253
|
+
}
|
|
254
|
+
if (normalized.includes('prediction'))
|
|
255
|
+
return 'prediction';
|
|
256
|
+
if (normalized.includes('grammar'))
|
|
257
|
+
return 'grammar';
|
|
258
|
+
if (normalized.includes('context'))
|
|
259
|
+
return 'autocontent';
|
|
260
|
+
return undefined;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Check if a cell is a workspace cell
|
|
264
|
+
*/
|
|
265
|
+
function isWorkspaceCell(metadata) {
|
|
266
|
+
return metadata.cellType === Grid3CellType.Workspace;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Check if a cell is a live cell
|
|
270
|
+
*/
|
|
271
|
+
function isLiveCell(metadata) {
|
|
272
|
+
return metadata.cellType === Grid3CellType.LiveCell;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Check if a cell is an auto content cell
|
|
276
|
+
*/
|
|
277
|
+
function isAutoContentCell(metadata) {
|
|
278
|
+
return metadata.cellType === Grid3CellType.AutoContent;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Check if a cell is a regular (non-plugin) cell
|
|
282
|
+
*/
|
|
283
|
+
function isRegularCell(metadata) {
|
|
284
|
+
return metadata.cellType === Grid3CellType.Regular;
|
|
285
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseSymbolReference } from './symbols';
|
|
1
2
|
export declare function resolveGrid3CellImage(zip: any, args: {
|
|
2
3
|
baseDir: string;
|
|
3
4
|
imageName?: string;
|
|
@@ -5,4 +6,16 @@ export declare function resolveGrid3CellImage(zip: any, args: {
|
|
|
5
6
|
y?: number;
|
|
6
7
|
dynamicFiles?: string[];
|
|
7
8
|
builtinHandler?: (name: string) => string | null;
|
|
8
|
-
}): string | null;
|
|
9
|
+
}, zipEntries?: any[]): string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Check if an image reference is a symbol library reference
|
|
12
|
+
* @param imageName - Image reference from Grid 3
|
|
13
|
+
* @returns True if it's a symbol library reference
|
|
14
|
+
*/
|
|
15
|
+
export declare function isSymbolLibraryReference(imageName?: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Parse a symbol library reference from an image name
|
|
18
|
+
* @param imageName - Image reference from Grid 3
|
|
19
|
+
* @returns Parsed reference or null if not a symbol reference
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseImageSymbolReference(imageName: string): ReturnType<typeof parseSymbolReference> | null;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveGrid3CellImage = resolveGrid3CellImage;
|
|
4
|
+
exports.isSymbolLibraryReference = isSymbolLibraryReference;
|
|
5
|
+
exports.parseImageSymbolReference = parseImageSymbolReference;
|
|
6
|
+
const symbols_1 = require("./symbols");
|
|
4
7
|
function normalizeZipPathLocal(p) {
|
|
5
8
|
const unified = p.replace(/\\/g, '/');
|
|
6
9
|
try {
|
|
@@ -10,9 +13,13 @@ function normalizeZipPathLocal(p) {
|
|
|
10
13
|
return unified;
|
|
11
14
|
}
|
|
12
15
|
}
|
|
13
|
-
function listZipEntries(zip) {
|
|
16
|
+
function listZipEntries(zip, zipEntries) {
|
|
14
17
|
try {
|
|
15
|
-
const raw =
|
|
18
|
+
const raw = Array.isArray(zipEntries) && zipEntries.length > 0
|
|
19
|
+
? zipEntries
|
|
20
|
+
: typeof zip?.getEntries === 'function'
|
|
21
|
+
? zip.getEntries()
|
|
22
|
+
: [];
|
|
16
23
|
let entries = [];
|
|
17
24
|
if (Array.isArray(raw))
|
|
18
25
|
entries = raw;
|
|
@@ -33,15 +40,29 @@ function joinBaseDir(baseDir, leaf) {
|
|
|
33
40
|
const base = normalizeZipPathLocal(baseDir).replace(/\/?$/, '/');
|
|
34
41
|
return normalizeZipPathLocal(base + leaf.replace(/^\//, ''));
|
|
35
42
|
}
|
|
36
|
-
function resolveGrid3CellImage(zip, args) {
|
|
43
|
+
function resolveGrid3CellImage(zip, args, zipEntries) {
|
|
37
44
|
const { baseDir, dynamicFiles } = args;
|
|
38
45
|
const imageName = args.imageName?.trim();
|
|
39
46
|
const x = args.x;
|
|
40
47
|
const y = args.y;
|
|
41
|
-
const entries = new Set(listZipEntries(zip));
|
|
48
|
+
const entries = new Set(listZipEntries(zip, zipEntries));
|
|
42
49
|
const has = (p) => entries.has(normalizeZipPathLocal(p));
|
|
43
|
-
// Built-in resource like [grid3x]...
|
|
50
|
+
// Built-in resource like [grid3x]... (old format, not symbol library)
|
|
51
|
+
// Check this BEFORE general symbol references to avoid misclassification
|
|
44
52
|
if (imageName && imageName.startsWith('[')) {
|
|
53
|
+
// Check if it's a symbol library reference like [widgit]/food/apple.png
|
|
54
|
+
// Symbol library references have a path after the library name
|
|
55
|
+
if ((0, symbols_1.isSymbolReference)(imageName)) {
|
|
56
|
+
const parsed = (0, symbols_1.parseSymbolReference)(imageName);
|
|
57
|
+
// If it's grid3x, it's a built-in resource, not a symbol library
|
|
58
|
+
if (parsed.library !== 'grid3x') {
|
|
59
|
+
// Symbol library references are NOT stored as files in the gridset
|
|
60
|
+
// They are resolved from the external Grid 3 installation
|
|
61
|
+
// Return null to indicate this is an external symbol reference
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// For grid3x and other built-in resources, use the builtinHandler
|
|
45
66
|
if (args.builtinHandler) {
|
|
46
67
|
const mapped = args.builtinHandler(imageName);
|
|
47
68
|
if (mapped)
|
|
@@ -98,3 +119,24 @@ function resolveGrid3CellImage(zip, args) {
|
|
|
98
119
|
}
|
|
99
120
|
return null;
|
|
100
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Check if an image reference is a symbol library reference
|
|
124
|
+
* @param imageName - Image reference from Grid 3
|
|
125
|
+
* @returns True if it's a symbol library reference
|
|
126
|
+
*/
|
|
127
|
+
function isSymbolLibraryReference(imageName) {
|
|
128
|
+
if (!imageName)
|
|
129
|
+
return false;
|
|
130
|
+
return (0, symbols_1.isSymbolReference)(imageName.trim());
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Parse a symbol library reference from an image name
|
|
134
|
+
* @param imageName - Image reference from Grid 3
|
|
135
|
+
* @returns Parsed reference or null if not a symbol reference
|
|
136
|
+
*/
|
|
137
|
+
function parseImageSymbolReference(imageName) {
|
|
138
|
+
if (!isSymbolLibraryReference(imageName)) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
return (0, symbols_1.parseSymbolReference)(imageName.trim());
|
|
142
|
+
}
|
|
@@ -4,6 +4,27 @@
|
|
|
4
4
|
* Utilities for creating and managing Grid3 styles, including default styles,
|
|
5
5
|
* style XML generation, and style conversion utilities.
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Cell background shapes supported by Grid 3
|
|
9
|
+
* Maps to Grid 3's CellBackgroundShape enum
|
|
10
|
+
*/
|
|
11
|
+
export declare enum CellBackgroundShape {
|
|
12
|
+
Rectangle = 0,
|
|
13
|
+
RoundedRectangle = 1,
|
|
14
|
+
FoldedCorner = 2,
|
|
15
|
+
Octagon = 3,
|
|
16
|
+
Folder = 4,
|
|
17
|
+
Ellipse = 5,
|
|
18
|
+
SpeechBubble = 6,
|
|
19
|
+
ThoughtBubble = 7,
|
|
20
|
+
Star = 8,
|
|
21
|
+
Circle = 9,
|
|
22
|
+
ColouredCorner = 10
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Human-readable shape names
|
|
26
|
+
*/
|
|
27
|
+
export declare const SHAPE_NAMES: Record<CellBackgroundShape, string>;
|
|
7
28
|
/**
|
|
8
29
|
* Grid3 Style object structure
|
|
9
30
|
*/
|
|
@@ -14,6 +35,7 @@ export interface Grid3Style {
|
|
|
14
35
|
FontColour?: string;
|
|
15
36
|
FontName?: string;
|
|
16
37
|
FontSize?: string | number;
|
|
38
|
+
BackgroundShape?: CellBackgroundShape;
|
|
17
39
|
}
|
|
18
40
|
/**
|
|
19
41
|
* Default Grid3 styles for common use cases
|
|
@@ -6,11 +6,45 @@
|
|
|
6
6
|
* style XML generation, and style conversion utilities.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.ensureAlphaChannel = exports.CATEGORY_STYLES = exports.DEFAULT_GRID3_STYLES = void 0;
|
|
9
|
+
exports.ensureAlphaChannel = exports.CATEGORY_STYLES = exports.DEFAULT_GRID3_STYLES = exports.SHAPE_NAMES = exports.CellBackgroundShape = void 0;
|
|
10
10
|
exports.createDefaultStylesXml = createDefaultStylesXml;
|
|
11
11
|
exports.createCategoryStyle = createCategoryStyle;
|
|
12
12
|
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
13
13
|
const colorUtils_1 = require("./colorUtils");
|
|
14
|
+
/**
|
|
15
|
+
* Cell background shapes supported by Grid 3
|
|
16
|
+
* Maps to Grid 3's CellBackgroundShape enum
|
|
17
|
+
*/
|
|
18
|
+
var CellBackgroundShape;
|
|
19
|
+
(function (CellBackgroundShape) {
|
|
20
|
+
CellBackgroundShape[CellBackgroundShape["Rectangle"] = 0] = "Rectangle";
|
|
21
|
+
CellBackgroundShape[CellBackgroundShape["RoundedRectangle"] = 1] = "RoundedRectangle";
|
|
22
|
+
CellBackgroundShape[CellBackgroundShape["FoldedCorner"] = 2] = "FoldedCorner";
|
|
23
|
+
CellBackgroundShape[CellBackgroundShape["Octagon"] = 3] = "Octagon";
|
|
24
|
+
CellBackgroundShape[CellBackgroundShape["Folder"] = 4] = "Folder";
|
|
25
|
+
CellBackgroundShape[CellBackgroundShape["Ellipse"] = 5] = "Ellipse";
|
|
26
|
+
CellBackgroundShape[CellBackgroundShape["SpeechBubble"] = 6] = "SpeechBubble";
|
|
27
|
+
CellBackgroundShape[CellBackgroundShape["ThoughtBubble"] = 7] = "ThoughtBubble";
|
|
28
|
+
CellBackgroundShape[CellBackgroundShape["Star"] = 8] = "Star";
|
|
29
|
+
CellBackgroundShape[CellBackgroundShape["Circle"] = 9] = "Circle";
|
|
30
|
+
CellBackgroundShape[CellBackgroundShape["ColouredCorner"] = 10] = "ColouredCorner";
|
|
31
|
+
})(CellBackgroundShape || (exports.CellBackgroundShape = CellBackgroundShape = {}));
|
|
32
|
+
/**
|
|
33
|
+
* Human-readable shape names
|
|
34
|
+
*/
|
|
35
|
+
exports.SHAPE_NAMES = {
|
|
36
|
+
[CellBackgroundShape.Rectangle]: 'Rectangle',
|
|
37
|
+
[CellBackgroundShape.RoundedRectangle]: 'Rounded Rectangle',
|
|
38
|
+
[CellBackgroundShape.FoldedCorner]: 'Folded Corner',
|
|
39
|
+
[CellBackgroundShape.Octagon]: 'Octagon',
|
|
40
|
+
[CellBackgroundShape.Folder]: 'Folder',
|
|
41
|
+
[CellBackgroundShape.Ellipse]: 'Ellipse',
|
|
42
|
+
[CellBackgroundShape.SpeechBubble]: 'Speech Bubble',
|
|
43
|
+
[CellBackgroundShape.ThoughtBubble]: 'Thought Bubble',
|
|
44
|
+
[CellBackgroundShape.Star]: 'Star',
|
|
45
|
+
[CellBackgroundShape.Circle]: 'Circle',
|
|
46
|
+
[CellBackgroundShape.ColouredCorner]: 'Coloured Corner',
|
|
47
|
+
};
|
|
14
48
|
/**
|
|
15
49
|
* Default Grid3 styles for common use cases
|
|
16
50
|
* Colors are in 8-digit ARGB hex format (#AARRGGBBFF)
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grid 3 Symbol Extraction Strategy
|
|
3
|
+
*
|
|
4
|
+
* For converting Grid 3 gridsets to other formats (like Asterics),
|
|
5
|
+
* we need to handle symbol library references properly.
|
|
6
|
+
*
|
|
7
|
+
* Strategy:
|
|
8
|
+
* 1. Check if image is embedded in gridset (extract directly)
|
|
9
|
+
* 2. If symbol library reference:
|
|
10
|
+
* a. Check if we can extract from .pix file (limited support)
|
|
11
|
+
* b. Provide reference/URL for manual resolution
|
|
12
|
+
* c. For Tawasol: provide alternative sources
|
|
13
|
+
*/
|
|
14
|
+
import { type SymbolReference } from './symbols';
|
|
15
|
+
/**
|
|
16
|
+
* Image extraction result
|
|
17
|
+
*/
|
|
18
|
+
export interface ExtractedImage {
|
|
19
|
+
found: boolean;
|
|
20
|
+
data?: Buffer;
|
|
21
|
+
format?: 'png' | 'jpg' | 'jpeg' | 'gif' | 'svg' | 'unknown';
|
|
22
|
+
source: 'embedded' | 'symbol-library' | 'external-file' | 'not-found';
|
|
23
|
+
reference?: string;
|
|
24
|
+
error?: string;
|
|
25
|
+
metadata?: {
|
|
26
|
+
library?: string;
|
|
27
|
+
symbolPath?: string;
|
|
28
|
+
attribution?: string;
|
|
29
|
+
license?: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Symbol extraction options
|
|
34
|
+
*/
|
|
35
|
+
export interface SymbolExtractionOptions {
|
|
36
|
+
grid3Path?: string;
|
|
37
|
+
locale?: string;
|
|
38
|
+
preferEmbedded?: boolean;
|
|
39
|
+
includeAttribution?: boolean;
|
|
40
|
+
/** For Tawasol: try to find alternative sources */
|
|
41
|
+
tryAlternativeSources?: boolean;
|
|
42
|
+
/** Callback for when symbol needs manual extraction */
|
|
43
|
+
onMissingSymbol?: (ref: SymbolReference) => void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Extract image data for a button
|
|
47
|
+
* @param gridsetBuffer - Gridset ZIP buffer
|
|
48
|
+
* @param resolvedImageEntry - Path to embedded image in gridset
|
|
49
|
+
* @param symbolReference - Symbol library reference
|
|
50
|
+
* @param options - Extraction options
|
|
51
|
+
* @returns Extracted image data
|
|
52
|
+
*/
|
|
53
|
+
export declare function extractButtonImage(gridsetBuffer: Buffer, resolvedImageEntry: string | undefined, symbolReference: string | undefined, options?: SymbolExtractionOptions): ExtractedImage;
|
|
54
|
+
/**
|
|
55
|
+
* Extract image from symbol library
|
|
56
|
+
* @param reference - Symbol reference like "[tawasl]/food/apple.png"
|
|
57
|
+
* @param options - Extraction options
|
|
58
|
+
* @returns Extracted image or reference info
|
|
59
|
+
*/
|
|
60
|
+
export declare function extractSymbolLibraryImage(reference: string, options?: SymbolExtractionOptions): ExtractedImage;
|
|
61
|
+
/**
|
|
62
|
+
* Convert extracted image to Asterics Grid format
|
|
63
|
+
* @param extracted - Extracted image
|
|
64
|
+
* @returns GridImage object for Asterics
|
|
65
|
+
*/
|
|
66
|
+
export declare function convertToAstericsImage(extracted: ExtractedImage): any;
|
|
67
|
+
/**
|
|
68
|
+
* Generate a symbol extraction report
|
|
69
|
+
* Useful for identifying which symbols need manual extraction
|
|
70
|
+
*/
|
|
71
|
+
export interface SymbolReport {
|
|
72
|
+
total: number;
|
|
73
|
+
embedded: number;
|
|
74
|
+
symbolLibraries: number;
|
|
75
|
+
notFound: number;
|
|
76
|
+
byLibrary: Record<string, number>;
|
|
77
|
+
missingSymbols: Array<{
|
|
78
|
+
reference: string;
|
|
79
|
+
library: string;
|
|
80
|
+
path: string;
|
|
81
|
+
attribution?: string;
|
|
82
|
+
license?: string;
|
|
83
|
+
}>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Analyze symbol usage for a gridset
|
|
87
|
+
* @param tree - AAC tree
|
|
88
|
+
* @returns Symbol usage report
|
|
89
|
+
*/
|
|
90
|
+
export declare function analyzeSymbolExtraction(tree: any): SymbolReport;
|
|
91
|
+
/**
|
|
92
|
+
* Suggest extraction strategy based on report
|
|
93
|
+
*/
|
|
94
|
+
export declare function suggestExtractionStrategy(report: SymbolReport): string;
|
|
95
|
+
/**
|
|
96
|
+
* Export symbol references to CSV for manual extraction
|
|
97
|
+
*/
|
|
98
|
+
export declare function exportSymbolReferencesToCsv(report: SymbolReport, outputPath: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* Create a manifest file for missing symbols
|
|
101
|
+
*/
|
|
102
|
+
export interface SymbolManifest {
|
|
103
|
+
generatedAt: string;
|
|
104
|
+
gridset: string;
|
|
105
|
+
totalSymbols: number;
|
|
106
|
+
embedded: number;
|
|
107
|
+
fromLibraries: number;
|
|
108
|
+
libraries: Record<string, {
|
|
109
|
+
count: number;
|
|
110
|
+
attribution?: string;
|
|
111
|
+
license?: string;
|
|
112
|
+
url?: string;
|
|
113
|
+
}>;
|
|
114
|
+
symbols: Array<{
|
|
115
|
+
pageId: string;
|
|
116
|
+
buttonId: string;
|
|
117
|
+
reference: string;
|
|
118
|
+
label?: string;
|
|
119
|
+
}>;
|
|
120
|
+
}
|
|
121
|
+
export declare function createSymbolManifest(tree: any, gridsetName: string): SymbolManifest;
|