forked from paperjs/paper.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
export.js
52 lines (48 loc) · 1.86 KB
/
export.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
* https://paperjs.org/
*
* Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
* https://juerglehni.com/ & https://puckey.studio/
*
* Distributed under the MIT license. See LICENSE file for details.
*
* All rights reserved.
*/
// First add Base and a couple of other objects that are not automatically
// exported to exports (Numerical, Key, etc), then inject all exports into
// PaperScope, and create the initial paper object, all in one statement:
// NOTE: Do not create local variable `var paper` since it would shield the
// global one in the whole scope.
var paper = new (PaperScope.inject(Base.exports, {
Base: Base,
Numerical: Numerical,
Key: Key,
DomEvent: DomEvent,
DomElement: DomElement,
// Export jsdom document and window too, for Node.js
document: document,
window: window,
// TODO: Remove in 1.0.0? (deprecated January 2016):
Symbol: SymbolDefinition,
PlacedSymbol: SymbolItem
}))();
// If we're on node, require some additional functionality now before finishing:
// - PaperScript support in require() with sourceMaps
// - exportFrames / exportImage on CanvasView
if (paper.agent.node) {
require('./node/extend.js')(paper);
}
// https://github.com/umdjs/umd
if (typeof define === 'function' && define.amd) {
// Support AMD (e.g. require.js)
// Use named module AMD syntax since there are other unnamed calls to
// define() inside the built library (from inlined Acorn / Esprima) that
// apparently confuse the require.js optimizer.
define('paper', paper);
} else if (typeof module === 'object' && module) { // could be `null`
// Support CommonJS module
// NOTE: Do not check typeof module.exports === 'object' since it will be
// the Base constructor function after straps.js is included.
module.exports = paper;
}