@antv/g-svg 1.8.45 → 1.8.47

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
@@ -526,9 +526,7 @@
526
526
  if (!isNaN(iterable.length)) {
527
527
  var i = -1,
528
528
  next = function next() {
529
- for (; ++i < iterable.length;) {
530
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
531
- }
529
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
532
530
  return next.value = undefined, next.done = !0, next;
533
531
  };
534
532
  return next.next = next;
@@ -574,9 +572,7 @@
574
572
  }), exports.keys = function (val) {
575
573
  var object = Object(val),
576
574
  keys = [];
577
- for (var key in object) {
578
- keys.push(key);
579
- }
575
+ for (var key in object) keys.push(key);
580
576
  return keys.reverse(), function next() {
581
577
  for (; keys.length;) {
582
578
  var key = keys.pop();
@@ -587,9 +583,7 @@
587
583
  }, exports.values = values, Context.prototype = {
588
584
  constructor: Context,
589
585
  reset: function reset(skipTempReset) {
590
- 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) {
591
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
592
- }
586
+ 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);
593
587
  },
594
588
  stop: function stop() {
595
589
  this.done = !0;
@@ -722,7 +716,8 @@
722
716
  _proto.apply = function apply(context, runtime) {
723
717
  var _this = this;
724
718
  var renderingService = context.renderingService,
725
- renderingContext = context.renderingContext;
719
+ renderingContext = context.renderingContext,
720
+ config = context.config;
726
721
  this.context = context;
727
722
  var canvas = renderingContext.root.ownerDocument.defaultView;
728
723
  // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
@@ -747,6 +742,9 @@
747
742
  var onPointerWheel = function onPointerWheel(ev) {
748
743
  renderingService.hooks.pointerWheel.call(ev);
749
744
  };
745
+ var onClick = function onClick(ev) {
746
+ renderingService.hooks.click.call(ev);
747
+ };
750
748
  var addPointerEventListener = function addPointerEventListener($el) {
751
749
  runtime.globalThis.document.addEventListener('pointermove', onPointerMove, true);
752
750
  $el.addEventListener('pointerdown', onPointerDown, true);
@@ -790,36 +788,37 @@
790
788
  renderingService.hooks.init.tapPromise(DOMInteractionPlugin.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
791
789
  var $el;
792
790
  return _regeneratorRuntime$1().wrap(function _callee$(_context) {
793
- while (1) {
794
- switch (_context.prev = _context.next) {
795
- case 0:
796
- $el = _this.context.contextService.getDomElement(); // @ts-ignore
797
- if (runtime.globalThis.navigator.msPointerEnabled) {
798
- // @ts-ignore
799
- $el.style.msContentZooming = 'none';
800
- // @ts-ignore
801
- $el.style.msTouchAction = 'none';
802
- } else if (canvas.supportsPointerEvents) {
803
- $el.style.touchAction = 'none';
804
- }
805
- if (canvas.supportsPointerEvents) {
806
- addPointerEventListener($el);
807
- } else {
808
- addMouseEventListener($el);
809
- }
810
- if (canvas.supportsTouchEvents) {
811
- addTouchEventListener($el);
812
- }
813
- // use passive event listeners
814
- // @see https://zhuanlan.zhihu.com/p/24555031
815
- $el.addEventListener('wheel', onPointerWheel, {
816
- passive: true,
817
- capture: true
818
- });
819
- case 5:
820
- case "end":
821
- return _context.stop();
822
- }
791
+ while (1) switch (_context.prev = _context.next) {
792
+ case 0:
793
+ $el = _this.context.contextService.getDomElement(); // @ts-ignore
794
+ if (runtime.globalThis.navigator.msPointerEnabled) {
795
+ // @ts-ignore
796
+ $el.style.msContentZooming = 'none';
797
+ // @ts-ignore
798
+ $el.style.msTouchAction = 'none';
799
+ } else if (canvas.supportsPointerEvents) {
800
+ $el.style.touchAction = 'none';
801
+ }
802
+ if (canvas.supportsPointerEvents) {
803
+ addPointerEventListener($el);
804
+ } else {
805
+ addMouseEventListener($el);
806
+ }
807
+ if (canvas.supportsTouchEvents) {
808
+ addTouchEventListener($el);
809
+ }
810
+ if (config.useNativeClickEvent) {
811
+ $el.addEventListener('click', onClick, true);
812
+ }
813
+ // use passive event listeners
814
+ // @see https://zhuanlan.zhihu.com/p/24555031
815
+ $el.addEventListener('wheel', onPointerWheel, {
816
+ passive: true,
817
+ capture: true
818
+ });
819
+ case 6:
820
+ case "end":
821
+ return _context.stop();
823
822
  }
824
823
  }, _callee);
825
824
  })));
@@ -842,6 +841,9 @@
842
841
  if (canvas.supportsTouchEvents) {
843
842
  removeTouchEventListener($el);
844
843
  }
844
+ if (config.useNativeClickEvent) {
845
+ $el.removeEventListener('click', onClick, true);
846
+ }
845
847
  $el.removeEventListener('wheel', onPointerWheel, true);
846
848
  });
847
849
  };
@@ -1015,212 +1017,6 @@
1015
1017
  return a;
1016
1018
  };
1017
1019
 
1018
- var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
1019
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
1020
- if (ar || !(i in from)) {
1021
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
1022
- ar[i] = from[i];
1023
- }
1024
- }
1025
- return to.concat(ar || Array.prototype.slice.call(from));
1026
- };
1027
- var BrowserInfo = /** @class */ (function () {
1028
- function BrowserInfo(name, version, os) {
1029
- this.name = name;
1030
- this.version = version;
1031
- this.os = os;
1032
- this.type = 'browser';
1033
- }
1034
- return BrowserInfo;
1035
- }());
1036
- var NodeInfo = /** @class */ (function () {
1037
- function NodeInfo(version) {
1038
- this.version = version;
1039
- this.type = 'node';
1040
- this.name = 'node';
1041
- this.os = process.platform;
1042
- }
1043
- return NodeInfo;
1044
- }());
1045
- var SearchBotDeviceInfo = /** @class */ (function () {
1046
- function SearchBotDeviceInfo(name, version, os, bot) {
1047
- this.name = name;
1048
- this.version = version;
1049
- this.os = os;
1050
- this.bot = bot;
1051
- this.type = 'bot-device';
1052
- }
1053
- return SearchBotDeviceInfo;
1054
- }());
1055
- var BotInfo = /** @class */ (function () {
1056
- function BotInfo() {
1057
- this.type = 'bot';
1058
- this.bot = true; // NOTE: deprecated test name instead
1059
- this.name = 'bot';
1060
- this.version = null;
1061
- this.os = null;
1062
- }
1063
- return BotInfo;
1064
- }());
1065
- var ReactNativeInfo = /** @class */ (function () {
1066
- function ReactNativeInfo() {
1067
- this.type = 'react-native';
1068
- this.name = 'react-native';
1069
- this.version = null;
1070
- this.os = null;
1071
- }
1072
- return ReactNativeInfo;
1073
- }());
1074
- // tslint:disable-next-line:max-line-length
1075
- var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/;
1076
- var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/;
1077
- var REQUIRED_VERSION_PARTS = 3;
1078
- var userAgentRules = [
1079
- ['aol', /AOLShield\/([0-9\._]+)/],
1080
- ['edge', /Edge\/([0-9\._]+)/],
1081
- ['edge-ios', /EdgiOS\/([0-9\._]+)/],
1082
- ['yandexbrowser', /YaBrowser\/([0-9\._]+)/],
1083
- ['kakaotalk', /KAKAOTALK\s([0-9\.]+)/],
1084
- ['samsung', /SamsungBrowser\/([0-9\.]+)/],
1085
- ['silk', /\bSilk\/([0-9._-]+)\b/],
1086
- ['miui', /MiuiBrowser\/([0-9\.]+)$/],
1087
- ['beaker', /BeakerBrowser\/([0-9\.]+)/],
1088
- ['edge-chromium', /EdgA?\/([0-9\.]+)/],
1089
- [
1090
- 'chromium-webview',
1091
- /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/,
1092
- ],
1093
- ['chrome', /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],
1094
- ['phantomjs', /PhantomJS\/([0-9\.]+)(:?\s|$)/],
1095
- ['crios', /CriOS\/([0-9\.]+)(:?\s|$)/],
1096
- ['firefox', /Firefox\/([0-9\.]+)(?:\s|$)/],
1097
- ['fxios', /FxiOS\/([0-9\.]+)/],
1098
- ['opera-mini', /Opera Mini.*Version\/([0-9\.]+)/],
1099
- ['opera', /Opera\/([0-9\.]+)(?:\s|$)/],
1100
- ['opera', /OPR\/([0-9\.]+)(:?\s|$)/],
1101
- ['pie', /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],
1102
- ['pie', /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],
1103
- ['netfront', /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],
1104
- ['ie', /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],
1105
- ['ie', /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],
1106
- ['ie', /MSIE\s(7\.0)/],
1107
- ['bb10', /BB10;\sTouch.*Version\/([0-9\.]+)/],
1108
- ['android', /Android\s([0-9\.]+)/],
1109
- ['ios', /Version\/([0-9\._]+).*Mobile.*Safari.*/],
1110
- ['safari', /Version\/([0-9\._]+).*Safari/],
1111
- ['facebook', /FB[AS]V\/([0-9\.]+)/],
1112
- ['instagram', /Instagram\s([0-9\.]+)/],
1113
- ['ios-webview', /AppleWebKit\/([0-9\.]+).*Mobile/],
1114
- ['ios-webview', /AppleWebKit\/([0-9\.]+).*Gecko\)$/],
1115
- ['curl', /^curl\/([0-9\.]+)$/],
1116
- ['searchbot', SEARCHBOX_UA_REGEX],
1117
- ];
1118
- var operatingSystemRules = [
1119
- ['iOS', /iP(hone|od|ad)/],
1120
- ['Android OS', /Android/],
1121
- ['BlackBerry OS', /BlackBerry|BB10/],
1122
- ['Windows Mobile', /IEMobile/],
1123
- ['Amazon OS', /Kindle/],
1124
- ['Windows 3.11', /Win16/],
1125
- ['Windows 95', /(Windows 95)|(Win95)|(Windows_95)/],
1126
- ['Windows 98', /(Windows 98)|(Win98)/],
1127
- ['Windows 2000', /(Windows NT 5.0)|(Windows 2000)/],
1128
- ['Windows XP', /(Windows NT 5.1)|(Windows XP)/],
1129
- ['Windows Server 2003', /(Windows NT 5.2)/],
1130
- ['Windows Vista', /(Windows NT 6.0)/],
1131
- ['Windows 7', /(Windows NT 6.1)/],
1132
- ['Windows 8', /(Windows NT 6.2)/],
1133
- ['Windows 8.1', /(Windows NT 6.3)/],
1134
- ['Windows 10', /(Windows NT 10.0)/],
1135
- ['Windows ME', /Windows ME/],
1136
- ['Windows CE', /Windows CE|WinCE|Microsoft Pocket Internet Explorer/],
1137
- ['Open BSD', /OpenBSD/],
1138
- ['Sun OS', /SunOS/],
1139
- ['Chrome OS', /CrOS/],
1140
- ['Linux', /(Linux)|(X11)/],
1141
- ['Mac OS', /(Mac_PowerPC)|(Macintosh)/],
1142
- ['QNX', /QNX/],
1143
- ['BeOS', /BeOS/],
1144
- ['OS/2', /OS\/2/],
1145
- ];
1146
- function detect(userAgent) {
1147
- if (!!userAgent) {
1148
- return parseUserAgent(userAgent);
1149
- }
1150
- if (typeof document === 'undefined' &&
1151
- typeof navigator !== 'undefined' &&
1152
- navigator.product === 'ReactNative') {
1153
- return new ReactNativeInfo();
1154
- }
1155
- if (typeof navigator !== 'undefined') {
1156
- return parseUserAgent(navigator.userAgent);
1157
- }
1158
- return getNodeVersion();
1159
- }
1160
- function matchUserAgent(ua) {
1161
- // opted for using reduce here rather than Array#first with a regex.test call
1162
- // this is primarily because using the reduce we only perform the regex
1163
- // execution once rather than once for the test and for the exec again below
1164
- // probably something that needs to be benchmarked though
1165
- return (ua !== '' &&
1166
- userAgentRules.reduce(function (matched, _a) {
1167
- var browser = _a[0], regex = _a[1];
1168
- if (matched) {
1169
- return matched;
1170
- }
1171
- var uaMatch = regex.exec(ua);
1172
- return !!uaMatch && [browser, uaMatch];
1173
- }, false));
1174
- }
1175
- function parseUserAgent(ua) {
1176
- var matchedRule = matchUserAgent(ua);
1177
- if (!matchedRule) {
1178
- return null;
1179
- }
1180
- var name = matchedRule[0], match = matchedRule[1];
1181
- if (name === 'searchbot') {
1182
- return new BotInfo();
1183
- }
1184
- // Do not use RegExp for split operation as some browser do not support it (See: http://blog.stevenlevithan.com/archives/cross-browser-split)
1185
- var versionParts = match[1] && match[1].split('.').join('_').split('_').slice(0, 3);
1186
- if (versionParts) {
1187
- if (versionParts.length < REQUIRED_VERSION_PARTS) {
1188
- versionParts = __spreadArray(__spreadArray([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length), true);
1189
- }
1190
- }
1191
- else {
1192
- versionParts = [];
1193
- }
1194
- var version = versionParts.join('.');
1195
- var os = detectOS(ua);
1196
- var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua);
1197
- if (searchBotMatch && searchBotMatch[1]) {
1198
- return new SearchBotDeviceInfo(name, version, os, searchBotMatch[1]);
1199
- }
1200
- return new BrowserInfo(name, version, os);
1201
- }
1202
- function detectOS(ua) {
1203
- for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) {
1204
- var _a = operatingSystemRules[ii], os = _a[0], regex = _a[1];
1205
- var match = regex.exec(ua);
1206
- if (match) {
1207
- return os;
1208
- }
1209
- }
1210
- return null;
1211
- }
1212
- function getNodeVersion() {
1213
- var isNode = typeof process !== 'undefined' && process.version;
1214
- return isNode ? new NodeInfo(process.version.slice(1)) : null;
1215
- }
1216
- function createVersionParts(count) {
1217
- var output = [];
1218
- for (var ii = 0; ii < count; ii++) {
1219
- output.push('0');
1220
- }
1221
- return output;
1222
- }
1223
-
1224
1020
  function _regeneratorRuntime$2() {
1225
1021
  _regeneratorRuntime$2 = function _regeneratorRuntime() {
1226
1022
  return exports;
@@ -1387,9 +1183,7 @@
1387
1183
  if (!isNaN(iterable.length)) {
1388
1184
  var i = -1,
1389
1185
  next = function next() {
1390
- for (; ++i < iterable.length;) {
1391
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
1392
- }
1186
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
1393
1187
  return next.value = undefined, next.done = !0, next;
1394
1188
  };
1395
1189
  return next.next = next;
@@ -1435,9 +1229,7 @@
1435
1229
  }), exports.keys = function (val) {
1436
1230
  var object = Object(val),
1437
1231
  keys = [];
1438
- for (var key in object) {
1439
- keys.push(key);
1440
- }
1232
+ for (var key in object) keys.push(key);
1441
1233
  return keys.reverse(), function next() {
1442
1234
  for (; keys.length;) {
1443
1235
  var key = keys.pop();
@@ -1448,9 +1240,7 @@
1448
1240
  }, exports.values = values, Context.prototype = {
1449
1241
  constructor: Context,
1450
1242
  reset: function reset(skipTempReset) {
1451
- 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) {
1452
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
1453
- }
1243
+ 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);
1454
1244
  },
1455
1245
  stop: function stop() {
1456
1246
  this.done = !0;
@@ -1585,8 +1375,20 @@
1585
1375
  return _setPrototypeOf$2(o, p);
1586
1376
  }
1587
1377
  var ElementSVG = function ElementSVG() {
1378
+ /**
1379
+ * basic element, eg. <circle>|<ellipse>
1380
+ */
1588
1381
  this.$el = void 0;
1382
+ /**
1383
+ * group wrapper for basic element, eg. <g><circle /></g>.
1384
+ * if current element is <g>, same as `$el`
1385
+ */
1589
1386
  this.$groupEl = void 0;
1387
+ /**
1388
+ * hitArea:
1389
+ * $groupEl -> $el
1390
+ * -> $hitTestingEl
1391
+ */
1590
1392
  this.$hitTestingEl = void 0;
1591
1393
  };
1592
1394
  ElementSVG.tag = 'c-svg-element';
@@ -1909,18 +1711,36 @@
1909
1711
  this.pluginOptions = void 0;
1910
1712
  this.defElementManager = void 0;
1911
1713
  this.context = void 0;
1714
+ /**
1715
+ * <camera>
1716
+ */
1912
1717
  this.$camera = void 0;
1718
+ /**
1719
+ * render at the end of frame
1720
+ */
1913
1721
  this.renderQueue = [];
1722
+ /**
1723
+ * dirty attributes at the end of frame
1724
+ */
1914
1725
  this.dirtyAttributes = new WeakMap();
1726
+ /**
1727
+ * reorder after mounted
1728
+ */
1915
1729
  this.pendingReorderQueue = new Set();
1730
+ /**
1731
+ * <use> elements in <clipPath>, which should be sync with clipPath
1732
+ *
1733
+ * @example
1734
+ * <clipPath transform="matrix(1,0,0,1,-100,-155)" id="clip-path-0-2">
1735
+ * <use href="#g_svg_circle_0" transform="matrix(1.477115,0,0,1.477115,150,150)">
1736
+ * </use>
1737
+ * </clipPath>
1738
+ */
1916
1739
  this.clipPathUseMap = new WeakMap();
1917
1740
  this.pluginOptions = pluginOptions;
1918
1741
  this.defElementManager = defElementManager;
1919
1742
  this.context = context;
1920
1743
  }
1921
- /**
1922
- * <camera>
1923
- */
1924
1744
  var _proto = SVGRendererPlugin.prototype;
1925
1745
  _proto.apply = function apply(context) {
1926
1746
  var _this = this;
@@ -2006,30 +1826,28 @@
2006
1826
  renderingService.hooks.init.tapPromise(SVGRendererPlugin.tag, /*#__PURE__*/_asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee() {
2007
1827
  var _this$context$config, background, document, $svg;
2008
1828
  return _regeneratorRuntime$2().wrap(function _callee$(_context) {
2009
- while (1) {
2010
- switch (_context.prev = _context.next) {
2011
- case 0:
2012
- _this$context$config = _this.context.config, background = _this$context$config.background, document = _this$context$config.document; // <defs>
2013
- _this.defElementManager.init();
2014
- $svg = _this.context.contextService.getContext();
2015
- if (background) {
2016
- $svg.style.background = background;
2017
- }
2018
- // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
2019
- $svg.setAttribute('color-interpolation-filters', 'sRGB');
2020
- _this.$camera = createSVGElement('g', document);
2021
- _this.$camera.id = G_SVG_PREFIX + "-camera";
2022
- _this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
2023
- $svg.appendChild(_this.$camera);
2024
- canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
2025
- canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
2026
- canvas.addEventListener(gLite.ElementEvent.REPARENT, handleReparent);
2027
- canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
2028
- canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
2029
- case 14:
2030
- case "end":
2031
- return _context.stop();
2032
- }
1829
+ while (1) switch (_context.prev = _context.next) {
1830
+ case 0:
1831
+ _this$context$config = _this.context.config, background = _this$context$config.background, document = _this$context$config.document; // <defs>
1832
+ _this.defElementManager.init();
1833
+ $svg = _this.context.contextService.getContext();
1834
+ if (background) {
1835
+ $svg.style.background = background;
1836
+ }
1837
+ // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
1838
+ $svg.setAttribute('color-interpolation-filters', 'sRGB');
1839
+ _this.$camera = createSVGElement('g', document);
1840
+ _this.$camera.id = G_SVG_PREFIX + "-camera";
1841
+ _this.applyTransform(_this.$camera, _this.context.camera.getOrthoMatrix());
1842
+ $svg.appendChild(_this.$camera);
1843
+ canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
1844
+ canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
1845
+ canvas.addEventListener(gLite.ElementEvent.REPARENT, handleReparent);
1846
+ canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
1847
+ canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleGeometryBoundsChanged);
1848
+ case 14:
1849
+ case "end":
1850
+ return _context.stop();
2033
1851
  }
2034
1852
  }, _callee);
2035
1853
  })));
@@ -2455,19 +2273,9 @@
2455
2273
  }();
2456
2274
  SVGRendererPlugin.tag = 'SVGRenderer';
2457
2275
 
2458
- // @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/alignment-baseline
2459
- var BASELINE_MAP = {
2460
- top: 'before-edge',
2461
- middle: 'central',
2462
- bottom: 'after-edge',
2463
- alphabetic: 'alphabetic',
2464
- ideographic: 'ideographic',
2465
- hanging: 'hanging'
2466
- };
2467
- // for FireFox
2468
2276
  // @see https://github.com/plouc/nivo/issues/164
2469
- var BASELINE_MAP_FOR_FIREFOX = {
2470
- top: 'text-before-edge',
2277
+ var BASELINE_MAP = {
2278
+ top: 'hanging',
2471
2279
  middle: 'central',
2472
2280
  bottom: 'text-after-edge',
2473
2281
  alphabetic: 'alphabetic',
@@ -2488,30 +2296,17 @@
2488
2296
  _parsedStyle$textDeco2 = parsedStyle.textDecorationColor,
2489
2297
  textDecorationColor = _parsedStyle$textDeco2 === void 0 ? '' : _parsedStyle$textDeco2,
2490
2298
  _parsedStyle$textDeco3 = parsedStyle.textDecorationStyle,
2491
- textDecorationStyle = _parsedStyle$textDeco3 === void 0 ? '' : _parsedStyle$textDeco3;
2492
- var textBaseline = parsedStyle.textBaseline,
2299
+ textDecorationStyle = _parsedStyle$textDeco3 === void 0 ? '' : _parsedStyle$textDeco3,
2493
2300
  metrics = parsedStyle.metrics;
2301
+ var textBaseline = parsedStyle.textBaseline;
2494
2302
  if (!gLite.runtime.enableCSSParsing && textBaseline === 'alphabetic') {
2495
2303
  textBaseline = 'bottom';
2496
2304
  }
2497
- var browser = detect();
2498
- if (browser && browser.name === 'firefox') {
2499
- // compatible with FireFox browser, ref: https://github.com/antvis/g/issues/119
2500
- $el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline] || 'alphabetic');
2501
- } else {
2502
- $el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline]);
2503
- $el.setAttribute('alignment-baseline', BASELINE_MAP[textBaseline]);
2504
- }
2305
+ $el.setAttribute('dominant-baseline', BASELINE_MAP[textBaseline]);
2505
2306
  $el.setAttribute('paint-order', 'stroke');
