@antv/g-svg 1.2.1 → 1.2.2
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.esm.js +86 -197
- package/dist/index.js +86 -197
- package/dist/index.umd.js +1784 -2157
- package/dist/index.umd.min.js +5 -5
- package/package.json +5 -5
package/dist/index.umd.js
CHANGED
|
@@ -349,16 +349,6 @@
|
|
|
349
349
|
}, exports;
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
-
function _typeof(obj) {
|
|
353
|
-
"@babel/helpers - typeof";
|
|
354
|
-
|
|
355
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
356
|
-
return typeof obj;
|
|
357
|
-
} : function (obj) {
|
|
358
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
359
|
-
}, _typeof(obj);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
352
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
363
353
|
try {
|
|
364
354
|
var info = gen[key](arg);
|
|
@@ -395,54 +385,11 @@
|
|
|
395
385
|
};
|
|
396
386
|
}
|
|
397
387
|
|
|
398
|
-
function
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
function _defineProperties(target, props) {
|
|
405
|
-
for (var i = 0; i < props.length; i++) {
|
|
406
|
-
var descriptor = props[i];
|
|
407
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
408
|
-
descriptor.configurable = true;
|
|
409
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
410
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
415
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
416
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
417
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
418
|
-
writable: false
|
|
419
|
-
});
|
|
420
|
-
return Constructor;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
function _inherits(subClass, superClass) {
|
|
424
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
425
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
429
|
-
constructor: {
|
|
430
|
-
value: subClass,
|
|
431
|
-
writable: true,
|
|
432
|
-
configurable: true
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
Object.defineProperty(subClass, "prototype", {
|
|
436
|
-
writable: false
|
|
437
|
-
});
|
|
438
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
439
|
-
}
|
|
388
|
+
function _inheritsLoose(subClass, superClass) {
|
|
389
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
390
|
+
subClass.prototype.constructor = subClass;
|
|
440
391
|
|
|
441
|
-
|
|
442
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
443
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
444
|
-
};
|
|
445
|
-
return _getPrototypeOf(o);
|
|
392
|
+
_setPrototypeOf(subClass, superClass);
|
|
446
393
|
}
|
|
447
394
|
|
|
448
395
|
function _setPrototypeOf(o, p) {
|
|
@@ -453,56 +400,6 @@
|
|
|
453
400
|
return _setPrototypeOf(o, p);
|
|
454
401
|
}
|
|
455
402
|
|
|
456
|
-
function _isNativeReflectConstruct() {
|
|
457
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
458
|
-
if (Reflect.construct.sham) return false;
|
|
459
|
-
if (typeof Proxy === "function") return true;
|
|
460
|
-
|
|
461
|
-
try {
|
|
462
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
463
|
-
return true;
|
|
464
|
-
} catch (e) {
|
|
465
|
-
return false;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
function _assertThisInitialized(self) {
|
|
470
|
-
if (self === void 0) {
|
|
471
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
return self;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
function _possibleConstructorReturn(self, call) {
|
|
478
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
479
|
-
return call;
|
|
480
|
-
} else if (call !== void 0) {
|
|
481
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
return _assertThisInitialized(self);
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
function _createSuper(Derived) {
|
|
488
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
489
|
-
|
|
490
|
-
return function _createSuperInternal() {
|
|
491
|
-
var Super = _getPrototypeOf(Derived),
|
|
492
|
-
result;
|
|
493
|
-
|
|
494
|
-
if (hasNativeReflectConstruct) {
|
|
495
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
496
|
-
|
|
497
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
498
|
-
} else {
|
|
499
|
-
result = Super.apply(this, arguments);
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
return _possibleConstructorReturn(this, result);
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
|
|
506
403
|
/******************************************************************************
|
|
507
404
|
Copyright (c) Microsoft Corporation.
|
|
508
405
|
|
|
@@ -654,7 +551,7 @@
|
|
|
654
551
|
if ("throw" !== record.type) {
|
|
655
552
|
var result = record.arg,
|
|
656
553
|
value = result.value;
|
|
657
|
-
return value && "object" ==
|
|
554
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
658
555
|
invoke("next", value, resolve, reject);
|
|
659
556
|
}, function (err) {
|
|
660
557
|
invoke("throw", err, resolve, reject);
|
|
@@ -915,31 +812,6 @@
|
|
|
915
812
|
};
|
|
916
813
|
}
|
|
917
814
|
|
|
918
|
-
function _classCallCheck$1(instance, Constructor) {
|
|
919
|
-
if (!(instance instanceof Constructor)) {
|
|
920
|
-
throw new TypeError("Cannot call a class as a function");
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
function _defineProperties$1(target, props) {
|
|
925
|
-
for (var i = 0; i < props.length; i++) {
|
|
926
|
-
var descriptor = props[i];
|
|
927
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
928
|
-
descriptor.configurable = true;
|
|
929
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
930
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
function _createClass$1(Constructor, protoProps, staticProps) {
|
|
935
|
-
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
936
|
-
if (staticProps) _defineProperties$1(Constructor, staticProps);
|
|
937
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
938
|
-
writable: false
|
|
939
|
-
});
|
|
940
|
-
return Constructor;
|
|
941
|
-
}
|
|
942
|
-
|
|
943
815
|
var _class;
|
|
944
816
|
|
|
945
817
|
var DOMInteractionPlugin_1;
|
|
@@ -949,150 +821,147 @@
|
|
|
949
821
|
|
|
950
822
|
var DOMInteractionPlugin = DOMInteractionPlugin_1 = (_class = /*#__PURE__*/function () {
|
|
951
823
|
function DOMInteractionPlugin() {
|
|
952
|
-
_classCallCheck$1(this, DOMInteractionPlugin);
|
|
953
|
-
|
|
954
824
|
this.contextService = void 0;
|
|
955
825
|
this.renderingContext = void 0;
|
|
956
826
|
}
|
|
957
827
|
|
|
958
|
-
|
|
959
|
-
key: "apply",
|
|
960
|
-
value: function apply(renderingService) {
|
|
961
|
-
var _this = this;
|
|
962
|
-
|
|
963
|
-
var canvas = this.renderingContext.root.ownerDocument.defaultView; // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
|
|
828
|
+
var _proto = DOMInteractionPlugin.prototype;
|
|
964
829
|
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
};
|
|
830
|
+
_proto.apply = function apply(renderingService) {
|
|
831
|
+
var _this = this;
|
|
968
832
|
|
|
969
|
-
|
|
970
|
-
renderingService.hooks.pointerUp.call(ev);
|
|
971
|
-
};
|
|
833
|
+
var canvas = this.renderingContext.root.ownerDocument.defaultView; // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
|
|
972
834
|
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
835
|
+
var onPointerMove = function onPointerMove(ev) {
|
|
836
|
+
renderingService.hooks.pointerMove.call(ev);
|
|
837
|
+
};
|
|
976
838
|
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
839
|
+
var onPointerUp = function onPointerUp(ev) {
|
|
840
|
+
renderingService.hooks.pointerUp.call(ev);
|
|
841
|
+
};
|
|
980
842
|
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
843
|
+
var onPointerDown = function onPointerDown(ev) {
|
|
844
|
+
renderingService.hooks.pointerDown.call(ev);
|
|
845
|
+
};
|
|
984
846
|
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
847
|
+
var onPointerOver = function onPointerOver(ev) {
|
|
848
|
+
renderingService.hooks.pointerOver.call(ev);
|
|
849
|
+
};
|
|
988
850
|
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
851
|
+
var onPointerOut = function onPointerOut(ev) {
|
|
852
|
+
renderingService.hooks.pointerOut.call(ev);
|
|
853
|
+
};
|
|
992
854
|
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
$el.addEventListener('pointerleave', onPointerOut, true);
|
|
997
|
-
$el.addEventListener('pointerover', onPointerOver, true);
|
|
998
|
-
globalThis.addEventListener('pointerup', onPointerUp, true);
|
|
999
|
-
};
|
|
855
|
+
var onPointerCancel = function onPointerCancel(ev) {
|
|
856
|
+
renderingService.hooks.pointerCancel.call(ev);
|
|
857
|
+
};
|
|
1000
858
|
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
$el.addEventListener('touchmove', onPointerMove, true);
|
|
1005
|
-
$el.addEventListener('touchcancel', onPointerCancel, true);
|
|
1006
|
-
};
|
|
859
|
+
var onPointerWheel = function onPointerWheel(ev) {
|
|
860
|
+
renderingService.hooks.pointerWheel.call(ev);
|
|
861
|
+
};
|
|
1007
862
|
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
863
|
+
var addPointerEventListener = function addPointerEventListener($el) {
|
|
864
|
+
globalThis.document.addEventListener('pointermove', onPointerMove, true);
|
|
865
|
+
$el.addEventListener('pointerdown', onPointerDown, true);
|
|
866
|
+
$el.addEventListener('pointerleave', onPointerOut, true);
|
|
867
|
+
$el.addEventListener('pointerover', onPointerOver, true);
|
|
868
|
+
globalThis.addEventListener('pointerup', onPointerUp, true);
|
|
869
|
+
};
|
|
1015
870
|
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
};
|
|
871
|
+
var addTouchEventListener = function addTouchEventListener($el) {
|
|
872
|
+
$el.addEventListener('touchstart', onPointerDown, true);
|
|
873
|
+
$el.addEventListener('touchend', onPointerUp, true);
|
|
874
|
+
$el.addEventListener('touchmove', onPointerMove, true);
|
|
875
|
+
$el.addEventListener('touchcancel', onPointerCancel, true);
|
|
876
|
+
};
|
|
1023
877
|
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
878
|
+
var addMouseEventListener = function addMouseEventListener($el) {
|
|
879
|
+
globalThis.document.addEventListener('mousemove', onPointerMove, true);
|
|
880
|
+
$el.addEventListener('mousedown', onPointerDown, true);
|
|
881
|
+
$el.addEventListener('mouseout', onPointerOut, true);
|
|
882
|
+
$el.addEventListener('mouseover', onPointerOver, true);
|
|
883
|
+
globalThis.addEventListener('mouseup', onPointerUp, true);
|
|
884
|
+
};
|
|
1029
885
|
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
886
|
+
var removePointerEventListener = function removePointerEventListener($el) {
|
|
887
|
+
globalThis.document.removeEventListener('pointermove', onPointerMove, true);
|
|
888
|
+
$el.removeEventListener('pointerdown', onPointerDown, true);
|
|
889
|
+
$el.removeEventListener('pointerleave', onPointerOut, true);
|
|
890
|
+
$el.removeEventListener('pointerover', onPointerOver, true);
|
|
891
|
+
globalThis.removeEventListener('pointerup', onPointerUp, true);
|
|
892
|
+
};
|
|
1037
893
|
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
case 0:
|
|
1044
|
-
$el = _this.contextService.getDomElement(); // @ts-ignore
|
|
894
|
+
var removeTouchEventListener = function removeTouchEventListener($el) {
|
|
895
|
+
$el.removeEventListener('touchstart', onPointerDown, true);
|
|
896
|
+
$el.removeEventListener('touchend', onPointerUp, true);
|
|
897
|
+
$el.removeEventListener('touchmove', onPointerMove, true);
|
|
898
|
+
};
|
|
1045
899
|
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
900
|
+
var removeMouseEventListener = function removeMouseEventListener($el) {
|
|
901
|
+
globalThis.document.removeEventListener('mousemove', onPointerMove, true);
|
|
902
|
+
$el.removeEventListener('mousedown', onPointerDown, true);
|
|
903
|
+
$el.removeEventListener('mouseout', onPointerOut, true);
|
|
904
|
+
$el.removeEventListener('mouseover', onPointerOver, true);
|
|
905
|
+
globalThis.removeEventListener('mouseup', onPointerUp, true);
|
|
906
|
+
};
|
|
1049
907
|
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
908
|
+
renderingService.hooks.init.tapPromise(DOMInteractionPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
|
|
909
|
+
var $el;
|
|
910
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
911
|
+
while (1) {
|
|
912
|
+
switch (_context.prev = _context.next) {
|
|
913
|
+
case 0:
|
|
914
|
+
$el = _this.contextService.getDomElement(); // @ts-ignore
|
|
915
|
+
|
|
916
|
+
if (globalThis.navigator.msPointerEnabled) {
|
|
917
|
+
// @ts-ignore
|
|
918
|
+
$el.style.msContentZooming = 'none'; // @ts-ignore
|
|
919
|
+
|
|
920
|
+
$el.style.msTouchAction = 'none';
|
|
921
|
+
} else if (canvas.supportsPointerEvents) {
|
|
922
|
+
$el.style.touchAction = 'none';
|
|
923
|
+
}
|
|
1054
924
|
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
925
|
+
if (canvas.supportsPointerEvents) {
|
|
926
|
+
addPointerEventListener($el);
|
|
927
|
+
} else {
|
|
928
|
+
addMouseEventListener($el);
|
|
929
|
+
}
|
|
1060
930
|
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
931
|
+
if (canvas.supportsTouchEvents) {
|
|
932
|
+
addTouchEventListener($el);
|
|
933
|
+
} // use passive event listeners
|
|
934
|
+
// @see https://zhuanlan.zhihu.com/p/24555031
|
|
1065
935
|
|
|
1066
936
|
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
937
|
+
$el.addEventListener('wheel', onPointerWheel, {
|
|
938
|
+
passive: true,
|
|
939
|
+
capture: true
|
|
940
|
+
});
|
|
1071
941
|
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
}
|
|
942
|
+
case 5:
|
|
943
|
+
case "end":
|
|
944
|
+
return _context.stop();
|
|
1076
945
|
}
|
|
1077
|
-
}, _callee);
|
|
1078
|
-
})));
|
|
1079
|
-
renderingService.hooks.destroy.tap(DOMInteractionPlugin_1.tag, function () {
|
|
1080
|
-
var $el = _this.contextService.getDomElement();
|
|
1081
|
-
|
|
1082
|
-
if (canvas.supportsPointerEvents) {
|
|
1083
|
-
removePointerEventListener($el);
|
|
1084
|
-
} else {
|
|
1085
|
-
removeMouseEventListener($el);
|
|
1086
946
|
}
|
|
947
|
+
}, _callee);
|
|
948
|
+
})));
|
|
949
|
+
renderingService.hooks.destroy.tap(DOMInteractionPlugin_1.tag, function () {
|
|
950
|
+
var $el = _this.contextService.getDomElement();
|
|
1087
951
|
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
952
|
+
if (canvas.supportsPointerEvents) {
|
|
953
|
+
removePointerEventListener($el);
|
|
954
|
+
} else {
|
|
955
|
+
removeMouseEventListener($el);
|
|
956
|
+
}
|
|
1091
957
|
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
958
|
+
if (canvas.supportsTouchEvents) {
|
|
959
|
+
removeTouchEventListener($el);
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
$el.removeEventListener('wheel', onPointerWheel, true);
|
|
963
|
+
});
|
|
964
|
+
};
|
|
1096
965
|
|
|
1097
966
|
return DOMInteractionPlugin;
|
|
1098
967
|
}(), _class.tag = 'DOMInteraction', _class);
|
|
@@ -1110,22 +979,18 @@
|
|
|
1110
979
|
|
|
1111
980
|
var Plugin = /*#__PURE__*/function () {
|
|
1112
981
|
function Plugin() {
|
|
1113
|
-
_classCallCheck$1(this, Plugin);
|
|
1114
|
-
|
|
1115
982
|
this.name = 'dom-interaction';
|
|
1116
983
|
}
|
|
1117
984
|
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
}
|
|
1128
|
-
}]);
|
|
985
|
+
var _proto = Plugin.prototype;
|
|
986
|
+
|
|
987
|
+
_proto.init = function init(container) {
|
|
988
|
+
container.load(containerModule, true);
|
|
989
|
+
};
|
|
990
|
+
|
|
991
|
+
_proto.destroy = function destroy(container) {
|
|
992
|
+
container.unload(containerModule);
|
|
993
|
+
};
|
|
1129
994
|
|
|
1130
995
|
return Plugin;
|
|
1131
996
|
}();
|
|
@@ -1135,6 +1000,39 @@
|
|
|
1135
1000
|
Plugin: Plugin
|
|
1136
1001
|
});
|
|
1137
1002
|
|
|
1003
|
+
function clonePath(path) {
|
|
1004
|
+
return path.map((x) => (Array.isArray(x) ? [...x] : x));
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* Rounds the values of a `PathArray` instance to
|
|
1009
|
+
* a specified amount of decimals and returns it.
|
|
1010
|
+
*/
|
|
1011
|
+
function roundPath(path, round) {
|
|
1012
|
+
if (round === 'off')
|
|
1013
|
+
return clonePath(path);
|
|
1014
|
+
// to round values to the power
|
|
1015
|
+
// the `round` value must be integer
|
|
1016
|
+
const pow = typeof round === 'number' && round >= 1 ? Math.pow(10, round) : 1;
|
|
1017
|
+
return path.map((pi) => {
|
|
1018
|
+
const values = pi
|
|
1019
|
+
.slice(1)
|
|
1020
|
+
.map(Number)
|
|
1021
|
+
.map((n) => (round ? Math.round(n * pow) / pow : Math.round(n)));
|
|
1022
|
+
return [pi[0], ...values];
|
|
1023
|
+
});
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
/**
|
|
1027
|
+
* Returns a valid `d` attribute string value created
|
|
1028
|
+
* by rounding values and concatenating the `pathArray` segments.
|
|
1029
|
+
*/
|
|
1030
|
+
function path2String(path, round = 'off') {
|
|
1031
|
+
return roundPath(path, round)
|
|
1032
|
+
.map((x) => x[0] + x.slice(1).join(' '))
|
|
1033
|
+
.join('');
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1138
1036
|
var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
1139
1037
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1140
1038
|
if (ar || !(i in from)) {
|
|
@@ -1341,1472 +1239,1316 @@
|
|
|
1341
1239
|
return output;
|
|
1342
1240
|
}
|
|
1343
1241
|
|
|
1344
|
-
function
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
var exports = {},
|
|
1351
|
-
Op = Object.prototype,
|
|
1352
|
-
hasOwn = Op.hasOwnProperty,
|
|
1353
|
-
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
1354
|
-
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
1355
|
-
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
1356
|
-
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
1242
|
+
var ElementSVG = function ElementSVG() {
|
|
1243
|
+
this.$el = void 0;
|
|
1244
|
+
this.$groupEl = void 0;
|
|
1245
|
+
this.$hitTestingEl = void 0;
|
|
1246
|
+
};
|
|
1357
1247
|
|
|
1358
|
-
|
|
1359
|
-
return Object.defineProperty(obj, key, {
|
|
1360
|
-
value: value,
|
|
1361
|
-
enumerable: !0,
|
|
1362
|
-
configurable: !0,
|
|
1363
|
-
writable: !0
|
|
1364
|
-
}), obj[key];
|
|
1365
|
-
}
|
|
1248
|
+
ElementSVG.tag = 'c-svg-element';
|
|
1366
1249
|
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1250
|
+
function updateImageElementAttribute($el, parsedStyle) {
|
|
1251
|
+
var _parsedStyle$img = parsedStyle.img,
|
|
1252
|
+
img = _parsedStyle$img === void 0 ? '' : _parsedStyle$img,
|
|
1253
|
+
width = parsedStyle.width,
|
|
1254
|
+
height = parsedStyle.height;
|
|
1255
|
+
$el.setAttribute('x', '0');
|
|
1256
|
+
$el.setAttribute('y', '0');
|
|
1374
1257
|
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
1258
|
+
if (g.isString(img)) {
|
|
1259
|
+
$el.setAttribute('href', img);
|
|
1260
|
+
} else if (img instanceof Image) {
|
|
1261
|
+
if (!width) {
|
|
1262
|
+
$el.setAttribute('width', "" + img.width); // TODO: set renderable.boundsDirty
|
|
1263
|
+
// this.attr('width', img.width);
|
|
1264
|
+
}
|
|
1383
1265
|
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
}
|
|
1266
|
+
if (!height) {
|
|
1267
|
+
$el.setAttribute('height', "" + img.height); // this.attr('height', img.height);
|
|
1268
|
+
}
|
|
1388
1269
|
|
|
1389
|
-
|
|
1390
|
-
|
|
1270
|
+
$el.setAttribute('href', img.src);
|
|
1271
|
+
} else if ( // @ts-ignore
|
|
1272
|
+
img instanceof HTMLElement && g.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
|
|
1273
|
+
$el.setAttribute('href', img.toDataURL()); // @ts-ignore
|
|
1274
|
+
} else if (img instanceof ImageData) {
|
|
1275
|
+
var canvas = document.createElement('canvas'); // @ts-ignore
|
|
1391
1276
|
|
|
1392
|
-
|
|
1393
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
1277
|
+
canvas.setAttribute('width', "" + img.width); // @ts-ignore
|
|
1394
1278
|
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
return delegateResult;
|
|
1398
|
-
}
|
|
1399
|
-
}
|
|
1279
|
+
canvas.setAttribute('height', "" + img.height);
|
|
1280
|
+
var context = canvas.getContext('2d');
|
|
1400
1281
|
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
context.dispatchException(context.arg);
|
|
1404
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
1405
|
-
state = "executing";
|
|
1406
|
-
var record = tryCatch(innerFn, self, context);
|
|
1282
|
+
if (context) {
|
|
1283
|
+
context.putImageData(img, 0, 0);
|
|
1407
1284
|
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
done: context.done
|
|
1413
|
-
};
|
|
1414
|
-
}
|
|
1285
|
+
if (!width) {
|
|
1286
|
+
// @ts-ignore
|
|
1287
|
+
$el.setAttribute('width', "" + img.width); // this.attr('width', img.width);
|
|
1288
|
+
}
|
|
1415
1289
|
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
}
|
|
1290
|
+
if (!height) {
|
|
1291
|
+
// @ts-ignore
|
|
1292
|
+
$el.setAttribute('height', "" + img.height); // this.attr('height', img.height);
|
|
1293
|
+
}
|
|
1421
1294
|
|
|
1422
|
-
|
|
1423
|
-
try {
|
|
1424
|
-
return {
|
|
1425
|
-
type: "normal",
|
|
1426
|
-
arg: fn.call(obj, arg)
|
|
1427
|
-
};
|
|
1428
|
-
} catch (err) {
|
|
1429
|
-
return {
|
|
1430
|
-
type: "throw",
|
|
1431
|
-
arg: err
|
|
1432
|
-
};
|
|
1295
|
+
$el.setAttribute('href', canvas.toDataURL());
|
|
1433
1296
|
}
|
|
1434
1297
|
}
|
|
1298
|
+
}
|
|
1435
1299
|
|
|
1436
|
-
|
|
1437
|
-
var
|
|
1300
|
+
function updateLineElementAttribute($el, parsedStyle) {
|
|
1301
|
+
var x1 = parsedStyle.x1,
|
|
1302
|
+
y1 = parsedStyle.y1,
|
|
1303
|
+
x2 = parsedStyle.x2,
|
|
1304
|
+
y2 = parsedStyle.y2,
|
|
1305
|
+
_parsedStyle$defX = parsedStyle.defX,
|
|
1306
|
+
defX = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
1307
|
+
_parsedStyle$defY = parsedStyle.defY,
|
|
1308
|
+
defY = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY; // @see https://github.com/antvis/g/issues/1038
|
|
1438
1309
|
|
|
1439
|
-
|
|
1310
|
+
$el.setAttribute('x1', "" + (x1.value - defX));
|
|
1311
|
+
$el.setAttribute('y1', "" + (y1.value - defY));
|
|
1312
|
+
$el.setAttribute('x2', "" + (x2.value - defX));
|
|
1313
|
+
$el.setAttribute('y2', "" + (y2.value - defY));
|
|
1314
|
+
}
|
|
1440
1315
|
|
|
1441
|
-
|
|
1316
|
+
function updatePathElementAttribute($el, parsedStyle) {
|
|
1317
|
+
var path = parsedStyle.path;
|
|
1318
|
+
$el.setAttribute('d', path2String(path.absolutePath, 3));
|
|
1319
|
+
}
|
|
1442
1320
|
|
|
1443
|
-
|
|
1321
|
+
function updatePolylineElementAttribute($el, parsedStyle) {
|
|
1322
|
+
var points = parsedStyle.points;
|
|
1444
1323
|
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
var getProto = Object.getPrototypeOf,
|
|
1450
|
-
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
1451
|
-
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
1452
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
1453
|
-
|
|
1454
|
-
function defineIteratorMethods(prototype) {
|
|
1455
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
1456
|
-
define(prototype, method, function (arg) {
|
|
1457
|
-
return this._invoke(method, arg);
|
|
1458
|
-
});
|
|
1459
|
-
});
|
|
1324
|
+
if (points && points.points && points.points.length >= 2) {
|
|
1325
|
+
$el.setAttribute('points', points.points.map(function (point) {
|
|
1326
|
+
return point[0] + "," + point[1];
|
|
1327
|
+
}).join(' '));
|
|
1460
1328
|
}
|
|
1329
|
+
}
|
|
1461
1330
|
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1331
|
+
function updateRectElementAttribute($el, parsedStyle) {
|
|
1332
|
+
var radius = parsedStyle.radius,
|
|
1333
|
+
width = parsedStyle.width,
|
|
1334
|
+
height = parsedStyle.height; // CSSKeyword: auto
|
|
1465
1335
|
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
1470
|
-
invoke("next", value, resolve, reject);
|
|
1471
|
-
}, function (err) {
|
|
1472
|
-
invoke("throw", err, resolve, reject);
|
|
1473
|
-
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
1474
|
-
result.value = unwrapped, resolve(result);
|
|
1475
|
-
}, function (error) {
|
|
1476
|
-
return invoke("throw", error, resolve, reject);
|
|
1477
|
-
});
|
|
1478
|
-
}
|
|
1336
|
+
if (!isFinite(width.value) || !isFinite(height.value)) {
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1479
1339
|
|
|
1480
|
-
|
|
1481
|
-
|
|
1340
|
+
var hasRadius = radius && radius.some(function (r) {
|
|
1341
|
+
return r.value !== 0;
|
|
1342
|
+
});
|
|
1343
|
+
var d = '';
|
|
1482
1344
|
|
|
1483
|
-
|
|
1345
|
+
if (!hasRadius) {
|
|
1346
|
+
d = "M 0,0 l " + width.value + ",0 l 0," + height.value + " l" + -width.value + " 0 z";
|
|
1347
|
+
} else {
|
|
1348
|
+
var _radius$map = radius.map(function (r) {
|
|
1349
|
+
return g.clamp(r.value, 0, Math.min(Math.abs(width.value) / 2, Math.abs(height.value) / 2));
|
|
1350
|
+
}),
|
|
1351
|
+
tlr = _radius$map[0],
|
|
1352
|
+
trr = _radius$map[1],
|
|
1353
|
+
brr = _radius$map[2],
|
|
1354
|
+
blr = _radius$map[3];
|
|
1484
1355
|
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
return new PromiseImpl(function (resolve, reject) {
|
|
1488
|
-
invoke(method, arg, resolve, reject);
|
|
1489
|
-
});
|
|
1490
|
-
}
|
|
1356
|
+
var signX = width.value > 0 ? 1 : -1;
|
|
1357
|
+
var signY = height.value > 0 ? 1 : -1; // sweep-flag @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Tutorial/Paths#arcs
|
|
1491
1358
|
|
|
1492
|
-
|
|
1493
|
-
|
|
1359
|
+
var sweepFlag = signX + signY !== 0 ? 1 : 0;
|
|
1360
|
+
d = [["M " + signX * tlr + ",0"], ["l " + (width.value - signX * (tlr + trr)) + ",0"], ["a " + trr + "," + trr + ",0,0," + sweepFlag + "," + signX * trr + "," + signY * trr], ["l 0," + (height.value - signY * (trr + brr))], ["a " + brr + "," + brr + ",0,0," + sweepFlag + "," + -signX * brr + "," + signY * brr], ["l " + (signX * (brr + blr) - width.value) + ",0"], ["a " + blr + "," + blr + ",0,0," + sweepFlag + "," + -signX * blr + "," + -signY * blr], ["l 0," + (signY * (blr + tlr) - height.value)], ["a " + tlr + "," + tlr + ",0,0," + sweepFlag + "," + signX * tlr + "," + -signY * tlr], ['z']].join(' ');
|
|
1494
1361
|
}
|
|
1495
1362
|
|
|
1496
|
-
|
|
1497
|
-
|
|
1363
|
+
$el.setAttribute('d', d);
|
|
1364
|
+
}
|
|
1498
1365
|
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
1503
|
-
}
|
|
1366
|
+
function numberToLongString(x) {
|
|
1367
|
+
return x.toFixed(6).replace('.000000', '');
|
|
1368
|
+
}
|
|
1504
1369
|
|
|
1505
|
-
|
|
1370
|
+
function convertHTML(str) {
|
|
1371
|
+
var regex = /[&|<|>|"|']/g;
|
|
1372
|
+
return str.replace(regex, function (match) {
|
|
1373
|
+
if (match === '&') {
|
|
1374
|
+
return '&';
|
|
1375
|
+
} else if (match === '<') {
|
|
1376
|
+
return '<';
|
|
1377
|
+
} else if (match === '>') {
|
|
1378
|
+
return '>';
|
|
1379
|
+
} else if (match === '"') {
|
|
1380
|
+
return '"';
|
|
1381
|
+
} else {
|
|
1382
|
+
return ''';
|
|
1506
1383
|
}
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1507
1386
|
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1387
|
+
var BASELINE_MAP = {
|
|
1388
|
+
top: 'before-edge',
|
|
1389
|
+
middle: 'central',
|
|
1390
|
+
bottom: 'after-edge',
|
|
1391
|
+
alphabetic: 'alphabetic',
|
|
1392
|
+
ideographic: 'ideographic',
|
|
1393
|
+
hanging: 'hanging'
|
|
1394
|
+
}; // for FireFox
|
|
1395
|
+
// @see https://github.com/plouc/nivo/issues/164
|
|
1513
1396
|
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1397
|
+
var BASELINE_MAP_FOR_FIREFOX = {
|
|
1398
|
+
top: 'text-before-edge',
|
|
1399
|
+
middle: 'central',
|
|
1400
|
+
bottom: 'text-after-edge',
|
|
1401
|
+
alphabetic: 'alphabetic',
|
|
1402
|
+
ideographic: 'ideographic',
|
|
1403
|
+
hanging: 'hanging'
|
|
1404
|
+
};
|
|
1520
1405
|
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1406
|
+
function updateTextElementAttribute($el, parsedStyle) {
|
|
1407
|
+
var textBaseline = parsedStyle.textBaseline,
|
|
1408
|
+
lineWidth = parsedStyle.lineWidth,
|
|
1409
|
+
metrics = parsedStyle.metrics,
|
|
1410
|
+
dx = parsedStyle.dx,
|
|
1411
|
+
dy = parsedStyle.dy;
|
|
1412
|
+
var browser = detect();
|
|
1525
1413
|
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1414
|
+
if (browser && browser.name === 'firefox') {
|
|
1415
|
+
// compatible with FireFox browser, ref: https://github.com/antvis/g/issues/119
|
|
1416
|
+
$el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value] || 'alphabetic');
|
|
1417
|
+
} else {
|
|
1418
|
+
$el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value]);
|
|
1419
|
+
$el.setAttribute('alignment-baseline', BASELINE_MAP[textBaseline.value]);
|
|
1530
1420
|
}
|
|
1531
1421
|
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
if (!isNaN(iterable.length)) {
|
|
1539
|
-
var i = -1,
|
|
1540
|
-
next = function next() {
|
|
1541
|
-
for (; ++i < iterable.length;) {
|
|
1542
|
-
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
1543
|
-
}
|
|
1422
|
+
$el.setAttribute('paint-order', 'stroke');
|
|
1423
|
+
var lines = metrics.lines,
|
|
1424
|
+
lineHeight = metrics.lineHeight,
|
|
1425
|
+
height = metrics.height;
|
|
1426
|
+
var lineNum = lines.length;
|
|
1427
|
+
$el.setAttribute('style', "transform:translate(" + dx.toString() + ", " + dy.toString() + ");");
|
|
1544
1428
|
|
|
1545
|
-
|
|
1546
|
-
|
|
1429
|
+
if (lineNum === 1) {
|
|
1430
|
+
$el.innerHTML = convertHTML(lines[0]);
|
|
1431
|
+
$el.setAttribute('dx', "" + lineWidth.value / 2);
|
|
1432
|
+
} else {
|
|
1433
|
+
$el.innerHTML = lines.map(function (line, i) {
|
|
1434
|
+
var dx = lineWidth.value / 2;
|
|
1435
|
+
var dy = 0;
|
|
1547
1436
|
|
|
1548
|
-
|
|
1437
|
+
if (i === 0) {
|
|
1438
|
+
// TODO: handle other textBaseline values
|
|
1439
|
+
if (textBaseline.value === 'middle') {
|
|
1440
|
+
dy = lineHeight / 2 - height / 2;
|
|
1441
|
+
} else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
|
|
1442
|
+
dy = 0;
|
|
1443
|
+
} else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
|
|
1444
|
+
dy = -lineHeight * (lineNum - 1);
|
|
1445
|
+
}
|
|
1446
|
+
} else {
|
|
1447
|
+
dy = lineHeight;
|
|
1549
1448
|
}
|
|
1550
|
-
}
|
|
1551
1449
|
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
};
|
|
1450
|
+
return "<tspan x=\"0\" dx=\"" + dx + "\" dy=\"" + dy + "\">" + convertHTML(line) + "</tspan>";
|
|
1451
|
+
}).join('');
|
|
1555
1452
|
}
|
|
1453
|
+
}
|
|
1556
1454
|
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
done: !0
|
|
1561
|
-
};
|
|
1562
|
-
}
|
|
1455
|
+
var CreateElementContribution = g.Syringe.defineToken('CreateElementContribution', {
|
|
1456
|
+
multiple: false
|
|
1457
|
+
});
|
|
1563
1458
|
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
}, exports.mark = function (genFun) {
|
|
1568
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
1569
|
-
}, exports.awrap = function (arg) {
|
|
1570
|
-
return {
|
|
1571
|
-
__await: arg
|
|
1572
|
-
};
|
|
1573
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
1574
|
-
return this;
|
|
1575
|
-
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
1576
|
-
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
1577
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
1578
|
-
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
1579
|
-
return result.done ? result.value : iter.next();
|
|
1580
|
-
});
|
|
1581
|
-
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
1582
|
-
return this;
|
|
1583
|
-
}), define(Gp, "toString", function () {
|
|
1584
|
-
return "[object Generator]";
|
|
1585
|
-
}), exports.keys = function (object) {
|
|
1586
|
-
var keys = [];
|
|
1459
|
+
function createSVGElement(type, doc) {
|
|
1460
|
+
return (doc || document).createElementNS('http://www.w3.org/2000/svg', type);
|
|
1461
|
+
}
|
|
1587
1462
|
|
|
1588
|
-
|
|
1589
|
-
keys.push(key);
|
|
1590
|
-
}
|
|
1463
|
+
var _SHAPE2TAGS, _SHAPE_UPDATE_DEPS;
|
|
1591
1464
|
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
var key = keys.pop();
|
|
1595
|
-
if (key in object) return next.value = key, next.done = !1, next;
|
|
1596
|
-
}
|
|
1465
|
+
var SHAPE2TAGS = (_SHAPE2TAGS = {}, _SHAPE2TAGS[g.Shape.RECT] = 'path', _SHAPE2TAGS[g.Shape.CIRCLE] = 'circle', _SHAPE2TAGS[g.Shape.ELLIPSE] = 'ellipse', _SHAPE2TAGS[g.Shape.IMAGE] = 'image', _SHAPE2TAGS[g.Shape.GROUP] = 'g', _SHAPE2TAGS[g.Shape.LINE] = 'line', _SHAPE2TAGS[g.Shape.POLYLINE] = 'polyline', _SHAPE2TAGS[g.Shape.POLYGON] = 'polygon', _SHAPE2TAGS[g.Shape.TEXT] = 'text', _SHAPE2TAGS[g.Shape.PATH] = 'path', _SHAPE2TAGS[g.Shape.HTML] = 'foreignObject', _SHAPE2TAGS);
|
|
1466
|
+
var SHAPE_UPDATE_DEPS = (_SHAPE_UPDATE_DEPS = {}, _SHAPE_UPDATE_DEPS[g.Shape.CIRCLE] = ['r'], _SHAPE_UPDATE_DEPS[g.Shape.ELLIPSE] = ['rx', 'ry'], _SHAPE_UPDATE_DEPS[g.Shape.RECT] = ['width', 'height', 'radius'], _SHAPE_UPDATE_DEPS[g.Shape.IMAGE] = ['img', 'width', 'height'], _SHAPE_UPDATE_DEPS[g.Shape.LINE] = ['x1', 'y1', 'x2', 'y2'], _SHAPE_UPDATE_DEPS[g.Shape.POLYLINE] = ['points'], _SHAPE_UPDATE_DEPS[g.Shape.POLYGON] = ['points'], _SHAPE_UPDATE_DEPS[g.Shape.PATH] = ['path'], _SHAPE_UPDATE_DEPS[g.Shape.TEXT] = ['text', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'wordWrap', 'wordWrapWidth', 'leading', 'textBaseline', 'textAlign', 'textTransform', 'whiteSpace', 'dx', 'dy'], _SHAPE_UPDATE_DEPS);
|
|
1597
1467
|
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
reset: function reset(skipTempReset) {
|
|
1603
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
|
|
1604
|
-
"t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
1605
|
-
}
|
|
1606
|
-
},
|
|
1607
|
-
stop: function stop() {
|
|
1608
|
-
this.done = !0;
|
|
1609
|
-
var rootRecord = this.tryEntries[0].completion;
|
|
1610
|
-
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
1611
|
-
return this.rval;
|
|
1612
|
-
},
|
|
1613
|
-
dispatchException: function dispatchException(exception) {
|
|
1614
|
-
if (this.done) throw exception;
|
|
1615
|
-
var context = this;
|
|
1468
|
+
var DefaultCreateElementContribution = /*#__PURE__*/function () {
|
|
1469
|
+
function DefaultCreateElementContribution() {
|
|
1470
|
+
this.canvasConfig = void 0;
|
|
1471
|
+
}
|
|
1616
1472
|
|
|
1617
|
-
|
|
1618
|
-
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
1619
|
-
}
|
|
1473
|
+
var _proto = DefaultCreateElementContribution.prototype;
|
|
1620
1474
|
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1475
|
+
_proto.createElement = function createElement(object) {
|
|
1476
|
+
var doc = this.canvasConfig.document;
|
|
1477
|
+
var type = SHAPE2TAGS[object.nodeName] || 'g';
|
|
1478
|
+
return createSVGElement(type, doc || document);
|
|
1479
|
+
};
|
|
1625
1480
|
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1481
|
+
_proto.shouldUpdateElementAttribute = function shouldUpdateElementAttribute(object, attributeName) {
|
|
1482
|
+
var nodeName = object.nodeName;
|
|
1483
|
+
return (SHAPE_UPDATE_DEPS[nodeName] || []).indexOf(attributeName) > -1;
|
|
1484
|
+
};
|
|
1629
1485
|
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
} else {
|
|
1636
|
-
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
1637
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
}
|
|
1641
|
-
},
|
|
1642
|
-
abrupt: function abrupt(type, arg) {
|
|
1643
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1644
|
-
var entry = this.tryEntries[i];
|
|
1486
|
+
_proto.updateElementAttribute = function updateElementAttribute(object) {
|
|
1487
|
+
// @ts-ignore
|
|
1488
|
+
var $el = object.elementSVG.$el;
|
|
1489
|
+
var nodeName = object.nodeName,
|
|
1490
|
+
parsedStyle = object.parsedStyle;
|
|
1645
1491
|
|
|
1646
|
-
|
|
1647
|
-
|
|
1492
|
+
switch (nodeName) {
|
|
1493
|
+
case g.Shape.IMAGE:
|
|
1494
|
+
{
|
|
1495
|
+
updateImageElementAttribute($el, parsedStyle);
|
|
1648
1496
|
break;
|
|
1649
1497
|
}
|
|
1650
|
-
}
|
|
1651
1498
|
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
if ("throw" === record.type) throw record.arg;
|
|
1658
|
-
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
1659
|
-
},
|
|
1660
|
-
finish: function finish(finallyLoc) {
|
|
1661
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1662
|
-
var entry = this.tryEntries[i];
|
|
1663
|
-
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
1664
|
-
}
|
|
1665
|
-
},
|
|
1666
|
-
catch: function _catch(tryLoc) {
|
|
1667
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1668
|
-
var entry = this.tryEntries[i];
|
|
1499
|
+
case g.Shape.RECT:
|
|
1500
|
+
{
|
|
1501
|
+
updateRectElementAttribute($el, parsedStyle);
|
|
1502
|
+
break;
|
|
1503
|
+
}
|
|
1669
1504
|
|
|
1670
|
-
|
|
1671
|
-
|
|
1505
|
+
case g.Shape.LINE:
|
|
1506
|
+
{
|
|
1507
|
+
updateLineElementAttribute($el, parsedStyle);
|
|
1508
|
+
break;
|
|
1509
|
+
}
|
|
1672
1510
|
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1511
|
+
case g.Shape.POLYGON:
|
|
1512
|
+
case g.Shape.POLYLINE:
|
|
1513
|
+
{
|
|
1514
|
+
updatePolylineElementAttribute($el, parsedStyle);
|
|
1515
|
+
break;
|
|
1516
|
+
}
|
|
1677
1517
|
|
|
1678
|
-
|
|
1518
|
+
case g.Shape.PATH:
|
|
1519
|
+
{
|
|
1520
|
+
updatePathElementAttribute($el, parsedStyle);
|
|
1521
|
+
break;
|
|
1679
1522
|
}
|
|
1680
|
-
}
|
|
1681
1523
|
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
resultName: resultName,
|
|
1688
|
-
nextLoc: nextLoc
|
|
1689
|
-
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
1524
|
+
case g.Shape.TEXT:
|
|
1525
|
+
{
|
|
1526
|
+
updateTextElementAttribute($el, parsedStyle);
|
|
1527
|
+
break;
|
|
1528
|
+
}
|
|
1690
1529
|
}
|
|
1691
|
-
}
|
|
1692
|
-
}
|
|
1693
|
-
|
|
1694
|
-
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1695
|
-
try {
|
|
1696
|
-
var info = gen[key](arg);
|
|
1697
|
-
var value = info.value;
|
|
1698
|
-
} catch (error) {
|
|
1699
|
-
reject(error);
|
|
1700
|
-
return;
|
|
1701
|
-
}
|
|
1530
|
+
};
|
|
1702
1531
|
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
} else {
|
|
1706
|
-
Promise.resolve(value).then(_next, _throw);
|
|
1707
|
-
}
|
|
1708
|
-
}
|
|
1532
|
+
return DefaultCreateElementContribution;
|
|
1533
|
+
}();
|
|
1709
1534
|
|
|
1710
|
-
|
|
1711
|
-
return function () {
|
|
1712
|
-
var self = this,
|
|
1713
|
-
args = arguments;
|
|
1714
|
-
return new Promise(function (resolve, reject) {
|
|
1715
|
-
var gen = fn.apply(self, args);
|
|
1535
|
+
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], DefaultCreateElementContribution.prototype, "canvasConfig", void 0);
|
|
1716
1536
|
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1537
|
+
DefaultCreateElementContribution = __decorate([g.singleton({
|
|
1538
|
+
token: CreateElementContribution
|
|
1539
|
+
})], DefaultCreateElementContribution);
|
|
1540
|
+
var FILTER_PREFIX = 'g-filter-';
|
|
1541
|
+
/**
|
|
1542
|
+
* use SVG filters, eg. blur, brightness, contrast...
|
|
1543
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/filter
|
|
1544
|
+
*/
|
|
1720
1545
|
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1546
|
+
function createOrUpdateFilter(document, $def, object, $el, filters) {
|
|
1547
|
+
// eg. filter="url(#f1) url(#f2)"
|
|
1548
|
+
var filterName = FILTER_PREFIX + object.entity;
|
|
1549
|
+
var $existedFilters = $def.querySelectorAll("[name=" + filterName + "]");
|
|
1724
1550
|
|
|
1725
|
-
|
|
1551
|
+
if ($existedFilters.length) {
|
|
1552
|
+
$existedFilters.forEach(function ($filter) {
|
|
1553
|
+
$def.removeChild($filter);
|
|
1726
1554
|
});
|
|
1727
|
-
};
|
|
1728
|
-
}
|
|
1729
|
-
|
|
1730
|
-
function _classCallCheck$2(instance, Constructor) {
|
|
1731
|
-
if (!(instance instanceof Constructor)) {
|
|
1732
|
-
throw new TypeError("Cannot call a class as a function");
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
-
|
|
1736
|
-
function _defineProperties$2(target, props) {
|
|
1737
|
-
for (var i = 0; i < props.length; i++) {
|
|
1738
|
-
var descriptor = props[i];
|
|
1739
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
1740
|
-
descriptor.configurable = true;
|
|
1741
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
1742
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1743
1555
|
}
|
|
1744
|
-
}
|
|
1745
|
-
|
|
1746
|
-
function _createClass$2(Constructor, protoProps, staticProps) {
|
|
1747
|
-
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
|
|
1748
|
-
if (staticProps) _defineProperties$2(Constructor, staticProps);
|
|
1749
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
1750
|
-
writable: false
|
|
1751
|
-
});
|
|
1752
|
-
return Constructor;
|
|
1753
|
-
}
|
|
1754
1556
|
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
value: value,
|
|
1759
|
-
enumerable: true,
|
|
1760
|
-
configurable: true,
|
|
1761
|
-
writable: true
|
|
1762
|
-
});
|
|
1557
|
+
if (filters.length === 0) {
|
|
1558
|
+
// 'none'
|
|
1559
|
+
$el === null || $el === void 0 ? void 0 : $el.removeAttribute('filter');
|
|
1763
1560
|
} else {
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
|
-
function _slicedToArray(arr, i) {
|
|
1771
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
|
-
function _arrayWithHoles(arr) {
|
|
1775
|
-
if (Array.isArray(arr)) return arr;
|
|
1776
|
-
}
|
|
1777
|
-
|
|
1778
|
-
function _iterableToArrayLimit(arr, i) {
|
|
1779
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1780
|
-
|
|
1781
|
-
if (_i == null) return;
|
|
1782
|
-
var _arr = [];
|
|
1783
|
-
var _n = true;
|
|
1784
|
-
var _d = false;
|
|
1785
|
-
|
|
1786
|
-
var _s, _e;
|
|
1787
|
-
|
|
1788
|
-
try {
|
|
1789
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
1790
|
-
_arr.push(_s.value);
|
|
1791
|
-
|
|
1792
|
-
if (i && _arr.length === i) break;
|
|
1793
|
-
}
|
|
1794
|
-
} catch (err) {
|
|
1795
|
-
_d = true;
|
|
1796
|
-
_e = err;
|
|
1797
|
-
} finally {
|
|
1798
|
-
try {
|
|
1799
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
1800
|
-
} finally {
|
|
1801
|
-
if (_d) throw _e;
|
|
1802
|
-
}
|
|
1803
|
-
}
|
|
1804
|
-
|
|
1805
|
-
return _arr;
|
|
1806
|
-
}
|
|
1807
|
-
|
|
1808
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
1809
|
-
if (!o) return;
|
|
1810
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
1811
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1812
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1813
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
1814
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
1815
|
-
}
|
|
1816
|
-
|
|
1817
|
-
function _arrayLikeToArray(arr, len) {
|
|
1818
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
1819
|
-
|
|
1820
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
1821
|
-
arr2[i] = arr[i];
|
|
1822
|
-
}
|
|
1823
|
-
|
|
1824
|
-
return arr2;
|
|
1825
|
-
}
|
|
1826
|
-
|
|
1827
|
-
function _nonIterableRest() {
|
|
1828
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
|
-
var ElementSVG = /*#__PURE__*/_createClass$2(function ElementSVG() {
|
|
1832
|
-
_classCallCheck$2(this, ElementSVG);
|
|
1833
|
-
|
|
1834
|
-
this.$el = void 0;
|
|
1835
|
-
this.$groupEl = void 0;
|
|
1836
|
-
this.$hitTestingEl = void 0;
|
|
1837
|
-
});
|
|
1838
|
-
|
|
1839
|
-
ElementSVG.tag = 'c-svg-element';
|
|
1840
|
-
|
|
1841
|
-
function updateImageElementAttribute($el, parsedStyle) {
|
|
1842
|
-
var _parsedStyle$img = parsedStyle.img,
|
|
1843
|
-
img = _parsedStyle$img === void 0 ? '' : _parsedStyle$img,
|
|
1844
|
-
width = parsedStyle.width,
|
|
1845
|
-
height = parsedStyle.height;
|
|
1846
|
-
$el.setAttribute('x', '0');
|
|
1847
|
-
$el.setAttribute('y', '0');
|
|
1848
|
-
|
|
1849
|
-
if (g.isString(img)) {
|
|
1850
|
-
$el.setAttribute('href', img);
|
|
1851
|
-
} else if (img instanceof Image) {
|
|
1852
|
-
if (!width) {
|
|
1853
|
-
$el.setAttribute('width', "".concat(img.width)); // TODO: set renderable.boundsDirty
|
|
1854
|
-
// this.attr('width', img.width);
|
|
1855
|
-
}
|
|
1561
|
+
var filterIds = filters.map(function (_ref, i) {
|
|
1562
|
+
var name = _ref.name,
|
|
1563
|
+
params = _ref.params;
|
|
1564
|
+
var $filter = createSVGElement('filter', document); // @see https://github.com/antvis/g/issues/1025
|
|
1856
1565
|
|
|
1857
|
-
|
|
1858
|
-
$el.setAttribute('height', "".concat(img.height)); // this.attr('height', img.height);
|
|
1859
|
-
}
|
|
1566
|
+
$filter.setAttribute('filterUnits', 'userSpaceOnUse');
|
|
1860
1567
|
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1568
|
+
if (name === 'blur') {
|
|
1569
|
+
createBlur(document, $filter, params);
|
|
1570
|
+
} else if (name === 'brightness') {
|
|
1571
|
+
createBrightness(document, $filter, params);
|
|
1572
|
+
} else if (name === 'drop-shadow') {
|
|
1573
|
+
createDropShadow(document, $filter, params);
|
|
1574
|
+
} else if (name === 'contrast') {
|
|
1575
|
+
createContrast(document, $filter, params);
|
|
1576
|
+
} else if (name === 'grayscale') {
|
|
1577
|
+
createGrayscale(document, $filter, params);
|
|
1578
|
+
} else if (name === 'sepia') {
|
|
1579
|
+
createSepia(document, $filter, params);
|
|
1580
|
+
} else if (name === 'saturate') {
|
|
1581
|
+
createSaturate(document, $filter, params);
|
|
1582
|
+
} else if (name === 'hue-rotate') {
|
|
1583
|
+
createHueRotate(document, $filter, params);
|
|
1584
|
+
} else if (name === 'invert') {
|
|
1585
|
+
createInvert(document, $filter, params);
|
|
1586
|
+
}
|
|
1867
1587
|
|
|
1868
|
-
|
|
1588
|
+
$filter.id = filterName + "-" + i;
|
|
1589
|
+
$filter.setAttribute('name', filterName);
|
|
1590
|
+
$def.appendChild($filter);
|
|
1591
|
+
return $filter.id;
|
|
1592
|
+
});
|
|
1593
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', filterIds.map(function (filterId) {
|
|
1594
|
+
return "url(#" + filterId + ")";
|
|
1595
|
+
}).join(' '));
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1869
1598
|
|
|
1870
|
-
|
|
1871
|
-
|
|
1599
|
+
function convertToAbsoluteValue(param) {
|
|
1600
|
+
return param.unit === g.UnitType.kPercentage ? param.value / 100 : param.value;
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* @see https://drafts.fxtf.org/filter-effects/#blurEquivalent
|
|
1604
|
+
*/
|
|
1872
1605
|
|
|
1873
|
-
if (context) {
|
|
1874
|
-
context.putImageData(img, 0, 0);
|
|
1875
1606
|
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1607
|
+
function createBlur(document, $filter, params) {
|
|
1608
|
+
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
1609
|
+
$feGaussianBlur.setAttribute('in', 'SourceGraphic');
|
|
1610
|
+
$feGaussianBlur.setAttribute('stdDeviation', "" + params[0].value);
|
|
1611
|
+
$filter.appendChild($feGaussianBlur);
|
|
1612
|
+
}
|
|
1880
1613
|
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1614
|
+
function createFeComponentTransfer(document, $filter, _ref2) {
|
|
1615
|
+
var type = _ref2.type,
|
|
1616
|
+
slope = _ref2.slope,
|
|
1617
|
+
intercept = _ref2.intercept,
|
|
1618
|
+
tableValues = _ref2.tableValues;
|
|
1619
|
+
var $feComponentTransfer = createSVGElement('feComponentTransfer', document);
|
|
1620
|
+
[createSVGElement('feFuncR', document), createSVGElement('feFuncG', document), createSVGElement('feFuncB', document)].forEach(function ($feFunc) {
|
|
1621
|
+
$feFunc.setAttribute('type', type);
|
|
1885
1622
|
|
|
1886
|
-
|
|
1623
|
+
if (type === 'table') {
|
|
1624
|
+
$feFunc.setAttribute('tableValues', "" + tableValues);
|
|
1625
|
+
} else {
|
|
1626
|
+
$feFunc.setAttribute('slope', "" + slope);
|
|
1627
|
+
$feFunc.setAttribute('intercept', "" + intercept);
|
|
1887
1628
|
}
|
|
1888
|
-
}
|
|
1889
|
-
}
|
|
1890
1629
|
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
x2 = parsedStyle.x2,
|
|
1895
|
-
y2 = parsedStyle.y2,
|
|
1896
|
-
defX = parsedStyle.defX,
|
|
1897
|
-
defY = parsedStyle.defY;
|
|
1898
|
-
$el.setAttribute('x1', "".concat(x1.value - defX));
|
|
1899
|
-
$el.setAttribute('y1', "".concat(y1.value - defY));
|
|
1900
|
-
$el.setAttribute('x2', "".concat(x2.value - defX));
|
|
1901
|
-
$el.setAttribute('y2', "".concat(y2.value - defY));
|
|
1630
|
+
$feComponentTransfer.appendChild($feFunc);
|
|
1631
|
+
});
|
|
1632
|
+
$filter.appendChild($feComponentTransfer);
|
|
1902
1633
|
}
|
|
1903
1634
|
|
|
1904
|
-
function
|
|
1905
|
-
var
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1635
|
+
function createContrast(document, $filter, params) {
|
|
1636
|
+
var slope = convertToAbsoluteValue(params[0]);
|
|
1637
|
+
createFeComponentTransfer(document, $filter, {
|
|
1638
|
+
type: 'linear',
|
|
1639
|
+
slope: slope,
|
|
1640
|
+
intercept: -(0.5 * slope) + 0.5
|
|
1641
|
+
});
|
|
1911
1642
|
}
|
|
1912
1643
|
|
|
1913
|
-
function
|
|
1914
|
-
var
|
|
1915
|
-
|
|
1644
|
+
function createInvert(document, $filter, params) {
|
|
1645
|
+
var amount = convertToAbsoluteValue(params[0]);
|
|
1646
|
+
createFeComponentTransfer(document, $filter, {
|
|
1647
|
+
type: 'table',
|
|
1648
|
+
tableValues: amount + " " + (1 - amount)
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1916
1651
|
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1652
|
+
function createBrightness(document, $filter, params) {
|
|
1653
|
+
var slope = convertToAbsoluteValue(params[0]);
|
|
1654
|
+
createFeComponentTransfer(document, $filter, {
|
|
1655
|
+
type: 'linear',
|
|
1656
|
+
slope: slope,
|
|
1657
|
+
intercept: 0
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1920
1660
|
|
|
1921
|
-
|
|
1922
|
-
|
|
1661
|
+
function createSaturate(document, $filter, params) {
|
|
1662
|
+
var amount = convertToAbsoluteValue(params[0]);
|
|
1663
|
+
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
1664
|
+
$feColorMatrix.setAttribute('type', 'saturate');
|
|
1665
|
+
$feColorMatrix.setAttribute('values', "" + amount);
|
|
1666
|
+
$filter.appendChild($feColorMatrix);
|
|
1667
|
+
}
|
|
1923
1668
|
|
|
1924
|
-
|
|
1925
|
-
|
|
1669
|
+
function createHueRotate(document, $filter, params) {
|
|
1670
|
+
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
1671
|
+
$feColorMatrix.setAttribute('type', 'hueRotate');
|
|
1672
|
+
$feColorMatrix.setAttribute('values', "" + params[0].to(g.UnitType.kDegrees).value);
|
|
1673
|
+
$filter.appendChild($feColorMatrix);
|
|
1674
|
+
}
|
|
1926
1675
|
|
|
1927
|
-
|
|
1928
|
-
|
|
1676
|
+
function createDropShadow(document, $filter, params) {
|
|
1677
|
+
var shadowOffsetX = params[0].value;
|
|
1678
|
+
var shadowOffsetY = params[1].value;
|
|
1679
|
+
var shadowBlur = params[2].value; // @ts-ignore
|
|
1929
1680
|
|
|
1930
|
-
|
|
1931
|
-
|
|
1681
|
+
var shadowColor = params[3].formatted;
|
|
1682
|
+
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
1683
|
+
$feGaussianBlur.setAttribute('in', 'SourceAlpha');
|
|
1684
|
+
$feGaussianBlur.setAttribute('stdDeviation', "" + shadowBlur);
|
|
1685
|
+
$filter.appendChild($feGaussianBlur);
|
|
1686
|
+
var $feOffset = createSVGElement('feOffset', document);
|
|
1687
|
+
$feOffset.setAttribute('dx', "" + shadowOffsetX);
|
|
1688
|
+
$feOffset.setAttribute('dy', "" + shadowOffsetY);
|
|
1689
|
+
$feOffset.setAttribute('result', 'offsetblur');
|
|
1690
|
+
$filter.appendChild($feOffset);
|
|
1691
|
+
var $feFlood = createSVGElement('feFlood', document);
|
|
1692
|
+
$feFlood.setAttribute('flood-color', shadowColor);
|
|
1693
|
+
$filter.appendChild($feFlood);
|
|
1694
|
+
var $feComposite = createSVGElement('feComposite', document);
|
|
1695
|
+
$feComposite.setAttribute('in2', 'offsetblur');
|
|
1696
|
+
$feComposite.setAttribute('operator', 'in');
|
|
1697
|
+
$filter.appendChild($feComposite);
|
|
1698
|
+
var $feMerge = createSVGElement('feMerge', document);
|
|
1699
|
+
$filter.appendChild($feMerge);
|
|
1700
|
+
var $feMergeNode1 = createSVGElement('feMergeNode', document);
|
|
1701
|
+
var $feMergeNode2 = createSVGElement('feMergeNode', document);
|
|
1702
|
+
$feMergeNode2.setAttribute('in', 'SourceGraphic');
|
|
1703
|
+
$feMerge.appendChild($feMergeNode1);
|
|
1704
|
+
$feMerge.appendChild($feMergeNode2);
|
|
1705
|
+
}
|
|
1932
1706
|
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1707
|
+
function createFeColorMatrix(document, $filter, matrix) {
|
|
1708
|
+
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
1709
|
+
$feColorMatrix.setAttribute('type', 'matrix');
|
|
1710
|
+
$feColorMatrix.setAttribute('values', matrix.join(' '));
|
|
1711
|
+
$filter.appendChild($feColorMatrix);
|
|
1712
|
+
}
|
|
1713
|
+
/**
|
|
1714
|
+
* @see https://drafts.fxtf.org/filter-effects/#grayscaleEquivalent
|
|
1715
|
+
*/
|
|
1937
1716
|
|
|
1938
|
-
if (~newValue.indexOf('NaN')) {
|
|
1939
|
-
return '';
|
|
1940
|
-
}
|
|
1941
1717
|
|
|
1942
|
-
|
|
1718
|
+
function createGrayscale(document, $filter, params) {
|
|
1719
|
+
var amount = convertToAbsoluteValue(params[0]);
|
|
1720
|
+
createFeColorMatrix(document, $filter, [0.2126 + 0.7874 * (1 - amount), 0.7152 - 0.7152 * (1 - amount), 0.0722 - 0.0722 * (1 - amount), 0, 0, 0.2126 - 0.2126 * (1 - amount), 0.7152 + 0.2848 * (1 - amount), 0.0722 - 0.0722 * (1 - amount), 0, 0, 0.2126 - 0.2126 * (1 - amount), 0.7152 - 0.7152 * (1 - amount), 0.0722 + 0.9278 * (1 - amount), 0, 0, 0, 0, 0, 1, 0]);
|
|
1943
1721
|
}
|
|
1722
|
+
/**
|
|
1723
|
+
* @see https://drafts.fxtf.org/filter-effects/#sepiaEquivalent
|
|
1724
|
+
*/
|
|
1944
1725
|
|
|
1945
|
-
function updatePolylineElementAttribute($el, parsedStyle) {
|
|
1946
|
-
var points = parsedStyle.points,
|
|
1947
|
-
_parsedStyle$defX = parsedStyle.defX,
|
|
1948
|
-
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
1949
|
-
_parsedStyle$defY = parsedStyle.defY,
|
|
1950
|
-
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
1951
1726
|
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
}).join(' '));
|
|
1956
|
-
}
|
|
1727
|
+
function createSepia(document, $filter, params) {
|
|
1728
|
+
var amount = convertToAbsoluteValue(params[0]);
|
|
1729
|
+
createFeColorMatrix(document, $filter, [0.393 + 0.607 * (1 - amount), 0.769 - 0.769 * (1 - amount), 0.189 - 0.189 * (1 - amount), 0, 0, 0.349 - 0.349 * (1 - amount), 0.686 + 0.314 * (1 - amount), 0.168 - 0.168 * (1 - amount), 0, 0, 0.272 - 0.272 * (1 - amount), 0.534 - 0.534 * (1 - amount), 0.131 + 0.869 * (1 - amount), 0, 0, 0, 0, 0, 1, 0]);
|
|
1957
1730
|
}
|
|
1958
1731
|
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
height = parsedStyle.height; // CSSKeyword: auto
|
|
1732
|
+
var PATTERN_PREFIX = 'g-pattern-';
|
|
1733
|
+
var cacheKey2IDMap = {};
|
|
1734
|
+
var counter = 0;
|
|
1963
1735
|
|
|
1964
|
-
|
|
1965
|
-
|
|
1736
|
+
function createOrUpdateGradientAndPattern(document, $def, object, $el, parsedColor, name, createImage) {
|
|
1737
|
+
// eg. clipPath don't have fill/stroke
|
|
1738
|
+
if (!parsedColor) {
|
|
1739
|
+
return '';
|
|
1966
1740
|
}
|
|
1967
1741
|
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1742
|
+
if (parsedColor instanceof g.CSSRGB) {
|
|
1743
|
+
// keep using currentColor @see https://github.com/d3/d3-axis/issues/49
|
|
1744
|
+
if (object.style[name] === 'currentColor') {
|
|
1745
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, 'currentColor');
|
|
1746
|
+
} else {
|
|
1747
|
+
// constant value, eg. '#fff'
|
|
1748
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, parsedColor.isNone ? 'none' : parsedColor.toString());
|
|
1749
|
+
}
|
|
1750
|
+
} else if (g.isPattern(parsedColor)) {
|
|
1751
|
+
var patternId = createOrUpdatePattern(document, $def, object, parsedColor, createImage); // use style instead of attribute when applying <pattern>
|
|
1752
|
+
// @see https://stackoverflow.com/a/7723115
|
|
1972
1753
|
|
|
1973
|
-
|
|
1974
|
-
|
|
1754
|
+
$el.style[name] = "url(#" + patternId + ")";
|
|
1755
|
+
return patternId;
|
|
1975
1756
|
} else {
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
var sweepFlag = signX + signY !== 0 ? 1 : 0;
|
|
1989
|
-
d = [["M ".concat(signX * tlr, ",0")], ["l ".concat(width.value - signX * (tlr + trr), ",0")], ["a ".concat(trr, ",").concat(trr, ",0,0,").concat(sweepFlag, ",").concat(signX * trr, ",").concat(signY * trr)], ["l 0,".concat(height.value - signY * (trr + brr))], ["a ".concat(brr, ",").concat(brr, ",0,0,").concat(sweepFlag, ",").concat(-signX * brr, ",").concat(signY * brr)], ["l ".concat(signX * (brr + blr) - width.value, ",0")], ["a ".concat(blr, ",").concat(blr, ",0,0,").concat(sweepFlag, ",").concat(-signX * blr, ",").concat(-signY * blr)], ["l 0,".concat(signY * (blr + tlr) - height.value)], ["a ".concat(tlr, ",").concat(tlr, ",0,0,").concat(sweepFlag, ",").concat(signX * tlr, ",").concat(-signY * tlr)], ['z']].join(' ');
|
|
1757
|
+
if (parsedColor.length === 1) {
|
|
1758
|
+
var gradientId = createOrUpdateGradient(document, object, $def, $el, parsedColor[0]);
|
|
1759
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#" + gradientId + ")");
|
|
1760
|
+
return gradientId;
|
|
1761
|
+
} else {
|
|
1762
|
+
// @see https://stackoverflow.com/questions/20671502/can-i-blend-gradients-in-svg
|
|
1763
|
+
var filterId = createOrUpdateMultiGradient(document, object, $def, $el, parsedColor);
|
|
1764
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + filterId + ")");
|
|
1765
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('fill', 'black');
|
|
1766
|
+
return filterId;
|
|
1767
|
+
}
|
|
1990
1768
|
}
|
|
1991
1769
|
|
|
1992
|
-
|
|
1770
|
+
return '';
|
|
1993
1771
|
}
|
|
1994
1772
|
|
|
1995
|
-
function
|
|
1996
|
-
|
|
1997
|
-
}
|
|
1773
|
+
function generateCacheKey(src) {
|
|
1774
|
+
var cacheKey = '';
|
|
1998
1775
|
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
1776
|
+
if (src instanceof g.CSSGradientValue) {
|
|
1777
|
+
var type = src.type,
|
|
1778
|
+
value = src.value;
|
|
1779
|
+
|
|
1780
|
+
if (type === g.GradientType.LinearGradient || type === g.GradientType.RadialGradient) {
|
|
1781
|
+
// @ts-ignore
|
|
1782
|
+
var _type = value.type,
|
|
1783
|
+
width = value.width,
|
|
1784
|
+
height = value.height,
|
|
1785
|
+
steps = value.steps,
|
|
1786
|
+
angle = value.angle,
|
|
1787
|
+
cx = value.cx,
|
|
1788
|
+
cy = value.cy;
|
|
1789
|
+
cacheKey = "" + _type + width + height + (angle || 0) + (cx || 0) + (cy || 0) + steps.map(function (step) {
|
|
1790
|
+
return step.join('');
|
|
1791
|
+
}).join('');
|
|
1792
|
+
}
|
|
1793
|
+
} else if (g.isPattern(src)) {
|
|
1794
|
+
if (g.isString(src.image)) {
|
|
1795
|
+
cacheKey = "pattern-" + src.image + "-" + src.repetition;
|
|
2010
1796
|
} else {
|
|
2011
|
-
|
|
1797
|
+
cacheKey = "pattern-" + counter;
|
|
2012
1798
|
}
|
|
2013
|
-
}
|
|
2014
|
-
}
|
|
2015
|
-
|
|
2016
|
-
var BASELINE_MAP = {
|
|
2017
|
-
top: 'before-edge',
|
|
2018
|
-
middle: 'central',
|
|
2019
|
-
bottom: 'after-edge',
|
|
2020
|
-
alphabetic: 'alphabetic',
|
|
2021
|
-
ideographic: 'ideographic',
|
|
2022
|
-
hanging: 'hanging'
|
|
2023
|
-
}; // for FireFox
|
|
2024
|
-
// @see https://github.com/plouc/nivo/issues/164
|
|
2025
|
-
|
|
2026
|
-
var BASELINE_MAP_FOR_FIREFOX = {
|
|
2027
|
-
top: 'text-before-edge',
|
|
2028
|
-
middle: 'central',
|
|
2029
|
-
bottom: 'text-after-edge',
|
|
2030
|
-
alphabetic: 'alphabetic',
|
|
2031
|
-
ideographic: 'ideographic',
|
|
2032
|
-
hanging: 'hanging'
|
|
2033
|
-
};
|
|
2034
|
-
|
|
2035
|
-
function updateTextElementAttribute($el, parsedStyle) {
|
|
2036
|
-
var textBaseline = parsedStyle.textBaseline,
|
|
2037
|
-
lineWidth = parsedStyle.lineWidth,
|
|
2038
|
-
metrics = parsedStyle.metrics,
|
|
2039
|
-
dx = parsedStyle.dx,
|
|
2040
|
-
dy = parsedStyle.dy;
|
|
2041
|
-
var browser = detect();
|
|
1799
|
+
}
|
|
2042
1800
|
|
|
2043
|
-
if (
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
$el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value]);
|
|
2048
|
-
$el.setAttribute('alignment-baseline', BASELINE_MAP[textBaseline.value]);
|
|
1801
|
+
if (cacheKey) {
|
|
1802
|
+
if (!cacheKey2IDMap[cacheKey]) {
|
|
1803
|
+
cacheKey2IDMap[cacheKey] = PATTERN_PREFIX + ("" + counter++);
|
|
1804
|
+
}
|
|
2049
1805
|
}
|
|
2050
1806
|
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
lineHeight = metrics.lineHeight,
|
|
2054
|
-
height = metrics.height;
|
|
2055
|
-
var lineNum = lines.length;
|
|
2056
|
-
$el.setAttribute('style', "transform:translate(".concat(dx.toString(), ", ").concat(dy.toString(), ");"));
|
|
1807
|
+
return cacheKey2IDMap[cacheKey];
|
|
1808
|
+
}
|
|
2057
1809
|
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
} else {
|
|
2062
|
-
$el.innerHTML = lines.map(function (line, i) {
|
|
2063
|
-
var dx = lineWidth.value / 2;
|
|
2064
|
-
var dy = 0;
|
|
1810
|
+
function createOrUpdatePattern(document, $def, object, pattern, createImage) {
|
|
1811
|
+
var patternId = generateCacheKey(pattern);
|
|
1812
|
+
var $existed = $def.querySelector("#" + patternId);
|
|
2065
1813
|
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
} else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
|
|
2071
|
-
dy = 0;
|
|
2072
|
-
} else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
|
|
2073
|
-
dy = -lineHeight * (lineNum - 1);
|
|
2074
|
-
}
|
|
2075
|
-
} else {
|
|
2076
|
-
dy = lineHeight;
|
|
2077
|
-
}
|
|
1814
|
+
if (!$existed) {
|
|
1815
|
+
var image = pattern.image,
|
|
1816
|
+
repetition = pattern.repetition;
|
|
1817
|
+
var imageURL = '';
|
|
2078
1818
|
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
1819
|
+
if (g.isString(image)) {
|
|
1820
|
+
imageURL = image;
|
|
1821
|
+
} else {
|
|
1822
|
+
if (g.isBrowser) {
|
|
1823
|
+
if (image instanceof HTMLImageElement) {
|
|
1824
|
+
imageURL = image.src;
|
|
1825
|
+
} else if (image instanceof HTMLCanvasElement) {
|
|
1826
|
+
imageURL = image.toDataURL();
|
|
1827
|
+
} else ;
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
2083
1830
|
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
1831
|
+
if (imageURL) {
|
|
1832
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/pattern
|
|
1833
|
+
var $pattern = createSVGElement('pattern', document);
|
|
1834
|
+
$pattern.setAttribute('patternUnits', 'userSpaceOnUse');
|
|
1835
|
+
var $image = createSVGElement('image', document);
|
|
1836
|
+
$pattern.appendChild($image);
|
|
1837
|
+
$pattern.id = patternId;
|
|
1838
|
+
$def.appendChild($pattern); // use href instead of xlink:href
|
|
1839
|
+
// @see https://stackoverflow.com/a/13379007
|
|
2087
1840
|
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
}
|
|
1841
|
+
$image.setAttribute('href', imageURL);
|
|
1842
|
+
var img;
|
|
2091
1843
|
|
|
2092
|
-
|
|
1844
|
+
if (createImage) {
|
|
1845
|
+
img = createImage(imageURL);
|
|
1846
|
+
} else if (g.isBrowser) {
|
|
1847
|
+
img = new window.Image();
|
|
1848
|
+
}
|
|
2093
1849
|
|
|
2094
|
-
|
|
2095
|
-
|
|
1850
|
+
if (!imageURL.match(/^data:/i)) {
|
|
1851
|
+
img.crossOrigin = 'Anonymous';
|
|
1852
|
+
$image.setAttribute('crossorigin', 'anonymous');
|
|
1853
|
+
}
|
|
2096
1854
|
|
|
2097
|
-
|
|
2098
|
-
function DefaultCreateElementContribution() {
|
|
2099
|
-
_classCallCheck$2(this, DefaultCreateElementContribution);
|
|
1855
|
+
img.src = imageURL;
|
|
2100
1856
|
|
|
2101
|
-
|
|
2102
|
-
|
|
1857
|
+
var onload = function onload() {
|
|
1858
|
+
$pattern.setAttribute('x', '0');
|
|
1859
|
+
$pattern.setAttribute('y', '0');
|
|
2103
1860
|
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
var doc = this.canvasConfig.document;
|
|
2108
|
-
var type = SHAPE2TAGS[object.nodeName] || 'g';
|
|
2109
|
-
return createSVGElement(type, doc || document);
|
|
2110
|
-
}
|
|
2111
|
-
}, {
|
|
2112
|
-
key: "shouldUpdateElementAttribute",
|
|
2113
|
-
value: function shouldUpdateElementAttribute(object, attributeName) {
|
|
2114
|
-
var nodeName = object.nodeName;
|
|
2115
|
-
return (SHAPE_UPDATE_DEPS[nodeName] || []).indexOf(attributeName) > -1;
|
|
2116
|
-
}
|
|
2117
|
-
}, {
|
|
2118
|
-
key: "updateElementAttribute",
|
|
2119
|
-
value: function updateElementAttribute(object) {
|
|
2120
|
-
// @ts-ignore
|
|
2121
|
-
var $el = object.elementSVG.$el;
|
|
2122
|
-
var nodeName = object.nodeName,
|
|
2123
|
-
parsedStyle = object.parsedStyle;
|
|
1861
|
+
var _object$getGeometryBo = object.getGeometryBounds(),
|
|
1862
|
+
halfExtents = _object$getGeometryBo.halfExtents; // There is no equivalent to CSS no-repeat for SVG patterns
|
|
1863
|
+
// @see https://stackoverflow.com/a/33481956
|
|
2124
1864
|
|
|
2125
|
-
switch (nodeName) {
|
|
2126
|
-
case g.Shape.IMAGE:
|
|
2127
|
-
{
|
|
2128
|
-
updateImageElementAttribute($el, parsedStyle);
|
|
2129
|
-
break;
|
|
2130
|
-
}
|
|
2131
1865
|
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
updateRectElementAttribute($el, parsedStyle);
|
|
2135
|
-
break;
|
|
2136
|
-
}
|
|
1866
|
+
var patternWidth = img.width;
|
|
1867
|
+
var patternHeight = img.height;
|
|
2137
1868
|
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
1869
|
+
if (repetition === 'repeat-x') {
|
|
1870
|
+
patternHeight = halfExtents[1] * 2;
|
|
1871
|
+
} else if (repetition === 'repeat-y') {
|
|
1872
|
+
patternWidth = halfExtents[0] * 2;
|
|
1873
|
+
} else if (repetition === 'no-repeat') {
|
|
1874
|
+
patternWidth = halfExtents[0] * 2;
|
|
1875
|
+
patternHeight = halfExtents[1] * 2;
|
|
1876
|
+
}
|
|
2143
1877
|
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
1878
|
+
$pattern.setAttribute('width', "" + patternWidth);
|
|
1879
|
+
$pattern.setAttribute('height', "" + patternHeight);
|
|
1880
|
+
$image.setAttribute('x', '0');
|
|
1881
|
+
$image.setAttribute('y', '0');
|
|
1882
|
+
$image.setAttribute('width', "" + img.width);
|
|
1883
|
+
$image.setAttribute('height', "" + img.height);
|
|
1884
|
+
};
|
|
2150
1885
|
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
}
|
|
1886
|
+
if (img.complete) {
|
|
1887
|
+
onload();
|
|
1888
|
+
} else {
|
|
1889
|
+
img.onload = onload; // Fix onload() bug in IE9
|
|
2156
1890
|
|
|
2157
|
-
|
|
2158
|
-
{
|
|
2159
|
-
updateTextElementAttribute($el, parsedStyle);
|
|
2160
|
-
break;
|
|
2161
|
-
}
|
|
1891
|
+
img.src = img.src;
|
|
2162
1892
|
}
|
|
2163
1893
|
}
|
|
2164
|
-
}
|
|
1894
|
+
}
|
|
2165
1895
|
|
|
2166
|
-
return
|
|
2167
|
-
}
|
|
1896
|
+
return patternId;
|
|
1897
|
+
}
|
|
2168
1898
|
|
|
2169
|
-
|
|
1899
|
+
function createOrUpdateGradient(document, object, $def, $el, parsedColor) {
|
|
1900
|
+
var gradientId = generateCacheKey(parsedColor);
|
|
1901
|
+
var $existed = $def.querySelector("#" + gradientId);
|
|
2170
1902
|
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
* use SVG filters, eg. blur, brightness, contrast...
|
|
2177
|
-
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/filter
|
|
2178
|
-
*/
|
|
1903
|
+
if (!$existed) {
|
|
1904
|
+
// <linearGradient> <radialGradient>
|
|
1905
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/linearGradient
|
|
1906
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/radialGradient
|
|
1907
|
+
$existed = createSVGElement(parsedColor.type === g.GradientType.LinearGradient ? 'linearGradient' : 'radialGradient', document); // @see https://github.com/antvis/g/issues/1025
|
|
2179
1908
|
|
|
2180
|
-
|
|
2181
|
-
// eg. filter="url(#f1) url(#f2)"
|
|
2182
|
-
var filterName = FILTER_PREFIX + object.entity;
|
|
2183
|
-
var $existedFilters = $def.querySelectorAll("[name=".concat(filterName, "]"));
|
|
1909
|
+
$existed.setAttribute('gradientUnits', 'userSpaceOnUse'); // add stops
|
|
2184
1910
|
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
1911
|
+
var innerHTML = '';
|
|
1912
|
+
parsedColor.value.steps.forEach(function (_ref) {
|
|
1913
|
+
var offset = _ref[0],
|
|
1914
|
+
color = _ref[1];
|
|
1915
|
+
innerHTML += "<stop offset=\"" + offset + "\" stop-color=\"" + color + "\"></stop>";
|
|
2188
1916
|
});
|
|
1917
|
+
$existed.innerHTML = innerHTML;
|
|
1918
|
+
$existed.id = gradientId;
|
|
1919
|
+
$def.appendChild($existed);
|
|
2189
1920
|
}
|
|
2190
1921
|
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
1922
|
+
var bounds = object.getGeometryBounds();
|
|
1923
|
+
var width = bounds && bounds.halfExtents[0] * 2 || 0;
|
|
1924
|
+
var height = bounds && bounds.halfExtents[1] * 2 || 0;
|
|
1925
|
+
|
|
1926
|
+
if (parsedColor.type === g.GradientType.LinearGradient) {
|
|
1927
|
+
var angle = parsedColor.value.angle;
|
|
1928
|
+
|
|
1929
|
+
var _computeLinearGradien = g.computeLinearGradient(width, height, angle),
|
|
1930
|
+
x1 = _computeLinearGradien.x1,
|
|
1931
|
+
y1 = _computeLinearGradien.y1,
|
|
1932
|
+
x2 = _computeLinearGradien.x2,
|
|
1933
|
+
y2 = _computeLinearGradien.y2;
|
|
1934
|
+
|
|
1935
|
+
$existed.setAttribute('x1', "" + x1);
|
|
1936
|
+
$existed.setAttribute('y1', "" + y1);
|
|
1937
|
+
$existed.setAttribute('x2', "" + x2);
|
|
1938
|
+
$existed.setAttribute('y2', "" + y2); // $existed.setAttribute('gradientTransform', `rotate(${angle})`);
|
|
2194
1939
|
} else {
|
|
2195
|
-
var
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
var $filter = createSVGElement('filter', document); // @see https://github.com/antvis/g/issues/1025
|
|
1940
|
+
var _parsedColor$value = parsedColor.value,
|
|
1941
|
+
cx = _parsedColor$value.cx,
|
|
1942
|
+
cy = _parsedColor$value.cy;
|
|
2199
1943
|
|
|
2200
|
-
|
|
1944
|
+
var _computeRadialGradien = g.computeRadialGradient(width, height, cx, cy),
|
|
1945
|
+
x = _computeRadialGradien.x,
|
|
1946
|
+
y = _computeRadialGradien.y,
|
|
1947
|
+
r = _computeRadialGradien.r;
|
|
2201
1948
|
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
} else if (name === 'drop-shadow') {
|
|
2207
|
-
createDropShadow(document, $filter, params);
|
|
2208
|
-
} else if (name === 'contrast') {
|
|
2209
|
-
createContrast(document, $filter, params);
|
|
2210
|
-
} else if (name === 'grayscale') {
|
|
2211
|
-
createGrayscale(document, $filter, params);
|
|
2212
|
-
} else if (name === 'sepia') {
|
|
2213
|
-
createSepia(document, $filter, params);
|
|
2214
|
-
} else if (name === 'saturate') {
|
|
2215
|
-
createSaturate(document, $filter, params);
|
|
2216
|
-
} else if (name === 'hue-rotate') {
|
|
2217
|
-
createHueRotate(document, $filter, params);
|
|
2218
|
-
} else if (name === 'invert') {
|
|
2219
|
-
createInvert(document, $filter, params);
|
|
2220
|
-
}
|
|
1949
|
+
$existed.setAttribute('cx', "" + x);
|
|
1950
|
+
$existed.setAttribute('cy', "" + y);
|
|
1951
|
+
$existed.setAttribute('r', "" + r);
|
|
1952
|
+
}
|
|
2221
1953
|
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
1954
|
+
return gradientId;
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
function createOrUpdateMultiGradient(document, object, $def, $el, gradients) {
|
|
1958
|
+
var filterId = FILTER_PREFIX + object.entity + '-gradient';
|
|
1959
|
+
var $existed = $def.querySelector("#" + filterId);
|
|
1960
|
+
|
|
1961
|
+
if (!$existed) {
|
|
1962
|
+
$existed = createSVGElement('filter', document);
|
|
1963
|
+
$existed.setAttribute('filterUnits', 'userSpaceOnUse'); // @see https://github.com/antvis/g/issues/1025
|
|
1964
|
+
|
|
1965
|
+
$existed.setAttribute('x', '0%');
|
|
1966
|
+
$existed.setAttribute('y', '0%');
|
|
1967
|
+
$existed.setAttribute('width', '100%');
|
|
1968
|
+
$existed.setAttribute('height', '100%');
|
|
1969
|
+
$existed.id = filterId;
|
|
1970
|
+
$def.appendChild($existed);
|
|
2230
1971
|
}
|
|
1972
|
+
/**
|
|
1973
|
+
* <rect id="wave-rect" x="0" y="0" width="100%" height="100%" fill="url(#wave)"></rect>
|
|
1974
|
+
* <filter id="blend-it" x="0%" y="0%" width="100%" height="100%">
|
|
1975
|
+
<feImage xlink:href="#wave-rect" result="myWave" x="100" y="100"/>
|
|
1976
|
+
<feImage xlink:href="#ry-rect" result="myRY" x="100" y="100"/>
|
|
1977
|
+
<feBlend in="myWave" in2="myRY" mode="multiply" result="blendedGrad"/>
|
|
1978
|
+
<feComposite in="blendedGrad" in2="SourceGraphic" operator="in"/>
|
|
1979
|
+
</filter>
|
|
1980
|
+
*/
|
|
1981
|
+
|
|
1982
|
+
|
|
1983
|
+
var blended = 0;
|
|
1984
|
+
gradients.forEach(function (gradient, i) {
|
|
1985
|
+
var gradientId = createOrUpdateGradient(document, object, $def, $el, gradient);
|
|
1986
|
+
var rectId = gradientId + '_rect';
|
|
1987
|
+
var $rect = createSVGElement('rect', document);
|
|
1988
|
+
$rect.setAttribute('x', '0');
|
|
1989
|
+
$rect.setAttribute('y', '0');
|
|
1990
|
+
$rect.setAttribute('width', '100%');
|
|
1991
|
+
$rect.setAttribute('height', '100%');
|
|
1992
|
+
$rect.setAttribute('fill', "url(#" + gradientId + ")");
|
|
1993
|
+
$rect.id = rectId;
|
|
1994
|
+
$def.appendChild($rect);
|
|
1995
|
+
var $feImage = createSVGElement('feImage', document);
|
|
1996
|
+
$feImage.setAttribute('href', "#" + rectId);
|
|
1997
|
+
$feImage.setAttribute('result', filterId + "-" + i);
|
|
1998
|
+
$existed.appendChild($feImage);
|
|
1999
|
+
|
|
2000
|
+
if (i > 0) {
|
|
2001
|
+
var $feBlend = createSVGElement('feBlend', document);
|
|
2002
|
+
$feBlend.setAttribute('in', i === 1 ? filterId + "-" + (i - 1) : filterId + "-blended-" + (blended - 1));
|
|
2003
|
+
$feBlend.setAttribute('in2', filterId + "-" + i);
|
|
2004
|
+
$feBlend.setAttribute('result', filterId + "-blended-" + blended++); // @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/blend-mode
|
|
2005
|
+
|
|
2006
|
+
$feBlend.setAttribute('mode', 'multiply');
|
|
2007
|
+
$existed.appendChild($feBlend);
|
|
2008
|
+
}
|
|
2009
|
+
});
|
|
2010
|
+
var $feComposite = createSVGElement('feComposite', document);
|
|
2011
|
+
$feComposite.setAttribute('in', filterId + "-blended-" + blended);
|
|
2012
|
+
$feComposite.setAttribute('in2', 'SourceGraphic');
|
|
2013
|
+
$feComposite.setAttribute('operator', 'in');
|
|
2014
|
+
$existed.appendChild($feComposite);
|
|
2015
|
+
return filterId;
|
|
2231
2016
|
}
|
|
2232
2017
|
|
|
2233
|
-
|
|
2234
|
-
return param.unit === g.UnitType.kPercentage ? param.value / 100 : param.value;
|
|
2235
|
-
}
|
|
2018
|
+
var FILTER_DROPSHADOW_PREFIX = 'g-filter-dropshadow-';
|
|
2236
2019
|
/**
|
|
2237
|
-
*
|
|
2020
|
+
* use SVG filters
|
|
2021
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/filter
|
|
2238
2022
|
*/
|
|
2239
2023
|
|
|
2024
|
+
function createOrUpdateShadow(document, $def, object, $el, name) {
|
|
2025
|
+
var _object$parsedStyle$s;
|
|
2240
2026
|
|
|
2241
|
-
|
|
2242
|
-
var $
|
|
2243
|
-
$feGaussianBlur.setAttribute('in', 'SourceGraphic');
|
|
2244
|
-
$feGaussianBlur.setAttribute('stdDeviation', "".concat(params[0].value));
|
|
2245
|
-
$filter.appendChild($feGaussianBlur);
|
|
2246
|
-
}
|
|
2027
|
+
var shadowId = FILTER_DROPSHADOW_PREFIX + object.entity;
|
|
2028
|
+
var $existedFilter = $def.querySelector("#" + shadowId);
|
|
2247
2029
|
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
slope = _ref2.slope,
|
|
2251
|
-
intercept = _ref2.intercept,
|
|
2252
|
-
tableValues = _ref2.tableValues;
|
|
2253
|
-
var $feComponentTransfer = createSVGElement('feComponentTransfer', document);
|
|
2254
|
-
[createSVGElement('feFuncR', document), createSVGElement('feFuncG', document), createSVGElement('feFuncB', document)].forEach(function ($feFunc) {
|
|
2255
|
-
$feFunc.setAttribute('type', type);
|
|
2030
|
+
if (!$existedFilter) {
|
|
2031
|
+
$existedFilter = createSVGElement('filter', document);
|
|
2256
2032
|
|
|
2257
|
-
|
|
2258
|
-
$feFunc.setAttribute('tableValues', "".concat(tableValues));
|
|
2259
|
-
} else {
|
|
2260
|
-
$feFunc.setAttribute('slope', "".concat(slope));
|
|
2261
|
-
$feFunc.setAttribute('intercept', "".concat(intercept));
|
|
2262
|
-
}
|
|
2033
|
+
var _$feDropShadow = createSVGElement('feDropShadow', document);
|
|
2263
2034
|
|
|
2264
|
-
$
|
|
2265
|
-
});
|
|
2266
|
-
$filter.appendChild($feComponentTransfer);
|
|
2267
|
-
}
|
|
2035
|
+
_$feDropShadow.setAttribute('dx', '0');
|
|
2268
2036
|
|
|
2269
|
-
|
|
2270
|
-
var slope = convertToAbsoluteValue(params[0]);
|
|
2271
|
-
createFeComponentTransfer(document, $filter, {
|
|
2272
|
-
type: 'linear',
|
|
2273
|
-
slope: slope,
|
|
2274
|
-
intercept: -(0.5 * slope) + 0.5
|
|
2275
|
-
});
|
|
2276
|
-
}
|
|
2037
|
+
_$feDropShadow.setAttribute('dy', '0');
|
|
2277
2038
|
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
createFeComponentTransfer(document, $filter, {
|
|
2281
|
-
type: 'table',
|
|
2282
|
-
tableValues: "".concat(amount, " ").concat(1 - amount)
|
|
2283
|
-
});
|
|
2284
|
-
}
|
|
2039
|
+
$existedFilter.appendChild(_$feDropShadow);
|
|
2040
|
+
$existedFilter.id = shadowId; // @see https://github.com/antvis/g/issues/1025
|
|
2285
2041
|
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
type: 'linear',
|
|
2290
|
-
slope: slope,
|
|
2291
|
-
intercept: 0
|
|
2292
|
-
});
|
|
2293
|
-
}
|
|
2042
|
+
$existedFilter.setAttribute('filterUnits', 'userSpaceOnUse');
|
|
2043
|
+
$def.appendChild($existedFilter);
|
|
2044
|
+
}
|
|
2294
2045
|
|
|
2295
|
-
|
|
2296
|
-
var amount = convertToAbsoluteValue(params[0]);
|
|
2297
|
-
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
2298
|
-
$feColorMatrix.setAttribute('type', 'saturate');
|
|
2299
|
-
$feColorMatrix.setAttribute('values', "".concat(amount));
|
|
2300
|
-
$filter.appendChild($feColorMatrix);
|
|
2301
|
-
}
|
|
2046
|
+
var $feDropShadow = $existedFilter.children[0];
|
|
2302
2047
|
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2048
|
+
if (name === 'shadowColor') {
|
|
2049
|
+
var parsedColor = object.parsedStyle[name];
|
|
2050
|
+
$feDropShadow.setAttribute('flood-color', parsedColor.toString());
|
|
2051
|
+
} else if (name === 'shadowBlur') {
|
|
2052
|
+
var shadowBlur = object.parsedStyle[name]; // half the blur radius
|
|
2053
|
+
// @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
|
|
2054
|
+
// @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
|
|
2309
2055
|
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2056
|
+
$feDropShadow.setAttribute('stdDeviation', "" + ((shadowBlur === null || shadowBlur === void 0 ? void 0 : shadowBlur.value) || 0) / 4);
|
|
2057
|
+
} else if (name === 'shadowOffsetX') {
|
|
2058
|
+
var shadowOffsetX = object.parsedStyle[name];
|
|
2059
|
+
$feDropShadow.setAttribute('dx', "" + ((shadowOffsetX === null || shadowOffsetX === void 0 ? void 0 : shadowOffsetX.value) || 0) / 2);
|
|
2060
|
+
} else if (name === 'shadowOffsetY') {
|
|
2061
|
+
var shadowOffsetY = object.parsedStyle[name];
|
|
2062
|
+
$feDropShadow.setAttribute('dy', "" + ((shadowOffsetY === null || shadowOffsetY === void 0 ? void 0 : shadowOffsetY.value) || 0) / 2);
|
|
2063
|
+
} // only apply shadow when blur > 0
|
|
2314
2064
|
|
|
2315
|
-
var shadowColor = params[3].formatted;
|
|
2316
|
-
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
2317
|
-
$feGaussianBlur.setAttribute('in', 'SourceAlpha');
|
|
2318
|
-
$feGaussianBlur.setAttribute('stdDeviation', "".concat(shadowBlur));
|
|
2319
|
-
$filter.appendChild($feGaussianBlur);
|
|
2320
|
-
var $feOffset = createSVGElement('feOffset', document);
|
|
2321
|
-
$feOffset.setAttribute('dx', "".concat(shadowOffsetX));
|
|
2322
|
-
$feOffset.setAttribute('dy', "".concat(shadowOffsetY));
|
|
2323
|
-
$feOffset.setAttribute('result', 'offsetblur');
|
|
2324
|
-
$filter.appendChild($feOffset);
|
|
2325
|
-
var $feFlood = createSVGElement('feFlood', document);
|
|
2326
|
-
$feFlood.setAttribute('flood-color', shadowColor);
|
|
2327
|
-
$filter.appendChild($feFlood);
|
|
2328
|
-
var $feComposite = createSVGElement('feComposite', document);
|
|
2329
|
-
$feComposite.setAttribute('in2', 'offsetblur');
|
|
2330
|
-
$feComposite.setAttribute('operator', 'in');
|
|
2331
|
-
$filter.appendChild($feComposite);
|
|
2332
|
-
var $feMerge = createSVGElement('feMerge', document);
|
|
2333
|
-
$filter.appendChild($feMerge);
|
|
2334
|
-
var $feMergeNode1 = createSVGElement('feMergeNode', document);
|
|
2335
|
-
var $feMergeNode2 = createSVGElement('feMergeNode', document);
|
|
2336
|
-
$feMergeNode2.setAttribute('in', 'SourceGraphic');
|
|
2337
|
-
$feMerge.appendChild($feMergeNode1);
|
|
2338
|
-
$feMerge.appendChild($feMergeNode2);
|
|
2339
|
-
}
|
|
2340
2065
|
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2066
|
+
if (!g.isNil(object.parsedStyle.shadowColor) && ((_object$parsedStyle$s = object.parsedStyle.shadowBlur) === null || _object$parsedStyle$s === void 0 ? void 0 : _object$parsedStyle$s.value) > 0) {
|
|
2067
|
+
// use filter <feDropShadow>
|
|
2068
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow
|
|
2069
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + shadowId + ")");
|
|
2070
|
+
} else {
|
|
2071
|
+
$el === null || $el === void 0 ? void 0 : $el.removeAttribute('filter');
|
|
2072
|
+
}
|
|
2346
2073
|
}
|
|
2347
|
-
/**
|
|
2348
|
-
* @see https://drafts.fxtf.org/filter-effects/#grayscaleEquivalent
|
|
2349
|
-
*/
|
|
2350
2074
|
|
|
2075
|
+
var urlRegexp = /url\(#(.*)\)/;
|
|
2351
2076
|
|
|
2352
|
-
function
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2077
|
+
var DefElementManager = /*#__PURE__*/function () {
|
|
2078
|
+
function DefElementManager() {
|
|
2079
|
+
this.canvasConfig = void 0;
|
|
2080
|
+
this.contextService = void 0;
|
|
2081
|
+
this.$def = void 0;
|
|
2082
|
+
this.gradientCache = {};
|
|
2083
|
+
}
|
|
2359
2084
|
|
|
2085
|
+
var _proto = DefElementManager.prototype;
|
|
2360
2086
|
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
}
|
|
2087
|
+
_proto.getDefElement = function getDefElement() {
|
|
2088
|
+
return this.$def;
|
|
2089
|
+
};
|
|
2365
2090
|
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2091
|
+
_proto.init = function init() {
|
|
2092
|
+
var document = this.canvasConfig.document;
|
|
2093
|
+
var $svg = this.contextService.getContext();
|
|
2094
|
+
this.$def = createSVGElement('defs', document);
|
|
2095
|
+
$svg.appendChild(this.$def);
|
|
2096
|
+
};
|
|
2369
2097
|
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
if (!parsedColor) {
|
|
2373
|
-
return '';
|
|
2374
|
-
}
|
|
2098
|
+
_proto.clear = function clear(entity) {
|
|
2099
|
+
var _this = this;
|
|
2375
2100
|
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
} else {
|
|
2381
|
-
// constant value, eg. '#fff'
|
|
2382
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, parsedColor.isNone ? 'none' : parsedColor.toString());
|
|
2383
|
-
}
|
|
2384
|
-
} else if (g.isPattern(parsedColor)) {
|
|
2385
|
-
var patternId = createOrUpdatePattern(document, $def, object, parsedColor, createImage); // use style instead of attribute when applying <pattern>
|
|
2386
|
-
// @see https://stackoverflow.com/a/7723115
|
|
2101
|
+
Object.keys(this.gradientCache).forEach(function (id) {
|
|
2102
|
+
_this.clearUnusedDefElement(_this.gradientCache, id, entity);
|
|
2103
|
+
});
|
|
2104
|
+
};
|
|
2387
2105
|
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
} else {
|
|
2396
|
-
// @see https://stackoverflow.com/questions/20671502/can-i-blend-gradients-in-svg
|
|
2397
|
-
var filterId = createOrUpdateMultiGradient(document, object, $def, $el, parsedColor);
|
|
2398
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#".concat(filterId, ")"));
|
|
2399
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute('fill', 'black');
|
|
2400
|
-
return filterId;
|
|
2106
|
+
_proto.clearUnusedDefElement = function clearUnusedDefElement(cache, id, entity) {
|
|
2107
|
+
if (cache[id].size === 1 && cache[id].has(entity)) {
|
|
2108
|
+
var targetElement = this.$def.querySelector("#" + id);
|
|
2109
|
+
|
|
2110
|
+
if (targetElement) {
|
|
2111
|
+
this.$def.removeChild(targetElement);
|
|
2112
|
+
}
|
|
2401
2113
|
}
|
|
2402
|
-
}
|
|
2114
|
+
};
|
|
2403
2115
|
|
|
2404
|
-
|
|
2405
|
-
|
|
2116
|
+
_proto.createOrUpdateGradientAndPattern = function createOrUpdateGradientAndPattern$1(object, $el, parsedColor, name) {
|
|
2117
|
+
var _this$canvasConfig = this.canvasConfig,
|
|
2118
|
+
doc = _this$canvasConfig.document,
|
|
2119
|
+
createImage = _this$canvasConfig.createImage;
|
|
2406
2120
|
|
|
2407
|
-
|
|
2408
|
-
|
|
2121
|
+
if ($el) {
|
|
2122
|
+
var _$el$getAttribute; // `url(#${gradientId})`
|
|
2409
2123
|
|
|
2410
|
-
if (src instanceof g.CSSGradientValue) {
|
|
2411
|
-
var type = src.type,
|
|
2412
|
-
value = src.value;
|
|
2413
2124
|
|
|
2414
|
-
|
|
2415
|
-
// @ts-ignore
|
|
2416
|
-
var _type = value.type,
|
|
2417
|
-
width = value.width,
|
|
2418
|
-
height = value.height,
|
|
2419
|
-
steps = value.steps,
|
|
2420
|
-
angle = value.angle,
|
|
2421
|
-
cx = value.cx,
|
|
2422
|
-
cy = value.cy;
|
|
2423
|
-
cacheKey = "".concat(_type).concat(width).concat(height).concat(angle || 0).concat(cx || 0).concat(cy || 0).concat(steps.map(function (step) {
|
|
2424
|
-
return step.join('');
|
|
2425
|
-
}).join(''));
|
|
2426
|
-
}
|
|
2427
|
-
} else if (g.isPattern(src)) {
|
|
2428
|
-
if (g.isString(src.image)) {
|
|
2429
|
-
cacheKey = "pattern-".concat(src.image, "-").concat(src.repetition);
|
|
2430
|
-
} else {
|
|
2431
|
-
cacheKey = "pattern-".concat(counter);
|
|
2432
|
-
}
|
|
2433
|
-
}
|
|
2125
|
+
var matches = (_$el$getAttribute = $el.getAttribute(name)) === null || _$el$getAttribute === void 0 ? void 0 : _$el$getAttribute.match(urlRegexp);
|
|
2434
2126
|
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2127
|
+
if (matches && matches.length > 1) {
|
|
2128
|
+
this.clearUnusedDefElement(this.gradientCache, matches[1], object.entity);
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
var newDefElementId = createOrUpdateGradientAndPattern(doc || document, this.$def, object, $el, parsedColor, name, createImage);
|
|
2132
|
+
|
|
2133
|
+
if (!this.gradientCache[newDefElementId]) {
|
|
2134
|
+
this.gradientCache[newDefElementId] = new Set();
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
this.gradientCache[newDefElementId].add(object.entity);
|
|
2438
2138
|
}
|
|
2439
|
-
}
|
|
2139
|
+
};
|
|
2440
2140
|
|
|
2441
|
-
|
|
2442
|
-
|
|
2141
|
+
_proto.createOrUpdateShadow = function createOrUpdateShadow$1(object, $el, name) {
|
|
2142
|
+
var doc = this.canvasConfig.document;
|
|
2143
|
+
createOrUpdateShadow(doc || document, this.$def, object, $el, name);
|
|
2144
|
+
};
|
|
2443
2145
|
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2146
|
+
_proto.createOrUpdateFilter = function createOrUpdateFilter$1(object, $el, filters) {
|
|
2147
|
+
var doc = this.canvasConfig.document;
|
|
2148
|
+
createOrUpdateFilter(doc || document, this.$def, object, $el, filters);
|
|
2149
|
+
};
|
|
2447
2150
|
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
repetition = pattern.repetition;
|
|
2451
|
-
var imageURL = '';
|
|
2151
|
+
return DefElementManager;
|
|
2152
|
+
}();
|
|
2452
2153
|
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2154
|
+
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], DefElementManager.prototype, "canvasConfig", void 0);
|
|
2155
|
+
|
|
2156
|
+
__decorate([g.inject(g.ContextService), __metadata("design:type", Object)], DefElementManager.prototype, "contextService", void 0);
|
|
2157
|
+
|
|
2158
|
+
DefElementManager = __decorate([g.singleton()], DefElementManager);
|
|
2159
|
+
|
|
2160
|
+
function _regeneratorRuntime$2() {
|
|
2161
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
2162
|
+
_regeneratorRuntime$2 = function _regeneratorRuntime() {
|
|
2163
|
+
return exports;
|
|
2164
|
+
};
|
|
2165
|
+
|
|
2166
|
+
var exports = {},
|
|
2167
|
+
Op = Object.prototype,
|
|
2168
|
+
hasOwn = Op.hasOwnProperty,
|
|
2169
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
2170
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
2171
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
2172
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
2464
2173
|
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
// @see https://stackoverflow.com/a/13379007
|
|
2174
|
+
function define(obj, key, value) {
|
|
2175
|
+
return Object.defineProperty(obj, key, {
|
|
2176
|
+
value: value,
|
|
2177
|
+
enumerable: !0,
|
|
2178
|
+
configurable: !0,
|
|
2179
|
+
writable: !0
|
|
2180
|
+
}), obj[key];
|
|
2181
|
+
}
|
|
2474
2182
|
|
|
2475
|
-
|
|
2476
|
-
|
|
2183
|
+
try {
|
|
2184
|
+
define({}, "");
|
|
2185
|
+
} catch (err) {
|
|
2186
|
+
define = function define(obj, key, value) {
|
|
2187
|
+
return obj[key] = value;
|
|
2188
|
+
};
|
|
2189
|
+
}
|
|
2477
2190
|
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2191
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
2192
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
2193
|
+
generator = Object.create(protoGenerator.prototype),
|
|
2194
|
+
context = new Context(tryLocsList || []);
|
|
2195
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
2196
|
+
var state = "suspendedStart";
|
|
2197
|
+
return function (method, arg) {
|
|
2198
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
2483
2199
|
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2200
|
+
if ("completed" === state) {
|
|
2201
|
+
if ("throw" === method) throw arg;
|
|
2202
|
+
return doneResult();
|
|
2203
|
+
}
|
|
2488
2204
|
|
|
2489
|
-
|
|
2205
|
+
for (context.method = method, context.arg = arg;;) {
|
|
2206
|
+
var delegate = context.delegate;
|
|
2490
2207
|
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
$pattern.setAttribute('y', '0');
|
|
2208
|
+
if (delegate) {
|
|
2209
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
2494
2210
|
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2211
|
+
if (delegateResult) {
|
|
2212
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
2213
|
+
return delegateResult;
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2498
2216
|
|
|
2217
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
2218
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
2219
|
+
context.dispatchException(context.arg);
|
|
2220
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
2221
|
+
state = "executing";
|
|
2222
|
+
var record = tryCatch(innerFn, self, context);
|
|
2499
2223
|
|
|
2500
|
-
|
|
2501
|
-
|
|
2224
|
+
if ("normal" === record.type) {
|
|
2225
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
2226
|
+
return {
|
|
2227
|
+
value: record.arg,
|
|
2228
|
+
done: context.done
|
|
2229
|
+
};
|
|
2230
|
+
}
|
|
2502
2231
|
|
|
2503
|
-
|
|
2504
|
-
patternHeight = halfExtents[1] * 2;
|
|
2505
|
-
} else if (repetition === 'repeat-y') {
|
|
2506
|
-
patternWidth = halfExtents[0] * 2;
|
|
2507
|
-
} else if (repetition === 'no-repeat') {
|
|
2508
|
-
patternWidth = halfExtents[0] * 2;
|
|
2509
|
-
patternHeight = halfExtents[1] * 2;
|
|
2232
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
2510
2233
|
}
|
|
2511
|
-
|
|
2512
|
-
$pattern.setAttribute('width', "".concat(patternWidth));
|
|
2513
|
-
$pattern.setAttribute('height', "".concat(patternHeight));
|
|
2514
|
-
$image.setAttribute('x', '0');
|
|
2515
|
-
$image.setAttribute('y', '0');
|
|
2516
|
-
$image.setAttribute('width', "".concat(img.width));
|
|
2517
|
-
$image.setAttribute('height', "".concat(img.height));
|
|
2518
2234
|
};
|
|
2235
|
+
}(innerFn, self, context), generator;
|
|
2236
|
+
}
|
|
2519
2237
|
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2238
|
+
function tryCatch(fn, obj, arg) {
|
|
2239
|
+
try {
|
|
2240
|
+
return {
|
|
2241
|
+
type: "normal",
|
|
2242
|
+
arg: fn.call(obj, arg)
|
|
2243
|
+
};
|
|
2244
|
+
} catch (err) {
|
|
2245
|
+
return {
|
|
2246
|
+
type: "throw",
|
|
2247
|
+
arg: err
|
|
2248
|
+
};
|
|
2527
2249
|
}
|
|
2528
2250
|
}
|
|
2529
2251
|
|
|
2530
|
-
|
|
2531
|
-
|
|
2252
|
+
exports.wrap = wrap;
|
|
2253
|
+
var ContinueSentinel = {};
|
|
2532
2254
|
|
|
2533
|
-
|
|
2534
|
-
var gradientId = generateCacheKey(parsedColor);
|
|
2535
|
-
var $existed = $def.querySelector("#".concat(gradientId));
|
|
2255
|
+
function Generator() {}
|
|
2536
2256
|
|
|
2537
|
-
|
|
2538
|
-
// <linearGradient> <radialGradient>
|
|
2539
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/linearGradient
|
|
2540
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/radialGradient
|
|
2541
|
-
$existed = createSVGElement(parsedColor.type === g.GradientType.LinearGradient ? 'linearGradient' : 'radialGradient', document); // @see https://github.com/antvis/g/issues/1025
|
|
2257
|
+
function GeneratorFunction() {}
|
|
2542
2258
|
|
|
2543
|
-
|
|
2259
|
+
function GeneratorFunctionPrototype() {}
|
|
2544
2260
|
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2261
|
+
var IteratorPrototype = {};
|
|
2262
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
2263
|
+
return this;
|
|
2264
|
+
});
|
|
2265
|
+
var getProto = Object.getPrototypeOf,
|
|
2266
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
2267
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
2268
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
2550
2269
|
|
|
2551
|
-
|
|
2270
|
+
function defineIteratorMethods(prototype) {
|
|
2271
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
2272
|
+
define(prototype, method, function (arg) {
|
|
2273
|
+
return this._invoke(method, arg);
|
|
2274
|
+
});
|
|
2552
2275
|
});
|
|
2553
|
-
$existed.innerHTML = innerHTML;
|
|
2554
|
-
$existed.id = gradientId;
|
|
2555
|
-
$def.appendChild($existed);
|
|
2556
2276
|
}
|
|
2557
2277
|
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
if (parsedColor.type === g.GradientType.LinearGradient) {
|
|
2563
|
-
var angle = parsedColor.value.angle;
|
|
2564
|
-
|
|
2565
|
-
var _computeLinearGradien = g.computeLinearGradient(width, height, angle),
|
|
2566
|
-
x1 = _computeLinearGradien.x1,
|
|
2567
|
-
y1 = _computeLinearGradien.y1,
|
|
2568
|
-
x2 = _computeLinearGradien.x2,
|
|
2569
|
-
y2 = _computeLinearGradien.y2;
|
|
2570
|
-
|
|
2571
|
-
$existed.setAttribute('x1', "".concat(x1));
|
|
2572
|
-
$existed.setAttribute('y1', "".concat(y1));
|
|
2573
|
-
$existed.setAttribute('x2', "".concat(x2));
|
|
2574
|
-
$existed.setAttribute('y2', "".concat(y2)); // $existed.setAttribute('gradientTransform', `rotate(${angle})`);
|
|
2575
|
-
} else {
|
|
2576
|
-
var _parsedColor$value = parsedColor.value,
|
|
2577
|
-
cx = _parsedColor$value.cx,
|
|
2578
|
-
cy = _parsedColor$value.cy;
|
|
2579
|
-
|
|
2580
|
-
var _computeRadialGradien = g.computeRadialGradient(width, height, cx, cy),
|
|
2581
|
-
x = _computeRadialGradien.x,
|
|
2582
|
-
y = _computeRadialGradien.y,
|
|
2583
|
-
r = _computeRadialGradien.r;
|
|
2278
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
2279
|
+
function invoke(method, arg, resolve, reject) {
|
|
2280
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
2584
2281
|
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2282
|
+
if ("throw" !== record.type) {
|
|
2283
|
+
var result = record.arg,
|
|
2284
|
+
value = result.value;
|
|
2285
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
2286
|
+
invoke("next", value, resolve, reject);
|
|
2287
|
+
}, function (err) {
|
|
2288
|
+
invoke("throw", err, resolve, reject);
|
|
2289
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
2290
|
+
result.value = unwrapped, resolve(result);
|
|
2291
|
+
}, function (error) {
|
|
2292
|
+
return invoke("throw", error, resolve, reject);
|
|
2293
|
+
});
|
|
2294
|
+
}
|
|
2589
2295
|
|
|
2590
|
-
|
|
2591
|
-
|
|
2296
|
+
reject(record.arg);
|
|
2297
|
+
}
|
|
2592
2298
|
|
|
2593
|
-
|
|
2594
|
-
var filterId = FILTER_PREFIX + object.entity + '-gradient';
|
|
2595
|
-
var $existed = $def.querySelector("#".concat(filterId));
|
|
2299
|
+
var previousPromise;
|
|
2596
2300
|
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2301
|
+
this._invoke = function (method, arg) {
|
|
2302
|
+
function callInvokeWithMethodAndArg() {
|
|
2303
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
2304
|
+
invoke(method, arg, resolve, reject);
|
|
2305
|
+
});
|
|
2306
|
+
}
|
|
2600
2307
|
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
$existed.setAttribute('width', '100%');
|
|
2604
|
-
$existed.setAttribute('height', '100%');
|
|
2605
|
-
$existed.id = filterId;
|
|
2606
|
-
$def.appendChild($existed);
|
|
2308
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
2309
|
+
};
|
|
2607
2310
|
}
|
|
2608
|
-
/**
|
|
2609
|
-
* <rect id="wave-rect" x="0" y="0" width="100%" height="100%" fill="url(#wave)"></rect>
|
|
2610
|
-
* <filter id="blend-it" x="0%" y="0%" width="100%" height="100%">
|
|
2611
|
-
<feImage xlink:href="#wave-rect" result="myWave" x="100" y="100"/>
|
|
2612
|
-
<feImage xlink:href="#ry-rect" result="myRY" x="100" y="100"/>
|
|
2613
|
-
<feBlend in="myWave" in2="myRY" mode="multiply" result="blendedGrad"/>
|
|
2614
|
-
<feComposite in="blendedGrad" in2="SourceGraphic" operator="in"/>
|
|
2615
|
-
</filter>
|
|
2616
|
-
*/
|
|
2617
2311
|
|
|
2312
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
2313
|
+
var method = delegate.iterator[context.method];
|
|
2618
2314
|
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
$rect.setAttribute('x', '0');
|
|
2625
|
-
$rect.setAttribute('y', '0');
|
|
2626
|
-
$rect.setAttribute('width', '100%');
|
|
2627
|
-
$rect.setAttribute('height', '100%');
|
|
2628
|
-
$rect.setAttribute('fill', "url(#".concat(gradientId, ")"));
|
|
2629
|
-
$rect.id = rectId;
|
|
2630
|
-
$def.appendChild($rect);
|
|
2631
|
-
var $feImage = createSVGElement('feImage', document);
|
|
2632
|
-
$feImage.setAttribute('href', "#".concat(rectId));
|
|
2633
|
-
$feImage.setAttribute('result', "".concat(filterId, "-").concat(i));
|
|
2634
|
-
$existed.appendChild($feImage);
|
|
2635
|
-
|
|
2636
|
-
if (i > 0) {
|
|
2637
|
-
var $feBlend = createSVGElement('feBlend', document);
|
|
2638
|
-
$feBlend.setAttribute('in', i === 1 ? "".concat(filterId, "-").concat(i - 1) : "".concat(filterId, "-blended-").concat(blended - 1));
|
|
2639
|
-
$feBlend.setAttribute('in2', "".concat(filterId, "-").concat(i));
|
|
2640
|
-
$feBlend.setAttribute('result', "".concat(filterId, "-blended-").concat(blended++)); // @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/blend-mode
|
|
2315
|
+
if (undefined === method) {
|
|
2316
|
+
if (context.delegate = null, "throw" === context.method) {
|
|
2317
|
+
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
2318
|
+
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
2319
|
+
}
|
|
2641
2320
|
|
|
2642
|
-
|
|
2643
|
-
$existed.appendChild($feBlend);
|
|
2321
|
+
return ContinueSentinel;
|
|
2644
2322
|
}
|
|
2645
|
-
});
|
|
2646
|
-
var $feComposite = createSVGElement('feComposite', document);
|
|
2647
|
-
$feComposite.setAttribute('in', "".concat(filterId, "-blended-").concat(blended));
|
|
2648
|
-
$feComposite.setAttribute('in2', 'SourceGraphic');
|
|
2649
|
-
$feComposite.setAttribute('operator', 'in');
|
|
2650
|
-
$existed.appendChild($feComposite);
|
|
2651
|
-
return filterId;
|
|
2652
|
-
}
|
|
2653
2323
|
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2324
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
2325
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
2326
|
+
var info = record.arg;
|
|
2327
|
+
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
2328
|
+
}
|
|
2659
2329
|
|
|
2660
|
-
|
|
2661
|
-
|
|
2330
|
+
function pushTryEntry(locs) {
|
|
2331
|
+
var entry = {
|
|
2332
|
+
tryLoc: locs[0]
|
|
2333
|
+
};
|
|
2334
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
2335
|
+
}
|
|
2662
2336
|
|
|
2663
|
-
|
|
2664
|
-
|
|
2337
|
+
function resetTryEntry(entry) {
|
|
2338
|
+
var record = entry.completion || {};
|
|
2339
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
2340
|
+
}
|
|
2665
2341
|
|
|
2666
|
-
|
|
2667
|
-
|
|
2342
|
+
function Context(tryLocsList) {
|
|
2343
|
+
this.tryEntries = [{
|
|
2344
|
+
tryLoc: "root"
|
|
2345
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
2346
|
+
}
|
|
2668
2347
|
|
|
2669
|
-
|
|
2348
|
+
function values(iterable) {
|
|
2349
|
+
if (iterable) {
|
|
2350
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
2351
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
2352
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
2670
2353
|
|
|
2671
|
-
|
|
2354
|
+
if (!isNaN(iterable.length)) {
|
|
2355
|
+
var i = -1,
|
|
2356
|
+
next = function next() {
|
|
2357
|
+
for (; ++i < iterable.length;) {
|
|
2358
|
+
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
2359
|
+
}
|
|
2672
2360
|
|
|
2673
|
-
|
|
2361
|
+
return next.value = undefined, next.done = !0, next;
|
|
2362
|
+
};
|
|
2674
2363
|
|
|
2675
|
-
|
|
2676
|
-
|
|
2364
|
+
return next.next = next;
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2677
2367
|
|
|
2678
|
-
|
|
2679
|
-
|
|
2368
|
+
return {
|
|
2369
|
+
next: doneResult
|
|
2370
|
+
};
|
|
2680
2371
|
}
|
|
2681
2372
|
|
|
2682
|
-
|
|
2373
|
+
function doneResult() {
|
|
2374
|
+
return {
|
|
2375
|
+
value: undefined,
|
|
2376
|
+
done: !0
|
|
2377
|
+
};
|
|
2378
|
+
}
|
|
2683
2379
|
|
|
2684
|
-
|
|
2685
|
-
var
|
|
2686
|
-
|
|
2687
|
-
}
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2380
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
2381
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
2382
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
2383
|
+
}, exports.mark = function (genFun) {
|
|
2384
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
2385
|
+
}, exports.awrap = function (arg) {
|
|
2386
|
+
return {
|
|
2387
|
+
__await: arg
|
|
2388
|
+
};
|
|
2389
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
2390
|
+
return this;
|
|
2391
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
2392
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
2393
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
2394
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
2395
|
+
return result.done ? result.value : iter.next();
|
|
2396
|
+
});
|
|
2397
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
2398
|
+
return this;
|
|
2399
|
+
}), define(Gp, "toString", function () {
|
|
2400
|
+
return "[object Generator]";
|
|
2401
|
+
}), exports.keys = function (object) {
|
|
2402
|
+
var keys = [];
|
|
2691
2403
|
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
$feDropShadow.setAttribute('dx', "".concat(((shadowOffsetX === null || shadowOffsetX === void 0 ? void 0 : shadowOffsetX.value) || 0) / 2));
|
|
2696
|
-
} else if (name === 'shadowOffsetY') {
|
|
2697
|
-
var shadowOffsetY = object.parsedStyle[name];
|
|
2698
|
-
$feDropShadow.setAttribute('dy', "".concat(((shadowOffsetY === null || shadowOffsetY === void 0 ? void 0 : shadowOffsetY.value) || 0) / 2));
|
|
2699
|
-
} // only apply shadow when blur > 0
|
|
2404
|
+
for (var key in object) {
|
|
2405
|
+
keys.push(key);
|
|
2406
|
+
}
|
|
2700
2407
|
|
|
2408
|
+
return keys.reverse(), function next() {
|
|
2409
|
+
for (; keys.length;) {
|
|
2410
|
+
var key = keys.pop();
|
|
2411
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
2412
|
+
}
|
|
2701
2413
|
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2414
|
+
return next.done = !0, next;
|
|
2415
|
+
};
|
|
2416
|
+
}, exports.values = values, Context.prototype = {
|
|
2417
|
+
constructor: Context,
|
|
2418
|
+
reset: function reset(skipTempReset) {
|
|
2419
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
|
|
2420
|
+
"t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
2421
|
+
}
|
|
2422
|
+
},
|
|
2423
|
+
stop: function stop() {
|
|
2424
|
+
this.done = !0;
|
|
2425
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
2426
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
2427
|
+
return this.rval;
|
|
2428
|
+
},
|
|
2429
|
+
dispatchException: function dispatchException(exception) {
|
|
2430
|
+
if (this.done) throw exception;
|
|
2431
|
+
var context = this;
|
|
2710
2432
|
|
|
2711
|
-
|
|
2433
|
+
function handle(loc, caught) {
|
|
2434
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
2435
|
+
}
|
|
2712
2436
|
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2437
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
2438
|
+
var entry = this.tryEntries[i],
|
|
2439
|
+
record = entry.completion;
|
|
2440
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
2716
2441
|
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
this.gradientCache = {};
|
|
2721
|
-
}
|
|
2442
|
+
if (entry.tryLoc <= this.prev) {
|
|
2443
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
2444
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
2722
2445
|
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
value: function clear(entity) {
|
|
2739
|
-
var _this = this;
|
|
2446
|
+
if (hasCatch && hasFinally) {
|
|
2447
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
2448
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
2449
|
+
} else if (hasCatch) {
|
|
2450
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
2451
|
+
} else {
|
|
2452
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
2453
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
},
|
|
2458
|
+
abrupt: function abrupt(type, arg) {
|
|
2459
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
2460
|
+
var entry = this.tryEntries[i];
|
|
2740
2461
|
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
}
|
|
2745
|
-
}, {
|
|
2746
|
-
key: "clearUnusedDefElement",
|
|
2747
|
-
value: function clearUnusedDefElement(cache, id, entity) {
|
|
2748
|
-
if (cache[id].size === 1 && cache[id].has(entity)) {
|
|
2749
|
-
var targetElement = this.$def.querySelector("#".concat(id));
|
|
2750
|
-
|
|
2751
|
-
if (targetElement) {
|
|
2752
|
-
this.$def.removeChild(targetElement);
|
|
2462
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
2463
|
+
var finallyEntry = entry;
|
|
2464
|
+
break;
|
|
2753
2465
|
}
|
|
2754
2466
|
}
|
|
2755
|
-
}
|
|
2756
|
-
}, {
|
|
2757
|
-
key: "createOrUpdateGradientAndPattern",
|
|
2758
|
-
value: function createOrUpdateGradientAndPattern$1(object, $el, parsedColor, name) {
|
|
2759
|
-
var _this$canvasConfig = this.canvasConfig,
|
|
2760
|
-
doc = _this$canvasConfig.document,
|
|
2761
|
-
createImage = _this$canvasConfig.createImage;
|
|
2762
2467
|
|
|
2763
|
-
|
|
2764
|
-
|
|
2468
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
2469
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
2470
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
2471
|
+
},
|
|
2472
|
+
complete: function complete(record, afterLoc) {
|
|
2473
|
+
if ("throw" === record.type) throw record.arg;
|
|
2474
|
+
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
2475
|
+
},
|
|
2476
|
+
finish: function finish(finallyLoc) {
|
|
2477
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
2478
|
+
var entry = this.tryEntries[i];
|
|
2479
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
2480
|
+
}
|
|
2481
|
+
},
|
|
2482
|
+
catch: function _catch(tryLoc) {
|
|
2483
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
2484
|
+
var entry = this.tryEntries[i];
|
|
2765
2485
|
|
|
2486
|
+
if (entry.tryLoc === tryLoc) {
|
|
2487
|
+
var record = entry.completion;
|
|
2766
2488
|
|
|
2767
|
-
|
|
2489
|
+
if ("throw" === record.type) {
|
|
2490
|
+
var thrown = record.arg;
|
|
2491
|
+
resetTryEntry(entry);
|
|
2492
|
+
}
|
|
2768
2493
|
|
|
2769
|
-
|
|
2770
|
-
this.clearUnusedDefElement(this.gradientCache, matches[1], object.entity);
|
|
2494
|
+
return thrown;
|
|
2771
2495
|
}
|
|
2496
|
+
}
|
|
2772
2497
|
|
|
2773
|
-
|
|
2498
|
+
throw new Error("illegal catch attempt");
|
|
2499
|
+
},
|
|
2500
|
+
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
2501
|
+
return this.delegate = {
|
|
2502
|
+
iterator: values(iterable),
|
|
2503
|
+
resultName: resultName,
|
|
2504
|
+
nextLoc: nextLoc
|
|
2505
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
2506
|
+
}
|
|
2507
|
+
}, exports;
|
|
2508
|
+
}
|
|
2774
2509
|
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2510
|
+
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2511
|
+
try {
|
|
2512
|
+
var info = gen[key](arg);
|
|
2513
|
+
var value = info.value;
|
|
2514
|
+
} catch (error) {
|
|
2515
|
+
reject(error);
|
|
2516
|
+
return;
|
|
2517
|
+
}
|
|
2778
2518
|
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
var doc = this.canvasConfig.document;
|
|
2786
|
-
createOrUpdateShadow(doc || document, this.$def, object, $el, name);
|
|
2787
|
-
}
|
|
2788
|
-
}, {
|
|
2789
|
-
key: "createOrUpdateFilter",
|
|
2790
|
-
value: function createOrUpdateFilter$1(object, $el, filters) {
|
|
2791
|
-
var doc = this.canvasConfig.document;
|
|
2792
|
-
createOrUpdateFilter(doc || document, this.$def, object, $el, filters);
|
|
2793
|
-
}
|
|
2794
|
-
}]);
|
|
2519
|
+
if (info.done) {
|
|
2520
|
+
resolve(value);
|
|
2521
|
+
} else {
|
|
2522
|
+
Promise.resolve(value).then(_next, _throw);
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2795
2525
|
|
|
2796
|
-
|
|
2797
|
-
|
|
2526
|
+
function _asyncToGenerator$2(fn) {
|
|
2527
|
+
return function () {
|
|
2528
|
+
var self = this,
|
|
2529
|
+
args = arguments;
|
|
2530
|
+
return new Promise(function (resolve, reject) {
|
|
2531
|
+
var gen = fn.apply(self, args);
|
|
2798
2532
|
|
|
2799
|
-
|
|
2533
|
+
function _next(value) {
|
|
2534
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
2535
|
+
}
|
|
2800
2536
|
|
|
2801
|
-
|
|
2537
|
+
function _throw(err) {
|
|
2538
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2539
|
+
}
|
|
2802
2540
|
|
|
2803
|
-
|
|
2541
|
+
_next(undefined);
|
|
2542
|
+
});
|
|
2543
|
+
};
|
|
2544
|
+
}
|
|
2804
2545
|
/**
|
|
2805
2546
|
* Common utilities
|
|
2806
2547
|
* @module glMatrix
|
|
2807
2548
|
*/
|
|
2808
2549
|
// Configuration Constants
|
|
2809
2550
|
|
|
2551
|
+
|
|
2810
2552
|
var EPSILON = 0.000001;
|
|
2811
2553
|
var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
|
|
2812
2554
|
if (!Math.hypot) Math.hypot = function () {
|
|
@@ -3543,8 +3285,6 @@
|
|
|
3543
3285
|
var CLIP_PATH_PREFIX = 'clip-path-';
|
|
3544
3286
|
var SVGRendererPlugin = SVGRendererPlugin_1 = (_class$1 = /*#__PURE__*/function () {
|
|
3545
3287
|
function SVGRendererPlugin() {
|
|
3546
|
-
_classCallCheck$2(this, SVGRendererPlugin);
|
|
3547
|
-
|
|
3548
3288
|
this.canvasConfig = void 0;
|
|
3549
3289
|
this.camera = void 0;
|
|
3550
3290
|
this.contextService = void 0;
|
|
@@ -3556,527 +3296,524 @@
|
|
|
3556
3296
|
this.pendingReorderQueue = new Set();
|
|
3557
3297
|
}
|
|
3558
3298
|
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3299
|
+
var _proto = SVGRendererPlugin.prototype;
|
|
3300
|
+
|
|
3301
|
+
_proto.apply = function apply(renderingService) {
|
|
3302
|
+
var _this = this;
|
|
3303
|
+
|
|
3304
|
+
var document = this.canvasConfig.document;
|
|
3563
3305
|
|
|
3564
|
-
|
|
3306
|
+
var handleMounted = function handleMounted(e) {
|
|
3307
|
+
var object = e.target; // create SVG DOM Node
|
|
3308
|
+
|
|
3309
|
+
_this.createSVGDom(document, object, _this.$camera);
|
|
3310
|
+
};
|
|
3311
|
+
|
|
3312
|
+
var handleUnmounted = function handleUnmounted(e) {
|
|
3313
|
+
var object = e.target;
|
|
3314
|
+
|
|
3315
|
+
_this.defElementManager.clear(object.entity);
|
|
3316
|
+
|
|
3317
|
+
_this.removeSVGDom(object);
|
|
3318
|
+
};
|
|
3319
|
+
|
|
3320
|
+
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
3321
|
+
var object = e.target; // @see https://github.com/antvis/g/issues/994
|
|
3322
|
+
// @ts-ignore
|
|
3565
3323
|
|
|
3566
|
-
|
|
3567
|
-
|
|
3324
|
+
if (!object.elementSVG) {
|
|
3325
|
+
return;
|
|
3326
|
+
}
|
|
3568
3327
|
|
|
3569
|
-
|
|
3570
|
-
};
|
|
3328
|
+
var attrName = e.attrName;
|
|
3571
3329
|
|
|
3572
|
-
|
|
3573
|
-
var
|
|
3330
|
+
if (attrName === 'zIndex') {
|
|
3331
|
+
var _object$parentNode, _object$parentNode$el;
|
|
3574
3332
|
|
|
3575
|
-
|
|
3333
|
+
var parent = object.parentNode; // @ts-ignore
|
|
3576
3334
|
|
|
3577
|
-
|
|
3578
|
-
|
|
3335
|
+
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;
|
|
3336
|
+
var children = ((parent === null || parent === void 0 ? void 0 : parent.children) || []).slice();
|
|
3579
3337
|
|
|
3580
|
-
|
|
3581
|
-
|
|
3338
|
+
if ($groupEl) {
|
|
3339
|
+
_this.reorderChildren(document, $groupEl, children);
|
|
3340
|
+
}
|
|
3341
|
+
} else if (attrName === 'increasedLineWidthForHitTesting') {
|
|
3582
3342
|
// @ts-ignore
|
|
3343
|
+
var svgElement = object.elementSVG;
|
|
3583
3344
|
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
}
|
|
3345
|
+
_this.createOrUpdateHitArea(object, svgElement.$el, svgElement.$groupEl);
|
|
3346
|
+
}
|
|
3587
3347
|
|
|
3588
|
-
|
|
3348
|
+
_this.updateAttribute(object, [attrName]);
|
|
3349
|
+
};
|
|
3589
3350
|
|
|
3590
|
-
|
|
3591
|
-
|
|
3351
|
+
var handleGeometryBoundsChanged = function handleGeometryBoundsChanged(e) {
|
|
3352
|
+
var _object$elementSVG;
|
|
3592
3353
|
|
|
3593
|
-
|
|
3354
|
+
var object = e.target; // @ts-ignore
|
|
3594
3355
|
|
|
3595
|
-
|
|
3596
|
-
|
|
3356
|
+
var $el = (_object$elementSVG = object.elementSVG) === null || _object$elementSVG === void 0 ? void 0 : _object$elementSVG.$el;
|
|
3357
|
+
var _object$parsedStyle = object.parsedStyle,
|
|
3358
|
+
fill = _object$parsedStyle.fill,
|
|
3359
|
+
stroke = _object$parsedStyle.stroke;
|
|
3597
3360
|
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
} else if (attrName === 'increasedLineWidthForHitTesting') {
|
|
3602
|
-
// @ts-ignore
|
|
3603
|
-
var svgElement = object.elementSVG;
|
|
3361
|
+
if (fill && !(fill instanceof g.CSSRGB)) {
|
|
3362
|
+
_this.defElementManager.createOrUpdateGradientAndPattern(object, $el, fill, 'fill');
|
|
3363
|
+
}
|
|
3604
3364
|
|
|
3605
|
-
|
|
3606
|
-
|
|
3365
|
+
if (stroke && !(stroke instanceof g.CSSRGB)) {
|
|
3366
|
+
_this.defElementManager.createOrUpdateGradientAndPattern(object, $el, stroke, 'stroke');
|
|
3367
|
+
}
|
|
3368
|
+
};
|
|
3607
3369
|
|
|
3608
|
-
|
|
3609
|
-
|
|
3370
|
+
renderingService.hooks.init.tapPromise(SVGRendererPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee() {
|
|
3371
|
+
var _this$canvasConfig, background, document, $svg;
|
|
3610
3372
|
|
|
3611
|
-
|
|
3612
|
-
|
|
3373
|
+
return _regeneratorRuntime$2().wrap(function _callee$(_context) {
|
|
3374
|
+
while (1) {
|
|
3375
|
+
switch (_context.prev = _context.next) {
|
|
3376
|
+
case 0:
|
|
3377
|
+
_this$canvasConfig = _this.canvasConfig, background = _this$canvasConfig.background, document = _this$canvasConfig.document; // <defs>
|
|
3613
3378
|
|
|
3614
|
-
|
|
3379
|
+
_this.defElementManager.init();
|
|
3615
3380
|
|
|
3616
|
-
|
|
3617
|
-
var _object$parsedStyle = object.parsedStyle,
|
|
3618
|
-
fill = _object$parsedStyle.fill,
|
|
3619
|
-
stroke = _object$parsedStyle.stroke;
|
|
3381
|
+
$svg = _this.contextService.getContext();
|
|
3620
3382
|
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3383
|
+
if (background) {
|
|
3384
|
+
$svg.style.background = background;
|
|
3385
|
+
} // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
|
|
3624
3386
|
|
|
3625
|
-
if (stroke && !(stroke instanceof g.CSSRGB)) {
|
|
3626
|
-
_this.defElementManager.createOrUpdateGradientAndPattern(object, $el, stroke, 'stroke');
|
|
3627
|
-
}
|
|
3628
|
-
};
|
|
3629
3387
|
|
|
3630
|
-
|
|
3631
|
-
|
|
3388
|
+
$svg.setAttribute('color-interpolation-filters', 'sRGB');
|
|
3389
|
+
_this.$camera = createSVGElement('g', document);
|
|
3390
|
+
_this.$camera.id = G_SVG_PREFIX + "_camera";
|
|
3632
3391
|
|
|
3633
|
-
|
|
3634
|
-
while (1) {
|
|
3635
|
-
switch (_context.prev = _context.next) {
|
|
3636
|
-
case 0:
|
|
3637
|
-
_this$canvasConfig = _this.canvasConfig, background = _this$canvasConfig.background, document = _this$canvasConfig.document; // <defs>
|
|
3392
|
+
_this.applyTransform(_this.$camera, _this.camera.getOrthoMatrix());
|
|
3638
3393
|
|
|
3639
|
-
|
|
3394
|
+
$svg.appendChild(_this.$camera);
|
|
3640
3395
|
|
|
3641
|
-
|
|
3396
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
3642
3397
|
|
|
3643
|
-
|
|
3644
|
-
$svg.style.background = background;
|
|
3645
|
-
} // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
|
|
3398
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
3646
3399
|
|
|
3400
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
3647
3401
|
|
|
3648
|
-
|
|
3649
|
-
_this.$camera = createSVGElement('g', document);
|
|
3650
|
-
_this.$camera.id = "".concat(G_SVG_PREFIX, "_camera");
|
|
3402
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.GEOMETRY_BOUNDS_CHANGED, handleGeometryBoundsChanged);
|
|
3651
3403
|
|
|
3652
|
-
|
|
3404
|
+
case 13:
|
|
3405
|
+
case "end":
|
|
3406
|
+
return _context.stop();
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
}, _callee);
|
|
3410
|
+
})));
|
|
3411
|
+
renderingService.hooks.destroy.tap(SVGRendererPlugin_1.tag, function () {
|
|
3412
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
3653
3413
|
|
|
3654
|
-
|
|
3414
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
3655
3415
|
|
|
3656
|
-
|
|
3416
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
3417
|
+
|
|
3418
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.GEOMETRY_BOUNDS_CHANGED, handleGeometryBoundsChanged);
|
|
3419
|
+
});
|
|
3420
|
+
renderingService.hooks.render.tap(SVGRendererPlugin_1.tag, function (object) {
|
|
3421
|
+
// if (!object.isCulled()) {
|
|
3422
|
+
_this.renderQueue.push(object); // }
|
|
3657
3423
|
|
|
3658
|
-
|
|
3424
|
+
});
|
|
3425
|
+
renderingService.hooks.beginFrame.tap(SVGRendererPlugin_1.tag, function () {
|
|
3426
|
+
var doc = _this.canvasConfig.document;
|
|
3659
3427
|
|
|
3660
|
-
|
|
3428
|
+
if (_this.pendingReorderQueue.size) {
|
|
3429
|
+
_this.pendingReorderQueue.forEach(function (object) {
|
|
3430
|
+
var _object$elementSVG2;
|
|
3661
3431
|
|
|
3662
|
-
|
|
3432
|
+
var children = ((object === null || object === void 0 ? void 0 : object.children) || []).slice();
|
|
3433
|
+
var $parentGroupEl = // @ts-ignore
|
|
3434
|
+
object === null || object === void 0 ? void 0 : (_object$elementSVG2 = object.elementSVG) === null || _object$elementSVG2 === void 0 ? void 0 : _object$elementSVG2.$groupEl;
|
|
3663
3435
|
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
return _context.stop();
|
|
3667
|
-
}
|
|
3436
|
+
if ($parentGroupEl) {
|
|
3437
|
+
_this.reorderChildren(doc || document, $parentGroupEl, children || []);
|
|
3668
3438
|
}
|
|
3669
|
-
}
|
|
3670
|
-
})));
|
|
3671
|
-
renderingService.hooks.destroy.tap(SVGRendererPlugin_1.tag, function () {
|
|
3672
|
-
_this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
3439
|
+
});
|
|
3673
3440
|
|
|
3674
|
-
_this.
|
|
3441
|
+
_this.pendingReorderQueue.clear();
|
|
3442
|
+
}
|
|
3443
|
+
});
|
|
3444
|
+
renderingService.hooks.endFrame.tap(SVGRendererPlugin_1.tag, function () {
|
|
3445
|
+
if (_this.renderingContext.renderReasons.has(g.RenderReason.CAMERA_CHANGED)) {
|
|
3446
|
+
_this.applyTransform(_this.$camera, _this.camera.getOrthoMatrix());
|
|
3447
|
+
}
|
|
3675
3448
|
|
|
3676
|
-
|
|
3449
|
+
_this.renderQueue.forEach(function (object) {
|
|
3450
|
+
var _object$elementSVG3, _object$elementSVG4; // @ts-ignore
|
|
3677
3451
|
|
|
3678
|
-
_this.renderingContext.root.removeEventListener(g.ElementEvent.GEOMETRY_BOUNDS_CHANGED, handleGeometryBoundsChanged);
|
|
3679
|
-
});
|
|
3680
|
-
renderingService.hooks.render.tap(SVGRendererPlugin_1.tag, function (object) {
|
|
3681
|
-
// if (!object.isCulled()) {
|
|
3682
|
-
_this.renderQueue.push(object); // }
|
|
3683
3452
|
|
|
3684
|
-
|
|
3685
|
-
renderingService.hooks.beginFrame.tap(SVGRendererPlugin_1.tag, function () {
|
|
3686
|
-
var doc = _this.canvasConfig.document;
|
|
3453
|
+
var $el = (_object$elementSVG3 = object.elementSVG) === null || _object$elementSVG3 === void 0 ? void 0 : _object$elementSVG3.$el; // @ts-ignore
|
|
3687
3454
|
|
|
3688
|
-
|
|
3689
|
-
_this.pendingReorderQueue.forEach(function (object) {
|
|
3690
|
-
var _object$elementSVG2;
|
|
3455
|
+
var $groupEl = (_object$elementSVG4 = object.elementSVG) === null || _object$elementSVG4 === void 0 ? void 0 : _object$elementSVG4.$groupEl;
|
|
3691
3456
|
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3457
|
+
if ($el && $groupEl) {
|
|
3458
|
+
// apply local RTS transformation to <group> wrapper
|
|
3459
|
+
// account for anchor
|
|
3460
|
+
_this.applyTransform($groupEl, object.getLocalTransform()); // finish rendering, clear dirty flag
|
|
3695
3461
|
|
|
3696
|
-
if ($parentGroupEl) {
|
|
3697
|
-
_this.reorderChildren(doc || document, $parentGroupEl, children || []);
|
|
3698
|
-
}
|
|
3699
|
-
});
|
|
3700
3462
|
|
|
3701
|
-
|
|
3463
|
+
object.renderable.dirty = false;
|
|
3702
3464
|
}
|
|
3703
3465
|
});
|
|
3704
|
-
renderingService.hooks.endFrame.tap(SVGRendererPlugin_1.tag, function () {
|
|
3705
|
-
if (_this.renderingContext.renderReasons.has(g.RenderReason.CAMERA_CHANGED)) {
|
|
3706
|
-
_this.applyTransform(_this.$camera, _this.camera.getOrthoMatrix());
|
|
3707
|
-
}
|
|
3708
|
-
|
|
3709
|
-
_this.renderQueue.forEach(function (object) {
|
|
3710
|
-
var _object$elementSVG3, _object$elementSVG4; // @ts-ignore
|
|
3711
|
-
|
|
3712
3466
|
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3467
|
+
_this.renderQueue = [];
|
|
3468
|
+
});
|
|
3469
|
+
};
|
|
3716
3470
|
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3471
|
+
_proto.reorderChildren = function reorderChildren(doc, $groupEl, children) {
|
|
3472
|
+
// need to reorder parent's children
|
|
3473
|
+
children.sort(function (a, b) {
|
|
3474
|
+
return a.sortable.renderOrder - b.sortable.renderOrder;
|
|
3475
|
+
});
|
|
3721
3476
|
|
|
3477
|
+
if (children.length) {
|
|
3478
|
+
// create empty fragment
|
|
3479
|
+
var fragment = (doc || document).createDocumentFragment();
|
|
3480
|
+
children.forEach(function (child) {
|
|
3481
|
+
if (child.isConnected) {
|
|
3482
|
+
// @ts-ignore
|
|
3483
|
+
var $el = child.elementSVG.$groupEl;
|
|
3722
3484
|
|
|
3723
|
-
|
|
3485
|
+
if ($el) {
|
|
3486
|
+
fragment.appendChild($el);
|
|
3724
3487
|
}
|
|
3725
|
-
}
|
|
3726
|
-
|
|
3727
|
-
_this.renderQueue = [];
|
|
3488
|
+
}
|
|
3728
3489
|
});
|
|
3490
|
+
$groupEl.appendChild(fragment);
|
|
3729
3491
|
}
|
|
3730
|
-
}
|
|
3731
|
-
key: "reorderChildren",
|
|
3732
|
-
value: function reorderChildren(doc, $groupEl, children) {
|
|
3733
|
-
// need to reorder parent's children
|
|
3734
|
-
children.sort(function (a, b) {
|
|
3735
|
-
return a.sortable.renderOrder - b.sortable.renderOrder;
|
|
3736
|
-
});
|
|
3492
|
+
};
|
|
3737
3493
|
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3494
|
+
_proto.applyTransform = function applyTransform($el, transform) {
|
|
3495
|
+
var translation = getTranslation(create$1(), transform);
|
|
3496
|
+
var scaling = getScaling(create$1(), transform);
|
|
3497
|
+
var rotation = getRotation(create$3(), transform);
|
|
3498
|
+
var x = translation[0],
|
|
3499
|
+
y = translation[1];
|
|
3500
|
+
var scaleX = scaling[0],
|
|
3501
|
+
scaleY = scaling[1]; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3745
3502
|
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
});
|
|
3751
|
-
$groupEl.appendChild(fragment);
|
|
3752
|
-
}
|
|
3753
|
-
}
|
|
3754
|
-
}, {
|
|
3755
|
-
key: "applyTransform",
|
|
3756
|
-
value: function applyTransform($el, transform) {
|
|
3757
|
-
var translation = getTranslation(create$1(), transform);
|
|
3758
|
-
var scaling = getScaling(create$1(), transform);
|
|
3759
|
-
var rotation = getRotation(create$3(), transform);
|
|
3503
|
+
var _getEuler = g.getEuler(create$1(), rotation),
|
|
3504
|
+
ex = _getEuler[0],
|
|
3505
|
+
ey = _getEuler[1],
|
|
3506
|
+
ez = _getEuler[2]; // gimbal lock at 90 degrees
|
|
3760
3507
|
|
|
3761
|
-
var _translation = _slicedToArray(translation, 2),
|
|
3762
|
-
x = _translation[0],
|
|
3763
|
-
y = _translation[1];
|
|
3764
3508
|
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
scaleY = _scaling[1]; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3509
|
+
var rts = g.fromRotationTranslationScale(ex || ez, x, y, scaleX, scaleY); // use proper precision avoiding too long string in `transform`
|
|
3510
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
3768
3511
|
|
|
3512
|
+
$el.setAttribute('transform', "matrix(" + numberToLongString(rts[0]) + "," + numberToLongString(rts[1]) + "," + numberToLongString(rts[3]) + "," + numberToLongString(rts[4]) + "," + numberToLongString(rts[6]) + "," + numberToLongString(rts[7]) + ")");
|
|
3513
|
+
};
|
|
3514
|
+
|
|
3515
|
+
_proto.applyAttributes = function applyAttributes(object) {
|
|
3516
|
+
// @ts-ignore
|
|
3517
|
+
var elementSVG = object.elementSVG;
|
|
3518
|
+
var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
|
|
3519
|
+
var $groupEl = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$groupEl;
|
|
3769
3520
|
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
ez = _getEuler2[2]; // gimbal lock at 90 degrees
|
|
3521
|
+
if ($el && $groupEl) {
|
|
3522
|
+
var nodeName = object.nodeName,
|
|
3523
|
+
attributes = object.attributes;
|
|
3524
|
+
$el.setAttribute('fill', 'none');
|
|
3775
3525
|
|
|
3526
|
+
if (nodeName === g.Shape.IMAGE) {
|
|
3527
|
+
$el.setAttribute('preserveAspectRatio', 'none');
|
|
3528
|
+
} // apply attributes
|
|
3776
3529
|
|
|
3777
|
-
var rts = g.fromRotationTranslationScale(ex || ez, x, y, scaleX, scaleY); // use proper precision avoiding too long string in `transform`
|
|
3778
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
3779
3530
|
|
|
3780
|
-
|
|
3531
|
+
this.updateAttribute(object, Object.keys(attributes));
|
|
3781
3532
|
}
|
|
3782
|
-
}
|
|
3783
|
-
key: "applyAttributes",
|
|
3784
|
-
value: function applyAttributes(object) {
|
|
3785
|
-
// @ts-ignore
|
|
3786
|
-
var elementSVG = object.elementSVG;
|
|
3787
|
-
var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
|
|
3788
|
-
var $groupEl = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$groupEl;
|
|
3533
|
+
};
|
|
3789
3534
|
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
attributes = object.attributes;
|
|
3793
|
-
$el.setAttribute('fill', 'none');
|
|
3535
|
+
_proto.updateAttribute = function updateAttribute(object, attributes) {
|
|
3536
|
+
var _this2 = this;
|
|
3794
3537
|
|
|
3795
|
-
|
|
3796
|
-
$el.setAttribute('preserveAspectRatio', 'none');
|
|
3797
|
-
} // apply attributes
|
|
3538
|
+
var document = this.canvasConfig.document; // @ts-ignore
|
|
3798
3539
|
|
|
3540
|
+
var _object$elementSVG5 = object.elementSVG,
|
|
3541
|
+
$el = _object$elementSVG5.$el,
|
|
3542
|
+
$groupEl = _object$elementSVG5.$groupEl,
|
|
3543
|
+
$hitTestingEl = _object$elementSVG5.$hitTestingEl;
|
|
3544
|
+
var parsedStyle = object.parsedStyle,
|
|
3545
|
+
computedStyle = object.computedStyle;
|
|
3546
|
+
var shouldUpdateElementAttribute = attributes.some(function (name) {
|
|
3547
|
+
return _this2.createElementContribution.shouldUpdateElementAttribute(object, name);
|
|
3548
|
+
}); // need re-generate path
|
|
3799
3549
|
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
key: "updateAttribute",
|
|
3805
|
-
value: function updateAttribute(object, attributes) {
|
|
3806
|
-
var _this2 = this;
|
|
3807
|
-
|
|
3808
|
-
var document = this.canvasConfig.document; // @ts-ignore
|
|
3809
|
-
|
|
3810
|
-
var _object$elementSVG5 = object.elementSVG,
|
|
3811
|
-
$el = _object$elementSVG5.$el,
|
|
3812
|
-
$groupEl = _object$elementSVG5.$groupEl,
|
|
3813
|
-
$hitTestingEl = _object$elementSVG5.$hitTestingEl;
|
|
3814
|
-
var parsedStyle = object.parsedStyle,
|
|
3815
|
-
computedStyle = object.computedStyle;
|
|
3816
|
-
var shouldUpdateElementAttribute = attributes.some(function (name) {
|
|
3817
|
-
return _this2.createElementContribution.shouldUpdateElementAttribute(object, name);
|
|
3818
|
-
}); // need re-generate path
|
|
3819
|
-
|
|
3820
|
-
if (shouldUpdateElementAttribute && $el) {
|
|
3821
|
-
[$el, $hitTestingEl].forEach(function ($el) {
|
|
3822
|
-
if ($el) {
|
|
3823
|
-
_this2.createElementContribution.updateElementAttribute(object, $el);
|
|
3550
|
+
if (shouldUpdateElementAttribute && $el) {
|
|
3551
|
+
[$el, $hitTestingEl].forEach(function ($el) {
|
|
3552
|
+
if ($el) {
|
|
3553
|
+
_this2.createElementContribution.updateElementAttribute(object, $el);
|
|
3824
3554
|
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
}
|
|
3555
|
+
if (object.nodeName !== g.Shape.TEXT) {
|
|
3556
|
+
_this2.updateAnchorWithTransform(object);
|
|
3828
3557
|
}
|
|
3829
|
-
}
|
|
3830
|
-
}
|
|
3558
|
+
}
|
|
3559
|
+
});
|
|
3560
|
+
} // update common attributes
|
|
3831
3561
|
|
|
3832
3562
|
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3563
|
+
attributes.forEach(function (name) {
|
|
3564
|
+
var usedName = SVG_ATTR_MAP[name];
|
|
3565
|
+
var computedValue = computedStyle[name];
|
|
3566
|
+
var usedValue = parsedStyle[name]; // <foreignObject>
|
|
3837
3567
|
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
}
|
|
3568
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
3569
|
+
if (name === 'lineWidth') {
|
|
3570
|
+
$el.style['border-width'] = (usedValue.value || 0) + "px";
|
|
3571
|
+
} else if (name === 'lineDash') {
|
|
3572
|
+
$el.style['border-style'] = 'dashed';
|
|
3844
3573
|
}
|
|
3574
|
+
}
|
|
3845
3575
|
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
} else {
|
|
3850
|
-
_this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName);
|
|
3851
|
-
}
|
|
3852
|
-
} else if (name === 'stroke') {
|
|
3853
|
-
if (object.nodeName === g.Shape.HTML) {
|
|
3854
|
-
$el.style['border-color'] = usedValue.toString();
|
|
3855
|
-
$el.style['border-style'] = 'solid';
|
|
3856
|
-
} else {
|
|
3857
|
-
_this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName);
|
|
3858
|
-
}
|
|
3859
|
-
} else if (name === 'visibility' && computedValue.value !== 'unset') {
|
|
3860
|
-
// use computed value
|
|
3861
|
-
// update `visibility` on <group>
|
|
3862
|
-
$groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, "".concat(computedValue.value));
|
|
3863
|
-
} else if (name === 'clipPath') {
|
|
3864
|
-
_this2.createOrUpdateClipPath(document, usedValue, $groupEl);
|
|
3865
|
-
} else if (name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
|
|
3866
|
-
_this2.defElementManager.createOrUpdateShadow(object, $el, name);
|
|
3867
|
-
} else if (name === 'filter') {
|
|
3868
|
-
_this2.defElementManager.createOrUpdateFilter(object, $el, usedValue);
|
|
3869
|
-
} else if (name === 'innerHTML') {
|
|
3870
|
-
_this2.createOrUpdateInnerHTML(document, $el, usedValue);
|
|
3871
|
-
} else if (name === 'anchor') {
|
|
3872
|
-
// text' anchor is controlled by `textAnchor` property
|
|
3873
|
-
if (object.nodeName !== g.Shape.TEXT) {
|
|
3874
|
-
_this2.updateAnchorWithTransform(object);
|
|
3875
|
-
}
|
|
3576
|
+
if (name === 'fill') {
|
|
3577
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
3578
|
+
$el.style.background = usedValue.toString();
|
|
3876
3579
|
} else {
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3580
|
+
_this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName);
|
|
3581
|
+
}
|
|
3582
|
+
} else if (name === 'stroke') {
|
|
3583
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
3584
|
+
$el.style['border-color'] = usedValue.toString();
|
|
3585
|
+
$el.style['border-style'] = 'solid';
|
|
3586
|
+
} else {
|
|
3587
|
+
_this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName);
|
|
3588
|
+
}
|
|
3589
|
+
} else if (name === 'visibility' && computedValue.value !== 'unset') {
|
|
3590
|
+
// use computed value
|
|
3591
|
+
// update `visibility` on <group>
|
|
3592
|
+
$groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, "" + computedValue.value);
|
|
3593
|
+
} else if (name === 'clipPath') {
|
|
3594
|
+
_this2.createOrUpdateClipPath(document, usedValue, $groupEl);
|
|
3595
|
+
} else if (name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
|
|
3596
|
+
_this2.defElementManager.createOrUpdateShadow(object, $el, name);
|
|
3597
|
+
} else if (name === 'filter') {
|
|
3598
|
+
_this2.defElementManager.createOrUpdateFilter(object, $el, usedValue);
|
|
3599
|
+
} else if (name === 'innerHTML') {
|
|
3600
|
+
_this2.createOrUpdateInnerHTML(document, $el, usedValue);
|
|
3601
|
+
} else if (name === 'anchor') {
|
|
3602
|
+
// text' anchor is controlled by `textAnchor` property
|
|
3603
|
+
if (object.nodeName !== g.Shape.TEXT) {
|
|
3604
|
+
_this2.updateAnchorWithTransform(object);
|
|
3605
|
+
}
|
|
3606
|
+
} else {
|
|
3607
|
+
if (computedValue) {
|
|
3608
|
+
// use computed value so that we can use cascaded effect in SVG
|
|
3609
|
+
var valueStr = computedValue.toString(); // ignore 'unset' and default value
|
|
3610
|
+
|
|
3611
|
+
[$el, $hitTestingEl].forEach(function ($el) {
|
|
3612
|
+
if ($el && usedName) {
|
|
3613
|
+
if (valueStr !== 'unset' && valueStr !== DEFAULT_VALUE_MAP[name]) {
|
|
3614
|
+
var _FORMAT_VALUE_MAP$nam;
|
|
3615
|
+
|
|
3616
|
+
var formattedValueStr = ((_FORMAT_VALUE_MAP$nam = FORMAT_VALUE_MAP[name]) === null || _FORMAT_VALUE_MAP$nam === void 0 ? void 0 : _FORMAT_VALUE_MAP$nam[valueStr]) || valueStr;
|
|
3617
|
+
$el.setAttribute(usedName, formattedValueStr);
|
|
3618
|
+
} else {
|
|
3619
|
+
$el.removeAttribute(usedName);
|
|
3891
3620
|
}
|
|
3892
|
-
}
|
|
3893
|
-
}
|
|
3621
|
+
}
|
|
3622
|
+
});
|
|
3894
3623
|
}
|
|
3895
|
-
}
|
|
3896
|
-
}
|
|
3897
|
-
}
|
|
3898
|
-
key: "createSVGDom",
|
|
3899
|
-
value: function createSVGDom(document, object, root) {
|
|
3900
|
-
var noWrapWithGroup = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; // create svg element
|
|
3901
|
-
// @ts-ignore
|
|
3624
|
+
}
|
|
3625
|
+
});
|
|
3626
|
+
};
|
|
3902
3627
|
|
|
3903
|
-
|
|
3628
|
+
_proto.createSVGDom = function createSVGDom(document, object, root, noWrapWithGroup) {
|
|
3629
|
+
if (noWrapWithGroup === void 0) {
|
|
3630
|
+
noWrapWithGroup = false;
|
|
3631
|
+
} // create svg element
|
|
3632
|
+
// @ts-ignore
|
|
3904
3633
|
|
|
3905
|
-
var svgElement = object.elementSVG; // use <group> as default, eg. CustomElement
|
|
3906
3634
|
|
|
3907
|
-
|
|
3635
|
+
object.elementSVG = new ElementSVG(); // @ts-ignore
|
|
3908
3636
|
|
|
3909
|
-
|
|
3910
|
-
var _object$parentNode$el2;
|
|
3637
|
+
var svgElement = object.elementSVG; // use <group> as default, eg. CustomElement
|
|
3911
3638
|
|
|
3912
|
-
|
|
3639
|
+
var $el = this.createElementContribution.createElement(object);
|
|
3913
3640
|
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
}
|
|
3641
|
+
if ($el) {
|
|
3642
|
+
var _object$parentNode$el2;
|
|
3917
3643
|
|
|
3918
|
-
|
|
3644
|
+
var $groupEl; // save $el on parsedStyle, which will be returned in getDomElement()
|
|
3919
3645
|
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
} else {
|
|
3924
|
-
$groupEl = $el;
|
|
3925
|
-
}
|
|
3646
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
3647
|
+
object.parsedStyle.$el = $el;
|
|
3648
|
+
}
|
|
3926
3649
|
|
|
3927
|
-
|
|
3928
|
-
svgElement.$groupEl = $groupEl; // apply attributes at first time
|
|
3650
|
+
$el.id = G_SVG_PREFIX + "_" + object.nodeName + "_" + object.entity;
|
|
3929
3651
|
|
|
3930
|
-
|
|
3652
|
+
if (($el.hasAttribute('data-wrapgroup') || $el.nodeName !== 'g') && !noWrapWithGroup) {
|
|
3653
|
+
$groupEl = createSVGElement('g', document);
|
|
3654
|
+
$groupEl.appendChild($el);
|
|
3655
|
+
} else {
|
|
3656
|
+
$groupEl = $el;
|
|
3657
|
+
}
|
|
3931
3658
|
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
object.parentNode && ((_object$parentNode$el2 = object.parentNode.elementSVG) === null || _object$parentNode$el2 === void 0 ? void 0 : _object$parentNode$el2.$groupEl) || root;
|
|
3659
|
+
svgElement.$el = $el;
|
|
3660
|
+
svgElement.$groupEl = $groupEl; // apply attributes at first time
|
|
3935
3661
|
|
|
3936
|
-
|
|
3937
|
-
$parentGroupEl.appendChild($groupEl); // need reorder children later
|
|
3662
|
+
this.applyAttributes(object); // create hitArea if necessary
|
|
3938
3663
|
|
|
3939
|
-
|
|
3940
|
-
|
|
3664
|
+
this.createOrUpdateHitArea(object, $el, $groupEl);
|
|
3665
|
+
var $parentGroupEl = // @ts-ignore
|
|
3666
|
+
object.parentNode && ((_object$parentNode$el2 = object.parentNode.elementSVG) === null || _object$parentNode$el2 === void 0 ? void 0 : _object$parentNode$el2.$groupEl) || root;
|
|
3667
|
+
|
|
3668
|
+
if ($parentGroupEl) {
|
|
3669
|
+
$parentGroupEl.appendChild($groupEl); // need reorder children later
|
|
3670
|
+
|
|
3671
|
+
this.pendingReorderQueue.add(object.parentNode);
|
|
3941
3672
|
}
|
|
3942
3673
|
}
|
|
3943
|
-
}
|
|
3944
|
-
key: "removeSVGDom",
|
|
3945
|
-
value: function removeSVGDom(object) {
|
|
3946
|
-
var _object$elementSVG6; // @ts-ignore
|
|
3674
|
+
};
|
|
3947
3675
|
|
|
3676
|
+
_proto.removeSVGDom = function removeSVGDom(object) {
|
|
3677
|
+
var _object$elementSVG6; // @ts-ignore
|
|
3948
3678
|
|
|
3949
|
-
var $groupEl = (_object$elementSVG6 = object.elementSVG) === null || _object$elementSVG6 === void 0 ? void 0 : _object$elementSVG6.$groupEl;
|
|
3950
3679
|
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3680
|
+
var $groupEl = (_object$elementSVG6 = object.elementSVG) === null || _object$elementSVG6 === void 0 ? void 0 : _object$elementSVG6.$groupEl;
|
|
3681
|
+
|
|
3682
|
+
if ($groupEl && $groupEl.parentNode) {
|
|
3683
|
+
$groupEl.parentNode.removeChild($groupEl); // object.entity.removeComponent(ElementSVG, true);
|
|
3954
3684
|
}
|
|
3955
|
-
}
|
|
3956
|
-
key: "createOrUpdateHitArea",
|
|
3957
|
-
value: function createOrUpdateHitArea(object, $el, $groupEl) {
|
|
3958
|
-
var _object$parsedStyle$i; // @ts-ignore
|
|
3685
|
+
};
|
|
3959
3686
|
|
|
3687
|
+
_proto.createOrUpdateHitArea = function createOrUpdateHitArea(object, $el, $groupEl) {
|
|
3688
|
+
var _object$parsedStyle$i; // @ts-ignore
|
|
3960
3689
|
|
|
3961
|
-
var svgElement = object.elementSVG;
|
|
3962
|
-
var $hitTestingEl = svgElement.$hitTestingEl;
|
|
3963
|
-
var increasedLineWidthForHitTesting = (_object$parsedStyle$i = object.parsedStyle.increasedLineWidthForHitTesting) === null || _object$parsedStyle$i === void 0 ? void 0 : _object$parsedStyle$i.value; // account for hitArea
|
|
3964
3690
|
|
|
3965
|
-
|
|
3966
|
-
|
|
3691
|
+
var svgElement = object.elementSVG;
|
|
3692
|
+
var $hitTestingEl = svgElement.$hitTestingEl;
|
|
3693
|
+
var increasedLineWidthForHitTesting = (_object$parsedStyle$i = object.parsedStyle.increasedLineWidthForHitTesting) === null || _object$parsedStyle$i === void 0 ? void 0 : _object$parsedStyle$i.value; // account for hitArea
|
|
3967
3694
|
|
|
3968
|
-
|
|
3969
|
-
|
|
3695
|
+
if (increasedLineWidthForHitTesting) {
|
|
3696
|
+
var _object$parsedStyle$l;
|
|
3970
3697
|
|
|
3971
|
-
|
|
3698
|
+
if (!$hitTestingEl) {
|
|
3699
|
+
$hitTestingEl = $el.cloneNode(); // use the entity suffix, so that `g-plugin-svg-picker` can extract
|
|
3972
3700
|
|
|
3973
|
-
|
|
3974
|
-
$hitTestingEl.removeAttribute(attribute);
|
|
3975
|
-
}); // hitArea should be 'transparent' but not 'none'
|
|
3701
|
+
$hitTestingEl.id = G_SVG_PREFIX + "_" + object.nodeName + "_hittesting_" + object.entity; // clear attributes like `filter` `font-size`
|
|
3976
3702
|
|
|
3977
|
-
|
|
3978
|
-
$hitTestingEl.
|
|
3979
|
-
|
|
3980
|
-
$groupEl.appendChild($hitTestingEl);
|
|
3981
|
-
svgElement.$hitTestingEl = $hitTestingEl;
|
|
3982
|
-
} // increase interactive line width
|
|
3703
|
+
['filter'].forEach(function (attribute) {
|
|
3704
|
+
$hitTestingEl.removeAttribute(attribute);
|
|
3705
|
+
}); // hitArea should be 'transparent' but not 'none'
|
|
3983
3706
|
|
|
3707
|
+
var hasFill = $el.getAttribute('fill') !== 'none';
|
|
3708
|
+
$hitTestingEl.setAttribute('fill', hasFill ? 'transparent' : 'none');
|
|
3709
|
+
$hitTestingEl.setAttribute('stroke', 'transparent');
|
|
3710
|
+
$groupEl.appendChild($hitTestingEl);
|
|
3711
|
+
svgElement.$hitTestingEl = $hitTestingEl;
|
|
3712
|
+
} // increase interactive line width
|
|
3984
3713
|
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3714
|
+
|
|
3715
|
+
$hitTestingEl.setAttribute('stroke-width', "" + (increasedLineWidthForHitTesting + ((_object$parsedStyle$l = object.parsedStyle.lineWidth) === null || _object$parsedStyle$l === void 0 ? void 0 : _object$parsedStyle$l.value)));
|
|
3716
|
+
} else {
|
|
3717
|
+
if ($hitTestingEl) {
|
|
3718
|
+
$groupEl.removeChild($hitTestingEl);
|
|
3719
|
+
svgElement.$hitTestingEl = null;
|
|
3991
3720
|
}
|
|
3992
3721
|
}
|
|
3993
|
-
}
|
|
3994
|
-
key: "createOrUpdateInnerHTML",
|
|
3995
|
-
value: function createOrUpdateInnerHTML(doc, $el, usedValue) {
|
|
3996
|
-
var $div = (doc || document).createElement('div');
|
|
3722
|
+
};
|
|
3997
3723
|
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
} else {
|
|
4001
|
-
$div.appendChild(usedValue);
|
|
4002
|
-
}
|
|
3724
|
+
_proto.createOrUpdateInnerHTML = function createOrUpdateInnerHTML(doc, $el, usedValue) {
|
|
3725
|
+
var $div = (doc || document).createElement('div');
|
|
4003
3726
|
|
|
4004
|
-
|
|
4005
|
-
$
|
|
3727
|
+
if (typeof usedValue === 'string') {
|
|
3728
|
+
$div.innerHTML = usedValue;
|
|
3729
|
+
} else {
|
|
3730
|
+
$div.appendChild(usedValue);
|
|
4006
3731
|
}
|
|
4007
|
-
}, {
|
|
4008
|
-
key: "createOrUpdateClipPath",
|
|
4009
|
-
value: function createOrUpdateClipPath(document, clipPath, $groupEl) {
|
|
4010
|
-
if (clipPath) {
|
|
4011
|
-
var _clipPath$elementSVG;
|
|
4012
3732
|
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
3733
|
+
$el.innerHTML = '';
|
|
3734
|
+
$el.appendChild($div);
|
|
3735
|
+
};
|
|
4016
3736
|
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
$clipPath.id = clipPathId;
|
|
4021
|
-
$def.appendChild($clipPath); // <clipPath><circle /></clipPath>
|
|
3737
|
+
_proto.createOrUpdateClipPath = function createOrUpdateClipPath(document, clipPath, $groupEl) {
|
|
3738
|
+
if (clipPath) {
|
|
3739
|
+
var _clipPath$elementSVG;
|
|
4022
3740
|
|
|
4023
|
-
|
|
3741
|
+
var clipPathId = CLIP_PATH_PREFIX + clipPath.entity;
|
|
3742
|
+
var $def = this.defElementManager.getDefElement();
|
|
3743
|
+
var existed = $def.querySelector("#" + clipPathId);
|
|
4024
3744
|
|
|
4025
|
-
|
|
4026
|
-
|
|
3745
|
+
if (!existed) {
|
|
3746
|
+
// create <clipPath> dom node, append it to <defs>
|
|
3747
|
+
var $clipPath = createSVGElement('clipPath', document);
|
|
3748
|
+
$clipPath.id = clipPathId;
|
|
3749
|
+
$def.appendChild($clipPath); // <clipPath><circle /></clipPath>
|
|
4027
3750
|
|
|
3751
|
+
this.createSVGDom(document, clipPath, $clipPath, true); // @ts-ignore
|
|
4028
3752
|
|
|
4029
|
-
|
|
3753
|
+
clipPath.elementSVG.$groupEl = $clipPath;
|
|
3754
|
+
} // @ts-ignore
|
|
4030
3755
|
|
|
4031
|
-
if ($clipPathGroupEl) {
|
|
4032
|
-
// apply local RTS transformation to <group> wrapper
|
|
4033
|
-
this.applyTransform($clipPathGroupEl, clipPath.getLocalTransform());
|
|
4034
|
-
} // apply attributes
|
|
4035
3756
|
|
|
3757
|
+
var $clipPathGroupEl = (_clipPath$elementSVG = clipPath.elementSVG) === null || _clipPath$elementSVG === void 0 ? void 0 : _clipPath$elementSVG.$groupEl;
|
|
4036
3758
|
|
|
4037
|
-
|
|
4038
|
-
//
|
|
3759
|
+
if ($clipPathGroupEl) {
|
|
3760
|
+
// apply local RTS transformation to <group> wrapper
|
|
3761
|
+
this.applyTransform($clipPathGroupEl, clipPath.getLocalTransform());
|
|
3762
|
+
} // apply attributes
|
|
4039
3763
|
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
3764
|
+
|
|
3765
|
+
this.applyAttributes(clipPath); // apply clipPath to $group
|
|
3766
|
+
// @see https://github.com/antvis/g/issues/961
|
|
3767
|
+
|
|
3768
|
+
$groupEl.setAttribute('clip-path', "url(#" + clipPathId + ")");
|
|
3769
|
+
} else {
|
|
3770
|
+
// remove clip path
|
|
3771
|
+
$groupEl.removeAttribute('clip-path');
|
|
4045
3772
|
}
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
3773
|
+
}
|
|
3774
|
+
/**
|
|
3775
|
+
* the origin is bounding box's top left corner
|
|
3776
|
+
*/
|
|
3777
|
+
;
|
|
4049
3778
|
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
value: function updateAnchorWithTransform(object) {
|
|
4053
|
-
var _object$elementSVG7, _object$elementSVG8;
|
|
3779
|
+
_proto.updateAnchorWithTransform = function updateAnchorWithTransform(object) {
|
|
3780
|
+
var _object$elementSVG7, _object$elementSVG8;
|
|
4054
3781
|
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
3782
|
+
var bounds = object.getGeometryBounds();
|
|
3783
|
+
var width = bounds && bounds.halfExtents[0] * 2 || 0;
|
|
3784
|
+
var height = bounds && bounds.halfExtents[1] * 2 || 0;
|
|
4058
3785
|
|
|
4059
|
-
|
|
4060
|
-
|
|
3786
|
+
var _ref2 = object.parsedStyle || {},
|
|
3787
|
+
anchor = _ref2.anchor; // @ts-ignore
|
|
4061
3788
|
|
|
4062
3789
|
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
$el.setAttribute('transform', // can't use percent unit like translate(-50%, -50%)
|
|
4068
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/transform#translate
|
|
4069
|
-
"translate(-".concat(anchor[0].value * width, ",-").concat(anchor[1].value * height, ")"));
|
|
4070
|
-
}
|
|
3790
|
+
[(_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) {
|
|
3791
|
+
if ($el) {
|
|
3792
|
+
var defX = 0;
|
|
3793
|
+
var defY = 0;
|
|
4071
3794
|
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
}
|
|
3795
|
+
if (object.nodeName === g.Shape.POLYLINE || object.nodeName === g.Shape.POLYGON || object.nodeName === g.Shape.PATH) {
|
|
3796
|
+
defX = object.parsedStyle.defX;
|
|
3797
|
+
defY = object.parsedStyle.defY;
|
|
4076
3798
|
}
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
3799
|
+
|
|
3800
|
+
var tx = -(anchor[0].value * width + defX);
|
|
3801
|
+
var ty = -(anchor[1].value * height + defY);
|
|
3802
|
+
|
|
3803
|
+
if (tx !== 0 || ty !== 0) {
|
|
3804
|
+
// apply anchor to element's `transform` property
|
|
3805
|
+
$el.setAttribute('transform', // can't use percent unit like translate(-50%, -50%)
|
|
3806
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/transform#translate
|
|
3807
|
+
"translate(" + tx + "," + ty + ")");
|
|
3808
|
+
}
|
|
3809
|
+
|
|
3810
|
+
if (object.nodeName === g.Shape.CIRCLE || object.nodeName === g.Shape.ELLIPSE) {
|
|
3811
|
+
$el.setAttribute('cx', "" + width / 2);
|
|
3812
|
+
$el.setAttribute('cy', "" + height / 2);
|
|
3813
|
+
}
|
|
3814
|
+
}
|
|
3815
|
+
});
|
|
3816
|
+
};
|
|
4080
3817
|
|
|
4081
3818
|
return SVGRendererPlugin;
|
|
4082
3819
|
}(), _class$1.tag = 'SVGRenderer', _class$1);
|
|
@@ -4104,22 +3841,18 @@
|
|
|
4104
3841
|
|
|
4105
3842
|
var Plugin$1 = /*#__PURE__*/function () {
|
|
4106
3843
|
function Plugin() {
|
|
4107
|
-
_classCallCheck$2(this, Plugin);
|
|
4108
|
-
|
|
4109
3844
|
this.name = 'svg-renderer';
|
|
4110
3845
|
}
|
|
4111
3846
|
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
}
|
|
4122
|
-
}]);
|
|
3847
|
+
var _proto = Plugin.prototype;
|
|
3848
|
+
|
|
3849
|
+
_proto.init = function init(container) {
|
|
3850
|
+
container.load(containerModule$1, true);
|
|
3851
|
+
};
|
|
3852
|
+
|
|
3853
|
+
_proto.destroy = function destroy(container) {
|
|
3854
|
+
container.unload(containerModule$1);
|
|
3855
|
+
};
|
|
4123
3856
|
|
|
4124
3857
|
return Plugin;
|
|
4125
3858
|
}();
|
|
@@ -4271,7 +4004,7 @@
|
|
|
4271
4004
|
if ("throw" !== record.type) {
|
|
4272
4005
|
var result = record.arg,
|
|
4273
4006
|
value = result.value;
|
|
4274
|
-
return value && "object" ==
|
|
4007
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
4275
4008
|
invoke("next", value, resolve, reject);
|
|
4276
4009
|
}, function (err) {
|
|
4277
4010
|
invoke("throw", err, resolve, reject);
|
|
@@ -4532,41 +4265,16 @@
|
|
|
4532
4265
|
};
|
|
4533
4266
|
}
|
|
4534
4267
|
|
|
4535
|
-
function
|
|
4536
|
-
if (!(instance instanceof Constructor)) {
|
|
4537
|
-
throw new TypeError("Cannot call a class as a function");
|
|
4538
|
-
}
|
|
4539
|
-
}
|
|
4540
|
-
|
|
4541
|
-
function _defineProperties$3(target, props) {
|
|
4542
|
-
for (var i = 0; i < props.length; i++) {
|
|
4543
|
-
var descriptor = props[i];
|
|
4544
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
4545
|
-
descriptor.configurable = true;
|
|
4546
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
4547
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
4548
|
-
}
|
|
4549
|
-
}
|
|
4550
|
-
|
|
4551
|
-
function _createClass$3(Constructor, protoProps, staticProps) {
|
|
4552
|
-
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
|
|
4553
|
-
if (staticProps) _defineProperties$3(Constructor, staticProps);
|
|
4554
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
4555
|
-
writable: false
|
|
4556
|
-
});
|
|
4557
|
-
return Constructor;
|
|
4558
|
-
}
|
|
4559
|
-
|
|
4560
|
-
function _unsupportedIterableToArray$1(o, minLen) {
|
|
4268
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
4561
4269
|
if (!o) return;
|
|
4562
|
-
if (typeof o === "string") return _arrayLikeToArray
|
|
4270
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
4563
4271
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
4564
4272
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
4565
4273
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
4566
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray
|
|
4274
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
4567
4275
|
}
|
|
4568
4276
|
|
|
4569
|
-
function _arrayLikeToArray
|
|
4277
|
+
function _arrayLikeToArray(arr, len) {
|
|
4570
4278
|
if (len == null || len > arr.length) len = arr.length;
|
|
4571
4279
|
|
|
4572
4280
|
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
@@ -4576,61 +4284,25 @@
|
|
|
4576
4284
|
return arr2;
|
|
4577
4285
|
}
|
|
4578
4286
|
|
|
4579
|
-
function
|
|
4287
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
4580
4288
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
4289
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
4581
4290
|
|
|
4582
|
-
if (
|
|
4583
|
-
if (
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4291
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
4292
|
+
if (it) o = it;
|
|
4293
|
+
var i = 0;
|
|
4294
|
+
return function () {
|
|
4295
|
+
if (i >= o.length) return {
|
|
4296
|
+
done: true
|
|
4297
|
+
};
|
|
4589
4298
|
return {
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
if (i >= o.length) return {
|
|
4593
|
-
done: true
|
|
4594
|
-
};
|
|
4595
|
-
return {
|
|
4596
|
-
done: false,
|
|
4597
|
-
value: o[i++]
|
|
4598
|
-
};
|
|
4599
|
-
},
|
|
4600
|
-
e: function e(_e) {
|
|
4601
|
-
throw _e;
|
|
4602
|
-
},
|
|
4603
|
-
f: F
|
|
4299
|
+
done: false,
|
|
4300
|
+
value: o[i++]
|
|
4604
4301
|
};
|
|
4605
|
-
}
|
|
4606
|
-
|
|
4607
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4302
|
+
};
|
|
4608
4303
|
}
|
|
4609
4304
|
|
|
4610
|
-
|
|
4611
|
-
didErr = false,
|
|
4612
|
-
err;
|
|
4613
|
-
return {
|
|
4614
|
-
s: function s() {
|
|
4615
|
-
it = it.call(o);
|
|
4616
|
-
},
|
|
4617
|
-
n: function n() {
|
|
4618
|
-
var step = it.next();
|
|
4619
|
-
normalCompletion = step.done;
|
|
4620
|
-
return step;
|
|
4621
|
-
},
|
|
4622
|
-
e: function e(_e2) {
|
|
4623
|
-
didErr = true;
|
|
4624
|
-
err = _e2;
|
|
4625
|
-
},
|
|
4626
|
-
f: function f() {
|
|
4627
|
-
try {
|
|
4628
|
-
if (!normalCompletion && it.return != null) it.return();
|
|
4629
|
-
} finally {
|
|
4630
|
-
if (didErr) throw err;
|
|
4631
|
-
}
|
|
4632
|
-
}
|
|
4633
|
-
};
|
|
4305
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4634
4306
|
}
|
|
4635
4307
|
|
|
4636
4308
|
var _class$2;
|
|
@@ -4645,116 +4317,93 @@
|
|
|
4645
4317
|
|
|
4646
4318
|
var SVGPickerPlugin = SVGPickerPlugin_1 = (_class$2 = /*#__PURE__*/function () {
|
|
4647
4319
|
function SVGPickerPlugin() {
|
|
4648
|
-
_classCallCheck$3(this, SVGPickerPlugin);
|
|
4649
|
-
|
|
4650
4320
|
this.canvasConfig = void 0;
|
|
4651
4321
|
this.displayObjectPool = void 0;
|
|
4652
4322
|
}
|
|
4653
4323
|
|
|
4654
|
-
|
|
4655
|
-
key: "apply",
|
|
4656
|
-
value: function apply(renderingService) {
|
|
4657
|
-
var _this = this;
|
|
4658
|
-
|
|
4659
|
-
var doc = this.canvasConfig.document;
|
|
4660
|
-
renderingService.hooks.pick.tapPromise(SVGPickerPlugin_1.tag, /*#__PURE__*/function () {
|
|
4661
|
-
var _ref = _asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee(result) {
|
|
4662
|
-
var topmost, _result$position, clientX, clientY, targets, _iterator, _step, element, id, index, target;
|
|
4663
|
-
|
|
4664
|
-
return _regeneratorRuntime$3().wrap(function _callee$(_context) {
|
|
4665
|
-
while (1) {
|
|
4666
|
-
switch (_context.prev = _context.next) {
|
|
4667
|
-
case 0:
|
|
4668
|
-
topmost = result.topmost, _result$position = result.position, clientX = _result$position.clientX, clientY = _result$position.clientY;
|
|
4669
|
-
_context.prev = 1;
|
|
4670
|
-
targets = []; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
|
|
4671
|
-
|
|
4672
|
-
_iterator = _createForOfIteratorHelper((doc || document).elementsFromPoint(clientX, clientY));
|
|
4673
|
-
_context.prev = 4;
|
|
4674
|
-
|
|
4675
|
-
_iterator.s();
|
|
4324
|
+
var _proto = SVGPickerPlugin.prototype;
|
|
4676
4325
|
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
_context.next = 19;
|
|
4680
|
-
break;
|
|
4681
|
-
}
|
|
4326
|
+
_proto.apply = function apply(renderingService) {
|
|
4327
|
+
var _this = this;
|
|
4682
4328
|
|
|
4683
|
-
|
|
4329
|
+
var doc = this.canvasConfig.document;
|
|
4330
|
+
renderingService.hooks.pick.tapPromise(SVGPickerPlugin_1.tag, /*#__PURE__*/function () {
|
|
4331
|
+
var _ref = _asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee(result) {
|
|
4332
|
+
var topmost, _result$position, clientX, clientY, targets, _iterator, _step, element, id, index, target;
|
|
4684
4333
|
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
index = id.lastIndexOf('_');
|
|
4693
|
-
target = _this.displayObjectPool.getByEntity(Number(id.substring(index + 1))); // don't need to account for `visibility` since DOM API already does
|
|
4334
|
+
return _regeneratorRuntime$3().wrap(function _callee$(_context) {
|
|
4335
|
+
while (1) {
|
|
4336
|
+
switch (_context.prev = _context.next) {
|
|
4337
|
+
case 0:
|
|
4338
|
+
topmost = result.topmost, _result$position = result.position, clientX = _result$position.clientX, clientY = _result$position.clientY;
|
|
4339
|
+
_context.prev = 1;
|
|
4340
|
+
targets = []; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
|
|
4694
4341
|
|
|
4695
|
-
|
|
4696
|
-
_context.next = 17;
|
|
4697
|
-
break;
|
|
4698
|
-
}
|
|
4342
|
+
_iterator = _createForOfIteratorHelperLoose((doc || document).elementsFromPoint(clientX, clientY));
|
|
4699
4343
|
|
|
4700
|
-
|
|
4344
|
+
case 4:
|
|
4345
|
+
if ((_step = _iterator()).done) {
|
|
4346
|
+
_context.next = 17;
|
|
4347
|
+
break;
|
|
4348
|
+
}
|
|
4701
4349
|
|
|
4702
|
-
|
|
4703
|
-
_context.next = 17;
|
|
4704
|
-
break;
|
|
4705
|
-
}
|
|
4350
|
+
element = _step.value; // eg. g_svg_circle_345
|
|
4706
4351
|
|
|
4707
|
-
|
|
4708
|
-
return _context.abrupt("return", result);
|
|
4352
|
+
id = element && element.getAttribute('id');
|
|
4709
4353
|
|
|
4710
|
-
|
|
4711
|
-
_context.next =
|
|
4354
|
+
if (!(id && id.startsWith(G_SVG_PREFIX))) {
|
|
4355
|
+
_context.next = 15;
|
|
4712
4356
|
break;
|
|
4357
|
+
}
|
|
4713
4358
|
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
break;
|
|
4359
|
+
index = id.lastIndexOf('_');
|
|
4360
|
+
target = _this.displayObjectPool.getByEntity(Number(id.substring(index + 1))); // don't need to account for `visibility` since DOM API already does
|
|
4717
4361
|
|
|
4718
|
-
|
|
4719
|
-
_context.
|
|
4720
|
-
|
|
4362
|
+
if (!(target && target.isInteractive())) {
|
|
4363
|
+
_context.next = 15;
|
|
4364
|
+
break;
|
|
4365
|
+
}
|
|
4721
4366
|
|
|
4722
|
-
|
|
4367
|
+
targets.push(target);
|
|
4723
4368
|
|
|
4724
|
-
|
|
4725
|
-
_context.
|
|
4369
|
+
if (!topmost) {
|
|
4370
|
+
_context.next = 15;
|
|
4371
|
+
break;
|
|
4372
|
+
}
|
|
4726
4373
|
|
|
4727
|
-
|
|
4374
|
+
result.picked = targets;
|
|
4375
|
+
return _context.abrupt("return", result);
|
|
4728
4376
|
|
|
4729
|
-
|
|
4377
|
+
case 15:
|
|
4378
|
+
_context.next = 4;
|
|
4379
|
+
break;
|
|
4730
4380
|
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4381
|
+
case 17:
|
|
4382
|
+
result.picked = targets;
|
|
4383
|
+
_context.next = 23;
|
|
4384
|
+
break;
|
|
4735
4385
|
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4386
|
+
case 20:
|
|
4387
|
+
_context.prev = 20;
|
|
4388
|
+
_context.t0 = _context["catch"](1);
|
|
4389
|
+
result.picked = [];
|
|
4740
4390
|
|
|
4741
|
-
|
|
4742
|
-
|
|
4391
|
+
case 23:
|
|
4392
|
+
return _context.abrupt("return", result);
|
|
4743
4393
|
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
}
|
|
4394
|
+
case 24:
|
|
4395
|
+
case "end":
|
|
4396
|
+
return _context.stop();
|
|
4748
4397
|
}
|
|
4749
|
-
}
|
|
4750
|
-
})
|
|
4398
|
+
}
|
|
4399
|
+
}, _callee, null, [[1, 20]]);
|
|
4400
|
+
}));
|
|
4751
4401
|
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
}]);
|
|
4402
|
+
return function (_x) {
|
|
4403
|
+
return _ref.apply(this, arguments);
|
|
4404
|
+
};
|
|
4405
|
+
}());
|
|
4406
|
+
};
|
|
4758
4407
|
|
|
4759
4408
|
return SVGPickerPlugin;
|
|
4760
4409
|
}(), _class$2.tag = 'SVGPicker', _class$2);
|
|
@@ -4772,22 +4421,18 @@
|
|
|
4772
4421
|
|
|
4773
4422
|
var Plugin$2 = /*#__PURE__*/function () {
|
|
4774
4423
|
function Plugin() {
|
|
4775
|
-
_classCallCheck$3(this, Plugin);
|
|
4776
|
-
|
|
4777
4424
|
this.name = 'svg-picker';
|
|
4778
4425
|
}
|
|
4779
4426
|
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
}
|
|
4790
|
-
}]);
|
|
4427
|
+
var _proto = Plugin.prototype;
|
|
4428
|
+
|
|
4429
|
+
_proto.init = function init(container) {
|
|
4430
|
+
container.load(containerModule$2, true);
|
|
4431
|
+
};
|
|
4432
|
+
|
|
4433
|
+
_proto.destroy = function destroy(container) {
|
|
4434
|
+
container.unload(containerModule$2);
|
|
4435
|
+
};
|
|
4791
4436
|
|
|
4792
4437
|
return Plugin;
|
|
4793
4438
|
}();
|
|
@@ -4799,105 +4444,95 @@
|
|
|
4799
4444
|
|
|
4800
4445
|
var SVGContextService = /*#__PURE__*/function () {
|
|
4801
4446
|
function SVGContextService() {
|
|
4802
|
-
_classCallCheck(this, SVGContextService);
|
|
4803
|
-
|
|
4804
4447
|
this.$container = void 0;
|
|
4805
4448
|
this.$namespace = void 0;
|
|
4806
4449
|
this.dpr = void 0;
|
|
4807
4450
|
this.canvasConfig = void 0;
|
|
4808
4451
|
}
|
|
4809
4452
|
|
|
4810
|
-
|
|
4811
|
-
key: "init",
|
|
4812
|
-
value: function () {
|
|
4813
|
-
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
4814
|
-
var _this$canvasConfig, container, doc, $namespace, dpr;
|
|
4453
|
+
var _proto = SVGContextService.prototype;
|
|
4815
4454
|
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
case 0:
|
|
4820
|
-
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document; // create container
|
|
4455
|
+
_proto.init = /*#__PURE__*/function () {
|
|
4456
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
4457
|
+
var _this$canvasConfig, container, doc, $namespace, dpr;
|
|
4821
4458
|
|
|
4822
|
-
|
|
4459
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4460
|
+
while (1) {
|
|
4461
|
+
switch (_context.prev = _context.next) {
|
|
4462
|
+
case 0:
|
|
4463
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document; // create container
|
|
4823
4464
|
|
|
4824
|
-
|
|
4825
|
-
if (!this.$container.style.position) {
|
|
4826
|
-
this.$container.style.position = 'relative';
|
|
4827
|
-
}
|
|
4465
|
+
this.$container = g.isString(container) ? (doc || document).getElementById(container) : container;
|
|
4828
4466
|
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
this.$container.appendChild($namespace);
|
|
4833
|
-
this.$namespace = $namespace;
|
|
4467
|
+
if (this.$container) {
|
|
4468
|
+
if (!this.$container.style.position) {
|
|
4469
|
+
this.$container.style.position = 'relative';
|
|
4834
4470
|
}
|
|
4835
4471
|
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4472
|
+
$namespace = createSVGElement('svg', doc);
|
|
4473
|
+
$namespace.setAttribute('width', "" + this.canvasConfig.width);
|
|
4474
|
+
$namespace.setAttribute('height', "" + this.canvasConfig.height);
|
|
4475
|
+
this.$container.appendChild($namespace);
|
|
4476
|
+
this.$namespace = $namespace;
|
|
4477
|
+
}
|
|
4839
4478
|
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4479
|
+
dpr = window.devicePixelRatio || 1;
|
|
4480
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
4481
|
+
this.dpr = dpr;
|
|
4482
|
+
|
|
4483
|
+
case 6:
|
|
4484
|
+
case "end":
|
|
4485
|
+
return _context.stop();
|
|
4844
4486
|
}
|
|
4845
|
-
}
|
|
4846
|
-
})
|
|
4487
|
+
}
|
|
4488
|
+
}, _callee, this);
|
|
4489
|
+
}));
|
|
4847
4490
|
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4491
|
+
function init() {
|
|
4492
|
+
return _init.apply(this, arguments);
|
|
4493
|
+
}
|
|
4851
4494
|
|
|
4852
|
-
|
|
4853
|
-
|
|
4495
|
+
return init;
|
|
4496
|
+
}() // @ts-ignore
|
|
4497
|
+
;
|
|
4854
4498
|
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
return this.$namespace;
|
|
4859
|
-
}
|
|
4860
|
-
}, {
|
|
4861
|
-
key: "getContext",
|
|
4862
|
-
value: function getContext() {
|
|
4863
|
-
return this.$namespace;
|
|
4864
|
-
}
|
|
4865
|
-
}, {
|
|
4866
|
-
key: "getDPR",
|
|
4867
|
-
value: function getDPR() {
|
|
4868
|
-
return this.dpr;
|
|
4869
|
-
}
|
|
4870
|
-
}, {
|
|
4871
|
-
key: "getBoundingClientRect",
|
|
4872
|
-
value: function getBoundingClientRect() {
|
|
4873
|
-
var _this$$namespace;
|
|
4499
|
+
_proto.getDomElement = function getDomElement() {
|
|
4500
|
+
return this.$namespace;
|
|
4501
|
+
};
|
|
4874
4502
|
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
}
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4503
|
+
_proto.getContext = function getContext() {
|
|
4504
|
+
return this.$namespace;
|
|
4505
|
+
};
|
|
4506
|
+
|
|
4507
|
+
_proto.getDPR = function getDPR() {
|
|
4508
|
+
return this.dpr;
|
|
4509
|
+
};
|
|
4510
|
+
|
|
4511
|
+
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
4512
|
+
var _this$$namespace;
|
|
4513
|
+
|
|
4514
|
+
return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
|
|
4515
|
+
};
|
|
4516
|
+
|
|
4517
|
+
_proto.destroy = function destroy() {
|
|
4518
|
+
// destroy context
|
|
4519
|
+
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
4520
|
+
this.$container.removeChild(this.$namespace);
|
|
4884
4521
|
}
|
|
4885
|
-
}
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
}
|
|
4522
|
+
};
|
|
4523
|
+
|
|
4524
|
+
_proto.resize = function resize(width, height) {
|
|
4525
|
+
if (this.$namespace) {
|
|
4526
|
+
this.$namespace.setAttribute('width', "" + width);
|
|
4527
|
+
this.$namespace.setAttribute('height', "" + height);
|
|
4892
4528
|
}
|
|
4893
|
-
}
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
}
|
|
4529
|
+
};
|
|
4530
|
+
|
|
4531
|
+
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
4532
|
+
if (this.$container) {
|
|
4533
|
+
this.$container.style.cursor = cursor;
|
|
4899
4534
|
}
|
|
4900
|
-
}
|
|
4535
|
+
};
|
|
4901
4536
|
|
|
4902
4537
|
return SVGContextService;
|
|
4903
4538
|
}();
|
|
@@ -4916,37 +4551,29 @@
|
|
|
4916
4551
|
});
|
|
4917
4552
|
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
4918
4553
|
function ContextRegisterPlugin() {
|
|
4919
|
-
_classCallCheck(this, ContextRegisterPlugin);
|
|
4920
|
-
|
|
4921
4554
|
this.name = 'svg-context-register';
|
|
4922
4555
|
}
|
|
4923
4556
|
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
}
|
|
4934
|
-
}]);
|
|
4557
|
+
var _proto = ContextRegisterPlugin.prototype;
|
|
4558
|
+
|
|
4559
|
+
_proto.init = function init(container) {
|
|
4560
|
+
container.load(containerModule$3, true);
|
|
4561
|
+
};
|
|
4562
|
+
|
|
4563
|
+
_proto.destroy = function destroy(container) {
|
|
4564
|
+
container.unload(containerModule$3);
|
|
4565
|
+
};
|
|
4935
4566
|
|
|
4936
4567
|
return ContextRegisterPlugin;
|
|
4937
4568
|
}();
|
|
4938
4569
|
|
|
4939
4570
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
var _super = _createSuper(Renderer);
|
|
4571
|
+
_inheritsLoose(Renderer, _AbstractRenderer);
|
|
4943
4572
|
|
|
4944
4573
|
function Renderer(config) {
|
|
4945
4574
|
var _this;
|
|
4946
4575
|
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
_this = _super.call(this, config);
|
|
4576
|
+
_this = _AbstractRenderer.call(this, config) || this;
|
|
4950
4577
|
|
|
4951
4578
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
4952
4579
|
|
|
@@ -4959,7 +4586,7 @@
|
|
|
4959
4586
|
return _this;
|
|
4960
4587
|
}
|
|
4961
4588
|
|
|
4962
|
-
return
|
|
4589
|
+
return Renderer;
|
|
4963
4590
|
}(g.AbstractRenderer);
|
|
4964
4591
|
|
|
4965
4592
|
exports.DomInteraction = index_esm;
|