@antv/g-svg 1.8.56 → 1.8.57

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,15 +305,6 @@
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
- }
317
308
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
318
309
  try {
319
310
  var info = gen[key](arg);
@@ -344,49 +335,10 @@
344
335
  });
345
336
  };
346
337
  }
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);
338
+ function _inheritsLoose(subClass, superClass) {
339
+ subClass.prototype = Object.create(superClass.prototype);
340
+ subClass.prototype.constructor = subClass;
341
+ _setPrototypeOf(subClass, superClass);
390
342
  }
391
343
  function _setPrototypeOf(o, p) {
392
344
  _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
@@ -395,17 +347,6 @@
395
347
  };
396
348
  return _setPrototypeOf(o, p);
397
349
  }
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
- }
409
350
  function _objectWithoutPropertiesLoose(source, excluded) {
410
351
  if (source == null) return {};
411
352
  var target = {};
@@ -418,63 +359,6 @@
418
359
  }
419
360
  return target;
420
361
  }
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
- }
478
362
 
479
363
  function _regeneratorRuntime$1() {
480
364
  _regeneratorRuntime$1 = function _regeneratorRuntime() {
@@ -552,7 +436,7 @@
552
436
  if ("throw" !== record.type) {
553
437
  var result = record.arg,
554
438
  value = result.value;
555
- return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
439
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
556
440
  invoke("next", value, resolve, reject);
557
441
  }, function (err) {
558
442
  invoke("throw", err, resolve, reject);
@@ -807,49 +691,10 @@
807
691
  });
808
692
  };
809
693
  }
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);
694
+ function _inheritsLoose$1(subClass, superClass) {
695
+ subClass.prototype = Object.create(superClass.prototype);
696
+ subClass.prototype.constructor = subClass;
697
+ _setPrototypeOf$1(subClass, superClass);
853
698
  }
854
699
  function _setPrototypeOf$1(o, p) {
855
700
  _setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
@@ -858,59 +703,6 @@
858
703
  };
859
704
  return _setPrototypeOf$1(o, p);
860
705
  }
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
- }
914
706
 
915
707
  // const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
916
708
  /**
@@ -918,174 +710,165 @@
918
710
  */
919
711
  var DOMInteractionPlugin = /*#__PURE__*/function () {
920
712
  function DOMInteractionPlugin() {
921
- _classCallCheck$1(this, DOMInteractionPlugin);
922
713
  this.context = void 0;
923
714
  }
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();
1038
- // @ts-ignore
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);
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
+ runtime.globalThis.addEventListener('pointercancel', onPointerCancel, true);
755
+ };
756
+ var addTouchEventListener = function addTouchEventListener($el) {
757
+ $el.addEventListener('touchstart', onPointerDown, true);
758
+ $el.addEventListener('touchend', onPointerUp, true);
759
+ $el.addEventListener('touchmove', onPointerMove, true);
760
+ $el.addEventListener('touchcancel', onPointerCancel, true);
761
+ };
762
+ var addMouseEventListener = function addMouseEventListener($el) {
763
+ runtime.globalThis.document.addEventListener('mousemove', onPointerMove, true);
764
+ $el.addEventListener('mousedown', onPointerDown, true);
765
+ $el.addEventListener('mouseout', onPointerOut, true);
766
+ $el.addEventListener('mouseover', onPointerOver, true);
767
+ runtime.globalThis.addEventListener('mouseup', onPointerUp, true);
768
+ };
769
+ var removePointerEventListener = function removePointerEventListener($el) {
770
+ runtime.globalThis.document.removeEventListener('pointermove', onPointerMove, true);
771
+ $el.removeEventListener('pointerdown', onPointerDown, true);
772
+ $el.removeEventListener('pointerleave', onPointerOut, true);
773
+ $el.removeEventListener('pointerover', onPointerOver, true);
774
+ runtime.globalThis.removeEventListener('pointerup', onPointerUp, true);
775
+ };
776
+ var removeTouchEventListener = function removeTouchEventListener($el) {
777
+ $el.removeEventListener('touchstart', onPointerDown, true);
778
+ $el.removeEventListener('touchend', onPointerUp, true);
779
+ $el.removeEventListener('touchmove', onPointerMove, true);
780
+ $el.removeEventListener('touchcancel', onPointerCancel, true);
781
+ };
782
+ var removeMouseEventListener = function removeMouseEventListener($el) {
783
+ runtime.globalThis.document.removeEventListener('mousemove', onPointerMove, true);
784
+ $el.removeEventListener('mousedown', onPointerDown, true);
785
+ $el.removeEventListener('mouseout', onPointerOut, true);
786
+ $el.removeEventListener('mouseover', onPointerOver, true);
787
+ runtime.globalThis.removeEventListener('mouseup', onPointerUp, true);
788
+ };
789
+ renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
790
+ var $el;
791
+ return _regeneratorRuntime$1().wrap(function _callee$(_context) {
792
+ while (1) switch (_context.prev = _context.next) {
793
+ case 0:
794
+ $el = _this.context.contextService.getDomElement(); // @ts-ignore
795
+ if (runtime.globalThis.navigator.msPointerEnabled) {
796
+ // @ts-ignore
797
+ $el.style.msContentZooming = 'none';
798
+ // @ts-ignore
799
+ $el.style.msTouchAction = 'none';
800
+ } else if (canvas.supportsPointerEvents) {
801
+ $el.style.touchAction = 'none';
802
+ }
803
+ if (canvas.supportsPointerEvents) {
804
+ addPointerEventListener($el);
805
+ } else {
806
+ addMouseEventListener($el);
807
+ }
808
+ if (canvas.supportsTouchEvents) {
809
+ addTouchEventListener($el);
810
+ }
811
+ if (config.useNativeClickEvent) {
812
+ $el.addEventListener('click', onClick, true);
813
+ }
814
+ // use passive event listeners
815
+ // @see https://zhuanlan.zhihu.com/p/24555031
816
+ $el.addEventListener('wheel', onPointerWheel, {
817
+ passive: true,
818
+ capture: true
819
+ });
820
+ case 6:
821
+ case "end":
822
+ return _context.stop();
1057
823
  }
1058
- $el.removeEventListener('wheel', onPointerWheel, true);
1059
- });
1060
- }
1061
- }]);
824
+ }, _callee);
825
+ })));
826
+ renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () {
827
+ var $el = _this.context.contextService.getDomElement();
828
+ // @ts-ignore
829
+ if (runtime.globalThis.navigator.msPointerEnabled) {
830
+ // @ts-ignore
831
+ $el.style.msContentZooming = '';
832
+ // @ts-ignore
833
+ $el.style.msTouchAction = '';
834
+ } else if (canvas.supportsPointerEvents) {
835
+ $el.style.touchAction = '';
836
+ }
837
+ if (canvas.supportsPointerEvents) {
838
+ removePointerEventListener($el);
839
+ } else {
840
+ removeMouseEventListener($el);
841
+ }
842
+ if (canvas.supportsTouchEvents) {
843
+ removeTouchEventListener($el);
844
+ }
845
+ if (config.useNativeClickEvent) {
846
+ $el.removeEventListener('click', onClick, true);
847
+ }
848
+ $el.removeEventListener('wheel', onPointerWheel, true);
849
+ });
850
+ };
1062
851
  return DOMInteractionPlugin;
1063
852
  }();
1064
853
  DOMInteractionPlugin.tag = 'DOMInteraction';
1065
854
  var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
1066
- _inherits$1(Plugin, _AbstractRendererPlug);
1067
- var _super = _createSuper$1(Plugin);
855
+ _inheritsLoose$1(Plugin, _AbstractRendererPlug);
1068
856
  function Plugin() {
1069
857
  var _this;
1070
- _classCallCheck$1(this, Plugin);
1071
858
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1072
859
  args[_key] = arguments[_key];
1073
860
  }
1074
- _this = _super.call.apply(_super, [this].concat(args));
861
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
1075
862
  _this.name = 'dom-interaction';
1076
863
  return _this;
1077
864
  }
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
- }]);
865
+ var _proto = Plugin.prototype;
866
+ _proto.init = function init() {
867
+ this.addRenderingPlugin(new DOMInteractionPlugin());
868
+ };
869
+ _proto.destroy = function destroy() {
870
+ this.removeAllRenderingPlugins();
871
+ };
1089
872
  return Plugin;
1090
873
  }(gLite.AbstractRendererPlugin);
1091
874
 
@@ -1170,7 +953,7 @@
1170
953
  if ("throw" !== record.type) {
1171
954
  var result = record.arg,
1172
955
  value = result.value;
1173
- return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
956
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
1174
957
  invoke("next", value, resolve, reject);
1175
958
  }, function (err) {
1176
959
  invoke("throw", err, resolve, reject);
@@ -1425,49 +1208,10 @@
1425
1208
  });
1426
1209
  };
1427
1210
  }
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);
1211
+ function _inheritsLoose$2(subClass, superClass) {
1212
+ subClass.prototype = Object.create(superClass.prototype);
1213
+ subClass.prototype.constructor = subClass;
1214
+ _setPrototypeOf$2(subClass, superClass);
1471
1215
  }
1472
1216
  function _setPrototypeOf$2(o, p) {
1473
1217
  _setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
@@ -1476,45 +1220,6 @@
1476
1220
  };
1477
1221
  return _setPrototypeOf$2(o, p);
1478
1222
  }
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
- }
1518
1223
  function _unsupportedIterableToArray(o, minLen) {
1519
1224
  if (!o) return;
1520
1225
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
@@ -1528,70 +1233,23 @@
1528
1233
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
1529
1234
  return arr2;
1530
1235
  }
1531
- function _createForOfIteratorHelper(o, allowArrayLike) {
1236
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
1532
1237
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
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() {};
1238
+ if (it) return (it = it.call(o)).next.bind(it);
1239
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
1240
+ if (it) o = it;
1241
+ var i = 0;
1242
+ return function () {
1243
+ if (i >= o.length) return {
1244
+ done: true
1245
+ };
1538
1246
  return {
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
1247
+ done: false,
1248
+ value: o[i++]
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
  }
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
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1595
1253
  }
1596
1254
 
1597
1255
  /**
@@ -1601,100 +1259,80 @@
1601
1259
  * 2. use elementFromPoint
1602
1260
  */
1603
1261
  var SVGPickerPlugin = /*#__PURE__*/function () {
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
- }
1262
+ function SVGPickerPlugin() {}
1263
+ var _proto = SVGPickerPlugin.prototype;
1264
+ _proto.apply = function apply(context, runtime) {
1265
+ var _this = this;
1266
+ var doc = context.config.document,
1267
+ renderingService = context.renderingService,
1268
+ svgElementMap = context.svgElementMap;
1269
+ renderingService.hooks.pick.tapPromise(SVGPickerPlugin.tag, /*#__PURE__*/function () {
1270
+ var _ref = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee(result) {
1271
+ return _regeneratorRuntime$2().wrap(function _callee$(_context) {
1272
+ while (1) switch (_context.prev = _context.next) {
1273
+ case 0:
1274
+ return _context.abrupt("return", _this.pick(svgElementMap, doc, result));
1275
+ case 1:
1276
+ case "end":
1277
+ return _context.stop();
1278
+ }
1279
+ }, _callee);
1280
+ }));
1281
+ return function (_x) {
1282
+ return _ref.apply(this, arguments);
1283
+ };
1284
+ }());
1285
+ renderingService.hooks.pickSync.tap(SVGPickerPlugin.tag, function (result) {
1286
+ return _this.pick(svgElementMap, doc, result);
1287
+ });
1288
+ };
1289
+ _proto.pick = function pick(svgElementMap, doc, result) {
1290
+ var topmost = result.topmost,
1291
+ _result$position = result.position,
1292
+ clientX = _result$position.clientX,
1293
+ clientY = _result$position.clientY;
1294
+ try {
1295
+ var targets = [];
1296
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
1297
+ for (var _iterator = _createForOfIteratorHelperLoose((doc || document).elementsFromPoint(clientX, clientY)), _step; !(_step = _iterator()).done;) {
1298
+ var element = _step.value;
1299
+ var target = svgElementMap.get(element);
1300
+ // don't need to account for `visibility` since DOM API already does
1301
+ if (target && target.isInteractive()) {
1302
+ targets.push(target);
1303
+ if (topmost) {
1304
+ result.picked = targets;
1305
+ return result;
1658
1306
  }
1659
- } catch (err) {
1660
- _iterator.e(err);
1661
- } finally {
1662
- _iterator.f();
1663
1307
  }
1664
- result.picked = targets;
1665
- } catch (e) {
1666
- result.picked = [];
1667
1308
  }
1668
- return result;
1309
+ result.picked = targets;
1310
+ } catch (e) {
1311
+ result.picked = [];
1669
1312
  }
1670
- }]);
1313
+ return result;
1314
+ };
1671
1315
  return SVGPickerPlugin;
1672
1316
  }();
1673
1317
  SVGPickerPlugin.tag = 'SVGPicker';
1674
1318
  var Plugin$1 = /*#__PURE__*/function (_AbstractRendererPlug) {
1675
- _inherits$2(Plugin, _AbstractRendererPlug);
1676
- var _super = _createSuper$2(Plugin);
1319
+ _inheritsLoose$2(Plugin, _AbstractRendererPlug);
1677
1320
  function Plugin() {
1678
1321
  var _this;
1679
- _classCallCheck$2(this, Plugin);
1680
1322
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1681
1323
  args[_key] = arguments[_key];
1682
1324
  }
1683
- _this = _super.call.apply(_super, [this].concat(args));
1325
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
1684
1326
  _this.name = 'svg-picker';
1685
1327
  return _this;
1686
1328
  }
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
- }]);
1329
+ var _proto = Plugin.prototype;
1330
+ _proto.init = function init() {
1331
+ this.addRenderingPlugin(new SVGPickerPlugin());
1332
+ };
1333
+ _proto.destroy = function destroy() {
1334
+ this.removeAllRenderingPlugins();
1335
+ };
1698
1336
  return Plugin;
1699
1337
  }(gLite.AbstractRendererPlugin);
1700
1338
 
@@ -1844,54 +1482,6 @@
1844
1482
  return a;
1845
1483
  };
1846
1484
 
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
- }
1895
1485
  function _regeneratorRuntime$3() {
1896
1486
  _regeneratorRuntime$3 = function _regeneratorRuntime() {
1897
1487
  return exports;
@@ -1968,7 +1558,7 @@
1968
1558
  if ("throw" !== record.type) {
1969
1559
  var result = record.arg,
1970
1560
  value = result.value;
1971
- return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
1561
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
1972
1562
  invoke("next", value, resolve, reject);
1973
1563
  }, function (err) {
1974
1564
  invoke("throw", err, resolve, reject);
@@ -2223,63 +1813,24 @@
2223
1813
  });
2224
1814
  };
2225
1815
  }
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
1816
+ function _extends() {
1817
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
1818
+ for (var i = 1; i < arguments.length; i++) {
1819
+ var source = arguments[i];
1820
+ for (var key in source) {
1821
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1822
+ target[key] = source[key];
1823
+ }
1824
+ }
2271
1825
  }
2272
- });
2273
- Object.defineProperty(subClass, "prototype", {
2274
- writable: false
2275
- });
2276
- if (superClass) _setPrototypeOf$3(subClass, superClass);
2277
- }
2278
- function _getPrototypeOf$3(o) {
2279
- _getPrototypeOf$3 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
2280
- return o.__proto__ || Object.getPrototypeOf(o);
1826
+ return target;
2281
1827
  };
2282
- return _getPrototypeOf$3(o);
1828
+ return _extends.apply(this, arguments);
1829
+ }
1830
+ function _inheritsLoose$3(subClass, superClass) {
1831
+ subClass.prototype = Object.create(superClass.prototype);
1832
+ subClass.prototype.constructor = subClass;
1833
+ _setPrototypeOf$3(subClass, superClass);
2283
1834
  }
2284
1835
  function _setPrototypeOf$3(o, p) {
2285
1836
  _setPrototypeOf$3 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
@@ -2288,83 +1839,7 @@
2288
1839
  };
2289
1840
  return _setPrototypeOf$3(o, p);
2290
1841
  }
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
+ var ElementSVG = function ElementSVG() {
2368
1843
  /**
2369
1844
  * basic element, eg. <circle>|<ellipse>
2370
1845
  */
@@ -2380,7 +1855,7 @@
2380
1855
  * -> $hitTestingEl
2381
1856
  */
2382
1857
  this.$hitTestingEl = void 0;
2383
- });
1858
+ };
2384
1859
  ElementSVG.tag = 'c-svg-element';
2385
1860
  function updateImageElementAttribute($el, parsedStyle) {
2386
1861
  var _parsedStyle$img = parsedStyle.img,
@@ -2393,13 +1868,13 @@
2393
1868
  $el.setAttribute('href', img);
2394
1869
  } else if (img instanceof Image) {
2395
1870
  if (!width) {
2396
- $el.setAttribute('width', "".concat(img.width));
1871
+ $el.setAttribute('width', "" + img.width);
2397
1872
  // TODO: set renderable.boundsDirty
2398
1873
  // this.attr('width', img.width);
2399
1874
  }
2400
1875
 
2401
1876
  if (!height) {
2402
- $el.setAttribute('height', "".concat(img.height));
1877
+ $el.setAttribute('height', "" + img.height);
2403
1878
  // this.attr('height', img.height);
2404
1879
  }
2405
1880
 
@@ -2412,21 +1887,21 @@
2412
1887
  } else if (img instanceof ImageData) {
2413
1888
  var canvas = document.createElement('canvas');
2414
1889
  // @ts-ignore
2415
- canvas.setAttribute('width', "".concat(img.width));
1890
+ canvas.setAttribute('width', "" + img.width);
2416
1891
  // @ts-ignore
2417
- canvas.setAttribute('height', "".concat(img.height));
1892
+ canvas.setAttribute('height', "" + img.height);
2418
1893
  var context = canvas.getContext('2d');
2419
1894
  if (context) {
2420
1895
  context.putImageData(img, 0, 0);
2421
1896
  if (!width) {
2422
1897
  // @ts-ignore
2423
- $el.setAttribute('width', "".concat(img.width));
1898
+ $el.setAttribute('width', "" + img.width);
2424
1899
  // this.attr('width', img.width);
2425
1900
  }
2426
1901
 
2427
1902
  if (!height) {
2428
1903
  // @ts-ignore
2429
- $el.setAttribute('height', "".concat(img.height));
1904
+ $el.setAttribute('height', "" + img.height);
2430
1905
  // this.attr('height', img.height);
2431
1906
  }
2432
1907
 
@@ -2469,10 +1944,10 @@
2469
1944
  endOffsetY = Math.sin(rad) * (markerEndOffset || 0);
2470
1945
  }
2471
1946
  // @see https://github.com/antvis/g/issues/1038
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));
1947
+ $el.setAttribute('x1', "" + (x1 - defX + startOffsetX));
1948
+ $el.setAttribute('y1', "" + (y1 - defY + startOffsetY));
1949
+ $el.setAttribute('x2', "" + (x2 - defX + endOffsetX));
1950
+ $el.setAttribute('y2', "" + (y2 - defY + endOffsetY));
2476
1951
  }
2477
1952
  function updatePathElementAttribute($el, parsedStyle) {
2478
1953
  var path = parsedStyle.path,
@@ -2493,9 +1968,8 @@
2493
1968
  var y;
2494
1969
  if (markerStart && gLite.isDisplayObject(markerStart) && markerStartOffset) {
2495
1970
  var _markerStart$parentNo = markerStart.parentNode.getStartTangent(),
2496
- _markerStart$parentNo2 = _slicedToArray(_markerStart$parentNo, 2),
2497
- p1 = _markerStart$parentNo2[0],
2498
- p2 = _markerStart$parentNo2[1];
1971
+ p1 = _markerStart$parentNo[0],
1972
+ p2 = _markerStart$parentNo[1];
2499
1973
  x = p1[0] - p2[0];
2500
1974
  y = p1[1] - p2[1];
2501
1975
  rad = Math.atan2(y, x);
@@ -2504,9 +1978,8 @@
2504
1978
  }
2505
1979
  if (markerEnd && gLite.isDisplayObject(markerEnd) && markerEndOffset) {
2506
1980
  var _markerEnd$parentNode = markerEnd.parentNode.getEndTangent(),
2507
- _markerEnd$parentNode2 = _slicedToArray(_markerEnd$parentNode, 2),
2508
- _p = _markerEnd$parentNode2[0],
2509
- _p2 = _markerEnd$parentNode2[1];
1981
+ _p = _markerEnd$parentNode[0],
1982
+ _p2 = _markerEnd$parentNode[1];
2510
1983
  x = _p[0] - _p2[0];
2511
1984
  y = _p[1] - _p2[1];
2512
1985
  rad = Math.atan2(y, x);
@@ -2558,7 +2031,7 @@
2558
2031
  offsetX = endOffsetX;
2559
2032
  offsetY = endOffsetY;
2560
2033
  }
2561
- return "".concat(point[0] - defX + offsetX, ",").concat(point[1] - defY + offsetY);
2034
+ return point[0] - defX + offsetX + "," + (point[1] - defY + offsetY);
2562
2035
  }).join(' '));
2563
2036
  }
2564
2037
  }
@@ -2575,21 +2048,20 @@
2575
2048
  });
2576
2049
  var d = '';
2577
2050
  if (!hasRadius) {
2578
- d = "M 0,0 l ".concat(width, ",0 l 0,").concat(height, " l").concat(-width, " 0 z");
2051
+ d = "M 0,0 l " + width + ",0 l 0," + height + " l" + -width + " 0 z";
2579
2052
  } else {
2580
2053
  var _radius$map = radius.map(function (r) {
2581
2054
  return clamp(r, 0, Math.min(Math.abs(width) / 2, Math.abs(height) / 2));
2582
2055
  }),
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];
2056
+ tlr = _radius$map[0],
2057
+ trr = _radius$map[1],
2058
+ brr = _radius$map[2],
2059
+ blr = _radius$map[3];
2588
2060
  var signX = width > 0 ? 1 : -1;
2589
2061
  var signY = height > 0 ? 1 : -1;
2590
2062
  // sweep-flag @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Tutorial/Paths#arcs
2591
2063
  var sweepFlag = signX + signY !== 0 ? 1 : 0;
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
+ 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(' ');
2593
2065
  }
2594
2066
  $el.setAttribute('d', d);
2595
2067
  }
@@ -2701,7 +2173,6 @@
2701
2173
  var TEXT_PATH_PREFIX = 'text-path-';
2702
2174
  var SVGRendererPlugin = /*#__PURE__*/function () {
2703
2175
  function SVGRendererPlugin(pluginOptions, defElementManager, context) {
2704
- _classCallCheck$3(this, SVGRendererPlugin);
2705
2176
  this.pluginOptions = void 0;
2706
2177
  this.defElementManager = void 0;
2707
2178
  this.context = void 0;
@@ -2739,553 +2210,534 @@
2739
2210
  this.defElementManager = defElementManager;
2740
2211
  this.context = context;
2741
2212
  }
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;
2749
- // @ts-ignore
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
- }
2763
- }
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);
2213
+ var _proto = SVGRendererPlugin.prototype;
2214
+ _proto.apply = function apply(context) {
2215
+ var _this = this;
2216
+ var renderingService = context.renderingService,
2217
+ renderingContext = context.renderingContext;
2218
+ this.context = context;
2219
+ // @ts-ignore
2220
+ this.context.svgElementMap = this.svgElementMap;
2221
+ var canvas = renderingContext.root.ownerDocument.defaultView;
2222
+ var document = this.context.config.document;
2223
+ var handleMounted = function handleMounted(e) {
2224
+ var object = e.target;
2225
+ // should remove clipPath already existed in <defs>
2226
+ var $useRefs = _this.clipPathUseMap.get(object);
2227
+ if ($useRefs) {
2228
+ var $def = _this.defElementManager.getDefElement();
2229
+ var existed = $def.querySelector("#" + _this.getId(object));
2230
+ if (existed) {
2231
+ existed.remove();
2781
2232
  }
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
2790
- // @ts-ignore
2791
- if (!object.elementSVG) {
2792
- return;
2233
+ }
2234
+ // create SVG DOM Node
2235
+ _this.createSVGDom(document, object, _this.$camera);
2236
+ };
2237
+ var handleUnmounted = function handleUnmounted(e) {
2238
+ var object = e.target;
2239
+ _this.defElementManager.clear(object.entity);
2240
+ _this.clipPathUseMap.delete(object);
2241
+ _this.removeSVGDom(object);
2242
+ };
2243
+ var reorderChildren = function reorderChildren(object) {
2244
+ var _object$parentNode, _object$parentNode$el;
2245
+ var parent = object.parentNode;
2246
+ // @ts-ignore
2247
+ 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;
2248
+ var children = ((parent === null || parent === void 0 ? void 0 : parent.children) || []).slice();
2249
+ if ($groupEl) {
2250
+ _this.reorderChildren(document, $groupEl, children);
2251
+ }
2252
+ };
2253
+ var handleReparent = function handleReparent(e) {
2254
+ var object = e.target;
2255
+ reorderChildren(object);
2256
+ };
2257
+ var handleAttributeChanged = function handleAttributeChanged(e) {
2258
+ var object = e.target;
2259
+ // @see https://github.com/antvis/g/issues/994
2260
+ // @ts-ignore
2261
+ if (!object.elementSVG) {
2262
+ return;
2263
+ }
2264
+ var attrName = e.attrName;
2265
+ var attribtues = _this.dirtyAttributes.get(object);
2266
+ if (!attribtues) {
2267
+ _this.dirtyAttributes.set(object, []);
2268
+ attribtues = _this.dirtyAttributes.get(object);
2269
+ }
2270
+ attribtues.push(attrName);
2271
+ };
2272
+ var handleGeometryBoundsChanged = function handleGeometryBoundsChanged(e) {
2273
+ var _object$elementSVG;
2274
+ var object = e.target;
2275
+ // @ts-ignore
2276
+ var $el = (_object$elementSVG = object.elementSVG) === null || _object$elementSVG === void 0 ? void 0 : _object$elementSVG.$el;
2277
+ var _object$parsedStyle = object.parsedStyle,
2278
+ fill = _object$parsedStyle.fill,
2279
+ stroke = _object$parsedStyle.stroke,
2280
+ clipPath = _object$parsedStyle.clipPath;
2281
+ if (fill && !gLite.isCSSRGB(fill)) {
2282
+ _this.defElementManager.createOrUpdateGradientAndPattern(object, $el, fill, 'fill', _this);
2283
+ }
2284
+ if (stroke && !gLite.isCSSRGB(stroke)) {
2285
+ _this.defElementManager.createOrUpdateGradientAndPattern(object, $el, stroke, 'stroke', _this);
2286
+ }
2287
+ if (clipPath) {
2288
+ var parentInvert = invert(create(), object.getWorldTransform());
2289
+ var clipPathId = CLIP_PATH_PREFIX + clipPath.entity + '-' + object.entity;
2290
+ var $def = _this.defElementManager.getDefElement();
2291
+ var $existed = $def.querySelector("#" + clipPathId);
2292
+ if ($existed) {
2293
+ _this.applyTransform($existed, parentInvert);
2793
2294
  }
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);
2295
+ }
2296
+ };
2297
+ renderingService.hooks.init.tapPromise(SVGRendererPlugin.tag, /*#__PURE__*/_asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee() {
2298
+ var _this$context$config, background, document, $svg;
2299
+ return _regeneratorRuntime$3().wrap(function _callee$(_context) {
2300
+ while (1) switch (_context.prev = _context.next) {
2301
+ case 0:
2302
+ _this$context$config = _this.context.config, background = _this$context$config.background, document = _this$context$config.document; // <defs>
2303
+ _this.defElementManager.init();
2304
+ $svg = _this.context.contextService.getContext();
2305
+ if (background) {
2306
+ $svg.style.background = background;
2307
+ }
2308
+ // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
2309
+ $svg.setAttribute('color-interpolation-filters', 'sRGB');
2310
+ _this.$camera = createSVGElement('g', document);
2311
+ _this.$camera.id = G_SVG_PREFIX + "-camera";
2312
+ _this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
2313
+ $svg.appendChild(_this.$camera);
2314
+ canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
2315
+ canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
2316
+ canvas.addEventListener(gLite.ElementEvent.REPARENT, handleReparent);
2317
+ canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
2318
+ canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
2319
+ case 14:
2320
+ case "end":
2321
+ return _context.stop();
2799
2322
  }
2800
- attribtues.push(attrName);
2801
- };
2802
- var handleGeometryBoundsChanged = function handleGeometryBoundsChanged(e) {
2803
- var _object$elementSVG;
2804
- var object = e.target;
2323
+ }, _callee);
2324
+ })));
2325
+ renderingService.hooks.destroy.tap(SVGRendererPlugin.tag, function () {
2326
+ canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
2327
+ canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
2328
+ canvas.removeEventListener(gLite.ElementEvent.REPARENT, handleReparent);
2329
+ canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
2330
+ canvas.removeEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
2331
+ });
2332
+ renderingService.hooks.render.tap(SVGRendererPlugin.tag, function (object) {
2333
+ _this.renderQueue.push(object);
2334
+ });
2335
+ renderingService.hooks.beginFrame.tap(SVGRendererPlugin.tag, function () {
2336
+ var doc = _this.context.config.document;
2337
+ if (_this.pendingReorderQueue.size) {
2338
+ _this.pendingReorderQueue.forEach(function (object) {
2339
+ var _object$elementSVG2;
2340
+ var children = ((object === null || object === void 0 ? void 0 : object.children) || []).slice();
2341
+ var $parentGroupEl =
2342
+ // @ts-ignore
2343
+ object === null || object === void 0 ? void 0 : (_object$elementSVG2 = object.elementSVG) === null || _object$elementSVG2 === void 0 ? void 0 : _object$elementSVG2.$groupEl;
2344
+ if ($parentGroupEl) {
2345
+ _this.reorderChildren(doc || document, $parentGroupEl, children || []);
2346
+ }
2347
+ });
2348
+ _this.pendingReorderQueue.clear();
2349
+ }
2350
+ });
2351
+ renderingService.hooks.endFrame.tap(SVGRendererPlugin.tag, function () {
2352
+ if (renderingContext.renderReasons.has(gLite.RenderReason.CAMERA_CHANGED)) {
2353
+ _this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
2354
+ }
2355
+ _this.renderQueue.forEach(function (object) {
2356
+ var _object$elementSVG3, _object$elementSVG4;
2805
2357
  // @ts-ignore
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);
2358
+ var $el = (_object$elementSVG3 = object.elementSVG) === null || _object$elementSVG3 === void 0 ? void 0 : _object$elementSVG3.$el;
2359
+ // @ts-ignore
2360
+ var $groupEl = (_object$elementSVG4 = object.elementSVG) === null || _object$elementSVG4 === void 0 ? void 0 : _object$elementSVG4.$groupEl;
2361
+ if ($el && $groupEl) {
2362
+ // apply local RTS transformation to <group> wrapper
2363
+ // account for anchor
2364
+ var localTransform = object.getLocalTransform();
2365
+ _this.applyTransform($groupEl, localTransform);
2366
+ // clipped shapes should also be informed
2367
+ var $useRefs = _this.clipPathUseMap.get(object);
2368
+ if ($useRefs && $useRefs.length) {
2369
+ $useRefs.forEach(function ($use) {
2370
+ // <clipPath transform="matrix()"><circle /></clipPath>
2371
+ _this.applyTransform($use, object.getWorldTransform());
2372
+ // const parentInvert = mat4.invert(
2373
+ // mat4.create(),
2374
+ // (object as DisplayObject).getWorldTransform(),
2375
+ // );
2376
+ // this.applyTransform($clipPath, parentInvert);
2377
+ });
2824
2378
  }
2379
+ // finish rendering, clear dirty flag
2380
+ object.renderable.dirty = false;
2825
2381
  }
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 || []);
2382
+ // update dirty attributes
2383
+ var attributes = _this.dirtyAttributes.get(object);
2384
+ if (attributes) {
2385
+ attributes.forEach(function (attrName) {
2386
+ if (attrName === 'zIndex') {
2387
+ reorderChildren(object);
2388
+ } else if (attrName === 'increasedLineWidthForHitTesting') {
2389
+ _this.createOrUpdateHitArea(object, $el, $groupEl);
2876
2390
  }
2391
+ _this.updateAttribute(object, [attrName]);
2877
2392
  });
2878
- _this.pendingReorderQueue.clear();
2393
+ _this.dirtyAttributes.delete(object);
2879
2394
  }
2880
2395
  });
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;
2887
- // @ts-ignore
2888
- var $el = (_object$elementSVG3 = object.elementSVG) === null || _object$elementSVG3 === void 0 ? void 0 : _object$elementSVG3.$el;
2396
+ _this.renderQueue = [];
2397
+ });
2398
+ };
2399
+ _proto.getId = function getId(object) {
2400
+ return G_SVG_PREFIX + "-" + object.entity;
2401
+ };
2402
+ _proto.reorderChildren = function reorderChildren(doc, $groupEl, children) {
2403
+ // need to reorder parent's children
2404
+ children.sort(function (a, b) {
2405
+ return a.sortable.renderOrder - b.sortable.renderOrder;
2406
+ });
2407
+ if (children.length) {
2408
+ // create empty fragment
2409
+ var fragment = (doc || document).createDocumentFragment();
2410
+ children.forEach(function (child) {
2411
+ if (child.isConnected) {
2889
2412
  // @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;
2911
- }
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);
2413
+ var $el = child.elementSVG.$groupEl;
2414
+ if ($el) {
2415
+ fragment.appendChild($el);
2924
2416
  }
2925
- });
2926
- _this.renderQueue = [];
2417
+ }
2927
2418
  });
2419
+ $groupEl.appendChild(fragment);
2928
2420
  }
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);
2954
- }
2955
- }
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));
2421
+ };
2422
+ _proto.applyTransform = function applyTransform($el, rts) {
2423
+ // use proper precision avoiding too long string in `transform`
2424
+ // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
2425
+ $el.setAttribute('transform', "matrix(" + numberToLongString(rts[0]) + "," + numberToLongString(rts[1]) + "," + numberToLongString(rts[4]) + "," + numberToLongString(rts[5]) + "," + numberToLongString(rts[12]) + "," + numberToLongString(rts[13]) + ")");
2426
+ };
2427
+ _proto.applyAttributes = function applyAttributes(object) {
2428
+ // @ts-ignore
2429
+ var elementSVG = object.elementSVG;
2430
+ var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
2431
+ var $groupEl = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$groupEl;
2432
+ if ($el && $groupEl) {
2433
+ var nodeName = object.nodeName,
2434
+ attributes = object.attributes;
2435
+ $el.setAttribute('fill', 'none');
2436
+ if (nodeName === gLite.Shape.IMAGE) {
2437
+ $el.setAttribute('preserveAspectRatio', 'none');
2979
2438
  }
2439
+ // apply attributes
2440
+ this.updateAttribute(object, Object.keys(attributes));
2980
2441
  }
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 (
2442
+ };
2443
+ _proto.updateAttribute = function updateAttribute(object, attributes) {
2444
+ var _this2 = this;
2445
+ var document = this.context.config.document;
2446
+ // @ts-ignore
2447
+ var _object$elementSVG5 = object.elementSVG,
2448
+ $el = _object$elementSVG5.$el,
2449
+ $groupEl = _object$elementSVG5.$groupEl,
2450
+ $hitTestingEl = _object$elementSVG5.$hitTestingEl;
2451
+ var parsedStyle = object.parsedStyle,
2452
+ computedStyle = object.computedStyle,
2453
+ nodeName = object.nodeName;
2454
+ var shouldUpdateElementAttribute = attributes.some(function (name) {
2455
+ return (
2456
+ // @ts-ignore
2457
+ _this2.context.SVGElementLifeCycleContribution.shouldUpdateElementAttribute(object, name)
2458
+ );
2459
+ });
2460
+ // need re-generate path
2461
+ if (shouldUpdateElementAttribute && $el) {
2462
+ [$el, $hitTestingEl].forEach(function ($el) {
2463
+ if ($el) {
2996
2464
  // @ts-ignore
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) {
2465
+ _this2.context.SVGElementLifeCycleContribution.updateElementAttribute(object, $el, _this2.svgElementMap);
2466
+ if (object.nodeName !== gLite.Shape.TEXT) {
3066
2467
  _this2.updateAnchorWithTransform(object);
3067
2468
  }
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
- }
3082
2469
  }
3083
2470
  });
3084
2471
  }
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;
2472
+ // update common attributes
2473
+ attributes.forEach(function (name) {
2474
+ var _FORMAT_VALUE_MAP$nam, _propertyMetadataCach;
2475
+ var usedName = SVG_ATTR_MAP[name];
2476
+ var computedValue = gLite.runtime.enableCSSParsing ? computedStyle[name] : parsedStyle[name];
2477
+ var computedValueStr = !isNil(computedValue) && computedValue.toString();
2478
+ 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;
2479
+ var usedValue = parsedStyle[name];
2480
+ var inherited = usedName && !!((_propertyMetadataCach = gLite.propertyMetadataCache[name]) === null || _propertyMetadataCach === void 0 ? void 0 : _propertyMetadataCach.inh);
2481
+ if (!usedName || (nodeName === gLite.Shape.GROUP || object.isCustomElement) && !gLite.runtime.enableCSSParsing && (inherited || usedName === 'fill' || usedName === 'stroke')) {
2482
+ return;
2483
+ }
2484
+ // <foreignObject>
2485
+ if (nodeName === gLite.Shape.HTML) {
2486
+ if (name === 'lineWidth') {
2487
+ $el.style['border-width'] = (usedValue || 0) + "px";
2488
+ } else if (name === 'lineDash') {
2489
+ $el.style['border-style'] = 'dashed';
3104
2490
  }
3105
- if (this.pluginOptions.outputSVGElementId) {
3106
- $el.id = this.getId(object);
2491
+ }
2492
+ if (name === 'fill') {
2493
+ if (nodeName === gLite.Shape.HTML) {
2494
+ $el.style.background = usedValue.toString();
2495
+ } else {
2496
+ _this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName, _this2);
3107
2497
  }
3108
- if (this.pluginOptions.outputSVGElementName && object.name) {
3109
- $el.setAttribute('name', object.name);
2498
+ } else if (name === 'stroke') {
2499
+ if (nodeName === gLite.Shape.HTML) {
2500
+ $el.style['border-color'] = usedValue.toString();
2501
+ $el.style['border-style'] = 'solid';
2502
+ } else {
2503
+ _this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName, _this2);
3110
2504
  }
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);
2505
+ } else if (gLite.runtime.enableCSSParsing && inherited) {
2506
+ // use computed value
2507
+ // update `visibility` on <group>
2508
+ if (computedValueStr !== 'unset' && computedValueStr !== DEFAULT_VALUE_MAP[name]) {
2509
+ $groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, formattedValueStr);
3115
2510
  } else {
3116
- $groupEl = $el;
2511
+ $groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.removeAttribute(usedName);
3117
2512
  }
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);
2513
+ } else if (name === 'clipPath') {
2514
+ _this2.createOrUpdateClipOrTextPath(document, usedValue, object);
2515
+ } else if (name === 'textPath') {
2516
+ _this2.createOrUpdateClipOrTextPath(document, usedValue, object, true);
2517
+ } else if (name === 'shadowType' || name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
2518
+ _this2.defElementManager.createOrUpdateShadow(object, $el, name);
2519
+ } else if (name === 'filter') {
2520
+ _this2.defElementManager.createOrUpdateFilter(object, $el, usedValue);
2521
+ } else if (name === 'innerHTML') {
2522
+ _this2.createOrUpdateInnerHTML(document, $el, usedValue);
2523
+ } else if (name === 'anchor') {
2524
+ // text' anchor is controlled by `textAnchor` property
2525
+ if (nodeName !== gLite.Shape.TEXT) {
2526
+ _this2.updateAnchorWithTransform(object);
2527
+ }
2528
+ } else {
2529
+ if (!isNil(computedValue)) {
2530
+ // use computed value so that we can use cascaded effect in SVG
2531
+ // ignore 'unset' and default value
2532
+ [$el, $hitTestingEl].forEach(function ($el) {
2533
+ if ($el && usedName) {
2534
+ if (computedValueStr !== 'unset' && computedValueStr !== DEFAULT_VALUE_MAP[name]) {
2535
+ $el.setAttribute(usedName, formattedValueStr);
2536
+ } else {
2537
+ $el.removeAttribute(usedName);
2538
+ }
2539
+ }
2540
+ });
3131
2541
  }
3132
2542
  }
2543
+ });
2544
+ };
2545
+ _proto.createSVGDom = function createSVGDom(document, object, root, noWrapWithGroup) {
2546
+ if (noWrapWithGroup === void 0) {
2547
+ noWrapWithGroup = false;
3133
2548
  }
3134
- }, {
3135
- key: "removeSVGDom",
3136
- value: function removeSVGDom(object) {
3137
- var _object$elementSVG6;
2549
+ // create svg element
2550
+ // @ts-ignore
2551
+ object.elementSVG = new ElementSVG();
2552
+ // @ts-ignore
2553
+ var svgElement = object.elementSVG;
2554
+ // use <group> as default, eg. CustomElement
2555
+ var $el =
2556
+ // @ts-ignore
2557
+ this.context.SVGElementLifeCycleContribution.createElement(object, this.svgElementMap);
2558
+ if ($el) {
2559
+ var _object$parentNode$el2;
2560
+ var $groupEl;
2561
+ // save $el on parsedStyle, which will be returned in getDomElement()
2562
+ if (object.nodeName === gLite.Shape.HTML) {
2563
+ object.parsedStyle.$el = $el;
2564
+ }
2565
+ if (this.pluginOptions.outputSVGElementId) {
2566
+ $el.id = this.getId(object);
2567
+ }
2568
+ if (this.pluginOptions.outputSVGElementName && object.name) {
2569
+ $el.setAttribute('name', object.name);
2570
+ }
2571
+ if (($el.hasAttribute('data-wrapgroup') || $el.nodeName !== 'g') && !noWrapWithGroup) {
2572
+ $groupEl = createSVGElement('g', document);
2573
+ $groupEl.id = $el.id + '-g';
2574
+ $groupEl.appendChild($el);
2575
+ } else {
2576
+ $groupEl = $el;
2577
+ }
2578
+ svgElement.$el = $el;
2579
+ svgElement.$groupEl = $groupEl;
2580
+ // apply attributes at first time
2581
+ this.applyAttributes(object);
2582
+ // create hitArea if necessary
2583
+ this.createOrUpdateHitArea(object, $el, $groupEl);
2584
+ var $parentGroupEl = root ||
3138
2585
  // @ts-ignore
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);
2586
+ object.parentNode && ((_object$parentNode$el2 = object.parentNode.elementSVG) === null || _object$parentNode$el2 === void 0 ? void 0 : _object$parentNode$el2.$groupEl);
2587
+ if ($parentGroupEl) {
2588
+ $parentGroupEl.appendChild($groupEl);
2589
+ // need reorder children later
2590
+ this.pendingReorderQueue.add(object.parentNode);
3145
2591
  }
3146
2592
  }
3147
- }, {
3148
- key: "createOrUpdateHitArea",
3149
- value: function createOrUpdateHitArea(object, $el, $groupEl) {
2593
+ };
2594
+ _proto.removeSVGDom = function removeSVGDom(object) {
2595
+ var _object$elementSVG6;
2596
+ // @ts-ignore
2597
+ var $groupEl = (_object$elementSVG6 = object.elementSVG) === null || _object$elementSVG6 === void 0 ? void 0 : _object$elementSVG6.$groupEl;
2598
+ if ($groupEl && $groupEl.parentNode) {
2599
+ $groupEl.parentNode.removeChild($groupEl);
3150
2600
  // @ts-ignore
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;
2601
+ this.context.SVGElementLifeCycleContribution.destroyElement(object, $groupEl);
2602
+ // object.entity.removeComponent(ElementSVG, true);
2603
+ }
2604
+ };
2605
+
2606
+ _proto.createOrUpdateHitArea = function createOrUpdateHitArea(object, $el, $groupEl) {
2607
+ // @ts-ignore
2608
+ var svgElement = object.elementSVG;
2609
+ var $hitTestingEl = svgElement.$hitTestingEl;
2610
+ var increasedLineWidthForHitTesting = object.parsedStyle.increasedLineWidthForHitTesting;
2611
+ // account for hitArea
2612
+ if (increasedLineWidthForHitTesting) {
2613
+ if (!$hitTestingEl) {
2614
+ $hitTestingEl = $el.cloneNode();
2615
+ if (this.pluginOptions.outputSVGElementId) {
2616
+ // use the entity suffix, so that `g-plugin-svg-picker` can extract
2617
+ $hitTestingEl.id = G_SVG_PREFIX + "-" + object.nodeName + "-hittesting-" + object.entity;
3179
2618
  }
2619
+ // clear attributes like `filter` `font-size`
2620
+ ['filter'].forEach(function (attribute) {
2621
+ $hitTestingEl.removeAttribute(attribute);
2622
+ });
2623
+ // hitArea should be 'transparent' but not 'none'
2624
+ var hasFill = $el.getAttribute('fill') !== 'none';
2625
+ $hitTestingEl.setAttribute('fill', hasFill ? 'transparent' : 'none');
2626
+ $hitTestingEl.setAttribute('stroke', 'transparent');
2627
+ $groupEl.appendChild($hitTestingEl);
2628
+ svgElement.$hitTestingEl = $hitTestingEl;
2629
+ }
2630
+ // increase interactive line width
2631
+ $hitTestingEl.setAttribute('stroke-width', "" + (increasedLineWidthForHitTesting + object.parsedStyle.lineWidth));
2632
+ } else {
2633
+ if ($hitTestingEl) {
2634
+ $groupEl.removeChild($hitTestingEl);
2635
+ svgElement.$hitTestingEl = null;
3180
2636
  }
3181
2637
  }
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);
2638
+ };
2639
+ _proto.createOrUpdateInnerHTML = function createOrUpdateInnerHTML(doc, $el, usedValue) {
2640
+ var $div = (doc || document).createElement('div');
2641
+ if (typeof usedValue === 'string') {
2642
+ $div.innerHTML = usedValue;
2643
+ } else {
2644
+ $div.appendChild(usedValue);
3193
2645
  }
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
- }
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);
2646
+ $el.innerHTML = '';
2647
+ $el.appendChild($div);
2648
+ };
2649
+ _proto.createOrUpdateClipOrTextPath = function createOrUpdateClipOrTextPath(document, clipPath, object, isTextPath) {
2650
+ if (isTextPath === void 0) {
2651
+ isTextPath = false;
2652
+ }
2653
+ // @ts-ignore
2654
+ var $groupEl = object.elementSVG.$groupEl;
2655
+ var PREFIX = isTextPath ? TEXT_PATH_PREFIX : CLIP_PATH_PREFIX;
2656
+ var attributeNameCamel = isTextPath ? 'g' : 'clipPath';
2657
+ var attributeNameHyphen = isTextPath ? 'text-path' : 'clip-path';
2658
+ if (clipPath) {
2659
+ var clipPathId = PREFIX + clipPath.entity + '-' + object.entity;
2660
+ var $def = this.defElementManager.getDefElement();
2661
+ var existed = $def.querySelector("#" + clipPathId);
2662
+ if (!existed) {
2663
+ var $clipPath;
2664
+ if (isTextPath) {
2665
+ // use <path> directly instead of wrapping with <g>
2666
+ this.createSVGDom(document, clipPath, null, true);
2667
+ // @ts-ignore
2668
+ $clipPath = clipPath.elementSVG.$el;
2669
+ } else {
2670
+ // the clipPath is allowed to be detached from canvas
2671
+ if (!clipPath.isConnected) {
2672
+ var $existedClipPath = $def.querySelector("#" + this.getId(clipPath));
2673
+ if (!$existedClipPath) {
2674
+ this.createSVGDom(document, clipPath, $def, true);
3232
2675
  }
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);
3238
2676
  }
3239
- $clipPath.id = clipPathId;
3240
- // append it to <defs>
3241
- $def.appendChild($clipPath);
3242
- }
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, ")"));
3249
- }
3250
- } else {
3251
- if (!isTextPath) {
3252
- // remove clip path
3253
- $groupEl.removeAttribute(attributeNameHyphen);
2677
+ // create <clipPath> dom node
2678
+ $clipPath = createSVGElement(attributeNameCamel, document);
2679
+ var $use = createSVGElement('use', document);
2680
+ // @ts-ignore
2681
+ $use.setAttribute('href', "#" + clipPath.elementSVG.$el.id);
2682
+ $clipPath.appendChild($use);
2683
+ var $useRefs = this.clipPathUseMap.get(clipPath);
2684
+ if (!$useRefs) {
2685
+ this.clipPathUseMap.set(clipPath, []);
2686
+ $useRefs = this.clipPathUseMap.get(clipPath);
2687
+ }
2688
+ $useRefs.push($use);
2689
+ // <clipPath transform="matrix()"><circle /></clipPath>
2690
+ this.applyTransform($use, clipPath.getWorldTransform());
2691
+ var parentInvert = invert(create(), object.getWorldTransform());
2692
+ this.applyTransform($clipPath, parentInvert);
3254
2693
  }
2694
+ $clipPath.id = clipPathId;
2695
+ // append it to <defs>
2696
+ $def.appendChild($clipPath);
2697
+ }
2698
+ // apply attributes
2699
+ this.applyAttributes(clipPath);
2700
+ if (!isTextPath) {
2701
+ // apply clipPath to $group
2702
+ // @see https://github.com/antvis/g/issues/961
2703
+ $groupEl.setAttribute(attributeNameHyphen, "url(#" + clipPathId + ")");
2704
+ }
2705
+ } else {
2706
+ if (!isTextPath) {
2707
+ // remove clip path
2708
+ $groupEl.removeAttribute(attributeNameHyphen);
3255
2709
  }
3256
2710
  }
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
- }
2711
+ }
2712
+ /**
2713
+ * the origin is bounding box's top left corner
2714
+ */;
2715
+ _proto.updateAnchorWithTransform = function updateAnchorWithTransform(object) {
2716
+ var _object$elementSVG7, _object$elementSVG8;
2717
+ var bounds = object.getGeometryBounds();
2718
+ var width = bounds && bounds.halfExtents[0] * 2 || 0;
2719
+ var height = bounds && bounds.halfExtents[1] * 2 || 0;
2720
+ var _ref2 = object.parsedStyle || {},
2721
+ anchor = _ref2.anchor;
2722
+ // @ts-ignore
2723
+ [(_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) {
2724
+ if ($el) {
2725
+ var tx = -(anchor[0] * width);
2726
+ var ty = -(anchor[1] * height);
2727
+ if (tx !== 0 || ty !== 0) {
2728
+ // apply anchor to element's `transform` property
2729
+ $el.setAttribute('transform',
2730
+ // can't use percent unit like translate(-50%, -50%)
2731
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/transform#translate
2732
+ "translate(" + tx + "," + ty + ")");
3285
2733
  }
3286
- });
3287
- }
3288
- }]);
2734
+ if (object.nodeName === gLite.Shape.CIRCLE || object.nodeName === gLite.Shape.ELLIPSE) {
2735
+ $el.setAttribute('cx', "" + width / 2);
2736
+ $el.setAttribute('cy', "" + height / 2);
2737
+ }
2738
+ }
2739
+ });
2740
+ };
3289
2741
  return SVGRendererPlugin;
3290
2742
  }();
3291
2743
  SVGRendererPlugin.tag = 'SVGRenderer';
@@ -3327,18 +2779,18 @@
3327
2779
  var lineNum = lines.length;
3328
2780
  var styleCSSText = '';
3329
2781
  if (dx !== 0 || dy !== 0) {
3330
- styleCSSText += "transform:translate(".concat(dx, "px, ").concat(dy, "px);");
2782
+ styleCSSText += "transform:translate(" + dx + "px, " + dy + "px);";
3331
2783
  }
3332
2784
  if (textDecorationLine && textDecorationLine !== 'none') {
3333
2785
  // use CSS text-decoration since the implementation in SVG is not good enough
3334
- styleCSSText += "text-decoration:".concat(textDecorationLine, " ").concat(textDecorationStyle, " ").concat(textDecorationColor, ";");
2786
+ styleCSSText += "text-decoration:" + textDecorationLine + " " + textDecorationStyle + " " + textDecorationColor + ";";
3335
2787
  }
3336
2788
  if (styleCSSText) {
3337
2789
  $el.setAttribute('style', styleCSSText);
3338
2790
  }
3339
2791
  if (lineNum === 1) {
3340
2792
  var textContent = convertHTML(lines[0]);
3341
- $el.setAttribute('dx', "".concat(lineWidth / 2));
2793
+ $el.setAttribute('dx', "" + lineWidth / 2);
3342
2794
  // Since `text-after-edge` is not a standard property value, we use `dy` instead.
3343
2795
  if (textBaseline === 'bottom' || textBaseline === 'top') {
3344
2796
  $el.setAttribute('dominant-baseline', 'middle');
@@ -3351,12 +2803,12 @@
3351
2803
  $el.innerHTML = '';
3352
2804
  // append <textPath href="#MyPath">text</textPath>
3353
2805
  var $textPath = createSVGElement('textPath', $el.ownerDocument);
3354
- $textPath.setAttribute('href', "#".concat(TEXT_PATH_PREFIX + textPath.entity));
2806
+ $textPath.setAttribute('href', "#" + (TEXT_PATH_PREFIX + textPath.entity));
3355
2807
  if (textPathSide !== 'left') {
3356
2808
  $textPath.setAttribute('side', textPathSide);
3357
2809
  }
3358
2810
  if (textPathStartOffset !== 0) {
3359
- $textPath.setAttribute('startOffset', "".concat(textPathStartOffset));
2811
+ $textPath.setAttribute('startOffset', "" + textPathStartOffset);
3360
2812
  }
3361
2813
  $textPath.innerHTML = textContent;
3362
2814
  $el.appendChild($textPath);
@@ -3379,81 +2831,72 @@
3379
2831
  } else {
3380
2832
  dy = lineHeight;
3381
2833
  }
3382
- return "<tspan x=\"0\" dx=\"".concat(dx, "\" dy=\"").concat(dy, "\">").concat(convertHTML(line), "</tspan>");
2834
+ return "<tspan x=\"0\" dx=\"" + dx + "\" dy=\"" + dy + "\">" + convertHTML(line) + "</tspan>";
3383
2835
  }).join('');
3384
2836
  }
3385
2837
  }
3386
2838
  var _SHAPE2TAGS, _SHAPE_UPDATE_DEPS;
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',
2839
+ 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);
2840
+ 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',
3389
2841
  // 'whiteSpace',
3390
- 'dx', 'dy']), _SHAPE_UPDATE_DEPS);
2842
+ 'dx', 'dy'], _SHAPE_UPDATE_DEPS);
3391
2843
  var DefaultElementLifeCycleContribution = /*#__PURE__*/function () {
3392
2844
  function DefaultElementLifeCycleContribution(context) {
3393
- _classCallCheck$3(this, DefaultElementLifeCycleContribution);
3394
2845
  this.context = void 0;
3395
2846
  this.context = context;
3396
2847
  }
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;
3405
- }
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
- }
2848
+ var _proto = DefaultElementLifeCycleContribution.prototype;
2849
+ _proto.createElement = function createElement(object, svgElementMap) {
2850
+ var doc = this.context.config.document;
2851
+ var type = SHAPE2TAGS[object.nodeName] || 'g';
2852
+ var $el = createSVGElement(type, doc || document);
2853
+ svgElementMap.set($el, object);
2854
+ return $el;
2855
+ };
2856
+ _proto.destroyElement = function destroyElement(object, $el) {};
2857
+ _proto.shouldUpdateElementAttribute = function shouldUpdateElementAttribute(object, attributeName) {
2858
+ var nodeName = object.nodeName;
2859
+ return (SHAPE_UPDATE_DEPS[nodeName] || []).indexOf(attributeName) > -1;
2860
+ };
2861
+ _proto.updateElementAttribute = function updateElementAttribute(object) {
2862
+ // @ts-ignore
2863
+ var $el = object.elementSVG.$el;
2864
+ var nodeName = object.nodeName,
2865
+ parsedStyle = object.parsedStyle;
2866
+ switch (nodeName) {
2867
+ case gLite.Shape.IMAGE:
2868
+ {
2869
+ updateImageElementAttribute($el, parsedStyle);
2870
+ break;
2871
+ }
2872
+ case gLite.Shape.RECT:
2873
+ {
2874
+ updateRectElementAttribute($el, parsedStyle);
2875
+ break;
2876
+ }
2877
+ case gLite.Shape.LINE:
2878
+ {
2879
+ updateLineElementAttribute($el, parsedStyle);
2880
+ break;
2881
+ }
2882
+ case gLite.Shape.POLYGON:
2883
+ case gLite.Shape.POLYLINE:
2884
+ {
2885
+ updatePolylineElementAttribute($el, parsedStyle);
2886
+ break;
2887
+ }
2888
+ case gLite.Shape.PATH:
2889
+ {
2890
+ updatePathElementAttribute($el, parsedStyle);
2891
+ break;
2892
+ }
2893
+ case gLite.Shape.TEXT:
2894
+ {
2895
+ updateTextElementAttribute($el, parsedStyle);
2896
+ break;
2897
+ }
3455
2898
  }
3456
- }]);
2899
+ };
3457
2900
  return DefaultElementLifeCycleContribution;
3458
2901
  }();
3459
2902
  var FILTER_PREFIX = 'g-filter-';
@@ -3464,7 +2907,7 @@
3464
2907
  function createOrUpdateFilter(document, $def, object, $el, filters) {
3465
2908
  // eg. filter="url(#f1) url(#f2)"
3466
2909
  var filterName = FILTER_PREFIX + object.entity;
3467
- var $existedFilters = $def.querySelectorAll("[name=".concat(filterName, "]"));
2910
+ var $existedFilters = $def.querySelectorAll("[name=" + filterName + "]");
3468
2911
  if ($existedFilters.length) {
3469
2912
  $existedFilters.forEach(function ($filter) {
3470
2913
  $def.removeChild($filter);
@@ -3499,7 +2942,7 @@
3499
2942
  } else if (name === 'invert') {
3500
2943
  createInvert(document, $filter, params);
3501
2944
  }
3502
- $filter.id = "".concat(filterName, "-").concat(i);
2945
+ $filter.id = filterName + "-" + i;
3503
2946
  $filter.setAttribute('name', filterName);
3504
2947
  $def.appendChild($filter);
3505
2948
  return $filter.id;
@@ -3507,7 +2950,7 @@
3507
2950
  // @see https://github.com/antvis/G/issues/1114
3508
2951
  setTimeout(function () {
3509
2952
  $el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', filterIds.map(function (filterId) {
3510
- return "url(#".concat(filterId, ")");
2953
+ return "url(#" + filterId + ")";
3511
2954
  }).join(' '));
3512
2955
  });
3513
2956
  }
@@ -3521,7 +2964,7 @@
3521
2964
  function createBlur(document, $filter, params) {
3522
2965
  var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
3523
2966
  $feGaussianBlur.setAttribute('in', 'SourceGraphic');
3524
- $feGaussianBlur.setAttribute('stdDeviation', "".concat(params[0].value));
2967
+ $feGaussianBlur.setAttribute('stdDeviation', "" + params[0].value);
3525
2968
  $filter.appendChild($feGaussianBlur);
3526
2969
  }
3527
2970
  function createFeComponentTransfer(document, $filter, _ref2) {
@@ -3533,10 +2976,10 @@
3533
2976
  [createSVGElement('feFuncR', document), createSVGElement('feFuncG', document), createSVGElement('feFuncB', document)].forEach(function ($feFunc) {
3534
2977
  $feFunc.setAttribute('type', type);
3535
2978
  if (type === 'table') {
3536
- $feFunc.setAttribute('tableValues', "".concat(tableValues));
2979
+ $feFunc.setAttribute('tableValues', "" + tableValues);
3537
2980
  } else {
3538
- $feFunc.setAttribute('slope', "".concat(slope));
3539
- $feFunc.setAttribute('intercept', "".concat(intercept));
2981
+ $feFunc.setAttribute('slope', "" + slope);
2982
+ $feFunc.setAttribute('intercept', "" + intercept);
3540
2983
  }
3541
2984
  $feComponentTransfer.appendChild($feFunc);
3542
2985
  });
@@ -3554,7 +2997,7 @@
3554
2997
  var amount = convertToAbsoluteValue(params[0]);
3555
2998
  createFeComponentTransfer(document, $filter, {
3556
2999
  type: 'table',
3557
- tableValues: "".concat(amount, " ").concat(1 - amount)
3000
+ tableValues: amount + " " + (1 - amount)
3558
3001
  });
3559
3002
  }
3560
3003
  function createBrightness(document, $filter, params) {
@@ -3569,7 +3012,7 @@
3569
3012
  var amount = convertToAbsoluteValue(params[0]);
3570
3013
  var $feColorMatrix = createSVGElement('feColorMatrix', document);
3571
3014
  $feColorMatrix.setAttribute('type', 'saturate');
3572
- $feColorMatrix.setAttribute('values', "".concat(amount));
3015
+ $feColorMatrix.setAttribute('values', "" + amount);
3573
3016
  $filter.appendChild($feColorMatrix);
3574
3017
  }
3575
3018
  function createHueRotate(document, $filter, params) {
@@ -3577,7 +3020,7 @@
3577
3020
  $feColorMatrix.setAttribute('type', 'hueRotate');
3578
3021
  // $feColorMatrix.setAttribute('values', `${params[0].to(UnitType.kDegrees).value}`);
3579
3022
  // FIXME: convert to degrees
3580
- $feColorMatrix.setAttribute('values', "".concat(params[0].value));
3023
+ $feColorMatrix.setAttribute('values', "" + params[0].value);
3581
3024
  $filter.appendChild($feColorMatrix);
3582
3025
  }
3583
3026
  function createDropShadow(document, $filter, params) {
@@ -3588,11 +3031,11 @@
3588
3031
  var shadowColor = params[3].formatted;
3589
3032
  var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
3590
3033
  $feGaussianBlur.setAttribute('in', 'SourceAlpha');
3591
- $feGaussianBlur.setAttribute('stdDeviation', "".concat(shadowBlur));
3034
+ $feGaussianBlur.setAttribute('stdDeviation', "" + shadowBlur);
3592
3035
  $filter.appendChild($feGaussianBlur);
3593
3036
  var $feOffset = createSVGElement('feOffset', document);
3594
- $feOffset.setAttribute('dx', "".concat(shadowOffsetX));
3595
- $feOffset.setAttribute('dy', "".concat(shadowOffsetY));
3037
+ $feOffset.setAttribute('dx', "" + shadowOffsetX);
3038
+ $feOffset.setAttribute('dy', "" + shadowOffsetY);
3596
3039
  $feOffset.setAttribute('result', 'offsetblur');
3597
3040
  $filter.appendChild($feOffset);
3598
3041
  var $feFlood = createSVGElement('feFlood', document);
@@ -3650,32 +3093,34 @@
3650
3093
  var patternId = createOrUpdatePattern(document, $def, object, parsedColor, createImage, plugin);
3651
3094
  // use style instead of attribute when applying <pattern>
3652
3095
  // @see https://stackoverflow.com/a/7723115
3653
- $el.style[name] = "url(#".concat(patternId, ")");
3096
+ $el.style[name] = "url(#" + patternId + ")";
3654
3097
  return patternId;
3655
3098
  } else {
3656
3099
  if (parsedColor.length === 1) {
3657
3100
  var gradientId = createOrUpdateGradient(document, object, $def, $el, parsedColor[0]);
3658
- $el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#".concat(gradientId, ")"));
3101
+ $el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#" + gradientId + ")");
3659
3102
  return gradientId;
3660
3103
  } else {
3661
3104
  // @see https://stackoverflow.com/questions/20671502/can-i-blend-gradients-in-svg
3662
3105
  var filterId = createOrUpdateMultiGradient(document, object, $def, $el, parsedColor);
3663
- $el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#".concat(filterId, ")"));
3106
+ $el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + filterId + ")");
3664
3107
  $el === null || $el === void 0 ? void 0 : $el.setAttribute('fill', 'black');
3665
3108
  return filterId;
3666
3109
  }
3667
3110
  }
3668
3111
  return '';
3669
3112
  }
3670
- function generateCacheKey(src) {
3671
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3113
+ function generateCacheKey(src, options) {
3114
+ if (options === void 0) {
3115
+ options = {};
3116
+ }
3672
3117
  var cacheKey = '';
3673
3118
  if (gLite.isCSSGradientValue(src)) {
3674
3119
  var type = src.type,
3675
3120
  value = src.value;
3676
3121
  if (type === gLite.GradientType.LinearGradient || type === gLite.GradientType.RadialGradient) {
3677
3122
  // @ts-ignore
3678
- var _value$options = _objectSpread2(_objectSpread2({}, value), options),
3123
+ var _value$options = _extends({}, value, options),
3679
3124
  _type = _value$options.type,
3680
3125
  width = _value$options.width,
3681
3126
  height = _value$options.height,
@@ -3684,25 +3129,25 @@
3684
3129
  cx = _value$options.cx,
3685
3130
  cy = _value$options.cy,
3686
3131
  size = _value$options.size;
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
+ 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) {
3688
3133
  var offset = _ref.offset,
3689
3134
  color = _ref.color;
3690
- return "".concat(offset).concat(color);
3691
- }).join('-'));
3135
+ return "" + offset + color;
3136
+ }).join('-');
3692
3137
  }
3693
3138
  } else if (gLite.isPattern(src)) {
3694
3139
  if (isString(src.image)) {
3695
- cacheKey = "pattern-".concat(src.image, "-").concat(src.repetition);
3140
+ cacheKey = "pattern-" + src.image + "-" + src.repetition;
3696
3141
  } else if (src.image.nodeName === 'rect') {
3697
3142
  // use rect's entity as key
3698
- cacheKey = "pattern-rect-".concat(src.image.entity);
3143
+ cacheKey = "pattern-rect-" + src.image.entity;
3699
3144
  } else {
3700
- cacheKey = "pattern-".concat(counter);
3145
+ cacheKey = "pattern-" + counter;
3701
3146
  }
3702
3147
  }
3703
3148
  if (cacheKey) {
3704
3149
  if (!cacheKey2IDMap[cacheKey]) {
3705
- cacheKey2IDMap[cacheKey] = PATTERN_PREFIX + "".concat(counter++);
3150
+ cacheKey2IDMap[cacheKey] = PATTERN_PREFIX + ("" + counter++);
3706
3151
  }
3707
3152
  }
3708
3153
  return cacheKey2IDMap[cacheKey];
@@ -3714,56 +3159,55 @@
3714
3159
  var t = parsed.t,
3715
3160
  d = parsed.d;
3716
3161
  if (t === 'translate') {
3717
- return "translate(".concat(d[0].value, " ").concat(d[1].value, ")");
3162
+ return "translate(" + d[0].value + " " + d[1].value + ")";
3718
3163
  } else if (t === 'translatex') {
3719
- return "translate(".concat(d[0].value, " 0)");
3164
+ return "translate(" + d[0].value + " 0)";
3720
3165
  } else if (t === 'translatey') {
3721
- return "translate(0 ".concat(d[0].value, ")");
3166
+ return "translate(0 " + d[0].value + ")";
3722
3167
  } else if (t === 'rotate') {
3723
- return "rotate(".concat(d[0].value, ")");
3168
+ return "rotate(" + d[0].value + ")";
3724
3169
  } else if (t === 'scale') {
3725
3170
  // scale(1) scale(1, 1)
3726
3171
  var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) {
3727
3172
  return s.value;
3728
3173
  })) || [1, 1];
3729
- return "scale(".concat(newScale[0], ", ").concat(newScale[1], ")");
3174
+ return "scale(" + newScale[0] + ", " + newScale[1] + ")";
3730
3175
  } else if (t === 'scalex') {
3731
3176
  var _newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) {
3732
3177
  return s.value;
3733
3178
  })) || [1];
3734
- return "scale(".concat(_newScale[0], ", 1)");
3179
+ return "scale(" + _newScale[0] + ", 1)";
3735
3180
  } else if (t === 'scaley') {
3736
3181
  var _newScale2 = (d === null || d === void 0 ? void 0 : d.map(function (s) {
3737
3182
  return s.value;
3738
3183
  })) || [1];
3739
- return "scale(1, ".concat(_newScale2[0], ")");
3184
+ return "scale(1, " + _newScale2[0] + ")";
3740
3185
  } else if (t === 'skew') {
3741
3186
  var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) {
3742
3187
  return s.value;
3743
3188
  })) || [0, 0];
3744
- return "skewX(".concat(newSkew[0], ") skewY(").concat(newSkew[1], ")");
3189
+ return "skewX(" + newSkew[0] + ") skewY(" + newSkew[1] + ")";
3745
3190
  } else if (t === 'skewx') {
3746
3191
  var _newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) {
3747
3192
  return s.value;
3748
3193
  })) || [0];
3749
- return "skewX(".concat(_newSkew[0], ")");
3194
+ return "skewX(" + _newSkew[0] + ")";
3750
3195
  } else if (t === 'skewy') {
3751
3196
  var _newSkew2 = (d === null || d === void 0 ? void 0 : d.map(function (s) {
3752
3197
  return s.value;
3753
3198
  })) || [0];
3754
- return "skewY(".concat(_newSkew2[0], ")");
3199
+ return "skewY(" + _newSkew2[0] + ")";
3755
3200
  } else if (t === 'matrix') {
3756
3201
  var _d$map = d.map(function (s) {
3757
3202
  return s.value;
3758
3203
  }),
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, ")");
3204
+ a = _d$map[0],
3205
+ b = _d$map[1],
3206
+ c = _d$map[2],
3207
+ dd = _d$map[3],
3208
+ tx = _d$map[4],
3209
+ ty = _d$map[5];
3210
+ return "matrix(" + a + " " + b + " " + c + " " + dd + " " + tx + " " + ty + ")";
3767
3211
  }
3768
3212
  }).join(' ');
3769
3213
  }
@@ -3794,13 +3238,13 @@
3794
3238
  patternWidth = halfExtents[0] * 2;
3795
3239
  patternHeight = halfExtents[1] * 2;
3796
3240
  }
3797
- $pattern.setAttribute('width', "".concat(patternWidth));
3798
- $pattern.setAttribute('height', "".concat(patternHeight));
3241
+ $pattern.setAttribute('width', "" + patternWidth);
3242
+ $pattern.setAttribute('height', "" + patternHeight);
3799
3243
  return $pattern;
3800
3244
  }
3801
3245
  function createOrUpdatePattern(document, $def, object, pattern, createImage, plugin) {
3802
3246
  var patternId = generateCacheKey(pattern);
3803
- var $existed = $def.querySelector("#".concat(patternId));
3247
+ var $existed = $def.querySelector("#" + patternId);
3804
3248
  if (!$existed) {
3805
3249
  var image = pattern.image;
3806
3250
  var imageURL = '';
@@ -3837,8 +3281,8 @@
3837
3281
  $pattern.appendChild($image);
3838
3282
  $image.setAttribute('x', '0');
3839
3283
  $image.setAttribute('y', '0');
3840
- $image.setAttribute('width', "".concat(img.width));
3841
- $image.setAttribute('height', "".concat(img.height));
3284
+ $image.setAttribute('width', "" + img.width);
3285
+ $image.setAttribute('height', "" + img.height);
3842
3286
  };
3843
3287
  if (img.complete) {
3844
3288
  onload();
@@ -3879,7 +3323,7 @@
3879
3323
  width: width,
3880
3324
  height: height
3881
3325
  });
3882
- var $existed = $def.querySelector("#".concat(gradientId));
3326
+ var $existed = $def.querySelector("#" + gradientId);
3883
3327
  if (!$existed) {
3884
3328
  // <linearGradient> <radialGradient>
3885
3329
  // @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/linearGradient
@@ -3897,7 +3341,7 @@
3897
3341
  var offset = _ref2.offset,
3898
3342
  color = _ref2.color;
3899
3343
  // TODO: support absolute unit like `px`
3900
- innerHTML += "<stop offset=\"".concat(offset.value / 100, "\" stop-color=\"").concat(color, "\"></stop>");
3344
+ innerHTML += "<stop offset=\"" + offset.value / 100 + "\" stop-color=\"" + color + "\"></stop>";
3901
3345
  });
3902
3346
  $existed.innerHTML = innerHTML;
3903
3347
  $existed.id = gradientId;
@@ -3910,10 +3354,10 @@
3910
3354
  y1 = _computeLinearGradien.y1,
3911
3355
  x2 = _computeLinearGradien.x2,
3912
3356
  y2 = _computeLinearGradien.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));
3357
+ $existed.setAttribute('x1', "" + x1);
3358
+ $existed.setAttribute('y1', "" + y1);
3359
+ $existed.setAttribute('x2', "" + x2);
3360
+ $existed.setAttribute('y2', "" + y2);
3917
3361
  // $existed.setAttribute('gradientTransform', `rotate(${angle})`);
3918
3362
  } else {
3919
3363
  var _parsedColor$value = parsedColor.value,
@@ -3924,15 +3368,15 @@
3924
3368
  x = _computeRadialGradien.x,
3925
3369
  y = _computeRadialGradien.y,
3926
3370
  r = _computeRadialGradien.r;
3927
- $existed.setAttribute('cx', "".concat(x));
3928
- $existed.setAttribute('cy', "".concat(y));
3929
- $existed.setAttribute('r', "".concat(r));
3371
+ $existed.setAttribute('cx', "" + x);
3372
+ $existed.setAttribute('cy', "" + y);
3373
+ $existed.setAttribute('r', "" + r);
3930
3374
  }
3931
3375
  return gradientId;
3932
3376
  }
3933
3377
  function createOrUpdateMultiGradient(document, object, $def, $el, gradients) {
3934
3378
  var filterId = FILTER_PREFIX + object.entity + '-gradient';
3935
- var $existed = $def.querySelector("#".concat(filterId));
3379
+ var $existed = $def.querySelector("#" + filterId);
3936
3380
  if (!$existed) {
3937
3381
  $existed = createSVGElement('filter', document);
3938
3382
  $existed.setAttribute('filterUnits', 'userSpaceOnUse');
@@ -3962,25 +3406,25 @@
3962
3406
  $rect.setAttribute('y', '0');
3963
3407
  $rect.setAttribute('width', '100%');
3964
3408
  $rect.setAttribute('height', '100%');
3965
- $rect.setAttribute('fill', "url(#".concat(gradientId, ")"));
3409
+ $rect.setAttribute('fill', "url(#" + gradientId + ")");
3966
3410
  $rect.id = rectId;
3967
3411
  $def.appendChild($rect);
3968
3412
  var $feImage = createSVGElement('feImage', document);
3969
- $feImage.setAttribute('href', "#".concat(rectId));
3970
- $feImage.setAttribute('result', "".concat(filterId, "-").concat(i));
3413
+ $feImage.setAttribute('href', "#" + rectId);
3414
+ $feImage.setAttribute('result', filterId + "-" + i);
3971
3415
  $existed.appendChild($feImage);
3972
3416
  if (i > 0) {
3973
3417
  var $feBlend = createSVGElement('feBlend', document);
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++));
3418
+ $feBlend.setAttribute('in', i === 1 ? filterId + "-" + (i - 1) : filterId + "-blended-" + (blended - 1));
3419
+ $feBlend.setAttribute('in2', filterId + "-" + i);
3420
+ $feBlend.setAttribute('result', filterId + "-blended-" + blended++);
3977
3421
  // @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/blend-mode
3978
3422
  $feBlend.setAttribute('mode', 'multiply');
3979
3423
  $existed.appendChild($feBlend);
3980
3424
  }
