@willwade/aac-processors 0.1.21 → 0.2.1

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.
Files changed (87) hide show
  1. package/README.md +3 -2
  2. package/dist/browser/processors/applePanelsProcessor.js +24 -24
  3. package/dist/browser/processors/astericsGridProcessor.js +22 -24
  4. package/dist/browser/processors/dotProcessor.js +6 -10
  5. package/dist/browser/processors/gridset/helpers.js +33 -30
  6. package/dist/browser/processors/gridset/symbolExtractor.js +2 -2
  7. package/dist/browser/processors/gridset/symbolSearch.js +22 -22
  8. package/dist/browser/processors/gridset/symbols.js +14 -14
  9. package/dist/browser/processors/gridsetProcessor.js +7 -7
  10. package/dist/browser/processors/obfProcessor.js +54 -47
  11. package/dist/browser/processors/opmlProcessor.js +6 -10
  12. package/dist/browser/processors/snap/helpers.js +34 -30
  13. package/dist/browser/processors/snapProcessor.js +28 -28
  14. package/dist/browser/processors/touchchatProcessor.js +24 -25
  15. package/dist/browser/utilities/analytics/history.js +24 -18
  16. package/dist/browser/utilities/analytics/metrics/comparison.js +16 -16
  17. package/dist/browser/utilities/analytics/metrics/vocabulary.js +2 -2
  18. package/dist/browser/utilities/analytics/reference/browser.js +16 -16
  19. package/dist/browser/utilities/analytics/reference/index.js +25 -24
  20. package/dist/browser/utils/io.js +29 -25
  21. package/dist/browser/utils/sqlite.js +5 -5
  22. package/dist/browser/utils/zip.js +2 -4
  23. package/dist/browser/validation/gridsetValidator.js +2 -2
  24. package/dist/browser/validation/obfValidator.js +2 -2
  25. package/dist/browser/validation/snapValidator.js +3 -3
  26. package/dist/browser/validation/touchChatValidator.js +3 -3
  27. package/dist/cli/index.js +19 -16
  28. package/dist/core/baseProcessor.d.ts +1 -1
  29. package/dist/processors/applePanelsProcessor.js +24 -24
  30. package/dist/processors/astericsGridProcessor.d.ts +4 -4
  31. package/dist/processors/astericsGridProcessor.js +22 -24
  32. package/dist/processors/dotProcessor.js +6 -10
  33. package/dist/processors/excelProcessor.d.ts +3 -3
  34. package/dist/processors/excelProcessor.js +10 -13
  35. package/dist/processors/gridset/helpers.d.ts +9 -9
  36. package/dist/processors/gridset/helpers.js +33 -30
  37. package/dist/processors/gridset/symbolExtractor.d.ts +1 -1
  38. package/dist/processors/gridset/symbolExtractor.js +2 -2
  39. package/dist/processors/gridset/symbolSearch.d.ts +10 -10
  40. package/dist/processors/gridset/symbolSearch.js +22 -22
  41. package/dist/processors/gridset/symbols.d.ts +3 -3
  42. package/dist/processors/gridset/symbols.js +14 -14
  43. package/dist/processors/gridsetProcessor.d.ts +2 -2
  44. package/dist/processors/gridsetProcessor.js +7 -7
  45. package/dist/processors/obfProcessor.d.ts +2 -2
  46. package/dist/processors/obfProcessor.js +54 -47
  47. package/dist/processors/obfsetProcessor.js +1 -2
  48. package/dist/processors/opmlProcessor.js +6 -10
  49. package/dist/processors/snap/helpers.d.ts +8 -8
  50. package/dist/processors/snap/helpers.js +34 -30
  51. package/dist/processors/snapProcessor.d.ts +2 -2
  52. package/dist/processors/snapProcessor.js +28 -28
  53. package/dist/processors/touchchatProcessor.d.ts +2 -2
  54. package/dist/processors/touchchatProcessor.js +24 -25
  55. package/dist/types/aac.d.ts +2 -2
  56. package/dist/utilities/analytics/history.d.ts +8 -8
  57. package/dist/utilities/analytics/history.js +24 -18
  58. package/dist/utilities/analytics/index.d.ts +1 -1
  59. package/dist/utilities/analytics/index.js +3 -2
  60. package/dist/utilities/analytics/metrics/comparison.d.ts +1 -1
  61. package/dist/utilities/analytics/metrics/comparison.js +16 -16
  62. package/dist/utilities/analytics/metrics/vocabulary.d.ts +1 -1
  63. package/dist/utilities/analytics/metrics/vocabulary.js +2 -2
  64. package/dist/utilities/analytics/reference/browser.d.ts +9 -9
  65. package/dist/utilities/analytics/reference/browser.js +16 -16
  66. package/dist/utilities/analytics/reference/index.d.ts +21 -21
  67. package/dist/utilities/analytics/reference/index.js +25 -24
  68. package/dist/utilities/symbolTools.d.ts +5 -5
  69. package/dist/utilities/symbolTools.js +10 -8
  70. package/dist/utils/io.d.ts +11 -11
  71. package/dist/utils/io.js +29 -25
  72. package/dist/utils/sqlite.d.ts +1 -1
  73. package/dist/utils/sqlite.js +5 -5
  74. package/dist/utils/zip.js +2 -4
  75. package/dist/validation/applePanelsValidator.js +7 -6
  76. package/dist/validation/astericsValidator.js +2 -2
  77. package/dist/validation/dotValidator.js +2 -2
  78. package/dist/validation/excelValidator.js +2 -2
  79. package/dist/validation/gridsetValidator.js +2 -2
  80. package/dist/validation/index.js +2 -2
  81. package/dist/validation/obfValidator.js +2 -2
  82. package/dist/validation/obfsetValidator.js +2 -2
  83. package/dist/validation/opmlValidator.js +2 -2
  84. package/dist/validation/snapValidator.js +3 -3
  85. package/dist/validation/touchChatValidator.js +3 -3
  86. package/docs/BROWSER_USAGE.md +0 -40
  87. package/package.json +1 -1
