mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Properly export Numerical and PaperScript again.
This commit is contained in:
parent
e516e6f651
commit
5592bb57e0
6 changed files with 20 additions and 15 deletions
|
@ -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
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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))();
|
||||
|
|
10
src/paper.js
10
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');
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue