mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-23 07:49:48 -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
|
@ -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
|
// 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
|
// due to the seperate loading of all source files, which are only availabe
|
||||||
// after the execution of paper.js
|
// after the execution of paper.js
|
||||||
paper = new PaperScope();
|
var paper = new PaperScope();
|
||||||
/*#*/ } // options.version == 'dev'
|
/*#*/ } // options.version == 'dev'
|
||||||
|
|
|
@ -87,8 +87,6 @@ var context = vm.createContext({
|
||||||
|
|
||||||
// Load Paper.js library files:
|
// Load Paper.js library files:
|
||||||
context.include('paper.js');
|
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
|
// 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
|
// Node.js scripts are executed do not share the definition of Object, we need
|
||||||
|
@ -109,7 +107,9 @@ Base.isPlainObject = function(obj) {
|
||||||
Base.each({
|
Base.each({
|
||||||
Canvas: Canvas,
|
Canvas: Canvas,
|
||||||
XMLSerializer: XMLSerializer,
|
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) {
|
}, function(value, key) {
|
||||||
this[key] = value;
|
this[key] = value;
|
||||||
}, context.PaperScope.prototype);
|
}, context.PaperScope.prototype);
|
||||||
|
@ -125,4 +125,4 @@ require.extensions['.pjs'] = function(module, uri) {
|
||||||
module.exports = scope;
|
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/PaperScript.js');
|
||||||
/*#*/ include('core/initialize.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
|
// Finally inject the classes set on 'this' into the PaperScope class and create
|
||||||
// the first PaperScope and return it, all in one statement.
|
// the first PaperScope and return it, all in one statement.
|
||||||
// The version for 'dev' of this happens in core/initialize.js, since it depends
|
// The version for 'dev' of this happens in core/initialize.js, since it depends
|
||||||
|
|
Loading…
Reference in a new issue