@antv/g-lite 1.2.10 → 1.2.12

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.js CHANGED
@@ -4254,6 +4254,33 @@ function getOrCalculatePathTotalLength(path) {
4254
4254
  }
4255
4255
  return path.parsedStyle.path.totalLength;
4256
4256
  }
4257
+ function removeRedundantMCommand(path) {
4258
+ for (var i = 0; i < path.length; i++) {
4259
+ var prevSegment = path[i - 1];
4260
+ var segment = path[i];
4261
+ var cmd = segment[0];
4262
+ if (cmd === 'M') {
4263
+ if (prevSegment) {
4264
+ var prevCmd = prevSegment[0];
4265
+ var srcPoint = [segment[1], segment[2]];
4266
+ var destPoint = void 0;
4267
+ if (prevCmd === 'L' || prevCmd === 'M') {
4268
+ destPoint = [prevSegment[1], prevSegment[2]];
4269
+ }
4270
+ else if (prevCmd === 'C' || prevCmd === 'A' || prevCmd === 'Q') {
4271
+ destPoint = [
4272
+ prevSegment[prevSegment.length - 2],
4273
+ prevSegment[prevSegment.length - 1],
4274
+ ];
4275
+ }
4276
+ if (destPoint && isSamePoint(srcPoint, destPoint)) {
4277
+ path.splice(i, 1);
4278
+ i--;
4279
+ }
4280
+ }
4281
+ }
4282
+ }
4283
+ }
4257
4284
  function hasArcOrBezier(path) {
4258
4285
  var hasArc = false;
4259
4286
  var count = path.length;
@@ -5024,6 +5051,7 @@ var internalParsePath = function (path) {
5024
5051
  absolutePath = util.normalizePath('');
5025
5052
  console.error("[g]: Invalid SVG Path definition: ".concat(path));
5026
5053
  }
5054
+ removeRedundantMCommand(absolutePath);
5027
5055
  var hasArc = hasArcOrBezier(absolutePath);
5028
5056
  var _a = extractPolygons(absolutePath), polygons = _a.polygons, polylines = _a.polylines;
5029
5057
  // for later use
@@ -7745,6 +7773,7 @@ var TOUCH_TO_POINTER = {
7745
7773
  touchmove: 'pointermove',
7746
7774
  touchcancel: 'pointercancel',
7747
7775
  };
7776
+ var clock = typeof performance === 'object' && performance.now ? performance : Date;
7748
7777
 
7749
7778
  function isFillOrStrokeAffected(pointerEvents, fill, stroke) {
7750
7779
  // account for pointerEvents
@@ -9199,7 +9228,7 @@ var EventService = /** @class */ (function () {
9199
9228
  };
9200
9229
  this.onPointerUp = function (from) {
9201
9230
  var _a;
9202
- var now = performance.now();
9231
+ var now = clock.now();
9203
9232
  var e = _this.createPointerEvent(from, undefined, undefined, _this.context.config.alwaysTriggerPointerEventOnCanvas
9204
9233
  ? _this.rootTarget
9205
9234
  : undefined);
@@ -9796,7 +9825,7 @@ var EventService = /** @class */ (function () {
9796
9825
  };
9797
9826
  EventService.prototype.copyData = function (from, to) {
9798
9827
  to.isTrusted = from.isTrusted;
9799
- to.timeStamp = performance.now();
9828
+ to.timeStamp = clock.now();
9800
9829
  to.type = from.type;
9801
9830
  to.detail = from.detail;
9802
9831
  to.view = from.view;
@@ -14536,7 +14565,7 @@ var EventPlugin = /** @class */ (function () {
14536
14565
  EventPlugin.prototype.transferMouseData = function (event, nativeEvent) {
14537
14566
  event.isTrusted = nativeEvent.isTrusted;
14538
14567
  event.srcElement = nativeEvent.srcElement;
14539
- event.timeStamp = performance.now();
14568
+ event.timeStamp = clock.now();
14540
14569
  event.type = nativeEvent.type;
14541
14570
  event.altKey = nativeEvent.altKey;
14542
14571
  event.metaKey = nativeEvent.metaKey;