@antv/g-lite 1.0.43 → 1.0.44

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
@@ -7504,12 +7504,12 @@
7504
7504
  if (z === void 0) {
7505
7505
  z = 0;
7506
7506
  }
7507
- if (isNumber(x)) {
7508
- return fromValues$2(x, y, z);
7509
- }
7510
7507
  if (Array.isArray(x) && x.length === 3) {
7511
7508
  return clone$1(x);
7512
7509
  }
7510
+ if (isNumber(x)) {
7511
+ return fromValues$2(x, y, z);
7512
+ }
7513
7513
  return fromValues$2(x[0], x[1] || y, x[2] || z);
7514
7514
  }
7515
7515
  function deg2rad(deg) {
@@ -11155,10 +11155,10 @@
11155
11155
  return !!object.type && !!object.value;
11156
11156
  }
11157
11157
  function isPattern(object) {
11158
- return isObject(object) && !!object.image;
11158
+ return object && !!object.image;
11159
11159
  }
11160
11160
  function isCSSRGB(object) {
11161
- return isObject(object) && !isNil(object.r) && !isNil(object.g) && !isNil(object.b);
11161
+ return object && !isNil(object.r) && !isNil(object.g) && !isNil(object.b);
11162
11162
  }
11163
11163
  /**
11164
11164
  * @see https://github.com/WebKit/WebKit/blob/main/Source/WebCore/css/parser/CSSParser.cpp#L97
@@ -11746,17 +11746,17 @@
11746
11746
  }
11747
11747
  function parseDimensionArrayFormat(string, size) {
11748
11748
  var parsed;
11749
- if (isString(string)) {
11749
+ if (Array.isArray(string)) {
11750
+ // [1, '2px', 3]
11751
+ parsed = string.map(function (segment) {
11752
+ return Number(segment);
11753
+ });
11754
+ } else if (isString(string)) {
11750
11755
  parsed = string.split(' ').map(function (segment) {
11751
11756
  return Number(segment);
11752
11757
  });
11753
11758
  } else if (isNumber(string)) {
11754
11759
  parsed = [string];
11755
- } else {
11756
- // [1, '2px', 3]
11757
- parsed = string.map(function (segment) {
11758
- return Number(segment);
11759
- });
11760
11760
  }
11761
11761
  if (size === 2) {
11762
11762
  if (parsed.length === 1) {
@@ -11810,7 +11810,9 @@
11810
11810
  if (valueWithUnit.unit === exports.UnitType.kPixels) {
11811
11811
  return Number(valueWithUnit.value);
11812
11812
  } else if (valueWithUnit.unit === exports.UnitType.kPercentage && target) {
11813
- var bounds = target.nodeName === exports.Shape.GROUP ? target.getLocalBounds() : target.getGeometryBounds();
11813
+ var bounds = target.nodeName === exports.Shape.GROUP ? target.getLocalBounds() :
11814
+ // : target.getGeometryBounds();
11815
+ target.geometry.contentBounds;
11814
11816
  var size = 0;
11815
11817
  if (!AABB.isEmpty(bounds)) {
11816
11818
  size = bounds.halfExtents[vec3Index] * 2;
@@ -14614,6 +14616,7 @@
14614
14616
  renderOrder: 0
14615
14617
  };
14616
14618
  _this.geometry = {
14619
+ dirty: false,
14617
14620
  contentBounds: undefined,
14618
14621
  renderBounds: undefined
14619
14622
  };
@@ -17674,11 +17677,13 @@
17674
17677
  var oldClipPath = object.parsedStyle.clipPath;
17675
17678
  var oldOffsetPath = object.parsedStyle.offsetPath;
17676
17679
  object.parsedStyle = Object.assign(object.parsedStyle, attributes);
17677
- var _needUpdateGeometry = false;
17678
- for (var i = 0; i < GEOMETRY_ATTRIBUTE_NAMES.length; i++) {
17679
- if (GEOMETRY_ATTRIBUTE_NAMES[i] in attributes) {
17680
- _needUpdateGeometry = true;
17681
- break;
17680
+ var _needUpdateGeometry = !!options.forceUpdateGeometry;
17681
+ if (!_needUpdateGeometry) {
17682
+ for (var i = 0; i < GEOMETRY_ATTRIBUTE_NAMES.length; i++) {
17683
+ if (GEOMETRY_ATTRIBUTE_NAMES[i] in attributes) {
17684
+ _needUpdateGeometry = true;
17685
+ break;
17686
+ }
17682
17687
  }
17683
17688
  }
17684
17689
  if (attributes.fill) {
@@ -17819,7 +17824,8 @@
17819
17824
  runtime.CSSPropertySyntaxFactory['<transform>'].postProcessor(object, _attributeNames);
17820
17825
  }
17821
17826
  if (_needUpdateGeometry) {
17822
- this.updateGeometry(object);
17827
+ object.geometry.dirty = true;
17828
+ runtime.sceneGraphService.dirtifyToRoot(object);
17823
17829
  }
17824
17830
  return;
17825
17831
  }
@@ -17885,7 +17891,8 @@
17885
17891
  // }
17886
17892
  // update geometry
17887
17893
  if (needUpdateGeometry) {
17888
- this.updateGeometry(object);
17894
+ object.geometry.dirty = true;
17895
+ runtime.sceneGraphService.dirtifyToRoot(object);
17889
17896
  }
17890
17897
  attributeNames.forEach(function (name) {
17891
17898
  if (name in object.parsedStyle) {
@@ -18193,7 +18200,10 @@
18193
18200
  usedOriginXValue = usedOriginXValue - (flipY ? -1 : 1) * (anchor && anchor[0] || 0) * geometry.contentBounds.halfExtents[0] * 2;
18194
18201
  usedOriginYValue = usedOriginYValue - (flipX ? -1 : 1) * (anchor && anchor[1] || 0) * geometry.contentBounds.halfExtents[1] * 2;
18195
18202
  object.setOrigin(usedOriginXValue, usedOriginYValue);
18196
- runtime.sceneGraphService.dirtifyToRoot(object);
18203
+ geometry.dirty = false;
18204
+ // console.log('calc geometry', object);
18205
+ // FIXME setOrigin may have already dirtified to root.
18206
+ // runtime.sceneGraphService.dirtifyToRoot(object);
18197
18207
  }
18198
18208
  };
18199
18209
  _proto.isPropertyInheritable = function isPropertyInheritable(name) {
@@ -18872,6 +18882,9 @@
18872
18882
  _proto.gotoLandmark = function gotoLandmark(name, options) {
18873
18883
  throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);
18874
18884
  };
18885
+ _proto.cancelLandmarkAnimation = function cancelLandmarkAnimation() {
18886
+ throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);
18887
+ };
18875
18888
  return Camera;
18876
18889
  }();
18877
18890
 
@@ -19079,7 +19092,8 @@
19079
19092
  } else if (textBaseline === 'top' || textBaseline === 'hanging') {
19080
19093
  lineYOffset = halfExtents[1] * 2;
19081
19094
  } else if (textBaseline === 'alphabetic') {
19082
- lineYOffset = lineHeight - fontProperties.ascent;
19095
+ // prevent calling getImageData for ascent metrics
19096
+ lineYOffset = runtime.enableCSSParsing ? lineHeight - fontProperties.ascent : 0;
19083
19097
  } else if (textBaseline === 'bottom' || textBaseline === 'ideographic') {
19084
19098
  lineYOffset = 0;
19085
19099
  }
@@ -21024,6 +21038,9 @@
21024
21038
  render = false;
21025
21039
  }
21026
21040
  var geometry = element.geometry;
21041
+ if (geometry.dirty) {
21042
+ runtime.styleValueRegistry.updateGeometry(element);
21043
+ }
21027
21044
  var bounds = render ? geometry.renderBounds : geometry.contentBounds || null;
21028
21045
  // return (bounds && new AABB(bounds.center, bounds.halfExtents)) || new AABB();
21029
21046
  return bounds || new AABB();
@@ -21341,12 +21358,19 @@
21341
21358
  _parsedStyle$leading = parsedStyle.leading,
21342
21359
  leading = _parsedStyle$leading === void 0 ? 0 : _parsedStyle$leading;
21343
21360
  var font = toFontString(parsedStyle);
21344
- var fontProperties = this.measureFont(font, offscreenCanvas);
21345
- // fallback in case UA disallow canvas data extraction
21346
- // (toDataURI, getImageData functions)
21347
- if (fontProperties.fontSize === 0) {
21348
- fontProperties.fontSize = fontSize;
21349
- fontProperties.ascent = fontSize;
21361
+ var fontProperties;
21362
+ if (runtime.enableCSSParsing) {
21363
+ fontProperties = this.measureFont(font, offscreenCanvas);
21364
+ // fallback in case UA disallow canvas data extraction
21365
+ // (toDataURI, getImageData functions)
21366
+ if (fontProperties.fontSize === 0) {
21367
+ fontProperties.fontSize = fontSize;
21368
+ fontProperties.ascent = fontSize;
21369
+ }
21370
+ } else {
21371
+ fontProperties = {
21372
+ fontSize: fontSize
21373
+ };
21350
21374
  }
21351
21375
  var context = this.runtime.offscreenCanvas.getOrCreateContext(offscreenCanvas);
21352
21376
  context.font = font;
@@ -22127,6 +22151,7 @@
22127
22151
  }
22128
22152
  var _proto = PrepareRendererPlugin.prototype;
22129
22153
  // private isFirstTimeRendering = true;
22154
+ // private syncing = false;
22130
22155
  _proto.apply = function apply(context) {
22131
22156
  var _this = this;
22132
22157
  var renderingService = context.renderingService,
@@ -22201,17 +22226,24 @@
22201
22226
  });
22202
22227
  renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
22203
22228
  // if (this.isFirstTimeRendering) {
22204
- // // @see https://github.com/antvis/G/issues/1117
22205
- // setTimeout(() => this.syncRTree());
22206
22229
  // this.isFirstTimeRendering = false;
22230
+ // this.syncing = true;
22231
+ // // @see https://github.com/antvis/G/issues/1117
22232
+ // setTimeout(() => {
22233
+ // this.syncRTree();
22234
+ // console.log('fcp...');
22235
+ // });
22207
22236
  // } else {
22208
- // this.syncRTree();
22209
- // }
22237
+ // console.log('next...');
22210
22238
  _this.syncRTree();
22239
+ // }
22211
22240
  });
22212
22241
  };
22213
22242
  _proto.syncRTree = function syncRTree() {
22214
22243
  var _this2 = this;
22244
+ // if (this.syncing) {
22245
+ // return;
22246
+ // }
22215
22247
  // bounds changed, need re-inserting its children
22216
22248
  var bulk = [];
22217
22249
  Array.from(this.toSync)
@@ -22254,6 +22286,7 @@
22254
22286
  this.rBush.load(bulk);
22255
22287
  bulk.length = 0;
22256
22288
  this.toSync.clear();
22289
+ // this.syncing = false;
22257
22290
  };
22258
22291
  return PrepareRendererPlugin;
22259
22292
  }();