@antv/g-svg 1.8.29 → 1.8.31
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/SVGContextService.d.ts +2 -0
- package/dist/SVGContextService.d.ts.map +1 -1
- package/dist/index.esm.js +240 -222
- package/dist/index.js +239 -221
- package/dist/index.umd.js +1196 -1640
- 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,58 +347,17 @@
|
|
|
395
347
|
};
|
|
396
348
|
return _setPrototypeOf(o, p);
|
|
397
349
|
}
|
|
398
|
-
function
|
|
399
|
-
if (
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
function _assertThisInitialized(self) {
|
|
410
|
-
if (self === void 0) {
|
|
411
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
412
|
-
}
|
|
413
|
-
return self;
|
|
414
|
-
}
|
|
415
|
-
function _possibleConstructorReturn(self, call) {
|
|
416
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
417
|
-
return call;
|
|
418
|
-
} else if (call !== void 0) {
|
|
419
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
420
|
-
}
|
|
421
|
-
return _assertThisInitialized(self);
|
|
422
|
-
}
|
|
423
|
-
function _createSuper(Derived) {
|
|
424
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
425
|
-
return function _createSuperInternal() {
|
|
426
|
-
var Super = _getPrototypeOf(Derived),
|
|
427
|
-
result;
|
|
428
|
-
if (hasNativeReflectConstruct) {
|
|
429
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
430
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
431
|
-
} else {
|
|
432
|
-
result = Super.apply(this, arguments);
|
|
433
|
-
}
|
|
434
|
-
return _possibleConstructorReturn(this, result);
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
function _toPrimitive(input, hint) {
|
|
438
|
-
if (typeof input !== "object" || input === null) return input;
|
|
439
|
-
var prim = input[Symbol.toPrimitive];
|
|
440
|
-
if (prim !== undefined) {
|
|
441
|
-
var res = prim.call(input, hint || "default");
|
|
442
|
-
if (typeof res !== "object") return res;
|
|
443
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
350
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
351
|
+
if (source == null) return {};
|
|
352
|
+
var target = {};
|
|
353
|
+
var sourceKeys = Object.keys(source);
|
|
354
|
+
var key, i;
|
|
355
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
356
|
+
key = sourceKeys[i];
|
|
357
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
358
|
+
target[key] = source[key];
|
|
444
359
|
}
|
|
445
|
-
return
|
|
446
|
-
}
|
|
447
|
-
function _toPropertyKey(arg) {
|
|
448
|
-
var key = _toPrimitive(arg, "string");
|
|
449
|
-
return typeof key === "symbol" ? key : String(key);
|
|
360
|
+
return target;
|
|
450
361
|
}
|
|
451
362
|
|
|
452
363
|
function _regeneratorRuntime$1() {
|
|
@@ -525,7 +436,7 @@
|
|
|
525
436
|
if ("throw" !== record.type) {
|
|
526
437
|
var result = record.arg,
|
|
527
438
|
value = result.value;
|
|
528
|
-
return value && "object" ==
|
|
439
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
529
440
|
invoke("next", value, resolve, reject);
|
|
530
441
|
}, function (err) {
|
|
531
442
|
invoke("throw", err, resolve, reject);
|
|
@@ -786,49 +697,10 @@
|
|
|
786
697
|
});
|
|
787
698
|
};
|
|
788
699
|
}
|
|
789
|
-
function
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
}
|
|
794
|
-
function _defineProperties$1(target, props) {
|
|
795
|
-
for (var i = 0; i < props.length; i++) {
|
|
796
|
-
var descriptor = props[i];
|
|
797
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
798
|
-
descriptor.configurable = true;
|
|
799
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
800
|
-
Object.defineProperty(target, _toPropertyKey$1(descriptor.key), descriptor);
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
function _createClass$1(Constructor, protoProps, staticProps) {
|
|
804
|
-
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
805
|
-
if (staticProps) _defineProperties$1(Constructor, staticProps);
|
|
806
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
807
|
-
writable: false
|
|
808
|
-
});
|
|
809
|
-
return Constructor;
|
|
810
|
-
}
|
|
811
|
-
function _inherits$1(subClass, superClass) {
|
|
812
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
813
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
814
|
-
}
|
|
815
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
816
|
-
constructor: {
|
|
817
|
-
value: subClass,
|
|
818
|
-
writable: true,
|
|
819
|
-
configurable: true
|
|
820
|
-
}
|
|
821
|
-
});
|
|
822
|
-
Object.defineProperty(subClass, "prototype", {
|
|
823
|
-
writable: false
|
|
824
|
-
});
|
|
825
|
-
if (superClass) _setPrototypeOf$1(subClass, superClass);
|
|
826
|
-
}
|
|
827
|
-
function _getPrototypeOf$1(o) {
|
|
828
|
-
_getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
829
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
830
|
-
};
|
|
831
|
-
return _getPrototypeOf$1(o);
|
|
700
|
+
function _inheritsLoose$1(subClass, superClass) {
|
|
701
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
702
|
+
subClass.prototype.constructor = subClass;
|
|
703
|
+
_setPrototypeOf$1(subClass, superClass);
|
|
832
704
|
}
|
|
833
705
|
function _setPrototypeOf$1(o, p) {
|
|
834
706
|
_setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -837,59 +709,6 @@
|
|
|
837
709
|
};
|
|
838
710
|
return _setPrototypeOf$1(o, p);
|
|
839
711
|
}
|
|
840
|
-
function _isNativeReflectConstruct$1() {
|
|
841
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
842
|
-
if (Reflect.construct.sham) return false;
|
|
843
|
-
if (typeof Proxy === "function") return true;
|
|
844
|
-
try {
|
|
845
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
846
|
-
return true;
|
|
847
|
-
} catch (e) {
|
|
848
|
-
return false;
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
function _assertThisInitialized$1(self) {
|
|
852
|
-
if (self === void 0) {
|
|
853
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
854
|
-
}
|
|
855
|
-
return self;
|
|
856
|
-
}
|
|
857
|
-
function _possibleConstructorReturn$1(self, call) {
|
|
858
|
-
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
859
|
-
return call;
|
|
860
|
-
} else if (call !== void 0) {
|
|
861
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
862
|
-
}
|
|
863
|
-
return _assertThisInitialized$1(self);
|
|
864
|
-
}
|
|
865
|
-
function _createSuper$1(Derived) {
|
|
866
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct$1();
|
|
867
|
-
return function _createSuperInternal() {
|
|
868
|
-
var Super = _getPrototypeOf$1(Derived),
|
|
869
|
-
result;
|
|
870
|
-
if (hasNativeReflectConstruct) {
|
|
871
|
-
var NewTarget = _getPrototypeOf$1(this).constructor;
|
|
872
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
873
|
-
} else {
|
|
874
|
-
result = Super.apply(this, arguments);
|
|
875
|
-
}
|
|
876
|
-
return _possibleConstructorReturn$1(this, result);
|
|
877
|
-
};
|
|
878
|
-
}
|
|
879
|
-
function _toPrimitive$1(input, hint) {
|
|
880
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
881
|
-
var prim = input[Symbol.toPrimitive];
|
|
882
|
-
if (prim !== undefined) {
|
|
883
|
-
var res = prim.call(input, hint || "default");
|
|
884
|
-
if (_typeof(res) !== "object") return res;
|
|
885
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
886
|
-
}
|
|
887
|
-
return (hint === "string" ? String : Number)(input);
|
|
888
|
-
}
|
|
889
|
-
function _toPropertyKey$1(arg) {
|
|
890
|
-
var key = _toPrimitive$1(arg, "string");
|
|
891
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
892
|
-
}
|
|
893
712
|
|
|
894
713
|
// const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
|
895
714
|
/**
|
|
@@ -897,165 +716,156 @@
|
|
|
897
716
|
*/
|
|
898
717
|
var DOMInteractionPlugin = /*#__PURE__*/function () {
|
|
899
718
|
function DOMInteractionPlugin() {
|
|
900
|
-
_classCallCheck$1(this, DOMInteractionPlugin);
|
|
901
719
|
this.context = void 0;
|
|
902
720
|
}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
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
|
-
return _context.stop();
|
|
1005
|
-
}
|
|
721
|
+
var _proto = DOMInteractionPlugin.prototype;
|
|
722
|
+
_proto.apply = function apply(context) {
|
|
723
|
+
var _this = this;
|
|
724
|
+
var renderingService = context.renderingService,
|
|
725
|
+
renderingContext = context.renderingContext;
|
|
726
|
+
this.context = context;
|
|
727
|
+
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
728
|
+
// const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
|
|
729
|
+
var onPointerMove = function onPointerMove(ev) {
|
|
730
|
+
renderingService.hooks.pointerMove.call(ev);
|
|
731
|
+
};
|
|
732
|
+
var onPointerUp = function onPointerUp(ev) {
|
|
733
|
+
renderingService.hooks.pointerUp.call(ev);
|
|
734
|
+
};
|
|
735
|
+
var onPointerDown = function onPointerDown(ev) {
|
|
736
|
+
renderingService.hooks.pointerDown.call(ev);
|
|
737
|
+
};
|
|
738
|
+
var onPointerOver = function onPointerOver(ev) {
|
|
739
|
+
renderingService.hooks.pointerOver.call(ev);
|
|
740
|
+
};
|
|
741
|
+
var onPointerOut = function onPointerOut(ev) {
|
|
742
|
+
renderingService.hooks.pointerOut.call(ev);
|
|
743
|
+
};
|
|
744
|
+
var onPointerCancel = function onPointerCancel(ev) {
|
|
745
|
+
renderingService.hooks.pointerCancel.call(ev);
|
|
746
|
+
};
|
|
747
|
+
var onPointerWheel = function onPointerWheel(ev) {
|
|
748
|
+
renderingService.hooks.pointerWheel.call(ev);
|
|
749
|
+
};
|
|
750
|
+
var addPointerEventListener = function addPointerEventListener($el) {
|
|
751
|
+
gLite.runtime.globalThis.document.addEventListener('pointermove', onPointerMove, true);
|
|
752
|
+
$el.addEventListener('pointerdown', onPointerDown, true);
|
|
753
|
+
$el.addEventListener('pointerleave', onPointerOut, true);
|
|
754
|
+
$el.addEventListener('pointerover', onPointerOver, true);
|
|
755
|
+
gLite.runtime.globalThis.addEventListener('pointerup', onPointerUp, true);
|
|
756
|
+
};
|
|
757
|
+
var addTouchEventListener = function addTouchEventListener($el) {
|
|
758
|
+
$el.addEventListener('touchstart', onPointerDown, true);
|
|
759
|
+
$el.addEventListener('touchend', onPointerUp, true);
|
|
760
|
+
$el.addEventListener('touchmove', onPointerMove, true);
|
|
761
|
+
$el.addEventListener('touchcancel', onPointerCancel, true);
|
|
762
|
+
};
|
|
763
|
+
var addMouseEventListener = function addMouseEventListener($el) {
|
|
764
|
+
gLite.runtime.globalThis.document.addEventListener('mousemove', onPointerMove, true);
|
|
765
|
+
$el.addEventListener('mousedown', onPointerDown, true);
|
|
766
|
+
$el.addEventListener('mouseout', onPointerOut, true);
|
|
767
|
+
$el.addEventListener('mouseover', onPointerOver, true);
|
|
768
|
+
gLite.runtime.globalThis.addEventListener('mouseup', onPointerUp, true);
|
|
769
|
+
};
|
|
770
|
+
var removePointerEventListener = function removePointerEventListener($el) {
|
|
771
|
+
gLite.runtime.globalThis.document.removeEventListener('pointermove', onPointerMove, true);
|
|
772
|
+
$el.removeEventListener('pointerdown', onPointerDown, true);
|
|
773
|
+
$el.removeEventListener('pointerleave', onPointerOut, true);
|
|
774
|
+
$el.removeEventListener('pointerover', onPointerOver, true);
|
|
775
|
+
gLite.runtime.globalThis.removeEventListener('pointerup', onPointerUp, true);
|
|
776
|
+
};
|
|
777
|
+
var removeTouchEventListener = function removeTouchEventListener($el) {
|
|
778
|
+
$el.removeEventListener('touchstart', onPointerDown, true);
|
|
779
|
+
$el.removeEventListener('touchend', onPointerUp, true);
|
|
780
|
+
$el.removeEventListener('touchmove', onPointerMove, true);
|
|
781
|
+
$el.removeEventListener('touchcancel', onPointerCancel, true);
|
|
782
|
+
};
|
|
783
|
+
var removeMouseEventListener = function removeMouseEventListener($el) {
|
|
784
|
+
gLite.runtime.globalThis.document.removeEventListener('mousemove', onPointerMove, true);
|
|
785
|
+
$el.removeEventListener('mousedown', onPointerDown, true);
|
|
786
|
+
$el.removeEventListener('mouseout', onPointerOut, true);
|
|
787
|
+
$el.removeEventListener('mouseover', onPointerOver, true);
|
|
788
|
+
gLite.runtime.globalThis.removeEventListener('mouseup', onPointerUp, true);
|
|
789
|
+
};
|
|
790
|
+
renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
|
|
791
|
+
var $el;
|
|
792
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
793
|
+
while (1) {
|
|
794
|
+
switch (_context.prev = _context.next) {
|
|
795
|
+
case 0:
|
|
796
|
+
$el = _this.context.contextService.getDomElement(); // @ts-ignore
|
|
797
|
+
if (gLite.runtime.globalThis.navigator.msPointerEnabled) {
|
|
798
|
+
// @ts-ignore
|
|
799
|
+
$el.style.msContentZooming = 'none';
|
|
800
|
+
// @ts-ignore
|
|
801
|
+
$el.style.msTouchAction = 'none';
|
|
802
|
+
} else if (canvas.supportsPointerEvents) {
|
|
803
|
+
$el.style.touchAction = 'none';
|
|
804
|
+
}
|
|
805
|
+
if (canvas.supportsPointerEvents) {
|
|
806
|
+
addPointerEventListener($el);
|
|
807
|
+
} else {
|
|
808
|
+
addMouseEventListener($el);
|
|
809
|
+
}
|
|
810
|
+
if (canvas.supportsTouchEvents) {
|
|
811
|
+
addTouchEventListener($el);
|
|
812
|
+
}
|
|
813
|
+
// use passive event listeners
|
|
814
|
+
// @see https://zhuanlan.zhihu.com/p/24555031
|
|
815
|
+
$el.addEventListener('wheel', onPointerWheel, {
|
|
816
|
+
passive: true,
|
|
817
|
+
capture: true
|
|
818
|
+
});
|
|
819
|
+
case 5:
|
|
820
|
+
case "end":
|
|
821
|
+
return _context.stop();
|
|
1006
822
|
}
|
|
1007
|
-
}, _callee);
|
|
1008
|
-
})));
|
|
1009
|
-
renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () {
|
|
1010
|
-
var $el = _this.context.contextService.getDomElement();
|
|
1011
|
-
// @ts-ignore
|
|
1012
|
-
if (globalThis.navigator.msPointerEnabled) {
|
|
1013
|
-
// @ts-ignore
|
|
1014
|
-
$el.style.msContentZooming = '';
|
|
1015
|
-
// @ts-ignore
|
|
1016
|
-
$el.style.msTouchAction = '';
|
|
1017
|
-
} else if (canvas.supportsPointerEvents) {
|
|
1018
|
-
$el.style.touchAction = '';
|
|
1019
|
-
}
|
|
1020
|
-
if (canvas.supportsPointerEvents) {
|
|
1021
|
-
removePointerEventListener($el);
|
|
1022
|
-
} else {
|
|
1023
|
-
removeMouseEventListener($el);
|
|
1024
|
-
}
|
|
1025
|
-
if (canvas.supportsTouchEvents) {
|
|
1026
|
-
removeTouchEventListener($el);
|
|
1027
823
|
}
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
824
|
+
}, _callee);
|
|
825
|
+
})));
|
|
826
|
+
renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () {
|
|
827
|
+
var $el = _this.context.contextService.getDomElement();
|
|
828
|
+
// @ts-ignore
|
|
829
|
+
if (gLite.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
|
+
$el.removeEventListener('wheel', onPointerWheel, true);
|
|
846
|
+
});
|
|
847
|
+
};
|
|
1032
848
|
return DOMInteractionPlugin;
|
|
1033
849
|
}();
|
|
1034
850
|
DOMInteractionPlugin.tag = 'DOMInteraction';
|
|
1035
851
|
var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
1036
|
-
|
|
1037
|
-
var _super = _createSuper$1(Plugin);
|
|
852
|
+
_inheritsLoose$1(Plugin, _AbstractRendererPlug);
|
|
1038
853
|
function Plugin() {
|
|
1039
854
|
var _this;
|
|
1040
|
-
_classCallCheck$1(this, Plugin);
|
|
1041
855
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1042
856
|
args[_key] = arguments[_key];
|
|
1043
857
|
}
|
|
1044
|
-
_this =
|
|
858
|
+
_this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
|
|
1045
859
|
_this.name = 'dom-interaction';
|
|
1046
860
|
return _this;
|
|
1047
861
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
value: function destroy() {
|
|
1056
|
-
this.removeAllRenderingPlugins();
|
|
1057
|
-
}
|
|
1058
|
-
}]);
|
|
862
|
+
var _proto = Plugin.prototype;
|
|
863
|
+
_proto.init = function init() {
|
|
864
|
+
this.addRenderingPlugin(new DOMInteractionPlugin());
|
|
865
|
+
};
|
|
866
|
+
_proto.destroy = function destroy() {
|
|
867
|
+
this.removeAllRenderingPlugins();
|
|
868
|
+
};
|
|
1059
869
|
return Plugin;
|
|
1060
870
|
}(gLite.AbstractRendererPlugin);
|
|
1061
871
|
|
|
@@ -1411,56 +1221,6 @@
|
|
|
1411
1221
|
return output;
|
|
1412
1222
|
}
|
|
1413
1223
|
|
|
1414
|
-
function _iterableToArrayLimit(arr, i) {
|
|
1415
|
-
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1416
|
-
if (null != _i) {
|
|
1417
|
-
var _s,
|
|
1418
|
-
_e,
|
|
1419
|
-
_x,
|
|
1420
|
-
_r,
|
|
1421
|
-
_arr = [],
|
|
1422
|
-
_n = !0,
|
|
1423
|
-
_d = !1;
|
|
1424
|
-
try {
|
|
1425
|
-
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
1426
|
-
if (Object(_i) !== _i) return;
|
|
1427
|
-
_n = !1;
|
|
1428
|
-
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) {
|
|
1429
|
-
;
|
|
1430
|
-
}
|
|
1431
|
-
} catch (err) {
|
|
1432
|
-
_d = !0, _e = err;
|
|
1433
|
-
} finally {
|
|
1434
|
-
try {
|
|
1435
|
-
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
1436
|
-
} finally {
|
|
1437
|
-
if (_d) throw _e;
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
return _arr;
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
function ownKeys(object, enumerableOnly) {
|
|
1444
|
-
var keys = Object.keys(object);
|
|
1445
|
-
if (Object.getOwnPropertySymbols) {
|
|
1446
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
1447
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
1448
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
1449
|
-
})), keys.push.apply(keys, symbols);
|
|
1450
|
-
}
|
|
1451
|
-
return keys;
|
|
1452
|
-
}
|
|
1453
|
-
function _objectSpread2(target) {
|
|
1454
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
1455
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
1456
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
1457
|
-
_defineProperty(target, key, source[key]);
|
|
1458
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
1459
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1460
|
-
});
|
|
1461
|
-
}
|
|
1462
|
-
return target;
|
|
1463
|
-
}
|
|
1464
1224
|
function _regeneratorRuntime$2() {
|
|
1465
1225
|
_regeneratorRuntime$2 = function _regeneratorRuntime() {
|
|
1466
1226
|
return exports;
|
|
@@ -1537,7 +1297,7 @@
|
|
|
1537
1297
|
if ("throw" !== record.type) {
|
|
1538
1298
|
var result = record.arg,
|
|
1539
1299
|
value = result.value;
|
|
1540
|
-
return value && "object" ==
|
|
1300
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
1541
1301
|
invoke("next", value, resolve, reject);
|
|
1542
1302
|
}, function (err) {
|
|
1543
1303
|
invoke("throw", err, resolve, reject);
|
|
@@ -1798,63 +1558,24 @@
|
|
|
1798
1558
|
});
|
|
1799
1559
|
};
|
|
1800
1560
|
}
|
|
1801
|
-
function
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
descriptor.configurable = true;
|
|
1811
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
1812
|
-
Object.defineProperty(target, _toPropertyKey$2(descriptor.key), descriptor);
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
|
-
function _createClass$2(Constructor, protoProps, staticProps) {
|
|
1816
|
-
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
|
|
1817
|
-
if (staticProps) _defineProperties$2(Constructor, staticProps);
|
|
1818
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
1819
|
-
writable: false
|
|
1820
|
-
});
|
|
1821
|
-
return Constructor;
|
|
1822
|
-
}
|
|
1823
|
-
function _defineProperty(obj, key, value) {
|
|
1824
|
-
key = _toPropertyKey$2(key);
|
|
1825
|
-
if (key in obj) {
|
|
1826
|
-
Object.defineProperty(obj, key, {
|
|
1827
|
-
value: value,
|
|
1828
|
-
enumerable: true,
|
|
1829
|
-
configurable: true,
|
|
1830
|
-
writable: true
|
|
1831
|
-
});
|
|
1832
|
-
} else {
|
|
1833
|
-
obj[key] = value;
|
|
1834
|
-
}
|
|
1835
|
-
return obj;
|
|
1836
|
-
}
|
|
1837
|
-
function _inherits$2(subClass, superClass) {
|
|
1838
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
1839
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
1840
|
-
}
|
|
1841
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
1842
|
-
constructor: {
|
|
1843
|
-
value: subClass,
|
|
1844
|
-
writable: true,
|
|
1845
|
-
configurable: true
|
|
1561
|
+
function _extends() {
|
|
1562
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
1563
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1564
|
+
var source = arguments[i];
|
|
1565
|
+
for (var key in source) {
|
|
1566
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1567
|
+
target[key] = source[key];
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1846
1570
|
}
|
|
1847
|
-
|
|
1848
|
-
Object.defineProperty(subClass, "prototype", {
|
|
1849
|
-
writable: false
|
|
1850
|
-
});
|
|
1851
|
-
if (superClass) _setPrototypeOf$2(subClass, superClass);
|
|
1852
|
-
}
|
|
1853
|
-
function _getPrototypeOf$2(o) {
|
|
1854
|
-
_getPrototypeOf$2 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
1855
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
1571
|
+
return target;
|
|
1856
1572
|
};
|
|
1857
|
-
return
|
|
1573
|
+
return _extends.apply(this, arguments);
|
|
1574
|
+
}
|
|
1575
|
+
function _inheritsLoose$2(subClass, superClass) {
|
|
1576
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
1577
|
+
subClass.prototype.constructor = subClass;
|
|
1578
|
+
_setPrototypeOf$2(subClass, superClass);
|
|
1858
1579
|
}
|
|
1859
1580
|
function _setPrototypeOf$2(o, p) {
|
|
1860
1581
|
_setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -1863,89 +1584,11 @@
|
|
|
1863
1584
|
};
|
|
1864
1585
|
return _setPrototypeOf$2(o, p);
|
|
1865
1586
|
}
|
|
1866
|
-
function
|
|
1867
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
1868
|
-
if (Reflect.construct.sham) return false;
|
|
1869
|
-
if (typeof Proxy === "function") return true;
|
|
1870
|
-
try {
|
|
1871
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
1872
|
-
return true;
|
|
1873
|
-
} catch (e) {
|
|
1874
|
-
return false;
|
|
1875
|
-
}
|
|
1876
|
-
}
|
|
1877
|
-
function _assertThisInitialized$2(self) {
|
|
1878
|
-
if (self === void 0) {
|
|
1879
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
1880
|
-
}
|
|
1881
|
-
return self;
|
|
1882
|
-
}
|
|
1883
|
-
function _possibleConstructorReturn$2(self, call) {
|
|
1884
|
-
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
1885
|
-
return call;
|
|
1886
|
-
} else if (call !== void 0) {
|
|
1887
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
1888
|
-
}
|
|
1889
|
-
return _assertThisInitialized$2(self);
|
|
1890
|
-
}
|
|
1891
|
-
function _createSuper$2(Derived) {
|
|
1892
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct$2();
|
|
1893
|
-
return function _createSuperInternal() {
|
|
1894
|
-
var Super = _getPrototypeOf$2(Derived),
|
|
1895
|
-
result;
|
|
1896
|
-
if (hasNativeReflectConstruct) {
|
|
1897
|
-
var NewTarget = _getPrototypeOf$2(this).constructor;
|
|
1898
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
1899
|
-
} else {
|
|
1900
|
-
result = Super.apply(this, arguments);
|
|
1901
|
-
}
|
|
1902
|
-
return _possibleConstructorReturn$2(this, result);
|
|
1903
|
-
};
|
|
1904
|
-
}
|
|
1905
|
-
function _slicedToArray(arr, i) {
|
|
1906
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
1907
|
-
}
|
|
1908
|
-
function _arrayWithHoles(arr) {
|
|
1909
|
-
if (Array.isArray(arr)) return arr;
|
|
1910
|
-
}
|
|
1911
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
1912
|
-
if (!o) return;
|
|
1913
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
1914
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1915
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1916
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
1917
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
1918
|
-
}
|
|
1919
|
-
function _arrayLikeToArray(arr, len) {
|
|
1920
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
1921
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
1922
|
-
arr2[i] = arr[i];
|
|
1923
|
-
}
|
|
1924
|
-
return arr2;
|
|
1925
|
-
}
|
|
1926
|
-
function _nonIterableRest() {
|
|
1927
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1928
|
-
}
|
|
1929
|
-
function _toPrimitive$2(input, hint) {
|
|
1930
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
1931
|
-
var prim = input[Symbol.toPrimitive];
|
|
1932
|
-
if (prim !== undefined) {
|
|
1933
|
-
var res = prim.call(input, hint || "default");
|
|
1934
|
-
if (_typeof(res) !== "object") return res;
|
|
1935
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1936
|
-
}
|
|
1937
|
-
return (hint === "string" ? String : Number)(input);
|
|
1938
|
-
}
|
|
1939
|
-
function _toPropertyKey$2(arg) {
|
|
1940
|
-
var key = _toPrimitive$2(arg, "string");
|
|
1941
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
1942
|
-
}
|
|
1943
|
-
var ElementSVG = /*#__PURE__*/_createClass$2(function ElementSVG() {
|
|
1944
|
-
_classCallCheck$2(this, ElementSVG);
|
|
1587
|
+
var ElementSVG = function ElementSVG() {
|
|
1945
1588
|
this.$el = void 0;
|
|
1946
1589
|
this.$groupEl = void 0;
|
|
1947
1590
|
this.$hitTestingEl = void 0;
|
|
1948
|
-
}
|
|
1591
|
+
};
|
|
1949
1592
|
ElementSVG.tag = 'c-svg-element';
|
|
1950
1593
|
function updateImageElementAttribute($el, parsedStyle) {
|
|
1951
1594
|
var _parsedStyle$img = parsedStyle.img,
|
|
@@ -1958,13 +1601,13 @@
|
|
|
1958
1601
|
$el.setAttribute('href', img);
|
|
1959
1602
|
} else if (img instanceof Image) {
|
|
1960
1603
|
if (!width) {
|
|
1961
|
-
$el.setAttribute('width', ""
|
|
1604
|
+
$el.setAttribute('width', "" + img.width);
|
|
1962
1605
|
// TODO: set renderable.boundsDirty
|
|
1963
1606
|
// this.attr('width', img.width);
|
|
1964
1607
|
}
|
|
1965
1608
|
|
|
1966
1609
|
if (!height) {
|
|
1967
|
-
$el.setAttribute('height', ""
|
|
1610
|
+
$el.setAttribute('height', "" + img.height);
|
|
1968
1611
|
// this.attr('height', img.height);
|
|
1969
1612
|
}
|
|
1970
1613
|
|
|
@@ -1977,21 +1620,21 @@
|
|
|
1977
1620
|
} else if (img instanceof ImageData) {
|
|
1978
1621
|
var canvas = document.createElement('canvas');
|
|
1979
1622
|
// @ts-ignore
|
|
1980
|
-
canvas.setAttribute('width', ""
|
|
1623
|
+
canvas.setAttribute('width', "" + img.width);
|
|
1981
1624
|
// @ts-ignore
|
|
1982
|
-
canvas.setAttribute('height', ""
|
|
1625
|
+
canvas.setAttribute('height', "" + img.height);
|
|
1983
1626
|
var context = canvas.getContext('2d');
|
|
1984
1627
|
if (context) {
|
|
1985
1628
|
context.putImageData(img, 0, 0);
|
|
1986
1629
|
if (!width) {
|
|
1987
1630
|
// @ts-ignore
|
|
1988
|
-
$el.setAttribute('width', ""
|
|
1631
|
+
$el.setAttribute('width', "" + img.width);
|
|
1989
1632
|
// this.attr('width', img.width);
|
|
1990
1633
|
}
|
|
1991
1634
|
|
|
1992
1635
|
if (!height) {
|
|
1993
1636
|
// @ts-ignore
|
|
1994
|
-
$el.setAttribute('height', ""
|
|
1637
|
+
$el.setAttribute('height', "" + img.height);
|
|
1995
1638
|
// this.attr('height', img.height);
|
|
1996
1639
|
}
|
|
1997
1640
|
|
|
@@ -2034,10 +1677,10 @@
|
|
|
2034
1677
|
endOffsetY = Math.sin(rad) * (markerEndOffset || 0);
|
|
2035
1678
|
}
|
|
2036
1679
|
// @see https://github.com/antvis/g/issues/1038
|
|
2037
|
-
$el.setAttribute('x1', ""
|
|
2038
|
-
$el.setAttribute('y1', ""
|
|
2039
|
-
$el.setAttribute('x2', ""
|
|
2040
|
-
$el.setAttribute('y2', ""
|
|
1680
|
+
$el.setAttribute('x1', "" + (x1 - defX + startOffsetX));
|
|
1681
|
+
$el.setAttribute('y1', "" + (y1 - defY + startOffsetY));
|
|
1682
|
+
$el.setAttribute('x2', "" + (x2 - defX + endOffsetX));
|
|
1683
|
+
$el.setAttribute('y2', "" + (y2 - defY + endOffsetY));
|
|
2041
1684
|
}
|
|
2042
1685
|
function updatePathElementAttribute($el, parsedStyle) {
|
|
2043
1686
|
var path = parsedStyle.path,
|
|
@@ -2058,9 +1701,8 @@
|
|
|
2058
1701
|
var y;
|
|
2059
1702
|
if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
|
|
2060
1703
|
var _markerStart$parentNo = markerStart.parentNode.getStartTangent(),
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
p2 = _markerStart$parentNo2[1];
|
|
1704
|
+
p1 = _markerStart$parentNo[0],
|
|
1705
|
+
p2 = _markerStart$parentNo[1];
|
|
2064
1706
|
x = p1[0] - p2[0];
|
|
2065
1707
|
y = p1[1] - p2[1];
|
|
2066
1708
|
rad = Math.atan2(y, x);
|
|
@@ -2069,9 +1711,8 @@
|
|
|
2069
1711
|
}
|
|
2070
1712
|
if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
|
|
2071
1713
|
var _markerEnd$parentNode = markerEnd.parentNode.getEndTangent(),
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
_p2 = _markerEnd$parentNode2[1];
|
|
1714
|
+
_p = _markerEnd$parentNode[0],
|
|
1715
|
+
_p2 = _markerEnd$parentNode[1];
|
|
2075
1716
|
x = _p[0] - _p2[0];
|
|
2076
1717
|
y = _p[1] - _p2[1];
|
|
2077
1718
|
rad = Math.atan2(y, x);
|
|
@@ -2123,7 +1764,7 @@
|
|
|
2123
1764
|
offsetX = endOffsetX;
|
|
2124
1765
|
offsetY = endOffsetY;
|
|
2125
1766
|
}
|
|
2126
|
-
return
|
|
1767
|
+
return point[0] - defX + offsetX + "," + (point[1] - defY + offsetY);
|
|
2127
1768
|
}).join(' '));
|
|
2128
1769
|
}
|
|
2129
1770
|
}
|
|
@@ -2140,21 +1781,20 @@
|
|
|
2140
1781
|
});
|
|
2141
1782
|
var d = '';
|
|
2142
1783
|
if (!hasRadius) {
|
|
2143
|
-
d = "M 0,0 l "
|
|
1784
|
+
d = "M 0,0 l " + width + ",0 l 0," + height + " l" + -width + " 0 z";
|
|
2144
1785
|
} else {
|
|
2145
1786
|
var _radius$map = radius.map(function (r) {
|
|
2146
1787
|
return clamp(r, 0, Math.min(Math.abs(width) / 2, Math.abs(height) / 2));
|
|
2147
1788
|
}),
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
blr = _radius$map2[3];
|
|
1789
|
+
tlr = _radius$map[0],
|
|
1790
|
+
trr = _radius$map[1],
|
|
1791
|
+
brr = _radius$map[2],
|
|
1792
|
+
blr = _radius$map[3];
|
|
2153
1793
|
var signX = width > 0 ? 1 : -1;
|
|
2154
1794
|
var signY = height > 0 ? 1 : -1;
|
|
2155
1795
|
// sweep-flag @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Tutorial/Paths#arcs
|
|
2156
1796
|
var sweepFlag = signX + signY !== 0 ? 1 : 0;
|
|
2157
|
-
d = [["M "
|
|
1797
|
+
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(' ');
|
|
2158
1798
|
}
|
|
2159
1799
|
$el.setAttribute('d', d);
|
|
2160
1800
|
}
|
|
@@ -2266,7 +1906,6 @@
|
|
|
2266
1906
|
var TEXT_PATH_PREFIX = 'text-path-';
|
|
2267
1907
|
var SVGRendererPlugin = /*#__PURE__*/function () {
|
|
2268
1908
|
function SVGRendererPlugin(pluginOptions, defElementManager, context) {
|
|
2269
|
-
_classCallCheck$2(this, SVGRendererPlugin);
|
|
2270
1909
|
this.pluginOptions = void 0;
|
|
2271
1910
|
this.defElementManager = void 0;
|
|
2272
1911
|
this.context = void 0;
|
|
@@ -2282,526 +1921,517 @@
|
|
|
2282
1921
|
/**
|
|
2283
1922
|
* <camera>
|
|
2284
1923
|
*/
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
var
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
_this.clipPathUseMap.delete(object);
|
|
2303
|
-
_this.removeSVGDom(object);
|
|
2304
|
-
};
|
|
2305
|
-
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
2306
|
-
var object = e.target;
|
|
2307
|
-
// @see https://github.com/antvis/g/issues/994
|
|
2308
|
-
// @ts-ignore
|
|
2309
|
-
if (!object.elementSVG) {
|
|
2310
|
-
return;
|
|
1924
|
+
var _proto = SVGRendererPlugin.prototype;
|
|
1925
|
+
_proto.apply = function apply(context) {
|
|
1926
|
+
var _this = this;
|
|
1927
|
+
var renderingService = context.renderingService,
|
|
1928
|
+
renderingContext = context.renderingContext;
|
|
1929
|
+
this.context = context;
|
|
1930
|
+
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
1931
|
+
var document = this.context.config.document;
|
|
1932
|
+
var handleMounted = function handleMounted(e) {
|
|
1933
|
+
var object = e.target;
|
|
1934
|
+
// should remove clipPath already existed in <defs>
|
|
1935
|
+
var $useRefs = _this.clipPathUseMap.get(object);
|
|
1936
|
+
if ($useRefs) {
|
|
1937
|
+
var $def = _this.defElementManager.getDefElement();
|
|
1938
|
+
var existed = $def.querySelector("#" + _this.getId(object));
|
|
1939
|
+
if (existed) {
|
|
1940
|
+
existed.remove();
|
|
2311
1941
|
}
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
1942
|
+
}
|
|
1943
|
+
// create SVG DOM Node
|
|
1944
|
+
_this.createSVGDom(document, object, _this.$camera);
|
|
1945
|
+
};
|
|
1946
|
+
var handleUnmounted = function handleUnmounted(e) {
|
|
1947
|
+
var object = e.target;
|
|
1948
|
+
_this.defElementManager.clear(object.entity);
|
|
1949
|
+
_this.clipPathUseMap.delete(object);
|
|
1950
|
+
_this.removeSVGDom(object);
|
|
1951
|
+
};
|
|
1952
|
+
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
1953
|
+
var object = e.target;
|
|
1954
|
+
// @see https://github.com/antvis/g/issues/994
|
|
1955
|
+
// @ts-ignore
|
|
1956
|
+
if (!object.elementSVG) {
|
|
1957
|
+
return;
|
|
1958
|
+
}
|
|
1959
|
+
var attrName = e.attrName;
|
|
1960
|
+
var attribtues = _this.dirtyAttributes.get(object);
|
|
1961
|
+
if (!attribtues) {
|
|
1962
|
+
_this.dirtyAttributes.set(object, []);
|
|
1963
|
+
attribtues = _this.dirtyAttributes.get(object);
|
|
1964
|
+
}
|
|
1965
|
+
attribtues.push(attrName);
|
|
1966
|
+
};
|
|
1967
|
+
var handleGeometryBoundsChanged = function handleGeometryBoundsChanged(e) {
|
|
1968
|
+
var _object$elementSVG;
|
|
1969
|
+
var object = e.target;
|
|
1970
|
+
// @ts-ignore
|
|
1971
|
+
var $el = (_object$elementSVG = object.elementSVG) === null || _object$elementSVG === void 0 ? void 0 : _object$elementSVG.$el;
|
|
1972
|
+
var _object$parsedStyle = object.parsedStyle,
|
|
1973
|
+
fill = _object$parsedStyle.fill,
|
|
1974
|
+
stroke = _object$parsedStyle.stroke;
|
|
1975
|
+
if (fill && !(fill instanceof gLite.CSSRGB)) {
|
|
1976
|
+
_this.defElementManager.createOrUpdateGradientAndPattern(object, $el, fill, 'fill', _this);
|
|
1977
|
+
}
|
|
1978
|
+
if (stroke && !(stroke instanceof gLite.CSSRGB)) {
|
|
1979
|
+
_this.defElementManager.createOrUpdateGradientAndPattern(object, $el, stroke, 'stroke', _this);
|
|
1980
|
+
}
|
|
1981
|
+
};
|
|
1982
|
+
renderingService.hooks.init.tapPromise(SVGRendererPlugin.tag, /*#__PURE__*/_asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee() {
|
|
1983
|
+
var _this$context$config, background, document, $svg;
|
|
1984
|
+
return _regeneratorRuntime$2().wrap(function _callee$(_context) {
|
|
1985
|
+
while (1) {
|
|
1986
|
+
switch (_context.prev = _context.next) {
|
|
1987
|
+
case 0:
|
|
1988
|
+
_this$context$config = _this.context.config, background = _this$context$config.background, document = _this$context$config.document; // <defs>
|
|
1989
|
+
_this.defElementManager.init();
|
|
1990
|
+
$svg = _this.context.contextService.getContext();
|
|
1991
|
+
if (background) {
|
|
1992
|
+
$svg.style.background = background;
|
|
1993
|
+
}
|
|
1994
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
|
|
1995
|
+
$svg.setAttribute('color-interpolation-filters', 'sRGB');
|
|
1996
|
+
_this.$camera = createSVGElement('g', document);
|
|
1997
|
+
_this.$camera.id = G_SVG_PREFIX + "-camera";
|
|
1998
|
+
_this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
|
|
1999
|
+
$svg.appendChild(_this.$camera);
|
|
2000
|
+
canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
2001
|
+
canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
2002
|
+
canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
2003
|
+
canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
|
|
2004
|
+
case 13:
|
|
2005
|
+
case "end":
|
|
2006
|
+
return _context.stop();
|
|
2007
|
+
}
|
|
2317
2008
|
}
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2009
|
+
}, _callee);
|
|
2010
|
+
})));
|
|
2011
|
+
renderingService.hooks.destroy.tap(SVGRendererPlugin.tag, function () {
|
|
2012
|
+
canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
2013
|
+
canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
2014
|
+
canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
2015
|
+
canvas.removeEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
|
|
2016
|
+
});
|
|
2017
|
+
renderingService.hooks.render.tap(SVGRendererPlugin.tag, function (object) {
|
|
2018
|
+
// if (!object.isCulled()) {
|
|
2019
|
+
_this.renderQueue.push(object);
|
|
2020
|
+
// }
|
|
2021
|
+
});
|
|
2022
|
+
|
|
2023
|
+
renderingService.hooks.beginFrame.tap(SVGRendererPlugin.tag, function () {
|
|
2024
|
+
var doc = _this.context.config.document;
|
|
2025
|
+
if (_this.pendingReorderQueue.size) {
|
|
2026
|
+
_this.pendingReorderQueue.forEach(function (object) {
|
|
2027
|
+
var _object$elementSVG2;
|
|
2028
|
+
var children = ((object === null || object === void 0 ? void 0 : object.children) || []).slice();
|
|
2029
|
+
var $parentGroupEl =
|
|
2030
|
+
// @ts-ignore
|
|
2031
|
+
object === null || object === void 0 ? void 0 : (_object$elementSVG2 = object.elementSVG) === null || _object$elementSVG2 === void 0 ? void 0 : _object$elementSVG2.$groupEl;
|
|
2032
|
+
if ($parentGroupEl) {
|
|
2033
|
+
_this.reorderChildren(doc || document, $parentGroupEl, children || []);
|
|
2034
|
+
}
|
|
2035
|
+
});
|
|
2036
|
+
_this.pendingReorderQueue.clear();
|
|
2037
|
+
}
|
|
2038
|
+
});
|
|
2039
|
+
renderingService.hooks.endFrame.tap(SVGRendererPlugin.tag, function () {
|
|
2040
|
+
if (renderingContext.renderReasons.has(gLite.RenderReason.CAMERA_CHANGED)) {
|
|
2041
|
+
_this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
|
|
2042
|
+
}
|
|
2043
|
+
_this.renderQueue.forEach(function (object) {
|
|
2044
|
+
var _object$elementSVG3, _object$elementSVG4;
|
|
2323
2045
|
// @ts-ignore
|
|
2324
|
-
var $el = (_object$
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
if (background) {
|
|
2345
|
-
$svg.style.background = background;
|
|
2346
|
-
}
|
|
2347
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
|
|
2348
|
-
$svg.setAttribute('color-interpolation-filters', 'sRGB');
|
|
2349
|
-
_this.$camera = createSVGElement('g', document);
|
|
2350
|
-
_this.$camera.id = "".concat(G_SVG_PREFIX, "-camera");
|
|
2351
|
-
_this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
|
|
2352
|
-
$svg.appendChild(_this.$camera);
|
|
2353
|
-
canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
2354
|
-
canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
2355
|
-
canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
2356
|
-
canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
|
|
2357
|
-
case 13:
|
|
2358
|
-
case "end":
|
|
2359
|
-
return _context.stop();
|
|
2360
|
-
}
|
|
2046
|
+
var $el = (_object$elementSVG3 = object.elementSVG) === null || _object$elementSVG3 === void 0 ? void 0 : _object$elementSVG3.$el;
|
|
2047
|
+
// @ts-ignore
|
|
2048
|
+
var $groupEl = (_object$elementSVG4 = object.elementSVG) === null || _object$elementSVG4 === void 0 ? void 0 : _object$elementSVG4.$groupEl;
|
|
2049
|
+
if ($el && $groupEl) {
|
|
2050
|
+
// apply local RTS transformation to <group> wrapper
|
|
2051
|
+
// account for anchor
|
|
2052
|
+
var localTransform = object.getLocalTransform();
|
|
2053
|
+
_this.applyTransform($groupEl, localTransform);
|
|
2054
|
+
// clipped shapes should also be informed
|
|
2055
|
+
var $useRefs = _this.clipPathUseMap.get(object);
|
|
2056
|
+
if ($useRefs && $useRefs.length) {
|
|
2057
|
+
$useRefs.forEach(function ($use) {
|
|
2058
|
+
// <clipPath transform="matrix()"><circle /></clipPath>
|
|
2059
|
+
_this.applyTransform($use, object.getWorldTransform());
|
|
2060
|
+
// const parentInvert = mat4.invert(
|
|
2061
|
+
// mat4.create(),
|
|
2062
|
+
// (object as DisplayObject).getWorldTransform(),
|
|
2063
|
+
// );
|
|
2064
|
+
// this.applyTransform($clipPath, parentInvert);
|
|
2065
|
+
});
|
|
2361
2066
|
}
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
var _object$elementSVG2;
|
|
2381
|
-
var children = ((object === null || object === void 0 ? void 0 : object.children) || []).slice();
|
|
2382
|
-
var $parentGroupEl =
|
|
2383
|
-
// @ts-ignore
|
|
2384
|
-
object === null || object === void 0 ? void 0 : (_object$elementSVG2 = object.elementSVG) === null || _object$elementSVG2 === void 0 ? void 0 : _object$elementSVG2.$groupEl;
|
|
2385
|
-
if ($parentGroupEl) {
|
|
2386
|
-
_this.reorderChildren(doc || document, $parentGroupEl, children || []);
|
|
2067
|
+
// finish rendering, clear dirty flag
|
|
2068
|
+
object.renderable.dirty = false;
|
|
2069
|
+
}
|
|
2070
|
+
// update dirty attributes
|
|
2071
|
+
var attributes = _this.dirtyAttributes.get(object);
|
|
2072
|
+
if (attributes) {
|
|
2073
|
+
attributes.forEach(function (attrName) {
|
|
2074
|
+
if (attrName === 'zIndex') {
|
|
2075
|
+
var _object$parentNode, _object$parentNode$el;
|
|
2076
|
+
var parent = object.parentNode;
|
|
2077
|
+
// @ts-ignore
|
|
2078
|
+
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;
|
|
2079
|
+
var children = ((parent === null || parent === void 0 ? void 0 : parent.children) || []).slice();
|
|
2080
|
+
if (_$groupEl) {
|
|
2081
|
+
_this.reorderChildren(document, _$groupEl, children);
|
|
2082
|
+
}
|
|
2083
|
+
} else if (attrName === 'increasedLineWidthForHitTesting') {
|
|
2084
|
+
_this.createOrUpdateHitArea(object, $el, $groupEl);
|
|
2387
2085
|
}
|
|
2086
|
+
_this.updateAttribute(object, [attrName]);
|
|
2388
2087
|
});
|
|
2389
|
-
_this.
|
|
2088
|
+
_this.dirtyAttributes.delete(object);
|
|
2390
2089
|
}
|
|
2391
2090
|
});
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2091
|
+
_this.renderQueue = [];
|
|
2092
|
+
});
|
|
2093
|
+
};
|
|
2094
|
+
_proto.getId = function getId(object) {
|
|
2095
|
+
return G_SVG_PREFIX + "-" + object.entity;
|
|
2096
|
+
};
|
|
2097
|
+
_proto.reorderChildren = function reorderChildren(doc, $groupEl, children) {
|
|
2098
|
+
// need to reorder parent's children
|
|
2099
|
+
children.sort(function (a, b) {
|
|
2100
|
+
return a.sortable.renderOrder - b.sortable.renderOrder;
|
|
2101
|
+
});
|
|
2102
|
+
if (children.length) {
|
|
2103
|
+
// create empty fragment
|
|
2104
|
+
var fragment = (doc || document).createDocumentFragment();
|
|
2105
|
+
children.forEach(function (child) {
|
|
2106
|
+
if (child.isConnected) {
|
|
2400
2107
|
// @ts-ignore
|
|
2401
|
-
var $
|
|
2402
|
-
if ($el
|
|
2403
|
-
|
|
2404
|
-
// account for anchor
|
|
2405
|
-
var localTransform = object.getLocalTransform();
|
|
2406
|
-
_this.applyTransform($groupEl, localTransform);
|
|
2407
|
-
// clipped shapes should also be informed
|
|
2408
|
-
var $useRefs = _this.clipPathUseMap.get(object);
|
|
2409
|
-
if ($useRefs && $useRefs.length) {
|
|
2410
|
-
$useRefs.forEach(function ($use) {
|
|
2411
|
-
// <clipPath transform="matrix()"><circle /></clipPath>
|
|
2412
|
-
_this.applyTransform($use, object.getWorldTransform());
|
|
2413
|
-
// const parentInvert = mat4.invert(
|
|
2414
|
-
// mat4.create(),
|
|
2415
|
-
// (object as DisplayObject).getWorldTransform(),
|
|
2416
|
-
// );
|
|
2417
|
-
// this.applyTransform($clipPath, parentInvert);
|
|
2418
|
-
});
|
|
2419
|
-
}
|
|
2420
|
-
// finish rendering, clear dirty flag
|
|
2421
|
-
object.renderable.dirty = false;
|
|
2422
|
-
}
|
|
2423
|
-
// update dirty attributes
|
|
2424
|
-
var attributes = _this.dirtyAttributes.get(object);
|
|
2425
|
-
if (attributes) {
|
|
2426
|
-
attributes.forEach(function (attrName) {
|
|
2427
|
-
if (attrName === 'zIndex') {
|
|
2428
|
-
var _object$parentNode, _object$parentNode$el;
|
|
2429
|
-
var parent = object.parentNode;
|
|
2430
|
-
// @ts-ignore
|
|
2431
|
-
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;
|
|
2432
|
-
var children = ((parent === null || parent === void 0 ? void 0 : parent.children) || []).slice();
|
|
2433
|
-
if (_$groupEl) {
|
|
2434
|
-
_this.reorderChildren(document, _$groupEl, children);
|
|
2435
|
-
}
|
|
2436
|
-
} else if (attrName === 'increasedLineWidthForHitTesting') {
|
|
2437
|
-
_this.createOrUpdateHitArea(object, $el, $groupEl);
|
|
2438
|
-
}
|
|
2439
|
-
_this.updateAttribute(object, [attrName]);
|
|
2440
|
-
});
|
|
2441
|
-
_this.dirtyAttributes.delete(object);
|
|
2108
|
+
var $el = child.elementSVG.$groupEl;
|
|
2109
|
+
if ($el) {
|
|
2110
|
+
fragment.appendChild($el);
|
|
2442
2111
|
}
|
|
2443
|
-
}
|
|
2444
|
-
_this.renderQueue = [];
|
|
2112
|
+
}
|
|
2445
2113
|
});
|
|
2114
|
+
$groupEl.appendChild(fragment);
|
|
2446
2115
|
}
|
|
2447
|
-
}
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2116
|
+
};
|
|
2117
|
+
_proto.applyTransform = function applyTransform($el, rts) {
|
|
2118
|
+
// use proper precision avoiding too long string in `transform`
|
|
2119
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
2120
|
+
$el.setAttribute('transform', "matrix(" + numberToLongString(rts[0]) + "," + numberToLongString(rts[1]) + "," + numberToLongString(rts[4]) + "," + numberToLongString(rts[5]) + "," + numberToLongString(rts[12]) + "," + numberToLongString(rts[13]) + ")");
|
|
2121
|
+
};
|
|
2122
|
+
_proto.applyAttributes = function applyAttributes(object) {
|
|
2123
|
+
// @ts-ignore
|
|
2124
|
+
var elementSVG = object.elementSVG;
|
|
2125
|
+
var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
|
|
2126
|
+
var $groupEl = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$groupEl;
|
|
2127
|
+
if ($el && $groupEl) {
|
|
2128
|
+
var nodeName = object.nodeName,
|
|
2129
|
+
attributes = object.attributes;
|
|
2130
|
+
$el.setAttribute('fill', 'none');
|
|
2131
|
+
if (nodeName === gLite.Shape.IMAGE) {
|
|
2132
|
+
$el.setAttribute('preserveAspectRatio', 'none');
|
|
2133
|
+
}
|
|
2134
|
+
// apply attributes
|
|
2135
|
+
this.updateAttribute(object, Object.keys(attributes));
|
|
2451
2136
|
}
|
|
2452
|
-
}
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
}
|
|
2474
|
-
}, {
|
|
2475
|
-
key: "applyTransform",
|
|
2476
|
-
value: function applyTransform($el, rts) {
|
|
2477
|
-
// use proper precision avoiding too long string in `transform`
|
|
2478
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
2479
|
-
$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]), ")"));
|
|
2480
|
-
}
|
|
2481
|
-
}, {
|
|
2482
|
-
key: "applyAttributes",
|
|
2483
|
-
value: function applyAttributes(object) {
|
|
2484
|
-
// @ts-ignore
|
|
2485
|
-
var elementSVG = object.elementSVG;
|
|
2486
|
-
var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
|
|
2487
|
-
var $groupEl = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$groupEl;
|
|
2488
|
-
if ($el && $groupEl) {
|
|
2489
|
-
var nodeName = object.nodeName,
|
|
2490
|
-
attributes = object.attributes;
|
|
2491
|
-
$el.setAttribute('fill', 'none');
|
|
2492
|
-
if (nodeName === gLite.Shape.IMAGE) {
|
|
2493
|
-
$el.setAttribute('preserveAspectRatio', 'none');
|
|
2494
|
-
}
|
|
2495
|
-
// apply attributes
|
|
2496
|
-
this.updateAttribute(object, Object.keys(attributes));
|
|
2497
|
-
}
|
|
2498
|
-
}
|
|
2499
|
-
}, {
|
|
2500
|
-
key: "updateAttribute",
|
|
2501
|
-
value: function updateAttribute(object, attributes) {
|
|
2502
|
-
var _this2 = this;
|
|
2503
|
-
var document = this.context.config.document;
|
|
2504
|
-
// @ts-ignore
|
|
2505
|
-
var _object$elementSVG5 = object.elementSVG,
|
|
2506
|
-
$el = _object$elementSVG5.$el,
|
|
2507
|
-
$groupEl = _object$elementSVG5.$groupEl,
|
|
2508
|
-
$hitTestingEl = _object$elementSVG5.$hitTestingEl;
|
|
2509
|
-
var parsedStyle = object.parsedStyle,
|
|
2510
|
-
computedStyle = object.computedStyle;
|
|
2511
|
-
var shouldUpdateElementAttribute = attributes.some(function (name) {
|
|
2512
|
-
return (
|
|
2137
|
+
};
|
|
2138
|
+
_proto.updateAttribute = function updateAttribute(object, attributes) {
|
|
2139
|
+
var _this2 = this;
|
|
2140
|
+
var document = this.context.config.document;
|
|
2141
|
+
// @ts-ignore
|
|
2142
|
+
var _object$elementSVG5 = object.elementSVG,
|
|
2143
|
+
$el = _object$elementSVG5.$el,
|
|
2144
|
+
$groupEl = _object$elementSVG5.$groupEl,
|
|
2145
|
+
$hitTestingEl = _object$elementSVG5.$hitTestingEl;
|
|
2146
|
+
var parsedStyle = object.parsedStyle,
|
|
2147
|
+
computedStyle = object.computedStyle;
|
|
2148
|
+
var shouldUpdateElementAttribute = attributes.some(function (name) {
|
|
2149
|
+
return (
|
|
2150
|
+
// @ts-ignore
|
|
2151
|
+
_this2.context.SVGElementLifeCycleContribution.shouldUpdateElementAttribute(object, name)
|
|
2152
|
+
);
|
|
2153
|
+
});
|
|
2154
|
+
// need re-generate path
|
|
2155
|
+
if (shouldUpdateElementAttribute && $el) {
|
|
2156
|
+
[$el, $hitTestingEl].forEach(function ($el) {
|
|
2157
|
+
if ($el) {
|
|
2513
2158
|
// @ts-ignore
|
|
2514
|
-
_this2.context.SVGElementLifeCycleContribution.
|
|
2515
|
-
);
|
|
2516
|
-
});
|
|
2517
|
-
// need re-generate path
|
|
2518
|
-
if (shouldUpdateElementAttribute && $el) {
|
|
2519
|
-
[$el, $hitTestingEl].forEach(function ($el) {
|
|
2520
|
-
if ($el) {
|
|
2521
|
-
// @ts-ignore
|
|
2522
|
-
_this2.context.SVGElementLifeCycleContribution.updateElementAttribute(object, $el);
|
|
2523
|
-
if (object.nodeName !== gLite.Shape.TEXT) {
|
|
2524
|
-
_this2.updateAnchorWithTransform(object);
|
|
2525
|
-
}
|
|
2526
|
-
}
|
|
2527
|
-
});
|
|
2528
|
-
}
|
|
2529
|
-
// update common attributes
|
|
2530
|
-
attributes.forEach(function (name) {
|
|
2531
|
-
var _FORMAT_VALUE_MAP$nam, _propertyMetadataCach;
|
|
2532
|
-
var usedName = SVG_ATTR_MAP[name];
|
|
2533
|
-
var computedValue = computedStyle[name];
|
|
2534
|
-
var computedValueStr = computedValue && computedValue.toString();
|
|
2535
|
-
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;
|
|
2536
|
-
var usedValue = parsedStyle[name];
|
|
2537
|
-
var inherited = !!((_propertyMetadataCach = gLite.propertyMetadataCache[name]) === null || _propertyMetadataCach === void 0 ? void 0 : _propertyMetadataCach.inh);
|
|
2538
|
-
if (!usedName) {
|
|
2539
|
-
return;
|
|
2540
|
-
}
|
|
2541
|
-
// <foreignObject>
|
|
2542
|
-
if (object.nodeName === gLite.Shape.HTML) {
|
|
2543
|
-
if (name === 'lineWidth') {
|
|
2544
|
-
$el.style['border-width'] = "".concat(usedValue || 0, "px");
|
|
2545
|
-
} else if (name === 'lineDash') {
|
|
2546
|
-
$el.style['border-style'] = 'dashed';
|
|
2547
|
-
}
|
|
2548
|
-
}
|
|
2549
|
-
if (name === 'fill') {
|
|
2550
|
-
if (object.nodeName === gLite.Shape.HTML) {
|
|
2551
|
-
$el.style.background = usedValue.toString();
|
|
2552
|
-
} else {
|
|
2553
|
-
_this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName, _this2);
|
|
2554
|
-
}
|
|
2555
|
-
} else if (name === 'stroke') {
|
|
2556
|
-
if (object.nodeName === gLite.Shape.HTML) {
|
|
2557
|
-
$el.style['border-color'] = usedValue.toString();
|
|
2558
|
-
$el.style['border-style'] = 'solid';
|
|
2559
|
-
} else {
|
|
2560
|
-
_this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName, _this2);
|
|
2561
|
-
}
|
|
2562
|
-
} else if (inherited && usedName) {
|
|
2563
|
-
// use computed value
|
|
2564
|
-
// update `visibility` on <group>
|
|
2565
|
-
if (computedValueStr !== 'unset' && computedValueStr !== DEFAULT_VALUE_MAP[name]) {
|
|
2566
|
-
$groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, formattedValueStr);
|
|
2567
|
-
} else {
|
|
2568
|
-
$groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.removeAttribute(usedName);
|
|
2569
|
-
}
|
|
2570
|
-
} else if (name === 'clipPath') {
|
|
2571
|
-
_this2.createOrUpdateClipOrTextPath(document, usedValue, object);
|
|
2572
|
-
} else if (name === 'textPath') {
|
|
2573
|
-
_this2.createOrUpdateClipOrTextPath(document, usedValue, object, true);
|
|
2574
|
-
} else if (name === 'shadowType' || name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
|
|
2575
|
-
_this2.defElementManager.createOrUpdateShadow(object, $el, name);
|
|
2576
|
-
} else if (name === 'filter') {
|
|
2577
|
-
_this2.defElementManager.createOrUpdateFilter(object, $el, usedValue);
|
|
2578
|
-
} else if (name === 'innerHTML') {
|
|
2579
|
-
_this2.createOrUpdateInnerHTML(document, $el, usedValue);
|
|
2580
|
-
} else if (name === 'anchor') {
|
|
2581
|
-
// text' anchor is controlled by `textAnchor` property
|
|
2159
|
+
_this2.context.SVGElementLifeCycleContribution.updateElementAttribute(object, $el);
|
|
2582
2160
|
if (object.nodeName !== gLite.Shape.TEXT) {
|
|
2583
2161
|
_this2.updateAnchorWithTransform(object);
|
|
2584
2162
|
}
|
|
2585
|
-
} else {
|
|
2586
|
-
if (computedValue) {
|
|
2587
|
-
// use computed value so that we can use cascaded effect in SVG
|
|
2588
|
-
// ignore 'unset' and default value
|
|
2589
|
-
[$el, $hitTestingEl].forEach(function ($el) {
|
|
2590
|
-
if ($el && usedName) {
|
|
2591
|
-
if (computedValueStr !== 'unset' && computedValueStr !== DEFAULT_VALUE_MAP[name]) {
|
|
2592
|
-
$el.setAttribute(usedName, formattedValueStr);
|
|
2593
|
-
} else {
|
|
2594
|
-
$el.removeAttribute(usedName);
|
|
2595
|
-
}
|
|
2596
|
-
}
|
|
2597
|
-
});
|
|
2598
|
-
}
|
|
2599
2163
|
}
|
|
2600
2164
|
});
|
|
2601
2165
|
}
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
var
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
var
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
if (
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
object.parsedStyle.$el = $el;
|
|
2166
|
+
// update common attributes
|
|
2167
|
+
attributes.forEach(function (name) {
|
|
2168
|
+
var _FORMAT_VALUE_MAP$nam, _propertyMetadataCach;
|
|
2169
|
+
var usedName = SVG_ATTR_MAP[name];
|
|
2170
|
+
var computedValue = computedStyle[name];
|
|
2171
|
+
var computedValueStr = computedValue && computedValue.toString();
|
|
2172
|
+
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;
|
|
2173
|
+
var usedValue = parsedStyle[name];
|
|
2174
|
+
var inherited = !!((_propertyMetadataCach = gLite.propertyMetadataCache[name]) === null || _propertyMetadataCach === void 0 ? void 0 : _propertyMetadataCach.inh);
|
|
2175
|
+
if (!usedName) {
|
|
2176
|
+
return;
|
|
2177
|
+
}
|
|
2178
|
+
// <foreignObject>
|
|
2179
|
+
if (object.nodeName === gLite.Shape.HTML) {
|
|
2180
|
+
if (name === 'lineWidth') {
|
|
2181
|
+
$el.style['border-width'] = (usedValue || 0) + "px";
|
|
2182
|
+
} else if (name === 'lineDash') {
|
|
2183
|
+
$el.style['border-style'] = 'dashed';
|
|
2621
2184
|
}
|
|
2622
|
-
|
|
2623
|
-
|
|
2185
|
+
}
|
|
2186
|
+
if (name === 'fill') {
|
|
2187
|
+
if (object.nodeName === gLite.Shape.HTML) {
|
|
2188
|
+
$el.style.background = usedValue.toString();
|
|
2189
|
+
} else {
|
|
2190
|
+
_this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName, _this2);
|
|
2624
2191
|
}
|
|
2625
|
-
|
|
2626
|
-
|
|
2192
|
+
} else if (name === 'stroke') {
|
|
2193
|
+
if (object.nodeName === gLite.Shape.HTML) {
|
|
2194
|
+
$el.style['border-color'] = usedValue.toString();
|
|
2195
|
+
$el.style['border-style'] = 'solid';
|
|
2196
|
+
} else {
|
|
2197
|
+
_this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName, _this2);
|
|
2627
2198
|
}
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2199
|
+
} else if (inherited && usedName) {
|
|
2200
|
+
// use computed value
|
|
2201
|
+
// update `visibility` on <group>
|
|
2202
|
+
if (computedValueStr !== 'unset' && computedValueStr !== DEFAULT_VALUE_MAP[name]) {
|
|
2203
|
+
$groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, formattedValueStr);
|
|
2631
2204
|
} else {
|
|
2632
|
-
$groupEl
|
|
2205
|
+
$groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.removeAttribute(usedName);
|
|
2633
2206
|
}
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2207
|
+
} else if (name === 'clipPath') {
|
|
2208
|
+
_this2.createOrUpdateClipOrTextPath(document, usedValue, object);
|
|
2209
|
+
} else if (name === 'textPath') {
|
|
2210
|
+
_this2.createOrUpdateClipOrTextPath(document, usedValue, object, true);
|
|
2211
|
+
} else if (name === 'shadowType' || name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
|
|
2212
|
+
_this2.defElementManager.createOrUpdateShadow(object, $el, name);
|
|
2213
|
+
} else if (name === 'filter') {
|
|
2214
|
+
_this2.defElementManager.createOrUpdateFilter(object, $el, usedValue);
|
|
2215
|
+
} else if (name === 'innerHTML') {
|
|
2216
|
+
_this2.createOrUpdateInnerHTML(document, $el, usedValue);
|
|
2217
|
+
} else if (name === 'anchor') {
|
|
2218
|
+
// text' anchor is controlled by `textAnchor` property
|
|
2219
|
+
if (object.nodeName !== gLite.Shape.TEXT) {
|
|
2220
|
+
_this2.updateAnchorWithTransform(object);
|
|
2221
|
+
}
|
|
2222
|
+
} else {
|
|
2223
|
+
if (computedValue) {
|
|
2224
|
+
// use computed value so that we can use cascaded effect in SVG
|
|
2225
|
+
// ignore 'unset' and default value
|
|
2226
|
+
[$el, $hitTestingEl].forEach(function ($el) {
|
|
2227
|
+
if ($el && usedName) {
|
|
2228
|
+
if (computedValueStr !== 'unset' && computedValueStr !== DEFAULT_VALUE_MAP[name]) {
|
|
2229
|
+
$el.setAttribute(usedName, formattedValueStr);
|
|
2230
|
+
} else {
|
|
2231
|
+
$el.removeAttribute(usedName);
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
});
|
|
2647
2235
|
}
|
|
2648
2236
|
}
|
|
2237
|
+
});
|
|
2238
|
+
};
|
|
2239
|
+
_proto.createSVGDom = function createSVGDom(document, object, root, noWrapWithGroup) {
|
|
2240
|
+
if (noWrapWithGroup === void 0) {
|
|
2241
|
+
noWrapWithGroup = false;
|
|
2649
2242
|
}
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2243
|
+
// create svg element
|
|
2244
|
+
// @ts-ignore
|
|
2245
|
+
object.elementSVG = new ElementSVG();
|
|
2246
|
+
// @ts-ignore
|
|
2247
|
+
var svgElement = object.elementSVG;
|
|
2248
|
+
// use <group> as default, eg. CustomElement
|
|
2249
|
+
var $el =
|
|
2250
|
+
// @ts-ignore
|
|
2251
|
+
this.context.SVGElementLifeCycleContribution.createElement(object);
|
|
2252
|
+
if ($el) {
|
|
2253
|
+
var _object$parentNode$el2;
|
|
2254
|
+
var $groupEl;
|
|
2255
|
+
// save $el on parsedStyle, which will be returned in getDomElement()
|
|
2256
|
+
if (object.nodeName === gLite.Shape.HTML) {
|
|
2257
|
+
object.parsedStyle.$el = $el;
|
|
2258
|
+
}
|
|
2259
|
+
if (this.pluginOptions.outputSVGElementId) {
|
|
2260
|
+
$el.id = this.getId(object);
|
|
2261
|
+
}
|
|
2262
|
+
if (this.pluginOptions.outputSVGElementName && object.name) {
|
|
2263
|
+
$el.setAttribute('name', object.name);
|
|
2264
|
+
}
|
|
2265
|
+
if (($el.hasAttribute('data-wrapgroup') || $el.nodeName !== 'g') && !noWrapWithGroup) {
|
|
2266
|
+
$groupEl = createSVGElement('g', document);
|
|
2267
|
+
$groupEl.id = $el.id + '-g';
|
|
2268
|
+
$groupEl.appendChild($el);
|
|
2269
|
+
} else {
|
|
2270
|
+
$groupEl = $el;
|
|
2271
|
+
}
|
|
2272
|
+
svgElement.$el = $el;
|
|
2273
|
+
svgElement.$groupEl = $groupEl;
|
|
2274
|
+
// apply attributes at first time
|
|
2275
|
+
this.applyAttributes(object);
|
|
2276
|
+
// create hitArea if necessary
|
|
2277
|
+
this.createOrUpdateHitArea(object, $el, $groupEl);
|
|
2278
|
+
var $parentGroupEl = root ||
|
|
2654
2279
|
// @ts-ignore
|
|
2655
|
-
|
|
2656
|
-
if ($
|
|
2657
|
-
$
|
|
2658
|
-
//
|
|
2659
|
-
this.
|
|
2660
|
-
// object.entity.removeComponent(ElementSVG, true);
|
|
2280
|
+
object.parentNode && ((_object$parentNode$el2 = object.parentNode.elementSVG) === null || _object$parentNode$el2 === void 0 ? void 0 : _object$parentNode$el2.$groupEl);
|
|
2281
|
+
if ($parentGroupEl) {
|
|
2282
|
+
$parentGroupEl.appendChild($groupEl);
|
|
2283
|
+
// need reorder children later
|
|
2284
|
+
this.pendingReorderQueue.add(object.parentNode);
|
|
2661
2285
|
}
|
|
2662
2286
|
}
|
|
2663
|
-
}
|
|
2664
|
-
|
|
2665
|
-
|
|
2287
|
+
};
|
|
2288
|
+
_proto.removeSVGDom = function removeSVGDom(object) {
|
|
2289
|
+
var _object$elementSVG6;
|
|
2290
|
+
// @ts-ignore
|
|
2291
|
+
var $groupEl = (_object$elementSVG6 = object.elementSVG) === null || _object$elementSVG6 === void 0 ? void 0 : _object$elementSVG6.$groupEl;
|
|
2292
|
+
if ($groupEl && $groupEl.parentNode) {
|
|
2293
|
+
$groupEl.parentNode.removeChild($groupEl);
|
|
2666
2294
|
// @ts-ignore
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
//
|
|
2683
|
-
|
|
2684
|
-
$hitTestingEl.setAttribute('fill', hasFill ? 'transparent' : 'none');
|
|
2685
|
-
$hitTestingEl.setAttribute('stroke', 'transparent');
|
|
2686
|
-
$groupEl.appendChild($hitTestingEl);
|
|
2687
|
-
svgElement.$hitTestingEl = $hitTestingEl;
|
|
2688
|
-
}
|
|
2689
|
-
// increase interactive line width
|
|
2690
|
-
$hitTestingEl.setAttribute('stroke-width', "".concat(increasedLineWidthForHitTesting + object.parsedStyle.lineWidth));
|
|
2691
|
-
} else {
|
|
2692
|
-
if ($hitTestingEl) {
|
|
2693
|
-
$groupEl.removeChild($hitTestingEl);
|
|
2694
|
-
svgElement.$hitTestingEl = null;
|
|
2295
|
+
this.context.SVGElementLifeCycleContribution.destroyElement(object, $groupEl);
|
|
2296
|
+
// object.entity.removeComponent(ElementSVG, true);
|
|
2297
|
+
}
|
|
2298
|
+
};
|
|
2299
|
+
|
|
2300
|
+
_proto.createOrUpdateHitArea = function createOrUpdateHitArea(object, $el, $groupEl) {
|
|
2301
|
+
// @ts-ignore
|
|
2302
|
+
var svgElement = object.elementSVG;
|
|
2303
|
+
var $hitTestingEl = svgElement.$hitTestingEl;
|
|
2304
|
+
var increasedLineWidthForHitTesting = object.parsedStyle.increasedLineWidthForHitTesting;
|
|
2305
|
+
// account for hitArea
|
|
2306
|
+
if (increasedLineWidthForHitTesting) {
|
|
2307
|
+
if (!$hitTestingEl) {
|
|
2308
|
+
$hitTestingEl = $el.cloneNode();
|
|
2309
|
+
if (this.pluginOptions.outputSVGElementId) {
|
|
2310
|
+
// use the entity suffix, so that `g-plugin-svg-picker` can extract
|
|
2311
|
+
$hitTestingEl.id = G_SVG_PREFIX + "-" + object.nodeName + "-hittesting-" + object.entity;
|
|
2695
2312
|
}
|
|
2313
|
+
// clear attributes like `filter` `font-size`
|
|
2314
|
+
['filter'].forEach(function (attribute) {
|
|
2315
|
+
$hitTestingEl.removeAttribute(attribute);
|
|
2316
|
+
});
|
|
2317
|
+
// hitArea should be 'transparent' but not 'none'
|
|
2318
|
+
var hasFill = $el.getAttribute('fill') !== 'none';
|
|
2319
|
+
$hitTestingEl.setAttribute('fill', hasFill ? 'transparent' : 'none');
|
|
2320
|
+
$hitTestingEl.setAttribute('stroke', 'transparent');
|
|
2321
|
+
$groupEl.appendChild($hitTestingEl);
|
|
2322
|
+
svgElement.$hitTestingEl = $hitTestingEl;
|
|
2696
2323
|
}
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
$div.innerHTML = usedValue;
|
|
2704
|
-
} else {
|
|
2705
|
-
$div.appendChild(usedValue);
|
|
2324
|
+
// increase interactive line width
|
|
2325
|
+
$hitTestingEl.setAttribute('stroke-width', "" + (increasedLineWidthForHitTesting + object.parsedStyle.lineWidth));
|
|
2326
|
+
} else {
|
|
2327
|
+
if ($hitTestingEl) {
|
|
2328
|
+
$groupEl.removeChild($hitTestingEl);
|
|
2329
|
+
svgElement.$hitTestingEl = null;
|
|
2706
2330
|
}
|
|
2707
|
-
$el.innerHTML = '';
|
|
2708
|
-
$el.appendChild($div);
|
|
2709
2331
|
}
|
|
2710
|
-
}
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
var $
|
|
2745
|
-
if (!$
|
|
2746
|
-
this.
|
|
2747
|
-
$useRefs = this.clipPathUseMap.get(clipPath);
|
|
2332
|
+
};
|
|
2333
|
+
_proto.createOrUpdateInnerHTML = function createOrUpdateInnerHTML(doc, $el, usedValue) {
|
|
2334
|
+
var $div = (doc || document).createElement('div');
|
|
2335
|
+
if (typeof usedValue === 'string') {
|
|
2336
|
+
$div.innerHTML = usedValue;
|
|
2337
|
+
} else {
|
|
2338
|
+
$div.appendChild(usedValue);
|
|
2339
|
+
}
|
|
2340
|
+
$el.innerHTML = '';
|
|
2341
|
+
$el.appendChild($div);
|
|
2342
|
+
};
|
|
2343
|
+
_proto.createOrUpdateClipOrTextPath = function createOrUpdateClipOrTextPath(document, clipPath, object, isTextPath) {
|
|
2344
|
+
if (isTextPath === void 0) {
|
|
2345
|
+
isTextPath = false;
|
|
2346
|
+
}
|
|
2347
|
+
// @ts-ignore
|
|
2348
|
+
var $groupEl = object.elementSVG.$groupEl;
|
|
2349
|
+
var PREFIX = isTextPath ? TEXT_PATH_PREFIX : CLIP_PATH_PREFIX;
|
|
2350
|
+
var attributeNameCamel = isTextPath ? 'g' : 'clipPath';
|
|
2351
|
+
var attributeNameHyphen = isTextPath ? 'text-path' : 'clip-path';
|
|
2352
|
+
if (clipPath) {
|
|
2353
|
+
var clipPathId = PREFIX + clipPath.entity + '-' + object.entity;
|
|
2354
|
+
var $def = this.defElementManager.getDefElement();
|
|
2355
|
+
var existed = $def.querySelector("#" + clipPathId);
|
|
2356
|
+
if (!existed) {
|
|
2357
|
+
var $clipPath;
|
|
2358
|
+
if (isTextPath) {
|
|
2359
|
+
// use <path> directly instead of wrapping with <g>
|
|
2360
|
+
this.createSVGDom(document, clipPath, null, true);
|
|
2361
|
+
// @ts-ignore
|
|
2362
|
+
$clipPath = clipPath.elementSVG.$el;
|
|
2363
|
+
} else {
|
|
2364
|
+
// the clipPath is allowed to be detached from canvas
|
|
2365
|
+
if (!clipPath.isConnected) {
|
|
2366
|
+
var $existedClipPath = $def.querySelector("#" + this.getId(clipPath));
|
|
2367
|
+
if (!$existedClipPath) {
|
|
2368
|
+
this.createSVGDom(document, clipPath, $def, true);
|
|
2748
2369
|
}
|
|
2749
|
-
$useRefs.push($use);
|
|
2750
|
-
// <clipPath transform="matrix()"><circle /></clipPath>
|
|
2751
|
-
this.applyTransform($use, clipPath.getWorldTransform());
|
|
2752
|
-
var parentInvert = invert(create(), object.getWorldTransform());
|
|
2753
|
-
this.applyTransform($clipPath, parentInvert);
|
|
2754
2370
|
}
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
$
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2371
|
+
// create <clipPath> dom node
|
|
2372
|
+
$clipPath = createSVGElement(attributeNameCamel, document);
|
|
2373
|
+
var $use = createSVGElement('use', document);
|
|
2374
|
+
// @ts-ignore
|
|
2375
|
+
$use.setAttribute('href', "#" + clipPath.elementSVG.$el.id);
|
|
2376
|
+
$clipPath.appendChild($use);
|
|
2377
|
+
var $useRefs = this.clipPathUseMap.get(clipPath);
|
|
2378
|
+
if (!$useRefs) {
|
|
2379
|
+
this.clipPathUseMap.set(clipPath, []);
|
|
2380
|
+
$useRefs = this.clipPathUseMap.get(clipPath);
|
|
2381
|
+
}
|
|
2382
|
+
$useRefs.push($use);
|
|
2383
|
+
// <clipPath transform="matrix()"><circle /></clipPath>
|
|
2384
|
+
this.applyTransform($use, clipPath.getWorldTransform());
|
|
2385
|
+
var parentInvert = invert(create(), object.getWorldTransform());
|
|
2386
|
+
this.applyTransform($clipPath, parentInvert);
|
|
2770
2387
|
}
|
|
2388
|
+
$clipPath.id = clipPathId;
|
|
2389
|
+
// append it to <defs>
|
|
2390
|
+
$def.appendChild($clipPath);
|
|
2391
|
+
}
|
|
2392
|
+
// apply attributes
|
|
2393
|
+
this.applyAttributes(clipPath);
|
|
2394
|
+
if (!isTextPath) {
|
|
2395
|
+
// apply clipPath to $group
|
|
2396
|
+
// @see https://github.com/antvis/g/issues/961
|
|
2397
|
+
$groupEl.setAttribute(attributeNameHyphen, "url(#" + clipPathId + ")");
|
|
2398
|
+
}
|
|
2399
|
+
} else {
|
|
2400
|
+
if (!isTextPath) {
|
|
2401
|
+
// remove clip path
|
|
2402
|
+
$groupEl.removeAttribute(attributeNameHyphen);
|
|
2771
2403
|
}
|
|
2772
2404
|
}
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
"translate(".concat(tx, ",").concat(ty, ")"));
|
|
2796
|
-
}
|
|
2797
|
-
if (object.nodeName === gLite.Shape.CIRCLE || object.nodeName === gLite.Shape.ELLIPSE) {
|
|
2798
|
-
$el.setAttribute('cx', "".concat(width / 2));
|
|
2799
|
-
$el.setAttribute('cy', "".concat(height / 2));
|
|
2800
|
-
}
|
|
2405
|
+
}
|
|
2406
|
+
/**
|
|
2407
|
+
* the origin is bounding box's top left corner
|
|
2408
|
+
*/;
|
|
2409
|
+
_proto.updateAnchorWithTransform = function updateAnchorWithTransform(object) {
|
|
2410
|
+
var _object$elementSVG7, _object$elementSVG8;
|
|
2411
|
+
var bounds = object.getGeometryBounds();
|
|
2412
|
+
var width = bounds && bounds.halfExtents[0] * 2 || 0;
|
|
2413
|
+
var height = bounds && bounds.halfExtents[1] * 2 || 0;
|
|
2414
|
+
var _ref2 = object.parsedStyle || {},
|
|
2415
|
+
anchor = _ref2.anchor;
|
|
2416
|
+
// @ts-ignore
|
|
2417
|
+
[(_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) {
|
|
2418
|
+
if ($el) {
|
|
2419
|
+
var tx = -(anchor[0] * width);
|
|
2420
|
+
var ty = -(anchor[1] * height);
|
|
2421
|
+
if (tx !== 0 || ty !== 0) {
|
|
2422
|
+
// apply anchor to element's `transform` property
|
|
2423
|
+
$el.setAttribute('transform',
|
|
2424
|
+
// can't use percent unit like translate(-50%, -50%)
|
|
2425
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/transform#translate
|
|
2426
|
+
"translate(" + tx + "," + ty + ")");
|
|
2801
2427
|
}
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2428
|
+
if (object.nodeName === gLite.Shape.CIRCLE || object.nodeName === gLite.Shape.ELLIPSE) {
|
|
2429
|
+
$el.setAttribute('cx', "" + width / 2);
|
|
2430
|
+
$el.setAttribute('cy', "" + height / 2);
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
});
|
|
2434
|
+
};
|
|
2805
2435
|
return SVGRendererPlugin;
|
|
2806
2436
|
}();
|
|
2807
2437
|
SVGRendererPlugin.tag = 'SVGRenderer';
|
|
@@ -2857,18 +2487,18 @@
|
|
|
2857
2487
|
var lineNum = lines.length;
|
|
2858
2488
|
var styleCSSText = '';
|
|
2859
2489
|
if (dx !== 0 || dy !== 0) {
|
|
2860
|
-
styleCSSText += "transform:translate("
|
|
2490
|
+
styleCSSText += "transform:translate(" + dx + "px, " + dy + "px);";
|
|
2861
2491
|
}
|
|
2862
2492
|
if (textDecorationLine && textDecorationLine !== 'none') {
|
|
2863
2493
|
// use CSS text-decoration since the implementation in SVG is not good enough
|
|
2864
|
-
styleCSSText += "text-decoration:"
|
|
2494
|
+
styleCSSText += "text-decoration:" + textDecorationLine + " " + textDecorationStyle + " " + textDecorationColor + ";";
|
|
2865
2495
|
}
|
|
2866
2496
|
if (styleCSSText) {
|
|
2867
2497
|
$el.setAttribute('style', styleCSSText);
|
|
2868
2498
|
}
|
|
2869
2499
|
if (lineNum === 1) {
|
|
2870
2500
|
var textContent = convertHTML(lines[0]);
|
|
2871
|
-
$el.setAttribute('dx', ""
|
|
2501
|
+
$el.setAttribute('dx', "" + lineWidth / 2);
|
|
2872
2502
|
// <textPath> only support one line
|
|
2873
2503
|
// @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/textPath
|
|
2874
2504
|
if (textPath) {
|
|
@@ -2876,12 +2506,12 @@
|
|
|
2876
2506
|
$el.innerHTML = '';
|
|
2877
2507
|
// append <textPath href="#MyPath">text</textPath>
|
|
2878
2508
|
var $textPath = createSVGElement('textPath', $el.ownerDocument);
|
|
2879
|
-
$textPath.setAttribute('href', "#"
|
|
2509
|
+
$textPath.setAttribute('href', "#" + (TEXT_PATH_PREFIX + textPath.entity));
|
|
2880
2510
|
if (textPathSide !== 'left') {
|
|
2881
2511
|
$textPath.setAttribute('side', textPathSide);
|
|
2882
2512
|
}
|
|
2883
2513
|
if (textPathStartOffset !== 0) {
|
|
2884
|
-
$textPath.setAttribute('startOffset', ""
|
|
2514
|
+
$textPath.setAttribute('startOffset', "" + textPathStartOffset);
|
|
2885
2515
|
}
|
|
2886
2516
|
$textPath.innerHTML = textContent;
|
|
2887
2517
|
$el.appendChild($textPath);
|
|
@@ -2904,79 +2534,70 @@
|
|
|
2904
2534
|
} else {
|
|
2905
2535
|
dy = lineHeight;
|
|
2906
2536
|
}
|
|
2907
|
-
return "<tspan x=\"0\" dx=\""
|
|
2537
|
+
return "<tspan x=\"0\" dx=\"" + dx + "\" dy=\"" + dy + "\">" + convertHTML(line) + "</tspan>";
|
|
2908
2538
|
}).join('');
|
|
2909
2539
|
}
|
|
2910
2540
|
}
|
|
2911
2541
|
var _SHAPE2TAGS, _SHAPE_UPDATE_DEPS;
|
|
2912
|
-
var SHAPE2TAGS = (_SHAPE2TAGS = {},
|
|
2913
|
-
var SHAPE_UPDATE_DEPS = (_SHAPE_UPDATE_DEPS = {},
|
|
2542
|
+
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);
|
|
2543
|
+
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',
|
|
2914
2544
|
// 'whiteSpace',
|
|
2915
|
-
'dx', 'dy']
|
|
2545
|
+
'dx', 'dy'], _SHAPE_UPDATE_DEPS);
|
|
2916
2546
|
var DefaultElementLifeCycleContribution = /*#__PURE__*/function () {
|
|
2917
2547
|
function DefaultElementLifeCycleContribution(context) {
|
|
2918
|
-
_classCallCheck$2(this, DefaultElementLifeCycleContribution);
|
|
2919
2548
|
this.context = void 0;
|
|
2920
2549
|
this.context = context;
|
|
2921
2550
|
}
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
}
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
break;
|
|
2971
|
-
}
|
|
2972
|
-
case gLite.Shape.TEXT:
|
|
2973
|
-
{
|
|
2974
|
-
updateTextElementAttribute($el, parsedStyle);
|
|
2975
|
-
break;
|
|
2976
|
-
}
|
|
2977
|
-
}
|
|
2551
|
+
var _proto = DefaultElementLifeCycleContribution.prototype;
|
|
2552
|
+
_proto.createElement = function createElement(object) {
|
|
2553
|
+
var doc = this.context.config.document;
|
|
2554
|
+
var type = SHAPE2TAGS[object.nodeName] || 'g';
|
|
2555
|
+
return createSVGElement(type, doc || document);
|
|
2556
|
+
};
|
|
2557
|
+
_proto.destroyElement = function destroyElement(object, $el) {};
|
|
2558
|
+
_proto.shouldUpdateElementAttribute = function shouldUpdateElementAttribute(object, attributeName) {
|
|
2559
|
+
var nodeName = object.nodeName;
|
|
2560
|
+
return (SHAPE_UPDATE_DEPS[nodeName] || []).indexOf(attributeName) > -1;
|
|
2561
|
+
};
|
|
2562
|
+
_proto.updateElementAttribute = function updateElementAttribute(object) {
|
|
2563
|
+
// @ts-ignore
|
|
2564
|
+
var $el = object.elementSVG.$el;
|
|
2565
|
+
var nodeName = object.nodeName,
|
|
2566
|
+
parsedStyle = object.parsedStyle;
|
|
2567
|
+
switch (nodeName) {
|
|
2568
|
+
case gLite.Shape.IMAGE:
|
|
2569
|
+
{
|
|
2570
|
+
updateImageElementAttribute($el, parsedStyle);
|
|
2571
|
+
break;
|
|
2572
|
+
}
|
|
2573
|
+
case gLite.Shape.RECT:
|
|
2574
|
+
{
|
|
2575
|
+
updateRectElementAttribute($el, parsedStyle);
|
|
2576
|
+
break;
|
|
2577
|
+
}
|
|
2578
|
+
case gLite.Shape.LINE:
|
|
2579
|
+
{
|
|
2580
|
+
updateLineElementAttribute($el, parsedStyle);
|
|
2581
|
+
break;
|
|
2582
|
+
}
|
|
2583
|
+
case gLite.Shape.POLYGON:
|
|
2584
|
+
case gLite.Shape.POLYLINE:
|
|
2585
|
+
{
|
|
2586
|
+
updatePolylineElementAttribute($el, parsedStyle);
|
|
2587
|
+
break;
|
|
2588
|
+
}
|
|
2589
|
+
case gLite.Shape.PATH:
|
|
2590
|
+
{
|
|
2591
|
+
updatePathElementAttribute($el, parsedStyle);
|
|
2592
|
+
break;
|
|
2593
|
+
}
|
|
2594
|
+
case gLite.Shape.TEXT:
|
|
2595
|
+
{
|
|
2596
|
+
updateTextElementAttribute($el, parsedStyle);
|
|
2597
|
+
break;
|
|
2598
|
+
}
|
|
2978
2599
|
}
|
|
2979
|
-
}
|
|
2600
|
+
};
|
|
2980
2601
|
return DefaultElementLifeCycleContribution;
|
|
2981
2602
|
}();
|
|
2982
2603
|
var FILTER_PREFIX = 'g-filter-';
|
|
@@ -2987,7 +2608,7 @@
|
|
|
2987
2608
|
function createOrUpdateFilter(document, $def, object, $el, filters) {
|
|
2988
2609
|
// eg. filter="url(#f1) url(#f2)"
|
|
2989
2610
|
var filterName = FILTER_PREFIX + object.entity;
|
|
2990
|
-
var $existedFilters = $def.querySelectorAll("[name="
|
|
2611
|
+
var $existedFilters = $def.querySelectorAll("[name=" + filterName + "]");
|
|
2991
2612
|
if ($existedFilters.length) {
|
|
2992
2613
|
$existedFilters.forEach(function ($filter) {
|
|
2993
2614
|
$def.removeChild($filter);
|
|
@@ -3022,7 +2643,7 @@
|
|
|
3022
2643
|
} else if (name === 'invert') {
|
|
3023
2644
|
createInvert(document, $filter, params);
|
|
3024
2645
|
}
|
|
3025
|
-
$filter.id =
|
|
2646
|
+
$filter.id = filterName + "-" + i;
|
|
3026
2647
|
$filter.setAttribute('name', filterName);
|
|
3027
2648
|
$def.appendChild($filter);
|
|
3028
2649
|
return $filter.id;
|
|
@@ -3030,7 +2651,7 @@
|
|
|
3030
2651
|
// @see https://github.com/antvis/G/issues/1114
|
|
3031
2652
|
setTimeout(function () {
|
|
3032
2653
|
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', filterIds.map(function (filterId) {
|
|
3033
|
-
return "url(#"
|
|
2654
|
+
return "url(#" + filterId + ")";
|
|
3034
2655
|
}).join(' '));
|
|
3035
2656
|
});
|
|
3036
2657
|
}
|
|
@@ -3044,7 +2665,7 @@
|
|
|
3044
2665
|
function createBlur(document, $filter, params) {
|
|
3045
2666
|
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
3046
2667
|
$feGaussianBlur.setAttribute('in', 'SourceGraphic');
|
|
3047
|
-
$feGaussianBlur.setAttribute('stdDeviation', ""
|
|
2668
|
+
$feGaussianBlur.setAttribute('stdDeviation', "" + params[0].value);
|
|
3048
2669
|
$filter.appendChild($feGaussianBlur);
|
|
3049
2670
|
}
|
|
3050
2671
|
function createFeComponentTransfer(document, $filter, _ref2) {
|
|
@@ -3056,10 +2677,10 @@
|
|
|
3056
2677
|
[createSVGElement('feFuncR', document), createSVGElement('feFuncG', document), createSVGElement('feFuncB', document)].forEach(function ($feFunc) {
|
|
3057
2678
|
$feFunc.setAttribute('type', type);
|
|
3058
2679
|
if (type === 'table') {
|
|
3059
|
-
$feFunc.setAttribute('tableValues', ""
|
|
2680
|
+
$feFunc.setAttribute('tableValues', "" + tableValues);
|
|
3060
2681
|
} else {
|
|
3061
|
-
$feFunc.setAttribute('slope', ""
|
|
3062
|
-
$feFunc.setAttribute('intercept', ""
|
|
2682
|
+
$feFunc.setAttribute('slope', "" + slope);
|
|
2683
|
+
$feFunc.setAttribute('intercept', "" + intercept);
|
|
3063
2684
|
}
|
|
3064
2685
|
$feComponentTransfer.appendChild($feFunc);
|
|
3065
2686
|
});
|
|
@@ -3077,7 +2698,7 @@
|
|
|
3077
2698
|
var amount = convertToAbsoluteValue(params[0]);
|
|
3078
2699
|
createFeComponentTransfer(document, $filter, {
|
|
3079
2700
|
type: 'table',
|
|
3080
|
-
tableValues:
|
|
2701
|
+
tableValues: amount + " " + (1 - amount)
|
|
3081
2702
|
});
|
|
3082
2703
|
}
|
|
3083
2704
|
function createBrightness(document, $filter, params) {
|
|
@@ -3092,13 +2713,13 @@
|
|
|
3092
2713
|
var amount = convertToAbsoluteValue(params[0]);
|
|
3093
2714
|
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
3094
2715
|
$feColorMatrix.setAttribute('type', 'saturate');
|
|
3095
|
-
$feColorMatrix.setAttribute('values', ""
|
|
2716
|
+
$feColorMatrix.setAttribute('values', "" + amount);
|
|
3096
2717
|
$filter.appendChild($feColorMatrix);
|
|
3097
2718
|
}
|
|
3098
2719
|
function createHueRotate(document, $filter, params) {
|
|
3099
2720
|
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
3100
2721
|
$feColorMatrix.setAttribute('type', 'hueRotate');
|
|
3101
|
-
$feColorMatrix.setAttribute('values', ""
|
|
2722
|
+
$feColorMatrix.setAttribute('values', "" + params[0].to(gLite.UnitType.kDegrees).value);
|
|
3102
2723
|
$filter.appendChild($feColorMatrix);
|
|
3103
2724
|
}
|
|
3104
2725
|
function createDropShadow(document, $filter, params) {
|
|
@@ -3109,11 +2730,11 @@
|
|
|
3109
2730
|
var shadowColor = params[3].formatted;
|
|
3110
2731
|
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
3111
2732
|
$feGaussianBlur.setAttribute('in', 'SourceAlpha');
|
|
3112
|
-
$feGaussianBlur.setAttribute('stdDeviation', ""
|
|
2733
|
+
$feGaussianBlur.setAttribute('stdDeviation', "" + shadowBlur);
|
|
3113
2734
|
$filter.appendChild($feGaussianBlur);
|
|
3114
2735
|
var $feOffset = createSVGElement('feOffset', document);
|
|
3115
|
-
$feOffset.setAttribute('dx', ""
|
|
3116
|
-
$feOffset.setAttribute('dy', ""
|
|
2736
|
+
$feOffset.setAttribute('dx', "" + shadowOffsetX);
|
|
2737
|
+
$feOffset.setAttribute('dy', "" + shadowOffsetY);
|
|
3117
2738
|
$feOffset.setAttribute('result', 'offsetblur');
|
|
3118
2739
|
$filter.appendChild($feOffset);
|
|
3119
2740
|
var $feFlood = createSVGElement('feFlood', document);
|
|
@@ -3171,32 +2792,34 @@
|
|
|
3171
2792
|
var patternId = createOrUpdatePattern(document, $def, object, parsedColor, createImage, plugin);
|
|
3172
2793
|
// use style instead of attribute when applying <pattern>
|
|
3173
2794
|
// @see https://stackoverflow.com/a/7723115
|
|
3174
|
-
$el.style[name] = "url(#"
|
|
2795
|
+
$el.style[name] = "url(#" + patternId + ")";
|
|
3175
2796
|
return patternId;
|
|
3176
2797
|
} else {
|
|
3177
2798
|
if (parsedColor.length === 1) {
|
|
3178
2799
|
var gradientId = createOrUpdateGradient(document, object, $def, $el, parsedColor[0]);
|
|
3179
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#"
|
|
2800
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#" + gradientId + ")");
|
|
3180
2801
|
return gradientId;
|
|
3181
2802
|
} else {
|
|
3182
2803
|
// @see https://stackoverflow.com/questions/20671502/can-i-blend-gradients-in-svg
|
|
3183
2804
|
var filterId = createOrUpdateMultiGradient(document, object, $def, $el, parsedColor);
|
|
3184
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#"
|
|
2805
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + filterId + ")");
|
|
3185
2806
|
$el === null || $el === void 0 ? void 0 : $el.setAttribute('fill', 'black');
|
|
3186
2807
|
return filterId;
|
|
3187
2808
|
}
|
|
3188
2809
|
}
|
|
3189
2810
|
return '';
|
|
3190
2811
|
}
|
|
3191
|
-
function generateCacheKey(src) {
|
|
3192
|
-
|
|
2812
|
+
function generateCacheKey(src, options) {
|
|
2813
|
+
if (options === void 0) {
|
|
2814
|
+
options = {};
|
|
2815
|
+
}
|
|
3193
2816
|
var cacheKey = '';
|
|
3194
2817
|
if (src instanceof gLite.CSSGradientValue) {
|
|
3195
2818
|
var type = src.type,
|
|
3196
2819
|
value = src.value;
|
|
3197
2820
|
if (type === gLite.GradientType.LinearGradient || type === gLite.GradientType.RadialGradient) {
|
|
3198
2821
|
// @ts-ignore
|
|
3199
|
-
var _value$options =
|
|
2822
|
+
var _value$options = _extends({}, value, options),
|
|
3200
2823
|
_type = _value$options.type,
|
|
3201
2824
|
width = _value$options.width,
|
|
3202
2825
|
height = _value$options.height,
|
|
@@ -3205,25 +2828,25 @@
|
|
|
3205
2828
|
cx = _value$options.cx,
|
|
3206
2829
|
cy = _value$options.cy,
|
|
3207
2830
|
size = _value$options.size;
|
|
3208
|
-
cacheKey = "gradient-"
|
|
2831
|
+
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) {
|
|
3209
2832
|
var offset = _ref.offset,
|
|
3210
2833
|
color = _ref.color;
|
|
3211
|
-
return ""
|
|
3212
|
-
}).join('-')
|
|
2834
|
+
return "" + offset + color;
|
|
2835
|
+
}).join('-');
|
|
3213
2836
|
}
|
|
3214
2837
|
} else if (gLite.isPattern(src)) {
|
|
3215
2838
|
if (isString(src.image)) {
|
|
3216
|
-
cacheKey = "pattern-"
|
|
2839
|
+
cacheKey = "pattern-" + src.image + "-" + src.repetition;
|
|
3217
2840
|
} else if (src.image instanceof gLite.Rect) {
|
|
3218
2841
|
// use rect's entity as key
|
|
3219
|
-
cacheKey = "pattern-rect-"
|
|
2842
|
+
cacheKey = "pattern-rect-" + src.image.entity;
|
|
3220
2843
|
} else {
|
|
3221
|
-
cacheKey = "pattern-"
|
|
2844
|
+
cacheKey = "pattern-" + counter;
|
|
3222
2845
|
}
|
|
3223
2846
|
}
|
|
3224
2847
|
if (cacheKey) {
|
|
3225
2848
|
if (!cacheKey2IDMap[cacheKey]) {
|
|
3226
|
-
cacheKey2IDMap[cacheKey] = PATTERN_PREFIX + ""
|
|
2849
|
+
cacheKey2IDMap[cacheKey] = PATTERN_PREFIX + ("" + counter++);
|
|
3227
2850
|
}
|
|
3228
2851
|
}
|
|
3229
2852
|
return cacheKey2IDMap[cacheKey];
|
|
@@ -3235,56 +2858,55 @@
|
|
|
3235
2858
|
var t = parsed.t,
|
|
3236
2859
|
d = parsed.d;
|
|
3237
2860
|
if (t === 'translate') {
|
|
3238
|
-
return "translate("
|
|
2861
|
+
return "translate(" + d[0].value + " " + d[1].value + ")";
|
|
3239
2862
|
} else if (t === 'translatex') {
|
|
3240
|
-
return "translate("
|
|
2863
|
+
return "translate(" + d[0].value + " 0)";
|
|
3241
2864
|
} else if (t === 'translatey') {
|
|
3242
|
-
return "translate(0 "
|
|
2865
|
+
return "translate(0 " + d[0].value + ")";
|
|
3243
2866
|
} else if (t === 'rotate') {
|
|
3244
|
-
return "rotate("
|
|
2867
|
+
return "rotate(" + d[0].value + ")";
|
|
3245
2868
|
} else if (t === 'scale') {
|
|
3246
2869
|
// scale(1) scale(1, 1)
|
|
3247
2870
|
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
3248
2871
|
return s.value;
|
|
3249
2872
|
})) || [1, 1];
|
|
3250
|
-
return "scale("
|
|
2873
|
+
return "scale(" + newScale[0] + ", " + newScale[1] + ")";
|
|
3251
2874
|
} else if (t === 'scalex') {
|
|
3252
2875
|
var _newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
3253
2876
|
return s.value;
|
|
3254
2877
|
})) || [1];
|
|
3255
|
-
return "scale("
|
|
2878
|
+
return "scale(" + _newScale[0] + ", 1)";
|
|
3256
2879
|
} else if (t === 'scaley') {
|
|
3257
2880
|
var _newScale2 = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
3258
2881
|
return s.value;
|
|
3259
2882
|
})) || [1];
|
|
3260
|
-
return "scale(1, "
|
|
2883
|
+
return "scale(1, " + _newScale2[0] + ")";
|
|
3261
2884
|
} else if (t === 'skew') {
|
|
3262
2885
|
var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
3263
2886
|
return s.value;
|
|
3264
2887
|
})) || [0, 0];
|
|
3265
|
-
return "skewX("
|
|
2888
|
+
return "skewX(" + newSkew[0] + ") skewY(" + newSkew[1] + ")";
|
|
3266
2889
|
} else if (t === 'skewx') {
|
|
3267
2890
|
var _newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
3268
2891
|
return s.value;
|
|
3269
2892
|
})) || [0];
|
|
3270
|
-
return "skewX("
|
|
2893
|
+
return "skewX(" + _newSkew[0] + ")";
|
|
3271
2894
|
} else if (t === 'skewy') {
|
|
3272
2895
|
var _newSkew2 = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
3273
2896
|
return s.value;
|
|
3274
2897
|
})) || [0];
|
|
3275
|
-
return "skewY("
|
|
2898
|
+
return "skewY(" + _newSkew2[0] + ")";
|
|
3276
2899
|
} else if (t === 'matrix') {
|
|
3277
2900
|
var _d$map = d.map(function (s) {
|
|
3278
2901
|
return s.value;
|
|
3279
2902
|
}),
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
return "matrix(".concat(a, " ").concat(b, " ").concat(c, " ").concat(dd, " ").concat(tx, " ").concat(ty, ")");
|
|
2903
|
+
a = _d$map[0],
|
|
2904
|
+
b = _d$map[1],
|
|
2905
|
+
c = _d$map[2],
|
|
2906
|
+
dd = _d$map[3],
|
|
2907
|
+
tx = _d$map[4],
|
|
2908
|
+
ty = _d$map[5];
|
|
2909
|
+
return "matrix(" + a + " " + b + " " + c + " " + dd + " " + tx + " " + ty + ")";
|
|
3288
2910
|
}
|
|
3289
2911
|
}).join(' ');
|
|
3290
2912
|
}
|
|
@@ -3315,13 +2937,13 @@
|
|
|
3315
2937
|
patternWidth = halfExtents[0] * 2;
|
|
3316
2938
|
patternHeight = halfExtents[1] * 2;
|
|
3317
2939
|
}
|
|
3318
|
-
$pattern.setAttribute('width', ""
|
|
3319
|
-
$pattern.setAttribute('height', ""
|
|
2940
|
+
$pattern.setAttribute('width', "" + patternWidth);
|
|
2941
|
+
$pattern.setAttribute('height', "" + patternHeight);
|
|
3320
2942
|
return $pattern;
|
|
3321
2943
|
}
|
|
3322
2944
|
function createOrUpdatePattern(document, $def, object, pattern, createImage, plugin) {
|
|
3323
2945
|
var patternId = generateCacheKey(pattern);
|
|
3324
|
-
var $existed = $def.querySelector("#"
|
|
2946
|
+
var $existed = $def.querySelector("#" + patternId);
|
|
3325
2947
|
if (!$existed) {
|
|
3326
2948
|
var image = pattern.image;
|
|
3327
2949
|
var imageURL = '';
|
|
@@ -3358,8 +2980,8 @@
|
|
|
3358
2980
|
$pattern.appendChild($image);
|
|
3359
2981
|
$image.setAttribute('x', '0');
|
|
3360
2982
|
$image.setAttribute('y', '0');
|
|
3361
|
-
$image.setAttribute('width', ""
|
|
3362
|
-
$image.setAttribute('height', ""
|
|
2983
|
+
$image.setAttribute('width', "" + img.width);
|
|
2984
|
+
$image.setAttribute('height', "" + img.height);
|
|
3363
2985
|
};
|
|
3364
2986
|
if (img.complete) {
|
|
3365
2987
|
onload();
|
|
@@ -3400,7 +3022,7 @@
|
|
|
3400
3022
|
width: width,
|
|
3401
3023
|
height: height
|
|
3402
3024
|
});
|
|
3403
|
-
var $existed = $def.querySelector("#"
|
|
3025
|
+
var $existed = $def.querySelector("#" + gradientId);
|
|
3404
3026
|
if (!$existed) {
|
|
3405
3027
|
// <linearGradient> <radialGradient>
|
|
3406
3028
|
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/linearGradient
|
|
@@ -3418,7 +3040,7 @@
|
|
|
3418
3040
|
var offset = _ref2.offset,
|
|
3419
3041
|
color = _ref2.color;
|
|
3420
3042
|
// TODO: support absolute unit like `px`
|
|
3421
|
-
innerHTML += "<stop offset=\""
|
|
3043
|
+
innerHTML += "<stop offset=\"" + offset.value / 100 + "\" stop-color=\"" + color + "\"></stop>";
|
|
3422
3044
|
});
|
|
3423
3045
|
$existed.innerHTML = innerHTML;
|
|
3424
3046
|
$existed.id = gradientId;
|
|
@@ -3431,10 +3053,10 @@
|
|
|
3431
3053
|
y1 = _computeLinearGradien.y1,
|
|
3432
3054
|
x2 = _computeLinearGradien.x2,
|
|
3433
3055
|
y2 = _computeLinearGradien.y2;
|
|
3434
|
-
$existed.setAttribute('x1', ""
|
|
3435
|
-
$existed.setAttribute('y1', ""
|
|
3436
|
-
$existed.setAttribute('x2', ""
|
|
3437
|
-
$existed.setAttribute('y2', ""
|
|
3056
|
+
$existed.setAttribute('x1', "" + x1);
|
|
3057
|
+
$existed.setAttribute('y1', "" + y1);
|
|
3058
|
+
$existed.setAttribute('x2', "" + x2);
|
|
3059
|
+
$existed.setAttribute('y2', "" + y2);
|
|
3438
3060
|
// $existed.setAttribute('gradientTransform', `rotate(${angle})`);
|
|
3439
3061
|
} else {
|
|
3440
3062
|
var _parsedColor$value = parsedColor.value,
|
|
@@ -3445,15 +3067,15 @@
|
|
|
3445
3067
|
x = _computeRadialGradien.x,
|
|
3446
3068
|
y = _computeRadialGradien.y,
|
|
3447
3069
|
r = _computeRadialGradien.r;
|
|
3448
|
-
$existed.setAttribute('cx', ""
|
|
3449
|
-
$existed.setAttribute('cy', ""
|
|
3450
|
-
$existed.setAttribute('r', ""
|
|
3070
|
+
$existed.setAttribute('cx', "" + x);
|
|
3071
|
+
$existed.setAttribute('cy', "" + y);
|
|
3072
|
+
$existed.setAttribute('r', "" + r);
|
|
3451
3073
|
}
|
|
3452
3074
|
return gradientId;
|
|
3453
3075
|
}
|
|
3454
3076
|
function createOrUpdateMultiGradient(document, object, $def, $el, gradients) {
|
|
3455
3077
|
var filterId = FILTER_PREFIX + object.entity + '-gradient';
|
|
3456
|
-
var $existed = $def.querySelector("#"
|
|
3078
|
+
var $existed = $def.querySelector("#" + filterId);
|
|
3457
3079
|
if (!$existed) {
|
|
3458
3080
|
$existed = createSVGElement('filter', document);
|
|
3459
3081
|
$existed.setAttribute('filterUnits', 'userSpaceOnUse');
|
|
@@ -3483,25 +3105,25 @@
|
|
|
3483
3105
|
$rect.setAttribute('y', '0');
|
|
3484
3106
|
$rect.setAttribute('width', '100%');
|
|
3485
3107
|
$rect.setAttribute('height', '100%');
|
|
3486
|
-
$rect.setAttribute('fill', "url(#"
|
|
3108
|
+
$rect.setAttribute('fill', "url(#" + gradientId + ")");
|
|
3487
3109
|
$rect.id = rectId;
|
|
3488
3110
|
$def.appendChild($rect);
|
|
3489
3111
|
var $feImage = createSVGElement('feImage', document);
|
|
3490
|
-
$feImage.setAttribute('href', "#"
|
|
3491
|
-
$feImage.setAttribute('result',
|
|
3112
|
+
$feImage.setAttribute('href', "#" + rectId);
|
|
3113
|
+
$feImage.setAttribute('result', filterId + "-" + i);
|
|
3492
3114
|
$existed.appendChild($feImage);
|
|
3493
3115
|
if (i > 0) {
|
|
3494
3116
|
var $feBlend = createSVGElement('feBlend', document);
|
|
3495
|
-
$feBlend.setAttribute('in', i === 1 ?
|
|
3496
|
-
$feBlend.setAttribute('in2',
|
|
3497
|
-
$feBlend.setAttribute('result',
|
|
3117
|
+
$feBlend.setAttribute('in', i === 1 ? filterId + "-" + (i - 1) : filterId + "-blended-" + (blended - 1));
|
|
3118
|
+
$feBlend.setAttribute('in2', filterId + "-" + i);
|
|
3119
|
+
$feBlend.setAttribute('result', filterId + "-blended-" + blended++);
|
|
3498
3120
|
// @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/blend-mode
|
|
3499
3121
|
$feBlend.setAttribute('mode', 'multiply');
|
|
3500
3122
|
$existed.appendChild($feBlend);
|
|
3501
3123
|
}
|
|
3502
3124
|
});
|
|
3503
3125
|
var $feComposite = createSVGElement('feComposite', document);
|
|
3504
|
-
$feComposite.setAttribute('in',
|
|
3126
|
+
$feComposite.setAttribute('in', filterId + "-blended-" + blended);
|
|
3505
3127
|
$feComposite.setAttribute('in2', 'SourceGraphic');
|
|
3506
3128
|
$feComposite.setAttribute('operator', 'in');
|
|
3507
3129
|
$existed.appendChild($feComposite);
|
|
@@ -3521,7 +3143,7 @@
|
|
|
3521
3143
|
shadowOffsetY = _object$parsedStyle.shadowOffsetY;
|
|
3522
3144
|
var hasShadow = !isNil(shadowColor) && shadowBlur > 0;
|
|
3523
3145
|
var shadowId = FILTER_DROPSHADOW_PREFIX + object.entity;
|
|
3524
|
-
var $existedFilter = $def.querySelector("#"
|
|
3146
|
+
var $existedFilter = $def.querySelector("#" + shadowId);
|
|
3525
3147
|
if ($existedFilter) {
|
|
3526
3148
|
var existedShadowType = $existedFilter.getAttribute('data-type');
|
|
3527
3149
|
if (existedShadowType !== shadowType || !hasShadow) {
|
|
@@ -3535,7 +3157,7 @@
|
|
|
3535
3157
|
if (hasShadow) {
|
|
3536
3158
|
// use filter <feDropShadow>
|
|
3537
3159
|
// @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow
|
|
3538
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#"
|
|
3160
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + shadowId + ")");
|
|
3539
3161
|
} else {
|
|
3540
3162
|
$el === null || $el === void 0 ? void 0 : $el.removeAttribute('filter');
|
|
3541
3163
|
return;
|
|
@@ -3545,9 +3167,9 @@
|
|
|
3545
3167
|
$existedFilter.setAttribute('data-type', shadowType);
|
|
3546
3168
|
if (shadowType === 'outer') {
|
|
3547
3169
|
var $feDropShadow = createSVGElement('feDropShadow', document);
|
|
3548
|
-
$feDropShadow.setAttribute('dx', ""
|
|
3549
|
-
$feDropShadow.setAttribute('dy', ""
|
|
3550
|
-
$feDropShadow.setAttribute('stdDeviation', ""
|
|
3170
|
+
$feDropShadow.setAttribute('dx', "" + (shadowOffsetX || 0) / 2);
|
|
3171
|
+
$feDropShadow.setAttribute('dy', "" + (shadowOffsetY || 0) / 2);
|
|
3172
|
+
$feDropShadow.setAttribute('stdDeviation', "" + (shadowBlur || 0) / 4);
|
|
3551
3173
|
$feDropShadow.setAttribute('flood-color', shadowColor.toString());
|
|
3552
3174
|
$existedFilter.appendChild($feDropShadow);
|
|
3553
3175
|
} else if (shadowType === 'inner') {
|
|
@@ -3559,11 +3181,11 @@
|
|
|
3559
3181
|
$feComponentTransfer.appendChild($feFuncA);
|
|
3560
3182
|
$existedFilter.appendChild($feComponentTransfer);
|
|
3561
3183
|
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
3562
|
-
$feGaussianBlur.setAttribute('stdDeviation', ""
|
|
3184
|
+
$feGaussianBlur.setAttribute('stdDeviation', "" + (shadowBlur || 0) / 4);
|
|
3563
3185
|
$existedFilter.appendChild($feGaussianBlur);
|
|
3564
3186
|
var $feOffset = createSVGElement('feOffset', document);
|
|
3565
|
-
$feOffset.setAttribute('dx', ""
|
|
3566
|
-
$feOffset.setAttribute('dy', ""
|
|
3187
|
+
$feOffset.setAttribute('dx', "" + (shadowOffsetX || 0) / 2);
|
|
3188
|
+
$feOffset.setAttribute('dy', "" + (shadowOffsetY || 0) / 2);
|
|
3567
3189
|
$feOffset.setAttribute('result', 'offsetblur');
|
|
3568
3190
|
$existedFilter.appendChild($feOffset);
|
|
3569
3191
|
var $feFlood = createSVGElement('feFlood', document);
|
|
@@ -3602,11 +3224,11 @@
|
|
|
3602
3224
|
// half the blur radius
|
|
3603
3225
|
// @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
|
|
3604
3226
|
// @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
|
|
3605
|
-
_$feGaussianBlur.setAttribute('stdDeviation', ""
|
|
3227
|
+
_$feGaussianBlur.setAttribute('stdDeviation', "" + (shadowBlur || 0) / 4);
|
|
3606
3228
|
} else if (name === 'shadowOffsetX') {
|
|
3607
|
-
_$feOffset.setAttribute('dx', ""
|
|
3229
|
+
_$feOffset.setAttribute('dx', "" + (shadowOffsetX || 0) / 2);
|
|
3608
3230
|
} else if (name === 'shadowOffsetY') {
|
|
3609
|
-
_$feOffset.setAttribute('dy', ""
|
|
3231
|
+
_$feOffset.setAttribute('dy', "" + (shadowOffsetY || 0) / 2);
|
|
3610
3232
|
}
|
|
3611
3233
|
} else if (shadowType === 'outer') {
|
|
3612
3234
|
var _$feDropShadow = $existedFilter.children[0];
|
|
@@ -3616,18 +3238,17 @@
|
|
|
3616
3238
|
// half the blur radius
|
|
3617
3239
|
// @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
|
|
3618
3240
|
// @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
|
|
3619
|
-
_$feDropShadow.setAttribute('stdDeviation', ""
|
|
3241
|
+
_$feDropShadow.setAttribute('stdDeviation', "" + (shadowBlur || 0) / 4);
|
|
3620
3242
|
} else if (name === 'shadowOffsetX') {
|
|
3621
|
-
_$feDropShadow.setAttribute('dx', ""
|
|
3243
|
+
_$feDropShadow.setAttribute('dx', "" + (shadowOffsetX || 0) / 2);
|
|
3622
3244
|
} else if (name === 'shadowOffsetY') {
|
|
3623
|
-
_$feDropShadow.setAttribute('dy', ""
|
|
3245
|
+
_$feDropShadow.setAttribute('dy', "" + (shadowOffsetY || 0) / 2);
|
|
3624
3246
|
}
|
|
3625
3247
|
}
|
|
3626
3248
|
}
|
|
3627
3249
|
var urlRegexp = /url\("?#(.*)\)/;
|
|
3628
3250
|
var DefElementManager = /*#__PURE__*/function () {
|
|
3629
3251
|
function DefElementManager(context) {
|
|
3630
|
-
_classCallCheck$2(this, DefElementManager);
|
|
3631
3252
|
this.context = void 0;
|
|
3632
3253
|
this.$def = void 0;
|
|
3633
3254
|
this.gradientCache = {};
|
|
@@ -3636,124 +3257,106 @@
|
|
|
3636
3257
|
/**
|
|
3637
3258
|
* container for <gradient> <clipPath>...
|
|
3638
3259
|
*/
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
}, {
|
|
3661
|
-
key: "clearUnusedDefElement",
|
|
3662
|
-
value: function clearUnusedDefElement(cache, id, entity) {
|
|
3663
|
-
if (cache[id] && cache[id].size === 1 && cache[id].has(entity)) {
|
|
3664
|
-
var targetElement = this.$def.querySelector("#".concat(id));
|
|
3665
|
-
if (targetElement) {
|
|
3666
|
-
this.$def.removeChild(targetElement);
|
|
3667
|
-
}
|
|
3260
|
+
var _proto = DefElementManager.prototype;
|
|
3261
|
+
_proto.getDefElement = function getDefElement() {
|
|
3262
|
+
return this.$def;
|
|
3263
|
+
};
|
|
3264
|
+
_proto.init = function init() {
|
|
3265
|
+
var document = this.context.config.document;
|
|
3266
|
+
var $svg = this.context.contextService.getContext();
|
|
3267
|
+
this.$def = createSVGElement('defs', document);
|
|
3268
|
+
$svg.appendChild(this.$def);
|
|
3269
|
+
};
|
|
3270
|
+
_proto.clear = function clear(entity) {
|
|
3271
|
+
var _this = this;
|
|
3272
|
+
Object.keys(this.gradientCache).forEach(function (id) {
|
|
3273
|
+
_this.clearUnusedDefElement(_this.gradientCache, id, entity);
|
|
3274
|
+
});
|
|
3275
|
+
};
|
|
3276
|
+
_proto.clearUnusedDefElement = function clearUnusedDefElement(cache, id, entity) {
|
|
3277
|
+
if (cache[id] && cache[id].size === 1 && cache[id].has(entity)) {
|
|
3278
|
+
var targetElement = this.$def.querySelector("#" + id);
|
|
3279
|
+
if (targetElement) {
|
|
3280
|
+
this.$def.removeChild(targetElement);
|
|
3668
3281
|
}
|
|
3669
3282
|
}
|
|
3670
|
-
}
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
if (newDefElementId) {
|
|
3691
|
-
|
|
3692
|
-
this.gradientCache[newDefElementId] = new Set();
|
|
3693
|
-
}
|
|
3694
|
-
this.gradientCache[newDefElementId].add(object.entity);
|
|
3283
|
+
};
|
|
3284
|
+
_proto.createOrUpdateGradientAndPattern = function createOrUpdateGradientAndPattern$1(object, $el, parsedColor, name, plugin) {
|
|
3285
|
+
var _this$context$config = this.context.config,
|
|
3286
|
+
doc = _this$context$config.document,
|
|
3287
|
+
createImage = _this$context$config.createImage;
|
|
3288
|
+
if ($el) {
|
|
3289
|
+
var attributeValue = '';
|
|
3290
|
+
if (gLite.isPattern(parsedColor)) {
|
|
3291
|
+
// `fill: url(#${patternId})`
|
|
3292
|
+
attributeValue = $el.style[name];
|
|
3293
|
+
} else {
|
|
3294
|
+
// `url(#${gradientId})`
|
|
3295
|
+
attributeValue = $el.getAttribute(name) || '';
|
|
3296
|
+
}
|
|
3297
|
+
var matches = attributeValue.match(urlRegexp);
|
|
3298
|
+
if (matches && matches.length > 1) {
|
|
3299
|
+
this.clearUnusedDefElement(this.gradientCache, matches[1].replace('"', ''), object.entity);
|
|
3300
|
+
}
|
|
3301
|
+
var newDefElementId = createOrUpdateGradientAndPattern(doc || document, this.$def, object, $el, parsedColor, name, createImage, plugin);
|
|
3302
|
+
if (newDefElementId) {
|
|
3303
|
+
if (!this.gradientCache[newDefElementId]) {
|
|
3304
|
+
this.gradientCache[newDefElementId] = new Set();
|
|
3695
3305
|
}
|
|
3306
|
+
this.gradientCache[newDefElementId].add(object.entity);
|
|
3696
3307
|
}
|
|
3697
3308
|
}
|
|
3698
|
-
}
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
var doc = this.context.config.document;
|
|
3708
|
-
createOrUpdateFilter(doc || document, this.$def, object, $el, filters);
|
|
3709
|
-
}
|
|
3710
|
-
}]);
|
|
3309
|
+
};
|
|
3310
|
+
_proto.createOrUpdateShadow = function createOrUpdateShadow$1(object, $el, name) {
|
|
3311
|
+
var doc = this.context.config.document;
|
|
3312
|
+
createOrUpdateShadow(doc || document, this.$def, object, $el, name);
|
|
3313
|
+
};
|
|
3314
|
+
_proto.createOrUpdateFilter = function createOrUpdateFilter$1(object, $el, filters) {
|
|
3315
|
+
var doc = this.context.config.document;
|
|
3316
|
+
createOrUpdateFilter(doc || document, this.$def, object, $el, filters);
|
|
3317
|
+
};
|
|
3711
3318
|
return DefElementManager;
|
|
3712
3319
|
}();
|
|
3713
3320
|
var Plugin$1 = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
function Plugin() {
|
|
3321
|
+
_inheritsLoose$2(Plugin, _AbstractRendererPlug);
|
|
3322
|
+
function Plugin(options) {
|
|
3717
3323
|
var _this;
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3324
|
+
if (options === void 0) {
|
|
3325
|
+
options = {};
|
|
3326
|
+
}
|
|
3327
|
+
_this = _AbstractRendererPlug.call(this) || this;
|
|
3721
3328
|
_this.options = void 0;
|
|
3722
3329
|
_this.name = 'svg-renderer';
|
|
3723
3330
|
_this.options = options;
|
|
3724
3331
|
return _this;
|
|
3725
3332
|
}
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
// @ts-ignore
|
|
3754
|
-
delete this.context.SVGElementLifeCycleContribution;
|
|
3755
|
-
}
|
|
3756
|
-
}]);
|
|
3333
|
+
var _proto = Plugin.prototype;
|
|
3334
|
+
_proto.init = function init() {
|
|
3335
|
+
var _this$options = this.options,
|
|
3336
|
+
outputSVGElementId = _this$options.outputSVGElementId,
|
|
3337
|
+
outputSVGElementName = _this$options.outputSVGElementName;
|
|
3338
|
+
var defElementManager = new DefElementManager(this.context);
|
|
3339
|
+
// default implementation
|
|
3340
|
+
var defaultElementLifeCycleContribution = new DefaultElementLifeCycleContribution(this.context);
|
|
3341
|
+
// @ts-ignore
|
|
3342
|
+
this.context.defaultElementLifeCycleContribution = defaultElementLifeCycleContribution;
|
|
3343
|
+
// @ts-ignore
|
|
3344
|
+
this.context.SVGElementLifeCycleContribution = defaultElementLifeCycleContribution;
|
|
3345
|
+
var SVGRendererPluginOptions = {
|
|
3346
|
+
outputSVGElementId: !isNil(outputSVGElementId) ? !!outputSVGElementId : true,
|
|
3347
|
+
outputSVGElementName: !isNil(outputSVGElementName) ? !!outputSVGElementName : true
|
|
3348
|
+
};
|
|
3349
|
+
this.addRenderingPlugin(
|
|
3350
|
+
// @ts-ignore
|
|
3351
|
+
new SVGRendererPlugin(SVGRendererPluginOptions, defElementManager, this.context));
|
|
3352
|
+
};
|
|
3353
|
+
_proto.destroy = function destroy() {
|
|
3354
|
+
this.removeAllRenderingPlugins();
|
|
3355
|
+
// @ts-ignore
|
|
3356
|
+
delete this.context.defaultElementLifeCycleContribution;
|
|
3357
|
+
// @ts-ignore
|
|
3358
|
+
delete this.context.SVGElementLifeCycleContribution;
|
|
3359
|
+
};
|
|
3757
3360
|
return Plugin;
|
|
3758
3361
|
}(gLite.AbstractRendererPlugin);
|
|
3759
3362
|
|
|
@@ -3855,7 +3458,7 @@
|
|
|
3855
3458
|
if ("throw" !== record.type) {
|
|
3856
3459
|
var result = record.arg,
|
|
3857
3460
|
value = result.value;
|
|
3858
|
-
return value && "object" ==
|
|
3461
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
3859
3462
|
invoke("next", value, resolve, reject);
|
|
3860
3463
|
}, function (err) {
|
|
3861
3464
|
invoke("throw", err, resolve, reject);
|
|
@@ -4116,49 +3719,10 @@
|
|
|
4116
3719
|
});
|
|
4117
3720
|
};
|
|
4118
3721
|
}
|
|
4119
|
-
function
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
}
|
|
4124
|
-
function _defineProperties$3(target, props) {
|
|
4125
|
-
for (var i = 0; i < props.length; i++) {
|
|
4126
|
-
var descriptor = props[i];
|
|
4127
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
4128
|
-
descriptor.configurable = true;
|
|
4129
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
4130
|
-
Object.defineProperty(target, _toPropertyKey$3(descriptor.key), descriptor);
|
|
4131
|
-
}
|
|
4132
|
-
}
|
|
4133
|
-
function _createClass$3(Constructor, protoProps, staticProps) {
|
|
4134
|
-
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
|
|
4135
|
-
if (staticProps) _defineProperties$3(Constructor, staticProps);
|
|
4136
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
4137
|
-
writable: false
|
|
4138
|
-
});
|
|
4139
|
-
return Constructor;
|
|
4140
|
-
}
|
|
4141
|
-
function _inherits$3(subClass, superClass) {
|
|
4142
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
4143
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
4144
|
-
}
|
|
4145
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
4146
|
-
constructor: {
|
|
4147
|
-
value: subClass,
|
|
4148
|
-
writable: true,
|
|
4149
|
-
configurable: true
|
|
4150
|
-
}
|
|
4151
|
-
});
|
|
4152
|
-
Object.defineProperty(subClass, "prototype", {
|
|
4153
|
-
writable: false
|
|
4154
|
-
});
|
|
4155
|
-
if (superClass) _setPrototypeOf$3(subClass, superClass);
|
|
4156
|
-
}
|
|
4157
|
-
function _getPrototypeOf$3(o) {
|
|
4158
|
-
_getPrototypeOf$3 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
4159
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
4160
|
-
};
|
|
4161
|
-
return _getPrototypeOf$3(o);
|
|
3722
|
+
function _inheritsLoose$3(subClass, superClass) {
|
|
3723
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
3724
|
+
subClass.prototype.constructor = subClass;
|
|
3725
|
+
_setPrototypeOf$3(subClass, superClass);
|
|
4162
3726
|
}
|
|
4163
3727
|
function _setPrototypeOf$3(o, p) {
|
|
4164
3728
|
_setPrototypeOf$3 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -4167,124 +3731,38 @@
|
|
|
4167
3731
|
};
|
|
4168
3732
|
return _setPrototypeOf$3(o, p);
|
|
4169
3733
|
}
|
|
4170
|
-
function
|
|
4171
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
4172
|
-
if (Reflect.construct.sham) return false;
|
|
4173
|
-
if (typeof Proxy === "function") return true;
|
|
4174
|
-
try {
|
|
4175
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
4176
|
-
return true;
|
|
4177
|
-
} catch (e) {
|
|
4178
|
-
return false;
|
|
4179
|
-
}
|
|
4180
|
-
}
|
|
4181
|
-
function _assertThisInitialized$3(self) {
|
|
4182
|
-
if (self === void 0) {
|
|
4183
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4184
|
-
}
|
|
4185
|
-
return self;
|
|
4186
|
-
}
|
|
4187
|
-
function _possibleConstructorReturn$3(self, call) {
|
|
4188
|
-
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
4189
|
-
return call;
|
|
4190
|
-
} else if (call !== void 0) {
|
|
4191
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
4192
|
-
}
|
|
4193
|
-
return _assertThisInitialized$3(self);
|
|
4194
|
-
}
|
|
4195
|
-
function _createSuper$3(Derived) {
|
|
4196
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct$3();
|
|
4197
|
-
return function _createSuperInternal() {
|
|
4198
|
-
var Super = _getPrototypeOf$3(Derived),
|
|
4199
|
-
result;
|
|
4200
|
-
if (hasNativeReflectConstruct) {
|
|
4201
|
-
var NewTarget = _getPrototypeOf$3(this).constructor;
|
|
4202
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
4203
|
-
} else {
|
|
4204
|
-
result = Super.apply(this, arguments);
|
|
4205
|
-
}
|
|
4206
|
-
return _possibleConstructorReturn$3(this, result);
|
|
4207
|
-
};
|
|
4208
|
-
}
|
|
4209
|
-
function _unsupportedIterableToArray$1(o, minLen) {
|
|
3734
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
4210
3735
|
if (!o) return;
|
|
4211
|
-
if (typeof o === "string") return _arrayLikeToArray
|
|
3736
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
4212
3737
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
4213
3738
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
4214
3739
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
4215
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray
|
|
3740
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
4216
3741
|
}
|
|
4217
|
-
function _arrayLikeToArray
|
|
3742
|
+
function _arrayLikeToArray(arr, len) {
|
|
4218
3743
|
if (len == null || len > arr.length) len = arr.length;
|
|
4219
3744
|
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
4220
3745
|
arr2[i] = arr[i];
|
|
4221
3746
|
}
|
|
4222
3747
|
return arr2;
|
|
4223
3748
|
}
|
|
4224
|
-
function
|
|
3749
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
4225
3750
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
4226
|
-
if (
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
3751
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
3752
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
3753
|
+
if (it) o = it;
|
|
3754
|
+
var i = 0;
|
|
3755
|
+
return function () {
|
|
3756
|
+
if (i >= o.length) return {
|
|
3757
|
+
done: true
|
|
3758
|
+
};
|
|
4231
3759
|
return {
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
if (i >= o.length) return {
|
|
4235
|
-
done: true
|
|
4236
|
-
};
|
|
4237
|
-
return {
|
|
4238
|
-
done: false,
|
|
4239
|
-
value: o[i++]
|
|
4240
|
-
};
|
|
4241
|
-
},
|
|
4242
|
-
e: function e(_e) {
|
|
4243
|
-
throw _e;
|
|
4244
|
-
},
|
|
4245
|
-
f: F
|
|
3760
|
+
done: false,
|
|
3761
|
+
value: o[i++]
|
|
4246
3762
|
};
|
|
4247
|
-
}
|
|
4248
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4249
|
-
}
|
|
4250
|
-
var normalCompletion = true,
|
|
4251
|
-
didErr = false,
|
|
4252
|
-
err;
|
|
4253
|
-
return {
|
|
4254
|
-
s: function s() {
|
|
4255
|
-
it = it.call(o);
|
|
4256
|
-
},
|
|
4257
|
-
n: function n() {
|
|
4258
|
-
var step = it.next();
|
|
4259
|
-
normalCompletion = step.done;
|
|
4260
|
-
return step;
|
|
4261
|
-
},
|
|
4262
|
-
e: function e(_e2) {
|
|
4263
|
-
didErr = true;
|
|
4264
|
-
err = _e2;
|
|
4265
|
-
},
|
|
4266
|
-
f: function f() {
|
|
4267
|
-
try {
|
|
4268
|
-
if (!normalCompletion && it.return != null) it.return();
|
|
4269
|
-
} finally {
|
|
4270
|
-
if (didErr) throw err;
|
|
4271
|
-
}
|
|
4272
|
-
}
|
|
4273
|
-
};
|
|
4274
|
-
}
|
|
4275
|
-
function _toPrimitive$3(input, hint) {
|
|
4276
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
4277
|
-
var prim = input[Symbol.toPrimitive];
|
|
4278
|
-
if (prim !== undefined) {
|
|
4279
|
-
var res = prim.call(input, hint || "default");
|
|
4280
|
-
if (_typeof(res) !== "object") return res;
|
|
4281
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
3763
|
+
};
|
|
4282
3764
|
}
|
|
4283
|
-
|
|
4284
|
-
}
|
|
4285
|
-
function _toPropertyKey$3(arg) {
|
|
4286
|
-
var key = _toPrimitive$3(arg, "string");
|
|
4287
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
3765
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4288
3766
|
}
|
|
4289
3767
|
|
|
4290
3768
|
/**
|
|
@@ -4294,106 +3772,86 @@
|
|
|
4294
3772
|
* 2. use elementFromPoint
|
|
4295
3773
|
*/
|
|
4296
3774
|
var SVGPickerPlugin = /*#__PURE__*/function () {
|
|
4297
|
-
function SVGPickerPlugin() {
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
var
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
case 1:
|
|
4314
|
-
case "end":
|
|
4315
|
-
return _context.stop();
|
|
4316
|
-
}
|
|
3775
|
+
function SVGPickerPlugin() {}
|
|
3776
|
+
var _proto = SVGPickerPlugin.prototype;
|
|
3777
|
+
_proto.apply = function apply(context) {
|
|
3778
|
+
var _this = this;
|
|
3779
|
+
var doc = context.config.document,
|
|
3780
|
+
renderingService = context.renderingService;
|
|
3781
|
+
renderingService.hooks.pick.tapPromise(SVGPickerPlugin.tag, /*#__PURE__*/function () {
|
|
3782
|
+
var _ref = _asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee(result) {
|
|
3783
|
+
return _regeneratorRuntime$3().wrap(function _callee$(_context) {
|
|
3784
|
+
while (1) {
|
|
3785
|
+
switch (_context.prev = _context.next) {
|
|
3786
|
+
case 0:
|
|
3787
|
+
return _context.abrupt("return", _this.pick(doc, result));
|
|
3788
|
+
case 1:
|
|
3789
|
+
case "end":
|
|
3790
|
+
return _context.stop();
|
|
4317
3791
|
}
|
|
4318
|
-
}
|
|
4319
|
-
})
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
}
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
}
|
|
4328
|
-
}
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
var
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
targets.push(target);
|
|
4351
|
-
if (topmost) {
|
|
4352
|
-
result.picked = targets;
|
|
4353
|
-
return result;
|
|
4354
|
-
}
|
|
4355
|
-
}
|
|
3792
|
+
}
|
|
3793
|
+
}, _callee);
|
|
3794
|
+
}));
|
|
3795
|
+
return function (_x) {
|
|
3796
|
+
return _ref.apply(this, arguments);
|
|
3797
|
+
};
|
|
3798
|
+
}());
|
|
3799
|
+
renderingService.hooks.pickSync.tap(SVGPickerPlugin.tag, function (result) {
|
|
3800
|
+
return _this.pick(doc, result);
|
|
3801
|
+
});
|
|
3802
|
+
};
|
|
3803
|
+
_proto.pick = function pick(doc, result) {
|
|
3804
|
+
var topmost = result.topmost,
|
|
3805
|
+
_result$position = result.position,
|
|
3806
|
+
clientX = _result$position.clientX,
|
|
3807
|
+
clientY = _result$position.clientY;
|
|
3808
|
+
try {
|
|
3809
|
+
var targets = [];
|
|
3810
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
|
|
3811
|
+
for (var _iterator = _createForOfIteratorHelperLoose((doc || document).elementsFromPoint(clientX, clientY)), _step; !(_step = _iterator()).done;) {
|
|
3812
|
+
var element = _step.value;
|
|
3813
|
+
// eg. g_svg_circle_345
|
|
3814
|
+
var id = element && element.getAttribute('id');
|
|
3815
|
+
if (id && id.startsWith(G_SVG_PREFIX)) {
|
|
3816
|
+
var index = id.lastIndexOf('-');
|
|
3817
|
+
var target = gLite.runtime.displayObjectPool.getByEntity(id.substring(index + 1));
|
|
3818
|
+
// don't need to account for `visibility` since DOM API already does
|
|
3819
|
+
if (target && target.isInteractive()) {
|
|
3820
|
+
targets.push(target);
|
|
3821
|
+
if (topmost) {
|
|
3822
|
+
result.picked = targets;
|
|
3823
|
+
return result;
|
|
4356
3824
|
}
|
|
4357
3825
|
}
|
|
4358
|
-
} catch (err) {
|
|
4359
|
-
_iterator.e(err);
|
|
4360
|
-
} finally {
|
|
4361
|
-
_iterator.f();
|
|
4362
3826
|
}
|
|
4363
|
-
result.picked = targets;
|
|
4364
|
-
} catch (e) {
|
|
4365
|
-
result.picked = [];
|
|
4366
3827
|
}
|
|
4367
|
-
|
|
3828
|
+
result.picked = targets;
|
|
3829
|
+
} catch (e) {
|
|
3830
|
+
result.picked = [];
|
|
4368
3831
|
}
|
|
4369
|
-
|
|
3832
|
+
return result;
|
|
3833
|
+
};
|
|
4370
3834
|
return SVGPickerPlugin;
|
|
4371
3835
|
}();
|
|
4372
3836
|
SVGPickerPlugin.tag = 'SVGPicker';
|
|
4373
3837
|
var Plugin$2 = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
4374
|
-
|
|
4375
|
-
var _super = _createSuper$3(Plugin);
|
|
3838
|
+
_inheritsLoose$3(Plugin, _AbstractRendererPlug);
|
|
4376
3839
|
function Plugin() {
|
|
4377
3840
|
var _this;
|
|
4378
|
-
_classCallCheck$3(this, Plugin);
|
|
4379
3841
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4380
3842
|
args[_key] = arguments[_key];
|
|
4381
3843
|
}
|
|
4382
|
-
_this =
|
|
3844
|
+
_this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
|
|
4383
3845
|
_this.name = 'svg-picker';
|
|
4384
3846
|
return _this;
|
|
4385
3847
|
}
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
value: function destroy() {
|
|
4394
|
-
this.removeAllRenderingPlugins();
|
|
4395
|
-
}
|
|
4396
|
-
}]);
|
|
3848
|
+
var _proto = Plugin.prototype;
|
|
3849
|
+
_proto.init = function init() {
|
|
3850
|
+
this.addRenderingPlugin(new SVGPickerPlugin());
|
|
3851
|
+
};
|
|
3852
|
+
_proto.destroy = function destroy() {
|
|
3853
|
+
this.removeAllRenderingPlugins();
|
|
3854
|
+
};
|
|
4397
3855
|
return Plugin;
|
|
4398
3856
|
}(gLite.AbstractRendererPlugin);
|
|
4399
3857
|
|
|
@@ -4402,165 +3860,263 @@
|
|
|
4402
3860
|
Plugin: Plugin$2
|
|
4403
3861
|
});
|
|
4404
3862
|
|
|
3863
|
+
var _excluded = ["offset", "composite", "computedOffset", "easing"],
|
|
3864
|
+
_excluded2 = ["offset", "composite", "computedOffset", "easing", "transformOrigin"],
|
|
3865
|
+
_excluded3 = ["offset", "composite", "computedOffset", "easing", "transformOrigin"],
|
|
3866
|
+
_excluded4 = ["offset", "composite", "computedOffset", "easing", "transformOrigin"];
|
|
4405
3867
|
var SVGContextService = /*#__PURE__*/function () {
|
|
4406
3868
|
function SVGContextService(context) {
|
|
4407
|
-
|
|
3869
|
+
this.context = void 0;
|
|
4408
3870
|
this.$container = void 0;
|
|
4409
3871
|
this.$namespace = void 0;
|
|
4410
3872
|
this.dpr = void 0;
|
|
4411
3873
|
this.canvasConfig = void 0;
|
|
3874
|
+
this.context = context;
|
|
4412
3875
|
this.canvasConfig = context.config;
|
|
4413
3876
|
}
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
var
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
if (this.$container) {
|
|
4426
|
-
|
|
4427
|
-
this.$container.style.position = 'relative';
|
|
4428
|
-
}
|
|
4429
|
-
$namespace = createSVGElement('svg', doc);
|
|
4430
|
-
$namespace.setAttribute('width', "".concat(this.canvasConfig.width));
|
|
4431
|
-
$namespace.setAttribute('height', "".concat(this.canvasConfig.height));
|
|
4432
|
-
this.$container.appendChild($namespace);
|
|
4433
|
-
this.$namespace = $namespace;
|
|
3877
|
+
var _proto = SVGContextService.prototype;
|
|
3878
|
+
_proto.init = /*#__PURE__*/function () {
|
|
3879
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
3880
|
+
var _this$canvasConfig, container, doc, devicePixelRatio, $namespace, dpr;
|
|
3881
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
3882
|
+
while (1) {
|
|
3883
|
+
switch (_context.prev = _context.next) {
|
|
3884
|
+
case 0:
|
|
3885
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document, devicePixelRatio = _this$canvasConfig.devicePixelRatio; // create container
|
|
3886
|
+
this.$container = isString(container) ? (doc || document).getElementById(container) : container;
|
|
3887
|
+
if (this.$container) {
|
|
3888
|
+
if (!this.$container.style.position) {
|
|
3889
|
+
this.$container.style.position = 'relative';
|
|
4434
3890
|
}
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
this.
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
3891
|
+
$namespace = createSVGElement('svg', doc);
|
|
3892
|
+
$namespace.setAttribute('width', "" + this.canvasConfig.width);
|
|
3893
|
+
$namespace.setAttribute('height', "" + this.canvasConfig.height);
|
|
3894
|
+
this.$container.appendChild($namespace);
|
|
3895
|
+
this.$namespace = $namespace;
|
|
3896
|
+
}
|
|
3897
|
+
// use user-defined dpr first
|
|
3898
|
+
dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
|
|
3899
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
3900
|
+
this.dpr = dpr;
|
|
3901
|
+
case 6:
|
|
3902
|
+
case "end":
|
|
3903
|
+
return _context.stop();
|
|
4443
3904
|
}
|
|
4444
|
-
}
|
|
4445
|
-
})
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
return init;
|
|
4450
|
-
}() // @ts-ignore
|
|
4451
|
-
}, {
|
|
4452
|
-
key: "getDomElement",
|
|
4453
|
-
value: function getDomElement() {
|
|
4454
|
-
return this.$namespace;
|
|
4455
|
-
}
|
|
4456
|
-
}, {
|
|
4457
|
-
key: "getContext",
|
|
4458
|
-
value: function getContext() {
|
|
4459
|
-
return this.$namespace;
|
|
4460
|
-
}
|
|
4461
|
-
}, {
|
|
4462
|
-
key: "getDPR",
|
|
4463
|
-
value: function getDPR() {
|
|
4464
|
-
return this.dpr;
|
|
3905
|
+
}
|
|
3906
|
+
}, _callee, this);
|
|
3907
|
+
}));
|
|
3908
|
+
function init() {
|
|
3909
|
+
return _init.apply(this, arguments);
|
|
4465
3910
|
}
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
3911
|
+
return init;
|
|
3912
|
+
}() // @ts-ignore
|
|
3913
|
+
;
|
|
3914
|
+
_proto.getDomElement = function getDomElement() {
|
|
3915
|
+
return this.$namespace;
|
|
3916
|
+
};
|
|
3917
|
+
_proto.getContext = function getContext() {
|
|
3918
|
+
return this.$namespace;
|
|
3919
|
+
};
|
|
3920
|
+
_proto.getDPR = function getDPR() {
|
|
3921
|
+
return this.dpr;
|
|
3922
|
+
};
|
|
3923
|
+
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
3924
|
+
var _this$$namespace;
|
|
3925
|
+
return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
|
|
3926
|
+
};
|
|
3927
|
+
_proto.destroy = function destroy() {
|
|
3928
|
+
// destroy context
|
|
3929
|
+
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
3930
|
+
this.$container.removeChild(this.$namespace);
|
|
4471
3931
|
}
|
|
4472
|
-
}
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
}
|
|
3932
|
+
};
|
|
3933
|
+
_proto.resize = function resize(width, height) {
|
|
3934
|
+
// SVG should ignore DPR
|
|
3935
|
+
if (this.$namespace) {
|
|
3936
|
+
this.$namespace.setAttribute('width', "" + width);
|
|
3937
|
+
this.$namespace.setAttribute('height', "" + height);
|
|
4479
3938
|
}
|
|
4480
|
-
}
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
if (this.$namespace) {
|
|
4485
|
-
this.$namespace.setAttribute('width', "".concat(width));
|
|
4486
|
-
this.$namespace.setAttribute('height', "".concat(height));
|
|
4487
|
-
}
|
|
3939
|
+
};
|
|
3940
|
+
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
3941
|
+
if (this.$container) {
|
|
3942
|
+
this.$container.style.cursor = cursor;
|
|
4488
3943
|
}
|
|
4489
|
-
}
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
this.$container.style.cursor = cursor;
|
|
4494
|
-
}
|
|
3944
|
+
};
|
|
3945
|
+
_proto.generateCSSText = function generateCSSText(animationName, selector, keyframes, timing, prefixes) {
|
|
3946
|
+
if (prefixes === void 0) {
|
|
3947
|
+
prefixes = {};
|
|
4495
3948
|
}
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
3949
|
+
var duration = timing.duration,
|
|
3950
|
+
easing = timing.easing,
|
|
3951
|
+
delay = timing.delay,
|
|
3952
|
+
direction = timing.direction,
|
|
3953
|
+
iterations = timing.iterations,
|
|
3954
|
+
fill = timing.fill;
|
|
3955
|
+
return "@keyframes " + animationName + "{" + keyframes.map(function (keyframe) {
|
|
3956
|
+
var offset = keyframe.offset,
|
|
3957
|
+
composite = keyframe.composite,
|
|
3958
|
+
computedOffset = keyframe.computedOffset,
|
|
3959
|
+
easing = keyframe.easing,
|
|
3960
|
+
rest = _objectWithoutPropertiesLoose(keyframe, _excluded);
|
|
3961
|
+
var rules = Object.keys(rest).map(function (attributeName) {
|
|
3962
|
+
return attributeName + ":" + (prefixes[attributeName] || '') + rest[attributeName] + ";";
|
|
3963
|
+
}).join('');
|
|
3964
|
+
return computedOffset * 100 + "%{" + rules + "}";
|
|
3965
|
+
}).join('') + "}" + (selector + " {animation: " + animationName + " " + duration + "ms " + easing + " " + delay + "ms " + (iterations === Infinity ? 'infinite' : iterations) + " " + direction + " " + fill + ";}");
|
|
3966
|
+
};
|
|
3967
|
+
_proto.toDataURL = /*#__PURE__*/function () {
|
|
3968
|
+
var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
3969
|
+
var _this = this;
|
|
3970
|
+
var cloneNode, doc, animationCounter, $style, svgDocType, svgDoc;
|
|
3971
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
3972
|
+
while (1) {
|
|
3973
|
+
switch (_context2.prev = _context2.next) {
|
|
3974
|
+
case 0:
|
|
3975
|
+
cloneNode = this.$namespace.cloneNode(true);
|
|
3976
|
+
doc = this.canvasConfig.document;
|
|
3977
|
+
animationCounter = 0;
|
|
3978
|
+
$style = null;
|
|
3979
|
+
this.context.renderingContext.root.forEach(function (object) {
|
|
3980
|
+
var animations = object.getAnimations();
|
|
3981
|
+
if (animations.length) {
|
|
3982
|
+
if (!$style) {
|
|
3983
|
+
// export animations to <style>, using CSS Transformation
|
|
3984
|
+
$style = (doc || document).createElement('style');
|
|
3985
|
+
cloneNode.appendChild($style);
|
|
3986
|
+
}
|
|
3987
|
+
// @ts-ignore
|
|
3988
|
+
var svgElement = object.elementSVG;
|
|
3989
|
+
var selfSelector = "#" + svgElement.$el.id;
|
|
3990
|
+
var groupSelector = "#" + svgElement.$groupEl.id;
|
|
3991
|
+
var selfCssText = '';
|
|
3992
|
+
var groupCssText = '';
|
|
3993
|
+
animations.forEach(function (animation) {
|
|
3994
|
+
var keyframes = animation.effect.getKeyframes();
|
|
3995
|
+
// split attributes into self and group
|
|
3996
|
+
if (keyframes.length) {
|
|
3997
|
+
var selfAttributes = [];
|
|
3998
|
+
var groupAttributes = [];
|
|
3999
|
+
var _keyframes$ = keyframes[0],
|
|
4000
|
+
offset = _keyframes$.offset,
|
|
4001
|
+
composite = _keyframes$.composite,
|
|
4002
|
+
computedOffset = _keyframes$.computedOffset,
|
|
4003
|
+
easing = _keyframes$.easing,
|
|
4004
|
+
transformOrigin = _keyframes$.transformOrigin,
|
|
4005
|
+
rest = _objectWithoutPropertiesLoose(_keyframes$, _excluded2);
|
|
4006
|
+
Object.keys(rest).forEach(function (attributeName) {
|
|
4007
|
+
var _propertyMetadataCach;
|
|
4008
|
+
if (attributeName === 'transform') {
|
|
4009
|
+
groupAttributes.push(attributeName);
|
|
4010
|
+
}
|
|
4011
|
+
var inherited = !!((_propertyMetadataCach = gLite.propertyMetadataCache[attributeName]) === null || _propertyMetadataCach === void 0 ? void 0 : _propertyMetadataCach.inh);
|
|
4012
|
+
if (inherited) {
|
|
4013
|
+
groupAttributes.push(attributeName);
|
|
4014
|
+
} else if (attributeName !== 'transform') {
|
|
4015
|
+
selfAttributes.push(attributeName);
|
|
4016
|
+
}
|
|
4017
|
+
});
|
|
4018
|
+
if (groupAttributes.length) {
|
|
4019
|
+
var keyframesWithGroup = keyframes.map(function (keyframe) {
|
|
4020
|
+
var offset = keyframe.offset,
|
|
4021
|
+
composite = keyframe.composite,
|
|
4022
|
+
computedOffset = keyframe.computedOffset,
|
|
4023
|
+
easing = keyframe.easing,
|
|
4024
|
+
transformOrigin = keyframe.transformOrigin,
|
|
4025
|
+
rest = _objectWithoutPropertiesLoose(keyframe, _excluded3);
|
|
4026
|
+
var ret = {
|
|
4027
|
+
offset: offset,
|
|
4028
|
+
composite: composite,
|
|
4029
|
+
computedOffset: computedOffset,
|
|
4030
|
+
easing: easing
|
|
4031
|
+
};
|
|
4032
|
+
Object.keys(rest).forEach(function (attributeName) {
|
|
4033
|
+
if (groupAttributes.includes(attributeName)) {
|
|
4034
|
+
ret[attributeName] = keyframe[attributeName];
|
|
4035
|
+
}
|
|
4036
|
+
});
|
|
4037
|
+
return ret;
|
|
4038
|
+
});
|
|
4039
|
+
groupCssText += _this.generateCSSText("a" + animationCounter++, groupSelector, keyframesWithGroup, animation.effect.getComputedTiming(), {
|
|
4040
|
+
transform: svgElement.$groupEl.getAttribute('transform')
|
|
4041
|
+
});
|
|
4042
|
+
}
|
|
4043
|
+
if (selfAttributes.length) {
|
|
4044
|
+
var keyframesWithSelf = keyframes.map(function (keyframe) {
|
|
4045
|
+
var offset = keyframe.offset,
|
|
4046
|
+
composite = keyframe.composite,
|
|
4047
|
+
computedOffset = keyframe.computedOffset,
|
|
4048
|
+
easing = keyframe.easing,
|
|
4049
|
+
transformOrigin = keyframe.transformOrigin,
|
|
4050
|
+
rest = _objectWithoutPropertiesLoose(keyframe, _excluded4);
|
|
4051
|
+
var ret = {
|
|
4052
|
+
offset: offset,
|
|
4053
|
+
composite: composite,
|
|
4054
|
+
computedOffset: computedOffset,
|
|
4055
|
+
easing: easing
|
|
4056
|
+
};
|
|
4057
|
+
Object.keys(rest).forEach(function (attributeName) {
|
|
4058
|
+
if (selfAttributes.includes(attributeName)) {
|
|
4059
|
+
ret[attributeName] = keyframe[attributeName];
|
|
4060
|
+
}
|
|
4061
|
+
});
|
|
4062
|
+
return ret;
|
|
4063
|
+
});
|
|
4064
|
+
selfCssText += _this.generateCSSText("a" + animationCounter++, selfSelector, keyframesWithSelf, animation.effect.getComputedTiming());
|
|
4065
|
+
}
|
|
4066
|
+
}
|
|
4067
|
+
});
|
|
4068
|
+
$style.textContent += selfCssText + groupCssText;
|
|
4069
|
+
}
|
|
4070
|
+
});
|
|
4071
|
+
svgDocType = document.implementation.createDocumentType('svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
|
|
4072
|
+
svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', svgDocType);
|
|
4073
|
+
svgDoc.replaceChild(cloneNode, svgDoc.documentElement);
|
|
4074
|
+
return _context2.abrupt("return", "data:image/svg+xml;charset=utf8," + encodeURIComponent(new XMLSerializer().serializeToString(svgDoc)));
|
|
4075
|
+
case 10:
|
|
4076
|
+
case "end":
|
|
4077
|
+
return _context2.stop();
|
|
4516
4078
|
}
|
|
4517
|
-
}
|
|
4518
|
-
})
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
}
|
|
4079
|
+
}
|
|
4080
|
+
}, _callee2, this);
|
|
4081
|
+
}));
|
|
4082
|
+
function toDataURL(_x) {
|
|
4083
|
+
return _toDataURL.apply(this, arguments);
|
|
4084
|
+
}
|
|
4085
|
+
return toDataURL;
|
|
4086
|
+
}();
|
|
4525
4087
|
return SVGContextService;
|
|
4526
4088
|
}();
|
|
4527
4089
|
|
|
4528
4090
|
var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
4529
|
-
|
|
4530
|
-
var _super = _createSuper(ContextRegisterPlugin);
|
|
4091
|
+
_inheritsLoose(ContextRegisterPlugin, _AbstractRendererPlug);
|
|
4531
4092
|
function ContextRegisterPlugin() {
|
|
4532
4093
|
var _this;
|
|
4533
|
-
_classCallCheck(this, ContextRegisterPlugin);
|
|
4534
4094
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4535
4095
|
args[_key] = arguments[_key];
|
|
4536
4096
|
}
|
|
4537
|
-
_this =
|
|
4097
|
+
_this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
|
|
4538
4098
|
_this.name = 'svg-context-register';
|
|
4539
4099
|
return _this;
|
|
4540
4100
|
}
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
value: function destroy() {
|
|
4550
|
-
delete this.context.ContextService;
|
|
4551
|
-
}
|
|
4552
|
-
}]);
|
|
4101
|
+
var _proto = ContextRegisterPlugin.prototype;
|
|
4102
|
+
_proto.init = function init() {
|
|
4103
|
+
// @ts-ignore
|
|
4104
|
+
this.context.ContextService = SVGContextService;
|
|
4105
|
+
};
|
|
4106
|
+
_proto.destroy = function destroy() {
|
|
4107
|
+
delete this.context.ContextService;
|
|
4108
|
+
};
|
|
4553
4109
|
return ContextRegisterPlugin;
|
|
4554
4110
|
}(gLite.AbstractRendererPlugin);
|
|
4555
4111
|
|
|
4556
4112
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
function Renderer() {
|
|
4113
|
+
_inheritsLoose(Renderer, _AbstractRenderer);
|
|
4114
|
+
function Renderer(config) {
|
|
4560
4115
|
var _this;
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4116
|
+
if (config === void 0) {
|
|
4117
|
+
config = {};
|
|
4118
|
+
}
|
|
4119
|
+
_this = _AbstractRenderer.call(this, config) || this;
|
|
4564
4120
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
4565
4121
|
_this.registerPlugin(new Plugin$1({
|
|
4566
4122
|
outputSVGElementId: config.outputSVGElementId
|
|
@@ -4569,7 +4125,7 @@
|
|
|
4569
4125
|
_this.registerPlugin(new Plugin$2());
|
|
4570
4126
|
return _this;
|
|
4571
4127
|
}
|
|
4572
|
-
return
|
|
4128
|
+
return Renderer;
|
|
4573
4129
|
}(gLite.AbstractRenderer);
|
|
4574
4130
|
|
|
4575
4131
|
exports.DomInteraction = index_esm;
|