@willwade/aac-processors 0.2.15 → 0.2.16
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.
|
@@ -2227,9 +2227,8 @@ class GridsetProcessor extends BaseProcessor {
|
|
|
2227
2227
|
await writeBinaryToPath(outputPath, originalBuffer);
|
|
2228
2228
|
return;
|
|
2229
2229
|
}
|
|
2230
|
-
const
|
|
2231
|
-
const
|
|
2232
|
-
const outputZip = new AdmZip();
|
|
2230
|
+
const originalZip = await this.options.zipAdapter(originalPath);
|
|
2231
|
+
const outputZip = await this.options.zipAdapter();
|
|
2233
2232
|
// Check if any page has pending mutations
|
|
2234
2233
|
const hasPendingMutations = Object.values(tree.pages).some((page) => page.pendingMutations.length > 0);
|
|
2235
2234
|
if (hasPendingMutations) {
|
|
@@ -2246,15 +2245,13 @@ class GridsetProcessor extends BaseProcessor {
|
|
|
2246
2245
|
suppressBooleanAttributes: false,
|
|
2247
2246
|
});
|
|
2248
2247
|
GridsetSaveHandler.saveWithMutations(tree, originalZip, outputZip, parser, gridBuilder, (page) => this.createBasicGridXml(page));
|
|
2249
|
-
// Copy
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
outputZip.addFile(entry.entryName, entry.getData());
|
|
2255
|
-
}
|
|
2248
|
+
// Copy files
|
|
2249
|
+
const outputFiles = [];
|
|
2250
|
+
for (const name of originalZip.listFiles()) {
|
|
2251
|
+
const data = await originalZip.readFile(name);
|
|
2252
|
+
outputFiles.push({ name, data });
|
|
2256
2253
|
}
|
|
2257
|
-
const outputBuffer = outputZip.
|
|
2254
|
+
const outputBuffer = await outputZip.writeFiles(outputFiles);
|
|
2258
2255
|
await writeBinaryToPath(outputPath, outputBuffer);
|
|
2259
2256
|
return;
|
|
2260
2257
|
}
|
|
@@ -2285,15 +2282,15 @@ class GridsetProcessor extends BaseProcessor {
|
|
|
2285
2282
|
const gridPath = `Grids/${page.name}/grid.xml`;
|
|
2286
2283
|
modifiedGridFiles.add(gridPath);
|
|
2287
2284
|
// Try to get the original grid.xml file
|
|
2288
|
-
const
|
|
2289
|
-
if (!
|
|
2285
|
+
const originalEntries = originalZip.listFiles();
|
|
2286
|
+
if (!originalEntries.includes(gridPath)) {
|
|
2290
2287
|
// If original doesn't exist, create a new basic grid
|
|
2291
2288
|
const basicGrid = this.createBasicGridXml(page);
|
|
2292
2289
|
newGridFiles.set(gridPath, basicGrid);
|
|
2293
2290
|
continue;
|
|
2294
2291
|
}
|
|
2295
2292
|
// Parse the original grid XML
|
|
2296
|
-
const originalContent =
|
|
2293
|
+
const originalContent = (await originalZip.readFile(gridPath)).toString();
|
|
2297
2294
|
const originalGrid = parser.parse(originalContent);
|
|
2298
2295
|
if (!originalGrid.Grid) {
|
|
2299
2296
|
// Invalid grid structure, create a basic one
|
|
@@ -2458,22 +2455,22 @@ class GridsetProcessor extends BaseProcessor {
|
|
|
2458
2455
|
newGridFiles.set(gridPath, builtXml);
|
|
2459
2456
|
}
|
|
2460
2457
|
// Copy all files from original zip, replacing modified grid files
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
continue;
|
|
2458
|
+
const outputFiles = [];
|
|
2459
|
+
for (const entry of originalZip.listFiles()) {
|
|
2464
2460
|
// Skip grid.xml files that we're modifying
|
|
2465
|
-
if (modifiedGridFiles.has(entry
|
|
2466
|
-
const newContent = newGridFiles.get(entry
|
|
2461
|
+
if (modifiedGridFiles.has(entry)) {
|
|
2462
|
+
const newContent = newGridFiles.get(entry);
|
|
2467
2463
|
if (newContent) {
|
|
2468
|
-
|
|
2464
|
+
outputFiles.push({ name: entry, data: Buffer.from(newContent, 'utf8') });
|
|
2469
2465
|
}
|
|
2470
2466
|
continue;
|
|
2471
2467
|
}
|
|
2472
2468
|
// Copy all other files as-is
|
|
2473
|
-
|
|
2469
|
+
const data = await originalZip.readFile(entry);
|
|
2470
|
+
outputFiles.push({ name: entry, data });
|
|
2474
2471
|
}
|
|
2475
2472
|
// Write the output ZIP
|
|
2476
|
-
const outputBuffer = outputZip.
|
|
2473
|
+
const outputBuffer = await outputZip.writeFiles(outputFiles);
|
|
2477
2474
|
await writeBinaryToPath(outputPath, outputBuffer);
|
|
2478
2475
|
}
|
|
2479
2476
|
/**
|
|
@@ -741,24 +741,18 @@ class ObfProcessor extends BaseProcessor {
|
|
|
741
741
|
await writeBinaryToPath(outputPath, originalBuffer);
|
|
742
742
|
return;
|
|
743
743
|
}
|
|
744
|
-
const
|
|
745
|
-
const
|
|
746
|
-
const
|
|
747
|
-
// Track which .obf files we're modifying
|
|
748
|
-
const modifiedObfFiles = new Set();
|
|
749
|
-
// Generate new .obf files for pages in the tree
|
|
750
|
-
const newObfFiles = new Map();
|
|
744
|
+
const originalZip = await this.options.zipAdapter(originalPath);
|
|
745
|
+
const outputZip = await this.options.zipAdapter();
|
|
746
|
+
const outputFiles = [];
|
|
751
747
|
for (const page of Object.values(tree.pages)) {
|
|
752
|
-
const
|
|
753
|
-
modifiedObfFiles.add(obfFilename);
|
|
748
|
+
const name = this.getPageFilename(page.id, tree.metadata);
|
|
754
749
|
// createObfBoardFromPage will automatically apply mutations if present
|
|
755
750
|
const obfBoard = this.createObfBoardFromPage(page, 'Board', tree.metadata);
|
|
756
|
-
const
|
|
757
|
-
|
|
751
|
+
const data = JSON.stringify(obfBoard, null, 2);
|
|
752
|
+
outputFiles.push({ name, data });
|
|
758
753
|
}
|
|
759
754
|
// Generate updated manifest if we have pages
|
|
760
755
|
if (Object.keys(tree.pages).length > 0) {
|
|
761
|
-
modifiedObfFiles.add('manifest.json');
|
|
762
756
|
const manifest = {
|
|
763
757
|
format: OBF_FORMAT_VERSION,
|
|
764
758
|
root: tree.metadata.defaultHomePageId,
|
|
@@ -771,25 +765,18 @@ class ObfProcessor extends BaseProcessor {
|
|
|
771
765
|
sounds: {},
|
|
772
766
|
},
|
|
773
767
|
};
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
const newContent = newObfFiles.get(entry.entryName);
|
|
783
|
-
if (newContent) {
|
|
784
|
-
outputZip.addFile(entry.entryName, Buffer.from(newContent, 'utf8'));
|
|
785
|
-
}
|
|
786
|
-
continue;
|
|
768
|
+
const data = Buffer.from(JSON.stringify(manifest), 'utf8');
|
|
769
|
+
outputFiles.push({ name: 'manifest.json', data });
|
|
770
|
+
}
|
|
771
|
+
// Add remaining .obf from original zip
|
|
772
|
+
for (const entry of originalZip.listFiles()) {
|
|
773
|
+
if (!outputFiles.find((file) => file.name === entry)) {
|
|
774
|
+
const data = await originalZip.readFile(entry);
|
|
775
|
+
outputFiles.push({ name: entry, data });
|
|
787
776
|
}
|
|
788
|
-
// Copy all other files as-is (preserves images, sounds, etc.)
|
|
789
|
-
outputZip.addFile(entry.entryName, entry.getData());
|
|
790
777
|
}
|
|
791
778
|
// Write the output ZIP
|
|
792
|
-
const outputBuffer = outputZip.
|
|
779
|
+
const outputBuffer = await outputZip.writeFiles(outputFiles);
|
|
793
780
|
await writeBinaryToPath(outputPath, outputBuffer);
|
|
794
781
|
}
|
|
795
782
|
/**
|
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.GridsetProcessor = void 0;
|
|
27
4
|
const baseProcessor_1 = require("../core/baseProcessor");
|
|
@@ -2253,9 +2230,8 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
2253
2230
|
await writeBinaryToPath(outputPath, originalBuffer);
|
|
2254
2231
|
return;
|
|
2255
2232
|
}
|
|
2256
|
-
const
|
|
2257
|
-
const
|
|
2258
|
-
const outputZip = new AdmZip();
|
|
2233
|
+
const originalZip = await this.options.zipAdapter(originalPath);
|
|
2234
|
+
const outputZip = await this.options.zipAdapter();
|
|
2259
2235
|
// Check if any page has pending mutations
|
|
2260
2236
|
const hasPendingMutations = Object.values(tree.pages).some((page) => page.pendingMutations.length > 0);
|
|
2261
2237
|
if (hasPendingMutations) {
|
|
@@ -2272,15 +2248,13 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
2272
2248
|
suppressBooleanAttributes: false,
|
|
2273
2249
|
});
|
|
2274
2250
|
saveMutations_1.GridsetSaveHandler.saveWithMutations(tree, originalZip, outputZip, parser, gridBuilder, (page) => this.createBasicGridXml(page));
|
|
2275
|
-
// Copy
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
outputZip.addFile(entry.entryName, entry.getData());
|
|
2281
|
-
}
|
|
2251
|
+
// Copy files
|
|
2252
|
+
const outputFiles = [];
|
|
2253
|
+
for (const name of originalZip.listFiles()) {
|
|
2254
|
+
const data = await originalZip.readFile(name);
|
|
2255
|
+
outputFiles.push({ name, data });
|
|
2282
2256
|
}
|
|
2283
|
-
const outputBuffer = outputZip.
|
|
2257
|
+
const outputBuffer = await outputZip.writeFiles(outputFiles);
|
|
2284
2258
|
await writeBinaryToPath(outputPath, outputBuffer);
|
|
2285
2259
|
return;
|
|
2286
2260
|
}
|
|
@@ -2311,15 +2285,15 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
2311
2285
|
const gridPath = `Grids/${page.name}/grid.xml`;
|
|
2312
2286
|
modifiedGridFiles.add(gridPath);
|
|
2313
2287
|
// Try to get the original grid.xml file
|
|
2314
|
-
const
|
|
2315
|
-
if (!
|
|
2288
|
+
const originalEntries = originalZip.listFiles();
|
|
2289
|
+
if (!originalEntries.includes(gridPath)) {
|
|
2316
2290
|
// If original doesn't exist, create a new basic grid
|
|
2317
2291
|
const basicGrid = this.createBasicGridXml(page);
|
|
2318
2292
|
newGridFiles.set(gridPath, basicGrid);
|
|
2319
2293
|
continue;
|
|
2320
2294
|
}
|
|
2321
2295
|
// Parse the original grid XML
|
|
2322
|
-
const originalContent =
|
|
2296
|
+
const originalContent = (await originalZip.readFile(gridPath)).toString();
|
|
2323
2297
|
const originalGrid = parser.parse(originalContent);
|
|
2324
2298
|
if (!originalGrid.Grid) {
|
|
2325
2299
|
// Invalid grid structure, create a basic one
|
|
@@ -2484,22 +2458,22 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
2484
2458
|
newGridFiles.set(gridPath, builtXml);
|
|
2485
2459
|
}
|
|
2486
2460
|
// Copy all files from original zip, replacing modified grid files
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
continue;
|
|
2461
|
+
const outputFiles = [];
|
|
2462
|
+
for (const entry of originalZip.listFiles()) {
|
|
2490
2463
|
// Skip grid.xml files that we're modifying
|
|
2491
|
-
if (modifiedGridFiles.has(entry
|
|
2492
|
-
const newContent = newGridFiles.get(entry
|
|
2464
|
+
if (modifiedGridFiles.has(entry)) {
|
|
2465
|
+
const newContent = newGridFiles.get(entry);
|
|
2493
2466
|
if (newContent) {
|
|
2494
|
-
|
|
2467
|
+
outputFiles.push({ name: entry, data: Buffer.from(newContent, 'utf8') });
|
|
2495
2468
|
}
|
|
2496
2469
|
continue;
|
|
2497
2470
|
}
|
|
2498
2471
|
// Copy all other files as-is
|
|
2499
|
-
|
|
2472
|
+
const data = await originalZip.readFile(entry);
|
|
2473
|
+
outputFiles.push({ name: entry, data });
|
|
2500
2474
|
}
|
|
2501
2475
|
// Write the output ZIP
|
|
2502
|
-
const outputBuffer = outputZip.
|
|
2476
|
+
const outputBuffer = await outputZip.writeFiles(outputFiles);
|
|
2503
2477
|
await writeBinaryToPath(outputPath, outputBuffer);
|
|
2504
2478
|
}
|
|
2505
2479
|
/**
|
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.ObfProcessor = void 0;
|
|
27
4
|
const baseProcessor_1 = require("../core/baseProcessor");
|
|
@@ -767,24 +744,18 @@ class ObfProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
767
744
|
await writeBinaryToPath(outputPath, originalBuffer);
|
|
768
745
|
return;
|
|
769
746
|
}
|
|
770
|
-
const
|
|
771
|
-
const
|
|
772
|
-
const
|
|
773
|
-
// Track which .obf files we're modifying
|
|
774
|
-
const modifiedObfFiles = new Set();
|
|
775
|
-
// Generate new .obf files for pages in the tree
|
|
776
|
-
const newObfFiles = new Map();
|
|
747
|
+
const originalZip = await this.options.zipAdapter(originalPath);
|
|
748
|
+
const outputZip = await this.options.zipAdapter();
|
|
749
|
+
const outputFiles = [];
|
|
777
750
|
for (const page of Object.values(tree.pages)) {
|
|
778
|
-
const
|
|
779
|
-
modifiedObfFiles.add(obfFilename);
|
|
751
|
+
const name = this.getPageFilename(page.id, tree.metadata);
|
|
780
752
|
// createObfBoardFromPage will automatically apply mutations if present
|
|
781
753
|
const obfBoard = this.createObfBoardFromPage(page, 'Board', tree.metadata);
|
|
782
|
-
const
|
|
783
|
-
|
|
754
|
+
const data = JSON.stringify(obfBoard, null, 2);
|
|
755
|
+
outputFiles.push({ name, data });
|
|
784
756
|
}
|
|
785
757
|
// Generate updated manifest if we have pages
|
|
786
758
|
if (Object.keys(tree.pages).length > 0) {
|
|
787
|
-
modifiedObfFiles.add('manifest.json');
|
|
788
759
|
const manifest = {
|
|
789
760
|
format: OBF_FORMAT_VERSION,
|
|
790
761
|
root: tree.metadata.defaultHomePageId,
|
|
@@ -797,25 +768,18 @@ class ObfProcessor extends baseProcessor_1.BaseProcessor {
|
|
|
797
768
|
sounds: {},
|
|
798
769
|
},
|
|
799
770
|
};
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
const newContent = newObfFiles.get(entry.entryName);
|
|
809
|
-
if (newContent) {
|
|
810
|
-
outputZip.addFile(entry.entryName, Buffer.from(newContent, 'utf8'));
|
|
811
|
-
}
|
|
812
|
-
continue;
|
|
771
|
+
const data = Buffer.from(JSON.stringify(manifest), 'utf8');
|
|
772
|
+
outputFiles.push({ name: 'manifest.json', data });
|
|
773
|
+
}
|
|
774
|
+
// Add remaining .obf from original zip
|
|
775
|
+
for (const entry of originalZip.listFiles()) {
|
|
776
|
+
if (!outputFiles.find((file) => file.name === entry)) {
|
|
777
|
+
const data = await originalZip.readFile(entry);
|
|
778
|
+
outputFiles.push({ name: entry, data });
|
|
813
779
|
}
|
|
814
|
-
// Copy all other files as-is (preserves images, sounds, etc.)
|
|
815
|
-
outputZip.addFile(entry.entryName, entry.getData());
|
|
816
780
|
}
|
|
817
781
|
// Write the output ZIP
|
|
818
|
-
const outputBuffer = outputZip.
|
|
782
|
+
const outputBuffer = await outputZip.writeFiles(outputFiles);
|
|
819
783
|
await writeBinaryToPath(outputPath, outputBuffer);
|
|
820
784
|
}
|
|
821
785
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willwade/aac-processors",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"description": "A comprehensive TypeScript library for processing AAC (Augmentative and Alternative Communication) file formats with translation support",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"browser": "dist/browser/index.browser.js",
|