@antv/g-svg 1.8.54 → 1.8.56

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
@@ -305,6 +305,15 @@
305
305
  }
306
306
  }, exports;
307
307
  }
308
+ function _typeof(obj) {
309
+ "@babel/helpers - typeof";
310
+
311
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
312
+ return typeof obj;
313
+ } : function (obj) {
314
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
315
+ }, _typeof(obj);
316
+ }
308
317
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
309
318
  try {
310
319
  var info = gen[key](arg);
@@ -335,10 +344,49 @@
335
344
  });
336
345
  };
337
346
  }
338
- function _inheritsLoose(subClass, superClass) {
339
- subClass.prototype = Object.create(superClass.prototype);
340
- subClass.prototype.constructor = subClass;
341
- _setPrototypeOf(subClass, superClass);
347
+ function _classCallCheck(instance, Constructor) {
348
+ if (!(instance instanceof Constructor)) {
349
+ throw new TypeError("Cannot call a class as a function");
350
+ }
351
+ }
352
+ function _defineProperties(target, props) {
353
+ for (var i = 0; i < props.length; i++) {
354
+ var descriptor = props[i];
355
+ descriptor.enumerable = descriptor.enumerable || false;
356
+ descriptor.configurable = true;
357
+ if ("value" in descriptor) descriptor.writable = true;
358
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
359
+ }
360
+ }
361
+ function _createClass(Constructor, protoProps, staticProps) {
362
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
363
+ if (staticProps) _defineProperties(Constructor, staticProps);
364
+ Object.defineProperty(Constructor, "prototype", {
365
+ writable: false
366
+ });
367
+ return Constructor;
368
+ }
369
+ function _inherits(subClass, superClass) {
370
+ if (typeof superClass !== "function" && superClass !== null) {
371
+ throw new TypeError("Super expression must either be null or a function");
372
+ }
373
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
374
+ constructor: {
375
+ value: subClass,
376
+ writable: true,
377
+ configurable: true
378
+ }
379
+ });
380
+ Object.defineProperty(subClass, "prototype", {
381
+ writable: false
382
+ });
383
+ if (superClass) _setPrototypeOf(subClass, superClass);
384
+ }
385
+ function _getPrototypeOf(o) {
386
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
387
+ return o.__proto__ || Object.getPrototypeOf(o);
388
+ };
389
+ return _getPrototypeOf(o);
342
390
  }
343
391
  function _setPrototypeOf(o, p) {
344
392
  _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
@@ -347,6 +395,17 @@
347
395
  };
348
396
  return _setPrototypeOf(o, p);
349
397
  }
398
+ function _isNativeReflectConstruct() {
399
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
400
+ if (Reflect.construct.sham) return false;
401
+ if (typeof Proxy === "function") return true;
402
+ try {
403
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
404
+ return true;
405
+ } catch (e) {
406
+ return false;
407
+ }
408
+ }
350
409
  function _objectWithoutPropertiesLoose(source, excluded) {
351
410
  if (source == null) return {};
352
411
  var target = {};
@@ -359,6 +418,63 @@
359
418
  }
360
419
  return target;
361
420
  }
421
+ function _objectWithoutProperties(source, excluded) {
422
+ if (source == null) return {};
423
+ var target = _objectWithoutPropertiesLoose(source, excluded);
424
+ var key, i;
425
+ if (Object.getOwnPropertySymbols) {
426
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
427
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
428
+ key = sourceSymbolKeys[i];
429
+ if (excluded.indexOf(key) >= 0) continue;
430
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
431
+ target[key] = source[key];
432
+ }
433
+ }
434
+ return target;
435
+ }
436
+ function _assertThisInitialized(self) {
437
+ if (self === void 0) {
438
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
439
+ }
440
+ return self;
441
+ }
442
+ function _possibleConstructorReturn(self, call) {
443
+ if (call && (typeof call === "object" || typeof call === "function")) {
444
+ return call;
445
+ } else if (call !== void 0) {
446
+ throw new TypeError("Derived constructors may only return object or undefined");
447
+ }
448
+ return _assertThisInitialized(self);
449
+ }
450
+ function _createSuper(Derived) {
451
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
452
+ return function _createSuperInternal() {
453
+ var Super = _getPrototypeOf(Derived),
454
+ result;
455
+ if (hasNativeReflectConstruct) {
456
+ var NewTarget = _getPrototypeOf(this).constructor;
457
+ result = Reflect.construct(Super, arguments, NewTarget);
458
+ } else {
459
+ result = Super.apply(this, arguments);
460
+ }
461
+ return _possibleConstructorReturn(this, result);
462
+ };
463
+ }
464
+ function _toPrimitive(input, hint) {
465
+ if (typeof input !== "object" || input === null) return input;
466
+ var prim = input[Symbol.toPrimitive];
467
+ if (prim !== undefined) {
468
+ var res = prim.call(input, hint || "default");
469
+ if (typeof res !== "object") return res;
470
+ throw new TypeError("@@toPrimitive must return a primitive value.");
471
+ }
472
+ return (hint === "string" ? String : Number)(input);
473
+ }
474
+ function _toPropertyKey(arg) {
475
+ var key = _toPrimitive(arg, "string");
476
+ return typeof key === "symbol" ? key : String(key);
477
+ }
362
478
 
363
479
  function _regeneratorRuntime$1() {
364
480
  _regeneratorRuntime$1 = function _regeneratorRuntime() {
@@ -436,7 +552,7 @@
436
552
  if ("throw" !== record.type) {
437
553
  var result = record.arg,
438
554
  value = result.value;
439
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
555
+ return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
440
556
  invoke("next", value, resolve, reject);
441
557
  }, function (err) {
442
558
  invoke("throw", err, resolve, reject);
@@ -691,10 +807,49 @@
691
807
  });
692
808
  };
693
809
  }
694
- function _inheritsLoose$1(subClass, superClass) {
695
- subClass.prototype = Object.create(superClass.prototype);
696
- subClass.prototype.constructor = subClass;
697
- _setPrototypeOf$1(subClass, superClass);
810
+ function _classCallCheck$1(instance, Constructor) {
811
+ if (!(instance instanceof Constructor)) {
812
+ throw new TypeError("Cannot call a class as a function");
813
+ }
814
+ }
815
+ function _defineProperties$1(target, props) {
816
+ for (var i = 0; i < props.length; i++) {
817
+ var descriptor = props[i];
818
+ descriptor.enumerable = descriptor.enumerable || false;
819
+ descriptor.configurable = true;
820
+ if ("value" in descriptor) descriptor.writable = true;
821
+ Object.defineProperty(target, _toPropertyKey$1(descriptor.key), descriptor);
822
+ }
823
+ }
824
+ function _createClass$1(Constructor, protoProps, staticProps) {
825
+ if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
826
+ if (staticProps) _defineProperties$1(Constructor, staticProps);
827
+ Object.defineProperty(Constructor, "prototype", {
828
+ writable: false
829
+ });
830
+ return Constructor;
831
+ }
832
+ function _inherits$1(subClass, superClass) {
833
+ if (typeof superClass !== "function" && superClass !== null) {
834
+ throw new TypeError("Super expression must either be null or a function");
835
+ }
836
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
837
+ constructor: {
838
+ value: subClass,
839
+ writable: true,
840
+ configurable: true
841
+ }
842
+ });
843
+ Object.defineProperty(subClass, "prototype", {
844
+ writable: false
845
+ });
846
+ if (superClass) _setPrototypeOf$1(subClass, superClass);
847
+ }
848
+ function _getPrototypeOf$1(o) {
849
+ _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
850
+ return o.__proto__ || Object.getPrototypeOf(o);
851
+ };
852
+ return _getPrototypeOf$1(o);
698
853
  }
699
854
  function _setPrototypeOf$1(o, p) {
700
855
  _setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
@@ -703,6 +858,59 @@
703
858
  };
704
859
  return _setPrototypeOf$1(o, p);
705
860
  }
861
+ function _isNativeReflectConstruct$1() {
862
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
863
+ if (Reflect.construct.sham) return false;
864
+ if (typeof Proxy === "function") return true;
865
+ try {
866
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
867
+ return true;
868
+ } catch (e) {
869
+ return false;
870
+ }
871
+ }
872
+ function _assertThisInitialized$1(self) {
873
+ if (self === void 0) {
874
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
875
+ }
876
+ return self;
877
+ }
878
+ function _possibleConstructorReturn$1(self, call) {
879
+ if (call && (_typeof(call) === "object" || typeof call === "function")) {
880
+ return call;
881
+ } else if (call !== void 0) {
882
+ throw new TypeError("Derived constructors may only return object or undefined");
883
+ }
884
+ return _assertThisInitialized$1(self);
885
+ }
886
+ function _createSuper$1(Derived) {
887
+ var hasNativeReflectConstruct = _isNativeReflectConstruct$1();
888
+ return function _createSuperInternal() {
889
+ var Super = _getPrototypeOf$1(Derived),
890
+ result;
891
+ if (hasNativeReflectConstruct) {
892
+ var NewTarget = _getPrototypeOf$1(this).constructor;
893
+ result = Reflect.construct(Super, arguments, NewTarget);
894
+ } else {
895
+ result = Super.apply(this, arguments);
896
+ }
897
+ return _possibleConstructorReturn$1(this, result);
898
+ };
899
+ }
900
+ function _toPrimitive$1(input, hint) {
901
+ if (_typeof(input) !== "object" || input === null) return input;
902
+ var prim = input[Symbol.toPrimitive];
903
+ if (prim !== undefined) {
904
+ var res = prim.call(input, hint || "default");
905
+ if (_typeof(res) !== "object") return res;
906
+ throw new TypeError("@@toPrimitive must return a primitive value.");
907
+ }
908
+ return (hint === "string" ? String : Number)(input);
909
+ }
910
+ function _toPropertyKey$1(arg) {
911
+ var key = _toPrimitive$1(arg, "string");
912
+ return _typeof(key) === "symbol" ? key : String(key);
913
+ }
706
914
 
707
915
  // const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
708
916
  /**
@@ -710,164 +918,174 @@
710
918
  */
711
919
  var DOMInteractionPlugin = /*#__PURE__*/function () {
712
920
  function DOMInteractionPlugin() {
921
+ _classCallCheck$1(this, DOMInteractionPlugin);
713
922
  this.context = void 0;
714
923
  }
715
- var _proto = DOMInteractionPlugin.prototype;
716
- _proto.apply = function apply(context, runtime) {
717
- var _this = this;
718
- var renderingService = context.renderingService,
719
- renderingContext = context.renderingContext,
720
- config = context.config;
721
- this.context = context;
722
- var canvas = renderingContext.root.ownerDocument.defaultView;
723
- // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
724
- var onPointerMove = function onPointerMove(ev) {
725
- renderingService.hooks.pointerMove.call(ev);
726
- };
727
- var onPointerUp = function onPointerUp(ev) {
728
- renderingService.hooks.pointerUp.call(ev);
729
- };
730
- var onPointerDown = function onPointerDown(ev) {
731
- renderingService.hooks.pointerDown.call(ev);
732
- };
733
- var onPointerOver = function onPointerOver(ev) {
734
- renderingService.hooks.pointerOver.call(ev);
735
- };
736
- var onPointerOut = function onPointerOut(ev) {
737
- renderingService.hooks.pointerOut.call(ev);
738
- };
739
- var onPointerCancel = function onPointerCancel(ev) {
740
- renderingService.hooks.pointerCancel.call(ev);
741
- };
742
- var onPointerWheel = function onPointerWheel(ev) {
743
- renderingService.hooks.pointerWheel.call(ev);
744
- };
745
- var onClick = function onClick(ev) {
746
- renderingService.hooks.click.call(ev);
747
- };
748
- var addPointerEventListener = function addPointerEventListener($el) {
749
- runtime.globalThis.document.addEventListener('pointermove', onPointerMove, true);
750
- $el.addEventListener('pointerdown', onPointerDown, true);
751
- $el.addEventListener('pointerleave', onPointerOut, true);
752
- $el.addEventListener('pointerover', onPointerOver, true);
753
- runtime.globalThis.addEventListener('pointerup', onPointerUp, true);
754
- };
755
- var addTouchEventListener = function addTouchEventListener($el) {
756
- $el.addEventListener('touchstart', onPointerDown, true);
757
- $el.addEventListener('touchend', onPointerUp, true);
758
- $el.addEventListener('touchmove', onPointerMove, true);
759
- $el.addEventListener('touchcancel', onPointerCancel, true);
760
- };
761
- var addMouseEventListener = function addMouseEventListener($el) {
762
- runtime.globalThis.document.addEventListener('mousemove', onPointerMove, true);
763
- $el.addEventListener('mousedown', onPointerDown, true);
764
- $el.addEventListener('mouseout', onPointerOut, true);
765
- $el.addEventListener('mouseover', onPointerOver, true);
766
- runtime.globalThis.addEventListener('mouseup', onPointerUp, true);
767
- };
768
- var removePointerEventListener = function removePointerEventListener($el) {
769
- runtime.globalThis.document.removeEventListener('pointermove', onPointerMove, true);
770
- $el.removeEventListener('pointerdown', onPointerDown, true);
771
- $el.removeEventListener('pointerleave', onPointerOut, true);
772
- $el.removeEventListener('pointerover', onPointerOver, true);
773
- runtime.globalThis.removeEventListener('pointerup', onPointerUp, true);
774
- };
775
- var removeTouchEventListener = function removeTouchEventListener($el) {
776
- $el.removeEventListener('touchstart', onPointerDown, true);
777
- $el.removeEventListener('touchend', onPointerUp, true);
778
- $el.removeEventListener('touchmove', onPointerMove, true);
779
- $el.removeEventListener('touchcancel', onPointerCancel, true);
780
- };
781
- var removeMouseEventListener = function removeMouseEventListener($el) {
782
- runtime.globalThis.document.removeEventListener('mousemove', onPointerMove, true);
783
- $el.removeEventListener('mousedown', onPointerDown, true);
784
- $el.removeEventListener('mouseout', onPointerOut, true);
785
- $el.removeEventListener('mouseover', onPointerOver, true);
786
- runtime.globalThis.removeEventListener('mouseup', onPointerUp, true);
787
- };
788
- renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
789
- var $el;
790
- return _regeneratorRuntime$1().wrap(function _callee$(_context) {
791
- while (1) switch (_context.prev = _context.next) {
792
- case 0:
793
- $el = _this.context.contextService.getDomElement(); // @ts-ignore
794
- if (runtime.globalThis.navigator.msPointerEnabled) {
795
- // @ts-ignore
796
- $el.style.msContentZooming = 'none';
797
- // @ts-ignore
798
- $el.style.msTouchAction = 'none';
799
- } else if (canvas.supportsPointerEvents) {
800
- $el.style.touchAction = 'none';
801
- }
802
- if (canvas.supportsPointerEvents) {
803
- addPointerEventListener($el);
804
- } else {
805
- addMouseEventListener($el);
806
- }
807
- if (canvas.supportsTouchEvents) {
808
- addTouchEventListener($el);
809
- }
810
- if (config.useNativeClickEvent) {
811
- $el.addEventListener('click', onClick, true);
812
- }
813
- // use passive event listeners
814
- // @see https://zhuanlan.zhihu.com/p/24555031
815
- $el.addEventListener('wheel', onPointerWheel, {
816
- passive: true,
817
- capture: true
818
- });
819
- case 6:
820
- case "end":
821
- return _context.stop();
822
- }
823
- }, _callee);
824
- })));
825
- renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () {
826
- var $el = _this.context.contextService.getDomElement();
827
- // @ts-ignore
828
- if (runtime.globalThis.navigator.msPointerEnabled) {
829
- // @ts-ignore
830
- $el.style.msContentZooming = '';
924
+ _createClass$1(DOMInteractionPlugin, [{
925
+ key: "apply",
926
+ value: function apply(context, runtime) {
927
+ var _this = this;
928
+ var renderingService = context.renderingService,
929
+ renderingContext = context.renderingContext,
930
+ config = context.config;
931
+ this.context = context;
932
+ var canvas = renderingContext.root.ownerDocument.defaultView;
933
+ // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
934
+ var onPointerMove = function onPointerMove(ev) {
935
+ renderingService.hooks.pointerMove.call(ev);
936
+ };
937
+ var onPointerUp = function onPointerUp(ev) {
938
+ renderingService.hooks.pointerUp.call(ev);
939
+ };
940
+ var onPointerDown = function onPointerDown(ev) {
941
+ renderingService.hooks.pointerDown.call(ev);
942
+ };
943
+ var onPointerOver = function onPointerOver(ev) {
944
+ renderingService.hooks.pointerOver.call(ev);
945
+ };
946
+ var onPointerOut = function onPointerOut(ev) {
947
+ renderingService.hooks.pointerOut.call(ev);
948
+ };
949
+ var onPointerCancel = function onPointerCancel(ev) {
950
+ renderingService.hooks.pointerCancel.call(ev);
951
+ };
952
+ var onPointerWheel = function onPointerWheel(ev) {
953
+ renderingService.hooks.pointerWheel.call(ev);
954
+ };
955
+ var onClick = function onClick(ev) {
956
+ renderingService.hooks.click.call(ev);
957
+ };
958
+ var addPointerEventListener = function addPointerEventListener($el) {
959
+ runtime.globalThis.document.addEventListener('pointermove', onPointerMove, true);
960
+ $el.addEventListener('pointerdown', onPointerDown, true);
961
+ $el.addEventListener('pointerleave', onPointerOut, true);
962
+ $el.addEventListener('pointerover', onPointerOver, true);
963
+ runtime.globalThis.addEventListener('pointerup', onPointerUp, true);
964
+ runtime.globalThis.addEventListener('pointercancel', onPointerCancel, true);
965
+ };
966
+ var addTouchEventListener = function addTouchEventListener($el) {
967
+ $el.addEventListener('touchstart', onPointerDown, true);
968
+ $el.addEventListener('touchend', onPointerUp, true);
969
+ $el.addEventListener('touchmove', onPointerMove, true);
970
+ $el.addEventListener('touchcancel', onPointerCancel, true);
971
+ };
972
+ var addMouseEventListener = function addMouseEventListener($el) {
973
+ runtime.globalThis.document.addEventListener('mousemove', onPointerMove, true);
974
+ $el.addEventListener('mousedown', onPointerDown, true);
975
+ $el.addEventListener('mouseout', onPointerOut, true);
976
+ $el.addEventListener('mouseover', onPointerOver, true);
977
+ runtime.globalThis.addEventListener('mouseup', onPointerUp, true);
978
+ };
979
+ var removePointerEventListener = function removePointerEventListener($el) {
980
+ runtime.globalThis.document.removeEventListener('pointermove', onPointerMove, true);
981
+ $el.removeEventListener('pointerdown', onPointerDown, true);
982
+ $el.removeEventListener('pointerleave', onPointerOut, true);
983
+ $el.removeEventListener('pointerover', onPointerOver, true);
984
+ runtime.globalThis.removeEventListener('pointerup', onPointerUp, true);
985
+ };
986
+ var removeTouchEventListener = function removeTouchEventListener($el) {
987
+ $el.removeEventListener('touchstart', onPointerDown, true);
988
+ $el.removeEventListener('touchend', onPointerUp, true);
989
+ $el.removeEventListener('touchmove', onPointerMove, true);
990
+ $el.removeEventListener('touchcancel', onPointerCancel, true);
991
+ };
992
+ var removeMouseEventListener = function removeMouseEventListener($el) {
993
+ runtime.globalThis.document.removeEventListener('mousemove', onPointerMove, true);
994
+ $el.removeEventListener('mousedown', onPointerDown, true);
995
+ $el.removeEventListener('mouseout', onPointerOut, true);
996
+ $el.removeEventListener('mouseover', onPointerOver, true);
997
+ runtime.globalThis.removeEventListener('mouseup', onPointerUp, true);
998
+ };
999
+ renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
1000
+ var $el;
1001
+ return _regeneratorRuntime$1().wrap(function _callee$(_context) {
1002
+ while (1) switch (_context.prev = _context.next) {
1003
+ case 0:
1004
+ $el = _this.context.contextService.getDomElement(); // @ts-ignore
1005
+ if (runtime.globalThis.navigator.msPointerEnabled) {
1006
+ // @ts-ignore
1007
+ $el.style.msContentZooming = 'none';
1008
+ // @ts-ignore
1009
+ $el.style.msTouchAction = 'none';
1010
+ } else if (canvas.supportsPointerEvents) {
1011
+ $el.style.touchAction = 'none';
1012
+ }
1013
+ if (canvas.supportsPointerEvents) {
1014
+ addPointerEventListener($el);
1015
+ } else {
1016
+ addMouseEventListener($el);
1017
+ }
1018
+ if (canvas.supportsTouchEvents) {
1019
+ addTouchEventListener($el);
1020
+ }
1021
+ if (config.useNativeClickEvent) {
1022
+ $el.addEventListener('click', onClick, true);
1023
+ }
1024
+ // use passive event listeners
1025
+ // @see https://zhuanlan.zhihu.com/p/24555031
1026
+ $el.addEventListener('wheel', onPointerWheel, {
1027
+ passive: true,
1028
+ capture: true
1029
+ });
1030
+ case 6:
1031
+ case "end":
1032
+ return _context.stop();
1033
+ }
1034
+ }, _callee);
1035
+ })));
1036
+ renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () {
1037
+ var $el = _this.context.contextService.getDomElement();
831
1038
  // @ts-ignore
832
- $el.style.msTouchAction = '';
833
- } else if (canvas.supportsPointerEvents) {
834
- $el.style.touchAction = '';
835
- }
836
- if (canvas.supportsPointerEvents) {
837
- removePointerEventListener($el);
838
- } else {
839
- removeMouseEventListener($el);
840
- }
841
- if (canvas.supportsTouchEvents) {
842
- removeTouchEventListener($el);
843
- }
844
- if (config.useNativeClickEvent) {
845
- $el.removeEventListener('click', onClick, true);
846
- }
847
- $el.removeEventListener('wheel', onPointerWheel, true);
848
- });
849
- };
1039
+ if (runtime.globalThis.navigator.msPointerEnabled) {
1040
+ // @ts-ignore
1041
+ $el.style.msContentZooming = '';
1042
+ // @ts-ignore
1043
+ $el.style.msTouchAction = '';
1044
+ } else if (canvas.supportsPointerEvents) {
1045
+ $el.style.touchAction = '';
1046
+ }
1047
+ if (canvas.supportsPointerEvents) {
1048
+ removePointerEventListener($el);
1049
+ } else {
1050
+ removeMouseEventListener($el);
1051
+ }
1052
+ if (canvas.supportsTouchEvents) {
1053
+ removeTouchEventListener($el);
1054
+ }
1055
+ if (config.useNativeClickEvent) {
1056
+ $el.removeEventListener('click', onClick, true);
1057
+ }
1058
+ $el.removeEventListener('wheel', onPointerWheel, true);
1059
+ });
1060
+ }
1061
+ }]);
850
1062
  return DOMInteractionPlugin;
