mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Fix Node.js support.
This commit is contained in:
parent
cbba321977
commit
7247c1a5a2
4 changed files with 5 additions and 7 deletions
1
index.js
1
index.js
|
@ -1 +0,0 @@
|
|||
module.exports = require('./src/loadNode.js');
|
|
@ -1,9 +1,7 @@
|
|||
var fs = require('fs'),
|
||||
vm = require('vm'),
|
||||
path = require('path'),
|
||||
// Have HTMLCanvasElement reference Canvas too, so we do not handle browser
|
||||
// and server differently in some places of our code.
|
||||
Canvas = HTMLCanvasElement =require('canvas');
|
||||
Canvas = require('canvas');
|
||||
|
||||
__dirname = path.resolve(__dirname, '../src/');
|
||||
|
||||
|
@ -16,6 +14,7 @@ var context = vm.createContext({
|
|||
fs: fs,
|
||||
// Node Canvas library: https://github.com/learnboost/node-canvas
|
||||
Canvas: Canvas,
|
||||
HTMLCanvasElement: Canvas,
|
||||
Image: Canvas.Image,
|
||||
// Copy over global variables:
|
||||
console: console,
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
"keywords": ["canvas", "graphic", "graphics", "vector", "paper.js"],
|
||||
"repository": "git://github.com/paperjs/paper.js/",
|
||||
"dependencies": {
|
||||
"canvas": "0.7.0"
|
||||
"canvas": ">= 0.7.0"
|
||||
},
|
||||
"engines": { "node": ">= 0.4.0 && < 0.6.0" },
|
||||
"engines": { "node": ">= 0.4.0" },
|
||||
"main": "./node.js/index.js"
|
||||
}
|
|
@ -155,7 +155,7 @@ var PaperScript = this.PaperScript = new function() {
|
|||
function evaluate(code, scope) {
|
||||
// Set currently active scope.
|
||||
paper = scope;
|
||||
var view = scope.project.view,
|
||||
var view = scope.project && scope.project.view,
|
||||
res;
|
||||
// Define variables for potential handlers, so eval() calls below to
|
||||
// fetch their values do not require try-catch around them.
|
||||
|
|
Loading…
Reference in a new issue