Andrea Condoluci 9 rokov pred
rodič
commit
fb8fb0d7f2

+ 1 - 1
Gruntfile.js

@@ -8,9 +8,9 @@ module.exports = function (grunt) {
         ' *\n' +
         ' * https://github.com/opensheetmusicdisplay/opensheetmusicdisplay\n' +
         ' */\n',
-    // Additional manual typings:
         typings = [
             'typings/browser.d.ts',
+            // Additional manual typings:
             'typings/vexflow.d.ts'
             // 'typings/fft.d.ts'
         ],

+ 4 - 1
karma.conf.js

@@ -25,13 +25,16 @@ module.exports = function (config) {
         }, {
             pattern: 'test/data/*.xml',
             included: true
+        }, {
+            pattern: 'test/data/*.mxl.str',
+            included: true
         }],
 
         // preprocess matching files before serving them to the browser
         // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
         preprocessors: {
             'test/data/*.xml': ['musicxml2js'],
-            'test/data/*.mxl': ['mxl2js']
+            'test/data/*.mxl.str': ['mxl2js']
         },
 
         // test results reporter to use

+ 1 - 1
package.json

@@ -24,7 +24,7 @@
     },
     "homepage": "http://opensheetmusicdisplay.org",
     "dependencies": {
-        "fft": "0.2.1",
+        "jszip": "",
         "vexflow": "",
 
         "chai": "^3.4.1",

+ 3 - 2
submodules/karma-mxl2js-preprocessor/lib/index.js

@@ -8,11 +8,12 @@ var createPreprocessor = function (logger, basePath) {
     'use strict';
     return function (content, file, done) {
         var path = file.originalPath.replace(basePath + '/', ''),
-            filename = path;
+            filename = path.replace('.str', '');
 
         file.path = file.path + '.js';
         done("window.__mxl__ = window.__mxl__ || {};\nwindow.__mxl__['" +
-                filename + "'] = '" + escapeString(content) + "';\n"
+                // filename + "'] = '" + escapeString(content) + "';\n"
+                filename + "'] = window.atob('" + content + "');\n"
               );
     };
 };

+ 35 - 5
test/Common/FileIO/Mxl.ts

@@ -1,13 +1,13 @@
 import {IXmlElement} from "../../../src/Common/FileIO/Xml";
-
+import JSZip = require("jszip");
 // typings for JSZip module
-type JSZip = any;
-declare var JSZip: any;
+// type JSZip = any;
+// declare var JSZip: any;
 
 function extractSheetFromMxl(data: string): any {
   "use strict";
   // let buf = Buffer.concat(data);
-  let zip: JSZip = new JSZip();
+  let zip: any = new JSZip();
 
   return zip.loadAsync(data).then((_: any) => {
     return zip.file("META-INF/container.xml").async("string");
@@ -17,14 +17,44 @@ function extractSheetFromMxl(data: string): any {
     console.log(content);
     // doc.Root.Element("rootfiles").Element("rootfile").Attribute("full-path").Value;
     let rootFile: string = doc.getElementsByTagName("rootfile")[0].getAttribute("full-path");
+    console.log("success..", rootFile);
     return zip.file(rootFile).async("string");
   }).then((content: string) => {
+    console.log("success...", content);
     let parser: DOMParser = new DOMParser();
     let doc: Document = parser.parseFromString(content, "text/xml");
+    console.log("success...", doc);
     return new IXmlElement(doc.documentElement);
+  }, (reason: any) => {
+    chai.assert.fail(0, 1, reason.message);
   });
 }
 
 describe("MXL Tests", () => {
-  chai.expect(extractSheetFromMxl).to.equal(extractSheetFromMxl);
+  // Initialize variables
+  let path: string = "test/data/MozartTrio.mxl";
+  // let score: IXmlElement;
+
+  function getSheet(filename: string): string {
+    console.log(((window as any).__mxl__));
+    return ((window as any).__mxl__)[filename];
+  }
+
+  before((): void => {
+      // Load the xml file
+      let mxl: string = getSheet(path);
+      chai.expect(mxl).to.not.be.undefined;
+      extractSheetFromMxl(mxl).then((elem: any) => {
+        console.log("success!", elem);
+      }, (reason: any) => {
+        chai.assert.fail(0, 1, reason.message);
+      });
+      // score = new IXmlElement(doc.getElementsByTagName("score-partwise")[0]);
+      // // chai.expect(score).to.not.be.undefined;
+      // sheet = reader.createMusicSheet(score, path);
+  });
+  it("Success", (done: MochaDone) => {
+    chai.expect(extractSheetFromMxl).to.equal(extractSheetFromMxl);
+    done();
+  });
 });

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
test/data/MozartTrio.mxl.str


+ 2 - 1
typings.json

@@ -1,6 +1,7 @@
 {
   "ambientDependencies": {
     "chai": "registry:dt/chai#3.4.0+20160317120654",
-    "mocha": "registry:dt/mocha#2.2.5+20160317120654"
+    "mocha": "registry:dt/mocha#2.2.5+20160317120654",
+    "jszip": "registry:dt/jszip"
   }
 }

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov