Blame view

node_modules/zrender/lib/core/env.js 2.53 KB
bd028579   易尊强   2/28
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
  var Browser = (function () {
      function Browser() {
          this.firefox = false;
          this.ie = false;
          this.edge = false;
          this.newEdge = false;
          this.weChat = false;
      }
      return Browser;
  }());
  var Env = (function () {
      function Env() {
          this.browser = new Browser();
          this.node = false;
          this.wxa = false;
          this.worker = false;
          this.svgSupported = false;
          this.touchEventsSupported = false;
          this.pointerEventsSupported = false;
          this.domSupported = false;
          this.transformSupported = false;
          this.transform3dSupported = false;
          this.hasGlobalWindow = typeof window !== 'undefined';
      }
      return Env;
  }());
  var env = new Env();
  if (typeof wx === 'object' && typeof wx.getSystemInfoSync === 'function') {
      env.wxa = true;
      env.touchEventsSupported = true;
  }
  else if (typeof document === 'undefined' && typeof self !== 'undefined') {
      env.worker = true;
  }
  else if (typeof navigator === 'undefined'
      || navigator.userAgent.indexOf('Node.js') === 0) {
      env.node = true;
      env.svgSupported = true;
  }
  else {
      detect(navigator.userAgent, env);
  }
  function detect(ua, env) {
      var browser = env.browser;
      var firefox = ua.match(/Firefox\/([\d.]+)/);
      var ie = ua.match(/MSIE\s([\d.]+)/)
          || ua.match(/Trident\/.+?rv:(([\d.]+))/);
      var edge = ua.match(/Edge?\/([\d.]+)/);
      var weChat = (/micromessenger/i).test(ua);
      if (firefox) {
          browser.firefox = true;
          browser.version = firefox[1];
      }
      if (ie) {
          browser.ie = true;
          browser.version = ie[1];
      }
      if (edge) {
          browser.edge = true;
          browser.version = edge[1];
          browser.newEdge = +edge[1].split('.')[0] > 18;
      }
      if (weChat) {
          browser.weChat = true;
      }
      env.svgSupported = typeof SVGRect !== 'undefined';
      env.touchEventsSupported = 'ontouchstart' in window && !browser.ie && !browser.edge;
      env.pointerEventsSupported = 'onpointerdown' in window
          && (browser.edge || (browser.ie && +browser.version >= 11));
      env.domSupported = typeof document !== 'undefined';
      var style = document.documentElement.style;
      env.transform3dSupported = ((browser.ie && 'transition' in style)
          || browser.edge
          || (('WebKitCSSMatrix' in window) && ('m11' in new WebKitCSSMatrix()))
          || 'MozPerspective' in style)
          && !('OTransition' in style);
      env.transformSupported = env.transform3dSupported
          || (browser.ie && +browser.version >= 9);
  }
  export default env;