@antv/l7-map 2.5.42 → 2.5.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/es/camera.js.map +1 -1
  2. package/es/earthmap.d.ts +0 -1
  3. package/es/earthmap.js +7 -26
  4. package/es/earthmap.js.map +1 -1
  5. package/es/handler/handler_manager.js +53 -33
  6. package/es/handler/handler_manager.js.map +1 -1
  7. package/es/handler/shim/drag_pan.js +9 -2
  8. package/es/handler/shim/drag_pan.js.map +1 -1
  9. package/es/handler/shim/touch_zoom_rotate.js +9 -2
  10. package/es/handler/shim/touch_zoom_rotate.js.map +1 -1
  11. package/es/hash.d.ts +1 -2
  12. package/es/hash.js +5 -4
  13. package/es/hash.js.map +1 -1
  14. package/es/interface.d.ts +1 -0
  15. package/es/map.d.ts +4 -1
  16. package/es/map.js +40 -20
  17. package/es/map.js.map +1 -1
  18. package/es/util.d.ts +3 -3
  19. package/es/util.js +6 -5
  20. package/es/util.js.map +1 -1
  21. package/es/utils/dom.js +60 -26
  22. package/es/utils/dom.js.map +1 -1
  23. package/es/utils/performance.js +2 -1
  24. package/es/utils/performance.js.map +1 -1
  25. package/lib/camera.js.map +1 -1
  26. package/lib/earthmap.js +7 -26
  27. package/lib/earthmap.js.map +1 -1
  28. package/lib/handler/handler_manager.js +55 -33
  29. package/lib/handler/handler_manager.js.map +1 -1
  30. package/lib/handler/shim/drag_pan.js +10 -2
  31. package/lib/handler/shim/drag_pan.js.map +1 -1
  32. package/lib/handler/shim/touch_zoom_rotate.js +10 -2
  33. package/lib/handler/shim/touch_zoom_rotate.js.map +1 -1
  34. package/lib/hash.js +9 -4
  35. package/lib/hash.js.map +1 -1
  36. package/lib/map.js +39 -19
  37. package/lib/map.js.map +1 -1
  38. package/lib/util.js +7 -5
  39. package/lib/util.js.map +1 -1
  40. package/lib/utils/dom.js +66 -26
  41. package/lib/utils/dom.js.map +1 -1
  42. package/lib/utils/performance.js +4 -1
  43. package/lib/utils/performance.js.map +1 -1
  44. package/package.json +3 -3
package/lib/util.js CHANGED
@@ -17,6 +17,8 @@ exports.raf = void 0;
17
17
  exports.renderframe = renderframe;
18
18
  exports.wrap = wrap;
19
19
 
20
+ var _l7Utils = require("@antv/l7-utils");
21
+
20
22
  var _unitbezier = _interopRequireDefault(require("@mapbox/unitbezier"));
21
23
 
22
24
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
@@ -52,12 +54,12 @@ var ease = bezier(0.25, 0.1, 0.25, 1);
52
54
  exports.ease = ease;
53
55
 