851
1063
  }();
852
1064
  DOMInteractionPlugin.tag = 'DOMInteraction';
853
1065
  var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
854
- _inheritsLoose$1(Plugin, _AbstractRendererPlug);
1066
+ _inherits$1(Plugin, _AbstractRendererPlug);
1067
+ var _super = _createSuper$1(Plugin);
855
1068
  function Plugin() {
856
1069
  var _this;
1070
+ _classCallCheck$1(this, Plugin);
857
1071
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
858
1072
  args[_key] = arguments[_key];
859
1073
  }
860
- _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
1074
+ _this = _super.call.apply(_super, [this].concat(args));
861
1075
  _this.name = 'dom-interaction';
862
1076
  return _this;
863
1077
  }
864
- var _proto = Plugin.prototype;
865
- _proto.init = function init() {
866
- this.addRenderingPlugin(new DOMInteractionPlugin());
867
- };
868
- _proto.destroy = function destroy() {
869
- this.removeAllRenderingPlugins();
870
- };
1078
+ _createClass$1(Plugin, [{
1079
+ key: "init",
1080
+ value: function init() {
1081
+ this.addRenderingPlugin(new DOMInteractionPlugin());
1082
+ }
1083
+ }, {
1084
+ key: "destroy",
1085
+ value: function destroy() {
1086
+ this.removeAllRenderingPlugins();
1087
+ }
1088
+ }]);
871
1089
  return Plugin;
872
1090
  }(gLite.AbstractRendererPlugin);
873
1091
 
@@ -952,7 +1170,7 @@
952
1170
  if ("throw" !== record.type) {
953
1171
  var result = record.arg,
954
1172
  value = result.value;
955
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
1173
+ return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
956
1174
  invoke("next", value, resolve, reject);
957
1175
  }, function (err) {
958
1176
  invoke("throw", err, resolve, reject);
@@ -1207,10 +1425,49 @@
1207
1425
  });
1208
1426
  };
1209
1427
  }
1210
- function _inheritsLoose$2(subClass, superClass) {
1211
- subClass.prototype = Object.create(superClass.prototype);
1212
- subClass.prototype.constructor = subClass;
1213
- _setPrototypeOf$2(subClass, superClass);
1428
+ function _classCallCheck$2(instance, Constructor) {
1429
+ if (!(instance instanceof Constructor)) {
1430
+ throw new TypeError("Cannot call a class as a function");
1431
+ }
1432
+ }
1433
+ function _defineProperties$2(target, props) {
1434
+ for (var i = 0; i < props.length; i++) {
1435
+ var descriptor = props[i];
1436
+ descriptor.enumerable = descriptor.enumerable || false;
1437
+ descriptor.configurable = true;
1438
+ if ("value" in descriptor) descriptor.writable = true;
1439
+ Object.defineProperty(target, _toPropertyKey$2(descriptor.key), descriptor);
1440
+ }
1441
+ }
1442
+ function _createClass$2(Constructor, protoProps, staticProps) {
1443
+ if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
1444
+ if (staticProps) _defineProperties$2(Constructor, staticProps);
1445
+ Object.defineProperty(Constructor, "prototype", {
1446
+ writable: false
1447
+ });
1448
+ return Constructor;
1449
+ }
1450
+ function _inherits$2(subClass, superClass) {
1451
+ if (typeof superClass !== "function" && superClass !== null) {
1452
+ throw new TypeError("Super expression must either be null or a function");
1453
+ }
1454
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
1455
+ constructor: {
1456
+ value: subClass,
1457
+ writable: true,
1458
+ configurable: true
1459
+ }
1460
+ });
1461
+ Object.defineProperty(subClass, "prototype", {
1462
+ writable: false
1463
+ });
1464
+ if (superClass) _setPrototypeOf$2(subClass, superClass);
1465
+ }
1466
+ function _getPrototypeOf$2(o) {
1467
+ _getPrototypeOf$2 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
1468
+ return o.__proto__ || Object.getPrototypeOf(o);
1469
+ };
1470
+ return _getPrototypeOf$2(o);
1214
1471
  }
1215
1472
  function _setPrototypeOf$2(o, p) {
1216
1473
  _setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
@@ -1219,6 +1476,45 @@
1219
1476
  };
1220
1477
  return _setPrototypeOf$2(o, p);
1221
1478
  }
1479
+ function _isNativeReflectConstruct$2() {
1480
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
1481
+ if (Reflect.construct.sham) return false;
1482
+ if (typeof Proxy === "function") return true;
1483
+ try {
1484
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
1485
+ return true;
1486
+ } catch (e) {
1487
+ return false;
1488
+ }
1489
+ }
1490
+ function _assertThisInitialized$2(self) {
1491
+ if (self === void 0) {
1492
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1493
+ }
1494
+ return self;
1495
+ }
1496
+ function _possibleConstructorReturn$2(self, call) {
1497
+ if (call && (_typeof(call) === "object" || typeof call === "function")) {
1498
+ return call;
1499
+ } else if (call !== void 0) {
1500
+ throw new TypeError("Derived constructors may only return object or undefined");
1501
+ }
1502
+ return _assertThisInitialized$2(self);
1503
+ }
1504
+ function _createSuper$2(Derived) {
1505
+ var hasNativeReflectConstruct = _isNativeReflectConstruct$2();
1506
+ return function _createSuperInternal() {
1507
+ var Super = _getPrototypeOf$2(Derived),
1508
+ result;
1509
+ if (hasNativeReflectConstruct) {
1510
+ var NewTarget = _getPrototypeOf$2(this).constructor;
1511
+ result = Reflect.construct(Super, arguments, NewTarget);
1512
+ } else {
1513
+ result = Super.apply(this, arguments);
1514
+ }
1515
+ return _possibleConstructorReturn$2(this, result);
1516
+ };
1517
+ }
1222
1518
  function _unsupportedIterableToArray(o, minLen) {
1223
1519
  if (!o) return;
1224
1520
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
@@ -1232,23 +1528,70 @@
1232
1528
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
1233
1529
  return arr2;
1234
1530
  }
1235
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
1531
+ function _createForOfIteratorHelper(o, allowArrayLike) {
1236
1532
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
1237
- if (it) return (it = it.call(o)).next.bind(it);
1238
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
1239
- if (it) o = it;
1240
- var i = 0;
1241
- return function () {
1242
- if (i >= o.length) return {
1243
- done: true
1244
- };
1533
+ if (!it) {
1534
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
1535
+ if (it) o = it;
1536
+ var i = 0;
1537
+ var F = function F() {};
1245
1538
  return {
1246
- done: false,
1247
- value: o[i++]
1539
+ s: F,
1540
+ n: function n() {
1541
+ if (i >= o.length) return {
1542
+ done: true
1543
+ };
1544
+ return {
1545
+ done: false,
1546
+ value: o[i++]
1547
+ };
1548
+ },
1549
+ e: function e(_e) {
1550
+ throw _e;
1551
+ },
1552
+ f: F
1248
1553
  };
1249
- };
1554
+ }
1555
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1556
+ }
1557
+ var normalCompletion = true,
1558
+ didErr = false,
1559
+ err;
1560
+ return {
1561
+ s: function s() {
1562
+ it = it.call(o);
1563
+ },
1564
+ n: function n() {
1565
+ var step = it.next();
1566
+ normalCompletion = step.done;
1567
+ return step;
1568
+ },
1569
+ e: function e(_e2) {
1570
+ didErr = true;
1571
+ err = _e2;
1572
+ },
1573
+ f: function f() {
1574
+ try {
1575
+ if (!normalCompletion && it.return != null) it.return();
1576
+ } finally {
1577
+ if (didErr) throw err;
1578
+ }
1579
+ }
1580
+ };
1581
+ }
1582
+ function _toPrimitive$2(input, hint) {
1583
+ if (_typeof(input) !== "object" || input === null) return input;
1584
+ var prim = input[Symbol.toPrimitive];
1585
+ if (prim !== undefined) {
1586
+ var res = prim.call(input, hint || "default");
1587
+ if (_typeof(res) !== "object") return res;
1588
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1250
1589
  }
1251
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1590
+ return (hint === "string" ? String : Number)(input);
1591
+ }
1592
+ function _toPropertyKey$2(arg) {
1593
+ var key = _toPrimitive$2(arg, "string");
1594
+ return _typeof(key) === "symbol" ? key : String(key);
1252
1595
  }
1253
1596
 
1254
1597
  /**
@@ -1258,80 +1601,100 @@
1258
1601
  * 2. use elementFromPoint
1259
1602
  */
1260
1603
  var SVGPickerPlugin = /*#__PURE__*/function () {
1261
- function SVGPickerPlugin() {}
1262
- var _proto = SVGPickerPlugin.prototype;
1263
- _proto.apply = function apply(context, runtime) {
1264
- var _this = this;
1265
- var doc = context.config.document,
1266
- renderingService = context.renderingService,
1267
- svgElementMap = context.svgElementMap;
1268
- renderingService.hooks.pick.tapPromise(SVGPickerPlugin.tag, /*#__PURE__*/function () {
1269
- var _ref = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee(result) {
1270
- return _regeneratorRuntime$2().wrap(function _callee$(_context) {
1271
- while (1) switch (_context.prev = _context.next) {
1272
- case 0:
1273
- return _context.abrupt("return", _this.pick(svgElementMap, doc, result));
1274
- case 1:
1275
- case "end":
1276
- return _context.stop();
1277
- }
1278
- }, _callee);
1279
- }));
1280
- return function (_x) {
1281
- return _ref.apply(this, arguments);
1282
- };
1283
- }());
1284
- renderingService.hooks.pickSync.tap(SVGPickerPlugin.tag, function (result) {
1285
- return _this.pick(svgElementMap, doc, result);
1286
- });
1287
- };
1288
- _proto.pick = function pick(svgElementMap, doc, result) {
1289
- var topmost = result.topmost,
1290
- _result$position = result.position,
1291
- clientX = _result$position.clientX,
1292
- clientY = _result$position.clientY;
1293
- try {
1294
- var targets = [];
1295
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
1296
- for (var _iterator = _createForOfIteratorHelperLoose((doc || document).elementsFromPoint(clientX, clientY)), _step; !(_step = _iterator()).done;) {
1297
- var element = _step.value;
1298
- var target = svgElementMap.get(element);
1299
- // don't need to account for `visibility` since DOM API already does
1300
- if (target && target.isInteractive()) {
1301
- targets.push(target);
1302
- if (topmost) {
1303
- result.picked = targets;
1304
- return result;
1604
+ function SVGPickerPlugin() {
1605
+ _classCallCheck$2(this, SVGPickerPlugin);
1606
+ }
1607
+ _createClass$2(SVGPickerPlugin, [{
1608
+ key: "apply",
1609
+ value: function apply(context, runtime) {
1610
+ var _this = this;
1611
+ var doc = context.config.document,
1612
+ renderingService = context.renderingService,
1613
+ svgElementMap = context.svgElementMap;
1614
+ renderingService.hooks.pick.tapPromise(SVGPickerPlugin.tag, /*#__PURE__*/function () {
1615
+ var _ref = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee(result) {
1616
+ return _regeneratorRuntime$2().wrap(function _callee$(_context) {
1617
+ while (1) switch (_context.prev = _context.next) {
1618
+ case 0:
1619
+ return _context.abrupt("return", _this.pick(svgElementMap, doc, result));
1620
+ case 1:
1621
+ case "end":
1622
+ return _context.stop();
1623
+ }
1624
+ }, _callee);
1625
+ }));
1626
+ return function (_x) {
1627
+ return _ref.apply(this, arguments);
1628
+ };
1629
+ }());
1630
+ renderingService.hooks.pickSync.tap(SVGPickerPlugin.tag, function (result) {
1631
+ return _this.pick(svgElementMap, doc, result);
1632
+ });
1633
+ }
1634
+ }, {
1635
+ key: "pick",
1636
+ value: function pick(svgElementMap, doc, result) {
1637
+ var topmost = result.topmost,
1638
+ _result$position = result.position,
1639
+ clientX = _result$position.clientX,
1640
+ clientY = _result$position.clientY;
1641
+ try {
1642
+ var targets = [];
1643
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
1644
+ var _iterator = _createForOfIteratorHelper((doc || document).elementsFromPoint(clientX, clientY)),
1645
+ _step;
1646
+ try {
1647
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1648
+ var element = _step.value;
1649
+ var target = svgElementMap.get(element);
1650
+ // don't need to account for `visibility` since DOM API already does
1651
+ if (target && target.isInteractive()) {
1652
+ targets.push(target);
1653
+ if (topmost) {
1654
+ result.picked = targets;
1655
+ return result;
1656
+ }
1657
+ }
1305
1658
  }
1659
+ } catch (err) {
1660
+ _iterator.e(err);
1661
+ } finally {
1662
+ _iterator.f();
1306
1663
  }
1664
+ result.picked = targets;
1665
+ } catch (e) {
1666
+ result.picked = [];
1307
1667
  }
1308
- result.picked = targets;
1309
- } catch (e) {
1310
- result.picked = [];
1668
+ return result;
1311
1669
  }
1312
- return result;
1313
- };
1670
+ }]);
1314
1671
  return SVGPickerPlugin;
1315
1672
  }();
1316
1673
  SVGPickerPlugin.tag = 'SVGPicker';
1317
1674
  var Plugin$1 = /*#__PURE__*/function (_AbstractRendererPlug) {
1318
- _inheritsLoose$2(Plugin, _AbstractRendererPlug);
1675
+ _inherits$2(Plugin, _AbstractRendererPlug);
1676
+ var _super = _createSuper$2(Plugin);
1319
1677
  function Plugin() {
1320
1678
  var _this;
1679
+ _classCallCheck$2(this, Plugin);
1321
1680
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1322
1681
  args[_key] = arguments[_key];
1323
1682
  }
1324
- _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
1683
+ _this = _super.call.apply(_super, [this].concat(args));
1325
1684
  _this.name = 'svg-picker';
1326
1685
  return _this;
1327
1686
  }
1328
- var _proto = Plugin.prototype;
1329
- _proto.init = function init() {
1330
- this.addRenderingPlugin(new SVGPickerPlugin());
1331
- };
1332
- _proto.destroy = function destroy() {
1333
- this.removeAllRenderingPlugins();
1334
- };
1687
+ _createClass$2(Plugin, [{
1688
+ key: "init",
1689
+ value: function init() {
1690
+ this.addRenderingPlugin(new SVGPickerPlugin());
1691
+ }
1692
+ }, {
1693
+ key: "destroy",
1694
+ value: function destroy() {
1695
+ this.removeAllRenderingPlugins();
1696
+ }
1697
+ }]);
1335
1698
  return Plugin;
1336
1699
  }(gLite.AbstractRendererPlugin);
1337
1700
 
@@ -1481,6 +1844,54 @@
1481
1844
  return a;
1482
1845
  };
1483
1846
 
1847
+ function _iterableToArrayLimit(arr, i) {
1848
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
1849
+ if (null != _i) {
1850
+ var _s,
1851
+ _e,
1852
+ _x,
1853
+ _r,
1854
+ _arr = [],
1855
+ _n = !0,
1856
+ _d = !1;
1857
+ try {
1858
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
1859
+ if (Object(_i) !== _i) return;
1860
+ _n = !1;
1861
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
1862
+ } catch (err) {
1863
+ _d = !0, _e = err;
1864
+ } finally {
1865
+ try {
1866
+ if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
1867
+ } finally {
1868
+ if (_d) throw _e;
1869
+ }
1870
+ }
1871
+ return _arr;
1872
+ }
1873
+ }
1874
+ function ownKeys(object, enumerableOnly) {
1875
+ var keys = Object.keys(object);
1876
+ if (Object.getOwnPropertySymbols) {
1877
+ var symbols = Object.getOwnPropertySymbols(object);
1878
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
1879
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1880
+ })), keys.push.apply(keys, symbols);
1881
+ }
1882
+ return keys;
1883
+ }
1884
+ function _objectSpread2(target) {
1885
+ for (var i = 1; i < arguments.length; i++) {
1886
+ var source = null != arguments[i] ? arguments[i] : {};
1887
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
1888
+ _defineProperty(target, key, source[key]);
1889
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
1890
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1891
+ });
1892
+ }
1893
+ return target;
1894
+ }
1484
1895
  function _regeneratorRuntime$3() {
1485
1896
  _regeneratorRuntime$3 = function _regeneratorRuntime() {
1486
1897
  return exports;
@@ -1557,7 +1968,7 @@
1557
1968
  if ("throw" !== record.type) {
1558
1969
  var result = record.arg,
1559
1970
  value = result.value;
1560
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
1971
+ return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
1561
1972
  invoke("next", value, resolve, reject);
1562
1973
  }, function (err) {
1563
1974
  invoke("throw", err, resolve, reject);
@@ -1812,24 +2223,63 @@
1812
2223
  });
1813
2224
  };
1814
2225
  }
1815
- function _extends() {
1816
- _extends = Object.assign ? Object.assign.bind() : function (target) {
1817
- for (var i = 1; i < arguments.length; i++) {
1818
- var source = arguments[i];
1819
- for (var key in source) {
1820
- if (Object.prototype.hasOwnProperty.call(source, key)) {
1821
- target[key] = source[key];
1822
- }
1823
- }
2226
+ function _classCallCheck$3(instance, Constructor) {
2227
+ if (!(instance instanceof Constructor)) {
2228
+ throw new TypeError("Cannot call a class as a function");
2229
+ }
2230
+ }
2231
+ function _defineProperties$3(target, props) {
2232
+ for (var i = 0; i < props.length; i++) {
2233
+ var descriptor = props[i];
2234
+ descriptor.enumerable = descriptor.enumerable || false;
2235
+ descriptor.configurable = true;
2236
+ if ("value" in descriptor) descriptor.writable = true;
2237
+ Object.defineProperty(target, _toPropertyKey$3(descriptor.key), descriptor);
2238
+ }
2239
+ }
2240
+ function _createClass$3(Constructor, protoProps, staticProps) {
2241
+ if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
2242
+ if (staticProps) _defineProperties$3(Constructor, staticProps);
2243
+ Object.defineProperty(Constructor, "prototype", {
2244
+ writable: false
2245
+ });
2246
+ return Constructor;
2247
+ }
2248
+ function _defineProperty(obj, key, value) {
2249
+ key = _toPropertyKey$3(key);
2250
+ if (key in obj) {
2251
+ Object.defineProperty(obj, key, {
2252
+ value: value,
2253
+ enumerable: true,
2254
+ configurable: true,
2255
+ writable: true
2256
+ });
2257
+ } else {
2258
+ obj[key] = value;
2259
+ }
2260
+ return obj;
2261
+ }
2262
+ function _inherits$3(subClass, superClass) {
2263
+ if (typeof superClass !== "function" && superClass !== null) {
2264
+ throw new TypeError("Super expression must either be null or a function");
2265
+ }
2266
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
2267
+ constructor: {
2268
+ value: subClass,
2269
+ writable: true,
2270
+ configurable: true
1824
2271
  }
1825
- return target;
1826
- };
1827
- return _extends.apply(this, arguments);
2272
+ });
2273
+ Object.defineProperty(subClass, "prototype", {
2274
+ writable: false
2275
+ });
2276
+ if (superClass) _setPrototypeOf$3(subClass, superClass);
1828
2277
  }
1829
- function _inheritsLoose$3(subClass, superClass) {
1830
- subClass.prototype = Object.create(superClass.prototype);
1831
- subClass.prototype.constructor = subClass;
1832
- _setPrototypeOf$3(subClass, superClass);
2278
+ function _getPrototypeOf$3(o) {
2279
+ _getPrototypeOf$3 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
2280
+ return o.__proto__ || Object.getPrototypeOf(o);
2281
+ };
2282
+ return _getPrototypeOf$3(o);
1833
2283
  }
1834
2284
  function _setPrototypeOf$3(o, p) {
1835
2285
  _setPrototypeOf$3 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
@@ -1838,7 +2288,83 @@
1838
2288
  };
1839
2289
  return _setPrototypeOf$3(o, p);
1840
2290
  }
1841
- var ElementSVG = function ElementSVG() {
2291
+ function _isNativeReflectConstruct$3() {
2292
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
2293
+ if (Reflect.construct.sham) return false;
2294
+ if (typeof Proxy === "function") return true;
2295
+ try {
2296
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
2297
+ return true;
2298
+ } catch (e) {
2299
+ return false;
2300
+ }
2301
+ }
2302
+ function _assertThisInitialized$3(self) {
2303
+ if (self === void 0) {
2304
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
2305
+ }
2306
+ return self;
2307
+ }
2308
+ function _possibleConstructorReturn$3(self, call) {
2309
+ if (call && (_typeof(call) === "object" || typeof call === "function")) {
2310
+ return call;
2311
+ } else if (call !== void 0) {
2312
+ throw new TypeError("Derived constructors may only return object or undefined");
2313
+ }
2314
+ return _assertThisInitialized$3(self);
2315
+ }
2316
+ function _createSuper$3(Derived) {
2317
+ var hasNativeReflectConstruct = _isNativeReflectConstruct$3();
2318
+ return function _createSuperInternal() {
2319
+ var Super = _getPrototypeOf$3(Derived),
2320
+ result;
2321
+ if (hasNativeReflectConstruct) {
2322
+ var NewTarget = _getPrototypeOf$3(this).constructor;
2323
+ result = Reflect.construct(Super, arguments, NewTarget);
2324
+ } else {
2325
+ result = Super.apply(this, arguments);
2326
+ }
2327
+ return _possibleConstructorReturn$3(this, result);
2328
+ };
2329
+ }
2330
+ function _slicedToArray(arr, i) {
2331
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest();
2332
+ }
2333
+ function _arrayWithHoles(arr) {
2334
+ if (Array.isArray(arr)) return arr;
2335
+ }
2336
+ function _unsupportedIterableToArray$1(o, minLen) {
2337
+ if (!o) return;
2338
+ if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
2339
+ var n = Object.prototype.toString.call(o).slice(8, -1);
2340
+ if (n === "Object" && o.constructor) n = o.constructor.name;
2341
+ if (n === "Map" || n === "Set") return Array.from(o);
2342
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
2343
+ }
2344
+ function _arrayLikeToArray$1(arr, len) {
2345
+ if (len == null || len > arr.length) len = arr.length;
2346
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
2347
+ return arr2;
2348
+ }
2349
+ function _nonIterableRest() {
2350
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2351
+ }
2352
+ function _toPrimitive$3(input, hint) {
2353
+ if (_typeof(input) !== "object" || input === null) return input;
2354
+ var prim = input[Symbol.toPrimitive];
2355
+ if (prim !== undefined) {
2356
+ var res = prim.call(input, hint || "default");
2357
+ if (_typeof(res) !== "object") return res;
2358
+ throw new TypeError("@@toPrimitive must return a primitive value.");
2359
+ }
2360
+ return (hint === "string" ? String : Number)(input);
2361
+ }
2362
+ function _toPropertyKey$3(arg) {
2363
+ var key = _toPrimitive$3(arg, "string");
2364
+ return _typeof(key) === "symbol" ? key : String(key);
2365
+ }
2366
+ var ElementSVG = /*#__PURE__*/_createClass$3(function ElementSVG() {
2367
+ _classCallCheck$3(this, ElementSVG);
1842
2368
  /**
1843
2369
  * basic element, eg. <circle>|<ellipse>
1844
2370
  */
@@ -1854,7 +2380,7 @@
1854
2380
  * -> $hitTestingEl
1855
2381
  */
1856
2382
  this.$hitTestingEl = void 0;
1857
- };
2383
+ });
1858
2384
  ElementSVG.tag = 'c-svg-element';
