@willwade/aac-processors 0.3.5 → 0.3.7

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.
@@ -69,6 +69,10 @@ export function getOs() {
69
69
  return cachedOs;
70
70
  }
71
71
  export function isNodeRuntime() {
72
+ const browserGlobals = globalThis;
73
+ if (browserGlobals.window !== undefined) {
74
+ return false;
75
+ }
72
76
  return typeof process !== 'undefined' && !!process.versions?.node;
73
77
  }
74
78
  export function getBasename(filePath) {
@@ -85,7 +85,7 @@ export class GridsetValidator extends BaseValidator {
85
85
  await this.add_check('xml_parse', 'valid XML', async () => {
86
86
  try {
87
87
  const parser = new xml2js.Parser();
88
- const contentStr = decodeText(content);
88
+ const contentStr = decodeText(content).replace(/^\uFEFF/, '');
89
89
  xmlObj = await parser.parseStringPromise(contentStr);
90
90
  }
91
91
  catch (e) {
@@ -128,7 +128,7 @@ export class GridsetValidator extends BaseValidator {
128
128
  try {
129
129
  const gridXml = await zip.readFile(entry);
130
130
  const parser = new xml2js.Parser();
131
- const xmlObj = await parser.parseStringPromise(gridXml);
131
+ const xmlObj = await parser.parseStringPromise(decodeText(toUint8Array(gridXml)).replace(/^\uFEFF/, ''));
132
132
  const grid = xmlObj.Grid || xmlObj.grid;
133
133
  if (!grid) {
134
134
  this.err(`${entry}: missing root <Grid> element`);
@@ -152,7 +152,7 @@ export class GridsetValidator extends BaseValidator {
152
152
  try {
153
153
  const settingsXml = await zip.readFile(settingsEntry);
154
154
  const parser = new xml2js.Parser();
155
- const xmlObj = await parser.parseStringPromise(settingsXml);
155
+ const xmlObj = await parser.parseStringPromise(decodeText(toUint8Array(settingsXml)).replace(/^\uFEFF/, ''));
156
156
  const settings = xmlObj.GridSetSettings || xmlObj.gridSetSettings || xmlObj.GridsetSettings;
157
157
  if (!settings) {
158
158
  this.warn('Invalid settings.xml structure');
package/dist/utils/io.js CHANGED
@@ -83,6 +83,10 @@ function getOs() {
83
83
  return cachedOs;
84
84
  }
85
85
  function isNodeRuntime() {
86
+ const browserGlobals = globalThis;
87
+ if (browserGlobals.window !== undefined) {
88
+ return false;
89
+ }
86
90
  return typeof process !== 'undefined' && !!process.versions?.node;
87
91
  }
88
92
  function getBasename(filePath) {
@@ -111,7 +111,7 @@ class GridsetValidator extends baseValidator_1.BaseValidator {
111
111
  await this.add_check('xml_parse', 'valid XML', async () => {
112
112
  try {
113
113
  const parser = new xml2js.Parser();
114
- const contentStr = (0, io_1.decodeText)(content);
114
+ const contentStr = (0, io_1.decodeText)(content).replace(/^\uFEFF/, '');
115
115
  xmlObj = await parser.parseStringPromise(contentStr);
116
116
  }
117
117
  catch (e) {
@@ -154,7 +154,7 @@ class GridsetValidator extends baseValidator_1.BaseValidator {
154
154
  try {
155
155
  const gridXml = await zip.readFile(entry);
156
156
  const parser = new xml2js.Parser();
157
- const xmlObj = await parser.parseStringPromise(gridXml);
157
+ const xmlObj = await parser.parseStringPromise((0, io_1.decodeText)((0, io_1.toUint8Array)(gridXml)).replace(/^\uFEFF/, ''));
158
158
  const grid = xmlObj.Grid || xmlObj.grid;
159
159
  if (!grid) {
160
160
  this.err(`${entry}: missing root <Grid> element`);
@@ -178,7 +178,7 @@ class GridsetValidator extends baseValidator_1.BaseValidator {
178
178
  try {
179
179
  const settingsXml = await zip.readFile(settingsEntry);
180
180
  const parser = new xml2js.Parser();
181
- const xmlObj = await parser.parseStringPromise(settingsXml);
181
+ const xmlObj = await parser.parseStringPromise((0, io_1.decodeText)((0, io_1.toUint8Array)(settingsXml)).replace(/^\uFEFF/, ''));
182
182
  const settings = xmlObj.GridSetSettings || xmlObj.gridSetSettings || xmlObj.GridsetSettings;
183
183
  if (!settings) {
184
184
  this.warn('Invalid settings.xml structure');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willwade/aac-processors",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
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",