@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.
Files changed (113) hide show
  1. package/dist/browser/core/baseProcessor.js +4 -0
  2. package/dist/browser/processors/applePanelsProcessor.js +33 -40
  3. package/dist/browser/processors/astericsGridProcessor.js +31 -26
  4. package/dist/browser/processors/dotProcessor.js +11 -12
  5. package/dist/browser/processors/gridset/colorUtils.js +354 -0
  6. package/dist/browser/processors/gridset/helpers.js +60 -53
  7. package/dist/browser/processors/gridset/index.js +61 -0
  8. package/dist/browser/processors/gridset/styleHelpers.js +205 -0
  9. package/dist/browser/processors/gridset/symbolExtractor.js +331 -0
  10. package/dist/browser/processors/gridset/symbolSearch.js +248 -0
  11. package/dist/browser/processors/gridset/symbols.js +39 -72
  12. package/dist/browser/processors/gridsetProcessor.js +39 -48
  13. package/dist/browser/processors/obfProcessor.js +39 -53
  14. package/dist/browser/processors/opmlProcessor.js +11 -12
  15. package/dist/browser/processors/snap/helpers.js +57 -49
  16. package/dist/browser/processors/snapProcessor.js +48 -51
  17. package/dist/browser/processors/touchchatProcessor.js +60 -52
  18. package/dist/browser/utilities/analytics/history.js +24 -18
  19. package/dist/browser/utilities/analytics/metrics/comparison.js +16 -16
  20. package/dist/browser/utilities/analytics/metrics/vocabulary.js +2 -2
  21. package/dist/browser/utilities/analytics/reference/browser.js +16 -16
  22. package/dist/browser/utilities/analytics/reference/index.js +44 -35
  23. package/dist/browser/utils/io.js +78 -21
  24. package/dist/browser/utils/sqlite.js +8 -10
  25. package/dist/browser/utils/zip.js +43 -43
  26. package/dist/browser/validation/baseValidator.js +5 -0
  27. package/dist/browser/validation/gridsetValidator.js +12 -20
  28. package/dist/browser/validation/obfValidator.js +6 -5
  29. package/dist/browser/validation/snapValidator.js +11 -7
  30. package/dist/browser/validation/touchChatValidator.js +23 -13
  31. package/dist/cli/index.js +22 -24
  32. package/dist/core/baseProcessor.d.ts +7 -7
  33. package/dist/core/baseProcessor.js +4 -0
  34. package/dist/processors/applePanelsProcessor.js +32 -39
  35. package/dist/processors/astericsGridProcessor.d.ts +4 -4
  36. package/dist/processors/astericsGridProcessor.js +30 -25
  37. package/dist/processors/dotProcessor.js +10 -11
  38. package/dist/processors/excelProcessor.d.ts +3 -3
  39. package/dist/processors/excelProcessor.js +14 -20
  40. package/dist/processors/gridset/helpers.d.ts +12 -14
  41. package/dist/processors/gridset/helpers.js +60 -79
  42. package/dist/processors/gridset/imageDebug.d.ts +3 -5
  43. package/dist/processors/gridset/imageDebug.js +4 -4
  44. package/dist/processors/gridset/password.d.ts +1 -1
  45. package/dist/processors/gridset/symbolExtractor.d.ts +5 -3
  46. package/dist/processors/gridset/symbolExtractor.js +15 -38
  47. package/dist/processors/gridset/symbolSearch.d.ts +11 -10
  48. package/dist/processors/gridset/symbolSearch.js +29 -51
  49. package/dist/processors/gridset/symbols.d.ts +8 -6
  50. package/dist/processors/gridset/symbols.js +38 -71
  51. package/dist/processors/gridset/wordlistHelpers.d.ts +4 -6
  52. package/dist/processors/gridset/wordlistHelpers.js +15 -74
  53. package/dist/processors/gridsetProcessor.d.ts +2 -2
  54. package/dist/processors/gridsetProcessor.js +38 -70
  55. package/dist/processors/obfProcessor.d.ts +2 -2
  56. package/dist/processors/obfProcessor.js +38 -75
  57. package/dist/processors/obfsetProcessor.js +2 -3
  58. package/dist/processors/opmlProcessor.js +10 -11
  59. package/dist/processors/snap/helpers.d.ts +9 -9
  60. package/dist/processors/snap/helpers.js +58 -76
  61. package/dist/processors/snapProcessor.d.ts +2 -2
  62. package/dist/processors/snapProcessor.js +47 -50
  63. package/dist/processors/touchchatProcessor.d.ts +2 -2
  64. package/dist/processors/touchchatProcessor.js +59 -51
  65. package/dist/types/aac.d.ts +2 -2
  66. package/dist/utilities/analytics/history.d.ts +8 -8
  67. package/dist/utilities/analytics/history.js +24 -18
  68. package/dist/utilities/analytics/index.d.ts +3 -2
  69. package/dist/utilities/analytics/index.js +9 -10
  70. package/dist/utilities/analytics/metrics/comparison.d.ts +1 -1
  71. package/dist/utilities/analytics/metrics/comparison.js +16 -16
  72. package/dist/utilities/analytics/metrics/vocabulary.d.ts +1 -1
  73. package/dist/utilities/analytics/metrics/vocabulary.js +2 -2
  74. package/dist/utilities/analytics/reference/browser.d.ts +9 -9
  75. package/dist/utilities/analytics/reference/browser.js +16 -16
  76. package/dist/utilities/analytics/reference/index.d.ts +25 -23
  77. package/dist/utilities/analytics/reference/index.js +43 -34
  78. package/dist/utilities/symbolTools.d.ts +8 -6
  79. package/dist/utilities/symbolTools.js +21 -18
  80. package/dist/utils/io.d.ts +24 -6
  81. package/dist/utils/io.js +79 -25
  82. package/dist/utils/sqlite.d.ts +3 -1
  83. package/dist/utils/sqlite.js +7 -9
  84. package/dist/utils/zip.d.ts +7 -3
  85. package/dist/utils/zip.js +43 -43
  86. package/dist/validation/applePanelsValidator.d.ts +2 -1
  87. package/dist/validation/applePanelsValidator.js +10 -11
  88. package/dist/validation/astericsValidator.d.ts +2 -1
  89. package/dist/validation/astericsValidator.js +5 -4
  90. package/dist/validation/baseValidator.d.ts +2 -2
  91. package/dist/validation/baseValidator.js +5 -0
  92. package/dist/validation/dotValidator.d.ts +2 -1
  93. package/dist/validation/dotValidator.js +5 -4
  94. package/dist/validation/excelValidator.d.ts +2 -1
  95. package/dist/validation/excelValidator.js +5 -4
  96. package/dist/validation/gridsetValidator.d.ts +2 -1
  97. package/dist/validation/gridsetValidator.js +11 -22
  98. package/dist/validation/index.d.ts +2 -2
  99. package/dist/validation/index.js +5 -4
  100. package/dist/validation/obfValidator.d.ts +2 -1
  101. package/dist/validation/obfValidator.js +5 -4
  102. package/dist/validation/obfsetValidator.d.ts +2 -1
  103. package/dist/validation/obfsetValidator.js +5 -4
  104. package/dist/validation/opmlValidator.d.ts +2 -1
  105. package/dist/validation/opmlValidator.js +5 -4
  106. package/dist/validation/snapValidator.d.ts +2 -1
  107. package/dist/validation/snapValidator.js +10 -6
  108. package/dist/validation/touchChatValidator.d.ts +4 -6
  109. package/dist/validation/touchChatValidator.js +22 -12
  110. package/dist/validation/validationTypes.d.ts +8 -1
  111. package/package.json +1 -1
  112. package/dist/core/fileProcessor.d.ts +0 -7
  113. package/dist/core/fileProcessor.js +0 -57