1859
2385
  function updateImageElementAttribute($el, parsedStyle) {
1860
2386
  var _parsedStyle$img = parsedStyle.img,
@@ -1867,13 +2393,13 @@
1867
2393
  $el.setAttribute('href', img);
1868
2394
  } else if (img instanceof Image) {
1869
2395
  if (!width) {
1870
- $el.setAttribute('width', "" + img.width);
2396
+ $el.setAttribute('width', "".concat(img.width));
1871
2397
  // TODO: set renderable.boundsDirty
1872
2398
  // this.attr('width', img.width);
1873
2399
  }
1874
2400
 
1875
2401
  if (!height) {
1876
- $el.setAttribute('height', "" + img.height);
2402
+ $el.setAttribute('height', "".concat(img.height));
1877
2403
  // this.attr('height', img.height);
1878
2404
  }
1879
2405
 
@@ -1886,21 +2412,21 @@
1886
2412
  } else if (img instanceof ImageData) {
1887
2413
  var canvas = document.createElement('canvas');
1888
2414
  // @ts-ignore
1889
- canvas.setAttribute('width', "" + img.width);
2415
+ canvas.setAttribute('width', "".concat(img.width));
1890
2416
  // @ts-ignore
1891
- canvas.setAttribute('height', "" + img.height);
2417
+ canvas.setAttribute('height', "".concat(img.height));
1892
2418
  var context = canvas.getContext('2d');
1893
2419
  if (context) {
1894
2420
  context.putImageData(img, 0, 0);
1895
2421
  if (!width) {
1896
2422
  // @ts-ignore
1897
- $el.setAttribute('width', "" + img.width);
2423
+ $el.setAttribute('width', "".concat(img.width));
1898
2424
  // this.attr('width', img.width);
1899
2425
  }
1900
2426
 
1901
2427
  if (!height) {
1902
2428
  // @ts-ignore
1903
- $el.setAttribute('height', "" + img.height);
2429
+ $el.setAttribute('height', "".concat(img.height));
1904
2430
  // this.attr('height', img.height);
1905
2431
  }
1906
2432
 
@@ -1943,10 +2469,10 @@
1943
2469
  endOffsetY = Math.sin(rad) * (markerEndOffset || 0);
1944
2470
  }
1945
2471
  // @see https://github.com/antvis/g/issues/1038
1946
- $el.setAttribute('x1', "" + (x1 - defX + startOffsetX));
1947
- $el.setAttribute('y1', "" + (y1 - defY + startOffsetY));
1948
- $el.setAttribute('x2', "" + (x2 - defX + endOffsetX));
1949
- $el.setAttribute('y2', "" + (y2 - defY + endOffsetY));
2472
+ $el.setAttribute('x1', "".concat(x1 - defX + startOffsetX));
2473
+ $el.setAttribute('y1', "".concat(y1 - defY + startOffsetY));
2474
+ $el.setAttribute('x2', "".concat(x2 - defX + endOffsetX));
2475
+ $el.setAttribute('y2', "".concat(y2 - defY + endOffsetY));
1950
2476
  }
1951
2477
  function updatePathElementAttribute($el, parsedStyle) {
1952
2478
  var path = parsedStyle.path,
@@ -1967,8 +2493,9 @@
1967
2493
  var y;
1968
2494
  if (markerStart && gLite.isDisplayObject(markerStart) && markerStartOffset) {
1969
2495
  var _markerStart$parentNo = markerStart.parentNode.getStartTangent(),
1970
- p1 = _markerStart$parentNo[0],
1971
- p2 = _markerStart$parentNo[1];
2496
+ _markerStart$parentNo2 = _slicedToArray(_markerStart$parentNo, 2),
2497
+ p1 = _markerStart$parentNo2[0],
2498
+ p2 = _markerStart$parentNo2[1];
1972
2499
  x = p1[0] - p2[0];
1973
2500
  y = p1[1] - p2[1];
1974
2501
  rad = Math.atan2(y, x);
@@ -1977,8 +2504,9 @@
1977
2504
  }
1978
2505
  if (markerEnd && gLite.isDisplayObject(markerEnd) && markerEndOffset) {
1979
2506
  var _markerEnd$parentNode = markerEnd.parentNode.getEndTangent(),
1980
- _p = _markerEnd$parentNode[0],
1981
- _p2 = _markerEnd$parentNode[1];
2507
+ _markerEnd$parentNode2 = _slicedToArray(_markerEnd$parentNode, 2),
2508
+ _p = _markerEnd$parentNode2[0],
2509
+ _p2 = _markerEnd$parentNode2[1];
1982
2510
  x = _p[0] - _p2[0];
1983
2511
  y = _p[1] - _p2[1];
1984
2512
  rad = Math.atan2(y, x);
@@ -2030,7 +2558,7 @@
2030
2558
  offsetX = endOffsetX;
2031
2559
  offsetY = endOffsetY;
2032
2560
  }
2033
- return point[0] - defX + offsetX + "," + (point[1] - defY + offsetY);
2561
+ return "".concat(point[0] - defX + offsetX, ",").concat(point[1] - defY + offsetY);
2034
2562
  }).join(' '));
2035
2563
  }
2036
2564
  }
@@ -2047,20 +2575,21 @@
2047
2575
  });
2048
2576
  var d = '';
2049
2577
  if (!hasRadius) {
2050
- d = "M 0,0 l " + width + ",0 l 0," + height + " l" + -width + " 0 z";
2578
+ d = "M 0,0 l ".concat(width, ",0 l 0,").concat(height, " l").concat(-width, " 0 z");
2051
2579
  } else {
2052
2580
  var _radius$map = radius.map(function (r) {
2053
2581
  return clamp(r, 0, Math.min(Math.abs(width) / 2, Math.abs(height) / 2));
2054
2582
  }),
2055
- tlr = _radius$map[0],
2056
- trr = _radius$map[1],
2057
- brr = _radius$map[2],
2058
- blr = _radius$map[3];
2583
+ _radius$map2 = _slicedToArray(_radius$map, 4),
2584
+ tlr = _radius$map2[0],
2585
+ trr = _radius$map2[1],
2586
+ brr = _radius$map2[2],
2587
+ blr = _radius$map2[3];
2059
2588
  var signX = width > 0 ? 1 : -1;
2060
2589
  var signY = height > 0 ? 1 : -1;
2061
2590
  // sweep-flag @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Tutorial/Paths#arcs
2062
2591
  var sweepFlag = signX + signY !== 0 ? 1 : 0;
2063
- d = [["M " + signX * tlr + ",0"], ["l " + (width - signX * (tlr + trr)) + ",0"], ["a " + trr + "," + trr + ",0,0," + sweepFlag + "," + signX * trr + "," + signY * trr], ["l 0," + (height - signY * (trr + brr))], ["a " + brr + "," + brr + ",0,0," + sweepFlag + "," + -signX * brr + "," + signY * brr], ["l " + (signX * (brr + blr) - width) + ",0"], ["a " + blr + "," + blr + ",0,0," + sweepFlag + "," + -signX * blr + "," + -signY * blr], ["l 0," + (signY * (blr + tlr) - height)], ["a " + tlr + "," + tlr + ",0,0," + sweepFlag + "," + signX * tlr + "," + -signY * tlr], ['z']].join(' ');
2592
+ d = [["M ".concat(signX * tlr, ",0")], ["l ".concat(width - signX * (tlr + trr), ",0")], ["a ".concat(trr, ",").concat(trr, ",0,0,").concat(sweepFlag, ",").concat(signX * trr, ",").concat(signY * trr)], ["l 0,".concat(height - signY * (trr + brr))], ["a ".concat(brr, ",").concat(brr, ",0,0,").concat(sweepFlag, ",").concat(-signX * brr, ",").concat(signY * brr)], ["l ".concat(signX * (brr + blr) - width, ",0")], ["a ".concat(blr, ",").concat(blr, ",0,0,").concat(sweepFlag, ",").concat(-signX * blr, ",").concat(-signY * blr)], ["l 0,".concat(signY * (blr + tlr) - height)], ["a ".concat(tlr, ",").concat(tlr, ",0,0,").concat(sweepFlag, ",").concat(signX * tlr, ",").concat(-signY * tlr)], ['z']].join(' ');
2064
2593
  }
2065
2594
  $el.setAttribute('d', d);
2066
2595
  }
@@ -2172,6 +2701,7 @@
2172
2701
  var TEXT_PATH_PREFIX = 'text-path-';
