@willwade/aac-processors 0.1.20 → 0.2.0
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/browser/core/baseProcessor.js +4 -0
- package/dist/browser/processors/applePanelsProcessor.js +33 -40
- package/dist/browser/processors/astericsGridProcessor.js +31 -26
- package/dist/browser/processors/dotProcessor.js +11 -12
- package/dist/browser/processors/gridset/colorUtils.js +354 -0
- package/dist/browser/processors/gridset/helpers.js +60 -53
- package/dist/browser/processors/gridset/index.js +61 -0
- package/dist/browser/processors/gridset/styleHelpers.js +205 -0
- package/dist/browser/processors/gridset/symbolExtractor.js +331 -0
- package/dist/browser/processors/gridset/symbolSearch.js +248 -0
- package/dist/browser/processors/gridset/symbols.js +39 -72
- package/dist/browser/processors/gridsetProcessor.js +39 -48
- package/dist/browser/processors/obfProcessor.js +39 -53
- package/dist/browser/processors/opmlProcessor.js +11 -12
- package/dist/browser/processors/snap/helpers.js +57 -49
- package/dist/browser/processors/snapProcessor.js +48 -51
- package/dist/browser/processors/touchchatProcessor.js +60 -52
- package/dist/browser/utilities/analytics/history.js +24 -18
- package/dist/browser/utilities/analytics/metrics/comparison.js +16 -16
- package/dist/browser/utilities/analytics/metrics/vocabulary.js +2 -2
- package/dist/browser/utilities/analytics/reference/browser.js +16 -16
- package/dist/browser/utilities/analytics/reference/index.js +44 -35
- package/dist/browser/utils/io.js +78 -21
- package/dist/browser/utils/sqlite.js +8 -10
- package/dist/browser/utils/zip.js +43 -43
- package/dist/browser/validation/baseValidator.js +5 -0
- package/dist/browser/validation/gridsetValidator.js +12 -20
- package/dist/browser/validation/obfValidator.js +6 -5
- package/dist/browser/validation/snapValidator.js +11 -7
- package/dist/browser/validation/touchChatValidator.js +23 -13
- package/dist/cli/index.js +22 -24
- package/dist/core/baseProcessor.d.ts +7 -7
- package/dist/core/baseProcessor.js +4 -0
- package/dist/processors/applePanelsProcessor.js +32 -39
- package/dist/processors/astericsGridProcessor.d.ts +4 -4
- package/dist/processors/astericsGridProcessor.js +30 -25
- package/dist/processors/dotProcessor.js +10 -11
- package/dist/processors/excelProcessor.d.ts +3 -3
- package/dist/processors/excelProcessor.js +14 -20
- package/dist/processors/gridset/helpers.d.ts +12 -14
- package/dist/processors/gridset/helpers.js +60 -79
- package/dist/processors/gridset/imageDebug.d.ts +3 -5
- package/dist/processors/gridset/imageDebug.js +4 -4
- package/dist/processors/gridset/password.d.ts +1 -1
- package/dist/processors/gridset/symbolExtractor.d.ts +5 -3
- package/dist/processors/gridset/symbolExtractor.js +15 -38
- package/dist/processors/gridset/symbolSearch.d.ts +11 -10
- package/dist/processors/gridset/symbolSearch.js +29 -51
- package/dist/processors/gridset/symbols.d.ts +8 -6
- package/dist/processors/gridset/symbols.js +38 -71
- package/dist/processors/gridset/wordlistHelpers.d.ts +4 -6
- package/dist/processors/gridset/wordlistHelpers.js +15 -74
- package/dist/processors/gridsetProcessor.d.ts +2 -2
- package/dist/processors/gridsetProcessor.js +38 -70
- package/dist/processors/obfProcessor.d.ts +2 -2
- package/dist/processors/obfProcessor.js +38 -75
- package/dist/processors/obfsetProcessor.js +2 -3
- package/dist/processors/opmlProcessor.js +10 -11
- package/dist/processors/snap/helpers.d.ts +9 -9
- package/dist/processors/snap/helpers.js +58 -76
- package/dist/processors/snapProcessor.d.ts +2 -2
- package/dist/processors/snapProcessor.js +47 -50
- package/dist/processors/touchchatProcessor.d.ts +2 -2
- package/dist/processors/touchchatProcessor.js +59 -51
- package/dist/types/aac.d.ts +2 -2
- package/dist/utilities/analytics/history.d.ts +8 -8
- package/dist/utilities/analytics/history.js +24 -18
- package/dist/utilities/analytics/index.d.ts +3 -2
- package/dist/utilities/analytics/index.js +9 -10
- package/dist/utilities/analytics/metrics/comparison.d.ts +1 -1
- package/dist/utilities/analytics/metrics/comparison.js +16 -16
- package/dist/utilities/analytics/metrics/vocabulary.d.ts +1 -1
- package/dist/utilities/analytics/metrics/vocabulary.js +2 -2
- package/dist/utilities/analytics/reference/browser.d.ts +9 -9
- package/dist/utilities/analytics/reference/browser.js +16 -16
- package/dist/utilities/analytics/reference/index.d.ts +25 -23
- package/dist/utilities/analytics/reference/index.js +43 -34
- package/dist/utilities/symbolTools.d.ts +8 -6
- package/dist/utilities/symbolTools.js +21 -18
- package/dist/utils/io.d.ts +24 -6
- package/dist/utils/io.js +79 -25
- package/dist/utils/sqlite.d.ts +3 -1
- package/dist/utils/sqlite.js +7 -9
- package/dist/utils/zip.d.ts +7 -3
- package/dist/utils/zip.js +43 -43
- package/dist/validation/applePanelsValidator.d.ts +2 -1
- package/dist/validation/applePanelsValidator.js +10 -11
- package/dist/validation/astericsValidator.d.ts +2 -1
- package/dist/validation/astericsValidator.js +5 -4
- package/dist/validation/baseValidator.d.ts +2 -2
- package/dist/validation/baseValidator.js +5 -0
- package/dist/validation/dotValidator.d.ts +2 -1
- package/dist/validation/dotValidator.js +5 -4
- package/dist/validation/excelValidator.d.ts +2 -1
- package/dist/validation/excelValidator.js +5 -4
- package/dist/validation/gridsetValidator.d.ts +2 -1
- package/dist/validation/gridsetValidator.js +11 -22
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +5 -4
- package/dist/validation/obfValidator.d.ts +2 -1
- package/dist/validation/obfValidator.js +5 -4
- package/dist/validation/obfsetValidator.d.ts +2 -1
- package/dist/validation/obfsetValidator.js +5 -4
- package/dist/validation/opmlValidator.d.ts +2 -1
- package/dist/validation/opmlValidator.js +5 -4
- package/dist/validation/snapValidator.d.ts +2 -1
- package/dist/validation/snapValidator.js +10 -6
- package/dist/validation/touchChatValidator.d.ts +4 -6
- package/dist/validation/touchChatValidator.js +22 -12
- package/dist/validation/validationTypes.d.ts +8 -1
- package/package.json +1 -1
- package/dist/core/fileProcessor.d.ts +0 -7
- package/dist/core/fileProcessor.js +0 -57
|
@@ -570,7 +570,7 @@ class AstericsGridProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
570
570
|
});
|
|
571
571
|
}
|
|
572
572
|
// Also extract texts from the raw file for comprehensive coverage
|
|
573
|
-
const rawTexts = this.extractRawTexts(filePathOrBuffer);
|
|
573
|
+
const rawTexts = await this.extractRawTexts(filePathOrBuffer);
|
|
574
574
|
rawTexts.forEach((text) => {
|
|
575
575
|
if (text && !texts.includes(text)) {
|
|
576
576
|
texts.push(text);
|
|
@@ -578,8 +578,9 @@ class AstericsGridProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
578
578
|
});
|
|
579
579
|
return texts;
|
|
580
580
|
}
|
|
581
|
-
extractRawTexts(filePathOrBuffer) {
|
|
582
|
-
|
|
581
|
+
async extractRawTexts(filePathOrBuffer) {
|
|
582
|
+
const { readTextFromInput } = this.options.fileAdapter;
|
|
583
|
+
let content = await readTextFromInput(filePathOrBuffer);
|
|
583
584
|
// Remove BOM if present
|
|
584
585
|
if (content.charCodeAt(0) === 0xfeff) {
|
|
585
586
|
content = content.slice(1);
|
|
@@ -659,12 +660,12 @@ class AstericsGridProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
659
660
|
}
|
|
660
661
|
}
|
|
661
662
|
async loadIntoTree(filePathOrBuffer) {
|
|
662
|
-
|
|
663
|
+
const { readBinaryFromInput, readTextFromInput } = this.options.fileAdapter;
|
|
663
664
|
const tree = new treeStructure_1.AACTree();
|
|
664
665
|
const filename = typeof filePathOrBuffer === 'string' ? (0, io_1.getBasename)(filePathOrBuffer) : 'upload.grd';
|
|
665
|
-
const buffer =
|
|
666
|
+
const buffer = await readBinaryFromInput(filePathOrBuffer);
|
|
666
667
|
try {
|
|
667
|
-
let content =
|
|
668
|
+
let content = await readTextFromInput(buffer);
|
|
668
669
|
// Remove BOM if present
|
|
669
670
|
if (content.charCodeAt(0) === 0xfeff) {
|
|
670
671
|
content = content.slice(1);
|
|
@@ -1057,8 +1058,8 @@ class AstericsGridProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
1057
1058
|
});
|
|
1058
1059
|
}
|
|
1059
1060
|
async processTexts(filePathOrBuffer, translations, outputPath) {
|
|
1060
|
-
|
|
1061
|
-
let content =
|
|
1061
|
+
const { readTextFromInput, readBinaryFromInput, writeTextToPath } = this.options.fileAdapter;
|
|
1062
|
+
let content = await readTextFromInput(filePathOrBuffer);
|
|
1062
1063
|
// Remove BOM if present
|
|
1063
1064
|
if (content.charCodeAt(0) === 0xfeff) {
|
|
1064
1065
|
content = content.slice(1);
|
|
@@ -1067,8 +1068,8 @@ class AstericsGridProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
1067
1068
|
// Apply translations directly to the JSON structure for comprehensive coverage
|
|
1068
1069
|
this.applyTranslationsToGridFile(grdFile, translations);
|
|
1069
1070
|
// Write the translated file
|
|
1070
|
-
|
|
1071
|
-
return
|
|
1071
|
+
await writeTextToPath(outputPath, JSON.stringify(grdFile, null, 2));
|
|
1072
|
+
return await readBinaryFromInput(outputPath);
|
|
1072
1073
|
}
|
|
1073
1074
|
applyTranslationsToGridFile(grdFile, translations) {
|
|
1074
1075
|
grdFile.grids.forEach((grid) => {
|
|
@@ -1180,7 +1181,7 @@ class AstericsGridProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
1180
1181
|
}
|
|
1181
1182
|
}
|
|
1182
1183
|
async saveFromTree(tree, outputPath) {
|
|
1183
|
-
|
|
1184
|
+
const { writeTextToPath } = this.options.fileAdapter;
|
|
1184
1185
|
// Use default Asterics Grid styling instead of taking from first page
|
|
1185
1186
|
// This prevents issues where the first page has unusual colors (like purple)
|
|
1186
1187
|
const defaultPageStyle = {
|
|
@@ -1383,13 +1384,14 @@ class AstericsGridProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
1383
1384
|
},
|
|
1384
1385
|
},
|
|
1385
1386
|
};
|
|
1386
|
-
|
|
1387
|
+
await writeTextToPath(outputPath, JSON.stringify(grdFile, null, 2));
|
|
1387
1388
|
}
|
|
1388
1389
|
/**
|
|
1389
1390
|
* Add audio recording to a specific grid element
|
|
1390
1391
|
*/
|
|
1391
|
-
addAudioToElement(filePath, elementId, audioData, metadata) {
|
|
1392
|
-
|
|
1392
|
+
async addAudioToElement(filePath, elementId, audioData, metadata) {
|
|
1393
|
+
const { readTextFromInput, writeTextToPath } = this.options.fileAdapter;
|
|
1394
|
+
let content = await readTextFromInput(filePath);
|
|
1393
1395
|
// Remove BOM if present
|
|
1394
1396
|
if (content.charCodeAt(0) === 0xfeff) {
|
|
1395
1397
|
content = content.slice(1);
|
|
@@ -1432,31 +1434,33 @@ class AstericsGridProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
1432
1434
|
throw new Error(`Element with ID ${elementId} not found`);
|
|
1433
1435
|
}
|
|
1434
1436
|
// Write back to file
|
|
1435
|
-
|
|
1437
|
+
await writeTextToPath(filePath, JSON.stringify(grdFile, null, 2));
|
|
1436
1438
|
}
|
|
1437
1439
|
/**
|
|
1438
1440
|
* Create a copy of the grid file with audio recordings added
|
|
1439
1441
|
*/
|
|
1440
|
-
createAudioEnhancedGridFile(sourceFilePath, targetFilePath, audioMappings) {
|
|
1442
|
+
async createAudioEnhancedGridFile(sourceFilePath, targetFilePath, audioMappings) {
|
|
1443
|
+
const { writeBinaryToPath, readBinaryFromInput } = this.options.fileAdapter;
|
|
1441
1444
|
// Copy the source file to target
|
|
1442
|
-
|
|
1443
|
-
fs.copyFileSync(sourceFilePath, targetFilePath);
|
|
1445
|
+
await writeBinaryToPath(targetFilePath, await readBinaryFromInput(sourceFilePath));
|
|
1444
1446
|
// Add audio recordings to the copy
|
|
1445
|
-
audioMappings.
|
|
1447
|
+
await Promise.all(Object.entries(audioMappings).map(async (item) => {
|
|
1448
|
+
const [elementId, audioInfo] = item;
|
|
1446
1449
|
try {
|
|
1447
|
-
this.addAudioToElement(targetFilePath, elementId, audioInfo.audioData, audioInfo.metadata);
|
|
1450
|
+
await this.addAudioToElement(targetFilePath, elementId, audioInfo.audioData, audioInfo.metadata);
|
|
1448
1451
|
}
|
|
1449
1452
|
catch (error) {
|
|
1450
1453
|
// Failed to add audio to element - continue with others
|
|
1451
1454
|
console.warn(`Failed to add audio to element ${elementId}:`, error);
|
|
1452
1455
|
}
|
|
1453
|
-
});
|
|
1456
|
+
}));
|
|
1454
1457
|
}
|
|
1455
1458
|
/**
|
|
1456
1459
|
* Extract all element IDs from the grid file for audio mapping
|
|
1457
1460
|
*/
|
|
1458
|
-
getElementIds(filePathOrBuffer) {
|
|
1459
|
-
|
|
1461
|
+
async getElementIds(filePathOrBuffer) {
|
|
1462
|
+
const { readTextFromInput } = this.options.fileAdapter;
|
|
1463
|
+
let content = await readTextFromInput(filePathOrBuffer);
|
|
1460
1464
|
// Remove BOM if present
|
|
1461
1465
|
if (content.charCodeAt(0) === 0xfeff) {
|
|
1462
1466
|
content = content.slice(1);
|
|
@@ -1478,8 +1482,9 @@ class AstericsGridProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
1478
1482
|
/**
|
|
1479
1483
|
* Check if an element has audio recording
|
|
1480
1484
|
*/
|
|
1481
|
-
hasAudioRecording(filePathOrBuffer, elementId) {
|
|
1482
|
-
|
|
1485
|
+
async hasAudioRecording(filePathOrBuffer, elementId) {
|
|
1486
|
+
const { readTextFromInput } = this.options.fileAdapter;
|
|
1487
|
+
let content = await readTextFromInput(filePathOrBuffer);
|
|
1483
1488
|
// Remove BOM if present
|
|
1484
1489
|
if (content.charCodeAt(0) === 0xfeff) {
|
|
1485
1490
|
content = content.slice(1);
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DotProcessor = void 0;
|
|
4
4
|
const baseProcessor_1 = require("../core/baseProcessor");
|
|
5
5
|
const treeStructure_1 = require("../core/treeStructure");
|
|
6
|
-
// Removed unused import: FileProcessor
|
|
7
6
|
const validationTypes_1 = require("../validation/validationTypes");
|
|
8
7
|
const io_1 = require("../utils/io");
|
|
9
8
|
class DotProcessor extends baseProcessor_1.BaseProcessor {
|
|
@@ -52,8 +51,8 @@ class DotProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
52
51
|
return { nodes: Array.from(nodes.values()), edges };
|
|
53
52
|
}
|
|
54
53
|
async extractTexts(filePathOrBuffer) {
|
|
55
|
-
|
|
56
|
-
const content =
|
|
54
|
+
const { readTextFromInput } = this.options.fileAdapter;
|
|
55
|
+
const content = await readTextFromInput(filePathOrBuffer);
|
|
57
56
|
const { nodes, edges } = this.parseDotFile(content);
|
|
58
57
|
const texts = [];
|
|
59
58
|
// Collect node labels
|
|
@@ -69,12 +68,12 @@ class DotProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
69
68
|
return texts;
|
|
70
69
|
}
|
|
71
70
|
async loadIntoTree(filePathOrBuffer) {
|
|
72
|
-
|
|
71
|
+
const { readBinaryFromInput, readTextFromInput } = this.options.fileAdapter;
|
|
73
72
|
const filename = typeof filePathOrBuffer === 'string' ? (0, io_1.getBasename)(filePathOrBuffer) : 'upload.dot';
|
|
74
|
-
const buffer =
|
|
73
|
+
const buffer = await readBinaryFromInput(filePathOrBuffer);
|
|
75
74
|
const filesize = buffer.byteLength;
|
|
76
75
|
try {
|
|
77
|
-
const content =
|
|
76
|
+
const content = await readTextFromInput(buffer);
|
|
78
77
|
if (!content || content.trim().length === 0) {
|
|
79
78
|
const validation = (0, validationTypes_1.buildValidationResultFromMessage)({
|
|
80
79
|
filename,
|
|
@@ -158,8 +157,8 @@ class DotProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
158
157
|
}
|
|
159
158
|
}
|
|
160
159
|
async processTexts(filePathOrBuffer, translations, outputPath) {
|
|
161
|
-
|
|
162
|
-
const content =
|
|
160
|
+
const { readTextFromInput, writeBinaryToPath } = this.options.fileAdapter;
|
|
161
|
+
const content = await readTextFromInput(filePathOrBuffer);
|
|
163
162
|
let translatedContent = content;
|
|
164
163
|
translations.forEach((translation, text) => {
|
|
165
164
|
if (typeof text === 'string' && typeof translation === 'string') {
|
|
@@ -170,11 +169,11 @@ class DotProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
170
169
|
}
|
|
171
170
|
});
|
|
172
171
|
const resultBuffer = (0, io_1.encodeText)(translatedContent || '');
|
|
173
|
-
|
|
172
|
+
await writeBinaryToPath(outputPath, resultBuffer);
|
|
174
173
|
return resultBuffer;
|
|
175
174
|
}
|
|
176
175
|
async saveFromTree(tree, _outputPath) {
|
|
177
|
-
|
|
176
|
+
const { writeTextToPath } = this.options.fileAdapter;
|
|
178
177
|
let dotContent = `digraph "${tree.metadata?.name || 'AACBoard'}" {\n`;
|
|
179
178
|
// Helper to escape DOT string
|
|
180
179
|
const escapeDotString = (str) => {
|
|
@@ -204,7 +203,7 @@ class DotProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
204
203
|
});
|
|
205
204
|
}
|
|
206
205
|
dotContent += '}\n';
|
|
207
|
-
|
|
206
|
+
await writeTextToPath(_outputPath, dotContent);
|
|
208
207
|
}
|
|
209
208
|
/**
|
|
210
209
|
* Extract strings with metadata for aac-tools-platform compatibility
|
|
@@ -11,13 +11,13 @@ export declare class ExcelProcessor extends BaseProcessor {
|
|
|
11
11
|
/**
|
|
12
12
|
* Extract all text content from an Excel file
|
|
13
13
|
* @param filePathOrBuffer - Path to Excel file or Buffer containing Excel data
|
|
14
|
-
* @returns
|
|
14
|
+
* @returns Promise resolving to all text content found in the Excel file
|
|
15
15
|
*/
|
|
16
16
|
extractTexts(_filePathOrBuffer: ProcessorInput): Promise<string[]>;
|
|
17
17
|
/**
|
|
18
18
|
* Load Excel file into AACTree structure
|
|
19
19
|
* @param filePathOrBuffer - Path to Excel file or Buffer containing Excel data
|
|
20
|
-
* @returns AACTree representation of the Excel file
|
|
20
|
+
* @returns Promise resolving to an AACTree representation of the Excel file
|
|
21
21
|
*/
|
|
22
22
|
loadIntoTree(_filePathOrBuffer: ProcessorInput): Promise<AACTree>;
|
|
23
23
|
/**
|
|
@@ -25,7 +25,7 @@ export declare class ExcelProcessor extends BaseProcessor {
|
|
|
25
25
|
* @param filePathOrBuffer - Path to Excel file or Buffer containing Excel data
|
|
26
26
|
* @param translations - Map of original text to translated text
|
|
27
27
|
* @param outputPath - Path where translated Excel file should be saved
|
|
28
|
-
* @returns
|
|
28
|
+
* @returns Promise resolving to a buffer containing the translated Excel file
|
|
29
29
|
*/
|
|
30
30
|
processTexts(_filePathOrBuffer: ProcessorInput, _translations: Map<string, string>, outputPath: string): Promise<Uint8Array>;
|
|
31
31
|
/**
|
|
@@ -22,13 +22,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
26
|
exports.ExcelProcessor = void 0;
|
|
30
|
-
const fs_1 = __importDefault(require("fs"));
|
|
31
|
-
const path_1 = __importDefault(require("path"));
|
|
32
27
|
const ExcelJS = __importStar(require("exceljs"));
|
|
33
28
|
const baseProcessor_1 = require("../core/baseProcessor");
|
|
34
29
|
const treeStructure_1 = require("../core/treeStructure");
|
|
@@ -41,38 +36,36 @@ class ExcelProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
41
36
|
/**
|
|
42
37
|
* Extract all text content from an Excel file
|
|
43
38
|
* @param filePathOrBuffer - Path to Excel file or Buffer containing Excel data
|
|
44
|
-
* @returns
|
|
39
|
+
* @returns Promise resolving to all text content found in the Excel file
|
|
45
40
|
*/
|
|
46
41
|
async extractTexts(_filePathOrBuffer) {
|
|
47
|
-
await Promise.resolve();
|
|
48
42
|
console.warn('ExcelProcessor.extractTexts is not implemented yet.');
|
|
49
|
-
return [];
|
|
43
|
+
return Promise.resolve([]);
|
|
50
44
|
}
|
|
51
45
|
/**
|
|
52
46
|
* Load Excel file into AACTree structure
|
|
53
47
|
* @param filePathOrBuffer - Path to Excel file or Buffer containing Excel data
|
|
54
|
-
* @returns AACTree representation of the Excel file
|
|
48
|
+
* @returns Promise resolving to an AACTree representation of the Excel file
|
|
55
49
|
*/
|
|
56
50
|
async loadIntoTree(_filePathOrBuffer) {
|
|
57
|
-
await Promise.resolve();
|
|
58
51
|
console.warn('ExcelProcessor.loadIntoTree is not implemented yet.');
|
|
59
52
|
const tree = new treeStructure_1.AACTree();
|
|
60
53
|
tree.metadata.format = 'excel';
|
|
61
|
-
return tree;
|
|
54
|
+
return Promise.resolve(tree);
|
|
62
55
|
}
|
|
63
56
|
/**
|
|
64
57
|
* Process texts in Excel file (apply translations)
|
|
65
58
|
* @param filePathOrBuffer - Path to Excel file or Buffer containing Excel data
|
|
66
59
|
* @param translations - Map of original text to translated text
|
|
67
60
|
* @param outputPath - Path where translated Excel file should be saved
|
|
68
|
-
* @returns
|
|
61
|
+
* @returns Promise resolving to a buffer containing the translated Excel file
|
|
69
62
|
*/
|
|
70
63
|
async processTexts(_filePathOrBuffer, _translations, outputPath) {
|
|
71
|
-
|
|
64
|
+
const { dirname, pathExists, mkDir } = this.options.fileAdapter;
|
|
72
65
|
console.warn('ExcelProcessor.processTexts is not implemented yet.');
|
|
73
|
-
const outputDir =
|
|
74
|
-
if (!
|
|
75
|
-
|
|
66
|
+
const outputDir = dirname(outputPath);
|
|
67
|
+
if (!(await pathExists(outputDir))) {
|
|
68
|
+
await mkDir(outputDir, { recursive: true });
|
|
76
69
|
}
|
|
77
70
|
return Buffer.alloc(0);
|
|
78
71
|
}
|
|
@@ -468,8 +461,9 @@ class ExcelProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
468
461
|
* Note: This method is async but maintains the sync interface for compatibility
|
|
469
462
|
*/
|
|
470
463
|
async saveFromTree(tree, outputPath) {
|
|
471
|
-
const
|
|
472
|
-
|
|
464
|
+
const { mkDir, dirname, writeTextToPath } = this.options.fileAdapter;
|
|
465
|
+
const outputDir = dirname(outputPath);
|
|
466
|
+
await mkDir(outputDir, { recursive: true });
|
|
473
467
|
try {
|
|
474
468
|
await this.saveFromTreeAsync(tree, outputPath);
|
|
475
469
|
}
|
|
@@ -478,8 +472,8 @@ class ExcelProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
478
472
|
console.error('Failed to save Excel file:', message);
|
|
479
473
|
try {
|
|
480
474
|
const fallbackPath = outputPath.replace(/\.xlsx$/i, '_error.txt');
|
|
481
|
-
|
|
482
|
-
|
|
475
|
+
await mkDir(dirname(fallbackPath), { recursive: true });
|
|
476
|
+
await writeTextToPath(fallbackPath, `Error saving Excel file: ${message}`);
|
|
483
477
|
}
|
|
484
478
|
catch (writeError) {
|
|
485
479
|
console.error('Failed to write Excel error file:', writeError);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AACTree, AACSemanticCategory, AACSemanticIntent } from '../../core/treeStructure';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { FileAdapter, ProcessorInput } from '../../utils/io';
|
|
3
|
+
import { ZipAdapter } from '../../utils/zip';
|
|
4
4
|
/**
|
|
5
5
|
* Build a map of button IDs to resolved image entry paths for a specific page.
|
|
6
6
|
* Helpful when rewriting zip entry names or validating images referenced in a grid.
|
|
@@ -17,9 +17,7 @@ export declare function getAllowedImageEntries(tree: AACTree): Set<string>;
|
|
|
17
17
|
* @param entryPath Entry name inside the zip
|
|
18
18
|
* @returns Image data buffer or null if not found
|
|
19
19
|
*/
|
|
20
|
-
export declare function openImage(gridsetBuffer: Uint8Array, entryPath: string, password?: string | undefined, zipAdapter?: (input
|
|
21
|
-
zip: ZipAdapter;
|
|
22
|
-
}>): Promise<Uint8Array | null>;
|
|
20
|
+
export declare function openImage(gridsetBuffer: Uint8Array, entryPath: string, password?: string | undefined, fileAdapter?: FileAdapter, zipAdapter?: (input?: ProcessorInput) => Promise<ZipAdapter>): Promise<Uint8Array | null>;
|
|
23
21
|
/**
|
|
24
22
|
* Generate a random GUID for Grid3 elements
|
|
25
23
|
* Grid3 uses GUIDs for grid identification
|
|
@@ -90,49 +88,49 @@ export declare function getCommonDocumentsPath(): string;
|
|
|
90
88
|
* C:\Users\Public\Documents\Smartbox\Grid 3\Users\{UserName}\Grid Sets\
|
|
91
89
|
* @returns Array of Grid3 user path information
|
|
92
90
|
*/
|
|
93
|
-
export declare function findGrid3UserPaths(): Grid3UserPath[]
|
|
91
|
+
export declare function findGrid3UserPaths(fileAdapter?: FileAdapter): Promise<Grid3UserPath[]>;
|
|
94
92
|
/**
|
|
95
93
|
* Find all Grid3 history database paths
|
|
96
94
|
* Convenience method that returns just the database file paths
|
|
97
95
|
* @returns Array of paths to history.sqlite files
|
|
98
96
|
*/
|
|
99
|
-
export declare function findGrid3HistoryDatabases(): string[]
|
|
97
|
+
export declare function findGrid3HistoryDatabases(fileAdapter?: FileAdapter): Promise<string[]>;
|
|
100
98
|
/**
|
|
101
99
|
* Get Grid 3 users (alias of findGrid3UserPaths for clarity)
|
|
102
100
|
*/
|
|
103
|
-
export declare function findGrid3Users(): Grid3UserPath[]
|
|
101
|
+
export declare function findGrid3Users(): Promise<Grid3UserPath[]>;
|
|
104
102
|
/**
|
|
105
103
|
* Find Grid 3 gridset/vocabulary files for each user
|
|
106
104
|
* @param userName Optional user filter; matches case-insensitively
|
|
107
105
|
* @returns Array of user/gridset path pairs
|
|
108
106
|
*/
|
|
109
|
-
export declare function findGrid3Vocabularies(userName?: string): Grid3VocabularyPath[]
|
|
107
|
+
export declare function findGrid3Vocabularies(userName?: string, fileAdapter?: FileAdapter): Promise<Grid3VocabularyPath[]>;
|
|
110
108
|
/**
|
|
111
109
|
* Find a specific user's Grid 3 history database
|
|
112
110
|
* @param userName User name to search for (case-insensitive)
|
|
113
111
|
* @param langCode Optional language code filter (case-insensitive)
|
|
114
112
|
* @returns Path to history.sqlite or null if not found
|
|
115
113
|
*/
|
|
116
|
-
export declare function findGrid3UserHistory(userName: string, langCode?: string): string | null
|
|
114
|
+
export declare function findGrid3UserHistory(userName: string, langCode?: string, fileAdapter?: FileAdapter): Promise<string | null>;
|
|
117
115
|
/**
|
|
118
116
|
* Check whether Grid 3 appears to be installed (Windows only)
|
|
119
117
|
*/
|
|
120
|
-
export declare function isGrid3Installed(): boolean
|
|
118
|
+
export declare function isGrid3Installed(fileAdapter?: FileAdapter): Promise<boolean>;
|
|
121
119
|
/**
|
|
122
120
|
* Read history events from a Grid 3 history.sqlite database.
|
|
123
121
|
* @param historyDbPath Absolute path to the history database
|
|
124
122
|
* @returns Parsed history entries grouped by phrase
|
|
125
123
|
*/
|
|
126
|
-
export declare function readGrid3History(historyDbPath: string): Grid3HistoryEntry[]
|
|
124
|
+
export declare function readGrid3History(historyDbPath: string, fileAdapter?: FileAdapter): Promise<Grid3HistoryEntry[]>;
|
|
127
125
|
/**
|
|
128
126
|
* Convenience wrapper to load history for a specific Grid 3 user/lang combination.
|
|
129
127
|
* @param userName Grid 3 user name (case-insensitive)
|
|
130
128
|
* @param langCode Optional language code to narrow selection (case-insensitive)
|
|
131
129
|
* @returns History entries for that user/language, or empty array if none
|
|
132
130
|
*/
|
|
133
|
-
export declare function readGrid3HistoryForUser(userName: string, langCode?: string): Grid3HistoryEntry[]
|
|
131
|
+
export declare function readGrid3HistoryForUser(userName: string, langCode?: string): Promise<Grid3HistoryEntry[]>;
|
|
134
132
|
/**
|
|
135
133
|
* Load all available Grid 3 histories on the machine.
|
|
136
134
|
* @returns Combined history entries from every discovered history.sqlite
|
|
137
135
|
*/
|
|
138
|
-
export declare function readAllGrid3History(): Grid3HistoryEntry[]
|
|
136
|
+
export declare function readAllGrid3History(): Promise<Grid3HistoryEntry[]>;
|