@visactor/vrender-components 0.21.0-alpha.12 → 0.21.0-alpha.13

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.
Files changed (94) hide show
  1. package/cjs/axis/type.d.ts +2 -2
  2. package/cjs/axis/type.js.map +1 -1
  3. package/cjs/brush/brush.js +1 -2
  4. package/cjs/brush/type.js +2 -1
  5. package/cjs/data-zoom/type.d.ts +1 -1
  6. package/cjs/data-zoom/type.js.map +1 -1
  7. package/cjs/gif/gif.d.ts +29 -0
  8. package/cjs/gif/gif.js +59 -0
  9. package/cjs/gif/gif.js.map +1 -0
  10. package/cjs/gif/index.d.ts +1 -0
  11. package/cjs/gif/index.js +21 -0
  12. package/cjs/gif/index.js.map +1 -0
  13. package/cjs/index.d.ts +2 -1
  14. package/cjs/index.js +2 -2
  15. package/cjs/index.js.map +1 -1
  16. package/cjs/interface.js.map +1 -1
  17. package/cjs/jsx/component-type.js +1 -2
  18. package/cjs/label/arc.js +3 -2
  19. package/cjs/label/arc.js.map +1 -1
  20. package/cjs/label/base.js +7 -12
  21. package/cjs/label/base.js.map +1 -1
  22. package/cjs/label/overlap/place.d.ts +1 -6
  23. package/cjs/label/overlap/place.js +4 -4
  24. package/cjs/label/overlap/place.js.map +1 -1
  25. package/cjs/label/overlap/shiftY.d.ts +1 -2
  26. package/cjs/label/overlap/shiftY.js +18 -72
  27. package/cjs/label/overlap/shiftY.js.map +1 -1
  28. package/cjs/label/polygon.js +1 -1
  29. package/cjs/label/rect.js +1 -1
  30. package/cjs/legend/color/type.d.ts +2 -2
  31. package/cjs/legend/color/type.js.map +1 -1
  32. package/cjs/legend/discrete/type.d.ts +1 -1
  33. package/cjs/legend/discrete/type.js.map +1 -1
  34. package/cjs/marker/type.d.ts +2 -2
  35. package/cjs/marker/type.js.map +1 -1
  36. package/cjs/player/type/discrete-player.d.ts +3 -3
  37. package/cjs/player/type/discrete-player.js.map +1 -1
  38. package/cjs/player/type/index.d.ts +2 -2
  39. package/cjs/player/type/index.js.map +1 -1
  40. package/cjs/scrollbar/index.d.ts +0 -1
  41. package/cjs/scrollbar/index.js +1 -2
  42. package/cjs/scrollbar/index.js.map +1 -1
  43. package/cjs/scrollbar/scrollbar-plugin.d.ts +15 -18
  44. package/cjs/scrollbar/scrollbar-plugin.js +97 -109
  45. package/cjs/scrollbar/scrollbar-plugin.js.map +1 -1
  46. package/cjs/timeline/type.js.map +1 -1
  47. package/dist/index.es.js +1274 -973
  48. package/es/axis/type.d.ts +2 -2
  49. package/es/axis/type.js.map +1 -1
  50. package/es/brush/brush.js +1 -2
  51. package/es/brush/type.js +2 -1
  52. package/es/data-zoom/type.d.ts +1 -1
  53. package/es/data-zoom/type.js.map +1 -1
  54. package/es/gif/gif.d.ts +29 -0
  55. package/es/gif/gif.js +55 -0
  56. package/es/gif/gif.js.map +1 -0
  57. package/es/gif/index.d.ts +1 -0
  58. package/es/gif/index.js +2 -0
  59. package/es/gif/index.js.map +1 -0
  60. package/es/index.d.ts +2 -1
  61. package/es/index.js +3 -1
  62. package/es/index.js.map +1 -1
  63. package/es/interface.js.map +1 -1
  64. package/es/jsx/component-type.js +1 -2
  65. package/es/label/arc.js +3 -2
  66. package/es/label/arc.js.map +1 -1
  67. package/es/label/base.js +7 -12
  68. package/es/label/base.js.map +1 -1
  69. package/es/label/overlap/place.d.ts +1 -6
  70. package/es/label/overlap/place.js +4 -4
  71. package/es/label/overlap/place.js.map +1 -1
  72. package/es/label/overlap/shiftY.d.ts +1 -2
  73. package/es/label/overlap/shiftY.js +15 -68
  74. package/es/label/overlap/shiftY.js.map +1 -1
  75. package/es/label/polygon.js +1 -1
  76. package/es/label/rect.js +1 -1
  77. package/es/legend/color/type.d.ts +2 -2
  78. package/es/legend/color/type.js.map +1 -1
  79. package/es/legend/discrete/type.d.ts +1 -1
  80. package/es/legend/discrete/type.js.map +1 -1
  81. package/es/marker/type.d.ts +2 -2
  82. package/es/marker/type.js.map +1 -1
  83. package/es/player/type/discrete-player.d.ts +3 -3
  84. package/es/player/type/discrete-player.js.map +1 -1
  85. package/es/player/type/index.d.ts +2 -2
  86. package/es/player/type/index.js.map +1 -1
  87. package/es/scrollbar/index.d.ts +0 -1
  88. package/es/scrollbar/index.js +0 -2
  89. package/es/scrollbar/index.js.map +1 -1
  90. package/es/scrollbar/scrollbar-plugin.d.ts +15 -18
  91. package/es/scrollbar/scrollbar-plugin.js +94 -111
  92. package/es/scrollbar/scrollbar-plugin.js.map +1 -1
  93. package/es/timeline/type.js.map +1 -1
  94. package/package.json +9 -9
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, isNumberClose, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, cos, sin, pi, isString, isArray, pointAt, isNumber, getDecimalPlaces, isNil, Color, OBBBounds, has, normalTransform, isValidUrl, isBase64, acos, sqrt, transformBoundsWithMatrix, arrayEqual, getContextFont, rotatePoint, clampAngleByRadian, asin, Bounds, getRectIntersect, isRectIntersect, isPlainObject, merge, clamp, clampRange, normalizePadding, debounce, throttle, hexToRgb, crossProduct, isValid, isEmpty, rectInsideAnotherRect, radianToDegree, getAngleByPoint, polarToCartesian, array, isValidNumber, calculateAnchorOfBounds, computeQuadrant, isGreater, isLess, normalizeAngle, flattenArray, cloneDeep, get, last, isRotateAABBIntersect, mixin, isEqual, interpolateString, minInArray, maxInArray, binaryFuzzySearchInNumberRange, polygonContainPoint } from '@visactor/vutils';
1
+ import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, isNumberClose, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, isString, cos, sin, pi, isArray, pointAt, isNumber, getDecimalPlaces, isNil, Color, OBBBounds, has, normalTransform, isValidUrl, isBase64, acos, sqrt, transformBoundsWithMatrix, arrayEqual, getContextFont, rotatePoint, clampAngleByRadian, asin, Bounds, getRectIntersect, isRectIntersect, isPlainObject, merge, clamp, clampRange, normalizePadding, debounce, throttle, hexToRgb, crossProduct, isValid, isEmpty, rectInsideAnotherRect, radianToDegree, getAngleByPoint, polarToCartesian, array, isValidNumber, calculateAnchorOfBounds, computeQuadrant, isGreater, isLess, normalizeAngle, flattenArray, cloneDeep, get, last, isRotateAABBIntersect, mixin, isEqual, interpolateString, minInArray, maxInArray, binaryFuzzySearchInNumberRange, polygonContainPoint } from '@visactor/vutils';
2
2
  import { isContinuous, isDiscrete, LinearScale } from '@visactor/vscale';
3
3
 
4
4
  class Generator {
@@ -592,6 +592,12 @@ let DefaultGlobal = class {
592
592
  get env() {
593
593
  return this._env;
594
594
  }
595
+ get isImageAnonymous() {
596
+ return this._isImageAnonymous;
597
+ }
598
+ set isImageAnonymous(isImageAnonymous) {
599
+ this._isImageAnonymous = isImageAnonymous;
600
+ }
595
601
  get devicePixelRatio() {
596
602
  return this._env || this.setEnv("browser"), this.envContribution.getDevicePixelRatio();
597
603
  }
@@ -626,7 +632,7 @@ let DefaultGlobal = class {
626
632
  this._env || this.setEnv("browser"), this.envContribution.applyStyles = support;
627
633
  }
628
634
  constructor(contributions) {
629
- this.contributions = contributions, this.id = Generator.GenAutoIncrementId(), this.hooks = {
635
+ this.contributions = contributions, this._isImageAnonymous = !0, this.id = Generator.GenAutoIncrementId(), this.hooks = {
630
636
  onSetEnv: new SyncHook(["lastEnv", "env", "global"])
631
637
  }, this.measureTextMethod = "native", this.optimizeVisible = !1;
632
638
  }
@@ -745,11 +751,6 @@ let DefaultGlobal = class {
745
751
  };
746
752
  DefaultGlobal = __decorate$P([injectable(), __param$z(0, inject(ContributionProvider)), __param$z(0, named(EnvContribution)), __metadata$E("design:paramtypes", [Object])], DefaultGlobal);
747
753
 
748
- var MeasureModeEnum;
749
- !function (MeasureModeEnum) {
750
- MeasureModeEnum[MeasureModeEnum.estimate = 0] = "estimate", MeasureModeEnum[MeasureModeEnum.actualBounding = 1] = "actualBounding", MeasureModeEnum[MeasureModeEnum.fontBounding = 2] = "fontBounding";
751
- }(MeasureModeEnum || (MeasureModeEnum = {}));
752
-
753
754
  const circleThreshold = tau - 1e-8;
754
755
  class BoundsContext {
755
756
  constructor(bounds) {
@@ -2014,7 +2015,6 @@ const DefaultStrokeStyle = Object.assign({
2014
2015
  const DefaultTextStyle = {
2015
2016
  text: "",
2016
2017
  maxLineWidth: 1 / 0,
2017
- maxWidth: 1 / 0,
2018
2018
  textAlign: "left",
2019
2019
  textBaseline: "alphabetic",
2020
2020
  fontSize: 16,
@@ -2038,9 +2038,7 @@ const DefaultTextStyle = {
2038
2038
  suffixPosition: "end",
2039
2039
  underlineDash: [],
2040
2040
  underlineOffset: 0,
2041
- disableAutoClipedPoptip: void 0,
2042
- measureMode: MeasureModeEnum.fontBounding,
2043
- keepCenterInLine: !1
2041
+ disableAutoClipedPoptip: void 0
2044
2042
  };
2045
2043
  const DefaultPickStyle = {
2046
2044
  pickStrokeBuffer: 0
@@ -2094,8 +2092,7 @@ const DefaultAttribute = Object.assign(Object.assign(Object.assign({
2094
2092
  globalZIndex: 1,
2095
2093
  globalCompositeOperation: "",
2096
2094
  overflow: "hidden",
2097
- shadowPickMode: "graphic",
2098
- keepStrokeScale: !1
2095
+ shadowPickMode: "graphic"
2099
2096
  }, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
2100
2097
  const DefaultArcAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
2101
2098
  startAngle: 0,
@@ -2362,32 +2359,10 @@ let ATextMeasure = class {
2362
2359
  configure(service, env) {
2363
2360
  this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
2364
2361
  }
2365
- _measureTextWithoutAlignBaseline(text, options, compatible) {
2362
+ measureTextWidth(text, options) {
2363
+ if (!this.context) return this.estimate(text, options).width;
2366
2364
  this.context.setTextStyleWithoutAlignBaseline(options);
2367
- const metrics = this.context.measureText(text);
2368
- return compatible ? this.compatibleMetrics(metrics, options) : metrics;
2369
- }
2370
- _measureTextWithAlignBaseline(text, options, compatible) {
2371
- this.context.setTextStyle(options);
2372
- const metrics = this.context.measureText(text);
2373
- return compatible ? this.compatibleMetrics(metrics, options) : metrics;
2374
- }
2375
- compatibleMetrics(metrics, options) {
2376
- if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
2377
- const {
2378
- ascent: ascent,
2379
- descent: descent
2380
- } = this.measureTextBoundADscentEstimate(options);
2381
- metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
2382
- }
2383
- if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
2384
- const {
2385
- left: left,
2386
- right: right
2387
- } = this.measureTextBoundLeftRightEstimate(options);
2388
- metrics.actualBoundingBoxLeft = left, metrics.actualBoundingBoxRight = right;
2389
- }
2390
- return metrics;
2365
+ return this.context.measureText(text).width;
2391
2366
  }
2392
2367
  estimate(text, _ref) {
2393
2368
  let {
@@ -2401,97 +2376,19 @@ let ATextMeasure = class {
2401
2376
  height: fontSize
2402
2377
  };
2403
2378
  }
2404
- measureTextWidth(text, options, textMeasure) {
2405
- return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
2406
- }
2407
- measureTextBoundsWidth(text, options, textMeasure) {
2408
- return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
2409
- }
2410
- measureTextBoundsLeftRight(text, options, textMeasure) {
2411
- return this.context ? {
2412
- left: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxLeft,
2413
- right: textMeasure.actualBoundingBoxRight
2414
- } : this.measureTextBoundLeftRightEstimate(options);
2415
- }
2416
- measureTextPixelHeight(text, options, textMeasure) {
2379
+ measureTextPixelHeight(text, options) {
2417
2380
  var _a;
2418
- 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;
2419
- }
2420
- measureTextPixelADscent(text, options, textMeasure) {
2421
- return this.context ? {
2422
- ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxAscent,
2423
- descent: textMeasure.actualBoundingBoxDescent
2424
- } : this.measureTextBoundADscentEstimate(options);
2425
- }
2426
- measureTextBoundHieght(text, options, textMeasure) {
2427
- var _a;
2428
- 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;
2429
- }
2430
- measureTextBoundADscent(text, options, textMeasure) {
2431
- return this.context ? {
2432
- ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).fontBoundingBoxAscent,
2433
- descent: textMeasure.fontBoundingBoxDescent
2434
- } : this.measureTextBoundADscentEstimate(options);
2435
- }
2436
- measureTextBoundADscentEstimate(options) {
2437
- var _a;
2438
- const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
2439
- return {
2440
- ascent: .79 * fontSize,
2441
- descent: .21 * fontSize
2442
- };
2381
+ if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
2382
+ this.context.setTextStyleWithoutAlignBaseline(options);
2383
+ const textMeasure = this.context.measureText(text);
2384
+ return Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent);
2443
2385
  }
2444
- measureTextBoundLeftRightEstimate(options) {
2386
+ measureTextBoundHieght(text, options) {
2445
2387
  var _a;
2446
- const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
2447
- {
2448
- textAlign: textAlign
2449
- } = options;
2450
- return "center" === textAlign ? {
2451
- left: fontSize / 2,
2452
- right: fontSize / 2
2453
- } : "right" === textAlign || "end" === textAlign ? {
2454
- left: fontSize,
2455
- right: 0
2456
- } : {
2457
- left: 0,
2458
- right: fontSize
2459
- };
2460
- }
2461
- measureTextPixelADscentAndWidth(text, options, mode) {
2462
- if (!this.context) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
2463
- width: this.estimate(text, options).width
2464
- });
2465
- const out = this._measureTextWithoutAlignBaseline(text, options, !0);
2466
- if (mode === MeasureModeEnum.actualBounding) return {
2467
- ascent: out.actualBoundingBoxAscent,
2468
- descent: out.actualBoundingBoxDescent,
2469
- width: out.width
2470
- };
2471
- if (mode === MeasureModeEnum.estimate) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
2472
- width: out.width
2473
- });
2474
- if (mode === MeasureModeEnum.fontBounding) {
2475
- let ascent = out.fontBoundingBoxAscent,
2476
- descent = out.fontBoundingBoxDescent;
2477
- if (out.actualBoundingBoxDescent && descent < out.actualBoundingBoxDescent) {
2478
- const delta = out.actualBoundingBoxDescent - descent;
2479
- descent += delta, ascent -= delta;
2480
- } else if (out.actualBoundingBoxAscent && ascent < out.actualBoundingBoxAscent) {
2481
- const delta = out.actualBoundingBoxAscent - ascent;
2482
- ascent += delta, descent -= delta;
2483
- }
2484
- return {
2485
- ascent: ascent,
2486
- descent: descent,
2487
- width: out.width
2488
- };
2489
- }
2490
- return {
2491
- ascent: out.actualBoundingBoxAscent,
2492
- descent: out.actualBoundingBoxDescent,
2493
- width: out.width
2494
- };
2388
+ if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
2389
+ this.context.setTextStyleWithoutAlignBaseline(options);
2390
+ const textMeasure = this.context.measureText(text);
2391
+ return Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent);
2495
2392
  }
2496
2393
  measureText(text, options) {
2497
2394
  return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
@@ -4274,16 +4171,12 @@ function getAttributeFromDefaultAttrList(attr, key) {
4274
4171
  }
4275
4172
  return attr[key];
4276
4173
  }
4277
- const _calculateLineHeight = (lineHeight, fontSize) => {
4174
+ const calculateLineHeight = (lineHeight, fontSize) => {
4278
4175
  if (isString(lineHeight) && "%" === lineHeight[lineHeight.length - 1]) {
4279
4176
  return fontSize * (Number.parseFloat(lineHeight.substring(0, lineHeight.length - 1)) / 100);
4280
4177
  }
4281
4178
  return lineHeight;
4282
4179
  };
4283
- const calculateLineHeight = (lineHeight, fontSize) => {
4284
- const _lh = _calculateLineHeight(lineHeight, fontSize);
4285
- return isNaN(_lh) ? _lh : Math.max(fontSize, _lh);
4286
- };
4287
4180
 
4288
4181
  class IncreaseCount extends ACustomAnimate {
4289
4182
  constructor(from, to, duration, easing, params) {
@@ -4485,7 +4378,7 @@ class ResourceLoader {
4485
4378
  }
4486
4379
  static GetFile(url, type) {
4487
4380
  let data = ResourceLoader.cache.get(url);
4488
- return data ? "init" === data.loadState || "fail" === data.loadState ? Promise.reject() : "loading" === data.loadState ? data.dataPromise.then(data => data.data) : Promise.resolve(data.data) : (data = {
4381
+ return data ? "fail" === data.loadState ? Promise.reject() : "init" === data.loadState || "loading" === data.loadState ? data.dataPromise.then(data => data.data) : Promise.resolve(data.data) : (data = {
4489
4382
  type: type,
4490
4383
  loadState: "init"
4491
4384
  }, ResourceLoader.cache.set(url, data), "arrayBuffer" === type ? data.dataPromise = application.global.loadArrayBuffer(url) : "blob" === type ? data.dataPromise = application.global.loadBlob(url) : "json" === type && (data.dataPromise = application.global.loadJson(url)), data.dataPromise.then(data => data.data));
@@ -6149,6 +6042,9 @@ const SymbolRenderContribution = Symbol.for("SymbolRenderContribution");
6149
6042
  const TextRenderContribution = Symbol.for("TextRenderContribution");
6150
6043
  const InteractiveSubRenderContribution = Symbol.for("InteractiveSubRenderContribution");
6151
6044
 
6045
+ function textDrawOffsetY(baseline, h) {
6046
+ return "top" === baseline ? Math.ceil(.79 * h) : "middle" === baseline ? Math.round(.3 * h) : "bottom" === baseline ? Math.round(-.21 * h) : 0;
6047
+ }
6152
6048
  function textDrawOffsetX(textAlign, width) {
6153
6049
  return "end" === textAlign || "right" === textAlign ? -width : "center" === textAlign ? -width / 2 : 0;
6154
6050
  }
@@ -6627,7 +6523,7 @@ class BaseRender {
6627
6523
  }
6628
6524
  }
6629
6525
 
6630
- const parse = function () {
6526
+ const parse$1 = function () {
6631
6527
  const tokens = {
6632
6528
  linearGradient: /^(linear\-gradient)/i,
6633
6529
  radialGradient: /^(radial\-gradient)/i,
@@ -6780,7 +6676,7 @@ class GradientParser {
6780
6676
  }
6781
6677
  static Parse(c) {
6782
6678
  if (GradientParser.IsGradientStr(c)) try {
6783
- const datum = parse(c)[0];
6679
+ const datum = parse$1(c)[0];
6784
6680
  if (datum) {
6785
6681
  if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
6786
6682
  if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
@@ -7137,8 +7033,7 @@ class DefaultArcRenderContribution {
7137
7033
  x: originX = arcAttribute.x,
7138
7034
  y: originY = arcAttribute.y,
7139
7035
  scaleX = arcAttribute.scaleX,
7140
- scaleY = arcAttribute.scaleY,
7141
- keepStrokeScale = arcAttribute.keepStrokeScale
7036
+ scaleY = arcAttribute.scaleY
7142
7037
  } = arc.attribute;
7143
7038
  let {
7144
7039
  innerRadius = arcAttribute.innerRadius,
@@ -7150,7 +7045,7 @@ class DefaultArcRenderContribution {
7150
7045
  {
7151
7046
  distance = arcAttribute[key].distance
7152
7047
  } = borderStyle,
7153
- d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
7048
+ d = getScaledStroke(context, distance, context.dpr),
7154
7049
  deltaAngle = distance / outerRadius,
7155
7050
  sign = "outerBorder" === key ? 1 : -1;
7156
7051
  if (arc.setAttributes({
@@ -7195,15 +7090,14 @@ class DefaultCircleRenderContribution {
7195
7090
  x: originX = circleAttribute.x,
7196
7091
  y: originY = circleAttribute.y,
7197
7092
  scaleX = circleAttribute.scaleX,
7198
- scaleY = circleAttribute.scaleY,
7199
- keepStrokeScale = circleAttribute.keepStrokeScale
7093
+ scaleY = circleAttribute.scaleY
7200
7094
  } = circle.attribute,
7201
7095
  renderBorder = (borderStyle, key) => {
7202
7096
  const doStroke = !(!borderStyle || !borderStyle.stroke),
7203
7097
  {
7204
7098
  distance = circleAttribute[key].distance
7205
7099
  } = borderStyle,
7206
- d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
7100
+ d = getScaledStroke(context, distance, context.dpr),
7207
7101
  sign = "outerBorder" === key ? 1 : -1;
7208
7102
  if (context.beginPath(), context.arc(x, y, radius + sign * d, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), strokeCb) strokeCb(context, borderStyle, circleAttribute[key]);else if (doStroke) {
7209
7103
  const lastOpacity = circleAttribute[key].opacity;
@@ -7322,8 +7216,7 @@ class DefaultRectRenderContribution {
7322
7216
  scaleX = rectAttribute.scaleX,
7323
7217
  scaleY = rectAttribute.scaleY,
7324
7218
  x1: x1,
7325
- y1: y1,
7326
- keepStrokeScale = rectAttribute.keepStrokeScale
7219
+ y1: y1
7327
7220
  } = rect.attribute;
7328
7221
  let {
7329
7222
  width: width,
@@ -7336,7 +7229,7 @@ class DefaultRectRenderContribution {
7336
7229
  {
7337
7230
  distance = rectAttribute[key].distance
7338
7231
  } = borderStyle,
7339
- d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
7232
+ d = getScaledStroke(context, distance, context.dpr),
7340
7233
  nextX = x + sign * d,
7341
7234
  nextY = y + sign * d,
7342
7235
  dw = 2 * d;
@@ -7466,8 +7359,9 @@ class DefaultImageRenderContribution extends DefaultRectRenderContribution {
7466
7359
  constructor() {
7467
7360
  super(...arguments), this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
7468
7361
  }
7469
- drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
7470
- return super.drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
7362
+ drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
7363
+ if (!(image.isGifImage && image.renderFrame && image.playing)) return super.drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
7364
+ image.renderFrame(context, x, y);
7471
7365
  }
7472
7366
  }
7473
7367
  const defaultImageRenderContribution = new DefaultImageRenderContribution();
@@ -7493,15 +7387,14 @@ class DefaultSymbolRenderContribution {
7493
7387
  x: originX = symbolAttribute.x,
7494
7388
  y: originY = symbolAttribute.y,
7495
7389
  scaleX = symbolAttribute.scaleX,
7496
- scaleY = symbolAttribute.scaleY,
7497
- keepStrokeScale = symbolAttribute.keepStrokeScale
7390
+ scaleY = symbolAttribute.scaleY
7498
7391
  } = symbol.attribute,
7499
7392
  renderBorder = (borderStyle, key) => {
7500
7393
  const doStroke = !(!borderStyle || !borderStyle.stroke),
7501
7394
  {
7502
7395
  distance = symbolAttribute[key].distance
7503
7396
  } = borderStyle,
7504
- d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
7397
+ d = getScaledStroke(context, distance, context.dpr),
7505
7398
  sign = "outerBorder" === key ? 1 : -1;
7506
7399
  if (context.beginPath(), !1 === parsedPath.drawOffset(context, size, x, y, sign * d) && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), strokeCb) strokeCb(context, borderStyle, symbolAttribute[key]);else if (doStroke) {
7507
7400
  const lastOpacity = symbolAttribute[key].opacity;
@@ -8777,8 +8670,16 @@ let DefaultCanvasTextRender = class extends BaseRender {
8777
8670
  verticalMode = textAttribute.verticalMode,
8778
8671
  x: originX = textAttribute.x,
8779
8672
  y: originY = textAttribute.y
8780
- } = text.attribute,
8781
- lineHeight = null !== (_a = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _a ? _a : fontSize,
8673
+ } = text.attribute;
8674
+ let {
8675
+ textAlign = textAttribute.textAlign,
8676
+ textBaseline = textAttribute.textBaseline
8677
+ } = text.attribute;
8678
+ if (!verticalMode && "vertical" === direction) {
8679
+ const t = textAlign;
8680
+ textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
8681
+ }
8682
+ const lineHeight = null !== (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize,
8782
8683
  data = this.valid(text, textAttribute, fillCb, strokeCb);
8783
8684
  if (!data) return;
8784
8685
  const {
@@ -8798,60 +8699,79 @@ let DefaultCanvasTextRender = class extends BaseRender {
8798
8699
  const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);
8799
8700
  matrix.rotateByCenter(Math.PI / 2, _x, _y), context.transformFromMatrix(matrix, !0), matrixAllocate.free(matrix);
8800
8701
  }
8801
- doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.fillText(t, _x, _y, z))), direction && (context.highPerformanceRestore(), context.setTransformForCurrent());
8702
+ 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());
8802
8703
  };
8803
- if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
8804
- const {
8805
- multilineLayout: multilineLayout
8806
- } = text;
8807
- if (!multilineLayout) return void context.highPerformanceRestore();
8808
- const {
8809
- xOffset: xOffset,
8810
- yOffset: yOffset
8811
- } = multilineLayout.bbox;
8812
- doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
8813
- context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
8814
- }))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
8815
- context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z), this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, line.descent, (line.descent - line.ascent) / 2, z, textAttribute, context, {
8816
- width: line.width
8704
+ if (text.isMultiLine) {
8705
+ if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
8706
+ const {
8707
+ multilineLayout: multilineLayout
8708
+ } = text;
8709
+ if (!multilineLayout) return void context.highPerformanceRestore();
8710
+ const {
8711
+ xOffset: xOffset,
8712
+ yOffset: yOffset
8713
+ } = multilineLayout.bbox;
8714
+ doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
8715
+ context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
8716
+ }))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
8717
+ 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, {
8718
+ width: line.width
8719
+ });
8720
+ })));
8721
+ } else {
8722
+ text.tryUpdateAABBBounds();
8723
+ const cache = text.cache,
8724
+ {
8725
+ verticalList: verticalList
8726
+ } = cache;
8727
+ context.textAlign = "left", context.textBaseline = "top";
8728
+ const totalHeight = lineHeight * verticalList.length;
8729
+ let totalW = 0;
8730
+ verticalList.forEach(verticalData => {
8731
+ const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
8732
+ totalW = max(_w, totalW);
8733
+ });
8734
+ let offsetY = 0,
8735
+ offsetX = 0;
8736
+ "bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
8737
+ const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
8738
+ dw = totalW - currentW;
8739
+ let currentOffsetY = offsetY;
8740
+ "center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
8741
+ const {
8742
+ text: text,
8743
+ width: width,
8744
+ direction: direction
8745
+ } = item;
8746
+ drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
8747
+ });
8817
8748
  });
8818
- })));
8819
- } else {
8820
- let {
8821
- textAlign = textAttribute.textAlign,
8822
- textBaseline = textAttribute.textBaseline
8823
- } = text.attribute;
8824
- if (!verticalMode) {
8825
- const t = textAlign;
8826
- textAlign = null !== (_b = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = text.getAlignMapBaseline()[t]) && void 0 !== _c ? _c : "top";
8827
8749
  }
8750
+ } else if ("horizontal" === direction) {
8751
+ context.setTextStyle(text.attribute, textAttribute, z);
8752
+ const t = text.clipedText;
8753
+ let dy = 0;
8754
+ lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)), drawText(t, 0, dy, 0);
8755
+ } else {
8828
8756
  text.tryUpdateAABBBounds();
8829
- const cache = text.cache,
8830
- {
8757
+ const cache = text.cache;
8758
+ if (cache) {
8759
+ context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
8760
+ const {
8831
8761
  verticalList: verticalList
8832
8762
  } = cache;
8833
- context.textAlign = "left", context.textBaseline = "top";
8834
- const totalHeight = lineHeight * verticalList.length;
8835
- let totalW = 0;
8836
- verticalList.forEach(verticalData => {
8837
- const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
8838
- totalW = max(_w, totalW);
8839
- });
8840
- let offsetY = 0,
8841
- offsetX = 0;
8842
- "bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
8843
- const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
8844
- dw = totalW - currentW;
8845
- let currentOffsetY = offsetY;
8846
- "center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
8763
+ let offsetY = 0;
8764
+ const totalW = verticalList[0].reduce((a, b) => a + (b.width || 0), 0);
8765
+ let offsetX = 0;
8766
+ "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 => {
8847
8767
  const {
8848
8768
  text: text,
8849
8769
  width: width,
8850
8770
  direction: direction
8851
8771
  } = item;
8852
- drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
8772
+ drawText(text, offsetX, offsetY, direction), offsetY += width;
8853
8773
  });
8854
- });
8774
+ }
8855
8775
  }
8856
8776
  transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context), this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
8857
8777
  }
@@ -8863,10 +8783,12 @@ let DefaultCanvasTextRender = class extends BaseRender {
8863
8783
  computed3dMatrix = !keepDirIn3d;
8864
8784
  this._draw(text, textAttribute, computed3dMatrix, drawContext, params);
8865
8785
  }
8866
- drawUnderLine(underline, lineThrough, text, anchorX, anchorY, offsetUnderLineY, offsetThroughLineY, z, textAttribute, context, multiOption) {
8786
+ drawUnderLine(underline, lineThrough, text, x, y, z, textAttribute, context, multiOption) {
8867
8787
  if (lineThrough + underline <= 0) return;
8868
8788
  const {
8869
8789
  textAlign = textAttribute.textAlign,
8790
+ textBaseline = textAttribute.textBaseline,
8791
+ fontSize = textAttribute.fontSize,
8870
8792
  fill = textAttribute.fill,
8871
8793
  opacity = textAttribute.opacity,
8872
8794
  underlineOffset = textAttribute.underlineOffset,
@@ -8876,21 +8798,23 @@ let DefaultCanvasTextRender = class extends BaseRender {
8876
8798
  isMulti = !isNil(multiOption),
8877
8799
  w = isMulti ? multiOption.width : text.clipedWidth,
8878
8800
  offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w),
8801
+ offsetY = textLayoutOffsetY(isMulti ? "alphabetic" : textBaseline, fontSize, fontSize),
8879
8802
  attribute = {
8880
8803
  lineWidth: 0,
8881
8804
  stroke: fill,
8882
8805
  opacity: opacity,
8883
8806
  strokeOpacity: fillOpacity
8884
8807
  };
8808
+ let deltaY = isMulti ? -3 : 0;
8885
8809
  if (underline) {
8886
- attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
8887
- const dy = anchorY + offsetUnderLineY + underlineOffset;
8888
- context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
8810
+ attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, x, y, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
8811
+ const dy = y + offsetY + fontSize + underlineOffset + deltaY;
8812
+ context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
8889
8813
  }
8890
- if (lineThrough) {
8891
- attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), context.beginPath();
8892
- const dy = anchorY + offsetThroughLineY;
8893
- context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
8814
+ if (isMulti && (deltaY = -1), lineThrough) {
8815
+ attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, x, y, textAttribute), context.beginPath();
8816
+ const dy = y + offsetY + fontSize / 2 + deltaY;
8817
+ context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
8894
8818
  }
8895
8819
  }
8896
8820
  };
@@ -9175,10 +9099,12 @@ let DefaultCanvasImageRender = class extends BaseRender {
9175
9099
  const {
9176
9100
  image: url
9177
9101
  } = image.attribute;
9178
- if (!url || !image.resources) return;
9179
- const res = image.resources.get(url);
9180
- if ("loading" === res.state && isString(url)) return void ResourceLoader.improveImageLoading(url);
9181
- if ("success" !== res.state) return;
9102
+ if (!image.isGifImage) {
9103
+ if (!url || !image.resources) return;
9104
+ const res = image.resources.get(url);
9105
+ if ("loading" === res.state && isString(url)) return void ResourceLoader.improveImageLoading(url);
9106
+ if ("success" !== res.state) return;
9107
+ }
9182
9108
  const {
9183
9109
  context: context
9184
9110
  } = renderService.drawParams;
@@ -9555,59 +9481,58 @@ class CanvasTextLayout {
9555
9481
  constructor(fontFamily, options, textMeasure) {
9556
9482
  this.fontFamily = fontFamily, this.textOptions = options, this.textMeasure = textMeasure;
9557
9483
  }
9558
- LayoutBBox(bbox, textAlign, textBaseline, linesLayout) {
9559
- if (bbox.xOffset = "left" === textAlign || "start" === textAlign ? 0 : "center" === textAlign ? bbox.width / -2 : "right" === textAlign || "end" === textAlign ? -bbox.width : 0, "top" === textBaseline) bbox.yOffset = 0;else if ("middle" === textBaseline) bbox.yOffset = bbox.height / -2;else if ("alphabetic" === textBaseline) {
9560
- let percent = .79;
9561
- if (1 === linesLayout.length) {
9562
- const lineInfo = linesLayout[0];
9563
- percent = lineInfo.ascent / (lineInfo.ascent + lineInfo.descent);
9564
- }
9565
- bbox.yOffset = bbox.height * -percent;
9566
- } else bbox.yOffset = -bbox.height;
9567
- return bbox;
9484
+ LayoutBBox(bbox, textAlign, textBaseline) {
9485
+ if ("left" === textAlign || "start" === textAlign) bbox.xOffset = 0;else if ("center" === textAlign) bbox.xOffset = bbox.width / -2;else {
9486
+ if ("right" !== textAlign && "end" !== textAlign) throw new Error("非法的textAlign");
9487
+ bbox.xOffset = -bbox.width;
9488
+ }
9489
+ return bbox.yOffset = "top" === textBaseline ? 0 : "middle" === textBaseline ? bbox.height / -2 : "alphabetic" === textBaseline ? -.79 * bbox.height : -bbox.height, bbox;
9490
+ }
9491
+ GetLayout(str, width, height, textAlign, textBaseline, lineHeight, suffix, wordBreak, suffixPosition) {
9492
+ const linesLayout = [],
9493
+ bboxWH = [width, height],
9494
+ bboxOffset = [0, 0];
9495
+ for (; str.length > 0;) {
9496
+ const {
9497
+ str: clipText
9498
+ } = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
9499
+ linesLayout.push({
9500
+ str: clipText,
9501
+ width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
9502
+ }), str = str.substring(clipText.length);
9503
+ }
9504
+ "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]));
9505
+ const bbox = {
9506
+ xOffset: bboxOffset[0],
9507
+ yOffset: bboxOffset[1],
9508
+ width: bboxWH[0],
9509
+ height: bboxWH[1]
9510
+ };
9511
+ return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
9568
9512
  }
9569
9513
  GetLayoutByLines(lines, textAlign, textBaseline, lineHeight) {
9570
9514
  let suffix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
9571
9515
  let wordBreak = arguments.length > 5 ? arguments[5] : undefined;
9572
- let params = arguments.length > 6 ? arguments[6] : undefined;
9573
- const {
9574
- lineWidth: lineWidth,
9575
- suffixPosition = "end",
9576
- measureMode = MeasureModeEnum.actualBounding,
9577
- keepCenterInLine = !1
9578
- } = null != params ? params : {};
9516
+ let lineWidth = arguments.length > 6 ? arguments[6] : undefined;
9517
+ let suffixPosition = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : "end";
9579
9518
  lines = lines.map(l => l.toString());
9580
9519
  const linesLayout = [],
9581
9520
  bboxWH = [0, 0];
9582
9521
  if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
9583
9522
  let width;
9584
- for (let i = 0, len = lines.length; i < len; i++) {
9585
- const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
9586
- width = Math.min(metrics.width, lineWidth), linesLayout.push({
9587
- str: metrics.width <= lineWidth ? lines[i].toString() : this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
9588
- width: width,
9589
- ascent: metrics.ascent,
9590
- descent: metrics.descent,
9591
- keepCenterInLine: keepCenterInLine
9592
- });
9593
- }
9523
+ for (let i = 0, len = lines.length; i < len; i++) width = Math.min(this.textMeasure.measureTextWidth(lines[i], this.textOptions), lineWidth), linesLayout.push({
9524
+ str: this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
9525
+ width: width
9526
+ });
9594
9527
  bboxWH[0] = lineWidth;
9595
9528
  } else {
9596
- let width,
9597
- text,
9598
- _lineWidth = 0;
9599
- for (let i = 0, len = lines.length; i < len; i++) {
9600
- text = lines[i];
9601
- const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
9602
- width = metrics.width, _lineWidth = Math.max(_lineWidth, width), linesLayout.push({
9603
- str: text,
9604
- width: width,
9605
- ascent: metrics.ascent,
9606
- descent: metrics.descent,
9607
- keepCenterInLine: keepCenterInLine
9608
- });
9609
- }
9610
- bboxWH[0] = _lineWidth;
9529
+ let width, text;
9530
+ lineWidth = 0;
9531
+ 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({
9532
+ str: text,
9533
+ width: width
9534
+ });
9535
+ bboxWH[0] = lineWidth;
9611
9536
  }
9612
9537
  bboxWH[1] = linesLayout.length * lineHeight, bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);
9613
9538
  const bbox = {
@@ -9616,7 +9541,7 @@ class CanvasTextLayout {
9616
9541
  width: bboxWH[0],
9617
9542
  height: bboxWH[1]
9618
9543
  };
9619
- return this.LayoutBBox(bbox, textAlign, textBaseline, linesLayout), this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
9544
+ return this.LayoutBBox(bbox, textAlign, textBaseline), this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
9620
9545
  }
9621
9546
  layoutWithBBox(bbox, lines, textAlign, textBaseline, lineHeight) {
9622
9547
  const origin = [0, 0],
@@ -9635,19 +9560,11 @@ class CanvasTextLayout {
9635
9560
  };
9636
9561
  }
9637
9562
  lineOffset(bbox, line, textAlign, textBaseline, lineHeight, origin) {
9638
- if ("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], !line.keepCenterInLine) {
9639
- const buf = 0,
9640
- actualHeightWithBuf = line.ascent + line.descent + buf;
9641
- if (actualHeightWithBuf < lineHeight - buf && ("bottom" === textBaseline ? line.topOffset += (lineHeight - actualHeightWithBuf) / 2 : "top" === textBaseline && (line.topOffset -= (lineHeight - actualHeightWithBuf) / 2)), "alphabetic" === textBaseline) {
9642
- const ratio = lineHeight / (line.ascent + line.descent);
9643
- line.topOffset = lineHeight / 2 + (line.ascent - line.descent) / 2 * ratio + origin[1];
9644
- }
9645
- }
9646
- return origin[1] += lineHeight, line;
9563
+ 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;
9647
9564
  }
9648
9565
  }
9649
9566
 
9650
- 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];
9567
+ const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
9651
9568
  class Text extends Graphic {
9652
9569
  get font() {
9653
9570
  const textTheme = this.getGraphicTheme();
@@ -9656,22 +9573,26 @@ class Text extends Graphic {
9656
9573
  get clipedText() {
9657
9574
  var _a;
9658
9575
  const attribute = this.attribute,
9659
- textTheme = this.getGraphicTheme(),
9660
- maxWidth = this.getMaxWidth(textTheme);
9661
- return Number.isFinite(maxWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
9576
+ textTheme = this.getGraphicTheme();
9577
+ if (!this.isSimplify()) return;
9578
+ const {
9579
+ maxLineWidth = textTheme.maxLineWidth
9580
+ } = attribute;
9581
+ return Number.isFinite(maxLineWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
9662
9582
  }
9663
9583
  get clipedWidth() {
9664
- return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
9584
+ if (this.isSimplify()) return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
9665
9585
  }
9666
9586
  get cliped() {
9667
9587
  var _a, _b;
9668
9588
  const textTheme = this.getGraphicTheme(),
9669
9589
  attribute = this.attribute,
9670
- maxWidth = this.getMaxWidth(textTheme);
9671
- if (!Number.isFinite(maxWidth)) return !1;
9672
- const {
9673
- text: text
9674
- } = this.attribute;
9590
+ {
9591
+ maxLineWidth = textTheme.maxLineWidth,
9592
+ text: text,
9593
+ whiteSpace = textTheme.whiteSpace
9594
+ } = attribute;
9595
+ if (!Number.isFinite(maxLineWidth)) return !1;
9675
9596
  if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
9676
9597
  let mergedText = "";
9677
9598
  this.cache.layoutData.lines.forEach(item => {
@@ -9682,7 +9603,10 @@ class Text extends Graphic {
9682
9603
  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();
9683
9604
  }
9684
9605
  get multilineLayout() {
9685
- return this.tryUpdateAABBBounds(), this.cache.layoutData;
9606
+ if (this.isMultiLine) return this.tryUpdateAABBBounds(), this.cache.layoutData;
9607
+ }
9608
+ isSimplify() {
9609
+ return !this.isMultiLine && "vertical" !== this.attribute.direction;
9686
9610
  }
9687
9611
  get isMultiLine() {
9688
9612
  return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
@@ -9755,74 +9679,8 @@ class Text extends Graphic {
9755
9679
  }
9756
9680
  return application.graphicService.combindShadowAABBBounds(aabbBounds, this), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds), transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix), aabbBounds;
9757
9681
  }
9758
- updateSingallineAABBBounds(text) {
9759
- this.updateMultilineAABBBounds([text]);
9760
- const layoutData = this.cache.layoutData;
9761
- if (layoutData && layoutData.lines && layoutData.lines.length) {
9762
- const line = layoutData.lines[0];
9763
- this.cache.clipedText = line.str, this.cache.clipedWidth = line.width;
9764
- }
9765
- return this._AABBBounds;
9766
- }
9767
- updateMultilineAABBBounds(text) {
9768
- const textTheme = this.getGraphicTheme(),
9769
- {
9770
- direction = textTheme.direction,
9771
- underlineOffset = textTheme.underlineOffset
9772
- } = this.attribute,
9773
- b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
9774
- return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
9775
- }
9776
- guessLineHeightBuf(fontSize) {
9777
- return fontSize ? .1 * fontSize : 0;
9778
- }
9779
- updateHorizontalMultilineAABBBounds(text) {
9780
- var _a;
9781
- const textTheme = this.getGraphicTheme(),
9782
- attribute = this.attribute,
9783
- {
9784
- fontFamily = textTheme.fontFamily,
9785
- textAlign = textTheme.textAlign,
9786
- textBaseline = textTheme.textBaseline,
9787
- fontSize = textTheme.fontSize,
9788
- fontWeight = textTheme.fontWeight,
9789
- ellipsis = textTheme.ellipsis,
9790
- maxLineWidth: maxLineWidth,
9791
- stroke = textTheme.stroke,
9792
- wrap = textTheme.wrap,
9793
- measureMode = textTheme.measureMode,
9794
- lineWidth = textTheme.lineWidth,
9795
- whiteSpace = textTheme.whiteSpace,
9796
- suffixPosition = textTheme.suffixPosition,
9797
- ignoreBuf = textTheme.ignoreBuf,
9798
- keepCenterInLine = textTheme.keepCenterInLine
9799
- } = attribute,
9800
- buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
9801
- lineHeight = this.getLineHeight(attribute, textTheme, buf);
9802
- if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
9803
- if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
9804
- const bbox = this.cache.layoutData.bbox;
9805
- return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9806
- }
9807
- const textMeasure = application.graphicUtil.textMeasure,
9808
- layoutData = new CanvasTextLayout(fontFamily, {
9809
- fontSize: fontSize,
9810
- fontWeight: fontWeight,
9811
- fontFamily: fontFamily,
9812
- lineHeight: lineHeight
9813
- }, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, {
9814
- lineWidth: maxLineWidth,
9815
- suffixPosition: suffixPosition,
9816
- measureMode: measureMode,
9817
- keepCenterInLine: keepCenterInLine
9818
- }),
9819
- {
9820
- bbox: bbox
9821
- } = layoutData;
9822
- 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;
9823
- }
9824
9682
  updateWrapAABBBounds(text) {
9825
- var _a, _b, _c;
9683
+ var _a, _b, _c, _d;
9826
9684
  const textTheme = this.getGraphicTheme(),
9827
9685
  {
9828
9686
  fontFamily = textTheme.fontFamily,
@@ -9836,26 +9694,22 @@ class Text extends Graphic {
9836
9694
  wordBreak = textTheme.wordBreak,
9837
9695
  fontWeight = textTheme.fontWeight,
9838
9696
  ignoreBuf = textTheme.ignoreBuf,
9839
- measureMode = textTheme.measureMode,
9840
9697
  suffixPosition = textTheme.suffixPosition,
9841
9698
  heightLimit = 0,
9842
- lineClamp: lineClamp,
9843
- keepCenterInLine = textTheme.keepCenterInLine
9699
+ lineClamp: lineClamp
9844
9700
  } = this.attribute,
9845
- buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
9846
- lineHeight = this.getLineHeight(this.attribute, textTheme, buf);
9847
- if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
9701
+ lineHeight = null !== (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : this.attribute.fontSize || textTheme.fontSize,
9702
+ buf = ignoreBuf ? 0 : 2;
9703
+ if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
9848
9704
  const bbox = this.cache.layoutData.bbox;
9849
9705
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9850
9706
  }
9851
9707
  const textMeasure = application.graphicUtil.textMeasure,
9852
- textOptions = {
9708
+ layoutObj = new CanvasTextLayout(fontFamily, {
9853
9709
  fontSize: fontSize,
9854
9710
  fontWeight: fontWeight,
9855
- fontFamily: fontFamily,
9856
- lineHeight: lineHeight
9857
- },
9858
- layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
9711
+ fontFamily: fontFamily
9712
+ }, textMeasure),
9859
9713
  lines = isArray(text) ? text.map(l => l.toString()) : [text.toString()],
9860
9714
  linesLayout = [],
9861
9715
  bboxWH = [0, 0];
@@ -9865,37 +9719,29 @@ class Text extends Graphic {
9865
9719
  const str = lines[i];
9866
9720
  let needCut = !0;
9867
9721
  if (i === lineCountLimit - 1) {
9868
- const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1),
9869
- matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
9722
+ const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1);
9870
9723
  linesLayout.push({
9871
9724
  str: clip.str,
9872
- width: clip.width,
9873
- ascent: matrics.ascent,
9874
- descent: matrics.descent,
9875
- keepCenterInLine: keepCenterInLine
9725
+ width: clip.width
9876
9726
  });
9877
9727
  break;
9878
9728
  }
9879
- const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
9729
+ const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
9880
9730
  if ("" !== str && "" === clip.str || clip.wordBreaked) {
9881
9731
  if (ellipsis) {
9882
- const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
9883
- clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
9732
+ const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
9733
+ clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
9884
9734
  } else clip.str = "", clip.width = 0;
9885
9735
  needCut = !1;
9886
9736
  }
9887
- const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
9888
9737
  linesLayout.push({
9889
9738
  str: clip.str,
9890
- width: clip.width,
9891
- ascent: matrics.ascent,
9892
- descent: matrics.descent,
9893
- keepCenterInLine: keepCenterInLine
9739
+ width: clip.width
9894
9740
  });
9895
9741
  let cutLength = clip.str.length;
9896
9742
  if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
9897
- const newStr = str.substring(cutLength);
9898
- lines.splice(i + 1, 0, newStr);
9743
+ let newStr = str.substring(cutLength);
9744
+ "keep-all" === wordBreak && (newStr = newStr.replace(/^\s+/g, "")), lines.splice(i + 1, 0, newStr);
9899
9745
  }
9900
9746
  }
9901
9747
  let maxWidth = 0;
@@ -9908,46 +9754,235 @@ class Text extends Graphic {
9908
9754
  lineWidth = 0;
9909
9755
  for (let i = 0, len = lines.length; i < len; i++) {
9910
9756
  if (i === lineCountLimit - 1) {
9911
- const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition),
9912
- matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
9757
+ const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
9913
9758
  linesLayout.push({
9914
9759
  str: clip.str,
9915
- width: clip.width,
9916
- ascent: matrics.ascent,
9917
- descent: matrics.descent,
9918
- keepCenterInLine: keepCenterInLine
9760
+ width: clip.width
9919
9761
  }), lineWidth = Math.max(lineWidth, clip.width);
9920
9762
  break;
9921
9763
  }
9922
- text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width);
9923
- const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions, measureMode);
9924
- linesLayout.push({
9764
+ text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
9925
9765
  str: text,
9926
- width: width,
9927
- ascent: matrics.ascent,
9928
- descent: matrics.descent,
9929
- keepCenterInLine: keepCenterInLine
9766
+ width: width
9930
9767
  });
9931
9768
  }
9932
9769
  bboxWH[0] = lineWidth;
9933
9770
  }
9934
- bboxWH[1] = linesLayout.length * lineHeight;
9771
+ bboxWH[1] = linesLayout.length * (lineHeight + buf);
9935
9772
  const bbox = {
9936
9773
  xOffset: 0,
9937
9774
  yOffset: 0,
9938
9775
  width: bboxWH[0],
9939
9776
  height: bboxWH[1]
9940
9777
  };
9941
- layoutObj.LayoutBBox(bbox, textAlign, textBaseline, linesLayout);
9778
+ layoutObj.LayoutBBox(bbox, textAlign, textBaseline);
9942
9779
  const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
9943
9780
  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;
9944
9781
  }
9945
- updateVerticalMultilineAABBBounds(text) {
9782
+ updateSingallineAABBBounds(text) {
9783
+ const textTheme = this.getGraphicTheme(),
9784
+ {
9785
+ direction = textTheme.direction,
9786
+ underlineOffset = textTheme.underlineOffset
9787
+ } = this.attribute,
9788
+ b = "horizontal" === direction ? this.updateHorizontalSinglelineAABBBounds(text) : this.updateVerticalSinglelineAABBBounds(text);
9789
+ return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
9790
+ }
9791
+ updateMultilineAABBBounds(text) {
9792
+ const textTheme = this.getGraphicTheme(),
9793
+ {
9794
+ direction = textTheme.direction,
9795
+ underlineOffset = textTheme.underlineOffset
9796
+ } = this.attribute,
9797
+ b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
9798
+ return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
9799
+ }
9800
+ updateHorizontalSinglelineAABBBounds(text) {
9801
+ var _a, _b;
9802
+ const textTheme = this.getGraphicTheme(),
9803
+ {
9804
+ wrap = textTheme.wrap
9805
+ } = this.attribute;
9806
+ if (wrap) return this.updateWrapAABBBounds([text]);
9807
+ const textMeasure = application.graphicUtil.textMeasure;
9808
+ let width, str;
9809
+ const attribute = this.attribute,
9810
+ {
9811
+ maxLineWidth = textTheme.maxLineWidth,
9812
+ ellipsis = textTheme.ellipsis,
9813
+ textAlign = textTheme.textAlign,
9814
+ textBaseline = textTheme.textBaseline,
9815
+ fontFamily = textTheme.fontFamily,
9816
+ fontSize = textTheme.fontSize,
9817
+ fontWeight = textTheme.fontWeight,
9818
+ stroke = textTheme.stroke,
9819
+ lineWidth = textTheme.lineWidth,
9820
+ ignoreBuf = textTheme.ignoreBuf,
9821
+ whiteSpace = textTheme.whiteSpace,
9822
+ suffixPosition = textTheme.suffixPosition
9823
+ } = attribute;
9824
+ if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
9825
+ const buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
9826
+ textFontSize = attribute.fontSize || textTheme.fontSize,
9827
+ lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) && void 0 !== _a ? _a : textFontSize + buf;
9828
+ if (!this.shouldUpdateShape() && this.cache) {
9829
+ width = null !== (_b = this.cache.clipedWidth) && void 0 !== _b ? _b : 0;
9830
+ const dx = textDrawOffsetX(textAlign, width),
9831
+ dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
9832
+ return this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9833
+ }
9834
+ if (Number.isFinite(maxLineWidth)) {
9835
+ if (ellipsis) {
9836
+ const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
9837
+ data = textMeasure.clipTextWithSuffix(text.toString(), {
9838
+ fontSize: fontSize,
9839
+ fontWeight: fontWeight,
9840
+ fontFamily: fontFamily
9841
+ }, maxLineWidth, strEllipsis, !1, suffixPosition);
9842
+ str = data.str, width = data.width;
9843
+ } else {
9844
+ const data = textMeasure.clipText(text.toString(), {
9845
+ fontSize: fontSize,
9846
+ fontWeight: fontWeight,
9847
+ fontFamily: fontFamily
9848
+ }, maxLineWidth, !1);
9849
+ str = data.str, width = data.width;
9850
+ }
9851
+ this.cache.clipedText = str, this.cache.clipedWidth = width;
9852
+ } else width = textMeasure.measureTextWidth(text.toString(), {
9853
+ fontSize: fontSize,
9854
+ fontWeight: fontWeight,
9855
+ fontFamily: fontFamily
9856
+ }), this.cache.clipedText = text.toString(), this.cache.clipedWidth = width;
9857
+ this.clearUpdateShapeTag();
9858
+ const dx = textDrawOffsetX(textAlign, width);
9859
+ let lh = lineHeight;
9860
+ application.global && application.global.isSafari() && (lh += .2 * fontSize);
9861
+ const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
9862
+ return this._AABBBounds.set(dx, dy, dx + width, dy + lh), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9863
+ }
9864
+ getBaselineMapAlign() {
9865
+ return Text.baselineMapAlign;
9866
+ }
9867
+ getAlignMapBaseline() {
9868
+ return Text.alignMapBaseline;
9869
+ }
9870
+ updateVerticalSinglelineAABBBounds(text) {
9871
+ var _a, _b, _c;
9872
+ const textTheme = this.getGraphicTheme(),
9873
+ textMeasure = application.graphicUtil.textMeasure;
9874
+ let width;
9875
+ const attribute = this.attribute,
9876
+ {
9877
+ ignoreBuf = textTheme.ignoreBuf
9878
+ } = attribute,
9879
+ buf = ignoreBuf ? 0 : 2,
9880
+ {
9881
+ maxLineWidth = textTheme.maxLineWidth,
9882
+ ellipsis = textTheme.ellipsis,
9883
+ fontSize = textTheme.fontSize,
9884
+ fontWeight = textTheme.fontWeight,
9885
+ fontFamily = textTheme.fontFamily,
9886
+ stroke = textTheme.stroke,
9887
+ lineWidth = textTheme.lineWidth,
9888
+ verticalMode = textTheme.verticalMode,
9889
+ suffixPosition = textTheme.suffixPosition
9890
+ } = attribute,
9891
+ lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
9892
+ let {
9893
+ textAlign = textTheme.textAlign,
9894
+ textBaseline = textTheme.textBaseline
9895
+ } = attribute;
9896
+ if (!verticalMode) {
9897
+ const t = textAlign;
9898
+ textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
9899
+ }
9900
+ if (!this.shouldUpdateShape() && this.cache) {
9901
+ width = this.cache.clipedWidth;
9902
+ const dx = textDrawOffsetX(textAlign, width),
9903
+ dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
9904
+ return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9905
+ }
9906
+ let verticalList = [verticalLayout(text.toString())];
9907
+ if (Number.isFinite(maxLineWidth)) {
9908
+ if (ellipsis) {
9909
+ const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
9910
+ data = textMeasure.clipTextWithSuffixVertical(verticalList[0], {
9911
+ fontSize: fontSize,
9912
+ fontWeight: fontWeight,
9913
+ fontFamily: fontFamily
9914
+ }, maxLineWidth, strEllipsis, !1, suffixPosition);
9915
+ verticalList = [data.verticalList], width = data.width;
9916
+ } else {
9917
+ const data = textMeasure.clipTextVertical(verticalList[0], {
9918
+ fontSize: fontSize,
9919
+ fontWeight: fontWeight,
9920
+ fontFamily: fontFamily
9921
+ }, maxLineWidth, !1);
9922
+ verticalList = [data.verticalList], width = data.width;
9923
+ }
9924
+ this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
9925
+ } else width = 0, verticalList[0].forEach(t => {
9926
+ const w = t.direction === TextDirection.HORIZONTAL ? fontSize : textMeasure.measureTextWidth(t.text, {
9927
+ fontSize: fontSize,
9928
+ fontWeight: fontWeight,
9929
+ fontFamily: fontFamily
9930
+ });
9931
+ width += w, t.width = w;
9932
+ }), this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
9933
+ this.clearUpdateShapeTag();
9934
+ const dx = textDrawOffsetX(textAlign, width),
9935
+ dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
9936
+ return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9937
+ }
9938
+ updateHorizontalMultilineAABBBounds(text) {
9946
9939
  var _a, _b;
9940
+ const textTheme = this.getGraphicTheme(),
9941
+ {
9942
+ wrap = textTheme.wrap
9943
+ } = this.attribute;
9944
+ if (wrap) return this.updateWrapAABBBounds(text);
9945
+ const attribute = this.attribute,
9946
+ {
9947
+ fontFamily = textTheme.fontFamily,
9948
+ textAlign = textTheme.textAlign,
9949
+ textBaseline = textTheme.textBaseline,
9950
+ fontSize = textTheme.fontSize,
9951
+ fontWeight = textTheme.fontWeight,
9952
+ ellipsis = textTheme.ellipsis,
9953
+ maxLineWidth: maxLineWidth,
9954
+ stroke = textTheme.stroke,
9955
+ lineWidth = textTheme.lineWidth,
9956
+ whiteSpace = textTheme.whiteSpace,
9957
+ suffixPosition = textTheme.suffixPosition
9958
+ } = attribute,
9959
+ lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
9960
+ if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
9961
+ if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
9962
+ const bbox = this.cache.layoutData.bbox;
9963
+ return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9964
+ }
9965
+ const textMeasure = application.graphicUtil.textMeasure,
9966
+ layoutData = new CanvasTextLayout(fontFamily, {
9967
+ fontSize: fontSize,
9968
+ fontWeight: fontWeight,
9969
+ fontFamily: fontFamily
9970
+ }, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
9971
+ {
9972
+ bbox: bbox
9973
+ } = layoutData;
9974
+ 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;
9975
+ }
9976
+ updateVerticalMultilineAABBBounds(text) {
9977
+ var _a, _b, _c;
9947
9978
  const textTheme = this.getGraphicTheme(),
9948
9979
  textMeasure = application.graphicUtil.textMeasure;
9949
9980
  let width;
9950
9981
  const attribute = this.attribute,
9982
+ {
9983
+ ignoreBuf = textTheme.ignoreBuf
9984
+ } = attribute,
9985
+ buf = ignoreBuf ? 0 : 2,
9951
9986
  {
9952
9987
  maxLineWidth = textTheme.maxLineWidth,
9953
9988
  ellipsis = textTheme.ellipsis,
@@ -9959,14 +9994,14 @@ class Text extends Graphic {
9959
9994
  verticalMode = textTheme.verticalMode,
9960
9995
  suffixPosition = textTheme.suffixPosition
9961
9996
  } = attribute,
9962
- lineHeight = this.getLineHeight(attribute, textTheme, 0);
9997
+ lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
9963
9998
  let {
9964
9999
  textAlign = textTheme.textAlign,
9965
10000
  textBaseline = textTheme.textBaseline
9966
10001
  } = attribute;
9967
10002
  if (!verticalMode) {
9968
10003
  const t = textAlign;
9969
- textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
10004
+ textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
9970
10005
  }
9971
10006
  if (width = 0, !this.shouldUpdateShape() && this.cache) {
9972
10007
  this.cache.verticalList.forEach(item => {
@@ -10014,15 +10049,6 @@ class Text extends Graphic {
10014
10049
  dy = textLayoutOffsetY(textBaseline, height, fontSize);
10015
10050
  return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
10016
10051
  }
10017
- getMaxWidth(theme) {
10018
- var _a, _b;
10019
- const attribute = this.attribute;
10020
- return null !== (_b = null !== (_a = attribute.maxLineWidth) && void 0 !== _a ? _a : attribute.maxWidth) && void 0 !== _b ? _b : theme.maxWidth;
10021
- }
10022
- getLineHeight(attribute, textTheme, buf) {
10023
- var _a;
10024
- return null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
10025
- }
10026
10052
  needUpdateTags(keys) {
10027
10053
  let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_UPDATE_TAG_KEY;
10028
10054
  return super.needUpdateTags(keys, k);
@@ -10037,12 +10063,6 @@ class Text extends Graphic {
10037
10063
  getNoWorkAnimateAttr() {
10038
10064
  return Text.NOWORK_ANIMATE_ATTR;
10039
10065
  }
10040
- getBaselineMapAlign() {
10041
- return Text.baselineMapAlign;
10042
- }
10043
- getAlignMapBaseline() {
10044
- return Text.alignMapBaseline;
10045
- }
10046
10066
  }
10047
10067
  Text.NOWORK_ANIMATE_ATTR = Object.assign({
10048
10068
  ellipsis: 1,
@@ -10121,10 +10141,7 @@ class WrapText extends Text {
10121
10141
  const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
10122
10142
  linesLayout.push({
10123
10143
  str: clip.str,
10124
- width: clip.width,
10125
- ascent: 0,
10126
- descent: 0,
10127
- keepCenterInLine: !1
10144
+ width: clip.width
10128
10145
  });
10129
10146
  break;
10130
10147
  }
@@ -10138,10 +10155,7 @@ class WrapText extends Text {
10138
10155
  }
10139
10156
  if (linesLayout.push({
10140
10157
  str: clip.str,
10141
- width: clip.width,
10142
- ascent: 0,
10143
- descent: 0,
10144
- keepCenterInLine: !1
10158
+ width: clip.width
10145
10159
  }), clip.str.length === str.length) ;else if (needCut) {
10146
10160
  const newStr = str.substring(clip.str.length);
10147
10161
  lines.splice(i + 1, 0, newStr);
@@ -10160,19 +10174,13 @@ class WrapText extends Text {
10160
10174
  const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
10161
10175
  linesLayout.push({
10162
10176
  str: clip.str,
10163
- width: clip.width,
10164
- ascent: 0,
10165
- descent: 0,
10166
- keepCenterInLine: !1
10177
+ width: clip.width
10167
10178
  }), lineWidth = Math.max(lineWidth, clip.width);
10168
10179
  break;
10169
10180
  }
10170
10181
  text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
10171
10182
  str: text,
10172
- width: width,
10173
- ascent: 0,
10174
- descent: 0,
10175
- keepCenterInLine: !1
10183
+ width: width
10176
10184
  });
10177
10185
  }
10178
10186
  bboxWH[0] = lineWidth;
@@ -10216,9 +10224,6 @@ class BaseSymbol {
10216
10224
  bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
10217
10225
  } else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
10218
10226
  }
10219
- parseSize(size) {
10220
- return isNumber(size) ? size : Math.min(size[0], size[1]);
10221
- }
10222
10227
  }
10223
10228
 
10224
10229
  function circle(ctx, r, x, y, z) {
@@ -10229,13 +10234,13 @@ class CircleSymbol extends BaseSymbol {
10229
10234
  super(...arguments), this.type = "circle", this.pathStr = "M0.5,0A0.5,0.5,0,1,1,-0.5,0A0.5,0.5,0,1,1,0.5,0";
10230
10235
  }
10231
10236
  draw(ctx, size, x, y, z) {
10232
- return circle(ctx, this.parseSize(size) / 2, x, y, z);
10237
+ return circle(ctx, size / 2, x, y, z);
10233
10238
  }
10234
10239
  drawOffset(ctx, size, x, y, offset, z) {
10235
- return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
10240
+ return circle(ctx, size / 2 + offset, x, y, z);
10236
10241
  }
10237
10242
  drawToSvgPath(size, x, y, z) {
10238
- const r = this.parseSize(size) / 2;
10243
+ const r = size / 2;
10239
10244
  return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
10240
10245
  }
10241
10246
  }
@@ -10252,10 +10257,10 @@ class CrossSymbol extends BaseSymbol {
10252
10257
  super(...arguments), this.type = "cross", this.pathStr = "M-0.5,-0.2L-0.5,0.2L-0.2,0.2L-0.2,0.5L0.2,0.5L0.2,0.2L0.5,0.2L0.5,-0.2L0.2,-0.2L0.2,-0.5L-0.2,-0.5L-0.2,-0.2Z";
10253
10258
  }
10254
10259
  draw(ctx, size, x, y, z) {
10255
- return cross(ctx, this.parseSize(size) / 6, x, y, z);
10260
+ return cross(ctx, size / 6, x, y, z);
10256
10261
  }
10257
10262
  drawOffset(ctx, size, x, y, offset, z) {
10258
- return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
10263
+ return crossOffset(ctx, size / 6, x, y, offset, z);
10259
10264
  }
10260
10265
  }
10261
10266
  var cross$1 = new CrossSymbol();
@@ -10268,13 +10273,13 @@ class DiamondSymbol extends BaseSymbol {
10268
10273
  super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
10269
10274
  }
10270
10275
  draw(ctx, size, x, y, z) {
10271
- return diamond(ctx, this.parseSize(size) / 2, x, y, z);
10276
+ return diamond(ctx, size / 2, x, y, z);
10272
10277
  }
10273
10278
  drawFitDir(ctx, size, x, y, z) {
10274
- return diamond(ctx, this.parseSize(size) / 2, x, y, z);
10279
+ return diamond(ctx, size / 2, x, y, z);
10275
10280
  }
10276
10281
  drawOffset(ctx, size, x, y, offset, z) {
10277
- return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
10282
+ return diamond(ctx, size / 2 + offset, x, y, z);
10278
10283
  }
10279
10284
  }
10280
10285
  var diamond$1 = new DiamondSymbol();
@@ -10288,10 +10293,10 @@ class SquareSymbol extends BaseSymbol {
10288
10293
  super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
10289
10294
  }
10290
10295
  draw(ctx, size, x, y) {
10291
- return square(ctx, this.parseSize(size) / 2, x, y);
10296
+ return square(ctx, size / 2, x, y);
10292
10297
  }
10293
10298
  drawOffset(ctx, size, x, y, offset) {
10294
- return square(ctx, this.parseSize(size) / 2 + offset, x, y);
10299
+ return square(ctx, size / 2 + offset, x, y);
10295
10300
  }
10296
10301
  }
10297
10302
  var square$1 = new SquareSymbol();
@@ -10305,10 +10310,10 @@ class TriangleUpSymbol extends BaseSymbol {
10305
10310
  super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
10306
10311
  }
10307
10312
  draw(ctx, size, x, y) {
10308
- return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
10313
+ return trianglUpOffset(ctx, size / 2, x, y);
10309
10314
  }
10310
10315
  drawOffset(ctx, size, x, y, offset) {
10311
- return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
10316
+ return trianglUpOffset(ctx, size / 2, x, y, offset);
10312
10317
  }
10313
10318
  }
10314
10319
  var triangleUp = new TriangleUpSymbol();
@@ -10340,10 +10345,10 @@ class StarSymbol extends BaseSymbol {
10340
10345
  super(...arguments), this.type = "star", this.pathStr = "M0 -1L0.22451398828979266 -0.3090169943749474L0.9510565162951535 -0.30901699437494745L0.3632712640026804 0.1180339887498948L0.5877852522924732 0.8090169943749473L8.326672684688674e-17 0.3819660112501051L-0.587785252292473 0.8090169943749476L-0.3632712640026804 0.11803398874989487L-0.9510565162951536 -0.30901699437494723L-0.22451398828979274 -0.30901699437494734Z";
10341
10346
  }
10342
10347
  draw(ctx, size, transX, transY) {
10343
- return star(ctx, this.parseSize(size) / 2, transX, transY);
10348
+ return star(ctx, size / 2, transX, transY);
10344
10349
  }
10345
10350
  drawOffset(ctx, size, transX, transY, offset) {
10346
- return star(ctx, this.parseSize(size) / 2 + offset, transX, transY);
10351
+ return star(ctx, size / 2 + offset, transX, transY);
10347
10352
  }
10348
10353
  }
10349
10354
  var star$1 = new StarSymbol();
@@ -10361,10 +10366,10 @@ class ArrowSymbol extends BaseSymbol {
10361
10366
  super(...arguments), this.type = "arrow", this.pathStr = "M-0.07142857142857142,0.5L0.07142857142857142,0.5L0.07142857142857142,-0.0625L0.2,-0.0625L0,-0.5L-0.2,-0.0625L-0.07142857142857142,-0.0625Z";
10362
10367
  }
10363
10368
  draw(ctx, size, transX, transY) {
10364
- return arrow(ctx, this.parseSize(size) / 2, transX, transY);
10369
+ return arrow(ctx, size / 2, transX, transY);
10365
10370
  }
10366
10371
  drawOffset(ctx, size, transX, transY, offset) {
10367
- return arrow(ctx, this.parseSize(size) / 2 + offset, transX, transY);
10372
+ return arrow(ctx, size / 2 + offset, transX, transY);
10368
10373
  }
10369
10374
  }
10370
10375
  var arrow$1 = new ArrowSymbol();
@@ -10378,10 +10383,10 @@ class WedgeSymbol extends BaseSymbol {
10378
10383
  super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
10379
10384
  }
10380
10385
  draw(ctx, size, transX, transY) {
10381
- return wedge(ctx, this.parseSize(size) / 2, transX, transY);
10386
+ return wedge(ctx, size / 2, transX, transY);
10382
10387
  }
10383
10388
  drawOffset(ctx, size, transX, transY, offset) {
10384
- return wedge(ctx, this.parseSize(size) / 2 + offset, transX, transY);
10389
+ return wedge(ctx, size / 2 + offset, transX, transY);
10385
10390
  }
10386
10391
  }
10387
10392
  var wedge$1 = new WedgeSymbol();
@@ -10394,10 +10399,10 @@ class StrokeSymbol extends BaseSymbol {
10394
10399
  super(...arguments), this.type = "stroke", this.pathStr = "";
10395
10400
  }
10396
10401
  draw(ctx, size, transX, transY) {
10397
- return stroke(ctx, this.parseSize(size) / 2, transX, transY);
10402
+ return stroke(ctx, size / 2, transX, transY);
10398
10403
  }
10399
10404
  drawOffset(ctx, size, transX, transY, offset) {
10400
- return stroke(ctx, this.parseSize(size) / 2 + offset, transX, transY);
10405
+ return stroke(ctx, size / 2 + offset, transX, transY);
10401
10406
  }
10402
10407
  }
10403
10408
  var stroke$1 = new StrokeSymbol();
@@ -10419,10 +10424,10 @@ class WyeSymbol extends BaseSymbol {
10419
10424
  super(...arguments), this.type = "wye", this.pathStr = "M0.25 0.14433756729740646L0.25 0.6443375672974064L-0.25 0.6443375672974064L-0.25 0.14433756729740643L-0.6830127018922193 -0.10566243270259357L-0.4330127018922193 -0.5386751345948129L0 -0.28867513459481287L0.4330127018922193 -0.5386751345948129L0.6830127018922193 -0.10566243270259357Z";
10420
10425
  }
10421
10426
  draw(ctx, size, transX, transY) {
10422
- return wye(ctx, this.parseSize(size) / 2, transX, transY);
10427
+ return wye(ctx, size / 2, transX, transY);
10423
10428
  }
10424
10429
  drawOffset(ctx, size, transX, transY, offset) {
10425
- return wye(ctx, this.parseSize(size) / 2 + offset, transX, transY);
10430
+ return wye(ctx, size / 2 + offset, transX, transY);
10426
10431
  }
10427
10432
  }
10428
10433
  var wye$1 = new WyeSymbol();
@@ -10435,10 +10440,10 @@ class TriangleLeftSymbol extends BaseSymbol {
10435
10440
  super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
10436
10441
  }
10437
10442
  draw(ctx, size, x, y) {
10438
- return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, 0);
10443
+ return trianglLeftOffset(ctx, size / 2, x, y, 0);
10439
10444
  }
10440
10445
  drawOffset(ctx, size, x, y, offset) {
10441
- return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, offset);
10446
+ return trianglLeftOffset(ctx, size / 2, x, y, offset);
10442
10447
  }
10443
10448
  }
10444
10449
  var triangleLeft = new TriangleLeftSymbol();
@@ -10452,10 +10457,10 @@ class TriangleRightSymbol extends BaseSymbol {
10452
10457
  super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
10453
10458
  }
10454
10459
  draw(ctx, size, x, y) {
10455
- return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y);
10460
+ return trianglRightOffset(ctx, size / 2, x, y);
10456
10461
  }
10457
10462
  drawOffset(ctx, size, x, y, offset) {
10458
- return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y, offset);
10463
+ return trianglRightOffset(ctx, size / 2, x, y, offset);
10459
10464
  }
10460
10465
  }
10461
10466
  var triangleRight = new TriangleRightSymbol();
@@ -10469,10 +10474,10 @@ class TriangleDownSymbol extends BaseSymbol {
10469
10474
  super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
10470
10475
  }
10471
10476
  draw(ctx, size, x, y) {
10472
- return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y);
10477
+ return trianglDownOffset(ctx, size / 2, x, y);
10473
10478
  }
10474
10479
  drawOffset(ctx, size, x, y, offset) {
10475
- return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y, offset);
10480
+ return trianglDownOffset(ctx, size / 2, x, y, offset);
10476
10481
  }
10477
10482
  }
10478
10483
  var triangleDown = new TriangleDownSymbol();
@@ -10487,10 +10492,10 @@ class ThinTriangleSymbol extends BaseSymbol {
10487
10492
  super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
10488
10493
  }
10489
10494
  draw(ctx, size, x, y) {
10490
- return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3, x, y);
10495
+ return thinTriangle(ctx, size / 2 / sqrt3, x, y);
10491
10496
  }
10492
10497
  drawOffset(ctx, size, x, y, offset) {
10493
- return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3 + offset, x, y);
10498
+ return thinTriangle(ctx, size / 2 / sqrt3 + offset, x, y);
10494
10499
  }
10495
10500
  }
10496
10501
  var thinTriangle$1 = new ThinTriangleSymbol();
@@ -10504,10 +10509,10 @@ class Arrow2LeftSymbol extends BaseSymbol {
10504
10509
  super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
10505
10510
  }
10506
10511
  draw(ctx, size, transX, transY) {
10507
- return arrow2Left(ctx, this.parseSize(size) / 4, transX, transY);
10512
+ return arrow2Left(ctx, size / 4, transX, transY);
10508
10513
  }
10509
10514
  drawOffset(ctx, size, transX, transY, offset) {
10510
- return arrow2Left(ctx, this.parseSize(size) / 4 + offset, transX, transY);
10515
+ return arrow2Left(ctx, size / 4 + offset, transX, transY);
10511
10516
  }
10512
10517
  }
10513
10518
  var arrow2Left$1 = new Arrow2LeftSymbol();
@@ -10521,10 +10526,10 @@ class Arrow2RightSymbol extends BaseSymbol {
10521
10526
  super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
10522
10527
  }
10523
10528
  draw(ctx, size, transX, transY) {
10524
- return arrow2Right(ctx, this.parseSize(size) / 4, transX, transY);
10529
+ return arrow2Right(ctx, size / 4, transX, transY);
10525
10530
  }
10526
10531
  drawOffset(ctx, size, transX, transY, offset) {
10527
- return arrow2Right(ctx, this.parseSize(size) / 4 + offset, transX, transY);
10532
+ return arrow2Right(ctx, size / 4 + offset, transX, transY);
10528
10533
  }
10529
10534
  }
10530
10535
  var arrow2Right$1 = new Arrow2RightSymbol();
@@ -10538,10 +10543,10 @@ class Arrow2UpSymbol extends BaseSymbol {
10538
10543
  super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
10539
10544
  }
10540
10545
  draw(ctx, size, transX, transY) {
10541
- return arrow2Up(ctx, this.parseSize(size) / 4, transX, transY);
10546
+ return arrow2Up(ctx, size / 4, transX, transY);
10542
10547
  }
10543
10548
  drawOffset(ctx, size, transX, transY, offset) {
10544
- return arrow2Up(ctx, this.parseSize(size) / 4 + offset, transX, transY);
10549
+ return arrow2Up(ctx, size / 4 + offset, transX, transY);
10545
10550
  }
10546
10551
  }
10547
10552
  var arrow2Up$1 = new Arrow2UpSymbol();
@@ -10555,10 +10560,10 @@ class Arrow2DownSymbol extends BaseSymbol {
10555
10560
  super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
10556
10561
  }
10557
10562
  draw(ctx, size, transX, transY) {
10558
- return arrow2Down(ctx, this.parseSize(size) / 4, transX, transY);
10563
+ return arrow2Down(ctx, size / 4, transX, transY);
10559
10564
  }
10560
10565
  drawOffset(ctx, size, transX, transY, offset) {
10561
- return arrow2Down(ctx, this.parseSize(size) / 4 + offset, transX, transY);
10566
+ return arrow2Down(ctx, size / 4 + offset, transX, transY);
10562
10567
  }
10563
10568
  }
10564
10569
  var arrow2Down$1 = new Arrow2DownSymbol();
@@ -10571,13 +10576,13 @@ class LineVSymbol extends BaseSymbol {
10571
10576
  super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
10572
10577
  }
10573
10578
  draw(ctx, size, x, y, z) {
10574
- return lineV(ctx, this.parseSize(size) / 2, x, y);
10579
+ return lineV(ctx, size / 2, x, y);
10575
10580
  }
10576
10581
  drawOffset(ctx, size, x, y, offset, z) {
10577
- return lineV(ctx, this.parseSize(size) / 2 + offset, x, y);
10582
+ return lineV(ctx, size / 2 + offset, x, y);
10578
10583
  }
10579
10584
  drawToSvgPath(size, x, y, z) {
10580
- const r = this.parseSize(size) / 2;
10585
+ const r = size / 2;
10581
10586
  return `M ${x}, ${y - r} L ${x},${y + r}`;
10582
10587
  }
10583
10588
  }
@@ -10591,13 +10596,13 @@ class LineHSymbol extends BaseSymbol {
10591
10596
  super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
10592
10597
  }
10593
10598
  draw(ctx, size, x, y, z) {
10594
- return lineH(ctx, this.parseSize(size) / 2, x, y);
10599
+ return lineH(ctx, size / 2, x, y);
10595
10600
  }
10596
10601
  drawOffset(ctx, size, x, y, offset, z) {
10597
- return lineH(ctx, this.parseSize(size) / 2 + offset, x, y);
10602
+ return lineH(ctx, size / 2 + offset, x, y);
10598
10603
  }
10599
10604
  drawToSvgPath(size, x, y, z) {
10600
- const r = this.parseSize(size) / 2;
10605
+ const r = size / 2;
10601
10606
  return `M ${x - r}, ${y} L ${x + r},${y}`;
10602
10607
  }
10603
10608
  }
@@ -10611,13 +10616,13 @@ class CloseSymbol extends BaseSymbol {
10611
10616
  super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
10612
10617
  }
10613
10618
  draw(ctx, size, x, y, z) {
10614
- return close(ctx, this.parseSize(size) / 2, x, y);
10619
+ return close(ctx, size / 2, x, y);
10615
10620
  }
10616
10621
  drawOffset(ctx, size, x, y, offset, z) {
10617
- return close(ctx, this.parseSize(size) / 2 + offset, x, y);
10622
+ return close(ctx, size / 2 + offset, x, y);
10618
10623
  }
10619
10624
  drawToSvgPath(size, x, y, z) {
10620
- const r = this.parseSize(size) / 2;
10625
+ const r = size / 2;
10621
10626
  return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
10622
10627
  }
10623
10628
  }
@@ -10651,18 +10656,15 @@ class CustomSymbolClass {
10651
10656
  this.pathStr = "", this.type = type, isArray(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
10652
10657
  }
10653
10658
  drawOffset(ctx, size, x, y, offset, z, cb) {
10654
- return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
10659
+ return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
10655
10660
  ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
10656
10661
  }), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
10657
10662
  }
10658
10663
  draw(ctx, size, x, y, z, cb) {
10659
- return size = this.parseSize(size), this.drawOffset(ctx, size, x, y, 0, z, cb);
10660
- }
10661
- parseSize(size) {
10662
- return isNumber(size) ? size : Math.min(size[0], size[1]);
10664
+ return this.drawOffset(ctx, size, x, y, 0, z, cb);
10663
10665
  }
10664
10666
  bounds(size, bounds) {
10665
- if (size = this.parseSize(size), this.isSvg) {
10667
+ if (this.isSvg) {
10666
10668
  if (!this.svgCache) return;
10667
10669
  return bounds.clear(), void this.svgCache.forEach(_ref => {
10668
10670
  let {
@@ -11166,11 +11168,7 @@ class Paragraph {
11166
11168
  case "sub":
11167
11169
  baseline += this.descent / 2;
11168
11170
  }
11169
- "vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0);
11170
- const {
11171
- lineWidth = 1
11172
- } = this.character;
11173
- this.character.stroke && lineWidth && (applyStrokeStyle(ctx, this.character), ctx.strokeText(text, left, baseline)), applyFillStyle(ctx, this.character), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
11171
+ "vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0), this.character.stroke && (applyStrokeStyle(ctx, this.character), ctx.strokeText(text, left, baseline)), applyFillStyle(ctx, this.character), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
11174
11172
  }
11175
11173
  getWidthWithEllips(direction) {
11176
11174
  let text = this.text;
@@ -13357,9 +13355,8 @@ class PickerBase {
13357
13355
  return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, (context, arcAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, arcAttribute, themeAttribute) => {
13358
13356
  if (picked) return !0;
13359
13357
  const lineWidth = arcAttribute.lineWidth || themeAttribute.lineWidth,
13360
- pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
13361
- keepStrokeScale = arcAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
13362
- return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
13358
+ pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
13359
+ return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
13363
13360
  }), pickContext.highPerformanceRestore(), picked;
13364
13361
  }
13365
13362
  }
@@ -13581,9 +13578,8 @@ class RectPickerBase {
13581
13578
  if (!onlyTranslate || rect.shadowRoot || isNumber(cornerRadius, !0) && 0 !== cornerRadius || isArray(cornerRadius) && cornerRadius.some(num => 0 !== num)) picked = !1, this.canvasRenderer.drawShape(rect, pickContext, x, y, {}, null, (context, rectAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, rectAttribute, themeAttribute) => {
13582
13579
  if (picked) return !0;
13583
13580
  const lineWidth = rectAttribute.lineWidth || themeAttribute.lineWidth,
13584
- pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
13585
- keepStrokeScale = rectAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
13586
- return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
13581
+ pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
13582
+ return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
13587
13583
  });else {
13588
13584
  const {
13589
13585
  fill = rectAttribute.fill,
@@ -13762,9 +13758,8 @@ class BaseLinePicker extends BaseRender {
13762
13758
  return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, context => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, lineAttribute, themeAttribute) => {
13763
13759
  if (picked) return !0;
13764
13760
  const lineWidth = lineAttribute.lineWidth || themeAttribute.lineWidth,
13765
- pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
13766
- keepStrokeScale = lineAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
13767
- return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
13761
+ pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
13762
+ return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
13768
13763
  }), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
13769
13764
  }
13770
13765
  }
@@ -13899,9 +13894,8 @@ let DefaultCanvasSymbolPicker = class extends Base3dPicker {
13899
13894
  return this.canvasRenderer.drawShape(symbol, pickContext, x, y, {}, null, (context, symbolAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, symbolAttribute, themeAttribute) => {
13900
13895
  if (picked) return !0;
13901
13896
  const lineWidth = symbolAttribute.lineWidth || themeAttribute.lineWidth,
13902
- pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
13903
- keepStrokeScale = symbolAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
13904
- return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
13897
+ pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
13898
+ return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
13905
13899
  }), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
13906
13900
  }
13907
13901
  };
@@ -14461,374 +14455,92 @@ class ScrollBar extends AbstractComponent {
14461
14455
  const [min, max] = clampRange(limitRange, 0, 1);
14462
14456
  const { width, height, x1, y1 } = this.getSliderRenderBounds();
14463
14457
  const sliderSize = this._sliderSize;
14464
- return direction === 'horizontal'
14465
- ? clampRange([x1 + min * width, x1 + max * width], x1, width - sliderSize)
14466
- : clampRange([y1 + min * height, y1 + max * height], y1, height - sliderSize);
14467
- }
14468
- _reset() {
14469
- this._sliderRenderBounds = null;
14470
- this._sliderLimitRange = null;
14471
- }
14472
- }
14473
- ScrollBar.defaultAttributes = {
14474
- direction: 'horizontal',
14475
- round: true,
14476
- sliderSize: 20,
14477
- sliderStyle: {
14478
- fill: 'rgba(0, 0, 0, .5)'
14479
- },
14480
- railStyle: {
14481
- fill: 'rgba(0, 0, 0, .0)'
14482
- },
14483
- padding: 2,
14484
- scrollRange: [0, 1],
14485
- delayType: 'throttle',
14486
- delayTime: 0,
14487
- realTime: true
14488
- };
14489
-
14490
- /******************************************************************************
14491
- Copyright (c) Microsoft Corporation.
14492
-
14493
- Permission to use, copy, modify, and/or distribute this software for any
14494
- purpose with or without fee is hereby granted.
14495
-
14496
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14497
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14498
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14499
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14500
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14501
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14502
- PERFORMANCE OF THIS SOFTWARE.
14503
- ***************************************************************************** */
14504
- function __rest(s, e) {
14505
- var t = {};
14506
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
14507
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
14508
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
14509
- }
14510
- return t;
14511
- }
14512
- function __decorate(decorators, target, key, desc) {
14513
- var c = arguments.length,
14514
- r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
14515
- d;
14516
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
14517
- return c > 3 && r && Object.defineProperty(target, key, r), r;
14518
- }
14519
- function __awaiter(thisArg, _arguments, P, generator) {
14520
- function adopt(value) {
14521
- return value instanceof P ? value : new P(function (resolve) {
14522
- resolve(value);
14523
- });
14524
- }
14525
- return new (P || (P = Promise))(function (resolve, reject) {
14526
- function fulfilled(value) {
14527
- try {
14528
- step(generator.next(value));
14529
- } catch (e) {
14530
- reject(e);
14531
- }
14532
- }
14533
- function rejected(value) {
14534
- try {
14535
- step(generator["throw"](value));
14536
- } catch (e) {
14537
- reject(e);
14538
- }
14539
- }
14540
- function step(result) {
14541
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
14542
- }
14543
- step((generator = generator.apply(thisArg, _arguments || [])).next());
14544
- });
14545
- }
14546
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
14547
- var e = new Error(message);
14548
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
14549
- };
14550
-
14551
- var ScrollBarPlugin_1;
14552
- let ScrollBarPlugin = ScrollBarPlugin_1 = class ScrollBarPlugin {
14553
- constructor() {
14554
- this.name = 'scrollbar';
14555
- this.activeEvent = 'onRegister';
14556
- this._uid = Generator.GenAutoIncrementId();
14557
- this.key = this.name + this._uid;
14558
- this.scroll = (e) => {
14559
- var _a, _b;
14560
- const graphic = e.target;
14561
- const data = this.getScrollContainer(graphic);
14562
- if (!data && !this.scrollContainer) {
14563
- return;
14564
- }
14565
- if (!data && this.scrollContainer) {
14566
- if (!this.scrollContainer.g.stage || this.scrollContainer.g.stage !== graphic.stage) {
14567
- return;
14568
- }
14569
- const newScrollContainer = this.formatScrollContainer(this.scrollContainer.g);
14570
- if (!newScrollContainer) {
14571
- this.clearScrollbar(this.scrollContainer.g, 'all');
14572
- return;
14573
- }
14574
- if (this.scrollContainer.showH && !newScrollContainer.showH) {
14575
- this.clearScrollbar(this.scrollContainer.g, 'horizontal');
14576
- }
14577
- if (this.scrollContainer.showV && !newScrollContainer.showV) {
14578
- this.clearScrollbar(this.scrollContainer.g, 'vertical');
14579
- }
14580
- this.scrollContainer = newScrollContainer;
14581
- }
14582
- else if (data && this.scrollContainer && data.g !== this.scrollContainer.g) {
14583
- this.clearScrollbar(this.scrollContainer.g, 'all');
14584
- }
14585
- this.scrollContainer = data !== null && data !== void 0 ? data : this.scrollContainer;
14586
- const scrollContainer = data.g;
14587
- const { width, height, scrollX = 0, scrollY = 0 } = scrollContainer.attribute;
14588
- let newScrollX = scrollX;
14589
- let newScrollY = scrollY;
14590
- let { showH, showV } = data;
14591
- this.scrollContainerBounds = new Bounds().set(0, 0, scrollContainer.attribute.width, scrollContainer.attribute.height);
14592
- if (showH && showH) {
14593
- if (abs(e.deltaX) > abs(e.deltaY)) {
14594
- showH = showH && true;
14595
- showV = showV && false;
14596
- }
14597
- else {
14598
- showH = showH && false;
14599
- showV = showV && true;
14600
- }
14601
- }
14602
- const childrenBounds = this.childrenBounds;
14603
- childrenBounds.clear();
14604
- childrenBounds.set(0, 0, scrollContainer.AABBBounds.width(), scrollContainer.AABBBounds.height());
14605
- const scrollWidth = childrenBounds.width();
14606
- const scrollHeight = childrenBounds.height();
14607
- if (showH) {
14608
- newScrollX = Math.max(Math.min(((_a = e.deltaX) !== null && _a !== void 0 ? _a : 0) - scrollX, scrollWidth - width), 0);
14609
- }
14610
- else {
14611
- newScrollX = -scrollX;
14612
- }
14613
- if (showV) {
14614
- newScrollY = Math.max(Math.min(((_b = e.deltaY) !== null && _b !== void 0 ? _b : 0) - scrollY, scrollHeight - height), 0);
14615
- }
14616
- else {
14617
- newScrollY = -scrollY;
14618
- }
14619
- childrenBounds.translate(-newScrollX, -newScrollY);
14620
- this.addOrUpdateScroll(showH, showV, scrollContainer.parent, scrollContainer);
14621
- scrollContainer.setAttributes({
14622
- scrollX: -newScrollX,
14623
- scrollY: -newScrollY
14624
- });
14625
- };
14626
- this.handleScrollBarChange = (params) => {
14627
- if (!this.scrollContainer ||
14628
- !this.scrollContainerBounds ||
14629
- !this.childrenBounds ||
14630
- !params ||
14631
- !params.target ||
14632
- !params.detail ||
14633
- !params.detail.value) {
14634
- return;
14635
- }
14636
- const scrollbar = params.target;
14637
- const newRange = params.detail.value;
14638
- if (scrollbar.attribute.direction === 'horizontal') {
14639
- const scrollWidth = this.childrenBounds.width();
14640
- this.scrollContainer.g.setAttributes({ scrollX: -newRange[0] * scrollWidth });
14641
- }
14642
- else {
14643
- const scrollHeight = this.childrenBounds.height();
14644
- this.scrollContainer.g.setAttributes({ scrollY: -newRange[0] * scrollHeight });
14645
- }
14646
- };
14647
- }
14648
- activate(context) {
14649
- this.pluginService = context;
14650
- const { stage } = this.pluginService;
14651
- this.childrenBounds = new AABBBounds();
14652
- stage.addEventListener('wheel', this.scroll);
14653
- this.params = ScrollBarPlugin_1.defaultParams;
14654
- }
14655
- initEventOfScrollbar(scrollContainer, scrollbar, isHorozntal) {
14656
- scrollContainer.addEventListener('pointerover', () => {
14657
- scrollbar.setAttribute('visibleAll', true);
14658
- });
14659
- scrollContainer.addEventListener('pointermove', () => {
14660
- scrollbar.setAttribute('visibleAll', true);
14661
- });
14662
- scrollContainer.addEventListener('pointerout', () => {
14663
- scrollbar.setAttribute('visibleAll', false);
14664
- });
14665
- scrollbar.addEventListener('pointerover', () => {
14666
- scrollbar.setAttribute('visibleAll', true);
14667
- });
14668
- scrollbar.addEventListener('pointerout', () => {
14669
- scrollbar.setAttribute('visibleAll', true);
14670
- });
14671
- scrollbar.addEventListener('scrollUp', this.handleScrollBarChange);
14672
- scrollbar.addEventListener(SCROLLBAR_EVENT, this.handleScrollBarChange);
14673
- }
14674
- addOrUpdateScroll(showH, showV, container, scrollContainer) {
14675
- if (showH) {
14676
- const { scrollBar: hScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, true);
14677
- if (!isUpdate) {
14678
- this.initEventOfScrollbar(scrollContainer, hScrollbar, true);
14679
- }
14680
- }
14681
- else {
14682
- this.clearScrollbar(scrollContainer, 'horizontal');
14683
- }
14684
- if (showV) {
14685
- const { scrollBar: vScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, false);
14686
- if (!isUpdate) {
14687
- this.initEventOfScrollbar(scrollContainer, vScrollbar, false);
14688
- }
14689
- }
14690
- else {
14691
- this.clearScrollbar(scrollContainer, 'vertical');
14692
- }
14693
- }
14694
- getDirection(isHorozntal) {
14695
- return isHorozntal ? 'horizontal' : 'vertical';
14696
- }
14697
- addOrUpdateHScroll(scrollContainer, container, isHorozntal) {
14698
- var _a;
14699
- const direction = this.getDirection(isHorozntal);
14700
- const name = `${(_a = scrollContainer.name) !== null && _a !== void 0 ? _a : scrollContainer._uid}_${this.getDirection(isHorozntal)}_${this.name}`;
14701
- const scrollbars = container.children.filter((g) => g.name === name);
14702
- let isUpdate = true;
14703
- let scrollBar = scrollbars[0];
14704
- const { y = 0, dy = 0, x = 0, dx = 0, height, width, zIndex = 0 } = this.scrollContainer.g.attribute;
14705
- const attrs = {
14706
- x: 0,
14707
- y: 0,
14708
- direction,
14709
- zIndex: zIndex + 1,
14710
- visibleAll: true,
14711
- padding: [2, 0],
14712
- railStyle: {
14713
- fill: 'rgba(0, 0, 0, .1)'
14714
- },
14715
- range: [0, 0.05]
14716
- };
14717
- if (isHorozntal) {
14718
- attrs.width = this.scrollContainerBounds.width();
14719
- attrs.height = 12;
14720
- }
14721
- else {
14722
- attrs.height = this.scrollContainerBounds.height();
14723
- attrs.width = 12;
14724
- }
14725
- if (!scrollBar) {
14726
- isUpdate = false;
14727
- scrollBar = new ScrollBar(attrs);
14728
- scrollBar.name = name;
14729
- container.add(scrollBar);
14730
- scrollBar.isScrollBar = true;
14731
- }
14732
- else if (scrollbars.length > 1) {
14733
- scrollbars.forEach((child, index) => {
14734
- var _a;
14735
- if (index) {
14736
- (_a = child.parent) === null || _a === void 0 ? void 0 : _a.removeChild(child);
14737
- }
14738
- });
14739
- }
14740
- const childrenBounds = this.childrenBounds;
14741
- if (isHorozntal) {
14742
- const ratio = Math.min(this.scrollContainerBounds.width() / childrenBounds.width(), 1);
14743
- const start = Math.max(Math.min(this.childrenBounds.x1 / this.childrenBounds.width(), 0), ratio - 1);
14744
- attrs.x = x + dx;
14745
- attrs.y = y + dy + height - this.scrollContainerBounds.height();
14746
- attrs.range = [-start, -start + ratio];
14747
- }
14748
- else {
14749
- const ratio = Math.min(this.scrollContainerBounds.height() / childrenBounds.height(), 1);
14750
- const start = Math.max(Math.min(this.childrenBounds.y1 / this.childrenBounds.height(), 0), ratio - 1);
14751
- attrs.x = x + dx + width - this.scrollContainerBounds.width();
14752
- attrs.y = y + dy;
14753
- attrs.range = [-start, -start + ratio];
14754
- }
14755
- scrollBar.setAttributes(attrs);
14756
- return {
14757
- scrollBar,
14758
- isUpdate
14759
- };
14760
- }
14761
- clearScrollbar(scrollContainer, type) {
14762
- if (!scrollContainer.parent) {
14763
- return;
14764
- }
14765
- const scrollbarBars = scrollContainer.parent.children.filter((child) => {
14766
- return child.isScrollBar && (type === 'all' || child.attribute.direction === type);
14767
- });
14768
- scrollbarBars.forEach((child) => {
14769
- child.parent.removeChild(child);
14770
- });
14771
- }
14772
- formatScrollContainer(g) {
14773
- if (!g || g.type !== 'group' || !g.attribute) {
14774
- return null;
14775
- }
14776
- const { overflow, width, height } = g.attribute;
14777
- if (!overflow || overflow === 'hidden') {
14778
- return null;
14779
- }
14780
- let showH = false;
14781
- let showV = false;
14782
- if (overflow === 'scroll') {
14783
- showH = true;
14784
- showV = true;
14785
- }
14786
- else {
14787
- showH = overflow === 'scroll-x';
14788
- showV = !showH;
14789
- }
14790
- if (!g.AABBBounds.empty()) {
14791
- if (showH) {
14792
- showH = width < g.AABBBounds.width();
14793
- }
14794
- if (showV) {
14795
- showV = height < g.AABBBounds.height();
14796
- }
14797
- }
14798
- return showH || showV ? { g: g, showH, showV } : null;
14799
- }
14800
- getScrollContainer(graphic) {
14801
- let g = graphic;
14802
- while (g) {
14803
- const res = this.formatScrollContainer(g);
14804
- if (res) {
14805
- return res;
14806
- }
14807
- g = g.parent;
14808
- }
14809
- return null;
14458
+ return direction === 'horizontal'
14459
+ ? clampRange([x1 + min * width, x1 + max * width], x1, width - sliderSize)
14460
+ : clampRange([y1 + min * height, y1 + max * height], y1, height - sliderSize);
14810
14461
  }
14811
- deactivate(context) {
14812
- const { stage } = this.pluginService;
14813
- stage.removeEventListener('wheel', this.scroll);
14462
+ _reset() {
14463
+ this._sliderRenderBounds = null;
14464
+ this._sliderLimitRange = null;
14814
14465
  }
14466
+ }
14467
+ ScrollBar.defaultAttributes = {
14468
+ direction: 'horizontal',
14469
+ round: true,
14470
+ sliderSize: 20,
14471
+ sliderStyle: {
14472
+ fill: 'rgba(0, 0, 0, .5)'
14473
+ },
14474
+ railStyle: {
14475
+ fill: 'rgba(0, 0, 0, .0)'
14476
+ },
14477
+ padding: 2,
14478
+ scrollRange: [0, 1],
14479
+ delayType: 'throttle',
14480
+ delayTime: 0,
14481
+ realTime: true
14815
14482
  };
14816
- ScrollBarPlugin.defaultParams = {
14817
- timeout: 500
14818
- };
14819
- ScrollBarPlugin = ScrollBarPlugin_1 = __decorate([
14820
- injectable()
14821
- ], ScrollBarPlugin);
14822
14483
 
14823
- const scrollbarModule = new ContainerModule((bind, unbind, isBound, rebind) => {
14824
- if (!isBound(ScrollBarPlugin)) {
14825
- bind(ScrollBarPlugin).toSelf();
14826
- bind(AutoEnablePlugins).toService(ScrollBarPlugin);
14484
+ /******************************************************************************
14485
+ Copyright (c) Microsoft Corporation.
14486
+
14487
+ Permission to use, copy, modify, and/or distribute this software for any
14488
+ purpose with or without fee is hereby granted.
14489
+
14490
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14491
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14492
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14493
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14494
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14495
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14496
+ PERFORMANCE OF THIS SOFTWARE.
14497
+ ***************************************************************************** */
14498
+ function __rest(s, e) {
14499
+ var t = {};
14500
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
14501
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
14502
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
14503
+ }
14504
+ return t;
14505
+ }
14506
+ function __decorate(decorators, target, key, desc) {
14507
+ var c = arguments.length,
14508
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
14509
+ d;
14510
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
14511
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
14512
+ }
14513
+ function __awaiter(thisArg, _arguments, P, generator) {
14514
+ function adopt(value) {
14515
+ return value instanceof P ? value : new P(function (resolve) {
14516
+ resolve(value);
14517
+ });
14518
+ }
14519
+ return new (P || (P = Promise))(function (resolve, reject) {
14520
+ function fulfilled(value) {
14521
+ try {
14522
+ step(generator.next(value));
14523
+ } catch (e) {
14524
+ reject(e);
14525
+ }
14827
14526
  }
14828
- });
14829
- function loadScrollbar() {
14830
- container.load(scrollbarModule);
14527
+ function rejected(value) {
14528
+ try {
14529
+ step(generator["throw"](value));
14530
+ } catch (e) {
14531
+ reject(e);
14532
+ }
14533
+ }
14534
+ function step(result) {
14535
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
14536
+ }
14537
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
14538
+ });
14831
14539
  }
14540
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
14541
+ var e = new Error(message);
14542
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
14543
+ };
14832
14544
 
14833
14545
  function traverseGroup(group, cb) {
14834
14546
  group.forEachChildren(node => {
@@ -16287,29 +15999,24 @@ function defaultLabelPosition(type) {
16287
15999
  return DefaultPositions;
16288
16000
  }
16289
16001
  }
16290
- function clampText(text, width, height, padding = {}) {
16002
+ function clampText(text, width, height) {
16291
16003
  const { x1, x2, y1, y2 } = text.AABBBounds;
16292
- const { top = 0, left = 0, right = 0, bottom = 0 } = padding;
16293
16004
  const minX = Math.min(x1, x2);
16294
16005
  const maxX = Math.max(x1, x2);
16295
16006
  const minY = Math.min(y1, y2);
16296
16007
  const maxY = Math.max(y1, y2);
16297
- const minXWithPadding = 0 - left;
16298
- const maxXWithPadding = width + right;
16299
- const minYWithPadding = 0 - top;
16300
- const maxYWithPadding = height + bottom;
16301
16008
  let dx = 0;
16302
16009
  let dy = 0;
16303
- if (minX < minXWithPadding && maxX - minX <= width) {
16010
+ if (minX < 0 && maxX - minX <= width) {
16304
16011
  dx = -minX;
16305
16012
  }
16306
- else if (maxX > maxXWithPadding && minX - (maxX - width) >= minXWithPadding) {
16013
+ else if (maxX > width && minX - (maxX - width) >= 0) {
16307
16014
  dx = width - maxX;
16308
16015
  }
16309
- if (minY < minYWithPadding && maxY - minY <= height) {
16016
+ if (minY < 0 && maxY - minY <= height) {
16310
16017
  dy = -minY;
16311
16018
  }
16312
- else if (maxY > maxYWithPadding && minY - (maxY - height) >= minYWithPadding) {
16019
+ else if (maxY > height && minY - (maxY - height) >= 0) {
16313
16020
  dy = height - maxY;
16314
16021
  }
16315
16022
  return { dx, dy };
@@ -16609,121 +16316,56 @@ function loadLabelComponent() {
16609
16316
  registerLine();
16610
16317
  }
16611
16318
 
16612
- const isIntersect = (top, bottom) => {
16613
- return Math.ceil(top) > Math.floor(bottom);
16614
- };
16615
- const isXIntersect = ([a, b], [c, d]) => {
16616
- return d > a && b > c;
16617
- };
16618
- function getIntersectionLength(range1, range2) {
16619
- const [start1, end1] = range1;
16620
- const [start2, end2] = range2;
16621
- const start = Math.max(start1, start2);
16622
- const end = Math.min(end1, end2);
16623
- return Math.max(0, end - start);
16624
- }
16625
- function shiftY(texts, option) {
16626
- const { maxIterations = 10, maxError = 0.1, padding = 1, maxY = Number.MAX_VALUE, labelling } = option;
16319
+ function shiftY(texts, option = {}) {
16320
+ const { maxIterations = 10, maxError = 0.1, padding = 1, maxY = Number.MAX_VALUE } = option;
16627
16321
  const n = texts.length;
16628
16322
  if (n <= 1) {
16629
16323
  return texts;
16630
16324
  }
16631
- const xMap = new Map();
16325
+ const isIntersect = ([a, b], [c, d]) => {
16326
+ return d > a && b > c;
16327
+ };
16632
16328
  const textInformation = new Map();
16633
- const getY1Initial = (text) => textInformation.get(text).y1Initial;
16634
- const getHeight = (text) => textInformation.get(text).height;
16635
- const getY1 = (text) => textInformation.get(text).y1;
16329
+ const getY0 = (text) => textInformation.get(text).y0;
16636
16330
  const getY = (text) => textInformation.get(text).y;
16637
- const getX = (text) => textInformation.get(text).x;
16331
+ const getHeight = (text) => textInformation.get(text).height;
16638
16332
  const getX1 = (text) => textInformation.get(text).x1;
16639
16333
  const getX2 = (text) => textInformation.get(text).x2;
16640
- const setY1 = (text, y) => {
16641
- textInformation.get(text).y1 = y;
16334
+ const setY = (text, y) => {
16335
+ textInformation.get(text).y = y;
16642
16336
  };
16643
- function adjustPositionInOneGroup(texts) {
16644
- if (texts.length === 1) {
16645
- return;
16646
- }
16647
- for (let i = texts.length - 1; i > 0; i--) {
16648
- const curText = texts[i];
16649
- const upperText = texts[i - 1];
16650
- const lowerText = texts[i + 1];
16651
- if (isIntersect(getY1(upperText) + getHeight(upperText), getY1(curText))) {
16652
- const { y } = labelling(curText);
16653
- if (!lowerText || !isIntersect(y + getHeight(curText) / 2, getY1(lowerText))) {
16654
- if (y + getHeight(curText) / 2 <= maxY) {
16655
- setY1(curText, getY1(curText) + y - getY(curText));
16656
- }
16657
- }
16658
- }
16659
- }
16660
- }
16661
- texts.sort((a, b) => a.attribute.x - b.attribute.x);
16662
16337
  for (const text of texts) {
16663
16338
  const { y1, y2, x1, x2 } = text.AABBBounds;
16664
- const { x, y } = text.attribute;
16665
- textInformation.set(text, { y1Initial: y1, y1, y2, y, height: y2 - y1, x1, x2, x });
16666
- let hasRange = false;
16667
- for (const [range, xGroupTexts] of xMap) {
16668
- const { start, end } = range;
16669
- if (x1 >= start && x2 <= end) {
16670
- xGroupTexts.push(text);
16671
- hasRange = true;
16672
- }
16673
- else if (isNumberClose(x, getX(xGroupTexts[0]), undefined, 5)) {
16674
- const newRange = { start: Math.min(start, x1), end: Math.max(end, x2) };
16675
- xGroupTexts.push(text);
16676
- xMap.set(newRange, xGroupTexts);
16677
- xMap.delete(range);
16678
- hasRange = true;
16679
- }
16680
- else if (getIntersectionLength([start, end], [x1, x2]) / (end - start) > 0.5) {
16681
- const newRange = { start: Math.min(start, x1), end: Math.max(end, x2) };
16682
- xGroupTexts.push(text);
16683
- xMap.set(newRange, xGroupTexts);
16684
- xMap.delete(range);
16685
- hasRange = true;
16686
- }
16687
- if (hasRange) {
16688
- break;
16689
- }
16690
- }
16691
- if (!hasRange) {
16692
- xMap.set({ start: x1, end: x2 }, [text]);
16693
- }
16694
- }
16695
- for (const xTexts of xMap.values()) {
16696
- xTexts.sort((a, b) => getY1Initial(a) - getY1Initial(b));
16697
- adjustPositionInOneGroup(xTexts);
16339
+ textInformation.set(text, { y0: y1, y: y1, height: y2 - y1, x1, x2 });
16698
16340
  }
16699
16341
  for (let iter = 0; iter < maxIterations; iter++) {
16700
- texts.sort((a, b) => getY1(a) - getY1(b));
16342
+ texts.sort((a, b) => getY(a) - getY(b));
16701
16343
  let error = 0;
16702
16344
  for (let i = 0; i < n - 1; i++) {
16703
16345
  const curText = texts[i];
16704
16346
  let j = i + 1;
16705
16347
  let nextText;
16706
16348
  while ((nextText = texts[j]) &&
16707
- !isXIntersect([getX1(curText), getX2(curText)], [getX1(nextText), getX2(nextText)])) {
16349
+ !isIntersect([getX1(curText), getX2(curText)], [getX1(nextText), getX2(nextText)])) {
16708
16350
  j += 1;
16709
16351
  }
16710
16352
  if (nextText) {
16711
- const y1 = getY1(curText);
16353
+ const y0 = getY(curText);
16712
16354
  const h0 = getHeight(curText);
16713
- const nextY1 = getY1(nextText);
16714
- const delta = nextY1 - (y1 + h0);
16355
+ const y1 = getY(nextText);
16356
+ const delta = y1 - (y0 + h0);
16715
16357
  if (delta < padding) {
16716
16358
  const newDelta = (padding - delta) / 2;
16717
16359
  error = Math.max(error, newDelta);
16718
16360
  if (y1 + newDelta + getHeight(nextText) > maxY) {
16719
- setY1(curText, y1 - (padding - delta));
16361
+ setY(curText, y0 - (padding - delta));
16720
16362
  }
16721
- else if (y1 - newDelta < 0) {
16722
- setY1(nextText, nextY1 + (padding - delta));
16363
+ else if (y0 - newDelta < 0) {
16364
+ setY(nextText, y1 + (padding - delta));
16723
16365
  }
16724
16366
  else {
16725
- setY1(curText, y1 - newDelta);
16726
- setY1(nextText, nextY1 + newDelta);
16367
+ setY(curText, y0 - newDelta);
16368
+ setY(nextText, y1 + newDelta);
16727
16369
  }
16728
16370
  }
16729
16371
  }
@@ -16733,25 +16375,10 @@ function shiftY(texts, option) {
16733
16375
  }
16734
16376
  }
16735
16377
  for (const text of texts) {
16736
- const finalY = text.attribute.y + getY1(text) - getY1Initial(text);
16378
+ const finalY = text.attribute.y + getY(text) - getY0(text);
16737
16379
  text.setAttribute('y', finalY);
16738
16380
  }
16739
- const result = [];
16740
- texts.sort((a, b) => a.attribute.x - b.attribute.x);
16741
- let start = 0;
16742
- let end = texts.length - 1;
16743
- while (start <= end) {
16744
- if (start === end) {
16745
- result.push(texts[start]);
16746
- }
16747
- else {
16748
- result.push(texts[start]);
16749
- result.push(texts[end]);
16750
- }
16751
- start++;
16752
- end--;
16753
- }
16754
- return result;
16381
+ return texts;
16755
16382
  }
16756
16383
 
16757
16384
  loadLabelComponent();
@@ -17097,25 +16724,18 @@ class LabelBase extends AbstractComponent {
17097
16724
  if (clampForce) {
17098
16725
  for (let i = 0; i < result.length; i++) {
17099
16726
  const text = labels[i];
17100
- const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
16727
+ const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
17101
16728
  if (dx !== 0 || dy !== 0) {
17102
16729
  text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });
17103
- text._isClamped = true;
17104
16730
  }
17105
16731
  }
17106
16732
  }
17107
- result = shiftY(result, Object.assign(Object.assign({ maxY: bmpTool.height }, strategy), { labelling: (text) => {
17108
- const baseMark = this.getRelatedGraphic(text.attribute);
17109
- const graphicBound = this._isCollectionBase
17110
- ? this.getGraphicBounds(null, this._idToPoint.get(text.attribute.id))
17111
- : this.getGraphicBounds(baseMark, text);
17112
- return this.labeling(text.AABBBounds, graphicBound, 'bottom', this.attribute.offset);
17113
- } }));
16733
+ result = shiftY(result, Object.assign({ maxY: bmpTool.height }, strategy));
17114
16734
  for (let i = 0; i < result.length; i++) {
17115
16735
  const text = result[i];
17116
16736
  const bounds = text.AABBBounds;
17117
16737
  const range = boundToRange(bmpTool, bounds, true);
17118
- if (canPlace(bmpTool, bitmap, bounds, clampForce, text._isClamped ? 0 : overlapPadding)) {
16738
+ if (canPlace(bmpTool, bitmap, bounds, clampForce, overlapPadding)) {
17119
16739
  bitmap.setRange(range);
17120
16740
  }
17121
16741
  else {
@@ -17188,7 +16808,7 @@ class LabelBase extends AbstractComponent {
17188
16808
  }
17189
16809
  }
17190
16810
  if (!hasPlace && clampForce) {
17191
- const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
16811
+ const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
17192
16812
  if (dx === 0 && dy === 0) {
17193
16813
  if (canPlace(bmpTool, bitmap, text.AABBBounds)) {
17194
16814
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
@@ -17672,9 +17292,6 @@ class ArcLabel extends LabelBase {
17672
17292
  this._alignOffset = 0;
17673
17293
  }
17674
17294
  _overlapping(labels) {
17675
- if (['inside', 'inside-center'].includes(this.attribute.position)) {
17676
- return super._overlapping(labels);
17677
- }
17678
17295
  return labels;
17679
17296
  }
17680
17297
  labeling(textBounds, graphicBounds, position = 'outside', offset = 0) {
@@ -29941,6 +29558,690 @@ EmptyTip.defaultAttributes = {
29941
29558
  }
29942
29559
  };
29943
29560
 
29944
- const version = "0.21.0-alpha.12";
29561
+ var lib$1 = {};
29562
+
29563
+ var gif = {};
29564
+
29565
+ var lib = {};
29566
+
29567
+ Object.defineProperty(lib, "__esModule", {
29568
+ value: true
29569
+ });
29570
+ lib.loop = lib.conditional = lib.parse = void 0;
29571
+ var parse = function parse(stream, schema) {
29572
+ var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
29573
+ var parent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : result;
29574
+ if (Array.isArray(schema)) {
29575
+ schema.forEach(function (partSchema) {
29576
+ return parse(stream, partSchema, result, parent);
29577
+ });
29578
+ } else if (typeof schema === 'function') {
29579
+ schema(stream, result, parent, parse);
29580
+ } else {
29581
+ var key = Object.keys(schema)[0];
29582
+ if (Array.isArray(schema[key])) {
29583
+ parent[key] = {};
29584
+ parse(stream, schema[key], result, parent[key]);
29585
+ } else {
29586
+ parent[key] = schema[key](stream, result, parent, parse);
29587
+ }
29588
+ }
29589
+ return result;
29590
+ };
29591
+ lib.parse = parse;
29592
+ var conditional = function conditional(schema, conditionFunc) {
29593
+ return function (stream, result, parent, parse) {
29594
+ if (conditionFunc(stream, result, parent)) {
29595
+ parse(stream, schema, result, parent);
29596
+ }
29597
+ };
29598
+ };
29599
+ lib.conditional = conditional;
29600
+ var loop = function loop(schema, continueFunc) {
29601
+ return function (stream, result, parent, parse) {
29602
+ var arr = [];
29603
+ var lastStreamPos = stream.pos;
29604
+ while (continueFunc(stream, result, parent)) {
29605
+ var newParent = {};
29606
+ parse(stream, schema, result, newParent); // cases when whole file is parsed but no termination is there and stream position is not getting updated as well
29607
+ // it falls into infinite recursion, null check to avoid the same
29608
+
29609
+ if (stream.pos === lastStreamPos) {
29610
+ break;
29611
+ }
29612
+ lastStreamPos = stream.pos;
29613
+ arr.push(newParent);
29614
+ }
29615
+ return arr;
29616
+ };
29617
+ };
29618
+ lib.loop = loop;
29619
+
29620
+ var uint8 = {};
29621
+
29622
+ Object.defineProperty(uint8, "__esModule", {
29623
+ value: true
29624
+ });
29625
+ uint8.readBits = uint8.readArray = uint8.readUnsigned = uint8.readString = uint8.peekBytes = uint8.readBytes = uint8.peekByte = uint8.readByte = uint8.buildStream = void 0;
29626
+
29627
+ // Default stream and parsers for Uint8TypedArray data type
29628
+ var buildStream = function buildStream(uint8Data) {
29629
+ return {
29630
+ data: uint8Data,
29631
+ pos: 0
29632
+ };
29633
+ };
29634
+ uint8.buildStream = buildStream;
29635
+ var readByte = function readByte() {
29636
+ return function (stream) {
29637
+ return stream.data[stream.pos++];
29638
+ };
29639
+ };
29640
+ uint8.readByte = readByte;
29641
+ var peekByte = function peekByte() {
29642
+ var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
29643
+ return function (stream) {
29644
+ return stream.data[stream.pos + offset];
29645
+ };
29646
+ };
29647
+ uint8.peekByte = peekByte;
29648
+ var readBytes = function readBytes(length) {
29649
+ return function (stream) {
29650
+ return stream.data.subarray(stream.pos, stream.pos += length);
29651
+ };
29652
+ };
29653
+ uint8.readBytes = readBytes;
29654
+ var peekBytes = function peekBytes(length) {
29655
+ return function (stream) {
29656
+ return stream.data.subarray(stream.pos, stream.pos + length);
29657
+ };
29658
+ };
29659
+ uint8.peekBytes = peekBytes;
29660
+ var readString = function readString(length) {
29661
+ return function (stream) {
29662
+ return Array.from(readBytes(length)(stream)).map(function (value) {
29663
+ return String.fromCharCode(value);
29664
+ }).join('');
29665
+ };
29666
+ };
29667
+ uint8.readString = readString;
29668
+ var readUnsigned = function readUnsigned(littleEndian) {
29669
+ return function (stream) {
29670
+ var bytes = readBytes(2)(stream);
29671
+ return littleEndian ? (bytes[1] << 8) + bytes[0] : (bytes[0] << 8) + bytes[1];
29672
+ };
29673
+ };
29674
+ uint8.readUnsigned = readUnsigned;
29675
+ var readArray = function readArray(byteSize, totalOrFunc) {
29676
+ return function (stream, result, parent) {
29677
+ var total = typeof totalOrFunc === 'function' ? totalOrFunc(stream, result, parent) : totalOrFunc;
29678
+ var parser = readBytes(byteSize);
29679
+ var arr = new Array(total);
29680
+ for (var i = 0; i < total; i++) {
29681
+ arr[i] = parser(stream);
29682
+ }
29683
+ return arr;
29684
+ };
29685
+ };
29686
+ uint8.readArray = readArray;
29687
+ var subBitsTotal = function subBitsTotal(bits, startIndex, length) {
29688
+ var result = 0;
29689
+ for (var i = 0; i < length; i++) {
29690
+ result += bits[startIndex + i] && Math.pow(2, length - i - 1);
29691
+ }
29692
+ return result;
29693
+ };
29694
+ var readBits = function readBits(schema) {
29695
+ return function (stream) {
29696
+ var _byte = readByte()(stream); // convert the byte to bit array
29697
+
29698
+ var bits = new Array(8);
29699
+ for (var i = 0; i < 8; i++) {
29700
+ bits[7 - i] = !!(_byte & 1 << i);
29701
+ } // convert the bit array to values based on the schema
29702
+
29703
+ return Object.keys(schema).reduce(function (res, key) {
29704
+ var def = schema[key];
29705
+ if (def.length) {
29706
+ res[key] = subBitsTotal(bits, def.index, def.length);
29707
+ } else {
29708
+ res[key] = bits[def.index];
29709
+ }
29710
+ return res;
29711
+ }, {});
29712
+ };
29713
+ };
29714
+ uint8.readBits = readBits;
29715
+
29716
+ (function (exports) {
29717
+
29718
+ Object.defineProperty(exports, "__esModule", {
29719
+ value: true
29720
+ });
29721
+ exports["default"] = void 0;
29722
+ var _ = lib;
29723
+ var _uint = uint8;
29724
+
29725
+ // a set of 0x00 terminated subblocks
29726
+ var subBlocksSchema = {
29727
+ blocks: function blocks(stream) {
29728
+ var terminator = 0x00;
29729
+ var chunks = [];
29730
+ var streamSize = stream.data.length;
29731
+ var total = 0;
29732
+ for (var size = (0, _uint.readByte)()(stream); size !== terminator; size = (0, _uint.readByte)()(stream)) {
29733
+ // size becomes undefined for some case when file is corrupted and terminator is not proper
29734
+ // null check to avoid recursion
29735
+ if (!size) break; // catch corrupted files with no terminator
29736
+
29737
+ if (stream.pos + size >= streamSize) {
29738
+ var availableSize = streamSize - stream.pos;
29739
+ chunks.push((0, _uint.readBytes)(availableSize)(stream));
29740
+ total += availableSize;
29741
+ break;
29742
+ }
29743
+ chunks.push((0, _uint.readBytes)(size)(stream));
29744
+ total += size;
29745
+ }
29746
+ var result = new Uint8Array(total);
29747
+ var offset = 0;
29748
+ for (var i = 0; i < chunks.length; i++) {
29749
+ result.set(chunks[i], offset);
29750
+ offset += chunks[i].length;
29751
+ }
29752
+ return result;
29753
+ }
29754
+ }; // global control extension
29755
+
29756
+ var gceSchema = (0, _.conditional)({
29757
+ gce: [{
29758
+ codes: (0, _uint.readBytes)(2)
29759
+ }, {
29760
+ byteSize: (0, _uint.readByte)()
29761
+ }, {
29762
+ extras: (0, _uint.readBits)({
29763
+ future: {
29764
+ index: 0,
29765
+ length: 3
29766
+ },
29767
+ disposal: {
29768
+ index: 3,
29769
+ length: 3
29770
+ },
29771
+ userInput: {
29772
+ index: 6
29773
+ },
29774
+ transparentColorGiven: {
29775
+ index: 7
29776
+ }
29777
+ })
29778
+ }, {
29779
+ delay: (0, _uint.readUnsigned)(true)
29780
+ }, {
29781
+ transparentColorIndex: (0, _uint.readByte)()
29782
+ }, {
29783
+ terminator: (0, _uint.readByte)()
29784
+ }]
29785
+ }, function (stream) {
29786
+ var codes = (0, _uint.peekBytes)(2)(stream);
29787
+ return codes[0] === 0x21 && codes[1] === 0xf9;
29788
+ }); // image pipeline block
29789
+
29790
+ var imageSchema = (0, _.conditional)({
29791
+ image: [{
29792
+ code: (0, _uint.readByte)()
29793
+ }, {
29794
+ descriptor: [{
29795
+ left: (0, _uint.readUnsigned)(true)
29796
+ }, {
29797
+ top: (0, _uint.readUnsigned)(true)
29798
+ }, {
29799
+ width: (0, _uint.readUnsigned)(true)
29800
+ }, {
29801
+ height: (0, _uint.readUnsigned)(true)
29802
+ }, {
29803
+ lct: (0, _uint.readBits)({
29804
+ exists: {
29805
+ index: 0
29806
+ },
29807
+ interlaced: {
29808
+ index: 1
29809
+ },
29810
+ sort: {
29811
+ index: 2
29812
+ },
29813
+ future: {
29814
+ index: 3,
29815
+ length: 2
29816
+ },
29817
+ size: {
29818
+ index: 5,
29819
+ length: 3
29820
+ }
29821
+ })
29822
+ }]
29823
+ }, (0, _.conditional)({
29824
+ lct: (0, _uint.readArray)(3, function (stream, result, parent) {
29825
+ return Math.pow(2, parent.descriptor.lct.size + 1);
29826
+ })
29827
+ }, function (stream, result, parent) {
29828
+ return parent.descriptor.lct.exists;
29829
+ }), {
29830
+ data: [{
29831
+ minCodeSize: (0, _uint.readByte)()
29832
+ }, subBlocksSchema]
29833
+ }]
29834
+ }, function (stream) {
29835
+ return (0, _uint.peekByte)()(stream) === 0x2c;
29836
+ }); // plain text block
29837
+
29838
+ var textSchema = (0, _.conditional)({
29839
+ text: [{
29840
+ codes: (0, _uint.readBytes)(2)
29841
+ }, {
29842
+ blockSize: (0, _uint.readByte)()
29843
+ }, {
29844
+ preData: function preData(stream, result, parent) {
29845
+ return (0, _uint.readBytes)(parent.text.blockSize)(stream);
29846
+ }
29847
+ }, subBlocksSchema]
29848
+ }, function (stream) {
29849
+ var codes = (0, _uint.peekBytes)(2)(stream);
29850
+ return codes[0] === 0x21 && codes[1] === 0x01;
29851
+ }); // application block
29852
+
29853
+ var applicationSchema = (0, _.conditional)({
29854
+ application: [{
29855
+ codes: (0, _uint.readBytes)(2)
29856
+ }, {
29857
+ blockSize: (0, _uint.readByte)()
29858
+ }, {
29859
+ id: function id(stream, result, parent) {
29860
+ return (0, _uint.readString)(parent.blockSize)(stream);
29861
+ }
29862
+ }, subBlocksSchema]
29863
+ }, function (stream) {
29864
+ var codes = (0, _uint.peekBytes)(2)(stream);
29865
+ return codes[0] === 0x21 && codes[1] === 0xff;
29866
+ }); // comment block
29867
+
29868
+ var commentSchema = (0, _.conditional)({
29869
+ comment: [{
29870
+ codes: (0, _uint.readBytes)(2)
29871
+ }, subBlocksSchema]
29872
+ }, function (stream) {
29873
+ var codes = (0, _uint.peekBytes)(2)(stream);
29874
+ return codes[0] === 0x21 && codes[1] === 0xfe;
29875
+ });
29876
+ var schema = [{
29877
+ header: [{
29878
+ signature: (0, _uint.readString)(3)
29879
+ }, {
29880
+ version: (0, _uint.readString)(3)
29881
+ }]
29882
+ }, {
29883
+ lsd: [{
29884
+ width: (0, _uint.readUnsigned)(true)
29885
+ }, {
29886
+ height: (0, _uint.readUnsigned)(true)
29887
+ }, {
29888
+ gct: (0, _uint.readBits)({
29889
+ exists: {
29890
+ index: 0
29891
+ },
29892
+ resolution: {
29893
+ index: 1,
29894
+ length: 3
29895
+ },
29896
+ sort: {
29897
+ index: 4
29898
+ },
29899
+ size: {
29900
+ index: 5,
29901
+ length: 3
29902
+ }
29903
+ })
29904
+ }, {
29905
+ backgroundColorIndex: (0, _uint.readByte)()
29906
+ }, {
29907
+ pixelAspectRatio: (0, _uint.readByte)()
29908
+ }]
29909
+ }, (0, _.conditional)({
29910
+ gct: (0, _uint.readArray)(3, function (stream, result) {
29911
+ return Math.pow(2, result.lsd.gct.size + 1);
29912
+ })
29913
+ }, function (stream, result) {
29914
+ return result.lsd.gct.exists;
29915
+ }),
29916
+ // content frames
29917
+ {
29918
+ frames: (0, _.loop)([gceSchema, applicationSchema, commentSchema, imageSchema, textSchema], function (stream) {
29919
+ var nextCode = (0, _uint.peekByte)()(stream); // rather than check for a terminator, we should check for the existence
29920
+ // of an ext or image block to avoid infinite loops
29921
+ //var terminator = 0x3B;
29922
+ //return nextCode !== terminator;
29923
+
29924
+ return nextCode === 0x21 || nextCode === 0x2c;
29925
+ })
29926
+ }];
29927
+ var _default = schema;
29928
+ exports["default"] = _default;
29929
+ })(gif);
29930
+
29931
+ var deinterlace$1 = {};
29932
+
29933
+ Object.defineProperty(deinterlace$1, "__esModule", {
29934
+ value: true
29935
+ });
29936
+ deinterlace$1.deinterlace = void 0;
29937
+
29938
+ /**
29939
+ * Deinterlace function from https://github.com/shachaf/jsgif
29940
+ */
29941
+ var deinterlace = function deinterlace(pixels, width) {
29942
+ var newPixels = new Array(pixels.length);
29943
+ var rows = pixels.length / width;
29944
+ var cpRow = function cpRow(toRow, fromRow) {
29945
+ var fromPixels = pixels.slice(fromRow * width, (fromRow + 1) * width);
29946
+ newPixels.splice.apply(newPixels, [toRow * width, width].concat(fromPixels));
29947
+ }; // See appendix E.
29948
+
29949
+ var offsets = [0, 4, 2, 1];
29950
+ var steps = [8, 8, 4, 2];
29951
+ var fromRow = 0;
29952
+ for (var pass = 0; pass < 4; pass++) {
29953
+ for (var toRow = offsets[pass]; toRow < rows; toRow += steps[pass]) {
29954
+ cpRow(toRow, fromRow);
29955
+ fromRow++;
29956
+ }
29957
+ }
29958
+ return newPixels;
29959
+ };
29960
+ deinterlace$1.deinterlace = deinterlace;
29961
+
29962
+ var lzw$1 = {};
29963
+
29964
+ Object.defineProperty(lzw$1, "__esModule", {
29965
+ value: true
29966
+ });
29967
+ lzw$1.lzw = void 0;
29968
+
29969
+ /**
29970
+ * javascript port of java LZW decompression
29971
+ * Original java author url: https://gist.github.com/devunwired/4479231
29972
+ */
29973
+ var lzw = function lzw(minCodeSize, data, pixelCount) {
29974
+ var MAX_STACK_SIZE = 4096;
29975
+ var nullCode = -1;
29976
+ var npix = pixelCount;
29977
+ var available, clear, code_mask, code_size, end_of_information, in_code, old_code, bits, code, i, datum, data_size, first, top, bi, pi;
29978
+ var dstPixels = new Array(pixelCount);
29979
+ var prefix = new Array(MAX_STACK_SIZE);
29980
+ var suffix = new Array(MAX_STACK_SIZE);
29981
+ var pixelStack = new Array(MAX_STACK_SIZE + 1); // Initialize GIF data stream decoder.
29982
+
29983
+ data_size = minCodeSize;
29984
+ clear = 1 << data_size;
29985
+ end_of_information = clear + 1;
29986
+ available = clear + 2;
29987
+ old_code = nullCode;
29988
+ code_size = data_size + 1;
29989
+ code_mask = (1 << code_size) - 1;
29990
+ for (code = 0; code < clear; code++) {
29991
+ prefix[code] = 0;
29992
+ suffix[code] = code;
29993
+ } // Decode GIF pixel stream.
29994
+
29995
+ var datum, bits, first, top, pi, bi;
29996
+ datum = bits = first = top = pi = bi = 0;
29997
+ for (i = 0; i < npix;) {
29998
+ if (top === 0) {
29999
+ if (bits < code_size) {
30000
+ // get the next byte
30001
+ datum += data[bi] << bits;
30002
+ bits += 8;
30003
+ bi++;
30004
+ continue;
30005
+ } // Get the next code.
30006
+
30007
+ code = datum & code_mask;
30008
+ datum >>= code_size;
30009
+ bits -= code_size; // Interpret the code
30010
+
30011
+ if (code > available || code == end_of_information) {
30012
+ break;
30013
+ }
30014
+ if (code == clear) {
30015
+ // Reset decoder.
30016
+ code_size = data_size + 1;
30017
+ code_mask = (1 << code_size) - 1;
30018
+ available = clear + 2;
30019
+ old_code = nullCode;
30020
+ continue;
30021
+ }
30022
+ if (old_code == nullCode) {
30023
+ pixelStack[top++] = suffix[code];
30024
+ old_code = code;
30025
+ first = code;
30026
+ continue;
30027
+ }
30028
+ in_code = code;
30029
+ if (code == available) {
30030
+ pixelStack[top++] = first;
30031
+ code = old_code;
30032
+ }
30033
+ while (code > clear) {
30034
+ pixelStack[top++] = suffix[code];
30035
+ code = prefix[code];
30036
+ }
30037
+ first = suffix[code] & 0xff;
30038
+ pixelStack[top++] = first; // add a new string to the table, but only if space is available
30039
+ // if not, just continue with current table until a clear code is found
30040
+ // (deferred clear code implementation as per GIF spec)
30041
+
30042
+ if (available < MAX_STACK_SIZE) {
30043
+ prefix[available] = old_code;
30044
+ suffix[available] = first;
30045
+ available++;
30046
+ if ((available & code_mask) === 0 && available < MAX_STACK_SIZE) {
30047
+ code_size++;
30048
+ code_mask += available;
30049
+ }
30050
+ }
30051
+ old_code = in_code;
30052
+ } // Pop a pixel off the pixel stack.
30053
+
30054
+ top--;
30055
+ dstPixels[pi++] = pixelStack[top];
30056
+ i++;
30057
+ }
30058
+ for (i = pi; i < npix; i++) {
30059
+ dstPixels[i] = 0; // clear missing pixels
30060
+ }
30061
+
30062
+ return dstPixels;
30063
+ };
30064
+ lzw$1.lzw = lzw;
30065
+
30066
+ Object.defineProperty(lib$1, "__esModule", {
30067
+ value: true
30068
+ });
30069
+ var decompressFrames_1 = lib$1.decompressFrames = lib$1.decompressFrame = parseGIF_1 = lib$1.parseGIF = void 0;
30070
+ var _gif = _interopRequireDefault(gif);
30071
+ var _jsBinarySchemaParser = lib;
30072
+ var _uint = uint8;
30073
+ var _deinterlace = deinterlace$1;
30074
+ var _lzw = lzw$1;
30075
+ function _interopRequireDefault(obj) {
30076
+ return obj && obj.__esModule ? obj : {
30077
+ "default": obj
30078
+ };
30079
+ }
30080
+ var parseGIF = function parseGIF(arrayBuffer) {
30081
+ var byteData = new Uint8Array(arrayBuffer);
30082
+ return (0, _jsBinarySchemaParser.parse)((0, _uint.buildStream)(byteData), _gif["default"]);
30083
+ };
30084
+ var parseGIF_1 = lib$1.parseGIF = parseGIF;
30085
+ var generatePatch = function generatePatch(image) {
30086
+ var totalPixels = image.pixels.length;
30087
+ var patchData = new Uint8ClampedArray(totalPixels * 4);
30088
+ for (var i = 0; i < totalPixels; i++) {
30089
+ var pos = i * 4;
30090
+ var colorIndex = image.pixels[i];
30091
+ var color = image.colorTable[colorIndex] || [0, 0, 0];
30092
+ patchData[pos] = color[0];
30093
+ patchData[pos + 1] = color[1];
30094
+ patchData[pos + 2] = color[2];
30095
+ patchData[pos + 3] = colorIndex !== image.transparentIndex ? 255 : 0;
30096
+ }
30097
+ return patchData;
30098
+ };
30099
+ var decompressFrame = function decompressFrame(frame, gct, buildImagePatch) {
30100
+ if (!frame.image) {
30101
+ console.warn('gif frame does not have associated image.');
30102
+ return;
30103
+ }
30104
+ var image = frame.image; // get the number of pixels
30105
+
30106
+ var totalPixels = image.descriptor.width * image.descriptor.height; // do lzw decompression
30107
+
30108
+ var pixels = (0, _lzw.lzw)(image.data.minCodeSize, image.data.blocks, totalPixels); // deal with interlacing if necessary
30109
+
30110
+ if (image.descriptor.lct.interlaced) {
30111
+ pixels = (0, _deinterlace.deinterlace)(pixels, image.descriptor.width);
30112
+ }
30113
+ var resultImage = {
30114
+ pixels: pixels,
30115
+ dims: {
30116
+ top: frame.image.descriptor.top,
30117
+ left: frame.image.descriptor.left,
30118
+ width: frame.image.descriptor.width,
30119
+ height: frame.image.descriptor.height
30120
+ }
30121
+ }; // color table
30122
+
30123
+ if (image.descriptor.lct && image.descriptor.lct.exists) {
30124
+ resultImage.colorTable = image.lct;
30125
+ } else {
30126
+ resultImage.colorTable = gct;
30127
+ } // add per frame relevant gce information
30128
+
30129
+ if (frame.gce) {
30130
+ resultImage.delay = (frame.gce.delay || 10) * 10; // convert to ms
30131
+
30132
+ resultImage.disposalType = frame.gce.extras.disposal; // transparency
30133
+
30134
+ if (frame.gce.extras.transparentColorGiven) {
30135
+ resultImage.transparentIndex = frame.gce.transparentColorIndex;
30136
+ }
30137
+ } // create canvas usable imagedata if desired
30138
+
30139
+ if (buildImagePatch) {
30140
+ resultImage.patch = generatePatch(resultImage);
30141
+ }
30142
+ return resultImage;
30143
+ };
30144
+ lib$1.decompressFrame = decompressFrame;
30145
+ var decompressFrames = function decompressFrames(parsedGif, buildImagePatches) {
30146
+ return parsedGif.frames.filter(function (f) {
30147
+ return f.image;
30148
+ }).map(function (f) {
30149
+ return decompressFrame(f, parsedGif.gct, buildImagePatches);
30150
+ });
30151
+ };
30152
+ decompressFrames_1 = lib$1.decompressFrames = decompressFrames;
30153
+
30154
+ class GifImage extends Image {
30155
+ constructor(params) {
30156
+ super(params);
30157
+ this.isGifImage = true;
30158
+ this.loadGif();
30159
+ }
30160
+ loadGif() {
30161
+ if (isString(this.attribute.gifImage)) {
30162
+ ResourceLoader.GetFile(this.attribute.gifImage, 'arrayBuffer')
30163
+ .then((res) => {
30164
+ const gif = parseGIF_1(res);
30165
+ const frames = decompressFrames_1(gif, true);
30166
+ this.renderGIF(frames);
30167
+ })
30168
+ .catch(e => {
30169
+ console.error('Gif load error: ', e);
30170
+ });
30171
+ }
30172
+ else if (this.attribute.gifImage instanceof ArrayBuffer) {
30173
+ const gif = parseGIF_1(this.attribute.gifImage);
30174
+ const frames = decompressFrames_1(gif, true);
30175
+ this.renderGIF(frames);
30176
+ }
30177
+ }
30178
+ renderGIF(frames) {
30179
+ this.loadedFrames = frames;
30180
+ this.frameIndex = 0;
30181
+ if (!this.tempCanvas) {
30182
+ this.tempCanvas = application.global.createCanvas({});
30183
+ this.tempCtx = this.tempCanvas.getContext('2d');
30184
+ }
30185
+ if (!this.gifCanvas) {
30186
+ this.gifCanvas = application.global.createCanvas({});
30187
+ this.gifCtx = this.gifCanvas.getContext('2d');
30188
+ }
30189
+ this.gifCanvas.width = frames[0].dims.width;
30190
+ this.gifCanvas.height = frames[0].dims.height;
30191
+ this.playing = true;
30192
+ this.lastTime = new Date().getTime();
30193
+ const animation = this.animate();
30194
+ if (this.attribute.timeline) {
30195
+ animation.setTimeline(this.attribute.timeline);
30196
+ }
30197
+ animation.to({}, 1000, 'linear').loop(Infinity);
30198
+ }
30199
+ renderFrame(context, x, y) {
30200
+ const frame = this.loadedFrames[this.frameIndex || 0];
30201
+ if (frame.disposalType === 2) {
30202
+ this.gifCtx.clearRect(0, 0, this.gifCanvas.width, this.gifCanvas.height);
30203
+ }
30204
+ this.drawPatch(frame);
30205
+ this.manipulate(context, x, y);
30206
+ const diff = new Date().getTime() - this.lastTime;
30207
+ if (frame.delay < diff) {
30208
+ this.frameIndex++;
30209
+ this.lastTime = new Date().getTime();
30210
+ }
30211
+ if (this.frameIndex >= this.loadedFrames.length) {
30212
+ this.frameIndex = 0;
30213
+ }
30214
+ }
30215
+ drawPatch(frame) {
30216
+ const dims = frame.dims;
30217
+ if (!this.frameImageData ||
30218
+ dims.width !== this.frameImageData.width ||
30219
+ dims.height !== this.frameImageData.height) {
30220
+ this.tempCanvas.width = dims.width;
30221
+ this.tempCanvas.height = dims.height;
30222
+ this.frameImageData = this.tempCtx.createImageData(dims.width, dims.height);
30223
+ }
30224
+ this.frameImageData.data.set(frame.patch);
30225
+ this.tempCtx.putImageData(this.frameImageData, 0, 0);
30226
+ this.gifCtx.drawImage(this.tempCanvas, dims.left, dims.top);
30227
+ }
30228
+ manipulate(context, x, y) {
30229
+ context.drawImage(this.gifCanvas, 0, 0, this.gifCanvas.width, this.gifCanvas.height, x, y, this.attribute.width, this.attribute.height);
30230
+ }
30231
+ setAttribute(key, value, forceUpdateTag, context) {
30232
+ super.setAttribute(key, value, forceUpdateTag, context);
30233
+ if (key === 'gifImage') {
30234
+ this.loadGif();
30235
+ }
30236
+ }
30237
+ setAttributes(params, forceUpdateTag, context) {
30238
+ super.setAttributes(params, forceUpdateTag, context);
30239
+ if (params.gifImage) {
30240
+ this.loadGif();
30241
+ }
30242
+ }
30243
+ }
30244
+
30245
+ const version = "0.21.0-alpha.13";
29945
30246
 
29946
- export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, hasOverlap, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, loadScrollbar, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, scrollbarModule, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };
30247
+ export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GifImage, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, hasOverlap, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };