mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
Prebuilt module for commit 7a2ccc6d44
This commit is contained in:
parent
2eab976f10
commit
4e17d56175
10 changed files with 90 additions and 77 deletions
5
dist/docs/assets/js/paper.js
vendored
5
dist/docs/assets/js/paper.js
vendored
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Date: Sun Mar 19 14:50:59 2017 +0100
|
* Date: Sun Mar 19 16:03:29 2017 +0100
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
@ -32,8 +32,7 @@
|
||||||
|
|
||||||
var paper = function(self, undefined) {
|
var paper = function(self, undefined) {
|
||||||
|
|
||||||
self = self || require('./node/window.js');
|
self = self || require('./node/self.js');
|
||||||
|
|
||||||
var window = self.window,
|
var window = self.window,
|
||||||
document = self.document;
|
document = self.document;
|
||||||
|
|
||||||
|
|
8
dist/node/canvas.js
vendored
8
dist/node/canvas.js
vendored
|
@ -15,7 +15,7 @@
|
||||||
// - Various Node Canvas methods, routed through from HTMLCanvasElement:
|
// - Various Node Canvas methods, routed through from HTMLCanvasElement:
|
||||||
// toBuffer, pngStream, createPNGStream, jpgStream, createJPGStream
|
// toBuffer, pngStream, createPNGStream, jpgStream, createJPGStream
|
||||||
|
|
||||||
module.exports = function(window) {
|
module.exports = function(self) {
|
||||||
var Canvas;
|
var Canvas;
|
||||||
try {
|
try {
|
||||||
Canvas = require('canvas');
|
Canvas = require('canvas');
|
||||||
|
@ -25,14 +25,14 @@ module.exports = function(window) {
|
||||||
// - On the browser, this corresponds to a worker context.
|
// - On the browser, this corresponds to a worker context.
|
||||||
// - On Node.js, it basically means the canvas is missing or not working
|
// - On Node.js, it basically means the canvas is missing or not working
|
||||||
// which can be treated the same way.
|
// which can be treated the same way.
|
||||||
delete window.window;
|
delete self.window;
|
||||||
console.info(
|
console.info(
|
||||||
'Unable to load Canvas module. Running in a headless context.');
|
'Canvas module not found, running in a headless context.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var idlUtils = require('jsdom/lib/jsdom/living/generated/utils'),
|
var idlUtils = require('jsdom/lib/jsdom/living/generated/utils'),
|
||||||
HTMLCanvasElement = window.HTMLCanvasElement;
|
HTMLCanvasElement = self.HTMLCanvasElement;
|
||||||
|
|
||||||
// Add fake HTMLCanvasElement#type property:
|
// Add fake HTMLCanvasElement#type property:
|
||||||
Object.defineProperty(HTMLCanvasElement.prototype, 'type', {
|
Object.defineProperty(HTMLCanvasElement.prototype, 'type', {
|
||||||
|
|
4
dist/node/extend.js
vendored
4
dist/node/extend.js
vendored
|
@ -57,8 +57,8 @@ module.exports = function(paper) {
|
||||||
paper.PaperScope.inject({
|
paper.PaperScope.inject({
|
||||||
createCanvas: function(width, height, type) {
|
createCanvas: function(width, height, type) {
|
||||||
// Do not use CanvasProvider.getCanvas(), since we may be changing
|
// Do not use CanvasProvider.getCanvas(), since we may be changing
|
||||||
// the underlying node-canvas and don't want to release it after
|
// the underlying node-canvas when requesting PDF support, and don't
|
||||||
// back into the pool.
|
// want to release it after back into the pool.
|
||||||
var canvas = paper.document.createElement('canvas');
|
var canvas = paper.document.createElement('canvas');
|
||||||
canvas.width = width;
|
canvas.width = width;
|
||||||
canvas.height = height;
|
canvas.height = height;
|
||||||
|
|
73
dist/node/self.js
vendored
Normal file
73
dist/node/self.js
vendored
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
||||||
|
* http://paperjs.org/
|
||||||
|
*
|
||||||
|
* Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
|
||||||
|
* http://scratchdisk.com/ & http://jonathanpuckey.com/
|
||||||
|
*
|
||||||
|
* Distributed under the MIT license. See LICENSE file for details.
|
||||||
|
*
|
||||||
|
* All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Node.js emulation layer of browser environment, based on jsdom with node-
|
||||||
|
// canvas integration.
|
||||||
|
|
||||||
|
var self;
|
||||||
|
|
||||||
|
try {
|
||||||
|
var jsdom = require('jsdom');
|
||||||
|
|
||||||
|
// Create our document and window objects through jsdom.
|
||||||
|
/* global document:true, window:true */
|
||||||
|
var document = jsdom.jsdom('<html><body></body></html>', {
|
||||||
|
// Use the current working directory as the document's origin, so
|
||||||
|
// requests to local files work correctly with CORS.
|
||||||
|
url: 'file://' + process.cwd() + '/',
|
||||||
|
features: {
|
||||||
|
FetchExternalResources: ['img', 'script']
|
||||||
|
}
|
||||||
|
});
|
||||||
|
self = document.defaultView;
|
||||||
|
|
||||||
|
require('./canvas.js')(self);
|
||||||
|
|
||||||
|
// Define XMLSerializer shim, to emulate browser behavior.
|
||||||
|
// Effort to bring XMLSerializer to jsdom:
|
||||||
|
// https://github.com/tmpvar/jsdom/issues/1368
|
||||||
|
/*jshint -W082 */
|
||||||
|
function XMLSerializer() {
|
||||||
|
}
|
||||||
|
|
||||||
|
XMLSerializer.prototype.serializeToString = function(node) {
|
||||||
|
if (!node)
|
||||||
|
return '';
|
||||||
|
// Fix a jsdom issue where all SVG tagNames are lowercased:
|
||||||
|
// https://github.com/tmpvar/jsdom/issues/620
|
||||||
|
var text = node.outerHTML,
|
||||||
|
tagNames = ['linearGradient', 'radialGradient', 'clipPath',
|
||||||
|
'textPath'];
|
||||||
|
for (var i = 0, l = tagNames.length; i < l; i++) {
|
||||||
|
var tagName = tagNames[i];
|
||||||
|
text = text.replace(
|
||||||
|
new RegExp('(<|</)' + tagName.toLowerCase() + '\\b', 'g'),
|
||||||
|
function(match, start) {
|
||||||
|
return start + tagName;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.XMLSerializer = XMLSerializer;
|
||||||
|
} catch(e) {
|
||||||
|
console.info(
|
||||||
|
'JSDom module not found, running in a headless context without DOM.');
|
||||||
|
self = {
|
||||||
|
navigator: {
|
||||||
|
userAgent: 'Node.js (' + process.platform + '; U; rv:' +
|
||||||
|
process.version + ')'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = self;
|
57
dist/node/window.js
vendored
57
dist/node/window.js
vendored
|
@ -1,57 +0,0 @@
|
||||||
/*
|
|
||||||
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
|
||||||
* http://paperjs.org/
|
|
||||||
*
|
|
||||||
* Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
|
|
||||||
* http://scratchdisk.com/ & http://jonathanpuckey.com/
|
|
||||||
*
|
|
||||||
* Distributed under the MIT license. See LICENSE file for details.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Node.js emulation layer of browser environment, based on jsdom with node-
|
|
||||||
// canvas integration.
|
|
||||||
|
|
||||||
var jsdom = require('jsdom');
|
|
||||||
|
|
||||||
// Create our document and window objects through jsdom.
|
|
||||||
/* global document:true, window:true */
|
|
||||||
var document = jsdom.jsdom('<html><body></body></html>', {
|
|
||||||
// Use the current working directory as the document's origin, so
|
|
||||||
// requests to local files work correctly with CORS.
|
|
||||||
url: 'file://' + process.cwd() + '/',
|
|
||||||
features: {
|
|
||||||
FetchExternalResources: ['img', 'script']
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
window = document.defaultView;
|
|
||||||
|
|
||||||
require('./canvas.js')(window);
|
|
||||||
|
|
||||||
// Define XMLSerializer and DOMParser shims, to emulate browser behavior.
|
|
||||||
// Effort to bring this to jsdom: https://github.com/tmpvar/jsdom/issues/1368
|
|
||||||
function XMLSerializer() {
|
|
||||||
}
|
|
||||||
|
|
||||||
XMLSerializer.prototype.serializeToString = function(node) {
|
|
||||||
if (!node)
|
|
||||||
return '';
|
|
||||||
var text = node.outerHTML;
|
|
||||||
// Fix a jsdom issue where all SVG tagNames are lowercased:
|
|
||||||
// https://github.com/tmpvar/jsdom/issues/620
|
|
||||||
var tagNames = ['linearGradient', 'radialGradient', 'clipPath', 'textPath'];
|
|
||||||
for (var i = 0, l = tagNames.length; i < l; i++) {
|
|
||||||
var tagName = tagNames[i];
|
|
||||||
text = text.replace(
|
|
||||||
new RegExp('(<|</)' + tagName.toLowerCase() + '\\b', 'g'),
|
|
||||||
function(match, start) {
|
|
||||||
return start + tagName;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return text;
|
|
||||||
};
|
|
||||||
|
|
||||||
window.XMLSerializer = XMLSerializer;
|
|
||||||
|
|
||||||
module.exports = window;
|
|
5
dist/paper-core.js
vendored
5
dist/paper-core.js
vendored
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Date: Sun Mar 19 14:50:59 2017 +0100
|
* Date: Sun Mar 19 16:03:29 2017 +0100
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
@ -32,8 +32,7 @@
|
||||||
|
|
||||||
var paper = function(self, undefined) {
|
var paper = function(self, undefined) {
|
||||||
|
|
||||||
self = self || require('./node/window.js');
|
self = self || require('./node/self.js');
|
||||||
|
|
||||||
var window = self.window,
|
var window = self.window,
|
||||||
document = self.document;
|
document = self.document;
|
||||||
|
|
||||||
|
|
4
dist/paper-core.min.js
vendored
4
dist/paper-core.min.js
vendored
File diff suppressed because one or more lines are too long
5
dist/paper-full.js
vendored
5
dist/paper-full.js
vendored
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Date: Sun Mar 19 14:50:59 2017 +0100
|
* Date: Sun Mar 19 16:03:29 2017 +0100
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
@ -32,8 +32,7 @@
|
||||||
|
|
||||||
var paper = function(self, undefined) {
|
var paper = function(self, undefined) {
|
||||||
|
|
||||||
self = self || require('./node/window.js');
|
self = self || require('./node/self.js');
|
||||||
|
|
||||||
var window = self.window,
|
var window = self.window,
|
||||||
document = self.document;
|
document = self.document;
|
||||||
|
|
||||||
|
|
4
dist/paper-full.min.js
vendored
4
dist/paper-full.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -80,7 +80,7 @@
|
||||||
"jsdom": false,
|
"jsdom": false,
|
||||||
"jsdom/lib/jsdom/living/generated/utils": false,
|
"jsdom/lib/jsdom/living/generated/utils": false,
|
||||||
"source-map-support": false,
|
"source-map-support": false,
|
||||||
"./dist/node/window.js": false,
|
"./dist/node/self.js": false,
|
||||||
"./dist/node/extend.js": false
|
"./dist/node/extend.js": false
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
Loading…
Reference in a new issue