2173
2702
  var SVGRendererPlugin = /*#__PURE__*/function () {
2174
2703
  function SVGRendererPlugin(pluginOptions, defElementManager, context) {
2704
+ _classCallCheck$3(this, SVGRendererPlugin);
2175
2705
  this.pluginOptions = void 0;
2176
2706
  this.defElementManager = void 0;
2177
2707
  this.context = void 0;
@@ -2209,534 +2739,553 @@
2209
2739
  this.defElementManager = defElementManager;
2210
2740
  this.context = context;
2211
2741
  }
2212
- var _proto = SVGRendererPlugin.prototype;
2213
- _proto.apply = function apply(context) {
2214
- var _this = this;
2215
- var renderingService = context.renderingService,
2216
- renderingContext = context.renderingContext;
2217
- this.context = context;
2218
- // @ts-ignore
2219
- this.context.svgElementMap = this.svgElementMap;
2220
- var canvas = renderingContext.root.ownerDocument.defaultView;
2221
- var document = this.context.config.document;
2222
- var handleMounted = function handleMounted(e) {
2223
- var object = e.target;
2224
- // should remove clipPath already existed in <defs>
2225
- var $useRefs = _this.clipPathUseMap.get(object);
2226
- if ($useRefs) {
2227
- var $def = _this.defElementManager.getDefElement();
2228
- var existed = $def.querySelector("#" + _this.getId(object));
2229
- if (existed) {
2230
- existed.remove();
2231
- }
2232
- }
2233
- // create SVG DOM Node
2234
- _this.createSVGDom(document, object, _this.$camera);
2235
- };
2236
- var handleUnmounted = function handleUnmounted(e) {
2237
- var object = e.target;
2238
- _this.defElementManager.clear(object.entity);
2239
- _this.clipPathUseMap.delete(object);
2240
- _this.removeSVGDom(object);
2241
- };
2242
- var reorderChildren = function reorderChildren(object) {
2243
- var _object$parentNode, _object$parentNode$el;
2244
- var parent = object.parentNode;
2245
- // @ts-ignore
2246
- 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;
2247
- var children = ((parent === null || parent === void 0 ? void 0 : parent.children) || []).slice();
2248
- if ($groupEl) {
2249
- _this.reorderChildren(document, $groupEl, children);
2250
- }
2251
- };
2252
- var handleReparent = function handleReparent(e) {
2253
- var object = e.target;
2254
- reorderChildren(object);
2255
- };
2256
- var handleAttributeChanged = function handleAttributeChanged(e) {
2257
- var object = e.target;
2258
- // @see https://github.com/antvis/g/issues/994
2259
- // @ts-ignore
2260
- if (!object.elementSVG) {
2261
- return;
2262
- }
2263
- var attrName = e.attrName;
2264
- var attribtues = _this.dirtyAttributes.get(object);
2265
- if (!attribtues) {
2266
- _this.dirtyAttributes.set(object, []);
2267
- attribtues = _this.dirtyAttributes.get(object);
2268
- }
2269
- attribtues.push(attrName);
2270
- };
2271
- var handleGeometryBoundsChanged = function handleGeometryBoundsChanged(e) {
2272
- var _object$elementSVG;
2273
- var object = e.target;
2742
+ _createClass$3(SVGRendererPlugin, [{
2743
+ key: "apply",
2744
+ value: function apply(context) {
2745
+ var _this = this;
2746
+ var renderingService = context.renderingService,
2747
+ renderingContext = context.renderingContext;
2748
+ this.context = context;
2274
2749
  // @ts-ignore
2275
- var $el = (_object$elementSVG = object.elementSVG) === null || _object$elementSVG === void 0 ? void 0 : _object$elementSVG.$el;
2276
- var _object$parsedStyle = object.parsedStyle,
2277
- fill = _object$parsedStyle.fill,
2278
- stroke = _object$parsedStyle.stroke,
2279
- clipPath = _object$parsedStyle.clipPath;
2280
- if (fill && !gLite.isCSSRGB(fill)) {
2281
- _this.defElementManager.createOrUpdateGradientAndPattern(object, $el, fill, 'fill', _this);
2282
- }
2283
- if (stroke && !gLite.isCSSRGB(stroke)) {
2284
- _this.defElementManager.createOrUpdateGradientAndPattern(object, $el, stroke, 'stroke', _this);
2285
- }
2286
- if (clipPath) {
2287
- var parentInvert = invert(create(), object.getWorldTransform());
2288
- var clipPathId = CLIP_PATH_PREFIX + clipPath.entity + '-' + object.entity;
2289
- var $def = _this.defElementManager.getDefElement();
2290
- var $existed = $def.querySelector("#" + clipPathId);
2291
- if ($existed) {
2292
- _this.applyTransform($existed, parentInvert);
2750
+ this.context.svgElementMap = this.svgElementMap;
2751
+ var canvas = renderingContext.root.ownerDocument.defaultView;
2752
+ var document = this.context.config.document;
2753
+ var handleMounted = function handleMounted(e) {
2754
+ var object = e.target;
2755
+ // should remove clipPath already existed in <defs>
2756
+ var $useRefs = _this.clipPathUseMap.get(object);
2757
+ if ($useRefs) {
2758
+ var $def = _this.defElementManager.getDefElement();
2759
+ var existed = $def.querySelector("#".concat(_this.getId(object)));
2760
+ if (existed) {
2761
+ existed.remove();
2762
+ }
2293
2763
  }
2294
- }
2295
- };
2296
- renderingService.hooks.init.tapPromise(SVGRendererPlugin.tag, /*#__PURE__*/_asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee() {
2297
- var _this$context$config, background, document, $svg;
2298
- return _regeneratorRuntime$3().wrap(function _callee$(_context) {
2299
- while (1) switch (_context.prev = _context.next) {
2300
- case 0:
2301
- _this$context$config = _this.context.config, background = _this$context$config.background, document = _this$context$config.document; // <defs>
2302
- _this.defElementManager.init();
2303
- $svg = _this.context.contextService.getContext();
2304
- if (background) {
2305
- $svg.style.background = background;
2306
- }
2307
- // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
2308
- $svg.setAttribute('color-interpolation-filters', 'sRGB');
2309
- _this.$camera = createSVGElement('g', document);
2310
- _this.$camera.id = G_SVG_PREFIX + "-camera";
2311
- _this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
2312
- $svg.appendChild(_this.$camera);
2313
- canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
2314
- canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
2315
- canvas.addEventListener(gLite.ElementEvent.REPARENT, handleReparent);
2316
- canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
2317
- canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
2318
- case 14:
2319
- case "end":
2320
- return _context.stop();
2764
+ // create SVG DOM Node
2765
+ _this.createSVGDom(document, object, _this.$camera);
2766
+ };
2767
+ var handleUnmounted = function handleUnmounted(e) {
2768
+ var object = e.target;
2769
+ _this.defElementManager.clear(object.entity);
2770
+ _this.clipPathUseMap.delete(object);
2771
+ _this.removeSVGDom(object);
2772
+ };
2773
+ var reorderChildren = function reorderChildren(object) {
2774
+ var _object$parentNode, _object$parentNode$el;
2775
+ var parent = object.parentNode;
2776
+ // @ts-ignore
2777
+ 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;
2778
+ var children = ((parent === null || parent === void 0 ? void 0 : parent.children) || []).slice();
2779
+ if ($groupEl) {
2780
+ _this.reorderChildren(document, $groupEl, children);
2321
2781
  }
2322
- }, _callee);
2323
- })));
2324
- renderingService.hooks.destroy.tap(SVGRendererPlugin.tag, function () {
2325
- canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
2326
- canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
2327
- canvas.removeEventListener(gLite.ElementEvent.REPARENT, handleReparent);
2328
- canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
2329
- canvas.removeEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
2330
- });
2331
- renderingService.hooks.render.tap(SVGRendererPlugin.tag, function (object) {
2332
- _this.renderQueue.push(object);
2333
- });
2334
- renderingService.hooks.beginFrame.tap(SVGRendererPlugin.tag, function () {
2335
- var doc = _this.context.config.document;
2336
- if (_this.pendingReorderQueue.size) {
2337
- _this.pendingReorderQueue.forEach(function (object) {
2338
- var _object$elementSVG2;
2339
- var children = ((object === null || object === void 0 ? void 0 : object.children) || []).slice();
2340
- var $parentGroupEl =
2341
- // @ts-ignore
2342
- object === null || object === void 0 ? void 0 : (_object$elementSVG2 = object.elementSVG) === null || _object$elementSVG2 === void 0 ? void 0 : _object$elementSVG2.$groupEl;
2343
- if ($parentGroupEl) {
2344
- _this.reorderChildren(doc || document, $parentGroupEl, children || []);
2345
- }
2346
- });
2347
- _this.pendingReorderQueue.clear();
2348
- }
2349
- });
2350
- renderingService.hooks.endFrame.tap(SVGRendererPlugin.tag, function () {
2351
- if (renderingContext.renderReasons.has(gLite.RenderReason.CAMERA_CHANGED)) {
2352
- _this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
2353
- }
2354
- _this.renderQueue.forEach(function (object) {
2355
- var _object$elementSVG3, _object$elementSVG4;
2782
+ };
2783
+ var handleReparent = function handleReparent(e) {
2784
+ var object = e.target;
2785
+ reorderChildren(object);
2786
+ };
2787
+ var handleAttributeChanged = function handleAttributeChanged(e) {
2788
+ var object = e.target;
2789
+ // @see https://github.com/antvis/g/issues/994
2356
2790
  // @ts-ignore
2357
- var $el = (_object$elementSVG3 = object.elementSVG) === null || _object$elementSVG3 === void 0 ? void 0 : _object$elementSVG3.$el;
2791
+ if (!object.elementSVG) {
2792
+ return;
2793
+ }
2794
+ var attrName = e.attrName;
2795
+ var attribtues = _this.dirtyAttributes.get(object);
2796
+ if (!attribtues) {
2797
+ _this.dirtyAttributes.set(object, []);
2798
+ attribtues = _this.dirtyAttributes.get(object);
2799
+ }
2800
+ attribtues.push(attrName);
2801
+ };
2802
+ var handleGeometryBoundsChanged = function handleGeometryBoundsChanged(e) {
2803
+ var _object$elementSVG;
2804
+ var object = e.target;
2358
2805
  // @ts-ignore
2359
- var $groupEl = (_object$elementSVG4 = object.elementSVG) === null || _object$elementSVG4 === void 0 ? void 0 : _object$elementSVG4.$groupEl;
2360
- if ($el && $groupEl) {
2361
- // apply local RTS transformation to <group> wrapper
2362
- // account for anchor
2363
- var localTransform = object.getLocalTransform();
2364
- _this.applyTransform($groupEl, localTransform);
2365
- // clipped shapes should also be informed
2366
- var $useRefs = _this.clipPathUseMap.get(object);
2367
- if ($useRefs && $useRefs.length) {
2368
- $useRefs.forEach(function ($use) {
2369
- // <clipPath transform="matrix()"><circle /></clipPath>
2370
- _this.applyTransform($use, object.getWorldTransform());
2371
- // const parentInvert = mat4.invert(
2372
- // mat4.create(),
2373
- // (object as DisplayObject).getWorldTransform(),
2374
- // );
2375
- // this.applyTransform($clipPath, parentInvert);
2376
- });
2806
+ var $el = (_object$elementSVG = object.elementSVG) === null || _object$elementSVG === void 0 ? void 0 : _object$elementSVG.$el;
2807
+ var _object$parsedStyle = object.parsedStyle,
2808
+ fill = _object$parsedStyle.fill,
2809
+ stroke = _object$parsedStyle.stroke,
2810
+ clipPath = _object$parsedStyle.clipPath;
2811
+ if (fill && !gLite.isCSSRGB(fill)) {
2812
+ _this.defElementManager.createOrUpdateGradientAndPattern(object, $el, fill, 'fill', _this);
2813
+ }
2814
+ if (stroke && !gLite.isCSSRGB(stroke)) {
2815
+ _this.defElementManager.createOrUpdateGradientAndPattern(object, $el, stroke, 'stroke', _this);
2816
+ }
2817
+ if (clipPath) {
2818
+ var parentInvert = invert(create(), object.getWorldTransform());
2819
+ var clipPathId = CLIP_PATH_PREFIX + clipPath.entity + '-' + object.entity;
2820
+ var $def = _this.defElementManager.getDefElement();
2821
+ var $existed = $def.querySelector("#".concat(clipPathId));
2822
+ if ($existed) {
2823
+ _this.applyTransform($existed, parentInvert);
2377
2824
  }
2378
- // finish rendering, clear dirty flag
2379
- object.renderable.dirty = false;
2380
2825
  }
2381
- // update dirty attributes
2382
- var attributes = _this.dirtyAttributes.get(object);
2383
- if (attributes) {
2384
- attributes.forEach(function (attrName) {
2385
- if (attrName === 'zIndex') {
2386
- reorderChildren(object);
2387
- } else if (attrName === 'increasedLineWidthForHitTesting') {
2388
- _this.createOrUpdateHitArea(object, $el, $groupEl);
2826
+ };
2827
+ renderingService.hooks.init.tapPromise(SVGRendererPlugin.tag, /*#__PURE__*/_asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee() {
2828
+ var _this$context$config, background, document, $svg;
2829
+ return _regeneratorRuntime$3().wrap(function _callee$(_context) {
2830
+ while (1) switch (_context.prev = _context.next) {
2831
+ case 0:
2832
+ _this$context$config = _this.context.config, background = _this$context$config.background, document = _this$context$config.document; // <defs>
2833
+ _this.defElementManager.init();
2834
+ $svg = _this.context.contextService.getContext();
2835
+ if (background) {
2836
+ $svg.style.background = background;
2837
+ }
2838
+ // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
2839
+ $svg.setAttribute('color-interpolation-filters', 'sRGB');
2840
+ _this.$camera = createSVGElement('g', document);
2841
+ _this.$camera.id = "".concat(G_SVG_PREFIX, "-camera");
2842
+ _this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
2843
+ $svg.appendChild(_this.$camera);
2844
+ canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
2845
+ canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
2846
+ canvas.addEventListener(gLite.ElementEvent.REPARENT, handleReparent);
2847
+ canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
2848
+ canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
2849
+ case 14:
2850
+ case "end":
2851
+ return _context.stop();
2852
+ }
2853
+ }, _callee);
2854
+ })));
2855
+ renderingService.hooks.destroy.tap(SVGRendererPlugin.tag, function () {
2856
+ canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
2857
+ canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
2858
+ canvas.removeEventListener(gLite.ElementEvent.REPARENT, handleReparent);
2859
+ canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
2860
+ canvas.removeEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
2861
+ });
2862
+ renderingService.hooks.render.tap(SVGRendererPlugin.tag, function (object) {
2863
+ _this.renderQueue.push(object);
2864
+ });
2865
+ renderingService.hooks.beginFrame.tap(SVGRendererPlugin.tag, function () {
2866
+ var doc = _this.context.config.document;
2867
+ if (_this.pendingReorderQueue.size) {
2868
+ _this.pendingReorderQueue.forEach(function (object) {
2869
+ var _object$elementSVG2;
2870
+ var children = ((object === null || object === void 0 ? void 0 : object.children) || []).slice();
2871
+ var $parentGroupEl =
2872
+ // @ts-ignore
2873
+ object === null || object === void 0 ? void 0 : (_object$elementSVG2 = object.elementSVG) === null || _object$elementSVG2 === void 0 ? void 0 : _object$elementSVG2.$groupEl;
2874
+ if ($parentGroupEl) {
2875
+ _this.reorderChildren(doc || document, $parentGroupEl, children || []);
2389
2876
  }
2390
- _this.updateAttribute(object, [attrName]);
2391
2877
  });
2392
- _this.dirtyAttributes.delete(object);
2878
+ _this.pendingReorderQueue.clear();
2393
2879
  }
2394
2880
  });
2395
- _this.renderQueue = [];
2396
- });
2397
- };
2398
- _proto.getId = function getId(object) {
2399
- return G_SVG_PREFIX + "-" + object.entity;
2400
- };
2401
- _proto.reorderChildren = function reorderChildren(doc, $groupEl, children) {
2402
- // need to reorder parent's children
2403
- children.sort(function (a, b) {
2404
- return a.sortable.renderOrder - b.sortable.renderOrder;
2405
- });
2406
- if (children.length) {
2407
- // create empty fragment
2408
- var fragment = (doc || document).createDocumentFragment();
2409
- children.forEach(function (child) {
2410
- if (child.isConnected) {
2881
+ renderingService.hooks.endFrame.tap(SVGRendererPlugin.tag, function () {
2882
+ if (renderingContext.renderReasons.has(gLite.RenderReason.CAMERA_CHANGED)) {
2883
+ _this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
2884
+ }
2885
+ _this.renderQueue.forEach(function (object) {
2886
+ var _object$elementSVG3, _object$elementSVG4;
2411
2887
  // @ts-ignore
2412
- var $el = child.elementSVG.$groupEl;
2413
- if ($el) {
2414
- fragment.appendChild($el);
2888
+ var $el = (_object$elementSVG3 = object.elementSVG) === null || _object$elementSVG3 === void 0 ? void 0 : _object$elementSVG3.$el;
2889
+ // @ts-ignore
2890
+ var $groupEl = (_object$elementSVG4 = object.elementSVG) === null || _object$elementSVG4 === void 0 ? void 0 : _object$elementSVG4.$groupEl;
2891
+ if ($el && $groupEl) {
2892
+ // apply local RTS transformation to <group> wrapper
2893
+ // account for anchor
2894
+ var localTransform = object.getLocalTransform();
2895
+ _this.applyTransform($groupEl, localTransform);
2896
+ // clipped shapes should also be informed
2897
+ var $useRefs = _this.clipPathUseMap.get(object);
2898
+ if ($useRefs && $useRefs.length) {
2899
+ $useRefs.forEach(function ($use) {
2900
+ // <clipPath transform="matrix()"><circle /></clipPath>
2901
+ _this.applyTransform($use, object.getWorldTransform());
2902
+ // const parentInvert = mat4.invert(
2903
+ // mat4.create(),
2904
+ // (object as DisplayObject).getWorldTransform(),
2905
+ // );
2906
+ // this.applyTransform($clipPath, parentInvert);
2907
+ });
2908
+ }
2909
+ // finish rendering, clear dirty flag
2910
+ object.renderable.dirty = false;
2415
2911
  }
2416
- }
2912
+ // update dirty attributes
2913
+ var attributes = _this.dirtyAttributes.get(object);
2914
+ if (attributes) {
2915
+ attributes.forEach(function (attrName) {
2916
+ if (attrName === 'zIndex') {
2917
+ reorderChildren(object);
2918
+ } else if (attrName === 'increasedLineWidthForHitTesting') {
2919
+ _this.createOrUpdateHitArea(object, $el, $groupEl);
2920
+ }
2921
+ _this.updateAttribute(object, [attrName]);
2922
+ });
2923
+ _this.dirtyAttributes.delete(object);
2924
+ }
2925
+ });
2926
+ _this.renderQueue = [];
2417
2927
  });
2418
- $groupEl.appendChild(fragment);
2419
2928
  }
2420
- };
2421
- _proto.applyTransform = function applyTransform($el, rts) {
2422
- // use proper precision avoiding too long string in `transform`
2423
- // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
2424
- $el.setAttribute('transform', "matrix(" + numberToLongString(rts[0]) + "," + numberToLongString(rts[1]) + "," + numberToLongString(rts[4]) + "," + numberToLongString(rts[5]) + "," + numberToLongString(rts[12]) + "," + numberToLongString(rts[13]) + ")");
2425
- };
2426
- _proto.applyAttributes = function applyAttributes(object) {
2427
- // @ts-ignore
2428
- var elementSVG = object.elementSVG;
2429
- var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
2430
- var $groupEl = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$groupEl;
2431
- if ($el && $groupEl) {
2432
- var nodeName = object.nodeName,
2433
- attributes = object.attributes;
2434
- $el.setAttribute('fill', 'none');
2435
- if (nodeName === gLite.Shape.IMAGE) {
2436
- $el.setAttribute('preserveAspectRatio', 'none');
2929
+ }, {
2930
+ key: "getId",
2931
+ value: function getId(object) {
2932
+ return "".concat(G_SVG_PREFIX, "-").concat(object.entity);
2933
+ }
2934
+ }, {
2935
+ key: "reorderChildren",
2936
+ value: function reorderChildren(doc, $groupEl, children) {
2937
+ // need to reorder parent's children
2938
+ children.sort(function (a, b) {
2939
+ return a.sortable.renderOrder - b.sortable.renderOrder;
2940
+ });
2941
+ if (children.length) {
2942
+ // create empty fragment
2943
+ var fragment = (doc || document).createDocumentFragment();
2944
+ children.forEach(function (child) {
2945
+ if (child.isConnected) {
2946
+ // @ts-ignore
2947
+ var $el = child.elementSVG.$groupEl;
2948
+ if ($el) {
2949
+ fragment.appendChild($el);
2950
+ }
2951
+ }
2952
+ });
2953
+ $groupEl.appendChild(fragment);
2437
2954
  }
2438
- // apply attributes
2439
- this.updateAttribute(object, Object.keys(attributes));
2440
2955
  }
2441
- };
2442
- _proto.updateAttribute = function updateAttribute(object, attributes) {
2443
- var _this2 = this;
2444
- var document = this.context.config.document;
2445
- // @ts-ignore
2446
- var _object$elementSVG5 = object.elementSVG,
2447
- $el = _object$elementSVG5.$el,
2448
- $groupEl = _object$elementSVG5.$groupEl,
2449
- $hitTestingEl = _object$elementSVG5.$hitTestingEl;
2450
- var parsedStyle = object.parsedStyle,
2451
- computedStyle = object.computedStyle,
2452
- nodeName = object.nodeName;
2453
- var shouldUpdateElementAttribute = attributes.some(function (name) {
2454
- return (
2455
- // @ts-ignore
2456
- _this2.context.SVGElementLifeCycleContribution.shouldUpdateElementAttribute(object, name)
2457
- );
2458
- });
2459
- // need re-generate path
2460
- if (shouldUpdateElementAttribute && $el) {
2461
- [$el, $hitTestingEl].forEach(function ($el) {
2462
- if ($el) {
2956
+ }, {
2957
+ key: "applyTransform",
2958
+ value: function applyTransform($el, rts) {
2959
+ // use proper precision avoiding too long string in `transform`
2960
+ // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
2961
+ $el.setAttribute('transform', "matrix(".concat(numberToLongString(rts[0]), ",").concat(numberToLongString(rts[1]), ",").concat(numberToLongString(rts[4]), ",").concat(numberToLongString(rts[5]), ",").concat(numberToLongString(rts[12]), ",").concat(numberToLongString(rts[13]), ")"));
2962
+ }
2963
+ }, {
2964
+ key: "applyAttributes",
2965
+ value: function applyAttributes(object) {
2966
+ // @ts-ignore
2967
+ var elementSVG = object.elementSVG;
2968
+ var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
2969
+ var $groupEl = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$groupEl;
2970
+ if ($el && $groupEl) {
2971
+ var nodeName = object.nodeName,
2972
+ attributes = object.attributes;
2973
+ $el.setAttribute('fill', 'none');
2974
+ if (nodeName === gLite.Shape.IMAGE) {
2975
+ $el.setAttribute('preserveAspectRatio', 'none');
2976
+ }
2977
+ // apply attributes
2978
+ this.updateAttribute(object, Object.keys(attributes));
2979
+ }
2980
+ }
2981
+ }, {
2982
+ key: "updateAttribute",
2983
+ value: function updateAttribute(object, attributes) {
2984
+ var _this2 = this;
2985
+ var document = this.context.config.document;
2986
+ // @ts-ignore
2987
+ var _object$elementSVG5 = object.elementSVG,
2988
+ $el = _object$elementSVG5.$el,
2989
+ $groupEl = _object$elementSVG5.$groupEl,
2990
+ $hitTestingEl = _object$elementSVG5.$hitTestingEl;
2991
+ var parsedStyle = object.parsedStyle,
2992
+ computedStyle = object.computedStyle,
2993
+ nodeName = object.nodeName;
2994
+ var shouldUpdateElementAttribute = attributes.some(function (name) {
2995
+ return (
2463
2996
  // @ts-ignore
2464
- _this2.context.SVGElementLifeCycleContribution.updateElementAttribute(object, $el, _this2.svgElementMap);
2465
- if (object.nodeName !== gLite.Shape.TEXT) {
2997
+ _this2.context.SVGElementLifeCycleContribution.shouldUpdateElementAttribute(object, name)
2998
+ );
2999
+ });
3000
+ // need re-generate path
3001
+ if (shouldUpdateElementAttribute && $el) {
3002
+ [$el, $hitTestingEl].forEach(function ($el) {
3003
+ if ($el) {
3004
+ // @ts-ignore
3005
+ _this2.context.SVGElementLifeCycleContribution.updateElementAttribute(object, $el, _this2.svgElementMap);
3006
+ if (object.nodeName !== gLite.Shape.TEXT) {
3007
+ _this2.updateAnchorWithTransform(object);
3008
+ }
3009
+ }
3010
+ });
3011
+ }
3012
+ // update common attributes
3013
+ attributes.forEach(function (name) {
3014
+ var _FORMAT_VALUE_MAP$nam, _propertyMetadataCach;
3015
+ var usedName = SVG_ATTR_MAP[name];
3016
+ var computedValue = gLite.runtime.enableCSSParsing ? computedStyle[name] : parsedStyle[name];
3017
+ var computedValueStr = !isNil(computedValue) && computedValue.toString();
3018
+ var formattedValueStr = ((_FORMAT_VALUE_MAP$nam = FORMAT_VALUE_MAP[name]) === null || _FORMAT_VALUE_MAP$nam === void 0 ? void 0 : _FORMAT_VALUE_MAP$nam[computedValueStr]) || computedValueStr;
3019
+ var usedValue = parsedStyle[name];
3020
+ var inherited = usedName && !!((_propertyMetadataCach = gLite.propertyMetadataCache[name]) === null || _propertyMetadataCach === void 0 ? void 0 : _propertyMetadataCach.inh);
3021
+ if (!usedName || (nodeName === gLite.Shape.GROUP || object.isCustomElement) && !gLite.runtime.enableCSSParsing && (inherited || usedName === 'fill' || usedName === 'stroke')) {
3022
+ return;
3023
+ }
3024
+ // <foreignObject>
3025
+ if (nodeName === gLite.Shape.HTML) {
3026
+ if (name === 'lineWidth') {
3027
+ $el.style['border-width'] = "".concat(usedValue || 0, "px");
3028
+ } else if (name === 'lineDash') {
3029
+ $el.style['border-style'] = 'dashed';
3030
+ }
3031
+ }
3032
+ if (name === 'fill') {
3033
+ if (nodeName === gLite.Shape.HTML) {
3034
+ $el.style.background = usedValue.toString();
3035
+ } else {
3036
+ _this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName, _this2);
3037
+ }
3038
+ } else if (name === 'stroke') {
3039
+ if (nodeName === gLite.Shape.HTML) {
3040
+ $el.style['border-color'] = usedValue.toString();
3041
+ $el.style['border-style'] = 'solid';
3042
+ } else {
3043
+ _this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName, _this2);
3044
+ }
3045
+ } else if (gLite.runtime.enableCSSParsing && inherited) {
3046
+ // use computed value
3047
+ // update `visibility` on <group>
3048
+ if (computedValueStr !== 'unset' && computedValueStr !== DEFAULT_VALUE_MAP[name]) {
3049
+ $groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, formattedValueStr);
3050
+ } else {
3051
+ $groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.removeAttribute(usedName);
3052
+ }
3053
+ } else if (name === 'clipPath') {
3054
+ _this2.createOrUpdateClipOrTextPath(document, usedValue, object);
3055
+ } else if (name === 'textPath') {
3056
+ _this2.createOrUpdateClipOrTextPath(document, usedValue, object, true);
3057
+ } else if (name === 'shadowType' || name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
3058
+ _this2.defElementManager.createOrUpdateShadow(object, $el, name);
3059
+ } else if (name === 'filter') {
3060
+ _this2.defElementManager.createOrUpdateFilter(object, $el, usedValue);
3061
+ } else if (name === 'innerHTML') {
3062
+ _this2.createOrUpdateInnerHTML(document, $el, usedValue);
3063
+ } else if (name === 'anchor') {
3064
+ // text' anchor is controlled by `textAnchor` property
3065
+ if (nodeName !== gLite.Shape.TEXT) {
2466
3066
  _this2.updateAnchorWithTransform(object);
2467
3067
  }
3068
+ } else {
3069
+ if (!isNil(computedValue)) {
3070
+ // use computed value so that we can use cascaded effect in SVG
3071
+ // ignore 'unset' and default value
3072
+ [$el, $hitTestingEl].forEach(function ($el) {
3073
+ if ($el && usedName) {
3074
+ if (computedValueStr !== 'unset' && computedValueStr !== DEFAULT_VALUE_MAP[name]) {
3075
+ $el.setAttribute(usedName, formattedValueStr);
3076
+ } else {
3077
+ $el.removeAttribute(usedName);
3078
+ }
3079
+ }
3080
+ });
3081
+ }
2468
3082
  }
2469
3083
  });
2470
3084
  }
2471
- // update common attributes
2472
- attributes.forEach(function (name) {
2473
- var _FORMAT_VALUE_MAP$nam, _propertyMetadataCach;
2474
- var usedName = SVG_ATTR_MAP[name];
2475
- var computedValue = gLite.runtime.enableCSSParsing ? computedStyle[name] : parsedStyle[name];
2476
- var computedValueStr = !isNil(computedValue) && computedValue.toString();
2477
- var formattedValueStr = ((_FORMAT_VALUE_MAP$nam = FORMAT_VALUE_MAP[name]) === null || _FORMAT_VALUE_MAP$nam === void 0 ? void 0 : _FORMAT_VALUE_MAP$nam[computedValueStr]) || computedValueStr;
2478
- var usedValue = parsedStyle[name];
2479
- var inherited = usedName && !!((_propertyMetadataCach = gLite.propertyMetadataCache[name]) === null || _propertyMetadataCach === void 0 ? void 0 : _propertyMetadataCach.inh);
2480
- if (!usedName || (nodeName === gLite.Shape.GROUP || object.isCustomElement) && !gLite.runtime.enableCSSParsing && (inherited || usedName === 'fill' || usedName === 'stroke')) {
2481
- return;
2482
- }
2483
- // <foreignObject>
2484
- if (nodeName === gLite.Shape.HTML) {
2485
- if (name === 'lineWidth') {
2486
- $el.style['border-width'] = (usedValue || 0) + "px";
2487
- } else if (name === 'lineDash') {
2488
- $el.style['border-style'] = 'dashed';
3085
+ }, {
3086
+ key: "createSVGDom",
3087
+ value: function createSVGDom(document, object, root) {
3088
+ var noWrapWithGroup = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
3089
+ // create svg element
3090
+ // @ts-ignore
3091
+ object.elementSVG = new ElementSVG();
3092
+ // @ts-ignore
3093
+ var svgElement = object.elementSVG;
3094
+ // use <group> as default, eg. CustomElement
3095
+ var $el =
3096
+ // @ts-ignore
3097
+ this.context.SVGElementLifeCycleContribution.createElement(object, this.svgElementMap);
3098
+ if ($el) {
3099
+ var _object$parentNode$el2;
3100
+ var $groupEl;
3101
+ // save $el on parsedStyle, which will be returned in getDomElement()
3102
+ if (object.nodeName === gLite.Shape.HTML) {
3103
+ object.parsedStyle.$el = $el;
2489
3104
  }
2490
- }
2491
- if (name === 'fill') {
2492
- if (nodeName === gLite.Shape.HTML) {
2493
- $el.style.background = usedValue.toString();
2494
- } else {
2495
- _this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName, _this2);
3105
+ if (this.pluginOptions.outputSVGElementId) {
3106
+ $el.id = this.getId(object);
2496
3107
  }
2497
- } else if (name === 'stroke') {
2498
- if (nodeName === gLite.Shape.HTML) {
2499
- $el.style['border-color'] = usedValue.toString();
2500
- $el.style['border-style'] = 'solid';
2501
- } else {
2502
- _this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName, _this2);
3108
+ if (this.pluginOptions.outputSVGElementName && object.name) {
3109
+ $el.setAttribute('name', object.name);
2503
3110
  }
2504
- } else if (gLite.runtime.enableCSSParsing && inherited) {
2505
- // use computed value
2506
- // update `visibility` on <group>
2507
- if (computedValueStr !== 'unset' && computedValueStr !== DEFAULT_VALUE_MAP[name]) {
2508
- $groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, formattedValueStr);
3111
+ if (($el.hasAttribute('data-wrapgroup') || $el.nodeName !== 'g') && !noWrapWithGroup) {
3112
+ $groupEl = createSVGElement('g', document);
3113
+ $groupEl.id = $el.id + '-g';
3114
+ $groupEl.appendChild($el);
2509
3115
  } else {
2510
- $groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.removeAttribute(usedName);
3116
+ $groupEl = $el;
2511
3117
  }
2512
- } else if (name === 'clipPath') {
2513
- _this2.createOrUpdateClipOrTextPath(document, usedValue, object);
2514
- } else if (name === 'textPath') {
2515
- _this2.createOrUpdateClipOrTextPath(document, usedValue, object, true);
2516
- } else if (name === 'shadowType' || name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
2517
- _this2.defElementManager.createOrUpdateShadow(object, $el, name);
2518
- } else if (name === 'filter') {
2519
- _this2.defElementManager.createOrUpdateFilter(object, $el, usedValue);
2520
- } else if (name === 'innerHTML') {
2521
- _this2.createOrUpdateInnerHTML(document, $el, usedValue);
2522
- } else if (name === 'anchor') {
2523
- // text' anchor is controlled by `textAnchor` property
2524
- if (nodeName !== gLite.Shape.TEXT) {
2525
- _this2.updateAnchorWithTransform(object);
2526
- }
2527
- } else {
2528
- if (!isNil(computedValue)) {
2529
- // use computed value so that we can use cascaded effect in SVG
2530
- // ignore 'unset' and default value
2531
- [$el, $hitTestingEl].forEach(function ($el) {
2532
- if ($el && usedName) {
2533
- if (computedValueStr !== 'unset' && computedValueStr !== DEFAULT_VALUE_MAP[name]) {
2534
- $el.setAttribute(usedName, formattedValueStr);
2535
- } else {
2536
- $el.removeAttribute(usedName);
2537
- }
2538
- }
2539
- });
3118
+ svgElement.$el = $el;
3119
+ svgElement.$groupEl = $groupEl;
3120
+ // apply attributes at first time
3121
+ this.applyAttributes(object);
3122
+ // create hitArea if necessary
3123
+ this.createOrUpdateHitArea(object, $el, $groupEl);
3124
+ var $parentGroupEl = root ||
3125
+ // @ts-ignore
3126
+ object.parentNode && ((_object$parentNode$el2 = object.parentNode.elementSVG) === null || _object$parentNode$el2 === void 0 ? void 0 : _object$parentNode$el2.$groupEl);
3127
+ if ($parentGroupEl) {
3128
+ $parentGroupEl.appendChild($groupEl);
3129
+ // need reorder children later
3130
+ this.pendingReorderQueue.add(object.parentNode);
2540
3131
  }
2541
3132
  }
2542
- });
2543
- };
2544
- _proto.createSVGDom = function createSVGDom(document, object, root, noWrapWithGroup) {
2545
- if (noWrapWithGroup === void 0) {
2546
- noWrapWithGroup = false;
2547
3133
  }
2548
- // create svg element
2549
- // @ts-ignore
2550
- object.elementSVG = new ElementSVG();
2551
- // @ts-ignore
2552
- var svgElement = object.elementSVG;
2553
- // use <group> as default, eg. CustomElement
2554
- var $el =
2555
- // @ts-ignore
2556
- this.context.SVGElementLifeCycleContribution.createElement(object, this.svgElementMap);
2557
- if ($el) {
2558
- var _object$parentNode$el2;
2559
- var $groupEl;
2560
- // save $el on parsedStyle, which will be returned in getDomElement()
2561
- if (object.nodeName === gLite.Shape.HTML) {
2562
- object.parsedStyle.$el = $el;
2563
- }
2564
- if (this.pluginOptions.outputSVGElementId) {
2565
- $el.id = this.getId(object);
2566
- }
2567
- if (this.pluginOptions.outputSVGElementName && object.name) {
2568
- $el.setAttribute('name', object.name);
2569
- }
2570
- if (($el.hasAttribute('data-wrapgroup') || $el.nodeName !== 'g') && !noWrapWithGroup) {
2571
- $groupEl = createSVGElement('g', document);
2572
- $groupEl.id = $el.id + '-g';
2573
- $groupEl.appendChild($el);
2574
- } else {
2575
- $groupEl = $el;
2576
- }
2577
- svgElement.$el = $el;
2578
- svgElement.$groupEl = $groupEl;
2579
- // apply attributes at first time
2580
- this.applyAttributes(object);
2581
- // create hitArea if necessary
2582
- this.createOrUpdateHitArea(object, $el, $groupEl);
2583
- var $parentGroupEl = root ||
3134
+ }, {
3135
+ key: "removeSVGDom",
3136
+ value: function removeSVGDom(object) {
3137
+ var _object$elementSVG6;
2584
3138
  // @ts-ignore
2585
- object.parentNode && ((_object$parentNode$el2 = object.parentNode.elementSVG) === null || _object$parentNode$el2 === void 0 ? void 0 : _object$parentNode$el2.$groupEl);
2586
- if ($parentGroupEl) {
2587
- $parentGroupEl.appendChild($groupEl);
2588
- // need reorder children later
2589
- this.pendingReorderQueue.add(object.parentNode);
3139
+ var $groupEl = (_object$elementSVG6 = object.elementSVG) === null || _object$elementSVG6 === void 0 ? void 0 : _object$elementSVG6.$groupEl;
3140
+ if ($groupEl && $groupEl.parentNode) {
3141
+ $groupEl.parentNode.removeChild($groupEl);
3142
+ // @ts-ignore
3143
+ this.context.SVGElementLifeCycleContribution.destroyElement(object, $groupEl);
3144
+ // object.entity.removeComponent(ElementSVG, true);
2590
3145
  }
2591
3146
  }
2592
- };
2593
- _proto.removeSVGDom = function removeSVGDom(object) {
2594
- var _object$elementSVG6;
2595
- // @ts-ignore
2596
- var $groupEl = (_object$elementSVG6 = object.elementSVG) === null || _object$elementSVG6 === void 0 ? void 0 : _object$elementSVG6.$groupEl;
2597
- if ($groupEl && $groupEl.parentNode) {
2598
- $groupEl.parentNode.removeChild($groupEl);
3147
+ }, {
3148
+ key: "createOrUpdateHitArea",
3149
+ value: function createOrUpdateHitArea(object, $el, $groupEl) {
2599
3150
  // @ts-ignore
2600
- this.context.SVGElementLifeCycleContribution.destroyElement(object, $groupEl);
2601
- // object.entity.removeComponent(ElementSVG, true);
2602
- }
2603
- };
2604
-
2605
- _proto.createOrUpdateHitArea = function createOrUpdateHitArea(object, $el, $groupEl) {
2606
- // @ts-ignore
2607
- var svgElement = object.elementSVG;
2608
- var $hitTestingEl = svgElement.$hitTestingEl;
2609
- var increasedLineWidthForHitTesting = object.parsedStyle.increasedLineWidthForHitTesting;
2610
- // account for hitArea
2611
- if (increasedLineWidthForHitTesting) {
2612
- if (!$hitTestingEl) {
2613
- $hitTestingEl = $el.cloneNode();
2614
- if (this.pluginOptions.outputSVGElementId) {
2615
- // use the entity suffix, so that `g-plugin-svg-picker` can extract
2616
- $hitTestingEl.id = G_SVG_PREFIX + "-" + object.nodeName + "-hittesting-" + object.entity;
3151
+ var svgElement = object.elementSVG;
3152
+ var $hitTestingEl = svgElement.$hitTestingEl;
3153
+ var increasedLineWidthForHitTesting = object.parsedStyle.increasedLineWidthForHitTesting;
3154
+ // account for hitArea
3155
+ if (increasedLineWidthForHitTesting) {
3156
+ if (!$hitTestingEl) {
3157
+ $hitTestingEl = $el.cloneNode();
3158
+ if (this.pluginOptions.outputSVGElementId) {
3159
+ // use the entity suffix, so that `g-plugin-svg-picker` can extract
3160
+ $hitTestingEl.id = "".concat(G_SVG_PREFIX, "-").concat(object.nodeName, "-hittesting-").concat(object.entity);
3161
+ }
3162
+ // clear attributes like `filter` `font-size`
3163
+ ['filter'].forEach(function (attribute) {
3164
+ $hitTestingEl.removeAttribute(attribute);
3165
+ });
3166
+ // hitArea should be 'transparent' but not 'none'
3167
+ var hasFill = $el.getAttribute('fill') !== 'none';
3168
+ $hitTestingEl.setAttribute('fill', hasFill ? 'transparent' : 'none');
3169
+ $hitTestingEl.setAttribute('stroke', 'transparent');
3170
+ $groupEl.appendChild($hitTestingEl);
3171
+ svgElement.$hitTestingEl = $hitTestingEl;
3172
+ }
3173
+ // increase interactive line width
3174
+ $hitTestingEl.setAttribute('stroke-width', "".concat(increasedLineWidthForHitTesting + object.parsedStyle.lineWidth));
3175
+ } else {
3176
+ if ($hitTestingEl) {
3177
+ $groupEl.removeChild($hitTestingEl);
3178
+ svgElement.$hitTestingEl = null;
2617
3179
  }
2618
- // clear attributes like `filter` `font-size`
2619
- ['filter'].forEach(function (attribute) {
2620
- $hitTestingEl.removeAttribute(attribute);
2621
- });
2622
- // hitArea should be 'transparent' but not 'none'
2623
- var hasFill = $el.getAttribute('fill') !== 'none';
2624
- $hitTestingEl.setAttribute('fill', hasFill ? 'transparent' : 'none');
2625
- $hitTestingEl.setAttribute('stroke', 'transparent');
2626
- $groupEl.appendChild($hitTestingEl);
2627
- svgElement.$hitTestingEl = $hitTestingEl;
2628
- }
2629
- // increase interactive line width
2630
- $hitTestingEl.setAttribute('stroke-width', "" + (increasedLineWidthForHitTesting + object.parsedStyle.lineWidth));
2631
- } else {
2632
- if ($hitTestingEl) {
2633
- $groupEl.removeChild($hitTestingEl);
2634
- svgElement.$hitTestingEl = null;
2635
3180
  }
2636
3181
  }
2637
- };
2638
- _proto.createOrUpdateInnerHTML = function createOrUpdateInnerHTML(doc, $el, usedValue) {
2639
- var $div = (doc || document).createElement('div');
2640
- if (typeof usedValue === 'string') {
2641
- $div.innerHTML = usedValue;
2642
- } else {
2643
- $div.appendChild(usedValue);
2644
- }
2645
- $el.innerHTML = '';
2646
- $el.appendChild($div);
2647
- };
2648
- _proto.createOrUpdateClipOrTextPath = function createOrUpdateClipOrTextPath(document, clipPath, object, isTextPath) {
2649
- if (isTextPath === void 0) {
2650
- isTextPath = false;
3182
+ }, {
3183
+ key: "createOrUpdateInnerHTML",
3184
+ value: function createOrUpdateInnerHTML(doc, $el, usedValue) {
3185
+ var $div = (doc || document).createElement('div');
3186
+ if (typeof usedValue === 'string') {
3187
+ $div.innerHTML = usedValue;
3188
+ } else {
3189
+ $div.appendChild(usedValue);
3190
+ }
3191
+ $el.innerHTML = '';
3192
+ $el.appendChild($div);
2651
3193
  }
2652
- // @ts-ignore
2653
- var $groupEl = object.elementSVG.$groupEl;
2654
- var PREFIX = isTextPath ? TEXT_PATH_PREFIX : CLIP_PATH_PREFIX;
2655
- var attributeNameCamel = isTextPath ? 'g' : 'clipPath';
2656
- var attributeNameHyphen = isTextPath ? 'text-path' : 'clip-path';
2657
- if (clipPath) {
2658
- var clipPathId = PREFIX + clipPath.entity + '-' + object.entity;
2659
- var $def = this.defElementManager.getDefElement();
2660
- var existed = $def.querySelector("#" + clipPathId);
2661
- if (!existed) {
2662
- var $clipPath;
2663
- if (isTextPath) {
2664
- // use <path> directly instead of wrapping with <g>
2665
- this.createSVGDom(document, clipPath, null, true);
2666
- // @ts-ignore
2667
- $clipPath = clipPath.elementSVG.$el;
2668
- } else {
2669
- // the clipPath is allowed to be detached from canvas
2670
- if (!clipPath.isConnected) {
2671
- var $existedClipPath = $def.querySelector("#" + this.getId(clipPath));
2672
- if (!$existedClipPath) {
2673
- this.createSVGDom(document, clipPath, $def, true);
3194
+ }, {
3195
+ key: "createOrUpdateClipOrTextPath",
3196
+ value: function createOrUpdateClipOrTextPath(document, clipPath, object) {
3197
+ var isTextPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
3198
+ // @ts-ignore
3199
+ var $groupEl = object.elementSVG.$groupEl;
3200
+ var PREFIX = isTextPath ? TEXT_PATH_PREFIX : CLIP_PATH_PREFIX;
3201
+ var attributeNameCamel = isTextPath ? 'g' : 'clipPath';
3202
+ var attributeNameHyphen = isTextPath ? 'text-path' : 'clip-path';
3203
+ if (clipPath) {
3204
+ var clipPathId = PREFIX + clipPath.entity + '-' + object.entity;
3205
+ var $def = this.defElementManager.getDefElement();
3206
+ var existed = $def.querySelector("#".concat(clipPathId));
3207
+ if (!existed) {
3208
+ var $clipPath;
3209
+ if (isTextPath) {
3210
+ // use <path> directly instead of wrapping with <g>
3211
+ this.createSVGDom(document, clipPath, null, true);
3212
+ // @ts-ignore
3213
+ $clipPath = clipPath.elementSVG.$el;
3214
+ } else {
3215
+ // the clipPath is allowed to be detached from canvas
3216
+ if (!clipPath.isConnected) {
3217
+ var $existedClipPath = $def.querySelector("#".concat(this.getId(clipPath)));
3218
+ if (!$existedClipPath) {
3219
+ this.createSVGDom(document, clipPath, $def, true);
3220
+ }
2674
3221
  }
3222
+ // create <clipPath> dom node
3223
+ $clipPath = createSVGElement(attributeNameCamel, document);
3224
+ var $use = createSVGElement('use', document);
3225
+ // @ts-ignore
3226
+ $use.setAttribute('href', "#".concat(clipPath.elementSVG.$el.id));
3227
+ $clipPath.appendChild($use);
3228
+ var $useRefs = this.clipPathUseMap.get(clipPath);
3229
+ if (!$useRefs) {
3230
+ this.clipPathUseMap.set(clipPath, []);
3231
+ $useRefs = this.clipPathUseMap.get(clipPath);
3232
+ }
3233
+ $useRefs.push($use);
3234
+ // <clipPath transform="matrix()"><circle /></clipPath>
3235
+ this.applyTransform($use, clipPath.getWorldTransform());
3236
+ var parentInvert = invert(create(), object.getWorldTransform());
3237
+ this.applyTransform($clipPath, parentInvert);
2675
3238
  }
2676
- // create <clipPath> dom node
2677
- $clipPath = createSVGElement(attributeNameCamel, document);
2678
- var $use = createSVGElement('use', document);
2679
- // @ts-ignore
2680
- $use.setAttribute('href', "#" + clipPath.elementSVG.$el.id);
2681
- $clipPath.appendChild($use);
2682
- var $useRefs = this.clipPathUseMap.get(clipPath);
2683
- if (!$useRefs) {
2684
- this.clipPathUseMap.set(clipPath, []);
2685
- $useRefs = this.clipPathUseMap.get(clipPath);
2686
- }
2687
- $useRefs.push($use);
2688
- // <clipPath transform="matrix()"><circle /></clipPath>
2689
- this.applyTransform($use, clipPath.getWorldTransform());
2690
- var parentInvert = invert(create(), object.getWorldTransform());
2691
- this.applyTransform($clipPath, parentInvert);
3239
+ $clipPath.id = clipPathId;
3240
+ // append it to <defs>
3241
+ $def.appendChild($clipPath);
2692
3242
  }
2693
- $clipPath.id = clipPathId;
2694
- // append it to <defs>
2695
- $def.appendChild($clipPath);
2696
- }
2697
- // apply attributes
2698
- this.applyAttributes(clipPath);
2699
- if (!isTextPath) {
2700
- // apply clipPath to $group
2701
- // @see https://github.com/antvis/g/issues/961
2702
- $groupEl.setAttribute(attributeNameHyphen, "url(#" + clipPathId + ")");
2703
- }
2704
- } else {
2705
- if (!isTextPath) {
2706
- // remove clip path
2707
- $groupEl.removeAttribute(attributeNameHyphen);
2708
- }
2709
- }
2710
- }
2711
- /**
2712
- * the origin is bounding box's top left corner
2713
- */;
2714
- _proto.updateAnchorWithTransform = function updateAnchorWithTransform(object) {
2715
- var _object$elementSVG7, _object$elementSVG8;
2716
- var bounds = object.getGeometryBounds();
2717
- var width = bounds && bounds.halfExtents[0] * 2 || 0;
2718
- var height = bounds && bounds.halfExtents[1] * 2 || 0;
2719
- var _ref2 = object.parsedStyle || {},
2720
- anchor = _ref2.anchor;
2721
- // @ts-ignore
2722
- [(_object$elementSVG7 = object.elementSVG) === null || _object$elementSVG7 === void 0 ? void 0 : _object$elementSVG7.$el, (_object$elementSVG8 = object.elementSVG) === null || _object$elementSVG8 === void 0 ? void 0 : _object$elementSVG8.$hitTestingEl].forEach(function ($el) {
2723
- if ($el) {
2724
- var tx = -(anchor[0] * width);
2725
- var ty = -(anchor[1] * height);
2726
- if (tx !== 0 || ty !== 0) {
2727
- // apply anchor to element's `transform` property
2728
- $el.setAttribute('transform',
2729
- // can't use percent unit like translate(-50%, -50%)
2730
- // @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/transform#translate
2731
- "translate(" + tx + "," + ty + ")");
3243
+ // apply attributes
3244
+ this.applyAttributes(clipPath);
3245
+ if (!isTextPath) {
3246
+ // apply clipPath to $group
3247
+ // @see https://github.com/antvis/g/issues/961
3248
+ $groupEl.setAttribute(attributeNameHyphen, "url(#".concat(clipPathId, ")"));
2732
3249
  }
2733
- if (object.nodeName === gLite.Shape.CIRCLE || object.nodeName === gLite.Shape.ELLIPSE) {
2734
- $el.setAttribute('cx', "" + width / 2);
2735
- $el.setAttribute('cy', "" + height / 2);
3250
+ } else {
3251
+ if (!isTextPath) {
3252
+ // remove clip path
3253
+ $groupEl.removeAttribute(attributeNameHyphen);
2736
3254
  }
2737
3255
  }
2738
- });
2739
- };
3256
+ }
3257
+ /**
3258
+ * the origin is bounding box's top left corner
3259
+ */
3260
+ }, {
3261
+ key: "updateAnchorWithTransform",
3262
+ value: function updateAnchorWithTransform(object) {
3263
+ var _object$elementSVG7, _object$elementSVG8;
3264
+ var bounds = object.getGeometryBounds();
3265
+ var width = bounds && bounds.halfExtents[0] * 2 || 0;
3266
+ var height = bounds && bounds.halfExtents[1] * 2 || 0;
3267
+ var _ref2 = object.parsedStyle || {},
3268
+ anchor = _ref2.anchor;
3269
+ // @ts-ignore
3270
+ [(_object$elementSVG7 = object.elementSVG) === null || _object$elementSVG7 === void 0 ? void 0 : _object$elementSVG7.$el, (_object$elementSVG8 = object.elementSVG) === null || _object$elementSVG8 === void 0 ? void 0 : _object$elementSVG8.$hitTestingEl].forEach(function ($el) {
3271
+ if ($el) {
3272
+ var tx = -(anchor[0] * width);
3273
+ var ty = -(anchor[1] * height);
3274
+ if (tx !== 0 || ty !== 0) {
3275
+ // apply anchor to element's `transform` property
3276
+ $el.setAttribute('transform',
3277
+ // can't use percent unit like translate(-50%, -50%)
3278
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/transform#translate
3279
+ "translate(".concat(tx, ",").concat(ty, ")"));
3280
+ }
3281
+ if (object.nodeName === gLite.Shape.CIRCLE || object.nodeName === gLite.Shape.ELLIPSE) {
3282
+ $el.setAttribute('cx', "".concat(width / 2));
3283
+ $el.setAttribute('cy', "".concat(height / 2));
3284
+ }
3285
+ }
3286
+ });
3287
+ }
3288
+ }]);
2740
3289
  return SVGRendererPlugin;
2741
3290
  }();
2742
3291
  SVGRendererPlugin.tag = 'SVGRenderer';
@@ -2778,18 +3327,18 @@
2778
3327
  var lineNum = lines.length;
2779
3328
  var styleCSSText = '';
2780
3329
  if (dx !== 0 || dy !== 0) {
2781
- styleCSSText += "transform:translate(" + dx + "px, " + dy + "px);";
3330
+ styleCSSText += "transform:translate(".concat(dx, "px, ").concat(dy, "px);");
2782
3331
  }
2783
3332
  if (textDecorationLine && textDecorationLine !== 'none') {
2784
3333
  // use CSS text-decoration since the implementation in SVG is not good enough
2785
- styleCSSText += "text-decoration:" + textDecorationLine + " " + textDecorationStyle + " " + textDecorationColor + ";";
3334
+ styleCSSText += "text-decoration:".concat(textDecorationLine, " ").concat(textDecorationStyle, " ").concat(textDecorationColor, ";");
2786
3335
  }
2787
3336
  if (styleCSSText) {
2788
3337
  $el.setAttribute('style', styleCSSText);
2789
3338
  }
2790
3339
  if (lineNum === 1) {
2791
3340
  var textContent = convertHTML(lines[0]);
2792
- $el.setAttribute('dx', "" + lineWidth / 2);
3341
+ $el.setAttribute('dx', "".concat(lineWidth / 2));
2793
3342
  // Since `text-after-edge` is not a standard property value, we use `dy` instead.
2794
3343
  if (textBaseline === 'bottom' || textBaseline === 'top') {
2795
3344
  $el.setAttribute('dominant-baseline', 'middle');
@@ -2802,12 +3351,12 @@
2802
3351
  $el.innerHTML = '';
2803
3352
  // append <textPath href="#MyPath">text</textPath>
2804
3353
  var $textPath = createSVGElement('textPath', $el.ownerDocument);
2805
- $textPath.setAttribute('href', "#" + (TEXT_PATH_PREFIX + textPath.entity));
3354
+ $textPath.setAttribute('href', "#".concat(TEXT_PATH_PREFIX + textPath.entity));
2806
3355
  if (textPathSide !== 'left') {
2807
3356
  $textPath.setAttribute('side', textPathSide);
2808
3357
  }
2809
3358
  if (textPathStartOffset !== 0) {
2810
- $textPath.setAttribute('startOffset', "" + textPathStartOffset);
3359
+ $textPath.setAttribute('startOffset', "".concat(textPathStartOffset));
2811
3360
  }
2812
3361
  $textPath.innerHTML = textContent;
2813
3362
  $el.appendChild($textPath);
@@ -2830,72 +3379,81 @@
2830
3379
  } else {
2831
3380
  dy = lineHeight;
2832
3381
  }
2833
- return "<tspan x=\"0\" dx=\"" + dx + "\" dy=\"" + dy + "\">" + convertHTML(line) + "</tspan>";
3382
+ return "<tspan x=\"0\" dx=\"".concat(dx, "\" dy=\"").concat(dy, "\">").concat(convertHTML(line), "</tspan>");
2834
3383
  }).join('');
2835
3384
  }
2836
3385
  }
2837
3386
  var _SHAPE2TAGS, _SHAPE_UPDATE_DEPS;
2838
- var SHAPE2TAGS = (_SHAPE2TAGS = {}, _SHAPE2TAGS[gLite.Shape.RECT] = 'path', _SHAPE2TAGS[gLite.Shape.CIRCLE] = 'circle', _SHAPE2TAGS[gLite.Shape.ELLIPSE] = 'ellipse', _SHAPE2TAGS[gLite.Shape.IMAGE] = 'image', _SHAPE2TAGS[gLite.Shape.GROUP] = 'g', _SHAPE2TAGS[gLite.Shape.LINE] = 'line', _SHAPE2TAGS[gLite.Shape.POLYLINE] = 'polyline', _SHAPE2TAGS[gLite.Shape.POLYGON] = 'polygon', _SHAPE2TAGS[gLite.Shape.TEXT] = 'text', _SHAPE2TAGS[gLite.Shape.PATH] = 'path', _SHAPE2TAGS[gLite.Shape.HTML] = 'foreignObject', _SHAPE2TAGS);
2839
- var SHAPE_UPDATE_DEPS = (_SHAPE_UPDATE_DEPS = {}, _SHAPE_UPDATE_DEPS[gLite.Shape.CIRCLE] = ['r'], _SHAPE_UPDATE_DEPS[gLite.Shape.ELLIPSE] = ['rx', 'ry'], _SHAPE_UPDATE_DEPS[gLite.Shape.RECT] = ['width', 'height', 'radius'], _SHAPE_UPDATE_DEPS[gLite.Shape.IMAGE] = ['img', 'width', 'height'], _SHAPE_UPDATE_DEPS[gLite.Shape.LINE] = ['x1', 'y1', 'x2', 'y2', 'markerStart', 'markerEnd', 'markerStartOffset', 'markerEndOffset'], _SHAPE_UPDATE_DEPS[gLite.Shape.POLYLINE] = ['points', 'markerStart', 'markerEnd', 'markerMid', 'markerStartOffset', 'markerEndOffset'], _SHAPE_UPDATE_DEPS[gLite.Shape.POLYGON] = ['points', 'markerStart', 'markerEnd', 'markerMid', 'markerStartOffset', 'markerEndOffset'], _SHAPE_UPDATE_DEPS[gLite.Shape.PATH] = ['path', 'markerStart', 'markerEnd', 'markerMid', 'markerStartOffset', 'markerEndOffset'], _SHAPE_UPDATE_DEPS[gLite.Shape.TEXT] = ['text', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'wordWrap', 'wordWrapWidth', 'maxLines', 'leading', 'textBaseline', 'textAlign', 'textTransform', 'textOverflow', 'textPath', 'textPathSide', 'textPathStartOffset', 'textDecorationLine', 'textDecorationColor', 'textDecorationStyle',
3387
+ var SHAPE2TAGS = (_SHAPE2TAGS = {}, _defineProperty(_SHAPE2TAGS, gLite.Shape.RECT, 'path'), _defineProperty(_SHAPE2TAGS, gLite.Shape.CIRCLE, 'circle'), _defineProperty(_SHAPE2TAGS, gLite.Shape.ELLIPSE, 'ellipse'), _defineProperty(_SHAPE2TAGS, gLite.Shape.IMAGE, 'image'), _defineProperty(_SHAPE2TAGS, gLite.Shape.GROUP, 'g'), _defineProperty(_SHAPE2TAGS, gLite.Shape.LINE, 'line'), _defineProperty(_SHAPE2TAGS, gLite.Shape.POLYLINE, 'polyline'), _defineProperty(_SHAPE2TAGS, gLite.Shape.POLYGON, 'polygon'), _defineProperty(_SHAPE2TAGS, gLite.Shape.TEXT, 'text'), _defineProperty(_SHAPE2TAGS, gLite.Shape.PATH, 'path'), _defineProperty(_SHAPE2TAGS, gLite.Shape.HTML, 'foreignObject'), _SHAPE2TAGS);
3388
+ var SHAPE_UPDATE_DEPS = (_SHAPE_UPDATE_DEPS = {}, _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.CIRCLE, ['r']), _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.ELLIPSE, ['rx', 'ry']), _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.RECT, ['width', 'height', 'radius']), _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.IMAGE, ['img', 'width', 'height']), _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.LINE, ['x1', 'y1', 'x2', 'y2', 'markerStart', 'markerEnd', 'markerStartOffset', 'markerEndOffset']), _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.POLYLINE, ['points', 'markerStart', 'markerEnd', 'markerMid', 'markerStartOffset', 'markerEndOffset']), _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.POLYGON, ['points', 'markerStart', 'markerEnd', 'markerMid', 'markerStartOffset', 'markerEndOffset']), _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.PATH, ['path', 'markerStart', 'markerEnd', 'markerMid', 'markerStartOffset', 'markerEndOffset']), _defineProperty(_SHAPE_UPDATE_DEPS, gLite.Shape.TEXT, ['text', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'wordWrap', 'wordWrapWidth', 'maxLines', 'leading', 'textBaseline', 'textAlign', 'textTransform', 'textOverflow', 'textPath', 'textPathSide', 'textPathStartOffset', 'textDecorationLine', 'textDecorationColor', 'textDecorationStyle',
2840
3389
  // 'whiteSpace',
2841
- 'dx', 'dy'], _SHAPE_UPDATE_DEPS);
3390
+ 'dx', 'dy']), _SHAPE_UPDATE_DEPS);
2842
3391
  var DefaultElementLifeCycleContribution = /*#__PURE__*/function () {
2843
3392
  function DefaultElementLifeCycleContribution(context) {
3393
+ _classCallCheck$3(this, DefaultElementLifeCycleContribution);
2844
3394
  this.context = void 0;
2845
3395
  this.context = context;
2846
3396
  }
2847
- var _proto = DefaultElementLifeCycleContribution.prototype;
2848
- _proto.createElement = function createElement(object, svgElementMap) {
2849
- var doc = this.context.config.document;
2850
- var type = SHAPE2TAGS[object.nodeName] || 'g';
2851
- var $el = createSVGElement(type, doc || document);
2852
- svgElementMap.set($el, object);
2853
- return $el;
2854
- };
2855
- _proto.destroyElement = function destroyElement(object, $el) {};
2856
- _proto.shouldUpdateElementAttribute = function shouldUpdateElementAttribute(object, attributeName) {
2857
- var nodeName = object.nodeName;
2858
- return (SHAPE_UPDATE_DEPS[nodeName] || []).indexOf(attributeName) > -1;
2859
- };
2860
- _proto.updateElementAttribute = function updateElementAttribute(object) {
2861
- // @ts-ignore
2862
- var $el = object.elementSVG.$el;
2863
- var nodeName = object.nodeName,
2864
- parsedStyle = object.parsedStyle;
2865
- switch (nodeName) {
2866
- case gLite.Shape.IMAGE:
2867
- {
2868
- updateImageElementAttribute($el, parsedStyle);
2869
- break;
2870
- }
2871
- case gLite.Shape.RECT:
2872
- {
2873
- updateRectElementAttribute($el, parsedStyle);
2874
- break;
2875
- }
2876
- case gLite.Shape.LINE:
2877
- {
2878
- updateLineElementAttribute($el, parsedStyle);
2879
- break;
2880
- }
2881
- case gLite.Shape.POLYGON:
2882
- case gLite.Shape.POLYLINE:
2883
- {
2884
- updatePolylineElementAttribute($el, parsedStyle);
2885
- break;
2886
- }
2887
- case gLite.Shape.PATH:
2888
- {
2889
- updatePathElementAttribute($el, parsedStyle);
2890
- break;
2891
- }
2892
- case gLite.Shape.TEXT:
2893
- {
2894
- updateTextElementAttribute($el, parsedStyle);
2895
- break;
2896
- }
3397
+ _createClass$3(DefaultElementLifeCycleContribution, [{
3398
+ key: "createElement",
3399
+ value: function createElement(object, svgElementMap) {
3400
+ var doc = this.context.config.document;
3401
+ var type = SHAPE2TAGS[object.nodeName] || 'g';
3402
+ var $el = createSVGElement(type, doc || document);
3403
+ svgElementMap.set($el, object);
3404
+ return $el;
2897
3405
  }
2898
- };
3406
+ }, {
3407
+ key: "destroyElement",
3408
+ value: function destroyElement(object, $el) {}
3409
+ }, {
3410
+ key: "shouldUpdateElementAttribute",
3411
+ value: function shouldUpdateElementAttribute(object, attributeName) {
3412
+ var nodeName = object.nodeName;
3413
+ return (SHAPE_UPDATE_DEPS[nodeName] || []).indexOf(attributeName) > -1;
3414
+ }
3415
+ }, {
3416
+ key: "updateElementAttribute",
3417
+ value: function updateElementAttribute(object) {
3418
+ // @ts-ignore
3419
+ var $el = object.elementSVG.$el;
3420
+ var nodeName = object.nodeName,
3421
+ parsedStyle = object.parsedStyle;
3422
+ switch (nodeName) {
3423
+ case gLite.Shape.IMAGE:
3424
+ {
3425
+ updateImageElementAttribute($el, parsedStyle);
3426
+ break;
3427
+ }
3428
+ case gLite.Shape.RECT:
3429
+ {
3430
+ updateRectElementAttribute($el, parsedStyle);
3431
+ break;
3432
+ }
3433
+ case gLite.Shape.LINE:
3434
+ {
3435
+ updateLineElementAttribute($el, parsedStyle);
3436
+ break;
3437
+ }
3438
+ case gLite.Shape.POLYGON:
3439
+ case gLite.Shape.POLYLINE:
3440
+ {
3441
+ updatePolylineElementAttribute($el, parsedStyle);
3442
+ break;
3443
+ }
3444
+ case gLite.Shape.PATH:
3445
+ {
3446
+ updatePathElementAttribute($el, parsedStyle);
3447
+ break;
3448
+ }
3449
+ case gLite.Shape.TEXT:
3450
+ {
3451
+ updateTextElementAttribute($el, parsedStyle);
3452
+ break;
3453
+ }
3454
+ }
3455
+ }
3456
+ }]);
2899
3457
  return DefaultElementLifeCycleContribution;
2900
3458
  }();
2901
3459
  var FILTER_PREFIX = 'g-filter-';
@@ -2906,7 +3464,7 @@
2906
3464
  function createOrUpdateFilter(document, $def, object, $el, filters) {
2907
3465
  // eg. filter="url(#f1) url(#f2)"
2908
3466
  var filterName = FILTER_PREFIX + object.entity;
2909
- var $existedFilters = $def.querySelectorAll("[name=" + filterName + "]");
3467
+ var $existedFilters = $def.querySelectorAll("[name=".concat(filterName, "]"));
2910
3468
  if ($existedFilters.length) {
2911
3469
  $existedFilters.forEach(function ($filter) {
2912
3470
  $def.removeChild($filter);
@@ -2941,7 +3499,7 @@
2941
3499
  } else if (name === 'invert') {
2942
3500
  createInvert(document, $filter, params);
2943
3501
  }
2944
- $filter.id = filterName + "-" + i;
3502
+ $filter.id = "".concat(filterName, "-").concat(i);
2945
3503
  $filter.setAttribute('name', filterName);
2946
3504
  $def.appendChild($filter);
2947
3505
  return $filter.id;
@@ -2949,7 +3507,7 @@
2949
3507
  // @see https://github.com/antvis/G/issues/1114
2950
3508
  setTimeout(function () {
2951
3509
  $el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', filterIds.map(function (filterId) {
2952
- return "url(#" + filterId + ")";
3510
+ return "url(#".concat(filterId, ")");
2953
3511
  }).join(' '));
2954
3512
  });
2955
3513
  }
@@ -2963,7 +3521,7 @@
2963
3521
  function createBlur(document, $filter, params) {
2964
3522
  var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
2965
3523
  $feGaussianBlur.setAttribute('in', 'SourceGraphic');
2966
- $feGaussianBlur.setAttribute('stdDeviation', "" + params[0].value);
3524
+ $feGaussianBlur.setAttribute('stdDeviation', "".concat(params[0].value));
2967
3525
  $filter.appendChild($feGaussianBlur);
2968
3526
  }
2969
3527
  function createFeComponentTransfer(document, $filter, _ref2) {
@@ -2975,10 +3533,10 @@
2975
3533
  [createSVGElement('feFuncR', document), createSVGElement('feFuncG', document), createSVGElement('feFuncB', document)].forEach(function ($feFunc) {
2976
3534
  $feFunc.setAttribute('type', type);
2977
3535
  if (type === 'table') {
2978
- $feFunc.setAttribute('tableValues', "" + tableValues);
3536
+ $feFunc.setAttribute('tableValues', "".concat(tableValues));
2979
3537
  } else {
2980
- $feFunc.setAttribute('slope', "" + slope);
2981
- $feFunc.setAttribute('intercept', "" + intercept);
3538
+ $feFunc.setAttribute('slope', "".concat(slope));
3539
+ $feFunc.setAttribute('intercept', "".concat(intercept));
2982
3540
  }
2983
3541
  $feComponentTransfer.appendChild($feFunc);
2984
3542
  });
@@ -2996,7 +3554,7 @@
2996
3554
  var amount = convertToAbsoluteValue(params[0]);
2997
3555
  createFeComponentTransfer(document, $filter, {
2998
3556
  type: 'table',
2999
- tableValues: amount + " " + (1 - amount)
3557
+ tableValues: "".concat(amount, " ").concat(1 - amount)
3000
3558
  });
3001
3559
  }
3002
3560
  function createBrightness(document, $filter, params) {
@@ -3011,7 +3569,7 @@
3011
3569
  var amount = convertToAbsoluteValue(params[0]);
3012
3570
  var $feColorMatrix = createSVGElement('feColorMatrix', document);
3013
3571
  $feColorMatrix.setAttribute('type', 'saturate');
3014
- $feColorMatrix.setAttribute('values', "" + amount);
3572
+ $feColorMatrix.setAttribute('values', "".concat(amount));
3015
3573
  $filter.appendChild($feColorMatrix);
3016
3574
  }
3017
3575
  function createHueRotate(document, $filter, params) {
@@ -3019,7 +3577,7 @@
3019
3577
  $feColorMatrix.setAttribute('type', 'hueRotate');
3020
3578
  // $feColorMatrix.setAttribute('values', `${params[0].to(UnitType.kDegrees).value}`);
3021
3579
  // FIXME: convert to degrees
3022
- $feColorMatrix.setAttribute('values', "" + params[0].value);
3580
+ $feColorMatrix.setAttribute('values', "".concat(params[0].value));
3023
3581
  $filter.appendChild($feColorMatrix);
3024
3582
  }
3025
3583
  function createDropShadow(document, $filter, params) {
@@ -3030,11 +3588,11 @@
3030
3588
  var shadowColor = params[3].formatted;
3031
3589
  var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
3032
3590
  $feGaussianBlur.setAttribute('in', 'SourceAlpha');
3033
- $feGaussianBlur.setAttribute('stdDeviation', "" + shadowBlur);
3591
+ $feGaussianBlur.setAttribute('stdDeviation', "".concat(shadowBlur));
3034
3592
  $filter.appendChild($feGaussianBlur);
3035
3593
  var $feOffset = createSVGElement('feOffset', document);
3036
- $feOffset.setAttribute('dx', "" + shadowOffsetX);
3037
- $feOffset.setAttribute('dy', "" + shadowOffsetY);
3594
+ $feOffset.setAttribute('dx', "".concat(shadowOffsetX));
3595
+ $feOffset.setAttribute('dy', "".concat(shadowOffsetY));
3038
3596
  $feOffset.setAttribute('result', 'offsetblur');
3039
3597
  $filter.appendChild($feOffset);
3040
3598
  var $feFlood = createSVGElement('feFlood', document);
@@ -3092,34 +3650,32 @@
3092
3650
  var patternId = createOrUpdatePattern(document, $def, object, parsedColor, createImage, plugin);
3093
3651
  // use style instead of attribute when applying <pattern>
3094
3652
  // @see https://stackoverflow.com/a/7723115
3095
- $el.style[name] = "url(#" + patternId + ")";
3653
+ $el.style[name] = "url(#".concat(patternId, ")");
3096
3654
  return patternId;
3097
3655
  } else {
3098
3656
  if (parsedColor.length === 1) {
3099
3657
  var gradientId = createOrUpdateGradient(document, object, $def, $el, parsedColor[0]);
3100
- $el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#" + gradientId + ")");
3658
+ $el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#".concat(gradientId, ")"));
3101
3659
  return gradientId;
3102
3660
  } else {
3103
3661
  // @see https://stackoverflow.com/questions/20671502/can-i-blend-gradients-in-svg
3104
3662
  var filterId = createOrUpdateMultiGradient(document, object, $def, $el, parsedColor);
3105
- $el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + filterId + ")");
3663
+ $el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#".concat(filterId, ")"));
3106
3664
  $el === null || $el === void 0 ? void 0 : $el.setAttribute('fill', 'black');
3107
3665
  return filterId;
3108
3666
  }
3109
3667
  }
3110
3668
  return '';
3111
3669
  }
3112
- function generateCacheKey(src, options) {
3113
- if (options === void 0) {
3114
- options = {};
3115
- }
3670
+ function generateCacheKey(src) {
3671
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3116
3672
  var cacheKey = '';
3117
3673
  if (gLite.isCSSGradientValue(src)) {
3118
3674
  var type = src.type,
3119
3675
  value = src.value;
3120
3676
  if (type === gLite.GradientType.LinearGradient || type === gLite.GradientType.RadialGradient) {
3121
3677
  // @ts-ignore
3122
- var _value$options = _extends({}, value, options),
3678
+ var _value$options = _objectSpread2(_objectSpread2({}, value), options),
3123
3679
  _type = _value$options.type,
3124
3680
  width = _value$options.width,
3125
3681
  height = _value$options.height,
@@ -3128,25 +3684,25 @@
3128
3684
  cx = _value$options.cx,
3129
3685
  cy = _value$options.cy,
3130
3686
  size = _value$options.size;
3131
- cacheKey = "gradient-" + _type + "-" + ((angle === null || angle === void 0 ? void 0 : angle.toString()) || 0) + "-" + ((cx === null || cx === void 0 ? void 0 : cx.toString()) || 0) + "-" + ((cy === null || cy === void 0 ? void 0 : cy.toString()) || 0) + "-" + ((size === null || size === void 0 ? void 0 : size.toString()) || 0) + "-" + width + "-" + height + "-" + steps.map(function (_ref) {
3687
+ cacheKey = "gradient-".concat(_type, "-").concat((angle === null || angle === void 0 ? void 0 : angle.toString()) || 0, "-").concat((cx === null || cx === void 0 ? void 0 : cx.toString()) || 0, "-").concat((cy === null || cy === void 0 ? void 0 : cy.toString()) || 0, "-").concat((size === null || size === void 0 ? void 0 : size.toString()) || 0, "-").concat(width, "-").concat(height, "-").concat(steps.map(function (_ref) {
3132
3688
  var offset = _ref.offset,
3133
3689
  color = _ref.color;
3134
- return "" + offset + color;
3135
- }).join('-');
3690
+ return "".concat(offset).concat(color);
3691
+ }).join('-'));
3136
3692
  }
3137
3693
  } else if (gLite.isPattern(src)) {
3138
3694
  if (isString(src.image)) {
3139
- cacheKey = "pattern-" + src.image + "-" + src.repetition;
3695
+ cacheKey = "pattern-".concat(src.image, "-").concat(src.repetition);
3140
3696
  } else if (src.image.nodeName === 'rect') {
3141
3697
  // use rect's entity as key
3142
- cacheKey = "pattern-rect-" + src.image.entity;
3698
+ cacheKey = "pattern-rect-".concat(src.image.entity);
3143
3699
  } else {
3144
- cacheKey = "pattern-" + counter;
3700
+ cacheKey = "pattern-".concat(counter);
3145
3701
  }
3146
3702
  }
3147
3703
  if (cacheKey) {
3148
3704
  if (!cacheKey2IDMap[cacheKey]) {
3149
- cacheKey2IDMap[cacheKey] = PATTERN_PREFIX + ("" + counter++);
3705
+ cacheKey2IDMap[cacheKey] = PATTERN_PREFIX + "".concat(counter++);
3150
3706
  }
3151
3707
  }
3152
3708
  return cacheKey2IDMap[cacheKey];
@@ -3158,55 +3714,56 @@
3158
3714
  var t = parsed.t,
3159
3715
  d = parsed.d;
3160
3716
  if (t === 'translate') {
3161
- return "translate(" + d[0].value + " " + d[1].value + ")";
3717
+ return "translate(".concat(d[0].value, " ").concat(d[1].value, ")");
3162
3718
  } else if (t === 'translatex') {
3163
- return "translate(" + d[0].value + " 0)";
3719
+ return "translate(".concat(d[0].value, " 0)");
3164
3720
  } else if (t === 'translatey') {
3165
- return "translate(0 " + d[0].value + ")";
3721
+ return "translate(0 ".concat(d[0].value, ")");
3166
3722
  } else if (t === 'rotate') {
3167
- return "rotate(" + d[0].value + ")";
3723
+ return "rotate(".concat(d[0].value, ")");
3168
3724
  } else if (t === 'scale') {
3169
3725
  // scale(1) scale(1, 1)
3170
3726
  var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) {
3171
3727
  return s.value;
3172
3728
  })) || [1, 1];
3173
- return "scale(" + newScale[0] + ", " + newScale[1] + ")";
3729
+ return "scale(".concat(newScale[0], ", ").concat(newScale[1], ")");
3174
3730
  } else if (t === 'scalex') {
3175
3731
  var _newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) {
3176
3732
  return s.value;
3177
3733
  })) || [1];
3178
- return "scale(" + _newScale[0] + ", 1)";
3734
+ return "scale(".concat(_newScale[0], ", 1)");
3179
3735
  } else if (t === 'scaley') {
3180
3736
  var _newScale2 = (d === null || d === void 0 ? void 0 : d.map(function (s) {
3181
3737
  return s.value;
3182
3738
  })) || [1];
3183
- return "scale(1, " + _newScale2[0] + ")";
3739
+ return "scale(1, ".concat(_newScale2[0], ")");
3184
3740
  } else if (t === 'skew') {
3185
3741
  var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) {
3186
3742
  return s.value;
3187
3743
  })) || [0, 0];
3188
- return "skewX(" + newSkew[0] + ") skewY(" + newSkew[1] + ")";
3744
+ return "skewX(".concat(newSkew[0], ") skewY(").concat(newSkew[1], ")");
3189
3745
  } else if (t === 'skewx') {
3190
3746
  var _newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) {
3191
3747
  return s.value;
3192
3748
  })) || [0];
3193
- return "skewX(" + _newSkew[0] + ")";
3749
+ return "skewX(".concat(_newSkew[0], ")");
3194
3750
  } else if (t === 'skewy') {
3195
3751
  var _newSkew2 = (d === null || d === void 0 ? void 0 : d.map(function (s) {
3196
3752
  return s.value;
3197
3753
  })) || [0];
3198
- return "skewY(" + _newSkew2[0] + ")";
3754
+ return "skewY(".concat(_newSkew2[0], ")");
3199
3755
  } else if (t === 'matrix') {
3200
3756
  var _d$map = d.map(function (s) {
3201
3757
  return s.value;
3202
3758
  }),
3203
- a = _d$map[0],
3204
- b = _d$map[1],
3205
- c = _d$map[2],
3206
- dd = _d$map[3],
3207
- tx = _d$map[4],
3208
- ty = _d$map[5];
3209
- return "matrix(" + a + " " + b + " " + c + " " + dd + " " + tx + " " + ty + ")";
3759
+ _d$map2 = _slicedToArray(_d$map, 6),
3760
+ a = _d$map2[0],
3761
+ b = _d$map2[1],
3762
+ c = _d$map2[2],
3763
+ dd = _d$map2[3],
3764
+ tx = _d$map2[4],
3765
+ ty = _d$map2[5];
3766
+ return "matrix(".concat(a, " ").concat(b, " ").concat(c, " ").concat(dd, " ").concat(tx, " ").concat(ty, ")");
3210
3767
  }
3211
3768
  }).join(' ');
3212
3769
  }
@@ -3237,13 +3794,13 @@
3237
3794
  patternWidth = halfExtents[0] * 2;
3238
3795
  patternHeight = halfExtents[1] * 2;
3239
3796
  }
3240
- $pattern.setAttribute('width', "" + patternWidth);
3241
- $pattern.setAttribute('height', "" + patternHeight);
3797
+ $pattern.setAttribute('width', "".concat(patternWidth));
3798
+ $pattern.setAttribute('height', "".concat(patternHeight));
3242
3799
  return $pattern;
3243
3800
  }
3244
3801
  function createOrUpdatePattern(document, $def, object, pattern, createImage, plugin) {
3245
3802
  var patternId = generateCacheKey(pattern);
3246
- var $existed = $def.querySelector("#" + patternId);
3803
+ var $existed = $def.querySelector("#".concat(patternId));
3247
3804
  if (!$existed) {
3248
3805
  var image = pattern.image;
3249
3806
  var imageURL = '';
@@ -3280,8 +3837,8 @@
3280
3837
  $pattern.appendChild($image);
3281
3838
  $image.setAttribute('x', '0');
3282
3839
  $image.setAttribute('y', '0');
3283
- $image.setAttribute('width', "" + img.width);
3284
- $image.setAttribute('height', "" + img.height);
3840
+ $image.setAttribute('width', "".concat(img.width));
3841
+ $image.setAttribute('height', "".concat(img.height));
3285
3842
  };
3286
3843
  if (img.complete) {
3287
3844
  onload();
@@ -3322,7 +3879,7 @@
3322
3879
  width: width,
3323
3880
  height: height
3324
3881
  });
3325
- var $existed = $def.querySelector("#" + gradientId);
3882
+ var $existed = $def.querySelector("#".concat(gradientId));
3326
3883
  if (!$existed) {
3327
3884
  // <linearGradient> <radialGradient>
3328
3885
  // @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/linearGradient
@@ -3340,7 +3897,7 @@
3340
3897
  var offset = _ref2.offset,
3341
3898
  color = _ref2.color;
3342
3899
  // TODO: support absolute unit like `px`
3343
- innerHTML += "<stop offset=\"" + offset.value / 100 + "\" stop-color=\"" + color + "\"></stop>";
3900
+ innerHTML += "<stop offset=\"".concat(offset.value / 100, "\" stop-color=\"").concat(color, "\"></stop>");
3344
3901
  });
3345
3902
  $existed.innerHTML = innerHTML;
3346
3903
  $existed.id = gradientId;
@@ -3353,10 +3910,10 @@
3353
3910
  y1 = _computeLinearGradien.y1,
3354
3911
  x2 = _computeLinearGradien.x2,
3355
3912
  y2 = _computeLinearGradien.y2;
3356
- $existed.setAttribute('x1', "" + x1);
3357
- $existed.setAttribute('y1', "" + y1);
3358
- $existed.setAttribute('x2', "" + x2);
3359
- $existed.setAttribute('y2', "" + y2);
3913
+ $existed.setAttribute('x1', "".concat(x1));
3914
+ $existed.setAttribute('y1', "".concat(y1));
3915
+ $existed.setAttribute('x2', "".concat(x2));
3916
+ $existed.setAttribute('y2', "".concat(y2));
3360
3917
  // $existed.setAttribute('gradientTransform', `rotate(${angle})`);
3361
3918
  } else {
3362
3919
  var _parsedColor$value = parsedColor.value,
@@ -3367,15 +3924,15 @@
3367
3924
  x = _computeRadialGradien.x,
3368
3925
  y = _computeRadialGradien.y,
3369
3926
  r = _computeRadialGradien.r;
3370
- $existed.setAttribute('cx', "" + x);
3371
- $existed.setAttribute('cy', "" + y);
3372
- $existed.setAttribute('r', "" + r);
3927
+ $existed.setAttribute('cx', "".concat(x));
3928
+ $existed.setAttribute('cy', "".concat(y));
3929
+ $existed.setAttribute('r', "".concat(r));
3373
3930
  }
3374
3931
  return gradientId;
3375
3932
  }
3376
3933
  function createOrUpdateMultiGradient(document, object, $def, $el, gradients) {
3377
3934
  var filterId = FILTER_PREFIX + object.entity + '-gradient';
3378
- var $existed = $def.querySelector("#" + filterId);
3935
+ var $existed = $def.querySelector("#".concat(filterId));
3379
3936
  if (!$existed) {
3380
3937
  $existed = createSVGElement('filter', document);
3381
3938
  $existed.setAttribute('filterUnits', 'userSpaceOnUse');
@@ -3405,25 +3962,25 @@
3405
3962
  $rect.setAttribute('y', '0');
3406
3963
  $rect.setAttribute('width', '100%');
3407
3964
  $rect.setAttribute('height', '100%');
3408
- $rect.setAttribute('fill', "url(#" + gradientId + ")");
3965
+ $rect.setAttribute('fill', "url(#".concat(gradientId, ")"));
3409
3966
  $rect.id = rectId;
3410
3967
  $def.appendChild($rect);
3411
3968
  var $feImage = createSVGElement('feImage', document);
3412
- $feImage.setAttribute('href', "#" + rectId);
3413
- $feImage.setAttribute('result', filterId + "-" + i);
3969
+ $feImage.setAttribute('href', "#".concat(rectId));
3970
+ $feImage.setAttribute('result', "".concat(filterId, "-").concat(i));
3414
3971
  $existed.appendChild($feImage);
3415
3972
  if (i > 0) {
3416
3973
  var $feBlend = createSVGElement('feBlend', document);
3417
- $feBlend.setAttribute('in', i === 1 ? filterId + "-" + (i - 1) : filterId + "-blended-" + (blended - 1));
3418
- $feBlend.setAttribute('in2', filterId + "-" + i);
3419
- $feBlend.setAttribute('result', filterId + "-blended-" + blended++);
3974
+ $feBlend.setAttribute('in', i === 1 ? "".concat(filterId, "-").concat(i - 1) : "".concat(filterId, "-blended-").concat(blended - 1));
3975
+ $feBlend.setAttribute('in2', "".concat(filterId, "-").concat(i));
3976
+ $feBlend.setAttribute('result', "".concat(filterId, "-blended-").concat(blended++));
3420
3977
  // @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/blend-mode
3421
3978
  $feBlend.setAttribute('mode', 'multiply');
3422
3979
  $existed.appendChild($feBlend);
3423
3980
  }
3424
3981
  });
3425
3982
  var $feComposite = createSVGElement('feComposite', document);
3426
- $feComposite.setAttribute('in', filterId + "-blended-" + blended);
3983
+ $feComposite.setAttribute('in', "".concat(filterId, "-blended-").concat(blended));
3427
3984
  $feComposite.setAttribute('in2', 'SourceGraphic');
3428
3985
  $feComposite.setAttribute('operator', 'in');
3429
3986
  $existed.appendChild($feComposite);
@@ -3443,7 +4000,7 @@
3443
4000
  shadowOffsetY = _object$parsedStyle.shadowOffsetY;
3444
4001
  var hasShadow = !isNil(shadowColor) && shadowBlur > 0;
3445
4002
  var shadowId = FILTER_DROPSHADOW_PREFIX + object.entity;
3446
- var $existedFilter = $def.querySelector("#" + shadowId);
4003
+ var $existedFilter = $def.querySelector("#".concat(shadowId));
3447
4004
  if ($existedFilter) {
3448
4005
  var existedShadowType = $existedFilter.getAttribute('data-type');
3449
4006
  if (existedShadowType !== shadowType || !hasShadow) {
@@ -3457,7 +4014,7 @@
3457
4014
  if (hasShadow) {
3458
4015
  // use filter <feDropShadow>
3459
4016
  // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow
3460
- $el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + shadowId + ")");
4017
+ $el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#".concat(shadowId, ")"));
3461
4018
  } else {
3462
4019
  $el === null || $el === void 0 ? void 0 : $el.removeAttribute('filter');
3463
4020
  return;
@@ -3467,9 +4024,9 @@
3467
4024
  $existedFilter.setAttribute('data-type', shadowType);
3468
4025
  if (shadowType === 'outer') {
3469
4026
  var $feDropShadow = createSVGElement('feDropShadow', document);
3470
- $feDropShadow.setAttribute('dx', "" + (shadowOffsetX || 0) / 2);
3471
- $feDropShadow.setAttribute('dy', "" + (shadowOffsetY || 0) / 2);
3472
- $feDropShadow.setAttribute('stdDeviation', "" + (shadowBlur || 0) / 4);
4027
+ $feDropShadow.setAttribute('dx', "".concat((shadowOffsetX || 0) / 2));
4028
+ $feDropShadow.setAttribute('dy', "".concat((shadowOffsetY || 0) / 2));
4029
+ $feDropShadow.setAttribute('stdDeviation', "".concat((shadowBlur || 0) / 4));
3473
4030
  $feDropShadow.setAttribute('flood-color', shadowColor.toString());
3474
4031
  $existedFilter.appendChild($feDropShadow);
3475
4032
  } else if (shadowType === 'inner') {
@@ -3481,11 +4038,11 @@
3481
4038
  $feComponentTransfer.appendChild($feFuncA);
3482
4039
  $existedFilter.appendChild($feComponentTransfer);
3483
4040
  var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
3484
- $feGaussianBlur.setAttribute('stdDeviation', "" + (shadowBlur || 0) / 4);
4041
+ $feGaussianBlur.setAttribute('stdDeviation', "".concat((shadowBlur || 0) / 4));
3485
4042
  $existedFilter.appendChild($feGaussianBlur);
3486
4043
  var $feOffset = createSVGElement('feOffset', document);
3487
- $feOffset.setAttribute('dx', "" + (shadowOffsetX || 0) / 2);
3488
- $feOffset.setAttribute('dy', "" + (shadowOffsetY || 0) / 2);
4044
+ $feOffset.setAttribute('dx', "".concat((shadowOffsetX || 0) / 2));
4045
+ $feOffset.setAttribute('dy', "".concat((shadowOffsetY || 0) / 2));
3489
4046
  $feOffset.setAttribute('result', 'offsetblur');
3490
4047
  $existedFilter.appendChild($feOffset);
3491
4048
  var $feFlood = createSVGElement('feFlood', document);
@@ -3524,11 +4081,11 @@
3524
4081
  // half the blur radius
3525
4082
  // @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
3526
4083
  // @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
3527
- _$feGaussianBlur.setAttribute('stdDeviation', "" + (shadowBlur || 0) / 4);
4084
+ _$feGaussianBlur.setAttribute('stdDeviation', "".concat((shadowBlur || 0) / 4));
3528
4085
  } else if (name === 'shadowOffsetX') {
3529
- _$feOffset.setAttribute('dx', "" + (shadowOffsetX || 0) / 2);
4086
+ _$feOffset.setAttribute('dx', "".concat((shadowOffsetX || 0) / 2));
3530
4087
  } else if (name === 'shadowOffsetY') {
3531
- _$feOffset.setAttribute('dy', "" + (shadowOffsetY || 0) / 2);
4088
+ _$feOffset.setAttribute('dy', "".concat((shadowOffsetY || 0) / 2));
3532
4089
  }
3533
4090
  } else if (shadowType === 'outer') {
3534
4091
  var _$feDropShadow = $existedFilter.children[0];
@@ -3538,17 +4095,18 @@
3538
4095
  // half the blur radius
3539
4096
  // @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
3540
4097
  // @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
3541
- _$feDropShadow.setAttribute('stdDeviation', "" + (shadowBlur || 0) / 4);
4098
+ _$feDropShadow.setAttribute('stdDeviation', "".concat((shadowBlur || 0) / 4));
3542
4099
  } else if (name === 'shadowOffsetX') {
3543
- _$feDropShadow.setAttribute('dx', "" + (shadowOffsetX || 0) / 2);
4100
+ _$feDropShadow.setAttribute('dx', "".concat((shadowOffsetX || 0) / 2));
3544
4101
  } else if (name === 'shadowOffsetY') {
3545
- _$feDropShadow.setAttribute('dy', "" + (shadowOffsetY || 0) / 2);
4102
+ _$feDropShadow.setAttribute('dy', "".concat((shadowOffsetY || 0) / 2));
3546
4103
  }
3547
4104
  }
3548
4105
  }
3549
4106
  var urlRegexp = /url\("?#(.*)\)/;
3550
4107
  var DefElementManager = /*#__PURE__*/function () {
3551
4108
  function DefElementManager(context) {
4109
+ _classCallCheck$3(this, DefElementManager);
3552
4110
  this.context = void 0;
3553
4111
  /**
3554
4112
  * container for <gradient> <clipPath>...
@@ -3557,106 +4115,124 @@
3557
4115
  this.gradientCache = {};
3558
4116
  this.context = context;
3559
4117
  }
3560
- var _proto = DefElementManager.prototype;
3561
- _proto.getDefElement = function getDefElement() {
3562
- return this.$def;
3563
- };
3564
- _proto.init = function init() {
3565
- var document = this.context.config.document;
3566
- var $svg = this.context.contextService.getContext();
3567
- this.$def = createSVGElement('defs', document);
3568
- $svg.appendChild(this.$def);
3569
- };
3570
- _proto.clear = function clear(entity) {
3571
- var _this = this;
3572
- Object.keys(this.gradientCache).forEach(function (id) {
3573
- _this.clearUnusedDefElement(_this.gradientCache, id, entity);
3574
- });
3575
- };
3576
- _proto.clearUnusedDefElement = function clearUnusedDefElement(cache, id, entity) {
3577
- if (cache[id] && cache[id].size === 1 && cache[id].has(entity)) {
3578
- var targetElement = this.$def.querySelector("#" + id);
3579
- if (targetElement) {
3580
- this.$def.removeChild(targetElement);
3581
- }
4118
+ _createClass$3(DefElementManager, [{
4119
+ key: "getDefElement",
4120
+ value: function getDefElement() {
4121
+ return this.$def;
3582
4122
  }
3583
- };
3584
- _proto.createOrUpdateGradientAndPattern = function createOrUpdateGradientAndPattern$1(object, $el, parsedColor, name, plugin) {
3585
- var _this$context$config = this.context.config,
3586
- doc = _this$context$config.document,
3587
- createImage = _this$context$config.createImage;
3588
- if ($el) {
3589
- var attributeValue = '';
3590
- if (gLite.isPattern(parsedColor)) {
3591
- // `fill: url(#${patternId})`
3592
- attributeValue = $el.style[name];
3593
- } else {
3594
- // `url(#${gradientId})`
3595
- attributeValue = $el.getAttribute(name) || '';
3596
- }
3597
- var matches = attributeValue.match(urlRegexp);
3598
- if (matches && matches.length > 1) {
3599
- this.clearUnusedDefElement(this.gradientCache, matches[1].replace('"', ''), object.entity);
4123
+ }, {
4124
+ key: "init",
4125
+ value: function init() {
4126
+ var document = this.context.config.document;
4127
+ var $svg = this.context.contextService.getContext();
4128
+ this.$def = createSVGElement('defs', document);
4129
+ $svg.appendChild(this.$def);
4130
+ }
4131
+ }, {
4132
+ key: "clear",
4133
+ value: function clear(entity) {
4134
+ var _this = this;
4135
+ Object.keys(this.gradientCache).forEach(function (id) {
4136
+ _this.clearUnusedDefElement(_this.gradientCache, id, entity);
4137
+ });
4138
+ }
4139
+ }, {
4140
+ key: "clearUnusedDefElement",
4141
+ value: function clearUnusedDefElement(cache, id, entity) {
4142
+ if (cache[id] && cache[id].size === 1 && cache[id].has(entity)) {
4143
+ var targetElement = this.$def.querySelector("#".concat(id));
4144
+ if (targetElement) {
4145
+ this.$def.removeChild(targetElement);
4146
+ }
3600
4147
  }
3601
- var newDefElementId = createOrUpdateGradientAndPattern(doc || document, this.$def, object, $el, parsedColor, name, createImage, plugin);
3602
- if (newDefElementId) {
3603
- if (!this.gradientCache[newDefElementId]) {
3604
- this.gradientCache[newDefElementId] = new Set();
4148
+ }
4149
+ }, {
4150
+ key: "createOrUpdateGradientAndPattern",
4151
+ value: function createOrUpdateGradientAndPattern$1(object, $el, parsedColor, name, plugin) {
4152
+ var _this$context$config = this.context.config,
4153
+ doc = _this$context$config.document,
4154
+ createImage = _this$context$config.createImage;
4155
+ if ($el) {
4156
+ var attributeValue = '';
4157
+ if (gLite.isPattern(parsedColor)) {
4158
+ // `fill: url(#${patternId})`
4159
+ attributeValue = $el.style[name];
4160
+ } else {
4161
+ // `url(#${gradientId})`
4162
+ attributeValue = $el.getAttribute(name) || '';
4163
+ }
4164
+ var matches = attributeValue.match(urlRegexp);
4165
+ if (matches && matches.length > 1) {
4166
+ this.clearUnusedDefElement(this.gradientCache, matches[1].replace('"', ''), object.entity);
4167
+ }
4168
+ var newDefElementId = createOrUpdateGradientAndPattern(doc || document, this.$def, object, $el, parsedColor, name, createImage, plugin);
4169
+ if (newDefElementId) {
4170
+ if (!this.gradientCache[newDefElementId]) {
4171
+ this.gradientCache[newDefElementId] = new Set();
4172
+ }
4173
+ this.gradientCache[newDefElementId].add(object.entity);
3605
4174
  }
3606
- this.gradientCache[newDefElementId].add(object.entity);
3607
4175
  }
3608
4176
  }
3609
- };
3610
- _proto.createOrUpdateShadow = function createOrUpdateShadow$1(object, $el, name) {
3611
- var doc = this.context.config.document;
3612
- createOrUpdateShadow(doc || document, this.$def, object, $el, name);
3613
- };
3614
- _proto.createOrUpdateFilter = function createOrUpdateFilter$1(object, $el, filters) {
3615
- var doc = this.context.config.document;
3616
- createOrUpdateFilter(doc || document, this.$def, object, $el, filters);
3617
- };
4177
+ }, {
4178
+ key: "createOrUpdateShadow",
4179
+ value: function createOrUpdateShadow$1(object, $el, name) {
4180
+ var doc = this.context.config.document;
4181
+ createOrUpdateShadow(doc || document, this.$def, object, $el, name);
4182
+ }
4183
+ }, {
4184
+ key: "createOrUpdateFilter",
4185
+ value: function createOrUpdateFilter$1(object, $el, filters) {
4186
+ var doc = this.context.config.document;
4187
+ createOrUpdateFilter(doc || document, this.$def, object, $el, filters);
4188
+ }
4189
+ }]);
3618
4190
  return DefElementManager;
3619
4191
  }();
3620
4192
  var Plugin$2 = /*#__PURE__*/function (_AbstractRendererPlug) {
3621
- _inheritsLoose$3(Plugin, _AbstractRendererPlug);
3622
- function Plugin(options) {
4193
+ _inherits$3(Plugin, _AbstractRendererPlug);
4194
+ var _super = _createSuper$3(Plugin);
4195
+ function Plugin() {
3623
4196
  var _this;
3624
- if (options === void 0) {
3625
- options = {};
3626
- }
3627
- _this = _AbstractRendererPlug.call(this) || this;
4197
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4198
+ _classCallCheck$3(this, Plugin);
4199
+ _this = _super.call(this);
3628
4200
  _this.options = void 0;
3629
4201
  _this.name = 'svg-renderer';
3630
4202
  _this.options = options;
3631
4203
  return _this;
3632
4204
  }
3633
- var _proto = Plugin.prototype;
3634
- _proto.init = function init() {
3635
- var _this$options = this.options,
3636
- outputSVGElementId = _this$options.outputSVGElementId,
3637
- outputSVGElementName = _this$options.outputSVGElementName;
3638
- var defElementManager = new DefElementManager(this.context);
3639
- // default implementation
3640
- var defaultElementLifeCycleContribution = new DefaultElementLifeCycleContribution(this.context);
3641
- // @ts-ignore
3642
- this.context.defaultElementLifeCycleContribution = defaultElementLifeCycleContribution;
3643
- // @ts-ignore
3644
- this.context.SVGElementLifeCycleContribution = defaultElementLifeCycleContribution;
3645
- var SVGRendererPluginOptions = {
3646
- outputSVGElementId: !isNil(outputSVGElementId) ? !!outputSVGElementId : true,
3647
- outputSVGElementName: !isNil(outputSVGElementName) ? !!outputSVGElementName : true
3648
- };
3649
- this.addRenderingPlugin(
3650
- // @ts-ignore
3651
- new SVGRendererPlugin(SVGRendererPluginOptions, defElementManager, this.context));
3652
- };
3653
- _proto.destroy = function destroy() {
3654
- this.removeAllRenderingPlugins();
3655
- // @ts-ignore
3656
- delete this.context.defaultElementLifeCycleContribution;
3657
- // @ts-ignore
3658
- delete this.context.SVGElementLifeCycleContribution;
3659
- };
4205
+ _createClass$3(Plugin, [{
4206
+ key: "init",
4207
+ value: function init() {
4208
+ var _this$options = this.options,
4209
+ outputSVGElementId = _this$options.outputSVGElementId,
4210
+ outputSVGElementName = _this$options.outputSVGElementName;
4211
+ var defElementManager = new DefElementManager(this.context);
4212
+ // default implementation
4213
+ var defaultElementLifeCycleContribution = new DefaultElementLifeCycleContribution(this.context);
4214
+ // @ts-ignore
4215
+ this.context.defaultElementLifeCycleContribution = defaultElementLifeCycleContribution;
4216
+ // @ts-ignore
4217
+ this.context.SVGElementLifeCycleContribution = defaultElementLifeCycleContribution;
4218
+ var SVGRendererPluginOptions = {
4219
+ outputSVGElementId: !isNil(outputSVGElementId) ? !!outputSVGElementId : true,
4220
+ outputSVGElementName: !isNil(outputSVGElementName) ? !!outputSVGElementName : true
4221
+ };
4222
+ this.addRenderingPlugin(
4223
+ // @ts-ignore
4224
+ new SVGRendererPlugin(SVGRendererPluginOptions, defElementManager, this.context));
4225
+ }
4226
+ }, {
4227
+ key: "destroy",
4228
+ value: function destroy() {
4229
+ this.removeAllRenderingPlugins();
4230
+ // @ts-ignore
4231
+ delete this.context.defaultElementLifeCycleContribution;
4232
+ // @ts-ignore
4233
+ delete this.context.SVGElementLifeCycleContribution;
4234
+ }
4235
+ }]);
3660
4236
  return Plugin;
3661
4237
  }(gLite.AbstractRendererPlugin);
3662
4238
 
@@ -3688,6 +4264,7 @@
3688
4264
  _excluded4 = ["offset", "composite", "computedOffset", "easing", "transformOrigin"];
3689
4265
  var SVGContextService = /*#__PURE__*/function () {
3690
4266
  function SVGContextService(context) {
4267
+ _classCallCheck(this, SVGContextService);
3691
4268
  this.context = void 0;
3692
4269
  this.$container = void 0;
3693
4270
  this.$namespace = void 0;
@@ -3696,245 +4273,273 @@
3696
4273
  this.context = context;
3697
4274
  this.canvasConfig = context.config;
3698
4275
  }
3699
- var _proto = SVGContextService.prototype;
3700
- _proto.init = /*#__PURE__*/function () {
3701
- var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
3702
- var _this$canvasConfig, container, doc, devicePixelRatio, $namespace, dpr;
3703
- return _regeneratorRuntime().wrap(function _callee$(_context) {
3704
- while (1) switch (_context.prev = _context.next) {
3705
- case 0:
3706
- _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document, devicePixelRatio = _this$canvasConfig.devicePixelRatio; // create container
3707
- this.$container = isString(container) ? (doc || document).getElementById(container) : container;
3708
- if (this.$container) {
3709
- if (!this.$container.style.position) {
3710
- this.$container.style.position = 'relative';
4276
+ _createClass(SVGContextService, [{
4277
+ key: "init",
4278
+ value: function () {
4279
+ var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
4280
+ var _this$canvasConfig, container, doc, devicePixelRatio, $namespace, dpr;
4281
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
4282
+ while (1) switch (_context.prev = _context.next) {
4283
+ case 0:
4284
+ _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document, devicePixelRatio = _this$canvasConfig.devicePixelRatio; // create container
4285
+ this.$container = isString(container) ? (doc || document).getElementById(container) : container;
4286
+ if (this.$container) {
4287
+ if (!this.$container.style.position) {
4288
+ this.$container.style.position = 'relative';
4289
+ }
4290
+ $namespace = createSVGElement('svg', doc);
4291
+ $namespace.setAttribute('width', "".concat(this.canvasConfig.width));
4292
+ $namespace.setAttribute('height', "".concat(this.canvasConfig.height));
4293
+ this.$container.appendChild($namespace);
4294
+ this.$namespace = $namespace;
3711
4295
  }
3712
- $namespace = createSVGElement('svg', doc);
3713
- $namespace.setAttribute('width', "" + this.canvasConfig.width);
3714
- $namespace.setAttribute('height', "" + this.canvasConfig.height);
3715
- this.$container.appendChild($namespace);
3716
- this.$namespace = $namespace;
3717
- }
3718
- // use user-defined dpr first
3719
- dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
3720
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
3721
- this.dpr = dpr;
3722
- case 6:
3723
- case "end":
3724
- return _context.stop();
3725
- }
3726
- }, _callee, this);
3727
- }));
3728
- function init() {
3729
- return _init.apply(this, arguments);
3730
- }
3731
- return init;
3732
- }() // @ts-ignore
3733
- ;
3734
- _proto.getDomElement = function getDomElement() {
3735
- return this.$namespace;
3736
- };
3737
- _proto.getContext = function getContext() {
3738
- return this.$namespace;
3739
- };
3740
- _proto.getDPR = function getDPR() {
3741
- return this.dpr;
3742
- };
3743
- _proto.getBoundingClientRect = function getBoundingClientRect() {
3744
- var _this$$namespace;
3745
- return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
3746
- };
3747
- _proto.destroy = function destroy() {
3748
- // destroy context
3749
- if (this.$container && this.$namespace && this.$namespace.parentNode) {
3750
- this.$container.removeChild(this.$namespace);
4296
+ // use user-defined dpr first
4297
+ dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
4298
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
4299
+ this.dpr = dpr;
4300
+ case 6:
4301
+ case "end":
4302
+ return _context.stop();
4303
+ }
4304
+ }, _callee, this);
4305
+ }));
4306
+ function init() {
4307
+ return _init.apply(this, arguments);
4308
+ }
4309
+ return init;
4310
+ }() // @ts-ignore
4311
+ }, {
4312
+ key: "getDomElement",
4313
+ value: function getDomElement() {
4314
+ return this.$namespace;
3751
4315
  }
3752
- };
3753
- _proto.resize = function resize(width, height) {
3754
- // SVG should ignore DPR
3755
- if (this.$namespace) {
3756
- this.$namespace.setAttribute('width', "" + width);
3757
- this.$namespace.setAttribute('height', "" + height);
4316
+ }, {
4317
+ key: "getContext",
4318
+ value: function getContext() {
4319
+ return this.$namespace;
3758
4320
  }
3759
- };
3760
- _proto.applyCursorStyle = function applyCursorStyle(cursor) {
3761
- if (this.$container) {
3762
- this.$container.style.cursor = cursor;
4321
+ }, {
4322
+ key: "getDPR",
4323
+ value: function getDPR() {
4324
+ return this.dpr;
3763
4325
  }
3764
- };
3765
- _proto.generateCSSText = function generateCSSText(animationName, selector, keyframes, timing, prefixes) {
3766
- if (prefixes === void 0) {
3767
- prefixes = {};
3768
- }
3769
- var duration = timing.duration,
3770
- easing = timing.easing,
3771
- delay = timing.delay,
3772
- direction = timing.direction,
3773
- iterations = timing.iterations,
3774
- fill = timing.fill;
3775
- return "@keyframes " + animationName + "{" + keyframes.map(function (keyframe) {
3776
- var offset = keyframe.offset,
3777
- composite = keyframe.composite,
3778
- computedOffset = keyframe.computedOffset,
3779
- easing = keyframe.easing,
3780
- rest = _objectWithoutPropertiesLoose(keyframe, _excluded);
3781
- var rules = Object.keys(rest).map(function (attributeName) {
3782
- return attributeName + ":" + (prefixes[attributeName] || '') + rest[attributeName] + ";";
3783
- }).join('');
3784
- return computedOffset * 100 + "%{" + rules + "}";
3785
- }).join('') + "}" + (selector + " {animation: " + animationName + " " + duration + "ms " + easing + " " + delay + "ms " + (iterations === Infinity ? 'infinite' : iterations) + " " + direction + " " + fill + ";}");
3786
- };
3787
- _proto.toDataURL = /*#__PURE__*/function () {
3788
- var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
3789
- var _this = this;
3790
- var cloneNode, doc, animationCounter, $style, svgDocType, svgDoc;
3791
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3792
- while (1) switch (_context2.prev = _context2.next) {
3793
- case 0:
3794
- cloneNode = this.$namespace.cloneNode(true);
3795
- doc = this.canvasConfig.document;
3796
- animationCounter = 0;
3797
- $style = null;
3798
- this.context.renderingContext.root.forEach(function (object) {
3799
- var animations = object.getAnimations();
3800
- if (animations.length) {
3801
- if (!$style) {
3802
- // export animations to <style>, using CSS Transformation
3803
- $style = (doc || document).createElement('style');
3804
- cloneNode.appendChild($style);
3805
- }
3806
- // @ts-ignore
3807
- var svgElement = object.elementSVG;
3808
- var selfSelector = "#" + svgElement.$el.id;
3809
- var groupSelector = "#" + svgElement.$groupEl.id;
3810
- var selfCssText = '';
3811
- var groupCssText = '';
3812
- animations.forEach(function (animation) {
3813
- var keyframes = animation.effect.getKeyframes();
3814
- // split attributes into self and group
3815
- if (keyframes.length) {
3816
- var selfAttributes = [];
3817
- var groupAttributes = [];
3818
- var _keyframes$ = keyframes[0],
3819
- offset = _keyframes$.offset,
3820
- composite = _keyframes$.composite,
3821
- computedOffset = _keyframes$.computedOffset,
3822
- easing = _keyframes$.easing,
3823
- transformOrigin = _keyframes$.transformOrigin,
3824
- rest = _objectWithoutPropertiesLoose(_keyframes$, _excluded2);
3825
- Object.keys(rest).forEach(function (attributeName) {
3826
- var _propertyMetadataCach;
3827
- if (attributeName === 'transform') {
3828
- groupAttributes.push(attributeName);
3829
- }
3830
- var inherited = !!((_propertyMetadataCach = gLite.propertyMetadataCache[attributeName]) === null || _propertyMetadataCach === void 0 ? void 0 : _propertyMetadataCach.inh);
3831
- if (inherited) {
3832
- groupAttributes.push(attributeName);
3833
- } else if (attributeName !== 'transform') {
3834
- selfAttributes.push(attributeName);
3835
- }
3836
- });
3837
- if (groupAttributes.length) {
3838
- var keyframesWithGroup = keyframes.map(function (keyframe) {
3839
- var offset = keyframe.offset,
3840
- composite = keyframe.composite,
3841
- computedOffset = keyframe.computedOffset,
3842
- easing = keyframe.easing,
3843
- transformOrigin = keyframe.transformOrigin,
3844
- rest = _objectWithoutPropertiesLoose(keyframe, _excluded3);
3845
- var ret = {
3846
- offset: offset,
3847
- composite: composite,
3848
- computedOffset: computedOffset,
3849
- easing: easing
3850
- };
3851
- Object.keys(rest).forEach(function (attributeName) {
3852
- if (groupAttributes.includes(attributeName)) {
3853
- ret[attributeName] = keyframe[attributeName];
3854
- }
3855
- });
3856
- return ret;
3857
- });
3858
- groupCssText += _this.generateCSSText("a" + animationCounter++, groupSelector, keyframesWithGroup, animation.effect.getComputedTiming(), {
3859
- transform: svgElement.$groupEl.getAttribute('transform')
4326
+ }, {
4327
+ key: "getBoundingClientRect",
4328
+ value: function getBoundingClientRect() {
4329
+ var _this$$namespace;
4330
+ return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
4331
+ }
4332
+ }, {
4333
+ key: "destroy",
4334
+ value: function destroy() {
4335
+ // destroy context
4336
+ if (this.$container && this.$namespace && this.$namespace.parentNode) {
4337
+ this.$container.removeChild(this.$namespace);
4338
+ }
4339
+ }
4340
+ }, {
4341
+ key: "resize",
4342
+ value: function resize(width, height) {
4343
+ // SVG should ignore DPR
4344
+ if (this.$namespace) {
4345
+ this.$namespace.setAttribute('width', "".concat(width));
4346
+ this.$namespace.setAttribute('height', "".concat(height));
4347
+ }
4348
+ }
4349
+ }, {
4350
+ key: "applyCursorStyle",
4351
+ value: function applyCursorStyle(cursor) {
4352
+ if (this.$container) {
4353
+ this.$container.style.cursor = cursor;
4354
+ }
4355
+ }
4356
+ }, {
4357
+ key: "generateCSSText",
4358
+ value: function generateCSSText(animationName, selector, keyframes, timing) {
4359
+ var prefixes = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
4360
+ var duration = timing.duration,
4361
+ easing = timing.easing,
4362
+ delay = timing.delay,
4363
+ direction = timing.direction,
4364
+ iterations = timing.iterations,
4365
+ fill = timing.fill;
4366
+ return "@keyframes ".concat(animationName, "{").concat(keyframes.map(function (keyframe) {
4367
+ var offset = keyframe.offset,
4368
+ composite = keyframe.composite,
4369
+ computedOffset = keyframe.computedOffset,
4370
+ easing = keyframe.easing,
4371
+ rest = _objectWithoutProperties(keyframe, _excluded);
4372
+ var rules = Object.keys(rest).map(function (attributeName) {
4373
+ return "".concat(attributeName, ":").concat(prefixes[attributeName] || '').concat(rest[attributeName], ";");
4374
+ }).join('');
4375
+ return "".concat(computedOffset * 100, "%{").concat(rules, "}");
4376
+ }).join(''), "}") + "".concat(selector, " {animation: ").concat(animationName, " ").concat(duration, "ms ").concat(easing, " ").concat(delay, "ms ").concat(iterations === Infinity ? 'infinite' : iterations, " ").concat(direction, " ").concat(fill, ";}");
4377
+ }
4378
+ }, {
4379
+ key: "toDataURL",
4380
+ value: function () {
4381
+ var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
4382
+ var _this = this;
4383
+ var cloneNode,
4384
+ doc,
4385
+ animationCounter,
4386
+ $style,
4387
+ svgDocType,
4388
+ svgDoc;
4389
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
4390
+ while (1) switch (_context2.prev = _context2.next) {
4391
+ case 0:
4392
+ cloneNode = this.$namespace.cloneNode(true);
4393
+ doc = this.canvasConfig.document;
4394
+ animationCounter = 0;
4395
+ $style = null;
4396
+ this.context.renderingContext.root.forEach(function (object) {
4397
+ var animations = object.getAnimations();
4398
+ if (animations.length) {
4399
+ if (!$style) {
4400
+ // export animations to <style>, using CSS Transformation
4401
+ $style = (doc || document).createElement('style');
4402
+ cloneNode.appendChild($style);
4403
+ }
4404
+ // @ts-ignore
4405
+ var svgElement = object.elementSVG;
4406
+ var selfSelector = "#".concat(svgElement.$el.id);
4407
+ var groupSelector = "#".concat(svgElement.$groupEl.id);
4408
+ var selfCssText = '';
4409
+ var groupCssText = '';
4410
+ animations.forEach(function (animation) {
4411
+ var keyframes = animation.effect.getKeyframes();
4412
+ // split attributes into self and group
4413
+ if (keyframes.length) {
4414
+ var selfAttributes = [];
4415
+ var groupAttributes = [];
4416
+ var _keyframes$ = keyframes[0],
4417
+ offset = _keyframes$.offset,
4418
+ composite = _keyframes$.composite,
4419
+ computedOffset = _keyframes$.computedOffset,
4420
+ easing = _keyframes$.easing,
4421
+ transformOrigin = _keyframes$.transformOrigin,
4422
+ rest = _objectWithoutProperties(_keyframes$, _excluded2);
4423
+ Object.keys(rest).forEach(function (attributeName) {
4424
+ var _propertyMetadataCach;
4425
+ if (attributeName === 'transform') {
4426
+ groupAttributes.push(attributeName);
4427
+ }
4428
+ var inherited = !!((_propertyMetadataCach = gLite.propertyMetadataCache[attributeName]) === null || _propertyMetadataCach === void 0 ? void 0 : _propertyMetadataCach.inh);
4429
+ if (inherited) {
4430
+ groupAttributes.push(attributeName);
4431
+ } else if (attributeName !== 'transform') {
4432
+ selfAttributes.push(attributeName);
4433
+ }
3860
4434
  });
3861
- }
3862
- if (selfAttributes.length) {
3863
- var keyframesWithSelf = keyframes.map(function (keyframe) {
3864
- var offset = keyframe.offset,
3865
- composite = keyframe.composite,
3866
- computedOffset = keyframe.computedOffset,
3867
- easing = keyframe.easing,
3868
- transformOrigin = keyframe.transformOrigin,
3869
- rest = _objectWithoutPropertiesLoose(keyframe, _excluded4);
3870
- var ret = {
3871
- offset: offset,
3872
- composite: composite,
3873
- computedOffset: computedOffset,
3874
- easing: easing
3875
- };
3876
- Object.keys(rest).forEach(function (attributeName) {
3877
- if (selfAttributes.includes(attributeName)) {
3878
- ret[attributeName] = keyframe[attributeName];
3879
- }
4435
+ if (groupAttributes.length) {
4436
+ var keyframesWithGroup = keyframes.map(function (keyframe) {
4437
+ var offset = keyframe.offset,
4438
+ composite = keyframe.composite,
4439
+ computedOffset = keyframe.computedOffset,
4440
+ easing = keyframe.easing,
4441
+ transformOrigin = keyframe.transformOrigin,
4442
+ rest = _objectWithoutProperties(keyframe, _excluded3);
4443
+ var ret = {
4444
+ offset: offset,
4445
+ composite: composite,
4446
+ computedOffset: computedOffset,
4447
+ easing: easing
4448
+ };
4449
+ Object.keys(rest).forEach(function (attributeName) {
4450
+ if (groupAttributes.includes(attributeName)) {
4451
+ ret[attributeName] = keyframe[attributeName];
4452
+ }
4453
+ });
4454
+ return ret;
3880
4455
  });
3881
- return ret;
3882
- });
3883
- selfCssText += _this.generateCSSText("a" + animationCounter++, selfSelector, keyframesWithSelf, animation.effect.getComputedTiming());
4456
+ groupCssText += _this.generateCSSText("a".concat(animationCounter++), groupSelector, keyframesWithGroup, animation.effect.getComputedTiming(), {
4457
+ transform: svgElement.$groupEl.getAttribute('transform')
4458
+ });
4459
+ }
4460
+ if (selfAttributes.length) {
4461
+ var keyframesWithSelf = keyframes.map(function (keyframe) {
4462
+ var offset = keyframe.offset,
4463
+ composite = keyframe.composite,
4464
+ computedOffset = keyframe.computedOffset,
4465
+ easing = keyframe.easing,
4466
+ transformOrigin = keyframe.transformOrigin,
4467
+ rest = _objectWithoutProperties(keyframe, _excluded4);
4468
+ var ret = {
4469
+ offset: offset,
4470
+ composite: composite,
4471
+ computedOffset: computedOffset,
4472
+ easing: easing
4473
+ };
4474
+ Object.keys(rest).forEach(function (attributeName) {
4475
+ if (selfAttributes.includes(attributeName)) {
4476
+ ret[attributeName] = keyframe[attributeName];
4477
+ }
4478
+ });
4479
+ return ret;
4480
+ });
4481
+ selfCssText += _this.generateCSSText("a".concat(animationCounter++), selfSelector, keyframesWithSelf, animation.effect.getComputedTiming());
4482
+ }
3884
4483
  }
3885
- }
3886
- });
3887
- $style.textContent += selfCssText + groupCssText;
3888
- }
3889
- });
3890
- svgDocType = document.implementation.createDocumentType('svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
3891
- svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', svgDocType);
3892
- svgDoc.replaceChild(cloneNode, svgDoc.documentElement);
3893
- return _context2.abrupt("return", "data:image/svg+xml;charset=utf8," + encodeURIComponent(new XMLSerializer().serializeToString(svgDoc)));
3894
- case 10:
3895
- case "end":
3896
- return _context2.stop();
3897
- }
3898
- }, _callee2, this);
3899
- }));
3900
- function toDataURL(_x) {
3901
- return _toDataURL.apply(this, arguments);
3902
- }
3903
- return toDataURL;
3904
- }();
4484
+ });
4485
+ $style.textContent += selfCssText + groupCssText;
4486
+ }
4487
+ });
4488
+ svgDocType = document.implementation.createDocumentType('svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
4489
+ svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', svgDocType);
4490
+ svgDoc.replaceChild(cloneNode, svgDoc.documentElement);
4491
+ return _context2.abrupt("return", "data:image/svg+xml;charset=utf8,".concat(encodeURIComponent(new XMLSerializer().serializeToString(svgDoc))));
4492
+ case 10:
4493
+ case "end":
4494
+ return _context2.stop();
4495
+ }
4496
+ }, _callee2, this);
4497
+ }));
4498
+ function toDataURL() {
4499
+ return _toDataURL.apply(this, arguments);
4500
+ }
4501
+ return toDataURL;
4502
+ }()
4503
+ }]);
3905
4504
  return SVGContextService;
