@antv/g-lite 1.2.21 → 1.3.0-next.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
@@ -3569,7 +3569,7 @@ var parseGradient$1 = (function () {
3569
3569
  return getAST();
3570
3570
  };
3571
3571
  })();
3572
- function computeLinearGradient(width, height, angle) {
3572
+ function computeLinearGradient(min, width, height, angle) {
3573
3573
  var rad = deg2rad(angle.value);
3574
3574
  var rx = 0;
3575
3575
  var ry = 0;
@@ -3578,13 +3578,13 @@ function computeLinearGradient(width, height, angle) {
3578
3578
  // get the length of gradient line
3579
3579
  // @see https://observablehq.com/@danburzo/css-gradient-line
3580
3580
  var length = Math.abs(width * Math.cos(rad)) + Math.abs(height * Math.sin(rad));
3581
- var x1 = rcx - (Math.cos(rad) * length) / 2;
3582
- var y1 = rcy - (Math.sin(rad) * length) / 2;
3583
- var x2 = rcx + (Math.cos(rad) * length) / 2;
3584
- var y2 = rcy + (Math.sin(rad) * length) / 2;
3581
+ var x1 = min[0] + rcx - (Math.cos(rad) * length) / 2;
3582
+ var y1 = min[1] + rcy - (Math.sin(rad) * length) / 2;
3583
+ var x2 = min[0] + rcx + (Math.cos(rad) * length) / 2;
3584
+ var y2 = min[1] + rcy + (Math.sin(rad) * length) / 2;
3585
3585
  return { x1: x1, y1: y1, x2: x2, y2: y2 };
3586
3586
  }
3587
- function computeRadialGradient(width, height, cx, cy, size) {
3587
+ function computeRadialGradient(min, width, height, cx, cy, size) {
3588
3588
  // 'px'
3589
3589
  var x = cx.value;
3590
3590
  var y = cy.value;
@@ -3615,7 +3615,7 @@ function computeRadialGradient(width, height, cx, cy, size) {
3615
3615
  }
3616
3616
  }
3617
3617
  }
3618
- return { x: x, y: y, r: r };
3618
+ return { x: x + min[0], y: y + min[1], r: r };
3619
3619
  }
3620
3620
 
3621
3621
  var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
@@ -4812,11 +4812,10 @@ function getArcParams(startPoint, params) {
4812
4812
  };
4813
4813
  }
4814
4814
  function commandsToPathString(commands, object, transform) {
4815
- var _a = object.parsedStyle, _b = _a.defX, defX = _b === void 0 ? 0 : _b, _c = _a.defY, defY = _c === void 0 ? 0 : _c;
4816
4815
  return commands.reduce(function (prev, cur) {
4817
4816
  var path = '';
4818
4817
  if (cur[0] === 'M' || cur[0] === 'L') {
4819
- var p = glMatrix.vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
4818
+ var p = glMatrix.vec3.fromValues(cur[1], cur[2], 0);
4820
4819
  if (transform) {
4821
4820
  glMatrix.vec3.transformMat4(p, p, transform);
4822
4821
  }
@@ -4826,9 +4825,9 @@ function commandsToPathString(commands, object, transform) {
4826
4825
  path = cur[0];
4827
4826
  }
4828
4827
  else if (cur[0] === 'C') {
4829
- var p1 = glMatrix.vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
4830
- var p2 = glMatrix.vec3.fromValues(cur[3] - defX, cur[4] - defY, 0);
4831
- var p3 = glMatrix.vec3.fromValues(cur[5] - defX, cur[6] - defY, 0);
4828
+ var p1 = glMatrix.vec3.fromValues(cur[1], cur[2], 0);
4829
+ var p2 = glMatrix.vec3.fromValues(cur[3], cur[4], 0);
4830
+ var p3 = glMatrix.vec3.fromValues(cur[5], cur[6], 0);
4832
4831
  if (transform) {
4833
4832
  glMatrix.vec3.transformMat4(p1, p1, transform);
4834
4833
  glMatrix.vec3.transformMat4(p2, p2, transform);
@@ -4837,15 +4836,15 @@ function commandsToPathString(commands, object, transform) {
4837
4836
  path = "".concat(cur[0]).concat(p1[0], ",").concat(p1[1], ",").concat(p2[0], ",").concat(p2[1], ",").concat(p3[0], ",").concat(p3[1]);
4838
4837
  }
4839
4838
  else if (cur[0] === 'A') {
4840
- var c = glMatrix.vec3.fromValues(cur[6] - defX, cur[7] - defY, 0);
4839
+ var c = glMatrix.vec3.fromValues(cur[6], cur[7], 0);
4841
4840
  if (transform) {
4842
4841
  glMatrix.vec3.transformMat4(c, c, transform);
4843
4842
  }
4844
4843
  path = "".concat(cur[0]).concat(cur[1], ",").concat(cur[2], ",").concat(cur[3], ",").concat(cur[4], ",").concat(cur[5], ",").concat(c[0], ",").concat(c[1]);
4845
4844
  }
4846
4845
  else if (cur[0] === 'Q') {
4847
- var p1 = glMatrix.vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
4848
- var p2 = glMatrix.vec3.fromValues(cur[3] - defX, cur[4] - defY, 0);
4846
+ var p1 = glMatrix.vec3.fromValues(cur[1], cur[2], 0);
4847
+ var p2 = glMatrix.vec3.fromValues(cur[3], cur[4], 0);
4849
4848
  if (transform) {
4850
4849
  glMatrix.vec3.transformMat4(p1, p1, transform);
4851
4850
  glMatrix.vec3.transformMat4(p2, p2, transform);
@@ -4966,7 +4965,7 @@ function convertToPath(object, transform) {
4966
4965
  return commandsToPathString(commands, object, transform);
4967
4966
  }
4968
4967
  }
4969
- function translatePathToString(absolutePath, defX, defY, startOffsetX, startOffsetY, endOffsetX, endOffsetY) {
4968
+ function translatePathToString(absolutePath, startOffsetX, startOffsetY, endOffsetX, endOffsetY) {
4970
4969
  if (startOffsetX === void 0) { startOffsetX = 0; }
4971
4970
  if (startOffsetY === void 0) { startOffsetY = 0; }
4972
4971
  if (endOffsetX === void 0) { endOffsetX = 0; }
@@ -4985,27 +4984,27 @@ function translatePathToString(absolutePath, defX, defY, startOffsetX, startOffs
4985
4984
  case 'M':
4986
4985
  // Use start marker offset
4987
4986
  if (useStartOffset) {
4988
- return "M ".concat(params[1] - defX + startOffsetX, ",").concat(params[2] - defY + startOffsetY, " L ").concat(params[1] - defX, ",").concat(params[2] - defY);
4987
+ return "M ".concat(params[1] + startOffsetX, ",").concat(params[2] + startOffsetY, " L ").concat(params[1], ",").concat(params[2]);
4989
4988
  }
4990
4989
  else {
4991
- return "M ".concat(params[1] - defX, ",").concat(params[2] - defY);
4990
+ return "M ".concat(params[1], ",").concat(params[2]);
4992
4991
  }
4993
4992
  case 'L':
4994
- return "L ".concat(params[1] - defX + (useEndOffset ? endOffsetX : 0), ",").concat(params[2] - defY + (useEndOffset ? endOffsetY : 0));
4993
+ return "L ".concat(params[1] + (useEndOffset ? endOffsetX : 0), ",").concat(params[2] + (useEndOffset ? endOffsetY : 0));
4995
4994
  case 'Q':
4996
- return ("Q ".concat(params[1] - defX, " ").concat(params[2] - defY, ",").concat(params[3] - defX, " ").concat(params[4] - defY) +
4995
+ return ("Q ".concat(params[1], " ").concat(params[2], ",").concat(params[3], " ").concat(params[4]) +
4997
4996
  (useEndOffset
4998
- ? " L ".concat(params[3] - defX + endOffsetX, ",").concat(params[4] - defY + endOffsetY)
4997
+ ? " L ".concat(params[3] + endOffsetX, ",").concat(params[4] + endOffsetY)
4999
4998
  : ''));
5000
4999
  case 'C':
5001
- return ("C ".concat(params[1] - defX, " ").concat(params[2] - defY, ",").concat(params[3] - defX, " ").concat(params[4] - defY, ",").concat(params[5] - defX, " ").concat(params[6] - defY) +
5000
+ return ("C ".concat(params[1], " ").concat(params[2], ",").concat(params[3], " ").concat(params[4], ",").concat(params[5], " ").concat(params[6]) +
5002
5001
  (useEndOffset
5003
- ? " L ".concat(params[5] - defX + endOffsetX, ",").concat(params[6] - defY + endOffsetY)
5002
+ ? " L ".concat(params[5] + endOffsetX, ",").concat(params[6] + endOffsetY)
5004
5003
  : ''));
5005
5004
  case 'A':
5006
- return ("A ".concat(params[1], " ").concat(params[2], " ").concat(params[3], " ").concat(params[4], " ").concat(params[5], " ").concat(params[6] - defX, " ").concat(params[7] - defY) +
5005
+ return ("A ".concat(params[1], " ").concat(params[2], " ").concat(params[3], " ").concat(params[4], " ").concat(params[5], " ").concat(params[6], " ").concat(params[7]) +
5007
5006
  (useEndOffset
5008
- ? " L ".concat(params[6] - defX + endOffsetX, ",").concat(params[7] - defY + endOffsetY)
5007
+ ? " L ".concat(params[6] + endOffsetX, ",").concat(params[7] + endOffsetY)
5009
5008
  : ''));
5010
5009
  case 'Z':
5011
5010
  return 'Z';
@@ -5135,12 +5134,8 @@ function parsePoints(pointsOrStr, object) {
5135
5134
  segments.push(segmentT);
5136
5135
  }
5137
5136
  });
5138
- var minX = Math.min.apply(Math, tslib.__spreadArray([], tslib.__read(points.map(function (point) { return point[0]; })), false));
5139
- var minY = Math.min.apply(Math, tslib.__spreadArray([], tslib.__read(points.map(function (point) { return point[1]; })), false));
5140
- if (object) {
5141
- object.parsedStyle.defX = minX;
5142
- object.parsedStyle.defY = minY;
5143
- }
5137
+ // const minX = Math.min(...points.map((point) => point[0]));
5138
+ // const minY = Math.min(...points.map((point) => point[1]));
5144
5139
  return {
5145
5140
  points: points,
5146
5141
  totalLength: totalLength,
@@ -6270,9 +6265,9 @@ var BUILT_IN_PROPERTIES = [
6270
6265
  n: 'anchor',
6271
6266
  p: 99,
6272
6267
  d: function (nodeName) {
6273
- if (nodeName === exports.Shape.CIRCLE || nodeName === exports.Shape.ELLIPSE) {
6274
- return '0.5 0.5';
6275
- }
6268
+ // if (nodeName === Shape.CIRCLE || nodeName === Shape.ELLIPSE) {
6269
+ // return '0.5 0.5';
6270
+ // }
6276
6271
  return '0 0';
6277
6272
  },
6278
6273
  l: true,
@@ -6677,7 +6672,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6677
6672
  // @ts-ignore
6678
6673
  if (attributes.points) {
6679
6674
  // @ts-ignore
6680
- object.parsedStyle.points = parsePoints(attributes.points, object);
6675
+ object.parsedStyle.points = parsePoints(attributes.points);
6681
6676
  }
6682
6677
  // Path
6683
6678
  // @ts-ignore
@@ -6689,8 +6684,6 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6689
6684
  object.parsedStyle.path = parsePath(
6690
6685
  // @ts-ignore
6691
6686
  attributes.path);
6692
- object.parsedStyle.defX = object.parsedStyle.path.rect.x;
6693
- object.parsedStyle.defY = object.parsedStyle.path.rect.y;
6694
6687
  }
6695
6688
  // Text
6696
6689
  if (attributes.textTransform) {
@@ -6738,42 +6731,6 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6738
6731
  // @ts-ignore
6739
6732
  attributes.markerMid, null, null);
6740
6733
  }
6741
- if (
6742
- // Circle & Ellipse
6743
- ((object.nodeName === exports.Shape.CIRCLE ||
6744
- object.nodeName === exports.Shape.ELLIPSE) &&
6745
- // @ts-ignore
6746
- (!util.isNil(attributes.cx) ||
6747
- // @ts-ignore
6748
- !util.isNil(attributes.cy))) ||
6749
- ((object.nodeName === exports.Shape.RECT ||
6750
- object.nodeName === exports.Shape.IMAGE ||
6751
- object.nodeName === exports.Shape.GROUP ||
6752
- object.nodeName === exports.Shape.HTML ||
6753
- object.nodeName === exports.Shape.TEXT ||
6754
- object.nodeName === exports.Shape.MESH) &&
6755
- // @ts-ignore
6756
- (!util.isNil(attributes.x) ||
6757
- // @ts-ignore
6758
- !util.isNil(attributes.y) ||
6759
- // @ts-ignore
6760
- !util.isNil(attributes.z))) ||
6761
- // Line
6762
- (object.nodeName === exports.Shape.LINE &&
6763
- // @ts-ignore
6764
- (!util.isNil(attributes.x1) ||
6765
- // @ts-ignore
6766
- !util.isNil(attributes.y1) ||
6767
- // @ts-ignore
6768
- !util.isNil(attributes.z1) ||
6769
- // @ts-ignore
6770
- !util.isNil(attributes.x2) ||
6771
- // @ts-ignore
6772
- !util.isNil(attributes.y2) ||
6773
- // @ts-ignore
6774
- !util.isNil(attributes.z2)))) {
6775
- this.runtime.CSSPropertySyntaxFactory['<coordinate>'].postProcessor(object, attributeNames_1);
6776
- }
6777
6734
  if (!util.isNil(attributes.zIndex)) {
6778
6735
  this.runtime.CSSPropertySyntaxFactory['<z-index>'].postProcessor(object, attributeNames_1);
6779
6736
  }
@@ -7052,12 +7009,12 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7052
7009
  geometry_1.renderBounds = new AABB();
7053
7010
  }
7054
7011
  var parsedStyle = object.parsedStyle;
7055
- var _a = geometryUpdater.update(parsedStyle, object), width = _a.width, height = _a.height, _b = _a.depth, depth = _b === void 0 ? 0 : _b, _c = _a.offsetX, offsetX = _c === void 0 ? 0 : _c, _d = _a.offsetY, offsetY = _d === void 0 ? 0 : _d, _e = _a.offsetZ, offsetZ = _e === void 0 ? 0 : _e;
7012
+ var _a = geometryUpdater.update(parsedStyle, object), cx = _a.cx, cy = _a.cy, _b = _a.cz, cz = _b === void 0 ? 0 : _b, hwidth = _a.hwidth, hheight = _a.hheight, _c = _a.hdepth, hdepth = _c === void 0 ? 0 : _c;
7056
7013
  // init with content box
7057
7014
  var halfExtents = [
7058
- Math.abs(width) / 2,
7059
- Math.abs(height) / 2,
7060
- depth / 2,
7015
+ Math.abs(hwidth),
7016
+ Math.abs(hheight),
7017
+ hdepth,
7061
7018
  ];
7062
7019
  // const halfExtents = vec3.set(
7063
7020
  // tmpVec3a,
@@ -7066,30 +7023,19 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7066
7023
  // depth / 2,
7067
7024
  // );
7068
7025
  // anchor is center by default, don't account for lineWidth here
7069
- var _f = parsedStyle, stroke = _f.stroke, lineWidth = _f.lineWidth,
7026
+ var _d = parsedStyle, stroke = _d.stroke, lineWidth = _d.lineWidth,
7070
7027
  // lineCap,
7071
7028
  // lineJoin,
7072
7029
  // miterLimit,
7073
- increasedLineWidthForHitTesting = _f.increasedLineWidthForHitTesting, shadowType = _f.shadowType, shadowColor = _f.shadowColor, _g = _f.filter, filter = _g === void 0 ? [] : _g, transformOrigin = _f.transformOrigin;
7074
- var anchor = parsedStyle.anchor;
7030
+ increasedLineWidthForHitTesting = _d.increasedLineWidthForHitTesting, shadowType = _d.shadowType, shadowColor = _d.shadowColor, _e = _d.filter, filter = _e === void 0 ? [] : _e, transformOrigin = _d.transformOrigin;
7031
+ // let anchor = parsedStyle.anchor;
7075
7032
  // <Text> use textAlign & textBaseline instead of anchor
7076
- if (nodeName === exports.Shape.TEXT) {
7077
- delete parsedStyle.anchor;
7078
- }
7079
- else if (nodeName === exports.Shape.MESH) {
7080
- parsedStyle.anchor[2] = 0.5;
7081
- }
7082
- var center = [
7083
- ((1 - ((anchor && anchor[0]) || 0) * 2) * width) / 2 + offsetX,
7084
- ((1 - ((anchor && anchor[1]) || 0) * 2) * height) / 2 + offsetY,
7085
- (1 - ((anchor && anchor[2]) || 0) * 2) * halfExtents[2] + offsetZ,
7086
- ];
7087
- // const center = vec3.set(
7088
- // tmpVec3b,
7089
- // ((1 - ((anchor && anchor[0]) || 0) * 2) * width) / 2 + offsetX,
7090
- // ((1 - ((anchor && anchor[1]) || 0) * 2) * height) / 2 + offsetY,
7091
- // (1 - ((anchor && anchor[2]) || 0) * 2) * halfExtents[2] + offsetZ,
7092
- // );
7033
+ // if (nodeName === Shape.TEXT) {
7034
+ // delete parsedStyle.anchor;
7035
+ // } else if (nodeName === Shape.MESH) {
7036
+ // parsedStyle.anchor[2] = 0.5;
7037
+ // }
7038
+ var center = [cx, cy, cz];
7093
7039
  // update geometry's AABB
7094
7040
  geometry_1.contentBounds.update(center, halfExtents);
7095
7041
  // @see https://github.molgen.mpg.de/git-mirror/cairo/blob/master/src/cairo-stroke-style.c#L97..L128
@@ -7122,8 +7068,8 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7122
7068
  geometry_1.renderBounds.update(center, halfExtents);
7123
7069
  // account for shadow, only support constant value now
7124
7070
  if (shadowColor && shadowType && shadowType !== 'inner') {
7125
- var _h = geometry_1.renderBounds, min = _h.min, max = _h.max;
7126
- var _j = parsedStyle, shadowBlur = _j.shadowBlur, shadowOffsetX = _j.shadowOffsetX, shadowOffsetY = _j.shadowOffsetY;
7071
+ var _f = geometry_1.renderBounds, min = _f.min, max = _f.max;
7072
+ var _g = parsedStyle, shadowBlur = _g.shadowBlur, shadowOffsetX = _g.shadowOffsetX, shadowOffsetY = _g.shadowOffsetY;
7127
7073
  var shadowBlurInPixels = shadowBlur || 0;
7128
7074
  var shadowOffsetXInPixels = shadowOffsetX || 0;
7129
7075
  var shadowOffsetYInPixels = shadowOffsetY || 0;
@@ -7160,12 +7106,11 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7160
7106
  geometry_1.renderBounds.setMinMax(min, max);
7161
7107
  }
7162
7108
  });
7163
- anchor = parsedStyle.anchor;
7164
7109
  // if (nodeName === Shape.RECT) {
7165
7110
  // account for negative width / height of Rect
7166
7111
  // @see https://github.com/antvis/g/issues/957
7167
- var flipY = width < 0;
7168
- var flipX = height < 0;
7112
+ var flipY = hwidth < 0;
7113
+ var flipX = hheight < 0;
7169
7114
  // } else {
7170
7115
  // }
7171
7116
  // set transform origin
@@ -7177,19 +7122,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7177
7122
  (transformOrigin
7178
7123
  ? convertPercentUnit(transformOrigin[1], 1, object)
7179
7124
  : 0);
7180
- usedOriginXValue =
7181
- usedOriginXValue -
7182
- (flipY ? -1 : 1) *
7183
- ((anchor && anchor[0]) || 0) *
7184
- geometry_1.contentBounds.halfExtents[0] *
7185
- 2;
7186
- usedOriginYValue =
7187
- usedOriginYValue -
7188
- (flipX ? -1 : 1) *
7189
- ((anchor && anchor[1]) || 0) *
7190
- geometry_1.contentBounds.halfExtents[1] *
7191
- 2;
7192
- object.setOrigin(usedOriginXValue, usedOriginYValue);
7125
+ object.setOrigin(cx - hwidth + usedOriginXValue, cy - hheight + usedOriginYValue);
7193
7126
  // FIXME setOrigin may have already dirtified to root.
7194
7127
  this.runtime.sceneGraphService.dirtifyToRoot(object);
7195
7128
  }
@@ -7411,177 +7344,6 @@ var CSSPropertyLengthOrPercentage14 = /** @class */ (function () {
7411
7344
  return CSSPropertyLengthOrPercentage14;
7412
7345
  }());
7413
7346
 
7414
- var tmpMat4 = glMatrix.mat4.create();
7415
- function parsedTransformToMat4(transform, object) {
7416
- var defX = object.parsedStyle.defX || 0;
7417
- var defY = object.parsedStyle.defY || 0;
7418
- // reset transform
7419
- object.resetLocalTransform();
7420
- object.setLocalPosition(defX, defY);
7421
- transform.forEach(function (parsed) {
7422
- var t = parsed.t, d = parsed.d;
7423
- if (t === 'scale') {
7424
- // scale(1) scale(1, 1)
7425
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1];
7426
- object.scaleLocal(newScale[0], newScale[1], 1);
7427
- }
7428
- else if (t === 'scalex') {
7429
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7430
- object.scaleLocal(newScale[0], 1, 1);
7431
- }
7432
- else if (t === 'scaley') {
7433
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7434
- object.scaleLocal(1, newScale[0], 1);
7435
- }
7436
- else if (t === 'scalez') {
7437
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7438
- object.scaleLocal(1, 1, newScale[0]);
7439
- }
7440
- else if (t === 'scale3d') {
7441
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1, 1];
7442
- object.scaleLocal(newScale[0], newScale[1], newScale[2]);
7443
- }
7444
- else if (t === 'translate') {
7445
- var newTranslation = d || [Opx, Opx];
7446
- object.translateLocal(newTranslation[0].value, newTranslation[1].value, 0);
7447
- }
7448
- else if (t === 'translatex') {
7449
- var newTranslation = d || [Opx];
7450
- object.translateLocal(newTranslation[0].value, 0, 0);
7451
- }
7452
- else if (t === 'translatey') {
7453
- var newTranslation = d || [Opx];
7454
- object.translateLocal(0, newTranslation[0].value, 0);
7455
- }
7456
- else if (t === 'translatez') {
7457
- var newTranslation = d || [Opx];
7458
- object.translateLocal(0, 0, newTranslation[0].value);
7459
- }
7460
- else if (t === 'translate3d') {
7461
- var newTranslation = d || [Opx, Opx, Opx];
7462
- object.translateLocal(newTranslation[0].value, newTranslation[1].value, newTranslation[2].value);
7463
- }
7464
- else if (t === 'rotate') {
7465
- var newAngles = d || [Odeg];
7466
- object.rotateLocal(0, 0, convertAngleUnit(newAngles[0]));
7467
- }
7468
- else if (t === 'rotatex') {
7469
- var newAngles = d || [Odeg];
7470
- object.rotateLocal(convertAngleUnit(newAngles[0]), 0, 0);
7471
- }
7472
- else if (t === 'rotatey') {
7473
- var newAngles = d || [Odeg];
7474
- object.rotateLocal(0, convertAngleUnit(newAngles[0]), 0);
7475
- }
7476
- else if (t === 'rotatez') {
7477
- var newAngles = d || [Odeg];
7478
- object.rotateLocal(0, 0, convertAngleUnit(newAngles[0]));
7479
- }
7480
- else if (t === 'rotate3d') ;
7481
- else if (t === 'skew') {
7482
- var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0, 0];
7483
- object.setLocalSkew(deg2rad(newSkew[0]), deg2rad(newSkew[1]));
7484
- }
7485
- else if (t === 'skewx') {
7486
- var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
7487
- object.setLocalSkew(deg2rad(newSkew[0]), object.getLocalSkew()[1]);
7488
- }
7489
- else if (t === 'skewy') {
7490
- var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
7491
- object.setLocalSkew(object.getLocalSkew()[0], deg2rad(newSkew[0]));
7492
- }
7493
- else if (t === 'matrix') {
7494
- var _a = tslib.__read(d.map(function (s) { return s.value; }), 6), a = _a[0], b = _a[1], c = _a[2], dd = _a[3], tx = _a[4], ty = _a[5];
7495
- object.setLocalTransform(glMatrix.mat4.set(tmpMat4, a, b, 0, 0, c, dd, 0, 0, 0, 0, 1, 0, tx + defX, ty + defY, 0, 1));
7496
- }
7497
- else if (t === 'matrix3d') {
7498
- // @ts-ignore
7499
- glMatrix.mat4.set.apply(glMatrix.mat4, tslib.__spreadArray([tmpMat4], tslib.__read(d.map(function (s) { return s.value; })), false));
7500
- tmpMat4[12] += defX;
7501
- tmpMat4[13] += defY;
7502
- object.setLocalTransform(tmpMat4);
7503
- }
7504
- });
7505
- return object.getLocalTransform();
7506
- }
7507
-
7508
- /**
7509
- * local position
7510
- */
7511
- var CSSPropertyLocalPosition = /** @class */ (function (_super) {
7512
- tslib.__extends(CSSPropertyLocalPosition, _super);
7513
- function CSSPropertyLocalPosition() {
7514
- return _super !== null && _super.apply(this, arguments) || this;
7515
- }
7516
- /**
7517
- * update local position
7518
- */
7519
- CSSPropertyLocalPosition.prototype.postProcessor = function (object, attributes) {
7520
- var x;
7521
- var y;
7522
- var z;
7523
- switch (object.nodeName) {
7524
- case exports.Shape.CIRCLE:
7525
- case exports.Shape.ELLIPSE:
7526
- var _a = object.parsedStyle, cx = _a.cx, cy = _a.cy, cz = _a.cz;
7527
- if (!util.isNil(cx)) {
7528
- x = cx;
7529
- }
7530
- if (!util.isNil(cy)) {
7531
- y = cy;
7532
- }
7533
- if (!util.isNil(cz)) {
7534
- z = cz;
7535
- }
7536
- break;
7537
- case exports.Shape.LINE:
7538
- var _b = object.parsedStyle, x1 = _b.x1, x2 = _b.x2, y1 = _b.y1, y2 = _b.y2;
7539
- var minX = Math.min(x1, x2);
7540
- var minY = Math.min(y1, y2);
7541
- x = minX;
7542
- y = minY;
7543
- z = 0;
7544
- break;
7545
- case exports.Shape.RECT:
7546
- case exports.Shape.IMAGE:
7547
- case exports.Shape.GROUP:
7548
- case exports.Shape.HTML:
7549
- case exports.Shape.TEXT:
7550
- case exports.Shape.MESH:
7551
- if (!util.isNil(object.parsedStyle.x)) {
7552
- x = object.parsedStyle.x;
7553
- }
7554
- if (!util.isNil(object.parsedStyle.y)) {
7555
- y = object.parsedStyle.y;
7556
- }
7557
- if (!util.isNil(object.parsedStyle.z)) {
7558
- z = object.parsedStyle.z;
7559
- }
7560
- break;
7561
- }
7562
- if (object.nodeName !== exports.Shape.PATH &&
7563
- object.nodeName !== exports.Shape.POLYLINE &&
7564
- object.nodeName !== exports.Shape.POLYGON) {
7565
- object.parsedStyle.defX = x || 0;
7566
- object.parsedStyle.defY = y || 0;
7567
- }
7568
- var needResetLocalPosition = !util.isNil(x) || !util.isNil(y) || !util.isNil(z);
7569
- // only if `transform` won't be processed later
7570
- if (needResetLocalPosition && attributes.indexOf('transform') === -1) {
7571
- // account for current transform if needed
7572
- var transform = object.parsedStyle.transform;
7573
- if (transform && transform.length) {
7574
- parsedTransformToMat4(transform, object);
7575
- }
7576
- else {
7577
- var _c = tslib.__read(object.getLocalPosition(), 3), ox = _c[0], oy = _c[1], oz = _c[2];
7578
- object.setLocalPosition(util.isNil(x) ? ox : x, util.isNil(y) ? oy : y, util.isNil(z) ? oz : z);
7579
- }
7580
- }
7581
- };
7582
- return CSSPropertyLocalPosition;
7583
- }(CSSPropertyLengthOrPercentage));
7584
-
7585
7347
  var CSSPropertyMarker = /** @class */ (function () {
7586
7348
  function CSSPropertyMarker() {
7587
7349
  }
@@ -7635,8 +7397,6 @@ var CSSPropertyOffsetDistance = /** @class */ (function () {
7635
7397
  // set position in world space
7636
7398
  var point = offsetPath.getPoint(offsetDistance);
7637
7399
  if (point) {
7638
- object.parsedStyle.defX = point.x;
7639
- object.parsedStyle.defY = point.y;
7640
7400
  object.setLocalPosition(point.x, point.y);
7641
7401
  }
7642
7402
  }
@@ -7685,18 +7445,6 @@ var CSSPropertyPath = /** @class */ (function () {
7685
7445
  }
7686
7446
  return parsed;
7687
7447
  };
7688
- /**
7689
- * update local position
7690
- */
7691
- CSSPropertyPath.prototype.postProcessor = function (object, attributes) {
7692
- object.parsedStyle.defX = object.parsedStyle.path.rect.x;
7693
- object.parsedStyle.defY = object.parsedStyle.path.rect.y;
7694
- if (object.nodeName === exports.Shape.PATH &&
7695
- attributes.indexOf('transform') === -1) {
7696
- var _a = object.parsedStyle, _b = _a.defX, defX = _b === void 0 ? 0 : _b, _c = _a.defY, defY = _c === void 0 ? 0 : _c;
7697
- object.setLocalPosition(defX, defY);
7698
- }
7699
- };
7700
7448
  return CSSPropertyPath;
7701
7449
  }());
7702
7450
 
@@ -7705,17 +7453,6 @@ var CSSPropertyPoints = /** @class */ (function () {
7705
7453
  this.parser = parsePoints;
7706
7454
  this.mixer = mergePoints;
7707
7455
  }
7708
- /**
7709
- * update local position
7710
- */
7711
- CSSPropertyPoints.prototype.postProcessor = function (object, attributes) {
7712
- if ((object.nodeName === exports.Shape.POLYGON ||
7713
- object.nodeName === exports.Shape.POLYLINE) &&
7714
- attributes.indexOf('transform') === -1) {
7715
- var _a = object.parsedStyle, defX = _a.defX, defY = _a.defY;
7716
- object.setLocalPosition(defX, defY);
7717
- }
7718
- };
7719
7456
  return CSSPropertyPoints;
7720
7457
  }());
7721
7458
 
@@ -8124,6 +7861,95 @@ function toFontString(attributes) {
8124
7861
  return "".concat(fontStyle, " ").concat(fontVariant, " ").concat(fontWeight, " ").concat(fontSizeString, " ").concat(fontFamilies.join(','));
8125
7862
  }
8126
7863
 
7864
+ var tmpMat4 = glMatrix.mat4.create();
7865
+ function parsedTransformToMat4(transform, object) {
7866
+ // reset transform
7867
+ object.resetLocalTransform();
7868
+ transform.forEach(function (parsed) {
7869
+ var t = parsed.t, d = parsed.d;
7870
+ if (t === 'scale') {
7871
+ // scale(1) scale(1, 1)
7872
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1];
7873
+ object.scaleLocal(newScale[0], newScale[1], 1);
7874
+ }
7875
+ else if (t === 'scalex') {
7876
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7877
+ object.scaleLocal(newScale[0], 1, 1);
7878
+ }
7879
+ else if (t === 'scaley') {
7880
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7881
+ object.scaleLocal(1, newScale[0], 1);
7882
+ }
7883
+ else if (t === 'scalez') {
7884
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7885
+ object.scaleLocal(1, 1, newScale[0]);
7886
+ }
7887
+ else if (t === 'scale3d') {
7888
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1, 1];
7889
+ object.scaleLocal(newScale[0], newScale[1], newScale[2]);
7890
+ }
7891
+ else if (t === 'translate') {
7892
+ var newTranslation = d || [Opx, Opx];
7893
+ object.translateLocal(newTranslation[0].value, newTranslation[1].value, 0);
7894
+ }
7895
+ else if (t === 'translatex') {
7896
+ var newTranslation = d || [Opx];
7897
+ object.translateLocal(newTranslation[0].value, 0, 0);
7898
+ }
7899
+ else if (t === 'translatey') {
7900
+ var newTranslation = d || [Opx];
7901
+ object.translateLocal(0, newTranslation[0].value, 0);
7902
+ }
7903
+ else if (t === 'translatez') {
7904
+ var newTranslation = d || [Opx];
7905
+ object.translateLocal(0, 0, newTranslation[0].value);
7906
+ }
7907
+ else if (t === 'translate3d') {
7908
+ var newTranslation = d || [Opx, Opx, Opx];
7909
+ object.translateLocal(newTranslation[0].value, newTranslation[1].value, newTranslation[2].value);
7910
+ }
7911
+ else if (t === 'rotate') {
7912
+ var newAngles = d || [Odeg];
7913
+ object.rotateLocal(0, 0, convertAngleUnit(newAngles[0]));
7914
+ }
7915
+ else if (t === 'rotatex') {
7916
+ var newAngles = d || [Odeg];
7917
+ object.rotateLocal(convertAngleUnit(newAngles[0]), 0, 0);
7918
+ }
7919
+ else if (t === 'rotatey') {
7920
+ var newAngles = d || [Odeg];
7921
+ object.rotateLocal(0, convertAngleUnit(newAngles[0]), 0);
7922
+ }
7923
+ else if (t === 'rotatez') {
7924
+ var newAngles = d || [Odeg];
7925
+ object.rotateLocal(0, 0, convertAngleUnit(newAngles[0]));
7926
+ }
7927
+ else if (t === 'rotate3d') ;
7928
+ else if (t === 'skew') {
7929
+ var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0, 0];
7930
+ object.setLocalSkew(deg2rad(newSkew[0]), deg2rad(newSkew[1]));
7931
+ }
7932
+ else if (t === 'skewx') {
7933
+ var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
7934
+ object.setLocalSkew(deg2rad(newSkew[0]), object.getLocalSkew()[1]);
7935
+ }
7936
+ else if (t === 'skewy') {
7937
+ var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
7938
+ object.setLocalSkew(object.getLocalSkew()[0], deg2rad(newSkew[0]));
7939
+ }
7940
+ else if (t === 'matrix') {
7941
+ var _a = tslib.__read(d.map(function (s) { return s.value; }), 6), a = _a[0], b = _a[1], c = _a[2], dd = _a[3], tx = _a[4], ty = _a[5];
7942
+ object.setLocalTransform(glMatrix.mat4.set(tmpMat4, a, b, 0, 0, c, dd, 0, 0, 0, 0, 1, 0, tx, ty, 0, 1));
7943
+ }
7944
+ else if (t === 'matrix3d') {
7945
+ // @ts-ignore
7946
+ glMatrix.mat4.set.apply(glMatrix.mat4, tslib.__spreadArray([tmpMat4], tslib.__read(d.map(function (s) { return s.value; })), false));
7947
+ object.setLocalTransform(tmpMat4);
7948
+ }
7949
+ });
7950
+ return object.getLocalTransform();
7951
+ }
7952
+
8127
7953
  /**
8128
7954
  * @see /zh/docs/api/animation#支持变换的属性
8129
7955
  *
@@ -8228,12 +8054,12 @@ var CircleUpdater = /** @class */ (function () {
8228
8054
  function CircleUpdater() {
8229
8055
  }
8230
8056
  CircleUpdater.prototype.update = function (parsedStyle, object) {
8231
- var r = parsedStyle.r;
8232
- var width = r * 2;
8233
- var height = r * 2;
8057
+ var cx = parsedStyle.cx, cy = parsedStyle.cy, r = parsedStyle.r;
8234
8058
  return {
8235
- width: width,
8236
- height: height,
8059
+ cx: cx,
8060
+ cy: cy,
8061
+ hwidth: r,
8062
+ hheight: r,
8237
8063
  };
8238
8064
  };
8239
8065
  return CircleUpdater;
@@ -8243,12 +8069,12 @@ var EllipseUpdater = /** @class */ (function () {
8243
8069
  function EllipseUpdater() {
8244
8070
  }
8245
8071
  EllipseUpdater.prototype.update = function (parsedStyle, object) {
8246
- var rx = parsedStyle.rx, ry = parsedStyle.ry;
8247
- var width = rx * 2;
8248
- var height = ry * 2;
8072
+ var cx = parsedStyle.cx, cy = parsedStyle.cy, rx = parsedStyle.rx, ry = parsedStyle.ry;
8249
8073
  return {
8250
- width: width,
8251
- height: height,
8074
+ cx: cx,
8075
+ cy: cy,
8076
+ hwidth: rx,
8077
+ hheight: ry,
8252
8078
  };
8253
8079
  };
8254
8080
  return EllipseUpdater;
@@ -8265,9 +8091,13 @@ var LineUpdater = /** @class */ (function () {
8265
8091
  var maxY = Math.max(y1, y2);
8266
8092
  var width = maxX - minX;
8267
8093
  var height = maxY - minY;
8094
+ var hwidth = width / 2;
8095
+ var hheight = height / 2;
8268
8096
  return {
8269
- width: width,
8270
- height: height,
8097
+ cx: minX + hwidth,
8098
+ cy: minY + hheight,
8099
+ hwidth: hwidth,
8100
+ hheight: hheight,
8271
8101
  };
8272
8102
  };
8273
8103
  return LineUpdater;
@@ -8278,10 +8108,14 @@ var PathUpdater = /** @class */ (function () {
8278
8108
  }
8279
8109
  PathUpdater.prototype.update = function (parsedStyle) {
8280
8110
  var path = parsedStyle.path;
8281
- var _a = path.rect, width = _a.width, height = _a.height;
8111
+ var _a = path.rect, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
8112
+ var hwidth = width / 2;
8113
+ var hheight = height / 2;
8282
8114
  return {
8283
- width: width,
8284
- height: height,
8115
+ cx: x + hwidth,
8116
+ cy: y + hheight,
8117
+ hwidth: hwidth,
8118
+ hheight: hheight,
8285
8119
  };
8286
8120
  };
8287
8121
  return PathUpdater;
@@ -8300,14 +8134,20 @@ var PolylineUpdater = /** @class */ (function () {
8300
8134
  var maxY = Math.max.apply(Math, tslib.__spreadArray([], tslib.__read(points.map(function (point) { return point[1]; })), false));
8301
8135
  var width = maxX - minX;
8302
8136
  var height = maxY - minY;
8137
+ var hwidth = width / 2;
8138
+ var hheight = height / 2;
8303
8139
  return {
8304
- width: width,
8305
- height: height,
8140
+ cx: minX + hwidth,
8141
+ cy: minY + hheight,
8142
+ hwidth: hwidth,
8143
+ hheight: hheight,
8306
8144
  };
8307
8145
  }
8308
8146
  return {
8309
- width: 0,
8310
- height: 0,
8147
+ cx: 0,
8148
+ cy: 0,
8149
+ hwidth: 0,
8150
+ hheight: 0,
8311
8151
  };
8312
8152
  };
8313
8153
  return PolylineUpdater;
@@ -8317,7 +8157,7 @@ var RectUpdater = /** @class */ (function () {
8317
8157
  function RectUpdater() {
8318
8158
  }
8319
8159
  RectUpdater.prototype.update = function (parsedStyle, object) {
8320
- var img = parsedStyle.img, _a = parsedStyle.width, width = _a === void 0 ? 0 : _a, _b = parsedStyle.height, height = _b === void 0 ? 0 : _b;
8160
+ var x = parsedStyle.x, y = parsedStyle.y, img = parsedStyle.img, _a = parsedStyle.width, width = _a === void 0 ? 0 : _a, _b = parsedStyle.height, height = _b === void 0 ? 0 : _b;
8321
8161
  var contentWidth = width;
8322
8162
  var contentHeight = height;
8323
8163
  // resize with HTMLImageElement's size
@@ -8332,8 +8172,10 @@ var RectUpdater = /** @class */ (function () {
8332
8172
  }
8333
8173
  }
8334
8174
  return {
8335
- width: contentWidth,
8336
- height: contentHeight,
8175
+ cx: x + contentWidth / 2,
8176
+ cy: y + contentHeight / 2,
8177
+ hwidth: contentWidth / 2,
8178
+ hheight: contentHeight / 2,
8337
8179
  };
8338
8180
  };
8339
8181
  return RectUpdater;
@@ -8356,7 +8198,7 @@ var TextUpdater = /** @class */ (function () {
8356
8198
  };
8357
8199
  TextUpdater.prototype.update = function (parsedStyle, object) {
8358
8200
  var _a, _b;
8359
- var text = parsedStyle.text, textAlign = parsedStyle.textAlign, lineWidth = parsedStyle.lineWidth, textBaseline = parsedStyle.textBaseline, dx = parsedStyle.dx, dy = parsedStyle.dy;
8201
+ var text = parsedStyle.text, textAlign = parsedStyle.textAlign, lineWidth = parsedStyle.lineWidth, textBaseline = parsedStyle.textBaseline, dx = parsedStyle.dx, dy = parsedStyle.dy, x = parsedStyle.x, y = parsedStyle.y;
8360
8202
  if (!this.isReadyToMeasure(parsedStyle, object)) {
8361
8203
  parsedStyle.metrics = {
8362
8204
  font: '',
@@ -8374,47 +8216,42 @@ var TextUpdater = /** @class */ (function () {
8374
8216
  lineMetrics: [],
8375
8217
  };
8376
8218
  return {
8377
- width: 0,
8378
- height: 0,
8379
- x: 0,
8380
- y: 0,
8381
- offsetX: 0,
8382
- offsetY: 0,
8219
+ hwidth: 0,
8220
+ hheight: 0,
8221
+ cx: 0,
8222
+ cy: 0,
8383
8223
  };
8384
8224
  }
8385
8225
  var offscreenCanvas = (((_b = (_a = object === null || object === void 0 ? void 0 : object.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.getConfig()) || {}).offscreenCanvas;
8386
8226
  var metrics = this.globalRuntime.textService.measureText(text, parsedStyle, offscreenCanvas);
8387
8227
  parsedStyle.metrics = metrics;
8388
8228
  var width = metrics.width, height = metrics.height, lineHeight = metrics.lineHeight, fontProperties = metrics.fontProperties;
8389
- // anchor is left-top by default
8390
- var halfExtents = [width / 2, height / 2, 0];
8229
+ var hwidth = width / 2;
8230
+ var hheight = height / 2;
8391
8231
  // default 'left'
8392
- var anchor = [0, 1];
8393
- var lineXOffset = 0;
8232
+ var lineXOffset = x + hwidth;
8394
8233
  if (textAlign === 'center' || textAlign === 'middle') {
8395
- lineXOffset = lineWidth / 2;
8396
- anchor = [0.5, 1];
8234
+ lineXOffset += lineWidth / 2 - hwidth;
8397
8235
  }
8398
8236
  else if (textAlign === 'right' || textAlign === 'end') {
8399
- lineXOffset = lineWidth;
8400
- anchor = [1, 1];
8237
+ lineXOffset += lineWidth - hwidth * 2;
8401
8238
  }
8402
- var lineYOffset = 0;
8239
+ var lineYOffset = y - hheight;
8403
8240
  if (textBaseline === 'middle') {
8404
8241
  // eslint-disable-next-line prefer-destructuring
8405
- lineYOffset = halfExtents[1];
8242
+ lineYOffset += hheight;
8406
8243
  }
8407
8244
  else if (textBaseline === 'top' || textBaseline === 'hanging') {
8408
- lineYOffset = halfExtents[1] * 2;
8245
+ lineYOffset += hheight * 2;
8409
8246
  }
8410
8247
  else if (textBaseline === 'alphabetic') {
8411
8248
  // prevent calling getImageData for ascent metrics
8412
- lineYOffset = this.globalRuntime.enableCSSParsing
8249
+ lineYOffset += this.globalRuntime.enableCSSParsing
8413
8250
  ? lineHeight - fontProperties.ascent
8414
8251
  : 0;
8415
8252
  }
8416
8253
  else if (textBaseline === 'bottom' || textBaseline === 'ideographic') {
8417
- lineYOffset = 0;
8254
+ lineYOffset += 0;
8418
8255
  }
8419
8256
  // TODO: ideographic & bottom
8420
8257
  if (dx) {
@@ -8423,13 +8260,11 @@ var TextUpdater = /** @class */ (function () {
8423
8260
  if (dy) {
8424
8261
  lineYOffset += dy;
8425
8262
  }
8426
- // update anchor
8427
- parsedStyle.anchor = [anchor[0], anchor[1], 0];
8428
8263
  return {
8429
- width: halfExtents[0] * 2,
8430
- height: halfExtents[1] * 2,
8431
- offsetX: lineXOffset,
8432
- offsetY: lineYOffset,
8264
+ cx: lineXOffset,
8265
+ cy: lineYOffset,
8266
+ hwidth: hwidth,
8267
+ hheight: hheight,
8433
8268
  };
8434
8269
  };
8435
8270
  return TextUpdater;
@@ -11704,7 +11539,7 @@ var CSSPropertySyntaxFactory = (function () {
11704
11539
  _a[exports.PropertySyntax.LENGTH_PERCENTAGE] = length,
11705
11540
  _a[exports.PropertySyntax.LENGTH_PERCENTAGE_12] = new CSSPropertyLengthOrPercentage12(),
11706
11541
  _a[exports.PropertySyntax.LENGTH_PERCENTAGE_14] = new CSSPropertyLengthOrPercentage14(),
11707
- _a[exports.PropertySyntax.COORDINATE] = new CSSPropertyLocalPosition(),
11542
+ _a[exports.PropertySyntax.COORDINATE] = new CSSPropertyLengthOrPercentage(),
11708
11543
  _a[exports.PropertySyntax.OFFSET_DISTANCE] = new CSSPropertyOffsetDistance(),
11709
11544
  _a[exports.PropertySyntax.OPACITY_VALUE] = new CSSPropertyOpacity(),
11710
11545
  _a[exports.PropertySyntax.PATH] = new CSSPropertyPath(),
@@ -12000,8 +11835,11 @@ var Element = /** @class */ (function (_super) {
12000
11835
  if ((_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) {
12001
11836
  this.ownerDocument.defaultView.mountChildren(child);
12002
11837
  }
12003
- insertedEvent.relatedNode = this;
12004
- child.dispatchEvent(insertedEvent);
11838
+ // @ts-ignore
11839
+ if (child.isMutationObserved) {
11840
+ insertedEvent.relatedNode = this;
11841
+ child.dispatchEvent(insertedEvent);
11842
+ }
12005
11843
  return child;
12006
11844
  };
12007
11845
  Element.prototype.insertBefore = function (newChild, refChild) {
@@ -12428,7 +12266,6 @@ var DATASET_PREFIX = 'data-';
12428
12266
  var DisplayObject = /** @class */ (function (_super) {
12429
12267
  tslib.__extends(DisplayObject, _super);
12430
12268
  function DisplayObject(config) {
12431
- var _a;
12432
12269
  var _this = _super.call(this) || this;
12433
12270
  _this.isCustomElement = false;
12434
12271
  _this.isMutationObserved = false;
@@ -12447,7 +12284,7 @@ var DisplayObject = /** @class */ (function (_super) {
12447
12284
  // eg. group.get('name')
12448
12285
  _this.config = config;
12449
12286
  // compatible with G 3.0
12450
- _this.config.interactive = (_a = _this.config.capture) !== null && _a !== void 0 ? _a : _this.config.interactive;
12287
+ // this.config.interactive = this.config.capture ?? this.config.interactive;
12451
12288
  // init scene graph node
12452
12289
  _this.id = _this.config.id || '';
12453
12290
  _this.name = _this.config.name || '';
@@ -12455,23 +12292,23 @@ var DisplayObject = /** @class */ (function (_super) {
12455
12292
  _this.className = _this.config.className || _this.config.class;
12456
12293
  }
12457
12294
  _this.nodeName = _this.config.type || exports.Shape.GROUP;
12458
- // compatible with G 3.0
12459
- _this.config.style =
12460
- _this.config.style || _this.config.attrs || {};
12461
- Object.assign(_this.config.style, _this.config.attrs);
12462
- // this.config.style = {
12463
- // // ...DEFAULT_STYLE_PROPS,
12464
- // ...this.config.style,
12465
- // ...this.config.attrs,
12466
- // };
12467
- if (_this.config.visible != null) {
12468
- _this.config.style.visibility =
12469
- _this.config.visible === false ? 'hidden' : 'visible';
12470
- }
12471
- if (_this.config.interactive != null) {
12472
- _this.config.style.pointerEvents =
12473
- _this.config.interactive === false ? 'none' : 'auto';
12474
- }
12295
+ // // compatible with G 3.0
12296
+ // this.config.style =
12297
+ // this.config.style || this.config.attrs || ({} as StyleProps);
12298
+ // // Object.assign(this.config.style, this.config.attrs);
12299
+ // // this.config.style = {
12300
+ // // // ...DEFAULT_STYLE_PROPS,
12301
+ // // ...this.config.style,
12302
+ // // ...this.config.attrs,
12303
+ // // };
12304
+ // if (this.config.visible != null) {
12305
+ // this.config.style.visibility =
12306
+ // this.config.visible === false ? 'hidden' : 'visible';
12307
+ // }
12308
+ // if (this.config.interactive != null) {
12309
+ // this.config.style.pointerEvents =
12310
+ // this.config.interactive === false ? 'none' : 'auto';
12311
+ // }
12475
12312
  // merge parsed value
12476
12313
  Object.assign(_this.parsedStyle, runtime.enableCSSParsing
12477
12314
  ? DEFAULT_PARSED_STYLE_PROPS
@@ -13223,12 +13060,16 @@ var CSS = {
13223
13060
 
13224
13061
  var Circle = /** @class */ (function (_super) {
13225
13062
  tslib.__extends(Circle, _super);
13063
+ // constructor(options: DisplayObjectConfig<CircleStyleProps> = {}) {
13064
+ // super(options);
13065
+ // this.nodeName = Shape.CIRCLE;
13066
+ // }
13226
13067
  function Circle(_a) {
13227
13068
  if (_a === void 0) { _a = {}; }
13228
13069
  var style = _a.style, rest = tslib.__rest(_a, ["style"]);
13229
13070
  return _super.call(this, tslib.__assign({ type: exports.Shape.CIRCLE, style: runtime.enableCSSParsing
13230
13071
  ? tslib.__assign({ cx: '', cy: '', r: '' }, style) : tslib.__assign({}, style), initialParsedStyle: {
13231
- anchor: [0.5, 0.5],
13072
+ // anchor: [0.5, 0.5],
13232
13073
  transformOrigin: runtime.enableCSSParsing
13233
13074
  ? null
13234
13075
  : [PECENTAGE_50, PECENTAGE_50],
@@ -13266,7 +13107,7 @@ var Ellipse = /** @class */ (function (_super) {
13266
13107
  var style = _a.style, rest = tslib.__rest(_a, ["style"]);
13267
13108
  return _super.call(this, tslib.__assign({ type: exports.Shape.ELLIPSE, style: runtime.enableCSSParsing
13268
13109
  ? tslib.__assign({ cx: '', cy: '', rx: '', ry: '' }, style) : tslib.__assign({}, style), initialParsedStyle: {
13269
- anchor: [0.5, 0.5],
13110
+ // anchor: [0.5, 0.5],
13270
13111
  transformOrigin: runtime.enableCSSParsing
13271
13112
  ? null
13272
13113
  : [PECENTAGE_50, PECENTAGE_50],
@@ -13436,7 +13277,7 @@ var Line = /** @class */ (function (_super) {
13436
13277
  }
13437
13278
  };
13438
13279
  Line.prototype.transformMarker = function (isStart) {
13439
- var _a = this.parsedStyle, markerStart = _a.markerStart, markerEnd = _a.markerEnd, markerStartOffset = _a.markerStartOffset, markerEndOffset = _a.markerEndOffset, x1 = _a.x1, x2 = _a.x2, y1 = _a.y1, y2 = _a.y2, defX = _a.defX, defY = _a.defY;
13280
+ var _a = this.parsedStyle, markerStart = _a.markerStart, markerEnd = _a.markerEnd, markerStartOffset = _a.markerStartOffset, markerEndOffset = _a.markerEndOffset, x1 = _a.x1, x2 = _a.x2, y1 = _a.y1, y2 = _a.y2;
13440
13281
  var marker = isStart ? markerStart : markerEnd;
13441
13282
  if (!marker || !isDisplayObject(marker)) {
13442
13283
  return;
@@ -13449,16 +13290,16 @@ var Line = /** @class */ (function (_super) {
13449
13290
  var offset;
13450
13291
  var originalAngle;
13451
13292
  if (isStart) {
13452
- ox = x1 - defX;
13453
- oy = y1 - defY;
13293
+ ox = x1;
13294
+ oy = y1;
13454
13295
  x = x2 - x1;
13455
13296
  y = y2 - y1;
13456
13297
  offset = markerStartOffset || 0;
13457
13298
  originalAngle = this.markerStartAngle;
13458
13299
  }
13459
13300
  else {
13460
- ox = x2 - defX;
13461
- oy = y2 - defY;
13301
+ ox = x2;
13302
+ oy = y2;
13462
13303
  x = x1 - x2;
13463
13304
  y = y1 - y2;
13464
13305
  offset = markerEndOffset || 0;
@@ -13472,9 +13313,9 @@ var Line = /** @class */ (function (_super) {
13472
13313
  Line.prototype.getPoint = function (ratio, inWorldSpace) {
13473
13314
  if (inWorldSpace === void 0) { inWorldSpace = false; }
13474
13315
  // TODO: account for z1/z2 in 3D line
13475
- var _a = this.parsedStyle, x1 = _a.x1, y1 = _a.y1, x2 = _a.x2, y2 = _a.y2, defX = _a.defX, defY = _a.defY;
13316
+ var _a = this.parsedStyle, x1 = _a.x1, y1 = _a.y1, x2 = _a.x2, y2 = _a.y2;
13476
13317
  var _b = gMath.linePointAt(x1, y1, x2, y2, ratio), x = _b.x, y = _b.y;
13477
- var transformed = glMatrix.vec3.transformMat4(glMatrix.vec3.create(), glMatrix.vec3.fromValues(x - defX, y - defY, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13318
+ var transformed = glMatrix.vec3.transformMat4(glMatrix.vec3.create(), glMatrix.vec3.fromValues(x, y, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13478
13319
  // apply local transformation
13479
13320
  return new Point(transformed[0], transformed[1]);
13480
13321
  };
@@ -13565,7 +13406,7 @@ var Path = /** @class */ (function (_super) {
13565
13406
  }
13566
13407
  };
13567
13408
  Path.prototype.transformMarker = function (isStart) {
13568
- var _a = this.parsedStyle, markerStart = _a.markerStart, markerEnd = _a.markerEnd, markerStartOffset = _a.markerStartOffset, markerEndOffset = _a.markerEndOffset, defX = _a.defX, defY = _a.defY;
13409
+ var _a = this.parsedStyle, markerStart = _a.markerStart, markerEnd = _a.markerEnd, markerStartOffset = _a.markerStartOffset, markerEndOffset = _a.markerEndOffset;
13569
13410
  var marker = isStart ? markerStart : markerEnd;
13570
13411
  if (!marker || !isDisplayObject(marker)) {
13571
13412
  return;
@@ -13579,8 +13420,8 @@ var Path = /** @class */ (function (_super) {
13579
13420
  var originalAngle;
13580
13421
  if (isStart) {
13581
13422
  var _b = tslib.__read(this.getStartTangent(), 2), p1 = _b[0], p2 = _b[1];
13582
- ox = p2[0] - defX;
13583
- oy = p2[1] - defY;
13423
+ ox = p2[0];
13424
+ oy = p2[1];
13584
13425
  x = p1[0] - p2[0];
13585
13426
  y = p1[1] - p2[1];
13586
13427
  offset = markerStartOffset || 0;
@@ -13588,8 +13429,8 @@ var Path = /** @class */ (function (_super) {
13588
13429
  }
13589
13430
  else {
13590
13431
  var _c = tslib.__read(this.getEndTangent(), 2), p1 = _c[0], p2 = _c[1];
13591
- ox = p2[0] - defX;
13592
- oy = p2[1] - defY;
13432
+ ox = p2[0];
13433
+ oy = p2[1];
13593
13434
  x = p1[0] - p2[0];
13594
13435
  y = p1[1] - p2[1];
13595
13436
  offset = markerEndOffset || 0;
@@ -13601,18 +13442,18 @@ var Path = /** @class */ (function (_super) {
13601
13442
  marker.setLocalPosition(ox + Math.cos(rad) * offset, oy + Math.sin(rad) * offset);
13602
13443
  };
13603
13444
  Path.prototype.placeMarkerMid = function (marker) {
13604
- var _a = this.parsedStyle, segments = _a.path.segments, defX = _a.defX, defY = _a.defY;
13445
+ var segments = this.parsedStyle.path.segments;
13605
13446
  // clear all existed markers
13606
13447
  this.markerMidList.forEach(function (marker) {
13607
13448
  marker.remove();
13608
13449
  });
13609
13450
  if (marker && isDisplayObject(marker)) {
13610
13451
  for (var i = 1; i < segments.length - 1; i++) {
13611
- var _b = tslib.__read(segments[i].currentPoint, 2), ox = _b[0], oy = _b[1];
13452
+ var _a = tslib.__read(segments[i].currentPoint, 2), ox = _a[0], oy = _a[1];
13612
13453
  var cloned = i === 1 ? marker : marker.cloneNode(true);
13613
13454
  this.markerMidList.push(cloned);
13614
13455
  this.appendChild(cloned);
13615
- cloned.setLocalPosition(ox - defX, oy - defY);
13456
+ cloned.setLocalPosition(ox, oy);
13616
13457
  // TODO: orient of marker
13617
13458
  }
13618
13459
  }
@@ -13630,9 +13471,9 @@ var Path = /** @class */ (function (_super) {
13630
13471
  */
13631
13472
  Path.prototype.getPointAtLength = function (distance, inWorldSpace) {
13632
13473
  if (inWorldSpace === void 0) { inWorldSpace = false; }
13633
- var _a = this.parsedStyle, defX = _a.defX, defY = _a.defY, absolutePath = _a.path.absolutePath;
13634
- var _b = util.getPointAtLength(absolutePath, distance), x = _b.x, y = _b.y;
13635
- var transformed = glMatrix.vec3.transformMat4(glMatrix.vec3.create(), glMatrix.vec3.fromValues(x - defX, y - defY, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13474
+ var absolutePath = this.parsedStyle.path.absolutePath;
13475
+ var _a = util.getPointAtLength(absolutePath, distance), x = _a.x, y = _a.y;
13476
+ var transformed = glMatrix.vec3.transformMat4(glMatrix.vec3.create(), glMatrix.vec3.fromValues(x, y, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13636
13477
  // apply local transformation
13637
13478
  return new Point(transformed[0], transformed[1]);
13638
13479
  };
@@ -13771,7 +13612,7 @@ var Polygon = /** @class */ (function (_super) {
13771
13612
  }
13772
13613
  };
13773
13614
  Polygon.prototype.transformMarker = function (isStart) {
13774
- var _a = this.parsedStyle, markerStart = _a.markerStart, markerEnd = _a.markerEnd, markerStartOffset = _a.markerStartOffset, markerEndOffset = _a.markerEndOffset, P = _a.points, defX = _a.defX, defY = _a.defY;
13615
+ var _a = this.parsedStyle, markerStart = _a.markerStart, markerEnd = _a.markerEnd, markerStartOffset = _a.markerStartOffset, markerEndOffset = _a.markerEndOffset, P = _a.points;
13775
13616
  var points = (P || {}).points;
13776
13617
  var marker = isStart ? markerStart : markerEnd;
13777
13618
  if (!marker || !isDisplayObject(marker) || !points) {
@@ -13784,8 +13625,8 @@ var Polygon = /** @class */ (function (_super) {
13784
13625
  var oy;
13785
13626
  var offset;
13786
13627
  var originalAngle;
13787
- ox = points[0][0] - defX;
13788
- oy = points[0][1] - defY;
13628
+ ox = points[0][0];
13629
+ oy = points[0][1];
13789
13630
  if (isStart) {
13790
13631
  x = points[1][0] - points[0][0];
13791
13632
  y = points[1][1] - points[0][1];
@@ -13795,8 +13636,8 @@ var Polygon = /** @class */ (function (_super) {
13795
13636
  else {
13796
13637
  var length_1 = points.length;
13797
13638
  if (!this.parsedStyle.isClosed) {
13798
- ox = points[length_1 - 1][0] - defX;
13799
- oy = points[length_1 - 1][1] - defY;
13639
+ ox = points[length_1 - 1][0];
13640
+ oy = points[length_1 - 1][1];
13800
13641
  x = points[length_1 - 2][0] - points[length_1 - 1][0];
13801
13642
  y = points[length_1 - 2][1] - points[length_1 - 1][1];
13802
13643
  }
@@ -13813,7 +13654,7 @@ var Polygon = /** @class */ (function (_super) {
13813
13654
  marker.setLocalPosition(ox + Math.cos(rad) * offset, oy + Math.sin(rad) * offset);
13814
13655
  };
13815
13656
  Polygon.prototype.placeMarkerMid = function (marker) {
13816
- var _a = this.parsedStyle, P = _a.points, defX = _a.defX, defY = _a.defY;
13657
+ var P = this.parsedStyle.points;
13817
13658
  var points = (P || {}).points;
13818
13659
  // clear all existed markers
13819
13660
  this.markerMidList.forEach(function (marker) {
@@ -13822,8 +13663,8 @@ var Polygon = /** @class */ (function (_super) {
13822
13663
  this.markerMidList = [];
13823
13664
  if (marker && isDisplayObject(marker) && points) {
13824
13665
  for (var i = 1; i < (this.parsedStyle.isClosed ? points.length : points.length - 1); i++) {
13825
- var ox = points[i][0] - defX;
13826
- var oy = points[i][1] - defY;
13666
+ var ox = points[i][0];
13667
+ var oy = points[i][1];
13827
13668
  var cloned = i === 1 ? marker : marker.cloneNode(true);
13828
13669
  this.markerMidList.push(cloned);
13829
13670
  this.appendChild(cloned);
@@ -13865,7 +13706,7 @@ var Polyline = /** @class */ (function (_super) {
13865
13706
  };
13866
13707
  Polyline.prototype.getPoint = function (ratio, inWorldSpace) {
13867
13708
  if (inWorldSpace === void 0) { inWorldSpace = false; }
13868
- var _a = this.parsedStyle, defX = _a.defX, defY = _a.defY, _b = _a.points, points = _b.points, segments = _b.segments;
13709
+ var _a = this.parsedStyle.points, points = _a.points, segments = _a.segments;
13869
13710
  var subt = 0;
13870
13711
  var index = 0;
13871
13712
  segments.forEach(function (v, i) {
@@ -13874,8 +13715,8 @@ var Polyline = /** @class */ (function (_super) {
13874
13715
  index = i;
13875
13716
  }
13876
13717
  });
13877
- var _c = gMath.linePointAt(points[index][0], points[index][1], points[index + 1][0], points[index + 1][1], subt), x = _c.x, y = _c.y;
13878
- var transformed = glMatrix.vec3.transformMat4(glMatrix.vec3.create(), glMatrix.vec3.fromValues(x - defX, y - defY, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13718
+ 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;
13719
+ var transformed = glMatrix.vec3.transformMat4(glMatrix.vec3.create(), glMatrix.vec3.fromValues(x, y, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13879
13720
  // apply local transformation
13880
13721
  return new Point(transformed[0], transformed[1]);
13881
13722
  };