frmatthew / exsurge

A JavaScript library for rendering Gregorian Chant in square note notation
MIT License
54 stars 13 forks source link

exsurge.js isn't working #74

Closed SirPL closed 8 years ago

SirPL commented 8 years ago

I don't know what had happend, but https://ex.surge.sh/exsurge.js stopped working. It produces following error:

Uncaught TypeError: score.createDrawable is not a function
    (anonymous function) @ 20:189
    layoutChantLines     @ Exsurge.Chant.js:550
    (anonymous function) @ 20:188
    (anonymous function) @ Exsurge.Chant.js:495

My code:

179 <script>
180 function genChant(div_id, gabcSource) {
181   var ctxt = new exsurge.ChantContext();
182   ctxt.lyricTextFont = "'Droid', 'Georgia', 'Times New Roman', 'Times', serif";
183   ctxt.lyricTextSize *= 1.2;
184   var mapping = exsurge.Gabc.createMappingsFromSource(ctxt, gabcSource);
185   var chantContainer = document.getElementById(div_id);
186   var score = new exsurge.ChantScore(ctxt, mapping, false);
187   score.performLayoutAsync(ctxt, function(){
188     score.layoutChantLines(ctxt, chantContainer.offsetWidth, function() {
189         chantContainer.innerHTML = score.createDrawable(ctxt);
190     })
191   });
192 }
193 </script>

Any idea what's wrong?

frmatthew commented 8 years ago

Yes, my apologies, yesterday I pushed a change that revised the drawing code...in the process createDrawable was renamed to createSvg. If you change that in your code you should be working again. I always regret making changes that break the API, but since this is 0.0 version software, it's just part of the dev process!

If this fixes your problem I'll let you close the issue, otherwise let me know if you're still having problems.

SirPL commented 8 years ago

Well. The dev version is now working, but minified is not. It produces following error:

Exsurge.Chant.js:506
     Uncaught TypeError: Cannot read property 'needsLayout' of undefined
frmatthew commented 8 years ago

OK, I've disabled name mangling in UglifyJS so that the minified versions work for now. Without mangling the size of the lib is a little larger...eventually a better solution would be to determine why name mangling stopped working and only disable mangling for those classes/functions/objects that need the right names (e.g., anything created dynamically in the Gabc code probably needs mangling disabled).