@willwade/aac-processors 0.1.1 → 0.1.3

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.
@@ -360,6 +360,12 @@ class GridsetProcessor extends BaseProcessor {
360
360
  if (s.r !== undefined) {
361
361
  const rElements = Array.isArray(s.r) ? s.r : [s.r];
362
362
  for (const r of rElements) {
363
+ if (typeof r === 'number') {
364
+ if (r !== 0) {
365
+ parts.push(String(r));
366
+ }
367
+ continue;
368
+ }
363
369
  if (typeof r === 'object' && r !== null && '#text' in r) {
364
370
  parts.push(String(r['#text']));
365
371
  }
@@ -507,7 +513,14 @@ class GridsetProcessor extends BaseProcessor {
507
513
  }
508
514
  // Debug: log all entry names
509
515
  console.log('[Gridset] Total zip entries:', entries.length);
510
- const gridEntries = entries.filter((e) => e.entryName.startsWith('Grids/') && e.entryName.endsWith('grid.xml'));
516
+ const normalizeEntryName = (entryName) => entryName.replace(/\\/g, '/').toLowerCase();
517
+ const isGridXmlEntry = (entryName) => {
518
+ const normalized = normalizeEntryName(entryName);
519
+ if (!normalized.endsWith('grid.xml'))
520
+ return false;
521
+ return normalized.startsWith('grids/') || normalized.includes('/grids/');
522
+ };
523
+ const gridEntries = entries.filter((e) => isGridXmlEntry(e.entryName));
511
524
  console.log('[Gridset] Grid XML entries found:', gridEntries.length);
512
525
  if (gridEntries.length > 0) {
513
526
  console.log('[Gridset] First few grid entries:', gridEntries.slice(0, 3).map((e) => e.entryName));
@@ -516,7 +529,7 @@ class GridsetProcessor extends BaseProcessor {
516
529
  const gridNameToIdMap = new Map();
517
530
  const gridIdToNameMap = new Map();
518
531
  for (const entry of entries) {
519
- if (entry.entryName.startsWith('Grids/') && entry.entryName.endsWith('grid.xml')) {
532
+ if (isGridXmlEntry(entry.entryName)) {
520
533
  try {
521
534
  const xmlContent = decodeText(await readEntryBuffer(entry));
522
535
  const data = parser.parse(xmlContent);
@@ -549,7 +562,7 @@ class GridsetProcessor extends BaseProcessor {
549
562
  // Second pass: process each grid file in the gridset
550
563
  for (const entry of entries) {
551
564
  // Only process files named grid.xml under Grids/ (any subdir)
552
- if (entry.entryName.startsWith('Grids/') && entry.entryName.endsWith('grid.xml')) {
565
+ if (isGridXmlEntry(entry.entryName)) {
553
566
  let xmlContent;
554
567
  try {
555
568
  const buffer = await readEntryBuffer(entry);
@@ -341,7 +341,7 @@ class ObfProcessor extends BaseProcessor {
341
341
  return null;
342
342
  }
343
343
  // If input is a string path and ends with .obf, treat as JSON
344
- if (typeof filePathOrBuffer === 'string' && filePathOrBuffer.endsWith('.obf')) {
344
+ if (typeof filePathOrBuffer === 'string' && filePathOrBuffer.toLowerCase().endsWith('.obf')) {
345
345
  try {
346
346
  const content = readTextFromInput(filePathOrBuffer);
347
347
  const boardData = tryParseObfJson(content);
@@ -393,8 +393,10 @@ class ObfProcessor extends BaseProcessor {
393
393
  }
394
394
  // Otherwise, try as ZIP (.obz). Detect likely zip signature first; throw if neither JSON nor ZIP
395
395
  function isLikelyZip(input) {
396
- if (typeof input === 'string')
397
- return input.endsWith('.zip') || input.endsWith('.obz');
396
+ if (typeof input === 'string') {
397
+ const lowered = input.toLowerCase();
398
+ return lowered.endsWith('.zip') || lowered.endsWith('.obz');
399
+ }
398
400
  const bytes = readBinaryFromInput(input);
399
401
  return bytes.length >= 2 && bytes[0] === 0x50 && bytes[1] === 0x4b;
400
402
  }
@@ -420,7 +422,7 @@ class ObfProcessor extends BaseProcessor {
420
422
  zip.forEach((relativePath, file) => {
421
423
  if (file.dir)
422
424
  return;
423
- if (relativePath.endsWith('.obf')) {
425
+ if (relativePath.toLowerCase().endsWith('.obf')) {
424
426
  obfEntries.push({ name: relativePath, file });
425
427
  }
426
428
  });
@@ -386,6 +386,12 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
386
386
  if (s.r !== undefined) {
387
387
  const rElements = Array.isArray(s.r) ? s.r : [s.r];
388
388
  for (const r of rElements) {
389
+ if (typeof r === 'number') {
390
+ if (r !== 0) {
391
+ parts.push(String(r));
392
+ }
393
+ continue;
394
+ }
389
395
  if (typeof r === 'object' && r !== null && '#text' in r) {
390
396
  parts.push(String(r['#text']));
391
397
  }
@@ -533,7 +539,14 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
533
539
  }
534
540
  // Debug: log all entry names
535
541
  console.log('[Gridset] Total zip entries:', entries.length);
536
- const gridEntries = entries.filter((e) => e.entryName.startsWith('Grids/') && e.entryName.endsWith('grid.xml'));
542
+ const normalizeEntryName = (entryName) => entryName.replace(/\\/g, '/').toLowerCase();
543
+ const isGridXmlEntry = (entryName) => {
544
+ const normalized = normalizeEntryName(entryName);
545
+ if (!normalized.endsWith('grid.xml'))
546
+ return false;
547
+ return normalized.startsWith('grids/') || normalized.includes('/grids/');
548
+ };
549
+ const gridEntries = entries.filter((e) => isGridXmlEntry(e.entryName));
537
550
  console.log('[Gridset] Grid XML entries found:', gridEntries.length);
538
551
  if (gridEntries.length > 0) {
539
552
  console.log('[Gridset] First few grid entries:', gridEntries.slice(0, 3).map((e) => e.entryName));
@@ -542,7 +555,7 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
542
555
  const gridNameToIdMap = new Map();
543
556
  const gridIdToNameMap = new Map();
544
557
  for (const entry of entries) {
545
- if (entry.entryName.startsWith('Grids/') && entry.entryName.endsWith('grid.xml')) {
558
+ if (isGridXmlEntry(entry.entryName)) {
546
559
  try {
547
560
  const xmlContent = (0, io_1.decodeText)(await readEntryBuffer(entry));
548
561
  const data = parser.parse(xmlContent);
@@ -575,7 +588,7 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
575
588
  // Second pass: process each grid file in the gridset
576
589
  for (const entry of entries) {
577
590
  // Only process files named grid.xml under Grids/ (any subdir)
578
- if (entry.entryName.startsWith('Grids/') && entry.entryName.endsWith('grid.xml')) {
591
+ if (isGridXmlEntry(entry.entryName)) {
579
592
  let xmlContent;
580
593
  try {
581
594
  const buffer = await readEntryBuffer(entry);
@@ -367,7 +367,7 @@ class ObfProcessor extends baseProcessor_1.BaseProcessor {
367
367
  return null;
368
368
  }
369
369
  // If input is a string path and ends with .obf, treat as JSON
370
- if (typeof filePathOrBuffer === 'string' && filePathOrBuffer.endsWith('.obf')) {
370
+ if (typeof filePathOrBuffer === 'string' && filePathOrBuffer.toLowerCase().endsWith('.obf')) {
371
371
  try {
372
372
  const content = (0, io_1.readTextFromInput)(filePathOrBuffer);
373
373
  const boardData = tryParseObfJson(content);
@@ -419,8 +419,10 @@ class ObfProcessor extends baseProcessor_1.BaseProcessor {
419
419
  }
420
420
  // Otherwise, try as ZIP (.obz). Detect likely zip signature first; throw if neither JSON nor ZIP
421
421
  function isLikelyZip(input) {
422
- if (typeof input === 'string')
423
- return input.endsWith('.zip') || input.endsWith('.obz');
422
+ if (typeof input === 'string') {
423
+ const lowered = input.toLowerCase();
424
+ return lowered.endsWith('.zip') || lowered.endsWith('.obz');
425
+ }
424
426
  const bytes = (0, io_1.readBinaryFromInput)(input);
425
427
  return bytes.length >= 2 && bytes[0] === 0x50 && bytes[1] === 0x4b;
426
428
  }
@@ -446,7 +448,7 @@ class ObfProcessor extends baseProcessor_1.BaseProcessor {
446
448
  zip.forEach((relativePath, file) => {
447
449
  if (file.dir)
448
450
  return;
449
- if (relativePath.endsWith('.obf')) {
451
+ if (relativePath.toLowerCase().endsWith('.obf')) {
450
452
  obfEntries.push({ name: relativePath, file });
451
453
  }
452
454
  });
@@ -4,7 +4,11 @@ import path from 'path';
4
4
  export default defineConfig({
5
5
  resolve: {
6
6
  alias: {
7
- 'aac-processors': path.resolve(__dirname, '../../src/index.browser.ts')
7
+ 'aac-processors': path.resolve(__dirname, '../../src/index.browser.ts'),
8
+ stream: path.resolve(__dirname, 'node_modules/stream-browserify'),
9
+ events: path.resolve(__dirname, 'node_modules/events'),
10
+ timers: path.resolve(__dirname, 'node_modules/timers-browserify'),
11
+ util: path.resolve(__dirname, 'node_modules/util')
8
12
  }
9
13
  },
10
14
  optimizeDeps: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willwade/aac-processors",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
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",
@@ -94,6 +94,7 @@
94
94
  "format": "prettier --write \"src/**/*.{js,ts}\" \"test/**/*.{js,ts}\" \"*.{js,ts,json,md}\"",
95
95
  "format:check": "prettier --check \"src/**/*.{js,ts}\" \"test/**/*.{js,ts}\" \"*.{js,ts,json,md}\"",
96
96
  "smoke:browser": "node scripts/smoke-browser-bundle.js",
97
+ "verify:browser-build": "node scripts/verify-browser-build.js",
97
98
  "test": "npm run build && jest",
98
99
  "test:watch": "npm run build && jest --watch",
99
100
  "test:coverage": "npm run build && jest --coverage",
@@ -102,8 +103,8 @@
102
103
  "docs": "typedoc",
103
104
  "coverage:report": "node scripts/coverage-analysis.js",
104
105
  "type-check": "tsc --noEmit",
105
- "prepublishOnly": "npm run build",
106
- "prepack": "npm run build"
106
+ "prepublishOnly": "npm run build:all && npm run verify:browser-build",
107
+ "prepack": "npm run build:all && npm run verify:browser-build"
107
108
  },
108
109
  "keywords": [
109
110
  "aac",