3906
4505
  }();
3907
4506
 
3908
4507
  var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
3909
- _inheritsLoose(ContextRegisterPlugin, _AbstractRendererPlug);
4508
+ _inherits(ContextRegisterPlugin, _AbstractRendererPlug);
4509
+ var _super = _createSuper(ContextRegisterPlugin);
3910
4510
  function ContextRegisterPlugin() {
3911
4511
  var _this;
4512
+ _classCallCheck(this, ContextRegisterPlugin);
3912
4513
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3913
4514
  args[_key] = arguments[_key];
3914
4515
  }
3915
- _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
4516
+ _this = _super.call.apply(_super, [this].concat(args));
3916
4517
  _this.name = 'svg-context-register';
3917
4518
  return _this;
3918
4519
  }
3919
- var _proto = ContextRegisterPlugin.prototype;
3920
- _proto.init = function init() {
3921
- // @ts-ignore
3922
- this.context.ContextService = SVGContextService;
3923
- };
3924
- _proto.destroy = function destroy() {
3925
- delete this.context.ContextService;
3926
- };
4520
+ _createClass(ContextRegisterPlugin, [{
4521
+ key: "init",
4522
+ value: function init() {
4523
+ // @ts-ignore
4524
+ this.context.ContextService = SVGContextService;
4525
+ }
4526
+ }, {
4527
+ key: "destroy",
4528
+ value: function destroy() {
4529
+ delete this.context.ContextService;
4530
+ }
4531
+ }]);
3927
4532
  return ContextRegisterPlugin;
3928
4533
  }(gLite.AbstractRendererPlugin);
3929
4534
 
3930
4535
  var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
3931
- _inheritsLoose(Renderer, _AbstractRenderer);
3932
- function Renderer(config) {
4536
+ _inherits(Renderer, _AbstractRenderer);
4537
+ var _super = _createSuper(Renderer);
4538
+ function Renderer() {
3933
4539
  var _this;
3934
- if (config === void 0) {
3935
- config = {};
3936
- }
3937
- _this = _AbstractRenderer.call(this, config) || this;
4540
+ var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4541
+ _classCallCheck(this, Renderer);
4542
+ _this = _super.call(this, config);
3938
4543
  _this.registerPlugin(new ContextRegisterPlugin());
3939
4544
  _this.registerPlugin(new Plugin$2({
3940
4545
  outputSVGElementId: config.outputSVGElementId
@@ -3943,7 +4548,7 @@
3943
4548
  _this.registerPlugin(new Plugin$1());
3944
4549
  return _this;
3945
4550
  }
3946
- return Renderer;
4551
+ return _createClass(Renderer);
3947
4552
  }(gLite.AbstractRenderer);
3948
4553
 
3949
4554
  exports.DomInteraction = index_esm;