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