@antv/g-svg 1.8.29 → 1.8.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +106 -224
- package/dist/index.js +106 -224
- package/dist/index.umd.js +1062 -1643
- 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,59 +347,6 @@
|
|
|
395
347
|
};
|
|
396
348
|
return _setPrototypeOf(o, p);
|
|
397
349
|
}
|
|
398
|
-
function _isNativeReflectConstruct() {
|
|
399
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
400
|
-
if (Reflect.construct.sham) return false;
|
|
401
|
-
if (typeof Proxy === "function") return true;
|
|
402
|
-
try {
|
|
403
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
404
|
-
return true;
|
|
405
|
-
} catch (e) {
|
|
406
|
-
return false;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
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.");
|
|
444
|
-
}
|
|
445
|
-
return (hint === "string" ? String : Number)(input);
|
|
446
|
-
}
|
|
447
|
-
function _toPropertyKey(arg) {
|
|
448
|
-
var key = _toPrimitive(arg, "string");
|
|
449
|
-
return typeof key === "symbol" ? key : String(key);
|
|
450
|
-
}
|
|
451
350
|
|
|
452
351
|
function _regeneratorRuntime$1() {
|
|
453
352
|
_regeneratorRuntime$1 = function _regeneratorRuntime() {
|
|
@@ -525,7 +424,7 @@
|
|
|
525
424
|
if ("throw" !== record.type) {
|
|
526
425
|
var result = record.arg,
|
|
527
426
|
value = result.value;
|
|
528
|
-
return value && "object" ==
|
|
427
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
529
428
|
invoke("next", value, resolve, reject);
|
|
530
429
|
}, function (err) {
|
|
531
430
|
invoke("throw", err, resolve, reject);
|
|
@@ -786,49 +685,10 @@
|
|
|
786
685
|
});
|
|
787
686
|
};
|
|
788
687
|
}
|
|
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);
|
|
688
|
+
function _inheritsLoose$1(subClass, superClass) {
|
|
689
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
690
|
+
subClass.prototype.constructor = subClass;
|
|
691
|
+
_setPrototypeOf$1(subClass, superClass);
|
|
832
692
|
}
|
|
833
693
|
function _setPrototypeOf$1(o, p) {
|
|
834
694
|
_setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -837,59 +697,6 @@
|
|
|
837
697
|
};
|
|
838
698
|
return _setPrototypeOf$1(o, p);
|
|
839
699
|
}
|
|
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
700
|
|
|
894
701
|
// const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
|
895
702
|
/**
|
|
@@ -897,165 +704,156 @@
|
|
|
897
704
|
*/
|
|
898
705
|
var DOMInteractionPlugin = /*#__PURE__*/function () {
|
|
899
706
|
function DOMInteractionPlugin() {
|
|
900
|
-
_classCallCheck$1(this, DOMInteractionPlugin);
|
|
901
707
|
this.context = void 0;
|
|
902
708
|
}
|
|
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
|
-
}
|
|
709
|
+
var _proto = DOMInteractionPlugin.prototype;
|
|
710
|
+
_proto.apply = function apply(context) {
|
|
711
|
+
var _this = this;
|
|
712
|
+
var renderingService = context.renderingService,
|
|
713
|
+
renderingContext = context.renderingContext;
|
|
714
|
+
this.context = context;
|
|
715
|
+
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
716
|
+
// const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
|
|
717
|
+
var onPointerMove = function onPointerMove(ev) {
|
|
718
|
+
renderingService.hooks.pointerMove.call(ev);
|
|
719
|
+
};
|
|
720
|
+
var onPointerUp = function onPointerUp(ev) {
|
|
721
|
+
renderingService.hooks.pointerUp.call(ev);
|
|
722
|
+
};
|
|
723
|
+
var onPointerDown = function onPointerDown(ev) {
|
|
724
|
+
renderingService.hooks.pointerDown.call(ev);
|
|
725
|
+
};
|
|
726
|
+
var onPointerOver = function onPointerOver(ev) {
|
|
727
|
+
renderingService.hooks.pointerOver.call(ev);
|
|
728
|
+
};
|
|
729
|
+
var onPointerOut = function onPointerOut(ev) {
|
|
730
|
+
renderingService.hooks.pointerOut.call(ev);
|
|
731
|
+
};
|
|
732
|
+
var onPointerCancel = function onPointerCancel(ev) {
|
|
733
|
+
renderingService.hooks.pointerCancel.call(ev);
|
|
734
|
+
};
|
|
735
|
+
var onPointerWheel = function onPointerWheel(ev) {
|
|
736
|
+
renderingService.hooks.pointerWheel.call(ev);
|
|
737
|
+
};
|
|
738
|
+
var addPointerEventListener = function addPointerEventListener($el) {
|
|
739
|
+
globalThis.document.addEventListener('pointermove', onPointerMove, true);
|
|
740
|
+
$el.addEventListener('pointerdown', onPointerDown, true);
|
|
741
|
+
$el.addEventListener('pointerleave', onPointerOut, true);
|
|
742
|
+
$el.addEventListener('pointerover', onPointerOver, true);
|
|
743
|
+
globalThis.addEventListener('pointerup', onPointerUp, true);
|
|
744
|
+
};
|
|
745
|
+
var addTouchEventListener = function addTouchEventListener($el) {
|
|
746
|
+
$el.addEventListener('touchstart', onPointerDown, true);
|
|
747
|
+
$el.addEventListener('touchend', onPointerUp, true);
|
|
748
|
+
$el.addEventListener('touchmove', onPointerMove, true);
|
|
749
|
+
$el.addEventListener('touchcancel', onPointerCancel, true);
|
|
750
|
+
};
|
|
751
|
+
var addMouseEventListener = function addMouseEventListener($el) {
|
|
752
|
+
globalThis.document.addEventListener('mousemove', onPointerMove, true);
|
|
753
|
+
$el.addEventListener('mousedown', onPointerDown, true);
|
|
754
|
+
$el.addEventListener('mouseout', onPointerOut, true);
|
|
755
|
+
$el.addEventListener('mouseover', onPointerOver, true);
|
|
756
|
+
globalThis.addEventListener('mouseup', onPointerUp, true);
|
|
757
|
+
};
|
|
758
|
+
var removePointerEventListener = function removePointerEventListener($el) {
|
|
759
|
+
globalThis.document.removeEventListener('pointermove', onPointerMove, true);
|
|
760
|
+
$el.removeEventListener('pointerdown', onPointerDown, true);
|
|
761
|
+
$el.removeEventListener('pointerleave', onPointerOut, true);
|
|
762
|
+
$el.removeEventListener('pointerover', onPointerOver, true);
|
|
763
|
+
globalThis.removeEventListener('pointerup', onPointerUp, true);
|
|
764
|
+
};
|
|
765
|
+
var removeTouchEventListener = function removeTouchEventListener($el) {
|
|
766
|
+
$el.removeEventListener('touchstart', onPointerDown, true);
|
|
767
|
+
$el.removeEventListener('touchend', onPointerUp, true);
|
|
768
|
+
$el.removeEventListener('touchmove', onPointerMove, true);
|
|
769
|
+
$el.removeEventListener('touchcancel', onPointerCancel, true);
|
|
770
|
+
};
|
|
771
|
+
var removeMouseEventListener = function removeMouseEventListener($el) {
|
|
772
|
+
globalThis.document.removeEventListener('mousemove', onPointerMove, true);
|
|
773
|
+
$el.removeEventListener('mousedown', onPointerDown, true);
|
|
774
|
+
$el.removeEventListener('mouseout', onPointerOut, true);
|
|
775
|
+
$el.removeEventListener('mouseover', onPointerOver, true);
|
|
776
|
+
globalThis.removeEventListener('mouseup', onPointerUp, true);
|
|
777
|
+
};
|
|
778
|
+
renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
|
|
779
|
+
var $el;
|
|
780
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
781
|
+
while (1) {
|
|
782
|
+
switch (_context.prev = _context.next) {
|
|
783
|
+
case 0:
|
|
784
|
+
$el = _this.context.contextService.getDomElement(); // @ts-ignore
|
|
785
|
+
if (globalThis.navigator.msPointerEnabled) {
|
|
786
|
+
// @ts-ignore
|
|
787
|
+
$el.style.msContentZooming = 'none';
|
|
788
|
+
// @ts-ignore
|
|
789
|
+
$el.style.msTouchAction = 'none';
|
|
790
|
+
} else if (canvas.supportsPointerEvents) {
|
|
791
|
+
$el.style.touchAction = 'none';
|
|
792
|
+
}
|
|
793
|
+
if (canvas.supportsPointerEvents) {
|
|
794
|
+
addPointerEventListener($el);
|
|
795
|
+
} else {
|
|
796
|
+
addMouseEventListener($el);
|
|
797
|
+
}
|
|
798
|
+
if (canvas.supportsTouchEvents) {
|
|
799
|
+
addTouchEventListener($el);
|
|
800
|
+
}
|
|
801
|
+
// use passive event listeners
|
|
802
|
+
// @see https://zhuanlan.zhihu.com/p/24555031
|
|
803
|
+
$el.addEventListener('wheel', onPointerWheel, {
|
|
804
|
+
passive: true,
|
|
805
|
+
capture: true
|
|
806
|
+
});
|
|
807
|
+
case 5:
|
|
808
|
+
case "end":
|
|
809
|
+
return _context.stop();
|
|
1006
810
|
}
|
|
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
811
|
}
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
812
|
+
}, _callee);
|
|
813
|
+
})));
|
|
814
|
+
renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () {
|
|
815
|
+
var $el = _this.context.contextService.getDomElement();
|
|
816
|
+
// @ts-ignore
|
|
817
|
+
if (globalThis.navigator.msPointerEnabled) {
|
|
818
|
+
// @ts-ignore
|
|
819
|
+
$el.style.msContentZooming = '';
|
|
820
|
+
// @ts-ignore
|
|
821
|
+
$el.style.msTouchAction = '';
|
|
822
|
+
} else if (canvas.supportsPointerEvents) {
|
|
823
|
+
$el.style.touchAction = '';
|
|
824
|
+
}
|
|
825
|
+
if (canvas.supportsPointerEvents) {
|
|
826
|
+
removePointerEventListener($el);
|
|
827
|
+
} else {
|
|
828
|
+
removeMouseEventListener($el);
|
|
829
|
+
}
|
|
830
|
+
if (canvas.supportsTouchEvents) {
|
|
831
|
+
removeTouchEventListener($el);
|
|
832
|
+
}
|
|
833
|
+
$el.removeEventListener('wheel', onPointerWheel, true);
|
|
834
|
+
});
|
|
835
|
+
};
|
|
1032
836
|
return DOMInteractionPlugin;
|
|
1033
837
|
}();
|
|
1034
838
|
DOMInteractionPlugin.tag = 'DOMInteraction';
|
|
1035
839
|
var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
1036
|
-
|
|
1037
|
-
var _super = _createSuper$1(Plugin);
|
|
840
|
+
_inheritsLoose$1(Plugin, _AbstractRendererPlug);
|
|
1038
841
|
function Plugin() {
|
|
1039
842
|
var _this;
|
|
1040
|
-
_classCallCheck$1(this, Plugin);
|
|
1041
843
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1042
844
|
args[_key] = arguments[_key];
|
|
1043
845
|
}
|
|
1044
|
-
_this =
|
|
846
|
+
_this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
|
|
1045
847
|
_this.name = 'dom-interaction';
|
|
1046
848
|
return _this;
|
|
1047
849
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
value: function destroy() {
|
|
1056
|
-
this.removeAllRenderingPlugins();
|
|
1057
|
-
}
|
|
1058
|
-
}]);
|
|
850
|
+
var _proto = Plugin.prototype;
|
|
851
|
+
_proto.init = function init() {
|
|
852
|
+
this.addRenderingPlugin(new DOMInteractionPlugin());
|
|
853
|
+
};
|
|
854
|
+
_proto.destroy = function destroy() {
|
|
855
|
+
this.removeAllRenderingPlugins();
|
|
856
|
+
};
|
|
1059
857
|
return Plugin;
|
|
1060
858
|
}(gLite.AbstractRendererPlugin);
|
|
1061
859
|
|
|
@@ -1411,56 +1209,6 @@
|
|
|
1411
1209
|
return output;
|
|
1412
1210
|
}
|
|
1413
1211
|
|
|
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
1212
|
function _regeneratorRuntime$2() {
|
|
1465
1213
|
_regeneratorRuntime$2 = function _regeneratorRuntime() {
|
|
1466
1214
|
return exports;
|
|
@@ -1537,7 +1285,7 @@
|
|
|
1537
1285
|
if ("throw" !== record.type) {
|
|
1538
1286
|
var result = record.arg,
|
|
1539
1287
|
value = result.value;
|
|
1540
|
-
return value && "object" ==
|
|
1288
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
1541
1289
|
invoke("next", value, resolve, reject);
|
|
1542
1290
|
}, function (err) {
|
|
1543
1291
|
invoke("throw", err, resolve, reject);
|
|
@@ -1798,63 +1546,24 @@
|
|
|
1798
1546
|
});
|
|
1799
1547
|
};
|
|
1800
1548
|
}
|
|
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
|
|
1549
|
+
function _extends() {
|
|
1550
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
1551
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1552
|
+
var source = arguments[i];
|
|
1553
|
+
for (var key in source) {
|
|
1554
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1555
|
+
target[key] = source[key];
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1846
1558
|
}
|
|
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);
|
|
1559
|
+
return target;
|
|
1856
1560
|
};
|
|
1857
|
-
return
|
|
1561
|
+
return _extends.apply(this, arguments);
|
|
1562
|
+
}
|
|
1563
|
+
function _inheritsLoose$2(subClass, superClass) {
|
|
1564
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
1565
|
+
subClass.prototype.constructor = subClass;
|
|
1566
|
+
_setPrototypeOf$2(subClass, superClass);
|
|
1858
1567
|
}
|
|
1859
1568
|
function _setPrototypeOf$2(o, p) {
|
|
1860
1569
|
_setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -1863,89 +1572,11 @@
|
|
|
1863
1572
|
};
|
|
1864
1573
|
return _setPrototypeOf$2(o, p);
|
|
1865
1574
|
}
|
|
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);
|
|
1575
|
+
var ElementSVG = function ElementSVG() {
|
|
1945
1576
|
this.$el = void 0;
|
|
1946
1577
|
this.$groupEl = void 0;
|
|
1947
1578
|
this.$hitTestingEl = void 0;
|
|
1948
|
-
}
|
|
1579
|
+
};
|
|
1949
1580
|
ElementSVG.tag = 'c-svg-element';
|
|
1950
1581
|
function updateImageElementAttribute($el, parsedStyle) {
|
|
1951
1582
|
var _parsedStyle$img = parsedStyle.img,
|
|
@@ -1958,13 +1589,13 @@
|
|
|
1958
1589
|
$el.setAttribute('href', img);
|
|
1959
1590
|
} else if (img instanceof Image) {
|
|
1960
1591
|
if (!width) {
|
|
1961
|
-
$el.setAttribute('width', ""
|
|
1592
|
+
$el.setAttribute('width', "" + img.width);
|
|
1962
1593
|
// TODO: set renderable.boundsDirty
|
|
1963
1594
|
// this.attr('width', img.width);
|
|
1964
1595
|
}
|
|
1965
1596
|
|
|
1966
1597
|
if (!height) {
|
|
1967
|
-
$el.setAttribute('height', ""
|
|
1598
|
+
$el.setAttribute('height', "" + img.height);
|
|
1968
1599
|
// this.attr('height', img.height);
|
|
1969
1600
|
}
|
|
1970
1601
|
|
|
@@ -1977,21 +1608,21 @@
|
|
|
1977
1608
|
} else if (img instanceof ImageData) {
|
|
1978
1609
|
var canvas = document.createElement('canvas');
|
|
1979
1610
|
// @ts-ignore
|
|
1980
|
-
canvas.setAttribute('width', ""
|
|
1611
|
+
canvas.setAttribute('width', "" + img.width);
|
|
1981
1612
|
// @ts-ignore
|
|
1982
|
-
canvas.setAttribute('height', ""
|
|
1613
|
+
canvas.setAttribute('height', "" + img.height);
|
|
1983
1614
|
var context = canvas.getContext('2d');
|
|
1984
1615
|
if (context) {
|
|
1985
1616
|
context.putImageData(img, 0, 0);
|
|
1986
1617
|
if (!width) {
|
|
1987
1618
|
// @ts-ignore
|
|
1988
|
-
$el.setAttribute('width', ""
|
|
1619
|
+
$el.setAttribute('width', "" + img.width);
|
|
1989
1620
|
// this.attr('width', img.width);
|
|
1990
1621
|
}
|
|
1991
1622
|
|
|
1992
1623
|
if (!height) {
|
|
1993
1624
|
// @ts-ignore
|
|
1994
|
-
$el.setAttribute('height', ""
|
|
1625
|
+
$el.setAttribute('height', "" + img.height);
|
|
1995
1626
|
// this.attr('height', img.height);
|
|
1996
1627
|
}
|
|
1997
1628
|
|
|
@@ -2034,10 +1665,10 @@
|
|
|
2034
1665
|
endOffsetY = Math.sin(rad) * (markerEndOffset || 0);
|
|
2035
1666
|
}
|
|
2036
1667
|
// @see https://github.com/antvis/g/issues/1038
|
|
2037
|
-
$el.setAttribute('x1', ""
|
|
2038
|
-
$el.setAttribute('y1', ""
|
|
2039
|
-
$el.setAttribute('x2', ""
|
|
2040
|
-
$el.setAttribute('y2', ""
|
|
1668
|
+
$el.setAttribute('x1', "" + (x1 - defX + startOffsetX));
|
|
1669
|
+
$el.setAttribute('y1', "" + (y1 - defY + startOffsetY));
|
|
1670
|
+
$el.setAttribute('x2', "" + (x2 - defX + endOffsetX));
|
|
1671
|
+
$el.setAttribute('y2', "" + (y2 - defY + endOffsetY));
|
|
2041
1672
|
}
|
|
2042
1673
|
function updatePathElementAttribute($el, parsedStyle) {
|
|
2043
1674
|
var path = parsedStyle.path,
|
|
@@ -2058,9 +1689,8 @@
|
|
|
2058
1689
|
var y;
|
|
2059
1690
|
if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
|
|
2060
1691
|
var _markerStart$parentNo = markerStart.parentNode.getStartTangent(),
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
p2 = _markerStart$parentNo2[1];
|
|
1692
|
+
p1 = _markerStart$parentNo[0],
|
|
1693
|
+
p2 = _markerStart$parentNo[1];
|
|
2064
1694
|
x = p1[0] - p2[0];
|
|
2065
1695
|
y = p1[1] - p2[1];
|
|
2066
1696
|
rad = Math.atan2(y, x);
|
|
@@ -2069,9 +1699,8 @@
|
|
|
2069
1699
|
}
|
|
2070
1700
|
if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
|
|
2071
1701
|
var _markerEnd$parentNode = markerEnd.parentNode.getEndTangent(),
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
_p2 = _markerEnd$parentNode2[1];
|
|
1702
|
+
_p = _markerEnd$parentNode[0],
|
|
1703
|
+
_p2 = _markerEnd$parentNode[1];
|
|
2075
1704
|
x = _p[0] - _p2[0];
|
|
2076
1705
|
y = _p[1] - _p2[1];
|
|
2077
1706
|
rad = Math.atan2(y, x);
|
|
@@ -2123,7 +1752,7 @@
|
|
|
2123
1752
|
offsetX = endOffsetX;
|
|
2124
1753
|
offsetY = endOffsetY;
|
|
2125
1754
|
}
|
|
2126
|
-
return
|
|
1755
|
+
return point[0] - defX + offsetX + "," + (point[1] - defY + offsetY);
|
|
2127
1756
|
}).join(' '));
|
|
2128
1757
|
}
|
|
2129
1758
|
}
|
|
@@ -2140,21 +1769,20 @@
|
|
|
2140
1769
|
});
|
|
2141
1770
|
var d = '';
|
|
2142
1771
|
if (!hasRadius) {
|
|
2143
|
-
d = "M 0,0 l "
|
|
1772
|
+
d = "M 0,0 l " + width + ",0 l 0," + height + " l" + -width + " 0 z";
|
|
2144
1773
|
} else {
|
|
2145
1774
|
var _radius$map = radius.map(function (r) {
|
|
2146
1775
|
return clamp(r, 0, Math.min(Math.abs(width) / 2, Math.abs(height) / 2));
|
|
2147
1776
|
}),
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
blr = _radius$map2[3];
|
|
1777
|
+
tlr = _radius$map[0],
|
|
1778
|
+
trr = _radius$map[1],
|
|
1779
|
+
brr = _radius$map[2],
|
|
1780
|
+
blr = _radius$map[3];
|
|
2153
1781
|
var signX = width > 0 ? 1 : -1;
|
|
2154
1782
|
var signY = height > 0 ? 1 : -1;
|
|
2155
1783
|
// sweep-flag @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Tutorial/Paths#arcs
|
|
2156
1784
|
var sweepFlag = signX + signY !== 0 ? 1 : 0;
|
|
2157
|
-
d = [["M "
|
|
1785
|
+
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
1786
|
}
|
|
2159
1787
|
$el.setAttribute('d', d);
|
|
2160
1788
|
}
|
|
@@ -2266,7 +1894,6 @@
|
|
|
2266
1894
|
var TEXT_PATH_PREFIX = 'text-path-';
|
|
2267
1895
|
var SVGRendererPlugin = /*#__PURE__*/function () {
|
|
2268
1896
|
function SVGRendererPlugin(pluginOptions, defElementManager, context) {
|
|
2269
|
-
_classCallCheck$2(this, SVGRendererPlugin);
|
|
2270
1897
|
this.pluginOptions = void 0;
|
|
2271
1898
|
this.defElementManager = void 0;
|
|
2272
1899
|
this.context = void 0;
|
|
@@ -2282,526 +1909,516 @@
|
|
|
2282
1909
|
/**
|
|
2283
1910
|
* <camera>
|
|
2284
1911
|
*/
|
|
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;
|
|
1912
|
+
var _proto = SVGRendererPlugin.prototype;
|
|
1913
|
+
_proto.apply = function apply(context) {
|
|
1914
|
+
var _this = this;
|
|
1915
|
+
var renderingService = context.renderingService,
|
|
1916
|
+
renderingContext = context.renderingContext;
|
|
1917
|
+
this.context = context;
|
|
1918
|
+
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
1919
|
+
var document = this.context.config.document;
|
|
1920
|
+
var handleMounted = function handleMounted(e) {
|
|
1921
|
+
var object = e.target;
|
|
1922
|
+
// should remove clipPath already existed in <defs>
|
|
1923
|
+
var $useRefs = _this.clipPathUseMap.get(object);
|
|
1924
|
+
if ($useRefs) {
|
|
1925
|
+
var $def = _this.defElementManager.getDefElement();
|
|
1926
|
+
var existed = $def.querySelector("#" + _this.getId(object));
|
|
1927
|
+
if (existed) {
|
|
1928
|
+
existed.remove();
|
|
2311
1929
|
}
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
1930
|
+
}
|
|
1931
|
+
// create SVG DOM Node
|
|
1932
|
+
_this.createSVGDom(document, object, _this.$camera);
|
|
1933
|
+
};
|
|
1934
|
+
var handleUnmounted = function handleUnmounted(e) {
|
|
1935
|
+
var object = e.target;
|
|
1936
|
+
_this.defElementManager.clear(object.entity);
|
|
1937
|
+
_this.clipPathUseMap.delete(object);
|
|
1938
|
+
_this.removeSVGDom(object);
|
|
1939
|
+
};
|
|
1940
|
+
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
1941
|
+
var object = e.target;
|
|
1942
|
+
// @see https://github.com/antvis/g/issues/994
|
|
1943
|
+
// @ts-ignore
|
|
1944
|
+
if (!object.elementSVG) {
|
|
1945
|
+
return;
|
|
1946
|
+
}
|
|
1947
|
+
var attrName = e.attrName;
|
|
1948
|
+
var attribtues = _this.dirtyAttributes.get(object);
|
|
1949
|
+
if (!attribtues) {
|
|
1950
|
+
_this.dirtyAttributes.set(object, []);
|
|
1951
|
+
attribtues = _this.dirtyAttributes.get(object);
|
|
1952
|
+
}
|
|
1953
|
+
attribtues.push(attrName);
|
|
1954
|
+
};
|
|
1955
|
+
var handleGeometryBoundsChanged = function handleGeometryBoundsChanged(e) {
|
|
1956
|
+
var _object$elementSVG;
|
|
1957
|
+
var object = e.target;
|
|
1958
|
+
// @ts-ignore
|
|
1959
|
+
var $el = (_object$elementSVG = object.elementSVG) === null || _object$elementSVG === void 0 ? void 0 : _object$elementSVG.$el;
|
|
1960
|
+
var _object$parsedStyle = object.parsedStyle,
|
|
1961
|
+
fill = _object$parsedStyle.fill,
|
|
1962
|
+
stroke = _object$parsedStyle.stroke;
|
|
1963
|
+
if (fill && !(fill instanceof gLite.CSSRGB)) {
|
|
1964
|
+
_this.defElementManager.createOrUpdateGradientAndPattern(object, $el, fill, 'fill', _this);
|
|
1965
|
+
}
|
|
1966
|
+
if (stroke && !(stroke instanceof gLite.CSSRGB)) {
|
|
1967
|
+
_this.defElementManager.createOrUpdateGradientAndPattern(object, $el, stroke, 'stroke', _this);
|
|
1968
|
+
}
|
|
1969
|
+
};
|
|
1970
|
+
renderingService.hooks.init.tapPromise(SVGRendererPlugin.tag, /*#__PURE__*/_asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee() {
|
|
1971
|
+
var _this$context$config, background, document, $svg;
|
|
1972
|
+
return _regeneratorRuntime$2().wrap(function _callee$(_context) {
|
|
1973
|
+
while (1) {
|
|
1974
|
+
switch (_context.prev = _context.next) {
|
|
1975
|
+
case 0:
|
|
1976
|
+
_this$context$config = _this.context.config, background = _this$context$config.background, document = _this$context$config.document; // <defs>
|
|
1977
|
+
_this.defElementManager.init();
|
|
1978
|
+
$svg = _this.context.contextService.getContext();
|
|
1979
|
+
if (background) {
|
|
1980
|
+
$svg.style.background = background;
|
|
1981
|
+
}
|
|
1982
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
|
|
1983
|
+
$svg.setAttribute('color-interpolation-filters', 'sRGB');
|
|
1984
|
+
_this.$camera = createSVGElement('g', document);
|
|
1985
|
+
_this.$camera.id = G_SVG_PREFIX + "-camera";
|
|
1986
|
+
_this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
|
|
1987
|
+
$svg.appendChild(_this.$camera);
|
|
1988
|
+
canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
1989
|
+
canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
1990
|
+
canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
1991
|
+
canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
|
|
1992
|
+
case 13:
|
|
1993
|
+
case "end":
|
|
1994
|
+
return _context.stop();
|
|
1995
|
+
}
|
|
2317
1996
|
}
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
1997
|
+
}, _callee);
|
|
1998
|
+
})));
|
|
1999
|
+
renderingService.hooks.destroy.tap(SVGRendererPlugin.tag, function () {
|
|
2000
|
+
canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
|
|
2001
|
+
canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
2002
|
+
canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
2003
|
+
canvas.removeEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
|
|
2004
|
+
});
|
|
2005
|
+
renderingService.hooks.render.tap(SVGRendererPlugin.tag, function (object) {
|
|
2006
|
+
// if (!object.isCulled()) {
|
|
2007
|
+
_this.renderQueue.push(object);
|
|
2008
|
+
// }
|
|
2009
|
+
});
|
|
2010
|
+
|
|
2011
|
+
renderingService.hooks.beginFrame.tap(SVGRendererPlugin.tag, function () {
|
|
2012
|
+
var doc = _this.context.config.document;
|
|
2013
|
+
if (_this.pendingReorderQueue.size) {
|
|
2014
|
+
_this.pendingReorderQueue.forEach(function (object) {
|
|
2015
|
+
var _object$elementSVG2;
|
|
2016
|
+
var children = ((object === null || object === void 0 ? void 0 : object.children) || []).slice();
|
|
2017
|
+
var $parentGroupEl =
|
|
2018
|
+
// @ts-ignore
|
|
2019
|
+
object === null || object === void 0 ? void 0 : (_object$elementSVG2 = object.elementSVG) === null || _object$elementSVG2 === void 0 ? void 0 : _object$elementSVG2.$groupEl;
|
|
2020
|
+
if ($parentGroupEl) {
|
|
2021
|
+
_this.reorderChildren(doc || document, $parentGroupEl, children || []);
|
|
2022
|
+
}
|
|
2023
|
+
});
|
|
2024
|
+
_this.pendingReorderQueue.clear();
|
|
2025
|
+
}
|
|
2026
|
+
});
|
|
2027
|
+
renderingService.hooks.endFrame.tap(SVGRendererPlugin.tag, function () {
|
|
2028
|
+
if (renderingContext.renderReasons.has(gLite.RenderReason.CAMERA_CHANGED)) {
|
|
2029
|
+
_this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
|
|
2030
|
+
}
|
|
2031
|
+
_this.renderQueue.forEach(function (object) {
|
|
2032
|
+
var _object$elementSVG3, _object$elementSVG4;
|
|
2323
2033
|
// @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
|
-
}
|
|
2034
|
+
var $el = (_object$elementSVG3 = object.elementSVG) === null || _object$elementSVG3 === void 0 ? void 0 : _object$elementSVG3.$el;
|
|
2035
|
+
// @ts-ignore
|
|
2036
|
+
var $groupEl = (_object$elementSVG4 = object.elementSVG) === null || _object$elementSVG4 === void 0 ? void 0 : _object$elementSVG4.$groupEl;
|
|
2037
|
+
if ($el && $groupEl) {
|
|
2038
|
+
// apply local RTS transformation to <group> wrapper
|
|
2039
|
+
// account for anchor
|
|
2040
|
+
var localTransform = object.getLocalTransform();
|
|
2041
|
+
_this.applyTransform($groupEl, localTransform);
|
|
2042
|
+
// clipped shapes should also be informed
|
|
2043
|
+
var $useRefs = _this.clipPathUseMap.get(object);
|
|
2044
|
+
if ($useRefs && $useRefs.length) {
|
|
2045
|
+
$useRefs.forEach(function ($use) {
|
|
2046
|
+
// <clipPath transform="matrix()"><circle /></clipPath>
|
|
2047
|
+
_this.applyTransform($use, object.getWorldTransform());
|
|
2048
|
+
// const parentInvert = mat4.invert(
|
|
2049
|
+
// mat4.create(),
|
|
2050
|
+
// (object as DisplayObject).getWorldTransform(),
|
|
2051
|
+
// );
|
|
2052
|
+
// this.applyTransform($clipPath, parentInvert);
|
|
2053
|
+
});
|
|
2361
2054
|
}
|
|
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 || []);
|
|
2055
|
+
// finish rendering, clear dirty flag
|
|
2056
|
+
object.renderable.dirty = false;
|
|
2057
|
+
}
|
|
2058
|
+
// update dirty attributes
|
|
2059
|
+
var attributes = _this.dirtyAttributes.get(object);
|
|
2060
|
+
if (attributes) {
|
|
2061
|
+
attributes.forEach(function (attrName) {
|
|
2062
|
+
if (attrName === 'zIndex') {
|
|
2063
|
+
var _object$parentNode, _object$parentNode$el;
|
|
2064
|
+
var parent = object.parentNode;
|
|
2065
|
+
// @ts-ignore
|
|
2066
|
+
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;
|
|
2067
|
+
var children = ((parent === null || parent === void 0 ? void 0 : parent.children) || []).slice();
|
|
2068
|
+
if (_$groupEl) {
|
|
2069
|
+
_this.reorderChildren(document, _$groupEl, children);
|
|
2070
|
+
}
|
|
2071
|
+
} else if (attrName === 'increasedLineWidthForHitTesting') {
|
|
2072
|
+
_this.createOrUpdateHitArea(object, $el, $groupEl);
|
|
2387
2073
|
}
|
|
2074
|
+
_this.updateAttribute(object, [attrName]);
|
|
2388
2075
|
});
|
|
2389
|
-
_this.
|
|
2076
|
+
_this.dirtyAttributes.delete(object);
|
|
2390
2077
|
}
|
|
2391
2078
|
});
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2079
|
+
_this.renderQueue = [];
|
|
2080
|
+
});
|
|
2081
|
+
};
|
|
2082
|
+
_proto.getId = function getId(object) {
|
|
2083
|
+
return G_SVG_PREFIX + "-" + object.nodeName + "-" + object.entity;
|
|
2084
|
+
};
|
|
2085
|
+
_proto.reorderChildren = function reorderChildren(doc, $groupEl, children) {
|
|
2086
|
+
// need to reorder parent's children
|
|
2087
|
+
children.sort(function (a, b) {
|
|
2088
|
+
return a.sortable.renderOrder - b.sortable.renderOrder;
|
|
2089
|
+
});
|
|
2090
|
+
if (children.length) {
|
|
2091
|
+
// create empty fragment
|
|
2092
|
+
var fragment = (doc || document).createDocumentFragment();
|
|
2093
|
+
children.forEach(function (child) {
|
|
2094
|
+
if (child.isConnected) {
|
|
2400
2095
|
// @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);
|
|
2096
|
+
var $el = child.elementSVG.$groupEl;
|
|
2097
|
+
if ($el) {
|
|
2098
|
+
fragment.appendChild($el);
|
|
2442
2099
|
}
|
|
2443
|
-
}
|
|
2444
|
-
_this.renderQueue = [];
|
|
2100
|
+
}
|
|
2445
2101
|
});
|
|
2102
|
+
$groupEl.appendChild(fragment);
|
|
2446
2103
|
}
|
|
2447
|
-
}
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
}
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
// @ts-ignore
|
|
2465
|
-
var $el = child.elementSVG.$groupEl;
|
|
2466
|
-
if ($el) {
|
|
2467
|
-
fragment.appendChild($el);
|
|
2468
|
-
}
|
|
2469
|
-
}
|
|
2470
|
-
});
|
|
2471
|
-
$groupEl.appendChild(fragment);
|
|
2104
|
+
};
|
|
2105
|
+
_proto.applyTransform = function applyTransform($el, rts) {
|
|
2106
|
+
// use proper precision avoiding too long string in `transform`
|
|
2107
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
2108
|
+
$el.setAttribute('transform', "matrix(" + numberToLongString(rts[0]) + "," + numberToLongString(rts[1]) + "," + numberToLongString(rts[4]) + "," + numberToLongString(rts[5]) + "," + numberToLongString(rts[12]) + "," + numberToLongString(rts[13]) + ")");
|
|
2109
|
+
};
|
|
2110
|
+
_proto.applyAttributes = function applyAttributes(object) {
|
|
2111
|
+
// @ts-ignore
|
|
2112
|
+
var elementSVG = object.elementSVG;
|
|
2113
|
+
var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
|
|
2114
|
+
var $groupEl = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$groupEl;
|
|
2115
|
+
if ($el && $groupEl) {
|
|
2116
|
+
var nodeName = object.nodeName,
|
|
2117
|
+
attributes = object.attributes;
|
|
2118
|
+
$el.setAttribute('fill', 'none');
|
|
2119
|
+
if (nodeName === gLite.Shape.IMAGE) {
|
|
2120
|
+
$el.setAttribute('preserveAspectRatio', 'none');
|
|
2472
2121
|
}
|
|
2122
|
+
// apply attributes
|
|
2123
|
+
this.updateAttribute(object, Object.keys(attributes));
|
|
2473
2124
|
}
|
|
2474
|
-
}
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
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 (
|
|
2125
|
+
};
|
|
2126
|
+
_proto.updateAttribute = function updateAttribute(object, attributes) {
|
|
2127
|
+
var _this2 = this;
|
|
2128
|
+
var document = this.context.config.document;
|
|
2129
|
+
// @ts-ignore
|
|
2130
|
+
var _object$elementSVG5 = object.elementSVG,
|
|
2131
|
+
$el = _object$elementSVG5.$el,
|
|
2132
|
+
$groupEl = _object$elementSVG5.$groupEl,
|
|
2133
|
+
$hitTestingEl = _object$elementSVG5.$hitTestingEl;
|
|
2134
|
+
var parsedStyle = object.parsedStyle,
|
|
2135
|
+
computedStyle = object.computedStyle;
|
|
2136
|
+
var shouldUpdateElementAttribute = attributes.some(function (name) {
|
|
2137
|
+
return (
|
|
2138
|
+
// @ts-ignore
|
|
2139
|
+
_this2.context.SVGElementLifeCycleContribution.shouldUpdateElementAttribute(object, name)
|
|
2140
|
+
);
|
|
2141
|
+
});
|
|
2142
|
+
// need re-generate path
|
|
2143
|
+
if (shouldUpdateElementAttribute && $el) {
|
|
2144
|
+
[$el, $hitTestingEl].forEach(function ($el) {
|
|
2145
|
+
if ($el) {
|
|
2513
2146
|
// @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
|
|
2147
|
+
_this2.context.SVGElementLifeCycleContribution.updateElementAttribute(object, $el);
|
|
2582
2148
|
if (object.nodeName !== gLite.Shape.TEXT) {
|
|
2583
2149
|
_this2.updateAnchorWithTransform(object);
|
|
2584
2150
|
}
|
|
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
2151
|
}
|
|
2600
2152
|
});
|
|
2601
2153
|
}
|
|
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;
|
|
2154
|
+
// update common attributes
|
|
2155
|
+
attributes.forEach(function (name) {
|
|
2156
|
+
var _FORMAT_VALUE_MAP$nam, _propertyMetadataCach;
|
|
2157
|
+
var usedName = SVG_ATTR_MAP[name];
|
|
2158
|
+
var computedValue = computedStyle[name];
|
|
2159
|
+
var computedValueStr = computedValue && computedValue.toString();
|
|
2160
|
+
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;
|
|
2161
|
+
var usedValue = parsedStyle[name];
|
|
2162
|
+
var inherited = !!((_propertyMetadataCach = gLite.propertyMetadataCache[name]) === null || _propertyMetadataCach === void 0 ? void 0 : _propertyMetadataCach.inh);
|
|
2163
|
+
if (!usedName) {
|
|
2164
|
+
return;
|
|
2165
|
+
}
|
|
2166
|
+
// <foreignObject>
|
|
2167
|
+
if (object.nodeName === gLite.Shape.HTML) {
|
|
2168
|
+
if (name === 'lineWidth') {
|
|
2169
|
+
$el.style['border-width'] = (usedValue || 0) + "px";
|
|
2170
|
+
} else if (name === 'lineDash') {
|
|
2171
|
+
$el.style['border-style'] = 'dashed';
|
|
2621
2172
|
}
|
|
2622
|
-
|
|
2623
|
-
|
|
2173
|
+
}
|
|
2174
|
+
if (name === 'fill') {
|
|
2175
|
+
if (object.nodeName === gLite.Shape.HTML) {
|
|
2176
|
+
$el.style.background = usedValue.toString();
|
|
2177
|
+
} else {
|
|
2178
|
+
_this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName, _this2);
|
|
2624
2179
|
}
|
|
2625
|
-
|
|
2626
|
-
|
|
2180
|
+
} else if (name === 'stroke') {
|
|
2181
|
+
if (object.nodeName === gLite.Shape.HTML) {
|
|
2182
|
+
$el.style['border-color'] = usedValue.toString();
|
|
2183
|
+
$el.style['border-style'] = 'solid';
|
|
2184
|
+
} else {
|
|
2185
|
+
_this2.defElementManager.createOrUpdateGradientAndPattern(object, $el, usedValue, usedName, _this2);
|
|
2627
2186
|
}
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2187
|
+
} else if (inherited && usedName) {
|
|
2188
|
+
// use computed value
|
|
2189
|
+
// update `visibility` on <group>
|
|
2190
|
+
if (computedValueStr !== 'unset' && computedValueStr !== DEFAULT_VALUE_MAP[name]) {
|
|
2191
|
+
$groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, formattedValueStr);
|
|
2631
2192
|
} else {
|
|
2632
|
-
$groupEl
|
|
2193
|
+
$groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.removeAttribute(usedName);
|
|
2633
2194
|
}
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2195
|
+
} else if (name === 'clipPath') {
|
|
2196
|
+
_this2.createOrUpdateClipOrTextPath(document, usedValue, object);
|
|
2197
|
+
} else if (name === 'textPath') {
|
|
2198
|
+
_this2.createOrUpdateClipOrTextPath(document, usedValue, object, true);
|
|
2199
|
+
} else if (name === 'shadowType' || name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
|
|
2200
|
+
_this2.defElementManager.createOrUpdateShadow(object, $el, name);
|
|
2201
|
+
} else if (name === 'filter') {
|
|
2202
|
+
_this2.defElementManager.createOrUpdateFilter(object, $el, usedValue);
|
|
2203
|
+
} else if (name === 'innerHTML') {
|
|
2204
|
+
_this2.createOrUpdateInnerHTML(document, $el, usedValue);
|
|
2205
|
+
} else if (name === 'anchor') {
|
|
2206
|
+
// text' anchor is controlled by `textAnchor` property
|
|
2207
|
+
if (object.nodeName !== gLite.Shape.TEXT) {
|
|
2208
|
+
_this2.updateAnchorWithTransform(object);
|
|
2209
|
+
}
|
|
2210
|
+
} else {
|
|
2211
|
+
if (computedValue) {
|
|
2212
|
+
// use computed value so that we can use cascaded effect in SVG
|
|
2213
|
+
// ignore 'unset' and default value
|
|
2214
|
+
[$el, $hitTestingEl].forEach(function ($el) {
|
|
2215
|
+
if ($el && usedName) {
|
|
2216
|
+
if (computedValueStr !== 'unset' && computedValueStr !== DEFAULT_VALUE_MAP[name]) {
|
|
2217
|
+
$el.setAttribute(usedName, formattedValueStr);
|
|
2218
|
+
} else {
|
|
2219
|
+
$el.removeAttribute(usedName);
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
});
|
|
2647
2223
|
}
|
|
2648
2224
|
}
|
|
2225
|
+
});
|
|
2226
|
+
};
|
|
2227
|
+
_proto.createSVGDom = function createSVGDom(document, object, root, noWrapWithGroup) {
|
|
2228
|
+
if (noWrapWithGroup === void 0) {
|
|
2229
|
+
noWrapWithGroup = false;
|
|
2649
2230
|
}
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2231
|
+
// create svg element
|
|
2232
|
+
// @ts-ignore
|
|
2233
|
+
object.elementSVG = new ElementSVG();
|
|
2234
|
+
// @ts-ignore
|
|
2235
|
+
var svgElement = object.elementSVG;
|
|
2236
|
+
// use <group> as default, eg. CustomElement
|
|
2237
|
+
var $el =
|
|
2238
|
+
// @ts-ignore
|
|
2239
|
+
this.context.SVGElementLifeCycleContribution.createElement(object);
|
|
2240
|
+
if ($el) {
|
|
2241
|
+
var _object$parentNode$el2;
|
|
2242
|
+
var $groupEl;
|
|
2243
|
+
// save $el on parsedStyle, which will be returned in getDomElement()
|
|
2244
|
+
if (object.nodeName === gLite.Shape.HTML) {
|
|
2245
|
+
object.parsedStyle.$el = $el;
|
|
2246
|
+
}
|
|
2247
|
+
if (this.pluginOptions.outputSVGElementId) {
|
|
2248
|
+
$el.id = this.getId(object);
|
|
2249
|
+
}
|
|
2250
|
+
if (this.pluginOptions.outputSVGElementName && object.name) {
|
|
2251
|
+
$el.setAttribute('name', object.name);
|
|
2252
|
+
}
|
|
2253
|
+
if (($el.hasAttribute('data-wrapgroup') || $el.nodeName !== 'g') && !noWrapWithGroup) {
|
|
2254
|
+
$groupEl = createSVGElement('g', document);
|
|
2255
|
+
$groupEl.appendChild($el);
|
|
2256
|
+
} else {
|
|
2257
|
+
$groupEl = $el;
|
|
2258
|
+
}
|
|
2259
|
+
svgElement.$el = $el;
|
|
2260
|
+
svgElement.$groupEl = $groupEl;
|
|
2261
|
+
// apply attributes at first time
|
|
2262
|
+
this.applyAttributes(object);
|
|
2263
|
+
// create hitArea if necessary
|
|
2264
|
+
this.createOrUpdateHitArea(object, $el, $groupEl);
|
|
2265
|
+
var $parentGroupEl = root ||
|
|
2654
2266
|
// @ts-ignore
|
|
2655
|
-
|
|
2656
|
-
if ($
|
|
2657
|
-
$
|
|
2658
|
-
//
|
|
2659
|
-
this.
|
|
2660
|
-
// object.entity.removeComponent(ElementSVG, true);
|
|
2267
|
+
object.parentNode && ((_object$parentNode$el2 = object.parentNode.elementSVG) === null || _object$parentNode$el2 === void 0 ? void 0 : _object$parentNode$el2.$groupEl);
|
|
2268
|
+
if ($parentGroupEl) {
|
|
2269
|
+
$parentGroupEl.appendChild($groupEl);
|
|
2270
|
+
// need reorder children later
|
|
2271
|
+
this.pendingReorderQueue.add(object.parentNode);
|
|
2661
2272
|
}
|
|
2662
2273
|
}
|
|
2663
|
-
}
|
|
2664
|
-
|
|
2665
|
-
|
|
2274
|
+
};
|
|
2275
|
+
_proto.removeSVGDom = function removeSVGDom(object) {
|
|
2276
|
+
var _object$elementSVG6;
|
|
2277
|
+
// @ts-ignore
|
|
2278
|
+
var $groupEl = (_object$elementSVG6 = object.elementSVG) === null || _object$elementSVG6 === void 0 ? void 0 : _object$elementSVG6.$groupEl;
|
|
2279
|
+
if ($groupEl && $groupEl.parentNode) {
|
|
2280
|
+
$groupEl.parentNode.removeChild($groupEl);
|
|
2666
2281
|
// @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;
|
|
2282
|
+
this.context.SVGElementLifeCycleContribution.destroyElement(object, $groupEl);
|
|
2283
|
+
// object.entity.removeComponent(ElementSVG, true);
|
|
2284
|
+
}
|
|
2285
|
+
};
|
|
2286
|
+
|
|
2287
|
+
_proto.createOrUpdateHitArea = function createOrUpdateHitArea(object, $el, $groupEl) {
|
|
2288
|
+
// @ts-ignore
|
|
2289
|
+
var svgElement = object.elementSVG;
|
|
2290
|
+
var $hitTestingEl = svgElement.$hitTestingEl;
|
|
2291
|
+
var increasedLineWidthForHitTesting = object.parsedStyle.increasedLineWidthForHitTesting;
|
|
2292
|
+
// account for hitArea
|
|
2293
|
+
if (increasedLineWidthForHitTesting) {
|
|
2294
|
+
if (!$hitTestingEl) {
|
|
2295
|
+
$hitTestingEl = $el.cloneNode();
|
|
2296
|
+
if (this.pluginOptions.outputSVGElementId) {
|
|
2297
|
+
// use the entity suffix, so that `g-plugin-svg-picker` can extract
|
|
2298
|
+
$hitTestingEl.id = G_SVG_PREFIX + "-" + object.nodeName + "-hittesting-" + object.entity;
|
|
2695
2299
|
}
|
|
2300
|
+
// clear attributes like `filter` `font-size`
|
|
2301
|
+
['filter'].forEach(function (attribute) {
|
|
2302
|
+
$hitTestingEl.removeAttribute(attribute);
|
|
2303
|
+
});
|
|
2304
|
+
// hitArea should be 'transparent' but not 'none'
|
|
2305
|
+
var hasFill = $el.getAttribute('fill') !== 'none';
|
|
2306
|
+
$hitTestingEl.setAttribute('fill', hasFill ? 'transparent' : 'none');
|
|
2307
|
+
$hitTestingEl.setAttribute('stroke', 'transparent');
|
|
2308
|
+
$groupEl.appendChild($hitTestingEl);
|
|
2309
|
+
svgElement.$hitTestingEl = $hitTestingEl;
|
|
2310
|
+
}
|
|
2311
|
+
// increase interactive line width
|
|
2312
|
+
$hitTestingEl.setAttribute('stroke-width', "" + (increasedLineWidthForHitTesting + object.parsedStyle.lineWidth));
|
|
2313
|
+
} else {
|
|
2314
|
+
if ($hitTestingEl) {
|
|
2315
|
+
$groupEl.removeChild($hitTestingEl);
|
|
2316
|
+
svgElement.$hitTestingEl = null;
|
|
2696
2317
|
}
|
|
2697
2318
|
}
|
|
2698
|
-
}
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
$div.appendChild(usedValue);
|
|
2706
|
-
}
|
|
2707
|
-
$el.innerHTML = '';
|
|
2708
|
-
$el.appendChild($div);
|
|
2319
|
+
};
|
|
2320
|
+
_proto.createOrUpdateInnerHTML = function createOrUpdateInnerHTML(doc, $el, usedValue) {
|
|
2321
|
+
var $div = (doc || document).createElement('div');
|
|
2322
|
+
if (typeof usedValue === 'string') {
|
|
2323
|
+
$div.innerHTML = usedValue;
|
|
2324
|
+
} else {
|
|
2325
|
+
$div.appendChild(usedValue);
|
|
2709
2326
|
}
|
|
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
|
-
$clipPath = createSVGElement(attributeNameCamel, document);
|
|
2740
|
-
var $use = createSVGElement('use', document);
|
|
2741
|
-
// @ts-ignore
|
|
2742
|
-
$use.setAttribute('href', "#".concat(clipPath.elementSVG.$el.id));
|
|
2743
|
-
$clipPath.appendChild($use);
|
|
2744
|
-
var $useRefs = this.clipPathUseMap.get(clipPath);
|
|
2745
|
-
if (!$useRefs) {
|
|
2746
|
-
this.clipPathUseMap.set(clipPath, []);
|
|
2747
|
-
$useRefs = this.clipPathUseMap.get(clipPath);
|
|
2327
|
+
$el.innerHTML = '';
|
|
2328
|
+
$el.appendChild($div);
|
|
2329
|
+
};
|
|
2330
|
+
_proto.createOrUpdateClipOrTextPath = function createOrUpdateClipOrTextPath(document, clipPath, object, isTextPath) {
|
|
2331
|
+
if (isTextPath === void 0) {
|
|
2332
|
+
isTextPath = false;
|
|
2333
|
+
}
|
|
2334
|
+
// @ts-ignore
|
|
2335
|
+
var $groupEl = object.elementSVG.$groupEl;
|
|
2336
|
+
var PREFIX = isTextPath ? TEXT_PATH_PREFIX : CLIP_PATH_PREFIX;
|
|
2337
|
+
var attributeNameCamel = isTextPath ? 'g' : 'clipPath';
|
|
2338
|
+
var attributeNameHyphen = isTextPath ? 'text-path' : 'clip-path';
|
|
2339
|
+
if (clipPath) {
|
|
2340
|
+
var clipPathId = PREFIX + clipPath.entity + '-' + object.entity;
|
|
2341
|
+
var $def = this.defElementManager.getDefElement();
|
|
2342
|
+
var existed = $def.querySelector("#" + clipPathId);
|
|
2343
|
+
if (!existed) {
|
|
2344
|
+
var $clipPath;
|
|
2345
|
+
if (isTextPath) {
|
|
2346
|
+
// use <path> directly instead of wrapping with <g>
|
|
2347
|
+
this.createSVGDom(document, clipPath, null, true);
|
|
2348
|
+
// @ts-ignore
|
|
2349
|
+
$clipPath = clipPath.elementSVG.$el;
|
|
2350
|
+
} else {
|
|
2351
|
+
// the clipPath is allowed to be detached from canvas
|
|
2352
|
+
if (!clipPath.isConnected) {
|
|
2353
|
+
var $existedClipPath = $def.querySelector("#" + this.getId(clipPath));
|
|
2354
|
+
if (!$existedClipPath) {
|
|
2355
|
+
this.createSVGDom(document, clipPath, $def, true);
|
|
2748
2356
|
}
|
|
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
2357
|
}
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
$
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2358
|
+
// create <clipPath> dom node
|
|
2359
|
+
$clipPath = createSVGElement(attributeNameCamel, document);
|
|
2360
|
+
var $use = createSVGElement('use', document);
|
|
2361
|
+
// @ts-ignore
|
|
2362
|
+
$use.setAttribute('href', "#" + clipPath.elementSVG.$el.id);
|
|
2363
|
+
$clipPath.appendChild($use);
|
|
2364
|
+
var $useRefs = this.clipPathUseMap.get(clipPath);
|
|
2365
|
+
if (!$useRefs) {
|
|
2366
|
+
this.clipPathUseMap.set(clipPath, []);
|
|
2367
|
+
$useRefs = this.clipPathUseMap.get(clipPath);
|
|
2368
|
+
}
|
|
2369
|
+
$useRefs.push($use);
|
|
2370
|
+
// <clipPath transform="matrix()"><circle /></clipPath>
|
|
2371
|
+
this.applyTransform($use, clipPath.getWorldTransform());
|
|
2372
|
+
var parentInvert = invert(create(), object.getWorldTransform());
|
|
2373
|
+
this.applyTransform($clipPath, parentInvert);
|
|
2770
2374
|
}
|
|
2375
|
+
$clipPath.id = clipPathId;
|
|
2376
|
+
// append it to <defs>
|
|
2377
|
+
$def.appendChild($clipPath);
|
|
2378
|
+
}
|
|
2379
|
+
// apply attributes
|
|
2380
|
+
this.applyAttributes(clipPath);
|
|
2381
|
+
if (!isTextPath) {
|
|
2382
|
+
// apply clipPath to $group
|
|
2383
|
+
// @see https://github.com/antvis/g/issues/961
|
|
2384
|
+
$groupEl.setAttribute(attributeNameHyphen, "url(#" + clipPathId + ")");
|
|
2385
|
+
}
|
|
2386
|
+
} else {
|
|
2387
|
+
if (!isTextPath) {
|
|
2388
|
+
// remove clip path
|
|
2389
|
+
$groupEl.removeAttribute(attributeNameHyphen);
|
|
2771
2390
|
}
|
|
2772
2391
|
}
|
|
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
|
-
}
|
|
2392
|
+
}
|
|
2393
|
+
/**
|
|
2394
|
+
* the origin is bounding box's top left corner
|
|
2395
|
+
*/;
|
|
2396
|
+
_proto.updateAnchorWithTransform = function updateAnchorWithTransform(object) {
|
|
2397
|
+
var _object$elementSVG7, _object$elementSVG8;
|
|
2398
|
+
var bounds = object.getGeometryBounds();
|
|
2399
|
+
var width = bounds && bounds.halfExtents[0] * 2 || 0;
|
|
2400
|
+
var height = bounds && bounds.halfExtents[1] * 2 || 0;
|
|
2401
|
+
var _ref2 = object.parsedStyle || {},
|
|
2402
|
+
anchor = _ref2.anchor;
|
|
2403
|
+
// @ts-ignore
|
|
2404
|
+
[(_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) {
|
|
2405
|
+
if ($el) {
|
|
2406
|
+
var tx = -(anchor[0] * width);
|
|
2407
|
+
var ty = -(anchor[1] * height);
|
|
2408
|
+
if (tx !== 0 || ty !== 0) {
|
|
2409
|
+
// apply anchor to element's `transform` property
|
|
2410
|
+
$el.setAttribute('transform',
|
|
2411
|
+
// can't use percent unit like translate(-50%, -50%)
|
|
2412
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/transform#translate
|
|
2413
|
+
"translate(" + tx + "," + ty + ")");
|
|
2801
2414
|
}
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2415
|
+
if (object.nodeName === gLite.Shape.CIRCLE || object.nodeName === gLite.Shape.ELLIPSE) {
|
|
2416
|
+
$el.setAttribute('cx', "" + width / 2);
|
|
2417
|
+
$el.setAttribute('cy', "" + height / 2);
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
});
|
|
2421
|
+
};
|
|
2805
2422
|
return SVGRendererPlugin;
|
|
2806
2423
|
}();
|
|
2807
2424
|
SVGRendererPlugin.tag = 'SVGRenderer';
|
|
@@ -2857,18 +2474,18 @@
|
|
|
2857
2474
|
var lineNum = lines.length;
|
|
2858
2475
|
var styleCSSText = '';
|
|
2859
2476
|
if (dx !== 0 || dy !== 0) {
|
|
2860
|
-
styleCSSText += "transform:translate("
|
|
2477
|
+
styleCSSText += "transform:translate(" + dx + "px, " + dy + "px);";
|
|
2861
2478
|
}
|
|
2862
2479
|
if (textDecorationLine && textDecorationLine !== 'none') {
|
|
2863
2480
|
// use CSS text-decoration since the implementation in SVG is not good enough
|
|
2864
|
-
styleCSSText += "text-decoration:"
|
|
2481
|
+
styleCSSText += "text-decoration:" + textDecorationLine + " " + textDecorationStyle + " " + textDecorationColor + ";";
|
|
2865
2482
|
}
|
|
2866
2483
|
if (styleCSSText) {
|
|
2867
2484
|
$el.setAttribute('style', styleCSSText);
|
|
2868
2485
|
}
|
|
2869
2486
|
if (lineNum === 1) {
|
|
2870
2487
|
var textContent = convertHTML(lines[0]);
|
|
2871
|
-
$el.setAttribute('dx', ""
|
|
2488
|
+
$el.setAttribute('dx', "" + lineWidth / 2);
|
|
2872
2489
|
// <textPath> only support one line
|
|
2873
2490
|
// @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/textPath
|
|
2874
2491
|
if (textPath) {
|
|
@@ -2876,12 +2493,12 @@
|
|
|
2876
2493
|
$el.innerHTML = '';
|
|
2877
2494
|
// append <textPath href="#MyPath">text</textPath>
|
|
2878
2495
|
var $textPath = createSVGElement('textPath', $el.ownerDocument);
|
|
2879
|
-
$textPath.setAttribute('href', "#"
|
|
2496
|
+
$textPath.setAttribute('href', "#" + (TEXT_PATH_PREFIX + textPath.entity));
|
|
2880
2497
|
if (textPathSide !== 'left') {
|
|
2881
2498
|
$textPath.setAttribute('side', textPathSide);
|
|
2882
2499
|
}
|
|
2883
2500
|
if (textPathStartOffset !== 0) {
|
|
2884
|
-
$textPath.setAttribute('startOffset', ""
|
|
2501
|
+
$textPath.setAttribute('startOffset', "" + textPathStartOffset);
|
|
2885
2502
|
}
|
|
2886
2503
|
$textPath.innerHTML = textContent;
|
|
2887
2504
|
$el.appendChild($textPath);
|
|
@@ -2904,79 +2521,70 @@
|
|
|
2904
2521
|
} else {
|
|
2905
2522
|
dy = lineHeight;
|
|
2906
2523
|
}
|
|
2907
|
-
return "<tspan x=\"0\" dx=\""
|
|
2524
|
+
return "<tspan x=\"0\" dx=\"" + dx + "\" dy=\"" + dy + "\">" + convertHTML(line) + "</tspan>";
|
|
2908
2525
|
}).join('');
|
|
2909
2526
|
}
|
|
2910
2527
|
}
|
|
2911
2528
|
var _SHAPE2TAGS, _SHAPE_UPDATE_DEPS;
|
|
2912
|
-
var SHAPE2TAGS = (_SHAPE2TAGS = {},
|
|
2913
|
-
var SHAPE_UPDATE_DEPS = (_SHAPE_UPDATE_DEPS = {},
|
|
2529
|
+
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);
|
|
2530
|
+
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
2531
|
// 'whiteSpace',
|
|
2915
|
-
'dx', 'dy']
|
|
2532
|
+
'dx', 'dy'], _SHAPE_UPDATE_DEPS);
|
|
2916
2533
|
var DefaultElementLifeCycleContribution = /*#__PURE__*/function () {
|
|
2917
2534
|
function DefaultElementLifeCycleContribution(context) {
|
|
2918
|
-
_classCallCheck$2(this, DefaultElementLifeCycleContribution);
|
|
2919
2535
|
this.context = void 0;
|
|
2920
2536
|
this.context = context;
|
|
2921
2537
|
}
|
|
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
|
-
}
|
|
2538
|
+
var _proto = DefaultElementLifeCycleContribution.prototype;
|
|
2539
|
+
_proto.createElement = function createElement(object) {
|
|
2540
|
+
var doc = this.context.config.document;
|
|
2541
|
+
var type = SHAPE2TAGS[object.nodeName] || 'g';
|
|
2542
|
+
return createSVGElement(type, doc || document);
|
|
2543
|
+
};
|
|
2544
|
+
_proto.destroyElement = function destroyElement(object, $el) {};
|
|
2545
|
+
_proto.shouldUpdateElementAttribute = function shouldUpdateElementAttribute(object, attributeName) {
|
|
2546
|
+
var nodeName = object.nodeName;
|
|
2547
|
+
return (SHAPE_UPDATE_DEPS[nodeName] || []).indexOf(attributeName) > -1;
|
|
2548
|
+
};
|
|
2549
|
+
_proto.updateElementAttribute = function updateElementAttribute(object) {
|
|
2550
|
+
// @ts-ignore
|
|
2551
|
+
var $el = object.elementSVG.$el;
|
|
2552
|
+
var nodeName = object.nodeName,
|
|
2553
|
+
parsedStyle = object.parsedStyle;
|
|
2554
|
+
switch (nodeName) {
|
|
2555
|
+
case gLite.Shape.IMAGE:
|
|
2556
|
+
{
|
|
2557
|
+
updateImageElementAttribute($el, parsedStyle);
|
|
2558
|
+
break;
|
|
2559
|
+
}
|
|
2560
|
+
case gLite.Shape.RECT:
|
|
2561
|
+
{
|
|
2562
|
+
updateRectElementAttribute($el, parsedStyle);
|
|
2563
|
+
break;
|
|
2564
|
+
}
|
|
2565
|
+
case gLite.Shape.LINE:
|
|
2566
|
+
{
|
|
2567
|
+
updateLineElementAttribute($el, parsedStyle);
|
|
2568
|
+
break;
|
|
2569
|
+
}
|
|
2570
|
+
case gLite.Shape.POLYGON:
|
|
2571
|
+
case gLite.Shape.POLYLINE:
|
|
2572
|
+
{
|
|
2573
|
+
updatePolylineElementAttribute($el, parsedStyle);
|
|
2574
|
+
break;
|
|
2575
|
+
}
|
|
2576
|
+
case gLite.Shape.PATH:
|
|
2577
|
+
{
|
|
2578
|
+
updatePathElementAttribute($el, parsedStyle);
|
|
2579
|
+
break;
|
|
2580
|
+
}
|
|
2581
|
+
case gLite.Shape.TEXT:
|
|
2582
|
+
{
|
|
2583
|
+
updateTextElementAttribute($el, parsedStyle);
|
|
2584
|
+
break;
|
|
2585
|
+
}
|
|
2978
2586
|
}
|
|
2979
|
-
}
|
|
2587
|
+
};
|
|
2980
2588
|
return DefaultElementLifeCycleContribution;
|
|
2981
2589
|
}();
|
|
2982
2590
|
var FILTER_PREFIX = 'g-filter-';
|
|
@@ -2987,7 +2595,7 @@
|
|
|
2987
2595
|
function createOrUpdateFilter(document, $def, object, $el, filters) {
|
|
2988
2596
|
// eg. filter="url(#f1) url(#f2)"
|
|
2989
2597
|
var filterName = FILTER_PREFIX + object.entity;
|
|
2990
|
-
var $existedFilters = $def.querySelectorAll("[name="
|
|
2598
|
+
var $existedFilters = $def.querySelectorAll("[name=" + filterName + "]");
|
|
2991
2599
|
if ($existedFilters.length) {
|
|
2992
2600
|
$existedFilters.forEach(function ($filter) {
|
|
2993
2601
|
$def.removeChild($filter);
|
|
@@ -3022,7 +2630,7 @@
|
|
|
3022
2630
|
} else if (name === 'invert') {
|
|
3023
2631
|
createInvert(document, $filter, params);
|
|
3024
2632
|
}
|
|
3025
|
-
$filter.id =
|
|
2633
|
+
$filter.id = filterName + "-" + i;
|
|
3026
2634
|
$filter.setAttribute('name', filterName);
|
|
3027
2635
|
$def.appendChild($filter);
|
|
3028
2636
|
return $filter.id;
|
|
@@ -3030,7 +2638,7 @@
|
|
|
3030
2638
|
// @see https://github.com/antvis/G/issues/1114
|
|
3031
2639
|
setTimeout(function () {
|
|
3032
2640
|
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', filterIds.map(function (filterId) {
|
|
3033
|
-
return "url(#"
|
|
2641
|
+
return "url(#" + filterId + ")";
|
|
3034
2642
|
}).join(' '));
|
|
3035
2643
|
});
|
|
3036
2644
|
}
|
|
@@ -3044,7 +2652,7 @@
|
|
|
3044
2652
|
function createBlur(document, $filter, params) {
|
|
3045
2653
|
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
3046
2654
|
$feGaussianBlur.setAttribute('in', 'SourceGraphic');
|
|
3047
|
-
$feGaussianBlur.setAttribute('stdDeviation', ""
|
|
2655
|
+
$feGaussianBlur.setAttribute('stdDeviation', "" + params[0].value);
|
|
3048
2656
|
$filter.appendChild($feGaussianBlur);
|
|
3049
2657
|
}
|
|
3050
2658
|
function createFeComponentTransfer(document, $filter, _ref2) {
|
|
@@ -3056,10 +2664,10 @@
|
|
|
3056
2664
|
[createSVGElement('feFuncR', document), createSVGElement('feFuncG', document), createSVGElement('feFuncB', document)].forEach(function ($feFunc) {
|
|
3057
2665
|
$feFunc.setAttribute('type', type);
|
|
3058
2666
|
if (type === 'table') {
|
|
3059
|
-
$feFunc.setAttribute('tableValues', ""
|
|
2667
|
+
$feFunc.setAttribute('tableValues', "" + tableValues);
|
|
3060
2668
|
} else {
|
|
3061
|
-
$feFunc.setAttribute('slope', ""
|
|
3062
|
-
$feFunc.setAttribute('intercept', ""
|
|
2669
|
+
$feFunc.setAttribute('slope', "" + slope);
|
|
2670
|
+
$feFunc.setAttribute('intercept', "" + intercept);
|
|
3063
2671
|
}
|
|
3064
2672
|
$feComponentTransfer.appendChild($feFunc);
|
|
3065
2673
|
});
|
|
@@ -3077,7 +2685,7 @@
|
|
|
3077
2685
|
var amount = convertToAbsoluteValue(params[0]);
|
|
3078
2686
|
createFeComponentTransfer(document, $filter, {
|
|
3079
2687
|
type: 'table',
|
|
3080
|
-
tableValues:
|
|
2688
|
+
tableValues: amount + " " + (1 - amount)
|
|
3081
2689
|
});
|
|
3082
2690
|
}
|
|
3083
2691
|
function createBrightness(document, $filter, params) {
|
|
@@ -3092,13 +2700,13 @@
|
|
|
3092
2700
|
var amount = convertToAbsoluteValue(params[0]);
|
|
3093
2701
|
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
3094
2702
|
$feColorMatrix.setAttribute('type', 'saturate');
|
|
3095
|
-
$feColorMatrix.setAttribute('values', ""
|
|
2703
|
+
$feColorMatrix.setAttribute('values', "" + amount);
|
|
3096
2704
|
$filter.appendChild($feColorMatrix);
|
|
3097
2705
|
}
|
|
3098
2706
|
function createHueRotate(document, $filter, params) {
|
|
3099
2707
|
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
3100
2708
|
$feColorMatrix.setAttribute('type', 'hueRotate');
|
|
3101
|
-
$feColorMatrix.setAttribute('values', ""
|
|
2709
|
+
$feColorMatrix.setAttribute('values', "" + params[0].to(gLite.UnitType.kDegrees).value);
|
|
3102
2710
|
$filter.appendChild($feColorMatrix);
|
|
3103
2711
|
}
|
|
3104
2712
|
function createDropShadow(document, $filter, params) {
|
|
@@ -3109,11 +2717,11 @@
|
|
|
3109
2717
|
var shadowColor = params[3].formatted;
|
|
3110
2718
|
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
3111
2719
|
$feGaussianBlur.setAttribute('in', 'SourceAlpha');
|
|
3112
|
-
$feGaussianBlur.setAttribute('stdDeviation', ""
|
|
2720
|
+
$feGaussianBlur.setAttribute('stdDeviation', "" + shadowBlur);
|
|
3113
2721
|
$filter.appendChild($feGaussianBlur);
|
|
3114
2722
|
var $feOffset = createSVGElement('feOffset', document);
|
|
3115
|
-
$feOffset.setAttribute('dx', ""
|
|
3116
|
-
$feOffset.setAttribute('dy', ""
|
|
2723
|
+
$feOffset.setAttribute('dx', "" + shadowOffsetX);
|
|
2724
|
+
$feOffset.setAttribute('dy', "" + shadowOffsetY);
|
|
3117
2725
|
$feOffset.setAttribute('result', 'offsetblur');
|
|
3118
2726
|
$filter.appendChild($feOffset);
|
|
3119
2727
|
var $feFlood = createSVGElement('feFlood', document);
|
|
@@ -3171,32 +2779,34 @@
|
|
|
3171
2779
|
var patternId = createOrUpdatePattern(document, $def, object, parsedColor, createImage, plugin);
|
|
3172
2780
|
// use style instead of attribute when applying <pattern>
|
|
3173
2781
|
// @see https://stackoverflow.com/a/7723115
|
|
3174
|
-
$el.style[name] = "url(#"
|
|
2782
|
+
$el.style[name] = "url(#" + patternId + ")";
|
|
3175
2783
|
return patternId;
|
|
3176
2784
|
} else {
|
|
3177
2785
|
if (parsedColor.length === 1) {
|
|
3178
2786
|
var gradientId = createOrUpdateGradient(document, object, $def, $el, parsedColor[0]);
|
|
3179
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#"
|
|
2787
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#" + gradientId + ")");
|
|
3180
2788
|
return gradientId;
|
|
3181
2789
|
} else {
|
|
3182
2790
|
// @see https://stackoverflow.com/questions/20671502/can-i-blend-gradients-in-svg
|
|
3183
2791
|
var filterId = createOrUpdateMultiGradient(document, object, $def, $el, parsedColor);
|
|
3184
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#"
|
|
2792
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + filterId + ")");
|
|
3185
2793
|
$el === null || $el === void 0 ? void 0 : $el.setAttribute('fill', 'black');
|
|
3186
2794
|
return filterId;
|
|
3187
2795
|
}
|
|
3188
2796
|
}
|
|
3189
2797
|
return '';
|
|
3190
2798
|
}
|
|
3191
|
-
function generateCacheKey(src) {
|
|
3192
|
-
|
|
2799
|
+
function generateCacheKey(src, options) {
|
|
2800
|
+
if (options === void 0) {
|
|
2801
|
+
options = {};
|
|
2802
|
+
}
|
|
3193
2803
|
var cacheKey = '';
|
|
3194
2804
|
if (src instanceof gLite.CSSGradientValue) {
|
|
3195
2805
|
var type = src.type,
|
|
3196
2806
|
value = src.value;
|
|
3197
2807
|
if (type === gLite.GradientType.LinearGradient || type === gLite.GradientType.RadialGradient) {
|
|
3198
2808
|
// @ts-ignore
|
|
3199
|
-
var _value$options =
|
|
2809
|
+
var _value$options = _extends({}, value, options),
|
|
3200
2810
|
_type = _value$options.type,
|
|
3201
2811
|
width = _value$options.width,
|
|
3202
2812
|
height = _value$options.height,
|
|
@@ -3205,25 +2815,25 @@
|
|
|
3205
2815
|
cx = _value$options.cx,
|
|
3206
2816
|
cy = _value$options.cy,
|
|
3207
2817
|
size = _value$options.size;
|
|
3208
|
-
cacheKey = "gradient-"
|
|
2818
|
+
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
2819
|
var offset = _ref.offset,
|
|
3210
2820
|
color = _ref.color;
|
|
3211
|
-
return ""
|
|
3212
|
-
}).join('-')
|
|
2821
|
+
return "" + offset + color;
|
|
2822
|
+
}).join('-');
|
|
3213
2823
|
}
|
|
3214
2824
|
} else if (gLite.isPattern(src)) {
|
|
3215
2825
|
if (isString(src.image)) {
|
|
3216
|
-
cacheKey = "pattern-"
|
|
2826
|
+
cacheKey = "pattern-" + src.image + "-" + src.repetition;
|
|
3217
2827
|
} else if (src.image instanceof gLite.Rect) {
|
|
3218
2828
|
// use rect's entity as key
|
|
3219
|
-
cacheKey = "pattern-rect-"
|
|
2829
|
+
cacheKey = "pattern-rect-" + src.image.entity;
|
|
3220
2830
|
} else {
|
|
3221
|
-
cacheKey = "pattern-"
|
|
2831
|
+
cacheKey = "pattern-" + counter;
|
|
3222
2832
|
}
|
|
3223
2833
|
}
|
|
3224
2834
|
if (cacheKey) {
|
|
3225
2835
|
if (!cacheKey2IDMap[cacheKey]) {
|
|
3226
|
-
cacheKey2IDMap[cacheKey] = PATTERN_PREFIX + ""
|
|
2836
|
+
cacheKey2IDMap[cacheKey] = PATTERN_PREFIX + ("" + counter++);
|
|
3227
2837
|
}
|
|
3228
2838
|
}
|
|
3229
2839
|
return cacheKey2IDMap[cacheKey];
|
|
@@ -3235,56 +2845,55 @@
|
|
|
3235
2845
|
var t = parsed.t,
|
|
3236
2846
|
d = parsed.d;
|
|
3237
2847
|
if (t === 'translate') {
|
|
3238
|
-
return "translate("
|
|
2848
|
+
return "translate(" + d[0].value + " " + d[1].value + ")";
|
|
3239
2849
|
} else if (t === 'translatex') {
|
|
3240
|
-
return "translate("
|
|
2850
|
+
return "translate(" + d[0].value + " 0)";
|
|
3241
2851
|
} else if (t === 'translatey') {
|
|
3242
|
-
return "translate(0 "
|
|
2852
|
+
return "translate(0 " + d[0].value + ")";
|
|
3243
2853
|
} else if (t === 'rotate') {
|
|
3244
|
-
return "rotate("
|
|
2854
|
+
return "rotate(" + d[0].value + ")";
|
|
3245
2855
|
} else if (t === 'scale') {
|
|
3246
2856
|
// scale(1) scale(1, 1)
|
|
3247
2857
|
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
3248
2858
|
return s.value;
|
|
3249
2859
|
})) || [1, 1];
|
|
3250
|
-
return "scale("
|
|
2860
|
+
return "scale(" + newScale[0] + ", " + newScale[1] + ")";
|
|
3251
2861
|
} else if (t === 'scalex') {
|
|
3252
2862
|
var _newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
3253
2863
|
return s.value;
|
|
3254
2864
|
})) || [1];
|
|
3255
|
-
return "scale("
|
|
2865
|
+
return "scale(" + _newScale[0] + ", 1)";
|
|
3256
2866
|
} else if (t === 'scaley') {
|
|
3257
2867
|
var _newScale2 = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
3258
2868
|
return s.value;
|
|
3259
2869
|
})) || [1];
|
|
3260
|
-
return "scale(1, "
|
|
2870
|
+
return "scale(1, " + _newScale2[0] + ")";
|
|
3261
2871
|
} else if (t === 'skew') {
|
|
3262
2872
|
var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
3263
2873
|
return s.value;
|
|
3264
2874
|
})) || [0, 0];
|
|
3265
|
-
return "skewX("
|
|
2875
|
+
return "skewX(" + newSkew[0] + ") skewY(" + newSkew[1] + ")";
|
|
3266
2876
|
} else if (t === 'skewx') {
|
|
3267
2877
|
var _newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
3268
2878
|
return s.value;
|
|
3269
2879
|
})) || [0];
|
|
3270
|
-
return "skewX("
|
|
2880
|
+
return "skewX(" + _newSkew[0] + ")";
|
|
3271
2881
|
} else if (t === 'skewy') {
|
|
3272
2882
|
var _newSkew2 = (d === null || d === void 0 ? void 0 : d.map(function (s) {
|
|
3273
2883
|
return s.value;
|
|
3274
2884
|
})) || [0];
|
|
3275
|
-
return "skewY("
|
|
2885
|
+
return "skewY(" + _newSkew2[0] + ")";
|
|
3276
2886
|
} else if (t === 'matrix') {
|
|
3277
2887
|
var _d$map = d.map(function (s) {
|
|
3278
2888
|
return s.value;
|
|
3279
2889
|
}),
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
return "matrix(".concat(a, " ").concat(b, " ").concat(c, " ").concat(dd, " ").concat(tx, " ").concat(ty, ")");
|
|
2890
|
+
a = _d$map[0],
|
|
2891
|
+
b = _d$map[1],
|
|
2892
|
+
c = _d$map[2],
|
|
2893
|
+
dd = _d$map[3],
|
|
2894
|
+
tx = _d$map[4],
|
|
2895
|
+
ty = _d$map[5];
|
|
2896
|
+
return "matrix(" + a + " " + b + " " + c + " " + dd + " " + tx + " " + ty + ")";
|
|
3288
2897
|
}
|
|
3289
2898
|
}).join(' ');
|
|
3290
2899
|
}
|
|
@@ -3315,13 +2924,13 @@
|
|
|
3315
2924
|
patternWidth = halfExtents[0] * 2;
|
|
3316
2925
|
patternHeight = halfExtents[1] * 2;
|
|
3317
2926
|
}
|
|
3318
|
-
$pattern.setAttribute('width', ""
|
|
3319
|
-
$pattern.setAttribute('height', ""
|
|
2927
|
+
$pattern.setAttribute('width', "" + patternWidth);
|
|
2928
|
+
$pattern.setAttribute('height', "" + patternHeight);
|
|
3320
2929
|
return $pattern;
|
|
3321
2930
|
}
|
|
3322
2931
|
function createOrUpdatePattern(document, $def, object, pattern, createImage, plugin) {
|
|
3323
2932
|
var patternId = generateCacheKey(pattern);
|
|
3324
|
-
var $existed = $def.querySelector("#"
|
|
2933
|
+
var $existed = $def.querySelector("#" + patternId);
|
|
3325
2934
|
if (!$existed) {
|
|
3326
2935
|
var image = pattern.image;
|
|
3327
2936
|
var imageURL = '';
|
|
@@ -3358,8 +2967,8 @@
|
|
|
3358
2967
|
$pattern.appendChild($image);
|
|
3359
2968
|
$image.setAttribute('x', '0');
|
|
3360
2969
|
$image.setAttribute('y', '0');
|
|
3361
|
-
$image.setAttribute('width', ""
|
|
3362
|
-
$image.setAttribute('height', ""
|
|
2970
|
+
$image.setAttribute('width', "" + img.width);
|
|
2971
|
+
$image.setAttribute('height', "" + img.height);
|
|
3363
2972
|
};
|
|
3364
2973
|
if (img.complete) {
|
|
3365
2974
|
onload();
|
|
@@ -3400,7 +3009,7 @@
|
|
|
3400
3009
|
width: width,
|
|
3401
3010
|
height: height
|
|
3402
3011
|
});
|
|
3403
|
-
var $existed = $def.querySelector("#"
|
|
3012
|
+
var $existed = $def.querySelector("#" + gradientId);
|
|
3404
3013
|
if (!$existed) {
|
|
3405
3014
|
// <linearGradient> <radialGradient>
|
|
3406
3015
|
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/linearGradient
|
|
@@ -3418,7 +3027,7 @@
|
|
|
3418
3027
|
var offset = _ref2.offset,
|
|
3419
3028
|
color = _ref2.color;
|
|
3420
3029
|
// TODO: support absolute unit like `px`
|
|
3421
|
-
innerHTML += "<stop offset=\""
|
|
3030
|
+
innerHTML += "<stop offset=\"" + offset.value / 100 + "\" stop-color=\"" + color + "\"></stop>";
|
|
3422
3031
|
});
|
|
3423
3032
|
$existed.innerHTML = innerHTML;
|
|
3424
3033
|
$existed.id = gradientId;
|
|
@@ -3431,10 +3040,10 @@
|
|
|
3431
3040
|
y1 = _computeLinearGradien.y1,
|
|
3432
3041
|
x2 = _computeLinearGradien.x2,
|
|
3433
3042
|
y2 = _computeLinearGradien.y2;
|
|
3434
|
-
$existed.setAttribute('x1', ""
|
|
3435
|
-
$existed.setAttribute('y1', ""
|
|
3436
|
-
$existed.setAttribute('x2', ""
|
|
3437
|
-
$existed.setAttribute('y2', ""
|
|
3043
|
+
$existed.setAttribute('x1', "" + x1);
|
|
3044
|
+
$existed.setAttribute('y1', "" + y1);
|
|
3045
|
+
$existed.setAttribute('x2', "" + x2);
|
|
3046
|
+
$existed.setAttribute('y2', "" + y2);
|
|
3438
3047
|
// $existed.setAttribute('gradientTransform', `rotate(${angle})`);
|
|
3439
3048
|
} else {
|
|
3440
3049
|
var _parsedColor$value = parsedColor.value,
|
|
@@ -3445,15 +3054,15 @@
|
|
|
3445
3054
|
x = _computeRadialGradien.x,
|
|
3446
3055
|
y = _computeRadialGradien.y,
|
|
3447
3056
|
r = _computeRadialGradien.r;
|
|
3448
|
-
$existed.setAttribute('cx', ""
|
|
3449
|
-
$existed.setAttribute('cy', ""
|
|
3450
|
-
$existed.setAttribute('r', ""
|
|
3057
|
+
$existed.setAttribute('cx', "" + x);
|
|
3058
|
+
$existed.setAttribute('cy', "" + y);
|
|
3059
|
+
$existed.setAttribute('r', "" + r);
|
|
3451
3060
|
}
|
|
3452
3061
|
return gradientId;
|
|
3453
3062
|
}
|
|
3454
3063
|
function createOrUpdateMultiGradient(document, object, $def, $el, gradients) {
|
|
3455
3064
|
var filterId = FILTER_PREFIX + object.entity + '-gradient';
|
|
3456
|
-
var $existed = $def.querySelector("#"
|
|
3065
|
+
var $existed = $def.querySelector("#" + filterId);
|
|
3457
3066
|
if (!$existed) {
|
|
3458
3067
|
$existed = createSVGElement('filter', document);
|
|
3459
3068
|
$existed.setAttribute('filterUnits', 'userSpaceOnUse');
|
|
@@ -3483,25 +3092,25 @@
|
|
|
3483
3092
|
$rect.setAttribute('y', '0');
|
|
3484
3093
|
$rect.setAttribute('width', '100%');
|
|
3485
3094
|
$rect.setAttribute('height', '100%');
|
|
3486
|
-
$rect.setAttribute('fill', "url(#"
|
|
3095
|
+
$rect.setAttribute('fill', "url(#" + gradientId + ")");
|
|
3487
3096
|
$rect.id = rectId;
|
|
3488
3097
|
$def.appendChild($rect);
|
|
3489
3098
|
var $feImage = createSVGElement('feImage', document);
|
|
3490
|
-
$feImage.setAttribute('href', "#"
|
|
3491
|
-
$feImage.setAttribute('result',
|
|
3099
|
+
$feImage.setAttribute('href', "#" + rectId);
|
|
3100
|
+
$feImage.setAttribute('result', filterId + "-" + i);
|
|
3492
3101
|
$existed.appendChild($feImage);
|
|
3493
3102
|
if (i > 0) {
|
|
3494
3103
|
var $feBlend = createSVGElement('feBlend', document);
|
|
3495
|
-
$feBlend.setAttribute('in', i === 1 ?
|
|
3496
|
-
$feBlend.setAttribute('in2',
|
|
3497
|
-
$feBlend.setAttribute('result',
|
|
3104
|
+
$feBlend.setAttribute('in', i === 1 ? filterId + "-" + (i - 1) : filterId + "-blended-" + (blended - 1));
|
|
3105
|
+
$feBlend.setAttribute('in2', filterId + "-" + i);
|
|
3106
|
+
$feBlend.setAttribute('result', filterId + "-blended-" + blended++);
|
|
3498
3107
|
// @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/blend-mode
|
|
3499
3108
|
$feBlend.setAttribute('mode', 'multiply');
|
|
3500
3109
|
$existed.appendChild($feBlend);
|
|
3501
3110
|
}
|
|
3502
3111
|
});
|
|
3503
3112
|
var $feComposite = createSVGElement('feComposite', document);
|
|
3504
|
-
$feComposite.setAttribute('in',
|
|
3113
|
+
$feComposite.setAttribute('in', filterId + "-blended-" + blended);
|
|
3505
3114
|
$feComposite.setAttribute('in2', 'SourceGraphic');
|
|
3506
3115
|
$feComposite.setAttribute('operator', 'in');
|
|
3507
3116
|
$existed.appendChild($feComposite);
|
|
@@ -3521,7 +3130,7 @@
|
|
|
3521
3130
|
shadowOffsetY = _object$parsedStyle.shadowOffsetY;
|
|
3522
3131
|
var hasShadow = !isNil(shadowColor) && shadowBlur > 0;
|
|
3523
3132
|
var shadowId = FILTER_DROPSHADOW_PREFIX + object.entity;
|
|
3524
|
-
var $existedFilter = $def.querySelector("#"
|
|
3133
|
+
var $existedFilter = $def.querySelector("#" + shadowId);
|
|
3525
3134
|
if ($existedFilter) {
|
|
3526
3135
|
var existedShadowType = $existedFilter.getAttribute('data-type');
|
|
3527
3136
|
if (existedShadowType !== shadowType || !hasShadow) {
|
|
@@ -3535,7 +3144,7 @@
|
|
|
3535
3144
|
if (hasShadow) {
|
|
3536
3145
|
// use filter <feDropShadow>
|
|
3537
3146
|
// @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow
|
|
3538
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#"
|
|
3147
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + shadowId + ")");
|
|
3539
3148
|
} else {
|
|
3540
3149
|
$el === null || $el === void 0 ? void 0 : $el.removeAttribute('filter');
|
|
3541
3150
|
return;
|
|
@@ -3545,9 +3154,9 @@
|
|
|
3545
3154
|
$existedFilter.setAttribute('data-type', shadowType);
|
|
3546
3155
|
if (shadowType === 'outer') {
|
|
3547
3156
|
var $feDropShadow = createSVGElement('feDropShadow', document);
|
|
3548
|
-
$feDropShadow.setAttribute('dx', ""
|
|
3549
|
-
$feDropShadow.setAttribute('dy', ""
|
|
3550
|
-
$feDropShadow.setAttribute('stdDeviation', ""
|
|
3157
|
+
$feDropShadow.setAttribute('dx', "" + (shadowOffsetX || 0) / 2);
|
|
3158
|
+
$feDropShadow.setAttribute('dy', "" + (shadowOffsetY || 0) / 2);
|
|
3159
|
+
$feDropShadow.setAttribute('stdDeviation', "" + (shadowBlur || 0) / 4);
|
|
3551
3160
|
$feDropShadow.setAttribute('flood-color', shadowColor.toString());
|
|
3552
3161
|
$existedFilter.appendChild($feDropShadow);
|
|
3553
3162
|
} else if (shadowType === 'inner') {
|
|
@@ -3559,11 +3168,11 @@
|
|
|
3559
3168
|
$feComponentTransfer.appendChild($feFuncA);
|
|
3560
3169
|
$existedFilter.appendChild($feComponentTransfer);
|
|
3561
3170
|
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
3562
|
-
$feGaussianBlur.setAttribute('stdDeviation', ""
|
|
3171
|
+
$feGaussianBlur.setAttribute('stdDeviation', "" + (shadowBlur || 0) / 4);
|
|
3563
3172
|
$existedFilter.appendChild($feGaussianBlur);
|
|
3564
3173
|
var $feOffset = createSVGElement('feOffset', document);
|
|
3565
|
-
$feOffset.setAttribute('dx', ""
|
|
3566
|
-
$feOffset.setAttribute('dy', ""
|
|
3174
|
+
$feOffset.setAttribute('dx', "" + (shadowOffsetX || 0) / 2);
|
|
3175
|
+
$feOffset.setAttribute('dy', "" + (shadowOffsetY || 0) / 2);
|
|
3567
3176
|
$feOffset.setAttribute('result', 'offsetblur');
|
|
3568
3177
|
$existedFilter.appendChild($feOffset);
|
|
3569
3178
|
var $feFlood = createSVGElement('feFlood', document);
|
|
@@ -3602,11 +3211,11 @@
|
|
|
3602
3211
|
// half the blur radius
|
|
3603
3212
|
// @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
|
|
3604
3213
|
// @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
|
|
3605
|
-
_$feGaussianBlur.setAttribute('stdDeviation', ""
|
|
3214
|
+
_$feGaussianBlur.setAttribute('stdDeviation', "" + (shadowBlur || 0) / 4);
|
|
3606
3215
|
} else if (name === 'shadowOffsetX') {
|
|
3607
|
-
_$feOffset.setAttribute('dx', ""
|
|
3216
|
+
_$feOffset.setAttribute('dx', "" + (shadowOffsetX || 0) / 2);
|
|
3608
3217
|
} else if (name === 'shadowOffsetY') {
|
|
3609
|
-
_$feOffset.setAttribute('dy', ""
|
|
3218
|
+
_$feOffset.setAttribute('dy', "" + (shadowOffsetY || 0) / 2);
|
|
3610
3219
|
}
|
|
3611
3220
|
} else if (shadowType === 'outer') {
|
|
3612
3221
|
var _$feDropShadow = $existedFilter.children[0];
|
|
@@ -3616,18 +3225,17 @@
|
|
|
3616
3225
|
// half the blur radius
|
|
3617
3226
|
// @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
|
|
3618
3227
|
// @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
|
|
3619
|
-
_$feDropShadow.setAttribute('stdDeviation', ""
|
|
3228
|
+
_$feDropShadow.setAttribute('stdDeviation', "" + (shadowBlur || 0) / 4);
|
|
3620
3229
|
} else if (name === 'shadowOffsetX') {
|
|
3621
|
-
_$feDropShadow.setAttribute('dx', ""
|
|
3230
|
+
_$feDropShadow.setAttribute('dx', "" + (shadowOffsetX || 0) / 2);
|
|
3622
3231
|
} else if (name === 'shadowOffsetY') {
|
|
3623
|
-
_$feDropShadow.setAttribute('dy', ""
|
|
3232
|
+
_$feDropShadow.setAttribute('dy', "" + (shadowOffsetY || 0) / 2);
|
|
3624
3233
|
}
|
|
3625
3234
|
}
|
|
3626
3235
|
}
|
|
3627
3236
|
var urlRegexp = /url\("?#(.*)\)/;
|
|
3628
3237
|
var DefElementManager = /*#__PURE__*/function () {
|
|
3629
3238
|
function DefElementManager(context) {
|
|
3630
|
-
_classCallCheck$2(this, DefElementManager);
|
|
3631
3239
|
this.context = void 0;
|
|
3632
3240
|
this.$def = void 0;
|
|
3633
3241
|
this.gradientCache = {};
|
|
@@ -3636,124 +3244,106 @@
|
|
|
3636
3244
|
/**
|
|
3637
3245
|
* container for <gradient> <clipPath>...
|
|
3638
3246
|
*/
|
|
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
|
-
}
|
|
3247
|
+
var _proto = DefElementManager.prototype;
|
|
3248
|
+
_proto.getDefElement = function getDefElement() {
|
|
3249
|
+
return this.$def;
|
|
3250
|
+
};
|
|
3251
|
+
_proto.init = function init() {
|
|
3252
|
+
var document = this.context.config.document;
|
|
3253
|
+
var $svg = this.context.contextService.getContext();
|
|
3254
|
+
this.$def = createSVGElement('defs', document);
|
|
3255
|
+
$svg.appendChild(this.$def);
|
|
3256
|
+
};
|
|
3257
|
+
_proto.clear = function clear(entity) {
|
|
3258
|
+
var _this = this;
|
|
3259
|
+
Object.keys(this.gradientCache).forEach(function (id) {
|
|
3260
|
+
_this.clearUnusedDefElement(_this.gradientCache, id, entity);
|
|
3261
|
+
});
|
|
3262
|
+
};
|
|
3263
|
+
_proto.clearUnusedDefElement = function clearUnusedDefElement(cache, id, entity) {
|
|
3264
|
+
if (cache[id] && cache[id].size === 1 && cache[id].has(entity)) {
|
|
3265
|
+
var targetElement = this.$def.querySelector("#" + id);
|
|
3266
|
+
if (targetElement) {
|
|
3267
|
+
this.$def.removeChild(targetElement);
|
|
3668
3268
|
}
|
|
3669
3269
|
}
|
|
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);
|
|
3270
|
+
};
|
|
3271
|
+
_proto.createOrUpdateGradientAndPattern = function createOrUpdateGradientAndPattern$1(object, $el, parsedColor, name, plugin) {
|
|
3272
|
+
var _this$context$config = this.context.config,
|
|
3273
|
+
doc = _this$context$config.document,
|
|
3274
|
+
createImage = _this$context$config.createImage;
|
|
3275
|
+
if ($el) {
|
|
3276
|
+
var attributeValue = '';
|
|
3277
|
+
if (gLite.isPattern(parsedColor)) {
|
|
3278
|
+
// `fill: url(#${patternId})`
|
|
3279
|
+
attributeValue = $el.style[name];
|
|
3280
|
+
} else {
|
|
3281
|
+
// `url(#${gradientId})`
|
|
3282
|
+
attributeValue = $el.getAttribute(name) || '';
|
|
3283
|
+
}
|
|
3284
|
+
var matches = attributeValue.match(urlRegexp);
|
|
3285
|
+
if (matches && matches.length > 1) {
|
|
3286
|
+
this.clearUnusedDefElement(this.gradientCache, matches[1].replace('"', ''), object.entity);
|
|
3287
|
+
}
|
|
3288
|
+
var newDefElementId = createOrUpdateGradientAndPattern(doc || document, this.$def, object, $el, parsedColor, name, createImage, plugin);
|
|
3289
|
+
if (newDefElementId) {
|
|
3290
|
+
if (!this.gradientCache[newDefElementId]) {
|
|
3291
|
+
this.gradientCache[newDefElementId] = new Set();
|
|
3695
3292
|
}
|
|
3293
|
+
this.gradientCache[newDefElementId].add(object.entity);
|
|
3696
3294
|
}
|
|
3697
3295
|
}
|
|
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
|
-
}]);
|
|
3296
|
+
};
|
|
3297
|
+
_proto.createOrUpdateShadow = function createOrUpdateShadow$1(object, $el, name) {
|
|
3298
|
+
var doc = this.context.config.document;
|
|
3299
|
+
createOrUpdateShadow(doc || document, this.$def, object, $el, name);
|
|
3300
|
+
};
|
|
3301
|
+
_proto.createOrUpdateFilter = function createOrUpdateFilter$1(object, $el, filters) {
|
|
3302
|
+
var doc = this.context.config.document;
|
|
3303
|
+
createOrUpdateFilter(doc || document, this.$def, object, $el, filters);
|
|
3304
|
+
};
|
|
3711
3305
|
return DefElementManager;
|
|
3712
3306
|
}();
|
|
3713
3307
|
var Plugin$1 = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
function Plugin() {
|
|
3308
|
+
_inheritsLoose$2(Plugin, _AbstractRendererPlug);
|
|
3309
|
+
function Plugin(options) {
|
|
3717
3310
|
var _this;
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3311
|
+
if (options === void 0) {
|
|
3312
|
+
options = {};
|
|
3313
|
+
}
|
|
3314
|
+
_this = _AbstractRendererPlug.call(this) || this;
|
|
3721
3315
|
_this.options = void 0;
|
|
3722
3316
|
_this.name = 'svg-renderer';
|
|
3723
3317
|
_this.options = options;
|
|
3724
3318
|
return _this;
|
|
3725
3319
|
}
|
|
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
|
-
}]);
|
|
3320
|
+
var _proto = Plugin.prototype;
|
|
3321
|
+
_proto.init = function init() {
|
|
3322
|
+
var _this$options = this.options,
|
|
3323
|
+
outputSVGElementId = _this$options.outputSVGElementId,
|
|
3324
|
+
outputSVGElementName = _this$options.outputSVGElementName;
|
|
3325
|
+
var defElementManager = new DefElementManager(this.context);
|
|
3326
|
+
// default implementation
|
|
3327
|
+
var defaultElementLifeCycleContribution = new DefaultElementLifeCycleContribution(this.context);
|
|
3328
|
+
// @ts-ignore
|
|
3329
|
+
this.context.defaultElementLifeCycleContribution = defaultElementLifeCycleContribution;
|
|
3330
|
+
// @ts-ignore
|
|
3331
|
+
this.context.SVGElementLifeCycleContribution = defaultElementLifeCycleContribution;
|
|
3332
|
+
var SVGRendererPluginOptions = {
|
|
3333
|
+
outputSVGElementId: !isNil(outputSVGElementId) ? !!outputSVGElementId : true,
|
|
3334
|
+
outputSVGElementName: !isNil(outputSVGElementName) ? !!outputSVGElementName : true
|
|
3335
|
+
};
|
|
3336
|
+
this.addRenderingPlugin(
|
|
3337
|
+
// @ts-ignore
|
|
3338
|
+
new SVGRendererPlugin(SVGRendererPluginOptions, defElementManager, this.context));
|
|
3339
|
+
};
|
|
3340
|
+
_proto.destroy = function destroy() {
|
|
3341
|
+
this.removeAllRenderingPlugins();
|
|
3342
|
+
// @ts-ignore
|
|
3343
|
+
delete this.context.defaultElementLifeCycleContribution;
|
|
3344
|
+
// @ts-ignore
|
|
3345
|
+
delete this.context.SVGElementLifeCycleContribution;
|
|
3346
|
+
};
|
|
3757
3347
|
return Plugin;
|
|
3758
3348
|
}(gLite.AbstractRendererPlugin);
|
|
3759
3349
|
|
|
@@ -3855,7 +3445,7 @@
|
|
|
3855
3445
|
if ("throw" !== record.type) {
|
|
3856
3446
|
var result = record.arg,
|
|
3857
3447
|
value = result.value;
|
|
3858
|
-
return value && "object" ==
|
|
3448
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
3859
3449
|
invoke("next", value, resolve, reject);
|
|
3860
3450
|
}, function (err) {
|
|
3861
3451
|
invoke("throw", err, resolve, reject);
|
|
@@ -4116,49 +3706,10 @@
|
|
|
4116
3706
|
});
|
|
4117
3707
|
};
|
|
4118
3708
|
}
|
|
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);
|
|
3709
|
+
function _inheritsLoose$3(subClass, superClass) {
|
|
3710
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
3711
|
+
subClass.prototype.constructor = subClass;
|
|
3712
|
+
_setPrototypeOf$3(subClass, superClass);
|
|
4162
3713
|
}
|
|
4163
3714
|
function _setPrototypeOf$3(o, p) {
|
|
4164
3715
|
_setPrototypeOf$3 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -4167,124 +3718,38 @@
|
|
|
4167
3718
|
};
|
|
4168
3719
|
return _setPrototypeOf$3(o, p);
|
|
4169
3720
|
}
|
|
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) {
|
|
3721
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
4210
3722
|
if (!o) return;
|
|
4211
|
-
if (typeof o === "string") return _arrayLikeToArray
|
|
3723
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
4212
3724
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
4213
3725
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
4214
3726
|
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
|
|
3727
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
4216
3728
|
}
|
|
4217
|
-
function _arrayLikeToArray
|
|
3729
|
+
function _arrayLikeToArray(arr, len) {
|
|
4218
3730
|
if (len == null || len > arr.length) len = arr.length;
|
|
4219
3731
|
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
4220
3732
|
arr2[i] = arr[i];
|
|
4221
3733
|
}
|
|
4222
3734
|
return arr2;
|
|
4223
3735
|
}
|
|
4224
|
-
function
|
|
3736
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
4225
3737
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
4226
|
-
if (
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
3738
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
3739
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
3740
|
+
if (it) o = it;
|
|
3741
|
+
var i = 0;
|
|
3742
|
+
return function () {
|
|
3743
|
+
if (i >= o.length) return {
|
|
3744
|
+
done: true
|
|
3745
|
+
};
|
|
4231
3746
|
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
|
|
3747
|
+
done: false,
|
|
3748
|
+
value: o[i++]
|
|
4246
3749
|
};
|
|
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.");
|
|
3750
|
+
};
|
|
4282
3751
|
}
|
|
4283
|
-
|
|
4284
|
-
}
|
|
4285
|
-
function _toPropertyKey$3(arg) {
|
|
4286
|
-
var key = _toPrimitive$3(arg, "string");
|
|
4287
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
3752
|
+
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
3753
|
}
|
|
4289
3754
|
|
|
4290
3755
|
/**
|
|
@@ -4294,106 +3759,86 @@
|
|
|
4294
3759
|
* 2. use elementFromPoint
|
|
4295
3760
|
*/
|
|
4296
3761
|
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
|
-
}
|
|
3762
|
+
function SVGPickerPlugin() {}
|
|
3763
|
+
var _proto = SVGPickerPlugin.prototype;
|
|
3764
|
+
_proto.apply = function apply(context) {
|
|
3765
|
+
var _this = this;
|
|
3766
|
+
var doc = context.config.document,
|
|
3767
|
+
renderingService = context.renderingService;
|
|
3768
|
+
renderingService.hooks.pick.tapPromise(SVGPickerPlugin.tag, /*#__PURE__*/function () {
|
|
3769
|
+
var _ref = _asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee(result) {
|
|
3770
|
+
return _regeneratorRuntime$3().wrap(function _callee$(_context) {
|
|
3771
|
+
while (1) {
|
|
3772
|
+
switch (_context.prev = _context.next) {
|
|
3773
|
+
case 0:
|
|
3774
|
+
return _context.abrupt("return", _this.pick(doc, result));
|
|
3775
|
+
case 1:
|
|
3776
|
+
case "end":
|
|
3777
|
+
return _context.stop();
|
|
4317
3778
|
}
|
|
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
|
-
}
|
|
3779
|
+
}
|
|
3780
|
+
}, _callee);
|
|
3781
|
+
}));
|
|
3782
|
+
return function (_x) {
|
|
3783
|
+
return _ref.apply(this, arguments);
|
|
3784
|
+
};
|
|
3785
|
+
}());
|
|
3786
|
+
renderingService.hooks.pickSync.tap(SVGPickerPlugin.tag, function (result) {
|
|
3787
|
+
return _this.pick(doc, result);
|
|
3788
|
+
});
|
|
3789
|
+
};
|
|
3790
|
+
_proto.pick = function pick(doc, result) {
|
|
3791
|
+
var topmost = result.topmost,
|
|
3792
|
+
_result$position = result.position,
|
|
3793
|
+
clientX = _result$position.clientX,
|
|
3794
|
+
clientY = _result$position.clientY;
|
|
3795
|
+
try {
|
|
3796
|
+
var targets = [];
|
|
3797
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
|
|
3798
|
+
for (var _iterator = _createForOfIteratorHelperLoose((doc || document).elementsFromPoint(clientX, clientY)), _step; !(_step = _iterator()).done;) {
|
|
3799
|
+
var element = _step.value;
|
|
3800
|
+
// eg. g_svg_circle_345
|
|
3801
|
+
var id = element && element.getAttribute('id');
|
|
3802
|
+
if (id && id.startsWith(G_SVG_PREFIX)) {
|
|
3803
|
+
var index = id.lastIndexOf('-');
|
|
3804
|
+
var target = gLite.runtime.displayObjectPool.getByEntity(id.substring(index + 1));
|
|
3805
|
+
// don't need to account for `visibility` since DOM API already does
|
|
3806
|
+
if (target && target.isInteractive()) {
|
|
3807
|
+
targets.push(target);
|
|
3808
|
+
if (topmost) {
|
|
3809
|
+
result.picked = targets;
|
|
3810
|
+
return result;
|
|
4356
3811
|
}
|
|
4357
3812
|
}
|
|
4358
|
-
} catch (err) {
|
|
4359
|
-
_iterator.e(err);
|
|
4360
|
-
} finally {
|
|
4361
|
-
_iterator.f();
|
|
4362
3813
|
}
|
|
4363
|
-
result.picked = targets;
|
|
4364
|
-
} catch (e) {
|
|
4365
|
-
result.picked = [];
|
|
4366
3814
|
}
|
|
4367
|
-
|
|
3815
|
+
result.picked = targets;
|
|
3816
|
+
} catch (e) {
|
|
3817
|
+
result.picked = [];
|
|
4368
3818
|
}
|
|
4369
|
-
|
|
3819
|
+
return result;
|
|
3820
|
+
};
|
|
4370
3821
|
return SVGPickerPlugin;
|
|
4371
3822
|
}();
|
|
4372
3823
|
SVGPickerPlugin.tag = 'SVGPicker';
|
|
4373
3824
|
var Plugin$2 = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
4374
|
-
|
|
4375
|
-
var _super = _createSuper$3(Plugin);
|
|
3825
|
+
_inheritsLoose$3(Plugin, _AbstractRendererPlug);
|
|
4376
3826
|
function Plugin() {
|
|
4377
3827
|
var _this;
|
|
4378
|
-
_classCallCheck$3(this, Plugin);
|
|
4379
3828
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4380
3829
|
args[_key] = arguments[_key];
|
|
4381
3830
|
}
|
|
4382
|
-
_this =
|
|
3831
|
+
_this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
|
|
4383
3832
|
_this.name = 'svg-picker';
|
|
4384
3833
|
return _this;
|
|
4385
3834
|
}
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
value: function destroy() {
|
|
4394
|
-
this.removeAllRenderingPlugins();
|
|
4395
|
-
}
|
|
4396
|
-
}]);
|
|
3835
|
+
var _proto = Plugin.prototype;
|
|
3836
|
+
_proto.init = function init() {
|
|
3837
|
+
this.addRenderingPlugin(new SVGPickerPlugin());
|
|
3838
|
+
};
|
|
3839
|
+
_proto.destroy = function destroy() {
|
|
3840
|
+
this.removeAllRenderingPlugins();
|
|
3841
|
+
};
|
|
4397
3842
|
return Plugin;
|
|
4398
3843
|
}(gLite.AbstractRendererPlugin);
|
|
4399
3844
|
|
|
@@ -4404,163 +3849,137 @@
|
|
|
4404
3849
|
|
|
4405
3850
|
var SVGContextService = /*#__PURE__*/function () {
|
|
4406
3851
|
function SVGContextService(context) {
|
|
4407
|
-
_classCallCheck(this, SVGContextService);
|
|
4408
3852
|
this.$container = void 0;
|
|
4409
3853
|
this.$namespace = void 0;
|
|
4410
3854
|
this.dpr = void 0;
|
|
4411
3855
|
this.canvasConfig = void 0;
|
|
4412
3856
|
this.canvasConfig = context.config;
|
|
4413
3857
|
}
|
|
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;
|
|
3858
|
+
var _proto = SVGContextService.prototype;
|
|
3859
|
+
_proto.init = /*#__PURE__*/function () {
|
|
3860
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
3861
|
+
var _this$canvasConfig, container, doc, devicePixelRatio, $namespace, dpr;
|
|
3862
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
3863
|
+
while (1) {
|
|
3864
|
+
switch (_context.prev = _context.next) {
|
|
3865
|
+
case 0:
|
|
3866
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document, devicePixelRatio = _this$canvasConfig.devicePixelRatio; // create container
|
|
3867
|
+
this.$container = isString(container) ? (doc || document).getElementById(container) : container;
|
|
3868
|
+
if (this.$container) {
|
|
3869
|
+
if (!this.$container.style.position) {
|
|
3870
|
+
this.$container.style.position = 'relative';
|
|
4434
3871
|
}
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
this.
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
3872
|
+
$namespace = createSVGElement('svg', doc);
|
|
3873
|
+
$namespace.setAttribute('width', "" + this.canvasConfig.width);
|
|
3874
|
+
$namespace.setAttribute('height', "" + this.canvasConfig.height);
|
|
3875
|
+
this.$container.appendChild($namespace);
|
|
3876
|
+
this.$namespace = $namespace;
|
|
3877
|
+
}
|
|
3878
|
+
// use user-defined dpr first
|
|
3879
|
+
dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
|
|
3880
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
3881
|
+
this.dpr = dpr;
|
|
3882
|
+
case 6:
|
|
3883
|
+
case "end":
|
|
3884
|
+
return _context.stop();
|
|
4443
3885
|
}
|
|
4444
|
-
}
|
|
4445
|
-
})
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
}
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
}
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
|
|
4471
|
-
}
|
|
4472
|
-
}, {
|
|
4473
|
-
key: "destroy",
|
|
4474
|
-
value: function destroy() {
|
|
4475
|
-
// destroy context
|
|
4476
|
-
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
4477
|
-
this.$container.removeChild(this.$namespace);
|
|
4478
|
-
}
|
|
3886
|
+
}
|
|
3887
|
+
}, _callee, this);
|
|
3888
|
+
}));
|
|
3889
|
+
function init() {
|
|
3890
|
+
return _init.apply(this, arguments);
|
|
3891
|
+
}
|
|
3892
|
+
return init;
|
|
3893
|
+
}() // @ts-ignore
|
|
3894
|
+
;
|
|
3895
|
+
_proto.getDomElement = function getDomElement() {
|
|
3896
|
+
return this.$namespace;
|
|
3897
|
+
};
|
|
3898
|
+
_proto.getContext = function getContext() {
|
|
3899
|
+
return this.$namespace;
|
|
3900
|
+
};
|
|
3901
|
+
_proto.getDPR = function getDPR() {
|
|
3902
|
+
return this.dpr;
|
|
3903
|
+
};
|
|
3904
|
+
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
3905
|
+
var _this$$namespace;
|
|
3906
|
+
return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
|
|
3907
|
+
};
|
|
3908
|
+
_proto.destroy = function destroy() {
|
|
3909
|
+
// destroy context
|
|
3910
|
+
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
3911
|
+
this.$container.removeChild(this.$namespace);
|
|
4479
3912
|
}
|
|
4480
|
-
}
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
this.$namespace.setAttribute('height', "".concat(height));
|
|
4487
|
-
}
|
|
3913
|
+
};
|
|
3914
|
+
_proto.resize = function resize(width, height) {
|
|
3915
|
+
// SVG should ignore DPR
|
|
3916
|
+
if (this.$namespace) {
|
|
3917
|
+
this.$namespace.setAttribute('width', "" + width);
|
|
3918
|
+
this.$namespace.setAttribute('height', "" + height);
|
|
4488
3919
|
}
|
|
4489
|
-
}
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
this.$container.style.cursor = cursor;
|
|
4494
|
-
}
|
|
3920
|
+
};
|
|
3921
|
+
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
3922
|
+
if (this.$container) {
|
|
3923
|
+
this.$container.style.cursor = cursor;
|
|
4495
3924
|
}
|
|
4496
|
-
}
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
var
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
case 6:
|
|
4513
|
-
case "end":
|
|
4514
|
-
return _context2.stop();
|
|
4515
|
-
}
|
|
3925
|
+
};
|
|
3926
|
+
_proto.toDataURL = /*#__PURE__*/function () {
|
|
3927
|
+
var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
3928
|
+
var cloneNode, svgDocType, svgDoc;
|
|
3929
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
3930
|
+
while (1) {
|
|
3931
|
+
switch (_context2.prev = _context2.next) {
|
|
3932
|
+
case 0:
|
|
3933
|
+
cloneNode = this.$namespace.cloneNode(true);
|
|
3934
|
+
svgDocType = document.implementation.createDocumentType('svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
|
|
3935
|
+
svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', svgDocType);
|
|
3936
|
+
svgDoc.replaceChild(cloneNode, svgDoc.documentElement);
|
|
3937
|
+
return _context2.abrupt("return", "data:image/svg+xml;charset=utf8," + encodeURIComponent(new XMLSerializer().serializeToString(svgDoc)));
|
|
3938
|
+
case 6:
|
|
3939
|
+
case "end":
|
|
3940
|
+
return _context2.stop();
|
|
4516
3941
|
}
|
|
4517
|
-
}
|
|
4518
|
-
})
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
}
|
|
3942
|
+
}
|
|
3943
|
+
}, _callee2, this);
|
|
3944
|
+
}));
|
|
3945
|
+
function toDataURL(_x) {
|
|
3946
|
+
return _toDataURL.apply(this, arguments);
|
|
3947
|
+
}
|
|
3948
|
+
return toDataURL;
|
|
3949
|
+
}();
|
|
4525
3950
|
return SVGContextService;
|
|
4526
3951
|
}();
|
|
4527
3952
|
|
|
4528
3953
|
var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
4529
|
-
|
|
4530
|
-
var _super = _createSuper(ContextRegisterPlugin);
|
|
3954
|
+
_inheritsLoose(ContextRegisterPlugin, _AbstractRendererPlug);
|
|
4531
3955
|
function ContextRegisterPlugin() {
|
|
4532
3956
|
var _this;
|
|
4533
|
-
_classCallCheck(this, ContextRegisterPlugin);
|
|
4534
3957
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4535
3958
|
args[_key] = arguments[_key];
|
|
4536
3959
|
}
|
|
4537
|
-
_this =
|
|
3960
|
+
_this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
|
|
4538
3961
|
_this.name = 'svg-context-register';
|
|
4539
3962
|
return _this;
|
|
4540
3963
|
}
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
value: function destroy() {
|
|
4550
|
-
delete this.context.ContextService;
|
|
4551
|
-
}
|
|
4552
|
-
}]);
|
|
3964
|
+
var _proto = ContextRegisterPlugin.prototype;
|
|
3965
|
+
_proto.init = function init() {
|
|
3966
|
+
// @ts-ignore
|
|
3967
|
+
this.context.ContextService = SVGContextService;
|
|
3968
|
+
};
|
|
3969
|
+
_proto.destroy = function destroy() {
|
|
3970
|
+
delete this.context.ContextService;
|
|
3971
|
+
};
|
|
4553
3972
|
return ContextRegisterPlugin;
|
|
4554
3973
|
}(gLite.AbstractRendererPlugin);
|
|
4555
3974
|
|
|
4556
3975
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
function Renderer() {
|
|
3976
|
+
_inheritsLoose(Renderer, _AbstractRenderer);
|
|
3977
|
+
function Renderer(config) {
|
|
4560
3978
|
var _this;
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
3979
|
+
if (config === void 0) {
|
|
3980
|
+
config = {};
|
|
3981
|
+
}
|
|
3982
|
+
_this = _AbstractRenderer.call(this, config) || this;
|
|
4564
3983
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
4565
3984
|
_this.registerPlugin(new Plugin$1({
|
|
4566
3985
|
outputSVGElementId: config.outputSVGElementId
|
|
@@ -4569,7 +3988,7 @@
|
|
|
4569
3988
|
_this.registerPlugin(new Plugin$2());
|
|
4570
3989
|
return _this;
|
|
4571
3990
|
}
|
|
4572
|
-
return
|
|
3991
|
+
return Renderer;
|
|
4573
3992
|
}(gLite.AbstractRenderer);
|
|
4574
3993
|
|
|
4575
3994
|
exports.DomInteraction = index_esm;
|