@visactor/vrender 0.21.0-alpha.2 → 0.21.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -2726,11 +2726,12 @@ function parseSvgPath(str) {
2726
2726
  for (let i = 0, len = paths.length; i < len; i++) if (currPath = paths[i], coordsStr = currPath.slice(1), commandChar = currPath[0], currCommandData = [commandChar], coordsStrArr = coordsStr.match(rePathCommand), null !== coordsStrArr) {
2727
2727
  for (let i = 0, len = coordsStrArr.length; i < len; i++) coordStr = coordsStrArr[i], coordNumber = parseFloat(coordStr), Number.isNaN(coordNumber) || currCommandData.push(coordNumber);
2728
2728
  if (standardCommandLen = commandLengths[commandChar], currCommandData.length - 1 > standardCommandLen) {
2729
- let subCommand;
2729
+ let subCommand,
2730
+ bestCommandChar = commandChar;
2730
2731
  for (let i = 1, len = currCommandData.length; i < len; i += standardCommandLen) {
2731
- subCommand = [commandChar];
2732
+ subCommand = [bestCommandChar];
2732
2733
  for (let j = i, subLen = i + standardCommandLen; j < subLen; j++) subCommand.push(currCommandData[j]);
2733
- result.push(subCommand);
2734
+ result.push(subCommand), "m" === bestCommandChar ? bestCommandChar = "l" : "M" === bestCommandChar && (bestCommandChar = "L");
2734
2735
  }
2735
2736
  } else result.push(currCommandData);
2736
2737
  } else result.push(currCommandData);
@@ -3912,6 +3913,7 @@ const DefaultStrokeStyle = Object.assign({
3912
3913
  const DefaultTextStyle = {
3913
3914
  text: "",
3914
3915
  maxLineWidth: 1 / 0,
3916
+ maxWidth: 1 / 0,
3915
3917
  textAlign: "left",
3916
3918
  textBaseline: "alphabetic",
3917
3919
  fontSize: 16,
@@ -3979,6 +3981,7 @@ const DefaultAttribute = Object.assign(Object.assign(Object.assign({
3979
3981
  zIndex: 0,
3980
3982
  layout: null,
3981
3983
  boundsPadding: 0,
3984
+ fillStrokeOrder: 0,
3982
3985
  renderStyle: "default",
3983
3986
  pickMode: "accurate",
3984
3987
  customPickShape: null,
@@ -4057,6 +4060,7 @@ const DefaultLineAttribute = Object.assign(Object.assign(Object.assign({}, Defau
4057
4060
  });
4058
4061
  const DefaultPathAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
4059
4062
  path: new CustomPath2D(),
4063
+ fillStrokeOrder: 1,
4060
4064
  customPath: () => {
4061
4065
  Logger.getInstance().warn("空函数");
4062
4066
  }
@@ -4262,10 +4266,32 @@ let ATextMeasure = class {
4262
4266
  configure(service, env) {
4263
4267
  this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
4264
4268
  }
4265
- measureTextWidth(text, options) {
4266
- if (!this.context) return this.estimate(text, options).width;
4269
+ _measureTextWithoutAlignBaseline(text, options, compatible) {
4267
4270
  this.context.setTextStyleWithoutAlignBaseline(options);
4268
- return this.context.measureText(text).width;
4271
+ const metrics = this.context.measureText(text);
4272
+ return compatible ? this.compatibleMetrics(metrics, options) : metrics;
4273
+ }
4274
+ _measureTextWithAlignBaseline(text, options, compatible) {
4275
+ this.context.setTextStyle(options);
4276
+ const metrics = this.context.measureText(text);
4277
+ return compatible ? this.compatibleMetrics(metrics, options) : metrics;
4278
+ }
4279
+ compatibleMetrics(metrics, options) {
4280
+ if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
4281
+ const {
4282
+ ascent: ascent,
4283
+ descent: descent
4284
+ } = this.measureTextBoundADscentEstimate(options);
4285
+ metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
4286
+ }
4287
+ if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
4288
+ const {
4289
+ left: left,
4290
+ right: right
4291
+ } = this.measureTextBoundLeftRightEstimate(options);
4292
+ metrics.actualBoundingBoxLeft = left, metrics.actualBoundingBoxRight = right;
4293
+ }
4294
+ return metrics;
4269
4295
  }
4270
4296
  estimate(text, _ref) {
4271
4297
  let {
@@ -4279,19 +4305,85 @@ let ATextMeasure = class {
4279
4305
  height: fontSize
4280
4306
  };
4281
4307
  }
4282
- measureTextPixelHeight(text, options) {
4308
+ measureTextWidth(text, options, textMeasure) {
4309
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
4310
+ }
4311
+ measureTextBoundsWidth(text, options, textMeasure) {
4312
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
4313
+ }
4314
+ measureTextBoundsLeftRight(text, options, textMeasure) {
4315
+ return this.context ? {
4316
+ left: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxLeft,
4317
+ right: textMeasure.actualBoundingBoxRight
4318
+ } : this.measureTextBoundLeftRightEstimate(options);
4319
+ }
4320
+ measureTextPixelHeight(text, options, textMeasure) {
4283
4321
  var _a;
4284
- if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
4285
- this.context.setTextStyleWithoutAlignBaseline(options);
4286
- const textMeasure = this.context.measureText(text);
4287
- return Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent);
4322
+ 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;
4323
+ }
4324
+ measureTextPixelADscent(text, options, textMeasure) {
4325
+ return this.context ? {
4326
+ ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxAscent,
4327
+ descent: textMeasure.actualBoundingBoxDescent
4328
+ } : this.measureTextBoundADscentEstimate(options);
4288
4329
  }
4289
- measureTextBoundHieght(text, options) {
4330
+ measureTextBoundHieght(text, options, textMeasure) {
4290
4331
  var _a;
4291
- if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
4292
- this.context.setTextStyleWithoutAlignBaseline(options);
4293
- const textMeasure = this.context.measureText(text);
4294
- return Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent);
4332
+ 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;
4333
+ }
4334
+ measureTextBoundADscent(text, options, textMeasure) {
4335
+ return this.context ? {
4336
+ ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).fontBoundingBoxAscent,
4337
+ descent: textMeasure.fontBoundingBoxDescent
4338
+ } : this.measureTextBoundADscentEstimate(options);
4339
+ }
4340
+ measureTextBoundADscentEstimate(options) {
4341
+ var _a;
4342
+ const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
4343
+ {
4344
+ textBaseline: textBaseline
4345
+ } = options;
4346
+ return "bottom" === textBaseline ? {
4347
+ ascent: fontSize,
4348
+ descent: 0
4349
+ } : "middle" === textBaseline ? {
4350
+ ascent: fontSize / 2,
4351
+ descent: fontSize / 2
4352
+ } : "alphabetic" === textBaseline ? {
4353
+ ascent: .79 * fontSize,
4354
+ descent: .21 * fontSize
4355
+ } : {
4356
+ ascent: 0,
4357
+ descent: fontSize
4358
+ };
4359
+ }
4360
+ measureTextBoundLeftRightEstimate(options) {
4361
+ var _a;
4362
+ const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
4363
+ {
4364
+ textAlign: textAlign
4365
+ } = options;
4366
+ return "center" === textAlign ? {
4367
+ left: fontSize / 2,
4368
+ right: fontSize / 2
4369
+ } : "right" === textAlign || "end" === textAlign ? {
4370
+ left: fontSize,
4371
+ right: 0
4372
+ } : {
4373
+ left: 0,
4374
+ right: fontSize
4375
+ };
4376
+ }
4377
+ measureTextPixelADscentAndWidth(text, options) {
4378
+ if (!this.context) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
4379
+ width: this.estimate(text, options).width
4380
+ });
4381
+ const out = this._measureTextWithoutAlignBaseline(text, options, !0);
4382
+ return {
4383
+ ascent: out.actualBoundingBoxAscent,
4384
+ descent: out.actualBoundingBoxDescent,
4385
+ width: out.width
4386
+ };
4295
4387
  }
4296
4388
  measureText(text, options) {
4297
4389
  return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
@@ -4369,6 +4461,14 @@ let ATextMeasure = class {
4369
4461
  return data;
4370
4462
  }
4371
4463
  _clipTextEnd(text, options, width, leftIdx, rightIdx) {
4464
+ if (leftIdx === rightIdx) {
4465
+ Logger.getInstance().warn(`【_clipTextEnd】不应该走到这里${text}, ${leftIdx}, ${rightIdx}`);
4466
+ const subText = text.substring(0, rightIdx + 1);
4467
+ return {
4468
+ str: subText,
4469
+ width: this.measureTextWidth(subText, options)
4470
+ };
4471
+ }
4372
4472
  const middleIdx = Math.floor((leftIdx + rightIdx) / 2),
4373
4473
  subText = text.substring(0, middleIdx + 1),
4374
4474
  strWidth = this.measureTextWidth(subText, options);
@@ -4402,7 +4502,7 @@ let ATextMeasure = class {
4402
4502
  }
4403
4503
  _clipTextStart(text, options, width, leftIdx, rightIdx) {
4404
4504
  const middleIdx = Math.ceil((leftIdx + rightIdx) / 2),
4405
- subText = text.substring(middleIdx - 1, text.length - 1),
4505
+ subText = text.substring(middleIdx - 1, text.length),
4406
4506
  strWidth = this.measureTextWidth(subText, options);
4407
4507
  let length;
4408
4508
  if (strWidth > width) {
@@ -4410,18 +4510,18 @@ let ATextMeasure = class {
4410
4510
  str: "",
4411
4511
  width: 0
4412
4512
  };
4413
- const str = text.substring(middleIdx, text.length - 1);
4513
+ const str = text.substring(middleIdx, text.length);
4414
4514
  return length = this.measureTextWidth(str, options), length <= width ? {
4415
4515
  str: str,
4416
4516
  width: length
4417
- } : this._clipTextStart(text, options, width, middleIdx, text.length - 1);
4517
+ } : this._clipTextStart(text, options, width, middleIdx, text.length);
4418
4518
  }
4419
4519
  if (strWidth < width) {
4420
4520
  if (middleIdx <= 0) return {
4421
4521
  str: text,
4422
4522
  width: this.measureTextWidth(text, options)
4423
4523
  };
4424
- const str = text.substring(middleIdx - 2, text.length - 1);
4524
+ const str = text.substring(middleIdx - 2, text.length);
4425
4525
  return length = this.measureTextWidth(str, options), length >= width ? {
4426
4526
  str: subText,
4427
4527
  width: strWidth
@@ -5082,7 +5182,7 @@ let DefaultWindow = class {
5082
5182
  }
5083
5183
  hasSubView() {
5084
5184
  const viewBox = this._handler.getViewBox();
5085
- return !(0 === viewBox.x1 && 0 === viewBox.y1 && this.width === viewBox.width() && this.height === viewBox.height());
5185
+ return !(0 === viewBox.x1 && 0 === viewBox.y1 && isNumberClose(this.width, viewBox.width()) && isNumberClose(this.height, viewBox.height()));
5086
5186
  }
5087
5187
  isVisible(bbox) {
5088
5188
  return this._handler.isVisible(bbox);
@@ -6006,7 +6106,7 @@ class EventManager {
6006
6106
  timeStamp: now
6007
6107
  });
6008
6108
  const clickHistory = trackingData.clicksByButton[from.button];
6009
- clickHistory.target === clickEvent.target && now - clickHistory.timeStamp < (null !== (_a = this._config.clickInterval) && void 0 !== _a ? _a : 200) ? ++clickHistory.clickCount : clickHistory.clickCount = 1, clickHistory.target = clickEvent.target, clickHistory.timeStamp = now, clickEvent.detail = clickHistory.clickCount, isMouseLike(clickEvent.pointerType) ? (this.dispatchEvent(clickEvent, "click"), 2 === clickHistory.clickCount && this.dispatchEvent(clickEvent, "dblclick")) : "touch" === clickEvent.pointerType && (this.dispatchEvent(clickEvent, "tap"), 2 === clickHistory.clickCount && this.dispatchEvent(clickEvent, "dbltap")), this.dispatchEvent(clickEvent, "pointertap"), this.freeEvent(clickEvent);
6109
+ clickHistory.target === clickEvent.target && now - clickHistory.timeStamp < (null !== (_a = this._config.clickInterval) && void 0 !== _a ? _a : 200) ? ++clickHistory.clickCount : clickHistory.clickCount = 1, clickHistory.target = clickEvent.target, clickHistory.timeStamp = now, clickEvent.detail = clickHistory.clickCount, isMouseLike(clickEvent.pointerType) ? (this.dispatchEvent(clickEvent, "click"), 2 === clickHistory.clickCount && this.dispatchEvent(clickEvent, "dblclick")) : "touch" === clickEvent.pointerType && this._config.supportsTouchEvents && (this.dispatchEvent(clickEvent, "tap"), 2 === clickHistory.clickCount && this.dispatchEvent(clickEvent, "dbltap")), this.dispatchEvent(clickEvent, "pointertap"), this.freeEvent(clickEvent);
6010
6110
  }
6011
6111
  this.freeEvent(e);
6012
6112
  }, this.onPointerUpOutside = (from, target) => {
@@ -6223,7 +6323,8 @@ class EventSystem {
6223
6323
  supportsPointerEvents = global.supportsPointerEvents
6224
6324
  } = params;
6225
6325
  this.manager = new EventManager(rootNode, {
6226
- clickInterval: clickInterval
6326
+ clickInterval: clickInterval,
6327
+ supportsTouchEvents: supportsTouchEvents
6227
6328
  }), this.globalObj = global, this.supportsPointerEvents = supportsPointerEvents, this.supportsTouchEvents = supportsTouchEvents, this.supportsMouseEvents = global.supportsMouseEvents, this.applyStyles = global.applyStyles, this.autoPreventDefault = autoPreventDefault, this.eventsAdded = !1, this.rootPointerEvent = new FederatedPointerEvent(), this.rootWheelEvent = new FederatedWheelEvent(), this.cursorStyles = {
6228
6329
  default: "inherit",
6229
6330
  pointer: "pointer"
@@ -12500,7 +12601,8 @@ let DefaultCanvasArcRender = class extends BaseRender {
12500
12601
  fill = arcAttribute.fill,
12501
12602
  stroke = arcAttribute.stroke,
12502
12603
  x: originX = arcAttribute.x,
12503
- y: originY = arcAttribute.y
12604
+ y: originY = arcAttribute.y,
12605
+ fillStrokeOrder = arcAttribute.fillStrokeOrder
12504
12606
  } = arc.attribute,
12505
12607
  data = this.valid(arc, arcAttribute, fillCb, strokeCb);
12506
12608
  if (!data) return;
@@ -12536,7 +12638,17 @@ let DefaultCanvasArcRender = class extends BaseRender {
12536
12638
  isFullStroke: isFullStroke,
12537
12639
  stroke: arrayStroke
12538
12640
  } = parseStroke(stroke);
12539
- if ((doFill || isFullStroke) && (context.beginPath(), drawArcPath$1(arc, context, x, y, outerRadius, innerRadius), beforeRenderContribitionsRuned = !0, context.setShadowBlendStyle && context.setShadowBlendStyle(arc, arc.attribute, arcAttribute), this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb), doFill && (fillCb ? fillCb(context, arc.attribute, arcAttribute) : fVisible && (context.setCommonStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.fill())), doStroke && isFullStroke && (strokeCb ? strokeCb(context, arc.attribute, arcAttribute) : sVisible && (context.setStrokeStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.stroke()))), !isFullStroke && doStroke) {
12641
+ if (doFill || isFullStroke) {
12642
+ context.beginPath(), drawArcPath$1(arc, context, x, y, outerRadius, innerRadius), beforeRenderContribitionsRuned = !0, context.setShadowBlendStyle && context.setShadowBlendStyle(arc, arc.attribute, arcAttribute), this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb);
12643
+ const _runFill = () => {
12644
+ doFill && (fillCb ? fillCb(context, arc.attribute, arcAttribute) : fVisible && (context.setCommonStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.fill()));
12645
+ },
12646
+ _runStroke = () => {
12647
+ doStroke && isFullStroke && (strokeCb ? strokeCb(context, arc.attribute, arcAttribute) : sVisible && (context.setStrokeStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.stroke()));
12648
+ };
12649
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke());
12650
+ }
12651
+ if (!isFullStroke && doStroke) {
12540
12652
  context.beginPath();
12541
12653
  drawArcPath$1(arc, context, x, y, outerRadius, innerRadius, arrayStroke);
12542
12654
  beforeRenderContribitionsRuned || this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb), strokeCb ? strokeCb(context, arc.attribute, arcAttribute) : sVisible && (context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute), context.stroke());
@@ -12554,14 +12666,20 @@ let DefaultCanvasArcRender = class extends BaseRender {
12554
12666
  fill = arcAttribute.fill
12555
12667
  } = arc.attribute,
12556
12668
  startAngle = endAngle;
12557
- if (this.drawArcTailCapPath(arc, context, x, y, outerRadius, innerRadius, startAngle, startAngle + capAngle), beforeRenderContribitionsRuned || this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb), doFill) {
12558
- const color = fill;
12559
- if ("conical" === color.gradient) {
12560
- const lastColor = getConicGradientAt(0, 0, endAngle, color);
12561
- fillCb || fillVisible && (context.setCommonStyle(arc, arc.attribute, x, y, arcAttribute), context.fillStyle = lastColor, context.fill());
12562
- }
12563
- }
12564
- doStroke && (strokeCb || sVisible && (context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute), context.stroke()));
12669
+ this.drawArcTailCapPath(arc, context, x, y, outerRadius, innerRadius, startAngle, startAngle + capAngle), beforeRenderContribitionsRuned || this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb);
12670
+ const _runFill = () => {
12671
+ if (doFill) {
12672
+ const color = fill;
12673
+ if ("conical" === color.gradient) {
12674
+ const lastColor = getConicGradientAt(0, 0, endAngle, color);
12675
+ fillCb || fillVisible && (context.setCommonStyle(arc, arc.attribute, x, y, arcAttribute), context.fillStyle = lastColor, context.fill());
12676
+ }
12677
+ }
12678
+ },
12679
+ _runStroke = () => {
12680
+ doStroke && (strokeCb || sVisible && (context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute), context.stroke()));
12681
+ };
12682
+ _runFill(), _runStroke();
12565
12683
  }
12566
12684
  }
12567
12685
  this.afterRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb), tempChangeConicalColor && (fill.startAngle += conicalOffset, fill.endAngle += conicalOffset);
@@ -12599,7 +12717,8 @@ let DefaultCanvasCircleRender = class extends BaseRender {
12599
12717
  startAngle = circleAttribute.startAngle,
12600
12718
  endAngle = circleAttribute.endAngle,
12601
12719
  x: originX = circleAttribute.x,
12602
- y: originY = circleAttribute.y
12720
+ y: originY = circleAttribute.y,
12721
+ fillStrokeOrder = circleAttribute.fillStrokeOrder
12603
12722
  } = circle.attribute,
12604
12723
  data = this.valid(circle, circleAttribute, fillCb, strokeCb);
12605
12724
  if (!data) return;
@@ -12609,7 +12728,14 @@ let DefaultCanvasCircleRender = class extends BaseRender {
12609
12728
  doFill: doFill,
12610
12729
  doStroke: doStroke
12611
12730
  } = data;
12612
- context.beginPath(), context.arc(x, y, radius, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), this.beforeRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb), doFill && (fillCb ? fillCb(context, circle.attribute, circleAttribute) : fVisible && (context.setCommonStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute), context.fill())), doStroke && (strokeCb ? strokeCb(context, circle.attribute, circleAttribute) : sVisible && (context.setStrokeStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute), context.stroke())), this.afterRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb);
12731
+ context.beginPath(), context.arc(x, y, radius, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), this.beforeRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb);
12732
+ const _runFill = () => {
12733
+ doFill && (fillCb ? fillCb(context, circle.attribute, circleAttribute) : fVisible && (context.setCommonStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute), context.fill()));
12734
+ },
12735
+ _runStroke = () => {
12736
+ doStroke && (strokeCb ? strokeCb(context, circle.attribute, circleAttribute) : sVisible && (context.setStrokeStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute), context.stroke()));
12737
+ };
12738
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb);
12613
12739
  }
12614
12740
  draw(circle, renderService, drawContext, params) {
12615
12741
  const circleAttribute = getTheme(circle, null == params ? void 0 : params.theme).circle;
@@ -13050,7 +13176,7 @@ let DefaultCanvasAreaRender = class extends BaseRender {
13050
13176
  super(), this.areaRenderContribitions = areaRenderContribitions, this.numberType = AREA_NUMBER_TYPE, this.builtinContributions = [defaultAreaTextureRenderContribution, defaultAreaBackgroundRenderContribution], this.init(areaRenderContribitions);
13051
13177
  }
13052
13178
  drawLinearAreaHighPerformance(area, context, fill, stroke, fillOpacity, strokeOpacity, offsetX, offsetY, areaAttribute, drawContext, params, fillCb, strokeCb) {
13053
- var _a, _b, _c, _d, _e;
13179
+ var _a, _b, _c;
13054
13180
  const {
13055
13181
  points: points
13056
13182
  } = area.attribute;
@@ -13074,28 +13200,31 @@ let DefaultCanvasAreaRender = class extends BaseRender {
13074
13200
  x: originX = 0,
13075
13201
  x: originY = 0
13076
13202
  } = area.attribute;
13077
- if (!1 !== fill && (fillCb ? fillCb(context, area.attribute, areaAttribute) : fillOpacity && (context.setCommonStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute), context.fill())), this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, !1, fill, !1, areaAttribute, drawContext, fillCb, null, {
13203
+ !1 !== fill && (fillCb ? fillCb(context, area.attribute, areaAttribute) : fillOpacity && (context.setCommonStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute), context.fill())), this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, !1, fill, !1, areaAttribute, drawContext, fillCb, null, {
13078
13204
  attribute: area.attribute
13079
- }), stroke) {
13080
- const {
13081
- stroke = areaAttribute && areaAttribute.stroke
13082
- } = area.attribute;
13083
- if (isArray$1(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1]) if (context.beginPath(), stroke[0]) {
13084
- context.moveTo(startP.x + offsetX, startP.y + offsetY, z);
13085
- for (let i = 1; i < points.length; i++) {
13086
- const p = points[i];
13087
- context.lineTo(p.x + offsetX, p.y + offsetY, z);
13088
- }
13089
- } else if (stroke[2]) {
13090
- const endP = points[points.length - 1];
13091
- context.moveTo(endP.x + offsetX, endP.y + offsetY, z);
13092
- for (let i = points.length - 2; i >= 0; i--) {
13093
- const p = points[i];
13094
- context.lineTo((null !== (_d = p.x1) && void 0 !== _d ? _d : p.x) + offsetX, (null !== (_e = p.y1) && void 0 !== _e ? _e : p.y) + offsetY, z);
13205
+ }), (() => {
13206
+ var _a, _b;
13207
+ if (stroke) {
13208
+ const {
13209
+ stroke = areaAttribute && areaAttribute.stroke
13210
+ } = area.attribute;
13211
+ if (isArray$1(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1]) if (context.beginPath(), stroke[0]) {
13212
+ context.moveTo(startP.x + offsetX, startP.y + offsetY, z);
13213
+ for (let i = 1; i < points.length; i++) {
13214
+ const p = points[i];
13215
+ context.lineTo(p.x + offsetX, p.y + offsetY, z);
13216
+ }
13217
+ } else if (stroke[2]) {
13218
+ const endP = points[points.length - 1];
13219
+ context.moveTo(endP.x + offsetX, endP.y + offsetY, z);
13220
+ for (let i = points.length - 2; i >= 0; i--) {
13221
+ const p = points[i];
13222
+ context.lineTo((null !== (_a = p.x1) && void 0 !== _a ? _a : p.x) + offsetX, (null !== (_b = p.y1) && void 0 !== _b ? _b : p.y) + offsetY, z);
13223
+ }
13095
13224
  }
13225
+ strokeCb ? strokeCb(context, area.attribute, areaAttribute) : (context.setStrokeStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute), context.stroke());
13096
13226
  }
13097
- strokeCb ? strokeCb(context, area.attribute, areaAttribute) : (context.setStrokeStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute), context.stroke());
13098
- }
13227
+ })();
13099
13228
  }
13100
13229
  drawShape(area, context, x, y, drawContext, params, fillCb, strokeCb) {
13101
13230
  var _a, _b, _c, _d, _e, _f;
@@ -13260,23 +13389,24 @@ let DefaultCanvasAreaRender = class extends BaseRender {
13260
13389
  x: originX = 0,
13261
13390
  x: originY = 0
13262
13391
  } = attribute;
13263
- if (!1 !== fill && (fillCb ? fillCb(context, attribute, defaultAttribute) : fillOpacity && (context.setCommonStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute), context.fill())), this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, !1, fill, !1, defaultAttribute, drawContext, fillCb, null, {
13392
+ return !1 !== fill && (fillCb ? fillCb(context, attribute, defaultAttribute) : fillOpacity && (context.setCommonStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute), context.fill())), this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, !1, fill, !1, defaultAttribute, drawContext, fillCb, null, {
13264
13393
  attribute: attribute
13265
- }), !1 !== stroke) if (strokeCb) strokeCb(context, attribute, defaultAttribute);else {
13266
- const {
13267
- stroke = defaultAttribute && defaultAttribute[1] && defaultAttribute[1].stroke
13268
- } = attribute;
13269
- isArray$1(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1] && (context.beginPath(), drawSegments(context.camera ? context : context.nativeContext, stroke[0] ? cache.top : cache.bottom, clipRange, direction === Direction$1.ROW ? "x" : "y", {
13270
- offsetX: offsetX,
13271
- offsetY: offsetY,
13272
- offsetZ: offsetZ,
13273
- drawConnect: connect,
13274
- mode: connectedType,
13275
- zeroX: connectedX,
13276
- zeroY: connectedY
13277
- })), context.setStrokeStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute), context.stroke();
13278
- }
13279
- return !1;
13394
+ }), (() => {
13395
+ if (!1 !== stroke) if (strokeCb) strokeCb(context, attribute, defaultAttribute);else {
13396
+ const {
13397
+ stroke = defaultAttribute && defaultAttribute[1] && defaultAttribute[1].stroke
13398
+ } = attribute;
13399
+ isArray$1(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1] && (context.beginPath(), drawSegments(context.camera ? context : context.nativeContext, stroke[0] ? cache.top : cache.bottom, clipRange, direction === Direction$1.ROW ? "x" : "y", {
13400
+ offsetX: offsetX,
13401
+ offsetY: offsetY,
13402
+ offsetZ: offsetZ,
13403
+ drawConnect: connect,
13404
+ mode: connectedType,
13405
+ zeroX: connectedX,
13406
+ zeroY: connectedY
13407
+ })), context.setStrokeStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute), context.stroke();
13408
+ }
13409
+ })(), !1;
13280
13410
  }
13281
13411
  };
13282
13412
  DefaultCanvasAreaRender = __decorate$1v([injectable(), __param$N(0, inject(ContributionProvider)), __param$N(0, named(AreaRenderContribution)), __metadata$19("design:paramtypes", [Object])], DefaultCanvasAreaRender);
@@ -13308,7 +13438,8 @@ let DefaultCanvasPathRender = class extends BaseRender {
13308
13438
  const pathAttribute = null !== (_a = this.tempTheme) && void 0 !== _a ? _a : getTheme(path, null == params ? void 0 : params.theme).path,
13309
13439
  {
13310
13440
  x: originX = pathAttribute.x,
13311
- y: originY = pathAttribute.y
13441
+ y: originY = pathAttribute.y,
13442
+ fillStrokeOrder = pathAttribute.fillStrokeOrder
13312
13443
  } = path.attribute,
13313
13444
  z = null !== (_b = this.z) && void 0 !== _b ? _b : 0,
13314
13445
  data = this.valid(path, pathAttribute, fillCb, strokeCb);
@@ -13323,7 +13454,14 @@ let DefaultCanvasPathRender = class extends BaseRender {
13323
13454
  const path2D = null !== (_c = path.attribute.path) && void 0 !== _c ? _c : pathAttribute.path;
13324
13455
  renderCommandList(path2D.commandList, context, x, y, 1, 1, z);
13325
13456
  }
13326
- context.setShadowBlendStyle && context.setShadowBlendStyle(path, path.attribute, pathAttribute), this.beforeRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb), doStroke && (strokeCb ? strokeCb(context, path.attribute, pathAttribute) : sVisible && (context.setStrokeStyle(path, path.attribute, originX - x, originY - y, pathAttribute), context.stroke())), doFill && (fillCb ? fillCb(context, path.attribute, pathAttribute) : fVisible && (context.setCommonStyle(path, path.attribute, originX - x, originY - y, pathAttribute), context.fill())), this.afterRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb);
13457
+ context.setShadowBlendStyle && context.setShadowBlendStyle(path, path.attribute, pathAttribute), this.beforeRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb);
13458
+ const _runStroke = () => {
13459
+ doStroke && (strokeCb ? strokeCb(context, path.attribute, pathAttribute) : sVisible && (context.setStrokeStyle(path, path.attribute, originX - x, originY - y, pathAttribute), context.stroke()));
13460
+ },
13461
+ _runFill = () => {
13462
+ doFill && (fillCb ? fillCb(context, path.attribute, pathAttribute) : fVisible && (context.setCommonStyle(path, path.attribute, originX - x, originY - y, pathAttribute), context.fill()));
13463
+ };
13464
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb);
13327
13465
  }
13328
13466
  draw(path, renderService, drawContext, params) {
13329
13467
  const pathAttribute = getTheme(path, null == params ? void 0 : params.theme).path;
@@ -13367,7 +13505,8 @@ let DefaultCanvasRectRender = class extends BaseRender {
13367
13505
  x1: x1,
13368
13506
  y1: y1,
13369
13507
  x: originX = rectAttribute.x,
13370
- y: originY = rectAttribute.y
13508
+ y: originY = rectAttribute.y,
13509
+ fillStrokeOrder = rectAttribute.fillStrokeOrder
13371
13510
  } = rect.attribute;
13372
13511
  let {
13373
13512
  width: width,
@@ -13386,7 +13525,14 @@ let DefaultCanvasRectRender = class extends BaseRender {
13386
13525
  doFill: doFill,
13387
13526
  doStroke: doStroke
13388
13527
  };
13389
- context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute), this.beforeRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb, doFillOrStroke), doFillOrStroke.doFill && (fillCb ? fillCb(context, rect.attribute, rectAttribute) : fVisible && (context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute), context.fill())), doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, rect.attribute, rectAttribute) : sVisible && (context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute), context.stroke())), this.afterRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
13528
+ context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute), this.beforeRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb, doFillOrStroke);
13529
+ const _runFill = () => {
13530
+ doFillOrStroke.doFill && (fillCb ? fillCb(context, rect.attribute, rectAttribute) : fVisible && (context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute), context.fill()));
13531
+ },
13532
+ _runStroke = () => {
13533
+ doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, rect.attribute, rectAttribute) : sVisible && (context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute), context.stroke()));
13534
+ };
13535
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
13390
13536
  }
13391
13537
  draw(rect, renderService, drawContext, params) {
13392
13538
  const rectAttribute = getTheme(rect, null == params ? void 0 : params.theme).rect;
@@ -13422,7 +13568,8 @@ let DefaultCanvasSymbolRender = class extends BaseRender {
13422
13568
  x: originX = symbolAttribute.x,
13423
13569
  y: originY = symbolAttribute.y,
13424
13570
  scaleX = symbolAttribute.scaleX,
13425
- scaleY = symbolAttribute.scaleY
13571
+ scaleY = symbolAttribute.scaleY,
13572
+ fillStrokeOrder = symbolAttribute.fillStrokeOrder
13426
13573
  } = symbol.attribute,
13427
13574
  data = this.valid(symbol, symbolAttribute, fillCb, strokeCb);
13428
13575
  if (!data) return;
@@ -13445,14 +13592,27 @@ let DefaultCanvasSymbolRender = class extends BaseRender {
13445
13592
  const obj = Object.assign({}, a);
13446
13593
  obj.fill = null !== (_a = a.fill) && void 0 !== _a ? _a : symbol.attribute.fill, obj.opacity = null !== (_b = a.opacity) && void 0 !== _b ? _b : symbol.attribute.opacity, obj.fillOpacity = symbol.attribute.fillOpacity, obj.stroke = null !== (_c = a.stroke) && void 0 !== _c ? _c : symbol.attribute.stroke, a = obj;
13447
13594
  }
13448
- a.fill && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : (context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute), context.fill())), a.stroke && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : (context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute), context.stroke()));
13595
+ const _runFill = () => {
13596
+ a.fill && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : (context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute), context.fill()));
13597
+ },
13598
+ _runStroke = () => {
13599
+ a.stroke && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : (context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute), context.stroke()));
13600
+ };
13601
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke());
13449
13602
  };
13450
13603
  if (keepDirIn3d && context.camera && context.project) {
13451
13604
  const p = context.project(x, y, z),
13452
13605
  camera = context.camera;
13453
13606
  context.camera = null, !1 === parsedPath.draw(context, isArray$1(size) ? [size[0] * scaleX, size[1] * scaleY] : size * scaleX, p.x, p.y, void 0, callback) && context.closePath(), context.camera = camera;
13454
13607
  } else !1 === parsedPath.draw(context, size, x, y, z, callback) && context.closePath();
13455
- context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), this.beforeRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb), doFill && !parsedPath.isSvg && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : fVisible && (context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute), context.fill())), doStroke && !parsedPath.isSvg && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : sVisible && (context.setStrokeStyle(symbol, symbol.attribute, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute), context.stroke())), this.afterRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
13608
+ context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), this.beforeRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
13609
+ const _runFill = () => {
13610
+ doFill && !parsedPath.isSvg && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : fVisible && (context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute), context.fill()));
13611
+ },
13612
+ _runStroke = () => {
13613
+ doStroke && !parsedPath.isSvg && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : sVisible && (context.setStrokeStyle(symbol, symbol.attribute, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute), context.stroke()));
13614
+ };
13615
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
13456
13616
  }
13457
13617
  draw(symbol, renderService, drawContext, params) {
13458
13618
  const symbolAttribute = getTheme(symbol, null == params ? void 0 : params.theme).symbol;
@@ -13630,77 +13790,50 @@ let DefaultCanvasTextRender = class extends BaseRender {
13630
13790
  }
13631
13791
  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());
13632
13792
  };
13633
- if (text.isMultiLine) {
13634
- if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
13635
- const {
13636
- multilineLayout: multilineLayout
13637
- } = text;
13638
- if (!multilineLayout) return void context.highPerformanceRestore();
13639
- const {
13640
- xOffset: xOffset,
13641
- yOffset: yOffset
13642
- } = multilineLayout.bbox;
13643
- doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
13644
- context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
13645
- }))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
13646
- 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, {
13647
- width: line.width
13648
- });
13649
- })));
13650
- } else {
13651
- text.tryUpdateAABBBounds();
13652
- const cache = text.cache,
13653
- {
13654
- verticalList: verticalList
13655
- } = cache;
13656
- context.textAlign = "left", context.textBaseline = "top";
13657
- const totalHeight = lineHeight * verticalList.length;
13658
- let totalW = 0;
13659
- verticalList.forEach(verticalData => {
13660
- const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
13661
- totalW = max(_w, totalW);
13662
- });
13663
- let offsetY = 0,
13664
- offsetX = 0;
13665
- "bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
13666
- const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
13667
- dw = totalW - currentW;
13668
- let currentOffsetY = offsetY;
13669
- "center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
13670
- const {
13671
- text: text,
13672
- width: width,
13673
- direction: direction
13674
- } = item;
13675
- drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
13676
- });
13793
+ if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
13794
+ const {
13795
+ multilineLayout: multilineLayout
13796
+ } = text;
13797
+ if (!multilineLayout) return void context.highPerformanceRestore();
13798
+ const {
13799
+ xOffset: xOffset,
13800
+ yOffset: yOffset
13801
+ } = multilineLayout.bbox;
13802
+ doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
13803
+ context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
13804
+ }))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
13805
+ 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, {
13806
+ width: line.width
13677
13807
  });
13678
- }
13679
- } else if ("horizontal" === direction) {
13680
- context.setTextStyle(text.attribute, textAttribute, z);
13681
- const t = text.clipedText;
13682
- let dy = 0;
13683
- lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)), drawText(t, 0, dy, 0);
13808
+ })));
13684
13809
  } else {
13685
13810
  text.tryUpdateAABBBounds();
13686
- const cache = text.cache;
13687
- if (cache) {
13688
- context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
13689
- const {
13811
+ const cache = text.cache,
13812
+ {
13690
13813
  verticalList: verticalList
13691
13814
  } = cache;
13692
- let offsetY = 0;
13693
- const totalW = verticalList[0].reduce((a, b) => a + (b.width || 0), 0);
13694
- let offsetX = 0;
13695
- "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 => {
13815
+ context.textAlign = "left", context.textBaseline = "top";
13816
+ const totalHeight = lineHeight * verticalList.length;
13817
+ let totalW = 0;
13818
+ verticalList.forEach(verticalData => {
13819
+ const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
13820
+ totalW = max(_w, totalW);
13821
+ });
13822
+ let offsetY = 0,
13823
+ offsetX = 0;
13824
+ "bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
13825
+ const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
13826
+ dw = totalW - currentW;
13827
+ let currentOffsetY = offsetY;
13828
+ "center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
13696
13829
  const {
13697
13830
  text: text,
13698
13831
  width: width,
13699
13832
  direction: direction
13700
13833
  } = item;
13701
- drawText(text, offsetX, offsetY, direction), offsetY += width;
13834
+ drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
13702
13835
  });
13703
- }
13836
+ });
13704
13837
  }
13705
13838
  transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context), this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
13706
13839
  }
@@ -13839,7 +13972,8 @@ let DefaultCanvasPolygonRender = class extends BaseRender {
13839
13972
  cornerRadius = polygonAttribute.cornerRadius,
13840
13973
  x: originX = polygonAttribute.x,
13841
13974
  y: originY = polygonAttribute.y,
13842
- closePath = polygonAttribute.closePath
13975
+ closePath = polygonAttribute.closePath,
13976
+ fillStrokeOrder = polygonAttribute.fillStrokeOrder
13843
13977
  } = polygon.attribute,
13844
13978
  data = this.valid(polygon, polygonAttribute, fillCb, strokeCb);
13845
13979
  if (!data) return;
@@ -13849,7 +13983,14 @@ let DefaultCanvasPolygonRender = class extends BaseRender {
13849
13983
  doFill: doFill,
13850
13984
  doStroke: doStroke
13851
13985
  } = data;
13852
- context.beginPath(), cornerRadius <= 0 || isArray$1(cornerRadius) && cornerRadius.every(num => 0 === num) ? drawPolygon(context.camera ? context : context.nativeContext, points, x, y) : drawRoundedPolygon(context.camera ? context : context.nativeContext, points, x, y, cornerRadius, closePath), closePath && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(polygon, polygon.attribute, polygonAttribute), this.beforeRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb), doFill && (fillCb ? fillCb(context, polygon.attribute, polygonAttribute) : fVisible && (context.setCommonStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute), context.fill())), doStroke && (strokeCb ? strokeCb(context, polygon.attribute, polygonAttribute) : sVisible && (context.setStrokeStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute), context.stroke())), this.afterRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb);
13986
+ context.beginPath(), cornerRadius <= 0 || isArray$1(cornerRadius) && cornerRadius.every(num => 0 === num) ? drawPolygon(context.camera ? context : context.nativeContext, points, x, y) : drawRoundedPolygon(context.camera ? context : context.nativeContext, points, x, y, cornerRadius, closePath), closePath && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(polygon, polygon.attribute, polygonAttribute), this.beforeRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb);
13987
+ const _runFill = () => {
13988
+ doFill && (fillCb ? fillCb(context, polygon.attribute, polygonAttribute) : fVisible && (context.setCommonStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute), context.fill()));
13989
+ },
13990
+ _runStroke = () => {
13991
+ doStroke && (strokeCb ? strokeCb(context, polygon.attribute, polygonAttribute) : sVisible && (context.setStrokeStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute), context.stroke()));
13992
+ };
13993
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb);
13853
13994
  }
13854
13995
  draw(polygon, renderService, drawContext, params) {
13855
13996
  const polygonAttribute = getTheme(polygon, null == params ? void 0 : params.theme).polygon;
@@ -13892,7 +14033,10 @@ let DefaultCanvasGroupRender = class {
13892
14033
  cornerRadius = groupAttribute.cornerRadius,
13893
14034
  path = groupAttribute.path,
13894
14035
  lineWidth = groupAttribute.lineWidth,
13895
- visible = groupAttribute.visible
14036
+ visible = groupAttribute.visible,
14037
+ fillStrokeOrder = groupAttribute.fillStrokeOrder,
14038
+ x: originX = groupAttribute.x,
14039
+ y: originY = groupAttribute.y
13896
14040
  } = group.attribute,
13897
14041
  fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill),
13898
14042
  sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height),
@@ -13918,7 +14062,14 @@ let DefaultCanvasGroupRender = class {
13918
14062
  };
13919
14063
  this._groupRenderContribitions.forEach(c => {
13920
14064
  c.time === BaseRenderContributionTime.beforeFillStroke && c.drawShape(group, context, x, y, doFill, doStroke, fVisible, sVisible, groupAttribute, drawContext, fillCb, strokeCb, doFillOrStroke);
13921
- }), clip && context.clip(), context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute), doFillOrStroke.doFill && (fillCb ? fillCb(context, group.attribute, groupAttribute) : fVisible && (context.setCommonStyle(group, group.attribute, x, y, groupAttribute), context.fill())), doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, group.attribute, groupAttribute) : sVisible && (context.setStrokeStyle(group, group.attribute, x, y, groupAttribute), context.stroke())), this._groupRenderContribitions.forEach(c => {
14065
+ }), clip && context.clip(), context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute);
14066
+ const _runFill = () => {
14067
+ doFillOrStroke.doFill && (fillCb ? fillCb(context, group.attribute, groupAttribute) : fVisible && (context.setCommonStyle(group, group.attribute, originX - x, originY - y, groupAttribute), context.fill()));
14068
+ },
14069
+ _runStroke = () => {
14070
+ doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, group.attribute, groupAttribute) : sVisible && (context.setStrokeStyle(group, group.attribute, originX - x, originY - y, groupAttribute), context.stroke()));
14071
+ };
14072
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this._groupRenderContribitions.forEach(c => {
13922
14073
  c.time === BaseRenderContributionTime.afterFillStroke && c.drawShape(group, context, x, y, doFill, doStroke, fVisible, sVisible, groupAttribute, drawContext, fillCb, strokeCb);
13923
14074
  });
13924
14075
  }
@@ -13984,6 +14135,7 @@ let DefaultCanvasImageRender = class extends BaseRender {
13984
14135
  x: originX = imageAttribute.x,
13985
14136
  y: originY = imageAttribute.y,
13986
14137
  cornerRadius = imageAttribute.cornerRadius,
14138
+ fillStrokeOrder = imageAttribute.fillStrokeOrder,
13987
14139
  image: url
13988
14140
  } = image.attribute,
13989
14141
  data = this.valid(image, imageAttribute, fillCb);
@@ -13994,20 +14146,26 @@ let DefaultCanvasImageRender = class extends BaseRender {
13994
14146
  doFill: doFill,
13995
14147
  doStroke: doStroke
13996
14148
  } = data;
13997
- if (context.setShadowBlendStyle && context.setShadowBlendStyle(image, imageAttribute), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb), doFill) if (fillCb) fillCb(context, image.attribute, imageAttribute);else if (fVisible) {
13998
- if (!url || !image.resources) return;
13999
- const res = image.resources.get(url);
14000
- if ("success" !== res.state) return;
14001
- let needRestore = !1;
14002
- 0 === cornerRadius || isArray$1(cornerRadius) && cornerRadius.every(num => 0 === num) || (context.beginPath(), createRectPath(context, x, y, width, height, cornerRadius), context.save(), context.clip(), needRestore = !0), context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
14003
- let repeat = 0;
14004
- if ("repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat) {
14005
- const pattern = context.createPattern(res.data, repeatStr[repeat]);
14006
- context.fillStyle = pattern, context.translate(x, y, !0), context.fillRect(0, 0, width, height), context.translate(-x, -y, !0);
14007
- } else context.drawImage(res.data, x, y, width, height);
14008
- needRestore && context.restore();
14009
- }
14010
- doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute), context.stroke())), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
14149
+ context.setShadowBlendStyle && context.setShadowBlendStyle(image, imageAttribute), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
14150
+ const _runFill = () => {
14151
+ if (doFill) if (fillCb) fillCb(context, image.attribute, imageAttribute);else if (fVisible) {
14152
+ if (!url || !image.resources) return;
14153
+ const res = image.resources.get(url);
14154
+ if ("success" !== res.state) return;
14155
+ let needRestore = !1;
14156
+ 0 === cornerRadius || isArray$1(cornerRadius) && cornerRadius.every(num => 0 === num) || (context.beginPath(), createRectPath(context, x, y, width, height, cornerRadius), context.save(), context.clip(), needRestore = !0), context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
14157
+ let repeat = 0;
14158
+ if ("repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat) {
14159
+ const pattern = context.createPattern(res.data, repeatStr[repeat]);
14160
+ context.fillStyle = pattern, context.translate(x, y, !0), context.fillRect(0, 0, width, height), context.translate(-x, -y, !0);
14161
+ } else context.drawImage(res.data, x, y, width, height);
14162
+ needRestore && context.restore();
14163
+ }
14164
+ },
14165
+ _runStroke = () => {
14166
+ doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute), context.stroke()));
14167
+ };
14168
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
14011
14169
  }
14012
14170
  draw(image, renderService, drawContext) {
14013
14171
  const {
@@ -14408,28 +14566,6 @@ class CanvasTextLayout {
14408
14566
  }
14409
14567
  return bbox.yOffset = "top" === textBaseline ? 0 : "middle" === textBaseline ? bbox.height / -2 : "alphabetic" === textBaseline ? -.79 * bbox.height : -bbox.height, bbox;
14410
14568
  }
14411
- GetLayout(str, width, height, textAlign, textBaseline, lineHeight, suffix, wordBreak, suffixPosition) {
14412
- const linesLayout = [],
14413
- bboxWH = [width, height],
14414
- bboxOffset = [0, 0];
14415
- for (; str.length > 0;) {
14416
- const {
14417
- str: clipText
14418
- } = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
14419
- linesLayout.push({
14420
- str: clipText,
14421
- width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
14422
- }), str = str.substring(clipText.length);
14423
- }
14424
- "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]));
14425
- const bbox = {
14426
- xOffset: bboxOffset[0],
14427
- yOffset: bboxOffset[1],
14428
- width: bboxWH[0],
14429
- height: bboxWH[1]
14430
- };
14431
- return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
14432
- }
14433
14569
  GetLayoutByLines(lines, textAlign, textBaseline, lineHeight) {
14434
14570
  let suffix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
14435
14571
  let wordBreak = arguments.length > 5 ? arguments[5] : undefined;
@@ -14440,18 +14576,29 @@ class CanvasTextLayout {
14440
14576
  bboxWH = [0, 0];
14441
14577
  if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
14442
14578
  let width;
14443
- for (let i = 0, len = lines.length; i < len; i++) width = Math.min(this.textMeasure.measureTextWidth(lines[i], this.textOptions), lineWidth), linesLayout.push({
14444
- str: this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
14445
- width: width
14446
- });
14579
+ for (let i = 0, len = lines.length; i < len; i++) {
14580
+ const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions);
14581
+ width = Math.min(metrics.width, lineWidth), linesLayout.push({
14582
+ str: this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
14583
+ width: width,
14584
+ ascent: metrics.ascent,
14585
+ descent: metrics.descent
14586
+ });
14587
+ }
14447
14588
  bboxWH[0] = lineWidth;
14448
14589
  } else {
14449
14590
  let width, text;
14450
14591
  lineWidth = 0;
14451
- 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({
14452
- str: text,
14453
- width: width
14454
- });
14592
+ for (let i = 0, len = lines.length; i < len; i++) {
14593
+ text = lines[i];
14594
+ const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions);
14595
+ width = metrics.width, lineWidth = Math.max(lineWidth, width), linesLayout.push({
14596
+ str: text,
14597
+ width: width,
14598
+ ascent: metrics.ascent,
14599
+ descent: metrics.descent
14600
+ });
14601
+ }
14455
14602
  bboxWH[0] = lineWidth;
14456
14603
  }
14457
14604
  bboxWH[1] = linesLayout.length * lineHeight, bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);
@@ -14480,11 +14627,11 @@ class CanvasTextLayout {
14480
14627
  };
14481
14628
  }
14482
14629
  lineOffset(bbox, line, textAlign, textBaseline, lineHeight, origin) {
14483
- 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;
14630
+ 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;
14484
14631
  }
14485
14632
  }
14486
14633
 
14487
- const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
14634
+ 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];
14488
14635
  class Text extends Graphic {
14489
14636
  get font() {
14490
14637
  const textTheme = this.getGraphicTheme();
@@ -14493,26 +14640,22 @@ class Text extends Graphic {
14493
14640
  get clipedText() {
14494
14641
  var _a;
14495
14642
  const attribute = this.attribute,
14496
- textTheme = this.getGraphicTheme();
14497
- if (!this.isSimplify()) return;
14498
- const {
14499
- maxLineWidth = textTheme.maxLineWidth
14500
- } = attribute;
14501
- return Number.isFinite(maxLineWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
14643
+ textTheme = this.getGraphicTheme(),
14644
+ maxWidth = this.getMaxWidth(textTheme);
14645
+ return Number.isFinite(maxWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
14502
14646
  }
14503
14647
  get clipedWidth() {
14504
- if (this.isSimplify()) return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
14648
+ return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
14505
14649
  }
14506
14650
  get cliped() {
14507
14651
  var _a, _b;
14508
14652
  const textTheme = this.getGraphicTheme(),
14509
14653
  attribute = this.attribute,
14510
- {
14511
- maxLineWidth = textTheme.maxLineWidth,
14512
- text: text,
14513
- whiteSpace = textTheme.whiteSpace
14514
- } = attribute;
14515
- if (!Number.isFinite(maxLineWidth)) return !1;
14654
+ maxWidth = this.getMaxWidth(textTheme);
14655
+ if (!Number.isFinite(maxWidth)) return !1;
14656
+ const {
14657
+ text: text
14658
+ } = this.attribute;
14516
14659
  if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
14517
14660
  let mergedText = "";
14518
14661
  this.cache.layoutData.lines.forEach(item => {
@@ -14523,10 +14666,7 @@ class Text extends Graphic {
14523
14666
  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();
14524
14667
  }
14525
14668
  get multilineLayout() {
14526
- if (this.isMultiLine) return this.tryUpdateAABBBounds(), this.cache.layoutData;
14527
- }
14528
- isSimplify() {
14529
- return !this.isMultiLine && "vertical" !== this.attribute.direction;
14669
+ return this.tryUpdateAABBBounds(), this.cache.layoutData;
14530
14670
  }
14531
14671
  get isMultiLine() {
14532
14672
  return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
@@ -14599,8 +14739,63 @@ class Text extends Graphic {
14599
14739
  }
14600
14740
  return application.graphicService.combindShadowAABBBounds(aabbBounds, this), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds), transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix), aabbBounds;
14601
14741
  }
14742
+ updateSingallineAABBBounds(text) {
14743
+ this.updateMultilineAABBBounds([text]);
14744
+ const layoutData = this.cache.layoutData;
14745
+ if (layoutData) {
14746
+ const line = layoutData.lines[0];
14747
+ this.cache.clipedText = line.str, this.cache.clipedWidth = line.width;
14748
+ }
14749
+ return this._AABBBounds;
14750
+ }
14751
+ updateMultilineAABBBounds(text) {
14752
+ const textTheme = this.getGraphicTheme(),
14753
+ {
14754
+ direction = textTheme.direction,
14755
+ underlineOffset = textTheme.underlineOffset
14756
+ } = this.attribute,
14757
+ b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
14758
+ return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
14759
+ }
14760
+ updateHorizontalMultilineAABBBounds(text) {
14761
+ var _a;
14762
+ const textTheme = this.getGraphicTheme(),
14763
+ attribute = this.attribute,
14764
+ {
14765
+ fontFamily = textTheme.fontFamily,
14766
+ textAlign = textTheme.textAlign,
14767
+ textBaseline = textTheme.textBaseline,
14768
+ fontSize = textTheme.fontSize,
14769
+ fontWeight = textTheme.fontWeight,
14770
+ ellipsis = textTheme.ellipsis,
14771
+ maxLineWidth: maxLineWidth,
14772
+ stroke = textTheme.stroke,
14773
+ wrap = textTheme.wrap,
14774
+ ignoreBuf = textTheme.ignoreBuf,
14775
+ lineWidth = textTheme.lineWidth,
14776
+ whiteSpace = textTheme.whiteSpace,
14777
+ suffixPosition = textTheme.suffixPosition
14778
+ } = attribute,
14779
+ buf = ignoreBuf ? 0 : 2,
14780
+ lineHeight = this.getLineHeight(attribute, textTheme) + buf;
14781
+ if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
14782
+ if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
14783
+ const bbox = this.cache.layoutData.bbox;
14784
+ return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14785
+ }
14786
+ const textMeasure = application.graphicUtil.textMeasure,
14787
+ layoutData = new CanvasTextLayout(fontFamily, {
14788
+ fontSize: fontSize,
14789
+ fontWeight: fontWeight,
14790
+ fontFamily: fontFamily
14791
+ }, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
14792
+ {
14793
+ bbox: bbox
14794
+ } = layoutData;
14795
+ 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;
14796
+ }
14602
14797
  updateWrapAABBBounds(text) {
14603
- var _a, _b, _c, _d;
14798
+ var _a, _b, _c;
14604
14799
  const textTheme = this.getGraphicTheme(),
14605
14800
  {
14606
14801
  fontFamily = textTheme.fontFamily,
@@ -14618,18 +14813,19 @@ class Text extends Graphic {
14618
14813
  heightLimit = 0,
14619
14814
  lineClamp: lineClamp
14620
14815
  } = this.attribute,
14621
- lineHeight = null !== (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : this.attribute.fontSize || textTheme.fontSize,
14622
- buf = ignoreBuf ? 0 : 2;
14623
- if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
14816
+ buf = ignoreBuf ? 0 : 2,
14817
+ lineHeight = this.getLineHeight(this.attribute, textTheme) + buf;
14818
+ if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
14624
14819
  const bbox = this.cache.layoutData.bbox;
14625
14820
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14626
14821
  }
14627
14822
  const textMeasure = application.graphicUtil.textMeasure,
14628
- layoutObj = new CanvasTextLayout(fontFamily, {
14823
+ textOptions = {
14629
14824
  fontSize: fontSize,
14630
14825
  fontWeight: fontWeight,
14631
14826
  fontFamily: fontFamily
14632
- }, textMeasure),
14827
+ },
14828
+ layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
14633
14829
  lines = isArray$1(text) ? text.map(l => l.toString()) : [text.toString()],
14634
14830
  linesLayout = [],
14635
14831
  bboxWH = [0, 0];
@@ -14639,29 +14835,33 @@ class Text extends Graphic {
14639
14835
  const str = lines[i];
14640
14836
  let needCut = !0;
14641
14837
  if (i === lineCountLimit - 1) {
14642
- const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1);
14838
+ const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1),
14839
+ matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
14643
14840
  linesLayout.push({
14644
14841
  str: clip.str,
14645
- width: clip.width
14842
+ width: clip.width,
14843
+ ascent: matrics.ascent,
14844
+ descent: matrics.descent
14646
14845
  });
14647
14846
  break;
14648
14847
  }
14649
- const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
14650
- if ("" !== str && "" === clip.str || clip.wordBreaked) {
14848
+ const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-word" === wordBreak);
14849
+ if ("" !== str && "" === clip.str) {
14651
14850
  if (ellipsis) {
14652
- const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
14653
- clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
14851
+ const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
14852
+ clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
14654
14853
  } else clip.str = "", clip.width = 0;
14655
14854
  needCut = !1;
14656
14855
  }
14657
- linesLayout.push({
14856
+ const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
14857
+ if (linesLayout.push({
14658
14858
  str: clip.str,
14659
- width: clip.width
14660
- });
14661
- let cutLength = clip.str.length;
14662
- if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
14663
- let newStr = str.substring(cutLength);
14664
- "keep-all" === wordBreak && (newStr = newStr.replace(/^\s+/g, "")), lines.splice(i + 1, 0, newStr);
14859
+ width: clip.width,
14860
+ ascent: matrics.ascent,
14861
+ descent: matrics.descent
14862
+ }), clip.str.length === str.length) ;else if (needCut) {
14863
+ const newStr = str.substring(clip.str.length);
14864
+ lines.splice(i + 1, 0, newStr);
14665
14865
  }
14666
14866
  }
14667
14867
  let maxWidth = 0;
@@ -14674,21 +14874,28 @@ class Text extends Graphic {
14674
14874
  lineWidth = 0;
14675
14875
  for (let i = 0, len = lines.length; i < len; i++) {
14676
14876
  if (i === lineCountLimit - 1) {
14677
- const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
14877
+ const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition),
14878
+ matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
14678
14879
  linesLayout.push({
14679
14880
  str: clip.str,
14680
- width: clip.width
14881
+ width: clip.width,
14882
+ ascent: matrics.ascent,
14883
+ descent: matrics.descent
14681
14884
  }), lineWidth = Math.max(lineWidth, clip.width);
14682
14885
  break;
14683
14886
  }
14684
- text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
14887
+ text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width);
14888
+ const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions);
14889
+ linesLayout.push({
14685
14890
  str: text,
14686
- width: width
14891
+ width: width,
14892
+ ascent: matrics.ascent,
14893
+ descent: matrics.descent
14687
14894
  });
14688
14895
  }
14689
14896
  bboxWH[0] = lineWidth;
14690
14897
  }
14691
- bboxWH[1] = linesLayout.length * (lineHeight + buf);
14898
+ bboxWH[1] = linesLayout.length * lineHeight;
14692
14899
  const bbox = {
14693
14900
  xOffset: 0,
14694
14901
  yOffset: 0,
@@ -14699,210 +14906,12 @@ class Text extends Graphic {
14699
14906
  const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
14700
14907
  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;
14701
14908
  }
14702
- updateSingallineAABBBounds(text) {
14703
- const textTheme = this.getGraphicTheme(),
14704
- {
14705
- direction = textTheme.direction,
14706
- underlineOffset = textTheme.underlineOffset
14707
- } = this.attribute,
14708
- b = "horizontal" === direction ? this.updateHorizontalSinglelineAABBBounds(text) : this.updateVerticalSinglelineAABBBounds(text);
14709
- return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
14710
- }
14711
- updateMultilineAABBBounds(text) {
14712
- const textTheme = this.getGraphicTheme(),
14713
- {
14714
- direction = textTheme.direction,
14715
- underlineOffset = textTheme.underlineOffset
14716
- } = this.attribute,
14717
- b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
14718
- return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
14719
- }
14720
- updateHorizontalSinglelineAABBBounds(text) {
14721
- var _a, _b;
14722
- const textTheme = this.getGraphicTheme(),
14723
- {
14724
- wrap = textTheme.wrap
14725
- } = this.attribute;
14726
- if (wrap) return this.updateWrapAABBBounds([text]);
14727
- const textMeasure = application.graphicUtil.textMeasure;
14728
- let width, str;
14729
- const attribute = this.attribute,
14730
- {
14731
- maxLineWidth = textTheme.maxLineWidth,
14732
- ellipsis = textTheme.ellipsis,
14733
- textAlign = textTheme.textAlign,
14734
- textBaseline = textTheme.textBaseline,
14735
- fontFamily = textTheme.fontFamily,
14736
- fontSize = textTheme.fontSize,
14737
- fontWeight = textTheme.fontWeight,
14738
- stroke = textTheme.stroke,
14739
- lineWidth = textTheme.lineWidth,
14740
- ignoreBuf = textTheme.ignoreBuf,
14741
- whiteSpace = textTheme.whiteSpace,
14742
- suffixPosition = textTheme.suffixPosition
14743
- } = attribute;
14744
- if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
14745
- const buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
14746
- textFontSize = attribute.fontSize || textTheme.fontSize,
14747
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) && void 0 !== _a ? _a : textFontSize + buf;
14748
- if (!this.shouldUpdateShape() && this.cache) {
14749
- width = null !== (_b = this.cache.clipedWidth) && void 0 !== _b ? _b : 0;
14750
- const dx = textDrawOffsetX(textAlign, width),
14751
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
14752
- return this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14753
- }
14754
- if (Number.isFinite(maxLineWidth)) {
14755
- if (ellipsis) {
14756
- const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
14757
- data = textMeasure.clipTextWithSuffix(text.toString(), {
14758
- fontSize: fontSize,
14759
- fontWeight: fontWeight,
14760
- fontFamily: fontFamily
14761
- }, maxLineWidth, strEllipsis, !1, suffixPosition);
14762
- str = data.str, width = data.width;
14763
- } else {
14764
- const data = textMeasure.clipText(text.toString(), {
14765
- fontSize: fontSize,
14766
- fontWeight: fontWeight,
14767
- fontFamily: fontFamily
14768
- }, maxLineWidth, !1);
14769
- str = data.str, width = data.width;
14770
- }
14771
- this.cache.clipedText = str, this.cache.clipedWidth = width;
14772
- } else width = textMeasure.measureTextWidth(text.toString(), {
14773
- fontSize: fontSize,
14774
- fontWeight: fontWeight,
14775
- fontFamily: fontFamily
14776
- }), this.cache.clipedText = text.toString(), this.cache.clipedWidth = width;
14777
- this.clearUpdateShapeTag();
14778
- const dx = textDrawOffsetX(textAlign, width);
14779
- let lh = lineHeight;
14780
- application.global && application.global.isSafari() && (lh += .2 * fontSize);
14781
- const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
14782
- return this._AABBBounds.set(dx, dy, dx + width, dy + lh), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14783
- }
14784
- getBaselineMapAlign() {
14785
- return Text.baselineMapAlign;
14786
- }
14787
- getAlignMapBaseline() {
14788
- return Text.alignMapBaseline;
14789
- }
14790
- updateVerticalSinglelineAABBBounds(text) {
14791
- var _a, _b, _c;
14792
- const textTheme = this.getGraphicTheme(),
14793
- textMeasure = application.graphicUtil.textMeasure;
14794
- let width;
14795
- const attribute = this.attribute,
14796
- {
14797
- ignoreBuf = textTheme.ignoreBuf
14798
- } = attribute,
14799
- buf = ignoreBuf ? 0 : 2,
14800
- {
14801
- maxLineWidth = textTheme.maxLineWidth,
14802
- ellipsis = textTheme.ellipsis,
14803
- fontSize = textTheme.fontSize,
14804
- fontWeight = textTheme.fontWeight,
14805
- fontFamily = textTheme.fontFamily,
14806
- stroke = textTheme.stroke,
14807
- lineWidth = textTheme.lineWidth,
14808
- verticalMode = textTheme.verticalMode,
14809
- suffixPosition = textTheme.suffixPosition
14810
- } = attribute,
14811
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
14812
- let {
14813
- textAlign = textTheme.textAlign,
14814
- textBaseline = textTheme.textBaseline
14815
- } = attribute;
14816
- if (!verticalMode) {
14817
- const t = textAlign;
14818
- textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
14819
- }
14820
- if (!this.shouldUpdateShape() && this.cache) {
14821
- width = this.cache.clipedWidth;
14822
- const dx = textDrawOffsetX(textAlign, width),
14823
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
14824
- return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14825
- }
14826
- let verticalList = [verticalLayout(text.toString())];
14827
- if (Number.isFinite(maxLineWidth)) {
14828
- if (ellipsis) {
14829
- const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
14830
- data = textMeasure.clipTextWithSuffixVertical(verticalList[0], {
14831
- fontSize: fontSize,
14832
- fontWeight: fontWeight,
14833
- fontFamily: fontFamily
14834
- }, maxLineWidth, strEllipsis, !1, suffixPosition);
14835
- verticalList = [data.verticalList], width = data.width;
14836
- } else {
14837
- const data = textMeasure.clipTextVertical(verticalList[0], {
14838
- fontSize: fontSize,
14839
- fontWeight: fontWeight,
14840
- fontFamily: fontFamily
14841
- }, maxLineWidth, !1);
14842
- verticalList = [data.verticalList], width = data.width;
14843
- }
14844
- this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
14845
- } else width = 0, verticalList[0].forEach(t => {
14846
- const w = t.direction === TextDirection.HORIZONTAL ? fontSize : textMeasure.measureTextWidth(t.text, {
14847
- fontSize: fontSize,
14848
- fontWeight: fontWeight,
14849
- fontFamily: fontFamily
14850
- });
14851
- width += w, t.width = w;
14852
- }), this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
14853
- this.clearUpdateShapeTag();
14854
- const dx = textDrawOffsetX(textAlign, width),
14855
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
14856
- return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14857
- }
14858
- updateHorizontalMultilineAABBBounds(text) {
14859
- var _a, _b;
14860
- const textTheme = this.getGraphicTheme(),
14861
- {
14862
- wrap = textTheme.wrap
14863
- } = this.attribute;
14864
- if (wrap) return this.updateWrapAABBBounds(text);
14865
- const attribute = this.attribute,
14866
- {
14867
- fontFamily = textTheme.fontFamily,
14868
- textAlign = textTheme.textAlign,
14869
- textBaseline = textTheme.textBaseline,
14870
- fontSize = textTheme.fontSize,
14871
- fontWeight = textTheme.fontWeight,
14872
- ellipsis = textTheme.ellipsis,
14873
- maxLineWidth: maxLineWidth,
14874
- stroke = textTheme.stroke,
14875
- lineWidth = textTheme.lineWidth,
14876
- whiteSpace = textTheme.whiteSpace,
14877
- suffixPosition = textTheme.suffixPosition
14878
- } = attribute,
14879
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
14880
- if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
14881
- if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
14882
- const bbox = this.cache.layoutData.bbox;
14883
- return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14884
- }
14885
- const textMeasure = application.graphicUtil.textMeasure,
14886
- layoutData = new CanvasTextLayout(fontFamily, {
14887
- fontSize: fontSize,
14888
- fontWeight: fontWeight,
14889
- fontFamily: fontFamily
14890
- }, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
14891
- {
14892
- bbox: bbox
14893
- } = layoutData;
14894
- 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;
14895
- }
14896
14909
  updateVerticalMultilineAABBBounds(text) {
14897
- var _a, _b, _c;
14910
+ var _a, _b;
14898
14911
  const textTheme = this.getGraphicTheme(),
14899
14912
  textMeasure = application.graphicUtil.textMeasure;
14900
14913
  let width;
14901
14914
  const attribute = this.attribute,
14902
- {
14903
- ignoreBuf = textTheme.ignoreBuf
14904
- } = attribute,
14905
- buf = ignoreBuf ? 0 : 2,
14906
14915
  {
14907
14916
  maxLineWidth = textTheme.maxLineWidth,
14908
14917
  ellipsis = textTheme.ellipsis,
@@ -14914,14 +14923,14 @@ class Text extends Graphic {
14914
14923
  verticalMode = textTheme.verticalMode,
14915
14924
  suffixPosition = textTheme.suffixPosition
14916
14925
  } = attribute,
14917
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
14926
+ lineHeight = this.getLineHeight(attribute, textTheme);
14918
14927
  let {
14919
14928
  textAlign = textTheme.textAlign,
14920
14929
  textBaseline = textTheme.textBaseline
14921
14930
  } = attribute;
14922
14931
  if (!verticalMode) {
14923
14932
  const t = textAlign;
14924
- textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
14933
+ textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
14925
14934
  }
14926
14935
  if (width = 0, !this.shouldUpdateShape() && this.cache) {
14927
14936
  this.cache.verticalList.forEach(item => {
@@ -14969,6 +14978,15 @@ class Text extends Graphic {
14969
14978
  dy = textLayoutOffsetY(textBaseline, height, fontSize);
14970
14979
  return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14971
14980
  }
14981
+ getMaxWidth(theme) {
14982
+ var _a, _b;
14983
+ const attribute = this.attribute;
14984
+ return null !== (_b = null !== (_a = attribute.maxLineWidth) && void 0 !== _a ? _a : attribute.maxWidth) && void 0 !== _b ? _b : theme.maxWidth;
14985
+ }
14986
+ getLineHeight(attribute, textTheme) {
14987
+ var _a;
14988
+ return null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
14989
+ }
14972
14990
  needUpdateTags(keys) {
14973
14991
  let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_UPDATE_TAG_KEY;
14974
14992
  return super.needUpdateTags(keys, k);
@@ -14983,6 +15001,12 @@ class Text extends Graphic {
14983
15001
  getNoWorkAnimateAttr() {
14984
15002
  return Text.NOWORK_ANIMATE_ATTR;
14985
15003
  }
15004
+ getBaselineMapAlign() {
15005
+ return Text.baselineMapAlign;
15006
+ }
15007
+ getAlignMapBaseline() {
15008
+ return Text.alignMapBaseline;
15009
+ }
14986
15010
  }
14987
15011
  Text.NOWORK_ANIMATE_ATTR = Object.assign({
14988
15012
  ellipsis: 1,
@@ -15061,7 +15085,9 @@ class WrapText extends Text {
15061
15085
  const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
15062
15086
  linesLayout.push({
15063
15087
  str: clip.str,
15064
- width: clip.width
15088
+ width: clip.width,
15089
+ ascent: 0,
15090
+ descent: 0
15065
15091
  });
15066
15092
  break;
15067
15093
  }
@@ -15075,7 +15101,9 @@ class WrapText extends Text {
15075
15101
  }
15076
15102
  if (linesLayout.push({
15077
15103
  str: clip.str,
15078
- width: clip.width
15104
+ width: clip.width,
15105
+ ascent: 0,
15106
+ descent: 0
15079
15107
  }), clip.str.length === str.length) ;else if (needCut) {
15080
15108
  const newStr = str.substring(clip.str.length);
15081
15109
  lines.splice(i + 1, 0, newStr);
@@ -15094,13 +15122,17 @@ class WrapText extends Text {
15094
15122
  const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
15095
15123
  linesLayout.push({
15096
15124
  str: clip.str,
15097
- width: clip.width
15125
+ width: clip.width,
15126
+ ascent: 0,
15127
+ descent: 0
15098
15128
  }), lineWidth = Math.max(lineWidth, clip.width);
15099
15129
  break;
15100
15130
  }
15101
15131
  text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
15102
15132
  str: text,
15103
- width: width
15133
+ width: width,
15134
+ ascent: 0,
15135
+ descent: 0
15104
15136
  });
15105
15137
  }
15106
15138
  bboxWH[0] = lineWidth;
@@ -18272,6 +18304,42 @@ class AutoRenderPlugin {
18272
18304
  }
18273
18305
  }
18274
18306
 
18307
+ class AutoRefreshPlugin {
18308
+ constructor() {
18309
+ this.name = "AutoRefreshPlugin", this.activeEvent = "onRegister", this._uid = Generator.GenAutoIncrementId(), this.key = this.name + this._uid, this.handleChange = graphic => {
18310
+ graphic.glyphHost && (graphic = graphic.glyphHost), graphic.stage === this.pluginService.stage && null != graphic.stage && graphic.stage.renderNextFrame();
18311
+ };
18312
+ }
18313
+ activate(context) {
18314
+ this.pluginService = context, this.dpr = application.global.devicePixelRatio, this.refresh();
18315
+ }
18316
+ refresh() {
18317
+ this._refreshByMediaQuery() || this._refreshByRaf();
18318
+ }
18319
+ _refreshByRaf() {
18320
+ const raf = application.global.getRequestAnimationFrame();
18321
+ this.rafId = raf(() => {
18322
+ application.global.devicePixelRatio !== this.dpr && (this.dpr = application.global.devicePixelRatio, this.pluginService.stage.setDpr(this.dpr, !0)), this.refresh();
18323
+ });
18324
+ }
18325
+ _refreshByMediaQuery() {
18326
+ try {
18327
+ const mqString = `(resolution: ${window.devicePixelRatio}dppx)`,
18328
+ updatePixelRatio = () => {
18329
+ window.devicePixelRatio !== this.dpr && (this.dpr = window.devicePixelRatio, this.pluginService.stage.setDpr(this.dpr, !0));
18330
+ };
18331
+ matchMedia(mqString).addEventListener("change", updatePixelRatio);
18332
+ } catch (err) {
18333
+ return !1;
18334
+ }
18335
+ return !0;
18336
+ }
18337
+ deactivate(context) {
18338
+ const craf = application.global.getCancelAnimationFrame();
18339
+ craf && this.rafId && craf(this.rafId);
18340
+ }
18341
+ }
18342
+
18275
18343
  class IncrementalAutoRenderPlugin {
18276
18344
  constructor() {
18277
18345
  this.name = "IncrementalAutoRenderPlugin", this.activeEvent = "onRegister", this.nextFrameRenderGroupSet = new Set(), this.willNextFrameRender = !1, this.nextUserParams = {}, this._uid = Generator.GenAutoIncrementId(), this.key = this.name + this._uid;
@@ -18474,7 +18542,7 @@ class Stage extends Group {
18474
18542
  canvas: params.canvas
18475
18543
  }), this.state = "normal", this.renderCount = 0, this.tryInitEventSystem(), this._background = null !== (_a = params.background) && void 0 !== _a ? _a : DefaultConfig$1.BACKGROUND, this.appendChild(this.layerService.createLayer(this, {
18476
18544
  main: !0
18477
- })), this.nextFrameRenderLayerSet = new Set(), this.willNextFrameRender = !1, this.stage = this, this.renderStyle = params.renderStyle, params.autoRender && this.enableAutoRender(), !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({
18545
+ })), 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({
18478
18546
  background: this._background
18479
18547
  });
18480
18548
  }
@@ -18609,6 +18677,14 @@ class Stage extends Group {
18609
18677
  this.pluginService.unRegister(plugin);
18610
18678
  }));
18611
18679
  }
18680
+ enableAutoRefresh() {
18681
+ this.autoRefresh || (this.autoRefresh = !0, this.pluginService.register(new AutoRefreshPlugin()));
18682
+ }
18683
+ disableAutoRefresh() {
18684
+ this.autoRefresh && (this.autoRefresh = !1, this.pluginService.findPluginsByName("AutoRefreshPlugin").forEach(plugin => {
18685
+ this.pluginService.unRegister(plugin);
18686
+ }));
18687
+ }
18612
18688
  enableIncrementalAutoRender() {
18613
18689
  this.increaseAutoRender || (this.increaseAutoRender = !0, this.pluginService.register(new IncrementalAutoRenderPlugin()));
18614
18690
  }
@@ -19615,27 +19691,9 @@ function simplifyRadialDist(points, sqTolerance) {
19615
19691
  for (let i = 1, len = points.length; i < len; i++) deltaX = points[i].x - lastX, deltaY = points[i].y - lastY, deltaX * deltaX + deltaY * deltaY > sqTolerance && (lastX = points[i].x, lastY = points[i].y, newPoints.push(points[i]));
19616
19692
  return points[points.length - 1].x === lastX && points[points.length - 1].y === lastY || newPoints.push(points[points.length - 1]), newPoints;
19617
19693
  }
19618
- function simplifyDPStep(points, startIdx, endIdx, sqTolerance, simplified) {
19619
- let maxSqDist = sqTolerance,
19620
- nextIdx = startIdx;
19621
- const startX = points[startIdx].x,
19622
- startY = points[startIdx].y,
19623
- vecX2 = points[endIdx].x - startX,
19624
- vecY2 = points[endIdx].y - startY,
19625
- sqLength = vecX2 * vecX2 + vecY2 * vecY2;
19626
- let area, sqArea, sqDistance, vecX1, vecY1;
19627
- for (let i = startIdx + 1, len = endIdx - 1; i < len; i++) vecX1 = points[i].x - startX, vecY1 = points[i].y - startY, area = vecX1 * vecY2 - vecX2 * vecY1, sqArea = area * area, sqDistance = sqArea / sqLength, sqDistance > maxSqDist && (maxSqDist = sqDistance, nextIdx = i);
19628
- maxSqDist > sqTolerance && (nextIdx - startIdx > 2 && simplifyDPStep(points, startIdx, nextIdx, sqTolerance, simplified), simplified.push(points[nextIdx], points[nextIdx + 1]), endIdx - nextIdx > 2 && simplifyDPStep(points, nextIdx, endIdx, sqTolerance, simplified));
19629
- }
19630
- function simplifyDouglasPeucker(points, sqTolerance) {
19631
- const lastIdx = points.length - 1,
19632
- simplified = [points[0]];
19633
- return simplifyDPStep(points, 0, lastIdx, sqTolerance, simplified), simplified.push(points[lastIdx]), simplified;
19634
- }
19635
19694
  function flatten_simplify(points, tolerance, highestQuality) {
19636
19695
  if (points.length <= 10) return points;
19637
- const sqTolerance = void 0 !== tolerance ? tolerance * tolerance : 1;
19638
- return points = simplifyDouglasPeucker(points = highestQuality ? points : simplifyRadialDist(points, sqTolerance), sqTolerance);
19696
+ return points = highestQuality ? points : simplifyRadialDist(points, void 0 !== tolerance ? tolerance * tolerance : 1);
19639
19697
  }
19640
19698
 
19641
19699
  function findCursorIndexIgnoreLinebreak(textConfig, cursorIndex) {
@@ -23672,7 +23730,7 @@ class Gesture extends EventEmitter {
23672
23730
  let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
23673
23731
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
23674
23732
  super(), this.cachedEvents = [], this.startPoints = [], this.processEvent = {}, this.throttleTimer = 0, this.emitThrottles = [], this.lastTapTarget = null, this.onStart = ev => {
23675
- this.reset(), this.startTime = clock.now();
23733
+ this.cachedEvents = [], this.startPoints = [], this.reset(), this.startTime = clock.now();
23676
23734
  const {
23677
23735
  cachedEvents: cachedEvents,
23678
23736
  startPoints: startPoints
@@ -23692,7 +23750,7 @@ class Gesture extends EventEmitter {
23692
23750
  if (1 !== startPoints.length) this.startDistance = calcDistance(startPoints[0], startPoints[1]), this.center = getCenter([startPoints[0], startPoints[1]]);else {
23693
23751
  const event = cachedEvents[0];
23694
23752
  this.pressTimeout = setTimeout(() => {
23695
- event.direction = "none", event.deltaX = 0, event.deltaY = 0, event.points = startPoints, this.triggerStartEvent("press", event), this.triggerEvent("press", event), this.eventType = "press", this.direction = "none";
23753
+ event.direction = "none", event.deltaX = 0, event.deltaY = 0, event.points = startPoints, this.triggerStartEvent("press", event), this.triggerEvent("press", event), this.eventType = "press", this.direction = "none", this.pressTimeout = null;
23696
23754
  }, this.config.press.time);
23697
23755
  }
23698
23756
  }, this.onMove = ev => {
@@ -23755,10 +23813,10 @@ class Gesture extends EventEmitter {
23755
23813
  lastMovePoint = this.lastMovePoint || startPoints[0],
23756
23814
  distance = calcDistance(prevMovePoint, lastMovePoint),
23757
23815
  velocity = distance / intervalTime;
23758
- velocity > this.config.swipe.velocity && distance > this.config.swipe.threshold && (endEvent.velocity = velocity, endEvent.direction = calcDirection(prevMovePoint, lastMovePoint), this.triggerEvent("swipe", endEvent));
23816
+ if (velocity > this.config.swipe.velocity && distance > this.config.swipe.threshold) return endEvent.velocity = velocity, endEvent.direction = calcDirection(prevMovePoint, lastMovePoint), this.triggerEvent("swipe", endEvent), this.cachedEvents = [], this.startPoints = [], void this.reset();
23759
23817
  }
23760
23818
  }
23761
- now - this.lastTapTime < this.config.tap.interval && ev.target === this.lastTapTarget ? this.tapCount++ : this.tapCount = 1, this.lastTapTime = now, this.lastTapTarget = ev.target, 1 === this.tapCount ? this.triggerEvent("tap", endEvent) : 2 === this.tapCount && (this.triggerEvent("doubletap", endEvent), this.tapCount = 0);
23819
+ now - this.startTime < this.config.press.time && (now - this.lastTapTime < this.config.tap.interval && ev.target === this.lastTapTarget ? this.tapCount++ : this.tapCount = 1, this.lastTapTime = now, this.lastTapTarget = ev.target, 1 === this.tapCount ? this.triggerEvent("tap", endEvent) : 2 === this.tapCount && (this.triggerEvent("doubletap", endEvent), this.tapCount = 0));
23762
23820
  }
23763
23821
  for (let i = 0, len = cachedEvents.length; i < len; i++) if (cachedEvents[i].pointerId === endEvent.pointerId) {
23764
23822
  cachedEvents.splice(i, 1), startPoints.splice(i, 1);
@@ -23834,6 +23892,7 @@ class Gesture extends EventEmitter {
23834
23892
  emitThrottles: emitThrottles
23835
23893
  } = this;
23836
23894
  throttleTimer || (this.throttleTimer = application.global.getRequestAnimationFrame()(() => {
23895
+ application.global.getCancelAnimationFrame()(this.throttleTimer), this.throttleTimer = null;
23837
23896
  for (let i = 0, len = emitThrottles.length; i < len; i++) {
23838
23897
  const {
23839
23898
  type: type,
@@ -23841,7 +23900,7 @@ class Gesture extends EventEmitter {
23841
23900
  } = emitThrottles[i];
23842
23901
  this.emitEvent(type, ev);
23843
23902
  }
23844
- this.throttleTimer = 0, this.emitThrottles.length = 0;
23903
+ this.emitThrottles.length = 0;
23845
23904
  }));
23846
23905
  }
23847
23906
  triggerStartEvent(type, ev) {
@@ -28134,10 +28193,8 @@ let DefaultCanvasTextPicker = class extends Base3dPicker {
28134
28193
  } = text.attribute,
28135
28194
  bounds = text.AABBBounds,
28136
28195
  height = bounds.height(),
28137
- width = bounds.width(),
28138
- offsetY = textLayoutOffsetY(textBaseline, height, fontSize),
28139
- offsetX = textDrawOffsetX(textAlign, width);
28140
- return context.rect(offsetX + x, offsetY + y, width, height, z), picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked;
28196
+ width = bounds.width();
28197
+ return context.rect(bounds.x1, bounds.y1, width, height, z), picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked;
28141
28198
  }, (context, symbolAttribute, themeAttribute) => picked), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
28142
28199
  }
28143
28200
  };
@@ -28477,7 +28534,7 @@ const registerWrapText = _registerWrapText;
28477
28534
 
28478
28535
  const roughModule = _roughModule;
28479
28536
 
28480
- const version = "0.21.0-alpha.2";
28537
+ const version = "0.21.0-alpha.3";
28481
28538
  preLoadAllModule();
28482
28539
  if (isBrowserEnv()) {
28483
28540
  loadBrowserEnv(container);