@antv/g-svg 1.1.3 → 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,165 +535,184 @@
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;
438
- var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
439
566
  /**
440
567
  * listen to mouse/touch/pointer events on DOM wrapper, trigger pointer events
441
568
  */
442
569
 
443
570
  var DOMInteractionPlugin = DOMInteractionPlugin_1 = (_class = /*#__PURE__*/function () {
444
571
  function DOMInteractionPlugin() {
572
+ _classCallCheck$1(this, DOMInteractionPlugin);
573
+
445
574
  this.contextService = void 0;
446
575
  this.renderingContext = void 0;
447
576
  }
448
577
 
449
- var _proto = DOMInteractionPlugin.prototype;
578
+ _createClass$1(DOMInteractionPlugin, [{
579
+ key: "apply",
580
+ value: function apply(renderingService) {
581
+ var _this = this;
450
582
 
451
- _proto.apply = function apply(renderingService) {
452
- var _this = this;
583
+ var canvas = this.renderingContext.root.ownerDocument.defaultView; // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
453
584
 
454
- var canvas = this.renderingContext.root.ownerDocument.defaultView;
455
- var SUPPORT_ONLY_TOUCH = canvas.supportTouchEvent && MOBILE_REGEX.test(navigator.userAgent);
456
-
457
- var onPointerMove = function onPointerMove(ev) {
458
- renderingService.hooks.pointerMove.call(ev);
459
- };
585
+ var onPointerMove = function onPointerMove(ev) {
586
+ renderingService.hooks.pointerMove.call(ev);
587
+ };
460
588
 
461
- var onPointerUp = function onPointerUp(ev) {
462
- renderingService.hooks.pointerUp.call(ev);
463
- };
589
+ var onPointerUp = function onPointerUp(ev) {
590
+ renderingService.hooks.pointerUp.call(ev);
591
+ };
464
592
 
465
- var onPointerDown = function onPointerDown(ev) {
466
- renderingService.hooks.pointerDown.call(ev);
467
- };
593
+ var onPointerDown = function onPointerDown(ev) {
594
+ renderingService.hooks.pointerDown.call(ev);
595
+ };
468
596
 
469
- var onPointerOver = function onPointerOver(ev) {
470
- renderingService.hooks.pointerOver.call(ev);
471
- };
597
+ var onPointerOver = function onPointerOver(ev) {
598
+ renderingService.hooks.pointerOver.call(ev);
599
+ };
472
600
 
473
- var onPointerOut = function onPointerOut(ev) {
474
- renderingService.hooks.pointerOut.call(ev);
475
- };
601
+ var onPointerOut = function onPointerOut(ev) {
602
+ renderingService.hooks.pointerOut.call(ev);
603
+ };
476
604
 
477
- var onPointerCancel = function onPointerCancel(ev) {
478
- renderingService.hooks.pointerCancel.call(ev);
479
- };
605
+ var onPointerCancel = function onPointerCancel(ev) {
606
+ renderingService.hooks.pointerCancel.call(ev);
607
+ };
480
608
 
481
- var onPointerWheel = function onPointerWheel(ev) {
482
- renderingService.hooks.pointerWheel.call(ev);
483
- };
609
+ var onPointerWheel = function onPointerWheel(ev) {
610
+ renderingService.hooks.pointerWheel.call(ev);
611
+ };
484
612
 
485
- var addPointerEventListener = function addPointerEventListener($el) {
486
- globalThis.document.addEventListener('pointermove', onPointerMove, true);
487
- $el.addEventListener('pointerdown', onPointerDown, true);
488
- $el.addEventListener('pointerleave', onPointerOut, true);
489
- $el.addEventListener('pointerover', onPointerOver, true);
490
- globalThis.addEventListener('pointerup', onPointerUp, true);
491
- };
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
+ };
492
620
 
493
- var addTouchEventListener = function addTouchEventListener($el) {
494
- $el.addEventListener('touchstart', onPointerDown, true);
495
- $el.addEventListener('touchend', onPointerUp, true);
496
- $el.addEventListener('touchmove', onPointerMove, true);
497
- $el.addEventListener('touchcancel', onPointerCancel, true);
498
- };
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
+ };
499
627
 
500
- var addMouseEventListener = function addMouseEventListener($el) {
501
- globalThis.document.addEventListener('mousemove', onPointerMove, true);
502
- $el.addEventListener('mousedown', onPointerDown, true);
503
- $el.addEventListener('mouseout', onPointerOut, true);
504
- $el.addEventListener('mouseover', onPointerOver, true);
505
- globalThis.addEventListener('mouseup', onPointerUp, true);
506
- };
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
+ };
507
635
 
508
- var removePointerEventListener = function removePointerEventListener($el) {
509
- globalThis.document.removeEventListener('pointermove', onPointerMove, true);
510
- $el.removeEventListener('pointerdown', onPointerDown, true);
511
- $el.removeEventListener('pointerleave', onPointerOut, true);
512
- $el.removeEventListener('pointerover', onPointerOver, true);
513
- globalThis.removeEventListener('pointerup', onPointerUp, true);
514
- };
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
+ };
515
643
 
516
- var removeTouchEventListener = function removeTouchEventListener($el) {
517
- $el.removeEventListener('touchstart', onPointerDown, true);
518
- $el.removeEventListener('touchend', onPointerUp, true);
519
- $el.removeEventListener('touchmove', onPointerMove, true);
520
- };
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
+ };
521
649
 
522
- var removeMouseEventListener = function removeMouseEventListener($el) {
523
- globalThis.document.removeEventListener('mousemove', onPointerMove, true);
524
- $el.removeEventListener('mousedown', onPointerDown, true);
525
- $el.removeEventListener('mouseout', onPointerOut, true);
526
- $el.removeEventListener('mouseover', onPointerOver, true);
527
- globalThis.removeEventListener('mouseup', onPointerUp, true);
528
- };
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
+ };
529
657
 
530
- renderingService.hooks.init.tapPromise(DOMInteractionPlugin_1.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
531
- var $el;
532
- return _regeneratorRuntime().wrap(function _callee$(_context) {
533
- while (1) {
534
- switch (_context.prev = _context.next) {
535
- case 0:
536
- $el = _this.contextService.getDomElement();
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
537
665
 
538
- if (canvas.supportPointerEvent) {
539
- addPointerEventListener($el);
540
- }
666
+ if (globalThis.navigator.msPointerEnabled) {
667
+ // @ts-ignore
668
+ $el.style.msContentZooming = 'none'; // @ts-ignore
541
669
 
542
- if (SUPPORT_ONLY_TOUCH) {
543
- addTouchEventListener($el);
544
- } else if (!canvas.supportTouchEvent) {
545
- if (!canvas.supportPointerEvent) {
546
- addMouseEventListener($el);
670
+ $el.style.msTouchAction = 'none';
671
+ } else if (canvas.supportsPointerEvents) {
672
+ $el.style.touchAction = 'none';
547
673
  }
548
- } else {
549
- addTouchEventListener($el);
550
674
 
551
- if (!canvas.supportPointerEvent) {
675
+ if (canvas.supportsPointerEvents) {
676
+ addPointerEventListener($el);
677
+ } else {
552
678
  addMouseEventListener($el);
553
679
  }
554
- } // use passive event listeners
555
- // @see https://zhuanlan.zhihu.com/p/24555031
556
680
 
681
+ if (canvas.supportsTouchEvents) {
682
+ addTouchEventListener($el);
683
+ } // use passive event listeners
684
+ // @see https://zhuanlan.zhihu.com/p/24555031
557
685
 
558
- $el.addEventListener('wheel', onPointerWheel, {
559
- passive: true,
560
- capture: true
561
- });
562
686
 
563
- case 4:
564
- case "end":
565
- return _context.stop();
566
- }
567
- }
568
- }, _callee);
569
- })));
570
- renderingService.hooks.destroy.tap(DOMInteractionPlugin_1.tag, function () {
571
- var $el = _this.contextService.getDomElement();
687
+ $el.addEventListener('wheel', onPointerWheel, {
688
+ passive: true,
689
+ capture: true
690
+ });
572
691
 
573
- if (canvas.supportPointerEvent) {
574
- removePointerEventListener($el);
575
- }
692
+ case 5:
693
+ case "end":
694
+ return _context.stop();
695
+ }
696
+ }
697
+ }, _callee);
698
+ })));
699
+ renderingService.hooks.destroy.tap(DOMInteractionPlugin_1.tag, function () {
700
+ var $el = _this.contextService.getDomElement();
576
701
 
577
- if (SUPPORT_ONLY_TOUCH) {
578
- removeTouchEventListener($el);
579
- } else if (!canvas.supportTouchEvent) {
580
- if (!canvas.supportPointerEvent) {
702
+ if (canvas.supportsPointerEvents) {
703
+ removePointerEventListener($el);
704
+ } else {
581
705
  removeMouseEventListener($el);
582
706
  }
583
- } else {
584
- removeTouchEventListener($el);
585
707
 
586
- if (!canvas.supportPointerEvent) {
587
- removeMouseEventListener($el);
708
+ if (canvas.supportsTouchEvents) {
709
+ removeTouchEventListener($el);
588
710
  }
589
- }
590
711
 
591
- $el.removeEventListener('wheel', onPointerWheel, true);
592
- });
593
- };
712
+ $el.removeEventListener('wheel', onPointerWheel, true);
713
+ });
714
+ }
715
+ }]);
594
716
 
595
717
  return DOMInteractionPlugin;
596
718
  }(), _class.tag = 'DOMInteraction', _class);
@@ -608,18 +730,22 @@
608
730
 
609
731
  var Plugin = /*#__PURE__*/function () {
610
732
  function Plugin() {
733
+ _classCallCheck$1(this, Plugin);
734
+
611
735
  this.name = 'dom-interaction';
612
736
  }
613
737
 
614
- var _proto = Plugin.prototype;
615
-
616
- _proto.init = function init(container) {
617
- container.load(containerModule, true);
618
- };
619
-
620
- _proto.destroy = function destroy(container) {
621
- container.unload(containerModule);
622
- };
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
+ }]);
623
749
 
624
750
  return Plugin;
625
751
  }();
@@ -835,330 +961,6 @@
835
961
  return output;
836
962
  }
837
963
 
838
- var ElementSVG = function ElementSVG() {
839
- this.$el = void 0;
840
- this.$groupEl = void 0;
841
- this.$hitTestingEl = void 0;
842
- };
843
-
844
- ElementSVG.tag = 'c-svg-element';
845
-
846
- var RectRenderer = /*#__PURE__*/function () {
847
- function RectRenderer() {
848
- this.dependencies = ['radius', 'width', 'height'];
849
- }
850
-
851
- var _proto = RectRenderer.prototype;
852
-
853
- _proto.apply = function apply($el, parsedStyle) {
854
- var radius = parsedStyle.radius,
855
- width = parsedStyle.width,
856
- height = parsedStyle.height;
857
- var hasRadius = radius && radius.some(function (r) {
858
- return r.value !== 0;
859
- });
860
- var d = '';
861
-
862
- if (!hasRadius) {
863
- d = "M 0,0 l " + width.value + ",0 l 0," + height.value + " l" + -width.value + " 0 z";
864
- } else {
865
- var _radius$map = radius.map(function (r) {
866
- return r.value;
867
- }),
868
- tlr = _radius$map[0],
869
- trr = _radius$map[1],
870
- brr = _radius$map[2],
871
- blr = _radius$map[3];
872
-
873
- 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(' ');
874
- }
875
-
876
- $el.setAttribute('d', d);
877
- };
878
-
879
- return RectRenderer;
880
- }();
881
-
882
- RectRenderer = __decorate([manaSyringe.singleton()], RectRenderer);
883
-
884
- var ImageRenderer = /*#__PURE__*/function () {
885
- function ImageRenderer() {
886
- this.dependencies = ['img', 'width', 'height'];
887
- }
888
-
889
- var _proto = ImageRenderer.prototype;
890
-
891
- _proto.apply = function apply($el, parsedStyle) {
892
- var _parsedStyle$img = parsedStyle.img,
893
- img = _parsedStyle$img === void 0 ? '' : _parsedStyle$img,
894
- width = parsedStyle.width,
895
- height = parsedStyle.height;
896
- $el.setAttribute('x', '0');
897
- $el.setAttribute('y', '0');
898
-
899
- if (g.isString(img)) {
900
- $el.setAttribute('href', img);
901
- } else if (img instanceof Image) {
902
- if (!width) {
903
- $el.setAttribute('width', "" + img.width); // TODO: set renderable.boundsDirty
904
- // this.attr('width', img.width);
905
- }
906
-
907
- if (!height) {
908
- $el.setAttribute('height', "" + img.height); // this.attr('height', img.height);
909
- }
910
-
911
- $el.setAttribute('href', img.src);
912
- } else if ( // @ts-ignore
913
- img instanceof HTMLElement && g.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
914
- $el.setAttribute('href', img.toDataURL()); // @ts-ignore
915
- } else if (img instanceof ImageData) {
916
- var canvas = document.createElement('canvas'); // @ts-ignore
917
-
918
- canvas.setAttribute('width', "" + img.width); // @ts-ignore
919
-
920
- canvas.setAttribute('height', "" + img.height);
921
- var context = canvas.getContext('2d');
922
-
923
- if (context) {
924
- context.putImageData(img, 0, 0);
925
-
926
- if (!width) {
927
- // @ts-ignore
928
- $el.setAttribute('width', "" + img.width); // this.attr('width', img.width);
929
- }
930
-
931
- if (!height) {
932
- // @ts-ignore
933
- $el.setAttribute('height', "" + img.height); // this.attr('height', img.height);
934
- }
935
-
936
- $el.setAttribute('href', canvas.toDataURL());
937
- }
938
- }
939
- };
940
-
941
- return ImageRenderer;
942
- }();
943
-
944
- ImageRenderer = __decorate([manaSyringe.singleton()], ImageRenderer);
945
-
946
- var LineRenderer = /*#__PURE__*/function () {
947
- function LineRenderer() {
948
- this.dependencies = ['x1', 'y1', 'x2', 'y2'];
949
- }
950
-
951
- var _proto = LineRenderer.prototype;
952
-
953
- _proto.apply = function apply($el, parsedStyle) {
954
- var x1 = parsedStyle.x1,
955
- y1 = parsedStyle.y1,
956
- x2 = parsedStyle.x2,
957
- y2 = parsedStyle.y2,
958
- _parsedStyle$defX = parsedStyle.defX,
959
- x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
960
- _parsedStyle$defY = parsedStyle.defY,
961
- y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY,
962
- stroke = parsedStyle.stroke;
963
- $el.setAttribute('x1', "" + (x1.value - x));
964
- $el.setAttribute('y1', "" + (y1.value - y));
965
- $el.setAttribute('x2', "" + (x2.value - x)); // fix horizontal line stroke url bug in Chrome
966
- // @see https://stackoverflow.com/questions/14680240/did-chrome-break-svg-stroke-url
967
-
968
- if (y1.value === y2.value && stroke && !(stroke instanceof g.CSSRGB)) {
969
- $el.setAttribute('y2', "" + (y2.value - y + 0.00001));
970
- } else {
971
- $el.setAttribute('y2', "" + (y2.value - y));
972
- }
973
- };
974
-
975
- return LineRenderer;
976
- }();
977
-
978
- LineRenderer = __decorate([manaSyringe.singleton()], LineRenderer);
979
-
980
- var PolylineRenderer = /*#__PURE__*/function () {
981
- function PolylineRenderer() {
982
- this.dependencies = ['points'];
983
- }
984
-
985
- var _proto = PolylineRenderer.prototype;
986
-
987
- _proto.apply = function apply($el, parsedStyle) {
988
- var points = parsedStyle.points,
989
- _parsedStyle$defX = parsedStyle.defX,
990
- x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
991
- _parsedStyle$defY = parsedStyle.defY,
992
- y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
993
-
994
- if (points && points.points && points.points.length >= 2) {
995
- $el.setAttribute('points', points.points.map(function (point) {
996
- return point[0] - x + "," + (point[1] - y);
997
- }).join(' '));
998
- }
999
- };
1000
-
1001
- return PolylineRenderer;
1002
- }();
1003
-
1004
- PolylineRenderer = __decorate([manaSyringe.singleton()], PolylineRenderer);
1005
-
1006
- function numberToLongString(x) {
1007
- return x.toFixed(6).replace('.000000', '');
1008
- }
1009
-
1010
- function convertHTML(str) {
1011
- var regex = /[&|<|>|"|']/g;
1012
- return str.replace(regex, function (match) {
1013
- if (match === '&') {
1014
- return '&amp;';
1015
- } else if (match === '<') {
1016
- return '&lt;';
1017
- } else if (match === '>') {
1018
- return '&gt;';
1019
- } else if (match === '"') {
1020
- return '&quot;';
1021
- } else {
1022
- return '&apos;';
1023
- }
1024
- });
1025
- }
1026
-
1027
- var BASELINE_MAP = {
1028
- top: 'before-edge',
1029
- middle: 'central',
1030
- bottom: 'after-edge',
1031
- alphabetic: 'alphabetic',
1032
- ideographic: 'ideographic',
1033
- hanging: 'hanging'
1034
- }; // for FireFox
1035
- // @see https://github.com/plouc/nivo/issues/164
1036
-
1037
- var BASELINE_MAP_FOR_FIREFOX = {
1038
- top: 'text-before-edge',
1039
- middle: 'central',
1040
- bottom: 'text-after-edge',
1041
- alphabetic: 'alphabetic',
1042
- ideographic: 'ideographic',
1043
- hanging: 'hanging'
1044
- };
1045
-
1046
- var TextRenderer = /*#__PURE__*/function () {
1047
- function TextRenderer() {
1048
- this.dependencies = ['text', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'wordWrap', 'wordWrapWidth', 'leading', 'textBaseline', 'textAlign', 'textTransform', 'whiteSpace', 'dx', 'dy'];
1049
- }
1050
-
1051
- var _proto = TextRenderer.prototype;
1052
-
1053
- _proto.apply = function apply($el, parsedStyle) {
1054
- var textBaseline = parsedStyle.textBaseline,
1055
- lineWidth = parsedStyle.lineWidth,
1056
- metrics = parsedStyle.metrics,
1057
- dx = parsedStyle.dx,
1058
- dy = parsedStyle.dy;
1059
- var browser = detect();
1060
-
1061
- if (browser && browser.name === 'firefox') {
1062
- // compatible with FireFox browser, ref: https://github.com/antvis/g/issues/119
1063
- $el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value] || 'alphabetic');
1064
- } else {
1065
- $el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value]);
1066
- $el.setAttribute('alignment-baseline', BASELINE_MAP[textBaseline.value]);
1067
- }
1068
-
1069
- $el.setAttribute('paint-order', 'stroke');
1070
- var lines = metrics.lines,
1071
- lineHeight = metrics.lineHeight,
1072
- height = metrics.height;
1073
- var lineNum = lines.length;
1074
- $el.setAttribute('style', "transform:translate(" + dx.toString() + ", " + dy.toString() + ");");
1075
-
1076
- if (lineNum === 1) {
1077
- $el.innerHTML = convertHTML(lines[0]);
1078
- $el.setAttribute('dx', "" + lineWidth.value / 2);
1079
- } else {
1080
- $el.innerHTML = lines.map(function (line, i) {
1081
- var dx = lineWidth.value / 2;
1082
- var dy = 0;
1083
-
1084
- if (i === 0) {
1085
- // TODO: handle other textBaseline values
1086
- if (textBaseline.value === 'middle') {
1087
- dy = lineHeight / 2 - height / 2;
1088
- } else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
1089
- dy = 0;
1090
- } else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
1091
- dy = -lineHeight * (lineNum - 1);
1092
- }
1093
- } else {
1094
- dy = lineHeight;
1095
- }
1096
-
1097
- return "<tspan x=\"0\" dx=\"" + dx + "\" dy=\"" + dy + "\">" + convertHTML(line) + "</tspan>";
1098
- }).join('');
1099
- }
1100
- };
1101
-
1102
- return TextRenderer;
1103
- }();
1104
-
1105
- TextRenderer = __decorate([manaSyringe.singleton()], TextRenderer);
1106
-
1107
- var PathRenderer = /*#__PURE__*/function () {
1108
- function PathRenderer() {
1109
- this.dependencies = ['path'];
1110
- }
1111
-
1112
- var _proto = PathRenderer.prototype;
1113
-
1114
- _proto.apply = function apply($el, parsedStyle) {
1115
- var path = parsedStyle.path,
1116
- _parsedStyle$defX = parsedStyle.defX,
1117
- x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
1118
- _parsedStyle$defY = parsedStyle.defY,
1119
- y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
1120
- $el.setAttribute('d', this.formatPath(path.absolutePath, x, y));
1121
- };
1122
-
1123
- _proto.formatPath = function formatPath(value, x, y) {
1124
- var newValue = value.map(function (params) {
1125
- var command = params[0];
1126
-
1127
- switch (command) {
1128
- case 'M':
1129
- return "M " + (params[1] - x) + "," + (params[2] - y);
1130
-
1131
- case 'L':
1132
- return "L " + (params[1] - x) + "," + (params[2] - y);
1133
-
1134
- case 'Q':
1135
- return "Q " + (params[1] - x) + " " + (params[2] - y) + "," + (params[3] - x) + " " + (params[4] - y);
1136
-
1137
- case 'C':
1138
- return "C " + (params[1] - x) + " " + (params[2] - y) + "," + (params[3] - x) + " " + (params[4] - y) + "," + (params[5] - x) + " " + (params[6] - y);
1139
-
1140
- case 'A':
1141
- return "A " + params[1] + " " + params[2] + " " + params[3] + " " + params[4] + " " + params[5] + " " + (params[6] - x) + " " + (params[7] - y);
1142
-
1143
- case 'Z':
1144
- return 'Z';
1145
- }
1146
- }).join(' ');
1147
-
1148
- if (~newValue.indexOf('NaN')) {
1149
- return '';
1150
- }
1151
-
1152
- return newValue;
1153
- };
1154
-
1155
- return PathRenderer;
1156
- }();
1157
-
1158
- PathRenderer = __decorate([manaSyringe.singleton()], PathRenderer);
1159
- var ElementRendererFactory = manaSyringe.Syringe.defineToken('ElementRendererFactory');
1160
- var ElementRenderer = manaSyringe.Syringe.defineToken('ElementRenderer');
1161
-
1162
964
  function _regeneratorRuntime$1() {
1163
965
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
1164
966
  _regeneratorRuntime$1 = function _regeneratorRuntime() {
@@ -1284,7 +1086,7 @@
1284
1086
  if ("throw" !== record.type) {
1285
1087
  var result = record.arg,
1286
1088
  value = result.value;
1287
- 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) {
1288
1090
  invoke("next", value, resolve, reject);
1289
1091
  }, function (err) {
1290
1092
  invoke("throw", err, resolve, reject);
@@ -1525,32 +1327,478 @@
1525
1327
  }
1526
1328
  }
1527
1329
 
1528
- function _asyncToGenerator$1(fn) {
1529
- return function () {
1530
- var self = this,
1531
- args = arguments;
1532
- return new Promise(function (resolve, reject) {
1533
- var gen = fn.apply(self, args);
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
+ }
1744
+
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];
1760
+
1761
+ switch (command) {
1762
+ case 'M':
1763
+ return "M ".concat(params[1] - x, ",").concat(params[2] - y);
1534
1764
 
1535
- function _next(value) {
1536
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
1537
- }
1765
+ case 'L':
1766
+ return "L ".concat(params[1] - x, ",").concat(params[2] - y);
1538
1767
 
1539
- function _throw(err) {
1540
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
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 '';
1541
1784
  }
1542
1785
 
1543
- _next(undefined);
1544
- });
1545
- };
1546
- }
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');
1547
1796
  /**
1548
1797
  * Common utilities
1549
1798
  * @module glMatrix
1550
1799
  */
1551
1800
  // Configuration Constants
1552
1801
 
1553
-
1554
1802
  var EPSILON = 0.000001;
1555
1803
  var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
1556
1804
  if (!Math.hypot) Math.hypot = function () {
@@ -2216,7 +2464,7 @@
2216
2464
  function createOrUpdateFilter($def, object, $el, filters) {
2217
2465
  // eg. filter="url(#f1) url(#f2)"
2218
2466
  var filterName = FILTER_PREFIX + object.entity;
2219
- var $existedFilters = $def.querySelectorAll("[name=" + filterName + "]");
2467
+ var $existedFilters = $def.querySelectorAll("[name=".concat(filterName, "]"));
2220
2468
 
2221
2469
  if ($existedFilters.length) {
2222
2470
  $existedFilters.forEach(function ($filter) {
@@ -2253,13 +2501,13 @@
2253
2501
  createInvert($filter, params);
2254
2502
  }
2255
2503
 
2256
- $filter.id = filterName + "-" + i;
2504
+ $filter.id = "".concat(filterName, "-").concat(i);
2257
2505
  $filter.setAttribute('name', filterName);
2258
2506
  $def.appendChild($filter);
2259
2507
  return $filter.id;
2260
2508
  });
2261
2509
  $el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', filterIds.map(function (filterId) {
2262
- return "url(#" + filterId + ")";
2510
+ return "url(#".concat(filterId, ")");
2263
2511
  }).join(' '));
2264
2512
  }
2265
2513
  }
@@ -2275,7 +2523,7 @@
2275
2523
  function createBlur($filter, params) {
2276
2524
  var $feGaussianBlur = createSVGElement('feGaussianBlur');
2277
2525
  $feGaussianBlur.setAttribute('in', 'SourceGraphic');
2278
- $feGaussianBlur.setAttribute('stdDeviation', "" + params[0].value);
2526
+ $feGaussianBlur.setAttribute('stdDeviation', "".concat(params[0].value));
2279
2527
  $filter.appendChild($feGaussianBlur);
2280
2528
  }
2281
2529
 
@@ -2289,10 +2537,10 @@
2289
2537
  $feFunc.setAttribute('type', type);
2290
2538
 
2291
2539
  if (type === 'table') {
2292
- $feFunc.setAttribute('tableValues', "" + tableValues);
2540
+ $feFunc.setAttribute('tableValues', "".concat(tableValues));
2293
2541
  } else {
2294
- $feFunc.setAttribute('slope', "" + slope);
2295
- $feFunc.setAttribute('intercept', "" + intercept);
2542
+ $feFunc.setAttribute('slope', "".concat(slope));
2543
+ $feFunc.setAttribute('intercept', "".concat(intercept));
2296
2544
  }
2297
2545
 
2298
2546
  $feComponentTransfer.appendChild($feFunc);
@@ -2313,7 +2561,7 @@
2313
2561
  var amount = convertToAbsoluteValue(params[0]);
2314
2562
  createFeComponentTransfer($filter, {
2315
2563
  type: 'table',
2316
- tableValues: amount + " " + (1 - amount)
2564
+ tableValues: "".concat(amount, " ").concat(1 - amount)
2317
2565
  });
2318
2566
  }
2319
2567
 
@@ -2330,14 +2578,14 @@
2330
2578
  var amount = convertToAbsoluteValue(params[0]);
2331
2579
  var $feColorMatrix = createSVGElement('feColorMatrix');
2332
2580
  $feColorMatrix.setAttribute('type', 'saturate');
2333
- $feColorMatrix.setAttribute('values', "" + amount);
2581
+ $feColorMatrix.setAttribute('values', "".concat(amount));
2334
2582
  $filter.appendChild($feColorMatrix);
2335
2583
  }
2336
2584
 
2337
2585
  function createHueRotate($filter, params) {
2338
2586
  var $feColorMatrix = createSVGElement('feColorMatrix');
2339
2587
  $feColorMatrix.setAttribute('type', 'hueRotate');
2340
- $feColorMatrix.setAttribute('values', "" + params[0].to(g.UnitType.kDegrees).value);
2588
+ $feColorMatrix.setAttribute('values', "".concat(params[0].to(g.UnitType.kDegrees).value));
2341
2589
  $filter.appendChild($feColorMatrix);
2342
2590
  }
2343
2591
 
@@ -2349,11 +2597,11 @@
2349
2597
  var shadowColor = params[3].formatted;
2350
2598
  var $feGaussianBlur = createSVGElement('feGaussianBlur');
2351
2599
  $feGaussianBlur.setAttribute('in', 'SourceAlpha');
2352
- $feGaussianBlur.setAttribute('stdDeviation', "" + shadowBlur);
2600
+ $feGaussianBlur.setAttribute('stdDeviation', "".concat(shadowBlur));
2353
2601
  $filter.appendChild($feGaussianBlur);
2354
2602
  var $feOffset = createSVGElement('feOffset');
2355
- $feOffset.setAttribute('dx', "" + shadowOffsetX);
2356
- $feOffset.setAttribute('dy', "" + shadowOffsetY);
2603
+ $feOffset.setAttribute('dx', "".concat(shadowOffsetX));
2604
+ $feOffset.setAttribute('dy', "".concat(shadowOffsetY));
2357
2605
  $feOffset.setAttribute('result', 'offsetblur');
2358
2606
  $filter.appendChild($feOffset);
2359
2607
  var $feFlood = createSVGElement('feFlood');
@@ -2407,7 +2655,7 @@
2407
2655
  }
2408
2656
 
2409
2657
  var gradientId = generateCacheKey(parsedColor);
2410
- var existed = $def.querySelector("#" + gradientId);
2658
+ var existed = $def.querySelector("#".concat(gradientId));
2411
2659
 
2412
2660
  if (parsedColor instanceof g.CSSRGB) {
2413
2661
  // keep using currentColor @see https://github.com/d3/d3-axis/issues/49
@@ -2423,13 +2671,13 @@
2423
2671
  createPattern($def, parsedColor, gradientId);
2424
2672
  }
2425
2673
 
2426
- $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, ")"));
2427
2675
  } else {
2428
2676
  if (!existed) {
2429
2677
  createGradient($def, parsedColor, gradientId);
2430
2678
  }
2431
2679
 
2432
- $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, ")"));
2433
2681
  }
2434
2682
  }
2435
2683
  }
@@ -2452,14 +2700,14 @@
2452
2700
  y1 = _params$value.y1,
2453
2701
  r1 = _params$value.r1,
2454
2702
  steps = _params$value.steps;
2455
- 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) {
2456
2704
  return step.join('');
2457
- }).join('');
2705
+ }).join(''));
2458
2706
  }
2459
2707
 
2460
2708
  if (cacheKey) {
2461
2709
  if (!cacheKey2IDMap[cacheKey]) {
2462
- cacheKey2IDMap[cacheKey] = "_pattern_" + type + "_" + counter++;
2710
+ cacheKey2IDMap[cacheKey] = "_pattern_".concat(type, "_").concat(counter++);
2463
2711
  }
2464
2712
  }
2465
2713
  }
@@ -2486,8 +2734,8 @@
2486
2734
  img.src = src;
2487
2735
 
2488
2736
  function onload() {
2489
- $pattern.setAttribute('width', "" + img.width);
2490
- $pattern.setAttribute('height', "" + img.height);
2737
+ $pattern.setAttribute('width', "".concat(img.width));
2738
+ $pattern.setAttribute('height', "".concat(img.height));
2491
2739
  }
2492
2740
 
2493
2741
  if (img.complete) {
@@ -2511,26 +2759,28 @@
2511
2759
  y0 = _parsedColor$value.y0,
2512
2760
  x1 = _parsedColor$value.x1,
2513
2761
  y1 = _parsedColor$value.y1;
2514
- $gradient.setAttribute('x1', "" + x0);
2515
- $gradient.setAttribute('y1', "" + y0);
2516
- $gradient.setAttribute('x2', "" + x1);
2517
- $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));
2518
2766
  } else {
2519
2767
  var _parsedColor$value2 = parsedColor.value,
2520
2768
  _x = _parsedColor$value2.x0,
2521
2769
  _y = _parsedColor$value2.y0,
2522
2770
  r1 = _parsedColor$value2.r1;
2523
- $gradient.setAttribute('cx', "" + _x);
2524
- $gradient.setAttribute('cy', "" + _y);
2525
- $gradient.setAttribute('r', "" + r1 / 2);
2771
+ $gradient.setAttribute('cx', "".concat(_x));
2772
+ $gradient.setAttribute('cy', "".concat(_y));
2773
+ $gradient.setAttribute('r', "".concat(r1 / 2));
2526
2774
  } // add stops
2527
2775
 
2528
2776
 
2529
2777
  var innerHTML = '';
2530
2778
  parsedColor.value.steps.forEach(function (_ref) {
2531
- var offset = _ref[0],
2532
- color = _ref[1];
2533
- 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>");
2534
2784
  });
2535
2785
  $gradient.innerHTML = innerHTML;
2536
2786
  $gradient.id = gradientId;
@@ -2545,7 +2795,7 @@
2545
2795
 
2546
2796
  function createOrUpdateShadow($def, object, $el, name) {
2547
2797
  var shadowId = FILTER_DROPSHADOW_PREFIX + object.entity;
2548
- var $existedFilter = $def.querySelector("#" + shadowId);
2798
+ var $existedFilter = $def.querySelector("#".concat(shadowId));
2549
2799
 
2550
2800
  if (!$existedFilter) {
2551
2801
  $existedFilter = createSVGElement('filter');
@@ -2571,24 +2821,52 @@
2571
2821
  // @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
2572
2822
  // @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
2573
2823
 
2574
- $feDropShadow.setAttribute('stdDeviation', "" + (shadowBlur && shadowBlur.value || 0) / 2);
2824
+ $feDropShadow.setAttribute('stdDeviation', "".concat((shadowBlur && shadowBlur.value || 0) / 2));
2575
2825
  } else if (name === 'shadowOffsetX') {
2576
2826
  var shadowOffsetX = object.parsedStyle[name];
2577
- $feDropShadow.setAttribute('dx', "" + (shadowOffsetX && shadowOffsetX.value || 0) / 2);
2827
+ $feDropShadow.setAttribute('dx', "".concat((shadowOffsetX && shadowOffsetX.value || 0) / 2));
2578
2828
  } else if (name === 'shadowOffsetY') {
2579
2829
  var shadowOffsetY = object.parsedStyle[name];
2580
- $feDropShadow.setAttribute('dy', "" + (shadowOffsetY && shadowOffsetY.value || 0) / 2);
2581
- } // use filter <feDropShadow>
2582
- // @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
2583
2832
 
2584
2833
 
2585
- $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
+ }
2586
2841
  }
2587
2842
 
2843
+ var CreateElementContribution = manaSyringe.Syringe.defineToken('CreateElementContribution', {
2844
+ multiple: false
2845
+ });
2846
+
2847
+ var DefaultElementContribution = /*#__PURE__*/function () {
2848
+ function DefaultElementContribution() {
2849
+ _classCallCheck$2(this, DefaultElementContribution);
2850
+ }
2851
+
2852
+ _createClass$2(DefaultElementContribution, [{
2853
+ key: "createElement",
2854
+ value: function createElement(object) {
2855
+ return createSVGElement(object.nodeName);
2856
+ }
2857
+ }]);
2858
+
2859
+ return DefaultElementContribution;
2860
+ }();
2861
+
2862
+ DefaultElementContribution = __decorate([manaSyringe.singleton({
2863
+ token: CreateElementContribution
2864
+ })], DefaultElementContribution);
2865
+
2588
2866
  var _SHAPE2TAGS, _class$1;
2589
2867
 
2590
2868
  var SVGRendererPlugin_1;
2591
- 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);
2592
2870
  var SVG_ATTR_MAP = {
2593
2871
  opacity: 'opacity',
2594
2872
  fillStyle: 'fill',
@@ -2670,464 +2948,485 @@
2670
2948
  var CLIP_PATH_PREFIX = 'clip-path-';
2671
2949
  var SVGRendererPlugin = SVGRendererPlugin_1 = (_class$1 = /*#__PURE__*/function () {
2672
2950
  function SVGRendererPlugin() {
2951
+ _classCallCheck$2(this, SVGRendererPlugin);
2952
+
2673
2953
  this.canvasConfig = void 0;
2674
2954
  this.camera = void 0;
2675
2955
  this.contextService = void 0;
2676
2956
  this.renderingContext = void 0;
2957
+ this.createElementContribution = void 0;
2677
2958
  this.elementRendererFactory = void 0;
2678
2959
  this.$def = void 0;
2679
2960
  this.$camera = void 0;
2680
2961
  this.renderQueue = [];
2681
2962
  }
2682
2963
 
2683
- var _proto = SVGRendererPlugin.prototype;
2964
+ _createClass$2(SVGRendererPlugin, [{
2965
+ key: "apply",
2966
+ value: function apply(renderingService) {
2967
+ var _this = this;
2684
2968
 
2685
- _proto.apply = function apply(renderingService) {
2686
- var _this = this;
2969
+ var handleMounted = function handleMounted(e) {
2970
+ var object = e.target; // create SVG DOM Node
2687
2971
 
2688
- var handleMounted = function handleMounted(e) {
2689
- var object = e.target; // create SVG DOM Node
2972
+ _this.createSVGDom(object, _this.$camera);
2973
+ };
2690
2974
 
2691
- _this.createSVGDom(object, _this.$camera);
2692
- };
2975
+ var handleUnmounted = function handleUnmounted(e) {
2976
+ var object = e.target;
2693
2977
 
2694
- var handleUnmounted = function handleUnmounted(e) {
2695
- var object = e.target;
2978
+ _this.removeSVGDom(object);
2979
+ };
2696
2980
 
2697
- _this.removeSVGDom(object);
2698
- };
2981
+ var handleAttributeChanged = function handleAttributeChanged(e) {
2982
+ var object = e.target; // @see https://github.com/antvis/g/issues/994
2983
+ // @ts-ignore
2699
2984
 
2700
- var handleAttributeChanged = function handleAttributeChanged(e) {
2701
- var object = e.target; // @see https://github.com/antvis/g/issues/994
2702
- // @ts-ignore
2985
+ if (!object.elementSVG) {
2986
+ return;
2987
+ }
2703
2988
 
2704
- if (!object.elementSVG) {
2705
- return;
2706
- }
2989
+ var attrName = e.attrName;
2707
2990
 
2708
- var attrName = e.attrName;
2991
+ if (attrName === 'zIndex') {
2992
+ var _object$parentNode, _object$parentNode$el;
2709
2993
 
2710
- if (attrName === 'zIndex') {
2711
- var _object$parentNode, _object$parentNode$el;
2994
+ var parent = object.parentNode; // @ts-ignore
2712
2995
 
2713
- 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();
2714
2998
 
2715
- 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;
2716
- 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;
2717
3005
 
2718
- if ($groupEl) {
2719
- _this.reorderChildren($groupEl, children);
3006
+ _this.createOrUpdateHitArea(object, svgElement.$el, svgElement.$groupEl);
2720
3007
  }
2721
- } else if (attrName === 'increasedLineWidthForHitTesting') {
2722
- // @ts-ignore
2723
- var svgElement = object.elementSVG;
2724
3008
 
2725
- _this.createOrUpdateHitArea(object, svgElement.$el, svgElement.$groupEl);
2726
- }
3009
+ _this.updateAttribute(object, [attrName]);
3010
+ };
2727
3011
 
2728
- _this.updateAttribute(object, [attrName]);
2729
- };
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;
2730
3021
 
2731
- renderingService.hooks.init.tapPromise(SVGRendererPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
2732
- var $svg, background;
2733
- return _regeneratorRuntime$1().wrap(function _callee$(_context) {
2734
- while (1) {
2735
- switch (_context.prev = _context.next) {
2736
- case 0:
2737
- _this.$def = createSVGElement('defs');
2738
- $svg = _this.contextService.getContext();
2739
- background = _this.canvasConfig.background;
2740
-
2741
- if (background) {
2742
- $svg.style.background = background;
2743
- }
3022
+ if (background) {
3023
+ $svg.style.background = background;
3024
+ }
2744
3025
 
2745
- $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
2746
3027
 
2747
- $svg.setAttribute('color-interpolation-filters', 'sRGB');
2748
- _this.$camera = createSVGElement('g');
2749
- _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");
2750
3031
 
2751
- _this.applyTransform(_this.$camera, _this.camera.getOrthoMatrix());
3032
+ _this.applyTransform(_this.$camera, _this.camera.getOrthoMatrix());
2752
3033
 
2753
- $svg.appendChild(_this.$camera);
3034
+ $svg.appendChild(_this.$camera);
2754
3035
 
2755
- _this.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
3036
+ _this.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
2756
3037
 
2757
- _this.renderingContext.root.addEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
3038
+ _this.renderingContext.root.addEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
2758
3039
 
2759
- _this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
3040
+ _this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
2760
3041
 
2761
- case 13:
2762
- case "end":
2763
- return _context.stop();
3042
+ case 13:
3043
+ case "end":
3044
+ return _context.stop();
3045
+ }
2764
3046
  }
2765
- }
2766
- }, _callee);
2767
- })));
2768
- renderingService.hooks.destroy.tap(SVGRendererPlugin_1.tag, function () {
2769
- _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);
2770
3051
 
2771
- _this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
2772
-
2773
- _this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
2774
- });
2775
- renderingService.hooks.render.tap(SVGRendererPlugin_1.tag, function (object) {
2776
- // if (!object.isCulled()) {
2777
- _this.renderQueue.push(object); // }
3052
+ _this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
2778
3053
 
2779
- });
2780
- renderingService.hooks.endFrame.tap(SVGRendererPlugin_1.tag, function () {
2781
- if (_this.renderingContext.renderReasons.has(g.RenderReason.CAMERA_CHANGED)) {
2782
- _this.applyTransform(_this.$camera, _this.camera.getOrthoMatrix());
2783
- }
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); // }
2784
3059
 
2785
- _this.renderQueue.forEach(function (object) {
2786
- 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
+ }
2787
3065
 
3066
+ _this.renderQueue.forEach(function (object) {
3067
+ var _object$elementSVG, _object$elementSVG2; // @ts-ignore
2788
3068
 
2789
- var $el = (_object$elementSVG = object.elementSVG) === null || _object$elementSVG === void 0 ? void 0 : _object$elementSVG.$el; // @ts-ignore
2790
3069
 
2791
- 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
2792
3071
 
2793
- if ($el && $groupEl) {
2794
- // apply local RTS transformation to <group> wrapper
2795
- // account for anchor
2796
- _this.applyTransform($groupEl, object.getLocalTransform());
3072
+ var $groupEl = (_object$elementSVG2 = object.elementSVG) === null || _object$elementSVG2 === void 0 ? void 0 : _object$elementSVG2.$groupEl;
2797
3073
 
2798
- var children = ((object === null || object === void 0 ? void 0 : object.children) || []).slice();
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
2799
3078
 
2800
- _this.reorderChildren($groupEl, children || []); // finish rendering, clear dirty flag
2801
3079
 
3080
+ object.renderable.dirty = false;
3081
+ }
3082
+ });
2802
3083
 
2803
- object.renderable.dirty = false;
2804
- }
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;
2805
3093
  });
2806
3094
 
2807
- _this.renderQueue = [];
2808
- });
2809
- };
2810
-
2811
- _proto.reorderChildren = function reorderChildren($groupEl, children) {
2812
- // need to reorder parent's children
2813
- children.sort(function (a, b) {
2814
- return a.sortable.renderOrder - b.sortable.renderOrder;
2815
- });
2816
-
2817
- if (children.length) {
2818
- // create empty fragment
2819
- var fragment = document.createDocumentFragment();
2820
- children.forEach(function (child) {
2821
- // @ts-ignore
2822
- 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;
2823
3102
 
2824
- if ($el) {
2825
- fragment.appendChild($el);
2826
- }
2827
- });
2828
- $groupEl.appendChild(fragment);
3103
+ if ($el) {
3104
+ fragment.appendChild($el);
3105
+ }
3106
+ }
3107
+ });
3108
+ $groupEl.appendChild(fragment);
3109
+ }
2829
3110
  }
2830
- };
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);
2831
3117
 
2832
- _proto.applyTransform = function applyTransform($el, transform) {
2833
- var translation = getTranslation(create$1(), transform);
2834
- var scaling = getScaling(create$1(), transform);
2835
- var rotation = getRotation(create$3(), transform);
2836
- var x = translation[0],
2837
- y = translation[1];
2838
- var scaleX = scaling[0],
2839
- 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];
2840
3121
 
2841
- var _getEuler = g.getEuler(create$1(), rotation),
2842
- ex = _getEuler[0],
2843
- ey = _getEuler[1],
2844
- 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
2845
3125
 
2846
3126
 
2847
- var rts = g.fromRotationTranslationScale(ex || ez, x, y, scaleX, scaleY); // use proper precision avoiding too long string in `transform`
2848
- // @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
2849
3132
 
2850
- $el.setAttribute('transform', "matrix(" + numberToLongString(rts[0]) + "," + numberToLongString(rts[1]) + "," + numberToLongString(rts[3]) + "," + numberToLongString(rts[4]) + "," + numberToLongString(rts[6]) + "," + numberToLongString(rts[7]) + ")");
2851
- };
2852
3133
 
2853
- _proto.applyAttributes = function applyAttributes(object) {
2854
- // @ts-ignore
2855
- var elementSVG = object.elementSVG;
2856
- var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
2857
- 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
2858
3136
 
2859
- if ($el && $groupEl) {
2860
- var nodeName = object.nodeName,
2861
- attributes = object.attributes;
2862
- $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;
2863
3146
 
2864
- if (nodeName === g.Shape.IMAGE) {
2865
- $el.setAttribute('preserveAspectRatio', 'none');
2866
- } // apply attributes
3147
+ if ($el && $groupEl) {
3148
+ var nodeName = object.nodeName,
3149
+ attributes = object.attributes;
3150
+ $el.setAttribute('fill', 'none');
2867
3151
 
3152
+ if (nodeName === g.Shape.IMAGE) {
3153
+ $el.setAttribute('preserveAspectRatio', 'none');
3154
+ } // apply attributes
2868
3155
 
2869
- this.updateAttribute(object, Object.keys(attributes));
2870
- }
2871
- };
2872
3156
 
2873
- _proto.updateAttribute = function updateAttribute(object, attributes) {
2874
- var _this2 = this;
2875
-
2876
- var needGeneratePath = false; // @ts-ignore
2877
-
2878
- var _object$elementSVG3 = object.elementSVG,
2879
- $el = _object$elementSVG3.$el,
2880
- $groupEl = _object$elementSVG3.$groupEl,
2881
- $hitTestingEl = _object$elementSVG3.$hitTestingEl;
2882
- var parsedStyle = object.parsedStyle,
2883
- computedStyle = object.computedStyle;
2884
- var elementRenderer = this.elementRendererFactory(object.nodeName);
2885
- attributes.forEach(function (name) {
2886
- var usedName = SVG_ATTR_MAP[name];
2887
- var computedValue = computedStyle[name];
2888
- var usedValue = parsedStyle[name]; // generate path only once
2889
-
2890
- if (!needGeneratePath && elementRenderer && elementRenderer.dependencies.indexOf(name) > -1) {
2891
- needGeneratePath = true;
2892
- } // <foreignObject>
2893
-
2894
-
2895
- if (object.nodeName === g.Shape.HTML) {
2896
- if (name === 'fill') {
2897
- $el.style.background = usedValue.toString();
2898
- } else if (name === 'stroke') {
2899
- $el.style['border-color'] = usedValue.toString();
2900
- $el.style['border-style'] = 'solid';
2901
- } else if (name === 'lineWidth') {
2902
- $el.style['border-width'] = (usedValue.value || 0) + "px";
2903
- } else if (name === 'lineDash') {
2904
- $el.style['border-style'] = 'dashed';
2905
- }
3157
+ this.updateAttribute(object, Object.keys(attributes));
2906
3158
  }
2907
-
2908
- if (name === 'fill' || name === 'stroke') {
2909
- createOrUpdateGradientAndPattern(_this2.$def, object, $el, usedValue, usedName);
2910
- } else if (name === 'visibility') {
2911
- // use computed value
2912
- // update `visibility` on <group>
2913
- $groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, "" + computedValue.value);
2914
- } else if (name === 'clipPath') {
2915
- _this2.createOrUpdateClipPath(usedValue, $groupEl);
2916
- } else if (name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
2917
- createOrUpdateShadow(_this2.$def, object, $el, name);
2918
- } else if (name === 'filter') {
2919
- createOrUpdateFilter(_this2.$def, object, $el, usedValue);
2920
- } else if (name === 'innerHTML') {
2921
- _this2.createOrUpdateInnerHTML($el, usedValue);
2922
- } else {
2923
- if ( // (!object.style.clipPathTargets) &&
2924
- object.nodeName !== g.Shape.TEXT && // text' anchor is controlled by `textAnchor` property
2925
- ['width', 'height', 'r', 'rx', 'ry', 'anchor'].indexOf(name) > -1) {
2926
- _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
+ }
2927
3195
  }
2928
3196
 
2929
- if (name !== 'anchor' && computedValue) {
2930
- // use computed value so that we can use cascaded effect in SVG
2931
- 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
+ }
2932
3217
 
2933
- if (valueStr !== 'unset' && valueStr !== DEFAULT_VALUE_MAP[name]) {
2934
- 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
2935
3221
 
2936
- 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;
2937
3222
  [$el, $hitTestingEl].forEach(function ($el) {
2938
3223
  if ($el && usedName) {
2939
- $el.setAttribute(usedName, formattedValueStr);
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
+ }
2940
3232
  }
2941
3233
  });
2942
3234
  }
2943
3235
  }
2944
- }
2945
- }); // need re-generate path
3236
+ }); // need re-generate path
2946
3237
 
