mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Further refine Node.js integration.
This commit is contained in:
parent
82b9cb3dbf
commit
dd96d67fe1
4 changed files with 9 additions and 7 deletions
|
@ -332,7 +332,7 @@ var Base = new function() { // Bootstrap scope
|
|||
*/
|
||||
isPlainObject: function(obj) {
|
||||
var proto = obj !== null && typeof obj === 'object'
|
||||
&& Object.getPrototypeOf(obj);
|
||||
&& Object.getPrototypeOf(obj);
|
||||
return proto && (proto === Object.prototype
|
||||
|| proto === Base.prototype);
|
||||
},
|
||||
|
|
|
@ -20,5 +20,5 @@ Base.each(this, function(val, key) {
|
|||
// See paper.js for the non-dev version of this code. We cannot handle dev there
|
||||
// due to the seperate loading of all source files, which are only availabe
|
||||
// after the execution of paper.js
|
||||
paper = new PaperScope();
|
||||
var paper = new PaperScope();
|
||||
/*#*/ } // options.version == 'dev'
|
||||
|
|
|
@ -87,8 +87,6 @@ var context = vm.createContext({
|
|||
|
||||
// Load Paper.js library files:
|
||||
context.include('paper.js');
|
||||
// Fix version now. Remove 2nd dot, so we can make a float out of it:
|
||||
options.version = parseFloat(json.version.replace(/(.)(\d)$/, '$2'));
|
||||
|
||||
// Since the context used for Paper.js compilation, and the context in which
|
||||
// Node.js scripts are executed do not share the definition of Object, we need
|
||||
|
@ -109,7 +107,9 @@ Base.isPlainObject = function(obj) {
|
|||
Base.each({
|
||||
Canvas: Canvas,
|
||||
XMLSerializer: XMLSerializer,
|
||||
DOMParser: DOMParser
|
||||
DOMParser: DOMParser,
|
||||
// Also fix version. Remove 2nd dot, so we can make a float out of it:
|
||||
version: parseFloat(json.version.replace(/(.)(\d)$/, '$2'))
|
||||
}, function(value, key) {
|
||||
this[key] = value;
|
||||
}, context.PaperScope.prototype);
|
||||
|
@ -125,4 +125,4 @@ require.extensions['.pjs'] = function(module, uri) {
|
|||
module.exports = scope;
|
||||
};
|
||||
|
||||
module.exports = new context.PaperScope();
|
||||
module.exports = context.paper;
|
||||
|
|
|
@ -127,7 +127,9 @@ var paper = new function() {
|
|||
/*#*/ include('core/PaperScript.js');
|
||||
/*#*/ include('core/initialize.js');
|
||||
|
||||
/*#*/ if (options.version != 'dev') {
|
||||
/*#*/ if (options.server) {
|
||||
return paper;
|
||||
/*#*/ } else if (options.version != 'dev') {
|
||||
// Finally inject the classes set on 'this' into the PaperScope class and create
|
||||
// the first PaperScope and return it, all in one statement.
|
||||
// The version for 'dev' of this happens in core/initialize.js, since it depends
|
||||
|
|
Loading…
Reference in a new issue