@visactor/vrender 0.21.0-alpha.4 → 0.21.0-alpha.5

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
@@ -3919,6 +3919,7 @@
3919
3919
  const DefaultTextStyle = {
3920
3920
  text: "",
3921
3921
  maxLineWidth: 1 / 0,
3922
+ maxWidth: 1 / 0,
3922
3923
  textAlign: "left",
3923
3924
  textBaseline: "alphabetic",
3924
3925
  fontSize: 16,
@@ -3996,7 +3997,8 @@
3996
3997
  globalZIndex: 1,
3997
3998
  globalCompositeOperation: "",
3998
3999
  overflow: "hidden",
3999
- shadowPickMode: "graphic"
4000
+ shadowPickMode: "graphic",
4001
+ keepStrokeScale: !1
4000
4002
  }, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
4001
4003
  function addAttributeToPrototype(obj, c, keys) {
4002
4004
  keys.forEach(key => {
@@ -4271,10 +4273,32 @@
4271
4273
  configure(service, env) {
4272
4274
  this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
4273
4275
  }
4274
- measureTextWidth(text, options) {
4275
- if (!this.context) return this.estimate(text, options).width;
4276
+ _measureTextWithoutAlignBaseline(text, options, compatible) {
4276
4277
  this.context.setTextStyleWithoutAlignBaseline(options);
4277
- return this.context.measureText(text).width;
4278
+ const metrics = this.context.measureText(text);
4279
+ return compatible ? this.compatibleMetrics(metrics, options) : metrics;
4280
+ }
4281
+ _measureTextWithAlignBaseline(text, options, compatible) {
4282
+ this.context.setTextStyle(options);
4283
+ const metrics = this.context.measureText(text);
4284
+ return compatible ? this.compatibleMetrics(metrics, options) : metrics;
4285
+ }
4286
+ compatibleMetrics(metrics, options) {
4287
+ if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
4288
+ const {
4289
+ ascent: ascent,
4290
+ descent: descent
4291
+ } = this.measureTextBoundADscentEstimate(options);
4292
+ metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
4293
+ }
4294
+ if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
4295
+ const {
4296
+ left: left,
4297
+ right: right
4298
+ } = this.measureTextBoundLeftRightEstimate(options);
4299
+ metrics.actualBoundingBoxLeft = left, metrics.actualBoundingBoxRight = right;
4300
+ }
4301
+ return metrics;
4278
4302
  }
4279
4303
  estimate(text, _ref) {
4280
4304
  let {
@@ -4288,19 +4312,85 @@
4288
4312
  height: fontSize
4289
4313
  };
4290
4314
  }
4291
- measureTextPixelHeight(text, options) {
4315
+ measureTextWidth(text, options, textMeasure) {
4316
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
4317
+ }
4318
+ measureTextBoundsWidth(text, options, textMeasure) {
4319
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
4320
+ }
4321
+ measureTextBoundsLeftRight(text, options, textMeasure) {
4322
+ return this.context ? {
4323
+ left: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxLeft,
4324
+ right: textMeasure.actualBoundingBoxRight
4325
+ } : this.measureTextBoundLeftRightEstimate(options);
4326
+ }
4327
+ measureTextPixelHeight(text, options, textMeasure) {
4292
4328
  var _a;
4293
- if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
4294
- this.context.setTextStyleWithoutAlignBaseline(options);
4295
- const textMeasure = this.context.measureText(text);
4296
- return Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent);
4329
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options, !0), Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent)) : null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
4297
4330
  }
4298
- measureTextBoundHieght(text, options) {
4331
+ measureTextPixelADscent(text, options, textMeasure) {
4332
+ return this.context ? {
4333
+ ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxAscent,
4334
+ descent: textMeasure.actualBoundingBoxDescent
4335
+ } : this.measureTextBoundADscentEstimate(options);
4336
+ }
4337
+ measureTextBoundHieght(text, options, textMeasure) {
4299
4338
  var _a;
4300
- if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
4301
- this.context.setTextStyleWithoutAlignBaseline(options);
4302
- const textMeasure = this.context.measureText(text);
4303
- return Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent);
4339
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options, !0), Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent)) : null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
4340
+ }
4341
+ measureTextBoundADscent(text, options, textMeasure) {
4342
+ return this.context ? {
4343
+ ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).fontBoundingBoxAscent,
4344
+ descent: textMeasure.fontBoundingBoxDescent
4345
+ } : this.measureTextBoundADscentEstimate(options);
4346
+ }
4347
+ measureTextBoundADscentEstimate(options) {
4348
+ var _a;
4349
+ const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
4350
+ {
4351
+ textBaseline: textBaseline
4352
+ } = options;
4353
+ return "bottom" === textBaseline ? {
4354
+ ascent: fontSize,
4355
+ descent: 0
4356
+ } : "middle" === textBaseline ? {
4357
+ ascent: fontSize / 2,
4358
+ descent: fontSize / 2
4359
+ } : "alphabetic" === textBaseline ? {
4360
+ ascent: .79 * fontSize,
4361
+ descent: .21 * fontSize
4362
+ } : {
4363
+ ascent: 0,
4364
+ descent: fontSize
4365
+ };
4366
+ }
4367
+ measureTextBoundLeftRightEstimate(options) {
4368
+ var _a;
4369
+ const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
4370
+ {
4371
+ textAlign: textAlign
4372
+ } = options;
4373
+ return "center" === textAlign ? {
4374
+ left: fontSize / 2,
4375
+ right: fontSize / 2
4376
+ } : "right" === textAlign || "end" === textAlign ? {
4377
+ left: fontSize,
4378
+ right: 0
4379
+ } : {
4380
+ left: 0,
4381
+ right: fontSize
4382
+ };
4383
+ }
4384
+ measureTextPixelADscentAndWidth(text, options) {
4385
+ if (!this.context) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
4386
+ width: this.estimate(text, options).width
4387
+ });
4388
+ const out = this._measureTextWithoutAlignBaseline(text, options, !0);
4389
+ return {
4390
+ ascent: out.actualBoundingBoxAscent,
4391
+ descent: out.actualBoundingBoxDescent,
4392
+ width: out.width
4393
+ };
4304
4394
  }
4305
4395
  measureText(text, options) {
4306
4396
  return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
@@ -6412,7 +6502,7 @@
6412
6502
  }
6413
6503
  }
6414
6504
 
6415
- class DefaultTicker {
6505
+ class DefaultTicker extends EventEmitter {
6416
6506
  set mode(m) {
6417
6507
  this._mode !== m && (this._mode = m, this.setupTickHandler());
6418
6508
  }
@@ -6421,17 +6511,17 @@
6421
6511
  }
6422
6512
  constructor() {
6423
6513
  let timelines = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
6424
- this.handleTick = (handler, params) => {
6514
+ super(), this.handleTick = (handler, params) => {
6425
6515
  const {
6426
6516
  once = !1
6427
6517
  } = null != params ? params : {};
6428
- this.ifCanStop() ? this.stop() : (this._handlerTick(handler), once || handler.tick(this.interval, this.handleTick));
6429
- }, this._handlerTick = handler => {
6518
+ this.ifCanStop() ? this.stop() : (this._handlerTick(), once || handler.tick(this.interval, this.handleTick));
6519
+ }, this._handlerTick = () => {
6430
6520
  const time = this.tickerHandler.getTime();
6431
6521
  let delta = 0;
6432
6522
  this.lastFrameTime >= 0 && (delta = time - this.lastFrameTime), this.lastFrameTime = time, this.status === STATUS$1.RUNNING && (this.tickCounts++, this.timelines.forEach(t => {
6433
6523
  t.tick(delta);
6434
- }));
6524
+ }), this.emit("afterTick"));
6435
6525
  }, this.init(), this.lastFrameTime = -1, this.tickCounts = 0, this.timelines = timelines, this.autoStop = !0;
6436
6526
  }
6437
6527
  init() {
@@ -6527,6 +6617,9 @@
6527
6617
  stop() {
6528
6618
  this.status = STATUS$1.INITIAL, this.setupTickHandler(), this.lastFrameTime = -1;
6529
6619
  }
6620
+ trySyncTickStatus() {
6621
+ this.status === STATUS$1.RUNNING && this._handlerTick();
6622
+ }
6530
6623
  }
6531
6624
 
6532
6625
  class ManualTickHandler {
@@ -7668,7 +7761,7 @@
7668
7761
  lastMatchedIndex = i, lastMatchedPoint = tagMap.get(this.toPoints[i].context);
7669
7762
  break;
7670
7763
  }
7671
- "clip" === this.newPointAnimateType && 0 !== this.toPoints.length && (Number.isFinite(lastMatchedIndex) ? (this.clipRange = this.toPoints[lastMatchedIndex][this.clipRangeByDimension] / this.toPoints[this.toPoints.length - 1][this.clipRangeByDimension], isValidNumber$1(this.clipRange) ? this.clipRange = clamp$1(this.clipRange, 0, 1) : this.clipRange = 0) : this.clipRange = 0);
7764
+ "clip" === this.newPointAnimateType && 0 !== this.toPoints.length && (Number.isFinite(lastMatchedIndex) ? (this.clipRange = this.toPoints[lastMatchedIndex][this.clipRangeByDimension] / this.toPoints[this.toPoints.length - 1][this.clipRangeByDimension], 1 === this.clipRange && (this.shrinkClipRange = this.toPoints[lastMatchedIndex][this.clipRangeByDimension] / this.fromPoints[this.fromPoints.length - 1][this.clipRangeByDimension]), isValidNumber$1(this.clipRange) ? this.clipRange = clamp$1(this.clipRange, 0, 1) : this.clipRange = 0) : this.clipRange = 0);
7672
7765
  let prevMatchedPoint = this.toPoints[0];
7673
7766
  this.interpolatePoints = this.toPoints.map((point, index) => {
7674
7767
  const matchedPoint = tagMap.get(point.context);
@@ -7680,11 +7773,19 @@
7680
7773
  return newPoint.defined = toPoint.defined, newPoint.context = toPoint.context, newPoint;
7681
7774
  });
7682
7775
  }
7776
+ onFirstRun() {
7777
+ const lastClipRange = this.target.attribute.clipRange;
7778
+ isValidNumber$1(lastClipRange * this.clipRange) && (this.clipRange *= lastClipRange);
7779
+ }
7683
7780
  onUpdate(end, ratio, out) {
7684
7781
  if (this.points = this.points.map((point, index) => {
7685
7782
  const newPoint = pointInterpolation(this.interpolatePoints[index][0], this.interpolatePoints[index][1], ratio);
7686
7783
  return newPoint.context = point.context, newPoint;
7687
- }), this.clipRange && (out.clipRange = this.clipRange + (1 - this.clipRange) * ratio), this.segmentsCache && this.to.segments) {
7784
+ }), this.clipRange) {
7785
+ if (this.shrinkClipRange) return void (end ? (out.points = this.toPoints, out.clipRange = 1) : (out.points = this.fromPoints, out.clipRange = this.clipRange - (this.clipRange - this.shrinkClipRange) * ratio));
7786
+ out.clipRange = this.clipRange + (1 - this.clipRange) * ratio;
7787
+ }
7788
+ if (this.segmentsCache && this.to.segments) {
7688
7789
  let start = 0;
7689
7790
  out.segments = this.to.segments.map((segment, index) => {
7690
7791
  const end = start + this.segmentsCache[index],
@@ -9100,7 +9201,7 @@
9100
9201
  }
9101
9202
  static GetFile(url, type) {
9102
9203
  let data = ResourceLoader.cache.get(url);
9103
- return data ? "fail" === data.loadState ? Promise.reject() : "init" === data.loadState || "loading" === data.loadState ? data.dataPromise.then(data => data.data) : Promise.resolve(data.data) : (data = {
9204
+ return data ? "init" === data.loadState || "fail" === data.loadState ? Promise.reject() : "loading" === data.loadState ? data.dataPromise.then(data => data.data) : Promise.resolve(data.data) : (data = {
9104
9205
  type: type,
9105
9206
  loadState: "init"
9106
9207
  }, ResourceLoader.cache.set(url, data), "arrayBuffer" === type ? data.dataPromise = application.global.loadArrayBuffer(url) : "blob" === type ? data.dataPromise = application.global.loadBlob(url) : "json" === type && (data.dataPromise = application.global.loadJson(url)), data.dataPromise.then(data => data.data));
@@ -12038,7 +12139,8 @@
12038
12139
  x: originX = arcAttribute.x,
12039
12140
  y: originY = arcAttribute.y,
12040
12141
  scaleX = arcAttribute.scaleX,
12041
- scaleY = arcAttribute.scaleY
12142
+ scaleY = arcAttribute.scaleY,
12143
+ keepStrokeScale = arcAttribute.keepStrokeScale
12042
12144
  } = arc.attribute;
12043
12145
  let {
12044
12146
  innerRadius = arcAttribute.innerRadius,
@@ -12050,7 +12152,7 @@
12050
12152
  {
12051
12153
  distance = arcAttribute[key].distance
12052
12154
  } = borderStyle,
12053
- d = getScaledStroke(context, distance, context.dpr),
12155
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
12054
12156
  deltaAngle = distance / outerRadius,
12055
12157
  sign = "outerBorder" === key ? 1 : -1;
12056
12158
  if (arc.setAttributes({
@@ -12095,14 +12197,15 @@
12095
12197
  x: originX = circleAttribute.x,
12096
12198
  y: originY = circleAttribute.y,
12097
12199
  scaleX = circleAttribute.scaleX,
12098
- scaleY = circleAttribute.scaleY
12200
+ scaleY = circleAttribute.scaleY,
12201
+ keepStrokeScale = circleAttribute.keepStrokeScale
12099
12202
  } = circle.attribute,
12100
12203
  renderBorder = (borderStyle, key) => {
12101
12204
  const doStroke = !(!borderStyle || !borderStyle.stroke),
12102
12205
  {
12103
12206
  distance = circleAttribute[key].distance
12104
12207
  } = borderStyle,
12105
- d = getScaledStroke(context, distance, context.dpr),
12208
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
12106
12209
  sign = "outerBorder" === key ? 1 : -1;
12107
12210
  if (context.beginPath(), context.arc(x, y, radius + sign * d, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), strokeCb) strokeCb(context, borderStyle, circleAttribute[key]);else if (doStroke) {
12108
12211
  const lastOpacity = circleAttribute[key].opacity;
@@ -12221,7 +12324,8 @@
12221
12324
  scaleX = rectAttribute.scaleX,
12222
12325
  scaleY = rectAttribute.scaleY,
12223
12326
  x1: x1,
12224
- y1: y1
12327
+ y1: y1,
12328
+ keepStrokeScale = rectAttribute.keepStrokeScale
12225
12329
  } = rect.attribute;
12226
12330
  let {
12227
12331
  width: width,
@@ -12234,7 +12338,7 @@
12234
12338
  {
12235
12339
  distance = rectAttribute[key].distance
12236
12340
  } = borderStyle,
12237
- d = getScaledStroke(context, distance, context.dpr),
12341
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
12238
12342
  nextX = x + sign * d,
12239
12343
  nextY = y + sign * d,
12240
12344
  dw = 2 * d;
@@ -12364,9 +12468,8 @@
12364
12468
  constructor() {
12365
12469
  super(...arguments), this.time = exports.BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
12366
12470
  }
12367
- drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
12368
- if (!(image.isGifImage && image.renderFrame && image.playing)) return super.drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
12369
- image.renderFrame(context, x, y);
12471
+ drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
12472
+ return super.drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
12370
12473
  }
12371
12474
  }
12372
12475
  const defaultImageRenderContribution = new DefaultImageRenderContribution();
@@ -12392,14 +12495,15 @@
12392
12495
  x: originX = symbolAttribute.x,
12393
12496
  y: originY = symbolAttribute.y,
12394
12497
  scaleX = symbolAttribute.scaleX,
12395
- scaleY = symbolAttribute.scaleY
12498
+ scaleY = symbolAttribute.scaleY,
12499
+ keepStrokeScale = symbolAttribute.keepStrokeScale
12396
12500
  } = symbol.attribute,
12397
12501
  renderBorder = (borderStyle, key) => {
12398
12502
  const doStroke = !(!borderStyle || !borderStyle.stroke),
12399
12503
  {
12400
12504
  distance = symbolAttribute[key].distance
12401
12505
  } = borderStyle,
12402
- d = getScaledStroke(context, distance, context.dpr),
12506
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
12403
12507
  sign = "outerBorder" === key ? 1 : -1;
12404
12508
  if (context.beginPath(), !1 === parsedPath.drawOffset(context, size, x, y, sign * d) && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), strokeCb) strokeCb(context, borderStyle, symbolAttribute[key]);else if (doStroke) {
12405
12509
  const lastOpacity = symbolAttribute[key].opacity;
@@ -13677,16 +13781,8 @@
13677
13781
  verticalMode = textAttribute.verticalMode,
13678
13782
  x: originX = textAttribute.x,
13679
13783
  y: originY = textAttribute.y
13680
- } = text.attribute;
13681
- let {
13682
- textAlign = textAttribute.textAlign,
13683
- textBaseline = textAttribute.textBaseline
13684
- } = text.attribute;
13685
- if (!verticalMode && "vertical" === direction) {
13686
- const t = textAlign;
13687
- textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
13688
- }
13689
- const lineHeight = null !== (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize,
13784
+ } = text.attribute,
13785
+ lineHeight = null !== (_a = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _a ? _a : fontSize,
13690
13786
  data = this.valid(text, textAttribute, fillCb, strokeCb);
13691
13787
  if (!data) return;
13692
13788
  const {
@@ -13706,79 +13802,60 @@
13706
13802
  const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);
13707
13803
  matrix.rotateByCenter(Math.PI / 2, _x, _y), context.transformFromMatrix(matrix, !0), matrixAllocate.free(matrix);
13708
13804
  }
13709
- doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.fillText(t, _x, _y, z), this.drawUnderLine(underline, lineThrough, text, _x, _y, z, textAttribute, context))), direction && (context.highPerformanceRestore(), context.setTransformForCurrent());
13805
+ doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.fillText(t, _x, _y, z))), direction && (context.highPerformanceRestore(), context.setTransformForCurrent());
13710
13806
  };
13711
- if (text.isMultiLine) {
13712
- if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
13713
- const {
13714
- multilineLayout: multilineLayout
13715
- } = text;
13716
- if (!multilineLayout) return void context.highPerformanceRestore();
13717
- const {
13718
- xOffset: xOffset,
13719
- yOffset: yOffset
13720
- } = multilineLayout.bbox;
13721
- doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
13722
- context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
13723
- }))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
13724
- context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z), this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y - textDrawOffsetY("bottom", fontSize) - .05 * fontSize, z, textAttribute, context, {
13725
- width: line.width
13726
- });
13727
- })));
13728
- } else {
13729
- text.tryUpdateAABBBounds();
13730
- const cache = text.cache,
13731
- {
13732
- verticalList: verticalList
13733
- } = cache;
13734
- context.textAlign = "left", context.textBaseline = "top";
13735
- const totalHeight = lineHeight * verticalList.length;
13736
- let totalW = 0;
13737
- verticalList.forEach(verticalData => {
13738
- const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
13739
- totalW = max(_w, totalW);
13740
- });
13741
- let offsetY = 0,
13742
- offsetX = 0;
13743
- "bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
13744
- const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
13745
- dw = totalW - currentW;
13746
- let currentOffsetY = offsetY;
13747
- "center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
13748
- const {
13749
- text: text,
13750
- width: width,
13751
- direction: direction
13752
- } = item;
13753
- drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
13754
- });
13807
+ if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
13808
+ const {
13809
+ multilineLayout: multilineLayout
13810
+ } = text;
13811
+ if (!multilineLayout) return void context.highPerformanceRestore();
13812
+ const {
13813
+ xOffset: xOffset,
13814
+ yOffset: yOffset
13815
+ } = multilineLayout.bbox;
13816
+ doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
13817
+ context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
13818
+ }))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
13819
+ context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z), this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, line.descent, (line.descent - line.ascent) / 2, z, textAttribute, context, {
13820
+ width: line.width
13755
13821
  });
13756
- }
13757
- } else if ("horizontal" === direction) {
13758
- context.setTextStyle(text.attribute, textAttribute, z);
13759
- const t = text.clipedText;
13760
- let dy = 0;
13761
- lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)), drawText(t, 0, dy, 0);
13822
+ })));
13762
13823
  } else {
13824
+ let {
13825
+ textAlign = textAttribute.textAlign,
13826
+ textBaseline = textAttribute.textBaseline
13827
+ } = text.attribute;
13828
+ if (!verticalMode) {
13829
+ const t = textAlign;
13830
+ textAlign = null !== (_b = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = text.getAlignMapBaseline()[t]) && void 0 !== _c ? _c : "top";
13831
+ }
13763
13832
  text.tryUpdateAABBBounds();
13764
- const cache = text.cache;
13765
- if (cache) {
13766
- context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
13767
- const {
13833
+ const cache = text.cache,
13834
+ {
13768
13835
  verticalList: verticalList
13769
13836
  } = cache;
13770
- let offsetY = 0;
13771
- const totalW = verticalList[0].reduce((a, b) => a + (b.width || 0), 0);
13772
- let offsetX = 0;
13773
- "bottom" === textBaseline ? offsetX = -lineHeight : "middle" === textBaseline && (offsetX = -lineHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), context.textAlign = "left", context.textBaseline = "top", verticalList[0].forEach(item => {
13837
+ context.textAlign = "left", context.textBaseline = "top";
13838
+ const totalHeight = lineHeight * verticalList.length;
13839
+ let totalW = 0;
13840
+ verticalList.forEach(verticalData => {
13841
+ const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
13842
+ totalW = max(_w, totalW);
13843
+ });
13844
+ let offsetY = 0,
13845
+ offsetX = 0;
13846
+ "bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
13847
+ const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
13848
+ dw = totalW - currentW;
13849
+ let currentOffsetY = offsetY;
13850
+ "center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
13774
13851
  const {
13775
13852
  text: text,
13776
13853
  width: width,
13777
13854
  direction: direction
13778
13855
  } = item;
13779
- drawText(text, offsetX, offsetY, direction), offsetY += width;
13856
+ drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
13780
13857
  });
13781
- }
13858
+ });
13782
13859
  }
13783
13860
  transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context), this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
13784
13861
  }
@@ -13790,12 +13867,10 @@
13790
13867
  computed3dMatrix = !keepDirIn3d;
13791
13868
  this._draw(text, textAttribute, computed3dMatrix, drawContext, params);
13792
13869
  }
13793
- drawUnderLine(underline, lineThrough, text, x, y, z, textAttribute, context, multiOption) {
13870
+ drawUnderLine(underline, lineThrough, text, anchorX, anchorY, offsetUnderLineY, offsetThroughLineY, z, textAttribute, context, multiOption) {
13794
13871
  if (lineThrough + underline <= 0) return;
13795
13872
  const {
13796
13873
  textAlign = textAttribute.textAlign,
13797
- textBaseline = textAttribute.textBaseline,
13798
- fontSize = textAttribute.fontSize,
13799
13874
  fill = textAttribute.fill,
13800
13875
  opacity = textAttribute.opacity,
13801
13876
  underlineOffset = textAttribute.underlineOffset,
@@ -13805,23 +13880,21 @@
13805
13880
  isMulti = !isNil$1(multiOption),
13806
13881
  w = isMulti ? multiOption.width : text.clipedWidth,
13807
13882
  offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w),
13808
- offsetY = textLayoutOffsetY(isMulti ? "alphabetic" : textBaseline, fontSize, fontSize),
13809
13883
  attribute = {
13810
13884
  lineWidth: 0,
13811
13885
  stroke: fill,
13812
13886
  opacity: opacity,
13813
13887
  strokeOpacity: fillOpacity
13814
13888
  };
13815
- let deltaY = isMulti ? -3 : 0;
13816
13889
  if (underline) {
13817
- attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, x, y, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
13818
- const dy = y + offsetY + fontSize + underlineOffset + deltaY;
13819
- context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
13890
+ attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
13891
+ const dy = anchorY + offsetUnderLineY + underlineOffset;
13892
+ context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
13820
13893
  }
13821
- if (isMulti && (deltaY = -1), lineThrough) {
13822
- attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, x, y, textAttribute), context.beginPath();
13823
- const dy = y + offsetY + fontSize / 2 + deltaY;
13824
- context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
13894
+ if (lineThrough) {
13895
+ attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), context.beginPath();
13896
+ const dy = anchorY + offsetThroughLineY;
13897
+ context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
13825
13898
  }
13826
13899
  }
13827
13900
  };
@@ -14116,12 +14189,10 @@
14116
14189
  const {
14117
14190
  image: url
14118
14191
  } = image.attribute;
14119
- if (!image.isGifImage) {
14120
- if (!url || !image.resources) return;
14121
- const res = image.resources.get(url);
14122
- if ("loading" === res.state && isString$1(url)) return void ResourceLoader.improveImageLoading(url);
14123
- if ("success" !== res.state) return;
14124
- }
14192
+ if (!url || !image.resources) return;
14193
+ const res = image.resources.get(url);
14194
+ if ("loading" === res.state && isString$1(url)) return void ResourceLoader.improveImageLoading(url);
14195
+ if ("success" !== res.state) return;
14125
14196
  const {
14126
14197
  context: context
14127
14198
  } = renderService.drawParams;
@@ -14513,28 +14584,6 @@
14513
14584
  }
14514
14585
  return bbox.yOffset = "top" === textBaseline ? 0 : "middle" === textBaseline ? bbox.height / -2 : "alphabetic" === textBaseline ? -.79 * bbox.height : -bbox.height, bbox;
14515
14586
  }
14516
- GetLayout(str, width, height, textAlign, textBaseline, lineHeight, suffix, wordBreak, suffixPosition) {
14517
- const linesLayout = [],
14518
- bboxWH = [width, height],
14519
- bboxOffset = [0, 0];
14520
- for (; str.length > 0;) {
14521
- const {
14522
- str: clipText
14523
- } = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
14524
- linesLayout.push({
14525
- str: clipText,
14526
- width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
14527
- }), str = str.substring(clipText.length);
14528
- }
14529
- "left" === textAlign || "start" === textAlign || ("center" === textAlign ? bboxOffset[0] = bboxWH[0] / -2 : "right" !== textAlign && "end" !== textAlign || (bboxOffset[0] = -bboxWH[0])), "top" === textBaseline || ("middle" === textBaseline ? bboxOffset[1] = bboxWH[1] / -2 : "bottom" === textBaseline && (bboxOffset[1] = -bboxWH[1]));
14530
- const bbox = {
14531
- xOffset: bboxOffset[0],
14532
- yOffset: bboxOffset[1],
14533
- width: bboxWH[0],
14534
- height: bboxWH[1]
14535
- };
14536
- return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
14537
- }
14538
14587
  GetLayoutByLines(lines, textAlign, textBaseline, lineHeight) {
14539
14588
  let suffix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
14540
14589
  let wordBreak = arguments.length > 5 ? arguments[5] : undefined;
@@ -14545,18 +14594,29 @@
14545
14594
  bboxWH = [0, 0];
14546
14595
  if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
14547
14596
  let width;
14548
- for (let i = 0, len = lines.length; i < len; i++) width = Math.min(this.textMeasure.measureTextWidth(lines[i], this.textOptions), lineWidth), linesLayout.push({
14549
- str: this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
14550
- width: width
14551
- });
14597
+ for (let i = 0, len = lines.length; i < len; i++) {
14598
+ const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions);
14599
+ width = Math.min(metrics.width, lineWidth), linesLayout.push({
14600
+ str: metrics.width <= lineWidth ? lines[i].toString() : this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
14601
+ width: width,
14602
+ ascent: metrics.ascent,
14603
+ descent: metrics.descent
14604
+ });
14605
+ }
14552
14606
  bboxWH[0] = lineWidth;
14553
14607
  } else {
14554
14608
  let width, text;
14555
14609
  lineWidth = 0;
14556
- for (let i = 0, len = lines.length; i < len; i++) text = lines[i], width = this.textMeasure.measureTextWidth(text, this.textOptions), lineWidth = Math.max(lineWidth, width), linesLayout.push({
14557
- str: text,
14558
- width: width
14559
- });
14610
+ for (let i = 0, len = lines.length; i < len; i++) {
14611
+ text = lines[i];
14612
+ const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions);
14613
+ width = metrics.width, lineWidth = Math.max(lineWidth, width), linesLayout.push({
14614
+ str: text,
14615
+ width: width,
14616
+ ascent: metrics.ascent,
14617
+ descent: metrics.descent
14618
+ });
14619
+ }
14560
14620
  bboxWH[0] = lineWidth;
14561
14621
  }
14562
14622
  bboxWH[1] = linesLayout.length * lineHeight, bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);
@@ -14585,11 +14645,11 @@
14585
14645
  };
14586
14646
  }
14587
14647
  lineOffset(bbox, line, textAlign, textBaseline, lineHeight, origin) {
14588
- return "left" === textAlign || "start" === textAlign ? line.leftOffset = 0 : "center" === textAlign ? line.leftOffset = (bbox.width - line.width) / 2 : "right" !== textAlign && "end" !== textAlign || (line.leftOffset = bbox.width - line.width), line.topOffset = (lineHeight - this.textOptions.fontSize) / 2 + .79 * this.textOptions.fontSize + origin[1], origin[1] += lineHeight, line;
14648
+ return "left" === textAlign || "start" === textAlign ? line.leftOffset = 0 : "center" === textAlign ? line.leftOffset = (bbox.width - line.width) / 2 : "right" !== textAlign && "end" !== textAlign || (line.leftOffset = bbox.width - line.width), line.topOffset = lineHeight / 2 + (line.ascent - line.descent) / 2 + origin[1], origin[1] += lineHeight, line;
14589
14649
  }
14590
14650
  }
14591
14651
 
14592
- const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
14652
+ const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "maxWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
14593
14653
  class Text extends Graphic {
14594
14654
  get font() {
14595
14655
  const textTheme = this.getGraphicTheme();
@@ -14598,26 +14658,22 @@
14598
14658
  get clipedText() {
14599
14659
  var _a;
14600
14660
  const attribute = this.attribute,
14601
- textTheme = this.getGraphicTheme();
14602
- if (!this.isSimplify()) return;
14603
- const {
14604
- maxLineWidth = textTheme.maxLineWidth
14605
- } = attribute;
14606
- return Number.isFinite(maxLineWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
14661
+ textTheme = this.getGraphicTheme(),
14662
+ maxWidth = this.getMaxWidth(textTheme);
14663
+ return Number.isFinite(maxWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
14607
14664
  }
14608
14665
  get clipedWidth() {
14609
- if (this.isSimplify()) return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
14666
+ return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
14610
14667
  }
14611
14668
  get cliped() {
14612
14669
  var _a, _b;
14613
14670
  const textTheme = this.getGraphicTheme(),
14614
14671
  attribute = this.attribute,
14615
- {
14616
- maxLineWidth = textTheme.maxLineWidth,
14617
- text: text,
14618
- whiteSpace = textTheme.whiteSpace
14619
- } = attribute;
14620
- if (!Number.isFinite(maxLineWidth)) return !1;
14672
+ maxWidth = this.getMaxWidth(textTheme);
14673
+ if (!Number.isFinite(maxWidth)) return !1;
14674
+ const {
14675
+ text: text
14676
+ } = this.attribute;
14621
14677
  if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
14622
14678
  let mergedText = "";
14623
14679
  this.cache.layoutData.lines.forEach(item => {
@@ -14628,10 +14684,7 @@
14628
14684
  return "vertical" === attribute.direction && this.cache.verticalList && this.cache.verticalList[0] ? this.cache.verticalList[0].map(item => item.text).join("") !== attribute.text.toString() : null != this.clipedText && this.clipedText !== attribute.text.toString();
14629
14685
  }
14630
14686
  get multilineLayout() {
14631
- if (this.isMultiLine) return this.tryUpdateAABBBounds(), this.cache.layoutData;
14632
- }
14633
- isSimplify() {
14634
- return !this.isMultiLine && "vertical" !== this.attribute.direction;
14687
+ return this.tryUpdateAABBBounds(), this.cache.layoutData;
14635
14688
  }
14636
14689
  get isMultiLine() {
14637
14690
  return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
@@ -14704,8 +14757,62 @@
14704
14757
  }
14705
14758
  return application.graphicService.combindShadowAABBBounds(aabbBounds, this), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds), transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix), aabbBounds;
14706
14759
  }
14760
+ updateSingallineAABBBounds(text) {
14761
+ this.updateMultilineAABBBounds([text]);
14762
+ const layoutData = this.cache.layoutData;
14763
+ if (layoutData) {
14764
+ const line = layoutData.lines[0];
14765
+ this.cache.clipedText = line.str, this.cache.clipedWidth = line.width;
14766
+ }
14767
+ return this._AABBBounds;
14768
+ }
14769
+ updateMultilineAABBBounds(text) {
14770
+ const textTheme = this.getGraphicTheme(),
14771
+ {
14772
+ direction = textTheme.direction,
14773
+ underlineOffset = textTheme.underlineOffset
14774
+ } = this.attribute,
14775
+ b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
14776
+ return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
14777
+ }
14778
+ updateHorizontalMultilineAABBBounds(text) {
14779
+ var _a;
14780
+ const textTheme = this.getGraphicTheme(),
14781
+ attribute = this.attribute,
14782
+ {
14783
+ fontFamily = textTheme.fontFamily,
14784
+ textAlign = textTheme.textAlign,
14785
+ textBaseline = textTheme.textBaseline,
14786
+ fontSize = textTheme.fontSize,
14787
+ fontWeight = textTheme.fontWeight,
14788
+ ellipsis = textTheme.ellipsis,
14789
+ maxLineWidth: maxLineWidth,
14790
+ stroke = textTheme.stroke,
14791
+ wrap = textTheme.wrap,
14792
+ ignoreBuf = textTheme.ignoreBuf,
14793
+ lineWidth = textTheme.lineWidth,
14794
+ whiteSpace = textTheme.whiteSpace,
14795
+ suffixPosition = textTheme.suffixPosition
14796
+ } = attribute,
14797
+ lineHeight = this.getLineHeight(attribute, textTheme);
14798
+ if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
14799
+ if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
14800
+ const bbox = this.cache.layoutData.bbox;
14801
+ return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14802
+ }
14803
+ const textMeasure = application.graphicUtil.textMeasure,
14804
+ layoutData = new CanvasTextLayout(fontFamily, {
14805
+ fontSize: fontSize,
14806
+ fontWeight: fontWeight,
14807
+ fontFamily: fontFamily
14808
+ }, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
14809
+ {
14810
+ bbox: bbox
14811
+ } = layoutData;
14812
+ return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14813
+ }
14707
14814
  updateWrapAABBBounds(text) {
14708
- var _a, _b, _c, _d;
14815
+ var _a, _b, _c;
14709
14816
  const textTheme = this.getGraphicTheme(),
14710
14817
  {
14711
14818
  fontFamily = textTheme.fontFamily,
@@ -14723,18 +14830,18 @@
14723
14830
  heightLimit = 0,
14724
14831
  lineClamp: lineClamp
14725
14832
  } = this.attribute,
14726
- lineHeight = null !== (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : this.attribute.fontSize || textTheme.fontSize,
14727
- buf = ignoreBuf ? 0 : 2;
14728
- if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
14833
+ lineHeight = this.getLineHeight(this.attribute, textTheme);
14834
+ if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
14729
14835
  const bbox = this.cache.layoutData.bbox;
14730
14836
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14731
14837
  }
14732
14838
  const textMeasure = application.graphicUtil.textMeasure,
14733
- layoutObj = new CanvasTextLayout(fontFamily, {
14839
+ textOptions = {
14734
14840
  fontSize: fontSize,
14735
14841
  fontWeight: fontWeight,
14736
14842
  fontFamily: fontFamily
14737
- }, textMeasure),
14843
+ },
14844
+ layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
14738
14845
  lines = isArray$1(text) ? text.map(l => l.toString()) : [text.toString()],
14739
14846
  linesLayout = [],
14740
14847
  bboxWH = [0, 0];
@@ -14744,29 +14851,35 @@
14744
14851
  const str = lines[i];
14745
14852
  let needCut = !0;
14746
14853
  if (i === lineCountLimit - 1) {
14747
- const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1);
14854
+ const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1),
14855
+ matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
14748
14856
  linesLayout.push({
14749
14857
  str: clip.str,
14750
- width: clip.width
14858
+ width: clip.width,
14859
+ ascent: matrics.ascent,
14860
+ descent: matrics.descent
14751
14861
  });
14752
14862
  break;
14753
14863
  }
14754
- const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
14864
+ const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
14755
14865
  if ("" !== str && "" === clip.str || clip.wordBreaked) {
14756
14866
  if (ellipsis) {
14757
- const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
14758
- clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
14867
+ const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
14868
+ clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
14759
14869
  } else clip.str = "", clip.width = 0;
14760
14870
  needCut = !1;
14761
14871
  }
14872
+ const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
14762
14873
  linesLayout.push({
14763
14874
  str: clip.str,
14764
- width: clip.width
14875
+ width: clip.width,
14876
+ ascent: matrics.ascent,
14877
+ descent: matrics.descent
14765
14878
  });
14766
14879
  let cutLength = clip.str.length;
14767
14880
  if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
14768
- let newStr = str.substring(cutLength);
14769
- "keep-all" === wordBreak && (newStr = newStr.replace(/^\s+/g, "")), lines.splice(i + 1, 0, newStr);
14881
+ const newStr = str.substring(cutLength);
14882
+ lines.splice(i + 1, 0, newStr);
14770
14883
  }
14771
14884
  }
14772
14885
  let maxWidth = 0;
@@ -14779,21 +14892,28 @@
14779
14892
  lineWidth = 0;
14780
14893
  for (let i = 0, len = lines.length; i < len; i++) {
14781
14894
  if (i === lineCountLimit - 1) {
14782
- const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
14895
+ const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition),
14896
+ matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
14783
14897
  linesLayout.push({
14784
14898
  str: clip.str,
14785
- width: clip.width
14899
+ width: clip.width,
14900
+ ascent: matrics.ascent,
14901
+ descent: matrics.descent
14786
14902
  }), lineWidth = Math.max(lineWidth, clip.width);
14787
14903
  break;
14788
14904
  }
14789
- text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
14905
+ text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width);
14906
+ const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions);
14907
+ linesLayout.push({
14790
14908
  str: text,
14791
- width: width
14909
+ width: width,
14910
+ ascent: matrics.ascent,
14911
+ descent: matrics.descent
14792
14912
  });
14793
14913
  }
14794
14914
  bboxWH[0] = lineWidth;
14795
14915
  }
14796
- bboxWH[1] = linesLayout.length * (lineHeight + buf);
14916
+ bboxWH[1] = linesLayout.length * lineHeight;
14797
14917
  const bbox = {
14798
14918
  xOffset: 0,
14799
14919
  yOffset: 0,
@@ -14804,210 +14924,12 @@
14804
14924
  const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
14805
14925
  return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14806
14926
  }
14807
- updateSingallineAABBBounds(text) {
14808
- const textTheme = this.getGraphicTheme(),
14809
- {
14810
- direction = textTheme.direction,
14811
- underlineOffset = textTheme.underlineOffset
14812
- } = this.attribute,
14813
- b = "horizontal" === direction ? this.updateHorizontalSinglelineAABBBounds(text) : this.updateVerticalSinglelineAABBBounds(text);
14814
- return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
14815
- }
14816
- updateMultilineAABBBounds(text) {
14817
- const textTheme = this.getGraphicTheme(),
14818
- {
14819
- direction = textTheme.direction,
14820
- underlineOffset = textTheme.underlineOffset
14821
- } = this.attribute,
14822
- b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
14823
- return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
14824
- }
14825
- updateHorizontalSinglelineAABBBounds(text) {
14826
- var _a, _b;
14827
- const textTheme = this.getGraphicTheme(),
14828
- {
14829
- wrap = textTheme.wrap
14830
- } = this.attribute;
14831
- if (wrap) return this.updateWrapAABBBounds([text]);
14832
- const textMeasure = application.graphicUtil.textMeasure;
14833
- let width, str;
14834
- const attribute = this.attribute,
14835
- {
14836
- maxLineWidth = textTheme.maxLineWidth,
14837
- ellipsis = textTheme.ellipsis,
14838
- textAlign = textTheme.textAlign,
14839
- textBaseline = textTheme.textBaseline,
14840
- fontFamily = textTheme.fontFamily,
14841
- fontSize = textTheme.fontSize,
14842
- fontWeight = textTheme.fontWeight,
14843
- stroke = textTheme.stroke,
14844
- lineWidth = textTheme.lineWidth,
14845
- ignoreBuf = textTheme.ignoreBuf,
14846
- whiteSpace = textTheme.whiteSpace,
14847
- suffixPosition = textTheme.suffixPosition
14848
- } = attribute;
14849
- if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
14850
- const buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
14851
- textFontSize = attribute.fontSize || textTheme.fontSize,
14852
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) && void 0 !== _a ? _a : textFontSize + buf;
14853
- if (!this.shouldUpdateShape() && this.cache) {
14854
- width = null !== (_b = this.cache.clipedWidth) && void 0 !== _b ? _b : 0;
14855
- const dx = textDrawOffsetX(textAlign, width),
14856
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
14857
- return this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14858
- }
14859
- if (Number.isFinite(maxLineWidth)) {
14860
- if (ellipsis) {
14861
- const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
14862
- data = textMeasure.clipTextWithSuffix(text.toString(), {
14863
- fontSize: fontSize,
14864
- fontWeight: fontWeight,
14865
- fontFamily: fontFamily
14866
- }, maxLineWidth, strEllipsis, !1, suffixPosition);
14867
- str = data.str, width = data.width;
14868
- } else {
14869
- const data = textMeasure.clipText(text.toString(), {
14870
- fontSize: fontSize,
14871
- fontWeight: fontWeight,
14872
- fontFamily: fontFamily
14873
- }, maxLineWidth, !1);
14874
- str = data.str, width = data.width;
14875
- }
14876
- this.cache.clipedText = str, this.cache.clipedWidth = width;
14877
- } else width = textMeasure.measureTextWidth(text.toString(), {
14878
- fontSize: fontSize,
14879
- fontWeight: fontWeight,
14880
- fontFamily: fontFamily
14881
- }), this.cache.clipedText = text.toString(), this.cache.clipedWidth = width;
14882
- this.clearUpdateShapeTag();
14883
- const dx = textDrawOffsetX(textAlign, width);
14884
- let lh = lineHeight;
14885
- application.global && application.global.isSafari() && (lh += .2 * fontSize);
14886
- const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
14887
- return this._AABBBounds.set(dx, dy, dx + width, dy + lh), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14888
- }
14889
- getBaselineMapAlign() {
14890
- return Text.baselineMapAlign;
14891
- }
14892
- getAlignMapBaseline() {
14893
- return Text.alignMapBaseline;
14894
- }
14895
- updateVerticalSinglelineAABBBounds(text) {
14896
- var _a, _b, _c;
14897
- const textTheme = this.getGraphicTheme(),
14898
- textMeasure = application.graphicUtil.textMeasure;
14899
- let width;
14900
- const attribute = this.attribute,
14901
- {
14902
- ignoreBuf = textTheme.ignoreBuf
14903
- } = attribute,
14904
- buf = ignoreBuf ? 0 : 2,
14905
- {
14906
- maxLineWidth = textTheme.maxLineWidth,
14907
- ellipsis = textTheme.ellipsis,
14908
- fontSize = textTheme.fontSize,
14909
- fontWeight = textTheme.fontWeight,
14910
- fontFamily = textTheme.fontFamily,
14911
- stroke = textTheme.stroke,
14912
- lineWidth = textTheme.lineWidth,
14913
- verticalMode = textTheme.verticalMode,
14914
- suffixPosition = textTheme.suffixPosition
14915
- } = attribute,
14916
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
14917
- let {
14918
- textAlign = textTheme.textAlign,
14919
- textBaseline = textTheme.textBaseline
14920
- } = attribute;
14921
- if (!verticalMode) {
14922
- const t = textAlign;
14923
- textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
14924
- }
14925
- if (!this.shouldUpdateShape() && this.cache) {
14926
- width = this.cache.clipedWidth;
14927
- const dx = textDrawOffsetX(textAlign, width),
14928
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
14929
- return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14930
- }
14931
- let verticalList = [verticalLayout(text.toString())];
14932
- if (Number.isFinite(maxLineWidth)) {
14933
- if (ellipsis) {
14934
- const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
14935
- data = textMeasure.clipTextWithSuffixVertical(verticalList[0], {
14936
- fontSize: fontSize,
14937
- fontWeight: fontWeight,
14938
- fontFamily: fontFamily
14939
- }, maxLineWidth, strEllipsis, !1, suffixPosition);
14940
- verticalList = [data.verticalList], width = data.width;
14941
- } else {
14942
- const data = textMeasure.clipTextVertical(verticalList[0], {
14943
- fontSize: fontSize,
14944
- fontWeight: fontWeight,
14945
- fontFamily: fontFamily
14946
- }, maxLineWidth, !1);
14947
- verticalList = [data.verticalList], width = data.width;
14948
- }
14949
- this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
14950
- } else width = 0, verticalList[0].forEach(t => {
14951
- const w = t.direction === exports.TextDirection.HORIZONTAL ? fontSize : textMeasure.measureTextWidth(t.text, {
14952
- fontSize: fontSize,
14953
- fontWeight: fontWeight,
14954
- fontFamily: fontFamily
14955
- });
14956
- width += w, t.width = w;
14957
- }), this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
14958
- this.clearUpdateShapeTag();
14959
- const dx = textDrawOffsetX(textAlign, width),
14960
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
14961
- return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14962
- }
14963
- updateHorizontalMultilineAABBBounds(text) {
14964
- var _a, _b;
14965
- const textTheme = this.getGraphicTheme(),
14966
- {
14967
- wrap = textTheme.wrap
14968
- } = this.attribute;
14969
- if (wrap) return this.updateWrapAABBBounds(text);
14970
- const attribute = this.attribute,
14971
- {
14972
- fontFamily = textTheme.fontFamily,
14973
- textAlign = textTheme.textAlign,
14974
- textBaseline = textTheme.textBaseline,
14975
- fontSize = textTheme.fontSize,
14976
- fontWeight = textTheme.fontWeight,
14977
- ellipsis = textTheme.ellipsis,
14978
- maxLineWidth: maxLineWidth,
14979
- stroke = textTheme.stroke,
14980
- lineWidth = textTheme.lineWidth,
14981
- whiteSpace = textTheme.whiteSpace,
14982
- suffixPosition = textTheme.suffixPosition
14983
- } = attribute,
14984
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
14985
- if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
14986
- if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
14987
- const bbox = this.cache.layoutData.bbox;
14988
- return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14989
- }
14990
- const textMeasure = application.graphicUtil.textMeasure,
14991
- layoutData = new CanvasTextLayout(fontFamily, {
14992
- fontSize: fontSize,
14993
- fontWeight: fontWeight,
14994
- fontFamily: fontFamily
14995
- }, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
14996
- {
14997
- bbox: bbox
14998
- } = layoutData;
14999
- return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
15000
- }
15001
14927
  updateVerticalMultilineAABBBounds(text) {
15002
- var _a, _b, _c;
14928
+ var _a, _b;
15003
14929
  const textTheme = this.getGraphicTheme(),
15004
14930
  textMeasure = application.graphicUtil.textMeasure;
15005
14931
  let width;
15006
14932
  const attribute = this.attribute,
15007
- {
15008
- ignoreBuf = textTheme.ignoreBuf
15009
- } = attribute,
15010
- buf = ignoreBuf ? 0 : 2,
15011
14933
  {
15012
14934
  maxLineWidth = textTheme.maxLineWidth,
15013
14935
  ellipsis = textTheme.ellipsis,
@@ -15019,14 +14941,14 @@
15019
14941
  verticalMode = textTheme.verticalMode,
15020
14942
  suffixPosition = textTheme.suffixPosition
15021
14943
  } = attribute,
15022
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
14944
+ lineHeight = this.getLineHeight(attribute, textTheme);
15023
14945
  let {
15024
14946
  textAlign = textTheme.textAlign,
15025
14947
  textBaseline = textTheme.textBaseline
15026
14948
  } = attribute;
15027
14949
  if (!verticalMode) {
15028
14950
  const t = textAlign;
15029
- textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
14951
+ textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
15030
14952
  }
15031
14953
  if (width = 0, !this.shouldUpdateShape() && this.cache) {
15032
14954
  this.cache.verticalList.forEach(item => {
@@ -15074,6 +14996,15 @@
15074
14996
  dy = textLayoutOffsetY(textBaseline, height, fontSize);
15075
14997
  return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
15076
14998
  }
14999
+ getMaxWidth(theme) {
15000
+ var _a, _b;
15001
+ const attribute = this.attribute;
15002
+ return null !== (_b = null !== (_a = attribute.maxLineWidth) && void 0 !== _a ? _a : attribute.maxWidth) && void 0 !== _b ? _b : theme.maxWidth;
15003
+ }
15004
+ getLineHeight(attribute, textTheme) {
15005
+ var _a;
15006
+ return null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
15007
+ }
15077
15008
  needUpdateTags(keys) {
15078
15009
  let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_UPDATE_TAG_KEY;
15079
15010
  return super.needUpdateTags(keys, k);
@@ -15088,6 +15019,12 @@
15088
15019
  getNoWorkAnimateAttr() {
15089
15020
  return Text.NOWORK_ANIMATE_ATTR;
15090
15021
  }
15022
+ getBaselineMapAlign() {
15023
+ return Text.baselineMapAlign;
15024
+ }
15025
+ getAlignMapBaseline() {
15026
+ return Text.alignMapBaseline;
15027
+ }
15091
15028
  }
15092
15029
  Text.NOWORK_ANIMATE_ATTR = Object.assign({
15093
15030
  ellipsis: 1,
@@ -15166,7 +15103,9 @@
15166
15103
  const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
15167
15104
  linesLayout.push({
15168
15105
  str: clip.str,
15169
- width: clip.width
15106
+ width: clip.width,
15107
+ ascent: 0,
15108
+ descent: 0
15170
15109
  });
15171
15110
  break;
15172
15111
  }
@@ -15180,7 +15119,9 @@
15180
15119
  }
15181
15120
  if (linesLayout.push({
15182
15121
  str: clip.str,
15183
- width: clip.width
15122
+ width: clip.width,
15123
+ ascent: 0,
15124
+ descent: 0
15184
15125
  }), clip.str.length === str.length) ;else if (needCut) {
15185
15126
  const newStr = str.substring(clip.str.length);
15186
15127
  lines.splice(i + 1, 0, newStr);
@@ -15199,13 +15140,17 @@
15199
15140
  const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
15200
15141
  linesLayout.push({
15201
15142
  str: clip.str,
15202
- width: clip.width
15143
+ width: clip.width,
15144
+ ascent: 0,
15145
+ descent: 0
15203
15146
  }), lineWidth = Math.max(lineWidth, clip.width);
15204
15147
  break;
15205
15148
  }
15206
15149
  text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
15207
15150
  str: text,
15208
- width: width
15151
+ width: width,
15152
+ ascent: 0,
15153
+ descent: 0
15209
15154
  });
15210
15155
  }
15211
15156
  bboxWH[0] = lineWidth;
@@ -15249,6 +15194,9 @@
15249
15194
  bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
15250
15195
  } else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
15251
15196
  }
15197
+ parseSize(size) {
15198
+ return isNumber$1(size) ? size : Math.min(size[0], size[1]);
15199
+ }
15252
15200
  }
15253
15201
 
15254
15202
  function circle(ctx, r, x, y, z) {
@@ -15259,13 +15207,13 @@
15259
15207
  super(...arguments), this.type = "circle", this.pathStr = "M0.5,0A0.5,0.5,0,1,1,-0.5,0A0.5,0.5,0,1,1,0.5,0";
15260
15208
  }
15261
15209
  draw(ctx, size, x, y, z) {
15262
- return circle(ctx, size / 2, x, y, z);
15210
+ return circle(ctx, this.parseSize(size) / 2, x, y, z);
15263
15211
  }
15264
15212
  drawOffset(ctx, size, x, y, offset, z) {
15265
- return circle(ctx, size / 2 + offset, x, y, z);
15213
+ return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
15266
15214
  }
15267
15215
  drawToSvgPath(size, x, y, z) {
15268
- const r = size / 2;
15216
+ const r = this.parseSize(size) / 2;
15269
15217
  return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
15270
15218
  }
15271
15219
  }
@@ -15282,10 +15230,10 @@
15282
15230
  super(...arguments), this.type = "cross", this.pathStr = "M-0.5,-0.2L-0.5,0.2L-0.2,0.2L-0.2,0.5L0.2,0.5L0.2,0.2L0.5,0.2L0.5,-0.2L0.2,-0.2L0.2,-0.5L-0.2,-0.5L-0.2,-0.2Z";
15283
15231
  }
15284
15232
  draw(ctx, size, x, y, z) {
15285
- return cross(ctx, size / 6, x, y, z);
15233
+ return cross(ctx, this.parseSize(size) / 6, x, y, z);
15286
15234
  }
15287
15235
  drawOffset(ctx, size, x, y, offset, z) {
15288
- return crossOffset(ctx, size / 6, x, y, offset, z);
15236
+ return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
15289
15237
  }
15290
15238
  }
15291
15239
  var cross$1 = new CrossSymbol();
@@ -15298,13 +15246,13 @@
15298
15246
  super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
15299
15247
  }
15300
15248
  draw(ctx, size, x, y, z) {
15301
- return diamond(ctx, size / 2, x, y, z);
15249
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
15302
15250
  }
15303
15251
  drawFitDir(ctx, size, x, y, z) {
15304
- return diamond(ctx, size / 2, x, y, z);
15252
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
15305
15253
  }
15306
15254
  drawOffset(ctx, size, x, y, offset, z) {
15307
- return diamond(ctx, size / 2 + offset, x, y, z);
15255
+ return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
15308
15256
  }
15309
15257
  }
15310
15258
  var diamond$1 = new DiamondSymbol();
@@ -15318,10 +15266,10 @@
15318
15266
  super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
15319
15267
  }
15320
15268
  draw(ctx, size, x, y) {
15321
- return square(ctx, size / 2, x, y);
15269
+ return square(ctx, this.parseSize(size) / 2, x, y);
15322
15270
  }
15323
15271
  drawOffset(ctx, size, x, y, offset) {
15324
- return square(ctx, size / 2 + offset, x, y);
15272
+ return square(ctx, this.parseSize(size) / 2 + offset, x, y);
15325
15273
  }
15326
15274
  }
15327
15275
  var square$1 = new SquareSymbol();
@@ -15335,10 +15283,10 @@
15335
15283
  super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
15336
15284
  }
15337
15285
  draw(ctx, size, x, y) {
15338
- return trianglUpOffset(ctx, size / 2, x, y);
15286
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
15339
15287
  }
15340
15288
  drawOffset(ctx, size, x, y, offset) {
15341
- return trianglUpOffset(ctx, size / 2, x, y, offset);
15289
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15342
15290
  }
15343
15291
  }
15344
15292
  var triangleUp = new TriangleUpSymbol();
@@ -15370,10 +15318,10 @@
15370
15318
  super(...arguments), this.type = "star", this.pathStr = "M0 -1L0.22451398828979266 -0.3090169943749474L0.9510565162951535 -0.30901699437494745L0.3632712640026804 0.1180339887498948L0.5877852522924732 0.8090169943749473L8.326672684688674e-17 0.3819660112501051L-0.587785252292473 0.8090169943749476L-0.3632712640026804 0.11803398874989487L-0.9510565162951536 -0.30901699437494723L-0.22451398828979274 -0.30901699437494734Z";
15371
15319
  }
15372
15320
  draw(ctx, size, transX, transY) {
15373
- return star(ctx, size / 2, transX, transY);
15321
+ return star(ctx, this.parseSize(size) / 2, transX, transY);
15374
15322
  }
15375
15323
  drawOffset(ctx, size, transX, transY, offset) {
15376
- return star(ctx, size / 2 + offset, transX, transY);
15324
+ return star(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15377
15325
  }
15378
15326
  }
15379
15327
  var star$1 = new StarSymbol();
@@ -15391,10 +15339,10 @@
15391
15339
  super(...arguments), this.type = "arrow", this.pathStr = "M-0.07142857142857142,0.5L0.07142857142857142,0.5L0.07142857142857142,-0.0625L0.2,-0.0625L0,-0.5L-0.2,-0.0625L-0.07142857142857142,-0.0625Z";
15392
15340
  }
15393
15341
  draw(ctx, size, transX, transY) {
15394
- return arrow(ctx, size / 2, transX, transY);
15342
+ return arrow(ctx, this.parseSize(size) / 2, transX, transY);
15395
15343
  }
15396
15344
  drawOffset(ctx, size, transX, transY, offset) {
15397
- return arrow(ctx, size / 2 + offset, transX, transY);
15345
+ return arrow(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15398
15346
  }
15399
15347
  }
15400
15348
  var arrow$1 = new ArrowSymbol();
@@ -15408,10 +15356,10 @@
15408
15356
  super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
15409
15357
  }
15410
15358
  draw(ctx, size, transX, transY) {
15411
- return wedge(ctx, size / 2, transX, transY);
15359
+ return wedge(ctx, this.parseSize(size) / 2, transX, transY);
15412
15360
  }
15413
15361
  drawOffset(ctx, size, transX, transY, offset) {
15414
- return wedge(ctx, size / 2 + offset, transX, transY);
15362
+ return wedge(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15415
15363
  }
15416
15364
  }
15417
15365
  var wedge$1 = new WedgeSymbol();
@@ -15424,10 +15372,10 @@
15424
15372
  super(...arguments), this.type = "stroke", this.pathStr = "";
15425
15373
  }
15426
15374
  draw(ctx, size, transX, transY) {
15427
- return stroke(ctx, size / 2, transX, transY);
15375
+ return stroke(ctx, this.parseSize(size) / 2, transX, transY);
15428
15376
  }
15429
15377
  drawOffset(ctx, size, transX, transY, offset) {
15430
- return stroke(ctx, size / 2 + offset, transX, transY);
15378
+ return stroke(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15431
15379
  }
15432
15380
  }
15433
15381
  var stroke$1 = new StrokeSymbol();
@@ -15449,10 +15397,10 @@
15449
15397
  super(...arguments), this.type = "wye", this.pathStr = "M0.25 0.14433756729740646L0.25 0.6443375672974064L-0.25 0.6443375672974064L-0.25 0.14433756729740643L-0.6830127018922193 -0.10566243270259357L-0.4330127018922193 -0.5386751345948129L0 -0.28867513459481287L0.4330127018922193 -0.5386751345948129L0.6830127018922193 -0.10566243270259357Z";
15450
15398
  }
15451
15399
  draw(ctx, size, transX, transY) {
15452
- return wye(ctx, size / 2, transX, transY);
15400
+ return wye(ctx, this.parseSize(size) / 2, transX, transY);
15453
15401
  }
15454
15402
  drawOffset(ctx, size, transX, transY, offset) {
15455
- return wye(ctx, size / 2 + offset, transX, transY);
15403
+ return wye(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15456
15404
  }
15457
15405
  }
15458
15406
  var wye$1 = new WyeSymbol();
@@ -15465,10 +15413,10 @@
15465
15413
  super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
15466
15414
  }
15467
15415
  draw(ctx, size, x, y) {
15468
- return trianglLeftOffset(ctx, size / 2, x, y, 0);
15416
+ return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, 0);
15469
15417
  }
15470
15418
  drawOffset(ctx, size, x, y, offset) {
15471
- return trianglLeftOffset(ctx, size / 2, x, y, offset);
15419
+ return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15472
15420
  }
15473
15421
  }
15474
15422
  var triangleLeft = new TriangleLeftSymbol();
@@ -15482,10 +15430,10 @@
15482
15430
  super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
15483
15431
  }
15484
15432
  draw(ctx, size, x, y) {
15485
- return trianglRightOffset(ctx, size / 2, x, y);
15433
+ return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y);
15486
15434
  }
15487
15435
  drawOffset(ctx, size, x, y, offset) {
15488
- return trianglRightOffset(ctx, size / 2, x, y, offset);
15436
+ return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15489
15437
  }
15490
15438
  }
15491
15439
  var triangleRight = new TriangleRightSymbol();
@@ -15499,10 +15447,10 @@
15499
15447
  super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
15500
15448
  }
15501
15449
  draw(ctx, size, x, y) {
15502
- return trianglDownOffset(ctx, size / 2, x, y);
15450
+ return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y);
15503
15451
  }
15504
15452
  drawOffset(ctx, size, x, y, offset) {
15505
- return trianglDownOffset(ctx, size / 2, x, y, offset);
15453
+ return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15506
15454
  }
15507
15455
  }
15508
15456
  var triangleDown = new TriangleDownSymbol();
@@ -15517,10 +15465,10 @@
15517
15465
  super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
15518
15466
  }
15519
15467
  draw(ctx, size, x, y) {
15520
- return thinTriangle(ctx, size / 2 / sqrt3, x, y);
15468
+ return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3, x, y);
15521
15469
  }
15522
15470
  drawOffset(ctx, size, x, y, offset) {
15523
- return thinTriangle(ctx, size / 2 / sqrt3 + offset, x, y);
15471
+ return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3 + offset, x, y);
15524
15472
  }
15525
15473
  }
15526
15474
  var thinTriangle$1 = new ThinTriangleSymbol();
@@ -15534,10 +15482,10 @@
15534
15482
  super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
15535
15483
  }
15536
15484
  draw(ctx, size, transX, transY) {
15537
- return arrow2Left(ctx, size / 4, transX, transY);
15485
+ return arrow2Left(ctx, this.parseSize(size) / 4, transX, transY);
15538
15486
  }
15539
15487
  drawOffset(ctx, size, transX, transY, offset) {
15540
- return arrow2Left(ctx, size / 4 + offset, transX, transY);
15488
+ return arrow2Left(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15541
15489
  }
15542
15490
  }
15543
15491
  var arrow2Left$1 = new Arrow2LeftSymbol();
@@ -15551,10 +15499,10 @@
15551
15499
  super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
15552
15500
  }
15553
15501
  draw(ctx, size, transX, transY) {
15554
- return arrow2Right(ctx, size / 4, transX, transY);
15502
+ return arrow2Right(ctx, this.parseSize(size) / 4, transX, transY);
15555
15503
  }
15556
15504
  drawOffset(ctx, size, transX, transY, offset) {
15557
- return arrow2Right(ctx, size / 4 + offset, transX, transY);
15505
+ return arrow2Right(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15558
15506
  }
15559
15507
  }
15560
15508
  var arrow2Right$1 = new Arrow2RightSymbol();
@@ -15568,10 +15516,10 @@
15568
15516
  super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
15569
15517
  }
15570
15518
  draw(ctx, size, transX, transY) {
15571
- return arrow2Up(ctx, size / 4, transX, transY);
15519
+ return arrow2Up(ctx, this.parseSize(size) / 4, transX, transY);
15572
15520
  }
15573
15521
  drawOffset(ctx, size, transX, transY, offset) {
15574
- return arrow2Up(ctx, size / 4 + offset, transX, transY);
15522
+ return arrow2Up(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15575
15523
  }
15576
15524
  }
15577
15525
  var arrow2Up$1 = new Arrow2UpSymbol();
@@ -15585,10 +15533,10 @@
15585
15533
  super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
15586
15534
  }
15587
15535
  draw(ctx, size, transX, transY) {
15588
- return arrow2Down(ctx, size / 4, transX, transY);
15536
+ return arrow2Down(ctx, this.parseSize(size) / 4, transX, transY);
15589
15537
  }
15590
15538
  drawOffset(ctx, size, transX, transY, offset) {
15591
- return arrow2Down(ctx, size / 4 + offset, transX, transY);
15539
+ return arrow2Down(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15592
15540
  }
15593
15541
  }
15594
15542
  var arrow2Down$1 = new Arrow2DownSymbol();
@@ -15601,13 +15549,13 @@
15601
15549
  super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
15602
15550
  }
15603
15551
  draw(ctx, size, x, y, z) {
15604
- return lineV(ctx, size / 2, x, y);
15552
+ return lineV(ctx, this.parseSize(size) / 2, x, y);
15605
15553
  }
15606
15554
  drawOffset(ctx, size, x, y, offset, z) {
15607
- return lineV(ctx, size / 2 + offset, x, y);
15555
+ return lineV(ctx, this.parseSize(size) / 2 + offset, x, y);
15608
15556
  }
15609
15557
  drawToSvgPath(size, x, y, z) {
15610
- const r = size / 2;
15558
+ const r = this.parseSize(size) / 2;
15611
15559
  return `M ${x}, ${y - r} L ${x},${y + r}`;
15612
15560
  }
15613
15561
  }
@@ -15621,13 +15569,13 @@
15621
15569
  super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
15622
15570
  }
15623
15571
  draw(ctx, size, x, y, z) {
15624
- return lineH(ctx, size / 2, x, y);
15572
+ return lineH(ctx, this.parseSize(size) / 2, x, y);
15625
15573
  }
15626
15574
  drawOffset(ctx, size, x, y, offset, z) {
15627
- return lineH(ctx, size / 2 + offset, x, y);
15575
+ return lineH(ctx, this.parseSize(size) / 2 + offset, x, y);
15628
15576
  }
15629
15577
  drawToSvgPath(size, x, y, z) {
15630
- const r = size / 2;
15578
+ const r = this.parseSize(size) / 2;
15631
15579
  return `M ${x - r}, ${y} L ${x + r},${y}`;
15632
15580
  }
15633
15581
  }
@@ -15641,13 +15589,13 @@
15641
15589
  super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
15642
15590
  }
15643
15591
  draw(ctx, size, x, y, z) {
15644
- return close(ctx, size / 2, x, y);
15592
+ return close(ctx, this.parseSize(size) / 2, x, y);
15645
15593
  }
15646
15594
  drawOffset(ctx, size, x, y, offset, z) {
15647
- return close(ctx, size / 2 + offset, x, y);
15595
+ return close(ctx, this.parseSize(size) / 2 + offset, x, y);
15648
15596
  }
15649
15597
  drawToSvgPath(size, x, y, z) {
15650
- const r = size / 2;
15598
+ const r = this.parseSize(size) / 2;
15651
15599
  return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
15652
15600
  }
15653
15601
  }
@@ -15681,15 +15629,18 @@
15681
15629
  this.pathStr = "", this.type = type, isArray$1(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
15682
15630
  }
15683
15631
  drawOffset(ctx, size, x, y, offset, z, cb) {
15684
- return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
15632
+ return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
15685
15633
  ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
15686
15634
  }), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
15687
15635
  }
15688
15636
  draw(ctx, size, x, y, z, cb) {
15689
- return this.drawOffset(ctx, size, x, y, 0, z, cb);
15637
+ return size = this.parseSize(size), this.drawOffset(ctx, size, x, y, 0, z, cb);
15638
+ }
15639
+ parseSize(size) {
15640
+ return isNumber$1(size) ? size : Math.min(size[0], size[1]);
15690
15641
  }
15691
15642
  bounds(size, bounds) {
15692
- if (this.isSvg) {
15643
+ if (size = this.parseSize(size), this.isSvg) {
15693
15644
  if (!this.svgCache) return;
15694
15645
  return bounds.clear(), void this.svgCache.forEach(_ref => {
15695
15646
  let {
@@ -16372,7 +16323,11 @@
16372
16323
  case "sub":
16373
16324
  baseline += this.descent / 2;
16374
16325
  }
16375
- "vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0), this.character.stroke && (applyStrokeStyle(ctx, this.character), ctx.strokeText(text, left, baseline)), applyFillStyle(ctx, this.character), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
16326
+ "vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0);
16327
+ const {
16328
+ lineWidth = 1
16329
+ } = this.character;
16330
+ this.character.stroke && lineWidth && (applyStrokeStyle(ctx, this.character), ctx.strokeText(text, left, baseline)), applyFillStyle(ctx, this.character), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
16376
16331
  }
16377
16332
  getWidthWithEllips(direction) {
16378
16333
  let text = this.text;
@@ -18589,7 +18544,7 @@
18589
18544
  constructor() {
18590
18545
  let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
18591
18546
  var _a;
18592
- super({}), this._onVisibleChange = visible => {
18547
+ super({}), this.tickedBeforeRender = !0, this._onVisibleChange = visible => {
18593
18548
  if (!(this._skipRender < 0)) if (visible) {
18594
18549
  if (this.dirtyBounds) {
18595
18550
  const b = this.window.getViewBox();
@@ -18600,7 +18555,10 @@
18600
18555
  }, this.beforeRender = stage => {
18601
18556
  this._beforeRender && this._beforeRender(stage);
18602
18557
  }, this.afterRender = stage => {
18603
- this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null;
18558
+ this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null, this.tickedBeforeRender = !1;
18559
+ }, this.afterTickCb = () => {
18560
+ var _a;
18561
+ this.tickedBeforeRender = !0, "performance" === (null === (_a = this.params.optimize) || void 0 === _a ? void 0 : _a.tickRenderMode) || "rendering" !== this.state && this.render();
18604
18562
  }, this.params = params, this.theme = new Theme(), this.hooks = {
18605
18563
  beforeRender: new SyncHook(["stage"]),
18606
18564
  afterRender: new SyncHook(["stage"])
@@ -18617,7 +18575,7 @@
18617
18575
  main: !0
18618
18576
  })), this.nextFrameRenderLayerSet = new Set(), this.willNextFrameRender = !1, this.stage = this, this.renderStyle = params.renderStyle, params.autoRender && this.enableAutoRender(), params.autoRefresh && this.enableAutoRefresh(), !1 === params.disableDirtyBounds && this.enableDirtyBounds(), params.enableHtmlAttribute && this.enableHtmlAttribute(params.enableHtmlAttribute), params.ReactDOM && this.enableReactAttribute(params.ReactDOM), params.enableLayout && this.enableLayout(), this.hooks.beforeRender.tap("constructor", this.beforeRender), this.hooks.afterRender.tap("constructor", this.afterRender), this._beforeRender = params.beforeRender, this._afterRender = params.afterRender, this.ticker = params.ticker || defaultTicker, this.supportInteractiveLayer = !1 !== params.interactiveLayer, this.timeline = new DefaultTimeline(), this.ticker.addTimeline(this.timeline), this.timeline.pause(), params.optimize || (params.optimize = {}), this.optmize(params.optimize), params.background && isString$1(this._background) && this._background.includes("/") && this.setAttributes({
18619
18577
  background: this._background
18620
- });
18578
+ }), this.ticker.on("afterTick", this.afterTickCb);
18621
18579
  }
18622
18580
  pauseRender() {
18623
18581
  let sr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
@@ -18846,7 +18804,7 @@
18846
18804
  if ("released" === this.releaseStatus) return;
18847
18805
  this.ticker.start(), this.timeline.resume();
18848
18806
  const state = this.state;
18849
- this.state = "rendering", this.layerService.prepareStageLayer(this), this._skipRender || (this.lastRenderparams = params, this.hooks.beforeRender.call(this), this._skipRender || (this.renderLayerList(this.children), this.combineLayersToWindow(), this.nextFrameRenderLayerSet.clear()), this.hooks.afterRender.call(this)), this.state = state, this._skipRender && this._skipRender++;
18807
+ this.state = "rendering", this.tickedBeforeRender || this.ticker.trySyncTickStatus(), this.layerService.prepareStageLayer(this), this._skipRender || (this.lastRenderparams = params, this.hooks.beforeRender.call(this), this._skipRender || (this.renderLayerList(this.children), this.combineLayersToWindow(), this.nextFrameRenderLayerSet.clear()), this.hooks.afterRender.call(this)), this.state = state, this._skipRender && this._skipRender++;
18850
18808
  }
18851
18809
  combineLayersToWindow() {
18852
18810
  if ("harmony" === this.global.env) {
@@ -18952,7 +18910,7 @@
18952
18910
  layer.release();
18953
18911
  }), this.interactiveLayer && (this.interactiveLayer.forEachChildren(item => {
18954
18912
  item.setStage && item.setStage(null, null), this.interactiveLayer.removeChild(item);
18955
- }), this.interactiveLayer.release()), this.window.release(), this.ticker.remTimeline(this.timeline), this.renderService.renderTreeRoots = [];
18913
+ }), this.interactiveLayer.release()), this.window.release(), this.ticker.remTimeline(this.timeline), this.ticker.removeListener("afterTick", this.afterTickCb), this.renderService.renderTreeRoots = [];
18956
18914
  }
18957
18915
  setStage(stage) {}
18958
18916
  dirty(b, matrix) {
@@ -23652,11 +23610,9 @@
23652
23610
  name: name,
23653
23611
  id: id,
23654
23612
  attribute: attribute,
23655
- stateProxy: stateProxy,
23656
- animation: animation,
23657
- timeline: timeline
23613
+ stateProxy: stateProxy
23658
23614
  } = _a,
23659
- props = __rest(_a, ["key", "name", "id", "attribute", "stateProxy", "animation", "timeline"]);
23615
+ props = __rest(_a, ["key", "name", "id", "attribute", "stateProxy"]);
23660
23616
  let c = type;
23661
23617
  isString$1(type) && (c = graphicCreator[type]);
23662
23618
  const childrenList = [];
@@ -23665,13 +23621,7 @@
23665
23621
  }
23666
23622
  children.length && flatten(1 === children.length ? children[0] : children, childrenList);
23667
23623
  const g = "Group" === c.name ? new c(attribute) : c(config);
23668
- if (parseToGraphic$1(g, childrenList, props), stateProxy && (g.stateProxy = stateProxy), name && (g.name = name), isArray$1(animation)) {
23669
- const animate = g.animate();
23670
- timeline && animate.setTimeline(timeline), animation.forEach(item => {
23671
- animate[item[0]](...item.slice(1));
23672
- });
23673
- }
23674
- return g;
23624
+ return parseToGraphic$1(g, childrenList, props), stateProxy && (g.stateProxy = stateProxy), g;
23675
23625
  }
23676
23626
  function parseToGraphic$1(g, childrenList, props) {
23677
23627
  let out,
@@ -23939,7 +23889,7 @@
23939
23889
  startTime: startTime,
23940
23890
  startPoints: startPoints
23941
23891
  } = this;
23942
- if (eventType) return eventType;
23892
+ if ("press" === eventType) return eventType;
23943
23893
  let type;
23944
23894
  return type = clock.now() - startTime > this.config.press.time && calcDistance(startPoints[0], point) < this.config.press.threshold ? "press" : "pan", this.eventType = type, type;
23945
23895
  }
@@ -24471,9 +24421,10 @@
24471
24421
  lineJoin = defaultParams.lineJoin,
24472
24422
  lineDash = defaultParams.lineDash,
24473
24423
  lineCap = defaultParams.lineCap,
24474
- miterLimit = defaultParams.miterLimit
24424
+ miterLimit = defaultParams.miterLimit,
24425
+ keepStrokeScale = defaultParams.keepStrokeScale
24475
24426
  } = attribute;
24476
- _context.lineWidth = getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
24427
+ _context.lineWidth = keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
24477
24428
  }
24478
24429
  }
24479
24430
  setTextStyleWithoutAlignBaseline(params, defaultParams, z) {
@@ -25373,8 +25324,9 @@
25373
25324
  return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, (context, arcAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, arcAttribute, themeAttribute) => {
25374
25325
  if (picked) return !0;
25375
25326
  const lineWidth = arcAttribute.lineWidth || themeAttribute.lineWidth,
25376
- pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
25377
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
25327
+ pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
25328
+ keepStrokeScale = arcAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
25329
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
25378
25330
  }), pickContext.highPerformanceRestore(), picked;
25379
25331
  }
25380
25332
  }
@@ -25647,8 +25599,9 @@
25647
25599
  if (!onlyTranslate || rect.shadowRoot || isNumber$1(cornerRadius, !0) && 0 !== cornerRadius || isArray$1(cornerRadius) && cornerRadius.some(num => 0 !== num)) picked = !1, this.canvasRenderer.drawShape(rect, pickContext, x, y, {}, null, (context, rectAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, rectAttribute, themeAttribute) => {
25648
25600
  if (picked) return !0;
25649
25601
  const lineWidth = rectAttribute.lineWidth || themeAttribute.lineWidth,
25650
- pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
25651
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
25602
+ pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
25603
+ keepStrokeScale = rectAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
25604
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
25652
25605
  });else {
25653
25606
  const {
25654
25607
  fill = rectAttribute.fill,
@@ -25962,9 +25915,10 @@
25962
25915
  lineJoin = defaultParams.lineJoin,
25963
25916
  lineDash = defaultParams.lineDash,
25964
25917
  lineCap = defaultParams.lineCap,
25965
- miterLimit = defaultParams.miterLimit
25918
+ miterLimit = defaultParams.miterLimit,
25919
+ keepStrokeScale = defaultParams.keepStrokeScale
25966
25920
  } = attribute;
25967
- _context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
25921
+ _context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
25968
25922
  }
25969
25923
  }
25970
25924
  measureText(text) {
@@ -26592,9 +26546,10 @@
26592
26546
  lineJoin = defaultParams.lineJoin,
26593
26547
  lineDash = defaultParams.lineDash,
26594
26548
  lineCap = defaultParams.lineCap,
26595
- miterLimit = defaultParams.miterLimit
26549
+ miterLimit = defaultParams.miterLimit,
26550
+ keepStrokeScale = defaultParams.keepStrokeScale
26596
26551
  } = attribute;
26597
- _context.setGlobalAlpha(strokeOpacity * opacity), _context.setLineWidth(getScaledStroke(this, lineWidth, this.dpr)), _context.setStrokeStyle(createColor(this, stroke, params, offsetX, offsetY)), _context.setLineJoin(lineJoin), lineDash && _context.setLineDash(lineDash), _context.setLineCap(lineCap), _context.setMiterLimit(miterLimit);
26552
+ _context.setGlobalAlpha(strokeOpacity * opacity), _context.setLineWidth(keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr)), _context.setStrokeStyle(createColor(this, stroke, params, offsetX, offsetY)), _context.setLineJoin(lineJoin), lineDash && _context.setLineDash(lineDash), _context.setLineCap(lineCap), _context.setMiterLimit(miterLimit);
26598
26553
  }
26599
26554
  }
26600
26555
  setTextStyleWithoutAlignBaseline(params, defaultParams) {
@@ -27634,9 +27589,10 @@
27634
27589
  lineJoin = defaultParams.lineJoin,
27635
27590
  lineDash = defaultParams.lineDash,
27636
27591
  lineCap = defaultParams.lineCap,
27637
- miterLimit = defaultParams.miterLimit
27592
+ miterLimit = defaultParams.miterLimit,
27593
+ keepStrokeScale = defaultParams.keepStrokeScale
27638
27594
  } = attribute;
27639
- _context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
27595
+ _context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
27640
27596
  }
27641
27597
  }
27642
27598
  measureText(text) {
@@ -28043,8 +27999,9 @@
28043
27999
  return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, context => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, lineAttribute, themeAttribute) => {
28044
28000
  if (picked) return !0;
28045
28001
  const lineWidth = lineAttribute.lineWidth || themeAttribute.lineWidth,
28046
- pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
28047
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
28002
+ pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
28003
+ keepStrokeScale = lineAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
28004
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
28048
28005
  }), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
28049
28006
  }
28050
28007
  }
@@ -28179,8 +28136,9 @@
28179
28136
  return this.canvasRenderer.drawShape(symbol, pickContext, x, y, {}, null, (context, symbolAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, symbolAttribute, themeAttribute) => {
28180
28137
  if (picked) return !0;
28181
28138
  const lineWidth = symbolAttribute.lineWidth || themeAttribute.lineWidth,
28182
- pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
28183
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
28139
+ pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
28140
+ keepStrokeScale = symbolAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
28141
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
28184
28142
  }), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
28185
28143
  }
28186
28144
  };
@@ -28617,7 +28575,7 @@
28617
28575
 
28618
28576
  const roughModule = _roughModule;
28619
28577
 
28620
- const version = "0.21.0-alpha.4";
28578
+ const version = "0.21.0-alpha.5";
28621
28579
  preLoadAllModule();
28622
28580
  if (isBrowserEnv()) {
28623
28581
  loadBrowserEnv(container);