3981
3425
  });
3982
3426
  var $feComposite = createSVGElement('feComposite', document);
3983
- $feComposite.setAttribute('in', "".concat(filterId, "-blended-").concat(blended));
3427
+ $feComposite.setAttribute('in', filterId + "-blended-" + blended);
3984
3428
  $feComposite.setAttribute('in2', 'SourceGraphic');
3985
3429
  $feComposite.setAttribute('operator', 'in');
3986
3430
  $existed.appendChild($feComposite);
@@ -4000,7 +3444,7 @@
4000
3444
  shadowOffsetY = _object$parsedStyle.shadowOffsetY;
4001
3445
  var hasShadow = !isNil(shadowColor) && shadowBlur > 0;
4002
3446
  var shadowId = FILTER_DROPSHADOW_PREFIX + object.entity;
4003
- var $existedFilter = $def.querySelector("#".concat(shadowId));
3447
+ var $existedFilter = $def.querySelector("#" + shadowId);
4004
3448
  if ($existedFilter) {
4005
3449
  var existedShadowType = $existedFilter.getAttribute('data-type');
4006
3450
  if (existedShadowType !== shadowType || !hasShadow) {
@@ -4014,7 +3458,7 @@
4014
3458
  if (hasShadow) {
4015
3459
  // use filter <feDropShadow>
4016
3460
  // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow
4017
- $el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#".concat(shadowId, ")"));
3461
+ $el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + shadowId + ")");
4018
3462
  } else {
4019
3463
  $el === null || $el === void 0 ? void 0 : $el.removeAttribute('filter');
4020
3464
  return;
@@ -4024,9 +3468,9 @@
4024
3468
  $existedFilter.setAttribute('data-type', shadowType);
4025
3469
  if (shadowType === 'outer') {
4026
3470
  var $feDropShadow = createSVGElement('feDropShadow', document);
4027
- $feDropShadow.setAttribute('dx', "".concat((shadowOffsetX || 0) / 2));
4028
- $feDropShadow.setAttribute('dy', "".concat((shadowOffsetY || 0) / 2));
4029
- $feDropShadow.setAttribute('stdDeviation', "".concat((shadowBlur || 0) / 4));
3471
+ $feDropShadow.setAttribute('dx', "" + (shadowOffsetX || 0) / 2);
3472
+ $feDropShadow.setAttribute('dy', "" + (shadowOffsetY || 0) / 2);
3473
+ $feDropShadow.setAttribute('stdDeviation', "" + (shadowBlur || 0) / 4);
4030
3474
  $feDropShadow.setAttribute('flood-color', shadowColor.toString());
4031
3475
  $existedFilter.appendChild($feDropShadow);
4032
3476
  } else if (shadowType === 'inner') {
@@ -4038,11 +3482,11 @@
4038
3482
  $feComponentTransfer.appendChild($feFuncA);
4039
3483
  $existedFilter.appendChild($feComponentTransfer);
4040
3484
  var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
4041
- $feGaussianBlur.setAttribute('stdDeviation', "".concat((shadowBlur || 0) / 4));
3485
+ $feGaussianBlur.setAttribute('stdDeviation', "" + (shadowBlur || 0) / 4);
4042
3486
  $existedFilter.appendChild($feGaussianBlur);
4043
3487
  var $feOffset = createSVGElement('feOffset', document);
4044
- $feOffset.setAttribute('dx', "".concat((shadowOffsetX || 0) / 2));
4045
- $feOffset.setAttribute('dy', "".concat((shadowOffsetY || 0) / 2));
3488
+ $feOffset.setAttribute('dx', "" + (shadowOffsetX || 0) / 2);
3489
+ $feOffset.setAttribute('dy', "" + (shadowOffsetY || 0) / 2);
4046
3490
  $feOffset.setAttribute('result', 'offsetblur');
4047
3491
  $existedFilter.appendChild($feOffset);
4048
3492
  var $feFlood = createSVGElement('feFlood', document);
@@ -4081,11 +3525,11 @@
4081
3525
  // half the blur radius
4082
3526
  // @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
4083
3527
  // @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
4084
- _$feGaussianBlur.setAttribute('stdDeviation', "".concat((shadowBlur || 0) / 4));
3528
+ _$feGaussianBlur.setAttribute('stdDeviation', "" + (shadowBlur || 0) / 4);
4085
3529
  } else if (name === 'shadowOffsetX') {
4086
- _$feOffset.setAttribute('dx', "".concat((shadowOffsetX || 0) / 2));
3530
+ _$feOffset.setAttribute('dx', "" + (shadowOffsetX || 0) / 2);
4087
3531
  } else if (name === 'shadowOffsetY') {
4088
- _$feOffset.setAttribute('dy', "".concat((shadowOffsetY || 0) / 2));
3532
+ _$feOffset.setAttribute('dy', "" + (shadowOffsetY || 0) / 2);
4089
3533
  }
4090
3534
  } else if (shadowType === 'outer') {
4091
3535
  var _$feDropShadow = $existedFilter.children[0];
@@ -4095,18 +3539,17 @@
4095
3539
  // half the blur radius
4096
3540
  // @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
4097
3541
  // @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
4098
- _$feDropShadow.setAttribute('stdDeviation', "".concat((shadowBlur || 0) / 4));
3542
+ _$feDropShadow.setAttribute('stdDeviation', "" + (shadowBlur || 0) / 4);
4099
3543
  } else if (name === 'shadowOffsetX') {
4100
- _$feDropShadow.setAttribute('dx', "".concat((shadowOffsetX || 0) / 2));
3544
+ _$feDropShadow.setAttribute('dx', "" + (shadowOffsetX || 0) / 2);
4101
3545
  } else if (name === 'shadowOffsetY') {
4102
- _$feDropShadow.setAttribute('dy', "".concat((shadowOffsetY || 0) / 2));
3546
+ _$feDropShadow.setAttribute('dy', "" + (shadowOffsetY || 0) / 2);
4103
3547
  }
4104
3548
  }
4105
3549
  }
