Browse Source

chore(package): remove es6-promise as dependency, update jszip to 3.4.0

required some build changes, because jszip now has inbuilt typescript definitions since 3.4.0,
and es6-promise.Promise was conflicting with Promise.

fixes #723
sschmid 5 years ago
parent
commit
69efa44e33

+ 2 - 3
package.json

@@ -61,9 +61,8 @@
   "homepage": "http://opensheetmusicdisplay.org",
   "dependencies": {
     "@types/vexflow": "^1.2.33",
-    "es6-promise": "^4.2.5",
     "jspdf-yworks": "^2.1.1",
-    "jszip": "3.3.0",
+    "jszip": "3.4.0",
     "loglevel": "^1.6.8",
     "svg2pdf.js": "^1.5.0",
     "typescript-collections": "^1.3.3",
@@ -80,7 +79,7 @@
     "cross-env": "^7.0.2",
     "cz-conventional-changelog": "^3.0.0",
     "eslint": "^6.8.0",
-    "eslint-config-standard": "^14.1.0",
+    "eslint-config-standard": "14.1.1",
     "eslint-plugin-import": "^2.20.2",
     "eslint-plugin-node": "^11.0.0",
     "eslint-plugin-promise": "^4.2.1",

+ 12 - 11
src/Common/FileIO/Mxl.ts

@@ -1,6 +1,5 @@
 import { IXmlElement } from "./Xml";
-import { Promise } from "es6-promise";
-import JSZip = require("jszip");
+import JSZip from "jszip";
 
 /**
  * Some helper methods to handle MXL files.
@@ -15,21 +14,23 @@ export class MXLHelper {
     public static MXLtoIXmlElement(data: string): Promise<IXmlElement> {
         // starting with jszip 3.4.0, JSZip.JSZip is not found,
         //    probably because of new possibly conflicting TypeScript definitions
-        const zip: JSZip.JSZip = new JSZip();
+        const zip: JSZip = new JSZip();
         // asynchronously load zip file and process it - with Promises
-        return zip.loadAsync(data).then(
-            (_: any) => {
-                return zip.file("META-INF/container.xml").async("string");
+        const zipLoadedAsync: Promise<JSZip> = zip.loadAsync(data);
+        const text: Promise<string> = zipLoadedAsync.then(
+            (_: JSZip) => {
+                return zip.file("META-INF/container.xml").async("text");
             },
             (err: any) => {
                 throw err;
             }
-        ).then(
+        );
+        return text.then(
             (content: string) => {
                 const parser: DOMParser = new DOMParser();
                 const doc: Document = parser.parseFromString(content, "text/xml");
                 const rootFile: string = doc.getElementsByTagName("rootfile")[0].getAttribute("full-path");
-                return zip.file(rootFile).async("string");
+                return zip.file(rootFile).async("text");
             },
             (err: any) => {
                 throw err;
@@ -55,11 +56,11 @@ export class MXLHelper {
     }
 
     public static MXLtoXMLstring(data: string): Promise<string> {
-        const zip:  JSZip.JSZip = new JSZip();
+        const zip:  JSZip = new JSZip();
         // asynchronously load zip file and process it - with Promises
         return zip.loadAsync(data).then(
             (_: any) => {
-                return zip.file("META-INF/container.xml").async("string");
+                return zip.file("META-INF/container.xml").async("text");
             },
             (err: any) => {
                 throw err;
@@ -69,7 +70,7 @@ export class MXLHelper {
                 const parser: DOMParser = new DOMParser();
                 const doc: Document = parser.parseFromString(content, "text/xml");
                 const rootFile: string = doc.getElementsByTagName("rootfile")[0].getAttribute("full-path");
-                return zip.file(rootFile).async("string");
+                return zip.file(rootFile).async("text");
             },
             (err: any) => {
                 throw err;

+ 0 - 2
src/OpenSheetMusicDisplay/AJAX.ts

@@ -1,5 +1,3 @@
-import {Promise} from "es6-promise";
-
 /**
  * Class with helper methods to handle asynchronous JavaScript requests
  */

+ 0 - 1
src/OpenSheetMusicDisplay/OpenSheetMusicDisplay.ts

@@ -10,7 +10,6 @@ import { CanvasVexFlowBackend } from "./../MusicalScore/Graphical/VexFlow/Canvas
 import { MusicSheet } from "./../MusicalScore/MusicSheet";
 import { Cursor } from "./Cursor";
 import { MXLHelper } from "../Common/FileIO/Mxl";
-import { Promise } from "es6-promise";
 import { AJAX } from "./AJAX";
 import log from "loglevel";
 import { DrawingParametersEnum, DrawingParameters, ColoringModes } from "../MusicalScore/Graphical/DrawingParameters";