소스 검색

Fixing submodules

Andrea Condoluci 9 년 전
부모
커밋
514cd473ea

+ 10 - 8
Gruntfile.js

@@ -11,8 +11,8 @@ module.exports = function (grunt) {
     // Additional manual typings:
         typings = [
             'typings/browser.d.ts',
-            'typings/vexflow.d.ts',
-            'typings/fft.d.ts'
+            'typings/vexflow.d.ts'
+            // 'typings/fft.d.ts'
         ],
     // Paths
         src = ['src/**/*.ts'],
@@ -47,10 +47,10 @@ module.exports = function (grunt) {
                 }
             },
             options: {
-                plugin: ['tsify'],
-                browserifyOptions: {
-                    standalone: 'MeasureSizeCalculator'
-                }
+                plugin: ['tsify']//,
+                // browserifyOptions: {
+                //     standalone: 'MeasureSizeCalculator'
+                // }
             }
         },
         // Uglify
@@ -60,7 +60,9 @@ module.exports = function (grunt) {
                     drop_console: true
                 },
                 banner: banner,
-                mangleProperties: true
+                mangle: true,
+                mangleProperties: true,
+                preserveComments: 'all'
             },
             my_target: {
                 files: {
@@ -105,7 +107,7 @@ module.exports = function (grunt) {
         jshint: {
             all: [
                 'Gruntfile.js', 'karma.conf.js',
-                'node_modules/karma-musicxml2js-preprocessor/package.json', 'node_modules/karma-musicxml2js-preprocessor/lib/index.js'
+                'submodules/karma-musicxml2js-preprocessor/package.json', 'submodules/karma-musicxml2js-preprocessor/lib/index.js'
             ]
         },
         // TypeScript Type Definitions

+ 2 - 1
karma.conf.js

@@ -30,7 +30,8 @@ module.exports = function (config) {
         // 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/*.xml': ['musicxml2js'],
+            'test/data/*.mxl': ['mxl2js']
         },
 
         // test results reporter to use

+ 6 - 3
package.json

@@ -27,8 +27,8 @@
         "fft": "0.2.1",
         "vexflow": "",
 
-        "chai": "",
-        "mocha": "",
+        "chai": "^3.4.1",
+        "mocha": "^2.3.4",
         "tsify": "",
         "tslint": "3.8.0",
         "typescript": "",
@@ -52,6 +52,9 @@
         "karma-mocha-reporter": "",
         "karma-chrome-launcher": "",
         "karma-firefox-launcher": "",
-        "karma-phantomjs-launcher": ""
+        "karma-phantomjs-launcher": "",
+
+        "submodules/karma-musicxml2js-preprocessor": "",
+        "submodules/karma-mxl2js-preprocessor": ""
     }
 }

+ 12 - 4
src/MusicalScore/Calculation/MeasureSizeCalculator.ts

@@ -125,11 +125,19 @@ export class MeasureSizeCalculator {
 
 
   public static getKeySignatureBoundingBox(sig: any): Vex.Flow.BoundingBox {
+    // FIXME: Maybe use Vex.Flow.keySignature(this.keySpec);
+    let stave: Vex.Flow.Stave = sig.getStave();
     let width: number = sig.getWidth();
-    return new Vex.Flow.BoundingBox(
-        0, 0,
-        width, 0
-    );
+    let maxLine: number = 1;
+    let minLine: number = 1;
+    for (let acc of sig.accList) {
+      maxLine = Math.max(acc.line, maxLine);
+      minLine = Math.min(acc.line, minLine);
+    }
+    let y: number = sig.getStave().getYForLine(minLine);
+    let height: number = stave.getSpacingBetweenLines() * (maxLine - minLine);
+    let x: number = 0; // FIXME
+    return new Vex.Flow.BoundingBox(x, y, width, height);
   }
 
 

+ 0 - 0
node_modules/karma-musicxml2js-preprocessor/.gitattributes → submodules/karma-musicxml2js-preprocessor@/.gitattributes


+ 0 - 0
node_modules/karma-musicxml2js-preprocessor/.gitignore → submodules/karma-musicxml2js-preprocessor@/.gitignore


+ 0 - 0
node_modules/karma-musicxml2js-preprocessor/lib/index.js → submodules/karma-musicxml2js-preprocessor@/lib/index.js


+ 0 - 0
node_modules/karma-musicxml2js-preprocessor/package.json → submodules/karma-musicxml2js-preprocessor@/package.json


+ 8 - 0
submodules/karma-mxl2js-preprocessor@/.gitattributes

@@ -0,0 +1,8 @@
+# See https://help.github.com/articles/dealing-with-line-endings
+
+# By default, normalize all files to unix line endings when commiting.
+* text
+
+# Denote all files that are truly binary and should not be modified.
+*.png binary
+*.jpg binary

+ 1 - 0
submodules/karma-mxl2js-preprocessor@/.gitignore

@@ -0,0 +1 @@
+node_modules

+ 24 - 0
submodules/karma-mxl2js-preprocessor@/lib/index.js

@@ -0,0 +1,24 @@
+/*globals module*/
+var escapeString = function (str) {
+    'use strict';
+    return str.replace(/'/g, '\\\'').replace(/\r?\n/g, '\\n\' +\n    \'');
+};
+
+var createPreprocessor = function (logger, basePath) {
+    'use strict';
+    return function (content, file, done) {
+        var path = file.originalPath.replace(basePath + '/', ''),
+            filename = path;
+
+        file.path = file.path + '.js';
+        done("window.__mxl__ = window.__mxl__ || {};\nwindow.__mxl__['" +
+                filename + "'] = '" + escapeString(content) + "';\n"
+              );
+    };
+};
+
+createPreprocessor.$inject = ['logger', 'config.basePath'];
+
+module.exports = {
+    'preprocessor:mxl2js': ['factory', createPreprocessor]
+};

+ 5 - 0
submodules/karma-mxl2js-preprocessor@/package.json

@@ -0,0 +1,5 @@
+{
+  "name": "karma-mxl2js-preprocessor",
+  "version": "0.0.1",
+  "main": "lib/index.js"
+}

+ 30 - 0
test/Common/FileIO/Mxl.ts

@@ -0,0 +1,30 @@
+import {IXmlElement} from "../../../src/Common/FileIO/Xml";
+
+// typings for JSZip module
+type JSZip = any;
+declare var JSZip: any;
+
+function extractSheetFromMxl(data: string): any {
+  "use strict";
+  // let buf = Buffer.concat(data);
+  let zip: JSZip = new JSZip();
+
+  return zip.loadAsync(data).then((_: any) => {
+    return zip.file("META-INF/container.xml").async("string");
+  }).then((content: string) => {
+    let parser: DOMParser = new DOMParser();
+    let doc: Document = parser.parseFromString(content, "text/xml");
+    console.log(content);
+    // doc.Root.Element("rootfiles").Element("rootfile").Attribute("full-path").Value;
+    let rootFile: string = doc.getElementsByTagName("rootfile")[0].getAttribute("full-path");
+    return zip.file(rootFile).async("string");
+  }).then((content: string) => {
+    let parser: DOMParser = new DOMParser();
+    let doc: Document = parser.parseFromString(content, "text/xml");
+    return new IXmlElement(doc.documentElement);
+  });
+}
+
+describe("MXL Tests", () => {
+  chai.expect(extractSheetFromMxl).to.equal(extractSheetFromMxl);
+});

+ 5 - 1
tsconfig.json

@@ -1,5 +1,9 @@
 {
   "compilerOptions": {
     "target": "ES5"
-  }
+  },
+  "exclude": [
+    "node_modules",
+    "typings"
+  ]
 }