musicxml-io 0.5.3 → 0.5.4

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.
package/dist/index.js CHANGED
@@ -2760,6 +2760,15 @@ function parseCompressed(data) {
2760
2760
  function isCompressed(data) {
2761
2761
  return data.length >= 2 && data[0] === 80 && data[1] === 75;
2762
2762
  }
2763
+ function decodeXmlBytes(data) {
2764
+ if (data.length >= 2 && data[0] === 254 && data[1] === 255) {
2765
+ return new TextDecoder("utf-16be").decode(data);
2766
+ }
2767
+ if (data.length >= 2 && data[0] === 255 && data[1] === 254) {
2768
+ return new TextDecoder("utf-16le").decode(data);
2769
+ }
2770
+ return new TextDecoder("utf-8").decode(data);
2771
+ }
2763
2772
  function parseAuto(data) {
2764
2773
  if (typeof data === "string") {
2765
2774
  return parse(data);
@@ -2767,7 +2776,7 @@ function parseAuto(data) {
2767
2776
  if (isCompressed(data)) {
2768
2777
  return parseCompressed(data);
2769
2778
  }
2770
- const xmlString = _fflate.strFromU8.call(void 0, data);
2779
+ const xmlString = decodeXmlBytes(data);
2771
2780
  return parse(xmlString);
2772
2781
  }
2773
2782
 
@@ -7875,10 +7884,10 @@ async function parseFile(filePath) {
7875
7884
  }
7876
7885
  function decodeBuffer(buffer) {
7877
7886
  if (buffer.length >= 2 && buffer[0] === 254 && buffer[1] === 255) {
7878
- return buffer.swap16().toString("utf-16le");
7887
+ return new TextDecoder("utf-16be").decode(buffer);
7879
7888
  }
7880
7889
  if (buffer.length >= 2 && buffer[0] === 255 && buffer[1] === 254) {
7881
- return buffer.toString("utf16le");
7890
+ return new TextDecoder("utf-16le").decode(buffer);
7882
7891
  }
7883
7892
  if (buffer.length >= 3 && buffer[0] === 239 && buffer[1] === 187 && buffer[2] === 191) {
7884
7893
  return buffer.toString("utf8", 3);
package/dist/index.mjs CHANGED
@@ -2760,6 +2760,15 @@ function parseCompressed(data) {
2760
2760
  function isCompressed(data) {
2761
2761
  return data.length >= 2 && data[0] === 80 && data[1] === 75;
2762
2762
  }
2763
+ function decodeXmlBytes(data) {
2764
+ if (data.length >= 2 && data[0] === 254 && data[1] === 255) {
2765
+ return new TextDecoder("utf-16be").decode(data);
2766
+ }
2767
+ if (data.length >= 2 && data[0] === 255 && data[1] === 254) {
2768
+ return new TextDecoder("utf-16le").decode(data);
2769
+ }
2770
+ return new TextDecoder("utf-8").decode(data);
2771
+ }
2763
2772
  function parseAuto(data) {
2764
2773
  if (typeof data === "string") {
2765
2774
  return parse(data);
@@ -2767,7 +2776,7 @@ function parseAuto(data) {
2767
2776
  if (isCompressed(data)) {
2768
2777
  return parseCompressed(data);
2769
2778
  }
2770
- const xmlString = strFromU8(data);
2779
+ const xmlString = decodeXmlBytes(data);
2771
2780
  return parse(xmlString);
2772
2781
  }
2773
2782
 
@@ -7875,10 +7884,10 @@ async function parseFile(filePath) {
7875
7884
  }
7876
7885
  function decodeBuffer(buffer) {
7877
7886
  if (buffer.length >= 2 && buffer[0] === 254 && buffer[1] === 255) {
7878
- return buffer.swap16().toString("utf-16le");
7887
+ return new TextDecoder("utf-16be").decode(buffer);
7879
7888
  }
7880
7889
  if (buffer.length >= 2 && buffer[0] === 255 && buffer[1] === 254) {
7881
- return buffer.toString("utf16le");
7890
+ return new TextDecoder("utf-16le").decode(buffer);
7882
7891
  }
7883
7892
  if (buffer.length >= 3 && buffer[0] === 239 && buffer[1] === 187 && buffer[2] === 191) {
7884
7893
  return buffer.toString("utf8", 3);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musicxml-io",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Parse and serialize MusicXML (.xml/.mxl) and ABC notation with high round-trip fidelity",
5
5
  "author": "tan-z-tan",
6
6
  "license": "MIT",