2947
- if (needGeneratePath && $el) {
2948
- [$el, $hitTestingEl].forEach(function ($el) {
2949
- if ($el) {
2950
- elementRenderer.apply($el, object.parsedStyle);
2951
- }
2952
- });
3238
+ if (needGeneratePath && $el) {
3239
+ [$el, $hitTestingEl].forEach(function ($el) {
3240
+ if ($el) {
3241
+ elementRenderer.apply($el, object.parsedStyle);
3242
+ }
3243
+ });
3244
+ }
2953
3245
  }
2954
- };
2955
-
2956
- _proto.createSVGDom = function createSVGDom(object, root, noWrapWithGroup) {
2957
- if (noWrapWithGroup === void 0) {
2958
- noWrapWithGroup = false;
2959
- } // create svg element
2960
- // @ts-ignore
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
2961
3251
 
3252
+ object.elementSVG = new ElementSVG(); // @ts-ignore
2962
3253
 
2963
- object.elementSVG = new ElementSVG(); // @ts-ignore
3254
+ var svgElement = object.elementSVG; // use <group> as default, eg. CustomElement
2964
3255
 
2965
- var svgElement = object.elementSVG; // use <group> as default, eg. CustomElement
3256
+ var type = SHAPE2TAGS[object.nodeName] || 'g';
2966
3257
 
2967
- var type = SHAPE2TAGS[object.nodeName] || 'g';
3258
+ if (type) {
3259
+ var _object$parentNode$el2;
2968
3260
 
2969
- if (type) {
2970
- var _object$parentNode$el2;
3261
+ var $groupEl;
3262
+ var $el = createSVGElement(type); // save $el on parsedStyle, which will be returned in getDomElement()
2971
3263
 
2972
- var $groupEl;
2973
- var $el = createSVGElement(type); // save $el on parsedStyle, which will be returned in getDomElement()
3264
+ if (object.nodeName === g.Shape.HTML) {
3265
+ object.parsedStyle.$el = $el;
3266
+ }
2974
3267
 
2975
- if (object.nodeName === g.Shape.HTML) {
2976
- object.parsedStyle.$el = $el;
2977
- }
3268
+ $el.id = "".concat(G_SVG_PREFIX, "_").concat(object.nodeName, "_").concat(object.entity);
2978
3269
 
2979
- $el.id = G_SVG_PREFIX + "_" + object.nodeName + "_" + object.entity;
3270
+ if (type !== 'g' && !noWrapWithGroup) {
3271
+ $groupEl = createSVGElement('g');
3272
+ $groupEl.appendChild($el);
3273
+ } else {
3274
+ $groupEl = $el;
3275
+ }
2980
3276
 
2981
- if (type !== 'g' && !noWrapWithGroup) {
2982
- $groupEl = createSVGElement('g');
2983
- $groupEl.appendChild($el);
2984
- } else {
2985
- $groupEl = $el;
2986
- }
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;
2987
3281
 
2988
- svgElement.$el = $el;
2989
- svgElement.$groupEl = $groupEl;
2990
- var $parentGroupEl = // @ts-ignore
2991
- object.parentNode && ((_object$parentNode$el2 = object.parentNode.elementSVG) === null || _object$parentNode$el2 === void 0 ? void 0 : _object$parentNode$el2.$groupEl) || root;
3282
+ if ($parentGroupEl) {
3283
+ var _object$parentNode2;
2992
3284
 
2993
- if ($parentGroupEl) {
2994
- $parentGroupEl.appendChild($groupEl);
2995
- } // 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
2996
3289
 
2997
3290
 
2998
- this.applyAttributes(object); // create hitArea if necessary
3291
+ this.applyAttributes(object); // create hitArea if necessary
2999
3292
 
3000
- this.createOrUpdateHitArea(object, $el, $groupEl);
3293
+ this.createOrUpdateHitArea(object, $el, $groupEl);
3294
+ }
3001
3295
  }
3002
- };
3003
-
3004
- _proto.removeSVGDom = function removeSVGDom(object) {
3005
- var _object$elementSVG4; // @ts-ignore
3296
+ }, {
3297
+ key: "removeSVGDom",
3298
+ value: function removeSVGDom(object) {
3299
+ var _object$elementSVG4; // @ts-ignore
3006
3300
 
3007
3301
 
3008
- var $groupEl = (_object$elementSVG4 = object.elementSVG) === null || _object$elementSVG4 === void 0 ? void 0 : _object$elementSVG4.$groupEl;
3302
+ var $groupEl = (_object$elementSVG4 = object.elementSVG) === null || _object$elementSVG4 === void 0 ? void 0 : _object$elementSVG4.$groupEl;
3009
3303
 
3010
- if ($groupEl && $groupEl.parentNode) {
3011
- $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
+ }
3012
3307
  }
3013
- };
3308
+ }, {
3309
+ key: "createOrUpdateHitArea",
3310
+ value: function createOrUpdateHitArea(object, $el, $groupEl) {
3311
+ var _object$parsedStyle$i; // @ts-ignore
3014
3312
 
3015
- _proto.createOrUpdateHitArea = function createOrUpdateHitArea(object, $el, $groupEl) {
3016
- var _object$parsedStyle$i; // @ts-ignore
3017
3313
 
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
3018
3317
 
3019
- var svgElement = object.elementSVG;
3020
- var $hitTestingEl = svgElement.$hitTestingEl;
3021
- var increasedLineWidthForHitTesting = (_object$parsedStyle$i = object.parsedStyle.increasedLineWidthForHitTesting) === null || _object$parsedStyle$i === void 0 ? void 0 : _object$parsedStyle$i.value; // account for hitArea
3318
+ if (increasedLineWidthForHitTesting) {
3319
+ var _object$parsedStyle$l;
3022
3320
 
3023
- if (increasedLineWidthForHitTesting) {
3024
- var _object$parsedStyle$l;
3321
+ if (!$hitTestingEl) {
3322
+ $hitTestingEl = $el.cloneNode(); // use the entity suffix, so that `g-plugin-svg-picker` can extract
3025
3323
 
3026
- if (!$hitTestingEl) {
3027
- $hitTestingEl = $el.cloneNode(); // use the entity suffix, so that `g-plugin-svg-picker` can extract
3324
+ $hitTestingEl.id = "".concat(G_SVG_PREFIX, "_").concat(object.nodeName, "_hittesting_").concat(object.entity); // clear attributes like `filter` `font-size`
3028
3325
 
3029
- $hitTestingEl.id = G_SVG_PREFIX + "_" + object.nodeName + "_hittesting_" + object.entity; // clear attributes like `filter` `font-size`
3326
+ ['filter'].forEach(function (attribute) {
3327
+ $hitTestingEl.removeAttribute(attribute);
3328
+ }); // hitArea should be 'transparent' but not 'none'
3030
3329
 
3031
- ['filter'].forEach(function (attribute) {
3032
- $hitTestingEl.removeAttribute(attribute);
3033
- }); // hitArea should be 'transparent' but not 'none'
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
3034
3336
 
3035
- var hasFill = $el.getAttribute('fill') !== 'none';
3036
- $hitTestingEl.setAttribute('fill', hasFill ? 'transparent' : 'none');
3037
- $hitTestingEl.setAttribute('stroke', 'transparent');
3038
- $groupEl.appendChild($hitTestingEl);
3039
- svgElement.$hitTestingEl = $hitTestingEl;
3040
- } // increase interactive line width
3041
3337
 
3042
-
3043
- $hitTestingEl.setAttribute('stroke-width', "" + (increasedLineWidthForHitTesting + ((_object$parsedStyle$l = object.parsedStyle.lineWidth) === null || _object$parsedStyle$l === void 0 ? void 0 : _object$parsedStyle$l.value)));
3044
- } else {
3045
- if ($hitTestingEl) {
3046
- $groupEl.removeChild($hitTestingEl);
3047
- 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
+ }
3048
3344
  }
3049
3345
  }
3050
- };
3346
+ }, {
3347
+ key: "createOrUpdateInnerHTML",
3348
+ value: function createOrUpdateInnerHTML($el, usedValue) {
3349
+ var $div = document.createElement('div');
3051
3350
 
3052
- _proto.createOrUpdateInnerHTML = function createOrUpdateInnerHTML($el, usedValue) {
3053
- var $div = document.createElement('div');
3351
+ if (typeof usedValue === 'string') {
3352
+ $div.innerHTML = usedValue;
3353
+ } else {
3354
+ $div.appendChild(usedValue);
3355
+ }
3054
3356
 
3055
- if (typeof usedValue === 'string') {
3056
- $div.innerHTML = usedValue;
3057
- } else {
3058
- $div.appendChild(usedValue);
3357
+ $el.innerHTML = '';
3358
+ $el.appendChild($div);
3059
3359
  }
3360
+ }, {
3361
+ key: "createOrUpdateClipPath",
3362
+ value: function createOrUpdateClipPath(clipPath, $groupEl) {
3363
+ if (clipPath) {
3364
+ var _clipPath$elementSVG;
3060
3365
 
3061
- $el.innerHTML = '';
3062
- $el.appendChild($div);
3063
- };
3064
-
3065
- _proto.createOrUpdateClipPath = function createOrUpdateClipPath(clipPath, $groupEl) {
3066
- if (clipPath) {
3067
- var _clipPath$elementSVG;
3366
+ var clipPathId = CLIP_PATH_PREFIX + clipPath.entity;
3367
+ var existed = this.$def.querySelector("#".concat(clipPathId));
3068
3368
 
3069
- var clipPathId = CLIP_PATH_PREFIX + clipPath.entity;
3070
- var existed = this.$def.querySelector("#" + clipPathId);
3071
-
3072
- if (!existed) {
3073
- // create <clipPath> dom node, append it to <defs>
3074
- var $clipPath = createSVGElement('clipPath');
3075
- $clipPath.id = clipPathId;
3076
- 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>
3077
3374
 
3078
- this.createSVGDom(clipPath, $clipPath, true); // @ts-ignore
3375
+ this.createSVGDom(clipPath, $clipPath, true); // @ts-ignore
3079
3376
 
3080
- clipPath.elementSVG.$groupEl = $clipPath;
3081
- } // @ts-ignore
3377
+ clipPath.elementSVG.$groupEl = $clipPath;
3378
+ } // @ts-ignore
3082
3379
 
3083
3380
 
3084
- 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;
3085
3382
 
3086
- if ($clipPathGroupEl) {
3087
- // apply local RTS transformation to <group> wrapper
3088
- this.applyTransform($clipPathGroupEl, clipPath.getLocalTransform());
3089
- } // apply attributes
3383
+ if ($clipPathGroupEl) {
3384
+ // apply local RTS transformation to <group> wrapper
3385
+ this.applyTransform($clipPathGroupEl, clipPath.getLocalTransform());
3386
+ } // apply attributes
3090
3387
 
3091
3388
 
3092
- this.applyAttributes(clipPath); // apply clipPath to $group
3093
- // @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
3094
3391
 
3095
- $groupEl.setAttribute('clip-path', "url(#" + clipPathId + ")");
3096
- } else {
3097
- // remove clip path
3098
- $groupEl.removeAttribute('clip-path');
3392
+ $groupEl.setAttribute('clip-path', "url(#".concat(clipPathId, ")"));
3393
+ } else {
3394
+ // remove clip path
3395
+ $groupEl.removeAttribute('clip-path');
3396
+ }
3099
3397
  }
3100
- }
3101
- /**
3102
- * the origin is bounding box's top left corner
3103
- */
3104
- ;
3105
-
3106
- _proto.updateAnchorWithTransform = function updateAnchorWithTransform(object) {
3107
- var _object$elementSVG5, _object$elementSVG6;
3398
+ /**
3399
+ * the origin is bounding box's top left corner
3400
+ */
3108
3401
 
3109
- var bounds = object.getGeometryBounds();
3110
- var width = bounds && bounds.halfExtents[0] * 2 || 0;
3111
- var height = bounds && bounds.halfExtents[1] * 2 || 0;
3402
+ }, {
3403
+ key: "updateAnchorWithTransform",
3404
+ value: function updateAnchorWithTransform(object) {
3405
+ var _object$elementSVG5, _object$elementSVG6;
3112
3406
 
3113
- var _ref2 = object.parsedStyle || {},
3114
- anchor = _ref2.anchor; // @ts-ignore
3407
+ var bounds = object.getGeometryBounds();
3408
+ var width = bounds && bounds.halfExtents[0] * 2 || 0;
3409
+ var height = bounds && bounds.halfExtents[1] * 2 || 0;
3115
3410
 
3411
+ var _ref2 = object.parsedStyle || {},
3412
+ anchor = _ref2.anchor; // @ts-ignore
3116
3413
 
3117
- [(_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) {
3118
- if ($el) {
3119
- // apply anchor to element's `transform` property
3120
- $el.setAttribute('transform', // can't use percent unit like translate(-50%, -50%)
3121
- // @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/transform#translate
3122
- "translate(-" + anchor[0].value * width + ",-" + anchor[1].value * height + ")");
3123
3414
 
3124
- if (object.nodeName === g.Shape.CIRCLE || object.nodeName === g.Shape.ELLIPSE) {
3125
- $el.setAttribute('cx', "" + width / 2);
3126
- $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
+ }
3127
3426
  }
3128
- }
3129
- });
3130
- };
3427
+ });
3428
+ }
3429
+ }]);
3131
3430
 
3132
3431
  return SVGRendererPlugin;
3133
3432
  }(), _class$1.tag = 'SVGRenderer', _class$1);
@@ -3140,6 +3439,8 @@
3140
3439
 
3141
3440
  __decorate([manaSyringe.inject(g.RenderingContext), __metadata("design:type", Object)], SVGRendererPlugin.prototype, "renderingContext", void 0);
3142
3441
 
3442
+ __decorate([manaSyringe.inject(CreateElementContribution), __metadata("design:type", Object)], SVGRendererPlugin.prototype, "createElementContribution", void 0);
3443
+
3143
3444
  __decorate([manaSyringe.inject(ElementRendererFactory), __metadata("design:type", Function)], SVGRendererPlugin.prototype, "elementRendererFactory", void 0);
3144
3445
 
3145
3446
  SVGRendererPlugin = SVGRendererPlugin_1 = __decorate([manaSyringe.singleton({
@@ -3177,23 +3478,28 @@
3177
3478
  };
3178
3479
  }
3179
3480
  });
3481
+ register(DefaultElementContribution);
3180
3482
  register(SVGRendererPlugin);
3181
3483
  });
3182
3484
 
3183
3485
  var Plugin$1 = /*#__PURE__*/function () {
3184
3486
  function Plugin() {
3487
+ _classCallCheck$2(this, Plugin);
3488
+
3185
3489
  this.name = 'svg-renderer';
3186
3490
  }
3187
3491
 
3188
- var _proto = Plugin.prototype;
3189
-
3190
- _proto.init = function init(container) {
3191
- container.load(containerModule$1, true);
3192
- };
3193
-
3194
- _proto.destroy = function destroy(container) {
3195
- container.unload(containerModule$1);
3196
- };
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
+ }]);
3197
3503
 
3198
3504
  return Plugin;
3199
3505
  }();
@@ -3336,7 +3642,7 @@
3336
3642
  if ("throw" !== record.type) {
3337
3643
  var result = record.arg,
3338
3644
  value = result.value;
3339
- 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) {
3340
3646
  invoke("next", value, resolve, reject);
3341
3647
  }, function (err) {
3342
3648
  invoke("throw", err, resolve, reject);
@@ -3597,16 +3903,41 @@
3597
3903
  };
3598
3904
  }
3599
3905
 
3600
- 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) {
3601
3932
  if (!o) return;
3602
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
3933
+ if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
3603
3934
  var n = Object.prototype.toString.call(o).slice(8, -1);
3604
3935
  if (n === "Object" && o.constructor) n = o.constructor.name;
3605
3936
  if (n === "Map" || n === "Set") return Array.from(o);
3606
- 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);
3607
3938
  }
3608
3939
 
3609
- function _arrayLikeToArray(arr, len) {
3940
+ function _arrayLikeToArray$1(arr, len) {
3610
3941
  if (len == null || len > arr.length) len = arr.length;
3611
3942
 
3612
3943
  for (var i = 0, arr2 = new Array(len); i < len; i++) {
@@ -3616,25 +3947,61 @@
3616
3947
  return arr2;
3617
3948
  }
3618
3949
 
3619
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
3950
+ function _createForOfIteratorHelper(o, allowArrayLike) {
3620
3951
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
3621
- if (it) return (it = it.call(o)).next.bind(it);
3622
3952
 
3623
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
3624
- if (it) o = it;
3625
- var i = 0;
3626
- return function () {
3627
- if (i >= o.length) return {
3628
- done: true
3629
- };
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
+
3630
3960
  return {
3631
- done: false,
3632
- 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
3633
3975
  };
3634
- };
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.");
3635
3979
  }
3636
3980
 
3637
- 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
+ };
3638
4005
  }
3639
4006
 
3640
4007
  var _class$2;
@@ -3649,92 +4016,115 @@
3649
4016
 
