@willwade/aac-processors 0.1.12 → 0.1.13

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.
@@ -325,8 +325,8 @@ class GridsetProcessor extends BaseProcessor {
325
325
  if (typeof val === 'number')
326
326
  return String(val);
327
327
  if (typeof val === 'object') {
328
- if ('#text' in val)
329
- return String(val['#text']);
328
+ // Don't immediately return #text - it might be whitespace alongside structured content
329
+ // Process structured format first: <p><s><r>text</r></s></p>
330
330
  // Handle Grid3 structured format <p><s><r>text</r></s></p>
331
331
  // Can start at p, s, or r level
332
332
  const parts = [];
@@ -342,8 +342,17 @@ class GridsetProcessor extends BaseProcessor {
342
342
  }
343
343
  continue;
344
344
  }
345
- if (typeof r === 'object' && r !== null && '#text' in r) {
346
- parts.push(String(r['#text']));
345
+ if (typeof r === 'object' && r !== null) {
346
+ // Check for #text (regular text) or #cdata (CDATA sections)
347
+ if ('#text' in r) {
348
+ parts.push(String(r['#text']));
349
+ }
350
+ else if ('#cdata' in r) {
351
+ parts.push(String(r['#cdata']));
352
+ }
353
+ else {
354
+ parts.push(String(r));
355
+ }
347
356
  }
348
357
  else {
349
358
  parts.push(String(r));
@@ -396,7 +405,15 @@ class GridsetProcessor extends BaseProcessor {
396
405
  }
397
406
  const password = this.getGridsetPassword(filePathOrBuffer);
398
407
  const entries = getZipEntriesFromAdapter(zipResult.zip, password);
399
- const parser = new XMLParser({ ignoreAttributes: false });
408
+ const options = {
409
+ ignoreAttributes: false,
410
+ ignoreDeclaration: true,
411
+ parseTagValue: false,
412
+ trimValues: false,
413
+ textNodeName: '#text',
414
+ cdataProp: '#cdata',
415
+ };
416
+ const parser = new XMLParser(options);
400
417
  const isEncryptedArchive = typeof filePathOrBuffer === 'string' && filePathOrBuffer.toLowerCase().endsWith('.gridsetx');
401
418
  const encryptedContentPassword = this.getGridsetPassword(filePathOrBuffer);
402
419
  // Initialize metadata
@@ -634,6 +651,13 @@ class GridsetProcessor extends BaseProcessor {
634
651
  if (text) {
635
652
  const val = this.textOf(text);
636
653
  if (val) {
654
+ // Debug: log WordList items with spaces to check extraction
655
+ if (pageWordListItems.length < 3) {
656
+ console.log(`[WordList] Extracted text: "${val}" (length: ${val.length}, has spaces: ${val.includes(' ')})`);
657
+ console.log(`[WordList] Chars:`, Array.from(val)
658
+ .map((c) => `"${c}" (${c.charCodeAt(0)})`)
659
+ .join(', '));
660
+ }
637
661
  pageWordListItems.push({
638
662
  text: val,
639
663
  image: item.Image || item.image || undefined,
@@ -351,8 +351,8 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
351
351
  if (typeof val === 'number')
352
352
  return String(val);
353
353
  if (typeof val === 'object') {
354
- if ('#text' in val)
355
- return String(val['#text']);
354
+ // Don't immediately return #text - it might be whitespace alongside structured content
355
+ // Process structured format first: <p><s><r>text</r></s></p>
356
356
  // Handle Grid3 structured format <p><s><r>text</r></s></p>
357
357
  // Can start at p, s, or r level
358
358
  const parts = [];
@@ -368,8 +368,17 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
368
368
  }
369
369
  continue;
370
370
  }
371
- if (typeof r === 'object' && r !== null && '#text' in r) {
372
- parts.push(String(r['#text']));
371
+ if (typeof r === 'object' && r !== null) {
372
+ // Check for #text (regular text) or #cdata (CDATA sections)
373
+ if ('#text' in r) {
374
+ parts.push(String(r['#text']));
375
+ }
376
+ else if ('#cdata' in r) {
377
+ parts.push(String(r['#cdata']));
378
+ }
379
+ else {
380
+ parts.push(String(r));
381
+ }
373
382
  }
374
383
  else {
375
384
  parts.push(String(r));
@@ -422,7 +431,15 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
422
431
  }
423
432
  const password = this.getGridsetPassword(filePathOrBuffer);
424
433
  const entries = (0, password_1.getZipEntriesFromAdapter)(zipResult.zip, password);
425
- const parser = new fast_xml_parser_1.XMLParser({ ignoreAttributes: false });
434
+ const options = {
435
+ ignoreAttributes: false,
436
+ ignoreDeclaration: true,
437
+ parseTagValue: false,
438
+ trimValues: false,
439
+ textNodeName: '#text',
440
+ cdataProp: '#cdata',
441
+ };
442
+ const parser = new fast_xml_parser_1.XMLParser(options);
426
443
  const isEncryptedArchive = typeof filePathOrBuffer === 'string' && filePathOrBuffer.toLowerCase().endsWith('.gridsetx');
427
444
  const encryptedContentPassword = this.getGridsetPassword(filePathOrBuffer);
428
445
  // Initialize metadata
@@ -660,6 +677,13 @@ class GridsetProcessor extends baseProcessor_1.BaseProcessor {
660
677
  if (text) {
661
678
  const val = this.textOf(text);
662
679
  if (val) {
680
+ // Debug: log WordList items with spaces to check extraction
681
+ if (pageWordListItems.length < 3) {
682
+ console.log(`[WordList] Extracted text: "${val}" (length: ${val.length}, has spaces: ${val.includes(' ')})`);
683
+ console.log(`[WordList] Chars:`, Array.from(val)
684
+ .map((c) => `"${c}" (${c.charCodeAt(0)})`)
685
+ .join(', '));
686
+ }
663
687
  pageWordListItems.push({
664
688
  text: val,
665
689
  image: item.Image || item.image || undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willwade/aac-processors",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
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",