@antv/g-canvas 1.1.6 → 1.1.7

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.
package/dist/index.umd.js CHANGED
@@ -1,67 +1,14 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@antv/g'), require('mana-syringe')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', '@antv/g', 'mana-syringe'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.G = global.G || {}, global.G.Canvas2D = {}), global.window.G, global.window.G.ManaSyringe));
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.G = global.G || {}, global.G.CanvasKit = {}), global.window.G, global.window.G.ManaSyringe));
5
5
  }(this, (function (exports, g, manaSyringe) { 'use strict';
6
6
 
7
- function _typeof(obj) {
8
- "@babel/helpers - typeof";
7
+ function _inheritsLoose(subClass, superClass) {
8
+ subClass.prototype = Object.create(superClass.prototype);
9
+ subClass.prototype.constructor = subClass;
9
10
 
10
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
11
- return typeof obj;
12
- } : function (obj) {
13
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
14
- }, _typeof(obj);
15
- }
16
-
17
- function _classCallCheck(instance, Constructor) {
18
- if (!(instance instanceof Constructor)) {
19
- throw new TypeError("Cannot call a class as a function");
20
- }
21
- }
22
-
23
- function _defineProperties(target, props) {
24
- for (var i = 0; i < props.length; i++) {
25
- var descriptor = props[i];
26
- descriptor.enumerable = descriptor.enumerable || false;
27
- descriptor.configurable = true;
28
- if ("value" in descriptor) descriptor.writable = true;
29
- Object.defineProperty(target, descriptor.key, descriptor);
30
- }
31
- }
32
-
33
- function _createClass(Constructor, protoProps, staticProps) {
34
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
35
- if (staticProps) _defineProperties(Constructor, staticProps);
36
- Object.defineProperty(Constructor, "prototype", {
37
- writable: false
38
- });
39
- return Constructor;
40
- }
41
-
42
- function _inherits(subClass, superClass) {
43
- if (typeof superClass !== "function" && superClass !== null) {
44
- throw new TypeError("Super expression must either be null or a function");
45
- }
46
-
47
- subClass.prototype = Object.create(superClass && superClass.prototype, {
48
- constructor: {
49
- value: subClass,
50
- writable: true,
51
- configurable: true
52
- }
53
- });
54
- Object.defineProperty(subClass, "prototype", {
55
- writable: false
56
- });
57
- if (superClass) _setPrototypeOf(subClass, superClass);
58
- }
59
-
60
- function _getPrototypeOf(o) {
61
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
62
- return o.__proto__ || Object.getPrototypeOf(o);
63
- };
64
- return _getPrototypeOf(o);
11
+ _setPrototypeOf(subClass, superClass);
65
12
  }
66
13
 
67
14
  function _setPrototypeOf(o, p) {
@@ -73,56 +20,6 @@
73
20
  return _setPrototypeOf(o, p);
74
21
  }
75
22
 
76
- function _isNativeReflectConstruct() {
77
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
78
- if (Reflect.construct.sham) return false;
79
- if (typeof Proxy === "function") return true;
80
-
81
- try {
82
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
83
- return true;
84
- } catch (e) {
85
- return false;
86
- }
87
- }
88
-
89
- function _assertThisInitialized(self) {
90
- if (self === void 0) {
91
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
92
- }
93
-
94
- return self;
95
- }
96
-
97
- function _possibleConstructorReturn(self, call) {
98
- if (call && (typeof call === "object" || typeof call === "function")) {
99
- return call;
100
- } else if (call !== void 0) {
101
- throw new TypeError("Derived constructors may only return object or undefined");
102
- }
103
-
104
- return _assertThisInitialized(self);
105
- }
106
-
107
- function _createSuper(Derived) {
108
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
109
-
110
- return function _createSuperInternal() {
111
- var Super = _getPrototypeOf(Derived),
112
- result;
113
-
114
- if (hasNativeReflectConstruct) {
115
- var NewTarget = _getPrototypeOf(this).constructor;
116
-
117
- result = Reflect.construct(Super, arguments, NewTarget);
118
- } else {
119
- result = Super.apply(this, arguments);
120
- }
121
-
122
- return _possibleConstructorReturn(this, result);
123
- };
124
- }
125
-
126
23
  /******************************************************************************
127
24
  Copyright (c) Microsoft Corporation.
128
25
 
@@ -274,7 +171,7 @@
274
171
  if ("throw" !== record.type) {
275
172
  var result = record.arg,
276
173
  value = result.value;
277
- return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
174
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
278
175
  invoke("next", value, resolve, reject);
279
176
  }, function (err) {
280
177
  invoke("throw", err, resolve, reject);
@@ -535,31 +432,6 @@
535
432
  };
536
433
  }
537
434
 
538
- function _classCallCheck$1(instance, Constructor) {
539
- if (!(instance instanceof Constructor)) {
540
- throw new TypeError("Cannot call a class as a function");
541
- }
542
- }
543
-
544
- function _defineProperties$1(target, props) {
545
- for (var i = 0; i < props.length; i++) {
546
- var descriptor = props[i];
547
- descriptor.enumerable = descriptor.enumerable || false;
548
- descriptor.configurable = true;
549
- if ("value" in descriptor) descriptor.writable = true;
550
- Object.defineProperty(target, descriptor.key, descriptor);
551
- }
552
- }
553
-
554
- function _createClass$1(Constructor, protoProps, staticProps) {
555
- if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
556
- if (staticProps) _defineProperties$1(Constructor, staticProps);
557
- Object.defineProperty(Constructor, "prototype", {
558
- writable: false
559
- });
560
- return Constructor;
561
- }
562
-
563
435
  var _class;
564
436
 
565
437
  var DOMInteractionPlugin_1;
@@ -569,150 +441,147 @@
569
441
 
570
442
  var DOMInteractionPlugin = DOMInteractionPlugin_1 = (_class = /*#__PURE__*/function () {
571
443
  function DOMInteractionPlugin() {
572
- _classCallCheck$1(this, DOMInteractionPlugin);
573
-
574
444
  this.contextService = void 0;
575
445
  this.renderingContext = void 0;
576
446
  }
577
447
 
578
- _createClass$1(DOMInteractionPlugin, [{
579
- key: "apply",
580
- value: function apply(renderingService) {
581
- var _this = this;
582
-
583
- var canvas = this.renderingContext.root.ownerDocument.defaultView; // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
448
+ var _proto = DOMInteractionPlugin.prototype;
584
449
 
585
- var onPointerMove = function onPointerMove(ev) {
586
- renderingService.hooks.pointerMove.call(ev);
587
- };
450
+ _proto.apply = function apply(renderingService) {
451
+ var _this = this;
588
452
 
589
- var onPointerUp = function onPointerUp(ev) {
590
- renderingService.hooks.pointerUp.call(ev);
591
- };
453
+ var canvas = this.renderingContext.root.ownerDocument.defaultView; // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
592
454
 
593
- var onPointerDown = function onPointerDown(ev) {
594
- renderingService.hooks.pointerDown.call(ev);
595
- };
455
+ var onPointerMove = function onPointerMove(ev) {
456
+ renderingService.hooks.pointerMove.call(ev);
457
+ };
596
458
 
597
- var onPointerOver = function onPointerOver(ev) {
598
- renderingService.hooks.pointerOver.call(ev);
599
- };
459
+ var onPointerUp = function onPointerUp(ev) {
460
+ renderingService.hooks.pointerUp.call(ev);
461
+ };
600
462
 
601
- var onPointerOut = function onPointerOut(ev) {
602
- renderingService.hooks.pointerOut.call(ev);
603
- };
463
+ var onPointerDown = function onPointerDown(ev) {
464
+ renderingService.hooks.pointerDown.call(ev);
465
+ };
604
466
 
605
- var onPointerCancel = function onPointerCancel(ev) {
606
- renderingService.hooks.pointerCancel.call(ev);
607
- };
467
+ var onPointerOver = function onPointerOver(ev) {
468
+ renderingService.hooks.pointerOver.call(ev);
469
+ };
608
470
 
609
- var onPointerWheel = function onPointerWheel(ev) {
610
- renderingService.hooks.pointerWheel.call(ev);
611
- };
471
+ var onPointerOut = function onPointerOut(ev) {
472
+ renderingService.hooks.pointerOut.call(ev);
473
+ };
612
474
 
613
- var addPointerEventListener = function addPointerEventListener($el) {
614
- globalThis.document.addEventListener('pointermove', onPointerMove, true);
615
- $el.addEventListener('pointerdown', onPointerDown, true);
616
- $el.addEventListener('pointerleave', onPointerOut, true);
617
- $el.addEventListener('pointerover', onPointerOver, true);
618
- globalThis.addEventListener('pointerup', onPointerUp, true);
619
- };
475
+ var onPointerCancel = function onPointerCancel(ev) {
476
+ renderingService.hooks.pointerCancel.call(ev);
477
+ };
620
478
 
621
- var addTouchEventListener = function addTouchEventListener($el) {
622
- $el.addEventListener('touchstart', onPointerDown, true);
623
- $el.addEventListener('touchend', onPointerUp, true);
624
- $el.addEventListener('touchmove', onPointerMove, true);
625
- $el.addEventListener('touchcancel', onPointerCancel, true);
626
- };
479
+ var onPointerWheel = function onPointerWheel(ev) {
480
+ renderingService.hooks.pointerWheel.call(ev);
481
+ };
627
482
 
628
- var addMouseEventListener = function addMouseEventListener($el) {
629
- globalThis.document.addEventListener('mousemove', onPointerMove, true);
630
- $el.addEventListener('mousedown', onPointerDown, true);
631
- $el.addEventListener('mouseout', onPointerOut, true);
632
- $el.addEventListener('mouseover', onPointerOver, true);
633
- globalThis.addEventListener('mouseup', onPointerUp, true);
634
- };
483
+ var addPointerEventListener = function addPointerEventListener($el) {
484
+ globalThis.document.addEventListener('pointermove', onPointerMove, true);
485
+ $el.addEventListener('pointerdown', onPointerDown, true);
486
+ $el.addEventListener('pointerleave', onPointerOut, true);
487
+ $el.addEventListener('pointerover', onPointerOver, true);
488
+ globalThis.addEventListener('pointerup', onPointerUp, true);
489
+ };
635
490
 
636
- var removePointerEventListener = function removePointerEventListener($el) {
637
- globalThis.document.removeEventListener('pointermove', onPointerMove, true);
638
- $el.removeEventListener('pointerdown', onPointerDown, true);
639
- $el.removeEventListener('pointerleave', onPointerOut, true);
640
- $el.removeEventListener('pointerover', onPointerOver, true);
641
- globalThis.removeEventListener('pointerup', onPointerUp, true);
642
- };
491
+ var addTouchEventListener = function addTouchEventListener($el) {
492
+ $el.addEventListener('touchstart', onPointerDown, true);
493
+ $el.addEventListener('touchend', onPointerUp, true);
494
+ $el.addEventListener('touchmove', onPointerMove, true);
495
+ $el.addEventListener('touchcancel', onPointerCancel, true);
496
+ };
643
497
 
644
- var removeTouchEventListener = function removeTouchEventListener($el) {
645
- $el.removeEventListener('touchstart', onPointerDown, true);
646
- $el.removeEventListener('touchend', onPointerUp, true);
647
- $el.removeEventListener('touchmove', onPointerMove, true);
648
- };
498
+ var addMouseEventListener = function addMouseEventListener($el) {
499
+ globalThis.document.addEventListener('mousemove', onPointerMove, true);
500
+ $el.addEventListener('mousedown', onPointerDown, true);
501
+ $el.addEventListener('mouseout', onPointerOut, true);
502
+ $el.addEventListener('mouseover', onPointerOver, true);
503
+ globalThis.addEventListener('mouseup', onPointerUp, true);
504
+ };
649
505
 
650
- var removeMouseEventListener = function removeMouseEventListener($el) {
651
- globalThis.document.removeEventListener('mousemove', onPointerMove, true);
652
- $el.removeEventListener('mousedown', onPointerDown, true);
653
- $el.removeEventListener('mouseout', onPointerOut, true);
654
- $el.removeEventListener('mouseover', onPointerOver, true);
655
- globalThis.removeEventListener('mouseup', onPointerUp, true);
656
- };
506
+ var removePointerEventListener = function removePointerEventListener($el) {
507
+ globalThis.document.removeEventListener('pointermove', onPointerMove, true);
508
+ $el.removeEventListener('pointerdown', onPointerDown, true);
509
+ $el.removeEventListener('pointerleave', onPointerOut, true);
510
+ $el.removeEventListener('pointerover', onPointerOver, true);
511
+ globalThis.removeEventListener('pointerup', onPointerUp, true);
512
+ };
657
513
 
658
- renderingService.hooks.init.tapPromise(DOMInteractionPlugin_1.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
659
- var $el;
660
- return _regeneratorRuntime().wrap(function _callee$(_context) {
661
- while (1) {
662
- switch (_context.prev = _context.next) {
663
- case 0:
664
- $el = _this.contextService.getDomElement(); // @ts-ignore
514
+ var removeTouchEventListener = function removeTouchEventListener($el) {
515
+ $el.removeEventListener('touchstart', onPointerDown, true);
516
+ $el.removeEventListener('touchend', onPointerUp, true);
517
+ $el.removeEventListener('touchmove', onPointerMove, true);
518
+ };
665
519
 
666
- if (globalThis.navigator.msPointerEnabled) {
667
- // @ts-ignore
668
- $el.style.msContentZooming = 'none'; // @ts-ignore
520
+ var removeMouseEventListener = function removeMouseEventListener($el) {
521
+ globalThis.document.removeEventListener('mousemove', onPointerMove, true);
522
+ $el.removeEventListener('mousedown', onPointerDown, true);
523
+ $el.removeEventListener('mouseout', onPointerOut, true);
524
+ $el.removeEventListener('mouseover', onPointerOver, true);
525
+ globalThis.removeEventListener('mouseup', onPointerUp, true);
526
+ };
669
527
 
670
- $el.style.msTouchAction = 'none';
671
- } else if (canvas.supportsPointerEvents) {
672
- $el.style.touchAction = 'none';
673
- }
528
+ renderingService.hooks.init.tapPromise(DOMInteractionPlugin_1.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
529
+ var $el;
530
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
531
+ while (1) {
532
+ switch (_context.prev = _context.next) {
533
+ case 0:
534
+ $el = _this.contextService.getDomElement(); // @ts-ignore
535
+
536
+ if (globalThis.navigator.msPointerEnabled) {
537
+ // @ts-ignore
538
+ $el.style.msContentZooming = 'none'; // @ts-ignore
539
+
540
+ $el.style.msTouchAction = 'none';
541
+ } else if (canvas.supportsPointerEvents) {
542
+ $el.style.touchAction = 'none';
543
+ }
674
544
 
675
- if (canvas.supportsPointerEvents) {
676
- addPointerEventListener($el);
677
- } else {
678
- addMouseEventListener($el);
679
- }
545
+ if (canvas.supportsPointerEvents) {
546
+ addPointerEventListener($el);
547
+ } else {
548
+ addMouseEventListener($el);
549
+ }
680
550
 
681
- if (canvas.supportsTouchEvents) {
682
- addTouchEventListener($el);
683
- } // use passive event listeners
684
- // @see https://zhuanlan.zhihu.com/p/24555031
551
+ if (canvas.supportsTouchEvents) {
552
+ addTouchEventListener($el);
553
+ } // use passive event listeners
554
+ // @see https://zhuanlan.zhihu.com/p/24555031
685
555
 
686
556
 
687
- $el.addEventListener('wheel', onPointerWheel, {
688
- passive: true,
689
- capture: true
690
- });
557
+ $el.addEventListener('wheel', onPointerWheel, {
558
+ passive: true,
559
+ capture: true
560
+ });
691
561
 
692
- case 5:
693
- case "end":
694
- return _context.stop();
695
- }
562
+ case 5:
563
+ case "end":
564
+ return _context.stop();
696
565
  }
697
- }, _callee);
698
- })));
699
- renderingService.hooks.destroy.tap(DOMInteractionPlugin_1.tag, function () {
700
- var $el = _this.contextService.getDomElement();
701
-
702
- if (canvas.supportsPointerEvents) {
703
- removePointerEventListener($el);
704
- } else {
705
- removeMouseEventListener($el);
706
566
  }
567
+ }, _callee);
568
+ })));
569
+ renderingService.hooks.destroy.tap(DOMInteractionPlugin_1.tag, function () {
570
+ var $el = _this.contextService.getDomElement();
707
571
 
708
- if (canvas.supportsTouchEvents) {
709
- removeTouchEventListener($el);
710
- }
572
+ if (canvas.supportsPointerEvents) {
573
+ removePointerEventListener($el);
574
+ } else {
575
+ removeMouseEventListener($el);
576
+ }
711
577
 
712
- $el.removeEventListener('wheel', onPointerWheel, true);
713
- });
714
- }
715
- }]);
578
+ if (canvas.supportsTouchEvents) {
579
+ removeTouchEventListener($el);
580
+ }
581
+
582
+ $el.removeEventListener('wheel', onPointerWheel, true);
583
+ });
584
+ };
716
585
 
717
586
  return DOMInteractionPlugin;
718
587
  }(), _class.tag = 'DOMInteraction', _class);
@@ -730,22 +599,18 @@
730
599
 
731
600
  var Plugin = /*#__PURE__*/function () {
732
601
  function Plugin() {
733
- _classCallCheck$1(this, Plugin);
734
-
735
602
  this.name = 'dom-interaction';
736
603
  }
737
604
 
738
- _createClass$1(Plugin, [{
739
- key: "init",
740
- value: function init(container) {
741
- container.load(containerModule, true);
742
- }
743
- }, {
744
- key: "destroy",
745
- value: function destroy(container) {
746
- container.unload(containerModule);
747
- }
748
- }]);
605
+ var _proto = Plugin.prototype;
606
+
607
+ _proto.init = function init(container) {
608
+ container.load(containerModule, true);
609
+ };
610
+
611
+ _proto.destroy = function destroy(container) {
612
+ container.unload(containerModule);
613
+ };
749
614
 
750
615
  return Plugin;
751
616
  }();
@@ -1320,32 +1185,6 @@
1320
1185
  }
1321
1186
  }
1322
1187
 
1323
- function ownKeys(object, enumerableOnly) {
1324
- var keys = Object.keys(object);
1325
-
1326
- if (Object.getOwnPropertySymbols) {
1327
- var symbols = Object.getOwnPropertySymbols(object);
1328
- enumerableOnly && (symbols = symbols.filter(function (sym) {
1329
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1330
- })), keys.push.apply(keys, symbols);
1331
- }
1332
-
1333
- return keys;
1334
- }
1335
-
1336
- function _objectSpread2(target) {
1337
- for (var i = 1; i < arguments.length; i++) {
1338
- var source = null != arguments[i] ? arguments[i] : {};
1339
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
1340
- _defineProperty(target, key, source[key]);
1341
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
1342
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1343
- });
1344
- }
1345
-
1346
- return target;
1347
- }
1348
-
1349
1188
  function _regeneratorRuntime$1() {
1350
1189
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
1351
1190
  _regeneratorRuntime$1 = function _regeneratorRuntime() {
@@ -1471,7 +1310,7 @@
1471
1310
  if ("throw" !== record.type) {
1472
1311
  var result = record.arg,
1473
1312
  value = result.value;
1474
- return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
1313
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
1475
1314
  invoke("next", value, resolve, reject);
1476
1315
  }, function (err) {
1477
1316
  invoke("throw", err, resolve, reject);
@@ -1732,69 +1571,29 @@
1732
1571
  };
1733
1572
  }
1734
1573
 
1735
- function _classCallCheck$2(instance, Constructor) {
1736
- if (!(instance instanceof Constructor)) {
1737
- throw new TypeError("Cannot call a class as a function");
1738
- }
1739
- }
1740
-
1741
- function _defineProperties$2(target, props) {
1742
- for (var i = 0; i < props.length; i++) {
1743
- var descriptor = props[i];
1744
- descriptor.enumerable = descriptor.enumerable || false;
1745
- descriptor.configurable = true;
1746
- if ("value" in descriptor) descriptor.writable = true;
1747
- Object.defineProperty(target, descriptor.key, descriptor);
1748
- }
1749
- }
1574
+ function _extends() {
1575
+ _extends = Object.assign || function (target) {
1576
+ for (var i = 1; i < arguments.length; i++) {
1577
+ var source = arguments[i];
1750
1578
 
1751
- function _createClass$2(Constructor, protoProps, staticProps) {
1752
- if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
1753
- if (staticProps) _defineProperties$2(Constructor, staticProps);
1754
- Object.defineProperty(Constructor, "prototype", {
1755
- writable: false
1756
- });
1757
- return Constructor;
1758
- }
1579
+ for (var key in source) {
1580
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1581
+ target[key] = source[key];
1582
+ }
1583
+ }
1584
+ }
1759
1585
 
1760
- function _defineProperty(obj, key, value) {
1761
- if (key in obj) {
1762
- Object.defineProperty(obj, key, {
1763
- value: value,
1764
- enumerable: true,
1765
- configurable: true,
1766
- writable: true
1767
- });
1768
- } else {
1769
- obj[key] = value;
1770
- }
1586
+ return target;
1587
+ };
1771
1588
 
1772
- return obj;
1589
+ return _extends.apply(this, arguments);
1773
1590
  }
1774
1591
 
1775
- function _inherits$1(subClass, superClass) {
1776
- if (typeof superClass !== "function" && superClass !== null) {
1777
- throw new TypeError("Super expression must either be null or a function");
1778
- }
1779
-
1780
- subClass.prototype = Object.create(superClass && superClass.prototype, {
1781
- constructor: {
1782
- value: subClass,
1783
- writable: true,
1784
- configurable: true
1785
- }
1786
- });
1787
- Object.defineProperty(subClass, "prototype", {
1788
- writable: false
1789
- });
1790
- if (superClass) _setPrototypeOf$1(subClass, superClass);
1791
- }
1592
+ function _inheritsLoose$1(subClass, superClass) {
1593
+ subClass.prototype = Object.create(superClass.prototype);
1594
+ subClass.prototype.constructor = subClass;
1792
1595
 
1793
- function _getPrototypeOf$1(o) {
1794
- _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
1795
- return o.__proto__ || Object.getPrototypeOf(o);
1796
- };
1797
- return _getPrototypeOf$1(o);
1596
+ _setPrototypeOf$1(subClass, superClass);
1798
1597
  }
1799
1598
 
1800
1599
  function _setPrototypeOf$1(o, p) {
@@ -1805,133 +1604,6 @@
1805
1604
 
1806
1605
  return _setPrototypeOf$1(o, p);
1807
1606
  }
1808
-
1809
- function _isNativeReflectConstruct$1() {
1810
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
1811
- if (Reflect.construct.sham) return false;
1812
- if (typeof Proxy === "function") return true;
1813
-
1814
- try {
1815
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
1816
- return true;
1817
- } catch (e) {
1818
- return false;
1819
- }
1820
- }
1821
-
1822
- function _assertThisInitialized$1(self) {
1823
- if (self === void 0) {
1824
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1825
- }
1826
-
1827
- return self;
1828
- }
1829
-
1830
- function _possibleConstructorReturn$1(self, call) {
1831
- if (call && (_typeof(call) === "object" || typeof call === "function")) {
1832
- return call;
1833
- } else if (call !== void 0) {
1834
- throw new TypeError("Derived constructors may only return object or undefined");
1835
- }
1836
-
1837
- return _assertThisInitialized$1(self);
1838
- }
1839
-
1840
- function _createSuper$1(Derived) {
1841
- var hasNativeReflectConstruct = _isNativeReflectConstruct$1();
1842
-
1843
- return function _createSuperInternal() {
1844
- var Super = _getPrototypeOf$1(Derived),
1845
- result;
1846
-
1847
- if (hasNativeReflectConstruct) {
1848
- var NewTarget = _getPrototypeOf$1(this).constructor;
1849
-
1850
- result = Reflect.construct(Super, arguments, NewTarget);
1851
- } else {
1852
- result = Super.apply(this, arguments);
1853
- }
1854
-
1855
- return _possibleConstructorReturn$1(this, result);
1856
- };
1857
- }
1858
-
1859
- function _slicedToArray(arr, i) {
1860
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
1861
- }
1862
-
1863
- function _toConsumableArray(arr) {
1864
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
1865
- }
1866
-
1867
- function _arrayWithoutHoles(arr) {
1868
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
1869
- }
1870
-
1871
- function _arrayWithHoles(arr) {
1872
- if (Array.isArray(arr)) return arr;
1873
- }
1874
-
1875
- function _iterableToArray(iter) {
1876
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
1877
- }
1878
-
1879
- function _iterableToArrayLimit(arr, i) {
1880
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1881
-
1882
- if (_i == null) return;
1883
- var _arr = [];
1884
- var _n = true;
1885
- var _d = false;
1886
-
1887
- var _s, _e;
1888
-
1889
- try {
1890
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
1891
- _arr.push(_s.value);
1892
-
1893
- if (i && _arr.length === i) break;
1894
- }
1895
- } catch (err) {
1896
- _d = true;
1897
- _e = err;
1898
- } finally {
1899
- try {
1900
- if (!_n && _i["return"] != null) _i["return"]();
1901
- } finally {
1902
- if (_d) throw _e;
1903
- }
1904
- }
1905
-
1906
- return _arr;
1907
- }
1908
-
1909
- function _unsupportedIterableToArray(o, minLen) {
1910
- if (!o) return;
1911
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
1912
- var n = Object.prototype.toString.call(o).slice(8, -1);
1913
- if (n === "Object" && o.constructor) n = o.constructor.name;
1914
- if (n === "Map" || n === "Set") return Array.from(o);
1915
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
1916
- }
1917
-
1918
- function _arrayLikeToArray(arr, len) {
1919
- if (len == null || len > arr.length) len = arr.length;
1920
-
1921
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
1922
- arr2[i] = arr[i];
1923
- }
1924
-
1925
- return arr2;
1926
- }
1927
-
1928
- function _nonIterableSpread() {
1929
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1930
- }
1931
-
1932
- function _nonIterableRest() {
1933
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1934
- }
1935
1607
  /**
1936
1608
  * Common utilities
1937
1609
  * @module glMatrix
@@ -2591,82 +2263,74 @@
2591
2263
  };
2592
2264
  }();
2593
2265
 
2594
- var RBushNode = /*#__PURE__*/_createClass$2(function RBushNode() {
2595
- _classCallCheck$2(this, RBushNode);
2596
-
2266
+ var RBushNode = function RBushNode() {
2597
2267
  this.aabb = void 0;
2598
- });
2268
+ };
2599
2269
 