2506
- // Since the geometry calculation is delayed, do it here if needed.
2507
- if (!metrics) {
2508
- text.isOverflowing();
2509
- metrics = text.parsedStyle.metrics;
2510
- }
2511
- var _metrics = metrics,
2512
- lines = _metrics.lines,
2513
- lineHeight = _metrics.lineHeight,
2514
- height = _metrics.height;
2307
+ var lines = metrics.lines,
2308
+ lineHeight = metrics.lineHeight,
2309
+ height = metrics.height;
2515
2310
  var lineNum = lines.length;
2516
2311
  var styleCSSText = '';
2517
2312
  if (dx !== 0 || dy !== 0) {
@@ -2527,6 +2322,11 @@
2527
2322
  if (lineNum === 1) {
2528
2323
  var textContent = convertHTML(lines[0]);
2529
2324
  $el.setAttribute('dx', "" + lineWidth / 2);
2325
+ // Since `text-after-edge` is not a standard property value, we use `dy` instead.
2326
+ if (textBaseline === 'bottom' || textBaseline === 'top') {
2327
+ $el.setAttribute('dominant-baseline', 'middle');
2328
+ $el.setAttribute('dy', textBaseline === 'bottom' ? "-0.5em" : '0.5em');
2329
+ }
2530
2330
  // <textPath> only support one line
2531
2331
  // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/textPath
2532
2332
  if (textPath) {
@@ -2621,7 +2421,7 @@
2621
2421
  }
2622
2422
  case gLite.Shape.TEXT:
2623
2423
  {
2624
- updateTextElementAttribute($el, parsedStyle, object);
2424
+ updateTextElementAttribute($el, parsedStyle);
2625
2425
  break;
2626
2426
  }
2627
2427
  }
@@ -3280,13 +3080,13 @@
3280
3080
  var DefElementManager = /*#__PURE__*/function () {
3281
3081
  function DefElementManager(context) {
3282
3082
  this.context = void 0;
3083
+ /**
3084
+ * container for <gradient> <clipPath>...
3085
+ */
3283
3086
  this.$def = void 0;
3284
3087
  this.gradientCache = {};
3285
3088
  this.context = context;
3286
3089
  }
3287
- /**
3288
- * container for <gradient> <clipPath>...
3289
- */
3290
3090
  var _proto = DefElementManager.prototype;
3291
3091
  _proto.getDefElement = function getDefElement() {
3292
3092
  return this.$def;
@@ -3578,9 +3378,7 @@
3578
3378
  if (!isNaN(iterable.length)) {
3579
3379
  var i = -1,
3580
3380
  next = function next() {
3581
- for (; ++i < iterable.length;) {
3582
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
3583
- }
3381
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
3584
3382
  return next.value = undefined, next.done = !0, next;
3585
3383
  };
3586
3384
  return next.next = next;
@@ -3626,9 +3424,7 @@
3626
3424
  }), exports.keys = function (val) {
3627
3425
  var object = Object(val),
3628
3426
  keys = [];
3629
- for (var key in object) {
3630
- keys.push(key);
3631
- }
3427
+ for (var key in object) keys.push(key);
3632
3428
  return keys.reverse(), function next() {
3633
3429
  for (; keys.length;) {
3634
3430
  var key = keys.pop();
@@ -3639,9 +3435,7 @@
3639
3435
  }, exports.values = values, Context.prototype = {
3640
3436
  constructor: Context,
3641
3437
  reset: function reset(skipTempReset) {
3642
- 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) {
3643
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
3644
- }
3438
+ 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);
3645
3439
  },
3646
3440
  stop: function stop() {
3647
3441
  this.done = !0;
@@ -3771,9 +3565,7 @@
3771
3565
  }
3772
3566
  function _arrayLikeToArray(arr, len) {
3773
3567
  if (len == null || len > arr.length) len = arr.length;
3774
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
3775
- arr2[i] = arr[i];
3776
- }
3568
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
3777
3569
  return arr2;
3778
3570
  }
3779
3571
  function _createForOfIteratorHelperLoose(o, allowArrayLike) {
@@ -3811,14 +3603,12 @@
3811
3603
  renderingService.hooks.pick.tapPromise(SVGPickerPlugin.tag, /*#__PURE__*/function () {
3812
3604
  var _ref = _asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee(result) {
3813
3605
  return _regeneratorRuntime$3().wrap(function _callee$(_context) {
3814
- while (1) {
3815
- switch (_context.prev = _context.next) {
3816
- case 0:
3817
- return _context.abrupt("return", _this.pick(runtime, doc, result));
3818
- case 1:
3819
- case "end":
3820
- return _context.stop();
3821
- }
3606
+ while (1) switch (_context.prev = _context.next) {
3607
+ case 0:
3608
+ return _context.abrupt("return", _this.pick(runtime, doc, result));
3609
+ case 1:
3610
+ case "end":
3611
+ return _context.stop();
3822
3612
  }
3823
3613
  }, _callee);
3824
3614
  }));
@@ -3909,29 +3699,27 @@
3909
3699
  var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
3910
3700
  var _this$canvasConfig, container, doc, devicePixelRatio, $namespace, dpr;
3911
3701
  return _regeneratorRuntime().wrap(function _callee$(_context) {
3912
- while (1) {
3913
- switch (_context.prev = _context.next) {
3914
- case 0:
3915
- _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document, devicePixelRatio = _this$canvasConfig.devicePixelRatio; // create container
3916
- this.$container = isString(container) ? (doc || document).getElementById(container) : container;
3917
- if (this.$container) {
3918
- if (!this.$container.style.position) {
3919
- this.$container.style.position = 'relative';
3920
- }
3921
- $namespace = createSVGElement('svg', doc);
3922
- $namespace.setAttribute('width', "" + this.canvasConfig.width);
3923
- $namespace.setAttribute('height', "" + this.canvasConfig.height);
3924
- this.$container.appendChild($namespace);
3925
- this.$namespace = $namespace;
3702
+ while (1) switch (_context.prev = _context.next) {
3703
+ case 0:
3704
+ _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document, devicePixelRatio = _this$canvasConfig.devicePixelRatio; // create container
3705
+ this.$container = isString(container) ? (doc || document).getElementById(container) : container;
3706
+ if (this.$container) {
3707
+ if (!this.$container.style.position) {
3708
+ this.$container.style.position = 'relative';
3926
3709
  }
3927
- // use user-defined dpr first
3928
- dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
3929
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
3930
- this.dpr = dpr;
3931
- case 6:
3932
- case "end":
3933
- return _context.stop();
3934
- }
3710
+ $namespace = createSVGElement('svg', doc);
3711
+ $namespace.setAttribute('width', "" + this.canvasConfig.width);
3712
+ $namespace.setAttribute('height', "" + this.canvasConfig.height);
3713
+ this.$container.appendChild($namespace);
3714
+ this.$namespace = $namespace;
3715
+ }
3716
+ // use user-defined dpr first
3717
+ dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
3718
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
3719
+ this.dpr = dpr;
3720
+ case 6:
3721
+ case "end":
3722
+ return _context.stop();
3935
3723
  }
3936
3724
  }, _callee, this);
3937
3725
  }));
@@ -3999,113 +3787,111 @@
3999
3787
  var _this = this;
4000
3788
  var cloneNode, doc, animationCounter, $style, svgDocType, svgDoc;
4001
3789
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
4002
- while (1) {
4003
- switch (_context2.prev = _context2.next) {
4004
- case 0:
4005
- cloneNode = this.$namespace.cloneNode(true);
4006
- doc = this.canvasConfig.document;
4007
- animationCounter = 0;
4008
- $style = null;
4009
- this.context.renderingContext.root.forEach(function (object) {
4010
- var animations = object.getAnimations();
4011
- if (animations.length) {
4012
- if (!$style) {
4013
- // export animations to <style>, using CSS Transformation
4014
- $style = (doc || document).createElement('style');
4015
- cloneNode.appendChild($style);
4016
- }
4017
- // @ts-ignore
4018
- var svgElement = object.elementSVG;
4019
- var selfSelector = "#" + svgElement.$el.id;
4020
- var groupSelector = "#" + svgElement.$groupEl.id;
4021
- var selfCssText = '';
4022
- var groupCssText = '';
4023
- animations.forEach(function (animation) {
4024
- var keyframes = animation.effect.getKeyframes();
4025
- // split attributes into self and group
4026
- if (keyframes.length) {
4027
- var selfAttributes = [];
4028
- var groupAttributes = [];
4029
- var _keyframes$ = keyframes[0],
4030
- offset = _keyframes$.offset,
4031
- composite = _keyframes$.composite,
4032
- computedOffset = _keyframes$.computedOffset,
4033
- easing = _keyframes$.easing,
4034
- transformOrigin = _keyframes$.transformOrigin,
4035
- rest = _objectWithoutPropertiesLoose(_keyframes$, _excluded2);
4036
- Object.keys(rest).forEach(function (attributeName) {
4037
- var _propertyMetadataCach;
4038
- if (attributeName === 'transform') {
4039
- groupAttributes.push(attributeName);
4040
- }
4041
- var inherited = !!((_propertyMetadataCach = gLite.propertyMetadataCache[attributeName]) === null || _propertyMetadataCach === void 0 ? void 0 : _propertyMetadataCach.inh);
4042
- if (inherited) {
4043
- groupAttributes.push(attributeName);
4044
- } else if (attributeName !== 'transform') {
4045
- selfAttributes.push(attributeName);
4046
- }
4047
- });
4048
- if (groupAttributes.length) {
4049
- var keyframesWithGroup = keyframes.map(function (keyframe) {
4050
- var offset = keyframe.offset,
4051
- composite = keyframe.composite,
4052
- computedOffset = keyframe.computedOffset,
4053
- easing = keyframe.easing,
4054
- transformOrigin = keyframe.transformOrigin,
4055
- rest = _objectWithoutPropertiesLoose(keyframe, _excluded3);
4056
- var ret = {
4057
- offset: offset,
4058
- composite: composite,
4059
- computedOffset: computedOffset,
4060
- easing: easing
4061
- };
4062
- Object.keys(rest).forEach(function (attributeName) {
4063
- if (groupAttributes.includes(attributeName)) {
4064
- ret[attributeName] = keyframe[attributeName];
4065
- }
4066
- });
4067
- return ret;
4068
- });
4069
- groupCssText += _this.generateCSSText("a" + animationCounter++, groupSelector, keyframesWithGroup, animation.effect.getComputedTiming(), {
4070
- transform: svgElement.$groupEl.getAttribute('transform')
4071
- });
3790
+ while (1) switch (_context2.prev = _context2.next) {
3791
+ case 0:
3792
+ cloneNode = this.$namespace.cloneNode(true);
3793
+ doc = this.canvasConfig.document;
3794
+ animationCounter = 0;
3795
+ $style = null;
3796
+ this.context.renderingContext.root.forEach(function (object) {
3797
+ var animations = object.getAnimations();
3798
+ if (animations.length) {
3799
+ if (!$style) {
3800
+ // export animations to <style>, using CSS Transformation
3801
+ $style = (doc || document).createElement('style');
3802
+ cloneNode.appendChild($style);
3803
+ }
3804
+ // @ts-ignore
3805
+ var svgElement = object.elementSVG;
3806
+ var selfSelector = "#" + svgElement.$el.id;
3807
+ var groupSelector = "#" + svgElement.$groupEl.id;
3808
+ var selfCssText = '';
3809
+ var groupCssText = '';
3810
+ animations.forEach(function (animation) {
3811
+ var keyframes = animation.effect.getKeyframes();
3812
+ // split attributes into self and group
3813
+ if (keyframes.length) {
3814
+ var selfAttributes = [];
3815
+ var groupAttributes = [];
3816
+ var _keyframes$ = keyframes[0],
3817
+ offset = _keyframes$.offset,
3818
+ composite = _keyframes$.composite,
3819
+ computedOffset = _keyframes$.computedOffset,
3820
+ easing = _keyframes$.easing,
3821
+ transformOrigin = _keyframes$.transformOrigin,
3822
+ rest = _objectWithoutPropertiesLoose(_keyframes$, _excluded2);
3823
+ Object.keys(rest).forEach(function (attributeName) {
3824
+ var _propertyMetadataCach;
3825
+ if (attributeName === 'transform') {
3826
+ groupAttributes.push(attributeName);
4072
3827
  }
4073
- if (selfAttributes.length) {
4074
- var keyframesWithSelf = keyframes.map(function (keyframe) {
4075
- var offset = keyframe.offset,
4076
- composite = keyframe.composite,
4077
- computedOffset = keyframe.computedOffset,
4078
- easing = keyframe.easing,
4079
- transformOrigin = keyframe.transformOrigin,
4080
- rest = _objectWithoutPropertiesLoose(keyframe, _excluded4);
4081
- var ret = {
4082
- offset: offset,
4083
- composite: composite,
4084
- computedOffset: computedOffset,
4085
- easing: easing
4086
- };
4087
- Object.keys(rest).forEach(function (attributeName) {
4088
- if (selfAttributes.includes(attributeName)) {
4089
- ret[attributeName] = keyframe[attributeName];
4090
- }
4091
- });
4092
- return ret;
4093
- });
4094
- selfCssText += _this.generateCSSText("a" + animationCounter++, selfSelector, keyframesWithSelf, animation.effect.getComputedTiming());
3828
+ var inherited = !!((_propertyMetadataCach = gLite.propertyMetadataCache[attributeName]) === null || _propertyMetadataCach === void 0 ? void 0 : _propertyMetadataCach.inh);
3829
+ if (inherited) {
3830
+ groupAttributes.push(attributeName);
3831
+ } else if (attributeName !== 'transform') {
3832
+ selfAttributes.push(attributeName);
4095
3833
  }
3834
+ });
3835
+ if (groupAttributes.length) {
3836
+ var keyframesWithGroup = keyframes.map(function (keyframe) {
3837
+ var offset = keyframe.offset,
3838
+ composite = keyframe.composite,
3839
+ computedOffset = keyframe.computedOffset,
3840
+ easing = keyframe.easing,
3841
+ transformOrigin = keyframe.transformOrigin,
3842
+ rest = _objectWithoutPropertiesLoose(keyframe, _excluded3);
3843
+ var ret = {
3844
+ offset: offset,
3845
+ composite: composite,
3846
+ computedOffset: computedOffset,
3847
+ easing: easing
3848
+ };
3849
+ Object.keys(rest).forEach(function (attributeName) {
3850
+ if (groupAttributes.includes(attributeName)) {
3851
+ ret[attributeName] = keyframe[attributeName];
3852
+ }
3853
+ });
3854
+ return ret;
3855
+ });
3856
+ groupCssText += _this.generateCSSText("a" + animationCounter++, groupSelector, keyframesWithGroup, animation.effect.getComputedTiming(), {
3857
+ transform: svgElement.$groupEl.getAttribute('transform')
3858
+ });
4096
3859
  }
4097
- });
4098
- $style.textContent += selfCssText + groupCssText;
4099
- }
4100
- });
4101
- svgDocType = document.implementation.createDocumentType('svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
4102
- svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', svgDocType);
4103
- svgDoc.replaceChild(cloneNode, svgDoc.documentElement);
4104
- return _context2.abrupt("return", "data:image/svg+xml;charset=utf8," + encodeURIComponent(new XMLSerializer().serializeToString(svgDoc)));
4105
- case 10:
4106
- case "end":
4107
- return _context2.stop();
4108
- }
3860
+ if (selfAttributes.length) {
3861
+ var keyframesWithSelf = keyframes.map(function (keyframe) {
3862
+ var offset = keyframe.offset,
3863
+ composite = keyframe.composite,
3864
+ computedOffset = keyframe.computedOffset,
3865
+ easing = keyframe.easing,
3866
+ transformOrigin = keyframe.transformOrigin,
3867
+ rest = _objectWithoutPropertiesLoose(keyframe, _excluded4);
3868
+ var ret = {
3869
+ offset: offset,
3870
+ composite: composite,
3871
+ computedOffset: computedOffset,
3872
+ easing: easing
3873
+ };
3874
+ Object.keys(rest).forEach(function (attributeName) {
3875
+ if (selfAttributes.includes(attributeName)) {
3876
+ ret[attributeName] = keyframe[attributeName];
3877
+ }
3878
+ });
3879
+ return ret;
3880
+ });
3881
+ selfCssText += _this.generateCSSText("a" + animationCounter++, selfSelector, keyframesWithSelf, animation.effect.getComputedTiming());
3882
+ }
3883
+ }
3884
+ });
3885
+ $style.textContent += selfCssText + groupCssText;
3886
+ }
3887
+ });
3888
+ svgDocType = document.implementation.createDocumentType('svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
3889
+ svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', svgDocType);
3890
+ svgDoc.replaceChild(cloneNode, svgDoc.documentElement);
3891
+ return _context2.abrupt("return", "data:image/svg+xml;charset=utf8," + encodeURIComponent(new XMLSerializer().serializeToString(svgDoc)));
3892
+ case 10:
3893
+ case "end":
3894
+ return _context2.stop();
4109
3895
  }
4110
3896
  }, _callee2, this);
4111
3897
  }));