@antv/g-svg 1.1.5 → 1.1.6

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
@@ -4,11 +4,64 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.G = global.G || {}, global.G.SVG = {}), global.window.G, global.window.G.ManaSyringe));
5
5
  }(this, (function (exports, g, manaSyringe) { 'use strict';
6
6
 
7
- function _inheritsLoose(subClass, superClass) {
8
- subClass.prototype = Object.create(superClass.prototype);
9
- subClass.prototype.constructor = subClass;
7
+ function _typeof(obj) {
8
+ "@babel/helpers - typeof";
9
+
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
+ }
10
59
 
11
- _setPrototypeOf(subClass, superClass);
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);
12
65
  }
13
66
 
14
67
  function _setPrototypeOf(o, p) {
@@ -20,6 +73,56 @@
20
73
  return _setPrototypeOf(o, p);
21
74
  }
22
75
 
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
+
23
126
  /******************************************************************************
24
127
  Copyright (c) Microsoft Corporation.
25
128
 
@@ -171,7 +274,7 @@
171
274
  if ("throw" !== record.type) {
172
275
  var result = record.arg,
173
276
  value = result.value;
174
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
277
+ return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
175
278
  invoke("next", value, resolve, reject);
176
279
  }, function (err) {
177
280
  invoke("throw", err, resolve, reject);
@@ -432,6 +535,31 @@
432
535
  };
433
536
  }
434
537
 
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
+
435
563
  var _class;
436
564
 
437
565
  var DOMInteractionPlugin_1;
@@ -441,147 +569,150 @@
441
569
 
442
570
  var DOMInteractionPlugin = DOMInteractionPlugin_1 = (_class = /*#__PURE__*/function () {
443
571
  function DOMInteractionPlugin() {
572
+ _classCallCheck$1(this, DOMInteractionPlugin);
573
+
444
574
  this.contextService = void 0;
445
575
  this.renderingContext = void 0;
446
576
  }
447
577
 
448
- var _proto = DOMInteractionPlugin.prototype;
578
+ _createClass$1(DOMInteractionPlugin, [{
579
+ key: "apply",
580
+ value: function apply(renderingService) {
581
+ var _this = this;
449
582
 
450
- _proto.apply = function apply(renderingService) {
451
- var _this = this;
583
+ var canvas = this.renderingContext.root.ownerDocument.defaultView; // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
452
584
 
453
- var canvas = this.renderingContext.root.ownerDocument.defaultView; // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
585
+ var onPointerMove = function onPointerMove(ev) {
586
+ renderingService.hooks.pointerMove.call(ev);
587
+ };
454
588
 
455
- var onPointerMove = function onPointerMove(ev) {
456
- renderingService.hooks.pointerMove.call(ev);
457
- };
589
+ var onPointerUp = function onPointerUp(ev) {
590
+ renderingService.hooks.pointerUp.call(ev);
591
+ };
458
592
 
459
- var onPointerUp = function onPointerUp(ev) {
460
- renderingService.hooks.pointerUp.call(ev);
461
- };
593
+ var onPointerDown = function onPointerDown(ev) {
594
+ renderingService.hooks.pointerDown.call(ev);
595
+ };
462
596
 
463
- var onPointerDown = function onPointerDown(ev) {
464
- renderingService.hooks.pointerDown.call(ev);
465
- };
597
+ var onPointerOver = function onPointerOver(ev) {
598
+ renderingService.hooks.pointerOver.call(ev);
599
+ };
466
600
 
467
- var onPointerOver = function onPointerOver(ev) {
468
- renderingService.hooks.pointerOver.call(ev);
469
- };
601
+ var onPointerOut = function onPointerOut(ev) {
602
+ renderingService.hooks.pointerOut.call(ev);
603
+ };
470
604
 
471
- var onPointerOut = function onPointerOut(ev) {
472
- renderingService.hooks.pointerOut.call(ev);
473
- };
605
+ var onPointerCancel = function onPointerCancel(ev) {
606
+ renderingService.hooks.pointerCancel.call(ev);
607
+ };
474
608
 
475
- var onPointerCancel = function onPointerCancel(ev) {
476
- renderingService.hooks.pointerCancel.call(ev);
477
- };
609
+ var onPointerWheel = function onPointerWheel(ev) {
610
+ renderingService.hooks.pointerWheel.call(ev);
611
+ };
478
612
 
479
- var onPointerWheel = function onPointerWheel(ev) {
480
- renderingService.hooks.pointerWheel.call(ev);
481
- };
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
+ };
482
620
 
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
- };
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
+ };
490
627
 
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
- };
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
+ };
497
635
 
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
- };
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
+ };
505
643
 
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
- };
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
+ };
513
649
 
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
- };
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
+ };
519
657
 
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
- };
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
527
665
 
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
- }
666
+ if (globalThis.navigator.msPointerEnabled) {
667
+ // @ts-ignore
668
+ $el.style.msContentZooming = 'none'; // @ts-ignore
544
669
 
545
- if (canvas.supportsPointerEvents) {
546
- addPointerEventListener($el);
547
- } else {
548
- addMouseEventListener($el);
549
- }
670
+ $el.style.msTouchAction = 'none';
671
+ } else if (canvas.supportsPointerEvents) {
672
+ $el.style.touchAction = 'none';
673
+ }
674
+
675
+ if (canvas.supportsPointerEvents) {
676
+ addPointerEventListener($el);
677
+ } else {
678
+ addMouseEventListener($el);
679
+ }
550
680
 
551
- if (canvas.supportsTouchEvents) {
552
- addTouchEventListener($el);
553
- } // use passive event listeners
554
- // @see https://zhuanlan.zhihu.com/p/24555031
681
+ if (canvas.supportsTouchEvents) {
682
+ addTouchEventListener($el);
683
+ } // use passive event listeners
684
+ // @see https://zhuanlan.zhihu.com/p/24555031
555
685
 
556
686
 
557
- $el.addEventListener('wheel', onPointerWheel, {
558
- passive: true,
559
- capture: true
560
- });
687
+ $el.addEventListener('wheel', onPointerWheel, {
688
+ passive: true,
689
+ capture: true
690
+ });
561
691
 
562
- case 5:
563
- case "end":
564
- return _context.stop();
692
+ case 5:
693
+ case "end":
694
+ return _context.stop();
695
+ }
565
696
  }
566
- }
567
- }, _callee);
568
- })));
569
- renderingService.hooks.destroy.tap(DOMInteractionPlugin_1.tag, function () {
570
- var $el = _this.contextService.getDomElement();
697
+ }, _callee);
698
+ })));
699
+ renderingService.hooks.destroy.tap(DOMInteractionPlugin_1.tag, function () {
700
+ var $el = _this.contextService.getDomElement();
571
701
 
572
- if (canvas.supportsPointerEvents) {
573
- removePointerEventListener($el);
574
- } else {
575
- removeMouseEventListener($el);
576
- }
702
+ if (canvas.supportsPointerEvents) {
703
+ removePointerEventListener($el);
704
+ } else {
705
+ removeMouseEventListener($el);
706
+ }
577
707
 
578
- if (canvas.supportsTouchEvents) {
579
- removeTouchEventListener($el);
580
- }
708
+ if (canvas.supportsTouchEvents) {
709
+ removeTouchEventListener($el);
710
+ }
581
711
 
582
- $el.removeEventListener('wheel', onPointerWheel, true);
583
- });
584
- };
712
+ $el.removeEventListener('wheel', onPointerWheel, true);
713
+ });
714
+ }
715
+ }]);
585
716
 
586
717
  return DOMInteractionPlugin;
587
718
  }(), _class.tag = 'DOMInteraction', _class);
@@ -599,18 +730,22 @@
599
730
 
600
731
  var Plugin = /*#__PURE__*/function () {
601
732
  function Plugin() {
733
+ _classCallCheck$1(this, Plugin);
734
+
602
735
  this.name = 'dom-interaction';
603
736
  }
604
737
 
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
- };
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
+ }]);
614
749
 
615
750
  return Plugin;
616
751
  }();
@@ -826,330 +961,6 @@
826
961
  return output;
827
962
  }
828
963
 
829
- var ElementSVG = function ElementSVG() {
830
- this.$el = void 0;
831
- this.$groupEl = void 0;
832
- this.$hitTestingEl = void 0;
833
- };
834
-
835
- ElementSVG.tag = 'c-svg-element';
836
-
837
- var RectRenderer = /*#__PURE__*/function () {
838
- function RectRenderer() {
839
- this.dependencies = ['radius', 'width', 'height'];
840
- }
841
-
842
- var _proto = RectRenderer.prototype;
843
-
844
- _proto.apply = function apply($el, parsedStyle) {
845
- var radius = parsedStyle.radius,
846
- width = parsedStyle.width,
847
- height = parsedStyle.height;
848
- var hasRadius = radius && radius.some(function (r) {
849
- return r.value !== 0;
850
- });
851
- var d = '';
852
-
853
- if (!hasRadius) {
854
- d = "M 0,0 l " + width.value + ",0 l 0," + height.value + " l" + -width.value + " 0 z";
855
- } else {
856
- var _radius$map = radius.map(function (r) {
857
- return r.value;
858
- }),
859
- tlr = _radius$map[0],
860
- trr = _radius$map[1],
861
- brr = _radius$map[2],
862
- blr = _radius$map[3];
863
-
864
- d = [["M " + tlr + ",0"], ["l " + (width.value - tlr - trr) + ",0"], ["a " + trr + "," + trr + ",0,0,1," + trr + "," + trr], ["l 0," + (height.value - trr - brr)], ["a " + brr + "," + brr + ",0,0,1," + -brr + "," + brr], ["l " + (brr + blr - width.value) + ",0"], ["a " + blr + "," + blr + ",0,0,1," + -blr + "," + -blr], ["l 0," + (blr + tlr - height.value)], ["a " + tlr + "," + tlr + ",0,0,1," + tlr + "," + -tlr], ['z']].join(' ');
865
- }
866
-
867
- $el.setAttribute('d', d);
868
- };
869
-
870
- return RectRenderer;
871
- }();
872
-
873
- RectRenderer = __decorate([manaSyringe.singleton()], RectRenderer);
874
-
875
- var ImageRenderer = /*#__PURE__*/function () {
876
- function ImageRenderer() {
877
- this.dependencies = ['img', 'width', 'height'];
878
- }
879
-
880
- var _proto = ImageRenderer.prototype;
881
-
882
- _proto.apply = function apply($el, parsedStyle) {
883
- var _parsedStyle$img = parsedStyle.img,
884
- img = _parsedStyle$img === void 0 ? '' : _parsedStyle$img,
885
- width = parsedStyle.width,
886
- height = parsedStyle.height;
887
- $el.setAttribute('x', '0');
888
- $el.setAttribute('y', '0');
889
-
890
- if (g.isString(img)) {
891
- $el.setAttribute('href', img);
892
- } else if (img instanceof Image) {
893
- if (!width) {
894
- $el.setAttribute('width', "" + img.width); // TODO: set renderable.boundsDirty
895
- // this.attr('width', img.width);
896
- }
897
-
898
- if (!height) {
899
- $el.setAttribute('height', "" + img.height); // this.attr('height', img.height);
900
- }
901
-
902
- $el.setAttribute('href', img.src);
903
- } else if ( // @ts-ignore
904
- img instanceof HTMLElement && g.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
905
- $el.setAttribute('href', img.toDataURL()); // @ts-ignore
906
- } else if (img instanceof ImageData) {
907
- var canvas = document.createElement('canvas'); // @ts-ignore
908
-
909
- canvas.setAttribute('width', "" + img.width); // @ts-ignore
910
-
911
- canvas.setAttribute('height', "" + img.height);
912
- var context = canvas.getContext('2d');
913
-
914
- if (context) {
915
- context.putImageData(img, 0, 0);
916
-
917
- if (!width) {
918
- // @ts-ignore
919
- $el.setAttribute('width', "" + img.width); // this.attr('width', img.width);
920
- }
921
-
922
- if (!height) {
923
- // @ts-ignore
924
- $el.setAttribute('height', "" + img.height); // this.attr('height', img.height);
925
- }
926
-
927
- $el.setAttribute('href', canvas.toDataURL());
928
- }
929
- }
930
- };
931
-
932
- return ImageRenderer;
933
- }();
934
-
935
- ImageRenderer = __decorate([manaSyringe.singleton()], ImageRenderer);
936
-
937
- var LineRenderer = /*#__PURE__*/function () {
938
- function LineRenderer() {
939
- this.dependencies = ['x1', 'y1', 'x2', 'y2'];
940
- }
941
-
942
- var _proto = LineRenderer.prototype;
943
-
944
- _proto.apply = function apply($el, parsedStyle) {
945
- var x1 = parsedStyle.x1,
946
- y1 = parsedStyle.y1,
947
- x2 = parsedStyle.x2,
948
- y2 = parsedStyle.y2,
949
- _parsedStyle$defX = parsedStyle.defX,
950
- x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
951
- _parsedStyle$defY = parsedStyle.defY,
952
- y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY,
953
- stroke = parsedStyle.stroke;
954
- $el.setAttribute('x1', "" + (x1.value - x));
955
- $el.setAttribute('y1', "" + (y1.value - y));
956
- $el.setAttribute('x2', "" + (x2.value - x)); // fix horizontal line stroke url bug in Chrome
957
- // @see https://stackoverflow.com/questions/14680240/did-chrome-break-svg-stroke-url
958
-
959
- if (y1.value === y2.value && stroke && !(stroke instanceof g.CSSRGB)) {
960
- $el.setAttribute('y2', "" + (y2.value - y + 0.00001));
961
- } else {
962
- $el.setAttribute('y2', "" + (y2.value - y));
963
- }
964
- };
965
-
966
- return LineRenderer;
967
- }();
968
-
969
- LineRenderer = __decorate([manaSyringe.singleton()], LineRenderer);
970
-
971
- var PolylineRenderer = /*#__PURE__*/function () {
972
- function PolylineRenderer() {
973
- this.dependencies = ['points'];
974
- }
975
-
976
- var _proto = PolylineRenderer.prototype;
977
-
978
- _proto.apply = function apply($el, parsedStyle) {
979
- var points = parsedStyle.points,
980
- _parsedStyle$defX = parsedStyle.defX,
981
- x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
982
- _parsedStyle$defY = parsedStyle.defY,
983
- y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
984
-
985
- if (points && points.points && points.points.length >= 2) {
986
- $el.setAttribute('points', points.points.map(function (point) {
987
- return point[0] - x + "," + (point[1] - y);
988
- }).join(' '));
989
- }
990
- };
991
-
992
- return PolylineRenderer;
993
- }();
994
-
995
- PolylineRenderer = __decorate([manaSyringe.singleton()], PolylineRenderer);
996
-
997
- function numberToLongString(x) {
998
- return x.toFixed(6).replace('.000000', '');
999
- }
1000
-
1001
- function convertHTML(str) {
1002
- var regex = /[&|<|>|"|']/g;
1003
- return str.replace(regex, function (match) {
1004
- if (match === '&') {
1005
- return '&amp;';
1006
- } else if (match === '<') {
1007
- return '&lt;';
1008
- } else if (match === '>') {
1009
- return '&gt;';
1010
- } else if (match === '"') {
1011
- return '&quot;';
1012
- } else {
1013
- return '&apos;';
1014
- }
1015
- });
1016
- }
1017
-
1018
- var BASELINE_MAP = {
1019
- top: 'before-edge',
1020
- middle: 'central',
1021
- bottom: 'after-edge',
1022
- alphabetic: 'alphabetic',
1023
- ideographic: 'ideographic',
1024
- hanging: 'hanging'
1025
- }; // for FireFox
1026
- // @see https://github.com/plouc/nivo/issues/164
1027
-
1028
- var BASELINE_MAP_FOR_FIREFOX = {
1029
- top: 'text-before-edge',
1030
- middle: 'central',
1031
- bottom: 'text-after-edge',
1032
- alphabetic: 'alphabetic',
1033
- ideographic: 'ideographic',
1034
- hanging: 'hanging'
1035
- };
1036
-
1037
- var TextRenderer = /*#__PURE__*/function () {
1038
- function TextRenderer() {
1039
- this.dependencies = ['text', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'wordWrap', 'wordWrapWidth', 'leading', 'textBaseline', 'textAlign', 'textTransform', 'whiteSpace', 'dx', 'dy'];
1040
- }
1041
-
1042
- var _proto = TextRenderer.prototype;
1043
-
1044
- _proto.apply = function apply($el, parsedStyle) {
1045
- var textBaseline = parsedStyle.textBaseline,
1046
- lineWidth = parsedStyle.lineWidth,
1047
- metrics = parsedStyle.metrics,
1048
- dx = parsedStyle.dx,
1049
- dy = parsedStyle.dy;
1050
- var browser = detect();
1051
-
1052
- if (browser && browser.name === 'firefox') {
1053
- // compatible with FireFox browser, ref: https://github.com/antvis/g/issues/119
1054
- $el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value] || 'alphabetic');
1055
- } else {
1056
- $el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value]);
1057
- $el.setAttribute('alignment-baseline', BASELINE_MAP[textBaseline.value]);
1058
- }
1059
-
1060
- $el.setAttribute('paint-order', 'stroke');
1061
- var lines = metrics.lines,
1062
- lineHeight = metrics.lineHeight,
1063
- height = metrics.height;
1064
- var lineNum = lines.length;
1065
- $el.setAttribute('style', "transform:translate(" + dx.toString() + ", " + dy.toString() + ");");
1066
-
1067
- if (lineNum === 1) {
1068
- $el.innerHTML = convertHTML(lines[0]);
1069
- $el.setAttribute('dx', "" + lineWidth.value / 2);
1070
- } else {
1071
- $el.innerHTML = lines.map(function (line, i) {
1072
- var dx = lineWidth.value / 2;
1073
- var dy = 0;
1074
-
1075
- if (i === 0) {
1076
- // TODO: handle other textBaseline values
1077
- if (textBaseline.value === 'middle') {
1078
- dy = lineHeight / 2 - height / 2;
1079
- } else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
1080
- dy = 0;
1081
- } else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
1082
- dy = -lineHeight * (lineNum - 1);
1083
- }
1084
- } else {
1085
- dy = lineHeight;
1086
- }
1087
-
1088
- return "<tspan x=\"0\" dx=\"" + dx + "\" dy=\"" + dy + "\">" + convertHTML(line) + "</tspan>";
1089
- }).join('');
1090
- }
1091
- };
1092
-
1093
- return TextRenderer;
1094
- }();
1095
-
1096
- TextRenderer = __decorate([manaSyringe.singleton()], TextRenderer);
1097
-
1098
- var PathRenderer = /*#__PURE__*/function () {
1099
- function PathRenderer() {
1100
- this.dependencies = ['path'];
1101
- }
1102
-
1103
- var _proto = PathRenderer.prototype;
1104
-
1105
- _proto.apply = function apply($el, parsedStyle) {
1106
- var path = parsedStyle.path,
1107
- _parsedStyle$defX = parsedStyle.defX,
1108
- x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
1109
- _parsedStyle$defY = parsedStyle.defY,
1110
- y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
1111
- $el.setAttribute('d', this.formatPath(path.absolutePath, x, y));
1112
- };
1113
-
1114
- _proto.formatPath = function formatPath(value, x, y) {
1115
- var newValue = value.map(function (params) {
1116
- var command = params[0];
1117
-
1118
- switch (command) {
1119
- case 'M':
1120
- return "M " + (params[1] - x) + "," + (params[2] - y);
1121
-
1122
- case 'L':
1123
- return "L " + (params[1] - x) + "," + (params[2] - y);
1124
-
1125
- case 'Q':
1126
- return "Q " + (params[1] - x) + " " + (params[2] - y) + "," + (params[3] - x) + " " + (params[4] - y);
1127
-
1128
- case 'C':
1129
- return "C " + (params[1] - x) + " " + (params[2] - y) + "," + (params[3] - x) + " " + (params[4] - y) + "," + (params[5] - x) + " " + (params[6] - y);
1130
-
1131
- case 'A':
1132
- return "A " + params[1] + " " + params[2] + " " + params[3] + " " + params[4] + " " + params[5] + " " + (params[6] - x) + " " + (params[7] - y);
1133
-
1134
- case 'Z':
1135
- return 'Z';
1136
- }
1137
- }).join(' ');
1138
-
1139
- if (~newValue.indexOf('NaN')) {
1140
- return '';
1141
- }
1142
-
1143
- return newValue;
1144
- };
1145
-
1146
- return PathRenderer;
1147
- }();
1148
-
1149
- PathRenderer = __decorate([manaSyringe.singleton()], PathRenderer);
1150
- var ElementRendererFactory = manaSyringe.Syringe.defineToken('ElementRendererFactory');
1151
- var ElementRenderer = manaSyringe.Syringe.defineToken('ElementRenderer');
1152
-
1153
964
  function _regeneratorRuntime$1() {
1154
965
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
1155
966
  _regeneratorRuntime$1 = function _regeneratorRuntime() {
@@ -1275,7 +1086,7 @@
1275
1086
  if ("throw" !== record.type) {
1276
1087
  var result = record.arg,
1277
1088
  value = result.value;
1278
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
1089
+ return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
1279
1090
  invoke("next", value, resolve, reject);
1280
1091
  }, function (err) {
1281
1092
  invoke("throw", err, resolve, reject);
@@ -1514,34 +1325,480 @@
1514
1325
  } else {
1515
1326
  Promise.resolve(value).then(_next, _throw);
1516
1327
  }
1517
- }
1328
+ }
1329
+
1330
+ function _asyncToGenerator$1(fn) {
1331
+ return function () {
1332
+ var self = this,
1333
+ args = arguments;
1334
+ return new Promise(function (resolve, reject) {
1335
+ var gen = fn.apply(self, args);
1336
+
1337
+ function _next(value) {
1338
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
1339
+ }
1340
+
1341
+ function _throw(err) {
1342
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
1343
+ }
1344
+
1345
+ _next(undefined);
1346
+ });
1347
+ };
1348
+ }
1349
+
1350
+ function _classCallCheck$2(instance, Constructor) {
1351
+ if (!(instance instanceof Constructor)) {
1352
+ throw new TypeError("Cannot call a class as a function");
1353
+ }
1354
+ }
1355
+
1356
+ function _defineProperties$2(target, props) {
1357
+ for (var i = 0; i < props.length; i++) {
1358
+ var descriptor = props[i];
1359
+ descriptor.enumerable = descriptor.enumerable || false;
1360
+ descriptor.configurable = true;
1361
+ if ("value" in descriptor) descriptor.writable = true;
1362
+ Object.defineProperty(target, descriptor.key, descriptor);
1363
+ }
1364
+ }
1365
+
1366
+ function _createClass$2(Constructor, protoProps, staticProps) {
1367
+ if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
1368
+ if (staticProps) _defineProperties$2(Constructor, staticProps);
1369
+ Object.defineProperty(Constructor, "prototype", {
1370
+ writable: false
1371
+ });
1372
+ return Constructor;
1373
+ }
1374
+
1375
+ function _defineProperty(obj, key, value) {
1376
+ if (key in obj) {
1377
+ Object.defineProperty(obj, key, {
1378
+ value: value,
1379
+ enumerable: true,
1380
+ configurable: true,
1381
+ writable: true
1382
+ });
1383
+ } else {
1384
+ obj[key] = value;
1385
+ }
1386
+
1387
+ return obj;
1388
+ }
1389
+
1390
+ function _slicedToArray(arr, i) {
1391
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
1392
+ }
1393
+
1394
+ function _arrayWithHoles(arr) {
1395
+ if (Array.isArray(arr)) return arr;
1396
+ }
1397
+
1398
+ function _iterableToArrayLimit(arr, i) {
1399
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1400
+
1401
+ if (_i == null) return;
1402
+ var _arr = [];
1403
+ var _n = true;
1404
+ var _d = false;
1405
+
1406
+ var _s, _e;
1407
+
1408
+ try {
1409
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
1410
+ _arr.push(_s.value);
1411
+
1412
+ if (i && _arr.length === i) break;
1413
+ }
1414
+ } catch (err) {
1415
+ _d = true;
1416
+ _e = err;
1417
+ } finally {
1418
+ try {
1419
+ if (!_n && _i["return"] != null) _i["return"]();
1420
+ } finally {
1421
+ if (_d) throw _e;
1422
+ }
1423
+ }
1424
+
1425
+ return _arr;
1426
+ }
1427
+
1428
+ function _unsupportedIterableToArray(o, minLen) {
1429
+ if (!o) return;
1430
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
1431
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1432
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1433
+ if (n === "Map" || n === "Set") return Array.from(o);
1434
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
1435
+ }
1436
+
1437
+ function _arrayLikeToArray(arr, len) {
1438
+ if (len == null || len > arr.length) len = arr.length;
1439
+
1440
+ for (var i = 0, arr2 = new Array(len); i < len; i++) {
1441
+ arr2[i] = arr[i];
1442
+ }
1443
+
1444
+ return arr2;
1445
+ }
1446
+
1447
+ function _nonIterableRest() {
1448
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1449
+ }
1450
+
1451
+ var ElementSVG = /*#__PURE__*/_createClass$2(function ElementSVG() {
1452
+ _classCallCheck$2(this, ElementSVG);
1453
+
1454
+ this.$el = void 0;
1455
+ this.$groupEl = void 0;
1456
+ this.$hitTestingEl = void 0;
1457
+ });
1458
+
1459
+ ElementSVG.tag = 'c-svg-element';
1460
+
1461
+ var RectRenderer = /*#__PURE__*/function () {
1462
+ function RectRenderer() {
1463
+ _classCallCheck$2(this, RectRenderer);
1464
+
1465
+ this.dependencies = ['radius', 'width', 'height'];
1466
+ }
1467
+
1468
+ _createClass$2(RectRenderer, [{
1469
+ key: "apply",
1470
+ value: function apply($el, parsedStyle) {
1471
+ var radius = parsedStyle.radius,
1472
+ width = parsedStyle.width,
1473
+ height = parsedStyle.height;
1474
+ var hasRadius = radius && radius.some(function (r) {
1475
+ return r.value !== 0;
1476
+ });
1477
+ var d = '';
1478
+
1479
+ if (!hasRadius) {
1480
+ d = "M 0,0 l ".concat(width.value, ",0 l 0,").concat(height.value, " l").concat(-width.value, " 0 z");
1481
+ } else {
1482
+ var _radius$map = radius.map(function (r) {
1483
+ return r.value;
1484
+ }),
1485
+ _radius$map2 = _slicedToArray(_radius$map, 4),
1486
+ tlr = _radius$map2[0],
1487
+ trr = _radius$map2[1],
1488
+ brr = _radius$map2[2],
1489
+ blr = _radius$map2[3];
1490
+
1491
+ d = [["M ".concat(tlr, ",0")], ["l ".concat(width.value - tlr - trr, ",0")], ["a ".concat(trr, ",").concat(trr, ",0,0,1,").concat(trr, ",").concat(trr)], ["l 0,".concat(height.value - trr - brr)], ["a ".concat(brr, ",").concat(brr, ",0,0,1,").concat(-brr, ",").concat(brr)], ["l ".concat(brr + blr - width.value, ",0")], ["a ".concat(blr, ",").concat(blr, ",0,0,1,").concat(-blr, ",").concat(-blr)], ["l 0,".concat(blr + tlr - height.value)], ["a ".concat(tlr, ",").concat(tlr, ",0,0,1,").concat(tlr, ",").concat(-tlr)], ['z']].join(' ');
1492
+ }
1493
+
1494
+ $el.setAttribute('d', d);
1495
+ }
1496
+ }]);
1497
+
1498
+ return RectRenderer;
1499
+ }();
1500
+
1501
+ RectRenderer = __decorate([manaSyringe.singleton()], RectRenderer);
1502
+
1503
+ var ImageRenderer = /*#__PURE__*/function () {
1504
+ function ImageRenderer() {
1505
+ _classCallCheck$2(this, ImageRenderer);
1506
+
1507
+ this.dependencies = ['img', 'width', 'height'];
1508
+ }
1509
+
1510
+ _createClass$2(ImageRenderer, [{
1511
+ key: "apply",
1512
+ value: function apply($el, parsedStyle) {
1513
+ var _parsedStyle$img = parsedStyle.img,
1514
+ img = _parsedStyle$img === void 0 ? '' : _parsedStyle$img,
1515
+ width = parsedStyle.width,
1516
+ height = parsedStyle.height;
1517
+ $el.setAttribute('x', '0');
1518
+ $el.setAttribute('y', '0');
1519
+
1520
+ if (g.isString(img)) {
1521
+ $el.setAttribute('href', img);
1522
+ } else if (img instanceof Image) {
1523
+ if (!width) {
1524
+ $el.setAttribute('width', "".concat(img.width)); // TODO: set renderable.boundsDirty
1525
+ // this.attr('width', img.width);
1526
+ }
1527
+
1528
+ if (!height) {
1529
+ $el.setAttribute('height', "".concat(img.height)); // this.attr('height', img.height);
1530
+ }
1531
+
1532
+ $el.setAttribute('href', img.src);
1533
+ } else if ( // @ts-ignore
1534
+ img instanceof HTMLElement && g.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
1535
+ $el.setAttribute('href', img.toDataURL()); // @ts-ignore
1536
+ } else if (img instanceof ImageData) {
1537
+ var canvas = document.createElement('canvas'); // @ts-ignore
1538
+
1539
+ canvas.setAttribute('width', "".concat(img.width)); // @ts-ignore
1540
+
1541
+ canvas.setAttribute('height', "".concat(img.height));
1542
+ var context = canvas.getContext('2d');
1543
+
1544
+ if (context) {
1545
+ context.putImageData(img, 0, 0);
1546
+
1547
+ if (!width) {
1548
+ // @ts-ignore
1549
+ $el.setAttribute('width', "".concat(img.width)); // this.attr('width', img.width);
1550
+ }
1551
+
1552
+ if (!height) {
1553
+ // @ts-ignore
1554
+ $el.setAttribute('height', "".concat(img.height)); // this.attr('height', img.height);
1555
+ }
1556
+
1557
+ $el.setAttribute('href', canvas.toDataURL());
1558
+ }
1559
+ }
1560
+ }
1561
+ }]);
1562
+
1563
+ return ImageRenderer;
1564
+ }();
1565
+
1566
+ ImageRenderer = __decorate([manaSyringe.singleton()], ImageRenderer);
1567
+
1568
+ var LineRenderer = /*#__PURE__*/function () {
1569
+ function LineRenderer() {
1570
+ _classCallCheck$2(this, LineRenderer);
1571
+
1572
+ this.dependencies = ['x1', 'y1', 'x2', 'y2'];
1573
+ }
1574
+
1575
+ _createClass$2(LineRenderer, [{
1576
+ key: "apply",
1577
+ value: function apply($el, parsedStyle) {
1578
+ var x1 = parsedStyle.x1,
1579
+ y1 = parsedStyle.y1,
1580
+ x2 = parsedStyle.x2,
1581
+ y2 = parsedStyle.y2,
1582
+ _parsedStyle$defX = parsedStyle.defX,
1583
+ x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
1584
+ _parsedStyle$defY = parsedStyle.defY,
1585
+ y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY,
1586
+ stroke = parsedStyle.stroke;
1587
+ $el.setAttribute('x1', "".concat(x1.value - x));
1588
+ $el.setAttribute('y1', "".concat(y1.value - y));
1589
+ $el.setAttribute('x2', "".concat(x2.value - x)); // fix horizontal line stroke url bug in Chrome
1590
+ // @see https://stackoverflow.com/questions/14680240/did-chrome-break-svg-stroke-url
1591
+
1592
+ if (y1.value === y2.value && stroke && !(stroke instanceof g.CSSRGB)) {
1593
+ $el.setAttribute('y2', "".concat(y2.value - y + 0.00001));
1594
+ } else {
1595
+ $el.setAttribute('y2', "".concat(y2.value - y));
1596
+ }
1597
+ }
1598
+ }]);
1599
+
1600
+ return LineRenderer;
1601
+ }();
1602
+
1603
+ LineRenderer = __decorate([manaSyringe.singleton()], LineRenderer);
1604
+
1605
+ var PolylineRenderer = /*#__PURE__*/function () {
1606
+ function PolylineRenderer() {
1607
+ _classCallCheck$2(this, PolylineRenderer);
1608
+
1609
+ this.dependencies = ['points'];
1610
+ }
1611
+
1612
+ _createClass$2(PolylineRenderer, [{
1613
+ key: "apply",
1614
+ value: function apply($el, parsedStyle) {
1615
+ var points = parsedStyle.points,
1616
+ _parsedStyle$defX = parsedStyle.defX,
1617
+ x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
1618
+ _parsedStyle$defY = parsedStyle.defY,
1619
+ y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
1620
+
1621
+ if (points && points.points && points.points.length >= 2) {
1622
+ $el.setAttribute('points', points.points.map(function (point) {
1623
+ return "".concat(point[0] - x, ",").concat(point[1] - y);
1624
+ }).join(' '));
1625
+ }
1626
+ }
1627
+ }]);
1628
+
1629
+ return PolylineRenderer;
1630
+ }();
1631
+
1632
+ PolylineRenderer = __decorate([manaSyringe.singleton()], PolylineRenderer);
1633
+
1634
+ function numberToLongString(x) {
1635
+ return x.toFixed(6).replace('.000000', '');
1636
+ }
1637
+
1638
+ function convertHTML(str) {
1639
+ var regex = /[&|<|>|"|']/g;
1640
+ return str.replace(regex, function (match) {
1641
+ if (match === '&') {
1642
+ return '&amp;';
1643
+ } else if (match === '<') {
1644
+ return '&lt;';
1645
+ } else if (match === '>') {
1646
+ return '&gt;';
1647
+ } else if (match === '"') {
1648
+ return '&quot;';
1649
+ } else {
1650
+ return '&apos;';
1651
+ }
1652
+ });
1653
+ }
1654
+
1655
+ var BASELINE_MAP = {
1656
+ top: 'before-edge',
1657
+ middle: 'central',
1658
+ bottom: 'after-edge',
1659
+ alphabetic: 'alphabetic',
1660
+ ideographic: 'ideographic',
1661
+ hanging: 'hanging'
1662
+ }; // for FireFox
1663
+ // @see https://github.com/plouc/nivo/issues/164
1664
+
1665
+ var BASELINE_MAP_FOR_FIREFOX = {
1666
+ top: 'text-before-edge',
1667
+ middle: 'central',
1668
+ bottom: 'text-after-edge',
1669
+ alphabetic: 'alphabetic',
1670
+ ideographic: 'ideographic',
1671
+ hanging: 'hanging'
1672
+ };
1673
+
1674
+ var TextRenderer = /*#__PURE__*/function () {
1675
+ function TextRenderer() {
1676
+ _classCallCheck$2(this, TextRenderer);
1677
+
1678
+ this.dependencies = ['text', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'wordWrap', 'wordWrapWidth', 'leading', 'textBaseline', 'textAlign', 'textTransform', 'whiteSpace', 'dx', 'dy'];
1679
+ }
1680
+
1681
+ _createClass$2(TextRenderer, [{
1682
+ key: "apply",
1683
+ value: function apply($el, parsedStyle) {
1684
+ var textBaseline = parsedStyle.textBaseline,
1685
+ lineWidth = parsedStyle.lineWidth,
1686
+ metrics = parsedStyle.metrics,
1687
+ dx = parsedStyle.dx,
1688
+ dy = parsedStyle.dy;
1689
+ var browser = detect();
1690
+
1691
+ if (browser && browser.name === 'firefox') {
1692
+ // compatible with FireFox browser, ref: https://github.com/antvis/g/issues/119
1693
+ $el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value] || 'alphabetic');
1694
+ } else {
1695
+ $el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value]);
1696
+ $el.setAttribute('alignment-baseline', BASELINE_MAP[textBaseline.value]);
1697
+ }
1698
+
1699
+ $el.setAttribute('paint-order', 'stroke');
1700
+ var lines = metrics.lines,
1701
+ lineHeight = metrics.lineHeight,
1702
+ height = metrics.height;
1703
+ var lineNum = lines.length;
1704
+ $el.setAttribute('style', "transform:translate(".concat(dx.toString(), ", ").concat(dy.toString(), ");"));
1705
+
1706
+ if (lineNum === 1) {
1707
+ $el.innerHTML = convertHTML(lines[0]);
1708
+ $el.setAttribute('dx', "".concat(lineWidth.value / 2));
1709
+ } else {
1710
+ $el.innerHTML = lines.map(function (line, i) {
1711
+ var dx = lineWidth.value / 2;
1712
+ var dy = 0;
1713
+
1714
+ if (i === 0) {
1715
+ // TODO: handle other textBaseline values
1716
+ if (textBaseline.value === 'middle') {
1717
+ dy = lineHeight / 2 - height / 2;
1718
+ } else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
1719
+ dy = 0;
1720
+ } else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
1721
+ dy = -lineHeight * (lineNum - 1);
1722
+ }
1723
+ } else {
1724
+ dy = lineHeight;
1725
+ }
1726
+
1727
+ return "<tspan x=\"0\" dx=\"".concat(dx, "\" dy=\"").concat(dy, "\">").concat(convertHTML(line), "</tspan>");
1728
+ }).join('');
1729
+ }
1730
+ }
1731
+ }]);
1732
+
1733
+ return TextRenderer;
1734
+ }();
1735
+
1736
+ TextRenderer = __decorate([manaSyringe.singleton()], TextRenderer);
1737
+
1738
+ var PathRenderer = /*#__PURE__*/function () {
1739
+ function PathRenderer() {
1740
+ _classCallCheck$2(this, PathRenderer);
1741
+
1742
+ this.dependencies = ['path'];
1743
+ }
1518
1744
 
1519
- function _asyncToGenerator$1(fn) {
1520
- return function () {
1521
- var self = this,
1522
- args = arguments;
1523
- return new Promise(function (resolve, reject) {
1524
- var gen = fn.apply(self, args);
1745
+ _createClass$2(PathRenderer, [{
1746
+ key: "apply",
1747
+ value: function apply($el, parsedStyle) {
1748
+ var path = parsedStyle.path,
1749
+ _parsedStyle$defX = parsedStyle.defX,
1750
+ x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
1751
+ _parsedStyle$defY = parsedStyle.defY,
1752
+ y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
1753
+ $el.setAttribute('d', this.formatPath(path.absolutePath, x, y));
1754
+ }
1755
+ }, {
1756
+ key: "formatPath",
1757
+ value: function formatPath(value, x, y) {
1758
+ var newValue = value.map(function (params) {
1759
+ var command = params[0];
1525
1760
 
1526
- function _next(value) {
1527
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
1528
- }
1761
+ switch (command) {
1762
+ case 'M':
1763
+ return "M ".concat(params[1] - x, ",").concat(params[2] - y);
1529
1764
 
1530
- function _throw(err) {
1531
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
1765
+ case 'L':
1766
+ return "L ".concat(params[1] - x, ",").concat(params[2] - y);
1767
+
1768
+ case 'Q':
1769
+ return "Q ".concat(params[1] - x, " ").concat(params[2] - y, ",").concat(params[3] - x, " ").concat(params[4] - y);
1770
+
1771
+ case 'C':
1772
+ return "C ".concat(params[1] - x, " ").concat(params[2] - y, ",").concat(params[3] - x, " ").concat(params[4] - y, ",").concat(params[5] - x, " ").concat(params[6] - y);
1773
+
1774
+ case 'A':
1775
+ return "A ".concat(params[1], " ").concat(params[2], " ").concat(params[3], " ").concat(params[4], " ").concat(params[5], " ").concat(params[6] - x, " ").concat(params[7] - y);
1776
+
1777
+ case 'Z':
1778
+ return 'Z';
1779
+ }
1780
+ }).join(' ');
1781
+
1782
+ if (~newValue.indexOf('NaN')) {
1783
+ return '';
1532
1784
  }
1533
1785
 
1534
- _next(undefined);
1535
- });
1536
- };
1537
- }
1786
+ return newValue;
1787
+ }
1788
+ }]);
1789
+
1790
+ return PathRenderer;
1791
+ }();
1792
+
1793
+ PathRenderer = __decorate([manaSyringe.singleton()], PathRenderer);
1794
+ var ElementRendererFactory = manaSyringe.Syringe.defineToken('ElementRendererFactory');
1795
+ var ElementRenderer = manaSyringe.Syringe.defineToken('ElementRenderer');
1538
1796
  /**
1539
1797
  * Common utilities
1540
1798
  * @module glMatrix
1541
1799
  */
1542
1800
  // Configuration Constants
1543
1801
 
1544
-
1545
1802
  var EPSILON = 0.000001;
1546
1803
  var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
1547
1804
  if (!Math.hypot) Math.hypot = function () {
@@ -2207,7 +2464,7 @@
2207
2464
  function createOrUpdateFilter($def, object, $el, filters) {
2208
2465
  // eg. filter="url(#f1) url(#f2)"
2209
2466
  var filterName = FILTER_PREFIX + object.entity;
2210
- var $existedFilters = $def.querySelectorAll("[name=" + filterName + "]");
2467
+ var $existedFilters = $def.querySelectorAll("[name=".concat(filterName, "]"));
2211
2468
 
2212
2469
  if ($existedFilters.length) {
2213
2470
  $existedFilters.forEach(function ($filter) {
@@ -2244,13 +2501,13 @@
2244
2501
  createInvert($filter, params);
2245
2502
  }
2246
2503
 
2247
- $filter.id = filterName + "-" + i;
2504
+ $filter.id = "".concat(filterName, "-").concat(i);
2248
2505
  $filter.setAttribute('name', filterName);
2249
2506
  $def.appendChild($filter);
2250
2507
  return $filter.id;
2251
2508
  });
2252
2509
  $el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', filterIds.map(function (filterId) {
2253
- return "url(#" + filterId + ")";
2510
+ return "url(#".concat(filterId, ")");
2254
2511
  }).join(' '));
2255
2512
  }
2256
2513
  }
@@ -2266,7 +2523,7 @@
2266
2523
  function createBlur($filter, params) {
2267
2524
  var $feGaussianBlur = createSVGElement('feGaussianBlur');
2268
2525
  $feGaussianBlur.setAttribute('in', 'SourceGraphic');
2269
- $feGaussianBlur.setAttribute('stdDeviation', "" + params[0].value);
2526
+ $feGaussianBlur.setAttribute('stdDeviation', "".concat(params[0].value));
2270
2527
  $filter.appendChild($feGaussianBlur);
2271
2528
  }
2272
2529
 
@@ -2280,10 +2537,10 @@
2280
2537
  $feFunc.setAttribute('type', type);
2281
2538
 
2282
2539
  if (type === 'table') {
2283
- $feFunc.setAttribute('tableValues', "" + tableValues);
2540
+ $feFunc.setAttribute('tableValues', "".concat(tableValues));
2284
2541
  } else {
2285
- $feFunc.setAttribute('slope', "" + slope);
2286
- $feFunc.setAttribute('intercept', "" + intercept);
2542
+ $feFunc.setAttribute('slope', "".concat(slope));
2543
+ $feFunc.setAttribute('intercept', "".concat(intercept));
2287
2544
  }
2288
2545
 
2289
2546
  $feComponentTransfer.appendChild($feFunc);
@@ -2304,7 +2561,7 @@
2304
2561
  var amount = convertToAbsoluteValue(params[0]);
2305
2562
  createFeComponentTransfer($filter, {
2306
2563
  type: 'table',
2307
- tableValues: amount + " " + (1 - amount)
2564
+ tableValues: "".concat(amount, " ").concat(1 - amount)
2308
2565
  });
2309
2566
  }
2310
2567
 
@@ -2321,14 +2578,14 @@
2321
2578
  var amount = convertToAbsoluteValue(params[0]);
2322
2579
  var $feColorMatrix = createSVGElement('feColorMatrix');
2323
2580
  $feColorMatrix.setAttribute('type', 'saturate');
2324
- $feColorMatrix.setAttribute('values', "" + amount);
2581
+ $feColorMatrix.setAttribute('values', "".concat(amount));
2325
2582
  $filter.appendChild($feColorMatrix);
2326
2583
  }
2327
2584
 
2328
2585
  function createHueRotate($filter, params) {
2329
2586
  var $feColorMatrix = createSVGElement('feColorMatrix');
2330
2587
  $feColorMatrix.setAttribute('type', 'hueRotate');
2331
- $feColorMatrix.setAttribute('values', "" + params[0].to(g.UnitType.kDegrees).value);
2588
+ $feColorMatrix.setAttribute('values', "".concat(params[0].to(g.UnitType.kDegrees).value));
2332
2589
  $filter.appendChild($feColorMatrix);
2333
2590
  }
2334
2591
 
@@ -2340,11 +2597,11 @@
2340
2597
  var shadowColor = params[3].formatted;
2341
2598
  var $feGaussianBlur = createSVGElement('feGaussianBlur');
2342
2599
  $feGaussianBlur.setAttribute('in', 'SourceAlpha');
2343
- $feGaussianBlur.setAttribute('stdDeviation', "" + shadowBlur);
2600
+ $feGaussianBlur.setAttribute('stdDeviation', "".concat(shadowBlur));
2344
2601
  $filter.appendChild($feGaussianBlur);
2345
2602
  var $feOffset = createSVGElement('feOffset');
2346
- $feOffset.setAttribute('dx', "" + shadowOffsetX);
2347
- $feOffset.setAttribute('dy', "" + shadowOffsetY);
2603
+ $feOffset.setAttribute('dx', "".concat(shadowOffsetX));
2604
+ $feOffset.setAttribute('dy', "".concat(shadowOffsetY));
2348
2605
  $feOffset.setAttribute('result', 'offsetblur');
2349
2606
  $filter.appendChild($feOffset);
2350
2607
  var $feFlood = createSVGElement('feFlood');
@@ -2398,7 +2655,7 @@
2398
2655
  }
2399
2656
 
2400
2657
  var gradientId = generateCacheKey(parsedColor);
2401
- var existed = $def.querySelector("#" + gradientId);
2658
+ var existed = $def.querySelector("#".concat(gradientId));
2402
2659
 
2403
2660
  if (parsedColor instanceof g.CSSRGB) {
2404
2661
  // keep using currentColor @see https://github.com/d3/d3-axis/issues/49
@@ -2414,13 +2671,13 @@
2414
2671
  createPattern($def, parsedColor, gradientId);
2415
2672
  }
2416
2673
 
2417
- $el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#" + gradientId + ")");
2674
+ $el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#".concat(gradientId, ")"));
2418
2675
  } else {
2419
2676
  if (!existed) {
2420
2677
  createGradient($def, parsedColor, gradientId);
2421
2678
  }
2422
2679
 
2423
- $el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#" + gradientId + ")");
2680
+ $el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#".concat(gradientId, ")"));
2424
2681
  }
2425
2682
  }
2426
2683
  }
@@ -2443,14 +2700,14 @@
2443
2700
  y1 = _params$value.y1,
2444
2701
  r1 = _params$value.r1,
2445
2702
  steps = _params$value.steps;
2446
- cacheKey = "" + type + x0 + y0 + x1 + y1 + (r1 || 0) + steps.map(function (step) {
2703
+ cacheKey = "".concat(type).concat(x0).concat(y0).concat(x1).concat(y1).concat(r1 || 0).concat(steps.map(function (step) {
2447
2704
  return step.join('');
2448
- }).join('');
2705
+ }).join(''));
2449
2706
  }
2450
2707
 
2451
2708
  if (cacheKey) {
2452
2709
  if (!cacheKey2IDMap[cacheKey]) {
2453
- cacheKey2IDMap[cacheKey] = "_pattern_" + type + "_" + counter++;
2710
+ cacheKey2IDMap[cacheKey] = "_pattern_".concat(type, "_").concat(counter++);
2454
2711
  }
2455
2712
  }
2456
2713
  }
@@ -2477,8 +2734,8 @@
2477
2734
  img.src = src;
2478
2735
 
2479
2736
  function onload() {
2480
- $pattern.setAttribute('width', "" + img.width);
2481
- $pattern.setAttribute('height', "" + img.height);
2737
+ $pattern.setAttribute('width', "".concat(img.width));
2738
+ $pattern.setAttribute('height', "".concat(img.height));
2482
2739
  }
2483
2740
 
2484
2741
  if (img.complete) {
@@ -2502,26 +2759,28 @@
2502
2759
  y0 = _parsedColor$value.y0,
2503
2760
  x1 = _parsedColor$value.x1,
2504
2761
  y1 = _parsedColor$value.y1;
2505
- $gradient.setAttribute('x1', "" + x0);
2506
- $gradient.setAttribute('y1', "" + y0);
2507
- $gradient.setAttribute('x2', "" + x1);
2508
- $gradient.setAttribute('y2', "" + y1);
2762
+ $gradient.setAttribute('x1', "".concat(x0));
2763
+ $gradient.setAttribute('y1', "".concat(y0));
2764
+ $gradient.setAttribute('x2', "".concat(x1));
2765
+ $gradient.setAttribute('y2', "".concat(y1));
2509
2766
  } else {
2510
2767
  var _parsedColor$value2 = parsedColor.value,
2511
2768
  _x = _parsedColor$value2.x0,
2512
2769
  _y = _parsedColor$value2.y0,
2513
2770
  r1 = _parsedColor$value2.r1;
2514
- $gradient.setAttribute('cx', "" + _x);
2515
- $gradient.setAttribute('cy', "" + _y);
2516
- $gradient.setAttribute('r', "" + r1 / 2);
2771
+ $gradient.setAttribute('cx', "".concat(_x));
2772
+ $gradient.setAttribute('cy', "".concat(_y));
2773
+ $gradient.setAttribute('r', "".concat(r1 / 2));
2517
2774
  } // add stops
2518
2775
 
2519
2776
 
2520
2777
  var innerHTML = '';
2521
2778
  parsedColor.value.steps.forEach(function (_ref) {
2522
- var offset = _ref[0],
2523
- color = _ref[1];
2524
- innerHTML += "<stop offset=\"" + offset + "\" stop-color=\"" + color + "\"></stop>";
2779
+ var _ref2 = _slicedToArray(_ref, 2),
2780
+ offset = _ref2[0],
2781
+ color = _ref2[1];
2782
+
2783
+ innerHTML += "<stop offset=\"".concat(offset, "\" stop-color=\"").concat(color, "\"></stop>");
2525
2784
  });
2526
2785
  $gradient.innerHTML = innerHTML;
2527
2786
  $gradient.id = gradientId;
@@ -2536,7 +2795,7 @@
2536
2795
 
2537
2796
  function createOrUpdateShadow($def, object, $el, name) {
2538
2797
  var shadowId = FILTER_DROPSHADOW_PREFIX + object.entity;
2539
- var $existedFilter = $def.querySelector("#" + shadowId);
2798
+ var $existedFilter = $def.querySelector("#".concat(shadowId));
2540
2799
 
2541
2800
  if (!$existedFilter) {
2542
2801
  $existedFilter = createSVGElement('filter');
@@ -2562,18 +2821,23 @@
2562
2821
  // @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
2563
2822
  // @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
2564
2823
 
2565
- $feDropShadow.setAttribute('stdDeviation', "" + (shadowBlur && shadowBlur.value || 0) / 2);
2824
+ $feDropShadow.setAttribute('stdDeviation', "".concat((shadowBlur && shadowBlur.value || 0) / 2));
2566
2825
  } else if (name === 'shadowOffsetX') {
2567
2826
  var shadowOffsetX = object.parsedStyle[name];
2568
- $feDropShadow.setAttribute('dx', "" + (shadowOffsetX && shadowOffsetX.value || 0) / 2);
2827
+ $feDropShadow.setAttribute('dx', "".concat((shadowOffsetX && shadowOffsetX.value || 0) / 2));
2569
2828
  } else if (name === 'shadowOffsetY') {
2570
2829
  var shadowOffsetY = object.parsedStyle[name];
2571
- $feDropShadow.setAttribute('dy', "" + (shadowOffsetY && shadowOffsetY.value || 0) / 2);
2572
- } // use filter <feDropShadow>
2573
- // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow
2830
+ $feDropShadow.setAttribute('dy', "".concat((shadowOffsetY && shadowOffsetY.value || 0) / 2));
2831
+ } // only apply shadow when blur > 0
2574
2832
 
2575
2833
 
2576
- $el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + shadowId + ")");
2834
+ if (object.parsedStyle.shadowBlur && object.parsedStyle.shadowBlur.value > 0) {
2835
+ // use filter <feDropShadow>
2836
+ // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow
2837
+ $el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#".concat(shadowId, ")"));
2838
+ } else {
2839
+ $el === null || $el === void 0 ? void 0 : $el.removeAttribute('filter');
2840
+ }
2577
2841
  }
2578
2842
 
2579
2843
  var CreateElementContribution = manaSyringe.Syringe.defineToken('CreateElementContribution', {
@@ -2581,13 +2845,16 @@
2581
2845
  });
2582
2846
 
2583
2847
  var DefaultElementContribution = /*#__PURE__*/function () {
2584
- function DefaultElementContribution() {}
2585
-
2586
- var _proto = DefaultElementContribution.prototype;
2848
+ function DefaultElementContribution() {
2849
+ _classCallCheck$2(this, DefaultElementContribution);
2850
+ }
2587
2851
 
2588
- _proto.createElement = function createElement(object) {
2589
- return createSVGElement(object.nodeName);
2590
- };
2852
+ _createClass$2(DefaultElementContribution, [{
2853
+ key: "createElement",
2854
+ value: function createElement(object) {
2855
+ return createSVGElement(object.nodeName);
2856
+ }
2857
+ }]);
2591
2858
 
2592
2859
  return DefaultElementContribution;
2593
2860
  }();
@@ -2599,7 +2866,7 @@
2599
2866
  var _SHAPE2TAGS, _class$1;
2600
2867
 
2601
2868
  var SVGRendererPlugin_1;
2602
- var SHAPE2TAGS = (_SHAPE2TAGS = {}, _SHAPE2TAGS[g.Shape.RECT] = 'path', _SHAPE2TAGS[g.Shape.CIRCLE] = 'circle', _SHAPE2TAGS[g.Shape.ELLIPSE] = 'ellipse', _SHAPE2TAGS[g.Shape.IMAGE] = 'image', _SHAPE2TAGS[g.Shape.GROUP] = 'g', _SHAPE2TAGS[g.Shape.LINE] = 'line', _SHAPE2TAGS[g.Shape.POLYLINE] = 'polyline', _SHAPE2TAGS[g.Shape.POLYGON] = 'polygon', _SHAPE2TAGS[g.Shape.TEXT] = 'text', _SHAPE2TAGS[g.Shape.PATH] = 'path', _SHAPE2TAGS[g.Shape.HTML] = 'foreignObject', _SHAPE2TAGS);
2869
+ var SHAPE2TAGS = (_SHAPE2TAGS = {}, _defineProperty(_SHAPE2TAGS, g.Shape.RECT, 'path'), _defineProperty(_SHAPE2TAGS, g.Shape.CIRCLE, 'circle'), _defineProperty(_SHAPE2TAGS, g.Shape.ELLIPSE, 'ellipse'), _defineProperty(_SHAPE2TAGS, g.Shape.IMAGE, 'image'), _defineProperty(_SHAPE2TAGS, g.Shape.GROUP, 'g'), _defineProperty(_SHAPE2TAGS, g.Shape.LINE, 'line'), _defineProperty(_SHAPE2TAGS, g.Shape.POLYLINE, 'polyline'), _defineProperty(_SHAPE2TAGS, g.Shape.POLYGON, 'polygon'), _defineProperty(_SHAPE2TAGS, g.Shape.TEXT, 'text'), _defineProperty(_SHAPE2TAGS, g.Shape.PATH, 'path'), _defineProperty(_SHAPE2TAGS, g.Shape.HTML, 'foreignObject'), _SHAPE2TAGS);
2603
2870
  var SVG_ATTR_MAP = {
2604
2871
  opacity: 'opacity',
2605
2872
  fillStyle: 'fill',
@@ -2681,6 +2948,8 @@
2681
2948
  var CLIP_PATH_PREFIX = 'clip-path-';
2682
2949
  var SVGRendererPlugin = SVGRendererPlugin_1 = (_class$1 = /*#__PURE__*/function () {
2683
2950
  function SVGRendererPlugin() {
2951
+ _classCallCheck$2(this, SVGRendererPlugin);
2952
+
2684
2953
  this.canvasConfig = void 0;
2685
2954
  this.camera = void 0;
2686
2955
  this.contextService = void 0;
@@ -2692,458 +2961,472 @@
2692
2961
  this.renderQueue = [];
2693
2962
  }
2694
2963
 
2695
- var _proto = SVGRendererPlugin.prototype;
2964
+ _createClass$2(SVGRendererPlugin, [{
2965
+ key: "apply",
2966
+ value: function apply(renderingService) {
2967
+ var _this = this;
2696
2968
 
2697
- _proto.apply = function apply(renderingService) {
2698
- var _this = this;
2969
+ var handleMounted = function handleMounted(e) {
2970
+ var object = e.target; // create SVG DOM Node
2699
2971
 
2700
- var handleMounted = function handleMounted(e) {
2701
- var object = e.target; // create SVG DOM Node
2972
+ _this.createSVGDom(object, _this.$camera);
2973
+ };
2702
2974
 
2703
- _this.createSVGDom(object, _this.$camera);
2704
- };
2975
+ var handleUnmounted = function handleUnmounted(e) {
2976
+ var object = e.target;
2705
2977
 
2706
- var handleUnmounted = function handleUnmounted(e) {
2707
- var object = e.target;
2978
+ _this.removeSVGDom(object);
2979
+ };
2708
2980
 
2709
- _this.removeSVGDom(object);
2710
- };
2981
+ var handleAttributeChanged = function handleAttributeChanged(e) {
2982
+ var object = e.target; // @see https://github.com/antvis/g/issues/994
2983
+ // @ts-ignore
2711
2984
 
2712
- var handleAttributeChanged = function handleAttributeChanged(e) {
2713
- var object = e.target; // @see https://github.com/antvis/g/issues/994
2714
- // @ts-ignore
2985
+ if (!object.elementSVG) {
2986
+ return;
2987
+ }
2715
2988
 
2716
- if (!object.elementSVG) {
2717
- return;
2718
- }
2989
+ var attrName = e.attrName;
2719
2990
 
2720
- var attrName = e.attrName;
2991
+ if (attrName === 'zIndex') {
2992
+ var _object$parentNode, _object$parentNode$el;
2721
2993
 
2722
- if (attrName === 'zIndex') {
2723
- var _object$parentNode, _object$parentNode$el;
2994
+ var parent = object.parentNode; // @ts-ignore
2724
2995
 
2725
- var parent = object.parentNode; // @ts-ignore
2996
+ var $groupEl = (_object$parentNode = object.parentNode) === null || _object$parentNode === void 0 ? void 0 : (_object$parentNode$el = _object$parentNode.elementSVG) === null || _object$parentNode$el === void 0 ? void 0 : _object$parentNode$el.$groupEl;
2997
+ var children = ((parent === null || parent === void 0 ? void 0 : parent.children) || []).slice();
2726
2998
 
2727
- var $groupEl = (_object$parentNode = object.parentNode) === null || _object$parentNode === void 0 ? void 0 : (_object$parentNode$el = _object$parentNode.elementSVG) === null || _object$parentNode$el === void 0 ? void 0 : _object$parentNode$el.$groupEl;
2728
- var children = ((parent === null || parent === void 0 ? void 0 : parent.children) || []).slice();
2999
+ if ($groupEl) {
3000
+ _this.reorderChildren($groupEl, children);
3001
+ }
3002
+ } else if (attrName === 'increasedLineWidthForHitTesting') {
3003
+ // @ts-ignore
3004
+ var svgElement = object.elementSVG;
2729
3005
 
2730
- if ($groupEl) {
2731
- _this.reorderChildren($groupEl, children);
3006
+ _this.createOrUpdateHitArea(object, svgElement.$el, svgElement.$groupEl);
2732
3007
  }
2733
- } else if (attrName === 'increasedLineWidthForHitTesting') {
2734
- // @ts-ignore
2735
- var svgElement = object.elementSVG;
2736
3008
 
2737
- _this.createOrUpdateHitArea(object, svgElement.$el, svgElement.$groupEl);
2738
- }
3009
+ _this.updateAttribute(object, [attrName]);
3010
+ };
2739
3011
 
2740
- _this.updateAttribute(object, [attrName]);
2741
- };
3012
+ renderingService.hooks.init.tapPromise(SVGRendererPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
3013
+ var $svg, background;
3014
+ return _regeneratorRuntime$1().wrap(function _callee$(_context) {
3015
+ while (1) {
3016
+ switch (_context.prev = _context.next) {
3017
+ case 0:
3018
+ _this.$def = createSVGElement('defs');
3019
+ $svg = _this.contextService.getContext();
3020
+ background = _this.canvasConfig.background;
2742
3021
 
2743
- renderingService.hooks.init.tapPromise(SVGRendererPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
2744
- var $svg, background;
2745
- return _regeneratorRuntime$1().wrap(function _callee$(_context) {
2746
- while (1) {
2747
- switch (_context.prev = _context.next) {
2748
- case 0:
2749
- _this.$def = createSVGElement('defs');
2750
- $svg = _this.contextService.getContext();
2751
- background = _this.canvasConfig.background;
2752
-
2753
- if (background) {
2754
- $svg.style.background = background;
2755
- }
3022
+ if (background) {
3023
+ $svg.style.background = background;
3024
+ }
2756
3025
 
2757
- $svg.appendChild(_this.$def); // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
3026
+ $svg.appendChild(_this.$def); // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
2758
3027
 
2759
- $svg.setAttribute('color-interpolation-filters', 'sRGB');
2760
- _this.$camera = createSVGElement('g');
2761
- _this.$camera.id = G_SVG_PREFIX + "_camera";
3028
+ $svg.setAttribute('color-interpolation-filters', 'sRGB');
3029
+ _this.$camera = createSVGElement('g');
3030
+ _this.$camera.id = "".concat(G_SVG_PREFIX, "_camera");
2762
3031
 
2763
- _this.applyTransform(_this.$camera, _this.camera.getOrthoMatrix());
3032
+ _this.applyTransform(_this.$camera, _this.camera.getOrthoMatrix());
2764
3033
 
2765
- $svg.appendChild(_this.$camera);
3034
+ $svg.appendChild(_this.$camera);
2766
3035
 
2767
- _this.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
3036
+ _this.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
2768
3037
 
2769
- _this.renderingContext.root.addEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
3038
+ _this.renderingContext.root.addEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
2770
3039
 
2771
- _this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
3040
+ _this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
2772
3041
 
2773
- case 13:
2774
- case "end":
2775
- return _context.stop();
3042
+ case 13:
3043
+ case "end":
3044
+ return _context.stop();
3045
+ }
2776
3046
  }
2777
- }
2778
- }, _callee);
2779
- })));
2780
- renderingService.hooks.destroy.tap(SVGRendererPlugin_1.tag, function () {
2781
- _this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
3047
+ }, _callee);
3048
+ })));
3049
+ renderingService.hooks.destroy.tap(SVGRendererPlugin_1.tag, function () {
3050
+ _this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
2782
3051
 
2783
- _this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
3052
+ _this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
2784
3053
 
2785
- _this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
2786
- });
2787
- renderingService.hooks.render.tap(SVGRendererPlugin_1.tag, function (object) {
2788
- // if (!object.isCulled()) {
2789
- _this.renderQueue.push(object); // }
2790
-
2791
- });
2792
- renderingService.hooks.endFrame.tap(SVGRendererPlugin_1.tag, function () {
2793
- if (_this.renderingContext.renderReasons.has(g.RenderReason.CAMERA_CHANGED)) {
2794
- _this.applyTransform(_this.$camera, _this.camera.getOrthoMatrix());
2795
- }
3054
+ _this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
3055
+ });
3056
+ renderingService.hooks.render.tap(SVGRendererPlugin_1.tag, function (object) {
3057
+ // if (!object.isCulled()) {
3058
+ _this.renderQueue.push(object); // }
2796
3059
 
2797
- _this.renderQueue.forEach(function (object) {
2798
- var _object$elementSVG, _object$elementSVG2; // @ts-ignore
3060
+ });
3061
+ renderingService.hooks.endFrame.tap(SVGRendererPlugin_1.tag, function () {
3062
+ if (_this.renderingContext.renderReasons.has(g.RenderReason.CAMERA_CHANGED)) {
3063
+ _this.applyTransform(_this.$camera, _this.camera.getOrthoMatrix());
3064
+ }
2799
3065
 
3066
+ _this.renderQueue.forEach(function (object) {
3067
+ var _object$elementSVG, _object$elementSVG2; // @ts-ignore
2800
3068
 
2801
- var $el = (_object$elementSVG = object.elementSVG) === null || _object$elementSVG === void 0 ? void 0 : _object$elementSVG.$el; // @ts-ignore
2802
3069
 
2803
- var $groupEl = (_object$elementSVG2 = object.elementSVG) === null || _object$elementSVG2 === void 0 ? void 0 : _object$elementSVG2.$groupEl;
3070
+ var $el = (_object$elementSVG = object.elementSVG) === null || _object$elementSVG === void 0 ? void 0 : _object$elementSVG.$el; // @ts-ignore
2804
3071
 
2805
- if ($el && $groupEl) {
2806
- // apply local RTS transformation to <group> wrapper
2807
- // account for anchor
2808
- _this.applyTransform($groupEl, object.getLocalTransform()); // finish rendering, clear dirty flag
3072
+ var $groupEl = (_object$elementSVG2 = object.elementSVG) === null || _object$elementSVG2 === void 0 ? void 0 : _object$elementSVG2.$groupEl;
2809
3073
 
3074
+ if ($el && $groupEl) {
3075
+ // apply local RTS transformation to <group> wrapper
3076
+ // account for anchor
3077
+ _this.applyTransform($groupEl, object.getLocalTransform()); // finish rendering, clear dirty flag
2810
3078
 
2811
- object.renderable.dirty = false;
2812
- }
2813
- });
2814
3079
 
2815
- _this.renderQueue = [];
2816
- });
2817
- };
3080
+ object.renderable.dirty = false;
3081
+ }
3082
+ });
2818
3083
 
2819
- _proto.reorderChildren = function reorderChildren($groupEl, children) {
2820
- // need to reorder parent's children
2821
- children.sort(function (a, b) {
2822
- return a.sortable.renderOrder - b.sortable.renderOrder;
2823
- });
3084
+ _this.renderQueue = [];
3085
+ });
3086
+ }
3087
+ }, {
3088
+ key: "reorderChildren",
3089
+ value: function reorderChildren($groupEl, children) {
3090
+ // need to reorder parent's children
3091
+ children.sort(function (a, b) {
3092
+ return a.sortable.renderOrder - b.sortable.renderOrder;
3093
+ });
2824
3094
 
2825
- if (children.length) {
2826
- // create empty fragment
2827
- var fragment = document.createDocumentFragment();
2828
- children.forEach(function (child) {
2829
- if (child.isConnected) {
2830
- // @ts-ignore
2831
- var $el = child.elementSVG.$groupEl;
3095
+ if (children.length) {
3096
+ // create empty fragment
3097
+ var fragment = document.createDocumentFragment();
3098
+ children.forEach(function (child) {
3099
+ if (child.isConnected) {
3100
+ // @ts-ignore
3101
+ var $el = child.elementSVG.$groupEl;
2832
3102
 
2833
- if ($el) {
2834
- fragment.appendChild($el);
3103
+ if ($el) {
3104
+ fragment.appendChild($el);
3105
+ }
2835
3106
  }
2836
- }
2837
- });
2838
- $groupEl.appendChild(fragment);
3107
+ });
3108
+ $groupEl.appendChild(fragment);
3109
+ }
2839
3110
  }
2840
- };
3111
+ }, {
3112
+ key: "applyTransform",
3113
+ value: function applyTransform($el, transform) {
3114
+ var translation = getTranslation(create$1(), transform);
3115
+ var scaling = getScaling(create$1(), transform);
3116
+ var rotation = getRotation(create$3(), transform);
2841
3117
 
2842
- _proto.applyTransform = function applyTransform($el, transform) {
2843
- var translation = getTranslation(create$1(), transform);
2844
- var scaling = getScaling(create$1(), transform);
2845
- var rotation = getRotation(create$3(), transform);
2846
- var x = translation[0],
2847
- y = translation[1];
2848
- var scaleX = scaling[0],
2849
- scaleY = scaling[1]; // eslint-disable-next-line @typescript-eslint/no-unused-vars
3118
+ var _translation = _slicedToArray(translation, 2),
3119
+ x = _translation[0],
3120
+ y = _translation[1];
2850
3121
 
2851
- var _getEuler = g.getEuler(create$1(), rotation),
2852
- ex = _getEuler[0],
2853
- ey = _getEuler[1],
2854
- ez = _getEuler[2]; // gimbal lock at 90 degrees
3122
+ var _scaling = _slicedToArray(scaling, 2),
3123
+ scaleX = _scaling[0],
3124
+ scaleY = _scaling[1]; // eslint-disable-next-line @typescript-eslint/no-unused-vars
2855
3125
 
2856
3126
 
2857
- var rts = g.fromRotationTranslationScale(ex || ez, x, y, scaleX, scaleY); // use proper precision avoiding too long string in `transform`
2858
- // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
3127
+ var _getEuler = g.getEuler(create$1(), rotation),
3128
+ _getEuler2 = _slicedToArray(_getEuler, 3),
3129
+ ex = _getEuler2[0],
3130
+ ey = _getEuler2[1],
3131
+ ez = _getEuler2[2]; // gimbal lock at 90 degrees
2859
3132
 
2860
- $el.setAttribute('transform', "matrix(" + numberToLongString(rts[0]) + "," + numberToLongString(rts[1]) + "," + numberToLongString(rts[3]) + "," + numberToLongString(rts[4]) + "," + numberToLongString(rts[6]) + "," + numberToLongString(rts[7]) + ")");
2861
- };
2862
3133
 
2863
- _proto.applyAttributes = function applyAttributes(object) {
2864
- // @ts-ignore
2865
- var elementSVG = object.elementSVG;
2866
- var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
2867
- var $groupEl = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$groupEl;
3134
+ var rts = g.fromRotationTranslationScale(ex || ez, x, y, scaleX, scaleY); // use proper precision avoiding too long string in `transform`
3135
+ // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
2868
3136
 
2869
- if ($el && $groupEl) {
2870
- var nodeName = object.nodeName,
2871
- attributes = object.attributes;
2872
- $el.setAttribute('fill', 'none');
3137
+ $el.setAttribute('transform', "matrix(".concat(numberToLongString(rts[0]), ",").concat(numberToLongString(rts[1]), ",").concat(numberToLongString(rts[3]), ",").concat(numberToLongString(rts[4]), ",").concat(numberToLongString(rts[6]), ",").concat(numberToLongString(rts[7]), ")"));
3138
+ }
3139
+ }, {
3140
+ key: "applyAttributes",
3141
+ value: function applyAttributes(object) {
3142
+ // @ts-ignore
3143
+ var elementSVG = object.elementSVG;
3144
+ var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
3145
+ var $groupEl = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$groupEl;
2873
3146
 
2874
- if (nodeName === g.Shape.IMAGE) {
2875
- $el.setAttribute('preserveAspectRatio', 'none');
2876
- } // apply attributes
3147
+ if ($el && $groupEl) {
3148
+ var nodeName = object.nodeName,
3149
+ attributes = object.attributes;
3150
+ $el.setAttribute('fill', 'none');
2877
3151
 
3152
+ if (nodeName === g.Shape.IMAGE) {
3153
+ $el.setAttribute('preserveAspectRatio', 'none');
3154
+ } // apply attributes
2878
3155
 
2879
- this.updateAttribute(object, Object.keys(attributes));
2880
- }
2881
- };
2882
3156
 
2883
- _proto.updateAttribute = function updateAttribute(object, attributes) {
2884
- var _this2 = this;
2885
-
2886
- var needGeneratePath = false; // @ts-ignore
2887
-
2888
- var _object$elementSVG3 = object.elementSVG,
2889
- $el = _object$elementSVG3.$el,
2890
- $groupEl = _object$elementSVG3.$groupEl,
2891
- $hitTestingEl = _object$elementSVG3.$hitTestingEl;
2892
- var parsedStyle = object.parsedStyle,
2893
- computedStyle = object.computedStyle;
2894
- var elementRenderer = this.elementRendererFactory(object.nodeName);
2895
- attributes.forEach(function (name) {
2896
- var usedName = SVG_ATTR_MAP[name];
2897
- var computedValue = computedStyle[name];
2898
- var usedValue = parsedStyle[name]; // generate path only once
2899
-
2900
- if (!needGeneratePath && elementRenderer && elementRenderer.dependencies.indexOf(name) > -1) {
2901
- needGeneratePath = true;
2902
- } // <foreignObject>
2903
-
2904
-
2905
- if (object.nodeName === g.Shape.HTML) {
2906
- if (name === 'fill') {
2907
- $el.style.background = usedValue.toString();
2908
- } else if (name === 'stroke') {
2909
- $el.style['border-color'] = usedValue.toString();
2910
- $el.style['border-style'] = 'solid';
2911
- } else if (name === 'lineWidth') {
2912
- $el.style['border-width'] = (usedValue.value || 0) + "px";
2913
- } else if (name === 'lineDash') {
2914
- $el.style['border-style'] = 'dashed';
2915
- }
3157
+ this.updateAttribute(object, Object.keys(attributes));
2916
3158
  }
2917
-
2918
- if (name === 'fill' || name === 'stroke') {
2919
- createOrUpdateGradientAndPattern(_this2.$def, object, $el, usedValue, usedName);
2920
- } else if (name === 'visibility') {
2921
- // use computed value
2922
- // update `visibility` on <group>
2923
- $groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, "" + computedValue.value);
2924
- } else if (name === 'clipPath') {
2925
- _this2.createOrUpdateClipPath(usedValue, $groupEl);
2926
- } else if (name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
2927
- createOrUpdateShadow(_this2.$def, object, $el, name);
2928
- } else if (name === 'filter') {
2929
- createOrUpdateFilter(_this2.$def, object, $el, usedValue);
2930
- } else if (name === 'innerHTML') {
2931
- _this2.createOrUpdateInnerHTML($el, usedValue);
2932
- } else {
2933
- if ( // (!object.style.clipPathTargets) &&
2934
- object.nodeName !== g.Shape.TEXT && // text' anchor is controlled by `textAnchor` property
2935
- ['width', 'height', 'r', 'rx', 'ry', 'anchor'].indexOf(name) > -1) {
2936
- _this2.updateAnchorWithTransform(object);
3159
+ }
3160
+ }, {
3161
+ key: "updateAttribute",
3162
+ value: function updateAttribute(object, attributes) {
3163
+ var _this2 = this;
3164
+
3165
+ var needGeneratePath = false; // @ts-ignore
3166
+
3167
+ var _object$elementSVG3 = object.elementSVG,
3168
+ $el = _object$elementSVG3.$el,
3169
+ $groupEl = _object$elementSVG3.$groupEl,
3170
+ $hitTestingEl = _object$elementSVG3.$hitTestingEl;
3171
+ var parsedStyle = object.parsedStyle,
3172
+ computedStyle = object.computedStyle;
3173
+ var elementRenderer = this.elementRendererFactory(object.nodeName);
3174
+ attributes.forEach(function (name) {
3175
+ var usedName = SVG_ATTR_MAP[name];
3176
+ var computedValue = computedStyle[name];
3177
+ var usedValue = parsedStyle[name]; // generate path only once
3178
+
3179
+ if (!needGeneratePath && elementRenderer && elementRenderer.dependencies.indexOf(name) > -1) {
3180
+ needGeneratePath = true;
3181
+ } // <foreignObject>
3182
+
3183
+
3184
+ if (object.nodeName === g.Shape.HTML) {
3185
+ if (name === 'fill') {
3186
+ $el.style.background = usedValue.toString();
3187
+ } else if (name === 'stroke') {
3188
+ $el.style['border-color'] = usedValue.toString();
3189
+ $el.style['border-style'] = 'solid';
3190
+ } else if (name === 'lineWidth') {
3191
+ $el.style['border-width'] = "".concat(usedValue.value || 0, "px");
3192
+ } else if (name === 'lineDash') {
3193
+ $el.style['border-style'] = 'dashed';
3194
+ }
2937
3195
  }
2938
3196
 
2939
- if (name !== 'anchor' && computedValue) {
2940
- // use computed value so that we can use cascaded effect in SVG
2941
- var valueStr = computedValue.toString(); // ignore 'unset' and default value
3197
+ if (name === 'fill' || name === 'stroke') {
3198
+ createOrUpdateGradientAndPattern(_this2.$def, object, $el, usedValue, usedName);
3199
+ } else if (name === 'visibility' && computedValue.value !== 'unset') {
3200
+ // use computed value
3201
+ // update `visibility` on <group>
3202
+ $groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, "".concat(computedValue.value));
3203
+ } else if (name === 'clipPath') {
3204
+ _this2.createOrUpdateClipPath(usedValue, $groupEl);
3205
+ } else if (name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
3206
+ createOrUpdateShadow(_this2.$def, object, $el, name);
3207
+ } else if (name === 'filter') {
3208
+ createOrUpdateFilter(_this2.$def, object, $el, usedValue);
3209
+ } else if (name === 'innerHTML') {
3210
+ _this2.createOrUpdateInnerHTML($el, usedValue);
3211
+ } else {
3212
+ if ( // (!object.style.clipPathTargets) &&
3213
+ object.nodeName !== g.Shape.TEXT && // text' anchor is controlled by `textAnchor` property
3214
+ ['width', 'height', 'r', 'rx', 'ry', 'anchor'].indexOf(name) > -1) {
3215
+ _this2.updateAnchorWithTransform(object);
3216
+ }
2942
3217
 
2943
- [$el, $hitTestingEl].forEach(function ($el) {
2944
- if ($el && usedName) {
2945
- if (valueStr !== 'unset' && valueStr !== DEFAULT_VALUE_MAP[name]) {
2946
- var _FORMAT_VALUE_MAP$nam;
3218
+ if (name !== 'anchor' && computedValue) {
3219
+ // use computed value so that we can use cascaded effect in SVG
3220
+ var valueStr = computedValue.toString(); // ignore 'unset' and default value
2947
3221
 
2948
- var formattedValueStr = ((_FORMAT_VALUE_MAP$nam = FORMAT_VALUE_MAP[name]) === null || _FORMAT_VALUE_MAP$nam === void 0 ? void 0 : _FORMAT_VALUE_MAP$nam[valueStr]) || valueStr;
2949
- $el.setAttribute(usedName, formattedValueStr);
2950
- } else {
2951
- $el.removeAttribute(usedName);
3222
+ [$el, $hitTestingEl].forEach(function ($el) {
3223
+ if ($el && usedName) {
3224
+ if (valueStr !== 'unset' && valueStr !== DEFAULT_VALUE_MAP[name]) {
3225
+ var _FORMAT_VALUE_MAP$nam;
3226
+
3227
+ var formattedValueStr = ((_FORMAT_VALUE_MAP$nam = FORMAT_VALUE_MAP[name]) === null || _FORMAT_VALUE_MAP$nam === void 0 ? void 0 : _FORMAT_VALUE_MAP$nam[valueStr]) || valueStr;
3228
+ $el.setAttribute(usedName, formattedValueStr);
3229
+ } else {
3230
+ $el.removeAttribute(usedName);
3231
+ }
2952
3232
  }
2953
- }
2954
- });
3233
+ });
3234
+ }
2955
3235
  }
2956
- }
2957
- }); // need re-generate path
3236
+ }); // need re-generate path
2958
3237
 
2959
- if (needGeneratePath && $el) {
2960
- [$el, $hitTestingEl].forEach(function ($el) {
2961
- if ($el) {
2962
- elementRenderer.apply($el, object.parsedStyle);
2963
- }
2964
- });
3238
+ if (needGeneratePath && $el) {
3239
+ [$el, $hitTestingEl].forEach(function ($el) {
3240
+ if ($el) {
3241
+ elementRenderer.apply($el, object.parsedStyle);
3242
+ }
3243
+ });
3244
+ }
2965
3245
  }
2966
- };
2967
-
2968
- _proto.createSVGDom = function createSVGDom(object, root, noWrapWithGroup) {
2969
- if (noWrapWithGroup === void 0) {
2970
- noWrapWithGroup = false;
2971
- } // create svg element
2972
- // @ts-ignore
2973
-
3246
+ }, {
3247
+ key: "createSVGDom",
3248
+ value: function createSVGDom(object, root) {
3249
+ var noWrapWithGroup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; // create svg element
3250
+ // @ts-ignore
2974
3251
 
2975
- object.elementSVG = new ElementSVG(); // @ts-ignore
3252
+ object.elementSVG = new ElementSVG(); // @ts-ignore
2976
3253
 
2977
- var svgElement = object.elementSVG; // use <group> as default, eg. CustomElement
3254
+ var svgElement = object.elementSVG; // use <group> as default, eg. CustomElement
2978
3255
 
2979
- var type = SHAPE2TAGS[object.nodeName] || 'g';
3256
+ var type = SHAPE2TAGS[object.nodeName] || 'g';
2980
3257
 
2981
- if (type) {
2982
- var _object$parentNode$el2;
3258
+ if (type) {
3259
+ var _object$parentNode$el2;
2983
3260
 
2984
- var $groupEl;
2985
- var $el = createSVGElement(type); // save $el on parsedStyle, which will be returned in getDomElement()
3261
+ var $groupEl;
3262
+ var $el = createSVGElement(type); // save $el on parsedStyle, which will be returned in getDomElement()
2986
3263
 
2987
- if (object.nodeName === g.Shape.HTML) {
2988
- object.parsedStyle.$el = $el;
2989
- }
3264
+ if (object.nodeName === g.Shape.HTML) {
3265
+ object.parsedStyle.$el = $el;
3266
+ }
2990
3267
 
2991
- $el.id = G_SVG_PREFIX + "_" + object.nodeName + "_" + object.entity;
3268
+ $el.id = "".concat(G_SVG_PREFIX, "_").concat(object.nodeName, "_").concat(object.entity);
2992
3269
 
2993
- if (type !== 'g' && !noWrapWithGroup) {
2994
- $groupEl = createSVGElement('g');
2995
- $groupEl.appendChild($el);
2996
- } else {
2997
- $groupEl = $el;
2998
- }
3270
+ if (type !== 'g' && !noWrapWithGroup) {
3271
+ $groupEl = createSVGElement('g');
3272
+ $groupEl.appendChild($el);
3273
+ } else {
3274
+ $groupEl = $el;
3275
+ }
2999
3276
 
3000
- svgElement.$el = $el;
3001
- svgElement.$groupEl = $groupEl;
3002
- var $parentGroupEl = // @ts-ignore
3003
- object.parentNode && ((_object$parentNode$el2 = object.parentNode.elementSVG) === null || _object$parentNode$el2 === void 0 ? void 0 : _object$parentNode$el2.$groupEl) || root;
3277
+ svgElement.$el = $el;
3278
+ svgElement.$groupEl = $groupEl;
3279
+ var $parentGroupEl = // @ts-ignore
3280
+ object.parentNode && ((_object$parentNode$el2 = object.parentNode.elementSVG) === null || _object$parentNode$el2 === void 0 ? void 0 : _object$parentNode$el2.$groupEl) || root;
3004
3281
 
3005
- if ($parentGroupEl) {
3006
- var _object$parentNode2;
3282
+ if ($parentGroupEl) {
3283
+ var _object$parentNode2;
3007
3284
 
3008
- $parentGroupEl.appendChild($groupEl);
3009
- var children = (((_object$parentNode2 = object.parentNode) === null || _object$parentNode2 === void 0 ? void 0 : _object$parentNode2.children) || []).slice();
3010
- this.reorderChildren($parentGroupEl, children || []);
3011
- } // apply attributes at first time
3285
+ $parentGroupEl.appendChild($groupEl);
3286
+ var children = (((_object$parentNode2 = object.parentNode) === null || _object$parentNode2 === void 0 ? void 0 : _object$parentNode2.children) || []).slice();
3287
+ this.reorderChildren($parentGroupEl, children || []);
3288
+ } // apply attributes at first time
3012
3289
 
3013
3290
 
3014
- this.applyAttributes(object); // create hitArea if necessary
3291
+ this.applyAttributes(object); // create hitArea if necessary
3015
3292
 
3016
- this.createOrUpdateHitArea(object, $el, $groupEl);
3293
+ this.createOrUpdateHitArea(object, $el, $groupEl);
3294
+ }
3017
3295
  }
3018
- };
3296
+ }, {
3297
+ key: "removeSVGDom",
3298
+ value: function removeSVGDom(object) {
3299
+ var _object$elementSVG4; // @ts-ignore
3019
3300
 
3020
- _proto.removeSVGDom = function removeSVGDom(object) {
3021
- var _object$elementSVG4; // @ts-ignore
3022
3301
 
3302
+ var $groupEl = (_object$elementSVG4 = object.elementSVG) === null || _object$elementSVG4 === void 0 ? void 0 : _object$elementSVG4.$groupEl;
3023
3303
 
3024
- var $groupEl = (_object$elementSVG4 = object.elementSVG) === null || _object$elementSVG4 === void 0 ? void 0 : _object$elementSVG4.$groupEl;
3025
-
3026
- if ($groupEl && $groupEl.parentNode) {
3027
- $groupEl.parentNode.removeChild($groupEl); // object.entity.removeComponent(ElementSVG, true);
3304
+ if ($groupEl && $groupEl.parentNode) {
3305
+ $groupEl.parentNode.removeChild($groupEl); // object.entity.removeComponent(ElementSVG, true);
3306
+ }
3028
3307
  }
3029
- };
3030
-
3031
- _proto.createOrUpdateHitArea = function createOrUpdateHitArea(object, $el, $groupEl) {
3032
- var _object$parsedStyle$i; // @ts-ignore
3308
+ }, {
3309
+ key: "createOrUpdateHitArea",
3310
+ value: function createOrUpdateHitArea(object, $el, $groupEl) {
3311
+ var _object$parsedStyle$i; // @ts-ignore
3033
3312
 
3034
3313
 
3035
- var svgElement = object.elementSVG;
3036
- var $hitTestingEl = svgElement.$hitTestingEl;
3037
- var increasedLineWidthForHitTesting = (_object$parsedStyle$i = object.parsedStyle.increasedLineWidthForHitTesting) === null || _object$parsedStyle$i === void 0 ? void 0 : _object$parsedStyle$i.value; // account for hitArea
3314
+ var svgElement = object.elementSVG;
3315
+ var $hitTestingEl = svgElement.$hitTestingEl;
3316
+ var increasedLineWidthForHitTesting = (_object$parsedStyle$i = object.parsedStyle.increasedLineWidthForHitTesting) === null || _object$parsedStyle$i === void 0 ? void 0 : _object$parsedStyle$i.value; // account for hitArea
3038
3317
 
3039
- if (increasedLineWidthForHitTesting) {
3040
- var _object$parsedStyle$l;
3318
+ if (increasedLineWidthForHitTesting) {
3319
+ var _object$parsedStyle$l;
3041
3320
 
3042
- if (!$hitTestingEl) {
3043
- $hitTestingEl = $el.cloneNode(); // use the entity suffix, so that `g-plugin-svg-picker` can extract
3321
+ if (!$hitTestingEl) {
3322
+ $hitTestingEl = $el.cloneNode(); // use the entity suffix, so that `g-plugin-svg-picker` can extract
3044
3323
 
3045
- $hitTestingEl.id = G_SVG_PREFIX + "_" + object.nodeName + "_hittesting_" + object.entity; // clear attributes like `filter` `font-size`
3324
+ $hitTestingEl.id = "".concat(G_SVG_PREFIX, "_").concat(object.nodeName, "_hittesting_").concat(object.entity); // clear attributes like `filter` `font-size`
3046
3325
 
3047
- ['filter'].forEach(function (attribute) {
3048
- $hitTestingEl.removeAttribute(attribute);
3049
- }); // hitArea should be 'transparent' but not 'none'
3326
+ ['filter'].forEach(function (attribute) {
3327
+ $hitTestingEl.removeAttribute(attribute);
3328
+ }); // hitArea should be 'transparent' but not 'none'
3050
3329
 
3051
- var hasFill = $el.getAttribute('fill') !== 'none';
3052
- $hitTestingEl.setAttribute('fill', hasFill ? 'transparent' : 'none');
3053
- $hitTestingEl.setAttribute('stroke', 'transparent');
3054
- $groupEl.appendChild($hitTestingEl);
3055
- svgElement.$hitTestingEl = $hitTestingEl;
3056
- } // increase interactive line width
3330
+ var hasFill = $el.getAttribute('fill') !== 'none';
3331
+ $hitTestingEl.setAttribute('fill', hasFill ? 'transparent' : 'none');
3332
+ $hitTestingEl.setAttribute('stroke', 'transparent');
3333
+ $groupEl.appendChild($hitTestingEl);
3334
+ svgElement.$hitTestingEl = $hitTestingEl;
3335
+ } // increase interactive line width
3057
3336
 
3058
3337
 
3059
- $hitTestingEl.setAttribute('stroke-width', "" + (increasedLineWidthForHitTesting + ((_object$parsedStyle$l = object.parsedStyle.lineWidth) === null || _object$parsedStyle$l === void 0 ? void 0 : _object$parsedStyle$l.value)));
3060
- } else {
3061
- if ($hitTestingEl) {
3062
- $groupEl.removeChild($hitTestingEl);
3063
- svgElement.$hitTestingEl = null;
3338
+ $hitTestingEl.setAttribute('stroke-width', "".concat(increasedLineWidthForHitTesting + ((_object$parsedStyle$l = object.parsedStyle.lineWidth) === null || _object$parsedStyle$l === void 0 ? void 0 : _object$parsedStyle$l.value)));
3339
+ } else {
3340
+ if ($hitTestingEl) {
3341
+ $groupEl.removeChild($hitTestingEl);
3342
+ svgElement.$hitTestingEl = null;
3343
+ }
3064
3344
  }
3065
3345
  }
3066
- };
3346
+ }, {
3347
+ key: "createOrUpdateInnerHTML",
3348
+ value: function createOrUpdateInnerHTML($el, usedValue) {
3349
+ var $div = document.createElement('div');
3067
3350
 
3068
- _proto.createOrUpdateInnerHTML = function createOrUpdateInnerHTML($el, usedValue) {
3069
- var $div = document.createElement('div');
3351
+ if (typeof usedValue === 'string') {
3352
+ $div.innerHTML = usedValue;
3353
+ } else {
3354
+ $div.appendChild(usedValue);
3355
+ }
3070
3356
 
3071
- if (typeof usedValue === 'string') {
3072
- $div.innerHTML = usedValue;
3073
- } else {
3074
- $div.appendChild(usedValue);
3357
+ $el.innerHTML = '';
3358
+ $el.appendChild($div);
3075
3359
  }
3360
+ }, {
3361
+ key: "createOrUpdateClipPath",
3362
+ value: function createOrUpdateClipPath(clipPath, $groupEl) {
3363
+ if (clipPath) {
3364
+ var _clipPath$elementSVG;
3076
3365
 
3077
- $el.innerHTML = '';
3078
- $el.appendChild($div);
3079
- };
3080
-
3081
- _proto.createOrUpdateClipPath = function createOrUpdateClipPath(clipPath, $groupEl) {
3082
- if (clipPath) {
3083
- var _clipPath$elementSVG;
3084
-
3085
- var clipPathId = CLIP_PATH_PREFIX + clipPath.entity;
3086
- var existed = this.$def.querySelector("#" + clipPathId);
3366
+ var clipPathId = CLIP_PATH_PREFIX + clipPath.entity;
3367
+ var existed = this.$def.querySelector("#".concat(clipPathId));
3087
3368
 
3088
- if (!existed) {
3089
- // create <clipPath> dom node, append it to <defs>
3090
- var $clipPath = createSVGElement('clipPath');
3091
- $clipPath.id = clipPathId;
3092
- this.$def.appendChild($clipPath); // <clipPath><circle /></clipPath>
3369
+ if (!existed) {
3370
+ // create <clipPath> dom node, append it to <defs>
3371
+ var $clipPath = createSVGElement('clipPath');
3372
+ $clipPath.id = clipPathId;
3373
+ this.$def.appendChild($clipPath); // <clipPath><circle /></clipPath>
3093
3374
 
3094
- this.createSVGDom(clipPath, $clipPath, true); // @ts-ignore
3375
+ this.createSVGDom(clipPath, $clipPath, true); // @ts-ignore
3095
3376
 
3096
- clipPath.elementSVG.$groupEl = $clipPath;
3097
- } // @ts-ignore
3377
+ clipPath.elementSVG.$groupEl = $clipPath;
3378
+ } // @ts-ignore
3098
3379
 
3099
3380
 
3100
- var $clipPathGroupEl = (_clipPath$elementSVG = clipPath.elementSVG) === null || _clipPath$elementSVG === void 0 ? void 0 : _clipPath$elementSVG.$groupEl;
3381
+ var $clipPathGroupEl = (_clipPath$elementSVG = clipPath.elementSVG) === null || _clipPath$elementSVG === void 0 ? void 0 : _clipPath$elementSVG.$groupEl;
3101
3382
 
3102
- if ($clipPathGroupEl) {
3103
- // apply local RTS transformation to <group> wrapper
3104
- this.applyTransform($clipPathGroupEl, clipPath.getLocalTransform());
3105
- } // apply attributes
3383
+ if ($clipPathGroupEl) {
3384
+ // apply local RTS transformation to <group> wrapper
3385
+ this.applyTransform($clipPathGroupEl, clipPath.getLocalTransform());
3386
+ } // apply attributes
3106
3387
 
3107
3388
 
3108
- this.applyAttributes(clipPath); // apply clipPath to $group
3109
- // @see https://github.com/antvis/g/issues/961
3389
+ this.applyAttributes(clipPath); // apply clipPath to $group
3390
+ // @see https://github.com/antvis/g/issues/961
3110
3391
 
3111
- $groupEl.setAttribute('clip-path', "url(#" + clipPathId + ")");
3112
- } else {
3113
- // remove clip path
3114
- $groupEl.removeAttribute('clip-path');
3392
+ $groupEl.setAttribute('clip-path', "url(#".concat(clipPathId, ")"));
3393
+ } else {
3394
+ // remove clip path
3395
+ $groupEl.removeAttribute('clip-path');
3396
+ }
3115
3397
  }
3116
- }
3117
- /**
3118
- * the origin is bounding box's top left corner
3119
- */
3120
- ;
3398
+ /**
3399
+ * the origin is bounding box's top left corner
3400
+ */
3121
3401
 
3122
- _proto.updateAnchorWithTransform = function updateAnchorWithTransform(object) {
3123
- var _object$elementSVG5, _object$elementSVG6;
3402
+ }, {
3403
+ key: "updateAnchorWithTransform",
3404
+ value: function updateAnchorWithTransform(object) {
3405
+ var _object$elementSVG5, _object$elementSVG6;
3124
3406
 
3125
- var bounds = object.getGeometryBounds();
3126
- var width = bounds && bounds.halfExtents[0] * 2 || 0;
3127
- var height = bounds && bounds.halfExtents[1] * 2 || 0;
3407
+ var bounds = object.getGeometryBounds();
3408
+ var width = bounds && bounds.halfExtents[0] * 2 || 0;
3409
+ var height = bounds && bounds.halfExtents[1] * 2 || 0;
3128
3410
 
3129
- var _ref2 = object.parsedStyle || {},
3130
- anchor = _ref2.anchor; // @ts-ignore
3411
+ var _ref2 = object.parsedStyle || {},
3412
+ anchor = _ref2.anchor; // @ts-ignore
3131
3413
 
3132
3414
 
3133
- [(_object$elementSVG5 = object.elementSVG) === null || _object$elementSVG5 === void 0 ? void 0 : _object$elementSVG5.$el, (_object$elementSVG6 = object.elementSVG) === null || _object$elementSVG6 === void 0 ? void 0 : _object$elementSVG6.$hitTestingEl].forEach(function ($el) {
3134
- if ($el) {
3135
- // apply anchor to element's `transform` property
3136
- $el.setAttribute('transform', // can't use percent unit like translate(-50%, -50%)
3137
- // @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/transform#translate
3138
- "translate(-" + anchor[0].value * width + ",-" + anchor[1].value * height + ")");
3139
-
3140
- if (object.nodeName === g.Shape.CIRCLE || object.nodeName === g.Shape.ELLIPSE) {
3141
- $el.setAttribute('cx', "" + width / 2);
3142
- $el.setAttribute('cy', "" + height / 2);
3415
+ [(_object$elementSVG5 = object.elementSVG) === null || _object$elementSVG5 === void 0 ? void 0 : _object$elementSVG5.$el, (_object$elementSVG6 = object.elementSVG) === null || _object$elementSVG6 === void 0 ? void 0 : _object$elementSVG6.$hitTestingEl].forEach(function ($el) {
3416
+ if ($el) {
3417
+ // apply anchor to element's `transform` property
3418
+ $el.setAttribute('transform', // can't use percent unit like translate(-50%, -50%)
3419
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/transform#translate
3420
+ "translate(-".concat(anchor[0].value * width, ",-").concat(anchor[1].value * height, ")"));
3421
+
3422
+ if (object.nodeName === g.Shape.CIRCLE || object.nodeName === g.Shape.ELLIPSE) {
3423
+ $el.setAttribute('cx', "".concat(width / 2));
3424
+ $el.setAttribute('cy', "".concat(height / 2));
3425
+ }
3143
3426
  }
3144
- }
3145
- });
3146
- };
3427
+ });
3428
+ }
3429
+ }]);
3147
3430
 
3148
3431
  return SVGRendererPlugin;
3149
3432
  }(), _class$1.tag = 'SVGRenderer', _class$1);
@@ -3201,18 +3484,22 @@
3201
3484
 
3202
3485
  var Plugin$1 = /*#__PURE__*/function () {
3203
3486
  function Plugin() {
3487
+ _classCallCheck$2(this, Plugin);
3488
+
3204
3489
  this.name = 'svg-renderer';
3205
3490
  }
3206
3491
 
3207
- var _proto = Plugin.prototype;
3208
-
3209
- _proto.init = function init(container) {
3210
- container.load(containerModule$1, true);
3211
- };
3212
-
3213
- _proto.destroy = function destroy(container) {
3214
- container.unload(containerModule$1);
3215
- };
3492
+ _createClass$2(Plugin, [{
3493
+ key: "init",
3494
+ value: function init(container) {
3495
+ container.load(containerModule$1, true);
3496
+ }
3497
+ }, {
3498
+ key: "destroy",
3499
+ value: function destroy(container) {
3500
+ container.unload(containerModule$1);
3501
+ }
3502
+ }]);
3216
3503
 
3217
3504
  return Plugin;
3218
3505
  }();
@@ -3355,7 +3642,7 @@
3355
3642
  if ("throw" !== record.type) {
3356
3643
  var result = record.arg,
3357
3644
  value = result.value;
3358
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
3645
+ return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
3359
3646
  invoke("next", value, resolve, reject);
3360
3647
  }, function (err) {
3361
3648
  invoke("throw", err, resolve, reject);
@@ -3616,16 +3903,41 @@
3616
3903
  };
3617
3904
  }
3618
3905
 
3619
- function _unsupportedIterableToArray(o, minLen) {
3906
+ function _classCallCheck$3(instance, Constructor) {
3907
+ if (!(instance instanceof Constructor)) {
3908
+ throw new TypeError("Cannot call a class as a function");
3909
+ }
3910
+ }
3911
+
3912
+ function _defineProperties$3(target, props) {
3913
+ for (var i = 0; i < props.length; i++) {
3914
+ var descriptor = props[i];
3915
+ descriptor.enumerable = descriptor.enumerable || false;
3916
+ descriptor.configurable = true;
3917
+ if ("value" in descriptor) descriptor.writable = true;
3918
+ Object.defineProperty(target, descriptor.key, descriptor);
3919
+ }
3920
+ }
3921
+
3922
+ function _createClass$3(Constructor, protoProps, staticProps) {
3923
+ if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
3924
+ if (staticProps) _defineProperties$3(Constructor, staticProps);
3925
+ Object.defineProperty(Constructor, "prototype", {
3926
+ writable: false
3927
+ });
3928
+ return Constructor;
3929
+ }
3930
+
3931
+ function _unsupportedIterableToArray$1(o, minLen) {
3620
3932
  if (!o) return;
3621
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
3933
+ if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
3622
3934
  var n = Object.prototype.toString.call(o).slice(8, -1);
3623
3935
  if (n === "Object" && o.constructor) n = o.constructor.name;
3624
3936
  if (n === "Map" || n === "Set") return Array.from(o);
3625
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
3937
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
3626
3938
  }
3627
3939
 
3628
- function _arrayLikeToArray(arr, len) {
3940
+ function _arrayLikeToArray$1(arr, len) {
3629
3941
  if (len == null || len > arr.length) len = arr.length;
3630
3942
 
3631
3943
  for (var i = 0, arr2 = new Array(len); i < len; i++) {
@@ -3635,25 +3947,61 @@
3635
3947
  return arr2;
3636
3948
  }
3637
3949
 
3638
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
3950
+ function _createForOfIteratorHelper(o, allowArrayLike) {
3639
3951
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
3640
- if (it) return (it = it.call(o)).next.bind(it);
3641
3952
 
3642
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
3643
- if (it) o = it;
3644
- var i = 0;
3645
- return function () {
3646
- if (i >= o.length) return {
3647
- done: true
3648
- };
3953
+ if (!it) {
3954
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") {
3955
+ if (it) o = it;
3956
+ var i = 0;
3957
+
3958
+ var F = function F() {};
3959
+
3649
3960
  return {
3650
- done: false,
3651
- value: o[i++]
3961
+ s: F,
3962
+ n: function n() {
3963
+ if (i >= o.length) return {
3964
+ done: true
3965
+ };
3966
+ return {
3967
+ done: false,
3968
+ value: o[i++]
3969
+ };
3970
+ },
3971
+ e: function e(_e) {
3972
+ throw _e;
3973
+ },
3974
+ f: F
3652
3975
  };
3653
- };
3976
+ }
3977
+
3978
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3654
3979
  }
3655
3980
 
3656
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3981
+ var normalCompletion = true,
3982
+ didErr = false,
3983
+ err;
3984
+ return {
3985
+ s: function s() {
3986
+ it = it.call(o);
3987
+ },
3988
+ n: function n() {
3989
+ var step = it.next();
3990
+ normalCompletion = step.done;
3991
+ return step;
3992
+ },
3993
+ e: function e(_e2) {
3994
+ didErr = true;
3995
+ err = _e2;
3996
+ },
3997
+ f: function f() {
3998
+ try {
3999
+ if (!normalCompletion && it.return != null) it.return();
4000
+ } finally {
4001
+ if (didErr) throw err;
4002
+ }
4003
+ }
4004
+ };
3657
4005
  }
3658
4006
 
3659
4007
  var _class$2;
@@ -3668,92 +4016,115 @@
3668
4016
 
3669
4017
  var SVGPickerPlugin = SVGPickerPlugin_1 = (_class$2 = /*#__PURE__*/function () {
3670
4018
  function SVGPickerPlugin() {
4019
+ _classCallCheck$3(this, SVGPickerPlugin);
4020
+
3671
4021
  this.sceneGraphService = void 0;
3672
4022
  this.displayObjectPool = void 0;
3673
4023
  }
3674
4024
 
3675
- var _proto = SVGPickerPlugin.prototype;
4025
+ _createClass$3(SVGPickerPlugin, [{
4026
+ key: "apply",
4027
+ value: function apply(renderingService) {
4028
+ var _this = this;
3676
4029
 
3677
- _proto.apply = function apply(renderingService) {
3678
- var _this = this;
4030
+ renderingService.hooks.pick.tapPromise(SVGPickerPlugin_1.tag, /*#__PURE__*/function () {
4031
+ var _ref = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee(result) {
4032
+ var topmost, _result$position, clientX, clientY, targets, _iterator, _step, element, id, index, target;
3679
4033
 
3680
- renderingService.hooks.pick.tapPromise(SVGPickerPlugin_1.tag, /*#__PURE__*/function () {
3681
- var _ref = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee(result) {
3682
- var topmost, _result$position, clientX, clientY, targets, _iterator, _step, element, id, index, target;
4034
+ return _regeneratorRuntime$2().wrap(function _callee$(_context) {
4035
+ while (1) {
4036
+ switch (_context.prev = _context.next) {
4037
+ case 0:
4038
+ topmost = result.topmost, _result$position = result.position, clientX = _result$position.clientX, clientY = _result$position.clientY;
4039
+ _context.prev = 1;
4040
+ targets = []; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
3683
4041
 
3684
- return _regeneratorRuntime$2().wrap(function _callee$(_context) {
3685
- while (1) {
3686
- switch (_context.prev = _context.next) {
3687
- case 0:
3688
- topmost = result.topmost, _result$position = result.position, clientX = _result$position.clientX, clientY = _result$position.clientY;
3689
- _context.prev = 1;
3690
- targets = []; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
4042
+ _iterator = _createForOfIteratorHelper(document.elementsFromPoint(clientX, clientY));
4043
+ _context.prev = 4;
3691
4044
 
3692
- _iterator = _createForOfIteratorHelperLoose(document.elementsFromPoint(clientX, clientY));
4045
+ _iterator.s();
3693
4046
 
3694
- case 4:
3695
- if ((_step = _iterator()).done) {
3696
- _context.next = 17;
3697
- break;
3698
- }
4047
+ case 6:
4048
+ if ((_step = _iterator.n()).done) {
4049
+ _context.next = 19;
4050
+ break;
4051
+ }
3699
4052
 
3700
- element = _step.value; // eg. g_svg_circle_345
4053
+ element = _step.value; // eg. g_svg_circle_345
3701
4054
 
3702
- id = element && element.getAttribute('id');
4055
+ id = element && element.getAttribute('id');
3703
4056
 
3704
- if (!(id && id.startsWith(G_SVG_PREFIX))) {
3705
- _context.next = 15;
3706
- break;
3707
- }
4057
+ if (!(id && id.startsWith(G_SVG_PREFIX))) {
4058
+ _context.next = 17;
4059
+ break;
4060
+ }
3708
4061
 
3709
- index = id.lastIndexOf('_');
3710
- target = _this.displayObjectPool.getByEntity(Number(id.substring(index + 1))); // don't need to account for `visibility` since DOM API already does
4062
+ index = id.lastIndexOf('_');
4063
+ target = _this.displayObjectPool.getByEntity(Number(id.substring(index + 1))); // don't need to account for `visibility` since DOM API already does
3711
4064
 
3712
- if (!(target && target.isInteractive())) {
3713
- _context.next = 15;
3714
- break;
3715
- }
4065
+ if (!(target && target.isInteractive())) {
4066
+ _context.next = 17;
4067
+ break;
4068
+ }
4069
+
4070
+ targets.push(target);
3716
4071
 
3717
- targets.push(target);
4072
+ if (!topmost) {
4073
+ _context.next = 17;
4074
+ break;
4075
+ }
3718
4076
 
3719
- if (!topmost) {
3720
- _context.next = 15;
4077
+ result.picked = targets;
4078
+ return _context.abrupt("return", result);
4079
+
4080
+ case 17:
4081
+ _context.next = 6;
3721
4082
  break;
3722
- }
3723
4083
 
3724
- result.picked = targets;
3725
- return _context.abrupt("return", result);
4084
+ case 19:
4085
+ _context.next = 24;
4086
+ break;
3726
4087
 
3727
- case 15:
3728
- _context.next = 4;
3729
- break;
4088
+ case 21:
4089
+ _context.prev = 21;
4090
+ _context.t0 = _context["catch"](4);
3730
4091
 
3731
- case 17:
3732
- result.picked = targets;
3733
- _context.next = 23;
3734
- break;
4092
+ _iterator.e(_context.t0);
3735
4093
 
3736
- case 20:
3737
- _context.prev = 20;
3738
- _context.t0 = _context["catch"](1);
3739
- result.picked = [];
4094
+ case 24:
4095
+ _context.prev = 24;
3740
4096
 
3741
- case 23:
3742
- return _context.abrupt("return", result);
4097
+ _iterator.f();
3743
4098
 
3744
- case 24:
3745
- case "end":
3746
- return _context.stop();
4099
+ return _context.finish(24);
4100
+
4101
+ case 27:
4102
+ result.picked = targets;
4103
+ _context.next = 33;
4104
+ break;
4105
+
4106
+ case 30:
4107
+ _context.prev = 30;
4108
+ _context.t1 = _context["catch"](1);
4109
+ result.picked = [];
4110
+
4111
+ case 33:
4112
+ return _context.abrupt("return", result);
4113
+
4114
+ case 34:
4115
+ case "end":
4116
+ return _context.stop();
4117
+ }
3747
4118
  }
3748
- }
3749
- }, _callee, null, [[1, 20]]);
3750
- }));
4119
+ }, _callee, null, [[1, 30], [4, 21, 24, 27]]);
4120
+ }));
3751
4121
 
3752
- return function (_x) {
3753
- return _ref.apply(this, arguments);
3754
- };
3755
- }());
3756
- };
4122
+ return function (_x) {
4123
+ return _ref.apply(this, arguments);
4124
+ };
4125
+ }());
4126
+ }
4127
+ }]);
3757
4128
 
3758
4129
  return SVGPickerPlugin;
3759
4130
  }(), _class$2.tag = 'SVGPicker', _class$2);
@@ -3771,18 +4142,22 @@
3771
4142
 
3772
4143
  var Plugin$2 = /*#__PURE__*/function () {
3773
4144
  function Plugin() {
4145
+ _classCallCheck$3(this, Plugin);
4146
+
3774
4147
  this.name = 'svg-picker';
3775
4148
  }
3776
4149
 
3777
- var _proto = Plugin.prototype;
3778
-
3779
- _proto.init = function init(container) {
3780
- container.load(containerModule$2, true);
3781
- };
3782
-
3783
- _proto.destroy = function destroy(container) {
3784
- container.unload(containerModule$2);
3785
- };
4150
+ _createClass$3(Plugin, [{
4151
+ key: "init",
4152
+ value: function init(container) {
4153
+ container.load(containerModule$2, true);
4154
+ }
4155
+ }, {
4156
+ key: "destroy",
4157
+ value: function destroy(container) {
4158
+ container.unload(containerModule$2);
4159
+ }
4160
+ }]);
3786
4161
 
3787
4162
  return Plugin;
3788
4163
  }();
@@ -3794,74 +4169,84 @@
3794
4169
 
3795
4170
  var SVGContextService = /*#__PURE__*/function () {
3796
4171
  function SVGContextService() {
4172
+ _classCallCheck(this, SVGContextService);
4173
+
3797
4174
  this.$container = void 0;
3798
4175
  this.$namespace = void 0;
3799
4176
  this.dpr = void 0;
3800
4177
  this.canvasConfig = void 0;
3801
4178
  }
3802
4179
 
3803
- var _proto = SVGContextService.prototype;
4180
+ _createClass(SVGContextService, [{
4181
+ key: "init",
4182
+ value: function init() {
4183
+ var container = this.canvasConfig.container; // create container
3804
4184
 
3805
- _proto.init = function init() {
3806
- var container = this.canvasConfig.container; // create container
4185
+ this.$container = g.isString(container) ? document.getElementById(container) : container;
3807
4186
 
3808
- this.$container = g.isString(container) ? document.getElementById(container) : container;
4187
+ if (this.$container) {
4188
+ if (!this.$container.style.position) {
4189
+ this.$container.style.position = 'relative';
4190
+ }
3809
4191
 
3810
- if (this.$container) {
3811
- if (!this.$container.style.position) {
3812
- this.$container.style.position = 'relative';
4192
+ var $namespace = createSVGElement('svg');
4193
+ $namespace.setAttribute('width', "".concat(this.canvasConfig.width));
4194
+ $namespace.setAttribute('height', "".concat(this.canvasConfig.height));
4195
+ this.$container.appendChild($namespace);
4196
+ this.$namespace = $namespace;
3813
4197
  }
3814
4198
 
3815
- var $namespace = createSVGElement('svg');
3816
- $namespace.setAttribute('width', "" + this.canvasConfig.width);
3817
- $namespace.setAttribute('height', "" + this.canvasConfig.height);
3818
- this.$container.appendChild($namespace);
3819
- this.$namespace = $namespace;
3820
- }
3821
-
3822
- var dpr = window.devicePixelRatio || 1;
3823
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
3824
- this.dpr = dpr;
3825
- } // @ts-ignore
3826
- ;
3827
-
3828
- _proto.getDomElement = function getDomElement() {
3829
- return this.$namespace;
3830
- };
3831
-
3832
- _proto.getContext = function getContext() {
3833
- return this.$namespace;
3834
- };
3835
-
3836
- _proto.getDPR = function getDPR() {
3837
- return this.dpr;
3838
- };
3839
-
3840
- _proto.getBoundingClientRect = function getBoundingClientRect() {
3841
- var _this$$namespace;
3842
-
3843
- return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
3844
- };
4199
+ var dpr = window.devicePixelRatio || 1;
4200
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
4201
+ this.dpr = dpr;
4202
+ } // @ts-ignore
3845
4203
 
3846
- _proto.destroy = function destroy() {
3847
- // destroy context
3848
- if (this.$container && this.$namespace && this.$namespace.parentNode) {
3849
- this.$container.removeChild(this.$namespace);
4204
+ }, {
4205
+ key: "getDomElement",
4206
+ value: function getDomElement() {
4207
+ return this.$namespace;
3850
4208
  }
3851
- };
3852
-
3853
- _proto.resize = function resize(width, height) {
3854
- if (this.$namespace) {
3855
- this.$namespace.setAttribute('width', "" + width);
3856
- this.$namespace.setAttribute('height', "" + height);
4209
+ }, {
4210
+ key: "getContext",
4211
+ value: function getContext() {
4212
+ return this.$namespace;
3857
4213
  }
3858
- };
4214
+ }, {
4215
+ key: "getDPR",
4216
+ value: function getDPR() {
4217
+ return this.dpr;
4218
+ }
4219
+ }, {
4220
+ key: "getBoundingClientRect",
4221
+ value: function getBoundingClientRect() {
4222
+ var _this$$namespace;
3859
4223
 
3860
- _proto.applyCursorStyle = function applyCursorStyle(cursor) {
3861
- if (this.$container) {
3862
- this.$container.style.cursor = cursor;
4224
+ return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
3863
4225
  }
3864
- };
4226
+ }, {
4227
+ key: "destroy",
4228
+ value: function destroy() {
4229
+ // destroy context
4230
+ if (this.$container && this.$namespace && this.$namespace.parentNode) {
4231
+ this.$container.removeChild(this.$namespace);
4232
+ }
4233
+ }
4234
+ }, {
4235
+ key: "resize",
4236
+ value: function resize(width, height) {
4237
+ if (this.$namespace) {
4238
+ this.$namespace.setAttribute('width', "".concat(width));
4239
+ this.$namespace.setAttribute('height', "".concat(height));
4240
+ }
4241
+ }
4242
+ }, {
4243
+ key: "applyCursorStyle",
4244
+ value: function applyCursorStyle(cursor) {
4245
+ if (this.$container) {
4246
+ this.$container.style.cursor = cursor;
4247
+ }
4248
+ }
4249
+ }]);
3865
4250
 
3866
4251
  return SVGContextService;
3867
4252
  }();
@@ -3880,29 +4265,37 @@
3880
4265
  });
3881
4266
  var ContextRegisterPlugin = /*#__PURE__*/function () {
3882
4267
  function ContextRegisterPlugin() {
4268
+ _classCallCheck(this, ContextRegisterPlugin);
4269
+
3883
4270
  this.name = 'svg-context-register';
3884
4271
  }
3885
4272
 
3886
- var _proto = ContextRegisterPlugin.prototype;
3887
-
3888
- _proto.init = function init(container) {
3889
- container.load(containerModule$3, true);
3890
- };
3891
-
3892
- _proto.destroy = function destroy(container) {
3893
- container.unload(containerModule$3);
3894
- };
4273
+ _createClass(ContextRegisterPlugin, [{
4274
+ key: "init",
4275
+ value: function init(container) {
4276
+ container.load(containerModule$3, true);
4277
+ }
4278
+ }, {
4279
+ key: "destroy",
4280
+ value: function destroy(container) {
4281
+ container.unload(containerModule$3);
4282
+ }
4283
+ }]);
3895
4284
 
3896
4285
  return ContextRegisterPlugin;
3897
4286
  }();
3898
4287
 
3899
4288
  var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
3900
- _inheritsLoose(Renderer, _AbstractRenderer);
4289
+ _inherits(Renderer, _AbstractRenderer);
4290
+
4291
+ var _super = _createSuper(Renderer);
3901
4292
 
3902
4293
  function Renderer(config) {
3903
4294
  var _this;
3904
4295
 
3905
- _this = _AbstractRenderer.call(this, config) || this;
4296
+ _classCallCheck(this, Renderer);
4297
+
4298
+ _this = _super.call(this, config);
3906
4299
 
3907
4300
  _this.registerPlugin(new ContextRegisterPlugin());
3908
4301
 
@@ -3915,7 +4308,7 @@
3915
4308
  return _this;
3916
4309
  }
3917
4310
 
3918
- return Renderer;
4311
+ return _createClass(Renderer);
3919
4312
  }(g.AbstractRenderer);
3920
4313
 
3921
4314
  exports.DomInteraction = index_esm;