@willwade/aac-processors 0.1.14 → 0.1.15
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.
|
@@ -65,7 +65,8 @@ export class TouchChatValidator extends BaseValidator {
|
|
|
65
65
|
this.warn('filename should end with .ce');
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
|
-
const
|
|
68
|
+
const looksLikeXml = this.isXmlBuffer(content);
|
|
69
|
+
const zipped = looksLikeXml ? false : await this.tryValidateZipSqlite(content);
|
|
69
70
|
if (!zipped) {
|
|
70
71
|
let xmlObj = null;
|
|
71
72
|
await this.add_check('xml_parse', 'valid XML', async () => {
|
|
@@ -228,6 +229,23 @@ export class TouchChatValidator extends BaseValidator {
|
|
|
228
229
|
}
|
|
229
230
|
return true;
|
|
230
231
|
}
|
|
232
|
+
isXmlBuffer(content) {
|
|
233
|
+
const bytes = content instanceof Uint8Array ? content : new Uint8Array(content);
|
|
234
|
+
const max = Math.min(bytes.length, 256);
|
|
235
|
+
let start = 0;
|
|
236
|
+
while (start < max) {
|
|
237
|
+
const ch = bytes[start];
|
|
238
|
+
if (ch === 0x20 || ch === 0x0a || ch === 0x0d || ch === 0x09) {
|
|
239
|
+
start += 1;
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
if (start >= max) {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
return bytes[start] === 0x3c; // '<'
|
|
248
|
+
}
|
|
231
249
|
async tryValidateZipSqlite(content) {
|
|
232
250
|
let usedZip = false;
|
|
233
251
|
await this.add_check('zip', 'TouchChat ZIP package', async () => {
|
|
@@ -91,7 +91,8 @@ class TouchChatValidator extends baseValidator_1.BaseValidator {
|
|
|
91
91
|
this.warn('filename should end with .ce');
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
|
-
const
|
|
94
|
+
const looksLikeXml = this.isXmlBuffer(content);
|
|
95
|
+
const zipped = looksLikeXml ? false : await this.tryValidateZipSqlite(content);
|
|
95
96
|
if (!zipped) {
|
|
96
97
|
let xmlObj = null;
|
|
97
98
|
await this.add_check('xml_parse', 'valid XML', async () => {
|
|
@@ -254,6 +255,23 @@ class TouchChatValidator extends baseValidator_1.BaseValidator {
|
|
|
254
255
|
}
|
|
255
256
|
return true;
|
|
256
257
|
}
|
|
258
|
+
isXmlBuffer(content) {
|
|
259
|
+
const bytes = content instanceof Uint8Array ? content : new Uint8Array(content);
|
|
260
|
+
const max = Math.min(bytes.length, 256);
|
|
261
|
+
let start = 0;
|
|
262
|
+
while (start < max) {
|
|
263
|
+
const ch = bytes[start];
|
|
264
|
+
if (ch === 0x20 || ch === 0x0a || ch === 0x0d || ch === 0x09) {
|
|
265
|
+
start += 1;
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
if (start >= max) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
return bytes[start] === 0x3c; // '<'
|
|
274
|
+
}
|
|
257
275
|
async tryValidateZipSqlite(content) {
|
|
258
276
|
let usedZip = false;
|
|
259
277
|
await this.add_check('zip', 'TouchChat ZIP package', async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willwade/aac-processors",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
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",
|