4106
3550
  var urlRegexp = /url\("?#(.*)\)/;
4107
3551
  var DefElementManager = /*#__PURE__*/function () {
4108
3552
  function DefElementManager(context) {
4109
- _classCallCheck$3(this, DefElementManager);
4110
3553
  this.context = void 0;
4111
3554
  /**
4112
3555
  * container for <gradient> <clipPath>...
@@ -4115,124 +3558,106 @@
4115
3558
  this.gradientCache = {};
4116
3559
  this.context = context;
4117
3560
  }
4118
- _createClass$3(DefElementManager, [{
4119
- key: "getDefElement",
4120
- value: function getDefElement() {
4121
- return this.$def;
4122
- }
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
- }
3561
+ var _proto = DefElementManager.prototype;
3562
+ _proto.getDefElement = function getDefElement() {
3563
+ return this.$def;
3564
+ };
3565
+ _proto.init = function init() {
3566
+ var document = this.context.config.document;
3567
+ var $svg = this.context.contextService.getContext();
3568
+ this.$def = createSVGElement('defs', document);
3569
+ $svg.appendChild(this.$def);
3570
+ };
3571
+ _proto.clear = function clear(entity) {
3572
+ var _this = this;
3573
+ Object.keys(this.gradientCache).forEach(function (id) {
3574
+ _this.clearUnusedDefElement(_this.gradientCache, id, entity);
3575
+ });
3576
+ };
3577
+ _proto.clearUnusedDefElement = function clearUnusedDefElement(cache, id, entity) {
3578
+ if (cache[id] && cache[id].size === 1 && cache[id].has(entity)) {
3579
+ var targetElement = this.$def.querySelector("#" + id);
3580
+ if (targetElement) {
3581
+ this.$def.removeChild(targetElement);
4147
3582
  }
4148
3583
  }
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);
3584
+ };
3585
+ _proto.createOrUpdateGradientAndPattern = function createOrUpdateGradientAndPattern$1(object, $el, parsedColor, name, plugin) {
3586
+ var _this$context$config = this.context.config,
3587
+ doc = _this$context$config.document,
3588
+ createImage = _this$context$config.createImage;
3589
+ if ($el) {
3590
+ var attributeValue = '';
3591
+ if (gLite.isPattern(parsedColor)) {
3592
+ // `fill: url(#${patternId})`
3593
+ attributeValue = $el.style[name];
3594
+ } else {
3595
+ // `url(#${gradientId})`
3596
+ attributeValue = $el.getAttribute(name) || '';
3597
+ }
3598
+ var matches = attributeValue.match(urlRegexp);
3599
+ if (matches && matches.length > 1) {
3600
+ this.clearUnusedDefElement(this.gradientCache, matches[1].replace('"', ''), object.entity);
3601
+ }
3602
+ var newDefElementId = createOrUpdateGradientAndPattern(doc || document, this.$def, object, $el, parsedColor, name, createImage, plugin);
3603
+ if (newDefElementId) {
3604
+ if (!this.gradientCache[newDefElementId]) {
3605
+ this.gradientCache[newDefElementId] = new Set();
4174
3606
  }
3607
+ this.gradientCache[newDefElementId].add(object.entity);
4175
3608
  }
4176
3609
  }
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
- }]);
3610
+ };
3611
+ _proto.createOrUpdateShadow = function createOrUpdateShadow$1(object, $el, name) {
3612
+ var doc = this.context.config.document;
3613
+ createOrUpdateShadow(doc || document, this.$def, object, $el, name);
3614
+ };
3615
+ _proto.createOrUpdateFilter = function createOrUpdateFilter$1(object, $el, filters) {
3616
+ var doc = this.context.config.document;
3617
+ createOrUpdateFilter(doc || document, this.$def, object, $el, filters);
3618
+ };
4190
3619
  return DefElementManager;
4191
3620
  }();
4192
3621
  var Plugin$2 = /*#__PURE__*/function (_AbstractRendererPlug) {
4193
- _inherits$3(Plugin, _AbstractRendererPlug);
4194
- var _super = _createSuper$3(Plugin);
4195
- function Plugin() {
3622
+ _inheritsLoose$3(Plugin, _AbstractRendererPlug);
3623
+ function Plugin(options) {
4196
3624
  var _this;
4197
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4198
- _classCallCheck$3(this, Plugin);
4199
- _this = _super.call(this);
3625
+ if (options === void 0) {
3626
+ options = {};
3627
+ }
3628
+ _this = _AbstractRendererPlug.call(this) || this;
4200
3629
  _this.options = void 0;
4201
3630
  _this.name = 'svg-renderer';
4202
3631
  _this.options = options;
4203
3632
  return _this;
4204
3633
  }
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
- }]);
3634
+ var _proto = Plugin.prototype;
3635
+ _proto.init = function init() {
3636
+ var _this$options = this.options,
3637
+ outputSVGElementId = _this$options.outputSVGElementId,
3638
+ outputSVGElementName = _this$options.outputSVGElementName;
3639
+ var defElementManager = new DefElementManager(this.context);
3640
+ // default implementation
3641
+ var defaultElementLifeCycleContribution = new DefaultElementLifeCycleContribution(this.context);
3642
+ // @ts-ignore
3643
+ this.context.defaultElementLifeCycleContribution = defaultElementLifeCycleContribution;
3644
+ // @ts-ignore
3645
+ this.context.SVGElementLifeCycleContribution = defaultElementLifeCycleContribution;
3646
+ var SVGRendererPluginOptions = {
3647
+ outputSVGElementId: !isNil(outputSVGElementId) ? !!outputSVGElementId : true,
3648
+ outputSVGElementName: !isNil(outputSVGElementName) ? !!outputSVGElementName : true
3649
+ };
3650
+ this.addRenderingPlugin(
3651
+ // @ts-ignore
3652
+ new SVGRendererPlugin(SVGRendererPluginOptions, defElementManager, this.context));
3653
+ };
3654
+ _proto.destroy = function destroy() {
3655
+ this.removeAllRenderingPlugins();
3656
+ // @ts-ignore
3657
+ delete this.context.defaultElementLifeCycleContribution;
3658
+ // @ts-ignore
3659
+ delete this.context.SVGElementLifeCycleContribution;
3660
+ };
4236
3661
  return Plugin;
4237
3662
  }(gLite.AbstractRendererPlugin);
4238
3663
 
@@ -4264,7 +3689,6 @@
4264
3689
  _excluded4 = ["offset", "composite", "computedOffset", "easing", "transformOrigin"];
4265
3690
  var SVGContextService = /*#__PURE__*/function () {
4266
3691
  function SVGContextService(context) {
4267
- _classCallCheck(this, SVGContextService);
4268
3692
  this.context = void 0;
4269
3693
  this.$container = void 0;
4270
3694
  this.$namespace = void 0;
@@ -4273,273 +3697,245 @@
4273
3697
  this.context = context;
4274
3698
  this.canvasConfig = context.config;
4275
3699
  }
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;
3700
+ var _proto = SVGContextService.prototype;
3701
+ _proto.init = /*#__PURE__*/function () {
3702
+ var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
3703
+ var _this$canvasConfig, container, doc, devicePixelRatio, $namespace, dpr;
3704
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
3705
+ while (1) switch (_context.prev = _context.next) {
3706
+ case 0:
3707
+ _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document, devicePixelRatio = _this$canvasConfig.devicePixelRatio; // create container
3708
+ this.$container = isString(container) ? (doc || document).getElementById(container) : container;
3709
+ if (this.$container) {
3710
+ if (!this.$container.style.position) {
3711
+ this.$container.style.position = 'relative';
4295
3712
  }
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;
4315
- }
4316
- }, {
4317
- key: "getContext",
4318
- value: function getContext() {
4319
- return this.$namespace;
4320
- }
4321
- }, {
4322
- key: "getDPR",
4323
- value: function getDPR() {
4324
- return this.dpr;
4325
- }
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
- }
3713
+ $namespace = createSVGElement('svg', doc);
3714
+ $namespace.setAttribute('width', "" + this.canvasConfig.width);
3715
+ $namespace.setAttribute('height', "" + this.canvasConfig.height);
3716
+ this.$container.appendChild($namespace);
3717
+ this.$namespace = $namespace;
3718
+ }
3719
+ // use user-defined dpr first
3720
+ dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
3721
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
3722
+ this.dpr = dpr;
3723
+ case 6:
3724
+ case "end":
3725
+ return _context.stop();
3726
+ }
3727
+ }, _callee, this);
3728
+ }));
3729
+ function init() {
3730
+ return _init.apply(this, arguments);
3731
+ }
3732
+ return init;
3733
+ }() // @ts-ignore
3734
+ ;
3735
+ _proto.getDomElement = function getDomElement() {
3736
+ return this.$namespace;
3737
+ };
3738
+ _proto.getContext = function getContext() {
3739
+ return this.$namespace;
3740
+ };
3741
+ _proto.getDPR = function getDPR() {
3742
+ return this.dpr;
3743
+ };
3744
+ _proto.getBoundingClientRect = function getBoundingClientRect() {
3745
+ var _this$$namespace;
3746
+ return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
3747
+ };
3748
+ _proto.destroy = function destroy() {
3749
+ // destroy context
3750
+ if (this.$container && this.$namespace && this.$namespace.parentNode) {
3751
+ this.$container.removeChild(this.$namespace);
4348
3752
  }
4349
- }, {
4350
- key: "applyCursorStyle",
4351
- value: function applyCursorStyle(cursor) {
4352
- if (this.$container) {
4353
- this.$container.style.cursor = cursor;
4354
- }
3753
+ };
3754
+ _proto.resize = function resize(width, height) {
3755
+ // SVG should ignore DPR
3756
+ if (this.$namespace) {
3757
+ this.$namespace.setAttribute('width', "" + width);
3758
+ this.$namespace.setAttribute('height', "" + height);
4355
3759
  }
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, ";}");
3760
+ };
3761
+ _proto.applyCursorStyle = function applyCursorStyle(cursor) {
3762
+ if (this.$container) {
3763
+ this.$container.style.cursor = cursor;
4377
3764
  }
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
- }
4434
- });
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;
4455
- });
4456
- groupCssText += _this.generateCSSText("a".concat(animationCounter++), groupSelector, keyframesWithGroup, animation.effect.getComputedTiming(), {
4457
- transform: svgElement.$groupEl.getAttribute('transform')
4458
- });
3765
+ };
3766
+ _proto.generateCSSText = function generateCSSText(animationName, selector, keyframes, timing, prefixes) {
3767
+ if (prefixes === void 0) {
3768
+ prefixes = {};
3769
+ }
3770
+ var duration = timing.duration,
3771
+ easing = timing.easing,
3772
+ delay = timing.delay,
3773
+ direction = timing.direction,
3774
+ iterations = timing.iterations,
3775
+ fill = timing.fill;
3776
+ return "@keyframes " + animationName + "{" + keyframes.map(function (keyframe) {
3777
+ var offset = keyframe.offset,
3778
+ composite = keyframe.composite,
3779
+ computedOffset = keyframe.computedOffset,
3780
+ easing = keyframe.easing,
3781
+ rest = _objectWithoutPropertiesLoose(keyframe, _excluded);
3782
+ var rules = Object.keys(rest).map(function (attributeName) {
3783
+ return attributeName + ":" + (prefixes[attributeName] || '') + rest[attributeName] + ";";
3784
+ }).join('');
3785
+ return computedOffset * 100 + "%{" + rules + "}";
3786
+ }).join('') + "}" + (selector + " {animation: " + animationName + " " + duration + "ms " + easing + " " + delay + "ms " + (iterations === Infinity ? 'infinite' : iterations) + " " + direction + " " + fill + ";}");
3787
+ };
3788
+ _proto.toDataURL = /*#__PURE__*/function () {
3789
+ var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
3790
+ var _this = this;
3791
+ var cloneNode, doc, animationCounter, $style, svgDocType, svgDoc;
3792
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3793
+ while (1) switch (_context2.prev = _context2.next) {
3794
+ case 0:
3795
+ cloneNode = this.$namespace.cloneNode(true);
3796
+ doc = this.canvasConfig.document;
3797
+ animationCounter = 0;
3798
+ $style = null;
3799
+ this.context.renderingContext.root.forEach(function (object) {
3800
+ var animations = object.getAnimations();
3801
+ if (animations.length) {
3802
+ if (!$style) {
3803
+ // export animations to <style>, using CSS Transformation
3804
+ $style = (doc || document).createElement('style');
3805
+ cloneNode.appendChild($style);
3806
+ }
3807
+ // @ts-ignore
3808
+ var svgElement = object.elementSVG;
3809
+ var selfSelector = "#" + svgElement.$el.id;
3810
+ var groupSelector = "#" + svgElement.$groupEl.id;
3811
+ var selfCssText = '';
3812
+ var groupCssText = '';
3813
+ animations.forEach(function (animation) {
3814
+ var keyframes = animation.effect.getKeyframes();
3815
+ // split attributes into self and group
3816
+ if (keyframes.length) {
3817
+ var selfAttributes = [];
3818
+ var groupAttributes = [];
3819
+ var _keyframes$ = keyframes[0],
3820
+ offset = _keyframes$.offset,
3821
+ composite = _keyframes$.composite,
3822
+ computedOffset = _keyframes$.computedOffset,
3823
+ easing = _keyframes$.easing,
3824
+ transformOrigin = _keyframes$.transformOrigin,
3825
+ rest = _objectWithoutPropertiesLoose(_keyframes$, _excluded2);
3826
+ Object.keys(rest).forEach(function (attributeName) {
3827
+ var _propertyMetadataCach;
3828
+ if (attributeName === 'transform') {
3829
+ groupAttributes.push(attributeName);
4459
3830
  }
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());
3831
+ var inherited = !!((_propertyMetadataCach = gLite.propertyMetadataCache[attributeName]) === null || _propertyMetadataCach === void 0 ? void 0 : _propertyMetadataCach.inh);
3832
+ if (inherited) {
3833
+ groupAttributes.push(attributeName);
3834
+ } else if (attributeName !== 'transform') {
3835
+ selfAttributes.push(attributeName);
4482
3836
  }
3837
+ });
3838
+ if (groupAttributes.length) {
3839
+ var keyframesWithGroup = keyframes.map(function (keyframe) {
3840
+ var offset = keyframe.offset,
3841
+ composite = keyframe.composite,
3842
+ computedOffset = keyframe.computedOffset,
3843
+ easing = keyframe.easing,
3844
+ transformOrigin = keyframe.transformOrigin,
3845
+ rest = _objectWithoutPropertiesLoose(keyframe, _excluded3);
3846
+ var ret = {
3847
+ offset: offset,
3848
+ composite: composite,
3849
+ computedOffset: computedOffset,
3850
+ easing: easing
3851
+ };
3852
+ Object.keys(rest).forEach(function (attributeName) {
3853
+ if (groupAttributes.includes(attributeName)) {
3854
+ ret[attributeName] = keyframe[attributeName];
3855
+ }
3856
+ });
3857
+ return ret;
3858
+ });
3859
+ groupCssText += _this.generateCSSText("a" + animationCounter++, groupSelector, keyframesWithGroup, animation.effect.getComputedTiming(), {
3860
+ transform: svgElement.$groupEl.getAttribute('transform')
3861
+ });
4483
3862
  }
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
- }]);
3863
+ if (selfAttributes.length) {
3864
+ var keyframesWithSelf = keyframes.map(function (keyframe) {
3865
+ var offset = keyframe.offset,
3866
+ composite = keyframe.composite,
3867
+ computedOffset = keyframe.computedOffset,
3868
+ easing = keyframe.easing,
3869
+ transformOrigin = keyframe.transformOrigin,
3870
+ rest = _objectWithoutPropertiesLoose(keyframe, _excluded4);
3871
+ var ret = {
3872
+ offset: offset,
3873
+ composite: composite,
3874
+ computedOffset: computedOffset,
3875
+ easing: easing
3876
+ };
3877
+ Object.keys(rest).forEach(function (attributeName) {
3878
+ if (selfAttributes.includes(attributeName)) {
3879
+ ret[attributeName] = keyframe[attributeName];
3880
+ }
3881
+ });
3882
+ return ret;
3883
+ });
3884
+ selfCssText += _this.generateCSSText("a" + animationCounter++, selfSelector, keyframesWithSelf, animation.effect.getComputedTiming());
3885
+ }
3886
+ }
3887
+ });
3888
+ $style.textContent += selfCssText + groupCssText;
3889
+ }
3890
+ });
3891
+ svgDocType = document.implementation.createDocumentType('svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
3892
+ svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', svgDocType);
3893
+ svgDoc.replaceChild(cloneNode, svgDoc.documentElement);
3894
+ return _context2.abrupt("return", "data:image/svg+xml;charset=utf8," + encodeURIComponent(new XMLSerializer().serializeToString(svgDoc)));
3895
+ case 10:
3896
+ case "end":
3897
+ return _context2.stop();
3898
+ }
3899
+ }, _callee2, this);
3900
+ }));
3901
+ function toDataURL(_x) {
3902
+ return _toDataURL.apply(this, arguments);
3903
+ }
3904
+ return toDataURL;
3905
+ }();
4504
3906
  return SVGContextService;
4505
3907
  }();
4506
3908
 
4507
3909
  var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
4508
- _inherits(ContextRegisterPlugin, _AbstractRendererPlug);
4509
- var _super = _createSuper(ContextRegisterPlugin);
3910
+ _inheritsLoose(ContextRegisterPlugin, _AbstractRendererPlug);
4510
3911
  function ContextRegisterPlugin() {
4511
3912
  var _this;
4512
- _classCallCheck(this, ContextRegisterPlugin);
4513
3913
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4514
3914
  args[_key] = arguments[_key];
4515
3915
  }
4516
- _this = _super.call.apply(_super, [this].concat(args));
3916
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
4517
3917
  _this.name = 'svg-context-register';
4518
3918
  return _this;
4519
3919
  }
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
- }]);
3920
+ var _proto = ContextRegisterPlugin.prototype;
3921
+ _proto.init = function init() {
3922
+ // @ts-ignore
3923
+ this.context.ContextService = SVGContextService;
3924
+ };
3925
+ _proto.destroy = function destroy() {
3926
+ delete this.context.ContextService;
3927
+ };
4532
3928
  return ContextRegisterPlugin;
4533
3929
  }(gLite.AbstractRendererPlugin);
4534
3930
 
4535
3931
  var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
4536
- _inherits(Renderer, _AbstractRenderer);
4537
- var _super = _createSuper(Renderer);
4538
- function Renderer() {
3932
+ _inheritsLoose(Renderer, _AbstractRenderer);
3933
+ function Renderer(config) {
4539
3934
  var _this;
4540
- var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4541
- _classCallCheck(this, Renderer);
4542
- _this = _super.call(this, config);
3935
+ if (config === void 0) {
3936
+ config = {};
3937
+ }
3938
+ _this = _AbstractRenderer.call(this, config) || this;
4543
3939
  _this.registerPlugin(new ContextRegisterPlugin());
4544
3940
  _this.registerPlugin(new Plugin$2({
4545
3941
  outputSVGElementId: config.outputSVGElementId
@@ -4548,7 +3944,7 @@
4548
3944
  _this.registerPlugin(new Plugin$1());
4549
3945
  return _this;
4550
3946
  }
4551
- return _createClass(Renderer);
3947
+ return Renderer;
4552
3948
  }(gLite.AbstractRenderer);
4553
3949
 
4554
3950
  exports.DomInteraction = index_esm;