@antv/g 5.6.0 → 5.6.1

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
@@ -18483,11 +18483,13 @@
18483
18483
  * @param {number} y2 结束点 y
18484
18484
  * @return {number} 距离
18485
18485
  */
18486
+
18486
18487
  function distance$1(x1, y1, x2, y2) {
18487
18488
  var dx = x1 - x2;
18488
18489
  var dy = y1 - y2;
18489
18490
  return Math.sqrt(dx * dx + dy * dy);
18490
18491
  }
18492
+
18491
18493
  function getBBoxByArray(xArr, yArr) {
18492
18494
  var minX = Math.min.apply(Math, xArr);
18493
18495
  var minY = Math.min.apply(Math, yArr);
@@ -18500,7 +18502,6 @@
18500
18502
  height: maxY - minY
18501
18503
  };
18502
18504
  }
18503
-
18504
18505
  var line = {
18505
18506
  /**
18506
18507
  * 计算线段的包围盒
@@ -18652,6 +18653,7 @@
18652
18653
  * @return {object} 点的坐标
18653
18654
  */
18654
18655
 
18656
+
18655
18657
  function pointAtSegments(points, t) {
18656
18658
  // 边界判断
18657
18659
  if (t > 1 || t < 0 || points.length < 2) {
@@ -18697,6 +18699,7 @@
18697
18699
  * @param {number} t 百分比 0-1
18698
18700
  */
18699
18701
 
18702
+
18700
18703
  function angleAtSegments(points, t) {
18701
18704
  // 边界判断
18702
18705
  if (t > 1 || t < 0 || points.length < 2) {
@@ -18727,6 +18730,7 @@
18727
18730
 
18728
18731
  return angle;
18729
18732
  }
18733
+
18730
18734
  function distanceAtSegment(points, x, y) {
18731
18735
  var minDistance = Infinity;
18732
18736
 
@@ -20051,6 +20055,10 @@
20051
20055
 
20052
20056
  function parseTransformOrigin(value) {
20053
20057
  if (isString(value)) {
20058
+ if (value === 'text-anchor') {
20059
+ return [new CSSUnitValue(0, 'px'), new CSSUnitValue(0, 'px')];
20060
+ }
20061
+
20054
20062
  var values = value.split(' ');
20055
20063
 
20056
20064
  if (values.length === 1) {
@@ -21604,7 +21612,8 @@
21604
21612
  textBaseline: '',
21605
21613
  textTransform: '',
21606
21614
  zIndex: '',
21607
- filter: ''
21615
+ filter: '',
21616
+ shadowType: ''
21608
21617
  };
21609
21618
  /**
21610
21619
  * prototype chains: DisplayObject -> Element -> Node -> EventTarget
@@ -22694,7 +22703,7 @@
22694
22703
  type: exports.Shape.PATH,
22695
22704
  style: _extends({
22696
22705
  path: '',
22697
- miterLimit: 4
22706
+ miterLimit: ''
22698
22707
  }, style)
22699
22708
  }, rest)) || this;
22700
22709
  }
@@ -22795,7 +22804,7 @@
22795
22804
  type: exports.Shape.POLYGON,
22796
22805
  style: _extends({
22797
22806
  points: '',
22798
- miterLimit: 4
22807
+ miterLimit: ''
22799
22808
  }, style)
22800
22809
  }, rest)) || this;
22801
22810
  }
@@ -22816,7 +22825,7 @@
22816
22825
  type: exports.Shape.POLYLINE,
22817
22826
  style: _extends({
22818
22827
  points: '',
22819
- miterLimit: 4
22828
+ miterLimit: ''
22820
22829
  }, style)
22821
22830
  }, rest)) || this;
22822
22831
  }
@@ -22907,14 +22916,15 @@
22907
22916
  /**
22908
22917
  * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement#constants
22909
22918
  */
22919
+ // LENGTHADJUST_SPACING: number = 1;
22920
+ // LENGTHADJUST_SPACINGANDGLYPHS: number = 2;
22921
+ // LENGTHADJUST_UNKNOWN: number = 0;
22910
22922
  function Text(_temp) {
22911
- var _this;
22912
-
22913
22923
  var _ref = _temp === void 0 ? {} : _temp,
22914
22924
  style = _ref.style,
22915
22925
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$a);
22916
22926
 
22917
- _this = _DisplayObject.call(this, _extends({
22927
+ return _DisplayObject.call(this, _extends({
22918
22928
  type: exports.Shape.TEXT,
22919
22929
  style: _extends({
22920
22930
  x: '',
@@ -22928,17 +22938,10 @@
22928
22938
  textAlign: '',
22929
22939
  textBaseline: '',
22930
22940
  textTransform: '',
22931
- // dropShadow: false,
22932
- // dropShadowAlpha: 1,
22933
- // dropShadowAngle: Math.PI / 6,
22934
- // dropShadowBlur: 0,
22935
- // dropShadowColor: '#000',
22936
- // dropShadowDistance: 5,
22937
22941
  fill: 'black',
22938
- // stroke: 'black',
22939
- letterSpacing: 0,
22940
- lineHeight: 0,
22941
- miterLimit: 10,
22942
+ letterSpacing: '',
22943
+ lineHeight: '',
22944
+ miterLimit: '',
22942
22945
  whiteSpace: 'pre',
22943
22946
  wordWrap: false,
22944
22947
  wordWrapWidth: 0,
@@ -22947,57 +22950,45 @@
22947
22950
  dy: ''
22948
22951
  }, style)
22949
22952
  }, rest)) || this;
22950
- _this.LENGTHADJUST_SPACING = 1;
22951
- _this.LENGTHADJUST_SPACINGANDGLYPHS = 2;
22952
- _this.LENGTHADJUST_UNKNOWN = 0;
22953
- _this.lengthAdjust = void 0;
22954
- _this.textLength = void 0;
22955
- return _this;
22956
- }
22957
-
22958
- var _proto = Text.prototype;
22953
+ } // lengthAdjust: SVGAnimatedEnumeration;
22954
+ // textLength: SVGAnimatedLength;
22955
+ // getCharNumAtPosition(point?: DOMPointInit): number {
22956
+ // throw new Error('Method not implemented.');
22957
+ // }
22959
22958
 
22960
- _proto.getCharNumAtPosition = function getCharNumAtPosition(point) {
22961
- throw new Error('Method not implemented.');
22962
- }
22963
22959
  /**
22964
22960
  * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
22965
22961
  */
22966
- ;
22962
+
22963
+
22964
+ var _proto = Text.prototype;
22967
22965
 
22968
22966
  _proto.getComputedTextLength = function getComputedTextLength() {
22969
22967
  var _this$parsedStyle$met;
22970
22968
 
22971
22969
  return ((_this$parsedStyle$met = this.parsedStyle.metrics) === null || _this$parsedStyle$met === void 0 ? void 0 : _this$parsedStyle$met.maxLineWidth) || 0;
22972
- };
22973
-
22974
- _proto.getEndPositionOfChar = function getEndPositionOfChar(charnum) {
22975
- throw new Error('Method not implemented.');
22976
- };
22977
-
22978
- _proto.getExtentOfChar = function getExtentOfChar(charnum) {
22979
- throw new Error('Method not implemented.');
22980
- };
22981
-
22982
- _proto.getNumberOfChars = function getNumberOfChars() {
22983
- throw new Error('Method not implemented.');
22984
- };
22985
-
22986
- _proto.getRotationOfChar = function getRotationOfChar(charnum) {
22987
- throw new Error('Method not implemented.');
22988
- };
22989
-
22990
- _proto.getStartPositionOfChar = function getStartPositionOfChar(charnum) {
22991
- throw new Error('Method not implemented.');
22992
- };
22993
-
22994
- _proto.getSubStringLength = function getSubStringLength(charnum, nchars) {
22995
- throw new Error('Method not implemented.');
22996
- };
22997
-
22998
- _proto.selectSubString = function selectSubString(charnum, nchars) {
22999
- throw new Error('Method not implemented.');
23000
- };
22970
+ } // getEndPositionOfChar(charnum: number): DOMPoint {
22971
+ // throw new Error('Method not implemented.');
22972
+ // }
22973
+ // getExtentOfChar(charnum: number): DOMRect {
22974
+ // throw new Error('Method not implemented.');
22975
+ // }
22976
+ // getNumberOfChars(): number {
22977
+ // throw new Error('Method not implemented.');
22978
+ // }
22979
+ // getRotationOfChar(charnum: number): number {
22980
+ // throw new Error('Method not implemented.');
22981
+ // }
22982
+ // getStartPositionOfChar(charnum: number): DOMPoint {
22983
+ // throw new Error('Method not implemented.');
22984
+ // }
22985
+ // getSubStringLength(charnum: number, nchars: number): number {
22986
+ // throw new Error('Method not implemented.');
22987
+ // }
22988
+ // selectSubString(charnum: number, nchars: number): void {
22989
+ // throw new Error('Method not implemented.');
22990
+ // }
22991
+ ;
23001
22992
 
23002
22993
  _proto.getLineBoundingRects = function getLineBoundingRects() {
23003
22994
  var _this$parsedStyle$met2;
@@ -23939,7 +23930,9 @@
23939
23930
  clazz = tagName === 'tspan' ? Text : Group;
23940
23931
  }
23941
23932
 
23942
- return new clazz(options);
23933
+ var shape = new clazz(options);
23934
+ shape.ownerDocument = this;
23935
+ return shape;
23943
23936
  };
23944
23937
 
23945
23938
  _proto.createElementNS = function createElementNS(namespaceURI, tagName, options) {
@@ -27589,20 +27582,15 @@
27589
27582
 
27590
27583
  if (this.renderingContext.renderReasons.size && this.inited) {
27591
27584
  this.renderDisplayObject(this.renderingContext.root, canvasConfig);
27585
+ this.hooks.beginFrame.call();
27586
+ this.renderingContext.renderListCurrentFrame.forEach(function (object) {
27587
+ _this2.hooks.beforeRender.call(object);
27592
27588
 
27593
- if (this.renderingContext.renderListCurrentFrame.length || this.renderingContext.renderListLastFrame.length !== this.renderingContext.renderListCurrentFrame.length) {
27594
- this.hooks.beginFrame.call();
27595
- this.renderingContext.renderListCurrentFrame.forEach(function (object) {
27596
- _this2.hooks.beforeRender.call(object);
27597
-
27598
- _this2.hooks.render.call(object);
27589
+ _this2.hooks.render.call(object);
27599
27590
 
27600
- _this2.hooks.afterRender.call(object);
27601
- });
27602
- this.hooks.endFrame.call();
27603
- }
27604
-
27605
- this.renderingContext.renderListLastFrame = [].concat(this.renderingContext.renderListCurrentFrame);
27591
+ _this2.hooks.afterRender.call(object);
27592
+ });
27593
+ this.hooks.endFrame.call();
27606
27594
  this.renderingContext.renderListCurrentFrame = [];
27607
27595
  this.renderingContext.renderReasons.clear();
27608
27596
  } // console.log('stats', this.stats);
@@ -29098,13 +29086,11 @@
29098
29086
  _proto.measureText = function measureText(text, parsedStyle, offscreenCanvas) {
29099
29087
  var fontSize = parsedStyle.fontSize,
29100
29088
  wordWrap = parsedStyle.wordWrap,
29101
- _parsedStyle$lineHeig = parsedStyle.lineHeight,
29102
- strokeHeight = _parsedStyle$lineHeig === void 0 ? 0 : _parsedStyle$lineHeig,
29089
+ strokeHeight = parsedStyle.lineHeight,
29103
29090
  lineWidth = parsedStyle.lineWidth,
29104
29091
  textBaseline = parsedStyle.textBaseline,
29105
29092
  textAlign = parsedStyle.textAlign,
29106
- _parsedStyle$letterSp = parsedStyle.letterSpacing,
29107
- letterSpacing = _parsedStyle$letterSp === void 0 ? 0 : _parsedStyle$letterSp,
29093
+ letterSpacing = parsedStyle.letterSpacing,
29108
29094
  _parsedStyle$leading = parsedStyle.leading,
29109
29095
  leading = _parsedStyle$leading === void 0 ? 0 : _parsedStyle$leading;
29110
29096
  var font = toFontString(parsedStyle);
@@ -29124,7 +29110,7 @@
29124
29110
  var maxLineWidth = 0;
29125
29111
 
29126
29112
  for (var i = 0; i < lines.length; i++) {
29127
- var _lineWidth = context.measureText(lines[i]).width + (lines[i].length - 1) * letterSpacing;
29113
+ var _lineWidth = context.measureText(lines[i]).width + (lines[i].length - 1) * letterSpacing.value;
29128
29114
 
29129
29115
  lineWidths[i] = _lineWidth;
29130
29116
  maxLineWidth = Math.max(maxLineWidth, _lineWidth);
@@ -29134,7 +29120,7 @@
29134
29120
  // width += dropShadowDistance;
29135
29121
  // }
29136
29122
 
29137
- var lineHeight = strokeHeight || fontProperties.fontSize + lineWidth.value;
29123
+ var lineHeight = strokeHeight.value || fontProperties.fontSize + lineWidth.value;
29138
29124
  var height = Math.max(lineHeight, fontProperties.fontSize + lineWidth.value) + (lines.length - 1) * (lineHeight + leading); // if (dropShadow) {
29139
29125
  // height += dropShadowDistance;
29140
29126
  // }
@@ -29179,17 +29165,16 @@
29179
29165
 
29180
29166
  var _ref$wordWrapWidth = _ref.wordWrapWidth,
29181
29167
  wordWrapWidth = _ref$wordWrapWidth === void 0 ? 0 : _ref$wordWrapWidth,
29182
- _ref$letterSpacing = _ref.letterSpacing,
29183
- letterSpacing = _ref$letterSpacing === void 0 ? 0 : _ref$letterSpacing;
29168
+ letterSpacing = _ref.letterSpacing;
29184
29169
  var context = this.offscreenCanvas.getOrCreateContext(offscreenCanvas);
29185
- var maxWidth = wordWrapWidth + letterSpacing;
29170
+ var maxWidth = wordWrapWidth + letterSpacing.value;
29186
29171
  var lines = [];
29187
29172
  var currentIndex = 0;
29188
29173
  var currentWidth = 0;
29189
29174
  var cache = {};
29190
29175
 
29191
29176
  var calcWidth = function calcWidth(char) {
29192
- return _this2.getFromCache(char, letterSpacing, cache, context);
29177
+ return _this2.getFromCache(char, letterSpacing.value, cache, context);
29193
29178
  };
29194
29179
 
29195
29180
  Array.from(text).forEach(function (char, i) {
@@ -29774,7 +29759,7 @@
29774
29759
  return fontSize.clone();
29775
29760
  }
29776
29761
 
29777
- return new CSSUnitValue(0, 'px');
29762
+ return null;
29778
29763
  }
29779
29764
  /**
29780
29765
  * <length> & <percentage>
@@ -29802,8 +29787,13 @@
29802
29787
  } else if (computed.unit === exports.UnitType.kEms) {
29803
29788
  if (object.parentNode) {
29804
29789
  var fontSize = getFontSize(object.parentNode);
29805
- fontSize.value *= computed.value;
29806
- return fontSize;
29790
+
29791
+ if (fontSize) {
29792
+ fontSize.value *= computed.value;
29793
+ return fontSize;
29794
+ } else {
29795
+ registry.addUnresolveProperty(object, name);
29796
+ }
29807
29797
  }
29808
29798
 
29809
29799
  return new CSSUnitValue(0, 'px');
@@ -29813,8 +29803,12 @@
29813
29803
  if (object === null || object === void 0 ? void 0 : (_object$ownerDocument = object.ownerDocument) === null || _object$ownerDocument === void 0 ? void 0 : _object$ownerDocument.documentElement) {
29814
29804
  var _fontSize = getFontSize(object.ownerDocument.documentElement);
29815
29805
 
29816
- _fontSize.value *= computed.value;
29817
- return _fontSize;
29806
+ if (_fontSize) {
29807
+ _fontSize.value *= computed.value;
29808
+ return _fontSize;
29809
+ } else {
29810
+ registry.addUnresolveProperty(object, name);
29811
+ }
29818
29812
  }
29819
29813
 
29820
29814
  return new CSSUnitValue(0, 'px');
@@ -30560,6 +30554,11 @@
30560
30554
  keywords: ['none'],
30561
30555
  defaultValue: 'none',
30562
30556
  syntax: exports.PropertySyntax.PAINT
30557
+ }, {
30558
+ name: 'shadowType',
30559
+ keywords: ['inner', 'outer', 'both'],
30560
+ defaultValue: 'outer',
30561
+ layoutDependent: true
30563
30562
  }, {
30564
30563
  name: 'shadowColor',
30565
30564
  interpolable: true,
@@ -30696,6 +30695,10 @@
30696
30695
  return 'center';
30697
30696
  }
30698
30697
 
30698
+ if (nodeName === exports.Shape.TEXT) {
30699
+ return 'text-anchor';
30700
+ }
30701
+
30699
30702
  return 'left top';
30700
30703
  },
30701
30704
  layoutDependent: true,
@@ -30887,16 +30890,27 @@
30887
30890
  defaultValue: 'normal'
30888
30891
  }, {
30889
30892
  name: 'lineHeight',
30890
- layoutDependent: true // interpolable: true,
30891
- // inherited: true,
30892
- // defaultValue: '-100%'
30893
-
30893
+ layoutDependent: true,
30894
+ syntax: exports.PropertySyntax.LENGTH,
30895
+ interpolable: true,
30896
+ defaultValue: '0'
30894
30897
  }, {
30895
30898
  name: 'letterSpacing',
30896
- layoutDependent: true // interpolable: true,
30897
- // inherited: true,
30898
- // defaultValue: '0',
30899
+ layoutDependent: true,
30900
+ syntax: exports.PropertySyntax.LENGTH,
30901
+ interpolable: true,
30902
+ defaultValue: '0'
30903
+ }, {
30904
+ name: 'miterLimit',
30905
+ layoutDependent: true,
30906
+ syntax: exports.PropertySyntax.NUMBER,
30907
+ defaultValue: function defaultValue(nodeName) {
30908
+ if (nodeName === exports.Shape.PATH || nodeName === exports.Shape.POLYGON || nodeName === exports.Shape.POLYLINE) {
30909
+ return '4';
30910
+ }
30899
30911
 
30912
+ return '10';
30913
+ }
30900
30914
  }, {
30901
30915
  name: 'wordWrap',
30902
30916
  layoutDependent: true
@@ -31292,6 +31306,7 @@
31292
31306
  var stroke = parsedStyle.stroke,
31293
31307
  lineWidth = parsedStyle.lineWidth,
31294
31308
  increasedLineWidthForHitTesting = parsedStyle.increasedLineWidthForHitTesting,
31309
+ shadowType = parsedStyle.shadowType,
31295
31310
  shadowColor = parsedStyle.shadowColor,
31296
31311
  _parsedStyle$filter = parsedStyle.filter,
31297
31312
  filter = _parsedStyle$filter === void 0 ? [] : _parsedStyle$filter,
@@ -31323,7 +31338,7 @@
31323
31338
 
31324
31339
  geometry.renderBounds.update(center, halfExtents); // account for shadow, only support constant value now
31325
31340
 
31326
- if (shadowColor) {
31341
+ if (shadowColor && (shadowType === null || shadowType === void 0 ? void 0 : shadowType.value) !== 'inner') {
31327
31342
  var _geometry$renderBound = geometry.renderBounds,
31328
31343
  min = _geometry$renderBound.min,
31329
31344
  max = _geometry$renderBound.max;
@@ -31688,9 +31703,8 @@
31688
31703
  if (!cullable.isCulled() && object.isVisible()) {
31689
31704
  return object;
31690
31705
  } else {
31691
- if (_this.renderingContext.renderListLastFrame.indexOf(object) > -1) {
31692
- object.dispatchEvent(new CustomEvent(exports.ElementEvent.CULLED));
31693
- }
31706
+ // if (this.renderingContext.renderListLastFrame.indexOf(object) > -1) {
31707
+ object.dispatchEvent(new CustomEvent(exports.ElementEvent.CULLED)); // }
31694
31708
  }
31695
31709
 
31696
31710
  return null;
@@ -32563,7 +32577,6 @@
32563
32577
  * the root node in scene graph
32564
32578
  */
32565
32579
  root: this.document.documentElement,
32566
- renderListLastFrame: [],
32567
32580
  renderListCurrentFrame: [],
32568
32581
  unculledEntities: [],
32569
32582
  renderReasons: new Set(),
@@ -33013,7 +33026,6 @@
33013
33026
  return Canvas;
33014
33027
  }(EventTarget);
33015
33028
 
33016
- // import * as ManaSyringe from 'mana-syringe';
33017
33029
  GlobalContainer$1.load(containerModule);
33018
33030
  var layoutEngine = GlobalContainer$1.get(exports.LayoutEngine);
33019
33031