@antv/g-lite 1.3.0-next.9 → 2.0.0

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
@@ -662,7 +662,7 @@ var AbstractRenderer = /** @class */ (function () {
662
662
  /**
663
663
  * enable dirty rectangle rendering by default
664
664
  */
665
- enableDirtyRectangleRendering: true, enableDirtyRectangleRenderingDebug: false }, config);
665
+ enableDirtyRectangleRendering: true, enableDirtyRectangleRenderingDebug: false, enableSizeAttenuation: true }, config);
666
666
  }
667
667
  AbstractRenderer.prototype.registerPlugin = function (plugin) {
668
668
  var index = this.plugins.findIndex(function (p) { return p === plugin; });
@@ -3186,7 +3186,7 @@ var getOrCreateUnitValue = function (value, unitOrName) {
3186
3186
  if (unitOrName === void 0) { unitOrName = exports.UnitType.kNumber; }
3187
3187
  return new CSSUnitValue(value, unitOrName);
3188
3188
  };
3189
- var PECENTAGE_50 = new CSSUnitValue(50, '%');
3189
+ new CSSUnitValue(50, '%');
3190
3190
 
3191
3191
  /**
3192
3192
  * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#changing-mesh-culling-strategy
@@ -3909,6 +3909,9 @@ var parseColor = memoize(function (colorStr) {
3909
3909
  // @see https://github.com/adobe-webplatform/Snap.svg/issues/526
3910
3910
  colorStr = 'black';
3911
3911
  }
3912
+ else if (colorStr === 'none') {
3913
+ return noneColor;
3914
+ }
3912
3915
  // support CSS gradient syntax
3913
3916
  var g = parseGradient(colorStr);
3914
3917
  if (g) {
@@ -4128,10 +4131,8 @@ function parseDimensionArray(string) {
4128
4131
  // },
4129
4132
  // ];
4130
4133
  // }
4131
- function convertPercentUnit(valueWithUnit, vec3Index, target) {
4132
- if (valueWithUnit.value === 0) {
4133
- return 0;
4134
- }
4134
+ function convertPercentUnit(valueWithUnit, vec3Index, target, useMin) {
4135
+ if (useMin === void 0) { useMin = false; }
4135
4136
  if (valueWithUnit.unit === exports.UnitType.kPixels) {
4136
4137
  return Number(valueWithUnit.value);
4137
4138
  }
@@ -4139,7 +4140,8 @@ function convertPercentUnit(valueWithUnit, vec3Index, target) {
4139
4140
  var bounds = target.nodeName === exports.Shape.GROUP
4140
4141
  ? target.getLocalBounds()
4141
4142
  : target.getGeometryBounds();
4142
- return (valueWithUnit.value / 100) * bounds.halfExtents[vec3Index] * 2;
4143
+ return ((useMin ? bounds.min[vec3Index] : 0) +
4144
+ (valueWithUnit.value / 100) * bounds.halfExtents[vec3Index] * 2);
4143
4145
  }
4144
4146
  return 0;
4145
4147
  }
@@ -4242,10 +4244,16 @@ function mergeNumberLists(left, right) {
4242
4244
  }
4243
4245
 
4244
4246
  function getOrCalculatePathTotalLength(path) {
4245
- if (path.parsedStyle.path.totalLength === 0) {
4246
- path.parsedStyle.path.totalLength = util.getTotalLength(path.parsedStyle.path.absolutePath);
4247
+ if (path.parsedStyle.d.totalLength === 0) {
4248
+ path.parsedStyle.d.totalLength = util.getTotalLength(path.parsedStyle.d.absolutePath);
4247
4249
  }
4248
- return path.parsedStyle.path.totalLength;
4250
+ return path.parsedStyle.d.totalLength;
4251
+ }
4252
+ function getOrCalculatePolylineTotalLength(polyline) {
4253
+ if (polyline.parsedStyle.points.totalLength === 0) {
4254
+ polyline.parsedStyle.points.totalLength = gMath.polylineLength(polyline.parsedStyle.points.points);
4255
+ }
4256
+ return polyline.parsedStyle.points.totalLength;
4249
4257
  }
4250
4258
  function removeRedundantMCommand(path) {
4251
4259
  for (var i = 0; i < path.length; i++) {
@@ -4955,7 +4963,7 @@ function convertToPath(object, transform) {
4955
4963
  }));
4956
4964
  break;
4957
4965
  case exports.Shape.PATH:
4958
- var absolutePath = object.parsedStyle.path.absolutePath;
4966
+ var absolutePath = object.parsedStyle.d.absolutePath;
4959
4967
  commands = tslib.__spreadArray([], tslib.__read(absolutePath), false);
4960
4968
  break;
4961
4969
  }
@@ -5117,27 +5125,10 @@ function parsePoints(pointsOrStr, object) {
5117
5125
  else {
5118
5126
  points = pointsOrStr;
5119
5127
  }
5120
- var segments = [];
5121
- var tempLength = 0;
5122
- var segmentT;
5123
- var segmentL;
5124
- var totalLength = gMath.polylineLength(points);
5125
- points.forEach(function (p, i) {
5126
- if (points[i + 1]) {
5127
- segmentT = [0, 0];
5128
- segmentT[0] = tempLength / totalLength;
5129
- segmentL = gMath.lineLength(p[0], p[1], points[i + 1][0], points[i + 1][1]);
5130
- tempLength += segmentL;
5131
- segmentT[1] = tempLength / totalLength;
5132
- segments.push(segmentT);
5133
- }
5134
- });
5135
- // const minX = Math.min(...points.map((point) => point[0]));
5136
- // const minY = Math.min(...points.map((point) => point[1]));
5137
5128
  return {
5138
5129
  points: points,
5139
- totalLength: totalLength,
5140
- segments: segments,
5130
+ totalLength: 0,
5131
+ segments: [],
5141
5132
  };
5142
5133
  }
5143
5134
  function mergePoints(left, right) {
@@ -5978,7 +5969,7 @@ function convertKeyword2Percent(keyword) {
5978
5969
  return '50%';
5979
5970
  }
5980
5971
  else if (keyword === 'left' || keyword === 'top') {
5981
- return '0';
5972
+ return '0%';
5982
5973
  }
5983
5974
  else if (keyword === 'right' || keyword === 'bottom') {
5984
5975
  return '100%';
@@ -6246,16 +6237,17 @@ var BUILT_IN_PROPERTIES = [
6246
6237
  {
6247
6238
  n: 'transformOrigin',
6248
6239
  p: 100,
6249
- // int: true,
6250
- d: function (nodeName) {
6251
- if (nodeName === exports.Shape.CIRCLE || nodeName === exports.Shape.ELLIPSE) {
6252
- return 'center';
6253
- }
6254
- if (nodeName === exports.Shape.TEXT) {
6255
- return 'text-anchor';
6256
- }
6257
- return 'left top';
6258
- },
6240
+ d: '0 0',
6241
+ // // int: true,
6242
+ // d: (nodeName: string) => {
6243
+ // if (nodeName === Shape.CIRCLE || nodeName === Shape.ELLIPSE) {
6244
+ // return 'center';
6245
+ // }
6246
+ // if (nodeName === Shape.TEXT) {
6247
+ // return 'text-anchor';
6248
+ // }
6249
+ // return 'left top';
6250
+ // },
6259
6251
  l: true,
6260
6252
  syntax: exports.PropertySyntax.TRANSFORM_ORIGIN,
6261
6253
  },
@@ -6394,11 +6386,10 @@ var BUILT_IN_PROPERTIES = [
6394
6386
  },
6395
6387
  // Path
6396
6388
  {
6397
- n: 'path',
6389
+ n: 'd',
6398
6390
  int: true,
6399
6391
  l: true,
6400
6392
  d: '',
6401
- a: ['d'],
6402
6393
  syntax: exports.PropertySyntax.PATH,
6403
6394
  p: 50,
6404
6395
  },
@@ -6622,16 +6613,16 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6622
6613
  }; }
6623
6614
  if (!this.runtime.enableCSSParsing) {
6624
6615
  Object.assign(object.attributes, attributes);
6625
- var attributeNames_1 = Object.keys(attributes);
6616
+ var attributeNames = Object.keys(attributes);
6626
6617
  // clipPath
6627
6618
  var oldClipPath = object.parsedStyle.clipPath;
6628
6619
  var oldOffsetPath = object.parsedStyle.offsetPath;
6629
6620
  object.parsedStyle = Object.assign(object.parsedStyle, attributes);
6630
- var needUpdateGeometry_1 = !!options.forceUpdateGeometry;
6631
- if (!needUpdateGeometry_1) {
6621
+ var needUpdateGeometry = !!options.forceUpdateGeometry;
6622
+ if (!needUpdateGeometry) {
6632
6623
  for (var i = 0; i < GEOMETRY_ATTRIBUTE_NAMES.length; i++) {
6633
6624
  if (GEOMETRY_ATTRIBUTE_NAMES[i] in attributes) {
6634
- needUpdateGeometry_1 = true;
6625
+ needUpdateGeometry = true;
6635
6626
  break;
6636
6627
  }
6637
6628
  }
@@ -6667,20 +6658,20 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6667
6658
  }
6668
6659
  // Path
6669
6660
  // @ts-ignore
6670
- if (attributes.path === '') {
6671
- object.parsedStyle.path = tslib.__assign({}, EMPTY_PARSED_PATH);
6661
+ if (attributes.d === '') {
6662
+ object.parsedStyle.d = tslib.__assign({}, EMPTY_PARSED_PATH);
6672
6663
  }
6673
6664
  // @ts-ignore
6674
- if (attributes.path) {
6675
- object.parsedStyle.path = parsePath(
6665
+ if (attributes.d) {
6666
+ object.parsedStyle.d = parsePath(
6676
6667
  // @ts-ignore
6677
- attributes.path);
6668
+ attributes.d);
6678
6669
  }
6679
6670
  // Text
6680
6671
  if (attributes.textTransform) {
6681
6672
  this.runtime.CSSPropertySyntaxFactory['<text-transform>'].calculator(null, null, { value: attributes.textTransform }, object, null);
6682
6673
  }
6683
- if (attributes.clipPath) {
6674
+ if (!util.isUndefined(attributes.clipPath)) {
6684
6675
  this.runtime.CSSPropertySyntaxFactory['<defined-path>'].calculator('clipPath', oldClipPath, attributes.clipPath, object, this.runtime);
6685
6676
  }
6686
6677
  if (attributes.offsetPath) {
@@ -6718,97 +6709,107 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6718
6709
  attributes.markerMid, null, null);
6719
6710
  }
6720
6711
  if (!util.isNil(attributes.zIndex)) {
6721
- this.runtime.CSSPropertySyntaxFactory['<z-index>'].postProcessor(object, attributeNames_1);
6712
+ this.runtime.CSSPropertySyntaxFactory['<z-index>'].postProcessor(object, attributeNames);
6722
6713
  }
6723
6714
  if (!util.isNil(attributes.offsetDistance)) {
6724
- this.runtime.CSSPropertySyntaxFactory['<offset-distance>'].postProcessor(object, attributeNames_1);
6715
+ this.runtime.CSSPropertySyntaxFactory['<offset-distance>'].postProcessor(object, attributeNames);
6725
6716
  }
6726
6717
  if (attributes.transform) {
6727
- this.runtime.CSSPropertySyntaxFactory['<transform>'].postProcessor(object, attributeNames_1);
6718
+ this.runtime.CSSPropertySyntaxFactory['<transform>'].postProcessor(object, attributeNames);
6728
6719
  }
6729
- if (needUpdateGeometry_1) {
6720
+ if (attributes.transformOrigin) {
6721
+ this.runtime.CSSPropertySyntaxFactory['<transform-origin>'].postProcessor(object, attributeNames);
6722
+ }
6723
+ if (needUpdateGeometry) {
6730
6724
  object.geometry.dirty = true;
6731
- // FIXME setOrigin may have already dirtified to root.
6732
- this.runtime.sceneGraphService.dirtifyToRoot(object);
6725
+ object.renderable.boundsDirty = true;
6726
+ object.renderable.renderBoundsDirty = true;
6727
+ if (!options.forceUpdateGeometry) {
6728
+ this.runtime.sceneGraphService.dirtifyToRoot(object);
6729
+ }
6733
6730
  }
6734
- return;
6735
6731
  }
6736
- var skipUpdateAttribute = options.skipUpdateAttribute, skipParse = options.skipParse, forceUpdateGeometry = options.forceUpdateGeometry, usedAttributes = options.usedAttributes, memoize = options.memoize;
6737
- var needUpdateGeometry = forceUpdateGeometry;
6738
- var attributeNames = Object.keys(attributes);
6739
- attributeNames.forEach(function (attributeName) {
6740
- var _a;
6741
- if (!skipUpdateAttribute) {
6742
- object.attributes[attributeName] = attributes[attributeName];
6743
- }
6744
- if (!needUpdateGeometry && ((_a = propertyMetadataCache[attributeName]) === null || _a === void 0 ? void 0 : _a.l)) {
6745
- needUpdateGeometry = true;
6746
- }
6747
- });
6748
- if (!skipParse) {
6749
- attributeNames.forEach(function (name) {
6750
- object.computedStyle[name] = _this.parseProperty(name, object.attributes[name], object, memoize);
6732
+ else {
6733
+ var skipUpdateAttribute_1 = options.skipUpdateAttribute, skipParse = options.skipParse, forceUpdateGeometry = options.forceUpdateGeometry, usedAttributes = options.usedAttributes, memoize_1 = options.memoize;
6734
+ var needUpdateGeometry_1 = forceUpdateGeometry;
6735
+ var attributeNames_1 = Object.keys(attributes);
6736
+ attributeNames_1.forEach(function (attributeName) {
6737
+ var _a;
6738
+ if (!skipUpdateAttribute_1) {
6739
+ object.attributes[attributeName] = attributes[attributeName];
6740
+ }
6741
+ if (!needUpdateGeometry_1 && ((_a = propertyMetadataCache[attributeName]) === null || _a === void 0 ? void 0 : _a.l)) {
6742
+ needUpdateGeometry_1 = true;
6743
+ }
6751
6744
  });
6752
- }
6753
- // let hasUnresolvedProperties = false;
6754
- // parse according to priority
6755
- // path 50
6756
- // points 50
6757
- // text 50
6758
- // textTransform 51
6759
- // transform 100
6760
- // transformOrigin 100
6761
- if (usedAttributes === null || usedAttributes === void 0 ? void 0 : usedAttributes.length) {
6762
- // uniqueAttributeSet.clear();
6763
- attributeNames = Array.from(new Set(attributeNames.concat(usedAttributes)));
6764
- }
6765
- // [
6766
- // 'path',
6767
- // 'points',
6768
- // 'text',
6769
- // 'textTransform',
6770
- // 'transform',
6771
- // 'transformOrigin',
6772
- // ].forEach((name) => {
6773
- // const index = attributeNames.indexOf(name);
6774
- // if (index > -1) {
6775
- // attributeNames.splice(index, 1);
6776
- // attributeNames.push(name);
6777
- // }
6778
- // });
6779
- attributeNames.forEach(function (name) {
6780
- // some style props maybe deleted after parsing such as `anchor` in Text
6781
- if (name in object.computedStyle) {
6782
- object.parsedStyle[name] = _this.computeProperty(name, object.computedStyle[name], object, memoize);
6745
+ if (!skipParse) {
6746
+ attributeNames_1.forEach(function (name) {
6747
+ object.computedStyle[name] = _this.parseProperty(name, object.attributes[name], object, memoize_1);
6748
+ });
6783
6749
  }
6784
- });
6785
- // if (hasUnresolvedProperties) {
6786
- // this.dirty = true;
6787
- // return;
6788
- // }
6789
- // update geometry
6790
- if (needUpdateGeometry) {
6791
- object.geometry.dirty = true;
6792
- // FIXME setOrigin may have already dirtified to root.
6793
- this.runtime.sceneGraphService.dirtifyToRoot(object);
6794
- }
6795
- attributeNames.forEach(function (name) {
6796
- if (name in object.parsedStyle) {
6797
- _this.postProcessProperty(name, object, attributeNames);
6750
+ // let hasUnresolvedProperties = false;
6751
+ // parse according to priority
6752
+ // path 50
6753
+ // points 50
6754
+ // text 50
6755
+ // textTransform 51
6756
+ // transform 100
6757
+ // transformOrigin 100
6758
+ if (usedAttributes === null || usedAttributes === void 0 ? void 0 : usedAttributes.length) {
6759
+ // uniqueAttributeSet.clear();
6760
+ attributeNames_1 = Array.from(new Set(attributeNames_1.concat(usedAttributes)));
6761
+ }
6762
+ // [
6763
+ // 'path',
6764
+ // 'points',
6765
+ // 'text',
6766
+ // 'textTransform',
6767
+ // 'transform',
6768
+ // 'transformOrigin',
6769
+ // ].forEach((name) => {
6770
+ // const index = attributeNames.indexOf(name);
6771
+ // if (index > -1) {
6772
+ // attributeNames.splice(index, 1);
6773
+ // attributeNames.push(name);
6774
+ // }
6775
+ // });
6776
+ attributeNames_1.forEach(function (name) {
6777
+ // some style props maybe deleted after parsing such as `anchor` in Text
6778
+ if (name in object.computedStyle) {
6779
+ object.parsedStyle[name] = _this.computeProperty(name, object.computedStyle[name], object, memoize_1);
6780
+ }
6781
+ });
6782
+ // if (hasUnresolvedProperties) {
6783
+ // this.dirty = true;
6784
+ // return;
6785
+ // }
6786
+ // update geometry
6787
+ if (needUpdateGeometry_1) {
6788
+ object.geometry.dirty = true;
6789
+ object.renderable.boundsDirty = true;
6790
+ object.renderable.renderBoundsDirty = true;
6791
+ if (!options.forceUpdateGeometry) {
6792
+ this.runtime.sceneGraphService.dirtifyToRoot(object);
6793
+ }
6798
6794
  }
6799
- });
6800
- if (this.runtime.enableCSSParsing && object.children.length) {
6801
- attributeNames.forEach(function (name) {
6802
- if (name in object.parsedStyle && _this.isPropertyInheritable(name)) {
6803
- // update children's inheritable
6804
- object.children.forEach(function (child) {
6805
- child.internalSetAttribute(name, null, {
6806
- skipUpdateAttribute: true,
6807
- skipParse: true,
6808
- });
6809
- });
6795
+ attributeNames_1.forEach(function (name) {
6796
+ if (name in object.parsedStyle) {
6797
+ _this.postProcessProperty(name, object, attributeNames_1);
6810
6798
  }
6811
6799
  });
6800
+ if (this.runtime.enableCSSParsing && object.children.length) {
6801
+ attributeNames_1.forEach(function (name) {
6802
+ if (name in object.parsedStyle && _this.isPropertyInheritable(name)) {
6803
+ // update children's inheritable
6804
+ object.children.forEach(function (child) {
6805
+ child.internalSetAttribute(name, null, {
6806
+ skipUpdateAttribute: true,
6807
+ skipParse: true,
6808
+ });
6809
+ });
6810
+ }
6811
+ });
6812
+ }
6812
6813
  }
6813
6814
  };
6814
6815
  /**
@@ -7001,11 +7002,15 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7001
7002
  // depth / 2,
7002
7003
  // );
7003
7004
  // anchor is center by default, don't account for lineWidth here
7004
- var _h = parsedStyle, stroke = _h.stroke, lineWidth = _h.lineWidth,
7005
+ var _h = parsedStyle, stroke = _h.stroke, _j = _h.lineWidth, lineWidth = _j === void 0 ? 1 : _j,
7005
7006
  // lineCap,
7006
7007
  // lineJoin,
7007
7008
  // miterLimit,
7008
- increasedLineWidthForHitTesting = _h.increasedLineWidthForHitTesting, shadowType = _h.shadowType, shadowColor = _h.shadowColor, _j = _h.filter, filter = _j === void 0 ? [] : _j, transformOrigin = _h.transformOrigin;
7009
+ _k = _h.increasedLineWidthForHitTesting,
7010
+ // lineCap,
7011
+ // lineJoin,
7012
+ // miterLimit,
7013
+ increasedLineWidthForHitTesting = _k === void 0 ? 0 : _k, _l = _h.shadowType, shadowType = _l === void 0 ? 'outer' : _l, shadowColor = _h.shadowColor, _m = _h.filter, filter = _m === void 0 ? [] : _m, transformOrigin = _h.transformOrigin;
7009
7014
  var center = [cx, cy, cz];
7010
7015
  // update geometry's AABB
7011
7016
  geometry_1.contentBounds.update(center, halfExtents);
@@ -7039,8 +7044,8 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7039
7044
  geometry_1.renderBounds.update(center, halfExtents);
7040
7045
  // account for shadow, only support constant value now
7041
7046
  if (shadowColor && shadowType && shadowType !== 'inner') {
7042
- var _k = geometry_1.renderBounds, min = _k.min, max = _k.max;
7043
- var _l = parsedStyle, shadowBlur = _l.shadowBlur, shadowOffsetX = _l.shadowOffsetX, shadowOffsetY = _l.shadowOffsetY;
7047
+ var _o = geometry_1.renderBounds, min = _o.min, max = _o.max;
7048
+ var _p = parsedStyle, shadowBlur = _p.shadowBlur, shadowOffsetX = _p.shadowOffsetX, shadowOffsetY = _p.shadowOffsetY;
7044
7049
  var shadowBlurInPixels = shadowBlur || 0;
7045
7050
  var shadowOffsetXInPixels = shadowOffsetX || 0;
7046
7051
  var shadowOffsetYInPixels = shadowOffsetY || 0;
@@ -7078,23 +7083,47 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7078
7083
  }
7079
7084
  });
7080
7085
  object.geometry.dirty = false;
7081
- // if (nodeName === Shape.RECT) {
7082
- // account for negative width / height of Rect
7083
7086
  // @see https://github.com/antvis/g/issues/957
7084
7087
  var flipY = hwidth < 0;
7085
7088
  var flipX = hheight < 0;
7086
- // } else {
7087
- // }
7088
7089
  // set transform origin
7089
7090
  var usedOriginXValue = (flipY ? -1 : 1) *
7090
7091
  (transformOrigin
7091
- ? convertPercentUnit(transformOrigin[0], 0, object)
7092
+ ? convertPercentUnit(transformOrigin[0], 0, object, true)
7092
7093
  : 0);
7093
7094
  var usedOriginYValue = (flipX ? -1 : 1) *
7094
7095
  (transformOrigin
7095
- ? convertPercentUnit(transformOrigin[1], 1, object)
7096
+ ? convertPercentUnit(transformOrigin[1], 1, object, true)
7096
7097
  : 0);
7097
- object.setOrigin(cx - hwidth + usedOriginXValue, cy - hheight + usedOriginYValue);
7098
+ if (usedOriginXValue || usedOriginYValue) {
7099
+ object.setOrigin(usedOriginXValue, usedOriginYValue);
7100
+ }
7101
+ }
7102
+ };
7103
+ DefaultStyleValueRegistry.prototype.updateSizeAttenuation = function (node, zoom) {
7104
+ if (node.style.isSizeAttenuation) {
7105
+ if (!node.style.rawLineWidth) {
7106
+ node.style.rawLineWidth = node.style.lineWidth;
7107
+ }
7108
+ node.style.lineWidth = (node.style.rawLineWidth || 1) / zoom;
7109
+ if (node.nodeName === exports.Shape.CIRCLE) {
7110
+ if (!node.style.rawR) {
7111
+ node.style.rawR = node.style.r;
7112
+ }
7113
+ node.style.r = (node.style.rawR || 1) / zoom;
7114
+ }
7115
+ }
7116
+ else {
7117
+ if (node.style.rawLineWidth) {
7118
+ node.style.lineWidth = node.style.rawLineWidth;
7119
+ delete node.style.rawLineWidth;
7120
+ }
7121
+ if (node.nodeName === exports.Shape.CIRCLE) {
7122
+ if (node.style.rawR) {
7123
+ node.style.r = node.style.rawR;
7124
+ delete node.style.rawR;
7125
+ }
7126
+ }
7098
7127
  }
7099
7128
  };
7100
7129
  DefaultStyleValueRegistry.prototype.isPropertyInheritable = function (name) {
@@ -7520,8 +7549,8 @@ function sortedIndex(array, value) {
7520
7549
  return low;
7521
7550
  }
7522
7551
  function sortByZIndex(o1, o2) {
7523
- var zIndex1 = Number(o1.parsedStyle.zIndex);
7524
- var zIndex2 = Number(o2.parsedStyle.zIndex);
7552
+ var zIndex1 = Number(o1.parsedStyle.zIndex || 0);
7553
+ var zIndex2 = Number(o2.parsedStyle.zIndex || 0);
7525
7554
  if (zIndex1 === zIndex2) {
7526
7555
  var parent_1 = o1.parentNode;
7527
7556
  if (parent_1) {
@@ -7585,6 +7614,7 @@ var clock = typeof performance === 'object' && performance.now ? performance : D
7585
7614
  function isFillOrStrokeAffected(pointerEvents, fill, stroke) {
7586
7615
  // account for pointerEvents
7587
7616
  // @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
7617
+ if (pointerEvents === void 0) { pointerEvents = 'auto'; }
7588
7618
  var hasFill = false;
7589
7619
  var hasStroke = false;
7590
7620
  var isFillOtherThanNone = !!fill && !fill.isNone;
@@ -7811,7 +7841,7 @@ var genericFontFamilies = [
7811
7841
  ];
7812
7842
  var stringRegExp = /([\"\'])[^\'\"]+\1/;
7813
7843
  function toFontString(attributes) {
7814
- var fontSize = attributes.fontSize, fontFamily = attributes.fontFamily, fontStyle = attributes.fontStyle, fontVariant = attributes.fontVariant, fontWeight = attributes.fontWeight;
7844
+ var _a = attributes.fontSize, fontSize = _a === void 0 ? 16 : _a, _b = attributes.fontFamily, fontFamily = _b === void 0 ? 'sans-serif' : _b, _c = attributes.fontStyle, fontStyle = _c === void 0 ? 'normal' : _c, _d = attributes.fontVariant, fontVariant = _d === void 0 ? 'normal' : _d, _e = attributes.fontWeight, fontWeight = _e === void 0 ? 'normal' : _e;
7815
7845
  // build canvas api font setting from individual components. Convert a numeric this.fontSize to px
7816
7846
  // const fontSizeString: string = isNumber(fontSize) ? `${fontSize}px` : fontSize.toString();
7817
7847
  var fontSizeString = (util.isNumber(fontSize) && "".concat(fontSize, "px")) || '16px';
@@ -7839,6 +7869,7 @@ function createSkewMatrix(skewMatrix, skewX, skewY) {
7839
7869
  skewMatrix[1] = Math.tan(skewY); // Skew X axis in Y direction
7840
7870
  return skewMatrix;
7841
7871
  }
7872
+ var SCALE_EPSILON = 0.00001;
7842
7873
  var tmpMat1 = glMatrix.mat4.create();
7843
7874
  var tmpMat2 = glMatrix.mat4.create();
7844
7875
  function parsedTransformToMat4(transform, object) {
@@ -7848,23 +7879,27 @@ function parsedTransformToMat4(transform, object) {
7848
7879
  var t = parsed.t, d = parsed.d;
7849
7880
  if (t === 'scale') {
7850
7881
  // scale(1) scale(1, 1)
7851
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1];
7882
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [
7883
+ 1, 1,
7884
+ ];
7852
7885
  glMatrix.mat4.fromScaling(tmpMat2, [newScale[0], newScale[1], 1]);
7853
7886
  }
7854
7887
  else if (t === 'scalex') {
7855
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7888
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
7856
7889
  glMatrix.mat4.fromScaling(tmpMat2, [newScale[0], 1, 1]);
7857
7890
  }
7858
7891
  else if (t === 'scaley') {
7859
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7892
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
7860
7893
  glMatrix.mat4.fromScaling(tmpMat2, [1, newScale[0], 1]);
7861
7894
  }
7862
7895
  else if (t === 'scalez') {
7863
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7896
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
7864
7897
  glMatrix.mat4.fromScaling(tmpMat2, [1, 1, newScale[0]]);
7865
7898
  }
7866
7899
  else if (t === 'scale3d') {
7867
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1, 1];
7900
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [
7901
+ 1, 1, 1,
7902
+ ];
7868
7903
  glMatrix.mat4.fromScaling(tmpMat2, [newScale[0], newScale[1], newScale[2]]);
7869
7904
  }
7870
7905
  else if (t === 'translate') {
@@ -8009,17 +8044,18 @@ var CSSPropertyTransformOrigin = /** @class */ (function () {
8009
8044
  function CSSPropertyTransformOrigin() {
8010
8045
  this.parser = parseTransformOrigin;
8011
8046
  this.parserUnmemoize = parseTransformOriginUnmemoize;
8012
- // calculator(
8013
- // name: string,
8014
- // oldParsed: [CSSUnitValue, CSSUnitValue],
8015
- // parsed: [CSSUnitValue, CSSUnitValue],
8016
- // object: DisplayObject,
8017
- // ): [number, number] {
8018
- // console.log(object, parsed);
8019
- // return [parsed[0].value, parsed[1].value];
8020
- // // return [convertPercentUnit(parsed[0], 0, object), convertPercentUnit(parsed[1], 1, object)];
8021
- // }
8022
8047
  }
8048
+ CSSPropertyTransformOrigin.prototype.postProcessor = function (object) {
8049
+ var transformOrigin = object.parsedStyle.transformOrigin;
8050
+ if (transformOrigin[0].unit === exports.UnitType.kPixels &&
8051
+ transformOrigin[1].unit === exports.UnitType.kPixels) {
8052
+ object.setOrigin(transformOrigin[0].value, transformOrigin[1].value);
8053
+ }
8054
+ else {
8055
+ // Relative to geometry bounds, calculate later.
8056
+ object.getGeometryBounds();
8057
+ }
8058
+ };
8023
8059
  return CSSPropertyTransformOrigin;
8024
8060
  }());
8025
8061
 
@@ -8106,8 +8142,8 @@ var PathUpdater = /** @class */ (function () {
8106
8142
  function PathUpdater() {
8107
8143
  }
8108
8144
  PathUpdater.prototype.update = function (parsedStyle) {
8109
- var path = parsedStyle.path;
8110
- var _a = path.rect, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
8145
+ var d = parsedStyle.d;
8146
+ var _a = d.rect, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
8111
8147
  var hwidth = width / 2;
8112
8148
  var hheight = height / 2;
8113
8149
  return {
@@ -8156,17 +8192,17 @@ var RectUpdater = /** @class */ (function () {
8156
8192
  function RectUpdater() {
8157
8193
  }
8158
8194
  RectUpdater.prototype.update = function (parsedStyle, object) {
8159
- var _a = parsedStyle.x, x = _a === void 0 ? 0 : _a, _b = parsedStyle.y, y = _b === void 0 ? 0 : _b, img = parsedStyle.img, _c = parsedStyle.width, width = _c === void 0 ? 0 : _c, _d = parsedStyle.height, height = _d === void 0 ? 0 : _d;
8195
+ var _a = parsedStyle.x, x = _a === void 0 ? 0 : _a, _b = parsedStyle.y, y = _b === void 0 ? 0 : _b, src = parsedStyle.src, _c = parsedStyle.width, width = _c === void 0 ? 0 : _c, _d = parsedStyle.height, height = _d === void 0 ? 0 : _d;
8160
8196
  var contentWidth = width;
8161
8197
  var contentHeight = height;
8162
8198
  // resize with HTMLImageElement's size
8163
- if (img && !util.isString(img)) {
8199
+ if (src && !util.isString(src)) {
8164
8200
  if (!contentWidth) {
8165
- contentWidth = img.width;
8201
+ contentWidth = src.width;
8166
8202
  parsedStyle.width = contentWidth;
8167
8203
  }
8168
8204
  if (!contentHeight) {
8169
- contentHeight = img.height;
8205
+ contentHeight = src.height;
8170
8206
  parsedStyle.height = contentHeight;
8171
8207
  }
8172
8208
  }
@@ -8186,18 +8222,20 @@ var TextUpdater = /** @class */ (function () {
8186
8222
  }
8187
8223
  TextUpdater.prototype.isReadyToMeasure = function (parsedStyle, object) {
8188
8224
  var text = parsedStyle.text, textAlign = parsedStyle.textAlign, textBaseline = parsedStyle.textBaseline, fontSize = parsedStyle.fontSize, fontStyle = parsedStyle.fontStyle, fontWeight = parsedStyle.fontWeight, fontVariant = parsedStyle.fontVariant, lineWidth = parsedStyle.lineWidth;
8189
- return (text &&
8190
- fontSize &&
8191
- fontStyle &&
8192
- fontWeight &&
8193
- fontVariant &&
8194
- textAlign &&
8195
- textBaseline &&
8196
- !util.isNil(lineWidth));
8225
+ return runtime.enableCSSParsing
8226
+ ? text &&
8227
+ fontSize &&
8228
+ fontStyle &&
8229
+ fontWeight &&
8230
+ fontVariant &&
8231
+ textAlign &&
8232
+ textBaseline &&
8233
+ !util.isNil(lineWidth)
8234
+ : text;
8197
8235
  };
8198
8236
  TextUpdater.prototype.update = function (parsedStyle, object) {
8199
8237
  var _a, _b;
8200
- var text = parsedStyle.text, textAlign = parsedStyle.textAlign, lineWidth = parsedStyle.lineWidth, textBaseline = parsedStyle.textBaseline, dx = parsedStyle.dx, dy = parsedStyle.dy, _c = parsedStyle.x, x = _c === void 0 ? 0 : _c, _d = parsedStyle.y, y = _d === void 0 ? 0 : _d;
8238
+ var text = parsedStyle.text, _c = parsedStyle.textAlign, textAlign = _c === void 0 ? 'start' : _c, _d = parsedStyle.lineWidth, lineWidth = _d === void 0 ? 1 : _d, _e = parsedStyle.textBaseline, textBaseline = _e === void 0 ? 'alphabetic' : _e, _f = parsedStyle.dx, dx = _f === void 0 ? 0 : _f, _g = parsedStyle.dy, dy = _g === void 0 ? 0 : _g, _h = parsedStyle.x, x = _h === void 0 ? 0 : _h, _j = parsedStyle.y, y = _j === void 0 ? 0 : _j;
8201
8239
  if (!this.isReadyToMeasure(parsedStyle, object)) {
8202
8240
  parsedStyle.metrics = {
8203
8241
  font: '',
@@ -9620,10 +9658,13 @@ var EventService = /** @class */ (function () {
9620
9658
  * whether the native event trigger came from Canvas,
9621
9659
  * should account for HTML shape
9622
9660
  */
9623
- EventService.prototype.isNativeEventFromCanvas = function (event) {
9624
- var _a;
9625
- var $el = this.context.contextService.getDomElement();
9626
- var target = (_a = event.nativeEvent) === null || _a === void 0 ? void 0 : _a.target;
9661
+ EventService.prototype.isNativeEventFromCanvas = function ($el, nativeEvent) {
9662
+ var target = nativeEvent === null || nativeEvent === void 0 ? void 0 : nativeEvent.target;
9663
+ // Get event target inside a web component.
9664
+ // @see https://stackoverflow.com/questions/57963312/get-event-target-inside-a-web-component
9665
+ if (target === null || target === void 0 ? void 0 : target.shadowRoot) {
9666
+ target = nativeEvent.composedPath()[0];
9667
+ }
9627
9668
  if (target) {
9628
9669
  // from <canvas>
9629
9670
  if (target === $el) {
@@ -9634,8 +9675,8 @@ var EventService = /** @class */ (function () {
9634
9675
  return $el.contains(target);
9635
9676
  }
9636
9677
  }
9637
- if (event.nativeEvent.composedPath) {
9638
- return event.nativeEvent.composedPath().indexOf($el) > -1;
9678
+ if (nativeEvent === null || nativeEvent === void 0 ? void 0 : nativeEvent.composedPath) {
9679
+ return nativeEvent.composedPath().indexOf($el) > -1;
9639
9680
  }
9640
9681
  // account for Touch
9641
9682
  return false;
@@ -9683,9 +9724,11 @@ var EventService = /** @class */ (function () {
9683
9724
  event.nativeEvent = from.nativeEvent;
9684
9725
  event.originalEvent = from;
9685
9726
  var existedHTML = this.getExistedHTML(event);
9727
+ var $el = this.context.contextService.getDomElement();
9686
9728
  event.target =
9687
9729
  target !== null && target !== void 0 ? target : (existedHTML ||
9688
- (this.isNativeEventFromCanvas(event) && this.pickTarget(event)) ||
9730
+ (this.isNativeEventFromCanvas($el, event.nativeEvent) &&
9731
+ this.pickTarget(event)) ||
9689
9732
  fallbackTarget);
9690
9733
  if (typeof type === 'string') {
9691
9734
  event.type = type;
@@ -9700,9 +9743,11 @@ var EventService = /** @class */ (function () {
9700
9743
  event.nativeEvent = from.nativeEvent;
9701
9744
  event.originalEvent = from;
9702
9745
  var existedHTML = this.getExistedHTML(event);
9746
+ var $el = this.context.contextService.getDomElement();
9703
9747
  event.target =
9704
9748
  existedHTML ||
9705
- (this.isNativeEventFromCanvas(event) && this.pickTarget(event));
9749
+ (this.isNativeEventFromCanvas($el, event.nativeEvent) &&
9750
+ this.pickTarget(event));
9706
9751
  return event;
9707
9752
  };
9708
9753
  EventService.prototype.trackingData = function (id) {
@@ -10702,6 +10747,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10702
10747
  }
10703
10748
  };
10704
10749
  DefaultSceneGraphService.prototype.getOrigin = function (element) {
10750
+ element.getGeometryBounds();
10705
10751
  return element.transformable.origin;
10706
10752
  };
10707
10753
  /**
@@ -11011,6 +11057,9 @@ var DefaultSceneGraphService = /** @class */ (function () {
11011
11057
  }
11012
11058
  }
11013
11059
  });
11060
+ if (!aabb) {
11061
+ aabb = new AABB();
11062
+ }
11014
11063
  if (render) {
11015
11064
  // FIXME: account for clip path
11016
11065
  var clipped = findClosestClipPathTarget(element);
@@ -11018,28 +11067,19 @@ var DefaultSceneGraphService = /** @class */ (function () {
11018
11067
  // use bounds under world space
11019
11068
  var clipPathBounds = clipped.parsedStyle.clipPath.getBounds(render);
11020
11069
  if (!aabb) {
11021
- aabb = clipPathBounds;
11070
+ aabb.update(clipPathBounds.center, clipPathBounds.halfExtents);
11022
11071
  }
11023
11072
  else if (clipPathBounds) {
11024
11073
  aabb = clipPathBounds.intersection(aabb);
11025
11074
  }
11026
11075
  }
11027
11076
  }
11028
- if (!aabb) {
11029
- aabb = new AABB();
11030
- }
11031
- if (aabb) {
11032
- if (render) {
11033
- renderable.renderBounds = aabb;
11034
- }
11035
- else {
11036
- renderable.bounds = aabb;
11037
- }
11038
- }
11039
11077
  if (render) {
11078
+ renderable.renderBounds = aabb;
11040
11079
  renderable.renderBoundsDirty = false;
11041
11080
  }
11042
11081
  else {
11082
+ renderable.bounds = aabb;
11043
11083
  renderable.boundsDirty = false;
11044
11084
  }
11045
11085
  return aabb;
@@ -11296,13 +11336,13 @@ var TextService = /** @class */ (function () {
11296
11336
  return properties;
11297
11337
  };
11298
11338
  TextService.prototype.measureText = function (text, parsedStyle, offscreenCanvas) {
11299
- var fontSize = parsedStyle.fontSize, wordWrap = parsedStyle.wordWrap, strokeHeight = parsedStyle.lineHeight, lineWidth = parsedStyle.lineWidth, textBaseline = parsedStyle.textBaseline, textAlign = parsedStyle.textAlign, letterSpacing = parsedStyle.letterSpacing, textPath = parsedStyle.textPath; parsedStyle.textPathSide; parsedStyle.textPathStartOffset;
11339
+ var _a = parsedStyle.fontSize, fontSize = _a === void 0 ? 16 : _a, _b = parsedStyle.wordWrap, wordWrap = _b === void 0 ? false : _b, strokeHeight = parsedStyle.lineHeight, _c = parsedStyle.lineWidth, lineWidth = _c === void 0 ? 1 : _c, _d = parsedStyle.textBaseline, textBaseline = _d === void 0 ? 'alphabetic' : _d, _e = parsedStyle.textAlign, textAlign = _e === void 0 ? 'start' : _e, _f = parsedStyle.letterSpacing, letterSpacing = _f === void 0 ? 0 : _f, textPath = parsedStyle.textPath; parsedStyle.textPathSide; parsedStyle.textPathStartOffset;
11300
11340
  var // dropShadow = 0,
11301
11341
  // dropShadowDistance = 0,
11302
- _a = parsedStyle.leading,
11342
+ _g = parsedStyle.leading,
11303
11343
  // dropShadow = 0,
11304
11344
  // dropShadowDistance = 0,
11305
- leading = _a === void 0 ? 0 : _a;
11345
+ leading = _g === void 0 ? 0 : _g;
11306
11346
  var font = toFontString(parsedStyle);
11307
11347
  // if (runtime.enableCSSParsing) {
11308
11348
  var fontProperties = this.measureFont(font, offscreenCanvas);
@@ -11414,7 +11454,7 @@ var TextService = /** @class */ (function () {
11414
11454
  TextService.prototype.setGraphemeOnPath = function () { };
11415
11455
  TextService.prototype.wordWrap = function (text, parsedStyle, offscreenCanvas) {
11416
11456
  var _this = this;
11417
- var _a = parsedStyle.wordWrapWidth, wordWrapWidth = _a === void 0 ? 0 : _a, letterSpacing = parsedStyle.letterSpacing, _b = parsedStyle.maxLines, maxLines = _b === void 0 ? Infinity : _b, textOverflow = parsedStyle.textOverflow;
11457
+ var _a = parsedStyle.wordWrapWidth, wordWrapWidth = _a === void 0 ? 0 : _a, _b = parsedStyle.letterSpacing, letterSpacing = _b === void 0 ? 0 : _b, _c = parsedStyle.maxLines, maxLines = _c === void 0 ? Infinity : _c, textOverflow = parsedStyle.textOverflow;
11418
11458
  var context = this.runtime.offscreenCanvasCreator.getOrCreateContext(offscreenCanvas);
11419
11459
  var maxWidth = wordWrapWidth + letterSpacing;
11420
11460
  var ellipsis = '';
@@ -11638,9 +11678,11 @@ runtime.CSSPropertySyntaxFactory = CSSPropertySyntaxFactory;
11638
11678
  runtime.styleValueRegistry = new DefaultStyleValueRegistry(runtime);
11639
11679
  runtime.layoutRegistry = null;
11640
11680
  runtime.globalThis = getGlobalThis();
11641
- runtime.enableCSSParsing = true;
11681
+ runtime.enableCSSParsing = false;
11642
11682
  runtime.enableDataset = false;
11643
11683
  runtime.enableStyleSyntax = true;
11684
+ runtime.enableAttributeDashCased = false;
11685
+ runtime.enableSizeAttenuation = false;
11644
11686
 
11645
11687
  var entityCounter = 0;
11646
11688
  function resetEntityCounter() {
@@ -11886,8 +11928,11 @@ var Element = /** @class */ (function (_super) {
11886
11928
  if ((_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) {
11887
11929
  this.ownerDocument.defaultView.mountChildren(child);
11888
11930
  }
11889
- insertedEvent.relatedNode = this;
11890
- child.dispatchEvent(insertedEvent);
11931
+ // @ts-ignore
11932
+ if (this.isMutationObserved) {
11933
+ insertedEvent.relatedNode = this;
11934
+ child.dispatchEvent(insertedEvent);
11935
+ }
11891
11936
  return child;
11892
11937
  };
11893
11938
  Element.prototype.insertBefore = function (newChild, refChild) {
@@ -12160,8 +12205,10 @@ var Element = /** @class */ (function (_super) {
12160
12205
  }
12161
12206
  var value = this.attributes[name];
12162
12207
  if (value === undefined) {
12163
- var attributeName = formatAttributeName(name);
12164
- value = this.attributes[attributeName];
12208
+ if (runtime.enableAttributeDashCased) {
12209
+ var attributeName = formatAttributeName(name);
12210
+ value = this.attributes[attributeName];
12211
+ }
12165
12212
  // if the given attribute does not exist, the value returned will either be null or ""
12166
12213
  return runtime.enableCSSParsing ? (util.isNil(value) ? null : value) : value;
12167
12214
  }
@@ -12231,6 +12278,9 @@ var Element = /** @class */ (function (_super) {
12231
12278
  function isDisplayObject(value) {
12232
12279
  return !!(value === null || value === void 0 ? void 0 : value.nodeName);
12233
12280
  }
12281
+ var Proxy = runtime.globalThis.Proxy
12282
+ ? runtime.globalThis.Proxy
12283
+ : function () { };
12234
12284
  var mutationEvent = new MutationEvent(exports.ElementEvent.ATTR_MODIFIED, null, null, null, null, MutationEvent.MODIFICATION, null, null);
12235
12285
  var DEFAULT_STYLE_PROPS = {
12236
12286
  opacity: '',
@@ -12267,7 +12317,20 @@ var DEFAULT_PARSED_STYLE_PROPS = {
12267
12317
  shadowType: 'outer',
12268
12318
  miterLimit: 10,
12269
12319
  };
12270
- var DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED = tslib.__assign(tslib.__assign({}, DEFAULT_PARSED_STYLE_PROPS), { opacity: 1, fillOpacity: 1, strokeOpacity: 1, visibility: 'visible', pointerEvents: 'auto', lineWidth: 1, lineCap: 'butt', lineJoin: 'miter', increasedLineWidthForHitTesting: 0, fillRule: 'nonzero' });
12320
+ // const DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED = {
12321
+ // ...DEFAULT_PARSED_STYLE_PROPS,
12322
+ // opacity: 1,
12323
+ // fillOpacity: 1,
12324
+ // strokeOpacity: 1,
12325
+ // visibility: 'visible',
12326
+ // pointerEvents: 'auto',
12327
+ // lineWidth: 1,
12328
+ // lineCap: 'butt',
12329
+ // lineJoin: 'miter',
12330
+ // increasedLineWidthForHitTesting: 0,
12331
+ // fillRule: 'nonzero',
12332
+ // // TODO: transformOrigin
12333
+ // };
12271
12334
  var INHERITABLE_BASE_STYLE_PROPS = [
12272
12335
  'opacity',
12273
12336
  'fillOpacity',
@@ -12319,13 +12382,6 @@ var DisplayObject = /** @class */ (function (_super) {
12319
12382
  * push to active animations after calling `animate()`
12320
12383
  */
12321
12384
  _this.activeAnimations = [];
12322
- /**
12323
- * Use `this.style.clipPath` instead.
12324
- * @deprecated
12325
- */
12326
- _this.getClip = function () {
12327
- return this.style.clipPath || null;
12328
- };
12329
12385
  // assign name, id to config
12330
12386
  // eg. group.get('name')
12331
12387
  _this.config = config;
@@ -12336,18 +12392,17 @@ var DisplayObject = /** @class */ (function (_super) {
12336
12392
  _this.className = _this.config.className || _this.config.class;
12337
12393
  }
12338
12394
  _this.nodeName = _this.config.type || exports.Shape.GROUP;
12339
- // merge parsed value
12340
- Object.assign(_this.parsedStyle, runtime.enableCSSParsing
12341
- ? DEFAULT_PARSED_STYLE_PROPS
12342
- : DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED, _this.config.initialParsedStyle);
12343
12395
  if (runtime.enableCSSParsing) {
12344
12396
  Object.assign(_this.attributes, DEFAULT_STYLE_PROPS);
12397
+ Object.assign(_this.parsedStyle, DEFAULT_PARSED_STYLE_PROPS, _this.config.initialParsedStyle);
12398
+ }
12399
+ else if (_this.config.initialParsedStyle) {
12400
+ Object.assign(_this.parsedStyle,
12401
+ // DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED,
12402
+ _this.config.initialParsedStyle);
12345
12403
  }
12346
12404
  // start to process attributes
12347
12405
  _this.initAttributes(_this.config.style);
12348
- var Proxy = runtime.globalThis.Proxy
12349
- ? runtime.globalThis.Proxy
12350
- : function () { };
12351
12406
  if (runtime.enableDataset) {
12352
12407
  _this.dataset = new Proxy({}, {
12353
12408
  get: function (target, name) {
@@ -12465,10 +12520,14 @@ var DisplayObject = /** @class */ (function (_super) {
12465
12520
  options.usedAttributes = INHERITABLE_STYLE_PROPS;
12466
12521
  }
12467
12522
  // account for FCP, process properties as less as possible
12468
- var formattedAttributes = {};
12469
- for (var name_1 in attributes) {
12470
- var attributeName = formatAttributeName(name_1);
12471
- formattedAttributes[attributeName] = attributes[name_1];
12523
+ var formattedAttributes = attributes;
12524
+ if (runtime.enableAttributeDashCased) {
12525
+ // @ts-ignore
12526
+ formattedAttributes = {};
12527
+ for (var name_1 in attributes) {
12528
+ var attributeName = formatAttributeName(name_1);
12529
+ formattedAttributes[attributeName] = attributes[name_1];
12530
+ }
12472
12531
  }
12473
12532
  runtime.styleValueRegistry.processProperties(this, formattedAttributes, options);
12474
12533
  // redraw at next frame
@@ -12477,14 +12536,16 @@ var DisplayObject = /** @class */ (function (_super) {
12477
12536
  DisplayObject.prototype.setAttribute = function (name, value, force, memoize) {
12478
12537
  if (force === void 0) { force = false; }
12479
12538
  if (memoize === void 0) { memoize = true; }
12480
- var attributeName = formatAttributeName(name);
12539
+ if (runtime.enableAttributeDashCased) {
12540
+ name = formatAttributeName(name);
12541
+ }
12481
12542
  // ignore undefined value
12482
12543
  if (util.isUndefined(value)) {
12483
12544
  return;
12484
12545
  }
12485
- if (force || value !== this.attributes[attributeName]) {
12486
- this.internalSetAttribute(attributeName, value, { memoize: memoize });
12487
- _super.prototype.setAttribute.call(this, attributeName, value);
12546
+ if (force || value !== this.attributes[name]) {
12547
+ this.internalSetAttribute(name, value, { memoize: memoize });
12548
+ _super.prototype.setAttribute.call(this, name, value);
12488
12549
  }
12489
12550
  };
12490
12551
  /**
@@ -12738,8 +12799,10 @@ var DisplayObject = /** @class */ (function (_super) {
12738
12799
  * shortcut for Used value of `visibility`
12739
12800
  */
12740
12801
  DisplayObject.prototype.isVisible = function () {
12741
- var _a;
12742
- return ((_a = this.parsedStyle) === null || _a === void 0 ? void 0 : _a.visibility) === 'visible';
12802
+ var _a, _b;
12803
+ return runtime.enableCSSParsing
12804
+ ? ((_a = this.parsedStyle) === null || _a === void 0 ? void 0 : _a.visibility) === 'visible'
12805
+ : ((_b = this.parsedStyle) === null || _b === void 0 ? void 0 : _b.visibility) !== 'hidden';
12743
12806
  };
12744
12807
  Object.defineProperty(DisplayObject.prototype, "interactive", {
12745
12808
  get: function () {
@@ -12931,13 +12994,6 @@ var DisplayObject = /** @class */ (function (_super) {
12931
12994
  DisplayObject.prototype.add = function (child, index) {
12932
12995
  return this.appendChild(child, index);
12933
12996
  };
12934
- /**
12935
- * Use `this.style.clipPath` instead.
12936
- * @deprecated
12937
- */
12938
- DisplayObject.prototype.setClip = function (clipPath) {
12939
- this.style.clipPath = clipPath;
12940
- };
12941
12997
  /**
12942
12998
  * @deprecated
12943
12999
  */
@@ -12982,124 +13038,11 @@ var DisplayObject = /** @class */ (function (_super) {
12982
13038
  return DisplayObject;
12983
13039
  }(Element));
12984
13040
 
12985
- /**
12986
- * holds useful CSS-related methods.
12987
- * @see https://developer.mozilla.org/en-US/docs/Web/API/CSS
12988
- *
12989
- * * CSS Typed OM @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/factory_functions
12990
- * * register property @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/RegisterProperty
12991
- * * CSS Layout API
12992
- */
12993
- var CSS = {
12994
- /**
12995
- * <number>
12996
- * @see https://drafts.csswg.org/css-values-4/#number-value
12997
- */
12998
- number: function (n) {
12999
- return new CSSUnitValue(n);
13000
- },
13001
- /**
13002
- * <percentage>
13003
- * @see https://drafts.csswg.org/css-values-4/#percentage-value
13004
- */
13005
- percent: function (n) {
13006
- return new CSSUnitValue(n, '%');
13007
- },
13008
- /**
13009
- * <length>
13010
- */
13011
- px: function (n) {
13012
- return new CSSUnitValue(n, 'px');
13013
- },
13014
- /**
13015
- * <length>
13016
- */
13017
- em: function (n) {
13018
- return new CSSUnitValue(n, 'em');
13019
- },
13020
- rem: function (n) {
13021
- return new CSSUnitValue(n, 'rem');
13022
- },
13023
- /**
13024
- * <angle>
13025
- */
13026
- deg: function (n) {
13027
- return new CSSUnitValue(n, 'deg');
13028
- },
13029
- /**
13030
- * <angle>
13031
- */
13032
- grad: function (n) {
13033
- return new CSSUnitValue(n, 'grad');
13034
- },
13035
- /**
13036
- * <angle>
13037
- */
13038
- rad: function (n) {
13039
- return new CSSUnitValue(n, 'rad');
13040
- },
13041
- /**
13042
- * <angle>
13043
- */
13044
- turn: function (n) {
13045
- return new CSSUnitValue(n, 'turn');
13046
- },
13047
- /**
13048
- * <time>
13049
- */
13050
- s: function (n) {
13051
- return new CSSUnitValue(n, 's');
13052
- },
13053
- /**
13054
- * <time>
13055
- */
13056
- ms: function (n) {
13057
- return new CSSUnitValue(n, 'ms');
13058
- },
13059
- /**
13060
- * CSS Properties & Values API
13061
- *
13062
- * @see https://developer.mozilla.org/en-US/docs/Web/API/CSS_Properties_and_Values_API
13063
- * @see https://drafts.css-houdini.org/css-properties-values-api/#registering-custom-properties
13064
- * @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/RegisterProperty
13065
- */
13066
- registerProperty: function (definition) {
13067
- var name = definition.name, inherits = definition.inherits, interpolable = definition.interpolable, initialValue = definition.initialValue, syntax = definition.syntax;
13068
- runtime.styleValueRegistry.registerMetadata({
13069
- n: name,
13070
- inh: inherits,
13071
- int: interpolable,
13072
- d: initialValue,
13073
- syntax: syntax,
13074
- });
13075
- },
13076
- /**
13077
- * CSS Layout API
13078
- * register layout
13079
- *
13080
- * @see https://github.com/w3c/css-houdini-drafts/blob/main/css-layout-api/EXPLAINER.md
13081
- * @see https://developer.mozilla.org/en-US/docs/Web/Guide/Houdini#css_layout_api
13082
- */
13083
- registerLayout: function (name, clazz) {
13084
- runtime.layoutRegistry.registerLayout(name, clazz);
13085
- },
13086
- };
13087
-
13088
13041
  var Circle = /** @class */ (function (_super) {
13089
13042
  tslib.__extends(Circle, _super);
13090
- // constructor(options: DisplayObjectConfig<CircleStyleProps> = {}) {
13091
- // super(options);
13092
- // this.nodeName = Shape.CIRCLE;
13093
- // }
13094
- function Circle(_a) {
13095
- if (_a === void 0) { _a = {}; }
13096
- var style = _a.style, rest = tslib.__rest(_a, ["style"]);
13097
- return _super.call(this, tslib.__assign({ type: exports.Shape.CIRCLE, style: runtime.enableCSSParsing
13098
- ? tslib.__assign({ cx: '', cy: '', r: '' }, style) : style, initialParsedStyle: {
13099
- transformOrigin: runtime.enableCSSParsing
13100
- ? null
13101
- : [PECENTAGE_50, PECENTAGE_50],
13102
- } }, rest)) || this;
13043
+ function Circle(options) {
13044
+ if (options === void 0) { options = {}; }
13045
+ return _super.call(this, tslib.__assign({ type: exports.Shape.CIRCLE }, options)) || this;
13103
13046
  }
13104
13047
  return Circle;
13105
13048
  }(DisplayObject));
@@ -13128,15 +13071,9 @@ var CustomElement = /** @class */ (function (_super) {
13128
13071
 
13129
13072
  var Ellipse = /** @class */ (function (_super) {
13130
13073
  tslib.__extends(Ellipse, _super);
13131
- function Ellipse(_a) {
13132
- if (_a === void 0) { _a = {}; }
13133
- var style = _a.style, rest = tslib.__rest(_a, ["style"]);
13134
- return _super.call(this, tslib.__assign({ type: exports.Shape.ELLIPSE, style: runtime.enableCSSParsing
13135
- ? tslib.__assign({ cx: '', cy: '', rx: '', ry: '' }, style) : style, initialParsedStyle: {
13136
- transformOrigin: runtime.enableCSSParsing
13137
- ? null
13138
- : [PECENTAGE_50, PECENTAGE_50],
13139
- } }, rest)) || this;
13074
+ function Ellipse(options) {
13075
+ if (options === void 0) { options = {}; }
13076
+ return _super.call(this, tslib.__assign({ type: exports.Shape.ELLIPSE }, options)) || this;
13140
13077
  }
13141
13078
  return Ellipse;
13142
13079
  }(DisplayObject));
@@ -13153,11 +13090,9 @@ var Ellipse = /** @class */ (function (_super) {
13153
13090
  */
13154
13091
  var Group = /** @class */ (function (_super) {
13155
13092
  tslib.__extends(Group, _super);
13156
- function Group(_a) {
13157
- if (_a === void 0) { _a = {}; }
13158
- var style = _a.style, rest = tslib.__rest(_a, ["style"]);
13159
- return _super.call(this, tslib.__assign({ type: exports.Shape.GROUP, style: runtime.enableCSSParsing
13160
- ? tslib.__assign({ width: '', height: '' }, style) : tslib.__assign({}, style) }, rest)) || this;
13093
+ function Group(options) {
13094
+ if (options === void 0) { options = {}; }
13095
+ return _super.call(this, tslib.__assign({ type: exports.Shape.GROUP }, options)) || this;
13161
13096
  }
13162
13097
  return Group;
13163
13098
  }(DisplayObject));
@@ -13230,11 +13165,9 @@ var HTML = /** @class */ (function (_super) {
13230
13165
 
13231
13166
  var Image = /** @class */ (function (_super) {
13232
13167
  tslib.__extends(Image, _super);
13233
- function Image(_a) {
13234
- if (_a === void 0) { _a = {}; }
13235
- var style = _a.style, rest = tslib.__rest(_a, ["style"]);
13236
- return _super.call(this, tslib.__assign({ type: exports.Shape.IMAGE, style: runtime.enableCSSParsing
13237
- ? tslib.__assign({ x: '', y: '', img: '', width: '', height: '' }, style) : tslib.__assign({}, style) }, rest)) || this;
13168
+ function Image(options) {
13169
+ if (options === void 0) { options = {}; }
13170
+ return _super.call(this, tslib.__assign({ type: exports.Shape.IMAGE }, options)) || this;
13238
13171
  }
13239
13172
  return Image;
13240
13173
  }(DisplayObject));
@@ -13363,11 +13296,11 @@ var Path = /** @class */ (function (_super) {
13363
13296
  var _this = this;
13364
13297
  var style = _a.style, rest = tslib.__rest(_a, ["style"]);
13365
13298
  _this = _super.call(this, tslib.__assign({ type: exports.Shape.PATH, style: runtime.enableCSSParsing
13366
- ? tslib.__assign({ path: '', miterLimit: '' }, style) : tslib.__assign({}, style), initialParsedStyle: runtime.enableCSSParsing
13299
+ ? tslib.__assign({ d: '', miterLimit: '' }, style) : tslib.__assign({}, style), initialParsedStyle: runtime.enableCSSParsing
13367
13300
  ? null
13368
13301
  : {
13369
13302
  miterLimit: 4,
13370
- path: tslib.__assign({}, EMPTY_PARSED_PATH),
13303
+ d: tslib.__assign({}, EMPTY_PARSED_PATH),
13371
13304
  } }, rest)) || this;
13372
13305
  _this.markerStartAngle = 0;
13373
13306
  _this.markerEndAngle = 0;
@@ -13392,7 +13325,7 @@ var Path = /** @class */ (function (_super) {
13392
13325
  return _this;
13393
13326
  }
13394
13327
  Path.prototype.attributeChangedCallback = function (attrName, oldValue, newValue, prevParsedValue, newParsedValue) {
13395
- if (attrName === 'path') {
13328
+ if (attrName === 'd') {
13396
13329
  // recalc markers
13397
13330
  this.transformMarker(true);
13398
13331
  this.transformMarker(false);
@@ -13467,7 +13400,7 @@ var Path = /** @class */ (function (_super) {
13467
13400
  marker.setLocalPosition(ox + Math.cos(rad) * offset, oy + Math.sin(rad) * offset);
13468
13401
  };
13469
13402
  Path.prototype.placeMarkerMid = function (marker) {
13470
- var segments = this.parsedStyle.path.segments;
13403
+ var segments = this.parsedStyle.d.segments;
13471
13404
  // clear all existed markers
13472
13405
  this.markerMidList.forEach(function (marker) {
13473
13406
  marker.remove();
@@ -13496,7 +13429,7 @@ var Path = /** @class */ (function (_super) {
13496
13429
  */
13497
13430
  Path.prototype.getPointAtLength = function (distance, inWorldSpace) {
13498
13431
  if (inWorldSpace === void 0) { inWorldSpace = false; }
13499
- var absolutePath = this.parsedStyle.path.absolutePath;
13432
+ var absolutePath = this.parsedStyle.d.absolutePath;
13500
13433
  var _a = util.getPointAtLength(absolutePath, distance), x = _a.x, y = _a.y;
13501
13434
  var transformed = glMatrix.vec3.transformMat4(glMatrix.vec3.create(), glMatrix.vec3.fromValues(x, y, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13502
13435
  // apply local transformation
@@ -13513,7 +13446,7 @@ var Path = /** @class */ (function (_super) {
13513
13446
  * Get start tangent vector
13514
13447
  */
13515
13448
  Path.prototype.getStartTangent = function () {
13516
- var segments = this.parsedStyle.path.segments;
13449
+ var segments = this.parsedStyle.d.segments;
13517
13450
  var result = [];
13518
13451
  if (segments.length > 1) {
13519
13452
  var startPoint = segments[0].currentPoint;
@@ -13535,7 +13468,7 @@ var Path = /** @class */ (function (_super) {
13535
13468
  * Get end tangent vector
13536
13469
  */
13537
13470
  Path.prototype.getEndTangent = function () {
13538
- var segments = this.parsedStyle.path.segments;
13471
+ var segments = this.parsedStyle.d.segments;
13539
13472
  var length = segments.length;
13540
13473
  var result = [];
13541
13474
  if (length > 1) {
@@ -13723,7 +13656,7 @@ var Polyline = /** @class */ (function (_super) {
13723
13656
  } }, rest)) || this;
13724
13657
  }
13725
13658
  Polyline.prototype.getTotalLength = function () {
13726
- return this.parsedStyle.points.totalLength;
13659
+ return getOrCalculatePolylineTotalLength(this);
13727
13660
  };
13728
13661
  Polyline.prototype.getPointAtLength = function (distance, inWorldSpace) {
13729
13662
  if (inWorldSpace === void 0) { inWorldSpace = false; }
@@ -13731,16 +13664,34 @@ var Polyline = /** @class */ (function (_super) {
13731
13664
  };
13732
13665
  Polyline.prototype.getPoint = function (ratio, inWorldSpace) {
13733
13666
  if (inWorldSpace === void 0) { inWorldSpace = false; }
13734
- var _a = this.parsedStyle.points, points = _a.points, segments = _a.segments;
13667
+ var points = this.parsedStyle.points.points;
13668
+ if (this.parsedStyle.points.segments.length === 0) {
13669
+ var segments_1 = [];
13670
+ var tempLength_1 = 0;
13671
+ var segmentT_1;
13672
+ var segmentL_1;
13673
+ var totalLength_1 = this.getTotalLength();
13674
+ points.forEach(function (p, i) {
13675
+ if (points[i + 1]) {
13676
+ segmentT_1 = [0, 0];
13677
+ segmentT_1[0] = tempLength_1 / totalLength_1;
13678
+ segmentL_1 = gMath.lineLength(p[0], p[1], points[i + 1][0], points[i + 1][1]);
13679
+ tempLength_1 += segmentL_1;
13680
+ segmentT_1[1] = tempLength_1 / totalLength_1;
13681
+ segments_1.push(segmentT_1);
13682
+ }
13683
+ });
13684
+ this.parsedStyle.points.segments = segments_1;
13685
+ }
13735
13686
  var subt = 0;
13736
13687
  var index = 0;
13737
- segments.forEach(function (v, i) {
13688
+ this.parsedStyle.points.segments.forEach(function (v, i) {
13738
13689
  if (ratio >= v[0] && ratio <= v[1]) {
13739
13690
  subt = (ratio - v[0]) / (v[1] - v[0]);
13740
13691
  index = i;
13741
13692
  }
13742
13693
  });
13743
- var _b = gMath.linePointAt(points[index][0], points[index][1], points[index + 1][0], points[index + 1][1], subt), x = _b.x, y = _b.y;
13694
+ var _a = gMath.linePointAt(points[index][0], points[index][1], points[index + 1][0], points[index + 1][1], subt), x = _a.x, y = _a.y;
13744
13695
  var transformed = glMatrix.vec3.transformMat4(glMatrix.vec3.create(), glMatrix.vec3.fromValues(x, y, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13745
13696
  // apply local transformation
13746
13697
  return new Point(transformed[0], transformed[1]);
@@ -13765,11 +13716,9 @@ var Polyline = /** @class */ (function (_super) {
13765
13716
 
13766
13717
  var Rect = /** @class */ (function (_super) {
13767
13718
  tslib.__extends(Rect, _super);
13768
- function Rect(_a) {
13769
- if (_a === void 0) { _a = {}; }
13770
- var style = _a.style, rest = tslib.__rest(_a, ["style"]);
13771
- return _super.call(this, tslib.__assign({ type: exports.Shape.RECT, style: runtime.enableCSSParsing
13772
- ? tslib.__assign({ x: '', y: '', width: '', height: '', radius: '' }, style) : tslib.__assign({}, style) }, rest)) || this;
13719
+ function Rect(options) {
13720
+ if (options === void 0) { options = {}; }
13721
+ return _super.call(this, tslib.__assign({ type: exports.Shape.RECT }, options)) || this;
13773
13722
  }
13774
13723
  return Rect;
13775
13724
  }(DisplayObject));
@@ -13791,26 +13740,7 @@ var Text = /** @class */ (function (_super) {
13791
13740
  return _super.call(this, tslib.__assign({ type: exports.Shape.TEXT, style: runtime.enableCSSParsing
13792
13741
  ? tslib.__assign({ x: '', y: '', text: '', fontSize: '', fontFamily: '', fontStyle: '', fontWeight: '', fontVariant: '', textAlign: '', textBaseline: '', textTransform: '', fill: 'black', letterSpacing: '', lineHeight: '', miterLimit: '',
13793
13742
  // whiteSpace: 'pre',
13794
- wordWrap: false, wordWrapWidth: 0, leading: 0, dx: '', dy: '' }, style) : tslib.__assign({ fill: 'black' }, style), initialParsedStyle: runtime.enableCSSParsing
13795
- ? {}
13796
- : {
13797
- x: 0,
13798
- y: 0,
13799
- fontSize: 16,
13800
- fontFamily: 'sans-serif',
13801
- fontStyle: 'normal',
13802
- fontWeight: 'normal',
13803
- fontVariant: 'normal',
13804
- lineHeight: 0,
13805
- letterSpacing: 0,
13806
- textBaseline: 'alphabetic',
13807
- textAlign: 'start',
13808
- wordWrap: false,
13809
- wordWrapWidth: 0,
13810
- leading: 0,
13811
- dx: 0,
13812
- dy: 0,
13813
- } }, rest)) || this;
13743
+ wordWrap: false, wordWrapWidth: 0, leading: 0, dx: '', dy: '' }, style) : tslib.__assign({ fill: 'black' }, style) }, rest)) || this;
13814
13744
  }
13815
13745
  // lengthAdjust: SVGAnimatedEnumeration;
13816
13746
  // textLength: SVGAnimatedLength;
@@ -13887,6 +13817,109 @@ var CustomElementRegistry = /** @class */ (function () {
13887
13817
  return CustomElementRegistry;
13888
13818
  }());
13889
13819
 
13820
+ /**
13821
+ * holds useful CSS-related methods.
13822
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CSS
13823
+ *
13824
+ * * CSS Typed OM @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/factory_functions
13825
+ * * register property @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/RegisterProperty
13826
+ * * CSS Layout API
13827
+ */
13828
+ var CSS = {
13829
+ /**
13830
+ * <number>
13831
+ * @see https://drafts.csswg.org/css-values-4/#number-value
13832
+ */
13833
+ number: function (n) {
13834
+ return new CSSUnitValue(n);
13835
+ },
13836
+ /**
13837
+ * <percentage>
13838
+ * @see https://drafts.csswg.org/css-values-4/#percentage-value
13839
+ */
13840
+ percent: function (n) {
13841
+ return new CSSUnitValue(n, '%');
13842
+ },
13843
+ /**
13844
+ * <length>
13845
+ */
13846
+ px: function (n) {
13847
+ return new CSSUnitValue(n, 'px');
13848
+ },
13849
+ /**
13850
+ * <length>
13851
+ */
13852
+ em: function (n) {
13853
+ return new CSSUnitValue(n, 'em');
13854
+ },
13855
+ rem: function (n) {
13856
+ return new CSSUnitValue(n, 'rem');
13857
+ },
13858
+ /**
13859
+ * <angle>
13860
+ */
13861
+ deg: function (n) {
13862
+ return new CSSUnitValue(n, 'deg');
13863
+ },
13864
+ /**
13865
+ * <angle>
13866
+ */
13867
+ grad: function (n) {
13868
+ return new CSSUnitValue(n, 'grad');
13869
+ },
13870
+ /**
13871
+ * <angle>
13872
+ */
13873
+ rad: function (n) {
13874
+ return new CSSUnitValue(n, 'rad');
13875
+ },
13876
+ /**
13877
+ * <angle>
13878
+ */
13879
+ turn: function (n) {
13880
+ return new CSSUnitValue(n, 'turn');
13881
+ },
13882
+ /**
13883
+ * <time>
13884
+ */
13885
+ s: function (n) {
13886
+ return new CSSUnitValue(n, 's');
13887
+ },
13888
+ /**
13889
+ * <time>
13890
+ */
13891
+ ms: function (n) {
13892
+ return new CSSUnitValue(n, 'ms');
13893
+ },
13894
+ /**
13895
+ * CSS Properties & Values API
13896
+ *
13897
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CSS_Properties_and_Values_API
13898
+ * @see https://drafts.css-houdini.org/css-properties-values-api/#registering-custom-properties
13899
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/RegisterProperty
13900
+ */
13901
+ registerProperty: function (definition) {
13902
+ var name = definition.name, inherits = definition.inherits, interpolable = definition.interpolable, initialValue = definition.initialValue, syntax = definition.syntax;
13903
+ runtime.styleValueRegistry.registerMetadata({
13904
+ n: name,
13905
+ inh: inherits,
13906
+ int: interpolable,
13907
+ d: initialValue,
13908
+ syntax: syntax,
13909
+ });
13910
+ },
13911
+ /**
13912
+ * CSS Layout API
13913
+ * register layout
13914
+ *
13915
+ * @see https://github.com/w3c/css-houdini-drafts/blob/main/css-layout-api/EXPLAINER.md
13916
+ * @see https://developer.mozilla.org/en-US/docs/Web/Guide/Houdini#css_layout_api
13917
+ */
13918
+ registerLayout: function (name, clazz) {
13919
+ runtime.layoutRegistry.registerLayout(name, clazz);
13920
+ },
13921
+ };
13922
+
13890
13923
  /**
13891
13924
  * the entry of DOM tree
13892
13925
  * Document -> Node -> EventTarget
@@ -13998,7 +14031,7 @@ var Document = /** @class */ (function (_super) {
13998
14031
  var hitTestList = [];
13999
14032
  rBushNodes.forEach(function (_a) {
14000
14033
  var displayObject = _a.displayObject;
14001
- var pointerEvents = displayObject.parsedStyle.pointerEvents;
14034
+ var _b = displayObject.parsedStyle.pointerEvents, pointerEvents = _b === void 0 ? 'auto' : _b;
14002
14035
  // account for `visibility`
14003
14036
  // @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
14004
14037
  var isVisibilityAffected = [
@@ -14400,21 +14433,8 @@ var EventPlugin = /** @class */ (function () {
14400
14433
  return;
14401
14434
  // account for element in SVG
14402
14435
  var $element = _this.context.contextService.getDomElement();
14403
- var outside = 'outside';
14404
- try {
14405
- outside =
14406
- $element &&
14407
- nativeEvent.target &&
14408
- nativeEvent.target !== $element &&
14409
- $element.contains &&
14410
- !$element.contains(nativeEvent.target)
14411
- ? 'outside'
14412
- : '';
14413
- }
14414
- catch (e) {
14415
- // nativeEvent.target maybe not Node, such as Window
14416
- // @see https://github.com/antvis/G/issues/1235
14417
- }
14436
+ var isNativeEventFromCanvas = _this.context.eventService.isNativeEventFromCanvas($element, nativeEvent);
14437
+ var outside = !isNativeEventFromCanvas ? 'outside' : '';
14418
14438
  var normalizedEvents = _this.normalizeToPointerEvent(nativeEvent, canvas);
14419
14439
  try {
14420
14440
  for (var normalizedEvents_3 = tslib.__values(normalizedEvents), normalizedEvents_3_1 = normalizedEvents_3.next(); !normalizedEvents_3_1.done; normalizedEvents_3_1 = normalizedEvents_3.next()) {
@@ -14727,11 +14747,13 @@ var PrepareRendererPlugin = /** @class */ (function () {
14727
14747
  * sync to RBush later
14728
14748
  */
14729
14749
  this.toSync = new Set();
14750
+ this.isFirstTimeRendering = true;
14751
+ this.syncing = false;
14752
+ this.isFirstTimeRenderingFinished = false;
14730
14753
  }
14731
- // private isFirstTimeRendering = true;
14732
- // private syncing = false;
14733
14754
  PrepareRendererPlugin.prototype.apply = function (context) {
14734
14755
  var _this = this;
14756
+ var _a;
14735
14757
  var renderingService = context.renderingService, renderingContext = context.renderingContext, rBushRoot = context.rBushRoot;
14736
14758
  var canvas = renderingContext.root.ownerDocument.defaultView;
14737
14759
  this.rBush = rBushRoot;
@@ -14760,6 +14782,9 @@ var PrepareRendererPlugin = /** @class */ (function () {
14760
14782
  };
14761
14783
  var handleMounted = function (e) {
14762
14784
  var object = e.target;
14785
+ if (runtime.enableSizeAttenuation) {
14786
+ runtime.styleValueRegistry.updateSizeAttenuation(object, canvas.getCamera().getZoom());
14787
+ }
14763
14788
  if (runtime.enableCSSParsing) {
14764
14789
  // recalc style values
14765
14790
  runtime.styleValueRegistry.recalc(object);
@@ -14790,26 +14815,28 @@ var PrepareRendererPlugin = /** @class */ (function () {
14790
14815
  canvas.removeEventListener(exports.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
14791
14816
  _this.toSync.clear();
14792
14817
  });
14818
+ var ric = (_a = runtime.globalThis.requestIdleCallback) !== null && _a !== void 0 ? _a : raf.bind(runtime.globalThis);
14793
14819
  renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
14794
- // if (this.isFirstTimeRendering) {
14795
- // this.isFirstTimeRendering = false;
14796
- // this.syncing = true;
14797
- // // @see https://github.com/antvis/G/issues/1117
14798
- // setTimeout(() => {
14799
- // this.syncRTree();
14800
- // console.log('fcp...');
14801
- // });
14802
- // } else {
14803
- // console.log('next...');
14804
- _this.syncRTree();
14805
- // }
14820
+ if (_this.isFirstTimeRendering) {
14821
+ _this.isFirstTimeRendering = false;
14822
+ _this.syncing = true;
14823
+ ric(function () {
14824
+ _this.syncRTree(true);
14825
+ _this.isFirstTimeRenderingFinished = true;
14826
+ });
14827
+ }
14828
+ else {
14829
+ _this.syncRTree();
14830
+ }
14806
14831
  });
14807
14832
  };
14808
- PrepareRendererPlugin.prototype.syncRTree = function () {
14809
- // if (this.syncing) {
14810
- // return;
14811
- // }
14833
+ PrepareRendererPlugin.prototype.syncRTree = function (force) {
14812
14834
  var _this = this;
14835
+ if (force === void 0) { force = false; }
14836
+ if (!force && (this.syncing || this.toSync.size === 0)) {
14837
+ return;
14838
+ }
14839
+ this.syncing = true;
14813
14840
  // bounds changed, need re-inserting its children
14814
14841
  var bulk = [];
14815
14842
  Array.from(this.toSync)
@@ -14823,6 +14850,14 @@ var PrepareRendererPlugin = /** @class */ (function () {
14823
14850
  }
14824
14851
  var renderBounds = node.getRenderBounds();
14825
14852
  if (renderBounds) {
14853
+ var renderable = node.renderable;
14854
+ if (force) {
14855
+ if (!renderable.dirtyRenderBounds) {
14856
+ renderable.dirtyRenderBounds = new AABB();
14857
+ }
14858
+ // save last dirty aabb
14859
+ renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
14860
+ }
14826
14861
  var _a = tslib.__read(renderBounds.getMin(), 2), minX = _a[0], minY = _a[1];
14827
14862
  var _b = tslib.__read(renderBounds.getMax(), 2), maxX = _b[0], maxY = _b[1];
14828
14863
  if (!rBushNode.aabb) {
@@ -14849,7 +14884,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
14849
14884
  this.rBush.load(bulk);
14850
14885
  bulk.length = 0;
14851
14886
  this.toSync.clear();
14852
- // this.syncing = false;
14887
+ this.syncing = false;
14853
14888
  };
14854
14889
  PrepareRendererPlugin.tag = 'Prepare';
14855
14890
  return PrepareRendererPlugin;
@@ -15002,10 +15037,20 @@ var Canvas = /** @class */ (function (_super) {
15002
15037
  // redraw when camera changed
15003
15038
  camera.eventEmitter.on(CameraEvent.UPDATED, function () {
15004
15039
  _this.context.renderingContext.renderReasons.add(exports.RenderReason.CAMERA_CHANGED);
15040
+ if (runtime.enableSizeAttenuation &&
15041
+ _this.getConfig().renderer.getConfig().enableSizeAttenuation) {
15042
+ _this.updateSizeAttenuation();
15043
+ }
15005
15044
  });
15006
15045
  // bind camera
15007
15046
  this.context.camera = camera;
15008
15047
  };
15048
+ Canvas.prototype.updateSizeAttenuation = function () {
15049
+ var zoom = this.getCamera().getZoom();
15050
+ this.document.documentElement.forEach(function (node) {
15051
+ runtime.styleValueRegistry.updateSizeAttenuation(node, zoom);
15052
+ });
15053
+ };
15009
15054
  Canvas.prototype.getConfig = function () {
15010
15055
  return this.context.config;
15011
15056
  };