diff --git a/src/core/Base.js b/src/core/Base.js index 475211e3..b250abc3 100644 --- a/src/core/Base.js +++ b/src/core/Base.js @@ -82,16 +82,15 @@ Base.inject(/** @lends Base# */{ // Keep track of all named classes for serialization and exporting. // Also register the Base class itself. - _classes: { 'Base': Base }, + exports: { 'Base': Base }, extend: function extend(src) { - // Override Base.extend() with a version that registers classes that - // define #_class inside the Base._classes lookup, for - // deserialization. + // Override Base.extend() to register named classes in Base.exports, + // for deserialization and injection into PaperScope. var res = extend.base.apply(this, arguments), name = res.name; if (name) - Base._classes[name] = res; + Base.exports[name] = res; return res; }, @@ -337,7 +336,7 @@ Base.inject(/** @lends Base# */{ /** * Deserializes from parsed JSON data. A simple convention is followed: * Array values with a string at the first position are links to - * deserializable types through Base._classes, and the values following + * deserializable types through Base.exports, and the values following * in the array are the arguments to their initialize function. * Any other value is passed on unmodified. * The passed data is recoursively traversed and converted, leaves first @@ -361,7 +360,7 @@ Base.inject(/** @lends Base# */{ // if so return its definition instead. if (data.dictionary && obj.length == 1 && /^#/.test(type)) return data.dictionary[type]; - type = Base._classes[type]; + type = Base.exports[type]; } res = []; // Skip first type entry for arguments diff --git a/src/core/PaperScript.js b/src/core/PaperScript.js index 0c7f73a0..081c0f74 100644 --- a/src/core/PaperScript.js +++ b/src/core/PaperScript.js @@ -20,8 +20,8 @@ /*#*/ } else if (options.parser == 'esprima') { /*#*/ include('../../lib/esprima-min.js'); /*#*/ } - -var PaperScript = new function() { + +var PaperScript = Base.exports.PaperScript = new function() { // Operators to overload var binaryOperators = { diff --git a/src/export.js b/src/export.js index e09d1353..de611e34 100644 --- a/src/export.js +++ b/src/export.js @@ -11,4 +11,4 @@ */ // Export all named classes to PaperScope and create the initial paper object. -var paper = new (PaperScope.inject(Base._classes))(); +var paper = new (PaperScope.inject(Base.exports))(); diff --git a/src/paper.js b/src/paper.js index 162ae276..2b9f6c47 100644 --- a/src/paper.js +++ b/src/paper.js @@ -35,10 +35,6 @@ var paper = new function() { // Inline Bootstrap core (the Base class) inside the paper scope first: /*#*/ include('../lib/straps.js'); -/*#*/ if (options.version == 'dev') { -/*#*/ include('constants.js'); -/*#*/ } // options.version == 'dev' - /*#*/ if (options.stats) { /*#*/ include('../lib/stats.js'); /*#*/ } // options.stats @@ -48,6 +44,12 @@ var paper = new function() { /*#*/ include('core/PaperScope.js'); /*#*/ include('core/PaperScopeItem.js'); +/*#*/ if (options.version == 'dev') { +// We can only load constants after core, since Numerical.js is loaded and +// requires on Base.exports for exporting. +/*#*/ include('constants.js'); +/*#*/ } // options.version == 'dev' + /*#*/ include('util/Formatter.js'); /*#*/ include('util/Numerical.js'); diff --git a/src/path/PathItem.js b/src/path/PathItem.js index 9fe3a71b..3b7309e0 100644 --- a/src/path/PathItem.js +++ b/src/path/PathItem.js @@ -20,6 +20,10 @@ * @extends Item */ var PathItem = Item.extend(/** @lends PathItem# */{ + initialize: function PathItem() { + Item.apply(this, arguments); + }, + /** * Returns all intersections between two {@link PathItem} items as an array * of {@link CurveLocation} objects. {@link CompoundPath} items are also diff --git a/src/util/Numerical.js b/src/util/Numerical.js index db04302a..4c110b35 100644 --- a/src/util/Numerical.js +++ b/src/util/Numerical.js @@ -10,7 +10,7 @@ * All rights reserved. */ -var Numerical = new function() { +var Numerical = Base.exports.Numerical = new function() { // Lookup tables for abscissas and weights with values for n = 2 .. 16. // As values are symetric, only store half of them and addapt algorithm