-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
HEADER.js
83 lines (77 loc) · 2.11 KB
/
HEADER.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { cache } from './src/cache';
import { config } from './src/config';
import { iMatrix, VERSION } from './src/constants';
var fabric = fabric || {
version: VERSION,
config,
cache,
iMatrix,
};
if (typeof exports !== 'undefined') {
exports.fabric = fabric;
} else if (typeof define === 'function' && define.amd) {
/* _AMD_START_ */
define([], function () {
return fabric;
});
}
/* _AMD_END_ */
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
if (
document instanceof
(typeof HTMLDocument !== 'undefined' ? HTMLDocument : Document)
) {
fabric.document = document;
} else {
fabric.document = document.implementation.createHTMLDocument('');
}
fabric.window = window;
window.fabric = fabric;
} else {
// assume we're running under node.js when document/window are not present
var jsdom = require('jsdom');
var virtualWindow = new jsdom.JSDOM(
decodeURIComponent(
'%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E'
),
{
features: {
FetchExternalResources: ['img'],
},
resources: 'usable',
}
).window;
fabric.document = virtualWindow.document;
fabric.jsdomImplForWrapper =
require('jsdom/lib/jsdom/living/generated/utils').implForWrapper;
fabric.nodeCanvas = require('jsdom/lib/jsdom/utils').Canvas;
fabric.window = virtualWindow;
global.DOMParser = fabric.window.DOMParser;
}
/**
* True when in environment that supports touch events
* @type boolean
*/
fabric.isTouchSupported =
'ontouchstart' in fabric.window ||
'ontouchstart' in fabric.document ||
(fabric.window &&
fabric.window.navigator &&
fabric.window.navigator.maxTouchPoints > 0);
/**
* True when in environment that's probably Node.js
* @type boolean
*/
fabric.isLikelyNode =
typeof Buffer !== 'undefined' && typeof window === 'undefined';
/**
* @todo move to config when window is exported
*/
config.configure({
devicePixelRatio:
fabric.window.devicePixelRatio ||
fabric.window.webkitDevicePixelRatio ||
fabric.window.mozDevicePixelRatio ||
1,
});
export { fabric };