package/dist/utils/zip.js CHANGED
@@ -23,58 +23,58 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.openZipFromInput = openZipFromInput;
26
+ exports.getZipAdapter = getZipAdapter;
27
27
  const io_1 = require("./io");
28
- async function openZipFromInput(input) {
29
- if (typeof input === 'string') {
30
- if (!(0, io_1.isNodeRuntime)()) {
31
- throw new Error('Zip file paths are not supported in browser environments.');
32
- }
33
- const AdmZip = (0, io_1.getNodeRequire)()('adm-zip');
34
- const admZip = new AdmZip(input);
35
- return {
36
- zip: {
37
- listFiles: () => admZip.getEntries().map((entry) => entry.entryName),
38
- readFile: (name) => {
39
- const entry = admZip.getEntry(name);
40
- if (!entry) {
41
- throw new Error(`Zip entry not found: ${name}`);
42
- }
43
- return Promise.resolve(entry.getData());
44
- },
45
- },
46
- };
47
- }
48
- const data = (0, io_1.readBinaryFromInput)(input);
28
+ async function getZipAdapter(input, fileAdapter) {
29
+ const adapter = fileAdapter ?? io_1.defaultFileAdapter;
49
30
  if ((0, io_1.isNodeRuntime)()) {
50
31
  const AdmZip = (0, io_1.getNodeRequire)()('adm-zip');
51
- const admZip = new AdmZip(Buffer.from(data));
32
+ const zip = input === undefined
33
+ ? new AdmZip(input)
34
+ : typeof input === 'string'
35
+ ? new AdmZip(input)
36
+ : new AdmZip(Buffer.from(await adapter.readBinaryFromInput(input)));
52
37
  return {
53
- zip: {
54
- listFiles: () => admZip.getEntries().map((entry) => entry.entryName),
55
- readFile: (name) => {
56
- const entry = admZip.getEntry(name);
57
- if (!entry) {
58
- throw new Error(`Zip entry not found: ${name}`);
59
- }
60
- return Promise.resolve(entry.getData());
61
- },
38
+ listFiles: () => {
39
+ return zip
40
+ .getEntries()
41
+ .filter((entry) => !entry.isDirectory)
42
+ .map((entry) => entry.entryName);
43
+ },
44
+ readFile: (name) => {
45
+ const entry = zip.getEntry(name);
46
+ if (!entry)
47
+ throw new Error(`Zip entry not found: ${name}`);
48
+ return Promise.resolve(entry.getData());
49
+ },
50
+ writeFiles: (files) => {
51
+ files.forEach((file) => {
52
+ zip.addFile(file.name, Buffer.from(file.data));
53
+ });
54
+ return Promise.resolve(zip.toBuffer());
62
55
  },
63
56
  };
64
57
  }
65
58
  const module = await Promise.resolve().then(() => __importStar(require('jszip')));
66
- const init = module.default || module;
67
- const zip = await init.loadAsync(data);
59
+ const JSZip = module.default || module;
60
+ const zip = input ? await JSZip.loadAsync(await adapter.readBinaryFromInput(input)) : new JSZip();
68
61
  return {
69
- zip: {
70
- listFiles: () => Object.keys(zip.files),
71
- readFile: async (name) => {
72
- const file = zip.file(name);
73
- if (!file) {
74
- throw new Error(`Zip entry not found: ${name}`);
75
- }
76
- return file.async('uint8array');
77
- },
62
+ listFiles: () => {
63
+ return Object.entries(zip.files)
64
+ .filter(([_, entry]) => !entry.dir)
65
+ .map(([name, _]) => name);
66
+ },
67
+ readFile: async (name) => {
68
+ const file = zip.file(name);
69
+ if (!file)
70
+ throw new Error(`Zip entry not found: ${name}`);
71
+ return file.async('uint8array');
72
+ },
73
+ writeFiles: async (files) => {
74
+ files.forEach((file) => {
75
+ zip.file(file.name, file.data);
76
+ });
77
+ return await zip.generateAsync({ type: 'uint8array' });
78
78
  },
79
79
  };
80
80
  }
@@ -1,10 +1,11 @@
1
1
  import { BaseValidator } from './baseValidator';
2
2
  import { ValidationResult } from './validationTypes';
3
+ import { FileAdapter } from '../utils/io';
3
4
  /**
4
5
  * Validator for Apple Panels (.plist or .ascconfig directory)
5
6
  */
6
7
  export declare class ApplePanelsValidator extends BaseValidator {
7
- static validateFile(filePath: string): Promise<ValidationResult>;
8
+ static validateFile(filePath: string, fileAdapter?: FileAdapter): Promise<ValidationResult>;
8
9
  static identifyFormat(content: any, filename: string): Promise<boolean>;
9
10
  validate(content: Buffer | Uint8Array, filename: string, filesize: number): Promise<ValidationResult>;
10
11
  }
@@ -12,25 +12,24 @@ const io_1 = require("../utils/io");
12
12
  * Validator for Apple Panels (.plist or .ascconfig directory)
13
13
  */
14
14
  class ApplePanelsValidator extends baseValidator_1.BaseValidator {
15
- static async validateFile(filePath) {
15
+ static async validateFile(filePath, fileAdapter = io_1.defaultFileAdapter) {
16
+ const { pathExists, isDirectory, getFileSize, readBinaryFromInput, join } = fileAdapter;
16
17
  const validator = new ApplePanelsValidator();
17
- const fs = (0, io_1.getFs)();
18
- const path = (0, io_1.getPath)();
19
18
  let content;
20
19
  const filename = (0, io_1.getBasename)(filePath);
21
20
  let size = 0;
22
- const stats = fs.existsSync(filePath) ? fs.statSync(filePath) : null;
23
- if (stats?.isDirectory() && filename.toLowerCase().endsWith('.ascconfig')) {
24
- const panelPath = path.join(filePath, 'Contents', 'Resources', 'PanelDefinitions.plist');
25
- if (!fs.existsSync(panelPath)) {
21
+ const isDir = await isDirectory(filePath);
22
+ if (isDir && filename.toLowerCase().endsWith('.ascconfig')) {
23
+ const panelPath = join(filePath, 'Contents', 'Resources', 'PanelDefinitions.plist');
24
+ if (!(await pathExists(panelPath))) {
26
25
  return validator.validate(Buffer.alloc(0), filename, 0);
27
26
  }
28
- content = fs.readFileSync(panelPath);
29
- size = fs.statSync(panelPath).size;
27
+ content = await readBinaryFromInput(panelPath);
28
+ size = await getFileSize(panelPath);
30
29
  }
31
30
  else {
32
- content = fs.readFileSync(filePath);
33
- size = stats?.size || content.byteLength;
31
+ content = await readBinaryFromInput(filePath);
32
+ size = (await getFileSize(filePath)) || content.byteLength;
34
33
  }
35
34
  return validator.validate(content, filename, size);
36
35
  }
@@ -1,5 +1,6 @@
1
1
  import { BaseValidator } from './baseValidator';
2
2
  import { ValidationResult } from './validationTypes';
3
+ import { FileAdapter } from '../utils/io';
3
4
  /**
4
5
  * Validator for Asterics Grid (.grd) JSON files
5
6
  */
@@ -7,7 +8,7 @@ export declare class AstericsGridValidator extends BaseValidator {
7
8
  /**
8
9
  * Validate from disk
9
10
  */
10
- static validateFile(filePath: string): Promise<ValidationResult>;
11
+ static validateFile(filePath: string, fileAdapter?: FileAdapter): Promise<ValidationResult>;
11
12
  /**
12
13
  * Identify whether the content appears to be an Asterics .grd file
13
14
  */
@@ -11,11 +11,12 @@ class AstericsGridValidator extends baseValidator_1.BaseValidator {
11
11
  /**
12
12
  * Validate from disk
13
13
  */
14
- static async validateFile(filePath) {
14
+ static async validateFile(filePath, fileAdapter) {
15
+ const { readBinaryFromInput, getFileSize } = fileAdapter ?? io_1.defaultFileAdapter;
15
16
  const validator = new AstericsGridValidator();
16
- const content = (0, io_1.readBinaryFromInput)(filePath);
17
- const stats = (0, io_1.getFs)().statSync(filePath);
18
- return validator.validate(content, (0, io_1.getBasename)(filePath), stats.size);
17
+ const content = await readBinaryFromInput(filePath);
18
+ const size = await getFileSize(filePath);
19
+ return validator.validate(content, (0, io_1.getBasename)(filePath), size);
19
20
  }
20
21
  /**
21
22
  * Identify whether the content appears to be an Asterics .grd file
@@ -1,4 +1,4 @@
1
- import { ValidationResult, ValidationCheck, ValidationOptions } from './validationTypes';
1
+ import { ValidationResult, ValidationCheck, ValidationOptions, ValidationConfig } from './validationTypes';
2
2
  /**
3
3
  * Base class for all format validators
4
4
  * Provides the check-based validation system
@@ -9,7 +9,7 @@ export declare abstract class BaseValidator {
9
9
  protected _checks: ValidationCheck[];
10
10
  protected _sub_checks: ValidationResult[];
11
11
  protected _blocked: boolean;
12
- protected _options: ValidationOptions;
12
+ protected _options: ValidationConfig;
13
13
  constructor(options?: ValidationOptions);
14
14
  /**
15
15
  * Reset validator state
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseValidator = void 0;
4
+ const io_1 = require("../utils/io");
5
+ const zip_1 = require("../utils/zip");
4
6
  const validationTypes_1 = require("./validationTypes");
5
7
  /**
6
8
  * Base class for all format validators
@@ -17,6 +19,9 @@ class BaseValidator {
17
19
  includeWarnings: options.includeWarnings ?? true,
18
20
  stopOnBlocker: options.stopOnBlocker ?? true,
19
21
  customRules: options.customRules || [],
22
+ fileAdapter: io_1.defaultFileAdapter,
23
+ zipAdapter: zip_1.getZipAdapter,
24
+ ...options,
20
25
  };
21
26
  this.reset();
22
27
  }
@@ -1,10 +1,11 @@
1
1
  import { BaseValidator } from './baseValidator';
2
2
  import { ValidationResult } from './validationTypes';
3
+ import { FileAdapter } from '../utils/io';
3
4
  /**
4
5
  * Validator for Graphviz DOT files
5
6
  */
6
7
  export declare class DotValidator extends BaseValidator {
7
- static validateFile(filePath: string): Promise<ValidationResult>;
8
+ static validateFile(filePath: string, fileAdapter?: FileAdapter): Promise<ValidationResult>;
8
9
  static identifyFormat(content: any, filename: string): Promise<boolean>;
9
10
  validate(content: Buffer | Uint8Array, filename: string, filesize: number): Promise<ValidationResult>;
10
11
  }
@@ -8,11 +8,12 @@ const io_1 = require("../utils/io");
8
8
  * Validator for Graphviz DOT files
9
9
  */
10
10
  class DotValidator extends baseValidator_1.BaseValidator {
11
- static async validateFile(filePath) {
11
+ static async validateFile(filePath, fileAdapter) {
12
+ const { readBinaryFromInput, getFileSize } = fileAdapter ?? io_1.defaultFileAdapter;
12
13
  const validator = new DotValidator();
13
- const content = (0, io_1.readBinaryFromInput)(filePath);
14
- const stats = (0, io_1.getFs)().statSync(filePath);
15
- return validator.validate(content, (0, io_1.getBasename)(filePath), stats.size);
14
+ const content = await readBinaryFromInput(filePath);
15
+ const size = await getFileSize(filePath);
16
+ return validator.validate(content, (0, io_1.getBasename)(filePath), size);
16
17
  }
17
18
  static async identifyFormat(content, filename) {
18
19
  const name = filename.toLowerCase();
@@ -1,10 +1,11 @@
1
1
  import { BaseValidator } from './baseValidator';
2
2
  import { ValidationResult } from './validationTypes';
3
+ import { FileAdapter } from '../utils/io';
3
4
  /**
4
5
  * Validator for Excel imports (.xlsx/.xls)
5
6
  */
6
7
  export declare class ExcelValidator extends BaseValidator {
7
- static validateFile(filePath: string): Promise<ValidationResult>;
8
+ static validateFile(filePath: string, fileAdapter?: FileAdapter): Promise<ValidationResult>;
8
9
  static identifyFormat(_content: any, filename: string): Promise<boolean>;
9
10
  validate(content: Buffer | Uint8Array, filename: string, filesize: number): Promise<ValidationResult>;
10
11
  }
@@ -32,11 +32,12 @@ const io_1 = require("../utils/io");
32
32
  * Validator for Excel imports (.xlsx/.xls)
33
33
  */
34
34
  class ExcelValidator extends baseValidator_1.BaseValidator {
35
- static async validateFile(filePath) {
35
+ static async validateFile(filePath, fileAdapter) {
36
+ const { readBinaryFromInput, getFileSize } = fileAdapter ?? io_1.defaultFileAdapter;
36
37
  const validator = new ExcelValidator();
37
- const content = (0, io_1.readBinaryFromInput)(filePath);
38
- const stats = (0, io_1.getFs)().statSync(filePath);
39
- return validator.validate(content, (0, io_1.getBasename)(filePath), stats.size);
38
+ const content = await readBinaryFromInput(filePath);
39
+ const size = await getFileSize(filePath);
40
+ return validator.validate(content, (0, io_1.getBasename)(filePath), size);
40
41
  }
41
42
  static async identifyFormat(_content, filename) {
42
43
  const name = filename.toLowerCase();
@@ -1,5 +1,6 @@
1
1
  import { BaseValidator } from './baseValidator';
2
2
  import { ValidationResult } from './validationTypes';
3
+ import { FileAdapter } from '../utils/io';
3
4
  /**
4
5
  * Validator for Grid3/Smartbox Gridset files (.gridset, .gridsetx)
5
6
  */
@@ -8,7 +9,7 @@ export declare class GridsetValidator extends BaseValidator {
8
9
  /**
9
10
  * Validate a Gridset file from disk
10
11
  */
11
- static validateFile(filePath: string): Promise<ValidationResult>;
12
+ static validateFile(filePath: string, fileAdapter?: FileAdapter): Promise<ValidationResult>;
12
13
  /**
13
14
  * Check if content is Gridset format
14
15
  */
@@ -22,15 +22,11 @@ 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.GridsetValidator = void 0;
30
27
  /* eslint-disable @typescript-eslint/require-await */
31
28
  /* eslint-disable @typescript-eslint/no-unsafe-argument */
32
29
  /* eslint-disable @typescript-eslint/no-unsafe-return */
33
- const jszip_1 = __importDefault(require("jszip"));
34
30
  const xml2js = __importStar(require("xml2js"));
35
31
  const baseValidator_1 = require("./baseValidator");
36
32
  const io_1 = require("../utils/io");
@@ -44,12 +40,12 @@ class GridsetValidator extends baseValidator_1.BaseValidator {
44
40
  /**
45
41
  * Validate a Gridset file from disk
46
42
  */
47
- static async validateFile(filePath) {
43
+ static async validateFile(filePath, fileAdapter) {
44
+ const { readBinaryFromInput, getFileSize } = fileAdapter ?? io_1.defaultFileAdapter;
48
45
  const validator = new GridsetValidator();
49
- const fs = (0, io_1.getFs)();
50
- const content = fs.readFileSync(filePath);
51
- const stats = fs.statSync(filePath);
52
- return validator.validate(content, (0, io_1.getBasename)(filePath), stats.size);
46
+ const content = await readBinaryFromInput(filePath);
47
+ const size = await getFileSize(filePath);
48
+ return validator.validate(content, (0, io_1.getBasename)(filePath), size);
53
49
  }
54
50
  /**
55
51
  * Check if content is Gridset format
@@ -138,24 +134,17 @@ class GridsetValidator extends baseValidator_1.BaseValidator {
138
134
  * Validate a ZIP archive (.gridset)
139
135
  */
140
136
  async validateZipArchive(content, filename, _filesize) {
141
- let zip;
142
- try {
143
- zip = await jszip_1.default.loadAsync((0, io_1.toUint8Array)(content));
144
- }
145
- catch (e) {
146
- this.err(`Failed to open ZIP archive: ${e.message}`, true);
147
- return;
148
- }
149
- const entries = Object.values(zip.files).filter((entry) => !entry.dir);
137
+ const zip = await this._options.zipAdapter(content);
138
+ const entries = zip.listFiles();
150
139
  // Check for gridset.xml (required)
151
140
  await this.add_check('gridset_xml_presence', 'gridset.xml presence', async () => {
152
- const gridsetEntry = entries.find((e) => e.name.toLowerCase() === 'gridset.xml');
141
+ const gridsetEntry = entries.find((e) => e.toLowerCase() === 'gridset.xml');
153
142
  if (!gridsetEntry) {
154
143
  this.err('Missing gridset.xml in archive', true);
155
144
  }
156
145
  else {
157
146
  try {
158
- const gridsetXml = await gridsetEntry.async('string');
147
+ const gridsetXml = await zip.readFile(gridsetEntry);
159
148
  const parser = new xml2js.Parser();
160
149
  const xmlObj = await parser.parseStringPromise(gridsetXml);
161
150
  const gridset = xmlObj.gridset || xmlObj.Gridset;
@@ -173,13 +162,13 @@ class GridsetValidator extends baseValidator_1.BaseValidator {
173
162
  });
174
163
  // Check for settings.xml (highly recommended/required for metadata)
175
164
  await this.add_check('settings_xml_presence', 'settings.xml presence', async () => {
176
- const settingsEntry = entries.find((e) => e.name.toLowerCase() === 'settings.xml');
165
+ const settingsEntry = entries.find((e) => e.toLowerCase() === 'settings.xml');
177
166
  if (!settingsEntry) {
178
167
  this.warn('Missing settings.xml in archive (required for full metadata)');
179
168
  }
180
169
  else {
181
170
  try {
182
- const settingsXml = await settingsEntry.async('string');
171
+ const settingsXml = await zip.readFile(settingsEntry);
183
172
  const parser = new xml2js.Parser();
184
173
  const xmlObj = await parser.parseStringPromise(settingsXml);
185
174
  const settings = xmlObj.GridSetSettings || xmlObj.gridSetSettings || xmlObj.GridsetSettings;
@@ -16,7 +16,7 @@ export { ApplePanelsValidator } from './applePanelsValidator';
16
16
  export { ObfsetValidator } from './obfsetValidator';
17
17
  import { BaseValidator } from './baseValidator';
18
18
  import { ValidationResult } from './validationTypes';
19
- import { type ProcessorInput } from '../utils/io';
19
+ import { FileAdapter, type ProcessorInput } from '../utils/io';
20
20
  export declare function getValidatorForFormat(format: string): BaseValidator | null;
21
21
  export declare function getValidatorForFile(filename: string): BaseValidator | null;
22
22
  /**
@@ -24,4 +24,4 @@ export declare function getValidatorForFile(filename: string): BaseValidator | n
24
24
  * When a file path is provided, any validator-specific validateFile() helper
25
25
  * will be used if available to access nested resources.
26
26
  */
27
- export declare function validateFileOrBuffer(filePathOrBuffer: ProcessorInput, filenameHint?: string): Promise<ValidationResult>;
27
+ export declare function validateFileOrBuffer(filePathOrBuffer: ProcessorInput, fileAdapter?: FileAdapter, filenameHint?: string): Promise<ValidationResult>;
@@ -125,10 +125,11 @@ function getValidatorForFile(filename) {
125
125
  * When a file path is provided, any validator-specific validateFile() helper
126
126
  * will be used if available to access nested resources.
127
127
  */
128
- async function validateFileOrBuffer(filePathOrBuffer, filenameHint) {
128
+ async function validateFileOrBuffer(filePathOrBuffer, fileAdapter, filenameHint) {
129
129
  const isPath = typeof filePathOrBuffer === 'string';
130
130
  const name = filenameHint || (isPath ? (0, io_1.getBasename)(filePathOrBuffer) : 'upload');
131
131
  const validator = getValidatorForFile(name) || getValidatorForFormat(name);
132
+ const adapter = fileAdapter ?? io_1.defaultFileAdapter;
132
133
  if (!validator) {
133
134
  throw new Error(`No validator registered for ${name}`);
134
135
  }
@@ -140,9 +141,9 @@ async function validateFileOrBuffer(filePathOrBuffer, filenameHint) {
140
141
  if (typeof ctor.validateFile === 'function') {
141
142
  return ctor.validateFile(filePathOrBuffer);
142
143
  }
143
- const buf = (0, io_1.readBinaryFromInput)(filePathOrBuffer);
144
- const stats = (0, io_1.getFs)().statSync(filePathOrBuffer);
145
- return validator.validate(buf, (0, io_1.getBasename)(filePathOrBuffer), stats.size);
144
+ const buf = await adapter.readBinaryFromInput(filePathOrBuffer);
145
+ const size = await adapter.getFileSize(filePathOrBuffer);
146
+ return validator.validate(buf, (0, io_1.getBasename)(filePathOrBuffer), size);
146
147
  }
147
148
  const buffer = (0, io_1.toUint8Array)(filePathOrBuffer);
148
149
  return validator.validate(buffer, name, buffer.byteLength);
@@ -1,5 +1,6 @@
1
1
  import { BaseValidator } from './baseValidator';
2
2
  import { ValidationResult } from './validationTypes';
3
+ import { FileAdapter } from '../utils/io';
3
4
  /**
4
5
  * Validator for Open Board Format (OBF/OBZ) files
5
6
  */
@@ -8,7 +9,7 @@ export declare class ObfValidator extends BaseValidator {
8
9
  /**
9
10
  * Validate an OBF file from disk
10
11
  */
11
- static validateFile(filePath: string): Promise<ValidationResult>;
12
+ static validateFile(filePath: string, fileAdapter?: FileAdapter): Promise<ValidationResult>;
12
13
  /**
13
14
  * Check if content is OBF format
14
15
  */
@@ -24,11 +24,12 @@ class ObfValidator extends baseValidator_1.BaseValidator {
24
24
  /**
25
25
  * Validate an OBF file from disk
26
26
  */
27
- static async validateFile(filePath) {
27
+ static async validateFile(filePath, fileAdapter) {
28
+ const { readBinaryFromInput, getFileSize } = fileAdapter ?? io_1.defaultFileAdapter;
28
29
  const validator = new ObfValidator();
29
- const content = (0, io_1.readBinaryFromInput)(filePath);
30
- const stats = (0, io_1.getFs)().statSync(filePath);
31
- return validator.validate(content, (0, io_1.getBasename)(filePath), stats.size);
30
+ const content = await readBinaryFromInput(filePath);
31
+ const size = await getFileSize(filePath);
32
+ return validator.validate(content, (0, io_1.getBasename)(filePath), size);
32
33
  }
33
34
  /**
34
35
  * Check if content is OBF format
@@ -1,10 +1,11 @@
1
1
  import { BaseValidator } from './baseValidator';
2
2
  import { ValidationResult } from './validationTypes';
3
+ import { FileAdapter } from '../utils/io';
3
4
  /**
4
5
  * Validator for OBF set bundles (.obfset) - JSON arrays of boards
5
6
  */
6
7
  export declare class ObfsetValidator extends BaseValidator {
7
- static validateFile(filePath: string): Promise<ValidationResult>;
8
+ static validateFile(filePath: string, fileAdapter?: FileAdapter): Promise<ValidationResult>;
8
9
  static identifyFormat(content: any, filename: string): Promise<boolean>;
9
10
  validate(content: Buffer | Uint8Array, filename: string, filesize: number): Promise<ValidationResult>;
10
11
  }
@@ -8,11 +8,12 @@ const io_1 = require("../utils/io");
8
8
  * Validator for OBF set bundles (.obfset) - JSON arrays of boards
9
9
  */
10
10
  class ObfsetValidator extends baseValidator_1.BaseValidator {
11
- static async validateFile(filePath) {
11
+ static async validateFile(filePath, fileAdapter) {
12
+ const { readBinaryFromInput, getFileSize } = fileAdapter ?? io_1.defaultFileAdapter;
12
13
  const validator = new ObfsetValidator();
13
- const content = (0, io_1.readBinaryFromInput)(filePath);
14
- const stats = (0, io_1.getFs)().statSync(filePath);
15
- return validator.validate(content, (0, io_1.getBasename)(filePath), stats.size);
14
+ const content = await readBinaryFromInput(filePath);
15
+ const size = await getFileSize(filePath);
16
+ return validator.validate(content, (0, io_1.getBasename)(filePath), size);
16
17
  }
17
18
  static async identifyFormat(content, filename) {
18
19
  const name = filename.toLowerCase();
@@ -1,10 +1,11 @@
1
1
  import { BaseValidator } from './baseValidator';
2
2
  import { ValidationResult } from './validationTypes';
3
+ import { FileAdapter } from '../utils/io';
3
4
  /**
4
5
  * Validator for OPML files
5
6
  */
6
7
  export declare class OpmlValidator extends BaseValidator {
7
- static validateFile(filePath: string): Promise<ValidationResult>;
8
+ static validateFile(filePath: string, fileAdapter?: FileAdapter): Promise<ValidationResult>;
8
9
  static identifyFormat(content: any, filename: string): Promise<boolean>;
9
10
  validate(content: Buffer | Uint8Array, filename: string, filesize: number): Promise<ValidationResult>;
10
11
  }
@@ -9,11 +9,12 @@ const io_1 = require("../utils/io");
9
9
  * Validator for OPML files
10
10
  */
11
11
  class OpmlValidator extends baseValidator_1.BaseValidator {
12
- static async validateFile(filePath) {
12
+ static async validateFile(filePath, fileAdapter) {
13
+ const { readBinaryFromInput, getFileSize } = fileAdapter ?? io_1.defaultFileAdapter;
13
14
  const validator = new OpmlValidator();
14
- const content = (0, io_1.readBinaryFromInput)(filePath);
15
- const stats = (0, io_1.getFs)().statSync(filePath);
16
- return validator.validate(content, (0, io_1.getBasename)(filePath), stats.size);
15
+ const content = await readBinaryFromInput(filePath);
16
+ const size = await getFileSize(filePath);
17
+ return validator.validate(content, (0, io_1.getBasename)(filePath), size);
17
18
  }
18
19
  static async identifyFormat(content, filename) {
19
20
  const name = filename.toLowerCase();
@@ -1,5 +1,6 @@
1
1
  import { BaseValidator } from './baseValidator';
2
2
  import { ValidationResult } from './validationTypes';
3
+ import { FileAdapter } from '../utils/io';
3
4
  /**
4
5
  * Validator for Snap files (.spb, .sps)
5
6
  * Snap files are zipped packages containing XML configuration
@@ -9,7 +10,7 @@ export declare class SnapValidator extends BaseValidator {
9
10
  /**
10
11
  * Validate a Snap file from disk
11
12
  */
12
- static validateFile(filePath: string): Promise<ValidationResult>;
13
+ static validateFile(filePath: string, fileAdapter?: FileAdapter): Promise<ValidationResult>;
13
14
  /**
14
15
  * Check if content is Snap format
15
16
  */
@@ -45,11 +45,12 @@ class SnapValidator extends baseValidator_1.BaseValidator {
45
45
  /**
46
46
  * Validate a Snap file from disk
47
47
  */
48
- static async validateFile(filePath) {
48
+ static async validateFile(filePath, fileAdapter) {
49
+ const { readBinaryFromInput, getFileSize } = fileAdapter ?? io_1.defaultFileAdapter;
49
50
  const validator = new SnapValidator();
50
- const content = (0, io_1.readBinaryFromInput)(filePath);
51
- const stats = (0, io_1.getFs)().statSync(filePath);
52
- return validator.validate(content, (0, io_1.getBasename)(filePath), stats.size);
51
+ const content = await readBinaryFromInput(filePath);
52
+ const size = await getFileSize(filePath);
53
+ return validator.validate(content, (0, io_1.getBasename)(filePath), size);
53
54
  }
54
55
  /**
55
56
  * Check if content is Snap format
@@ -187,7 +188,10 @@ class SnapValidator extends baseValidator_1.BaseValidator {
187
188
  await this.add_check('sqlite', 'valid SQLite database', async () => {
188
189
  let cleanup;
189
190
  try {
190
- const result = await (0, sqlite_1.openSqliteDatabase)(content, { readonly: true });
191
+ const result = await (0, sqlite_1.openSqliteDatabase)(content, {
192
+ readonly: true,
193
+ fileAdapter: this._options.fileAdapter,
194
+ });
191
195
  const db = result.db;
192
196
  cleanup = result.cleanup;
193
197
  const tableRows = db
@@ -234,7 +238,7 @@ class SnapValidator extends baseValidator_1.BaseValidator {
234
238
  }
235
239
  finally {
236
240
  if (cleanup) {
237
- cleanup();
241
+ await cleanup();
238
242
  }
239
243
  }
240
244
  });
@@ -1,7 +1,7 @@
1
1
  import { BaseValidator } from './baseValidator';
2
2
  import { ValidationResult } from './validationTypes';
3
- import { type ProcessorInput } from '../utils/io';
4
- import { type ZipAdapter } from '../utils/zip';
3
+ import { FileAdapter, type ProcessorInput } from '../utils/io';
4
+ import { ZipAdapter } from '../utils/zip';
5
5
  /**
6
6
  * Validator for TouchChat files (.ce)
7
7
  * TouchChat files are ZIP archives that contain a .c4v SQLite database.
@@ -12,13 +12,11 @@ export declare class TouchChatValidator extends BaseValidator {
12
12
  /**
13
13
  * Validate a TouchChat file from disk
14
14
  */
15
- static validateFile(filePath: string): Promise<ValidationResult>;
15
+ static validateFile(filePath: string, fileAdapter?: FileAdapter): Promise<ValidationResult>;
16
16
  /**
17
17
  * Check if content is TouchChat format
18
18
  */
19
- static identifyFormat(content: any, filename: string, zipAdapter?: (input: ProcessorInput) => Promise<{
20
- zip: ZipAdapter;
21
- }>): Promise<boolean>;
19
+ static identifyFormat(content: any, filename: string, fileAdapter?: FileAdapter, zipAdapter?: (input: ProcessorInput) => Promise<ZipAdapter>): Promise<boolean>;
22
20
  /**
23
21
  * Main validation method
24
22
  */