mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-01 16:49:15 -04:00
Make sure the Base class is exposed in Node.js
This commit is contained in:
parent
45ab6c7676
commit
c70b985911
3 changed files with 5 additions and 9 deletions
src/node
|
@ -93,8 +93,6 @@ context.include('paper.js');
|
|||
// to redefine Base.isPlainObject() here.
|
||||
// So instead of checking for Object.prototype, we're checking
|
||||
// proto.constructor.name for 'Object'
|
||||
// TODO: Benchmark the speed and consider this implementation instead of the
|
||||
// current one in straps.js too
|
||||
var Base = context.Base;
|
||||
Base.isPlainObject = function(obj) {
|
||||
var proto = obj !== null && typeof obj === 'object'
|
||||
|
@ -103,16 +101,14 @@ Base.isPlainObject = function(obj) {
|
|||
|| proto === Base.prototype);
|
||||
};
|
||||
|
||||
// Expose the Canvas, XMLSerializer to paper scopes:
|
||||
Base.each({
|
||||
context.PaperScope.inject({
|
||||
// Expose the Canvas, XMLSerializer & DOMParser to PaperScope:
|
||||
Canvas: Canvas,
|
||||
XMLSerializer: XMLSerializer,
|
||||
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);
|
||||
});
|
||||
|
||||
require.extensions['.pjs'] = function(module, uri) {
|
||||
var source = context.PaperScript.compile(fs.readFileSync(uri, 'utf8'));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue