@antv/g-svg 1.8.58 → 1.8.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -360,6 +360,184 @@
360
360
  return target;
361
361
  }
362
362
 
363
+ function _inheritsLoose$1(subClass, superClass) {
364
+ subClass.prototype = Object.create(superClass.prototype);
365
+ subClass.prototype.constructor = subClass;
366
+ _setPrototypeOf$1(subClass, superClass);
367
+ }
368
+ function _setPrototypeOf$1(o, p) {
369
+ _setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
370
+ o.__proto__ = p;
371
+ return o;
372
+ };
373
+ return _setPrototypeOf$1(o, p);
374
+ }
375
+
376
+ // const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
377
+ /**
378
+ * listen to mouse/touch/pointer events on DOM wrapper, trigger pointer events
379
+ */
380
+ var DOMInteractionPlugin = /*#__PURE__*/function () {
381
+ function DOMInteractionPlugin() {
382
+ this.context = void 0;
383
+ }
384
+ var _proto = DOMInteractionPlugin.prototype;
385
+ _proto.apply = function apply(context, runtime) {
386
+ var _this = this;
387
+ var renderingService = context.renderingService,
388
+ renderingContext = context.renderingContext,
389
+ config = context.config;
390
+ this.context = context;
391
+ var canvas = renderingContext.root.ownerDocument.defaultView;
392
+ // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
393
+ var onPointerMove = function onPointerMove(ev) {
394
+ renderingService.hooks.pointerMove.call(ev);
395
+ };
396
+ var onPointerUp = function onPointerUp(ev) {
397
+ renderingService.hooks.pointerUp.call(ev);
398
+ };
399
+ var onPointerDown = function onPointerDown(ev) {
400
+ renderingService.hooks.pointerDown.call(ev);
401
+ };
402
+ var onPointerOver = function onPointerOver(ev) {
403
+ renderingService.hooks.pointerOver.call(ev);
404
+ };
405
+ var onPointerOut = function onPointerOut(ev) {
406
+ renderingService.hooks.pointerOut.call(ev);
407
+ };
408
+ var onPointerCancel = function onPointerCancel(ev) {
409
+ renderingService.hooks.pointerCancel.call(ev);
410
+ };
411
+ var onPointerWheel = function onPointerWheel(ev) {
412
+ renderingService.hooks.pointerWheel.call(ev);
413
+ };
414
+ var onClick = function onClick(ev) {
415
+ renderingService.hooks.click.call(ev);
416
+ };
417
+ var addPointerEventListener = function addPointerEventListener($el) {
418
+ runtime.globalThis.document.addEventListener('pointermove', onPointerMove, true);
419
+ $el.addEventListener('pointerdown', onPointerDown, true);
420
+ $el.addEventListener('pointerleave', onPointerOut, true);
421
+ $el.addEventListener('pointerover', onPointerOver, true);
422
+ runtime.globalThis.addEventListener('pointerup', onPointerUp, true);
423
+ runtime.globalThis.addEventListener('pointercancel', onPointerCancel, true);
424
+ };
425
+ var addTouchEventListener = function addTouchEventListener($el) {
426
+ $el.addEventListener('touchstart', onPointerDown, true);
427
+ $el.addEventListener('touchend', onPointerUp, true);
428
+ $el.addEventListener('touchmove', onPointerMove, true);
429
+ $el.addEventListener('touchcancel', onPointerCancel, true);
430
+ };
431
+ var addMouseEventListener = function addMouseEventListener($el) {
432
+ runtime.globalThis.document.addEventListener('mousemove', onPointerMove, true);
433
+ $el.addEventListener('mousedown', onPointerDown, true);
434
+ $el.addEventListener('mouseout', onPointerOut, true);
435
+ $el.addEventListener('mouseover', onPointerOver, true);
436
+ runtime.globalThis.addEventListener('mouseup', onPointerUp, true);
437
+ };
438
+ var removePointerEventListener = function removePointerEventListener($el) {
439
+ runtime.globalThis.document.removeEventListener('pointermove', onPointerMove, true);
440
+ $el.removeEventListener('pointerdown', onPointerDown, true);
441
+ $el.removeEventListener('pointerleave', onPointerOut, true);
442
+ $el.removeEventListener('pointerover', onPointerOver, true);
443
+ runtime.globalThis.removeEventListener('pointerup', onPointerUp, true);
444
+ };
445
+ var removeTouchEventListener = function removeTouchEventListener($el) {
446
+ $el.removeEventListener('touchstart', onPointerDown, true);
447
+ $el.removeEventListener('touchend', onPointerUp, true);
448
+ $el.removeEventListener('touchmove', onPointerMove, true);
449
+ $el.removeEventListener('touchcancel', onPointerCancel, true);
450
+ };
451
+ var removeMouseEventListener = function removeMouseEventListener($el) {
452
+ runtime.globalThis.document.removeEventListener('mousemove', onPointerMove, true);
453
+ $el.removeEventListener('mousedown', onPointerDown, true);
454
+ $el.removeEventListener('mouseout', onPointerOut, true);
455
+ $el.removeEventListener('mouseover', onPointerOver, true);
456
+ runtime.globalThis.removeEventListener('mouseup', onPointerUp, true);
457
+ };
458
+ renderingService.hooks.init.tap(DOMInteractionPlugin.tag, function () {
459
+ var $el = _this.context.contextService.getDomElement();
460
+ // @ts-ignore
461
+ if (runtime.globalThis.navigator.msPointerEnabled) {
462
+ // @ts-ignore
463
+ $el.style.msContentZooming = 'none';
464
+ // @ts-ignore
465
+ $el.style.msTouchAction = 'none';
466
+ } else if (canvas.supportsPointerEvents) {
467
+ $el.style.touchAction = 'none';
468
+ }
469
+ if (canvas.supportsPointerEvents) {
470
+ addPointerEventListener($el);
471
+ } else {
472
+ addMouseEventListener($el);
473
+ }
474
+ if (canvas.supportsTouchEvents) {
475
+ addTouchEventListener($el);
476
+ }
477
+ if (config.useNativeClickEvent) {
478
+ $el.addEventListener('click', onClick, true);
479
+ }
480
+ // use passive event listeners
481
+ // @see https://zhuanlan.zhihu.com/p/24555031
482
+ $el.addEventListener('wheel', onPointerWheel, {
483
+ passive: true,
484
+ capture: true
485
+ });
486
+ });
487
+ renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () {
488
+ var $el = _this.context.contextService.getDomElement();
489
+ // @ts-ignore
490
+ if (runtime.globalThis.navigator.msPointerEnabled) {
491
+ // @ts-ignore
492
+ $el.style.msContentZooming = '';
493
+ // @ts-ignore
494
+ $el.style.msTouchAction = '';
495
+ } else if (canvas.supportsPointerEvents) {
496
+ $el.style.touchAction = '';
497
+ }
498
+ if (canvas.supportsPointerEvents) {
499
+ removePointerEventListener($el);
500
+ } else {
501
+ removeMouseEventListener($el);
502
+ }
503
+ if (canvas.supportsTouchEvents) {
504
+ removeTouchEventListener($el);
505
+ }
506
+ if (config.useNativeClickEvent) {
507
+ $el.removeEventListener('click', onClick, true);
508
+ }
509
+ $el.removeEventListener('wheel', onPointerWheel, true);
510
+ });
511
+ };
512
+ return DOMInteractionPlugin;
513
+ }();
514
+ DOMInteractionPlugin.tag = 'DOMInteraction';
515
+ var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
516
+ _inheritsLoose$1(Plugin, _AbstractRendererPlug);
517
+ function Plugin() {
518
+ var _this;
519
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
520
+ args[_key] = arguments[_key];
521
+ }
522
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
523
+ _this.name = 'dom-interaction';
524
+ return _this;
525
+ }
526
+ var _proto = Plugin.prototype;
527
+ _proto.init = function init() {
528
+ this.addRenderingPlugin(new DOMInteractionPlugin());
529
+ };
530
+ _proto.destroy = function destroy() {
531
+ this.removeAllRenderingPlugins();
532
+ };
533
+ return Plugin;
534
+ }(gLite.AbstractRendererPlugin);
535
+
536
+ var index_esm = /*#__PURE__*/Object.freeze({
537
+ __proto__: null,
538
+ Plugin: Plugin
539
+ });
540
+
363
541
  function _regeneratorRuntime$1() {
364
542
  _regeneratorRuntime$1 = function _regeneratorRuntime() {
365
543
  return exports;
@@ -691,1128 +869,280 @@
691
869
  });
692
870
  };
693
871
  }
694
- function _inheritsLoose$1(subClass, superClass) {
872
+ function _inheritsLoose$2(subClass, superClass) {
695
873
  subClass.prototype = Object.create(superClass.prototype);
696
874
  subClass.prototype.constructor = subClass;
697
- _setPrototypeOf$1(subClass, superClass);
875
+ _setPrototypeOf$2(subClass, superClass);
698
876
  }
699
- function _setPrototypeOf$1(o, p) {
700
- _setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
877
+ function _setPrototypeOf$2(o, p) {
878
+ _setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
701
879
  o.__proto__ = p;
702
880
  return o;
703
881
  };
704
- return _setPrototypeOf$1(o, p);
882
+ return _setPrototypeOf$2(o, p);
883
+ }
884
+ function _unsupportedIterableToArray(o, minLen) {
885
+ if (!o) return;
886
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
887
+ var n = Object.prototype.toString.call(o).slice(8, -1);
888
+ if (n === "Object" && o.constructor) n = o.constructor.name;
889
+ if (n === "Map" || n === "Set") return Array.from(o);
890
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
891
+ }
892
+ function _arrayLikeToArray(arr, len) {
893
+ if (len == null || len > arr.length) len = arr.length;
894
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
895
+ return arr2;
896
+ }
897
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
898
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
899
+ if (it) return (it = it.call(o)).next.bind(it);
900
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
901
+ if (it) o = it;
902
+ var i = 0;
903
+ return function () {
904
+ if (i >= o.length) return {
905
+ done: true
906
+ };
907
+ return {
908
+ done: false,
909
+ value: o[i++]
910
+ };
911
+ };
912
+ }
913
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
705
914
  }
706
915
 
707
- // const MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
708
916
  /**
709
- * listen to mouse/touch/pointer events on DOM wrapper, trigger pointer events
917
+ * pick shape(s) with Mouse/Touch event
918
+ *
919
+ * 1. find AABB with r-tree
920
+ * 2. use elementFromPoint
710
921
  */
711
- var DOMInteractionPlugin = /*#__PURE__*/function () {
712
- function DOMInteractionPlugin() {
713
- this.context = void 0;
714
- }
715
- var _proto = DOMInteractionPlugin.prototype;
922
+ var SVGPickerPlugin = /*#__PURE__*/function () {
923
+ function SVGPickerPlugin() {}
924
+ var _proto = SVGPickerPlugin.prototype;
716
925
  _proto.apply = function apply(context, runtime) {
717
926
  var _this = this;
718
- var renderingService = context.renderingService,
719
- renderingContext = context.renderingContext,
720
- config = context.config;
721
- this.context = context;
722
- var canvas = renderingContext.root.ownerDocument.defaultView;
723
- // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
724
- var onPointerMove = function onPointerMove(ev) {
725
- renderingService.hooks.pointerMove.call(ev);
726
- };
727
- var onPointerUp = function onPointerUp(ev) {
728
- renderingService.hooks.pointerUp.call(ev);
729
- };
730
- var onPointerDown = function onPointerDown(ev) {
731
- renderingService.hooks.pointerDown.call(ev);
732
- };
733
- var onPointerOver = function onPointerOver(ev) {
734
- renderingService.hooks.pointerOver.call(ev);
735
- };
736
- var onPointerOut = function onPointerOut(ev) {
737
- renderingService.hooks.pointerOut.call(ev);
738
- };
739
- var onPointerCancel = function onPointerCancel(ev) {
740
- renderingService.hooks.pointerCancel.call(ev);
741
- };
742
- var onPointerWheel = function onPointerWheel(ev) {
743
- renderingService.hooks.pointerWheel.call(ev);
744
- };
745
- var onClick = function onClick(ev) {
746
- renderingService.hooks.click.call(ev);
747
- };
748
- var addPointerEventListener = function addPointerEventListener($el) {
749
- runtime.globalThis.document.addEventListener('pointermove', onPointerMove, true);
750
- $el.addEventListener('pointerdown', onPointerDown, true);
751
- $el.addEventListener('pointerleave', onPointerOut, true);
752
- $el.addEventListener('pointerover', onPointerOver, true);
753
- runtime.globalThis.addEventListener('pointerup', onPointerUp, true);
754
- runtime.globalThis.addEventListener('pointercancel', onPointerCancel, true);
755
- };
756
- var addTouchEventListener = function addTouchEventListener($el) {
757
- $el.addEventListener('touchstart', onPointerDown, true);
758
- $el.addEventListener('touchend', onPointerUp, true);
759
- $el.addEventListener('touchmove', onPointerMove, true);
760
- $el.addEventListener('touchcancel', onPointerCancel, true);
761
- };
762
- var addMouseEventListener = function addMouseEventListener($el) {
763
- runtime.globalThis.document.addEventListener('mousemove', onPointerMove, true);
764
- $el.addEventListener('mousedown', onPointerDown, true);
765
- $el.addEventListener('mouseout', onPointerOut, true);
766
- $el.addEventListener('mouseover', onPointerOver, true);
767
- runtime.globalThis.addEventListener('mouseup', onPointerUp, true);
768
- };
769
- var removePointerEventListener = function removePointerEventListener($el) {
770
- runtime.globalThis.document.removeEventListener('pointermove', onPointerMove, true);
771
- $el.removeEventListener('pointerdown', onPointerDown, true);
772
- $el.removeEventListener('pointerleave', onPointerOut, true);
773
- $el.removeEventListener('pointerover', onPointerOver, true);
774
- runtime.globalThis.removeEventListener('pointerup', onPointerUp, true);
775
- };
776
- var removeTouchEventListener = function removeTouchEventListener($el) {
777
- $el.removeEventListener('touchstart', onPointerDown, true);
778
- $el.removeEventListener('touchend', onPointerUp, true);
779
- $el.removeEventListener('touchmove', onPointerMove, true);
780
- $el.removeEventListener('touchcancel', onPointerCancel, true);
781
- };
782
- var removeMouseEventListener = function removeMouseEventListener($el) {
783
- runtime.globalThis.document.removeEventListener('mousemove', onPointerMove, true);
784
- $el.removeEventListener('mousedown', onPointerDown, true);
785
- $el.removeEventListener('mouseout', onPointerOut, true);
786
- $el.removeEventListener('mouseover', onPointerOver, true);
787
- runtime.globalThis.removeEventListener('mouseup', onPointerUp, true);
788
- };
789
- renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
790
- var $el;
791
- return _regeneratorRuntime$1().wrap(function _callee$(_context) {
792
- while (1) switch (_context.prev = _context.next) {
793
- case 0:
794
- $el = _this.context.contextService.getDomElement(); // @ts-ignore
795
- if (runtime.globalThis.navigator.msPointerEnabled) {
796
- // @ts-ignore
797
- $el.style.msContentZooming = 'none';
798
- // @ts-ignore
799
- $el.style.msTouchAction = 'none';
800
- } else if (canvas.supportsPointerEvents) {
801
- $el.style.touchAction = 'none';
802
- }
803
- if (canvas.supportsPointerEvents) {
804
- addPointerEventListener($el);
805
- } else {
806
- addMouseEventListener($el);
807
- }
808
- if (canvas.supportsTouchEvents) {
809
- addTouchEventListener($el);
810
- }
811
- if (config.useNativeClickEvent) {
812
- $el.addEventListener('click', onClick, true);
813
- }
814
- // use passive event listeners
815
- // @see https://zhuanlan.zhihu.com/p/24555031
816
- $el.addEventListener('wheel', onPointerWheel, {
817
- passive: true,
818
- capture: true
819
- });
820
- case 6:
821
- case "end":
822
- return _context.stop();
823
- }
824
- }, _callee);
825
- })));
826
- renderingService.hooks.destroy.tap(DOMInteractionPlugin.tag, function () {
827
- var $el = _this.context.contextService.getDomElement();
828
- // @ts-ignore
829
- if (runtime.globalThis.navigator.msPointerEnabled) {
830
- // @ts-ignore
831
- $el.style.msContentZooming = '';
832
- // @ts-ignore
833
- $el.style.msTouchAction = '';
834
- } else if (canvas.supportsPointerEvents) {
835
- $el.style.touchAction = '';
836
- }
837
- if (canvas.supportsPointerEvents) {
838
- removePointerEventListener($el);
839
- } else {
840
- removeMouseEventListener($el);
841
- }
842
- if (canvas.supportsTouchEvents) {
843
- removeTouchEventListener($el);
844
- }
845
- if (config.useNativeClickEvent) {
846
- $el.removeEventListener('click', onClick, true);
847
- }
848
- $el.removeEventListener('wheel', onPointerWheel, true);
849
- });
850
- };
851
- return DOMInteractionPlugin;
852
- }();
853
- DOMInteractionPlugin.tag = 'DOMInteraction';
854
- var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
855
- _inheritsLoose$1(Plugin, _AbstractRendererPlug);
856
- function Plugin() {
857
- var _this;
858
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
859
- args[_key] = arguments[_key];
860
- }
861
- _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
862
- _this.name = 'dom-interaction';
863
- return _this;
864
- }
865
- var _proto = Plugin.prototype;
866
- _proto.init = function init() {
867
- this.addRenderingPlugin(new DOMInteractionPlugin());
868
- };
869
- _proto.destroy = function destroy() {
870
- this.removeAllRenderingPlugins();
871
- };
872
- return Plugin;
873
- }(gLite.AbstractRendererPlugin);
874
-
875
- var index_esm = /*#__PURE__*/Object.freeze({
876
- __proto__: null,
877
- Plugin: Plugin
878
- });
879
-
880
- function _regeneratorRuntime$2() {
881
- _regeneratorRuntime$2 = function _regeneratorRuntime() {
882
- return exports;
883
- };
884
- var exports = {},
885
- Op = Object.prototype,
886
- hasOwn = Op.hasOwnProperty,
887
- defineProperty = Object.defineProperty || function (obj, key, desc) {
888
- obj[key] = desc.value;
889
- },
890
- $Symbol = "function" == typeof Symbol ? Symbol : {},
891
- iteratorSymbol = $Symbol.iterator || "@@iterator",
892
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
893
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
894
- function define(obj, key, value) {
895
- return Object.defineProperty(obj, key, {
896
- value: value,
897
- enumerable: !0,
898
- configurable: !0,
899
- writable: !0
900
- }), obj[key];
901
- }
902
- try {
903
- define({}, "");
904
- } catch (err) {
905
- define = function define(obj, key, value) {
906
- return obj[key] = value;
907
- };
908
- }
909
- function wrap(innerFn, outerFn, self, tryLocsList) {
910
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
911
- generator = Object.create(protoGenerator.prototype),
912
- context = new Context(tryLocsList || []);
913
- return defineProperty(generator, "_invoke", {
914
- value: makeInvokeMethod(innerFn, self, context)
915
- }), generator;
916
- }
917
- function tryCatch(fn, obj, arg) {
918
- try {
919
- return {
920
- type: "normal",
921
- arg: fn.call(obj, arg)
922
- };
923
- } catch (err) {
924
- return {
925
- type: "throw",
926
- arg: err
927
- };
928
- }
929
- }
930
- exports.wrap = wrap;
931
- var ContinueSentinel = {};
932
- function Generator() {}
933
- function GeneratorFunction() {}
934
- function GeneratorFunctionPrototype() {}
935
- var IteratorPrototype = {};
936
- define(IteratorPrototype, iteratorSymbol, function () {
937
- return this;
938
- });
939
- var getProto = Object.getPrototypeOf,
940
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
941
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
942
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
943
- function defineIteratorMethods(prototype) {
944
- ["next", "throw", "return"].forEach(function (method) {
945
- define(prototype, method, function (arg) {
946
- return this._invoke(method, arg);
947
- });
948
- });
949
- }
950
- function AsyncIterator(generator, PromiseImpl) {
951
- function invoke(method, arg, resolve, reject) {
952
- var record = tryCatch(generator[method], generator, arg);
953
- if ("throw" !== record.type) {
954
- var result = record.arg,
955
- value = result.value;
956
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
957
- invoke("next", value, resolve, reject);
958
- }, function (err) {
959
- invoke("throw", err, resolve, reject);
960
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
961
- result.value = unwrapped, resolve(result);
962
- }, function (error) {
963
- return invoke("throw", error, resolve, reject);
964
- });
965
- }
966
- reject(record.arg);
967
- }
968
- var previousPromise;
969
- defineProperty(this, "_invoke", {
970
- value: function value(method, arg) {
971
- function callInvokeWithMethodAndArg() {
972
- return new PromiseImpl(function (resolve, reject) {
973
- invoke(method, arg, resolve, reject);
974
- });
975
- }
976
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
977
- }
978
- });
979
- }
980
- function makeInvokeMethod(innerFn, self, context) {
981
- var state = "suspendedStart";
982
- return function (method, arg) {
983
- if ("executing" === state) throw new Error("Generator is already running");
984
- if ("completed" === state) {
985
- if ("throw" === method) throw arg;
986
- return doneResult();
987
- }
988
- for (context.method = method, context.arg = arg;;) {
989
- var delegate = context.delegate;
990
- if (delegate) {
991
- var delegateResult = maybeInvokeDelegate(delegate, context);
992
- if (delegateResult) {
993
- if (delegateResult === ContinueSentinel) continue;
994
- return delegateResult;
995
- }
996
- }
997
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
998
- if ("suspendedStart" === state) throw state = "completed", context.arg;
999
- context.dispatchException(context.arg);
1000
- } else "return" === context.method && context.abrupt("return", context.arg);
1001
- state = "executing";
1002
- var record = tryCatch(innerFn, self, context);
1003
- if ("normal" === record.type) {
1004
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
1005
- return {
1006
- value: record.arg,
1007
- done: context.done
1008
- };
1009
- }
1010
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
1011
- }
1012
- };
1013
- }
1014
- function maybeInvokeDelegate(delegate, context) {
1015
- var methodName = context.method,
1016
- method = delegate.iterator[methodName];
1017
- if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
1018
- var record = tryCatch(method, delegate.iterator, context.arg);
1019
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
1020
- var info = record.arg;
1021
- return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
1022
- }
1023
- function pushTryEntry(locs) {
1024
- var entry = {
1025
- tryLoc: locs[0]
1026
- };
1027
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
1028
- }
1029
- function resetTryEntry(entry) {
1030
- var record = entry.completion || {};
1031
- record.type = "normal", delete record.arg, entry.completion = record;
1032
- }
1033
- function Context(tryLocsList) {
1034
- this.tryEntries = [{
1035
- tryLoc: "root"
1036
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
1037
- }
1038
- function values(iterable) {
1039
- if (iterable) {
1040
- var iteratorMethod = iterable[iteratorSymbol];
1041
- if (iteratorMethod) return iteratorMethod.call(iterable);
1042
- if ("function" == typeof iterable.next) return iterable;
1043
- if (!isNaN(iterable.length)) {
1044
- var i = -1,
1045
- next = function next() {
1046
- for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
1047
- return next.value = undefined, next.done = !0, next;
1048
- };
1049
- return next.next = next;
1050
- }
1051
- }
1052
- return {
1053
- next: doneResult
1054
- };
1055
- }
1056
- function doneResult() {
1057
- return {
1058
- value: undefined,
1059
- done: !0
1060
- };
1061
- }
1062
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
1063
- value: GeneratorFunctionPrototype,
1064
- configurable: !0
1065
- }), defineProperty(GeneratorFunctionPrototype, "constructor", {
1066
- value: GeneratorFunction,
1067
- configurable: !0
1068
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
1069
- var ctor = "function" == typeof genFun && genFun.constructor;
1070
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
1071
- }, exports.mark = function (genFun) {
1072
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
1073
- }, exports.awrap = function (arg) {
1074
- return {
1075
- __await: arg
1076
- };
1077
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
1078
- return this;
1079
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
1080
- void 0 === PromiseImpl && (PromiseImpl = Promise);
1081
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
1082
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
1083
- return result.done ? result.value : iter.next();
1084
- });
1085
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
1086
- return this;
1087
- }), define(Gp, "toString", function () {
1088
- return "[object Generator]";
1089
- }), exports.keys = function (val) {
1090
- var object = Object(val),
1091
- keys = [];
1092
- for (var key in object) keys.push(key);
1093
- return keys.reverse(), function next() {
1094
- for (; keys.length;) {
1095
- var key = keys.pop();
1096
- if (key in object) return next.value = key, next.done = !1, next;
1097
- }
1098
- return next.done = !0, next;
1099
- };
1100
- }, exports.values = values, Context.prototype = {
1101
- constructor: Context,
1102
- reset: function reset(skipTempReset) {
1103
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
1104
- },
1105
- stop: function stop() {
1106
- this.done = !0;
1107
- var rootRecord = this.tryEntries[0].completion;
1108
- if ("throw" === rootRecord.type) throw rootRecord.arg;
1109
- return this.rval;
1110
- },
1111
- dispatchException: function dispatchException(exception) {
1112
- if (this.done) throw exception;
1113
- var context = this;
1114
- function handle(loc, caught) {
1115
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
1116
- }
1117
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1118
- var entry = this.tryEntries[i],
1119
- record = entry.completion;
1120
- if ("root" === entry.tryLoc) return handle("end");
1121
- if (entry.tryLoc <= this.prev) {
1122
- var hasCatch = hasOwn.call(entry, "catchLoc"),
1123
- hasFinally = hasOwn.call(entry, "finallyLoc");
1124
- if (hasCatch && hasFinally) {
1125
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
1126
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
1127
- } else if (hasCatch) {
1128
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
1129
- } else {
1130
- if (!hasFinally) throw new Error("try statement without catch or finally");
1131
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
1132
- }
1133
- }
1134
- }
1135
- },
1136
- abrupt: function abrupt(type, arg) {
1137
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1138
- var entry = this.tryEntries[i];
1139
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
1140
- var finallyEntry = entry;
1141
- break;
1142
- }
1143
- }
1144
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
1145
- var record = finallyEntry ? finallyEntry.completion : {};
1146
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
1147
- },
1148
- complete: function complete(record, afterLoc) {
1149
- if ("throw" === record.type) throw record.arg;
1150
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
1151
- },
1152
- finish: function finish(finallyLoc) {
1153
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1154
- var entry = this.tryEntries[i];
1155
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
1156
- }
1157
- },
1158
- catch: function _catch(tryLoc) {
1159
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1160
- var entry = this.tryEntries[i];
1161
- if (entry.tryLoc === tryLoc) {
1162
- var record = entry.completion;
1163
- if ("throw" === record.type) {
1164
- var thrown = record.arg;
1165
- resetTryEntry(entry);
1166
- }
1167
- return thrown;
1168
- }
1169
- }
1170
- throw new Error("illegal catch attempt");
1171
- },
1172
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
1173
- return this.delegate = {
1174
- iterator: values(iterable),
1175
- resultName: resultName,
1176
- nextLoc: nextLoc
1177
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
1178
- }
1179
- }, exports;
1180
- }
1181
- function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
1182
- try {
1183
- var info = gen[key](arg);
1184
- var value = info.value;
1185
- } catch (error) {
1186
- reject(error);
1187
- return;
1188
- }
1189
- if (info.done) {
1190
- resolve(value);
1191
- } else {
1192
- Promise.resolve(value).then(_next, _throw);
1193
- }
1194
- }
1195
- function _asyncToGenerator$2(fn) {
1196
- return function () {
1197
- var self = this,
1198
- args = arguments;
1199
- return new Promise(function (resolve, reject) {
1200
- var gen = fn.apply(self, args);
1201
- function _next(value) {
1202
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
1203
- }
1204
- function _throw(err) {
1205
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
1206
- }
1207
- _next(undefined);
1208
- });
1209
- };
1210
- }
1211
- function _inheritsLoose$2(subClass, superClass) {
1212
- subClass.prototype = Object.create(superClass.prototype);
1213
- subClass.prototype.constructor = subClass;
1214
- _setPrototypeOf$2(subClass, superClass);
1215
- }
1216
- function _setPrototypeOf$2(o, p) {
1217
- _setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
1218
- o.__proto__ = p;
1219
- return o;
1220
- };
1221
- return _setPrototypeOf$2(o, p);
1222
- }
1223
- function _unsupportedIterableToArray(o, minLen) {
1224
- if (!o) return;
1225
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
1226
- var n = Object.prototype.toString.call(o).slice(8, -1);
1227
- if (n === "Object" && o.constructor) n = o.constructor.name;
1228
- if (n === "Map" || n === "Set") return Array.from(o);
1229
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
1230
- }
1231
- function _arrayLikeToArray(arr, len) {
1232
- if (len == null || len > arr.length) len = arr.length;
1233
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
1234
- return arr2;
1235
- }
1236
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
1237
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
1238
- if (it) return (it = it.call(o)).next.bind(it);
1239
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
1240
- if (it) o = it;
1241
- var i = 0;
1242
- return function () {
1243
- if (i >= o.length) return {
1244
- done: true
1245
- };
1246
- return {
1247
- done: false,
1248
- value: o[i++]
1249
- };
1250
- };
1251
- }
1252
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1253
- }
1254
-
1255
- /**
1256
- * pick shape(s) with Mouse/Touch event
1257
- *
1258
- * 1. find AABB with r-tree
1259
- * 2. use elementFromPoint
1260
- */
1261
- var SVGPickerPlugin = /*#__PURE__*/function () {
1262
- function SVGPickerPlugin() {}
1263
- var _proto = SVGPickerPlugin.prototype;
1264
- _proto.apply = function apply(context, runtime) {
1265
- var _this = this;
1266
- var doc = context.config.document,
1267
- renderingService = context.renderingService,
1268
- svgElementMap = context.svgElementMap;
1269
- renderingService.hooks.pick.tapPromise(SVGPickerPlugin.tag, /*#__PURE__*/function () {
1270
- var _ref = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee(result) {
1271
- return _regeneratorRuntime$2().wrap(function _callee$(_context) {
1272
- while (1) switch (_context.prev = _context.next) {
1273
- case 0:
1274
- return _context.abrupt("return", _this.pick(svgElementMap, doc, result));
1275
- case 1:
1276
- case "end":
1277
- return _context.stop();
1278
- }
1279
- }, _callee);
1280
- }));
1281
- return function (_x) {
1282
- return _ref.apply(this, arguments);
1283
- };
1284
- }());
1285
- renderingService.hooks.pickSync.tap(SVGPickerPlugin.tag, function (result) {
1286
- return _this.pick(svgElementMap, doc, result);
1287
- });
1288
- };
1289
- _proto.pick = function pick(svgElementMap, doc, result) {
1290
- var topmost = result.topmost,
1291
- _result$position = result.position,
1292
- clientX = _result$position.clientX,
1293
- clientY = _result$position.clientY;
1294
- try {
1295
- var targets = [];
1296
- // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
1297
- for (var _iterator = _createForOfIteratorHelperLoose((doc || document).elementsFromPoint(clientX, clientY)), _step; !(_step = _iterator()).done;) {
1298
- var element = _step.value;
1299
- var target = svgElementMap.get(element);
1300
- // don't need to account for `visibility` since DOM API already does
1301
- if (target && target.isInteractive()) {
1302
- targets.push(target);
1303
- if (topmost) {
1304
- result.picked = targets;
1305
- return result;
1306
- }
1307
- }
1308
- }
1309
- result.picked = targets;
1310
- } catch (e) {
1311
- result.picked = [];
1312
- }
1313
- return result;
1314
- };
1315
- return SVGPickerPlugin;
1316
- }();
1317
- SVGPickerPlugin.tag = 'SVGPicker';
1318
- var Plugin$1 = /*#__PURE__*/function (_AbstractRendererPlug) {
1319
- _inheritsLoose$2(Plugin, _AbstractRendererPlug);
1320
- function Plugin() {
1321
- var _this;
1322
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1323
- args[_key] = arguments[_key];
1324
- }
1325
- _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
1326
- _this.name = 'svg-picker';
1327
- return _this;
1328
- }
1329
- var _proto = Plugin.prototype;
1330
- _proto.init = function init() {
1331
- this.addRenderingPlugin(new SVGPickerPlugin());
1332
- };
1333
- _proto.destroy = function destroy() {
1334
- this.removeAllRenderingPlugins();
1335
- };
1336
- return Plugin;
1337
- }(gLite.AbstractRendererPlugin);
1338
-
1339
- var index_esm$1 = /*#__PURE__*/Object.freeze({
1340
- __proto__: null,
1341
- Plugin: Plugin$1
1342
- });
1343
-
1344
- /**
1345
- * Common utilities
1346
- * @module glMatrix
1347
- */
1348
- var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
1349
- if (!Math.hypot) Math.hypot = function () {
1350
- var y = 0,
1351
- i = arguments.length;
1352
-
1353
- while (i--) {
1354
- y += arguments[i] * arguments[i];
1355
- }
1356
-
1357
- return Math.sqrt(y);
1358
- };
1359
-
1360
- /**
1361
- * 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied.
1362
- * @module mat4
1363
- */
1364
-
1365
- /**
1366
- * Creates a new identity mat4
1367
- *
1368
- * @returns {mat4} a new 4x4 matrix
1369
- */
1370
-
1371
- function create() {
1372
- var out = new ARRAY_TYPE(16);
1373
-
1374
- if (ARRAY_TYPE != Float32Array) {
1375
- out[1] = 0;
1376
- out[2] = 0;
1377
- out[3] = 0;
1378
- out[4] = 0;
1379
- out[6] = 0;
1380
- out[7] = 0;
1381
- out[8] = 0;
1382
- out[9] = 0;
1383
- out[11] = 0;
1384
- out[12] = 0;
1385
- out[13] = 0;
1386
- out[14] = 0;
1387
- }
1388
-
1389
- out[0] = 1;
1390
- out[5] = 1;
1391
- out[10] = 1;
1392
- out[15] = 1;
1393
- return out;
1394
- }
1395
- /**
1396
- * Inverts a mat4
1397
- *
1398
- * @param {mat4} out the receiving matrix
1399
- * @param {ReadonlyMat4} a the source matrix
1400
- * @returns {mat4} out
1401
- */
1402
-
1403
- function invert(out, a) {
1404
- var a00 = a[0],
1405
- a01 = a[1],
1406
- a02 = a[2],
1407
- a03 = a[3];
1408
- var a10 = a[4],
1409
- a11 = a[5],
1410
- a12 = a[6],
1411
- a13 = a[7];
1412
- var a20 = a[8],
1413
- a21 = a[9],
1414
- a22 = a[10],
1415
- a23 = a[11];
1416
- var a30 = a[12],
1417
- a31 = a[13],
1418
- a32 = a[14],
1419
- a33 = a[15];
1420
- var b00 = a00 * a11 - a01 * a10;
1421
- var b01 = a00 * a12 - a02 * a10;
1422
- var b02 = a00 * a13 - a03 * a10;
1423
- var b03 = a01 * a12 - a02 * a11;
1424
- var b04 = a01 * a13 - a03 * a11;
1425
- var b05 = a02 * a13 - a03 * a12;
1426
- var b06 = a20 * a31 - a21 * a30;
1427
- var b07 = a20 * a32 - a22 * a30;
1428
- var b08 = a20 * a33 - a23 * a30;
1429
- var b09 = a21 * a32 - a22 * a31;
1430
- var b10 = a21 * a33 - a23 * a31;
1431
- var b11 = a22 * a33 - a23 * a32; // Calculate the determinant
1432
-
1433
- var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
1434
-
1435
- if (!det) {
1436
- return null;
1437
- }
1438
-
1439
- det = 1.0 / det;
1440
- out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
1441
- out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
1442
- out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
1443
- out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
1444
- out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
1445
- out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
1446
- out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
1447
- out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
1448
- out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
1449
- out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
1450
- out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
1451
- out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
1452
- out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
1453
- out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
1454
- out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
1455
- out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
1456
- return out;
1457
- }
1458
-
1459
- // isFinite,
1460
- var isNil = function (value) {
1461
- /**
1462
- * isNil(null) => true
1463
- * isNil() => true
1464
- */
1465
- return value === null || value === undefined;
1466
- };
1467
-
1468
- var toString = {}.toString;
1469
- var isType = function (value, type) { return toString.call(value) === '[object ' + type + ']'; };
1470
-
1471
- var isString = (function (str) {
1472
- return isType(str, 'String');
1473
- });
1474
-
1475
- var clamp = function (a, min, max) {
1476
- if (a < min) {
1477
- return min;
1478
- }
1479
- else if (a > max) {
1480
- return max;
1481
- }
1482
- return a;
1483
- };
1484
-
1485
- function _regeneratorRuntime$3() {
1486
- _regeneratorRuntime$3 = function _regeneratorRuntime() {
1487
- return exports;
1488
- };
1489
- var exports = {},
1490
- Op = Object.prototype,
1491
- hasOwn = Op.hasOwnProperty,
1492
- defineProperty = Object.defineProperty || function (obj, key, desc) {
1493
- obj[key] = desc.value;
1494
- },
1495
- $Symbol = "function" == typeof Symbol ? Symbol : {},
1496
- iteratorSymbol = $Symbol.iterator || "@@iterator",
1497
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
1498
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
1499
- function define(obj, key, value) {
1500
- return Object.defineProperty(obj, key, {
1501
- value: value,
1502
- enumerable: !0,
1503
- configurable: !0,
1504
- writable: !0
1505
- }), obj[key];
1506
- }
1507
- try {
1508
- define({}, "");
1509
- } catch (err) {
1510
- define = function define(obj, key, value) {
1511
- return obj[key] = value;
1512
- };
1513
- }
1514
- function wrap(innerFn, outerFn, self, tryLocsList) {
1515
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
1516
- generator = Object.create(protoGenerator.prototype),
1517
- context = new Context(tryLocsList || []);
1518
- return defineProperty(generator, "_invoke", {
1519
- value: makeInvokeMethod(innerFn, self, context)
1520
- }), generator;
1521
- }
1522
- function tryCatch(fn, obj, arg) {
1523
- try {
1524
- return {
1525
- type: "normal",
1526
- arg: fn.call(obj, arg)
1527
- };
1528
- } catch (err) {
1529
- return {
1530
- type: "throw",
1531
- arg: err
1532
- };
1533
- }
1534
- }
1535
- exports.wrap = wrap;
1536
- var ContinueSentinel = {};
1537
- function Generator() {}
1538
- function GeneratorFunction() {}
1539
- function GeneratorFunctionPrototype() {}
1540
- var IteratorPrototype = {};
1541
- define(IteratorPrototype, iteratorSymbol, function () {
1542
- return this;
1543
- });
1544
- var getProto = Object.getPrototypeOf,
1545
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
1546
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
1547
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
1548
- function defineIteratorMethods(prototype) {
1549
- ["next", "throw", "return"].forEach(function (method) {
1550
- define(prototype, method, function (arg) {
1551
- return this._invoke(method, arg);
1552
- });
1553
- });
1554
- }
1555
- function AsyncIterator(generator, PromiseImpl) {
1556
- function invoke(method, arg, resolve, reject) {
1557
- var record = tryCatch(generator[method], generator, arg);
1558
- if ("throw" !== record.type) {
1559
- var result = record.arg,
1560
- value = result.value;
1561
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
1562
- invoke("next", value, resolve, reject);
1563
- }, function (err) {
1564
- invoke("throw", err, resolve, reject);
1565
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
1566
- result.value = unwrapped, resolve(result);
1567
- }, function (error) {
1568
- return invoke("throw", error, resolve, reject);
1569
- });
1570
- }
1571
- reject(record.arg);
1572
- }
1573
- var previousPromise;
1574
- defineProperty(this, "_invoke", {
1575
- value: function value(method, arg) {
1576
- function callInvokeWithMethodAndArg() {
1577
- return new PromiseImpl(function (resolve, reject) {
1578
- invoke(method, arg, resolve, reject);
1579
- });
1580
- }
1581
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
1582
- }
1583
- });
1584
- }
1585
- function makeInvokeMethod(innerFn, self, context) {
1586
- var state = "suspendedStart";
1587
- return function (method, arg) {
1588
- if ("executing" === state) throw new Error("Generator is already running");
1589
- if ("completed" === state) {
1590
- if ("throw" === method) throw arg;
1591
- return doneResult();
1592
- }
1593
- for (context.method = method, context.arg = arg;;) {
1594
- var delegate = context.delegate;
1595
- if (delegate) {
1596
- var delegateResult = maybeInvokeDelegate(delegate, context);
1597
- if (delegateResult) {
1598
- if (delegateResult === ContinueSentinel) continue;
1599
- return delegateResult;
1600
- }
1601
- }
1602
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
1603
- if ("suspendedStart" === state) throw state = "completed", context.arg;
1604
- context.dispatchException(context.arg);
1605
- } else "return" === context.method && context.abrupt("return", context.arg);
1606
- state = "executing";
1607
- var record = tryCatch(innerFn, self, context);
1608
- if ("normal" === record.type) {
1609
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
1610
- return {
1611
- value: record.arg,
1612
- done: context.done
1613
- };
1614
- }
1615
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
1616
- }
1617
- };
1618
- }
1619
- function maybeInvokeDelegate(delegate, context) {
1620
- var methodName = context.method,
1621
- method = delegate.iterator[methodName];
1622
- if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
1623
- var record = tryCatch(method, delegate.iterator, context.arg);
1624
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
1625
- var info = record.arg;
1626
- return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
1627
- }
1628
- function pushTryEntry(locs) {
1629
- var entry = {
1630
- tryLoc: locs[0]
1631
- };
1632
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
1633
- }
1634
- function resetTryEntry(entry) {
1635
- var record = entry.completion || {};
1636
- record.type = "normal", delete record.arg, entry.completion = record;
1637
- }
1638
- function Context(tryLocsList) {
1639
- this.tryEntries = [{
1640
- tryLoc: "root"
1641
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
1642
- }
1643
- function values(iterable) {
1644
- if (iterable) {
1645
- var iteratorMethod = iterable[iteratorSymbol];
1646
- if (iteratorMethod) return iteratorMethod.call(iterable);
1647
- if ("function" == typeof iterable.next) return iterable;
1648
- if (!isNaN(iterable.length)) {
1649
- var i = -1,
1650
- next = function next() {
1651
- for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
1652
- return next.value = undefined, next.done = !0, next;
1653
- };
1654
- return next.next = next;
1655
- }
1656
- }
1657
- return {
1658
- next: doneResult
1659
- };
1660
- }
1661
- function doneResult() {
1662
- return {
1663
- value: undefined,
1664
- done: !0
1665
- };
1666
- }
1667
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
1668
- value: GeneratorFunctionPrototype,
1669
- configurable: !0
1670
- }), defineProperty(GeneratorFunctionPrototype, "constructor", {
1671
- value: GeneratorFunction,
1672
- configurable: !0
1673
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
1674
- var ctor = "function" == typeof genFun && genFun.constructor;
1675
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
1676
- }, exports.mark = function (genFun) {
1677
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
1678
- }, exports.awrap = function (arg) {
1679
- return {
1680
- __await: arg
1681
- };
1682
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
1683
- return this;
1684
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
1685
- void 0 === PromiseImpl && (PromiseImpl = Promise);
1686
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
1687
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
1688
- return result.done ? result.value : iter.next();
1689
- });
1690
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
1691
- return this;
1692
- }), define(Gp, "toString", function () {
1693
- return "[object Generator]";
1694
- }), exports.keys = function (val) {
1695
- var object = Object(val),
1696
- keys = [];
1697
- for (var key in object) keys.push(key);
1698
- return keys.reverse(), function next() {
1699
- for (; keys.length;) {
1700
- var key = keys.pop();
1701
- if (key in object) return next.value = key, next.done = !1, next;
1702
- }
1703
- return next.done = !0, next;
1704
- };
1705
- }, exports.values = values, Context.prototype = {
1706
- constructor: Context,
1707
- reset: function reset(skipTempReset) {
1708
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
1709
- },
1710
- stop: function stop() {
1711
- this.done = !0;
1712
- var rootRecord = this.tryEntries[0].completion;
1713
- if ("throw" === rootRecord.type) throw rootRecord.arg;
1714
- return this.rval;
1715
- },
1716
- dispatchException: function dispatchException(exception) {
1717
- if (this.done) throw exception;
1718
- var context = this;
1719
- function handle(loc, caught) {
1720
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
1721
- }
1722
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1723
- var entry = this.tryEntries[i],
1724
- record = entry.completion;
1725
- if ("root" === entry.tryLoc) return handle("end");
1726
- if (entry.tryLoc <= this.prev) {
1727
- var hasCatch = hasOwn.call(entry, "catchLoc"),
1728
- hasFinally = hasOwn.call(entry, "finallyLoc");
1729
- if (hasCatch && hasFinally) {
1730
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
1731
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
1732
- } else if (hasCatch) {
1733
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
1734
- } else {
1735
- if (!hasFinally) throw new Error("try statement without catch or finally");
1736
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
927
+ var doc = context.config.document,
928
+ renderingService = context.renderingService,
929
+ svgElementMap = context.svgElementMap;
930
+ renderingService.hooks.pick.tapPromise(SVGPickerPlugin.tag, /*#__PURE__*/function () {
931
+ var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee(result) {
932
+ return _regeneratorRuntime$1().wrap(function _callee$(_context) {
933
+ while (1) switch (_context.prev = _context.next) {
934
+ case 0:
935
+ return _context.abrupt("return", _this.pick(svgElementMap, doc, result));
936
+ case 1:
937
+ case "end":
938
+ return _context.stop();
1737
939
  }
1738
- }
1739
- }
1740
- },
1741
- abrupt: function abrupt(type, arg) {
1742
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1743
- var entry = this.tryEntries[i];
1744
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
1745
- var finallyEntry = entry;
1746
- break;
1747
- }
1748
- }
1749
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
1750
- var record = finallyEntry ? finallyEntry.completion : {};
1751
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
1752
- },
1753
- complete: function complete(record, afterLoc) {
1754
- if ("throw" === record.type) throw record.arg;
1755
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
1756
- },
1757
- finish: function finish(finallyLoc) {
1758
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1759
- var entry = this.tryEntries[i];
1760
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
1761
- }
1762
- },
1763
- catch: function _catch(tryLoc) {
1764
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1765
- var entry = this.tryEntries[i];
1766
- if (entry.tryLoc === tryLoc) {
1767
- var record = entry.completion;
1768
- if ("throw" === record.type) {
1769
- var thrown = record.arg;
1770
- resetTryEntry(entry);
940
+ }, _callee);
941
+ }));
942
+ return function (_x) {
943
+ return _ref.apply(this, arguments);
944
+ };
945
+ }());
946
+ renderingService.hooks.pickSync.tap(SVGPickerPlugin.tag, function (result) {
947
+ return _this.pick(svgElementMap, doc, result);
948
+ });
949
+ };
950
+ _proto.pick = function pick(svgElementMap, doc, result) {
951
+ var topmost = result.topmost,
952
+ _result$position = result.position,
953
+ clientX = _result$position.clientX,
954
+ clientY = _result$position.clientY;
955
+ try {
956
+ var targets = [];
957
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
958
+ for (var _iterator = _createForOfIteratorHelperLoose((doc || document).elementsFromPoint(clientX, clientY)), _step; !(_step = _iterator()).done;) {
959
+ var element = _step.value;
960
+ var target = svgElementMap.get(element);
961
+ // don't need to account for `visibility` since DOM API already does
962
+ if (target && target.isInteractive()) {
963
+ targets.push(target);
964
+ if (topmost) {
965
+ result.picked = targets;
966
+ return result;
1771
967
  }
1772
- return thrown;
1773
968
  }
1774
969
  }
1775
- throw new Error("illegal catch attempt");
1776
- },
1777
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
1778
- return this.delegate = {
1779
- iterator: values(iterable),
1780
- resultName: resultName,
1781
- nextLoc: nextLoc
1782
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
970
+ result.picked = targets;
971
+ } catch (e) {
972
+ result.picked = [];
1783
973
  }
1784
- }, exports;
1785
- }
1786
- function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
1787
- try {
1788
- var info = gen[key](arg);
1789
- var value = info.value;
1790
- } catch (error) {
1791
- reject(error);
1792
- return;
974
+ return result;
975
+ };
976
+ return SVGPickerPlugin;
977
+ }();
978
+ SVGPickerPlugin.tag = 'SVGPicker';
979
+ var Plugin$1 = /*#__PURE__*/function (_AbstractRendererPlug) {
980
+ _inheritsLoose$2(Plugin, _AbstractRendererPlug);
981
+ function Plugin() {
982
+ var _this;
983
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
984
+ args[_key] = arguments[_key];
985
+ }
986
+ _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
987
+ _this.name = 'svg-picker';
988
+ return _this;
1793
989
  }
1794
- if (info.done) {
1795
- resolve(value);
1796
- } else {
1797
- Promise.resolve(value).then(_next, _throw);
990
+ var _proto = Plugin.prototype;
991
+ _proto.init = function init() {
992
+ this.addRenderingPlugin(new SVGPickerPlugin());
993
+ };
994
+ _proto.destroy = function destroy() {
995
+ this.removeAllRenderingPlugins();
996
+ };
997
+ return Plugin;
998
+ }(gLite.AbstractRendererPlugin);
999
+
1000
+ var index_esm$1 = /*#__PURE__*/Object.freeze({
1001
+ __proto__: null,
1002
+ Plugin: Plugin$1
1003
+ });
1004
+
1005
+ /**
1006
+ * Common utilities
1007
+ * @module glMatrix
1008
+ */
1009
+ var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
1010
+ if (!Math.hypot) Math.hypot = function () {
1011
+ var y = 0,
1012
+ i = arguments.length;
1013
+
1014
+ while (i--) {
1015
+ y += arguments[i] * arguments[i];
1016
+ }
1017
+
1018
+ return Math.sqrt(y);
1019
+ };
1020
+
1021
+ /**
1022
+ * 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied.
1023
+ * @module mat4
1024
+ */
1025
+
1026
+ /**
1027
+ * Creates a new identity mat4
1028
+ *
1029
+ * @returns {mat4} a new 4x4 matrix
1030
+ */
1031
+
1032
+ function create() {
1033
+ var out = new ARRAY_TYPE(16);
1034
+
1035
+ if (ARRAY_TYPE != Float32Array) {
1036
+ out[1] = 0;
1037
+ out[2] = 0;
1038
+ out[3] = 0;
1039
+ out[4] = 0;
1040
+ out[6] = 0;
1041
+ out[7] = 0;
1042
+ out[8] = 0;
1043
+ out[9] = 0;
1044
+ out[11] = 0;
1045
+ out[12] = 0;
1046
+ out[13] = 0;
1047
+ out[14] = 0;
1798
1048
  }
1049
+
1050
+ out[0] = 1;
1051
+ out[5] = 1;
1052
+ out[10] = 1;
1053
+ out[15] = 1;
1054
+ return out;
1799
1055
  }
1800
- function _asyncToGenerator$3(fn) {
1801
- return function () {
1802
- var self = this,
1803
- args = arguments;
1804
- return new Promise(function (resolve, reject) {
1805
- var gen = fn.apply(self, args);
1806
- function _next(value) {
1807
- asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
1808
- }
1809
- function _throw(err) {
1810
- asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
1811
- }
1812
- _next(undefined);
1813
- });
1814
- };
1056
+ /**
1057
+ * Inverts a mat4
1058
+ *
1059
+ * @param {mat4} out the receiving matrix
1060
+ * @param {ReadonlyMat4} a the source matrix
1061
+ * @returns {mat4} out
1062
+ */
1063
+
1064
+ function invert(out, a) {
1065
+ var a00 = a[0],
1066
+ a01 = a[1],
1067
+ a02 = a[2],
1068
+ a03 = a[3];
1069
+ var a10 = a[4],
1070
+ a11 = a[5],
1071
+ a12 = a[6],
1072
+ a13 = a[7];
1073
+ var a20 = a[8],
1074
+ a21 = a[9],
1075
+ a22 = a[10],
1076
+ a23 = a[11];
1077
+ var a30 = a[12],
1078
+ a31 = a[13],
1079
+ a32 = a[14],
1080
+ a33 = a[15];
1081
+ var b00 = a00 * a11 - a01 * a10;
1082
+ var b01 = a00 * a12 - a02 * a10;
1083
+ var b02 = a00 * a13 - a03 * a10;
1084
+ var b03 = a01 * a12 - a02 * a11;
1085
+ var b04 = a01 * a13 - a03 * a11;
1086
+ var b05 = a02 * a13 - a03 * a12;
1087
+ var b06 = a20 * a31 - a21 * a30;
1088
+ var b07 = a20 * a32 - a22 * a30;
1089
+ var b08 = a20 * a33 - a23 * a30;
1090
+ var b09 = a21 * a32 - a22 * a31;
1091
+ var b10 = a21 * a33 - a23 * a31;
1092
+ var b11 = a22 * a33 - a23 * a32; // Calculate the determinant
1093
+
1094
+ var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
1095
+
1096
+ if (!det) {
1097
+ return null;
1098
+ }
1099
+
1100
+ det = 1.0 / det;
1101
+ out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
1102
+ out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
1103
+ out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
1104
+ out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
1105
+ out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
1106
+ out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
1107
+ out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
1108
+ out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
1109
+ out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
1110
+ out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
1111
+ out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
1112
+ out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
1113
+ out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
1114
+ out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
1115
+ out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
1116
+ out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
1117
+ return out;
1815
1118
  }
1119
+
1120
+ // isFinite,
1121
+ var isNil = function (value) {
1122
+ /**
1123
+ * isNil(null) => true
1124
+ * isNil() => true
1125
+ */
1126
+ return value === null || value === undefined;
1127
+ };
1128
+
1129
+ var toString = {}.toString;
1130
+ var isType = function (value, type) { return toString.call(value) === '[object ' + type + ']'; };
1131
+
1132
+ var isString = (function (str) {
1133
+ return isType(str, 'String');
1134
+ });
1135
+
1136
+ var clamp = function (a, min, max) {
1137
+ if (a < min) {
1138
+ return min;
1139
+ }
1140
+ else if (a > max) {
1141
+ return max;
1142
+ }
1143
+ return a;
1144
+ };
1145
+
1816
1146
  function _extends() {
1817
1147
  _extends = Object.assign ? Object.assign.bind() : function (target) {
1818
1148
  for (var i = 1; i < arguments.length; i++) {
@@ -2294,34 +1624,28 @@
2294
1624
  }
2295
1625
  }
2296
1626
  };
2297
- renderingService.hooks.init.tapPromise(SVGRendererPlugin.tag, /*#__PURE__*/_asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee() {
2298
- var _this$context$config, background, document, $svg;
2299
- return _regeneratorRuntime$3().wrap(function _callee$(_context) {
2300
- while (1) switch (_context.prev = _context.next) {
2301
- case 0:
2302
- _this$context$config = _this.context.config, background = _this$context$config.background, document = _this$context$config.document; // <defs>
2303
- _this.defElementManager.init();
2304
- $svg = _this.context.contextService.getContext();
2305
- if (background) {
2306
- $svg.style.background = background;
2307
- }
2308
- // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
2309
- $svg.setAttribute('color-interpolation-filters', 'sRGB');
2310
- _this.$camera = createSVGElement('g', document);
2311
- _this.$camera.id = G_SVG_PREFIX + "-camera";
2312
- _this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
2313
- $svg.appendChild(_this.$camera);
2314
- canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
2315
- canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
2316
- canvas.addEventListener(gLite.ElementEvent.REPARENT, handleReparent);
2317
- canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
2318
- canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
2319
- case 14:
2320
- case "end":
2321
- return _context.stop();
2322
- }
2323
- }, _callee);
2324
- })));
1627
+ renderingService.hooks.init.tap(SVGRendererPlugin.tag, function () {
1628
+ var _this$context$config = _this.context.config,
1629
+ background = _this$context$config.background,
1630
+ document = _this$context$config.document;
1631
+ // <defs>
1632
+ _this.defElementManager.init();
1633
+ var $svg = _this.context.contextService.getContext();
1634
+ if (background) {
1635
+ $svg.style.background = background;
1636
+ }
1637
+ // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
1638
+ $svg.setAttribute('color-interpolation-filters', 'sRGB');
1639
+ _this.$camera = createSVGElement('g', document);
1640
+ _this.$camera.id = G_SVG_PREFIX + "-camera";
1641
+ _this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
1642
+ $svg.appendChild(_this.$camera);
1643
+ canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
1644
+ canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
1645
+ canvas.addEventListener(gLite.ElementEvent.REPARENT, handleReparent);
1646
+ canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
1647
+ canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
1648
+ });
2325
1649
  renderingService.hooks.destroy.tap(SVGRendererPlugin.tag, function () {
2326
1650
  canvas.removeEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
2327
1651
  canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
@@ -2717,8 +2041,8 @@
2717
2041
  var bounds = object.getGeometryBounds();
2718
2042
  var width = bounds && bounds.halfExtents[0] * 2 || 0;
2719
2043
  var height = bounds && bounds.halfExtents[1] * 2 || 0;
2720
- var _ref2 = object.parsedStyle || {},
2721
- anchor = _ref2.anchor;
2044
+ var _ref = object.parsedStyle || {},
2045
+ anchor = _ref.anchor;
2722
2046
  // @ts-ignore
2723
2047
  [(_object$elementSVG7 = object.elementSVG) === null || _object$elementSVG7 === void 0 ? void 0 : _object$elementSVG7.$el, (_object$elementSVG8 = object.elementSVG) === null || _object$elementSVG8 === void 0 ? void 0 : _object$elementSVG8.$hitTestingEl].forEach(function ($el) {
2724
2048
  if ($el) {
@@ -3698,39 +3022,29 @@
3698
3022
  this.canvasConfig = context.config;
3699
3023
  }
3700
3024
  var _proto = SVGContextService.prototype;
3701
- _proto.init = /*#__PURE__*/function () {
3702
- var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
3703
- var _this$canvasConfig, container, doc, devicePixelRatio, $namespace, dpr;
3704
- return _regeneratorRuntime().wrap(function _callee$(_context) {
3705
- while (1) switch (_context.prev = _context.next) {
3706
- case 0:
3707
- _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document, devicePixelRatio = _this$canvasConfig.devicePixelRatio; // create container
3708
- this.$container = isString(container) ? (doc || document).getElementById(container) : container;
3709
- if (this.$container) {
3710
- if (!this.$container.style.position) {
3711
- this.$container.style.position = 'relative';
3712
- }
3713
- $namespace = createSVGElement('svg', doc);
3714
- $namespace.setAttribute('width', "" + this.canvasConfig.width);
3715
- $namespace.setAttribute('height', "" + this.canvasConfig.height);
3716
- this.$container.appendChild($namespace);
3717
- this.$namespace = $namespace;
3718
- }
3719
- // use user-defined dpr first
3720
- dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
3721
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
3722
- this.dpr = dpr;
3723
- case 6:
3724
- case "end":
3725
- return _context.stop();
3726
- }
3727
- }, _callee, this);
3728
- }));
3729
- function init() {
3730
- return _init.apply(this, arguments);
3025
+ _proto.init = function init() {
3026
+ var _this$canvasConfig = this.canvasConfig,
3027
+ container = _this$canvasConfig.container,
3028
+ doc = _this$canvasConfig.document,
3029
+ devicePixelRatio = _this$canvasConfig.devicePixelRatio;
3030
+ // create container
3031
+ this.$container = isString(container) ? (doc || document).getElementById(container) : container;
3032
+ if (this.$container) {
3033
+ if (!this.$container.style.position) {
3034
+ this.$container.style.position = 'relative';
3035
+ }
3036
+ var $namespace = createSVGElement('svg', doc);
3037
+ $namespace.setAttribute('width', "" + this.canvasConfig.width);
3038
+ $namespace.setAttribute('height', "" + this.canvasConfig.height);
3039
+ this.$container.appendChild($namespace);
3040
+ this.$namespace = $namespace;
3731
3041
  }
3732
- return init;
3733
- }() // @ts-ignore
3042
+ // use user-defined dpr first
3043
+ var dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
3044
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
3045
+ this.dpr = dpr;
3046
+ }
3047
+ // @ts-ignore
3734
3048
  ;
3735
3049
  _proto.getDomElement = function getDomElement() {
3736
3050
  return this.$namespace;
@@ -3786,11 +3100,11 @@
3786
3100
  }).join('') + "}" + (selector + " {animation: " + animationName + " " + duration + "ms " + easing + " " + delay + "ms " + (iterations === Infinity ? 'infinite' : iterations) + " " + direction + " " + fill + ";}");
3787
3101
  };