@@ -39,7 +39,7 @@ class SnapSymbolExtractor extends SymbolExtractor {
39
39
  }
40
40
  exports.SnapSymbolExtractor = SnapSymbolExtractor;
41
41
  class SnapSymbolResolver extends SymbolResolver {
42
- resolveSymbol(symbolRef) {
42
+ async resolveSymbol(symbolRef) {
43
43
  const { join, writeBinaryToPath } = this.fileAdapter;
44
44
  if (!Database)
45
45
  throw new Error('better-sqlite3 not installed');
@@ -50,7 +50,7 @@ class SnapSymbolResolver extends SymbolResolver {
50
50
  if (!row)
51
51
  return null;
52
52
  const outPath = join(this.symbolPath, `${symbolRef}.png`);
53
- writeBinaryToPath(outPath, row.ImageData);
53
+ await writeBinaryToPath(outPath, row.ImageData);
54
54
  return outPath;
55
55
  }
56
56
  }
@@ -86,11 +86,12 @@ class Grid3SymbolExtractor extends SymbolExtractor {
86
86
  }
87
87
  exports.Grid3SymbolExtractor = Grid3SymbolExtractor;
88
88
  class Grid3SymbolResolver extends SymbolResolver {
89
- resolveSymbol(symbolRef) {
89
+ async resolveSymbol(symbolRef) {
90
90
  const { join, pathExists } = this.fileAdapter;
91
91
  // Implementation depends on Grid 3 symbol storage format
92
92
  const symbolPath = join(this.symbolPath, symbolRef);
93
- return pathExists(symbolPath) ? symbolPath : null;
93
+ const exists = await pathExists(symbolPath);
94
+ return exists ? symbolPath : null;
94
95
  }
95
96
  }
96
97
  exports.Grid3SymbolResolver = Grid3SymbolResolver;
@@ -103,22 +104,23 @@ class TouchChatSymbolExtractor extends SymbolExtractor {
103
104
  }
104
105
  exports.TouchChatSymbolExtractor = TouchChatSymbolExtractor;
105
106
  class TouchChatSymbolResolver extends SymbolResolver {
106
- resolveSymbol(symbolRef) {
107
+ async resolveSymbol(symbolRef) {
107
108
  const { join, pathExists } = this.fileAdapter;
108
109
  // Implementation depends on TouchChat symbol storage format
109
110
  const symbolPath = join(this.symbolPath, symbolRef);
110
- return pathExists(symbolPath) ? symbolPath : null;
111
+ const exists = await pathExists(symbolPath);
112
+ return exists ? symbolPath : null;
111
113
  }
112
114
  }
113
115
  exports.TouchChatSymbolResolver = TouchChatSymbolResolver;
114
116
  // --- Simple fallback function for PCS-style lookup ---
115
- function resolveSymbol(label, symbolDir, fileAdapter = io_1.defaultFileAdapter) {
117
+ async function resolveSymbol(label, symbolDir, fileAdapter = io_1.defaultFileAdapter) {
116
118
  const { join, pathExists } = fileAdapter;
117
119
  const cleanLabel = label.toLowerCase().replace(/[^a-z0-9]/g, '');
118
120
  const exts = ['.png', '.jpg', '.svg'];
119
121
  for (const ext of exts) {
120
122
  const symbolPath = join(symbolDir, cleanLabel + ext);
121
- if (pathExists(symbolPath)) {
123
+ if (await pathExists(symbolPath)) {
122
124
  return symbolPath;
123
125
  }
124
126
  }
@@ -1,22 +1,22 @@
1
1
  export type ProcessorInput = string | Buffer | ArrayBuffer | Uint8Array;
2
2
  export type BinaryOutput = Buffer | Uint8Array;
3
3
  export interface FileAdapter {
4
- readBinaryFromInput: (input: ProcessorInput) => Uint8Array;
5
- readTextFromInput: (input: ProcessorInput, encoding?: BufferEncoding) => string;
6
- writeBinaryToPath: (outputPath: string, data: BinaryOutput) => void;
7
- writeTextToPath: (outputPath: string, text: string) => void;
8
- pathExists: (path: string) => boolean;
9
- isDirectory: (path: string) => boolean;
10
- getFileSize: (path: string) => number;
4
+ readBinaryFromInput: (input: ProcessorInput) => Promise<Uint8Array>;
5
+ readTextFromInput: (input: ProcessorInput, encoding?: BufferEncoding) => Promise<string>;
6
+ writeBinaryToPath: (outputPath: string, data: BinaryOutput) => Promise<void>;
7
+ writeTextToPath: (outputPath: string, text: string) => Promise<void>;
8
+ pathExists: (path: string) => Promise<boolean>;
9
+ isDirectory: (path: string) => Promise<boolean>;
10
+ getFileSize: (path: string) => Promise<number>;
11
11
  mkDir: (path: string, options?: {
12
12
  recursive?: boolean;
13
- }) => void;
14
- listDir: (path: string) => string[];
13
+ }) => Promise<void>;
14
+ listDir: (path: string) => Promise<string[]>;
15
15
  removePath: (path: string, options?: {
16
16
  recursive?: boolean;
17
17
  force?: boolean;
18
- }) => void;
19
- mkTempDir: (prefix: string) => string;
18
+ }) => Promise<void>;
19
+ mkTempDir: (prefix: string) => Promise<string>;
20
20
  join: (...pathParts: string[]) => string;
21
21
  dirname: (path: string) => string;
22
22
  basename: (path: string, suffix?: string) => string;
package/dist/utils/io.js CHANGED
@@ -38,7 +38,7 @@ function getFs() {
38
38
  if (!cachedFs) {
39
39
  try {
40
40
  const nodeRequire = getNodeRequire();
41
- const fsModule = 'fs';
41
+ const fsModule = 'node:fs';
42
42
  cachedFs = nodeRequire(fsModule);
43
43
  }
44
44
  catch {
@@ -135,57 +135,61 @@ function extname(path) {
135
135
  const tail = splitDeviceRe.exec(path)?.at(3) ?? '';
136
136
  return splitTailRe.exec(tail)?.at(3) ?? '';
137
137
  }
138
- function readBinaryFromInput(input) {
138
+ async function readBinaryFromInput(input) {
139
139
  if (typeof input === 'string') {
140
- return getFs().readFileSync(input);
140
+ return Promise.resolve(getFs().readFileSync(input));
141
141
  }
142
142
  if (typeof Buffer !== 'undefined' && Buffer.isBuffer(input)) {
143
- return input;
143
+ return Promise.resolve(input);
144
144
  }
145
145
  if (input instanceof ArrayBuffer) {
146
- return new Uint8Array(input);
146
+ return Promise.resolve(new Uint8Array(input));
147
147
  }
148
- return input;
148
+ return Promise.resolve(input);
149
149
  }
150
- function readTextFromInput(input, encoding = 'utf8') {
150
+ async function readTextFromInput(input, encoding = 'utf8') {
151
151
  if (typeof input === 'string') {
152
- return getFs().readFileSync(input, encoding);
152
+ return Promise.resolve(getFs().readFileSync(input, encoding));
153
153
  }
154
154
  if (typeof Buffer !== 'undefined' && Buffer.isBuffer(input)) {
155
- return input.toString(encoding);
155
+ return Promise.resolve(input.toString(encoding));
156
156
  }
157
157
  if (input instanceof ArrayBuffer) {
158
- return decodeText(new Uint8Array(input));
158
+ return Promise.resolve(decodeText(new Uint8Array(input)));
159
159
  }
160
- return decodeText(input);
160
+ return Promise.resolve(decodeText(input));
161
161
  }
162
- function writeBinaryToPath(outputPath, data) {
162
+ async function writeBinaryToPath(outputPath, data) {
163
163
  getFs().writeFileSync(outputPath, data);
164
+ await Promise.resolve();
164
165
  }
165
- function writeTextToPath(outputPath, text) {
166
+ async function writeTextToPath(outputPath, text) {
166
167
  getFs().writeFileSync(outputPath, text, 'utf8');
168
+ await Promise.resolve();
167
169
  }
168
- function pathExists(path) {
169
- return getFs().existsSync(path);
170
+ async function pathExists(path) {
171
+ return Promise.resolve(getFs().existsSync(path));
170
172
  }
171
- function isDirectory(path) {
172
- return getFs().statSync(path).isDirectory();
173
+ async function isDirectory(path) {
174
+ return Promise.resolve(getFs().statSync(path).isDirectory());
173
175
  }
174
- function getFileSize(path) {
175
- return getFs().statSync(path).size;
176
+ async function getFileSize(path) {
177
+ return Promise.resolve(getFs().statSync(path).size);
176
178
  }
177
- function mkDir(path, options) {
179
+ async function mkDir(path, options) {
178
180
  getFs().mkdirSync(path, options);
181
+ await Promise.resolve();
179
182
  }
180
- function listDir(path) {
181
- return getFs().readdirSync(path);
183
+ async function listDir(path) {
184
+ return Promise.resolve(getFs().readdirSync(path));
182
185
  }
183
- function removePath(path, options) {
186
+ async function removePath(path, options) {
184
187
  getFs().rmSync(path, options);
188
+ await Promise.resolve();
185
189
  }
186
- function mkTempDir(prefix) {
190
+ async function mkTempDir(prefix) {
187
191
  const path = join(getOs().tmpdir(), prefix);
188
- return getFs().mkdtempSync(path);
192
+ return Promise.resolve(getFs().mkdtempSync(path));
189
193
  }
190
194
  function join(...pathParts) {
191
195
  return getPath().join(...pathParts);
@@ -16,7 +16,7 @@ export interface SqliteOpenOptions {
16
16
  }
17
17
  export interface SqliteOpenResult {
18
18
  db: SqliteDatabaseAdapter;
19
- cleanup?: () => void;
19
+ cleanup?: () => Promise<void>;
20
20
  }
21
21
  export declare function configureSqlJs(config: SqlJsConfig): void;
22
22
  export declare function requireBetterSqlite3(): typeof import('better-sqlite3');
@@ -107,24 +107,24 @@ async function openSqliteDatabase(input, options = {}) {
107
107
  const db = new Database(input, { readonly: options.readonly ?? true });
108
108
  return { db };
109
109
  }
110
- const data = readBinaryFromInput(input);
110
+ const data = await readBinaryFromInput(input);
111
111
  if (!(0, io_1.isNodeRuntime)()) {
112
112
  const SQL = await getSqlJs();
113
113
  const db = new SQL.Database(data);
114
114
  return { db: createSqlJsAdapter(db) };
115
115
  }
116
- const tempDir = mkTempDir('aac-sqlite-');
116
+ const tempDir = await mkTempDir('aac-sqlite-');
117
117
  const dbPath = join(tempDir, 'input.sqlite');
118
- writeBinaryToPath(dbPath, data);
118
+ await writeBinaryToPath(dbPath, data);
119
119
  const Database = getBetterSqlite3();
120
120
  const db = new Database(dbPath, { readonly: options.readonly ?? true });
121
- const cleanup = () => {
121
+ const cleanup = async () => {
122
122
  try {
123
123
  db.close();
124
124
  }
125
125
  finally {
126
126
  try {
127
- removePath(tempDir, { recursive: true, force: true });
127
+ await removePath(tempDir, { recursive: true, force: true });
128
128
  }
129
129
  catch (error) {
130
130
  console.warn('Failed to clean up temporary SQLite files:', error);
package/dist/utils/zip.js CHANGED
@@ -33,7 +33,7 @@ async function getZipAdapter(input, fileAdapter) {
33
33
  ? new AdmZip(input)
34
34
  : typeof input === 'string'
35
35
  ? new AdmZip(input)
36
- : new AdmZip(Buffer.from(adapter.readBinaryFromInput(input)));
36
+ : new AdmZip(Buffer.from(await adapter.readBinaryFromInput(input)));
37
37
  return {
38
38
  listFiles: () => {
39
39
  return zip
@@ -57,9 +57,7 @@ async function getZipAdapter(input, fileAdapter) {
57
57
  }
58
58
  const module = await Promise.resolve().then(() => __importStar(require('jszip')));
59
59
  const JSZip = module.default || module;
60
- if (input !== undefined && typeof input === 'string')
61
- throw new Error('Zip file paths are not supported in browser environments.');
62
- const zip = input ? await JSZip.loadAsync(adapter.readBinaryFromInput(input)) : new JSZip();
60
+ const zip = input ? await JSZip.loadAsync(await adapter.readBinaryFromInput(input)) : new JSZip();
63
61
  return {
64
62
  listFiles: () => {
65
63
  return Object.entries(zip.files)
@@ -18,17 +18,18 @@ class ApplePanelsValidator extends baseValidator_1.BaseValidator {
18
18
  let content;
19
19
  const filename = (0, io_1.getBasename)(filePath);
20
20
  let size = 0;
21
- if (isDirectory(filePath) && filename.toLowerCase().endsWith('.ascconfig')) {
21
+ const isDir = await isDirectory(filePath);
22
+ if (isDir && filename.toLowerCase().endsWith('.ascconfig')) {
22
23
  const panelPath = join(filePath, 'Contents', 'Resources', 'PanelDefinitions.plist');
23
- if (!pathExists(panelPath)) {
24
+ if (!(await pathExists(panelPath))) {
24
25
  return validator.validate(Buffer.alloc(0), filename, 0);
25
26
  }
26
- content = readBinaryFromInput(panelPath);
27
- size = getFileSize(panelPath);
27
+ content = await readBinaryFromInput(panelPath);
28
+ size = await getFileSize(panelPath);
28
29
  }
29
30
  else {
30
- content = readBinaryFromInput(filePath);
31
- size = getFileSize(filePath) || content.byteLength;
31
+ content = await readBinaryFromInput(filePath);
32
+ size = (await getFileSize(filePath)) || content.byteLength;
32
33
  }
33
34
  return validator.validate(content, filename, size);
34
35
  }
@@ -14,8 +14,8 @@ class AstericsGridValidator extends baseValidator_1.BaseValidator {
14
14
  static async validateFile(filePath, fileAdapter) {
15
15
  const { readBinaryFromInput, getFileSize } = fileAdapter ?? io_1.defaultFileAdapter;
16
16
  const validator = new AstericsGridValidator();
17
- const content = readBinaryFromInput(filePath);
18
- const size = getFileSize(filePath);
17
+ const content = await readBinaryFromInput(filePath);
18
+ const size = await getFileSize(filePath);
19
19
  return validator.validate(content, (0, io_1.getBasename)(filePath), size);
20
20
  }
21
21
  /**
@@ -11,8 +11,8 @@ class DotValidator extends baseValidator_1.BaseValidator {
11
11
  static async validateFile(filePath, fileAdapter) {
12
12
  const { readBinaryFromInput, getFileSize } = fileAdapter ?? io_1.defaultFileAdapter;
13
13
  const validator = new DotValidator();
14
- const content = readBinaryFromInput(filePath);
15
- const size = getFileSize(filePath);
14
+ const content = await readBinaryFromInput(filePath);
15
+ const size = await getFileSize(filePath);
16
16
  return validator.validate(content, (0, io_1.getBasename)(filePath), size);
17
17
  }
18
18
  static async identifyFormat(content, filename) {
@@ -35,8 +35,8 @@ class ExcelValidator extends baseValidator_1.BaseValidator {
35
35
  static async validateFile(filePath, fileAdapter) {
36
36
  const { readBinaryFromInput, getFileSize } = fileAdapter ?? io_1.defaultFileAdapter;
37
37
  const validator = new ExcelValidator();
38
- const content = readBinaryFromInput(filePath);
39
- const size = getFileSize(filePath);
38
+ const content = await readBinaryFromInput(filePath);
39
+ const size = await getFileSize(filePath);
40
40
  return validator.validate(content, (0, io_1.getBasename)(filePath), size);
41
41
  }
42
42
  static async identifyFormat(_content, filename) {
@@ -43,8 +43,8 @@ class GridsetValidator extends baseValidator_1.BaseValidator {
43
43
  static async validateFile(filePath, fileAdapter) {
44
44
  const { readBinaryFromInput, getFileSize } = fileAdapter ?? io_1.defaultFileAdapter;
45
45
  const validator = new GridsetValidator();
46
- const content = readBinaryFromInput(filePath);
47
- const size = getFileSize(filePath);
46
+ const content = await readBinaryFromInput(filePath);
47
+ const size = await getFileSize(filePath);
48
48
  return validator.validate(content, (0, io_1.getBasename)(filePath), size);
49
49
  }
50
50
  /**
@@ -141,8 +141,8 @@ async function validateFileOrBuffer(filePathOrBuffer, fileAdapter, filenameHint)
141
141
  if (typeof ctor.validateFile === 'function') {
142
142
  return ctor.validateFile(filePathOrBuffer);
143
143
  }
144
- const buf = adapter.readBinaryFromInput(filePathOrBuffer);
145
- const size = adapter.getFileSize(filePathOrBuffer);
144
+ const buf = await adapter.readBinaryFromInput(filePathOrBuffer);
145
+ const size = await adapter.getFileSize(filePathOrBuffer);
146
146
  return validator.validate(buf, (0, io_1.getBasename)(filePathOrBuffer), size);
147
147
  }
148
148
  const buffer = (0, io_1.toUint8Array)(filePathOrBuffer);
@@ -27,8 +27,8 @@ class ObfValidator extends baseValidator_1.BaseValidator {
27
27
  static async validateFile(filePath, fileAdapter) {
28
28
  const { readBinaryFromInput, getFileSize } = fileAdapter ?? io_1.defaultFileAdapter;
29
29
  const validator = new ObfValidator();
30
- const content = readBinaryFromInput(filePath);
31
- const size = getFileSize(filePath);
30
+ const content = await readBinaryFromInput(filePath);
31
+ const size = await getFileSize(filePath);
32
32
  return validator.validate(content, (0, io_1.getBasename)(filePath), size);
33
33
  }
34
34
  /**
@@ -11,8 +11,8 @@ class ObfsetValidator extends baseValidator_1.BaseValidator {
11
11
  static async validateFile(filePath, fileAdapter) {
12
12
  const { readBinaryFromInput, getFileSize } = fileAdapter ?? io_1.defaultFileAdapter;
13
13
  const validator = new ObfsetValidator();
14
- const content = readBinaryFromInput(filePath);
15
- const size = getFileSize(filePath);
14
+ const content = await readBinaryFromInput(filePath);
15
+ const size = await getFileSize(filePath);
16
16
  return validator.validate(content, (0, io_1.getBasename)(filePath), size);
17
17
  }
18
18
  static async identifyFormat(content, filename) {
@@ -12,8 +12,8 @@ class OpmlValidator extends baseValidator_1.BaseValidator {
12
12
  static async validateFile(filePath, fileAdapter) {
13
13
  const { readBinaryFromInput, getFileSize } = fileAdapter ?? io_1.defaultFileAdapter;
14
14
  const validator = new OpmlValidator();
15
- const content = readBinaryFromInput(filePath);
16
- const size = getFileSize(filePath);
15
+ const content = await readBinaryFromInput(filePath);
16
+ const size = await getFileSize(filePath);
17
17
  return validator.validate(content, (0, io_1.getBasename)(filePath), size);
18
18
  }
19
19
  static async identifyFormat(content, filename) {
@@ -48,8 +48,8 @@ class SnapValidator extends baseValidator_1.BaseValidator {
48
48
  static async validateFile(filePath, fileAdapter) {
49
49
  const { readBinaryFromInput, getFileSize } = fileAdapter ?? io_1.defaultFileAdapter;
50
50
  const validator = new SnapValidator();
51
- const content = readBinaryFromInput(filePath);
52
- const size = getFileSize(filePath);
51
+ const content = await readBinaryFromInput(filePath);
52
+ const size = await getFileSize(filePath);
53
53
  return validator.validate(content, (0, io_1.getBasename)(filePath), size);
54
54
  }
55
55
  /**
@@ -238,7 +238,7 @@ class SnapValidator extends baseValidator_1.BaseValidator {
238
238
  }
239
239
  finally {
240
240
  if (cleanup) {
241
- cleanup();
241
+ await cleanup();
242
242
  }
243
243
  }
244
244
  });
@@ -47,8 +47,8 @@ class TouchChatValidator extends baseValidator_1.BaseValidator {
47
47
  static async validateFile(filePath, fileAdapter) {
48
48
  const { readBinaryFromInput, getFileSize } = fileAdapter ?? io_1.defaultFileAdapter;
49
49
  const validator = new TouchChatValidator();
50
- const content = readBinaryFromInput(filePath);
51
- const size = getFileSize(filePath);
50
+ const content = await readBinaryFromInput(filePath);
51
+ const size = await getFileSize(filePath);
52
52
  return validator.validate(content, (0, io_1.getBasename)(filePath), size);
53
53
  }
54
54
  /**
@@ -361,7 +361,7 @@ class TouchChatValidator extends baseValidator_1.BaseValidator {
361
361
  }
362
362
  finally {
363
363
  if (cleanup) {
364
- cleanup();
364
+ await cleanup();
365
365
  }
366
366
  }
367
367
  });
@@ -212,46 +212,6 @@ The most common browser use case is loading files from an `<input type="file">`
212
212
  </script>
213
213
  ```
214
214
 
215
- ### Processing Translations
216
-
217
- ```html
218
- <script type="module">
219
- import { getProcessor } from 'aac-processors';
220
-
221
- async function translateFile(file, translations) {
222
- const extension = '.' + file.name.split('.').pop();
223
- const processor = getProcessor(extension);
224
- const arrayBuffer = await file.arrayBuffer();
225
-
226
- // Process texts with translations
227
- const translatedBuffer = await processor.processTexts(
228
- arrayBuffer,
229
- translations,
230
- null // Don't save to file, return buffer
231
- );
232
-
233
- // Create download link
234
- const blob = new Blob([translatedBuffer], { type: 'application/octet-stream' });
235
- const url = URL.createObjectURL(blob);
236
- const a = document.createElement('a');
237
- a.href = url;
238
- a.download = 'translated-' + file.name;
239
- a.click();
240
- URL.revokeObjectURL(url);
241
- }
242
-
243
- // Usage
244
- const translations = new Map([
245
- ['Hello', 'Hola'],
246
- ['Goodbye', 'Adiós'],
247
- ['Yes', 'Sí'],
248
- ['No', 'No']
249
- ]);
250
-
251
- translateFile(myFile, translations);
252
- </script>
253
- ```
254
-
255
215
  ## Supported File Types
256
216
 
257
217
  ### Browser-Compatible Processors
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willwade/aac-processors",
3
- "version": "0.1.21",
3
+ "version": "0.2.1",
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",