2600
2270
  RBushNode.tag = 'c-canvas-rbush-node';
2601
2271
 
2602
2272
  var GradientPool = /*#__PURE__*/function () {
2603
2273
  function GradientPool() {
2604
- _classCallCheck$2(this, GradientPool);
2605
-
2606
2274
  this.gradientCache = {};
2607
2275
  }
2608
2276
 
2609
- _createClass$2(GradientPool, [{
2610
- key: "getOrCreateGradient",
2611
- value: function getOrCreateGradient(params, context) {
2612
- var key = this.generateCacheKey(params);
2613
- var type = params.type,
2614
- x0 = params.x0,
2615
- y0 = params.y0,
2616
- x1 = params.x1,
2617
- y1 = params.y1,
2618
- steps = params.steps,
2619
- width = params.width,
2620
- height = params.height;
2621
-
2622
- if (this.gradientCache[key]) {
2623
- return this.gradientCache[key];
2624
- }
2277
+ var _proto = GradientPool.prototype;
2625
2278
 
2626
- var gradient = null;
2279
+ _proto.getOrCreateGradient = function getOrCreateGradient(params, context) {
2280
+ var key = this.generateCacheKey(params);
2281
+ var type = params.type,
2282
+ x0 = params.x0,
2283
+ y0 = params.y0,
2284
+ x1 = params.x1,
2285
+ y1 = params.y1,
2286
+ steps = params.steps,
2287
+ width = params.width,
2288
+ height = params.height;
2627
2289
 
2628
- if (type === g.GradientPatternType.LinearGradient) {
2629
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
2630
- gradient = context.createLinearGradient(x0 * width, y0 * height, x1 * width, y1 * height);
2631
- } else if (type === g.GradientPatternType.RadialGradient) {
2632
- var r = Math.sqrt(width * width + height * height) / 2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
2290
+ if (this.gradientCache[key]) {
2291
+ return this.gradientCache[key];
2292
+ }
2633
2293
 
2634
- gradient = context.createRadialGradient(x0 * width, y0 * height, 0, x1 * width, y1 * height, params.r1 * r);
2635
- }
2294
+ var gradient = null;
2636
2295
 
2637
- if (gradient) {
2638
- steps.forEach(function (_ref) {
2639
- var _gradient;
2296
+ if (type === g.GradientPatternType.LinearGradient) {
2297
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
2298
+ gradient = context.createLinearGradient(x0 * width, y0 * height, x1 * width, y1 * height);
2299
+ } else if (type === g.GradientPatternType.RadialGradient) {
2300
+ var r = Math.sqrt(width * width + height * height) / 2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
2640
2301
 
2641
- var _ref2 = _slicedToArray(_ref, 2),
2642
- offset = _ref2[0],
2643
- color = _ref2[1];
2302
+ gradient = context.createRadialGradient(x0 * width, y0 * height, 0, x1 * width, y1 * height, params.r1 * r);
2303
+ }
2644
2304
 
2645
- (_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(Number(offset), color);
2646
- });
2647
- this.gradientCache[key] = gradient;
2648
- }
2305
+ if (gradient) {
2306
+ steps.forEach(function (_ref) {
2307
+ var _gradient;
2649
2308
 
2650
- return this.gradientCache[key];
2309
+ var offset = _ref[0],
2310
+ color = _ref[1];
2311
+ (_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(Number(offset), color);
2312
+ });
2313
+ this.gradientCache[key] = gradient;
2651
2314
  }
2652
- }, {
2653
- key: "generateCacheKey",
2654
- value: function generateCacheKey(params) {
2655
- // @ts-ignore
2656
- var type = params.type,
2657
- x0 = params.x0,
2658
- y0 = params.y0,
2659
- x1 = params.x1,
2660
- y1 = params.y1,
2661
- r1 = params.r1,
2662
- steps = params.steps,
2663
- width = params.width,
2664
- height = params.height;
2665
- return "gradient-".concat(type, "-").concat(x0, "-").concat(y0, "-").concat(x1, "-").concat(y1, "-").concat(r1 || 0, "-").concat(width, "-").concat(height, "-").concat(steps.map(function (step) {
2666
- return step.join('');
2667
- }).join('-'));
2668
- }
2669
- }]);
2315
+
2316
+ return this.gradientCache[key];
2317
+ };
2318
+
2319
+ _proto.generateCacheKey = function generateCacheKey(params) {
2320
+ // @ts-ignore
2321
+ var type = params.type,
2322
+ x0 = params.x0,
2323
+ y0 = params.y0,
2324
+ x1 = params.x1,
2325
+ y1 = params.y1,
2326
+ r1 = params.r1,
2327
+ steps = params.steps,
2328
+ width = params.width,
2329
+ height = params.height;
2330
+ return "gradient-" + type + "-" + x0 + "-" + y0 + "-" + x1 + "-" + y1 + "-" + (r1 || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
2331
+ return step.join('');
2332
+ }).join('-');
2333
+ };
2670
2334
 
2671
2335
  return GradientPool;
2672
2336
  }();
@@ -2675,88 +2339,81 @@
2675
2339
 
2676
2340
  var ImagePool = /*#__PURE__*/function () {
2677
2341
  function ImagePool() {
2678
- _classCallCheck$2(this, ImagePool);
2679
-
2680
2342
  this.imageCache = {};
2681
2343
  this.patternCache = {};
2682
2344
  this.canvasConfig = void 0;
2683
2345
  }
2684
2346
 
2685
- _createClass$2(ImagePool, [{
2686
- key: "getImageSync",
2687
- value: function getImageSync(src) {
2688
- return this.imageCache[src];
2689
- }
2690
- }, {
2691
- key: "getOrCreateImage",
2692
- value: function getOrCreateImage(src) {
2693
- var _this = this;
2347
+ var _proto = ImagePool.prototype;
2348
+
2349
+ _proto.getImageSync = function getImageSync(src) {
2350
+ return this.imageCache[src];
2351
+ };
2694
2352
 
2695
- if (this.imageCache[src]) {
2696
- return Promise.resolve(this.imageCache[src]);
2697
- } // @see https://github.com/antvis/g/issues/938
2353
+ _proto.getOrCreateImage = function getOrCreateImage(src) {
2354
+ var _this = this;
2698
2355
 
2356
+ if (this.imageCache[src]) {
2357
+ return Promise.resolve(this.imageCache[src]);
2358
+ } // @see https://github.com/antvis/g/issues/938
2699
2359
 
2700
- var createImage = this.canvasConfig.createImage;
2701
- return new Promise(function (resolve, reject) {
2702
- var image;
2703
2360
 
2704
- if (createImage) {
2705
- image = createImage(src);
2706
- } else if (g.isBrowser) {
2707
- image = new window.Image();
2708
- }
2361
+ var createImage = this.canvasConfig.createImage;
2362
+ return new Promise(function (resolve, reject) {
2363
+ var image;
2709
2364
 
2710
- if (image) {
2711
- image.onload = function () {
2712
- resolve(image);
2713
- };
2365
+ if (createImage) {
2366
+ image = createImage(src);
2367
+ } else if (g.isBrowser) {
2368
+ image = new window.Image();
2369
+ }
2714
2370
 
2715
- image.onerror = function (ev) {
2716
- reject(ev);
2717
- };
2371
+ if (image) {
2372
+ image.onload = function () {
2373
+ resolve(image);
2374
+ };
2718
2375
 
2719
- image.crossOrigin = 'Anonymous';
2720
- image.src = src;
2721
- _this.imageCache[src] = image;
2722
- }
2723
- });
2724
- }
2725
- }, {
2726
- key: "getPatternSync",
2727
- value: function getPatternSync(pattern) {
2728
- var patternKey = this.generatePatternKey(pattern);
2376
+ image.onerror = function (ev) {
2377
+ reject(ev);
2378
+ };
2729
2379
 
2730
- if (this.patternCache[patternKey]) {
2731
- return this.patternCache[patternKey];
2380
+ image.crossOrigin = 'Anonymous';
2381
+ image.src = src;
2382
+ _this.imageCache[src] = image;
2732
2383
  }
2384
+ });
2385
+ };
2386
+
2387
+ _proto.getPatternSync = function getPatternSync(pattern) {
2388
+ var patternKey = this.generatePatternKey(pattern);
2389
+
2390
+ if (this.patternCache[patternKey]) {
2391
+ return this.patternCache[patternKey];
2733
2392
  }
2734
- }, {
2735
- key: "createPattern",
2736
- value: function createPattern(patternParams, context) {
2737
- var _this2 = this;
2393
+ };
2738
2394
 
2739
- return this.getOrCreateImage(patternParams.src).then(function (image) {
2740
- var patternKey = _this2.generatePatternKey(patternParams); // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
2395
+ _proto.createPattern = function createPattern(patternParams, context) {
2396
+ var _this2 = this;
2741
2397
 
2398
+ return this.getOrCreateImage(patternParams.src).then(function (image) {
2399
+ var patternKey = _this2.generatePatternKey(patternParams); // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
2742
2400
 
2743
- var pattern = context.createPattern(image, patternParams.repetition);
2744
2401
 
2745
- if (pattern) {
2746
- _this2.patternCache[patternKey] = pattern;
2747
- }
2402
+ var pattern = context.createPattern(image, patternParams.repetition);
2748
2403
 
2749
- return _this2.patternCache[patternKey];
2750
- });
2751
- }
2752
- }, {
2753
- key: "generatePatternKey",
2754
- value: function generatePatternKey(pattern) {
2755
- var src = pattern.src,
2756
- repetition = pattern.repetition;
2757
- return "pattern-".concat(src, "-").concat(repetition);
2758
- }
2759
- }]);
2404
+ if (pattern) {
2405
+ _this2.patternCache[patternKey] = pattern;
2406
+ }
2407
+
2408
+ return _this2.patternCache[patternKey];
2409
+ });
2410
+ };
2411
+
2412
+ _proto.generatePatternKey = function generatePatternKey(pattern) {
2413
+ var src = pattern.src,
2414
+ repetition = pattern.repetition;
2415
+ return "pattern-" + src + "-" + repetition;
2416
+ };
2760
2417
 
2761
2418
  return ImagePool;
2762
2419
  }();
@@ -2805,11 +2462,10 @@
2805
2462
  var _radius$map = radius.map(function (r) {
2806
2463
  return r.value;
2807
2464
  }),
2808
- _radius$map2 = _slicedToArray(_radius$map, 4),
2809
- r1 = _radius$map2[0],
2810
- r2 = _radius$map2[1],
2811
- r3 = _radius$map2[2],
2812
- r4 = _radius$map2[3];
2465
+ r1 = _radius$map[0],
2466
+ r2 = _radius$map[1],
2467
+ r3 = _radius$map[2],
2468
+ r4 = _radius$map[3];
2813
2469
 
2814
2470
  context.moveTo(r1, 0);
2815
2471
  context.lineTo(w - r2, 0);
@@ -2901,9 +2557,7 @@
2901
2557
  var _parsedStyle$path = parsedStyle.path,
2902
2558
  curve = _parsedStyle$path.curve,
2903
2559
  zCommandIndexes = _parsedStyle$path.zCommandIndexes;
2904
-
2905
- var path = _toConsumableArray(curve);
2906
-
2560
+ var path = [].concat(curve);
2907
2561
  zCommandIndexes.forEach(function (zIndex, index) {
2908
2562
  path.splice(zIndex + index, 1, ['Z']);
2909
2563
  });
@@ -2962,44 +2616,40 @@
2962
2616
 
2963
2617
  var ImageRenderer = /*#__PURE__*/function () {
2964
2618
  function ImageRenderer() {
2965
- _classCallCheck$2(this, ImageRenderer);
2966
-
2967
2619
  this.imagePool = void 0;
2968
2620
  }
2969
2621
 
2970
- _createClass$2(ImageRenderer, [{
2971
- key: "hash",
2972
- value: function hash(parsedStyle) {
2973
- return '';
2974
- }
2975
- }, {
2976
- key: "render",
2977
- value: function render(context, parsedStyle) {
2978
- var width = parsedStyle.width,
2979
- height = parsedStyle.height,
2980
- img = parsedStyle.img;
2981
- var image;
2982
- var iw = width.value;
2983
- var ih = height.value;
2622
+ var _proto = ImageRenderer.prototype;
2984
2623
 
2985
- if (g.isString(img)) {
2986
- // image has been loaded in `mounted` hook
2987
- image = this.imagePool.getImageSync(img);
2988
- } else {
2989
- iw || (iw = img.width);
2990
- ih || (ih = img.height);
2991
- image = img;
2992
- }
2624
+ _proto.hash = function hash(parsedStyle) {
2625
+ return '';
2626
+ };
2993
2627
 
2994
- if (image) {
2995
- // node-canvas will throw the following err:
2996
- // Error: Image given has not completed loading
2997
- try {
2998
- context.drawImage(image, 0, 0, iw, ih);
2999
- } catch (e) {}
3000
- }
2628
+ _proto.render = function render(context, parsedStyle) {
2629
+ var width = parsedStyle.width,
2630
+ height = parsedStyle.height,
2631
+ img = parsedStyle.img;
2632
+ var image;
2633
+ var iw = width.value;
2634
+ var ih = height.value;
2635
+
2636
+ if (g.isString(img)) {
2637
+ // image has been loaded in `mounted` hook
2638
+ image = this.imagePool.getImageSync(img);
2639
+ } else {
2640
+ iw || (iw = img.width);
2641
+ ih || (ih = img.height);
2642
+ image = img;
2643
+ }
2644
+
2645
+ if (image) {
2646
+ // node-canvas will throw the following err:
2647
+ // Error: Image given has not completed loading
2648
+ try {
2649
+ context.drawImage(image, 0, 0, iw, ih);
2650
+ } catch (e) {}
3001
2651
  }
3002
- }]);
2652
+ };
3003
2653
 
3004
2654
  return ImageRenderer;
3005
2655
  }();
@@ -3011,162 +2661,158 @@
3011
2661
  })], ImageRenderer);
3012
2662
 
3013
2663
  var TextRenderer = /*#__PURE__*/function () {
3014
- function TextRenderer() {
3015
- _classCallCheck$2(this, TextRenderer);
3016
- }
3017
-
3018
- _createClass$2(TextRenderer, [{
3019
- key: "hash",
3020
- value: function hash(parsedStyle) {
3021
- return '';
3022
- }
3023
- }, {
3024
- key: "render",
3025
- value: function render(context, parsedStyle, object) {
3026
- var lineWidth = parsedStyle.lineWidth,
3027
- textAlign = parsedStyle.textAlign,
3028
- textBaseline = parsedStyle.textBaseline,
3029
- lineJoin = parsedStyle.lineJoin,
3030
- _parsedStyle$miterLim = parsedStyle.miterLimit,
3031
- miterLimit = _parsedStyle$miterLim === void 0 ? 0 : _parsedStyle$miterLim,
3032
- _parsedStyle$letterSp = parsedStyle.letterSpacing,
3033
- letterSpacing = _parsedStyle$letterSp === void 0 ? 0 : _parsedStyle$letterSp,
3034
- stroke = parsedStyle.stroke,
3035
- fill = parsedStyle.fill,
3036
- fillOpacity = parsedStyle.fillOpacity,
3037
- strokeOpacity = parsedStyle.strokeOpacity,
3038
- opacity = parsedStyle.opacity,
3039
- metrics = parsedStyle.metrics,
3040
- dx = parsedStyle.dx,
3041
- dy = parsedStyle.dy;
3042
- var font = metrics.font,
3043
- lines = metrics.lines,
3044
- height = metrics.height,
3045
- lineHeight = metrics.lineHeight,
3046
- lineMetrics = metrics.lineMetrics;
3047
- context.font = font;
3048
- context.lineWidth = lineWidth.value;
3049
- context.textAlign = textAlign.value;
3050
- context.textBaseline = textBaseline.value;
3051
- context.lineJoin = lineJoin.value;
3052
- context.miterLimit = miterLimit;
3053
- var linePositionY = 0; // handle vertical text baseline
3054
-
3055
- if (textBaseline.value === 'middle') {
3056
- linePositionY = -height / 2 - lineHeight / 2;
3057
- } else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
3058
- linePositionY = -height;
3059
- } else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
3060
- linePositionY = -lineHeight;
3061
- } // account for dx & dy
3062
-
3063
-
3064
- var offsetX = 0;
3065
-
3066
- if (dx && dx.unit === g.UnitType.kPixels) {
3067
- offsetX += dx.value;
3068
- }
3069
-
3070
- if (dy && dy.unit === g.UnitType.kPixels) {
3071
- linePositionY += dy.value;
3072
- } // draw lines line by line
2664
+ function TextRenderer() {}
3073
2665
 
2666
+ var _proto = TextRenderer.prototype;
3074
2667
 
3075
- for (var i = 0; i < lines.length; i++) {
3076
- var linePositionX = lineWidth.value / 2 + offsetX;
3077
- linePositionY += lineHeight; // no need to re-position X, cause we already set text align
3078
- // @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign
2668
+ _proto.hash = function hash(parsedStyle) {
2669
+ return '';
2670
+ };
3079
2671
 
3080
- if (!g.isNil(stroke) && !stroke.isNone && lineWidth && lineWidth.value) {
3081
- this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value, true);
3082
- }
2672
+ _proto.render = function render(context, parsedStyle, object) {
2673
+ var lineWidth = parsedStyle.lineWidth,
2674
+ textAlign = parsedStyle.textAlign,
2675
+ textBaseline = parsedStyle.textBaseline,
2676
+ lineJoin = parsedStyle.lineJoin,
2677
+ _parsedStyle$miterLim = parsedStyle.miterLimit,
2678
+ miterLimit = _parsedStyle$miterLim === void 0 ? 0 : _parsedStyle$miterLim,
2679
+ _parsedStyle$letterSp = parsedStyle.letterSpacing,
2680
+ letterSpacing = _parsedStyle$letterSp === void 0 ? 0 : _parsedStyle$letterSp,
2681
+ stroke = parsedStyle.stroke,
2682
+ fill = parsedStyle.fill,
2683
+ fillOpacity = parsedStyle.fillOpacity,
2684
+ strokeOpacity = parsedStyle.strokeOpacity,
2685
+ opacity = parsedStyle.opacity,
2686
+ metrics = parsedStyle.metrics,
2687
+ dx = parsedStyle.dx,
2688
+ dy = parsedStyle.dy;
2689
+ var font = metrics.font,
2690
+ lines = metrics.lines,
2691
+ height = metrics.height,
2692
+ lineHeight = metrics.lineHeight,
2693
+ lineMetrics = metrics.lineMetrics;
2694
+ context.font = font;
2695
+ context.lineWidth = lineWidth.value;
2696
+ context.textAlign = textAlign.value;
2697
+ context.textBaseline = textBaseline.value;
2698
+ context.lineJoin = lineJoin.value;
2699
+ context.miterLimit = miterLimit;
2700
+ var linePositionY = 0; // handle vertical text baseline
2701
+
2702
+ if (textBaseline.value === 'middle') {
2703
+ linePositionY = -height / 2 - lineHeight / 2;
2704
+ } else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
2705
+ linePositionY = -height;
2706
+ } else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
2707
+ linePositionY = -lineHeight;
2708
+ } // account for dx & dy
2709
+
2710
+
2711
+ var offsetX = 0;
2712
+
2713
+ if (dx && dx.unit === g.UnitType.kPixels) {
2714
+ offsetX += dx.value;
2715
+ }
2716
+
2717
+ if (dy && dy.unit === g.UnitType.kPixels) {
2718
+ linePositionY += dy.value;
2719
+ } // draw lines line by line
2720
+
2721
+
2722
+ for (var i = 0; i < lines.length; i++) {
2723
+ var linePositionX = lineWidth.value / 2 + offsetX;
2724
+ linePositionY += lineHeight; // no need to re-position X, cause we already set text align
2725
+ // @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign
2726
+
2727
+ if (!g.isNil(stroke) && !stroke.isNone && lineWidth && lineWidth.value) {
2728
+ this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value, true);
2729
+ }
3083
2730
 
3084
- if (!g.isNil(fill)) {
3085
- this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value);
3086
- }
2731
+ if (!g.isNil(fill)) {
2732
+ this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value);
3087
2733
  }
3088
2734
  }