3788
3102
  _proto.toDataURL = /*#__PURE__*/function () {
3789
- var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
3103
+ var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
3790
3104
  var _this = this;
3791
3105
  var cloneNode, doc, animationCounter, $style, svgDocType, svgDoc;
3792
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3793
- while (1) switch (_context2.prev = _context2.next) {
3106
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
3107
+ while (1) switch (_context.prev = _context.next) {
3794
3108
  case 0:
3795
3109
  cloneNode = this.$namespace.cloneNode(true);
3796
3110
  doc = this.canvasConfig.document;
@@ -3891,12 +3205,12 @@
3891
3205
  svgDocType = document.implementation.createDocumentType('svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
3892
3206
  svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', svgDocType);
3893
3207
  svgDoc.replaceChild(cloneNode, svgDoc.documentElement);
3894
- return _context2.abrupt("return", "data:image/svg+xml;charset=utf8," + encodeURIComponent(new XMLSerializer().serializeToString(svgDoc)));
3208
+ return _context.abrupt("return", "data:image/svg+xml;charset=utf8," + encodeURIComponent(new XMLSerializer().serializeToString(svgDoc)));
3895
3209
  case 10:
3896
3210
  case "end":
3897
- return _context2.stop();
3211
+ return _context.stop();
3898
3212
  }
3899
- }, _callee2, this);
3213
+ }, _callee, this);
3900
3214
  }));
3901
3215
  function toDataURL(_x) {
3902
3216
  return _toDataURL.apply(this, arguments);