Further refine Node.js integration.

This commit is contained in:
Jürg Lehni 2013-05-09 16:06:45 -07:00
parent 82b9cb3dbf
commit dd96d67fe1
4 changed files with 9 additions and 7 deletions

View file

@ -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);
},

View file

@ -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'

View file

@ -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;

View file

@ -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