3089
- }, {
3090
- key: "drawLetterSpacing",
3091
- value: function drawLetterSpacing(context, text, lineMetrics, textAlign, x, y, letterSpacing, fillOpacity, strokeOpacity, opacity) {
3092
- var isStroke = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : false; // letterSpacing of 0 means normal, render all texts directly
2735
+ };
3093
2736
 
3094
- if (letterSpacing === 0) {
3095
- if (isStroke) {
3096
- this.strokeText(context, text, x, y, strokeOpacity);
3097
- } else {
3098
- this.fillText(context, text, x, y, fillOpacity, opacity);
3099
- }
2737
+ _proto.drawLetterSpacing = function drawLetterSpacing(context, text, lineMetrics, textAlign, x, y, letterSpacing, fillOpacity, strokeOpacity, opacity, isStroke) {
2738
+ if (isStroke === void 0) {
2739
+ isStroke = false;
2740
+ } // letterSpacing of 0 means normal, render all texts directly
3100
2741
 
3101
- return;
3102
- } // draw text using left align
3103
2742
 
2743
+ if (letterSpacing === 0) {
2744
+ if (isStroke) {
2745
+ this.strokeText(context, text, x, y, strokeOpacity);
2746
+ } else {
2747
+ this.fillText(context, text, x, y, fillOpacity, opacity);
2748
+ }
3104
2749
 
3105
- var currentTextAlign = context.textAlign;
3106
- context.textAlign = 'left';
3107
- var currentPosition = x;
2750
+ return;
2751
+ } // draw text using left align
3108
2752
 
3109
- if (textAlign === 'center') {
3110
- currentPosition = x - lineMetrics.width / 2;
3111
- } else if (textAlign === 'right' || textAlign === 'end') {
3112
- currentPosition = x - lineMetrics.width;
3113
- }
3114
2753
 
3115
- var stringArray = Array.from(text);
3116
- var previousWidth = context.measureText(text).width;
3117
- var currentWidth = 0;
2754
+ var currentTextAlign = context.textAlign;
2755
+ context.textAlign = 'left';
2756
+ var currentPosition = x;
2757
+
2758
+ if (textAlign === 'center') {
2759
+ currentPosition = x - lineMetrics.width / 2;
2760
+ } else if (textAlign === 'right' || textAlign === 'end') {
2761
+ currentPosition = x - lineMetrics.width;
2762
+ }
3118
2763
 
3119
- for (var i = 0; i < stringArray.length; ++i) {
3120
- var currentChar = stringArray[i];
2764
+ var stringArray = Array.from(text);
2765
+ var previousWidth = context.measureText(text).width;
2766
+ var currentWidth = 0;
3121
2767
 
3122
- if (isStroke) {
3123
- this.strokeText(context, currentChar, currentPosition, y, strokeOpacity);
3124
- } else {
3125
- this.fillText(context, currentChar, currentPosition, y, fillOpacity, opacity);
3126
- }
2768
+ for (var i = 0; i < stringArray.length; ++i) {
2769
+ var currentChar = stringArray[i];
3127
2770
 
3128
- currentWidth = context.measureText(text.substring(i + 1)).width;
3129
- currentPosition += previousWidth - currentWidth + letterSpacing;
3130
- previousWidth = currentWidth;
2771
+ if (isStroke) {
2772
+ this.strokeText(context, currentChar, currentPosition, y, strokeOpacity);
2773
+ } else {
2774
+ this.fillText(context, currentChar, currentPosition, y, fillOpacity, opacity);
3131
2775
  }
3132
2776
 
3133
- context.textAlign = currentTextAlign;
2777
+ currentWidth = context.measureText(text.substring(i + 1)).width;
2778
+ currentPosition += previousWidth - currentWidth + letterSpacing;
2779
+ previousWidth = currentWidth;
3134
2780
  }
3135
- }, {
3136
- key: "fillText",
3137
- value: function fillText(context, text, x, y, fillOpacity, opacity) {
3138
- var currentGlobalAlpha;
3139
- var applyOpacity = !g.isNil(fillOpacity) && fillOpacity !== 1;
3140
2781
 
3141
- if (applyOpacity) {
3142
- currentGlobalAlpha = context.globalAlpha;
3143
- context.globalAlpha = fillOpacity * opacity;
3144
- }
2782
+ context.textAlign = currentTextAlign;
2783
+ };
3145
2784
 
3146
- context.fillText(text, x, y);
2785
+ _proto.fillText = function fillText(context, text, x, y, fillOpacity, opacity) {
2786
+ var currentGlobalAlpha;
2787
+ var applyOpacity = !g.isNil(fillOpacity) && fillOpacity !== 1;
3147
2788
 
3148
- if (applyOpacity) {
3149
- context.globalAlpha = currentGlobalAlpha;
3150
- }
2789
+ if (applyOpacity) {
2790
+ currentGlobalAlpha = context.globalAlpha;
2791
+ context.globalAlpha = fillOpacity * opacity;
3151
2792
  }
3152
- }, {
3153
- key: "strokeText",
3154
- value: function strokeText(context, text, x, y, strokeOpacity) {
3155
- var currentGlobalAlpha;
3156
- var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity !== 1;
3157
2793
 
3158
- if (applyOpacity) {
3159
- currentGlobalAlpha = context.globalAlpha;
3160
- context.globalAlpha = strokeOpacity;
3161
- }
2794
+ context.fillText(text, x, y);
2795
+
2796
+ if (applyOpacity) {
2797
+ context.globalAlpha = currentGlobalAlpha;
2798
+ }
2799
+ };
3162
2800
 
3163
- context.strokeText(text, x, y);
2801
+ _proto.strokeText = function strokeText(context, text, x, y, strokeOpacity) {
2802
+ var currentGlobalAlpha;
2803
+ var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity !== 1;
3164
2804
 
3165
- if (applyOpacity) {
3166
- context.globalAlpha = currentGlobalAlpha;
3167
- }
2805
+ if (applyOpacity) {
2806
+ currentGlobalAlpha = context.globalAlpha;
2807
+ context.globalAlpha = strokeOpacity;
3168
2808
  }
3169
- }]);
2809
+
2810
+ context.strokeText(text, x, y);
2811
+
2812
+ if (applyOpacity) {
2813
+ context.globalAlpha = currentGlobalAlpha;
2814
+ }
2815
+ };
3170
2816
 
3171
2817
  return TextRenderer;
3172
2818
  }();
@@ -3176,119 +2822,115 @@
3176
2822
  })], TextRenderer);
3177
2823
 
3178
2824
  var DefaultRenderer = /*#__PURE__*/function () {
3179
- function DefaultRenderer() {
3180
- _classCallCheck$2(this, DefaultRenderer);
3181
- }
3182
-
3183
- _createClass$2(DefaultRenderer, [{
3184
- key: "hash",
3185
- value: function hash(parsedStyle) {
3186
- // const { fill, opacity, fillOpacity, stroke, strokeOpacity, lineWidth, lineCap, lineJoin } =
3187
- // parsedStyle;
3188
- // return fill + opacity + fillOpacity + stroke + strokeOpacity + lineWidth + lineCap + lineJoin;
3189
- return '';
3190
- }
3191
- }, {
3192
- key: "render",
3193
- value: function render(context, parsedStyle) {
3194
- var fill = parsedStyle.fill,
3195
- opacity = parsedStyle.opacity,
3196
- fillOpacity = parsedStyle.fillOpacity,
3197
- stroke = parsedStyle.stroke,
3198
- strokeOpacity = parsedStyle.strokeOpacity,
3199
- lineWidth = parsedStyle.lineWidth,
3200
- lineCap = parsedStyle.lineCap,
3201
- lineJoin = parsedStyle.lineJoin,
3202
- shadowColor = parsedStyle.shadowColor,
3203
- filter = parsedStyle.filter,
3204
- miterLimit = parsedStyle.miterLimit;
3205
- var hasFill = !g.isNil(fill) && !fill.isNone;
3206
- var hasStroke = !g.isNil(stroke) && !stroke.isNone;
3207
- var isFillTransparent = fill.alpha === 0;
3208
-
3209
- if (hasFill) {
3210
- if (!g.isNil(fillOpacity) && fillOpacity.value !== 1) {
3211
- context.globalAlpha = fillOpacity.value;
3212
- context.fill();
3213
- context.globalAlpha = opacity.value;
3214
- } else {
3215
- context.fill();
3216
- }
2825
+ function DefaultRenderer() {}
2826
+
2827
+ var _proto = DefaultRenderer.prototype;
2828
+
2829
+ _proto.hash = function hash(parsedStyle) {
2830
+ // const { fill, opacity, fillOpacity, stroke, strokeOpacity, lineWidth, lineCap, lineJoin } =
2831
+ // parsedStyle;
2832
+ // return fill + opacity + fillOpacity + stroke + strokeOpacity + lineWidth + lineCap + lineJoin;
2833
+ return '';
2834
+ };
2835
+
2836
+ _proto.render = function render(context, parsedStyle) {
2837
+ var fill = parsedStyle.fill,
2838
+ opacity = parsedStyle.opacity,
2839
+ fillOpacity = parsedStyle.fillOpacity,
2840
+ stroke = parsedStyle.stroke,
2841
+ strokeOpacity = parsedStyle.strokeOpacity,
2842
+ lineWidth = parsedStyle.lineWidth,
2843
+ lineCap = parsedStyle.lineCap,
2844
+ lineJoin = parsedStyle.lineJoin,
2845
+ shadowColor = parsedStyle.shadowColor,
2846
+ filter = parsedStyle.filter,
2847
+ miterLimit = parsedStyle.miterLimit;
2848
+ var hasFill = !g.isNil(fill) && !fill.isNone;
2849
+ var hasStroke = !g.isNil(stroke) && !stroke.isNone;
2850
+ var isFillTransparent = fill.alpha === 0;
2851
+
2852
+ if (hasFill) {
2853
+ if (!g.isNil(fillOpacity) && fillOpacity.value !== 1) {
2854
+ context.globalAlpha = fillOpacity.value;
2855
+ context.fill();
2856
+ context.globalAlpha = opacity.value;
2857
+ } else {
2858
+ context.fill();
3217
2859
  }
2860
+ }
3218
2861
 
3219
- if (hasStroke) {
3220
- if (lineWidth && lineWidth.value > 0) {
3221
- var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity.value !== 1;
2862
+ if (hasStroke) {
2863
+ if (lineWidth && lineWidth.value > 0) {
2864
+ var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity.value !== 1;
3222
2865
 
3223
- if (applyOpacity) {
3224
- context.globalAlpha = strokeOpacity.value;
3225
- }
2866
+ if (applyOpacity) {
2867
+ context.globalAlpha = strokeOpacity.value;
2868
+ }
3226
2869
 
3227
- context.lineWidth = lineWidth.value;
2870
+ context.lineWidth = lineWidth.value;
3228
2871
 
3229
- if (!g.isNil(miterLimit)) {
3230
- context.miterLimit = miterLimit;
3231
- }
2872
+ if (!g.isNil(miterLimit)) {
2873
+ context.miterLimit = miterLimit;
2874
+ }
3232
2875
 
3233
- if (!g.isNil(lineCap)) {
3234
- context.lineCap = lineCap.value;
3235
- }
2876
+ if (!g.isNil(lineCap)) {
2877
+ context.lineCap = lineCap.value;
2878
+ }
3236
2879
 
3237
- if (!g.isNil(lineJoin)) {
3238
- context.lineJoin = lineJoin.value;
3239
- }
2880
+ if (!g.isNil(lineJoin)) {
2881
+ context.lineJoin = lineJoin.value;
2882
+ }
3240
2883
 
3241
- var oldShadowBlur;
3242
- var oldShadowColor;
3243
- var oldFilter;
3244
- var hasShadowColor = !g.isNil(shadowColor);
3245
- var hasFilter = !g.isNil(filter);
3246
-
3247
- if (hasShadowColor) {
3248
- // prevent inner shadow when drawing stroke, toggle shadowBlur & filter(drop-shadow)
3249
- // save shadow blur
3250
- oldShadowBlur = context.shadowBlur;
3251
- oldShadowColor = context.shadowColor;
3252
-
3253
- if (!g.isNil(oldShadowBlur)) {
3254
- context.shadowColor = 'transparent';
3255
- context.shadowBlur = 0;
3256
- }
2884
+ var oldShadowBlur;
2885
+ var oldShadowColor;
2886
+ var oldFilter;
2887
+ var hasShadowColor = !g.isNil(shadowColor);
2888
+ var hasFilter = !g.isNil(filter);
2889
+
2890
+ if (hasShadowColor) {
2891
+ // prevent inner shadow when drawing stroke, toggle shadowBlur & filter(drop-shadow)
2892
+ // save shadow blur
2893
+ oldShadowBlur = context.shadowBlur;
2894
+ oldShadowColor = context.shadowColor;
2895
+
2896
+ if (!g.isNil(oldShadowBlur)) {
2897
+ context.shadowColor = 'transparent';
2898
+ context.shadowBlur = 0;
3257
2899
  }
2900
+ }
3258
2901
 
3259
- if (hasFilter) {
3260
- // save drop-shadow filter
3261
- oldFilter = context.filter;
2902
+ if (hasFilter) {
2903
+ // save drop-shadow filter
2904
+ oldFilter = context.filter;
3262
2905
 
3263
- if (!g.isNil(oldFilter) && oldFilter.indexOf('drop-shadow') > -1) {
3264
- context.filter = oldFilter.replace(/drop-shadow\([^)]*\)/, '').trim() || 'none';
3265
- }
2906
+ if (!g.isNil(oldFilter) && oldFilter.indexOf('drop-shadow') > -1) {
2907
+ context.filter = oldFilter.replace(/drop-shadow\([^)]*\)/, '').trim() || 'none';
3266
2908
  }
2909
+ }
3267
2910
 
3268
- var drawStroke = hasFill && !isFillTransparent;
2911
+ var drawStroke = hasFill && !isFillTransparent;
3269
2912
 
3270
- if (drawStroke) {
3271
- context.stroke();
3272
- } // restore shadow blur
2913
+ if (drawStroke) {
2914
+ context.stroke();
2915
+ } // restore shadow blur
3273
2916
 
3274
2917
 
3275
- if (hasShadowColor) {
3276
- context.shadowColor = oldShadowColor;
3277
- context.shadowBlur = oldShadowBlur;
3278
- } // restore filters
2918
+ if (hasShadowColor) {
2919
+ context.shadowColor = oldShadowColor;
2920
+ context.shadowBlur = oldShadowBlur;
2921
+ } // restore filters
3279
2922
 
3280
2923
 
3281
- if (hasFilter) {
3282
- context.filter = oldFilter;
3283
- }
2924
+ if (hasFilter) {
2925
+ context.filter = oldFilter;
2926
+ }
3284
2927
 
3285
- if (!drawStroke) {
3286
- context.stroke();
3287
- }
2928
+ if (!drawStroke) {
2929
+ context.stroke();
3288
2930
  }
3289
2931
  }
3290
2932
  }
3291
- }]);
2933
+ };
3292
2934
 
3293
2935
  return DefaultRenderer;
3294
2936
  }();
@@ -3296,17 +2938,13 @@
3296
2938
  DefaultRenderer = __decorate([manaSyringe.singleton()], DefaultRenderer);
3297
2939
 
3298
2940
  var RectRenderer = /*#__PURE__*/function (_DefaultRenderer) {
3299
- _inherits$1(RectRenderer, _DefaultRenderer);
3300
-
3301
- var _super = _createSuper$1(RectRenderer);
2941
+ _inheritsLoose$1(RectRenderer, _DefaultRenderer);
3302
2942
 
3303
2943
  function RectRenderer() {
3304
- _classCallCheck$2(this, RectRenderer);
3305
-
3306
- return _super.apply(this, arguments);
2944
+ return _DefaultRenderer.apply(this, arguments) || this;
3307
2945
  }
3308
2946
 
3309
- return _createClass$2(RectRenderer);
2947
+ return RectRenderer;
3310
2948
  }(DefaultRenderer);
3311
2949
 
3312
2950
  RectRenderer = __decorate([manaSyringe.singleton({
@@ -3314,17 +2952,13 @@
3314
2952
  })], RectRenderer);
3315
2953
 
3316
2954
  var CircleRenderer = /*#__PURE__*/function (_DefaultRenderer) {
3317
- _inherits$1(CircleRenderer, _DefaultRenderer);
3318
-
3319
- var _super = _createSuper$1(CircleRenderer);
2955
+ _inheritsLoose$1(CircleRenderer, _DefaultRenderer);
3320
2956
 
3321
2957
  function CircleRenderer() {
3322
- _classCallCheck$2(this, CircleRenderer);
3323
-
3324
- return _super.apply(this, arguments);
2958
+ return _DefaultRenderer.apply(this, arguments) || this;
3325
2959
  }
3326
2960
 
3327
- return _createClass$2(CircleRenderer);
2961
+ return CircleRenderer;
3328
2962
  }(DefaultRenderer);
3329
2963
 
3330
2964
  CircleRenderer = __decorate([manaSyringe.singleton({
@@ -3332,17 +2966,13 @@
3332
2966
  })], CircleRenderer);
3333
2967
 
3334
2968
  var EllipseRenderer = /*#__PURE__*/function (_DefaultRenderer) {
3335
- _inherits$1(EllipseRenderer, _DefaultRenderer);
3336
-
3337
- var _super = _createSuper$1(EllipseRenderer);
2969
+ _inheritsLoose$1(EllipseRenderer, _DefaultRenderer);
3338
2970
 
3339
2971
  function EllipseRenderer() {
3340
- _classCallCheck$2(this, EllipseRenderer);
3341
-
3342
- return _super.apply(this, arguments);
2972
+ return _DefaultRenderer.apply(this, arguments) || this;
3343
2973
  }
3344
2974
 
3345
- return _createClass$2(EllipseRenderer);
2975
+ return EllipseRenderer;
3346
2976
  }(DefaultRenderer);
3347
2977
 
3348
2978
  EllipseRenderer = __decorate([manaSyringe.singleton({
@@ -3350,17 +2980,13 @@
3350
2980
  })], EllipseRenderer);
3351
2981
 
3352
2982
  var LineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
3353
- _inherits$1(LineRenderer, _DefaultRenderer);
3354
-
3355
- var _super = _createSuper$1(LineRenderer);
2983
+ _inheritsLoose$1(LineRenderer, _DefaultRenderer);
3356
2984
 
3357
2985
  function LineRenderer() {
3358
- _classCallCheck$2(this, LineRenderer);
3359
-
3360
- return _super.apply(this, arguments);
2986
+ return _DefaultRenderer.apply(this, arguments) || this;
3361
2987
  }
3362
2988
 
3363
- return _createClass$2(LineRenderer);
2989
+ return LineRenderer;
3364
2990
  }(DefaultRenderer);
3365
2991
 
3366
2992
  LineRenderer = __decorate([manaSyringe.singleton({
@@ -3368,17 +2994,13 @@
3368
2994
  })], LineRenderer);
3369
2995
 
3370
2996
  var PolylineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
3371
- _inherits$1(PolylineRenderer, _DefaultRenderer);
3372
-
3373
- var _super = _createSuper$1(PolylineRenderer);
2997
+ _inheritsLoose$1(PolylineRenderer, _DefaultRenderer);
3374
2998
 
3375
2999
  function PolylineRenderer() {
3376
- _classCallCheck$2(this, PolylineRenderer);
3377
-
3378
- return _super.apply(this, arguments);
3000
+ return _DefaultRenderer.apply(this, arguments) || this;
3379
3001
  }
3380
3002
 
3381
- return _createClass$2(PolylineRenderer);
3003
+ return PolylineRenderer;
3382
3004
  }(DefaultRenderer);
3383
3005
 
3384
3006
  PolylineRenderer = __decorate([manaSyringe.singleton({
@@ -3386,17 +3008,13 @@
3386
3008
  })], PolylineRenderer);
3387
3009
 
3388
3010
  var PolygonRenderer = /*#__PURE__*/function (_DefaultRenderer) {
3389
- _inherits$1(PolygonRenderer, _DefaultRenderer);
3390
-
3391
- var _super = _createSuper$1(PolygonRenderer);
3011
+ _inheritsLoose$1(PolygonRenderer, _DefaultRenderer);
3392
3012
 
3393
3013
  function PolygonRenderer() {
3394
- _classCallCheck$2(this, PolygonRenderer);
3395
-
3396
- return _super.apply(this, arguments);
3014
+ return _DefaultRenderer.apply(this, arguments) || this;
3397
3015
  }
3398
3016
 
3399
- return _createClass$2(PolygonRenderer);
3017
+ return PolygonRenderer;
3400
3018
  }(DefaultRenderer);
3401
3019
 
3402
3020
  PolygonRenderer = __decorate([manaSyringe.singleton({
@@ -3404,17 +3022,13 @@
3404
3022
  })], PolygonRenderer);
3405
3023
 
3406
3024
  var PathRenderer = /*#__PURE__*/function (_DefaultRenderer) {
3407
- _inherits$1(PathRenderer, _DefaultRenderer);
3408
-
3409
- var _super = _createSuper$1(PathRenderer);
3025
+ _inheritsLoose$1(PathRenderer, _DefaultRenderer);
3410
3026
 
3411
3027
  function PathRenderer() {
3412
- _classCallCheck$2(this, PathRenderer);
3413
-
3414
- return _super.apply(this, arguments);
3028
+ return _DefaultRenderer.apply(this, arguments) || this;
3415
3029
  }
3416
3030
 
3417
- return _createClass$2(PathRenderer);
3031
+ return PathRenderer;
3418
3032
  }(DefaultRenderer);
3419
3033
 
3420
3034
  PathRenderer = __decorate([manaSyringe.singleton({
@@ -3433,8 +3047,6 @@
3433
3047
 
3434
3048
  var CanvasRendererPlugin = CanvasRendererPlugin_1 = (_class$1 = /*#__PURE__*/function () {
3435
3049
  function CanvasRendererPlugin() {
3436
- _classCallCheck$2(this, CanvasRendererPlugin);
3437
-
3438
3050
  this.canvasConfig = void 0;
3439
3051
  this.camera = void 0;
3440
3052
  this.contextService = void 0;
@@ -3455,641 +3067,619 @@
3455
3067
  this.toSync = new Set();
3456
3068
  }
3457
3069
 
3458
- _createClass$2(CanvasRendererPlugin, [{
3459
- key: "syncRTree",
3460
- value: function syncRTree() {
3461
- var _this = this; // bounds changed, need re-inserting its children
3070
+ var _proto = CanvasRendererPlugin.prototype;
3462
3071
 
3072
+ _proto.syncRTree = function syncRTree() {
3073
+ var _this = this; // bounds changed, need re-inserting its children
3463
3074
 
3464
- var bulk = [];
3465
- Array.from(this.toSync) // some objects may be removed since last frame
3466
- .filter(function (object) {
3467
- return object.isConnected;
3468
- }).forEach(function (node) {
3469
- // @ts-ignore
3470
- var rBushNode = node.rBushNode; // clear dirty node
3471
3075
 
3472
- if (rBushNode) {
3473
- _this.rBush.remove(rBushNode.aabb);
3474
- }
3076
+ var bulk = [];
3077
+ Array.from(this.toSync) // some objects may be removed since last frame
3078
+ .filter(function (object) {
3079
+ return object.isConnected;
3080
+ }).forEach(function (node) {
3081
+ // @ts-ignore
3082
+ var rBushNode = node.rBushNode; // clear dirty node
3475
3083
 
3476
- var renderBounds = node.getRenderBounds();
3477
-
3478
- if (renderBounds) {
3479
- var _renderBounds$getMin = renderBounds.getMin(),
3480
- _renderBounds$getMin2 = _slicedToArray(_renderBounds$getMin, 2),
3481
- minX = _renderBounds$getMin2[0],
3482
- minY = _renderBounds$getMin2[1];
3483
-
3484
- var _renderBounds$getMax = renderBounds.getMax(),
3485
- _renderBounds$getMax2 = _slicedToArray(_renderBounds$getMax, 2),
3486
- maxX = _renderBounds$getMax2[0],
3487
- maxY = _renderBounds$getMax2[1];
3488
-
3489
- rBushNode.aabb = {
3490
- id: node.entity,
3491
- minX: minX,
3492
- minY: minY,
3493
- maxX: maxX,
3494
- maxY: maxY
3495
- };
3496
- }
3084
+ if (rBushNode) {
3085
+ _this.rBush.remove(rBushNode.aabb);
3086
+ }
3497
3087
 
3498
- if (rBushNode.aabb) {
3499
- bulk.push(rBushNode.aabb);
3500
- }
3501
- }); // use bulk inserting, which is ~2-3 times faster
3502
- // @see https://github.com/mourner/rbush#bulk-inserting-data
3088
+ var renderBounds = node.getRenderBounds();
3503
3089
 
3504
- this.rBush.load(bulk);
3505
- this.toSync.clear();
3506
- }
3507
- /**
3508
- * sync to RBush later
3509
- */
3090
+ if (renderBounds) {
3091
+ var _renderBounds$getMin = renderBounds.getMin(),
3092
+ minX = _renderBounds$getMin[0],
3093
+ minY = _renderBounds$getMin[1];
3094
+
3095
+ var _renderBounds$getMax = renderBounds.getMax(),
3096
+ maxX = _renderBounds$getMax[0],
3097
+ maxY = _renderBounds$getMax[1];
3098
+
3099
+ rBushNode.aabb = {
3100
+ id: node.entity,
3101
+ minX: minX,
3102
+ minY: minY,
3103
+ maxX: maxX,
3104
+ maxY: maxY
3105
+ };
3106
+ }
3510
3107
 
3511
- }, {
3512
- key: "pushToSync",
3513
- value: function pushToSync(list) {
3514
- var _this2 = this;
3108
+ if (rBushNode.aabb) {
3109
+ bulk.push(rBushNode.aabb);
3110
+ }
3111
+ }); // use bulk inserting, which is ~2-3 times faster
3112
+ // @see https://github.com/mourner/rbush#bulk-inserting-data
3515
3113
 
3516
- list.forEach(function (i) {
3517
- _this2.toSync.add(i);
3518
- });
3519
- }
3520
- }, {
3521
- key: "apply",
3522
- value: function apply(renderingService) {
3523
- var _this3 = this;
3114
+ this.rBush.load(bulk);
3115
+ this.toSync.clear();
3116
+ }
3117
+ /**
3118
+ * sync to RBush later
3119
+ */
3120
+ ;
3524
3121
 
3525
- var handleMounted = function handleMounted(e) {
3526
- var object = e.target; // @ts-ignore
3122
+ _proto.pushToSync = function pushToSync(list) {
3123
+ var _this2 = this;
3527
3124
 
3528
- object.rBushNode = new RBushNode();
3125
+ list.forEach(function (i) {
3126
+ _this2.toSync.add(i);
3127
+ });
3128
+ };
3529
3129
 
3530
- _this3.pushToSync(e.composedPath().slice(0, -2));
3531
- };
3130
+ _proto.apply = function apply(renderingService) {
3131
+ var _this3 = this;
3532
3132
 
3533
- var handleUnmounted = function handleUnmounted(e) {
3534
- var object = e.target; // remove r-bush node
3535
- // @ts-ignore
3133
+ var handleMounted = function handleMounted(e) {
3134
+ var object = e.target; // @ts-ignore
3536
3135
 
3537
- var rBushNode = object.rBushNode;
3136
+ object.rBushNode = new RBushNode();
3538
3137
 
3539
- if (rBushNode.aabb) {
3540
- _this3.rBush.remove(rBushNode.aabb);
3138
+ _this3.pushToSync(e.composedPath().slice(0, -2));
3139
+ };
3541
3140
 
3542
- _this3.toSync.delete(object); // save removed aabbs for dirty-rectangle rendering later
3141
+ var handleUnmounted = function handleUnmounted(e) {
3142
+ var object = e.target; // remove r-bush node
3143
+ // @ts-ignore
3543
3144
 
3145
+ var rBushNode = object.rBushNode;
3544
3146
 
3545
- _this3.removedRBushNodeAABBs.push(rBushNode.aabb);
3546
- }
3547
- };
3147
+ if (rBushNode.aabb) {
3148
+ _this3.rBush.remove(rBushNode.aabb);
3548
3149
 
3549
- var handleBoundsChanged = function handleBoundsChanged(e) {
3550
- var _object$ownerDocument;
3150
+ _this3.toSync.delete(object); // save removed aabbs for dirty-rectangle rendering later
3551
3151
 
3552
- var object = e.target; // skip if this object mounted on another scenegraph root
3553
3152
 
3554
- if (((_object$ownerDocument = object.ownerDocument) === null || _object$ownerDocument === void 0 ? void 0 : _object$ownerDocument.documentElement) !== _this3.renderingContext.root) {
3555
- return;
3556
- }
3153
+ _this3.removedRBushNodeAABBs.push(rBushNode.aabb);
3154
+ }
3155
+ };
3557
3156
 
3558
- var affectChildren = e.detail.affectChildren;
3157
+ var handleBoundsChanged = function handleBoundsChanged(e) {
3158
+ var _object$ownerDocument;
3559
3159
 
3560
- if (affectChildren) {
3561
- object.forEach(function (node) {
3562
- _this3.pushToSync([node]);
3563
- });
3564
- }
3160
+ var object = e.target; // skip if this object mounted on another scenegraph root
3565
3161
 
3566
- _this3.pushToSync(e.composedPath().slice(0, -2));
3567
- };
3162
+ if (((_object$ownerDocument = object.ownerDocument) === null || _object$ownerDocument === void 0 ? void 0 : _object$ownerDocument.documentElement) !== _this3.renderingContext.root) {
3163
+ return;
3164
+ }
3568
3165
 
3569
- renderingService.hooks.init.tapPromise(CanvasRendererPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
3570
- var _this3$canvasConfig, width, height, context;
3166
+ var affectChildren = e.detail.affectChildren;
3571
3167
 
3572
- return _regeneratorRuntime$1().wrap(function _callee$(_context) {
3573
- while (1) {
3574
- switch (_context.prev = _context.next) {
3575
- case 0:
3576
- _this3.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
3168
+ if (affectChildren) {
3169
+ object.forEach(function (node) {
3170
+ _this3.pushToSync([node]);
3171
+ });
3172
+ }
3577
3173
 
3578
- _this3.renderingContext.root.addEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
3174
+ _this3.pushToSync(e.composedPath().slice(0, -2));
3175
+ };
3579
3176
 
3580
- _this3.renderingContext.root.addEventListener(g.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged); // clear fullscreen
3177
+ renderingService.hooks.init.tapPromise(CanvasRendererPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
3178
+ var _this3$canvasConfig, width, height, context;
3581
3179
 
3180
+ return _regeneratorRuntime$1().wrap(function _callee$(_context) {
3181
+ while (1) {
3182
+ switch (_context.prev = _context.next) {
3183
+ case 0:
3184
+ _this3.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
3582
3185
 
3583
- _this3$canvasConfig = _this3.canvasConfig, width = _this3$canvasConfig.width, height = _this3$canvasConfig.height;
3584
- context = _this3.contextService.getContext();
3186
+ _this3.renderingContext.root.addEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
3585
3187
 
3586
- _this3.clearRect(context, 0, 0, width, height);
3188
+ _this3.renderingContext.root.addEventListener(g.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged); // clear fullscreen
3587
3189
 
3588
- case 6:
3589
- case "end":
3590
- return _context.stop();
3591
- }
3592
- }
3593
- }, _callee);
3594
- })));
3595
- renderingService.hooks.destroy.tap(CanvasRendererPlugin_1.tag, function () {
3596
- _this3.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
3597
3190
 
3598
- _this3.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
3191
+ _this3$canvasConfig = _this3.canvasConfig, width = _this3$canvasConfig.width, height = _this3$canvasConfig.height;
3192
+ context = _this3.contextService.getContext();
3599
3193
 
3600
- _this3.renderingContext.root.removeEventListener(g.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
3601
- });
3602
- renderingService.hooks.beginFrame.tap(CanvasRendererPlugin_1.tag, function () {
3603
- var context = _this3.contextService.getContext();
3194
+ _this3.clearRect(context, 0, 0, width, height);
3195
+
3196
+ case 6:
3197
+ case "end":
3198
+ return _context.stop();
3199
+ }
3200
+ }
3201
+ }, _callee);
3202
+ })));
3203
+ renderingService.hooks.destroy.tap(CanvasRendererPlugin_1.tag, function () {
3204
+ _this3.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
3604
3205
 
3605
- var _this3$canvasConfig2 = _this3.canvasConfig,
3606
- renderer = _this3$canvasConfig2.renderer,
3607
- width = _this3$canvasConfig2.width,
3608
- height = _this3$canvasConfig2.height;
3206
+ _this3.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
3609
3207
 
3610
- var _renderer$getConfig = renderer.getConfig(),
3611
- enableDirtyRectangleRendering = _renderer$getConfig.enableDirtyRectangleRendering; // clear fullscreen when:
3612
- // 1. dirty rectangle rendering disabled
3613
- // 2. camera changed
3208
+ _this3.renderingContext.root.removeEventListener(g.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
3209
+ });
3210
+ renderingService.hooks.beginFrame.tap(CanvasRendererPlugin_1.tag, function () {
3211
+ var context = _this3.contextService.getContext();
3614
3212
 
3213
+ var _this3$canvasConfig2 = _this3.canvasConfig,
3214
+ renderer = _this3$canvasConfig2.renderer,
3215
+ width = _this3$canvasConfig2.width,
3216
+ height = _this3$canvasConfig2.height;
3615
3217
 
3616
- _this3.clearFullScreen = !enableDirtyRectangleRendering || _this3.renderingContext.renderReasons.has(g.RenderReason.CAMERA_CHANGED);
3218
+ var _renderer$getConfig = renderer.getConfig(),
3219
+ enableDirtyRectangleRendering = _renderer$getConfig.enableDirtyRectangleRendering; // clear fullscreen when:
3220
+ // 1. dirty rectangle rendering disabled
3221
+ // 2. camera changed
3617
3222
 
3618
- if (context) {
3619
- context.save();
3620
3223
 
3621
- if (_this3.clearFullScreen) {
3622
- _this3.clearRect(context, 0, 0, width, height);
3623
- } // account for camera's world matrix
3224
+ _this3.clearFullScreen = !enableDirtyRectangleRendering || _this3.renderingContext.renderReasons.has(g.RenderReason.CAMERA_CHANGED);
3624
3225
 
3226
+ if (context) {
3227
+ context.save();
3625
3228
 
3626
- _this3.applyTransform(context, _this3.camera.getOrthoMatrix());
3627
- }
3628
- }); // render at the end of frame
3229
+ if (_this3.clearFullScreen) {
3230
+ _this3.clearRect(context, 0, 0, width, height);
3231
+ } // account for camera's world matrix
3629
3232
 
3630
- renderingService.hooks.endFrame.tap(CanvasRendererPlugin_1.tag, function () {
3631
- _this3.syncRTree();
3632
3233
 
3633
- var _this3$canvasConfig$r = _this3.canvasConfig.renderer.getConfig(),
3634
- enableDirtyRectangleRendering = _this3$canvasConfig$r.enableDirtyRectangleRendering,
3635
- enableDirtyRectangleRenderingDebug = _this3$canvasConfig$r.enableDirtyRectangleRenderingDebug;
3234
+ _this3.applyTransform(context, _this3.camera.getOrthoMatrix());
3235
+ }
3236
+ }); // render at the end of frame
3636
3237
 
3637
- var context = _this3.contextService.getContext();
3238
+ renderingService.hooks.endFrame.tap(CanvasRendererPlugin_1.tag, function () {
3239
+ _this3.syncRTree();
3638
3240
 
3639
- var dirtyObjects = _this3.renderQueue;
3241
+ var _this3$canvasConfig$r = _this3.canvasConfig.renderer.getConfig(),
3242
+ enableDirtyRectangleRendering = _this3$canvasConfig$r.enableDirtyRectangleRendering,
3243
+ enableDirtyRectangleRenderingDebug = _this3$canvasConfig$r.enableDirtyRectangleRenderingDebug;
3640
3244
 
3641
- if (enableDirtyRectangleRendering) {
3642
- // eg. camera changed
3643
- if (!_this3.clearFullScreen) {
3644
- // merge removed AABB
3645
- var dirtyRenderBounds = _this3.safeMergeAABB.apply(_this3, [_this3.mergeDirtyAABBs( // should not ignore group since clipPath may affect its children
3646
- // this.renderQueue.filter((o) => o.nodeName !== Shape.GROUP)),
3647
- _this3.renderQueue)].concat(_toConsumableArray(_this3.removedRBushNodeAABBs.map(function (_ref2) {
3648
- var minX = _ref2.minX,
3649
- minY = _ref2.minY,
3650
- maxX = _ref2.maxX,
3651
- maxY = _ref2.maxY;
3652
- var aabb = new g.AABB();
3653
- aabb.setMinMax(fromValues(minX, minY, 0), fromValues(maxX, maxY, 0));
3654
- return aabb;
3655
- }))));
3245
+ var context = _this3.contextService.getContext();
3656
3246
 
3657
- _this3.removedRBushNodeAABBs = [];
3247
+ var dirtyObjects = _this3.renderQueue;
3658
3248
 
3659
- if (g.AABB.isEmpty(dirtyRenderBounds)) {
3660
- _this3.renderQueue = [];
3661
- return;
3662
- } // clear & clip dirty rectangle
3249
+ if (enableDirtyRectangleRendering) {
3250
+ // eg. camera changed
3251
+ if (!_this3.clearFullScreen) {
3252
+ // merge removed AABB
3253
+ var dirtyRenderBounds = _this3.safeMergeAABB.apply(_this3, [_this3.mergeDirtyAABBs( // should not ignore group since clipPath may affect its children
3254
+ // this.renderQueue.filter((o) => o.nodeName !== Shape.GROUP)),
3255
+ _this3.renderQueue)].concat(_this3.removedRBushNodeAABBs.map(function (_ref2) {
3256
+ var minX = _ref2.minX,
3257
+ minY = _ref2.minY,
3258
+ maxX = _ref2.maxX,
3259
+ maxY = _ref2.maxY;
3260
+ var aabb = new g.AABB();
3261
+ aabb.setMinMax(fromValues(minX, minY, 0), fromValues(maxX, maxY, 0));
3262
+ return aabb;
3263
+ })));
3663
3264
 
3265
+ _this3.removedRBushNodeAABBs = [];
3664
3266
 
3665
- var _this3$convertAABB2Re = _this3.convertAABB2Rect(dirtyRenderBounds),
3666
- x = _this3$convertAABB2Re.x,
3667
- y = _this3$convertAABB2Re.y,
3668
- width = _this3$convertAABB2Re.width,
3669
- height = _this3$convertAABB2Re.height;
3267
+ if (g.AABB.isEmpty(dirtyRenderBounds)) {
3268
+ _this3.renderQueue = [];
3269
+ return;
3270
+ } // clear & clip dirty rectangle
3670
3271
 
3671
- _this3.clearRect(context, x, y, width, height);
3672
3272
 
3673
- context.beginPath();
3674
- context.rect(x, y, width, height);
3675
- context.clip(); // draw dirty rectangle
3273
+ var _this3$convertAABB2Re = _this3.convertAABB2Rect(dirtyRenderBounds),
3274
+ x = _this3$convertAABB2Re.x,
3275
+ y = _this3$convertAABB2Re.y,
3276
+ width = _this3$convertAABB2Re.width,
3277
+ height = _this3$convertAABB2Re.height;
3676
3278
 
3677
- if (enableDirtyRectangleRenderingDebug) {
3678
- context.lineWidth = 4;
3679
- context.strokeStyle = "rgba(".concat(Math.random() * 255, ", ").concat(Math.random() * 255, ", ").concat(Math.random() * 255, ", 1)");
3680
- context.strokeRect(x, y, width, height);
3681
- } // search objects intersect with dirty rectangle
3279
+ _this3.clearRect(context, x, y, width, height);
3682
3280
 
3281
+ context.beginPath();
3282
+ context.rect(x, y, width, height);
3283
+ context.clip(); // draw dirty rectangle
3683
3284
 
3684
- dirtyObjects = _this3.searchDirtyObjects(dirtyRenderBounds);
3685
- } // do rendering
3285
+ if (enableDirtyRectangleRenderingDebug) {
3286
+ context.lineWidth = 4;
3287
+ context.strokeStyle = "rgba(" + Math.random() * 255 + ", " + Math.random() * 255 + ", " + Math.random() * 255 + ", 1)";
3288
+ context.strokeRect(x, y, width, height);
3289
+ } // search objects intersect with dirty rectangle
3686
3290
 
3687
3291
 
3688
- dirtyObjects // sort by z-index
3689
- .sort(function (a, b) {
3690
- return a.sortable.renderOrder - b.sortable.renderOrder;
3691
- }).forEach(function (object) {
3692
- // culled object should not be rendered
3693
- if (object && object.isVisible() && !object.isCulled()) {
3694
- _this3.renderDisplayObject(object, renderingService);
3695
- }
3696
- });
3292
+ dirtyObjects = _this3.searchDirtyObjects(dirtyRenderBounds);
3293
+ } // do rendering
3697
3294
 
3698
- if (_this3.enableBatch && _this3.batchedStyleHash) {
3699
- _this3.flush(context, renderingService);
3700
- } // save dirty AABBs in last frame
3701
3295
 
3296
+ dirtyObjects // sort by z-index
3297
+ .sort(function (a, b) {
3298
+ return a.sortable.renderOrder - b.sortable.renderOrder;
3299
+ }).forEach(function (object) {
3300
+ // culled object should not be rendered
3301
+ if (object && object.isVisible() && !object.isCulled()) {
3302
+ _this3.renderDisplayObject(object, renderingService);
3303
+ }
3304
+ });
3702
3305
 
3703
- _this3.renderQueue.forEach(function (object) {
3704
- _this3.saveDirtyAABB(object);
3705
- }); // clear queue
3306
+ if (_this3.enableBatch && _this3.batchedStyleHash) {
3307
+ _this3.flush(context, renderingService);
3308
+ } // save dirty AABBs in last frame
3706
3309
 
3707
3310
 
3708
- _this3.renderQueue = [];
3709
- } // pop restore stack, eg. root -> parent -> child
3311
+ _this3.renderQueue.forEach(function (object) {
3312
+ _this3.saveDirtyAABB(object);
3313
+ }); // clear queue
3710
3314
 
3711
3315
 
3712
- _this3.restoreStack.forEach(function (s) {
3713
- context.restore();
3714
- }); // clear restore stack
3316
+ _this3.renderQueue = [];
3317
+ } // pop restore stack, eg. root -> parent -> child
3715
3318
 
3716
3319
 
3717
- _this3.restoreStack = [];
3718
- _this3.clearFullScreen = false;
3320
+ _this3.restoreStack.forEach(function (s) {
3719
3321
  context.restore();
3720
- });
3721
- renderingService.hooks.render.tap(CanvasRendererPlugin_1.tag, function (object) {
3722
- var _this3$canvasConfig$r2 = _this3.canvasConfig.renderer.getConfig(),
3723
- enableDirtyRectangleRendering = _this3$canvasConfig$r2.enableDirtyRectangleRendering;
3322
+ }); // clear restore stack
3724
3323
 
3725
- if (!enableDirtyRectangleRendering) {
3726
- if (object.isVisible() && !object.isCulled()) {
3727
- // render immediately
3728
- _this3.renderDisplayObject(object, renderingService);
3729
- }
3730
- } else {
3731
- // render at the end of frame
3732
- _this3.renderQueue.push(object);
3324
+
3325
+ _this3.restoreStack = [];
3326
+ _this3.clearFullScreen = false;
3327
+ context.restore();
3328
+ });
3329
+ renderingService.hooks.render.tap(CanvasRendererPlugin_1.tag, function (object) {
3330
+ var _this3$canvasConfig$r2 = _this3.canvasConfig.renderer.getConfig(),
3331
+ enableDirtyRectangleRendering = _this3$canvasConfig$r2.enableDirtyRectangleRendering;
3332
+
3333
+ if (!enableDirtyRectangleRendering) {
3334
+ if (object.isVisible() && !object.isCulled()) {
3335
+ // render immediately
3336
+ _this3.renderDisplayObject(object, renderingService);
3733
3337
  }
3734
- });
3338
+ } else {
3339
+ // render at the end of frame
3340
+ _this3.renderQueue.push(object);
3341
+ }
3342
+ });
3343
+ };
3344
+
3345
+ _proto.clearRect = function clearRect(context, x, y, width, height) {
3346
+ context.clearRect(x, y, width, height);
3347
+ var background = this.canvasConfig.background;
3348
+
3349
+ if (background) {
3350
+ context.fillStyle = background;
3351
+ context.fillRect(x, y, width, height);
3735
3352
  }
3736
- }, {
3737
- key: "clearRect",
3738
- value: function clearRect(context, x, y, width, height) {
3739
- context.clearRect(x, y, width, height);
3740
- var background = this.canvasConfig.background;
3353
+ };
3354
+
3355
+ _proto.flush = function flush(context, renderingService) {
3356
+ if (this.batchedDisplayObject) {
3357
+ var styleRenderer = this.styleRendererFactory(this.batchedDisplayObject.nodeName);
3741
3358
 
3742
- if (background) {
3743
- context.fillStyle = background;
3744
- context.fillRect(x, y, width, height);
3359
+ if (styleRenderer) {
3360
+ // apply attributes to context
3361
+ this.applyAttributesToContext(context, this.batchedDisplayObject, renderingService); // close path first
3362
+
3363
+ context.closePath();
3364
+ styleRenderer.render(context, this.batchedDisplayObject.parsedStyle, this.batchedDisplayObject);
3365
+ context.restore();
3745
3366
  }
3367
+
3368
+ this.batchedStyleHash = '';
3369
+ this.batchedDisplayObject = null;
3746
3370
  }
3747
- }, {
3748
- key: "flush",
3749
- value: function flush(context, renderingService) {
3750
- if (this.batchedDisplayObject) {
3751
- var styleRenderer = this.styleRendererFactory(this.batchedDisplayObject.nodeName);
3371
+ };
3752
3372
 
3753
- if (styleRenderer) {
3754
- // apply attributes to context
3755
- this.applyAttributesToContext(context, this.batchedDisplayObject, renderingService); // close path first
3373
+ _proto.renderDisplayObject = function renderDisplayObject(object, renderingService) {
3374
+ var _this4 = this;
3756
3375
 
3757
- context.closePath();
3758
- styleRenderer.render(context, this.batchedDisplayObject.parsedStyle, this.batchedDisplayObject);
3759
- context.restore();
3760
- }
3376
+ var context = this.contextService.getContext(); // restore to its parent
3761
3377
 
3762
- this.batchedStyleHash = '';
3763
- this.batchedDisplayObject = null;
3764
- }
3378
+ var parent = this.restoreStack[this.restoreStack.length - 1];
3379
+
3380
+ while (parent && object.parentNode !== parent) {
3381
+ context.restore();
3382
+ this.restoreStack.pop();
3383
+ parent = this.restoreStack[this.restoreStack.length - 1];
3765
3384
  }
3766
- }, {
3767
- key: "renderDisplayObject",
3768
- value: function renderDisplayObject(object, renderingService) {
3769
- var _this4 = this;
3770
3385
 
3771
- var context = this.contextService.getContext(); // restore to its parent
3386
+ var nodeName = object.nodeName;
3387
+ var styleRenderer = this.styleRendererFactory(nodeName);
3388
+ var startBatch = false;
3772
3389
 
3773
- var parent = this.restoreStack[this.restoreStack.length - 1];
3390
+ if (this.enableBatch && styleRenderer) {
3391
+ var hash = styleRenderer.hash(object.attributes);
3774
3392
 
3775
- while (parent && object.parentNode !== parent) {
3776
- context.restore();
3777
- this.restoreStack.pop();
3778
- parent = this.restoreStack[this.restoreStack.length - 1];
3393
+ if (this.batchedStyleHash && hash !== this.batchedStyleHash) {
3394
+ this.flush(context, renderingService);
3395
+ }
3396
+
3397
+ if (!this.batchedStyleHash) {
3398
+ this.batchedStyleHash = hash;
3399
+ this.batchedDisplayObject = object;
3400
+ startBatch = true;
3779
3401
  }
3402
+ } // reset transformation
3780
3403
 
3781
- var nodeName = object.nodeName;
3782
- var styleRenderer = this.styleRendererFactory(nodeName);
3783
- var startBatch = false;
3784
3404
 
3785
- if (this.enableBatch && styleRenderer) {
3786
- var hash = styleRenderer.hash(object.attributes);
3405
+ context.save(); // apply RTS transformation in world space
3787
3406
 
3788
- if (this.batchedStyleHash && hash !== this.batchedStyleHash) {
3789
- this.flush(context, renderingService);
3790
- }
3407
+ this.applyTransform(context, object.getLocalTransform()); // clip path
3791
3408
 
3792
- if (!this.batchedStyleHash) {
3793
- this.batchedStyleHash = hash;
3794
- this.batchedDisplayObject = object;
3795
- startBatch = true;
3796
- }
3797
- } // reset transformation
3409
+ var clipPathShape = object.style.clipPath;
3410
+
3411
+ if (clipPathShape) {
3412
+ context.save(); // apply clip shape's RTS
3413
+
3414
+ this.applyTransform(context, clipPathShape.getLocalTransform()); // generate path in local space
3798
3415
 
3416
+ var generatePath = this.pathGeneratorFactory(clipPathShape.nodeName);
3799
3417
 
3800
- context.save(); // apply RTS transformation in world space
3418
+ if (generatePath) {
3419
+ this.useAnchor(context, clipPathShape, function () {
3420
+ context.beginPath();
3421
+ generatePath(context, clipPathShape.parsedStyle);
3422
+ context.closePath();
3423
+ });
3424
+ }
3801
3425
 
3802
- this.applyTransform(context, object.getLocalTransform()); // clip path
3426
+ context.restore();
3427
+ context.clip();
3428
+ } // fill & stroke
3803
3429
 
3804
- var clipPathShape = object.style.clipPath;
3805
3430
 
3806
- if (clipPathShape) {
3807
- context.save(); // apply clip shape's RTS
3431
+ if (!this.enableBatch) {
3432
+ context.save(); // apply attributes to context
3808
3433
 
3809
- this.applyTransform(context, clipPathShape.getLocalTransform()); // generate path in local space
3434
+ this.applyAttributesToContext(context, object, renderingService);
3435
+ } // apply anchor in local space
3810
3436
 
3811
- var generatePath = this.pathGeneratorFactory(clipPathShape.nodeName);
3812
3437
 
3813
- if (generatePath) {
3814
- this.useAnchor(context, clipPathShape, function () {
3815
- context.beginPath();
3816
- generatePath(context, clipPathShape.parsedStyle);
3817
- context.closePath();
3818
- });
3438
+ this.useAnchor(context, object, function () {
3439
+ // generate path in local space
3440
+ var generatePath = _this4.pathGeneratorFactory(object.nodeName);
3441
+
3442
+ if (generatePath) {
3443
+ if (startBatch || !_this4.enableBatch) {
3444
+ context.beginPath();
3819
3445
  }
3820
3446
 
3821
- context.restore();
3822
- context.clip();
3447
+ generatePath(context, object.parsedStyle);
3448
+
3449
+ if (!_this4.enableBatch && object.nodeName !== g.Shape.LINE && object.nodeName !== g.Shape.PATH && object.nodeName !== g.Shape.POLYLINE) {
3450
+ context.closePath();
3451
+ }
3823
3452
  } // fill & stroke
3824
3453
 
3825
3454
 
3826
- if (!this.enableBatch) {
3827
- context.save(); // apply attributes to context
3455
+ if (styleRenderer && !_this4.enableBatch) {
3456
+ styleRenderer.render(context, object.parsedStyle, object);
3457
+ }
3458
+ }); // restore applied attributes, eg. shadowBlur shadowColor...
3828
3459
 
3829
- this.applyAttributesToContext(context, object, renderingService);
3830
- } // apply anchor in local space
3460
+ if (!this.enableBatch) {
3461
+ context.restore();
3462
+ } // finish rendering, clear dirty flag
3831
3463
 
3832
3464
 
3833
- this.useAnchor(context, object, function () {
3834
- // generate path in local space
3835
- var generatePath = _this4.pathGeneratorFactory(object.nodeName);
3465
+ object.renderable.dirty = false;
3466
+ this.restoreStack.push(object);
3467
+ };
3836
3468
 
3837
- if (generatePath) {
3838
- if (startBatch || !_this4.enableBatch) {
3839
- context.beginPath();
3840
- }
3469
+ _proto.convertAABB2Rect = function convertAABB2Rect(aabb) {
3470
+ var min = aabb.getMin();
3471
+ var max = aabb.getMax(); // expand the rectangle a bit to avoid artifacts
3472
+ // @see https://www.yuque.com/antv/ou292n/bi8nix#ExvCu
3473
+
3474
+ var minX = Math.floor(min[0]);
3475
+ var minY = Math.floor(min[1]);
3476
+ var maxX = Math.ceil(max[0]);
3477
+ var maxY = Math.ceil(max[1]);
3478
+ var width = maxX - minX;
3479
+ var height = maxY - minY;
3480
+ return {
3481
+ x: minX,
3482
+ y: minY,
3483
+ width: width,
3484
+ height: height
3485
+ };
3486
+ }
3487
+ /**
3488
+ * TODO: merge dirty rectangles with some strategies.
3489
+ * For now, we just simply merge all the rectangles into one.
3490
+ * @see https://idom.me/articles/841.html
3491
+ */
3492
+ ;
3841
3493
 
3842
- generatePath(context, object.parsedStyle);
3494
+ _proto.mergeDirtyAABBs = function mergeDirtyAABBs(dirtyObjects) {
3495
+ // merge into a big AABB
3496
+ var aabb = new g.AABB();
3497
+ dirtyObjects.forEach(function (object) {
3498
+ var renderBounds = object.getRenderBounds();
3499
+ aabb.add(renderBounds);
3500
+ var dirtyRenderBounds = object.renderable.dirtyRenderBounds;
3843
3501
 
3844
- if (!_this4.enableBatch && object.nodeName !== g.Shape.LINE && object.nodeName !== g.Shape.PATH && object.nodeName !== g.Shape.POLYLINE) {
3845
- context.closePath();
3846
- }
3847
- } // fill & stroke
3502
+ if (dirtyRenderBounds) {
3503
+ aabb.add(dirtyRenderBounds);
3504
+ }
3505
+ });
3506
+ return aabb;
3507
+ };
3848
3508
 
3509
+ _proto.searchDirtyObjects = function searchDirtyObjects(dirtyRectangle) {
3510
+ var _this5 = this; // search in r-tree, get all affected nodes
3849
3511
 
3850
- if (styleRenderer && !_this4.enableBatch) {
3851
- styleRenderer.render(context, object.parsedStyle, object);
3852
- }
3853
- }); // restore applied attributes, eg. shadowBlur shadowColor...
3854
3512
 
3855
- if (!this.enableBatch) {
3856
- context.restore();
3857
- } // finish rendering, clear dirty flag
3513
+ var _dirtyRectangle$getMi = dirtyRectangle.getMin(),
3514
+ minX = _dirtyRectangle$getMi[0],
3515
+ minY = _dirtyRectangle$getMi[1];
3858
3516
 
3517
+ var _dirtyRectangle$getMa = dirtyRectangle.getMax(),
3518
+ maxX = _dirtyRectangle$getMa[0],
3519
+ maxY = _dirtyRectangle$getMa[1];
3859
3520
 
3860
- object.renderable.dirty = false;
3861
- this.restoreStack.push(object);
3862
- }
3863
- }, {
3864
- key: "convertAABB2Rect",
3865
- value: function convertAABB2Rect(aabb) {
3866
- var min = aabb.getMin();
3867
- var max = aabb.getMax(); // expand the rectangle a bit to avoid artifacts
3868
- // @see https://www.yuque.com/antv/ou292n/bi8nix#ExvCu
3521
+ var rBushNodes = this.rBush.search({
3522
+ minX: minX,
3523
+ minY: minY,
3524
+ maxX: maxX,
3525
+ maxY: maxY
3526
+ });
3527
+ return rBushNodes.map(function (_ref3) {
3528
+ var id = _ref3.id;
3529
+ return _this5.displayObjectPool.getByEntity(id);
3530
+ });
3531
+ };
3869
3532
 
3870
- var minX = Math.floor(min[0]);
3871
- var minY = Math.floor(min[1]);
3872
- var maxX = Math.ceil(max[0]);
3873
- var maxY = Math.ceil(max[1]);
3874
- var width = maxX - minX;
3875
- var height = maxY - minY;
3876
- return {
3877
- x: minX,
3878
- y: minY,
3879
- width: width,
3880
- height: height
3881
- };
3533
+ _proto.saveDirtyAABB = function saveDirtyAABB(object) {
3534
+ var renderable = object.renderable;
3535
+
3536
+ if (!renderable.dirtyRenderBounds) {
3537
+ renderable.dirtyRenderBounds = new g.AABB();
3882
3538
  }
3883
- /**
3884
- * TODO: merge dirty rectangles with some strategies.
3885
- * For now, we just simply merge all the rectangles into one.
3886
- * @see https://idom.me/articles/841.html
3887
- */
3888
-
3889
- }, {
3890
- key: "mergeDirtyAABBs",
3891
- value: function mergeDirtyAABBs(dirtyObjects) {
3892
- // merge into a big AABB
3893
- var aabb = new g.AABB();
3894
- dirtyObjects.forEach(function (object) {
3895
- var renderBounds = object.getRenderBounds();
3896
- aabb.add(renderBounds);
3897
- var dirtyRenderBounds = object.renderable.dirtyRenderBounds;
3898
-
3899
- if (dirtyRenderBounds) {
3900
- aabb.add(dirtyRenderBounds);
3901
- }
3902
- });
3903
- return aabb;
3539
+
3540
+ var renderBounds = object.getRenderBounds();
3541
+
3542
+ if (renderBounds) {
3543
+ // save last dirty aabb
3544
+ renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
3904
3545
  }
3905
- }, {
3906
- key: "searchDirtyObjects",
3907
- value: function searchDirtyObjects(dirtyRectangle) {
3908
- var _this5 = this; // search in r-tree, get all affected nodes
3546
+ };
3909
3547
 
3548
+ _proto.applyTransform = function applyTransform(context, transform) {
3549
+ var _mat4$getTranslation = getTranslation(create$1(), transform),
3550
+ tx = _mat4$getTranslation[0],
3551
+ ty = _mat4$getTranslation[1];
3910
3552
 
3911
- var _dirtyRectangle$getMi = dirtyRectangle.getMin(),
3912
- _dirtyRectangle$getMi2 = _slicedToArray(_dirtyRectangle$getMi, 2),
3913
- minX = _dirtyRectangle$getMi2[0],
3914
- minY = _dirtyRectangle$getMi2[1];
3553
+ var _mat4$getScaling = getScaling(create$1(), transform),
3554
+ sx = _mat4$getScaling[0],
3555
+ sy = _mat4$getScaling[1];
3915
3556
 
3916
- var _dirtyRectangle$getMa = dirtyRectangle.getMax(),
3917
- _dirtyRectangle$getMa2 = _slicedToArray(_dirtyRectangle$getMa, 2),
3918
- maxX = _dirtyRectangle$getMa2[0],
3919
- maxY = _dirtyRectangle$getMa2[1];
3557
+ var rotation = getRotation(create$3(), transform); // eslint-disable-next-line @typescript-eslint/no-unused-vars
3920
3558
 
3921
- var rBushNodes = this.rBush.search({
3922
- minX: minX,
3923
- minY: minY,
3924
- maxX: maxX,
3925
- maxY: maxY
3926
- });
3927
- return rBushNodes.map(function (_ref3) {
3928
- var id = _ref3.id;
3929
- return _this5.displayObjectPool.getByEntity(id);
3930
- });
3931
- }
3932
- }, {
3933
- key: "saveDirtyAABB",
3934
- value: function saveDirtyAABB(object) {
3935
- var renderable = object.renderable;
3559
+ var _getEuler = g.getEuler(create$1(), rotation),
3560
+ eux = _getEuler[0],
3561
+ euy = _getEuler[1],
3562
+ euz = _getEuler[2]; // gimbal lock at 90 degrees
3936
3563
 
3937
- if (!renderable.dirtyRenderBounds) {
3938
- renderable.dirtyRenderBounds = new g.AABB();
3939
- }
3940
3564
 
3941
- var renderBounds = object.getRenderBounds();
3565
+ var rts = g.fromRotationTranslationScale(eux || euz, tx, ty, sx, sy); // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
3942
3566
 
3943
- if (renderBounds) {
3944
- // save last dirty aabb
3945
- renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
3946
- }
3947
- }
3948
- }, {
3949
- key: "applyTransform",
3950
- value: function applyTransform(context, transform) {
3951
- var _mat4$getTranslation = getTranslation(create$1(), transform),
3952
- _mat4$getTranslation2 = _slicedToArray(_mat4$getTranslation, 2),
3953
- tx = _mat4$getTranslation2[0],
3954
- ty = _mat4$getTranslation2[1];
3955
-
3956
- var _mat4$getScaling = getScaling(create$1(), transform),
3957
- _mat4$getScaling2 = _slicedToArray(_mat4$getScaling, 2),
3958
- sx = _mat4$getScaling2[0],
3959
- sy = _mat4$getScaling2[1];
3960
-
3961
- var rotation = getRotation(create$3(), transform); // eslint-disable-next-line @typescript-eslint/no-unused-vars
3962
-
3963
- var _getEuler = g.getEuler(create$1(), rotation),
3964
- _getEuler2 = _slicedToArray(_getEuler, 3),
3965
- eux = _getEuler2[0],
3966
- euy = _getEuler2[1],
3967
- euz = _getEuler2[2]; // gimbal lock at 90 degrees
3968
-
3969
-
3970
- var rts = g.fromRotationTranslationScale(eux || euz, tx, ty, sx, sy); // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
3971
-
3972
- context.transform(rts[0], rts[1], rts[3], rts[4], rts[6], rts[7]);
3973
- }
3974
- }, {
3975
- key: "getColor",
3976
- value: function getColor(parsedColor, object, context, renderingService) {
3977
- var color;
3978
-
3979
- if (parsedColor instanceof g.CSSGradientValue) {
3980
- if (parsedColor.type === g.GradientPatternType.LinearGradient || parsedColor.type === g.GradientPatternType.RadialGradient) {
3981
- var bounds = object.getGeometryBounds();
3982
- var width = bounds && bounds.halfExtents[0] * 2 || 0;
3983
- var height = bounds && bounds.halfExtents[1] * 2 || 0;
3984
- color = this.gradientPool.getOrCreateGradient(_objectSpread2(_objectSpread2({
3985
- type: parsedColor.type
3986
- }, parsedColor.value), {}, {
3987
- width: width,
3988
- height: height
3989
- }), context);
3990
- } else if (parsedColor.type === g.GradientPatternType.Pattern) {
3991
- var pattern = this.imagePool.getPatternSync(parsedColor.value);
3992
-
3993
- if (pattern) {
3994
- color = pattern;
3995
- } else {
3996
- this.imagePool.createPattern(parsedColor.value, context).then(function () {
3997
- // set dirty rectangle flag
3998
- object.renderable.dirty = true;
3999
- renderingService.dirtify();
4000
- });
4001
- }
3567
+ context.transform(rts[0], rts[1], rts[3], rts[4], rts[6], rts[7]);
3568
+ };
3569
+
3570
+ _proto.getColor = function getColor(parsedColor, object, context, renderingService) {
3571
+ var color;
3572
+
3573
+ if (parsedColor instanceof g.CSSGradientValue) {
3574
+ if (parsedColor.type === g.GradientPatternType.LinearGradient || parsedColor.type === g.GradientPatternType.RadialGradient) {
3575
+ var bounds = object.getGeometryBounds();
3576
+ var width = bounds && bounds.halfExtents[0] * 2 || 0;
3577
+ var height = bounds && bounds.halfExtents[1] * 2 || 0;
3578
+ color = this.gradientPool.getOrCreateGradient(_extends({
3579
+ type: parsedColor.type
3580
+ }, parsedColor.value, {
3581
+ width: width,
3582
+ height: height
3583
+ }), context);
3584
+ } else if (parsedColor.type === g.GradientPatternType.Pattern) {
3585
+ var pattern = this.imagePool.getPatternSync(parsedColor.value);
3586
+
3587
+ if (pattern) {
3588
+ color = pattern;
3589
+ } else {
3590
+ this.imagePool.createPattern(parsedColor.value, context).then(function () {
3591
+ // set dirty rectangle flag
3592
+ object.renderable.dirty = true;
3593
+ renderingService.dirtify();
3594
+ });
4002
3595
  }
4003
- } else {
4004
- // constant, eg. rgba(255,255,255,1)
4005
- color = parsedColor.toString();
4006
3596
  }
3597
+ } else {
3598
+ // constant, eg. rgba(255,255,255,1)
3599
+ color = parsedColor.toString();
3600
+ }
4007
3601
 
4008
- return color;
4009
- }
4010
- }, {
4011
- key: "applyAttributesToContext",
4012
- value: function applyAttributesToContext(context, object, renderingService) {
4013
- var _object$parsedStyle = object.parsedStyle,
4014
- stroke = _object$parsedStyle.stroke,
4015
- fill = _object$parsedStyle.fill,
4016
- opacity = _object$parsedStyle.opacity,
4017
- lineDash = _object$parsedStyle.lineDash,
4018
- lineDashOffset = _object$parsedStyle.lineDashOffset,
4019
- filter = _object$parsedStyle.filter,
4020
- shadowColor = _object$parsedStyle.shadowColor,
4021
- shadowBlur = _object$parsedStyle.shadowBlur,
4022
- shadowOffsetX = _object$parsedStyle.shadowOffsetX,
4023
- shadowOffsetY = _object$parsedStyle.shadowOffsetY; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/setLineDash
4024
-
4025
- if (lineDash && Array.isArray(lineDash)) {
4026
- context.setLineDash(lineDash.map(function (segment) {
4027
- return segment.value;
4028
- }));
4029
- } // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/lineDashOffset
4030
-
4031
-
4032
- if (!g.isNil(lineDashOffset)) {
4033
- context.lineDashOffset = lineDashOffset.value;
4034
- }
3602
+ return color;
3603
+ };
4035
3604
 
4036
- if (!g.isNil(opacity)) {
4037
- context.globalAlpha *= opacity.value;
4038
- }
3605
+ _proto.applyAttributesToContext = function applyAttributesToContext(context, object, renderingService) {
3606
+ var _object$parsedStyle = object.parsedStyle,
3607
+ stroke = _object$parsedStyle.stroke,
3608
+ fill = _object$parsedStyle.fill,
3609
+ opacity = _object$parsedStyle.opacity,
3610
+ lineDash = _object$parsedStyle.lineDash,
3611
+ lineDashOffset = _object$parsedStyle.lineDashOffset,
3612
+ filter = _object$parsedStyle.filter,
3613
+ shadowColor = _object$parsedStyle.shadowColor,
3614
+ shadowBlur = _object$parsedStyle.shadowBlur,
3615
+ shadowOffsetX = _object$parsedStyle.shadowOffsetX,
3616
+ shadowOffsetY = _object$parsedStyle.shadowOffsetY; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/setLineDash
4039
3617
 
4040
- if (!g.isNil(stroke) && !stroke.isNone) {
4041
- context.strokeStyle = this.getColor(stroke, object, context, renderingService);
4042
- }
3618
+ if (lineDash && Array.isArray(lineDash)) {
3619
+ context.setLineDash(lineDash.map(function (segment) {
3620
+ return segment.value;
3621
+ }));
3622
+ } // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/lineDashOffset
4043
3623
 
4044
- if (!g.isNil(fill) && !fill.isNone) {
4045
- context.fillStyle = this.getColor(fill, object, context, renderingService);
4046
- }
4047
3624
 
4048
- if (!g.isNil(filter)) {
4049
- // use raw filter string
4050
- context.filter = object.style.filter;
4051
- }
3625
+ if (!g.isNil(lineDashOffset)) {
3626
+ context.lineDashOffset = lineDashOffset.value;
3627
+ }
4052
3628
 
4053
- if (!g.isNil(shadowColor)) {
4054
- context.shadowColor = shadowColor.toString();
4055
- context.shadowBlur = shadowBlur && shadowBlur.value || 0;
4056
- context.shadowOffsetX = shadowOffsetX && shadowOffsetX.value || 0;
4057
- context.shadowOffsetY = shadowOffsetY && shadowOffsetY.value || 0;
4058
- }
3629
+ if (!g.isNil(opacity)) {
3630
+ context.globalAlpha *= opacity.value;
4059
3631
  }
4060
- }, {
4061
- key: "useAnchor",
4062
- value: function useAnchor(context, object, callback) {
4063
- var contentBounds = object.getGeometryBounds();
4064
3632
 
4065
- if (contentBounds) {
4066
- var halfExtents = contentBounds.halfExtents; // apply anchor, use true size, not include stroke,
4067
- // eg. bounds = true size + half lineWidth
3633
+ if (!g.isNil(stroke) && !stroke.isNone) {
3634
+ context.strokeStyle = this.getColor(stroke, object, context, renderingService);
3635
+ }
4068
3636
 
4069
- var _ref4 = object.parsedStyle || {},
4070
- anchor = _ref4.anchor;
3637
+ if (!g.isNil(fill) && !fill.isNone) {
3638
+ context.fillStyle = this.getColor(fill, object, context, renderingService);
3639
+ }
4071
3640
 
4072
- context.translate(-(anchor && anchor[0].value || 0) * halfExtents[0] * 2, -(anchor && anchor[1].value || 0) * halfExtents[1] * 2);
4073
- callback();
4074
- } else {
4075
- callback();
4076
- }
3641
+ if (!g.isNil(filter)) {
3642
+ // use raw filter string
3643
+ context.filter = object.style.filter;
4077
3644
  }
4078
- }, {
4079
- key: "safeMergeAABB",
4080
- value: function safeMergeAABB() {
4081
- var merged = new g.AABB();
4082
3645
 
4083
- for (var _len = arguments.length, aabbs = new Array(_len), _key = 0; _key < _len; _key++) {
4084
- aabbs[_key] = arguments[_key];
4085
- }
3646
+ if (!g.isNil(shadowColor)) {
3647
+ context.shadowColor = shadowColor.toString();
3648
+ context.shadowBlur = shadowBlur && shadowBlur.value || 0;
3649
+ context.shadowOffsetX = shadowOffsetX && shadowOffsetX.value || 0;
3650
+ context.shadowOffsetY = shadowOffsetY && shadowOffsetY.value || 0;
3651
+ }
3652
+ };
4086
3653
 
4087
- aabbs.forEach(function (aabb) {
4088
- merged.add(aabb);
4089
- });
4090
- return merged;
3654
+ _proto.useAnchor = function useAnchor(context, object, callback) {
3655
+ var contentBounds = object.getGeometryBounds();
3656
+
3657
+ if (contentBounds) {
3658
+ var halfExtents = contentBounds.halfExtents; // apply anchor, use true size, not include stroke,
3659
+ // eg. bounds = true size + half lineWidth
3660
+
3661
+ var _ref4 = object.parsedStyle || {},
3662
+ anchor = _ref4.anchor;
3663
+
3664
+ context.translate(-(anchor && anchor[0].value || 0) * halfExtents[0] * 2, -(anchor && anchor[1].value || 0) * halfExtents[1] * 2);
3665
+ callback();
3666
+ } else {
3667
+ callback();
3668
+ }
3669
+ };
3670
+
3671
+ _proto.safeMergeAABB = function safeMergeAABB() {
3672
+ var merged = new g.AABB();
3673
+
3674
+ for (var _len = arguments.length, aabbs = new Array(_len), _key = 0; _key < _len; _key++) {
3675
+ aabbs[_key] = arguments[_key];
4091
3676
  }
4092
- }]);
3677
+
3678
+ aabbs.forEach(function (aabb) {
3679
+ merged.add(aabb);
3680
+ });
3681
+ return merged;
3682
+ };
4093
3683
 
4094
3684
  return CanvasRendererPlugin;
4095
3685
  }(), _class$1.tag = 'CanvasRenderer', _class$1);
@@ -4123,155 +3713,84 @@
4123
3713
  var LoadImagePlugin_1;
4124
3714
  var LoadImagePlugin = LoadImagePlugin_1 = (_class$1$1 = /*#__PURE__*/function () {
4125
3715
  function LoadImagePlugin() {
4126
- _classCallCheck$2(this, LoadImagePlugin);
4127
-
4128
3716
  this.imagePool = void 0;
4129
3717
  this.renderingContext = void 0;
4130
3718
  }
4131
3719
 
4132
- _createClass$2(LoadImagePlugin, [{
4133
- key: "apply",
4134
- value: function apply(renderingService) {
4135
- var _this = this;
3720
+ var _proto = LoadImagePlugin.prototype;
4136
3721
 
4137
- var handleMounted = function handleMounted(e) {
4138
- var object = e.target;
4139
- var nodeName = object.nodeName,
4140
- attributes = object.attributes;
3722
+ _proto.apply = function apply(renderingService) {
3723
+ var _this = this;
3724
+
3725
+ var handleMounted = function handleMounted(e) {
3726
+ var object = e.target;
3727
+ var nodeName = object.nodeName,
3728
+ attributes = object.attributes;
3729
+
3730
+ if (nodeName === g.Shape.IMAGE) {
3731
+ var img = attributes.img;
3732
+
3733
+ if (g.isString(img)) {
3734
+ _this.imagePool.getOrCreateImage(img).then(function () {
3735
+ // set dirty rectangle flag
3736
+ object.renderable.dirty = true;
3737
+ renderingService.dirtify();
3738
+ });
3739
+ }
3740
+ }
3741
+ };
4141
3742
 
4142
- if (nodeName === g.Shape.IMAGE) {
4143
- var img = attributes.img;
3743
+ var handleAttributeChanged = function handleAttributeChanged(e) {
3744
+ var object = e.target;
3745
+ var attrName = e.attrName,
3746
+ newValue = e.newValue;
4144
3747
 
4145
- if (g.isString(img)) {
4146
- _this.imagePool.getOrCreateImage(img).then(function () {
3748
+ if (object.nodeName === g.Shape.IMAGE) {
3749
+ if (attrName === 'img') {
3750
+ if (g.isString(newValue)) {
3751
+ _this.imagePool.getOrCreateImage(newValue).then(function () {
4147
3752
  // set dirty rectangle flag
4148
3753
  object.renderable.dirty = true;
4149
3754
  renderingService.dirtify();
4150
3755
  });
4151
3756
  }
4152
3757
  }
4153
- };
4154
-
4155
- var handleAttributeChanged = function handleAttributeChanged(e) {
4156
- var object = e.target;
4157
- var attrName = e.attrName,
4158
- newValue = e.newValue;
4159
-
4160
- if (object.nodeName === g.Shape.IMAGE) {
4161
- if (attrName === 'img') {
4162
- if (g.isString(newValue)) {
4163
- _this.imagePool.getOrCreateImage(newValue).then(function () {
4164
- // set dirty rectangle flag
4165
- object.renderable.dirty = true;
4166
- renderingService.dirtify();
4167
- });
4168
- }
4169
- }
4170
- }
4171
- };
3758
+ }
3759
+ };
4172
3760
 
4173
- renderingService.hooks.init.tapPromise(LoadImagePlugin_1.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
4174
- return _regeneratorRuntime$1().wrap(function _callee$(_context) {
4175
- while (1) {
4176
- switch (_context.prev = _context.next) {
4177
- case 0:
4178
- _this.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
3761
+ renderingService.hooks.init.tapPromise(LoadImagePlugin_1.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
3762
+ return _regeneratorRuntime$1().wrap(function _callee$(_context) {
3763
+ while (1) {
3764
+ switch (_context.prev = _context.next) {
3765
+ case 0:
3766
+ _this.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
4179
3767
 
4180
- _this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
3768
+ _this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
4181
3769
 
4182
- case 2:
4183
- case "end":
4184
- return _context.stop();
4185
- }
3770
+ case 2:
3771
+ case "end":
3772
+ return _context.stop();
4186
3773
  }
4187
- }, _callee);
4188
- })));
4189
- renderingService.hooks.destroy.tap(LoadImagePlugin_1.tag, function () {
4190
- _this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
4191
-
4192
- _this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
4193
- });
4194
- }
4195
- }]);
4196
-
4197
- return LoadImagePlugin;
4198
- }(), _class$1$1.tag = 'LoadImage', _class$1$1);
4199
-
4200
- __decorate([manaSyringe.inject(ImagePool), __metadata("design:type", ImagePool)], LoadImagePlugin.prototype, "imagePool", void 0);
4201
-
4202
- __decorate([manaSyringe.inject(g.RenderingContext), __metadata("design:type", Object)], LoadImagePlugin.prototype, "renderingContext", void 0);
3774
+ }
3775
+ }, _callee);
3776
+ })));
3777
+ renderingService.hooks.destroy.tap(LoadImagePlugin_1.tag, function () {
3778
+ _this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
4203
3779
 
4204
- LoadImagePlugin = LoadImagePlugin_1 = __decorate([manaSyringe.singleton({
4205
- contrib: g.RenderingPluginContribution
4206
- })], LoadImagePlugin);
4207
- /**
4208
- * register shape renderers
4209
- */
3780
+ _this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
3781
+ });
3782
+ };
4210
3783
 
4211
- manaSyringe.GlobalContainer.register({
4212
- token: {
4213
- token: PathGenerator,
4214
- named: g.Shape.CIRCLE
4215
- },
4216
- useValue: generatePath
4217
- });
4218
- manaSyringe.GlobalContainer.register({
4219
- token: {
4220
- token: PathGenerator,
4221
- named: g.Shape.ELLIPSE
4222
- },
4223
- useValue: generatePath$1
4224
- });
4225
- manaSyringe.GlobalContainer.register({
4226
- token: {
4227
- token: PathGenerator,
4228
- named: g.Shape.RECT
4229
- },
4230
- useValue: generatePath$2
4231
- });
4232
- manaSyringe.GlobalContainer.register({
4233
- token: {
4234
- token: PathGenerator,
4235
- named: g.Shape.LINE
4236
- },
4237
- useValue: generatePath$3
4238
- });
4239
- manaSyringe.GlobalContainer.register({
4240
- token: {
4241
- token: PathGenerator,
4242
- named: g.Shape.POLYLINE
4243
- },
4244
- useValue: generatePath$4
4245
- });
4246
- manaSyringe.GlobalContainer.register({
4247
- token: {
4248
- token: PathGenerator,
4249
- named: g.Shape.POLYGON
4250
- },
4251
- useValue: generatePath$5
4252
- });
4253
- manaSyringe.GlobalContainer.register({
4254
- token: {
4255
- token: PathGenerator,
4256
- named: g.Shape.PATH
4257
- },
4258
- useValue: generatePath$6
4259
- });
4260
- manaSyringe.GlobalContainer.register({
4261
- token: PathGeneratorFactory,
4262
- useFactory: function useFactory(ctx) {
4263
- var cache = {};
4264
- return function (tagName) {
4265
- if (!cache[tagName]) {
4266
- if (ctx.container.isBoundNamed(PathGenerator, tagName)) {
4267
- cache[tagName] = ctx.container.getNamed(PathGenerator, tagName);
4268
- }
4269
- }
3784
+ return LoadImagePlugin;
3785
+ }(), _class$1$1.tag = 'LoadImage', _class$1$1);
4270
3786
 
4271
- return cache[tagName];
4272
- };
4273
- }
4274
- });
3787
+ __decorate([manaSyringe.inject(ImagePool), __metadata("design:type", ImagePool)], LoadImagePlugin.prototype, "imagePool", void 0);
3788
+
3789
+ __decorate([manaSyringe.inject(g.RenderingContext), __metadata("design:type", Object)], LoadImagePlugin.prototype, "renderingContext", void 0);
3790
+
3791
+ LoadImagePlugin = LoadImagePlugin_1 = __decorate([manaSyringe.singleton({
3792
+ contrib: g.RenderingPluginContribution
3793
+ })], LoadImagePlugin);
4275
3794
  var containerModule$1 = manaSyringe.Module(function (register) {
4276
3795
  var _shape2Token;
4277
3796
 
@@ -4289,7 +3808,7 @@
4289
3808
  register(PolylineRenderer);
4290
3809
  register(PolygonRenderer);
4291
3810
  register(PathRenderer);
4292
- var shape2Token = (_shape2Token = {}, _defineProperty(_shape2Token, g.Shape.CIRCLE, CircleRendererContribution), _defineProperty(_shape2Token, g.Shape.ELLIPSE, EllipseRendererContribution), _defineProperty(_shape2Token, g.Shape.RECT, RectRendererContribution), _defineProperty(_shape2Token, g.Shape.IMAGE, ImageRendererContribution), _defineProperty(_shape2Token, g.Shape.TEXT, TextRendererContribution), _defineProperty(_shape2Token, g.Shape.LINE, LineRendererContribution), _defineProperty(_shape2Token, g.Shape.POLYLINE, PolylineRendererContribution), _defineProperty(_shape2Token, g.Shape.POLYGON, PolygonRendererContribution), _defineProperty(_shape2Token, g.Shape.PATH, PathRendererContribution), _shape2Token);
3811
+ var shape2Token = (_shape2Token = {}, _shape2Token[g.Shape.CIRCLE] = CircleRendererContribution, _shape2Token[g.Shape.ELLIPSE] = EllipseRendererContribution, _shape2Token[g.Shape.RECT] = RectRendererContribution, _shape2Token[g.Shape.IMAGE] = ImageRendererContribution, _shape2Token[g.Shape.TEXT] = TextRendererContribution, _shape2Token[g.Shape.LINE] = LineRendererContribution, _shape2Token[g.Shape.POLYLINE] = PolylineRendererContribution, _shape2Token[g.Shape.POLYGON] = PolygonRendererContribution, _shape2Token[g.Shape.PATH] = PathRendererContribution, _shape2Token);
4293
3812
  register({
4294
3813
  token: StyleRendererFactory,
4295
3814
  useFactory: function useFactory(ctx) {
@@ -4314,22 +3833,88 @@
4314
3833
 
4315
3834
  var Plugin$1 = /*#__PURE__*/function () {
4316
3835
  function Plugin() {
4317
- _classCallCheck$2(this, Plugin);
4318
-
4319
3836
  this.name = 'canvas-renderer';
4320
3837
  }
4321
3838
 
4322
- _createClass$2(Plugin, [{
4323
- key: "init",
4324
- value: function init(container) {
4325
- container.load(containerModule$1, true);
4326
- }
4327
- }, {
4328
- key: "destroy",
4329
- value: function destroy(container) {
4330
- container.unload(containerModule$1);
3839
+ var _proto = Plugin.prototype;
3840
+
3841
+ _proto.init = function init(container) {
3842
+ if (!manaSyringe.GlobalContainer.isBound(PathGeneratorFactory)) {
3843
+ /**
3844
+ * register shape renderers
3845
+ */
3846
+ manaSyringe.GlobalContainer.register({
3847
+ token: {
3848
+ token: PathGenerator,
3849
+ named: g.Shape.CIRCLE
3850
+ },
3851
+ useValue: generatePath
3852
+ });
3853
+ manaSyringe.GlobalContainer.register({
3854
+ token: {
3855
+ token: PathGenerator,
3856
+ named: g.Shape.ELLIPSE
3857
+ },
3858
+ useValue: generatePath$1
3859
+ });
3860
+ manaSyringe.GlobalContainer.register({
3861
+ token: {
3862
+ token: PathGenerator,
3863
+ named: g.Shape.RECT
3864
+ },
3865
+ useValue: generatePath$2
3866
+ });
3867
+ manaSyringe.GlobalContainer.register({
3868
+ token: {
3869
+ token: PathGenerator,
3870
+ named: g.Shape.LINE
3871
+ },
3872
+ useValue: generatePath$3
3873
+ });
3874
+ manaSyringe.GlobalContainer.register({
3875
+ token: {
3876
+ token: PathGenerator,
3877
+ named: g.Shape.POLYLINE
3878
+ },
3879
+ useValue: generatePath$4
3880
+ });
3881
+ manaSyringe.GlobalContainer.register({
3882
+ token: {
3883
+ token: PathGenerator,
3884
+ named: g.Shape.POLYGON
3885
+ },
3886
+ useValue: generatePath$5
3887
+ });
3888
+ manaSyringe.GlobalContainer.register({
3889
+ token: {
3890
+ token: PathGenerator,
3891
+ named: g.Shape.PATH
3892
+ },
3893
+ useValue: generatePath$6
3894
+ });
3895
+ manaSyringe.GlobalContainer.register({
3896
+ token: PathGeneratorFactory,
3897
+ useFactory: function useFactory(ctx) {
3898
+ var cache = {};
3899
+ return function (tagName) {
3900
+ if (!cache[tagName]) {
3901
+ if (ctx.container.isBoundNamed(PathGenerator, tagName)) {
3902
+ cache[tagName] = ctx.container.getNamed(PathGenerator, tagName);
3903
+ }
3904
+ }
3905
+
3906
+ return cache[tagName];
3907
+ };
3908
+ }
3909
+ });
4331
3910
  }
4332
- }]);
3911
+
3912
+ container.load(containerModule$1, true);
3913
+ };
3914
+
3915
+ _proto.destroy = function destroy(container) {
3916
+ container.unload(containerModule$1);
3917
+ };
4333
3918
 
4334
3919
  return Plugin;
4335
3920
  }();
@@ -4488,7 +4073,7 @@
4488
4073
  if ("throw" !== record.type) {
4489
4074
  var result = record.arg,
4490
4075
  value = result.value;
4491
- return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
4076
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
4492
4077
  invoke("next", value, resolve, reject);
4493
4078
  }, function (err) {
4494
4079
  invoke("throw", err, resolve, reject);
@@ -4748,92 +4333,6 @@
4748
4333
  });
4749
4334
  };
4750
4335
  }
4751
-
4752
- function _classCallCheck$3(instance, Constructor) {
4753
- if (!(instance instanceof Constructor)) {
4754
- throw new TypeError("Cannot call a class as a function");
4755
- }
4756
- }
4757
-
4758
- function _defineProperties$3(target, props) {
4759
- for (var i = 0; i < props.length; i++) {
4760
- var descriptor = props[i];
4761
- descriptor.enumerable = descriptor.enumerable || false;
4762
- descriptor.configurable = true;
4763
- if ("value" in descriptor) descriptor.writable = true;
4764
- Object.defineProperty(target, descriptor.key, descriptor);
4765
- }
4766
- }
4767
-
4768
- function _createClass$3(Constructor, protoProps, staticProps) {
4769
- if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
4770
- if (staticProps) _defineProperties$3(Constructor, staticProps);
4771
- Object.defineProperty(Constructor, "prototype", {
4772
- writable: false
4773
- });
4774
- return Constructor;
4775
- }
4776
-
4777
- function _slicedToArray$1(arr, i) {
4778
- return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest$1();
4779
- }
4780
-
4781
- function _arrayWithHoles$1(arr) {
4782
- if (Array.isArray(arr)) return arr;
4783
- }
4784
-
4785
- function _iterableToArrayLimit$1(arr, i) {
4786
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
4787
-
4788
- if (_i == null) return;
4789
- var _arr = [];
4790
- var _n = true;
4791
- var _d = false;
4792
-
4793
- var _s, _e;
4794
-
4795
- try {
4796
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
4797
- _arr.push(_s.value);
4798
-
4799
- if (i && _arr.length === i) break;
4800
- }
4801
- } catch (err) {
4802
- _d = true;
4803
- _e = err;
4804
- } finally {
4805
- try {
4806
- if (!_n && _i["return"] != null) _i["return"]();
4807
- } finally {
4808
- if (_d) throw _e;
4809
- }
4810
- }
4811
-
4812
- return _arr;
4813
- }
4814
-
4815
- function _unsupportedIterableToArray$1(o, minLen) {
4816
- if (!o) return;
4817
- if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
4818
- var n = Object.prototype.toString.call(o).slice(8, -1);
4819
- if (n === "Object" && o.constructor) n = o.constructor.name;
4820
- if (n === "Map" || n === "Set") return Array.from(o);
4821
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
4822
- }
4823
-
4824
- function _arrayLikeToArray$1(arr, len) {
4825
- if (len == null || len > arr.length) len = arr.length;
4826
-
4827
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
4828
- arr2[i] = arr[i];
4829
- }
4830
-
4831
- return arr2;
4832
- }
4833
-
4834
- function _nonIterableRest$1() {
4835
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4836
- }
4837
4336
  /**
4838
4337
  * Common utilities
4839
4338
  * @module glMatrix
@@ -5428,8 +4927,6 @@
5428
4927
  function CanvasPickerPlugin() {
5429
4928
  var _this = this;
5430
4929
 
5431
- _classCallCheck$3(this, CanvasPickerPlugin);
5432
-
5433
4930
  this.displayObjectPool = void 0;
5434
4931
  this.canvasConfig = void 0;
5435
4932
  this.offscreenCanvas = void 0;
@@ -5475,109 +4972,108 @@
5475
4972
  };
5476
4973
  }
5477
4974
 
5478
- _createClass$3(CanvasPickerPlugin, [{
5479
- key: "apply",
5480
- value: function apply(renderingService) {
5481
- var _this2 = this;
5482
-
5483
- renderingService.hooks.pick.tapPromise(CanvasPickerPlugin_1.tag, /*#__PURE__*/function () {
5484
- var _ref = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee(result) {
5485
- var topmost, _result$position, x, y, position, rBushNodes, queriedIds, hitTestList, pickedDisplayObjects, _i, _hitTestList, displayObject, clipPath, objectToTest, worldTransform;
5486
-
5487
- return _regeneratorRuntime$2().wrap(function _callee$(_context) {
5488
- while (1) {
5489
- switch (_context.prev = _context.next) {
5490
- case 0:
5491
- topmost = result.topmost, _result$position = result.position, x = _result$position.x, y = _result$position.y; // position in world space
5492
-
5493
- position = fromValues$1(x, y, 0); // query by AABB first with spatial index(r-tree)
5494
-
5495
- rBushNodes = _this2.rBush.search({
5496
- minX: position[0],
5497
- minY: position[1],
5498
- maxX: position[0],
5499
- maxY: position[1]
5500
- });
5501
- queriedIds = rBushNodes.map(function (node) {
5502
- return node.id;
5503
- });
5504
- hitTestList = [];
5505
- rBushNodes.forEach(function (_ref2) {
5506
- var id = _ref2.id;
5507
-
5508
- var displayObject = _this2.displayObjectPool.getByEntity(id);
5509
-
5510
- if (displayObject.isVisible() && !displayObject.isCulled() && displayObject.isInteractive()) {
5511
- // parent is not included, eg. parent is clipped
5512
- if (displayObject.parentNode && queriedIds.indexOf(displayObject.parentNode.entity) === -1) {
5513
- return;
5514
- }
5515
-
5516
- hitTestList.push(displayObject);
5517
- }
5518
- }); // find group with max z-index
5519
-
5520
- hitTestList.sort(function (a, b) {
5521
- return b.sortable.renderOrder - a.sortable.renderOrder;
5522
- });
5523
- pickedDisplayObjects = [];
5524
- _i = 0, _hitTestList = hitTestList;
5525
-
5526
- case 9:
5527
- if (!(_i < _hitTestList.length)) {
5528
- _context.next = 25;
5529
- break;
5530
- }
4975
+ var _proto = CanvasPickerPlugin.prototype;
5531
4976
 
5532
- displayObject = _hitTestList[_i]; // test with clip path
4977
+ _proto.apply = function apply(renderingService) {
4978
+ var _this2 = this;
5533
4979
 
5534
- clipPath = displayObject.parsedStyle.clipPath;
5535
- objectToTest = clipPath || displayObject;
5536
- worldTransform = displayObject.getWorldTransform(); // clipped's world matrix * clipPath's local matrix
4980
+ renderingService.hooks.pick.tapPromise(CanvasPickerPlugin_1.tag, /*#__PURE__*/function () {
4981
+ var _ref = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee(result) {
4982
+ var topmost, _result$position, x, y, position, rBushNodes, queriedIds, hitTestList, pickedDisplayObjects, _i, _hitTestList, displayObject, clipPath, objectToTest, worldTransform;
5537
4983
 
5538
- if (clipPath) {
5539
- worldTransform = multiply$1(create$1$1(), worldTransform, clipPath.getLocalTransform());
5540
- }
4984
+ return _regeneratorRuntime$2().wrap(function _callee$(_context) {
4985
+ while (1) {
4986
+ switch (_context.prev = _context.next) {
4987
+ case 0:
4988
+ topmost = result.topmost, _result$position = result.position, x = _result$position.x, y = _result$position.y; // position in world space
5541
4989
 
5542
- if (!_this2.isHit(objectToTest, position, worldTransform)) {
5543
- _context.next = 22;
5544
- break;
5545
- }
4990
+ position = fromValues$1(x, y, 0); // query by AABB first with spatial index(r-tree)
4991
+
4992
+ rBushNodes = _this2.rBush.search({
4993
+ minX: position[0],
4994
+ minY: position[1],
4995
+ maxX: position[0],
4996
+ maxY: position[1]
4997
+ });
4998
+ queriedIds = rBushNodes.map(function (node) {
4999
+ return node.id;
5000
+ });
5001
+ hitTestList = [];
5002
+ rBushNodes.forEach(function (_ref2) {
5003
+ var id = _ref2.id;
5004
+
5005
+ var displayObject = _this2.displayObjectPool.getByEntity(id);
5006
+
5007
+ if (displayObject.isVisible() && !displayObject.isCulled() && displayObject.isInteractive()) {
5008
+ // parent is not included, eg. parent is clipped
5009
+ if (displayObject.parentNode && queriedIds.indexOf(displayObject.parentNode.entity) === -1) {
5010
+ return;
5011
+ }
5546
5012
 
5547
- if (!topmost) {
5548
- _context.next = 21;
5549
- break;
5013
+ hitTestList.push(displayObject);
5550
5014
  }
5015
+ }); // find group with max z-index
5016
+
5017
+ hitTestList.sort(function (a, b) {
5018
+ return b.sortable.renderOrder - a.sortable.renderOrder;
5019
+ });
5020
+ pickedDisplayObjects = [];
5021
+ _i = 0, _hitTestList = hitTestList;
5022
+
5023
+ case 9:
5024
+ if (!(_i < _hitTestList.length)) {
5025
+ _context.next = 25;
5026
+ break;
5027
+ }
5028
+
5029
+ displayObject = _hitTestList[_i]; // test with clip path
5030
+
5031
+ clipPath = displayObject.parsedStyle.clipPath;
5032
+ objectToTest = clipPath || displayObject;
5033
+ worldTransform = displayObject.getWorldTransform(); // clipped's world matrix * clipPath's local matrix
5551
5034
 
5552
- result.picked = [displayObject];
5553
- return _context.abrupt("return", result);
5035
+ if (clipPath) {
5036
+ worldTransform = multiply$1(create$1$1(), worldTransform, clipPath.getLocalTransform());
5037
+ }
5554
5038
 
5555
- case 21:
5556
- pickedDisplayObjects.push(displayObject);
5039
+ if (!_this2.isHit(objectToTest, position, worldTransform)) {
5040
+ _context.next = 22;
5041
+ break;
5042
+ }
5557
5043
 
5558
- case 22:
5559
- _i++;
5560
- _context.next = 9;
5044
+ if (!topmost) {
5045
+ _context.next = 21;
5561
5046
  break;
5047
+ }
5562
5048
 
5563
- case 25:
5564
- result.picked = pickedDisplayObjects;
5565
- return _context.abrupt("return", result);
5049
+ result.picked = [displayObject];
5050
+ return _context.abrupt("return", result);
5566
5051
 
5567
- case 27:
5568
- case "end":
5569
- return _context.stop();
5570
- }
5052
+ case 21:
5053
+ pickedDisplayObjects.push(displayObject);
5054
+
5055
+ case 22:
5056
+ _i++;
5057
+ _context.next = 9;
5058
+ break;
5059
+
5060
+ case 25:
5061
+ result.picked = pickedDisplayObjects;
5062
+ return _context.abrupt("return", result);
5063
+
5064
+ case 27:
5065
+ case "end":
5066
+ return _context.stop();
5571
5067
  }
5572
- }, _callee);
5573
- }));
5068
+ }
5069
+ }, _callee);
5070
+ }));
5574
5071
 
5575
- return function (_x) {
5576
- return _ref.apply(this, arguments);
5577
- };
5578
- }());
5579
- }
5580
- }]);
5072
+ return function (_x) {
5073
+ return _ref.apply(this, arguments);
5074
+ };
5075
+ }());
5076
+ };
5581
5077
 
5582
5078
  return CanvasPickerPlugin;
5583
5079
  }(), _class$2.tag = 'CanvasPicker', _class$2);
@@ -5597,41 +5093,6 @@
5597
5093
  CanvasPickerPlugin = CanvasPickerPlugin_1 = __decorate([manaSyringe.singleton({
5598
5094
  contrib: g.RenderingPluginContribution
5599
5095
  })], CanvasPickerPlugin);
5600
-
5601
- function _toConsumableArray$1(arr) {
5602
- return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1$1(arr) || _nonIterableSpread$1();
5603
- }
5604
-
5605
- function _arrayWithoutHoles$1(arr) {
5606
- if (Array.isArray(arr)) return _arrayLikeToArray$1$1(arr);
5607
- }
5608
-
5609
- function _iterableToArray$1(iter) {
5610
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
5611
- }
5612
-
5613
- function _unsupportedIterableToArray$1$1(o, minLen) {
5614
- if (!o) return;
5615
- if (typeof o === "string") return _arrayLikeToArray$1$1(o, minLen);
5616
- var n = Object.prototype.toString.call(o).slice(8, -1);
5617
- if (n === "Object" && o.constructor) n = o.constructor.name;
5618
- if (n === "Map" || n === "Set") return Array.from(o);
5619
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1$1(o, minLen);
5620
- }
5621
-
5622
- function _arrayLikeToArray$1$1(arr, len) {
5623
- if (len == null || len > arr.length) len = arr.length;
5624
-
5625
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
5626
- arr2[i] = arr[i];
5627
- }
5628
-
5629
- return arr2;
5630
- }
5631
-
5632
- function _nonIterableSpread$1() {
5633
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5634
- }
5635
5096
  /**
5636
5097
  * 两点之间的距离
5637
5098
  * @param {number} x1 起始点 x
@@ -5641,7 +5102,6 @@
5641
5102
  * @return {number} 距离
5642
5103
  */
5643
5104
 
5644
-
5645
5105
  function distance(x1, y1, x2, y2) {
5646
5106
  var dx = x1 - x2;
5647
5107
  var dy = y1 - y2;
@@ -5653,10 +5113,10 @@
5653
5113
  }
5654
5114
 
5655
5115
  function getBBoxByArray(xArr, yArr) {
5656
- var minX = Math.min.apply(Math, _toConsumableArray$1(xArr));
5657
- var minY = Math.min.apply(Math, _toConsumableArray$1(yArr));
5658
- var maxX = Math.max.apply(Math, _toConsumableArray$1(xArr));
5659
- var maxY = Math.max.apply(Math, _toConsumableArray$1(yArr));
5116
+ var minX = Math.min.apply(Math, xArr);
5117
+ var minY = Math.min.apply(Math, yArr);
5118
+ var maxX = Math.max.apply(Math, xArr);
5119
+ var maxY = Math.max.apply(Math, yArr);
5660
5120
  return {
5661
5121
  x: minX,
5662
5122
  y: minY,
@@ -5799,7 +5259,7 @@
5799
5259
  for (var i = 0; i <= segNum; i++) {
5800
5260
  var _t = i * increaseRate;
5801
5261
 
5802
- var v1 = [tCallback.apply(void 0, _toConsumableArray$1(xArr.concat([_t]))), tCallback.apply(void 0, _toConsumableArray$1(yArr.concat([_t])))];
5262
+ var v1 = [tCallback.apply(void 0, xArr.concat([_t])), tCallback.apply(void 0, yArr.concat([_t]))];
5803
5263
  var d1 = distance(v0[0], v0[1], v1[0], v1[1]);
5804
5264
 
5805
5265
  if (d1 < d) {
@@ -5833,7 +5293,7 @@
5833
5293
 
5834
5294
  var prev = t - interval;
5835
5295
  var next = t + interval;
5836
- var _v = [tCallback.apply(void 0, _toConsumableArray$1(xArr.concat([prev]))), tCallback.apply(void 0, _toConsumableArray$1(yArr.concat([prev])))];
5296
+ var _v = [tCallback.apply(void 0, xArr.concat([prev])), tCallback.apply(void 0, yArr.concat([prev]))];
5837
5297
 
5838
5298
  var _d = distance(v0[0], v0[1], _v[0], _v[1]);
5839
5299
 
@@ -5841,7 +5301,7 @@
5841
5301
  t = prev;
5842
5302
  d = _d;
5843
5303
  } else {
5844
- var v2 = [tCallback.apply(void 0, _toConsumableArray$1(xArr.concat([next]))), tCallback.apply(void 0, _toConsumableArray$1(yArr.concat([next])))];
5304
+ var v2 = [tCallback.apply(void 0, xArr.concat([next])), tCallback.apply(void 0, yArr.concat([next]))];
5845
5305
  var d2 = distance(v0[0], v0[1], v2[0], v2[1]);
5846
5306
 
5847
5307
  if (next <= 1 && d2 < d) {
@@ -5854,8 +5314,8 @@
5854
5314
  }
5855
5315
 
5856
5316
  return {
5857
- x: tCallback.apply(void 0, _toConsumableArray$1(xArr.concat([t]))),
5858
- y: tCallback.apply(void 0, _toConsumableArray$1(yArr.concat([t])))
5317
+ x: tCallback.apply(void 0, xArr.concat([t])),
5318
+ y: tCallback.apply(void 0, yArr.concat([t]))
5859
5319
  };
5860
5320
  } // 近似求解 https://community.khronos.org/t/3d-cubic-bezier-segment-length/62363/2
5861
5321
 
@@ -5924,7 +5384,7 @@
5924
5384
  var right = quadratics[1];
5925
5385
  left.push(iterationCount - 1);
5926
5386
  right.push(iterationCount - 1);
5927
- return quadraticLength.apply(void 0, _toConsumableArray$1(left)) + quadraticLength.apply(void 0, _toConsumableArray$1(right));
5387
+ return quadraticLength.apply(void 0, left) + quadraticLength.apply(void 0, right);
5928
5388
  }
5929
5389
 
5930
5390
  var quadratic = {
@@ -6045,9 +5505,9 @@
6045
5505
  }
6046
5506
 
6047
5507
  var cubics = divideCubic(x1, y1, x2, y2, x3, y3, x4, y4, 0.5);
6048
- var left = [].concat(_toConsumableArray$1(cubics[0]), [iterationCount - 1]);
6049
- var right = [].concat(_toConsumableArray$1(cubics[1]), [iterationCount - 1]);
6050
- return cubicLength.apply(void 0, _toConsumableArray$1(left)) + cubicLength.apply(void 0, _toConsumableArray$1(right));
5508
+ var left = [].concat(cubics[0], [iterationCount - 1]);
5509
+ var right = [].concat(cubics[1], [iterationCount - 1]);
5510
+ return cubicLength.apply(void 0, left) + cubicLength.apply(void 0, right);
6051
5511
  }
6052
5512
 
6053
5513
  var cubic = {
@@ -6249,7 +5709,7 @@
6249
5709
  increasedLineWidthForHitTesting = _displayObject$parsed.increasedLineWidthForHitTesting,
6250
5710
  clipPathTargets = _displayObject$parsed.clipPathTargets;
6251
5711
  var r = rInPixels.value;
6252
- var halfLineWidth = (((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + increasedLineWidthForHitTesting.value) / 2;
5712
+ var halfLineWidth = ((lineWidth && lineWidth.value || 0) + (increasedLineWidthForHitTesting && increasedLineWidthForHitTesting.value || 0)) / 2;
6253
5713
  var absDistance = distance$1(r, r, position.x, position.y);
6254
5714
  var isClipPath = !!(clipPathTargets === null || clipPathTargets === void 0 ? void 0 : clipPathTargets.length);
6255
5715
  var hasFill = fill && !fill.isNone;
@@ -6527,12 +5987,10 @@
6527
5987
  }
6528
5988
 
6529
5989
  function inRectWithRadius(minX, minY, width, height, radiusArray, lineWidth, x, y) {
6530
- var _radiusArray = _slicedToArray$1(radiusArray, 4),
6531
- tlr = _radiusArray[0],
6532
- trr = _radiusArray[1],
6533
- brr = _radiusArray[2],
6534
- blr = _radiusArray[3];
6535
-
5990
+ var tlr = radiusArray[0],
5991
+ trr = radiusArray[1],
5992
+ brr = radiusArray[2],
5993
+ blr = radiusArray[3];
6536
5994
  return inLine(minX + tlr, minY, minX + width - trr, minY, lineWidth, x, y) || inLine(minX + width, minY + trr, minX + width, minY + height - brr, lineWidth, x, y) || inLine(minX + width - brr, minY + height, minX + blr, minY + height, lineWidth, x, y) || inLine(minX, minY + height - blr, minX, minY + tlr, lineWidth, x, y) || inArc(minX + width - trr, minY + trr, trr, 1.5 * Math.PI, 2 * Math.PI, lineWidth, x, y) || inArc(minX + width - brr, minY + height - brr, brr, 0, 0.5 * Math.PI, lineWidth, x, y) || inArc(minX + blr, minY + height - blr, blr, 0.5 * Math.PI, Math.PI, lineWidth, x, y) || inArc(minX + tlr, minY + tlr, tlr, Math.PI, 1.5 * Math.PI, lineWidth, x, y);
6537
5995
  }
6538
5996
 
@@ -6599,22 +6057,18 @@
6599
6057
 
6600
6058
  var Plugin$2 = /*#__PURE__*/function () {
6601
6059
  function Plugin() {
6602
- _classCallCheck$3(this, Plugin);
6603
-
6604
6060
  this.name = 'canvas-picker';
6605
6061
  }
6606
6062
 
6607
- _createClass$3(Plugin, [{
6608
- key: "init",
6609
- value: function init(container) {
6610
- container.load(containerModule$2, true);
6611
- }
6612
- }, {
6613
- key: "destroy",
6614
- value: function destroy(container) {
6615
- container.unload(containerModule$2);
6616
- }
6617
- }]);
6063
+ var _proto = Plugin.prototype;
6064
+
6065
+ _proto.init = function init(container) {
6066
+ container.load(containerModule$2, true);
6067
+ };
6068
+
6069
+ _proto.destroy = function destroy(container) {
6070
+ container.unload(containerModule$2);
6071
+ };
6618
6072
 
6619
6073
  return Plugin;
6620
6074
  }();
@@ -6749,7 +6203,7 @@
6749
6203
  if ("throw" !== record.type) {
6750
6204
  var result = record.arg,
6751
6205
  value = result.value;
6752
- return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
6206
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
6753
6207
  invoke("next", value, resolve, reject);
6754
6208
  }, function (err) {
6755
6209
  invoke("throw", err, resolve, reject);
@@ -7010,260 +6464,231 @@
7010
6464
  };
7011
6465
  }
7012
6466
 
7013
- function _classCallCheck$4(instance, Constructor) {
7014
- if (!(instance instanceof Constructor)) {
7015
- throw new TypeError("Cannot call a class as a function");
7016
- }
7017
- }
7018
-
7019
- function _defineProperties$4(target, props) {
7020
- for (var i = 0; i < props.length; i++) {
7021
- var descriptor = props[i];
7022
- descriptor.enumerable = descriptor.enumerable || false;
7023
- descriptor.configurable = true;
7024
- if ("value" in descriptor) descriptor.writable = true;
7025
- Object.defineProperty(target, descriptor.key, descriptor);
7026
- }
7027
- }
7028
-
7029
- function _createClass$4(Constructor, protoProps, staticProps) {
7030
- if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);
7031
- if (staticProps) _defineProperties$4(Constructor, staticProps);
7032
- Object.defineProperty(Constructor, "prototype", {
7033
- writable: false
7034
- });
7035
- return Constructor;
7036
- }
7037
-
7038
6467
  var _class$3;
7039
6468
 
7040
6469
  var HTMLRenderingPlugin_1;
7041
6470
  var HTML_PREFIX = 'g-html-';
7042
6471
  var HTMLRenderingPlugin = HTMLRenderingPlugin_1 = (_class$3 = /*#__PURE__*/function () {
7043
6472
  function HTMLRenderingPlugin() {
7044
- _classCallCheck$4(this, HTMLRenderingPlugin);
7045
-
7046
6473
  this.contextService = void 0;
7047
6474
  this.renderingContext = void 0;
6475
+ this.canvasConfig = void 0;
7048
6476
  this.$camera = void 0;
7049
6477
  }
7050
6478
 
7051
- _createClass$4(HTMLRenderingPlugin, [{
7052
- key: "apply",
7053
- value: function apply(renderingService) {
7054
- var _this = this;
6479
+ var _proto = HTMLRenderingPlugin.prototype;
7055
6480
 
7056
- var handleMounted = function handleMounted(e) {
7057
- var object = e.target;
6481
+ _proto.apply = function apply(renderingService) {
6482
+ var _this = this;
7058
6483
 
7059
- if (object.nodeName === g.Shape.HTML) {
7060
- var $el = _this.getOrCreateEl(object); // apply documentElement's style
6484
+ var handleMounted = function handleMounted(e) {
6485
+ var object = e.target;
7061
6486
 
6487
+ if (object.nodeName === g.Shape.HTML) {
6488
+ var $el = _this.getOrCreateEl(object); // apply documentElement's style
7062
6489
 
7063
- var attributes = object.ownerDocument.documentElement.attributes;
7064
- Object.keys(attributes).forEach(function (name) {
7065
- $el.style[name] = attributes[name];
7066
- });
7067
- Object.keys(object.attributes).forEach(function (name) {
7068
- _this.updateAttribute(name, object);
7069
- });
7070
- }
7071
- };
7072
6490
 
7073
- var handleUnmounted = function handleUnmounted(e) {
7074
- var object = e.target;
6491
+ var attributes = object.ownerDocument.documentElement.attributes;
6492
+ Object.keys(attributes).forEach(function (name) {
6493
+ $el.style[name] = attributes[name];
6494
+ });
6495
+ Object.keys(object.attributes).forEach(function (name) {
6496
+ _this.updateAttribute(name, object);
6497
+ });
6498
+ }
6499
+ };
7075
6500
 
7076
- if (object.nodeName === g.Shape.HTML) {
7077
- var existedId = _this.getId(object);
6501
+ var handleUnmounted = function handleUnmounted(e) {
6502
+ var object = e.target;
7078
6503
 
7079
- var $container = _this.contextService.getDomElement().parentNode;
6504
+ if (object.nodeName === g.Shape.HTML) {
6505
+ var existedId = _this.getId(object);
7080
6506
 
7081
- if ($container) {
7082
- var $existedElement = $container.querySelector('#' + existedId);
6507
+ var $container = _this.contextService.getDomElement().parentNode;
7083
6508
 
7084
- if ($existedElement) {
7085
- $container.removeChild($existedElement);
7086
- }
6509
+ if ($container) {
6510
+ var $existedElement = $container.querySelector('#' + existedId);
6511
+
6512
+ if ($existedElement) {
6513
+ $container.removeChild($existedElement);
7087
6514
  }
7088
6515
  }
7089
- };
6516
+ }
6517
+ };
7090
6518
 
7091
- var handleAttributeChanged = function handleAttributeChanged(e) {
7092
- var object = e.target;
6519
+ var handleAttributeChanged = function handleAttributeChanged(e) {
6520
+ var object = e.target;
7093
6521
 
7094
- if (object.nodeName === g.Shape.HTML) {
7095
- var attrName = e.attrName;
6522
+ if (object.nodeName === g.Shape.HTML) {
6523
+ var attrName = e.attrName;
7096
6524
 
7097
- _this.updateAttribute(attrName, object);
7098
- }
7099
- };
6525
+ _this.updateAttribute(attrName, object);
6526
+ }
6527
+ };
7100
6528
 
7101
- renderingService.hooks.init.tapPromise(HTMLRenderingPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee() {
7102
- return _regeneratorRuntime$3().wrap(function _callee$(_context) {
7103
- while (1) {
7104
- switch (_context.prev = _context.next) {
7105
- case 0:
7106
- _this.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
6529
+ renderingService.hooks.init.tapPromise(HTMLRenderingPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee() {
6530
+ return _regeneratorRuntime$3().wrap(function _callee$(_context) {
6531
+ while (1) {
6532
+ switch (_context.prev = _context.next) {
6533
+ case 0:
6534
+ _this.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
7107
6535
 
7108
- _this.renderingContext.root.addEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
6536
+ _this.renderingContext.root.addEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
7109
6537
 
7110
- _this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
6538
+ _this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
7111
6539
 
7112
- case 3:
7113
- case "end":
7114
- return _context.stop();
7115
- }
6540
+ case 3:
6541
+ case "end":
6542
+ return _context.stop();
7116
6543
  }
7117
- }, _callee);
7118
- })));
7119
- renderingService.hooks.destroy.tap(HTMLRenderingPlugin_1.tag, function () {
7120
- _this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
6544
+ }
6545
+ }, _callee);
6546
+ })));
6547
+ renderingService.hooks.destroy.tap(HTMLRenderingPlugin_1.tag, function () {
6548
+ _this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
7121
6549
 
7122
- _this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
6550
+ _this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
7123
6551
 
7124
- _this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
7125
- });
7126
- }
7127
- }, {
7128
- key: "getId",
7129
- value: function getId(object) {
7130
- return object.id || HTML_PREFIX + object.entity;
7131
- }
7132
- }, {
7133
- key: "getOrCreateEl",
7134
- value: function getOrCreateEl(object) {
7135
- var existedId = this.getId(object);
7136
- var $container = this.contextService.getDomElement().parentNode;
6552
+ _this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
6553
+ });
6554
+ };
7137
6555
 
7138
- if ($container) {
7139
- var $existedElement = $container.querySelector('#' + existedId);
6556
+ _proto.getId = function getId(object) {
6557
+ return object.id || HTML_PREFIX + object.entity;
6558
+ };
7140
6559
 
7141
- if (!$existedElement) {
7142
- $existedElement = document.createElement('div');
7143
- object.parsedStyle.$el = $existedElement;
7144
- $existedElement.id = existedId;
6560
+ _proto.getOrCreateEl = function getOrCreateEl(object) {
6561
+ var doc = this.canvasConfig.document;
6562
+ var existedId = this.getId(object);
6563
+ var $container = this.contextService.getDomElement().parentNode;
7145
6564
 
7146
- if (object.name) {
7147
- $existedElement.setAttribute('name', object.name);
7148
- }
6565
+ if ($container) {
6566
+ var $existedElement = $container.querySelector('#' + existedId);
7149
6567
 
7150
- if (object.className) {
7151
- $existedElement.className = object.className;
7152
- }
6568
+ if (!$existedElement) {
6569
+ $existedElement = (doc || document).createElement('div');
6570
+ object.parsedStyle.$el = $existedElement;
6571
+ $existedElement.id = existedId;
7153
6572
 
7154
- $container.appendChild($existedElement); // use absolute position
6573
+ if (object.name) {
6574
+ $existedElement.setAttribute('name', object.name);
6575
+ }
7155
6576
 
7156
- $existedElement.style.position = 'absolute';
7157
- $existedElement.style.left = '0';
7158
- $existedElement.style.top = '0';
7159
- $existedElement.style['will-change'] = 'transform';
7160
- var worldTransform = object.getWorldTransform();
7161
- $existedElement.style.transform = "matrix(".concat([worldTransform[0], worldTransform[1], worldTransform[4], worldTransform[5], worldTransform[12], worldTransform[13]].join(','), ")");
6577
+ if (object.className) {
6578
+ $existedElement.className = object.className;
7162
6579
  }
7163
6580
 
7164
- return $existedElement;
6581
+ $container.appendChild($existedElement); // use absolute position
6582
+
6583
+ $existedElement.style.position = 'absolute';
6584
+ $existedElement.style.left = '0';
6585
+ $existedElement.style.top = '0';
6586
+ $existedElement.style['will-change'] = 'transform';
6587
+ var worldTransform = object.getWorldTransform();
6588
+ $existedElement.style.transform = "matrix(" + [worldTransform[0], worldTransform[1], worldTransform[4], worldTransform[5], worldTransform[12], worldTransform[13]].join(',') + ")";
7165
6589
  }
7166
6590
 
7167
- return null;
6591
+ return $existedElement;
7168
6592
  }
7169
- }, {
7170
- key: "updateAttribute",
7171
- value: function updateAttribute(name, object) {
7172
- var $el = this.getOrCreateEl(object);
7173
6593
 
7174
- switch (name) {
7175
- case 'innerHTML':
7176
- var innerHTML = object.parsedStyle.innerHTML;
6594
+ return null;
6595
+ };
7177
6596
 
7178
- if (g.isString(innerHTML)) {
7179
- $el.innerHTML = innerHTML;
7180
- } else {
7181
- $el.innerHTML = '';
7182
- $el.appendChild(innerHTML);
7183
- }
6597
+ _proto.updateAttribute = function updateAttribute(name, object) {
6598
+ var $el = this.getOrCreateEl(object);
7184
6599
 
7185
- break;
6600
+ switch (name) {
6601
+ case 'innerHTML':
6602
+ var innerHTML = object.parsedStyle.innerHTML;
7186
6603
 
7187
- case 'modelMatrix':
7188
- case 'transformOrigin':
7189
- var transformOrigin = object.parsedStyle.transformOrigin;
7190
- $el.style['transform-origin'] = "".concat(transformOrigin[0].value, " ").concat(transformOrigin[1].value);
7191
- var worldTransform = object.getWorldTransform();
7192
- $el.style.transform = "matrix(".concat([worldTransform[0], worldTransform[1], worldTransform[4], worldTransform[5], worldTransform[12], worldTransform[13]].join(','), ")");
7193
- break;
6604
+ if (g.isString(innerHTML)) {
6605
+ $el.innerHTML = innerHTML;
6606
+ } else {
6607
+ $el.innerHTML = '';
6608
+ $el.appendChild(innerHTML);
6609
+ }
7194
6610
 
7195
- case 'width':
7196
- var width = object.computedStyleMap().get('width');
7197
- $el.style.width = width.toString();
7198
- break;
6611
+ break;
7199
6612
 
7200
- case 'height':
7201
- var height = object.computedStyleMap().get('height');
7202
- $el.style.height = height.toString();
7203
- break;
6613
+ case 'modelMatrix':
6614
+ case 'transformOrigin':
6615
+ var transformOrigin = object.parsedStyle.transformOrigin;
6616
+ $el.style['transform-origin'] = transformOrigin[0].value + " " + transformOrigin[1].value;
6617
+ var worldTransform = object.getWorldTransform();
6618
+ $el.style.transform = "matrix(" + [worldTransform[0], worldTransform[1], worldTransform[4], worldTransform[5], worldTransform[12], worldTransform[13]].join(',') + ")";
6619
+ break;
7204
6620
 
7205
- case 'zIndex':
7206
- var zIndex = object.parsedStyle.zIndex;
7207
- $el.style['z-index'] = "".concat(zIndex.value);
7208
- break;
6621
+ case 'width':
6622
+ var width = object.computedStyleMap().get('width');
6623
+ $el.style.width = width.toString();
6624
+ break;
7209
6625
 
7210
- case 'visibility':
7211
- var visibility = object.parsedStyle.visibility;
7212
- $el.style.visibility = visibility.value;
7213
- break;
6626
+ case 'height':
6627
+ var height = object.computedStyleMap().get('height');
6628
+ $el.style.height = height.toString();
6629
+ break;
7214
6630
 
7215
- case 'pointerEvents':
7216
- var pointerEvents = object.parsedStyle.pointerEvents;
7217
- $el.style.pointerEvents = pointerEvents.value;
7218
- break;
6631
+ case 'zIndex':
6632
+ var zIndex = object.parsedStyle.zIndex;
6633
+ $el.style['z-index'] = "" + zIndex.value;
6634
+ break;
7219
6635
 
7220
- case 'opacity':
7221
- var opacity = object.parsedStyle.opacity;
7222
- $el.style.opacity = "".concat(opacity.value);
7223
- break;
6636
+ case 'visibility':
6637
+ var visibility = object.parsedStyle.visibility;
6638
+ $el.style.visibility = visibility.value;
6639
+ break;
6640
+
6641
+ case 'pointerEvents':
6642
+ var pointerEvents = object.parsedStyle.pointerEvents;
6643
+ $el.style.pointerEvents = pointerEvents.value;
6644
+ break;
6645
+
6646
+ case 'opacity':
6647
+ var opacity = object.parsedStyle.opacity;
6648
+ $el.style.opacity = "" + opacity.value;
6649
+ break;
7224
6650
 
7225
- case 'fill':
7226
- var fill = object.parsedStyle.fill;
7227
- var color = '';
6651
+ case 'fill':
6652
+ var fill = object.parsedStyle.fill;
6653
+ var color = '';
7228
6654
 
7229
- if (fill instanceof g.CSSRGB) {
7230
- color = fill.toString();
7231
- } else if (fill instanceof g.CSSGradientValue) {
7232
- if (fill.type === g.GradientPatternType.LinearGradient) {
7233
- var steps = fill.value.steps.map(function (cur) {
7234
- // ['0', '#ffffff'],
7235
- return "".concat(cur[1], " ").concat(Number(cur[0]) * 100, "%");
7236
- }).join(','); // @see https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient()
6655
+ if (fill instanceof g.CSSRGB) {
6656
+ color = fill.toString();
6657
+ } else if (fill instanceof g.CSSGradientValue) {
6658
+ if (fill.type === g.GradientPatternType.LinearGradient) {
6659
+ var steps = fill.value.steps.map(function (cur) {
6660
+ // ['0', '#ffffff'],
6661
+ return cur[1] + " " + Number(cur[0]) * 100 + "%";
6662
+ }).join(','); // @see https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient()
7237
6663
 
7238
- color = "linear-gradient(to right, ".concat(steps, ");");
7239
- }
6664
+ color = "linear-gradient(to right, " + steps + ");";
7240
6665
  }
6666
+ }
7241
6667
 
7242
- $el.style.background = color;
7243
- break;
6668
+ $el.style.background = color;
6669
+ break;
7244
6670
 
7245
- case 'stroke':
7246
- var stroke = object.parsedStyle.stroke;
7247
- $el.style['border-color'] = stroke.toString();
7248
- $el.style['border-style'] = 'solid';
7249
- break;
6671
+ case 'stroke':
6672
+ var stroke = object.parsedStyle.stroke;
6673
+ $el.style['border-color'] = stroke.toString();
6674
+ $el.style['border-style'] = 'solid';
6675
+ break;
7250
6676
 
7251
- case 'lineWidth':
7252
- var lineWidth = object.parsedStyle.lineWidth;
7253
- $el.style['border-width'] = "".concat(lineWidth.value || 0, "px");
7254
- break;
6677
+ case 'lineWidth':
6678
+ var lineWidth = object.parsedStyle.lineWidth;
6679
+ $el.style['border-width'] = (lineWidth.value || 0) + "px";
6680
+ break;
7255
6681
 
7256
- case 'lineDash':
7257
- $el.style['border-style'] = 'dashed';
7258
- break;
6682
+ case 'lineDash':
6683
+ $el.style['border-style'] = 'dashed';
6684
+ break;
7259
6685
 
7260
- case 'filter':
7261
- var filter = object.parsedStyle.filter;
7262
- $el.style.filter = filter;
7263
- break;
7264
- }
6686
+ case 'filter':
6687
+ var filter = object.parsedStyle.filter;
6688
+ $el.style.filter = filter;
6689
+ break;
7265
6690
  }
7266
- }]);
6691
+ };
7267
6692
 
7268
6693
  return HTMLRenderingPlugin;
7269
6694
  }(), _class$3.tag = 'HTMLRendering', _class$3);
@@ -7272,6 +6697,8 @@
7272
6697
 
7273
6698
  __decorate([manaSyringe.inject(g.RenderingContext), __metadata("design:type", Object)], HTMLRenderingPlugin.prototype, "renderingContext", void 0);
7274
6699
 
6700
+ __decorate([manaSyringe.inject(g.CanvasConfig), __metadata("design:type", Object)], HTMLRenderingPlugin.prototype, "canvasConfig", void 0);
6701
+
7275
6702
  HTMLRenderingPlugin = HTMLRenderingPlugin_1 = __decorate([manaSyringe.singleton({
7276
6703
  contrib: g.RenderingPluginContribution
7277
6704
  })], HTMLRenderingPlugin);
@@ -7281,22 +6708,18 @@
7281
6708
 
7282
6709
  var Plugin$3 = /*#__PURE__*/function () {
7283
6710
  function Plugin() {
7284
- _classCallCheck$4(this, Plugin);
7285
-
7286
6711
  this.name = 'html-renderer';
7287
6712
  }
7288
6713
 
7289
- _createClass$4(Plugin, [{
7290
- key: "init",
7291
- value: function init(container) {
7292
- container.load(containerModule$3, true);
7293
- }
7294
- }, {
7295
- key: "destroy",
7296
- value: function destroy(container) {
7297
- container.unload(containerModule$3);
7298
- }
7299
- }]);
6714
+ var _proto = Plugin.prototype;
6715
+
6716
+ _proto.init = function init(container) {
6717
+ container.load(containerModule$3, true);
6718
+ };
6719
+
6720
+ _proto.destroy = function destroy(container) {
6721
+ container.unload(containerModule$3);
6722
+ };
7300
6723
 
7301
6724
  return Plugin;
7302
6725
  }();
@@ -7308,8 +6731,6 @@
7308
6731
 
7309
6732
  var Canvas2DContextService = /*#__PURE__*/function () {
7310
6733
  function Canvas2DContextService() {
7311
- _classCallCheck(this, Canvas2DContextService);
7312
-
7313
6734
  this.$container = void 0;
7314
6735
  this.$canvas = void 0;
7315
6736
  this.dpr = void 0;
@@ -7317,102 +6738,94 @@
7317
6738
  this.canvasConfig = void 0;
7318
6739
  }
7319
6740
 
7320
- _createClass(Canvas2DContextService, [{
7321
- key: "init",
7322
- value: function init() {
7323
- var _this$canvasConfig = this.canvasConfig,
7324
- container = _this$canvasConfig.container,
7325
- canvas = _this$canvasConfig.canvas,
7326
- devicePixelRatio = _this$canvasConfig.devicePixelRatio;
6741
+ var _proto = Canvas2DContextService.prototype;
7327
6742
 
7328
- if (canvas) {
7329
- this.$canvas = canvas;
6743
+ _proto.init = function init() {
6744
+ var _this$canvasConfig = this.canvasConfig,
6745
+ container = _this$canvasConfig.container,
6746
+ canvas = _this$canvasConfig.canvas,
6747
+ devicePixelRatio = _this$canvasConfig.devicePixelRatio;
7330
6748
 
7331
- if (container && canvas.parentElement !== container) {
7332
- container.appendChild(canvas);
7333
- }
6749
+ if (canvas) {
6750
+ this.$canvas = canvas;
7334
6751
 
7335
- this.$container = canvas.parentElement;
7336
- this.canvasConfig.container = this.$container;
7337
- } else if (container) {
7338
- // create container
7339
- this.$container = g.isString(container) ? document.getElementById(container) : container;
6752
+ if (container && canvas.parentElement !== container) {
6753
+ container.appendChild(canvas);
6754
+ }
7340
6755
 
7341
- if (this.$container) {
7342
- // create canvas
7343
- var $canvas = document.createElement('canvas');
7344
- this.$container.appendChild($canvas);
6756
+ this.$container = canvas.parentElement;
6757
+ this.canvasConfig.container = this.$container;
6758
+ } else if (container) {
6759
+ // create container
6760
+ this.$container = g.isString(container) ? document.getElementById(container) : container;
7345
6761
 
7346
- if (!this.$container.style.position) {
7347
- this.$container.style.position = 'relative';
7348
- }
6762
+ if (this.$container) {
6763
+ // create canvas
6764
+ var $canvas = document.createElement('canvas');
6765
+ this.$container.appendChild($canvas);
7349
6766
 
7350
- this.$canvas = $canvas;
6767
+ if (!this.$container.style.position) {
6768
+ this.$container.style.position = 'relative';
7351
6769
  }
7352
- }
7353
6770
 
7354
- this.context = this.$canvas.getContext('2d'); // use user-defined dpr first
7355
-
7356
- var dpr = devicePixelRatio || g.isBrowser && window.devicePixelRatio || 1;
7357
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
7358
- this.dpr = dpr;
7359
- this.resize(this.canvasConfig.width, this.canvasConfig.height);
7360
- }
7361
- }, {
7362
- key: "getContext",
7363
- value: function getContext() {
7364
- return this.context;
7365
- }
7366
- }, {
7367
- key: "getDomElement",
7368
- value: function getDomElement() {
7369
- return this.$canvas;
7370
- }
7371
- }, {
7372
- key: "getDPR",
7373
- value: function getDPR() {
7374
- return this.dpr;
7375
- }
7376
- }, {
7377
- key: "getBoundingClientRect",
7378
- value: function getBoundingClientRect() {
7379
- if (this.$canvas.getBoundingClientRect) {
7380
- return this.$canvas.getBoundingClientRect();
6771
+ this.$canvas = $canvas;
7381
6772
  }
7382
6773
  }
7383
- }, {
7384
- key: "destroy",
7385
- value: function destroy() {
6774
+
6775
+ this.context = this.$canvas.getContext('2d'); // use user-defined dpr first
6776
+
6777
+ var dpr = devicePixelRatio || g.isBrowser && window.devicePixelRatio || 1;
6778
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
6779
+ this.dpr = dpr;
6780
+ this.resize(this.canvasConfig.width, this.canvasConfig.height);
6781
+ };
6782
+
6783
+ _proto.getContext = function getContext() {
6784
+ return this.context;
6785
+ };
6786
+
6787
+ _proto.getDomElement = function getDomElement() {
6788
+ return this.$canvas;
6789
+ };
6790
+
6791
+ _proto.getDPR = function getDPR() {
6792
+ return this.dpr;
6793
+ };
6794
+
6795
+ _proto.getBoundingClientRect = function getBoundingClientRect() {
6796
+ if (this.$canvas.getBoundingClientRect) {
6797
+ return this.$canvas.getBoundingClientRect();
6798
+ }
6799
+ };
6800
+
6801
+ _proto.destroy = function destroy() {
6802
+ // @ts-ignore
6803
+ if (this.$container && this.$canvas && this.$canvas.parentNode) {
6804
+ // destroy context
7386
6805
  // @ts-ignore
7387
- if (this.$container && this.$canvas && this.$canvas.parentNode) {
7388
- // destroy context
7389
- // @ts-ignore
7390
- this.$container.removeChild(this.$canvas);
7391
- }
6806
+ this.$container.removeChild(this.$canvas);
7392
6807
  }
7393
- }, {
7394
- key: "resize",
7395
- value: function resize(width, height) {
7396
- if (this.$canvas) {
7397
- // set canvas width & height
7398
- this.$canvas.width = this.dpr * width;
7399
- this.$canvas.height = this.dpr * height; // set CSS style width & height
6808
+ };
7400
6809
 
7401
- g.setDOMSize(this.$canvas, width, height);
7402
- var dpr = this.getDPR(); // scale all drawing operations by the dpr
7403
- // @see https://www.html5rocks.com/en/tutorials/canvas/hidpi/
6810
+ _proto.resize = function resize(width, height) {
6811
+ if (this.$canvas) {
6812
+ // set canvas width & height
6813
+ this.$canvas.width = this.dpr * width;
6814
+ this.$canvas.height = this.dpr * height; // set CSS style width & height
7404
6815
 
7405
- this.context.scale(dpr, dpr);
7406
- }
6816
+ g.setDOMSize(this.$canvas, width, height);
6817
+ var dpr = this.getDPR(); // scale all drawing operations by the dpr
6818
+ // @see https://www.html5rocks.com/en/tutorials/canvas/hidpi/
6819
+
6820
+ this.context.scale(dpr, dpr);
7407
6821
  }
7408
- }, {
7409
- key: "applyCursorStyle",
7410
- value: function applyCursorStyle(cursor) {
7411
- if (this.$container && this.$container.style) {
7412
- this.$container.style.cursor = cursor;
7413
- }
6822
+ };
6823
+
6824
+ _proto.applyCursorStyle = function applyCursorStyle(cursor) {
6825
+ if (this.$container && this.$container.style) {
6826
+ this.$container.style.cursor = cursor;
7414
6827
  }
7415
- }]);
6828
+ };
7416
6829
 
7417
6830
  return Canvas2DContextService;
7418
6831
  }();
@@ -7431,37 +6844,29 @@
7431
6844
  });
7432
6845
  var ContextRegisterPlugin = /*#__PURE__*/function () {
7433
6846
  function ContextRegisterPlugin() {
7434
- _classCallCheck(this, ContextRegisterPlugin);
7435
-
7436
6847
  this.name = 'canvas-context-register';
7437
6848
  }
7438
6849
 
7439
- _createClass(ContextRegisterPlugin, [{
7440
- key: "init",
7441
- value: function init(container) {
7442
- container.load(containerModule$4, true);
7443
- }
7444
- }, {
7445
- key: "destroy",
7446
- value: function destroy(container) {
7447
- container.unload(containerModule$4);
7448
- }
7449
- }]);
6850
+ var _proto = ContextRegisterPlugin.prototype;
6851
+
6852
+ _proto.init = function init(container) {
6853
+ container.load(containerModule$4, true);
6854
+ };
6855
+
6856
+ _proto.destroy = function destroy(container) {
6857
+ container.unload(containerModule$4);
6858
+ };
7450
6859
 
7451
6860
  return ContextRegisterPlugin;
7452
6861
  }();
7453
6862
 
7454
6863
  var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
7455
- _inherits(Renderer, _AbstractRenderer);
7456
-
7457
- var _super = _createSuper(Renderer);
6864
+ _inheritsLoose(Renderer, _AbstractRenderer);
7458
6865
 
7459
6866
  function Renderer(config) {
7460
6867
  var _this;
7461
6868
 
7462
- _classCallCheck(this, Renderer);
7463
-
7464
- _this = _super.call(this, config); // register Canvas2DContext
6869
+ _this = _AbstractRenderer.call(this, config) || this; // register Canvas2DContext
7465
6870
 
7466
6871
  _this.registerPlugin(new ContextRegisterPlugin()); // enable rendering with Canvas2D API
7467
6872
 
@@ -7479,7 +6884,7 @@
7479
6884
  return _this;
7480
6885
  }
7481
6886
 
7482
- return _createClass(Renderer);
6887
+ return Renderer;
7483
6888
  }(g.AbstractRenderer);
7484
6889
 
7485
6890
  exports.CanvasPicker = index_esm$2;