@antv/g-lite 2.2.1 → 2.2.3

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.
Files changed (38) hide show
  1. package/dist/index.esm.js +53 -31
  2. package/dist/index.esm.js.map +1 -1
  3. package/dist/index.js +53 -31
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.umd.min.js +5 -5
  6. package/dist/index.umd.min.js.map +1 -1
  7. package/package.json +1 -1
  8. package/types/css/StyleValueRegistry.d.ts +1 -1
  9. package/types/css/StyleValueRegistry.d.ts.map +1 -1
  10. package/types/display-objects/Circle.d.ts +1 -0
  11. package/types/display-objects/Circle.d.ts.map +1 -1
  12. package/types/display-objects/CustomElement.d.ts.map +1 -1
  13. package/types/display-objects/DisplayObject.d.ts +1 -0
  14. package/types/display-objects/DisplayObject.d.ts.map +1 -1
  15. package/types/display-objects/Ellipse.d.ts +1 -0
  16. package/types/display-objects/Ellipse.d.ts.map +1 -1
  17. package/types/display-objects/Group.d.ts +1 -0
  18. package/types/display-objects/Group.d.ts.map +1 -1
  19. package/types/display-objects/HTML.d.ts +1 -0
  20. package/types/display-objects/HTML.d.ts.map +1 -1
  21. package/types/display-objects/Image.d.ts +1 -0
  22. package/types/display-objects/Image.d.ts.map +1 -1
  23. package/types/display-objects/Line.d.ts +1 -0
  24. package/types/display-objects/Line.d.ts.map +1 -1
  25. package/types/display-objects/Path.d.ts +1 -0
  26. package/types/display-objects/Path.d.ts.map +1 -1
  27. package/types/display-objects/Polygon.d.ts +1 -0
  28. package/types/display-objects/Polygon.d.ts.map +1 -1
  29. package/types/display-objects/Polyline.d.ts +1 -0
  30. package/types/display-objects/Polyline.d.ts.map +1 -1
  31. package/types/display-objects/Rect.d.ts +1 -0
  32. package/types/display-objects/Rect.d.ts.map +1 -1
  33. package/types/display-objects/Text.d.ts +1 -0
  34. package/types/display-objects/Text.d.ts.map +1 -1
  35. package/types/global-runtime.d.ts +5 -0
  36. package/types/global-runtime.d.ts.map +1 -1
  37. package/types/services/TextService.d.ts +0 -1
  38. package/types/services/TextService.d.ts.map +1 -1
package/dist/index.esm.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /*!
2
2
  * @antv/g-lite
3
3
  * @description A core module for rendering engine implements DOM API.
4
- * @version 2.2.1
5
- * @date 11/5/2024, 10:45:58 AM
4
+ * @version 2.2.3
5
+ * @date 11/14/2024, 8:16:02 AM
6
6
  * @author AntVis
7
7
  * @docs https://g.antv.antgroup.com/
8
8
  */
@@ -6371,7 +6371,7 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
6371
6371
  // clipPath
6372
6372
  var oldClipPath = object.parsedStyle.clipPath;
6373
6373
  var oldOffsetPath = object.parsedStyle.offsetPath;
6374
- Object.assign(object.parsedStyle, attributes);
6374
+ assignParsedStyle(object, attributes);
6375
6375
  var needUpdateGeometry = !!options.forceUpdateGeometry;
6376
6376
  if (!needUpdateGeometry) {
6377
6377
  for (var i in attributes) {
@@ -6632,6 +6632,18 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
6632
6632
  }
6633
6633
  }]);
6634
6634
  }();
6635
+ function assignParsedStyle(object, attributes) {
6636
+ if (!runtime.enableMassiveParsedStyleAssignOptimization) {
6637
+ Object.assign(object.parsedStyle, attributes);
6638
+ return;
6639
+ }
6640
+ var list = object.constructor.PARSED_STYLE_LIST;
6641
+ for (var key in attributes) {
6642
+ if (list.has(key)) {
6643
+ object.parsedStyle[key] = attributes[key];
6644
+ }
6645
+ }
6646
+ }
6635
6647
 
6636
6648
  var CSSPropertyAngle = /*#__PURE__*/function () {
6637
6649
  function CSSPropertyAngle() {
@@ -11435,9 +11447,6 @@ var TextService = /*#__PURE__*/function () {
11435
11447
  };
11436
11448
  }
11437
11449
  }
11438
- }, {
11439
- key: "setGraphemeOnPath",
11440
- value: function setGraphemeOnPath() {}
11441
11450
  }, {
11442
11451
  key: "wordWrap",
11443
11452
  value: function wordWrap(text, parsedStyle, offscreenCanvas) {
@@ -11467,6 +11476,27 @@ var TextService = /*#__PURE__*/function () {
11467
11476
  var ellipsisWidth = Array.from(ellipsis).reduce(function (prev, cur) {
11468
11477
  return prev + calcWidth(cur);
11469
11478
  }, 0);
11479
+ function appendEllipsis(lineIndex) {
11480
+ // If there is not enough space to display the string itself, it is clipped.
11481
+ // @see https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow#values
11482
+ if (ellipsisWidth <= 0 || ellipsisWidth > maxWidth) {
11483
+ return;
11484
+ }
11485
+
11486
+ // Backspace from line's end.
11487
+ var currentLineLength = lines[lineIndex].length;
11488
+ var lastLineWidth = 0;
11489
+ var lastLineIndex = currentLineLength;
11490
+ for (var i = 0; i < currentLineLength; i++) {
11491
+ var width = calcWidth(lines[lineIndex][i]);
11492
+ if (lastLineWidth + width + ellipsisWidth > maxWidth) {
11493
+ lastLineIndex = i;
11494
+ break;
11495
+ }
11496
+ lastLineWidth += width;
11497
+ }
11498
+ lines[lineIndex] = (lines[lineIndex] || '').slice(0, lastLineIndex) + ellipsis;
11499
+ }
11470
11500
  var chars = Array.from(text);
11471
11501
  for (var i = 0; i < chars.length; i++) {
11472
11502
  var _char3 = chars[i];
@@ -11479,6 +11509,9 @@ var TextService = /*#__PURE__*/function () {
11479
11509
  // exceed maxLines, break immediately
11480
11510
  if (currentIndex >= maxLines) {
11481
11511
  parsedStyle.isOverflowing = true;
11512
+ if (i < chars.length - 1) {
11513
+ appendEllipsis(currentIndex - 1);
11514
+ }
11482
11515
  break;
11483
11516
  }
11484
11517
  currentWidth = 0;
@@ -11488,24 +11521,7 @@ var TextService = /*#__PURE__*/function () {
11488
11521
  if (currentWidth > 0 && currentWidth + charWidth > maxWidth) {
11489
11522
  if (currentIndex + 1 >= maxLines) {
11490
11523
  parsedStyle.isOverflowing = true;
11491
-
11492
- // If there is not enough space to display the string itself, it is clipped.
11493
- // @see https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow#values
11494
- if (ellipsisWidth > 0 && ellipsisWidth <= maxWidth) {
11495
- // Backspace from line's end.
11496
- var currentLineLength = lines[currentIndex].length;
11497
- var lastLineWidth = 0;
11498
- var lastLineIndex = currentLineLength;
11499
- for (var _i2 = 0; _i2 < currentLineLength; _i2++) {
11500
- var width = calcWidth(lines[currentIndex][_i2]);
11501
- if (lastLineWidth + width + ellipsisWidth > maxWidth) {
11502
- lastLineIndex = _i2;
11503
- break;
11504
- }
11505
- lastLineWidth += width;
11506
- }
11507
- lines[currentIndex] = (lines[currentIndex] || '').slice(0, lastLineIndex) + ellipsis;
11508
- }
11524
+ appendEllipsis(currentIndex);
11509
11525
  break;
11510
11526
  }
11511
11527
  currentIndex++;
@@ -11602,7 +11618,7 @@ var runtime = {};
11602
11618
  var geometryUpdaterFactory = function (_ref) {
11603
11619
  var rectUpdater = new RectUpdater();
11604
11620
  var polylineUpdater = new PolylineUpdater();
11605
- return _ref = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_ref, Shape.CIRCLE, new CircleUpdater()), Shape.ELLIPSE, new EllipseUpdater()), Shape.RECT, rectUpdater), Shape.IMAGE, rectUpdater), Shape.GROUP, new GroupUpdater()), Shape.LINE, new LineUpdater()), Shape.TEXT, new TextUpdater(runtime)), Shape.POLYLINE, polylineUpdater), Shape.POLYGON, polylineUpdater), Shape.PATH, new PathUpdater()), _defineProperty(_defineProperty(_ref, Shape.HTML, new HTMLUpdater()), Shape.MESH, null);
11621
+ return _ref = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_ref, Shape.FRAGMENT, null), Shape.CIRCLE, new CircleUpdater()), Shape.ELLIPSE, new EllipseUpdater()), Shape.RECT, rectUpdater), Shape.IMAGE, rectUpdater), Shape.GROUP, new GroupUpdater()), Shape.LINE, new LineUpdater()), Shape.TEXT, new TextUpdater(runtime)), Shape.POLYLINE, polylineUpdater), Shape.POLYGON, polylineUpdater), _defineProperty(_defineProperty(_defineProperty(_ref, Shape.PATH, new PathUpdater()), Shape.HTML, new HTMLUpdater()), Shape.MESH, null);
11606
11622
  }();
11607
11623
  var CSSPropertySyntaxFactory = function (_ref2) {
11608
11624
  var color = new CSSPropertyColor();
@@ -12359,9 +12375,6 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
12359
12375
 
12360
12376
  // assign name, id to config
12361
12377
  // eg. group.get('name')
12362
- /**
12363
- * contains style props in constructor's params, eg. fill, stroke...
12364
- */
12365
12378
  _this.isCustomElement = false;
12366
12379
  _this.isMutationObserved = false;
12367
12380
  /**
@@ -13157,6 +13170,7 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
13157
13170
  // #endregion deprecated
13158
13171
  }]);
13159
13172
  }(Element);
13173
+ DisplayObject.PARSED_STYLE_LIST = new Set(['class', 'className', 'clipPath', 'cursor', 'display', 'draggable', 'droppable', 'fill', 'fillOpacity', 'fillRule', 'filter', 'increasedLineWidthForHitTesting', 'lineCap', 'lineDash', 'lineDashOffset', 'lineJoin', 'lineWidth', 'miterLimit', 'hitArea', 'offsetDistance', 'offsetPath', 'offsetX', 'offsetY', 'opacity', 'pointerEvents', 'shadowColor', 'shadowType', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'stroke', 'strokeOpacity', 'strokeWidth', 'strokeLinecap', 'strokeLineJoin', 'strokeDasharray', 'strokeDashoffset', 'transform', 'transformOrigin', 'textTransform', 'visibility', 'zIndex']);
13160
13174
 
13161
13175
  var Circle = /*#__PURE__*/function (_DisplayObject) {
13162
13176
  function Circle() {
@@ -13169,6 +13183,7 @@ var Circle = /*#__PURE__*/function (_DisplayObject) {
13169
13183
  _inherits(Circle, _DisplayObject);
13170
13184
  return _createClass(Circle);
13171
13185
  }(DisplayObject);
13186
+ Circle.PARSED_STYLE_LIST = new Set([].concat(_toConsumableArray(DisplayObject.PARSED_STYLE_LIST), ['cx', 'cy', 'cz', 'r', 'isBillboard', 'isSizeAttenuation']));
13172
13187
 
13173
13188
  var _excluded$6 = ["style"];
13174
13189
  /**
@@ -13187,9 +13202,6 @@ var CustomElement = /*#__PURE__*/function (_DisplayObject) {
13187
13202
  _this = _callSuper(this, CustomElement, [_objectSpread({
13188
13203
  style: style
13189
13204
  }, rest)]);
13190
- // static get observedAttributes(): string[] {
13191
- // return [];
13192
- // }
13193
13205
  _this.isCustomElement = true;
13194
13206
  return _this;
13195
13207
  }
@@ -13212,6 +13224,7 @@ var Ellipse = /*#__PURE__*/function (_DisplayObject) {
13212
13224
  _inherits(Ellipse, _DisplayObject);
13213
13225
  return _createClass(Ellipse);
13214
13226
  }(DisplayObject);
13227
+ Ellipse.PARSED_STYLE_LIST = new Set([].concat(_toConsumableArray(DisplayObject.PARSED_STYLE_LIST), ['cx', 'cy', 'cz', 'rx', 'ry', 'isBillboard', 'isSizeAttenuation']));
13215
13228
 
13216
13229
  /**
13217
13230
  * 节点片段,用于包裹多个节点并批量操作
@@ -13254,6 +13267,7 @@ var Group = /*#__PURE__*/function (_DisplayObject) {
13254
13267
  _inherits(Group, _DisplayObject);
13255
13268
  return _createClass(Group);
13256
13269
  }(DisplayObject);
13270
+ Group.PARSED_STYLE_LIST = new Set([].concat(_toConsumableArray(DisplayObject.PARSED_STYLE_LIST), ['width', 'height']));
13257
13271
 
13258
13272
  var _excluded$5 = ["style"];
13259
13273
  /**
@@ -13340,6 +13354,7 @@ var HTML = /*#__PURE__*/function (_DisplayObject) {
13340
13354
  }
13341
13355
  }]);
13342
13356
  }(DisplayObject);
13357
+ HTML.PARSED_STYLE_LIST = new Set([].concat(_toConsumableArray(DisplayObject.PARSED_STYLE_LIST), ['x', 'y', '$el', 'innerHTML', 'width', 'height']));
13343
13358
 
13344
13359
  var Image = /*#__PURE__*/function (_DisplayObject) {
13345
13360
  function Image() {
@@ -13352,6 +13367,7 @@ var Image = /*#__PURE__*/function (_DisplayObject) {
13352
13367
  _inherits(Image, _DisplayObject);
13353
13368
  return _createClass(Image);
13354
13369
  }(DisplayObject);
13370
+ Image.PARSED_STYLE_LIST = new Set([].concat(_toConsumableArray(DisplayObject.PARSED_STYLE_LIST), ['x', 'y', 'z', 'src', 'width', 'height', 'isBillboard', 'billboardRotation', 'isSizeAttenuation', 'keepAspectRatio']));
13355
13371
 
13356
13372
  var _excluded$4 = ["style"];
13357
13373
  /**
@@ -13507,6 +13523,7 @@ var Line = /*#__PURE__*/function (_DisplayObject) {
13507
13523
  }
13508
13524
  }]);
13509
13525
  }(DisplayObject);
13526
+ Line.PARSED_STYLE_LIST = new Set([].concat(_toConsumableArray(DisplayObject.PARSED_STYLE_LIST), ['x1', 'y1', 'x2', 'y2', 'z1', 'z2', 'isBillboard', 'isSizeAttenuation', 'markerStart', 'markerEnd', 'markerStartOffset', 'markerEndOffset']));
13510
13527
 
13511
13528
  var _excluded$3 = ["style"];
13512
13529
  var Path = /*#__PURE__*/function (_DisplayObject) {
@@ -13745,6 +13762,7 @@ var Path = /*#__PURE__*/function (_DisplayObject) {
13745
13762
  }
13746
13763
  }]);
13747
13764
  }(DisplayObject);
13765
+ Path.PARSED_STYLE_LIST = new Set([].concat(_toConsumableArray(DisplayObject.PARSED_STYLE_LIST), ['d', 'markerStart', 'markerMid', 'markerEnd', 'markerStartOffset', 'markerEndOffset', 'isBillboard', 'isSizeAttenuation']));
13748
13766
 
13749
13767
  var _excluded$2 = ["style"];
13750
13768
  var Polygon = /*#__PURE__*/function (_DisplayObject) {
@@ -13906,6 +13924,7 @@ var Polygon = /*#__PURE__*/function (_DisplayObject) {
13906
13924
  }
13907
13925
  }]);
13908
13926
  }(DisplayObject);
13927
+ Polygon.PARSED_STYLE_LIST = new Set([].concat(_toConsumableArray(DisplayObject.PARSED_STYLE_LIST), ['points', 'markerStart', 'markerMid', 'markerEnd', 'markerStartOffset', 'markerEndOffset', 'isClosed', 'isBillboard', 'isSizeAttenuation']));
13909
13928
 
13910
13929
  var _excluded$1 = ["style"];
13911
13930
  /**
@@ -14003,6 +14022,7 @@ var Polyline = /*#__PURE__*/function (_Polygon) {
14003
14022
  }
14004
14023
  }]);
14005
14024
  }(Polygon);
14025
+ Polyline.PARSED_STYLE_LIST = new Set([].concat(_toConsumableArray(Polygon.PARSED_STYLE_LIST), ['points', 'markerStart', 'markerMid', 'markerEnd', 'markerStartOffset', 'markerEndOffset', 'isBillboard']));
14006
14026
 
14007
14027
  var Rect = /*#__PURE__*/function (_DisplayObject) {
14008
14028
  function Rect() {
@@ -14015,6 +14035,7 @@ var Rect = /*#__PURE__*/function (_DisplayObject) {
14015
14035
  _inherits(Rect, _DisplayObject);
14016
14036
  return _createClass(Rect);
14017
14037
  }(DisplayObject);
14038
+ Rect.PARSED_STYLE_LIST = new Set([].concat(_toConsumableArray(DisplayObject.PARSED_STYLE_LIST), ['x', 'y', 'z', 'width', 'height', 'isBillboard', 'isSizeAttenuation', 'radius']));
14018
14039
 
14019
14040
  var _excluded = ["style"];
14020
14041
  /**
@@ -14067,6 +14088,7 @@ var Text = /*#__PURE__*/function (_DisplayObject) {
14067
14088
  }
14068
14089
  }]);
14069
14090
  }(DisplayObject);
14091
+ Text.PARSED_STYLE_LIST = new Set([].concat(_toConsumableArray(DisplayObject.PARSED_STYLE_LIST), ['x', 'y', 'z', 'isBillboard', 'billboardRotation', 'isSizeAttenuation', 'text', 'textAlign', 'textBaseline', 'fontStyle', 'fontSize', 'fontFamily', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'leading', 'wordWrap', 'wordWrapWidth', 'maxLines', 'textOverflow', 'isOverflowing', 'textPath', 'textDecorationLine', 'textDecorationColor', 'textDecorationStyle', 'textPathSide', 'textPathStartOffset', 'metrics', 'dx', 'dy']));
14070
14092
 
14071
14093
  /**
14072
14094
  * canvas.customElements