54
56
  function prefersReducedMotion() {
55
- if (!window.matchMedia) {
57
+ if (_l7Utils.isMini || !_l7Utils.$window.matchMedia) {
56
58
  return false;
57
59
  }
58
60
 
59
61
  if (reducedMotionQuery == null) {
60
- reducedMotionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
62
+ reducedMotionQuery = _l7Utils.$window.matchMedia('(prefers-reduced-motion: reduce)');
61
63
  }
62
64
 
63
65
  return reducedMotionQuery.matches;
@@ -86,12 +88,12 @@ function pick(src, properties) {
86
88
  return result;
87
89
  }
88
90
 
89
- var now = window.performance && window.performance.now ? window.performance.now.bind(window.performance) : Date.now.bind(Date);
91
+ var now = _l7Utils.isMini ? Date.now.bind(Date) : _l7Utils.$window.performance && _l7Utils.$window.performance.now ? _l7Utils.$window.performance.now.bind(_l7Utils.$window.performance) : Date.now.bind(Date);
90
92
  exports.now = now;
91
- var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
93
+ var raf = _l7Utils.$window.requestAnimationFrame || _l7Utils.$window.mozRequestAnimationFrame || _l7Utils.$window.webkitRequestAnimationFrame || _l7Utils.$window.msRequestAnimationFrame;
92
94
  exports.raf = raf;
93
95
 
94
- var _cancel = window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.msCancelAnimationFrame;
96
+ var _cancel = _l7Utils.$window.cancelAnimationFrame || _l7Utils.$window.mozCancelAnimationFrame || _l7Utils.$window.webkitCancelAnimationFrame || _l7Utils.$window.msCancelAnimationFrame;
95
97
 
96
98
  exports.cancel = _cancel;
97
99
 
package/lib/util.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/util.ts"],"names":["reducedMotionQuery","wrap","n","min","max","d","w","clamp","Math","interpolate","a","b","t","bezier","p1x","p1y","p2x","p2y","bez","UnitBezier","solve","ease","prefersReducedMotion","window","matchMedia","matches","pick","src","properties","result","name","now","performance","bind","Date","raf","requestAnimationFrame","mozRequestAnimationFrame","webkitRequestAnimationFrame","msRequestAnimationFrame","cancel","cancelAnimationFrame","mozCancelAnimationFrame","webkitCancelAnimationFrame","msCancelAnimationFrame","renderframe","fn","frame"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;;;;;;;;AACA,IAAIA,kBAAJ;;AAIO,SAASC,IAAT,CAAcC,CAAd,EAAyBC,GAAzB,EAAsCC,GAAtC,EAA2D;AAChE,MAAMC,CAAC,GAAGD,GAAG,GAAGD,GAAhB;AACA,MAAMG,CAAC,GAAI,CAAE,CAACJ,CAAC,GAAGC,GAAL,IAAYE,CAAb,GAAkBA,CAAnB,IAAwBA,CAAzB,GAA8BF,GAAxC;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AAAA,MAAM,CAACC,IAAD,CAAN,GAAeH,GAAG,CAACG,IAAD,CAAlB;AACD;AACF;AANuB;AAAA;AAAA;AAAA;AAAA;;AAOxB,SAAOD,MAAP;AACD;;AAEM,IAAME,GAAG,GACdR,MAAM,CAACS,WAAP,IAAsBT,MAAM,CAACS,WAAP,CAAmBD,GAAzC,GACIR,MAAM,CAACS,WAAP,CAAmBD,GAAnB,CAAuBE,IAAvB,CAA4BV,MAAM,CAACS,WAAnC,CADJ,GAEIE,IAAI,CAACH,GAAL,CAASE,IAAT,CAAcC,IAAd,CAHC;;AAKA,IAAMC,GAAG,GACdZ,MAAM,CAACa,qBAAP,IAEAb,MAAM,CAACc,wBAFP,IAIAd,MAAM,CAACe,2BAJP,IAMAf,MAAM,CAACgB,uBAPF;;;AASA,IAAMC,OAAM,GACjBjB,MAAM,CAACkB,oBAAP,IAEAlB,MAAM,CAACmB,uBAFP,IAIAnB,MAAM,CAACoB,0BAJP,IAMApB,MAAM,CAACqB,sBAPF;;;;AASA,SAASC,WAAT,CACLC,EADK,EAEQ;AACb,MAAMC,KAAK,GAAGZ,GAAG,CAACW,EAAD,CAAjB;AACA,SAAO;AAAEN,IAAAA,MAAM,EAAE;AAAA,aAAMA,OAAM,CAACO,KAAD,CAAZ;AAAA;AAAV,GAAP;AACD","sourcesContent":["// @ts-ignore\nimport UnitBezier from '@mapbox/unitbezier';\nlet reducedMotionQuery: MediaQueryList;\nexport interface ICancelable {\n cancel: () => void;\n}\nexport function wrap(n: number, min: number, max: number): number {\n const d = max - min;\n const w = ((((n - min) % d) + d) % d) + min;\n return w === min ? max : w;\n}\n\nexport function clamp(n: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, n));\n}\n\nexport function interpolate(a: number, b: number, t: number) {\n return a * (1 - t) + b * t;\n}\nexport function bezier(\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n): (t: number) => number {\n const bez = new UnitBezier(p1x, p1y, p2x, p2y);\n return (t: number) => {\n return bez.solve(t);\n };\n}\n\nexport const ease = bezier(0.25, 0.1, 0.25, 1);\n\nexport function prefersReducedMotion(): boolean {\n if (!window.matchMedia) {\n return false;\n }\n // Lazily initialize media query\n if (reducedMotionQuery == null) {\n reducedMotionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');\n }\n return reducedMotionQuery.matches;\n}\n\nexport function pick(\n src: { [key: string]: any },\n properties: string[],\n): { [key: string]: any } {\n const result: { [key: string]: any } = {};\n for (const name of properties) {\n if (name in src) {\n result[name] = src[name];\n }\n }\n return result;\n}\n\nexport const now =\n window.performance && window.performance.now\n ? window.performance.now.bind(window.performance)\n : Date.now.bind(Date);\n\nexport const raf =\n window.requestAnimationFrame ||\n // @ts-ignore\n window.mozRequestAnimationFrame ||\n // @ts-ignore\n window.webkitRequestAnimationFrame ||\n // @ts-ignore\n window.msRequestAnimationFrame;\n\nexport const cancel =\n window.cancelAnimationFrame ||\n // @ts-ignore\n window.mozCancelAnimationFrame ||\n // @ts-ignore\n window.webkitCancelAnimationFrame ||\n // @ts-ignore\n window.msCancelAnimationFrame;\n\nexport function renderframe(\n fn: (paintStartTimestamp: number) => void,\n): ICancelable {\n const frame = raf(fn);\n return { cancel: () => cancel(frame) };\n}\n"],"file":"util.js"}
1
+ {"version":3,"sources":["../src/util.ts"],"names":["reducedMotionQuery","wrap","n","min","max","d","w","clamp","Math","interpolate","a","b","t","bezier","p1x","p1y","p2x","p2y","bez","UnitBezier","solve","ease","prefersReducedMotion","isMini","$window","matchMedia","matches","pick","src","properties","result","name","now","Date","bind","performance","raf","requestAnimationFrame","mozRequestAnimationFrame","webkitRequestAnimationFrame","msRequestAnimationFrame","cancel","cancelAnimationFrame","mozCancelAnimationFrame","webkitCancelAnimationFrame","msCancelAnimationFrame","renderframe","fn","frame"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;;;;;;;AACA,IAAIA,kBAAJ;;AAIO,SAASC,IAAT,CAAcC,CAAd,EAAyBC,GAAzB,EAAsCC,GAAtC,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,EAELC,UAFK,EAGmB;AACxB,MAAMC,MAA8B,GAAG,EAAvC;;AADwB,6CAELD,UAFK;AAAA;;AAAA;AAExB,wDAA+B;AAAA,UAApBE,IAAoB;;AAC7B,UAAIA,IAAI,IAAIH,GAAZ,EAAiB;AACfE,QAAAA,MAAM,CAACC,IAAD,CAAN,GAAeH,GAAG,CAACG,IAAD,CAAlB;AACD;AACF;AANuB;AAAA;AAAA;AAAA;AAAA;;AAOxB,SAAOD,MAAP;AACD;;AAEM,IAAME,GAAG,GAAGT,kBACfU,IAAI,CAACD,GAAL,CAASE,IAAT,CAAcD,IAAd,CADe,GAEfT,iBAAQW,WAAR,IAAuBX,iBAAQW,WAAR,CAAoBH,GAA3C,GACAR,iBAAQW,WAAR,CAAoBH,GAApB,CAAwBE,IAAxB,CAA6BV,iBAAQW,WAArC,CADA,GAEAF,IAAI,CAACD,GAAL,CAASE,IAAT,CAAcD,IAAd,CAJG;;AAMA,IAAMG,GAAG,GACdZ,iBAAQa,qBAAR,IAEAb,iBAAQc,wBAFR,IAIAd,iBAAQe,2BAJR,IAMAf,iBAAQgB,uBAPH;;;AASA,IAAMC,OAAM,GACjBjB,iBAAQkB,oBAAR,IAEAlB,iBAAQmB,uBAFR,IAIAnB,iBAAQoB,0BAJR,IAMApB,iBAAQqB,sBAPH;;;;AASA,SAASC,WAAT,CACLC,EADK,EAEQ;AACb,MAAMC,KAAK,GAAGZ,GAAG,CAACW,EAAD,CAAjB;AACA,SAAO;AAAEN,IAAAA,MAAM,EAAE;AAAA,aAAMA,OAAM,CAACO,KAAD,CAAZ;AAAA;AAAV,GAAP;AACD","sourcesContent":["import { $window, isMini } from '@antv/l7-utils';\n// @ts-ignore\nimport UnitBezier from '@mapbox/unitbezier';\nlet reducedMotionQuery: MediaQueryList;\nexport interface ICancelable {\n cancel: () => void;\n}\nexport function wrap(n: number, min: number, max: number): number {\n const d = max - min;\n const w = ((((n - min) % d) + d) % d) + min;\n return w === min ? max : w;\n}\n\nexport function clamp(n: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, n));\n}\n\nexport function interpolate(a: number, b: number, t: number) {\n return a * (1 - t) + b * t;\n}\nexport function bezier(\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n): (t: number) => number {\n const bez = new UnitBezier(p1x, p1y, p2x, p2y);\n return (t: number) => {\n return bez.solve(t);\n };\n}\n\nexport const ease = bezier(0.25, 0.1, 0.25, 1);\n\nexport function prefersReducedMotion(): boolean {\n // @ts-ignore\n if (isMini || !$window.matchMedia) {\n return false;\n }\n // Lazily initialize media query\n if (reducedMotionQuery == null) {\n // @ts-ignore\n reducedMotionQuery = $window.matchMedia('(prefers-reduced-motion: reduce)');\n }\n return reducedMotionQuery.matches;\n}\n\nexport function pick(\n src: { [key: string]: any },\n properties: string[],\n): { [key: string]: any } {\n const result: { [key: string]: any } = {};\n for (const name of properties) {\n if (name in src) {\n result[name] = src[name];\n }\n }\n return result;\n}\n\nexport const now = isMini\n ? Date.now.bind(Date)\n : $window.performance && $window.performance.now\n ? $window.performance.now.bind($window.performance)\n : Date.now.bind(Date);\n\nexport const raf =\n $window.requestAnimationFrame ||\n // @ts-ignore\n $window.mozRequestAnimationFrame ||\n // @ts-ignore\n $window.webkitRequestAnimationFrame ||\n // @ts-ignore\n $window.msRequestAnimationFrame;\n\nexport const cancel =\n $window.cancelAnimationFrame ||\n // @ts-ignore\n $window.mozCancelAnimationFrame ||\n // @ts-ignore\n $window.webkitCancelAnimationFrame ||\n // @ts-ignore\n $window.msCancelAnimationFrame;\n\nexport function renderframe(\n fn: (paintStartTimestamp: number) => void,\n): ICancelable {\n const frame = raf(fn);\n return { cancel: () => cancel(frame) };\n}\n"],"file":"util.js"}
package/lib/utils/dom.js CHANGED
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
+ var _l7Utils = require("@antv/l7-utils");
11
+
10
12
  var _point = _interopRequireDefault(require("../geo/point"));
11
13
 
12
14
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
@@ -20,7 +22,7 @@ var _default = DOM;
20
22
  exports.default = _default;
21
23
 
22
24
  DOM.create = function (tagName, className, container) {
23
- var el = window.document.createElement(tagName);
25
+ var el = _l7Utils.$window.document.createElement(tagName);
24
26
 
25
27
  if (className !== undefined) {
26
28
  el.className = className;
@@ -34,11 +36,12 @@ DOM.create = function (tagName, className, container) {
34
36
  };
35
37
 
36
38
  DOM.createNS = function (namespaceURI, tagName) {
37
- var el = window.document.createElementNS(namespaceURI, tagName);
39
+ var el = _l7Utils.$window.document.createElementNS(namespaceURI, tagName);
40
+
38
41
  return el;
39
42
  };
40
43
 
41
- var docStyle = window.document && window.document.documentElement.style;
44
+ var docStyle = _l7Utils.$window.document && _l7Utils.$window.document.documentElement.style;
42
45
 
43
46
  function testProp(props) {
44
47
  if (!docStyle) {
@@ -95,8 +98,10 @@ try {
95
98
  passiveSupported = true;
96
99
  }
97
100
  });
98
- window.addEventListener('test', options, options);
99
- window.removeEventListener('test', options, options);
101
+
102
+ _l7Utils.$window.addEventListener('test', options, options);
103
+
104
+ _l7Utils.$window.removeEventListener('test', options, options);
100
105
  } catch (err) {
101
106
  passiveSupported = false;
102
107
  }
@@ -124,44 +129,79 @@ DOM.removeEventListener = function (target, type, callback) {
124
129
  var suppressClick = function suppressClick(e) {
125
130
  e.preventDefault();
126
131
  e.stopPropagation();
127
- window.removeEventListener('click', suppressClick, true);
132
+
133
+ _l7Utils.$window.removeEventListener('click', suppressClick, true);
128
134
  };
129
135
 
130
136
  DOM.suppressClick = function () {
131
- window.addEventListener('click', suppressClick, true);
132
- window.setTimeout(function () {
133
- window.removeEventListener('click', suppressClick, true);
137
+ if (_l7Utils.isMini) {
138
+ return;
139
+ }
140
+
141
+ _l7Utils.$window.addEventListener('click', suppressClick, true);
142
+
143
+ setTimeout(function () {
144
+ _l7Utils.$window.removeEventListener('click', suppressClick, true);
134
145
  }, 0);
135
146
  };
136
147
 
137
148
  DOM.mousePos = function (el, e) {
138
- var rect = el.getBoundingClientRect();
139
- return new _point.default(e.clientX - rect.left - el.clientLeft, e.clientY - rect.top - el.clientTop);
149
+ if (!_l7Utils.isMini) {
150
+ var rect = el.getBoundingClientRect();
151
+ return new _point.default(e.clientX - rect.left - el.clientLeft, e.clientY - rect.top - el.clientTop);
152
+ } else {
153
+ return new _point.default(e.clientX - el.left - 0, e.clientY - el.top - 0);
154
+ }
140
155
  };
141
156
 
142
157
  DOM.touchPos = function (el, touches) {
143
- var rect = el.getBoundingClientRect();
144
- var points = [];
158
+ if (!_l7Utils.isMini) {
159
+ var rect = el.getBoundingClientRect();
160
+ var points = [];
145
161
 
146
- var _iterator2 = _createForOfIteratorHelper(touches),
147
- _step2;
162
+ var _iterator2 = _createForOfIteratorHelper(touches),
163
+ _step2;
148
164
 
149
- try {
150
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
151
- var touche = _step2.value;
152
- points.push(new _point.default(touche.clientX - rect.left - el.clientLeft, touche.clientY - rect.top - el.clientTop));
165
+ try {
166
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
167
+ var touche = _step2.value;
168
+ points.push(new _point.default(touche.clientX - rect.left - el.clientLeft, touche.clientY - rect.top - el.clientTop));
169
+ }
170
+ } catch (err) {
171
+ _iterator2.e(err);
172
+ } finally {
173
+ _iterator2.f();
153
174
  }
154
- } catch (err) {
155
- _iterator2.e(err);
156
- } finally {
157
- _iterator2.f();
158
- }
159
175
 
160
- return points;
176
+ return points;
177
+ } else {
178
+ var _points = [];
179
+
180
+ var _iterator3 = _createForOfIteratorHelper(touches),
181
+ _step3;
182
+
183
+ try {
184
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
185
+ var _touche = _step3.value;
186
+
187
+ _points.push(new _point.default(_touche.clientX - el.left, _touche.clientY - el.top));
188
+ }
189
+ } catch (err) {
190
+ _iterator3.e(err);
191
+ } finally {
192
+ _iterator3.f();
193
+ }
194
+
195
+ return _points;
196
+ }
161
197
  };
162
198
 
163
199
  DOM.mouseButton = function (e) {
164
- if (typeof window.InstallTrigger !== 'undefined' && e.button === 2 && e.ctrlKey && window.navigator.platform.toUpperCase().indexOf('MAC') >= 0) {
200
+ if (!_l7Utils.isMini) {
201
+ return e.button;
202
+ }
203
+
204
+ if (typeof _l7Utils.$window.InstallTrigger !== 'undefined' && e.button === 2 && e.ctrlKey && _l7Utils.$window.navigator.platform.toUpperCase().indexOf('MAC') >= 0) {
165
205
  return 0;
166
206
  }
167
207
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/dom.ts"],"names":["DOM","create","tagName","className","container","el","window","document","createElement","undefined","appendChild","createNS","namespaceURI","createElementNS","docStyle","documentElement","style","testProp","props","i","selectProp","userSelect","disableDrag","enableDrag","transformProp","setTransform","value","passiveSupported","options","Object","defineProperty","get","addEventListener","removeEventListener","err","target","type","callback","capture","suppressClick","e","preventDefault","stopPropagation","setTimeout","mousePos","rect","getBoundingClientRect","Point","clientX","left","clientLeft","clientY","top","clientTop","touchPos","touches","points","touche","push","mouseButton","InstallTrigger","button","ctrlKey","navigator","platform","toUpperCase","indexOf","remove","node","parentNode","removeChild"],"mappings":";;;;;;;;;AACA;;;;;;;;AAEA,IAAMA,G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UADtB,EAELV,CAAC,CAACW,OAAF,GAAYN,IAAI,CAACO,GAAjB,GAAuB/C,EAAE,CAACgD,SAFrB,CAAP;AAID,CAND;;AAQArD,GAAG,CAACsD,QAAJ,GAAe,UAACjD,EAAD,EAAkBkD,OAAlB,EAAuC;AACpD,MAAMV,IAAI,GAAGxC,EAAE,CAACyC,qBAAH,EAAb;AACA,MAAMU,MAAM,GAAG,EAAf;;AAFoD,8CAG/BD,OAH+B;AAAA;;AAAA;AAGpD,2DAA8B;AAAA,UAAnBE,MAAmB;AAC5BD,MAAAA,MAAM,CAACE,IAAP,CACE,IAAIX,cAAJ,CACEU,MAAM,CAACT,OAAP,GAAiBH,IAAI,CAACI,IAAtB,GAA6B5C,EAAE,CAAC6C,UADlC,EAEEO,MAAM,CAACN,OAAP,GAAiBN,IAAI,CAACO,GAAtB,GAA4B/C,EAAE,CAACgD,SAFjC,CADF;AAMD;AAVmD;AAAA;AAAA;AAAA;AAAA;;AAWpD,SAAOG,MAAP;AACD,CAZD;;AAcAxD,GAAG,CAAC2D,WAAJ,GAAkB,UAACnB,CAAD,EAAmB;AACnC,MAEE,OAAOlC,MAAM,CAACsD,cAAd,KAAiC,WAAjC,IACApB,CAAC,CAACqB,MAAF,KAAa,CADb,IAEArB,CAAC,CAACsB,OAFF,IAGAxD,MAAM,CAACyD,SAAP,CAAiBC,QAAjB,CAA0BC,WAA1B,GAAwCC,OAAxC,CAAgD,KAAhD,KAA0D,CAL5D,EAME;AAIA,WAAO,CAAP;AACD;;AACD,SAAO1B,CAAC,CAACqB,MAAT;AACD,CAdD;;AAgBA7D,GAAG,CAACmE,MAAJ,GAAa,UAACC,IAAD,EAAuB;AAClC,MAAIA,IAAI,CAACC,UAAT,EAAqB;AACnBD,IAAAA,IAAI,CAACC,UAAL,CAAgBC,WAAhB,CAA4BF,IAA5B;AACD;AACF,CAJD","sourcesContent":["// @ts-ignore\nimport Point from '../geo/point';\n\nconst DOM: {\n [key: string]: (...arg: any[]) => any;\n} = {};\nexport default DOM;\n\nDOM.create = (tagName: string, className?: string, container?: HTMLElement) => {\n const el = window.document.createElement(tagName);\n if (className !== undefined) {\n el.className = className;\n }\n if (container) {\n container.appendChild(el);\n }\n return el;\n};\n\nDOM.createNS = (namespaceURI: string, tagName: string) => {\n const el = window.document.createElementNS(namespaceURI, tagName);\n return el;\n};\n\nconst docStyle = window.document && window.document.documentElement.style;\n\nfunction testProp(props: any) {\n if (!docStyle) {\n return props[0];\n }\n for (const i of props) {\n if (i in docStyle) {\n return i;\n }\n }\n return props[0];\n}\n\nconst selectProp = testProp([\n 'userSelect',\n 'MozUserSelect',\n 'WebkitUserSelect',\n 'msUserSelect',\n]);\nlet userSelect: any;\n\nDOM.disableDrag = () => {\n if (docStyle && selectProp) {\n userSelect = docStyle[selectProp];\n docStyle[selectProp] = 'none';\n }\n};\n\nDOM.enableDrag = () => {\n if (docStyle && selectProp) {\n docStyle[selectProp] = userSelect;\n }\n};\n\nconst transformProp = testProp(['transform', 'WebkitTransform']);\n\nDOM.setTransform = (el: HTMLElement, value: string) => {\n // https://github.com/facebook/flow/issues/7754\n // $FlowFixMe\n el.style[transformProp] = value;\n};\n\n// Feature detection for {passive: false} support in add/removeEventListener.\nlet passiveSupported = false;\n\ntry {\n // https://github.com/facebook/flow/issues/285\n // $FlowFixMe\n const options = Object.defineProperty({}, 'passive', {\n get() {\n // eslint-disable-line\n passiveSupported = true;\n },\n });\n // @ts-ignore\n window.addEventListener('test', options, options);\n // @ts-ignore\n window.removeEventListener('test', options, options);\n} catch (err) {\n passiveSupported = false;\n}\n\nDOM.addEventListener = (\n target: any,\n type: any,\n callback: any,\n options: { passive?: boolean; capture?: boolean } = {},\n) => {\n if ('passive' in options && passiveSupported) {\n target.addEventListener(type, callback, options);\n } else {\n target.addEventListener(type, callback, options.capture);\n }\n};\n\nDOM.removeEventListener = (\n target: any,\n type: any,\n callback: any,\n options: { passive?: boolean; capture?: boolean } = {},\n) => {\n if ('passive' in options && passiveSupported) {\n target.removeEventListener(type, callback, options);\n } else {\n target.removeEventListener(type, callback, options.capture);\n }\n};\n\n// Suppress the next click, but only if it's immediate.\nconst suppressClick = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n window.removeEventListener('click', suppressClick, true);\n};\n\nDOM.suppressClick = () => {\n window.addEventListener('click', suppressClick, true);\n window.setTimeout(() => {\n window.removeEventListener('click', suppressClick, true);\n }, 0);\n};\n\nDOM.mousePos = (el: HTMLElement, e: MouseEvent | Touch) => {\n const rect = el.getBoundingClientRect();\n return new Point(\n e.clientX - rect.left - el.clientLeft,\n e.clientY - rect.top - el.clientTop,\n );\n};\n\nDOM.touchPos = (el: HTMLElement, touches: Touch[]) => {\n const rect = el.getBoundingClientRect();\n const points = [];\n for (const touche of touches) {\n points.push(\n new Point(\n touche.clientX - rect.left - el.clientLeft,\n touche.clientY - rect.top - el.clientTop,\n ),\n );\n }\n return points;\n};\n\nDOM.mouseButton = (e: MouseEvent) => {\n if (\n // @ts-ignore\n typeof window.InstallTrigger !== 'undefined' &&\n e.button === 2 &&\n e.ctrlKey &&\n window.navigator.platform.toUpperCase().indexOf('MAC') >= 0\n ) {\n // Fix for https://github.com/mapbox/mapbox-gl-js/issues/3131:\n // Firefox (detected by InstallTrigger) on Mac determines e.button = 2 when\n // using Control + left click\n return 0;\n }\n return e.button;\n};\n\nDOM.remove = (node: HTMLElement) => {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n};\n"],"file":"dom.js"}
1
+ {"version":3,"sources":["../../src/utils/dom.ts"],"names":["DOM","create","tagName","className","container","el","$window","document","createElement","undefined","appendChild","createNS","namespaceURI","createElementNS","docStyle","documentElement","style","testProp","props","i","selectProp","userSelect","disableDrag","enableDrag","transformProp","setTransform","value","passiveSupported","options","Object","defineProperty","get","addEventListener","removeEventListener","err","target","type","callback","capture","suppressClick","e","preventDefault","stopPropagation","isMini","setTimeout","mousePos","rect","getBoundingClientRect","Point","clientX","left","clientLeft","clientY","top","clientTop","touchPos","touches","points","touche","push","mouseButton","button","InstallTrigger","ctrlKey","navigator","platform","toUpperCase","indexOf","remove","node","parentNode","removeChild"],"mappings":";;;;;;;;;AAAA;;AAEA;;;;;;;;AAEA,IAAMA,GAEL,GAAG,EAFJ;eAGeA,G;;;AAEfA,GAAG,CAACC,MAAJ,GAAa,UAACC,OAAD,EAAkBC,SAAlB,EAAsCC,SAAtC,EAAkE;AAC7E,MAAMC,EAAE,GAAGC,iBAAQC,QAAR,CAAiBC,aAAjB,CAA+BN,OAA/B,CAAX;;AACA,MAAIC,SAAS,KAAKM,SAAlB,EAA6B;AAC3BJ,IAAAA,EAAE,CAACF,SAAH,GAAeA,SAAf;AACD;;AACD,MAAIC,SAAJ,EAAe;AACbA,IAAAA,SAAS,CAACM,WAAV,CAAsBL,EAAtB;AACD;;AACD,SAAOA,EAAP;AACD,CATD;;AAWAL,GAAG,CAACW,QAAJ,GAAe,UAACC,YAAD,EAAuBV,OAAvB,EAA2C;AACxD,MAAMG,EAAE,GAAGC,iBAAQC,QAAR,CAAiBM,eAAjB,CACTD,YADS,EAETV,OAFS,CAAX;;AAIA,SAAOG,EAAP;AACD,CAND;;AAQA,IAAMS,QAAQ,GAAGR,iBAAQC,QAAR,IAAoBD,iBAAQC,QAAR,CAAiBQ,eAAjB,CAAiCC,KAAtE;;AAEA,SAASC,QAAT,CAAkBC,KAAlB,EAA8B;AAC5B,MAAI,CAACJ,QAAL,EAAe;AACb,WAAOI,KAAK,CAAC,CAAD,CAAZ;AACD;;AAH2B,6CAIZA,KAJY;AAAA;;AAAA;AAI5B,wDAAuB;AAAA,UAAZC,CAAY;;AACrB,UAAIA,CAAC,IAAIL,QAAT,EAAmB;AACjB,eAAOK,CAAP;AACD;AACF;AAR2B;AAAA;AAAA;AAAA;AAAA;;AAS5B,SAAOD,KAAK,CAAC,CAAD,CAAZ;AACD;;AAED,IAAME,UAAU,GAAGH,QAAQ,CAAC,CAC1B,YAD0B,EAE1B,eAF0B,EAG1B,kBAH0B,EAI1B,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AAQD;AAXI;AAAA;AAAA;AAAA;AAAA;;AAYL,WAAOI,OAAP;AACD;AACF,CA5BD;;AA8BAzD,GAAG,CAAC4D,WAAJ,GAAkB,UAACpB,CAAD,EAAmB;AACnC,MAAI,CAACG,eAAL,EAAa;AACX,WAAOH,CAAC,CAACqB,MAAT;AACD;;AACD,MAEE,OAAOvD,iBAAQwD,cAAf,KAAkC,WAAlC,IACAtB,CAAC,CAACqB,MAAF,KAAa,CADb,IAEArB,CAAC,CAACuB,OAFF,IAGAzD,iBAAQ0D,SAAR,CAAkBC,QAAlB,CAA2BC,WAA3B,GAAyCC,OAAzC,CAAiD,KAAjD,KAA2D,CAL7D,EAME;AAIA,WAAO,CAAP;AACD;;AACD,SAAO3B,CAAC,CAACqB,MAAT;AACD,CAjBD;;AAmBA7D,GAAG,CAACoE,MAAJ,GAAa,UAACC,IAAD,EAAuB;AAClC,MAAIA,IAAI,CAACC,UAAT,EAAqB;AACnBD,IAAAA,IAAI,CAACC,UAAL,CAAgBC,WAAhB,CAA4BF,IAA5B;AACD;AACF,CAJD","sourcesContent":["import { $window, isMini } from '@antv/l7-utils';\n// @ts-ignore\nimport Point from '../geo/point';\n\nconst DOM: {\n [key: string]: (...arg: any[]) => any;\n} = {};\nexport default DOM;\n\nDOM.create = (tagName: string, className?: string, container?: HTMLElement) => {\n const el = $window.document.createElement(tagName) as HTMLElement;\n if (className !== undefined) {\n el.className = className;\n }\n if (container) {\n container.appendChild(el);\n }\n return el;\n};\n\nDOM.createNS = (namespaceURI: string, tagName: string) => {\n const el = $window.document.createElementNS(\n namespaceURI,\n tagName,\n ) as HTMLElement;\n return el;\n};\n\nconst docStyle = $window.document && $window.document.documentElement.style;\n\nfunction testProp(props: any) {\n if (!docStyle) {\n return props[0];\n }\n for (const i of props) {\n if (i in docStyle) {\n return i;\n }\n }\n return props[0];\n}\n\nconst selectProp = testProp([\n 'userSelect',\n 'MozUserSelect',\n 'WebkitUserSelect',\n 'msUserSelect',\n]);\nlet userSelect: any;\n\nDOM.disableDrag = () => {\n if (docStyle && selectProp) {\n userSelect = docStyle[selectProp];\n docStyle[selectProp] = 'none';\n }\n};\n\nDOM.enableDrag = () => {\n if (docStyle && selectProp) {\n docStyle[selectProp] = userSelect;\n }\n};\n\nconst transformProp = testProp(['transform', 'WebkitTransform']);\n\nDOM.setTransform = (el: HTMLElement, value: string) => {\n // https://github.com/facebook/flow/issues/7754\n // $FlowFixMe\n el.style[transformProp] = value;\n};\n\n// Feature detection for {passive: false} support in add/removeEventListener.\nlet passiveSupported = false;\n\ntry {\n // https://github.com/facebook/flow/issues/285\n // $FlowFixMe\n const options = Object.defineProperty({}, 'passive', {\n get() {\n // eslint-disable-line\n passiveSupported = true;\n },\n });\n // @ts-ignore\n $window.addEventListener('test', options, options);\n // @ts-ignore\n $window.removeEventListener('test', options, options);\n} catch (err) {\n passiveSupported = false;\n}\n\nDOM.addEventListener = (\n target: any,\n type: any,\n callback: any,\n options: { passive?: boolean; capture?: boolean } = {},\n) => {\n if ('passive' in options && passiveSupported) {\n target.addEventListener(type, callback, options);\n } else {\n target.addEventListener(type, callback, options.capture);\n }\n};\n\nDOM.removeEventListener = (\n target: any,\n type: any,\n callback: any,\n options: { passive?: boolean; capture?: boolean } = {},\n) => {\n if ('passive' in options && passiveSupported) {\n target.removeEventListener(type, callback, options);\n } else {\n target.removeEventListener(type, callback, options.capture);\n }\n};\n\n// Suppress the next click, but only if it's immediate.\nconst suppressClick = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n $window.removeEventListener('click', suppressClick, true);\n};\n\nDOM.suppressClick = () => {\n if (isMini) {\n return;\n }\n $window.addEventListener('click', suppressClick, true);\n setTimeout(() => {\n $window.removeEventListener('click', suppressClick, true);\n }, 0);\n};\n\nDOM.mousePos = (el: HTMLElement, e: MouseEvent | Touch) => {\n // 暂时从 el 上获取 top/left, 后面需要动态获取\n if (!isMini) {\n const rect = el.getBoundingClientRect();\n return new Point(\n e.clientX - rect.left - el.clientLeft,\n e.clientY - rect.top - el.clientTop,\n );\n } else {\n return new Point(\n // @ts-ignore\n e.clientX - el.left - 0,\n // @ts-ignore\n e.clientY - el.top - 0,\n );\n }\n};\n\nDOM.touchPos = (el: HTMLElement, touches: Touch[]) => {\n // 暂时从 el 上获取 top/left, 后面需要动态获取\n if (!isMini) {\n const rect = el.getBoundingClientRect();\n const points = [];\n for (const touche of touches) {\n points.push(\n new Point(\n touche.clientX - rect.left - el.clientLeft,\n touche.clientY - rect.top - el.clientTop,\n ),\n );\n }\n return points;\n } else {\n const points = [];\n for (const touche of touches) {\n points.push(\n new Point(\n // @ts-ignore\n touche.clientX - el.left,\n // @ts-ignore\n touche.clientY - el.top,\n ),\n );\n }\n return points;\n }\n};\n\nDOM.mouseButton = (e: MouseEvent) => {\n if (!isMini) {\n return e.button;\n }\n if (\n // @ts-ignore\n typeof $window.InstallTrigger !== 'undefined' &&\n e.button === 2 &&\n e.ctrlKey &&\n $window.navigator.platform.toUpperCase().indexOf('MAC') >= 0\n ) {\n // Fix for https://github.com/mapbox/mapbox-gl-js/issues/3131:\n // Firefox (detected by InstallTrigger) on Mac determines e.button = 2 when\n // using Control + left click\n return 0;\n }\n return e.button;\n};\n\nDOM.remove = (node: HTMLElement) => {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n};\n"],"file":"dom.js"}
@@ -4,11 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.PerformanceUtils = exports.PerformanceMarkers = void 0;
7
+
8
+ var _l7Utils = require("@antv/l7-utils");
9
+
7
10
  var lastFrameTime = null;
8
11
  var frameTimes = [];
9
12
  var minFramerateTarget = 30;
10
13
  var frameTimeTarget = 1000 / minFramerateTarget;
11
- var performance = window.performance;
14
+ var performance = _l7Utils.$window.performance;
12
15
  var PerformanceMarkers = {
13
16
  create: 'create',
14
17
  load: 'load',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/performance.ts"],"names":["lastFrameTime","frameTimes","minFramerateTarget","frameTimeTarget","performance","window","PerformanceMarkers","create","load","fullLoad","PerformanceUtils","mark","marker","frame","timestamp","currTimestamp","frameTime","push","clearMetrics","clearMeasures","clearMarks","getPerformanceMetrics","loadTime","measure","duration","fullLoadTime","totalFrames","length","avgFrameTime","reduce","prev","curr","fps","droppedFrames","filter","acc","percentDroppedFrames"],"mappings":";;;;;;AAAA,IAAIA,aAA4B,GAAG,IAAnC;AACA,IAAIC,UAAoB,GAAG,EAA3B;AAEA,IAAMC,kBAAkB,GAAG,EAA3B;AACA,IAAMC,eAAe,GAAG,OAAOD,kBAA/B;AACA,IAAME,WAAW,GAAGC,MAAM,CAACD,WAA3B;AASO,IAAME,kBAAkB,GAAG;AAChCC,EAAAA,MAAM,EAAE,QADwB;AAEhCC,EAAAA,IAAI,EAAE,MAF0B;AAGhCC,EAAAA,QAAQ,EAAE;AAHsB,CAA3B;;AAMA,IAAMC,gBAAgB,GAAG;AAC9BC,EAAAA,IAD8B,gBACzBC,MADyB,EACT;AACnBR,IAAAA,WAAW,CAACO,IAAZ,CAAiBC,MAAjB;AACD,GAH6B;AAI9BC,EAAAA,KAJ8B,iBAIxBC,SAJwB,EAIL;AACvB,QAAMC,aAAa,GAAGD,SAAtB;;AACA,QAAId,aAAa,IAAI,IAArB,EAA2B;AACzB,UAAMgB,SAAS,GAAGD,aAAa,GAAGf,aAAlC;AACAC,MAAAA,UAAU,CAACgB,IAAX,CAAgBD,SAAhB;AACD;;AACDhB,IAAAA,aAAa,GAAGe,aAAhB;AACD,GAX6B;AAY9BG,EAAAA,YAZ8B,0BAYf;AACblB,IAAAA,aAAa,GAAG,IAAhB;AACAC,IAAAA,UAAU,GAAG,EAAb;AACAG,IAAAA,WAAW,CAACe,aAAZ,CAA0B,UAA1B;AACAf,IAAAA,WAAW,CAACe,aAAZ,CAA0B,cAA1B;;AAGA,SAAK,IAAMP,MAAX,IAAqBN,kBAArB,EAAyC;AAEvCF,MAAAA,WAAW,CAACgB,UAAZ,CAAuBd,kBAAkB,CAACM,MAAD,CAAzC;AACD;AACF,GAvB6B;AAwB9BS,EAAAA,qBAxB8B,mCAwBe;AAC3C,QAAMC,QAAQ,GAAGlB,WAAW,CAACmB,OAAZ,CACf,UADe,EAEfjB,kBAAkB,CAACC,MAFJ,EAGfD,kBAAkB,CAACE,IAHJ,EAKfgB,QALF;AAOA,QAAMC,YAAY,GAAGrB,WAAW,CAACmB,OAAZ,CACnB,cADmB,EAEnBjB,kBAAkB,CAACC,MAFA,EAGnBD,kBAAkB,CAACG,QAHA,EAKnBe,QALF;AAMA,QAAME,WAAW,GAAGzB,UAAU,CAAC0B,MAA/B;AAEA,QAAMC,YAAY,GAChB3B,UAAU,CAAC4B,MAAX,CAAkB,UAACC,IAAD,EAAOC,IAAP;AAAA,aAAgBD,IAAI,GAAGC,IAAvB;AAAA,KAAlB,EAA+C,CAA/C,IAAoDL,WAApD,GAAkE,IADpE;AAEA,QAAMM,GAAG,GAAG,IAAIJ,YAAhB;AAGA,QAAMK,aAAa,GAAGhC,UAAU,CAC7BiC,MADmB,CACZ,UAAClB,SAAD;AAAA,aAAeA,SAAS,GAAGb,eAA3B;AAAA,KADY,EAEnB0B,MAFmB,CAEZ,UAACM,GAAD,EAAMJ,IAAN,EAAe;AACrB,aAAOI,GAAG,GAAG,CAACJ,IAAI,GAAG5B,eAAR,IAA2BA,eAAxC;AACD,KAJmB,EAIjB,CAJiB,CAAtB;AAKA,QAAMiC,oBAAoB,GACvBH,aAAa,IAAIP,WAAW,GAAGO,aAAlB,CAAd,GAAkD,GADpD;AAGA,WAAO;AACLX,MAAAA,QAAQ,EAARA,QADK;AAELG,MAAAA,YAAY,EAAZA,YAFK;AAGLO,MAAAA,GAAG,EAAHA,GAHK;AAILI,MAAAA,oBAAoB,EAApBA;AAJK,KAAP;AAMD;AA3D6B,CAAzB","sourcesContent":["let lastFrameTime: number | null = null;\nlet frameTimes: number[] = [];\n\nconst minFramerateTarget = 30;\nconst frameTimeTarget = 1000 / minFramerateTarget;\nconst performance = window.performance;\n\nexport interface IPerformanceMetrics {\n loadTime: number;\n fullLoadTime: number;\n fps: number;\n percentDroppedFrames: number;\n}\n\nexport const PerformanceMarkers = {\n create: 'create',\n load: 'load',\n fullLoad: 'fullLoad',\n};\n\nexport const PerformanceUtils = {\n mark(marker: string) {\n performance.mark(marker);\n },\n frame(timestamp: number) {\n const currTimestamp = timestamp;\n if (lastFrameTime != null) {\n const frameTime = currTimestamp - lastFrameTime;\n frameTimes.push(frameTime);\n }\n lastFrameTime = currTimestamp;\n },\n clearMetrics() {\n lastFrameTime = null;\n frameTimes = [];\n performance.clearMeasures('loadTime');\n performance.clearMeasures('fullLoadTime');\n // @ts-ignore\n // tslint:disable-next-line:forin\n for (const marker in PerformanceMarkers) {\n // @ts-ignore\n performance.clearMarks(PerformanceMarkers[marker]);\n }\n },\n getPerformanceMetrics(): IPerformanceMetrics {\n const loadTime = performance.measure(\n 'loadTime',\n PerformanceMarkers.create,\n PerformanceMarkers.load,\n // @ts-ignore\n ).duration;\n\n const fullLoadTime = performance.measure(\n 'fullLoadTime',\n PerformanceMarkers.create,\n PerformanceMarkers.fullLoad,\n // @ts-ignore\n ).duration;\n const totalFrames = frameTimes.length;\n\n const avgFrameTime =\n frameTimes.reduce((prev, curr) => prev + curr, 0) / totalFrames / 1000;\n const fps = 1 / avgFrameTime;\n\n // count frames that missed our framerate target\n const droppedFrames = frameTimes\n .filter((frameTime) => frameTime > frameTimeTarget)\n .reduce((acc, curr) => {\n return acc + (curr - frameTimeTarget) / frameTimeTarget;\n }, 0);\n const percentDroppedFrames =\n (droppedFrames / (totalFrames + droppedFrames)) * 100;\n\n return {\n loadTime,\n fullLoadTime,\n fps,\n percentDroppedFrames,\n };\n },\n};\n"],"file":"performance.js"}
1
+ {"version":3,"sources":["../../src/utils/performance.ts"],"names":["lastFrameTime","frameTimes","minFramerateTarget","frameTimeTarget","performance","$window","PerformanceMarkers","create","load","fullLoad","PerformanceUtils","mark","marker","frame","timestamp","currTimestamp","frameTime","push","clearMetrics","clearMeasures","clearMarks","getPerformanceMetrics","loadTime","measure","duration","fullLoadTime","totalFrames","length","avgFrameTime","reduce","prev","curr","fps","droppedFrames","filter","acc","percentDroppedFrames"],"mappings":";;;;;;;AAAA;;AACA,IAAIA,aAA4B,GAAG,IAAnC;AACA,IAAIC,UAAoB,GAAG,EAA3B;AAEA,IAAMC,kBAAkB,GAAG,EAA3B;AACA,IAAMC,eAAe,GAAG,OAAOD,kBAA/B;AACA,IAAME,WAAW,GAAGC,iBAAQD,WAA5B;AASO,IAAME,kBAAkB,GAAG;AAChCC,EAAAA,MAAM,EAAE,QADwB;AAEhCC,EAAAA,IAAI,EAAE,MAF0B;AAGhCC,EAAAA,QAAQ,EAAE;AAHsB,CAA3B;;AAMA,IAAMC,gBAAgB,GAAG;AAC9BC,EAAAA,IAD8B,gBACzBC,MADyB,EACT;AACnBR,IAAAA,WAAW,CAACO,IAAZ,CAAiBC,MAAjB;AACD,GAH6B;AAI9BC,EAAAA,KAJ8B,iBAIxBC,SAJwB,EAIL;AACvB,QAAMC,aAAa,GAAGD,SAAtB;;AACA,QAAId,aAAa,IAAI,IAArB,EAA2B;AACzB,UAAMgB,SAAS,GAAGD,aAAa,GAAGf,aAAlC;AACAC,MAAAA,UAAU,CAACgB,IAAX,CAAgBD,SAAhB;AACD;;AACDhB,IAAAA,aAAa,GAAGe,aAAhB;AACD,GAX6B;AAY9BG,EAAAA,YAZ8B,0BAYf;AACblB,IAAAA,aAAa,GAAG,IAAhB;AACAC,IAAAA,UAAU,GAAG,EAAb;AACAG,IAAAA,WAAW,CAACe,aAAZ,CAA0B,UAA1B;AACAf,IAAAA,WAAW,CAACe,aAAZ,CAA0B,cAA1B;;AAGA,SAAK,IAAMP,MAAX,IAAqBN,kBAArB,EAAyC;AAEvCF,MAAAA,WAAW,CAACgB,UAAZ,CAAuBd,kBAAkB,CAACM,MAAD,CAAzC;AACD;AACF,GAvB6B;AAwB9BS,EAAAA,qBAxB8B,mCAwBe;AAC3C,QAAMC,QAAQ,GAAGlB,WAAW,CAACmB,OAAZ,CACf,UADe,EAEfjB,kBAAkB,CAACC,MAFJ,EAGfD,kBAAkB,CAACE,IAHJ,EAKfgB,QALF;AAOA,QAAMC,YAAY,GAAGrB,WAAW,CAACmB,OAAZ,CACnB,cADmB,EAEnBjB,kBAAkB,CAACC,MAFA,EAGnBD,kBAAkB,CAACG,QAHA,EAKnBe,QALF;AAMA,QAAME,WAAW,GAAGzB,UAAU,CAAC0B,MAA/B;AAEA,QAAMC,YAAY,GAChB3B,UAAU,CAAC4B,MAAX,CAAkB,UAACC,IAAD,EAAOC,IAAP;AAAA,aAAgBD,IAAI,GAAGC,IAAvB;AAAA,KAAlB,EAA+C,CAA/C,IAAoDL,WAApD,GAAkE,IADpE;AAEA,QAAMM,GAAG,GAAG,IAAIJ,YAAhB;AAGA,QAAMK,aAAa,GAAGhC,UAAU,CAC7BiC,MADmB,CACZ,UAAClB,SAAD;AAAA,aAAeA,SAAS,GAAGb,eAA3B;AAAA,KADY,EAEnB0B,MAFmB,CAEZ,UAACM,GAAD,EAAMJ,IAAN,EAAe;AACrB,aAAOI,GAAG,GAAG,CAACJ,IAAI,GAAG5B,eAAR,IAA2BA,eAAxC;AACD,KAJmB,EAIjB,CAJiB,CAAtB;AAKA,QAAMiC,oBAAoB,GACvBH,aAAa,IAAIP,WAAW,GAAGO,aAAlB,CAAd,GAAkD,GADpD;AAGA,WAAO;AACLX,MAAAA,QAAQ,EAARA,QADK;AAELG,MAAAA,YAAY,EAAZA,YAFK;AAGLO,MAAAA,GAAG,EAAHA,GAHK;AAILI,MAAAA,oBAAoB,EAApBA;AAJK,KAAP;AAMD;AA3D6B,CAAzB","sourcesContent":["import { $window } from '@antv/l7-utils';\nlet lastFrameTime: number | null = null;\nlet frameTimes: number[] = [];\n\nconst minFramerateTarget = 30;\nconst frameTimeTarget = 1000 / minFramerateTarget;\nconst performance = $window.performance;\n\nexport interface IPerformanceMetrics {\n loadTime: number;\n fullLoadTime: number;\n fps: number;\n percentDroppedFrames: number;\n}\n\nexport const PerformanceMarkers = {\n create: 'create',\n load: 'load',\n fullLoad: 'fullLoad',\n};\n\nexport const PerformanceUtils = {\n mark(marker: string) {\n performance.mark(marker);\n },\n frame(timestamp: number) {\n const currTimestamp = timestamp;\n if (lastFrameTime != null) {\n const frameTime = currTimestamp - lastFrameTime;\n frameTimes.push(frameTime);\n }\n lastFrameTime = currTimestamp;\n },\n clearMetrics() {\n lastFrameTime = null;\n frameTimes = [];\n performance.clearMeasures('loadTime');\n performance.clearMeasures('fullLoadTime');\n // @ts-ignore\n // tslint:disable-next-line:forin\n for (const marker in PerformanceMarkers) {\n // @ts-ignore\n performance.clearMarks(PerformanceMarkers[marker]);\n }\n },\n getPerformanceMetrics(): IPerformanceMetrics {\n const loadTime = performance.measure(\n 'loadTime',\n PerformanceMarkers.create,\n PerformanceMarkers.load,\n // @ts-ignore\n ).duration;\n\n const fullLoadTime = performance.measure(\n 'fullLoadTime',\n PerformanceMarkers.create,\n PerformanceMarkers.fullLoad,\n // @ts-ignore\n ).duration;\n const totalFrames = frameTimes.length;\n\n const avgFrameTime =\n frameTimes.reduce((prev, curr) => prev + curr, 0) / totalFrames / 1000;\n const fps = 1 / avgFrameTime;\n\n // count frames that missed our framerate target\n const droppedFrames = frameTimes\n .filter((frameTime) => frameTime > frameTimeTarget)\n .reduce((acc, curr) => {\n return acc + (curr - frameTimeTarget) / frameTimeTarget;\n }, 0);\n const percentDroppedFrames =\n (droppedFrames / (totalFrames + droppedFrames)) * 100;\n\n return {\n loadTime,\n fullLoadTime,\n fps,\n percentDroppedFrames,\n };\n },\n};\n"],"file":"performance.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-map",
3
- "version": "2.5.42",
3
+ "version": "2.5.47",
4
4
  "description": "l7 map",
5
5
  "keywords": [],
6
6
  "author": "thinkinggis <lzx199065@gmail.com>",
@@ -37,12 +37,12 @@
37
37
  },
38
38
  "homepage": "https://github.com/antvis/L7#readme",
39
39
  "dependencies": {
40
- "@antv/l7-utils": "^2.5.42",
40
+ "@antv/l7-utils": "^2.5.47",
41
41
  "@babel/runtime": "^7.7.7",
42
42
  "@mapbox/point-geometry": "^0.1.0",
43
43
  "@mapbox/unitbezier": "^0.0.0",
44
44
  "eventemitter3": "^4.0.4",
45
45
  "lodash": "^4.17.15"
46
46
  },
47
- "gitHead": "d59c0f28f65bcfcf9e8774dc987a056c9654df70"
47
+ "gitHead": "8b809eca7cd37428fab4960643c0d3c0a824806d"
48
48
  }