@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.js CHANGED
@@ -9053,6 +9053,10 @@ function mergeTransforms(left, right, target) {
9053
9053
 
9054
9054
  function parseTransformOrigin(value) {
9055
9055
  if (isString(value)) {
9056
+ if (value === 'text-anchor') {
9057
+ return [new CSSUnitValue(0, 'px'), new CSSUnitValue(0, 'px')];
9058
+ }
9059
+
9056
9060
  var values = value.split(' ');
9057
9061
 
9058
9062
  if (values.length === 1) {
@@ -10606,7 +10610,8 @@ var DEFAULT_STYLE_PROPS = {
10606
10610
  textBaseline: '',
10607
10611
  textTransform: '',
10608
10612
  zIndex: '',
10609
- filter: ''
10613
+ filter: '',
10614
+ shadowType: ''
10610
10615
  };
10611
10616
  /**
10612
10617
  * prototype chains: DisplayObject -> Element -> Node -> EventTarget
@@ -11696,7 +11701,7 @@ var Path = /*#__PURE__*/function (_DisplayObject) {
11696
11701
  type: exports.Shape.PATH,
11697
11702
  style: _extends({
11698
11703
  path: '',
11699
- miterLimit: 4
11704
+ miterLimit: ''
11700
11705
  }, style)
11701
11706
  }, rest)) || this;
11702
11707
  }
@@ -11797,7 +11802,7 @@ var Polygon = /*#__PURE__*/function (_DisplayObject) {
11797
11802
  type: exports.Shape.POLYGON,
11798
11803
  style: _extends({
11799
11804
  points: '',
11800
- miterLimit: 4
11805
+ miterLimit: ''
11801
11806
  }, style)
11802
11807
  }, rest)) || this;
11803
11808
  }
@@ -11818,7 +11823,7 @@ var Polyline = /*#__PURE__*/function (_DisplayObject) {
11818
11823
  type: exports.Shape.POLYLINE,
11819
11824
  style: _extends({
11820
11825
  points: '',
11821
- miterLimit: 4
11826
+ miterLimit: ''
11822
11827
  }, style)
11823
11828
  }, rest)) || this;
11824
11829
  }
@@ -11909,14 +11914,15 @@ var Text = /*#__PURE__*/function (_DisplayObject) {
11909
11914
  /**
11910
11915
  * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement#constants
11911
11916
  */
11917
+ // LENGTHADJUST_SPACING: number = 1;
11918
+ // LENGTHADJUST_SPACINGANDGLYPHS: number = 2;
11919
+ // LENGTHADJUST_UNKNOWN: number = 0;
11912
11920
  function Text(_temp) {
11913
- var _this;
11914
-
11915
11921
  var _ref = _temp === void 0 ? {} : _temp,
11916
11922
  style = _ref.style,
11917
11923
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$a);
11918
11924
 
11919
- _this = _DisplayObject.call(this, _extends({
11925
+ return _DisplayObject.call(this, _extends({
11920
11926
  type: exports.Shape.TEXT,
11921
11927
  style: _extends({
11922
11928
  x: '',
@@ -11930,17 +11936,10 @@ var Text = /*#__PURE__*/function (_DisplayObject) {
11930
11936
  textAlign: '',
11931
11937
  textBaseline: '',
11932
11938
  textTransform: '',
11933
- // dropShadow: false,
11934
- // dropShadowAlpha: 1,
11935
- // dropShadowAngle: Math.PI / 6,
11936
- // dropShadowBlur: 0,
11937
- // dropShadowColor: '#000',
11938
- // dropShadowDistance: 5,
11939
11939
  fill: 'black',
11940
- // stroke: 'black',
11941
- letterSpacing: 0,
11942
- lineHeight: 0,
11943
- miterLimit: 10,
11940
+ letterSpacing: '',
11941
+ lineHeight: '',
11942
+ miterLimit: '',
11944
11943
  whiteSpace: 'pre',
11945
11944
  wordWrap: false,
11946
11945
  wordWrapWidth: 0,
@@ -11949,57 +11948,45 @@ var Text = /*#__PURE__*/function (_DisplayObject) {
11949
11948
  dy: ''
11950
11949
  }, style)
11951
11950
  }, rest)) || this;
11952
- _this.LENGTHADJUST_SPACING = 1;
11953
- _this.LENGTHADJUST_SPACINGANDGLYPHS = 2;
11954
- _this.LENGTHADJUST_UNKNOWN = 0;
11955
- _this.lengthAdjust = void 0;
11956
- _this.textLength = void 0;
11957
- return _this;
11958
- }
11959
-
11960
- var _proto = Text.prototype;
11951
+ } // lengthAdjust: SVGAnimatedEnumeration;
11952
+ // textLength: SVGAnimatedLength;
11953
+ // getCharNumAtPosition(point?: DOMPointInit): number {
11954
+ // throw new Error('Method not implemented.');
11955
+ // }
11961
11956
 
11962
- _proto.getCharNumAtPosition = function getCharNumAtPosition(point) {
11963
- throw new Error('Method not implemented.');
11964
- }
11965
11957
  /**
11966
11958
  * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
11967
11959
  */
11968
- ;
11960
+
11961
+
11962
+ var _proto = Text.prototype;
11969
11963
 
11970
11964
  _proto.getComputedTextLength = function getComputedTextLength() {
11971
11965
  var _this$parsedStyle$met;
11972
11966
 
11973
11967
  return ((_this$parsedStyle$met = this.parsedStyle.metrics) === null || _this$parsedStyle$met === void 0 ? void 0 : _this$parsedStyle$met.maxLineWidth) || 0;
11974
- };
11975
-
11976
- _proto.getEndPositionOfChar = function getEndPositionOfChar(charnum) {
11977
- throw new Error('Method not implemented.');
11978
- };
11979
-
11980
- _proto.getExtentOfChar = function getExtentOfChar(charnum) {
11981
- throw new Error('Method not implemented.');
11982
- };
11983
-
11984
- _proto.getNumberOfChars = function getNumberOfChars() {
11985
- throw new Error('Method not implemented.');
11986
- };
11987
-
11988
- _proto.getRotationOfChar = function getRotationOfChar(charnum) {
11989
- throw new Error('Method not implemented.');
11990
- };
11991
-
11992
- _proto.getStartPositionOfChar = function getStartPositionOfChar(charnum) {
11993
- throw new Error('Method not implemented.');
11994
- };
11995
-
11996
- _proto.getSubStringLength = function getSubStringLength(charnum, nchars) {
11997
- throw new Error('Method not implemented.');
11998
- };
11999
-
12000
- _proto.selectSubString = function selectSubString(charnum, nchars) {
12001
- throw new Error('Method not implemented.');
12002
- };
11968
+ } // getEndPositionOfChar(charnum: number): DOMPoint {
11969
+ // throw new Error('Method not implemented.');
11970
+ // }
11971
+ // getExtentOfChar(charnum: number): DOMRect {
11972
+ // throw new Error('Method not implemented.');
11973
+ // }
11974
+ // getNumberOfChars(): number {
11975
+ // throw new Error('Method not implemented.');
11976
+ // }
11977
+ // getRotationOfChar(charnum: number): number {
11978
+ // throw new Error('Method not implemented.');
11979
+ // }
11980
+ // getStartPositionOfChar(charnum: number): DOMPoint {
11981
+ // throw new Error('Method not implemented.');
11982
+ // }
11983
+ // getSubStringLength(charnum: number, nchars: number): number {
11984
+ // throw new Error('Method not implemented.');
11985
+ // }
11986
+ // selectSubString(charnum: number, nchars: number): void {
11987
+ // throw new Error('Method not implemented.');
11988
+ // }
11989
+ ;
12003
11990
 
12004
11991
  _proto.getLineBoundingRects = function getLineBoundingRects() {
12005
11992
  var _this$parsedStyle$met2;
@@ -12941,7 +12928,9 @@ var Document = /*#__PURE__*/function (_Node) {
12941
12928
  clazz = tagName === 'tspan' ? Text : Group;
12942
12929
  }
12943
12930
 
12944
- return new clazz(options);
12931
+ var shape = new clazz(options);
12932
+ shape.ownerDocument = this;
12933
+ return shape;
12945
12934
  };
12946
12935
 
12947
12936
  _proto.createElementNS = function createElementNS(namespaceURI, tagName, options) {
@@ -16591,20 +16580,15 @@ exports.RenderingService = /*#__PURE__*/function () {
16591
16580
 
16592
16581
  if (this.renderingContext.renderReasons.size && this.inited) {
16593
16582
  this.renderDisplayObject(this.renderingContext.root, canvasConfig);
16583
+ this.hooks.beginFrame.call();
16584
+ this.renderingContext.renderListCurrentFrame.forEach(function (object) {
16585
+ _this2.hooks.beforeRender.call(object);
16594
16586
 
16595
- if (this.renderingContext.renderListCurrentFrame.length || this.renderingContext.renderListLastFrame.length !== this.renderingContext.renderListCurrentFrame.length) {
16596
- this.hooks.beginFrame.call();
16597
- this.renderingContext.renderListCurrentFrame.forEach(function (object) {
16598
- _this2.hooks.beforeRender.call(object);
16599
-
16600
- _this2.hooks.render.call(object);
16601
-
16602
- _this2.hooks.afterRender.call(object);
16603
- });
16604
- this.hooks.endFrame.call();
16605
- }
16587
+ _this2.hooks.render.call(object);
16606
16588
 
16607
- this.renderingContext.renderListLastFrame = [].concat(this.renderingContext.renderListCurrentFrame);
16589
+ _this2.hooks.afterRender.call(object);
16590
+ });
16591
+ this.hooks.endFrame.call();
16608
16592
  this.renderingContext.renderListCurrentFrame = [];
16609
16593
  this.renderingContext.renderReasons.clear();
16610
16594
  } // console.log('stats', this.stats);
@@ -18100,13 +18084,11 @@ exports.TextService = /*#__PURE__*/function () {
18100
18084
  _proto.measureText = function measureText(text, parsedStyle, offscreenCanvas) {
18101
18085
  var fontSize = parsedStyle.fontSize,
18102
18086
  wordWrap = parsedStyle.wordWrap,
18103
- _parsedStyle$lineHeig = parsedStyle.lineHeight,
18104
- strokeHeight = _parsedStyle$lineHeig === void 0 ? 0 : _parsedStyle$lineHeig,
18087
+ strokeHeight = parsedStyle.lineHeight,
18105
18088
  lineWidth = parsedStyle.lineWidth,
18106
18089
  textBaseline = parsedStyle.textBaseline,
18107
18090
  textAlign = parsedStyle.textAlign,
18108
- _parsedStyle$letterSp = parsedStyle.letterSpacing,
18109
- letterSpacing = _parsedStyle$letterSp === void 0 ? 0 : _parsedStyle$letterSp,
18091
+ letterSpacing = parsedStyle.letterSpacing,
18110
18092
  _parsedStyle$leading = parsedStyle.leading,
18111
18093
  leading = _parsedStyle$leading === void 0 ? 0 : _parsedStyle$leading;
18112
18094
  var font = toFontString(parsedStyle);
@@ -18126,7 +18108,7 @@ exports.TextService = /*#__PURE__*/function () {
18126
18108
  var maxLineWidth = 0;
18127
18109
 
18128
18110
  for (var i = 0; i < lines.length; i++) {
18129
- var _lineWidth = context.measureText(lines[i]).width + (lines[i].length - 1) * letterSpacing;
18111
+ var _lineWidth = context.measureText(lines[i]).width + (lines[i].length - 1) * letterSpacing.value;
18130
18112
 
18131
18113
  lineWidths[i] = _lineWidth;
18132
18114
  maxLineWidth = Math.max(maxLineWidth, _lineWidth);
@@ -18136,7 +18118,7 @@ exports.TextService = /*#__PURE__*/function () {
18136
18118
  // width += dropShadowDistance;
18137
18119
  // }
18138
18120
 
18139
- var lineHeight = strokeHeight || fontProperties.fontSize + lineWidth.value;
18121
+ var lineHeight = strokeHeight.value || fontProperties.fontSize + lineWidth.value;
18140
18122
  var height = Math.max(lineHeight, fontProperties.fontSize + lineWidth.value) + (lines.length - 1) * (lineHeight + leading); // if (dropShadow) {
18141
18123
  // height += dropShadowDistance;
18142
18124
  // }
@@ -18181,17 +18163,16 @@ exports.TextService = /*#__PURE__*/function () {
18181
18163
 
18182
18164
  var _ref$wordWrapWidth = _ref.wordWrapWidth,
18183
18165
  wordWrapWidth = _ref$wordWrapWidth === void 0 ? 0 : _ref$wordWrapWidth,
18184
- _ref$letterSpacing = _ref.letterSpacing,
18185
- letterSpacing = _ref$letterSpacing === void 0 ? 0 : _ref$letterSpacing;
18166
+ letterSpacing = _ref.letterSpacing;
18186
18167
  var context = this.offscreenCanvas.getOrCreateContext(offscreenCanvas);
18187
- var maxWidth = wordWrapWidth + letterSpacing;
18168
+ var maxWidth = wordWrapWidth + letterSpacing.value;
18188
18169
  var lines = [];
18189
18170
  var currentIndex = 0;
18190
18171
  var currentWidth = 0;
18191
18172
  var cache = {};
18192
18173
 
18193
18174
  var calcWidth = function calcWidth(char) {
18194
- return _this2.getFromCache(char, letterSpacing, cache, context);
18175
+ return _this2.getFromCache(char, letterSpacing.value, cache, context);
18195
18176
  };
18196
18177
 
18197
18178
  Array.from(text).forEach(function (char, i) {
@@ -18776,7 +18757,7 @@ function getFontSize(object) {
18776
18757
  return fontSize.clone();
18777
18758
  }
18778
18759
 
18779
- return new CSSUnitValue(0, 'px');
18760
+ return null;
18780
18761
  }
18781
18762
  /**
18782
18763
  * <length> & <percentage>
@@ -18804,8 +18785,13 @@ exports.CSSPropertyLengthOrPercentage = /*#__PURE__*/function () {
18804
18785
  } else if (computed.unit === exports.UnitType.kEms) {
18805
18786
  if (object.parentNode) {
18806
18787
  var fontSize = getFontSize(object.parentNode);
18807
- fontSize.value *= computed.value;
18808
- return fontSize;
18788
+
18789
+ if (fontSize) {
18790
+ fontSize.value *= computed.value;
18791
+ return fontSize;
18792
+ } else {
18793
+ registry.addUnresolveProperty(object, name);
18794
+ }
18809
18795
  }
18810
18796
 
18811
18797
  return new CSSUnitValue(0, 'px');
@@ -18815,8 +18801,12 @@ exports.CSSPropertyLengthOrPercentage = /*#__PURE__*/function () {
18815
18801
  if (object === null || object === void 0 ? void 0 : (_object$ownerDocument = object.ownerDocument) === null || _object$ownerDocument === void 0 ? void 0 : _object$ownerDocument.documentElement) {
18816
18802
  var _fontSize = getFontSize(object.ownerDocument.documentElement);
18817
18803
 
18818
- _fontSize.value *= computed.value;
18819
- return _fontSize;
18804
+ if (_fontSize) {
18805
+ _fontSize.value *= computed.value;
18806
+ return _fontSize;
18807
+ } else {
18808
+ registry.addUnresolveProperty(object, name);
18809
+ }
18820
18810
  }
18821
18811
 
18822
18812
  return new CSSUnitValue(0, 'px');
@@ -19562,6 +19552,11 @@ var BUILT_IN_PROPERTIES = [{
19562
19552
  keywords: ['none'],
19563
19553
  defaultValue: 'none',
19564
19554
  syntax: exports.PropertySyntax.PAINT
19555
+ }, {
19556
+ name: 'shadowType',
19557
+ keywords: ['inner', 'outer', 'both'],
19558
+ defaultValue: 'outer',
19559
+ layoutDependent: true
19565
19560
  }, {
19566
19561
  name: 'shadowColor',
19567
19562
  interpolable: true,
@@ -19698,6 +19693,10 @@ var BUILT_IN_PROPERTIES = [{
19698
19693
  return 'center';
19699
19694
  }
19700
19695
 
19696
+ if (nodeName === exports.Shape.TEXT) {
19697
+ return 'text-anchor';
19698
+ }
19699
+
19701
19700
  return 'left top';
19702
19701
  },
19703
19702
  layoutDependent: true,
@@ -19889,16 +19888,27 @@ var BUILT_IN_PROPERTIES = [{
19889
19888
  defaultValue: 'normal'
19890
19889
  }, {
19891
19890
  name: 'lineHeight',
19892
- layoutDependent: true // interpolable: true,
19893
- // inherited: true,
19894
- // defaultValue: '-100%'
19895
-
19891
+ layoutDependent: true,
19892
+ syntax: exports.PropertySyntax.LENGTH,
19893
+ interpolable: true,
19894
+ defaultValue: '0'
19896
19895
  }, {
19897
19896
  name: 'letterSpacing',
19898
- layoutDependent: true // interpolable: true,
19899
- // inherited: true,
19900
- // defaultValue: '0',
19897
+ layoutDependent: true,
19898
+ syntax: exports.PropertySyntax.LENGTH,
19899
+ interpolable: true,
19900
+ defaultValue: '0'
19901
+ }, {
19902
+ name: 'miterLimit',
19903
+ layoutDependent: true,
19904
+ syntax: exports.PropertySyntax.NUMBER,
19905
+ defaultValue: function defaultValue(nodeName) {
19906
+ if (nodeName === exports.Shape.PATH || nodeName === exports.Shape.POLYGON || nodeName === exports.Shape.POLYLINE) {
19907
+ return '4';
19908
+ }
19901
19909
 
19910
+ return '10';
19911
+ }
19902
19912
  }, {
19903
19913
  name: 'wordWrap',
19904
19914
  layoutDependent: true
@@ -20294,6 +20304,7 @@ exports.DefaultStyleValueRegistry = /*#__PURE__*/function () {
20294
20304
  var stroke = parsedStyle.stroke,
20295
20305
  lineWidth = parsedStyle.lineWidth,
20296
20306
  increasedLineWidthForHitTesting = parsedStyle.increasedLineWidthForHitTesting,
20307
+ shadowType = parsedStyle.shadowType,
20297
20308
  shadowColor = parsedStyle.shadowColor,
20298
20309
  _parsedStyle$filter = parsedStyle.filter,
20299
20310
  filter = _parsedStyle$filter === void 0 ? [] : _parsedStyle$filter,
@@ -20325,7 +20336,7 @@ exports.DefaultStyleValueRegistry = /*#__PURE__*/function () {
20325
20336
 
20326
20337
  geometry.renderBounds.update(center, halfExtents); // account for shadow, only support constant value now
20327
20338
 
20328
- if (shadowColor) {
20339
+ if (shadowColor && (shadowType === null || shadowType === void 0 ? void 0 : shadowType.value) !== 'inner') {
20329
20340
  var _geometry$renderBound = geometry.renderBounds,
20330
20341
  min = _geometry$renderBound.min,
20331
20342
  max = _geometry$renderBound.max;
@@ -20688,9 +20699,8 @@ var CullingPlugin = CullingPlugin_1 = (_class$1 = /*#__PURE__*/function () {
20688
20699
  if (!cullable.isCulled() && object.isVisible()) {
20689
20700
  return object;
20690
20701
  } else {
20691
- if (_this.renderingContext.renderListLastFrame.indexOf(object) > -1) {
20692
- object.dispatchEvent(new CustomEvent(exports.ElementEvent.CULLED));
20693
- }
20702
+ // if (this.renderingContext.renderListLastFrame.indexOf(object) > -1) {
20703
+ object.dispatchEvent(new CustomEvent(exports.ElementEvent.CULLED)); // }
20694
20704
  }
20695
20705
 
20696
20706
  return null;
@@ -21563,7 +21573,6 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
21563
21573
  * the root node in scene graph
21564
21574
  */
21565
21575
  root: this.document.documentElement,
21566
- renderListLastFrame: [],
21567
21576
  renderListCurrentFrame: [],
21568
21577
  unculledEntities: [],
21569
21578
  renderReasons: new Set(),
@@ -22013,7 +22022,6 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
22013
22022
  return Canvas;
22014
22023
  }(EventTarget);
22015
22024
 
22016
- // import * as ManaSyringe from 'mana-syringe';
22017
22025
  manaSyringe.GlobalContainer.load(containerModule);
22018
22026
  var layoutEngine = manaSyringe.GlobalContainer.get(exports.LayoutEngine);
22019
22027