3650
4017
  var SVGPickerPlugin = SVGPickerPlugin_1 = (_class$2 = /*#__PURE__*/function () {
3651
4018
  function SVGPickerPlugin() {
4019
+ _classCallCheck$3(this, SVGPickerPlugin);
4020
+
3652
4021
  this.sceneGraphService = void 0;
3653
4022
  this.displayObjectPool = void 0;
3654
4023
  }
3655
4024
 
3656
- var _proto = SVGPickerPlugin.prototype;
4025
+ _createClass$3(SVGPickerPlugin, [{
4026
+ key: "apply",
4027
+ value: function apply(renderingService) {
4028
+ var _this = this;
3657
4029
 
3658
- _proto.apply = function apply(renderingService) {
3659
- 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;
3660
4033
 
3661
- renderingService.hooks.pick.tapPromise(SVGPickerPlugin_1.tag, /*#__PURE__*/function () {
3662
- var _ref = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee(result) {
3663
- 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
3664
4041
 
3665
- return _regeneratorRuntime$2().wrap(function _callee$(_context) {
3666
- while (1) {
3667
- switch (_context.prev = _context.next) {
3668
- case 0:
3669
- topmost = result.topmost, _result$position = result.position, clientX = _result$position.clientX, clientY = _result$position.clientY;
3670
- _context.prev = 1;
3671
- targets = []; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
4042
+ _iterator = _createForOfIteratorHelper(document.elementsFromPoint(clientX, clientY));
4043
+ _context.prev = 4;
3672
4044
 
3673
- _iterator = _createForOfIteratorHelperLoose(document.elementsFromPoint(clientX, clientY));
4045
+ _iterator.s();
3674
4046
 
3675
- case 4:
3676
- if ((_step = _iterator()).done) {
3677
- _context.next = 17;
3678
- break;
3679
- }
4047
+ case 6:
4048
+ if ((_step = _iterator.n()).done) {
4049
+ _context.next = 19;
4050
+ break;
4051
+ }
3680
4052
 
3681
- element = _step.value; // eg. g_svg_circle_345
4053
+ element = _step.value; // eg. g_svg_circle_345
3682
4054
 
3683
- id = element && element.getAttribute('id');
4055
+ id = element && element.getAttribute('id');
3684
4056
 
3685
- if (!(id && id.startsWith(G_SVG_PREFIX))) {
3686
- _context.next = 15;
3687
- break;
3688
- }
4057
+ if (!(id && id.startsWith(G_SVG_PREFIX))) {
4058
+ _context.next = 17;
4059
+ break;
4060
+ }
3689
4061
 
3690
- index = id.lastIndexOf('_');
3691
- 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
3692
4064
 
3693
- if (!(target && target.isInteractive())) {
3694
- _context.next = 15;
3695
- break;
3696
- }
4065
+ if (!(target && target.isInteractive())) {
4066
+ _context.next = 17;
4067
+ break;
4068
+ }
4069
+
4070
+ targets.push(target);
3697
4071
 
3698
- targets.push(target);
4072
+ if (!topmost) {
4073
+ _context.next = 17;
4074
+ break;
4075
+ }
3699
4076
 
3700
- if (!topmost) {
3701
- _context.next = 15;
4077
+ result.picked = targets;
4078
+ return _context.abrupt("return", result);
4079
+
4080
+ case 17:
4081
+ _context.next = 6;
3702
4082
  break;
3703
- }
3704
4083
 
3705
- result.picked = targets;
3706
- return _context.abrupt("return", result);
4084
+ case 19:
4085
+ _context.next = 24;
4086
+ break;
3707
4087
 
3708
- case 15:
3709
- _context.next = 4;
3710
- break;
4088
+ case 21:
4089
+ _context.prev = 21;
4090
+ _context.t0 = _context["catch"](4);
3711
4091
 
3712
- case 17:
3713
- result.picked = targets;
3714
- _context.next = 23;
3715
- break;
4092
+ _iterator.e(_context.t0);
3716
4093
 
3717
- case 20:
3718
- _context.prev = 20;
3719
- _context.t0 = _context["catch"](1);
3720
- result.picked = [];
4094
+ case 24:
4095
+ _context.prev = 24;
3721
4096
 
3722
- case 23:
3723
- return _context.abrupt("return", result);
4097
+ _iterator.f();
3724
4098
 
3725
- case 24:
3726
- case "end":
3727
- 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
+ }
3728
4118
  }
3729
- }
3730
- }, _callee, null, [[1, 20]]);
3731
- }));
4119
+ }, _callee, null, [[1, 30], [4, 21, 24, 27]]);
4120
+ }));
3732
4121
 
3733
- return function (_x) {
3734
- return _ref.apply(this, arguments);
3735
- };
3736
- }());
3737
- };
4122
+ return function (_x) {
4123
+ return _ref.apply(this, arguments);
4124
+ };
4125
+ }());
4126
+ }
4127
+ }]);
3738
4128
 
3739
4129
  return SVGPickerPlugin;
3740
4130
  }(), _class$2.tag = 'SVGPicker', _class$2);
@@ -3752,18 +4142,22 @@
3752
4142
 
3753
4143
  var Plugin$2 = /*#__PURE__*/function () {
3754
4144
  function Plugin() {
4145
+ _classCallCheck$3(this, Plugin);
4146
+
3755
4147
  this.name = 'svg-picker';
3756
4148
  }
3757
4149
 
3758
- var _proto = Plugin.prototype;
3759
-
3760
- _proto.init = function init(container) {
3761
- container.load(containerModule$2, true);
3762
- };
3763
-
3764
- _proto.destroy = function destroy(container) {
3765
- container.unload(containerModule$2);
3766
- };
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
+ }]);
3767
4161
 
3768
4162
  return Plugin;
3769
4163
  }();
@@ -3775,74 +4169,84 @@
3775
4169
 
3776
4170
  var SVGContextService = /*#__PURE__*/function () {
3777
4171
  function SVGContextService() {
4172
+ _classCallCheck(this, SVGContextService);
4173
+
3778
4174
  this.$container = void 0;
3779
4175
  this.$namespace = void 0;
3780
4176
  this.dpr = void 0;
3781
4177
  this.canvasConfig = void 0;
3782
4178
  }
3783
4179
 
3784
- var _proto = SVGContextService.prototype;
4180
+ _createClass(SVGContextService, [{
4181
+ key: "init",
4182
+ value: function init() {
4183
+ var container = this.canvasConfig.container; // create container
3785
4184
 
3786
- _proto.init = function init() {
3787
- var container = this.canvasConfig.container; // create container
4185
+ this.$container = g.isString(container) ? document.getElementById(container) : container;
3788
4186
 
3789
- 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
+ }
3790
4191
 
3791
- if (this.$container) {
3792
- if (!this.$container.style.position) {
3793
- 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;
3794
4197
  }
3795
4198
 
3796
- var $namespace = createSVGElement('svg');
3797
- $namespace.setAttribute('width', "" + this.canvasConfig.width);
3798
- $namespace.setAttribute('height', "" + this.canvasConfig.height);
3799
- this.$container.appendChild($namespace);
3800
- this.$namespace = $namespace;
3801
- }
3802
-
3803
- var dpr = window.devicePixelRatio || 1;
3804
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
3805
- this.dpr = dpr;
3806
- } // @ts-ignore
3807
- ;
3808
-
3809
- _proto.getDomElement = function getDomElement() {
3810
- return this.$namespace;
3811
- };
3812
-
3813
- _proto.getContext = function getContext() {
3814
- return this.$namespace;
3815
- };
3816
-
3817
- _proto.getDPR = function getDPR() {
3818
- return this.dpr;
3819
- };
3820
-
3821
- _proto.getBoundingClientRect = function getBoundingClientRect() {
3822
- var _this$$namespace;
3823
-
3824
- return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
3825
- };
4199
+ var dpr = window.devicePixelRatio || 1;
4200
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
4201
+ this.dpr = dpr;
4202
+ } // @ts-ignore
3826
4203
 
3827
- _proto.destroy = function destroy() {
3828
- // destroy context
3829
- if (this.$container && this.$namespace && this.$namespace.parentNode) {
3830
- this.$container.removeChild(this.$namespace);
4204
+ }, {
4205
+ key: "getDomElement",
4206
+ value: function getDomElement() {
4207
+ return this.$namespace;
3831
4208
  }
3832
- };
3833
-
3834
- _proto.resize = function resize(width, height) {
3835
- if (this.$namespace) {
3836
- this.$namespace.setAttribute('width', "" + width);
3837
- this.$namespace.setAttribute('height', "" + height);
4209
+ }, {
4210
+ key: "getContext",
4211
+ value: function getContext() {
4212
+ return this.$namespace;
3838
4213
  }
3839
- };
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;
3840
4223
 
3841
- _proto.applyCursorStyle = function applyCursorStyle(cursor) {
3842
- if (this.$container) {
3843
- this.$container.style.cursor = cursor;
4224
+ return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
3844
4225
  }
3845
- };
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
+ }]);
3846
4250
 
3847
4251
  return SVGContextService;
3848
4252
  }();
@@ -3861,29 +4265,37 @@
3861
4265
  });
3862
4266
  var ContextRegisterPlugin = /*#__PURE__*/function () {
3863
4267
  function ContextRegisterPlugin() {
4268
+ _classCallCheck(this, ContextRegisterPlugin);
4269
+
3864
4270
  this.name = 'svg-context-register';
3865
4271
  }
3866
4272
 
3867
- var _proto = ContextRegisterPlugin.prototype;
3868
-
3869
- _proto.init = function init(container) {
3870
- container.load(containerModule$3, true);
3871
- };
3872
-
3873
- _proto.destroy = function destroy(container) {
3874
- container.unload(containerModule$3);
3875
- };
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
+ }]);
3876
4284
 
3877
4285
  return ContextRegisterPlugin;
3878
4286
  }();
3879
4287
 
3880
4288
  var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
3881
- _inheritsLoose(Renderer, _AbstractRenderer);
4289
+ _inherits(Renderer, _AbstractRenderer);
4290
+
4291
+ var _super = _createSuper(Renderer);
3882
4292
 
3883
4293
  function Renderer(config) {
3884
4294
  var _this;
3885
4295
 
3886
- _this = _AbstractRenderer.call(this, config) || this;
4296
+ _classCallCheck(this, Renderer);
4297
+
4298
+ _this = _super.call(this, config);
3887
4299
 
3888
4300
  _this.registerPlugin(new ContextRegisterPlugin());
3889
4301
 
@@ -3896,7 +4308,7 @@
3896
4308
  return _this;
3897
4309
  }
3898
4310
 
3899
- return Renderer;
4311
+ return _createClass(Renderer);
3900
4312
  }(g.AbstractRenderer);
3901
4313
 
3902
4314
  exports.DomInteraction = index_esm;